[Scummvm-git-logs] scummvm master -> 75f54a0ef858467abf51eac67716a9b7b65637da

grisenti noreply at scummvm.org
Wed Mar 29 17:32:34 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
75f54a0ef8 HPL1: cleanup duplicate code in renderer


Commit: 75f54a0ef858467abf51eac67716a9b7b65637da
    https://github.com/scummvm/scummvm/commit/75f54a0ef858467abf51eac67716a9b7b65637da
Author: grisenti (emanuele at grisenti.net)
Date: 2023-03-29T19:32:21+02:00

Commit Message:
HPL1: cleanup duplicate code in renderer

Changed paths:
    engines/hpl1/engine/graphics/Renderer3D.cpp


diff --git a/engines/hpl1/engine/graphics/Renderer3D.cpp b/engines/hpl1/engine/graphics/Renderer3D.cpp
index ff608ed043a..6baea1c7488 100644
--- a/engines/hpl1/engine/graphics/Renderer3D.cpp
+++ b/engines/hpl1/engine/graphics/Renderer3D.cpp
@@ -563,18 +563,20 @@ void cRenderer3D::InitSkyBox() {
 
 //-----------------------------------------------------------------------
 
+static void clearTextures(uint start, cRenderSettings &rendererSettings, iLowLevelGraphics *lowLevelGfx) {
+	for (uint i = start; i < MAX_TEXTUREUNITS; ++i) {
+		if (rendererSettings.mpTexture[i]) {
+			lowLevelGfx->SetTexture(i, nullptr);
+			rendererSettings.mpTexture[i] = nullptr;
+		}
+	}
+}
+
 void cRenderer3D::RenderFog(cCamera3D *apCamera) {
 	if (mRenderSettings.mbFogActive == false || !_solidFogProgram)
 		return;
-	int i;
-	//////////////////////////////////
-	// Set textures to NULL
-	for (i = 0; i < MAX_TEXTUREUNITS; ++i) {
-		if (mRenderSettings.mpTexture[i]) {
-			mpLowLevelGraphics->SetTexture(i, NULL);
-			mRenderSettings.mpTexture[i] = NULL;
-		}
-	}
+
+	clearTextures(0, mRenderSettings, mpLowLevelGraphics);
 
 	//////////////////////////////////
 	// Set fog program
@@ -586,7 +588,6 @@ void cRenderer3D::RenderFog(cCamera3D *apCamera) {
 	_solidFogProgram->SetFloat("fogStart", mRenderSettings.mfFogStart);
 	_solidFogProgram->SetFloat("fogEnd", mRenderSettings.mfFogEnd);
 
-
 	//////////////////////////////////
 	// Blend mode
 	mpLowLevelGraphics->SetBlendActive(true);
@@ -639,7 +640,7 @@ void cRenderer3D::RenderSkyBox(cCamera3D *apCamera) {
 	if (mbSkyBoxActive == false)
 		return;
 
-	Hpl1::logInfo(Hpl1::kDebugRenderer, "%s", "Drawing skybox");
+	Hpl1::logInfo(Hpl1::kDebugRenderer, "%s\n", "Drawing skybox");
 
 	if (mRenderSettings.gpuProgram) {
 		mRenderSettings.gpuProgram->UnBind();
@@ -655,14 +656,7 @@ void cRenderer3D::RenderSkyBox(cCamera3D *apCamera) {
 			Log(" Setting Vertex Buffer: NULL\n");
 	}
 
-	for (int i = 1; i < MAX_TEXTUREUNITS; ++i) {
-		if (mRenderSettings.mpTexture[i]) {
-			mpLowLevelGraphics->SetTexture(i, NULL);
-			mRenderSettings.mpTexture[i] = NULL;
-			if (mbLog)
-				Log(" Setting Texture %d : NULL\n", i);
-		}
-	}
+	clearTextures(1, mRenderSettings, mpLowLevelGraphics);
 
 	mRenderSettings.mbMatrixWasNULL = false;
 




More information about the Scummvm-git-logs mailing list