mostly dynamic GL binding (more needs to be done, but it's closer)
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 4 May 2002 12:04:19 +0000 (12:04 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 4 May 2002 12:04:19 +0000 (12:04 +0000)
added gl_mesh_drawmode cvar (3 = drawrangeelements (if available), 2 = drawelements, 1 = arrayelement, 0 = completely manual), 0 should get the 3dfx glquake minigl running...

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@1819 d7cf8633-e32d-0410-b094-e92efae38249

gl_backend.c
gl_draw.c
gl_rmain.c
gl_textures.c
glquake.h
vid_shared.c

index 3e0c3ac..5b9a8d2 100644 (file)
@@ -6,6 +6,7 @@ cvar_t gl_mesh_maxtriangles = {0, "gl_mesh_maxtriangles", "8192"};
 //cvar_t gl_mesh_batchtriangles = {0, "gl_mesh_batchtriangles", "1024"};
 cvar_t gl_mesh_batchtriangles = {0, "gl_mesh_batchtriangles", "0"};
 cvar_t gl_mesh_floatcolors = {0, "gl_mesh_floatcolors", "0"};
+cvar_t gl_mesh_drawmode = {CVAR_SAVE, "gl_mesh_drawmode", "3"};
 
 cvar_t r_render = {0, "r_render", "1"};
 cvar_t gl_dither = {CVAR_SAVE, "gl_dither", "1"}; // whether or not to use dithering
@@ -262,6 +263,7 @@ void gl_backend_init(void)
        Cvar_RegisterVariable(&gl_mesh_maxtriangles);
        Cvar_RegisterVariable(&gl_mesh_batchtriangles);
        Cvar_RegisterVariable(&gl_mesh_floatcolors);
+       Cvar_RegisterVariable(&gl_mesh_drawmode);
        R_RegisterModule("GL_Backend", gl_backend_start, gl_backend_shutdown, gl_backend_newmap);
        gl_backend_bufferchanges(true);
        for (i = 0;i < 256;i++)
@@ -276,7 +278,7 @@ int arraylocked = false;
 
 void GL_LockArray(int first, int count)
 {
-       if (!arraylocked && gl_supportslockarrays && gl_lockarrays.integer)
+       if (!arraylocked && gl_supportslockarrays && gl_lockarrays.integer && gl_mesh_drawmode.integer != 0)
        {
                qglLockArraysEXT(first, count);
                CHECKGLERROR
@@ -312,19 +314,19 @@ static void GL_SetupFrame (void)
        if (!r_render.integer)
                return;
 
-//     glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // LordHavoc: moved to SCR_UpdateScreen
+//     qglClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // LordHavoc: moved to SCR_UpdateScreen
 //     gldepthmin = 0;
 //     gldepthmax = 1;
-       glDepthFunc (GL_LEQUAL);CHECKGLERROR
+       qglDepthFunc (GL_LEQUAL);CHECKGLERROR
 
-//     glDepthRange (gldepthmin, gldepthmax);CHECKGLERROR
+//     qglDepthRange (gldepthmin, gldepthmax);CHECKGLERROR
 
        // set up viewpoint
-       glMatrixMode(GL_PROJECTION);CHECKGLERROR
-       glLoadIdentity ();CHECKGLERROR
+       qglMatrixMode(GL_PROJECTION);CHECKGLERROR
+       qglLoadIdentity ();CHECKGLERROR
 
        // y is weird beause OpenGL is bottom to top, we use top to bottom
-       glViewport(r_refdef.x, vid.realheight - (r_refdef.y + r_refdef.height), r_refdef.width, r_refdef.height);CHECKGLERROR
+       qglViewport(r_refdef.x, vid.realheight - (r_refdef.y + r_refdef.height), r_refdef.width, r_refdef.height);CHECKGLERROR
 
        // depth range
        zNear = 1.0;
@@ -340,40 +342,40 @@ static void GL_SetupFrame (void)
        ymax = zNear * tan(fovy * M_PI / 360.0);
 
        // set view pyramid
-       glFrustum(-xmax, xmax, -ymax, ymax, zNear, zFar);CHECKGLERROR
+       qglFrustum(-xmax, xmax, -ymax, ymax, zNear, zFar);CHECKGLERROR
 
-//     glCullFace(GL_FRONT);CHECKGLERROR
+//     qglCullFace(GL_FRONT);CHECKGLERROR
 
-       glMatrixMode(GL_MODELVIEW);CHECKGLERROR
-       glLoadIdentity ();CHECKGLERROR
+       qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
+       qglLoadIdentity ();CHECKGLERROR
 
        // put Z going up
-       glRotatef (-90,  1, 0, 0);CHECKGLERROR
-       glRotatef (90,  0, 0, 1);CHECKGLERROR
+       qglRotatef (-90,  1, 0, 0);CHECKGLERROR
+       qglRotatef (90,  0, 0, 1);CHECKGLERROR
        // camera rotation
-       glRotatef (-r_refdef.viewangles[2],  1, 0, 0);CHECKGLERROR
-       glRotatef (-r_refdef.viewangles[0],  0, 1, 0);CHECKGLERROR
-       glRotatef (-r_refdef.viewangles[1],  0, 0, 1);CHECKGLERROR
+       qglRotatef (-r_refdef.viewangles[2],  1, 0, 0);CHECKGLERROR
+       qglRotatef (-r_refdef.viewangles[0],  0, 1, 0);CHECKGLERROR
+       qglRotatef (-r_refdef.viewangles[1],  0, 0, 1);CHECKGLERROR
        // camera location
-       glTranslatef (-r_refdef.vieworg[0],  -r_refdef.vieworg[1],  -r_refdef.vieworg[2]);CHECKGLERROR
+       qglTranslatef (-r_refdef.vieworg[0],  -r_refdef.vieworg[1],  -r_refdef.vieworg[2]);CHECKGLERROR
 
-//     glGetFloatv (GL_MODELVIEW_MATRIX, r_world_matrix);
+//     qglGetFloatv (GL_MODELVIEW_MATRIX, r_world_matrix);
 
        //
        // set drawing parms
        //
 //     if (gl_cull.integer)
 //     {
-//             glEnable(GL_CULL_FACE);CHECKGLERROR
+//             qglEnable(GL_CULL_FACE);CHECKGLERROR
 //     }
 //     else
 //     {
-//             glDisable(GL_CULL_FACE);CHECKGLERROR
+//             qglDisable(GL_CULL_FACE);CHECKGLERROR
 //     }
 
-//     glEnable(GL_BLEND);CHECKGLERROR
-//     glEnable(GL_DEPTH_TEST);CHECKGLERROR
-//     glDepthMask(1);CHECKGLERROR
+//     qglEnable(GL_BLEND);CHECKGLERROR
+//     qglEnable(GL_DEPTH_TEST);CHECKGLERROR
+//     qglDepthMask(1);CHECKGLERROR
 }
 
 static int mesh_blendfunc1;
@@ -384,7 +386,7 @@ static int mesh_depthtest;
 static int mesh_unit;
 static int mesh_clientunit;
 static int mesh_texture[MAX_TEXTUREUNITS];
-static int mesh_texturergbscale[MAX_TEXTUREUNITS];
+static float mesh_texturergbscale[MAX_TEXTUREUNITS];
 
 void GL_SetupTextureState(void)
 {
@@ -394,64 +396,83 @@ void GL_SetupTextureState(void)
                for (i = 0;i < backendunits;i++)
                {
                        qglActiveTexture(GL_TEXTURE0_ARB + (mesh_unit = i));CHECKGLERROR
-                       glBindTexture(GL_TEXTURE_2D, mesh_texture[i]);CHECKGLERROR
+                       qglBindTexture(GL_TEXTURE_2D, mesh_texture[i]);CHECKGLERROR
                        if (gl_combine.integer)
                        {
-                               glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_CONSTANT_ARB);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_PREVIOUS_ARB);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB, GL_CONSTANT_ARB);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, GL_SRC_ALPHA);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB, GL_SRC_ALPHA);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, mesh_texturergbscale[i]);CHECKGLERROR
-                               glTexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_CONSTANT_ARB);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_PREVIOUS_ARB);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB, GL_CONSTANT_ARB);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, GL_SRC_ALPHA);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB, GL_SRC_ALPHA);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, mesh_texturergbscale[i]);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1);CHECKGLERROR
                        }
                        else
                        {
-                               glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);CHECKGLERROR
                        }
