Practical Tools for Simple Design
Loading...
Searching...
No Matches
Context.hpp
1
#ifndef CORE_CONTEXT_HPP
2
#define CORE_CONTEXT_HPP
3
4
#include "pch.hpp"
// IWYU pragma: export
5
6
#include "config.hpp"
7
8
#include "Util/Time.hpp"
9
10
namespace
Core
{
11
class
Context
{
12
public
:
16
Context
();
17
Context
(
const
Context
&) =
delete
;
18
Context
(
Context
&&) =
delete
;
19
20
~Context
();
21
22
Context
&operator=(
const
Context
&) =
delete
;
23
Context
&operator=(
Context
&&) =
delete
;
24
25
static
std::shared_ptr<Context> GetInstance();
26
27
bool
GetExit()
const
{
return
m_Exit; }
28
unsigned
int
GetWindowWidth()
const
{
return
m_WindowWidth; }
29
unsigned
int
GetWindowHeight()
const
{
return
m_WindowHeight; }
30
31
void
SetExit(
bool
exit) { m_Exit = exit; }
32
void
SetWindowWidth(
unsigned
int
width) { m_WindowWidth = width; }
33
void
SetWindowHeight(
unsigned
int
height) { m_WindowHeight = height; }
34
void
SetWindowIcon(
const
std::string &path);
35
36
void
Setup();
37
void
Update();
38
39
private
:
40
SDL_Window *m_Window;
41
SDL_GLContext m_GlContext;
42
43
static
std::shared_ptr<Context> s_Instance;
44
bool
m_Exit =
false
;
45
46
unsigned
int
m_WindowWidth = PTSD_Config::WINDOW_WIDTH;
47
unsigned
int
m_WindowHeight = PTSD_Config::WINDOW_HEIGHT;
48
49
// Can't access Time::s_Now, so using this variable to track time.
50
Util::ms_t m_BeforeUpdateTime =
Util::Time::GetElapsedTimeMs
();
51
};
52
}
// namespace Core
53
54
#endif
Core::Context
Definition:
Context.hpp:11
Core::Context::Context
Context()
Initialize context for SDL, OpenGL, and create a window.
Util::Time::GetElapsedTimeMs
static ms_t GetElapsedTimeMs()
Get the elapsed time from the start of the program in milliseconds.
Core
Core functionality of the framework
Definition:
config.hpp:7
include
Core
Context.hpp
Generated by
1.9.5