Kemena3D
Loading...
Searching...
No Matches
kemena::kWindow Class Reference

Creates and manages an SDL3 application window. More...

#include <kwindow.h>

Public Member Functions

 kWindow ()
 Constructs an uninitialised window; call init() to create the SDL window.
virtual ~kWindow ()
 Destroys the window, releasing the SDL window and frame timer.
bool init (int width, int height, kString title, bool maximized=false, kWindowType type=kWindowType::WINDOW_DEFAULT, void *nativeHandle=nullptr)
 Creates and shows the SDL window.
void destroy ()
 Destroys the SDL window and releases its resources.
void swap ()
 Swaps the front and back buffers (presents the rendered frame).
int getWindowWidth ()
 Returns the current client-area width in pixels.
int getWindowHeight ()
 Returns the current client-area height in pixels.
kString getWindowTitle ()
 Returns the window title kString.
void setWindowTitle (kString newTitle)
 Changes the window title bar text.
SDL_Window * getSdlWindow ()
 Returns the underlying SDL_Window pointer.
bool getRunning ()
 Returns whether the application main loop should keep running.
void setRunning (bool newRunning)
 Controls the running state of the application.
kTimergetTimer ()
 Returns the frame timer associated with this window.

Detailed Description

Creates and manages an SDL3 application window.

kWindow wraps the SDL_Window lifecycle and provides helpers for querying window dimensions, swapping the back buffer, and accessing the built-in frame timer. Attach a kRenderer to a kWindow before rendering.

Constructor & Destructor Documentation

◆ kWindow()

kemena::kWindow::kWindow ( )

Constructs an uninitialised window; call init() to create the SDL window.

◆ ~kWindow()

virtual kemena::kWindow::~kWindow ( )
virtual

Destroys the window, releasing the SDL window and frame timer.

Member Function Documentation

◆ destroy()

void kemena::kWindow::destroy ( )

Destroys the SDL window and releases its resources.

◆ getRunning()

bool kemena::kWindow::getRunning ( )

Returns whether the application main loop should keep running.

Returns
false after the user closes the window or setRunning(false) is called.

◆ getSdlWindow()

SDL_Window * kemena::kWindow::getSdlWindow ( )

Returns the underlying SDL_Window pointer.

Returns
Raw SDL window handle; valid until destroy() is called.

◆ getTimer()

kTimer * kemena::kWindow::getTimer ( )

Returns the frame timer associated with this window.

Returns
Pointer to the kTimer; valid for the lifetime of the window.

◆ getWindowHeight()

int kemena::kWindow::getWindowHeight ( )

Returns the current client-area height in pixels.

◆ getWindowTitle()

kString kemena::kWindow::getWindowTitle ( )

Returns the window title kString.

◆ getWindowWidth()

int kemena::kWindow::getWindowWidth ( )

Returns the current client-area width in pixels.

◆ init()

bool kemena::kWindow::init ( int width,
int height,
kString title,
bool maximized = false,
kWindowType type = kWindowType::WINDOW_DEFAULT,
void * nativeHandle = nullptr )

Creates and shows the SDL window.

Parameters
widthInitial client-area width in pixels.
heightInitial client-area height in pixels.
titleWindow title bar text.
maximizedIf true, the window starts maximised.
typeWindow mode (windowed, fullscreen, borderless).
nativeHandleOptional platform-specific parent window handle.
Returns
true on success.

◆ setRunning()

void kemena::kWindow::setRunning ( bool newRunning)

Controls the running state of the application.

Parameters
newRunningSet to false to request the main loop to exit.

◆ setWindowTitle()

void kemena::kWindow::setWindowTitle ( kString newTitle)

Changes the window title bar text.

Parameters
newTitleNew title kString.

◆ swap()

void kemena::kWindow::swap ( )

Swaps the front and back buffers (presents the rendered frame).


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