83 lines
2.6 KiB
Zig
83 lines
2.6 KiB
Zig
const std = @import("std");
|
|
const c = @import("c.zig");
|
|
const vk = @import("vk");
|
|
|
|
const Window = @import("Window.zig");
|
|
|
|
// const BaseDispatch = vk.BaseWrapper(.{
|
|
// .createInstance = true,
|
|
// .getInstanceProcAddr = true,
|
|
// });
|
|
//
|
|
// const InstanceDispatch = vk.InstanceWrapper(.{
|
|
// .destroyInstance = true,
|
|
// });
|
|
//
|
|
// const Context = struct {
|
|
// vkb: BaseDispatch,
|
|
// vki: InstanceDispatch,
|
|
//
|
|
// instance: vk.Instance,
|
|
//
|
|
// pub fn init(allocator: std.mem.Allocator, app_name: [*:0]const u8, window: *c.GLFWwindow) !Context {
|
|
// _ = allocator;
|
|
// _ = window;
|
|
//
|
|
// var self: Context = undefined;
|
|
// self.vkb = try BaseDispatch.load(c.glfwGetInstanceProcAddress);
|
|
//
|
|
// var glfw_exts_count: u32 = 0;
|
|
// const glfw_exts = c.glfwGetRequiredInstanceExtensions(&glfw_exts_count);
|
|
//
|
|
// const app_info = vk.ApplicationInfo{
|
|
// .p_application_name = app_name,
|
|
// .application_version = vk.makeApiVersion(0, 0, 0, 0),
|
|
// .p_engine_name = app_name,
|
|
// .engine_version = vk.makeApiVersion(0, 0, 0, 0),
|
|
// .api_version = vk.API_VERSION_1_2,
|
|
// };
|
|
//
|
|
// self.instance = try self.vkb.createInstance(&.{
|
|
// .p_application_info = &app_info,
|
|
// .enabled_extension_count = glfw_exts_count,
|
|
// .pp_enabled_extension_names = @as([*]const [*:0]const u8, @ptrCast(glfw_exts)),
|
|
// }, null);
|
|
//
|
|
// self.vki = try InstanceDispatch.load(self.instance, self.vkb.dispatch.vkGetInstanceProcAddr);
|
|
// errdefer self.vki.destroyInstance(self.instance, null);
|
|
//
|
|
// return self;
|
|
// }
|
|
//
|
|
// pub fn deinit(self: Context) void {
|
|
// self.vki.destroyInstance(self.instance, null);
|
|
// }
|
|
// };
|
|
|
|
pub fn main() !void {
|
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
const allocator = gpa.allocator();
|
|
defer _ = gpa.detectLeaks();
|
|
|
|
if (c.glfwInit() != c.GLFW_TRUE) {
|
|
return error.GlfwInitFailed;
|
|
}
|
|
defer c.glfwTerminate();
|
|
|
|
const window = try Window.init(allocator);
|
|
defer window.deinit();
|
|
|
|
// window.mainLoop();
|
|
|
|
// c.glfwWindowHint(c.GLFW_CLIENT_API, c.GLFW_NO_API);
|
|
// const window: *c.GLFWwindow = c.glfwCreateWindow(1280, 720, "Hello World!", null, null) orelse return error.GlfwWindowFailed;
|
|
// defer c.glfwDestroyWindow(window);
|
|
|
|
// const ctx = try Context.init(allocator, "content", window);
|
|
// defer ctx.deinit();
|
|
|
|
// while (c.glfwWindowShouldClose(window) == 0) : (c.glfwPollEvents()) {
|
|
// c.glfwSwapBuffers(window);
|
|
// }
|
|
}
|