Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2012-01-23 00:25:25 +0400
committerMitchell Stokes <mogurijin@gmail.com>2012-01-23 00:25:25 +0400
commit686ce92fe88d166f0fa1658363c4de8c1b5009b2 (patch)
treeb811169ce9e199a4da77f503ae9a3bed9f61683d
parent359e961a12e5c2f6432b8d65a543d2d6e389ba17 (diff)
Committing patch "[#27676] Change window size/resolution in realtime" by me.
Description: This patch allows the user to change the size of the window (or the resolution in fullscreen mode) using the new bge.render.setWindowSize() method. This only works in the Blenderplayer since it doesn't make a whole lot of sense for the embedded player.
-rw-r--r--doc/python_api/rst/bge.render.rst8
-rw-r--r--intern/ghost/GHOST_ISystem.h9
-rw-r--r--intern/ghost/intern/GHOST_System.cpp13
-rw-r--r--intern/ghost/intern/GHOST_System.h9
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp5
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.h2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_Canvas.h1
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp20
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.h2
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp11
-rw-r--r--source/gameengine/Rasterizer/RAS_ICanvas.h9
11 files changed, 88 insertions, 1 deletions
diff --git a/doc/python_api/rst/bge.render.rst b/doc/python_api/rst/bge.render.rst
index eeb50a833ff..ddc05ac1d8c 100644
--- a/doc/python_api/rst/bge.render.rst
+++ b/doc/python_api/rst/bge.render.rst
@@ -77,6 +77,14 @@ Functions
:rtype: integer
+.. function:: setWindowSize(width, height)
+
+ Set the width and height of the window (in pixels). This also works for fullscreen applications.
+
+ :type width: integer
+ :type height: integer
+
+
.. function:: makeScreenshot(filename)
Writes a screenshot to the given filename.
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 3ec8d3d2fbf..ee67694760b 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -271,6 +271,15 @@ public:
*/
virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window,
const bool stereoVisual, const GHOST_TUns16 numOfAASamples=0) = 0;
+
+ /**
+ * Updates the resolution while in fullscreen mode.
+ * @param setting The new setting of the display.
+ * @param window Window displayed in full screen.
+ *
+ * @return Indication of success.
+ */
+ virtual GHOST_TSuccess updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window) = 0;
/**
* Ends full screen mode.
diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp
index 4efdcbc6519..944ade3f22b 100644
--- a/intern/ghost/intern/GHOST_System.cpp
+++ b/intern/ghost/intern/GHOST_System.cpp
@@ -168,6 +168,19 @@ GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting
}
+GHOST_TSuccess GHOST_System::updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window)
+{
+ GHOST_TSuccess success = GHOST_kFailure;
+ GHOST_ASSERT(m_windowManager, "GHOST_System::updateFullScreen(): invalid window manager");
+ if(m_displayManager) {
+ if (m_windowManager->getFullScreen()) {
+ success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, setting);
+ }
+ }
+
+ return success;
+}
+
GHOST_TSuccess GHOST_System::endFullScreen(void)
{
GHOST_TSuccess success = GHOST_kFailure;
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index 6286121719d..0bb0387a287 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -145,6 +145,15 @@ public:
*/
virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window,
const bool stereoVisual, const GHOST_TUns16 numOfAASamples=0);
+
+ /**
+ * Updates the resolution while in fullscreen mode.
+ * @param setting The new setting of the display.
+ * @param window Window displayed in full screen.
+ *
+ * @return Indication of success.
+ */
+ virtual GHOST_TSuccess updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window);
/**
* Ends full screen mode.
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
index 2a21b531b6b..7e7b3d2e3d4 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
@@ -59,6 +59,11 @@ void KX_BlenderCanvas::SwapBuffers()
BL_SwapBuffers(m_win);
}
+void KX_BlenderCanvas::ResizeWindow(int width, int height)
+{
+ // Not implemented for the embedded player
+}
+
void KX_BlenderCanvas::BeginFrame()
{
glEnable(GL_DEPTH_TEST);
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
index 1f38cf9766d..44dffb5bc54 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
@@ -78,7 +78,7 @@ public:
SwapBuffers(
);
void
- Resize(
+ ResizeWindow(
int width,
int height
);
diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h
index 6ac1323783b..a9d7ab1b93f 100644
--- a/source/gameengine/GamePlayer/common/GPC_Canvas.h
+++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h
@@ -103,6 +103,7 @@ public:
void Resize(int width, int height);
+ virtual void ResizeWindow(int width, int height){};
/**
* @section Methods inherited from abstract base class RAS_ICanvas.
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
index 4b5d2bbf96a..9b01cb5786f 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
@@ -108,6 +108,26 @@ void GPG_Canvas::SwapBuffers()
}
}
+void GPG_Canvas::ResizeWindow(int width, int height)
+{
+ if (m_window->getState() == GHOST_kWindowStateFullScreen)
+ {
+ GHOST_ISystem* system = GHOST_ISystem::getSystem();
+ GHOST_DisplaySetting setting;
+ setting.xPixels = width;
+ setting.yPixels = height;
+ //XXX allow these to be changed or kept from previous state
+ setting.bpp = 32;
+ setting.frequency = 60;
+
+ system->updateFullScreen(setting, &m_window);
+ }
+
+ m_window->setClientSize(width, height);
+
+ Resize(width, height);
+}
+
float GPG_Canvas::GetMouseNormalizedX(int x)
{
return float(x)/this->GetWidth();
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
index c1ebb09251c..217cfc5eb88 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
+++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
@@ -60,6 +60,8 @@ public:
virtual float GetMouseNormalizedX(int x);
virtual float GetMouseNormalizedY(int y);
+ virtual void ResizeWindow(int width, int height);
+
bool BeginDraw() { return true;};
void EndDraw() {};
};
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 114ca735265..32106b1fdd8 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -1288,6 +1288,16 @@ static PyObject* gPyDrawLine(PyObject*, PyObject* args)
Py_RETURN_NONE;
}
+static PyObject* gPySetWindowSize(PyObject*, PyObject* args)
+{
+ int width, height;
+ if (!PyArg_ParseTuple(args, "ii:resize", &width, &height))
+ return NULL;
+
+ gp_Canvas->ResizeWindow(width, height);
+ Py_RETURN_NONE;
+}
+
static struct PyMethodDef rasterizer_methods[] = {
{"getWindowWidth",(PyCFunction) gPyGetWindowWidth,
METH_VARARGS, "getWindowWidth doc"},
@@ -1329,6 +1339,7 @@ static struct PyMethodDef rasterizer_methods[] = {
METH_VARARGS, "get the anisotropic filtering level"},
{"drawLine", (PyCFunction) gPyDrawLine,
METH_VARARGS, "draw a line on the screen"},
+ {"setWindowSize", (PyCFunction) gPySetWindowSize, METH_VARARGS, ""},
{ NULL, (PyCFunction) NULL, 0, NULL }
};
diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h
index d7e2f237bb0..2c2f62c946e 100644
--- a/source/gameengine/Rasterizer/RAS_ICanvas.h
+++ b/source/gameengine/Rasterizer/RAS_ICanvas.h
@@ -205,6 +205,15 @@ public:
MakeScreenShot(
const char* filename
)=0;
+
+ virtual
+ void
+ ResizeWindow(
+ int width,
+ int height
+ )=0;
+
+
protected:
RAS_MouseState m_mousestate;