Skip to content

Commit

Permalink
Fix previous commit and clean up.
Browse files Browse the repository at this point in the history
Vertex lighting still needs full surface rebuild if lighting parameters
change.

Also merge LM_(Begin|End)Building calls into upload_world_surfaces().
  • Loading branch information
skullernet committed Dec 7, 2023
1 parent d6fb3da commit 4001f13
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/refresh/surf.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,9 @@ static void upload_world_surfaces(void)
if (!qglActiveTexture || (!qglClientActiveTexture && !gl_static.use_shaders))
Cvar_Set("gl_vertexlight", "1");

// begin building lightmaps
LM_BeginBuilding();

if (!gl_static.world.vertices)
qglBindBuffer(GL_ARRAY_BUFFER, gl_static.world.bufnum);

Expand Down Expand Up @@ -917,6 +920,9 @@ static void upload_world_surfaces(void)
qglBindBuffer(GL_ARRAY_BUFFER, 0);
}

// end building lightmaps
LM_EndBuilding();

gl_fullbright->modified = false;
gl_vertexlight->modified = false;
}
Expand Down Expand Up @@ -949,9 +955,16 @@ void GL_RebuildLighting(void)

// rebuild all surfaces if toggling lightmaps off/on
if (gl_fullbright->modified || gl_vertexlight->modified) {
LM_BeginBuilding();
upload_world_surfaces();
LM_EndBuilding();
return;
}

if (gl_fullbright->integer)
return;

// rebuild all surfaces if doing vertex lighting (and not fullbright)
if (gl_vertexlight->integer) {
upload_world_surfaces();
return;
}

Expand Down Expand Up @@ -1058,14 +1071,8 @@ void GL_LoadWorld(const char *name)
gl_static.nolm_mask = SURF_NOLM_MASK_REMASTER;
}

// begin building lightmaps
LM_BeginBuilding();

// post process all surfaces
upload_world_surfaces();

// end building lightmaps
LM_EndBuilding();

GL_ShowErrors(__func__);
}

0 comments on commit 4001f13

Please sign in to comment.