backends: prepare for inclusion in a C++20 module purview

Each backend becomes its own module that imports 'imgui' and includes
its header and source in the purview. Do the same preparation as for
the core:
- Skip system, platform and graphics API includes under
  IMGUI_CXX_MODULE, because the module includes them in its global
  module fragment.
- Skip the forward declarations of platform types (GLFWwindow,
  SDL_Window, ID3D11Device...). Declared in the purview, they would be
  new types attached to the backend module instead of the real ones.
  For the same reason, sdl2 drops the elaborated
  'struct _SDL_GameController'.
- Wrap each header's API in IMGUI_EXPORT_BEGIN/END.
- win32: export ImGui_ImplWin32_WndProcHandler() under IMGUI_CXX_MODULE.
  The header keeps it commented out to avoid pulling in <windows.h>,
  but a module user can't forward-declare it themselves.
- glfw: skip the local GetIO(ImGuiContext*) declaration, because
  'imgui' exports it.
This commit is contained in:
Sharadh Rajaraman 2026-09-28 16:30:10 +01:00
parent 6e99a5c717
commit 08fbbd9624
38 changed files with 138 additions and 4 deletions

View File

@ -66,6 +66,7 @@
#include "imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_impl_allegro5.h"
#ifndef IMGUI_CXX_MODULE
#include <stdint.h> // uint64_t
#include <cstring> // memcpy
@ -75,6 +76,7 @@
#ifdef _WIN32
#include <allegro5/allegro_windows.h>
#endif
#endif
#define ALLEGRO_HAS_CLIPBOARD ((ALLEGRO_VERSION_INT & ~ALLEGRO_UNSTABLE_BIT) >= ((5 << 24) | (1 << 16) | (12 << 8))) // Clipboard only supported from Allegro 5.1.12
#define ALLEGRO_HAS_DRAW_INDEXED_PRIM ((ALLEGRO_VERSION_INT & ~ALLEGRO_UNSTABLE_BIT) >= ((5 << 24) | (2 << 16) | ( 5 << 8))) // DX9 implementation of al_draw_indexed_prim() got fixed in Allegro 5.2.5

View File

@ -24,9 +24,12 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
#ifndef IMGUI_CXX_MODULE
struct ALLEGRO_DISPLAY;
union ALLEGRO_EVENT;
#endif
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display);
IMGUI_IMPL_API void ImGui_ImplAllegro5_Shutdown();
@ -41,5 +44,6 @@ IMGUI_IMPL_API void ImGui_ImplAllegro5_InvalidateDeviceObjects();
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
IMGUI_IMPL_API void ImGui_ImplAllegro5_UpdateTexture(ImTextureData* tex);
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -34,11 +34,13 @@
#include "imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_impl_android.h"
#ifndef IMGUI_CXX_MODULE
#include <time.h>
#include <android/native_window.h>
#include <android/input.h>
#include <android/keycodes.h>
#include <android/log.h>
#endif
// Android data
static double g_Time = 0.0;

View File

@ -25,13 +25,17 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
#ifndef IMGUI_CXX_MODULE
struct ANativeWindow;
struct AInputEvent;
#endif
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplAndroid_Init(ANativeWindow* window);
IMGUI_IMPL_API int32_t ImGui_ImplAndroid_HandleInputEvent(const AInputEvent* input_event);
IMGUI_IMPL_API void ImGui_ImplAndroid_Shutdown();
IMGUI_IMPL_API void ImGui_ImplAndroid_NewFrame();
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -47,10 +47,12 @@
#include "imgui_impl_dx10.h"
// DirectX
#ifndef IMGUI_CXX_MODULE
#include <stdio.h>
#include <d3d10_1.h>
#include <d3d10.h>
#include <d3dcompiler.h>
#endif
#ifdef _MSC_VER
#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
#endif

View File

