[Scummvm-cvs-logs] scummvm master -> 8161effc68e3853f4c92536ab06ed9736684f6bf

lordhoto lordhoto at gmail.com
Wed Mar 23 22:38:03 CET 2016


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

Summary:
2ebffd2da5 OPENGL: Fix black screen for some GL implementations with shaders.
8161effc68 OPENGL: Add assertions to check for valid attribute state.


Commit: 2ebffd2da5e9669a804a1dd8761ccd0d27533733
    https://github.com/scummvm/scummvm/commit/2ebffd2da5e9669a804a1dd8761ccd0d27533733
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2016-03-23T22:30:25+01:00

Commit Message:
OPENGL: Fix black screen for some GL implementations with shaders.

For compatibility location 0 is used to decide whether fixed function style
vertex information is used in old GL contexts. In some cases drivers might
assign the color information to be passed through attribute 0. This caused
the array attribute status for location 0 to be disabled and resulted in
wrong vertex data to be used.

Changed paths:
    backends/graphics/opengl/pipelines/shader.cpp
    backends/graphics/opengl/pipelines/shader.h



diff --git a/backends/graphics/opengl/pipelines/shader.cpp b/backends/graphics/opengl/pipelines/shader.cpp
index c7befe2..84c42e3 100644
--- a/backends/graphics/opengl/pipelines/shader.cpp
+++ b/backends/graphics/opengl/pipelines/shader.cpp
@@ -28,7 +28,7 @@ namespace OpenGL {
 
 #if !USE_FORCED_GLES
 ShaderPipeline::ShaderPipeline(Shader *shader)
-    : _activeShader(shader) {
+    : _activeShader(shader), _colorAttributes() {
 	_vertexAttribLocation = shader->getAttributeLocation("position");
 	_texCoordAttribLocation = shader->getAttributeLocation("texCoordIn");
 	_colorAttribLocation = shader->getAttributeLocation("blendColorIn");
@@ -37,6 +37,7 @@ ShaderPipeline::ShaderPipeline(Shader *shader)
 void ShaderPipeline::activateInternal() {
 	GL_CALL(glEnableVertexAttribArray(_vertexAttribLocation));
 	GL_CALL(glEnableVertexAttribArray(_texCoordAttribLocation));
+	GL_CALL(glEnableVertexAttribArray(_colorAttribLocation));
 
 	if (g_context.multitextureSupported) {
 		GL_CALL(glActiveTexture(GL_TEXTURE0));
@@ -48,12 +49,21 @@ void ShaderPipeline::activateInternal() {
 void ShaderPipeline::deactivateInternal() {
 	GL_CALL(glDisableVertexAttribArray(_vertexAttribLocation));
 	GL_CALL(glDisableVertexAttribArray(_texCoordAttribLocation));
+	GL_CALL(glDisableVertexAttribArray(_colorAttribLocation));
 
 	_activeShader->deactivate();
 }
 
 void ShaderPipeline::setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
-	GL_CALL(glVertexAttrib4f(_colorAttribLocation, r, g, b, a));
+	GLfloat *dst = _colorAttributes;
+	for (uint i = 0; i < 4; ++i) {
+		*dst++ = r;
+		*dst++ = g;
+		*dst++ = b;
+		*dst++ = a;
+	}
+
+	GL_CALL(glVertexAttribPointer(_colorAttribLocation, 4, GL_FLOAT, GL_FALSE, 0, _colorAttributes));
 }
 
 void ShaderPipeline::drawTexture(const GLTexture &texture, const GLfloat *coordinates) {
diff --git a/backends/graphics/opengl/pipelines/shader.h b/backends/graphics/opengl/pipelines/shader.h
index 95167ee..6159607 100644
--- a/backends/graphics/opengl/pipelines/shader.h
+++ b/backends/graphics/opengl/pipelines/shader.h
@@ -48,6 +48,8 @@ protected:
 	GLint _texCoordAttribLocation;
 	GLint _colorAttribLocation;
 
+	GLfloat _colorAttributes[4*4];
+
 	Shader *const _activeShader;
 };
 #endif // !USE_FORCED_GLES


Commit: 8161effc68e3853f4c92536ab06ed9736684f6bf
    https://github.com/scummvm/scummvm/commit/8161effc68e3853f4c92536ab06ed9736684f6bf
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2016-03-23T22:37:16+01:00

Commit Message:
OPENGL: Add assertions to check for valid attribute state.

Changed paths:
    backends/graphics/opengl/pipelines/shader.cpp



diff --git a/backends/graphics/opengl/pipelines/shader.cpp b/backends/graphics/opengl/pipelines/shader.cpp
index 84c42e3..8e38458 100644
--- a/backends/graphics/opengl/pipelines/shader.cpp
+++ b/backends/graphics/opengl/pipelines/shader.cpp
@@ -32,6 +32,18 @@ ShaderPipeline::ShaderPipeline(Shader *shader)
 	_vertexAttribLocation = shader->getAttributeLocation("position");
 	_texCoordAttribLocation = shader->getAttributeLocation("texCoordIn");
 	_colorAttribLocation = shader->getAttributeLocation("blendColorIn");
+
+	assert(_vertexAttribLocation   != -1);
+	assert(_texCoordAttribLocation != -1);
+	assert(_colorAttribLocation    != -1);
+
+	// One of the attributes needs to be passed through location 0, otherwise
+	// we get no output for GL contexts due to GL compatibility reasons. Let's
+	// check whether this ever happens. If this ever gets hit, we need to
+	// enable location 0 and pass some dummy values through it to fix output.
+	assert(   _vertexAttribLocation == 0
+	       || _texCoordAttribLocation == 0
+	       || _colorAttribLocation == 0);
 }
 
 void ShaderPipeline::activateInternal() {






More information about the Scummvm-git-logs mailing list