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

Class responsible for managing resolution settings, calculating render resolution based on selected mode. More...

#include <ResolutionManager.hpp>

Public Member Functions

 ResolutionManager (SDL_Window *p_window)
 Constructor.
void setMode (ResolutionMode mode)
 Function to set the resolution mode. It is called by engine method.
ResolutionMode getCurrentMode () const
 Function to get the current resolution mode.
glm::uvec2 getRenderResolution () const
 Function to get the current render resolution.
glm::uvec2 getWindowResolution () const
 Function to get the current window resolution.
float getUpscaleRatio () const
 Function to get the current upscale ratio. Read window resolution divided by render resolution.
void update ()
 Updates the internal resolution state based on the current window size and mode.
float getPotencialUpscaleRatio ()
 Calculates the potential upscale ratio for a given height. @description allows you to create consistant sizing in both native and ps1 sharp modes.

Private Member Functions

void calculatePS1SharpResolution ()
 Internal helper to calculate integer-scaled resolutions for the PS1_SHARP mode.

Private Attributes

SDL_Window * m_p_window
ResolutionMode m_currentMode = ResolutionMode::PS1_SHARP
glm::uvec2 m_windowResolution
glm::uvec2 m_renderResolution
float m_upscaleRatio = 1.0f

Detailed Description

Class responsible for managing resolution settings, calculating render resolution based on selected mode.

Definition at line 46 of file ResolutionManager.hpp.

Constructor & Destructor Documentation

◆ ResolutionManager()

vex::ResolutionManager::ResolutionManager ( SDL_Window * p_window)

Constructor.

Parameters
SDL_Window*p_window - Pointer to the SDL window.

Definition at line 7 of file ResolutionManager.cpp.

Member Function Documentation

◆ calculatePS1SharpResolution()

void vex::ResolutionManager::calculatePS1SharpResolution ( )
private

Internal helper to calculate integer-scaled resolutions for the PS1_SHARP mode.

Determines the maximum integer scale factor (clamped between 1 and 4) that fits within the current window height. Ensures the render height does not drop below 240p.

Definition at line 107 of file ResolutionManager.cpp.

◆ getCurrentMode()

ResolutionMode vex::ResolutionManager::getCurrentMode ( ) const
inline

Function to get the current resolution mode.

Definition at line 57 of file ResolutionManager.hpp.

◆ getPotencialUpscaleRatio()

float vex::ResolutionManager::getPotencialUpscaleRatio ( )

Calculates the potential upscale ratio for a given height. @description allows you to create consistant sizing in both native and ps1 sharp modes.

Returns
float - The potential upscale ratio.

Definition at line 92 of file ResolutionManager.cpp.

◆ getRenderResolution()

glm::uvec2 vex::ResolutionManager::getRenderResolution ( ) const
inline

Function to get the current render resolution.

Returns
glm::uvec2 - The current render resolution.

Definition at line 61 of file ResolutionManager.hpp.

◆ getUpscaleRatio()

float vex::ResolutionManager::getUpscaleRatio ( ) const
inline

Function to get the current upscale ratio. Read window resolution divided by render resolution.

Returns
float - The current upscale ratio.

Definition at line 69 of file ResolutionManager.hpp.

◆ getWindowResolution()

glm::uvec2 vex::ResolutionManager::getWindowResolution ( ) const
inline

Function to get the current window resolution.

Returns
glm::uvec2 - The current window resolution.

Definition at line 65 of file ResolutionManager.hpp.

◆ setMode()

void vex::ResolutionManager::setMode ( ResolutionMode mode)

Function to set the resolution mode. It is called by engine method.

Parameters
ResolutionModemode - The resolution mode to set.

Definition at line 11 of file ResolutionManager.cpp.

◆ update()

void vex::ResolutionManager::update ( )

Updates the internal resolution state based on the current window size and mode.

Queries the actual window size from SDL (SDL_GetWindowSizeInPixels). Depending on m_currentMode:

  • NATIVE: Matches render resolution to window size (1:1).
  • RES_240P/480P: Fixes the vertical resolution to 240 or 480 and calculates width based on aspect ratio.
  • PS1_SHARP: Calls calculatePS1SharpResolution() to find an integer scale factor.

Definition at line 16 of file ResolutionManager.cpp.

Member Data Documentation

◆ m_currentMode

ResolutionMode vex::ResolutionManager::m_currentMode = ResolutionMode::PS1_SHARP
private

Definition at line 90 of file ResolutionManager.hpp.

◆ m_p_window

SDL_Window* vex::ResolutionManager::m_p_window
private

Definition at line 89 of file ResolutionManager.hpp.

◆ m_renderResolution

glm::uvec2 vex::ResolutionManager::m_renderResolution
private

Definition at line 92 of file ResolutionManager.hpp.

◆ m_upscaleRatio

float vex::ResolutionManager::m_upscaleRatio = 1.0f
private

Definition at line 93 of file ResolutionManager.hpp.

◆ m_windowResolution

glm::uvec2 vex::ResolutionManager::m_windowResolution
private

Definition at line 91 of file ResolutionManager.hpp.


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