Browse Source

add helper function to get attrib->num_components from GLenum

main
cinnaboot 5 years ago
parent
commit
95baf4cfe9
  1. 14
      src/shader.cpp

14
src/shader.cpp

@ -465,6 +465,17 @@ parseUniformBlocks(memory_arena* arena, shader_program* s, GLContext* gl_ctx)
return true; return true;
} }
u32
getNumAttribComponents(GLenum type)
{
switch (type) {
case GL_FLOAT_VEC3: return 3;
default:
printf("%s(), unknown GLenum\n", __FUNCTION__);
return 0;
}
}
bool bool
parseAttributes(memory_arena* arena, shader_program* s, GLContext* gl_ctx) 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]; GLVertexAttrib* attrib = &s->vertex_attribs[i];
attrib->data_type = type; attrib->data_type = type;
attrib->location = location; 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)); attrib->name = arenaCopyCStr(arena, attrib_name, sizeof(attrib_name));
// TODO: replace POSITION, NORMAL, UV... etc enums in loadGLMesh() // TODO: replace POSITION, NORMAL, UV... etc enums in loadGLMesh()
// with extra logic to detect mesh to shader mapping // with extra logic to detect mesh to shader mapping

Loading…
Cancel
Save