renamed polygonelements, skyboxelements, skysphereelements, to add 3s
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 6 Nov 2009 12:49:09 +0000 (12:49 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 6 Nov 2009 12:49:09 +0000 (12:49 +0000)
and 3i versions of each, since most processing functions need 3i

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

cl_screen.c
clvm_cmds.c
draw.h
gl_backend.c
gl_backend.h
gl_draw.c
gl_rmain.c
gl_rsurf.c
r_shadow.c
r_sky.c

index e7a6e2a..ab1d4f2 100644 (file)
@@ -1812,7 +1812,7 @@ static void SCR_DrawLoadingStack(void)
                        //                                        ^^^^^^^^^^ blue component
                        //                              ^^^^^^ bottom row
                        //          ^^^^^^^^^^^^ alpha is always on
-               R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
 
                // make sure everything is cleared, including the progress indicator
                if(loadingscreenheight < 8)
@@ -1875,13 +1875,13 @@ static void SCR_DrawLoadingScreen (qboolean clear)
                R_Mesh_ResetTextureState();
                R_Mesh_TexBind(0, R_GetTexture(loadingscreentexture));
                R_Mesh_TexCoordPointer(0, 2, loadingscreentexture_texcoord2f, 0, 0);
-               R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
        }
        R_Mesh_VertexPointer(loadingscreenpic_vertex3f, 0, 0);
        R_Mesh_ResetTextureState();
        R_Mesh_TexBind(0, R_GetTexture(loadingscreenpic->tex));
        R_Mesh_TexCoordPointer(0, 2, loadingscreenpic_texcoord2f, 0, 0);
-       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+       R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
        SCR_DrawLoadingStack();
 }
 
index e7ec435..71cbb33 100644 (file)
@@ -3078,7 +3078,8 @@ void VMPolygons_Store(vmpolygons_t *polys)
                mesh.texture = polys->begin_texture;
                mesh.num_vertices = polys->begin_vertices;
                mesh.num_triangles = polys->begin_vertices-2;
-               mesh.data_element3s = polygonelements;
+               mesh.data_element3i = polygonelement3i;
+               mesh.data_element3s = polygonelement3s;
                mesh.data_vertex3f = polys->begin_vertex[0];
                mesh.data_color4f = polys->begin_color[0];
                mesh.data_texcoord2f = polys->begin_texcoord[0];
diff --git a/draw.h b/draw.h
index f0af80c..74b3c0b 100644 (file)
--- a/draw.h
+++ b/draw.h
@@ -64,6 +64,7 @@ typedef struct drawqueuemesh_s
        rtexture_t *texture;
        int num_triangles;
        int num_vertices;
+       int *data_element3i;
        unsigned short *data_element3s;
        float *data_vertex3f;
        float *data_texcoord2f;
index f41c975..955ac37 100644 (file)
@@ -143,8 +143,10 @@ for (y = 0;y < rows - 1;y++)
 }
 */
 
