Critiques
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m26s

This commit is contained in:
2024-12-07 19:03:03 -05:00
parent fdde8486f7
commit e0c001b1f1

View File

@@ -15,6 +15,8 @@
// Ignore last 2 commit names. Clion saved the last commit name which fucking blows
// God I'm dumb as shit -maxine
// We aren't fucking doing this anymore. We're adults, let's act like it. -maxine
enum class RWindowFlags: uint8_t {
IN_FOCUS,
FULLSCREEN,
@@ -26,6 +28,13 @@ enum class RWindowFlags: uint8_t {
std::string RWindowFlagToStr(RWindowFlags flag);
// TODO: Refactor RenderingAPI into a polymorphic class interface for greater reusability.
// We aren't doing this either.
// This will be replaced with a standard interface like IRenderer.
// The interface will be given to RWindow as a generic component.
// RWindow should have no clue what RenderingAPI its using as long
// as it adheres to the interface. - maxine
enum class RenderingAPI: uint8_t {
OPENGL = 0,
//Vulkan is unimplemented.
@@ -48,7 +57,7 @@ namespace ReWindow {
class GLXRenderer : public GLRenderBase {};
class WGLRenderer : public GLRenderBase {};
// TODO: Refactor RenderingAPI into a polymorphic class interface for greater reusability.
// This may be better split into multiple component classes.
// RWindow is just way too big to be easily grokkable.
@@ -88,6 +97,8 @@ namespace ReWindow {
Event<RWindowEvent> OnFocusGainEvent;
Event<float> OnRefreshEvent;
Event<WindowResizeRequestEvent> OnResizeRequestEvent;
// This will be implemented later.
// Still working out the details for how I'll tackle it. - maxine
Event<InputServiceEvent> OnInputServiceEvent;
public:
@@ -99,6 +110,9 @@ namespace ReWindow {
virtual void OnRefresh(float elapsed) {};
virtual void OnResizeSuccess() {};
virtual bool OnResizeRequest(const WindowResizeRequestEvent& e) { return true; }
// This will be implemented later.
// Still working out the details for how I'll tackle it. - maxine
virtual void OnInput(const InputServiceEvent& e) {};
public:
/// This function instructs the operating system to create the actual window, and give it to us to control.
@@ -111,6 +125,7 @@ namespace ReWindow {
void Close();
/// Closes the window immediately, potentially without allowing finalization to occur.
void ForceClose();
// Just wondering. Why?? -maxine
void ForceCloseAndTerminateProgram();
void CloseAndReopenInPlace();
@@ -123,26 +138,28 @@ namespace ReWindow {
/// Returns whether the window can be resized.
[[nodiscard]] bool IsResizable() const;
/// Returns whether V-Sync is enabled.
[[nodiscard]] bool IsVsyncEnabled() const;
[[nodiscard]] bool IsVsyncEnabled() const; // Why should RWindow know about this? I think this would be better suited for the Rendering API - maxine
/// 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;
[[nodiscard]] bool IsAlive() const; // bool IsComputerOn() { return true; } - maxine
public:
/// Sets which rendering API is to be used with this window.
void SetRenderer(RenderingAPI api);
void SetRenderer(RenderingAPI api); // This is fine, but RWindow should instead take an object responsible for handling rendering - maxine
/// 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.
// "No guarantee about follow-through can be given." Then don't let the fucking window handle it -maxine
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.
// "No guarantee about follow-through can be given." Then don't let the fucking window handle it -maxine
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);
void SetVsyncEnabled(bool vsync); // Again a Renderer object should just handle this
/// Sets the title of this window.
void SetTitle(const std::string& title);
/// 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 SetSizeWithoutEvent(const Vector2& size); //AAAAAHHHHHHHHH WINDOZE MAKING THINGS DIFFICULT :/ - Redacted. Like always - maxine
void SetLastKnownWindowSize(const Vector2& size);
/// Requests the operating system to change the window size.
/// @param width
@@ -172,6 +189,9 @@ namespace ReWindow {
/// Returns the vertical length of this window, in pixels.
[[nodiscard]] int GetHeight() const;
/// Returns the name of the developer of the user's graphics driver, if it can be determined.
// This shouldn't be fucking handled by the window at all. This should be handled by a renderer object.
// I've only left it here to ask questions about WHY the window needs to know the graphics driver.
// - maxine
std::string getGraphicsDriverVendor();
/// Returns the position of the window's top-left corner relative to the display
Vector2 GetPos() const;
@@ -179,9 +199,12 @@ namespace ReWindow {
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).
// There's probably a better way to do this. We just don't know it yet. - maxine
Vector2 GetPositionOfRenderableArea() const;
/// Returns the current time, represented as a high-resolution std::chrono alias.
// Why does the window need to know this? - maxine
static std::chrono::steady_clock::time_point GetTimestamp();
// All of this may be better chopped of into a Delta Time engine. - maxine
/// 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;
@@ -189,14 +212,19 @@ namespace ReWindow {
[[nodiscard]] float GetRefreshRate() const;
/// Returns the number of frames ran since the windows' creation.
[[nodiscard]] float GetRefreshCounter() const;
// I still don't like the fact the window knows anything about rendering the cursor.
// This should be handled by a configurable rendering system.
// - maxine
bool GetCursorVisible();
public:
// Why? - maxine
/// 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();
public:
// As far as I'm concerned this all seems fine. - maxine
/// 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();
@@ -210,30 +238,30 @@ namespace ReWindow {
public:
/// 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.
// "there is no guarantee of it always working" Then don't let the fucking window handle it -maxine
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.
// "there is no guarantee of it always working" Then don't let the fucking window handle it -maxine
void Lower() const;
/// 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();
void RestoreCursorFromLastCenter();
void RestoreCursorFromLastCenter(); // Again this is meh to me - maxine
public:
// WHY THE FUCK DOES THE WINDOW HANDLE THIS???! IT SHOULD HAVE NO IDEA! - maxine
/// Calls OpenGL's SwapBuffers routine.
/// NOTE: This is only used when the underlying rendering API is set to OpenGL.
static void GLSwapBuffers();
public:
// This is fine, though a little annoying to read. - maxine
/// 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);
public:
/// 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();
@@ -246,10 +274,11 @@ namespace ReWindow {
void processFocusOut();
/// Executes event handlers for input events
/// @note currently not implemented. Will be part of the interface to the Input Service
/// @note currently not implemented. Will be part of the interface to the Input Service - maxine
void processOnInput();
protected:
// I'm not sure what we're doing here. - maxine
void LogEvent(const RWindowEvent& e) { eventLog.push_back(e);}
RWindowEvent GetLastEvent() const {
return eventLog.back();
@@ -271,10 +300,12 @@ namespace ReWindow {
bool closing = false;
protected:
// Honestly may be better suited for a Delta Time engine - maxine
float delta_time = 0.f;
float refresh_rate = 0.f;
unsigned int refresh_count = 0;
// TODO: Implement ringbuffer / circular vector class of some sort.
// This should really be done because this looks dumb. - maxine
float refresh_rate_prev_1 = 0.f;
float refresh_rate_prev_2 = 0.f;
float refresh_rate_prev_3 = 0.f;
@@ -286,6 +317,10 @@ namespace ReWindow {
std::string title = "Redacted Window";
protected:
// Again we're not doing this.
// The Rendering API will be an object which
// handles rendering for the window.
// - maxine
RenderingAPI renderer = RenderingAPI::OPENGL;
};
}