Unigine.RenderState Class
A low-level graphics state abstraction.
Usage Example#
The following example illustrates the common usage of the saveState(), clearStates(), flushStates(), and restoreState() methods
/* ... */
// saving the current render state
RenderState.SaveState();
// clearing the current render state to prevent our rendering code from being affected by the previous settings
RenderState.ClearStates();
/* ... */
// changing current render state
RenderState.SetBlendFunc(RenderState.BLEND_SRC_ALPHA, RenderState.BLEND_ONE_MINUS_SRC_ALPHA );
// flushing the current render state to GPU
RenderState.FlushStates();
/* rendering code begin
...
rendering code end */
// clearing the current render state (if necessary)
RenderState.ClearStates();
// changing current render state again
RenderState.SetPolygonFront(1);
// flushing the current render state to GPU
RenderState.FlushStates();
/* rendering code begin
...
rendering code end */
// restoring the previously saved render state
RenderState.RestoreState();
/* ... */
RenderState Class
Properties
Material Material#
The current material.
Shader Shader#
The shader.
int Anisotropy#
The current texture anisotropy level (degree of anisotropic filtering).
int PolygonFill#
The polygon fill mode.
int PolygonCull#
The polygon cull mode.
int PolygonFront#
The Value indicating if the polygon front mode is set.
int DepthFunc#
The current depth function.
int Height#
The viewport height.
int Width#
The viewport width.
int CoordX#
The X-coordinate of the viewport.
int CoordY#
The Y-coordinate of the viewport.
Texture ScreenColorTexture#
The screen color texture.
Texture ScreenDepthTexture#
The screen depth texture.
float PolygonSlope#
The polygon slope offset.
float PolygonBias#
The polygon bias offset.
int BlendOperation#
The current blending operation.
int BlendDestFunc#
The destination blending function.
int BlendSrcFunc#
The source blending function.
int StencilRef#
The stencil reference value.
int StencilPass#
The stencil mode.
int StencilFunc#
The stencil function.
Members
void SetBlendDestFunc ( int func ) #
Sets a new destination blending function.Arguments
- int func - New destination blending function to be set. One of the BLEND_* variables.
int GetBlendDestFunc ( ) #
Returns the destination blending function.Return value
Destination blending function. One of the BLEND_* variables.int GetBlendDestFuncBuffer ( int num ) #
Returns the destination blending function for the specified buffer.Arguments
- int num - Buffer number.
Return value
Destination blending function. One of the BLEND_* variables.void SetBlendFunc ( int src, int dest, int blend_op = 0 ) #
Sets blending function.Arguments
- int src - Source blending function. One of the BLEND_* variables.
- int dest - Destination blending function. One of the BLEND_* variables.
- int blend_op - Blending operation to be used. One of the BLEND_OP_* variables. BLEND_OP_ADD is used by default.
void SetBlendFuncBuffer ( int num, int src, int dest, int blend_op = 0 ) #
Sets blending function for the specified buffer.Arguments
- int num - Buffer number.
- int src - Source blending function. One of the BLEND_* variables.
- int dest - Destination blending function. One of the BLEND_* variables.
- int blend_op - Blending operation to be used. One of the BLEND_OP_* variables. BLEND_OP_ADD is used by default.
void SetBlendSrcFunc ( int func ) #
Sets a new source blending function.Arguments
- int func - New source blending function to be set. One of the BLEND_* variables.
int GetBlendSrcFunc ( ) #
Returns the source blending function.Return value
Source blending function. One of the BLEND_* variables.int GetBlendSrcFuncBuffer ( int num ) #
Returns the source blending function for the specified buffer.Arguments
- int num - Buffer number.
Return value
Source blending function. One of the BLEND_* variables.void SetBlendOperation ( int operation ) #
Sets a new blending operation.Arguments
- int operation - New blending operation to be set. One of the BLEND_OP_* variables.
int GetBlendOperation ( ) #
Returns the current blending operation.Return value
Current blending operation. One of the BLEND_OP_* variables.int GetBlendOperationBuffer ( int num ) #
Returns the current blending operation for the given buffer.Arguments
- int num - Buffer number.
Return value
Current blending operation for the given buffer. One of the BLEND_OP_* variables.void SetBufferMask ( int num, int mask ) #
Sets the buffer mask.Arguments
- int num - Buffer number.
- int mask - Buffer mask.
int GetBufferMask ( int num ) #
Returns buffer mask.Arguments
- int num - Buffer number.
Return value
Buffer mask.void SetMaterial ( int pass, Material material ) #
Sets the specified material to be used for the specified rendering pass.Arguments
- int pass - Rendering pass for which the material is to be set.
- Material material - Material to be used.
void SetPolygonBias ( float bias ) #
Sets a new polygon bias offset.Arguments
- float bias - New polygon bias offset to be set.
float GetPolygonBias ( ) #
Returns the polygon bias offset.Return value
Polygon bias offset.void SetPolygonOffset ( float bias, float offset ) #
Sets the polygon offset value.Arguments
- float bias - Polygon bias offset.
- float offset - Polygon slope offset.
void SetPolygonSlope ( float slope ) #
Sets a new polygon slope offset.Arguments
- float slope - New polygon slope offset.
float GetPolygonSlope ( ) #
Returns the polygon slope offset.Return value
Polygon slope offset.void SetScissorTest ( float x, float y, float width, float height ) #
Sets scissor test.Arguments
- float x - The X coordinate.
- float y - The Y coordinate.
- float width - Viewport width.
- float height - Viewport height.
void SetScissorTest ( ivec4 rectangle ) #
Sets scissor test by using rectangle coordinates.Arguments
- ivec4 rectangle - Rectangle coordinates.
void SetScissorTest ( vec4 rectangle ) #
Sets scissor test by using rectangle coordinates.Arguments
- vec4 rectangle - Rectangle coordinates.
int GetScissorTest ( ) #
Returns the scissors test status.Return value
Scissors test status.Texture GetScreenColorTexture ( ) #
Returns the screen color texture.Return value
Texture.Texture GetScreenDepthTexture ( ) #
Returns the screen depth texture.Return value
Texture.void SetStencilFunc ( int func ) #
Sets the stencil function.Arguments
- int func - Stencil function.
int GetStencilFunc ( ) #
Returns the stencil function.Return value
Stencil function.void SetStencilPass ( int pass ) #
Sets a new stencil mode.Arguments
- int pass - New stencil mode to be set (one of the STENCIL_* variables.)
int GetStencilPass ( ) #
Returns the stencil mode.Return value
The stencil mode (one of the STENCIL_* variables.)void SetStencilRef ( int ref ) #
Sets a new stencil reference value.Arguments
- int ref - New stencil reference value to be set.
int GetStencilRef ( ) #
Returns the stencil reference value.Return value
Stencil reference value.void SetStructuredBuffer ( int num, StructuredBuffer buffer ) #
Sets given StructuredBuffer to the render state.Arguments
- int num - StructuredBuffer unit number.
- StructuredBuffer buffer - A pointer to the StructuredBuffer.
void SetTexture ( int binding, int num, Texture texture ) #
Sets the texture.Arguments
- int binding - Binding.
- int num - Texture unit number (texture slot).
- Texture texture - Texture.
void SetTexture ( int binding, int num, Texture texture, int sampler_flags ) #
Arguments
- int binding
- int num - Texture unit number (texture slot).
- Texture texture
- int sampler_flags
Texture GetTexture ( int num ) #
Returns the current texture.Arguments
- int num - Texture unit number (texture slot).
Return value
Texture.void SetViewport ( int x, int y, int width, int height ) #
Sets the viewport size and position.Arguments
- int x - The X coordinate.
- int y - The Y coordinate.
- int width - The width.
- int height - The height.
void ClearBuffer ( int buffer, vec4 color, float depth = 0.0f, int stencil = 0 ) #
Clears the specified buffer.Arguments
- int buffer - Buffer mask determines which buffers are to be cleared. One or combination of BUFFER_* variables.
clearBuffer(BUFFER_COLOR); // clears color buffer clearBuffer(BUFFER_DEPTH); // clears depth buffer clearBuffer(BUFFER_STENCIL); // clears stencil buffer //masks can be combined: clearBuffer(BUFFER_COLOR | BUFFER_STENCIL); // clears color and stencil buffer //there is a separate BUFFER_DEPTH_STENCIL mask for convenience clearBuffer(BUFFER_DEPTH_STENCIL);
- vec4 color - Color value to be used.
- float depth - Depth value to be used.
- int stencil - Stencil value to be used.
void ClearStates ( bool clear_all = true ) #
Clears all current render states. This method is used to prevent certain rendering code segment from being affected by other segments. See the usage example, that illustrates the typical use case.Arguments
- bool clear_all - Clear flag: true - to clear current shader, material, textures, and structured buffers as well, or false to clear render states only.
void ClearStructuredBuffer ( StructuredBuffer buffer ) #
Clears the specified structured buffer.Arguments
- StructuredBuffer buffer - Structured buffer to be cleared.
void ClearStructuredBuffers ( ) #
Clears all current structured buffers.void ClearTexture ( Texture texture ) #
Clears the specified texture.Arguments
- Texture texture - Texture to be cleared.
void ClearTextures ( ) #
Clears all textures.void FlushRender ( ) #
Flushes the render.void FlushStates ( ) #
Flushes the current render state to GPU. See the usage example, that illustrates the typical use case.void SaveState ( ) #
Saves the current render state. This method is to be used together with the restoreState() method to enclose a segment of code, that changes the render state. See the usage example, that illustrates the typical use case.void RestoreState ( ) #
Restores the current render state, that was saved by calling the saveState() method. These two methods are used together to enclose a segment of code, that changes the render state. See the usage example, that illustrates the typical use case.void Dispatch ( int group_threads_x, int group_threads_y, int group_threads_z ) #
Executes commands in a compute shader (similar to ID3D11DeviceContext::Dispatch() method). A compute shader can be run on many threads in parallel, within a thread group. Index a particular thread, within a thread group using a 3D vector given by (x,y,z).Arguments
- int group_threads_x - Local X work-group size of the compute shader.
- int group_threads_y - Local Y work-group size of the compute shader.
- int group_threads_z - Local Z work-group size of the compute shader.
Last update:
2024-12-13
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)