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:
Diffstat (limited to 'source/blender/python/gpu/gpu_py_shader.c')
-rw-r--r--source/blender/python/gpu/gpu_py_shader.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c
index 145586d8ab0..c7b59ee0d6e 100644
--- a/source/blender/python/gpu/gpu_py_shader.c
+++ b/source/blender/python/gpu/gpu_py_shader.c
@@ -70,6 +70,12 @@ static const struct PyC_StringEnumItems pygpu_shader_builtin_items[] = {
{0, NULL},
};
+static const struct PyC_StringEnumItems pygpu_shader_config_items[] = {
+ {GPU_SHADER_CFG_DEFAULT, "DEFAULT"},
+ {GPU_SHADER_CFG_CLIPPED, "CLIPPED"},
+ {0, NULL},
+};
+
static int pygpu_shader_uniform_location_get(GPUShader *shader,
const char *name,
const char *error_prefix)
@@ -711,29 +717,48 @@ static PyObject *pygpu_shader_unbind(BPyGPUShader *UNUSED(self))
}
PyDoc_STRVAR(pygpu_shader_from_builtin_doc,
- ".. function:: from_builtin(pygpu_shader_name)\n"
+ ".. function:: from_builtin(shader_name, config='DEFAULT')\n"
"\n"
" Shaders that are embedded in the blender internal code.\n"
" They all read the uniform ``mat4 ModelViewProjectionMatrix``,\n"
" which can be edited by the :mod:`gpu.matrix` module.\n"
+ " You can also choose a shader configuration that uses clip_planes by setting the "
+ "``CLIPPED`` value to the config parameter. Note that in this case you also need to "
+ "manually set the value of ``ModelMatrix``.\n"
+ "\n"
" For more details, you can check the shader code with the\n"
" :func:`gpu.shader.code_from_builtin` function.\n"
"\n"
- " :param pygpu_shader_name: One of these builtin shader names:\n"
+ " :param shader_name: One of these builtin shader names:\n"
"\n" PYDOC_BUILTIN_SHADER_LIST
- " :type pygpu_shader_name: str\n"
+ " :type shader_name: str\n"
+ " :param config: One of these types of shader configuration:\n"
+ " - ``DEFAULT``\n"
+ " - ``CLIPPED``\n"
+ " :type config: str\n"
" :return: Shader object corresponding to the given name.\n"
" :rtype: :class:`bpy.types.GPUShader`\n");
-static PyObject *pygpu_shader_from_builtin(PyObject *UNUSED(self), PyObject *arg)
+static PyObject *pygpu_shader_from_builtin(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
{
BPYGPU_IS_INIT_OR_ERROR_OBJ;
struct PyC_StringEnum pygpu_bultinshader = {pygpu_shader_builtin_items};
- if (!PyC_ParseStringEnum(arg, &pygpu_bultinshader)) {
+ struct PyC_StringEnum pygpu_config = {pygpu_shader_config_items, GPU_SHADER_CFG_DEFAULT};
+
+ static const char *_keywords[] = {"shader_name", "config", NULL};
+ static _PyArg_Parser _parser = {"O&|$O&:from_builtin", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(args,
+ kwds,
+ &_parser,
+ PyC_ParseStringEnum,
+ &pygpu_bultinshader,
+ PyC_ParseStringEnum,
+ &pygpu_config)) {
return NULL;
}
- GPUShader *shader = GPU_shader_get_builtin_shader(pygpu_bultinshader.value_found);
+ GPUShader *shader = GPU_shader_get_builtin_shader_with_config(pygpu_bultinshader.value_found,
+ pygpu_config.value_found);
return BPyGPUShader_CreatePyObject(shader, true);
}
@@ -788,7 +813,7 @@ 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,
+ METH_VARARGS | METH_KEYWORDS,
pygpu_shader_from_builtin_doc},
{"code_from_builtin",
(PyCFunction)pygpu_shader_code_from_builtin,