-unsigned short polygonelements[(POLYGONELEMENTS_MAXPOINTS-2)*3];
-unsigned short quadelements[QUADELEMENTS_MAXQUADS*6];
+int polygonelement3i[(POLYGONELEMENTS_MAXPOINTS-2)*3];
+unsigned short polygonelement3s[(POLYGONELEMENTS_MAXPOINTS-2)*3];
+int quadelement3i[QUADELEMENTS_MAXQUADS*6];
+unsigned short quadelement3s[QUADELEMENTS_MAXQUADS*6];
 
 void GL_Backend_AllocArrays(void)
 {
@@ -236,21 +238,26 @@ void gl_backend_init(void)
 
        for (i = 0;i < POLYGONELEMENTS_MAXPOINTS - 2;i++)
        {
-               polygonelements[i * 3 + 0] = 0;
-               polygonelements[i * 3 + 1] = i + 1;
-               polygonelements[i * 3 + 2] = i + 2;
+               polygonelement3s[i * 3 + 0] = 0;
+               polygonelement3s[i * 3 + 1] = i + 1;
+               polygonelement3s[i * 3 + 2] = i + 2;
        }
        // elements for rendering a series of quads as triangles
        for (i = 0;i < QUADELEMENTS_MAXQUADS;i++)
        {
-               quadelements[i * 6 + 0] = i * 4;
-               quadelements[i * 6 + 1] = i * 4 + 1;
-               quadelements[i * 6 + 2] = i * 4 + 2;
-               quadelements[i * 6 + 3] = i * 4;
-               quadelements[i * 6 + 4] = i * 4 + 2;
-               quadelements[i * 6 + 5] = i * 4 + 3;
+               quadelement3s[i * 6 + 0] = i * 4;
+               quadelement3s[i * 6 + 1] = i * 4 + 1;
+               quadelement3s[i * 6 + 2] = i * 4 + 2;
+               quadelement3s[i * 6 + 3] = i * 4;
+               quadelement3s[i * 6 + 4] = i * 4 + 2;
+               quadelement3s[i * 6 + 5] = i * 4 + 3;
        }
 
+       for (i = 0;i < (POLYGONELEMENTS_MAXPOINTS - 2)*3;i++)
+               polygonelement3i[i] = polygonelement3s[i];
+       for (i = 0;i < QUADELEMENTS_MAXQUADS*3;i++)
+               quadelement3i[i] = quadelement3s[i];
+
        Cvar_RegisterVariable(&r_render);
        Cvar_RegisterVariable(&r_renderview);
        Cvar_RegisterVariable(&r_waterwarp);
index ea9d6e6..e8113e2 100644 (file)
@@ -6,9 +6,11 @@
 #define MAX_TEXTUREUNITS 64
 
 #define POLYGONELEMENTS_MAXPOINTS 258
-extern unsigned short polygonelements[(POLYGONELEMENTS_MAXPOINTS-2)*3];
+extern int polygonelement3i[(POLYGONELEMENTS_MAXPOINTS-2)*3];
+extern unsigned short polygonelement3s[(POLYGONELEMENTS_MAXPOINTS-2)*3];
 #define QUADELEMENTS_MAXQUADS 128
-extern unsigned short quadelements[QUADELEMENTS_MAXQUADS*6];
+extern int quadelement3i[QUADELEMENTS_MAXQUADS*6];
+extern unsigned short quadelement3s[QUADELEMENTS_MAXQUADS*6];
 
 void R_Viewport_TransformToScreen(const r_viewport_t *v, const vec4_t in, vec4_t out);
 void R_Viewport_InitOrtho(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, double x1, double y1, double x2, double y2, double zNear, double zFar, const double *nearplane);
index 5f78a00..e75a97a 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -865,7 +865,7 @@ void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, flo
        floats[3] = floats[6] = x + width;
        floats[7] = floats[10] = y + height;
 
-       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+       R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
 }
 
 void DrawQ_RotPic(float x, float y, cachepic_t *pic, float width, float height, float org_x, float org_y, float angle, float red, float green, float blue, float alpha, int flags)
@@ -918,7 +918,7 @@ void DrawQ_RotPic(float x, float y, cachepic_t *pic, float width, float height,
        floats[9]  = x - cosaf*org_x + cosar*(height-org_y);
        floats[10] = y - sinaf*org_x + sinar*(height-org_y);
 
-       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+       R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
 }
 
 void DrawQ_Fill(float x, float y, float width, float height, float red, float green, float blue, float alpha, int flags)
@@ -939,7 +939,7 @@ void DrawQ_Fill(float x, float y, float width, float height, float red, float gr
        floats[3] = floats[6] = x + width;
        floats[7] = floats[10] = y + height;
 
-       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+       R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
 }
 
 /// color tag printing
@@ -1209,7 +1209,7 @@ float DrawQ_String_Font(float startx, float starty, const char *text, size_t max
                        if (batchcount >= QUADELEMENTS_MAXQUADS)
                        {
                                GL_LockArrays(0, batchcount * 4);
-                               R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, NULL, quadelements, 0, 0);
+                               R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, quadelement3s, 0, 0);
                                GL_LockArrays(0, 0);
                                batchcount = 0;
                                ac = color4f;
