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

aquadran aquadran at gmail.com
Tue Nov 9 08:22:45 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:
aa3718f0e8 STARK: Move texture binding out of vertices loop


Commit: aa3718f0e8755aba24f7ce9c48a86e69d4001494
    https://github.com/scummvm/scummvm/commit/aa3718f0e8755aba24f7ce9c48a86e69d4001494
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2021-11-09T09:22:41+01:00

Commit Message:
STARK: Move texture binding out of vertices loop

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


diff --git a/engines/stark/gfx/openglactor.cpp b/engines/stark/gfx/openglactor.cpp
index 3c50891c66..e68150d4aa 100644
--- a/engines/stark/gfx/openglactor.cpp
+++ b/engines/stark/gfx/openglactor.cpp
@@ -114,19 +114,22 @@ void OpenGLActorRenderer::render(const Math::Vector3d &position, float direction
 		const Material *material = mats[(*face)->materialId];
 		Math::Vector3d color;
 		const Gfx::Texture *tex = resolveTexture(material);
+		if (tex) {
+			tex->bind();
+			glEnable(GL_TEXTURE_2D);
+		} else {
+			glBindTexture(GL_TEXTURE_2D, 0);
+			glDisable(GL_TEXTURE_2D);
+		}
 		auto vertexIndices = _faceEBO[*face];
 		auto numVertexIndices = (*face)->vertexIndices.size();
 		for (uint32 i = 0; i < numVertexIndices; i++) {
 			if (tex) {
-				tex->bind();
-				glEnable(GL_TEXTURE_2D);
 				if (_gfx->computeLightsEnabled())
 					color = Math::Vector3d(1.0f, 1.0f, 1.0f);
 				else
 					glColor3f(1.0f, 1.0f, 1.0f);
 			} else {
-				glBindTexture(GL_TEXTURE_2D, 0);
-				glDisable(GL_TEXTURE_2D);
 				if (_gfx->computeLightsEnabled())
 					color = Math::Vector3d(material->r, material->g, material->b);
 				else
diff --git a/engines/stark/gfx/openglprop.cpp b/engines/stark/gfx/openglprop.cpp
index 11173a953e..327ca55bdf 100644
--- a/engines/stark/gfx/openglprop.cpp
+++ b/engines/stark/gfx/openglprop.cpp
@@ -86,6 +86,13 @@ void OpenGLPropRenderer::render(const Math::Vector3d &position, float direction,
 		const Material &material = materials[face->materialId];
 		Math::Vector3d color;
 		const Gfx::Texture *tex = _texture->getTexture(material.texture);
+		if (tex) {
+			tex->bind();
+			glEnable(GL_TEXTURE_2D);
+		} else {
+			glBindTexture(GL_TEXTURE_2D, 0);
+			glDisable(GL_TEXTURE_2D);
+		}
 		auto vertexIndices = _faceEBO[face];
 		auto numVertexIndices = (face)->vertexIndices.size();
 		if (!_gfx->computeLightsEnabled()) {
@@ -98,8 +105,6 @@ void OpenGLPropRenderer::render(const Math::Vector3d &position, float direction,
 			uint32 index = vertexIndices[i];
 			auto vertex = _faceVBO[index];
 			if (tex) {
-				tex->bind();
-				glEnable(GL_TEXTURE_2D);
 				if (_gfx->computeLightsEnabled())
 					color = Math::Vector3d(1.0f, 1.0f, 1.0f);
 				else
@@ -112,8 +117,6 @@ void OpenGLPropRenderer::render(const Math::Vector3d &position, float direction,
 					vertex.texT = 1.0f - vertex.stexT;
 				}
 			} else {
-				glBindTexture(GL_TEXTURE_2D, 0);
-				glDisable(GL_TEXTURE_2D);
 				if (_gfx->computeLightsEnabled())
 					color = Math::Vector3d(material.r, material.g, material.b);
 				else
diff --git a/engines/stark/gfx/tinyglactor.cpp b/engines/stark/gfx/tinyglactor.cpp
index 529c504bcc..43f1137ca4 100644
--- a/engines/stark/gfx/tinyglactor.cpp
+++ b/engines/stark/gfx/tinyglactor.cpp
@@ -104,16 +104,19 @@ void TinyGLActorRenderer::render(const Math::Vector3d &position, float direction
 		const Material *material = mats[(*face)->materialId];
 		Math::Vector3d color;
 		const Gfx::Texture *tex = resolveTexture(material);
+		if (tex) {
+			tex->bind();
+			tglEnable(TGL_TEXTURE_2D);
+		} else {
+			tglBindTexture(TGL_TEXTURE_2D, 0);
+			tglDisable(TGL_TEXTURE_2D);
+		}
 		auto vertexIndices = _faceEBO[*face];
 		auto numVertexIndices = (*face)->vertexIndices.size();
 		for (uint32 i = 0; i < numVertexIndices; i++) {
 			if (tex) {
-				tex->bind();
-				tglEnable(TGL_TEXTURE_2D);
 				color = Math::Vector3d(1.0f, 1.0f, 1.0f);
 			} else {
-				tglBindTexture(TGL_TEXTURE_2D, 0);
-				tglDisable(TGL_TEXTURE_2D);
 				color = Math::Vector3d(material->r, material->g, material->b);
 			}
 			uint32 index = vertexIndices[i];
diff --git a/engines/stark/gfx/tinyglprop.cpp b/engines/stark/gfx/tinyglprop.cpp
index 06d4521b22..66a400c3e0 100644
--- a/engines/stark/gfx/tinyglprop.cpp
+++ b/engines/stark/gfx/tinyglprop.cpp
@@ -78,14 +78,19 @@ void TinyGLPropRenderer::render(const Math::Vector3d &position, float direction,
 		const Material &material = materials[face->materialId];
 		Math::Vector3d color;
 		const Gfx::Texture *tex = _texture->getTexture(material.texture);
+		if (tex) {
+			tex->bind();
+			tglEnable(TGL_TEXTURE_2D);
+		} else {
+			tglBindTexture(TGL_TEXTURE_2D, 0);
+			tglDisable(TGL_TEXTURE_2D);
+		}
 		auto vertexIndices = _faceEBO[face];
 		auto numVertexIndices = (face)->vertexIndices.size();
 		for (uint32 i = 0; i < numVertexIndices; i++) {
 			uint32 index = vertexIndices[i];
 			auto vertex = _faceVBO[index];
 			if (tex) {
-				tex->bind();
-				tglEnable(TGL_TEXTURE_2D);
 				color = Math::Vector3d(1.0f, 1.0f, 1.0f);
 				if (material.doubleSided) {
 					vertex.texS = vertex.stexS;
@@ -95,8 +100,6 @@ void TinyGLPropRenderer::render(const Math::Vector3d &position, float direction,
 					vertex.texT = 1.0f - vertex.stexT;
 				}
 			} else {
-				tglBindTexture(TGL_TEXTURE_2D, 0);
-				tglDisable(TGL_TEXTURE_2D);
 				color = Math::Vector3d(material.r, material.g, material.b);
 			}
 




More information about the Scummvm-git-logs mailing list