This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Программирование
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine::RenderState Class

Header:#include <UnigineRenderState.h>

A low-level graphics state abstraction.

Usage Example

The following example illustrates the common usage of the saveState(), clearStates(), flushStates(), and restoreState() methods

Source code (C++)
/* ... */

// getting the current render state pointer
RenderState *render_state = RenderState::get();

// saving the current render state
render_state->saveState();

	// clearing the current render state to prevent our rendering code from being affected by the previous settings
	render_state->clearStates();

	/* ... */

	// changing current render state 
	render_state->setBlendFunc(RenderState::BLEND_SRC_ALPHA, RenderState::BLEND_ONE_MINUS_SRC_ALPHA );

	// flushing the current render state to GPU
	render_state->flushStates();

	/*	rendering code begin 

	... 
	
	rendering code end */

	// clearing the current render state (if necessary)
	render_state->clearStates();

	// changing current render state again
	render_state->setPolygonFront(1);

	// flushing the current render state to GPU
	render_state->flushStates();

	/*	rendering code begin 

	... 
	
	rendering code end */

// restoring the previously saved render state
render_state->restoreState();

/* ... */

RenderState Class

Members


RenderState * get()

Returns a pointer to the existing RenderState instance.

Return value

A pointer to the RenderState instance.

void setAnisotropy(int anisotropy)

Sets the texture anisotropy level (degree of anisotropic filtering).

Arguments

  • int anisotropy - Texture anisotropy level to be set:
    • 0 - anisotropy level 1.
    • 1 - anisotropy level 2.
    • 2 - anisotropy level 4.
    • 3 - anisotropy level 8.
    • 4 - anisotropy level 16.

int getAnisotropy()

Returns the current texture anisotropy level (degree of anisotropic filtering).

Return value

Current texture anisotropy level:
  • 0 - anisotropy level 1.
  • 1 - anisotropy level 2.
  • 2 - anisotropy level 4.
  • 3 - anisotropy level 8.
  • 4 - anisotropy level 16.

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.

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.

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 setDepthFunc(int func)

Sets the depth function.

Arguments

  • int func - Depth function

int getDepthFunc()

Returns the current depth function.

Return value

The depth function (one of the DEPTH_* variables).

int getHeight()

Returns the viewport height.

Return value

Viewport height.

void setMaterial(const Ptr<Material> & material)

Sets the material.

Arguments

  • const Ptr<Material> & material - Material smart pointer.

Ptr<Material> getMaterial()

Returns the current material.

Return value

Material smart pointer.

float getPolygonBias()

Returns the polygon bias offset.

Return value

Polygon bias offset.

void setPolygonCull(int cull)

Sets the polygon cull mode.

Arguments

  • int cull - The polygon cull mode (one of the CULL_* variables).

int getPolygonCull()

Returns the polygon cull mode.

Return value

Polygon cull mode (one of the CULL_* variables).

void setPolygonFill(int fill)

Sets the polygon fill mode.

Arguments

  • int fill - Polygon fill mode (one of the FILL_* variables).

int getPolygonFill()

Returns the polygon fill mode.

Return value

Polygon fill mode.

void setPolygonFront(int front)

Set the polygon mode to front.

Arguments

  • int front - 1 - enable the front mode; 0 - disable it.

int getPolygonFront()

Returns value indicating if the polygon front mode is set.

Return value

1 if the polygon front mode is set; otherwise - 0.

void setPolygonOffset(float bias, float offset)

Sets the polygon offset value.

Arguments

  • float bias - Polygon bias offset.
  • float offset - 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(const Math::ivec4 & rectangle)

Sets scissor test by using rectangle coordinates.

Arguments

  • const Math::ivec4 & rectangle - Rectangle coordinates.

void setScissorTest(const Math::vec4 & rectangle)

Sets scissor test by using rectangle coordinates.

Arguments

  • const Math::vec4 & rectangle - Rectangle coordinates.

int getScissorTest()

Returns the scissors test status.

Return value

Scissors test status.

Ptr<Texture> getScreenColorTexture()

Returns the screen color texture.

Return value

Texture smart pointer.

Ptr<Texture> getScreenDepthTexture()

Returns the screen depth texture.

Return value

Texture smart pointer.

void setShader(const Ptr<Shader> & shader)

Sets the shader.

Arguments

  • const Ptr<Shader> & shader - Shader smart pointer.

Ptr<Shader> getShader()

Returns the shader.

Return value

Shader smart pointer.

void setStencilFunc(int func, int pass, int ref)