@ -19,10 +19,13 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
#ifndef IMGUI_CXX_MODULE
struct ID3D10Device;
struct ID3D10SamplerState;
struct ID3D10Buffer;
#endif
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplDX10_Init(ID3D10Device* device);
IMGUI_IMPL_API void ImGui_ImplDX10_Shutdown();
@ -47,5 +50,6 @@ struct ImGui_ImplDX10_RenderState
//ID3D10SamplerState* SamplerNearest; // Use ImDrawList::AddCallback(ImGui::GetPlatform().DrawCallback_SetSamplerNearest)
};
IMGUI_IMPL_API ImGui_ImplDX10_RenderState* ImGui_ImplDX10_GetRenderState();
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -48,9 +48,11 @@
#include "imgui_impl_dx11.h"
// DirectX
#ifndef IMGUI_CXX_MODULE
#include <stdio.h>
#include <d3d11.h>
#include <d3dcompiler.h>
#endif
#ifdef _MSC_VER
#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
#endif

View File

@ -19,11 +19,14 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
#ifndef IMGUI_CXX_MODULE
struct ID3D11Device;
struct ID3D11DeviceContext;
struct ID3D11SamplerState;
struct ID3D11Buffer;
#endif
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context);
IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown();
@ -49,5 +52,6 @@ struct ImGui_ImplDX11_RenderState
//ID3D11SamplerState* SamplerNearest; // Use ImDrawList::AddCallback(ImGui::GetPlatform().DrawCallback_SetSamplerNearest)
};
IMGUI_IMPL_API ImGui_ImplDX11_RenderState* ImGui_ImplDX11_GetRenderState();
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -63,9 +63,11 @@
#include "imgui_impl_dx12.h"
// DirectX
#ifndef IMGUI_CXX_MODULE
#include <d3d12.h>
#include <dxgi1_5.h>
#include <d3dcompiler.h>
#endif
#ifdef _MSC_VER
#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
#endif

View File

@ -21,8 +21,10 @@
#pragma once
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
#ifndef IMGUI_CXX_MODULE
#include <dxgiformat.h> // DXGI_FORMAT
#include <d3d12.h> // D3D12_CPU_DESCRIPTOR_HANDLE
#endif
// Clang/GCC warnings with -Weverything
#if defined(__clang__)
@ -30,6 +32,7 @@
#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast
#endif
IMGUI_EXPORT_BEGIN
// Initialization data, for ImGui_ImplDX12_Init()
struct ImGui_ImplDX12_InitInfo
{
@ -84,6 +87,8 @@ IMGUI_IMPL_API ImGui_ImplDX12_RenderState* ImGui_ImplDX12_GetRenderState();
//IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* srv_descriptor_heap, D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
#endif
IMGUI_EXPORT_END
#if defined(__clang__)
#pragma clang diagnostic pop
#endif

View File

@ -47,7 +47,9 @@
#include "imgui_impl_dx9.h"
// DirectX
#ifndef IMGUI_CXX_MODULE
#include <d3d9.h>
#endif
// Clang/GCC warnings with -Weverything
#if defined(__clang__)

View File

@ -19,8 +19,11 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
#ifndef IMGUI_CXX_MODULE
struct IDirect3DDevice9;
#endif
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device);
IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown();
@ -33,5 +36,6 @@ IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects();
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
IMGUI_IMPL_API void ImGui_ImplDX9_UpdateTexture(ImTextureData* tex);
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -132,6 +132,7 @@
#else
#define GLFW_HAS_WAYLAND 0
#endif
#ifndef IMGUI_CXX_MODULE
#include <GLFW/glfw3.h>
#ifdef _WIN32
#undef APIENTRY
@ -165,6 +166,7 @@
#define EMSCRIPTEN_USE_EMBEDDED_GLFW3
#endif
#endif
#endif // #ifndef IMGUI_CXX_MODULE
// We gather version tests as define in order to easily see which features are version-dependent.
#define GLFW_VERSION_COMBINED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 + GLFW_VERSION_REVISION)
@ -241,7 +243,9 @@ struct ImGui_ImplGlfw_Data
// (passing install_callbacks=false in ImGui_ImplGlfw_InitXXX functions), set the current dear imgui context and then call our callbacks.
// - Otherwise we may need to store a GLFWWindow* -> ImGuiContext* map and handle this in the backend, adding a little bit of extra complexity to it.
// FIXME: some shared resources (mouse cursor shape, gamepad) are mishandled when using multi-context.
#ifndef IMGUI_CXX_MODULE
namespace ImGui { extern ImGuiIO& GetIO(ImGuiContext*); }
#endif
static ImGui_ImplGlfw_Data* ImGui_ImplGlfw_GetBackendData()
{
// Get data for current context

View File

@ -26,9 +26,12 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
#ifndef IMGUI_CXX_MODULE
struct GLFWwindow;
struct GLFWmonitor;
#endif
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks);
@ -66,6 +69,6 @@ IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int
IMGUI_IMPL_API void ImGui_ImplGlfw_Sleep(int milliseconds);
IMGUI_IMPL_API float ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window);
IMGUI_IMPL_API float ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor);
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -37,12 +37,14 @@
#include "imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_impl_glut.h"
#ifndef IMGUI_CXX_MODULE
#define GL_SILENCE_DEPRECATION
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/freeglut.h>
#endif
#endif
#ifdef _MSC_VER
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)