-                       qglClientActiveTexture(GL_TEXTURE0_ARB + (mesh_clientunit = i));CHECKGLERROR
-                       glTexCoordPointer(2, GL_FLOAT, sizeof(buf_texcoord_t), buf_texcoord[i]);CHECKGLERROR
                        if (mesh_texture[i])
                        {
-                               glEnable(GL_TEXTURE_2D);CHECKGLERROR
-                               glEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                               qglEnable(GL_TEXTURE_2D);CHECKGLERROR
                        }
                        else
                        {
-                               glDisable(GL_TEXTURE_2D);CHECKGLERROR
-                               glDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                               qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+                       }
+                       if (gl_mesh_drawmode.integer != 0)
+                       {
+                               qglClientActiveTexture(GL_TEXTURE0_ARB + (mesh_clientunit = i));CHECKGLERROR
+                               qglTexCoordPointer(2, GL_FLOAT, sizeof(buf_texcoord_t), buf_texcoord[i]);CHECKGLERROR
+                               if (mesh_texture[i])
+                               {
+                                       qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                               }
+                               else
+                               {
+                                       qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                               }
                        }
                }
        }
        else
        {
-               glBindTexture(GL_TEXTURE_2D, mesh_texture[0]);CHECKGLERROR
-               glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);CHECKGLERROR
-               glTexCoordPointer(2, GL_FLOAT, sizeof(buf_texcoord_t), buf_texcoord[0]);CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_2D, mesh_texture[0]);CHECKGLERROR
+               qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);CHECKGLERROR
                if (mesh_texture[0])
                {
-                       glEnable(GL_TEXTURE_2D);CHECKGLERROR
-                       glEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                       qglEnable(GL_TEXTURE_2D);CHECKGLERROR
                }
                else
                {
-                       glDisable(GL_TEXTURE_2D);CHECKGLERROR
-                       glDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                       qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+               }
+               if (gl_mesh_drawmode.integer != 0)
+               {
+                       qglTexCoordPointer(2, GL_FLOAT, sizeof(buf_texcoord_t), buf_texcoord[0]);CHECKGLERROR
+                       if (mesh_texture[0])
+                       {
+                               qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                       }
+                       else
+                       {
+                               qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                       }
                }
        }
 }
 
 // called at beginning of frame
+int usedarrays;
 void R_Mesh_Start(void)
 {
        int i;
@@ -488,33 +509,38 @@ void R_Mesh_Start(void)
                mesh_texturergbscale[i] = 1;
        }
 
-       glEnable(GL_CULL_FACE);CHECKGLERROR
-       glCullFace(GL_FRONT);CHECKGLERROR
+       qglEnable(GL_CULL_FACE);CHECKGLERROR
+       qglCullFace(GL_FRONT);CHECKGLERROR
 
        mesh_depthtest = true;
-       glEnable(GL_DEPTH_TEST);CHECKGLERROR
+       qglEnable(GL_DEPTH_TEST);CHECKGLERROR
 
        mesh_blendfunc1 = GL_ONE;
        mesh_blendfunc2 = GL_ZERO;
-       glBlendFunc(mesh_blendfunc1, mesh_blendfunc2);CHECKGLERROR
+       qglBlendFunc(mesh_blendfunc1, mesh_blendfunc2);CHECKGLERROR
 
        mesh_blend = 0;
-       glDisable(GL_BLEND);CHECKGLERROR
+       qglDisable(GL_BLEND);CHECKGLERROR
 
        mesh_depthmask = GL_TRUE;
-       glDepthMask(mesh_depthmask);CHECKGLERROR
+       qglDepthMask(mesh_depthmask);CHECKGLERROR
 
-       glVertexPointer(3, GL_FLOAT, sizeof(buf_vertex_t), &buf_vertex[0].v[0]);CHECKGLERROR
-       glEnableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
-       if (gl_mesh_floatcolors.integer)
-       {
-               glColorPointer(4, GL_FLOAT, sizeof(buf_fcolor_t), &buf_fcolor[0].c[0]);CHECKGLERROR
-       }
-       else
+       usedarrays = false;
+       if (gl_mesh_drawmode.integer != 0)
        {
-               glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(buf_bcolor_t), &buf_bcolor[0].c[0]);CHECKGLERROR
+               usedarrays = true;
+               qglVertexPointer(3, GL_FLOAT, sizeof(buf_vertex_t), &buf_vertex[0].v[0]);CHECKGLERROR
+               qglEnableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
+               if (gl_mesh_floatcolors.integer)
+               {
+                       qglColorPointer(4, GL_FLOAT, sizeof(buf_fcolor_t), &buf_fcolor[0].c[0]);CHECKGLERROR
+               }
+               else
+               {
+                       qglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(buf_bcolor_t), &buf_bcolor[0].c[0]);CHECKGLERROR
+               }
+               qglEnableClientState(GL_COLOR_ARRAY);CHECKGLERROR
        }
-       glEnableClientState(GL_COLOR_ARRAY);CHECKGLERROR
 
        GL_SetupTextureState();
 }
@@ -581,7 +607,7 @@ void GL_MeshState(buf_mesh_t *mesh)
                                }
                                if (mesh_texture[i] == 0)
                                {
-                                       glEnable(GL_TEXTURE_2D);CHECKGLERROR
+                                       qglEnable(GL_TEXTURE_2D);CHECKGLERROR
                                        // have to disable texcoord array on disabled texture
                                        // units due to NVIDIA driver bug with
                                        // compiled_vertex_array
@@ -589,12 +615,12 @@ void GL_MeshState(buf_mesh_t *mesh)
                                        {
                                                qglClientActiveTexture(GL_TEXTURE0_ARB + (mesh_clientunit = i));CHECKGLERROR
                                        }
-                                       glEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                                       qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
                                }
-                               glBindTexture(GL_TEXTURE_2D, (mesh_texture[i] = mesh->textures[i]));CHECKGLERROR
+                               qglBindTexture(GL_TEXTURE_2D, (mesh_texture[i] = mesh->textures[i]));CHECKGLERROR
                                if (mesh_texture[i] == 0)
                                {
-                                       glDisable(GL_TEXTURE_2D);CHECKGLERROR
+                                       qglDisable(GL_TEXTURE_2D);CHECKGLERROR
                                        // have to disable texcoord array on disabled texture
                                        // units due to NVIDIA driver bug with
                                        // compiled_vertex_array
@@ -602,7 +628,7 @@ void GL_MeshState(buf_mesh_t *mesh)
                                        {
                                                qglClientActiveTexture(GL_TEXTURE0_ARB + (mesh_clientunit = i));CHECKGLERROR
                                        }
-                                       glDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                                       qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
                                }
                        }
                        if (mesh_texturergbscale[i] != mesh->texturergbscale[i])
@@ -611,7 +637,7 @@ void GL_MeshState(buf_mesh_t *mesh)
                                {
                                        qglActiveTexture(GL_TEXTURE0_ARB + (mesh_unit = i));CHECKGLERROR
                                }
-                               glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, (mesh_texturergbscale[i] = mesh->texturergbscale[i]));CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, (mesh_texturergbscale[i] = mesh->texturergbscale[i]));CHECKGLERROR
                        }
                }
        }
@@ -621,20 +647,20 @@ void GL_MeshState(buf_mesh_t *mesh)
                {
                        if (mesh_texture[0] == 0)
                        {
-                               glEnable(GL_TEXTURE_2D);CHECKGLERROR
-                               glEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                               qglEnable(GL_TEXTURE_2D);CHECKGLERROR
+                               qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
                        }
-                       glBindTexture(GL_TEXTURE_2D, (mesh_texture[0] = mesh->textures[0]));CHECKGLERROR
+                       qglBindTexture(GL_TEXTURE_2D, (mesh_texture[0] = mesh->textures[0]));CHECKGLERROR
                        if (mesh_texture[0] == 0)
                        {
-                               glDisable(GL_TEXTURE_2D);CHECKGLERROR
-                               glDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                               qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+                               qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
                        }
                }
        }
        if (mesh_blendfunc1 != mesh->blendfunc1 || mesh_blendfunc2 != mesh->blendfunc2)
        {
-               glBlendFunc(mesh_blendfunc1 = mesh->blendfunc1, mesh_blendfunc2 = mesh->blendfunc2);CHECKGLERROR
+               qglBlendFunc(mesh_blendfunc1 = mesh->blendfunc1, mesh_blendfunc2 = mesh->blendfunc2);CHECKGLERROR
                if (mesh_blendfunc2 == GL_ZERO)
                {
                        if (mesh_blendfunc1 == GL_ONE)
@@ -642,7 +668,7 @@ void GL_MeshState(buf_mesh_t *mesh)
                                if (mesh_blend)
                                {
                                        mesh_blend = 0;
-                                       glDisable(GL_BLEND);CHECKGLERROR
+                                       qglDisable(GL_BLEND);CHECKGLERROR
                                }
                        }
                        else
@@ -650,7 +676,7 @@ void GL_MeshState(buf_mesh_t *mesh)
                                if (!mesh_blend)
                                {
                                        mesh_blend = 1;
-                                       glEnable(GL_BLEND);CHECKGLERROR
+                                       qglEnable(GL_BLEND);CHECKGLERROR
                                }
                        }
                }
