|
|
|
@ -259,9 +259,11 @@ initTransforms(MemoryArena* arena, |
|
|
|
xform_ubo->target = GL_UNIFORM_BUFFER; |
|
|
|
xform_ubo->target = GL_UNIFORM_BUFFER; |
|
|
|
xform_ubo->data_type = GL_FLOAT; |
|
|
|
xform_ubo->data_type = GL_FLOAT; |
|
|
|
xform_ubo->name = arenaCopyCStr(arena, "matrices"); |
|
|
|
xform_ubo->name = arenaCopyCStr(arena, "matrices"); |
|
|
|
|
|
|
|
xform_ubo->data_size = sizeof(*xforms); |
|
|
|
|
|
|
|
|
|
|
|
glBindBuffer(xform_ubo->target, xform_ubo->id); |
|
|
|
glBindBuffer(xform_ubo->target, xform_ubo->id); |
|
|
|
glBufferData(xform_ubo->target, sizeof(*xforms), xforms, GL_DYNAMIC_DRAW); |
|
|
|
glBufferData(xform_ubo->target, xform_ubo->data_size, xforms, |
|
|
|
|
|
|
|
GL_DYNAMIC_DRAW); |
|
|
|
|
|
|
|
|
|
|
|
// NOTE: bindbufferbase
|
|
|
|
// NOTE: bindbufferbase
|
|
|
|
xform_ubo->binding_idx = gl_ctx->binding_count++; |
|
|
|
xform_ubo->binding_idx = gl_ctx->binding_count++; |
|
|
|
@ -330,13 +332,14 @@ loadGLMesh(const Mesh& m, |
|
|
|
attrib->buf_type = mappings[i].buf_type; |
|
|
|
attrib->buf_type = mappings[i].buf_type; |
|
|
|
u32 type_size = getGLTypeSize(attrib->data_type); |
|
|
|
u32 type_size = getGLTypeSize(attrib->data_type); |
|
|
|
assert(type_size > 0); |
|
|
|
assert(type_size > 0); |
|
|
|
|
|
|
|
buf.data_size = m.num_vertices * type_size; |
|
|
|
|
|
|
|
|
|
|
|
void* mesh_buf_data = getMeshData(m, mappings[i]); |
|
|
|
void* mesh_buf_data = getMeshData(m, mappings[i]); |
|
|
|
assert(mesh_buf_data); |
|
|
|
assert(mesh_buf_data); |
|
|
|
initGLAttribBuffer(&buf, GL_ARRAY_BUFFER, attrib); |
|
|
|
initGLAttribBuffer(&buf, GL_ARRAY_BUFFER, attrib); |
|
|
|
glBindBuffer(buf.target, buf.id); |
|
|
|
glBindBuffer(buf.target, buf.id); |
|
|
|
glBufferData(buf.target, |
|
|
|
glBufferData(buf.target, |
|
|
|
m.num_vertices * type_size, |
|
|
|
buf.data_size, |
|
|
|
mesh_buf_data, |
|
|
|
mesh_buf_data, |
|
|
|
glm.usage); |
|
|
|
glm.usage); |
|
|
|
glVertexAttribPointer(attrib->location, attrib->num_components, |
|
|
|
glVertexAttribPointer(attrib->location, attrib->num_components, |
|
|
|
@ -347,9 +350,10 @@ loadGLMesh(const Mesh& m, |
|
|
|
glGenBuffers(1, &glm.element_buf->id); |
|
|
|
glGenBuffers(1, &glm.element_buf->id); |
|
|
|
glm.element_buf->target = GL_ELEMENT_ARRAY_BUFFER; |
|
|
|
glm.element_buf->target = GL_ELEMENT_ARRAY_BUFFER; |
|
|
|
glm.element_buf->data_type = GL_UNSIGNED_SHORT; |
|
|
|
glm.element_buf->data_type = GL_UNSIGNED_SHORT; |
|
|
|
|
|
|
|
glm.element_buf->data_size = m.num_indices * sizeof(u16); |
|
|
|
glBindBuffer(glm.element_buf->target, glm.element_buf->id); |
|
|
|
glBindBuffer(glm.element_buf->target, glm.element_buf->id); |
|
|
|
glBufferData(glm.element_buf->target, |
|
|
|
glBufferData(glm.element_buf->target, |
|
|
|
m.num_indices * sizeof(u16), |
|
|
|
glm.element_buf->data_size, |
|
|
|
m.indices, |
|
|
|
m.indices, |
|
|
|
glm.usage); |
|
|
|
glm.usage); |
|
|
|
|
|
|
|
|
|
|
|
|