Skip to content

Instantly share code, notes, and snippets.

@kim366
Created October 14, 2021 22:12
Show Gist options
  • Save kim366/38026ef3f42e9c5a0f1cc9e451aa00f7 to your computer and use it in GitHub Desktop.
Save kim366/38026ef3f42e9c5a0f1cc9e451aa00f7 to your computer and use it in GitHub Desktop.
package main
import "vendor:glfw"
import "core:math/linalg"
import "core:fmt"
import vk "vendor:vulkan"
import "core:dynlib"
instance: vk.Instance
main :: proc() {
glfw.Init()
defer glfw.Terminate()
create_vulkan_instance := cast(proc(pCreateInfo: ^vk.InstanceCreateInfo, pAllocator: ^vk.AllocationCallbacks, pInstance: ^vk.Instance))glfw.GetInstanceProcAddress(nil, "vkCreateInstance");
app_info := vk.ApplicationInfo{
sType = vk.StructureType.APPLICATION_INFO,
pApplicationName = "Hello Triangle",
applicationVersion = vk.MAKE_VERSION(1, 0, 0),
pEngineName = "No Engine",
engineVersion = vk.MAKE_VERSION(1, 0, 0),
apiVersion = vk.API_VERSION_1_0,
}
extensions := glfw.GetRequiredInstanceExtensions()
create_info := vk.InstanceCreateInfo{
sType = vk.StructureType.INSTANCE_CREATE_INFO,
pApplicationInfo = &app_info,
enabledExtensionCount = cast(u32)len(extensions),
ppEnabledExtensionNames = raw_data(extensions),
enabledLayerCount = 0,
}
create_vulkan_instance(&create_info, nil, &instance)
set_proc_address :: proc(p: rawptr, name: cstring) {
fptr := glfw.GetInstanceProcAddress(instance, name)
(cast(^rawptr)p)^ = fptr
}
vk.load_proc_addresses(set_proc_address)
glfw.WindowHint(glfw.CLIENT_API, glfw.NO_API)
window := glfw.CreateWindow(800, 600, "Vulkan window", nil, nil)
defer glfw.DestroyWindow(window)
extension_count: u32 = ---
vk.EnumerateInstanceExtensionProperties(nil, &extension_count, nil);
fmt.printf("{} extensions supported\n", extension_count)
using linalg
matrix: Matrix4f32
vec: Vector4f32
test := mul(matrix, vec)
for glfw.WindowShouldClose(window) == 0 {
glfw.PollEvents()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment