Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/gpu/gpu_py_shader.c
| Show All 30 Lines | |||||
| #include "GPU_shader.h" | #include "GPU_shader.h" | ||||
| #include "GPU_shader_interface.h" | #include "GPU_shader_interface.h" | ||||
| #include "../generic/py_capi_utils.h" | #include "../generic/py_capi_utils.h" | ||||
| #include "../generic/python_utildefines.h" | #include "../generic/python_utildefines.h" | ||||
| #include "../mathutils/mathutils.h" | #include "../mathutils/mathutils.h" | ||||
| #include "gpu_py.h" | |||||
| #include "gpu_py_shader.h" /* own include */ | #include "gpu_py_shader.h" /* own include */ | ||||
| #include "gpu_py_vertex_format.h" | #include "gpu_py_vertex_format.h" | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Enum Conversion. | /** \name Enum Conversion. | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | struct { | ||||
| const char *defines; | const char *defines; | ||||
| } params = {0}; | } params = {0}; | ||||
| static const char *_keywords[] = { | static const char *_keywords[] = { | ||||
| "vertexcode", "fragcode", "geocode", | "vertexcode", "fragcode", "geocode", | ||||
| "libcode", "defines", NULL}; | "libcode", "defines", NULL}; | ||||
| static _PyArg_Parser _parser = {"ss|$sss:GPUShader.__new__", _keywords, 0}; | static _PyArg_Parser _parser = {"ss|$sss:GPUShader.__new__", _keywords, 0}; | ||||
| if (!_PyArg_ParseTupleAndKeywordsFast( | if (!bpygpu_is_initialized() || | ||||
| !_PyArg_ParseTupleAndKeywordsFast( | |||||
| args, kwds, &_parser, | args, kwds, &_parser, | ||||
| ¶ms.vertexcode, ¶ms.fragcode, ¶ms.geocode, | ¶ms.vertexcode, ¶ms.fragcode, ¶ms.geocode, | ||||
| ¶ms.libcode, ¶ms.defines)) | ¶ms.libcode, ¶ms.defines)) | ||||
| { | { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GPUShader *shader = GPU_shader_create( | GPUShader *shader = GPU_shader_create( | ||||
| ▲ Show 20 Lines • Show All 583 Lines • ▼ Show 20 Lines | |||||
| " :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 *bpygpu_shader_from_builtin(PyObject *UNUSED(self), PyObject *arg) | ||||
| { | { | ||||
| GPUBuiltinShader shader_id; | GPUBuiltinShader shader_id; | ||||
| if (!bpygpu_ParseBultinShaderEnum(arg, &shader_id)) { | if (!bpygpu_is_initialized() || | ||||
| !bpygpu_ParseBultinShaderEnum(arg, &shader_id)) | |||||
| { | |||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GPUShader *shader = GPU_shader_get_builtin_shader(shader_id); | GPUShader *shader = GPU_shader_get_builtin_shader(shader_id); | ||||
| return BPyGPUShader_CreatePyObject(shader, true); | return BPyGPUShader_CreatePyObject(shader, true); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines | |||||