diff --git a/include/SFML/Graphics/RenderWindow.h b/include/SFML/Graphics/RenderWindow.h index 9838bbc..fb14d21 100644 --- a/include/SFML/Graphics/RenderWindow.h +++ b/include/SFML/Graphics/RenderWindow.h @@ -618,5 +618,18 @@ CSFML_GRAPHICS_API void sfMouse_setPositionRenderWindow(sfVector2i position, con //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfVector2i sfTouch_getPositionRenderWindow(unsigned int finger, const sfRenderWindow* relativeTo); +//////////////////////////////////////////////////////////// +/// \brief Create a Vulkan rendering surface +/// +/// \param renderWindow RenderWindow object +/// \param instance Vulkan instance +/// \param surface Created surface +/// \param allocator Allocator to use +/// +/// \return True if surface creation was successful, false otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfBool sfRenderWindow_createVulkanSurface(sfRenderWindow* renderWindow, const VkInstance* instance, VkSurfaceKHR* surface, const VkAllocationCallbacks* allocator); + #endif // SFML_RENDERWINDOW_H diff --git a/include/SFML/System/Alloc.h b/include/SFML/System/Alloc.h new file mode 100644 index 0000000..fabaf38 --- /dev/null +++ b/include/SFML/System/Alloc.h @@ -0,0 +1,49 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_ALLOC_H +#define SFML_ALLOC_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// \brief Deallocates memory +/// +/// This function deallocates the memory being pointed to +/// using the free function from the C standard library. +/// +/// The memory must have been previously allocated using a call +/// to malloc. +/// +/// \param ptr Pointer to the memory to deallocate +/// +//////////////////////////////////////////////////////////// +CSFML_SYSTEM_API void sfFree(void* ptr); + + +#endif // SFML_ALLOC_H diff --git a/include/SFML/Window/Mouse.h b/include/SFML/Window/Mouse.h index d0a0a7a..566754f 100644 --- a/include/SFML/Window/Mouse.h +++ b/include/SFML/Window/Mouse.h @@ -94,5 +94,30 @@ CSFML_WINDOW_API sfVector2i sfMouse_getPosition(const sfWindow* relativeTo); //////////////////////////////////////////////////////////// CSFML_WINDOW_API void sfMouse_setPosition(sfVector2i position, const sfWindow* relativeTo); +//////////////////////////////////////////////////////////// +/// \brief Get the current position of the mouse relative to a window base +/// +/// This function returns the current position of the mouse +/// cursor relative to the given window base, or desktop if NULL is passed. +/// +/// \param relativeTo Reference window +/// +/// \return Position of the mouse cursor, relative to the given window base +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API sfVector2i sfMouse_getPositionWindowBase(const sfWindowBase* relativeTo); + +//////////////////////////////////////////////////////////// +/// \brief Set the current position of the mouse relative to a window base +/// +/// This function sets the current position of the mouse +/// cursor relative to the given window base, or desktop if NULL is passed. +/// +/// \param position New position of the mouse +/// \param relativeTo Reference window +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API void sfMouse_setPositionWindowBase(sfVector2i position, const sfWindowBase* relativeTo); + #endif // SFML_MOUSE_H diff --git a/include/SFML/Window/Touch.h b/include/SFML/Window/Touch.h index 137da14..9e0a5d7 100644 --- a/include/SFML/Window/Touch.h +++ b/include/SFML/Window/Touch.h @@ -57,5 +57,19 @@ CSFML_WINDOW_API sfBool sfTouch_isDown(unsigned int finger); //////////////////////////////////////////////////////////// CSFML_WINDOW_API sfVector2i sfTouch_getPosition(unsigned int finger, const sfWindow* relativeTo); +//////////////////////////////////////////////////////////// +/// \brief Get the current position of a touch in window coordinates +/// +/// This function returns the current touch position +/// relative to the given window base, or desktop if NULL is passed. +/// +/// \param finger Finger index +/// \param relativeTo Reference window +/// +/// \return Current position of \a finger, or undefined if it's not down +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API sfVector2i sfTouch_getPositionWindowBase(unsigned int finger, const sfWindowBase* relativeTo); + #endif // SFML_TOUCH_H diff --git a/include/SFML/Window/Window.h b/include/SFML/Window/Window.h index d02756a..9db90f6 100644 --- a/include/SFML/Window/Window.h +++ b/include/SFML/Window/Window.h @@ -474,5 +474,18 @@ CSFML_WINDOW_API void sfWindow_display(sfWindow* window); //////////////////////////////////////////////////////////// CSFML_WINDOW_API sfWindowHandle sfWindow_getSystemHandle(const sfWindow* window); +//////////////////////////////////////////////////////////// +/// \brief Create a Vulkan rendering surface +/// +/// \param window Window object +/// \param instance Vulkan instance +/// \param surface Created surface +/// \param allocator Allocator to use +/// +/// \return True if surface creation was successful, false otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API sfBool sfWindow_createVulkanSurface(sfWindow* window, const VkInstance* instance, VkSurfaceKHR* surface, const VkAllocationCallbacks* allocator); + #endif // SFML_WINDOW_H diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp index 1c1e6aa..e9cb4e3 100644 --- a/src/SFML/Graphics/RenderWindow.cpp +++ b/src/SFML/Graphics/RenderWindow.cpp @@ -561,6 +561,7 @@ void sfMouse_setPositionRenderWindow(sfVector2i position, const sfRenderWindow* sf::Mouse::setPosition(sf::Vector2i(position.x, position.y)); } + //////////////////////////////////////////////////////////// sfVector2i sfTouch_getPositionRenderWindow(unsigned int finger, const sfRenderWindow* relativeTo) { @@ -574,3 +575,12 @@ sfVector2i sfTouch_getPositionRenderWindow(unsigned int finger, const sfRenderWi sfVector2i position = { sfmlPosition.x, sfmlPosition.y }; return position; } + + +//////////////////////////////////////////////////////////// +sfBool sfRenderWindow_createVulkanSurface(sfRenderWindow* renderWindow, const VkInstance* instance, VkSurfaceKHR* surface, const VkAllocationCallbacks* allocator) +{ + CSFML_CHECK_RETURN(instance, sfFalse); + CSFML_CHECK_RETURN(surface, sfFalse); + CSFML_CALL_RETURN(renderWindow, createVulkanSurface(*instance, *surface, allocator), sfFalse); +} diff --git a/src/SFML/System/Alloc.cpp b/src/SFML/System/Alloc.cpp new file mode 100644 index 0000000..e121e24 --- /dev/null +++ b/src/SFML/System/Alloc.cpp @@ -0,0 +1,37 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + +#include + + +//////////////////////////////////////////////////////////// +void sfFree(void* ptr) +{ + free(ptr); +} diff --git a/src/SFML/System/CMakeLists.txt b/src/SFML/System/CMakeLists.txt index 2ea169c..e29a0dd 100644 --- a/src/SFML/System/CMakeLists.txt +++ b/src/SFML/System/CMakeLists.txt @@ -6,6 +6,8 @@ set(SRCROOT ${PROJECT_SOURCE_DIR}/src/SFML/System) set(SRC ${PROJECT_SOURCE_DIR}/include/SFML/GPUPreference.h ${INCROOT}/Export.h + ${SRCROOT}/Alloc.cpp + ${INCROOT}/Alloc.h ${SRCROOT}/Buffer.cpp ${SRCROOT}/BufferStruct.h ${INCROOT}/Buffer.h diff --git a/src/SFML/Window/Mouse.cpp b/src/SFML/Window/Mouse.cpp index 71977be..ac0a848 100644 --- a/src/SFML/Window/Mouse.cpp +++ b/src/SFML/Window/Mouse.cpp @@ -26,6 +26,7 @@ // Headers //////////////////////////////////////////////////////////// #include +#include #include #include #include @@ -60,3 +61,27 @@ void sfMouse_setPosition(sfVector2i position, const sfWindow* relativeTo) else sf::Mouse::setPosition(sf::Vector2i(position.x, position.y)); } + + +//////////////////////////////////////////////////////////// +sfVector2i sfMouse_getPositionWindowBase(const sfWindowBase* relativeTo) +{ + sf::Vector2i sfmlPos; + if (relativeTo) + sfmlPos = sf::Mouse::getPosition(relativeTo->This); + else + sfmlPos = sf::Mouse::getPosition(); + + sfVector2i position = { sfmlPos.x, sfmlPos.y }; + return position; +} + + +//////////////////////////////////////////////////////////// +void sfMouse_setPositionWindowBase(sfVector2i position, const sfWindowBase* relativeTo) +{ + if (relativeTo) + sf::Mouse::setPosition(sf::Vector2i(position.x, position.y), relativeTo->This); + else + sf::Mouse::setPosition(sf::Vector2i(position.x, position.y)); +} diff --git a/src/SFML/Window/Touch.cpp b/src/SFML/Window/Touch.cpp index f58accf..df4fa8b 100644 --- a/src/SFML/Window/Touch.cpp +++ b/src/SFML/Window/Touch.cpp @@ -27,6 +27,7 @@ //////////////////////////////////////////////////////////// #include #include +#include #include #include @@ -51,3 +52,16 @@ sfVector2i sfTouch_getPosition(unsigned int finger, const sfWindow* relativeTo) return position; } +//////////////////////////////////////////////////////////// +sfVector2i sfTouch_getPositionWindowBase(unsigned int finger, const sfWindowBase* relativeTo) +{ + sf::Vector2i sfmlPosition; + + if (relativeTo) + sfmlPosition = sf::Touch::getPosition(finger, relativeTo->This); + else + sfmlPosition = sf::Touch::getPosition(finger); + + sfVector2i position = { sfmlPosition.x, sfmlPosition.y }; + return position; +} diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 9390c0b..f11b2da 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -322,3 +322,12 @@ sfWindowHandle sfWindow_getSystemHandle(const sfWindow* window) return static_cast(window->This.getSystemHandle()); } + + +//////////////////////////////////////////////////////////// +sfBool sfWindow_createVulkanSurface(sfWindow* window, const VkInstance* instance, VkSurfaceKHR* surface, const VkAllocationCallbacks* allocator) +{ + CSFML_CHECK_RETURN(instance, sfFalse); + CSFML_CHECK_RETURN(surface, sfFalse); + CSFML_CALL_RETURN(window, createVulkanSurface(*instance, *surface, allocator), sfFalse); +}