Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
Flint::SdlWindow Class Reference

SDL3 window implementation that also exposes the SDL GPU context. More...

#include <flint/window/sdl-window.h>

+ Inheritance diagram for Flint::SdlWindow:
+ Collaboration diagram for Flint::SdlWindow:

Public Member Functions

 SdlWindow (const ApplicationConfig &config, GRAPHICS_BACKEND backend)
 Create and show an SDL window.
 
void display () override
 Present the current frame to the screen.
 
bool isOpen () const override
 Return true if the window is open and the application should keep running.
 
void setMouseCursor (CursorType type) override
 Set the mouse cursor shape.
 
void pollEvents (const std::function< void(const AppEvent &)> &handler) override
 Poll all pending OS events and dispatch them to handler.
 
void setTitle (const std::string &name) override
 Set the window title.
 
void close () override
 Signal that the window should close at the end of the current frame.
 
Flint::Vec2i getSize () const override
 Return the current window size in pixels.
 
Flint::Vec2f getMousePosition () const override
 Return the current mouse cursor position in window-space pixels.
 
Flint::Vec2f mapPixelToCoords (Flint::Vec2f pixel) const override
 Pass-through pixel-to-coord mapping (no scaling applied).
 
void addGlobalEventListener (std::function< void(const AppEvent &)> callback) override
 Register a global event listener that receives every polled event.
 
bool hasFocus () const override
 Return true if the window currently has input focus.
 
void * getNativeHandle () const override
 Return the platform-native window handle (e.g. HWND, SDL_Window*).
 
void setGPUDevice (SDL_GPUDevice *device) override
 Store the SDL GPU device created by the renderer (IGPUContext).
 
SDL_GPUDevice * getGPUDevice () override
 Return the SDL GPU device (IGPUContext).
 
SDL_GPUCommandBuffer * getCommandBuffer () override
 Return the current frame's command buffer (IGPUContext).
 
SDL_GPURenderPass * getRenderPass () override
 Return the current frame's render pass (IGPUContext).
 
bool isFullscreen () const override
 Return true if the window is in fullscreen mode.
 
void setFullscreen (bool fullscreen) override
 Enter or exit fullscreen mode.
 
- Public Member Functions inherited from Flint::IWindow
- Public Member Functions inherited from Flint::IGPUContext

Detailed Description

SDL3 window implementation that also exposes the SDL GPU context.

Implements both IWindow (for event polling and presentation) and IGPUContext (for GPU device, command buffer, and render pass access). The Application and GPURenderer obtain GPU handles through this class without depending on any other platform type.

Definition at line 23 of file sdl-window.h.

Constructor & Destructor Documentation

◆ SdlWindow()

Flint::SdlWindow::SdlWindow ( const ApplicationConfig & config,
GRAPHICS_BACKEND backend )
explicit

Create and show an SDL window.

Parameters
configApplication configuration

Member Function Documentation

◆ addGlobalEventListener()

void Flint::SdlWindow::addGlobalEventListener ( std::function< void(const AppEvent &)> callback)
overridevirtual

Register a global event listener that receives every polled event.

Multiple listeners can be registered; they are called in registration order.

Parameters
callbackListener invoked for each AppEvent.

Implements Flint::IWindow.

◆ close()

void Flint::SdlWindow::close ( )
inlineoverridevirtual

Signal that the window should close at the end of the current frame.

Implements Flint::IWindow.

Definition at line 44 of file sdl-window.h.

◆ display()

void Flint::SdlWindow::display ( )
overridevirtual

Present the current frame to the screen.

Implements Flint::IWindow.

◆ getCommandBuffer()

SDL_GPUCommandBuffer * Flint::SdlWindow::getCommandBuffer ( )
inlineoverridevirtual

Return the current frame's command buffer (IGPUContext).

Implements Flint::IGPUContext.

Definition at line 86 of file sdl-window.h.

◆ getGPUDevice()

SDL_GPUDevice * Flint::SdlWindow::getGPUDevice ( )
inlineoverridevirtual

Return the SDL GPU device (IGPUContext).

Implements Flint::IGPUContext.

Definition at line 81 of file sdl-window.h.

◆ getMousePosition()

Flint::Vec2f Flint::SdlWindow::getMousePosition ( ) const
inlineoverridevirtual

Return the current mouse cursor position in window-space pixels.

Implements Flint::IWindow.

Definition at line 56 of file sdl-window.h.

◆ getNativeHandle()

void * Flint::SdlWindow::getNativeHandle ( ) const
inlineoverridevirtual

Return the platform-native window handle (e.g. HWND, SDL_Window*).

Cast to the appropriate platform type when needed.

Returns
Opaque native handle as void*.

Implements Flint::IWindow.

Definition at line 71 of file sdl-window.h.

◆ getRenderPass()

SDL_GPURenderPass * Flint::SdlWindow::getRenderPass ( )
inlineoverridevirtual

Return the current frame's render pass (IGPUContext).

Implements Flint::IGPUContext.

Definition at line 91 of file sdl-window.h.

◆ getSize()

Flint::Vec2i Flint::SdlWindow::getSize ( ) const
inlineoverridevirtual

Return the current window size in pixels.

Implements Flint::IWindow.

Definition at line 49 of file sdl-window.h.

◆ hasFocus()

bool Flint::SdlWindow::hasFocus ( ) const
overridevirtual

Return true if the window currently has input focus.

Implements Flint::IWindow.

◆ isFullscreen()

bool Flint::SdlWindow::isFullscreen ( ) const
inlineoverridevirtual

Return true if the window is in fullscreen mode.

Implements Flint::IWindow.

Definition at line 96 of file sdl-window.h.

◆ isOpen()

bool Flint::SdlWindow::isOpen ( ) const
overridevirtual

Return true if the window is open and the application should keep running.

Implements Flint::IWindow.

◆ mapPixelToCoords()

Flint::Vec2f Flint::SdlWindow::mapPixelToCoords ( Flint::Vec2f pixel) const
inlineoverridevirtual

Pass-through pixel-to-coord mapping (no scaling applied).

Implements Flint::IWindow.

Definition at line 63 of file sdl-window.h.

◆ pollEvents()

void Flint::SdlWindow::pollEvents ( const std::function< void(const AppEvent &)> & handler)
overridevirtual

Poll all pending OS events and dispatch them to handler.

Parameters
handlerCallback invoked once for each pending AppEvent.

Implements Flint::IWindow.

◆ setFullscreen()

void Flint::SdlWindow::setFullscreen ( bool fullscreen)
inlineoverridevirtual

Enter or exit fullscreen mode.

Parameters
fullscreentrue to enter SDL_WINDOW_FULLSCREEN mode.

Implements Flint::IWindow.

Definition at line 106 of file sdl-window.h.

◆ setGPUDevice()

void Flint::SdlWindow::setGPUDevice ( SDL_GPUDevice * device)
inlineoverridevirtual

Store the SDL GPU device created by the renderer (IGPUContext).

Implements Flint::IGPUContext.

Definition at line 76 of file sdl-window.h.

◆ setMouseCursor()

void Flint::SdlWindow::setMouseCursor ( CursorType type)
overridevirtual

Set the mouse cursor shape.

Parameters
typeDesired cursor shape.

Implements Flint::IWindow.

◆ setTitle()

void Flint::SdlWindow::setTitle ( const std::string & name)
inlineoverridevirtual

Set the window title.

Implements Flint::IWindow.

Definition at line 39 of file sdl-window.h.


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