Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/gpu/gpu_py_state.c
| Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
| * \{ */ | * \{ */ | ||||
| PyDoc_STRVAR( | PyDoc_STRVAR( | ||||
| pygpu_state_blend_set_doc, | pygpu_state_blend_set_doc, | ||||
| ".. function:: blend_set(mode)\n" | ".. function:: blend_set(mode)\n" | ||||
| "\n" | "\n" | ||||
| " Defines the fixed pipeline blending equation.\n" | " Defines the fixed pipeline blending equation.\n" | ||||
| "\n" | "\n" | ||||
| " :param mode: The type of blend mode.\n" | " :arg mode: The type of blend mode.\n" | ||||
| " * ``NONE`` No blending.\n" | " * ``NONE`` No blending.\n" | ||||
| " * ``ALPHA`` The original color channels are interpolated according to the alpha " | " * ``ALPHA`` The original color channels are interpolated according to the alpha " | ||||
| "value.\n" | "value.\n" | ||||
| " * ``ALPHA_PREMULT`` The original color channels are interpolated according to the " | " * ``ALPHA_PREMULT`` The original color channels are interpolated according to the " | ||||
| "alpha value with the new colors pre-multiplied by this value.\n" | "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`` The original color channels are added by the corresponding ones.\n" | ||||
| " * ``ADDITIVE_PREMULT`` The original color channels are added by the corresponding ones " | " * ``ADDITIVE_PREMULT`` The original color channels are added by the corresponding ones " | ||||
| "that are pre-multiplied by the alpha value.\n" | "that are pre-multiplied by the alpha value.\n" | ||||
| Show All 25 Lines | static PyObject *pygpu_state_blend_get(PyObject *UNUSED(self)) | ||||
| return PyUnicode_FromString(PyC_StringEnum_FindIDFromValue(pygpu_state_blend_items, blend)); | return PyUnicode_FromString(PyC_StringEnum_FindIDFromValue(pygpu_state_blend_items, blend)); | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_state_clip_distances_set_doc, | PyDoc_STRVAR(pygpu_state_clip_distances_set_doc, | ||||
| ".. function:: clip_distances_set(distances_enabled)\n" | ".. function:: clip_distances_set(distances_enabled)\n" | ||||
| "\n" | "\n" | ||||
| " Sets the number of `gl_ClipDistance` planes used for clip geometry.\n" | " Sets the number of `gl_ClipDistance` planes used for clip geometry.\n" | ||||
| "\n" | "\n" | ||||
| " :param distances_enabled: Number of clip distances enabled.\n" | " :arg distances_enabled: Number of clip distances enabled.\n" | ||||
| " :type distances_enabled: int\n"); | " :type distances_enabled: int\n"); | ||||
| static PyObject *pygpu_state_clip_distances_set(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_state_clip_distances_set(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| int distances_enabled = (int)PyLong_AsUnsignedLong(value); | int distances_enabled = (int)PyLong_AsUnsignedLong(value); | ||||
| if (distances_enabled == -1) { | if (distances_enabled == -1) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (distances_enabled > 6) { | if (distances_enabled > 6) { | ||||
| PyErr_SetString(PyExc_ValueError, "too many distances enabled, max is 6"); | PyErr_SetString(PyExc_ValueError, "too many distances enabled, max is 6"); | ||||
| } | } | ||||
| GPU_clip_distances(distances_enabled); | GPU_clip_distances(distances_enabled); | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_state_depth_test_set_doc, | PyDoc_STRVAR(pygpu_state_depth_test_set_doc, | ||||
| ".. function:: depth_test_set(mode)\n" | ".. function:: depth_test_set(mode)\n" | ||||
| "\n" | "\n" | ||||
| " Defines the depth_test equation.\n" | " Defines the depth_test equation.\n" | ||||
| "\n" | "\n" | ||||
| " :param mode: The depth test equation name.\n" | " :arg mode: The depth test equation name.\n" | ||||
| " Possible values are `NONE`, `ALWAYS`, `LESS`, `LESS_EQUAL`, `EQUAL`, " | " Possible values are `NONE`, `ALWAYS`, `LESS`, `LESS_EQUAL`, `EQUAL`, " | ||||
| "`GREATER` and `GREATER_EQUAL`.\n" | "`GREATER` and `GREATER_EQUAL`.\n" | ||||
| " :type mode: str\n"); | " :type mode: str\n"); | ||||
| static PyObject *pygpu_state_depth_test_set(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_state_depth_test_set(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| struct PyC_StringEnum pygpu_depth_test = {pygpu_state_depthtest_items}; | struct PyC_StringEnum pygpu_depth_test = {pygpu_state_depthtest_items}; | ||||
| if (!PyC_ParseStringEnum(value, &pygpu_depth_test)) { | if (!PyC_ParseStringEnum(value, &pygpu_depth_test)) { | ||||
| return NULL; | return NULL; | ||||
| Show All 13 Lines | static PyObject *pygpu_state_depth_test_get(PyObject *UNUSED(self)) | ||||
| return PyUnicode_FromString(PyC_StringEnum_FindIDFromValue(pygpu_state_depthtest_items, test)); | return PyUnicode_FromString(PyC_StringEnum_FindIDFromValue(pygpu_state_depthtest_items, test)); | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_state_depth_mask_set_doc, | PyDoc_STRVAR(pygpu_state_depth_mask_set_doc, | ||||
| ".. function:: depth_mask_set(value)\n" | ".. function:: depth_mask_set(value)\n" | ||||
| "\n" | "\n" | ||||
| " Write to depth component.\n" | " Write to depth component.\n" | ||||
| "\n" | "\n" | ||||
| " :param value: True for writing to the depth component.\n" | " :arg value: True for writing to the depth component.\n" | ||||
| " :type near: bool\n"); | " :type near: bool\n"); | ||||
| static PyObject *pygpu_state_depth_mask_set(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_state_depth_mask_set(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| bool write_to_depth; | bool write_to_depth; | ||||
| if (!PyC_ParseBool(value, &write_to_depth)) { | if (!PyC_ParseBool(value, &write_to_depth)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GPU_depth_mask(write_to_depth); | GPU_depth_mask(write_to_depth); | ||||
| Show All 10 Lines | |||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_state_viewport_set_doc, | PyDoc_STRVAR(pygpu_state_viewport_set_doc, | ||||
| ".. function:: viewport_set(x, y, xsize, ysize)\n" | ".. function:: viewport_set(x, y, xsize, ysize)\n" | ||||
| "\n" | "\n" | ||||
| " Specifies the viewport of the active framebuffer.\n" | " Specifies the viewport of the active framebuffer.\n" | ||||
| " Note: The viewport state is not saved upon framebuffer rebind.\n" | " Note: The viewport state is not saved upon framebuffer rebind.\n" | ||||
| "\n" | "\n" | ||||
| " :param x, y: lower left corner of the viewport_set rectangle, in pixels.\n" | " :arg x, y: lower left corner of the viewport_set rectangle, in pixels.\n" | ||||
| " :param width, height: width and height of the viewport_set.\n" | " :type x, y: int\n" | ||||
| " :type x, y, xsize, ysize: int\n"); | " :arg xsize, ysize: width and height of the viewport_set.\n" | ||||
| " :type xsize, ysize: int\n"); | |||||
| static PyObject *pygpu_state_viewport_set(PyObject *UNUSED(self), PyObject *args) | static PyObject *pygpu_state_viewport_set(PyObject *UNUSED(self), PyObject *args) | ||||
| { | { | ||||
| int x, y, xsize, ysize; | int x, y, xsize, ysize; | ||||
| if (!PyArg_ParseTuple(args, "iiii:viewport_set", &x, &y, &xsize, &ysize)) { | if (!PyArg_ParseTuple(args, "iiii:viewport_set", &x, &y, &xsize, &ysize)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GPU_viewport(x, y, xsize, ysize); | GPU_viewport(x, y, xsize, ysize); | ||||
| Show All 18 Lines | static PyObject *pygpu_state_viewport_get(PyObject *UNUSED(self), PyObject *UNUSED(args)) | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_state_line_width_set_doc, | PyDoc_STRVAR(pygpu_state_line_width_set_doc, | ||||
| ".. function:: line_width_set(width)\n" | ".. function:: line_width_set(width)\n" | ||||
| "\n" | "\n" | ||||
| " Specify the width of rasterized lines.\n" | " Specify the width of rasterized lines.\n" | ||||
| "\n" | "\n" | ||||
| " :param size: New width.\n" | " :arg size: New width.\n" | ||||
| " :type mode: float\n"); | " :type mode: float\n"); | ||||
| static PyObject *pygpu_state_line_width_set(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_state_line_width_set(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| float width = (float)PyFloat_AsDouble(value); | float width = (float)PyFloat_AsDouble(value); | ||||
| if (PyErr_Occurred()) { | if (PyErr_Occurred()) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| Show All 11 Lines | static PyObject *pygpu_state_line_width_get(PyObject *UNUSED(self)) | ||||
| return PyFloat_FromDouble((double)width); | return PyFloat_FromDouble((double)width); | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_state_point_size_set_doc, | PyDoc_STRVAR(pygpu_state_point_size_set_doc, | ||||
| ".. function:: point_size_set(size)\n" | ".. function:: point_size_set(size)\n" | ||||
| "\n" | "\n" | ||||
| " Specify the diameter of rasterized points.\n" | " Specify the diameter of rasterized points.\n" | ||||
| "\n" | "\n" | ||||
| " :param size: New diameter.\n" | " :arg size: New diameter.\n" | ||||
| " :type mode: float\n"); | " :type mode: float\n"); | ||||
| static PyObject *pygpu_state_point_size_set(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_state_point_size_set(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| float size = (float)PyFloat_AsDouble(value); | float size = (float)PyFloat_AsDouble(value); | ||||
| if (PyErr_Occurred()) { | if (PyErr_Occurred()) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GPU_point_size(size); | GPU_point_size(size); | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_state_color_mask_set_doc, | PyDoc_STRVAR(pygpu_state_color_mask_set_doc, | ||||
| ".. function:: color_mask_set(r, g, b, a)\n" | ".. function:: color_mask_set(r, g, b, a)\n" | ||||
| "\n" | "\n" | ||||
| " Enable or disable writing of frame buffer color components.\n" | " Enable or disable writing of frame buffer color components.\n" | ||||
| "\n" | "\n" | ||||
| " :param r, g, b, a: components red, green, blue, and alpha.\n" | " :arg r, g, b, a: components red, green, blue, and alpha.\n" | ||||
| " :type r, g, b, a: bool\n"); | " :type r, g, b, a: bool\n"); | ||||
| static PyObject *pygpu_state_color_mask_set(PyObject *UNUSED(self), PyObject *args) | static PyObject *pygpu_state_color_mask_set(PyObject *UNUSED(self), PyObject *args) | ||||
| { | { | ||||
| int r, g, b, a; | int r, g, b, a; | ||||
| if (!PyArg_ParseTuple(args, "pppp:color_mask_set", &r, &g, &b, &a)) { | if (!PyArg_ParseTuple(args, "pppp:color_mask_set", &r, &g, &b, &a)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GPU_color_mask((bool)r, (bool)g, (bool)b, (bool)a); | GPU_color_mask((bool)r, (bool)g, (bool)b, (bool)a); | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_state_face_culling_set_doc, | PyDoc_STRVAR(pygpu_state_face_culling_set_doc, | ||||
| ".. function:: face_culling_set(culling)\n" | ".. function:: face_culling_set(culling)\n" | ||||
| "\n" | "\n" | ||||
| " Specify whether none, front-facing or back-facing facets can be culled.\n" | " Specify whether none, front-facing or back-facing facets can be culled.\n" | ||||
| "\n" | "\n" | ||||
| " :param mode: `NONE`, `FRONT` or `BACK`.\n" | " :arg mode: `NONE`, `FRONT` or `BACK`.\n" | ||||
| " :type mode: str\n"); | " :type mode: str\n"); | ||||
| static PyObject *pygpu_state_face_culling_set(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_state_face_culling_set(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| struct PyC_StringEnum pygpu_faceculling = {pygpu_state_faceculling_items}; | struct PyC_StringEnum pygpu_faceculling = {pygpu_state_faceculling_items}; | ||||
| if (!PyC_ParseStringEnum(value, &pygpu_faceculling)) { | if (!PyC_ParseStringEnum(value, &pygpu_faceculling)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GPU_face_culling(pygpu_faceculling.value_found); | GPU_face_culling(pygpu_faceculling.value_found); | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_state_front_facing_set_doc, | PyDoc_STRVAR(pygpu_state_front_facing_set_doc, | ||||
| ".. function:: front_facing_set(invert)\n" | ".. function:: front_facing_set(invert)\n" | ||||
| "\n" | "\n" | ||||
| " Specifies the orientation of front-facing polygons.\n" | " Specifies the orientation of front-facing polygons.\n" | ||||
| "\n" | "\n" | ||||
| " :param invert: True for clockwise polygons as front-facing.\n" | " :arg invert: True for clockwise polygons as front-facing.\n" | ||||
| " :type mode: bool\n"); | " :type mode: bool\n"); | ||||
| static PyObject *pygpu_state_front_facing_set(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_state_front_facing_set(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| bool invert; | bool invert; | ||||
| if (!PyC_ParseBool(value, &invert)) { | if (!PyC_ParseBool(value, &invert)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GPU_front_facing(invert); | GPU_front_facing(invert); | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_state_program_point_size_set_doc, | PyDoc_STRVAR(pygpu_state_program_point_size_set_doc, | ||||
| ".. function:: program_point_size_set(enable)\n" | ".. function:: program_point_size_set(enable)\n" | ||||
| "\n" | "\n" | ||||
| " If enabled, the derived point size is taken from the (potentially clipped) " | " If enabled, the derived point size is taken from the (potentially clipped) " | ||||
| "shader builtin gl_PointSize.\n" | "shader builtin gl_PointSize.\n" | ||||
| "\n" | "\n" | ||||
| " :param enable: True for shader builtin gl_PointSize.\n" | " :arg enable: True for shader builtin gl_PointSize.\n" | ||||
| " :type enable: bool\n"); | " :type enable: bool\n"); | ||||
| static PyObject *pygpu_state_program_point_size_set(PyObject *UNUSED(self), PyObject *value) | static PyObject *pygpu_state_program_point_size_set(PyObject *UNUSED(self), PyObject *value) | ||||
| { | { | ||||
| bool enable; | bool enable; | ||||
| if (!PyC_ParseBool(value, &enable)) { | if (!PyC_ParseBool(value, &enable)) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines | |||||