Sets the stencil function.

Arguments

  • int func - Stencil function.
  • int pass - Stencil operation.
  • int ref - Stencil reference value.

int getStencilFunc()

Returns the stencil function.

Return value

Stencil function.

int getStencilPass()

Returns the stencil mode.

Return value

The stencil mode (one of the STENCIL_* variables.)

int getStencilRef()

Returns the stencil reference value.

Return value

Stencil reference value.

void setStructuredBuffer(int num, const Ptr<StructuredBuffer> & buffer)

Sets given StructuredBuffer to the render state.

Arguments

  • int num - StructuredBuffer unit number.
  • const Ptr<StructuredBuffer> & buffer - A pointer to the StructuredBuffer.

void setTexture(int binding, int num, const Ptr<Texture> & texture)

Sets the texture.

Arguments

  • int binding - Binding.
  • int num - Texture unit number.
  • const Ptr<Texture> & texture - Texture smart pointer.

Ptr<Texture> getTexture(int num)

Returns the current texture.

Arguments

  • int num - Texture unit number.

Return value

Texture smart pointer.

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.

int getWidth()

Returns the viewport width.

Return value

Viewport width.

void clearBuffer(int buffer, const Math::vec4 & color, float depth = 1.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.
    Source code
    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);
  • const Math::vec4 & color - Color value to be used.
  • float depth - Depth value to be used.
  • int stencil - Stencil value to be used.

void clearStates()

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.

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

int BIND_ALL

Description

A flag indicating that texture should be bound to all shaders.

int BIND_FRAGMENT

Description

A flag indicating that texture should be bound to fragment shaders only.

int BLEND_DEST_ALPHA

Description

Destination alpha blending factor. Each component of the color is multiplied by the alpha value of the destination.

int BLEND_DEST_COLOR

Description

Destination color blending factor. Each component of the color is multiplied by the destination color.

int BLEND_NONE

Description

None blending factor.

int BLEND_ONE

Description

One blending factor. Each component of the color is multiplied by (1, 1, 1, 1).

int BLEND_ONE_MINUS_DEST_ALPHA

Description

Inversed destination alpha blending factor. Each component of the color is multiplied by the inverse of the alpha value of the destination.

int BLEND_ONE_MINUS_DEST_COLOR

Description

Inversed destination color blending factor. Each component of the color is multiplied by the inverse of the destination color.

int BLEND_ONE_MINUS_SRC1_ALPHA

Description

Inversed source alpha blending factor (for dual source blending). Each component of the color is multiplied by the inverse of the alpha value of the source.

int BLEND_ONE_MINUS_SRC1_COLOR

Description

Inversed source color blending factor (for dual source blending). Each component of the color is multiplied by the inverse of the source color.

int BLEND_ONE_MINUS_SRC_ALPHA

Description

Inversed source alpha blending factor. Each component of the color is multiplied by the inverse of the alpha value of the source.

int BLEND_ONE_MINUS_SRC_COLOR

Description

Inversed source color blending factor. Each component of the color is multiplied by the inverse of the source color.

int BLEND_SRC1_ALPHA

Description

Source alpha blending factor. Each component of the color is multiplied by the alpha value of the source.

int BLEND_SRC1_COLOR

Description

Source color blending factor (for dual source blending). Each component of the color is multiplied by the source color.

int BLEND_SRC_ALPHA

Description

Source alpha blending factor. Each component of the color is multiplied by the alpha value of the source.

int BLEND_SRC_COLOR

Description

Source color blending factor. Each component of the color is multiplied by the source color.

int BLEND_ZERO

Description

Zero blending factor. Each component of the color is multiplied by (0, 0, 0, 0).

int BUFFER_ALL

Description

Buffer mask indicating that all color channels, depth, and stencil buffers are available for rendering.

int BUFFER_ALPHA

Description

Buffer mask indicating that A channel of the buffer is available for rendering.

int BUFFER_BLUE

Description

Buffer mask indicating that B channel of the buffer is available for rendering.

int BUFFER_COLOR

Description

Buffer mask indicating that all color channels of the buffer are available for rendering.

int BUFFER_DEPTH

Description

Buffer mask indicating that depth buffer is available for rendering.

int BUFFER_DEPTH_STENCIL

Description

Buffer mask indicating that depth and stencil buffers are available for rendering.

int BUFFER_GREEN

Description

Buffer mask indicating that G channel of the buffer is available for rendering.

int BUFFER_NONE

Description

Buffer mask indicating that all color channels, depth, and stencil buffers are not available for rendering.

