aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/opengl/pipelines
diff options
context:
space:
mode:
authorJohannes Schickel2016-03-04 00:14:22 +0100
committerJohannes Schickel2016-03-16 20:29:31 +0100
commit39100b613272523c2e36be213cc827857a08f824 (patch)
tree975c372986e91cd3f5f35b506e674466eb321fb6 /backends/graphics/opengl/pipelines
parentbaca885cfce10acaa7a9892133aaa5b82c7183f7 (diff)
downloadscummvm-rg350-39100b613272523c2e36be213cc827857a08f824.tar.gz
scummvm-rg350-39100b613272523c2e36be213cc827857a08f824.tar.bz2
scummvm-rg350-39100b613272523c2e36be213cc827857a08f824.zip
OPENGL: Do not hardcode any uniform/attribute handling in Shader.
Diffstat (limited to 'backends/graphics/opengl/pipelines')
-rw-r--r--backends/graphics/opengl/pipelines/shader.cpp16
-rw-r--r--backends/graphics/opengl/pipelines/shader.h4
2 files changed, 15 insertions, 5 deletions
diff --git a/backends/graphics/opengl/pipelines/shader.cpp b/backends/graphics/opengl/pipelines/shader.cpp
index 46e81423c5..c7befe22b8 100644
--- a/backends/graphics/opengl/pipelines/shader.cpp
+++ b/backends/graphics/opengl/pipelines/shader.cpp
@@ -29,11 +29,14 @@ namespace OpenGL {
#if !USE_FORCED_GLES
ShaderPipeline::ShaderPipeline(Shader *shader)
: _activeShader(shader) {
+ _vertexAttribLocation = shader->getAttributeLocation("position");
+ _texCoordAttribLocation = shader->getAttributeLocation("texCoordIn");
+ _colorAttribLocation = shader->getAttributeLocation("blendColorIn");
}
void ShaderPipeline::activateInternal() {
- GL_CALL(glEnableVertexAttribArray(kPositionAttribLocation));
- GL_CALL(glEnableVertexAttribArray(kTexCoordAttribLocation));
+ GL_CALL(glEnableVertexAttribArray(_vertexAttribLocation));
+ GL_CALL(glEnableVertexAttribArray(_texCoordAttribLocation));
if (g_context.multitextureSupported) {
GL_CALL(glActiveTexture(GL_TEXTURE0));
@@ -43,18 +46,21 @@ void ShaderPipeline::activateInternal() {
}
void ShaderPipeline::deactivateInternal() {
+ GL_CALL(glDisableVertexAttribArray(_vertexAttribLocation));
+ GL_CALL(glDisableVertexAttribArray(_texCoordAttribLocation));
+
_activeShader->deactivate();
}
void ShaderPipeline::setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
- GL_CALL(glVertexAttrib4f(kColorAttribLocation, r, g, b, a));
+ GL_CALL(glVertexAttrib4f(_colorAttribLocation, r, g, b, a));
}
void ShaderPipeline::drawTexture(const GLTexture &texture, const GLfloat *coordinates) {
texture.bind();
- GL_CALL(glVertexAttribPointer(kTexCoordAttribLocation, 2, GL_FLOAT, GL_FALSE, 0, texture.getTexCoords()));
- GL_CALL(glVertexAttribPointer(kPositionAttribLocation, 2, GL_FLOAT, GL_FALSE, 0, coordinates));
+ GL_CALL(glVertexAttribPointer(_texCoordAttribLocation, 2, GL_FLOAT, GL_FALSE, 0, texture.getTexCoords()));
+ GL_CALL(glVertexAttribPointer(_vertexAttribLocation, 2, GL_FLOAT, GL_FALSE, 0, coordinates));
GL_CALL(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
}
diff --git a/backends/graphics/opengl/pipelines/shader.h b/backends/graphics/opengl/pipelines/shader.h
index 8e82bd7a31..95167ee03f 100644
--- a/backends/graphics/opengl/pipelines/shader.h
+++ b/backends/graphics/opengl/pipelines/shader.h
@@ -44,6 +44,10 @@ protected:
virtual void activateInternal();
virtual void deactivateInternal();
+ GLint _vertexAttribLocation;
+ GLint _texCoordAttribLocation;
+ GLint _colorAttribLocation;
+
Shader *const _activeShader;
};
#endif // !USE_FORCED_GLES