]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_warp.c
disabled wad3 loading from "wad" key in worldspawn of map when not loading an HL map
[xonotic/darkplaces.git] / gl_warp.c
index 495f59399f60506883b04e27bde5e1c19431b17f..c3ccd0d20a24931cb948df1a79c898ab924b673d 100644 (file)
--- a/gl_warp.c
+++ b/gl_warp.c
@@ -25,8 +25,8 @@ extern        model_t *loadmodel;
 
 int            skytexturenum;
 
-int            solidskytexture;
-int            alphaskytexture;
+rtexture_t *solidskytexture;
+rtexture_t *alphaskytexture;
 float  speedscale;             // for top sky and bottom sky
 
 msurface_t     *warpface;
@@ -120,7 +120,7 @@ void SubdividePolygon (int numverts, float *verts)
                return;
        }
 
-       poly = Hunk_Alloc (sizeof(glpoly_t) + (numverts-4) * VERTEXSIZE*sizeof(float));
+       poly = Hunk_AllocName (sizeof(glpoly_t) + (numverts-4) * VERTEXSIZE*sizeof(float), "surfaces");
        poly->next = warpface->polys;
        warpface->polys = poly;
        poly->numverts = numverts;
@@ -176,7 +176,7 @@ void GL_SubdivideSurface (msurface_t *fa)
 
 
 
-int skyboxside[6];
+rtexture_t *skyboxside[6];
 
 char skyname[256];
 
@@ -202,16 +202,16 @@ void R_LoadSkyBox (void)
        for (i=0 ; i<6 ; i++)
        {
                sprintf (name, "env/%s%s", skyname, suf[i]);
-               if (!(image_rgba = loadimagepixels(name, FALSE, 0, 0)))
+               if (!(image_rgba = loadimagepixels(name, false, 0, 0)))
                {
                        sprintf (name, "gfx/env/%s%s", skyname, suf[i]);
-                       if (!(image_rgba = loadimagepixels(name, FALSE, 0, 0)))
+                       if (!(image_rgba = loadimagepixels(name, false, 0, 0)))
                        {
                                Con_Printf ("Couldn't load %s\n", name);
                                continue;
                        }
                }
-               skyboxside[i] = GL_LoadTexture(va("skyboxside%d", i), image_width, image_height, image_rgba, false, false, 4);
+               skyboxside[i] = R_LoadTexture(va("skyboxside%d", i), image_width, image_height, image_rgba, TEXF_RGBA | TEXF_PRECACHE);
                qfree(image_rgba);
        }
 }
@@ -257,42 +257,42 @@ void R_SkyBox()
                glColor3f(0.5,0.5,0.5);
        else
                glColor3f(1,1,1);
-       glBindTexture(GL_TEXTURE_2D, skyboxside[3]); // front
+       glBindTexture(GL_TEXTURE_2D, R_GetTexture(skyboxside[3])); // front
        glBegin(GL_QUADS);
        R_SkyBoxPolyVec(1, 0,  1, -1,  1);
        R_SkyBoxPolyVec(1, 1,  1, -1, -1);
        R_SkyBoxPolyVec(0, 1,  1,  1, -1);
        R_SkyBoxPolyVec(0, 0,  1,  1,  1);
        glEnd();
-       glBindTexture(GL_TEXTURE_2D, skyboxside[1]); // back
+       glBindTexture(GL_TEXTURE_2D, R_GetTexture(skyboxside[1])); // back
        glBegin(GL_QUADS);
        R_SkyBoxPolyVec(1, 0, -1,  1,  1);
        R_SkyBoxPolyVec(1, 1, -1,  1, -1);
        R_SkyBoxPolyVec(0, 1, -1, -1, -1);
        R_SkyBoxPolyVec(0, 0, -1, -1,  1);
        glEnd();
-       glBindTexture(GL_TEXTURE_2D, skyboxside[0]); // right
+       glBindTexture(GL_TEXTURE_2D, R_GetTexture(skyboxside[0])); // right
        glBegin(GL_QUADS);
        R_SkyBoxPolyVec(1, 0,  1,  1,  1);
        R_SkyBoxPolyVec(1, 1,  1,  1, -1);
        R_SkyBoxPolyVec(0, 1, -1,  1, -1);
        R_SkyBoxPolyVec(0, 0, -1,  1,  1);
        glEnd();
-       glBindTexture(GL_TEXTURE_2D, skyboxside[2]); // left
+       glBindTexture(GL_TEXTURE_2D, R_GetTexture(skyboxside[2])); // left
        glBegin(GL_QUADS);
        R_SkyBoxPolyVec(1, 0, -1, -1,  1);
        R_SkyBoxPolyVec(1, 1, -1, -1, -1);
        R_SkyBoxPolyVec(0, 1,  1, -1, -1);
        R_SkyBoxPolyVec(0, 0,  1, -1,  1);
        glEnd();
-       glBindTexture(GL_TEXTURE_2D, skyboxside[4]); // up
+       glBindTexture(GL_TEXTURE_2D, R_GetTexture(skyboxside[4])); // up
        glBegin(GL_QUADS);
        R_SkyBoxPolyVec(1, 0,  1, -1,  1);
        R_SkyBoxPolyVec(1, 1,  1,  1,  1);
        R_SkyBoxPolyVec(0, 1, -1,  1,  1);
        R_SkyBoxPolyVec(0, 0, -1, -1,  1);
        glEnd();
-       glBindTexture(GL_TEXTURE_2D, skyboxside[5]); // down
+       glBindTexture(GL_TEXTURE_2D, R_GetTexture(skyboxside[5])); // down
        glBegin(GL_QUADS);
        R_SkyBoxPolyVec(1, 0,  1,  1, -1);
        R_SkyBoxPolyVec(1, 1,  1, -1, -1);
@@ -331,7 +331,6 @@ void skydomecalc(float *dome, float dx, float dy, float dz)
        }
 }
 
-extern cvar_t gl_vertexarrays;
 void skydome(float *source, float s, float texscale)
 {
        vec_t vert[33*33][3], tex[33*33][2], *v, *t;
@@ -346,33 +345,15 @@ void skydome(float *source, float s, float texscale)
                *v++ = *source++ + r_refdef.vieworg[1];
                *v++ = *source++ + r_refdef.vieworg[2];
        }
-       if (gl_vertexarrays.value)
-       {
-               qglTexCoordPointer(2, GL_FLOAT, 0, tex);
-               qglVertexPointer(3, GL_FLOAT, 0, vert);
-               glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-               glEnableClientState(GL_VERTEX_ARRAY);
-//             qglInterleavedArrays(GL_T2F_V3F, 0, vert);
-               for (i = 0;i < (32*66);i+=66)
-                       qglDrawElements(GL_TRIANGLE_STRIP, 66, GL_UNSIGNED_SHORT, &skydomeindices[i]);
-               glDisableClientState(GL_VERTEX_ARRAY);
-               glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-       }
-       else
-       {
-               index = skydomeindices;
-               for (i = 0;i < (32*66);i+=66)
-               {
-                       glBegin(GL_TRIANGLE_STRIP);
-                       for (j = 0;j < 66;j++)
-                       {
-                               // Matrox G200 (and possibly G400) drivers don't support TexCoord2fv...
-                               glTexCoord2f(tex[*index][0], tex[*index][1]);
-                               glVertex3fv(&vert[*index++][0]);
-                       }
-                       glEnd();
-               }
-       }
+       glTexCoordPointer(2, GL_FLOAT, 0, tex);
+       glVertexPointer(3, GL_FLOAT, 0, vert);
+       glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+       glEnableClientState(GL_VERTEX_ARRAY);
+//     glInterleavedArrays(GL_T2F_V3F, 0, vert);
+       for (i = 0;i < (32*66);i+=66)
+               glDrawElements(GL_TRIANGLE_STRIP, 66, GL_UNSIGNED_SHORT, &skydomeindices[i]);
+       glDisableClientState(GL_VERTEX_ARRAY);
+       glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 }
 
 void R_SkyDome()
@@ -391,12 +372,12 @@ void R_SkyDome()
                skydomecalc(skydomeouter, 1024, 1024, 256);
                skydomecalc(skydomeinner, 512, 512, 128);
        }
-       speedscale = realtime*8.0/256.0;
+       speedscale = cl.time*8.0/256.0;
        speedscale -= (int)speedscale;
        skydome(skydomeouter, speedscale, 1.0 / 256.0);
        glEnable (GL_BLEND);
        glBindTexture(GL_TEXTURE_2D, alphaskytexture); // lower clouds
-       speedscale = realtime*8.0/128.0;
+       speedscale = cl.time*8.0/128.0;
        speedscale -= (int)speedscale;
        skydome(skydomeinner, speedscale, 1.0 / 128.0);
        glDisable (GL_BLEND);
@@ -465,7 +446,7 @@ void R_InitSky (byte *src, int bytesperpixel)
                ((byte *)&transpix)[3] = 0;
        }
 
-       solidskytexture = GL_LoadTexture ("sky_solidtexture", 128, 128, (byte *) trans, false, false, 4);
+       solidskytexture = R_LoadTexture ("sky_solidtexture", 128, 128, (byte *) trans, TEXF_RGBA | TEXF_PRECACHE);
 
        if (bytesperpixel == 4)
        {
@@ -486,6 +467,6 @@ void R_InitSky (byte *src, int bytesperpixel)
                        }
        }
 
-       alphaskytexture = GL_LoadTexture ("sky_alphatexture", 128, 128, (byte *) trans, false, true, 4);
+       alphaskytexture = R_LoadTexture ("sky_alphatexture", 128, 128, (byte *) trans, TEXF_ALPHA | TEXF_RGBA | TEXF_PRECACHE);
 }