View File

@ -26,6 +26,7 @@
#ifndef IMGUI_DISABLE
#include "imgui.h" // IMGUI_IMPL_API
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplGLUT_Init();
IMGUI_IMPL_API void ImGui_ImplGLUT_InstallFuncs();
@ -43,5 +44,6 @@ IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int
IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc
IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc
IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -13,6 +13,7 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
// Null = NullPlatform + NullRender
@ -30,5 +31,6 @@ IMGUI_IMPL_API bool ImGui_ImplNullRender_Init();
IMGUI_IMPL_API void ImGui_ImplNullRender_Shutdown();
IMGUI_IMPL_API void ImGui_ImplNullRender_NewFrame();
IMGUI_IMPL_API void ImGui_ImplNullRender_RenderDrawData(ImDrawData* draw_data);
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -56,7 +56,9 @@
#include "imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_impl_opengl2.h"
#ifndef IMGUI_CXX_MODULE
#include <stdint.h> // intptr_t
#endif
// Clang/GCC warnings with -Weverything
#if defined(__clang__)
@ -66,6 +68,7 @@
#endif
// Include OpenGL header (without an OpenGL loader) requires a bit of fiddling
#ifndef IMGUI_CXX_MODULE
#if defined(_WIN32) && !defined(APIENTRY)
#define APIENTRY __stdcall // It is customary to use APIENTRY for OpenGL function pointer declarations on all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
#endif
@ -78,11 +81,14 @@
#else
#include <GL/gl.h>
#endif
#endif
// [Debugging]
//#define IMGUI_IMPL_OPENGL_DEBUG
#ifdef IMGUI_IMPL_OPENGL_DEBUG
#ifndef IMGUI_CXX_MODULE
#include <stdio.h>
#endif
#define GL_CALL(_CALL) do { _CALL; GLenum gl_err = glGetError(); if (gl_err != 0) fprintf(stderr, "GL error 0x%x returned from '%s'.\n", gl_err, #_CALL); } while (0) // Call with error check
#else
#define GL_CALL(_CALL) _CALL // Call without error check

View File

@ -28,6 +28,7 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_Init();
IMGUI_IMPL_API void ImGui_ImplOpenGL2_Shutdown();
@ -40,5 +41,6 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyDeviceObjects();
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = nullptr to handle this manually.
IMGUI_IMPL_API void ImGui_ImplOpenGL2_UpdateTexture(ImTextureData* tex);
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -133,11 +133,13 @@
#include "imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_impl_opengl3.h"
#ifndef IMGUI_CXX_MODULE
#include <stdio.h>
#include <stdint.h> // intptr_t
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif
#endif
// Clang/GCC warnings with -Weverything
#if defined(__clang__)
@ -158,6 +160,7 @@
#endif
// GL includes
#ifndef IMGUI_CXX_MODULE
#if defined(IMGUI_IMPL_OPENGL_ES2)
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV))
#include <OpenGLES/ES2/gl.h> // Use GL ES 2
@ -189,6 +192,7 @@
#define IMGUI_IMPL_OPENGL_LOADER_IMGL3W
#include "imgui_impl_opengl3_loader.h"
#endif
#endif // #ifndef IMGUI_CXX_MODULE
// Vertex arrays are not supported on ES2/WebGL1 unless Emscripten which uses an extension
#ifndef IMGUI_IMPL_OPENGL_ES2
@ -231,7 +235,9 @@
// [Debugging]
//#define IMGUI_IMPL_OPENGL_DEBUG
#ifdef IMGUI_IMPL_OPENGL_DEBUG
#ifndef IMGUI_CXX_MODULE
#include <stdio.h>
#endif
#define GL_CALL(_CALL) do { _CALL; GLenum gl_err = glGetError(); if (gl_err != 0) fprintf(stderr, "GL error 0x%x returned from '%s'.\n", gl_err, #_CALL); } while (0) // Call with error check
#else
#define GL_CALL(_CALL) _CALL // Call without error check

