evan 2026.1.4
Evan
Loading...
Searching...
No Matches
evan::IDesktopPlatform Class Referenceabstract

Desktop platform implementation. More...

#include <headers/evan/glfw/IDesktopPlatform.hpp>

Inheritance diagram for evan::IDesktopPlatform:
Collaboration diagram for evan::IDesktopPlatform:

Public Member Functions

 ~IDesktopPlatform () override
 Destructor for DesktopPlatform.
 
virtual std::vector< std::string > getRequiredInstanceExtensions () const override=0
 Get the required instance extensions for the Desktop platform.
 
bool shouldClose () const override
 Check if the Desktop platform should close.
 
virtual std::vector< std::shared_ptr< utility::event::Event > > pollEvents (ADeviceBackend &deviceBackend) override
 Poll events for the Desktop platform.
 
virtual VkSurfaceKHR createSurface (VkInstance instance) const =0
 Create a Vulkan surface for the Desktop platform.
 
std::shared_ptr< ADeviceBackend > createDeviceBackend () const override
 Create a device context for the Desktop platform.
 
std::shared_ptr< ASwapchainContext > createSwapchainContext (const DeviceContext &deviceContext) const override
 Create a swapchain context for the Desktop platform.
 
utility::event::KeyboardEvent::KeyCode convertGlfwKeyToKeyCode (int glfwKey) const
 Convert a GLFW key code to a KeyboardEvent::KeyCode.
 
utility::event::MouseButtonEvent::Button convertGlfwMouseButtonToButton (int glfwMouseButton) const
 Convert a GLFW mouse button code to a MouseButtonEvent::Button.
 
utility::event::KeyboardEvent::KeyModifiers convertGlfwModsToKeyModifiers (int glfwMods) const
 Convert GLFW modifier flags to KeyModifiers.
 
utility::event::MouseMotionEvent::MousePosition getMousePosition () const
 Get the current mouse position.
 
utility::event::MouseMotionEvent::MousePosition convertCursorPosition (double xPos, double yPos) const
 Convert a GLFW cursor position to framebuffer coordinates.
 
std::vector< std::shared_ptr< utility::event::KeyboardEvent > > getPressedMovementKeys () const
 Get the current state of movement keys.
 
- Public Member Functions inherited from evan::IPlatform
virtual ~IPlatform ()=default
 Virtual destructor.
 
virtual VkInstanceCreateFlags getInstanceCreateFlags () const
 Get platform-specific Vulkan instance creation flags.
 
virtual std::vector< std::string > getRequiredDeviceExtensions () const
 Get platform-specific required Vulkan device extensions.
 
virtual std::filesystem::path getPipelineCachePath () const
 Get the path where the Vulkan pipeline cache is persisted.
 
Error getLastError () const
 Get the last error recorded by the platform.
 

Public Attributes

GLFWwindow * _window = nullptr
 Currently active GLFW window for the Desktop platform.
 
std::vector< std::shared_ptr< utility::event::KeyboardEvent > > _keyboardEvents
 Vector to store keyboard events.
 
std::vector< std::shared_ptr< utility::event::MouseButtonEvent > > _mouseButtonEvents
 Vector to store mouse button events.
 
std::vector< std::shared_ptr< utility::event::MouseMotionEvent > > _mouseMotionEvents
 Vector to store mouse motion events.
 
std::vector< std::shared_ptr< utility::event::MouseWheelEvent > > _mouseWheelEvents
 Vector to store mouse wheel events.
 
std::vector< std::shared_ptr< utility::event::CursorEnterEvent > > _cursorEnterEvents
 Vector to store cursor enter/leave events.
 
std::vector< std::shared_ptr< utility::event::FileDropEvent > > _fileDropEvents
 Vector to store file drop events.
 
std::vector< std::shared_ptr< utility::event::TextInputEvent > > _textInputEvents
 Vector to store text input events.
 

Additional Inherited Members

- Protected Member Functions inherited from evan::IPlatform
virtual std::filesystem::path getDefaultCacheRoot () const =0
 Get the platform-specific cache root directory.
 
- Protected Attributes inherited from evan::IPlatform
Error _lastError = Error::Ok
 Sticky error recorded by the platform while polling events.
 

Detailed Description

Desktop platform implementation.

This class provides an implementation of the IPlatform interface for Desktop. It handles platform-specific functionality related to Desktop using GLFW for window management and event handling.

Definition at line 34 of file IDesktopPlatform.hpp.

Constructor & Destructor Documentation

◆ ~IDesktopPlatform()

evan::IDesktopPlatform::~IDesktopPlatform ( )
override

Destructor for DesktopPlatform.

Ensures proper cleanup of Desktop resources.

Definition at line 13 of file IDesktopPlatform.cpp.

Member Function Documentation

◆ convertCursorPosition()

utility::event::MouseMotionEvent::MousePosition evan::IDesktopPlatform::convertCursorPosition ( double  xPos,
double  yPos 
) const

Convert a GLFW cursor position to framebuffer coordinates.

