Skip to content

Commit

Permalink
library: fix ItemIcon matrix buffer offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamcake committed Dec 1, 2024
1 parent 03756f2 commit c3a74a0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/library/gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1625,16 +1625,17 @@ void _bolt_gl_onDrawElements(GLenum mode, GLsizei count, GLenum type, const void
if (tex && tex->compare_mode == GL_NONE && tex->internalformat == GL_RGBA8 && tex->width == GAME_ITEM_ICON_SIZE && tex->height == GAME_ITEM_ICON_SIZE && tex->icon.model_count < MAX_MODELS_PER_ICON) {
struct ItemIconModel* model = &tex->icon.models[tex->icon.model_count];
tex->icon.model_count += 1;
GLfloat model_matrix[16];
GLint ubo_binding, ubo_view_index;
gl.GetActiveUniformBlockiv(c->bound_program->id, c->bound_program->block_index_ViewTransforms, GL_UNIFORM_BLOCK_BINDING, &ubo_binding);
gl.GetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, ubo_binding, &ubo_view_index);
const uint8_t* ubo_view_buf = (uint8_t*)_bolt_context_get_buffer(c, ubo_view_index)->data;
gl.GetUniformfv(c->bound_program->id, c->bound_program->loc_uModelMatrix, model_matrix);
const float* viewmatrix = (float*)(ubo_view_buf + c->bound_program->offset_uViewMatrix);
const float* projmatrix = (float*)(ubo_view_buf + c->bound_program->offset_uProjectionMatrix);
const float* viewprojmatrix = (float*)(ubo_view_buf + c->bound_program->offset_uViewProjMatrix);
for (size_t i = 0; i < 16; i += 1) {
model->view_matrix.matrix[i] = (double)*(float*)(ubo_view_buf + c->bound_program->offset_uViewMatrix);
model->projection_matrix.matrix[i] = (double)*(float*)(ubo_view_buf + c->bound_program->offset_uProjectionMatrix);
model->viewproj_matrix.matrix[i] = (double)*(float*)(ubo_view_buf + c->bound_program->offset_uViewProjMatrix);
model->view_matrix.matrix[i] = (double)viewmatrix[i];
model->projection_matrix.matrix[i] = (double)projmatrix[i];
model->viewproj_matrix.matrix[i] = (double)viewprojmatrix[i];
}
model->vertex_count = count;
model->vertices = malloc(sizeof(*model->vertices) * count);
Expand Down

0 comments on commit c3a74a0

Please sign in to comment.