added a lot more CHECKGLERROR macro calls, to identify precisely where any error...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 26 Apr 2006 10:20:45 +0000 (10:20 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 26 Apr 2006 10:20:45 +0000 (10:20 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6331 d7cf8633-e32d-0410-b094-e92efae38249

15 files changed:
cl_screen.c
gl_backend.c
gl_draw.c
gl_rmain.c
gl_rsurf.c
gl_textures.c
glquake.h
prvm_cmds.c
r_shadow.c
todo
vid_agl.c
vid_glx.c
vid_sdl.c
vid_shared.c
vid_wgl.c

index 3935a46..eccb767 100644 (file)
@@ -407,7 +407,8 @@ void R_TimeReport(char *desc)
        if (r_speeds.integer < 2 || !r_timereport_active)
                return;
 
-       qglFinish();
+       CHECKGLERROR
+       qglFinish();CHECKGLERROR
        r_timereport_temp = r_timereport_current;
        r_timereport_current = Sys_DoubleTime();
        t = (int) ((r_timereport_current - r_timereport_temp) * 1000000.0 + 0.5);
@@ -757,14 +758,14 @@ qboolean SCR_CaptureVideo_VideoFrame(int newframenum)
        unsigned char *b, *out;
        char filename[32];
        int outoffset = (width/2)*(height/2);
+       CHECKGLERROR
        //return SCR_ScreenShot(filename, cls.capturevideo_buffer, cls.capturevideo_buffer + vid.width * vid.height * 3, cls.capturevideo_buffer + vid.width * vid.height * 6, 0, 0, vid.width, vid.height, false, false, false, jpeg, true);
        // speed is critical here, so do saving as directly as possible
        switch (cls.capturevideo_format)
        {
        case CAPTUREVIDEOFORMAT_RAWYV12:
                // FIXME: width/height must be multiple of 2, enforce this?
-               qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, cls.capturevideo_buffer);
-               CHECKGLERROR
+               qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, cls.capturevideo_buffer);CHECKGLERROR
                // process one line at a time, and CbCr every other line at 2 pixel intervals
                for (y = 0;y < height;y++)
                {
@@ -805,15 +806,13 @@ qboolean SCR_CaptureVideo_VideoFrame(int newframenum)
                                return false;
                return true;
        case CAPTUREVIDEOFORMAT_RAWRGB:
-               qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, cls.capturevideo_buffer);
-               CHECKGLERROR
+               qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, cls.capturevideo_buffer);CHECKGLERROR
                for (;cls.capturevideo_frame < newframenum;cls.capturevideo_frame++)
                        if (!FS_Write (cls.capturevideo_videofile, cls.capturevideo_buffer, width*height*3))
                                return false;
                return true;
        case CAPTUREVIDEOFORMAT_JPEG:
