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
This commit is contained in:
parent
f9f3c29a3a
commit
e36b0cb8f3
@ -123,6 +123,12 @@ Functions
|
|||||||
|
|
||||||
:rtype: bool
|
: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)
|
.. function:: makeScreenshot(filename)
|
||||||
|
|
||||||
Writes an image file with the current displayed frame.
|
Writes an image file with the current displayed frame.
|
||||||
|
@ -97,6 +97,11 @@ bool KX_BlenderCanvas::GetSwapInterval(int &intervalOut)
|
|||||||
return wm_window_get_swap_interval(m_win, &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)
|
void KX_BlenderCanvas::ResizeWindow(int width, int height)
|
||||||
{
|
{
|
||||||
// Not implemented for the embedded player
|
// Not implemented for the embedded player
|
||||||
|
@ -87,6 +87,8 @@ public:
|
|||||||
int &intervalOut
|
int &intervalOut
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void GetDisplayDimensions(int &width, int &height);
|
||||||
|
|
||||||
void
|
void
|
||||||
ResizeWindow(
|
ResizeWindow(
|
||||||
int width,
|
int width,
|
||||||
|
@ -71,6 +71,8 @@ public:
|
|||||||
|
|
||||||
virtual void ResizeWindow(int width, int height) {}
|
virtual void ResizeWindow(int width, int height) {}
|
||||||
|
|
||||||
|
virtual void GetDisplayDimensions(int &width, int &height) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \section Methods inherited from abstract base class RAS_ICanvas.
|
* \section Methods inherited from abstract base class RAS_ICanvas.
|
||||||
*/
|
*/
|
||||||
|
@ -121,6 +121,18 @@ bool GPG_Canvas::GetSwapInterval(int& intervalOut)
|
|||||||
return false;
|
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)
|
void GPG_Canvas::ResizeWindow(int width, int height)
|
||||||
{
|
{
|
||||||
if (m_window->getState() == GHOST_kWindowStateFullScreen)
|
if (m_window->getState() == GHOST_kWindowStateFullScreen)
|
||||||
|
@ -63,6 +63,8 @@ public:
|
|||||||
virtual float GetMouseNormalizedX(int x);
|
virtual float GetMouseNormalizedX(int x);
|
||||||
virtual float GetMouseNormalizedY(int y);
|
virtual float GetMouseNormalizedY(int y);
|
||||||
|
|
||||||
|
virtual void GetDisplayDimensions(int &width, int &height);
|
||||||
|
|
||||||
virtual void ResizeWindow(int width, int height);
|
virtual void ResizeWindow(int width, int height);
|
||||||
virtual void SetFullScreen(bool enable);
|
virtual void SetFullScreen(bool enable);
|
||||||
virtual bool GetFullScreen();
|
virtual bool GetFullScreen();
|
||||||
|
@ -1403,6 +1403,20 @@ static PyObject *gPyClearDebugList(PyObject *)
|
|||||||
Py_RETURN_NONE;
|
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,
|
PyDoc_STRVAR(Rasterizer_module_documentation,
|
||||||
"This is the Python API for the game engine of Rasterizer"
|
"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, ""},
|
{"setWindowSize", (PyCFunction) gPySetWindowSize, METH_VARARGS, ""},
|
||||||
{"setFullScreen", (PyCFunction) gPySetFullScreen, METH_O, ""},
|
{"setFullScreen", (PyCFunction) gPySetFullScreen, METH_O, ""},
|
||||||
{"getFullScreen", (PyCFunction) gPyGetFullScreen, METH_NOARGS, ""},
|
{"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, ""},
|
{"setMipmapping", (PyCFunction) gPySetMipmapping, METH_VARARGS, ""},
|
||||||
{"getMipmapping", (PyCFunction) gPyGetMipmapping, METH_NOARGS, ""},
|
{"getMipmapping", (PyCFunction) gPyGetMipmapping, METH_NOARGS, ""},
|
||||||
{"setVsync", (PyCFunction) gPySetVsync, METH_VARARGS, ""},
|
{"setVsync", (PyCFunction) gPySetVsync, METH_VARARGS, ""},
|
||||||
|
@ -237,6 +237,8 @@ public:
|
|||||||
const char* filename
|
const char* filename
|
||||||
)=0;
|
)=0;
|
||||||
|
|
||||||
|
virtual void GetDisplayDimensions(int &width, int &height) = 0;
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
void
|
void
|
||||||
ResizeWindow(
|
ResizeWindow(
|
||||||
|
Loading…
Reference in New Issue
Block a user