[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56025] trunk/blender: BGE: Adding a render.setFullScreen() and a render.getFullScreen() to allow fulscreening games via Python.
Mitchell Stokes
mogurijin at gmail.com
Sat Apr 13 23:09:02 CEST 2013
Revision: 56025
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56025
Author: moguri
Date: 2013-04-13 21:09:02 +0000 (Sat, 13 Apr 2013)
Log Message:
-----------
BGE: Adding a render.setFullScreen() and a render.getFullScreen() to allow fulscreening games via Python.
Modified Paths:
--------------
trunk/blender/doc/python_api/rst/bge.render.rst
trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
trunk/blender/source/gameengine/Rasterizer/RAS_ICanvas.h
Modified: trunk/blender/doc/python_api/rst/bge.render.rst
===================================================================
--- trunk/blender/doc/python_api/rst/bge.render.rst 2013-04-13 20:58:49 UTC (rev 56024)
+++ trunk/blender/doc/python_api/rst/bge.render.rst 2013-04-13 21:09:02 UTC (rev 56025)
@@ -86,7 +86,18 @@
: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)
Writes a screenshot to the given filename.
Modified: trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
===================================================================
--- trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp 2013-04-13 20:58:49 UTC (rev 56024)
+++ trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp 2013-04-13 21:09:02 UTC (rev 56025)
@@ -70,6 +70,17 @@
// 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);
Modified: trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
===================================================================
--- trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h 2013-04-13 20:58:49 UTC (rev 56024)
+++ trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h 2013-04-13 21:09:02 UTC (rev 56025)
@@ -86,6 +86,14 @@
);
void
+ SetFullScreen(
+ bool enable
+ );
+
+ bool
+ GetFullScreen();
+
+ void
BeginFrame(
);
Modified: trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
===================================================================
--- trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp 2013-04-13 20:58:49 UTC (rev 56024)
+++ trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp 2013-04-13 21:09:02 UTC (rev 56025)
@@ -128,6 +128,19 @@
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();
Modified: trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
===================================================================
--- trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Canvas.h 2013-04-13 20:58:49 UTC (rev 56024)
+++ trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Canvas.h 2013-04-13 21:09:02 UTC (rev 56025)
@@ -61,6 +61,8 @@
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() {};
Modified: trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp 2013-04-13 20:58:49 UTC (rev 56024)
+++ trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp 2013-04-13 21:09:02 UTC (rev 56025)
@@ -1327,6 +1327,17 @@
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 @@
{"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 }
};
Modified: trunk/blender/source/gameengine/Rasterizer/RAS_ICanvas.h
===================================================================
--- trunk/blender/source/gameengine/Rasterizer/RAS_ICanvas.h 2013-04-13 20:58:49 UTC (rev 56024)
+++ trunk/blender/source/gameengine/Rasterizer/RAS_ICanvas.h 2013-04-13 21:09:02 UTC (rev 56025)
@@ -232,6 +232,16 @@
int height
)=0;
+ virtual
+ void
+ SetFullScreen(
+ bool enable
+ )=0;
+
+ virtual
+ bool
+ GetFullScreen()=0;
+
protected:
More information about the Bf-blender-cvs
mailing list