-               qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, cls.capturevideo_buffer);
-               CHECKGLERROR
+               qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, cls.capturevideo_buffer);CHECKGLERROR
                for (;cls.capturevideo_frame < newframenum;cls.capturevideo_frame++)
                {
                        sprintf(filename, "video/dp%06d.jpg", cls.capturevideo_frame);
@@ -830,8 +829,7 @@ qboolean SCR_CaptureVideo_VideoFrame(int newframenum)
                cls.capturevideo_buffer[14] = (height >> 0) & 0xFF;
                cls.capturevideo_buffer[15] = (height >> 8) & 0xFF;
                cls.capturevideo_buffer[16] = 24;       // pixel size
-               qglReadPixels (x, y, width, height, GL_BGR, GL_UNSIGNED_BYTE, cls.capturevideo_buffer + 18);
-               CHECKGLERROR
+               qglReadPixels (x, y, width, height, GL_BGR, GL_UNSIGNED_BYTE, cls.capturevideo_buffer + 18);CHECKGLERROR
                for (;cls.capturevideo_frame < newframenum;cls.capturevideo_frame++)
                {
                        sprintf(filename, "video/dp%06d.tga", cls.capturevideo_frame);
@@ -1084,8 +1082,8 @@ qboolean SCR_ScreenShot(char *filename, unsigned char *buffer1, unsigned char *b
        if (!r_render.integer)
                return false;
 
-       qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer1);
        CHECKGLERROR
+       qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer1);CHECKGLERROR
 
        if (scr_screenshot_gammaboost.value != 1 && gammacorrect)
        {
@@ -1115,11 +1113,15 @@ void R_ClearScreen(void)
        if (r_render.integer)
        {
                // clear to black
+               CHECKGLERROR
                if (fogenabled)
-                       qglClearColor(fogcolor[0],fogcolor[1],fogcolor[2],0);
+               {
+                       qglClearColor(fogcolor[0],fogcolor[1],fogcolor[2],0);CHECKGLERROR
+               }
                else
-                       qglClearColor(0,0,0,0);
-               CHECKGLERROR
+               {
+                       qglClearColor(0,0,0,0);CHECKGLERROR
+               }
                qglClearDepth(1);CHECKGLERROR
                if (gl_stencil)
                {
@@ -1276,14 +1278,15 @@ void SCR_UpdateLoadingScreen (void)
        // don't do anything if not initialized yet
        if (vid_hidden)
                return;
-       qglViewport(0, 0, vid.width, vid.height);
-       //qglDisable(GL_SCISSOR_TEST);
-       //qglDepthMask(1);
-       qglColorMask(1,1,1,1);
-       //qglClearColor(0,0,0,0);
-       //qglClear(GL_COLOR_BUFFER_BIT);
-       //qglCullFace(GL_FRONT);
-       //qglDisable(GL_CULL_FACE);
+       CHECKGLERROR
+       qglViewport(0, 0, vid.width, vid.height);CHECKGLERROR
+       //qglDisable(GL_SCISSOR_TEST);CHECKGLERROR
+       //qglDepthMask(1);CHECKGLERROR
+       qglColorMask(1,1,1,1);CHECKGLERROR
+       //qglClearColor(0,0,0,0);CHECKGLERROR
+       //qglClear(GL_COLOR_BUFFER_BIT);CHECKGLERROR
+       //qglCullFace(GL_FRONT);CHECKGLERROR
+       //qglDisable(GL_CULL_FACE);CHECKGLERROR
        //R_ClearScreen();
        R_Textures_Frame();
        GL_SetupView_Mode_Ortho(0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100);
@@ -1390,13 +1393,12 @@ void CL_UpdateScreen(void)
                R_TimeReport("start");
 
        CHECKGLERROR
-       qglViewport(0, 0, vid.width, vid.height);
-       qglDisable(GL_SCISSOR_TEST);
-       qglDepthMask(1);
-       qglColorMask(1,1,1,1);
-       qglClearColor(0,0,0,0);
-       qglClear(GL_COLOR_BUFFER_BIT);
-       CHECKGLERROR
+       qglViewport(0, 0, vid.width, vid.height);CHECKGLERROR
+       qglDisable(GL_SCISSOR_TEST);CHECKGLERROR
+       qglDepthMask(1);CHECKGLERROR
+       qglColorMask(1,1,1,1);CHECKGLERROR
+       qglClearColor(0,0,0,0);CHECKGLERROR
+       qglClear(GL_COLOR_BUFFER_BIT);CHECKGLERROR
 
        if (r_timereport_active)
                R_TimeReport("clear");
index ca2b710..414911f 100644 (file)
@@ -267,11 +267,12 @@ void GL_SetupView_Mode_Perspective (double frustumx, double frustumy, double zNe
                return;
 
        // set up viewpoint
+       CHECKGLERROR
        qglMatrixMode(GL_PROJECTION);CHECKGLERROR
        qglLoadIdentity();CHECKGLERROR
        // set view pyramid
        qglFrustum(-frustumx * zNear, frustumx * zNear, -frustumy * zNear, frustumy * zNear, zNear, zFar);CHECKGLERROR
-       qglGetDoublev(GL_PROJECTION_MATRIX, m);
+       qglGetDoublev(GL_PROJECTION_MATRIX, m);CHECKGLERROR
        backend_projectmatrix.m[0][0] = m[0];
        backend_projectmatrix.m[1][0] = m[1];
        backend_projectmatrix.m[2][0] = m[2];
@@ -290,6 +291,7 @@ void GL_SetupView_Mode_Perspective (double frustumx, double frustumy, double zNe
        backend_projectmatrix.m[3][3] = m[15];
        qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
        GL_SetupView_Orientation_Identity();
+       CHECKGLERROR
 }
 
 void GL_SetupView_Mode_PerspectiveInfiniteFarClip (double frustumx, double frustumy, double zNear)
@@ -300,6 +302,7 @@ void GL_SetupView_Mode_PerspectiveInfiniteFarClip (double frustumx, double frust
                return;
 
        // set up viewpoint
+       CHECKGLERROR
        qglMatrixMode(GL_PROJECTION);CHECKGLERROR
        qglLoadIdentity();CHECKGLERROR
        // set view pyramid
@@ -320,9 +323,10 @@ void GL_SetupView_Mode_PerspectiveInfiniteFarClip (double frustumx, double frust
        m[13] = 0;
        m[14] = -2 * zNear * nudge;
        m[15] = 0;
-       qglLoadMatrixd(m);
+       qglLoadMatrixd(m);CHECKGLERROR
        qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
        GL_SetupView_Orientation_Identity();
+       CHECKGLERROR
        backend_projectmatrix.m[0][0] = m[0];
        backend_projectmatrix.m[1][0] = m[1];
        backend_projectmatrix.m[2][0] = m[2];
@@ -349,10 +353,11 @@ void GL_SetupView_Mode_Ortho (double x1, double y1, double x2, double y2, double
                return;
 
        // set up viewpoint
+       CHECKGLERROR
        qglMatrixMode(GL_PROJECTION);CHECKGLERROR
        qglLoadIdentity();CHECKGLERROR
-       qglOrtho(x1, x2, y2, y1, zNear, zFar);
-       qglGetDoublev(GL_PROJECTION_MATRIX, m);
+       qglOrtho(x1, x2, y2, y1, zNear, zFar);CHECKGLERROR
+       qglGetDoublev(GL_PROJECTION_MATRIX, m);CHECKGLERROR
        backend_projectmatrix.m[0][0] = m[0];
        backend_projectmatrix.m[1][0] = m[1];
        backend_projectmatrix.m[2][0] = m[2];
@@ -371,6 +376,7 @@ void GL_SetupView_Mode_Ortho (double x1, double y1, double x2, double y2, double
        backend_projectmatrix.m[3][3] = m[15];
        qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
        GL_SetupView_Orientation_Identity();
+       CHECKGLERROR
 }
 
 typedef struct gltextureunit_s
@@ -469,9 +475,9 @@ void GL_SetupTextureState(void)
                {
                        qglDisable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
                }
-               qglMatrixMode(GL_TEXTURE);
-               qglLoadIdentity();
-               qglMatrixMode(GL_MODELVIEW);
+               qglMatrixMode(GL_TEXTURE);CHECKGLERROR
+               qglLoadIdentity();CHECKGLERROR
+               qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
                if (gl_combine.integer)
                {
                        qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);CHECKGLERROR
@@ -496,6 +502,7 @@ void GL_SetupTextureState(void)
                {
                        qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);CHECKGLERROR
                }
+               CHECKGLERROR
        }
        CHECKGLERROR
 }
@@ -548,6 +555,7 @@ void GL_ActiveTexture(unsigned int num)
                gl_state.unit = num;
                if (qglActiveTexture)
                {
+                       CHECKGLERROR
                        qglActiveTexture(GL_TEXTURE0_ARB + gl_state.unit);
                        CHECKGLERROR
                }
@@ -561,6 +569,7 @@ void GL_ClientActiveTexture(unsigned int num)
                gl_state.clientunit = num;
                if (qglActiveTexture)
                {
+                       CHECKGLERROR
                        qglClientActiveTexture(GL_TEXTURE0_ARB + gl_state.clientunit);
                        CHECKGLERROR
                }
@@ -571,6 +580,7 @@ void GL_BlendFunc(int blendfunc1, int blendfunc2)
 {
        if (gl_state.blendfunc1 != blendfunc1 || gl_state.blendfunc2 != blendfunc2)
        {
+               CHECKGLERROR
                qglBlendFunc(gl_state.blendfunc1 = blendfunc1, gl_state.blendfunc2 = blendfunc2);CHECKGLERROR
                if (gl_state.blendfunc2 == GL_ZERO)
                {
@@ -606,6 +616,7 @@ void GL_DepthMask(int state)
 {
        if (gl_state.depthmask != state)
        {
+               CHECKGLERROR
                qglDepthMask(gl_state.depthmask = state);CHECKGLERROR
        }
 }
@@ -615,6 +626,7 @@ void GL_DepthTest(int state)
        if (gl_state.depthtest != state)
        {
                gl_state.depthtest = state;
+               CHECKGLERROR
                if (gl_state.depthtest)
                {
                        qglEnable(GL_DEPTH_TEST);CHECKGLERROR
@@ -631,6 +643,7 @@ void GL_AlphaTest(int state)
        if (gl_state.alphatest != state)
        {
                gl_state.alphatest = state;
+               CHECKGLERROR
                if (gl_state.alphatest)
                {
                        qglEnable(GL_ALPHA_TEST);CHECKGLERROR
@@ -648,6 +661,7 @@ void GL_ColorMask(int r, int g, int b, int a)
        if (gl_state.colormask != state)
        {
                gl_state.colormask = state;
+               CHECKGLERROR
                qglColorMask((GLboolean)r, (GLboolean)g, (GLboolean)b, (GLboolean)a);CHECKGLERROR
        }
 }
@@ -710,6 +724,7 @@ void GL_ScissorTest(int state)
 
 void GL_Clear(int mask)
 {
+       CHECKGLERROR
        qglClear(mask);CHECKGLERROR
 }
 
@@ -730,6 +745,11 @@ void R_Mesh_Start(void)
 {
        BACKENDACTIVECHECK
        CHECKGLERROR
+       if (gl_printcheckerror.integer && !gl_paranoid.integer)
+       {
+               Con_Printf("WARNING: gl_printcheckerror is on but gl_paranoid is off, turning it on...\n");
+               Cvar_SetValueQuick(&gl_paranoid, 1);
+       }
        GL_Backend_ResetState();
 }
 
@@ -740,8 +760,7 @@ unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **ver
        char compilelog[MAX_INPUTLINE];
        CHECKGLERROR
 
-       programobject = qglCreateProgramObjectARB();
-       CHECKGLERROR
+       programobject = qglCreateProgramObjectARB();CHECKGLERROR
        if (!programobject)
                return 0;
 
@@ -767,66 +786,56 @@ unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **ver
 
        if (vertexstrings_count)
        {
-               CHECKGLERROR
-               vertexshaderobject = qglCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
+               vertexshaderobject = qglCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);CHECKGLERROR
                if (!vertexshaderobject)
                {
                        qglDeleteObjectARB(programobject);
                        CHECKGLERROR
                        return 0;
                }
-               qglShaderSourceARB(vertexshaderobject, vertexstrings_count, vertexstrings_list, NULL);
-               qglCompileShaderARB(vertexshaderobject);
-               CHECKGLERROR
-               qglGetObjectParameterivARB(vertexshaderobject, GL_OBJECT_COMPILE_STATUS_ARB, &vertexshadercompiled);
-               qglGetInfoLogARB(vertexshaderobject, sizeof(compilelog), NULL, compilelog);
+               qglShaderSourceARB(vertexshaderobject, vertexstrings_count, vertexstrings_list, NULL);CHECKGLERROR
+               qglCompileShaderARB(vertexshaderobject);CHECKGLERROR
+               qglGetObjectParameterivARB(vertexshaderobject, GL_OBJECT_COMPILE_STATUS_ARB, &vertexshadercompiled);CHECKGLERROR
+               qglGetInfoLogARB(vertexshaderobject, sizeof(compilelog), NULL, compilelog);CHECKGLERROR
                if (compilelog[0])
                        Con_DPrintf("vertex shader compile log:\n%s\n", compilelog);
                if (!vertexshadercompiled)
                {
-                       qglDeleteObjectARB(programobject);
-                       qglDeleteObjectARB(vertexshaderobject);
-                       CHECKGLERROR
+                       qglDeleteObjectARB(programobject);CHECKGLERROR
+                       qglDeleteObjectARB(vertexshaderobject);CHECKGLERROR
                        return 0;
                }
-               qglAttachObjectARB(programobject, vertexshaderobject);
-               qglDeleteObjectARB(vertexshaderobject);
-               CHECKGLERROR
+               qglAttachObjectARB(programobject, vertexshaderobject);CHECKGLERROR
+               qglDeleteObjectARB(vertexshaderobject);CHECKGLERROR
        }
 
        if (fragmentstrings_count)
        {
-               CHECKGLERROR
-               fragmentshaderobject = qglCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
+               fragmentshaderobject = qglCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);CHECKGLERROR
                if (!fragmentshaderobject)
                {
-                       qglDeleteObjectARB(programobject);
-                       CHECKGLERROR
+                       qglDeleteObjectARB(programobject);CHECKGLERROR
                        return 0;
                }
-               qglShaderSourceARB(fragmentshaderobject, fragmentstrings_count, fragmentstrings_list, NULL);
-               qglCompileShaderARB(fragmentshaderobject);
-               CHECKGLERROR
-               qglGetObjectParameterivARB(fragmentshaderobject, GL_OBJECT_COMPILE_STATUS_ARB, &fragmentshadercompiled);
-               qglGetInfoLogARB(fragmentshaderobject, sizeof(compilelog), NULL, compilelog);
+               qglShaderSourceARB(fragmentshaderobject, fragmentstrings_count, fragmentstrings_list, NULL);CHECKGLERROR
+               qglCompileShaderARB(fragmentshaderobject);CHECKGLERROR
+               qglGetObjectParameterivARB(fragmentshaderobject, GL_OBJECT_COMPILE_STATUS_ARB, &fragmentshadercompiled);CHECKGLERROR
+               qglGetInfoLogARB(fragmentshaderobject, sizeof(compilelog), NULL, compilelog);CHECKGLERROR
                if (compilelog[0])
                        Con_DPrintf("fragment shader compile log:\n%s\n", compilelog);
                if (!fragmentshadercompiled)
                {
-                       qglDeleteObjectARB(programobject);
-                       qglDeleteObjectARB(fragmentshaderobject);
-                       CHECKGLERROR
+                       qglDeleteObjectARB(programobject);CHECKGLERROR
+                       qglDeleteObjectARB(fragmentshaderobject);CHECKGLERROR
                        return 0;
                }
-               qglAttachObjectARB(programobject, fragmentshaderobject);
-               qglDeleteObjectARB(fragmentshaderobject);
-               CHECKGLERROR
+               qglAttachObjectARB(programobject, fragmentshaderobject);CHECKGLERROR
+               qglDeleteObjectARB(fragmentshaderobject);CHECKGLERROR
        }
 
-       qglLinkProgramARB(programobject);
-       CHECKGLERROR
-       qglGetObjectParameterivARB(programobject, GL_OBJECT_LINK_STATUS_ARB, &programlinked);
-       qglGetInfoLogARB(programobject, sizeof(compilelog), NULL, compilelog);
+       qglLinkProgramARB(programobject);CHECKGLERROR
+       qglGetObjectParameterivARB(programobject, GL_OBJECT_LINK_STATUS_ARB, &programlinked);CHECKGLERROR
+       qglGetInfoLogARB(programobject, sizeof(compilelog), NULL, compilelog);CHECKGLERROR
        if (compilelog[0])
        {
                Con_DPrintf("program link log:\n%s\n", compilelog);
@@ -839,10 +848,9 @@ unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **ver
                if (strstr(compilelog, "fragment shader will run in software"))
                        programlinked = false;
        }
-       CHECKGLERROR
        if (!programlinked)
        {
-               qglDeleteObjectARB(programobject);
+               qglDeleteObjectARB(programobject);CHECKGLERROR
                return 0;
        }
        CHECKGLERROR
@@ -880,7 +888,7 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int numtriangles, const int *
                Con_Printf("R_Mesh_Draw(%d, %d, %d, %08p);\n", firstvertex, numvertices, numtriangles, elements);
                return;
        }
-       //CHECKGLERROR
+       CHECKGLERROR
        renderstats.meshes++;
        renderstats.meshes_elements += numelements;
        if (gl_paranoid.integer)
@@ -889,12 +897,14 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int numtriangles, const int *
                const int *p;
                if (!qglIsEnabled(GL_VERTEX_ARRAY))
                        Con_Print("R_Mesh_Draw: vertex array not enabled\n");
+               CHECKGLERROR
                for (j = 0, size = numvertices * 3, p = (int *)((float *)gl_state.pointer_vertex + firstvertex * 3);j < size;j++, p++)
                        paranoidblah += *p;
                if (gl_state.pointer_color)
                {
                        if (!qglIsEnabled(GL_COLOR_ARRAY))
                                Con_Print("R_Mesh_Draw: color array set but not enabled\n");
+                       CHECKGLERROR
                        for (j = 0, size = numvertices * 4, p = (int *)((float *)gl_state.pointer_color + firstvertex * 4);j < size;j++, p++)
                                paranoidblah += *p;
                }
@@ -905,6 +915,7 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int numtriangles, const int *
                                GL_ClientActiveTexture(i);
                                if (!qglIsEnabled(GL_TEXTURE_COORD_ARRAY))
                                        Con_Print("R_Mesh_Draw: texcoord array set but not enabled\n");
+                               CHECKGLERROR
                                for (j = 0, size = numvertices * gl_state.units[i].arraycomponents, p = (int *)((float *)gl_state.units[i].pointer_texcoord + firstvertex * gl_state.units[i].arraycomponents);j < size;j++, p++)
                                        paranoidblah += *p;
                        }
@@ -1080,7 +1091,8 @@ void R_Mesh_Matrix(const matrix4x4_t *matrix)
                backend_modelmatrix = *matrix;
                Matrix4x4_Concat(&backend_modelviewmatrix, &backend_viewmatrix, matrix);
                Matrix4x4_Transpose(&backend_glmodelviewmatrix, &backend_modelviewmatrix);
-               qglLoadMatrixf(&backend_glmodelviewmatrix.m[0][0]);
+               CHECKGLERROR
+               qglLoadMatrixf(&backend_glmodelviewmatrix.m[0][0]);CHECKGLERROR
        }
 }
 
@@ -1102,20 +1114,16 @@ void R_Mesh_ColorPointer(const float *color4f)
                CHECKGLERROR
                if (!gl_state.pointer_color)
                {
-                       qglEnableClientState(GL_COLOR_ARRAY);
-                       CHECKGLERROR
+                       qglEnableClientState(GL_COLOR_ARRAY);CHECKGLERROR
                }
                else if (!color4f)
                {
-                       qglDisableClientState(GL_COLOR_ARRAY);
-                       CHECKGLERROR
+                       qglDisableClientState(GL_COLOR_ARRAY);CHECKGLERROR
                        // when color array is on the glColor gets trashed, set it again
-                       qglColor4f(gl_state.color4f[0], gl_state.color4f[1], gl_state.color4f[2], gl_state.color4f[3]);
-                       CHECKGLERROR
+                       qglColor4f(gl_state.color4f[0], gl_state.color4f[1], gl_state.color4f[2], gl_state.color4f[3]);CHECKGLERROR
                }
                gl_state.pointer_color = color4f;
-               qglColorPointer(4, GL_FLOAT, sizeof(float[4]), gl_state.pointer_color);
-               CHECKGLERROR
+               qglColorPointer(4, GL_FLOAT, sizeof(float[4]), gl_state.pointer_color);CHECKGLERROR
        }
 }
 
@@ -1123,6 +1131,7 @@ void R_Mesh_TexCoordPointer(unsigned int unitnum, unsigned int numcomponents, co
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
        // update array settings
+       CHECKGLERROR
        if (texcoord)
        {
                // texcoord array
@@ -1131,8 +1140,7 @@ void R_Mesh_TexCoordPointer(unsigned int unitnum, unsigned int numcomponents, co
                        unit->pointer_texcoord = texcoord;
                        unit->arraycomponents = numcomponents;
                        GL_ClientActiveTexture(unitnum);
-                       qglTexCoordPointer(unit->arraycomponents, GL_FLOAT, sizeof(float) * unit->arraycomponents, unit->pointer_texcoord);
-                       CHECKGLERROR
+                       qglTexCoordPointer(unit->arraycomponents, GL_FLOAT, sizeof(float) * unit->arraycomponents, unit->pointer_texcoord);CHECKGLERROR
                }
                // texture array unit is enabled, enable the array
                if (!unit->arrayenabled)
@@ -1168,17 +1176,20 @@ void R_Mesh_TexBindAll(unsigned int unitnum, int tex1d, int tex2d, int tex3d, in
                        if (tex1d)
                        {
                                if (unit->t1d == 0)
-                                       qglEnable(GL_TEXTURE_1D);
+                               {
+                                       qglEnable(GL_TEXTURE_1D);CHECKGLERROR
+                               }
                        }
                        else
                        {
                                if (unit->t1d)
-                                       qglDisable(GL_TEXTURE_1D);
+                               {
+                                       qglDisable(GL_TEXTURE_1D);CHECKGLERROR
+                               }
                        }
                }
                unit->t1d = tex1d;
-               qglBindTexture(GL_TEXTURE_1D, unit->t1d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_1D, unit->t1d);CHECKGLERROR
        }
        // update 2d texture binding
        if (unit->t2d != tex2d)
@@ -1189,17 +1200,20 @@ void R_Mesh_TexBindAll(unsigned int unitnum, int tex1d, int tex2d, int tex3d, in
                        if (tex2d)
                        {
                                if (unit->t2d == 0)
-                                       qglEnable(GL_TEXTURE_2D);
+                               {
+                                       qglEnable(GL_TEXTURE_2D);CHECKGLERROR
+                               }
                        }
                        else
                        {
                                if (unit->t2d)
-                                       qglDisable(GL_TEXTURE_2D);
+                               {
+                                       qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+                               }
                        }
                }
                unit->t2d = tex2d;
-               qglBindTexture(GL_TEXTURE_2D, unit->t2d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_2D, unit->t2d);CHECKGLERROR
        }
        // update 3d texture binding
        if (unit->t3d != tex3d)
@@ -1210,17 +1224,20 @@ void R_Mesh_TexBindAll(unsigned int unitnum, int tex1d, int tex2d, int tex3d, in
                        if (tex3d)
                        {
                                if (unit->t3d == 0)
-                                       qglEnable(GL_TEXTURE_3D);
+                               {
+                                       qglEnable(GL_TEXTURE_3D);CHECKGLERROR
+                               }
                        }
                        else
                        {
                                if (unit->t3d)
-                                       qglDisable(GL_TEXTURE_3D);
+                               {
+                                       qglDisable(GL_TEXTURE_3D);CHECKGLERROR
+                               }
                        }
                }
                unit->t3d = tex3d;
-               qglBindTexture(GL_TEXTURE_3D, unit->t3d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_3D, unit->t3d);CHECKGLERROR
        }
        // update cubemap texture binding
        if (unit->tcubemap != texcubemap)
@@ -1231,17 +1248,20 @@ void R_Mesh_TexBindAll(unsigned int unitnum, int tex1d, int tex2d, int tex3d, in
                        if (texcubemap)
                        {
                                if (unit->tcubemap == 0)
-                                       qglEnable(GL_TEXTURE_CUBE_MAP_ARB);
+                               {
+                                       qglEnable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
+                               }
                        }
                        else
                        {
                                if (unit->tcubemap)
-                                       qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+                               {
+                                       qglDisable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
+                               }
                        }
                }
                unit->tcubemap = texcubemap;
-               qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);CHECKGLERROR
        }
 }
 
@@ -1259,17 +1279,20 @@ void R_Mesh_TexBind1D(unsigned int unitnum, int texnum)
                        if (texnum)
                        {
                                if (unit->t1d == 0)
-                                       qglEnable(GL_TEXTURE_1D);
+                               {
+                                       qglEnable(GL_TEXTURE_1D);CHECKGLERROR
+                               }
                        }
                        else
                        {
                                if (unit->t1d)
-                                       qglDisable(GL_TEXTURE_1D);
+                               {
+                                       qglDisable(GL_TEXTURE_1D);CHECKGLERROR
+                               }
                        }
                }
                unit->t1d = texnum;
