37 {
39 m_Data.Title = props.Title;
40 m_Data.Width = props.Width;
41 m_Data.Height = props.Height;
42
43 VZ_CORE_INFO(
"Creating window {0} ({1}, {2})", props.Title, props.Width, props.Height);
44
45
47 {
48 int success = glfwInit();
52 }
53
54 m_Window = glfwCreateWindow((
int)props.Width, (
int)props.Height,
m_Data.Title.c_str(),
nullptr,
nullptr);
55
58
59
62
63
64 glfwSetWindowSizeCallback(
m_Window, [](GLFWwindow* window,
int width,
int height)
65 {
68 data.Width = width;
69
70 WindowResizeEvent event(width, height);
71 VZ_CORE_WARN(
"Window resized to {0}, {1}", width, height);
72 data.EventCallback(event);
73 });
74
75 glfwSetWindowCloseCallback(
m_Window, [](GLFWwindow* window)
76 {
78 WindowCloseEvent event;
80 });
81
82 glfwSetKeyCallback(
m_Window, [](GLFWwindow* window,
int key,
int scancode,
int action,
int mods)
83 {
85 switch (action)
86 {
87 case GLFW_PRESS:
88 {
89 KeyPressedEvent event(key, 0);
90 data.EventCallback(event);
91 break;
92 }
93 case GLFW_RELEASE:
94 {
95 KeyReleasedEvent event(key);
96 data.EventCallback(event);
97 break;
98 }
99 case GLFW_REPEAT:
100 {
101 KeyPressedEvent event(key, 1);
102 data.EventCallback(event);
103 break;
104 }
105 }
106 });
107
108 glfwSetCharCallback(
m_Window, [](GLFWwindow* window,
unsigned int keycode)
109 {
111 KeyTypedEvent event(keycode);
112 data.EventCallback(event);
113 });
114
115 glfwSetMouseButtonCallback(
m_Window, [](GLFWwindow* window,
int button,
int action,
int mods)
116 {
118 switch (action)
119 {
120 case GLFW_PRESS:
121 {
122 MouseButtonPressedEvent event(button);
123 data.EventCallback(event);
124 break;
125 }
126 case GLFW_RELEASE:
127 {
128 MouseButtonReleasedEvent event(button);
129 data.EventCallback(event);
130 break;
131 }
132 }
133 });
134
135 glfwSetScrollCallback(
m_Window, [](GLFWwindow* window,
double xOffset,
double yOffset)
136 {
138 MouseScrolledEvent event((float)xOffset, (float)yOffset);
139 data.EventCallback(event);
140 });
141
142 glfwSetCursorPosCallback(
m_Window, [](GLFWwindow* window,
double xPos,
double yPos)
143 {
145 MouseMovedEvent event((float)xPos, (float)yPos);
146 data.EventCallback(event);
147 });
148 }
#define VZ_CORE_ASSERT(x,...)
Definition Asserts.h:20
#define VZ_CORE_WARN(...)
warn: indicates a potential issue or important event
Definition Log.h:39
#define VZ_CORE_INFO(...)
info: general information about application flow
Definition Log.h:37
GraphicsContext * m_Context
Definition WindowsWindow.h:31
unsigned int Height
Definition WindowsWindow.h:35
EventCallbackFn EventCallback
Definition WindowsWindow.h:38
void SetVSync(bool enabled) override
Sets whether vertical synchronization (VSync) is enabled.
Definition WindowsWindow.cpp:163
Definition WindowsWindow.h:33
static bool s_GLFWInitialized
Definition WindowsWindow.cpp:13
static void GLFWErrorCallback(int error, const char *description)
Definition WindowsWindow.cpp:15