Skip to content

Commit 928a050

Browse files
committed
Updated to SDL3 and Imgui latest
1 parent 3ac72ae commit 928a050

18 files changed

+17244
-6351
lines changed

include/zest/imgui/imgui.h

Lines changed: 1291 additions & 716 deletions
Large diffs are not rendered by default.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline
2+
// - Desktop GL: 2.x 3.x 4.x
3+
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
4+
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
5+
6+
// Implemented features:
7+
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
8+
// [x] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset) [Desktop OpenGL only!]
9+
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
10+
11+
// About WebGL/ES:
12+
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
13+
// - This is done automatically on iOS, Android and Emscripten targets.
14+
// - For other targets, the define needs to be visible from the imgui_impl_opengl3.cpp compilation unit. If unsure, define globally or in imconfig.h.
15+
16+
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
17+
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
18+
// Learn about Dear ImGui:
19+
// - FAQ https://dearimgui.com/faq
20+
// - Getting Started https://dearimgui.com/getting-started
21+
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
22+
// - Introduction, links and more at the top of imgui.cpp
23+
24+
// About GLSL version:
25+
// The 'glsl_version' initialization parameter should be nullptr (default) or a "#version XXX" string.
26+
// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
27+
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
28+
29+
#pragma once
30+
#include "imgui.h" // IMGUI_IMPL_API
31+
#ifndef IMGUI_DISABLE
32+
33+
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
34+
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
35+
IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
36+
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
37+
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
38+
39+
// (Optional) Called by Init/NewFrame/Shutdown
40+
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
41+
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
42+
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
43+
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
44+
45+
// Configuration flags to add in your imconfig file:
46+
//#define IMGUI_IMPL_OPENGL_ES2 // Enable ES 2 (Auto-detected on Emscripten)
47+
//#define IMGUI_IMPL_OPENGL_ES3 // Enable ES 3 (Auto-detected on iOS/Android)
48+
49+
// You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
50+
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
51+
&& !defined(IMGUI_IMPL_OPENGL_ES3)
52+
53+
// Try to detect GLES on matching platforms
54+
#if defined(__APPLE__)
55+
#include <TargetConditionals.h>
56+
#endif
57+
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
58+
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
59+
#elif defined(__EMSCRIPTEN__) || defined(__amigaos4__)
60+
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
61+
#else
62+
// Otherwise imgui_impl_opengl3_loader.h will be used.
63+
#endif
64+
65+
#endif
66+
67+
#endif // #ifndef IMGUI_DISABLE

include/zest/imgui/imgui_impl_sdl2.h

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,46 @@
55
// Implemented features:
66
// [X] Platform: Clipboard support.
77
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen.
8-
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
8+
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values are obsolete since 1.87 and not supported since 1.91.5]
99
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
10-
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
10+
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
11+
// [X] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
1112
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
12-
// Missing features:
13-
// [ ] Platform: Multi-viewport + Minimized windows seems to break mouse wheel events (at least under Windows).
14-
// [x] Platform: Basic IME support. App needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
13+
// Missing features or Issues:
14+
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
15+
// [ ] Platform: Multi-viewport: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
1516

1617
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
1718
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
18-
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
19-
// Read online: https://github.com/ocornut/imgui/tree/master/docs
19+
// Learn about Dear ImGui:
20+
// - FAQ https://dearimgui.com/faq
21+
// - Getting Started https://dearimgui.com/getting-started
22+
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
23+
// - Introduction, links and more at the top of imgui.cpp
2024

2125
#pragma once
2226
#include "imgui.h" // IMGUI_IMPL_API
27+
#ifndef IMGUI_DISABLE
2328

2429
struct SDL_Window;
2530
struct SDL_Renderer;
31+
struct _SDL_GameController;
2632
typedef union SDL_Event SDL_Event;
2733

34+
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
2835
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
2936
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
3037
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
3138
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
3239
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
40+
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOther(SDL_Window* window);
3341
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
3442
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame();
3543
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
3644

37-
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
38-
static inline void ImGui_ImplSDL2_NewFrame(SDL_Window*) { ImGui_ImplSDL2_NewFrame(); } // 1.84: removed unnecessary parameter
39-
#endif
45+
// Gamepad selection automatically starts in AutoFirst mode, picking first available SDL_Gamepad. You may override this.
46+
// When using manual mode, caller is responsible for opening/closing gamepad.
47+
enum ImGui_ImplSDL2_GamepadMode { ImGui_ImplSDL2_GamepadMode_AutoFirst, ImGui_ImplSDL2_GamepadMode_AutoAll, ImGui_ImplSDL2_GamepadMode_Manual };
48+
IMGUI_IMPL_API void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode, struct _SDL_GameController** manual_gamepads_array = nullptr, int manual_gamepads_count = -1);
49+
50+
#endif // #ifndef IMGUI_DISABLE
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// dear imgui: Platform Backend for SDL3 (*EXPERIMENTAL*)
2+
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
3+
// (Info: SDL3 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
4+
5+
// (**IMPORTANT: SDL 3.0.0 is NOT YET RELEASED AND CURRENTLY HAS A FAST CHANGING API. THIS CODE BREAKS OFTEN AS SDL3 CHANGES.**)
6+
7+
// Implemented features:
8+
// [X] Platform: Clipboard support.
9+
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen.
10+
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values are obsolete since 1.87 and not supported since 1.91.5]
11+
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
12+
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
13+
// [x] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable' -> the OS animation effect when window gets created/destroyed is problematic. SDL2 backend doesn't have issue.
14+
// Missing features or Issues:
15+
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
16+
// [x] Platform: IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
17+
18+
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
19+
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
20+
// Learn about Dear ImGui:
21+
// - FAQ https://dearimgui.com/faq
22+
// - Getting Started https://dearimgui.com/getting-started
23+
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
24+
// - Introduction, links and more at the top of imgui.cpp
25+
26+
#pragma once
27+
#include "imgui.h" // IMGUI_IMPL_API
28+
#ifndef IMGUI_DISABLE
29+
30+
struct SDL_Window;
31+
struct SDL_Renderer;
32+
struct SDL_Gamepad;
33+
typedef union SDL_Event SDL_Event;
34+
35+
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
36+
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
37+
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window);
38+
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForD3D(SDL_Window* window);
39+
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForMetal(SDL_Window* window);
40+
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
41+
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForOther(SDL_Window* window);
42+
IMGUI_IMPL_API void ImGui_ImplSDL3_Shutdown();
43+
IMGUI_IMPL_API void ImGui_ImplSDL3_NewFrame();
44+
IMGUI_IMPL_API bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event);
45+
46+
// Gamepad selection automatically starts in AutoFirst mode, picking first available SDL_Gamepad. You may override this.
47+
// When using manual mode, caller is responsible for opening/closing gamepad.
48+
enum ImGui_ImplSDL3_GamepadMode { ImGui_ImplSDL3_GamepadMode_AutoFirst, ImGui_ImplSDL3_GamepadMode_AutoAll, ImGui_ImplSDL3_GamepadMode_Manual };
49+
IMGUI_IMPL_API void ImGui_ImplSDL3_SetGamepadMode(ImGui_ImplSDL3_GamepadMode mode, SDL_Gamepad** manual_gamepads_array = nullptr, int manual_gamepads_count = -1);
50+
51+
#endif // #ifndef IMGUI_DISABLE

0 commit comments

Comments
 (0)