Skip to content

Commit 6dbb8cf

Browse files
committed
.
1 parent 6459132 commit 6dbb8cf

14 files changed

+935
-5
lines changed
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
{
2+
"tasks": [{
3+
"label": "Zig: Build",
4+
"args": [ "build", "--summary", "all" ],
5+
"detail": "zig build --summary all",
6+
"command": "zig", "type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "build", "isDefault": true },
7+
"presentation": { "group": "build", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
8+
},
9+
{
10+
"label": "Zig: Build Release Safe.",
11+
"args": [ "build", "-Doptimize=ReleaseSafe", "--summary", "all" ],
12+
"detail": "zig build -Doptimize=ReleaseSafe --summary all",
13+
"command": "zig", "type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "build", "isDefault": false },
14+
"presentation": { "group": "build", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
15+
},
16+
{
17+
"label": "Zig: Build Release Fast.",
18+
"args": [ "build", "-Doptimize=ReleaseFast", "--summary", "all" ],
19+
"detail": "zig build -Doptimize=ReleaseFast --summary all",
20+
"command": "zig","type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "build", "isDefault": false },
21+
"presentation": { "group": "build", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
22+
},
23+
{
24+
"label": "Zig: Build Release Small.",
25+
"args": [ "build", "-Doptimize=ReleaseSmall", "--summary", "all" ],
26+
"detail": "zig build -Doptimize=ReleaseSmall --summary all",
27+
"command": "zig", "type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "build", "isDefault": false },
28+
"presentation": { "group": "build", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
29+
},
30+
{
31+
"label": "Zig: Build Release Strip.",
32+
"args": [ ],
33+
"detail": "zig build-exe -O ReleaseSmall -fstrip -fsingle-threaded (+ lots of options) main.zig",
34+
"command": "buildReleaseStrip.bat", "type": "shell", "options": { "cwd": "${workspaceRoot}\\tools" }, "group": { "kind": "build", "isDefault": false },
35+
"presentation": { "group": "build", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
36+
},
37+
{
38+
"label": "Zig: Test",
39+
"args": [ "test", "${file}" ],
40+
"detail": "'zig test' in the current workspace.",
41+
"command": "zig", "type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "test", "isDefault": true },
42+
"presentation": { "group": "test", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
43+
},
44+
{
45+
"label": "Zig: Run main",
46+
"args": [ "run", "-lc++", "-lgdi32", "-ldwmapi", "-lopengl32", "main.zig",
47+
"lib/imgui/cimgui.cpp",
48+
"lib/imgui/cimgui_impl_opengl3.cpp",
49+
"lib/imgui/cimgui_impl_win32.cpp",
50+
"lib/imgui/imgui.cpp",
51+
"lib/imgui/imgui_widgets.cpp",
52+
"lib/imgui/imgui_draw.cpp",
53+
"lib/imgui/imgui_tables.cpp",
54+
"lib/imgui/imgui_demo.cpp",
55+
"lib/imgui/imgui_impl_win32.cpp",
56+
"lib/imgui/imgui_impl_opengl3.cpp"
57+
],
58+
"detail": "zig run main.zig",
59+
"command": "zig", "type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "none", "isDefault": true },
60+
"presentation": { "group": "launch", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
61+
},
62+
{
63+
"label": "Zig: Run main (With Args)",
64+
"args": [ "run", "-lc++", "-lgdi32", "-ldwmapi", "-lopengl32", "main.zig",
65+
"lib/imgui/cimgui.cpp",
66+
"lib/imgui/cimgui_impl_opengl3.cpp",
67+
"lib/imgui/cimgui_impl_win32.cpp",
68+
"lib/imgui/imgui.cpp",
69+
"lib/imgui/imgui_widgets.cpp",
70+
"lib/imgui/imgui_draw.cpp",
71+
"lib/imgui/imgui_tables.cpp",
72+
"lib/imgui/imgui_demo.cpp",
73+
"lib/imgui/imgui_impl_win32.cpp",
74+
"lib/imgui/imgui_impl_opengl3.cpp", "--", "ArgsForYourProgram" ],
75+
"detail": "zig run main.zig -- ArgsForYourProgram",
76+
"command": "zig", "type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "none", "isDefault": false },
77+
"presentation": { "group": "launch", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
78+
},
79+
{
80+
"label": "Zig: Run main (Fast)",
81+
"args": [ "run", "-lc++", "-lgdi32", "-ldwmapi", "-lopengl32", "main.zig",
82+
"lib/imgui/cimgui.cpp",
83+
"lib/imgui/cimgui_impl_opengl3.cpp",
84+
"lib/imgui/cimgui_impl_win32.cpp",
85+
"lib/imgui/imgui.cpp",
86+
"lib/imgui/imgui_widgets.cpp",
87+
"lib/imgui/imgui_draw.cpp",
88+
"lib/imgui/imgui_tables.cpp",
89+
"lib/imgui/imgui_demo.cpp",
90+
"lib/imgui/imgui_impl_win32.cpp",
91+
"lib/imgui/imgui_impl_opengl3.cpp", "-O", "ReleaseFast" ],
92+
"detail": "zig run main.zig -O ReleaseFast",
93+
"command": "zig", "type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "none", "isDefault": false },
94+
"presentation": { "group": "launch", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
95+
},
96+
{
97+
"label": "Zig: Run main (Safe)",
98+
"args": [ "run", "-lc++", "-lgdi32", "-ldwmapi", "-lopengl32", "main.zig",
99+
"lib/imgui/cimgui.cpp",
100+
"lib/imgui/cimgui_impl_opengl3.cpp",
101+
"lib/imgui/cimgui_impl_win32.cpp",
102+
"lib/imgui/imgui.cpp",
103+
"lib/imgui/imgui_widgets.cpp",
104+
"lib/imgui/imgui_draw.cpp",
105+
"lib/imgui/imgui_tables.cpp",
106+
"lib/imgui/imgui_demo.cpp",
107+
"lib/imgui/imgui_impl_win32.cpp",
108+
"lib/imgui/imgui_impl_opengl3.cpp", "-O", "ReleaseSafe" ],
109+
"detail": "zig run main.zig -O ReleaseSafe",
110+
"command": "zig", "type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "none", "isDefault": false },
111+
"presentation": { "group": "launch", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
112+
},
113+
{
114+
"label": "Zig: Run main (Small)",
115+
"args": [ "run", "-lc++", "-lgdi32", "-ldwmapi", "-lopengl32", "main.zig",
116+
"lib/imgui/cimgui.cpp",
117+
"lib/imgui/cimgui_impl_opengl3.cpp",
118+
"lib/imgui/cimgui_impl_win32.cpp",
119+
"lib/imgui/imgui.cpp",
120+
"lib/imgui/imgui_widgets.cpp",
121+
"lib/imgui/imgui_draw.cpp",
122+
"lib/imgui/imgui_tables.cpp",
123+
"lib/imgui/imgui_demo.cpp",
124+
"lib/imgui/imgui_impl_win32.cpp",
125+
"lib/imgui/imgui_impl_opengl3.cpp", "-O", "ReleaseSmall" ],
126+
"detail": "zig run main.zig -O ReleaseSmall",
127+
"command": "zig", "type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "none", "isDefault": false },
128+
"presentation": { "group": "launch", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
129+
},
130+
{
131+
"label": "Zig: Run current file",
132+
"args": [ "run", "${file}" ],
133+
"detail": "'zig run' active file in the current workspace.",
134+
"command": "zig", "type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "none", "isDefault": false },
135+
"presentation": { "group": "launch", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
136+
},
137+
{
138+
"label": "zTime Zig: Run current file",
139+
"args": [ "zig", "run", "-lc", "${file}" ],
140+
"detail": "'zTime zig run' active file in the current workspace.",
141+
"command": "zig", "type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "none", "isDefault": false },
142+
"presentation": { "group": "zTime", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
143+
},
144+
{
145+
"label": "Zig: Docs",
146+
"args": [ "run", "-femit-docs", "main.zig" ],
147+
"detail": "Generate docs from source comments.",
148+
"command": "zig", "type": "shell", "options": { "cwd": "${workspaceRoot}" }, "group": { "kind": "none", "isDefault": false },
149+
"presentation": { "group": "docs", "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "close": false }, "problemMatcher": []
150+
}],
151+
"version": "2.0.0"
152+
}

BaseImGui/build_opengl3.zig

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const std = @import("std");
2+
3+
pub fn build(b: *std.Build) void {
4+
//Build
5+
const target = b.standardTargetOptions(.{});
6+
const optimize = b.standardOptimizeOption(.{});
7+
8+
const projectname = "BaseImGui";
9+
const rootfile = "main.zig";
10+
11+
const exe = b.addExecutable(.{
12+
.name = projectname,
13+
.root_source_file = .{ .path = rootfile },
14+
.target = target,
15+
.optimize = optimize,
16+
});
17+
exe.addWin32ResourceFile(.{
18+
.file = .{ .path = projectname ++ ".rc" },
19+
.flags = &.{"/c65001"}, // UTF-8 codepage
20+
});
21+
22+
exe.linkSystemLibrary("gdi32");
23+
exe.linkSystemLibrary("dwmapi");
24+
exe.linkSystemLibrary("opengl32");
25+
26+
exe.addIncludePath( .{ .path = "lib/cimgui" } );
27+
exe.addIncludePath( .{ .path = "lib/cimgui/imgui" } );
28+
29+
var c_srcs = .{
30+
"lib/imgui/cimgui.cpp",
31+
"lib/imgui/cimgui_impl_opengl3.cpp",
32+
"lib/imgui/cimgui_impl_win32.cpp",
33+
"lib/imgui/imgui.cpp",
34+
"lib/imgui/imgui_widgets.cpp",
35+
"lib/imgui/imgui_draw.cpp",
36+
"lib/imgui/imgui_tables.cpp",
37+
"lib/imgui/imgui_demo.cpp",
38+
"lib/imgui/imgui_impl_win32.cpp",
39+
"lib/imgui/imgui_impl_opengl3.cpp"
40+
};
41+
inline for (c_srcs) |c_cpp| {
42+
exe.addCSourceFile(.{
43+
.file = std.build.LazyPath.relative(c_cpp),
44+
.flags = &.{ }
45+
});
46+
}
47+
48+
exe.linkLibCpp();
49+
50+
switch (optimize) {
51+
.Debug => b.exe_dir = "bin/Debug",
52+
.ReleaseSafe => b.exe_dir = "bin/ReleaseSafe",
53+
.ReleaseFast => b.exe_dir = "bin/ReleaseFast",
54+
.ReleaseSmall => b.exe_dir = "bin/ReleaseSmall",
55+
//else => b.exe_dir = "bin/Else",
56+
}
57+
b.installArtifact(exe);
58+
59+
//Run
60+
const run_cmd = b.addRunArtifact(exe);
61+
run_cmd.step.dependOn(b.getInstallStep());
62+
if (b.args) |args| {
63+
run_cmd.addArgs(args);
64+
}
65+
const run_step = b.step("run", "Run the app");
66+
run_step.dependOn(&run_cmd.step);
67+
68+
//Tests
69+
const unit_tests = b.addTest(.{
70+
.root_source_file = .{ .path = rootfile },
71+
.target = target,
72+
.optimize = optimize,
73+
});
74+
const run_unit_tests = b.addRunArtifact(unit_tests);
75+
const test_step = b.step("test", "Run unit tests");
76+
test_step.dependOn(&run_unit_tests.step);
77+
}

BaseImGui/main.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// ImGui_impl_OpenGL3
12
const std = @import("std");
23
const win = struct {
34
usingnamespace std.os.windows;
@@ -10,7 +11,7 @@ const L = std.unicode.utf8ToUtf16LeStringLiteral;
1011

1112
// NOTE ABOUT VSCODE + ZLS:
1213
// Use full path for all cIncludes:
13-
// @cInclude("C:/zig_microui/lib/SDL2/include/SDL.h");
14+
// @cInclude("C:/zig_workbench/lib/SDL2/include/SDL.h");
1415
const im = @cImport({
1516
@cInclude("lib/imgui/cimgui.h");
1617
@cInclude("lib/imgui/cimgui_impl_opengl3.h");

0 commit comments

Comments
 (0)