Class Engine::VirtualResolution¶
ClassList > Engine > VirtualResolution
Fixed-size game canvas, scaled and centered into the OS window. More...
#include <VirtualResolution.hpp>
Public Functions¶
| Type | Name |
|---|---|
| void | ApplyMouseMapping () Makes Raylib mouse queries return virtual canvas coordinates. |
| void | Begin () Starts drawing into the virtual canvas. |
| void | ClearMouseMapping () Restores Raylib mouse queries to window coordinates. |
| void | End () Stops drawing into the virtual canvas. |
| void | EnsureSize (int width, int height) Recreates the render texture only when the virtual size changes. |
| Rectangle | GetDestRect () const |
| int | GetHeight () const |
| float | GetScale () const |
| RenderTexture2D & | GetTexture () |
| const RenderTexture2D & | GetTexture () const |
| Vector2 | GetVirtualMouse () const Mouse position in virtual canvas pixels, clamped to the canvas. |
| int | GetWidth () const |
| void | Load () (Re)loads the render texture for the current virtual size. |
| void | Present () Draws the canvas into the current frame, letterboxed. |
| void | Unload () Releases the GPU render texture. Safe to call more than once. |
| void | UpdateLetterbox (int screenWidth, int screenHeight) Recomputes the uniform scale and the centered destination rectangle. |
| VirtualResolution (int width, int height) Creates the canvas and loads its render texture. |
|
| VirtualResolution (const VirtualResolution &) = delete |
|
| VirtualResolution (VirtualResolution &&) = delete |
|
| VirtualResolution & | operator= (const VirtualResolution &) = delete |
| VirtualResolution & | operator= (VirtualResolution &&) = delete |
| ~VirtualResolution () |
Public Static Functions¶
| Type | Name |
|---|---|
| int | ResolveAxis (int virtualSize, int windowSize) Uses virtualSize when it is positive, otherwisewindowSize . |
Detailed Description¶
Draw calls go into an off-screen render texture. The texture is then scaled uniformly so the virtual aspect ratio is preserved (letterbox / pillarbox). Mouse input can be mapped back into that canvas.
Public Functions Documentation¶
function ApplyMouseMapping¶
Makes Raylib mouse queries return virtual canvas coordinates.
Do not use this while immediate-mode UI (ImGui / rlImGui) reads the mouse.
function Begin¶
Starts drawing into the virtual canvas.
function ClearMouseMapping¶
Restores Raylib mouse queries to window coordinates.
function End¶
Stops drawing into the virtual canvas.
function EnsureSize¶
Recreates the render texture only when the virtual size changes.
Parameters:
widthNew virtual width in pixels.heightNew virtual height in pixels.
function GetDestRect¶
function GetHeight¶
function GetScale¶
function GetTexture [½]¶
function GetTexture [2/2]¶
function GetVirtualMouse¶
Mouse position in virtual canvas pixels, clamped to the canvas.
When ApplyMouseMapping() is active, Raylib's cursor is already in canvas space. Otherwise the window cursor is remapped from the letterbox.
function GetWidth¶
function Load¶
(Re)loads the render texture for the current virtual size.
Safe to call again: an existing texture is released first.
function Present¶
Draws the canvas into the current frame, letterboxed.
The caller clears the window first. Does not change the mouse mapping.
function Unload¶
Releases the GPU render texture. Safe to call more than once.
Must run while the Raylib window (OpenGL context) is still open.
function UpdateLetterbox¶
Recomputes the uniform scale and the centered destination rectangle.
Parameters:
screenWidthCurrent OS window width in pixels.screenHeightCurrent OS window height in pixels.
function VirtualResolution [⅓]¶
Creates the canvas and loads its render texture.
Parameters:
widthVirtual canvas width in pixels.heightVirtual canvas height in pixels.
function VirtualResolution [⅔]¶
function VirtualResolution [3/3]¶
function operator=¶
function operator=¶
function ~VirtualResolution¶
Public Static Functions Documentation¶
function ResolveAxis¶
Uses virtualSize when it is positive, otherwisewindowSize .
A non-positive virtual axis means "match the window" so older projects stay 1:1 until they set a distinct canvas size.
The documentation for this class was generated from the following file /home/runner/work/r-type/r-type/Engine/include/Core/VirtualResolution.hpp