blender/source/gameengine
Dalai Felinto 8ed439b89e 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")
"""
2015-01-22 03:00:24 -02:00
..
BlenderRoutines Fix for bool flag use 2015-01-07 12:08:55 +11:00
Converter Fix T43174: "Record animation" does not update fcurve handles 2015-01-09 15:29:47 +01:00
Expressions Freestyle: reserve array sizes before filling 2015-01-04 21:23:26 +11:00
GameLogic Cleanup: style 2015-01-21 11:57:11 +11:00
GamePlayer Fix for bool flag use 2015-01-07 12:08:55 +11:00
Ketsji bge.render.getStereoEye() and bge.types.LEFT_EYE/RIGHT_EYE 2015-01-22 03:00:24 -02:00
Network mathutils: refactor instantiation 2015-01-04 17:43:57 +11:00
Physics Cleanup of BGE code CcdPhysicsEnvironment::CallbackTriggers() 2015-01-21 18:43:05 +01:00
Rasterizer Ghost Context Refactor 2014-10-07 15:47:32 -05:00
SceneGraph Style Cleanup: remove preprocessor indentation (updated wiki style guide too) 2013-12-22 14:12:19 +11:00
VideoTexture Revert "Fix T40257: Frustum culling not working properly" 2015-01-07 20:38:05 -08:00
CMakeLists.txt BGE: Removing the source files for the PHY interfaces since they just contained virtual destructors. This means we had license and doc blocks for 3 lines of code, which seemed silly. This also means that ge_phys_common no longer needs to be built as a library. I tested this with CMake and SCons using GCC; hopefully this doesn't break other systems. 2013-02-24 07:09:39 +00:00
SConscript BGE: Removing the source files for the PHY interfaces since they just contained virtual destructors. This means we had license and doc blocks for 3 lines of code, which seemed silly. This also means that ge_phys_common no longer needs to be built as a library. I tested this with CMake and SCons using GCC; hopefully this doesn't break other systems. 2013-02-24 07:09:39 +00:00