]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rmain.c
-Changed the SDL window icon back to DP's icon.
[xonotic/darkplaces.git] / gl_rmain.c
index 1d0bc1d2876cf27d7a75ee572198f40487e4617d..4042819641c1d090b85f198a6ee4d531265886f4 100644 (file)
@@ -103,6 +103,9 @@ cvar_t r_bloom_intensity = {CVAR_SAVE, "r_bloom_intensity", "2"};
 cvar_t r_bloom_blur = {CVAR_SAVE, "r_bloom_blur", "8"};
 cvar_t r_bloom_resolution = {CVAR_SAVE, "r_bloom_resolution", "320"};
 cvar_t r_bloom_power = {CVAR_SAVE, "r_bloom_power", "4"};
+
+cvar_t developer_texturelogging = {0, "developer_texturelogging", "1"};
+
 rtexturepool_t *r_main_texturepool;
 rtexture_t *r_bloom_texture_screen;
 rtexture_t *r_bloom_texture_bloom;
@@ -110,6 +113,8 @@ rtexture_t *r_texture_blanknormalmap;
 rtexture_t *r_texture_white;
 rtexture_t *r_texture_black;
 rtexture_t *r_texture_notexture;
+rtexture_t *r_texture_whitecube;
+rtexture_t *r_texture_normalizationcube;
 
 void R_ModulateColors(float *in, float *out, int verts, float r, float g, float b)
 {
@@ -211,9 +216,12 @@ void FOG_registercvars(void)
 
 void gl_main_start(void)
 {
-       int x, y;
+       int x, y, side;
+       vec3_t v;
+       vec_t s, t, intensity;
        qbyte pix[16][16][4];
-       qbyte data[4];
+#define NORMSIZE 64
+       qbyte data[6*NORMSIZE*NORMSIZE*4];
        r_main_texturepool = R_AllocTexturePool();
        r_bloom_texture_screen = NULL;
        r_bloom_texture_bloom = NULL;
@@ -253,7 +261,67 @@ void gl_main_start(void)
                        }
                }
        }
-       r_texture_notexture = R_LoadTexture2D(mod_shared_texturepool, "notexture", 16, 16, &pix[0][0][0], TEXTYPE_RGBA, TEXF_MIPMAP, NULL);
+       r_texture_notexture = R_LoadTexture2D(r_main_texturepool, "notexture", 16, 16, &pix[0][0][0], TEXTYPE_RGBA, TEXF_MIPMAP, NULL);
+       if (gl_texturecubemap)
+       {
+               data[ 0] = 255;data[ 1] = 255;data[ 2] = 255;data[ 3] = 255;
+               data[ 4] = 255;data[ 5] = 255;data[ 6] = 255;data[ 7] = 255;
+               data[ 8] = 255;data[ 9] = 255;data[10] = 255;data[11] = 255;
+               data[12] = 255;data[13] = 255;data[14] = 255;data[15] = 255;
+               data[16] = 255;data[17] = 255;data[18] = 255;data[19] = 255;
+               data[20] = 255;data[21] = 255;data[22] = 255;data[23] = 255;
+               r_texture_whitecube = R_LoadTextureCubeMap(r_main_texturepool, "whitecube", 1, data, TEXTYPE_RGBA, TEXF_PRECACHE | TEXF_CLAMP, NULL);
+               for (side = 0;side < 6;side++)
+               {
+                       for (y = 0;y < NORMSIZE;y++)
+                       {
+                               for (x = 0;x < NORMSIZE;x++)
+                               {
+                                       s = (x + 0.5f) * (2.0f / NORMSIZE) - 1.0f;
+                                       t = (y + 0.5f) * (2.0f / NORMSIZE) - 1.0f;
+                                       switch(side)
+                                       {
+                                       case 0:
+                                               v[0] = 1;
+                                               v[1] = -t;
+                                               v[2] = -s;
+                                               break;
+                                       case 1:
+                                               v[0] = -1;
+                                               v[1] = -t;
+                                               v[2] = s;
+                                               break;
+                                       case 2:
+                                               v[0] = s;
+                                               v[1] = 1;
+                                               v[2] = t;
+                                               break;
+                                       case 3:
+                                               v[0] = s;
+                                               v[1] = -1;
+                                               v[2] = -t;
+                                               break;
+                                       case 4:
+                                               v[0] = s;
+                                               v[1] = -t;
+                                               v[2] = 1;
+                                               break;
+                                       case 5:
+                                               v[0] = -s;
+                                               v[1] = -t;
+                                               v[2] = -1;
+                                               break;
+                                       }
+                                       intensity = 127.0f / sqrt(DotProduct(v, v));
+                                       data[((side*NORMSIZE+y)*NORMSIZE+x)*4+0] = 128.0f + intensity * v[0];
+                                       data[((side*NORMSIZE+y)*NORMSIZE+x)*4+1] = 128.0f + intensity * v[1];
+                                       data[((side*NORMSIZE+y)*NORMSIZE+x)*4+2] = 128.0f + intensity * v[2];
+                                       data[((side*NORMSIZE+y)*NORMSIZE+x)*4+3] = 255;
+                               }
+                       }
+               }
+               r_texture_normalizationcube = R_LoadTextureCubeMap(r_main_texturepool, "normalcube", NORMSIZE, data, TEXTYPE_RGBA, TEXF_PRECACHE | TEXF_CLAMP, NULL);
+       }
 }
 
 void gl_main_shutdown(void)
