]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_poly.c
added back r_speeds2, with masses of information (6 lines high), and made it print...
[xonotic/darkplaces.git] / gl_poly.c
index d312335ec68ccf8397c19bcb0acee54e616fd662..2631e3520ce319611708a14f5ebf91bb0605b24e 100644 (file)
--- a/gl_poly.c
+++ b/gl_poly.c
@@ -34,22 +34,37 @@ float transviewdist; // distance of view origin along the view normal
 
 float transreciptable[256];
 
-void glpoly_init()
+void gl_poly_start()
 {
        int i;
-       Cvar_RegisterVariable (&gl_multitexture);
-       Cvar_RegisterVariable (&gl_vertexarrays);
-       transvert = malloc(MAX_TRANSVERTS * sizeof(transvert_t));
-       transpoly = malloc(MAX_TRANSPOLYS * sizeof(transpoly_t));
-       transpolyindex = malloc(MAX_TRANSPOLYS * sizeof(unsigned short));
-       wallvert = malloc(MAX_WALLVERTS * sizeof(wallvert_t));
-       wallpoly = malloc(MAX_WALLPOLYS * sizeof(wallpoly_t));
-       skyvert = malloc(MAX_SKYVERTS * sizeof(skyvert_t));
-       skypoly = malloc(MAX_SKYPOLYS * sizeof(skypoly_t));
+       transvert = qmalloc(MAX_TRANSVERTS * sizeof(transvert_t));
+       transpoly = qmalloc(MAX_TRANSPOLYS * sizeof(transpoly_t));
+       transpolyindex = qmalloc(MAX_TRANSPOLYS * sizeof(unsigned short));
+       wallvert = qmalloc(MAX_WALLVERTS * sizeof(wallvert_t));
+       wallpoly = qmalloc(MAX_WALLPOLYS * sizeof(wallpoly_t));
+       skyvert = qmalloc(MAX_SKYVERTS * sizeof(skyvert_t));
+       skypoly = qmalloc(MAX_SKYPOLYS * sizeof(skypoly_t));
        transreciptable[0] = 0.0f;
        for (i = 1;i < 256;i++)
                transreciptable[i] = 1.0f / i;
 }
+void gl_poly_shutdown()
+{
+       qfree(transvert);
+       qfree(transpoly);
+       qfree(transpolyindex);
+       qfree(wallvert);
+       qfree(wallpoly);
+       qfree(skyvert);
+       qfree(skypoly);
+}
+
+void GL_Poly_Init()
+{
+       Cvar_RegisterVariable (&gl_multitexture);
+       Cvar_RegisterVariable (&gl_vertexarrays);
+       R_RegisterModule("GL_Poly", gl_poly_start, gl_poly_shutdown);
+}
 
 void transpolyclear()
 {
@@ -59,6 +74,8 @@ void transpolyclear()
        transviewdist = DotProduct(r_refdef.vieworg, vpn);
 }
 
