diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-06-14 23:22:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-06-14 23:37:06 +0300 |
commit | bc6c26b7616281cbeaf0987869f117664d829908 (patch) | |
tree | ffa64105836b7e28db724c66f4a8829a39b79762 /src | |
parent | 447729b01b7412833cc36e79f1ce9ebe15bf0e06 (diff) | |
download | manaplus-bc6c26b7616281cbeaf0987869f117664d829908.tar.gz manaplus-bc6c26b7616281cbeaf0987869f117664d829908.tar.bz2 manaplus-bc6c26b7616281cbeaf0987869f117664d829908.tar.xz manaplus-bc6c26b7616281cbeaf0987869f117664d829908.zip |
In modernopengl add support for EBO, but unused.
Diffstat (limited to 'src')
-rw-r--r-- | src/render/modernopenglgraphics.cpp | 32 | ||||
-rw-r--r-- | src/render/modernopenglgraphics.h | 4 |
2 files changed, 34 insertions, 2 deletions
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp index de3bba76a..a166f64b9 100644 --- a/src/render/modernopenglgraphics.cpp +++ b/src/render/modernopenglgraphics.cpp @@ -97,7 +97,9 @@ ModernOpenGLGraphics::ModernOpenGLGraphics() : mDrawTypeUniform(0U), mVao(0U), mVbo(0U), + mEbo(0U), mVboCached(0U), + mEboCached(0U), mAttributesCached(0U), mColorAlpha(false), mTextureDraw(false), @@ -118,9 +120,14 @@ ModernOpenGLGraphics::~ModernOpenGLGraphics() mProgram->decRef(); if (mVbo) { -// logger->log("delete buffer: %u", mVbo); +// logger->log("delete buffer vbo: %u", mVbo); mglDeleteBuffers(1, &mVbo); } + if (mEbo) + { +// logger->log("delete buffer ebo: %u", mEbo); + mglDeleteBuffers(1, &mEbo); + } if (mVao) mglDeleteVertexArrays(1, &mVao); } @@ -147,8 +154,11 @@ void ModernOpenGLGraphics::postInit() mglGenVertexArrays(1, &mVao); mglBindVertexArray(mVao); mglGenBuffers(1, &mVbo); - //logger->log("gen buffer: %u", mVbo); + //logger->log("gen vbo buffer: %u", mVbo); bindArrayBuffer(mVbo); + mglGenBuffers(1, &mEbo); + //logger->log("gen ebo buffer: %u", mEbo); + bindElementBuffer(mEbo); logger->log("Compiling shaders"); mProgram = shaders.getSimpleProgram(); @@ -338,12 +348,16 @@ void ModernOpenGLGraphics::testDraw() }; //logger->log("allocate: %d, %ld", mVboCached, sizeof(vertices)); + //logger->log("allocate ebo: %d, %ld", mEboCached, sizeof(elements)); mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STREAM_DRAW); +// mglBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elements), +// elements, GL_STREAM_DRAW); #ifdef DEBUG_DRAW_CALLS mDrawCalls ++; #endif glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); +// glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, 0); } void ModernOpenGLGraphics::drawImageCached(const Image *const image A_UNUSED, @@ -1148,6 +1162,20 @@ void ModernOpenGLGraphics::bindArrayBuffer(const GLuint vbo) } } +void ModernOpenGLGraphics::bindElementBuffer(const GLuint ebo) +{ + if (mEboCached != ebo) + { + mEboCached = ebo; + logger->log("bind element: %u", ebo); + mglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); +/* + if (mglIsBuffer(ebo) != GL_TRUE) + logger->log("bind wrong buffer: %u", vbo); +*/ + } +} + void ModernOpenGLGraphics::bindArrayBufferAndAttributes(const GLuint vbo) { if (mVboCached != vbo) diff --git a/src/render/modernopenglgraphics.h b/src/render/modernopenglgraphics.h index b5f7fdd3a..28a7f8bbb 100644 --- a/src/render/modernopenglgraphics.h +++ b/src/render/modernopenglgraphics.h @@ -107,6 +107,8 @@ class ModernOpenGLGraphics final : public Graphics inline void bindAttributes(); + inline void bindElementBuffer(const GLuint ebo); + GLint *mIntArray; GLint *mIntArrayCached; ShaderProgram *mProgram; @@ -123,7 +125,9 @@ class ModernOpenGLGraphics final : public Graphics GLuint mDrawTypeUniform; GLuint mVao; GLuint mVbo; + GLuint mEbo; GLuint mVboCached; + GLuint mEboCached; GLuint mAttributesCached; bool mColorAlpha; bool mTextureDraw; |