@@ -659,7 +685,7 @@ void GL_MeshState(buf_mesh_t *mesh)
                        if (!mesh_blend)
                        {
                                mesh_blend = 1;
-                               glEnable(GL_BLEND);CHECKGLERROR
+                               qglEnable(GL_BLEND);CHECKGLERROR
                        }
                }
        }
@@ -667,14 +693,87 @@ void GL_MeshState(buf_mesh_t *mesh)
        {
                mesh_depthtest = mesh->depthtest;
                if (mesh_depthtest)
-                       glEnable(GL_DEPTH_TEST);
+                       qglEnable(GL_DEPTH_TEST);
                else
-                       glDisable(GL_DEPTH_TEST);
+                       qglDisable(GL_DEPTH_TEST);
        }
        if (mesh_depthmask != mesh->depthmask)
        {
-               glDepthMask(mesh_depthmask = mesh->depthmask);CHECKGLERROR
+               qglDepthMask(mesh_depthmask = mesh->depthmask);CHECKGLERROR
+       }
+}
+
+void GL_DrawRangeElements(int firstvert, int endvert, int indexcount, GLuint *index)
+{
+       unsigned int i, j, in;
+       if (gl_mesh_drawmode.integer == 3 && qglDrawRangeElements == NULL)
+               Cvar_SetValueQuick(&gl_mesh_drawmode, 2);
+
+       if (gl_mesh_drawmode.integer == 3)
+       {
+               // GL 1.2 or GL 1.1 with extension
+               qglDrawRangeElements(GL_TRIANGLES, firstvert, endvert, indexcount, GL_UNSIGNED_INT, index);
+       }
+       else if (gl_mesh_drawmode.integer == 2)
+       {
+               // GL 1.1
+               qglDrawElements(GL_TRIANGLES, indexcount, GL_UNSIGNED_INT, index);
+       }
+       else if (gl_mesh_drawmode.integer == 1)
+       {
+               // GL 1.1
+               // feed it manually using glArrayElement
+               qglBegin(GL_TRIANGLES);
+               for (i = 0;i < indexcount;i++)
+                       qglArrayElement(index[i]);
+               qglEnd();
+       }
+       else
+       {
+               // GL 1.1 but not using vertex arrays - 3dfx glquake minigl driver
+               // feed it manually
+               if (gl_mesh_drawmode.integer != 0)
+                       Cvar_SetValueQuick(&gl_mesh_drawmode, 0);
+               qglBegin(GL_TRIANGLES);
+               if (r_multitexture.integer)
+               {
+                       // the minigl doesn't have this (because it does not have ARB_multitexture)
+                       for (i = 0;i < indexcount;i++)
+                       {
+                               in = index[i];
+                               qglColor4ub(buf_bcolor[in].c[0], buf_bcolor[in].c[1], buf_bcolor[in].c[2], buf_bcolor[in].c[3]);
+                               for (j = 0;j < backendunits;j++)
+                                       if (mesh_texture[j])
+                                               qglMultiTexCoord2f(GL_TEXTURE0_ARB + j, buf_texcoord[j][in].t[0], buf_texcoord[j][in].t[1]);
+                               qglVertex3f(buf_vertex[in].v[0], buf_vertex[in].v[1], buf_vertex[in].v[2]);
+                       }
+               }
+               else
+               {
+                       for (i = 0;i < indexcount;i++)
+                       {
+                               in = index[i];
+                               qglColor4ub(buf_bcolor[in].c[0], buf_bcolor[in].c[1], buf_bcolor[in].c[2], buf_bcolor[in].c[3]);
+                               if (mesh_texture[0])
+                                       qglTexCoord2f(buf_texcoord[0][in].t[0], buf_texcoord[0][in].t[1]);
+                               qglVertex3f(buf_vertex[in].v[0], buf_vertex[in].v[1], buf_vertex[in].v[2]);
+                       }
+               }
+               qglEnd();
+       }
+       /*
+       if (qglDrawRangeElements)
+               qglDrawRangeElements(GL_TRIANGLES, firstvert, endvert, indexcount, index);
+       else
+       {
        }
+       #ifdef WIN32
+       // FIXME: dynamic link to GL so we can get DrawRangeElements on WIN32
+       qglDrawElements(GL_TRIANGLES, indexcount, GL_UNSIGNED_INT, index);CHECKGLERROR
+       #else
+       qglDrawRangeElements(GL_TRIANGLES, firstvert, firstvert + mesh->verts, indexcount, GL_UNSIGNED_INT, index);CHECKGLERROR
+       #endif
+       */
 }
 
 // renders mesh buffers, called to flush buffers when full
@@ -697,7 +796,7 @@ void R_Mesh_Render(void)
 
        GL_UpdateFarclip();
 
-       if (!gl_mesh_floatcolors.integer)
+       if (!gl_mesh_floatcolors.integer || gl_mesh_drawmode.integer == 0)
                GL_ConvertColorsFloatToByte();
 
        // lock the arrays now that they will have no further modifications
@@ -710,12 +809,7 @@ void R_Mesh_Render(void)
 
        GL_MeshState(buf_mesh);
        GL_LockArray(0, currentvertex);
-       #ifdef WIN32
-       // FIXME: dynamic link to GL so we can get DrawRangeElements on WIN32
-       glDrawElements(GL_TRIANGLES, buf_mesh->triangles * 3, GL_UNSIGNED_INT, (unsigned int *)&buf_tri[buf_mesh->firsttriangle].index[0]);CHECKGLERROR
-       #else
-       glDrawRangeElements(GL_TRIANGLES, buf_mesh->firstvert, buf_mesh->firstvert + buf_mesh->verts, buf_mesh->triangles * 3, GL_UNSIGNED_INT, (unsigned int *)&buf_tri[buf_mesh->firsttriangle].index[0]);CHECKGLERROR
-       #endif
+       GL_DrawRangeElements(buf_mesh->firstvert, buf_mesh->firstvert + buf_mesh->verts, buf_mesh->triangles * 3, (unsigned int *)&buf_tri[buf_mesh->firsttriangle].index[0]);CHECKGLERROR
 
        if (currentmesh >= 2)
        {
@@ -732,12 +826,7 @@ void R_Mesh_Render(void)
                                for (i = 0;i < indexcount;i++)
                                        index[i] += firstvert;
 
-                       #ifdef WIN32
-                       // FIXME: dynamic link to GL so we can get DrawRangeElements on WIN32
-                       glDrawElements(GL_TRIANGLES, indexcount, GL_UNSIGNED_INT, index);CHECKGLERROR
-                       #else
-                       glDrawRangeElements(GL_TRIANGLES, firstvert, firstvert + mesh->verts, indexcount, GL_UNSIGNED_INT, index);CHECKGLERROR
-                       #endif
+                       GL_DrawRangeElements(firstvert, firstvert + mesh->verts, indexcount, index);CHECKGLERROR
                }
        }
 
@@ -760,45 +849,54 @@ void R_Mesh_Finish(void)
                for (i = backendunits - 1;i >= 0;i--)
                {
                        qglActiveTexture(GL_TEXTURE0_ARB + i);CHECKGLERROR
-                       glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);CHECKGLERROR
+                       qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);CHECKGLERROR
                        if (gl_combine.integer)
                        {
-                               glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0f);CHECKGLERROR
+                               qglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1);CHECKGLERROR
                        }
                        if (i > 0)
                        {
-                               glDisable(GL_TEXTURE_2D);CHECKGLERROR
+                               qglDisable(GL_TEXTURE_2D);CHECKGLERROR
                        }
                        else
                        {
-                               glEnable(GL_TEXTURE_2D);CHECKGLERROR
+                               qglEnable(GL_TEXTURE_2D);CHECKGLERROR
                        }
