Grindstone Game Engine
v0.2.0
An open source game engine and toolkit.
Toggle main menu visibility
Loading...
Searching...
No Matches
Window.hpp
1
#pragma once
2
3
#include <string>
4
#include <filesystem>
5
#include <Common/Graphics/WindowGraphicsBinding.hpp>
6
#include <Common/Display/Display.hpp>
7
#include <Common/Input/CursorMode.hpp>
8
9
namespace
Grindstone {
10
class
EngineCore
;
11
12
class
Window
{
13
public
:
14
enum class
FullscreenMode {
15
Windowed = 0,
16
Borderless,
17
Fullscreen
18
};
19
20
struct
CreateInfo
{
21
EngineCore
* engineCore =
nullptr
;
22
FullscreenMode fullscreen = FullscreenMode::Windowed;
23
Grindstone::Display
display;
24
unsigned
int
width = 0;
25
unsigned
int
height = 0;
26
const
char
* title =
nullptr
;
27
bool
isSwapchainControlledByEngine =
false
;
28
};
29
public
:
30
virtual
~Window
() {}
31
static
Grindstone::Window
* Create(CreateInfo& createInfo);
32
virtual
void
Show() = 0;
33
virtual
void
Hide() = 0;
34
virtual
bool
ShouldClose() = 0;
35
virtual
void
HandleEvents() = 0;
36
virtual
void
SetFullscreen(FullscreenMode mode) = 0;
37
virtual
void
GetWindowRect(
unsigned
int
& left,
unsigned
int
& top,
unsigned
int
& right,
unsigned
int
& bottom)
const
= 0;
38
virtual
void
GetWindowSize(
unsigned
int
& width,
unsigned
int
& height)
const
= 0;
39
virtual
void
SetWindowSize(
unsigned
int
width,
unsigned
int
height) = 0;
40
virtual
void
GetMousePos(
unsigned
int
& x,
unsigned
int
& y)
const
= 0;
41
virtual
void
SetMousePos(
unsigned
int
x,
unsigned
int
y) = 0;
42
virtual
void
SetCursorMode(Grindstone::Input::CursorMode cursorMode) = 0;
43
virtual
Grindstone::Input::CursorMode GetCursorMode()
const
= 0;
44
virtual
void
SetMouseIsRawMotion(
bool
isRawMotion) = 0;
45
virtual
bool
GetMouseIsRawMotion()
const
= 0;
46
virtual
void
SetWindowPos(
unsigned
int
x,
unsigned
int
y) = 0;
47
virtual
void
GetWindowPos(
unsigned
int
& x,
unsigned
int
& y)
const
= 0;
48
virtual
void
SetWindowFocus(
bool
isFocused) = 0;
49
virtual
bool
GetWindowFocus()
const
= 0;
50
virtual
bool
GetWindowMinimized()
const
= 0;
51
virtual
void
GetTitle(
char
* allocatedBuffer)
const
= 0;
52
virtual
void
SetTitle(
const
char
* title) = 0;
53
virtual
void
SetWindowAlpha(
float
alpha) = 0;
54
virtual
float
GetWindowDpiScale()
const
= 0;
55
virtual
void
Close() = 0;
56
57
virtual
bool
CopyStringToClipboard(
const
std::string& stringToCopy) = 0;
58
virtual
std::filesystem::path BrowseFolder(std::filesystem::path& defaultPath) = 0;
59
virtual
std::filesystem::path OpenFileDialogue(
const
char
* filter =
"All Files (*.*)\0*.*\0"
) = 0;
60
virtual
std::filesystem::path SaveFileDialogue(
const
char
* filter =
"All Files (*.*)\0*.*\0"
) = 0;
61
virtual
void
ExplorePath(
const
char
* path) = 0;
62
virtual
void
OpenFileUsingDefaultProgram(
const
char
* path) = 0;
63
public
:
64
inline
Grindstone::GraphicsAPI::WindowGraphicsBinding
* GetWindowGraphicsBinding()
const
{
65
return
windowsGraphicsBinding;
66
}
67
68
inline
void
AddBinding(
Grindstone::GraphicsAPI::WindowGraphicsBinding
* wgb) {
69
windowsGraphicsBinding = wgb;
70
}
71
72
inline
void
ImmediateSetContext() {
73
windowsGraphicsBinding->ImmediateSetContext();
74
}
75
76
inline
void
ImmediateSwapBuffers() {
77
windowsGraphicsBinding->ImmediateSwapBuffers();
78
}
79
80
inline
bool
IsSwapchainControlledByEngine()
const
{
81
return
isSwapchainControlledByEngine;
82
}
83
protected
:
84
Grindstone::GraphicsAPI::WindowGraphicsBinding* windowsGraphicsBinding =
nullptr
;
85
bool
isSwapchainControlledByEngine;
86
private
:
87
virtual
bool
Initialize(
CreateInfo
& createInfo) = 0;
88
};
89
};
Grindstone::EngineCore
Definition
EngineCore.hpp:59
Grindstone::GraphicsAPI::WindowGraphicsBinding
Definition
WindowGraphicsBinding.hpp:18
Grindstone::Window
Definition
Window.hpp:12
Grindstone::Display
Definition
Display.hpp:6
Grindstone::Window::CreateInfo
Definition
Window.hpp:20
sources
code
Common
Window
Window.hpp
Generated by
1.17.0