@@ -264,6 +332,8 @@ void gl_main_shutdown(void)
        r_texture_blanknormalmap = NULL;
        r_texture_white = NULL;
        r_texture_black = NULL;
+       r_texture_whitecube = NULL;
+       r_texture_normalizationcube = NULL;
 }
 
 extern void CL_ParseEntityLump(char *entitystring);
@@ -316,6 +386,7 @@ void GL_Main_Init(void)
        Cvar_RegisterVariable(&r_bloom_blur);
        Cvar_RegisterVariable(&r_bloom_resolution);
        Cvar_RegisterVariable(&r_bloom_power);
+       Cvar_RegisterVariable(&developer_texturelogging);
        if (gamemode == GAME_NEHAHRA || gamemode == GAME_NEXUIZ || gamemode == GAME_TENEBRAE)
                Cvar_SetValue("r_fullbrights", 0);
        R_RegisterModule("GL_Main", gl_main_start, gl_main_shutdown, gl_main_newmap);
@@ -475,6 +546,7 @@ static void R_MarkEntities (void)
        if (!r_drawentities.integer)
                return;
 
+       r_refdef.worldentity->visframe = r_framecount;
        renderimask = envmap ? (RENDER_EXTERIORMODEL | RENDER_VIEWMODEL) : (chase_active.integer ? 0 : RENDER_EXTERIORMODEL);
        if (r_refdef.worldmodel && r_refdef.worldmodel->brush.BoxTouchingVisibleLeafs)
        {
@@ -930,7 +1002,7 @@ void R_RenderScene(void)
                S_ExtraUpdate ();
 
        GL_ShowTrisColor(0, 0, 0.033, 1);
-       R_ShadowVolumeLighting(false, false);
+       R_ShadowVolumeLighting(false);
        R_TimeReport("rtlights");
 
        // don't let sound skip if going slow
@@ -962,8 +1034,8 @@ void R_RenderScene(void)
 
        if ((r_shadow_visiblelighting.integer || r_shadow_visiblevolumes.integer) && !r_showtrispass)
        {
-               R_ShadowVolumeLighting(r_shadow_visiblelighting.integer, r_shadow_visiblevolumes.integer);
-               R_TimeReport("shadowvolume");
+               R_ShadowVolumeLighting(true);
+               R_TimeReport("visiblevolume");
        }
 
        GL_ShowTrisColor(0.05, 0.05, 0.05, 1);