Vuo
0.9.1
|
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) |
Creates a reference-counted object for rendering a scenegraph. | |
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], VuoSceneRendererInternal *sceneRenderer) |
Draws so (using the uploaded object names in soi ). | |
void | VuoSceneRenderer_drawElement (VuoSceneObject so, float projectionMatrix[16], float compositeModelviewMatrix[16], VuoGlContext glContext, int element, float length) |
Draws all vertex normals in so . | |
void | VuoSceneRenderer_drawSceneObjectsRecursively (VuoSceneObject so, VuoSceneRendererInternal_object *soi, float projectionMatrix[16], float modelviewMatrix[16], VuoSceneRendererInternal *sceneRenderer) |
Draws so and its child objects. | |
void | VuoSceneRenderer_drawLights (VuoSceneRendererInternal *sceneRenderer) |
Draws the scene's point and spot lights. | |
void | VuoSceneRenderer_draw (VuoSceneRenderer sr) |
Renders the scene. | |
static void | drawCircle (CGLContextObj cgl_ctx, VuoPoint3d center, float radius, VuoPoint3d normal) |
Draws a circle using OpenGL immediate mode. | |
static void | drawCone (CGLContextObj cgl_ctx, VuoPoint3d center, float radius, VuoPoint3d normal, float height) |
Draws a cone using OpenGL immediate mode. | |
void | VuoSceneRenderer_uploadSceneObject (VuoSceneObject so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext) |
Binds the relevant (given the current shader) parts of so to an OpenGL Vertex Array Object. | |
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_cleanupSceneObject (VuoSceneObject so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext) |
Releases the GPU objects created by VuoSceneRenderer_uploadSceneObject . | |
void | VuoSceneRenderer_cleanupSceneObjectsRecursively (VuoSceneObject so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext) |
Releases the GPU objects created by VuoSceneRenderer_uploadSceneObjectsRecursively . | |
void | VuoSceneRenderer_releaseSceneObjectsRecursively (VuoSceneObject so) |
Releases the Vuo objects related to this scenegraph. | |
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 VuoSceneRendererInternal_object |
Class Members | ||
---|---|---|
list < VuoSceneRendererInternal_object > |
childObjects | |
list < VuoSceneRendererInternal_meshItem > |
meshItems |
class VuoSceneRendererInternal |
Class Members | ||
---|---|---|
float | ambientBrightness | |
VuoColor | ambientColor | |
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 |
|
static |
Initialize VuoSceneRenderer_vertexArraySemaphore
.
|
static |
Draws a circle using OpenGL immediate mode.
For debugging only.
|
static |
Draws a cone using OpenGL immediate mode.
For debugging only.
void VuoSceneRenderer_cleanupSceneObject | ( | 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.)
void VuoSceneRenderer_cleanupSceneObjectsRecursively | ( | 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_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.)
void VuoSceneRenderer_drawElement | ( | VuoSceneObject | so, |
float | projectionMatrix[16], | ||
float | compositeModelviewMatrix[16], | ||
VuoGlContext | glContext, | ||
int | element, | ||
float | length | ||
) |
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.)
void VuoSceneRenderer_drawLights | ( | VuoSceneRendererInternal * | sceneRenderer | ) |
Draws the scene's point and spot lights.
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
).
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], | ||
VuoSceneRendererInternal * | sceneRenderer | ||
) |
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 | ) |
Creates a reference-counted object for rendering a scenegraph.
This function may be called from any thread.
|
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 | ) |
Helper for VuoSceneRenderer_regenerateProjectionMatrix and VuoSceneRenderer_draw.
Must be called while scenegraphSemaphore is locked.
void VuoSceneRenderer_releaseSceneObjectsRecursively | ( | VuoSceneObject | so | ) |
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.)
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
.
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, | ||
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.)
void VuoSceneRenderer_uploadSceneObject | ( | VuoSceneObject | so, |
VuoSceneRendererInternal_object * | soi, | ||
VuoGlContext | glContext | ||
) |
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.)
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.)
|
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 Compare4Cameras.vuo without this.)