Cogl.DepthState

Fields

Name

Type

Access

Description

private_member_magic

int

r

private_member_padding0

int

r

private_member_padding1

int

r

private_member_padding2

int

r

private_member_padding3

int

r

private_member_padding4

int

r

private_member_padding5

int

r

private_member_padding6

int

r

private_member_padding7

int

r

private_member_padding8

int

r

private_member_padding9

int

r

private_member_range_far

float

r

private_member_range_near

float

r

private_member_test_enabled

int

r

private_member_test_function

Cogl.DepthTestFunction

r

private_member_write_enabled

int

r

Methods

get_range (near_val, far_val)

get_test_enabled ()

get_test_function ()

get_write_enabled ()

init ()

set_range (near_val, far_val)

set_test_enabled (enable)

set_test_function (function)

set_write_enabled (enable)

Details

class Cogl.DepthState

New in version 2.0.

get_range(near_val, far_val)
Parameters:
  • near_val (float) – A pointer to store the near component of the depth range

  • far_val (float) – A pointer to store the far component of the depth range

Gets the current range to which normalized depth values are mapped before writing to the depth buffer. This corresponds to the range set with Cogl.DepthState.set_range().

New in version 2.0.

get_test_enabled()
Returns:

The pipeline’s current depth test enabled state.

Return type:

int

Gets the current depth test enabled state as previously set by Cogl.DepthState.set_test_enabled().

New in version 2.0.

get_test_function()
Returns:

The current depth test enable state.

Return type:

Cogl.DepthTestFunction

Gets the current depth test enable state as previously set via Cogl.DepthState.set_test_enabled().

New in version 2.0.

get_write_enabled()
Returns:

The current depth writing enable state

Return type:

int

Gets the depth writing enable state as set by the corresponding Cogl.DepthState.set_write_enabled().

New in version 2.0.

init()

Initializes the members of self to their default values.

You should never pass an un initialized Cogl.DepthState structure to Cogl.Pipeline.set_depth_state().

New in version 2.0.

set_range(near_val, far_val)
Parameters:
  • near_val (float) – The near component of the desired depth range which will be clamped to the range [0, 1]

  • far_val (float) – The far component of the desired depth range which will be clamped to the range [0, 1]

Sets the range to map depth values in normalized device coordinates to before writing out to a depth buffer.

After your geometry has be transformed, clipped and had perspective division applied placing it in normalized device coordinates all depth values between the near and far z clipping planes are in the range -1 to 1. Before writing any depth value to the depth buffer though the value is mapped into the range [0, 1].

With this function you can change the range which depth values are mapped too although the range must still lye within the range [0, 1].

If your driver does not support this feature (for example you are using GLES 1 drivers) then if you don’t use the default range values you will get an error reported when calling Cogl.Pipeline.set_depth_state (). You can check ahead of time for the Cogl.FeatureID.OGL_FEATURE_ID_DEPTH_RANGE feature with Cogl.has_feature() to know if this function will succeed.

By default normalized device coordinate depth values are mapped to the full range of depth buffer values, [0, 1].

NB: this won’t directly affect the state of the GPU. You have to then set the state on a Cogl.Pipeline using Cogl.Pipeline.set_depth_state().

New in version 2.0.

set_test_enabled(enable)
Parameters:

enable (int) – The enable state you want

Enables or disables depth testing according to the value of enable.

If depth testing is enable then the Cogl.DepthTestFunction set using Cogl.DepthState.set_test_function() us used to evaluate the depth value of incoming fragments against the corresponding value stored in the current depth buffer, and if the test passes then the fragments depth value is used to update the depth buffer. (unless you have disabled depth writing via Cogl.DepthState.set_write_enabled())

By default depth testing is disabled.

NB: this won’t directly affect the state of the GPU. You have to then set the state on a Cogl.Pipeline using Cogl.Pipeline.set_depth_state()

New in version 2.0.

set_test_function(function)
Parameters:

function (Cogl.DepthTestFunction) – The Cogl.DepthTestFunction to set

Sets the Cogl.DepthTestFunction used to compare the depth value of an incoming fragment against the corresponding value in the current depth buffer.

By default the depth test function is Cogl.DepthTestFunction.LESS

NB: this won’t directly affect the state of the GPU. You have to then set the state on a Cogl.Pipeline using Cogl.Pipeline.set_depth_state()

New in version 2.0.

set_write_enabled(enable)
Parameters:

enable (int) – The enable state you want

Enables or disables depth buffer writing according to the value of enable. Normally when depth testing is enabled and the comparison between a fragment’s depth value and the corresponding depth buffer value passes then the fragment’s depth is written to the depth buffer unless writing is disabled here.

By default depth writing is enabled

NB: this won’t directly affect the state of the GPU. You have to then set the state on a Cogl.Pipeline using Cogl.Pipeline.set_depth_state()

New in version 2.0.