summaryrefslogtreecommitdiff
path: root/src/render/modernopenglgraphics.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-07-02 19:33:01 +0300
committerAndrei Karas <akaras@inbox.ru>2014-07-02 19:33:01 +0300
commiteda234f5e156d376541044b351fd2e1e766700a3 (patch)
tree56ef425beb88fe84c280dea3a3ddeef676553589 /src/render/modernopenglgraphics.cpp
parent5ce62dae5b3848833765a19296ffd9fd7e9721d8 (diff)
downloadplus-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.cpp22
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)