]> icculus.org git repositories - btb/d2x.git/blob - include/ogl_init.h
use PhysicsFS for saving levels
[btb/d2x.git] / include / ogl_init.h
1 /* interface to OpenGL functions
2  * Added 9/15/99 Matthew Mueller
3  * Got rid of OpenGL-internal stuff 2004-5-16 Martin Schaffner
4  */
5
6 #ifndef _OGL_INIT_H_ 
7 #define _OGL_INIT_H_
8
9 #ifdef _MSC_VER
10 # undef MAC // dirty feckin hack
11 #include <windows.h>
12 #include <stddef.h>
13 # define MAC(x)
14 #endif
15
16 #ifdef _MSC_VER //_WIN32
17 #define OGL_RUNTIME_LOAD
18 #endif
19
20 #ifdef OGL_RUNTIME_LOAD
21 #include "loadgl.h"
22 int ogl_init_load_library(void);
23 #else
24 #define GL_GLEXT_LEGACY
25 #undef GL_ARB_multitexture
26 #if defined(__APPLE__) && defined(__MACH__)
27 #include <OpenGL/gl.h>
28 #include <OpenGL/glu.h>
29 #else
30 #define GL_GLEXT_PROTOTYPES
31 #include <GL/gl.h>
32 #endif
33 #endif
34
35 #ifndef GL_VERSION_1_1
36 #ifdef GL_EXT_texture
37 #define GL_INTENSITY4 GL_INTENSITY4_EXT
38 #define GL_INTENSITY8 GL_INTENSITY8_EXT
39 #endif
40 #endif
41
42 #include "gr.h"
43 #include "palette.h"
44 #include "pstypes.h"
45
46 /* we need to export ogl_texture for 2d/font.c */
47 typedef struct _ogl_texture {
48         GLuint handle;
49         GLint internalformat;
50         GLenum format;
51         int w,h,tw,th,lw;
52         int bytesu;
53         int bytes;
54         GLfloat u,v;
55         GLfloat prio;
56         int wrapstate[2];
57         fix lastrend;
58         unsigned long numrend;
59         char wantmip;
60 } ogl_texture;
61
62 extern ogl_texture* ogl_get_free_texture();
63 void ogl_init_texture(ogl_texture* t, int w, int h, int flags);
64
65 extern int ogl_alttexmerge;//merge textures by just printing the seperate textures?
66 extern int ogl_rgba_internalformat;
67 extern int ogl_rgb_internalformat;
68 extern int ogl_setgammaramp_ok;
69 extern int ogl_intensity4_ok;
70 extern int ogl_luminance4_alpha4_ok;
71 extern int ogl_rgba2_ok;
72 extern int ogl_readpixels_ok;
73 extern int ogl_gettexlevelparam_ok;
74
75 #ifndef EXT_texture_env_combine
76 #define EXT_texture_env_combine 1
77 #define GL_COMBINE_RGB_EXT                0x8571
78 #define GL_COMBINE_ALPHA_EXT              0x8572
79 #define GL_PRIMARY_COLOR_EXT              0x8577
80 #define GL_PREVIOUS_EXT                   0x8578
81 #define GL_SOURCE0_RGB_EXT                0x8580
82 #define GL_SOURCE1_RGB_EXT                0x8581
83 #define GL_SOURCE2_RGB_EXT                0x8582
84 #define GL_SOURCE0_ALPHA_EXT              0x8588
85 #define GL_SOURCE1_ALPHA_EXT              0x8589
86 #define GL_SOURCE2_ALPHA_EXT              0x858A
87 #define GL_OPERAND0_RGB_EXT               0x8590
88 #define GL_OPERAND1_RGB_EXT               0x8591
89 #define GL_OPERAND2_RGB_EXT               0x8592
90 #define GL_OPERAND0_ALPHA_EXT             0x8598
91 #define GL_OPERAND1_ALPHA_EXT             0x8599
92 #define GL_OPERAND2_ALPHA_EXT             0x859A
93 #endif
94
95 #ifndef GL_NV_texture_env_combine4
96 #define GL_NV_texture_env_combine4 1
97 #define GL_COMBINE4_NV                    0x8503
98 #define GL_SOURCE3_RGB_NV                 0x8583
99 #define GL_SOURCE3_ALPHA_NV               0x858B
100 #define GL_OPERAND3_RGB_NV                0x8593
101 #define GL_OPERAND3_ALPHA_NV              0x859B
102 #endif
103 extern int ogl_nv_texture_env_combine4_ok;
104
105 #ifdef GL_NV_register_combiners
106 extern int ogl_nv_register_combiners_ok;
107 #define OGL_SUPER_TRANSPARENT_OK (ogl_nv_register_combiners_ok)
108 #else
109 #define OGL_SUPER_TRANSPARENT_OK (0)
110 #endif
111
112 #ifndef GL_EXT_texture_filter_anisotropic
113 #define GL_EXT_texture_filter_anisotropic 1
114 #define GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE
115 #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
116 #endif
117 extern int ogl_ext_texture_filter_anisotropic_ok;
118
119 #ifndef GL_EXT_shared_texture_palette
120 #define GL_EXT_shared_texture_palette     1
121 #define GL_SHARED_TEXTURE_PALETTE_EXT     0x81FB
122 #endif
123
124 #ifdef GL_EXT_paletted_texture
125 extern int ogl_paletted_texture_ok;
126 extern int ogl_shared_palette_ok;
127 #endif
128 void ogl_init_shared_palette(void);
129
130 extern int gl_initialized;
131 extern int GL_texmagfilt,GL_texminfilt,GL_needmipmaps;
132 extern float GL_texanisofilt;
133 extern int gl_reticle;
134
135 extern int active_texture_unit;
136 void ogl_setActiveTexture(int t);
137
138 int ogl_check_mode(int x, int y); // check if mode is valid
139 int ogl_init_window(int x, int y);//create a window/switch modes/etc
140 void ogl_destroy_window(void);//destroy window/etc
141 void ogl_init(void);//one time initialization
142 void ogl_close(void);//one time shutdown
143
144
145 #define OGL_FLAG_MIPMAP (1 << 0)
146 #define OGL_FLAG_NOCOLOR (1 << 1)
147 #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.
148 void ogl_loadbmtexture_f(grs_bitmap *bm, int flags);
149 void ogl_freebmtexture(grs_bitmap *bm);
150
151 void ogl_start_offscreen_render(int x, int y, int w, int h);
152 void ogl_end_offscreen_render(void);
153 void ogl_start_frame(void);
154 void ogl_end_frame(void);
155 void ogl_swap_buffers(void);
156 void ogl_set_screen_mode(void);
157 void ogl_cache_level_textures(void);
158
159 void ogl_urect(int left, int top, int right, int bot);
160 bool ogl_ubitmapm_c(int x, int y, grs_bitmap *bm, int c);
161 bool ogl_ubitmapm(int x, int y, grs_bitmap *bm);
162 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);
163 bool ogl_ubitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
164 bool ogl_ubitblt_tolinear(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
165 bool ogl_ubitblt_copy(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
166 void ogl_upixelc(int x, int y, int c);
167 void ogl_ulinec(int left, int top, int right, int bot, int c);
168
169 #include "3d.h"
170 bool g3_draw_tmap_2(int nv,g3s_point **pointlist,g3s_uvl *uvl_list,grs_bitmap *bmbot,grs_bitmap *bm, int orient);
171
172 void ogl_draw_reticle(int cross, int primary, int secondary);
173
174 #endif /* _OGL_INIT_H_ */