mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-08 23:45:46 +01:00
Each imgui_impl_X.cppm builds one backend as module imgui.impl.X, following the same layout as imgui.cppm. The global module fragment holds the platform and graphics API headers, using the same conditions as the backend's .cpp. The purview imports std.compat and imgui and includes the backend header. The .cpp goes in 'module :private;'. The backend header includes imgui.h, but its declarations already come from 'import imgui;' and must not be redeclared in this module. Module units therefore define IMGUI_CXX_MODULE_IMPORTED, which makes imgui.h contribute only its macros. Usage: 'import imgui; import imgui.impl.glfw;'. Link the module library in place of the backend .cpp.
59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
// dear imgui: Platform Backend for GLFW, as a C++20 named module.
|
|
// See imgui.cppm for usage and design. Import with: 'import imgui; import imgui.impl.glfw;'
|
|
|
|
module;
|
|
|
|
#define IMGUI_CXX_MODULE 1
|
|
#define IMGUI_CXX_MODULE_IMPORTED 1
|
|
#include "imgui_macros.h"
|
|
#include <float.h> // FLT_MAX
|
|
|
|
// GLFW (same as imgui_impl_glfw.cpp)
|
|
#if defined(__has_include)
|
|
#if !__has_include(<X11/Xlib.h>) || !__has_include(<X11/extensions/Xrandr.h>)
|
|
#define IMGUI_IMPL_GLFW_DISABLE_X11
|
|
#endif
|
|
#endif
|
|
#include <GLFW/glfw3.h>
|
|
#ifdef _WIN32
|
|
#undef APIENTRY
|
|
#ifndef GLFW_EXPOSE_NATIVE_WIN32
|
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
|
#endif
|
|
#include <GLFW/glfw3native.h>
|
|
#elif defined(__APPLE__)
|
|
#ifndef GLFW_EXPOSE_NATIVE_COCOA
|
|
#define GLFW_EXPOSE_NATIVE_COCOA
|
|
#endif
|
|
#include <GLFW/glfw3native.h>
|
|
#elif !defined(IMGUI_IMPL_GLFW_DISABLE_X11) && (defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__))
|
|
#ifndef GLFW_EXPOSE_NATIVE_X11
|
|
#define GLFW_EXPOSE_NATIVE_X11
|
|
#endif
|
|
#include <GLFW/glfw3native.h>
|
|
#endif
|
|
#undef Status
|
|
#ifndef _WIN32
|
|
#include <unistd.h>
|
|
#endif
|
|
#ifdef __EMSCRIPTEN__
|
|
#include <emscripten.h>
|
|
#include <emscripten/html5.h>
|
|
#ifdef EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3
|
|
#include <GLFW/emscripten_glfw3.h>
|
|
#else
|
|
#define EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
|
#endif
|
|
#endif
|
|
|
|
export module imgui.impl.glfw;
|
|
|
|
import std.compat;
|
|
import imgui;
|
|
|
|
#include "imgui_impl_glfw.h"
|
|
|
|
module :private;
|
|
|
|
#include "imgui_impl_glfw.cpp"
|