@@ -1222,7 +1222,7 @@ float DrawQ_String_Font(float startx, float starty, const char *text, size_t max
        if (batchcount > 0)
        {
                GL_LockArrays(0, batchcount * 4);
-               R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, NULL, quadelements, 0, 0);
+               R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, quadelement3s, 0, 0);
                GL_LockArrays(0, 0);
        }
 
@@ -1322,7 +1322,7 @@ void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height
        floats[28] = r4;floats[29] = g4;floats[30] = b4;floats[31] = a4;
        floats[32] = r3;floats[33] = g3;floats[34] = b3;floats[35] = a3;
 
-       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+       R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
 }
 
 void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags)
@@ -1337,7 +1337,7 @@ void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags)
        R_SetupGenericShader(mesh->texture != NULL);
 
        GL_LockArrays(0, mesh->num_vertices);
-       R_Mesh_Draw(0, mesh->num_vertices, 0, mesh->num_triangles, NULL, mesh->data_element3s, 0, 0);
+       R_Mesh_Draw(0, mesh->num_vertices, 0, mesh->num_triangles, mesh->data_element3i, mesh->data_element3s, 0, 0);
        GL_LockArrays(0, 0);
 }
 
@@ -1435,7 +1435,7 @@ void R_DrawGamma(void)
                        while (c[0] >= 1.01f || c[1] >= 1.01f || c[2] >= 1.01f)
                        {
                                GL_Color(bound(0, c[0] - 1, 1), bound(0, c[1] - 1, 1), bound(0, c[2] - 1, 1), 1);
-                               R_Mesh_Draw(0, 3, 0, 1, NULL, polygonelements, 0, 0);
+                               R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, polygonelement3s, 0, 0);
                                VectorScale(c, 0.5, c);
                        }
                }
@@ -1451,7 +1451,7 @@ void R_DrawGamma(void)
                {
                        GL_BlendFunc(GL_ONE, GL_ONE);
                        GL_Color(c[0], c[1], c[2], 1);
-                       R_Mesh_Draw(0, 3, 0, 1, NULL, polygonelements, 0, 0);
+                       R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, polygonelement3s, 0, 0);
                }
        }
 }
index 096cc88..69697b9 100644 (file)
@@ -4147,7 +4147,7 @@ void R_Bloom_CopyBloomTexture(float colorscale)
        R_SetupGenericShader(true);
        R_Mesh_TexCoordPointer(0, 2, r_bloomstate.screentexcoord2f, 0, 0);
        R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
-       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+       R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
        r_refdef.stats.bloom_drawpixels += r_bloomstate.bloomwidth * r_bloomstate.bloomheight;
 
        // we now have a bloom image in the framebuffer
@@ -4192,7 +4192,7 @@ void R_Bloom_MakeTexture(void)
                GL_Color(r, r, r, 1);
                R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_bloom));
                R_Mesh_TexCoordPointer(0, 2, r_bloomstate.bloomtexcoord2f, 0, 0);
-               R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
                r_refdef.stats.bloom_drawpixels += r_bloomstate.bloomwidth * r_bloomstate.bloomheight;
 
                // copy the vertically blurred bloom view to a texture
@@ -4242,7 +4242,7 @@ void R_Bloom_MakeTexture(void)
                        if(range >= 1)
                                r *= (1 - x*x/(float)(range*range));
                        GL_Color(r, r, r, 1);
-                       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+                       R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
                        r_refdef.stats.bloom_drawpixels += r_bloomstate.bloomwidth * r_bloomstate.bloomheight;
                        GL_BlendFunc(GL_ONE, GL_ONE);
                }
@@ -4262,7 +4262,7 @@ void R_Bloom_MakeTexture(void)
                R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_bloom));
                R_Mesh_TexCoordPointer(0, 2, r_bloomstate.bloomtexcoord2f, 0, 0);
                GL_Color(1, 1, 1, 1);
