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 "Karma/Core.h"
13#include "Karma/Events/Event.h"
14
16
17namespace Karma
18{
23 {
29 std::string Title;
35 unsigned int Width;
41 unsigned int Height;
42
48 WindowProps(const std::string& title = "Karma Engine",
49 unsigned int width = 1280,
50 unsigned int height = 720) : Title(title),
51 Width(width), Height(height)
52 {
53 }
54 };
55
56 // Interface representing desktop based window
61 {
62 public:
70 using EventCallbackFn = std::function<void(Event&)>;
71
77 virtual ~Window()
78 {
79 }
80
87 virtual void OnUpdate() = 0;
88
95 virtual bool OnResize(WindowResizeEvent& event) = 0;
96
102 virtual unsigned int GetWidth() const = 0;
103
109 virtual unsigned int GetHeight() const = 0;
110
142 virtual void SetEventCallback(const EventCallbackFn& callback) = 0;
143
149 virtual void SetVSync(bool enabled) = 0;
150
156 virtual bool IsVSync() const = 0;
157
163 virtual void* GetNativeWindow() const = 0;
164
170 static Window* Create(const WindowProps& props = WindowProps());
171 };
172}
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:88
The abstract base class of Karma's window (for platform specific purposes).
Definition Window.h:61
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:70
virtual void OnUpdate()=0
Pure virtual function for calls in each loop.
virtual ~Window()
A virtual destructor for the Window.
Definition Window.h:77
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:20
The "tangible" properties of a window.
Definition Window.h:23
unsigned int Width
The width of the window.
Definition Window.h:35
std::string Title
The title of the window.
Definition Window.h:29
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:48
unsigned int Height
The height of the window.
Definition Window.h:41