This commit is contained in:
2024-06-17 22:15:20 -04:00
parent 3adef96da7
commit 56fdc3d90b
3 changed files with 106 additions and 527 deletions

View File

@@ -12,9 +12,8 @@
#include <X11/X.h>
#endif
#include "rewindow/data/X11Scancodes.h"
#include "rewindow/data/WindowsScancodes.h"
#include <rewindow/data/X11Scancodes.h>
#include <rewindow/data/WindowsScancodes.h>
//#include "jlog/jlog.hpp"
using J3ML::LinearAlgebra::Vector2;
@@ -22,7 +21,9 @@ using J3ML::LinearAlgebra::Vector2;
class Key
{
private:
inline static std::vector<Key> keyboard;
//clion on Linux falsely marks this as being wrong.
inline static std::vector<Key> keyboard{};
public:
static std::vector<Key> GetKeyboard();
Key();

View File

@@ -32,96 +32,85 @@ Atom windowTypeUtilityAtom;
XSizeHints hints;
GLXContext glContext;
namespace ReWindow {
using namespace ReWindow;
RWindow::RWindow() {
title = "ReWindow Application";
width = 640;
height = 480;
//RWindow::singleton = this;
RWindow::RWindow() {
title = "ReWindow Application";
width = 640;
height = 480;
//RWindow::singleton = this;
}
RWindow::RWindow(const std::string& title, int width, int height) : flags(false,false,false,false) {
this->title = title;
this->width = width;
this->height = height;
//RWindow::singleton = this;
}
RWindow::RWindow(const std::string& title, int width, int height, RenderingAPI renderer) :
title(title), width(width), height(height), renderer(renderer) {}
void RWindow::raise() const { XRaiseWindow(display, window); }
void RWindow::lower() const { XLowerWindow(display, window); }
void RWindow::destroyWindow() {
XDestroySubwindows(display, window);
XAutoRepeatOn(display);
XDestroyWindow(display, window);
delete this;
}
void RWindow::refresh() {
// TODO: Implement refresh time keeping
OnRefresh(0.f);
// TODO: Check if mouse coords have changed, only then fire OnMouseMove event
Vector2 mouse_coords = getCursorPos();
auto eventData = MouseMoveEvent(mouse_coords);
OnMouseMove(eventData);
std::this_thread::sleep_for(1ms);
}
bool RWindow::getFlag(RWindowFlags flag) const {return flags[(int)flag];}
void RWindow::setFlag(RWindowFlags flag, bool state) {
XGetWindowAttributes(display,window,&windowAttributes);
flags[(int) flag] = state;
//Once you've done this you cannot make it resizable again.
if (flag == RWindowFlags::RESIZABLE && !state) {
hints.flags = PMinSize | PMaxSize;
hints.min_width = hints.max_width = windowAttributes.width;
hints.min_height = hints.max_height = windowAttributes.height;
XSetWMNormalHints(display, window, &hints);
}
}
RWindow::RWindow(const std::string& title, int width, int height) : flags(false,false,false,false) {
this->title = title;
this->width = width;
this->height = height;
void RWindow::pollEvents() {
while(XPending(display)) {
XNextEvent(display, &xev);
//RWindow::singleton = this;
}
RWindow::RWindow(const std::string& title, int width, int height, RenderingAPI renderer) :
title(title), width(width), height(height), renderer(renderer)
{
//RWindow::singleton = this;
}
void RWindow::raise() const { XRaiseWindow(display, window); }
void RWindow::lower() const { XLowerWindow(display, window); }
if (xev.type == ClientMessage)
if (xev.xclient.message_type == XInternAtom(display, "WM_PROTOCOLS", False) && static_cast<Atom>(xev.xclient.data.l[0]) == wmDeleteWindow) {
destroyWindow();
exit(0);
}
void RWindow::destroyWindow() {
XDestroySubwindows(display, window);
XAutoRepeatOn(display);
XDestroyWindow(display, window);
delete this;
}
void RWindow::refresh() {
// TODO: Implement refresh time keeping
OnRefresh(0.f);
// TODO: Check if mouse coords have changed, only then fire OnMouseMove event
Vector2 mouse_coords = getCursorPos();
auto eventData = MouseMoveEvent(mouse_coords);
OnMouseMove(eventData);
std::this_thread::sleep_for(1ms);
}
bool RWindow::getFlag(RWindowFlags flag) const
{
if (flags[(int)flag])
return true;
return false;
}
void RWindow::setFlag(RWindowFlags flag, bool state) {
XGetWindowAttributes(display,window,&windowAttributes);
flags[(int) flag] = state;
//Once you've done this you cannot make it resizable again.
if (flag == RWindowFlags::RESIZABLE && !state) {
hints.flags = PMinSize | PMaxSize;
hints.min_width = hints.max_width = windowAttributes.width;
hints.min_height = hints.max_height = windowAttributes.height;
XSetWMNormalHints(display, window, &hints);
if (xev.type == FocusIn) {
XAutoRepeatOff(display);
//focusGained.Invoke();
RWindowEvent event {};
OnFocusGain(event);
setFlag(RWindowFlags::IN_FOCUS, true);
}
}
void RWindow::pollEvents() {
while(XPending(display)) {
XNextEvent(display, &xev);
if (xev.type == ClientMessage) {
if (xev.xclient.message_type == XInternAtom(display, "WM_PROTOCOLS", False) &&
static_cast<Atom>(xev.xclient.data.l[0]) == wmDeleteWindow) {
destroyWindow();
exit(0);
}
}
if (xev.type == FocusIn) {
XAutoRepeatOff(display);
//focusGained.Invoke();
RWindowEvent event {};
OnFocusGain(event);
setFlag(RWindowFlags::IN_FOCUS, true);
}
if (xev.type == FocusOut) {
if (xev.type == FocusOut) {
XAutoRepeatOn(display);
//focusLost.Invoke();
RWindowEvent event {};
@@ -154,8 +143,7 @@ namespace ReWindow {
OnMouseButtonUp(eventData);
}
if (xev.type == ButtonPress)
{
if (xev.type == ButtonPress) {
MouseButton button = GetMouseButtonFromXButton(xev.xbutton.button);
auto eventData = MouseButtonDownEvent(button);
eventData.Button = button;
@@ -164,19 +152,12 @@ namespace ReWindow {
OnMouseButtonDown(eventData);
}
if (xev.type == Expose) {
}
if (xev.type == Expose) {}
// NOTE: This event is functionally useless, as it only informs of the very beginning and end of a mouse movement.
if (xev.type == MotionNotify)
{
//auto eventData = MouseMoveEvent(xev.xmotion.x, xev.xmotion.y);
if (xev.type == MotionNotify) {}
//OnMouseMove(eventData);
}
if (xev.type == ResizeRequest)
{
if (xev.type == ResizeRequest) {
auto eventData = WindowResizeRequestEvent();
lastKnownWindowSize = eventData.Size;
eventData.Size = {(float)xev.xresizerequest.width, (float)xev.xresizerequest.height};
@@ -189,17 +170,15 @@ namespace ReWindow {
}
// Might make the window go off the screen on some window managers.
void RWindow::setSize(int newWidth, int newHeight)
{
if (!getFlag(RWindowFlags::RESIZABLE))
return;
void RWindow::setSize(int newWidth, int newHeight) {
if (!getFlag(RWindowFlags::RESIZABLE)) return;
this->width = newWidth;
this->height = newHeight;
XResizeWindow(display, window, width, height);
}
void RWindow::setSize(const Vector2& size)
{
void RWindow::setSize(const Vector2& size) {
this->width = size.x;
this->height = size.y;
this->setSize(size.x, size.y);
@@ -217,8 +196,7 @@ namespace ReWindow {
unsigned m;
bool mouseAvailable = XQueryPointer(display, window, &root_return, &child_return, &root_x_ret, &root_y_ret, &win_x_ret, &win_y_ret, &mask_return);
if (mouseAvailable)
{
if (mouseAvailable) {
// TODO: process retrieved mouse coordinates
// TODO: normalize coordinates from displaySpace to windowSpace
// TODO: fire mouse movement event
@@ -234,28 +212,22 @@ namespace ReWindow {
}
// TODO: implement integer vector2/3 types
Vector2 RWindow::getSize() const
{
Vector2 RWindow::getSize() const {
XGetWindowAttributes(display,window,&windowAttributes);
return {(float)windowAttributes.width, (float)windowAttributes.height};
}
// TODO: implement integer vector2/3 types
Vector2 RWindow::getPos() const
{
Vector2 RWindow::getPos() const {
XGetWindowAttributes(display,window,&windowAttributes);
return {(float)windowAttributes.x, (float)windowAttributes.y};
}
void RWindow::setPos(int x, int y)
{
void RWindow::setPos(int x, int y) {
XMoveWindow(display, window, x, y);
}
void RWindow::setPos(const Vector2& pos)
{
void RWindow::setPos(const Vector2& pos) {
this->setPos(pos.x, pos.y);
}
@@ -290,11 +262,10 @@ namespace ReWindow {
fullscreenmode = true;
XEvent xev;
Atom wm_state = XInternAtom (display, "_NET_WM_STATE", true );
Atom wm_fullscreen = XInternAtom (display, "_NET_WM_STATE_FULLSCREEN", true );
Atom wm_state = XInternAtom(display, "_NET_WM_STATE", true);
Atom wm_fullscreen = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", true);
XChangeProperty(display, window, wm_state, XA_ATOM, 32,
PropModeReplace, (unsigned char *)&wm_fullscreen, 1);
XChangeProperty(display, window, wm_state, XA_ATOM, 32, PropModeReplace, (unsigned char *)&wm_fullscreen, 1);
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
xev.xclient.window = window;
@@ -303,8 +274,7 @@ namespace ReWindow {
xev.xclient.data.l[0] = 1; // _NET_WM_STATE_ADD
xev.xclient.data.l[1] = fullscreenmode;
xev.xclient.data.l[2] = 0;
XSendEvent(display, DefaultRootWindow(display), False,
SubstructureNotifyMask | SubstructureRedirectMask, &xev);
XSendEvent(display, DefaultRootWindow(display), False, SubstructureNotifyMask | SubstructureRedirectMask, &xev);
}
void RWindow::restoreFromFullscreen() {
@@ -320,8 +290,7 @@ namespace ReWindow {
xev.xclient.data.l[0] = 0; // _NET_WM_STATE_REMOVE
xev.xclient.data.l[1] = fullscreenmode;
xev.xclient.data.l[2] = 0;
XSendEvent(display, DefaultRootWindow(display), False,
SubstructureNotifyMask | SubstructureRedirectMask, &xev);
XSendEvent(display, DefaultRootWindow(display), False, SubstructureNotifyMask | SubstructureRedirectMask, &xev);
}
void RWindow::setVsyncEnabled(bool b) {
@@ -346,15 +315,13 @@ namespace ReWindow {
xSetWindowAttributes.override_redirect = True;
xSetWindowAttributes.event_mask = ExposureMask;
//setVsyncEnabled(vsync);
if (renderer == RenderingAPI::OPENGL)
{
if (renderer == RenderingAPI::OPENGL) {
GLint glAttributes[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
visual = glXChooseVisual(display, defaultScreen, glAttributes);
glContext = glXCreateContext(display, visual, nullptr, GL_TRUE);
}
xSetWindowAttributes.colormap = XCreateColormap(display, RootWindow(display, defaultScreen), visual->visual,
AllocNone);
xSetWindowAttributes.colormap = XCreateColormap(display, RootWindow(display, defaultScreen), visual->visual, AllocNone);
window = XCreateWindow(display, RootWindow(display, defaultScreen), 0, 0, width, height, 0, visual->depth,
InputOutput, visual->visual, CWBackPixel | CWColormap | CWBorderPixel | NoEventMask,
@@ -374,14 +341,9 @@ namespace ReWindow {
XStoreName(display, window, title.c_str());
wmDeleteWindow = XInternAtom(display, "WM_DELETE_WINDOW", False);
XSetWMProtocols(display, window, &wmDeleteWindow, 1);
if (renderer == RenderingAPI::OPENGL)
{
if (renderer == RenderingAPI::OPENGL) {
glXMakeCurrent(display, window, glContext);
}
//setVsyncEnabled(vsync);
open = true;
}
@@ -401,16 +363,13 @@ namespace ReWindow {
}
// TODO: Implement MouseButton map
bool RWindow::isMouseButtonDown(MouseButton button) const
{
bool RWindow::isMouseButtonDown(MouseButton button) const {
return false;
}
void RWindow::setRenderer(RenderingAPI api) {
renderer = api;
}
// TODO: Implement ControllerButton map
}

View File

@@ -1,391 +1,10 @@
#include <rewindow/types/window.h>
#include <rewindow/types/cursors.h>
#include <GL/gl.h>
typedef BOOL (APIENTRY* PFNWGLSWAPINTERVALEXTPROC)(int interval);
using namespace ReWindow;
HINSTANCE hInstance = GetModuleHandle(NULL);
LRESULT CALLBACK ReWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
ReWindow::RWindow* subject = (ReWindow::RWindow*) GetWindowLongPtrA (hwnd, GWLP_USERDATA);
switch (uMsg) {
case WM_DESTROY:
PostQuitMessage (0);
break;
case WM_SETFOCUS: {
ReWindow::RWindowEvent event {};
subject->OnFocusGain (event);
subject->setFlag (RWindowFlags::IN_FOCUS, true);
break;
}
case WM_KILLFOCUS: {
ReWindow::RWindowEvent event {};
subject->OnFocusLost (event);
subject->setFlag (RWindowFlags::IN_FOCUS, false);
break;
}
case WM_KEYDOWN: {
auto key = GetKeyFromWindowsScancode ((WindowsScancode) wParam);
subject->pressKey (key);
break;
}
case WM_KEYUP: {
auto key = GetKeyFromWindowsScancode ((WindowsScancode) wParam);
subject->liftKey (key);
break;
}
case WM_LBUTTONDOWN: {
auto event = ReWindow::WindowEvents::MouseButtonDownEvent(MouseButtons::Left);
event.Button = MouseButtons::Left;
subject->OnMouseButtonDown(event);
break;
}
case WM_RBUTTONDOWN: {
auto event = ReWindow::WindowEvents::MouseButtonDownEvent(MouseButtons::Right);
event.Button = MouseButtons::Right;
subject->OnMouseButtonDown(event);
break;
}
case WM_MBUTTONDOWN: {
auto event = ReWindow::WindowEvents::MouseButtonDownEvent(MouseButtons::Middle);
event.Button = MouseButtons::Middle;
subject->OnMouseButtonDown(event);
break;
}
case WM_LBUTTONUP: {
auto event = ReWindow::WindowEvents::MouseButtonUpEvent();
event.Button = MouseButtons::Left;
subject->OnMouseButtonUp(event);
break;
}
case WM_RBUTTONUP: {
auto event = ReWindow::WindowEvents::MouseButtonUpEvent();
event.Button = MouseButtons::Right;
subject->OnMouseButtonUp(event);
break;
}
case WM_MBUTTONUP: {
auto event = ReWindow::WindowEvents::MouseButtonUpEvent();
event.Button = MouseButtons::Middle;
subject->OnMouseButtonUp(event);
break;
}
case WM_MOUSEMOVE: {
auto event = ReWindow::WindowEvents::MouseMoveEvent (GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam));
subject->OnMouseMove(event);
break;
}
case WM_SHOWWINDOW:
if (wParam) {
// as for Expose event in linux
}
break;
case WM_WINDOWPOSCHANGED: {
WINDOWPOS *pos = (WINDOWPOS *) lParam;
subject->setRect (pos->x, pos->y, pos->cx, pos->cy);
auto event = ReWindow::WindowEvents::WindowResizeRequestEvent();
event.Size = {(float) pos->cx, (float) pos->cy};
subject->OnResizeRequest (event);
break;
}
default:
return DefWindowProcA (hwnd, uMsg, wParam, lParam);
}
return TRUE;
}
static HWND hwnd = NULL;
static HDC hdc = NULL;
static ATOM reClass = 0;
static HGLRC glrc = NULL;
static DEVMODEA mode;
void registerClass () {
if (!reClass) {
HINSTANCE module = GetModuleHandleA (NULL);
WNDCLASSA rewc = {CS_HREDRAW | CS_VREDRAW,
ReWindowProc, 0, 0, module, NULL, LoadCursor (NULL, IDC_ARROW),
(HBRUSH) GetStockObject (BLACK_BRUSH), NULL, "ReWindowClass"
};
reClass = RegisterClassA (&rewc);
}
}
ReWindow::RWindow::RWindow() {
registerClass ();
for (int num = 0; num < (int) RWindowFlags::MAX_FLAG; ++num) {
flags[num] = false;
}
hwnd = CreateWindowA ("ReWindowClass", "ReWindow", WS_TILEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, NULL, 0);
SetWindowLongPtrA (hwnd, GWLP_USERDATA, (LONG_PTR) this);
}
ReWindow::RWindow::RWindow (const std::string& title, int width, int height) {
registerClass ();
for (int num = 0; num < (int) RWindowFlags::MAX_FLAG; ++num) {
flags[num] = false;
}
hwnd = CreateWindowA ("ReWindowClass", title.c_str (), WS_TILEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, width, height,
NULL, NULL, NULL, 0);
SetWindowLongPtrA (hwnd, GWLP_USERDATA, (LONG_PTR) this);
}
void ReWindow::RWindow::raise() const {
SetForegroundWindow (hwnd);
SetActiveWindow (hwnd);
SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
ShowWindow (hwnd, SW_SHOW);
// Redraw to prevent the window blank
RedrawWindow (hwnd, NULL, 0, RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
}
void ReWindow::RWindow::lower() const {
ShowWindow (hwnd, SW_MINIMIZE);
}
void ReWindow::RWindow::destroyWindow() {
if (hwnd) {
if (hdc) {
if (glrc) {
wglMakeCurrent (NULL, NULL);
wglDeleteContext (glrc);
}
ReleaseDC (hwnd, hdc);
}
DestroyWindow (hwnd);
}
delete this;
}
void ReWindow::RWindow::refresh() {
// TODO: Implement refresh time keeping
OnRefresh (0.f);
// TODO: Check if mouse coords have changed, only then fire OnMouseMove event
Vector2 mouse_coords = getCursorPos();
auto eventData = MouseMoveEvent(mouse_coords);
OnMouseMove(eventData);
std::this_thread::sleep_for(1ms);
}
bool ReWindow::RWindow::getFlag (RWindowFlags flag) const {
return (flags[(int) flag]);
}
void ReWindow::RWindow::setFlag (RWindowFlags flag, bool state) {
DWORD style = GetWindowLongA (hwnd, GWL_STYLE);
flags[(int) flag] = state;
if (flag == RWindowFlags::RESIZABLE) {
if (style & WS_THICKFRAME) {
if (!state) {
style &= ~WS_THICKFRAME;
SetWindowLongA (hwnd, GWL_STYLE, style);
}
}
else {
if (state) {
style |= WS_THICKFRAME;
SetWindowLongA (hwnd, GWL_STYLE, style);
}
}
}
}
void ReWindow::RWindow::pollEvents() {
MSG msg;
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT) {
setFlag (RWindowFlags::QUIT, true);
}
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
// Might make the window go off the screen on some window managers.
void ReWindow::RWindow::setSize (int w, int h) {
if (!getFlag (RWindowFlags::RESIZABLE)) return;
MoveWindow (hwnd, x, y, w, h, TRUE);
}
void ReWindow::RWindow::setSize(const Vector2& size) {
if (!getFlag (RWindowFlags::RESIZABLE)) return;
MoveWindow (hwnd, x, y, size.x, size.y, TRUE);
}
Vector2 ReWindow::RWindow::getCursorPos() const {
POINT pos;
GetCursorPos (&pos);
// TODO: normalize coordinates from displaySpace to windowSpace
// TODO: fire mouse movement event
//std::cout << win_x_ret << ", " << win_y_ret << std::endl;
// TODO: Compensate for height of window TitleBar + window border width
Vector2 mouse_coords_raw = {(float) pos.x, (float) pos.y};
auto window_pos = getPos();
return mouse_coords_raw - window_pos;
}
// TODO: implement integer vector2/3 types
Vector2 ReWindow::RWindow::getSize() const {
return {(float) width, (float) height};
}
// TODO: implement integer vector2/3 types
Vector2 ReWindow::RWindow::getPos() const {
return Vector2 ((float) x, (float) y);
}
void ReWindow::RWindow::setPos(int nx, int ny) {
MoveWindow (hwnd, nx, ny, width, height, TRUE);
}
void ReWindow::RWindow::setPos(const Vector2& pos) {
MoveWindow (hwnd, pos.x, pos.y, width, height, TRUE);
}
void ReWindow::RWindow::glSwapBuffers() {
SwapBuffers (hdc);
}
bool ReWindow::RWindow::isResizable() const {
return this->getFlag (RWindowFlags::RESIZABLE);
}
bool ReWindow::RWindow::isAlive() const {
return !getFlag (RWindowFlags::QUIT);
}
void ReWindow::RWindow::setResizable(bool resizable) {
this->resizable = resizable;
this->setFlag(RWindowFlags::RESIZABLE, resizable);
}
void ReWindow::RWindow::setFullscreen(bool fs) {
if (fs) {
fullscreen();
}
else restoreFromFullscreen();
}
void ReWindow::RWindow::fullscreen() {
DEVMODEA screen = {sizeof (DEVMODEA)};
screen.dmBitsPerPel = 32;
screen.dmPelsWidth = width;
screen.dmPelsHeight = height;
screen.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
if (ChangeDisplaySettingsA (&screen, 0) == DISP_CHANGE_SUCCESSFUL) {
fullscreenmode = true;
}
}
void ReWindow::RWindow::restoreFromFullscreen() {
if (ChangeDisplaySettingsA (&mode, 0) == DISP_CHANGE_SUCCESSFUL) {
fullscreenmode = false;
}
}
void ReWindow::RWindow::setVsyncEnabled (bool b) {
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
if (wglSwapIntervalEXT != nullptr)
wglSwapIntervalEXT(b);
}
bool ReWindow::RWindow::isFullscreen() const {
return fullscreenmode;
}
void ReWindow::RWindow::setCursorStyle (CursorStyle style) const {
int idcs[] ={32512, 32513, 32514, 325123, 32649, 32650};
SetClassLongPtr (hwnd, GCLP_HCURSOR, (LONG_PTR) LoadCursor (NULL, MAKEINTRESOURCE (idcs[style.WindowsCursor])));
}
void ReWindow::RWindow::Open() {
if (hwnd) {
hdc = GetDC (hwnd);
PIXELFORMATDESCRIPTOR pfd = {
sizeof (PIXELFORMATDESCRIPTOR),
1, PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW,
PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 32,
0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0
};
int ipf = ChoosePixelFormat (hdc, &pfd);
if (ipf) {
SetPixelFormat (hdc, ipf, &pfd);
glrc = wglCreateContext (hdc);
if (glrc) {
wglMakeCurrent (hdc, glrc);
EnumDisplaySettingsA (NULL, ENUM_CURRENT_SETTINGS, &mode);
open = true;
raise();
}
}
}
}
void ReWindow::RWindow::setTitle (const std::string &title) {
this->title = title;
SetWindowTextA (hwnd, title.c_str ());
}
std::string ReWindow::RWindow::getTitle () const {
return this->title;
}
bool ReWindow::RWindow::isKeyDown (Key key) const {
auto find = currentKeyboard.PressedKeys.find (key);
if (find != currentKeyboard.PressedKeys.end ()) {
return currentKeyboard.PressedKeys.at (key);
}
return false;
}
// TODO: Implement MouseButton map
bool ReWindow::RWindow::isMouseButtonDown(MouseButton button) const {
return false;
}
void ReWindow::RWindow::setRenderer (RenderingAPI api) {
renderer = api;
}
RWindow::RWindow() {
title = "ReWindow Application";
width = 640;
height = 480;
}