libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
Fast3dWindow.h
Go to the documentation of this file.
1#pragma once
7
8namespace Ship {
9class ConsoleVariable;
10class ControlDeck;
11} // namespace Ship
12
13union Gfx;
14#include "interpreter.h"
15
16namespace Fast {
17
32
45class Fast3dWindow : public Ship::Window {
46 public:
47 Fast3dWindow(std::shared_ptr<Ship::Config> config = nullptr,
48 std::shared_ptr<Ship::ConsoleVariable> consoleVariables = nullptr,
49 std::shared_ptr<Ship::ControlDeck> controlDeck = nullptr);
50 Fast3dWindow(std::vector<std::shared_ptr<Ship::GuiWindow>> guiWindows,
51 std::shared_ptr<Ship::Config> config = nullptr,
52 std::shared_ptr<Ship::ConsoleVariable> consoleVariables = nullptr,
53 std::shared_ptr<Ship::ControlDeck> controlDeck = nullptr);
54 Fast3dWindow(std::shared_ptr<Ship::Gui> gui, std::shared_ptr<Ship::Config> config = nullptr,
55 std::shared_ptr<Ship::ConsoleVariable> consoleVariables = nullptr,
56 std::shared_ptr<Ship::ControlDeck> controlDeck = nullptr);
57 Fast3dWindow(std::shared_ptr<Ship::Gui> gui, std::shared_ptr<FastMouseStateManager> mouseStateManager,
58 std::shared_ptr<Ship::Config> config = nullptr,
59 std::shared_ptr<Ship::ConsoleVariable> consoleVariables = nullptr,
60 std::shared_ptr<Ship::ControlDeck> controlDeck = nullptr);
62
63 void Close() override;
64 void RunGuiOnly() override;
65 void StartFrame() override;
66 void EndFrame() override;
67 bool IsFrameReady() override;
68 void HandleEvents() override;
69 void SetCursorVisibility(bool visible) override;
70 uint32_t GetWidth() override;
71 uint32_t GetHeight() override;
72 int32_t GetPosX() override;
73 int32_t GetPosY() override;
74 float GetAspectRatio() override;
75 void SetMousePos(Ship::Coords pos) override;
79 bool GetMouseState(Ship::MouseBtn btn) override;
80 void SetMouseCapture(bool capture) override;
81 bool IsMouseCaptured() override;
82 uint32_t GetCurrentRefreshRate() override;
84 bool CanDisableVerticalSync() override;
85 void SetResolutionMultiplier(float multiplier) override;
86 void SetMsaaLevel(uint32_t value) override;
87 void SetFullscreen(bool isFullscreen) override;
88 bool IsFullscreen() override;
89 bool IsRunning() override;
90 uintptr_t GetGfxFrameBuffer() override;
91 const char* GetKeyName(int32_t scancode) override;
92
93 std::string GetWindowBackendName() override;
94
95 void SetCurrentDimensions(uint32_t width, uint32_t height) override;
96 void SetCurrentDimensions(uint32_t width, uint32_t height, int32_t posX, int32_t posY) override;
97 void SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height) override;
98 void SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height, int32_t posX, int32_t posY) override;
100
102 int32_t GetTargetFps();
103 void SetTargetFps(int32_t fps);
104 void SetMaximumFrameLatency(int32_t latency);
105 void GetPixelDepthPrepare(float x, float y);
106 uint16_t GetPixelDepth(float x, float y);
107 void SetTextureFilter(FilteringMode filteringMode);
110 bool DrawAndRunGraphicsCommands(Gfx* commands, const std::unordered_map<Mtx*, MtxF>& mtxReplacements);
111
112 std::weak_ptr<Interpreter> GetInterpreterWeak() const;
113
115 std::shared_ptr<GfxDebugger> GetGfxDebugger() const;
116
117 protected:
118 void OnInit(const nlohmann::json& initArgs = nlohmann::json::object()) override;
119
120 static bool KeyDown(int32_t scancode);
121 static bool KeyUp(int32_t scancode);
122 static void AllKeysUp();
123 static bool MouseButtonDown(int button);
124 static bool MouseButtonUp(int button);
125 static void OnFullscreenChanged(bool isNowFullscreen);
126
127 private:
128 GfxRenderingAPI* mRenderingApi;
129 GfxWindowBackend* mWindowManagerApi;
130 std::shared_ptr<Interpreter> mInterpreter = nullptr;
131 std::shared_ptr<Ship::ConsoleVariable> mConsoleVariables;
132 mutable std::shared_ptr<Ship::ControlDeck> mControlDeck;
133 std::shared_ptr<GfxDebugger> mGfxDebugger;
134
136 std::shared_ptr<Ship::ConsoleVariable> GetConsoleVariables() const;
138 std::shared_ptr<Ship::ControlDeck> GetControlDeck() const;
139};
140} // namespace Fast
Fast3D-based window and rendering context.
Definition Fast3dWindow.h:45
uint32_t GetWidth() override
Returns the current width of the window client area in pixels.
std::weak_ptr< Interpreter > GetInterpreterWeak() const
uintptr_t GetGfxFrameBuffer() override
Returns a handle to the graphics API framebuffer object.
Ship::CoordsF GetMouseWheel() override
Returns the mouse wheel scroll delta for the current frame.
void EndFrame() override
Ends the current render frame and presents it to the display.
void Close() override
Requests that the window and application close.
uint16_t GetPixelDepth(float x, float y)
static void AllKeysUp()
uint32_t GetHeight() override
Returns the current height of the window client area in pixels.
void SetResolutionMultiplier(float multiplier) override
Sets the internal rendering resolution multiplier.
Fast3dWindow(std::shared_ptr< Ship::Gui > gui, std::shared_ptr< FastMouseStateManager > mouseStateManager, std::shared_ptr< Ship::Config > config=nullptr, std::shared_ptr< Ship::ConsoleVariable > consoleVariables=nullptr, std::shared_ptr< Ship::ControlDeck > controlDeck=nullptr)
static bool KeyDown(int32_t scancode)
void StartFrame() override
Begins a new render frame; clears the back buffer and sets up state.
bool CanDisableVerticalSync() override
Returns true if vertical sync can be disabled on this backend.
uint32_t GetCurrentRefreshRate() override
Returns the display's current refresh rate in Hz.
Ship::Coords GetMousePos() override
Returns the current mouse cursor position relative to the window.
const char * GetKeyName(int32_t scancode) override
Returns the human-readable name for a keyboard scancode.
bool IsFrameReady() override
Returns true if the renderer is ready to begin a new frame.
void HandleEvents() override
Processes pending OS/input events.
void RunGuiOnly() override
Runs a single GUI-only tick without executing game logic.
void SetTargetFps(int32_t fps)
void SetMousePos(Ship::Coords pos) override
Moves the mouse cursor to the given window-relative coordinates.
Ship::Coords GetMouseDelta() override
Returns the mouse movement delta since the last frame.
void SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height, int32_t posX, int32_t posY) override
Switches fullscreen state and sets the window dimensions and position.
void SetMouseCapture(bool capture) override
Enables or disables mouse capture (relative/locked mouse mode).
bool GetMouseState(Ship::MouseBtn btn) override
Returns whether the given mouse button is currently pressed.
Fast3dWindow(std::shared_ptr< Ship::Gui > gui, std::shared_ptr< Ship::Config > config=nullptr, std::shared_ptr< Ship::ConsoleVariable > consoleVariables=nullptr, std::shared_ptr< Ship::ControlDeck > controlDeck=nullptr)
bool IsRunning() override
Returns true while the window / render loop is running.
Fast3dWindow(std::vector< std::shared_ptr< Ship::GuiWindow > > guiWindows, std::shared_ptr< Ship::Config > config=nullptr, std::shared_ptr< Ship::ConsoleVariable > consoleVariables=nullptr, std::shared_ptr< Ship::ControlDeck > controlDeck=nullptr)
std::string GetWindowBackendName() override
Returns a human-readable name for the current window backend.
static bool MouseButtonDown(int button)
void SetCursorVisibility(bool visible) override
Shows or hides the OS mouse cursor over the window.
bool SupportsWindowedFullscreen() override
Returns true if the backend supports a windowed-fullscreen (borderless) mode.
void SetCurrentDimensions(uint32_t width, uint32_t height) override
Sets the window dimensions (size and position) and applies them immediately.
static bool MouseButtonUp(int button)
float GetAspectRatio() override
Returns the current aspect ratio (width / height) of the window.
void SetMaximumFrameLatency(int32_t latency)
Ship::WindowRect GetPrimaryMonitorRect() override
Returns the bounding rectangle of the primary monitor.
void SetTextureFilter(FilteringMode filteringMode)
void OnInit(const nlohmann::json &initArgs=nlohmann::json::object()) override
Override this to implement component-specific initialization logic.
int32_t GetPosX() override
Returns the X position of the window's top-left corner on the desktop.
int32_t GetPosY() override
Returns the Y position of the window's top-left corner on the desktop.
static void OnFullscreenChanged(bool isNowFullscreen)
bool IsMouseCaptured() override
Returns true if the mouse is currently captured.
std::shared_ptr< GfxDebugger > GetGfxDebugger() const
Returns the graphics debugger for this Fast3D window.
static bool KeyUp(int32_t scancode)
void SetCurrentDimensions(uint32_t width, uint32_t height, int32_t posX, int32_t posY) override
Sets the window dimensions and position and applies them immediately.
void SetCurrentDimensions(bool isFullscreen, uint32_t width, uint32_t height) override
Switches fullscreen state and sets the window dimensions.
int32_t GetTargetFps()
bool DrawAndRunGraphicsCommands(Gfx *commands, const std::unordered_map< Mtx *, MtxF > &mtxReplacements)
void SetFullscreen(bool isFullscreen) override
Switches between fullscreen and windowed mode.
bool IsFullscreen() override
Returns true if the window is currently in fullscreen mode.
void SetRendererUCode(UcodeHandlers ucode)
void GetPixelDepthPrepare(float x, float y)
Fast3dWindow(std::shared_ptr< Ship::Config > config=nullptr, std::shared_ptr< Ship::ConsoleVariable > consoleVariables=nullptr, std::shared_ptr< Ship::ControlDeck > controlDeck=nullptr)
void SetMsaaLevel(uint32_t value) override
Sets the MSAA sample count.
Definition gfx_rendering_api.h:30
Definition gfx_window_manager_api.h:7
Abstract base class for the application window and rendering surface.
Definition Window.h:62
Definition gfx_direct3d_common.h:19
FilteringMode
Definition gfx_rendering_api.h:17
WindowBackend
Identifies the graphics/windowing backend used by Fast3dWindow.
Definition Fast3dWindow.h:27
@ FAST3D_SDL_OPENGL
Definition Fast3dWindow.h:29
@ FAST3D_DXGI_DX11
Definition Fast3dWindow.h:28
@ FAST3D_SDL_METAL
Definition Fast3dWindow.h:30
Core namespace for the libultraship engine framework.
Definition gfx_direct3d_common.h:14
MouseBtn
Identifies a mouse button delivered to the input mapping system.
Definition KeyboardScancodes.h:136
Floating-point pixel coordinates.
Definition Window.h:32
Identifies the graphics/windowing backend in use.
Definition Window.h:26
Screen-space rectangle in integer pixels.
Definition Window.h:38
UcodeHandlers
Definition ucodehandlers.h:3