aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/opengl
diff options
context:
space:
mode:
authorJohannes Schickel2016-03-23 22:30:22 +0100
committerJohannes Schickel2016-03-23 22:30:25 +0100
commit2ebffd2da5e9669a804a1dd8761ccd0d27533733 (patch)
treebcb1d927ef92d035e465e4a1b2bf02f47440c98d /backends/graphics/opengl
parentf299e96273cb73df34ec229aa0639db140b99286 (diff)
downloadscummvm-rg350-2ebffd2da5e9669a804a1dd8761ccd0d27533733.tar.gz
scummvm-rg350-2ebffd2da5e9669a804a1dd8761ccd0d27533733.tar.bz2
scummvm-rg350-2ebffd2da5e9669a804a1dd8761ccd0d27533733.zip
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.
Diffstat (limited to 'backends/graphics/opengl')
-rw-r--r--backends/graphics/opengl/pipelines/shader.cpp14
-rw-r--r--backends/graphics/opengl/pipelines/shader.h2
2 files changed, 14 insertions, 2 deletions
diff --git a/backends/graphics/opengl/pipelines/shader.cpp b/backends/graphics/opengl/pipelines/shader.cpp
index c7befe22b8..84c42e30ed 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 95167ee03f..6159607099 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