|
libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
|
Fast3D-based window and rendering context. More...
#include <Fast3dWindow.h>
Public Member Functions | |
| Fast3dWindow (std::shared_ptr< Ship::Config > config=nullptr, std::shared_ptr< Ship::ConsoleVariable > consoleVariables=nullptr, std::shared_ptr< Ship::ControlDeck > controlDeck=nullptr) | |
| 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) | |
| 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) | |
| 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) | |
| ~Fast3dWindow () | |
| void | Close () override |
| Requests that the window and application close. | |
| void | RunGuiOnly () override |
| Runs a single GUI-only tick without executing game logic. | |
| void | StartFrame () override |
| Begins a new render frame; clears the back buffer and sets up state. | |
| void | EndFrame () override |
| Ends the current render frame and presents it to the display. | |
| bool | IsFrameReady () override |
| Returns true if the renderer is ready to begin a new frame. | |
| void | HandleEvents () override |
| Processes pending OS/input events. | |
| void | SetCursorVisibility (bool visible) override |
| Shows or hides the OS mouse cursor over the window. | |
| uint32_t | GetWidth () override |
| Returns the current width of the window client area in pixels. | |
| uint32_t | GetHeight () override |
| Returns the current height of the window client area in pixels. | |
| 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. | |
| float | GetAspectRatio () override |
| Returns the current aspect ratio (width / height) of the window. | |
| void | SetMousePos (Ship::Coords pos) override |
| Moves the mouse cursor to the given window-relative coordinates. | |
| Ship::Coords | GetMousePos () override |
| Returns the current mouse cursor position relative to the window. | |
| Ship::Coords | GetMouseDelta () override |
| Returns the mouse movement delta since the last frame. | |
| Ship::CoordsF | GetMouseWheel () override |
| Returns the mouse wheel scroll delta for the current frame. | |
| bool | GetMouseState (Ship::MouseBtn btn) override |
| Returns whether the given mouse button is currently pressed. | |
| void | SetMouseCapture (bool capture) override |
| Enables or disables mouse capture (relative/locked mouse mode). | |
| bool | IsMouseCaptured () override |
| Returns true if the mouse is currently captured. | |
| uint32_t | GetCurrentRefreshRate () override |
| Returns the display's current refresh rate in Hz. | |
| bool | SupportsWindowedFullscreen () override |
| Returns true if the backend supports a windowed-fullscreen (borderless) mode. | |
| bool | CanDisableVerticalSync () override |
| Returns true if vertical sync can be disabled on this backend. | |
| void | SetResolutionMultiplier (float multiplier) override |
| Sets the internal rendering resolution multiplier. | |
| void | SetMsaaLevel (uint32_t value) override |
| Sets the MSAA sample count. | |
| void | SetFullscreen (bool isFullscreen) override |
| Switches between fullscreen and windowed mode. | |
| bool | IsFullscreen () override |
| Returns true if the window is currently in fullscreen mode. | |
| bool | IsRunning () override |
| Returns true while the window / render loop is running. | |
| uintptr_t | GetGfxFrameBuffer () override |
| Returns a handle to the graphics API framebuffer object. | |
| const char * | GetKeyName (int32_t scancode) override |
| Returns the human-readable name for a keyboard scancode. | |
| std::string | GetWindowBackendName () override |
| Returns a human-readable name for the current window backend. | |
| void | SetCurrentDimensions (uint32_t width, uint32_t height) override |
| Sets the window dimensions (size and position) and applies them immediately. | |
| 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. | |
| 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. | |
| Ship::WindowRect | GetPrimaryMonitorRect () override |
| Returns the bounding rectangle of the primary monitor. | |
| void | InitWindowManager () |
| int32_t | GetTargetFps () |
| void | SetTargetFps (int32_t fps) |
| void | SetMaximumFrameLatency (int32_t latency) |
| void | GetPixelDepthPrepare (float x, float y) |
| uint16_t | GetPixelDepth (float x, float y) |
| void | SetTextureFilter (FilteringMode filteringMode) |
| void | SetRendererUCode (UcodeHandlers ucode) |
| void | EnableSRGBMode () |
| bool | DrawAndRunGraphicsCommands (Gfx *commands, const std::unordered_map< Mtx *, MtxF > &mtxReplacements) |
| std::weak_ptr< Interpreter > | GetInterpreterWeak () const |
| std::shared_ptr< GfxDebugger > | GetGfxDebugger () const |
| Returns the graphics debugger for this Fast3D window. | |
Public Member Functions inherited from Ship::Window | |
| Window (std::shared_ptr< Config > config=nullptr) | |
| Window (const std::vector< std::shared_ptr< GuiWindow > > &guiWindows, std::shared_ptr< Config > config=nullptr) | |
| Constructs a Window and pre-registers a list of GUI windows. | |
| Window (std::shared_ptr< Gui > gui, std::shared_ptr< Config > config=nullptr) | |
| Constructs a Window backed by a pre-constructed Gui instance. | |
| Window (std::shared_ptr< Gui > gui, std::shared_ptr< MouseStateManager > mouseStateManager, std::shared_ptr< Config > config=nullptr) | |
| Constructs a Window with both a Gui and a MouseStateManager. | |
| virtual | ~Window () |
| int32_t | GetWindowBackend () |
| Returns the current graphics backend identifier. | |
| std::shared_ptr< std::vector< int32_t > > | GetAvailableWindowBackends () |
| Returns the list of backends available on this platform. | |
| bool | IsAvailableWindowBackend (int32_t backendId) |
| Returns true if the backend with the given ID is available on this platform. | |
| int32_t | GetLastScancode () |
| Returns the scancode of the last key event received. | |
| void | SetLastScancode (int32_t scanCode) |
| Records the most recently received keyboard scancode. | |
| void | ToggleFullscreen () |
| Toggles between fullscreen and windowed mode. | |
| float | GetCurrentAspectRatio () |
| Returns the current aspect ratio, recomputed from GetWidth() / GetHeight(). | |
| void | SaveWindowToConfig () |
| Persists window geometry and backend settings to the Config. | |
| std::shared_ptr< Gui > | GetGui () |
| Returns the GUI overlay layer. | |
| bool | ShouldAutoCaptureMouse () |
| Returns true if the window should automatically capture the mouse when focused. | |
| void | SetAutoCaptureMouse (bool capture) |
| Enables or disables automatic mouse capture on window focus. | |
| bool | ShouldForceCursorVisibility () |
| Returns true if the cursor should always be visible regardless of capture state. | |
| void | SetForceCursorVisibility (bool visible) |
| Forces the cursor to remain visible even when captured. | |
| int32_t | GetFullscreenScancode () |
| Returns the scancode bound to the fullscreen toggle action. | |
| int32_t | GetMouseCaptureScancode () |
| Returns the scancode bound to the mouse-capture toggle action. | |
| void | SetFullscreenScancode (int32_t scancode) |
| Binds a scancode to the fullscreen toggle action. | |
| void | SetMouseCaptureScancode (int32_t scancode) |
| Binds a scancode to the mouse-capture toggle action. | |
| std::shared_ptr< MouseStateManager > | GetMouseStateManager () |
| Returns the MouseStateManager used to track mouse button and position state. | |
Public Member Functions inherited from Ship::Component | |
| Component (const std::string &name, std::shared_ptr< Context > context=nullptr) | |
| Constructs a Component with the given name. | |
| virtual | ~Component () |
| void | Init (const nlohmann::json &initArgs=nlohmann::json::object()) |
| Performs one-time initialization of this component. | |
| bool | IsInitialized () const |
| Returns true once Init() (or MarkInitialized()) has completed successfully. | |
| const std::string & | GetName () const |
| Returns the name of this Component. | |
| std::string | ToString () const |
| Returns a human-readable string representation (e.g. "Name (id)"). | |
| std::string | ToTreeString (int depth=0) const |
| Returns a human-readable tree representation of this component and its children. | |
| operator std::string () const | |
| Conversion operator to std::string; equivalent to ToString(). | |
| ParentComponentList & | GetParents () |
| Returns a mutable reference to the parent list. | |
| const ParentComponentList & | GetParents () const |
| Returns a const reference to the parent list. | |
| ComponentList & | GetChildren () |
| Returns a mutable reference to the child list. | |
| const ComponentList & | GetChildren () const |
| Returns a const reference to the child list. | |
| virtual std::shared_ptr< Component > | TryGetSharedComponent () noexcept |
| Returns a shared_ptr to this Component when available, otherwise nullptr. | |
| virtual std::shared_ptr< Component > | GetSharedComponent () |
| Returns a shared_ptr to this Component via the correct enable_shared_from_this base. | |
| template<typename T > | |
| bool | HasInChildren () const |
| Checks whether any descendant Component matches type T via BFS. | |
| template<typename T > | |
| std::shared_ptr< T > | GetFirstInChildren () const |
| Returns the first descendant that matches type T via BFS. | |
| template<typename T > | |
| std::shared_ptr< std::vector< std::shared_ptr< T > > > | GetInChildren () const |
| Returns all descendants that match type T via BFS. | |
| template<typename T > | |
| bool | HasInParents () const |
| Checks whether any ancestor Component matches type T via BFS. | |
| template<typename T > | |
| std::shared_ptr< T > | GetFirstInParents () const |
| Returns the first ancestor that matches type T via BFS. | |
| template<typename T > | |
| std::shared_ptr< std::vector< std::shared_ptr< T > > > | GetInParents () const |
| Returns all ancestors that match type T via BFS. | |
Public Member Functions inherited from Ship::Part | |
| Part () | |
| Constructs a Part and assigns it a unique ID. | |
| Part (std::shared_ptr< Context > context) | |
| Constructs a Part with an explicit Context reference and unique ID. | |
| virtual | ~Part ()=default |
| uint64_t | GetId () const |
| Returns the unique identifier for this Part. | |
| bool | operator== (const Part &other) const |
| Compares two Parts for equality by their unique IDs. | |
| std::shared_ptr< Context > | GetContext () const |
| Returns the Context this Part belongs to, or nullptr if unset. | |
| void | SetContext (std::shared_ptr< Context > ctx) |
| Sets the Context this Part belongs to. | |
Protected Member Functions | |
| void | OnInit (const nlohmann::json &initArgs=nlohmann::json::object()) override |
| Override this to implement component-specific initialization logic. | |
Protected Member Functions inherited from Ship::Window | |
| void | OnInit (const nlohmann::json &initArgs) override |
| Caches this Window on the MouseStateManager. | |
| void | SetWindowBackend (int32_t backend) |
| Records the active graphics backend. Called by subclass constructors. | |
| void | AddAvailableWindowBackend (int32_t backend) |
| Adds a backend to the list of backends available on this platform. | |
| int32_t | GetSavedWindowBackend () |
| Reads the saved window backend identifier from the config. | |
| std::shared_ptr< Config > | GetConfig () const |
| Returns the cached Config component after validating it is ready for use. | |
Protected Member Functions inherited from Ship::Component | |
| void | MarkInitialized () |
| Marks this component as initialized without going through Init(). | |
| template<typename T > | |
| std::shared_ptr< T > | RequireDependency (const std::shared_ptr< T > &dependency, const std::string &dependencyName) const |
| Returns a cached dependency after validating it exists and is initialized. | |
Protected Member Functions inherited from Ship::Part | |
| virtual void | OnAdded (bool forced) |
| Called after this Part has been added to a PartList. | |
| virtual void | OnRemoved (bool forced) |
| Called after this Part has been removed from a PartList. | |
Static Protected Member Functions | |
| static bool | KeyDown (int32_t scancode) |
| static bool | KeyUp (int32_t scancode) |
| static void | AllKeysUp () |
| static bool | MouseButtonDown (int button) |
| static bool | MouseButtonUp (int button) |
| static void | OnFullscreenChanged (bool isNowFullscreen) |
Fast3D-based window and rendering context.
Fast3dWindow drives the Fast3D graphics pipeline and integrates with the Ship component hierarchy. The following dependencies are cached on the class:
| Fast::Fast3dWindow::Fast3dWindow | ( | std::shared_ptr< Ship::Config > | config = nullptr, |
| std::shared_ptr< Ship::ConsoleVariable > | consoleVariables = nullptr, |
||
| std::shared_ptr< Ship::ControlDeck > | controlDeck = nullptr |
||
| ) |
| Fast::Fast3dWindow::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 |
||
| ) |
| Fast::Fast3dWindow::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 |
||
| ) |
| Fast::Fast3dWindow::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 |
||
| ) |
| Fast::Fast3dWindow::~Fast3dWindow | ( | ) |
|
staticprotected |
|
overridevirtual |
Returns true if vertical sync can be disabled on this backend.
Implements Ship::Window.
|
overridevirtual |
Requests that the window and application close.
Implements Ship::Window.
| bool Fast::Fast3dWindow::DrawAndRunGraphicsCommands | ( | Gfx * | commands, |
| const std::unordered_map< Mtx *, MtxF > & | mtxReplacements | ||
| ) |
| void Fast::Fast3dWindow::EnableSRGBMode | ( | ) |
|
overridevirtual |
Ends the current render frame and presents it to the display.
Implements Ship::Window.
|
overridevirtual |
Returns the current aspect ratio (width / height) of the window.
Implements Ship::Window.
|
overridevirtual |
Returns the display's current refresh rate in Hz.
Implements Ship::Window.
| std::shared_ptr< GfxDebugger > Fast::Fast3dWindow::GetGfxDebugger | ( | ) | const |
Returns the graphics debugger for this Fast3D window.
|
overridevirtual |
Returns a handle to the graphics API framebuffer object.
Implements Ship::Window.
|
overridevirtual |
Returns the current height of the window client area in pixels.
Implements Ship::Window.
| std::weak_ptr< Interpreter > Fast::Fast3dWindow::GetInterpreterWeak | ( | ) | const |
|
overridevirtual |
Returns the human-readable name for a keyboard scancode.
| scancode | Platform scancode value. |
Implements Ship::Window.
|
overridevirtual |
Returns the mouse movement delta since the last frame.
Implements Ship::Window.
|
overridevirtual |
Returns the current mouse cursor position relative to the window.
Implements Ship::Window.
|
overridevirtual |
Returns whether the given mouse button is currently pressed.
| btn | Mouse button to query. |
Implements Ship::Window.
|
overridevirtual |
Returns the mouse wheel scroll delta for the current frame.
Implements Ship::Window.
| uint16_t Fast::Fast3dWindow::GetPixelDepth | ( | float | x, |
| float | y | ||
| ) |
| void Fast::Fast3dWindow::GetPixelDepthPrepare | ( | float | x, |
| float | y | ||
| ) |
|
overridevirtual |
Returns the X position of the window's top-left corner on the desktop.
Implements Ship::Window.
|
overridevirtual |
Returns the Y position of the window's top-left corner on the desktop.
Implements Ship::Window.
|
overridevirtual |
Returns the bounding rectangle of the primary monitor.
Implements Ship::Window.
| int32_t Fast::Fast3dWindow::GetTargetFps | ( | ) |
|
overridevirtual |
Returns the current width of the window client area in pixels.
Implements Ship::Window.
|
overridevirtual |
Returns a human-readable name for the current window backend.
The base implementation returns an empty string. Concrete subclasses (e.g. Fast3dWindow) override this to return backend-specific names such as "OpenGL", "Metal", or "DirectX 11".
Reimplemented from Ship::Window.
|
overridevirtual |
Processes pending OS/input events.
Implements Ship::Window.
| void Fast::Fast3dWindow::InitWindowManager | ( | ) |
|
overridevirtual |
Returns true if the renderer is ready to begin a new frame.
Implements Ship::Window.
|
overridevirtual |
Returns true if the window is currently in fullscreen mode.
Implements Ship::Window.
|
overridevirtual |
Returns true if the mouse is currently captured.
Implements Ship::Window.
|
overridevirtual |
Returns true while the window / render loop is running.
Implements Ship::Window.
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
overrideprotectedvirtual |
Override this to implement component-specific initialization logic.
Called by Init() the first time it is invoked. After OnInit() returns without throwing, the component is marked as initialized. If OnInit() throws, the component remains uninitialized so Init() may be retried.
| initArgs | JSON object with component-specific initialization arguments from the build hierarchy. Default implementation ignores them. |
Components with initialization parameters (ResourceManager, Window, …) provide their own Init(…) overload instead of overriding this method.
The default implementation is a no-op.
Reimplemented from Ship::Component.
|
overridevirtual |
Runs a single GUI-only tick without executing game logic.
Implements Ship::Window.
|
overridevirtual |
Switches fullscreen state and sets the window dimensions.
| isFullscreen | true to enter fullscreen, false for windowed. |
| width | New client-area width in pixels. |
| height | New client-area height in pixels. |
Implements Ship::Window.
|
overridevirtual |
Switches fullscreen state and sets the window dimensions and position.
| isFullscreen | true to enter fullscreen, false for windowed. |
| width | New client-area width in pixels. |
| height | New client-area height in pixels. |
| posX | Left edge of the window in screen coordinates. |
| posY | Top edge of the window in screen coordinates. |
Implements Ship::Window.
|
overridevirtual |
Sets the window dimensions (size and position) and applies them immediately.
| width | New client-area width in pixels. |
| height | New client-area height in pixels. |
Implements Ship::Window.
|
overridevirtual |
Sets the window dimensions and position and applies them immediately.
| width | New client-area width in pixels. |
| height | New client-area height in pixels. |
| posX | Left edge of the window in screen coordinates. |
| posY | Top edge of the window in screen coordinates. |
Implements Ship::Window.
|
overridevirtual |
Shows or hides the OS mouse cursor over the window.
| visible | true to show, false to hide. |
Implements Ship::Window.
|
overridevirtual |
Switches between fullscreen and windowed mode.
| isFullscreen | true to enter fullscreen, false to return to windowed. |
Implements Ship::Window.
| void Fast::Fast3dWindow::SetMaximumFrameLatency | ( | int32_t | latency | ) |
|
overridevirtual |
Enables or disables mouse capture (relative/locked mouse mode).
| capture | true to capture, false to release. |
Implements Ship::Window.
|
overridevirtual |
Moves the mouse cursor to the given window-relative coordinates.
| pos | Target position in window pixels. |
Implements Ship::Window.
|
overridevirtual |
Sets the MSAA sample count.
| value | Number of MSAA samples (e.g. 1, 2, 4, 8). |
Implements Ship::Window.
| void Fast::Fast3dWindow::SetRendererUCode | ( | UcodeHandlers | ucode | ) |
|
overridevirtual |
Sets the internal rendering resolution multiplier.
| multiplier | Values > 1 super-sample; < 1 sub-sample. |
Implements Ship::Window.
| void Fast::Fast3dWindow::SetTargetFps | ( | int32_t | fps | ) |
| void Fast::Fast3dWindow::SetTextureFilter | ( | FilteringMode | filteringMode | ) |
|
overridevirtual |
Begins a new render frame; clears the back buffer and sets up state.
Implements Ship::Window.
|
overridevirtual |
Returns true if the backend supports a windowed-fullscreen (borderless) mode.
Implements Ship::Window.