[Scummvm-git-logs] scummvm master -> d48524ca9f58b857c12430444afa305864a3de89

aquadran aquadran at gmail.com
Sun Apr 4 05:10:49 UTC 2021


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:
d48524ca9f STARK: Avoid color material calls in loop


Commit: d48524ca9f58b857c12430444afa305864a3de89
    https://github.com/scummvm/scummvm/commit/d48524ca9f58b857c12430444afa305864a3de89
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2021-04-04T07:10:41+02:00

Commit Message:
STARK: Avoid color material calls in loop

Changed paths:
    engines/stark/gfx/openglactor.cpp
    engines/stark/gfx/openglprop.cpp


diff --git a/engines/stark/gfx/openglactor.cpp b/engines/stark/gfx/openglactor.cpp
index 86a308d834..9d775743f1 100644
--- a/engines/stark/gfx/openglactor.cpp
+++ b/engines/stark/gfx/openglactor.cpp
@@ -99,11 +99,11 @@ void OpenGLActorRenderer::render(const Math::Vector3d &position, float direction
 	Common::Array<Material *> mats = _model->getMaterials();
 	const Common::Array<BoneNode *> &bones = _model->getBones();
 
+	glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
+	glEnable(GL_COLOR_MATERIAL);
 	for (Common::Array<Face *>::const_iterator face = faces.begin(); face != faces.end(); ++face) {
 		const Material *material = mats[(*face)->materialId];
 		const Gfx::Texture *tex = resolveTexture(material);
-		glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
-		glEnable(GL_COLOR_MATERIAL);
 		if (tex) {
 			tex->bind();
 			glColor3f(1.0f, 1.0f, 1.0f);
@@ -183,8 +183,8 @@ void OpenGLActorRenderer::render(const Math::Vector3d &position, float direction
 		glDisableClientState(GL_NORMAL_ARRAY);
 		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 
-		glDisable(GL_COLOR_MATERIAL);
 	}
+	glDisable(GL_COLOR_MATERIAL);
 
 
 	if (drawShadow) {
diff --git a/engines/stark/gfx/openglprop.cpp b/engines/stark/gfx/openglprop.cpp
index 3fd6e6f6f8..5e6e1bd9e0 100644
--- a/engines/stark/gfx/openglprop.cpp
+++ b/engines/stark/gfx/openglprop.cpp
@@ -67,6 +67,7 @@ void OpenGLPropRenderer::render(const Math::Vector3d &position, float direction,
 	const Common::Array<Face> &faces = _model->getFaces();
 	const Common::Array<Material> &materials = _model->getMaterials();
 
+	glEnable(GL_COLOR_MATERIAL);
 	for (Common::Array<Face>::const_iterator face = faces.begin(); face != faces.end(); ++face) {
 		const Material &material = materials[face->materialId];
 
@@ -76,7 +77,6 @@ void OpenGLPropRenderer::render(const Math::Vector3d &position, float direction,
 			glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
 		else
 			glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
-		glEnable(GL_COLOR_MATERIAL);
 		if (tex) {
 			tex->bind();
 			glColor3f(1.0f, 1.0f, 1.0f);
@@ -102,8 +102,8 @@ void OpenGLPropRenderer::render(const Math::Vector3d &position, float direction,
 		glDisableClientState(GL_NORMAL_ARRAY);
 		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 
-		glDisable(GL_COLOR_MATERIAL);
 	}
+	glDisable(GL_COLOR_MATERIAL);
 
 }
 




More information about the Scummvm-git-logs mailing list