matf-rg-engine 1.0.0
Base for project for the Computer Graphics course at Faculty of Mathematics, University of Belgrade
|
Registers Platform events such as mouse movement, key press, window events... More...
#include <PlatformController.hpp>
Public Member Functions | |
const Key & | key (KeyId key) const |
Get the state of the Key in the current frame. | |
const MousePosition & | mouse () const |
Get the state of the MousePosition in the current frame. | |
std::string_view | name () const override |
Get the name of the Controller. | |
const Window * | window () const |
Get the window. | |
void | register_platform_event_observer (std::unique_ptr< PlatformEventObserver > observer) |
Register a PlatformEventObserver callback for platform events. By default, the PlatformController registers a PlatformEventObserver that does nothing. | |
const FrameTime & | frame_time () const |
Get FrameTime for the previous frame. Updated in during core::App::loop. | |
float | dt () const |
Get elapsed time for the previous frame. | |
void | set_enable_cursor (bool enabled) |
Enables/disabled the visibility of the cursor on screen. | |
void | swap_buffers () |
Swaps the current draw buffer for the main window. Should be called at the end of the frame. | |
void | _platform_on_mouse (double x, double y) |
Called from the platform-specific callback. You shouldn't call this function directly. | |
void | _platform_on_keyboard (int key, int action) |
Called from the platform-specific callback. You shouldn't call this function directly. | |
void | _platform_on_scroll (double x, double y) |
Called from the platform-specific callback. You shouldn't call this function directly. | |
void | _platform_on_framebuffer_resize (int width, int height) |
Called from the platform-specific callback. You shouldn't call this function directly. | |
void | _platform_on_window_close (GLFWwindow *window) |
Called from the platform-specific callback. You shouldn't call this function directly. | |
void | _platform_on_mouse_button (int button, int action) |
Public Member Functions inherited from engine::core::Controller | |
virtual | ~Controller ()=default |
void | before (Controller *next) |
void | after (Controller *prev) |
const std::vector< Controller * > & | next () const |
bool | is_enabled () const |
Controller will execute as long this function returns true. | |
void | set_enable (bool value) |
Enables or disables the controller based on value. The ControllerManager executes only the enabled controllers, except for the Controller::poll_events function, that's executed always. By default, controllers are enabled when registered. | |
Private Member Functions | |
Key & | key_ref (KeyId key) |
void | initialize () override |
Initializes the platform layer and registers platform-specific event callbacks. | |
void | terminate () override |
Terminate the platform layer. | |
bool | loop () override |
Checks whether the main loop should continue. Executes in the core::App::loop. | |
void | poll_events () override |
Process internal and external events. Executes in the core::App::poll_events. | |
void | update_mouse () |
void | update_key (Key &key_data) const |
Updates the state of a key. Key states are repesented as a state machine with the following states: Released, JustPressed, Pressed, JustReleased. The state machine transitions are as follows: | |
Private Attributes | |
FrameTime | m_frame_time |
Window | m_window |
std::vector< Key > | m_keys |
std::vector< std::unique_ptr< PlatformEventObserver > > | m_platform_event_observers |
Friends | |
class | ControllerManager |
Additional Inherited Members | |
Static Public Member Functions inherited from engine::core::Controller | |
template<typename TController > | |
static TController * | get (std::source_location location=std::source_location::current()) |
Serves as a single access point for all the Controller types throughout the code base. Make sure to register the controller via App::register_controller before calling this function. | |
Registers Platform events such as mouse movement, key press, window events...
const MousePosition & engine::platform::PlatformController::mouse | ( | ) | const |
Get the state of the MousePosition in the current frame.
|
overridevirtual |
Get the name of the Controller.
Reimplemented from engine::core::Controller.
Get the window.
void engine::platform::PlatformController::register_platform_event_observer | ( | std::unique_ptr< PlatformEventObserver > | observer | ) |
Register a PlatformEventObserver callback for platform events. By default, the PlatformController registers a PlatformEventObserver that does nothing.
Get FrameTime for the previous frame. Updated in during core::App::loop.
|
inline |
Get elapsed time for the previous frame.
Enables/disabled the visibility of the cursor on screen.
void engine::platform::PlatformController::swap_buffers | ( | ) |
Swaps the current draw buffer for the main window. Should be called at the end of the frame.
Called from the platform-specific callback. You shouldn't call this function directly.
Called from the platform-specific callback. You shouldn't call this function directly.
Called from the platform-specific callback. You shouldn't call this function directly.
void engine::platform::PlatformController::_platform_on_framebuffer_resize | ( | int | width, |
int | height | ||
) |
Called from the platform-specific callback. You shouldn't call this function directly.
void engine::platform::PlatformController::_platform_on_window_close | ( | GLFWwindow * | window | ) |
Called from the platform-specific callback. You shouldn't call this function directly.
|
overrideprivatevirtual |
Initializes the platform layer and registers platform-specific event callbacks.
Reimplemented from engine::core::Controller.
|
overrideprivatevirtual |
Terminate the platform layer.
Reimplemented from engine::core::Controller.
|
overrideprivatevirtual |
Checks whether the main loop should continue. Executes in the core::App::loop.
Reimplemented from engine::core::Controller.
|
overrideprivatevirtual |
Process internal and external events. Executes in the core::App::poll_events.
Reimplemented from engine::core::Controller.
|
private |
Updates the state of a key. Key states are repesented as a state machine with the following states: Released, JustPressed, Pressed, JustReleased. The state machine transitions are as follows:
key_data | The key to update. |
|
private |
|
private |
|
private |
|
private |