class
#include <core/io/window.hpp>
BaseWindow Interface used to wrap low-level window API implementations.
Allows polling of input events and creates a gl::
Public functions
- void pushEvent(WindowEvent&& event)
- Pushes an event to the event queue.
- auto pollEvent() -> std::optional<WindowEvent>
- Polls the window for events.
- void swapBuffers() pure virtual
- Swaps the window buffers.
-
auto renderDevice() const -> gl::
RenderDevice& pure virtual - Gets the render device associated with this window.
- auto size() const -> glm::uvec2 pure virtual
- Gets the window size, which may differ from the framebuffer size.
- auto framebufferSize() const -> glm::uvec2 pure virtual
- Gets the window framebuffer size, which may differ from the window size.
- auto contentScale() const -> float pure virtual
- Gets the window content scale, commonly known as "DPI scale".
- auto shouldClose() const -> bool pure virtual
- Checks whether the window should close.
- auto time() const -> double pure virtual
- Gets the time since the window was created.
- void mouseState(MouseState state) pure virtual
- Sets the mouse state when the window is focused.
- auto mouseState() const -> MouseState pure virtual
- Gets the mouse state when the window is focused.
- auto getMousePosition() -> glm::ivec2 pure virtual
- Gets the position of the mouse cursor.
- void setMousePosition(glm::ivec2 position) pure virtual
- Sets the position of the mouse cursor.
-
auto createCursor(Cursor::
Standard standard) -> std::shared_ptr<Cursor> pure virtual - Creates a new cursor with a standard shape.
- void cursor(std::shared_ptr<Cursor> cursor) pure virtual
- Sets the current cursor. Pass nullptr to use the default cursor.
- void clipboard(const std::string& text) pure virtual
- Sets the content of the clipboard.
- auto clipboard() const -> const char* pure virtual
- Gets the content of the clipboard.
- auto modifiers() const -> Modifiers pure virtual
- Gets the last used keyboard modifiers.
-
auto pressed(Key key,
Modifiers modifiers = Modifiers::
None) const -> bool pure virtual - Checks if a key is currently pressed with (at least) the given modifiers.
- auto pressed(MouseButton button) const -> bool pure virtual
- Checks if a mouse button is currently pressed.
- auto gamepadState(int gamepad, GamepadState& state) const -> bool pure virtual
- Gets the state of the specified gamepad.
Protected functions
- void pollEvents() pure virtual
- Asks the implementation to fill the event queue with new events.
Function documentation
void cubos:: core:: io:: BaseWindow:: pushEvent(WindowEvent&& event)
Pushes an event to the event queue.
Parameters | |
---|---|
event | Event to push. |
std::optional<WindowEvent> cubos:: core:: io:: BaseWindow:: pollEvent()
Polls the window for events.
Returns | Next event, or std::nullopt if there are no more events. |
---|
gl:: RenderDevice& cubos:: core:: io:: BaseWindow:: renderDevice() const pure virtual
Gets the render device associated with this window.
Returns | Render device associated with this window. |
---|
glm::uvec2 cubos:: core:: io:: BaseWindow:: size() const pure virtual
Gets the window size, which may differ from the framebuffer size.
Returns | Window size, in screen coordinates. |
---|
glm::uvec2 cubos:: core:: io:: BaseWindow:: framebufferSize() const pure virtual
Gets the window framebuffer size, which may differ from the window size.
Returns | Window framebuffer size, in pixels. |
---|
float cubos:: core:: io:: BaseWindow:: contentScale() const pure virtual
Gets the window content scale, commonly known as "DPI scale".
Returns | Ratio between the current DPI and the platform's default DPI. |
---|
bool cubos:: core:: io:: BaseWindow:: shouldClose() const pure virtual
Checks whether the window should close.
Returns | Whether the window should close. |
---|
double cubos:: core:: io:: BaseWindow:: time() const pure virtual
Gets the time since the window was created.
Returns | Time since the window was created, in seconds. |
---|
void cubos:: core:: io:: BaseWindow:: mouseState(MouseState state) pure virtual
Sets the mouse state when the window is focused.
Parameters | |
---|---|
state | Mouse state. |
MouseState cubos:: core:: io:: BaseWindow:: mouseState() const pure virtual
Gets the mouse state when the window is focused.
Returns | Mouse state when the window is focused. |
---|
glm::ivec2 cubos:: core:: io:: BaseWindow:: getMousePosition() pure virtual
Gets the position of the mouse cursor.
Returns | Position of the mouse cursor, in screen coordinates. |
---|
void cubos:: core:: io:: BaseWindow:: setMousePosition(glm::ivec2 position) pure virtual
Sets the position of the mouse cursor.
Parameters | |
---|---|
position | New position of the mouse cursor, in screen coordinates. |
std::shared_ptr<Cursor> cubos:: core:: io:: BaseWindow:: createCursor(Cursor:: Standard standard) pure virtual
Creates a new cursor with a standard shape.
Parameters | |
---|---|
standard | Standard cursor to use. |
Returns | New cursor, or nullptr if creation failed. |
void cubos:: core:: io:: BaseWindow:: clipboard(const std::string& text) pure virtual
Sets the content of the clipboard.
Parameters | |
---|---|
text | New clipboard text. |
const char* cubos:: core:: io:: BaseWindow:: clipboard() const pure virtual
Gets the content of the clipboard.
Returns | Text from the clipboard. Guaranteed to be valid until the next call. |
---|
bool cubos:: core:: io:: BaseWindow:: pressed(Key key,
Modifiers modifiers = Modifiers:: None) const pure virtual
Checks if a key is currently pressed with (at least) the given modifiers.
Parameters | |
---|---|
key | Key to check. |
modifiers | Modifiers to check. |
Returns | Whether the key and modifiers (or a superset of) are currently pressed. |
bool cubos:: core:: io:: BaseWindow:: pressed(MouseButton button) const pure virtual
Checks if a mouse button is currently pressed.
Parameters | |
---|---|
button | Mouse button to check. |
Returns | Whether the mouse button is currently pressed. |
bool cubos:: core:: io:: BaseWindow:: gamepadState(int gamepad,
GamepadState& state) const pure virtual
Gets the state of the specified gamepad.
Parameters | |
---|---|
gamepad | Gamepad to get the state of. |
state | State to fill with the gamepad state. |
Returns | Whether the gamepad was found. |