diff options
author | Johannes Schickel | 2016-03-04 00:14:22 +0100 |
---|---|---|
committer | Johannes Schickel | 2016-03-16 20:29:31 +0100 |
commit | 39100b613272523c2e36be213cc827857a08f824 (patch) | |
tree | 975c372986e91cd3f5f35b506e674466eb321fb6 /backends/graphics/opengl/pipelines/shader.cpp | |
parent | baca885cfce10acaa7a9892133aaa5b82c7183f7 (diff) | |
download | scummvm-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/shader.cpp')
-rw-r--r-- | backends/graphics/opengl/pipelines/shader.cpp | 16 |
1 files changed, 11 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)); } |