KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
LinuxWindow.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 LinuxWindow : public Window
24 {
25 public:
32 LinuxWindow(const WindowProps& props);
33
39 virtual ~LinuxWindow();
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:
103
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
155 bool VSync;
156
157 EventCallbackFn EventCallback;
158 };
159
160 WindowData m_Data;
161 };
162}
This file contains the Window class.
An abstract class for creating a context for Renderer and provide graphics API.
Definition GraphicsContext.h:20
void SetVSync(bool enabled) override
Based on API chosen, the Linux based VSync toggle.
Definition LinuxWindow.cpp:232
virtual void * GetNativeWindow() const override
Getter for the Linux Window handle.
Definition LinuxWindow.h:86
LinuxWindow(const WindowProps &props)
A constructor to initialize Linux Window with appropriate properties.
Definition LinuxWindow.cpp:27
unsigned int GetHeight() const override
Getter for Linux Window height.
Definition LinuxWindow.h:68
virtual bool OnResize(WindowResizeEvent &event) override
Linux implementation of WindowResize event.
Definition LinuxWindow.cpp:103
virtual ~LinuxWindow()
A destructor to clean up the mess and Linux window relevant resources.
Definition LinuxWindow.cpp:32
bool IsVSync() const override
Query for Linux VSync status.
Definition LinuxWindow.cpp:263
void SetEventCallback(const EventCallbackFn &callback) override
Sets a listner for Linux Window.
Definition LinuxWindow.h:76
void OnUpdate() override
Called each loop for input polling and OpenGL swapbuffers.
Definition LinuxWindow.cpp:226
unsigned int GetWidth() const override
Getter for the Linux Window width.
Definition LinuxWindow.h:61
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