View File

@ -31,6 +31,7 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
@ -53,7 +54,7 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_UpdateTexture(ImTextureData* tex);
&& !defined(IMGUI_IMPL_OPENGL_ES3)
// Try to detect GLES on matching platforms
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(IMGUI_CXX_MODULE)
#include <TargetConditionals.h>
#endif
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
@ -77,5 +78,6 @@ struct ImGui_ImplOpenGL3_RenderState
unsigned int CurrentTexParameterFilter; // (GLuint) Used if UseTexParameterFilter == true
};
IMGUI_IMPL_API ImGui_ImplOpenGL3_RenderState* ImGui_ImplOpenGL3_GetRenderState();
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -20,11 +20,13 @@
#ifndef IMGUI_DISABLE
#include "imgui_impl_qnx.h"
#ifndef IMGUI_CXX_MODULE
#include <float.h>
#include <stdint.h>
#include <string.h>
#include <sys/keycodes.h>
#include <time.h>
#endif
static unsigned int ImGui_ImplQNX_KeySymToUnicode(unsigned int keysym);

View File

@ -23,13 +23,17 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
#ifndef IMGUI_CXX_MODULE
#include <screen/screen.h>
#endif
IMGUI_EXPORT_BEGIN
// The application owns the Screen context, window and event object.
// Poll events with screen_get_event() and pass each non-NONE event to ProcessEvent().
IMGUI_IMPL_API bool ImGui_ImplQNX_Init(screen_context_t context, screen_window_t window);
IMGUI_IMPL_API void ImGui_ImplQNX_Shutdown();
IMGUI_IMPL_API void ImGui_ImplQNX_NewFrame();
IMGUI_IMPL_API bool ImGui_ImplQNX_ProcessEvent(screen_event_t event);
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -118,6 +118,7 @@
#endif
// SDL
#ifndef IMGUI_CXX_MODULE
#include <SDL.h>
#include <SDL_syswm.h>
#include <stdio.h> // for snprintf()
@ -127,6 +128,7 @@
#ifdef __EMSCRIPTEN__
#include <emscripten/em_js.h>
#endif
#endif
#undef Status // X11 headers are leaking this.
#if SDL_VERSION_ATLEAST(2,0,4) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS) && !defined(__amigaos4__)
@ -142,12 +144,14 @@
#define SDL_HAS_METAL 0
#endif
#define SDL_HAS_OPEN_URL SDL_VERSION_ATLEAST(2,0,14)
#ifndef IMGUI_CXX_MODULE
#if SDL_HAS_VULKAN
#include <SDL_vulkan.h>
#endif
#if SDL_HAS_METAL
#include <SDL_metal.h>
#endif
#endif
// SDL Data
struct ImGui_ImplSDL2_Data
@ -803,7 +807,7 @@ static void ImGui_ImplSDL2_CloseGamepads()
bd->Gamepads.resize(0);
}
void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode, struct _SDL_GameController** manual_gamepads_array, int manual_gamepads_count)
void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode, _SDL_GameController** manual_gamepads_array, int manual_gamepads_count)
{
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
ImGui_ImplSDL2_CloseGamepads();

View File

@ -22,11 +22,14 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
#ifndef IMGUI_CXX_MODULE
struct SDL_Window;
struct SDL_Renderer;
struct _SDL_GameController;
typedef union SDL_Event SDL_Event;
#endif
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
@ -45,7 +48,7 @@ IMGUI_IMPL_API float ImGui_ImplSDL2_GetContentScaleForDisplay(int display_ind
// Gamepad selection automatically starts in AutoFirst mode, picking first available SDL_Gamepad. You may override this.
// When using manual mode, caller is responsible for opening/closing gamepad.
enum ImGui_ImplSDL2_GamepadMode { ImGui_ImplSDL2_GamepadMode_AutoFirst, ImGui_ImplSDL2_GamepadMode_AutoAll, ImGui_ImplSDL2_GamepadMode_Manual };
IMGUI_IMPL_API void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode, struct _SDL_GameController** manual_gamepads_array = nullptr, int manual_gamepads_count = -1);
IMGUI_IMPL_API void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode, _SDL_GameController** manual_gamepads_array = nullptr, int manual_gamepads_count = -1);
// (Advanced, for X11 users) Override Mouse Capture mode. Mouse capture allows receiving updated mouse position after clicking inside our window and dragging outside it.
// Having this 'Enabled' is in theory always better. But, on X11 if you crash/break to debugger while capture is active you may temporarily lose access to your mouse.
@ -53,5 +56,6 @@ IMGUI_IMPL_API void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode
// But you may independently decide on X11, when a debugger is attached, to set this value to ImGui_ImplSDL2_MouseCaptureMode_Disabled.
enum ImGui_ImplSDL2_MouseCaptureMode { ImGui_ImplSDL2_MouseCaptureMode_Enabled, ImGui_ImplSDL2_MouseCaptureMode_EnabledAfterDrag, ImGui_ImplSDL2_MouseCaptureMode_Disabled };
IMGUI_IMPL_API void ImGui_ImplSDL2_SetMouseCaptureMode(ImGui_ImplSDL2_MouseCaptureMode mode);
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -77,6 +77,7 @@
#endif
// SDL
#ifndef IMGUI_CXX_MODULE
#include <SDL3/SDL.h>
#include <stdio.h> // for snprintf()
#if defined(__APPLE__)
@ -88,6 +89,7 @@
#endif
#include <windows.h>
#endif
#endif
#if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS) && !defined(__amigaos4__)
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 1

