From 0e0c5aa9039d6aab9732392d439e1932eaae84e9 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Sat, 18 Dec 2021 11:12:13 -0500 Subject: [PATCH] add more debug info for vertex attribs --- src/shader.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/shader.cpp b/src/shader.cpp index ac41a26..b84233b 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -375,6 +375,10 @@ initCTXSizes(GLContext* gl_ctx) gl_ctx->max_fragment_blocks); printf("GL_MAX_UNIFORM_BLOCK_SIZE: %d\n", gl_ctx->max_ublock_size); + + GLint max_vertex_attribs = 0; + glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs); + printf("GL_MAX_VERTEX_ATTRIBS: %d\n", max_vertex_attribs); #endif } } @@ -441,7 +445,35 @@ parseAttributes(memory_arena* arena, shader_program* s, GLContext* gl_ctx) { // TODO: parse buffers (vert, normal, uv), glGetActiveAttrib() /// - printf("%s(), FIXME:\n", __FUNCTION__); + printf("\n---------------------------------\n"); + printf("%s(), FIXME: dumping attrib info for programe: %s\n", + __FUNCTION__, s->name); + + + GLint active_attribs; + glGetProgramiv(s->prog_id, GL_ACTIVE_ATTRIBUTES, &active_attribs); + printf("active attributes: %d\n", active_attribs); + + GLchar attrib_name[256]; + GLsizei length; + GLint size; + GLenum type; + + for (int i = 0; i < active_attribs; i++) { + glGetActiveAttrib(s->prog_id, i, sizeof(attrib_name), + &length, &size, &type, attrib_name); + GLint location = glGetAttribLocation(s->prog_id, attrib_name); + printf("attrib idx: %d, location: %d, type: %s, name: %s \n", + i, location, glEnumToString(type), attrib_name); + + // TODO: create a gl_buffer for each vertex attrib... + // TODO: store attrib location on attrib struct + // TODO: replace POSITION, NORMAL, UV... etc enums in loadGLMesh() + // with extra logic to detect mesh to shader mapping + } + + printf("---------------------------------\n\n"); + return true; }