diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-06-10 20:51:32 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-06-10 20:51:32 +0300 |
commit | d7b65dd309ce9b91be9ef4f22d55f7f4009007a2 (patch) | |
tree | 54b890ee5e06cb3f229650a66e04e05e6276b4fa /src/render/modernopenglgraphics.cpp | |
parent | 03b8fa8772ef8aadb73fb096c7ba4e257902a331 (diff) | |
download | plus-d7b65dd309ce9b91be9ef4f22d55f7f4009007a2.tar.gz plus-d7b65dd309ce9b91be9ef4f22d55f7f4009007a2.tar.bz2 plus-d7b65dd309ce9b91be9ef4f22d55f7f4009007a2.tar.xz plus-d7b65dd309ce9b91be9ef4f22d55f7f4009007a2.zip |
In modernopengl add basic VAO usage.
Diffstat (limited to 'src/render/modernopenglgraphics.cpp')
-rw-r--r-- | src/render/modernopenglgraphics.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp index caa14cb33..c3e4fbba3 100644 --- a/src/render/modernopenglgraphics.cpp +++ b/src/render/modernopenglgraphics.cpp @@ -71,6 +71,7 @@ ModernOpenGLGraphics::ModernOpenGLGraphics() : mTexAttrib(0), mSimpleScreenUniform(0U), mTextureScreenUniform(0U), + mVao(0U), mColorAlpha(false), mTextureDraw(false), #ifdef DEBUG_BIND_TEXTURE @@ -88,6 +89,8 @@ ModernOpenGLGraphics::~ModernOpenGLGraphics() deleteArraysInternal(); if (mSimpleProgram) mSimpleProgram->decRef(); + if (mVao) + mglDeleteVertexArrays(1, &mVao); } void ModernOpenGLGraphics::initArrays(const int vertCount) @@ -109,30 +112,29 @@ void ModernOpenGLGraphics::initArrays(const int vertCount) void ModernOpenGLGraphics::postInit() { + mglGenVertexArrays(1, &mVao); + mglBindVertexArray(mVao); + logger->log("Compiling shaders"); mSimpleProgram = shaders.getSimpleProgram(); mSimpleProgramId = mSimpleProgram->getProgramId(); mTextureProgram = shaders.getTextureProgram(); mTextureProgramId = mTextureProgram->getProgramId(); - if (mSimpleProgram && mTextureProgram) - { - logger->log("Shaders compilation done."); - mglUseProgram(mSimpleProgramId); - mSimplePosAttrib = mglGetAttribLocation(mSimpleProgramId, "position"); - mglEnableVertexAttribArray(mSimplePosAttrib); - mSimpleColorUniform = mglGetUniformLocation(mSimpleProgramId, "color"); - mSimpleScreenUniform = mglGetUniformLocation(mSimpleProgramId, "screen"); - - mTexturePosAttrib = mglGetAttribLocation(mTextureProgramId, "position"); - mTexAttrib = mglGetAttribLocation(mTextureProgramId, "texcoord"); - mTextureScreenUniform = mglGetUniformLocation(mTextureProgramId, "screen"); - - screenResized(); - } - else - { + if (!mSimpleProgram || !mTextureProgram) logger->error("Shaders compilation error."); - } + + logger->log("Shaders compilation done."); + mglUseProgram(mSimpleProgramId); + mSimplePosAttrib = mglGetAttribLocation(mSimpleProgramId, "position"); + mglEnableVertexAttribArray(mSimplePosAttrib); + mSimpleColorUniform = mglGetUniformLocation(mSimpleProgramId, "color"); + mSimpleScreenUniform = mglGetUniformLocation(mSimpleProgramId, "screen"); + + mTexturePosAttrib = mglGetAttribLocation(mTextureProgramId, "position"); + mTexAttrib = mglGetAttribLocation(mTextureProgramId, "texcoord"); + mTextureScreenUniform = mglGetUniformLocation(mTextureProgramId, "screen"); + + screenResized(); } void ModernOpenGLGraphics::screenResized() |