GLFW reports cursor positions in screen coordinates (points on high-DPI displays), while the swapchain viewport is sized in framebuffer pixels. Scaling keeps ray picking and the debug pointer aligned with the on-screen mouse cursor.

Parameters
xPosHorizontal cursor position in screen coordinates.
yPosVertical cursor position in screen coordinates.
Returns
Cursor position in framebuffer pixel coordinates.

Definition at line 246 of file IDesktopPlatform.cpp.

◆ convertGlfwKeyToKeyCode()

utility::event::KeyboardEvent::KeyCode evan::IDesktopPlatform::convertGlfwKeyToKeyCode ( int  glfwKey) const

Convert a GLFW key code to a KeyboardEvent::KeyCode.

Parameters
glfwKeyThe GLFW key code to convert.
Returns
The corresponding KeyboardEvent::KeyCode for the given GLFW key code.

Definition at line 184 of file IDesktopPlatform.cpp.

◆ convertGlfwModsToKeyModifiers()

utility::event::KeyboardEvent::KeyModifiers evan::IDesktopPlatform::convertGlfwModsToKeyModifiers ( int  glfwMods) const

Convert GLFW modifier flags to KeyModifiers.

Parameters
glfwModsThe GLFW modifier flags to convert.
Returns
The corresponding KeyModifiers for the given GLFW modifier flags.

Definition at line 211 of file IDesktopPlatform.cpp.

◆ convertGlfwMouseButtonToButton()

utility::event::MouseButtonEvent::Button evan::IDesktopPlatform::convertGlfwMouseButtonToButton ( int  glfwMouseButton) const

Convert a GLFW mouse button code to a MouseButtonEvent::Button.

Parameters
glfwMouseButtonThe GLFW mouse button code to convert.
Returns
The corresponding MouseButtonEvent::Button for the given GLFW mouse button code.

Definition at line 190 of file IDesktopPlatform.cpp.

◆ createDeviceBackend()

std::shared_ptr< evan::ADeviceBackend > evan::IDesktopPlatform::createDeviceBackend ( ) const
overridevirtual

Create a device context for the Desktop platform.

Returns
A shared pointer to the created device context for the Desktop platform.

This method creates a device context specific to the Desktop platform, which is responsible for managing Vulkan device resources and operations. The implementation may involve initializing Vulkan and setting up the necessary resources for rendering on the Desktop environment.

Implements evan::IPlatform.

Definition at line 30 of file IDesktopPlatform.cpp.

◆ createSurface()

virtual VkSurfaceKHR evan::IDesktopPlatform::createSurface ( VkInstance  instance) const
pure virtual

Create a Vulkan surface for the Desktop platform.

Parameters
instanceThe Vulkan instance to use for creating the surface.
Returns
The created Vulkan surface handle.

This method creates a Vulkan surface that is compatible with the Desktop platform, allowing rendered images to be presented on the screen. The implementation may involve using GLFW's functions to create a window surface that can be used with Vulkan.

Implemented in evan::LinuxDesktopPlatform, evan::MacOsDesktopPlatform, and evan::WindowsDesktopPlatform.

◆ createSwapchainContext()

std::shared_ptr< evan::ASwapchainContext > evan::IDesktopPlatform::createSwapchainContext ( const DeviceContext &  deviceContext) const
overridevirtual

Create a swapchain context for the Desktop platform.

Parameters
deviceContextThe device context to use for creating the swapchain context.
Returns
A shared pointer to the created swapchain context.

This method creates a swapchain context specific to the Desktop platform, which is responsible for managing the presentation of rendered images to the screen. The implementation may involve creating a Vulkan swapchain and associated resources tailored to the Desktop environment.

Implements evan::IPlatform.

Definition at line 38 of file IDesktopPlatform.cpp.

Here is the call graph for this function:

◆ getMousePosition()

utility::event::MouseMotionEvent::MousePosition evan::IDesktopPlatform::getMousePosition ( ) const

Get the current mouse position.

Returns
The current mouse position as a MousePosition (2D vector).

This method retrieves the current position of the mouse cursor on the screen, which can be used for handling mouse motion events and interactions within the application.

Definition at line 236 of file IDesktopPlatform.cpp.

◆ getPressedMovementKeys()

std::vector< std::shared_ptr< utility::event::KeyboardEvent > > evan::IDesktopPlatform::getPressedMovementKeys ( ) const

Get the current state of movement keys.

Polls the current state of movement keys (WASD, QE, arrows) and returns keyboard events for keys that are currently pressed. This enables continuous movement while holding keys.

Returns
Vector of keyboard events for currently pressed movement keys.

Definition at line 273 of file IDesktopPlatform.cpp.

◆ getRequiredInstanceExtensions()

std::vector< std::string > evan::IDesktopPlatform::getRequiredInstanceExtensions ( ) const
overridepure virtual

Get the required instance extensions for the Desktop platform.

Returns
A vector of strings representing the required instance extensions for the Desktop platform.

This method retrieves the necessary Vulkan instance extensions required for the Desktop platform, which may include extensions for window surface creation and other platform-specific features.

