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:
authorJacques Lucke <mail@jlucke.com>2018-10-09 12:17:29 +0300
committerJacques Lucke <mail@jlucke.com>2018-10-09 12:17:29 +0300
commit9560fe60e42d4fe098a24c17f31b6313eaae3364 (patch)
tree03e12f53792db7bc55c53523bc29bb1141f55bf0 /source/blender/python
parent1b910082a0effdeb06653203b1d773094a2068e5 (diff)
Python API: new GPUShader.format_calc() method
Reviewers: mano-wii, fclem, campbellbarton Differential Revision: https://developer.blender.org/D3772
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/gpu/gpu_py_shader.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c
index 64b208ed49f..154c2f8caf1 100644
--- a/source/blender/python/gpu/gpu_py_shader.c
+++ b/source/blender/python/gpu/gpu_py_shader.c
@@ -36,6 +36,7 @@
#include "../generic/python_utildefines.h"
#include "gpu_py_shader.h" /* own include */
+#include "gpu_py_vertex_format.h"
/* -------------------------------------------------------------------- */
@@ -569,6 +570,21 @@ static PyObject *bpygpu_shader_attr_from_name(
return PyLong_FromLong(attrib);
}
+PyDoc_STRVAR(bpygpu_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 *bpygpu_shader_calc_format(BPyGPUShader *self, PyObject *UNUSED(arg))
+{
+ BPyGPUVertFormat *ret = (BPyGPUVertFormat *)BPyGPUVertFormat_CreatePyObject(NULL);
+ GPU_vertformat_from_interface(&ret->fmt, GPU_shader_get_interface(self->shader));
+ return (PyObject *)ret;
+}
+
static struct PyMethodDef bpygpu_shader_methods[] = {
{"bind", (PyCFunction)bpygpu_shader_bind,
METH_NOARGS, bpygpu_shader_bind_doc},
@@ -602,6 +618,9 @@ static struct PyMethodDef bpygpu_shader_methods[] = {
{"attr_from_name",
(PyCFunction)bpygpu_shader_attr_from_name,
METH_O, bpygpu_shader_attr_from_name_doc},
+ {"format_calc",
+ (PyCFunction)bpygpu_shader_calc_format,
+ METH_NOARGS, bpygpu_shader_calc_format_doc},
{NULL, NULL, 0, NULL}
};