Vuo  1.1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
VuoSceneRenderer.cc File Reference

Description

VuoSceneRenderer implementation.

Classes

struct  VuoSceneRendererInternal_meshItem
 GL Objects corresponding with a VuoSubmesh instance. More...
 
class  VuoSceneRendererInternal_object
 GL Objects corresponding with a VuoSceneObject instance. More...
 
class  VuoSceneRendererInternal
 Internal state data for a VuoSceneRenderer instance. More...
 

Macros

#define glGenVertexArrays   glGenVertexArraysAPPLE
 
#define glBindVertexArray   glBindVertexArrayAPPLE
 
#define glDeleteVertexArrays   glDeleteVertexArraysAPPLE
 

Functions

static void __attribute__ ((constructor)) VuoSceneRenderer_init()
 Initialize VuoSceneRenderer_vertexArraySemaphore.
 
void VuoSceneRenderer_destroy (VuoSceneRenderer sr)
 Destroys and deallocates the scene renderer.
 
static void VuoSceneRenderer_prepareContext (CGLContextObj cgl_ctx)
 Configures OpenGL state for the specified context.
 
VuoSceneRenderer VuoSceneRenderer_make (VuoGlContext glContext, float backingScaleFactor)
 Creates a reference-counted object for rendering a scenegraph.
 
static void VuoSceneRenderer_regenerateProjectionMatrixInternal (VuoSceneRendererInternal *sceneRenderer)
 Helper for VuoSceneRenderer_regenerateProjectionMatrix and VuoSceneRenderer_draw.
 
void VuoSceneRenderer_regenerateProjectionMatrix (VuoSceneRenderer sr, unsigned int width, unsigned int height)
 Using the first camera found in the scene (or VuoSceneObject_makeDefaultCamera() if there is no camera in the scene), recalculates the projection matrix based on the specified viewport width and height.
 
static void VuoSceneRenderer_drawSceneObject (VuoSceneObject so, VuoSceneRendererInternal_object *soi, float projectionMatrix[16], float modelviewMatrix[16], VuoSceneRendererInternal *sceneRenderer)
 Draws so (using the uploaded object names in soi).
 
static void VuoSceneRenderer_drawSceneObjectsRecursively (VuoSceneObject so, VuoSceneRendererInternal_object *soi, float projectionMatrix[16], float modelviewMatrix[16], VuoSceneRendererInternal *sceneRenderer)
 Draws so and its child objects.
 
void VuoSceneRenderer_draw (VuoSceneRenderer sr)
 Renders the scene.
 
void VuoSubmeshMesh_download (VuoSubmesh *submesh)
 Copies element data from GPU back to the CPU.
 
static void VuoSceneRenderer_renderText (VuoSceneRendererInternal *sceneRenderer, VuoSceneObject &so)
 Draws all vertex normals in so.
 
static void VuoSceneRenderer_uploadSceneObject (VuoSceneRendererInternal *sceneRenderer, VuoSceneObject &so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext)
 Binds the relevant (given the current shader) parts of so to an OpenGL Vertex Array Object.
 
static void VuoSceneRenderer_uploadSceneObjectsRecursively (VuoSceneRendererInternal *sceneRenderer, VuoSceneObject &so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext)
 Uploads so and its child objects to the GPU, and stores the uploaded object names in soi.
 
static void VuoSceneRenderer_cleanupSceneObject (VuoSceneObject so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext)
 Releases the GPU objects created by VuoSceneRenderer_uploadSceneObject.
 
static void VuoSceneRenderer_cleanupSceneObjectsRecursively (VuoSceneObject so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext)
 Releases the GPU objects created by VuoSceneRenderer_uploadSceneObjectsRecursively.
 
static void VuoSceneRenderer_releaseSceneObjectsRecursively (VuoSceneObject so)
 Releases the Vuo objects related to this scenegraph.
 