-               R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
                r_refdef.stats.bloom_drawpixels += r_bloomstate.bloomwidth * r_bloomstate.bloomheight;
 
                GL_BlendFunc(GL_ONE, GL_ONE);
@@ -4270,7 +4270,7 @@ void R_Bloom_MakeTexture(void)
                R_Mesh_TexBind(0, R_GetTexture(r_texture_white));
                R_Mesh_TexCoordPointer(0, 2, r_bloomstate.bloomtexcoord2f, 0, 0);
                GL_Color(r_bloom_colorsubtract.value, r_bloom_colorsubtract.value, r_bloom_colorsubtract.value, 1);
-               R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
                r_refdef.stats.bloom_drawpixels += r_bloomstate.bloomwidth * r_bloomstate.bloomheight;
                qglBlendEquationEXT(GL_FUNC_ADD_EXT);
 
@@ -4386,7 +4386,7 @@ static void R_BlendView(void)
                                GL_Color(1, 1, 1, cl.motionbluralpha);
                                R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
                                R_Mesh_TexCoordPointer(0, 2, r_bloomstate.screentexcoord2f, 0, 0);
-                               R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+                               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
                                r_refdef.stats.bloom_drawpixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
                        }
                }
@@ -4461,7 +4461,7 @@ static void R_BlendView(void)
                }
                if (r_glsl_permutation->loc_Saturation >= 0)
                        qglUniform1fARB(r_glsl_permutation->loc_Saturation, r_glsl_saturation.value);
-               R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
                r_refdef.stats.bloom_drawpixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
                return;
        }
@@ -4481,7 +4481,7 @@ static void R_BlendView(void)
                GL_BlendFunc(GL_ONE, GL_ONE);
                R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_bloom));
                R_Mesh_TexCoordPointer(0, 2, r_bloomstate.bloomtexcoord2f, 0, 0);
-               R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
                r_refdef.stats.bloom_drawpixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
        }
        else if (r_bloomstate.texture_bloom)
@@ -4510,14 +4510,14 @@ static void R_BlendView(void)
                else
                {
                        R_SetupGenericShader(true);
-                       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+                       R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
                        r_refdef.stats.bloom_drawpixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
                        // now blend on the bloom texture
                        GL_BlendFunc(GL_ONE, GL_ONE);
                        R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_screen));
                        R_Mesh_TexCoordPointer(0, 2, r_bloomstate.screentexcoord2f, 0, 0);
                }
-               R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
                r_refdef.stats.bloom_drawpixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height;
        }
        if (r_refdef.viewblend[3] >= (1.0f / 256.0f))
@@ -4529,7 +4529,7 @@ static void R_BlendView(void)
                R_SetupGenericShader(false);
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                GL_Color(r_refdef.viewblend[0], r_refdef.viewblend[1], r_refdef.viewblend[2], r_refdef.viewblend[3]);
-               R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
        }
 }
 
@@ -5128,7 +5128,7 @@ static void R_DrawEntityBBoxes(void)
        prog = prog_save;
 }
 
-unsigned short nomodelelements[24] =
+static const int nomodelelement3i[24] =
 {
        5, 2, 0,
        5, 1, 2,
@@ -5140,7 +5140,19 @@ unsigned short nomodelelements[24] =
        1, 3, 4
 };
 
-float nomodelvertex3f[6*3] =
+static const unsigned short nomodelelement3s[24] =
+{
+       5, 2, 0,
+       5, 1, 2,
+       5, 0, 3,
+       5, 3, 1,
+       0, 2, 4,
+       2, 1, 4,
+       3, 0, 4,
+       1, 3, 4
+};
+
+static const float nomodelvertex3f[6*3] =
 {
        -16,   0,   0,
         16,   0,   0,
@@ -5150,7 +5162,7 @@ float nomodelvertex3f[6*3] =
          0,   0,  16
 };
 
