udRenderTarget

The udRenderTarget object provides an interface to specify a viewport to render to. Once instantiated, the udRenderTarget can have its targets set, providing both a colour and depth output of the render which will utilize the matrices provided to the SetMatrix function.

Enums

enum udRenderTargetMatrix

These are the various matrix types used within the render target

Values:

ValueDescription
udRTM_CameraThe local to world-space transform of the camera (View is implicitly set as the inverse).
udRTM_ViewThe view-space transform for the model (does not need to be set explicitly).
udRTM_ProjectionThe projection matrix (default is 60 degree LH).
udRTM_ViewportViewport scaling matrix (default width and height of viewport).
udRTM_CountTotal number of matrix types. Used internally but can be used as an iterator max when checking matrix information.

Functions

enum udError udRenderTarget_Create(struct udContext *pContext, struct udRenderTarget **ppRenderTarget, struct udRenderContext *pRenderer, uint32_t width, uint32_t height)

Create a udRenderTarget with a viewport using width and height.

!NOTE The application should call udRenderTarget_Destroy with ppRenderTarget to destroy the object once it’s no longer needed.

ParameterDescription
pContextThe context to be used to create the render target.
ppRenderTargetThe pointer pointer of the udRenderTarget. This will allocate an instance of udRenderTarget into ppRenderTarget.
pRendererThe renderer associated with the render target.
widthThe width of the viewport.
heightThe height of the viewport.

Returns: A udError value based on the result of the render target creation.

enum udError udRenderTarget_Destroy(struct udRenderTarget **ppRenderTarget)

Destroys the instance of ppRenderTarget.

!NOTE The value of ppRenderTarget will be set to NULL.

ParameterDescription
ppRenderTargetThe pointer pointer of the udRenderTarget. This will deallocate the instance of udRenderTarget.

Returns: A udError value based on the result of the render target destruction.

enum udError udRenderTarget_SetTargets(struct udRenderTarget *pRenderTarget, void *pColorBuffer, uint32_t colorClearValue, void *pDepthBuffer)

Set a memory buffers that a render target will write to.

!NOTE This internally calls udRenderTarget_SetTargetsWithPitch with both color and depth pitches set to 0.

ParameterDescription
pRenderTargetThe render target to associate a target buffer with.
pColorBufferThe color buffer, if null the buffer will not be rendered to anymore.
colorClearValueThe clear value to clear the color buffer with.
pDepthBufferThe depth buffer, required

Returns: A udError value based on the result of setting the targets.

enum udError udRenderTarget_SetTargetsWithPitch(struct udRenderTarget *pRenderTarget, void *pColorBuffer, uint32_t colorClearValue, void *pDepthBuffer, uint32_t colorPitchInBytes, uint32_t depthPitchInBytes)

Set a memory buffers that a render target will write to (with pitch).

ParameterDescription
pRenderTargetThe render target to associate a target buffer with.
pColorBufferThe color buffer, if null the buffer will not be rendered to anymore.
colorClearValueThe clear value to clear the color buffer with.
pDepthBufferThe depth buffer, required
colorPitchInBytesThe number of bytes that make up a row of the color buffer.
depthPitchInBytesThe number of bytes that make up a row of the depth buffer.

Returns: A udError value based on the result of setting the targets.

enum udError udRenderTarget_GetMatrix(const struct udRenderTarget *pRenderTarget, enum udRenderTargetMatrix matrixType, double cameraMatrix[16])

Get the matrix associated with pRenderTarget of type matrixType and fill it in cameraMatrix.

ParameterDescription
pRenderTargetThe render target to get the matrix from.
matrixTypeThe type of matrix to get.
cameraMatrixThe array of 16 doubles which gets filled out with the matrix.

Returns: A udError value based on the result of getting the matrix.

enum udError udRenderTarget_SetMatrix(struct udRenderTarget *pRenderTarget, enum udRenderTargetMatrix matrixType, const double cameraMatrix[16])

Set the matrix associated with pRenderTarget of type matrixType and get it from cameraMatrix.

ParameterDescription
pRenderTargetThe render target to set the matrix to.
matrixTypeThe type of matrix to set.
cameraMatrixThe array of 16 doubles to fill out the internal matrix with.

Returns: A udError value based on the result of setting the matrix.

enum udError udRenderTarget_SetLogarithmicDepthPlanes(struct udRenderTarget *pRenderTarget, double nearPlane, double farPlane)

Set the logarithmic depth near and far planes that will be used for logarithmic rendering. Note: These values are only used when the ‘udRCF_LogarithmicDepth’ rendering flag is set.

ParameterDescription
pRenderTargetThe render target to set the matrix to.
nearPlaneThe value that the near plane will be set to.
farPlaneThe value that the far plane will be set to.