View File

@ -22,11 +22,14 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
#ifndef IMGUI_CXX_MODULE
struct SDL_Window;
struct SDL_Renderer;
struct SDL_Gamepad;
typedef union SDL_Event SDL_Event;
#endif
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForVulkan(SDL_Window* window);
@ -50,5 +53,6 @@ IMGUI_IMPL_API void ImGui_ImplSDL3_SetGamepadMode(ImGui_ImplSDL3_GamepadMode
// But you may independently decide on X11, when a debugger is attached, to set this value to ImGui_ImplSDL3_MouseCaptureMode_Disabled.
enum ImGui_ImplSDL3_MouseCaptureMode { ImGui_ImplSDL3_MouseCaptureMode_Enabled, ImGui_ImplSDL3_MouseCaptureMode_EnabledAfterDrag, ImGui_ImplSDL3_MouseCaptureMode_Disabled };
IMGUI_IMPL_API void ImGui_ImplSDL3_SetMouseCaptureMode(ImGui_ImplSDL3_MouseCaptureMode mode);
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -25,8 +25,11 @@
#pragma once
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
#ifndef IMGUI_CXX_MODULE
#include <SDL3/SDL_gpu.h>
#endif
IMGUI_EXPORT_BEGIN
// Initialization data, for ImGui_ImplSDLGPU_Init()
// - Remember to set ColorTargetFormat to the correct format. If you're rendering to the swapchain, call SDL_GetGPUSwapchainTextureFormat() to query the right value
struct ImGui_ImplSDLGPU3_InitInfo
@ -60,5 +63,6 @@ struct ImGui_ImplSDLGPU3_RenderState
SDL_GPUDevice* Device;
};
IMGUI_IMPL_API ImGui_ImplSDLGPU3_RenderState* ImGui_ImplSDLGPU3_GetRenderState();
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -44,7 +44,9 @@
#include "imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_impl_sdlrenderer2.h"
#ifndef IMGUI_CXX_MODULE
#include <stdint.h> // intptr_t
#endif
// Clang warnings with -Weverything
#if defined(__clang__)
@ -55,8 +57,10 @@
#endif
// SDL
#ifndef IMGUI_CXX_MODULE
#include <SDL_render.h>
#include <SDL_version.h>
#endif
#if !SDL_VERSION_ATLEAST(2,0,17)
#error This backend requires SDL 2.0.17+ because of SDL_RenderGeometry() function
#endif

