Cogs.Core
Public Types | Static Public Member Functions | Public Attributes | List of all members
Cogs::DepthStencilState Struct Reference

Encapsulates state for depth buffer usage and stencil buffer usage in a state object. More...

#include <DepthStencilState.h>

Public Types

enum  DepthFunction {
  Never = 0 , Less , LessOrEqual , Equal ,
  GreaterOrEqual , Greater , NotEqual , Always
}
 Depth functions to apply when determining object visibility based on its depth test. More...
 

Static Public Member Functions

static DepthStencilState DefaultState ()
 Constructs a depth stencil state object initialized with the default values.
 

Public Attributes

bool depthEnabled
 If depth testing is enabled/disabled. Default is true.
 
bool writeEnabled
 If writes to the depth buffer are enabled/disabled. Default is true.
 
DepthFunction depthFunction
 The depth function to use for depth testing.
 

Detailed Description

Encapsulates state for depth buffer usage and stencil buffer usage in a state object.

This can be used to control how objects being drawn affect the contents of depth/stencil buffers, and which rules to apply when figuring out if an object should be drawn based on its depth values.

Definition at line 12 of file DepthStencilState.h.

Member Enumeration Documentation

◆ DepthFunction

Depth functions to apply when determining object visibility based on its depth test.

Example: Object A is rendered at depth 0.5 The depth function is set to Greater Object B is rendered at depth 0.6 Visibility = depth(B) Greater depth(A) = True

Enumerator
Never 

Never evaluates to true. When using this, all objects will fail depth testing.

Less 

Less depth.

LessOrEqual 

Less or equal depth.

Equal 

Equal depth.

GreaterOrEqual 

Greater or equal depth.

Greater 

Greater depth.

NotEqual 

Depth not equal evaluates to true.

Always 

Always evaluates to true.

Definition at line 23 of file DepthStencilState.h.

Member Function Documentation

◆ DefaultState()

static DepthStencilState Cogs::DepthStencilState::DefaultState ( )
inlinestatic

Constructs a depth stencil state object initialized with the default values.

Definition at line 59 of file DepthStencilState.h.

References Less.

Referenced by Cogs::Core::Renderer::render(), Cogs::ContextGL20::setDepthStencilState(), and Cogs::ContextGLES30::setDepthStencilState().

Member Data Documentation

◆ depthEnabled

bool Cogs::DepthStencilState::depthEnabled

◆ depthFunction

DepthFunction Cogs::DepthStencilState::depthFunction

The depth function to use for depth testing.

The depth of an object being drawn is compared to the contents of the depth buffer using this function. If the result of the depth test is true, the object is sent to the rasterization state, else no rasterization is performed.

Definition at line 54 of file DepthStencilState.h.

Referenced by Cogs::RenderTargetsD3D12::loadDepthStencilState(), Cogs::RenderTargetsD3D11::loadDepthStencilState(), Cogs::RenderTargetsVK::loadDepthStencilState(), Cogs::Core::Renderer::render(), Cogs::ContextGL20::setDepthStencilState(), and Cogs::ContextGLES30::setDepthStencilState().

◆ writeEnabled

bool Cogs::DepthStencilState::writeEnabled

The documentation for this struct was generated from the following file: