Compare commits
11 Commits
1fa5c9675f
...
25fa193b1f
Author | SHA1 | Date |
---|---|---|
Rekai Nyangadzayi Musuka | 25fa193b1f | |
Rekai Nyangadzayi Musuka | 334c021350 | |
Rekai Nyangadzayi Musuka | 2894f69c2f | |
Rekai Nyangadzayi Musuka | be835bb15b | |
Rekai Nyangadzayi Musuka | a2e5652678 | |
Rekai Nyangadzayi Musuka | 925ff4b50a | |
Rekai Nyangadzayi Musuka | 1ff2abf816 | |
Rekai Nyangadzayi Musuka | 367dd7a99e | |
Rekai Nyangadzayi Musuka | c7d1c329a1 | |
Rekai Nyangadzayi Musuka | 6c56505fa6 | |
Rekai Nyangadzayi Musuka | 9964c55136 |
53
build.zig
53
build.zig
|
@ -11,10 +11,6 @@ pub const Backend = enum {
|
|||
pub const Options = struct {
|
||||
backend: Backend,
|
||||
shared: bool = false,
|
||||
/// use bundled imgui source
|
||||
with_imgui: bool = true,
|
||||
/// use bundled implot source
|
||||
with_implot: bool = true,
|
||||
};
|
||||
|
||||
pub const Package = struct {
|
||||
|
@ -71,55 +67,40 @@ pub fn package(
|
|||
.optimize = optimize,
|
||||
});
|
||||
|
||||
zgui_c_cpp.addIncludePath(.{ .path = thisDir() ++ "/libs" });
|
||||
zgui_c_cpp.addIncludePath(.{ .path = thisDir() ++ "/libs/imgui" });
|
||||
zgui_c_cpp.addIncludePath(thisDir() ++ "/libs");
|
||||
zgui_c_cpp.addIncludePath(thisDir() ++ "/libs/imgui");
|
||||
|
||||
zgui_c_cpp.linkLibC();
|
||||
zgui_c_cpp.linkLibCpp();
|
||||
|
||||
const cflags = &.{"-fno-sanitize=undefined"};
|
||||
|
||||
zgui_c_cpp.addCSourceFile(.{
|
||||
.file = .{ .path = thisDir() ++ "/src/zgui.cpp" },
|
||||
.flags = cflags,
|
||||
});
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/src/zgui.cpp", cflags);
|
||||
|
||||
if (args.options.with_imgui) {
|
||||
zgui_c_cpp.addCSourceFiles(&.{
|
||||
thisDir() ++ "/libs/imgui/imgui.cpp",
|
||||
thisDir() ++ "/libs/imgui/imgui_widgets.cpp",
|
||||
thisDir() ++ "/libs/imgui/imgui_tables.cpp",
|
||||
thisDir() ++ "/libs/imgui/imgui_draw.cpp",
|
||||
thisDir() ++ "/libs/imgui/imgui_demo.cpp",
|
||||
}, cflags);
|
||||
}
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/imgui.cpp", cflags);
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/imgui_widgets.cpp", cflags);
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/imgui_tables.cpp", cflags);
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/imgui_draw.cpp", cflags);
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/imgui_demo.cpp", cflags);
|
||||
|
||||
if (args.options.with_implot) {
|
||||
zgui_c_cpp.addCSourceFiles(&.{
|
||||
thisDir() ++ "/libs/imgui/implot_demo.cpp",
|
||||
thisDir() ++ "/libs/imgui/implot.cpp",
|
||||
thisDir() ++ "/libs/imgui/implot_items.cpp",
|
||||
}, cflags);
|
||||
}
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/implot_demo.cpp", cflags);
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/implot.cpp", cflags);
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/implot_items.cpp", cflags);
|
||||
|
||||
switch (args.options.backend) {
|
||||
.glfw_wgpu => {
|
||||
zgui_c_cpp.addIncludePath(.{ .path = thisDir() ++ "/../zglfw/libs/glfw/include" });
|
||||
zgui_c_cpp.addIncludePath(.{ .path = thisDir() ++ "/../zgpu/libs/dawn/include" });
|
||||
zgui_c_cpp.addCSourceFiles(&.{
|
||||
thisDir() ++ "/libs/imgui/backends/imgui_impl_glfw.cpp",
|
||||
thisDir() ++ "/libs/imgui/backends/imgui_impl_wgpu.cpp",
|
||||
}, cflags);
|
||||
zgui_c_cpp.addIncludePath(thisDir() ++ "/../zglfw/libs/glfw/include");
|
||||
zgui_c_cpp.addIncludePath(thisDir() ++ "/../zgpu/libs/dawn/include");
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/backends/imgui_impl_glfw.cpp", cflags);
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/backends/imgui_impl_wgpu.cpp", cflags);
|
||||
},
|
||||
.glfw_opengl3 => {
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/backends/imgui_impl_glfw.cpp", cflags);
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/backends/imgui_impl_opengl3.cpp", cflags);
|
||||
},
|
||||
.win32_dx12 => {
|
||||
zgui_c_cpp.addCSourceFiles(&.{
|
||||
thisDir() ++ "/libs/imgui/backends/imgui_impl_win32.cpp",
|
||||
thisDir() ++ "/libs/imgui/backends/imgui_impl_dx12.cpp",
|
||||
}, cflags);
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/backends/imgui_impl_win32.cpp", cflags);
|
||||
zgui_c_cpp.addCSourceFile(thisDir() ++ "/libs/imgui/backends/imgui_impl_dx12.cpp", cflags);
|
||||
zgui_c_cpp.linkSystemLibraryName("d3dcompiler_47");
|
||||
zgui_c_cpp.linkSystemLibraryName("dwmapi");
|
||||
},
|
||||
|
|
|
@ -539,14 +539,11 @@ static void ImGui_ImplWGPU_CreateFontsTexture()
|
|||
// Create the associated sampler
|
||||
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||
{
|
||||
const WGPUMipmapFilterMode mipmap_filter_mode = g_config.texture_filter_mode == 1 ? WGPUMipmapFilterMode_Linear : WGPUMipmapFilterMode_Nearest;
|
||||
|
||||
const WGPUFilterMode filter_mode = g_config.texture_filter_mode == 1 ? WGPUFilterMode_Linear : WGPUFilterMode_Nearest;
|
||||
|
||||
WGPUSamplerDescriptor sampler_desc = {};
|
||||
sampler_desc.minFilter = filter_mode;
|
||||
sampler_desc.magFilter = filter_mode;
|
||||
sampler_desc.mipmapFilter = mipmap_filter_mode;
|
||||
sampler_desc.mipmapFilter = filter_mode;
|
||||
sampler_desc.addressModeU = WGPUAddressMode_Repeat;
|
||||
sampler_desc.addressModeV = WGPUAddressMode_Repeat;
|
||||
sampler_desc.addressModeW = WGPUAddressMode_Repeat;
|
||||
|
|
64
src/gui.zig
64
src/gui.zig
|
@ -226,10 +226,6 @@ pub const io = struct {
|
|||
pub const getFontsTexId = zguiIoGetFontsTexId;
|
||||
extern fn zguiIoGetFontsTexId() TextureIdent;
|
||||
|
||||
/// `pub fn zguiIoSetConfigWindowsMoveFromTitleBarOnly(bool) void`
|
||||
pub const setConfigWindowsMoveFromTitleBarOnly = zguiIoSetConfigWindowsMoveFromTitleBarOnly;
|
||||
extern fn zguiIoSetConfigWindowsMoveFromTitleBarOnly(enabled: bool) void;
|
||||
|
||||
/// `pub fn zguiIoGetWantCaptureMouse() bool`
|
||||
pub const getWantCaptureMouse = zguiIoGetWantCaptureMouse;
|
||||
extern fn zguiIoGetWantCaptureMouse() bool;
|
||||
|
@ -1165,13 +1161,6 @@ pub const setMouseCursor = zguiSetMouseCursor;
|
|||
extern fn zguiGetMouseCursor() Cursor;
|
||||
extern fn zguiSetMouseCursor(cursor: Cursor) void;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
pub fn getMousePos() [2]f32 {
|
||||
var pos: [2]f32 = undefined;
|
||||
zguiGetMousePos(&pos);
|
||||
return pos;
|
||||
}
|
||||
extern fn zguiGetMousePos(pos: *[2]f32) void;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// `pub fn alignTextToFramePadding() void`
|
||||
pub const alignTextToFramePadding = zguiAlignTextToFramePadding;
|
||||
/// `pub fn getTextLineHeight() f32`
|
||||
|
@ -1463,43 +1452,6 @@ pub fn combo(label: [:0]const u8, args: Combo) bool {
|
|||
args.popup_max_height_in_items,
|
||||
);
|
||||
}
|
||||
/// creates a combo box directly from a pointer to an enum value using zig's
|
||||
/// comptime mechanics to infer the items for the list at compile time
|
||||
pub fn comboFromEnum(
|
||||
label: [:0]const u8,
|
||||
/// must be a pointer to an enum value (var my_enum: *FoodKinds = .Banana)
|
||||
/// that is backed by some kind of integer that can safely cast into an
|
||||
/// i32 (the underlying imgui restriction)
|
||||
current_item: anytype,
|
||||
) bool {
|
||||
const item_names = comptime lbl: {
|
||||
const item_type = @typeInfo(@TypeOf(current_item.*));
|
||||
switch (item_type) {
|
||||
.Enum => |e| {
|
||||
comptime var str: [:0]const u8 = "";
|
||||
|
||||
inline for (e.fields) |f| {
|
||||
str = str ++ f.name ++ "\x00";
|
||||
}
|
||||
break :lbl str;
|
||||
},
|
||||
else => {
|
||||
@compileError("Error: current_item must be a pointer-to-an-enum, not a " ++ @TypeOf(current_item));
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
var item: i32 = @intCast(@intFromEnum(current_item.*));
|
||||
|
||||
const result = combo(label, .{
|
||||
.items_separated_by_zeros = item_names,
|
||||
.current_item = &item,
|
||||
});
|
||||
|
||||
current_item.* = @enumFromInt(item);
|
||||
|
||||
return result;
|
||||
}
|
||||
extern fn zguiCombo(
|
||||
label: [*:0]const u8,
|
||||
current_item: *i32,
|
||||
|
@ -2909,8 +2861,8 @@ pub const BeginTable = struct {
|
|||
outer_size: [2]f32 = .{ 0, 0 },
|
||||
inner_width: f32 = 0,
|
||||
};
|
||||
pub fn beginTable(name: [:0]const u8, args: BeginTable) bool {
|
||||
return zguiBeginTable(name, args.column, args.flags, &args.outer_size, args.inner_width);
|
||||
pub fn beginTable(name: [:0]const u8, args: BeginTable) void {
|
||||
zguiBeginTable(name, args.column, args.flags, &args.outer_size, args.inner_width);
|
||||
}
|
||||
extern fn zguiBeginTable(
|
||||
str_id: [*:0]const u8,
|
||||
|
@ -2918,7 +2870,7 @@ extern fn zguiBeginTable(
|
|||
flags: TableFlags,
|
||||
outer_size: *const [2]f32,
|
||||
inner_width: f32,
|
||||
) bool;
|
||||
) void;
|
||||
|
||||
pub fn endTable() void {
|
||||
zguiEndTable();
|
||||
|
@ -3018,11 +2970,6 @@ pub const MouseButton = enum(u32) {
|
|||
right = 1,
|
||||
middle = 2,
|
||||
};
|
||||
|
||||
/// `pub fn isMouseDown(mouse_button: MouseButton) bool`
|
||||
pub const isMouseDown = zguiIsMouseDown;
|
||||
/// `pub fn isMouseClicked(mouse_button: MouseButton) bool`
|
||||
pub const isMouseClicked = zguiIsMouseClicked;
|
||||
/// `pub fn isMouseDoubleClicked(mouse_button: MouseButton) bool`
|
||||
pub const isMouseDoubleClicked = zguiIsMouseDoubleClicked;
|
||||
/// `pub fn isItemClicked(mouse_button: MouseButton) bool`
|
||||
|
@ -3045,8 +2992,6 @@ pub const isAnyItemHovered = zguiIsAnyItemHovered;
|
|||
pub const isAnyItemActive = zguiIsAnyItemActive;
|
||||
/// `pub fn isAnyItemFocused() bool`
|
||||
pub const isAnyItemFocused = zguiIsAnyItemFocused;
|
||||
extern fn zguiIsMouseDown(mouse_button: MouseButton) bool;
|
||||
extern fn zguiIsMouseClicked(mouse_button: MouseButton) bool;
|
||||
extern fn zguiIsMouseDoubleClicked(mouse_button: MouseButton) bool;
|
||||
extern fn zguiIsItemHovered(flags: HoveredFlags) bool;
|
||||
extern fn zguiIsItemActive() bool;
|
||||
|
@ -3231,8 +3176,6 @@ pub fn beginPopupModal(name: [:0]const u8, args: Begin) bool {
|
|||
pub fn openPopup(str_id: [:0]const u8, flags: PopupFlags) void {
|
||||
zguiOpenPopup(str_id, flags);
|
||||
}
|
||||
/// `pub fn beginPopup(str_id: [:0]const u8, flags: WindowFlags) bool`
|
||||
pub const beginPopup = zguiBeginPopup;
|
||||
/// `pub fn endPopup() void`
|
||||
pub const endPopup = zguiEndPopup;
|
||||
/// `pub fn closeCurrentPopup() void`
|
||||
|
@ -3240,7 +3183,6 @@ pub const closeCurrentPopup = zguiCloseCurrentPopup;
|
|||
extern fn zguiBeginPopupContextWindow() bool;
|
||||
extern fn zguiBeginPopupContextItem() bool;
|
||||
extern fn zguiBeginPopupModal(name: [*:0]const u8, popen: ?*bool, flags: WindowFlags) bool;
|
||||
extern fn zguiBeginPopup(str_id: [*:0]const u8, flags: WindowFlags) bool;
|
||||
extern fn zguiEndPopup() void;
|
||||
extern fn zguiOpenPopup(str_id: [*:0]const u8, flags: PopupFlags) void;
|
||||
extern fn zguiCloseCurrentPopup() void;
|
||||
|
|
30
src/zgui.cpp
30
src/zgui.cpp
|
@ -260,12 +260,6 @@ ZGUI_API void zguiSetMouseCursor(int cursor) {
|
|||
ImGui::SetMouseCursor(cursor);
|
||||
}
|
||||
|
||||
ZGUI_API void zguiGetMousePos(float pos[2]) {
|
||||
const ImVec2 p = ImGui::GetMousePos();
|
||||
pos[0] = p.x;
|
||||
pos[1] = p.y;
|
||||
}
|
||||
|
||||
ZGUI_API void zguiAlignTextToFramePadding(void) {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
}
|
||||
|
@ -1084,10 +1078,6 @@ ZGUI_API bool zguiTreeNode(const char* label) {
|
|||
return ImGui::TreeNode(label);
|
||||
}
|
||||
|
||||
ZGUI_API bool zguiTreeNodeFlags(const char* label, ImGuiTreeNodeFlags flags) {
|
||||
return ImGui::TreeNodeEx(label, flags);
|
||||
}
|
||||
|
||||
ZGUI_API bool zguiTreeNodeStrId(const char* str_id, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
@ -1242,10 +1232,6 @@ ZGUI_API ImTextureID zguiIoGetFontsTexId(void) {
|
|||
return ImGui::GetIO().Fonts->TexID;
|
||||
}
|
||||
|
||||
ZGUI_API void zguiIoSetConfigWindowsMoveFromTitleBarOnly(bool enabled) {
|
||||
ImGui::GetIO().ConfigWindowsMoveFromTitleBarOnly = enabled;
|
||||
}
|
||||
|
||||
ZGUI_API bool zguiIoGetWantCaptureMouse(void) {
|
||||
return ImGui::GetIO().WantCaptureMouse;
|
||||
}
|
||||
|
@ -1329,14 +1315,6 @@ ZGUI_API bool zguiIsItemClicked(ImGuiMouseButton mouse_button) {
|
|||
return ImGui::IsItemClicked(mouse_button);
|
||||
}
|
||||
|
||||
ZGUI_API bool zguiIsMouseDown(ImGuiMouseButton button) {
|
||||
return ImGui::IsMouseDown(button);
|
||||
}
|
||||
|
||||
ZGUI_API bool zguiIsMouseClicked(ImGuiMouseButton button) {
|
||||
return ImGui::IsMouseClicked(button);
|
||||
}
|
||||
|
||||
ZGUI_API bool zguiIsMouseDoubleClicked(ImGuiMouseButton button) {
|
||||
return ImGui::IsMouseDoubleClicked(button);
|
||||
}
|
||||
|
@ -1469,10 +1447,6 @@ ZGUI_API void zguiEndTooltip(void) {
|
|||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ZGUI_API bool zguiBeginPopup(const char* str_id, ImGuiWindowFlags flags){
|
||||
return ImGui::BeginPopup(str_id, flags);
|
||||
}
|
||||
|
||||
ZGUI_API bool zguiBeginPopupContextWindow(void) {
|
||||
return ImGui::BeginPopupContextWindow();
|
||||
}
|
||||
|
@ -1501,14 +1475,14 @@ ZGUI_API void zguiCloseCurrentPopup(void) {
|
|||
// Tables
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ZGUI_API bool zguiBeginTable(
|
||||
ZGUI_API void zguiBeginTable(
|
||||
const char* str_id,
|
||||
int column,
|
||||
ImGuiTableFlags flags,
|
||||
const float outer_size[2],
|
||||
float inner_width
|
||||
) {
|
||||
return ImGui::BeginTable(str_id, column, flags, { outer_size[0], outer_size[1] }, inner_width);
|
||||
ImGui::BeginTable(str_id, column, flags, { outer_size[0], outer_size[1] }, inner_width);
|
||||
}
|
||||
|
||||
ZGUI_API void zguiEndTable(void) {
|
||||
|
|
Loading…
Reference in New Issue