]> icculus.org git repositories - btb/d2x.git/blob - include/ogl_init.h
Support for cross-compiling, and cygwin fixes
[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 #endif
20
21 #ifndef GL_VERSION_1_1
22 #ifdef GL_EXT_texture
23 #define GL_INTENSITY4 GL_INTENSITY4_EXT
24 #define GL_INTENSITY8 GL_INTENSITY8_EXT
25 #endif
26 #endif
27
28
29 #include "gr.h"
30 #include "palette.h"
31 #include "pstypes.h"
32
33
34 #define OGL_TEXTURE_LIST_SIZE 2000
35
36 typedef struct _ogl_texture {
37         int handle;
38         GLint internalformat;
39         GLenum format;
40         int w,h,tw,th,lw;
41         int bytesu;
42         int bytes;
43         GLfloat u,v;
44         GLfloat prio;
45         int wrapstate;
46         fix lastrend;
47         ulong numrend;
48         char wantmip;
49 } ogl_texture;
50
51 extern ogl_texture ogl_texture_list[OGL_TEXTURE_LIST_SIZE];
52
53 extern int ogl_mem_target;
54 ogl_texture* ogl_get_free_texture(void);
55 void ogl_init_texture(ogl_texture* t);
56 void ogl_init_texture_list_internal(void);
57 void ogl_smash_texture_list_internal(void);
58 void ogl_vivify_texture_list_internal(void);
59
60 extern int ogl_fullscreen;
61 void ogl_do_fullscreen_internal(void);
62
63 extern int ogl_voodoohack;
64
65 extern int ogl_alttexmerge;//merge textures by just printing the seperate textures?
66 extern int ogl_rgba_format;
67 extern int ogl_intensity4_ok;
68 extern int ogl_luminance4_alpha4_ok;
69 extern int ogl_rgba2_ok;
70 extern int ogl_readpixels_ok;
71
72 extern int gl_initialized;
73 extern int GL_texmagfilt,GL_texminfilt,GL_needmipmaps;
74 extern int gl_reticle;
75
76 extern int GL_TEXTURE_2D_enabled;
77 //extern int GL_texclamp_enabled;
78 //extern int GL_TEXTURE_ENV_MODE_state,GL_TEXTURE_MAG_FILTER_state,GL_TEXTURE_MIN_FILTER_state;
79 #define OGL_ENABLE2(a,f) {if (a ## _enabled!=1) {f;a ## _enabled=1;}}
80 #define OGL_DISABLE2(a,f) {if (a ## _enabled!=0) {f;a ## _enabled=0;}}
81
82 //#define OGL_ENABLE(a) OGL_ENABLE2(a,glEnable(a))
83 //#define OGL_DISABLE(a) OGL_DISABLE2(a,glDisable(a))
84 #define OGL_ENABLE(a) OGL_ENABLE2(GL_ ## a,glEnable(GL_ ## a))
85 #define OGL_DISABLE(a) OGL_DISABLE2(GL_ ## a,glDisable(GL_ ## a))
86
87 //#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);)
88 //#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);)
89
90 //#define OGL_SETSTATE(a,s,f) {if (a ## _state!=s) {f;a ## _state=s;}}
91
92 //#define OGL_TEXENV(p,m) OGL_SETSTATE(p,m,glTexEnvi(GL_TEXTURE_ENV, p,m));
93 //#define OGL_TEXPARAM(p,m) OGL_SETSTATE(p,m,glTexParameteri(GL_TEXTURE_2D,p,m));
94
95 extern int last_width,last_height;
96 #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;}}
97
98 //platform specific funcs
99 //MSVC seems to have problems with inline funcs not being found during linking
100 #ifndef _MSC_VER
101 inline 
102 #endif
103 void ogl_swap_buffers_internal(void);
104 int ogl_init_window(int x, int y);//create a window/switch modes/etc
105 void ogl_destroy_window(void);//destroy window/etc
106 void ogl_init(void);//one time initialization
107 void ogl_close(void);//one time shutdown
108
109 //generic funcs
110 #define OGLTEXBUFSIZE (1024*1024*4)
111 extern GLubyte texbuf[OGLTEXBUFSIZE];
112 //void ogl_filltexbuf(unsigned char *data,GLubyte *texp,int width,int height,int twidth,int theight);
113 void ogl_filltexbuf(unsigned char *data,GLubyte *texp,int truewidth,int width,int height,int dxo,int dyo,int twidth,int theight,int type);
114 void ogl_loadbmtexture_m(grs_bitmap *bm,int domipmap);
115 void ogl_loadbmtexture(grs_bitmap *bm);
116 //void ogl_loadtexture(unsigned char * data, int width, int height,int dxo,int dyo, int *texid,float *u,float *v,char domipmap,float prio);
117 void ogl_loadtexture(unsigned char * data, int dxo,int dyo, ogl_texture *tex);
118 void ogl_freetexture(ogl_texture *gltexture);
119 void ogl_freebmtexture(grs_bitmap *bm);
120 void ogl_do_palfx(void);
121 void ogl_start_frame(void);
122 void ogl_end_frame(void);
123 void ogl_swap_buffers(void);
124 void ogl_set_screen_mode(void);
125 void ogl_cache_level_textures(void);
126
127 void ogl_urect(int left,int top,int right,int bot);
128 bool ogl_ubitmapm_c(int x, int y,grs_bitmap *bm,int c);
129 bool ogl_ubitmapm(int x, int y,grs_bitmap *bm);
130 bool ogl_ubitblt(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
131 bool ogl_ubitblt_tolinear(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
132 bool ogl_ubitblt_copy(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
133 void ogl_upixelc(int x, int y, int c);
134 void ogl_ulinec(int left,int top,int right,int bot,int c);
135
136 extern unsigned char *ogl_pal;
137
138 #include "3d.h"
139 bool g3_draw_tmap_2(int nv,g3s_point **pointlist,g3s_uvl *uvl_list,grs_bitmap *bmbot,grs_bitmap *bm,int orient);
140
141 void ogl_draw_reticle(int cross,int primary,int secondary);
142
143 //whee
144 //#define PAL2Tr(c) ((gr_palette[c*3]+gr_palette_gamma)/63.0)
145 //#define PAL2Tg(c) ((gr_palette[c*3+1]+gr_palette_gamma)/63.0)
146 //#define PAL2Tb(c) ((gr_palette[c*3+2]+gr_palette_gamma)/63.0)
147 //#define PAL2Tr(c) ((gr_palette[c*3])/63.0)
148 //#define PAL2Tg(c) ((gr_palette[c*3+1])/63.0)
149 //#define PAL2Tb(c) ((gr_palette[c*3+2])/63.0)
150 #define CPAL2Tr(c) ((gr_current_pal[c*3])/63.0)
151 #define CPAL2Tg(c) ((gr_current_pal[c*3+1])/63.0)
152 #define CPAL2Tb(c) ((gr_current_pal[c*3+2])/63.0)
153 #define PAL2Tr(c) ((ogl_pal[c*3])/63.0)
154 #define PAL2Tg(c) ((ogl_pal[c*3+1])/63.0)
155 #define PAL2Tb(c) ((ogl_pal[c*3+2])/63.0)
156 //inline GLfloat PAL2Tr(int c);
157 //inline GLfloat PAL2Tg(int c);
158 //inline GLfloat PAL2Tb(int c);
159
160 #endif