diff options
-rw-r--r-- | backends/graphics/opengl/context.cpp | 2 | ||||
-rw-r--r-- | backends/graphics/opengl/framebuffer.cpp | 2 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.cpp | 4 | ||||
-rw-r--r-- | backends/graphics/opengl/pipelines/fixed.cpp | 66 | ||||
-rw-r--r-- | backends/graphics/opengl/pipelines/fixed.h | 45 | ||||
-rw-r--r-- | backends/graphics/opengl/pipelines/pipeline.cpp | 47 | ||||
-rw-r--r-- | backends/graphics/opengl/pipelines/pipeline.h (renamed from backends/graphics/opengl/pipeline.h) | 37 | ||||
-rw-r--r-- | backends/graphics/opengl/pipelines/shader.cpp (renamed from backends/graphics/opengl/pipeline.cpp) | 60 | ||||
-rw-r--r-- | backends/graphics/opengl/pipelines/shader.h | 52 | ||||
-rw-r--r-- | backends/graphics/opengl/texture.cpp | 2 | ||||
-rw-r--r-- | backends/module.mk | 6 |
11 files changed, 223 insertions, 100 deletions
diff --git a/backends/graphics/opengl/context.cpp b/backends/graphics/opengl/context.cpp index 09da353918..d93ecdc517 100644 --- a/backends/graphics/opengl/context.cpp +++ b/backends/graphics/opengl/context.cpp @@ -23,7 +23,7 @@ #include "backends/graphics/opengl/opengl-sys.h" #include "backends/graphics/opengl/opengl-graphics.h" #include "backends/graphics/opengl/shader.h" -#include "backends/graphics/opengl/pipeline.h" +#include "backends/graphics/opengl/pipelines/pipeline.h" #include "backends/graphics/opengl/framebuffer.h" #include "common/tokenizer.h" diff --git a/backends/graphics/opengl/framebuffer.cpp b/backends/graphics/opengl/framebuffer.cpp index f3332cb469..7191aab8bc 100644 --- a/backends/graphics/opengl/framebuffer.cpp +++ b/backends/graphics/opengl/framebuffer.cpp @@ -22,7 +22,7 @@ #include "backends/graphics/opengl/framebuffer.h" #include "backends/graphics/opengl/texture.h" -#include "backends/graphics/opengl/pipeline.h" +#include "backends/graphics/opengl/pipelines/pipeline.h" namespace OpenGL { diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 6ede6a296c..3322ff5c55 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -23,7 +23,9 @@ #include "backends/graphics/opengl/opengl-graphics.h" #include "backends/graphics/opengl/texture.h" -#include "backends/graphics/opengl/pipeline.h" +#include "backends/graphics/opengl/pipelines/pipeline.h" +#include "backends/graphics/opengl/pipelines/fixed.h" +#include "backends/graphics/opengl/pipelines/shader.h" #include "backends/graphics/opengl/shader.h" #include "common/textconsole.h" diff --git a/backends/graphics/opengl/pipelines/fixed.cpp b/backends/graphics/opengl/pipelines/fixed.cpp new file mode 100644 index 0000000000..1d671d112e --- /dev/null +++ b/backends/graphics/opengl/pipelines/fixed.cpp @@ -0,0 +1,66 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "backends/graphics/opengl/pipelines/fixed.h" + +namespace OpenGL { + +#if !USE_FORCED_GLES2 +void FixedPipeline::activate() { + GL_CALL(glDisable(GL_LIGHTING)); + GL_CALL(glDisable(GL_FOG)); + GL_CALL(glShadeModel(GL_FLAT)); + GL_CALL(glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)); + + GL_CALL(glEnableClientState(GL_VERTEX_ARRAY)); + GL_CALL(glEnableClientState(GL_TEXTURE_COORD_ARRAY)); + +#if !USE_FORCED_GLES + if (g_context.multitextureSupported) { + GL_CALL(glActiveTexture(GL_TEXTURE0)); + } +#endif + GL_CALL(glEnable(GL_TEXTURE_2D)); +} + +void FixedPipeline::setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { + GL_CALL(glColor4f(r, g, b, a)); +} + +void FixedPipeline::drawTexture(const GLTexture &texture, const GLfloat *coordinates) { + texture.bind(); + + GL_CALL(glTexCoordPointer(2, GL_FLOAT, 0, texture.getTexCoords())); + GL_CALL(glVertexPointer(2, GL_FLOAT, 0, coordinates)); + GL_CALL(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)); +} + +void FixedPipeline::setProjectionMatrix(const GLfloat *projectionMatrix) { + GL_CALL(glMatrixMode(GL_PROJECTION)); + GL_CALL(glLoadMatrixf(projectionMatrix)); + + GL_CALL(glMatrixMode(GL_MODELVIEW)); + GL_CALL(glLoadIdentity()); +} +#endif // !USE_FORCED_GLES2 + +} // End of namespace OpenGL diff --git a/backends/graphics/opengl/pipelines/fixed.h b/backends/graphics/opengl/pipelines/fixed.h new file mode 100644 index 0000000000..f344ef1364 --- /dev/null +++ b/backends/graphics/opengl/pipelines/fixed.h @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef BACKENDS_GRAPHICS_OPENGL_PIPELINES_FIXED_H +#define BACKENDS_GRAPHICS_OPENGL_PIPELINES_FIXED_H + +#include "backends/graphics/opengl/pipelines/pipeline.h" + +namespace OpenGL { + +#if !USE_FORCED_GLES2 +class FixedPipeline : public Pipeline { +public: + virtual void activate(); + + virtual void setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a); + + virtual void drawTexture(const GLTexture &texture, const GLfloat *coordinates); + + virtual void setProjectionMatrix(const GLfloat *projectionMatrix); +}; +#endif // !USE_FORCED_GLES2 + +} // End of namespace OpenGL + +#endif diff --git a/backends/graphics/opengl/pipelines/pipeline.cpp b/backends/graphics/opengl/pipelines/pipeline.cpp new file mode 100644 index 0000000000..64121d512a --- /dev/null +++ b/backends/graphics/opengl/pipelines/pipeline.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "backends/graphics/opengl/pipelines/pipeline.h" +#include "backends/graphics/opengl/framebuffer.h" + +namespace OpenGL { + +Pipeline::Pipeline() + : _activeFramebuffer(nullptr) { +} + +Framebuffer *Pipeline::setFramebuffer(Framebuffer *framebuffer) { + Framebuffer *oldFramebuffer = _activeFramebuffer; + if (oldFramebuffer) { + oldFramebuffer->deactivate(); + } + + _activeFramebuffer = framebuffer; + if (_activeFramebuffer) { + _activeFramebuffer->activate(); + setProjectionMatrix(_activeFramebuffer->getProjectionMatrix()); + } + + return oldFramebuffer; +} + +} // End of namespace OpenGL diff --git a/backends/graphics/opengl/pipeline.h b/backends/graphics/opengl/pipelines/pipeline.h index 5ec52f2f28..8509a26f8f 100644 --- a/backends/graphics/opengl/pipeline.h +++ b/backends/graphics/opengl/pipelines/pipeline.h @@ -20,8 +20,8 @@ * */ -#ifndef BACKENDS_GRAPHICS_OPENGL_PIEPLINE_H -#define BACKENDS_GRAPHICS_OPENGL_PIEPLINE_H +#ifndef BACKENDS_GRAPHICS_OPENGL_PIPELINES_PIPELINE_H +#define BACKENDS_GRAPHICS_OPENGL_PIPELINES_PIPELINE_H #include "backends/graphics/opengl/opengl-sys.h" #include "backends/graphics/opengl/texture.h" @@ -116,39 +116,6 @@ protected: Framebuffer *_activeFramebuffer; }; -#if !USE_FORCED_GLES2 -class FixedPipeline : public Pipeline { -public: - virtual void activate(); - - virtual void setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a); - - virtual void drawTexture(const GLTexture &texture, const GLfloat *coordinates); - - virtual void setProjectionMatrix(const GLfloat *projectionMatrix); -}; -#endif // !USE_FORCED_GLES2 - -#if !USE_FORCED_GLES -class ShaderPipeline : public Pipeline { -public: - ShaderPipeline(); - - virtual void activate(); - - virtual Shader *setShader(Shader *shader); - - virtual void setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a); - - virtual void drawTexture(const GLTexture &texture, const GLfloat *coordinates); - - virtual void setProjectionMatrix(const GLfloat *projectionMatrix); - -private: - Shader *_activeShader; -}; -#endif // !USE_FORCED_GLES - } // End of namespace OpenGL #endif diff --git a/backends/graphics/opengl/pipeline.cpp b/backends/graphics/opengl/pipelines/shader.cpp index 9ac3fe44de..42f511d147 100644 --- a/backends/graphics/opengl/pipeline.cpp +++ b/backends/graphics/opengl/pipelines/shader.cpp @@ -20,70 +20,12 @@ * */ -#include "backends/graphics/opengl/pipeline.h" +#include "backends/graphics/opengl/pipelines/shader.h" #include "backends/graphics/opengl/shader.h" #include "backends/graphics/opengl/framebuffer.h" namespace OpenGL { -Pipeline::Pipeline() - : _activeFramebuffer(nullptr) { -} - -Framebuffer *Pipeline::setFramebuffer(Framebuffer *framebuffer) { - Framebuffer *oldFramebuffer = _activeFramebuffer; - if (oldFramebuffer) { - oldFramebuffer->deactivate(); - } - - _activeFramebuffer = framebuffer; - if (_activeFramebuffer) { - _activeFramebuffer->activate(); - setProjectionMatrix(_activeFramebuffer->getProjectionMatrix()); - } - - return oldFramebuffer; -} - -#if !USE_FORCED_GLES2 -void FixedPipeline::activate() { - GL_CALL(glDisable(GL_LIGHTING)); - GL_CALL(glDisable(GL_FOG)); - GL_CALL(glShadeModel(GL_FLAT)); - GL_CALL(glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)); - - GL_CALL(glEnableClientState(GL_VERTEX_ARRAY)); - GL_CALL(glEnableClientState(GL_TEXTURE_COORD_ARRAY)); - -#if !USE_FORCED_GLES - if (g_context.multitextureSupported) { - GL_CALL(glActiveTexture(GL_TEXTURE0)); - } -#endif - GL_CALL(glEnable(GL_TEXTURE_2D)); -} - -void FixedPipeline::setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { - GL_CALL(glColor4f(r, g, b, a)); -} - -void FixedPipeline::drawTexture(const GLTexture &texture, const GLfloat *coordinates) { - texture.bind(); - - GL_CALL(glTexCoordPointer(2, GL_FLOAT, 0, texture.getTexCoords())); - GL_CALL(glVertexPointer(2, GL_FLOAT, 0, coordinates)); - GL_CALL(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)); -} - -void FixedPipeline::setProjectionMatrix(const GLfloat *projectionMatrix) { - GL_CALL(glMatrixMode(GL_PROJECTION)); - GL_CALL(glLoadMatrixf(projectionMatrix)); - - GL_CALL(glMatrixMode(GL_MODELVIEW)); - GL_CALL(glLoadIdentity()); -} -#endif // !USE_FORCED_GLES2 - #if !USE_FORCED_GLES ShaderPipeline::ShaderPipeline() : _activeShader(nullptr) { diff --git a/backends/graphics/opengl/pipelines/shader.h b/backends/graphics/opengl/pipelines/shader.h new file mode 100644 index 0000000000..96e15803f0 --- /dev/null +++ b/backends/graphics/opengl/pipelines/shader.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef BACKENDS_GRAPHICS_OPENGL_PIPELINES_SHADER_H +#define BACKENDS_GRAPHICS_OPENGL_PIPELINES_SHADER_H + +#include "backends/graphics/opengl/pipelines/pipeline.h" + +namespace OpenGL { + +#if !USE_FORCED_GLES +class ShaderPipeline : public Pipeline { +public: + ShaderPipeline(); + + virtual void activate(); + + virtual Shader *setShader(Shader *shader); + + virtual void setColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a); + + virtual void drawTexture(const GLTexture &texture, const GLfloat *coordinates); + + virtual void setProjectionMatrix(const GLfloat *projectionMatrix); + +private: + Shader *_activeShader; +}; +#endif // !USE_FORCED_GLES + +} // End of namespace OpenGL + +#endif diff --git a/backends/graphics/opengl/texture.cpp b/backends/graphics/opengl/texture.cpp index 8746527d5b..b0e474d415 100644 --- a/backends/graphics/opengl/texture.cpp +++ b/backends/graphics/opengl/texture.cpp @@ -22,7 +22,7 @@ #include "backends/graphics/opengl/texture.h" #include "backends/graphics/opengl/shader.h" -#include "backends/graphics/opengl/pipeline.h" +#include "backends/graphics/opengl/pipelines/pipeline.h" #include "backends/graphics/opengl/framebuffer.h" #include "common/rect.h" diff --git a/backends/module.mk b/backends/module.mk index f786933ade..fd97e19417 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -56,9 +56,11 @@ MODULE_OBJS += \ graphics/opengl/debug.o \ graphics/opengl/framebuffer.o \ graphics/opengl/opengl-graphics.o \ - graphics/opengl/pipeline.o \ graphics/opengl/shader.o \ - graphics/opengl/texture.o + graphics/opengl/texture.o \ + graphics/opengl/pipelines/fixed.o \ + graphics/opengl/pipelines/pipeline.o \ + graphics/opengl/pipelines/shader.o endif # SDL specific source files. |