VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
vex::Interface Class Reference

Interface Class for vulkan backend. More...

#include <Interface.hpp>

Public Member Functions

 Interface (SDL_Window *window, glm::uvec2 initialResolution, GameInfo gInfo, VirtualFileSystem *vfs)
 Constructor for Interface class.
 ~Interface ()
 Simple destructor cleaning up resources.
void bindWindow (SDL_Window *window)
 Binds the backend to a window.
void unbindWindow ()
 Unbinds the current window.
void createDefaultTexture ()
 Creates the default texture.
VulkanContextgetContext ()
 Getter for VulkanContext.
VulkanResourcesgetResources ()
 Getter for VulkanResources.
MeshManagergetMeshManager ()
 Getter for MeshManager.
RenderergetRenderer ()
 Getter for Renderer.
void setEnvironment (environment env)
 Allows to update Enviroment settings at runtime.
environment getEnvironment ()
 Getter for Enviroment settings.
void WaitForGPUToFinish ()
 Helper function to wait for GPU to finish.
void setVSync (bool enabled)
 Sets VSync (Vertical Synchronization).

Private Member Functions

uint32_t GetBestDeviceVersion ()
bool CheckValidationLayerSupport ()

Private Attributes

VulkanContext m_context
SDL_Window * m_p_window
VirtualFileSystemm_vfs
std::unique_ptr< VulkanSwapchainManagerm_p_swapchainManager
std::unique_ptr< VulkanResourcesm_p_resources
std::unique_ptr< VulkanPipelinem_p_pipeline
std::unique_ptr< VulkanPipelinem_p_transPipeline
std::unique_ptr< VulkanPipelinem_p_maskPipeline
std::unique_ptr< VulkanPipelinem_p_billboardMaskedPipeline
std::unique_ptr< VulkanPipelinem_p_billboardTransPipeline
std::unique_ptr< VulkanPipelinem_p_particleMaskedPipeline
std::unique_ptr< VulkanPipelinem_p_particleTransPipeline
std::unique_ptr< VulkanPipelinem_p_uiPipeline
std::unique_ptr< VulkanPipelinem_p_compositePipeline
std::unique_ptr< VulkanPipelinem_p_fullscreenPipeline
std::unique_ptr< MeshManagerm_p_meshManager
std::unique_ptr< Rendererm_p_renderer

Detailed Description

Interface Class for vulkan backend.

This class manages the entire Vulkan backend lifecycle. It handles:

  • Instance and Device creation (selecting GPU, enabling extensions like Dynamic Rendering/MultiDraw).
  • Window surface binding and Swapchain initialization via VulkanSwapchainManager.
  • Resource management (Textures, UBOs) via VulkanResources.
  • Pipeline creation (Graphics, UI, Fullscreen) via VulkanPipeline.

Definition at line 34 of file Interface.hpp.

Constructor & Destructor Documentation

◆ Interface()

vex::Interface::Interface ( SDL_Window * window,
glm::uvec2 initialResolution,
GameInfo gInfo,
VirtualFileSystem * vfs )

Constructor for Interface class.

Initializes the Vulkan loader, creates an Instance with required extensions (including Portability for macOS), picks a physical device, creates a logical device with VMA allocator, and initializes all subsystems (Resources, MeshManager, Pipelines, Renderer).

Parameters
SDL_Window*window - Pointer to the SDL_Window to bind to.
glm::uvec2initialResolution - Initial rendering resolution.
GameInfogInfo - Game metadata used for application info in Vulkan.
VirtualFileSystem*vfs - Pointer to the virtual file system for asset loading.

Definition at line 74 of file Interface.cpp.

◆ ~Interface()

vex::Interface::~Interface ( )

Simple destructor cleaning up resources.

Waits for the device to idle, then destroys subsystems in reverse dependency order (Renderer -> Pipelines -> Resources -> Swapchain -> Device -> Instance).

Definition at line 730 of file Interface.cpp.

Member Function Documentation

◆ bindWindow()

void vex::Interface::bindWindow ( SDL_Window * window)

Binds the backend to a window.

Creates a Vulkan surface using SDL_Vulkan_CreateSurface and initializes the swapchain.

Parameters
SDL_Window*window - Pointer to the SDL_Window.

Definition at line 799 of file Interface.cpp.

◆ CheckValidationLayerSupport()

bool vex::Interface::CheckValidationLayerSupport ( )
private

Definition at line 17 of file Interface.cpp.

◆ createDefaultTexture()

void vex::Interface::createDefaultTexture ( )

Creates the default texture.

Delegates to VulkanResources::createDefaultTexture to generate a 1x1 white fallback texture.

Definition at line 785 of file Interface.cpp.

◆ GetBestDeviceVersion()

uint32_t vex::Interface::GetBestDeviceVersion ( )
private

Definition at line 31 of file Interface.cpp.

◆ getContext()

VulkanContext * vex::Interface::getContext ( )
inline

Getter for VulkanContext.

Returns
VulkanContext* - Pointer to the core Vulkan context structure (Device, Queue, etc.).

