summaryrefslogtreecommitdiff
path: root/src
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
parentbe4ed51b29f77de23f6ffbf61df65554c6a394ad (diff)
downloadmv-0020c3ef152041998e04a3e2d227e719509f2a63.tar.gz
mv-0020c3ef152041998e04a3e2d227e719509f2a63.tar.bz2
mv-0020c3ef152041998e04a3e2d227e719509f2a63.tar.xz
mv-0020c3ef152041998e04a3e2d227e719509f2a63.zip
Allow resize nacl window with OpenGL without recreating context.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/render/graphics.cpp42
-rw-r--r--src/render/naclfunctions.h35
-rw-r--r--src/render/naclgles.cpp4
-rw-r--r--src/render/naclgles.h2
6 files changed, 73 insertions, 12 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a1fb32532..6501974bb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1013,6 +1013,7 @@ SET(SRCS
render/mobileopenglgraphics.h
render/modernopenglgraphics.cpp
render/modernopenglgraphics.h
+ render/naclfunctions.h
render/naclgles.cpp
render/naclgles.h
input/mouseinput.h
diff --git a/src/Makefile.am b/src/Makefile.am
index aeb73164b..992a7b396 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -520,6 +520,7 @@ SRC += events/actionevent.h \
render/mobileopenglgraphics.h \
render/modernopenglgraphics.cpp \
render/modernopenglgraphics.h \
+ render/naclfunctions.h \
render/naclgles.cpp \
render/naclgles.h \
render/naclglfunctions.h \
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;
+ }
}
}
diff --git a/src/render/naclfunctions.h b/src/render/naclfunctions.h
new file mode 100644
index 000000000..940d02015
--- /dev/null
+++ b/src/render/naclfunctions.h
@@ -0,0 +1,35 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RENDER_NACLFUNCTIONS_H
+#define RENDER_NACLFUNCTIONS_H
+
+#if defined(__native_client__) && defined(USE_OPENGL)
+
+#include <ppapi/c/ppb_graphics_3d.h>
+
+extern const struct PPB_Graphics3D_1_0 *graphics3dInterface;
+extern PP_Resource gles2Context;
+
+#define naclResizeBuffers(...) \
+ graphics3dInterface->ResizeBuffers(gles2Context, __VA_ARGS__)
+
+#endif // defined(__native_client__) && defined(USE_OPENGL)
+#endif // RENDER_NACLFUNCTIONS_H
diff --git a/src/render/naclgles.cpp b/src/render/naclgles.cpp
index ef53e6849..6451b6a36 100644
--- a/src/render/naclgles.cpp
+++ b/src/render/naclgles.cpp
@@ -28,6 +28,7 @@
#include <ppapi_simple/ps.h>
+#include <ppapi/c/ppb_graphics_3d.h>
#include <ppapi/c/ppb_opengles2.h>
#include <ppapi/gles2/gl2ext_ppapi.h>
@@ -36,11 +37,14 @@
const struct PPB_OpenGLES2* gles2Interface = nullptr;
PP_Resource gles2Context = nullptr;
+const struct PPB_Graphics3D_1_0 *graphics3dInterface = nullptr;
void NaclGles::initGles()
{
gles2Interface = static_cast<const PPB_OpenGLES2*>(
PSGetInterface(PPB_OPENGLES2_INTERFACE));
+ graphics3dInterface = static_cast<const PPB_Graphics3D_1_0*>(
+ PSGetInterface(PPB_GRAPHICS_3D_INTERFACE_1_0));
gles2Context = glGetCurrentContextPPAPI();
logger->log("InitGles: %p, %d", gles2Interface, gles2Context);
diff --git a/src/render/naclgles.h b/src/render/naclgles.h
index 44b1a1f97..aaa4459d2 100644
--- a/src/render/naclgles.h
+++ b/src/render/naclgles.h
@@ -23,8 +23,6 @@
#if defined(__native_client__) && defined(USE_OPENGL)
-#include <ppapi/c/ppb_opengles2.h>
-
namespace NaclGles
{
void initGles();