]> icculus.org git repositories - btb/d2x.git/blob - include/ogl_init.h
Build fixes. EDITOR_SRCS added to libmain_a_SOURCES.
[btb/d2x.git] / include / ogl_init.h
1 //prototypes opengl functions - Added 9/15/99 Matthew Mueller
2 #ifndef _OGL_INIT_H_ 
3 #define _OGL_INIT_H_
4
5 #ifdef __WINDOWS__
6 #include <windows.h>
7 #include <stddef.h>
8 #endif
9
10 //#ifdef __WINDOWS__
11 //#define OGL_RUNTIME_LOAD
12 //#endif
13
14 #ifdef OGL_RUNTIME_LOAD
15 #include "loadgl.h"
16 int ogl_init_load_library(void);
17 #else
18 #include <GL/gl.h>
19 //######hack, since multi texture support is not working
20 #undef GL_ARB_multitexture
21 #undef GL_SGIS_multitexture
22 #endif
23
24 #ifndef GL_VERSION_1_1
25 #ifdef GL_EXT_texture
26 #define GL_INTENSITY4 GL_INTENSITY4_EXT
27 #define GL_INTENSITY8 GL_INTENSITY8_EXT
28 #endif
29 #endif
30
31
32 #include "gr.h"
33 #include "palette.h"
34 #include "pstypes.h"
35
36
37 #define OGL_TEXTURE_LIST_SIZE 2000
38
39 typedef struct _ogl_texture {
40         int handle;
41         GLint internalformat;
42         GLenum format;
43         int w,h,tw,th,lw;
44         int bytesu;
45         int bytes;
46         GLfloat u,v;
47         GLfloat prio;
48         int wrapstate;
49         fix lastrend;
50         ulong numrend;
51         char wantmip;
52 } ogl_texture;
53
54 extern ogl_texture ogl_texture_list[OGL_TEXTURE_LIST_SIZE];
55
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);
62
63 extern int ogl_fullscreen;
64 void ogl_do_fullscreen_internal(void);
65
66 extern int ogl_voodoohack;
67
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;
77 #else
78 #define ogl_arb_multitexture_ok 0
79 #endif
80 #ifdef GL_SGIS_multitexture
81 extern int ogl_sgis_multitexture_ok;
82 #else
83 #define ogl_sgis_multitexture_ok 0
84 #endif
85
86 extern int gl_initialized;
87 extern int GL_texmagfilt,GL_texminfilt,GL_needmipmaps;
88 extern int gl_reticle;
89
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;}}
95
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))
100
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);)
103
104 //#define OGL_SETSTATE(a,s,f) {if (a ## _state!=s) {f;a ## _state=s;}}
105
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));
108
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;}}
111
112 //platform specific funcs
113 //MSVC seems to have problems with inline funcs not being found during linking
114 #ifndef _MSC_VER
115 inline 
116 #endif
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
122
123 //generic funcs
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);
141
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);
151
152 extern unsigned char *ogl_pal;
153
154 #include "3d.h"
155 bool g3_draw_tmap_2(int nv,g3s_point **pointlist,g3s_uvl *uvl_list,grs_bitmap *bmbot,grs_bitmap *bm,int orient);
156
157 void ogl_draw_reticle(int cross,int primary,int secondary);
158
159 //whee
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);
175
176 #endif