Merge pull request #518 from Th3T3chn0G1t/master

demo/backend: Fixed UBSan trip in GLFW OpenGL3
This commit is contained in:
dumblob 2022-11-24 16:08:57 +01:00 committed by GitHub
commit 7ae6d7dacc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -240,7 +240,7 @@ nk_glfw3_render(struct nk_glfw* glfw, enum nk_anti_aliasing AA, int max_vertex_b
/* convert from command queue into draw list and draw to screen */
const struct nk_draw_command *cmd;
void *vertices, *elements;
const nk_draw_index *offset = NULL;
nk_size offset = 0;
/* allocate vertex and element buffer */
glBindVertexArray(dev->vao);
@ -292,8 +292,8 @@ nk_glfw3_render(struct nk_glfw* glfw, enum nk_anti_aliasing AA, int max_vertex_b
(GLint)((glfw->height - (GLint)(cmd->clip_rect.y + cmd->clip_rect.h)) * glfw->fb_scale.y),
(GLint)(cmd->clip_rect.w * glfw->fb_scale.x),
(GLint)(cmd->clip_rect.h * glfw->fb_scale.y));
glDrawElements(GL_TRIANGLES, (GLsizei)cmd->elem_count, GL_UNSIGNED_SHORT, offset);
offset += cmd->elem_count;
glDrawElements(GL_TRIANGLES, (GLsizei)cmd->elem_count, GL_UNSIGNED_SHORT, (const void*) offset);
offset += cmd->elem_count * sizeof(nk_draw_index);
}
nk_clear(&glfw->ctx);
nk_buffer_clear(&dev->cmds);