View File

@ -29,8 +29,11 @@
#ifndef IMGUI_DISABLE
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_CXX_MODULE
struct SDL_Renderer;
#endif
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer);
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_Shutdown();
@ -52,5 +55,6 @@ struct ImGui_ImplSDLRenderer2_RenderState
SDL_Renderer* Renderer;
};
IMGUI_IMPL_API ImGui_ImplSDLRenderer2_RenderState* ImGui_ImplSDLRenderer2_GetRenderState();
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -41,7 +41,9 @@
#include "imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_impl_sdlrenderer3.h"
#ifndef IMGUI_CXX_MODULE
#include <stdint.h> // intptr_t
#endif
// Clang warnings with -Weverything
#if defined(__clang__)
@ -52,8 +54,10 @@
#endif
// SDL
#ifndef IMGUI_CXX_MODULE
#include <SDL3/SDL_render.h>
#include <SDL3/SDL_version.h>
#endif
#if !SDL_VERSION_ATLEAST(3,0,0)
#error This backend requires SDL 3.0.0+
#endif

View File

@ -28,8 +28,11 @@
#ifndef IMGUI_DISABLE
// For SDL_ScaleMode which cannot be forward declared.
#ifndef IMGUI_CXX_MODULE
#include <SDL3/SDL_render.h>
#endif
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer);
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_Shutdown();
@ -52,5 +55,6 @@ struct ImGui_ImplSDLRenderer3_RenderState
SDL_ScaleMode CurrentScaleMode; // Current scale mode during render. Set to SDL_SCALEMODE_INVALID to use "SetSamplerFromTex" mode.
};
IMGUI_IMPL_API ImGui_ImplSDLRenderer3_RenderState* ImGui_ImplSDLRenderer3_GetRenderState();
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -118,7 +118,9 @@
#include "imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_impl_vulkan.h"
#ifndef IMGUI_CXX_MODULE
#include <stdio.h>
#endif
#ifndef IM_MAX
#define IM_MAX(A, B) (((A) >= (B)) ? (A) : (B))
#endif

View File

@ -64,6 +64,7 @@
#endif
// Vulkan includes
#ifndef IMGUI_CXX_MODULE
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
#ifdef IMGUI_IMPL_VULKAN_VOLK_FILENAME
#include IMGUI_IMPL_VULKAN_VOLK_FILENAME
@ -73,6 +74,7 @@
#else
#include <vulkan/vulkan.h>
#endif
#endif
#if defined(VK_VERSION_1_3) || defined(VK_KHR_dynamic_rendering)
#define IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
#endif
@ -81,6 +83,7 @@
#define IMGUI_IMPL_VULKAN_MINIMUM_SAMPLED_IMAGE_POOL_SIZE (8) // Minimum per atlas
#define IMGUI_IMPL_VULKAN_MINIMUM_SAMPLER_POOL_SIZE (2) // Minimum for linear + nearest
IMGUI_EXPORT_BEGIN
// Specify settings to create pipeline and swapchain
struct ImGui_ImplVulkan_PipelineInfo
{
@ -273,6 +276,8 @@ struct ImGui_ImplVulkanH_Window
}
};
IMGUI_EXPORT_END
#if defined(__clang__)
#pragma clang diagnostic pop
#endif

View File

