diff options
author | Jacques Lucke <mail@jlucke.com> | 2018-10-05 16:10:56 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2018-10-05 16:10:56 +0300 |
commit | 564d37c4b67af534b6c12d2bebbd7883c3d3817c (patch) | |
tree | b66ffd18788459459ea38e652e002f0332dce05c /source/blender/gpu | |
parent | 1aae42aa8837fe5b82bc6ba5ead90583700908ad (diff) |
Python API: new GPUVertFormat constructor and vbo.fill_attribute method
Reviewer: fclem
Differential Revision: https://developer.blender.org/D3760
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_vertex_format.h | 1 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_vertex_format.c | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h index 7e0038e3473..5e7e036bf41 100644 --- a/source/blender/gpu/GPU_vertex_format.h +++ b/source/blender/gpu/GPU_vertex_format.h @@ -87,6 +87,7 @@ uint GPU_vertformat_attr_add( GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode); void GPU_vertformat_alias_add(GPUVertFormat *, const char *alias); +int GPU_vertformat_attr_id_get(const GPUVertFormat *, const char *name); /* format conversion */ diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c index 59e413a1f3e..f1aaa99fbc6 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.c +++ b/source/blender/gpu/intern/gpu_vertex_format.c @@ -34,6 +34,8 @@ #include <stddef.h> #include <string.h> +#include "BLI_utildefines.h" + #define PACK_DEBUG 0 #if PACK_DEBUG @@ -204,6 +206,19 @@ void GPU_vertformat_alias_add(GPUVertFormat *format, const char *alias) attrib->name[attrib->name_len++] = copy_attrib_name(format, alias); } +int GPU_vertformat_attr_id_get(const GPUVertFormat *format, const char *name) +{ + for (int i = 0; i < format->attr_len; i++) { + const GPUVertAttr *attrib = format->attribs + i; + for (int j = 0; j < attrib->name_len; j++) { + if (STREQ(name, attrib->name[j])) { + return i; + } + } + } + return -1; +} + uint padding(uint offset, uint alignment) { const uint mod = offset % alignment; |