diff options
Diffstat (limited to 'source/blender/python/gpu/gpu_py_element.c')
-rw-r--r-- | source/blender/python/gpu/gpu_py_element.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/source/blender/python/gpu/gpu_py_element.c b/source/blender/python/gpu/gpu_py_element.c index f43338c42d2..0e5094cbbc0 100644 --- a/source/blender/python/gpu/gpu_py_element.c +++ b/source/blender/python/gpu/gpu_py_element.c @@ -32,6 +32,7 @@ #include "../generic/py_capi_utils.h" #include "../generic/python_utildefines.h" +#include "gpu_py.h" #include "gpu_py_api.h" #include "gpu_py_element.h" /* own include */ @@ -46,10 +47,8 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar const char *error_prefix = "IndexBuf.__new__"; bool ok = true; - struct { - GPUPrimType type_id; - PyObject *seq; - } params; + struct PyC_StringEnum prim_type = {bpygpu_primtype_items, GPU_PRIM_NONE}; + PyObject *seq; uint verts_per_prim; uint index_len; @@ -58,11 +57,11 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar static const char *_keywords[] = {"type", "seq", NULL}; static _PyArg_Parser _parser = {"$O&O:IndexBuf.__new__", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( - args, kwds, &_parser, bpygpu_ParsePrimType, ¶ms.type_id, ¶ms.seq)) { + args, kwds, &_parser, PyC_ParseStringEnum, &prim_type, &seq)) { return NULL; } - verts_per_prim = GPU_indexbuf_primitive_len(params.type_id); + verts_per_prim = GPU_indexbuf_primitive_len(prim_type.value_found); if (verts_per_prim == -1) { PyErr_Format(PyExc_ValueError, "The argument 'type' must be " @@ -70,10 +69,10 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar return NULL; } - if (PyObject_CheckBuffer(params.seq)) { + if (PyObject_CheckBuffer(seq)) { Py_buffer pybuffer; - if (PyObject_GetBuffer(params.seq, &pybuffer, PyBUF_FORMAT | PyBUF_ND) == -1) { + if (PyObject_GetBuffer(seq, &pybuffer, PyBUF_FORMAT | PyBUF_ND) == -1) { /* PyObject_GetBuffer already handles error messages. */ return NULL; } @@ -97,7 +96,7 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar /* The `vertex_len` parameter is only used for asserts in the Debug build. */ /* Not very useful in python since scripts are often tested in Release build. */ /* Use `INT_MAX` instead of the actual number of vertices. */ - GPU_indexbuf_init(&builder, params.type_id, index_len, INT_MAX); + GPU_indexbuf_init(&builder, prim_type.value_found, index_len, INT_MAX); #if 0 uint *buf = pybuffer.buf; @@ -111,7 +110,7 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar PyBuffer_Release(&pybuffer); } else { - PyObject *seq_fast = PySequence_Fast(params.seq, error_prefix); + PyObject *seq_fast = PySequence_Fast(seq, error_prefix); if (seq_fast == NULL) { return false; @@ -126,7 +125,7 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar /* The `vertex_len` parameter is only used for asserts in the Debug build. */ /* Not very useful in python since scripts are often tested in Release build. */ /* Use `INT_MAX` instead of the actual number of vertices. */ - GPU_indexbuf_init(&builder, params.type_id, index_len, INT_MAX); + GPU_indexbuf_init(&builder, prim_type.value_found, index_len, INT_MAX); if (verts_per_prim == 1) { for (uint i = 0; i < seq_len; i++) { |