mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 05:27:01 +00:00
Added IMGUI_CHECKVERSION() macro to compare version string and data structure sizes in order to catch issues with mismatching compilation unit settings. (#1695, #1769)
This commit is contained in:
parent
711a63befc
commit
eb1c36fdfb
@ -57,7 +57,9 @@ Other Changes:
|
|||||||
- InputText: On Mac OS X, filter out characters when the Cmd modifier is held. (#1747) [@sivu]
|
- InputText: On Mac OS X, filter out characters when the Cmd modifier is held. (#1747) [@sivu]
|
||||||
- InputText: On Mac OS X, support Cmd+Shift+Z for Redo. Cmd+Y is also supported as major apps seems to default to support both. (#1765) [@lfnoise]
|
- InputText: On Mac OS X, support Cmd+Shift+Z for Redo. Cmd+Y is also supported as major apps seems to default to support both. (#1765) [@lfnoise]
|
||||||
- Style: Changed default style.DisplaySafeAreaPadding values from (4,4) to (3,3) so it is smaller than FramePadding and has no effect on main menu bar on a computer. (#1439)
|
- Style: Changed default style.DisplaySafeAreaPadding values from (4,4) to (3,3) so it is smaller than FramePadding and has no effect on main menu bar on a computer. (#1439)
|
||||||
|
- Misc: Added IMGUI_CHECKVERSION() macro to compare version string and data structure sizes in order to catch issues with mismatching compilation unit settings. (#1695, #1769)
|
||||||
- Demo: Fixed Overlay: Added a context menu item to enable freely moving the window.
|
- Demo: Fixed Overlay: Added a context menu item to enable freely moving the window.
|
||||||
|
- Examples: Calling IMGUI_CHECKVERSION() in the main.cpp of every example application.
|
||||||
- Examples: Allegro 5: Added support for 32-bit indices setup via defining ImDrawIdx, to avoid an unnecessary conversion (Allegro 5 doesn't support 16-bit indices).
|
- Examples: Allegro 5: Added support for 32-bit indices setup via defining ImDrawIdx, to avoid an unnecessary conversion (Allegro 5 doesn't support 16-bit indices).
|
||||||
- Examples: Allegro 5: Renamed bindings from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp.
|
- Examples: Allegro 5: Renamed bindings from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp.
|
||||||
- Various minor fixes, tweaks, refactoring, comments.
|
- Various minor fixes, tweaks, refactoring, comments.
|
||||||
|
@ -22,7 +22,8 @@ int main(int, char**)
|
|||||||
al_register_event_source(queue, al_get_keyboard_event_source());
|
al_register_event_source(queue, al_get_keyboard_event_source());
|
||||||
al_register_event_source(queue, al_get_mouse_event_source());
|
al_register_event_source(queue, al_get_mouse_event_source());
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup Dear ImGui binding
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
@ -111,7 +111,8 @@ int main(int, char**)
|
|||||||
ShowWindow(hwnd, SW_SHOWDEFAULT);
|
ShowWindow(hwnd, SW_SHOWDEFAULT);
|
||||||
UpdateWindow(hwnd);
|
UpdateWindow(hwnd);
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup Dear ImGui binding
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
@ -114,7 +114,8 @@ int main(int, char**)
|
|||||||
ShowWindow(hwnd, SW_SHOWDEFAULT);
|
ShowWindow(hwnd, SW_SHOWDEFAULT);
|
||||||
UpdateWindow(hwnd);
|
UpdateWindow(hwnd);
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup Dear ImGui binding
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
@ -285,7 +285,8 @@ int main(int, char**)
|
|||||||
ShowWindow(hwnd, SW_SHOWDEFAULT);
|
ShowWindow(hwnd, SW_SHOWDEFAULT);
|
||||||
UpdateWindow(hwnd);
|
UpdateWindow(hwnd);
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup Dear ImGui binding
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
@ -74,7 +74,8 @@ int main(int, char**)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup Dear ImGui binding
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
@ -16,7 +16,8 @@ int main(int, char**)
|
|||||||
{
|
{
|
||||||
IwGxInit();
|
IwGxInit();
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup Dear ImGui binding
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ int main(int, char**)
|
|||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapInterval(1); // Enable vsync
|
glfwSwapInterval(1); // Enable vsync
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup Dear ImGui binding
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
@ -31,7 +31,8 @@ int main(int, char**)
|
|||||||
glfwSwapInterval(1); // Enable vsync
|
glfwSwapInterval(1); // Enable vsync
|
||||||
gl3wInit();
|
gl3wInit();
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup Dear ImGui binding
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
@ -33,7 +33,8 @@ int main(int, char**)
|
|||||||
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
||||||
SDL_GL_SetSwapInterval(1); // Enable vsync
|
SDL_GL_SetSwapInterval(1); // Enable vsync
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup Dear ImGui binding
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
@ -33,7 +33,8 @@ int main(int, char**)
|
|||||||
SDL_GL_SetSwapInterval(1); // Enable vsync
|
SDL_GL_SetSwapInterval(1); // Enable vsync
|
||||||
gl3wInit();
|
gl3wInit();
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup Dear ImGui binding
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
@ -625,7 +625,8 @@ int main(int, char**)
|
|||||||
setup_vulkan(window);
|
setup_vulkan(window);
|
||||||
glfwSetFramebufferSizeCallback(window, glfw_resize_callback);
|
glfwSetFramebufferSizeCallback(window, glfw_resize_callback);
|
||||||
|
|
||||||
// Setup ImGui binding
|
// Setup Dear ImGui binding
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
ImGui_ImplGlfwVulkan_Init_Data init_data = {};
|
ImGui_ImplGlfwVulkan_Init_Data init_data = {};
|
||||||
|
14
imgui.cpp
14
imgui.cpp
@ -2644,6 +2644,20 @@ void ImGui::SetCurrentContext(ImGuiContext* ctx)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function to verify that the type sizes are matching between the calling file's compilation unit and imgui.cpp's compilation unit
|
||||||
|
// If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. you may see different structures from what imgui.cpp sees which is highly problematic.
|
||||||
|
bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert)
|
||||||
|
{
|
||||||
|
bool error = false;
|
||||||
|
if (strcmp(version, IMGUI_VERSION)!=0) { error = true; IM_ASSERT(strcmp(version,IMGUI_VERSION)==0 && "Mismatch version string!"); }
|
||||||
|
if (sz_io != sizeof(ImGuiIO)) { error = true; IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); }
|
||||||
|
if (sz_style != sizeof(ImGuiStyle)) { error = true; IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); }
|
||||||
|
if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); }
|
||||||
|
if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); }
|
||||||
|
if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); }
|
||||||
|
return !error;
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void(*free_func)(void* ptr, void* user_data), void* user_data)
|
void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void(*free_func)(void* ptr, void* user_data), void* user_data)
|
||||||
{
|
{
|
||||||
GImAllocatorAllocFunc = alloc_func;
|
GImAllocatorAllocFunc = alloc_func;
|
||||||
|
11
imgui.h
11
imgui.h
@ -21,20 +21,20 @@
|
|||||||
#include <stddef.h> // ptrdiff_t, NULL
|
#include <stddef.h> // ptrdiff_t, NULL
|
||||||
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
||||||
|
|
||||||
|
// Version
|
||||||
#define IMGUI_VERSION "1.61 WIP"
|
#define IMGUI_VERSION "1.61 WIP"
|
||||||
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert))
|
||||||
|
|
||||||
// Define attributes of all API symbols declarations, e.g. for DLL under Windows.
|
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
|
||||||
#ifndef IMGUI_API
|
#ifndef IMGUI_API
|
||||||
#define IMGUI_API
|
#define IMGUI_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Define assertion handler.
|
// Helpers
|
||||||
#ifndef IM_ASSERT
|
#ifndef IM_ASSERT
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#define IM_ASSERT(_EXPR) assert(_EXPR)
|
#define IM_ASSERT(_EXPR) assert(_EXPR)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Helpers
|
|
||||||
#if defined(__clang__) || defined(__GNUC__)
|
#if defined(__clang__) || defined(__GNUC__)
|
||||||
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1))) // Apply printf-style warnings to user functions.
|
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1))) // Apply printf-style warnings to user functions.
|
||||||
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
|
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
|
||||||
@ -60,7 +60,7 @@ struct ImDrawVert; // A single vertex (20 bytes by default, ove
|
|||||||
struct ImFont; // Runtime data for a single font within a parent ImFontAtlas
|
struct ImFont; // Runtime data for a single font within a parent ImFontAtlas
|
||||||
struct ImFontAtlas; // Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF/OTF font loader
|
struct ImFontAtlas; // Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF/OTF font loader
|
||||||
struct ImFontConfig; // Configuration data when adding a font or merging fonts
|
struct ImFontConfig; // Configuration data when adding a font or merging fonts
|
||||||
struct ImColor; // Helper functions to create a color that can be converted to either u32 or float4
|
struct ImColor; // Helper functions to create a color that can be converted to either u32 or float4 (*obsolete* please avoid using)
|
||||||
struct ImGuiIO; // Main configuration and I/O between your application and ImGui
|
struct ImGuiIO; // Main configuration and I/O between your application and ImGui
|
||||||
struct ImGuiOnceUponAFrame; // Simple helper for running a block of code not more than once a frame, used by IMGUI_ONCE_UPON_A_FRAME macro
|
struct ImGuiOnceUponAFrame; // Simple helper for running a block of code not more than once a frame, used by IMGUI_ONCE_UPON_A_FRAME macro
|
||||||
struct ImGuiStorage; // Simple custom key value storage
|
struct ImGuiStorage; // Simple custom key value storage
|
||||||
@ -143,6 +143,7 @@ namespace ImGui
|
|||||||
IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = destroy current context
|
IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = destroy current context
|
||||||
IMGUI_API ImGuiContext* GetCurrentContext();
|
IMGUI_API ImGuiContext* GetCurrentContext();
|
||||||
IMGUI_API void SetCurrentContext(ImGuiContext* ctx);
|
IMGUI_API void SetCurrentContext(ImGuiContext* ctx);
|
||||||
|
IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert);
|
||||||
|
|
||||||
// Main
|
// Main
|
||||||
IMGUI_API ImGuiIO& GetIO();
|
IMGUI_API ImGuiIO& GetIO();
|
||||||
|
Loading…
Reference in New Issue
Block a user