diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f9b02c..f4ad729 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,11 @@ csfml_set_option(CMAKE_BUILD_TYPE Release STRING "Choose the type of build (Debu # project name project(CSFML VERSION 3.0.0) +# we use the paths from the cmake GNUInstallDirs module as defaults +# you can override these if you like +# https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html +include(GNUInstallDirs) + # include the configuration file include(${PROJECT_SOURCE_DIR}/cmake/Config.cmake) @@ -68,7 +73,7 @@ endif() csfml_set_option(CSFML_INSTALL_PKGCONFIG_FILES ${CSFML_INSTALL_PKGCONFIG_DEFAULT} BOOL "TRUE to automatically install pkg-config files so other projects can find SFML") if(CSFML_INSTALL_PKGCONFIG_FILES) - csfml_set_option(CSFML_PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${CSFML_PKGCONFIG_DIR}" PATH "Install directory for CSFML's pkg-config .pc files") + csfml_set_option(CSFML_PKGCONFIG_INSTALL_DIR "${CSFML_PKGCONFIG_DIR}" PATH "Install directory for CSFML's pkg-config .pc files") foreach(csfml_module IN ITEMS all system window graphics audio network) configure_file( @@ -76,7 +81,7 @@ if(CSFML_INSTALL_PKGCONFIG_FILES) "tools/pkg-config/csfml-${csfml_module}.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tools/pkg-config/csfml-${csfml_module}.pc" - DESTINATION "${CSFML_PKGCONFIG_INSTALL_PREFIX}") + DESTINATION "${CSFML_PKGCONFIG_INSTALL_DIR}") endforeach() endif() diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 2adaca0..0ce3111 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -14,10 +14,10 @@ endif() # set pkgconfig install directory # this could be e.g. macports on mac or msys2 on windows etc. -set(CSFML_PKGCONFIG_DIR "/${CMAKE_INSTALL_LIBDIR}/pkgconfig") +set(CSFML_PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig") if(SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD) - set(CSFML_PKGCONFIG_DIR "/libdata/pkgconfig") + set(CSFML_PKGCONFIG_DIR "libdata/pkgconfig") endif() # detect the compiler and its version diff --git a/include/SFML/Graphics/Font.h b/include/SFML/Graphics/Font.h index 7a1b19b..2cb299d 100644 --- a/include/SFML/Graphics/Font.h +++ b/include/SFML/Graphics/Font.h @@ -99,6 +99,25 @@ CSFML_GRAPHICS_API void sfFont_destroy(sfFont* font); //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfGlyph sfFont_getGlyph(const sfFont* font, uint32_t codePoint, unsigned int characterSize, bool bold, float outlineThickness); +//////////////////////////////////////////////////////////// +/// \brief Determine if this font has a glyph representing the requested code point +/// +/// Most fonts only include a very limited selection of glyphs from +/// specific Unicode subsets, like Latin, Cyrillic, or Asian characters. +/// +/// While code points without representation will return a font specific +/// default character, it might be useful to verify whether specific +/// code points are included to determine whether a font is suited +/// to display text in a specific language. +/// +/// \param font Source font +/// \param codePoint Unicode code point to check +/// +/// \return True if the codepoint has a glyph representation, sfFalse otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API bool sfFont_hasGlyph(const sfFont* font, uint32_t codePoint); + //////////////////////////////////////////////////////////// /// \brief Get the kerning value corresponding to a given pair of characters in a font /// diff --git a/include/SFML/Graphics/RenderWindow.h b/include/SFML/Graphics/RenderWindow.h index 406d21d..be50442 100644 --- a/include/SFML/Graphics/RenderWindow.h +++ b/include/SFML/Graphics/RenderWindow.h @@ -591,5 +591,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 bool 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 963a6c1..c133cb9 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 a5c9447..3563590 100644 --- a/include/SFML/Window/Touch.h +++ b/include/SFML/Window/Touch.h @@ -57,5 +57,19 @@ CSFML_WINDOW_API bool 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 04b7945..6e40e2e 100644 --- a/include/SFML/Window/Window.h +++ b/include/SFML/Window/Window.h @@ -476,5 +476,18 @@ CSFML_WINDOW_API void sfWindow_display(sfWindow* window); //////////////////////////////////////////////////////////// CSFML_WINDOW_API sfWindowHandle sfWindow_getNativeHandle(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 bool sfWindow_createVulkanSurface(sfWindow* window, const VkInstance* instance, VkSurfaceKHR* surface, const VkAllocationCallbacks* allocator); + #endif // SFML_WINDOW_H diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 780e819..c685283 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -114,6 +114,13 @@ sfGlyph sfFont_getGlyph(const sfFont* font, uint32_t codePoint, unsigned int cha } +//////////////////////////////////////////////////////////// +bool sfFont_hasGlyph(const sfFont* font, uint32_t codePoint) +{ + CSFML_CALL_RETURN(font, hasGlyph(codePoint), false); +} + + //////////////////////////////////////////////////////////// float sfFont_getKerning(const sfFont* font, uint32_t first, uint32_t second, unsigned int characterSize) { diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp index 6e39024..21945de 100644 --- a/src/SFML/Graphics/RenderWindow.cpp +++ b/src/SFML/Graphics/RenderWindow.cpp @@ -549,6 +549,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) { @@ -562,3 +563,12 @@ sfVector2i sfTouch_getPositionRenderWindow(unsigned int finger, const sfRenderWi sfVector2i position = { sfmlPosition.x, sfmlPosition.y }; return position; } + + +//////////////////////////////////////////////////////////// +bool sfRenderWindow_createVulkanSurface(sfRenderWindow* renderWindow, const VkInstance* instance, VkSurfaceKHR* surface, const VkAllocationCallbacks* allocator) +{ + CSFML_CHECK_RETURN(instance, false); + CSFML_CHECK_RETURN(surface, false); + CSFML_CALL_RETURN(renderWindow, createVulkanSurface(*instance, *surface, allocator), false); +} 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 fd81ffd..1147e03 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 57a812f..559a032 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 9d9bd07..05385a4 100644 --- a/src/SFML/Window/Touch.cpp +++ b/src/SFML/Window/Touch.cpp @@ -27,6 +27,7 @@ //////////////////////////////////////////////////////////// #include #include +#include #include #include @@ -50,3 +51,17 @@ sfVector2i sfTouch_getPosition(unsigned int finger, const sfWindow* relativeTo) sfVector2i position = {sfmlPosition.x, sfmlPosition.y}; 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 73792a8..bb583aa 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -322,3 +322,12 @@ sfWindowHandle sfWindow_getNativeHandle(const sfWindow* window) return static_cast(window->This.getNativeHandle()); } + + +//////////////////////////////////////////////////////////// +bool sfWindow_createVulkanSurface(sfWindow* window, const VkInstance* instance, VkSurfaceKHR* surface, const VkAllocationCallbacks* allocator) +{ + CSFML_CHECK_RETURN(instance, false); + CSFML_CHECK_RETURN(surface, false); + CSFML_CALL_RETURN(window, createVulkanSurface(*instance, *surface, allocator), false); +}