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