6
$\begingroup$

I am aware of libraries that already do this (like GLFW), but I would actually prefer do all of the window and context creation by myself.

$\endgroup$
7
$\begingroup$

There's no such thing as a Vulkan context, the way there is with OpenGL. This is because Vulkan is a lower level API and an OpenGL context ties together a number of concepts that are distinct in the Vulkan API.

For example, the OpenGL context ties together the concept of extension management, memory management, draw commands and surface presentation. In Vulkan those are all managed through independent interfaces.

There are a number of things in Vulkan that kind of correspond to an OpenGL context in different ways, depending on what you're trying to do.

VkInstance encapsulates access to the Vulkan libraries on the system, including enumerating the global extensions.

VkPhysicalDevice lets you query the hardware capabilities and hardware specific extensions.

VkDevice lets you actually interact with the hardware to do things like allocate memory.

VkCommandBuffer is the interface for setting up and executing draw calls.

However, since you're focused on windows, what you're probably interested in is VkSurfaceKHR. This encapsulates interaction with a windowing system, including initializing a surface from the OS specific window handles and doing presentation calls.

On Windows, to interact with a window, you need to have an existing VkInstance, and you need to call vkCreateWin32SurfaceKHR and pass it a structure containing an HWND and an HINSTANCE. If it succeeds then you have a surface to which you can then present images.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.