diff --git a/Quake/glquake.h b/Quake/glquake.h index f1d2bf36..5f49bb2d 100644 --- a/Quake/glquake.h +++ b/Quake/glquake.h @@ -286,7 +286,7 @@ int R_LightPoint (vec3_t p); void GL_SubdivideSurface (msurface_t *fa); void R_BuildLightMap (msurface_t *surf, byte *dest, int stride); void R_RenderDynamicLightmaps (msurface_t *fa); -void R_UploadLightmap (int lmap); +void R_UploadLightmaps (); void R_DrawTextureChains_ShowTris (void); void R_DrawBrushModel_ShowTris (entity_t *e); diff --git a/Quake/r_brush.c b/Quake/r_brush.c index a78b287d..4805e066 100644 --- a/Quake/r_brush.c +++ b/Quake/r_brush.c @@ -207,7 +207,6 @@ void R_DrawSequentialPoly (msurface_t *s) R_RenderDynamicLightmaps (s); GL_Bind (lightmap_textures[s->lightmaptexturenum]); - R_UploadLightmap(s->lightmaptexturenum); if (!gl_overbright.value) { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); @@ -317,7 +316,6 @@ void R_DrawSequentialPoly (msurface_t *s) GL_EnableMultitexture(); // selects TEXTURE1 GL_Bind (lightmap_textures[s->lightmaptexturenum]); R_RenderDynamicLightmaps (s); - R_UploadLightmap(s->lightmaptexturenum); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); @@ -355,7 +353,6 @@ void R_DrawSequentialPoly (msurface_t *s) //second pass -- lightmap with black fog, modulate blended R_RenderDynamicLightmaps (s); GL_Bind (lightmap_textures[s->lightmaptexturenum]); - R_UploadLightmap(s->lightmaptexturenum); glDepthMask (GL_FALSE); glEnable (GL_BLEND); glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR); //2x modulate @@ -398,7 +395,6 @@ void R_DrawSequentialPoly (msurface_t *s) GL_EnableMultitexture(); // selects TEXTURE1 GL_Bind (lightmap_textures[s->lightmaptexturenum]); R_RenderDynamicLightmaps (s); - R_UploadLightmap(s->lightmaptexturenum); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBegin(GL_POLYGON); v = s->polys->verts[0]; @@ -430,7 +426,6 @@ void R_DrawSequentialPoly (msurface_t *s) //second pass -- lightmap with black fog, modulate blended R_RenderDynamicLightmaps (s); GL_Bind (lightmap_textures[s->lightmaptexturenum]); - R_UploadLightmap(s->lightmaptexturenum); glDepthMask (GL_FALSE); glEnable (GL_BLEND); glBlendFunc (GL_ZERO, GL_SRC_COLOR); //modulate @@ -1150,7 +1145,7 @@ R_UploadLightmap -- johnfitz -- uploads the modified lightmap to opengl if neces assumes lightmap texture is already bound =============== */ -void R_UploadLightmap(int lmap) +static void R_UploadLightmap(int lmap) { glRect_t *theRect; @@ -1170,6 +1165,20 @@ void R_UploadLightmap(int lmap) rs_dynamiclightmaps++; } +void R_UploadLightmaps (void) +{ + int lmap; + + for (lmap = 0; lmap < MAX_LIGHTMAPS; lmap++) + { + if (!lightmap_modified[lmap]) + continue; + + GL_Bind (lightmap_textures[lmap]); + R_UploadLightmap(lmap); + } +} + /* ================ R_RebuildAllLightmaps -- johnfitz -- called when gl_overbright gets toggled diff --git a/Quake/r_world.c b/Quake/r_world.c index 9b880ba9..377ed568 100644 --- a/Quake/r_world.c +++ b/Quake/r_world.c @@ -373,7 +373,6 @@ void R_DrawTextureChains_Multitexture (void) } R_RenderDynamicLightmaps (s); GL_Bind (lightmap_textures[s->lightmaptexturenum]); - R_UploadLightmap(s->lightmaptexturenum); glBegin(GL_POLYGON); v = s->polys->verts[0]; for (j=0 ; jpolys->numverts ; j++, v+= VERTEXSIZE) @@ -587,7 +586,6 @@ void R_DrawLightmapChains (void) continue; GL_Bind (lightmap_textures[i]); - R_UploadLightmap(i); for (p = lightmap_polys[i]; p; p=p->chain) { glBegin (GL_POLYGON); @@ -613,6 +611,10 @@ void R_DrawWorld (void) if (!r_drawworld_cheatsafe) return; +// mh dynamic lightmap speedup: upload all modified lightmaps from the last +// frame in a single batch + R_UploadLightmaps (); + if (r_drawflat_cheatsafe) { glDisable (GL_TEXTURE_2D);