aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2016-02-29 00:04:33 +0100
committerJohannes Schickel2016-03-16 20:29:31 +0100
commit3f9852eb202b55b93f6e3121ce473951bff033cd (patch)
tree81b0b954eddec39f4e6c6ce052126d53dfaee224
parent26f106497a863b84c502d122b5ba749176b2c426 (diff)
downloadscummvm-rg350-3f9852eb202b55b93f6e3121ce473951bff033cd.tar.gz
scummvm-rg350-3f9852eb202b55b93f6e3121ce473951bff033cd.tar.bz2
scummvm-rg350-3f9852eb202b55b93f6e3121ce473951bff033cd.zip
OPENGL: Make shader pipelines use fixed shaders.
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp10
-rw-r--r--backends/graphics/opengl/pipelines/clut8.cpp7
-rw-r--r--backends/graphics/opengl/pipelines/clut8.h2
-rw-r--r--backends/graphics/opengl/pipelines/pipeline.h18
-rw-r--r--backends/graphics/opengl/pipelines/shader.cpp17
-rw-r--r--backends/graphics/opengl/pipelines/shader.h8
6 files changed, 10 insertions, 52 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index c5bc99eb70..4d6a00a3b3 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -851,7 +851,8 @@ void OpenGLGraphicsManager::notifyContextCreate(const Graphics::PixelFormat &def
#if !USE_FORCED_GLES
if (g_context.shadersSupported) {
- _pipeline = new ShaderPipeline();
+ ShaderMan.notifyCreate();
+ _pipeline = new ShaderPipeline(ShaderMan.query(ShaderManager::kDefault));
}
#endif
@@ -863,13 +864,6 @@ void OpenGLGraphicsManager::notifyContextCreate(const Graphics::PixelFormat &def
g_context.setPipeline(_pipeline);
-#if !USE_FORCED_GLES
- if (g_context.shadersSupported) {
- ShaderMan.notifyCreate();
- g_context.getActivePipeline()->setShader(ShaderMan.query(ShaderManager::kDefault));
- }
-#endif
-
// Disable 3D properties.
GL_CALL(glDisable(GL_CULL_FACE));
GL_CALL(glDisable(GL_DEPTH_TEST));
diff --git a/backends/graphics/opengl/pipelines/clut8.cpp b/backends/graphics/opengl/pipelines/clut8.cpp
index 69dd0a3e28..9f2aa94b90 100644
--- a/backends/graphics/opengl/pipelines/clut8.cpp
+++ b/backends/graphics/opengl/pipelines/clut8.cpp
@@ -28,12 +28,7 @@ namespace OpenGL {
#if !USE_FORCED_GLES
CLUT8LookUpPipeline::CLUT8LookUpPipeline()
- : _paletteTexture(nullptr) {
- ShaderPipeline::setShader(ShaderMan.query(ShaderManager::kCLUT8LookUp));
-}
-
-Shader *CLUT8LookUpPipeline::setShader(Shader *shader) {
- return ShaderPipeline::setShader(ShaderMan.query(ShaderManager::kCLUT8LookUp));
+ : ShaderPipeline(ShaderMan.query(ShaderManager::kCLUT8LookUp)), _paletteTexture(nullptr) {
}
void CLUT8LookUpPipeline::drawTexture(const GLTexture &texture, const GLfloat *coordinates) {
diff --git a/backends/graphics/opengl/pipelines/clut8.h b/backends/graphics/opengl/pipelines/clut8.h
index fed6cbfe32..16724e4652 100644
--- a/backends/graphics/opengl/pipelines/clut8.h
+++ b/backends/graphics/opengl/pipelines/clut8.h
@@ -32,8 +32,6 @@ class CLUT8LookUpPipeline : public ShaderPipeline {
public:
CLUT8LookUpPipeline();
- virtual Shader *setShader(Shader *shader);
-
void setPaletteTexture(const GLTexture *paletteTexture) { _paletteTexture = paletteTexture; }
virtual void drawTexture(const GLTexture &texture, const GLfloat *coordinates);
diff --git a/backends/graphics/opengl/pipelines/pipeline.h b/backends/graphics/opengl/pipelines/pipeline.h
index 8545ef2101..9f32d33b95 100644
--- a/backends/graphics/opengl/pipelines/pipeline.h
+++ b/backends/graphics/opengl/pipelines/pipeline.h
@@ -29,9 +29,6 @@
namespace OpenGL {
class Framebuffer;
-#if !USE_FORCED_GLES
-class Shader;
-#endif
/**
* Interface for OpenGL pipeline functionality.
@@ -67,21 +64,6 @@ public:
*/
Framebuffer *setFramebuffer(Framebuffer *framebuffer);
-#if !USE_FORCED_GLES
- /**
- * Set shader program.
- *
- * Not all pipelines support shader programs. This is method exits at this
- * place for convenience only.
- *
- * Client is responsible for any memory management related to shader.
- *
- * @param shader Shader program to activate.
- * @return Formerly active shader program.
- */
- virtual Shader *setShader(Shader *shader) { return nullptr; }
-#endif
-
/**
* Set modulation color.
*
diff --git a/backends/graphics/opengl/pipelines/shader.cpp b/backends/graphics/opengl/pipelines/shader.cpp
index f408b682ab..69af911fc6 100644
--- a/backends/graphics/opengl/pipelines/shader.cpp
+++ b/backends/graphics/opengl/pipelines/shader.cpp
@@ -27,8 +27,8 @@
namespace OpenGL {
#if !USE_FORCED_GLES
-ShaderPipeline::ShaderPipeline()
- : _activeShader(nullptr) {
+ShaderPipeline::ShaderPipeline(Shader *shader)
+ : _activeShader(shader) {
}
void ShaderPipeline::activateInternal() {
@@ -40,17 +40,6 @@ void ShaderPipeline::activateInternal() {
}
}
-Shader *ShaderPipeline::setShader(Shader *shader) {
- Shader *oldShader = _activeShader;
-
- _activeShader = shader;
- if (_activeShader && _activeFramebuffer) {
- _activeShader->activate(_activeFramebuffer->getProjectionMatrix());
- }
-
- return oldShader;
-}
-
void ShaderPipeline::setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
GL_CALL(glVertexAttrib4f(kColorAttribLocation, r, g, b, a));
}
@@ -64,7 +53,7 @@ void ShaderPipeline::drawTexture(const GLTexture &texture, const GLfloat *coordi
}
void ShaderPipeline::setProjectionMatrix(const GLfloat *projectionMatrix) {
- if (_activeShader) {
+ if (isActive() && _activeShader) {
_activeShader->activate(projectionMatrix);
}
}
diff --git a/backends/graphics/opengl/pipelines/shader.h b/backends/graphics/opengl/pipelines/shader.h
index a5b94e89f5..52046f8dd5 100644
--- a/backends/graphics/opengl/pipelines/shader.h
+++ b/backends/graphics/opengl/pipelines/shader.h
@@ -28,11 +28,11 @@
namespace OpenGL {
#if !USE_FORCED_GLES
+class Shader;
+
class ShaderPipeline : public Pipeline {
public:
- ShaderPipeline();
-
- virtual Shader *setShader(Shader *shader);
+ ShaderPipeline(Shader *shader);
virtual void setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
@@ -43,7 +43,7 @@ public:
protected:
virtual void activateInternal();
- Shader *_activeShader;
+ Shader *const _activeShader;
};
#endif // !USE_FORCED_GLES