27#define PYDOC_BLEND_LITERAL \
28 "Literal['NONE', 'ALPHA', 'ALPHA_PREMULT', 'ADDITIVE', " \
29 "'ADDITIVE_PREMULT', 'MULTIPLY', 'SUBTRACT', 'INVERT']"
30#define PYDOC_DEPTHTEST_LITERAL \
31 "Literal['NONE', 'ALWAYS', 'LESS', 'LESS_EQUAL', 'EQUAL', 'GREATER', 'GREATER_EQUAL']"
83 pygpu_state_blend_set_doc,
84 ".. function:: blend_set(mode)\n"
86 " Defines the fixed pipeline blending equation.\n"
88 " :param mode: The type of blend mode.\n"
90 " * ``NONE`` No blending.\n"
91 " * ``ALPHA`` The original color channels are interpolated according to the alpha "
93 " * ``ALPHA_PREMULT`` The original color channels are interpolated according to the "
94 "alpha value with the new colors pre-multiplied by this value.\n"
95 " * ``ADDITIVE`` The original color channels are added by the corresponding ones.\n"
96 " * ``ADDITIVE_PREMULT`` The original color channels are added by the corresponding ones "
97 "that are pre-multiplied by the alpha value.\n"
98 " * ``MULTIPLY`` The original color channels are multiplied by the corresponding ones.\n"
99 " * ``SUBTRACT`` The original color channels are subtracted by the corresponding ones.\n"
100 " * ``INVERT`` The original color channels are replaced by its complementary color.\n"
119 pygpu_state_blend_get_doc,
120 ".. function:: blend_get()\n"
122 " Current blending equation.\n"
124 " :return: The current blend mode.\n"
136 pygpu_state_clip_distances_set_doc,
137 ".. function:: clip_distances_set(distances_enabled)\n"
139 " Sets the number of ``gl_ClipDistance`` planes used for clip geometry.\n"
141 " :param distances_enabled: Number of clip distances enabled.\n"
142 " :type distances_enabled: int\n");
147 int distances_enabled = int(PyLong_AsUnsignedLong(value));
148 if (distances_enabled == -1) {
152 if (distances_enabled > 6) {
153 PyErr_SetString(PyExc_ValueError,
"too many distances enabled, max is 6");
162 pygpu_state_depth_test_set_doc,
163 ".. function:: depth_test_set(mode)\n"
165 " Defines the depth_test equation.\n"
167 " :param mode: The depth test equation name.\n"
183 pygpu_state_depth_test_get_doc,
184 ".. function:: depth_test_get()\n"
186 " Current depth_test equation.\n"
188 " :return: The current depth test mode.\n"
200 pygpu_state_depth_mask_set_doc,
201 ".. function:: depth_mask_set(value)\n"
203 " Write to depth component.\n"
205 " :param value: True for writing to the depth component.\n"
206 " :type value: bool\n");
221 pygpu_state_depth_mask_get_doc,
222 ".. function:: depth_mask_get()\n"
224 " Writing status in the depth component.\n"
226 " :return: True if writing to the depth component is enabled.\n"
237 pygpu_state_viewport_set_doc,
238 ".. function:: viewport_set(x, y, xsize, ysize)\n"
240 " Specifies the viewport of the active framebuffer.\n"
241 " Note: The viewport state is not saved upon framebuffer rebind.\n"
243 " :param x: Lower left corner x coordinate, in pixels.\n"
245 " :param y: Lower left corner y coordinate, in pixels.\n"
247 " :param xsize: Width of the viewport.\n"
248 " :type xsize: int\n"
249 " :param ysize: Height of the viewport.\n"
250 " :type ysize: int\n");
255 int x,
y, xsize, ysize;
256 if (!PyArg_ParseTuple(args,
276 pygpu_state_viewport_get_doc,
277 ".. function:: viewport_get()\n"
279 " Viewport of the active framebuffer.\n"
281 " :return: The viewport as a tuple (x, y, xsize, ysize).\n"
282 " :rtype: tuple[int, int, int, int]\n");
290 PyObject *
ret = PyTuple_New(4);
292 PyLong_FromLong(viewport[0]),
293 PyLong_FromLong(viewport[1]),
294 PyLong_FromLong(viewport[2]),
295 PyLong_FromLong(viewport[3]));
301 pygpu_state_scissor_set_doc,
302 ".. function:: scissor_set(x, y, xsize, ysize)\n"
304 " Specifies the scissor area of the active framebuffer.\n"
305 " Note: The scissor state is not saved upon framebuffer rebind.\n"
307 " :param x: Lower left corner x coordinate, in pixels.\n"
309 " :param y: Lower left corner y coordinate, in pixels.\n"
311 " :param xsize: Width of the scissor rectangle.\n"
312 " :type xsize: int\n"
313 " :param ysize: Height of the scissor rectangle.\n"
314 " :type ysize: int\n");
319 int x,
y, xsize, ysize;
320 if (!PyArg_ParseTuple(args,
340 pygpu_state_scissor_get_doc,
341 ".. function:: scissor_get()\n"
343 " Retrieve the scissors of the active framebuffer.\n"
344 " Note: Only valid between 'scissor_set' and a framebuffer rebind.\n"
346 " :return: The scissor of the active framebuffer as a tuple\n"
347 " (x, y, xsize, ysize).\n"
348 " x, y: lower left corner of the scissor rectangle, in pixels.\n"
349 " xsize, ysize: width and height of the scissor rectangle.\n"
350 " :rtype: tuple[int, int, int, int]\n");
358 PyObject *
ret = PyTuple_New(4);
360 PyLong_FromLong(scissor[0]),
361 PyLong_FromLong(scissor[1]),
362 PyLong_FromLong(scissor[2]),
363 PyLong_FromLong(scissor[3]));
369 pygpu_state_scissor_test_set_doc,
370 ".. function:: scissor_test_set(enable)\n"
372 " Enable/disable scissor testing on the active framebuffer.\n"
375 " True - enable scissor testing.\n"
376 " False - disable scissor testing.\n"
377 " :type enable: bool\n");
393 pygpu_state_line_width_set_doc,
394 ".. function:: line_width_set(width)\n"
396 " Specify the width of rasterized lines.\n"
398 " :param width: New width.\n"
399 " :type width: float\n");
404 float width =
float(PyFloat_AsDouble(value));
405 if (PyErr_Occurred()) {
415 pygpu_state_line_width_get_doc,
416 ".. function:: line_width_get()\n"
418 " Current width of rasterized lines.\n"
420 " :return: The current line width.\n"
427 return PyFloat_FromDouble(
double(width));
432 pygpu_state_point_size_set_doc,
433 ".. function:: point_size_set(size)\n"
435 " Specify the diameter of rasterized points.\n"
437 " When ``program_point_size_set(False)`` is set, this sets the ``size``\n"
438 " uniform of point shaders. Any value set by ``uniform_float(\"size\", ...)``\n"
439 " on a point shader will be overwritten by this function. Use\n"
440 " ``program_point_size_set(True)`` to disable this override and control\n"
441 " point size via ``gl_PointSize`` in the vertex shader.\n"
443 " :param size: New diameter.\n"
444 " :type size: float\n");
449 float size =
float(PyFloat_AsDouble(value));
450 if (PyErr_Occurred()) {
460 pygpu_state_color_mask_set_doc,
461 ".. function:: color_mask_set(r, g, b, a)\n"
463 " Enable or disable writing of frame buffer color components.\n"
465 " :param r: Red component.\n"
467 " :param g: Green component.\n"
469 " :param b: Blue component.\n"
471 " :param a: Alpha component.\n"
478 if (!PyArg_ParseTuple(args,
498 pygpu_state_face_culling_set_doc,
499 ".. function:: face_culling_set(culling)\n"
501 " Specify whether none, front-facing or back-facing facets can be culled.\n"
503 " :param culling: The face culling mode.\n"
504 " :type culling: Literal['NONE', 'FRONT', 'BACK']\n");
520 pygpu_state_front_facing_set_doc,
521 ".. function:: front_facing_set(invert)\n"
523 " Specifies the orientation of front-facing polygons.\n"
525 " :param invert: True for clockwise polygons as front-facing.\n"
526 " :type invert: bool\n");
542 pygpu_state_program_point_size_set_doc,
543 ".. function:: program_point_size_set(enable)\n"
545 " When enabled (True), point size is taken from the shader builtin\n"
546 " ``gl_PointSize``. When disabled (False), the global state value can\n"
547 " be applied to the shader ``size`` uniform, overwriting any user-set\n"
550 " :param enable: True to use shader ``gl_PointSize``, False for global state.\n"
551 " :type enable: bool\n");
567 pygpu_state_active_framebuffer_get_doc,
568 ".. function:: active_framebuffer_get()\n"
570 " Return the active frame-buffer in context.\n"
572 " :return: The active framebuffer.\n"
573 " :rtype: :class:`gpu.types.GPUFrameBuffer`\n");
590# pragma clang diagnostic push
591# pragma clang diagnostic ignored "-Wcast-function-type"
593# pragma GCC diagnostic push
594# pragma GCC diagnostic ignored "-Wcast-function-type"
603 pygpu_state_blend_set_doc},
607 pygpu_state_blend_get_doc},
608 {
"clip_distances_set",
611 pygpu_state_clip_distances_set_doc},
615 pygpu_state_depth_test_set_doc},
619 pygpu_state_depth_test_get_doc},
623 pygpu_state_depth_mask_set_doc},
627 pygpu_state_depth_mask_get_doc},
631 pygpu_state_viewport_set_doc},
635 pygpu_state_viewport_get_doc},
639 pygpu_state_scissor_set_doc},
643 pygpu_state_scissor_get_doc},
647 pygpu_state_scissor_test_set_doc},
651 pygpu_state_line_width_set_doc},
655 pygpu_state_line_width_get_doc},
659 pygpu_state_point_size_set_doc},
663 pygpu_state_color_mask_set_doc},
667 pygpu_state_face_culling_set_doc},
671 pygpu_state_front_facing_set_doc},
672 {
"program_point_size_set",
675 pygpu_state_program_point_size_set_doc},
676 {
"active_framebuffer_get",
679 pygpu_state_active_framebuffer_get_doc},
680 {
nullptr,
nullptr, 0,
nullptr},
685# pragma clang diagnostic pop
687# pragma GCC diagnostic pop
694 "This module provides access to the gpu state.");
#define BPYGPU_IS_INIT_OR_ERROR_OBJ
#define PYDOC_BLEND_LITERAL
#define PYDOC_DEPTHTEST_LITERAL
float2x2 invert(float2x2 mat)
void GPU_scissor_test(bool enable)
gpu::FrameBuffer * GPU_framebuffer_active_get()
static const PyC_StringEnumItems pygpu_state_blend_items[]
static PyObject * pygpu_state_depth_mask_get(PyObject *)
int PyC_ParseBool(PyObject *o, void *p)
void GPU_clip_distances(int distances_enabled)
PyObject * bpygpu_state_init()
GPUDepthTest GPU_depth_test_get()
BLI_INLINE float fb(float length, float L)
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
void GPU_point_size(float size)
static PyModuleDef pygpu_state_module_def
void GPU_depth_mask(bool depth)
static PyObject * pygpu_state_blend_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_active_framebuffer_get(PyObject *)
static PyObject * pygpu_state_viewport_set(PyObject *, PyObject *args)
static PyObject * pygpu_state_color_mask_set(PyObject *, PyObject *args)
PyObject * BPyGPUFrameBuffer_CreatePyObject(gpu::FrameBuffer *fb, bool shared_reference)
static PyObject * pygpu_state_depth_test_set(PyObject *, PyObject *value)
void GPU_line_width(float width)
@ GPU_BLEND_ADDITIVE_PREMULT
@ GPU_BLEND_ALPHA_PREMULT
float GPU_line_width_get()
static PyObject * pygpu_state_depth_test_get(PyObject *)
static PyObject * pygpu_state_point_size_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_scissor_test_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_line_width_get(PyObject *)
@ GPU_DEPTH_GREATER_EQUAL
static PyObject * pygpu_state_line_width_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_clip_distances_set(PyObject *, PyObject *value)
void GPU_scissor_get(int coords[4])
bool GPU_depth_mask_get()
void GPU_color_mask(bool r, bool g, bool b, bool a)
void GPU_program_point_size(bool enable)
const char * PyC_StringEnum_FindIDFromValue(const PyC_StringEnumItems *items, const int value)
static PyObject * pygpu_state_face_culling_set(PyObject *, PyObject *value)
void GPU_scissor(int x, int y, int width, int height)
static PyObject * pygpu_state_blend_get(PyObject *)
static PyObject * pygpu_state_viewport_get(PyObject *, PyObject *)
static PyObject * pygpu_state_depth_mask_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_scissor_get(PyObject *, PyObject *)
void GPU_viewport(int x, int y, int width, int height)
static const PyC_StringEnumItems pygpu_state_depthtest_items[]
void GPU_viewport_size_get_i(int coords[4])
void GPU_face_culling(GPUFaceCullTest culling)
static PyObject * pygpu_state_front_facing_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_program_point_size_set(PyObject *, PyObject *value)
void GPU_front_facing(bool invert)
void GPU_blend(GPUBlend blend)
static PyObject * pygpu_state_scissor_set(PyObject *, PyObject *args)
int PyC_ParseStringEnum(PyObject *o, void *p)
static PyMethodDef pygpu_state__tp_methods[]
void GPU_depth_test(GPUDepthTest test)
static const PyC_StringEnumItems pygpu_state_faceculling_items[]
#define PyTuple_SET_ITEMS(op_arg,...)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float