More binding fixes after update

This commit is contained in:
Mason Remaley 2025-09-07 17:22:36 -07:00
parent 2e1987cc65
commit cfa032b789
7 changed files with 864 additions and 56 deletions

View file

@ -5,10 +5,8 @@
.minimum_zig_version = "0.15.1",
.dependencies = .{
.@"dear-imgui" = .{
// XXX: ...
// .url = "https://github.com/ocornut/imgui/archive/refs/tags/v1.92.2b-docking.tar.gz",
// .hash = "N-V-__8AAPZKeQDWGL4ckVmICNUMMWIikMKny4fQHvs2tCFh",
.path = "../imgui",
.url = "https://github.com/ocornut/imgui/archive/refs/tags/v1.92.2b-docking.tar.gz",
.hash = "N-V-__8AAPZKeQDWGL4ckVmICNUMMWIikMKny4fQHvs2tCFh",
},
.@"Vulkan-Headers" = .{
.url = "https://github.com/KhronosGroup/Vulkan-Headers/archive/refs/tags/v1.4.313.tar.gz",

View file

@ -0,0 +1,82 @@
// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
// **DO NOT EDIT DIRECTLY**
// https://github.com/dearimgui/dear_bindings
#include "imgui.h"
#include "imgui_impl_sdl3.h"
#include <stdio.h>
// Wrap this in a namespace to keep it separate from the C++ API
namespace cimgui
{
#include "dcimgui_impl_sdl3.h"
}
// By-value struct conversions
// Function stubs
#ifndef IMGUI_DISABLE
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForOpenGL(cimgui::SDL_Window* window, void* sdl_gl_context)
{
return ::ImGui_ImplSDL3_InitForOpenGL(reinterpret_cast<::SDL_Window*>(window), sdl_gl_context);
}
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForVulkan(cimgui::SDL_Window* window)
{
return ::ImGui_ImplSDL3_InitForVulkan(reinterpret_cast<::SDL_Window*>(window));
}
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForD3D(cimgui::SDL_Window* window)
{
return ::ImGui_ImplSDL3_InitForD3D(reinterpret_cast<::SDL_Window*>(window));
}
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForMetal(cimgui::SDL_Window* window)
{
return ::ImGui_ImplSDL3_InitForMetal(reinterpret_cast<::SDL_Window*>(window));
}
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForSDLRenderer(cimgui::SDL_Window* window, cimgui::SDL_Renderer* renderer)
{
return ::ImGui_ImplSDL3_InitForSDLRenderer(reinterpret_cast<::SDL_Window*>(window), reinterpret_cast<::SDL_Renderer*>(renderer));
}
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForSDLGPU(cimgui::SDL_Window* window)
{
return ::ImGui_ImplSDL3_InitForSDLGPU(reinterpret_cast<::SDL_Window*>(window));
}
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_InitForOther(cimgui::SDL_Window* window)
{
return ::ImGui_ImplSDL3_InitForOther(reinterpret_cast<::SDL_Window*>(window));
}
CIMGUI_IMPL_API void cimgui::cImGui_ImplSDL3_Shutdown(void)
{
::ImGui_ImplSDL3_Shutdown();
}
CIMGUI_IMPL_API void cimgui::cImGui_ImplSDL3_NewFrame(void)
{
::ImGui_ImplSDL3_NewFrame();
}
CIMGUI_IMPL_API bool cimgui::cImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
{
return ::ImGui_ImplSDL3_ProcessEvent(event);
}
CIMGUI_IMPL_API void cimgui::cImGui_ImplSDL3_SetGamepadMode(cimgui::ImGui_ImplSDL3_GamepadMode mode)
{
::ImGui_ImplSDL3_SetGamepadMode(static_cast<::ImGui_ImplSDL3_GamepadMode>(mode));
}
CIMGUI_IMPL_API void cimgui::cImGui_ImplSDL3_SetGamepadModeEx(cimgui::ImGui_ImplSDL3_GamepadMode mode, cimgui::SDL_Gamepad** manual_gamepads_array, int manual_gamepads_count)
{
::ImGui_ImplSDL3_SetGamepadMode(static_cast<::ImGui_ImplSDL3_GamepadMode>(mode), reinterpret_cast<::SDL_Gamepad**>(manual_gamepads_array), manual_gamepads_count);
}
#endif // #ifndef IMGUI_DISABLE

View file

@ -0,0 +1,67 @@
// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
// **DO NOT EDIT DIRECTLY**
// https://github.com/dearimgui/dear_bindings
// dear imgui: Platform Backend for SDL3
// This needs to be used along with a Renderer (e.g. SDL_GPU, DirectX11, OpenGL3, Vulkan..)
// (Info: SDL3 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
// Implemented features:
// [X] Platform: Clipboard support.
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen.
// [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]
// [X] Platform: Gamepad support.
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// [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.
// Missing features or Issues:
// [ ] Platform: Multi-viewport: Minimized windows seems to break mouse wheel events (at least under Windows).
// [x] Platform: IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// Learn about Dear ImGui:
// - FAQ https://dearimgui.com/faq
// - Getting Started https://dearimgui.com/getting-started
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
// - Introduction, links and more at the top of imgui.cpp
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
#include "dcimgui.h"
#ifndef IMGUI_DISABLE
typedef struct SDL_Window SDL_Window;
typedef struct SDL_Renderer SDL_Renderer;
typedef struct SDL_Gamepad SDL_Gamepad;
typedef union SDL_Event SDL_Event;
typedef struct ImDrawData_t ImDrawData;
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForVulkan(SDL_Window* window);
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForD3D(SDL_Window* window);
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForMetal(SDL_Window* window);
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForSDLGPU(SDL_Window* window);
CIMGUI_IMPL_API bool cImGui_ImplSDL3_InitForOther(SDL_Window* window);
CIMGUI_IMPL_API void cImGui_ImplSDL3_Shutdown(void);
CIMGUI_IMPL_API void cImGui_ImplSDL3_NewFrame(void);
CIMGUI_IMPL_API bool cImGui_ImplSDL3_ProcessEvent(const SDL_Event* event);
// 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.
typedef enum
{
ImGui_ImplSDL3_GamepadMode_AutoFirst,
ImGui_ImplSDL3_GamepadMode_AutoAll,
ImGui_ImplSDL3_GamepadMode_Manual,
} ImGui_ImplSDL3_GamepadMode;
CIMGUI_IMPL_API void cImGui_ImplSDL3_SetGamepadMode(ImGui_ImplSDL3_GamepadMode mode); // Implied manual_gamepads_array = nullptr, manual_gamepads_count = -1
CIMGUI_IMPL_API void cImGui_ImplSDL3_SetGamepadModeEx(ImGui_ImplSDL3_GamepadMode mode, SDL_Gamepad** manual_gamepads_array /* = nullptr */, int manual_gamepads_count /* = -1 */);
#endif// #ifndef IMGUI_DISABLE
#ifdef __cplusplus
} // End of extern "C" block
#endif

View file

@ -0,0 +1,646 @@
{
"defines": [],
"enums": [
{
"name": "ImGui_ImplSDL3_GamepadMode",
"original_fully_qualified_name": "ImGui_ImplSDL3_GamepadMode",
"is_flags_enum": false,
"elements": [
{
"name": "ImGui_ImplSDL3_GamepadMode_AutoFirst",
"value": 0,
"is_count": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 47
}
},
{
"name": "ImGui_ImplSDL3_GamepadMode_AutoAll",
"value": 1,
"is_count": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 47
}
},
{
"name": "ImGui_ImplSDL3_GamepadMode_Manual",
"value": 2,
"is_count": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 47
}
}
],
"comments": {
"preceding": [
"// 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."
]
},
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 47
}
}
],
"typedefs": [
{
"name": "SDL_Event",
"type": {
"declaration": "SDL_Event",
"description": {
"kind": "User",
"name": "SDL_Event"
}
},
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h"
}
}
],
"structs": [
{
"name": "SDL_Window",
"original_fully_qualified_name": "SDL_Window",
"kind": "struct",
"by_value": false,
"forward_declaration": true,
"is_anonymous": false,
"fields": [],
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 28
}
},
{
"name": "SDL_Renderer",
"original_fully_qualified_name": "SDL_Renderer",
"kind": "struct",
"by_value": false,
"forward_declaration": true,
"is_anonymous": false,
"fields": [],
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 29
}
},
{
"name": "SDL_Gamepad",
"original_fully_qualified_name": "SDL_Gamepad",
"kind": "struct",
"by_value": false,
"forward_declaration": true,
"is_anonymous": false,
"fields": [],
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 30
}
},
{
"name": "ImDrawData",
"original_fully_qualified_name": "ImDrawData",
"kind": "struct",
"by_value": false,
"forward_declaration": true,
"is_anonymous": false,
"fields": [],
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 1
}
}
],
"functions": [
{
"name": "cImGui_ImplSDL3_InitForOpenGL",
"original_fully_qualified_name": "ImGui_ImplSDL3_InitForOpenGL",
"return_type": {
"declaration": "bool",
"description": {
"kind": "Builtin",
"builtin_type": "bool"
}
},
"arguments": [
{
"name": "window",
"type": {
"declaration": "SDL_Window*",
"description": {
"kind": "Pointer",
"inner_type": {
"kind": "User",
"name": "SDL_Window"
}
}
},
"is_array": false,
"is_varargs": false,
"is_instance_pointer": false
},
{
"name": "sdl_gl_context",
"type": {
"declaration": "void*",
"description": {
"kind": "Pointer",
"inner_type": {
"kind": "Builtin",
"builtin_type": "void"
}
}
},
"is_array": false,
"is_varargs": false,
"is_instance_pointer": false
}
],
"is_default_argument_helper": false,
"is_manual_helper": false,
"is_imstr_helper": false,
"has_imstr_helper": false,
"is_unformatted_helper": false,
"is_static": false,
"comments": {
"preceding": [
"// Follow \"Getting Started\" link and check examples/ folder to learn about using backends!"
]
},
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 34
}
},
{
"name": "cImGui_ImplSDL3_InitForVulkan",
"original_fully_qualified_name": "ImGui_ImplSDL3_InitForVulkan",
"return_type": {
"declaration": "bool",
"description": {
"kind": "Builtin",
"builtin_type": "bool"
}
},
"arguments": [
{
"name": "window",
"type": {
"declaration": "SDL_Window*",
"description": {
"kind": "Pointer",
"inner_type": {
"kind": "User",
"name": "SDL_Window"
}
}
},
"is_array": false,
"is_varargs": false,
"is_instance_pointer": false
}
],
"is_default_argument_helper": false,
"is_manual_helper": false,
"is_imstr_helper": false,
"has_imstr_helper": false,
"is_unformatted_helper": false,
"is_static": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 35
}
},
{
"name": "cImGui_ImplSDL3_InitForD3D",
"original_fully_qualified_name": "ImGui_ImplSDL3_InitForD3D",
"return_type": {
"declaration": "bool",
"description": {
"kind": "Builtin",
"builtin_type": "bool"
}
},
"arguments": [
{
"name": "window",
"type": {
"declaration": "SDL_Window*",
"description": {
"kind": "Pointer",
"inner_type": {
"kind": "User",
"name": "SDL_Window"
}
}
},
"is_array": false,
"is_varargs": false,
"is_instance_pointer": false
}
],
"is_default_argument_helper": false,
"is_manual_helper": false,
"is_imstr_helper": false,
"has_imstr_helper": false,
"is_unformatted_helper": false,
"is_static": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 36
}
},
{
"name": "cImGui_ImplSDL3_InitForMetal",
"original_fully_qualified_name": "ImGui_ImplSDL3_InitForMetal",
"return_type": {
"declaration": "bool",
"description": {
"kind": "Builtin",
"builtin_type": "bool"
}
},
"arguments": [
{
"name": "window",
"type": {
"declaration": "SDL_Window*",
"description": {
"kind": "Pointer",
"inner_type": {
"kind": "User",
"name": "SDL_Window"
}
}
},
"is_array": false,
"is_varargs": false,
"is_instance_pointer": false
}
],
"is_default_argument_helper": false,
"is_manual_helper": false,
"is_imstr_helper": false,
"has_imstr_helper": false,
"is_unformatted_helper": false,
"is_static": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 37
}
},
{
"name": "cImGui_ImplSDL3_InitForSDLRenderer",
"original_fully_qualified_name": "ImGui_ImplSDL3_InitForSDLRenderer",
"return_type": {
"declaration": "bool",
"description": {
"kind": "Builtin",
"builtin_type": "bool"
}
},
"arguments": [
{
"name": "window",
"type": {
"declaration": "SDL_Window*",
"description": {
"kind": "Pointer",
"inner_type": {
"kind": "User",
"name": "SDL_Window"
}
}
},
"is_array": false,
"is_varargs": false,
"is_instance_pointer": false
},
{
"name": "renderer",
"type": {
"declaration": "SDL_Renderer*",
"description": {
"kind": "Pointer",
"inner_type": {
"kind": "User",
"name": "SDL_Renderer"
}
}
},
"is_array": false,
"is_varargs": false,
"is_instance_pointer": false
}
],
"is_default_argument_helper": false,
"is_manual_helper": false,
"is_imstr_helper": false,
"has_imstr_helper": false,
"is_unformatted_helper": false,
"is_static": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 38
}
},
{
"name": "cImGui_ImplSDL3_InitForSDLGPU",
"original_fully_qualified_name": "ImGui_ImplSDL3_InitForSDLGPU",
"return_type": {
"declaration": "bool",
"description": {
"kind": "Builtin",
"builtin_type": "bool"
}
},
"arguments": [
{
"name": "window",
"type": {
"declaration": "SDL_Window*",
"description": {
"kind": "Pointer",
"inner_type": {
"kind": "User",
"name": "SDL_Window"
}
}
},
"is_array": false,
"is_varargs": false,
"is_instance_pointer": false
}
],
"is_default_argument_helper": false,
"is_manual_helper": false,
"is_imstr_helper": false,
"has_imstr_helper": false,
"is_unformatted_helper": false,
"is_static": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 39
}
},
{
"name": "cImGui_ImplSDL3_InitForOther",
"original_fully_qualified_name": "ImGui_ImplSDL3_InitForOther",
"return_type": {
"declaration": "bool",
"description": {
"kind": "Builtin",
"builtin_type": "bool"
}
},
"arguments": [
{
"name": "window",
"type": {
"declaration": "SDL_Window*",
"description": {
"kind": "Pointer",
"inner_type": {
"kind": "User",
"name": "SDL_Window"
}
}
},
"is_array": false,
"is_varargs": false,
"is_instance_pointer": false
}
],
"is_default_argument_helper": false,
"is_manual_helper": false,
"is_imstr_helper": false,
"has_imstr_helper": false,
"is_unformatted_helper": false,
"is_static": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 40
}
},
{
"name": "cImGui_ImplSDL3_Shutdown",
"original_fully_qualified_name": "ImGui_ImplSDL3_Shutdown",
"return_type": {
"declaration": "void",
"description": {
"kind": "Builtin",
"builtin_type": "void"
}
},
"arguments": [],
"is_default_argument_helper": false,
"is_manual_helper": false,
"is_imstr_helper": false,
"has_imstr_helper": false,
"is_unformatted_helper": false,
"is_static": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 41
}
},
{
"name": "cImGui_ImplSDL3_NewFrame",
"original_fully_qualified_name": "ImGui_ImplSDL3_NewFrame",
"return_type": {
"declaration": "void",
"description": {
"kind": "Builtin",
"builtin_type": "void"
}
},
"arguments": [],
"is_default_argument_helper": false,
"is_manual_helper": false,
"is_imstr_helper": false,
"has_imstr_helper": false,
"is_unformatted_helper": false,
"is_static": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 42
}
},
{
"name": "cImGui_ImplSDL3_ProcessEvent",
"original_fully_qualified_name": "ImGui_ImplSDL3_ProcessEvent",
"return_type": {
"declaration": "bool",
"description": {
"kind": "Builtin",
"builtin_type": "bool"
}
},
"arguments": [
{
"name": "event",
"type": {
"declaration": "const SDL_Event*",
"description": {
"kind": "Pointer",
"inner_type": {
"kind": "User",
"name": "SDL_Event",
"storage_classes": [
"const"
]
}
}
},
"is_array": false,
"is_varargs": false,
"is_instance_pointer": false
}
],
"is_default_argument_helper": false,
"is_manual_helper": false,
"is_imstr_helper": false,
"has_imstr_helper": false,
"is_unformatted_helper": false,
"is_static": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 43
}
},
{
"name": "cImGui_ImplSDL3_SetGamepadMode",
"original_fully_qualified_name": "ImGui_ImplSDL3_SetGamepadMode",
"return_type": {
"declaration": "void",
"description": {
"kind": "Builtin",
"builtin_type": "void"
}
},
"arguments": [
{
"name": "mode",
"type": {
"declaration": "ImGui_ImplSDL3_GamepadMode",
"description": {
"kind": "User",
"name": "ImGui_ImplSDL3_GamepadMode"
}
},
"is_array": false,
"is_varargs": false,
"is_instance_pointer": false
}
],
"is_default_argument_helper": true,
"is_manual_helper": false,
"is_imstr_helper": false,
"has_imstr_helper": false,
"is_unformatted_helper": false,
"is_static": false,
"comments": {
"attached": "// Implied manual_gamepads_array = nullptr, manual_gamepads_count = -1"
},
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 48
}
},
{
"name": "cImGui_ImplSDL3_SetGamepadModeEx",
"original_fully_qualified_name": "ImGui_ImplSDL3_SetGamepadMode",
"return_type": {
"declaration": "void",
"description": {
"kind": "Builtin",
"builtin_type": "void"
}
},
"arguments": [
{
"name": "mode",
"type": {
"declaration": "ImGui_ImplSDL3_GamepadMode",
"description": {
"kind": "User",
"name": "ImGui_ImplSDL3_GamepadMode"
}
},
"is_array": false,
"is_varargs": false,
"is_instance_pointer": false
},
{
"name": "manual_gamepads_array",
"type": {
"declaration": "SDL_Gamepad**",
"description": {
"kind": "Pointer",
"inner_type": {
"kind": "Pointer",
"inner_type": {
"kind": "User",
"name": "SDL_Gamepad"
}
}
}
},
"is_array": false,
"is_varargs": false,
"default_value": "nullptr",
"is_instance_pointer": false
},
{
"name": "manual_gamepads_count",
"type": {
"declaration": "int",
"description": {
"kind": "Builtin",
"builtin_type": "int"
}
},
"is_array": false,
"is_varargs": false,
"default_value": "-1",
"is_instance_pointer": false
}
],
"is_default_argument_helper": false,
"is_manual_helper": false,
"is_imstr_helper": false,
"has_imstr_helper": false,
"is_unformatted_helper": false,
"is_static": false,
"is_internal": false,
"source_location": {
"filename": "imgui_impl_sdl3.h",
"line": 48
}
}
]
}

