2
3
4
5
10#include "Core/Event/KeyEvent.h"
11#include "Core/Event/MouseEvent.h"
12#include "Core/Event/WindowEvent.h"
22
23
26 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
27 glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
28 glfwWindowHint(GLFW_DECORATED, GLFW_TRUE);
30 const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
32 glfwWindowHint(GLFW_RED_BITS , mode->redBits );
33 glfwWindowHint(GLFW_GREEN_BITS , mode->greenBits );
34 glfwWindowHint(GLFW_BLUE_BITS , mode->blueBits );
35 glfwWindowHint(GLFW_REFRESH_RATE , mode->refreshRate );
38
39
40
41 vulkanState.m_Windows = glfwCreateWindow(initInfo
.width, initInfo
.height, initInfo
.name.c_str(),
nullptr,
nullptr);
44
45
46 glfwSetWindowIcon(vulkanState.m_Windows, 1, &initInfo.icon->image);
49
50
51
52
55
56
57 glfwSetWindowUserPointer(vulkanState.m_Windows,
this);
60
61
70
71
75
76
85
86
87
88 glfwSetErrorCallback([](
int error,
const char* description)
91 SPICES_CORE_INFO(description);
95
96
97
101
102
103 glfwSetWindowSizeCallback(
m_VulkanState.m_Windows, [](GLFWwindow* window,
int width,
int height)
106
107
108 const auto vulkanWindow =
static_cast<VulkanWindows*>(glfwGetWindowUserPointer(window));
111
112
113 vulkanWindow->m_WindowsResized =
true;
114 vulkanWindow->m_WindowInfo.width = width;
115 vulkanWindow->m_WindowInfo.height = height;
118
119
123
124
129
130
131 glfwSetWindowCloseCallback(
m_VulkanState.m_Windows, [](GLFWwindow* window)
134
135
139
140
145
146
147 glfwSetKeyCallback(
m_VulkanState.m_Windows, [](GLFWwindow* window,
int key,
int scancode,
int action,
int mods)
154
155
159
160
168
169
173
174
182
183
187
188
197
198
199 glfwSetCharCallback(
m_VulkanState.m_Windows, [](GLFWwindow* window,
unsigned int keycode)
202
203
207
208
213
214
215 glfwSetMouseButtonCallback(
m_VulkanState.m_Windows, [](GLFWwindow* window,
int button,
int action,
int mods)
222
223
227
228
236
237
241
242
251
252
253 glfwSetScrollCallback(
m_VulkanState.m_Windows, [](GLFWwindow* window,
double xOffset,
double yOffset)
256
257
261
262
267
268
269 glfwSetCursorPosCallback(
m_VulkanState.m_Windows, [](GLFWwindow* window,
double xPos,
double yPos)
272
273
277
278
#define SPICES_PROFILE_ZONE
static EventCallbackFn GetEventCallbackFn()
Get Global Root Event Function Pointer.
This Class is the basic Event Class. Inherit from it and create specific event class.
KeyPressedEvent(int keycode, int repeatCount)
Constructor Function.
This Class is inherited from KeyEvent Class.
KeyReleasedEvent(int keycode)
Constructor Function.
This Class is inherited from KeyEvent Class.
KeyTypedEvent(int keycode)
Constructor Function.
This Class is inherited from KeyEvent Class.
MouseMovedEvent(float x, float y)
Constructor Function.
This Class is inherited from Event Class.
VulkanState & m_VulkanState
The global VulkanState Referenced from VulkanRenderBackend.
VulkanObject(VulkanState &vulkanState)
Constructor Function. Init member variables.
VulkanObject Class. This class defines the basic behaves of VulkanObject. When we create an new Vulka...
VulkanWindows(VulkanState &vulkanState, const WindowInfo &initInfo)
Constructor Function. Create Windows.
virtual ~VulkanWindows() override
Destructor Function.
void SetInternalCallBack() const
Set all needed GLFW events call back.
VulkanWindows Class. This class defines the windows behaves.
This Class is inherited from Event Class.
WindowResizeEvent(uint32_t width, uint32_t height)
Constructor Function.
This Class is inherited from Event Class. Called when window resized. This Event register by glfw win...
This struct contains all Vulkan object in used global.
std::string name
Window's name.
int height
Window's height.
This struct defines the basic information of window.