17 #include "../generic/py_capi_utils.h"
18 #include "../generic/python_utildefines.h"
70 pygpu_state_blend_set_doc,
71 ".. function:: blend_set(mode)\n"
73 " Defines the fixed pipeline blending equation.\n"
75 " :param mode: The type of blend mode.\n"
76 " * ``NONE`` No blending.\n"
77 " * ``ALPHA`` The original color channels are interpolated according to the alpha "
79 " * ``ALPHA_PREMULT`` The original color channels are interpolated according to the "
80 "alpha value with the new colors pre-multiplied by this value.\n"
81 " * ``ADDITIVE`` The original color channels are added by the corresponding ones.\n"
82 " * ``ADDITIVE_PREMULT`` The original color channels are added by the corresponding ones "
83 "that are pre-multiplied by the alpha value.\n"
84 " * ``MULTIPLY`` The original color channels are multiplied by the corresponding ones.\n"
85 " * ``SUBTRACT`` The original color channels are subtracted by the corresponding ones.\n"
86 " * ``INVERT`` The original color channels are replaced by its complementary color.\n"
90 " :type mode: str\n");
102 ".. function:: blend_get()\n"
104 " Current blending equation.\n"
113 ".. function:: clip_distances_set(distances_enabled)\n"
115 " Sets the number of `gl_ClipDistance` planes used for clip geometry.\n"
117 " :param distances_enabled: Number of clip distances enabled.\n"
118 " :type distances_enabled: int\n");
121 int distances_enabled = (int)PyLong_AsUnsignedLong(value);
122 if (distances_enabled == -1) {
126 if (distances_enabled > 6) {
127 PyErr_SetString(PyExc_ValueError,
"too many distances enabled, max is 6");
135 ".. function:: depth_test_set(mode)\n"
137 " Defines the depth_test equation.\n"
139 " :param mode: The depth test equation name.\n"
140 " Possible values are `NONE`, `ALWAYS`, `LESS`, `LESS_EQUAL`, `EQUAL`, "
141 "`GREATER` and `GREATER_EQUAL`.\n"
142 " :type mode: str\n");
154 ".. function:: depth_test_get()\n"
156 " Current depth_test equation.\n"
165 ".. function:: depth_mask_set(value)\n"
167 " Write to depth component.\n"
169 " :param value: True for writing to the depth component.\n"
170 " :type near: bool\n");
182 ".. function:: depth_mask_get()\n"
184 " Writing status in the depth component.\n");
191 ".. function:: viewport_set(x, y, xsize, ysize)\n"
193 " Specifies the viewport of the active framebuffer.\n"
194 " Note: The viewport state is not saved upon framebuffer rebind.\n"
196 " :param x, y: lower left corner of the viewport_set rectangle, in pixels.\n"
197 " :param width, height: width and height of the viewport_set.\n"
198 " :type x, y, xsize, ysize: int\n");
201 int x,
y, xsize, ysize;
202 if (!PyArg_ParseTuple(args,
"iiii:viewport_set", &
x, &
y, &xsize, &ysize)) {
211 ".. function:: viewport_get()\n"
213 " Viewport of the active framebuffer.\n");
219 PyObject *
ret = PyTuple_New(4);
221 PyLong_FromLong(viewport[0]),
222 PyLong_FromLong(viewport[1]),
223 PyLong_FromLong(viewport[2]),
224 PyLong_FromLong(viewport[3]));
229 ".. function:: line_width_set(width)\n"
231 " Specify the width of rasterized lines.\n"
233 " :param size: New width.\n"
234 " :type mode: float\n");
238 if (PyErr_Occurred()) {
247 ".. function:: line_width_get()\n"
249 " Current width of rasterized lines.\n");
253 return PyFloat_FromDouble((
double)
width);
257 ".. function:: point_size_set(size)\n"
259 " Specify the diameter of rasterized points.\n"
261 " :param size: New diameter.\n"
262 " :type mode: float\n");
265 float size = (
float)PyFloat_AsDouble(value);
266 if (PyErr_Occurred()) {
275 ".. function:: color_mask_set(r, g, b, a)\n"
277 " Enable or disable writing of frame buffer color components.\n"
279 " :param r, g, b, a: components red, green, blue, and alpha.\n"
280 " :type r, g, b, a: bool\n");
284 if (!PyArg_ParseTuple(args,
"pppp:color_mask_set", &
r, &
g, &
b, &
a)) {
293 ".. function:: face_culling_set(culling)\n"
295 " Specify whether none, front-facing or back-facing facets can be culled.\n"
297 " :param mode: `NONE`, `FRONT` or `BACK`.\n"
298 " :type mode: str\n");
311 ".. function:: front_facing_set(invert)\n"
313 " Specifies the orientation of front-facing polygons.\n"
315 " :param invert: True for clockwise polygons as front-facing.\n"
316 " :type mode: bool\n");
329 ".. function:: program_point_size_set(enable)\n"
331 " If enabled, the derived point size is taken from the (potentially clipped) "
332 "shader builtin gl_PointSize.\n"
334 " :param enable: True for shader builtin gl_PointSize.\n"
335 " :type enable: bool\n");
348 ".. function:: framebuffer_active_get(enable)\n"
350 " Return the active frame-buffer in context.\n");
367 {
"clip_distances_set",
370 pygpu_state_clip_distances_set_doc},
374 pygpu_state_depth_test_set_doc},
378 pygpu_state_depth_test_get_doc},
382 pygpu_state_depth_mask_set_doc},
386 pygpu_state_depth_mask_get_doc},
390 pygpu_state_viewport_set_doc},
394 pygpu_state_viewport_get_doc},
398 pygpu_state_line_width_set_doc},
402 pygpu_state_line_width_get_doc},
406 pygpu_state_point_size_set_doc},
410 pygpu_state_color_mask_set_doc},
414 pygpu_state_face_culling_set_doc},
418 pygpu_state_front_facing_set_doc},
419 {
"program_point_size_set",
422 pygpu_state_program_point_size_set_doc},
423 {
"active_framebuffer_get",
426 pygpu_state_framebuffer_active_get_doc},
430 PyDoc_STRVAR(pygpu_state__tp_doc,
"This module provides access to the gpu state.");
432 PyModuleDef_HEAD_INIT,
433 .m_name =
"gpu.state",
434 .m_doc = pygpu_state__tp_doc,
typedef float(TangentPoint)[2]
struct GPUFrameBuffer GPUFrameBuffer
GPUFrameBuffer * GPU_framebuffer_active_get(void)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
void GPU_program_point_size(bool enable)
void GPU_face_culling(eGPUFaceCullTest culling)
@ GPU_BLEND_ADDITIVE_PREMULT
@ GPU_BLEND_ALPHA_PREMULT
void GPU_blend(eGPUBlend blend)
void GPU_line_width(float width)
float GPU_line_width_get(void)
void GPU_depth_mask(bool depth)
void GPU_color_mask(bool r, bool g, bool b, bool a)
void GPU_viewport_size_get_i(int coords[4])
eGPUBlend GPU_blend_get(void)
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_DEPTH_GREATER_EQUAL
eGPUDepthTest GPU_depth_test_get(void)
void GPU_depth_test(eGPUDepthTest test)
void GPU_clip_distances(int distances_enabled)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
PyObject * BPyGPUFrameBuffer_CreatePyObject(GPUFrameBuffer *fb, bool shared_reference)
static PyObject * pygpu_state_depth_mask_set(PyObject *UNUSED(self), PyObject *value)
static const struct PyC_StringEnumItems pygpu_state_faceculling_items[]
static PyObject * pygpu_state_viewport_set(PyObject *UNUSED(self), PyObject *args)
static PyObject * pygpu_state_blend_set(PyObject *UNUSED(self), PyObject *value)
static const struct PyC_StringEnumItems pygpu_state_depthtest_items[]
static PyObject * pygpu_state_front_facing_set(PyObject *UNUSED(self), PyObject *value)
static PyObject * pygpu_state_blend_get(PyObject *UNUSED(self))
static PyObject * pygpu_state_depth_mask_get(PyObject *UNUSED(self))
static PyObject * pygpu_state_depth_test_set(PyObject *UNUSED(self), PyObject *value)
PyDoc_STRVAR(pygpu_state_blend_set_doc, ".. function:: blend_set(mode)\n" "\n" " Defines the fixed pipeline blending equation.\n" "\n" " :param mode: The type of blend mode.\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_point_size_set(PyObject *UNUSED(self), PyObject *value)
static PyObject * pygpu_state_face_culling_set(PyObject *UNUSED(self), PyObject *value)
static PyObject * pygpu_state_program_point_size_set(PyObject *UNUSED(self), PyObject *value)
static PyObject * pygpu_state_framebuffer_active_get(PyObject *UNUSED(self))
static PyObject * pygpu_state_line_width_get(PyObject *UNUSED(self))
static PyObject * pygpu_state_viewport_get(PyObject *UNUSED(self), PyObject *UNUSED(args))
static struct PyMethodDef pygpu_state__tp_methods[]
static PyObject * pygpu_state_clip_distances_set(PyObject *UNUSED(self), PyObject *value)
static PyObject * pygpu_state_line_width_set(PyObject *UNUSED(self), PyObject *value)
static PyObject * pygpu_state_color_mask_set(PyObject *UNUSED(self), PyObject *args)
static PyModuleDef pygpu_state_module_def
static PyObject * pygpu_state_depth_test_get(PyObject *UNUSED(self))
PyObject * bpygpu_state_init(void)
static const struct PyC_StringEnumItems pygpu_state_blend_items[]
BLI_INLINE float fb(float length, float L)
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
int PyC_ParseStringEnum(PyObject *o, void *p)
const char * PyC_StringEnum_FindIDFromValue(const struct 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)