Skip to content
Finalspace edited this page May 29, 2026 · 1 revision

Table of Contents

Initialize Vulkan

Initializing Vulkan is different than initializing other graphics APIs such as OpenGL, but FPL helps you in the first steps.

The very first thing you need is a Vulkan Instance (VkInstance).

Secondly you require a Vulkan Surface (VkSurfaceKHR) to present the graphical result to the screen.

FPL can create the Instance and the Surface for you.

The surface creation is mandatory, but an existing instance can optionally be passed to the fplSettings structure if needed.

Create a Vulkan Instance and a Surface

First you have to create a fplSettings structure and initialize it with default settings using fplSetDefaultSettings().

Second you set the fplVideoSettings::backend to fplVideoBackendType_Vulkan .

We can reference the fplVulkanSettings type stored in fplGraphicsApiSettings::vulkan for convenience usage later.

 settings;
(&settings);

// Reference of the video settings
 *videoSettings = &settings.;

// Forcing the video backend to Vulkan
videoSettings-> = ;

// Reference of the vulkan settings for later usage
 *vulkanSettings = &videoSettings..;

Fill in the application, engine and api versions

 *vulkanSettings = &videoSettings..;

vulkanSettings-> = "The name of your application";
vulkanSettings-> = (, "1.0.0", "1", "0", "0"); // Version of your application

vulkanSettings-> = "The name of your engine";
vulkanSettings-> = (, "1.0.0", "1", "0", "0"); // Version of your engine

vulkanSettings-> = (, "1.1.0", "1", "1", "0"); // Preferred Vulkan API version (should be greater or equal than 1.1.0)

Choose a Vulkan validation mode

static void VulkanValidationLayerCallback(void *userData, const char *message, const VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, const VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT *debugUtilsMessengerCallbackData) {
    ("Vulkan Validation: %s\n", message);
}

 *vulkanSettings = &videoSettings..;

vulkanSettings-> = ; // Do not use the Vulkan Validation Layer as an instance extension

// or
vulkanSettings-> = fplVulkanValidationLayerMode_Logging; // Enable Vulkan Validation Layer as an instance extension and log everything to FPL directly, using the FPL logging system

// or
vulkanSettings-> = fplVulkanValidationLayerMode_User; // Enable Vulkan Validation Layer as an instance extension and let the user handle the logging
vulkanSettings-> = VulkanValidationLayerCallback; // The user callback
vulkanSettings-> = (void *)YourUserData; // The user data passed to the callback

Continue with Vulkan Usage

Create a Vulkan Surface from an existing Instance

If you already have a Vulkan Instance (VkInstance), you can simply pass that to the fplVulkanSettings::instanceHandle field and initialize FPL with fplPlatformInit():

VkInstance yourVulkanInstance;

 *vulkanSettings = &videoSettings..;

vulkanSettings->instance = yourVulkanInstance; // Pass in your vulkan instance to FPL

if ((, &settings)) {
    // ... Vulkan Surface is created now and ready to use
}

Continue with Vulkan Usage

Vulkan Usage

After you have created a Vulkan Instance and a Surface, you can query it by calling fplGetVideoSurface() directly after fplPlatformInit():

if ((, &settings)) {
    // Get video surface
    const  *surface = ();
    (surface != );

    // Get the VkInstance and VkSurfaceKHR
    VkInstance instanceHandle = (VkInstance)surface->.instanceHandle;
    VkSurfaceKHR surfaceHandle = (VkSurfaceKHR)surface->vulkan.surfaceKHR;
    (instanceHandle != VK_NULL_HANDLE);
    (surfaceHandle != VK_NULL_HANDLE);

    // ... continue the Vulkan initialization process
}

After that, the typical Vulkan process continues:

See the FPL_Vulkan demo for more details or learn more about Vulkan: Vulkan-Tutorials

Memory Allocator

If you have an existing memory allocator for Vulkan, you can pass that to FPL before calling fplPlatformInit():

VkAllocationCallbacks *yourMemoryAllocator;

 *vulkanSettings = &videoSettings..;

vulkanSettings-> = (void *)yourMemoryAllocator; // Pass in your memory allocator

Final Platform Layer

Pages

Topics

Data Structures

Clone this wiki locally