-                       glBindTexture(GL_TEXTURE_2D, 0);CHECKGLERROR
+                       qglBindTexture(GL_TEXTURE_2D, 0);CHECKGLERROR
 
-                       qglClientActiveTexture(GL_TEXTURE0_ARB + i);CHECKGLERROR
-                       glDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                       if (usedarrays)
+                       {
+                               qglClientActiveTexture(GL_TEXTURE0_ARB + i);CHECKGLERROR
+                               qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+                       }
                }
        }
        else
        {
-               glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);CHECKGLERROR
-               glEnable(GL_TEXTURE_2D);CHECKGLERROR
-               glDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+               qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);CHECKGLERROR
+               qglEnable(GL_TEXTURE_2D);CHECKGLERROR
+               if (usedarrays)
+               {
+                       qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+               }
+       }
+       if (usedarrays)
+       {
+               qglDisableClientState(GL_COLOR_ARRAY);CHECKGLERROR
+               qglDisableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
        }
-       glDisableClientState(GL_COLOR_ARRAY);CHECKGLERROR
-       glDisableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
 
-       glDisable(GL_BLEND);CHECKGLERROR
-       glEnable(GL_DEPTH_TEST);CHECKGLERROR
-       glDepthMask(true);CHECKGLERROR
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);CHECKGLERROR
+       qglDisable(GL_BLEND);CHECKGLERROR
+       qglEnable(GL_DEPTH_TEST);CHECKGLERROR
+       qglDepthMask(GL_TRUE);CHECKGLERROR
+       qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);CHECKGLERROR
 }
 
 void R_Mesh_ClearDepth(void)
 {
        R_Mesh_AddTransparent();
        R_Mesh_Finish();
-       glClear(GL_DEPTH_BUFFER_BIT);
+       qglClear(GL_DEPTH_BUFFER_BIT);
        R_Mesh_Start();
 }
 
@@ -1436,7 +1534,7 @@ qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height)
                return false;
 
        buffer = Mem_Alloc(tempmempool, width*height*3);
-       glReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer);
+       qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer);
        CHECKGLERROR
 
        // LordHavoc: compensate for v_overbrightbits when using hardware gamma
@@ -1457,17 +1555,17 @@ void R_ClearScreen(void)
        if (r_render.integer)
        {
                // clear to black
-               glClearColor(0,0,0,0);CHECKGLERROR
+               qglClearColor(0,0,0,0);CHECKGLERROR
                // clear the screen
-               glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);CHECKGLERROR
+               qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);CHECKGLERROR
                // set dithering mode
                if (gl_dither.integer)
                {
-                       glEnable(GL_DITHER);CHECKGLERROR
+                       qglEnable(GL_DITHER);CHECKGLERROR
                }
                else
                {
-                       glDisable(GL_DITHER);CHECKGLERROR
+                       qglDisable(GL_DITHER);CHECKGLERROR
                }
        }
 }
@@ -1513,5 +1611,5 @@ void SCR_UpdateScreen (void)
 
        // tell driver to commit it's partially full geometry queue to the rendering queue
        // (this doesn't wait for the commands themselves to complete)
-       glFlush();
+       qglFlush();
 }
index edab967..88c6275 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -314,45 +314,45 @@ void R_DrawQueue(void)
        if (!r_render.integer)
                return;
 
-       glViewport(vid.realx, vid.realy, vid.realwidth, vid.realheight);
+       qglViewport(vid.realx, vid.realy, vid.realwidth, vid.realheight);
 
-       glMatrixMode(GL_PROJECTION);
-    glLoadIdentity();
-       glOrtho(0, vid.conwidth, vid.conheight, 0, -99999, 99999);
+       qglMatrixMode(GL_PROJECTION);
+    qglLoadIdentity();
+       qglOrtho(0, vid.conwidth, vid.conheight, 0, -99999, 99999);
 
-       glMatrixMode(GL_MODELVIEW);
-    glLoadIdentity();
+       qglMatrixMode(GL_MODELVIEW);
+    qglLoadIdentity();
 
-       glDisable(GL_DEPTH_TEST);
-       glDisable(GL_CULL_FACE);
-       glEnable(GL_BLEND);
-       glEnable(GL_TEXTURE_2D);
-       glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+       qglDisable(GL_DEPTH_TEST);
+       qglDisable(GL_CULL_FACE);
+       qglEnable(GL_BLEND);
+       qglEnable(GL_TEXTURE_2D);
+       qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 
        chartexnum = R_GetTexture(char_texture);
 
        additive = false;
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        currentpic = "";
        pic = NULL;
-       glBindTexture(GL_TEXTURE_2D, 0);
+       qglBindTexture(GL_TEXTURE_2D, 0);
        color = 0;
-       glColor4ub(0,0,0,0);
+       qglColor4ub(0,0,0,0);
 
        // LordHavoc: NEAREST mode on text if not scaling up
        /*
        if (vid.realwidth <= (int) vid.conwidth)
        {
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
                CHECKGLERROR
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
                CHECKGLERROR
        }
        else
        {
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                CHECKGLERROR
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
                CHECKGLERROR
        }
        */
@@ -370,10 +370,10 @@ void R_DrawQueue(void)
                                if (batch)
                                {
                                        batch = false;
-                                       glEnd();
+                                       qglEnd();
                                }
                                additive = true;
-                               glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+                               qglBlendFunc(GL_SRC_ALPHA, GL_ONE);
                        }
                }
                else
@@ -383,21 +383,21 @@ void R_DrawQueue(void)
                                if (batch)
                                {
                                        batch = false;
-                                       glEnd();
+                                       qglEnd();
                                }
                                additive = false;
-                               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+                               qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                        }
                }
                if (color != dq->color)
                {
                        color = dq->color;
-                       glColor4ub((qbyte)(((color >> 24) & 0xFF) >> overbright), (qbyte)(((color >> 16) & 0xFF) >> overbright), (qbyte)(((color >> 8) & 0xFF) >> overbright), (qbyte)(color & 0xFF));
+                       qglColor4ub((qbyte)(((color >> 24) & 0xFF) >> overbright), (qbyte)(((color >> 16) & 0xFF) >> overbright), (qbyte)(((color >> 8) & 0xFF) >> overbright), (qbyte)(color & 0xFF));
                }
                if (batch && batchcount > 128)
                {
                        batch = false;
-                       glEnd();
+                       qglEnd();
                }
                x = dq->x;
                y = dq->y;
@@ -414,11 +414,11 @@ void R_DrawQueue(void)
                                        if (batch)
                                        {
                                                batch = false;
-                                               glEnd();
+                                               qglEnd();
                                        }
                                        currentpic = str;
                                        pic = Draw_CachePic(str);
-                                       glBindTexture(GL_TEXTURE_2D, R_GetTexture(pic->tex));
+                                       qglBindTexture(GL_TEXTURE_2D, R_GetTexture(pic->tex));
                                }
                                if (w == 0)
                                        w = pic->width;
@@ -427,14 +427,14 @@ void R_DrawQueue(void)
                                if (!batch)
                                {
                                        batch = true;
-                                       glBegin(GL_QUADS);
+                                       qglBegin(GL_QUADS);
                                        batchcount = 0;
                                }
                                //DrawQuad(dq->x, dq->y, w, h, 0, 0, 1, 1);
-                               glTexCoord2f (0, 0);glVertex2f (x  , y  );
-                               glTexCoord2f (1, 0);glVertex2f (x+w, y  );
-                               glTexCoord2f (1, 1);glVertex2f (x+w, y+h);
-                               glTexCoord2f (0, 1);glVertex2f (x  , y+h);
+                               qglTexCoord2f (0, 0);qglVertex2f (x  , y  );
+                               qglTexCoord2f (1, 0);qglVertex2f (x+w, y  );
+                               qglTexCoord2f (1, 1);qglVertex2f (x+w, y+h);
+                               qglTexCoord2f (0, 1);qglVertex2f (x  , y+h);
                                batchcount++;
                        }
                        else
@@ -444,22 +444,22 @@ void R_DrawQueue(void)
                                        if (batch)
                                        {
                                                batch = false;
-                                               glEnd();
+                                               qglEnd();
                                        }
                                        currentpic = "";
