1 //prototypes opengl functions - Added 9/15/99 Matthew Mueller
11 //#define OGL_RUNTIME_LOAD
14 #ifdef OGL_RUNTIME_LOAD
16 int ogl_init_load_library(void);
19 //######hack, since multi texture support is not working
20 #undef GL_ARB_multitexture
21 #undef GL_SGIS_multitexture
24 #ifndef GL_VERSION_1_1
26 #define GL_INTENSITY4 GL_INTENSITY4_EXT
27 #define GL_INTENSITY8 GL_INTENSITY8_EXT
37 #define OGL_TEXTURE_LIST_SIZE 2000
39 typedef struct _ogl_texture {
54 extern ogl_texture ogl_texture_list[OGL_TEXTURE_LIST_SIZE];
56 extern int ogl_mem_target;
57 ogl_texture* ogl_get_free_texture(void);
58 void ogl_init_texture(ogl_texture* t);
59 void ogl_init_texture_list_internal(void);
60 void ogl_smash_texture_list_internal(void);
61 void ogl_vivify_texture_list_internal(void);
63 extern int ogl_fullscreen;
64 void ogl_do_fullscreen_internal(void);
66 extern int ogl_voodoohack;
68 extern int ogl_alttexmerge;//merge textures by just printing the seperate textures?
69 extern int ogl_rgba_format;
70 extern int ogl_intensity4_ok;
71 extern int ogl_luminance4_alpha4_ok;
72 extern int ogl_rgba2_ok;
73 extern int ogl_readpixels_ok;
74 extern int ogl_gettexlevelparam_ok;
75 #ifdef GL_ARB_multitexture
76 extern int ogl_arb_multitexture_ok;
78 #define ogl_arb_multitexture_ok 0
80 #ifdef GL_SGIS_multitexture
81 extern int ogl_sgis_multitexture_ok;
83 #define ogl_sgis_multitexture_ok 0
86 extern int gl_initialized;
87 extern int GL_texmagfilt,GL_texminfilt,GL_needmipmaps;
88 extern int gl_reticle;
90 extern int GL_TEXTURE_2D_enabled;
91 //extern int GL_texclamp_enabled;
92 //extern int GL_TEXTURE_ENV_MODE_state,GL_TEXTURE_MAG_FILTER_state,GL_TEXTURE_MIN_FILTER_state;
93 #define OGL_ENABLE2(a,f) {if (a ## _enabled!=1) {f;a ## _enabled=1;}}
94 #define OGL_DISABLE2(a,f) {if (a ## _enabled!=0) {f;a ## _enabled=0;}}
96 //#define OGL_ENABLE(a) OGL_ENABLE2(a,glEnable(a))
97 //#define OGL_DISABLE(a) OGL_DISABLE2(a,glDisable(a))
98 #define OGL_ENABLE(a) OGL_ENABLE2(GL_ ## a,glEnable(GL_ ## a))
99 #define OGL_DISABLE(a) OGL_DISABLE2(GL_ ## a,glDisable(GL_ ## a))
101 //#define OGL_TEXCLAMP() OGL_ENABLE2(GL_texclamp,glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);)
102 //#define OGL_TEXREPEAT() OGL_DISABLE2(GL_texclamp,glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);)
104 //#define OGL_SETSTATE(a,s,f) {if (a ## _state!=s) {f;a ## _state=s;}}
106 //#define OGL_TEXENV(p,m) OGL_SETSTATE(p,m,glTexEnvi(GL_TEXTURE_ENV, p,m));
107 //#define OGL_TEXPARAM(p,m) OGL_SETSTATE(p,m,glTexParameteri(GL_TEXTURE_2D,p,m));
109 extern int last_width,last_height;
110 #define OGL_VIEWPORT(x,y,w,h){if (w!=last_width || h!=last_height){glViewport(x,grd_curscreen->sc_canvas.cv_bitmap.bm_h-y-h,w,h);last_width=w;last_height=h;}}
112 //platform specific funcs
113 //MSVC seems to have problems with inline funcs not being found during linking
117 void ogl_swap_buffers_internal(void);
118 int ogl_init_window(int x, int y);//create a window/switch modes/etc
119 void ogl_destroy_window(void);//destroy window/etc
120 void ogl_init(void);//one time initialization
121 void ogl_close(void);//one time shutdown
124 //#define OGLTEXBUFSIZE (1024*1024*4)
125 #define OGLTEXBUFSIZE (2048*2048*4)
126 extern GLubyte texbuf[OGLTEXBUFSIZE];
127 //void ogl_filltexbuf(unsigned char *data,GLubyte *texp,int width,int height,int twidth,int theight);
128 void ogl_filltexbuf(unsigned char *data,GLubyte *texp,int truewidth,int width,int height,int dxo,int dyo,int twidth,int theight,int type);
129 void ogl_loadbmtexture_m(grs_bitmap *bm,int domipmap);
130 void ogl_loadbmtexture(grs_bitmap *bm);
131 //void ogl_loadtexture(unsigned char * data, int width, int height,int dxo,int dyo, int *texid,float *u,float *v,char domipmap,float prio);
132 void ogl_loadtexture(unsigned char * data, int dxo,int dyo, ogl_texture *tex);
133 void ogl_freetexture(ogl_texture *gltexture);
134 void ogl_freebmtexture(grs_bitmap *bm);
135 void ogl_do_palfx(void);
136 void ogl_start_frame(void);
137 void ogl_end_frame(void);
138 void ogl_swap_buffers(void);
139 void ogl_set_screen_mode(void);
140 void ogl_cache_level_textures(void);
142 void ogl_urect(int left,int top,int right,int bot);
143 bool ogl_ubitmapm_c(int x, int y,grs_bitmap *bm,int c);
144 bool ogl_ubitmapm(int x, int y,grs_bitmap *bm);
145 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);
146 bool ogl_ubitblt(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
147 bool ogl_ubitblt_tolinear(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
148 bool ogl_ubitblt_copy(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
149 void ogl_upixelc(int x, int y, int c);
150 void ogl_ulinec(int left,int top,int right,int bot,int c);
152 extern unsigned char *ogl_pal;
155 bool g3_draw_tmap_2(int nv,g3s_point **pointlist,g3s_uvl *uvl_list,grs_bitmap *bmbot,grs_bitmap *bm,int orient);
157 void ogl_draw_reticle(int cross,int primary,int secondary);
160 //#define PAL2Tr(c) ((gr_palette[c*3]+gr_palette_gamma)/63.0)
161 //#define PAL2Tg(c) ((gr_palette[c*3+1]+gr_palette_gamma)/63.0)
162 //#define PAL2Tb(c) ((gr_palette[c*3+2]+gr_palette_gamma)/63.0)
163 //#define PAL2Tr(c) ((gr_palette[c*3])/63.0)
164 //#define PAL2Tg(c) ((gr_palette[c*3+1])/63.0)
165 //#define PAL2Tb(c) ((gr_palette[c*3+2])/63.0)
166 #define CPAL2Tr(c) ((gr_current_pal[c*3])/63.0)
167 #define CPAL2Tg(c) ((gr_current_pal[c*3+1])/63.0)
168 #define CPAL2Tb(c) ((gr_current_pal[c*3+2])/63.0)
169 #define PAL2Tr(c) ((ogl_pal[c*3])/63.0)
170 #define PAL2Tg(c) ((ogl_pal[c*3+1])/63.0)
171 #define PAL2Tb(c) ((ogl_pal[c*3+2])/63.0)
172 //inline GLfloat PAL2Tr(int c);
173 //inline GLfloat PAL2Tg(int c);
174 //inline GLfloat PAL2Tb(int c);