2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup bpygpu
|
|
|
|
|
*
|
|
|
|
|
* This file defines the gpu.state API.
|
|
|
|
|
*
|
2021-07-20 22:52:31 +10:00
|
|
|
* - Use `bpygpu_` for local API.
|
|
|
|
|
* - Use `BPyGPU` for public API.
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <Python.h>
|
|
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "GPU_framebuffer.hh"
|
|
|
|
|
#include "GPU_state.hh"
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
|
2024-09-24 15:25:36 +02:00
|
|
|
#include "../generic/py_capi_utils.hh"
|
|
|
|
|
#include "../generic/python_utildefines.hh"
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
|
2024-03-23 10:06:45 -04:00
|
|
|
#include "gpu_py.hh"
|
|
|
|
|
#include "gpu_py_framebuffer.hh"
|
|
|
|
|
#include "gpu_py_state.hh" /* own include */
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Helper Functions
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2023-07-22 11:33:36 +10:00
|
|
|
static const PyC_StringEnumItems pygpu_state_blend_items[] = {
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{GPU_BLEND_NONE, "NONE"},
|
|
|
|
|
{GPU_BLEND_ALPHA, "ALPHA"},
|
|
|
|
|
{GPU_BLEND_ALPHA_PREMULT, "ALPHA_PREMULT"},
|
|
|
|
|
{GPU_BLEND_ADDITIVE, "ADDITIVE"},
|
|
|
|
|
{GPU_BLEND_ADDITIVE_PREMULT, "ADDITIVE_PREMULT"},
|
|
|
|
|
{GPU_BLEND_MULTIPLY, "MULTIPLY"},
|
|
|
|
|
{GPU_BLEND_SUBTRACT, "SUBTRACT"},
|
|
|
|
|
{GPU_BLEND_INVERT, "INVERT"},
|
|
|
|
|
/**
|
|
|
|
|
* These are quite special cases used inside the draw manager.
|
|
|
|
|
* {GPU_BLEND_OIT, "OIT"},
|
|
|
|
|
* {GPU_BLEND_BACKGROUND, "BACKGROUND"},
|
|
|
|
|
* {GPU_BLEND_CUSTOM, "CUSTOM"},
|
|
|
|
|
*/
|
2023-07-21 19:41:03 +02:00
|
|
|
{0, nullptr},
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
};
|
|
|
|
|
|
2023-07-22 11:33:36 +10:00
|
|
|
static const PyC_StringEnumItems pygpu_state_depthtest_items[] = {
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{GPU_DEPTH_NONE, "NONE"},
|
|
|
|
|
{GPU_DEPTH_ALWAYS, "ALWAYS"},
|
|
|
|
|
{GPU_DEPTH_LESS, "LESS"},
|
|
|
|
|
{GPU_DEPTH_LESS_EQUAL, "LESS_EQUAL"},
|
|
|
|
|
{GPU_DEPTH_EQUAL, "EQUAL"},
|
|
|
|
|
{GPU_DEPTH_GREATER, "GREATER"},
|
|
|
|
|
{GPU_DEPTH_GREATER_EQUAL, "GREATER_EQUAL"},
|
2023-07-21 19:41:03 +02:00
|
|
|
{0, nullptr},
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
};
|
|
|
|
|
|
2023-07-22 11:33:36 +10:00
|
|
|
static const PyC_StringEnumItems pygpu_state_faceculling_items[] = {
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{GPU_CULL_NONE, "NONE"},
|
|
|
|
|
{GPU_CULL_FRONT, "FRONT"},
|
|
|
|
|
{GPU_CULL_BACK, "BACK"},
|
2023-07-21 19:41:03 +02:00
|
|
|
{0, nullptr},
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Manage Stack
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2021-03-16 12:48:00 -03:00
|
|
|
PyDoc_STRVAR(
|
2024-01-25 10:22:16 +11:00
|
|
|
/* Wrap. */
|
2021-03-16 12:48:00 -03:00
|
|
|
pygpu_state_blend_set_doc,
|
|
|
|
|
".. function:: blend_set(mode)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Defines the fixed pipeline blending equation.\n"
|
|
|
|
|
"\n"
|
2022-09-19 14:22:31 +10:00
|
|
|
" :arg mode: The type of blend mode.\n"
|
2024-11-03 19:28:00 +11:00
|
|
|
"\n"
|
2021-03-31 17:42:21 +11:00
|
|
|
" * ``NONE`` No blending.\n"
|
|
|
|
|
" * ``ALPHA`` The original color channels are interpolated according to the alpha "
|
|
|
|
|
"value.\n"
|
|
|
|
|
" * ``ALPHA_PREMULT`` The original color channels are interpolated according to the "
|
|
|
|
|
"alpha value with the new colors pre-multiplied by this value.\n"
|
|
|
|
|
" * ``ADDITIVE`` The original color channels are added by the corresponding ones.\n"
|
|
|
|
|
" * ``ADDITIVE_PREMULT`` The original color channels are added by the corresponding ones "
|
2021-03-16 12:48:00 -03:00
|
|
|
"that are pre-multiplied by the alpha value.\n"
|
2021-03-31 17:42:21 +11:00
|
|
|
" * ``MULTIPLY`` The original color channels are multiplied by the corresponding ones.\n"
|
|
|
|
|
" * ``SUBTRACT`` The original color channels are subtracted by the corresponding ones.\n"
|
|
|
|
|
" * ``INVERT`` The original color channels are replaced by its complementary color.\n"
|
2021-03-31 09:46:38 +02:00
|
|
|
//" * ``OIT``.\n"
|
|
|
|
|
//" * ``BACKGROUND`` .\n"
|
|
|
|
|
//" * ``CUSTOM`` .\n"
|
2021-03-16 12:48:00 -03:00
|
|
|
" :type mode: str\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_blend_set(PyObject * /*self*/, PyObject *value)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
2023-07-22 11:33:36 +10:00
|
|
|
PyC_StringEnum pygpu_blend = {pygpu_state_blend_items};
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
if (!PyC_ParseStringEnum(value, &pygpu_blend)) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
}
|
2025-09-15 15:11:02 +02:00
|
|
|
GPU_blend(GPUBlend(pygpu_blend.value_found));
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_blend_get_doc,
|
|
|
|
|
".. function:: blend_get()\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Current blending equation.\n"
|
|
|
|
|
"\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_blend_get(PyObject * /*self*/)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
2025-09-15 15:11:02 +02:00
|
|
|
GPUBlend blend = GPU_blend_get();
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
return PyUnicode_FromString(PyC_StringEnum_FindIDFromValue(pygpu_state_blend_items, blend));
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_clip_distances_set_doc,
|
|
|
|
|
".. function:: clip_distances_set(distances_enabled)\n"
|
|
|
|
|
"\n"
|
2025-08-22 15:10:29 +10:00
|
|
|
" Sets the number of ``gl_ClipDistance`` planes used for clip geometry.\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
"\n"
|
|
|
|
|
" :arg distances_enabled: Number of clip distances enabled.\n"
|
|
|
|
|
" :type distances_enabled: int\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_clip_distances_set(PyObject * /*self*/, PyObject *value)
|
2021-08-26 13:02:52 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
2023-07-22 11:33:36 +10:00
|
|
|
int distances_enabled = int(PyLong_AsUnsignedLong(value));
|
2021-08-26 13:02:52 -03:00
|
|
|
if (distances_enabled == -1) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
2021-08-26 13:02:52 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (distances_enabled > 6) {
|
|
|
|
|
PyErr_SetString(PyExc_ValueError, "too many distances enabled, max is 6");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_clip_distances(distances_enabled);
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_depth_test_set_doc,
|
|
|
|
|
".. function:: depth_test_set(mode)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Defines the depth_test equation.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg mode: The depth test equation name.\n"
|
2025-08-22 15:10:29 +10:00
|
|
|
" Possible values are ``NONE``, ``ALWAYS``, ``LESS``, ``LESS_EQUAL``, ``EQUAL``, "
|
|
|
|
|
"``GREATER`` and ``GREATER_EQUAL``.\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
" :type mode: str\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_depth_test_set(PyObject * /*self*/, PyObject *value)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
2023-07-22 11:33:36 +10:00
|
|
|
PyC_StringEnum pygpu_depth_test = {pygpu_state_depthtest_items};
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
if (!PyC_ParseStringEnum(value, &pygpu_depth_test)) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
}
|
2025-09-15 15:11:02 +02:00
|
|
|
GPU_depth_test(GPUDepthTest(pygpu_depth_test.value_found));
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_depth_test_get_doc,
|
|
|
|
|
".. function:: depth_test_get()\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Current depth_test equation.\n"
|
|
|
|
|
"\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_depth_test_get(PyObject * /*self*/)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
2025-09-15 15:11:02 +02:00
|
|
|
GPUDepthTest test = GPU_depth_test_get();
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
return PyUnicode_FromString(PyC_StringEnum_FindIDFromValue(pygpu_state_depthtest_items, test));
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_depth_mask_set_doc,
|
|
|
|
|
".. function:: depth_mask_set(value)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Write to depth component.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg value: True for writing to the depth component.\n"
|
|
|
|
|
" :type near: bool\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_depth_mask_set(PyObject * /*self*/, PyObject *value)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
bool write_to_depth;
|
|
|
|
|
if (!PyC_ParseBool(value, &write_to_depth)) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
}
|
|
|
|
|
GPU_depth_mask(write_to_depth);
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_depth_mask_get_doc,
|
|
|
|
|
".. function:: depth_mask_get()\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Writing status in the depth component.\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_depth_mask_get(PyObject * /*self*/)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
return PyBool_FromLong(GPU_depth_mask_get());
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_viewport_set_doc,
|
|
|
|
|
".. function:: viewport_set(x, y, xsize, ysize)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Specifies the viewport of the active framebuffer.\n"
|
|
|
|
|
" Note: The viewport state is not saved upon framebuffer rebind.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg x, y: lower left corner of the viewport_set rectangle, in pixels.\n"
|
|
|
|
|
" :type x, y: int\n"
|
|
|
|
|
" :arg xsize, ysize: width and height of the viewport_set.\n"
|
|
|
|
|
" :type xsize, ysize: int\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_viewport_set(PyObject * /*self*/, PyObject *args)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
int x, y, xsize, ysize;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "iiii:viewport_set", &x, &y, &xsize, &ysize)) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_viewport(x, y, xsize, ysize);
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_viewport_get_doc,
|
|
|
|
|
".. function:: viewport_get()\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Viewport of the active framebuffer.\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_viewport_get(PyObject * /*self*/, PyObject * /*args*/)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
int viewport[4];
|
|
|
|
|
GPU_viewport_size_get_i(viewport);
|
|
|
|
|
|
|
|
|
|
PyObject *ret = PyTuple_New(4);
|
|
|
|
|
PyTuple_SET_ITEMS(ret,
|
|
|
|
|
PyLong_FromLong(viewport[0]),
|
|
|
|
|
PyLong_FromLong(viewport[1]),
|
|
|
|
|
PyLong_FromLong(viewport[2]),
|
|
|
|
|
PyLong_FromLong(viewport[3]));
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_scissor_set_doc,
|
|
|
|
|
".. function:: scissor_set(x, y, xsize, ysize)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Specifies the scissor area of the active framebuffer.\n"
|
|
|
|
|
" Note: The scissor state is not saved upon framebuffer rebind.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg x, y: lower left corner of the scissor rectangle, in pixels.\n"
|
|
|
|
|
" :type x, y: int\n"
|
|
|
|
|
" :arg xsize, ysize: width and height of the scissor rectangle.\n"
|
|
|
|
|
" :type xsize, ysize: int\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_scissor_set(PyObject * /*self*/, PyObject *args)
|
2023-02-20 09:13:20 +01:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
2023-02-20 09:13:20 +01:00
|
|
|
int x, y, xsize, ysize;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "iiii:scissor_set", &x, &y, &xsize, &ysize)) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
2023-02-20 09:13:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_scissor(x, y, xsize, ysize);
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_scissor_get_doc,
|
|
|
|
|
".. function:: scissor_get()\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Retrieve the scissors of the active framebuffer.\n"
|
|
|
|
|
" Note: Only valid between 'scissor_set' and a framebuffer rebind.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :return: The scissor of the active framebuffer as a tuple\n"
|
|
|
|
|
" (x, y, xsize, ysize).\n"
|
|
|
|
|
" x, y: lower left corner of the scissor rectangle, in pixels.\n"
|
|
|
|
|
" xsize, ysize: width and height of the scissor rectangle.\n"
|
2024-11-03 15:42:19 +11:00
|
|
|
" :rtype: tuple[int, int, int, int]\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_scissor_get(PyObject * /*self*/, PyObject * /*args*/)
|
2023-02-20 09:13:20 +01:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
2023-02-20 09:13:20 +01:00
|
|
|
int scissor[4];
|
|
|
|
|
GPU_scissor_get(scissor);
|
|
|
|
|
|
|
|
|
|
PyObject *ret = PyTuple_New(4);
|
|
|
|
|
PyTuple_SET_ITEMS(ret,
|
|
|
|
|
PyLong_FromLong(scissor[0]),
|
|
|
|
|
PyLong_FromLong(scissor[1]),
|
|
|
|
|
PyLong_FromLong(scissor[2]),
|
|
|
|
|
PyLong_FromLong(scissor[3]));
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_scissor_test_set_doc,
|
|
|
|
|
".. function:: scissor_test_set(enable)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Enable/disable scissor testing on the active framebuffer.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg enable:\n"
|
|
|
|
|
" True - enable scissor testing.\n"
|
|
|
|
|
" False - disable scissor testing.\n"
|
|
|
|
|
" :type enable: bool\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_scissor_test_set(PyObject * /*self*/, PyObject *value)
|
2023-02-20 09:13:20 +01:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
2023-02-20 09:13:20 +01:00
|
|
|
bool enabled;
|
|
|
|
|
if (!PyC_ParseBool(value, &enabled)) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
2023-02-20 09:13:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_scissor_test(enabled);
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_line_width_set_doc,
|
|
|
|
|
".. function:: line_width_set(width)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Specify the width of rasterized lines.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg size: New width.\n"
|
|
|
|
|
" :type mode: float\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_line_width_set(PyObject * /*self*/, PyObject *value)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
2023-07-22 11:33:36 +10:00
|
|
|
float width = float(PyFloat_AsDouble(value));
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
if (PyErr_Occurred()) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_line_width(width);
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_line_width_get_doc,
|
|
|
|
|
".. function:: line_width_get()\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Current width of rasterized lines.\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_line_width_get(PyObject * /*self*/)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
float width = GPU_line_width_get();
|
2023-07-22 11:33:36 +10:00
|
|
|
return PyFloat_FromDouble(double(width));
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_point_size_set_doc,
|
|
|
|
|
".. function:: point_size_set(size)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Specify the diameter of rasterized points.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg size: New diameter.\n"
|
|
|
|
|
" :type mode: float\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_point_size_set(PyObject * /*self*/, PyObject *value)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
2023-07-22 11:33:36 +10:00
|
|
|
float size = float(PyFloat_AsDouble(value));
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
if (PyErr_Occurred()) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_point_size(size);
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_color_mask_set_doc,
|
|
|
|
|
".. function:: color_mask_set(r, g, b, a)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Enable or disable writing of frame buffer color components.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg r, g, b, a: components red, green, blue, and alpha.\n"
|
|
|
|
|
" :type r, g, b, a: bool\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_color_mask_set(PyObject * /*self*/, PyObject *args)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
int r, g, b, a;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "pppp:color_mask_set", &r, &g, &b, &a)) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
}
|
|
|
|
|
|
2023-07-22 11:33:36 +10:00
|
|
|
GPU_color_mask(bool(r), bool(g), bool(b), bool(a));
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_face_culling_set_doc,
|
|
|
|
|
".. function:: face_culling_set(culling)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Specify whether none, front-facing or back-facing facets can be culled.\n"
|
|
|
|
|
"\n"
|
2025-08-22 15:10:29 +10:00
|
|
|
" :arg mode: ``NONE``, ``FRONT`` or ``BACK``.\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
" :type mode: str\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_face_culling_set(PyObject * /*self*/, PyObject *value)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
2023-07-22 11:33:36 +10:00
|
|
|
PyC_StringEnum pygpu_faceculling = {pygpu_state_faceculling_items};
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
if (!PyC_ParseStringEnum(value, &pygpu_faceculling)) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
}
|
|
|
|
|
|
2025-09-15 15:11:02 +02:00
|
|
|
GPU_face_culling(GPUFaceCullTest(pygpu_faceculling.value_found));
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_front_facing_set_doc,
|
|
|
|
|
".. function:: front_facing_set(invert)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Specifies the orientation of front-facing polygons.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg invert: True for clockwise polygons as front-facing.\n"
|
|
|
|
|
" :type mode: bool\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_front_facing_set(PyObject * /*self*/, PyObject *value)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
bool invert;
|
|
|
|
|
if (!PyC_ParseBool(value, &invert)) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_front_facing(invert);
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state_program_point_size_set_doc,
|
|
|
|
|
".. function:: program_point_size_set(enable)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" If enabled, the derived point size is taken from the (potentially clipped) "
|
|
|
|
|
"shader builtin gl_PointSize.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg enable: True for shader builtin gl_PointSize.\n"
|
|
|
|
|
" :type enable: bool\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_state_program_point_size_set(PyObject * /*self*/, PyObject *value)
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
bool enable;
|
|
|
|
|
if (!PyC_ParseBool(value, &enable)) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_program_point_size(enable);
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
2024-09-16 09:51:04 +02:00
|
|
|
pygpu_state_active_framebuffer_get_doc,
|
|
|
|
|
".. function:: active_framebuffer_get(enable)\n"
|
2024-01-25 10:22:16 +11:00
|
|
|
"\n"
|
|
|
|
|
" Return the active frame-buffer in context.\n");
|
2024-09-16 09:51:04 +02:00
|
|
|
static PyObject *pygpu_state_active_framebuffer_get(PyObject * /*self*/)
|
2021-04-30 10:48:55 -03:00
|
|
|
{
|
2024-06-19 17:54:35 +02:00
|
|
|
BPYGPU_IS_INIT_OR_ERROR_OBJ;
|
|
|
|
|
|
2025-09-16 17:50:48 +02:00
|
|
|
blender::gpu::FrameBuffer *fb = GPU_framebuffer_active_get();
|
2021-04-30 10:48:55 -03:00
|
|
|
return BPyGPUFrameBuffer_CreatePyObject(fb, true);
|
|
|
|
|
}
|
|
|
|
|
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Module
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2025-04-01 12:06:03 +11:00
|
|
|
#ifdef __GNUC__
|
|
|
|
|
# ifdef __clang__
|
|
|
|
|
# pragma clang diagnostic push
|
|
|
|
|
# pragma clang diagnostic ignored "-Wcast-function-type"
|
|
|
|
|
# else
|
|
|
|
|
# pragma GCC diagnostic push
|
|
|
|
|
# pragma GCC diagnostic ignored "-Wcast-function-type"
|
|
|
|
|
# endif
|
2023-07-22 11:11:42 +10:00
|
|
|
#endif
|
|
|
|
|
|
2023-06-03 08:36:28 +10:00
|
|
|
static PyMethodDef pygpu_state__tp_methods[] = {
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
/* Manage Stack */
|
|
|
|
|
{"blend_set", (PyCFunction)pygpu_state_blend_set, METH_O, pygpu_state_blend_set_doc},
|
|
|
|
|
{"blend_get", (PyCFunction)pygpu_state_blend_get, METH_NOARGS, pygpu_state_blend_get_doc},
|
2021-08-26 13:02:52 -03:00
|
|
|
{"clip_distances_set",
|
|
|
|
|
(PyCFunction)pygpu_state_clip_distances_set,
|
|
|
|
|
METH_O,
|
|
|
|
|
pygpu_state_clip_distances_set_doc},
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{"depth_test_set",
|
|
|
|
|
(PyCFunction)pygpu_state_depth_test_set,
|
|
|
|
|
METH_O,
|
|
|
|
|
pygpu_state_depth_test_set_doc},
|
|
|
|
|
{"depth_test_get",
|
|
|
|
|
(PyCFunction)pygpu_state_depth_test_get,
|
|
|
|
|
METH_NOARGS,
|
|
|
|
|
pygpu_state_depth_test_get_doc},
|
|
|
|
|
{"depth_mask_set",
|
|
|
|
|
(PyCFunction)pygpu_state_depth_mask_set,
|
|
|
|
|
METH_O,
|
|
|
|
|
pygpu_state_depth_mask_set_doc},
|
|
|
|
|
{"depth_mask_get",
|
|
|
|
|
(PyCFunction)pygpu_state_depth_mask_get,
|
|
|
|
|
METH_NOARGS,
|
|
|
|
|
pygpu_state_depth_mask_get_doc},
|
|
|
|
|
{"viewport_set",
|
|
|
|
|
(PyCFunction)pygpu_state_viewport_set,
|
|
|
|
|
METH_VARARGS,
|
|
|
|
|
pygpu_state_viewport_set_doc},
|
|
|
|
|
{"viewport_get",
|
|
|
|
|
(PyCFunction)pygpu_state_viewport_get,
|
|
|
|
|
METH_NOARGS,
|
|
|
|
|
pygpu_state_viewport_get_doc},
|
2023-02-20 09:13:20 +01:00
|
|
|
{"scissor_set",
|
|
|
|
|
(PyCFunction)pygpu_state_scissor_set,
|
|
|
|
|
METH_VARARGS,
|
|
|
|
|
pygpu_state_scissor_set_doc},
|
|
|
|
|
{"scissor_get",
|
|
|
|
|
(PyCFunction)pygpu_state_scissor_get,
|
|
|
|
|
METH_NOARGS,
|
|
|
|
|
pygpu_state_scissor_get_doc},
|
|
|
|
|
{"scissor_test_set",
|
|
|
|
|
(PyCFunction)pygpu_state_scissor_test_set,
|
2023-03-17 08:03:55 +01:00
|
|
|
METH_O,
|
2023-02-20 09:13:20 +01:00
|
|
|
pygpu_state_scissor_test_set_doc},
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{"line_width_set",
|
|
|
|
|
(PyCFunction)pygpu_state_line_width_set,
|
|
|
|
|
METH_O,
|
|
|
|
|
pygpu_state_line_width_set_doc},
|
|
|
|
|
{"line_width_get",
|
|
|
|
|
(PyCFunction)pygpu_state_line_width_get,
|
|
|
|
|
METH_NOARGS,
|
|
|
|
|
pygpu_state_line_width_get_doc},
|
|
|
|
|
{"point_size_set",
|
|
|
|
|
(PyCFunction)pygpu_state_point_size_set,
|
|
|
|
|
METH_O,
|
|
|
|
|
pygpu_state_point_size_set_doc},
|
|
|
|
|
{"color_mask_set",
|
|
|
|
|
(PyCFunction)pygpu_state_color_mask_set,
|
|
|
|
|
METH_VARARGS,
|
|
|
|
|
pygpu_state_color_mask_set_doc},
|
|
|
|
|
{"face_culling_set",
|
|
|
|
|
(PyCFunction)pygpu_state_face_culling_set,
|
|
|
|
|
METH_O,
|
|
|
|
|
pygpu_state_face_culling_set_doc},
|
|
|
|
|
{"front_facing_set",
|
|
|
|
|
(PyCFunction)pygpu_state_front_facing_set,
|
|
|
|
|
METH_O,
|
|
|
|
|
pygpu_state_front_facing_set_doc},
|
|
|
|
|
{"program_point_size_set",
|
|
|
|
|
(PyCFunction)pygpu_state_program_point_size_set,
|
|
|
|
|
METH_O,
|
|
|
|
|
pygpu_state_program_point_size_set_doc},
|
2021-04-30 10:48:55 -03:00
|
|
|
{"active_framebuffer_get",
|
2024-09-16 09:51:04 +02:00
|
|
|
(PyCFunction)pygpu_state_active_framebuffer_get,
|
2021-04-30 10:48:55 -03:00
|
|
|
METH_NOARGS,
|
2024-09-16 09:51:04 +02:00
|
|
|
pygpu_state_active_framebuffer_get_doc},
|
2023-07-21 19:41:03 +02:00
|
|
|
{nullptr, nullptr, 0, nullptr},
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
};
|
|
|
|
|
|
2025-04-01 12:06:03 +11:00
|
|
|
#ifdef __GNUC__
|
|
|
|
|
# ifdef __clang__
|
|
|
|
|
# pragma clang diagnostic pop
|
|
|
|
|
# else
|
|
|
|
|
# pragma GCC diagnostic pop
|
|
|
|
|
# endif
|
2023-07-22 11:11:42 +10:00
|
|
|
#endif
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_state__tp_doc,
|
|
|
|
|
"This module provides access to the gpu state.");
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
static PyModuleDef pygpu_state_module_def = {
|
2023-07-16 17:43:31 +10:00
|
|
|
/*m_base*/ PyModuleDef_HEAD_INIT,
|
2022-11-08 11:13:58 +11:00
|
|
|
/*m_name*/ "gpu.state",
|
|
|
|
|
/*m_doc*/ pygpu_state__tp_doc,
|
|
|
|
|
/*m_size*/ 0,
|
|
|
|
|
/*m_methods*/ pygpu_state__tp_methods,
|
2023-07-21 19:41:03 +02:00
|
|
|
/*m_slots*/ nullptr,
|
|
|
|
|
/*m_traverse*/ nullptr,
|
|
|
|
|
/*m_clear*/ nullptr,
|
|
|
|
|
/*m_free*/ nullptr,
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
};
|
|
|
|
|
|
2023-07-22 11:33:36 +10:00
|
|
|
PyObject *bpygpu_state_init()
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
{
|
|
|
|
|
PyObject *submodule;
|
|
|
|
|
|
2024-06-19 17:54:35 +02:00
|
|
|
submodule = PyModule_Create(&pygpu_state_module_def);
|
Python: gpu module: add new submodules and types
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 10:48:08 -03:00
|
|
|
|
|
|
|
|
return submodule;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \} */
|