int BUFFER_RED

Description

Buffer mask indicating that R channel of the buffer is available for rendering.

int BUFFER_STENCIL

Description

Buffer mask indicating that stencil buffer is available for rendering.

int CULL_BACK

Description

A flag indicating that back-facing polygons should be culled.

int CULL_FRONT

Description

A flag indicating that front-facing polygons should be culled.

int CULL_NONE

Description

A flag tat disables the polygon culling.

int DEPTH_ALWAYS

Description

A flag indicating depth function that performs the comparison which always succeeds (always passes).

int DEPTH_EQUAL

Description

A flag indicating depth function that performs the comparison which is an equal-to operation (passes if the incoming depth value is equal to the stored depth value).

int DEPTH_NOT_EQUAL

Description

A flag indicating depth function that performs the comparison which is a not-equal-to operation (passes if the incoming depth value is not equal to the stored depth value).

int DEPTH_GEQUAL

Description

A flag indicating depth function that performs the comparison which is a greater-than or equal-to operation (passes if the incoming depth value is greater than or equal to the stored depth value).

int DEPTH_LEQUAL

Description

A flag indicating depth function that performs the comparison which is a less-than or equal-to operation (passes if the incoming depth value is less than or equal to the stored depth value).

int DEPTH_NONE

Description

A flag that disables the depth comparison function.

int FILL_SOLID

Description

A flag that specifies how polygons will be rasterized (the interior of the polygon is filled)

int FILL_WIREFRAME

Description

A flag that specifies how polygons will be rasterized (boundary edges of the polygon are drawn as line segments.)

int FRONT_CCW

Description

Counterclockwise orientation mode of the front-facing polygon.s

int FRONT_CW

Description

Clockwise orientation mode of the front-facing polygons.

int FRONT_INVERT

Description

Back-facing mode for polygons.

int STENCIL_KEEP

Description

A flag indicating stencil buffer operation that does not update the entry in the stencil buffer (stencil value unchanged).

int STENCIL_INCR

Description

A flag indicating stencil buffer operation that increments the stencil-buffer entry (stencil value incremented).

int STENCIL_REPLACE

Description

A flag indicating stencil buffer operation that replaces the stencil-buffer entry with a reference value (stencil value replaced by stencil reference value).

int STENCIL_NONE

Description

A flag that disables the stencil test.

int STENCIL_LESS

Description

A flag indicating stencil function that performs a comparison which is a less-than operation (passes if reference value is less than stencil buffer).

int STENCIL_EQUAL

Description

A flag indicating stencil function that performs a comparison which is an equal-to operation (passes if reference value is equal to stencil buffer).

int STENCIL_LESS_EQUAL

Description

A flag indicating stencil function that performs a comparison which is a less-than-or-equal-to operation (passes if reference value is less than or equal to stencil buffer).

int STENCIL_GREATER

Description

A flag indicating stencil function that performs a comparison which is a greater-than operation (passes if reference value is greater than stencil buffer).

int STENCIL_NOT_EQUAL

Description

A flag indicating stencil function that performs a comparison which is an not-equal-to operation (passes if reference value is not equal to stencil buffer).

int STENCIL_GREATER_EQUAL

Description

A flag indicating stencil function that performs a comparison which is a greater-than-or-equal-to operation (passes if reference value is greater than or equal to stencil buffer).

int STENCIL_ALWAYS

Description

A flag indicating stencil function that performs the comparison which always succeeds.

int ALPHA_COVERAGE

int ALPHA_NONE

int BLEND_OP_ADD

Description

ADD blending operation: source and destination colors are added to each other. O = sS + dD. The source and dest are multiplied by blending parameters.

int BLEND_OP_SUBTRACT

Description

SUBTRACT blending operation: subtracts the destination from the source. O = sS - dD. The source and dest are multiplied by blending parameters.

int BLEND_OP_REVERSE_SUBTRACT

Description

REVERSE SUBTRACT blending operation: subtracts the source from the destination. O = dD - sS. The source and dest are multiplied by blending parameters.

int BLEND_OP_MIN

Description

MIN blending operation: output color is the component-wise minimum value of the source and dest colors. So for RGB it means that Or = min(Sr, Dr), Og = min(Sg, Dg), and so forth.

int BLEND_OP_MAX

Description

MAX blending operation: output color is the component-wise maximum value of the source and dest colors. So for RGB it means that Or = max(Sr, Dr), Og = max(Sg, Dg), and so forth.
Last update: 10.08.2018
Build: ()