summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-06-10 21:07:18 +0300
committerAndrei Karas <akaras@inbox.ru>2014-06-10 21:07:18 +0300
commit0ae3fbab8d27f46d618a4cfe738c73c70bc3a57e (patch)
tree205e4fd2896c913762861416c49a52862be6f456 /src
parentd7b65dd309ce9b91be9ef4f22d55f7f4009007a2 (diff)
downloadplus-0ae3fbab8d27f46d618a4cfe738c73c70bc3a57e.tar.gz
plus-0ae3fbab8d27f46d618a4cfe738c73c70bc3a57e.tar.bz2
plus-0ae3fbab8d27f46d618a4cfe738c73c70bc3a57e.tar.xz
plus-0ae3fbab8d27f46d618a4cfe738c73c70bc3a57e.zip
In modernopengl Use one global VBO
Diffstat (limited to 'src')
-rw-r--r--src/render/modernopenglgraphics.cpp18
-rw-r--r--src/render/modernopenglgraphics.h1
2 files changed, 6 insertions, 13 deletions
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index c3e4fbba3..3f6c3595b 100644
--- a/src/render/modernopenglgraphics.cpp
+++ b/src/render/modernopenglgraphics.cpp
@@ -72,6 +72,7 @@ ModernOpenGLGraphics::ModernOpenGLGraphics() :
mSimpleScreenUniform(0U),
mTextureScreenUniform(0U),
mVao(0U),
+ mVbo(0U),
mColorAlpha(false),
mTextureDraw(false),
#ifdef DEBUG_BIND_TEXTURE
@@ -89,6 +90,8 @@ ModernOpenGLGraphics::~ModernOpenGLGraphics()
deleteArraysInternal();
if (mSimpleProgram)
mSimpleProgram->decRef();
+ if (mVbo)
+ mglDeleteBuffers(1, &mVbo);
if (mVao)
mglDeleteVertexArrays(1, &mVao);
}
@@ -114,6 +117,8 @@ void ModernOpenGLGraphics::postInit()
{
mglGenVertexArrays(1, &mVao);
mglBindVertexArray(mVao);
+ mglGenBuffers(1, &mVbo);
+ mglBindBuffer(GL_ARRAY_BUFFER, mVbo);
logger->log("Compiling shaders");
mSimpleProgram = shaders.getSimpleProgram();
@@ -244,9 +249,6 @@ void ModernOpenGLGraphics::drawQuad(const Image *const image,
x2, y2, texX2, texY2
};
- GLuint vbo;
- mglGenBuffers(1, &vbo);
- mglBindBuffer(GL_ARRAY_BUFFER, vbo);
mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
vertices, GL_DYNAMIC_DRAW);
@@ -617,17 +619,12 @@ void ModernOpenGLGraphics::drawRectangle(const Rect& rect)
x2, y2,
x2, y1
};
- GLuint vbo;
- mglGenBuffers(1, &vbo);
- mglBindBuffer(GL_ARRAY_BUFFER, vbo);
mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
vertices, GL_DYNAMIC_DRAW);
// mglEnableVertexAttribArray(mSimplePosAttrib);
mglVertexAttribPointer(mSimplePosAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0);
glDrawArrays(GL_LINE_LOOP, 0, 4);
-
- mglDeleteBuffers(1, &vbo);
}
void ModernOpenGLGraphics::fillRectangle(const Rect& rect)
@@ -645,17 +642,12 @@ void ModernOpenGLGraphics::fillRectangle(const Rect& rect)
x1, y2,
x2, y2
};
- GLuint vbo;
- mglGenBuffers(1, &vbo);
- mglBindBuffer(GL_ARRAY_BUFFER, vbo);
mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
vertices, GL_DYNAMIC_DRAW);
// mglEnableVertexAttribArray(mSimplePosAttrib);
mglVertexAttribPointer(mSimplePosAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- mglDeleteBuffers(1, &vbo);
}
void ModernOpenGLGraphics::setTexturingAndBlending(const bool enable)
diff --git a/src/render/modernopenglgraphics.h b/src/render/modernopenglgraphics.h
index b3a217ca2..34124bacc 100644
--- a/src/render/modernopenglgraphics.h
+++ b/src/render/modernopenglgraphics.h
@@ -100,6 +100,7 @@ class ModernOpenGLGraphics final : public Graphics
GLuint mSimpleScreenUniform;
GLuint mTextureScreenUniform;
GLuint mVao;
+ GLuint mVbo;
bool mColorAlpha;
bool mTextureDraw;
#ifdef DEBUG_BIND_TEXTURE