KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
MacWindow.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
23 class MacWindow : public Window
24 {
25 public:
32 MacWindow(const WindowProps& props);
33
39 virtual ~MacWindow();
40
47 void OnUpdate() override;
48
54 virtual bool OnResize(WindowResizeEvent& event) override;
55
61 inline unsigned int GetWidth() const override { return m_Data.Width; }
62
68 inline unsigned int GetHeight() const override { return m_Data.Height; }
69
76 inline void SetEventCallback(const EventCallbackFn& callback) override
77 {
78 m_Data.EventCallback = callback;
79 }
80
86 inline virtual void* GetNativeWindow() const override { return m_Window; }
87
93 void SetVSync(bool enabled) override;
94
100 bool IsVSync() const override;
101
102 private:
116 void Init(const WindowProps& props);
117
132 void SetGLFWCallbacks(GLFWwindow* glfwWindow);
133
140 void ShutDown();
141
142 GLFWwindow* m_Window;
143 GraphicsContext* m_Context;
144
150 struct WindowData
151 {
152 std::string Title;
153 unsigned int Width, Height;
154 bool VSync;
155
156 EventCallbackFn EventCallback;
157 };
158
159 WindowData m_Data;
160 };
161}
This file contains the Window class.
An abstract class for creating a context for Renderer and provide graphics API.
Definition GraphicsContext.h:20
bool IsVSync() const override
Query for Mac VSync status.
Definition MacWindow.cpp:264
virtual ~MacWindow()
A destructor to clean up the mess and Mac window relevant resources.
Definition MacWindow.cpp:33
virtual void * GetNativeWindow() const override
Getter for the Mac Window handle.
Definition MacWindow.h:86
MacWindow(const WindowProps &props)
A constructor to initialize Mac Window with appropriate properties.
Definition MacWindow.cpp:28
void SetVSync(bool enabled) override
Based on API chosen, the Mac based VSync toggle.
Definition MacWindow.cpp:233
void OnUpdate() override
Called each loop for input polling and OpenGL swapbuffers.
Definition MacWindow.cpp:227
unsigned int GetHeight() const override
Getter for Mac Window height.
Definition MacWindow.h:68
void SetEventCallback(const EventCallbackFn &callback) override
Sets a listner for Mac Window.
Definition MacWindow.h:76
unsigned int GetWidth() const override
Getter for the Mac Window width.
Definition MacWindow.h:61
virtual bool OnResize(WindowResizeEvent &event) override
MacOS implementation of WindowResize event.
Definition MacWindow.cpp:38
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
The "tangible" properties of a window.
Definition Window.h:25