Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import glfw "shared:odin-glfw"
- import fmt "core:fmt"
- import vk "shared:odin-vulkan"
- main :: proc() {
- window := init_window(500, 500, "hi");
- fmt.println("start");
- instance := create_instance();
- defer vk.destroy_instance(instance, nil);
- fmt.println("end");
- for !glfw.window_should_close(window) {
- glfw.poll_events();
- }
- }
- init_window :: proc(width, height: int, title: string) -> glfw.Window_Handle {
- error_callback :: proc"c"(error: i32, desc: cstring) {
- fmt.printf("Error code %d: %s\n", error, desc);
- }
- glfw.set_error_callback(error_callback);
- glfw.init();
- glfw.window_hint(glfw.CLIENT_API, cast(int) glfw.NO_API);
- glfw.window_hint(glfw.RESIZABLE, cast(int) glfw.FALSE);
- window := glfw.create_window(width, height, title, nil, nil);
- if window == nil do panic("window couldnt be created");
- return window;
- }
- // c macro to check the result of a create call
- VK_CHECK :: proc(call: vk.Result) {
- assert(call == vk.Result.Success);
- }
- // c macro to create a vulkan api version
- vk_make_version :: proc(major, minor, patch: u32) -> u32 {
- return (((major) << 22) | ((minor) << 12) | (patch));
- }
- debug_layers := [1]cstring {
- "VK_LAYER_LUNARG_standard_validation",
- };
- create_instance :: proc() -> vk.Instance {
- using vk;
- app_info: ApplicationInfo;
- app_info.sType = StructureType.ApplicationInfo;
- app_info.apiVersion = API_VERSION_1_1;
- create_info: InstanceCreateInfo;
- create_info.sType = StructureType.InstanceCreateInfo;
- create_info.pApplicationInfo = &app_info;
- // without these we can normally compile
- create_info.ppEnabledLayerNames = &debug_layers[0];
- create_info.enabledLayerCount = len(debug_layers);
- instance: vk.Instance;
- VK_CHECK(vk.create_instance(&create_info, nil, &instance));
- return instance;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement