]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_backend.c
removed \n from all Host_Error, Sys_Error, PRVM_ERROR, PF_ERROR calls, since Host_Err...
[xonotic/darkplaces.git] / gl_backend.c
index d56bc790671244933ba5a94e2aa94cf0fa6e9181..320e7e73cfdd4deb24347bbd17a77b8928fa2931 100644 (file)
@@ -73,7 +73,7 @@ void GL_PrintError(int errornumber, char *filename, int linenumber)
 }
 #endif
 
-#define BACKENDACTIVECHECK if (!backendactive) Sys_Error("GL backend function called when backend is not active\n");
+#define BACKENDACTIVECHECK if (!backendactive) Sys_Error("GL backend function called when backend is not active");
 
 void SCR_ScreenShot_f (void);
 
@@ -174,9 +174,9 @@ static void gl_backend_start(void)
        if (gl_support_fragment_shader)
        {
                CHECKGLERROR
-               qglGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &backendimageunits);
+               qglGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, (int *)&backendimageunits);
                CHECKGLERROR
-               qglGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &backendarrayunits);
+               qglGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, (int *)&backendarrayunits);
                CHECKGLERROR
                Con_Printf("GLSL shader support detected: texture units = %i texenv, %i image, %i array\n", backendunits, backendimageunits, backendarrayunits);
        }
@@ -407,7 +407,7 @@ typedef struct gltextureunit_s
 }
 gltextureunit_t;
 
