-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.zig
58 lines (45 loc) · 1.37 KB
/
main.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const std = @import("std");
const win = struct {
usingnamespace std.os.windows;
usingnamespace std.os.windows.kernel32;
};
// Remember to copy lib/GLFW/glfw3.dll to Zig.exe Folder PATH
// Change @cInclude to full path
const glfw = @cImport({
@cInclude("lib/glad/include/glad.h");
@cInclude("lib/glfw/include/glfw3.h");
});
pub fn main() void {
// Hide console window
const BUF_TITLE = 1024;
var hwndFound: win.HWND = undefined;
var pszWindowTitle: [BUF_TITLE:0]win.CHAR = std.mem.zeroes([BUF_TITLE:0]win.CHAR);
_ = GetConsoleTitleA(&pszWindowTitle, BUF_TITLE);
hwndFound=FindWindowA(null, &pszWindowTitle);
_ = ShowWindow(hwndFound, SW_HIDE);
// ===
_ = glfw.glfwInit();
const window = glfw.glfwCreateWindow(800, 640, "GLFW3 Window", null, null);
while (glfw.glfwWindowShouldClose(window) == 0) {
//render(window);
glfw.glfwSwapBuffers(window);
glfw.glfwPollEvents();
}
glfw.glfwDestroyWindow(window);
glfw.glfwTerminate();
}
pub extern "kernel32" fn GetConsoleTitleA(
lpConsoleTitle: win.LPSTR,
nSize: win.DWORD,
) callconv(win.WINAPI) win.DWORD;
pub extern "kernel32" fn FindWindowA(
lpClassName: ?win.LPSTR,
lpWindowName: ?win.LPSTR,
) callconv(win.WINAPI) win.HWND;
const SW_HIDE = 0;
pub extern "user32" fn ShowWindow(hWnd: win.HWND, nCmdShow: i32) callconv(win.WINAPI) win.BOOL;
//
// Tests section
//
test " " {
}