-               qglBindTexture(GL_TEXTURE_1D, unit->t1d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_1D, unit->t1d);CHECKGLERROR
        }
        // update 2d texture binding
        if (unit->t2d)
@@ -1278,11 +1301,12 @@ void R_Mesh_TexBind1D(unsigned int unitnum, int texnum)
                if (unitnum < backendunits)
                {
                        if (unit->t2d)
-                               qglDisable(GL_TEXTURE_2D);
+                       {
+                               qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+                       }
                }
                unit->t2d = 0;
-               qglBindTexture(GL_TEXTURE_2D, unit->t2d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_2D, unit->t2d);CHECKGLERROR
        }
        // update 3d texture binding
        if (unit->t3d)
@@ -1291,11 +1315,12 @@ void R_Mesh_TexBind1D(unsigned int unitnum, int texnum)
                if (unitnum < backendunits)
                {
                        if (unit->t3d)
-                               qglDisable(GL_TEXTURE_3D);
+                       {
+                               qglDisable(GL_TEXTURE_3D);CHECKGLERROR
+                       }
                }
                unit->t3d = 0;
-               qglBindTexture(GL_TEXTURE_3D, unit->t3d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_3D, unit->t3d);CHECKGLERROR
        }
        // update cubemap texture binding
        if (unit->tcubemap)
@@ -1304,11 +1329,12 @@ void R_Mesh_TexBind1D(unsigned int unitnum, int texnum)
                if (unitnum < backendunits)
                {
                        if (unit->tcubemap)
-                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+                       {
+                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
+                       }
                }
                unit->tcubemap = 0;
-               qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);CHECKGLERROR
        }
 }
 
@@ -1324,11 +1350,12 @@ void R_Mesh_TexBind(unsigned int unitnum, int texnum)
                if (unitnum < backendunits)
                {
                        if (unit->t1d)
-                               qglDisable(GL_TEXTURE_1D);
+                       {
+                               qglDisable(GL_TEXTURE_1D);CHECKGLERROR
+                       }
                }
                unit->t1d = 0;
-               qglBindTexture(GL_TEXTURE_1D, unit->t1d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_1D, unit->t1d);CHECKGLERROR
        }
        // update 2d texture binding
        if (unit->t2d != texnum)
@@ -1339,17 +1366,20 @@ void R_Mesh_TexBind(unsigned int unitnum, int texnum)
                        if (texnum)
                        {
                                if (unit->t2d == 0)
-                                       qglEnable(GL_TEXTURE_2D);
+                               {
+                                       qglEnable(GL_TEXTURE_2D);CHECKGLERROR
+                               }
                        }
                        else
                        {
                                if (unit->t2d)
-                                       qglDisable(GL_TEXTURE_2D);
+                               {
+                                       qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+                               }
                        }
                }
                unit->t2d = texnum;
-               qglBindTexture(GL_TEXTURE_2D, unit->t2d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_2D, unit->t2d);CHECKGLERROR
        }
        // update 3d texture binding
        if (unit->t3d)
@@ -1358,11 +1388,12 @@ void R_Mesh_TexBind(unsigned int unitnum, int texnum)
                if (unitnum < backendunits)
                {
                        if (unit->t3d)
-                               qglDisable(GL_TEXTURE_3D);
+                       {
+                               qglDisable(GL_TEXTURE_3D);CHECKGLERROR
+                       }
                }
                unit->t3d = 0;
-               qglBindTexture(GL_TEXTURE_3D, unit->t3d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_3D, unit->t3d);CHECKGLERROR
        }
        // update cubemap texture binding
        if (unit->tcubemap != 0)
@@ -1371,11 +1402,12 @@ void R_Mesh_TexBind(unsigned int unitnum, int texnum)
                if (unitnum < backendunits)
                {
                        if (unit->tcubemap)
-                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+                       {
+                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
+                       }
                }
                unit->tcubemap = 0;
-               qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);CHECKGLERROR
        }
 }
 
@@ -1391,11 +1423,12 @@ void R_Mesh_TexBind3D(unsigned int unitnum, int texnum)
                if (unitnum < backendunits)
                {
                        if (unit->t1d)
-                               qglDisable(GL_TEXTURE_1D);
+                       {
+                               qglDisable(GL_TEXTURE_1D);CHECKGLERROR
+                       }
                }
                unit->t1d = 0;
-               qglBindTexture(GL_TEXTURE_1D, unit->t1d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_1D, unit->t1d);CHECKGLERROR
        }
        // update 2d texture binding
        if (unit->t2d)
@@ -1404,11 +1437,12 @@ void R_Mesh_TexBind3D(unsigned int unitnum, int texnum)
                if (unitnum < backendunits)
                {
                        if (unit->t2d)
-                               qglDisable(GL_TEXTURE_2D);
+                       {
+                               qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+                       }
                }
                unit->t2d = 0;
-               qglBindTexture(GL_TEXTURE_2D, unit->t2d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_2D, unit->t2d);CHECKGLERROR
        }
        // update 3d texture binding
        if (unit->t3d != texnum)
@@ -1419,17 +1453,20 @@ void R_Mesh_TexBind3D(unsigned int unitnum, int texnum)
                        if (texnum)
                        {
                                if (unit->t3d == 0)
-                                       qglEnable(GL_TEXTURE_3D);
+                               {
+                                       qglEnable(GL_TEXTURE_3D);CHECKGLERROR
+                               }
                        }
                        else
                        {
                                if (unit->t3d)
-                                       qglDisable(GL_TEXTURE_3D);
+                               {
+                                       qglDisable(GL_TEXTURE_3D);CHECKGLERROR
+                               }
                        }
                }
                unit->t3d = texnum;
-               qglBindTexture(GL_TEXTURE_3D, unit->t3d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_3D, unit->t3d);CHECKGLERROR
        }
        // update cubemap texture binding
        if (unit->tcubemap != 0)
@@ -1438,11 +1475,12 @@ void R_Mesh_TexBind3D(unsigned int unitnum, int texnum)
                if (unitnum < backendunits)
                {
                        if (unit->tcubemap)
-                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+                       {
+                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
+                       }
                }
                unit->tcubemap = 0;
-               qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);CHECKGLERROR
        }
 }
 
@@ -1458,11 +1496,12 @@ void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum)
                if (unitnum < backendunits)
                {
                        if (unit->t1d)
-                               qglDisable(GL_TEXTURE_1D);
+                       {
+                               qglDisable(GL_TEXTURE_1D);CHECKGLERROR
+                       }
                }
                unit->t1d = 0;
-               qglBindTexture(GL_TEXTURE_1D, unit->t1d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_1D, unit->t1d);CHECKGLERROR
        }
        // update 2d texture binding
        if (unit->t2d)
@@ -1471,11 +1510,12 @@ void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum)
                if (unitnum < backendunits)
                {
                        if (unit->t2d)
-                               qglDisable(GL_TEXTURE_2D);
+                       {
+                               qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+                       }
                }
                unit->t2d = 0;
-               qglBindTexture(GL_TEXTURE_2D, unit->t2d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_2D, unit->t2d);CHECKGLERROR
        }
        // update 3d texture binding
        if (unit->t3d)
@@ -1484,11 +1524,12 @@ void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum)
                if (unitnum < backendunits)
                {
                        if (unit->t3d)
-                               qglDisable(GL_TEXTURE_3D);
+                       {
+                               qglDisable(GL_TEXTURE_3D);CHECKGLERROR
+                       }
                }
                unit->t3d = 0;
-               qglBindTexture(GL_TEXTURE_3D, unit->t3d);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_3D, unit->t3d);CHECKGLERROR
        }
        // update cubemap texture binding
        if (unit->tcubemap != texnum)
@@ -1499,17 +1540,20 @@ void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum)
                        if (texnum)
                        {
                                if (unit->tcubemap == 0)
-                                       qglEnable(GL_TEXTURE_CUBE_MAP_ARB);
+                               {
+                                       qglEnable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
+                               }
                        }
                        else
                        {
                                if (unit->tcubemap)
-                                       qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+                               {
+                                       qglDisable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
+                               }
                        }
                }
                unit->tcubemap = texnum;
-               qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);
-               CHECKGLERROR
+               qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);CHECKGLERROR
        }
 }
 
@@ -1524,11 +1568,12 @@ void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix)
                        matrix4x4_t tempmatrix;
                        unit->texmatrixenabled = true;
                        unit->matrix = *matrix;
+                       CHECKGLERROR
                        Matrix4x4_Transpose(&tempmatrix, &unit->matrix);
-                       qglMatrixMode(GL_TEXTURE);
+                       qglMatrixMode(GL_TEXTURE);CHECKGLERROR
                        GL_ActiveTexture(unitnum);
-                       qglLoadMatrixf(&tempmatrix.m[0][0]);
-                       qglMatrixMode(GL_MODELVIEW);
+                       qglLoadMatrixf(&tempmatrix.m[0][0]);CHECKGLERROR
+                       qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
                }
        }
        else
@@ -1537,10 +1582,11 @@ void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix)
                if (unit->texmatrixenabled)
                {
                        unit->texmatrixenabled = false;
-                       qglMatrixMode(GL_TEXTURE);
+                       CHECKGLERROR
+                       qglMatrixMode(GL_TEXTURE);CHECKGLERROR
                        GL_ActiveTexture(unitnum);
-                       qglLoadIdentity();
-                       qglMatrixMode(GL_MODELVIEW);
+                       qglLoadIdentity();CHECKGLERROR
+                       qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
                }
        }
 }
@@ -1548,6 +1594,7 @@ void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix)
 void R_Mesh_TexCombine(unsigned int unitnum, int combinergb, int combinealpha, int rgbscale, int alphascale)
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
+       CHECKGLERROR
        if (gl_combine.integer)
        {
                // GL_ARB_texture_env_combine
@@ -1602,10 +1649,12 @@ void R_Mesh_TextureState(const rmeshstate_t *m)
 
        BACKENDACTIVECHECK
 
+       CHECKGLERROR
        if (gl_backend_rebindtextures)
        {
                gl_backend_rebindtextures = false;
                GL_SetupTextureState();
+               CHECKGLERROR
        }
 
        for (i = 0;i < backendimageunits;i++)
@@ -1622,6 +1671,7 @@ void R_Mesh_TextureState(const rmeshstate_t *m)
                R_Mesh_TexMatrix(i, &m->texmatrix[i]);
                R_Mesh_TexCombine(i, m->texcombinergb[i], m->texcombinealpha[i], m->texrgbscale[i], m->texalphascale[i]);
        }
+       CHECKGLERROR
 }
 
 void R_Mesh_ResetTextureState(void)
@@ -1630,10 +1680,12 @@ void R_Mesh_ResetTextureState(void)
 
        BACKENDACTIVECHECK
 
+       CHECKGLERROR
        if (gl_backend_rebindtextures)
        {
                gl_backend_rebindtextures = false;
                GL_SetupTextureState();
+               CHECKGLERROR
        }
 
        for (unitnum = 0;unitnum < backendimageunits;unitnum++)
@@ -1644,40 +1696,44 @@ void R_Mesh_ResetTextureState(void)
                {
                        GL_ActiveTexture(unitnum);
                        if (unitnum < backendunits)
-                               qglDisable(GL_TEXTURE_1D);
+                       {
+                               qglDisable(GL_TEXTURE_1D);CHECKGLERROR
+                       }
                        unit->t1d = 0;
-                       qglBindTexture(GL_TEXTURE_1D, unit->t1d);
-                       CHECKGLERROR
+                       qglBindTexture(GL_TEXTURE_1D, unit->t1d);CHECKGLERROR
                }
                // update 2d texture binding
                if (unit->t2d)
                {
                        GL_ActiveTexture(unitnum);
                        if (unitnum < backendunits)
-                               qglDisable(GL_TEXTURE_2D);
+                       {
+                               qglDisable(GL_TEXTURE_2D);CHECKGLERROR
+                       }
                        unit->t2d = 0;
-                       qglBindTexture(GL_TEXTURE_2D, unit->t2d);
-                       CHECKGLERROR
+                       qglBindTexture(GL_TEXTURE_2D, unit->t2d);CHECKGLERROR
                }
                // update 3d texture binding
                if (unit->t3d)
                {
                        GL_ActiveTexture(unitnum);
                        if (unitnum < backendunits)
-                               qglDisable(GL_TEXTURE_3D);
+                       {
+                               qglDisable(GL_TEXTURE_3D);CHECKGLERROR
+                       }
                        unit->t3d = 0;
-                       qglBindTexture(GL_TEXTURE_3D, unit->t3d);
-                       CHECKGLERROR
+                       qglBindTexture(GL_TEXTURE_3D, unit->t3d);CHECKGLERROR
                }
                // update cubemap texture binding
                if (unit->tcubemap)
                {
                        GL_ActiveTexture(unitnum);
                        if (unitnum < backendunits)
-                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+                       {
+                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
+                       }
                        unit->tcubemap = 0;
-                       qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);
-                       CHECKGLERROR
+                       qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);CHECKGLERROR
                }
        }
        for (unitnum = 0;unitnum < backendarrayunits;unitnum++)
