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>2013-04-14 01:09:02 +0400
committerMitchell Stokes <mogurijin@gmail.com>2013-04-14 01:09:02 +0400
commitdbf4328f3fba5e1fbd39422d6a322f752e2e122e (patch)
treedc45fce6c38bdc9bf9ddb9a699a8c40a05a5e2f0
parent81cfbaacb001ade11f52c3150b4aa6aaff965c64 (diff)
BGE: Adding a render.setFullScreen() and a render.getFullScreen() to allow fulscreening games via Python.
-rw-r--r--doc/python_api/rst/bge.render.rst11
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp11
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.h8
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp13
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.h2
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp13
-rw-r--r--source/gameengine/Rasterizer/RAS_ICanvas.h10
7 files changed, 68 insertions, 0 deletions
diff --git a/doc/python_api/rst/bge.render.rst b/doc/python_api/rst/bge.render.rst
index e203826d318..fbf20eeccaf 100644
--- a/doc/python_api/rst/bge.render.rst
+++ b/doc/python_api/rst/bge.render.rst
@@ -86,6 +86,17 @@ Functions
:type width: integer
:type height: integer
+.. function:: setFullScreen(enable)
+
+ Set whether or not the window should be fullscreen.
+
+ :type enable: bool
+
+.. function:: getFullScreen()
+
+ Returns whether or not the window is fullscreen.
+
+ :rtype: bool
.. function:: makeScreenshot(filename)
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
index e15b8ac942f..b6c41064282 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
@@ -70,6 +70,17 @@ void KX_BlenderCanvas::ResizeWindow(int width, int height)
// Not implemented for the embedded player
}
+void KX_BlenderCanvas::SetFullScreen(bool enable)
+{
+ // Not implemented for the embedded player
+}
+
+bool KX_BlenderCanvas::GetFullScreen()
+{
+ // Not implemented for the embedded player
+ return false;
+}
+
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 430f956bc7f..bc487504eeb 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
@@ -86,6 +86,14 @@ public:
);
void
+ SetFullScreen(
+ bool enable
+ );
+
+ bool
+ GetFullScreen();
+
+ void
BeginFrame(
);
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
index 9b01cb5786f..c438dcdd4a6 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
@@ -128,6 +128,19 @@ void GPG_Canvas::ResizeWindow(int width, int height)
Resize(width, height);
}
+void GPG_Canvas::SetFullScreen(bool enable)
+{
+ if (enable)
+ m_window->setState(GHOST_kWindowStateFullScreen);
+ else
+ m_window->setState(GHOST_kWindowStateNormal);
+}
+
+bool GPG_Canvas::GetFullScreen()
+{
+ return m_window->getState() == GHOST_kWindowStateFullScreen;
+}
+
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 440fd2bba27..6168d96b337 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
+++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
@@ -61,6 +61,8 @@ public:
virtual float GetMouseNormalizedY(int y);
virtual void ResizeWindow(int width, int height);
+ virtual void SetFullScreen(bool enable);
+ virtual bool GetFullScreen();
bool BeginDraw() { return true; }
void EndDraw() {};
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 0bdf08bc25f..af6297369bd 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -1327,6 +1327,17 @@ static PyObject *gPySetWindowSize(PyObject *, PyObject *args)
Py_RETURN_NONE;
}
+static PyObject *gPySetFullScreen(PyObject *, PyObject *value)
+{
+ gp_Canvas->SetFullScreen(PyObject_IsTrue(value));
+ Py_RETURN_NONE;
+}
+
+static PyObject *gPyGetFullScreen(PyObject *)
+{
+ return PyBool_FromLong(gp_Canvas->GetFullScreen());
+}
+
static struct PyMethodDef rasterizer_methods[] = {
{"getWindowWidth",(PyCFunction) gPyGetWindowWidth,
METH_VARARGS, "getWindowWidth doc"},
@@ -1368,6 +1379,8 @@ static struct PyMethodDef rasterizer_methods[] = {
{"drawLine", (PyCFunction) gPyDrawLine,
METH_VARARGS, "draw a line on the screen"},
{"setWindowSize", (PyCFunction) gPySetWindowSize, METH_VARARGS, ""},
+ {"setFullScreen", (PyCFunction) gPySetFullScreen, METH_O, ""},
+ {"getFullScreen", (PyCFunction) gPyGetFullScreen, METH_NOARGS, ""},
{ NULL, (PyCFunction) NULL, 0, NULL }
};
diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h
index 63ad7892aa5..1b1e43a5257 100644
--- a/source/gameengine/Rasterizer/RAS_ICanvas.h
+++ b/source/gameengine/Rasterizer/RAS_ICanvas.h
@@ -232,6 +232,16 @@ public:
int height
)=0;
+ virtual
+ void
+ SetFullScreen(
+ bool enable
+ )=0;
+
+ virtual
+ bool
+ GetFullScreen()=0;
+
protected: