Skip to content

Commit e729fb9

Browse files
committed
imgui 1.90-docking source
1 parent 93058af commit e729fb9

13 files changed

+1338
-2567
lines changed

imgui/src/imgui/imconfig.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,12 @@
8080
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
8181

8282
//---- Include imgui_user.h at the end of imgui.h as a convenience
83-
// May be convenient for some users to only explicitly include vanilla imgui.h and have extra stuff included.
8483
//#define IMGUI_INCLUDE_IMGUI_USER_H
85-
//#define IMGUI_USER_H_FILENAME "my_folder/my_imgui_user.h"
8684

8785
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
8886
//#define IMGUI_USE_BGRA_PACKED_COLOR
8987

90-
//---- Use 32-bit for ImWchar (default is 16-bit) to support Unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
88+
//---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
9189
//#define IMGUI_USE_WCHAR32
9290

9391
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version

imgui/src/imgui/imgui.cpp

Lines changed: 552 additions & 1084 deletions
Large diffs are not rendered by default.

imgui/src/imgui/imgui.h

Lines changed: 249 additions & 292 deletions
Large diffs are not rendered by default.

imgui/src/imgui/imgui_demo.cpp

Lines changed: 76 additions & 184 deletions
Large diffs are not rendered by default.

imgui/src/imgui/imgui_draw.cpp

Lines changed: 23 additions & 334 deletions
Large diffs are not rendered by default.

imgui/src/imgui/imgui_impl_android.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static ImGuiKey ImGui_ImplAndroid_KeyCodeToImGuiKey(int32_t key_code)
159159
}
160160
}
161161

162-
int32_t ImGui_ImplAndroid_HandleInputEvent(const AInputEvent* input_event)
162+
int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
163163
{
164164
ImGuiIO& io = ImGui::GetIO();
165165
int32_t event_type = AInputEvent_getType(input_event);
@@ -186,7 +186,7 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(const AInputEvent* input_event)
186186
case AKEY_EVENT_ACTION_UP:
187187
{
188188
ImGuiKey key = ImGui_ImplAndroid_KeyCodeToImGuiKey(event_key_code);
189-
if (key != ImGuiKey_None)
189+
if (key != ImGuiKey_None && (event_action == AKEY_EVENT_ACTION_DOWN || event_action == AKEY_EVENT_ACTION_UP))
190190
{
191191
io.AddKeyEvent(key, event_action == AKEY_EVENT_ACTION_DOWN);
192192
io.SetKeyEventNativeData(key, event_key_code, event_scan_code);
@@ -224,27 +224,25 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(const AInputEvent* input_event)
224224
{
225225
case AMOTION_EVENT_ACTION_DOWN:
226226
case AMOTION_EVENT_ACTION_UP:
227-
{
228227
// Physical mouse buttons (and probably other physical devices) also invoke the actions AMOTION_EVENT_ACTION_DOWN/_UP,
229228
// but we have to process them separately to identify the actual button pressed. This is done below via
230229
// AMOTION_EVENT_ACTION_BUTTON_PRESS/_RELEASE. Here, we only process "FINGER" input (and "UNKNOWN", as a fallback).
231-
int tool_type = AMotionEvent_getToolType(input_event, event_pointer_index);
232-
if (tool_type == AMOTION_EVENT_TOOL_TYPE_FINGER || tool_type == AMOTION_EVENT_TOOL_TYPE_UNKNOWN)
230+
if((AMotionEvent_getToolType(input_event, event_pointer_index) == AMOTION_EVENT_TOOL_TYPE_FINGER)
231+
|| (AMotionEvent_getToolType(input_event, event_pointer_index) == AMOTION_EVENT_TOOL_TYPE_UNKNOWN))
233232
{
234233
io.AddMousePosEvent(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));
235234
io.AddMouseButtonEvent(0, event_action == AMOTION_EVENT_ACTION_DOWN);
236235
}
237236
break;
238-
}
239237
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
240238
case AMOTION_EVENT_ACTION_BUTTON_RELEASE:
241-
{
242-
int32_t button_state = AMotionEvent_getButtonState(input_event);
243-
io.AddMouseButtonEvent(0, (button_state & AMOTION_EVENT_BUTTON_PRIMARY) != 0);
244-
io.AddMouseButtonEvent(1, (button_state & AMOTION_EVENT_BUTTON_SECONDARY) != 0);
245-
io.AddMouseButtonEvent(2, (button_state & AMOTION_EVENT_BUTTON_TERTIARY) != 0);
239+
{
240+
int32_t button_state = AMotionEvent_getButtonState(input_event);
241+
io.AddMouseButtonEvent(0, (button_state & AMOTION_EVENT_BUTTON_PRIMARY) != 0);
242+
io.AddMouseButtonEvent(1, (button_state & AMOTION_EVENT_BUTTON_SECONDARY) != 0);
243+
io.AddMouseButtonEvent(2, (button_state & AMOTION_EVENT_BUTTON_TERTIARY) != 0);
244+
}
246245
break;
247-
}
248246
case AMOTION_EVENT_ACTION_HOVER_MOVE: // Hovering: Tool moves while NOT pressed (such as a physical mouse)
249247
case AMOTION_EVENT_ACTION_MOVE: // Touch pointer moves while DOWN
250248
io.AddMousePosEvent(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index));

imgui/src/imgui/imgui_impl_android.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct ANativeWindow;
3030
struct AInputEvent;
3131

3232
IMGUI_IMPL_API bool ImGui_ImplAndroid_Init(ANativeWindow* window);
33-
IMGUI_IMPL_API int32_t ImGui_ImplAndroid_HandleInputEvent(const AInputEvent* input_event);
33+
IMGUI_IMPL_API int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event);
3434
IMGUI_IMPL_API void ImGui_ImplAndroid_Shutdown();
3535
IMGUI_IMPL_API void ImGui_ImplAndroid_NewFrame();
3636

imgui/src/imgui/imgui_impl_opengl3.cpp

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323

2424
// CHANGELOG
2525
// (minor and older changes stripped away, please see git history for details)
26-
// 2024-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
27-
// 2024-01-09: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" and variants, fixing regression on distros missing a symlink.
28-
// 2023-11-08: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" instead of "libGL.so.1", accommodating for NetBSD systems having only "libGL.so.3" available. (#6983)
26+
// 2023-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
27+
// 2023-11-08: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" instead of "libGL.so.1", accomodating for NetBSD systems having only "libGL.so.3" available. (#6983)
2928
// 2023-10-05: OpenGL: Rename symbols in our internal loader so that LTO compilation with another copy of gl3w is possible. (#6875, #6668, #4445)
3029
// 2023-06-20: OpenGL: Fixed erroneous use glGetIntegerv(GL_CONTEXT_PROFILE_MASK) on contexts lower than 3.2. (#6539, #6333)
3130
// 2023-05-09: OpenGL: Support for glBindSampler() backup/restore on ES3. (#6375)
@@ -178,20 +177,9 @@
178177
#define GL_VERTEX_ARRAY_BINDING GL_VERTEX_ARRAY_BINDING_OES
179178
#endif
180179

181-
// Desktop GL 2.0+ has extension and glPolygonMode() which GL ES and WebGL don't have..
182-
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
183-
#define IMGUI_IMPL_OPENGL_HAS_EXTENSIONS // has glGetIntegerv(GL_NUM_EXTENSIONS)
184-
#define IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE // has glPolygonMode()
185-
#endif
186-
187-
// Desktop GL 2.1+ and GL ES 3.0+ have glBindBuffer() with GL_PIXEL_UNPACK_BUFFER target.
188-
#if !defined(IMGUI_IMPL_OPENGL_ES2)
189-
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
190-
#endif
191-
192-
// Desktop GL 3.1+ has GL_PRIMITIVE_RESTART state
193-
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_1)
194-
#define IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
180+
// Desktop GL 2.0+ has glPolygonMode() which GL ES and WebGL don't have.
181+
#ifdef GL_POLYGON_MODE
182+
#define IMGUI_IMPL_HAS_POLYGON_MODE
195183
#endif
196184

197185
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
@@ -204,6 +192,16 @@
204192
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
205193
#endif
206194

195+
// Desktop GL 3.1+ has GL_PRIMITIVE_RESTART state
196+
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_1)
197+
#define IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
198+
#endif
199+
200+
// Desktop GL use extension detection
201+
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
202+
#define IMGUI_IMPL_OPENGL_MAY_HAVE_EXTENSIONS
203+
#endif
204+
207205
// [Debugging]
208206
//#define IMGUI_IMPL_OPENGL_DEBUG
209207
#ifdef IMGUI_IMPL_OPENGL_DEBUG
@@ -367,7 +365,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
367365

368366
// Detect extensions we support
369367
bd->HasClipOrigin = (bd->GlVersion >= 450);
370-
#ifdef IMGUI_IMPL_OPENGL_HAS_EXTENSIONS
368+
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_EXTENSIONS
371369
GLint num_extensions = 0;
372370
glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
373371
for (GLint i = 0; i < num_extensions; i++)
@@ -423,7 +421,7 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
423421
if (bd->GlVersion >= 310)
424422
glDisable(GL_PRIMITIVE_RESTART);
425423
#endif
426-
#ifdef IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE
424+
#ifdef IMGUI_IMPL_HAS_POLYGON_MODE
427425
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
428426
#endif
429427

@@ -512,7 +510,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
512510
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
513511
GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
514512
#endif
515-
#ifdef IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE
513+
#ifdef IMGUI_IMPL_HAS_POLYGON_MODE
516514
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
517515
#endif
518516
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
@@ -651,7 +649,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
651649
if (bd->GlVersion >= 310) { if (last_enable_primitive_restart) glEnable(GL_PRIMITIVE_RESTART); else glDisable(GL_PRIMITIVE_RESTART); }
652650
#endif
653651

654-
#ifdef IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE
652+
#ifdef IMGUI_IMPL_HAS_POLYGON_MODE
655653
// Desktop OpenGL 3.0 and OpenGL 3.1 had separate polygon draw modes for front-facing and back-facing faces of polygons
656654
if (bd->GlVersion <= 310 || bd->GlProfileIsCompat)
657655
{
@@ -662,7 +660,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
662660
{
663661
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
664662
}
665-
#endif // IMGUI_IMPL_OPENGL_HAS_POLYGON_MODE
663+
#endif // IMGUI_IMPL_HAS_POLYGON_MODE
666664

667665
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
668666
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
@@ -759,10 +757,6 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
759757
GLint last_texture, last_array_buffer;
760758
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
761759
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
762-
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
763-
GLint last_pixel_unpack_buffer;
764-
if (bd->GlVersion >= 210) { glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &last_pixel_unpack_buffer); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); }
765-
#endif
766760
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
767761
GLint last_vertex_array;
768762
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
@@ -936,9 +930,6 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
936930
// Restore modified GL state
937931
glBindTexture(GL_TEXTURE_2D, last_texture);
938932
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
939-
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
940-
if (bd->GlVersion >= 210) { glBindBuffer(GL_PIXEL_UNPACK_BUFFER, last_pixel_unpack_buffer); }
941-
#endif
942933
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
943934
glBindVertexArray(last_vertex_array);
944935
#endif

imgui/src/imgui/imgui_impl_opengl3_loader.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ typedef khronos_intptr_t GLintptr;
260260
#define GL_ARRAY_BUFFER_BINDING 0x8894
261261
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
262262
#define GL_STREAM_DRAW 0x88E0
263-
#define GL_PIXEL_UNPACK_BUFFER 0x88EC
264-
#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
265263
typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
266264
typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
267265
typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
@@ -610,7 +608,7 @@ extern "C" {
610608

611609
#include <stdlib.h>
612610

613-
#define GL3W_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
611+
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
614612

615613
#if defined(_WIN32)
616614
#ifndef WIN32_LEAN_AND_MEAN
@@ -670,10 +668,6 @@ static int open_libgl(void)
670668
{
671669
// While most systems use libGL.so.1, NetBSD seems to use that libGL.so.3. See https://github.com/ocornut/imgui/issues/6983
672670
libgl = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL);
673-
if (!libgl)
674-
libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
675-
if (!libgl)
676-
libgl = dlopen("libGL.so.3", RTLD_LAZY | RTLD_LOCAL);
677671
if (!libgl)
678672
return GL3W_ERROR_LIBRARY_OPEN;
679673
*(void **)(&glx_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB");
@@ -806,7 +800,7 @@ GL3W_API union ImGL3WProcs imgl3wProcs;
806800
static void load_procs(GL3WGetProcAddressProc proc)
807801
{
808802
size_t i;
809-
for (i = 0; i < GL3W_ARRAY_SIZE(proc_names); i++)
803+
for (i = 0; i < ARRAY_SIZE(proc_names); i++)
810804
imgl3wProcs.ptr[i] = proc(proc_names[i]);
811805
}
812806

0 commit comments

Comments
 (0)