Featured Article

Vulkan SDL3 Tutorial

Cynthia Jul 13, 2026

Ready to dive into the world of modern game development with Vulkan and SDL3? Look no further! This comprehensive tutorial is designed to guide you through creating a basic 3D application using these powerful tools. Whether you're a seasoned developer or new to the scene, you'll find this resource engaging and packed with insights.

How To Make A Volcano Diorama (Free Printable)
How To Make A Volcano Diorama (Free Printable)

Before we begin, ensure you have Vulkan SDK, SDL3, and a C++ compiler like MSVC or GCC, installed on your system. By the end of this tutorial, you'll have a functioning SDL3 application rendering 3D geometry using Vulkan. Let's get started!

6 Simple Steps to the Most Dramatic Baking Soda and Vinegar Volcano Experiment Ever!
6 Simple Steps to the Most Dramatic Baking Soda and Vinegar Volcano Experiment Ever!

Setting Up Your Development Environment

The first step is to set up your development environment. For this tutorial, we'll use CMake to generate project files and compile the application. Install CMake and ensure it's added to your system's PATH. We'll also use GLM for mathematics and stb_image for loading texture images.

Anatomy of a Volcano Craft PLUS B/W Free Worksheet
Anatomy of a Volcano Craft PLUS B/W Free Worksheet

Create a new folder for your project and navigate to it. Initialize a CMake project with the following command: `cmake -S . -B build -G "Visual Studio 16 2019"`. This will generate a Visual Studio solution in the 'build' folder.

Installing Dependencies

an image of a volcano made out of paper with the words make your own volcano
an image of a volcano made out of paper with the words make your own volcano

To install GLM and stb_image, download them from their respective websites and add the include directories and source files to your project. For GLM, simply add the include directory to your project. For stb_image, add the include directory and source file.

Ensure the Vulkan SDK includes are also added to your project. If you're using Visual Studio, right-click on your project, select "Properties", navigate to "C/C++ > General > Additional Include Directories", and add the Vulkan SDK include paths.

Creating a Basic SDL3 Window

Volcano Diorama Kit: How to Use for Science Fun (Free)
Volcano Diorama Kit: How to Use for Science Fun (Free)

Let's start by creating a window using SDL3. Initialize SDL3 in your main function and create an SDL_Window and SDL_Renderer. Set up some basic window properties like title, position, and dimension. Here's a simple example:

```cpp SDL_Init(SDL_INIT_VIDEO); SDL_WindowFlags windowFlags = (SDL_WindowFlags)(SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); SDL_Window* window = SDL_CreateWindow("Vulkan SDL3 Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, windowFlags); SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); ```

To render a basic color, create an SDL_Texture from a surface and draw it on the SDL_Renderer:

```cpp SDL_Surface* surface = SDL_CreateRGBSurface(0, 800, 600, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); SDL_FillRect(surface, NULL, 0xFF00FF00); SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface); SDL_Rect rect = {0, 0, 800, 600}; SDL_RenderCopy(renderer, texture, NULL, &rect); SDL_RenderPresent(renderer); ```

Initializing Vulkan and Creating a Swap Chain

someone is making a palm tree out of tinfoil and some other things on the table
someone is making a palm tree out of tinfoil and some other things on the table

Now that we have an SDL3 window, let's move on to initializing Vulkan. Create a Vulkan instance with required extensions and find a suitable physical device. Create a logical device and queue for graphics operations.

To present rendered images on the SDL3 window, we need a swap chain. Create a surface for the SDL_Window and use it to create a swap chain with the desired image format, extent, and usage. Here's a basic example:

Volcano Drawing Idea In Simple 8 Steps
Volcano Drawing Idea In Simple 8 Steps
an image of how to draw lava in different colors and sizes, with instructions on how to
an image of how to draw lava in different colors and sizes, with instructions on how to
How to make a Volcano for kids
How to make a Volcano for kids
Cre: maisonnookcoloring
Cre: maisonnookcoloring
a young boy is holding a cardboard box with plants and rocks in it while standing on the grass
a young boy is holding a cardboard box with plants and rocks in it while standing on the grass
How To Make Volcano Model For School Project | Inside Of Volcano | Simple And Easy Projects |
How To Make Volcano Model For School Project | Inside Of Volcano | Simple And Easy Projects |
Cresco gioco imparo: i vulcani |
Cresco gioco imparo: i vulcani |
15 Volcano Drawing Ideas - How To Draw Volcano
15 Volcano Drawing Ideas - How To Draw Volcano

Creating a Vulkan Instance and Physical Device

In your Vulkan initialization function, create a Vulkan instance with required extensions:

```cpp std::vector requiredExtensions = {"VK_KHR_surface", "VK_KHR_swapchain"}; VkInstanceCreateInfo instanceCreateInfo = {}; instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; instanceCreateInfo.pNext = NULL; instanceCreateInfo_flags = 0; instanceCreateInfo.pApplicationInfo = &appInfo; instanceCreateInfo.enabledExtensionCount = (uint32_t)requiredExtensions.size(); instanceCreateInfo.ppEnabledExtensionNames = requiredExtensions.data(); vkCreateInstance(&instanceCreateInfo, NULL, &instance); ```

Find a suitable physical device and create a logical device and queue for graphics operations:

Creating a Vulkan Surface and Swap Chain

Create a Vulkan surface from the SDL_Window:

```cpp VkSurfaceKHR surface; vkCreateXlibSurfaceKHR(instance, &surfaceCreateInfo, NULL, &surface); ```

Create a swap chain with the desired image format, extent, and usage:

```cpp VkSwapchainCreateInfoKHR swapchainCreateInfo = {}; swapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; swapchainCreateInfo.pNext = NULL; swapchainCreateInfo.flags = 0; swapchainCreateInfo.surface = surface; swapchainCreateInfo.minImageCount = 2; swapchainCreateInfo.imageFormat = format; swapchainCreateInfo.imageColorSpace = colorSpace; swapchainCreateInfo.imageExtent = extent; swapchainCreateInfo.imageArrayLayers = 1; swapchainCreateInfo.imageUsage = usage; vkCreateSwapchainKHR(device, &swapchainCreateInfo, NULL, &swapchain); ```

Query the swap chain images and create an image view for each:

Creating Descriptor and Frame Buffers

Create descriptor sets for binding resources to shaders and frame buffers for rendering to. Allocate a descriptor set and layout, create an image view for the depth buffer, and create a frame buffer:

Finally, populate the descriptor set with the appropriate resources and begin rendering to the frame buffers:

There you have it! A functioning SDL3 application rendering 3D geometry using Vulkan. As you progress, you can add shaders, textures, and more advanced rendering techniques. Happy coding!