@@ -1698,10 +1754,11 @@ void R_Mesh_ResetTextureState(void)
                if (unit->texmatrixenabled)
                {
                        unit->texmatrixenabled = false;
-                       qglMatrixMode(GL_TEXTURE);
+                       CHECKGLERROR
+                       qglMatrixMode(GL_TEXTURE);CHECKGLERROR
                        GL_ActiveTexture(unitnum);
-                       qglLoadIdentity();
-                       qglMatrixMode(GL_MODELVIEW);
+                       qglLoadIdentity();CHECKGLERROR
+                       qglMatrixMode(GL_MODELVIEW);CHECKGLERROR
                }
                if (gl_combine.integer)
                {
@@ -1744,6 +1801,7 @@ void R_Mesh_ResetTextureState(void)
 
 void R_Mesh_Draw_ShowTris(int firstvertex, int numvertices, int numtriangles, const int *elements)
 {
+       CHECKGLERROR
        qglBegin(GL_LINES);
        for (;numtriangles;numtriangles--, elements += 3)
        {
index 1d448ac..bebaee3 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -502,9 +502,10 @@ void DrawQ_Begin(void)
        r_view_matrix = r_refdef.viewentitymatrix;
        GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
 
-       qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);
+       CHECKGLERROR
+       qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);CHECKGLERROR
        GL_SetupView_Mode_Ortho(0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100);
-       qglDepthFunc(GL_LEQUAL);
+       qglDepthFunc(GL_LEQUAL);CHECKGLERROR
        R_Mesh_Matrix(&identitymatrix);
 
        GL_DepthMask(true);
@@ -828,6 +829,7 @@ void DrawQ_LineLoop (drawqueuemesh_t *mesh, int flags)
        if (!r_render.integer)
                return;
 
+       CHECKGLERROR
        if(flags == DRAWFLAG_ADDITIVE)
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        else if(flags == DRAWFLAG_MODULATE)
@@ -838,6 +840,7 @@ void DrawQ_LineLoop (drawqueuemesh_t *mesh, int flags)
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
        GL_Color(1,1,1,1);
+       CHECKGLERROR
        qglBegin(GL_LINE_LOOP);
        for (num = 0;num < mesh->num_vertices;num++)
        {
@@ -846,6 +849,7 @@ void DrawQ_LineLoop (drawqueuemesh_t *mesh, int flags)
                qglVertex2f(mesh->data_vertex3f[num*3+0], mesh->data_vertex3f[num*3+1]);
        }
        qglEnd();
+       CHECKGLERROR
 }
 
 //LordHavoc: FIXME: this is nasty!
@@ -856,7 +860,8 @@ void DrawQ_LineWidth (float width)
                Con_Printf("DrawQ_LineWidth: not in 2d rendering stage!\n");
                return;
        }
-       qglLineWidth(width);
+       CHECKGLERROR
+       qglLineWidth(width);CHECKGLERROR
 }
 
 //[515]: this is old, delete
@@ -871,6 +876,7 @@ void DrawQ_Line (float width, float x1, float y1, float x2, float y2, float r, f
        if (!r_render.integer)
                return;
 
+       CHECKGLERROR
        if(width > 0)
                DrawQ_LineWidth(width);
 
@@ -884,10 +890,12 @@ void DrawQ_Line (float width, float x1, float y1, float x2, float y2, float r, f
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
        GL_Color(r,g,b,alpha);
+       CHECKGLERROR
        qglBegin(GL_LINES);
        qglVertex2f(x1, y1);
        qglVertex2f(x2, y2);
        qglEnd();
+       CHECKGLERROR
 }
 
 void DrawQ_SetClipArea(float x, float y, float width, float height)
index 0708991..96e1a8d 100644 (file)
@@ -790,7 +790,7 @@ void R_GLSL_CompilePermutation(int permutation)
        if (p->program)
        {
                CHECKGLERROR
-               qglUseProgramObjectARB(p->program);
+               qglUseProgramObjectARB(p->program);CHECKGLERROR
                p->loc_Texture_Normal      = qglGetUniformLocationARB(p->program, "Texture_Normal");
                p->loc_Texture_Color       = qglGetUniformLocationARB(p->program, "Texture_Color");
                p->loc_Texture_Gloss       = qglGetUniformLocationARB(p->program, "Texture_Gloss");
@@ -827,8 +827,8 @@ void R_GLSL_CompilePermutation(int permutation)
                if (p->loc_Texture_Lightmap >= 0)  qglUniform1iARB(p->loc_Texture_Lightmap, 7);
                if (p->loc_Texture_Deluxemap >= 0) qglUniform1iARB(p->loc_Texture_Deluxemap, 8);
                if (p->loc_Texture_Glow >= 0)      qglUniform1iARB(p->loc_Texture_Glow, 9);
-               qglUseProgramObjectARB(0);
                CHECKGLERROR
+               qglUseProgramObjectARB(0);CHECKGLERROR
        }
        else
                Con_Printf("permutation%s failed for shader %s, some features may not work properly!\n", permutationname, "glsl/default.glsl");
@@ -1203,8 +1203,9 @@ void GL_Init (void)
        Con_DPrintf("\nengine extensions: %s\n", vm_sv_extensions );
 
        // clear to black (loading plaque will be seen over this)
-       qglClearColor(0,0,0,1);
-       qglClear(GL_COLOR_BUFFER_BIT);
+       CHECKGLERROR
+       qglClearColor(0,0,0,1);CHECKGLERROR
+       qglClear(GL_COLOR_BUFFER_BIT);CHECKGLERROR
 }
 
 int R_CullBox(const vec3_t mins, const vec3_t maxs)
@@ -1557,13 +1558,15 @@ static void R_BlendView(void)
                R_Mesh_TexBind(0, R_GetTexture(r_bloom_texture_screen));
                // copy view into the full resolution screen image texture
                GL_ActiveTexture(0);
-               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);
+               CHECKGLERROR
+               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);CHECKGLERROR
                renderstats.bloom_copypixels += r_view_width * r_view_height;
                // now scale it down to the bloom size and raise to a power of itself
                // to darken it (this leaves the really bright stuff bright, and
                // everything else becomes very dark)
                // TODO: optimize with multitexture or GLSL
-               qglViewport(r_view_x, vid.height - (r_view_y + bloomheight), bloomwidth, bloomheight);
+               CHECKGLERROR
+               qglViewport(r_view_x, vid.height - (r_view_y + bloomheight), bloomwidth, bloomheight);CHECKGLERROR
                GL_BlendFunc(GL_ONE, GL_ZERO);
                GL_Color(1, 1, 1, 1);
                R_Mesh_Draw(0, 4, 2, polygonelements);
@@ -1580,7 +1583,8 @@ static void R_BlendView(void)
                R_Mesh_TexBind(0, R_GetTexture(r_bloom_texture_bloom));
                R_Mesh_TexCoordPointer(0, 2, texcoord2f[2]);
                GL_ActiveTexture(0);
-               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view_x, vid.height - (r_view_y + bloomheight), bloomwidth, bloomheight);
+               CHECKGLERROR
+               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view_x, vid.height - (r_view_y + bloomheight), bloomwidth, bloomheight);CHECKGLERROR
                renderstats.bloom_copypixels += bloomwidth * bloomheight;
                // blend on at multiple vertical offsets to achieve a vertical blur
                // TODO: do offset blends using GLSL
@@ -1612,7 +1616,8 @@ static void R_BlendView(void)
                }
                // copy the vertically blurred bloom view to a texture
                GL_ActiveTexture(0);
-               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view_x, vid.height - (r_view_y + bloomheight), bloomwidth, bloomheight);
+               CHECKGLERROR
+               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view_x, vid.height - (r_view_y + bloomheight), bloomwidth, bloomheight);CHECKGLERROR
                renderstats.bloom_copypixels += bloomwidth * bloomheight;
                // blend the vertically blurred image at multiple offsets horizontally
                // to finish the blur effect
@@ -1645,10 +1650,11 @@ static void R_BlendView(void)
                }
                // copy the blurred bloom view to a texture
                GL_ActiveTexture(0);
-               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view_x, vid.height - (r_view_y + bloomheight), bloomwidth, bloomheight);
+               CHECKGLERROR
+               qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r_view_x, vid.height - (r_view_y + bloomheight), bloomwidth, bloomheight);CHECKGLERROR
                renderstats.bloom_copypixels += bloomwidth * bloomheight;
                // go back to full view area
-               qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);
+               qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);CHECKGLERROR
                // put the original screen image back in place and blend the bloom
                // texture on it
                GL_Color(1,1,1,1);
@@ -1725,7 +1731,8 @@ void R_RenderView(void)
        }
 
        // GL is weird because it's bottom to top, r_view_y is top to bottom
-       qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);
+       CHECKGLERROR
+       qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);CHECKGLERROR
        GL_Scissor(r_view_x, r_view_y, r_view_width, r_view_height);
        GL_ScissorTest(true);
        GL_DepthMask(true);
@@ -1735,14 +1742,16 @@ void R_RenderView(void)
        if (r_timereport_active)
                R_TimeReport("setup");
 
-       qglDepthFunc(GL_LEQUAL);
-       qglPolygonOffset(r_polygonfactor, r_polygonoffset);
-       qglEnable(GL_POLYGON_OFFSET_FILL);
+       CHECKGLERROR
+       qglDepthFunc(GL_LEQUAL);CHECKGLERROR
+       qglPolygonOffset(r_polygonfactor, r_polygonoffset);CHECKGLERROR
+       qglEnable(GL_POLYGON_OFFSET_FILL);CHECKGLERROR
 
        R_RenderScene();
 
-       qglPolygonOffset(r_polygonfactor, r_polygonoffset);
-       qglDisable(GL_POLYGON_OFFSET_FILL);
+       CHECKGLERROR
+       qglPolygonOffset(r_polygonfactor, r_polygonoffset);CHECKGLERROR
+       qglDisable(GL_POLYGON_OFFSET_FILL);CHECKGLERROR
 
        R_BlendView();
        if (r_timereport_active)
@@ -1750,6 +1759,7 @@ void R_RenderView(void)
 
        GL_Scissor(0, 0, vid.width, vid.height);
        GL_ScissorTest(false);
+       CHECKGLERROR
 }
 
 //[515]: csqc
@@ -1785,7 +1795,8 @@ void CSQC_R_ClearScreen (void)
        }
 
        // GL is weird because it's bottom to top, r_view_y is top to bottom
-       qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);
+       CHECKGLERROR
+       qglViewport(r_view_x, vid.height - (r_view_y + r_view_height), r_view_width, r_view_height);CHECKGLERROR
        GL_Scissor(r_view_x, r_view_y, r_view_width, r_view_height);
        GL_ScissorTest(true);
        GL_DepthMask(true);
@@ -1794,19 +1805,22 @@ void CSQC_R_ClearScreen (void)
        R_UpdateFog();
        if (r_timereport_active)
                R_TimeReport("setup");
+       CHECKGLERROR
 }
 
 //[515]: csqc
 void CSQC_R_RenderScene (void)
 {
-       qglDepthFunc(GL_LEQUAL);
-       qglPolygonOffset(r_polygonfactor, r_polygonoffset);
-       qglEnable(GL_POLYGON_OFFSET_FILL);
+       CHECKGLERROR
+       qglDepthFunc(GL_LEQUAL);CHECKGLERROR
+       qglPolygonOffset(r_polygonfactor, r_polygonoffset);CHECKGLERROR
+       qglEnable(GL_POLYGON_OFFSET_FILL);CHECKGLERROR
 
        R_RenderScene();
 
-       qglPolygonOffset(r_polygonfactor, r_polygonoffset);
-       qglDisable(GL_POLYGON_OFFSET_FILL);
+       CHECKGLERROR
+       qglPolygonOffset(r_polygonfactor, r_polygonoffset);CHECKGLERROR
+       qglDisable(GL_POLYGON_OFFSET_FILL);CHECKGLERROR
 
        R_BlendView();
        if (r_timereport_active)
@@ -1814,6 +1828,7 @@ void CSQC_R_RenderScene (void)
 
        GL_Scissor(0, 0, vid.width, vid.height);
        GL_ScissorTest(false);
+       CHECKGLERROR
 }
 
 extern void R_DrawLightningBeams (void);
@@ -1828,8 +1843,11 @@ void R_RenderScene(void)
 
        r_framecount++;
 
+       CHECKGLERROR
        if (gl_support_fragment_shader)
-               qglUseProgramObjectARB(0);
+       {
+               qglUseProgramObjectARB(0);CHECKGLERROR
+       }
 
        R_MeshQueue_BeginScene();
 
@@ -1945,8 +1963,11 @@ void R_RenderScene(void)
        if (r_refdef.extraupdate)
                S_ExtraUpdate ();
 
+       CHECKGLERROR
        if (gl_support_fragment_shader)
