KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
WindowsWindow.h
Go to the documentation of this file.
1
10#pragma once
11
12#include "Karma/Window.h"
13
14struct GLFWwindow;
15
16namespace Karma
17{
18 class GraphicsContext;
19
25 class WindowsWindow : public Window
26 {
27 public:
36 WindowsWindow(const WindowProps& props);
37
44 virtual ~WindowsWindow();
45
52 virtual void OnUpdate() override;
53
60 virtual bool OnResize(WindowResizeEvent& event) override;
61
68 inline unsigned int GetWidth() const override { return m_Data.Width; }
69
76 inline unsigned int GetHeight() const override { return m_Data.Height; }
77
86 inline void SetEventCallback(const EventCallbackFn& callback) override
87 {
88 m_Data.EventCallback = callback;
89 }
90
97 inline virtual void* GetNativeWindow() const override { return m_Window; }
98
105 void SetVSync(bool enabled) override;
106
113 bool IsVSync() const override;
114
121 GLFWwindow* GetHandle() const { return m_Window; }
122
123 private:
124 void Init(const WindowProps& props);
125
126 void SetGLFWCallbacks(GLFWwindow* glfwWindow);
127 void ShutDown();
128
129 GLFWwindow* m_Window;
130 GraphicsContext* m_Context;
131
132 struct WindowData
133 {
134 std::string Title;
135 unsigned int Width, Height;
136 bool VSync;
137
138 EventCallbackFn EventCallback;
139 };
140
141 WindowData m_Data;
142 };
143}
This file contains the Window class.
An abstract class for creating a context for Renderer and provide graphics API.
Definition GraphicsContext.h:20
The abstract base class of Karma's window (for platform specific purposes).
Definition Window.h:63
std::function< void(Event &)> EventCallbackFn
A data structure for use in Window::SetEventCallback.
Definition Window.h:72
Event triggered when Window is resized.
Definition ApplicationEvent.h:22
void SetVSync(bool enabled) override
Sets VSync on or off.
Definition WindowsWindow.cpp:218
virtual bool OnResize(WindowResizeEvent &event) override
Windows specific implementation of WindowResize event.
Definition WindowsWindow.cpp:96
virtual ~WindowsWindow()
A destructor.
Definition WindowsWindow.cpp:31
void SetEventCallback(const EventCallbackFn &callback) override
Sets a listener for Window events.
Definition WindowsWindow.h:86
WindowsWindow(const WindowProps &props)
A constructor.
Definition WindowsWindow.cpp:26
bool IsVSync() const override
Getter for VSync status.
Definition WindowsWindow.cpp:250
GLFWwindow * GetHandle() const
Getter for the GLFW Window handle.
Definition WindowsWindow.h:121
virtual void OnUpdate() override
Function called in each loop iteration.
Definition WindowsWindow.cpp:212
unsigned int GetHeight() const override
Getter for the Window height.
Definition WindowsWindow.h:76
unsigned int GetWidth() const override
Getter for the Window width.
Definition WindowsWindow.h:68
virtual void * GetNativeWindow() const override
Getter for the native Window handle.
Definition WindowsWindow.h:97
The "tangible" properties of a window.
Definition Window.h:25