diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-09-28 14:13:09 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-09-28 14:13:09 +0300 |
commit | 7fdb9e168dcd35d2695007cc77b3b27034a21cd5 (patch) | |
tree | 614f5b6741644d6de394152724eb2d85c8d06c75 /source/blender/python/generic/bgl.c | |
parent | 64de8c8f0de018f5d2b075db738d7b6322d6d21a (diff) | |
parent | 75e8e3779bcf59622b9e7c43529ca9f91b40a917 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/python/generic/bgl.c')
-rw-r--r-- | source/blender/python/generic/bgl.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index ada7f7d8afb..c290e5bd7a0 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -476,20 +476,35 @@ int BGL_typeSize(int type) return -1; } -static int gl_buffer_type_from_py_format_char(char format) +static int gl_buffer_type_from_py_format_char(char *typestr) { + if (ELEM(typestr[0], '<', '>', '|')) { + typestr += 1; + } + char format = typestr[0]; + char byte_num = typestr[1]; + switch (format) { + case 't': case 'b': - return GL_BYTE; case 'h': + if (!byte_num) return GL_BYTE; + ATTR_FALLTHROUGH; case 'i': - return GL_SHORT; + if (!byte_num) return GL_SHORT; + ATTR_FALLTHROUGH; case 'l': - return GL_INT; + if (!byte_num || byte_num == '4') return GL_INT; + if (byte_num == '1') return GL_BYTE; + if (byte_num == '2') return GL_SHORT; + break; case 'f': - return GL_FLOAT; + if (!byte_num) return GL_FLOAT; + ATTR_FALLTHROUGH; case 'd': - return GL_DOUBLE; + if (!byte_num || byte_num == '8') return GL_DOUBLE; + if (byte_num == '4') return GL_FLOAT; + break; } return -1; /* UNKNOWN */ } @@ -786,9 +801,9 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject return NULL; } - if (type != gl_buffer_type_from_py_format_char(*pybuffer.format)) { + if (type != gl_buffer_type_from_py_format_char(pybuffer.format)) { PyErr_Format(PyExc_TypeError, - "`GL_TYPE` and `format` of object with buffer interface do not match"); + "`GL_TYPE` and `typestr` of object with buffer interface do not match. '%s'", pybuffer.format); } else if (ndimensions != pybuffer.ndim || !compare_dimensions(ndimensions, dimensions, pybuffer.shape)) |