KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
Karma::Window Class Referenceabstract

The abstract base class of Karma's window (for platform specific purposes) More...

#include <Window.h>

Inheritance diagram for Karma::Window:

Public Types

using EventCallbackFn = std::function<void(Event&)>
 A data structure for use in Window::SetEventCallback.
 

Public Member Functions

virtual ~Window ()
 A virtual destructor for the Window.
 
virtual void OnUpdate ()=0
 Pure virtual function for calls in each loop.
 
virtual bool OnResize (WindowResizeEvent &event)=0
 Pure virtual function called when Window resize happens.
 
virtual unsigned int GetWidth () const =0
 A pure virtual getter for Width of the Window.
 
virtual unsigned int GetHeight () const =0
 Pure virtual getter for the Height of the Window.
 
virtual void SetEventCallback (const EventCallbackFn &callback)=0
 Setting a function, Application::OnEvent, to be called when a Karma Event happens, detected by GLFW Window like so.
 
virtual void SetVSync (bool enabled)=0
 Pure virtual function for VSync.
 
virtual bool IsVSync () const =0
 Pure virtual function for VSync status.
 
virtual void * GetNativeWindow () const =0
 Pure virtual getter for the native (GLFW) Window handle.
 

Static Public Member Functions

static WindowCreate (const WindowProps &props=WindowProps())
 Platform based, implemented function for Window creation.
 

Detailed Description

The abstract base class of Karma's window (for platform specific purposes)

Member Typedef Documentation

◆ EventCallbackFn

using Karma::Window::EventCallbackFn = std::function<void(Event&)>

A data structure for use in Window::SetEventCallback.

For instance KR_BIND_EVENT_FN(Application::OnEvent) is a EventCallbackFn.

Since
Karma 1.0.0

Constructor & Destructor Documentation

◆ ~Window()

virtual Karma::Window::~Window ( )
inlinevirtual

A virtual destructor for the Window.

Since
Karma 1.0.0

Member Function Documentation

◆ Create()

static Window * Karma::Window::Create ( const WindowProps & props = WindowProps())
static

Platform based, implemented function for Window creation.

Since
Karma 1.0.0

◆ GetHeight()

virtual unsigned int Karma::Window::GetHeight ( ) const
pure virtual

Pure virtual getter for the Height of the Window.

Since
Karma 1.0.0

Implemented in Karma::LinuxWindow, Karma::MacWindow, and Karma::WindowsWindow.

◆ GetNativeWindow()

virtual void * Karma::Window::GetNativeWindow ( ) const
pure virtual

Pure virtual getter for the native (GLFW) Window handle.

Since
Karma 1.0.0

Implemented in Karma::LinuxWindow, Karma::MacWindow, and Karma::WindowsWindow.

◆ GetWidth()

virtual unsigned int Karma::Window::GetWidth ( ) const
pure virtual

A pure virtual getter for Width of the Window.

Since
Karma 1.0.0

Implemented in Karma::LinuxWindow, Karma::MacWindow, and Karma::WindowsWindow.

◆ IsVSync()

virtual bool Karma::Window::IsVSync ( ) const
pure virtual

Pure virtual function for VSync status.

Since
Karma 1.0.0

Implemented in Karma::LinuxWindow, Karma::MacWindow, and Karma::WindowsWindow.

◆ OnResize()

virtual bool Karma::Window::OnResize ( WindowResizeEvent & event)
pure virtual

Pure virtual function called when Window resize happens.

See also
Application::OnWindowResize
Since
Karma 1.0.0

Implemented in Karma::LinuxWindow, Karma::MacWindow, and Karma::WindowsWindow.

◆ OnUpdate()

virtual void Karma::Window::OnUpdate ( )
pure virtual

Pure virtual function for calls in each loop.

See also
Application::Run()
Since
Karma 1.0.0

Implemented in Karma::LinuxWindow, Karma::MacWindow, and Karma::WindowsWindow.

◆ SetEventCallback()

virtual void Karma::Window::SetEventCallback ( const EventCallbackFn & callback)
pure virtual

Setting a function, Application::OnEvent, to be called when a Karma Event happens, detected by GLFW Window like so.

SetGLFWCallbacks(GLFWwindow* glfwWindow)
{
//
// @param GLFWwindow the window whose sizecallback is desired
// @param GLFWwindowsizefun the function pointer that gets called whenever
// window size changes. The Cherno uses something what is
// known as lambda. I don't quite understand the relation
// between function pointer and lambda.
//
glfwSetWindowSizeCallback(glfwWindow, [](GLFWwindow* window, int width, int height)
{
WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window);
data.Width = width;
data.Height = height;
WindowResizeEvent event(width, height);
data.EventCallback(event);// <-- This is translated to Application::OnEvent(event)
});
}
Event triggered when Window is resized.
Definition ApplicationEvent.h:22

Setting the listener basically.

Parameters
callbackThe function to be called
See also
Application::Application()
Since
Karma 1.0.0

Implemented in Karma::LinuxWindow, Karma::MacWindow, and Karma::WindowsWindow.

◆ SetVSync()

virtual void Karma::Window::SetVSync ( bool enabled)
pure virtual

Pure virtual function for VSync.

Since
Karma 1.0.0

Implemented in Karma::LinuxWindow, Karma::MacWindow, and Karma::WindowsWindow.


The documentation for this class was generated from the following file: