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
path: root/doc
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2015-01-22 07:42:40 +0300
committerDalai Felinto <dfelinto@gmail.com>2015-01-22 08:00:24 +0300
commit8ed439b89ed4f4c968c90f8074bb0925f79cee80 (patch)
tree5d6ebb2827bde6dc233415519ff17ba04b78093f /doc
parent1b1a6e0c9298166fee40ebb9b254f973879017bd (diff)
bge.render.getStereoEye() and bge.types.LEFT_EYE/RIGHT_EYE
This function allows the user to run specific code for each of the rendered stereoscopic eyes in the Game Engine. The initial use case is to set the camera projection matrix in a scene.pre_draw callback function for each eye, to be used in VR (Virtual Reality) installations. Reviewed by Mitchell Stokes and Campbell Barton, thank you guys. Sample Test Python Script: """ import bge import bgl import blf def init(): """init function - runs once""" scene = bge.logic.getCurrentScene() scene.post_draw.append(write) def write(): """write on screen - depending on the eye""" width = bge.render.getWindowWidth() height = bge.render.getWindowHeight() # OpenGL setup bgl.glMatrixMode(bgl.GL_PROJECTION) bgl.glLoadIdentity() bgl.gluOrtho2D(0, width, 0, height) bgl.glMatrixMode(bgl.GL_MODELVIEW) bgl.glLoadIdentity() eye = bge.render.getStereoEye() if eye == bge.render.LEFT_EYE: blf.position(0, (width * 0.2), (height * 0.3), 0) blf.size(0, 40, 72) blf.draw(0, "Left") else: # bge.render.RIGHT_EYE: blf.position(0, (width * 0.7), (height * 0.3), 0) blf.size(0, 40, 72) blf.draw(0, "Right") """
Diffstat (limited to 'doc')
-rw-r--r--doc/python_api/rst/bge.render.rst17
1 files changed, 17 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.