summaryrefslogtreecommitdiff
path: root/src/render
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
parent5ce62dae5b3848833765a19296ffd9fd7e9721d8 (diff)
downloadManaVerse-eda234f5e156d376541044b351fd2e1e766700a3.tar.gz
ManaVerse-eda234f5e156d376541044b351fd2e1e766700a3.tar.bz2
ManaVerse-eda234f5e156d376541044b351fd2e1e766700a3.tar.xz
ManaVerse-eda234f5e156d376541044b351fd2e1e766700a3.zip
Fix resize in modernopengl with own context in SDL1.2 build.
Diffstat (limited to 'src/render')
-rw-r--r--src/render/graphics.cpp2
-rw-r--r--src/render/graphics.h6
-rw-r--r--src/render/modernopenglgraphics.cpp22
-rw-r--r--src/render/modernopenglgraphics.h4
4 files changed, 28 insertions, 6 deletions
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index a9dc968db..4c5d1d282 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -504,6 +504,7 @@ bool Graphics::resizeScreen(const int width, const int height)
// +++ need impliment resize in soft mode
#endif // USE_OPENGL
+ screenResized();
beginDraw();
return true;
@@ -527,6 +528,7 @@ bool Graphics::resizeScreen(const int width, const int height)
}
}
+ screenResized();
beginDraw();
return success;
diff --git a/src/render/graphics.h b/src/render/graphics.h
index e05f23a84..3a051ed55 100644
--- a/src/render/graphics.h
+++ b/src/render/graphics.h
@@ -167,6 +167,9 @@ class Graphics notfinal
*/
virtual bool resizeScreen(const int width, const int height);
+ virtual void restoreContext()
+ { }
+
/**
* Draws a resclaled version of the image
*/
@@ -468,6 +471,9 @@ class Graphics notfinal
uint32_t *const arr A_UNUSED)
{ }
+ virtual void screenResized()
+ { }
+
int mWidth;
int mHeight;
int mActualWidth;
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)
diff --git a/src/render/modernopenglgraphics.h b/src/render/modernopenglgraphics.h
index 2b27c621e..86e9f7bf1 100644
--- a/src/render/modernopenglgraphics.h
+++ b/src/render/modernopenglgraphics.h
@@ -64,7 +64,7 @@ class ModernOpenGLGraphics final : public Graphics
void setColorAll(const Color &color,
const Color &color2) override final;
- void screenResized();
+ void screenResized() override final;
void finalize(ImageCollection *const col) override final;
@@ -85,6 +85,8 @@ class ModernOpenGLGraphics final : public Graphics
virtual void createGLContext() override final;
private:
+ void deleteGLObjects();
+
inline void drawQuad(const Image *const image,
const int srcX, const int srcY,
const int dstX, const int dstY,