diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-06-11 12:44:57 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-06-11 12:44:57 +0300 |
commit | e8a8db1e71d90eda2f76b6c34afc8c1ec5cd2b8b (patch) | |
tree | 8877badb3d70f78adf16bdd57c8bd3217877b783 | |
parent | 16aee7e951a63492548380517eb550be93ce4369 (diff) | |
download | mv-e8a8db1e71d90eda2f76b6c34afc8c1ec5cd2b8b.tar.gz mv-e8a8db1e71d90eda2f76b6c34afc8c1ec5cd2b8b.tar.bz2 mv-e8a8db1e71d90eda2f76b6c34afc8c1ec5cd2b8b.tar.xz mv-e8a8db1e71d90eda2f76b6c34afc8c1ec5cd2b8b.zip |
In modernopengl for textures use one attribute (before was two)
-rw-r--r-- | data/graphics/shaders/texture_vertex.glsl | 5 | ||||
-rw-r--r-- | src/render/modernopenglgraphics.cpp | 16 | ||||
-rw-r--r-- | src/render/modernopenglgraphics.h | 1 |
3 files changed, 3 insertions, 19 deletions
diff --git a/data/graphics/shaders/texture_vertex.glsl b/data/graphics/shaders/texture_vertex.glsl index c86d9211f..a10a39b13 100644 --- a/data/graphics/shaders/texture_vertex.glsl +++ b/data/graphics/shaders/texture_vertex.glsl @@ -1,10 +1,9 @@ #version 150 core -in vec2 position; -in vec2 texcoord; +in vec4 position; out vec2 Texcoord; uniform vec2 screen; void main() { - Texcoord = texcoord; + Texcoord = vec2(position.z, position.w); gl_Position = vec4(position.x / screen.x - 1, 1 - position.y / screen.y, 0.0, 1.0); } diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp index 7ab94348c..3241821ba 100644 --- a/src/render/modernopenglgraphics.cpp +++ b/src/render/modernopenglgraphics.cpp @@ -100,7 +100,6 @@ ModernOpenGLGraphics::ModernOpenGLGraphics() : mSimpleColorUniform(0U), mSimplePosAttrib(0), mTexturePosAttrib(0), - mTexAttrib(0), mSimpleScreenUniform(0U), mTextureScreenUniform(0U), mVao(0U), @@ -169,10 +168,8 @@ void ModernOpenGLGraphics::postInit() mglVertexAttribFormat(mSimplePosAttrib, 2, GL_FLOAT, GL_FALSE, 0); mTexturePosAttrib = mglGetAttribLocation(mTextureProgramId, "position"); - mTexAttrib = mglGetAttribLocation(mTextureProgramId, "texcoord"); mTextureScreenUniform = mglGetUniformLocation(mTextureProgramId, "screen"); - mglVertexAttribFormat(mTexturePosAttrib, 2, GL_FLOAT, GL_FALSE, 0); - mglVertexAttribFormat(mTexAttrib, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat)); + mglVertexAttribFormat(mTexturePosAttrib, 4, GL_FLOAT, GL_FALSE, 0); screenResized(); } @@ -288,11 +285,7 @@ void ModernOpenGLGraphics::drawQuad(const Image *const image, }; mglBindVertexBuffer(0, mVbo, 0, 4 * sizeof(GLfloat)); - mglBindVertexBuffer(1, mVbo, 0, 4 * sizeof(GLfloat)); - mglVertexAttribBinding(mTexturePosAttrib, 0); - mglVertexAttribBinding(mTexAttrib, 1); - mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_DYNAMIC_DRAW); @@ -761,7 +754,6 @@ void ModernOpenGLGraphics::setTexturingAndBlending(const bool enable) mglDisableVertexAttribArray(mSimplePosAttrib); mglUseProgram(mTextureProgramId); mglEnableVertexAttribArray(mTexturePosAttrib); - mglEnableVertexAttribArray(mTexAttrib); } if (!mAlpha) { @@ -775,7 +767,6 @@ void ModernOpenGLGraphics::setTexturingAndBlending(const bool enable) { mTextureDraw = false; mglDisableVertexAttribArray(mTexturePosAttrib); - mglDisableVertexAttribArray(mTexAttrib); mglUseProgram(mSimpleProgramId); mglEnableVertexAttribArray(mSimplePosAttrib); } @@ -855,13 +846,8 @@ void ModernOpenGLGraphics::clearScreen() const void ModernOpenGLGraphics::drawTriangleArray(const int size) { mglBindVertexBuffer(0, mVbo, 0, 4 * sizeof(GLfloat)); - mglBindVertexBuffer(1, mVbo, 0, 4 * sizeof(GLfloat)); - mglVertexAttribBinding(mTexturePosAttrib, 0); - mglVertexAttribBinding(mTexAttrib, 1); - mglBufferData(GL_ARRAY_BUFFER, size, mFloatArray, GL_DYNAMIC_DRAW); - glDrawArrays(GL_TRIANGLES, 0, size / 2);; } diff --git a/src/render/modernopenglgraphics.h b/src/render/modernopenglgraphics.h index 1fed5d371..5519fd282 100644 --- a/src/render/modernopenglgraphics.h +++ b/src/render/modernopenglgraphics.h @@ -98,7 +98,6 @@ class ModernOpenGLGraphics final : public Graphics GLuint mSimpleColorUniform; GLint mSimplePosAttrib; GLint mTexturePosAttrib; - GLint mTexAttrib; GLuint mSimpleScreenUniform; GLuint mTextureScreenUniform; GLuint mVao; |