Skip to content

Commit 4f8ee94

Browse files
authored
add option to use 32-bit draw index (#4)
1 parent b353ef8 commit 4f8ee94

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

build.zig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ pub fn build(b: *std.Build) void {
5050
"use_wchar32",
5151
"Extended unicode support",
5252
) orelse false,
53+
.use_32bit_draw_idx = b.option(
54+
bool,
55+
"use_32bit_draw_idx",
56+
"Use 32-bit draw index",
57+
) orelse false,
5358
};
5459

5560
const options_step = b.addOptions();
@@ -66,7 +71,12 @@ pub fn build(b: *std.Build) void {
6671
},
6772
});
6873

69-
const cflags = &.{ "-fno-sanitize=undefined", "-Wno-elaborated-enum-base", "-Wno-error=date-time" };
74+
const cflags = &.{
75+
"-fno-sanitize=undefined",
76+
"-Wno-elaborated-enum-base",
77+
"-Wno-error=date-time",
78+
if (options.use_32bit_draw_idx) "-DIMGUI_USE_32BIT_DRAW_INDEX" else "",
79+
};
7080

7181
const imgui = if (options.shared) blk: {
7282
const lib = b.addSharedLibrary(.{

libs/imgui/imconfig.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@
111111
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
112112
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
113113
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
114-
//#define ImDrawIdx unsigned int
114+
#ifdef IMGUI_USE_32BIT_DRAW_INDEX
115+
#define ImDrawIdx unsigned int
116+
#endif
115117

116118
//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly)
117119
//struct ImDrawList;

src/gui.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const assert = std.debug.assert;
2525
pub const f32_min: f32 = 1.17549435082228750796873653722225e-38;
2626
pub const f32_max: f32 = 3.40282346638528859811704183484517e+38;
2727
//--------------------------------------------------------------------------------------------------
28-
pub const DrawIdx = u16;
28+
pub const DrawIdx = if (@import("zgui_options").use_32bit_draw_idx) u32 else u16;
2929
pub const DrawVert = extern struct {
3030
pos: [2]f32,
3131
uv: [2]f32,

0 commit comments

Comments
 (0)