From 2aee4419e37899d6daee71566a1dc19c1bf57cf5 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 20 Nov 2014 08:15:21 +0000 Subject: [PATCH] Fixed compatibility with std::vector if user decide to #define ImVector --- examples/directx9_example/main.cpp | 6 +++--- examples/opengl_example/main.cpp | 6 +++--- imgui.cpp | 1 + imgui.h | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/directx9_example/main.cpp b/examples/directx9_example/main.cpp index 12fe6d27..16141de2 100644 --- a/examples/directx9_example/main.cpp +++ b/examples/directx9_example/main.cpp @@ -92,9 +92,9 @@ static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_c { // Render command list const ImDrawList* cmd_list = cmd_lists[n]; - const ImDrawCmd* pcmd_end = cmd_list->commands.end(); - for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++) - { + for (size_t cmd_i = 0; cmd_i < cmd_list->commands.size(); cmd_i++) + { + const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; const RECT r = { (LONG)pcmd->clip_rect.x, (LONG)pcmd->clip_rect.y, (LONG)pcmd->clip_rect.z, (LONG)pcmd->clip_rect.w }; g_pd3dDevice->SetScissorRect(&r); g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, vtx_offset, pcmd->vtx_count/3); diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp index abdc30e6..d6d7eddf 100644 --- a/examples/opengl_example/main.cpp +++ b/examples/opengl_example/main.cpp @@ -63,15 +63,15 @@ static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_c for (int n = 0; n < cmd_lists_count; n++) { const ImDrawList* cmd_list = cmd_lists[n]; - const unsigned char* vtx_buffer = (const unsigned char*)cmd_list->vtx_buffer.begin(); + const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->vtx_buffer.front(); 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(); - for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++) + for (size_t cmd_i = 0; cmd_i < cmd_list->commands.size(); cmd_i++) { + const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; glScissor((int)pcmd->clip_rect.x, (int)(height - pcmd->clip_rect.w), (int)(pcmd->clip_rect.z - pcmd->clip_rect.x), (int)(pcmd->clip_rect.w - pcmd->clip_rect.y)); glDrawArrays(GL_TRIANGLES, vtx_offset, pcmd->vtx_count); vtx_offset += pcmd->vtx_count; diff --git a/imgui.cpp b/imgui.cpp index 667e6533..177ad449 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -204,6 +204,7 @@ - input: rework IO to be able to pass actual events to fix temporal aliasing issues. - input: support track pad style scrolling & slider edit. - tooltip: move to fit within screen (e.g. when mouse cursor is right of the screen). + - clipboard: automatically transform \n into \n\r or equivalent for higher compability on windows - portability: big-endian test/support (github issue #81) - misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL - misc: not thread-safe diff --git a/imgui.h b/imgui.h index 56ddf2f3..1289e366 100644 --- a/imgui.h +++ b/imgui.h @@ -573,8 +573,8 @@ struct ImGuiTextBuffer ImGuiTextBuffer() { Buf.push_back(0); } ~ImGuiTextBuffer() { clear(); } - const char* begin() const { return Buf.begin(); } - const char* end() const { return Buf.end()-1; } + const char* begin() const { return &Buf.front(); } + const char* end() const { return &Buf.back(); } // Buf is zero-terminated, so end() will point on the zero-terminator size_t size() const { return Buf.size()-1; } bool empty() { return Buf.empty(); } void clear() { Buf.clear(); Buf.push_back(0); }