-                                       glBindTexture(GL_TEXTURE_2D, 0);
+                                       qglBindTexture(GL_TEXTURE_2D, 0);
                                }
                                if (!batch)
                                {
                                        batch = true;
-                                       glBegin(GL_QUADS);
+                                       qglBegin(GL_QUADS);
                                        batchcount = 0;
                                }
                                //DrawQuad(dq->x, dq->y, dq->scalex, dq->scaley, 0, 0, 1, 1);
-                               glTexCoord2f (0, 0);glVertex2f (x  , y  );
-                               glTexCoord2f (1, 0);glVertex2f (x+w, y  );
-                               glTexCoord2f (1, 1);glVertex2f (x+w, y+h);
-                               glTexCoord2f (0, 1);glVertex2f (x  , y+h);
+                               qglTexCoord2f (0, 0);qglVertex2f (x  , y  );
+                               qglTexCoord2f (1, 0);qglVertex2f (x+w, y  );
+                               qglTexCoord2f (1, 1);qglVertex2f (x+w, y+h);
+                               qglTexCoord2f (0, 1);qglVertex2f (x  , y+h);
                                batchcount++;
                        }
                        break;
@@ -470,15 +470,15 @@ void R_DrawQueue(void)
                                if (batch)
                                {
                                        batch = false;
-                                       glEnd();
+                                       qglEnd();
                                }
                                currentpic = "conchars";
-                               glBindTexture(GL_TEXTURE_2D, chartexnum);
+                               qglBindTexture(GL_TEXTURE_2D, chartexnum);
                        }
                        if (!batch)
                        {
                                batch = true;
-                               glBegin(GL_QUADS);
+                               qglBegin(GL_QUADS);
                                batchcount = 0;
                        }
                        while ((num = *str++) && x < vid.conwidth)
@@ -490,10 +490,10 @@ void R_DrawQueue(void)
                                        u = 0.0625f - (1.0f / 256.0f);
                                        v = 0.0625f - (1.0f / 256.0f);
                                        //DrawQuad(x, y, w, h, (num & 15)*0.0625f + (0.5f / 256.0f), (num >> 4)*0.0625f + (0.5f / 256.0f), 0.0625f - (1.0f / 256.0f), 0.0625f - (1.0f / 256.0f));
-                                       glTexCoord2f (s  , t  );glVertex2f (x  , y  );
-                                       glTexCoord2f (s+u, t  );glVertex2f (x+w, y  );
-                                       glTexCoord2f (s+u, t+v);glVertex2f (x+w, y+h);
-                                       glTexCoord2f (s  , t+v);glVertex2f (x  , y+h);
+                                       qglTexCoord2f (s  , t  );qglVertex2f (x  , y  );
+                                       qglTexCoord2f (s+u, t  );qglVertex2f (x+w, y  );
+                                       qglTexCoord2f (s+u, t+v);qglVertex2f (x+w, y+h);
+                                       qglTexCoord2f (s  , t+v);qglVertex2f (x  , y+h);
                                        batchcount++;
                                }
                                x += w;
@@ -502,72 +502,72 @@ void R_DrawQueue(void)
                }
        }
        if (batch)
-               glEnd();
+               qglEnd();
        CHECKGLERROR
 
        if (!v_hwgamma.integer)
        {
-               glDisable(GL_TEXTURE_2D);
+               qglDisable(GL_TEXTURE_2D);
                CHECKGLERROR
                t = v_contrast.value * (float) (1 << v_overbrightbits.integer);
                if (t >= 1.01f)
                {
-                       glBlendFunc (GL_DST_COLOR, GL_ONE);
+                       qglBlendFunc (GL_DST_COLOR, GL_ONE);
                        CHECKGLERROR
-                       glBegin (GL_TRIANGLES);
+                       qglBegin (GL_TRIANGLES);
                        while (t >= 1.01f)
                        {
                                num = (int) ((t - 1.0f) * 255.0f);
                                if (num > 255)
                                        num = 255;
-                               glColor4ub ((qbyte) num, (qbyte) num, (qbyte) num, 255);
-                               glVertex2f (-5000, -5000);
-                               glVertex2f (10000, -5000);
-                               glVertex2f (-5000, 10000);
+                               qglColor4ub ((qbyte) num, (qbyte) num, (qbyte) num, 255);
+                               qglVertex2f (-5000, -5000);
+                               qglVertex2f (10000, -5000);
+                               qglVertex2f (-5000, 10000);
                                t *= 0.5;
                        }
-                       glEnd ();
+                       qglEnd ();
                        CHECKGLERROR
                }
                else if (t <= 0.99f)
                {
-                       glBlendFunc(GL_ZERO, GL_SRC_COLOR);
+                       qglBlendFunc(GL_ZERO, GL_SRC_COLOR);
                        CHECKGLERROR
-                       glBegin(GL_TRIANGLES);
+                       qglBegin(GL_TRIANGLES);
                        num = (int) (t * 255.0f);
-                       glColor4ub ((qbyte) num, (qbyte) num, (qbyte) num, 255);
-                       glVertex2f (-5000, -5000);
-                       glVertex2f (10000, -5000);
-                       glVertex2f (-5000, 10000);
-                       glEnd();
+                       qglColor4ub ((qbyte) num, (qbyte) num, (qbyte) num, 255);
+                       qglVertex2f (-5000, -5000);
+                       qglVertex2f (10000, -5000);
+                       qglVertex2f (-5000, 10000);
+                       qglEnd();
                        CHECKGLERROR
                }
                if (v_brightness.value >= 0.01f)
                {
-                       glBlendFunc (GL_ONE, GL_ONE);
+                       qglBlendFunc (GL_ONE, GL_ONE);
                        CHECKGLERROR
                        num = (int) (v_brightness.value * 255.0f);
-                       glColor4ub ((qbyte) num, (qbyte) num, (qbyte) num, 255);
+                       qglColor4ub ((qbyte) num, (qbyte) num, (qbyte) num, 255);
                        CHECKGLERROR
-                       glBegin (GL_TRIANGLES);
-                       glVertex2f (-5000, -5000);
-                       glVertex2f (10000, -5000);
-                       glVertex2f (-5000, 10000);
-                       glEnd ();
+                       qglBegin (GL_TRIANGLES);
+                       qglVertex2f (-5000, -5000);
+                       qglVertex2f (10000, -5000);
+                       qglVertex2f (-5000, 10000);
+                       qglEnd ();
                        CHECKGLERROR
                }
-               glEnable(GL_TEXTURE_2D);
+               qglEnable(GL_TEXTURE_2D);
                CHECKGLERROR
        }
 
-       glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        CHECKGLERROR
-       glEnable (GL_CULL_FACE);
+       qglEnable (GL_CULL_FACE);
        CHECKGLERROR
-       glEnable (GL_DEPTH_TEST);
+       qglEnable (GL_DEPTH_TEST);
        CHECKGLERROR
-       glDisable (GL_BLEND);
+       qglDisable (GL_BLEND);
        CHECKGLERROR
-       glColor4ub (255, 255, 255, 255);
+       qglColor4ub (255, 255, 255, 255);
        CHECKGLERROR
 }
index b06ebf8..cae6f82 100644 (file)
@@ -98,7 +98,7 @@ static void R_TimeRefresh_f (void)
 
        intimerefresh = 1;
        start = Sys_DoubleTime ();
-       //glDrawBuffer (GL_FRONT);
+       //qglDrawBuffer (GL_FRONT);
        for (i = 0;i < 128;i++)
        {
                r_refdef.viewangles[0] = 0;
@@ -107,7 +107,7 @@ static void R_TimeRefresh_f (void)
                CL_UpdateScreen();
                //R_RenderView();
        }
-       //glDrawBuffer  (GL_BACK);
+       //qglDrawBuffer  (GL_BACK);
 
        stop = Sys_DoubleTime ();
        intimerefresh = 0;
@@ -347,10 +347,10 @@ void GL_Init (void)
        // LordHavoc: report supported extensions
        Con_Printf ("\nengine extensions: %s\n", ENGINE_EXTENSIONS);
 
-       glCullFace(GL_FRONT);
-       glEnable(GL_TEXTURE_2D);
+       qglCullFace(GL_FRONT);
+       qglEnable(GL_TEXTURE_2D);
 
-//     glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
+//     qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
 }
 
 
@@ -469,13 +469,13 @@ void R_DrawViewModel (void)
 //     if (gl_viewmodeldepthhack.integer)
 //     {
 //             R_Mesh_Render();
-//             glDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin));
+//             qglDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin));
 //     }
        currentrenderentity->model->Draw();
 //     if (gl_viewmodeldepthhack.integer)
 //     {
 //             R_Mesh_Render();
