From 616668dac3c67ff22c1463aeb9dd06c59dd235c8 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 15 Nov 2014 13:10:15 +0000 Subject: [PATCH] OpenGL example: uses offsetof() macros for vertice definition instead of hardcoded offsets --- examples/opengl_example/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp index f797ab5af..abdc30e64 100644 --- a/examples/opengl_example/main.cpp +++ b/examples/opengl_example/main.cpp @@ -64,9 +64,9 @@ static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_c { const ImDrawList* cmd_list = cmd_lists[n]; const unsigned char* vtx_buffer = (const unsigned char*)cmd_list->vtx_buffer.begin(); - glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer)); - glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer+8)); - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer+16)); + glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + offsetof(ImDrawVert, pos))); + glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + offsetof(ImDrawVert, uv))); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + offsetof(ImDrawVert, col))); int vtx_offset = 0; const ImDrawCmd* pcmd_end = cmd_list->commands.end();