From 425cfdd5be12a0c167bd55eeb1ac84d37b7f2ead Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 20 Sep 2018 19:51:02 +0000 Subject: GPU Python API: shader.uniform_float The existing alternative is to use a buffer and call uniform_vector_float which is overkill for such a simple operation. --- source/blender/python/gpu/gpu_py_shader.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source/blender/python') diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c index 76fe38c57e9..3a9122297cd 100644 --- a/source/blender/python/gpu/gpu_py_shader.c +++ b/source/blender/python/gpu/gpu_py_shader.c @@ -323,6 +323,34 @@ static PyObject *bpygpu_shader_uniform_vector_int( Py_RETURN_NONE; } +PyDoc_STRVAR(bpygpu_shader_uniform_float_doc, + ".. method:: uniform_float(location, value)\n" + "\n" + " Set uniform value.\n" + "\n" + " :param location: builtin identifier.\n" + " :type location: `int`\n" + " :param value: uniform value.\n" + " :type value: `float`\n" +); +static PyObject *bpygpu_shader_uniform_float( + BPyGPUShader *self, PyObject *args) +{ + int location; + float value; + + if (!PyArg_ParseTuple( + args, "if:GPUShader.uniform_float", + &location, &value)) + { + return NULL; + } + + GPU_shader_uniform_float(self->shader, location, value); + + Py_RETURN_NONE; +} + PyDoc_STRVAR(bpygpu_shader_uniform_int_doc, ".. method:: uniform_int(location, value)\n" "\n" @@ -408,6 +436,9 @@ static struct PyMethodDef bpygpu_shader_methods[] = { {"uniform_vector_int", (PyCFunction)bpygpu_shader_uniform_vector_int, METH_VARARGS, bpygpu_shader_uniform_vector_int_doc}, + {"uniform_float", + (PyCFunction)bpygpu_shader_uniform_float, + METH_VARARGS, bpygpu_shader_uniform_float_doc}, {"uniform_int", (PyCFunction)bpygpu_shader_uniform_int, METH_VARARGS, bpygpu_shader_uniform_int_doc}, -- cgit v1.2.3