Kale
Loading...
Searching...
No Matches
Window.hpp
Go to the documentation of this file.
1/*
2 Copyright 2022 Rishi Challa
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#pragma once
18
20
21#ifdef KALE_SDL
22 #include "SDL/WindowOuter.hpp"
23#elif defined(KALE_GLFW)
24 #include "GLFW/WindowOuter.hpp"
25#endif
26
27#include <list>
28#include <vector>
29#include <string>
30
31#ifdef KALE_VULKAN
32 #include <vulkan/vulkan.hpp>
33#endif
34
35namespace Kale {
36
37#ifdef KALE_VULKAN
38
42 namespace Vulkan {
43
47 class Renderer;
48
52 class Core;
53 }
54
55#endif
56
57#ifdef KALE_OPENGL
58
62 namespace OpenGL {
63
67 class Core;
68 }
69
70#endif
71
75 class EventHandler;
76
77 class Window {
78
79#ifdef KALE_SDL
80 #include "SDL/WindowInner.hpp"
81#elif defined(KALE_GLFW)
82 #include "GLFW/WindowInner.hpp"
83#endif
84
85 private:
86
90 std::list<EventHandler*> eventHandlers;
91
92 protected:
93
99 void create(const char* title);
100
104 void update();
105
110 std::vector<const char*> getInstanceExtensions() const;
111
112#ifdef KALE_VULKAN
113
120 void createWindowSurface(const vk::UniqueInstance& instance, vk::UniqueSurfaceKHR& surface) const;
121
122 friend class Vulkan::Core;
123
124#endif
125
126#ifdef KALE_OPENGL
127
132 void setupGlad() const;
133
137 void swapBuffers() const noexcept;
138
139 friend class OpenGL::Core;
140
141#endif
142
143 friend class Application;
144
145 public:
146
151
156
161 bool isOpen() const;
162
167
172
177 void setIcon(const std::string& filePath);
178
184
190
195
200 const char* getTitle() const;
201
206 void registerEvents(EventHandler* handler);
207
212 void removeEvents(EventHandler* handler);
213 };
214}
void removeEvents(EventHandler *handler)
Definition Window.cpp:31
friend class Vulkan::Core
Definition Window.hpp:122
Vector2ui getFramebufferSize() const
void lockCursor()
void registerEvents(EventHandler *handler)
Definition Window.cpp:24
bool isOpen() const
Vector2ui getSize() const
std::vector< const char * > getInstanceExtensions() const
void createWindowSurface(const vk::UniqueInstance &instance, vk::UniqueSurfaceKHR &surface) const
void setupGlad() const
std::list< EventHandler * > eventHandlers
Definition Window.hpp:90
void create(const char *title)
const char * getTitle() const
Vector2f getSizeF() const
void unlockCursor()
void setIcon(const std::string &filePath)
void swapBuffers() const noexcept