@ -57,8 +57,10 @@
#ifndef IMGUI_DISABLE
#include "imgui_impl_wgpu.h"
#ifndef IMGUI_CXX_MODULE
#include <limits.h>
#include <stdio.h>
#endif
// One of IMGUI_IMPL_WEBGPU_BACKEND_DAWN or IMGUI_IMPL_WEBGPU_BACKEND_WGPU must be provided. See imgui_impl_wgpu.h for more details.
#if !defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) && !defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU) && !defined(IMGUI_IMPL_WEBGPU_BACKEND_WGVK)
@ -69,7 +71,9 @@
#endif
// Dear ImGui prototypes from imgui_internal.h
#ifndef IMGUI_CXX_MODULE
extern ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed);
#endif
#define MEMALIGN(_SIZE,_ALIGN) (((_SIZE) + ((_ALIGN) - 1)) & ~((_ALIGN) - 1)) // Memory align (copied from IM_ALIGN() macro).
// WebGPU data
@ -1083,12 +1087,14 @@ void ImGui_ImplWGPU_DebugPrintAdapterInfo(const WGPUAdapter& adapter)
#if defined(__APPLE__)
// MacOS specific: is necessary to compile with "-x objective-c++" flags
// (e.g. using cmake: set_source_files_properties(${IMGUI_DIR}/backends/imgui_impl_wgpu.cpp PROPERTIES COMPILE_FLAGS "-x objective-c++") )
#ifndef IMGUI_CXX_MODULE
#include <TargetConditionals.h>
#if TARGET_OS_OSX
#include <Cocoa/Cocoa.h>
#include <QuartzCore/CAMetalLayer.h>
#endif
#endif
#endif
WGPUSurface ImGui_ImplWGPU_CreateWGPUSurfaceHelper(ImGui_ImplWGPU_CreateSurfaceInfo* info)
{

View File

@ -34,15 +34,20 @@
// Setup Emscripten default if not specified.
#if defined(__EMSCRIPTEN__) && !defined(IMGUI_IMPL_WEBGPU_BACKEND_DAWN) && !defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU)
#ifndef IMGUI_CXX_MODULE
#include <emscripten/version.h>
#endif
#define IMGUI_IMPL_WEBGPU_BACKEND_DAWN
#endif
#ifndef IMGUI_CXX_MODULE
#include <webgpu/webgpu.h>
#if defined(IMGUI_IMPL_WEBGPU_BACKEND_WGPU) && !defined(__EMSCRIPTEN__)
#include <webgpu/wgpu.h> // WGPULogLevel
#endif
#endif
IMGUI_EXPORT_BEGIN
// Initialization data, for ImGui_ImplWGPU_Init()
struct ImGui_ImplWGPU_InitInfo
{
@ -115,5 +120,6 @@ struct ImGui_ImplWGPU_CreateSurfaceInfo
};
WGPUSurface ImGui_ImplWGPU_CreateWGPUSurfaceHelper(ImGui_ImplWGPU_CreateSurfaceInfo* info);
#endif // #ifndef __EMSCRIPTEN__
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE

View File

@ -86,6 +86,7 @@
#include "imgui.h"
#ifndef IMGUI_DISABLE
#include "imgui_impl_win32.h"
#ifndef IMGUI_CXX_MODULE
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
@ -93,10 +94,13 @@
#include <windowsx.h> // GET_X_LPARAM(), GET_Y_LPARAM()
#include <tchar.h>
#include <dwmapi.h>
#endif
// Using XInput for gamepad (will load DLL dynamically)
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
#ifndef IMGUI_CXX_MODULE
#include <xinput.h>
#endif
typedef DWORD(WINAPI* PFN_XInputGetCapabilities)(DWORD, DWORD, XINPUT_CAPABILITIES*);
typedef DWORD(WINAPI* PFN_XInputGetState)(DWORD, XINPUT_STATE*);
#endif

View File

@ -20,6 +20,7 @@
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
IMGUI_EXPORT_BEGIN
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd);
IMGUI_IMPL_API bool ImGui_ImplWin32_InitForOpenGL(void* hwnd);
@ -34,6 +35,9 @@ IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
#if 0
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
#endif
#ifdef IMGUI_CXX_MODULE // (C++20 module: exported instead, as a forward declaration in your code wouldn't be attached to the module)
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
#endif
// DPI-related helpers (optional)
// - Use to enable DPI awareness without having to create an application manifest.
@ -49,5 +53,6 @@ IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); //
// - Use to enable alpha compositing transparency with the desktop.
// - Use together with e.g. clearing your framebuffer with zero-alpha.
IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd
IMGUI_EXPORT_END
#endif // #ifndef IMGUI_DISABLE