-float nomodelcolor4f[6*4] =
+static const float nomodelcolor4f[6*4] =
 {
        0.0f, 0.0f, 0.5f, 1.0f,
        0.0f, 0.0f, 0.5f, 1.0f,
@@ -5221,7 +5233,7 @@ void R_DrawNoModel_TransparentCallback(const entity_render_t *ent, const rtlight
        else
                R_Mesh_ColorPointer(nomodelcolor4f, 0, 0);
        R_Mesh_ResetTextureState();
-       R_Mesh_Draw(0, 6, 0, 8, NULL, nomodelelements, 0, 0);
+       R_Mesh_Draw(0, 6, 0, 8, nomodelelement3i, nomodelelement3s, 0, 0);
 }
 
 void R_DrawNoModel(entity_render_t *ent)
@@ -5310,7 +5322,7 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_
        R_Mesh_TexCoordPointer(0, 2, spritetexcoord2f, 0, 0);
        // FIXME: fixed function path can't properly handle r_refdef.view.colorscale > 1
        GL_Color(cr * fog * r_refdef.view.colorscale, cg * fog * r_refdef.view.colorscale, cb * fog * r_refdef.view.colorscale, ca);
-       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+       R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
 
        if (blendfunc2 == GL_ONE_MINUS_SRC_ALPHA)
        {
@@ -5318,7 +5330,7 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_
                GL_BlendFunc(blendfunc1, GL_ONE);
                fog = 1 - fog;
                GL_Color(r_refdef.fogcolor[0] * fog, r_refdef.fogcolor[1] * fog, r_refdef.fogcolor[2] * fog, ca);
-               R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+               R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
        }
 }
 
index ced25af..c48add3 100644 (file)
@@ -364,7 +364,7 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, const rtlight_t *r
                         isvis ? 0.125f : 0.03125f);
        for (i = 0, v = vertex3f;i < numpoints;i++, v += 3)
                VectorCopy(portal->points[i].position, v);
-       R_Mesh_Draw(0, numpoints, 0, numpoints - 2, NULL, polygonelements, 0, 0);
+       R_Mesh_Draw(0, numpoints, 0, numpoints - 2, polygonelement3i, polygonelement3s, 0, 0);
 }
 
 // LordHavoc: this is just a nice debugging tool, very slow
index 502654d..530049b 100644 (file)
@@ -4520,7 +4520,7 @@ void R_DrawModelShadows(void)
        qglStencilFunc(GL_NOTEQUAL, 128, ~0);CHECKGLERROR
 
        // apply the blend to the shadowed areas
-       R_Mesh_Draw(0, 4, 0, 2, NULL, polygonelements, 0, 0);
+       R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
 
        // restore the viewport
        R_SetViewport(&r_refdef.view.viewport);
diff --git a/r_sky.c b/r_sky.c
index 8f63cab..c3160f2 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -253,7 +253,29 @@ static const float skyboxtexcoord2f[6*4*2] =
        0, 0
 };
 
-static const unsigned short skyboxelements[6*2*3] =
+static const int skyboxelement3i[6*2*3] =
+{
+       // skyside[3]
+        0,  1,  2,
+        0,  2,  3,
+       // skyside[1]
+        4,  5,  6,
+        4,  6,  7,
+       // skyside[0]
+        8,  9, 10,
+        8, 10, 11,
+       // skyside[2]
+       12, 13, 14,
+       12, 14, 15,
+       // skyside[4]
+       16, 17, 18,
+       16, 18, 19,
+       // skyside[5]
+       20, 21, 22,
+       20, 22, 23
+};
+
+static const unsigned short skyboxelement3s[6*2*3] =
 {
        // skyside[3]
         0,  1,  2,
@@ -295,7 +317,7 @@ static void R_SkyBox(void)
        for (i = 0;i < 6;i++)
        {
                R_Mesh_TexBind(0, R_GetTexture(skyboxside[i]));
-               R_Mesh_Draw(0, 6*4, i*2, 2, NULL, skyboxelements, 0, 0);
+               R_Mesh_Draw(0, 6*4, i*2, 2, skyboxelement3i, skyboxelement3s, 0, 0);
        }
 
        if(r_refdef.fogenabled)
@@ -306,7 +328,7 @@ static void R_SkyBox(void)
                for (i = 0;i < 6;i++)
                {
                        R_Mesh_TexBind(0, 0);
-                       R_Mesh_Draw(0, 6*4, i*2, 2, NULL, skyboxelements, 0, 0);
+                       R_Mesh_Draw(0, 6*4, i*2, 2, skyboxelement3i, skyboxelement3s, 0, 0);
                }
        }
 
