diff options
-rw-r--r-- | doc/python_api/rst/bge.render.rst | 17 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 20 |
2 files changed, 37 insertions, 0 deletions
diff --git a/doc/python_api/rst/bge.render.rst b/doc/python_api/rst/bge.render.rst index 9dd4057c82f..03db3bf3b76 100644 --- a/doc/python_api/rst/bge.render.rst +++ b/doc/python_api/rst/bge.render.rst @@ -75,6 +75,14 @@ Constants Enables adaptive vsync if supported. Adaptive vsync enables vsync if the framerate is above the monitors refresh rate. Otherwise, vsync is diabled if the framerate is too low. +.. data:: LEFT_EYE + + Left eye being used during stereoscopic rendering. + +.. data:: RIGHT_EYE + + Right eye being used during stereoscopic rendering. + ********* Functions ********* @@ -217,6 +225,15 @@ Functions :rtype: float +.. function:: getStereoEye() + + Gets the current stereoscopy eye being rendered. + This function is mainly used in a :class:`bge.types.KX_Scene.pre_draw` callback + function to customize the camera projection matrices for each + stereoscopic eye. + + :rtype: LEFT_EYE, RIGHT_EYE + .. function:: setMaterialMode(mode) Set the material mode to use for OpenGL rendering. diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 3ddd53b971f..348b84e8cf3 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1006,6 +1006,21 @@ static PyObject *gPyGetFocalLength(PyObject *, PyObject *, PyObject *) Py_RETURN_NONE; } +static PyObject *gPyGetStereoEye(PyObject *, PyObject *, PyObject *) +{ + int flag = RAS_IRasterizer::RAS_STEREO_LEFTEYE; + + if (!gp_Rasterizer) { + PyErr_SetString(PyExc_RuntimeError, "Rasterizer.getStereoEye(), Rasterizer not available"); + return NULL; + } + + if (gp_Rasterizer->Stereo()) + flag = gp_Rasterizer->GetEye(); + + return PyLong_FromLong(flag); +} + static PyObject *gPySetBackgroundColor(PyObject *, PyObject *value) { @@ -1496,6 +1511,7 @@ static struct PyMethodDef rasterizer_methods[] = { {"getEyeSeparation", (PyCFunction) gPyGetEyeSeparation, METH_NOARGS, "get the eye separation for stereo mode"}, {"setFocalLength", (PyCFunction) gPySetFocalLength, METH_VARARGS, "set the focal length for stereo mode"}, {"getFocalLength", (PyCFunction) gPyGetFocalLength, METH_VARARGS, "get the focal length for stereo mode"}, + {"getStereoEye", (PyCFunction) gPyGetStereoEye, METH_VARARGS, "get the current stereoscopy eye being rendered"}, {"setMaterialMode",(PyCFunction) gPySetMaterialType, METH_VARARGS, "set the material mode to use for OpenGL rendering"}, {"getMaterialMode",(PyCFunction) gPyGetMaterialType, @@ -2320,6 +2336,10 @@ PyObject *initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) KX_MACRO_addTypesToDict(d, VSYNC_ON, VSYNC_ON); KX_MACRO_addTypesToDict(d, VSYNC_ADAPTIVE, VSYNC_ADAPTIVE); + /* stereoscopy */ + KX_MACRO_addTypesToDict(d, LEFT_EYE, RAS_IRasterizer::RAS_STEREO_LEFTEYE); + KX_MACRO_addTypesToDict(d, RIGHT_EYE, RAS_IRasterizer::RAS_STEREO_RIGHTEYE); + // XXXX Add constants here // Check for errors |