diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-02 19:33:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-02 19:33:01 +0300 |
commit | eda234f5e156d376541044b351fd2e1e766700a3 (patch) | |
tree | 56ef425beb88fe84c280dea3a3ddeef676553589 /src/render/modernopenglgraphics.cpp | |
parent | 5ce62dae5b3848833765a19296ffd9fd7e9721d8 (diff) | |
download | plus-eda234f5e156d376541044b351fd2e1e766700a3.tar.gz plus-eda234f5e156d376541044b351fd2e1e766700a3.tar.bz2 plus-eda234f5e156d376541044b351fd2e1e766700a3.tar.xz plus-eda234f5e156d376541044b351fd2e1e766700a3.zip |
Fix resize in modernopengl with own context in SDL1.2 build.
Diffstat (limited to 'src/render/modernopenglgraphics.cpp')
-rw-r--r-- | src/render/modernopenglgraphics.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp index 1fadba3c4..eb245e0de 100644 --- a/src/render/modernopenglgraphics.cpp +++ b/src/render/modernopenglgraphics.cpp @@ -117,6 +117,11 @@ ModernOpenGLGraphics::ModernOpenGLGraphics() : ModernOpenGLGraphics::~ModernOpenGLGraphics() { deleteArraysInternal(); + deleteGLObjects(); +} + +void ModernOpenGLGraphics::deleteGLObjects() +{ if (mProgram) mProgram->decRef(); if (mVbo) @@ -191,14 +196,18 @@ void ModernOpenGLGraphics::postInit() // mglVertexAttribIPointer(mPosAttrib, 4, GL_INT, 4 * sizeof(GLint), 0); mAttributesCached = mVbo; - screenResized(); + mglUniform2f(mScreenUniform, + static_cast<float>(mWidth) / 2.0f, + static_cast<float>(mHeight) / 2.0f); } void ModernOpenGLGraphics::screenResized() { - mglUniform2f(mScreenUniform, - static_cast<float>(mWidth) / 2.0f, - static_cast<float>(mHeight) / 2.0f); + deleteGLObjects(); + mVboCached = 0U; + mEboCached = 0U; + mAttributesCached = 0U; + postInit(); } void ModernOpenGLGraphics::deleteArrays() @@ -1261,7 +1270,10 @@ void ModernOpenGLGraphics::clearScreen() const void ModernOpenGLGraphics::createGLContext() { - mGLContext = SDL::createGLContext(mWindow, 3, 3); + if (mGLContext) + SDL::makeCurrentContext(mGLContext); + else + mGLContext = SDL::createGLContext(mWindow, 3, 3); } void ModernOpenGLGraphics::finalize(ImageCollection *const col) |