@@ -323,7 +345,8 @@ static void R_SkyBox(void)
 #define skysphere_numtriangles (skygridx * skygridy * 2)
 static float skysphere_vertex3f[skysphere_numverts * 3];
 static float skysphere_texcoord2f[skysphere_numverts * 2];
-static unsigned short skysphere_elements[skysphere_numtriangles * 3];
+static int skysphere_element3i[skysphere_numtriangles * 3];
+static unsigned short skysphere_element3s[skysphere_numtriangles * 3];
 
 static void skyspherecalc(void)
 {
@@ -356,7 +379,7 @@ static void skyspherecalc(void)
                        *vertex3f++ = v[2];
                }
        }
-       e = skysphere_elements;
+       e = skysphere_element3s;
        for (j = 0;j < skygridy;j++)
        {
                for (i = 0;i < skygridx;i++)
@@ -370,6 +393,8 @@ static void skyspherecalc(void)
                        *e++ = (j + 1) * skygridx1 + i;
                }
        }
+       for (i = 0;i < skysphere_numtriangles*3;i++)
+               skysphere_element3i[i] = skysphere_element3s[i];
 }
 
 static void R_SkySphere(void)
@@ -416,7 +441,7 @@ static void R_SkySphere(void)
                R_Mesh_TexCoordPointer(1, 2, skysphere_texcoord2f, 0, 0);
                R_Mesh_TexMatrix(1, &scroll2matrix);
                GL_LockArrays(0, skysphere_numverts);
-               R_Mesh_Draw(0, skysphere_numverts, 0, skysphere_numtriangles, NULL, skysphere_elements, 0, 0);
+               R_Mesh_Draw(0, skysphere_numverts, 0, skysphere_numtriangles, skysphere_element3i, skysphere_element3s, 0, 0);
                GL_LockArrays(0, 0);
                R_Mesh_TexBind(1, 0);
        }
@@ -425,13 +450,13 @@ static void R_SkySphere(void)
                // two pass
                R_SetupGenericShader(true);
                GL_LockArrays(0, skysphere_numverts);
-               R_Mesh_Draw(0, skysphere_numverts, 0, skysphere_numtriangles, NULL, skysphere_elements, 0, 0);
+               R_Mesh_Draw(0, skysphere_numverts, 0, skysphere_numtriangles, skysphere_element3i, skysphere_element3s, 0, 0);
 
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                R_Mesh_TexBind(0, R_GetTexture(r_refdef.scene.worldmodel->brush.alphaskytexture));
                R_Mesh_TexMatrix(0, &scroll2matrix);
                GL_LockArrays(0, skysphere_numverts);
-               R_Mesh_Draw(0, skysphere_numverts, 0, skysphere_numtriangles, NULL, skysphere_elements, 0, 0);
+               R_Mesh_Draw(0, skysphere_numverts, 0, skysphere_numtriangles, skysphere_element3i, skysphere_element3s, 0, 0);
                GL_LockArrays(0, 0);
        }
 
@@ -442,7 +467,7 @@ static void R_SkySphere(void)
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                GL_Color(r_refdef.fogcolor[0], r_refdef.fogcolor[1], r_refdef.fogcolor[2], 1 - r_refdef.fogmasktable[FOGMASKTABLEWIDTH-1]);
                GL_LockArrays(0, skysphere_numverts);
-               R_Mesh_Draw(0, skysphere_numverts, 0, skysphere_numtriangles, NULL, skysphere_elements, 0, 0);
+               R_Mesh_Draw(0, skysphere_numverts, 0, skysphere_numtriangles, skysphere_element3i, skysphere_element3s, 0, 0);
                GL_LockArrays(0, 0);
        }
 }