diff options
author | mano-wii <germano.costa@ig.com.br> | 2018-10-06 06:13:54 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2018-10-06 06:13:54 +0300 |
commit | 0f5533441390d049d2b85e86abdd57b5a874e530 (patch) | |
tree | 717aa1bb3a31b2189fcdce603c9b9322d42084a3 /source/blender/python/generic | |
parent | 98e62d459ac3918bde15d9e286c9bbd1ff34b190 (diff) |
Cleanup: use new format string utility
Diffstat (limited to 'source/blender/python/generic')
-rw-r--r-- | source/blender/python/generic/bgl.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 981aec17e6b..58bfea5fab8 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -37,6 +37,8 @@ #include "GPU_glew.h" #include "MEM_guardedalloc.h" +#include "../generic/py_capi_utils.h" + #include "bgl.h" @@ -478,29 +480,19 @@ int BGL_typeSize(int type) static int gl_buffer_type_from_py_buffer(Py_buffer *pybuffer) { - char *typestr = pybuffer->format; + const char format = FORMAT_STR_GET(pybuffer->format); Py_ssize_t itemsize = pybuffer->itemsize; - if (ELEM(typestr[0], '<', '>', '|')) { - typestr += 1; + if (FORMAT_STR_IS_FLOAT(format)) { + if (itemsize == 4) return GL_FLOAT; + if (itemsize == 8) return GL_DOUBLE; } - - switch (typestr[0]) { - case 't': - case 'b': - case 'h': - case 'i': - case 'l': - if (itemsize == 1) return GL_BYTE; - if (itemsize == 2) return GL_SHORT; - if (itemsize == 4) return GL_INT; - break; - case 'f': - case 'd': - if (itemsize == 4) return GL_FLOAT; - if (itemsize == 8) return GL_DOUBLE; - break; + if (FORMAT_STR_IS_BYTE(format) || FORMAT_STR_IS_INT(format)) { + if (itemsize == 1) return GL_BYTE; + if (itemsize == 2) return GL_SHORT; + if (itemsize == 4) return GL_INT; } + return -1; /* UNKNOWN */ } |