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

aquadran noreply at scummvm.org
Thu Dec 30 12:08:18 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:
cb66523652 WME3D: Cleanup OpenGL calls


Commit: cb665236520770c45ad951b246b7899841b62209
    https://github.com/scummvm/scummvm/commit/cb665236520770c45ad951b246b7899841b62209
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2021-12-30T13:08:14+01:00

Commit Message:
WME3D: Cleanup OpenGL calls

Changed paths:
    engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
    engines/wintermute/base/gfx/opengl/mesh3ds_opengl.cpp
    engines/wintermute/base/gfx/opengl/meshx_opengl.cpp
    engines/wintermute/base/gfx/opengl/shadow_volume_opengl.cpp


diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
index 38afbfeb608..1d82c0b432f 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
@@ -189,7 +189,7 @@ void BaseRenderOpenGL3D::displayShadow(BaseObject *object, const Math::Vector3d
 
 	glLoadMatrixf(worldTransformation.getData());
 
-	glDepthMask(false);
+	glDepthMask(GL_FALSE);
 	glEnable(GL_TEXTURE_2D);
 	static_cast<BaseSurfaceOpenGL3D *>(shadowImage)->setTexture();
 
@@ -203,7 +203,11 @@ void BaseRenderOpenGL3D::displayShadow(BaseObject *object, const Math::Vector3d
 
 	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
-	glDepthMask(true);
+	glDisableClientState(GL_VERTEX_ARRAY);
+	glDisableClientState(GL_NORMAL_ARRAY);
+	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+
+	glDepthMask(GL_TRUE);
 	glLoadMatrixf(_lastViewMatrix.getData());
 }
 
@@ -267,6 +271,7 @@ void BaseRenderOpenGL3D::fadeToColor(byte r, byte g, byte b, byte a) {
 	glEnable(GL_BLEND);
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 	glBindTexture(GL_TEXTURE_2D, 0);
+	glDisable(GL_TEXTURE_2D);
 
 	glEnableClientState(GL_VERTEX_ARRAY);
 	glEnableClientState(GL_COLOR_ARRAY);
@@ -276,6 +281,9 @@ void BaseRenderOpenGL3D::fadeToColor(byte r, byte g, byte b, byte a) {
 
 	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
+	glDisableClientState(GL_VERTEX_ARRAY);
+	glDisableClientState(GL_COLOR_ARRAY);
+
 	setup2D(true);
 }
 
@@ -298,9 +306,9 @@ bool BaseRenderOpenGL3D::drawLine(int x1, int y1, int x2, int y2, uint32 color)
 	byte b = RGBCOLGetB(color);
 
 	glBegin(GL_LINES);
-	glColor4b(r, g, b, a);
-	glVertex3f(x1, y1, 0.9f);
-	glVertex3f(x2, y2, 0.9f);
+		glColor4ub(r, g, b, a);
+		glVertex3f(x1, y1, 0.9f);
+		glVertex3f(x2, y2, 0.9f);
 	glEnd();
 
 	return true;
@@ -444,9 +452,7 @@ bool BaseRenderOpenGL3D::setup2D(bool force) {
 		glDisable(GL_LIGHTING);
 		glDisable(GL_DEPTH_TEST);
 		glDisable(GL_STENCIL_TEST);
-		glDisable(GL_CLIP_PLANE0);
 		glDisable(GL_FOG);
-		glLightModeli(GL_LIGHT_MODEL_AMBIENT, 0);
 
 		glEnable(GL_CULL_FACE);
 		glFrontFace(GL_CCW);
@@ -535,6 +541,7 @@ bool BaseRenderOpenGL3D::setupLines() {
 		glDisable(GL_DEPTH_TEST);
 		glEnable(GL_BLEND);
 		glEnable(GL_ALPHA_TEST);
+		glDisable(GL_TEXTURE_2D);
 		glBindTexture(GL_TEXTURE_2D, 0);
 	}
 
@@ -673,6 +680,10 @@ bool BaseRenderOpenGL3D::drawSpriteEx(BaseSurfaceOpenGL3D &tex, const Wintermute
 
 	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
+	glDisableClientState(GL_COLOR_ARRAY);
+	glDisableClientState(GL_VERTEX_ARRAY);
+	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+
 	if (alphaDisable) {
 		glEnable(GL_ALPHA_TEST);
 	}
@@ -690,10 +701,10 @@ void BaseRenderOpenGL3D::renderSceneGeometry(const BaseArray<AdWalkplane *> &pla
 	glDisable(GL_DEPTH_TEST);
 	glFrontFace(GL_CCW);
 	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-	glDisableClientState(GL_COLOR_ARRAY);
 	glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
 	glEnable(GL_COLOR_MATERIAL);
 
+	glDisable(GL_TEXTURE_2D);
 	glBindTexture(GL_TEXTURE_2D, 0);
 
 	// render walk planes
@@ -757,6 +768,7 @@ void BaseRenderOpenGL3D::renderShadowGeometry(const BaseArray<AdWalkplane *> &pl
 	glBlendFunc(GL_ZERO, GL_ONE);
 
 	glFrontFace(GL_CCW);
+	glDisable(GL_TEXTURE_2D);
 	glBindTexture(GL_TEXTURE_2D, 0);
 
 	// render walk planes
diff --git a/engines/wintermute/base/gfx/opengl/mesh3ds_opengl.cpp b/engines/wintermute/base/gfx/opengl/mesh3ds_opengl.cpp
index 220bf30661c..d8806be2f35 100644
--- a/engines/wintermute/base/gfx/opengl/mesh3ds_opengl.cpp
+++ b/engines/wintermute/base/gfx/opengl/mesh3ds_opengl.cpp
@@ -46,6 +46,7 @@ void Mesh3DSOpenGL::render() {
 	glEnableClientState(GL_VERTEX_ARRAY);
 	glVertexPointer(3, GL_FLOAT, sizeof(GeometryVertex), reinterpret_cast<byte *>(_vertexData));
 	glDrawElements(GL_TRIANGLES, _indexCount, GL_UNSIGNED_SHORT, _indexData);
+	glDisableClientState(GL_VERTEX_ARRAY);
 }
 
 } // namespace Wintermute
diff --git a/engines/wintermute/base/gfx/opengl/meshx_opengl.cpp b/engines/wintermute/base/gfx/opengl/meshx_opengl.cpp
index fd4d5829e49..6eb61f690ce 100644
--- a/engines/wintermute/base/gfx/opengl/meshx_opengl.cpp
+++ b/engines/wintermute/base/gfx/opengl/meshx_opengl.cpp
@@ -57,7 +57,9 @@ bool MeshXOpenGL::render(ModelX *model) {
 		glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, _materials[materialIndex]->_emissive.data);
 		glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, _materials[materialIndex]->_shininess);
 
+		bool textureEnable = false;
 		if (_materials[materialIndex]->getSurface()) {
+			textureEnable = true;
 			glEnable(GL_TEXTURE_2D);
 			static_cast<BaseSurfaceOpenGL3D *>(_materials[materialIndex]->getSurface())->setTexture();
 		} else {
@@ -67,13 +69,19 @@ bool MeshXOpenGL::render(ModelX *model) {
 
 		glEnableClientState(GL_VERTEX_ARRAY);
 		glEnableClientState(GL_NORMAL_ARRAY);
-		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+		if (textureEnable)
+			glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 
 		glVertexPointer(3, GL_FLOAT, kVertexComponentCount * sizeof(float), _vertexData + kPositionOffset);
 		glNormalPointer(GL_FLOAT, kVertexComponentCount * sizeof(float), _vertexData + kNormalOffset);
-		glTexCoordPointer(2, GL_FLOAT, kVertexComponentCount * sizeof(float), _vertexData + kTextureCoordOffset);
+		if (textureEnable)
+			glTexCoordPointer(2, GL_FLOAT, kVertexComponentCount * sizeof(float), _vertexData + kTextureCoordOffset);
 
 		glDrawElements(GL_TRIANGLES, _indexRanges[i + 1] - _indexRanges[i], GL_UNSIGNED_SHORT, _indexData.data() + _indexRanges[i]);
+
+		glDisableClientState(GL_VERTEX_ARRAY);
+		glDisableClientState(GL_NORMAL_ARRAY);
+		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 	}
 
 	glBindTexture(GL_TEXTURE_2D, 0);
diff --git a/engines/wintermute/base/gfx/opengl/shadow_volume_opengl.cpp b/engines/wintermute/base/gfx/opengl/shadow_volume_opengl.cpp
index 6c3892af3bc..1e6b5700ef1 100644
--- a/engines/wintermute/base/gfx/opengl/shadow_volume_opengl.cpp
+++ b/engines/wintermute/base/gfx/opengl/shadow_volume_opengl.cpp
@@ -47,12 +47,12 @@ ShadowVolumeOpenGL::~ShadowVolumeOpenGL() {
 //////////////////////////////////////////////////////////////////////////
 bool ShadowVolumeOpenGL::render() {
 	glBindTexture(GL_TEXTURE_2D, 0);
+	glDisable(GL_TEXTURE_2D);
 
 	glEnableClientState(GL_VERTEX_ARRAY);
-	glDisableClientState(GL_COLOR_ARRAY);
-	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 	glVertexPointer(3, GL_FLOAT, 0, _vertices.data());
 	glDrawArrays(GL_TRIANGLES, 0, _vertices.size());
+	glDisableClientState(GL_VERTEX_ARRAY);
 
 	return true;
 }
@@ -62,6 +62,8 @@ bool ShadowVolumeOpenGL::renderToStencilBuffer() {
 	// Disable z-buffer writes (note: z-testing still occurs), and enable the
 	// stencil-buffer
 	glDepthMask(GL_FALSE);
+	glDisable(GL_TEXTURE_2D);
+	glDisable(GL_LIGHTING);
 	glEnable(GL_STENCIL_TEST);
 	glEnable(GL_CULL_FACE);
 
@@ -72,8 +74,6 @@ bool ShadowVolumeOpenGL::renderToStencilBuffer() {
 	glStencilFunc(GL_ALWAYS, 0x1, 0xFFFFFFFF);
 
 	glShadeModel(GL_FLAT);
-	glDisable(GL_LIGHTING);
-
 	// Make sure that no pixels get drawn to the frame buffer
 	glEnable(GL_BLEND);
 	glBlendFunc(GL_ZERO, GL_ONE);
@@ -125,8 +125,6 @@ bool ShadowVolumeOpenGL::renderToScene() {
 
 	glEnableClientState(GL_COLOR_ARRAY);
 	glEnableClientState(GL_VERTEX_ARRAY);
-	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-	glDisableClientState(GL_NORMAL_ARRAY);
 
 	// Draw a big, gray square
 	glVertexPointer(3, GL_FLOAT, sizeof(ShadowVertex), &_shadowMask[0].x);
@@ -134,6 +132,9 @@ bool ShadowVolumeOpenGL::renderToScene() {
 
 	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
+	glDisableClientState(GL_COLOR_ARRAY);
+	glDisableClientState(GL_VERTEX_ARRAY);
+
 	// Restore render states
 	glEnable(GL_DEPTH_TEST);
 	glDisable(GL_STENCIL_TEST);




More information about the Scummvm-git-logs mailing list