]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_warp.c
added back r_speeds2, with masses of information (6 lines high), and made it print...
[xonotic/darkplaces.git] / gl_warp.c
index 5bf52b35ac45df99c86a04f3cc4a61219c2c9be5..8f35afba4df63e3d9f474ebd6483537d2fca09ac 100644 (file)
--- a/gl_warp.c
+++ b/gl_warp.c
@@ -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,17 +176,12 @@ void GL_SubdivideSurface (msurface_t *fa)
 
 
 
-extern qboolean lighthalf;
-
-#define        SKY_TEX         4000
+int skyboxside[6];
 
 char skyname[256];
 
 // LordHavoc: moved LoadTGA and LoadPCX to gl_draw.c
 
-extern int image_width, image_height;
-
-byte* loadimagepixels (char* filename, qboolean complain, int matchwidth, int matchheight);
 /*
 ==================
 R_LoadSkyBox
@@ -196,12 +191,16 @@ char      *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
 void R_LoadSkyBox (void)
 {
        int             i;
-       char    name[64];
+       char    name[1024];
        byte*   image_rgba;
 
+       if (strlen(skyname) >= 1000)
+       {
+               Con_Printf ("sky name too long (%i, max is 1000)\n", strlen(skyname));
+               return;
+       }
        for (i=0 ; i<6 ; i++)
        {
-               glBindTexture(GL_TEXTURE_2D, SKY_TEX + i);
                sprintf (name, "env/%s%s", skyname, suf[i]);
                if (!(image_rgba = loadimagepixels(name, FALSE, 0, 0)))
                {
@@ -212,10 +211,8 @@ void R_LoadSkyBox (void)
                                continue;
                        }
                }
-               glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, image_width, image_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_rgba);
-               free (image_rgba);
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+               skyboxside[i] = GL_LoadTexture(va("skyboxside%d", i), image_width, image_height, image_rgba, false, false, 4);
+               qfree(image_rgba);
        }
 }
 
@@ -260,42 +257,42 @@ void R_SkyBox()
                glColor3f(0.5,0.5,0.5);
        else
                glColor3f(1,1,1);
-       glBindTexture(GL_TEXTURE_2D, SKY_TEX + 3); // front
+       glBindTexture(GL_TEXTURE_2D, 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, SKY_TEX + 1); // back
+       glBindTexture(GL_TEXTURE_2D, 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, SKY_TEX + 0); // right
+       glBindTexture(GL_TEXTURE_2D, 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, SKY_TEX + 2); // left
+       glBindTexture(GL_TEXTURE_2D, 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, SKY_TEX + 4); // up
+       glBindTexture(GL_TEXTURE_2D, 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, SKY_TEX + 5); // down
+       glBindTexture(GL_TEXTURE_2D, skyboxside[5]); // down
        glBegin(GL_QUADS);
        R_SkyBoxPolyVec(1, 0,  1,  1, -1);
        R_SkyBoxPolyVec(1, 1,  1, -1, -1);
@@ -394,12 +391,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);
@@ -408,6 +405,8 @@ void R_SkyDome()
 
 void R_Sky()
 {
+       if (!r_render.value)
+               return;
        if (!skyname[0])
                return;
        glDisable(GL_DEPTH_TEST);
@@ -430,18 +429,14 @@ R_InitSky
 A sky texture is 256*128, with the right side being a masked overlay
 ==============
 */
-// LordHavoc: changed this for GLQuake
-void R_InitSky (byte *src, int bytesperpixel) //texture_t *mt)
+void R_InitSky (byte *src, int bytesperpixel)
 {
        int                     i, j, p;
-//     byte            *src;
        unsigned        trans[128*128];
        unsigned        transpix;
        int                     r, g, b;
        unsigned        *rgba;
 
-//     src = (byte *)mt + mt->offsets[0];
-
        if (bytesperpixel == 4)
        {
                for (i = 0;i < 128;i++)
@@ -470,16 +465,7 @@ void R_InitSky (byte *src, int bytesperpixel) //texture_t *mt)
                ((byte *)&transpix)[3] = 0;
        }
 
-       if (!solidskytexture)
-               solidskytexture = texture_extension_number++;
-       if (!isDedicated)
-       {
-               glBindTexture(GL_TEXTURE_2D, solidskytexture );
-               glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans);
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-       }
-
+       solidskytexture = GL_LoadTexture ("sky_solidtexture", 128, 128, (byte *) trans, false, false, 4);
 
        if (bytesperpixel == 4)
        {
@@ -500,14 +486,6 @@ void R_InitSky (byte *src, int bytesperpixel) //texture_t *mt)
                        }
        }
 
-       if (!alphaskytexture)
-               alphaskytexture = texture_extension_number++;
-       if (!isDedicated)
-       {
-               glBindTexture(GL_TEXTURE_2D, alphaskytexture);
-               glTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, trans);
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-               glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-       }
+       alphaskytexture = GL_LoadTexture ("sky_alphatexture", 128, 128, (byte *) trans, false, true, 4);
 }