KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
WindowsWindow.h
1#pragma once
2
3#include "Karma/Window.h"
4
5struct GLFWwindow;
6
7namespace Karma
8{
9 class GraphicsContext;
10
11 class WindowsWindow : public Window
12 {
13 public:
14 WindowsWindow(const WindowProps& props);
15 virtual ~WindowsWindow();
16
17 virtual void OnUpdate() override;
18 virtual bool OnResize(WindowResizeEvent& event) override;
19
20 inline unsigned int GetWidth() const override { return m_Data.Width; }
21 inline unsigned int GetHeight() const override { return m_Data.Height; }
22
23 inline void SetEventCallback(const EventCallbackFn& callback) override
24 {
25 m_Data.EventCallback = callback;
26 }
27 inline virtual void* GetNativeWindow() const override { return m_Window; }
28
29 void SetVSync(bool enabled) override;
30 bool IsVSync() const override;
31
32 GLFWwindow* GetHandle() const { return m_Window; }
33
34 private:
35 void Init(const WindowProps& props);
36
37 void SetGLFWCallbacks(GLFWwindow* glfwWindow);
38 void ShutDown();
39
40 GLFWwindow* m_Window;
41 GraphicsContext* m_Context;
42
43 struct WindowData
44 {
45 std::string Title;
46 unsigned int Width, Height;
47 bool VSync;
48
49 EventCallbackFn EventCallback;
50 };
51
52 WindowData m_Data;
53 };
54}
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
Pure virtual function for VSync.
Definition WindowsWindow.cpp:218
virtual bool OnResize(WindowResizeEvent &event) override
Pure virtual function called when Window resize happens.
Definition WindowsWindow.cpp:96
void SetEventCallback(const EventCallbackFn &callback) override
Setting a function, Application::OnEvent, to be called when a Karma Event happens,...
Definition WindowsWindow.h:23
bool IsVSync() const override
Pure virtual function for VSync status.
Definition WindowsWindow.cpp:250
virtual void OnUpdate() override
Pure virtual function for calls in each loop.
Definition WindowsWindow.cpp:212
unsigned int GetHeight() const override
Pure virtual getter for the Height of the Window.
Definition WindowsWindow.h:21
unsigned int GetWidth() const override
A pure virtual getter for Width of the Window.
Definition WindowsWindow.h:20
virtual void * GetNativeWindow() const override
Pure virtual getter for the native (GLFW) Window handle.
Definition WindowsWindow.h:27
The "tangible" properties of a window.
Definition Window.h:25