Creating a Surface

A surface is an abstraction of a window

The application needs some way of interacting with the platform's windowing system in order to display the triangle on screen. Vulkan uses an object called a surface to do this.

What is a surface?

A surface is an abstraction of a native surface or window. It is defined in the KHR_surface_extension which was initialised when creating the instance. After all rendering operations have been completed the images are presented to the surface.

The surface object must be created in one of several slightly different ways depending on which platform the application is going to be deployed to, as the surface holds a connection to a platform-specific native window object. For example, to create a surface in an application that is going to be deployed to Android, the vkCreateAndroidSurfaceWindow() function is used. These functions are contained within their own separate Vulkan extensions which must be initialised when the instance is created.

Example: initSurface()

The example code demonstrates how to create surface objects for five different platforms. The process for doing this is very similar for all platforms. It involves defining a creation struct, which holds a reference to the native window object, and then calling vkCreate[platform]SurfaceKHR(…). As mentioned before, the platform-specific wrapper, which creates these native window objects, is found in the appendices of this guide.