2014-06-01 17:55:23 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the DXX-Rebirth project <http://www.dxx-rebirth.com/>.
|
|
|
|
* It is copyright by its individual contributors, as recorded in the
|
|
|
|
* project's Git history. See COPYING.txt at the top level for license
|
|
|
|
* terms and a link to the Git history.
|
|
|
|
*/
|
2008-01-29 14:49:54 +00:00
|
|
|
/* interface to OpenGL functions
|
|
|
|
* Added 9/15/99 Matthew Mueller
|
|
|
|
* Got rid of OpenGL-internal stuff 2004-5-16 Martin Schaffner
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _OGL_INIT_H_
|
|
|
|
#define _OGL_INIT_H_
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#endif
|
|
|
|
|
2008-04-06 20:23:28 +00:00
|
|
|
#ifdef _WIN32
|
2008-01-29 14:49:54 +00:00
|
|
|
#include "loadgl.h"
|
|
|
|
#else
|
2008-04-24 14:27:54 +00:00
|
|
|
# define GL_GLEXT_LEGACY
|
|
|
|
# if defined(__APPLE__) && defined(__MACH__)
|
|
|
|
# include <OpenGL/gl.h>
|
|
|
|
# include <OpenGL/glu.h>
|
|
|
|
# else
|
|
|
|
# define GL_GLEXT_PROTOTYPES
|
2011-01-06 11:43:55 +00:00
|
|
|
# ifdef OGLES
|
|
|
|
# include <GLES/gl.h>
|
|
|
|
# else
|
2008-04-24 14:27:54 +00:00
|
|
|
# include <GL/gl.h>
|
2011-01-06 11:43:55 +00:00
|
|
|
# endif
|
2008-04-24 14:27:54 +00:00
|
|
|
# endif
|
|
|
|
# ifndef GL_CLAMP_TO_EDGE // hack for Mac OS 9, others?
|
|
|
|
# define GL_CLAMP_TO_EDGE GL_CLAMP
|
|
|
|
# endif
|
2008-01-29 14:49:54 +00:00
|
|
|
#endif
|
|
|
|
|
2011-01-16 00:50:28 +00:00
|
|
|
#include "gr.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "pstypes.h"
|
2012-11-11 22:12:51 +00:00
|
|
|
#include "3d.h"
|
2011-01-16 00:50:28 +00:00
|
|
|
|
2008-01-29 14:49:54 +00:00
|
|
|
#ifndef GL_VERSION_1_1
|
|
|
|
#ifdef GL_EXT_texture
|
|
|
|
#define GL_INTENSITY4 GL_INTENSITY4_EXT
|
|
|
|
#define GL_INTENSITY8 GL_INTENSITY8_EXT
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2011-01-16 00:50:28 +00:00
|
|
|
#ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
|
|
|
|
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
|
|
|
|
#endif
|
|
|
|
#ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
|
|
|
|
#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
|
|
|
|
#endif
|
2008-01-29 14:49:54 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2008-01-29 14:49:54 +00:00
|
|
|
/* we need to export ogl_texture for 2d/font.c */
|
2013-12-22 22:03:07 +00:00
|
|
|
struct ogl_texture
|
|
|
|
{
|
2008-01-29 14:49:54 +00:00
|
|
|
GLuint handle;
|
|
|
|
GLint internalformat;
|
|
|
|
GLenum format;
|
|
|
|
int w,h,tw,th,lw;
|
|
|
|
int bytesu;
|
|
|
|
int bytes;
|
|
|
|
GLfloat u,v;
|
|
|
|
GLfloat prio;
|
|
|
|
int wrapstate;
|
|
|
|
unsigned long numrend;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2008-01-29 14:49:54 +00:00
|
|
|
|
|
|
|
extern ogl_texture* ogl_get_free_texture();
|
2014-11-30 22:09:19 +00:00
|
|
|
void ogl_init_texture(ogl_texture &t, int w, int h, int flags);
|
2008-01-29 14:49:54 +00:00
|
|
|
|
|
|
|
void ogl_init_shared_palette(void);
|
|
|
|
|
|
|
|
extern int gl_initialized;
|
|
|
|
|
|
|
|
extern int active_texture_unit;
|
2011-01-16 00:50:28 +00:00
|
|
|
extern GLfloat ogl_maxanisotropy;
|
|
|
|
|
2008-01-29 14:49:54 +00:00
|
|
|
void ogl_setActiveTexture(int t);
|
|
|
|
|
|
|
|
int ogl_init_window(int x, int y);//create a window/switch modes/etc
|
|
|
|
|
|
|
|
#define OGL_FLAG_MIPMAP (1 << 0)
|
|
|
|
#define OGL_FLAG_NOCOLOR (1 << 1)
|
|
|
|
#define OGL_FLAG_ALPHA (1 << 31) // not required for ogl_loadbmtexture, since it uses the BM_FLAG_TRANSPARENT, but is needed for ogl_init_texture.
|
2014-11-13 03:42:41 +00:00
|
|
|
void ogl_loadbmtexture_f(grs_bitmap &bm, int texfilt);
|
2014-11-30 22:09:20 +00:00
|
|
|
void ogl_freebmtexture(grs_bitmap &bm);
|
2008-01-29 14:49:54 +00:00
|
|
|
|
|
|
|
void ogl_start_frame(void);
|
|
|
|
void ogl_end_frame(void);
|
|
|
|
void ogl_set_screen_mode(void);
|
|
|
|
void ogl_cache_level_textures(void);
|
|
|
|
|
|
|
|
void ogl_urect(int left, int top, int right, int bot);
|
2014-11-30 22:09:18 +00:00
|
|
|
bool ogl_ubitmapm_cs(int x, int y,int dw, int dh, grs_bitmap &bm,int c, int scale);
|
2011-01-16 00:50:28 +00:00
|
|
|
bool ogl_ubitblt_i(int dw, int dh, int dx, int dy, int sw, int sh, int sx, int sy, grs_bitmap * src, grs_bitmap * dest, int texfilt);
|
2008-01-29 14:49:54 +00:00
|
|
|
bool ogl_ubitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
|
|
|
|
void ogl_upixelc(int x, int y, int c);
|
2014-11-30 22:09:18 +00:00
|
|
|
unsigned char ogl_ugpixel(const grs_bitmap &bitmap, unsigned x, unsigned y);
|
2008-01-29 14:49:54 +00:00
|
|
|
void ogl_ulinec(int left, int top, int right, int bot, int c);
|
|
|
|
|
|
|
|
#include "3d.h"
|
2014-11-15 03:10:06 +00:00
|
|
|
void _g3_draw_tmap_2(unsigned nv, const g3s_point *const *const pointlist, const g3s_uvl *uvl_list, const g3s_lrgb *light_rgb, grs_bitmap *bmbot, grs_bitmap *bm, int orient);
|
2014-09-04 03:02:21 +00:00
|
|
|
|
|
|
|
template <std::size_t N>
|
2014-11-16 19:14:51 +00:00
|
|
|
static inline void g3_draw_tmap_2(unsigned nv, const array<cg3s_point *, N> &pointlist, const array<g3s_uvl, N> &uvl_list, const array<g3s_lrgb, N> &light_rgb, grs_bitmap *bmbot, grs_bitmap *bm, int orient)
|
2014-09-04 03:02:21 +00:00
|
|
|
{
|
|
|
|
static_assert(N <= MAX_POINTS_PER_POLY, "too many points in tmap");
|
|
|
|
#ifdef DXX_HAVE_BUILTIN_CONSTANT_P
|
|
|
|
if (__builtin_constant_p(nv) && nv > N)
|
|
|
|
DXX_ALWAYS_ERROR_FUNCTION(dxx_trap_tmap_overread, "reading beyond array");
|
|
|
|
#endif
|
2014-11-15 03:10:06 +00:00
|
|
|
_g3_draw_tmap_2(nv, &pointlist[0], &uvl_list[0], &light_rgb[0], bmbot, bm, orient);
|
2014-09-04 03:02:21 +00:00
|
|
|
}
|
2008-01-29 14:49:54 +00:00
|
|
|
|
2011-01-10 15:12:00 +00:00
|
|
|
void ogl_draw_vertex_reticle(int cross,int primary,int secondary,int color,int alpha,int size_offs);
|
2011-02-17 23:17:49 +00:00
|
|
|
void ogl_toggle_depth_test(int enable);
|
2011-02-23 16:46:36 +00:00
|
|
|
void ogl_set_blending();
|
2013-08-16 02:00:35 +00:00
|
|
|
unsigned pow2ize(unsigned x);//from ogl.c
|
2008-01-29 14:49:54 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#endif
|
|
|
|
|
2008-01-29 14:49:54 +00:00
|
|
|
#endif /* _OGL_INIT_H_ */
|