Compare commits
22 Commits
Prerelease
...
ReWindow-R
Author | SHA1 | Date | |
---|---|---|---|
4f1140b217 | |||
dd4b7b7d29 | |||
a68ced6874 | |||
d5a08ecea2 | |||
df32610007 | |||
921f2118e8 | |||
780fd8308a | |||
20b6f1041f | |||
94960e0433 | |||
2a63ad8054 | |||
cbfce17d44 | |||
1f17244662 | |||
5ff4fb2a73 | |||
30f20394c8 | |||
4264f008c2 | |||
4ab07d97e3 | |||
cb5222e476 | |||
e0c001b1f1 | |||
fdde8486f7 | |||
51e3787d38 | |||
66c3ebb9da | |||
2a2293842a |
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <J3ML/J3ML.hpp>
|
||||
#include "J3ML/J3ML.hpp"
|
||||
|
||||
namespace ReWindow {
|
||||
class FullscreenGraphicsMode;
|
@@ -11,6 +11,11 @@
|
||||
#pragma once
|
||||
|
||||
namespace ReWindow {
|
||||
class GamepadState {
|
||||
public:
|
||||
std::map<GamepadButton, bool> PressedButtons;
|
||||
};
|
||||
|
||||
class Gamepad;
|
||||
class Xbox360Gamepad;
|
||||
class XboxOneGamepad;
|
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include "J3ML/LinearAlgebra.hpp"
|
||||
namespace ReWindow {
|
||||
class GamepadButton;
|
||||
class GamepadTrigger;
|
@@ -6,9 +6,9 @@
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <rewindow/data/X11Scancodes.h>
|
||||
#include <rewindow/data/WindowsScancodes.h>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include "rewindow/X11Scancodes.hpp"
|
||||
#include "rewindow/WindowsScancodes.hpp"
|
||||
#include "J3ML/LinearAlgebra.hpp"
|
||||
|
||||
|
||||
class Key
|
@@ -13,6 +13,10 @@
|
||||
|
||||
namespace ReWindow
|
||||
{
|
||||
class KeyboardState {
|
||||
public:
|
||||
std::map<Key, bool> PressedKeys;
|
||||
};
|
||||
class InputDevice {};
|
||||
|
||||
class Keyboard : public InputDevice
|
80
include/ReWindow/Mouse.hpp
Normal file
80
include/ReWindow/Mouse.hpp
Normal file
@@ -0,0 +1,80 @@
|
||||
/// ReWindowLibrary
|
||||
/// A C++20 Library for creating and managing windows in a platform-independent manner
|
||||
/// Developed and Maintained by the boys @ Redacted Software.
|
||||
/// (c) 2024 Redacted Software
|
||||
/// This work is dedicated to the public domain.
|
||||
|
||||
/// @file keyboard.h
|
||||
/// @desc A class that models the functionality of a mouse / pointer device.
|
||||
/// @edit 2024-07-29
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace ReWindow
|
||||
{
|
||||
class MouseState {
|
||||
public:
|
||||
struct
|
||||
{
|
||||
bool LMB = false;
|
||||
bool RMB = false;
|
||||
bool MMB = false;
|
||||
bool SideButton1 = false;
|
||||
bool SideButton2 = false;
|
||||
bool MWheelUp = false;
|
||||
bool MWheelDown = false;
|
||||
} Buttons;
|
||||
|
||||
|
||||
Vector2 Position;
|
||||
int Wheel = 0;
|
||||
|
||||
[[nodiscard]] bool IsDown(const MouseButton& btn) const
|
||||
{
|
||||
if (btn == MouseButtons::Left) return Buttons.LMB;
|
||||
if (btn == MouseButtons::Right) return Buttons.RMB;
|
||||
if (btn == MouseButtons::Middle) return Buttons.MMB;
|
||||
if (btn == MouseButtons::Mouse4) return Buttons.SideButton1;
|
||||
if (btn == MouseButtons::Mouse5) return Buttons.SideButton2;
|
||||
//if (btn == MouseButtons::MWheelUp) return Buttons.MWheelUp;
|
||||
//if (btn == MouseButtons::MWheelDown) return Buttons.MWheelDown;
|
||||
|
||||
return false; // Unknown button?
|
||||
}
|
||||
|
||||
void Set(const MouseButton& btn, bool state)
|
||||
{
|
||||
if (btn == MouseButtons::Left) Buttons.LMB = state;
|
||||
if (btn == MouseButtons::Right) Buttons.RMB = state;
|
||||
if (btn == MouseButtons::Middle) Buttons.MMB = state;
|
||||
if (btn == MouseButtons::Mouse4) Buttons.SideButton1 = state;
|
||||
if (btn == MouseButtons::Mouse5) Buttons.SideButton2 = state;
|
||||
//if (btn == MouseButtons::MWheelUp) Buttons.MWheelUp = state;
|
||||
//if (btn == MouseButtons::MWheelDown) Buttons.MWheelDown = state;
|
||||
}
|
||||
|
||||
bool& operator[](const MouseButton& btn)
|
||||
{
|
||||
if (btn == MouseButtons::Left) return Buttons.LMB;
|
||||
if (btn == MouseButtons::Right) return Buttons.RMB;
|
||||
if (btn == MouseButtons::Middle) return Buttons.MMB;
|
||||
if (btn == MouseButtons::Mouse4) return Buttons.SideButton1;
|
||||
if (btn == MouseButtons::Mouse5) return Buttons.SideButton2;
|
||||
//if (btn == MouseButtons::MWheelUp) return Buttons.MWheelUp;
|
||||
//if (btn == MouseButtons::MWheelDown) return Buttons.MWheelDown;
|
||||
|
||||
throw std::runtime_error("Attempted to handle unmapped mouse button");
|
||||
}
|
||||
};
|
||||
|
||||
class InputDevice {}; // TODO: Remember to break InputDevice into it's own file and not define it twice!!!
|
||||
|
||||
class Pointer : public InputDevice {};
|
||||
|
||||
|
||||
class Mouse : public Pointer
|
||||
{
|
||||
|
||||
};
|
||||
}
|
223
include/ReWindow/RWindow.hpp
Normal file
223
include/ReWindow/RWindow.hpp
Normal file
@@ -0,0 +1,223 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include "Event.h"
|
||||
#include <map>
|
||||
#include <thread>
|
||||
#include "Key.hpp"
|
||||
#include "rewindow/Cursors.hpp"
|
||||
#include "MouseButton.hpp"
|
||||
#include "GamepadButton.hpp"
|
||||
#include "J3ML/LinearAlgebra.hpp"
|
||||
#include "WindowEvents.hpp"
|
||||
#include <format>
|
||||
#include <queue>
|
||||
|
||||
#include <experimental/propagate_const>
|
||||
|
||||
|
||||
namespace ReWindow {
|
||||
enum class RenderingAPI: uint8_t {
|
||||
OPENGL = 0,
|
||||
//Vulkan is unimplemented.
|
||||
VULKAN = 1,
|
||||
};
|
||||
//
|
||||
|
||||
class RWindowImpl;
|
||||
class XLibImpl;
|
||||
class Win32Impl;
|
||||
class RWindow;
|
||||
}
|
||||
|
||||
class ReWindow::RWindow {
|
||||
private:
|
||||
RWindowImpl* Impl = nullptr;
|
||||
public:
|
||||
//RWindow() = default;
|
||||
//RWindow();
|
||||
|
||||
static RWindowImpl* GetPlatformImplementation(const RWindowParams& args) {
|
||||
|
||||
#if UNIX
|
||||
return new XLibImpl(args);
|
||||
#endif
|
||||
|
||||
#if WIN32
|
||||
return new Win32Impl(args);
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
explicit RWindow(const RWindowParams& params)
|
||||
: Impl(GetPlatformImplementation(params)) { }
|
||||
|
||||
RWindow()
|
||||
: RWindow({
|
||||
.title = "Redacted Window",
|
||||
.width = 640, .height = 480,
|
||||
.fullscreen = false,
|
||||
.resizable = true,
|
||||
.vsync = false
|
||||
}) { }
|
||||
|
||||
// TODO: Is this one valid?
|
||||
explicit RWindow(RWindowImpl* wImpl)
|
||||
: Impl(wImpl) { }
|
||||
|
||||
RWindow(RWindowImpl* wImpl, RenderImpl* wRenderImpl)
|
||||
: Impl(wImpl), Renderer(wRenderImpl) { }
|
||||
|
||||
/*
|
||||
explicit RWindow(const std::string& wTitle,
|
||||
int wWidth = 640, int wHeight = 480,
|
||||
RenderingAPI wRenderer = RenderingAPI::OPENGL,
|
||||
bool wFullscreen = false,
|
||||
bool wResizable = true,
|
||||
bool wVsync = false) :
|
||||
RWindowImpl(wTitle, wWidth, wHeight, wRenderer, wFullscreen, wResizable, wVsync) {};
|
||||
*/
|
||||
~RWindow() = default;
|
||||
public:
|
||||
// Platform dependant
|
||||
void Open() { Impl->Open(); };
|
||||
void Close() { Impl->Close(); };
|
||||
void PollEvents() { Impl->PollEvents(); };
|
||||
void Refresh() { Impl->Refresh(); };
|
||||
public:
|
||||
// Shared
|
||||
/// Returns whether the window currently has mouse and/or keyboard focus.
|
||||
[[nodiscard]] bool IsFocused() const { return Impl->IsFocused(); };
|
||||
/// Returns whether the window is currently in Fullscreen.
|
||||
// TODO: Support Fullscreen, FullscreenWindowed, and Windowed?
|
||||
[[nodiscard]] bool IsFullscreen() const { return Impl->IsFullscreen(); } ;
|
||||
/// Returns whether the window can be resized.
|
||||
[[nodiscard]] bool IsResizable() const { return Impl->IsResizable(); } ;
|
||||
/// Returns whether V-Sync is enabled.
|
||||
[[nodiscard]] bool IsVsyncEnabled() const { return Impl->IsVsyncEnabled(); } ;
|
||||
/// Returns whether the window is considered to be alive. Once dead, any logic loop should be terminated, and the cleanup procedure should run.
|
||||
[[nodiscard]] bool IsAlive() const { return Impl->IsAlive(); } ;
|
||||
// Should have IsOpen since window could be closed then reopened
|
||||
public:
|
||||
// Platform dependant
|
||||
/// Sets whether or not to make the window fullscreen.
|
||||
/// @note This is implemented per-OS, and as such, it simply requests the OS to do what we want. No guarantee about follow-through can be given.
|
||||
void SetFullscreen(bool fs) { Impl->SetFullscreen(fs); };
|
||||
/// Sets whether or not to make the window resizable.
|
||||
/// @note This is implemented per-OS, and as such, it simply requests the OS to do what we want. No guarantee about follow-through can be given.
|
||||
void SetResizable(bool resizable) { Impl->SetResizable(resizable); };
|
||||
/// Sets whether or not to enable vertical synchronization.
|
||||
/// @note This is implemented per-OS, and as such, it simply requests the OS to do what we want. No guarantee about follow-through can be given.
|
||||
void SetVsyncEnabled(bool vsync) { Impl->SetVsyncEnabled(vsync); };
|
||||
/// Requests the operating system to change the window size.
|
||||
/// @param width
|
||||
/// @param height
|
||||
void SetSize(int width, int height) { Impl->SetSize(width, height); };
|
||||
/// Requests the operating system to change the window size.
|
||||
/// @param size
|
||||
void SetSize(const Vector2& size) { Impl->SetSize(size); };
|
||||
|
||||
// Shared
|
||||
/// Sets the title of this window.
|
||||
void SetTitle(const std::string& title) { Impl->SetTitle(title); };
|
||||
public:
|
||||
// Shared
|
||||
[[nodiscard]] std::string GetTitle() const { return Impl->GetTitle(); } ;
|
||||
/// Returns the position of the window's top-left corner relative to the display
|
||||
[[nodiscard]] Vector2 GetPos() const { return Impl->GetPos(); } ;
|
||||
/// Returns the known size of the window, in {x,y} pixel measurement.
|
||||
[[nodiscard]] Vector2 GetSize() const { return Impl->GetSize(); } ;
|
||||
/// Returns the horizontal length of the renderable area in pixels.
|
||||
[[nodiscard]] int GetWidth() const { return Impl->GetWidth(); } ;
|
||||
/// Returns the vertical length of the renderable area, in pixels.
|
||||
[[nodiscard]] int GetHeight() const { return Impl->GetHeight(); } ;
|
||||
/// Returns the amount of time, in seconds, between the current and last frame.
|
||||
/// Technically, no, it returns the elapsed time of the frame, start to finish.
|
||||
[[nodiscard]] float GetDeltaTime() const { return Impl->GetDeltaTime(); } ;
|
||||
/// Returns the approximate frames-per-second using delta time.
|
||||
[[nodiscard]] float GetRefreshRate() const { return Impl->GetRefreshRate(); } ;
|
||||
/// Returns the number of frames ran since the windows' creation.
|
||||
[[nodiscard]] float GetRefreshCounter() const { return Impl->GetRefreshCounter(); } ;
|
||||
public:
|
||||
// Figure out what to do with these later
|
||||
void Raise() const { Impl->Raise(); };
|
||||
void Lower() const { Impl->Lower(); };
|
||||
void DestroyOSWindowHandle() { Impl->DestroyOSWindowHandle(); };
|
||||
void SetCursorVisible(bool cursor_enable) { Impl->SetCursorVisible(cursor_enable); };
|
||||
Vector2 GetAccurateMouseCoordinates() const { return Impl->GetAccurateMouseCoordinates(); } ;
|
||||
void GLSwapBuffers() { Impl->GLSwapBuffers(); };
|
||||
void Fullscreen() { Impl->Fullscreen(); };
|
||||
void RestoreFromFullscreen() { Impl->RestoreFromFullscreen(); };
|
||||
// I know this doesn't modify the class, but it indirectly modifies the window
|
||||
// Making it const just seems deceptive.
|
||||
void SetCursorStyle(CursorStyle style) const { return Impl->SetCursorStyle(style); } ;
|
||||
Vector2 GetPositionOfRenderableArea() const { return Impl->GetPositionOfRenderableArea(); } ;
|
||||
std::string getGraphicsDriverVendor() { return Impl->getGraphicsDriverVendor(); };
|
||||
void SetFlag(RWindowFlags flag, bool state) { Impl->SetFlag(flag, state); };
|
||||
void processKeyRelease (Key key) { Impl->processKeyRelease(key); };
|
||||
void processKeyPress (Key key) { Impl->processKeyPress(key); };
|
||||
void processOnClose() { Impl->processOnClose(); };
|
||||
void processOnOpen() { Impl->processOnOpen(); };
|
||||
void processMousePress(const MouseButton& btn) { Impl->processMousePress(btn); };
|
||||
void processMouseRelease(const MouseButton& btn) { Impl->processMouseRelease(btn); };
|
||||
void processFocusIn() { Impl->processFocusIn(); };
|
||||
void processFocusOut() { Impl->processFocusOut(); };
|
||||
void processMouseMove(Vector2 last_pos, Vector2 new_pos) { Impl->processMouseMove(last_pos, new_pos); };
|
||||
void processMouseWheel(int scrolls) { Impl->processMouseWheel(scrolls); };
|
||||
virtual void OnOpen() {}
|
||||
virtual void OnClosing() {}
|
||||
virtual void OnFocusLost(const RWindowEvent& e) {}
|
||||
virtual void OnFocusGain(const RWindowEvent& e) {}
|
||||
virtual void OnRefresh(float elapsed) {}
|
||||
virtual void OnResizeSuccess() {}
|
||||
virtual bool OnResizeRequest(const WindowResizeRequestEvent& e) { return true;}
|
||||
virtual void OnKeyDown(const KeyDownEvent&) {}
|
||||
virtual void OnKeyUp(const KeyUpEvent&) {}
|
||||
virtual void OnMouseMove(const MouseMoveEvent&) {}
|
||||
virtual void OnMouseButtonDown(const MouseButtonDownEvent&) {}
|
||||
virtual void OnMouseButtonUp(const MouseButtonUpEvent&) {}
|
||||
virtual void OnMouseWheel(const MouseWheelEvent&) {}
|
||||
Event<> OnOpenEvent;
|
||||
Event<> OnClosingEvent;
|
||||
Event<RWindowEvent> OnFocusLostEvent;
|
||||
Event<RWindowEvent> OnFocusGainEvent;
|
||||
Event<float> OnRefreshEvent;
|
||||
Event<WindowResizeRequestEvent> OnResizeRequestEvent;
|
||||
Event<KeyDownEvent> OnKeyDownEvent;
|
||||
Event<KeyUpEvent> OnKeyUpEvent;
|
||||
Event<MouseMoveEvent> OnMouseMoveEvent;
|
||||
Event<MouseButtonDownEvent> OnMouseButtonDownEvent;
|
||||
Event<MouseButtonUpEvent> OnMouseButtonUpEvent;
|
||||
Event<MouseWheelEvent> OnMouseWheelEvent;
|
||||
|
||||
Vector2 GetMouseCoordinates() const { return Impl->GetMouseCoordinates(); };
|
||||
bool GetFlag(RWindowFlags flag) const { return Impl->GetFlag(flag); };
|
||||
//bool IsAlive() const { return Impl->
|
||||
//IsAlive(); };
|
||||
void SetSizeWithoutEvent(const Vector2& size) { Impl->SetSizeWithoutEvent(size); };
|
||||
void LogEvent(const RWindowEvent& e) { Impl->LogEvent(e); };
|
||||
RWindowEvent GetLastEvent() const { return Impl->GetLastEvent(); }
|
||||
void SetLastKnownWindowSize(const Vector2& size) { Impl->SetLastKnownWindowSize(size); };
|
||||
void SetRenderer(RenderingAPI api) { Impl->SetRenderer(api); };
|
||||
bool IsKeyDown(Key key) const { return Impl->IsKeyDown(key); };
|
||||
bool IsMouseButtonDown(const MouseButton &button) const { return Impl->IsMouseButtonDown(button); };
|
||||
void ManagedRefresh() { Impl->ManagedRefresh(); };
|
||||
float ComputeElapsedFrameTimeSeconds(std::chrono::steady_clock::time_point start, std::chrono::steady_clock::time_point end) { return Impl->ComputeElapsedFrameTimeSeconds(start, end); };
|
||||
std::chrono::steady_clock::time_point GetTimestamp() { return Impl->GetTimestamp(); };
|
||||
void UpdateFrameTiming(float frame_time) { Impl->UpdateFrameTiming(frame_time); };
|
||||
//bool IsResizable() const { return Impl->
|
||||
//IsResizable(); };
|
||||
//bool IsFullscreen() const { return Impl->
|
||||
//IsFullscreen(); };
|
||||
//bool IsFocused() const { return Impl->
|
||||
//IsFocused(); };
|
||||
//bool IsVsyncEnabled() const { return Impl->
|
||||
//IsVsyncEnabled(); };
|
||||
void ForceClose() { Impl->ForceClose(); };
|
||||
void ForceCloseAndTerminateProgram() { Impl->ForceCloseAndTerminateProgram(); };
|
||||
int GetMouseWheelPersistent() const { return Impl->GetMouseWheelPersistent();}
|
||||
[[nodiscard]] bool IsOpen() const { return Impl->IsOpen();}
|
||||
[[nodiscard]] bool IsClosing() const { return Impl->IsClosing();}
|
||||
|
||||
};
|
167
include/ReWindow/RWindowImpl.hpp
Normal file
167
include/ReWindow/RWindowImpl.hpp
Normal file
@@ -0,0 +1,167 @@
|
||||
#pragma once
|
||||
|
||||
namespace ReWindow { class RWindowImpl; }
|
||||
|
||||
class ReWindow::RWindowImpl {
|
||||
protected: // Should maybe make private
|
||||
int width = 1280;
|
||||
int height = 720;
|
||||
|
||||
bool open = false; // Is the underlying OS-Window-Handle actually open.
|
||||
bool resizable = true;
|
||||
bool fullscreen_mode = false;
|
||||
bool focused = true;
|
||||
bool vsync = false;
|
||||
bool cursor_visible = true;
|
||||
bool closing = false;
|
||||
|
||||
float delta_time = 0.f;
|
||||
float refresh_rate = 0.f;
|
||||
unsigned int refresh_count = 0;
|
||||
|
||||
std::string title = "Redacted Window";
|
||||
|
||||
Vector2 lastKnownWindowSize {0, 0};
|
||||
|
||||
// TODO: Implement ringbuffer / circular vector class of some sort.
|
||||
float refresh_rate_prev_1 = 0.f;
|
||||
float refresh_rate_prev_2 = 0.f;
|
||||
float refresh_rate_prev_3 = 0.f;
|
||||
float refresh_rate_prev_4 = 0.f;
|
||||
float refresh_rate_prev_5 = 0.f;
|
||||
|
||||
float avg_refresh_rate = 0.0f;
|
||||
|
||||
// Figure out what to do with this shit later
|
||||
bool flags[5];
|
||||
KeyboardState currentKeyboard; // current frame keyboard state.
|
||||
KeyboardState previousKeyboard; // previous frame keyboard state.
|
||||
MouseState currentMouse; // purrent frame mouse state.
|
||||
MouseState previousMouse; // previous frame mouse state
|
||||
RenderingAPI renderer = RenderingAPI::OPENGL;
|
||||
//
|
||||
public:
|
||||
explicit RWindowImpl(const RWindowParams& params)
|
||||
: RWindowImpl(params.title, params.width, params.height, RenderingAPI::OPENGL, params.fullscreen, p)
|
||||
explicit RWindowImpl(const std::string& wTitle,
|
||||
int wWidth = 640, int wHeight = 480,
|
||||
RenderingAPI wRenderer = RenderingAPI::OPENGL,
|
||||
bool wFullscreen = false,
|
||||
bool wResizable = true,
|
||||
bool wVsync = false);
|
||||
~RWindowImpl();
|
||||
public:
|
||||
virtual void Open();
|
||||
virtual void Close();
|
||||
virtual void PollEvents();
|
||||
virtual void Refresh();
|
||||
public:
|
||||
bool IsFocused() const;
|
||||
bool IsFullscreen() const;
|
||||
bool IsResizable() const;
|
||||
bool IsVsyncEnabled() const;
|
||||
bool IsAlive() const;
|
||||
public:
|
||||
void SetFullscreen(bool fs);
|
||||
void SetResizable(bool fs);
|
||||
void SetVsyncEnabled(bool vsync);
|
||||
void SetSize(int width, int height);
|
||||
void SetSize(const Vector2& size);
|
||||
// Added here for now
|
||||
void SetPos(int x, int y);
|
||||
void SetPos(const Vector2& pos);
|
||||
//
|
||||
virtual void SetTitle(const std::string& title);
|
||||
public:
|
||||
std::string GetTitle() const;
|
||||
Vector2 GetPos() const;
|
||||
Vector2 GetSize() const;
|
||||
int GetWidth() const;
|
||||
int GetHeight() const;
|
||||
float GetDeltaTime() const;
|
||||
float GetRefreshRate() const;
|
||||
float GetRefreshCounter() const;
|
||||
public:
|
||||
// Figure out what to do with these later
|
||||
void Raise() const;
|
||||
void Lower() const;
|
||||
void DestroyOSWindowHandle();
|
||||
void SetCursorVisible(bool cursor_enable);
|
||||
Vector2 GetAccurateMouseCoordinates() const;
|
||||
void GLSwapBuffers();
|
||||
void Fullscreen();
|
||||
void RestoreFromFullscreen();
|
||||
// I know this doesn't modify the class, but it indirectly modifies the window
|
||||
// Making it const just seems deceptive.
|
||||
void SetCursorStyle(CursorStyle style) const;
|
||||
Vector2 GetPositionOfRenderableArea() const;
|
||||
std::string getGraphicsDriverVendor();
|
||||
void SetFlag(RWindowFlags flag, bool state);
|
||||
// Make protected
|
||||
void processKeyRelease (Key key);
|
||||
void processKeyPress (Key key);
|
||||
void processOnClose();
|
||||
void processOnOpen();
|
||||
void processMousePress(const MouseButton& btn);
|
||||
void processMouseRelease(const MouseButton& btn);
|
||||
void processFocusIn();
|
||||
void processFocusOut();
|
||||
void processMouseMove(Vector2 last_pos, Vector2 new_pos);
|
||||
void processMouseWheel(int scrolls);
|
||||
//
|
||||
virtual void OnOpen() {}
|
||||
virtual void OnClosing() {}
|
||||
virtual void OnFocusLost(const RWindowEvent& e) {}
|
||||
virtual void OnFocusGain(const RWindowEvent& e) {}
|
||||
virtual void OnRefresh(float elapsed) {}
|
||||
virtual void OnResizeSuccess() {}
|
||||
virtual bool OnResizeRequest(const WindowResizeRequestEvent& e) { return true;}
|
||||
virtual void OnKeyDown(const KeyDownEvent&) {}
|
||||
virtual void OnKeyUp(const KeyUpEvent&) {}
|
||||
virtual void OnMouseMove(const MouseMoveEvent&) {}
|
||||
virtual void OnMouseButtonDown(const MouseButtonDownEvent&) {}
|
||||
virtual void OnMouseButtonUp(const MouseButtonUpEvent&) {}
|
||||
virtual void OnMouseWheel(const MouseWheelEvent&) {}
|
||||
Event<> OnOpenEvent;
|
||||
Event<> OnClosingEvent;
|
||||
Event<RWindowEvent> OnFocusLostEvent;
|
||||
Event<RWindowEvent> OnFocusGainEvent;
|
||||
Event<float> OnRefreshEvent;
|
||||
Event<WindowResizeRequestEvent> OnResizeRequestEvent;
|
||||
Event<KeyDownEvent> OnKeyDownEvent;
|
||||
Event<KeyUpEvent> OnKeyUpEvent;
|
||||
Event<MouseMoveEvent> OnMouseMoveEvent;
|
||||
Event<MouseButtonDownEvent> OnMouseButtonDownEvent;
|
||||
Event<MouseButtonUpEvent> OnMouseButtonUpEvent;
|
||||
Event<MouseWheelEvent> OnMouseWheelEvent;
|
||||
|
||||
Vector2 GetMouseCoordinates() const;
|
||||
bool GetFlag(RWindowFlags flag) const;
|
||||
//bool IsAlive() const;
|
||||
void SetSizeWithoutEvent(const Vector2& size);
|
||||
std::vector<RWindowEvent> eventLog;
|
||||
std::queue<RWindowEvent> eventQueue;
|
||||
void LogEvent(const RWindowEvent& e) { eventLog.push_back(e);};
|
||||
RWindowEvent GetLastEvent() const {
|
||||
return eventLog.back();
|
||||
};
|
||||
void SetLastKnownWindowSize(const Vector2& size);
|
||||
void SetRenderer(RenderingAPI api);
|
||||
bool IsKeyDown(Key key) const;
|
||||
bool IsMouseButtonDown(const MouseButton &button) const;
|
||||
void ManagedRefresh();
|
||||
float ComputeElapsedFrameTimeSeconds(std::chrono::steady_clock::time_point start, std::chrono::steady_clock::time_point end);
|
||||
std::chrono::steady_clock::time_point GetTimestamp();
|
||||
void UpdateFrameTiming(float frame_time);
|
||||
/*
|
||||
bool IsResizable() const;
|
||||
bool IsFullscreen() const;
|
||||
bool IsFocused() const;
|
||||
bool IsVsyncEnabled() const;
|
||||
*/
|
||||
void ForceClose();
|
||||
void ForceCloseAndTerminateProgram();
|
||||
int GetMouseWheelPersistent() const { return currentMouse.Wheel;}
|
||||
[[nodiscard]] bool IsOpen() const { return open;}
|
||||
[[nodiscard]] bool IsClosing() const { return closing;}
|
||||
};
|
15
include/ReWindow/RWindowParams.hpp
Normal file
15
include/ReWindow/RWindowParams.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ReWindow {
|
||||
struct RWindowParams
|
||||
{
|
||||
std::string title;
|
||||
int width;
|
||||
int height;
|
||||
bool fullscreen;
|
||||
bool resizable;
|
||||
bool vsync;
|
||||
};
|
||||
}
|
5
include/ReWindow/Win32Impl.hpp
Normal file
5
include/ReWindow/Win32Impl.hpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
class ReWindow::Win32Impl : ReWindow::RWindowImpl {
|
||||
public:
|
||||
};
|
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <rewindow/types/key.h>
|
||||
#include <rewindow/types/mousebutton.h>
|
||||
#include "Key.hpp"
|
||||
#include "MouseButton.hpp"
|
||||
|
||||
namespace ReWindow {
|
||||
|
37
include/ReWindow/XLibImpl.hpp
Normal file
37
include/ReWindow/XLibImpl.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <ReWindow/RWindowImpl.hpp>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <GL/glx.h>
|
||||
#include "J3ML/LinearAlgebra.hpp"
|
||||
|
||||
|
||||
namespace ReWindow { class XLibImpl; };
|
||||
|
||||
class ReWindow::XLibImpl : ReWindow::RWindowImpl {
|
||||
Window window;
|
||||
XEvent xev;
|
||||
Display* display = XOpenDisplay(nullptr);
|
||||
int defaultScreen = DefaultScreen(display);
|
||||
XVisualInfo* visual;
|
||||
XSetWindowAttributes xSetWindowAttributes;
|
||||
XWindowAttributes windowAttributes;
|
||||
Atom wmDeleteWindow;
|
||||
// Make it start as floating because fuck tiling WMs
|
||||
Atom windowTypeAtom;
|
||||
Atom windowTypeUtilityAtom;
|
||||
XSizeHints hints;
|
||||
GLXContext glContext;
|
||||
Cursor invisible_cursor = 0;
|
||||
Vector2 render_area_position = {0, 0};
|
||||
Vector2 position = {0, 0};
|
||||
bool should_poll_x_for_mouse_pos = true;
|
||||
public:
|
||||
void Open() override;
|
||||
void Close() override;
|
||||
void PollEvents() override;
|
||||
void SetTitle(const std::string &title) override;
|
||||
void Refresh() override;
|
||||
};
|
||||
|
@@ -1,26 +0,0 @@
|
||||
/// ReWindowLibrary
|
||||
/// A C++20 Library for creating and managing windows in a platform-independent manner
|
||||
/// Developed and Maintained by the boys @ Redacted Software.
|
||||
/// (c) 2024 Redacted Software
|
||||
/// This work is dedicated to the public domain.
|
||||
|
||||
/// @file keyboard.h
|
||||
/// @desc A class that models the functionality of a mouse / pointer device.
|
||||
/// @edit 2024-07-29
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace ReWindow
|
||||
{
|
||||
|
||||
class InputDevice {}; // TODO: Remember to break InputDevice into it's own file and not define it twice!!!
|
||||
|
||||
class Pointer : public InputDevice {};
|
||||
|
||||
|
||||
class Mouse : public Pointer
|
||||
{
|
||||
|
||||
};
|
||||
}
|
@@ -1,457 +0,0 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <Event.h>
|
||||
#include <map>
|
||||
#include <thread>
|
||||
#include <rewindow/types/key.h>
|
||||
#include <rewindow/types/cursors.h>
|
||||
#include <rewindow/types/mousebutton.h>
|
||||
#include <rewindow/types/gamepadbutton.h>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <rewindow/types/WindowEvents.hpp>
|
||||
#include <format>
|
||||
#include <queue>
|
||||
|
||||
|
||||
enum class RWindowFlags: uint8_t {
|
||||
IN_FOCUS,
|
||||
FULLSCREEN,
|
||||
RESIZABLE,
|
||||
VSYNC,
|
||||
QUIT,
|
||||
MAX_FLAG
|
||||
};
|
||||
|
||||
std::string RWindowFlagToStr(RWindowFlags flag);
|
||||
|
||||
enum class RenderingAPI: uint8_t {
|
||||
OPENGL = 0,
|
||||
//Vulkan is unimplemented.
|
||||
VULKAN = 1,
|
||||
};
|
||||
|
||||
namespace ReWindow
|
||||
{
|
||||
using J3ML::LinearAlgebra::Vector2;
|
||||
|
||||
class KeyboardState {
|
||||
public:
|
||||
std::map<Key, bool> PressedKeys;
|
||||
};
|
||||
|
||||
class GamepadState {
|
||||
public:
|
||||
std::map<GamepadButton, bool> PressedButtons;
|
||||
};
|
||||
|
||||
class MouseState {
|
||||
public:
|
||||
struct
|
||||
{
|
||||
bool LMB = false;
|
||||
bool RMB = false;
|
||||
bool MMB = false;
|
||||
bool SideButton1 = false;
|
||||
bool SideButton2 = false;
|
||||
bool MWheelUp = false;
|
||||
bool MWheelDown = false;
|
||||
} Buttons;
|
||||
|
||||
|
||||
Vector2 Position;
|
||||
int Wheel = 0;
|
||||
|
||||
[[nodiscard]] bool IsDown(const MouseButton& btn) const
|
||||
{
|
||||
if (btn == MouseButtons::Left) return Buttons.LMB;
|
||||
if (btn == MouseButtons::Right) return Buttons.RMB;
|
||||
if (btn == MouseButtons::Middle) return Buttons.MMB;
|
||||
if (btn == MouseButtons::Mouse4) return Buttons.SideButton1;
|
||||
if (btn == MouseButtons::Mouse5) return Buttons.SideButton2;
|
||||
//if (btn == MouseButtons::MWheelUp) return Buttons.MWheelUp;
|
||||
//if (btn == MouseButtons::MWheelDown) return Buttons.MWheelDown;
|
||||
|
||||
return false; // Unknown button?
|
||||
}
|
||||
|
||||
void Set(const MouseButton& btn, bool state)
|
||||
{
|
||||
if (btn == MouseButtons::Left) Buttons.LMB = state;
|
||||
if (btn == MouseButtons::Right) Buttons.RMB = state;
|
||||
if (btn == MouseButtons::Middle) Buttons.MMB = state;
|
||||
if (btn == MouseButtons::Mouse4) Buttons.SideButton1 = state;
|
||||
if (btn == MouseButtons::Mouse5) Buttons.SideButton2 = state;
|
||||
//if (btn == MouseButtons::MWheelUp) Buttons.MWheelUp = state;
|
||||
//if (btn == MouseButtons::MWheelDown) Buttons.MWheelDown = state;
|
||||
}
|
||||
|
||||
bool& operator[](const MouseButton& btn)
|
||||
{
|
||||
if (btn == MouseButtons::Left) return Buttons.LMB;
|
||||
if (btn == MouseButtons::Right) return Buttons.RMB;
|
||||
if (btn == MouseButtons::Middle) return Buttons.MMB;
|
||||
if (btn == MouseButtons::Mouse4) return Buttons.SideButton1;
|
||||
if (btn == MouseButtons::Mouse5) return Buttons.SideButton2;
|
||||
//if (btn == MouseButtons::MWheelUp) return Buttons.MWheelUp;
|
||||
//if (btn == MouseButtons::MWheelDown) return Buttons.MWheelDown;
|
||||
|
||||
throw std::runtime_error("Attempted to handle unmapped mouse button");
|
||||
}
|
||||
};
|
||||
|
||||
class IRenderer {
|
||||
public:
|
||||
virtual void Initialize();
|
||||
virtual void SwapBuffers();
|
||||
virtual std::string GetDriverVendor();
|
||||
virtual void SetVsync(bool enabled);
|
||||
virtual void SetViewportSize(int width, int height);
|
||||
virtual void MakeCurrent();
|
||||
};
|
||||
|
||||
class VulkanRenderBase : public IRenderer {};
|
||||
class GLRenderBase : public IRenderer {};
|
||||
class GLXRenderer : public GLRenderBase {};
|
||||
class WGLRenderer : public GLRenderBase {};
|
||||
|
||||
// TODO: Refactor RenderingAPI into a polymorphic class interface for greater reusability.
|
||||
|
||||
/// RWindow is a class implementation of a platform-independent window abstraction.
|
||||
/// This library also provides abstractions for user-input devices, and their interaction with the window.
|
||||
class RWindow {
|
||||
public:
|
||||
#pragma region Constructors
|
||||
/// The default constructor does not set any members, and are left uninitialized.
|
||||
RWindow() = default;
|
||||
/// Constructs a window by explicitly setting the title, width, height, and optionally; rendering API, fullscreen, resizable, and vsync.
|
||||
/// @param wTitle The window title text.
|
||||
/// @param wWidth
|
||||
/// @param wHeight
|
||||
/// @param wRenderer
|
||||
/// @param wFullscreen
|
||||
/// @param wResizable
|
||||
/// @param wVsync
|
||||
explicit RWindow(const std::string& wTitle, int wWidth = 640, int wHeight = 480,
|
||||
RenderingAPI wRenderer = RenderingAPI::OPENGL,
|
||||
bool wFullscreen = false,
|
||||
bool wResizable = true,
|
||||
bool wVsync = false);
|
||||
/// Constructs a window as above with the additional argument of explicitly setting which render API is to be used.
|
||||
|
||||
/// The destructor deallocates and cleans up any memory used by the RWindow program.
|
||||
/// @note If the window handle is not already destroyed, it will be done here.
|
||||
~RWindow();
|
||||
|
||||
#pragma endregion
|
||||
|
||||
/// Bindables are provided for hooking into window instances conveniently, without the need to derive and override for simple use cases.
|
||||
#pragma region Bindable Events
|
||||
|
||||
Event<> OnOpenEvent;
|
||||
Event<> OnClosingEvent;
|
||||
Event<RWindowEvent> OnFocusLostEvent;
|
||||
Event<RWindowEvent> OnFocusGainEvent;
|
||||
Event<float> OnRefreshEvent;
|
||||
Event<WindowResizeRequestEvent> OnResizeRequestEvent;
|
||||
Event<KeyDownEvent> OnKeyDownEvent;
|
||||
Event<KeyUpEvent> OnKeyUpEvent;
|
||||
Event<MouseMoveEvent> OnMouseMoveEvent;
|
||||
Event<MouseButtonDownEvent> OnMouseButtonDownEvent;
|
||||
Event<MouseButtonUpEvent> OnMouseButtonUpEvent;
|
||||
Event<MouseWheelEvent> OnMouseWheelEvent;
|
||||
#pragma endregion
|
||||
|
||||
/// These methods can also be overridden in derived classes.
|
||||
#pragma region Overrides
|
||||
|
||||
/// Called upon the window requesting to open.
|
||||
virtual void OnOpen() {}
|
||||
/// Called right before the window closes.
|
||||
virtual void OnClosing() {}
|
||||
/// Called when the window loses focus.
|
||||
virtual void OnFocusLost(const RWindowEvent& e) {}
|
||||
/// Called when the window gains focus.
|
||||
virtual void OnFocusGain(const RWindowEvent& e) {}
|
||||
/// Called when the window is 'refreshed', in other words, a render pass is completed.
|
||||
virtual void OnRefresh(float elapsed) {}
|
||||
/// Called when a resize request has succeeded.
|
||||
virtual void OnResizeSuccess() {}
|
||||
/// Called when a resize request is sent to the operating system.
|
||||
virtual bool OnResizeRequest(const WindowResizeRequestEvent& e) { return true;}
|
||||
virtual void OnKeyDown(const KeyDownEvent&) {}
|
||||
virtual void OnKeyUp(const KeyUpEvent&) {}
|
||||
virtual void OnMouseMove(const MouseMoveEvent&) {}
|
||||
virtual void OnMouseButtonDown(const MouseButtonDownEvent&) {}
|
||||
virtual void OnMouseButtonUp(const MouseButtonUpEvent&) {}
|
||||
virtual void OnMouseWheel(const MouseWheelEvent&) {}
|
||||
#pragma endregion
|
||||
|
||||
/// Returns a Vector2 representing mouse coordinates relative to the top-left corner of the window.
|
||||
/// This result is cached from the operating-system, and as such may be out-of-date.
|
||||
/// @see GetAccurateMouseCoordinates().
|
||||
Vector2 GetMouseCoordinates() const;
|
||||
|
||||
int GetMouseWheelPersistent() const { return currentMouse.Wheel;}
|
||||
|
||||
/// Sets which rendering API is to be used with this window.
|
||||
void SetRenderer(RenderingAPI api);
|
||||
|
||||
/// This function instructs the operating system to create the actual window, and give it to us to control.
|
||||
/// Calling this function, therefore, creates the real 'window' object on the operating system.
|
||||
void Open();
|
||||
|
||||
/// Tells the window that we want to close, without directly forcing it to. This gives us time to finalize any work we are performing.
|
||||
|
||||
[[nodiscard]] bool IsOpen() const { return open;}
|
||||
[[nodiscard]] bool IsClosing() const { return closing;}
|
||||
|
||||
|
||||
/// Cleans up and closes the window object.
|
||||
void Close();
|
||||
|
||||
/// Closes the window immediately, potentially without allowing finalization to occur.
|
||||
void ForceClose();
|
||||
|
||||
|
||||
void ForceCloseAndTerminateProgram();
|
||||
|
||||
void CloseAndReopenInPlace();
|
||||
|
||||
void MessageBox(); // TODO: Must be implemented from scratch as a Motif Window in x11
|
||||
|
||||
/// Sends a request to the operating system to have this window somehow demand attention from the user.
|
||||
/// This is implemented per-operating system, and as such no guarantees about behavior can be made.
|
||||
void Flash();
|
||||
|
||||
/// Returns whether the window currently has mouse and/or keyboard focus.
|
||||
[[nodiscard]] bool IsFocused() const;
|
||||
|
||||
/// Returns whether the window is currently in Fullscreen.
|
||||
// TODO: Support Fullscreen, FullscreenWindowed, and Windowed?
|
||||
[[nodiscard]] bool IsFullscreen() const;
|
||||
|
||||
/// Returns whether the window can be resized.
|
||||
[[nodiscard]] bool IsResizable() const;
|
||||
|
||||
/// Returns whether V-Sync is enabled.
|
||||
[[nodiscard]] bool IsVsyncEnabled() const;
|
||||
|
||||
/// Returns whether the window is considered to be alive. Once dead, any logic loop should be terminated, and the cleanup procedure should run.
|
||||
[[nodiscard]] bool IsAlive() const;
|
||||
|
||||
/// Returns whether the given key is currently being pressed.
|
||||
[[nodiscard]] bool IsKeyDown(Key key) const;
|
||||
|
||||
/// Returns whether the given mouse button is currently being pressed.
|
||||
[[nodiscard]] bool IsMouseButtonDown(const MouseButton &button) const;
|
||||
|
||||
/// Sets whether or not to make the window fullscreen.
|
||||
/// @note This is implemented per-OS, and as such, it simply requests the OS to do what we want. No guarantee about follow-through can be given.
|
||||
void SetFullscreen(bool fs);
|
||||
|
||||
/// Sets whether or not to make the window resizable.
|
||||
/// @note This is implemented per-OS, and as such, it simply requests the OS to do what we want. No guarantee about follow-through can be given.
|
||||
void SetResizable(bool resizable);
|
||||
|
||||
/// Sets whether or not to enable vertical synchronization.
|
||||
/// @note This is implemented per-OS, and as such, it simply requests the OS to do what we want. No guarantee about follow-through can be given.
|
||||
void SetVsyncEnabled(bool vsync);
|
||||
|
||||
/// Sets the title of this window.
|
||||
void SetTitle(const std::string& title);
|
||||
[[nodiscard]] std::string GetTitle() const;
|
||||
|
||||
/// Returns the horizontal length of this window, in pixels.
|
||||
[[nodiscard]] int GetWidth() const;
|
||||
/// Returns the vertical length of this window, in pixels.
|
||||
[[nodiscard]] int GetHeight() const;
|
||||
|
||||
/// A special-case function to change our internal size variable, without triggering event updates.
|
||||
void SetSizeWithoutEvent(const Vector2& size); //AAAAAHHHHHHHHH WINDOZE MAKING THINGS DIFFICULT :/ - Redacted.
|
||||
|
||||
void SetLastKnownWindowSize(const Vector2& size);
|
||||
|
||||
// TODO: Josh hates parameter-flags, it's not 1995 :/
|
||||
bool GetFlag(RWindowFlags flag) const;
|
||||
// TODO: Josh hates parameter-flags, it's not 1995 :/
|
||||
void SetFlag(RWindowFlags flag, bool state);
|
||||
|
||||
/// Returns the name of the developer of the user's graphics driver, if it can be determined.
|
||||
std::string getGraphicsDriverVendor();
|
||||
|
||||
/// Tells the underlying window manager to destroy this window and drop the handle.
|
||||
/// The window, in theory, can not be re-opened after this.
|
||||
void DestroyOSWindowHandle();
|
||||
|
||||
/// Reads events from the operating system, and processes them accordingly.
|
||||
/// TODO: Move out of public API, consumers should call Refresh or ideally an update() call.
|
||||
void PollEvents();
|
||||
|
||||
/// Updates internal window state, similar to ManagedRefresh, but without accounting for any timekeeping. This is left up to the user.
|
||||
void Refresh();
|
||||
|
||||
/// Updates the window and handles timing internally.
|
||||
void ManagedRefresh();
|
||||
|
||||
/// Requests the operating system to change the window size.
|
||||
/// @param width
|
||||
/// @param height
|
||||
void SetSize(int width, int height);
|
||||
/// Requests the operating system to change the window size.
|
||||
/// @param size
|
||||
void SetSize(const Vector2& size);
|
||||
|
||||
/// Returns the position of the window's top-left corner relative to the display
|
||||
Vector2 GetPos() const;
|
||||
|
||||
/// Returns the known size of the window, in {x,y} pixel measurement.
|
||||
Vector2 GetSize() const;
|
||||
|
||||
/// Returns the position of the "renderable area" of the window relative to it's top left corner.
|
||||
/// (used to account for the width or the border & title bar).
|
||||
Vector2 GetPositionOfRenderableArea() const;
|
||||
|
||||
/// Requests the operating system to move the window to the specified coordinates on the display.
|
||||
/// @param x The horizontal screen position to place the window at.
|
||||
/// @param y The vertical screen position to place the window at.
|
||||
void SetPos(int x, int y);
|
||||
/// Requests the operating system to move the window to the specified coordinates on the display.
|
||||
/// @param pos A Vector2 representing the x,y coordinates of the desired window destination. Fractional values are ignored.
|
||||
void SetPos(const Vector2& pos);
|
||||
|
||||
|
||||
/// Pull the window to the top, such that it is displayed on top of everything else.
|
||||
/// NOTE: The implementation is defined per-OS, and thus there is no guarantee of it always working.
|
||||
void Raise() const;
|
||||
/// Push the window Lower, such that it is effectively hidden behind other windows.
|
||||
/// NOTE: The implementation is defined per-OS, and thus there is no guarantee of it always working.
|
||||
void Lower() const;
|
||||
|
||||
void SetCursorStyle(CursorStyle style) const;
|
||||
|
||||
void SetCursorCustomIcon() const;
|
||||
|
||||
void SetCursorLocked();
|
||||
|
||||
void SetCursorCenter();
|
||||
|
||||
void RestoreCursorFromLastCenter(); // Feels nicer for users
|
||||
|
||||
/// Hides the cursor when it's inside of our window. Useful for 3D game camera.
|
||||
void SetCursorVisible(bool cursor_enable);
|
||||
|
||||
bool GetCursorVisible();
|
||||
|
||||
/// Calls OpenGL's SwapBuffers routine.
|
||||
/// NOTE: This is only used when the underlying rendering API is set to OpenGL.
|
||||
static void GLSwapBuffers();
|
||||
|
||||
/// Returns the current time, represented as a high-resolution std::chrono alias.
|
||||
static std::chrono::steady_clock::time_point GetTimestamp();
|
||||
|
||||
/// Computes elapsed time from a start-point and end-point.
|
||||
float ComputeElapsedFrameTimeSeconds(std::chrono::steady_clock::time_point start, std::chrono::steady_clock::time_point end);
|
||||
|
||||
/// Updates internals to account for the latest calculated frame time.
|
||||
void UpdateFrameTiming(float frame_time);
|
||||
|
||||
/// Returns the amount of time, in seconds, between the current and last frame.
|
||||
/// Technically, no, it returns the elapsed time of the frame, start to finish.
|
||||
[[nodiscard]] float GetDeltaTime() const;
|
||||
|
||||
/// Returns the approximate frames-per-second using delta time.
|
||||
[[nodiscard]] float GetRefreshRate() const;
|
||||
|
||||
/// Returns the number of frames ran since the windows' creation.
|
||||
[[nodiscard]] float GetRefreshCounter() const;
|
||||
protected:
|
||||
|
||||
void LogEvent(const RWindowEvent& e) { eventLog.push_back(e);}
|
||||
//void EnqueueEvent(const RWindowEvent& e) { eventQueue.push(e);}
|
||||
RWindowEvent GetLastEvent() const {
|
||||
return eventLog.back();
|
||||
}
|
||||
/// Requests the operating system to make the window fullscreen. Saves the previous window size as well.
|
||||
void Fullscreen();
|
||||
|
||||
/// Requests the operating system to take the window out of fullscreen mode. Previously saved window size is restored, if possible.
|
||||
void RestoreFromFullscreen();
|
||||
|
||||
protected:
|
||||
#pragma region Data
|
||||
int width = 1280;
|
||||
int height = 720;
|
||||
|
||||
bool open = false; // Is the underlying OS-Window-Handle actually open.
|
||||
bool resizable = true;
|
||||
bool fullscreen_mode = false;
|
||||
bool focused = true;
|
||||
bool vsync = false;
|
||||
bool cursor_visible = true;
|
||||
bool closing = false;
|
||||
|
||||
float delta_time = 0.f;
|
||||
float refresh_rate = 0.f;
|
||||
unsigned int refresh_count = 0;
|
||||
|
||||
std::string title = "Redacted Window";
|
||||
|
||||
|
||||
|
||||
Vector2 lastKnownWindowSize {0, 0};
|
||||
bool flags[5];
|
||||
std::vector<RWindowEvent> eventLog; // history of all logged window events.
|
||||
std::queue<RWindowEvent> eventQueue; //
|
||||
KeyboardState currentKeyboard; // current frame keyboard state.
|
||||
KeyboardState previousKeyboard; // previous frame keyboard state.
|
||||
MouseState currentMouse; // purrent frame mouse state.
|
||||
MouseState previousMouse; // previous frame mouse state
|
||||
|
||||
RenderingAPI renderer = RenderingAPI::OPENGL;
|
||||
|
||||
// TODO: Implement ringbuffer / circular vector class of some sort.
|
||||
float refresh_rate_prev_1 = 0.f;
|
||||
float refresh_rate_prev_2 = 0.f;
|
||||
float refresh_rate_prev_3 = 0.f;
|
||||
float refresh_rate_prev_4 = 0.f;
|
||||
float refresh_rate_prev_5 = 0.f;
|
||||
|
||||
float avg_refresh_rate = 0.0f;
|
||||
#pragma endregion
|
||||
#pragma region Internals
|
||||
/// Returns the most accurate and recent available mouse coordinates.
|
||||
/// @note Call this version at most **once** per-frame. It polls the X-Window server and therefore is quite slow.
|
||||
/// @see getCursorPos();
|
||||
Vector2 GetAccurateMouseCoordinates() const;
|
||||
|
||||
public:
|
||||
/// These unfortunately *have* to be public because of the poor design of the windows event loop.
|
||||
#pragma region Event Callers
|
||||
/// Executes event handlers for keyboard rele;ase events.
|
||||
void processKeyRelease (Key key);
|
||||
/// Executes event handlers for keyboard press events.
|
||||
void processKeyPress (Key key);
|
||||
/// Executes event handlers for window close events.
|
||||
/// @note This will be invoked **before** the window-close procedure begins.
|
||||
void processOnClose();
|
||||
/// Executes event handlers for window open events.
|
||||
/// @note This will be invoked **after** the window-open procedure completes.
|
||||
void processOnOpen();
|
||||
/// Executes event handlers for mouse press events.
|
||||
void processMousePress(const MouseButton& btn);
|
||||
/// Executes event handlers for mouse release events.
|
||||
void processMouseRelease(const MouseButton& btn);
|
||||
/// Executes event handlers for window focus events.
|
||||
void processFocusIn();
|
||||
/// Executes event handlers for window unfocus events.
|
||||
void processFocusOut();
|
||||
|
||||
void processMouseMove(Vector2 last_pos, Vector2 new_pos);
|
||||
|
||||
void processMouseWheel(int scrolls);
|
||||
#pragma endregion
|
||||
private:
|
||||
#pragma endregion
|
||||
};
|
||||
}
|
64
main.cpp
64
main.cpp
@@ -1,7 +1,7 @@
|
||||
#include <iostream>
|
||||
#include <rewindow/types/window.h>
|
||||
#include <rewindow/types/display.h>
|
||||
#include <rewindow/logger/logger.h>
|
||||
#include <ReWindow/RWindow.hpp>
|
||||
#include <ReWindow/Display.hpp>
|
||||
#include <ReWindow/Logger.hpp>
|
||||
|
||||
//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Windows :/
|
||||
#if _WIN32
|
||||
@@ -18,6 +18,10 @@ std::ostream& operator<<(std::ostream& os, const Vector2& v) {
|
||||
}
|
||||
|
||||
class MyWindow : public ReWindow::RWindow {
|
||||
public:
|
||||
float r = 255;
|
||||
float b = 0;
|
||||
float g = g;
|
||||
public:
|
||||
MyWindow(const std::string& title, int w, int h) : ReWindow::RWindow(title, w, h) {}
|
||||
|
||||
@@ -26,7 +30,13 @@ class MyWindow : public ReWindow::RWindow {
|
||||
void OnKeyDown(const ReWindow::KeyDownEvent& e) override {}
|
||||
|
||||
void OnRefresh(float elapsed) override {
|
||||
glClearColor(255, 0, 0, 255);
|
||||
if (r >= 1)
|
||||
r = 1;
|
||||
if (b >= 1)
|
||||
b = 1;
|
||||
if (g >= 1)
|
||||
g = 1;
|
||||
glClearColor(r, g, b, 255);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
GLSwapBuffers();
|
||||
auto pos = GetMouseCoordinates();
|
||||
@@ -54,9 +64,9 @@ class MyWindow : public ReWindow::RWindow {
|
||||
std::cout << "Mouse5 Mouse Button" << std::endl;
|
||||
|
||||
|
||||
if (IsKeyDown(Keys::N))
|
||||
if (IsKeyDown(Keys::N)) {
|
||||
std::cout << "Gotteem" << std::endl;
|
||||
|
||||
}
|
||||
RWindow::OnRefresh(elapsed);
|
||||
}
|
||||
|
||||
@@ -105,11 +115,11 @@ int main() {
|
||||
}
|
||||
*/
|
||||
|
||||
auto* window = new MyWindow("Test Window", 600, 480);
|
||||
MyWindow* window = new MyWindow("Test Window", 600, 480);
|
||||
jlog::Debug(std::format("New window '{}' created. width={} height={}", window->GetTitle(), window->GetWidth(),
|
||||
window->GetHeight()));
|
||||
|
||||
window->SetRenderer(RenderingAPI::OPENGL);
|
||||
window->SetRenderer(ReWindow::RenderingAPI::OPENGL);
|
||||
jlog::Debug(std::format("Rendering API OPENGL set for window '{}'", window->GetTitle()));
|
||||
|
||||
window->Open();
|
||||
@@ -148,12 +158,15 @@ int main() {
|
||||
std::cout << window->GetMouseWheelPersistent() << std::endl;
|
||||
};
|
||||
|
||||
/*
|
||||
while (!window->IsClosing()) {
|
||||
//window->PollEvents();
|
||||
window->ManagedRefresh();
|
||||
}
|
||||
}*/
|
||||
|
||||
delete window;
|
||||
// Found problem
|
||||
// free(): double free detected in tcache 2
|
||||
// delete window;
|
||||
// Alternatively:
|
||||
/*
|
||||
* while (window->IsAlive()) {
|
||||
@@ -170,6 +183,37 @@ int main() {
|
||||
*/
|
||||
|
||||
//exit(0);
|
||||
|
||||
MyWindow* windowdos = new MyWindow("Test Window Dos", 600, 480);
|
||||
|
||||
windowdos->SetRenderer(ReWindow::RenderingAPI::OPENGL);
|
||||
|
||||
windowdos->Open();
|
||||
|
||||
window->r = 0;
|
||||
|
||||
bool swap;
|
||||
while (!windowdos->IsClosing() && !window->IsClosing()) {
|
||||
window->r += 0.01;
|
||||
if (window->r >= 1 && !swap) {
|
||||
window->g += 0.01;
|
||||
}
|
||||
if (window->g >= 1 && !swap)
|
||||
window->b += 0.01;
|
||||
if (window->b >= 1) {
|
||||
window->r = 0.01;
|
||||
window->g = 0.01;
|
||||
window->b = 0.01;
|
||||
}
|
||||
|
||||
|
||||
|
||||
window->ManagedRefresh();
|
||||
windowdos->ManagedRefresh();
|
||||
//sleep(10);
|
||||
}
|
||||
delete window;
|
||||
delete windowdos;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <rewindow/types/gamepadbutton.h>
|
||||
#include <ReWindow/GamepadButton.hpp>
|
||||
|
||||
bool ReWindow::GamepadButton::operator ==(const GamepadButton &rhs) const {
|
||||
return this->GetMnemonicButtonCode() == rhs.GetMnemonicButtonCode();
|
@@ -1,5 +1,5 @@
|
||||
#include <rewindow/types/key.h>
|
||||
//#include <rewindow/logger.h>
|
||||
#include <ReWindow/Key.hpp>
|
||||
//#include <ReWindow/logger.h>
|
||||
//std::vector<Key> Key::keyboard = {};
|
||||
|
||||
std::vector<Key> Key::GetKeyboard() { return keyboard; }
|
@@ -1,4 +1,4 @@
|
||||
#include "rewindow/logger/logger.h"
|
||||
#include <ReWindow/Logger.hpp>
|
||||
|
||||
namespace ReWindow::Logger {
|
||||
using namespace jlog;
|
@@ -1,7 +1,7 @@
|
||||
#include <rewindow/types/mousebutton.h>
|
||||
#include <ReWindow/MouseButton.hpp>
|
||||
#include <string>
|
||||
#include <X11/X.h>
|
||||
#include "rewindow/logger/logger.h"
|
||||
#include <ReWindow/Logger.hpp>
|
||||
|
||||
|
||||
MouseButton::MouseButton(const std::string& charcode, unsigned int index) {
|
@@ -1,46 +1,18 @@
|
||||
#include <rewindow/types/window.h>
|
||||
#include "rewindow/logger/logger.h"
|
||||
std::string RWindowFlagToStr(RWindowFlags flag) {
|
||||
switch (flag) {
|
||||
case RWindowFlags::IN_FOCUS: return "IN_FOCUS";
|
||||
case RWindowFlags::FULLSCREEN: return "FULLSCREEN";
|
||||
case RWindowFlags::RESIZABLE: return "RESIZEABLE";
|
||||
case RWindowFlags::VSYNC: return "VSYNC";
|
||||
case RWindowFlags::QUIT: return "QUIT";
|
||||
case RWindowFlags::MAX_FLAG: return "MAX_FLAG";
|
||||
default:
|
||||
return "unimplemented flag";
|
||||
}
|
||||
};
|
||||
#include <ReWindow/RWindowImpl.hpp>
|
||||
|
||||
using namespace ReWindow;
|
||||
|
||||
RWindow::RWindow(const std::string& wTitle, int wWidth, int wHeight, RenderingAPI wRenderer, bool wFullscreen, bool wResizable, bool wVsync)
|
||||
: title(wTitle), width(wWidth), height(wHeight), renderer(wRenderer), fullscreen_mode(wFullscreen), resizable(wResizable), vsync(wVsync),
|
||||
flags{false,wFullscreen,wResizable,wVsync} {
|
||||
|
||||
}
|
||||
|
||||
RWindow::~RWindow() {
|
||||
if (open)
|
||||
DestroyOSWindowHandle();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vector2 RWindow::GetMouseCoordinates() const {
|
||||
Vector2 RWindowImpl::GetMouseCoordinates() const {
|
||||
return currentMouse.Position;
|
||||
}
|
||||
|
||||
bool RWindow::GetFlag(RWindowFlags flag) const {
|
||||
bool RWindowImpl::GetFlag(RWindowFlags flag) const {
|
||||
return flags[(int) flag];
|
||||
}
|
||||
|
||||
bool RWindow::IsAlive() const {
|
||||
bool RWindowImpl::IsAlive() const {
|
||||
return (!closing) && open;
|
||||
}
|
||||
|
||||
void RWindow::SetFullscreen(bool fs) {
|
||||
void RWindowImpl::SetFullscreen(bool fs) {
|
||||
if (fs)
|
||||
Fullscreen();
|
||||
else
|
||||
@@ -48,7 +20,7 @@ void RWindow::SetFullscreen(bool fs) {
|
||||
}
|
||||
|
||||
#pragma region Event Processors Implementation
|
||||
void RWindow::processFocusIn()
|
||||
void RWindowImpl::processFocusIn()
|
||||
{
|
||||
RWindowEvent event {};
|
||||
OnFocusGain(event);
|
||||
@@ -56,7 +28,7 @@ void RWindow::processFocusIn()
|
||||
LogEvent(event);
|
||||
}
|
||||
|
||||
void RWindow::processFocusOut()
|
||||
void RWindowImpl::processFocusOut()
|
||||
{
|
||||
RWindowEvent event {};
|
||||
OnFocusLost(event);
|
||||
@@ -64,7 +36,7 @@ void RWindow::processFocusOut()
|
||||
LogEvent(event);
|
||||
}
|
||||
|
||||
void RWindow::processMousePress(const MouseButton& btn)
|
||||
void RWindowImpl::processMousePress(const MouseButton& btn)
|
||||
{
|
||||
currentMouse.Set(btn, true);
|
||||
auto event = MouseButtonDownEvent(btn);
|
||||
@@ -74,7 +46,7 @@ void RWindow::processMousePress(const MouseButton& btn)
|
||||
|
||||
}
|
||||
|
||||
void RWindow::processMouseMove(Vector2 last_pos, Vector2 new_pos)
|
||||
void RWindowImpl::processMouseMove(Vector2 last_pos, Vector2 new_pos)
|
||||
{
|
||||
currentMouse.Position = new_pos;
|
||||
auto event = MouseMoveEvent(new_pos);
|
||||
@@ -83,7 +55,7 @@ void RWindow::processMouseMove(Vector2 last_pos, Vector2 new_pos)
|
||||
LogEvent(event);
|
||||
}
|
||||
|
||||
void RWindow::processMouseRelease(const MouseButton& btn)
|
||||
void RWindowImpl::processMouseRelease(const MouseButton& btn)
|
||||
{
|
||||
currentMouse.Set(btn, false);
|
||||
auto event = MouseButtonUpEvent(btn);
|
||||
@@ -93,7 +65,7 @@ void RWindow::processMouseRelease(const MouseButton& btn)
|
||||
|
||||
}
|
||||
|
||||
void RWindow::processKeyRelease(Key key) {
|
||||
void RWindowImpl::processKeyRelease(Key key) {
|
||||
currentKeyboard.PressedKeys[key] = false;
|
||||
auto event = KeyUpEvent(key);
|
||||
OnKeyUp(event);
|
||||
@@ -101,7 +73,7 @@ void RWindow::processKeyRelease(Key key) {
|
||||
LogEvent(event);
|
||||
}
|
||||
|
||||
void RWindow::processKeyPress(Key key) {
|
||||
void RWindowImpl::processKeyPress(Key key) {
|
||||
currentKeyboard.PressedKeys[key] = true;
|
||||
auto event = KeyDownEvent(key);
|
||||
OnKeyDown(event);
|
||||
@@ -109,7 +81,7 @@ void RWindow::processKeyPress(Key key) {
|
||||
LogEvent(event);
|
||||
}
|
||||
|
||||
void RWindow::processOnClose()
|
||||
void RWindowImpl::processOnClose()
|
||||
{
|
||||
auto event = RWindowEvent();
|
||||
OnClosing();
|
||||
@@ -117,7 +89,7 @@ void RWindow::processOnClose()
|
||||
LogEvent(event);
|
||||
}
|
||||
|
||||
void RWindow::processOnOpen()
|
||||
void RWindowImpl::processOnOpen()
|
||||
{
|
||||
auto event = RWindowEvent();
|
||||
OnOpen();
|
||||
@@ -127,60 +99,60 @@ void RWindow::processOnOpen()
|
||||
|
||||
#pragma endregion
|
||||
|
||||
std::string RWindow::GetTitle() const {
|
||||
std::string RWindowImpl::GetTitle() const {
|
||||
return this->title;
|
||||
}
|
||||
|
||||
/*
|
||||
Vector2 RWindow::GetSize() const
|
||||
Vector2 RWindowImpl::GetSize() const
|
||||
{
|
||||
return {this->width, this->height};
|
||||
}
|
||||
*/
|
||||
|
||||
int RWindow::GetWidth() const
|
||||
int RWindowImpl::GetWidth() const
|
||||
{
|
||||
return this->width;
|
||||
}
|
||||
|
||||
int RWindow::GetHeight() const
|
||||
int RWindowImpl::GetHeight() const
|
||||
{
|
||||
return this->height;
|
||||
}
|
||||
|
||||
void RWindow::SetSizeWithoutEvent(const Vector2& size) {
|
||||
void RWindowImpl::SetSizeWithoutEvent(const Vector2& size) {
|
||||
width = size.x;
|
||||
height = size.y;
|
||||
}
|
||||
|
||||
void RWindow::SetLastKnownWindowSize(const Vector2& size) {
|
||||
void RWindowImpl::SetLastKnownWindowSize(const Vector2& size) {
|
||||
lastKnownWindowSize = size;
|
||||
}
|
||||
|
||||
void RWindow::SetRenderer(RenderingAPI api) {
|
||||
void RWindowImpl::SetRenderer(RenderingAPI api) {
|
||||
renderer = api;
|
||||
}
|
||||
|
||||
void RWindow::SetSize(const Vector2& size) {
|
||||
void RWindowImpl::SetSize(const Vector2& size) {
|
||||
this->width = size.x;
|
||||
this->height = size.y;
|
||||
this->SetSize(size.x, size.y);
|
||||
}
|
||||
|
||||
bool RWindow::IsKeyDown(Key key) const {
|
||||
bool RWindowImpl::IsKeyDown(Key key) const {
|
||||
if (currentKeyboard.PressedKeys.contains(key))
|
||||
return currentKeyboard.PressedKeys.at(key);
|
||||
|
||||
return false; // NOTE: Key may not be mapped!!
|
||||
}
|
||||
|
||||
bool RWindow::IsMouseButtonDown(const MouseButton &button) const {
|
||||
bool RWindowImpl::IsMouseButtonDown(const MouseButton &button) const {
|
||||
// TODO: Implement MouseButton map
|
||||
return currentMouse.IsDown(button);
|
||||
}
|
||||
|
||||
|
||||
void RWindow::ManagedRefresh()
|
||||
void RWindowImpl::ManagedRefresh()
|
||||
{
|
||||
auto begin = GetTimestamp();
|
||||
Refresh();
|
||||
@@ -191,7 +163,107 @@ void RWindow::ManagedRefresh()
|
||||
UpdateFrameTiming(dt);
|
||||
}
|
||||
|
||||
void RWindow::Refresh() {
|
||||
/*
|
||||
void RWindowImpl::Refresh() {
|
||||
PollEvents();
|
||||
OnRefresh(delta_time);
|
||||
|
||||
// Only call once and cache the result.
|
||||
currentMouse.Position = GetAccurateMouseCoordinates();
|
||||
|
||||
/// TODO: Implement optional minimum epsilon to trigger a Mouse Update.
|
||||
if (currentMouse.Position != previousMouse.Position) {
|
||||
processMouseMove(previousMouse.Position, currentMouse.Position);
|
||||
previousMouse.Position = currentMouse.Position;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
float RWindowImpl::ComputeElapsedFrameTimeSeconds(std::chrono::steady_clock::time_point start, std::chrono::steady_clock::time_point end) {
|
||||
auto frame_time = end - start;
|
||||
unsigned long int frame_time_us = std::chrono::duration_cast<std::chrono::microseconds>(frame_time).count();
|
||||
float frame_time_s = frame_time_us / (1000.f * 1000.f);
|
||||
return frame_time_s;
|
||||
}
|
||||
|
||||
std::chrono::steady_clock::time_point RWindowImpl::GetTimestamp() {
|
||||
return std::chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
void RWindowImpl::UpdateFrameTiming(float frame_time) {
|
||||
delta_time = frame_time;
|
||||
refresh_rate = 1.f / delta_time;
|
||||
refresh_rate_prev_5 = refresh_rate_prev_4;
|
||||
refresh_rate_prev_4 = refresh_rate_prev_3;
|
||||
refresh_rate_prev_3 = refresh_rate_prev_2;
|
||||
refresh_rate_prev_2 = refresh_rate_prev_1;
|
||||
refresh_rate_prev_1 = refresh_rate;
|
||||
avg_refresh_rate = (refresh_rate_prev_1 + refresh_rate_prev_2 + refresh_rate_prev_3 + refresh_rate_prev_4 + refresh_rate_prev_5) / 5.f;
|
||||
refresh_count++;
|
||||
}
|
||||
|
||||
|
||||
void RWindowImpl::processMouseWheel(int scrolls)
|
||||
{
|
||||
currentMouse.Wheel += scrolls;
|
||||
auto ev = MouseWheelEvent(scrolls);
|
||||
OnMouseWheel(ev);
|
||||
OnMouseWheelEvent(ev);
|
||||
|
||||
previousMouse.Wheel = currentMouse.Wheel;
|
||||
}
|
||||
|
||||
|
||||
bool RWindowImpl::IsResizable() const {
|
||||
return resizable;
|
||||
}
|
||||
|
||||
bool RWindowImpl::IsFullscreen() const {
|
||||
return fullscreen_mode;
|
||||
}
|
||||
|
||||
bool RWindowImpl::IsFocused() const {
|
||||
return focused;
|
||||
}
|
||||
|
||||
bool RWindowImpl::IsVsyncEnabled() const {
|
||||
return vsync;
|
||||
}
|
||||
|
||||
float RWindowImpl::GetDeltaTime() const { return delta_time; }
|
||||
|
||||
float RWindowImpl::GetRefreshRate() const { return refresh_rate; }
|
||||
|
||||
float RWindowImpl::GetRefreshCounter() const { return refresh_count; }
|
||||
|
||||
void RWindowImpl::Close() {
|
||||
closing = true;
|
||||
processOnClose();
|
||||
}
|
||||
|
||||
void RWindowImpl::Open() {
|
||||
open = true;
|
||||
processOnOpen();
|
||||
}
|
||||
|
||||
void RWindowImpl::ForceClose() {
|
||||
Close();
|
||||
DestroyOSWindowHandle();
|
||||
}
|
||||
|
||||
void RWindowImpl::ForceCloseAndTerminateProgram() {
|
||||
ForceClose();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void RWindowImpl::PollEvents()
|
||||
{
|
||||
previousKeyboard = currentKeyboard;
|
||||
previousMouse.Buttons = currentMouse.Buttons;
|
||||
}
|
||||
|
||||
void RWindowImpl::Refresh()
|
||||
{
|
||||
PollEvents();
|
||||
OnRefresh(delta_time);
|
||||
|
||||
@@ -205,77 +277,3 @@ void RWindow::Refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
float RWindow::ComputeElapsedFrameTimeSeconds(std::chrono::steady_clock::time_point start, std::chrono::steady_clock::time_point end) {
|
||||
auto frame_time = end - start;
|
||||
unsigned long int frame_time_us = std::chrono::duration_cast<std::chrono::microseconds>(frame_time).count();
|
||||
float frame_time_s = frame_time_us / (1000.f * 1000.f);
|
||||
return frame_time_s;
|
||||
}
|
||||
|
||||
std::chrono::steady_clock::time_point RWindow::GetTimestamp() {
|
||||
return std::chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
void RWindow::UpdateFrameTiming(float frame_time) {
|
||||
delta_time = frame_time;
|
||||
refresh_rate = 1.f / delta_time;
|
||||
refresh_rate_prev_5 = refresh_rate_prev_4;
|
||||
refresh_rate_prev_4 = refresh_rate_prev_3;
|
||||
refresh_rate_prev_3 = refresh_rate_prev_2;
|
||||
refresh_rate_prev_2 = refresh_rate_prev_1;
|
||||
refresh_rate_prev_1 = refresh_rate;
|
||||
avg_refresh_rate = (refresh_rate_prev_1 + refresh_rate_prev_2 + refresh_rate_prev_3 + refresh_rate_prev_4 + refresh_rate_prev_5) / 5.f;
|
||||
refresh_count++;
|
||||
}
|
||||
|
||||
|
||||
void RWindow::processMouseWheel(int scrolls)
|
||||
{
|
||||
currentMouse.Wheel += scrolls;
|
||||
auto ev = MouseWheelEvent(scrolls);
|
||||
OnMouseWheel(ev);
|
||||
OnMouseWheelEvent(ev);
|
||||
|
||||
previousMouse.Wheel = currentMouse.Wheel;
|
||||
}
|
||||
|
||||
|
||||
bool RWindow::IsResizable() const {
|
||||
return resizable;
|
||||
}
|
||||
|
||||
bool RWindow::IsFullscreen() const {
|
||||
return fullscreen_mode;
|
||||
}
|
||||
|
||||
bool RWindow::IsFocused() const {
|
||||
return focused;
|
||||
}
|
||||
|
||||
bool RWindow::IsVsyncEnabled() const {
|
||||
return vsync;
|
||||
}
|
||||
|
||||
float RWindow::GetDeltaTime() const { return delta_time; }
|
||||
|
||||
float RWindow::GetRefreshRate() const { return refresh_rate; }
|
||||
|
||||
float RWindow::GetRefreshCounter() const { return refresh_count; }
|
||||
|
||||
void RWindow::Close() {
|
||||
closing = true;
|
||||
processOnClose();
|
||||
}
|
||||
|
||||
void RWindow::ForceClose() {
|
||||
Close();
|
||||
DestroyOSWindowHandle();
|
||||
}
|
||||
|
||||
void RWindow::ForceCloseAndTerminateProgram() {
|
||||
ForceClose();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include <Windows.h>
|
||||
#include <gl/GL.h>
|
||||
#include <rewindow/types/window.h>
|
||||
#include <ReWindow/RWindow.hpp>
|
||||
|
||||
using namespace ReWindow;
|
||||
|
7
src/ReWindow/WindowEvents.cpp
Normal file
7
src/ReWindow/WindowEvents.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <ReWindow/WindowEvents.hpp>
|
||||
|
||||
|
||||
namespace ReWindow
|
||||
{
|
||||
|
||||
}
|
481
src/ReWindow/XLibImpl.cpp
Normal file
481
src/ReWindow/XLibImpl.cpp
Normal file
@@ -0,0 +1,481 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <GL/glx.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ReWindow/RWindow.hpp>
|
||||
#include <ReWindow/Cursors.hpp>
|
||||
#include <J3ML/J3ML.hpp>
|
||||
#include <ReWindow/Logger.hpp>
|
||||
|
||||
|
||||
|
||||
// TODO: Move all "global" members to be instantiated class members of Window
|
||||
// Doing this would break the intended "Platform-Specific" Encapsulation
|
||||
// So should we do derived platform-specific subclasses?
|
||||
// The intended goal of the ReWindow class is a one-stop object that handles window management on **ALL** platforms
|
||||
|
||||
using namespace ReWindow;
|
||||
|
||||
/*
|
||||
Window window;
|
||||
XEvent xev;
|
||||
Display* display = XOpenDisplay(nullptr);
|
||||
int defaultScreen = DefaultScreen(display);
|
||||
XVisualInfo* visual;
|
||||
XSetWindowAttributes xSetWindowAttributes;
|
||||
XWindowAttributes windowAttributes;
|
||||
Atom wmDeleteWindow;
|
||||
// Make it start as floating because fuck tiling WMs
|
||||
Atom windowTypeAtom;
|
||||
Atom windowTypeUtilityAtom;
|
||||
XSizeHints hints;
|
||||
GLXContext glContext;
|
||||
Cursor invisible_cursor = 0;
|
||||
|
||||
Vector2 render_area_position = {0, 0};
|
||||
Vector2 position = {0, 0};
|
||||
bool should_poll_x_for_mouse_pos = true;
|
||||
*/
|
||||
|
||||
class RWindowImpl::Platform {
|
||||
public:
|
||||
Platform() = default;
|
||||
public:
|
||||
Window window;
|
||||
XEvent xev;
|
||||
Display* display = XOpenDisplay(nullptr);
|
||||
int defaultScreen = DefaultScreen(display);
|
||||
XVisualInfo* visual;
|
||||
XSetWindowAttributes xSetWindowAttributes;
|
||||
XWindowAttributes windowAttributes;
|
||||
Atom wmDeleteWindow;
|
||||
// Make it start as floating because fuck tiling WMs
|
||||
Atom windowTypeAtom;
|
||||
Atom windowTypeUtilityAtom;
|
||||
XSizeHints hints;
|
||||
GLXContext glContext;
|
||||
Cursor invisible_cursor = 0;
|
||||
|
||||
Vector2 render_area_position = {0, 0};
|
||||
Vector2 position = {0, 0};
|
||||
bool should_poll_x_for_mouse_pos = true;
|
||||
};
|
||||
|
||||
RWindowImpl::RWindowImpl(const std::string &wTitle, int wWidth, int wHeight, RenderingAPI wRenderer, bool wFullscreen, bool wResizable, bool wVsync) : pPlatform(new Platform) {
|
||||
title = wTitle;
|
||||
width = wWidth;
|
||||
height = wHeight;
|
||||
renderer = wRenderer;
|
||||
fullscreen_mode = wFullscreen;
|
||||
resizable = wResizable;
|
||||
vsync = wVsync;
|
||||
}
|
||||
|
||||
RWindowImpl::~RWindowImpl() {
|
||||
if (pPlatform) { std::cout << "FUCK" << std::endl; delete pPlatform; };
|
||||
if (open)
|
||||
DestroyOSWindowHandle();
|
||||
}
|
||||
|
||||
void XLibImpl::SetTitle(const std::string &title) {
|
||||
RWindowImpl::SetTitle(title);
|
||||
XStoreName(pPlatform->display, pPlatform->window, title.c_str());
|
||||
}
|
||||
|
||||
void XLibImpl::Open() {
|
||||
|
||||
pPlatform->xSetWindowAttributes.border_pixel = BlackPixel(pPlatform->display, pPlatform->defaultScreen);
|
||||
pPlatform->xSetWindowAttributes.background_pixel = BlackPixel(pPlatform->display, pPlatform->defaultScreen);
|
||||
pPlatform->xSetWindowAttributes.override_redirect = True;
|
||||
pPlatform->xSetWindowAttributes.event_mask = ExposureMask;
|
||||
//SetVsyncEnabled(vsync);
|
||||
if (renderer == RenderingAPI::OPENGL) {
|
||||
GLint glAttributes[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
|
||||
pPlatform->visual = glXChooseVisual(pPlatform->display, pPlatform->defaultScreen, glAttributes);
|
||||
pPlatform->glContext = glXCreateContext(pPlatform->display, pPlatform->visual, nullptr, GL_TRUE);
|
||||
}
|
||||
|
||||
pPlatform->xSetWindowAttributes.colormap = XCreateColormap(pPlatform->display, RootWindow(pPlatform->display, pPlatform->defaultScreen), pPlatform->visual->visual, AllocNone);
|
||||
|
||||
pPlatform->window = XCreateWindow(pPlatform->display, RootWindow(pPlatform->display, pPlatform->defaultScreen), 0, 0, width, height, 0, pPlatform->visual->depth,
|
||||
InputOutput, pPlatform->visual->visual, CWBackPixel | CWColormap | CWBorderPixel | NoEventMask,
|
||||
&pPlatform->xSetWindowAttributes);
|
||||
// Set window to floating because fucking tiling WMs
|
||||
pPlatform->windowTypeAtom = XInternAtom(pPlatform->display, "_NET_WM_WINDOW_TYPE", False);
|
||||
pPlatform->windowTypeUtilityAtom = XInternAtom(pPlatform->display, "_NET_WM_WINDOW_TYPE_UTILITY", False);
|
||||
XChangeProperty(pPlatform->display, pPlatform->window, pPlatform->windowTypeAtom, XA_ATOM, 32, PropModeReplace,
|
||||
(unsigned char *)&pPlatform->windowTypeUtilityAtom, 1);
|
||||
//
|
||||
XSelectInput(pPlatform->display, pPlatform->window,
|
||||
ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
|
||||
PointerMotionMask |
|
||||
PointerMotionHintMask | FocusChangeMask | StructureNotifyMask | SubstructureRedirectMask |
|
||||
SubstructureNotifyMask | CWColormap );
|
||||
XMapWindow(pPlatform->display, pPlatform->window);
|
||||
XStoreName(pPlatform->display, pPlatform->window, title.c_str());
|
||||
pPlatform->wmDeleteWindow = XInternAtom(pPlatform->display, "WM_DELETE_WINDOW", False);
|
||||
XSetWMProtocols(pPlatform->display, pPlatform->window, &pPlatform->wmDeleteWindow, 1);
|
||||
|
||||
if (renderer == RenderingAPI::OPENGL)
|
||||
glXMakeCurrent(pPlatform->display, pPlatform->window, pPlatform->glContext);
|
||||
|
||||
// Get the position of the renderable area relative to the rest of the window.
|
||||
XGetWindowAttributes(pPlatform->display, pPlatform->window, &pPlatform->windowAttributes);
|
||||
pPlatform->render_area_position = { (float) pPlatform->windowAttributes.x, (float) pPlatform->windowAttributes.y };
|
||||
RWindowImpl::Open();
|
||||
}
|
||||
|
||||
|
||||
void XLibImpl::Close()
|
||||
{
|
||||
RWindowImpl::Close();
|
||||
}
|
||||
|
||||
//using namespace ReWindow;
|
||||
|
||||
void RWindowImpl::Raise() const {
|
||||
Logger::Debug(std::format("Raising window '{}'", this->title));
|
||||
|
||||
// Get the position of the renderable area relative to the rest of the window.
|
||||
XGetWindowAttributes(pPlatform->display, pPlatform->window, &pPlatform->windowAttributes);
|
||||
pPlatform->render_area_position = { (float) pPlatform->windowAttributes.x, (float) pPlatform->windowAttributes.y };
|
||||
|
||||
XRaiseWindow(pPlatform->display, pPlatform->window);
|
||||
}
|
||||
|
||||
void RWindowImpl::Lower() const
|
||||
{
|
||||
Logger::Debug(std::format("Lowering window '{}'", this->title));
|
||||
XLowerWindow(pPlatform->display, pPlatform->window);
|
||||
}
|
||||
|
||||
void RWindowImpl::DestroyOSWindowHandle() {
|
||||
Logger::Debug(std::format("Destroying window '{}'", this->title));
|
||||
XDestroySubwindows(pPlatform->display, pPlatform->window);
|
||||
Logger::Debug(std::format("Destroyed window '{}'", this->title));
|
||||
XDestroyWindow(pPlatform->display, pPlatform->window);
|
||||
|
||||
system("xset r on"); // Re-set X-server parameter to enable key-repeat.
|
||||
|
||||
open = false;
|
||||
}
|
||||
|
||||
//void RWindow::
|
||||
|
||||
void RWindowImpl::SetCursorVisible(bool cursor_enable) {
|
||||
cursor_visible = cursor_enable;
|
||||
if (pPlatform->invisible_cursor == 0) {
|
||||
Pixmap blank_pixmap = XCreatePixmap(pPlatform->display, pPlatform->window, 1, 1, 1);
|
||||
XColor dummy; dummy.pixel = 0; dummy.red = 0; dummy.flags = 0;
|
||||
pPlatform->invisible_cursor = XCreatePixmapCursor(pPlatform->display, blank_pixmap, blank_pixmap, &dummy, &dummy, 0, 0);
|
||||
XFreePixmap(pPlatform->display, blank_pixmap);
|
||||
}
|
||||
|
||||
if (!cursor_enable)
|
||||
XDefineCursor(pPlatform->display, pPlatform->window, pPlatform->invisible_cursor);
|
||||
|
||||
if (cursor_enable)
|
||||
XUndefineCursor(pPlatform->display, pPlatform->window);
|
||||
}
|
||||
|
||||
void RWindowImpl::SetResizable(bool sizable) {
|
||||
XGetWindowAttributes(pPlatform->display,pPlatform->window,&pPlatform->windowAttributes);
|
||||
|
||||
|
||||
this->resizable = sizable;
|
||||
if (!sizable)
|
||||
{
|
||||
Logger::Debug("Once you've done this you cannot make it resizable again.");
|
||||
pPlatform->hints.flags = PMinSize | PMaxSize;
|
||||
pPlatform->hints.min_width = pPlatform->hints.max_width = pPlatform->windowAttributes.width;
|
||||
pPlatform->hints.min_height = pPlatform->hints.max_height = pPlatform->windowAttributes.height;
|
||||
XSetWMNormalHints(pPlatform->display, pPlatform->window, &pPlatform->hints);
|
||||
}
|
||||
//this->SetFlag(RWindowFlags::RESIZABLE, resizable);
|
||||
|
||||
}
|
||||
|
||||
// Fuck you
|
||||
void RWindowImpl::SetFlag(RWindowFlags flag, bool state) {
|
||||
XGetWindowAttributes(pPlatform->display,pPlatform->window,&pPlatform->windowAttributes);
|
||||
flags[(int) flag] = state;
|
||||
//Once you've done this you cannot make it resizable again.
|
||||
if (flag == RWindowFlags::RESIZABLE && !state) {
|
||||
Logger::Debug("Once you've done this you cannot make it resizable again.");
|
||||
pPlatform->hints.flags = PMinSize | PMaxSize;
|
||||
pPlatform->hints.min_width = pPlatform->hints.max_width = pPlatform->windowAttributes.width;
|
||||
pPlatform->hints.min_height = pPlatform->hints.max_height = pPlatform->windowAttributes.height;
|
||||
XSetWMNormalHints(pPlatform->display, pPlatform->window, &pPlatform->hints);
|
||||
}
|
||||
Logger::Debug(std::format("Set flag '{}' to state '{}' for window '{}'", RWindowFlagToStr(flag), state, this->title));
|
||||
}
|
||||
|
||||
void XLibImpl::PollEvents() {
|
||||
while(XPending(pPlatform->display)) {
|
||||
XNextEvent(pPlatform->display, &pPlatform->xev);
|
||||
|
||||
|
||||
if (pPlatform->xev.type == ClientMessage)
|
||||
Logger::Info(std::format("Event '{}'", "ClientMessage"));
|
||||
|
||||
if (pPlatform->xev.xclient.message_type == XInternAtom(pPlatform->display, "WM_PROTOCOLS", False) && static_cast<Atom>(pPlatform->xev.xclient.data.l[0]) == pPlatform->wmDeleteWindow) {
|
||||
Logger::Info("Closing");
|
||||
Close();
|
||||
}
|
||||
|
||||
if (pPlatform->xev.type == FocusIn) {
|
||||
Logger::Debug(std::format("Event'{}'", "FocusIn"));
|
||||
XAutoRepeatOff(pPlatform->display);
|
||||
SetFlag(RWindowFlags::IN_FOCUS, true);
|
||||
|
||||
if (!cursor_visible)
|
||||
XDefineCursor(pPlatform->display, pPlatform->window, pPlatform->invisible_cursor);
|
||||
|
||||
// Get the position of the renderable area relative to the rest of the window.
|
||||
XGetWindowAttributes(pPlatform->display, pPlatform->window, &pPlatform->windowAttributes);
|
||||
pPlatform->render_area_position = { (float) pPlatform->windowAttributes.x, (float) pPlatform->windowAttributes.y };
|
||||
processFocusIn();
|
||||
}
|
||||
|
||||
if (pPlatform->xev.type == FocusOut) {
|
||||
Logger::Debug(std::format("Event '{}'", "FocusOut"));
|
||||
XAutoRepeatOn(pPlatform->display);
|
||||
|
||||
SetFlag(RWindowFlags::IN_FOCUS, false);
|
||||
if (!cursor_visible)
|
||||
XUndefineCursor(pPlatform->display, pPlatform->window);
|
||||
|
||||
processFocusOut();
|
||||
}
|
||||
|
||||
if (pPlatform->xev.type == KeyRelease) {
|
||||
Logger::Debug(std::format("Event '{}'", "KeyRelease"));
|
||||
auto scancode = (X11Scancode) pPlatform->xev.xkey.keycode;
|
||||
auto key = GetKeyFromX11Scancode(scancode);
|
||||
processKeyRelease(key);
|
||||
}
|
||||
|
||||
if (pPlatform->xev.type == KeyPress) {
|
||||
Logger::Debug(std::format("Event '{}'", "KeyPress"));
|
||||
auto scancode = (X11Scancode) pPlatform->xev.xkey.keycode;
|
||||
auto key = GetKeyFromX11Scancode(scancode);
|
||||
processKeyPress(key);
|
||||
}
|
||||
|
||||
if (pPlatform->xev.type == ButtonRelease) {
|
||||
|
||||
// Mouse Wheel fires both the ButtonPress and ButtonRelease instantaneously.
|
||||
// Therefore, we handle it as a specific MouseWheel event rather than a MouseButton event,
|
||||
// and only call on ButtonPress, otherwise it will appear to duplicate the mouse wheel scroll.
|
||||
if (pPlatform->xev.xbutton.button != 4 && pPlatform->xev.xbutton.button != 5) {
|
||||
MouseButton button = GetMouseButtonFromXButton(pPlatform->xev.xbutton.button);
|
||||
Logger::Debug(std::format("Event '{}'", "ButtonRelease"));
|
||||
processMouseRelease(button);
|
||||
}
|
||||
}
|
||||
|
||||
if (pPlatform->xev.type == ButtonPress) {
|
||||
|
||||
// Mouse Wheel fires both the ButtonPress and ButtonRelease instantaneously.
|
||||
// Therefore, we handle it as a specific MouseWheel event rather than a MouseButton event,
|
||||
// and only call on ButtonPress, otherwise it will appear to duplicate the mouse wheel scroll.
|
||||
if (pPlatform->xev.xbutton.button == 4) {
|
||||
processMouseWheel(-1);
|
||||
} else if (pPlatform->xev.xbutton.button == 5) {
|
||||
processMouseWheel(1);
|
||||
} else
|
||||
{
|
||||
MouseButton button = GetMouseButtonFromXButton(pPlatform->xev.xbutton.button);
|
||||
|
||||
Logger::Debug(std::format("Event: MouseButtonPress {}", button.Mnemonic));
|
||||
|
||||
processMousePress(button);
|
||||
}
|
||||
}
|
||||
|
||||
if (pPlatform->xev.type == Expose)
|
||||
{
|
||||
Logger::Debug(std::format("Event '{}'", "Expose"));
|
||||
// Essentially allows more than one window to be drawable
|
||||
// https://www.khronos.org/opengl/wiki/Programming_OpenGL_in_Linux:_GLX_and_Xlib
|
||||
// https://registry.khronos.org/OpenGL-Refpages/gl2.1/xhtml/glXMakeCurrent.xml
|
||||
//glXMakeCurrent(pPlatform->display, pPlatform->window, pPlatform->glContext);
|
||||
}
|
||||
|
||||
// NOTE: This event is functionally useless, as it only informs of the very beginning and end of a mouse movement.
|
||||
if (pPlatform->xev.type == MotionNotify)
|
||||
{
|
||||
Logger::Debug(std::format("Event '{}'", "MotionNotify"));
|
||||
}
|
||||
|
||||
if (pPlatform->xev.type == ConfigureNotify) {
|
||||
if (this->width != pPlatform->xev.xconfigurerequest.width || this->height != pPlatform->xev.xconfigurerequest.height) {
|
||||
Logger::Debug(std::format("Event '{}'", "ResizeRequest"));
|
||||
|
||||
this->width = pPlatform->xev.xconfigurerequest.width;
|
||||
this->height = pPlatform->xev.xconfigurerequest.height;
|
||||
|
||||
auto eventData = WindowResizeRequestEvent();
|
||||
eventData.Size = { (float) pPlatform->xev.xconfigurerequest.width, (float) pPlatform->xev.xconfigurerequest.height };
|
||||
lastKnownWindowSize = eventData.Size;
|
||||
|
||||
OnResizeRequest(eventData);
|
||||
OnResizeRequestEvent(eventData);
|
||||
}
|
||||
|
||||
//Window Moved.
|
||||
if (pPlatform->position.x != pPlatform->xev.xconfigurerequest.x || pPlatform->position.y != pPlatform->xev.xconfigurerequest.y)
|
||||
pPlatform->position = { (float) pPlatform->xev.xconfigurerequest.x, (float) pPlatform->xev.xconfigurerequest.y };
|
||||
}
|
||||
|
||||
}
|
||||
RWindowImpl::PollEvents();
|
||||
}
|
||||
|
||||
|
||||
void XLibImpl::Refresh() {
|
||||
// Essentially allows more than one window to be drawable
|
||||
// https://www.khronos.org/opengl/wiki/Programming_OpenGL_in_Linux:_GLX_and_Xlib
|
||||
// https://registry.khronos.org/OpenGL-Refpages/gl2.1/xhtml/glXMakeCurrent.xml
|
||||
glXMakeCurrent(pPlatform->display, pPlatform->window, pPlatform->glContext);
|
||||
|
||||
RWindowImpl::Refresh();
|
||||
}
|
||||
|
||||
|
||||
// Might make the window go off the screen on some window managers.
|
||||
void RWindowImpl::SetSize(int newWidth, int newHeight) {
|
||||
if (!resizable) return;
|
||||
|
||||
this->width = newWidth;
|
||||
this->height = newHeight;
|
||||
XResizeWindow(pPlatform->display, pPlatform->window, newWidth, newHeight);
|
||||
XFlush(pPlatform->display);
|
||||
Logger::Info(std::format("Set size for '{}' to {} x {}", this->title, newWidth, newHeight));
|
||||
}
|
||||
|
||||
Vector2 RWindowImpl::GetAccurateMouseCoordinates() const {
|
||||
|
||||
Window root_return, child_return;
|
||||
int root_x_ret, root_y_ret;
|
||||
int win_x_ret, win_y_ret;
|
||||
uint32_t mask_return;
|
||||
|
||||
// This seems to be relative to the top left corner of the renderable area.
|
||||
bool mouseAvailable = XQueryPointer(pPlatform->display, pPlatform->window, &root_return, &child_return, &root_x_ret, &root_y_ret, &win_x_ret, &win_y_ret, &mask_return);
|
||||
|
||||
if (mouseAvailable) {
|
||||
// TODO: normalize coordinates from displaySpace to windowSpace
|
||||
// TODO: fire mouse movement event
|
||||
Vector2 m_coords = { (float) win_x_ret, (float) win_y_ret };
|
||||
return m_coords;
|
||||
}
|
||||
return Vector2::Zero;
|
||||
}
|
||||
|
||||
|
||||
Vector2 RWindowImpl::GetSize() const {
|
||||
return {(float) this->width, (float) this->height};
|
||||
}
|
||||
|
||||
//Vector2 RWindow::getLastKnownResize() const
|
||||
//{
|
||||
// return lastKnownWindowSize;
|
||||
//}
|
||||
|
||||
// TODO: implement integer vector2/3 types
|
||||
Vector2 RWindowImpl::GetPos() const {
|
||||
return pPlatform->position;
|
||||
}
|
||||
|
||||
void RWindowImpl::SetPos(int x, int y) {
|
||||
XMoveWindow(pPlatform->display, pPlatform->window, x, y);
|
||||
pPlatform->position = { (float) x, (float) y };
|
||||
}
|
||||
|
||||
void RWindowImpl::SetPos(const Vector2& pos) {
|
||||
SetPos(pos.x, pos.y);
|
||||
}
|
||||
|
||||
|
||||
void RWindowImpl::GLSwapBuffers() {
|
||||
glXSwapBuffers(pPlatform->display,pPlatform->window);
|
||||
}
|
||||
|
||||
|
||||
void RWindowImpl::Fullscreen() {
|
||||
Logger::Info(std::format("Fullscreening '{}'", this->title));
|
||||
fullscreen_mode = true;
|
||||
|
||||
XEvent xev;
|
||||
Atom wm_state = XInternAtom(pPlatform->display, "_NET_WM_STATE", true);
|
||||
Atom wm_fullscreen = XInternAtom(pPlatform->display, "_NET_WM_STATE_FULLSCREEN", true);
|
||||
|
||||
XChangeProperty(pPlatform->display, pPlatform->window, wm_state, XA_ATOM, 32, PropModeReplace, (unsigned char *)&wm_fullscreen, 1);
|
||||
memset(&xev, 0, sizeof(xev));
|
||||
xev.type = ClientMessage;
|
||||
xev.xclient.window = pPlatform->window;
|
||||
xev.xclient.message_type = wm_state;
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = 1; // _NET_WM_STATE_ADD
|
||||
xev.xclient.data.l[1] = fullscreen_mode;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
XSendEvent(pPlatform->display, DefaultRootWindow(pPlatform->display), False, SubstructureNotifyMask | SubstructureRedirectMask, &xev);
|
||||
Logger::Debug(std::format("Fullscreened '{}'", this->title));
|
||||
}
|
||||
|
||||
void RWindowImpl::RestoreFromFullscreen() {
|
||||
Logger::Debug(std::format("Restoring '{}' from Fullscreen", this->title));
|
||||
fullscreen_mode = false;
|
||||
XEvent xev;
|
||||
Atom wm_state = XInternAtom(pPlatform->display, "_NET_WM_STATE", False);
|
||||
Atom fullscreen = XInternAtom(pPlatform->display, "_NET_WM_STATE_FULLSCREEN", False);
|
||||
memset(&xev, 0, sizeof(xev));
|
||||
xev.type = ClientMessage;
|
||||
xev.xclient.window = pPlatform->window;
|
||||
xev.xclient.message_type = wm_state;
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = 0; // _NET_WM_STATE_REMOVE
|
||||
xev.xclient.data.l[1] = fullscreen_mode;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
XSendEvent(pPlatform->display, DefaultRootWindow(pPlatform->display), False, SubstructureNotifyMask | SubstructureRedirectMask, &xev);
|
||||
Logger::Debug(std::format("Restored '{}' from Fullscreen", this->title));
|
||||
}
|
||||
|
||||
void RWindowImpl::SetVsyncEnabled(bool b) {
|
||||
PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT;
|
||||
glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT");
|
||||
glXSwapIntervalEXT(pPlatform->display, pPlatform->window, b);
|
||||
}
|
||||
|
||||
|
||||
// I know this doesn't modify the class, but it indirectly modifies the window
|
||||
// Making it const just seems deceptive.
|
||||
void RWindowImpl::SetCursorStyle(CursorStyle style) const {
|
||||
u32 x11_cursor_resolved_enum = static_cast<u32>(style.X11Cursor);
|
||||
Cursor c = XCreateFontCursor(pPlatform->display, x11_cursor_resolved_enum);
|
||||
XDefineCursor(pPlatform->display, pPlatform->window, c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RWindowImpl::SetTitle(const std::string &title) {
|
||||
this->title = title;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vector2 RWindowImpl::GetPositionOfRenderableArea() const {
|
||||
return pPlatform->render_area_position;
|
||||
}
|
||||
|
||||
std::string RWindowImpl::getGraphicsDriverVendor() {
|
||||
return std::string(reinterpret_cast<const char*>(glGetString(GL_VENDOR)));
|
||||
}
|
||||
|
||||
|
||||
// TODO: Implement ControllerButton map
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <rewindow/types/display.h>
|
||||
#include <ReWindow/Display.hpp>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
|
@@ -1,409 +0,0 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <GL/glx.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <rewindow/types/window.h>
|
||||
#include <rewindow/types/cursors.h>
|
||||
#include <J3ML/J3ML.hpp>
|
||||
#include <rewindow/logger/logger.h>
|
||||
|
||||
|
||||
|
||||
// TODO: Move all "global" members to be instantiated class members of Window
|
||||
// Doing this would break the intended "Platform-Specific" Encapsulation
|
||||
// So should we do derived platform-specific subclasses?
|
||||
// The intended goal of the ReWindow class is a one-stop object that handles window management on **ALL** platforms
|
||||
|
||||
Window window;
|
||||
XEvent xev;
|
||||
Display* display = XOpenDisplay(nullptr);
|
||||
int defaultScreen = DefaultScreen(display);
|
||||
XVisualInfo* visual;
|
||||
XSetWindowAttributes xSetWindowAttributes;
|
||||
XWindowAttributes windowAttributes;
|
||||
Atom wmDeleteWindow;
|
||||
// Make it start as floating because fuck tiling WMs
|
||||
Atom windowTypeAtom;
|
||||
Atom windowTypeUtilityAtom;
|
||||
XSizeHints hints;
|
||||
GLXContext glContext;
|
||||
Cursor invisible_cursor = 0;
|
||||
|
||||
Vector2 render_area_position = {0, 0};
|
||||
Vector2 position = {0, 0};
|
||||
bool should_poll_x_for_mouse_pos = true;
|
||||
|
||||
|
||||
using namespace ReWindow;
|
||||
|
||||
void RWindow::Raise() const {
|
||||
Logger::Debug(std::format("Raising window '{}'", this->title));
|
||||
|
||||
// Get the position of the renderable area relative to the rest of the window.
|
||||
XGetWindowAttributes(display, window, &windowAttributes);
|
||||
render_area_position = { (float) windowAttributes.x, (float) windowAttributes.y };
|
||||
|
||||
XRaiseWindow(display, window);
|
||||
}
|
||||
|
||||
void RWindow::Lower() const
|
||||
{
|
||||
Logger::Debug(std::format("Lowering window '{}'", this->title));
|
||||
XLowerWindow(display, window);
|
||||
}
|
||||
|
||||
void RWindow::DestroyOSWindowHandle() {
|
||||
Logger::Debug(std::format("Destroying window '{}'", this->title));
|
||||
XDestroySubwindows(display, window);
|
||||
Logger::Debug(std::format("Destroyed window '{}'", this->title));
|
||||
XDestroyWindow(display, window);
|
||||
|
||||
system("xset r on"); // Re-set X-server parameter to enable key-repeat.
|
||||
|
||||
open = false;
|
||||
}
|
||||
|
||||
//void RWindow::
|
||||
|
||||
void RWindow::SetCursorVisible(bool cursor_enable) {
|
||||
cursor_visible = cursor_enable;
|
||||
if (invisible_cursor == 0) {
|
||||
Pixmap blank_pixmap = XCreatePixmap(display, window, 1, 1, 1);
|
||||
XColor dummy; dummy.pixel = 0; dummy.red = 0; dummy.flags = 0;
|
||||
invisible_cursor = XCreatePixmapCursor(display, blank_pixmap, blank_pixmap, &dummy, &dummy, 0, 0);
|
||||
XFreePixmap(display, blank_pixmap);
|
||||
}
|
||||
|
||||
if (!cursor_enable)
|
||||
XDefineCursor(display, window, invisible_cursor);
|
||||
|
||||
if (cursor_enable)
|
||||
XUndefineCursor(display, window);
|
||||
}
|
||||
|
||||
void RWindow::SetResizable(bool sizable) {
|
||||
XGetWindowAttributes(display,window,&windowAttributes);
|
||||
|
||||
|
||||
this->resizable = sizable;
|
||||
if (!sizable)
|
||||
{
|
||||
Logger::Debug("Once you've done this you cannot make it resizable again.");
|
||||
hints.flags = PMinSize | PMaxSize;
|
||||
hints.min_width = hints.max_width = windowAttributes.width;
|
||||
hints.min_height = hints.max_height = windowAttributes.height;
|
||||
XSetWMNormalHints(display, window, &hints);
|
||||
}
|
||||
//this->SetFlag(RWindowFlags::RESIZABLE, resizable);
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
Logger::Debug("Once you've done this you cannot make it resizable again.");
|
||||
hints.flags = PMinSize | PMaxSize;
|
||||
hints.min_width = hints.max_width = windowAttributes.width;
|
||||
hints.min_height = hints.max_height = windowAttributes.height;
|
||||
XSetWMNormalHints(display, window, &hints);
|
||||
}
|
||||
Logger::Debug(std::format("Set flag '{}' to state '{}' for window '{}'", RWindowFlagToStr(flag), state, this->title));
|
||||
}
|
||||
|
||||
void RWindow::PollEvents() {
|
||||
while(XPending(display)) {
|
||||
XNextEvent(display, &xev);
|
||||
|
||||
if (xev.type == ClientMessage)
|
||||
Logger::Info(std::format("Event '{}'", "ClientMessage"));
|
||||
|
||||
if (xev.xclient.message_type == XInternAtom(display, "WM_PROTOCOLS", False) && static_cast<Atom>(xev.xclient.data.l[0]) == wmDeleteWindow) {
|
||||
Close();
|
||||
}
|
||||
|
||||
if (xev.type == FocusIn) {
|
||||
Logger::Debug(std::format("Event'{}'", "FocusIn"));
|
||||
XAutoRepeatOff(display);
|
||||
SetFlag(RWindowFlags::IN_FOCUS, true);
|
||||
|
||||
if (!cursor_visible)
|
||||
XDefineCursor(display, window, invisible_cursor);
|
||||
|
||||
// Get the position of the renderable area relative to the rest of the window.
|
||||
XGetWindowAttributes(display, window, &windowAttributes);
|
||||
render_area_position = { (float) windowAttributes.x, (float) windowAttributes.y };
|
||||
processFocusIn();
|
||||
}
|
||||
|
||||
if (xev.type == FocusOut) {
|
||||
Logger::Debug(std::format("Event '{}'", "FocusOut"));
|
||||
XAutoRepeatOn(display);
|
||||
|
||||
SetFlag(RWindowFlags::IN_FOCUS, false);
|
||||
if (!cursor_visible)
|
||||
XUndefineCursor(display, window);
|
||||
|
||||
processFocusOut();
|
||||
}
|
||||
|
||||
if (xev.type == KeyRelease) {
|
||||
Logger::Debug(std::format("Event '{}'", "KeyRelease"));
|
||||
auto scancode = (X11Scancode) xev.xkey.keycode;
|
||||
auto key = GetKeyFromX11Scancode(scancode);
|
||||
processKeyRelease(key);
|
||||
}
|
||||
|
||||
if (xev.type == KeyPress) {
|
||||
Logger::Debug(std::format("Event '{}'", "KeyPress"));
|
||||
auto scancode = (X11Scancode) xev.xkey.keycode;
|
||||
auto key = GetKeyFromX11Scancode(scancode);
|
||||
processKeyPress(key);
|
||||
}
|
||||
|
||||
if (xev.type == ButtonRelease) {
|
||||
|
||||
// Mouse Wheel fires both the ButtonPress and ButtonRelease instantaneously.
|
||||
// Therefore, we handle it as a specific MouseWheel event rather than a MouseButton event,
|
||||
// and only call on ButtonPress, otherwise it will appear to duplicate the mouse wheel scroll.
|
||||
if (xev.xbutton.button != 4 && xev.xbutton.button != 5) {
|
||||
MouseButton button = GetMouseButtonFromXButton(xev.xbutton.button);
|
||||
Logger::Debug(std::format("Event '{}'", "ButtonRelease"));
|
||||
processMouseRelease(button);
|
||||
}
|
||||
}
|
||||
|
||||
if (xev.type == ButtonPress) {
|
||||
|
||||
// Mouse Wheel fires both the ButtonPress and ButtonRelease instantaneously.
|
||||
// Therefore, we handle it as a specific MouseWheel event rather than a MouseButton event,
|
||||
// and only call on ButtonPress, otherwise it will appear to duplicate the mouse wheel scroll.
|
||||
if (xev.xbutton.button == 4) {
|
||||
processMouseWheel(-1);
|
||||
} else if (xev.xbutton.button == 5) {
|
||||
processMouseWheel(1);
|
||||
} else
|
||||
{
|
||||
MouseButton button = GetMouseButtonFromXButton(xev.xbutton.button);
|
||||
|
||||
Logger::Debug(std::format("Event: MouseButtonPress {}", button.Mnemonic));
|
||||
|
||||
processMousePress(button);
|
||||
}
|
||||
}
|
||||
|
||||
if (xev.type == Expose)
|
||||
{
|
||||
Logger::Debug(std::format("Event '{}'", "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)
|
||||
{
|
||||
Logger::Debug(std::format("Event '{}'", "MotionNotify"));
|
||||
}
|
||||
|
||||
if (xev.type == ConfigureNotify) {
|
||||
if (this->width != xev.xconfigurerequest.width || this->height != xev.xconfigurerequest.height) {
|
||||
Logger::Debug(std::format("Event '{}'", "ResizeRequest"));
|
||||
|
||||
this->width = xev.xconfigurerequest.width;
|
||||
this->height = xev.xconfigurerequest.height;
|
||||
|
||||
auto eventData = WindowResizeRequestEvent();
|
||||
eventData.Size = { (float) xev.xconfigurerequest.width, (float) xev.xconfigurerequest.height };
|
||||
lastKnownWindowSize = eventData.Size;
|
||||
|
||||
OnResizeRequest(eventData);
|
||||
OnResizeRequestEvent(eventData);
|
||||
}
|
||||
|
||||
//Window Moved.
|
||||
if (position.x != xev.xconfigurerequest.x || position.y != xev.xconfigurerequest.y)
|
||||
position = { (float) xev.xconfigurerequest.x, (float) xev.xconfigurerequest.y };
|
||||
}
|
||||
|
||||
}
|
||||
previousKeyboard = currentKeyboard;
|
||||
previousMouse.Buttons = currentMouse.Buttons;
|
||||
}
|
||||
|
||||
|
||||
// Might make the window go off the screen on some window managers.
|
||||
void RWindow::SetSize(int newWidth, int newHeight) {
|
||||
if (!resizable) return;
|
||||
|
||||
this->width = newWidth;
|
||||
this->height = newHeight;
|
||||
XResizeWindow(display, window, newWidth, newHeight);
|
||||
XFlush(display);
|
||||
Logger::Info(std::format("Set size for '{}' to {} x {}", this->title, newWidth, newHeight));
|
||||
}
|
||||
|
||||
Vector2 RWindow::GetAccurateMouseCoordinates() const {
|
||||
|
||||
Window root_return, child_return;
|
||||
int root_x_ret, root_y_ret;
|
||||
int win_x_ret, win_y_ret;
|
||||
uint32_t mask_return;
|
||||
|
||||
// This seems to be relative to the top left corner of the renderable area.
|
||||
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) {
|
||||
// TODO: normalize coordinates from displaySpace to windowSpace
|
||||
// TODO: fire mouse movement event
|
||||
Vector2 m_coords = { (float) win_x_ret, (float) win_y_ret };
|
||||
return m_coords;
|
||||
}
|
||||
return Vector2::Zero;
|
||||
}
|
||||
|
||||
|
||||
Vector2 RWindow::GetSize() const {
|
||||
return {(float) this->width, (float) this->height};
|
||||
}
|
||||
|
||||
//Vector2 RWindow::getLastKnownResize() const
|
||||
//{
|
||||
// return lastKnownWindowSize;
|
||||
//}
|
||||
|
||||
// TODO: implement integer vector2/3 types
|
||||
Vector2 RWindow::GetPos() const {
|
||||
return position;
|
||||
}
|
||||
|
||||
void RWindow::SetPos(int x, int y) {
|
||||
XMoveWindow(display, window, x, y);
|
||||
position = { (float) x, (float) y };
|
||||
}
|
||||
|
||||
void RWindow::SetPos(const Vector2& pos) {
|
||||
SetPos(pos.x, pos.y);
|
||||
}
|
||||
|
||||
|
||||
void RWindow::GLSwapBuffers() {
|
||||
glXSwapBuffers(display,window);
|
||||
}
|
||||
|
||||
|
||||
void RWindow::Fullscreen() {
|
||||
Logger::Info(std::format("Fullscreening '{}'", this->title));
|
||||
fullscreen_mode = true;
|
||||
|
||||
XEvent xev;
|
||||
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);
|
||||
memset(&xev, 0, sizeof(xev));
|
||||
xev.type = ClientMessage;
|
||||
xev.xclient.window = window;
|
||||
xev.xclient.message_type = wm_state;
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = 1; // _NET_WM_STATE_ADD
|
||||
xev.xclient.data.l[1] = fullscreen_mode;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
XSendEvent(display, DefaultRootWindow(display), False, SubstructureNotifyMask | SubstructureRedirectMask, &xev);
|
||||
Logger::Debug(std::format("Fullscreened '{}'", this->title));
|
||||
}
|
||||
|
||||
void RWindow::RestoreFromFullscreen() {
|
||||
Logger::Debug(std::format("Restoring '{}' from Fullscreen", this->title));
|
||||
fullscreen_mode = false;
|
||||
XEvent xev;
|
||||
Atom wm_state = XInternAtom(display, "_NET_WM_STATE", False);
|
||||
Atom fullscreen = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False);
|
||||
memset(&xev, 0, sizeof(xev));
|
||||
xev.type = ClientMessage;
|
||||
xev.xclient.window = window;
|
||||
xev.xclient.message_type = wm_state;
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = 0; // _NET_WM_STATE_REMOVE
|
||||
xev.xclient.data.l[1] = fullscreen_mode;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
XSendEvent(display, DefaultRootWindow(display), False, SubstructureNotifyMask | SubstructureRedirectMask, &xev);
|
||||
Logger::Debug(std::format("Restored '{}' from Fullscreen", this->title));
|
||||
}
|
||||
|
||||
void RWindow::SetVsyncEnabled(bool b) {
|
||||
PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT;
|
||||
glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT");
|
||||
glXSwapIntervalEXT(display, window, b);
|
||||
}
|
||||
|
||||
|
||||
void RWindow::SetCursorStyle(CursorStyle style) const {
|
||||
u32 x11_cursor_resolved_enum = static_cast<u32>(style.X11Cursor);
|
||||
Cursor c = XCreateFontCursor(display, x11_cursor_resolved_enum);
|
||||
XDefineCursor(display, window, c);
|
||||
}
|
||||
|
||||
void RWindow::Open() {
|
||||
xSetWindowAttributes.border_pixel = BlackPixel(display, defaultScreen);
|
||||
xSetWindowAttributes.background_pixel = BlackPixel(display, defaultScreen);
|
||||
xSetWindowAttributes.override_redirect = True;
|
||||
xSetWindowAttributes.event_mask = ExposureMask;
|
||||
//SetVsyncEnabled(vsync);
|
||||
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);
|
||||
|
||||
window = XCreateWindow(display, RootWindow(display, defaultScreen), 0, 0, width, height, 0, visual->depth,
|
||||
InputOutput, visual->visual, CWBackPixel | CWColormap | CWBorderPixel | NoEventMask,
|
||||
&xSetWindowAttributes);
|
||||
// Set window to floating because fucking tiling WMs
|
||||
windowTypeAtom = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
|
||||
windowTypeUtilityAtom = XInternAtom(display, "_NET_WM_WINDOW_TYPE_UTILITY", False);
|
||||
XChangeProperty(display, window, windowTypeAtom, XA_ATOM, 32, PropModeReplace,
|
||||
(unsigned char *)&windowTypeUtilityAtom, 1);
|
||||
//
|
||||
XSelectInput(display, window,
|
||||
ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
|
||||
PointerMotionMask |
|
||||
PointerMotionHintMask | FocusChangeMask | StructureNotifyMask | SubstructureRedirectMask |
|
||||
SubstructureNotifyMask | CWColormap );
|
||||
XMapWindow(display, window);
|
||||
XStoreName(display, window, title.c_str());
|
||||
wmDeleteWindow = XInternAtom(display, "WM_DELETE_WINDOW", False);
|
||||
XSetWMProtocols(display, window, &wmDeleteWindow, 1);
|
||||
|
||||
if (renderer == RenderingAPI::OPENGL)
|
||||
glXMakeCurrent(display, window, glContext);
|
||||
|
||||
// Get the position of the renderable area relative to the rest of the window.
|
||||
XGetWindowAttributes(display, window, &windowAttributes);
|
||||
render_area_position = { (float) windowAttributes.x, (float) windowAttributes.y };
|
||||
|
||||
open = true;
|
||||
|
||||
processOnOpen();
|
||||
}
|
||||
|
||||
void RWindow::SetTitle(const std::string &title) {
|
||||
this->title = title;
|
||||
XStoreName(display, window, title.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vector2 RWindow::GetPositionOfRenderableArea() const {
|
||||
return render_area_position;
|
||||
}
|
||||
|
||||
std::string RWindow::getGraphicsDriverVendor() {
|
||||
return std::string(reinterpret_cast<const char*>(glGetString(GL_VENDOR)));
|
||||
}
|
||||
|
||||
|
||||
// TODO: Implement ControllerButton map
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <rewindow/types/display.h>
|
||||
#include <ReWindow/Display.hpp>
|
||||
|
||||
using namespace ReWindow;
|
||||
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#include <rewindow/types/WindowEvents.hpp>
|
||||
|
||||
|
||||
namespace ReWindow
|
||||
{
|
||||
|
||||
}
|
Reference in New Issue
Block a user