+// turned into a #define
+/*
 void transpolybegin(int texnum, int glowtexnum, int fogtexnum, int transpolytype)
 {
        if (currenttranspoly >= MAX_TRANSPOLYS || currenttransvert >= MAX_TRANSVERTS)
@@ -71,6 +88,7 @@ void transpolybegin(int texnum, int glowtexnum, int fogtexnum, int transpolytype
        transpoly[currenttranspoly].verts = 0;
 //     transpoly[currenttranspoly].ndist = 0; // clear the normal
 }
+*/
 
 // turned into a #define
 /*
@@ -131,7 +149,6 @@ void transpolyend()
 }
 
 int transpolyindices;
-extern qboolean isG200;
 
 /*
 void transpolyrenderminmax()
@@ -350,6 +367,8 @@ void transpolyrender()
 {
        int i, j, tpolytype, texnum;
        transpoly_t *p;
+       if (!r_render.value)
+               return;
        if (currenttranspoly < 1)
                return;
 //     transpolyrenderminmax();
@@ -367,10 +386,6 @@ void transpolyrender()
                glEnable(GL_ALPHA_TEST);
        else
                glDisable(GL_ALPHA_TEST);
-       // later note: wasn't working on my TNT drivers...  strangely...  used a cheaper hack in transpolyvert
-       //// offset by 16 depth units so decal sprites appear infront of walls
-       //glPolygonOffset(1, -16);
-       //glEnable(GL_POLYGON_OFFSET_FILL);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        tpolytype = TPOLYTYPE_ALPHA;
        texnum = -1;
@@ -538,52 +553,23 @@ void transpolyrender()
                glEnd();
        }
 
-       //glDisable(GL_POLYGON_OFFSET_FILL);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glDepthMask(1); // enable zbuffer updates
        glDisable(GL_ALPHA_TEST);
 }
 
-/*
-void lightpolybegin(int texnum)
-{
-       if (currentlightpoly >= MAX_LIGHTPOLYS || currentlightvert >= MAX_LIGHTVERTS)
-               return;
-       lightpoly[currentlightpoly].texnum = (unsigned short) texnum;
-       lightpoly[currentlightpoly].firstvert = currentlightvert;
-       lightpoly[currentlightpoly].verts = 0;
-}
-
-// lightpolyvert is a #define
-
-void lightpolyend()
-{
-       if (currentlightpoly >= MAX_LIGHTPOLYS)
-               return;
-       if (lightpoly[currentlightpoly].verts < 3) // skip invalid polygons
-       {
-               currentlightvert = lightpoly[currentlightpoly].firstvert; // reset vert pointer
-               return;
-       }
-       if (currentlightvert >= MAX_LIGHTVERTS)
-               return;
-       currentlightpoly++;
-}
-*/
-
-extern qboolean isG200;
-
 void wallpolyclear()
 {
        currentwallpoly = currentwallvert = 0;
 }
 
-extern qboolean lighthalf;
 void wallpolyrender()
 {
        int i, j, texnum, lighttexnum;
        wallpoly_t *p;
        wallvert_t *vert;
+       if (!r_render.value)
+               return;
        if (currentwallpoly < 1)
                return;
        c_brush_polys += currentwallpoly;
@@ -796,8 +782,6 @@ void skypolyclear()
        currentskypoly = currentskyvert = 0;
 }
 
-extern qboolean isATI;
-
 extern char skyname[];
 extern int solidskytexture, alphaskytexture;
 void skypolyrender()
@@ -807,6 +791,8 @@ void skypolyrender()
        skyvert_t *vert;
        float length, speedscale;
        vec3_t dir;
+       if (!r_render.value)
+               return;
        if (currentskypoly < 1)
                return;
        // testing
@@ -818,13 +804,16 @@ void skypolyrender()
        glDepthMask(1);
        if (!fogenabled && !skyname[0]) // normal quake sky
        {
-               glColor3f(0.5f, 0.5f, 0.5f);
+               if(lighthalf)
+                       glColor3f(0.5f, 0.5f, 0.5f);
+               else
+                       glColor3f(1.0f,1.0f,1.0f);
                glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
                glEnable(GL_TEXTURE_2D);
                glDisable(GL_BLEND);
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                glBindTexture(GL_TEXTURE_2D, solidskytexture); // upper clouds
-               speedscale = realtime*8;
+               speedscale = cl.time*8;
                speedscale -= (int)speedscale & ~127 ;
                for (i = 0,p = &skypoly[0];i < currentskypoly;i++, p++)
                {
@@ -847,7 +836,7 @@ void skypolyrender()
                glEnable(GL_BLEND);
                glDepthMask(0);
                glBindTexture(GL_TEXTURE_2D, alphaskytexture); // lower clouds
-               speedscale = realtime*16;
+               speedscale = cl.time*16;
                speedscale -= (int)speedscale & ~127 ;
                for (i = 0,p = &skypoly[0];i < currentskypoly;i++, p++)
                {