Kemena3D
Loading...
Searching...
No Matches
kwindow.h
Go to the documentation of this file.
1
5
6#ifndef KWINDOW_H
7#define KWINDOW_H
8
9#include "kexport.h"
10
11#include "kdatatype.h"
12#include "ktimer.h"
13
14#include <iostream>
15#include <string>
16
17// Tell SDL not to mess with main()
18#define SDL_MAIN_HANDLED
19#include <SDL3/SDL.h>
20#include <SDL3/SDL_main.h>
21
22namespace kemena
23{
32 {
33 public:
36
38 virtual ~kWindow();
39
50 bool init(int width, int height, kString title, bool maximized = false,
51 kWindowType type = kWindowType::WINDOW_DEFAULT, void *nativeHandle = nullptr);
52
54 void destroy();
55
57 void swap();
58
61
64
67
72 void setWindowTitle(kString newTitle);
73
78 SDL_Window *getSdlWindow();
79
84 bool getRunning();
85
90 void setRunning(bool newRunning);
91
97
98 protected:
99 private:
100 SDL_Window *sdlWindow = NULL;
101
102 kString windowTitle;
103 int windowWidth;
104 int windowHeight;
105
106 bool running = true;
107 kTimer *timer;
108 };
109}
110
111#endif // KWINDOW_H
Measures elapsed time between consecutive frames.
Definition ktimer.h:22
kString getWindowTitle()
Returns the window title kString.
SDL_Window * getSdlWindow()
Returns the underlying SDL_Window pointer.
bool getRunning()
Returns whether the application main loop should keep running.
void swap()
Swaps the front and back buffers (presents the rendered frame).
int getWindowHeight()
Returns the current client-area height in pixels.
int getWindowWidth()
Returns the current client-area width in pixels.
kTimer * getTimer()
Returns the frame timer associated with this window.
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.
kWindow()
Constructs an uninitialised window; call init() to create the SDL window.
void setWindowTitle(kString newTitle)
Changes the window title bar text.
void setRunning(bool newRunning)
Controls the running state of the application.
virtual ~kWindow()
Destroys the window, releasing the SDL window and frame timer.
Core type aliases, enumerations, structs, and utility functions used throughout the engine.
Symbol visibility / linkage macro for the Kemena3D library.
#define KEMENA3D_API
Definition kexport.h:35
High-resolution per-frame delta-time timer.
Top-level Kemena3D engine namespace.
Definition kanimation.h:23
std::string kString
Standard string alias.
Definition kdatatype.h:42
kWindowType
Window creation mode.
Definition kdatatype.h:76
@ WINDOW_DEFAULT
Normal windowed mode.
Definition kdatatype.h:77