Blender  V3.3
gpu_py_batch.c File Reference
#include <Python.h>
#include "BLI_utildefines.h"
#include "GPU_batch.h"
#include "../generic/py_capi_utils.h"
#include "gpu_py.h"
#include "gpu_py_element.h"
#include "gpu_py_shader.h"
#include "gpu_py_vertex_buffer.h"
#include "gpu_py_batch.h"

Go to the source code of this file.

Functions

Utility Functions
static bool pygpu_batch_is_program_or_error (BPyGPUBatch *self)
 
Public API
PyObject * BPyGPUBatch_CreatePyObject (GPUBatch *batch)
 

GPUBatch Type

static struct PyMethodDef pygpu_batch__tp_methods []
 
PyTypeObject BPyGPUBatch_Type
 
static PyObject * pygpu_batch__tp_new (PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
 
 PyDoc_STRVAR (pygpu_batch_vertbuf_add_doc, ".. method:: vertbuf_add(buf)\n" "\n" " Add another vertex buffer to the Batch.\n" " It is not possible to add more vertices to the batch using this method.\n" " Instead it can be used to add more attributes to the existing vertices.\n" " A good use case would be when you have a separate\n" " vertex buffer for vertex positions and vertex normals.\n" " Current a batch can have at most " STRINGIFY(GPU_BATCH_VBO_MAX_LEN) " vertex buffers.\n" "\n" " :param buf: The vertex buffer that will be added to the batch.\n" " :type buf: :class:`gpu.types.GPUVertBuf`\n")
 
static PyObject * pygpu_batch_vertbuf_add (BPyGPUBatch *self, BPyGPUVertBuf *py_buf)
 
 PyDoc_STRVAR (pygpu_batch_program_set_doc, ".. method:: program_set(program)\n" "\n" " Assign a shader to this batch that will be used for drawing when not overwritten later.\n" " Note: This method has to be called in the draw context that the batch will be drawn in.\n" " This function does not need to be called when you always\n" " set the shader when calling :meth:`gpu.types.GPUBatch.draw`.\n" "\n" " :param program: The program/shader the batch will use in future draw calls.\n" " :type program: :class:`gpu.types.GPUShader`\n")
 
static PyObject * pygpu_batch_program_set (BPyGPUBatch *self, BPyGPUShader *py_shader)
 
 PyDoc_STRVAR (pygpu_batch_draw_doc, ".. method:: draw(program=None)\n" "\n" " Run the drawing program with the parameters assigned to the batch.\n" "\n" " :param program: Program that performs the drawing operations.\n" " If ``None`` is passed, the last program set to this batch will run.\n" " :type program: :class:`gpu.types.GPUShader`\n")
 
static PyObject * pygpu_batch_draw (BPyGPUBatch *self, PyObject *args)
 
static PyObject * pygpu_batch_program_use_begin (BPyGPUBatch *self)
 
static PyObject * pygpu_batch_program_use_end (BPyGPUBatch *self)
 
static int pygpu_batch__tp_traverse (BPyGPUBatch *self, visitproc visit, void *arg)
 
static int pygpu_batch__tp_clear (BPyGPUBatch *self)
 
static void pygpu_batch__tp_dealloc (BPyGPUBatch *self)
 
 PyDoc_STRVAR (pygpu_batch__tp_doc, ".. class:: GPUBatch(type, buf, elem=None)\n" "\n" " Reusable container for drawable geometry.\n" "\n" " :arg type: The primitive type of geometry to be drawn.\n" " Possible values are `POINTS`, `LINES`, `TRIS`, `LINE_STRIP`, `LINE_LOOP`, `TRI_STRIP`, " "`TRI_FAN`, `LINES_ADJ`, `TRIS_ADJ` and `LINE_STRIP_ADJ`.\n" " :type type: str\n" " :arg buf: Vertex buffer containing all or some of the attributes required for drawing.\n" " :type buf: :class:`gpu.types.GPUVertBuf`\n" " :arg elem: An optional index buffer.\n" " :type elem: :class:`gpu.types.GPUIndexBuf`\n")
 

Detailed Description

This file defines the off-screen functionalities of the 'gpu' module used for off-screen OpenGL rendering.

Definition in file gpu_py_batch.c.

Function Documentation

◆ BPyGPUBatch_CreatePyObject()

PyObject* BPyGPUBatch_CreatePyObject ( GPUBatch batch)

Definition at line 329 of file gpu_py_batch.c.

References batch, BPyGPUBatch_Type, NULL, and BPyGPUBatch::references.

Referenced by pygpu_batch__tp_new().

◆ PyDoc_STRVAR() [1/4]

PyDoc_STRVAR ( pygpu_batch__tp_doc  ,
".. class:: GPUBatch(type, buf, elem=None)\n" "\n" " Reusable container for drawable geometry.\n" "\n" " :arg type: The primitive type of geometry to be drawn.\n" " Possible values are `POINTS`  ,
`LINES`  ,
`TRIS`  ,
`LINE_STRIP`  ,
`LINE_LOOP`  ,
`TRI_STRIP`  ,
" "`TRI_FAN`  ,
`LINES_ADJ`  ,
`TRIS_ADJ` and `LINE_STRIP_ADJ`.\n" " :type type:str\n" " :arg buf:Vertex buffer containing all or some of the attributes required for drawing.\n" " :type buf::class:`gpu.types.GPUVertBuf`\n" " :arg elem:An optional index buffer.\n" " :type elem::class:`gpu.types.GPUIndexBuf`\n"   
)

◆ PyDoc_STRVAR() [2/4]

PyDoc_STRVAR ( pygpu_batch_draw_doc  ,
".. method:: draw(program=None)\n" "\n" " Run the drawing program with the parameters assigned to the batch.\n" "\n" " :param program: Program that performs the drawing operations.\n" " If ``None`` is  passed,
the last program set to this batch will run.\n" " :type program::class:`gpu.types.GPUShader`\n"   
)

◆ PyDoc_STRVAR() [3/4]

PyDoc_STRVAR ( pygpu_batch_program_set_doc  ,
".. method:: program_set(program)\n" "\n" " Assign a shader to this batch that will be used for drawing when not overwritten later.\n" " Note: This method has to be called in the draw context that the batch will be drawn in.\n" " This function does not need to be called when you always\n" " set the shader when calling :meth:`gpu.types.GPUBatch.draw`.\n" "\n" " :param program: The program/shader the batch will use in future draw calls.\n" " :type program: :class:`gpu.types.GPUShader`\n"   
)

◆ PyDoc_STRVAR() [4/4]

PyDoc_STRVAR ( pygpu_batch_vertbuf_add_doc  ,
".. method:: vertbuf_add(buf)\n" "\n" " Add another vertex buffer to the Batch.\n" " It is not possible to add more vertices to the batch using this method.\n" " Instead it can be used to add more attributes to the existing vertices.\n" " A good use case would be when you have a separate\n" " vertex buffer for vertex positions and vertex normals.\n" " Current a batch can have at most " STRINGIFY(GPU_BATCH_VBO_MAX_LEN) " vertex buffers.\n" "\n" " :param buf: The vertex buffer that will be added to the batch.\n" " :type buf: :class:`gpu.types.GPUVertBuf`\n"   
)

◆ pygpu_batch__tp_clear()

static int pygpu_batch__tp_clear ( BPyGPUBatch self)
static

Definition at line 270 of file gpu_py_batch.c.

References self.

Referenced by pygpu_batch__tp_dealloc().

◆ pygpu_batch__tp_dealloc()

static void pygpu_batch__tp_dealloc ( BPyGPUBatch self)
static

Definition at line 278 of file gpu_py_batch.c.

References GPU_batch_discard(), pygpu_batch__tp_clear(), and self.

◆ pygpu_batch__tp_new()

static PyObject* pygpu_batch__tp_new ( PyTypeObject *  UNUSEDtype,
PyObject *  args,
PyObject *  kwds 
)
static

◆ pygpu_batch__tp_traverse()

static int pygpu_batch__tp_traverse ( BPyGPUBatch self,
visitproc  visit,
void arg 
)
static

Definition at line 264 of file gpu_py_batch.c.

References self.

◆ pygpu_batch_draw()

static PyObject* pygpu_batch_draw ( BPyGPUBatch self,
PyObject *  args 
)
static

◆ pygpu_batch_is_program_or_error()

static bool pygpu_batch_is_program_or_error ( BPyGPUBatch self)
static

Definition at line 33 of file gpu_py_batch.c.

References self.

Referenced by pygpu_batch_draw(), and pygpu_batch_program_use_begin().

◆ pygpu_batch_program_set()

static PyObject* pygpu_batch_program_set ( BPyGPUBatch self,
BPyGPUShader py_shader 
)
static

◆ pygpu_batch_program_use_begin()

static PyObject* pygpu_batch_program_use_begin ( BPyGPUBatch self)
static

Definition at line 235 of file gpu_py_batch.c.

References GPU_shader_bind(), NULL, pygpu_batch_is_program_or_error(), and self.

◆ pygpu_batch_program_use_end()

static PyObject* pygpu_batch_program_use_end ( BPyGPUBatch self)
static

Definition at line 244 of file gpu_py_batch.c.

◆ pygpu_batch_vertbuf_add()

static PyObject* pygpu_batch_vertbuf_add ( BPyGPUBatch self,
BPyGPUVertBuf py_buf 
)
static

Variable Documentation

◆ BPyGPUBatch_Type

PyTypeObject BPyGPUBatch_Type
Initial value:
= {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUBatch",
.tp_basicsize = sizeof(BPyGPUBatch),
.tp_dealloc = (destructor)pygpu_batch__tp_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
.tp_doc = pygpu_batch__tp_doc,
.tp_traverse = (traverseproc)pygpu_batch__tp_traverse,
.tp_clear = (inquiry)pygpu_batch__tp_clear,
.tp_methods = pygpu_batch__tp_methods,
}
static PyObject * pygpu_batch__tp_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
Definition: gpu_py_batch.c:48
static int pygpu_batch__tp_clear(BPyGPUBatch *self)
Definition: gpu_py_batch.c:270
static int pygpu_batch__tp_traverse(BPyGPUBatch *self, visitproc visit, void *arg)
Definition: gpu_py_batch.c:264
static void pygpu_batch__tp_dealloc(BPyGPUBatch *self)
Definition: gpu_py_batch.c:278
static struct PyMethodDef pygpu_batch__tp_methods[]
Definition: gpu_py_batch.c:253
struct BPyGPUBatch BPyGPUBatch

Definition at line 307 of file gpu_py_batch.c.

Referenced by bpygpu_types_init(), and BPyGPUBatch_CreatePyObject().

◆ pygpu_batch__tp_methods

struct PyMethodDef pygpu_batch__tp_methods[]
static
Initial value:
= {
{"vertbuf_add", (PyCFunction)pygpu_batch_vertbuf_add, METH_O, pygpu_batch_vertbuf_add_doc},
{"program_set", (PyCFunction)pygpu_batch_program_set, METH_O, pygpu_batch_program_set_doc},
{"draw", (PyCFunction)pygpu_batch_draw, METH_VARARGS, pygpu_batch_draw_doc},
{"_program_use_begin", (PyCFunction)pygpu_batch_program_use_begin, METH_NOARGS, ""},
{"_program_use_end", (PyCFunction)pygpu_batch_program_use_end, METH_NOARGS, ""},
{NULL, NULL, 0, NULL},
}
static PyObject * pygpu_batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_shader)
Definition: gpu_py_batch.c:176
static PyObject * pygpu_batch_draw(BPyGPUBatch *self, PyObject *args)
Definition: gpu_py_batch.c:215
static PyObject * pygpu_batch_program_use_begin(BPyGPUBatch *self)
Definition: gpu_py_batch.c:235
static PyObject * pygpu_batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_buf)
Definition: gpu_py_batch.c:133
static PyObject * pygpu_batch_program_use_end(BPyGPUBatch *self)
Definition: gpu_py_batch.c:244

Definition at line 244 of file gpu_py_batch.c.