-               qglUseProgramObjectARB(0);
+       {
+               qglUseProgramObjectARB(0);CHECKGLERROR
+       }
 }
 
 /*
@@ -2518,8 +2539,11 @@ void RSurf_ActiveEntity(const entity_render_t *ent)
 
 void RSurf_CleanUp(void)
 {
+       CHECKGLERROR
        if (rsurface_mode == RSURFMODE_GLSL)
-               qglUseProgramObjectARB(0);
+       {
+               qglUseProgramObjectARB(0);CHECKGLERROR
+       }
        GL_AlphaTest(false);
        rsurface_mode = RSURFMODE_NONE;
        rsurface_lightmaptexture = NULL;
@@ -2748,9 +2772,12 @@ static void R_DrawTextureSurfaceList(int texturenumsurfaces, msurface_t **textur
        renderstats.entities_surfaces += texturenumsurfaces;
        // FIXME: identify models using a better check than rsurface_model->brush.shadowmesh
        lightmode = ((rsurface_entity->effects & EF_FULLBRIGHT) || rsurface_model->brush.shadowmesh) ? 0 : 2;
+       CHECKGLERROR
        GL_DepthTest(!(rsurface_texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST));
        if ((rsurface_texture->textureflags & Q3TEXTUREFLAG_TWOSIDED) || (rsurface_entity->flags & RENDER_NOCULLFACE))
-               qglDisable(GL_CULL_FACE);
+       {
+               qglDisable(GL_CULL_FACE);CHECKGLERROR
+       }
        if (r_showsurfaces.integer)
        {
                if (rsurface_mode != RSURFMODE_SHOWSURFACES)
@@ -2778,7 +2805,9 @@ static void R_DrawTextureSurfaceList(int texturenumsurfaces, msurface_t **textur
                        if (rsurface_mode != RSURFMODE_SKY)
                        {
                                if (rsurface_mode == RSURFMODE_GLSL)
-                                       qglUseProgramObjectARB(0);
+                               {
+                                       qglUseProgramObjectARB(0);CHECKGLERROR
+                               }
                                rsurface_mode = RSURFMODE_SKY;
                                if (skyrendernow)
                                {
@@ -2887,10 +2916,13 @@ static void R_DrawTextureSurfaceList(int texturenumsurfaces, msurface_t **textur
        {
                int layerindex;
                const texturelayer_t *layer;
+               CHECKGLERROR
                if (rsurface_mode != RSURFMODE_MULTIPASS)
                {
                        if (rsurface_mode == RSURFMODE_GLSL)
-                               qglUseProgramObjectARB(0);
+                       {
+                               qglUseProgramObjectARB(0);CHECKGLERROR
+                       }
                        rsurface_mode = RSURFMODE_MULTIPASS;
                }
                RSurf_PrepareVerticesForBatch(true, false, texturenumsurfaces, texturesurfacelist);
@@ -2905,7 +2937,7 @@ static void R_DrawTextureSurfaceList(int texturenumsurfaces, msurface_t **textur
                                else
                                {
                                        GL_AlphaTest(false);
-                                       qglDepthFunc(GL_EQUAL);
+                                       qglDepthFunc(GL_EQUAL);CHECKGLERROR
                                }
                        }
                        GL_DepthMask(layer->depthmask);
@@ -3103,15 +3135,19 @@ static void R_DrawTextureSurfaceList(int texturenumsurfaces, msurface_t **textur
                                GL_LockArrays(0, 0);
                        }
                }
+               CHECKGLERROR
                if (rsurface_texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
                {
-                       qglDepthFunc(GL_LEQUAL);
+                       qglDepthFunc(GL_LEQUAL);CHECKGLERROR
                        GL_AlphaTest(false);
                }
        }
+       CHECKGLERROR
        GL_LockArrays(0, 0);
        if ((rsurface_texture->textureflags & Q3TEXTUREFLAG_TWOSIDED) || (rsurface_entity->flags & RENDER_NOCULLFACE))
-               qglEnable(GL_CULL_FACE);
+       {
+               qglEnable(GL_CULL_FACE);CHECKGLERROR
+       }
 }
 
 static void R_DrawSurface_TransparentCallback(const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight)
@@ -3268,20 +3304,21 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces)
                int i;
                const msurface_t *surface;
                q3mbrush_t *brush;
+               CHECKGLERROR
                R_Mesh_Matrix(&ent->matrix);
                R_Mesh_ColorPointer(NULL);
                R_Mesh_ResetTextureState();
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
                GL_DepthMask(false);
                GL_DepthTest(!r_showdisabledepthtest.integer);
-               qglPolygonOffset(r_polygonfactor + r_showcollisionbrushes_polygonfactor.value, r_polygonoffset + r_showcollisionbrushes_polygonoffset.value);
+               qglPolygonOffset(r_polygonfactor + r_showcollisionbrushes_polygonfactor.value, r_polygonoffset + r_showcollisionbrushes_polygonoffset.value);CHECKGLERROR
                for (i = 0, brush = model->brush.data_brushes + model->firstmodelbrush;i < model->nummodelbrushes;i++, brush++)
                        if (brush->colbrushf && brush->colbrushf->numtriangles)
                                R_DrawCollisionBrush(brush->colbrushf);
                for (i = 0, surface = model->data_surfaces + model->firstmodelsurface;i < model->nummodelsurfaces;i++, surface++)
                        if (surface->num_collisiontriangles)
                                R_DrawCollisionSurface(ent, surface);
-               qglPolygonOffset(r_polygonfactor, r_polygonoffset);
+               qglPolygonOffset(r_polygonfactor, r_polygonoffset);CHECKGLERROR
        }
 
        if (r_showtris.integer || r_shownormals.integer)
@@ -3290,10 +3327,13 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces)
                msurface_t *surface;
                const int *elements;
                vec3_t v;
+               CHECKGLERROR
                GL_DepthTest(true);
                GL_DepthMask(true);
                if (r_showdisabledepthtest.integer)
-                       qglDepthFunc(GL_ALWAYS);
+               {
+                       qglDepthFunc(GL_ALWAYS);CHECKGLERROR
+               }
                GL_BlendFunc(GL_ONE, GL_ZERO);
                R_Mesh_ColorPointer(NULL);
                R_Mesh_ResetTextureState();
@@ -3314,6 +3354,7 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces)
                                        else
                                                GL_Color(0, r_showtris.value, 0, 1);
                                        elements = (ent->model->surfmesh.data_element3i + 3 * surface->num_firsttriangle);
+                                       CHECKGLERROR
                                        qglBegin(GL_LINES);
                                        for (k = 0;k < surface->num_triangles;k++, elements += 3)
                                        {
@@ -3322,6 +3363,7 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces)
                                                qglArrayElement(elements[2]);qglArrayElement(elements[0]);
                                        }
                                        qglEnd();
+                                       CHECKGLERROR
                                }
                                if (r_shownormals.integer)
                                {
@@ -3335,6 +3377,7 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces)
                                                qglVertex3f(v[0], v[1], v[2]);
                                        }
                                        qglEnd();
+                                       CHECKGLERROR
                                        GL_Color(0, 0, r_shownormals.value, 1);
                                        qglBegin(GL_LINES);
                                        for (k = 0, l = surface->num_firstvertex;k < surface->num_vertices;k++, l++)
@@ -3345,6 +3388,7 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces)
                                                qglVertex3f(v[0], v[1], v[2]);
                                        }
                                        qglEnd();
+                                       CHECKGLERROR
                                        GL_Color(0, r_shownormals.value, 0, 1);
                                        qglBegin(GL_LINES);
                                        for (k = 0, l = surface->num_firstvertex;k < surface->num_vertices;k++, l++)
@@ -3355,12 +3399,15 @@ void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces)
                                                qglVertex3f(v[0], v[1], v[2]);
                                        }
                                        qglEnd();
+                                       CHECKGLERROR
                                }
                        }
                }
                rsurface_texture = NULL;
                if (r_showdisabledepthtest.integer)
-                       qglDepthFunc(GL_LEQUAL);
+               {
+                       qglDepthFunc(GL_LEQUAL);CHECKGLERROR
+               }
        }
 }
 
index 43334b6..1ebbfec 100644 (file)
@@ -343,10 +343,11 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, int surfacenumber,
        int i, numpoints;
        float *v;
        float vertex3f[POLYGONELEMENTS_MAXPOINTS*3];
+       CHECKGLERROR
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthMask(false);
        GL_DepthTest(true);
-       qglDisable(GL_CULL_FACE);
+       qglDisable(GL_CULL_FACE);CHECKGLERROR
        R_Mesh_Matrix(&identitymatrix);
 
        numpoints = min(portal->numpoints, POLYGONELEMENTS_MAXPOINTS);
@@ -363,7 +364,7 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, int surfacenumber,
        for (i = 0, v = vertex3f;i < numpoints;i++, v += 3)
                VectorCopy(portal->points[i].position, v);
        R_Mesh_Draw(0, numpoints, numpoints - 2, polygonelements);
-       qglEnable(GL_CULL_FACE);
+       qglEnable(GL_CULL_FACE);CHECKGLERROR
 }
 
 // LordHavoc: this is just a nice debugging tool, very slow
@@ -814,12 +815,14 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface
        msurface_t *batchsurfacelist[RSURF_MAX_BATCHSURFACES];
        texture_t *tex;
        qboolean skip;
+       CHECKGLERROR
        RSurf_ActiveEntity(ent);
        R_UpdateAllTextureInfo(ent);
        tex = NULL;
        rsurface_texture = NULL;
        skip = false;
        batchnumsurfaces = 0;
+       CHECKGLERROR
        for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
        {
                if ((ent == r_refdef.worldentity && !r_worldsurfacevisible[surfacelist[surfacelistindex]]))
@@ -863,7 +866,7 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface
                        R_Shadow_RenderSurfacesLighting(batchnumsurfaces, batchsurfacelist);
                batchnumsurfaces = 0;
        }
-       qglEnable(GL_CULL_FACE);
+       qglEnable(GL_CULL_FACE);CHECKGLERROR
 }
 
 //Made by [515]
index cf4131c..97e0aa9 100644 (file)
@@ -198,7 +198,10 @@ void R_FreeTexture(rtexture_t *rt)
                Host_Error("R_FreeTexture: texture \"%s\" not linked in pool", glt->identifier);
 
        if (glt->texnum)
-               qglDeleteTextures(1, (GLuint *)&glt->texnum);
+       {
+               CHECKGLERROR
+               qglDeleteTextures(1, (GLuint *)&glt->texnum);CHECKGLERROR
+       }
 
        if (glt->inputtexels)
                Mem_Free(glt->inputtexels);
@@ -293,6 +296,7 @@ static void GL_TextureMode_f (void)
 
        // change all the existing mipmap texture objects
        // FIXME: force renderer(/client/something?) restart instead?
+       CHECKGLERROR
        for (pool = gltexturepoolchain;pool;pool = pool->next)
        {
                for (glt = pool->gltchain;glt;glt = glt->chain)
@@ -300,14 +304,18 @@ static void GL_TextureMode_f (void)
                        // only update already uploaded images
                        if (!(glt->flags & (GLTEXF_UPLOAD | TEXF_FORCENEAREST | TEXF_FORCELINEAR)))
                        {
-                               qglGetIntegerv(gltexturetypebindingenums[glt->texturetype], &oldbindtexnum);
-                               qglBindTexture(gltexturetypeenums[glt->texturetype], glt->texnum);
+                               qglGetIntegerv(gltexturetypebindingenums[glt->texturetype], &oldbindtexnum);CHECKGLERROR
+                               qglBindTexture(gltexturetypeenums[glt->texturetype], glt->texnum);CHECKGLERROR
                                if (glt->flags & TEXF_MIPMAP)
-                                       qglTexParameteri(gltexturetypeenums[glt->texturetype], GL_TEXTURE_MIN_FILTER, gl_filter_min);
+                               {
+                                       qglTexParameteri(gltexturetypeenums[glt->texturetype], GL_TEXTURE_MIN_FILTER, gl_filter_min);CHECKGLERROR
+                               }
                                else
-                                       qglTexParameteri(gltexturetypeenums[glt->texturetype], GL_TEXTURE_MIN_FILTER, gl_filter_mag);
-                               qglTexParameteri(gltexturetypeenums[glt->texturetype], GL_TEXTURE_MAG_FILTER, gl_filter_mag);
-                               qglBindTexture(gltexturetypeenums[glt->texturetype], oldbindtexnum);
+                               {
+                                       qglTexParameteri(gltexturetypeenums[glt->texturetype], GL_TEXTURE_MIN_FILTER, gl_filter_mag);CHECKGLERROR
+                               }
+                               qglTexParameteri(gltexturetypeenums[glt->texturetype], GL_TEXTURE_MAG_FILTER, gl_filter_mag);CHECKGLERROR
+                               qglBindTexture(gltexturetypeenums[glt->texturetype], oldbindtexnum);CHECKGLERROR
                        }
                }
        }
@@ -442,8 +450,8 @@ static void R_TextureStats_f(void)
 static void r_textures_start(void)
 {
        // LordHavoc: allow any alignment
-       qglPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        CHECKGLERROR
+       qglPixelStorei(GL_UNPACK_ALIGNMENT, 1);CHECKGLERROR
 
        texturemempool = Mem_AllocPool("texture management", 0, NULL);
 
@@ -521,6 +529,7 @@ void R_Textures_Frame (void)
 
                Cvar_SetValueQuick(&gl_texture_anisotropy, old_aniso);
 
+               CHECKGLERROR
                for (pool = gltexturepoolchain;pool;pool = pool->next)
                {
                        for (glt = pool->gltchain;glt;glt = glt->chain)
@@ -528,12 +537,12 @@ void R_Textures_Frame (void)
                                // only update already uploaded images
                                if ((glt->flags & (GLTEXF_UPLOAD | TEXF_MIPMAP)) == TEXF_MIPMAP)
                                {
-                                       qglGetIntegerv(gltexturetypebindingenums[glt->texturetype], &oldbindtexnum);
+                                       qglGetIntegerv(gltexturetypebindingenums[glt->texturetype], &oldbindtexnum);CHECKGLERROR
 
-                                       qglBindTexture(gltexturetypeenums[glt->texturetype], glt->texnum);
+                                       qglBindTexture(gltexturetypeenums[glt->texturetype], glt->texnum);CHECKGLERROR
                                        qglTexParameteri(gltexturetypeenums[glt->texturetype], GL_TEXTURE_MAX_ANISOTROPY_EXT, old_aniso);CHECKGLERROR
 
-                                       qglBindTexture(gltexturetypeenums[glt->texturetype], oldbindtexnum);
+                                       qglBindTexture(gltexturetypeenums[glt->texturetype], oldbindtexnum);CHECKGLERROR
                                }
                        }
                }
@@ -635,9 +644,8 @@ static void R_Upload(gltexture_t *glt, unsigned char *data, int fragx, int fragy
        CHECKGLERROR
 
        // we need to restore the texture binding after finishing the upload
-       qglGetIntegerv(gltexturetypebindingenums[glt->texturetype], &oldbindtexnum);
-       qglBindTexture(gltexturetypeenums[glt->texturetype], glt->texnum);
-       CHECKGLERROR
+       qglGetIntegerv(gltexturetypebindingenums[glt->texturetype], &oldbindtexnum);CHECKGLERROR
+       qglBindTexture(gltexturetypeenums[glt->texturetype], glt->texnum);CHECKGLERROR
 
        // these are rounded up versions of the size to do better resampling
        for (width  = 1;width  < glt->inputwidth ;width  <<= 1);
@@ -666,16 +674,13 @@ static void R_Upload(gltexture_t *glt, unsigned char *data, int fragx, int fragy
                switch(glt->texturetype)
                {
                case GLTEXTURETYPE_1D:
-                       qglTexSubImage1D(GL_TEXTURE_1D, 0, fragx, fragwidth, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);
-                       CHECKGLERROR
+                       qglTexSubImage1D(GL_TEXTURE_1D, 0, fragx, fragwidth, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR
                        break;
                case GLTEXTURETYPE_2D:
-                       qglTexSubImage2D(GL_TEXTURE_2D, 0, fragx, fragy, fragwidth, fragheight, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);
-                       CHECKGLERROR
+                       qglTexSubImage2D(GL_TEXTURE_2D, 0, fragx, fragy, fragwidth, fragheight, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR
                        break;
                case GLTEXTURETYPE_3D:
-                       qglTexSubImage3D(GL_TEXTURE_3D, 0, fragx, fragy, fragz, fragwidth, fragheight, fragdepth, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);
-                       CHECKGLERROR
+                       qglTexSubImage3D(GL_TEXTURE_3D, 0, fragx, fragy, fragz, fragwidth, fragheight, fragdepth, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR
                        break;
                default:
                        Host_Error("R_Upload: partial update of type other than 1D, 2D, or 3D");
@@ -709,44 +714,38 @@ static void R_Upload(gltexture_t *glt, unsigned char *data, int fragx, int fragy
                switch(glt->texturetype)
                {
                case GLTEXTURETYPE_1D:
-                       qglTexImage1D(GL_TEXTURE_1D, mip++, glt->glinternalformat, width, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);
-                       CHECKGLERROR
+                       qglTexImage1D(GL_TEXTURE_1D, mip++, glt->glinternalformat, width, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR
                        if (glt->flags & TEXF_MIPMAP)
                        {
                                while (width > 1 || height > 1 || depth > 1)
                                {
                                        Image_MipReduce(prevbuffer, resizebuffer, &width, &height, &depth, 1, 1, 1, glt->bytesperpixel);
                                        prevbuffer = resizebuffer;
-                                       qglTexImage1D(GL_TEXTURE_1D, mip++, glt->glinternalformat, width, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);
-                                       CHECKGLERROR
+                                       qglTexImage1D(GL_TEXTURE_1D, mip++, glt->glinternalformat, width, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR
                                }
                        }
                        break;
                case GLTEXTURETYPE_2D:
-                       qglTexImage2D(GL_TEXTURE_2D, mip++, glt->glinternalformat, width, height, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);
-                       CHECKGLERROR
+                       qglTexImage2D(GL_TEXTURE_2D, mip++, glt->glinternalformat, width, height, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR
                        if (glt->flags & TEXF_MIPMAP)
                        {
                                while (width > 1 || height > 1 || depth > 1)
                                {
                                        Image_MipReduce(prevbuffer, resizebuffer, &width, &height, &depth, 1, 1, 1, glt->bytesperpixel);
                                        prevbuffer = resizebuffer;
-                                       qglTexImage2D(GL_TEXTURE_2D, mip++, glt->glinternalformat, width, height, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);
-                                       CHECKGLERROR
+                                       qglTexImage2D(GL_TEXTURE_2D, mip++, glt->glinternalformat, width, height, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR
                                }
                        }
                        break;
                case GLTEXTURETYPE_3D:
-                       qglTexImage3D(GL_TEXTURE_3D, mip++, glt->glinternalformat, width, height, depth, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);
-                       CHECKGLERROR
+                       qglTexImage3D(GL_TEXTURE_3D, mip++, glt->glinternalformat, width, height, depth, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR
                        if (glt->flags & TEXF_MIPMAP)
                        {
                                while (width > 1 || height > 1 || depth > 1)
                                {
                                        Image_MipReduce(prevbuffer, resizebuffer, &width, &height, &depth, 1, 1, 1, glt->bytesperpixel);
                                        prevbuffer = resizebuffer;
-                                       qglTexImage3D(GL_TEXTURE_3D, mip++, glt->glinternalformat, width, height, depth, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);
-                                       CHECKGLERROR
+                                       qglTexImage3D(GL_TEXTURE_3D, mip++, glt->glinternalformat, width, height, depth, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR
                                }
                        }
                        break;
@@ -770,16 +769,14 @@ static void R_Upload(gltexture_t *glt, unsigned char *data, int fragx, int fragy
                                        prevbuffer = resizebuffer;
                                }
                                mip = 0;
-                               qglTexImage2D(cubemapside[i], mip++, glt->glinternalformat, width, height, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);
-                               CHECKGLERROR
+                               qglTexImage2D(cubemapside[i], mip++, glt->glinternalformat, width, height, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR
                                if (glt->flags & TEXF_MIPMAP)
                                {
                                        while (width > 1 || height > 1 || depth > 1)
                                        {
                                                Image_MipReduce(prevbuffer, resizebuffer, &width, &height, &depth, 1, 1, 1, glt->bytesperpixel);
                                                prevbuffer = resizebuffer;
-                                               qglTexImage2D(cubemapside[i], mip++, glt->glinternalformat, width, height, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);
-                                               CHECKGLERROR
+                                               qglTexImage2D(cubemapside[i], mip++, glt->glinternalformat, width, height, 0, glt->glformat, GL_UNSIGNED_BYTE, prevbuffer);CHECKGLERROR
                                        }
                                }
                        }
@@ -787,7 +784,7 @@ static void R_Upload(gltexture_t *glt, unsigned char *data, int fragx, int fragy
                }
                GL_SetupTextureParameters(glt->flags, glt->texturetype);
        }
-       qglBindTexture(gltexturetypeenums[glt->texturetype], oldbindtexnum);
+       qglBindTexture(gltexturetypeenums[glt->texturetype], oldbindtexnum);CHECKGLERROR
 }
 
 static void R_UploadTexture (gltexture_t *glt)
@@ -795,7 +792,8 @@ static void R_UploadTexture (gltexture_t *glt)
        if (!(glt->flags & GLTEXF_UPLOAD))
                return;
 
-       qglGenTextures(1, (GLuint *)&glt->texnum);
+       CHECKGLERROR
+       qglGenTextures(1, (GLuint *)&glt->texnum);CHECKGLERROR
        R_Upload(glt, glt->inputtexels, 0, 0, 0, glt->inputwidth, glt->inputheight, glt->inputdepth);
        if (glt->inputtexels)
        {
index a84dd17..5cc8935 100644 (file)
--- a/glquake.h
+++ b/glquake.h
@@ -681,7 +681,7 @@ extern int gl_support_shading_language_100;
 #define DEBUGGL
 
 #ifdef DEBUGGL
-#define CHECKGLERROR {if (gl_printcheckerror.integer) Con_Printf("CHECKGLERROR at %s:%d\n", __FILE__, __LINE__);if (gl_paranoid.integer && (errornumber = qglGetError())) GL_PrintError(errornumber, __FILE__, __LINE__);}
+#define CHECKGLERROR {if (gl_paranoid.integer){if (gl_printcheckerror.integer) Con_Printf("CHECKGLERROR at %s:%d\n", __FILE__, __LINE__);errornumber = qglGetError();if (errornumber) GL_PrintError(errornumber, __FILE__, __LINE__);}}
 extern int errornumber;
 void GL_PrintError(int errornumber, char *filename, int linenumber);
 #else
index e298e8e..a3eacce 100644 (file)
@@ -2871,10 +2871,11 @@ void VM_DrawPolygonCallback (const entity_render_t *ent, int surfacenumber, cons
 
        R_Mesh_TexBind(0, R_GetTexture(p->tex));
 
+       CHECKGLERROR
        //[515]: is speed is max ?
        if(p->flags & VM_POLYGON_FLLINES)       //[515]: lines
        {
-               qglLineWidth(p->data[13]);
+               qglLineWidth(p->data[13]);CHECKGLERROR
                qglBegin(GL_LINE_LOOP);
                        qglTexCoord1f   (p->data[12]);
                        qglColor4f              (p->data[20], p->data[21], p->data[22], p->data[23]);
@@ -2898,6 +2899,7 @@ void VM_DrawPolygonCallback (const entity_render_t *ent, int surfacenumber, cons
                                }
                        }
                qglEnd();
+               CHECKGLERROR
        }
        else
        {
@@ -2921,6 +2923,7 @@ void VM_DrawPolygonCallback (const entity_render_t *ent, int surfacenumber, cons
                                qglVertex3f             (p->data[9] , p->data[10],  p->data[11]);
                        }
                qglEnd();
+               CHECKGLERROR
        }
 }
 
index c1dcc70..d845cb3 100644 (file)
@@ -709,20 +709,22 @@ void R_Shadow_RenderVolume(int numvertices, int numtriangles, const float *verte
                return;
        }
        renderstats.lights_shadowtriangles += numtriangles;
+       CHECKGLERROR
        R_Mesh_VertexPointer(vertex3f);
        GL_LockArrays(0, numvertices);
        if (r_shadow_rendermode == R_SHADOW_RENDERMODE_STENCIL)
        {
                // decrement stencil if backface is behind depthbuffer
-               qglCullFace(GL_BACK); // quake is backwards, this culls front faces
-               qglStencilOp(GL_KEEP, GL_DECR, GL_KEEP);
+               qglCullFace(GL_BACK);CHECKGLERROR // quake is backwards, this culls front faces
+               qglStencilOp(GL_KEEP, GL_DECR, GL_KEEP);CHECKGLERROR
                R_Mesh_Draw(0, numvertices, numtriangles, element3i);
                // increment stencil if frontface is behind depthbuffer
-               qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
-               qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP);
+               qglCullFace(GL_FRONT);CHECKGLERROR // quake is backwards, this culls back faces
+               qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP);CHECKGLERROR
        }
        R_Mesh_Draw(0, numvertices, numtriangles, element3i);
        GL_LockArrays(0, 0);
+       CHECKGLERROR
 }
 
 static void R_Shadow_MakeTextures(void)
@@ -816,14 +818,15 @@ void R_Shadow_RenderMode_Begin(void)
         || r_shadow_lightattenuationscale.value != r_shadow_attenscale)
                R_Shadow_MakeTextures();
 
+       CHECKGLERROR
        R_Mesh_ColorPointer(NULL);
        R_Mesh_ResetTextureState();
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_DepthMask(false);
        GL_DepthTest(true);
        GL_Color(0, 0, 0, 1);
-       qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
-       qglEnable(GL_CULL_FACE);
+       qglCullFace(GL_FRONT);CHECKGLERROR // quake is backwards, this culls back faces
+       qglEnable(GL_CULL_FACE);CHECKGLERROR
        GL_Scissor(r_view_x, r_view_y, r_view_width, r_view_height);
 
        r_shadow_rendermode = R_SHADOW_RENDERMODE_NONE;
@@ -848,51 +851,51 @@ void R_Shadow_RenderMode_ActiveLight(rtlight_t *rtlight)
 
 void R_Shadow_RenderMode_Reset(void)
 {
+       CHECKGLERROR
        if (r_shadow_rendermode == R_SHADOW_RENDERMODE_LIGHT_GLSL)
        {
-               qglUseProgramObjectARB(0);
-               // HACK HACK HACK: work around for bug in NVIDIAI 6xxx drivers that causes GL_OUT_OF_MEMORY and/or software rendering
-               qglBegin(GL_TRIANGLES);
-               qglEnd();
-               CHECKGLERROR
+               qglUseProgramObjectARB(0);CHECKGLERROR
        }
        else if (r_shadow_rendermode == R_SHADOW_RENDERMODE_STENCILTWOSIDE)
-               qglDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
+       {
+               qglDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);CHECKGLERROR
+       }
        R_Mesh_ColorPointer(NULL);
        R_Mesh_ResetTextureState();
 }
 
 void R_Shadow_RenderMode_StencilShadowVolumes(void)
 {
+       CHECKGLERROR
        R_Shadow_RenderMode_Reset();
        GL_Color(1, 1, 1, 1);
        GL_ColorMask(0, 0, 0, 0);
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_DepthMask(false);
        GL_DepthTest(true);
-       qglPolygonOffset(r_shadowpolygonfactor, r_shadowpolygonoffset);
-       qglDepthFunc(GL_LESS);
-       qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
-       qglEnable(GL_STENCIL_TEST);
-       qglStencilFunc(GL_ALWAYS, 128, ~0);
+       qglPolygonOffset(r_shadowpolygonfactor, r_shadowpolygonoffset);CHECKGLERROR
+       qglDepthFunc(GL_LESS);CHECKGLERROR
+       qglCullFace(GL_FRONT);CHECKGLERROR // quake is backwards, this culls back faces
+       qglEnable(GL_STENCIL_TEST);CHECKGLERROR
+       qglStencilFunc(GL_ALWAYS, 128, ~0);CHECKGLERROR
        r_shadow_rendermode = r_shadow_shadowingrendermode;
        if (r_shadow_rendermode == R_SHADOW_RENDERMODE_STENCILTWOSIDE)
        {
-               qglDisable(GL_CULL_FACE);
-               qglEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
-               qglActiveStencilFaceEXT(GL_BACK); // quake is backwards, this is front faces
-               qglStencilMask(~0);
-               qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP);
-               qglActiveStencilFaceEXT(GL_FRONT); // quake is backwards, this is back faces
-               qglStencilMask(~0);
-               qglStencilOp(GL_KEEP, GL_DECR, GL_KEEP);
+               qglDisable(GL_CULL_FACE);CHECKGLERROR
+               qglEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);CHECKGLERROR
+               qglActiveStencilFaceEXT(GL_BACK);CHECKGLERROR // quake is backwards, this is front faces
+               qglStencilMask(~0);CHECKGLERROR
+               qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP);CHECKGLERROR
+               qglActiveStencilFaceEXT(GL_FRONT);CHECKGLERROR // quake is backwards, this is back faces
+               qglStencilMask(~0);CHECKGLERROR
+               qglStencilOp(GL_KEEP, GL_DECR, GL_KEEP);CHECKGLERROR
        }
        else
        {
-               qglEnable(GL_CULL_FACE);
-               qglStencilMask(~0);
+               qglEnable(GL_CULL_FACE);CHECKGLERROR
+               qglStencilMask(~0);CHECKGLERROR
                // this is changed by every shadow render so its value here is unimportant
-               qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+               qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);CHECKGLERROR
        }
        GL_Clear(GL_STENCIL_BUFFER_BIT);
        renderstats.lights_clears++;
@@ -900,29 +903,38 @@ void R_Shadow_RenderMode_StencilShadowVolumes(void)
 
 void R_Shadow_RenderMode_Lighting(qboolean stenciltest, qboolean transparent)
 {
+       CHECKGLERROR
        R_Shadow_RenderMode_Reset();
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        GL_DepthMask(false);
        GL_DepthTest(true);
-       qglPolygonOffset(r_polygonfactor, r_polygonoffset);
-       //qglDisable(GL_POLYGON_OFFSET_FILL);
+       qglPolygonOffset(r_polygonfactor, r_polygonoffset);CHECKGLERROR
+       //qglDisable(GL_POLYGON_OFFSET_FILL);CHECKGLERROR
        GL_Color(1, 1, 1, 1);
        GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
        if (transparent)
-               qglDepthFunc(GL_LEQUAL);
+       {
+               qglDepthFunc(GL_LEQUAL);CHECKGLERROR
+       }
        else
-               qglDepthFunc(GL_EQUAL);
-       qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
-       qglEnable(GL_CULL_FACE);
+       {
+               qglDepthFunc(GL_EQUAL);CHECKGLERROR
+       }
+       qglCullFace(GL_FRONT);CHECKGLERROR // quake is backwards, this culls back faces
+       qglEnable(GL_CULL_FACE);CHECKGLERROR
        if (stenciltest)
-               qglEnable(GL_STENCIL_TEST);
+       {
+               qglEnable(GL_STENCIL_TEST);CHECKGLERROR
+       }
        else
-               qglDisable(GL_STENCIL_TEST);
-       qglStencilMask(~0);
-       qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+       {
+               qglDisable(GL_STENCIL_TEST);CHECKGLERROR
+       }
+       qglStencilMask(~0);CHECKGLERROR
+       qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);CHECKGLERROR
        // only draw light where this geometry was already rendered AND the
        // stencil is 128 (values other than this mean shadow)
-       qglStencilFunc(GL_EQUAL, 128, ~0);
+       qglStencilFunc(GL_EQUAL, 128, ~0);CHECKGLERROR
        r_shadow_rendermode = r_shadow_lightingrendermode;
        // do global setup needed for the chosen lighting mode
        if (r_shadow_rendermode == R_SHADOW_RENDERMODE_LIGHT_GLSL)
@@ -946,63 +958,76 @@ void R_Shadow_RenderMode_Lighting(qboolean stenciltest, qboolean transparent)
 
 void R_Shadow_RenderMode_VisibleShadowVolumes(void)
 {
+       CHECKGLERROR
        R_Shadow_RenderMode_Reset();
        GL_BlendFunc(GL_ONE, GL_ONE);
        GL_DepthMask(false);
        GL_DepthTest(!r_showdisabledepthtest.integer);
-       qglPolygonOffset(r_polygonfactor, r_polygonoffset);
+       qglPolygonOffset(r_polygonfactor, r_polygonoffset);CHECKGLERROR
        GL_Color(0.0, 0.0125, 0.1, 1);
        GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
-       qglDepthFunc(GL_GEQUAL);
-       qglCullFace(GL_FRONT); // this culls back
-       qglDisable(GL_CULL_FACE);
-       qglDisable(GL_STENCIL_TEST);
+       qglDepthFunc(GL_GEQUAL);CHECKGLERROR
+       qglCullFace(GL_FRONT);CHECKGLERROR // this culls back
+       qglDisable(GL_CULL_FACE);CHECKGLERROR
+       qglDisable(GL_STENCIL_TEST);CHECKGLERROR
        r_shadow_rendermode = R_SHADOW_RENDERMODE_VISIBLEVOLUMES;
 }
 
 void R_Shadow_RenderMode_VisibleLighting(qboolean stenciltest, qboolean transparent)
 {
+       CHECKGLERROR
        R_Shadow_RenderMode_Reset();
        GL_BlendFunc(GL_ONE, GL_ONE);
        GL_DepthMask(false);
        GL_DepthTest(!r_showdisabledepthtest.integer);
-       qglPolygonOffset(r_polygonfactor, r_polygonoffset);
+       qglPolygonOffset(r_polygonfactor, r_polygonoffset);CHECKGLERROR
        GL_Color(0.1, 0.0125, 0, 1);
        GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
        if (transparent)
-               qglDepthFunc(GL_LEQUAL);
+       {
+               qglDepthFunc(GL_LEQUAL);CHECKGLERROR
+       }
        else
-               qglDepthFunc(GL_EQUAL);
-       qglCullFace(GL_FRONT); // this culls back
-       qglEnable(GL_CULL_FACE);
+       {
+               qglDepthFunc(GL_EQUAL);CHECKGLERROR
+       }
+       qglCullFace(GL_FRONT);CHECKGLERROR // this culls back
+       qglEnable(GL_CULL_FACE);CHECKGLERROR
        if (stenciltest)
-               qglEnable(GL_STENCIL_TEST);
+       {
+               qglEnable(GL_STENCIL_TEST);CHECKGLERROR
+       }
        else
-               qglDisable(GL_STENCIL_TEST);
+       {
+               qglDisable(GL_STENCIL_TEST);CHECKGLERROR
+       }
        r_shadow_rendermode = R_SHADOW_RENDERMODE_VISIBLELIGHTING;
 }
 
 void R_Shadow_RenderMode_End(void)
 {
+       CHECKGLERROR
        R_Shadow_RenderMode_Reset();
        R_Shadow_RenderMode_ActiveLight(NULL);
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_DepthMask(true);
        GL_DepthTest(true);
-       qglPolygonOffset(r_polygonfactor, r_polygonoffset);
-       //qglDisable(GL_POLYGON_OFFSET_FILL);
+       qglPolygonOffset(r_polygonfactor, r_polygonoffset);CHECKGLERROR
+       //qglDisable(GL_POLYGON_OFFSET_FILL);CHECKGLERROR
        GL_Color(1, 1, 1, 1);
        GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
        GL_Scissor(r_view_x, r_view_y, r_view_width, r_view_height);
-       qglDepthFunc(GL_LEQUAL);
-       qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
-       qglEnable(GL_CULL_FACE);
-       qglDisable(GL_STENCIL_TEST);
-       qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+       qglDepthFunc(GL_LEQUAL);CHECKGLERROR
+       qglCullFace(GL_FRONT);CHECKGLERROR // quake is backwards, this culls back faces
+       qglEnable(GL_CULL_FACE);CHECKGLERROR
+       qglDisable(GL_STENCIL_TEST);CHECKGLERROR
+       qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);CHECKGLERROR
        if (gl_support_stenciltwoside)
-               qglDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
-       qglStencilMask(~0);
-       qglStencilFunc(GL_ALWAYS, 128, ~0);
+       {
+               qglDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);CHECKGLERROR
+       }
+       qglStencilMask(~0);CHECKGLERROR
+       qglStencilFunc(GL_ALWAYS, 128, ~0);CHECKGLERROR
        r_shadow_rendermode = R_SHADOW_RENDERMODE_NONE;
 }
 
@@ -1090,8 +1115,8 @@ qboolean R_Shadow_ScissorForBBox(const float *mins, const float *maxs)
 
        // the light area is visible, set up the scissor rectangle
        GL_Scissor(ix1, vid.height - iy2, ix2 - ix1, iy2 - iy1);
-       //qglScissor(ix1, iy1, ix2 - ix1, iy2 - iy1);
-       //qglEnable(GL_SCISSOR_TEST);
+       //qglScissor(ix1, iy1, ix2 - ix1, iy2 - iy1);CHECKGLERROR
+       //qglEnable(GL_SCISSOR_TEST);CHECKGLERROR
        renderstats.lights_scissored++;
        return false;
 }
@@ -1257,7 +1282,9 @@ static void R_Shadow_RenderSurfacesLighting_Light_GLSL(int numsurfaces, msurface
        R_Mesh_TexCoordPointer(2, 3, rsurface_tvector3f);
        R_Mesh_TexCoordPointer(3, 3, rsurface_normal3f);
        if (rsurface_texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
-               qglDepthFunc(GL_EQUAL);
+       {
+               qglDepthFunc(GL_EQUAL);CHECKGLERROR
+       }
        for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
        {
                const msurface_t *surface = surfacelist[surfacelistindex];
@@ -1266,7 +1293,9 @@ static void R_Shadow_RenderSurfacesLighting_Light_GLSL(int numsurfaces, msurface
        }
        GL_LockArrays(0, 0);
        if (rsurface_texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
-               qglDepthFunc(GL_LEQUAL);
+       {
+               qglDepthFunc(GL_LEQUAL);CHECKGLERROR
+       }
 }
 
 static void R_Shadow_RenderSurfacesLighting_Light_Dot3_AmbientPass(const msurface_t *surface, const vec3_t lightcolorbase, rtexture_t *basetexture, float colorscale)
@@ -1943,9 +1972,13 @@ void R_Shadow_RenderSurfacesLighting(int numsurfaces, msurface_t **surfacelist)
        if ((r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * VectorLength2(lightcolorbase) + (r_shadow_rtlight->specularscale * rsurface_texture->specularscale) * VectorLength2(lightcolorbase) < (1.0f / 1048576.0f))
                return;
        if ((rsurface_texture->textureflags & Q3TEXTUREFLAG_TWOSIDED) || (rsurface_entity->flags & RENDER_NOCULLFACE))
-               qglDisable(GL_CULL_FACE);
+       {
+               qglDisable(GL_CULL_FACE);CHECKGLERROR
+       }
        else
-               qglEnable(GL_CULL_FACE);
+       {
+               qglEnable(GL_CULL_FACE);CHECKGLERROR
+       }
        if (rsurface_texture->colormapping)
        {
                qboolean dopants = rsurface_texture->skin.pants != NULL && VectorLength2(rsurface_entity->colormap_pantscolor) >= (1.0f / 1048576.0f);
@@ -2159,6 +2192,7 @@ void R_Shadow_DrawEntityShadow(entity_render_t *ent, int numsurfaces, int *surfa
                {
                        shadowmesh_t *mesh;
                        R_Mesh_Matrix(&ent->matrix);
+                       CHECKGLERROR
                        for (mesh = r_shadow_rtlight->static_meshchain_shadow;mesh;mesh = mesh->next)
                        {
                                renderstats.lights_shadowtriangles += mesh->numtriangles;
@@ -2167,16 +2201,17 @@ void R_Shadow_DrawEntityShadow(entity_render_t *ent, int numsurfaces, int *surfa
                                if (r_shadow_rendermode == R_SHADOW_RENDERMODE_STENCIL)
                                {
                                        // decrement stencil if backface is behind depthbuffer
-                                       qglCullFace(GL_BACK); // quake is backwards, this culls front faces
-                                       qglStencilOp(GL_KEEP, GL_DECR, GL_KEEP);
+                                       qglCullFace(GL_BACK);CHECKGLERROR // quake is backwards, this culls front faces
+                                       qglStencilOp(GL_KEEP, GL_DECR, GL_KEEP);CHECKGLERROR
                                        R_Mesh_Draw(0, mesh->numverts, mesh->numtriangles, mesh->element3i);
                                        // increment stencil if frontface is behind depthbuffer
-                                       qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
-                                       qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP);
+                                       qglCullFace(GL_FRONT);CHECKGLERROR // quake is backwards, this culls back faces
+                                       qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP);CHECKGLERROR
                                }
                                R_Mesh_Draw(0, mesh->numverts, mesh->numtriangles, mesh->element3i);
                                GL_LockArrays(0, 0);
                        }
+                       CHECKGLERROR
                }
                else if (numsurfaces)
                {
diff --git a/todo b/todo
index 050dd96..bb7e280 100644 (file)
--- a/todo
+++ b/todo
@@ -7,21 +7,18 @@
 -d (Gleeb) feature darkplaces server: add sv_playerphysicsqc cvar to allow engine to ignore SV_PlayerPhysics function, this would also have to change the reported extensions (Gleeb)
 -d (HellToupee) feature darkplaces client: add a dot crosshair texture (HellToupee)
 -d (Joel Murdoch) change darkplaces client: add a swinging weapon motion to replace the removed forward/back movement of the weapon, should be controllable with cl_bob_* cvars (Joel Murdoch)
--d (Kedhrin) bug dpmod: air control doesn't seem to be working (Kedhrin)
 -d (Kinn) bug darkplaces WGL client: default WGL input back to GDI, the DirectInput driver is malfunctioning, losing key release messages, stuttering mouse input, and lacks mouse wheel support (Wazat, Kinn)
 -d (Mabus) bug darkplaces loading: test zlib support with entirely pk3'd id1 data (should crash because of zlib not being setup early enough - fix this) (Mabus)
 -d (Mitchell) bug darkplaces renderer: fix fogging in realtime lighting mode, need to split the shaders into two stages, this will also fix decal bugs with fog (Mitchell)
 -d (Morphed) bug darkplaces renderer: Morphed's colormapping experiments in nexuiz show a difference in gloss color with GLSL vs dot3 path, http://img494.imageshack.us/img494/8745/nexuiz0000258lf.jpg http://www.nexuiz.com/forums/index.php?showtopic=1531 - and apparently it looks right or wrong depending on view point, suddenly switching (Morphed)
 -d (Mr Fribbles) feature darkplaces particles: reimplement quake effects for a cl_particles_quake mode (Mr Fribbles, metlslime)
 -d (QuakeMatt) change darkplaces menu: remove gl_combine from menu as it's not saved to config and really shouldn't be changed except when debugging drivers (QuakeMatt)
+-d (Sajt) bug darkplaces collision: frikbots are falling through the map (Sajt)
 -d (Speedy) feature darkplaces init: add -demolooponly option which makes escape key quit, and disables all other keys (Speedy)
 -d (Spike) change darkplaces prvm: disable the unknown opcode error in progs loading so that fteqcc fastarrays progs will load (Spike)
--d (Supa, Wazat, SavageX, Vermeulen, Spike) feature darkplaces server: make a DP_SV_CUSTOMIZEENTITYFORCLIENT extension which calls a .float customizeentityforclient() function for each client that may see the entity, the function returns TRUE if it should send, FALSE if it should not, and is fully capable of editing the entity's fields, this allows cloaked players to appear less transparent to their teammates, navigation markers to only show to their team, etc (Urre, Supa, Wazat, SavageX, Vermeulen, Spike)
+-d (Supa, Wazat, Spike) feature darkplaces server: make a DP_SV_CUSTOMIZEENTITYFORCLIENT extension which calls a .float customizeentityforclient() function for each client that may see the entity, the function returns TRUE if it should send, FALSE if it should not, and is fully capable of editing the entity's fields, this allows cloaked players to appear less transparent to their teammates, navigation markers to only show to their team, etc (Urre, Supa, Wazat, SavageX, Vermeulen, Spike)
 -d (Toddd) bug darkplaces client: fix gl_flashblend, it's still drawing rtdlights even when gl_flashblend is on (Toddd)
--d (Vermeulen) bug darkplaces physics: q3bsp collisions are still glitchy, particularly gunshots hitting thin air near brushes, even with mod_q3bsp_optimizedtraceline 0, test in dpdm2r by shooting down through gaps in the architecture around the top platform (Vermeulen)
--d (Vermeulen) bug darkplaces protocol: sometimes players are invisible in nexuiz, showing only their gun model, this may be related to svc_precache messages not being sent during signon (Vermeulen)
 -d (Wazat) bug darkplaces renderer: make sure that unlit maps show up fullbright (Wazat)
--d (div0, SavageX) bug darkplaces server: sv_jumpstep should be defaulted to off because it makes it possible to reach places one should not be able to reach in quake, it can be turned on by particular games if desired (div0, SavageX, Kazashi)
 -d (evilfrog) bug darkplaces server: error() qc builtin does not print error message, just Host_Error: Program error or something similar (evilfrog)
 -d (flum) bug darkplaces client: corona on your own muzzleflash is annoying when looking down because it can be seen, disable corona on all muzzleflashes (flum)
 -d (hyenur) change dpmod: make cells only 30 damage, they're too powerful now (hyenur)
 -d (mashakos) bug darkplaces input: fix the mouse move when console is raised in glx, probably by ignoring the first move after console raise (mashakos)
 -d (mrinsane) bug darkplaces renderer: r_wateralpha 1 water that has lightmapping is black in r_shadow_realtime_world 1 mode, but only if the map was loaded in r_shadow_realtime_world 1 mode, if started in 0 and then going to 1 it does not have black water, this is probably lightmap updates not occurring in rtworld mode (mrinsane)
 -d (romi) bug darkplaces client: cl.sfx sounds aren't playing (romi)
+-d (steven a) bug darkplaces server: Blood Mage monsters are stuck in place apparently (steven a)
 -d (yummyluv) feature darkplaces protocol: add EF_DOUBLESIDED for double sided entity rendering (disable cull face for this entity) (yummyluv)
 -d (yummyluv) feature darkplaces protocol: add buttons 9-16 (yummyluv)
 -f (James D) bug darkplaces server: losing runes on episode completion, completing episode 1 then 2 then 3 causes it to forget 1, then 4 causes it to forget 2 and 3, making it impossible to open the boss gate (James D)
 -f (Wazat) bug darkplaces: client's slowmo detection (measuring packet times and comparing to game time changes) may be making the game unpleasant (Wazat)
 0 bug darkplaces client: GAME_NEHAHRA: make sure cutscenes and movies work, got a report of seeing a black screen (NightFright)
 0 bug darkplaces client: fix cl_bobmodel bug which momentarily jolts the gun when you pass through a trigger, pick up an item, etc, Sajt thinks this is related to console prints as well as centerprint (Sajt)
-0 bug darkplaces collision: frikbots are falling through the map (Sajt)
 0 bug darkplaces csqc: after the drawqueue was eliminated, the CSQC probably can't draw 2D polygons the same way, so it may need fixing ([515])
 0 bug darkplaces csqc: engine-based rocket entities have a trail but they don't glow if csqc is used
 0 bug darkplaces loader: make rtlight entity loader support q3map/q3map2 lights properly, they use a spawnflag for LINEAR mode, by default they use 1/(x*x) falloff (Carni, motorsep)
@@ -51,9 +48,9 @@
 0 bug darkplaces renderer: r_wateralpha 0.9 is invisible on r_glsl 0;gl_combine 0 path (Lardarse]
 0 bug darkplaces renderer: r_wateralpha on maps that are not watervised shows sky, this is a known glquake bug but it is fixable in darkplaces at load time by marking opposite-content (water-empty, empty-water) leafs as visible in their pvs sets, this involves checking the portal flow...  (knghtbrd)
 0 bug darkplaces renderer: showfps values 2 and 3 are printing bogus numbers like -2 billion (Willis)
-0 bug darkplaces server: Blood Mage monsters are stuck in place apparently (steven a)
 0 bug darkplaces server: SV_PushMove is ignoring model type in its angles_x handling, where as the renderer checks only model type to determine angles_x handling (Urre)
 0 bug darkplaces server: SV_PushMove's call to SV_ClipMoveToEntity should do a trace, not just a point test, to support hollow pusher models (Urre)
+0 bug darkplaces server: if sv_fixedframeratesingleplayer is 0 and cl_maxfps is something like 10, the server still runs every frame, consuming massive amounts of cpu and resulting in very small frametime values
 0 bug darkplaces server: the lava+func_trains room of r1m5 is leaving items floating in the air - r1m5 is Towers of Wrath, in episode of Dissolution of Eternity, aka rogue (maichal)
 0 bug darkplaces video: generate 1024 color gamma ramps for glx on Quadro, right now hardware gamma is being disabled on these cards because they use 1024 color ramps, not 256 (div0)
 0 bug darkplaces wgl client: during video mode setup, sometimes another application's window becomes permanently top most, not darkplaces' fullscreen window, why? (tZork)
@@ -92,6 +89,7 @@
 0 change darkplaces networking: make darkplaces detect its *public* client port from master server and send that in nq connect messages (wallace)
 0 change darkplaces protocol: PRYDON_CLIENTCURSOR should use a stat and .prydoncursor field instead of the cl_prydoncursor cvar, because stuffcmd is a bit icky (FrikaC)
 0 change darkplaces protocol: use q3 print "print message" command packet instead of qw print 'nmessage' command packet? (div0, KadaverJack)
+0 change darkplaces prvm: prvm_globals should print values of globals like entity fields do, not just names
 0 change darkplaces renderer: get rid of DSDT texture support in texture manager, it was only used for the geforce3 water shader which has been removed
 0 change darkplaces renderer: remove GL_NV_texture_shader detection
 0 change darkplaces renderer: rename r_drawportals to r_showportals, and move its declaration to gl_rmain.c
 0 feature darkplaces website: add q1source.zip to downloads page and suggest that mingw/Dev-C++ users may need the dx headers from it (cpuforbrain)
 0 feature darkplaces: .vis files - like .lit but replacement vis data, note this also requires .leaf files (knghtbrd)
 0 feature dpmaster: don't filter by protocol version if query is for protocol version 0, this way server browsers can see multiple versions of a single game, should probably also add a 'any' gamename that disables gamename filtering (Angst, Elric)
+0 feature dpmaster: release an example /etc/init.d/dpdmasterd script based on the one LordHavoc is using
 0 feature dpmod: add a g_spawnprotectiontime cvar which would default to 1 (invulnerable for 1 second after spawn) to prevent mining the spawn points
 0 feature dpmod: add a summon command using KRIMZON_SV_PARSECLIENTCOMMAND which would summon the specified monster infront of you (Kedhrin)
 0 feature dpmod: add higher quality replacement sbar images
 2 feature hmap2: add .hlwad and .hlw support to hqbsp (convert to quake palette, and check for colormap.lmp to see how many fullbrights are involved, also add -fullbrights option to control this) (Todd, FrikaC)
 2 optimization darkplaces collision: do trace against patch bbox before testing triangles
 2 optimization darkplaces renderer: move skybox/skysphere render to after sky polygons, so that they can do a depth comparison to draw only on the sky polygons, using DepthRange(1,1) and DepthFunc(GL_GREATER), note though that portal renders will need half depth range (Mercury)
-3 bug darkplaces client: make "wait" command wait for next network frame somehow when connected, to make frikbot .way files load properly (Nexuiz, Transfusion, FrikaC)
 3 bug darkplaces collision: add edge bevels in collision code, by trying all crossproduct combinations of an edge with planes from the other brush, and choosing only the ones which are valid
 3 bug darkplaces compatibility: quakerally does not work, figure out why (Spike)
 3 bug darkplaces compatibility: targetquake does not work, figure out why
@@ -485,6 +483,7 @@ d bug darkplaces client: disable vsync when doing a timedemo (Randy)
 d bug darkplaces client: do replay cl_movement queue each time a move is added, as this is called from the server packet parser, which can overwhelm the client with several packets in one frame, leading to a complete lockup until the level changes (Black)
 d bug darkplaces client: figure out why multimap demos are skipping the later portions, it's probably related to the time seeking, probably not being reset (Urre)
 d bug darkplaces client: finale text during episode-end intermissions shows briefly in its entirety and all as one line (going off the screen), then disappears and begins typing slowly as it should (Sajt)
+d bug darkplaces client: make "wait" command wait fornext network frame somehow when connected, to make frikbot .way files load properly (Transfusion, FrikaC)
 d bug darkplaces client: make envmap command work with the corrected layout
 d bug darkplaces client: make server queries use a queue to avoid flooding out queries too fast (Willis)
 d bug darkplaces client: missing bolt/beam models should not produce warnings
@@ -515,6 +514,7 @@ d bug darkplaces model: don't Host_Error when a model is unknown/unsupported typ
 d bug darkplaces model: ignore attempts to load "" (SavageX, Vermeulen)
 d bug darkplaces particles: cl_particles_quality is affecting lifetime of decals, it should not
 d bug darkplaces physics: corpses/gibs are not riding down e1m1 lift (scar3crow)
+d bug darkplaces physics: q3bsp collisions are still glitchy, particularly gunshots hitting thin air near brushes, even with mod_q3bsp_optimizedtraceline 0, test in dpdm2r by shooting down through gaps in the architecture around the top platform (Vermeulen)
 d bug darkplaces physics: test TecnoX and find the frikbot crash in SV_Physics (KrimZon)
 d bug darkplaces physics: the zombie lift in e3m2 before the gold key is not working (scar3crow)
 d bug darkplaces protocol: fix cl_nodelta 1, it's halting updates after you move away from an area (Tomaz, sublim3)
@@ -523,6 +523,7 @@ d bug darkplaces protocol: getting packetlog overflow warnings again, but WHY? (
 d bug darkplaces protocol: it's possible to get a "received signon 1 when at 1" error in singleplayer when restarting level, perhaps this relates to very low framerate
 d bug darkplaces protocol: models sometimes staying in nexuiz after a big battle, entities that don't exist on the server anymore (Spike)
 d bug darkplaces protocol: something is causing things like tracers to sometimes stay indefinitely (Vermeulen)
+d bug darkplaces protocol: sometimes players are invisible in nexuiz, showing only their gun model, this may be related to svc_precache messages not being sent during signon (Vermeulen)
 d bug darkplaces prvm: assignment to world is not producing an error after world spawn stage (Spike)
 d bug darkplaces prvm: findchain/findchainfloat are corrupting things when trying to write to the .chain field (Kedhrin)
 d bug darkplaces prvm: findflags/findchainflags are server-specific, these should be moved into the generic progs commands
@@ -578,8 +579,10 @@ d bug darkplaces server: projectiles spawned during client physics called by SV_
 d bug darkplaces server: running only one server frame per host frame is really bad in listen servers where the client may be too slow to keep up the server framerate
 d bug darkplaces server: sending unused lightstyles in serverinfo packet is silly (Spike)
 d bug darkplaces server: stepping while jumping is setting FL_GROUND (allowing the quake2 doublejump bug)
+d bug darkplaces server: sv_jumpstep should be defaulted to off because it makes it possible to reach places one should not be able to reach in quake, it can be turned on by particular games if desired (div0, SavageX, Kazashi)
 d bug darkplaces server: when trying to load a map that is missing the model is still precached permanently, causing 'not found' warnings every time r_restart/vid_restart are used
 d bug darkplaces sound: spatialization bug occurs in The Ascension of Vigil, making all player and monster sounds far to the right (RenegadeC)
+d bug dpmod: air control doesn't seem to be working (Kedhrin)
 d bug dpmod: fix the 'shell casing spawning at wrong player' bug somehow
 d bug dpmod: items aren't respawning in coop, they should
 d bug dpmod: shouldn't get double kill for killing something and its corpse (Sajt)
index d881887..6823840 100644 (file)
--- a/vid_agl.c
+++ b/vid_agl.c
@@ -136,8 +136,11 @@ void VID_Finish (qboolean allowmousegrab)
 
        if (r_render.integer)
        {
+               CHECKGLERROR
                if (r_speeds.integer || gl_finish.integer)
-                       qglFinish();
+               {
+                       qglFinish();CHECKGLERROR
+               }
                qaglSwapBuffers(context);
        }
        VID_UpdateGamma(false, GAMMA_TABLE_SIZE);
index 1dd9e1b..17a6f70 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -585,9 +585,12 @@ void VID_Finish (qboolean allowmousegrab)
 
        if (r_render.integer)
        {
+               CHECKGLERROR
                if (r_speeds.integer || gl_finish.integer)
-                       qglFinish();
-               qglXSwapBuffers(vidx11_display, win);
+               {
+                       qglFinish();CHECKGLERROR
+               }
+               qglXSwapBuffers(vidx11_display, win);CHECKGLERROR
        }
 
        if (vid_x11_hardwaregammasupported)
index b96a359..c01973c 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -488,8 +488,11 @@ void VID_Finish (qboolean allowmousegrab)
        Uint8 appstate;
        qboolean vid_usemouse;
 
+       CHECKGLERROR
        if (r_speeds.integer || gl_finish.integer)
-               qglFinish();
+       {
+               qglFinish();CHECKGLERROR
+       }
        SDL_GL_SwapBuffers();
 
        //react on appstate changes
index 5a66af8..77d510b 100644 (file)
@@ -643,6 +643,7 @@ void VID_CheckExtensions(void)
        Con_Printf("GL_EXTENSIONS: %s\n", gl_extensions);
        Con_Printf("%s_EXTENSIONS: %s\n", gl_platform, gl_platformextensions);
 
+       CHECKGLERROR
        qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max_texture_size);
 
        Con_Print("Checking OpenGL extensions...\n");
@@ -692,6 +693,7 @@ void VID_CheckExtensions(void)
                if ((gl_support_shading_language_100 = GL_CheckExtension("GL_ARB_shading_language_100", NULL, "-noshadinglanguage100", false)))
                        if ((gl_support_vertex_shader = GL_CheckExtension("GL_ARB_vertex_shader", vertexshaderfuncs, "-novertexshader", false)))
                                gl_support_fragment_shader = GL_CheckExtension("GL_ARB_fragment_shader", NULL, "-nofragmentshader", false);
+       CHECKGLERROR
 }
 
 void Force_CenterView_f (void)
index a567a84..c52d0d9 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -285,8 +285,11 @@ void VID_Finish (qboolean allowmousegrab)
 
        if (r_render.integer && !vid_hidden)
        {
+               CHECKGLERROR
                if (r_speeds.integer || gl_finish.integer)
-                       qglFinish();
+               {
+                       qglFinish();CHECKGLERROR
+               }
                SwapBuffers(baseDC);
        }