Cleanup: Python GPU: change prefix 'bpygpu_' to 'py_' in static functions

This commit is contained in:
2020-12-11 16:05:58 -03:00
parent cada56b1f7
commit bbd7f94d8a
8 changed files with 283 additions and 311 deletions

View File

@@ -48,7 +48,7 @@
/** \name Utility Functions /** \name Utility Functions
* \{ */ * \{ */
static bool bpygpu_batch_is_program_or_error(BPyGPUBatch *self) static bool py_batch_is_program_or_error(BPyGPUBatch *self)
{ {
if (!self->batch->shader) { if (!self->batch->shader) {
PyErr_SetString(PyExc_RuntimeError, "batch does not have any program assigned to it"); PyErr_SetString(PyExc_RuntimeError, "batch does not have any program assigned to it");
@@ -63,7 +63,7 @@ static bool bpygpu_batch_is_program_or_error(BPyGPUBatch *self)
/** \name GPUBatch Type /** \name GPUBatch Type
* \{ */ * \{ */
static PyObject *bpygpu_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) static PyObject *py_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{ {
BPYGPU_IS_INIT_OR_ERROR_OBJ; BPYGPU_IS_INIT_OR_ERROR_OBJ;
@@ -121,7 +121,7 @@ static PyObject *bpygpu_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, Py
return (PyObject *)ret; return (PyObject *)ret;
} }
PyDoc_STRVAR(bpygpu_Batch_vertbuf_add_doc, PyDoc_STRVAR(py_Batch_vertbuf_add_doc,
".. method:: vertbuf_add(buf)\n" ".. method:: vertbuf_add(buf)\n"
"\n" "\n"
" Add another vertex buffer to the Batch.\n" " Add another vertex buffer to the Batch.\n"
@@ -134,7 +134,7 @@ PyDoc_STRVAR(bpygpu_Batch_vertbuf_add_doc,
" :param buf: The vertex buffer that will be added to the batch.\n" " :param buf: The vertex buffer that will be added to the batch.\n"
" :type buf: :class:`gpu.types.GPUVertBuf`\n" " :type buf: :class:`gpu.types.GPUVertBuf`\n"
); );
static PyObject *bpygpu_Batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_buf) static PyObject *py_Batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_buf)
{ {
if (!BPyGPUVertBuf_Check(py_buf)) { if (!BPyGPUVertBuf_Check(py_buf)) {
PyErr_Format(PyExc_TypeError, "Expected a GPUVertBuf, got %s", Py_TYPE(py_buf)->tp_name); PyErr_Format(PyExc_TypeError, "Expected a GPUVertBuf, got %s", Py_TYPE(py_buf)->tp_name);
@@ -167,7 +167,7 @@ static PyObject *bpygpu_Batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_b
} }
PyDoc_STRVAR( PyDoc_STRVAR(
bpygpu_Batch_program_set_doc, py_Batch_program_set_doc,
".. method:: program_set(program)\n" ".. method:: program_set(program)\n"
"\n" "\n"
" Assign a shader to this batch that will be used for drawing when not overwritten later.\n" " Assign a shader to this batch that will be used for drawing when not overwritten later.\n"
@@ -177,7 +177,7 @@ PyDoc_STRVAR(
"\n" "\n"
" :param program: The program/shader the batch will use in future draw calls.\n" " :param program: The program/shader the batch will use in future draw calls.\n"
" :type program: :class:`gpu.types.GPUShader`\n"); " :type program: :class:`gpu.types.GPUShader`\n");
static PyObject *bpygpu_Batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_shader) static PyObject *py_Batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_shader)
{ {
if (!BPyGPUShader_Check(py_shader)) { if (!BPyGPUShader_Check(py_shader)) {
PyErr_Format(PyExc_TypeError, "Expected a GPUShader, got %s", Py_TYPE(py_shader)->tp_name); PyErr_Format(PyExc_TypeError, "Expected a GPUShader, got %s", Py_TYPE(py_shader)->tp_name);
@@ -208,7 +208,7 @@ static PyObject *bpygpu_Batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_sh
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_Batch_draw_doc, PyDoc_STRVAR(py_Batch_draw_doc,
".. method:: draw(program=None)\n" ".. method:: draw(program=None)\n"
"\n" "\n"
" Run the drawing program with the parameters assigned to the batch.\n" " Run the drawing program with the parameters assigned to the batch.\n"
@@ -216,7 +216,7 @@ PyDoc_STRVAR(bpygpu_Batch_draw_doc,
" :param program: Program that performs the drawing operations.\n" " :param program: Program that performs the drawing operations.\n"
" If ``None`` is passed, the last program set to this batch will run.\n" " If ``None`` is passed, the last program set to this batch will run.\n"
" :type program: :class:`gpu.types.GPUShader`\n"); " :type program: :class:`gpu.types.GPUShader`\n");
static PyObject *bpygpu_Batch_draw(BPyGPUBatch *self, PyObject *args) static PyObject *py_Batch_draw(BPyGPUBatch *self, PyObject *args)
{ {
BPyGPUShader *py_program = NULL; BPyGPUShader *py_program = NULL;
@@ -224,7 +224,7 @@ static PyObject *bpygpu_Batch_draw(BPyGPUBatch *self, PyObject *args)
return NULL; return NULL;
} }
if (py_program == NULL) { if (py_program == NULL) {
if (!bpygpu_batch_is_program_or_error(self)) { if (!py_batch_is_program_or_error(self)) {
return NULL; return NULL;
} }
} }
@@ -236,42 +236,42 @@ static PyObject *bpygpu_Batch_draw(BPyGPUBatch *self, PyObject *args)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static PyObject *bpygpu_Batch_program_use_begin(BPyGPUBatch *self) static PyObject *py_Batch_program_use_begin(BPyGPUBatch *self)
{ {
if (!bpygpu_batch_is_program_or_error(self)) { if (!py_batch_is_program_or_error(self)) {
return NULL; return NULL;
} }
GPU_shader_bind(self->batch->shader); GPU_shader_bind(self->batch->shader);
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static PyObject *bpygpu_Batch_program_use_end(BPyGPUBatch *self) static PyObject *py_Batch_program_use_end(BPyGPUBatch *self)
{ {
if (!bpygpu_batch_is_program_or_error(self)) { if (!py_batch_is_program_or_error(self)) {
return NULL; return NULL;
} }
GPU_shader_unbind(); GPU_shader_unbind();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static struct PyMethodDef bpygpu_Batch_methods[] = { static struct PyMethodDef py_Batch_methods[] = {
{"vertbuf_add", (PyCFunction)bpygpu_Batch_vertbuf_add, METH_O, bpygpu_Batch_vertbuf_add_doc}, {"vertbuf_add", (PyCFunction)py_Batch_vertbuf_add, METH_O, py_Batch_vertbuf_add_doc},
{"program_set", (PyCFunction)bpygpu_Batch_program_set, METH_O, bpygpu_Batch_program_set_doc}, {"program_set", (PyCFunction)py_Batch_program_set, METH_O, py_Batch_program_set_doc},
{"draw", (PyCFunction)bpygpu_Batch_draw, METH_VARARGS, bpygpu_Batch_draw_doc}, {"draw", (PyCFunction)py_Batch_draw, METH_VARARGS, py_Batch_draw_doc},
{"_program_use_begin", (PyCFunction)bpygpu_Batch_program_use_begin, METH_NOARGS, ""}, {"_program_use_begin", (PyCFunction)py_Batch_program_use_begin, METH_NOARGS, ""},
{"_program_use_end", (PyCFunction)bpygpu_Batch_program_use_end, METH_NOARGS, ""}, {"_program_use_end", (PyCFunction)py_Batch_program_use_end, METH_NOARGS, ""},
{NULL, NULL, 0, NULL}, {NULL, NULL, 0, NULL},
}; };
#ifdef USE_GPU_PY_REFERENCES #ifdef USE_GPU_PY_REFERENCES
static int bpygpu_Batch_traverse(BPyGPUBatch *self, visitproc visit, void *arg) static int py_Batch_traverse(BPyGPUBatch *self, visitproc visit, void *arg)
{ {
Py_VISIT(self->references); Py_VISIT(self->references);
return 0; return 0;
} }
static int bpygpu_Batch_clear(BPyGPUBatch *self) static int py_Batch_clear(BPyGPUBatch *self)
{ {
Py_CLEAR(self->references); Py_CLEAR(self->references);
return 0; return 0;
@@ -279,14 +279,14 @@ static int bpygpu_Batch_clear(BPyGPUBatch *self)
#endif #endif
static void bpygpu_Batch_dealloc(BPyGPUBatch *self) static void py_Batch_dealloc(BPyGPUBatch *self)
{ {
GPU_batch_discard(self->batch); GPU_batch_discard(self->batch);
#ifdef USE_GPU_PY_REFERENCES #ifdef USE_GPU_PY_REFERENCES
if (self->references) { if (self->references) {
PyObject_GC_UnTrack(self); PyObject_GC_UnTrack(self);
bpygpu_Batch_clear(self); py_Batch_clear(self);
Py_XDECREF(self->references); Py_XDECREF(self->references);
} }
#endif #endif
@@ -319,17 +319,17 @@ PyDoc_STRVAR(
PyTypeObject BPyGPUBatch_Type = { PyTypeObject BPyGPUBatch_Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUBatch", PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUBatch",
.tp_basicsize = sizeof(BPyGPUBatch), .tp_basicsize = sizeof(BPyGPUBatch),
.tp_dealloc = (destructor)bpygpu_Batch_dealloc, .tp_dealloc = (destructor)py_Batch_dealloc,
#ifdef USE_GPU_PY_REFERENCES #ifdef USE_GPU_PY_REFERENCES
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
.tp_doc = py_gpu_batch_doc, .tp_doc = py_gpu_batch_doc,
.tp_traverse = (traverseproc)bpygpu_Batch_traverse, .tp_traverse = (traverseproc)py_Batch_traverse,
.tp_clear = (inquiry)bpygpu_Batch_clear, .tp_clear = (inquiry)py_Batch_clear,
#else #else
.tp_flags = Py_TPFLAGS_DEFAULT, .tp_flags = Py_TPFLAGS_DEFAULT,
#endif #endif
.tp_methods = bpygpu_Batch_methods, .tp_methods = py_Batch_methods,
.tp_new = bpygpu_Batch_new, .tp_new = py_Batch_new,
}; };
/** \} */ /** \} */

View File

@@ -39,7 +39,7 @@
/** \name IndexBuf Type /** \name IndexBuf Type
* \{ */ * \{ */
static PyObject *bpygpu_IndexBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) static PyObject *py_IndexBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{ {
BPYGPU_IS_INIT_OR_ERROR_OBJ; BPYGPU_IS_INIT_OR_ERROR_OBJ;
@@ -175,7 +175,7 @@ static PyObject *bpygpu_IndexBuf_new(PyTypeObject *UNUSED(type), PyObject *args,
return BPyGPUIndexBuf_CreatePyObject(GPU_indexbuf_build(&builder)); return BPyGPUIndexBuf_CreatePyObject(GPU_indexbuf_build(&builder));
} }
static void bpygpu_IndexBuf_dealloc(BPyGPUIndexBuf *self) static void py_IndexBuf_dealloc(BPyGPUIndexBuf *self)
{ {
GPU_indexbuf_discard(self->elem); GPU_indexbuf_discard(self->elem);
Py_TYPE(self)->tp_free(self); Py_TYPE(self)->tp_free(self);
@@ -199,10 +199,10 @@ PyDoc_STRVAR(py_gpu_element_doc,
PyTypeObject BPyGPUIndexBuf_Type = { PyTypeObject BPyGPUIndexBuf_Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUIndexBuf", PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUIndexBuf",
.tp_basicsize = sizeof(BPyGPUIndexBuf), .tp_basicsize = sizeof(BPyGPUIndexBuf),
.tp_dealloc = (destructor)bpygpu_IndexBuf_dealloc, .tp_dealloc = (destructor)py_IndexBuf_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT, .tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = py_gpu_element_doc, .tp_doc = py_gpu_element_doc,
.tp_new = bpygpu_IndexBuf_new, .tp_new = py_IndexBuf_new,
}; };
/** \} */ /** \} */

View File

@@ -44,7 +44,7 @@
/** \name Helper Functions /** \name Helper Functions
* \{ */ * \{ */
static bool bpygpu_stack_is_push_model_view_ok_or_error(void) static bool py_stack_is_push_model_view_ok_or_error(void)
{ {
if (GPU_matrix_stack_level_get_model_view() >= GPU_PY_MATRIX_STACK_LEN) { if (GPU_matrix_stack_level_get_model_view() >= GPU_PY_MATRIX_STACK_LEN) {
PyErr_SetString( PyErr_SetString(
@@ -55,7 +55,7 @@ static bool bpygpu_stack_is_push_model_view_ok_or_error(void)
return true; return true;
} }
static bool bpygpu_stack_is_push_projection_ok_or_error(void) static bool py_stack_is_push_projection_ok_or_error(void)
{ {
if (GPU_matrix_stack_level_get_projection() >= GPU_PY_MATRIX_STACK_LEN) { if (GPU_matrix_stack_level_get_projection() >= GPU_PY_MATRIX_STACK_LEN) {
PyErr_SetString( PyErr_SetString(
@@ -66,7 +66,7 @@ static bool bpygpu_stack_is_push_projection_ok_or_error(void)
return true; return true;
} }
static bool bpygpu_stack_is_pop_model_view_ok_or_error(void) static bool py_stack_is_pop_model_view_ok_or_error(void)
{ {
if (GPU_matrix_stack_level_get_model_view() == 0) { if (GPU_matrix_stack_level_get_model_view() == 0) {
PyErr_SetString(PyExc_RuntimeError, "Minimum model-view stack depth reached"); PyErr_SetString(PyExc_RuntimeError, "Minimum model-view stack depth reached");
@@ -75,7 +75,7 @@ static bool bpygpu_stack_is_pop_model_view_ok_or_error(void)
return true; return true;
} }
static bool bpygpu_stack_is_pop_projection_ok_or_error(void) static bool py_stack_is_pop_projection_ok_or_error(void)
{ {
if (GPU_matrix_stack_level_get_projection() == 0) { if (GPU_matrix_stack_level_get_projection() == 0) {
PyErr_SetString(PyExc_RuntimeError, "Minimum projection stack depth reached"); PyErr_SetString(PyExc_RuntimeError, "Minimum projection stack depth reached");
@@ -90,52 +90,52 @@ static bool bpygpu_stack_is_pop_projection_ok_or_error(void)
/** \name Manage Stack /** \name Manage Stack
* \{ */ * \{ */
PyDoc_STRVAR(bpygpu_matrix_push_doc, PyDoc_STRVAR(py_matrix_push_doc,
".. function:: push()\n" ".. function:: push()\n"
"\n" "\n"
" Add to the model-view matrix stack.\n"); " Add to the model-view matrix stack.\n");
static PyObject *bpygpu_matrix_push(PyObject *UNUSED(self)) static PyObject *py_matrix_push(PyObject *UNUSED(self))
{ {
if (!bpygpu_stack_is_push_model_view_ok_or_error()) { if (!py_stack_is_push_model_view_ok_or_error()) {
return NULL; return NULL;
} }
GPU_matrix_push(); GPU_matrix_push();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_matrix_pop_doc, PyDoc_STRVAR(py_matrix_pop_doc,
".. function:: pop()\n" ".. function:: pop()\n"
"\n" "\n"
" Remove the last model-view matrix from the stack.\n"); " Remove the last model-view matrix from the stack.\n");
static PyObject *bpygpu_matrix_pop(PyObject *UNUSED(self)) static PyObject *py_matrix_pop(PyObject *UNUSED(self))
{ {
if (!bpygpu_stack_is_pop_model_view_ok_or_error()) { if (!py_stack_is_pop_model_view_ok_or_error()) {
return NULL; return NULL;
} }
GPU_matrix_pop(); GPU_matrix_pop();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_matrix_push_projection_doc, PyDoc_STRVAR(py_matrix_push_projection_doc,
".. function:: push_projection()\n" ".. function:: push_projection()\n"
"\n" "\n"
" Add to the projection matrix stack.\n"); " Add to the projection matrix stack.\n");
static PyObject *bpygpu_matrix_push_projection(PyObject *UNUSED(self)) static PyObject *py_matrix_push_projection(PyObject *UNUSED(self))
{ {
if (!bpygpu_stack_is_push_projection_ok_or_error()) { if (!py_stack_is_push_projection_ok_or_error()) {
return NULL; return NULL;
} }
GPU_matrix_push_projection(); GPU_matrix_push_projection();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_matrix_pop_projection_doc, PyDoc_STRVAR(py_matrix_pop_projection_doc,
".. function:: pop_projection()\n" ".. function:: pop_projection()\n"
"\n" "\n"
" Remove the last projection matrix from the stack.\n"); " Remove the last projection matrix from the stack.\n");
static PyObject *bpygpu_matrix_pop_projection(PyObject *UNUSED(self)) static PyObject *py_matrix_pop_projection(PyObject *UNUSED(self))
{ {
if (!bpygpu_stack_is_pop_projection_ok_or_error()) { if (!py_stack_is_pop_projection_ok_or_error()) {
return NULL; return NULL;
} }
GPU_matrix_pop_projection(); GPU_matrix_pop_projection();
@@ -162,12 +162,12 @@ enum {
PYGPU_MATRIX_TYPE_PROJECTION = 2, PYGPU_MATRIX_TYPE_PROJECTION = 2,
}; };
static PyObject *bpygpu_matrix_stack_context_enter(BPyGPU_MatrixStackContext *self); static PyObject *py_matrix_stack_context_enter(BPyGPU_MatrixStackContext *self);
static PyObject *bpygpu_matrix_stack_context_exit(BPyGPU_MatrixStackContext *self, PyObject *args); static PyObject *py_matrix_stack_context_exit(BPyGPU_MatrixStackContext *self, PyObject *args);
static PyMethodDef bpygpu_matrix_stack_context_methods[] = { static PyMethodDef py_matrix_stack_context_methods[] = {
{"__enter__", (PyCFunction)bpygpu_matrix_stack_context_enter, METH_NOARGS}, {"__enter__", (PyCFunction)py_matrix_stack_context_enter, METH_NOARGS},
{"__exit__", (PyCFunction)bpygpu_matrix_stack_context_exit, METH_VARARGS}, {"__exit__", (PyCFunction)py_matrix_stack_context_exit, METH_VARARGS},
{NULL}, {NULL},
}; };
@@ -175,10 +175,10 @@ static PyTypeObject BPyGPU_matrix_stack_context_Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUMatrixStackContext", PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUMatrixStackContext",
.tp_basicsize = sizeof(BPyGPU_MatrixStackContext), .tp_basicsize = sizeof(BPyGPU_MatrixStackContext),
.tp_flags = Py_TPFLAGS_DEFAULT, .tp_flags = Py_TPFLAGS_DEFAULT,
.tp_methods = bpygpu_matrix_stack_context_methods, .tp_methods = py_matrix_stack_context_methods,
}; };
static PyObject *bpygpu_matrix_stack_context_enter(BPyGPU_MatrixStackContext *self) static PyObject *py_matrix_stack_context_enter(BPyGPU_MatrixStackContext *self)
{ {
/* sanity - should never happen */ /* sanity - should never happen */
if (self->level != -1) { if (self->level != -1) {
@@ -187,14 +187,14 @@ static PyObject *bpygpu_matrix_stack_context_enter(BPyGPU_MatrixStackContext *se
} }
if (self->type == PYGPU_MATRIX_TYPE_MODEL_VIEW) { if (self->type == PYGPU_MATRIX_TYPE_MODEL_VIEW) {
if (!bpygpu_stack_is_push_model_view_ok_or_error()) { if (!py_stack_is_push_model_view_ok_or_error()) {
return NULL; return NULL;
} }
GPU_matrix_push(); GPU_matrix_push();
self->level = GPU_matrix_stack_level_get_model_view(); self->level = GPU_matrix_stack_level_get_model_view();
} }
else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) { else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) {
if (!bpygpu_stack_is_push_projection_ok_or_error()) { if (!py_stack_is_push_projection_ok_or_error()) {
return NULL; return NULL;
} }
GPU_matrix_push_projection(); GPU_matrix_push_projection();
@@ -206,8 +206,8 @@ static PyObject *bpygpu_matrix_stack_context_enter(BPyGPU_MatrixStackContext *se
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static PyObject *bpygpu_matrix_stack_context_exit(BPyGPU_MatrixStackContext *self, static PyObject *py_matrix_stack_context_exit(BPyGPU_MatrixStackContext *self,
PyObject *UNUSED(args)) PyObject *UNUSED(args))
{ {
/* sanity - should never happen */ /* sanity - should never happen */
if (self->level == -1) { if (self->level == -1) {
@@ -240,7 +240,7 @@ finally:
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static PyObject *bpygpu_matrix_push_pop_impl(int type) static PyObject *py_matrix_push_pop_impl(int type)
{ {
BPyGPU_MatrixStackContext *ret = PyObject_New(BPyGPU_MatrixStackContext, BPyGPU_MatrixStackContext *ret = PyObject_New(BPyGPU_MatrixStackContext,
&BPyGPU_matrix_stack_context_Type); &BPyGPU_matrix_stack_context_Type);
@@ -250,23 +250,23 @@ static PyObject *bpygpu_matrix_push_pop_impl(int type)
} }
PyDoc_STRVAR( PyDoc_STRVAR(
bpygpu_matrix_push_pop_doc, py_matrix_push_pop_doc,
".. function:: push_pop()\n" ".. function:: push_pop()\n"
"\n" "\n"
" Context manager to ensure balanced push/pop calls, even in the case of an error.\n"); " Context manager to ensure balanced push/pop calls, even in the case of an error.\n");
static PyObject *bpygpu_matrix_push_pop(PyObject *UNUSED(self)) static PyObject *py_matrix_push_pop(PyObject *UNUSED(self))
{ {
return bpygpu_matrix_push_pop_impl(PYGPU_MATRIX_TYPE_MODEL_VIEW); return py_matrix_push_pop_impl(PYGPU_MATRIX_TYPE_MODEL_VIEW);
} }
PyDoc_STRVAR( PyDoc_STRVAR(
bpygpu_matrix_push_pop_projection_doc, py_matrix_push_pop_projection_doc,
".. function:: push_pop_projection()\n" ".. function:: push_pop_projection()\n"
"\n" "\n"
" Context manager to ensure balanced push/pop calls, even in the case of an error.\n"); " Context manager to ensure balanced push/pop calls, even in the case of an error.\n");
static PyObject *bpygpu_matrix_push_pop_projection(PyObject *UNUSED(self)) static PyObject *py_matrix_push_pop_projection(PyObject *UNUSED(self))
{ {
return bpygpu_matrix_push_pop_impl(PYGPU_MATRIX_TYPE_PROJECTION); return py_matrix_push_pop_impl(PYGPU_MATRIX_TYPE_PROJECTION);
} }
/** \} */ /** \} */
@@ -275,14 +275,14 @@ static PyObject *bpygpu_matrix_push_pop_projection(PyObject *UNUSED(self))
/** \name Manipulate State /** \name Manipulate State
* \{ */ * \{ */
PyDoc_STRVAR(bpygpu_matrix_multiply_matrix_doc, PyDoc_STRVAR(py_matrix_multiply_matrix_doc,
".. function:: multiply_matrix(matrix)\n" ".. function:: multiply_matrix(matrix)\n"
"\n" "\n"
" Multiply the current stack matrix.\n" " Multiply the current stack matrix.\n"
"\n" "\n"
" :param matrix: A 4x4 matrix.\n" " :param matrix: A 4x4 matrix.\n"
" :type matrix: :class:`mathutils.Matrix`\n"); " :type matrix: :class:`mathutils.Matrix`\n");
static PyObject *bpygpu_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject *value) static PyObject *py_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject *value)
{ {
MatrixObject *pymat; MatrixObject *pymat;
if (!Matrix_Parse4x4(value, &pymat)) { if (!Matrix_Parse4x4(value, &pymat)) {
@@ -292,14 +292,14 @@ static PyObject *bpygpu_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_matrix_scale_doc, PyDoc_STRVAR(py_matrix_scale_doc,
".. function:: scale(scale)\n" ".. function:: scale(scale)\n"
"\n" "\n"
" Scale the current stack matrix.\n" " Scale the current stack matrix.\n"
"\n" "\n"
" :param scale: Scale the current stack matrix.\n" " :param scale: Scale the current stack matrix.\n"
" :type scale: sequence of 2 or 3 floats\n"); " :type scale: sequence of 2 or 3 floats\n");
static PyObject *bpygpu_matrix_scale(PyObject *UNUSED(self), PyObject *value) static PyObject *py_matrix_scale(PyObject *UNUSED(self), PyObject *value)
{ {
float scale[3]; float scale[3];
int len; int len;
@@ -316,12 +316,12 @@ static PyObject *bpygpu_matrix_scale(PyObject *UNUSED(self), PyObject *value)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_matrix_scale_uniform_doc, PyDoc_STRVAR(py_matrix_scale_uniform_doc,
".. function:: scale_uniform(scale)\n" ".. function:: scale_uniform(scale)\n"
"\n" "\n"
" :param scale: Scale the current stack matrix.\n" " :param scale: Scale the current stack matrix.\n"
" :type scale: float\n"); " :type scale: float\n");
static PyObject *bpygpu_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *value) static PyObject *py_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *value)
{ {
float scalar; float scalar;
if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) { if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
@@ -332,14 +332,14 @@ static PyObject *bpygpu_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *v
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_matrix_translate_doc, PyDoc_STRVAR(py_matrix_translate_doc,
".. function:: translate(offset)\n" ".. function:: translate(offset)\n"
"\n" "\n"
" Scale the current stack matrix.\n" " Scale the current stack matrix.\n"
"\n" "\n"
" :param offset: Translate the current stack matrix.\n" " :param offset: Translate the current stack matrix.\n"
" :type offset: sequence of 2 or 3 floats\n"); " :type offset: sequence of 2 or 3 floats\n");
static PyObject *bpygpu_matrix_translate(PyObject *UNUSED(self), PyObject *value) static PyObject *py_matrix_translate(PyObject *UNUSED(self), PyObject *value)
{ {
float offset[3]; float offset[3];
int len; int len;
@@ -362,34 +362,34 @@ static PyObject *bpygpu_matrix_translate(PyObject *UNUSED(self), PyObject *value
/** \name Write State /** \name Write State
* \{ */ * \{ */
PyDoc_STRVAR(bpygpu_matrix_reset_doc, PyDoc_STRVAR(py_matrix_reset_doc,
".. function:: reset()\n" ".. function:: reset()\n"
"\n" "\n"
" Empty stack and set to identity.\n"); " Empty stack and set to identity.\n");
static PyObject *bpygpu_matrix_reset(PyObject *UNUSED(self)) static PyObject *py_matrix_reset(PyObject *UNUSED(self))
{ {
GPU_matrix_reset(); GPU_matrix_reset();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_matrix_load_identity_doc, PyDoc_STRVAR(py_matrix_load_identity_doc,
".. function:: load_identity()\n" ".. function:: load_identity()\n"
"\n" "\n"
" Empty stack and set to identity.\n"); " Empty stack and set to identity.\n");
static PyObject *bpygpu_matrix_load_identity(PyObject *UNUSED(self)) static PyObject *py_matrix_load_identity(PyObject *UNUSED(self))
{ {
GPU_matrix_identity_set(); GPU_matrix_identity_set();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_matrix_load_matrix_doc, PyDoc_STRVAR(py_matrix_load_matrix_doc,
".. function:: load_matrix(matrix)\n" ".. function:: load_matrix(matrix)\n"
"\n" "\n"
" Load a matrix into the stack.\n" " Load a matrix into the stack.\n"
"\n" "\n"
" :param matrix: A 4x4 matrix.\n" " :param matrix: A 4x4 matrix.\n"
" :type matrix: :class:`mathutils.Matrix`\n"); " :type matrix: :class:`mathutils.Matrix`\n");
static PyObject *bpygpu_matrix_load_matrix(PyObject *UNUSED(self), PyObject *value) static PyObject *py_matrix_load_matrix(PyObject *UNUSED(self), PyObject *value)
{ {
MatrixObject *pymat; MatrixObject *pymat;
if (!Matrix_Parse4x4(value, &pymat)) { if (!Matrix_Parse4x4(value, &pymat)) {
@@ -399,14 +399,14 @@ static PyObject *bpygpu_matrix_load_matrix(PyObject *UNUSED(self), PyObject *val
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_matrix_load_projection_matrix_doc, PyDoc_STRVAR(py_matrix_load_projection_matrix_doc,
".. function:: load_projection_matrix(matrix)\n" ".. function:: load_projection_matrix(matrix)\n"
"\n" "\n"
" Load a projection matrix into the stack.\n" " Load a projection matrix into the stack.\n"
"\n" "\n"
" :param matrix: A 4x4 matrix.\n" " :param matrix: A 4x4 matrix.\n"
" :type matrix: :class:`mathutils.Matrix`\n"); " :type matrix: :class:`mathutils.Matrix`\n");
static PyObject *bpygpu_matrix_load_projection_matrix(PyObject *UNUSED(self), PyObject *value) static PyObject *py_matrix_load_projection_matrix(PyObject *UNUSED(self), PyObject *value)
{ {
MatrixObject *pymat; MatrixObject *pymat;
if (!Matrix_Parse4x4(value, &pymat)) { if (!Matrix_Parse4x4(value, &pymat)) {
@@ -422,42 +422,42 @@ static PyObject *bpygpu_matrix_load_projection_matrix(PyObject *UNUSED(self), Py
/** \name Read State /** \name Read State
* \{ */ * \{ */
PyDoc_STRVAR(bpygpu_matrix_get_projection_matrix_doc, PyDoc_STRVAR(py_matrix_get_projection_matrix_doc,
".. function:: get_projection_matrix()\n" ".. function:: get_projection_matrix()\n"
"\n" "\n"
" Return a copy of the projection matrix.\n" " Return a copy of the projection matrix.\n"
"\n" "\n"
" :return: A 4x4 projection matrix.\n" " :return: A 4x4 projection matrix.\n"
" :rtype: :class:`mathutils.Matrix`\n"); " :rtype: :class:`mathutils.Matrix`\n");
static PyObject *bpygpu_matrix_get_projection_matrix(PyObject *UNUSED(self)) static PyObject *py_matrix_get_projection_matrix(PyObject *UNUSED(self))
{ {
float matrix[4][4]; float matrix[4][4];
GPU_matrix_projection_get(matrix); GPU_matrix_projection_get(matrix);
return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL); return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL);
} }
PyDoc_STRVAR(bpygpu_matrix_get_model_view_matrix_doc, PyDoc_STRVAR(py_matrix_get_model_view_matrix_doc,
".. function:: get_model_view_matrix()\n" ".. function:: get_model_view_matrix()\n"
"\n" "\n"
" Return a copy of the model-view matrix.\n" " Return a copy of the model-view matrix.\n"
"\n" "\n"
" :return: A 4x4 view matrix.\n" " :return: A 4x4 view matrix.\n"
" :rtype: :class:`mathutils.Matrix`\n"); " :rtype: :class:`mathutils.Matrix`\n");
static PyObject *bpygpu_matrix_get_model_view_matrix(PyObject *UNUSED(self)) static PyObject *py_matrix_get_model_view_matrix(PyObject *UNUSED(self))
{ {
float matrix[4][4]; float matrix[4][4];
GPU_matrix_model_view_get(matrix); GPU_matrix_model_view_get(matrix);
return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL); return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL);
} }
PyDoc_STRVAR(bpygpu_matrix_get_normal_matrix_doc, PyDoc_STRVAR(py_matrix_get_normal_matrix_doc,
".. function:: get_normal_matrix()\n" ".. function:: get_normal_matrix()\n"
"\n" "\n"
" Return a copy of the normal matrix.\n" " Return a copy of the normal matrix.\n"
"\n" "\n"
" :return: A 3x3 normal matrix.\n" " :return: A 3x3 normal matrix.\n"
" :rtype: :class:`mathutils.Matrix`\n"); " :rtype: :class:`mathutils.Matrix`\n");
static PyObject *bpygpu_matrix_get_normal_matrix(PyObject *UNUSED(self)) static PyObject *py_matrix_get_normal_matrix(PyObject *UNUSED(self))
{ {
float matrix[3][3]; float matrix[3][3];
GPU_matrix_normal_get(matrix); GPU_matrix_normal_get(matrix);
@@ -470,81 +470,78 @@ static PyObject *bpygpu_matrix_get_normal_matrix(PyObject *UNUSED(self))
/** \name Module /** \name Module
* \{ */ * \{ */
static struct PyMethodDef bpygpu_matrix_methods[] = { static struct PyMethodDef py_matrix_methods[] = {
/* Manage Stack */ /* Manage Stack */
{"push", (PyCFunction)bpygpu_matrix_push, METH_NOARGS, bpygpu_matrix_push_doc}, {"push", (PyCFunction)py_matrix_push, METH_NOARGS, py_matrix_push_doc},
{"pop", (PyCFunction)bpygpu_matrix_pop, METH_NOARGS, bpygpu_matrix_pop_doc}, {"pop", (PyCFunction)py_matrix_pop, METH_NOARGS, py_matrix_pop_doc},
{"push_projection", {"push_projection",
(PyCFunction)bpygpu_matrix_push_projection, (PyCFunction)py_matrix_push_projection,
METH_NOARGS, METH_NOARGS,
bpygpu_matrix_push_projection_doc}, py_matrix_push_projection_doc},
{"pop_projection", {"pop_projection",
(PyCFunction)bpygpu_matrix_pop_projection, (PyCFunction)py_matrix_pop_projection,
METH_NOARGS, METH_NOARGS,
bpygpu_matrix_pop_projection_doc}, py_matrix_pop_projection_doc},
/* Stack (Context Manager) */ /* Stack (Context Manager) */
{"push_pop", (PyCFunction)bpygpu_matrix_push_pop, METH_NOARGS, bpygpu_matrix_push_pop_doc}, {"push_pop", (PyCFunction)py_matrix_push_pop, METH_NOARGS, py_matrix_push_pop_doc},
{"push_pop_projection", {"push_pop_projection",
(PyCFunction)bpygpu_matrix_push_pop_projection, (PyCFunction)py_matrix_push_pop_projection,
METH_NOARGS, METH_NOARGS,
bpygpu_matrix_push_pop_projection_doc}, py_matrix_push_pop_projection_doc},
/* Manipulate State */ /* Manipulate State */
{"multiply_matrix", {"multiply_matrix",
(PyCFunction)bpygpu_matrix_multiply_matrix, (PyCFunction)py_matrix_multiply_matrix,
METH_O, METH_O,
bpygpu_matrix_multiply_matrix_doc}, py_matrix_multiply_matrix_doc},
{"scale", (PyCFunction)bpygpu_matrix_scale, METH_O, bpygpu_matrix_scale_doc}, {"scale", (PyCFunction)py_matrix_scale, METH_O, py_matrix_scale_doc},
{"scale_uniform", {"scale_uniform", (PyCFunction)py_matrix_scale_uniform, METH_O, py_matrix_scale_uniform_doc},
(PyCFunction)bpygpu_matrix_scale_uniform, {"translate", (PyCFunction)py_matrix_translate, METH_O, py_matrix_translate_doc},
METH_O,
bpygpu_matrix_scale_uniform_doc},
{"translate", (PyCFunction)bpygpu_matrix_translate, METH_O, bpygpu_matrix_translate_doc},
/* TODO */ /* TODO */
#if 0 #if 0
{"rotate", (PyCFunction)bpygpu_matrix_rotate, METH_O, bpygpu_matrix_rotate_doc}, {"rotate", (PyCFunction)py_matrix_rotate, METH_O, py_matrix_rotate_doc},
{"rotate_axis", (PyCFunction)bpygpu_matrix_rotate_axis, METH_O, bpygpu_matrix_rotate_axis_doc}, {"rotate_axis", (PyCFunction)py_matrix_rotate_axis, METH_O, py_matrix_rotate_axis_doc},
{"look_at", (PyCFunction)bpygpu_matrix_look_at, METH_O, bpygpu_matrix_look_at_doc}, {"look_at", (PyCFunction)py_matrix_look_at, METH_O, py_matrix_look_at_doc},
#endif #endif
/* Write State */ /* Write State */
{"reset", (PyCFunction)bpygpu_matrix_reset, METH_NOARGS, bpygpu_matrix_reset_doc}, {"reset", (PyCFunction)py_matrix_reset, METH_NOARGS, py_matrix_reset_doc},
{"load_identity", {"load_identity",
(PyCFunction)bpygpu_matrix_load_identity, (PyCFunction)py_matrix_load_identity,
METH_NOARGS, METH_NOARGS,
bpygpu_matrix_load_identity_doc}, py_matrix_load_identity_doc},
{"load_matrix", (PyCFunction)bpygpu_matrix_load_matrix, METH_O, bpygpu_matrix_load_matrix_doc}, {"load_matrix", (PyCFunction)py_matrix_load_matrix, METH_O, py_matrix_load_matrix_doc},
{"load_projection_matrix", {"load_projection_matrix",
(PyCFunction)bpygpu_matrix_load_projection_matrix, (PyCFunction)py_matrix_load_projection_matrix,
METH_O, METH_O,
bpygpu_matrix_load_projection_matrix_doc}, py_matrix_load_projection_matrix_doc},
/* Read State */ /* Read State */
{"get_projection_matrix", {"get_projection_matrix",
(PyCFunction)bpygpu_matrix_get_projection_matrix, (PyCFunction)py_matrix_get_projection_matrix,
METH_NOARGS, METH_NOARGS,
bpygpu_matrix_get_projection_matrix_doc}, py_matrix_get_projection_matrix_doc},
{"get_model_view_matrix", {"get_model_view_matrix",
(PyCFunction)bpygpu_matrix_get_model_view_matrix, (PyCFunction)py_matrix_get_model_view_matrix,
METH_NOARGS, METH_NOARGS,
bpygpu_matrix_get_model_view_matrix_doc}, py_matrix_get_model_view_matrix_doc},
{"get_normal_matrix", {"get_normal_matrix",
(PyCFunction)bpygpu_matrix_get_normal_matrix, (PyCFunction)py_matrix_get_normal_matrix,
METH_NOARGS, METH_NOARGS,
bpygpu_matrix_get_normal_matrix_doc}, py_matrix_get_normal_matrix_doc},
{NULL, NULL, 0, NULL}, {NULL, NULL, 0, NULL},
}; };
PyDoc_STRVAR(bpygpu_matrix_doc, "This module provides access to the matrix stack."); PyDoc_STRVAR(py_matrix_doc, "This module provides access to the matrix stack.");
static PyModuleDef BPyGPU_matrix_module_def = { static PyModuleDef BPyGPU_matrix_module_def = {
PyModuleDef_HEAD_INIT, PyModuleDef_HEAD_INIT,
.m_name = "gpu.matrix", .m_name = "gpu.matrix",
.m_doc = bpygpu_matrix_doc, .m_doc = py_matrix_doc,
.m_methods = bpygpu_matrix_methods, .m_methods = py_matrix_methods,
}; };
PyObject *BPyInit_gpu_matrix(void) PyObject *BPyInit_gpu_matrix(void)

View File

@@ -58,9 +58,9 @@
/** \name GPUOffScreen Common Utilities /** \name GPUOffScreen Common Utilities
* \{ */ * \{ */
static int bpygpu_offscreen_valid_check(BPyGPUOffScreen *bpygpu_ofs) static int py_offscreen_valid_check(BPyGPUOffScreen *py_ofs)
{ {
if (UNLIKELY(bpygpu_ofs->ofs == NULL)) { if (UNLIKELY(py_ofs->ofs == NULL)) {
PyErr_SetString(PyExc_ReferenceError, "GPU offscreen was freed, no further access is valid"); PyErr_SetString(PyExc_ReferenceError, "GPU offscreen was freed, no further access is valid");
return -1; return -1;
} }
@@ -69,7 +69,7 @@ static int bpygpu_offscreen_valid_check(BPyGPUOffScreen *bpygpu_ofs)
#define BPY_GPU_OFFSCREEN_CHECK_OBJ(bpygpu) \ #define BPY_GPU_OFFSCREEN_CHECK_OBJ(bpygpu) \
{ \ { \
if (UNLIKELY(bpygpu_offscreen_valid_check(bpygpu) == -1)) { \ if (UNLIKELY(py_offscreen_valid_check(bpygpu) == -1)) { \
return NULL; \ return NULL; \
} \ } \
} \ } \
@@ -81,7 +81,7 @@ static int bpygpu_offscreen_valid_check(BPyGPUOffScreen *bpygpu_ofs)
/** \name GPUOffscreen Type /** \name GPUOffscreen Type
* \{ */ * \{ */
static PyObject *bpygpu_offscreen_new(PyTypeObject *UNUSED(self), PyObject *args, PyObject *kwds) static PyObject *py_offscreen_new(PyTypeObject *UNUSED(self), PyObject *args, PyObject *kwds)
{ {
BPYGPU_IS_INIT_OR_ERROR_OBJ; BPYGPU_IS_INIT_OR_ERROR_OBJ;
@@ -112,23 +112,23 @@ static PyObject *bpygpu_offscreen_new(PyTypeObject *UNUSED(self), PyObject *args
return BPyGPUOffScreen_CreatePyObject(ofs); return BPyGPUOffScreen_CreatePyObject(ofs);
} }
PyDoc_STRVAR(bpygpu_offscreen_width_doc, "Width of the texture.\n\n:type: `int`"); PyDoc_STRVAR(py_offscreen_width_doc, "Width of the texture.\n\n:type: `int`");
static PyObject *bpygpu_offscreen_width_get(BPyGPUOffScreen *self, void *UNUSED(type)) static PyObject *py_offscreen_width_get(BPyGPUOffScreen *self, void *UNUSED(type))
{ {
BPY_GPU_OFFSCREEN_CHECK_OBJ(self); BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
return PyLong_FromLong(GPU_offscreen_width(self->ofs)); return PyLong_FromLong(GPU_offscreen_width(self->ofs));
} }
PyDoc_STRVAR(bpygpu_offscreen_height_doc, "Height of the texture.\n\n:type: `int`"); PyDoc_STRVAR(py_offscreen_height_doc, "Height of the texture.\n\n:type: `int`");
static PyObject *bpygpu_offscreen_height_get(BPyGPUOffScreen *self, void *UNUSED(type)) static PyObject *py_offscreen_height_get(BPyGPUOffScreen *self, void *UNUSED(type))
{ {
BPY_GPU_OFFSCREEN_CHECK_OBJ(self); BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
return PyLong_FromLong(GPU_offscreen_height(self->ofs)); return PyLong_FromLong(GPU_offscreen_height(self->ofs));
} }
PyDoc_STRVAR(bpygpu_offscreen_color_texture_doc, PyDoc_STRVAR(py_offscreen_color_texture_doc,
"OpenGL bindcode for the color texture.\n\n:type: `int`"); "OpenGL bindcode for the color texture.\n\n:type: `int`");
static PyObject *bpygpu_offscreen_color_texture_get(BPyGPUOffScreen *self, void *UNUSED(type)) static PyObject *py_offscreen_color_texture_get(BPyGPUOffScreen *self, void *UNUSED(type))
{ {
BPY_GPU_OFFSCREEN_CHECK_OBJ(self); BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
GPUTexture *texture = GPU_offscreen_color_texture(self->ofs); GPUTexture *texture = GPU_offscreen_color_texture(self->ofs);
@@ -136,7 +136,7 @@ static PyObject *bpygpu_offscreen_color_texture_get(BPyGPUOffScreen *self, void
} }
PyDoc_STRVAR( PyDoc_STRVAR(
bpygpu_offscreen_bind_doc, py_offscreen_bind_doc,
".. method:: bind(save=True)\n" ".. method:: bind(save=True)\n"
"\n" "\n"
" Bind the offscreen object.\n" " Bind the offscreen object.\n"
@@ -145,7 +145,7 @@ PyDoc_STRVAR(
"\n" "\n"
" :arg save: Save the current OpenGL state, so that it can be restored when unbinding.\n" " :arg save: Save the current OpenGL state, so that it can be restored when unbinding.\n"
" :type save: `bool`\n"); " :type save: `bool`\n");
static PyObject *bpygpu_offscreen_bind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds) static PyObject *py_offscreen_bind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
{ {
BPY_GPU_OFFSCREEN_CHECK_OBJ(self); BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
bool save = true; bool save = true;
@@ -165,7 +165,7 @@ static PyObject *bpygpu_offscreen_bind(BPyGPUOffScreen *self, PyObject *args, Py
return (PyObject *)self; return (PyObject *)self;
} }
PyDoc_STRVAR(bpygpu_offscreen_unbind_doc, PyDoc_STRVAR(py_offscreen_unbind_doc,
".. method:: unbind(restore=True)\n" ".. method:: unbind(restore=True)\n"
"\n" "\n"
" Unbind the offscreen object.\n" " Unbind the offscreen object.\n"
@@ -173,7 +173,7 @@ PyDoc_STRVAR(bpygpu_offscreen_unbind_doc,
" :arg restore: Restore the OpenGL state, can only be used when the state has been " " :arg restore: Restore the OpenGL state, can only be used when the state has been "
"saved before.\n" "saved before.\n"
" :type restore: `bool`\n"); " :type restore: `bool`\n");
static PyObject *bpygpu_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds) static PyObject *py_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
{ {
bool restore = true; bool restore = true;
@@ -191,7 +191,7 @@ static PyObject *bpygpu_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args,
} }
PyDoc_STRVAR( PyDoc_STRVAR(
bpygpu_offscreen_draw_view3d_doc, py_offscreen_draw_view3d_doc,
".. method:: draw_view3d(scene, view_layer, view3d, region, view_matrix, projection_matrix)\n" ".. method:: draw_view3d(scene, view_layer, view3d, region, view_matrix, projection_matrix)\n"
"\n" "\n"
" Draw the 3d viewport in the offscreen object.\n" " Draw the 3d viewport in the offscreen object.\n"
@@ -208,9 +208,7 @@ PyDoc_STRVAR(
" :type view_matrix: :class:`mathutils.Matrix`\n" " :type view_matrix: :class:`mathutils.Matrix`\n"
" :arg projection_matrix: Projection Matrix (e.g. ``camera.calc_matrix_camera(...)``).\n" " :arg projection_matrix: Projection Matrix (e.g. ``camera.calc_matrix_camera(...)``).\n"
" :type projection_matrix: :class:`mathutils.Matrix`\n"); " :type projection_matrix: :class:`mathutils.Matrix`\n");
static PyObject *bpygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, static PyObject *py_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
PyObject *args,
PyObject *kwds)
{ {
MatrixObject *py_mat_view, *py_mat_projection; MatrixObject *py_mat_view, *py_mat_projection;
PyObject *py_scene, *py_view_layer, *py_region, *py_view3d; PyObject *py_scene, *py_view_layer, *py_region, *py_view3d;
@@ -272,12 +270,12 @@ static PyObject *bpygpu_offscreen_draw_view3d(BPyGPUOffScreen *self,
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_offscreen_free_doc, PyDoc_STRVAR(py_offscreen_free_doc,
".. method:: free()\n" ".. method:: free()\n"
"\n" "\n"
" Free the offscreen object.\n" " Free the offscreen object.\n"
" The framebuffer, texture and render objects will no longer be accessible.\n"); " The framebuffer, texture and render objects will no longer be accessible.\n");
static PyObject *bpygpu_offscreen_free(BPyGPUOffScreen *self) static PyObject *py_offscreen_free(BPyGPUOffScreen *self)
{ {
BPY_GPU_OFFSCREEN_CHECK_OBJ(self); BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
@@ -286,12 +284,12 @@ static PyObject *bpygpu_offscreen_free(BPyGPUOffScreen *self)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static PyObject *bpygpu_offscreen_bind_context_enter(BPyGPUOffScreen *UNUSED(self)) static PyObject *py_offscreen_bind_context_enter(BPyGPUOffScreen *UNUSED(self))
{ {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static PyObject *bpygpu_offscreen_bind_context_exit(BPyGPUOffScreen *self, PyObject *UNUSED(args)) static PyObject *py_offscreen_bind_context_exit(BPyGPUOffScreen *self, PyObject *UNUSED(args))
{ {
GPU_offscreen_unbind(self->ofs, self->is_saved); GPU_offscreen_unbind(self->ofs, self->is_saved);
Py_RETURN_NONE; Py_RETURN_NONE;
@@ -305,41 +303,34 @@ static void BPyGPUOffScreen__tp_dealloc(BPyGPUOffScreen *self)
Py_TYPE(self)->tp_free((PyObject *)self); Py_TYPE(self)->tp_free((PyObject *)self);
} }
static PyGetSetDef bpygpu_offscreen_getseters[] = { static PyGetSetDef py_offscreen_getseters[] = {
{"color_texture", {"color_texture",
(getter)bpygpu_offscreen_color_texture_get, (getter)py_offscreen_color_texture_get,
(setter)NULL, (setter)NULL,
bpygpu_offscreen_color_texture_doc, py_offscreen_color_texture_doc,
NULL},
{"width", (getter)bpygpu_offscreen_width_get, (setter)NULL, bpygpu_offscreen_width_doc, NULL},
{"height",
(getter)bpygpu_offscreen_height_get,
(setter)NULL,
bpygpu_offscreen_height_doc,
NULL}, NULL},
{"width", (getter)py_offscreen_width_get, (setter)NULL, py_offscreen_width_doc, NULL},
{"height", (getter)py_offscreen_height_get, (setter)NULL, py_offscreen_height_doc, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */ {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
}; };
static struct PyMethodDef bpygpu_offscreen_methods[] = { static struct PyMethodDef py_offscreen_methods[] = {
{"bind", {"bind", (PyCFunction)py_offscreen_bind, METH_VARARGS | METH_KEYWORDS, py_offscreen_bind_doc},
(PyCFunction)bpygpu_offscreen_bind,
METH_VARARGS | METH_KEYWORDS,
bpygpu_offscreen_bind_doc},
{"unbind", {"unbind",
(PyCFunction)bpygpu_offscreen_unbind, (PyCFunction)py_offscreen_unbind,
METH_VARARGS | METH_KEYWORDS, METH_VARARGS | METH_KEYWORDS,
bpygpu_offscreen_unbind_doc}, py_offscreen_unbind_doc},
{"draw_view3d", {"draw_view3d",
(PyCFunction)bpygpu_offscreen_draw_view3d, (PyCFunction)py_offscreen_draw_view3d,
METH_VARARGS | METH_KEYWORDS, METH_VARARGS | METH_KEYWORDS,
bpygpu_offscreen_draw_view3d_doc}, py_offscreen_draw_view3d_doc},
{"free", (PyCFunction)bpygpu_offscreen_free, METH_NOARGS, bpygpu_offscreen_free_doc}, {"free", (PyCFunction)py_offscreen_free, METH_NOARGS, py_offscreen_free_doc},
{"__enter__", (PyCFunction)bpygpu_offscreen_bind_context_enter, METH_NOARGS}, {"__enter__", (PyCFunction)py_offscreen_bind_context_enter, METH_NOARGS},
{"__exit__", (PyCFunction)bpygpu_offscreen_bind_context_exit, METH_VARARGS}, {"__exit__", (PyCFunction)py_offscreen_bind_context_exit, METH_VARARGS},
{NULL, NULL, 0, NULL}, {NULL, NULL, 0, NULL},
}; };
PyDoc_STRVAR(bpygpu_offscreen_doc, PyDoc_STRVAR(py_offscreen_doc,
".. class:: GPUOffScreen(width, height)\n" ".. class:: GPUOffScreen(width, height)\n"
"\n" "\n"
" This object gives access to off screen buffers.\n" " This object gives access to off screen buffers.\n"
@@ -353,10 +344,10 @@ PyTypeObject BPyGPUOffScreen_Type = {
.tp_basicsize = sizeof(BPyGPUOffScreen), .tp_basicsize = sizeof(BPyGPUOffScreen),
.tp_dealloc = (destructor)BPyGPUOffScreen__tp_dealloc, .tp_dealloc = (destructor)BPyGPUOffScreen__tp_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT, .tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = bpygpu_offscreen_doc, .tp_doc = py_offscreen_doc,
.tp_methods = bpygpu_offscreen_methods, .tp_methods = py_offscreen_methods,
.tp_getset = bpygpu_offscreen_getseters, .tp_getset = py_offscreen_getseters,
.tp_new = bpygpu_offscreen_new, .tp_new = py_offscreen_new,
}; };
/** \} */ /** \} */

View File

@@ -40,14 +40,14 @@
/** \name Methods /** \name Methods
* \{ */ * \{ */
PyDoc_STRVAR(bpygpu_select_load_id_doc, PyDoc_STRVAR(py_select_load_id_doc,
".. function:: load_id(id)\n" ".. function:: load_id(id)\n"
"\n" "\n"
" Set the selection ID.\n" " Set the selection ID.\n"
"\n" "\n"
" :param id: Number (32-bit uint).\n" " :param id: Number (32-bit uint).\n"
" :type select: int\n"); " :type select: int\n");
static PyObject *bpygpu_select_load_id(PyObject *UNUSED(self), PyObject *value) static PyObject *py_select_load_id(PyObject *UNUSED(self), PyObject *value)
{ {
uint id; uint id;
if ((id = PyC_Long_AsU32(value)) == (uint)-1) { if ((id = PyC_Long_AsU32(value)) == (uint)-1) {
@@ -62,18 +62,18 @@ static PyObject *bpygpu_select_load_id(PyObject *UNUSED(self), PyObject *value)
/** \name Module /** \name Module
* \{ */ * \{ */
static struct PyMethodDef bpygpu_select_methods[] = { static struct PyMethodDef py_select_methods[] = {
/* Manage Stack */ /* Manage Stack */
{"load_id", (PyCFunction)bpygpu_select_load_id, METH_O, bpygpu_select_load_id_doc}, {"load_id", (PyCFunction)py_select_load_id, METH_O, py_select_load_id_doc},
{NULL, NULL, 0, NULL}, {NULL, NULL, 0, NULL},
}; };
PyDoc_STRVAR(bpygpu_select_doc, "This module provides access to selection."); PyDoc_STRVAR(py_select_doc, "This module provides access to selection.");
static PyModuleDef BPyGPU_select_module_def = { static PyModuleDef BPyGPU_select_module_def = {
PyModuleDef_HEAD_INIT, PyModuleDef_HEAD_INIT,
.m_name = "gpu.select", .m_name = "gpu.select",
.m_doc = bpygpu_select_doc, .m_doc = py_select_doc,
.m_methods = bpygpu_select_methods, .m_methods = py_select_methods,
}; };
PyObject *BPyInit_gpu_select(void) PyObject *BPyInit_gpu_select(void)

View File

@@ -51,9 +51,7 @@ static const struct PyC_StringEnumItems pygpu_bultinshader_items[] = {
{0, NULL}, {0, NULL},
}; };
static int bpygpu_uniform_location_get(GPUShader *shader, static int py_uniform_location_get(GPUShader *shader, const char *name, const char *error_prefix)
const char *name,
const char *error_prefix)
{ {
const int uniform = GPU_shader_get_uniform(shader, name); const int uniform = GPU_shader_get_uniform(shader, name);
@@ -70,7 +68,7 @@ static int bpygpu_uniform_location_get(GPUShader *shader,
/** \name Shader Type /** \name Shader Type
* \{ */ * \{ */
static PyObject *bpygpu_shader_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) static PyObject *py_shader_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{ {
BPYGPU_IS_INIT_OR_ERROR_OBJ; BPYGPU_IS_INIT_OR_ERROR_OBJ;
@@ -109,17 +107,17 @@ static PyObject *bpygpu_shader_new(PyTypeObject *UNUSED(type), PyObject *args, P
} }
PyDoc_STRVAR( PyDoc_STRVAR(
bpygpu_shader_bind_doc, py_shader_bind_doc,
".. method:: bind()\n" ".. method:: bind()\n"
"\n" "\n"
" Bind the shader object. Required to be able to change uniforms of this shader.\n"); " Bind the shader object. Required to be able to change uniforms of this shader.\n");
static PyObject *bpygpu_shader_bind(BPyGPUShader *self) static PyObject *py_shader_bind(BPyGPUShader *self)
{ {
GPU_shader_bind(self->shader); GPU_shader_bind(self->shader);
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_shader_uniform_from_name_doc, PyDoc_STRVAR(py_shader_uniform_from_name_doc,
".. method:: uniform_from_name(name)\n" ".. method:: uniform_from_name(name)\n"
"\n" "\n"
" Get uniform location by name.\n" " Get uniform location by name.\n"
@@ -128,14 +126,14 @@ PyDoc_STRVAR(bpygpu_shader_uniform_from_name_doc,
" :type name: `str`\n" " :type name: `str`\n"
" :return: Location of the uniform variable.\n" " :return: Location of the uniform variable.\n"
" :rtype: `int`\n"); " :rtype: `int`\n");
static PyObject *bpygpu_shader_uniform_from_name(BPyGPUShader *self, PyObject *arg) static PyObject *py_shader_uniform_from_name(BPyGPUShader *self, PyObject *arg)
{ {
const char *name = PyUnicode_AsUTF8(arg); const char *name = PyUnicode_AsUTF8(arg);
if (name == NULL) { if (name == NULL) {
return NULL; return NULL;
} }
const int uniform = bpygpu_uniform_location_get(self->shader, name, "GPUShader.get_uniform"); const int uniform = py_uniform_location_get(self->shader, name, "GPUShader.get_uniform");
if (uniform == -1) { if (uniform == -1) {
return NULL; return NULL;
@@ -145,7 +143,7 @@ static PyObject *bpygpu_shader_uniform_from_name(BPyGPUShader *self, PyObject *a
} }
PyDoc_STRVAR( PyDoc_STRVAR(
bpygpu_shader_uniform_block_from_name_doc, py_shader_uniform_block_from_name_doc,
".. method:: uniform_block_from_name(name)\n" ".. method:: uniform_block_from_name(name)\n"
"\n" "\n"
" Get uniform block location by name.\n" " Get uniform block location by name.\n"
@@ -154,7 +152,7 @@ PyDoc_STRVAR(
" :type name: `str`\n" " :type name: `str`\n"
" :return: The location of the uniform block variable.\n" " :return: The location of the uniform block variable.\n"
" :rtype: `int`\n"); " :rtype: `int`\n");
static PyObject *bpygpu_shader_uniform_block_from_name(BPyGPUShader *self, PyObject *arg) static PyObject *py_shader_uniform_block_from_name(BPyGPUShader *self, PyObject *arg)
{ {
const char *name = PyUnicode_AsUTF8(arg); const char *name = PyUnicode_AsUTF8(arg);
if (name == NULL) { if (name == NULL) {
@@ -171,12 +169,12 @@ static PyObject *bpygpu_shader_uniform_block_from_name(BPyGPUShader *self, PyObj
return PyLong_FromLong(uniform); return PyLong_FromLong(uniform);
} }
static bool bpygpu_shader_uniform_vector_imp(PyObject *args, static bool py_shader_uniform_vector_imp(PyObject *args,
int elem_size, int elem_size,
int *r_location, int *r_location,
int *r_length, int *r_length,
int *r_count, int *r_count,
Py_buffer *r_pybuffer) Py_buffer *r_pybuffer)
{ {
PyObject *buffer; PyObject *buffer;
@@ -199,7 +197,7 @@ static bool bpygpu_shader_uniform_vector_imp(PyObject *args,
return true; return true;
} }
PyDoc_STRVAR(bpygpu_shader_uniform_vector_float_doc, PyDoc_STRVAR(py_shader_uniform_vector_float_doc,
".. method:: uniform_vector_float(location, buffer, length, count)\n" ".. method:: uniform_vector_float(location, buffer, length, count)\n"
"\n" "\n"
" Set the buffer to fill the uniform.\n" " Set the buffer to fill the uniform.\n"
@@ -219,14 +217,13 @@ PyDoc_STRVAR(bpygpu_shader_uniform_vector_float_doc,
" :param count: Specifies the number of elements, vector or matrices that are to " " :param count: Specifies the number of elements, vector or matrices that are to "
"be modified.\n" "be modified.\n"
" :type count: int\n"); " :type count: int\n");
static PyObject *bpygpu_shader_uniform_vector_float(BPyGPUShader *self, PyObject *args) static PyObject *py_shader_uniform_vector_float(BPyGPUShader *self, PyObject *args)
{ {
int location, length, count; int location, length, count;
Py_buffer pybuffer; Py_buffer pybuffer;
if (!bpygpu_shader_uniform_vector_imp( if (!py_shader_uniform_vector_imp(args, sizeof(float), &location, &length, &count, &pybuffer)) {
args, sizeof(float), &location, &length, &count, &pybuffer)) {
return NULL; return NULL;
} }
@@ -237,18 +234,17 @@ static PyObject *bpygpu_shader_uniform_vector_float(BPyGPUShader *self, PyObject
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_shader_uniform_vector_int_doc, PyDoc_STRVAR(py_shader_uniform_vector_int_doc,
".. method:: uniform_vector_int(location, buffer, length, count)\n" ".. method:: uniform_vector_int(location, buffer, length, count)\n"
"\n" "\n"
" See GPUShader.uniform_vector_float(...) description.\n"); " See GPUShader.uniform_vector_float(...) description.\n");
static PyObject *bpygpu_shader_uniform_vector_int(BPyGPUShader *self, PyObject *args) static PyObject *py_shader_uniform_vector_int(BPyGPUShader *self, PyObject *args)
{ {
int location, length, count; int location, length, count;
Py_buffer pybuffer; Py_buffer pybuffer;
if (!bpygpu_shader_uniform_vector_imp( if (!py_shader_uniform_vector_imp(args, sizeof(int), &location, &length, &count, &pybuffer)) {
args, sizeof(int), &location, &length, &count, &pybuffer)) {
return NULL; return NULL;
} }
@@ -259,7 +255,7 @@ static PyObject *bpygpu_shader_uniform_vector_int(BPyGPUShader *self, PyObject *
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_shader_uniform_bool_doc, PyDoc_STRVAR(py_shader_uniform_bool_doc,
".. method:: uniform_bool(name, seq)\n" ".. method:: uniform_bool(name, seq)\n"
"\n" "\n"
" Specify the value of a uniform variable for the current program object.\n" " Specify the value of a uniform variable for the current program object.\n"
@@ -268,7 +264,7 @@ PyDoc_STRVAR(bpygpu_shader_uniform_bool_doc,
" :type name: str\n" " :type name: str\n"
" :param seq: Value that will be used to update the specified uniform variable.\n" " :param seq: Value that will be used to update the specified uniform variable.\n"
" :type seq: sequence of bools\n"); " :type seq: sequence of bools\n");
static PyObject *bpygpu_shader_uniform_bool(BPyGPUShader *self, PyObject *args) static PyObject *py_shader_uniform_bool(BPyGPUShader *self, PyObject *args)
{ {
const char *error_prefix = "GPUShader.uniform_bool"; const char *error_prefix = "GPUShader.uniform_bool";
@@ -312,7 +308,7 @@ static PyObject *bpygpu_shader_uniform_bool(BPyGPUShader *self, PyObject *args)
return NULL; return NULL;
} }
const int location = bpygpu_uniform_location_get(self->shader, params.id, error_prefix); const int location = py_uniform_location_get(self->shader, params.id, error_prefix);
if (location == -1) { if (location == -1) {
return NULL; return NULL;
@@ -323,7 +319,7 @@ static PyObject *bpygpu_shader_uniform_bool(BPyGPUShader *self, PyObject *args)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_shader_uniform_float_doc, PyDoc_STRVAR(py_shader_uniform_float_doc,
".. method:: uniform_float(name, value)\n" ".. method:: uniform_float(name, value)\n"
"\n" "\n"
" Specify the value of a uniform variable for the current program object.\n" " Specify the value of a uniform variable for the current program object.\n"
@@ -332,7 +328,7 @@ PyDoc_STRVAR(bpygpu_shader_uniform_float_doc,
" :type name: str\n" " :type name: str\n"
" :param value: Value that will be used to update the specified uniform variable.\n" " :param value: Value that will be used to update the specified uniform variable.\n"
" :type value: single number or sequence of numbers\n"); " :type value: single number or sequence of numbers\n");
static PyObject *bpygpu_shader_uniform_float(BPyGPUShader *self, PyObject *args) static PyObject *py_shader_uniform_float(BPyGPUShader *self, PyObject *args)
{ {
const char *error_prefix = "GPUShader.uniform_float"; const char *error_prefix = "GPUShader.uniform_float";
@@ -381,7 +377,7 @@ static PyObject *bpygpu_shader_uniform_float(BPyGPUShader *self, PyObject *args)
return NULL; return NULL;
} }
const int location = bpygpu_uniform_location_get(self->shader, params.id, error_prefix); const int location = py_uniform_location_get(self->shader, params.id, error_prefix);
if (location == -1) { if (location == -1) {
return NULL; return NULL;
@@ -392,7 +388,7 @@ static PyObject *bpygpu_shader_uniform_float(BPyGPUShader *self, PyObject *args)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_shader_uniform_int_doc, PyDoc_STRVAR(py_shader_uniform_int_doc,
".. method:: uniform_int(name, seq)\n" ".. method:: uniform_int(name, seq)\n"
"\n" "\n"
" Specify the value of a uniform variable for the current program object.\n" " Specify the value of a uniform variable for the current program object.\n"
@@ -401,7 +397,7 @@ PyDoc_STRVAR(bpygpu_shader_uniform_int_doc,
" :type name: str\n" " :type name: str\n"
" :param seq: Value that will be used to update the specified uniform variable.\n" " :param seq: Value that will be used to update the specified uniform variable.\n"
" :type seq: sequence of numbers\n"); " :type seq: sequence of numbers\n");
static PyObject *bpygpu_shader_uniform_int(BPyGPUShader *self, PyObject *args) static PyObject *py_shader_uniform_int(BPyGPUShader *self, PyObject *args)
{ {
const char *error_prefix = "GPUShader.uniform_int"; const char *error_prefix = "GPUShader.uniform_int";
@@ -451,7 +447,7 @@ static PyObject *bpygpu_shader_uniform_int(BPyGPUShader *self, PyObject *args)
return NULL; return NULL;
} }
const int location = bpygpu_uniform_location_get(self->shader, params.id, error_prefix); const int location = py_uniform_location_get(self->shader, params.id, error_prefix);
if (location == -1) { if (location == -1) {
return NULL; return NULL;
@@ -463,7 +459,7 @@ static PyObject *bpygpu_shader_uniform_int(BPyGPUShader *self, PyObject *args)
} }
PyDoc_STRVAR( PyDoc_STRVAR(
bpygpu_shader_attr_from_name_doc, py_shader_attr_from_name_doc,
".. method:: attr_from_name(name)\n" ".. method:: attr_from_name(name)\n"
"\n" "\n"
" Get attribute location by name.\n" " Get attribute location by name.\n"
@@ -472,7 +468,7 @@ PyDoc_STRVAR(
" :type name: str\n" " :type name: str\n"
" :return: The location of an attribute variable.\n" " :return: The location of an attribute variable.\n"
" :rtype: int\n"); " :rtype: int\n");
static PyObject *bpygpu_shader_attr_from_name(BPyGPUShader *self, PyObject *arg) static PyObject *py_shader_attr_from_name(BPyGPUShader *self, PyObject *arg)
{ {
const char *name = PyUnicode_AsUTF8(arg); const char *name = PyUnicode_AsUTF8(arg);
if (name == NULL) { if (name == NULL) {
@@ -489,75 +485,69 @@ static PyObject *bpygpu_shader_attr_from_name(BPyGPUShader *self, PyObject *arg)
return PyLong_FromLong(attr); return PyLong_FromLong(attr);
} }
PyDoc_STRVAR(bpygpu_shader_calc_format_doc, PyDoc_STRVAR(py_shader_calc_format_doc,
".. method:: calc_format()\n" ".. method:: calc_format()\n"
"\n" "\n"
" Build a new format based on the attributes of the shader.\n" " Build a new format based on the attributes of the shader.\n"
"\n" "\n"
" :return: vertex attribute format for the shader\n" " :return: vertex attribute format for the shader\n"
" :rtype: GPUVertFormat\n"); " :rtype: GPUVertFormat\n");
static PyObject *bpygpu_shader_calc_format(BPyGPUShader *self, PyObject *UNUSED(arg)) static PyObject *py_shader_calc_format(BPyGPUShader *self, PyObject *UNUSED(arg))
{ {
BPyGPUVertFormat *ret = (BPyGPUVertFormat *)BPyGPUVertFormat_CreatePyObject(NULL); BPyGPUVertFormat *ret = (BPyGPUVertFormat *)BPyGPUVertFormat_CreatePyObject(NULL);
GPU_vertformat_from_shader(&ret->fmt, self->shader); GPU_vertformat_from_shader(&ret->fmt, self->shader);
return (PyObject *)ret; return (PyObject *)ret;
} }
static struct PyMethodDef bpygpu_shader_methods[] = { static struct PyMethodDef py_shader_methods[] = {
{"bind", (PyCFunction)bpygpu_shader_bind, METH_NOARGS, bpygpu_shader_bind_doc}, {"bind", (PyCFunction)py_shader_bind, METH_NOARGS, py_shader_bind_doc},
{"uniform_from_name", {"uniform_from_name",
(PyCFunction)bpygpu_shader_uniform_from_name, (PyCFunction)py_shader_uniform_from_name,
METH_O, METH_O,
bpygpu_shader_uniform_from_name_doc}, py_shader_uniform_from_name_doc},
{"uniform_block_from_name", {"uniform_block_from_name",
(PyCFunction)bpygpu_shader_uniform_block_from_name, (PyCFunction)py_shader_uniform_block_from_name,
METH_O, METH_O,
bpygpu_shader_uniform_block_from_name_doc}, py_shader_uniform_block_from_name_doc},
{"uniform_vector_float", {"uniform_vector_float",
(PyCFunction)bpygpu_shader_uniform_vector_float, (PyCFunction)py_shader_uniform_vector_float,
METH_VARARGS, METH_VARARGS,
bpygpu_shader_uniform_vector_float_doc}, py_shader_uniform_vector_float_doc},
{"uniform_vector_int", {"uniform_vector_int",
(PyCFunction)bpygpu_shader_uniform_vector_int, (PyCFunction)py_shader_uniform_vector_int,
METH_VARARGS, METH_VARARGS,
bpygpu_shader_uniform_vector_int_doc}, py_shader_uniform_vector_int_doc},
{"uniform_bool", {"uniform_bool",
(PyCFunction)bpygpu_shader_uniform_bool, (PyCFunction)py_shader_uniform_bool,
METH_VARARGS, METH_VARARGS,
bpygpu_shader_uniform_bool_doc}, py_shader_uniform_bool_doc},
{"uniform_float", {"uniform_float",
(PyCFunction)bpygpu_shader_uniform_float, (PyCFunction)py_shader_uniform_float,
METH_VARARGS, METH_VARARGS,
bpygpu_shader_uniform_float_doc}, py_shader_uniform_float_doc},
{"uniform_int", {"uniform_int", (PyCFunction)py_shader_uniform_int, METH_VARARGS, py_shader_uniform_int_doc},
(PyCFunction)bpygpu_shader_uniform_int,
METH_VARARGS,
bpygpu_shader_uniform_int_doc},
{"attr_from_name", {"attr_from_name",
(PyCFunction)bpygpu_shader_attr_from_name, (PyCFunction)py_shader_attr_from_name,
METH_O, METH_O,
bpygpu_shader_attr_from_name_doc}, py_shader_attr_from_name_doc},
{"format_calc", {"format_calc", (PyCFunction)py_shader_calc_format, METH_NOARGS, py_shader_calc_format_doc},
(PyCFunction)bpygpu_shader_calc_format,
METH_NOARGS,
bpygpu_shader_calc_format_doc},
{NULL, NULL, 0, NULL}, {NULL, NULL, 0, NULL},
}; };
PyDoc_STRVAR( PyDoc_STRVAR(
bpygpu_shader_program_doc, py_shader_program_doc,
"The name of the program object for use by the OpenGL API (read-only).\n\n:type: int"); "The name of the program object for use by the OpenGL API (read-only).\n\n:type: int");
static PyObject *bpygpu_shader_program_get(BPyGPUShader *self, void *UNUSED(closure)) static PyObject *py_shader_program_get(BPyGPUShader *self, void *UNUSED(closure))
{ {
return PyLong_FromLong(GPU_shader_get_program(self->shader)); return PyLong_FromLong(GPU_shader_get_program(self->shader));
} }
static PyGetSetDef bpygpu_shader_getseters[] = { static PyGetSetDef py_shader_getseters[] = {
{"program", (getter)bpygpu_shader_program_get, (setter)NULL, bpygpu_shader_program_doc, NULL}, {"program", (getter)py_shader_program_get, (setter)NULL, py_shader_program_doc, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */ {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
}; };
static void bpygpu_shader_dealloc(BPyGPUShader *self) static void py_shader_dealloc(BPyGPUShader *self)
{ {
if (self->is_builtin == false) { if (self->is_builtin == false) {
GPU_shader_free(self->shader); GPU_shader_free(self->shader);
@@ -566,7 +556,7 @@ static void bpygpu_shader_dealloc(BPyGPUShader *self)
} }
PyDoc_STRVAR( PyDoc_STRVAR(
bpygpu_shader_doc, py_shader_doc,
".. class:: GPUShader(vertexcode, fragcode, geocode=None, libcode=None, defines=None)\n" ".. class:: GPUShader(vertexcode, fragcode, geocode=None, libcode=None, defines=None)\n"
"\n" "\n"
" GPUShader combines multiple GLSL shaders into a program used for drawing.\n" " GPUShader combines multiple GLSL shaders into a program used for drawing.\n"
@@ -600,12 +590,12 @@ PyDoc_STRVAR(
PyTypeObject BPyGPUShader_Type = { PyTypeObject BPyGPUShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUShader", PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUShader",
.tp_basicsize = sizeof(BPyGPUShader), .tp_basicsize = sizeof(BPyGPUShader),
.tp_dealloc = (destructor)bpygpu_shader_dealloc, .tp_dealloc = (destructor)py_shader_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT, .tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = bpygpu_shader_doc, .tp_doc = py_shader_doc,
.tp_methods = bpygpu_shader_methods, .tp_methods = py_shader_methods,
.tp_getset = bpygpu_shader_getseters, .tp_getset = py_shader_getseters,
.tp_new = bpygpu_shader_new, .tp_new = py_shader_new,
}; };
/** \} */ /** \} */
@@ -614,17 +604,17 @@ PyTypeObject BPyGPUShader_Type = {
/** \name gpu.shader Module API /** \name gpu.shader Module API
* \{ */ * \{ */
PyDoc_STRVAR(bpygpu_shader_unbind_doc, PyDoc_STRVAR(py_shader_unbind_doc,
".. function:: unbind()\n" ".. function:: unbind()\n"
"\n" "\n"
" Unbind the bound shader object.\n"); " Unbind the bound shader object.\n");
static PyObject *bpygpu_shader_unbind(BPyGPUShader *UNUSED(self)) static PyObject *py_shader_unbind(BPyGPUShader *UNUSED(self))
{ {
GPU_shader_unbind(); GPU_shader_unbind();
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(bpygpu_shader_from_builtin_doc, PyDoc_STRVAR(py_shader_from_builtin_doc,
".. function:: from_builtin(shader_name)\n" ".. function:: from_builtin(shader_name)\n"
"\n" "\n"
" Shaders that are embedded in the blender internal code.\n" " Shaders that are embedded in the blender internal code.\n"
@@ -644,11 +634,11 @@ PyDoc_STRVAR(bpygpu_shader_from_builtin_doc,
" :type shader_name: str\n" " :type shader_name: str\n"
" :return: Shader object corresponding to the given name.\n" " :return: Shader object corresponding to the given name.\n"
" :rtype: :class:`bpy.types.GPUShader`\n"); " :rtype: :class:`bpy.types.GPUShader`\n");
static PyObject *bpygpu_shader_from_builtin(PyObject *UNUSED(self), PyObject *arg) static PyObject *py_shader_from_builtin(PyObject *UNUSED(self), PyObject *arg)
{ {
BPYGPU_IS_INIT_OR_ERROR_OBJ; BPYGPU_IS_INIT_OR_ERROR_OBJ;
const struct PyC_StringEnum pygpu_bultinshader = {&pygpu_bultinshader_items, -1}; struct PyC_StringEnum pygpu_bultinshader = {&pygpu_bultinshader_items};
if (!PyC_ParseStringEnum(arg, &pygpu_bultinshader)) { if (!PyC_ParseStringEnum(arg, &pygpu_bultinshader)) {
return NULL; return NULL;
} }
@@ -658,7 +648,7 @@ static PyObject *bpygpu_shader_from_builtin(PyObject *UNUSED(self), PyObject *ar
return BPyGPUShader_CreatePyObject(shader, true); return BPyGPUShader_CreatePyObject(shader, true);
} }
PyDoc_STRVAR(bpygpu_shader_code_from_builtin_doc, PyDoc_STRVAR(py_shader_code_from_builtin_doc,
".. function:: code_from_builtin(shader_name)\n" ".. function:: code_from_builtin(shader_name)\n"
"\n" "\n"
" Exposes the internal shader code for query.\n" " Exposes the internal shader code for query.\n"
@@ -674,7 +664,7 @@ PyDoc_STRVAR(bpygpu_shader_code_from_builtin_doc,
" :type shader_name: str\n" " :type shader_name: str\n"
" :return: Vertex, fragment and geometry shader codes.\n" " :return: Vertex, fragment and geometry shader codes.\n"
" :rtype: dict\n"); " :rtype: dict\n");
static PyObject *bpygpu_shader_code_from_builtin(BPyGPUShader *UNUSED(self), PyObject *arg) static PyObject *py_shader_code_from_builtin(BPyGPUShader *UNUSED(self), PyObject *arg)
{ {
const char *vert; const char *vert;
const char *frag; const char *frag;
@@ -683,7 +673,7 @@ static PyObject *bpygpu_shader_code_from_builtin(BPyGPUShader *UNUSED(self), PyO
PyObject *item, *r_dict; PyObject *item, *r_dict;
const struct PyC_StringEnum pygpu_bultinshader = {&pygpu_bultinshader_items, -1}; struct PyC_StringEnum pygpu_bultinshader = {&pygpu_bultinshader_items};
if (!PyC_ParseStringEnum(arg, &pygpu_bultinshader)) { if (!PyC_ParseStringEnum(arg, &pygpu_bultinshader)) {
return NULL; return NULL;
} }
@@ -710,20 +700,17 @@ static PyObject *bpygpu_shader_code_from_builtin(BPyGPUShader *UNUSED(self), PyO
return r_dict; return r_dict;
} }
static struct PyMethodDef bpygpu_shader_module_methods[] = { static struct PyMethodDef py_shader_module_methods[] = {
{"unbind", (PyCFunction)bpygpu_shader_unbind, METH_NOARGS, bpygpu_shader_unbind_doc}, {"unbind", (PyCFunction)py_shader_unbind, METH_NOARGS, py_shader_unbind_doc},
{"from_builtin", {"from_builtin", (PyCFunction)py_shader_from_builtin, METH_O, py_shader_from_builtin_doc},
(PyCFunction)bpygpu_shader_from_builtin,
METH_O,
bpygpu_shader_from_builtin_doc},
{"code_from_builtin", {"code_from_builtin",
(PyCFunction)bpygpu_shader_code_from_builtin, (PyCFunction)py_shader_code_from_builtin,
METH_O, METH_O,
bpygpu_shader_code_from_builtin_doc}, py_shader_code_from_builtin_doc},
{NULL, NULL, 0, NULL}, {NULL, NULL, 0, NULL},
}; };
PyDoc_STRVAR(bpygpu_shader_module_doc, PyDoc_STRVAR(py_shader_module_doc,
"This module provides access to GPUShader internal functions.\n" "This module provides access to GPUShader internal functions.\n"
"\n" "\n"
".. rubric:: Built-in shaders\n" ".. rubric:: Built-in shaders\n"
@@ -755,8 +742,8 @@ PyDoc_STRVAR(bpygpu_shader_module_doc,
static PyModuleDef BPyGPU_shader_module_def = { static PyModuleDef BPyGPU_shader_module_def = {
PyModuleDef_HEAD_INIT, PyModuleDef_HEAD_INIT,
.m_name = "gpu.shader", .m_name = "gpu.shader",
.m_doc = bpygpu_shader_module_doc, .m_doc = py_shader_module_doc,
.m_methods = bpygpu_shader_module_methods, .m_methods = py_shader_module_methods,
}; };
/** \} */ /** \} */

View File

@@ -116,10 +116,10 @@ static void fill_format_sequence(void *data_dst_void,
#undef WARN_TYPE_LIMIT_PUSH #undef WARN_TYPE_LIMIT_PUSH
#undef WARN_TYPE_LIMIT_POP #undef WARN_TYPE_LIMIT_POP
static bool bpygpu_vertbuf_fill_impl(GPUVertBuf *vbo, static bool py_vertbuf_fill_impl(GPUVertBuf *vbo,
uint data_id, uint data_id,
PyObject *seq, PyObject *seq,
const char *error_prefix) const char *error_prefix)
{ {
const char *exc_str_size_mismatch = "Expected a %s of size %d, got %u"; const char *exc_str_size_mismatch = "Expected a %s of size %d, got %u";
@@ -213,10 +213,7 @@ static bool bpygpu_vertbuf_fill_impl(GPUVertBuf *vbo,
return ok; return ok;
} }
static int bpygpu_attr_fill(GPUVertBuf *buf, static int py_attr_fill(GPUVertBuf *buf, int id, PyObject *py_seq_data, const char *error_prefix)
int id,
PyObject *py_seq_data,
const char *error_prefix)
{ {
if (id < 0 || id >= GPU_vertbuf_get_format(buf)->attr_len) { if (id < 0 || id >= GPU_vertbuf_get_format(buf)->attr_len) {
PyErr_Format(PyExc_ValueError, "Format id %d out of range", id); PyErr_Format(PyExc_ValueError, "Format id %d out of range", id);
@@ -228,7 +225,7 @@ static int bpygpu_attr_fill(GPUVertBuf *buf,
return 0; return 0;
} }
if (!bpygpu_vertbuf_fill_impl(buf, (uint)id, py_seq_data, error_prefix)) { if (!py_vertbuf_fill_impl(buf, (uint)id, py_seq_data, error_prefix)) {
return 0; return 0;
} }
@@ -241,7 +238,7 @@ static int bpygpu_attr_fill(GPUVertBuf *buf,
/** \name VertBuf Type /** \name VertBuf Type
* \{ */ * \{ */
static PyObject *bpygpu_VertBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) static PyObject *py_VertBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{ {
struct { struct {
PyObject *py_fmt; PyObject *py_fmt;
@@ -263,7 +260,7 @@ static PyObject *bpygpu_VertBuf_new(PyTypeObject *UNUSED(type), PyObject *args,
return BPyGPUVertBuf_CreatePyObject(vbo); return BPyGPUVertBuf_CreatePyObject(vbo);
} }
PyDoc_STRVAR(bpygpu_VertBuf_attr_fill_doc, PyDoc_STRVAR(py_VertBuf_attr_fill_doc,
".. method:: attr_fill(id, data)\n" ".. method:: attr_fill(id, data)\n"
"\n" "\n"
" Insert data into the buffer for a single attribute.\n" " Insert data into the buffer for a single attribute.\n"
@@ -272,7 +269,7 @@ PyDoc_STRVAR(bpygpu_VertBuf_attr_fill_doc,
" :type id: int or str\n" " :type id: int or str\n"
" :param data: Sequence of data that should be stored in the buffer\n" " :param data: Sequence of data that should be stored in the buffer\n"
" :type data: sequence of values or tuples\n"); " :type data: sequence of values or tuples\n");
static PyObject *bpygpu_VertBuf_attr_fill(BPyGPUVertBuf *self, PyObject *args, PyObject *kwds) static PyObject *py_VertBuf_attr_fill(BPyGPUVertBuf *self, PyObject *args, PyObject *kwds)
{ {
PyObject *data; PyObject *data;
PyObject *identifier; PyObject *identifier;
@@ -302,22 +299,22 @@ static PyObject *bpygpu_VertBuf_attr_fill(BPyGPUVertBuf *self, PyObject *args, P
return NULL; return NULL;
} }
if (!bpygpu_attr_fill(self->buf, id, data, "GPUVertBuf.attr_fill")) { if (!py_attr_fill(self->buf, id, data, "GPUVertBuf.attr_fill")) {
return NULL; return NULL;
} }
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static struct PyMethodDef bpygpu_VertBuf_methods[] = { static struct PyMethodDef py_VertBuf_methods[] = {
{"attr_fill", {"attr_fill",
(PyCFunction)bpygpu_VertBuf_attr_fill, (PyCFunction)py_VertBuf_attr_fill,
METH_VARARGS | METH_KEYWORDS, METH_VARARGS | METH_KEYWORDS,
bpygpu_VertBuf_attr_fill_doc}, py_VertBuf_attr_fill_doc},
{NULL, NULL, 0, NULL}, {NULL, NULL, 0, NULL},
}; };
static void bpygpu_VertBuf_dealloc(BPyGPUVertBuf *self) static void py_VertBuf_dealloc(BPyGPUVertBuf *self)
{ {
GPU_vertbuf_discard(self->buf); GPU_vertbuf_discard(self->buf);
Py_TYPE(self)->tp_free(self); Py_TYPE(self)->tp_free(self);
@@ -335,11 +332,11 @@ PyDoc_STRVAR(py_gpu_vertex_buffer_doc,
PyTypeObject BPyGPUVertBuf_Type = { PyTypeObject BPyGPUVertBuf_Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUVertBuf", PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUVertBuf",
.tp_basicsize = sizeof(BPyGPUVertBuf), .tp_basicsize = sizeof(BPyGPUVertBuf),
.tp_dealloc = (destructor)bpygpu_VertBuf_dealloc, .tp_dealloc = (destructor)py_VertBuf_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT, .tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = py_gpu_vertex_buffer_doc, .tp_doc = py_gpu_vertex_buffer_doc,
.tp_methods = bpygpu_VertBuf_methods, .tp_methods = py_VertBuf_methods,
.tp_new = bpygpu_VertBuf_new, .tp_new = py_VertBuf_new,
}; };
/** \} */ /** \} */

View File

@@ -50,7 +50,7 @@
* Use with PyArg_ParseTuple's "O&" formatting. * Use with PyArg_ParseTuple's "O&" formatting.
* \{ */ * \{ */
static int bpygpu_parse_component_type(const char *str, int length) static int py_parse_component_type(const char *str, int length)
{ {
if (length == 2) { if (length == 2) {
switch (*((ushort *)str)) { switch (*((ushort *)str)) {
@@ -83,7 +83,7 @@ static int bpygpu_parse_component_type(const char *str, int length)
return -1; return -1;
} }
static int bpygpu_parse_fetch_mode(const char *str, int length) static int py_parse_fetch_mode(const char *str, int length)
{ {
#define MATCH_ID(id) \ #define MATCH_ID(id) \
if (length == strlen(STRINGIFY(id))) { \ if (length == strlen(STRINGIFY(id))) { \
@@ -102,7 +102,7 @@ static int bpygpu_parse_fetch_mode(const char *str, int length)
return -1; return -1;
} }
static int bpygpu_ParseVertCompType(PyObject *o, void *p) static int py_ParseVertCompType(PyObject *o, void *p)
{ {
Py_ssize_t length; Py_ssize_t length;
const char *str = _PyUnicode_AsStringAndSize(o, &length); const char *str = _PyUnicode_AsStringAndSize(o, &length);
@@ -112,7 +112,7 @@ static int bpygpu_ParseVertCompType(PyObject *o, void *p)
return 0; return 0;
} }
const int comp_type = bpygpu_parse_component_type(str, length); const int comp_type = py_parse_component_type(str, length);
if (comp_type == -1) { if (comp_type == -1) {
PyErr_Format(PyExc_ValueError, "unknown component type: '%s", str); PyErr_Format(PyExc_ValueError, "unknown component type: '%s", str);
return 0; return 0;
@@ -122,7 +122,7 @@ static int bpygpu_ParseVertCompType(PyObject *o, void *p)
return 1; return 1;
} }
static int bpygpu_ParseVertFetchMode(PyObject *o, void *p) static int py_ParseVertFetchMode(PyObject *o, void *p)
{ {
Py_ssize_t length; Py_ssize_t length;
const char *str = _PyUnicode_AsStringAndSize(o, &length); const char *str = _PyUnicode_AsStringAndSize(o, &length);
@@ -132,7 +132,7 @@ static int bpygpu_ParseVertFetchMode(PyObject *o, void *p)
return 0; return 0;
} }
const int fetch_mode = bpygpu_parse_fetch_mode(str, length); const int fetch_mode = py_parse_fetch_mode(str, length);
if (fetch_mode == -1) { if (fetch_mode == -1) {
PyErr_Format(PyExc_ValueError, "unknown type literal: '%s'", str); PyErr_Format(PyExc_ValueError, "unknown type literal: '%s'", str);
return 0; return 0;
@@ -148,7 +148,7 @@ static int bpygpu_ParseVertFetchMode(PyObject *o, void *p)
/** \name VertFormat Type /** \name VertFormat Type
* \{ */ * \{ */
static PyObject *bpygpu_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) static PyObject *py_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{ {
if (PyTuple_GET_SIZE(args) || (kwds && PyDict_Size(kwds))) { if (PyTuple_GET_SIZE(args) || (kwds && PyDict_Size(kwds))) {
PyErr_SetString(PyExc_ValueError, "This function takes no arguments"); PyErr_SetString(PyExc_ValueError, "This function takes no arguments");
@@ -158,7 +158,7 @@ static PyObject *bpygpu_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *arg
} }
PyDoc_STRVAR( PyDoc_STRVAR(
bpygpu_VertFormat_attr_add_doc, py_VertFormat_attr_add_doc,
".. method:: attr_add(id, comp_type, len, fetch_mode)\n" ".. method:: attr_add(id, comp_type, len, fetch_mode)\n"
"\n" "\n"
" Add a new attribute to the format.\n" " Add a new attribute to the format.\n"
@@ -177,7 +177,7 @@ PyDoc_STRVAR(
" converted to a normal 4 byte float when used.\n" " converted to a normal 4 byte float when used.\n"
" Possible values are `FLOAT`, `INT`, `INT_TO_FLOAT_UNIT` and `INT_TO_FLOAT`.\n" " Possible values are `FLOAT`, `INT`, `INT_TO_FLOAT_UNIT` and `INT_TO_FLOAT`.\n"
" :type fetch_mode: `str`\n"); " :type fetch_mode: `str`\n");
static PyObject *bpygpu_VertFormat_attr_add(BPyGPUVertFormat *self, PyObject *args, PyObject *kwds) static PyObject *py_VertFormat_attr_add(BPyGPUVertFormat *self, PyObject *args, PyObject *kwds)
{ {
struct { struct {
const char *id; const char *id;
@@ -197,10 +197,10 @@ static PyObject *bpygpu_VertFormat_attr_add(BPyGPUVertFormat *self, PyObject *ar
kwds, kwds,
&_parser, &_parser,
&params.id, &params.id,
bpygpu_ParseVertCompType, py_ParseVertCompType,
&params.comp_type, &params.comp_type,
&params.len, &params.len,
bpygpu_ParseVertFetchMode, py_ParseVertFetchMode,
&params.fetch_mode)) { &params.fetch_mode)) {
return NULL; return NULL;
} }
@@ -210,31 +210,31 @@ static PyObject *bpygpu_VertFormat_attr_add(BPyGPUVertFormat *self, PyObject *ar
return PyLong_FromLong(attr_id); return PyLong_FromLong(attr_id);
} }
static struct PyMethodDef bpygpu_VertFormat_methods[] = { static struct PyMethodDef py_VertFormat_methods[] = {
{"attr_add", {"attr_add",
(PyCFunction)bpygpu_VertFormat_attr_add, (PyCFunction)py_VertFormat_attr_add,
METH_VARARGS | METH_KEYWORDS, METH_VARARGS | METH_KEYWORDS,
bpygpu_VertFormat_attr_add_doc}, py_VertFormat_attr_add_doc},
{NULL, NULL, 0, NULL}, {NULL, NULL, 0, NULL},
}; };
static void bpygpu_VertFormat_dealloc(BPyGPUVertFormat *self) static void py_VertFormat_dealloc(BPyGPUVertFormat *self)
{ {
Py_TYPE(self)->tp_free(self); Py_TYPE(self)->tp_free(self);
} }
PyDoc_STRVAR(bpygpu_VertFormat_doc, PyDoc_STRVAR(py_VertFormat_doc,
".. class:: GPUVertFormat()\n" ".. class:: GPUVertFormat()\n"
"\n" "\n"
" This object contains information about the structure of a vertex buffer.\n"); " This object contains information about the structure of a vertex buffer.\n");
PyTypeObject BPyGPUVertFormat_Type = { PyTypeObject BPyGPUVertFormat_Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUVertFormat", PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUVertFormat",
.tp_basicsize = sizeof(BPyGPUVertFormat), .tp_basicsize = sizeof(BPyGPUVertFormat),
.tp_dealloc = (destructor)bpygpu_VertFormat_dealloc, .tp_dealloc = (destructor)py_VertFormat_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT, .tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = bpygpu_VertFormat_doc, .tp_doc = py_VertFormat_doc,
.tp_methods = bpygpu_VertFormat_methods, .tp_methods = py_VertFormat_methods,
.tp_new = bpygpu_VertFormat_new, .tp_new = py_VertFormat_new,
}; };
/** \} */ /** \} */