1
$\begingroup$

I was recently told here how to manage the integration between Vulkan and Win32.

I am writing a windowing library like "GLFW", that is only going to support Vulkan; I have now come to the point where I need to implement SwapBuffers(Window) type of function; I have tried to reverse engineer Glfw's glfwSwapBuffers(GLFWWindow*) function to see how they implemented it in their framework, but I wasn't able to understand it fully.

How do I "swap the buffers" in a Win32 window?

P.S: The library is written in C

$\endgroup$
2
$\begingroup$

I have now come to the point where I need to implement SwapBuffers(Window) type of function

Then stop doing that. You need that function in OpenGL because the windowing code is explicitly not part of OpenGL, so to write cross-platform GL code, you need an encapsulation layer.

That is not the case for Vulkan. While you still need a layer to create the window, handling the display, swap-chain images, and so forth is all part of the Vulkan API. The user's code should have complete and total control over this stuff; your abstraction layer need not be involved.

Indeed, since Vulkan has no concept of a "default framebuffer", there's no way for you to abstract away presentable images without user support. Just do what GLFW3 does in its Vulkan support: provide a cross-platform way for the user to create a Vulkan surface.

$\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.