-//             glDepthRange (gldepthmin, gldepthmax);
+//             qglDepthRange (gldepthmin, gldepthmax);
 //     }
 }
 
@@ -580,27 +580,27 @@ static void R_BlendView(void)
        R_Mesh_Draw(&m);
 
        /*
-       glMatrixMode(GL_PROJECTION);
-       glLoadIdentity ();
-       glOrtho  (0, 1, 1, 0, -99999, 99999);
-       glMatrixMode(GL_MODELVIEW);
-       glLoadIdentity ();
-       glDisable (GL_DEPTH_TEST);
-       glDisable (GL_CULL_FACE);
-       glDisable(GL_TEXTURE_2D);
-       glEnable(GL_BLEND);
-       glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-       glBegin (GL_TRIANGLES);
-       glColor4f (r_refdef.viewblend[0] * overbrightscale, r_refdef.viewblend[1] * overbrightscale, r_refdef.viewblend[2] * overbrightscale, r_refdef.viewblend[3]);
-       glVertex2f (-5, -5);
-       glVertex2f (10, -5);
-       glVertex2f (-5, 10);
-       glEnd ();
-
-       glEnable (GL_CULL_FACE);
-       glEnable (GL_DEPTH_TEST);
-       glDisable(GL_BLEND);
-       glEnable(GL_TEXTURE_2D);
+       qglMatrixMode(GL_PROJECTION);
+       qglLoadIdentity ();
+       qglOrtho  (0, 1, 1, 0, -99999, 99999);
+       qglMatrixMode(GL_MODELVIEW);
+       qglLoadIdentity ();
+       qglDisable (GL_DEPTH_TEST);
+       qglDisable (GL_CULL_FACE);
+       qglDisable(GL_TEXTURE_2D);
+       qglEnable(GL_BLEND);
+       qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       qglBegin (GL_TRIANGLES);
+       qglColor4f (r_refdef.viewblend[0] * overbrightscale, r_refdef.viewblend[1] * overbrightscale, r_refdef.viewblend[2] * overbrightscale, r_refdef.viewblend[3]);
+       qglVertex2f (-5, -5);
+       qglVertex2f (10, -5);
+       qglVertex2f (-5, 10);
+       qglEnd ();
+
+       qglEnable (GL_CULL_FACE);
+       qglEnable (GL_DEPTH_TEST);
+       qglDisable(GL_BLEND);
+       qglEnable(GL_TEXTURE_2D);
        */
 }
 
index f8f1fa3..5648a1e 100644 (file)
@@ -360,12 +360,12 @@ static void GL_TextureMode_f (void)
                        // only update already uploaded images
                        if (!(image->flags & GLTEXF_UPLOAD))
                        {
-                               glBindTexture(GL_TEXTURE_2D, image->texnum);
+                               qglBindTexture(GL_TEXTURE_2D, image->texnum);
                                if (image->flags & TEXF_MIPMAP)
-                                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
+                                       qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
                                else
-                                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
-                               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+                                       qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
+                               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
                        }
                }
        }
@@ -525,7 +525,7 @@ static void R_Upload(gltexture_t *glt, qbyte *data)
        qbyte *prevbuffer;
        prevbuffer = data;
 
-       glBindTexture(GL_TEXTURE_2D, glt->image->texnum);
+       qglBindTexture(GL_TEXTURE_2D, glt->image->texnum);
        CHECKGLERROR
 
        gl_backend_rebindtextures = true;
@@ -552,11 +552,11 @@ static void R_Upload(gltexture_t *glt, qbyte *data)
                        Con_DPrintf("uploaded new fragments image\n");
                        glt->image->flags &= ~GLTEXF_UPLOAD;
                        memset(resizebuffer, 255, glt->image->width * glt->image->height * glt->image->bytesperpixel);
-                       glTexImage2D (GL_TEXTURE_2D, 0, glt->image->glinternalformat, glt->image->width, glt->image->height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, resizebuffer);
+                       qglTexImage2D (GL_TEXTURE_2D, 0, glt->image->glinternalformat, glt->image->width, glt->image->height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, resizebuffer);
                        CHECKGLERROR
-                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
+                       qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
                        CHECKGLERROR
-                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+                       qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
                        CHECKGLERROR
                }
 
@@ -573,7 +573,7 @@ static void R_Upload(gltexture_t *glt, qbyte *data)
                        prevbuffer = colorconvertbuffer;
                }
 