View file

@ -0,0 +1,7 @@
{
"defines": [],
"enums": [],
"typedefs": [],
"structs": [],
"functions": []
}

View file

@ -91,31 +91,7 @@ const Header = struct {
// are added.
const Conditional = struct {
condition: enum { ifdef, ifndef, @"if", ifnot },
expression: enum {
IMGUI_DISABLE_OBSOLETE_FUNCTIONS,
IMGUI_DISABLE_OBSOLETE_KEYIO,
IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT,
IMGUI_USE_WCHAR32,
ImTextureID,
ImDrawIdx,
ImDrawCallback,
CIMGUI_API,
CIMGUI_IMPL_API,
@"defined(_MSC_VER)&&!defined(__clang__)&&!defined(__INTEL_COMPILER)&&!defined(IMGUI_DEBUG_PARANOID)",
@"defined(IMGUI_DISABLE_OBSOLETE_FUNCTIONS)&&!defined(IMGUI_DISABLE_OBSOLETE_KEYIO)",
IMGUI_DEFINE_MATH_OPERATORS,
IM_COL32_R_SHIFT,
IMGUI_USE_BGRA_PACKED_COLOR,
IM_DRAWLIST_TEX_LINES_WIDTH_MAX,
@"defined(IMGUI_DISABLE_METRICS_WINDOW)&&!defined(IMGUI_DISABLE_OBSOLETE_FUNCTIONS)&&!defined(IMGUI_DISABLE_DEBUG_TOOLS)",
@"defined(IMGUI_HAS_IMSTR)",
IMGUI_HAS_IMSTR,
@"defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES)&&!defined(VK_NO_PROTOTYPES)",
@"defined(VK_USE_PLATFORM_WIN32_KHR)&&!defined(NOMINMAX)",
@"defined(VK_VERSION_1_3)|| defined(VK_KHR_dynamic_rendering)",
IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING,
IMGUI_DISABLE_DEBUG_TOOLS,
},
expression: []const u8,
};
const Type = struct {
@ -302,7 +278,16 @@ fn writeDefines(writer: anytype, header: *const Header) !void {
if (define.is_internal) continue;
if (skip(define.conditionals)) continue;
if (define.content) |content| {
try writer.print("const {s} = {s};\n", .{ define.name, content });
if (std.mem.startsWith(u8, content, "(")) {
const end = std.mem.indexOfScalar(u8, content, ')').?;
const ty = content[1..end];
const val = content[end + 1 ..];
try writer.print("const {s}: ", .{define.name});
try writeTypeName(writer, ty);
try writer.print(" = {s};\n", .{val});
} else {
try writer.print("const {s} = {s};\n", .{ define.name, content });
}
}
}
}
@ -832,32 +817,41 @@ fn writePointerType(
// Returns true if we should skip due to a conditional
fn skip(conditionals: []const Header.Conditional) bool {
for (conditionals) |conditional| {
const defined = switch (conditional.expression) {
.IMGUI_DISABLE_OBSOLETE_FUNCTIONS,
.IMGUI_DISABLE_OBSOLETE_KEYIO,
.CIMGUI_API,
.CIMGUI_IMPL_API,
.@"defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES)&&!defined(VK_NO_PROTOTYPES)",
.@"defined(VK_USE_PLATFORM_WIN32_KHR)&&!defined(NOMINMAX)",
.IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING,
.@"defined(VK_VERSION_1_3)|| defined(VK_KHR_dynamic_rendering)",
=> true,
.IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT,
.IMGUI_USE_WCHAR32,
.ImTextureID,
.ImDrawIdx,
.ImDrawCallback,
.@"defined(_MSC_VER)&&!defined(__clang__)&&!defined(__INTEL_COMPILER)&&!defined(IMGUI_DEBUG_PARANOID)",
.@"defined(IMGUI_DISABLE_OBSOLETE_FUNCTIONS)&&!defined(IMGUI_DISABLE_OBSOLETE_KEYIO)",
.IMGUI_DEFINE_MATH_OPERATORS,
.IM_COL32_R_SHIFT,
.IMGUI_USE_BGRA_PACKED_COLOR,
.IM_DRAWLIST_TEX_LINES_WIDTH_MAX,
.@"defined(IMGUI_DISABLE_METRICS_WINDOW)&&!defined(IMGUI_DISABLE_OBSOLETE_FUNCTIONS)&&!defined(IMGUI_DISABLE_DEBUG_TOOLS)",
.@"defined(IMGUI_HAS_IMSTR)",
.IMGUI_HAS_IMSTR,
.IMGUI_DISABLE_DEBUG_TOOLS,
=> false,
// We just manually decide which of these are correct rather than trying to automatically
// parse them. We do this with a chain of if statements because std.json doesn't give us any
// information about what string it saw or what line number the error was on if we try to
// parse it as an enum, which is a huge pain when upgrading dear imgui.
const defined = b: {
// True conditionals
if (std.mem.eql(u8, conditional.expression, "IMGUI_DISABLE_OBSOLETE_FUNCTIONS")) break :b true;
if (std.mem.eql(u8, conditional.expression, "IMGUI_DISABLE_OBSOLETE_FUNCTIONS")) break :b true;
if (std.mem.eql(u8, conditional.expression, "IMGUI_DISABLE_OBSOLETE_KEYIO")) break :b true;
if (std.mem.eql(u8, conditional.expression, "CIMGUI_API")) break :b true;
if (std.mem.eql(u8, conditional.expression, "CIMGUI_IMPL_API")) break :b true;
if (std.mem.eql(u8, conditional.expression, "defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES)&&!defined(VK_NO_PROTOTYPES)")) break :b true;
if (std.mem.eql(u8, conditional.expression, "defined(VK_USE_PLATFORM_WIN32_KHR)&&!defined(NOMINMAX)")) break :b true;
if (std.mem.eql(u8, conditional.expression, "IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING")) break :b true;
if (std.mem.eql(u8, conditional.expression, "defined(VK_VERSION_1_3)|| defined(VK_KHR_dynamic_rendering)")) break :b true;
// False conditionals
if (std.mem.eql(u8, conditional.expression, "IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT")) break :b false;
if (std.mem.eql(u8, conditional.expression, "IMGUI_USE_WCHAR32")) break :b false;
if (std.mem.eql(u8, conditional.expression, "ImTextureID")) break :b false;
if (std.mem.eql(u8, conditional.expression, "ImDrawIdx")) break :b false;
if (std.mem.eql(u8, conditional.expression, "ImDrawCallback")) break :b false;
if (std.mem.eql(u8, conditional.expression, "defined(_MSC_VER)&&!defined(__clang__)&&!defined(__INTEL_COMPILER)&&!defined(IMGUI_DEBUG_PARANOID)")) break :b false;
if (std.mem.eql(u8, conditional.expression, "defined(IMGUI_DISABLE_OBSOLETE_FUNCTIONS)&&!defined(IMGUI_DISABLE_OBSOLETE_KEYIO)")) break :b false;
if (std.mem.eql(u8, conditional.expression, "IMGUI_DEFINE_MATH_OPERATORS")) break :b false;
if (std.mem.eql(u8, conditional.expression, "IM_COL32_R_SHIFT")) break :b false;
if (std.mem.eql(u8, conditional.expression, "IMGUI_USE_BGRA_PACKED_COLOR")) break :b false;
if (std.mem.eql(u8, conditional.expression, "IM_DRAWLIST_TEX_LINES_WIDTH_MAX")) break :b false;
if (std.mem.eql(u8, conditional.expression, "defined(IMGUI_DISABLE_METRICS_WINDOW)&&!defined(IMGUI_DISABLE_OBSOLETE_FUNCTIONS)&&!defined(IMGUI_DISABLE_DEBUG_TOOLS)")) break :b false;
if (std.mem.eql(u8, conditional.expression, "defined(IMGUI_HAS_IMSTR)")) break :b false;
if (std.mem.eql(u8, conditional.expression, "IMGUI_HAS_IMSTR")) break :b false;
if (std.mem.eql(u8, conditional.expression, "IMGUI_DISABLE_DEBUG_TOOLS")) break :b false;
if (std.mem.eql(u8, conditional.expression, "ImTextureID_Invalid")) break :b false;
std.debug.panic("unexpected preprocessor conditional: {s}", .{conditional.expression});
};
switch (conditional.condition) {
.ifdef, .@"if" => if (!defined) return true,
@ -909,10 +903,16 @@ fn writeTypeName(writer: anytype, raw: []const u8) !void {
}
}
const escaped = std.mem.indexOfScalar(u8, name, '<') != null;
if (escaped) try writer.writeAll("@\"");
for (name) |c| switch (c) {
'_' => {},
else => try writer.writeByte(c),
};
if (escaped) try writer.writeByte('"');
}
// Convert a cimgui field name to a Zig field name

View file

@ -1,4 +1,5 @@
const DrawData = @import("dear_imgui").DrawData;
const TextureData = @import("dear_imgui").TextureData;
const Options = struct {
PFNvkVoidFunction: type,
@ -19,6 +20,7 @@ const Options = struct {
VkInstance: type,
VkPhysicalDevice: type,
VkPipeline: type,
VkPipelineLayout: type,
VkPipelineCache: type,
VkPipelineRenderingCreateInfoKHR: type,
VkPresentModeKHR: type,
@ -54,6 +56,7 @@ pub fn get(options: Options) type {
const VkInstance = options.VkInstance;
const VkPhysicalDevice = options.VkPhysicalDevice;
const VkPipeline = options.VkInstance;
const VkPipelineLayout = options.VkPipelineLayout;
const VkPipelineCache = options.VkPipelineCache;
const VkPipelineRenderingCreateInfoKHR = options.VkPipelineRenderingCreateInfoKHR;
const VkPresentModeKHR = options.VkPresentModeKHR;
@ -68,3 +71,8 @@ pub fn get(options: Options) type {
const VkSwapchainKHR = options.VkSwapchainKHR;
return struct {
// Instantiation of relevant `ImVector`s not provided by the dear bindings for some reason
pub const @"Vector<ImGuiImplVulkanHFrame>" = extern struct { size: c_int, capacity: c_int, data: ?[*]Frame };
pub const @"Vector<ImGuiImplVulkanHFrameSemaphores>" = extern struct { size: c_int, capacity: c_int, data: ?[*]Frame };