From 95baf4cfe99f58ddb5dd01909fe1b4ffc6b8df7f Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Fri, 24 Dec 2021 09:10:58 -0500 Subject: [PATCH] add helper function to get attrib->num_components from GLenum --- src/shader.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/shader.cpp b/src/shader.cpp index 5cfe449..190f3d1 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -465,6 +465,17 @@ parseUniformBlocks(memory_arena* arena, shader_program* s, GLContext* gl_ctx) return true; } +u32 +getNumAttribComponents(GLenum type) +{ + switch (type) { + case GL_FLOAT_VEC3: return 3; + default: + printf("%s(), unknown GLenum\n", __FUNCTION__); + return 0; + } +} + bool parseAttributes(memory_arena* arena, shader_program* s, GLContext* gl_ctx) { @@ -494,7 +505,8 @@ parseAttributes(memory_arena* arena, shader_program* s, GLContext* gl_ctx) GLVertexAttrib* attrib = &s->vertex_attribs[i]; attrib->data_type = type; attrib->location = location; - // FIXME: need a helper for attrib->num_components + attrib->num_components = getNumAttribComponents(type); + assert(attrib->num_components > 0); attrib->name = arenaCopyCStr(arena, attrib_name, sizeof(attrib_name)); // TODO: replace POSITION, NORMAL, UV... etc enums in loadGLMesh() // with extra logic to detect mesh to shader mapping