Skip to content

Commit ccc38b5

Browse files
authored
Merge pull request #78 from Cold-Bytes-Games/port-texturedata
2 parents a376446 + 6da534a commit ccc38b5

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn build(b: *std.Build) void {
9494
"-fno-sanitize=undefined",
9595
"-Wno-elaborated-enum-base",
9696
"-Wno-error=date-time",
97-
if (options.use_32bit_draw_idx) "-DIMGUI_USE_32BIT_DRAW_INDEX" else "",
97+
if (options.use_32bit_draw_idx) "-DImDrawIdx=unsigned int" else "",
9898
};
9999

100100
const objcflags = &.{

src/gui.zig

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ pub const io = struct {
407407
extern fn zguiIoAddCharacterEvent(char: c_int) void;
408408
};
409409

410+
pub const platform_io = struct {
411+
pub const getTextures = zguiPlatformIoGetTextures;
412+
extern fn zguiPlatformIoGetTextures() *Vector(*TextureData);
413+
};
414+
410415
pub fn setClipboardText(value: [:0]const u8) void {
411416
zguiSetClipboardText(value.ptr);
412417
}
@@ -428,15 +433,55 @@ pub const DrawData = *extern struct {
428433
display_size: [2]f32,
429434
framebuffer_scale: [2]f32,
430435
owner_viewport: ?*Viewport,
431-
textures: *Vector(TextureIdent),
436+
textures: *Vector(*TextureData),
432437
};
433438
pub const Font = *opaque {};
434439
pub const Ident = u32;
435440
pub const TextureIdent = enum(u64) { _ };
436441
pub const TextureRef = extern struct {
437-
tex_data: ?*anyopaque,
442+
tex_data: ?*TextureData,
443+
tex_id: TextureIdent,
444+
};
445+
446+
pub const TextureStatus = enum(c_int) {
447+
ok,
448+
destroyed,
449+
want_create,
450+
want_updates,
451+
want_destroy,
452+
};
453+
454+
pub const TextureFormat = enum(c_int) {
455+
rgba32,
456+
alpha8,
457+
};
458+
459+
pub const TextureRect = extern struct {
460+
x: c_ushort,
461+
y: c_ushort,
462+
w: c_ushort,
463+
h: c_ushort,
464+
};
465+
466+
pub const TextureData = extern struct {
467+
unique_id: c_int,
468+
status: TextureStatus,
469+
backend_user_data: ?*anyopaque,
438470
tex_id: TextureIdent,
471+
format: TextureFormat,
472+
width: c_int,
473+
height: c_int,
474+
bytes_per_pixel: c_int,
475+
pixels: [*]u8,
476+
used_rect: TextureRect,
477+
update_Rect: TextureRect,
478+
updates: Vector(TextureRect),
479+
unused_Frames: c_int,
480+
ref_count: c_ushort,
481+
use_colors: bool,
482+
want_destroy_next_frame: bool,
439483
};
484+
440485
pub const Wchar = if (@import("zgui_options").use_wchar32) u32 else u16;
441486
pub const Key = enum(c_int) {
442487
none = 0,

src/zgui.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,11 @@ extern "C"
16731673
ImGui::GetIO().AddInputCharacter(c);
16741674
}
16751675

1676+
ZGUI_API ImVector<ImTextureData*>* zguiPlatformIoGetTextures()
1677+
{
1678+
return &ImGui::GetPlatformIO().Textures;
1679+
}
1680+
16761681
ZGUI_API bool zguiIsItemHovered(ImGuiHoveredFlags flags)
16771682
{
16781683
return ImGui::IsItemHovered(flags);

0 commit comments

Comments
 (0)