From 63dceb6cdf9787e601ec1963bfc5bb8f11de8087 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Mon, 7 Feb 2022 11:07:37 -0500 Subject: [PATCH] initialize GLBuffer members to sane defaults at creation --- src/shader.cpp | 8 ++++++++ src/shader.h | 6 ++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/shader.cpp b/src/shader.cpp index 1cce201..6260369 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -49,6 +49,14 @@ initGLContext(MemoryArena* arena, gl_ctx->shaders = ARENA_ALLOC(arena, ShaderProgram, max_shaders); gl_ctx->max_ubos = max_ubos; gl_ctx->uniform_buffers = ARENA_ALLOC(arena, GLBuffer, max_ubos); + + // NOTE: initialize GLBuffer struct members to sane defaults + for (u32 i = 0; i < max_ubos; i++) { + GLBuffer& buf = gl_ctx->uniform_buffers[i]; + buf.location = -1; + buf.binding_idx = -1; + } + gl_ctx->max_textures = max_textures; gl_ctx->textures = ARENA_ALLOC(arena, GLTexture, max_textures); diff --git a/src/shader.h b/src/shader.h index 7a19e1f..5eaf2ae 100644 --- a/src/shader.h +++ b/src/shader.h @@ -89,10 +89,8 @@ struct GLBuffer GLenum target; GLenum data_type; GLuint data_size; // NOTE: size of buffer in bytes - // FIXME: we should initialize both of these to UINT_MAX because '0' is a - // valid location and index - GLuint location; // NOTE: if used as backing for vertex attribute - GLuint binding_idx; // NOTE: if used as backing from uniform buffer object + GLint location; // NOTE: if used as backing for vertex attribute + GLint binding_idx; // NOTE: if used as backing from uniform buffer object char* name; };