Implements evan::IPlatform.

Implemented in evan::LinuxDesktopPlatform, evan::MacOsDesktopPlatform, and evan::WindowsDesktopPlatform.

Definition at line 156 of file IDesktopPlatform.cpp.

◆ pollEvents()

std::vector< std::shared_ptr< utility::event::Event > > evan::IDesktopPlatform::pollEvents ( ADeviceBackend &  deviceBackend)
overridevirtual

Poll events for the Desktop platform.

Parameters
deviceBackendThe device backend to use for polling events.

This method processes events for the Desktop platform, such as user input and window events, using the provided device backend. It ensures that the application remains responsive to user interactions and system events.

Note: The implementation of this method may involve using GLFW's event polling functions to handle events specific to the Desktop platform.

Returns
A vector of shared pointers to Event objects representing the events that were polled from the Desktop platform. Each Event object contains information about the type of event, such as input events.

Implements evan::IPlatform.

Definition at line 65 of file IDesktopPlatform.cpp.

◆ shouldClose()

bool evan::IDesktopPlatform::shouldClose ( ) const
overridevirtual

Check if the Desktop platform should close.

Returns
true if the Desktop platform should close, false otherwise.

Implements evan::IPlatform.

Definition at line 177 of file IDesktopPlatform.cpp.

Member Data Documentation

◆ _cursorEnterEvents

std::vector<std::shared_ptr<utility::event::CursorEnterEvent> > evan::IDesktopPlatform::_cursorEnterEvents

Vector to store cursor enter/leave events.

This vector holds unique pointers to CursorEnterEvent objects, which represent cursor enter/leave events that have been polled from the GLFW event system. Each CursorEnterEvent contains information about whether the cursor entered or left the window's content area.

Definition at line 270 of file IDesktopPlatform.hpp.

◆ _fileDropEvents

std::vector<std::shared_ptr<utility::event::FileDropEvent> > evan::IDesktopPlatform::_fileDropEvents

Vector to store file drop events.

This vector holds unique pointers to FileDropEvent objects, which represent file drop events that have been polled from the GLFW event system. Each FileDropEvent contains information about the paths of files and/or directories dropped on the window.

Definition at line 281 of file IDesktopPlatform.hpp.

◆ _keyboardEvents

std::vector<std::shared_ptr<utility::event::KeyboardEvent> > evan::IDesktopPlatform::_keyboardEvents

Vector to store keyboard events.

This vector holds unique pointers to KeyboardEvent objects, which represent keyboard input events that have been polled from the GLFW event system. Each KeyboardEvent contains information about the key that was pressed or released, as well as any modifier keys that were active at the time of the event. This allows the application to process keyboard input in a structured way, responding to user interactions effectively.

Definition at line 220 of file IDesktopPlatform.hpp.

◆ _mouseButtonEvents

std::vector<std::shared_ptr<utility::event::MouseButtonEvent> > evan::IDesktopPlatform::_mouseButtonEvents

Vector to store mouse button events.

This vector holds unique pointers to MouseButtonEvent objects, which represent mouse button input events that have been polled from the GLFW event system. Each MouseButtonEvent contains information about which mouse button was pressed or released, as well as the current state of all mouse buttons and the position of the mouse cursor at the time of the event. This allows the application to process mouse button input in a structured way, responding to user interactions effectively.

Definition at line 235 of file IDesktopPlatform.hpp.

◆ _mouseMotionEvents

std::vector<std::shared_ptr<utility::event::MouseMotionEvent> > evan::IDesktopPlatform::_mouseMotionEvents

Vector to store mouse motion events.

This vector holds unique pointers to MouseMotionEvent objects, which represent mouse motion events that have been polled from the GLFW event system. Each MouseMotionEvent contains information about the current position of the mouse cursor, allowing the application to respond to mouse movement and interactions effectively.

Definition at line 247 of file IDesktopPlatform.hpp.

◆ _mouseWheelEvents

std::vector<std::shared_ptr<utility::event::MouseWheelEvent> > evan::IDesktopPlatform::_mouseWheelEvents

Vector to store mouse wheel events.

This vector holds unique pointers to MouseWheelEvent objects, which represent mouse wheel scroll events that have been polled from the GLFW event system. Each MouseWheelEvent contains information about the scroll offset, allowing the application to respond to mouse wheel scrolling interactions effectively.

Definition at line 259 of file IDesktopPlatform.hpp.

◆ _textInputEvents

std::vector<std::shared_ptr<utility::event::TextInputEvent> > evan::IDesktopPlatform::_textInputEvents

Vector to store text input events.

This vector holds unique pointers to TextInputEvent objects, which represent text input events that have been polled from the GLFW event system. Each TextInputEvent contains committed UTF-8 text input from the operating system's text input system.

Definition at line 292 of file IDesktopPlatform.hpp.

◆ _window

GLFWwindow* evan::IDesktopPlatform::_window = nullptr

Currently active GLFW window for the Desktop platform.

Definition at line 206 of file IDesktopPlatform.hpp.


The documentation for this class was generated from the following files: