Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions include/SFML/Graphics/RenderWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
49 changes: 49 additions & 0 deletions include/SFML/System/Alloc.h
Original file line number Diff line number Diff line change
@@ -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 <SFML/System/Export.h>


////////////////////////////////////////////////////////////
/// \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
25 changes: 25 additions & 0 deletions include/SFML/Window/Mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions include/SFML/Window/Touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions include/SFML/Window/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions src/SFML/Graphics/RenderWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);
}
37 changes: 37 additions & 0 deletions src/SFML/System/Alloc.cpp
Original file line number Diff line number Diff line change
@@ -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 <SFML/System/Alloc.h>

#include <stdlib.h>


////////////////////////////////////////////////////////////
void sfFree(void* ptr)
{
free(ptr);
}
2 changes: 2 additions & 0 deletions src/SFML/System/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions src/SFML/Window/Mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Mouse.h>
#include <SFML/Window/WindowBaseStruct.h>
#include <SFML/Window/WindowStruct.h>
#include <SFML/Window/Mouse.hpp>
#include <SFML/Internal.h>
Expand Down Expand Up @@ -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));
}
14 changes: 14 additions & 0 deletions src/SFML/Window/Touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Window/Touch.h>
#include <SFML/Window/Touch.hpp>
#include <SFML/Window/WindowBaseStruct.h>
#include <SFML/Window/WindowStruct.h>
#include <SFML/Internal.h>

Expand All @@ -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;
}
9 changes: 9 additions & 0 deletions src/SFML/Window/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,12 @@ sfWindowHandle sfWindow_getSystemHandle(const sfWindow* window)

return static_cast<sfWindowHandle>(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);
}