Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2021-02-17 16:16:41 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-02-17 16:38:59 +0300
commitb7e1660d405d9d73f1aff54358a6d2d1461a75d0 (patch)
treedaa73f48a05438d953ea4eb5873db52405244d4e
parent1ea6394fc8446cb54ec011d0e210135b8b5a4d33 (diff)
Cleanup: Use 'pygpu_' prefix in the cpython GPU module
`py_` prefix can be confused with the Python's own API's.
-rw-r--r--source/blender/python/gpu/gpu_py_api.c8
-rw-r--r--source/blender/python/gpu/gpu_py_batch.c60
-rw-r--r--source/blender/python/gpu/gpu_py_element.c12
-rw-r--r--source/blender/python/gpu/gpu_py_matrix.c191
-rw-r--r--source/blender/python/gpu/gpu_py_offscreen.c109
-rw-r--r--source/blender/python/gpu/gpu_py_select.c18
-rw-r--r--source/blender/python/gpu/gpu_py_shader.c193
-rw-r--r--source/blender/python/gpu/gpu_py_types.c4
-rw-r--r--source/blender/python/gpu/gpu_py_vertex_buffer.c54
-rw-r--r--source/blender/python/gpu/gpu_py_vertex_format.c42
10 files changed, 357 insertions, 334 deletions
diff --git a/source/blender/python/gpu/gpu_py_api.c b/source/blender/python/gpu/gpu_py_api.c
index eb2fd1f7304..dcc8484319e 100644
--- a/source/blender/python/gpu/gpu_py_api.c
+++ b/source/blender/python/gpu/gpu_py_api.c
@@ -105,13 +105,13 @@ success:
/** \name GPU Module
* \{ */
-PyDoc_STRVAR(GPU_doc,
+PyDoc_STRVAR(pygpu_doc,
"This module provides Python wrappers for the GPU implementation in Blender.\n"
"Some higher level functions can be found in the `gpu_extras` module.");
-static struct PyModuleDef GPU_module_def = {
+static struct PyModuleDef pygpu_module_def = {
PyModuleDef_HEAD_INIT,
.m_name = "gpu",
- .m_doc = GPU_doc,
+ .m_doc = pygpu_doc,
};
PyObject *BPyInit_gpu(void)
@@ -120,7 +120,7 @@ PyObject *BPyInit_gpu(void)
PyObject *submodule;
PyObject *mod;
- mod = PyModule_Create(&GPU_module_def);
+ mod = PyModule_Create(&pygpu_module_def);
PyModule_AddObject(mod, "types", (submodule = bpygpu_types_init()));
PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c
index 9fb7aea162a..0e4cc4d2219 100644
--- a/source/blender/python/gpu/gpu_py_batch.c
+++ b/source/blender/python/gpu/gpu_py_batch.c
@@ -48,7 +48,7 @@
/** \name Utility Functions
* \{ */
-static bool py_batch_is_program_or_error(BPyGPUBatch *self)
+static bool pygpu_batch_is_program_or_error(BPyGPUBatch *self)
{
if (!self->batch->shader) {
PyErr_SetString(PyExc_RuntimeError, "batch does not have any program assigned to it");
@@ -63,7 +63,7 @@ static bool py_batch_is_program_or_error(BPyGPUBatch *self)
/** \name GPUBatch Type
* \{ */
-static PyObject *py_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *pygpu_batch__tp_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{
BPYGPU_IS_INIT_OR_ERROR_OBJ;
@@ -121,7 +121,7 @@ static PyObject *py_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObje
return (PyObject *)ret;
}
-PyDoc_STRVAR(py_Batch_vertbuf_add_doc,
+PyDoc_STRVAR(pygpu_batch_vertbuf_add_doc,
".. method:: vertbuf_add(buf)\n"
"\n"
" Add another vertex buffer to the Batch.\n"
@@ -134,7 +134,7 @@ PyDoc_STRVAR(py_Batch_vertbuf_add_doc,
" :param buf: The vertex buffer that will be added to the batch.\n"
" :type buf: :class:`gpu.types.GPUVertBuf`\n"
);
-static PyObject *py_Batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_buf)
+static PyObject *pygpu_batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_buf)
{
if (!BPyGPUVertBuf_Check(py_buf)) {
PyErr_Format(PyExc_TypeError, "Expected a GPUVertBuf, got %s", Py_TYPE(py_buf)->tp_name);
@@ -167,7 +167,7 @@ static PyObject *py_Batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_buf)
}
PyDoc_STRVAR(
- py_Batch_program_set_doc,
+ 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"
@@ -177,7 +177,7 @@ PyDoc_STRVAR(
"\n"
" :param program: The program/shader the batch will use in future draw calls.\n"
" :type program: :class:`gpu.types.GPUShader`\n");
-static PyObject *py_Batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_shader)
+static PyObject *pygpu_batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_shader)
{
if (!BPyGPUShader_Check(py_shader)) {
PyErr_Format(PyExc_TypeError, "Expected a GPUShader, got %s", Py_TYPE(py_shader)->tp_name);
@@ -208,7 +208,7 @@ static PyObject *py_Batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_shader
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_Batch_draw_doc,
+PyDoc_STRVAR(pygpu_batch_draw_doc,
".. method:: draw(program=None)\n"
"\n"
" Run the drawing program with the parameters assigned to the batch.\n"
@@ -216,7 +216,7 @@ PyDoc_STRVAR(py_Batch_draw_doc,
" :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 *py_Batch_draw(BPyGPUBatch *self, PyObject *args)
+static PyObject *pygpu_batch_draw(BPyGPUBatch *self, PyObject *args)
{
BPyGPUShader *py_program = NULL;
@@ -224,7 +224,7 @@ static PyObject *py_Batch_draw(BPyGPUBatch *self, PyObject *args)
return NULL;
}
if (py_program == NULL) {
- if (!py_batch_is_program_or_error(self)) {
+ if (!pygpu_batch_is_program_or_error(self)) {
return NULL;
}
}
@@ -236,42 +236,42 @@ static PyObject *py_Batch_draw(BPyGPUBatch *self, PyObject *args)
Py_RETURN_NONE;
}
-static PyObject *py_Batch_program_use_begin(BPyGPUBatch *self)
+static PyObject *pygpu_batch_program_use_begin(BPyGPUBatch *self)
{
- if (!py_batch_is_program_or_error(self)) {
+ if (!pygpu_batch_is_program_or_error(self)) {
return NULL;
}
GPU_shader_bind(self->batch->shader);
Py_RETURN_NONE;
}
-static PyObject *py_Batch_program_use_end(BPyGPUBatch *self)
+static PyObject *pygpu_batch_program_use_end(BPyGPUBatch *self)
{
- if (!py_batch_is_program_or_error(self)) {
+ if (!pygpu_batch_is_program_or_error(self)) {
return NULL;
}
GPU_shader_unbind();
Py_RETURN_NONE;
}
-static struct PyMethodDef py_Batch_methods[] = {
- {"vertbuf_add", (PyCFunction)py_Batch_vertbuf_add, METH_O, py_Batch_vertbuf_add_doc},
- {"program_set", (PyCFunction)py_Batch_program_set, METH_O, py_Batch_program_set_doc},
- {"draw", (PyCFunction)py_Batch_draw, METH_VARARGS, py_Batch_draw_doc},
- {"_program_use_begin", (PyCFunction)py_Batch_program_use_begin, METH_NOARGS, ""},
- {"_program_use_end", (PyCFunction)py_Batch_program_use_end, METH_NOARGS, ""},
+static struct PyMethodDef pygpu_batch__tp_methods[] = {
+ {"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},
};
#ifdef USE_GPU_PY_REFERENCES
-static int py_Batch_traverse(BPyGPUBatch *self, visitproc visit, void *arg)
+static int pygpu_batch__tp_traverse(BPyGPUBatch *self, visitproc visit, void *arg)
{
Py_VISIT(self->references);
return 0;
}
-static int py_Batch_clear(BPyGPUBatch *self)
+static int pygpu_batch__tp_clear(BPyGPUBatch *self)
{
Py_CLEAR(self->references);
return 0;
@@ -279,14 +279,14 @@ static int py_Batch_clear(BPyGPUBatch *self)
#endif
-static void py_Batch_dealloc(BPyGPUBatch *self)
+static void pygpu_batch__tp_dealloc(BPyGPUBatch *self)
{
GPU_batch_discard(self->batch);
#ifdef USE_GPU_PY_REFERENCES
if (self->references) {
PyObject_GC_UnTrack(self);
- py_Batch_clear(self);
+ pygpu_batch__tp_clear(self);
Py_XDECREF(self->references);
}
#endif
@@ -295,7 +295,7 @@ static void py_Batch_dealloc(BPyGPUBatch *self)
}
PyDoc_STRVAR(
- py_gpu_batch_doc,
+ pygpu_batch__tp_doc,
".. class:: GPUBatch(type, buf, elem=None)\n"
"\n"
" Reusable container for drawable geometry.\n"
@@ -319,17 +319,17 @@ PyDoc_STRVAR(
PyTypeObject BPyGPUBatch_Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUBatch",
.tp_basicsize = sizeof(BPyGPUBatch),
- .tp_dealloc = (destructor)py_Batch_dealloc,
+ .tp_dealloc = (destructor)pygpu_batch__tp_dealloc,
#ifdef USE_GPU_PY_REFERENCES
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- .tp_doc = py_gpu_batch_doc,
- .tp_traverse = (traverseproc)py_Batch_traverse,
- .tp_clear = (inquiry)py_Batch_clear,
+ .tp_doc = pygpu_batch__tp_doc,
+ .tp_traverse = (traverseproc)pygpu_batch__tp_traverse,
+ .tp_clear = (inquiry)pygpu_batch__tp_clear,
#else
.tp_flags = Py_TPFLAGS_DEFAULT,
#endif
- .tp_methods = py_Batch_methods,
- .tp_new = py_Batch_new,
+ .tp_methods = pygpu_batch__tp_methods,
+ .tp_new = pygpu_batch__tp_new,
};
/** \} */
diff --git a/source/blender/python/gpu/gpu_py_element.c b/source/blender/python/gpu/gpu_py_element.c
index 0a1aecde986..f43338c42d2 100644
--- a/source/blender/python/gpu/gpu_py_element.c
+++ b/source/blender/python/gpu/gpu_py_element.c
@@ -39,7 +39,7 @@
/** \name IndexBuf Type
* \{ */
-static PyObject *py_IndexBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{
BPYGPU_IS_INIT_OR_ERROR_OBJ;
@@ -175,13 +175,13 @@ static PyObject *py_IndexBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyO
return BPyGPUIndexBuf_CreatePyObject(GPU_indexbuf_build(&builder));
}
-static void py_IndexBuf_dealloc(BPyGPUIndexBuf *self)
+static void pygpu_IndexBuf__tp_dealloc(BPyGPUIndexBuf *self)
{
GPU_indexbuf_discard(self->elem);
Py_TYPE(self)->tp_free(self);
}
-PyDoc_STRVAR(py_gpu_element_doc,
+PyDoc_STRVAR(pygpu_IndexBuf__tp_doc,
".. class:: GPUIndexBuf(type, seq)\n"
"\n"
" Contains an index buffer.\n"
@@ -199,10 +199,10 @@ PyDoc_STRVAR(py_gpu_element_doc,
PyTypeObject BPyGPUIndexBuf_Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUIndexBuf",
.tp_basicsize = sizeof(BPyGPUIndexBuf),
- .tp_dealloc = (destructor)py_IndexBuf_dealloc,
+ .tp_dealloc = (destructor)pygpu_IndexBuf__tp_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_doc = py_gpu_element_doc,
- .tp_new = py_IndexBuf_new,
+ .tp_doc = pygpu_IndexBuf__tp_doc,
+ .tp_new = pygpu_IndexBuf__tp_new,
};
/** \} */
diff --git a/source/blender/python/gpu/gpu_py_matrix.c b/source/blender/python/gpu/gpu_py_matrix.c
index 05e0a416b94..df7c82379b3 100644
--- a/source/blender/python/gpu/gpu_py_matrix.c
+++ b/source/blender/python/gpu/gpu_py_matrix.c
@@ -44,7 +44,7 @@
/** \name Helper Functions
* \{ */
-static bool py_stack_is_push_model_view_ok_or_error(void)
+static bool pygpu_stack_is_push_model_view_ok_or_error(void)
{
if (GPU_matrix_stack_level_get_model_view() >= GPU_PY_MATRIX_STACK_LEN) {
PyErr_SetString(
@@ -55,7 +55,7 @@ static bool py_stack_is_push_model_view_ok_or_error(void)
return true;
}
-static bool py_stack_is_push_projection_ok_or_error(void)
+static bool pygpu_stack_is_push_projection_ok_or_error(void)
{
if (GPU_matrix_stack_level_get_projection() >= GPU_PY_MATRIX_STACK_LEN) {
PyErr_SetString(
@@ -66,7 +66,7 @@ static bool py_stack_is_push_projection_ok_or_error(void)
return true;
}
-static bool py_stack_is_pop_model_view_ok_or_error(void)
+static bool pygpu_stack_is_pop_model_view_ok_or_error(void)
{
if (GPU_matrix_stack_level_get_model_view() == 0) {
PyErr_SetString(PyExc_RuntimeError, "Minimum model-view stack depth reached");
@@ -75,7 +75,7 @@ static bool py_stack_is_pop_model_view_ok_or_error(void)
return true;
}
-static bool py_stack_is_pop_projection_ok_or_error(void)
+static bool pygpu_stack_is_pop_projection_ok_or_error(void)
{
if (GPU_matrix_stack_level_get_projection() == 0) {
PyErr_SetString(PyExc_RuntimeError, "Minimum projection stack depth reached");
@@ -90,52 +90,52 @@ static bool py_stack_is_pop_projection_ok_or_error(void)
/** \name Manage Stack
* \{ */
-PyDoc_STRVAR(py_matrix_push_doc,
+PyDoc_STRVAR(pygpu_matrix_push_doc,
".. function:: push()\n"
"\n"
" Add to the model-view matrix stack.\n");
-static PyObject *py_matrix_push(PyObject *UNUSED(self))
+static PyObject *pygpu_matrix_push(PyObject *UNUSED(self))
{
- if (!py_stack_is_push_model_view_ok_or_error()) {
+ if (!pygpu_stack_is_push_model_view_ok_or_error()) {
return NULL;
}
GPU_matrix_push();
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_matrix_pop_doc,
+PyDoc_STRVAR(pygpu_matrix_pop_doc,
".. function:: pop()\n"
"\n"
" Remove the last model-view matrix from the stack.\n");
-static PyObject *py_matrix_pop(PyObject *UNUSED(self))
+static PyObject *pygpu_matrix_pop(PyObject *UNUSED(self))
{
- if (!py_stack_is_pop_model_view_ok_or_error()) {
+ if (!pygpu_stack_is_pop_model_view_ok_or_error()) {
return NULL;
}
GPU_matrix_pop();
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_matrix_push_projection_doc,
+PyDoc_STRVAR(pygpu_matrix_push_projection_doc,
".. function:: push_projection()\n"
"\n"
" Add to the projection matrix stack.\n");
-static PyObject *py_matrix_push_projection(PyObject *UNUSED(self))
+static PyObject *pygpu_matrix_push_projection(PyObject *UNUSED(self))
{
- if (!py_stack_is_push_projection_ok_or_error()) {
+ if (!pygpu_stack_is_push_projection_ok_or_error()) {
return NULL;
}
GPU_matrix_push_projection();
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_matrix_pop_projection_doc,
+PyDoc_STRVAR(pygpu_matrix_pop_projection_doc,
".. function:: pop_projection()\n"
"\n"
" Remove the last projection matrix from the stack.\n");
-static PyObject *py_matrix_pop_projection(PyObject *UNUSED(self))
+static PyObject *pygpu_matrix_pop_projection(PyObject *UNUSED(self))
{
- if (!py_stack_is_pop_projection_ok_or_error()) {
+ if (!pygpu_stack_is_pop_projection_ok_or_error()) {
return NULL;
}
GPU_matrix_pop_projection();
@@ -162,23 +162,23 @@ enum {
PYGPU_MATRIX_TYPE_PROJECTION = 2,
};
-static PyObject *py_matrix_stack_context_enter(BPyGPU_MatrixStackContext *self);
-static PyObject *py_matrix_stack_context_exit(BPyGPU_MatrixStackContext *self, PyObject *args);
+static PyObject *pygpu_matrix_stack_context_enter(BPyGPU_MatrixStackContext *self);
+static PyObject *pygpu_matrix_stack_context_exit(BPyGPU_MatrixStackContext *self, PyObject *args);
-static PyMethodDef py_matrix_stack_context_methods[] = {
- {"__enter__", (PyCFunction)py_matrix_stack_context_enter, METH_NOARGS},
- {"__exit__", (PyCFunction)py_matrix_stack_context_exit, METH_VARARGS},
+static PyMethodDef pygpu_matrix_stack_context__tp_methods[] = {
+ {"__enter__", (PyCFunction)pygpu_matrix_stack_context_enter, METH_NOARGS},
+ {"__exit__", (PyCFunction)pygpu_matrix_stack_context_exit, METH_VARARGS},
{NULL},
};
-static PyTypeObject BPyGPU_matrix_stack_context_Type = {
+static PyTypeObject PyGPUMatrixStackContext_Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUMatrixStackContext",
.tp_basicsize = sizeof(BPyGPU_MatrixStackContext),
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_methods = py_matrix_stack_context_methods,
+ .tp_methods = pygpu_matrix_stack_context__tp_methods,
};
-static PyObject *py_matrix_stack_context_enter(BPyGPU_MatrixStackContext *self)
+static PyObject *pygpu_matrix_stack_context_enter(BPyGPU_MatrixStackContext *self)
{
/* sanity - should never happen */
if (self->level != -1) {
@@ -187,14 +187,14 @@ static PyObject *py_matrix_stack_context_enter(BPyGPU_MatrixStackContext *self)
}
if (self->type == PYGPU_MATRIX_TYPE_MODEL_VIEW) {
- if (!py_stack_is_push_model_view_ok_or_error()) {
+ if (!pygpu_stack_is_push_model_view_ok_or_error()) {
return NULL;
}
GPU_matrix_push();
self->level = GPU_matrix_stack_level_get_model_view();
}
else if (self->type == PYGPU_MATRIX_TYPE_PROJECTION) {
- if (!py_stack_is_push_projection_ok_or_error()) {
+ if (!pygpu_stack_is_push_projection_ok_or_error()) {
return NULL;
}
GPU_matrix_push_projection();
@@ -206,8 +206,8 @@ static PyObject *py_matrix_stack_context_enter(BPyGPU_MatrixStackContext *self)
Py_RETURN_NONE;
}
-static PyObject *py_matrix_stack_context_exit(BPyGPU_MatrixStackContext *self,
- PyObject *UNUSED(args))
+static PyObject *pygpu_matrix_stack_context_exit(BPyGPU_MatrixStackContext *self,
+ PyObject *UNUSED(args))
{
/* sanity - should never happen */
if (self->level == -1) {
@@ -240,33 +240,33 @@ finally:
Py_RETURN_NONE;
}
-static PyObject *py_matrix_push_pop_impl(int type)
+static PyObject *pygpu_matrix_push_pop_impl(int type)
{
BPyGPU_MatrixStackContext *ret = PyObject_New(BPyGPU_MatrixStackContext,
- &BPyGPU_matrix_stack_context_Type);
+ &PyGPUMatrixStackContext_Type);
ret->type = type;
ret->level = -1;
return (PyObject *)ret;
}
PyDoc_STRVAR(
- py_matrix_push_pop_doc,
+ pygpu_matrix_push_pop_doc,
".. function:: push_pop()\n"
"\n"
" Context manager to ensure balanced push/pop calls, even in the case of an error.\n");
-static PyObject *py_matrix_push_pop(PyObject *UNUSED(self))
+static PyObject *pygpu_matrix_push_pop(PyObject *UNUSED(self))
{
- return py_matrix_push_pop_impl(PYGPU_MATRIX_TYPE_MODEL_VIEW);
+ return pygpu_matrix_push_pop_impl(PYGPU_MATRIX_TYPE_MODEL_VIEW);
}
PyDoc_STRVAR(
- py_matrix_push_pop_projection_doc,
+ pygpu_matrix_push_pop_projection_doc,
".. function:: push_pop_projection()\n"
"\n"
" Context manager to ensure balanced push/pop calls, even in the case of an error.\n");
-static PyObject *py_matrix_push_pop_projection(PyObject *UNUSED(self))
+static PyObject *pygpu_matrix_push_pop_projection(PyObject *UNUSED(self))
{
- return py_matrix_push_pop_impl(PYGPU_MATRIX_TYPE_PROJECTION);
+ return pygpu_matrix_push_pop_impl(PYGPU_MATRIX_TYPE_PROJECTION);
}
/** \} */
@@ -275,14 +275,14 @@ static PyObject *py_matrix_push_pop_projection(PyObject *UNUSED(self))
/** \name Manipulate State
* \{ */
-PyDoc_STRVAR(py_matrix_multiply_matrix_doc,
+PyDoc_STRVAR(pygpu_matrix_multiply_matrix_doc,
".. function:: multiply_matrix(matrix)\n"
"\n"
" Multiply the current stack matrix.\n"
"\n"
" :param matrix: A 4x4 matrix.\n"
" :type matrix: :class:`mathutils.Matrix`\n");
-static PyObject *py_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject *value)
+static PyObject *pygpu_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject *value)
{
MatrixObject *pymat;
if (!Matrix_Parse4x4(value, &pymat)) {
@@ -292,14 +292,14 @@ static PyObject *py_matrix_multiply_matrix(PyObject *UNUSED(self), PyObject *val
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_matrix_scale_doc,
+PyDoc_STRVAR(pygpu_matrix_scale_doc,
".. function:: scale(scale)\n"
"\n"
" Scale the current stack matrix.\n"
"\n"
" :param scale: Scale the current stack matrix.\n"
" :type scale: sequence of 2 or 3 floats\n");
-static PyObject *py_matrix_scale(PyObject *UNUSED(self), PyObject *value)
+static PyObject *pygpu_matrix_scale(PyObject *UNUSED(self), PyObject *value)
{
float scale[3];
int len;
@@ -316,12 +316,12 @@ static PyObject *py_matrix_scale(PyObject *UNUSED(self), PyObject *value)
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_matrix_scale_uniform_doc,
+PyDoc_STRVAR(pygpu_matrix_scale_uniform_doc,
".. function:: scale_uniform(scale)\n"
"\n"
" :param scale: Scale the current stack matrix.\n"
" :type scale: float\n");
-static PyObject *py_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *value)
+static PyObject *pygpu_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *value)
{
float scalar;
if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) {
@@ -332,14 +332,14 @@ static PyObject *py_matrix_scale_uniform(PyObject *UNUSED(self), PyObject *value
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_matrix_translate_doc,
+PyDoc_STRVAR(pygpu_matrix_translate_doc,
".. function:: translate(offset)\n"
"\n"
" Scale the current stack matrix.\n"
"\n"
" :param offset: Translate the current stack matrix.\n"
" :type offset: sequence of 2 or 3 floats\n");
-static PyObject *py_matrix_translate(PyObject *UNUSED(self), PyObject *value)
+static PyObject *pygpu_matrix_translate(PyObject *UNUSED(self), PyObject *value)
{
float offset[3];
int len;
@@ -362,34 +362,34 @@ static PyObject *py_matrix_translate(PyObject *UNUSED(self), PyObject *value)
/** \name Write State
* \{ */
-PyDoc_STRVAR(py_matrix_reset_doc,
+PyDoc_STRVAR(pygpu_matrix_reset_doc,
".. function:: reset()\n"
"\n"
" Empty stack and set to identity.\n");
-static PyObject *py_matrix_reset(PyObject *UNUSED(self))
+static PyObject *pygpu_matrix_reset(PyObject *UNUSED(self))
{
GPU_matrix_reset();
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_matrix_load_identity_doc,
+PyDoc_STRVAR(pygpu_matrix_load_identity_doc,
".. function:: load_identity()\n"
"\n"
" Empty stack and set to identity.\n");
-static PyObject *py_matrix_load_identity(PyObject *UNUSED(self))
+static PyObject *pygpu_matrix_load_identity(PyObject *UNUSED(self))
{
GPU_matrix_identity_set();
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_matrix_load_matrix_doc,
+PyDoc_STRVAR(pygpu_matrix_load_matrix_doc,
".. function:: load_matrix(matrix)\n"
"\n"
" Load a matrix into the stack.\n"
"\n"
" :param matrix: A 4x4 matrix.\n"
" :type matrix: :class:`mathutils.Matrix`\n");
-static PyObject *py_matrix_load_matrix(PyObject *UNUSED(self), PyObject *value)
+static PyObject *pygpu_matrix_load_matrix(PyObject *UNUSED(self), PyObject *value)
{
MatrixObject *pymat;
if (!Matrix_Parse4x4(value, &pymat)) {
@@ -399,14 +399,14 @@ static PyObject *py_matrix_load_matrix(PyObject *UNUSED(self), PyObject *value)
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_matrix_load_projection_matrix_doc,
+PyDoc_STRVAR(pygpu_matrix_load_projection_matrix_doc,
".. function:: load_projection_matrix(matrix)\n"
"\n"
" Load a projection matrix into the stack.\n"
"\n"
" :param matrix: A 4x4 matrix.\n"
" :type matrix: :class:`mathutils.Matrix`\n");
-static PyObject *py_matrix_load_projection_matrix(PyObject *UNUSED(self), PyObject *value)
+static PyObject *pygpu_matrix_load_projection_matrix(PyObject *UNUSED(self), PyObject *value)
{
MatrixObject *pymat;
if (!Matrix_Parse4x4(value, &pymat)) {
@@ -422,42 +422,42 @@ static PyObject *py_matrix_load_projection_matrix(PyObject *UNUSED(self), PyObje
/** \name Read State
* \{ */
-PyDoc_STRVAR(py_matrix_get_projection_matrix_doc,
+PyDoc_STRVAR(pygpu_matrix_get_projection_matrix_doc,
".. function:: get_projection_matrix()\n"
"\n"
" Return a copy of the projection matrix.\n"
"\n"
" :return: A 4x4 projection matrix.\n"
" :rtype: :class:`mathutils.Matrix`\n");
-static PyObject *py_matrix_get_projection_matrix(PyObject *UNUSED(self))
+static PyObject *pygpu_matrix_get_projection_matrix(PyObject *UNUSED(self))
{
float matrix[4][4];
GPU_matrix_projection_get(matrix);
return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL);
}
-PyDoc_STRVAR(py_matrix_get_model_view_matrix_doc,
+PyDoc_STRVAR(pygpu_matrix_get_model_view_matrix_doc,
".. function:: get_model_view_matrix()\n"
"\n"
" Return a copy of the model-view matrix.\n"
"\n"
" :return: A 4x4 view matrix.\n"
" :rtype: :class:`mathutils.Matrix`\n");
-static PyObject *py_matrix_get_model_view_matrix(PyObject *UNUSED(self))
+static PyObject *pygpu_matrix_get_model_view_matrix(PyObject *UNUSED(self))
{
float matrix[4][4];
GPU_matrix_model_view_get(matrix);
return Matrix_CreatePyObject(&matrix[0][0], 4, 4, NULL);
}
-PyDoc_STRVAR(py_matrix_get_normal_matrix_doc,
+PyDoc_STRVAR(pygpu_matrix_get_normal_matrix_doc,
".. function:: get_normal_matrix()\n"
"\n"
" Return a copy of the normal matrix.\n"
"\n"
" :return: A 3x3 normal matrix.\n"
" :rtype: :class:`mathutils.Matrix`\n");
-static PyObject *py_matrix_get_normal_matrix(PyObject *UNUSED(self))
+static PyObject *pygpu_matrix_get_normal_matrix(PyObject *UNUSED(self))
{
float matrix[3][3];
GPU_matrix_normal_get(matrix);
@@ -470,87 +470,90 @@ static PyObject *py_matrix_get_normal_matrix(PyObject *UNUSED(self))
/** \name Module
* \{ */
-static struct PyMethodDef py_matrix_methods[] = {
+static struct PyMethodDef pygpu_matrix__tp_methods[] = {
/* Manage Stack */
- {"push", (PyCFunction)py_matrix_push, METH_NOARGS, py_matrix_push_doc},
- {"pop", (PyCFunction)py_matrix_pop, METH_NOARGS, py_matrix_pop_doc},
+ {"push", (PyCFunction)pygpu_matrix_push, METH_NOARGS, pygpu_matrix_push_doc},
+ {"pop", (PyCFunction)pygpu_matrix_pop, METH_NOARGS, pygpu_matrix_pop_doc},
{"push_projection",
- (PyCFunction)py_matrix_push_projection,
+ (PyCFunction)pygpu_matrix_push_projection,
METH_NOARGS,
- py_matrix_push_projection_doc},
+ pygpu_matrix_push_projection_doc},
{"pop_projection",
- (PyCFunction)py_matrix_pop_projection,
+ (PyCFunction)pygpu_matrix_pop_projection,
METH_NOARGS,
- py_matrix_pop_projection_doc},
+ pygpu_matrix_pop_projection_doc},
/* Stack (Context Manager) */
- {"push_pop", (PyCFunction)py_matrix_push_pop, METH_NOARGS, py_matrix_push_pop_doc},
+ {"push_pop", (PyCFunction)pygpu_matrix_push_pop, METH_NOARGS, pygpu_matrix_push_pop_doc},
{"push_pop_projection",
- (PyCFunction)py_matrix_push_pop_projection,
+ (PyCFunction)pygpu_matrix_push_pop_projection,
METH_NOARGS,
- py_matrix_push_pop_projection_doc},
+ pygpu_matrix_push_pop_projection_doc},
/* Manipulate State */
{"multiply_matrix",
- (PyCFunction)py_matrix_multiply_matrix,
+ (PyCFunction)pygpu_matrix_multiply_matrix,
METH_O,
- py_matrix_multiply_matrix_doc},
- {"scale", (PyCFunction)py_matrix_scale, METH_O, py_matrix_scale_doc},
- {"scale_uniform", (PyCFunction)py_matrix_scale_uniform, METH_O, py_matrix_scale_uniform_doc},
- {"translate", (PyCFunction)py_matrix_translate, METH_O, py_matrix_translate_doc},
+ pygpu_matrix_multiply_matrix_doc},
+ {"scale", (PyCFunction)pygpu_matrix_scale, METH_O, pygpu_matrix_scale_doc},
+ {"scale_uniform",
+ (PyCFunction)pygpu_matrix_scale_uniform,
+ METH_O,
+ pygpu_matrix_scale_uniform_doc},
+ {"translate", (PyCFunction)pygpu_matrix_translate, METH_O, pygpu_matrix_translate_doc},
/* TODO */
#if 0
- {"rotate", (PyCFunction)py_matrix_rotate, METH_O, py_matrix_rotate_doc},
- {"rotate_axis", (PyCFunction)py_matrix_rotate_axis, METH_O, py_matrix_rotate_axis_doc},
- {"look_at", (PyCFunction)py_matrix_look_at, METH_O, py_matrix_look_at_doc},
+ {"rotate", (PyCFunction)pygpu_matrix_rotate, METH_O, pygpu_matrix_rotate_doc},
+ {"rotate_axis", (PyCFunction)pygpu_matrix_rotate_axis, METH_O, pygpu_matrix_rotate_axis_doc},
+ {"look_at", (PyCFunction)pygpu_matrix_look_at, METH_O, pygpu_matrix_look_at_doc},
#endif
/* Write State */
- {"reset", (PyCFunction)py_matrix_reset, METH_NOARGS, py_matrix_reset_doc},
+ {"reset", (PyCFunction)pygpu_matrix_reset, METH_NOARGS, pygpu_matrix_reset_doc},
{"load_identity",
- (PyCFunction)py_matrix_load_identity,
+ (PyCFunction)pygpu_matrix_load_identity,
METH_NOARGS,
- py_matrix_load_identity_doc},
- {"load_matrix", (PyCFunction)py_matrix_load_matrix, METH_O, py_matrix_load_matrix_doc},
+ pygpu_matrix_load_identity_doc},
+ {"load_matrix", (PyCFunction)pygpu_matrix_load_matrix, METH_O, pygpu_matrix_load_matrix_doc},
{"load_projection_matrix",
- (PyCFunction)py_matrix_load_projection_matrix,
+ (PyCFunction)pygpu_matrix_load_projection_matrix,
METH_O,
- py_matrix_load_projection_matrix_doc},
+ pygpu_matrix_load_projection_matrix_doc},
/* Read State */
{"get_projection_matrix",
- (PyCFunction)py_matrix_get_projection_matrix,
+ (PyCFunction)pygpu_matrix_get_projection_matrix,
METH_NOARGS,
- py_matrix_get_projection_matrix_doc},
+ pygpu_matrix_get_projection_matrix_doc},
{"get_model_view_matrix",
- (PyCFunction)py_matrix_get_model_view_matrix,
+ (PyCFunction)pygpu_matrix_get_model_view_matrix,
METH_NOARGS,
- py_matrix_get_model_view_matrix_doc},
+ pygpu_matrix_get_model_view_matrix_doc},
{"get_normal_matrix",
- (PyCFunction)py_matrix_get_normal_matrix,
+ (PyCFunction)pygpu_matrix_get_normal_matrix,
METH_NOARGS,
- py_matrix_get_normal_matrix_doc},
+ pygpu_matrix_get_normal_matrix_doc},
{NULL, NULL, 0, NULL},
};
-PyDoc_STRVAR(py_matrix_doc, "This module provides access to the matrix stack.");
-static PyModuleDef py_matrix_module_def = {
+PyDoc_STRVAR(pygpu_matrix__tp_doc, "This module provides access to the matrix stack.");
+static PyModuleDef pygpu_matrix_module_def = {
PyModuleDef_HEAD_INIT,
.m_name = "gpu.matrix",
- .m_doc = py_matrix_doc,
- .m_methods = py_matrix_methods,
+ .m_doc = pygpu_matrix__tp_doc,
+ .m_methods = pygpu_matrix__tp_methods,
};
PyObject *bpygpu_matrix_init(void)
{
PyObject *submodule;
- submodule = PyModule_Create(&py_matrix_module_def);
+ submodule = PyModule_Create(&pygpu_matrix_module_def);
- if (PyType_Ready(&BPyGPU_matrix_stack_context_Type) < 0) {
+ if (PyType_Ready(&PyGPUMatrixStackContext_Type) < 0) {
return NULL;
}
diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c
index 8d2df826722..2431a1fca5b 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.c
+++ b/source/blender/python/gpu/gpu_py_offscreen.c
@@ -58,9 +58,9 @@
/** \name GPUOffScreen Common Utilities
* \{ */
-static int py_offscreen_valid_check(BPyGPUOffScreen *py_ofs)
+static int pygpu_offscreen_valid_check(BPyGPUOffScreen *pygpu_ofs)
{
- if (UNLIKELY(py_ofs->ofs == NULL)) {
+ if (UNLIKELY(pygpu_ofs->ofs == NULL)) {
PyErr_SetString(PyExc_ReferenceError, "GPU offscreen was freed, no further access is valid");
return -1;
}
@@ -69,7 +69,7 @@ static int py_offscreen_valid_check(BPyGPUOffScreen *py_ofs)
#define BPY_GPU_OFFSCREEN_CHECK_OBJ(bpygpu) \
{ \
- if (UNLIKELY(py_offscreen_valid_check(bpygpu) == -1)) { \
+ if (UNLIKELY(pygpu_offscreen_valid_check(bpygpu) == -1)) { \
return NULL; \
} \
} \
@@ -81,7 +81,7 @@ static int py_offscreen_valid_check(BPyGPUOffScreen *py_ofs)
/** \name GPUOffscreen Type
* \{ */
-static PyObject *py_offscreen_new(PyTypeObject *UNUSED(self), PyObject *args, PyObject *kwds)
+static PyObject *pygpu_offscreen_new(PyTypeObject *UNUSED(self), PyObject *args, PyObject *kwds)
{
BPYGPU_IS_INIT_OR_ERROR_OBJ;
@@ -112,23 +112,23 @@ static PyObject *py_offscreen_new(PyTypeObject *UNUSED(self), PyObject *args, Py
return BPyGPUOffScreen_CreatePyObject(ofs);
}
-PyDoc_STRVAR(py_offscreen_width_doc, "Width of the texture.\n\n:type: `int`");
-static PyObject *py_offscreen_width_get(BPyGPUOffScreen *self, void *UNUSED(type))
+PyDoc_STRVAR(pygpu_offscreen_width_doc, "Width of the texture.\n\n:type: `int`");
+static PyObject *pygpu_offscreen_width_get(BPyGPUOffScreen *self, void *UNUSED(type))
{
BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
return PyLong_FromLong(GPU_offscreen_width(self->ofs));
}
-PyDoc_STRVAR(py_offscreen_height_doc, "Height of the texture.\n\n:type: `int`");
-static PyObject *py_offscreen_height_get(BPyGPUOffScreen *self, void *UNUSED(type))
+PyDoc_STRVAR(pygpu_offscreen_height_doc, "Height of the texture.\n\n:type: `int`");
+static PyObject *pygpu_offscreen_height_get(BPyGPUOffScreen *self, void *UNUSED(type))
{
BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
return PyLong_FromLong(GPU_offscreen_height(self->ofs));
}
-PyDoc_STRVAR(py_offscreen_color_texture_doc,
+PyDoc_STRVAR(pygpu_offscreen_color_texture_doc,
"OpenGL bindcode for the color texture.\n\n:type: `int`");
-static PyObject *py_offscreen_color_texture_get(BPyGPUOffScreen *self, void *UNUSED(type))
+static PyObject *pygpu_offscreen_color_texture_get(BPyGPUOffScreen *self, void *UNUSED(type))
{
BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
GPUTexture *texture = GPU_offscreen_color_texture(self->ofs);
@@ -136,7 +136,7 @@ static PyObject *py_offscreen_color_texture_get(BPyGPUOffScreen *self, void *UNU
}
PyDoc_STRVAR(
- py_offscreen_bind_doc,
+ pygpu_offscreen_bind_doc,
".. method:: bind(save=True)\n"
"\n"
" Bind the offscreen object.\n"
@@ -145,7 +145,7 @@ PyDoc_STRVAR(
"\n"
" :arg save: Save the current OpenGL state, so that it can be restored when unbinding.\n"
" :type save: `bool`\n");
-static PyObject *py_offscreen_bind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
+static PyObject *pygpu_offscreen_bind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
{
BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
bool save = true;
@@ -165,7 +165,7 @@ static PyObject *py_offscreen_bind(BPyGPUOffScreen *self, PyObject *args, PyObje
return (PyObject *)self;
}
-PyDoc_STRVAR(py_offscreen_unbind_doc,
+PyDoc_STRVAR(pygpu_offscreen_unbind_doc,
".. method:: unbind(restore=True)\n"
"\n"
" Unbind the offscreen object.\n"
@@ -173,7 +173,7 @@ PyDoc_STRVAR(py_offscreen_unbind_doc,
" :arg restore: Restore the OpenGL state, can only be used when the state has been "
"saved before.\n"
" :type restore: `bool`\n");
-static PyObject *py_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
+static PyObject *pygpu_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
{
bool restore = true;
@@ -191,7 +191,7 @@ static PyObject *py_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, PyOb
}
PyDoc_STRVAR(
- py_offscreen_draw_view3d_doc,
+ pygpu_offscreen_draw_view3d_doc,
".. method:: draw_view3d(scene, view_layer, view3d, region, view_matrix, projection_matrix)\n"
"\n"
" Draw the 3d viewport in the offscreen object.\n"
@@ -208,10 +208,10 @@ PyDoc_STRVAR(
" :type view_matrix: :class:`mathutils.Matrix`\n"
" :arg projection_matrix: Projection Matrix (e.g. ``camera.calc_matrix_camera(...)``).\n"
" :type projection_matrix: :class:`mathutils.Matrix`\n");
-static PyObject *py_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
+static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
{
- MatrixObject *py_mat_view, *py_mat_projection;
- PyObject *py_scene, *py_view_layer, *py_region, *py_view3d;
+ MatrixObject *pygpu_mat_view, *pygpu_mat_projection;
+ PyObject *pygpu_scene, *pygpu_view_layer, *pygpu_region, *pygpu_view3d;
struct Depsgraph *depsgraph;
struct Scene *scene;
@@ -228,18 +228,18 @@ static PyObject *py_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *args,
if (!_PyArg_ParseTupleAndKeywordsFast(args,
kwds,
&_parser,
- &py_scene,
- &py_view_layer,
- &py_view3d,
- &py_region,
+ &pygpu_scene,
+ &pygpu_view_layer,
+ &pygpu_view3d,
+ &pygpu_region,
Matrix_Parse4x4,
- &py_mat_view,
+ &pygpu_mat_view,
Matrix_Parse4x4,
- &py_mat_projection) ||
- (!(scene = PyC_RNA_AsPointer(py_scene, "Scene")) ||
- !(view_layer = PyC_RNA_AsPointer(py_view_layer, "ViewLayer")) ||
- !(v3d = PyC_RNA_AsPointer(py_view3d, "SpaceView3D")) ||
- !(region = PyC_RNA_AsPointer(py_region, "Region")))) {
+ &pygpu_mat_projection) ||
+ (!(scene = PyC_RNA_AsPointer(pygpu_scene, "Scene")) ||
+ !(view_layer = PyC_RNA_AsPointer(pygpu_view_layer, "ViewLayer")) ||
+ !(v3d = PyC_RNA_AsPointer(pygpu_view3d, "SpaceView3D")) ||
+ !(region = PyC_RNA_AsPointer(pygpu_region, "Region")))) {
return NULL;
}
@@ -262,8 +262,8 @@ static PyObject *py_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *args,
region,
GPU_offscreen_width(self->ofs),
GPU_offscreen_height(self->ofs),
- (float(*)[4])py_mat_view->matrix,
- (float(*)[4])py_mat_projection->matrix,
+ (float(*)[4])pygpu_mat_view->matrix,
+ (float(*)[4])pygpu_mat_projection->matrix,
true,
true,
"",
@@ -281,12 +281,12 @@ static PyObject *py_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *args,
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_offscreen_free_doc,
+PyDoc_STRVAR(pygpu_offscreen_free_doc,
".. method:: free()\n"
"\n"
" Free the offscreen object.\n"
" The framebuffer, texture and render objects will no longer be accessible.\n");
-static PyObject *py_offscreen_free(BPyGPUOffScreen *self)
+static PyObject *pygpu_offscreen_free(BPyGPUOffScreen *self)
{
BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
@@ -295,12 +295,12 @@ static PyObject *py_offscreen_free(BPyGPUOffScreen *self)
Py_RETURN_NONE;
}
-static PyObject *py_offscreen_bind_context_enter(BPyGPUOffScreen *UNUSED(self))
+static PyObject *pygpu_offscreen_bind_context_enter(BPyGPUOffScreen *UNUSED(self))
{
Py_RETURN_NONE;
}
-static PyObject *py_offscreen_bind_context_exit(BPyGPUOffScreen *self, PyObject *UNUSED(args))
+static PyObject *pygpu_offscreen_bind_context_exit(BPyGPUOffScreen *self, PyObject *UNUSED(args))
{
GPU_offscreen_unbind(self->ofs, self->is_saved);
Py_RETURN_NONE;
@@ -314,34 +314,37 @@ static void BPyGPUOffScreen__tp_dealloc(BPyGPUOffScreen *self)
Py_TYPE(self)->tp_free((PyObject *)self);
}
-static PyGetSetDef py_offscreen_getseters[] = {
+static PyGetSetDef pygpu_offscreen_getseters[] = {
{"color_texture",
- (getter)py_offscreen_color_texture_get,
+ (getter)pygpu_offscreen_color_texture_get,
(setter)NULL,
- py_offscreen_color_texture_doc,
+ pygpu_offscreen_color_texture_doc,
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},
+ {"width", (getter)pygpu_offscreen_width_get, (setter)NULL, pygpu_offscreen_width_doc, NULL},
+ {"height", (getter)pygpu_offscreen_height_get, (setter)NULL, pygpu_offscreen_height_doc, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
-static struct PyMethodDef py_offscreen_methods[] = {
- {"bind", (PyCFunction)py_offscreen_bind, METH_VARARGS | METH_KEYWORDS, py_offscreen_bind_doc},
+static struct PyMethodDef pygpu_offscreen_methods[] = {
+ {"bind",
+ (PyCFunction)pygpu_offscreen_bind,
+ METH_VARARGS | METH_KEYWORDS,
+ pygpu_offscreen_bind_doc},
{"unbind",
- (PyCFunction)py_offscreen_unbind,
+ (PyCFunction)pygpu_offscreen_unbind,
METH_VARARGS | METH_KEYWORDS,
- py_offscreen_unbind_doc},
+ pygpu_offscreen_unbind_doc},
{"draw_view3d",
- (PyCFunction)py_offscreen_draw_view3d,
+ (PyCFunction)pygpu_offscreen_draw_view3d,
METH_VARARGS | METH_KEYWORDS,
- py_offscreen_draw_view3d_doc},
- {"free", (PyCFunction)py_offscreen_free, METH_NOARGS, py_offscreen_free_doc},
- {"__enter__", (PyCFunction)py_offscreen_bind_context_enter, METH_NOARGS},
- {"__exit__", (PyCFunction)py_offscreen_bind_context_exit, METH_VARARGS},
+ pygpu_offscreen_draw_view3d_doc},
+ {"free", (PyCFunction)pygpu_offscreen_free, METH_NOARGS, pygpu_offscreen_free_doc},
+ {"__enter__", (PyCFunction)pygpu_offscreen_bind_context_enter, METH_NOARGS},
+ {"__exit__", (PyCFunction)pygpu_offscreen_bind_context_exit, METH_VARARGS},
{NULL, NULL, 0, NULL},
};
-PyDoc_STRVAR(py_offscreen_doc,
+PyDoc_STRVAR(pygpu_offscreen_doc,
".. class:: GPUOffScreen(width, height)\n"
"\n"
" This object gives access to off screen buffers.\n"
@@ -355,10 +358,10 @@ PyTypeObject BPyGPUOffScreen_Type = {
.tp_basicsize = sizeof(BPyGPUOffScreen),
.tp_dealloc = (destructor)BPyGPUOffScreen__tp_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_doc = py_offscreen_doc,
- .tp_methods = py_offscreen_methods,
- .tp_getset = py_offscreen_getseters,
- .tp_new = py_offscreen_new,
+ .tp_doc = pygpu_offscreen_doc,
+ .tp_methods = pygpu_offscreen_methods,
+ .tp_getset = pygpu_offscreen_getseters,
+ .tp_new = pygpu_offscreen_new,
};
/** \} */
diff --git a/source/blender/python/gpu/gpu_py_select.c b/source/blender/python/gpu/gpu_py_select.c
index e92ef9f7504..b72aca6a792 100644
--- a/source/blender/python/gpu/gpu_py_select.c
+++ b/source/blender/python/gpu/gpu_py_select.c
@@ -40,14 +40,14 @@
/** \name Methods
* \{ */
-PyDoc_STRVAR(py_select_load_id_doc,
+PyDoc_STRVAR(pygpu_select_load_id_doc,
".. function:: load_id(id)\n"
"\n"
" Set the selection ID.\n"
"\n"
" :param id: Number (32-bit uint).\n"
" :type select: int\n");
-static PyObject *py_select_load_id(PyObject *UNUSED(self), PyObject *value)
+static PyObject *pygpu_select_load_id(PyObject *UNUSED(self), PyObject *value)
{
uint id;
if ((id = PyC_Long_AsU32(value)) == (uint)-1) {
@@ -62,25 +62,25 @@ static PyObject *py_select_load_id(PyObject *UNUSED(self), PyObject *value)
/** \name Module
* \{ */
-static struct PyMethodDef py_select_methods[] = {
+static struct PyMethodDef pygpu_select__tp_methods[] = {
/* Manage Stack */
- {"load_id", (PyCFunction)py_select_load_id, METH_O, py_select_load_id_doc},
+ {"load_id", (PyCFunction)pygpu_select_load_id, METH_O, pygpu_select_load_id_doc},
{NULL, NULL, 0, NULL},
};
-PyDoc_STRVAR(py_select_doc, "This module provides access to selection.");
-static PyModuleDef py_select_module_def = {
+PyDoc_STRVAR(pygpu_select__tp_doc, "This module provides access to selection.");
+static PyModuleDef pygpu_select_module_def = {
PyModuleDef_HEAD_INIT,
.m_name = "gpu.select",
- .m_doc = py_select_doc,
- .m_methods = py_select_methods,
+ .m_doc = pygpu_select__tp_doc,
+ .m_methods = pygpu_select__tp_methods,
};
PyObject *bpygpu_select_init(void)
{
PyObject *submodule;
- submodule = PyModule_Create(&py_select_module_def);
+ submodule = PyModule_Create(&pygpu_select_module_def);
return submodule;
}
diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c
index e5ffbd5e9e3..ddc3ccd9827 100644
--- a/source/blender/python/gpu/gpu_py_shader.c
+++ b/source/blender/python/gpu/gpu_py_shader.c
@@ -32,14 +32,15 @@
#include "../mathutils/mathutils.h"
#include "gpu_py_api.h"
-#include "gpu_py_shader.h" /* own include */
#include "gpu_py_vertex_format.h"
+#include "gpu_py_shader.h" /* own include */
+
/* -------------------------------------------------------------------- */
/** \name Enum Conversion.
* \{ */
-static const struct PyC_StringEnumItems pygpu_bultinshader_items[] = {
+static const struct PyC_StringEnumItems pygpu_shader_builtin_items[] = {
{GPU_SHADER_2D_UNIFORM_COLOR, "2D_UNIFORM_COLOR"},
{GPU_SHADER_2D_FLAT_COLOR, "2D_FLAT_COLOR"},
{GPU_SHADER_2D_SMOOTH_COLOR, "2D_SMOOTH_COLOR"},
@@ -51,7 +52,9 @@ static const struct PyC_StringEnumItems pygpu_bultinshader_items[] = {
{0, NULL},
};
-static int py_uniform_location_get(GPUShader *shader, const char *name, const char *error_prefix)
+static int pygpu_shader_uniform_location_get(GPUShader *shader,
+ const char *name,
+ const char *error_prefix)
{
const int uniform = GPU_shader_get_uniform(shader, name);
@@ -68,7 +71,7 @@ static int py_uniform_location_get(GPUShader *shader, const char *name, const ch
/** \name Shader Type
* \{ */
-static PyObject *py_shader_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *pygpu_shader__tp_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{
BPYGPU_IS_INIT_OR_ERROR_OBJ;
@@ -107,17 +110,17 @@ static PyObject *py_shader_new(PyTypeObject *UNUSED(type), PyObject *args, PyObj
}
PyDoc_STRVAR(
- py_shader_bind_doc,
+ pygpu_shader_bind_doc,
".. method:: bind()\n"
"\n"
" Bind the shader object. Required to be able to change uniforms of this shader.\n");
-static PyObject *py_shader_bind(BPyGPUShader *self)
+static PyObject *pygpu_shader_bind(BPyGPUShader *self)
{
GPU_shader_bind(self->shader);
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_shader_uniform_from_name_doc,
+PyDoc_STRVAR(pygpu_shader_uniform_from_name_doc,
".. method:: uniform_from_name(name)\n"
"\n"
" Get uniform location by name.\n"
@@ -126,14 +129,15 @@ PyDoc_STRVAR(py_shader_uniform_from_name_doc,
" :type name: `str`\n"
" :return: Location of the uniform variable.\n"
" :rtype: `int`\n");
-static PyObject *py_shader_uniform_from_name(BPyGPUShader *self, PyObject *arg)
+static PyObject *pygpu_shader_uniform_from_name(BPyGPUShader *self, PyObject *arg)
{
const char *name = PyUnicode_AsUTF8(arg);
if (name == NULL) {
return NULL;
}
- const int uniform = py_uniform_location_get(self->shader, name, "GPUShader.get_uniform");
+ const int uniform = pygpu_shader_uniform_location_get(
+ self->shader, name, "GPUShader.get_uniform");
if (uniform == -1) {
return NULL;
@@ -143,7 +147,7 @@ static PyObject *py_shader_uniform_from_name(BPyGPUShader *self, PyObject *arg)
}
PyDoc_STRVAR(
- py_shader_uniform_block_from_name_doc,
+ pygpu_shader_uniform_block_from_name_doc,
".. method:: uniform_block_from_name(name)\n"
"\n"
" Get uniform block location by name.\n"
@@ -152,7 +156,7 @@ PyDoc_STRVAR(
" :type name: `str`\n"
" :return: The location of the uniform block variable.\n"
" :rtype: `int`\n");
-static PyObject *py_shader_uniform_block_from_name(BPyGPUShader *self, PyObject *arg)
+static PyObject *pygpu_shader_uniform_block_from_name(BPyGPUShader *self, PyObject *arg)
{
const char *name = PyUnicode_AsUTF8(arg);
if (name == NULL) {
@@ -169,12 +173,12 @@ static PyObject *py_shader_uniform_block_from_name(BPyGPUShader *self, PyObject
return PyLong_FromLong(uniform);
}
-static bool py_shader_uniform_vector_impl(PyObject *args,
- int elem_size,
- int *r_location,
- int *r_length,
- int *r_count,
- Py_buffer *r_pybuffer)
+static bool pygpu_shader_uniform_vector_impl(PyObject *args,
+ int elem_size,
+ int *r_location,
+ int *r_length,
+ int *r_count,
+ Py_buffer *r_pybuffer)
{
PyObject *buffer;
@@ -197,7 +201,7 @@ static bool py_shader_uniform_vector_impl(PyObject *args,
return true;
}
-PyDoc_STRVAR(py_shader_uniform_vector_float_doc,
+PyDoc_STRVAR(pygpu_shader_uniform_vector_float_doc,
".. method:: uniform_vector_float(location, buffer, length, count)\n"
"\n"
" Set the buffer to fill the uniform.\n"
@@ -217,13 +221,14 @@ PyDoc_STRVAR(py_shader_uniform_vector_float_doc,
" :param count: Specifies the number of elements, vector or matrices that are to "
"be modified.\n"
" :type count: int\n");
-static PyObject *py_shader_uniform_vector_float(BPyGPUShader *self, PyObject *args)
+static PyObject *pygpu_shader_uniform_vector_float(BPyGPUShader *self, PyObject *args)
{
int location, length, count;
Py_buffer pybuffer;
- if (!py_shader_uniform_vector_impl(args, sizeof(float), &location, &length, &count, &pybuffer)) {
+ if (!pygpu_shader_uniform_vector_impl(
+ args, sizeof(float), &location, &length, &count, &pybuffer)) {
return NULL;
}
@@ -234,17 +239,18 @@ static PyObject *py_shader_uniform_vector_float(BPyGPUShader *self, PyObject *ar
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_shader_uniform_vector_int_doc,
+PyDoc_STRVAR(pygpu_shader_uniform_vector_int_doc,
".. method:: uniform_vector_int(location, buffer, length, count)\n"
"\n"
" See GPUShader.uniform_vector_float(...) description.\n");
-static PyObject *py_shader_uniform_vector_int(BPyGPUShader *self, PyObject *args)
+static PyObject *pygpu_shader_uniform_vector_int(BPyGPUShader *self, PyObject *args)
{
int location, length, count;
Py_buffer pybuffer;
- if (!py_shader_uniform_vector_impl(args, sizeof(int), &location, &length, &count, &pybuffer)) {
+ if (!pygpu_shader_uniform_vector_impl(
+ args, sizeof(int), &location, &length, &count, &pybuffer)) {
return NULL;
}
@@ -255,7 +261,7 @@ static PyObject *py_shader_uniform_vector_int(BPyGPUShader *self, PyObject *args
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_shader_uniform_bool_doc,
+PyDoc_STRVAR(pygpu_shader_uniform_bool_doc,
".. method:: uniform_bool(name, seq)\n"
"\n"
" Specify the value of a uniform variable for the current program object.\n"
@@ -264,7 +270,7 @@ PyDoc_STRVAR(py_shader_uniform_bool_doc,
" :type name: str\n"
" :param seq: Value that will be used to update the specified uniform variable.\n"
" :type seq: sequence of bools\n");
-static PyObject *py_shader_uniform_bool(BPyGPUShader *self, PyObject *args)
+static PyObject *pygpu_shader_uniform_bool(BPyGPUShader *self, PyObject *args)
{
const char *error_prefix = "GPUShader.uniform_bool";
@@ -308,7 +314,7 @@ static PyObject *py_shader_uniform_bool(BPyGPUShader *self, PyObject *args)
return NULL;
}
- const int location = py_uniform_location_get(self->shader, params.id, error_prefix);
+ const int location = pygpu_shader_uniform_location_get(self->shader, params.id, error_prefix);
if (location == -1) {
return NULL;
@@ -319,7 +325,7 @@ static PyObject *py_shader_uniform_bool(BPyGPUShader *self, PyObject *args)
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_shader_uniform_float_doc,
+PyDoc_STRVAR(pygpu_shader_uniform_float_doc,
".. method:: uniform_float(name, value)\n"
"\n"
" Specify the value of a uniform variable for the current program object.\n"
@@ -328,7 +334,7 @@ PyDoc_STRVAR(py_shader_uniform_float_doc,
" :type name: str\n"
" :param value: Value that will be used to update the specified uniform variable.\n"
" :type value: single number or sequence of numbers\n");
-static PyObject *py_shader_uniform_float(BPyGPUShader *self, PyObject *args)
+static PyObject *pygpu_shader_uniform_float(BPyGPUShader *self, PyObject *args)
{
const char *error_prefix = "GPUShader.uniform_float";
@@ -377,7 +383,7 @@ static PyObject *py_shader_uniform_float(BPyGPUShader *self, PyObject *args)
return NULL;
}
- const int location = py_uniform_location_get(self->shader, params.id, error_prefix);
+ const int location = pygpu_shader_uniform_location_get(self->shader, params.id, error_prefix);
if (location == -1) {
return NULL;
@@ -388,7 +394,7 @@ static PyObject *py_shader_uniform_float(BPyGPUShader *self, PyObject *args)
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_shader_uniform_int_doc,
+PyDoc_STRVAR(pygpu_shader_uniform_int_doc,
".. method:: uniform_int(name, seq)\n"
"\n"
" Specify the value of a uniform variable for the current program object.\n"
@@ -397,7 +403,7 @@ PyDoc_STRVAR(py_shader_uniform_int_doc,
" :type name: str\n"
" :param seq: Value that will be used to update the specified uniform variable.\n"
" :type seq: sequence of numbers\n");
-static PyObject *py_shader_uniform_int(BPyGPUShader *self, PyObject *args)
+static PyObject *pygpu_shader_uniform_int(BPyGPUShader *self, PyObject *args)
{
const char *error_prefix = "GPUShader.uniform_int";
@@ -447,7 +453,7 @@ static PyObject *py_shader_uniform_int(BPyGPUShader *self, PyObject *args)
return NULL;
}
- const int location = py_uniform_location_get(self->shader, params.id, error_prefix);
+ const int location = pygpu_shader_uniform_location_get(self->shader, params.id, error_prefix);
if (location == -1) {
return NULL;
@@ -459,7 +465,7 @@ static PyObject *py_shader_uniform_int(BPyGPUShader *self, PyObject *args)
}
PyDoc_STRVAR(
- py_shader_attr_from_name_doc,
+ pygpu_shader_attr_from_name_doc,
".. method:: attr_from_name(name)\n"
"\n"
" Get attribute location by name.\n"
@@ -468,7 +474,7 @@ PyDoc_STRVAR(
" :type name: str\n"
" :return: The location of an attribute variable.\n"
" :rtype: int\n");
-static PyObject *py_shader_attr_from_name(BPyGPUShader *self, PyObject *arg)
+static PyObject *pygpu_shader_attr_from_name(BPyGPUShader *self, PyObject *arg)
{
const char *name = PyUnicode_AsUTF8(arg);
if (name == NULL) {
@@ -485,69 +491,75 @@ static PyObject *py_shader_attr_from_name(BPyGPUShader *self, PyObject *arg)
return PyLong_FromLong(attr);
}
-PyDoc_STRVAR(py_shader_calc_format_doc,
+PyDoc_STRVAR(pygpu_shader_calc_format_doc,
".. method:: calc_format()\n"
"\n"
" Build a new format based on the attributes of the shader.\n"
"\n"
" :return: vertex attribute format for the shader\n"
" :rtype: GPUVertFormat\n");
-static PyObject *py_shader_calc_format(BPyGPUShader *self, PyObject *UNUSED(arg))
+static PyObject *pygpu_shader_calc_format(BPyGPUShader *self, PyObject *UNUSED(arg))
{
BPyGPUVertFormat *ret = (BPyGPUVertFormat *)BPyGPUVertFormat_CreatePyObject(NULL);
GPU_vertformat_from_shader(&ret->fmt, self->shader);
return (PyObject *)ret;
}
-static struct PyMethodDef py_shader_methods[] = {
- {"bind", (PyCFunction)py_shader_bind, METH_NOARGS, py_shader_bind_doc},
+static struct PyMethodDef pygpu_shader__tp_methods[] = {
+ {"bind", (PyCFunction)pygpu_shader_bind, METH_NOARGS, pygpu_shader_bind_doc},
{"uniform_from_name",
- (PyCFunction)py_shader_uniform_from_name,
+ (PyCFunction)pygpu_shader_uniform_from_name,
METH_O,
- py_shader_uniform_from_name_doc},
+ pygpu_shader_uniform_from_name_doc},
{"uniform_block_from_name",
- (PyCFunction)py_shader_uniform_block_from_name,
+ (PyCFunction)pygpu_shader_uniform_block_from_name,
METH_O,
- py_shader_uniform_block_from_name_doc},
+ pygpu_shader_uniform_block_from_name_doc},
{"uniform_vector_float",
- (PyCFunction)py_shader_uniform_vector_float,
+ (PyCFunction)pygpu_shader_uniform_vector_float,
METH_VARARGS,
- py_shader_uniform_vector_float_doc},
+ pygpu_shader_uniform_vector_float_doc},
{"uniform_vector_int",
- (PyCFunction)py_shader_uniform_vector_int,
+ (PyCFunction)pygpu_shader_uniform_vector_int,
METH_VARARGS,
- py_shader_uniform_vector_int_doc},
+ pygpu_shader_uniform_vector_int_doc},
{"uniform_bool",
- (PyCFunction)py_shader_uniform_bool,
+ (PyCFunction)pygpu_shader_uniform_bool,
METH_VARARGS,
- py_shader_uniform_bool_doc},
+ pygpu_shader_uniform_bool_doc},
{"uniform_float",
- (PyCFunction)py_shader_uniform_float,
+ (PyCFunction)pygpu_shader_uniform_float,
METH_VARARGS,
- py_shader_uniform_float_doc},
- {"uniform_int", (PyCFunction)py_shader_uniform_int, METH_VARARGS, py_shader_uniform_int_doc},
+ pygpu_shader_uniform_float_doc},
+ {"uniform_int",
+ (PyCFunction)pygpu_shader_uniform_int,
+ METH_VARARGS,
+ pygpu_shader_uniform_int_doc},
{"attr_from_name",
- (PyCFunction)py_shader_attr_from_name,
+ (PyCFunction)pygpu_shader_attr_from_name,
METH_O,
- py_shader_attr_from_name_doc},
- {"format_calc", (PyCFunction)py_shader_calc_format, METH_NOARGS, py_shader_calc_format_doc},
+ pygpu_shader_attr_from_name_doc},
+ {"format_calc",
+ (PyCFunction)pygpu_shader_calc_format,
+ METH_NOARGS,
+ pygpu_shader_calc_format_doc},
{NULL, NULL, 0, NULL},
};
PyDoc_STRVAR(
- py_shader_program_doc,
+ pygpu_shader_program_doc,
"The name of the program object for use by the OpenGL API (read-only).\n\n:type: int");
-static PyObject *py_shader_program_get(BPyGPUShader *self, void *UNUSED(closure))
+static PyObject *pygpu_shader_program_get(BPyGPUShader *self, void *UNUSED(closure))
{
return PyLong_FromLong(GPU_shader_get_program(self->shader));
}
-static PyGetSetDef py_shader_getseters[] = {
- {"program", (getter)py_shader_program_get, (setter)NULL, py_shader_program_doc, NULL},
+static PyGetSetDef pygpu_shader__tp_getseters[] = {
+ {"program", (getter)pygpu_shader_program_get, (setter)NULL, pygpu_shader_program_doc, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};
-static void py_shader_dealloc(BPyGPUShader *self)
+static void pygpu_shader__tp_dealloc(BPyGPUShader *self)
{
if (self->is_builtin == false) {
GPU_shader_free(self->shader);
@@ -556,7 +568,7 @@ static void py_shader_dealloc(BPyGPUShader *self)
}
PyDoc_STRVAR(
- py_shader_doc,
+ pygpu_shader__tp_doc,
".. class:: GPUShader(vertexcode, fragcode, geocode=None, libcode=None, defines=None)\n"
"\n"
" GPUShader combines multiple GLSL shaders into a program used for drawing.\n"
@@ -587,12 +599,12 @@ PyDoc_STRVAR(
PyTypeObject BPyGPUShader_Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUShader",
.tp_basicsize = sizeof(BPyGPUShader),
- .tp_dealloc = (destructor)py_shader_dealloc,
+ .tp_dealloc = (destructor)pygpu_shader__tp_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_doc = py_shader_doc,
- .tp_methods = py_shader_methods,
- .tp_getset = py_shader_getseters,
- .tp_new = py_shader_new,
+ .tp_doc = pygpu_shader__tp_doc,
+ .tp_methods = pygpu_shader__tp_methods,
+ .tp_getset = pygpu_shader__tp_getseters,
+ .tp_new = pygpu_shader__tp_new,
};
/** \} */
@@ -601,18 +613,18 @@ PyTypeObject BPyGPUShader_Type = {
/** \name gpu.shader Module API
* \{ */
-PyDoc_STRVAR(py_shader_unbind_doc,
+PyDoc_STRVAR(pygpu_shader_unbind_doc,
".. function:: unbind()\n"
"\n"
" Unbind the bound shader object.\n");
-static PyObject *py_shader_unbind(BPyGPUShader *UNUSED(self))
+static PyObject *pygpu_shader_unbind(BPyGPUShader *UNUSED(self))
{
GPU_shader_unbind();
Py_RETURN_NONE;
}
-PyDoc_STRVAR(py_shader_from_builtin_doc,
- ".. function:: from_builtin(shader_name)\n"
+PyDoc_STRVAR(pygpu_shader_from_builtin_doc,
+ ".. function:: from_builtin(pygpu_shader_name)\n"
"\n"
" Shaders that are embedded in the blender internal code.\n"
" They all read the uniform ``mat4 ModelViewProjectionMatrix``,\n"
@@ -620,7 +632,7 @@ PyDoc_STRVAR(py_shader_from_builtin_doc,
" For more details, you can check the shader code with the\n"
" :func:`gpu.shader.code_from_builtin` function.\n"
"\n"
- " :param shader_name: One of these builtin shader names:\n\n"
+ " :param pygpu_shader_name: One of these builtin shader names:\n\n"
" - ``2D_UNIFORM_COLOR``\n"
" - ``2D_FLAT_COLOR``\n"
" - ``2D_SMOOTH_COLOR``\n"
@@ -628,14 +640,14 @@ PyDoc_STRVAR(py_shader_from_builtin_doc,
" - ``3D_UNIFORM_COLOR``\n"
" - ``3D_FLAT_COLOR``\n"
" - ``3D_SMOOTH_COLOR``\n"
- " :type shader_name: str\n"
+ " :type pygpu_shader_name: str\n"
" :return: Shader object corresponding to the given name.\n"
" :rtype: :class:`bpy.types.GPUShader`\n");
-static PyObject *py_shader_from_builtin(PyObject *UNUSED(self), PyObject *arg)
+static PyObject *pygpu_shader_from_builtin(PyObject *UNUSED(self), PyObject *arg)
{
BPYGPU_IS_INIT_OR_ERROR_OBJ;
- struct PyC_StringEnum pygpu_bultinshader = {pygpu_bultinshader_items};
+ struct PyC_StringEnum pygpu_bultinshader = {pygpu_shader_builtin_items};
if (!PyC_ParseStringEnum(arg, &pygpu_bultinshader)) {
return NULL;
}
@@ -645,12 +657,12 @@ static PyObject *py_shader_from_builtin(PyObject *UNUSED(self), PyObject *arg)
return BPyGPUShader_CreatePyObject(shader, true);
}
-PyDoc_STRVAR(py_shader_code_from_builtin_doc,
- ".. function:: code_from_builtin(shader_name)\n"
+PyDoc_STRVAR(pygpu_shader_code_from_builtin_doc,
+ ".. function:: code_from_builtin(pygpu_shader_name)\n"
"\n"
" Exposes the internal shader code for query.\n"
"\n"
- " :param shader_name: One of these builtin shader names:\n\n"
+ " :param pygpu_shader_name: One of these builtin shader names:\n\n"
" - ``2D_UNIFORM_COLOR``\n"
" - ``2D_FLAT_COLOR``\n"
" - ``2D_SMOOTH_COLOR``\n"
@@ -658,10 +670,10 @@ PyDoc_STRVAR(py_shader_code_from_builtin_doc,
" - ``3D_UNIFORM_COLOR``\n"
" - ``3D_FLAT_COLOR``\n"
" - ``3D_SMOOTH_COLOR``\n"
- " :type shader_name: str\n"
+ " :type pygpu_shader_name: str\n"
" :return: Vertex, fragment and geometry shader codes.\n"
" :rtype: dict\n");
-static PyObject *py_shader_code_from_builtin(BPyGPUShader *UNUSED(self), PyObject *arg)
+static PyObject *pygpu_shader_code_from_builtin(BPyGPUShader *UNUSED(self), PyObject *arg)
{
const char *vert;
const char *frag;
@@ -670,7 +682,7 @@ static PyObject *py_shader_code_from_builtin(BPyGPUShader *UNUSED(self), PyObjec
PyObject *item, *r_dict;
- struct PyC_StringEnum pygpu_bultinshader = {pygpu_bultinshader_items};
+ struct PyC_StringEnum pygpu_bultinshader = {pygpu_shader_builtin_items};
if (!PyC_ParseStringEnum(arg, &pygpu_bultinshader)) {
return NULL;
}
@@ -697,17 +709,20 @@ static PyObject *py_shader_code_from_builtin(BPyGPUShader *UNUSED(self), PyObjec
return r_dict;
}
-static struct PyMethodDef py_shader_module_methods[] = {
- {"unbind", (PyCFunction)py_shader_unbind, METH_NOARGS, py_shader_unbind_doc},
- {"from_builtin", (PyCFunction)py_shader_from_builtin, METH_O, py_shader_from_builtin_doc},
+static struct PyMethodDef pygpu_shader_module__tp_methods[] = {
+ {"unbind", (PyCFunction)pygpu_shader_unbind, METH_NOARGS, pygpu_shader_unbind_doc},
+ {"from_builtin",
+ (PyCFunction)pygpu_shader_from_builtin,
+ METH_O,
+ pygpu_shader_from_builtin_doc},
{"code_from_builtin",
- (PyCFunction)py_shader_code_from_builtin,
+ (PyCFunction)pygpu_shader_code_from_builtin,
METH_O,
- py_shader_code_from_builtin_doc},
+ pygpu_shader_code_from_builtin_doc},
{NULL, NULL, 0, NULL},
};
-PyDoc_STRVAR(py_shader_module_doc,
+PyDoc_STRVAR(pygpu_shader_module__tp_doc,
"This module provides access to GPUShader internal functions.\n"
"\n"
".. rubric:: Built-in shaders\n"
@@ -736,11 +751,11 @@ PyDoc_STRVAR(py_shader_module_doc,
"3D_SMOOTH_COLOR\n"
" :Attributes: vec3 pos, vec4 color\n"
" :Uniforms: none\n");
-static PyModuleDef py_shader_module_def = {
+static PyModuleDef pygpu_shader_module_def = {
PyModuleDef_HEAD_INIT,
.m_name = "gpu.shader",
- .m_doc = py_shader_module_doc,
- .m_methods = py_shader_module_methods,
+ .m_doc = pygpu_shader_module__tp_doc,
+ .m_methods = pygpu_shader_module__tp_methods,
};
/** \} */
@@ -764,7 +779,7 @@ PyObject *bpygpu_shader_init(void)
{
PyObject *submodule;
- submodule = PyModule_Create(&py_shader_module_def);
+ submodule = PyModule_Create(&pygpu_shader_module_def);
return submodule;
}
diff --git a/source/blender/python/gpu/gpu_py_types.c b/source/blender/python/gpu/gpu_py_types.c
index f0208d3993e..5829cd8c088 100644
--- a/source/blender/python/gpu/gpu_py_types.c
+++ b/source/blender/python/gpu/gpu_py_types.c
@@ -32,7 +32,7 @@
/** \name GPU Types Module
* \{ */
-static struct PyModuleDef py_types_module_def = {
+static struct PyModuleDef pygpu_types_module_def = {
PyModuleDef_HEAD_INIT,
.m_name = "gpu.types",
};
@@ -41,7 +41,7 @@ PyObject *bpygpu_types_init(void)
{
PyObject *submodule;
- submodule = PyModule_Create(&py_types_module_def);
+ submodule = PyModule_Create(&pygpu_types_module_def);
if (PyType_Ready(&BPyGPUVertFormat_Type) < 0) {
return NULL;
diff --git a/source/blender/python/gpu/gpu_py_vertex_buffer.c b/source/blender/python/gpu/gpu_py_vertex_buffer.c
index 8e19eac76d0..160931393ed 100644
--- a/source/blender/python/gpu/gpu_py_vertex_buffer.c
+++ b/source/blender/python/gpu/gpu_py_vertex_buffer.c
@@ -39,7 +39,7 @@
/** \name Utility Functions
* \{ */
-#define PY_AS_NATIVE_SWITCH(attr) \
+#define PYGPU_AS_NATIVE_SWITCH(attr) \
switch (attr->comp_type) { \
case GPU_COMP_I8: { \
PY_AS_NATIVE(int8_t, PyC_Long_AsI8); \
@@ -75,7 +75,7 @@
((void)0)
/* No error checking, callers must run PyErr_Occurred */
-static void fill_format_elem(void *data_dst_void, PyObject *py_src, const GPUVertAttr *attr)
+static void pygpu_fill_format_elem(void *data_dst_void, PyObject *py_src, const GPUVertAttr *attr)
{
#define PY_AS_NATIVE(ty_dst, py_as_native) \
{ \
@@ -84,13 +84,13 @@ static void fill_format_elem(void *data_dst_void, PyObject *py_src, const GPUVer
} \
((void)0)
- PY_AS_NATIVE_SWITCH(attr);
+ PYGPU_AS_NATIVE_SWITCH(attr);
#undef PY_AS_NATIVE
}
/* No error checking, callers must run PyErr_Occurred */
-static void fill_format_sequence(void *data_dst_void,
+static void pygpu_fill_format_sequence(void *data_dst_void,
PyObject *py_seq_fast,
const GPUVertAttr *attr)
{
@@ -107,19 +107,19 @@ static void fill_format_sequence(void *data_dst_void,
} \
((void)0)
- PY_AS_NATIVE_SWITCH(attr);
+ PYGPU_AS_NATIVE_SWITCH(attr);
#undef PY_AS_NATIVE
}
-#undef PY_AS_NATIVE_SWITCH
+#undef PYGPU_AS_NATIVE_SWITCH
#undef WARN_TYPE_LIMIT_PUSH
#undef WARN_TYPE_LIMIT_POP
-static bool py_vertbuf_fill_impl(GPUVertBuf *vbo,
- uint data_id,
- PyObject *seq,
- const char *error_prefix)
+static bool pygpu_vertbuf_fill_impl(GPUVertBuf *vbo,
+ uint data_id,
+ PyObject *seq,
+ const char *error_prefix)
{
const char *exc_str_size_mismatch = "Expected a %s of size %d, got %u";
@@ -173,7 +173,7 @@ static bool py_vertbuf_fill_impl(GPUVertBuf *vbo,
for (uint i = 0; i < seq_len; i++) {
uchar *data = (uchar *)GPU_vertbuf_raw_step(&data_step);
PyObject *item = seq_items[i];
- fill_format_elem(data, item, attr);
+ pygpu_fill_format_elem(data, item, attr);
}
}
else {
@@ -197,7 +197,7 @@ static bool py_vertbuf_fill_impl(GPUVertBuf *vbo,
}
/* May trigger error, check below */
- fill_format_sequence(data, seq_fast_item, attr);
+ pygpu_fill_format_sequence(data, seq_fast_item, attr);
Py_DECREF(seq_fast_item);
}
}
@@ -213,7 +213,7 @@ static bool py_vertbuf_fill_impl(GPUVertBuf *vbo,
return ok;
}
-static int py_attr_fill(GPUVertBuf *buf, int id, PyObject *py_seq_data, const char *error_prefix)
+static int pygpu_vertbuf_fill(GPUVertBuf *buf, int id, PyObject *py_seq_data, const char *error_prefix)
{
if (id < 0 || id >= GPU_vertbuf_get_format(buf)->attr_len) {
PyErr_Format(PyExc_ValueError, "Format id %d out of range", id);
@@ -225,7 +225,7 @@ static int py_attr_fill(GPUVertBuf *buf, int id, PyObject *py_seq_data, const ch
return 0;
}
- if (!py_vertbuf_fill_impl(buf, (uint)id, py_seq_data, error_prefix)) {
+ if (!pygpu_vertbuf_fill_impl(buf, (uint)id, py_seq_data, error_prefix)) {
return 0;
}
@@ -238,7 +238,7 @@ static int py_attr_fill(GPUVertBuf *buf, int id, PyObject *py_seq_data, const ch
/** \name VertBuf Type
* \{ */
-static PyObject *py_VertBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *pygpu_vertbuf__tp_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
{
struct {
PyObject *py_fmt;
@@ -260,7 +260,7 @@ static PyObject *py_VertBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyOb
return BPyGPUVertBuf_CreatePyObject(vbo);
}
-PyDoc_STRVAR(py_VertBuf_attr_fill_doc,
+PyDoc_STRVAR(pygpu_vertbuf_attr_fill_doc,
".. method:: attr_fill(id, data)\n"
"\n"
" Insert data into the buffer for a single attribute.\n"
@@ -269,7 +269,7 @@ PyDoc_STRVAR(py_VertBuf_attr_fill_doc,
" :type id: int or str\n"
" :param data: Sequence of data that should be stored in the buffer\n"
" :type data: sequence of values or tuples\n");
-static PyObject *py_VertBuf_attr_fill(BPyGPUVertBuf *self, PyObject *args, PyObject *kwds)
+static PyObject *pygpu_vertbuf_attr_fill(BPyGPUVertBuf *self, PyObject *args, PyObject *kwds)
{
PyObject *data;
PyObject *identifier;
@@ -299,28 +299,28 @@ static PyObject *py_VertBuf_attr_fill(BPyGPUVertBuf *self, PyObject *args, PyObj
return NULL;
}
- if (!py_attr_fill(self->buf, id, data, "GPUVertBuf.attr_fill")) {
+ if (!pygpu_vertbuf_fill(self->buf, id, data, "GPUVertBuf.attr_fill")) {
return NULL;
}
Py_RETURN_NONE;
}
-static struct PyMethodDef py_VertBuf_methods[] = {
+static struct PyMethodDef pygpu_vertbuf__tp_methods[] = {
{"attr_fill",
- (PyCFunction)py_VertBuf_attr_fill,
+ (PyCFunction)pygpu_vertbuf_attr_fill,
METH_VARARGS | METH_KEYWORDS,
- py_VertBuf_attr_fill_doc},
+ pygpu_vertbuf_attr_fill_doc},
{NULL, NULL, 0, NULL},
};
-static void py_VertBuf_dealloc(BPyGPUVertBuf *self)
+static void pygpu_vertbuf__tp_dealloc(BPyGPUVertBuf *self)
{
GPU_vertbuf_discard(self->buf);
Py_TYPE(self)->tp_free(self);
}
-PyDoc_STRVAR(py_gpu_vertex_buffer_doc,
+PyDoc_STRVAR(pygpu_vertbuf__tp_doc,
".. class:: GPUVertBuf(len, format)\n"
"\n"
" Contains a VBO.\n"
@@ -332,11 +332,11 @@ PyDoc_STRVAR(py_gpu_vertex_buffer_doc,
PyTypeObject BPyGPUVertBuf_Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUVertBuf",
.tp_basicsize = sizeof(BPyGPUVertBuf),
- .tp_dealloc = (destructor)py_VertBuf_dealloc,
+ .tp_dealloc = (destructor)pygpu_vertbuf__tp_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_doc = py_gpu_vertex_buffer_doc,
- .tp_methods = py_VertBuf_methods,
- .tp_new = py_VertBuf_new,
+ .tp_doc = pygpu_vertbuf__tp_doc,
+ .tp_methods = pygpu_vertbuf__tp_methods,
+ .tp_new = pygpu_vertbuf__tp_new,
};
/** \} */
diff --git a/source/blender/python/gpu/gpu_py_vertex_format.c b/source/blender/python/gpu/gpu_py_vertex_format.c
index 52e1a720f97..67f612f8ba3 100644
--- a/source/blender/python/gpu/gpu_py_vertex_format.c
+++ b/source/blender/python/gpu/gpu_py_vertex_format.c
@@ -50,7 +50,7 @@
* Use with PyArg_ParseTuple's "O&" formatting.
* \{ */
-static int py_parse_component_type(const char *str, int length)
+static int pygpu_vertformat_parse_component_type(const char *str, int length)
{
if (length == 2) {
switch (*((ushort *)str)) {
@@ -83,7 +83,7 @@ static int py_parse_component_type(const char *str, int length)
return -1;
}
-static int py_parse_fetch_mode(const char *str, int length)
+static int pygpu_vertformat_parse_fetch_mode(const char *str, int length)
{
#define MATCH_ID(id) \
if (length == strlen(STRINGIFY(id))) { \
@@ -102,7 +102,7 @@ static int py_parse_fetch_mode(const char *str, int length)
return -1;
}
-static int py_ParseVertCompType(PyObject *o, void *p)
+static int pygpu_ParseVertCompType(PyObject *o, void *p)
{
Py_ssize_t length;
const char *str = PyUnicode_AsUTF8AndSize(o, &length);
@@ -112,7 +112,7 @@ static int py_ParseVertCompType(PyObject *o, void *p)
return 0;
}
- const int comp_type = py_parse_component_type(str, length);
+ const int comp_type = pygpu_vertformat_parse_component_type(str, length);
if (comp_type == -1) {
PyErr_Format(PyExc_ValueError, "unknown component type: '%s", str);
return 0;
@@ -122,7 +122,7 @@ static int py_ParseVertCompType(PyObject *o, void *p)
return 1;
}
-static int py_ParseVertFetchMode(PyObject *o, void *p)
+static int pygpu_ParseVertFetchMode(PyObject *o, void *p)
{
Py_ssize_t length;
const char *str = PyUnicode_AsUTF8AndSize(o, &length);
@@ -132,7 +132,7 @@ static int py_ParseVertFetchMode(PyObject *o, void *p)
return 0;
}
- const int fetch_mode = py_parse_fetch_mode(str, length);
+ const int fetch_mode = pygpu_vertformat_parse_fetch_mode(str, length);
if (fetch_mode == -1) {
PyErr_Format(PyExc_ValueError, "unknown type literal: '%s'", str);
return 0;
@@ -148,7 +148,9 @@ static int py_ParseVertFetchMode(PyObject *o, void *p)
/** \name VertFormat Type
* \{ */
-static PyObject *py_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds)
+static PyObject *pygpu_vertformat__tp_new(PyTypeObject *UNUSED(type),
+ PyObject *args,
+ PyObject *kwds)
{
if (PyTuple_GET_SIZE(args) || (kwds && PyDict_Size(kwds))) {
PyErr_SetString(PyExc_ValueError, "This function takes no arguments");
@@ -158,7 +160,7 @@ static PyObject *py_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *args, P
}
PyDoc_STRVAR(
- py_VertFormat_attr_add_doc,
+ pygpu_vertformat_attr_add_doc,
".. method:: attr_add(id, comp_type, len, fetch_mode)\n"
"\n"
" Add a new attribute to the format.\n"
@@ -177,7 +179,7 @@ PyDoc_STRVAR(
" converted to a normal 4 byte float when used.\n"
" Possible values are `FLOAT`, `INT`, `INT_TO_FLOAT_UNIT` and `INT_TO_FLOAT`.\n"
" :type fetch_mode: `str`\n");
-static PyObject *py_VertFormat_attr_add(BPyGPUVertFormat *self, PyObject *args, PyObject *kwds)
+static PyObject *pygpu_vertformat_attr_add(BPyGPUVertFormat *self, PyObject *args, PyObject *kwds)
{
struct {
const char *id;
@@ -197,10 +199,10 @@ static PyObject *py_VertFormat_attr_add(BPyGPUVertFormat *self, PyObject *args,
kwds,
&_parser,
&params.id,
- py_ParseVertCompType,
+ pygpu_ParseVertCompType,
&params.comp_type,
&params.len,
- py_ParseVertFetchMode,
+ pygpu_ParseVertFetchMode,
&params.fetch_mode)) {
return NULL;
}
@@ -210,31 +212,31 @@ static PyObject *py_VertFormat_attr_add(BPyGPUVertFormat *self, PyObject *args,
return PyLong_FromLong(attr_id);
}
-static struct PyMethodDef py_VertFormat_methods[] = {
+static struct PyMethodDef pygpu_vertformat__tp_methods[] = {
{"attr_add",
- (PyCFunction)py_VertFormat_attr_add,
+ (PyCFunction)pygpu_vertformat_attr_add,
METH_VARARGS | METH_KEYWORDS,
- py_VertFormat_attr_add_doc},
+ pygpu_vertformat_attr_add_doc},
{NULL, NULL, 0, NULL},
};
-static void py_VertFormat_dealloc(BPyGPUVertFormat *self)
+static void pygpu_vertformat__tp_dealloc(BPyGPUVertFormat *self)
{
Py_TYPE(self)->tp_free(self);
}
-PyDoc_STRVAR(py_VertFormat_doc,
+PyDoc_STRVAR(pygpu_vertformat__tp_doc,
".. class:: GPUVertFormat()\n"
"\n"
" This object contains information about the structure of a vertex buffer.\n");
PyTypeObject BPyGPUVertFormat_Type = {
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUVertFormat",
.tp_basicsize = sizeof(BPyGPUVertFormat),
- .tp_dealloc = (destructor)py_VertFormat_dealloc,
+ .tp_dealloc = (destructor)pygpu_vertformat__tp_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_doc = py_VertFormat_doc,
- .tp_methods = py_VertFormat_methods,
- .tp_new = py_VertFormat_new,
+ .tp_doc = pygpu_vertformat__tp_doc,
+ .tp_methods = pygpu_vertformat__tp_methods,
+ .tp_new = pygpu_vertformat__tp_new,
};
/** \} */