summaryrefslogtreecommitdiff
path: root/src/render/graphics.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-12-13 02:30:25 +0300
committerAndrei Karas <akaras@inbox.ru>2015-12-13 02:31:19 +0300
commit0020c3ef152041998e04a3e2d227e719509f2a63 (patch)
tree663a4b657c58c4d8d46695bf7788b0e7cda3279c /src/render/graphics.cpp
parentbe4ed51b29f77de23f6ffbf61df65554c6a394ad (diff)
downloadmanaplus-0020c3ef152041998e04a3e2d227e719509f2a63.tar.gz
manaplus-0020c3ef152041998e04a3e2d227e719509f2a63.tar.bz2
manaplus-0020c3ef152041998e04a3e2d227e719509f2a63.tar.xz
manaplus-0020c3ef152041998e04a3e2d227e719509f2a63.zip
Allow resize nacl window with OpenGL without recreating context.
Diffstat (limited to 'src/render/graphics.cpp')
-rw-r--r--src/render/graphics.cpp42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index ca97e86ee..16e28b5fe 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -78,6 +78,7 @@
#ifdef USE_OPENGL
#include "resources/openglimagehelper.h"
#if defined(__native_client__)
+#include "render/naclfunctions.h"
#include "render/naclgles.h"
#endif
#endif
@@ -512,7 +513,7 @@ bool Graphics::resizeScreen(const int width, const int height)
// Setup OpenGL
glViewport(0, 0, mActualWidth, mActualHeight);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
-#else
+#else // USE_OPENGL
// +++ need impliment resize in soft mode
#endif // USE_OPENGL
@@ -520,23 +521,44 @@ bool Graphics::resizeScreen(const int width, const int height)
beginDraw();
return true;
-#else
+#else // USE_SDL2
+
const int prevWidth = mWidth;
const int prevHeight = mHeight;
endDraw();
- const bool success = setVideoMode(width, height, mScale, mBpp,
- mFullscreen, mHWAccel, mEnableResize, mNoFrame);
+ const bool success = true;
+#ifdef __native_client__
+ if (mOpenGL != RENDER_SOFTWARE)
+ {
+ mRect.w = static_cast<int32_t>(width / mScale);
+ mRect.h = static_cast<int32_t>(height / mScale);
+ mWidth = width / mScale;
+ mHeight = height / mScale;
+ mActualWidth = width;
+ mActualHeight = height;
+#ifdef USE_OPENGL
+ naclResizeBuffers(mActualWidth, mActualHeight);
+ glViewport(0, 0, mActualWidth, mActualHeight);
+#endif // USE_OPENGL
- // If it didn't work, try to restore the previous size. If that didn't
- // work either, bail out (but then we're in deep trouble).
- if (!success)
+ }
+ else
+#endif // __native_client__
{
- if (!setVideoMode(prevWidth, prevHeight, mScale, mBpp,
- mFullscreen, mHWAccel, mEnableResize, mNoFrame))
+ bool success = setVideoMode(width, height, mScale, mBpp,
+ mFullscreen, mHWAccel, mEnableResize, mNoFrame);
+
+ // If it didn't work, try to restore the previous size. If that didn't
+ // work either, bail out (but then we're in deep trouble).
+ if (!success)
{
- return false;
+ if (!setVideoMode(prevWidth, prevHeight, mScale, mBpp,
+ mFullscreen, mHWAccel, mEnableResize, mNoFrame))
+ {
+ return false;
+ }
}
}