Vuo
1.2.6
|
VuoSceneRenderer implementation.
Classes | |
class | VuoSceneRendererInternal_object |
GL Objects corresponding with a VuoSceneObject instance. More... | |
class | VuoSceneRendererInternal |
Internal state data for a VuoSceneRenderer instance. More... | |
struct | VuoSceneRendererInternal::glState |
Store OpenGL state locally so we can change only when necessary, since calling glEnable/Disable marks the state dirty even if the state was unchanged. More... | |
struct | VuoSceneRenderer_treeRenderState |
State for rendering an object at its particular place in the hierarchy. More... | |
Macros | |
#define | VuoSceneRenderer_setGL(cap, value) |
Ensures the specified OpenGL cap ability is set to value (avoiding a state change if possible). | |
#define | VuoSceneRenderer_setGLDepthMask(value) |
Ensures the OpenGL depth mask is set to value (avoiding a state change if possible). | |
#define | VuoSceneRenderer_setGLFaceCulling(value) |
Ensures the OpenGL face culling mode is set to value (avoiding a state change if possible). | |
#define | VuoSceneRenderer_setGLBlendFunction(srcRGB, dstRGB, srcAlpha, dstAlpha) |
Ensures the OpenGL blend function is set to the specified values (avoiding a state change if possible). | |
#define | VuoSceneRenderer_setGLBlendEquation(modeRGB, modeAlpha) |
Ensures the OpenGL blend equation is set to the specified values (avoiding a state change if possible). | |
#define | glGenVertexArrays glGenVertexArraysAPPLE |
#define | glBindVertexArray glBindVertexArrayAPPLE |
#define | glDeleteVertexArrays glDeleteVertexArraysAPPLE |
Typedefs | |
typedef std::pair< void *, void * > | VuoSceneRendererMeshShader |
A VuoMesh/VuoShader combination. | |
typedef std::map < VuoSceneRendererMeshShader, GLuint > | VuoSceneRendererMeshShaderVAOs |
The VAO for each VuoMesh/VuoShader combination. | |
Functions | |
void | VuoSceneRenderer_destroy (VuoSceneRenderer sr) |
Destroys and deallocates the scene renderer. | |
static void | VuoSceneRenderer_uploadSceneObject (VuoSceneRendererInternal *sceneRenderer, VuoSceneObject so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext, bool cache) |
Binds the relevant (given the current shader) parts of so to an OpenGL Vertex Array Object. | |
VuoSceneRenderer | VuoSceneRenderer_make (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_addUniformSuffix (char *address, int i, const char *suffix) |
Overwrites address with a null-terminated string consisting of i (converted to string, assumed to be between 0 and 19 inclusive) followed by suffix . | |
void | VuoSceneRenderer_checkDataBounds (CGLContextObj cgl_ctx, VuoSubmesh submesh, GLuint positionAttribute) |
Checks to ensure the currently-active VBO is correctly configured. | |
static void | VuoSceneRenderer_drawSceneObject (VuoSceneObject so, VuoSceneRendererInternal_object *soi, float projectionMatrix[16], float modelviewMatrix[16], VuoSceneRendererInternal *sceneRenderer, VuoGlContext glContext) |
Draws so (using the uploaded object names in soi ). | |
static void | VuoSceneRenderer_drawSceneObjectsRecursively (VuoSceneRendererInternal *sceneRenderer, VuoGlContext glContext) |
Draws so and its child objects. | |
static void | VuoSceneRenderer_cleanupSceneObjectsRecursively (VuoSceneObject so, VuoSceneRendererInternal_object *soi, VuoGlContext glContext) |
Cleans up internal state created by VuoSceneRenderer_uploadSceneObjectsRecursively . | |
static void | VuoSceneRenderer_cleanupMeshShaderItems (VuoSceneRendererInternal *sceneRenderer, VuoGlContext glContext) |
Releases the GPU objects created by VuoSceneRenderer_uploadSceneObjectsRecursively . | |
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 . | |
void | VuoSceneRenderer_draw (VuoSceneRenderer sr) |
Uploads the scene to the GPU (if it's changed), and renders it. | |
static void | VuoSceneRenderer_renderText (VuoSceneRendererInternal *sceneRenderer, VuoSceneObject so, VuoSceneRendererInternal_object *soi) |
Draws all vertex normals in so . | |
void | VuoSceneRenderer_setRootSceneObject (VuoSceneRenderer sr, VuoSceneObject rootSceneObject) |
Changes the scenegraph to be rendered. | |
VuoSceneObject | VuoSceneRenderer_getRootSceneObject (VuoSceneRenderer sr, bool *isValid) |
Returns the scenegraph to be rendered. | |
void | VuoSceneRenderer_setCameraName (VuoSceneRenderer sr, VuoText cameraName, VuoBoolean useLeftCamera) |
Changes the name of the camera to look for. | |
bool | VuoSceneRenderer_renderInternal (VuoSceneRenderer sr, VuoGlContext glContext, GLuint *outputTexture, GLenum target, GLuint imageGlInternalFormat, VuoMultisample multisample, GLuint *outputDepthTexture) |
Helper for VuoSceneRenderer_render* . | |
void | VuoSceneRenderer_renderToImage (VuoSceneRenderer sr, VuoImage *image, VuoImageColorDepth imageColorDepth, VuoMultisample multisample, VuoImage *depthImage) |
Renders the scene onto image and optionally depthImage . | |
VuoIoSurface | VuoSceneRenderer_renderToIOSurface (VuoSceneRenderer sr, VuoImageColorDepth imageColorDepth, VuoMultisample multisample, bool includeDepthBuffer) |
Renders the scene onto an IOSurface. | |
class VuoSceneRendererInternal |
Class Members | ||
---|---|---|
float | ambientBrightness | |
VuoColor | ambientColor | |
float | backingScaleFactor | |
VuoSceneObject | camera | |
float | cameraMatrixInverse[16] | Column-major 4x4 matrix. |
VuoText | cameraName | |
GLint | glContextRendererID | |
struct glState | glState | |
VuoSceneRendererMeshShaderVAOs | meshShaderItems | Given a VuoMesh and a VuoShader, stores a set of VAOs. |
bool | needToRegenerateProjectionMatrix | |
VuoList_VuoSceneObject | pointLights | |
float | projectionMatrix[16] | Column-major 4x4 matrix. |
VuoSceneObject | rootSceneObject | The latest scene that's actually been uploaded and drawn. |
VuoSceneRendererInternal_object | rootSceneObjectInternal | |
VuoSceneObject | rootSceneObjectPending | The latest scene from VuoSceneRenderer_setRootSceneObject(). |
bool | rootSceneObjectPendingUpdated | Whether rootSceneObjectPending contains a new scene (compared to rootSceneObject). |
bool | rootSceneObjectPendingValid | Whether rootSceneObjectPending has already been initialized. |
bool | rootSceneObjectValid | Whether rootSceneObject has already been initialized (and uploaded and drawn). |
dispatch_semaphore_t | scenegraphSemaphore | Serializes access to other data in this structure. |
VuoList_VuoSceneObject | spotLights | |
VuoBoolean | useLeftCamera | |
unsigned int | viewportHeight | |
unsigned int | viewportWidth | |
VuoSceneObject | vignetteQuad | |
VuoSceneRendererInternal_object | vignetteQuadInternal | |
VuoShader | vignetteShader |
struct VuoSceneRendererInternal::glState |
struct VuoSceneRenderer_treeRenderState |
Class Members | ||
---|---|---|
float | modelviewMatrix[16] | |
VuoSceneObject * | so | |
VuoSceneRendererInternal_object * | soi |
#define VuoSceneRenderer_setGL | ( | cap, | |
value | |||
) |
Ensures the specified OpenGL cap
ability is set to value
(avoiding a state change if possible).
#define VuoSceneRenderer_setGLBlendEquation | ( | modeRGB, | |
modeAlpha | |||
) |
Ensures the OpenGL blend equation is set to the specified values (avoiding a state change if possible).
#define VuoSceneRenderer_setGLBlendFunction | ( | srcRGB, | |
dstRGB, | |||
srcAlpha, | |||
dstAlpha | |||
) |
Ensures the OpenGL blend function is set to the specified values (avoiding a state change if possible).
#define VuoSceneRenderer_setGLDepthMask | ( | value | ) |
Ensures the OpenGL depth mask is set to value
(avoiding a state change if possible).
#define VuoSceneRenderer_setGLFaceCulling | ( | value | ) |
Ensures the OpenGL face culling mode is set to value
(avoiding a state change if possible).
typedef std::pair<void *, void *> VuoSceneRendererMeshShader |
A VuoMesh/VuoShader combination.
typedef std::map<VuoSceneRendererMeshShader, GLuint> VuoSceneRendererMeshShaderVAOs |
The VAO for each VuoMesh/VuoShader combination.
|
static |
Overwrites address
with a null-terminated string consisting of i
(converted to string, assumed to be between 0 and 19 inclusive) followed by suffix
.
void VuoSceneRenderer_checkDataBounds | ( | CGLContextObj | cgl_ctx, |
VuoSubmesh | submesh, | ||
GLuint | positionAttribute | ||
) |
Checks to ensure the currently-active VBO is correctly configured.
This is time-consuming (since it downloads data from the GPU), so it should be used sparingly (e.g., in debug mode).
|
static |
Releases the GPU objects created by VuoSceneRenderer_uploadSceneObjectsRecursively
.
|
static |
Cleans up internal state 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 | ) |
Uploads the scene to the GPU (if it's changed), and renders it.
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 |
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 |
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.)
VuoSceneObject VuoSceneRenderer_getRootSceneObject | ( | VuoSceneRenderer | sr, |
bool * | isValid | ||
) |
Returns the scenegraph to be rendered.
This function only returns valid data after VuoSceneRenderer_draw has been called.
This function may be called from any thread.
VuoSceneRenderer VuoSceneRenderer_make | ( | float | backingScaleFactor | ) |
Creates a reference-counted object for rendering a scenegraph.
This function may be called from any thread.
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.
|
static |
Helper for VuoSceneRenderer_regenerateProjectionMatrix and VuoSceneRenderer_draw.
Must be called while scenegraphSemaphore is locked.
bool VuoSceneRenderer_renderInternal | ( | VuoSceneRenderer | sr, |
VuoGlContext | glContext, | ||
GLuint * | outputTexture, | ||
GLenum | target, | ||
GLuint | imageGlInternalFormat, | ||
VuoMultisample | multisample, | ||
GLuint * | outputDepthTexture | ||
) |
Helper for VuoSceneRenderer_render*
.
|
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.
void VuoSceneRenderer_renderToImage | ( | VuoSceneRenderer | sr, |
VuoImage * | image, | ||
VuoImageColorDepth | imageColorDepth, | ||
VuoMultisample | multisample, | ||
VuoImage * | depthImage | ||
) |
Renders the scene onto image
and optionally depthImage
.
VuoIoSurface VuoSceneRenderer_renderToIOSurface | ( | VuoSceneRenderer | sr, |
VuoImageColorDepth | imageColorDepth, | ||
VuoMultisample | multisample, | ||
bool | includeDepthBuffer | ||
) |
Renders the scene onto an IOSurface.
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 retains the scene, but it isn't uploaded to the GPU until you call VuoSceneRenderer_draw.
This function may be called from any thread.
|
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.
If cache
is true, the VAO is cached in sceneRenderer->meshShaderItems (which gets cleaned up by VuoSceneRenderer_cleanupMeshShaderItems each time the root sceneobject is changed).
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 |
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.)