-static struct
+static struct gl_state_s
 {
        int blendfunc1;
        int blendfunc2;
@@ -432,8 +432,8 @@ void GL_SetupTextureState(void)
        unsigned int i;
        gltextureunit_t *unit;
        CHECKGLERROR
-       gl_state.unit = -1;
-       gl_state.clientunit = -1;
+       gl_state.unit = MAX_TEXTUREUNITS;
+       gl_state.clientunit = MAX_TEXTUREUNITS;
        for (i = 0;i < MAX_TEXTUREUNITS;i++)
        {
                unit = gl_state.units + i;
@@ -709,7 +709,7 @@ void GL_LockArrays(int first, int count)
 void GL_Scissor (int x, int y, int width, int height)
 {
        CHECKGLERROR
-       qglScissor(x, vid.realheight - (y + height),width,height);
+       qglScissor(x, vid.height - (y + height),width,height);
        CHECKGLERROR
 }
 
@@ -886,8 +886,8 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int numtriangles, const int *
                R_Mesh_Draw_ShowTris(firstvertex, numvertices, numtriangles, elements);
                return;
        }
-       c_meshs++;
-       c_meshelements += numelements;
+       renderstats.meshes++;
+       renderstats.meshes_elements += numelements;
        if (gl_paranoid.integer)
        {
                unsigned int i, j, size;
@@ -1102,6 +1102,8 @@ void R_Mesh_VertexPointer(const float *vertex3f)
 
 void R_Mesh_ColorPointer(const float *color4f)
 {
+       if (r_showtrispass)
+               return;
        if (gl_state.pointer_color != color4f)
        {
                CHECKGLERROR
@@ -1127,6 +1129,8 @@ void R_Mesh_ColorPointer(const float *color4f)
 void R_Mesh_TexCoordPointer(unsigned int unitnum, unsigned int numcomponents, const float *texcoord)
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
+       if (r_showtrispass)
+               return;
        // update array settings
        if (texcoord)
        {
@@ -1162,7 +1166,9 @@ void R_Mesh_TexCoordPointer(unsigned int unitnum, unsigned int numcomponents, co
 void R_Mesh_TexBindAll(unsigned int unitnum, int tex1d, int tex2d, int tex3d, int texcubemap)
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
-       if (unitnum >= backendunits)
+       if (unitnum >= backendimageunits)
+               return;
+       if (r_showtrispass)
                return;
        // update 1d texture binding
        if (unit->t1d != tex1d)
@@ -1253,21 +1259,26 @@ void R_Mesh_TexBindAll(unsigned int unitnum, int tex1d, int tex2d, int tex3d, in
 void R_Mesh_TexBind1D(unsigned int unitnum, int texnum)
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
-       if (unitnum >= backendunits)
+       if (unitnum >= backendimageunits)
+               return;
+       if (r_showtrispass)
                return;
        // update 1d texture binding
        if (unit->t1d != texnum)
        {
                GL_ActiveTexture(unitnum);
-               if (texnum)
-               {
-                       if (unit->t1d == 0)
-                               qglEnable(GL_TEXTURE_1D);
-               }
-               else
+               if (unitnum < backendunits)
                {
-                       if (unit->t1d)
-                               qglDisable(GL_TEXTURE_1D);
+                       if (texnum)
+                       {
+                               if (unit->t1d == 0)
+                                       qglEnable(GL_TEXTURE_1D);
+                       }
+                       else
+                       {
+                               if (unit->t1d)
+                                       qglDisable(GL_TEXTURE_1D);
+                       }
                }
                unit->t1d = texnum;
                qglBindTexture(GL_TEXTURE_1D, unit->t1d);
@@ -1277,8 +1288,11 @@ void R_Mesh_TexBind1D(unsigned int unitnum, int texnum)
        if (unit->t2d)
        {
                GL_ActiveTexture(unitnum);
-               if (unit->t2d)
-                       qglDisable(GL_TEXTURE_2D);
+               if (unitnum < backendunits)
+               {
+                       if (unit->t2d)
+                               qglDisable(GL_TEXTURE_2D);
+               }
                unit->t2d = 0;
                qglBindTexture(GL_TEXTURE_2D, unit->t2d);
                CHECKGLERROR
@@ -1287,8 +1301,11 @@ void R_Mesh_TexBind1D(unsigned int unitnum, int texnum)
        if (unit->t3d)
        {
                GL_ActiveTexture(unitnum);
-               if (unit->t3d)
-                       qglDisable(GL_TEXTURE_3D);
+               if (unitnum < backendunits)
+               {
+                       if (unit->t3d)
+                               qglDisable(GL_TEXTURE_3D);
+               }
                unit->t3d = 0;
                qglBindTexture(GL_TEXTURE_3D, unit->t3d);
                CHECKGLERROR
@@ -1297,8 +1314,11 @@ void R_Mesh_TexBind1D(unsigned int unitnum, int texnum)
        if (unit->tcubemap)
        {
                GL_ActiveTexture(unitnum);
-               if (unit->tcubemap)
-                       qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+               if (unitnum < backendunits)
+               {
+                       if (unit->tcubemap)
+                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+               }
                unit->tcubemap = 0;
                qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);
                CHECKGLERROR
@@ -1308,14 +1328,19 @@ void R_Mesh_TexBind1D(unsigned int unitnum, int texnum)
 void R_Mesh_TexBind(unsigned int unitnum, int texnum)
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
-       if (unitnum >= backendunits)
+       if (unitnum >= backendimageunits)
+               return;
+       if (r_showtrispass)
                return;
        // update 1d texture binding
        if (unit->t1d)
        {
                GL_ActiveTexture(unitnum);
-               if (unit->t1d)
-                       qglDisable(GL_TEXTURE_1D);
+               if (unitnum < backendunits)
+               {
+                       if (unit->t1d)
+                               qglDisable(GL_TEXTURE_1D);
+               }
                unit->t1d = 0;
                qglBindTexture(GL_TEXTURE_1D, unit->t1d);
                CHECKGLERROR
@@ -1324,15 +1349,18 @@ void R_Mesh_TexBind(unsigned int unitnum, int texnum)
        if (unit->t2d != texnum)
        {
                GL_ActiveTexture(unitnum);
-               if (texnum)
-               {
-                       if (unit->t2d == 0)
-                               qglEnable(GL_TEXTURE_2D);
-               }
-               else
+               if (unitnum < backendunits)
                {
-                       if (unit->t2d)
-                               qglDisable(GL_TEXTURE_2D);
+                       if (texnum)
+                       {
+                               if (unit->t2d == 0)
+                                       qglEnable(GL_TEXTURE_2D);
+                       }
+                       else
+                       {
+                               if (unit->t2d)
+                                       qglDisable(GL_TEXTURE_2D);
+                       }
                }
                unit->t2d = texnum;
                qglBindTexture(GL_TEXTURE_2D, unit->t2d);
@@ -1342,8 +1370,11 @@ void R_Mesh_TexBind(unsigned int unitnum, int texnum)
        if (unit->t3d)
        {
                GL_ActiveTexture(unitnum);
-               if (unit->t3d)
-                       qglDisable(GL_TEXTURE_3D);
+               if (unitnum < backendunits)
+               {
+                       if (unit->t3d)
+                               qglDisable(GL_TEXTURE_3D);
+               }
                unit->t3d = 0;
                qglBindTexture(GL_TEXTURE_3D, unit->t3d);
                CHECKGLERROR
@@ -1352,8 +1383,11 @@ void R_Mesh_TexBind(unsigned int unitnum, int texnum)
        if (unit->tcubemap != 0)
        {
                GL_ActiveTexture(unitnum);
-               if (unit->tcubemap)
-                       qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+               if (unitnum < backendunits)
+               {
+                       if (unit->tcubemap)
+                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+               }
                unit->tcubemap = 0;
                qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);
                CHECKGLERROR
@@ -1363,14 +1397,19 @@ void R_Mesh_TexBind(unsigned int unitnum, int texnum)
 void R_Mesh_TexBind3D(unsigned int unitnum, int texnum)
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
-       if (unitnum >= backendunits)
+       if (unitnum >= backendimageunits)
+               return;
+       if (r_showtrispass)
                return;
        // update 1d texture binding
        if (unit->t1d)
        {
                GL_ActiveTexture(unitnum);
-               if (unit->t1d)
-                       qglDisable(GL_TEXTURE_1D);
+               if (unitnum < backendunits)
+               {
+                       if (unit->t1d)
+                               qglDisable(GL_TEXTURE_1D);
+               }
                unit->t1d = 0;
                qglBindTexture(GL_TEXTURE_1D, unit->t1d);
                CHECKGLERROR
@@ -1379,8 +1418,11 @@ void R_Mesh_TexBind3D(unsigned int unitnum, int texnum)
        if (unit->t2d)
        {
                GL_ActiveTexture(unitnum);
-               if (unit->t2d)
-                       qglDisable(GL_TEXTURE_2D);
+               if (unitnum < backendunits)
+               {
+                       if (unit->t2d)
+                               qglDisable(GL_TEXTURE_2D);
+               }
                unit->t2d = 0;
                qglBindTexture(GL_TEXTURE_2D, unit->t2d);
                CHECKGLERROR
@@ -1389,15 +1431,18 @@ void R_Mesh_TexBind3D(unsigned int unitnum, int texnum)
        if (unit->t3d != texnum)
        {
                GL_ActiveTexture(unitnum);
-               if (texnum)
-               {
-                       if (unit->t3d == 0)
-                               qglEnable(GL_TEXTURE_3D);
-               }
-               else
+               if (unitnum < backendunits)
                {
-                       if (unit->t3d)
-                               qglDisable(GL_TEXTURE_3D);
+                       if (texnum)
+                       {
+                               if (unit->t3d == 0)
+                                       qglEnable(GL_TEXTURE_3D);
+                       }
+                       else
+                       {
+                               if (unit->t3d)
+                                       qglDisable(GL_TEXTURE_3D);
+                       }
                }
                unit->t3d = texnum;
                qglBindTexture(GL_TEXTURE_3D, unit->t3d);
@@ -1407,8 +1452,11 @@ void R_Mesh_TexBind3D(unsigned int unitnum, int texnum)
        if (unit->tcubemap != 0)
        {
                GL_ActiveTexture(unitnum);
-               if (unit->tcubemap)
-                       qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+               if (unitnum < backendunits)
+               {
+                       if (unit->tcubemap)
+                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+               }
                unit->tcubemap = 0;
                qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);
                CHECKGLERROR
@@ -1418,14 +1466,19 @@ void R_Mesh_TexBind3D(unsigned int unitnum, int texnum)
 void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum)
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
-       if (unitnum >= backendunits)
+       if (unitnum >= backendimageunits)
+               return;
+       if (r_showtrispass)
                return;
        // update 1d texture binding
        if (unit->t1d)
        {
                GL_ActiveTexture(unitnum);
-               if (unit->t1d)
-                       qglDisable(GL_TEXTURE_1D);
+               if (unitnum < backendunits)
+               {
+                       if (unit->t1d)
+                               qglDisable(GL_TEXTURE_1D);
+               }
                unit->t1d = 0;
                qglBindTexture(GL_TEXTURE_1D, unit->t1d);
                CHECKGLERROR
@@ -1434,8 +1487,11 @@ void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum)
        if (unit->t2d)
        {
                GL_ActiveTexture(unitnum);
-               if (unit->t2d)
-                       qglDisable(GL_TEXTURE_2D);
+               if (unitnum < backendunits)
+               {
+                       if (unit->t2d)
+                               qglDisable(GL_TEXTURE_2D);
+               }
                unit->t2d = 0;
                qglBindTexture(GL_TEXTURE_2D, unit->t2d);
                CHECKGLERROR
@@ -1444,8 +1500,11 @@ void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum)
        if (unit->t3d)
        {
                GL_ActiveTexture(unitnum);
-               if (unit->t3d)
-                       qglDisable(GL_TEXTURE_3D);
+               if (unitnum < backendunits)
+               {
+                       if (unit->t3d)
+                               qglDisable(GL_TEXTURE_3D);
+               }
                unit->t3d = 0;
                qglBindTexture(GL_TEXTURE_3D, unit->t3d);
                CHECKGLERROR
@@ -1454,15 +1513,18 @@ void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum)
        if (unit->tcubemap != texnum)
        {
                GL_ActiveTexture(unitnum);
-               if (texnum)
-               {
-                       if (unit->tcubemap == 0)
-                               qglEnable(GL_TEXTURE_CUBE_MAP_ARB);
-               }
-               else
+               if (unitnum < backendunits)
                {
-                       if (unit->tcubemap)
-                               qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+                       if (texnum)
+                       {
+                               if (unit->tcubemap == 0)
+                                       qglEnable(GL_TEXTURE_CUBE_MAP_ARB);
+                       }
+                       else
+                       {
+                               if (unit->tcubemap)
+                                       qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
+                       }
                }
                unit->tcubemap = texnum;
                qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);
@@ -1473,6 +1535,8 @@ void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum)
 void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix)
 {
        gltextureunit_t *unit = gl_state.units + unitnum;
+       if (r_showtrispass)
+               return;
        if (matrix->m[3][3])
        {
                // texmatrix specified, check if it is different
@@ -1505,6 +1569,8 @@ 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;
+       if (r_showtrispass)
+               return;
        if (gl_combine.integer)
        {
                // GL_ARB_texture_env_combine
@@ -1560,10 +1626,6 @@ void R_Mesh_State(const rmeshstate_t *m)
        BACKENDACTIVECHECK
 
        R_Mesh_VertexPointer(m->pointer_vertex);
-
-       if (r_showtrispass)
-               return;
-
        R_Mesh_ColorPointer(m->pointer_color);
 
        if (gl_backend_rebindtextures)
@@ -1609,7 +1671,7 @@ void R_Mesh_Draw_ShowTris(int firstvertex, int numvertices, int numtriangles, co
 ==============================================================================
 */
 
-qboolean SCR_ScreenShot(char *filename, qbyte *buffer1, qbyte *buffer2, qbyte *buffer3, int x, int y, int width, int height, qboolean flipx, qboolean flipy, qboolean flipdiagonal, qboolean jpeg)
+qboolean SCR_ScreenShot(char *filename, unsigned char *buffer1, unsigned char *buffer2, unsigned char *buffer3, int x, int y, int width, int height, qboolean flipx, qboolean flipy, qboolean flipdiagonal, qboolean jpeg, qboolean gammacorrect)
 {
        int     indices[3] = {0,1,2};
        qboolean ret;
@@ -1620,7 +1682,7 @@ qboolean SCR_ScreenShot(char *filename, qbyte *buffer1, qbyte *buffer2, qbyte *b
        qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer1);
        CHECKGLERROR
 
-       if (scr_screenshot_gamma.value != 1)
+       if (scr_screenshot_gamma.value != 1 && gammacorrect)
        {
                int i;
                double igamma = 1.0 / scr_screenshot_gamma.value;
@@ -1648,7 +1710,11 @@ void R_ClearScreen(void)
        if (r_render.integer)
        {
                // clear to black
-               qglClearColor(0,0,0,0);CHECKGLERROR
+               if (fogenabled)
+                       qglClearColor(fogcolor[0],fogcolor[1],fogcolor[2],0);
+               else
+                       qglClearColor(0,0,0,0);
+               CHECKGLERROR
                qglClearDepth(1);CHECKGLERROR
                if (gl_stencil)
                {
@@ -1701,6 +1767,7 @@ void SCR_DrawScreen (void)
                        GL_DepthMask(GL_FALSE);
                        memset(&m, 0, sizeof(m));
                        R_Mesh_State(&m);
+                       //qglEnable(GL_LINE_SMOOTH);
                        GL_ShowTrisColor(0.2,0.2,0.2,1);
                        r_showtrispass = 1;
                }
@@ -1714,19 +1781,19 @@ void SCR_DrawScreen (void)
 
                        if (r_stereo_sidebyside.integer)
                        {
-                               r_refdef.width = vid.realwidth * size / 2.5;
-                               r_refdef.height = vid.realheight * size / 2.5 * (1 - bound(0, r_letterbox.value, 100) / 100);
-                               r_refdef.x = (vid.realwidth - r_refdef.width * 2.5) * 0.5;
-                               r_refdef.y = (vid.realheight - r_refdef.height)/2;
+                               r_refdef.width = vid.width * size / 2.5;
+                               r_refdef.height = vid.height * size / 2.5 * (1 - bound(0, r_letterbox.value, 100) / 100);
+                               r_refdef.x = (vid.width - r_refdef.width * 2.5) * 0.5;
+                               r_refdef.y = (vid.height - r_refdef.height)/2;
                                if (r_stereo_side)
                                        r_refdef.x += r_refdef.width * 1.5;
                        }
                        else
                        {
-                               r_refdef.width = vid.realwidth * size;
-                               r_refdef.height = vid.realheight * size * (1 - bound(0, r_letterbox.value, 100) / 100);
-                               r_refdef.x = (vid.realwidth - r_refdef.width)/2;
-                               r_refdef.y = (vid.realheight - r_refdef.height)/2;
+                               r_refdef.width = vid.width * size;
+                               r_refdef.height = vid.height * size * (1 - bound(0, r_letterbox.value, 100) / 100);
+                               r_refdef.x = (vid.width - r_refdef.width)/2;
+                               r_refdef.y = (vid.height - r_refdef.height)/2;
                        }
 
                        // LordHavoc: viewzoom (zoom in for sniper rifles, etc)
@@ -1739,9 +1806,9 @@ void SCR_DrawScreen (void)
                        {
                                float sizex = bound(10, scr_zoomwindow_viewsizex.value, 100) / 100.0;
                                float sizey = bound(10, scr_zoomwindow_viewsizey.value, 100) / 100.0;
-                               r_refdef.width = vid.realwidth * sizex;
-                               r_refdef.height = vid.realheight * sizey;
-                               r_refdef.x = (vid.realwidth - r_refdef.width)/2;
+                               r_refdef.width = vid.width * sizex;
+                               r_refdef.height = vid.height * sizey;
+                               r_refdef.x = (vid.width - r_refdef.width)/2;
                                r_refdef.y = 0;
                                r_refdef.fov_x = scr_zoomwindow_fov.value * r_refdef.fovscale_x;
                                r_refdef.fov_y = CalcFov(scr_zoomwindow_fov.value, r_refdef.width, r_refdef.height) * r_refdef.fovscale_y;
@@ -1752,8 +1819,8 @@ void SCR_DrawScreen (void)
 
                if (!r_stereo_sidebyside.integer)
                {
-                       r_refdef.width = vid.realwidth;
-                       r_refdef.height = vid.realheight;
+                       r_refdef.width = vid.width;
+                       r_refdef.height = vid.height;
                        r_refdef.x = 0;
                        r_refdef.y = 0;
                }
@@ -1766,6 +1833,7 @@ void SCR_DrawScreen (void)
                R_TimeReport("meshfinish");
        }
        r_showtrispass = 0;
+       //qglDisable(GL_LINE_SMOOTH);
 }
 
 void SCR_UpdateLoadingScreen (void)
@@ -1777,9 +1845,8 @@ void SCR_UpdateLoadingScreen (void)
        if (vid_hidden)
                return;
        r_showtrispass = 0;
-       VID_GetWindowSize(&vid.realx, &vid.realy, &vid.realwidth, &vid.realheight);
        VID_UpdateGamma(false);
-       qglViewport(0, 0, vid.realwidth, vid.realheight);
+       qglViewport(0, 0, vid.width, vid.height);
        //qglDisable(GL_SCISSOR_TEST);
        //qglDepthMask(1);
        qglColorMask(1,1,1,1);
@@ -1793,7 +1860,7 @@ void SCR_UpdateLoadingScreen (void)
        R_Mesh_Start();
        R_Mesh_Matrix(&r_identitymatrix);
        // draw the loading plaque
-       pic = Draw_CachePic("gfx/loading.lmp", false);
+       pic = Draw_CachePic("gfx/loading", false);
        x = (vid_conwidth.integer - pic->width)/2;
        y = (vid_conheight.integer - pic->height)/2;
        GL_Color(1,1,1,1);
@@ -1838,11 +1905,11 @@ void SCR_UpdateScreen (void)
        if (r_textureunits.integer < 1)
                Cvar_SetValueQuick(&r_textureunits, 1);
 
-       if (gl_combine.integer && (!gl_combine_extension || r_textureunits.integer < 2))
+       if (gl_combine.integer && !gl_combine_extension)
                Cvar_SetValueQuick(&gl_combine, 0);
 
        CHECKGLERROR
-       qglViewport(0, 0, vid.realwidth, vid.realheight);
+       qglViewport(0, 0, vid.width, vid.height);
        qglDisable(GL_SCISSOR_TEST);
        qglDepthMask(1);
        qglColorMask(1,1,1,1);
@@ -1972,7 +2039,7 @@ static rcachearrayitem_t r_mesh_rcacheitems[RCACHEARRAY_ITEMS];
 // size of data buffer
 static int r_mesh_rcachedata_size = RCACHEARRAY_DEFAULTSIZE;
 // data buffer
-static qbyte r_mesh_rcachedata[RCACHEARRAY_DEFAULTSIZE];
+static unsigned char r_mesh_rcachedata[RCACHEARRAY_DEFAULTSIZE];
 
 // current state
 static int r_mesh_rcachedata_offset;
@@ -2033,7 +2100,7 @@ int R_Mesh_CacheArray(rcachearrayrequest_t *r)
        //R_Mesh_CacheArray_ValidateState(3);
        // calculate a hashindex to choose a cache chain
        r->data = NULL;
-       hashindex = CRC_Block((void *)r, sizeof(*r)) % RCACHEARRAY_HASHSIZE;
+       hashindex = CRC_Block((unsigned char *)r, sizeof(*r)) % RCACHEARRAY_HASHSIZE;
 
        // is it already cached?
        for (lhead = &r_mesh_rcachechain[hashindex], l = lhead->next;l != lhead;l = l->next)