74 pygpu_state_blend_set_doc,
75 ".. function:: blend_set(mode)\n"
77 " Defines the fixed pipeline blending equation.\n"
79 " :arg mode: The type of blend mode.\n"
81 " * ``NONE`` No blending.\n"
82 " * ``ALPHA`` The original color channels are interpolated according to the alpha "
84 " * ``ALPHA_PREMULT`` The original color channels are interpolated according to the "
85 "alpha value with the new colors pre-multiplied by this value.\n"
86 " * ``ADDITIVE`` The original color channels are added by the corresponding ones.\n"
87 " * ``ADDITIVE_PREMULT`` The original color channels are added by the corresponding ones "
88 "that are pre-multiplied by the alpha value.\n"
89 " * ``MULTIPLY`` The original color channels are multiplied by the corresponding ones.\n"
90 " * ``SUBTRACT`` The original color channels are subtracted by the corresponding ones.\n"
91 " * ``INVERT`` The original color channels are replaced by its complementary color.\n"
95 " :type mode: str\n");
110 pygpu_state_blend_get_doc,
111 ".. function:: blend_get()\n"
113 " Current blending equation.\n"
125 pygpu_state_clip_distances_set_doc,
126 ".. function:: clip_distances_set(distances_enabled)\n"
128 " Sets the number of ``gl_ClipDistance`` planes used for clip geometry.\n"
130 " :arg distances_enabled: Number of clip distances enabled.\n"
131 " :type distances_enabled: int\n");
136 int distances_enabled = int(PyLong_AsUnsignedLong(value));
137 if (distances_enabled == -1) {
141 if (distances_enabled > 6) {
142 PyErr_SetString(PyExc_ValueError,
"too many distances enabled, max is 6");
151 pygpu_state_depth_test_set_doc,
152 ".. function:: depth_test_set(mode)\n"
154 " Defines the depth_test equation.\n"
156 " :arg mode: The depth test equation name.\n"
157 " Possible values are ``NONE``, ``ALWAYS``, ``LESS``, ``LESS_EQUAL``, ``EQUAL``, "
158 "``GREATER`` and ``GREATER_EQUAL``.\n"
159 " :type mode: str\n");
174 pygpu_state_depth_test_get_doc,
175 ".. function:: depth_test_get()\n"
177 " Current depth_test equation.\n"
189 pygpu_state_depth_mask_set_doc,
190 ".. function:: depth_mask_set(value)\n"
192 " Write to depth component.\n"
194 " :arg value: True for writing to the depth component.\n"
195 " :type near: bool\n");
210 pygpu_state_depth_mask_get_doc,
211 ".. function:: depth_mask_get()\n"
213 " Writing status in the depth component.\n");
223 pygpu_state_viewport_set_doc,
224 ".. function:: viewport_set(x, y, xsize, ysize)\n"
226 " Specifies the viewport of the active framebuffer.\n"
227 " Note: The viewport state is not saved upon framebuffer rebind.\n"
229 " :arg x, y: lower left corner of the viewport_set rectangle, in pixels.\n"
231 " :arg xsize, ysize: width and height of the viewport_set.\n"
232 " :type xsize, ysize: int\n");
237 int x,
y, xsize, ysize;
238 if (!PyArg_ParseTuple(args,
"iiii:viewport_set", &
x, &
y, &xsize, &ysize)) {
248 pygpu_state_viewport_get_doc,
249 ".. function:: viewport_get()\n"
251 " Viewport of the active framebuffer.\n");
259 PyObject *
ret = PyTuple_New(4);
261 PyLong_FromLong(viewport[0]),
262 PyLong_FromLong(viewport[1]),
263 PyLong_FromLong(viewport[2]),
264 PyLong_FromLong(viewport[3]));
270 pygpu_state_scissor_set_doc,
271 ".. function:: scissor_set(x, y, xsize, ysize)\n"
273 " Specifies the scissor area of the active framebuffer.\n"
274 " Note: The scissor state is not saved upon framebuffer rebind.\n"
276 " :arg x, y: lower left corner of the scissor rectangle, in pixels.\n"
278 " :arg xsize, ysize: width and height of the scissor rectangle.\n"
279 " :type xsize, ysize: int\n");
284 int x,
y, xsize, ysize;
285 if (!PyArg_ParseTuple(args,
"iiii:scissor_set", &
x, &
y, &xsize, &ysize)) {
295 pygpu_state_scissor_get_doc,
296 ".. function:: scissor_get()\n"
298 " Retrieve the scissors of the active framebuffer.\n"
299 " Note: Only valid between 'scissor_set' and a framebuffer rebind.\n"
301 " :return: The scissor of the active framebuffer as a tuple\n"
302 " (x, y, xsize, ysize).\n"
303 " x, y: lower left corner of the scissor rectangle, in pixels.\n"
304 " xsize, ysize: width and height of the scissor rectangle.\n"
305 " :rtype: tuple[int, int, int, int]\n");
313 PyObject *
ret = PyTuple_New(4);
315 PyLong_FromLong(scissor[0]),
316 PyLong_FromLong(scissor[1]),
317 PyLong_FromLong(scissor[2]),
318 PyLong_FromLong(scissor[3]));
324 pygpu_state_scissor_test_set_doc,
325 ".. function:: scissor_test_set(enable)\n"
327 " Enable/disable scissor testing on the active framebuffer.\n"
330 " True - enable scissor testing.\n"
331 " False - disable scissor testing.\n"
332 " :type enable: bool\n");
348 pygpu_state_line_width_set_doc,
349 ".. function:: line_width_set(width)\n"
351 " Specify the width of rasterized lines.\n"
353 " :arg size: New width.\n"
354 " :type mode: float\n");
359 float width =
float(PyFloat_AsDouble(value));
360 if (PyErr_Occurred()) {
370 pygpu_state_line_width_get_doc,
371 ".. function:: line_width_get()\n"
373 " Current width of rasterized lines.\n");
379 return PyFloat_FromDouble(
double(width));
384 pygpu_state_point_size_set_doc,
385 ".. function:: point_size_set(size)\n"
387 " Specify the diameter of rasterized points.\n"
389 " :arg size: New diameter.\n"
390 " :type mode: float\n");
395 float size =
float(PyFloat_AsDouble(value));
396 if (PyErr_Occurred()) {
406 pygpu_state_color_mask_set_doc,
407 ".. function:: color_mask_set(r, g, b, a)\n"
409 " Enable or disable writing of frame buffer color components.\n"
411 " :arg r, g, b, a: components red, green, blue, and alpha.\n"
412 " :type r, g, b, a: bool\n");
418 if (!PyArg_ParseTuple(args,
"pppp:color_mask_set", &r, &g, &
b, &a)) {
428 pygpu_state_face_culling_set_doc,
429 ".. function:: face_culling_set(culling)\n"
431 " Specify whether none, front-facing or back-facing facets can be culled.\n"
433 " :arg mode: ``NONE``, ``FRONT`` or ``BACK``.\n"
434 " :type mode: str\n");
450 pygpu_state_front_facing_set_doc,
451 ".. function:: front_facing_set(invert)\n"
453 " Specifies the orientation of front-facing polygons.\n"
455 " :arg invert: True for clockwise polygons as front-facing.\n"
456 " :type mode: bool\n");
472 pygpu_state_program_point_size_set_doc,
473 ".. function:: program_point_size_set(enable)\n"
475 " If enabled, the derived point size is taken from the (potentially clipped) "
476 "shader builtin gl_PointSize.\n"
478 " :arg enable: True for shader builtin gl_PointSize.\n"
479 " :type enable: bool\n");
495 pygpu_state_active_framebuffer_get_doc,
496 ".. function:: active_framebuffer_get(enable)\n"
498 " Return the active frame-buffer in context.\n");
515# pragma clang diagnostic push
516# pragma clang diagnostic ignored "-Wcast-function-type"
518# pragma GCC diagnostic push
519# pragma GCC diagnostic ignored "-Wcast-function-type"
527 {
"clip_distances_set",
530 pygpu_state_clip_distances_set_doc},
534 pygpu_state_depth_test_set_doc},
538 pygpu_state_depth_test_get_doc},
542 pygpu_state_depth_mask_set_doc},
546 pygpu_state_depth_mask_get_doc},
550 pygpu_state_viewport_set_doc},
554 pygpu_state_viewport_get_doc},
558 pygpu_state_scissor_set_doc},
562 pygpu_state_scissor_get_doc},
566 pygpu_state_scissor_test_set_doc},
570 pygpu_state_line_width_set_doc},
574 pygpu_state_line_width_get_doc},
578 pygpu_state_point_size_set_doc},
582 pygpu_state_color_mask_set_doc},
586 pygpu_state_face_culling_set_doc},
590 pygpu_state_front_facing_set_doc},
591 {
"program_point_size_set",
594 pygpu_state_program_point_size_set_doc},
595 {
"active_framebuffer_get",
598 pygpu_state_active_framebuffer_get_doc},
599 {
nullptr,
nullptr, 0,
nullptr},
604# pragma clang diagnostic pop
606# pragma GCC diagnostic pop
613 "This module provides access to the gpu state.");
blender::gpu::FrameBuffer * GPU_framebuffer_active_get()
void GPU_program_point_size(bool enable)
void GPU_scissor_test(bool enable)
@ GPU_DEPTH_GREATER_EQUAL
void GPU_line_width(float width)
@ GPU_BLEND_ADDITIVE_PREMULT
@ GPU_BLEND_ALPHA_PREMULT
void GPU_depth_mask(bool depth)
void GPU_face_culling(GPUFaceCullTest culling)
void GPU_blend(GPUBlend blend)
void GPU_depth_test(GPUDepthTest test)
void GPU_color_mask(bool r, bool g, bool b, bool a)
void GPU_viewport_size_get_i(int coords[4])
void GPU_scissor(int x, int y, int width, int height)
GPUDepthTest GPU_depth_test_get()
float GPU_line_width_get()
void GPU_front_facing(bool invert)
void GPU_viewport(int x, int y, int width, int height)
void GPU_point_size(float size)
bool GPU_depth_mask_get()
void GPU_scissor_get(int coords[4])
void GPU_clip_distances(int distances_enabled)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
#define BPYGPU_IS_INIT_OR_ERROR_OBJ
PyObject * BPyGPUFrameBuffer_CreatePyObject(blender::gpu::FrameBuffer *fb, bool shared_reference)
static PyObject * pygpu_state_scissor_set(PyObject *, PyObject *args)
static PyObject * pygpu_state_blend_get(PyObject *)
static PyObject * pygpu_state_viewport_set(PyObject *, PyObject *args)
static PyMethodDef pygpu_state__tp_methods[]
static PyObject * pygpu_state_program_point_size_set(PyObject *, PyObject *value)
PyDoc_STRVAR(pygpu_state_blend_set_doc, ".. function:: blend_set(mode)\n" "\n" " Defines the fixed pipeline blending equation.\n" "\n" " :arg mode: The type of blend mode.\n" "\n" " * ``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 " "that are pre-multiplied by the alpha value.\n" " * ``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" " :type mode: str\n")
static PyObject * pygpu_state_viewport_get(PyObject *, PyObject *)
static PyObject * pygpu_state_scissor_test_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_line_width_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_front_facing_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_point_size_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_active_framebuffer_get(PyObject *)
PyObject * bpygpu_state_init()
static PyObject * pygpu_state_depth_mask_get(PyObject *)
static PyObject * pygpu_state_face_culling_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_clip_distances_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_blend_set(PyObject *, PyObject *value)
static const PyC_StringEnumItems pygpu_state_depthtest_items[]
static PyObject * pygpu_state_depth_test_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_line_width_get(PyObject *)
static PyObject * pygpu_state_depth_test_get(PyObject *)
static PyObject * pygpu_state_depth_mask_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_color_mask_set(PyObject *, PyObject *args)
static const PyC_StringEnumItems pygpu_state_faceculling_items[]
static PyObject * pygpu_state_scissor_get(PyObject *, PyObject *)
static PyModuleDef pygpu_state_module_def
static const PyC_StringEnumItems pygpu_state_blend_items[]
BLI_INLINE float fb(float length, float L)
CCL_NAMESPACE_BEGIN ccl_device float invert(const float color, const float factor)
int PyC_ParseStringEnum(PyObject *o, void *p)
const char * PyC_StringEnum_FindIDFromValue(const PyC_StringEnumItems *items, const int value)
int PyC_ParseBool(PyObject *o, void *p)
#define PyTuple_SET_ITEMS(op_arg,...)
static int blend(const Tex *tex, const float texvec[3], TexResult *texres)