forked from mirror/vulkan-zig
Swapchain
This commit is contained in:
@@ -2,26 +2,9 @@ const std = @import("std");
|
||||
const vk = @import("vulkan");
|
||||
const c = @import("c.zig");
|
||||
const GraphicsContext = @import("graphics_context.zig").GraphicsContext;
|
||||
|
||||
const BaseDispatch = struct {
|
||||
vkCreateInstance: vk.PfnCreateInstance,
|
||||
usingnamespace vk.BaseWrapper(@This());
|
||||
};
|
||||
|
||||
const InstanceDispatch = struct {
|
||||
vkDestroyInstance: vk.PfnDestroyInstance,
|
||||
vkCreateDevice: vk.PfnCreateDevice,
|
||||
vkDestroySurfaceKHR: vk.PfnDestroySurfaceKHR,
|
||||
usingnamespace vk.InstanceWrapper(@This());
|
||||
};
|
||||
|
||||
const DeviceDispatch = struct {
|
||||
vkDestroyDevice: vk.PfnDestroyDevice,
|
||||
usingnamespace vk.DeviceWrapper(@This());
|
||||
};
|
||||
const Swapchain = @import("swapchain.zig").Swapchain;
|
||||
|
||||
const app_name = "vulkan-zig example";
|
||||
|
||||
const app_info = vk.ApplicationInfo{
|
||||
.p_application_name = app_name,
|
||||
.application_version = vk.makeVersion(0, 0, 0),
|
||||
@@ -34,12 +17,12 @@ pub fn main() !void {
|
||||
if (c.glfwInit() != c.GLFW_TRUE) return error.GlfwInitFailed;
|
||||
defer c.glfwTerminate();
|
||||
|
||||
const dim = vk.Extent2D{.width = 800, .height = 600};
|
||||
const extent = vk.Extent2D{.width = 800, .height = 600};
|
||||
|
||||
c.glfwWindowHint(c.GLFW_CLIENT_API, c.GLFW_NO_API);
|
||||
const window = c.glfwCreateWindow(
|
||||
dim.width,
|
||||
dim.height,
|
||||
extent.width,
|
||||
extent.height,
|
||||
app_name,
|
||||
null,
|
||||
null
|
||||
@@ -48,4 +31,14 @@ pub fn main() !void {
|
||||
|
||||
const gc = try GraphicsContext.init(std.heap.page_allocator, &app_info, window);
|
||||
defer gc.deinit();
|
||||
|
||||
std.debug.print("Using device: {}\n", .{gc.deviceName()});
|
||||
|
||||
const swapchain = try Swapchain.init(&gc, std.heap.page_allocator, extent);
|
||||
defer swapchain.deinit();
|
||||
|
||||
while (c.glfwWindowShouldClose(window) == c.GLFW_FALSE) {
|
||||
c.glfwSwapBuffers(window);
|
||||
c.glfwPollEvents();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user