static void VuoSceneRenderer_retainSceneObjectsRecursively (VuoSceneObject so)
 Deeply retains so.
 
void VuoSceneRenderer_setRootSceneObject (VuoSceneRenderer sr, VuoSceneObject rootSceneObject)
 Changes the scenegraph to be rendered.
 
void VuoSceneRenderer_setCameraName (VuoSceneRenderer sr, VuoText cameraName, VuoBoolean useLeftCamera)
 Changes the name of the camera to look for.
 
void VuoSceneRenderer_renderToImage (VuoSceneRenderer sr, VuoImage *image, VuoImageColorDepth imageColorDepth, VuoImage *depthImage)
 Creates an OpenGL Framebuffer Object, and uses it to render the scene to image and depthImage.
 

Variables

static dispatch_semaphore_t VuoSceneRenderer_vertexArraySemaphore
 Work around apparent GL driver bug, wherein attempting to simultaneously bind the same buffer to multiple VAOs on separate contexts causes a crash.
 

Class Documentation

struct VuoSceneRendererInternal_meshItem
Class Members
GLuint vertexArray
class VuoSceneRendererInternal_object
Class Members
list
< VuoSceneRendererInternal_object >
childObjects
list
< VuoSceneRendererInternal_meshItem >
meshItems
class VuoSceneRendererInternal
Class Members
float ambientBrightness
VuoColor ambientColor
float backingScaleFactor
VuoSceneObject camera
VuoText cameraName
VuoGlContext glContext
bool needToRegenerateProjectionMatrix
VuoList_VuoSceneObject pointLights
float projectionMatrix[16] Column-major 4x4 matrix.
VuoSceneObject rootSceneObject
VuoSceneRendererInternal_object rootSceneObjectInternal
dispatch_semaphore_t scenegraphSemaphore Serializes access to other data in this structure.
bool scenegraphValid
VuoList_VuoSceneObject spotLights
VuoBoolean useLeftCamera
unsigned int viewportHeight
unsigned int viewportWidth

Function Documentation

static void __attribute__ ( (constructor)  )
static

Initialize VuoSceneRenderer_vertexArraySemaphore.

static void VuoSceneRenderer_cleanupSceneObject ( VuoSceneObject  so,
VuoSceneRendererInternal_object soi,
VuoGlContext  glContext 
)
static

Releases the GPU objects created by VuoSceneRenderer_uploadSceneObject.

Does not traverse child objects.

Must be called while scenegraphSemaphore is locked.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

static void VuoSceneRenderer_cleanupSceneObjectsRecursively ( VuoSceneObject  so,
VuoSceneRendererInternal_object soi,
VuoGlContext  glContext 
)
static

Releases the GPU objects created by VuoSceneRenderer_uploadSceneObjectsRecursively.

Must be called while scenegraphSemaphore is locked.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

void VuoSceneRenderer_destroy ( VuoSceneRenderer  sr)

Destroys and deallocates the scene renderer.

This function may be called from any thread.

void VuoSceneRenderer_draw ( VuoSceneRenderer  sr)

Renders the scene.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

static void VuoSceneRenderer_drawSceneObject ( VuoSceneObject  so,
VuoSceneRendererInternal_object soi,
float  projectionMatrix[16],
float  modelviewMatrix[16],
VuoSceneRendererInternal sceneRenderer 
)
static

Draws so (using the uploaded object names in soi).

Does not traverse child objects.

Must be called while scenegraphSemaphore is locked.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

static void VuoSceneRenderer_drawSceneObjectsRecursively ( VuoSceneObject  so,
VuoSceneRendererInternal_object soi,
float  projectionMatrix[16],
float  modelviewMatrix[16],
VuoSceneRendererInternal sceneRenderer 
)
static

Draws so and its child objects.

Must be called while scenegraphSemaphore is locked.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

VuoSceneRenderer VuoSceneRenderer_make ( VuoGlContext  glContext,
float  backingScaleFactor 
)