-               glTexSubImage2D(GL_TEXTURE_2D, 0, glt->x, glt->y, glt->width, glt->height, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
+               qglTexSubImage2D(GL_TEXTURE_2D, 0, glt->x, glt->y, glt->width, glt->height, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
                CHECKGLERROR
                return;
        }
@@ -634,7 +634,7 @@ static void R_Upload(gltexture_t *glt, qbyte *data)
                internalformat = 4;
 
        mip = 0;
-       glTexImage2D(GL_TEXTURE_2D, mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
+       qglTexImage2D(GL_TEXTURE_2D, mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
        CHECKGLERROR
        if (glt->flags & TEXF_MIPMAP)
        {
@@ -643,20 +643,20 @@ static void R_Upload(gltexture_t *glt, qbyte *data)
                        Image_MipReduce(prevbuffer, resizebuffer, &width, &height, 1, 1, glt->image->bytesperpixel);
                        prevbuffer = resizebuffer;
 
-                       glTexImage2D(GL_TEXTURE_2D, mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
+                       qglTexImage2D(GL_TEXTURE_2D, mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
                        CHECKGLERROR
                }
 
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
+               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
                CHECKGLERROR
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
                CHECKGLERROR
        }
        else
        {
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
+               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
                CHECKGLERROR
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
                CHECKGLERROR
        }
 }
index 7a9d016..f5cf1a7 100644 (file)
--- a/glquake.h
+++ b/glquake.h
@@ -49,8 +49,9 @@ extern const char *gl_renderer;
 extern const char *gl_version;
 extern const char *gl_extensions;
 
-#ifndef _WIN32
-#define APIENTRY /* */
+// wgl uses APIENTRY
+#ifndef APIENTRY
+#define APIENTRY
 #endif
 
 // for platforms (wgl) that do not use GLAPIENTRY
@@ -60,7 +61,7 @@ extern const char *gl_extensions;
 
 // GL_ARB_multitexture
 extern int gl_textureunits;
-//extern void (GLAPIENTRY *qglMultiTexCoord2f) (GLenum, GLfloat, GLfloat);
+extern void (GLAPIENTRY *qglMultiTexCoord2f) (GLenum, GLfloat, GLfloat);
 extern void (GLAPIENTRY *qglActiveTexture) (GLenum);
 extern void (GLAPIENTRY *qglClientActiveTexture) (GLenum);
 #ifndef GL_ACTIVE_TEXTURE_ARB
@@ -135,13 +136,89 @@ extern int gl_combine_extension;
 
 extern cvar_t gl_combine;
 
-#ifdef WIN32
-#else
-//#ifndef MESA
-//extern void (GLAPIENTRY *glColorTableEXT)(int, int, int, int, int, const void*);
-//#endif
-
-#endif
+extern void (GLAPIENTRY *qglClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+
+extern void (GLAPIENTRY *qglClear)(GLbitfield mask);
+
+//extern void (GLAPIENTRY *qglAlphaFunc)(GLenum func, GLclampf ref);
+extern void (GLAPIENTRY *qglBlendFunc)(GLenum sfactor, GLenum dfactor);
+extern void (GLAPIENTRY *qglCullFace)(GLenum mode);
+
+extern void (GLAPIENTRY *qglDrawBuffer)(GLenum mode);
+extern void (GLAPIENTRY *qglReadBuffer)(GLenum mode);
+extern void (GLAPIENTRY *qglEnable)(GLenum cap);
+extern void (GLAPIENTRY *qglDisable)(GLenum cap);
+//extern GLboolean GLAPIENTRY *qglIsEnabled)(GLenum cap);
+
+extern void (GLAPIENTRY *qglEnableClientState)(GLenum cap);
+extern void (GLAPIENTRY *qglDisableClientState)(GLenum cap);
+
+//extern void (GLAPIENTRY *qglGetBooleanv)(GLenum pname, GLboolean *params);
+//extern void (GLAPIENTRY *qglGetDoublev)(GLenum pname, GLdouble *params);
+//extern void (GLAPIENTRY *qglGetFloatv)(GLenum pname, GLfloat *params);
+extern void (GLAPIENTRY *qglGetIntegerv)(GLenum pname, GLint *params);
+
+extern GLenum (GLAPIENTRY *qglGetError)(void);
+extern const GLubyte* (GLAPIENTRY *qglGetString)(GLenum name);
+extern void (GLAPIENTRY *qglFinish)(void);
+extern void (GLAPIENTRY *qglFlush)(void);
+
+extern void (GLAPIENTRY *qglClearDepth)(GLclampd depth);
+extern void (GLAPIENTRY *qglDepthFunc)(GLenum func);
+extern void (GLAPIENTRY *qglDepthMask)(GLboolean flag);
+extern void (GLAPIENTRY *qglDepthRange)(GLclampd near_val, GLclampd far_val);
+
+extern void (GLAPIENTRY *qglDrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+extern void (GLAPIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+extern void (GLAPIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+//extern void (GLAPIENTRY *qglNormalPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
+extern void (GLAPIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+extern void (GLAPIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+extern void (GLAPIENTRY *qglArrayElement)(GLint i);
+
+extern void (GLAPIENTRY *qglColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+extern void (GLAPIENTRY *qglTexCoord2f)(GLfloat s, GLfloat t);
+extern void (GLAPIENTRY *qglVertex2f)(GLfloat x, GLfloat y);
+extern void (GLAPIENTRY *qglVertex3f)(GLfloat x, GLfloat y, GLfloat z);
+extern void (GLAPIENTRY *qglBegin)(GLenum mode);
+extern void (GLAPIENTRY *qglEnd)(void);
+
+extern void (GLAPIENTRY *qglMatrixMode)(GLenum mode);
+extern void (GLAPIENTRY *qglOrtho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val);
+extern void (GLAPIENTRY *qglFrustum)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val);
+extern void (GLAPIENTRY *qglViewport)(GLint x, GLint y, GLsizei width, GLsizei height);
+//extern void (GLAPIENTRY *qglPushMatrix)(void);
+//extern void (GLAPIENTRY *qglPopMatrix)(void);
+extern void (GLAPIENTRY *qglLoadIdentity)(void);
+//extern void (GLAPIENTRY *qglLoadMatrixd)(const GLdouble *m);
+//extern void (GLAPIENTRY *qglLoadMatrixf)(const GLfloat *m);
+//extern void (GLAPIENTRY *qglMultMatrixd)(const GLdouble *m);
+//extern void (GLAPIENTRY *qglMultMatrixf)(const GLfloat *m);
+//extern void (GLAPIENTRY *qglRotated)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
+extern void (GLAPIENTRY *qglRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+//extern void (GLAPIENTRY *qglScaled)(GLdouble x, GLdouble y, GLdouble z);
+//extern void (GLAPIENTRY *qglScalef)(GLfloat x, GLfloat y, GLfloat z);
+//extern void (GLAPIENTRY *qglTranslated)(GLdouble x, GLdouble y, GLdouble z);
+extern void (GLAPIENTRY *qglTranslatef)(GLfloat x, GLfloat y, GLfloat z);
+
+extern void (GLAPIENTRY *qglReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
+
+//extern void (GLAPIENTRY *qglStencilFunc)(GLenum func, GLint ref, GLuint mask);
+//extern void (GLAPIENTRY *qglStencilMask)(GLuint mask);
+//extern void (GLAPIENTRY *qglStencilOp)(GLenum fail, GLenum zfail, GLenum zpass);
+//extern void (GLAPIENTRY *qglClearStencil)(GLint s);
+
+//extern void (GLAPIENTRY *qglTexEnvf)(GLenum target, GLenum pname, GLfloat param);
+extern void (GLAPIENTRY *qglTexEnvi)(GLenum target, GLenum pname, GLint param);
+
+//extern void (GLAPIENTRY *qglTexParameterf)(GLenum target, GLenum pname, GLfloat param);
+extern void (GLAPIENTRY *qglTexParameteri)(GLenum target, GLenum pname, GLint param);
+
+extern void (GLAPIENTRY *qglTexImage2D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels );
+
+extern void (GLAPIENTRY *qglBindTexture)(GLenum target, GLuint texture);
+
+extern void (GLAPIENTRY *qglTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
 
 #define DEBUGGL
 
index ef49a7f..4f00421 100644 (file)
@@ -23,7 +23,7 @@ cvar_t in_pitch_max = {0, "in_pitch_max", "90"};
 cvar_t m_filter = {CVAR_SAVE, "m_filter","0"};
 
 // GL_ARB_multitexture
-//void (GLAPIENTRY *qglMultiTexCoord2f) (GLenum, GLfloat, GLfloat);
+void (GLAPIENTRY *qglMultiTexCoord2f) (GLenum, GLfloat, GLfloat);
 void (GLAPIENTRY *qglActiveTexture) (GLenum);
 void (GLAPIENTRY *qglClientActiveTexture) (GLenum);
 
@@ -31,6 +31,94 @@ void (GLAPIENTRY *qglClientActiveTexture) (GLenum);
 void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count);
 void (GLAPIENTRY *qglUnlockArraysEXT) (void);
 
+
+// general GL functions
+
+void (GLAPIENTRY *qglClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+
+void (GLAPIENTRY *qglClear)(GLbitfield mask);
+
+//void (GLAPIENTRY *qglAlphaFunc)(GLenum func, GLclampf ref);
+void (GLAPIENTRY *qglBlendFunc)(GLenum sfactor, GLenum dfactor);
+void (GLAPIENTRY *qglCullFace)(GLenum mode);
+
+void (GLAPIENTRY *qglDrawBuffer)(GLenum mode);
+void (GLAPIENTRY *qglReadBuffer)(GLenum mode);
+void (GLAPIENTRY *qglEnable)(GLenum cap);
+void (GLAPIENTRY *qglDisable)(GLenum cap);
+//GLboolean GLAPIENTRY *qglIsEnabled)(GLenum cap);
+
+void (GLAPIENTRY *qglEnableClientState)(GLenum cap);
+void (GLAPIENTRY *qglDisableClientState)(GLenum cap);
+
+//void (GLAPIENTRY *qglGetBooleanv)(GLenum pname, GLboolean *params);
+//void (GLAPIENTRY *qglGetDoublev)(GLenum pname, GLdouble *params);
+//void (GLAPIENTRY *qglGetFloatv)(GLenum pname, GLfloat *params);
+void (GLAPIENTRY *qglGetIntegerv)(GLenum pname, GLint *params);
+
+GLenum (GLAPIENTRY *qglGetError)(void);
+const GLubyte* (GLAPIENTRY *qglGetString)(GLenum name);
+void (GLAPIENTRY *qglFinish)(void);
+void (GLAPIENTRY *qglFlush)(void);
+
+void (GLAPIENTRY *qglClearDepth)(GLclampd depth);
+void (GLAPIENTRY *qglDepthFunc)(GLenum func);
+void (GLAPIENTRY *qglDepthMask)(GLboolean flag);
+void (GLAPIENTRY *qglDepthRange)(GLclampd near_val, GLclampd far_val);
+
+void (GLAPIENTRY *qglDrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+void (GLAPIENTRY *qglDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+void (GLAPIENTRY *qglVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+//void (GLAPIENTRY *qglNormalPointer)(GLenum type, GLsizei stride, const GLvoid *ptr);
+void (GLAPIENTRY *qglColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+void (GLAPIENTRY *qglTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+void (GLAPIENTRY *qglArrayElement)(GLint i);
+
+void (GLAPIENTRY *qglColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+void (GLAPIENTRY *qglTexCoord2f)(GLfloat s, GLfloat t);
+void (GLAPIENTRY *qglVertex2f)(GLfloat x, GLfloat y);
+void (GLAPIENTRY *qglVertex3f)(GLfloat x, GLfloat y, GLfloat z);
+void (GLAPIENTRY *qglBegin)(GLenum mode);
+void (GLAPIENTRY *qglEnd)(void);
+
+void (GLAPIENTRY *qglMatrixMode)(GLenum mode);
+void (GLAPIENTRY *qglOrtho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val);
+void (GLAPIENTRY *qglFrustum)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val);
+void (GLAPIENTRY *qglViewport)(GLint x, GLint y, GLsizei width, GLsizei height);
+//void (GLAPIENTRY *qglPushMatrix)(void);
+//void (GLAPIENTRY *qglPopMatrix)(void);
+void (GLAPIENTRY *qglLoadIdentity)(void);
+//void (GLAPIENTRY *qglLoadMatrixd)(const GLdouble *m);
+//void (GLAPIENTRY *qglLoadMatrixf)(const GLfloat *m);
+//void (GLAPIENTRY *qglMultMatrixd)(const GLdouble *m);
+//void (GLAPIENTRY *qglMultMatrixf)(const GLfloat *m);
+//void (GLAPIENTRY *qglRotated)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
+void (GLAPIENTRY *qglRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+//void (GLAPIENTRY *qglScaled)(GLdouble x, GLdouble y, GLdouble z);
+//void (GLAPIENTRY *qglScalef)(GLfloat x, GLfloat y, GLfloat z);
+//void (GLAPIENTRY *qglTranslated)(GLdouble x, GLdouble y, GLdouble z);
+void (GLAPIENTRY *qglTranslatef)(GLfloat x, GLfloat y, GLfloat z);
+
+void (GLAPIENTRY *qglReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
+
+//void (GLAPIENTRY *qglStencilFunc)(GLenum func, GLint ref, GLuint mask);
+//void (GLAPIENTRY *qglStencilMask)(GLuint mask);
+//void (GLAPIENTRY *qglStencilOp)(GLenum fail, GLenum zfail, GLenum zpass);
+//void (GLAPIENTRY *qglClearStencil)(GLint s);
+
+//void (GLAPIENTRY *qglTexEnvf)(GLenum target, GLenum pname, GLfloat param);
+void (GLAPIENTRY *qglTexEnvi)(GLenum target, GLenum pname, GLint param);
+
+//void (GLAPIENTRY *qglTexParameterf)(GLenum target, GLenum pname, GLfloat param);
+void (GLAPIENTRY *qglTexParameteri)(GLenum target, GLenum pname, GLint param);
+
+void (GLAPIENTRY *qglTexImage2D)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+
+void (GLAPIENTRY *qglBindTexture)(GLenum target, GLuint texture);
+
+void (GLAPIENTRY *qglTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+
+
 typedef struct
 {
        char *name;
@@ -47,9 +135,85 @@ typedef struct
 }
 gl_extensioninfo_t;
 
+static gl_extensionfunctionlist_t opengl110funcs[] =
+{
+       {"glClearColor", (void **) &qglClearColor},
+       {"glClear", (void **) &qglClear},
+//     {"glAlphaFunc", (void **) &qglAlphaFunc},
+       {"glBlendFunc", (void **) &qglBlendFunc},
+       {"glCullFace", (void **) &qglCullFace},
+       {"glDrawBuffer", (void **) &qglDrawBuffer},
+       {"glReadBuffer", (void **) &qglReadBuffer},
+       {"glEnable", (void **) &qglEnable},
+       {"glDisable", (void **) &qglDisable},
+//     {"glIsEnabled", (void **) &qglIsEnabled},
+       {"glEnableClientState", (void **) &qglEnableClientState},
+       {"glDisableClientState", (void **) &qglDisableClientState},
+//     {"glGetBooleanv", (void **) &qglGetBooleanv},
+//     {"glGetDoublev", (void **) &qglGetDoublev},
+//     {"glGetFloatv", (void **) &qglGetFloatv},
+       {"glGetIntegerv", (void **) &qglGetIntegerv},
+       {"glGetError", (void **) &qglGetError},
+       {"glGetString", (void **) &qglGetString},
+       {"glFinish", (void **) &qglFinish},
+       {"glFlush", (void **) &qglFlush},
+       {"glClearDepth", (void **) &qglClearDepth},
+       {"glDepthFunc", (void **) &qglDepthFunc},
+       {"glDepthMask", (void **) &qglDepthMask},
+       {"glDepthRange", (void **) &qglDepthRange},
+       {"glDrawElements", (void **) &qglDrawElements},
+       {"glVertexPointer", (void **) &qglVertexPointer},
+//     {"glNormalPointer", (void **) &qglNormalPointer},
+       {"glColorPointer", (void **) &qglColorPointer},
+       {"glTexCoordPointer", (void **) &qglTexCoordPointer},
+       {"glArrayElement", (void **) &qglArrayElement},
+       {"glColor4ub", (void **) &qglColor4ub},
+       {"glTexCoord2f", (void **) &qglTexCoord2f},
+       {"glVertex2f", (void **) &qglVertex2f},
+       {"glVertex3f", (void **) &qglVertex3f},
+       {"glBegin", (void **) &qglBegin},
+       {"glEnd", (void **) &qglEnd},
+       {"glMatrixMode", (void **) &qglMatrixMode},
+       {"glOrtho", (void **) &qglOrtho},
+       {"glFrustum", (void **) &qglFrustum},
+       {"glViewport", (void **) &qglViewport},
+//     {"glPushMatrix", (void **) &qglPushMatrix},
+//     {"glPopMatrix", (void **) &qglPopMatrix},
+       {"glLoadIdentity", (void **) &qglLoadIdentity},
+//     {"glLoadMatrixd", (void **) &qglLoadMatrixd},
+//     {"glLoadMatrixf", (void **) &qglLoadMatrixf},
+//     {"glMultMatrixd", (void **) &qglMultMatrixd},
+//     {"glMultMatrixf", (void **) &qglMultMatrixf},
+//     {"glRotated", (void **) &qglRotated},
+       {"glRotatef", (void **) &qglRotatef},
+//     {"glScaled", (void **) &qglScaled},
+//     {"glScalef", (void **) &qglScalef},
+//     {"glTranslated", (void **) &qglTranslated},
+       {"glTranslatef", (void **) &qglTranslatef},
+       {"glReadPixels", (void **) &qglReadPixels},
+//     {"glStencilFunc", (void **) &qglStencilFunc},
+//     {"glStencilMask", (void **) &qglStencilMask},
+//     {"glStencilOp", (void **) &qglStencilOp},
+//     {"glClearStencil", (void **) &qglClearStencil},
+//     {"glTexEnvf", (void **) &qglTexEnvf},
+       {"glTexEnvi", (void **) &qglTexEnvi},
+//     {"glTexParameterf", (void **) &qglTexParameterf},
+       {"glTexParameteri", (void **) &qglTexParameteri},
+       {"glTexImage2D", (void **) &qglTexImage2D},
+       {"glBindTexture", (void **) &qglBindTexture},
+       {"glTexSubImage2D", (void **) &qglTexSubImage2D},
+       {NULL, NULL}
+};
+
+static gl_extensionfunctionlist_t drawrangeelementsfuncs[] =
+{
+       {"glDrawRangeElements", (void **) &qglDrawRangeElements},
+       {NULL, NULL}
+};
+
 static gl_extensionfunctionlist_t multitexturefuncs[] =
 {
-       //{"glMultiTexCoord2fARB", (void **) &qglMultiTexCoord2f},
+       {"glMultiTexCoord2fARB", (void **) &qglMultiTexCoord2f},
        {"glActiveTextureARB", (void **) &qglActiveTexture},
        {"glClientActiveTextureARB", (void **) &qglClientActiveTexture},
        {NULL, NULL}
@@ -120,7 +284,7 @@ static int gl_checkextension(char *name, gl_extensionfunctionlist_t *funcs, char
                return false;
        }
 
-       if (strstr(gl_extensions, name))
+       if (!strstr(name, "GL_") || strstr(gl_extensions, name))
        {
                for (func = funcs;func && func->name != NULL;func++)
                {
@@ -150,6 +314,11 @@ void VID_CheckExtensions(void)
        gl_supportslockarrays = false;
        gl_textureunits = 1;
 
+       if (!gl_checkextension("OpenGL 1.1.0 or above", opengl110funcs, NULL))
+               Sys_Error("OpenGL 1.1.0 functions not found\n");
+
+       gl_checkextension("glDrawRangeElements", drawrangeelementsfuncs, "-nodrawrangeelements");
+
        if (gl_checkextension("GL_ARB_multitexture", multitexturefuncs, "-nomtex"))
        {
                glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_textureunits);
@@ -205,7 +374,7 @@ void IN_Mouse(usercmd_t *cmd, float mx, float my)
        mouse_y *= sensitivity.value * cl.viewzoom;
 
        // Add mouse X/Y movement to cmd
-       if ( (in_strafe.state & 1) || (lookstrafe.integer && mouselook))
+       if ((in_strafe.state & 1) || (lookstrafe.integer && mouselook))
                cmd->sidemove += m_side.value * mouse_x;
        else
                cl.viewangles[YAW] -= m_yaw.value * mouse_x;