Blender  V3.3
gpu_py_state.c File Reference
#include <Python.h>
#include "GPU_framebuffer.h"
#include "GPU_state.h"
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
#include "gpu_py_framebuffer.h"
#include "gpu_py_state.h"

Go to the source code of this file.

Functions

Manage Stack
 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_blend_set (PyObject *UNUSED(self), PyObject *value)
 
 PyDoc_STRVAR (pygpu_state_blend_get_doc, ".. function:: blend_get()\n" "\n" " Current blending equation.\n" "\n")
 
static PyObject * pygpu_state_blend_get (PyObject *UNUSED(self))
 
 PyDoc_STRVAR (pygpu_state_clip_distances_set_doc, ".. function:: clip_distances_set(distances_enabled)\n" "\n" " Sets the number of `gl_ClipDistance` planes used for clip geometry.\n" "\n" " :param distances_enabled: Number of clip distances enabled.\n" " :type distances_enabled: int\n")
 
static PyObject * pygpu_state_clip_distances_set (PyObject *UNUSED(self), PyObject *value)
 
 PyDoc_STRVAR (pygpu_state_depth_test_set_doc, ".. function:: depth_test_set(mode)\n" "\n" " Defines the depth_test equation.\n" "\n" " :param mode: The depth test equation name.\n" " Possible values are `NONE`, `ALWAYS`, `LESS`, `LESS_EQUAL`, `EQUAL`, " "`GREATER` and `GREATER_EQUAL`.\n" " :type mode: str\n")
 
static PyObject * pygpu_state_depth_test_set (PyObject *UNUSED(self), PyObject *value)
 
 PyDoc_STRVAR (pygpu_state_depth_test_get_doc, ".. function:: depth_test_get()\n" "\n" " Current depth_test equation.\n" "\n")
 
static PyObject * pygpu_state_depth_test_get (PyObject *UNUSED(self))
 
 PyDoc_STRVAR (pygpu_state_depth_mask_set_doc, ".. function:: depth_mask_set(value)\n" "\n" " Write to depth component.\n" "\n" " :param value: True for writing to the depth component.\n" " :type near: bool\n")
 
static PyObject * pygpu_state_depth_mask_set (PyObject *UNUSED(self), PyObject *value)
 
 PyDoc_STRVAR (pygpu_state_depth_mask_get_doc, ".. function:: depth_mask_get()\n" "\n" " Writing status in the depth component.\n")
 
static PyObject * pygpu_state_depth_mask_get (PyObject *UNUSED(self))
 
 PyDoc_STRVAR (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" " :param 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, xsize, ysize: int\n")
 
static PyObject * pygpu_state_viewport_set (PyObject *UNUSED(self), PyObject *args)
 
 PyDoc_STRVAR (pygpu_state_viewport_get_doc, ".. function:: viewport_get()\n" "\n" " Viewport of the active framebuffer.\n")
 
static PyObject * pygpu_state_viewport_get (PyObject *UNUSED(self), PyObject *UNUSED(args))
 
 PyDoc_STRVAR (pygpu_state_line_width_set_doc, ".. function:: line_width_set(width)\n" "\n" " Specify the width of rasterized lines.\n" "\n" " :param size: New width.\n" " :type mode: float\n")
 
static PyObject * pygpu_state_line_width_set (PyObject *UNUSED(self), PyObject *value)
 
 PyDoc_STRVAR (pygpu_state_line_width_get_doc, ".. function:: line_width_get()\n" "\n" " Current width of rasterized lines.\n")
 
static PyObject * pygpu_state_line_width_get (PyObject *UNUSED(self))
 
 PyDoc_STRVAR (pygpu_state_point_size_set_doc, ".. function:: point_size_set(size)\n" "\n" " Specify the diameter of rasterized points.\n" "\n" " :param size: New diameter.\n" " :type mode: float\n")
 
static PyObject * pygpu_state_point_size_set (PyObject *UNUSED(self), PyObject *value)
 
 PyDoc_STRVAR (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" " :param r, g, b, a: components red, green, blue, and alpha.\n" " :type r, g, b, a: bool\n")
 
static PyObject * pygpu_state_color_mask_set (PyObject *UNUSED(self), PyObject *args)
 
 PyDoc_STRVAR (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" " :param mode: `NONE`, `FRONT` or `BACK`.\n" " :type mode: str\n")
 
static PyObject * pygpu_state_face_culling_set (PyObject *UNUSED(self), PyObject *value)
 
 PyDoc_STRVAR (pygpu_state_front_facing_set_doc, ".. function:: front_facing_set(invert)\n" "\n" " Specifies the orientation of front-facing polygons.\n" "\n" " :param invert: True for clockwise polygons as front-facing.\n" " :type mode: bool\n")
 
static PyObject * pygpu_state_front_facing_set (PyObject *UNUSED(self), PyObject *value)
 
 PyDoc_STRVAR (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" " :param enable: True for shader builtin gl_PointSize.\n" " :type enable: bool\n")
 
static PyObject * pygpu_state_program_point_size_set (PyObject *UNUSED(self), PyObject *value)
 
 PyDoc_STRVAR (pygpu_state_framebuffer_active_get_doc, ".. function:: framebuffer_active_get(enable)\n" "\n" " Return the active frame-buffer in context.\n")
 
static PyObject * pygpu_state_framebuffer_active_get (PyObject *UNUSED(self))
 

Variables

Helper Functions
static const struct PyC_StringEnumItems pygpu_state_blend_items []
 
static const struct PyC_StringEnumItems pygpu_state_depthtest_items []
 
static const struct PyC_StringEnumItems pygpu_state_faceculling_items []
 

Module

static struct PyMethodDef pygpu_state__tp_methods []
 
static PyModuleDef pygpu_state_module_def
 
 PyDoc_STRVAR (pygpu_state__tp_doc, "This module provides access to the gpu state.")
 
PyObject * bpygpu_state_init (void)
 

Detailed Description

This file defines the gpu.state API.

Definition in file gpu_py_state.c.

Function Documentation

◆ bpygpu_state_init()

PyObject* bpygpu_state_init ( void  )

Definition at line 438 of file gpu_py_state.c.

References pygpu_state_module_def.

Referenced by BPyInit_gpu().

◆ PyDoc_STRVAR() [1/18]

PyDoc_STRVAR ( pygpu_state__tp_doc  ,
"This module provides access to the gpu state."   
)

◆ PyDoc_STRVAR() [2/18]

PyDoc_STRVAR ( pygpu_state_blend_get_doc  ,
".. function:: blend_get()\n" "\n" " Current blending equation.\n" "\n"   
)

◆ PyDoc_STRVAR() [3/18]

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"   
)

◆ PyDoc_STRVAR() [4/18]

PyDoc_STRVAR ( pygpu_state_clip_distances_set_doc  ,
".. function:: clip_distances_set(distances_enabled)\n" "\n" " Sets the number of `gl_ClipDistance` planes used for clip geometry.\n" "\n" " :param distances_enabled: Number of clip distances enabled.\n" " :type distances_enabled: int\n"   
)

◆ PyDoc_STRVAR() [5/18]

PyDoc_STRVAR ( 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" " :param  r,
,
,
a:components  red,
green  ,
blue  ,
and alpha.\n" " :type  r,
,
,
a:bool\n"   
)

◆ PyDoc_STRVAR() [6/18]

PyDoc_STRVAR ( pygpu_state_depth_mask_get_doc  ,
".. function:: depth_mask_get()\n" "\n" " Writing status in the depth component.\n"   
)

◆ PyDoc_STRVAR() [7/18]

PyDoc_STRVAR ( pygpu_state_depth_mask_set_doc  ,
".. function:: depth_mask_set(value)\n" "\n" " Write to depth component.\n" "\n" " :param value: True for writing to the depth component.\n" " :type near: bool\n"   
)

◆ PyDoc_STRVAR() [8/18]

PyDoc_STRVAR ( pygpu_state_depth_test_get_doc  ,
".. function:: depth_test_get()\n" "\n" " Current depth_test equation.\n" "\n"   
)

◆ PyDoc_STRVAR() [9/18]

PyDoc_STRVAR ( pygpu_state_depth_test_set_doc  ,
".. function:: depth_test_set(mode)\n" "\n" " Defines the depth_test equation.\n" "\n" " :param mode: The depth test equation name.\n" " Possible values are `NONE`  ,
`ALWAYS`  ,
`LESS`  ,
`LESS_EQUAL`  ,
`EQUAL`  ,
" "`GREATER` and `GREATER_EQUAL`.\n" " :type mode:str\n"   
)

◆ PyDoc_STRVAR() [10/18]

PyDoc_STRVAR ( 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" " :param mode:`NONE`  ,
`FRONT` or `BACK`.\n" " :type mode:str\n"   
)

◆ PyDoc_STRVAR() [11/18]

PyDoc_STRVAR ( pygpu_state_framebuffer_active_get_doc  ,
".. function:: framebuffer_active_get(enable)\n" "\n" " Return the active frame-buffer in context.\n"   
)

◆ PyDoc_STRVAR() [12/18]

PyDoc_STRVAR ( pygpu_state_front_facing_set_doc  ,
".. function:: front_facing_set(invert)\n" "\n" " Specifies the orientation of front-facing polygons.\n" "\n" " :param invert: True for clockwise polygons as front-facing.\n" " :type mode: bool\n"   
)

◆ PyDoc_STRVAR() [13/18]

PyDoc_STRVAR ( pygpu_state_line_width_get_doc  ,
".. function:: line_width_get()\n" "\n" " Current width of rasterized lines.\n"   
)

◆ PyDoc_STRVAR() [14/18]

PyDoc_STRVAR ( pygpu_state_line_width_set_doc  ,
".. function:: line_width_set(width)\n" "\n" " Specify the width of rasterized lines.\n" "\n" " :param size: New width.\n" " :type mode: float\n"   
)

◆ PyDoc_STRVAR() [15/18]

PyDoc_STRVAR ( pygpu_state_point_size_set_doc  ,
".. function:: point_size_set(size)\n" "\n" " Specify the diameter of rasterized points.\n" "\n" " :param size: New diameter.\n" " :type mode: float\n"   
)

◆ PyDoc_STRVAR() [16/18]

PyDoc_STRVAR ( 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" " :param enable:True for shader builtin gl_PointSize.\n" " :type enable:bool\n"   
)

◆ PyDoc_STRVAR() [17/18]

PyDoc_STRVAR ( pygpu_state_viewport_get_doc  ,
".. function:: viewport_get()\n" "\n" " Viewport of the active framebuffer.\n"   
)

◆ PyDoc_STRVAR() [18/18]

PyDoc_STRVAR ( 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" " :param  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  ,
xsize  ,
ysize:int\n"   
)

◆ pygpu_state_blend_get()

static PyObject* pygpu_state_blend_get ( PyObject *  UNUSEDself)
static

◆ pygpu_state_blend_set()

static PyObject* pygpu_state_blend_set ( PyObject *  UNUSEDself,
PyObject *  value 
)
static

◆ pygpu_state_clip_distances_set()

static PyObject* pygpu_state_clip_distances_set ( PyObject *  UNUSEDself,
PyObject *  value 
)
static

Definition at line 119 of file gpu_py_state.c.

References GPU_clip_distances(), and NULL.

◆ pygpu_state_color_mask_set()

static PyObject* pygpu_state_color_mask_set ( PyObject *  UNUSEDself,
PyObject *  args 
)
static

Definition at line 281 of file gpu_py_state.c.

References Freestyle::a, usdtokens::b(), usdtokens::g(), GPU_color_mask(), NULL, and r.

◆ pygpu_state_depth_mask_get()

static PyObject* pygpu_state_depth_mask_get ( PyObject *  UNUSEDself)
static

Definition at line 185 of file gpu_py_state.c.

References GPU_depth_mask_get().

◆ pygpu_state_depth_mask_set()

static PyObject* pygpu_state_depth_mask_set ( PyObject *  UNUSEDself,
PyObject *  value 
)
static

Definition at line 171 of file gpu_py_state.c.

References GPU_depth_mask(), NULL, and PyC_ParseBool().

◆ pygpu_state_depth_test_get()

static PyObject* pygpu_state_depth_test_get ( PyObject *  UNUSEDself)
static

◆ pygpu_state_depth_test_set()

static PyObject* pygpu_state_depth_test_set ( PyObject *  UNUSEDself,
PyObject *  value 
)
static

◆ pygpu_state_face_culling_set()

static PyObject* pygpu_state_face_culling_set ( PyObject *  UNUSEDself,
PyObject *  value 
)
static

◆ pygpu_state_framebuffer_active_get()

static PyObject* pygpu_state_framebuffer_active_get ( PyObject *  UNUSEDself)
static

Definition at line 351 of file gpu_py_state.c.

◆ pygpu_state_front_facing_set()

static PyObject* pygpu_state_front_facing_set ( PyObject *  UNUSEDself,
PyObject *  value 
)
static

Definition at line 317 of file gpu_py_state.c.

References GPU_front_facing(), invert(), NULL, and PyC_ParseBool().

◆ pygpu_state_line_width_get()

static PyObject* pygpu_state_line_width_get ( PyObject *  UNUSEDself)
static

Definition at line 250 of file gpu_py_state.c.

References GPU_line_width_get(), and width.

◆ pygpu_state_line_width_set()

static PyObject* pygpu_state_line_width_set ( PyObject *  UNUSEDself,
PyObject *  value 
)
static

Definition at line 235 of file gpu_py_state.c.

References float(), GPU_line_width(), NULL, and width.

◆ pygpu_state_point_size_set()

static PyObject* pygpu_state_point_size_set ( PyObject *  UNUSEDself,
PyObject *  value 
)
static

Definition at line 263 of file gpu_py_state.c.

References float(), GPU_point_size(), NULL, and size().

◆ pygpu_state_program_point_size_set()

static PyObject* pygpu_state_program_point_size_set ( PyObject *  UNUSEDself,
PyObject *  value 
)
static

Definition at line 336 of file gpu_py_state.c.

References GPU_program_point_size(), NULL, and PyC_ParseBool().

◆ pygpu_state_viewport_get()

static PyObject* pygpu_state_viewport_get ( PyObject *  UNUSEDself,
PyObject *  UNUSEDargs 
)
static

Definition at line 214 of file gpu_py_state.c.

References GPU_viewport_size_get_i(), PyTuple_SET_ITEMS, and ret.

◆ pygpu_state_viewport_set()

static PyObject* pygpu_state_viewport_set ( PyObject *  UNUSEDself,
PyObject *  args 
)
static

Definition at line 199 of file gpu_py_state.c.

References GPU_viewport(), NULL, x, and y.

Variable Documentation

◆ pygpu_state__tp_methods

struct PyMethodDef pygpu_state__tp_methods[]
static

Definition at line 351 of file gpu_py_state.c.

◆ pygpu_state_blend_items

const struct PyC_StringEnumItems pygpu_state_blend_items[]
static
Initial value:
= {
{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"},
{0, NULL},
}
@ GPU_BLEND_ADDITIVE_PREMULT
Definition: GPU_state.h:65
@ GPU_BLEND_INVERT
Definition: GPU_state.h:70
@ GPU_BLEND_MULTIPLY
Definition: GPU_state.h:66
@ GPU_BLEND_NONE
Definition: GPU_state.h:60
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:62
@ GPU_BLEND_ADDITIVE
Definition: GPU_state.h:64
@ GPU_BLEND_SUBTRACT
Definition: GPU_state.h:67
@ GPU_BLEND_ALPHA_PREMULT
Definition: GPU_state.h:63

Definition at line 1 of file gpu_py_state.c.

Referenced by pygpu_state_blend_get(), and pygpu_state_blend_set().

◆ pygpu_state_depthtest_items

const struct PyC_StringEnumItems pygpu_state_depthtest_items[]
static
Initial value:
= {
{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"},
{0, NULL},
}
@ GPU_DEPTH_GREATER
Definition: GPU_state.h:88
@ GPU_DEPTH_EQUAL
Definition: GPU_state.h:87
@ GPU_DEPTH_ALWAYS
Definition: GPU_state.h:84
@ GPU_DEPTH_GREATER_EQUAL
Definition: GPU_state.h:89
@ GPU_DEPTH_LESS
Definition: GPU_state.h:85
@ GPU_DEPTH_LESS_EQUAL
Definition: GPU_state.h:86
@ GPU_DEPTH_NONE
Definition: GPU_state.h:83

Definition at line 1 of file gpu_py_state.c.

Referenced by pygpu_state_depth_test_get(), and pygpu_state_depth_test_set().

◆ pygpu_state_faceculling_items

const struct PyC_StringEnumItems pygpu_state_faceculling_items[]
static
Initial value:
= {
{GPU_CULL_NONE, "NONE"},
{GPU_CULL_FRONT, "FRONT"},
{GPU_CULL_BACK, "BACK"},
{0, NULL},
}
@ GPU_CULL_FRONT
Definition: GPU_state.h:109
@ GPU_CULL_NONE
Definition: GPU_state.h:108
@ GPU_CULL_BACK
Definition: GPU_state.h:110

Definition at line 1 of file gpu_py_state.c.

Referenced by pygpu_state_face_culling_set().

◆ pygpu_state_module_def

PyModuleDef pygpu_state_module_def
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
.m_name = "gpu.state",
.m_doc = pygpu_state__tp_doc,
}
static struct PyMethodDef pygpu_state__tp_methods[]
Definition: gpu_py_state.c:363

Definition at line 431 of file gpu_py_state.c.

Referenced by bpygpu_state_init().