Creates a reference-counted object for rendering a scenegraph.

This function may be called from any thread.

static void VuoSceneRenderer_prepareContext ( CGLContextObj  cgl_ctx)
static

Configures OpenGL state for the specified context.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

void VuoSceneRenderer_regenerateProjectionMatrix ( VuoSceneRenderer  sr,
unsigned int  width,
unsigned int  height 
)

Using the first camera found in the scene (or VuoSceneObject_makeDefaultCamera() if there is no camera in the scene), recalculates the projection matrix based on the specified viewport width and height.

This function may be called from any thread.

void VuoSceneRenderer_regenerateProjectionMatrixInternal ( VuoSceneRendererInternal sceneRenderer)
static

Helper for VuoSceneRenderer_regenerateProjectionMatrix and VuoSceneRenderer_draw.

Must be called while scenegraphSemaphore is locked.

static void VuoSceneRenderer_releaseSceneObjectsRecursively ( VuoSceneObject  so)
static

Releases the Vuo objects related to this scenegraph.

Must be called while scenegraphSemaphore is locked.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

static void VuoSceneRenderer_renderText ( VuoSceneRendererInternal sceneRenderer,
VuoSceneObject so 
)
static

Draws all vertex normals in so.

Must be called while scenegraphSemaphore is locked.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.) Draws a circle using OpenGL immediate mode. For debugging only. Draws a cone using OpenGL immediate mode. For debugging only. Draws the scene's point and spot lights. Creates a mesh and image for the specified sceneobject, if they don't already exist.

void VuoSceneRenderer_renderToImage ( VuoSceneRenderer  sr,
VuoImage image,
VuoImageColorDepth  imageColorDepth,
VuoImage depthImage 
)

Creates an OpenGL Framebuffer Object, and uses it to render the scene to image and depthImage.

static void VuoSceneRenderer_retainSceneObjectsRecursively ( VuoSceneObject  so)
static

Deeply retains so.

Must be called while scenegraphSemaphore is locked.

This function may be called from any thread.

void VuoSceneRenderer_setCameraName ( VuoSceneRenderer  sr,
VuoText  cameraName,
VuoBoolean  useLeftCamera 
)

Changes the name of the camera to look for.

The first camera whose name contains cameraName will be rendered (next time VuoSceneRenderer_draw() is called), or, if no camera matches, VuoSceneObject_makeDefaultCamera() will be used.

If cameraName is stereoscopic, useLeftCamera selects between the left and right cameras in the stereo pair.

This function may be called from any thread.

void VuoSceneRenderer_setRootSceneObject ( VuoSceneRenderer  sr,
VuoSceneObject  rootSceneObject 
)

Changes the scenegraph to be rendered.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

static void VuoSceneRenderer_uploadSceneObject ( VuoSceneRendererInternal sceneRenderer,
VuoSceneObject so,
VuoSceneRendererInternal_object soi,
VuoGlContext  glContext 
)
static

Binds the relevant (given the current shader) parts of so to an OpenGL Vertex Array Object.

Does not traverse child objects.

Must be called while scenegraphSemaphore is locked.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

static void VuoSceneRenderer_uploadSceneObjectsRecursively ( VuoSceneRendererInternal sceneRenderer,
VuoSceneObject so,
VuoSceneRendererInternal_object soi,
VuoGlContext  glContext 
)
static

Uploads so and its child objects to the GPU, and stores the uploaded object names in soi.

Must be called while scenegraphSemaphore is locked.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

void VuoSubmeshMesh_download ( VuoSubmesh submesh)

Copies element data from GPU back to the CPU.

Variable Documentation

dispatch_semaphore_t VuoSceneRenderer_vertexArraySemaphore
static

Work around apparent GL driver bug, wherein attempting to simultaneously bind the same buffer to multiple VAOs on separate contexts causes a crash.

(Try running CompareCameras.vuo without this.)