From 564d37c4b67af534b6c12d2bebbd7883c3d3817c Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 5 Oct 2018 15:10:56 +0200 Subject: Python API: new GPUVertFormat constructor and vbo.fill_attribute method Reviewer: fclem Differential Revision: https://developer.blender.org/D3760 --- source/blender/gpu/intern/gpu_vertex_format.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/gpu/intern/gpu_vertex_format.c') 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 #include +#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; -- cgit v1.2.3