I'm trying to make an SDL2/Vulkan app in Odin, but I'm having trouble that when trying to create an instance, the application crashes because of reading null reference; I'm not sure why this is happening.
Through some basic google-ing, I found that for SDL, I need SDL2.dll from odin/vendor directory. I got that, but I'm not sure what to do about Vulkan. I have Vulkan SDK installed on the computer, and I confirmed from vsdbg (in VSCode) that vulkan-1.dll library gets loaded, but this doesn't seem to be enough. Here's the code...
sdl2.Init(sdl2.INIT_VIDEO)
tempWindow := sdl2.CreateWindow(
"temp window to get instance extensions",
0,
0,
800,
600,
sdl2.WINDOW_VULKAN | sdl2.WINDOW_ALLOW_HIGHDPI | sdl2.WINDOW_SHOWN,
)
defer sdl2.DestroyWindow(tempWindow)
instance: vulkan.Instance = ---
{
extensionsCount := u32(0)
sdl2.Vulkan_GetInstanceExtensions((^sdl2.Window)(tempWindow), &extensionsCount, nil)
extensions := make([]cstring, extensionsCount)
defer delete(extensions)
sdl2.Vulkan_GetInstanceExtensions((^sdl2.Window)(tempWindow), &extensionsCount, raw_data(extensions))
// print extensions
for i := u32(0); i < extensionsCount; i += 1 {
debug.log("Renderer", debug.LogLevel.INFO, string(extensions[i]))
}
// create vulkan instance
appInfo := vulkan.ApplicationInfo {
// ..
}
instanceInfo := vulkan.InstanceCreateInfo {
// ..
}
result := vulkan.CreateInstance(&instanceInfo, nil, &instance) // the line that crashes because of null reference
if result != vulkan.Result.SUCCESS {
debug.log("Renderer", debug.LogLevel.ERROR, "Failed to create vulkan instance")
}
}