1 //************************************************************************** 2 //** 3 //** ## ## ## ## ## #### #### ### ### 4 //** ## ## ## ## ## ## ## ## ## ## #### #### 5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ## 6 //** ## ## ######## ## ## ## ## ## ## ## ### ## 7 //** ### ## ## ### ## ## ## ## ## ## 8 //** # ## ## # #### #### ## ## 9 //** 10 //** $Id: gl_local.h 4349 2010-12-17 15:07:11Z dj_jl $ 11 //** 12 //** Copyright (C) 1999-2006 Jānis Legzdiņš 13 //** 14 //** This program is free software; you can redistribute it and/or 15 //** modify it under the terms of the GNU General Public License 16 //** as published by the Free Software Foundation; either version 2 17 //** of the License, or (at your option) any later version. 18 //** 19 //** This program is distributed in the hope that it will be useful, 20 //** but WITHOUT ANY WARRANTY; without even the implied warranty of 21 //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 //** GNU General Public License for more details. 23 //** 24 //************************************************************************** 25 26 #ifndef _GL_LOCAL_H 27 #define _GL_LOCAL_H 28 29 // HEADER FILES ------------------------------------------------------------ 30 31 #ifdef _WIN32 32 #include "winlocal.h" 33 #endif 34 #include <GL/gl.h> 35 36 #ifndef APIENTRY 37 #define APIENTRY 38 #endif 39 40 #include "gamedefs.h" 41 #include "cl_local.h" 42 #include "r_shared.h" 43 44 // MACROS ------------------------------------------------------------------ 45 46 // TYPES ------------------------------------------------------------------- 47 48 // 49 // Extensions 50 // 51 52 // ARB_multitexture 53 #ifndef GL_ARB_multitexture 54 #define GL_TEXTURE0_ARB 0x84C0 55 #define GL_TEXTURE1_ARB 0x84C1 56 #define GL_TEXTURE2_ARB 0x84C2 57 #define GL_TEXTURE3_ARB 0x84C3 58 #define GL_TEXTURE4_ARB 0x84C4 59 #define GL_TEXTURE5_ARB 0x84C5 60 #define GL_TEXTURE6_ARB 0x84C6 61 #define GL_TEXTURE7_ARB 0x84C7 62 #define GL_TEXTURE8_ARB 0x84C8 63 #define GL_TEXTURE9_ARB 0x84C9 64 #define GL_TEXTURE10_ARB 0x84CA 65 #define GL_TEXTURE11_ARB 0x84CB 66 #define GL_TEXTURE12_ARB 0x84CC 67 #define GL_TEXTURE13_ARB 0x84CD 68 #define GL_TEXTURE14_ARB 0x84CE 69 #define GL_TEXTURE15_ARB 0x84CF 70 #define GL_TEXTURE16_ARB 0x84D0 71 #define GL_TEXTURE17_ARB 0x84D1 72 #define GL_TEXTURE18_ARB 0x84D2 73 #define GL_TEXTURE19_ARB 0x84D3 74 #define GL_TEXTURE20_ARB 0x84D4 75 #define GL_TEXTURE21_ARB 0x84D5 76 #define GL_TEXTURE22_ARB 0x84D6 77 #define GL_TEXTURE23_ARB 0x84D7 78 #define GL_TEXTURE24_ARB 0x84D8 79 #define GL_TEXTURE25_ARB 0x84D9 80 #define GL_TEXTURE26_ARB 0x84DA 81 #define GL_TEXTURE27_ARB 0x84DB 82 #define GL_TEXTURE28_ARB 0x84DC 83 #define GL_TEXTURE29_ARB 0x84DD 84 #define GL_TEXTURE30_ARB 0x84DE 85 #define GL_TEXTURE31_ARB 0x84DF 86 #define GL_ACTIVE_TEXTURE_ARB 0x84E0 87 #define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 88 #define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 89 #endif 90 91 typedef void (APIENTRY*glMultiTexCoord2fARB_t)(GLenum, GLfloat, GLfloat); 92 typedef void (APIENTRY*glActiveTextureARB_t)(GLenum); 93 94 // EXT_point_parameters 95 #ifndef GL_EXT_point_parameters 96 #define GL_POINT_SIZE_MIN_EXT 0x8126 97 #define GL_POINT_SIZE_MAX_EXT 0x8127 98 #define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 99 #define GL_DISTANCE_ATTENUATION_EXT 0x8129 100 #endif 101 102 typedef void (APIENTRY*glPointParameterfEXT_t)(GLenum, GLfloat); 103 typedef void (APIENTRY*glPointParameterfvEXT_t)(GLenum, const GLfloat *); 104 105 // EXT_texture_filter_anisotropic 106 #ifndef GL_EXT_texture_filter_anisotropic 107 #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE 108 #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF 109 #endif 110 111 // SGIS_texture_edge_clamp 112 #ifndef GL_SGIS_texture_edge_clamp 113 #define GL_CLAMP_TO_EDGE_SGIS 0x812F 114 #endif 115 116 typedef void (APIENTRY*glStencilFuncSeparate_t)(GLenum, GLenum, GLint, GLuint); 117 typedef void (APIENTRY*glStencilOpSeparate_t)(GLenum, GLenum, GLenum, GLenum); 118 119 #ifndef GL_EXT_stencil_wrap 120 #define GL_INCR_WRAP_EXT 0x8507 121 #define GL_DECR_WRAP_EXT 0x8508 122 #endif 123 124 #ifndef GL_ARB_shader_objects 125 #define GL_PROGRAM_OBJECT_ARB 0x8B40 126 #define GL_SHADER_OBJECT_ARB 0x8B48 127 #define GL_OBJECT_TYPE_ARB 0x8B4E 128 #define GL_OBJECT_SUBTYPE_ARB 0x8B4F 129 #define GL_FLOAT_VEC2_ARB 0x8B50 130 #define GL_FLOAT_VEC3_ARB 0x8B51 131 #define GL_FLOAT_VEC4_ARB 0x8B52 132 #define GL_INT_VEC2_ARB 0x8B53 133 #define GL_INT_VEC3_ARB 0x8B54 134 #define GL_INT_VEC4_ARB 0x8B55 135 #define GL_BOOL_ARB 0x8B56 136 #define GL_BOOL_VEC2_ARB 0x8B57 137 #define GL_BOOL_VEC3_ARB 0x8B58 138 #define GL_BOOL_VEC4_ARB 0x8B59 139 #define GL_FLOAT_MAT2_ARB 0x8B5A 140 #define GL_FLOAT_MAT3_ARB 0x8B5B 141 #define GL_FLOAT_MAT4_ARB 0x8B5C 142 #define GL_SAMPLER_1D_ARB 0x8B5D 143 #define GL_SAMPLER_2D_ARB 0x8B5E 144 #define GL_SAMPLER_3D_ARB 0x8B5F 145 #define GL_SAMPLER_CUBE_ARB 0x8B60 146 #define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 147 #define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 148 #define GL_SAMPLER_2D_RECT_ARB 0x8B63 149 #define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 150 #define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 151 #define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 152 #define GL_OBJECT_LINK_STATUS_ARB 0x8B82 153 #define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 154 #define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 155 #define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 156 #define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 157 #define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 158 #define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 159 160 typedef char GLcharARB; 161 typedef unsigned int GLhandleARB; 162 #endif 163 164 typedef void (APIENTRY*glDeleteObjectARB_t)(GLhandleARB); 165 typedef GLhandleARB (APIENTRY*glGetHandleARB_t)(GLenum); 166 typedef void (APIENTRY*glDetachObjectARB_t)(GLhandleARB, GLhandleARB); 167 typedef GLhandleARB (APIENTRY*glCreateShaderObjectARB_t)(GLenum); 168 typedef void (APIENTRY*glShaderSourceARB_t)(GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); 169 typedef void (APIENTRY*glCompileShaderARB_t)(GLhandleARB); 170 typedef GLhandleARB (APIENTRY*glCreateProgramObjectARB_t)(void); 171 typedef void (APIENTRY*glAttachObjectARB_t)(GLhandleARB, GLhandleARB); 172 typedef void (APIENTRY*glLinkProgramARB_t)(GLhandleARB); 173 typedef void (APIENTRY*glUseProgramObjectARB_t)(GLhandleARB); 174 typedef void (APIENTRY*glValidateProgramARB_t)(GLhandleARB); 175 typedef void (APIENTRY*glUniform1fARB_t)(GLint, GLfloat); 176 typedef void (APIENTRY*glUniform2fARB_t)(GLint, GLfloat, GLfloat); 177 typedef void (APIENTRY*glUniform3fARB_t)(GLint, GLfloat, GLfloat, GLfloat); 178 typedef void (APIENTRY*glUniform4fARB_t)(GLint, GLfloat, GLfloat, GLfloat, GLfloat); 179 typedef void (APIENTRY*glUniform1iARB_t)(GLint, GLint); 180 typedef void (APIENTRY*glUniform2iARB_t)(GLint, GLint, GLint); 181 typedef void (APIENTRY*glUniform3iARB_t)(GLint, GLint, GLint, GLint); 182 typedef void (APIENTRY*glUniform4iARB_t)(GLint, GLint, GLint, GLint, GLint); 183 typedef void (APIENTRY*glUniform1fvARB_t)(GLint, GLsizei, const GLfloat *); 184 typedef void (APIENTRY*glUniform2fvARB_t)(GLint, GLsizei, const GLfloat *); 185 typedef void (APIENTRY*glUniform3fvARB_t)(GLint, GLsizei, const GLfloat *); 186 typedef void (APIENTRY*glUniform4fvARB_t)(GLint, GLsizei, const GLfloat *); 187 typedef void (APIENTRY*glUniform1ivARB_t)(GLint, GLsizei, const GLint *); 188 typedef void (APIENTRY*glUniform2ivARB_t)(GLint, GLsizei, const GLint *); 189 typedef void (APIENTRY*glUniform3ivARB_t)(GLint, GLsizei, const GLint *); 190 typedef void (APIENTRY*glUniform4ivARB_t)(GLint, GLsizei, const GLint *); 191 typedef void (APIENTRY*glUniformMatrix2fvARB_t)(GLint, GLsizei, GLboolean, const GLfloat *); 192 typedef void (APIENTRY*glUniformMatrix3fvARB_t)(GLint, GLsizei, GLboolean, const GLfloat *); 193 typedef void (APIENTRY*glUniformMatrix4fvARB_t)(GLint, GLsizei, GLboolean, const GLfloat *); 194 typedef void (APIENTRY*glGetObjectParameterfvARB_t)(GLhandleARB, GLenum, GLfloat *); 195 typedef void (APIENTRY*glGetObjectParameterivARB_t)(GLhandleARB, GLenum, GLint *); 196 typedef void (APIENTRY*glGetInfoLogARB_t)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); 197 typedef void (APIENTRY*glGetAttachedObjectsARB_t)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); 198 typedef GLint (APIENTRY*glGetUniformLocationARB_t)(GLhandleARB, const GLcharARB *); 199 typedef void (APIENTRY*glGetActiveUniformARB_t)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); 200 typedef void (APIENTRY*glGetUniformfvARB_t)(GLhandleARB, GLint, GLfloat *); 201 typedef void (APIENTRY*glGetUniformivARB_t)(GLhandleARB, GLint, GLint *); 202 typedef void (APIENTRY*glGetShaderSourceARB_t)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *); 203 204 #ifndef GL_ARB_vertex_shader 205 #define GL_VERTEX_SHADER_ARB 0x8B31 206 #define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A 207 #define GL_MAX_VARYING_FLOATS_ARB 0x8B4B 208 #define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 209 #define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 210 #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C 211 #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D 212 #define GL_MAX_TEXTURE_COORDS_ARB 0x8871 213 #define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 214 #define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 215 #define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 216 #define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A 217 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 218 #define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 219 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 220 #define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 221 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A 222 #define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 223 #define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 224 #endif 225 226 typedef void (APIENTRY*glVertexAttrib1dARB_t)(GLuint, GLdouble); 227 typedef void (APIENTRY*glVertexAttrib1dvARB_t)(GLuint, const GLdouble *); 228 typedef void (APIENTRY*glVertexAttrib1fARB_t)(GLuint, GLfloat); 229 typedef void (APIENTRY*glVertexAttrib1fvARB_t)(GLuint, const GLfloat *); 230 typedef void (APIENTRY*glVertexAttrib1sARB_t)(GLuint, GLshort); 231 typedef void (APIENTRY*glVertexAttrib1svARB_t)(GLuint, const GLshort *); 232 typedef void (APIENTRY*glVertexAttrib2dARB_t)(GLuint, GLdouble, GLdouble); 233 typedef void (APIENTRY*glVertexAttrib2dvARB_t)(GLuint, const GLdouble *); 234 typedef void (APIENTRY*glVertexAttrib2fARB_t)(GLuint, GLfloat, GLfloat); 235 typedef void (APIENTRY*glVertexAttrib2fvARB_t)(GLuint, const GLfloat *); 236 typedef void (APIENTRY*glVertexAttrib2sARB_t)(GLuint, GLshort, GLshort); 237 typedef void (APIENTRY*glVertexAttrib2svARB_t)(GLuint, const GLshort *); 238 typedef void (APIENTRY*glVertexAttrib3dARB_t)(GLuint, GLdouble, GLdouble, GLdouble); 239 typedef void (APIENTRY*glVertexAttrib3dvARB_t)(GLuint, const GLdouble *); 240 typedef void (APIENTRY*glVertexAttrib3fARB_t)(GLuint, GLfloat, GLfloat, GLfloat); 241 typedef void (APIENTRY*glVertexAttrib3fvARB_t)(GLuint, const GLfloat *); 242 typedef void (APIENTRY*glVertexAttrib3sARB_t)(GLuint, GLshort, GLshort, GLshort); 243 typedef void (APIENTRY*glVertexAttrib3svARB_t)(GLuint, const GLshort *); 244 typedef void (APIENTRY*glVertexAttrib4NbvARB_t)(GLuint, const GLbyte *); 245 typedef void (APIENTRY*glVertexAttrib4NivARB_t)(GLuint, const GLint *); 246 typedef void (APIENTRY*glVertexAttrib4NsvARB_t)(GLuint, const GLshort *); 247 typedef void (APIENTRY*glVertexAttrib4NubARB_t)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte); 248 typedef void (APIENTRY*glVertexAttrib4NubvARB_t)(GLuint, const GLubyte *); 249 typedef void (APIENTRY*glVertexAttrib4NuivARB_t)(GLuint, const GLuint *); 250 typedef void (APIENTRY*glVertexAttrib4NusvARB_t)(GLuint, const GLushort *); 251 typedef void (APIENTRY*glVertexAttrib4bvARB_t)(GLuint, const GLbyte *); 252 typedef void (APIENTRY*glVertexAttrib4dARB_t)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble); 253 typedef void (APIENTRY*glVertexAttrib4dvARB_t)(GLuint, const GLdouble *); 254 typedef void (APIENTRY*glVertexAttrib4fARB_t)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat); 255 typedef void (APIENTRY*glVertexAttrib4fvARB_t)(GLuint, const GLfloat *); 256 typedef void (APIENTRY*glVertexAttrib4ivARB_t)(GLuint, const GLint *); 257 typedef void (APIENTRY*glVertexAttrib4sARB_t)(GLuint, GLshort, GLshort, GLshort, GLshort); 258 typedef void (APIENTRY*glVertexAttrib4svARB_t)(GLuint, const GLshort *); 259 typedef void (APIENTRY*glVertexAttrib4ubvARB_t)(GLuint, const GLubyte *); 260 typedef void (APIENTRY*glVertexAttrib4uivARB_t)(GLuint, const GLuint *); 261 typedef void (APIENTRY*glVertexAttrib4usvARB_t)(GLuint, const GLushort *); 262 typedef void (APIENTRY*glVertexAttribPointerARB_t)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); 263 typedef void (APIENTRY*glEnableVertexAttribArrayARB_t)(GLuint); 264 typedef void (APIENTRY*glDisableVertexAttribArrayARB_t)(GLuint); 265 typedef void (APIENTRY*glBindAttribLocationARB_t)(GLhandleARB, GLuint, const GLcharARB *); 266 typedef void (APIENTRY*glGetActiveAttribARB_t)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); 267 typedef GLint (APIENTRY*glGetAttribLocationARB_t)(GLhandleARB, const GLcharARB *); 268 typedef void (APIENTRY*glGetVertexAttribdvARB_t)(GLuint, GLenum, GLdouble *); 269 typedef void (APIENTRY*glGetVertexAttribfvARB_t)(GLuint, GLenum, GLfloat *); 270 typedef void (APIENTRY*glGetVertexAttribivARB_t)(GLuint, GLenum, GLint *); 271 typedef void (APIENTRY*glGetVertexAttribPointervARB_t)(GLuint, GLenum, GLvoid* *); 272 273 #ifndef GL_ARB_fragment_shader 274 #define GL_FRAGMENT_SHADER_ARB 0x8B30 275 #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 276 #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B 277 #endif 278 279 #ifndef GL_ARB_shading_language_100 280 #define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C 281 #endif 282 283 #ifndef GL_ARB_depth_clamp 284 #define GL_DEPTH_CLAMP 0x864F 285 #endif 286 287 #ifndef GL_ARB_vertex_buffer_object 288 #define GL_BUFFER_SIZE_ARB 0x8764 289 #define GL_BUFFER_USAGE_ARB 0x8765 290 #define GL_ARRAY_BUFFER_ARB 0x8892 291 #define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 292 #define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 293 #define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 294 #define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 295 #define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 296 #define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 297 #define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 298 #define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A 299 #define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B 300 #define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C 301 #define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D 302 #define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E 303 #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F 304 #define GL_READ_ONLY_ARB 0x88B8 305 #define GL_WRITE_ONLY_ARB 0x88B9 306 #define GL_READ_WRITE_ARB 0x88BA 307 #define GL_BUFFER_ACCESS_ARB 0x88BB 308 #define GL_BUFFER_MAPPED_ARB 0x88BC 309 #define GL_BUFFER_MAP_POINTER_ARB 0x88BD 310 #define GL_STREAM_DRAW_ARB 0x88E0 311 #define GL_STREAM_READ_ARB 0x88E1 312 #define GL_STREAM_COPY_ARB 0x88E2 313 #define GL_STATIC_DRAW_ARB 0x88E4 314 #define GL_STATIC_READ_ARB 0x88E5 315 #define GL_STATIC_COPY_ARB 0x88E6 316 #define GL_DYNAMIC_DRAW_ARB 0x88E8 317 #define GL_DYNAMIC_READ_ARB 0x88E9 318 #define GL_DYNAMIC_COPY_ARB 0x88EA 319 320 /* GL types for handling large vertex buffer objects */ 321 typedef ptrdiff_t GLintptrARB; 322 typedef ptrdiff_t GLsizeiptrARB; 323 #endif 324 325 typedef void (APIENTRY*glBindBufferARB_t)(GLenum, GLuint); 326 typedef void (APIENTRY*glDeleteBuffersARB_t)(GLsizei, const GLuint *); 327 typedef void (APIENTRY*glGenBuffersARB_t)(GLsizei, GLuint *); 328 typedef GLboolean (APIENTRY*glIsBufferARB_t)(GLuint); 329 typedef void (APIENTRY*glBufferDataARB_t)(GLenum, GLsizeiptrARB, const GLvoid *, GLenum); 330 typedef void (APIENTRY*glBufferSubDataARB_t)(GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); 331 typedef void (APIENTRY*glGetBufferSubDataARB_t)(GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); 332 typedef GLvoid* (APIENTRY*glMapBufferARB_t)(GLenum, GLenum); 333 typedef GLboolean (APIENTRY*glUnmapBufferARB_t)(GLenum); 334 typedef void (APIENTRY*glGetBufferParameterivARB_t)(GLenum, GLenum, GLint *); 335 typedef void (APIENTRY*glGetBufferPointervARB_t)(GLenum, GLenum, GLvoid* *); 336 337 #ifndef GL_EXT_draw_range_elements 338 #define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 339 #define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 340 #endif 341 342 typedef void (APIENTRY*glDrawRangeElementsEXT_t)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); 343 344 class VOpenGLDrawer : public VDrawer 345 { 346 public: 347 // 348 // VDrawer interface 349 // 350 VOpenGLDrawer(); 351 void InitResolution(); 352 void StartUpdate(); 353 void Setup2D(); 354 void BeginDirectUpdate(); 355 void EndDirectUpdate(); 356 void* ReadScreen(int*, bool*); 357 void ReadBackScreen(int, int, rgba_t*); 358 359 // Rendering stuff 360 void SetupView(VRenderLevelDrawer*, const refdef_t*); 361 void SetupViewOrg(); 362 void EndView(); 363 364 // Texture stuff 365 void PrecacheTexture(VTexture*); 366 367 // Polygon drawing 368 void WorldDrawing(); 369 void WorldDrawingShaders(); 370 void DrawWorldAmbientPass(); 371 void BeginShadowVolumesPass(); 372 void BeginLightShadowVolumes(); 373 void RenderSurfaceShadowVolume(surface_t *surf, TVec& LightPos, float Radius); 374 void BeginLightPass(TVec&, float, vuint32); 375 void DrawSurfaceLight(surface_t*); 376 void DrawWorldTexturesPass(); 377 void DrawWorldFogPass(); 378 void EndFogPass(); 379 void DrawSkyPolygon(surface_t*, bool, VTexture*, float, VTexture*, float, 380 int); 381 void DrawMaskedPolygon(surface_t*, float, bool); 382 void DrawSpritePolygon(TVec*, VTexture*, float, bool, VTextureTranslation*, 383 int, vuint32, vuint32, const TVec&, float, const TVec&, const TVec&, 384 const TVec&); 385 void DrawAliasModel(const TVec&, const TAVec&, const TVec&, const TVec&, 386 VMeshModel*, int, int, VTexture*, VTextureTranslation*, int, vuint32, 387 vuint32, float, bool, bool, float, bool); 388 void DrawAliasModelAmbient(const TVec&, const TAVec&, const TVec&, 389 const TVec&, VMeshModel*, int, int, VTexture*, vuint32, float, bool); 390 void DrawAliasModelTextures(const TVec&, const TAVec&, const TVec&, const TVec&, 391 VMeshModel*, int, int, VTexture*, VTextureTranslation*, int, float, bool); 392 void BeginModelsLightPass(TVec&, float, vuint32); 393 void DrawAliasModelLight(const TVec&, const TAVec&, const TVec&, 394 const TVec&, VMeshModel*, int, int, VTexture*, float, bool); 395 void BeginModelsShadowsPass(TVec&, float); 396 void DrawAliasModelShadow(const TVec&, const TAVec&, const TVec&, 397 const TVec&, VMeshModel*, int, int, float, bool, const TVec&, float); 398 void DrawAliasModelFog(const TVec&, const TAVec&, const TVec&, 399 const TVec&, VMeshModel*, int, int, VTexture*, vuint32, float, bool); 400 bool StartPortal(VPortal*, bool); 401 void EndPortal(VPortal*, bool); 402 403 // Particles 404 void StartParticles(); 405 void DrawParticle(particle_t *); 406 void EndParticles(); 407 408 // Drawing 409 void DrawPic(float, float, float, float, float, float, float, float, 410 VTexture*, VTextureTranslation*, float); 411 void DrawPicShadow(float, float, float, float, float, float, float, 412 float, VTexture*, float); 413 void FillRectWithFlat(float, float, float, float, float, float, float, 414 float, VTexture*); 415 void FillRect(float, float, float, float, vuint32); 416 void ShadeRect(int, int, int, int, float); 417 void DrawConsoleBackground(int); 418 void DrawSpriteLump(float, float, float, float, VTexture*, 419 VTextureTranslation*, bool); 420 421 // Automap 422 void StartAutomap(); 423 void DrawLine(int, int, vuint32, int, int, vuint32); 424 void EndAutomap(); 425 426 // Advanced drawing. 427 bool SupportsAdvancedRendering(); 428 429 protected: 430 enum { M_INFINITY = 8000 }; 431 432 GLint maxTexSize; 433 bool texturesGenerated; 434 435 GLuint particle_texture; 436 437 GLuint lmap_id[NUM_BLOCK_SURFS]; 438 439 GLuint addmap_id[NUM_BLOCK_SURFS]; 440 441 float tex_iw; 442 float tex_ih; 443 444 GLenum maxfilter; 445 GLenum minfilter; 446 GLenum mipfilter; 447 GLenum ClampToEdge; 448 GLfloat max_anisotropy; 449 450 int lastgamma; 451 int CurrentFade; 452 453 bool pointparmsable; 454 bool HaveShaders; 455 bool HaveDepthClamp; 456 bool HaveStencilWrap; 457 bool HaveVertexBufferObject; 458 bool HaveDrawRangeElements; 459 460 TArray<GLhandleARB> CreatedShaderObjects; 461 TArray<VMeshModel*> UploadedModels; 462 463 GLhandleARB DrawSimpleProgram; 464 GLint DrawSimpleTextureLoc; 465 GLint DrawSimpleAlphaLoc; 466 467 GLhandleARB DrawShadowProgram; 468 GLint DrawShadowTextureLoc; 469 GLint DrawShadowAlphaLoc; 470 471 GLhandleARB DrawFixedColProgram; 472 GLint DrawFixedColColourLoc; 473 474 GLhandleARB DrawAutomapProgram; 475 476 GLhandleARB SurfZBufProgram; 477 478 GLhandleARB SurfSimpleProgram; 479 GLint SurfSimpleSAxisLoc; 480 GLint SurfSimpleTAxisLoc; 481 GLint SurfSimpleSOffsLoc; 482 GLint SurfSimpleTOffsLoc; 483 GLint SurfSimpleTexIWLoc; 484 GLint SurfSimpleTexIHLoc; 485 GLint SurfSimpleTextureLoc; 486 GLint SurfSimpleLightLoc; 487 GLint SurfSimpleFogEnabledLoc; 488 GLint SurfSimpleFogTypeLoc; 489 GLint SurfSimpleFogColourLoc; 490 GLint SurfSimpleFogDensityLoc; 491 GLint SurfSimpleFogStartLoc; 492 GLint SurfSimpleFogEndLoc; 493 494 GLhandleARB SurfLightmapProgram; 495 GLint SurfLightmapSAxisLoc; 496 GLint SurfLightmapTAxisLoc; 497 GLint SurfLightmapSOffsLoc; 498 GLint SurfLightmapTOffsLoc; 499 GLint SurfLightmapTexIWLoc; 500 GLint SurfLightmapTexIHLoc; 501 GLint SurfLightmapTexMinSLoc; 502 GLint SurfLightmapTexMinTLoc; 503 GLint SurfLightmapCacheSLoc; 504 GLint SurfLightmapCacheTLoc; 505 GLint SurfLightmapTextureLoc; 506 GLint SurfLightmapLightMapLoc; 507 GLint SurfLightmapSpecularMapLoc; 508 GLint SurfLightmapFogEnabledLoc; 509 GLint SurfLightmapFogTypeLoc; 510 GLint SurfLightmapFogColourLoc; 511 GLint SurfLightmapFogDensityLoc; 512 GLint SurfLightmapFogStartLoc; 513 GLint SurfLightmapFogEndLoc; 514 515 GLhandleARB SurfSkyProgram; 516 GLint SurfSkyTextureLoc; 517 GLint SurfSkyBrightnessLoc; 518 GLint SurfSkyTexCoordLoc; 519 520 GLhandleARB SurfDSkyProgram; 521 GLint SurfDSkyTextureLoc; 522 GLint SurfDSkyTexture2Loc; 523 GLint SurfDSkyBrightnessLoc; 524 GLint SurfDSkyTexCoordLoc; 525 GLint SurfDSkyTexCoord2Loc; 526 527 GLhandleARB SurfMaskedProgram; 528 GLint SurfMaskedTextureLoc; 529 GLint SurfMaskedLightLoc; 530 GLint SurfMaskedFogEnabledLoc; 531 GLint SurfMaskedFogTypeLoc; 532 GLint SurfMaskedFogColourLoc; 533 GLint SurfMaskedFogDensityLoc; 534 GLint SurfMaskedFogStartLoc; 535 GLint SurfMaskedFogEndLoc; 536 GLint SurfMaskedAlphaRefLoc; 537 GLint SurfMaskedTexCoordLoc; 538 539 GLhandleARB SurfModelProgram; 540 GLint SurfModelInterLoc; 541 GLint SurfModelTextureLoc; 542 GLint SurfModelFogEnabledLoc; 543 GLint SurfModelFogTypeLoc; 544 GLint SurfModelFogColourLoc; 545 GLint SurfModelFogDensityLoc; 546 GLint SurfModelFogStartLoc; 547 GLint SurfModelFogEndLoc; 548 GLint SurfModelVert2Loc; 549 GLint SurfModelTexCoordLoc; 550 GLint SurfModelLightValLoc; 551 552 GLhandleARB SurfPartProgram; 553 GLint SurfPartTexCoordLoc; 554 GLint SurfPartLightValLoc; 555 556 GLhandleARB ShadowsAmbientProgram; 557 GLint ShadowsAmbientLightLoc; 558 559 GLhandleARB ShadowsLightProgram; 560 GLint ShadowsLightLightPosLoc; 561 GLint ShadowsLightLightRadiusLoc; 562 GLint ShadowsLightLightColourLoc; 563 GLint ShadowsLightSurfNormalLoc; 564 GLint ShadowsLightSurfDistLoc; 565 566 GLhandleARB ShadowsTextureProgram; 567 GLint ShadowsTextureTexCoordLoc; 568 GLint ShadowsTextureTextureLoc; 569 570 GLhandleARB ShadowsModelAmbientProgram; 571 GLint ShadowsModelAmbientInterLoc; 572 GLint ShadowsModelAmbientTextureLoc; 573 GLint ShadowsModelAmbientLightLoc; 574 GLint ShadowsModelAmbientModelToWorldMatLoc; 575 GLint ShadowsModelAmbientVert2Loc; 576 GLint ShadowsModelAmbientTexCoordLoc; 577 578 GLhandleARB ShadowsModelTexturesProgram; 579 GLint ShadowsModelTexturesInterLoc; 580 GLint ShadowsModelTexturesTextureLoc; 581 GLint ShadowsModelTexturesModelToWorldMatLoc; 582 GLint ShadowsModelTexturesVert2Loc; 583 GLint ShadowsModelTexturesTexCoordLoc; 584 585 GLhandleARB ShadowsModelLightProgram; 586 GLint ShadowsModelLightInterLoc; 587 GLint ShadowsModelLightTextureLoc; 588 GLint ShadowsModelLightLightPosLoc; 589 GLint ShadowsModelLightLightRadiusLoc; 590 GLint ShadowsModelLightLightColourLoc; 591 GLint ShadowsModelLightModelToWorldMatLoc; 592 GLint ShadowsModelLightNormalToWorldMatLoc; 593 GLint ShadowsModelLightVert2Loc; 594 GLint ShadowsModelLightVertNormalLoc; 595 GLint ShadowsModelLightVert2NormalLoc; 596 GLint ShadowsModelLightTexCoordLoc; 597 598 GLhandleARB ShadowsModelShadowProgram; 599 GLint ShadowsModelShadowInterLoc; 600 GLint ShadowsModelShadowLightPosLoc; 601 GLint ShadowsModelShadowModelToWorldMatLoc; 602 GLint ShadowsModelShadowVert2Loc; 603 GLint ShadowsModelShadowOffsetLoc; 604 605 GLhandleARB ShadowsFogProgram; 606 GLint ShadowsFogFogTypeLoc; 607 GLint ShadowsFogFogColourLoc; 608 GLint ShadowsFogFogDensityLoc; 609 GLint ShadowsFogFogStartLoc; 610 GLint ShadowsFogFogEndLoc; 611 612 GLhandleARB ShadowsModelFogProgram; 613 GLint ShadowsModelFogInterLoc; 614 GLint ShadowsModelFogModelToWorldMatLoc; 615 GLint ShadowsModelFogTextureLoc; 616 GLint ShadowsModelFogFogTypeLoc; 617 GLint ShadowsModelFogFogColourLoc; 618 GLint ShadowsModelFogFogDensityLoc; 619 GLint ShadowsModelFogFogStartLoc; 620 GLint ShadowsModelFogFogEndLoc; 621 GLint ShadowsModelFogVert2Loc; 622 GLint ShadowsModelFogTexCoordLoc; 623 624 // 625 // Console variables 626 // 627 static VCvarI tex_linear; 628 static VCvarI clear; 629 static VCvarI blend_sprites; 630 static VCvarI ext_multitexture; 631 static VCvarI ext_point_parameters; 632 static VCvarI ext_anisotropy; 633 static VCvarI ext_shaders; 634 static VCvarI ext_vertex_buffer_objects; 635 static VCvarF maxdist; 636 static VCvarI model_lighting; 637 static VCvarI specular_highlights; 638 639 // Extensions 640 bool CheckExtension(const char*); 641 virtual void* GetExtFuncPtr(const char*) = 0; 642 643 void SetFade(vuint32 NewFade); 644 645 void GenerateTextures(); 646 void FlushTextures(); 647 void DeleteTextures(); 648 void FlushTexture(VTexture*); 649 void SetTexture(VTexture*, int); 650 void SetSpriteLump(VTexture*, VTextureTranslation*, int); 651 void SetPic(VTexture*, VTextureTranslation*, int); 652 void GenerateTexture(VTexture*, GLuint*, VTextureTranslation*, int); 653 void UploadTexture8(int, int, const vuint8*, const rgba_t*); 654 void UploadTexture(int, int, const rgba_t*); 655 656 void DoHorizonPolygon(surface_t*); 657 void DrawPortalArea(VPortal*); 658 659 GLhandleARB LoadShader(GLenum Type, const VStr& FileName); 660 GLhandleARB CreateProgram(GLhandleARB VertexShader, GLhandleARB FragmentShader); 661 662 void UploadModel(VMeshModel* Mdl); 663 void UnloadModels(); 664 665 #define _(x) x##_t p_##x 666 _(glMultiTexCoord2fARB); 667 _(glActiveTextureARB); 668 669 _(glPointParameterfEXT); 670 _(glPointParameterfvEXT); 671 672 _(glStencilFuncSeparate); 673 _(glStencilOpSeparate); 674 675 _(glDeleteObjectARB); 676 _(glGetHandleARB); 677 _(glDetachObjectARB); 678 _(glCreateShaderObjectARB); 679 _(glShaderSourceARB); 680 _(glCompileShaderARB); 681 _(glCreateProgramObjectARB); 682 _(glAttachObjectARB); 683 _(glLinkProgramARB); 684 _(glUseProgramObjectARB); 685 _(glValidateProgramARB); 686 _(glUniform1fARB); 687 _(glUniform2fARB); 688 _(glUniform3fARB); 689 _(glUniform4fARB); 690 _(glUniform1iARB); 691 _(glUniform2iARB); 692 _(glUniform3iARB); 693 _(glUniform4iARB); 694 _(glUniform1fvARB); 695 _(glUniform2fvARB); 696 _(glUniform3fvARB); 697 _(glUniform4fvARB); 698 _(glUniform1ivARB); 699 _(glUniform2ivARB); 700 _(glUniform3ivARB); 701 _(glUniform4ivARB); 702 _(glUniformMatrix2fvARB); 703 _(glUniformMatrix3fvARB); 704 _(glUniformMatrix4fvARB); 705 _(glGetObjectParameterfvARB); 706 _(glGetObjectParameterivARB); 707 _(glGetInfoLogARB); 708 _(glGetAttachedObjectsARB); 709 _(glGetUniformLocationARB); 710 _(glGetActiveUniformARB); 711 _(glGetUniformfvARB); 712 _(glGetUniformivARB); 713 _(glGetShaderSourceARB); 714 715 _(glVertexAttrib1dARB); 716 _(glVertexAttrib1dvARB); 717 _(glVertexAttrib1fARB); 718 _(glVertexAttrib1fvARB); 719 _(glVertexAttrib1sARB); 720 _(glVertexAttrib1svARB); 721 _(glVertexAttrib2dARB); 722 _(glVertexAttrib2dvARB); 723 _(glVertexAttrib2fARB); 724 _(glVertexAttrib2fvARB); 725 _(glVertexAttrib2sARB); 726 _(glVertexAttrib2svARB); 727 _(glVertexAttrib3dARB); 728 _(glVertexAttrib3dvARB); 729 _(glVertexAttrib3fARB); 730 _(glVertexAttrib3fvARB); 731 _(glVertexAttrib3sARB); 732 _(glVertexAttrib3svARB); 733 _(glVertexAttrib4NbvARB); 734 _(glVertexAttrib4NivARB); 735 _(glVertexAttrib4NsvARB); 736 _(glVertexAttrib4NubARB); 737 _(glVertexAttrib4NubvARB); 738 _(glVertexAttrib4NuivARB); 739 _(glVertexAttrib4NusvARB); 740 _(glVertexAttrib4bvARB); 741 _(glVertexAttrib4dARB); 742 _(glVertexAttrib4dvARB); 743 _(glVertexAttrib4fARB); 744 _(glVertexAttrib4fvARB); 745 _(glVertexAttrib4ivARB); 746 _(glVertexAttrib4sARB); 747 _(glVertexAttrib4svARB); 748 _(glVertexAttrib4ubvARB); 749 _(glVertexAttrib4uivARB); 750 _(glVertexAttrib4usvARB); 751 _(glVertexAttribPointerARB); 752 _(glEnableVertexAttribArrayARB); 753 _(glDisableVertexAttribArrayARB); 754 _(glBindAttribLocationARB); 755 _(glGetActiveAttribARB); 756 _(glGetAttribLocationARB); 757 _(glGetVertexAttribdvARB); 758 _(glGetVertexAttribfvARB); 759 _(glGetVertexAttribivARB); 760 _(glGetVertexAttribPointervARB); 761 762 _(glBindBufferARB); 763 _(glDeleteBuffersARB); 764 _(glGenBuffersARB); 765 _(glIsBufferARB); 766 _(glBufferDataARB); 767 _(glBufferSubDataARB); 768 _(glGetBufferSubDataARB); 769 _(glMapBufferARB); 770 _(glUnmapBufferARB); 771 _(glGetBufferParameterivARB); 772 _(glGetBufferPointervARB); 773 774 _(glDrawRangeElementsEXT); 775 #undef _ 776 MultiTexCoord(int level,GLfloat s,GLfloat t)777 void MultiTexCoord(int level, GLfloat s, GLfloat t) 778 { 779 p_glMultiTexCoord2fARB(GLenum(GL_TEXTURE0_ARB + level), s, t); 780 } SelectTexture(int level)781 void SelectTexture(int level) 782 { 783 p_glActiveTextureARB(GLenum(GL_TEXTURE0_ARB + level)); 784 } 785 SetColour(vuint32 c)786 static void SetColour(vuint32 c) 787 { 788 glColor4ub(byte((c >> 16) & 0xff), byte((c >> 8) & 0xff), 789 byte(c & 0xff), byte(c >> 24)); 790 } 791 }; 792 793 // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- 794 795 // PUBLIC DATA DECLARATIONS ------------------------------------------------ 796 797 #endif 798