2011-04-14 13:12:03 -04:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2011-04-14 13:12:03 -04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Intel Corporation.
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2011-04-14 13:12:03 -04:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
2011-04-14 13:12:03 -04:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2011-04-14 13:12:03 -04:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
2023-11-07 05:56:00 -05:00
|
|
|
#include "config.h"
|
2011-04-14 13:12:03 -04:00
|
|
|
|
2023-08-07 09:38:12 -04:00
|
|
|
#include "cogl/cogl-util.h"
|
|
|
|
#include "cogl/cogl-depth-state-private.h"
|
|
|
|
#include "cogl/cogl-depth-state.h"
|
2011-04-14 13:12:03 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
cogl_depth_state_init (CoglDepthState *state)
|
|
|
|
{
|
|
|
|
state->magic = COGL_DEPTH_STATE_MAGIC;
|
|
|
|
|
2012-03-31 16:30:26 -04:00
|
|
|
/* The same as the GL defaults */
|
2011-04-14 13:12:03 -04:00
|
|
|
state->test_enabled = FALSE;
|
|
|
|
state->write_enabled = TRUE;
|
|
|
|
state->test_function = COGL_DEPTH_TEST_FUNCTION_LESS;
|
|
|
|
state->range_near = 0;
|
|
|
|
state->range_far = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cogl_depth_state_set_test_enabled (CoglDepthState *state,
|
2018-11-24 07:04:47 -05:00
|
|
|
gboolean enabled)
|
2011-04-14 13:12:03 -04:00
|
|
|
{
|
2019-06-17 17:40:06 -04:00
|
|
|
g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC);
|
2011-04-14 13:12:03 -04:00
|
|
|
state->test_enabled = enabled;
|
|
|
|
}
|
|
|
|
|
2018-11-24 07:04:47 -05:00
|
|
|
gboolean
|
2011-04-14 13:12:03 -04:00
|
|
|
cogl_depth_state_get_test_enabled (CoglDepthState *state)
|
|
|
|
{
|
2019-06-17 17:42:01 -04:00
|
|
|
g_return_val_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE);
|
2011-04-14 13:12:03 -04:00
|
|
|
return state->test_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cogl_depth_state_set_write_enabled (CoglDepthState *state,
|
2018-11-24 07:04:47 -05:00
|
|
|
gboolean enabled)
|
2011-04-14 13:12:03 -04:00
|
|
|
{
|
2019-06-17 17:40:06 -04:00
|
|
|
g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC);
|
2011-04-14 13:12:03 -04:00
|
|
|
state->write_enabled = enabled;
|
|
|
|
}
|
|
|
|
|
2018-11-24 07:04:47 -05:00
|
|
|
gboolean
|
2011-04-14 13:12:03 -04:00
|
|
|
cogl_depth_state_get_write_enabled (CoglDepthState *state)
|
|
|
|
{
|
2019-06-17 17:42:01 -04:00
|
|
|
g_return_val_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE);
|
2011-04-14 13:12:03 -04:00
|
|
|
return state->write_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cogl_depth_state_set_test_function (CoglDepthState *state,
|
|
|
|
CoglDepthTestFunction function)
|
|
|
|
{
|
2019-06-17 17:40:06 -04:00
|
|
|
g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC);
|
2011-04-14 13:12:03 -04:00
|
|
|
state->test_function = function;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglDepthTestFunction
|
|
|
|
cogl_depth_state_get_test_function (CoglDepthState *state)
|
|
|
|
{
|
2019-06-17 17:42:01 -04:00
|
|
|
g_return_val_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC, FALSE);
|
2011-04-14 13:12:03 -04:00
|
|
|
return state->test_function;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cogl_depth_state_set_range (CoglDepthState *state,
|
2011-06-14 09:40:27 -04:00
|
|
|
float near,
|
|
|
|
float far)
|
2011-04-14 13:12:03 -04:00
|
|
|
{
|
2019-06-17 17:40:06 -04:00
|
|
|
g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC);
|
2011-06-14 09:40:27 -04:00
|
|
|
state->range_near = near;
|
|
|
|
state->range_far = far;
|
2011-04-14 13:12:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cogl_depth_state_get_range (CoglDepthState *state,
|
|
|
|
float *near_out,
|
|
|
|
float *far_out)
|
|
|
|
{
|
2019-06-17 17:40:06 -04:00
|
|
|
g_return_if_fail (state->magic == COGL_DEPTH_STATE_MAGIC);
|
2011-04-14 13:12:03 -04:00
|
|
|
*near_out = state->range_near;
|
|
|
|
*far_out = state->range_far;
|
|
|
|
}
|