evan 2026.1.4
Evan
Loading...
Searching...
No Matches
evan::MacOsDesktopPlatform Class Reference

MacOS desktop platform implementation. More...

#include <headers/evan/glfw/platform/MacOsDesktopPlatform.hpp>

Inheritance diagram for evan::MacOsDesktopPlatform:
Collaboration diagram for evan::MacOsDesktopPlatform:

Public Member Functions

 MacOsDesktopPlatform (const std::string &name, const uint32_t width, const uint32_t height)
 Constructor for MacOsDesktopPlatform.
 
 ~MacOsDesktopPlatform ()=default
 Destructor for MacOsDesktopPlatform. This destructor ensures proper cleanup of resources associated with the MacOS desktop platform, such as destroying the Vulkan surface and any other resources that were created during initialization.
 
std::vector< std::string > getRequiredInstanceExtensions () const override
 Get the required instance extensions for the MacOS desktop platform.
 
VkInstanceCreateFlags getInstanceCreateFlags () const override
 Get the Vulkan instance creation flags for the MacOS desktop platform.
 
std::vector< std::string > getRequiredDeviceExtensions () const override
 Get the required Vulkan device extensions for the MacOS desktop platform.
 
VkSurfaceKHR createSurface (VkInstance instance) const override
 Create a Vulkan surface for the MacOS desktop platform.
 
- Public Member Functions inherited from evan::IDesktopPlatform
 ~IDesktopPlatform () override
 Destructor for DesktopPlatform.
 
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.
 
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 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.
 

Protected Member Functions

std::filesystem::path getDefaultCacheRoot () const override
 Get the macOS cache root directory.
 

Additional Inherited Members

- Public Attributes inherited from evan::IDesktopPlatform
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.
 
- Protected Attributes inherited from evan::IPlatform
Error _lastError = Error::Ok
 Sticky error recorded by the platform while polling events.
 

Detailed Description

MacOS desktop platform implementation.

This class provides an implementation of the IDesktopPlatform interface specifically for the MacOS desktop environment. It handles platform-specific functionality related to MacOS, such as creating a Vulkan surface using MoltenVK and managing the necessary resources for rendering on MacOS.

Definition at line 25 of file MacOsDesktopPlatform.hpp.

Constructor & Destructor Documentation

◆ MacOsDesktopPlatform()

evan::MacOsDesktopPlatform::MacOsDesktopPlatform ( const std::string &  name,
const uint32_t  width,
const uint32_t  height 
)

Constructor for MacOsDesktopPlatform.

Parameters
nameThe name of the window.
widthThe width of the window.
heightThe height of the window. This constructor initializes the MacOS desktop platform with the specified window parameters, setting up the necessary resources for rendering on MacOS using Vulkan and MoltenVK.

Definition at line 13 of file MacOsDesktopPlatform.cpp.

Member Function Documentation

◆ createSurface()

VkSurfaceKHR evan::MacOsDesktopPlatform::createSurface ( VkInstance  instance) const
overridevirtual

Create a Vulkan surface for the MacOS 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 MacOS desktop platform, allowing rendered images to be presented on the screen. The implementation may involve using MoltenVK's functions to create a window surface that can be used with Vulkan on MacOS.

Implements evan::IDesktopPlatform.

Definition at line 65 of file MacOsDesktopPlatform.cpp.

◆ getDefaultCacheRoot()

std::filesystem::path evan::MacOsDesktopPlatform::getDefaultCacheRoot ( ) const
overrideprotectedvirtual

Get the macOS cache root directory.

Returns
~/Library/Caches, or an empty path when HOME is not set.

Implements evan::IPlatform.

Definition at line 84 of file MacOsDesktopPlatform.cpp.

◆ getInstanceCreateFlags()

VkInstanceCreateFlags evan::MacOsDesktopPlatform::getInstanceCreateFlags ( ) const
overridevirtual

Get the Vulkan instance creation flags for the MacOS desktop platform.

Returns
Flags to OR into VkInstanceCreateInfo::flags.

MoltenVK requires the portability enumeration bit to expose the VK_KHR_portability_subset device extension.

Reimplemented from evan::IPlatform.

Definition at line 53 of file MacOsDesktopPlatform.cpp.

◆ getRequiredDeviceExtensions()

std::vector< std::string > evan::MacOsDesktopPlatform::getRequiredDeviceExtensions ( ) const
overridevirtual

Get the required Vulkan device extensions for the MacOS desktop platform.

Returns
A vector of strings representing the required device extensions.

MoltenVK requires the VK_KHR_portability_subset device extension.

Reimplemented from evan::IPlatform.

Definition at line 59 of file MacOsDesktopPlatform.cpp.

◆ getRequiredInstanceExtensions()

std::vector< std::string > evan::MacOsDesktopPlatform::getRequiredInstanceExtensions ( ) const
overridevirtual

Get the required instance extensions for the MacOS desktop platform.

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

This method retrieves the necessary Vulkan instance extensions required for the MacOS desktop platform, which may include extensions for window surface creation and other platform-specific features related to MoltenVK and Vulkan on MacOS.

Implements evan::IDesktopPlatform.

Definition at line 37 of file MacOsDesktopPlatform.cpp.


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