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:
authorThomas Szepe <HG1_public@gmx.net>2015-04-07 19:32:25 +0300
committerThomas Szepe <HG1_public@gmx.net>2015-04-07 19:32:25 +0300
commite36b0cb8f32fc4302499c87e5c2b4c1ecc7a6543 (patch)
tree53fcd2ebd7775bebc00f8ca5960a2bd18145e17e /source/gameengine
parentf9f3c29a3a5b558e09c36076521bdafc91e7e326 (diff)
BGE: New API method getDisplayDimensions
This patch adds a new API function to get the actual display dimensions in pixels. Reviewers: dfelinto, sybren, lordloki, moguri Reviewed By: lordloki, moguri Differential Revision: https://developer.blender.org/D648
Diffstat (limited to 'source/gameengine')
-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.h2
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp12
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Canvas.h2
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp16
-rw-r--r--source/gameengine/Rasterizer/RAS_ICanvas.h2
7 files changed, 41 insertions, 0 deletions
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
index 3a31806fad4..e37818678d6 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
@@ -97,6 +97,11 @@ bool KX_BlenderCanvas::GetSwapInterval(int &intervalOut)
return wm_window_get_swap_interval(m_win, &intervalOut);
}
+void KX_BlenderCanvas::GetDisplayDimensions(int &width, int &height)
+{
+ wm_get_screensize(&width, &height);
+}
+
void KX_BlenderCanvas::ResizeWindow(int width, int height)
{
// Not implemented for the embedded player
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
index c150af21230..817a667d783 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
@@ -87,6 +87,8 @@ public:
int &intervalOut
);
+ void GetDisplayDimensions(int &width, int &height);
+
void
ResizeWindow(
int width,
diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h
index acbea477e38..34cc9759a08 100644
--- a/source/gameengine/GamePlayer/common/GPC_Canvas.h
+++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h
@@ -71,6 +71,8 @@ public:
virtual void ResizeWindow(int width, int height) {}
+ virtual void GetDisplayDimensions(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 556f85804ea..09eb1691dae 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
@@ -121,6 +121,18 @@ bool GPG_Canvas::GetSwapInterval(int& intervalOut)
return false;
}
+void GPG_Canvas::GetDisplayDimensions(int &width, int &height)
+ {
+ unsigned int uiwidth;
+ unsigned int uiheight;
+
+ GHOST_ISystem *system = GHOST_ISystem::getSystem();
+ system->getMainDisplayDimensions(uiwidth, uiheight);
+
+ width = uiwidth;
+ height = uiheight;
+}
+
void GPG_Canvas::ResizeWindow(int width, int height)
{
if (m_window->getState() == GHOST_kWindowStateFullScreen)
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
index 337c2cedf55..18afbf6cd9e 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
+++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h
@@ -63,6 +63,8 @@ public:
virtual float GetMouseNormalizedX(int x);
virtual float GetMouseNormalizedY(int y);
+ virtual void GetDisplayDimensions(int &width, int &height);
+
virtual void ResizeWindow(int width, int height);
virtual void SetFullScreen(bool enable);
virtual bool GetFullScreen();
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 18b25d340dd..420e0be8c5d 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -1403,6 +1403,20 @@ static PyObject *gPyClearDebugList(PyObject *)
Py_RETURN_NONE;
}
+static PyObject *gPyGetDisplayDimensions(PyObject *)
+{
+ PyObject *list = PyList_New(0);
+ int width;
+ int height;
+
+ gp_Canvas->GetDisplayDimensions(width, height);
+
+ PyList_Append(list, PyLong_FromLong(width));
+ PyList_Append(list, PyLong_FromLong(height));
+
+ return list;
+}
+
PyDoc_STRVAR(Rasterizer_module_documentation,
"This is the Python API for the game engine of Rasterizer"
);
@@ -1446,6 +1460,8 @@ static struct PyMethodDef rasterizer_methods[] = {
{"setWindowSize", (PyCFunction) gPySetWindowSize, METH_VARARGS, ""},
{"setFullScreen", (PyCFunction) gPySetFullScreen, METH_O, ""},
{"getFullScreen", (PyCFunction) gPyGetFullScreen, METH_NOARGS, ""},
+ {"getDisplayDimensions", (PyCFunction) gPyGetDisplayDimensions, METH_NOARGS,
+ "Get the actual dimensions, in pixels, of the physical display (e.g., the monitor)."},
{"setMipmapping", (PyCFunction) gPySetMipmapping, METH_VARARGS, ""},
{"getMipmapping", (PyCFunction) gPyGetMipmapping, METH_NOARGS, ""},
{"setVsync", (PyCFunction) gPySetVsync, METH_VARARGS, ""},
diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h
index d90cbea286e..471c2c97fa1 100644
--- a/source/gameengine/Rasterizer/RAS_ICanvas.h
+++ b/source/gameengine/Rasterizer/RAS_ICanvas.h
@@ -237,6 +237,8 @@ public:
const char* filename
)=0;
+ virtual void GetDisplayDimensions(int &width, int &height) = 0;
+
virtual
void
ResizeWindow(