KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
Window.h
Go to the documentation of this file.
1
10#pragma once
11
12#include "krpch.h"
13
14#include "Karma/Core.h"
15#include "Karma/Events/Event.h"
16
18
19namespace Karma
20{
25 {
31 std::string Title;
37 unsigned int Width;
43 unsigned int Height;
44
50 WindowProps(const std::string& title = "Karma Engine",
51 unsigned int width = 1280,
52 unsigned int height = 720) : Title(title),
53 Width(width), Height(height)
54 {
55 }
56 };
57
58 // Interface representing desktop based window
63 {
64 public:
72 using EventCallbackFn = std::function<void(Event&)>;
73
79 virtual ~Window()
80 {
81 }
82
89 virtual void OnUpdate() = 0;
90
97 virtual bool OnResize(WindowResizeEvent& event) = 0;
98
104 virtual unsigned int GetWidth() const = 0;
105
111 virtual unsigned int GetHeight() const = 0;
112
144 virtual void SetEventCallback(const EventCallbackFn& callback) = 0;
145
151 virtual void SetVSync(bool enabled) = 0;
152
158 virtual bool IsVSync() const = 0;
159
165 virtual void* GetNativeWindow() const = 0;
166
172 static Window* Create(const WindowProps& props = WindowProps());
173 };
174}
This file contains the classes concerned with activity of Window.
This file contains the macros for Karma's classes' general purpose use, including assertions and stor...
#define KARMA_API
Defining Karma's API macro for storage class information.
Definition Core.h:41
This file contains the base class Event for Karma's events.
The base class of all the events for Karma.
Definition Event.h:90
The abstract base class of Karma's window (for platform specific purposes)
Definition Window.h:63
virtual void * GetNativeWindow() const =0
Pure virtual getter for the native (GLFW) Window handle.
static Window * Create(const WindowProps &props=WindowProps())
Platform based, implemented function for Window creation.
virtual void SetEventCallback(const EventCallbackFn &callback)=0
Setting a function, Application::OnEvent, to be called when a Karma Event happens,...
virtual bool OnResize(WindowResizeEvent &event)=0
Pure virtual function called when Window resize happens.
std::function< void(Event &)> EventCallbackFn
A data structure for use in Window::SetEventCallback.
Definition Window.h:72
virtual void OnUpdate()=0
Pure virtual function for calls in each loop.
virtual ~Window()
A virtual destructor for the Window.
Definition Window.h:79
virtual void SetVSync(bool enabled)=0
Pure virtual function for VSync.
virtual unsigned int GetWidth() const =0
A pure virtual getter for Width of the Window.
virtual bool IsVSync() const =0
Pure virtual function for VSync status.
virtual unsigned int GetHeight() const =0
Pure virtual getter for the Height of the Window.
Event triggered when Window is resized.
Definition ApplicationEvent.h:22
The "tangible" properties of a window.
Definition Window.h:25
unsigned int Width
The width of the window.
Definition Window.h:37
std::string Title
The title of the window.
Definition Window.h:31
WindowProps(const std::string &title="Karma Engine", unsigned int width=1280, unsigned int height=720)
A constructor for pleasent dimensions of the window.
Definition Window.h:50
unsigned int Height
The height of the window.
Definition Window.h:43