Commit: e36b0cb8f32fc4302499c87e5c2b4c1ecc7a6543
Author: Thomas Szepe
Date:   Tue Apr 7 18:32:25 2015 +0200
Branches: master
https://developer.blender.org/rBe36b0cb8f32fc4302499c87e5c2b4c1ecc7a6543

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

===================================================================

M       doc/python_api/rst/bge.render.rst
M       source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
M       source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
M       source/gameengine/GamePlayer/common/GPC_Canvas.h
M       source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp
M       source/gameengine/GamePlayer/ghost/GPG_Canvas.h
M       source/gameengine/Ketsji/KX_PythonInit.cpp
M       source/gameengine/Rasterizer/RAS_ICanvas.h

===================================================================

diff --git a/doc/python_api/rst/bge.render.rst 
b/doc/python_api/rst/bge.render.rst
index 651693b..1748ae1 100644
--- a/doc/python_api/rst/bge.render.rst
+++ b/doc/python_api/rst/bge.render.rst
@@ -123,6 +123,12 @@ Functions
 
    :rtype: bool
 
+.. function:: getDisplayDimensions()
+
+   Get the actual display dimensions, in pixels, of the physical display 
(e.g., the monitor).
+   
+   :type dimension: list [width,heigh] 
+
 .. function:: makeScreenshot(filename)
 
    Writes an image file with the current displayed frame.
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp 
b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
index 3a31806..e378186 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 c150af2..817a667 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 acbea47..34cc975 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 556f858..09eb169 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 337c2ce..18afbf6 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 18b25d3..420e0be 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 d90cbea..471c2c9 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(

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to