diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 3334c9a9f9b..287a7bfbe70 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -389,8 +389,8 @@ Graphics::PixelBuffer SurfaceSdlGraphicsManager::setupScreen(uint screenW, uint // Setup the box shader used to render the overlay const char* attributes[] = { "position", "texcoord", NULL }; - _boxShader = Graphics::Shader::fromStrings("box", Graphics::BuiltinShaders::boxVertex, Graphics::BuiltinShaders::boxFragment, attributes); - _boxVerticesVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(vertices), vertices); + _boxShader = OpenGL::Shader::fromStrings("box", OpenGL::BuiltinShaders::boxVertex, OpenGL::BuiltinShaders::boxFragment, attributes); + _boxVerticesVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(vertices), vertices); _boxShader->enableVertexAttribute("position", _boxVerticesVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0); _boxShader->enableVertexAttribute("texcoord", _boxVerticesVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0); #endif diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index e52584c26ed..1ff66628ab8 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -32,7 +32,7 @@ #undef ARRAYSIZE #ifdef USE_OPENGL_SHADERS -#include "graphics/opengles2/shader.h" +#include "graphics/opengl/shader.h" #endif #include "backends/graphics/graphics.h" @@ -189,7 +189,7 @@ protected: OpenGL::FrameBuffer *_frameBuffer; #ifdef USE_OPENGL_SHADERS - Graphics::Shader *_boxShader; + OpenGL::Shader *_boxShader; GLuint _boxVerticesVBO; void drawOverlayOpenGLShaders(); diff --git a/backends/platform/android/gfx.cpp b/backends/platform/android/gfx.cpp index ced0968b580..4d9db1c4c82 100644 --- a/backends/platform/android/gfx.cpp +++ b/backends/platform/android/gfx.cpp @@ -42,7 +42,7 @@ #include "common/endian.h" #include "common/tokenizer.h" #include "graphics/conversion.h" -#include "graphics/opengles2/shader.h" +#include "graphics/opengl/shader.h" #include "graphics/opengl/extensions.h" #include "backends/platform/android/android.h" diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index 5501e40a214..d70bf19d110 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -41,7 +41,7 @@ #include "base/main.h" #include "graphics/surface.h" -#include "graphics/opengles2/shader.h" +#include "graphics/opengl/shader.h" #include "graphics/opengl/extensions.h" #include "common/rect.h" @@ -55,7 +55,7 @@ // Supported GL extensions static bool npot_supported = false; -Graphics::Shader * g_box_shader; +OpenGL::Shader * g_box_shader; GLuint g_verticesVBO; static inline GLfixed xdiv(int numerator, int denominator) { @@ -86,8 +86,8 @@ void GLESBaseTexture::initGL() { npot_supported = OpenGL::isExtensionSupported("GL_ARB_texture_non_power_of_two"); const char* attributes[] = { "position", "texcoord", NULL }; - g_box_shader = Graphics::Shader::fromStrings("control", Graphics::BuiltinShaders::controlVertex, Graphics::BuiltinShaders::controlFragment, attributes); - g_verticesVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(vertices), vertices); + g_box_shader = OpenGL::Shader::fromStrings("control", OpenGL::BuiltinShaders::controlVertex, OpenGL::BuiltinShaders::controlFragment, attributes); + g_verticesVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(vertices), vertices); g_box_shader->enableVertexAttribute("position", g_verticesVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0); g_box_shader->enableVertexAttribute("texcoord", g_verticesVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0); } diff --git a/engines/grim/gfx_opengl_shaders.cpp b/engines/grim/gfx_opengl_shaders.cpp index 659ac4704bf..81e04c66a6f 100644 --- a/engines/grim/gfx_opengl_shaders.cpp +++ b/engines/grim/gfx_opengl_shaders.cpp @@ -110,7 +110,7 @@ struct GrimVertex { }; struct TextUserData { - Graphics::Shader * shader; + OpenGL::Shader * shader; uint32 characters; Color color; GLuint texture; @@ -122,7 +122,7 @@ struct FontUserData { }; struct EMIModelUserData { - Graphics::Shader *_shader; + OpenGL::Shader *_shader; uint32 _texCoordsVBO; uint32 _colorMapVBO; uint32 _verticesVBO; @@ -130,7 +130,7 @@ struct EMIModelUserData { }; struct ModelUserData { - Graphics::Shader *_shader; + OpenGL::Shader *_shader; uint32 _meshInfoVBO; }; @@ -290,11 +290,11 @@ void GfxOpenGLS::setupQuadEBO() { p[5] = start++; } - _quadEBO = Graphics::Shader::createBuffer(GL_ELEMENT_ARRAY_BUFFER, sizeof(quad_indices), quad_indices, GL_STATIC_DRAW); + _quadEBO = OpenGL::Shader::createBuffer(GL_ELEMENT_ARRAY_BUFFER, sizeof(quad_indices), quad_indices, GL_STATIC_DRAW); } void GfxOpenGLS::setupTexturedQuad() { - _smushVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(textured_quad), textured_quad, GL_STATIC_DRAW); + _smushVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(textured_quad), textured_quad, GL_STATIC_DRAW); _smushProgram->enableVertexAttribute("position", _smushVBO, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); _smushProgram->enableVertexAttribute("texcoord", _smushVBO, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 2 * sizeof(float)); @@ -310,7 +310,7 @@ void GfxOpenGLS::setupTexturedQuad() { } void GfxOpenGLS::setupTexturedCenteredQuad() { - _spriteVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(textured_quad_centered), textured_quad_centered, GL_STATIC_DRAW); + _spriteVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(textured_quad_centered), textured_quad_centered, GL_STATIC_DRAW); _spriteProgram->enableVertexAttribute("position", _spriteVBO, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), 0); _spriteProgram->enableVertexAttribute("texcoord", _spriteVBO, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), 3 * sizeof(float)); _spriteProgram->disableVertexAttribute("color", Math::Vector4d(1.0f, 1.0f, 1.0f, 1.0f)); @@ -372,26 +372,26 @@ void GfxOpenGLS::setupShaders() { bool isEMI = g_grim->getGameType() == GType_MONKEY4; static const char* commonAttributes[] = {"position", "texcoord", NULL}; - _backgroundProgram = Graphics::Shader::fromFiles(isEMI ? "emi_background" : "grim_background", commonAttributes); - _smushProgram = Graphics::Shader::fromFiles("smush", commonAttributes); - _textProgram = Graphics::Shader::fromFiles("text", commonAttributes); - _emergProgram = Graphics::Shader::fromFiles("emerg", commonAttributes); + _backgroundProgram = OpenGL::Shader::fromFiles(isEMI ? "emi_background" : "grim_background", commonAttributes); + _smushProgram = OpenGL::Shader::fromFiles("smush", commonAttributes); + _textProgram = OpenGL::Shader::fromFiles("text", commonAttributes); + _emergProgram = OpenGL::Shader::fromFiles("emerg", commonAttributes); static const char* actorAttributes[] = {"position", "texcoord", "color", "normal", NULL}; - _actorProgram = Graphics::Shader::fromFiles(isEMI ? "emi_actor" : "grim_actor", actorAttributes); - _spriteProgram = Graphics::Shader::fromFiles(isEMI ? "emi_actor" : "grim_actor", actorAttributes); + _actorProgram = OpenGL::Shader::fromFiles(isEMI ? "emi_actor" : "grim_actor", actorAttributes); + _spriteProgram = OpenGL::Shader::fromFiles(isEMI ? "emi_actor" : "grim_actor", actorAttributes); static const char* primAttributes[] = { "position", NULL }; - _shadowPlaneProgram = Graphics::Shader::fromFiles("shadowplane", primAttributes); - _primitiveProgram = Graphics::Shader::fromFiles("grim_primitive", primAttributes); + _shadowPlaneProgram = OpenGL::Shader::fromFiles("shadowplane", primAttributes); + _primitiveProgram = OpenGL::Shader::fromFiles("grim_primitive", primAttributes); if (!isEMI) { _irisProgram = _primitiveProgram->clone(); - _dimProgram = Graphics::Shader::fromFiles("dim", commonAttributes); + _dimProgram = OpenGL::Shader::fromFiles("dim", commonAttributes); _dimRegionProgram = _dimProgram->clone(); } else { - _dimPlaneProgram = Graphics::Shader::fromFiles("emi_dimplane", primAttributes); + _dimPlaneProgram = OpenGL::Shader::fromFiles("emi_dimplane", primAttributes); } setupQuadEBO(); @@ -400,7 +400,7 @@ void GfxOpenGLS::setupShaders() { setupPrimitives(); if (!isEMI) { - _blastVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, 128 * 16 * sizeof(float), NULL, GL_DYNAMIC_DRAW); + _blastVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, 128 * 16 * sizeof(float), NULL, GL_DYNAMIC_DRAW); } } @@ -862,8 +862,8 @@ void GfxOpenGLS::drawShadowPlanes() { ShadowUserData *sud = new ShadowUserData; _currentShadowArray->userData = sud; sud->_numTriangles = numTriangles; - sud->_verticesVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, 3 * numVertices * sizeof(float), vertBuf, GL_STATIC_DRAW); - sud->_indicesVBO = Graphics::Shader::createBuffer(GL_ELEMENT_ARRAY_BUFFER, 3 * numTriangles * sizeof(uint16), idxBuf, GL_STATIC_DRAW); + sud->_verticesVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, 3 * numVertices * sizeof(float), vertBuf, GL_STATIC_DRAW); + sud->_indicesVBO = OpenGL::Shader::createBuffer(GL_ELEMENT_ARRAY_BUFFER, 3 * numTriangles * sizeof(uint16), idxBuf, GL_STATIC_DRAW); delete[] vertBuf; delete[] idxBuf; @@ -974,7 +974,7 @@ void GfxOpenGLS::drawMesh(const Mesh *mesh) { const ModelUserData *mud = (const ModelUserData *)mesh->_userData; if (!mud) return; - Graphics::Shader *actorShader = mud->_shader; + OpenGL::Shader *actorShader = mud->_shader; actorShader->use(); actorShader->setUniform("extraMatrix", _matrixStack.top()); @@ -1315,11 +1315,11 @@ void GfxOpenGLS::createBitmap(BitmapData *bitmap) { delete[] texData; bitmap->freeData(); - Graphics::Shader *shader = _backgroundProgram->clone(); + OpenGL::Shader *shader = _backgroundProgram->clone(); bitmap->_userData = shader; if (g_grim->getGameType() == GType_MONKEY4) { - GLuint vbo = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, bitmap->_numCoords * 4 * sizeof(float), bitmap->_texc, GL_STATIC_DRAW); + GLuint vbo = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, bitmap->_numCoords * 4 * sizeof(float), bitmap->_texc, GL_STATIC_DRAW); shader->enableVertexAttribute("position", vbo, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); shader->enableVertexAttribute("texcoord", vbo, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 2*sizeof(float)); } @@ -1333,7 +1333,7 @@ void GfxOpenGLS::createBitmap(BitmapData *bitmap) { void GfxOpenGLS::drawBitmap(const Bitmap *bitmap, int dx, int dy, uint32 layer) { if (g_grim->getGameType() == GType_MONKEY4 && bitmap->_data && bitmap->_data->_texc) { BitmapData *data = bitmap->_data; - Graphics::Shader *shader = (Graphics::Shader *)data->_userData; + OpenGL::Shader *shader = (OpenGL::Shader *)data->_userData; GLuint *textures = (GLuint *)bitmap->getTexIds(); glDisable(GL_DEPTH_TEST); @@ -1369,7 +1369,7 @@ void GfxOpenGLS::drawBitmap(const Bitmap *bitmap, int dx, int dy, uint32 layer) glDisable(GL_BLEND); } - Graphics::Shader *shader = (Graphics::Shader *)bitmap->_data->_userData; + OpenGL::Shader *shader = (OpenGL::Shader *)bitmap->_data->_userData; shader->use(); glDisable(GL_DEPTH_TEST); glDepthMask(GL_FALSE); @@ -1424,7 +1424,7 @@ void GfxOpenGLS::destroyBitmap(BitmapData *bitmap) { delete[] textures; bitmap->_texIds = 0; } - Graphics::Shader *shader = (Graphics::Shader *)bitmap->_userData; + OpenGL::Shader *shader = (OpenGL::Shader *)bitmap->_userData; if (g_grim->getGameType() == GType_MONKEY4) { glDeleteBuffers(1, &shader->getAttributeAt(0)._vbo); } @@ -1584,10 +1584,10 @@ void GfxOpenGLS::createTextObject(TextObject *text) { glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferSubData(GL_ARRAY_BUFFER, 0, numCharacters * 16 * sizeof(float), bufData); } else { - vbo = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, numCharacters * 16 * sizeof(float), bufData, GL_STATIC_DRAW); + vbo = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, numCharacters * 16 * sizeof(float), bufData, GL_STATIC_DRAW); } - Graphics::Shader * textShader = _textProgram->clone(); + OpenGL::Shader * textShader = _textProgram->clone(); glBindBuffer(GL_ARRAY_BUFFER, vbo); textShader->enableVertexAttribute("position", vbo, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); @@ -1974,15 +1974,15 @@ void GfxOpenGLS::renderZBitmaps(bool render) { void GfxOpenGLS::createEMIModel(EMIModel *model) { EMIModelUserData *mud = new EMIModelUserData; model->_userData = mud; - mud->_verticesVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, model->_numVertices * 3 * sizeof(float), model->_vertices, GL_STREAM_DRAW); + mud->_verticesVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, model->_numVertices * 3 * sizeof(float), model->_vertices, GL_STREAM_DRAW); - mud->_normalsVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, model->_numVertices * 3 * sizeof(float), model->_normals, GL_STREAM_DRAW); + mud->_normalsVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, model->_numVertices * 3 * sizeof(float), model->_normals, GL_STREAM_DRAW); - mud->_texCoordsVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, model->_numVertices * 2 * sizeof(float), model->_texVerts, GL_STATIC_DRAW); + mud->_texCoordsVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, model->_numVertices * 2 * sizeof(float), model->_texVerts, GL_STATIC_DRAW); - mud->_colorMapVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, model->_numVertices * 4 * sizeof(byte), model->_colorMap, GL_STATIC_DRAW); + mud->_colorMapVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, model->_numVertices * 4 * sizeof(byte), model->_colorMap, GL_STATIC_DRAW); - Graphics::Shader * actorShader = _actorProgram->clone(); + OpenGL::Shader * actorShader = _actorProgram->clone(); actorShader->enableVertexAttribute("position", mud->_verticesVBO, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0); actorShader->enableVertexAttribute("normal", mud->_normalsVBO, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0); actorShader->enableVertexAttribute("texcoord", mud->_texCoordsVBO, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), 0); @@ -1991,7 +1991,7 @@ void GfxOpenGLS::createEMIModel(EMIModel *model) { for (uint32 i = 0; i < model->_numFaces; ++i) { EMIMeshFace * face = &model->_faces[i]; - face->_indicesEBO = Graphics::Shader::createBuffer(GL_ELEMENT_ARRAY_BUFFER, face->_faceLength * 3 * sizeof(uint32), face->_indexes, GL_STATIC_DRAW); + face->_indicesEBO = OpenGL::Shader::createBuffer(GL_ELEMENT_ARRAY_BUFFER, face->_faceLength * 3 * sizeof(uint32), face->_indexes, GL_STATIC_DRAW); } glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); @@ -2032,9 +2032,9 @@ void GfxOpenGLS::createMesh(Mesh *mesh) { ModelUserData *mud = new ModelUserData; mesh->_userData = mud; - mud->_meshInfoVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, meshInfo.size() * sizeof(GrimVertex), &meshInfo[0], GL_STATIC_DRAW); + mud->_meshInfoVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, meshInfo.size() * sizeof(GrimVertex), &meshInfo[0], GL_STATIC_DRAW); - Graphics::Shader *shader = _actorProgram->clone(); + OpenGL::Shader *shader = _actorProgram->clone(); mud->_shader = shader; shader->enableVertexAttribute("position", mud->_meshInfoVBO, 3, GL_FLOAT, GL_FALSE, sizeof(GrimVertex), 0); shader->enableVertexAttribute("texcoord", mud->_meshInfoVBO, 2, GL_FLOAT, GL_FALSE, sizeof(GrimVertex), 3 * sizeof(float)); diff --git a/engines/grim/gfx_opengl_shaders.h b/engines/grim/gfx_opengl_shaders.h index ba36598f819..72e74fc33c8 100644 --- a/engines/grim/gfx_opengl_shaders.h +++ b/engines/grim/gfx_opengl_shaders.h @@ -25,7 +25,7 @@ #include "engines/grim/actor.h" #include "engines/grim/gfx_base.h" -#include "graphics/opengles2/shader.h" +#include "graphics/opengl/shader.h" #include "common/stack.h" #include "common/rect.h" @@ -220,20 +220,20 @@ private: float _alpha; int _maxLights; GLuint _emergTexture; - Graphics::Shader* _emergProgram; + OpenGL::Shader* _emergProgram; - Graphics::Shader* _backgroundProgram; - Graphics::Shader* _actorProgram; - Graphics::Shader* _spriteProgram; - Graphics::Shader* _dimProgram; - Graphics::Shader* _dimPlaneProgram; - Graphics::Shader* _dimRegionProgram; - Graphics::Shader* _smushProgram; + OpenGL::Shader* _backgroundProgram; + OpenGL::Shader* _actorProgram; + OpenGL::Shader* _spriteProgram; + OpenGL::Shader* _dimProgram; + OpenGL::Shader* _dimPlaneProgram; + OpenGL::Shader* _dimRegionProgram; + OpenGL::Shader* _smushProgram; GLuint _smushVBO, _quadEBO; - Graphics::Shader* _textProgram; - Graphics::Shader* _primitiveProgram; - Graphics::Shader* _irisProgram; - Graphics::Shader* _shadowPlaneProgram; + OpenGL::Shader* _textProgram; + OpenGL::Shader* _primitiveProgram; + OpenGL::Shader* _irisProgram; + OpenGL::Shader* _shadowPlaneProgram; int _smushWidth; int _smushHeight; diff --git a/engines/myst3/gfx_opengl_shaders.cpp b/engines/myst3/gfx_opengl_shaders.cpp index 34644c450ae..78f83376c5e 100644 --- a/engines/myst3/gfx_opengl_shaders.cpp +++ b/engines/myst3/gfx_opengl_shaders.cpp @@ -58,7 +58,7 @@ #include "math/quat.h" #include "graphics/opengl/extensions.h" -#include "graphics/opengles2/shader.h" +#include "graphics/opengl/shader.h" #include "engines/myst3/gfx.h" #include "engines/myst3/gfx_opengl_texture.h" @@ -89,7 +89,7 @@ void ShaderRenderer::setupQuadEBO() { p[5] = start++; } - _quadEBO = Graphics::Shader::createBuffer(GL_ELEMENT_ARRAY_BUFFER, sizeof(quadIndices), quadIndices, GL_STATIC_DRAW); + _quadEBO = OpenGL::Shader::createBuffer(GL_ELEMENT_ARRAY_BUFFER, sizeof(quadIndices), quadIndices, GL_STATIC_DRAW); } Math::Vector2d ShaderRenderer::scaled(float x, float y) const { @@ -113,11 +113,11 @@ ShaderRenderer::ShaderRenderer(OSystem *system) : } ShaderRenderer::~ShaderRenderer() { - Graphics::Shader::freeBuffer(_boxVBO); - Graphics::Shader::freeBuffer(_cubeVBO); - Graphics::Shader::freeBuffer(_rect3dVBO); - Graphics::Shader::freeBuffer(_textVBO); - Graphics::Shader::freeBuffer(_quadEBO); + OpenGL::Shader::freeBuffer(_boxVBO); + OpenGL::Shader::freeBuffer(_cubeVBO); + OpenGL::Shader::freeBuffer(_rect3dVBO); + OpenGL::Shader::freeBuffer(_textVBO); + OpenGL::Shader::freeBuffer(_quadEBO); delete _boxShader; delete _cubeShader; @@ -151,23 +151,23 @@ void ShaderRenderer::init() { glEnable(GL_DEPTH_TEST); static const char* attributes[] = { "position", "texcoord", NULL }; - _boxShader = Graphics::Shader::fromFiles("myst3_box", attributes); - _boxVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(boxVertices), boxVertices); + _boxShader = OpenGL::Shader::fromFiles("myst3_box", attributes); + _boxVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(boxVertices), boxVertices); _boxShader->enableVertexAttribute("position", _boxVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0); _boxShader->enableVertexAttribute("texcoord", _boxVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0); - _cubeShader = Graphics::Shader::fromFiles("myst3_cube", attributes); - _cubeVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(cubeVertices), cubeVertices); + _cubeShader = OpenGL::Shader::fromFiles("myst3_cube", attributes); + _cubeVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(cubeVertices), cubeVertices); _cubeShader->enableVertexAttribute("texcoord", _cubeVBO, 2, GL_FLOAT, GL_TRUE, 5 * sizeof(float), 0); _cubeShader->enableVertexAttribute("position", _cubeVBO, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), 2 * sizeof(float)); - _rect3dShader = Graphics::Shader::fromFiles("myst3_cube", attributes); - _rect3dVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, 20 * sizeof(float), NULL); + _rect3dShader = OpenGL::Shader::fromFiles("myst3_cube", attributes); + _rect3dVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, 20 * sizeof(float), NULL); _rect3dShader->enableVertexAttribute("texcoord", _rect3dVBO, 2, GL_FLOAT, GL_TRUE, 5 * sizeof(float), 0); _rect3dShader->enableVertexAttribute("position", _rect3dVBO, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), 2 * sizeof(float)); - _textShader = Graphics::Shader::fromFiles("myst3_text", attributes); - _textVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, 100 * 16 * sizeof(float), NULL, GL_DYNAMIC_DRAW); + _textShader = OpenGL::Shader::fromFiles("myst3_text", attributes); + _textVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, 100 * 16 * sizeof(float), NULL, GL_DYNAMIC_DRAW); _textShader->enableVertexAttribute("texcoord", _textVBO, 2, GL_FLOAT, GL_TRUE, 4 * sizeof(float), 0); _textShader->enableVertexAttribute("position", _textVBO, 2, GL_FLOAT, GL_TRUE, 4 * sizeof(float), 2 * sizeof(float)); diff --git a/engines/myst3/gfx_opengl_shaders.h b/engines/myst3/gfx_opengl_shaders.h index f0a24c389e0..200637b0b56 100644 --- a/engines/myst3/gfx_opengl_shaders.h +++ b/engines/myst3/gfx_opengl_shaders.h @@ -26,7 +26,7 @@ #include "common/rect.h" #include "math/rect2d.h" -#include "graphics/opengles2/shader.h" +#include "graphics/opengl/shader.h" #include "engines/myst3/gfx.h" @@ -62,10 +62,10 @@ private: void setupQuadEBO(); Math::Vector2d scaled(float x, float y) const; - Graphics::Shader *_boxShader; - Graphics::Shader *_cubeShader; - Graphics::Shader *_rect3dShader; - Graphics::Shader *_textShader; + OpenGL::Shader *_boxShader; + OpenGL::Shader *_cubeShader; + OpenGL::Shader *_rect3dShader; + OpenGL::Shader *_textShader; GLuint _boxVBO; GLuint _cubeVBO; diff --git a/engines/stark/gfx/opengls.cpp b/engines/stark/gfx/opengls.cpp index 837a15805c1..a09d7b4a47b 100644 --- a/engines/stark/gfx/opengls.cpp +++ b/engines/stark/gfx/opengls.cpp @@ -36,7 +36,7 @@ #include "engines/stark/gfx/opengltexture.h" #include "graphics/pixelbuffer.h" -#include "graphics/opengles2/shader.h" +#include "graphics/opengl/shader.h" namespace Stark { namespace Gfx { @@ -56,7 +56,7 @@ OpenGLSDriver::OpenGLSDriver() : } OpenGLSDriver::~OpenGLSDriver() { - Graphics::Shader::freeBuffer(_surfaceVBO); + OpenGL::Shader::freeBuffer(_surfaceVBO); delete _surfaceShader; delete _actorShader; } @@ -68,13 +68,13 @@ void OpenGLSDriver::init() { computeScreenViewport(); static const char* attributes[] = { "position", "texcoord", nullptr }; - _surfaceShader = Graphics::Shader::fromFiles("stark_surface", attributes); - _surfaceVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(surfaceVertices), surfaceVertices); + _surfaceShader = OpenGL::Shader::fromFiles("stark_surface", attributes); + _surfaceVBO = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(surfaceVertices), surfaceVertices); _surfaceShader->enableVertexAttribute("position", _surfaceVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0); _surfaceShader->enableVertexAttribute("texcoord", _surfaceVBO, 2, GL_FLOAT, GL_TRUE, 2 * sizeof(float), 0); static const char* actorAttributes[] = { "position1", "position2", "bone1", "bone2", "boneWeight", "normal", "texcoord", nullptr }; - _actorShader = Graphics::Shader::fromFiles("stark_actor", actorAttributes); + _actorShader = OpenGL::Shader::fromFiles("stark_actor", actorAttributes); } void OpenGLSDriver::setScreenViewport(bool noScaling) { @@ -169,11 +169,11 @@ Common::Rect OpenGLSDriver::getUnscaledViewport() const { return _unscaledViewport; } -Graphics::Shader *OpenGLSDriver::createActorShaderInstance() { +OpenGL::Shader *OpenGLSDriver::createActorShaderInstance() { return _actorShader->clone(); } -Graphics::Shader *OpenGLSDriver::createSurfaceShaderInstance() { +OpenGL::Shader *OpenGLSDriver::createSurfaceShaderInstance() { return _surfaceShader->clone(); } diff --git a/engines/stark/gfx/opengls.h b/engines/stark/gfx/opengls.h index fedade7c716..3bdd3036f26 100644 --- a/engines/stark/gfx/opengls.h +++ b/engines/stark/gfx/opengls.h @@ -33,7 +33,7 @@ #include "math/vector2d.h" -namespace Graphics { +namespace OpenGL { class Shader; } @@ -58,8 +58,8 @@ public: VisualProp *createPropRenderer() override; SurfaceRenderer *createSurfaceRenderer() override; - Graphics::Shader *createActorShaderInstance(); - Graphics::Shader *createSurfaceShaderInstance(); + OpenGL::Shader *createActorShaderInstance(); + OpenGL::Shader *createSurfaceShaderInstance(); void start2DMode(); void end2DMode(); @@ -72,8 +72,8 @@ private: Common::Rect _viewport; Common::Rect _unscaledViewport; - Graphics::Shader *_surfaceShader; - Graphics::Shader *_actorShader; + OpenGL::Shader *_surfaceShader; + OpenGL::Shader *_actorShader; uint32 _surfaceVBO; }; diff --git a/engines/stark/gfx/openglsactor.cpp b/engines/stark/gfx/openglsactor.cpp index 32dfc2ed957..3e4a8d6ee21 100644 --- a/engines/stark/gfx/openglsactor.cpp +++ b/engines/stark/gfx/openglsactor.cpp @@ -29,7 +29,7 @@ #include "engines/stark/gfx/opengls.h" #include "engines/stark/gfx/texture.h" -#include "graphics/opengles2/shader.h" +#include "graphics/opengl/shader.h" namespace Stark { namespace Gfx { @@ -120,11 +120,11 @@ void OpenGLSActorRenderer::render(const Math::Vector3d position, float direction void OpenGLSActorRenderer::clearVertices() { for (FaceBufferMap::iterator it = _faceVBO.begin(); it != _faceVBO.end(); ++it) { - Graphics::Shader::freeBuffer(it->_value); + OpenGL::Shader::freeBuffer(it->_value); } for (FaceBufferMap::iterator it = _faceEBO.begin(); it != _faceEBO.end(); ++it) { - Graphics::Shader::freeBuffer(it->_value); + OpenGL::Shader::freeBuffer(it->_value); } _faceVBO.clear(); @@ -168,7 +168,7 @@ uint32 OpenGLSActorRenderer::createFaceVBO(const FaceNode *face) { *vertPtr++ = (*tri)->_texT; } - uint32 vbo = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(float) * 14 * face->_verts.size(), vertices); + uint32 vbo = OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(float) * 14 * face->_verts.size(), vertices); delete[] vertices; return vbo; @@ -190,7 +190,7 @@ uint32 OpenGLSActorRenderer::createFaceEBO(const FaceNode *face) { } } - uint32 ebo = Graphics::Shader::createBuffer(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32) * 3 * face->_tris.size(), indices); + uint32 ebo = OpenGL::Shader::createBuffer(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32) * 3 * face->_tris.size(), indices); delete[] indices; return ebo; diff --git a/engines/stark/gfx/openglsactor.h b/engines/stark/gfx/openglsactor.h index da75a6cf150..83ed0a793b5 100644 --- a/engines/stark/gfx/openglsactor.h +++ b/engines/stark/gfx/openglsactor.h @@ -29,7 +29,7 @@ #include "engines/stark/gfx/renderentry.h" #include "engines/stark/visual/actor.h" -namespace Graphics { +namespace OpenGL { class Shader; } @@ -49,7 +49,7 @@ protected: typedef Common::HashMap FaceBufferMap; OpenGLSDriver *_gfx; - Graphics::Shader *_shader; + OpenGL::Shader *_shader; FaceBufferMap _faceVBO; FaceBufferMap _faceEBO; diff --git a/engines/stark/gfx/openglsprop.cpp b/engines/stark/gfx/openglsprop.cpp index b8d26331a34..c1b7b57883c 100644 --- a/engines/stark/gfx/openglsprop.cpp +++ b/engines/stark/gfx/openglsprop.cpp @@ -27,7 +27,7 @@ #include "engines/stark/gfx/driver.h" #include "engines/stark/gfx/texture.h" -#include "graphics/opengles2/shader.h" +#include "graphics/opengl/shader.h" namespace Stark { namespace Gfx { @@ -37,7 +37,7 @@ OpenGLSPropRenderer::OpenGLSPropRenderer(Driver *gfx) : _gfx(gfx), _faceVBO(-1) { static const char* attributes[] = { "position", "normal", "texcoord", nullptr }; - _shader = Graphics::Shader::fromFiles("stark_prop", attributes); + _shader = OpenGL::Shader::fromFiles("stark_prop", attributes); } OpenGLSPropRenderer::~OpenGLSPropRenderer() { @@ -96,11 +96,11 @@ void OpenGLSPropRenderer::render(const Math::Vector3d position, float direction) } void OpenGLSPropRenderer::clearVertices() { - Graphics::Shader::freeBuffer(_faceVBO); + OpenGL::Shader::freeBuffer(_faceVBO); _faceVBO = -1; for (FaceBufferMap::iterator it = _faceEBO.begin(); it != _faceEBO.end(); ++it) { - Graphics::Shader::freeBuffer(it->_value); + OpenGL::Shader::freeBuffer(it->_value); } _faceEBO.clear(); @@ -118,11 +118,11 @@ void OpenGLSPropRenderer::uploadVertices() { uint32 OpenGLSPropRenderer::createFaceVBO() { const Common::Array &vertices = _model->getVertices(); - return Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(float) * 9 * vertices.size(), &vertices.front()); + return OpenGL::Shader::createBuffer(GL_ARRAY_BUFFER, sizeof(float) * 9 * vertices.size(), &vertices.front()); } uint32 OpenGLSPropRenderer::createFaceEBO(const Formats::BiffMesh::Face *face) { - return Graphics::Shader::createBuffer(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32) * face->vertexIndices.size(), &face->vertexIndices.front()); + return OpenGL::Shader::createBuffer(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32) * face->vertexIndices.size(), &face->vertexIndices.front()); } } // End of namespace Gfx diff --git a/engines/stark/gfx/openglsprop.h b/engines/stark/gfx/openglsprop.h index 22ff64ccb1e..e0d2e4e716a 100644 --- a/engines/stark/gfx/openglsprop.h +++ b/engines/stark/gfx/openglsprop.h @@ -29,7 +29,7 @@ #include "engines/stark/formats/biffmesh.h" #include "engines/stark/visual/prop.h" -namespace Graphics { +namespace OpenGL { class Shader; } @@ -50,7 +50,7 @@ protected: typedef Common::HashMap FaceBufferMap; Driver *_gfx; - Graphics::Shader *_shader; + OpenGL::Shader *_shader; int32 _faceVBO; FaceBufferMap _faceEBO; diff --git a/engines/stark/gfx/openglssurface.cpp b/engines/stark/gfx/openglssurface.cpp index 0b1ba33b80a..1cfad1426cf 100644 --- a/engines/stark/gfx/openglssurface.cpp +++ b/engines/stark/gfx/openglssurface.cpp @@ -25,7 +25,7 @@ #include "engines/stark/gfx/opengls.h" #include "engines/stark/gfx/texture.h" -#include "graphics/opengles2/shader.h" +#include "graphics/opengl/shader.h" namespace Stark { namespace Gfx { diff --git a/engines/stark/gfx/openglssurface.h b/engines/stark/gfx/openglssurface.h index 21791adf5b0..c77aa0ae30e 100644 --- a/engines/stark/gfx/openglssurface.h +++ b/engines/stark/gfx/openglssurface.h @@ -27,7 +27,7 @@ #include "math/vector2d.h" -namespace Graphics { +namespace OpenGL { class Shader; } @@ -53,7 +53,7 @@ private: Math::Vector2d normalizeCurrentCoordinates(float x, float y) const; OpenGLSDriver *_gfx; - Graphics::Shader *_shader; + OpenGL::Shader *_shader; }; } // End of namespace Gfx diff --git a/graphics/module.mk b/graphics/module.mk index 5f6286fdc9b..94c297d6d90 100644 --- a/graphics/module.mk +++ b/graphics/module.mk @@ -30,10 +30,10 @@ MODULE_OBJS := \ opengl/framebuffer.o \ opengl/texture.o \ opengl/extensions.o \ - opengles2/shader.o \ - opengles2/box_shaders.o \ - opengles2/control_shaders.o \ - opengles2/compat_shaders.o \ + opengl/shader.o \ + opengl/box_shaders.o \ + opengl/control_shaders.o \ + opengl/compat_shaders.o \ tinygl/api.o \ tinygl/arrays.o \ tinygl/clear.o \ diff --git a/graphics/opengles2/box_shaders.cpp b/graphics/opengl/box_shaders.cpp similarity index 97% rename from graphics/opengles2/box_shaders.cpp rename to graphics/opengl/box_shaders.cpp index beb468b7541..e8d2889d9ba 100644 --- a/graphics/opengles2/box_shaders.cpp +++ b/graphics/opengl/box_shaders.cpp @@ -24,7 +24,7 @@ #if defined(USE_GLES2) || defined(USE_OPENGL_SHADERS) -namespace Graphics { +namespace OpenGL { namespace BuiltinShaders { const char *boxVertex = @@ -60,6 +60,6 @@ const char *boxFragment = "}\n"; } -} +} // End of namespace OpenGL #endif diff --git a/graphics/opengles2/compat_shaders.cpp b/graphics/opengl/compat_shaders.cpp similarity index 97% rename from graphics/opengles2/compat_shaders.cpp rename to graphics/opengl/compat_shaders.cpp index 975f35e7d91..3655f6c9b8c 100644 --- a/graphics/opengles2/compat_shaders.cpp +++ b/graphics/opengl/compat_shaders.cpp @@ -24,7 +24,7 @@ #if defined(USE_GLES2) || defined(USE_OPENGL_SHADERS) -namespace Graphics { +namespace OpenGL { namespace BuiltinShaders { const char *compatVertex = @@ -76,6 +76,6 @@ const char *compatFragment = ; } -} +} // End of namespace OpenGL #endif diff --git a/graphics/opengles2/control_shaders.cpp b/graphics/opengl/control_shaders.cpp similarity index 97% rename from graphics/opengles2/control_shaders.cpp rename to graphics/opengl/control_shaders.cpp index 541070edbe7..0933414d6b8 100644 --- a/graphics/opengles2/control_shaders.cpp +++ b/graphics/opengl/control_shaders.cpp @@ -24,7 +24,7 @@ #if defined(USE_GLES2) || defined(USE_OPENGL_SHADERS) -namespace Graphics { +namespace OpenGL { namespace BuiltinShaders { const char *controlVertex = @@ -60,6 +60,6 @@ const char *controlFragment = "}\n"; } -} +} // End of namespace OpenGL #endif diff --git a/graphics/opengles2/shader.cpp b/graphics/opengl/shader.cpp similarity index 96% rename from graphics/opengles2/shader.cpp rename to graphics/opengl/shader.cpp index 7cf7eccf5c0..88f833f0d62 100644 --- a/graphics/opengles2/shader.cpp +++ b/graphics/opengl/shader.cpp @@ -24,9 +24,9 @@ #if defined(USE_GLES2) || defined(USE_OPENGL_SHADERS) -#include "graphics/opengles2/shader.h" +#include "graphics/opengl/shader.h" -namespace Graphics { +namespace OpenGL { static const GLchar *readFile(const Common::String &filename) { Common::File file; @@ -71,7 +71,7 @@ static GLuint createDirectShader(const char *shaderSource, GLenum shaderType, co static GLuint createCompatShader(const char *shaderSource, GLenum shaderType, const Common::String &name) { const GLchar *compatSource = - shaderType == GL_VERTEX_SHADER ? Graphics::BuiltinShaders::compatVertex : Graphics::BuiltinShaders::compatFragment; + shaderType == GL_VERTEX_SHADER ? OpenGL::BuiltinShaders::compatVertex : OpenGL::BuiltinShaders::compatFragment; const GLchar *shaderSources[] = { #ifdef USE_GLES2 "#version 100\n", @@ -181,7 +181,7 @@ void Shader::use(bool forceReload) { glUseProgram(*_shaderNo); for (uint32 i = 0; i < _attributes.size(); ++i) { - Graphics::VertexAttrib &attrib = _attributes[i]; + VertexAttrib &attrib = _attributes[i]; if (attrib._enabled) { glEnableVertexAttribArray(i); glBindBuffer(GL_ARRAY_BUFFER, attrib._vbo); @@ -251,6 +251,6 @@ void Shader::unbind() { glUseProgram(0); _previousShader = nullptr; } -} +} // End of namespace OpenGL #endif diff --git a/graphics/opengles2/shader.h b/graphics/opengl/shader.h similarity index 99% rename from graphics/opengles2/shader.h rename to graphics/opengl/shader.h index fbeb9cfa7aa..e0d5576849d 100644 --- a/graphics/opengles2/shader.h +++ b/graphics/opengl/shader.h @@ -35,7 +35,7 @@ #include "graphics/opengl/system_headers.h" -namespace Graphics { +namespace OpenGL { namespace BuiltinShaders { extern const char *boxVertex, *boxFragment; @@ -161,6 +161,6 @@ private: static Shader *_previousShader; }; -} +} // End of namespace OpenGL #endif