Browse Source

initialize GLBuffer members to sane defaults at creation

main
cinnaboot 4 years ago
parent
commit
63dceb6cdf
  1. 8
      src/shader.cpp
  2. 6
      src/shader.h

8
src/shader.cpp

@ -49,6 +49,14 @@ initGLContext(MemoryArena* arena,
gl_ctx->shaders = ARENA_ALLOC(arena, ShaderProgram, max_shaders); gl_ctx->shaders = ARENA_ALLOC(arena, ShaderProgram, max_shaders);
gl_ctx->max_ubos = max_ubos; gl_ctx->max_ubos = max_ubos;
gl_ctx->uniform_buffers = ARENA_ALLOC(arena, GLBuffer, 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->max_textures = max_textures;
gl_ctx->textures = ARENA_ALLOC(arena, GLTexture, max_textures); gl_ctx->textures = ARENA_ALLOC(arena, GLTexture, max_textures);

6
src/shader.h

@ -89,10 +89,8 @@ struct GLBuffer
GLenum target; GLenum target;
GLenum data_type; GLenum data_type;
GLuint data_size; // NOTE: size of buffer in bytes GLuint data_size; // NOTE: size of buffer in bytes
// FIXME: we should initialize both of these to UINT_MAX because '0' is a GLint location; // NOTE: if used as backing for vertex attribute
// valid location and index GLint binding_idx; // NOTE: if used as backing from uniform buffer object
GLuint location; // NOTE: if used as backing for vertex attribute
GLuint binding_idx; // NOTE: if used as backing from uniform buffer object
char* name; char* name;
}; };

Loading…
Cancel
Save