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

Description

VuoSceneRenderer implementation.

Classes

struct  VuoSceneRendererInternal_vertices
 GL Objects corresponding with a VuoVertices 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

void VuoSceneRenderer_destroy (VuoSceneRenderer sr)
 Destroys and deallocates the scene renderer.
 
VuoSceneRenderer VuoSceneRenderer_make (void)
 Creates a reference-counted object for rendering a scenegraph.
 
void VuoSceneRenderer_prepareContext (VuoSceneRenderer sceneRenderer, VuoGlContext glContext)
 Sets up OpenGL state on the current GL Context.
 
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.
 
void VuoSceneRenderer_drawSceneObject (VuoSceneObject so, VuoSceneRendererInternal_object *soi, float projectionMatrix[16], float modelviewMatrix[16], VuoGlContext glContext)
 Draws so (using the uploaded object names in soi).
 
void VuoSceneRenderer_drawSceneObjectsRecursively (VuoSceneObject so, VuoSceneRendererInternal_object *soi, float projectionMatrix[16], float modelviewMatrix[16], VuoGlContext glContext)
 Draws so and its child objects.
 
void VuoSceneRenderer_draw (VuoSceneRenderer sr, VuoGlContext glContext)
 Renders the scene.
 
void VuoSceneRenderer_drawElement (VuoSceneRenderer sr, VuoGlContext glContext, int element, float length)
 Draws all vertex normals in sceneRenderer-rootSceneObject.
 
void VuoSceneRenderer_uploadSceneObject (VuoSceneObject so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext)
 Uploads so to the GPU, and stores the uploaded object names in soi.
 
void VuoSceneRenderer_uploadSceneObjectsRecursively (VuoSceneObject so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext)
 Uploads so and its child objects to the GPU, and stores the uploaded object names in soi.
 
void VuoSceneRenderer_releaseSceneObject (VuoSceneObject so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext)
 Releases the GPU objects created by VuoSceneRenderer_uploadSceneObject.
 
void VuoSceneRenderer_releaseSceneObjectsRecursively (VuoSceneObject so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext)
 Releases the GPU objects created by VuoSceneRenderer_uploadSceneObjectsRecursively.
 
void VuoSceneRenderer_retainSceneObjectsRecursively (VuoSceneObject so)
 Deeply retains so.
 
void VuoSceneRenderer_setRootSceneObject (VuoSceneRenderer sr, VuoGlContext glContext, VuoSceneObject rootSceneObject)
 Changes the scenegraph to be rendered.
 
void VuoSceneRenderer_setCameraName (VuoSceneRenderer sr, VuoText cameraName)
 Changes the name of the camera to look for.
 

Class Documentation

struct VuoSceneRendererInternal_vertices
Class Members
GLuint bitangentBuffer
GLuint elementBuffer
GLuint normalBuffer
GLuint positionBuffer
GLuint tangentBuffer
GLuint textureCoordinateBuffer
class VuoSceneRendererInternal_object
Class Members
list
< VuoSceneRendererInternal_object >
childObjects
list
< VuoSceneRendererInternal_vertices >
vertices
class VuoSceneRendererInternal
Class Members
VuoText cameraName
bool needToRegenerateProjectionMatrix
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
unsigned int viewportHeight
unsigned int viewportWidth

Function Documentation

void VuoSceneRenderer_destroy ( VuoSceneRenderer  sr)

Destroys and deallocates the scene renderer.

This function may be called from any thread.

void VuoSceneRenderer_draw ( VuoSceneRenderer  sr,
VuoGlContext  glContext 
)

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.)

void VuoSceneRenderer_drawElement ( VuoSceneRenderer  sr,
VuoGlContext  glContext,
int  element,
float  length 
)

Draws all vertex normals in sceneRenderer-rootSceneObject.

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.)

Todo:
update VuoSceneRenderer_draw() to call this for each VuoSceneObject when debugging
void VuoSceneRenderer_drawSceneObject ( VuoSceneObject  so,
VuoSceneRendererInternal_object soi,
float  projectionMatrix[16],
float  modelviewMatrix[16],
VuoGlContext  glContext 
)

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.)

void VuoSceneRenderer_drawSceneObjectsRecursively ( VuoSceneObject  so,
VuoSceneRendererInternal_object soi,
float  projectionMatrix[16],
float  modelviewMatrix[16],
VuoGlContext  glContext 
)

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 ( void  )

Creates a reference-counted object for rendering a scenegraph.

This function may be called from any thread.

void VuoSceneRenderer_prepareContext ( VuoSceneRenderer  sceneRenderer,
VuoGlContext  glContext 
)

Sets up OpenGL state on the current GL 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)

Helper for VuoSceneRenderer_regenerateProjectionMatrix and VuoSceneRenderer_draw.

Must be called while scenegraphSemaphore is locked.

void VuoSceneRenderer_releaseSceneObject ( VuoSceneObject  so,
VuoSceneRendererInternal_object soi,
VuoGlContext  glContext 
)

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.)

Todo:
https://b33p.net/kosada/node/6752 — Why does this leak if we recycle it?
void VuoSceneRenderer_releaseSceneObjectsRecursively ( VuoSceneObject  so,
VuoSceneRendererInternal_object soi,
VuoGlContext  glContext 
)

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_retainSceneObjectsRecursively ( VuoSceneObject  so)

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 
)

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.

This function may be called from any thread.

void VuoSceneRenderer_setRootSceneObject ( VuoSceneRenderer  sr,
VuoGlContext  glContext,
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.)

void VuoSceneRenderer_uploadSceneObject ( VuoSceneObject  so,
VuoSceneRendererInternal_object soi,
VuoGlContext  glContext 
)

Uploads so to the GPU, and stores 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.)

void VuoSceneRenderer_uploadSceneObjectsRecursively ( VuoSceneObject  so,
VuoSceneRendererInternal_object soi,
VuoGlContext  glContext 
)

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.)