Definition at line 63 of file Interface.hpp.

◆ getEnvironment()

environment vex::Interface::getEnvironment ( )
inline

Getter for Enviroment settings.

Returns
environment - A copy of the current environment settings.

Definition at line 84 of file Interface.hpp.

◆ getMeshManager()

MeshManager & vex::Interface::getMeshManager ( )
inline

Getter for MeshManager.

Returns
MeshManager& - Reference to the mesh manager.

Definition at line 71 of file Interface.hpp.

◆ getRenderer()

Renderer & vex::Interface::getRenderer ( )
inline

Getter for Renderer.

Returns
Renderer& - Reference to the renderer.

Definition at line 75 of file Interface.hpp.

◆ getResources()

VulkanResources * vex::Interface::getResources ( )
inline

Getter for VulkanResources.

Returns
VulkanResources* - Pointer to the resource manager.

Definition at line 67 of file Interface.hpp.

◆ setEnvironment()

void vex::Interface::setEnvironment ( environment env)
inline

Allows to update Enviroment settings at runtime.

Updates the internal environment struct in the context, which the Renderer later pushes to the Scene UBO (e.g., Lighting, PS1 effects).

Parameters
environmentenv - The new environment settings.

Definition at line 80 of file Interface.hpp.

◆ setVSync()

void vex::Interface::setVSync ( bool enabled)

Sets VSync (Vertical Synchronization).

Updates the swapchain manager settings and requests a swapchain recreation on the next frame.

Parameters
boolenabled - True to enable VSync (FIFO), false to disable (IMMEDIATE/MAILBOX).

Definition at line 793 of file Interface.cpp.

◆ unbindWindow()

void vex::Interface::unbindWindow ( )

Unbinds the current window.

Waits for the GPU to idle, cleans up the swapchain, and destroys the window surface.

Definition at line 813 of file Interface.cpp.

◆ WaitForGPUToFinish()

void vex::Interface::WaitForGPUToFinish ( )

Helper function to wait for GPU to finish.

Calls vkDeviceWaitIdle. Should be used before resizing or shutting down to prevent resource hazards.

Definition at line 789 of file Interface.cpp.

Member Data Documentation

◆ m_context

VulkanContext vex::Interface::m_context
private

Definition at line 101 of file Interface.hpp.

◆ m_p_billboardMaskedPipeline

std::unique_ptr<VulkanPipeline> vex::Interface::m_p_billboardMaskedPipeline
private

Definition at line 109 of file Interface.hpp.

◆ m_p_billboardTransPipeline

std::unique_ptr<VulkanPipeline> vex::Interface::m_p_billboardTransPipeline
private

Definition at line 110 of file Interface.hpp.

◆ m_p_compositePipeline

std::unique_ptr<VulkanPipeline> vex::Interface::m_p_compositePipeline
private

Definition at line 114 of file Interface.hpp.

◆ m_p_fullscreenPipeline

std::unique_ptr<VulkanPipeline> vex::Interface::m_p_fullscreenPipeline
private

Definition at line 115 of file Interface.hpp.

◆ m_p_maskPipeline

std::unique_ptr<VulkanPipeline> vex::Interface::m_p_maskPipeline
private

Definition at line 108 of file Interface.hpp.

◆ m_p_meshManager

std::unique_ptr<MeshManager> vex::Interface::m_p_meshManager
private

Definition at line 116 of file Interface.hpp.

◆ m_p_particleMaskedPipeline

std::unique_ptr<VulkanPipeline> vex::Interface::m_p_particleMaskedPipeline
private

Definition at line 111 of file Interface.hpp.

◆ m_p_particleTransPipeline

std::unique_ptr<VulkanPipeline> vex::Interface::m_p_particleTransPipeline
private

Definition at line 112 of file Interface.hpp.

◆ m_p_pipeline

std::unique_ptr<VulkanPipeline> vex::Interface::m_p_pipeline
private

Definition at line 106 of file Interface.hpp.

◆ m_p_renderer

std::unique_ptr<Renderer> vex::Interface::m_p_renderer
private

Definition at line 117 of file Interface.hpp.

◆ m_p_resources

std::unique_ptr<VulkanResources> vex::Interface::m_p_resources
private

Definition at line 105 of file Interface.hpp.

◆ m_p_swapchainManager

std::unique_ptr<VulkanSwapchainManager> vex::Interface::m_p_swapchainManager
private

Definition at line 104 of file Interface.hpp.

◆ m_p_transPipeline

std::unique_ptr<VulkanPipeline> vex::Interface::m_p_transPipeline
private

Definition at line 107 of file Interface.hpp.

◆ m_p_uiPipeline

std::unique_ptr<VulkanPipeline> vex::Interface::m_p_uiPipeline
private

Definition at line 113 of file Interface.hpp.

◆ m_p_window

SDL_Window* vex::Interface::m_p_window
private

Definition at line 102 of file Interface.hpp.

◆ m_vfs

VirtualFileSystem* vex::Interface::m_vfs
private

Definition at line 103 of file Interface.hpp.


The documentation for this class was generated from the following files: