Compile CSFML with SFML 3.0

This commit is contained in:
Miron Alexandru authored and Chris Thrasher committed 2024-03-28 17:59:11 -06:00
1 parent 0d292bdb3c
commit 61bcbc5906
62 files changed
+431 -655

No files matched your search

+1 -1
View File
@@ -42,7 +42,7 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
repository: SFML/SFML repository: SFML/SFML
ref: 2.6.0 ref: master
path: SFML path: SFML
- name: Configure SFML CMake - name: Configure SFML CMake
+3
View File
@@ -41,5 +41,8 @@ cmake-build-*/
.idea/ .idea/
.vs/ .vs/
# CMake User Presets
CMakeUserPresets.json
# System files # System files
.DS_Store .DS_Store
+3 -5
View File
@@ -7,7 +7,7 @@ int main(void)
{ {
// Create the main window // Create the main window
const sfVideoMode mode = {800, 600, 32}; const sfVideoMode mode = {800, 600, 32};
sfRenderWindow* window = sfRenderWindow_create(mode, "SFML window", sfResize | sfClose, NULL); sfRenderWindow* window = sfRenderWindow_create(mode, "SFML window", sfResize | sfClose, sfWindowed, NULL);
if (!window) if (!window)
return EXIT_FAILURE; return EXIT_FAILURE;
@@ -18,8 +18,7 @@ int main(void)
sfRenderWindow_destroy(window); sfRenderWindow_destroy(window);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
sfSprite* sprite = sfSprite_create(); sfSprite* sprite = sfSprite_create(texture);
sfSprite_setTexture(sprite, texture, true);
const sfVector2f spritePosition = {200, 200}; const sfVector2f spritePosition = {200, 200};
sfSprite_setPosition(sprite, spritePosition); sfSprite_setPosition(sprite, spritePosition);
@@ -32,9 +31,8 @@ int main(void)
sfRenderWindow_destroy(window); sfRenderWindow_destroy(window);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
sfText* text = sfText_create(); sfText* text = sfText_create(font);
sfText_setString(text, "Hello, SFML!"); sfText_setString(text, "Hello, SFML!");
sfText_setFont(text, font);
sfText_setCharacterSize(text, 50); sfText_setCharacterSize(text, 50);
// Load a music to play // Load a music to play
+3 -1
View File
@@ -37,11 +37,13 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create a new sound /// \brief Create a new sound
///
/// \param soundBuffer Sound buffer containing the audio data to play with the sound
/// ///
/// \return A new sfSound object /// \return A new sfSound object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_AUDIO_API sfSound* sfSound_create(void); CSFML_AUDIO_API sfSound* sfSound_create(const sfSoundBuffer* buffer);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create a new sound by copying an existing one /// \brief Create a new sound by copying an existing one
+10
View File
@@ -142,4 +142,14 @@
#endif #endif
////////////////////////////////////////////////////////////
/// Define sfChar32
///
/// Work around macOS not providing <uchar.h>
////////////////////////////////////////////////////////////
#include <stdint.h>
typedef uint32_t sfChar32;
#endif // SFML_CONFIG_H #endif // SFML_CONFIG_H
+3 -1
View File
@@ -224,9 +224,11 @@ CSFML_GRAPHICS_API void sfImage_createMaskFromColor(sfImage* image, sfColor colo
/// \param destY Y coordinate of the destination position /// \param destY Y coordinate of the destination position
/// \param sourceRect Sub-rectangle of the source image to copy /// \param sourceRect Sub-rectangle of the source image to copy
/// \param applyAlpha Should the copy take in account the source transparency? /// \param applyAlpha Should the copy take in account the source transparency?
///
/// \return True if the operation was successful, false otherwise
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfImage_copyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect, bool applyAlpha); CSFML_GRAPHICS_API bool sfImage_copyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect, bool applyAlpha);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change the color of a pixel in an image /// \brief Change the color of a pixel in an image
+1 -16
View File
@@ -40,21 +40,6 @@
#include <stddef.h> #include <stddef.h>
////////////////////////////////////////////////////////////
/// \brief Construct a new render texture
///
/// \param width Width of the render texture
/// \param height Height of the render texture
/// \param depthBuffer Do you want a depth-buffer attached? (useful only if you're doing 3D OpenGL on the rendertexture)
///
/// \return A new sfRenderTexture object, or NULL if it failed
///
/// \deprecated
/// Use sfRenderTexture_createWithSettings instead.
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_create(unsigned int width, unsigned int height, bool depthBuffer);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Construct a new render texture /// \brief Construct a new render texture
/// ///
@@ -65,7 +50,7 @@ CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_create(unsigned int width, u
/// \return A new sfRenderTexture object, or NULL if it failed /// \return A new sfRenderTexture object, or NULL if it failed
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_createWithSettings(unsigned int width, unsigned int height, const sfContextSettings* settings); CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_create(unsigned int width, unsigned int height, const sfContextSettings* settings);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Destroy an existing render texture /// \brief Destroy an existing render texture
+4 -4
View File
@@ -52,7 +52,7 @@
/// \param settings Creation settings (pass NULL to use default values) /// \param settings Creation settings (pass NULL to use default values)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const char* title, uint32_t style, const sfContextSettings* settings); CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const char* title, uint32_t style, sfWindowState state, const sfContextSettings* settings);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Construct a new render window (with a UTF-32 title) /// \brief Construct a new render window (with a UTF-32 title)
@@ -63,7 +63,7 @@ CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const
/// \param settings Creation settings (pass NULL to use default values) /// \param settings Creation settings (pass NULL to use default values)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_createUnicode(sfVideoMode mode, const uint32_t* title, uint32_t style, const sfContextSettings* settings); CSFML_GRAPHICS_API sfRenderWindow* sfRenderWindow_createUnicode(sfVideoMode mode, const sfChar32* title, uint32_t style, sfWindowState state, const sfContextSettings* settings);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Construct a render window from an existing control /// \brief Construct a render window from an existing control
@@ -196,7 +196,7 @@ CSFML_GRAPHICS_API void sfRenderWindow_setTitle(sfRenderWindow* renderWindow, co
/// \param title New title /// \param title New title
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfRenderWindow_setUnicodeTitle(sfRenderWindow* renderWindow, const uint32_t* title); CSFML_GRAPHICS_API void sfRenderWindow_setUnicodeTitle(sfRenderWindow* renderWindow, const sfChar32* title);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change a render window's icon /// \brief Change a render window's icon
@@ -352,7 +352,7 @@ CSFML_GRAPHICS_API void sfRenderWindow_display(sfRenderWindow* renderWindow);
/// \return Window handle /// \return Window handle
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfWindowHandle sfRenderWindow_getSystemHandle(const sfRenderWindow* renderWindow); CSFML_GRAPHICS_API sfWindowHandle sfRenderWindow_getNativeHandle(const sfRenderWindow* renderWindow);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Clear a render window with the given color /// \brief Clear a render window with the given color
+3 -1
View File
@@ -39,11 +39,13 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create a new sprite /// \brief Create a new sprite
///
/// \param texture Source texture
/// ///
/// \return A new sfSprite object, or NULL if it failed /// \return A new sfSprite object, or NULL if it failed
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfSprite* sfSprite_create(void); CSFML_GRAPHICS_API sfSprite* sfSprite_create(const sfTexture* texture);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Copy an existing sprite /// \brief Copy an existing sprite
+6 -4
View File
@@ -52,11 +52,13 @@ typedef enum
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create a new text /// \brief Create a new text
///
/// \param font Font used to draw the string
/// ///
/// \return A new sfText object, or NULL if it failed /// \return A new sfText object, or NULL if it failed
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfText* sfText_create(void); CSFML_GRAPHICS_API sfText* sfText_create(const sfFont* font);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Copy an existing text /// \brief Copy an existing text
@@ -247,7 +249,7 @@ CSFML_GRAPHICS_API void sfText_setString(sfText* text, const char* string);
/// \param string New string /// \param string New string
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfText_setUnicodeString(sfText* text, const uint32_t* string); CSFML_GRAPHICS_API void sfText_setUnicodeString(sfText* text, const sfChar32* string);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set the font of a text /// \brief Set the font of a text
@@ -391,13 +393,13 @@ CSFML_GRAPHICS_API const char* sfText_getString(const sfText* text);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the string of a text (returns a unicode string) /// \brief Get the string of a text (returns a unicode string)
/// ///
/// \param text Text object /// \param text Text object
/// ///
/// \return String as UTF-32 /// \return String as UTF-32
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const uint32_t* sfText_getUnicodeString(const sfText* text); CSFML_GRAPHICS_API const sfChar32* sfText_getUnicodeString(const sfText* text);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the font used by a text /// \brief Get the font used by a text
+17
View File
@@ -219,6 +219,9 @@ CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getMessage(const sfFtpDirec
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the directory returned in a FTP directory response /// \brief Get the directory returned in a FTP directory response
/// ///
/// The returned const char* owns the string and must be freed to
/// avoid memory leaks.
///
/// \param ftpDirectoryResponse Ftp directory response /// \param ftpDirectoryResponse Ftp directory response
/// ///
/// \return Directory name /// \return Directory name
@@ -227,6 +230,20 @@ CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getMessage(const sfFtpDirec
CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getDirectory(const sfFtpDirectoryResponse* ftpDirectoryResponse); CSFML_NETWORK_API const char* sfFtpDirectoryResponse_getDirectory(const sfFtpDirectoryResponse* ftpDirectoryResponse);
////////////////////////////////////////////////////////////
/// \brief Get the directory returned in a FTP directory response
///
/// The returned const sfChar32* owns the string and must be freed to
/// avoid memory leaks.
///
/// \param ftpDirectoryResponse Ftp directory response
///
/// \return Directory name
///
////////////////////////////////////////////////////////////
CSFML_NETWORK_API const sfChar32* sfFtpDirectoryResponse_getDirectoryUnicode(const sfFtpDirectoryResponse* ftpDirectoryResponse);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Destroy a FTP response /// \brief Destroy a FTP response
/// ///
-2
View File
@@ -33,9 +33,7 @@
#include <SFML/System/Buffer.h> #include <SFML/System/Buffer.h>
#include <SFML/System/Clock.h> #include <SFML/System/Clock.h>
#include <SFML/System/InputStream.h> #include <SFML/System/InputStream.h>
#include <SFML/System/Mutex.h>
#include <SFML/System/Sleep.h> #include <SFML/System/Sleep.h>
#include <SFML/System/Thread.h>
#include <SFML/System/Time.h> #include <SFML/System/Time.h>
#include <SFML/System/Vector2.h> #include <SFML/System/Vector2.h>
#include <SFML/System/Vector3.h> #include <SFML/System/Vector3.h>
-68
View File
@@ -1,68 +0,0 @@
////////////////////////////////////////////////////////////
//
// 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_MUTEX_H
#define SFML_MUTEX_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.h>
#include <SFML/System/Types.h>
////////////////////////////////////////////////////////////
/// \brief Create a new mutex
///
/// \return A new sfMutex object
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API sfMutex* sfMutex_create(void);
////////////////////////////////////////////////////////////
/// \brief Destroy a mutex
///
/// \param mutex Mutex to destroy
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfMutex_destroy(sfMutex* mutex);
////////////////////////////////////////////////////////////
/// \brief Lock a mutex
///
/// \param mutex Mutex object
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfMutex_lock(sfMutex* mutex);
////////////////////////////////////////////////////////////
/// \brief Unlock a mutex
///
/// \param mutex Mutex object
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfMutex_unlock(sfMutex* mutex);
#endif // SFML_MUTEX_H
-103
View File
@@ -1,103 +0,0 @@
////////////////////////////////////////////////////////////
//
// 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_THREAD_H
#define SFML_THREAD_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Export.h>
#include <SFML/System/Types.h>
////////////////////////////////////////////////////////////
/// \brief Create a new thread from a function pointer
///
/// Note: this does *not* run the thread, use sfThread_launch.
///
/// \param function Entry point of the thread
/// \param userData Custom data to pass to the thread function
///
/// \return A new sfThread object
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API sfThread* sfThread_create(void (*function)(void*), void* userData);
////////////////////////////////////////////////////////////
/// \brief Destroy a thread
///
/// This function calls sfThread_wait, so that the internal thread
/// cannot survive after the sfThread object is destroyed.
///
/// \param thread Thread to destroy
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfThread_destroy(sfThread* thread);
////////////////////////////////////////////////////////////
/// \brief Run a thread
///
/// This function starts the entry point passed to the
/// thread's constructor, and returns immediately.
/// After this function returns, the thread's function is
/// running in parallel to the calling code.
///
/// \param thread Thread object
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfThread_launch(sfThread* thread);
////////////////////////////////////////////////////////////
/// \brief Wait until a thread finishes
///
/// This function will block the execution until the
/// thread's function ends.
/// Warning: if the thread function never ends, the calling
/// thread will block forever.
/// If this function is called from its owner thread, it
/// returns without doing anything.
///
/// \param thread Thread object
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfThread_wait(sfThread* thread);
////////////////////////////////////////////////////////////
/// \brief Terminate a thread
///
/// This function immediately stops the thread, without waiting
/// for its function to finish.
/// Terminating a thread with this function is not safe,
/// and can lead to local variables not being destroyed
/// on some operating systems. You should rather try to make
/// the thread function terminate by itself.
///
/// \param thread Thread object
///
////////////////////////////////////////////////////////////
CSFML_SYSTEM_API void sfThread_terminate(sfThread* thread);
#endif // SFML_THREAD_H
+2 -3
View File
@@ -55,7 +55,7 @@ CSFML_WINDOW_API const char* sfClipboard_getString(void);
/// \return Clipboard contents as UTF-32 /// \return Clipboard contents as UTF-32
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_WINDOW_API const uint32_t* sfClipboard_getUnicodeString(void); CSFML_WINDOW_API const sfChar32* sfClipboard_getUnicodeString(void);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set the content of the clipboard as ANSI string data /// \brief Set the content of the clipboard as ANSI string data
@@ -79,7 +79,6 @@ CSFML_WINDOW_API void sfClipboard_setString(const char* text);
/// to the clipboard /// to the clipboard
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfClipboard_setUnicodeString(const uint32_t* text); CSFML_WINDOW_API void sfClipboard_setUnicodeString(const sfChar32* text);
#endif // SFML_CURSOR_H #endif // SFML_CURSOR_H
+6 -4
View File
@@ -81,12 +81,13 @@ typedef struct
/// \param mode Video mode to use (defines the width, height and depth of the rendering area of the window) /// \param mode Video mode to use (defines the width, height and depth of the rendering area of the window)
/// \param title Title of the window /// \param title Title of the window
/// \param style Window style /// \param style Window style
/// \param state Window state
/// \param settings Additional settings for the underlying OpenGL context /// \param settings Additional settings for the underlying OpenGL context
/// ///
/// \return A new sfWindow object /// \return A new sfWindow object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfWindow* sfWindow_create(sfVideoMode mode, const char* title, uint32_t style, const sfContextSettings* settings); CSFML_WINDOW_API sfWindow* sfWindow_create(sfVideoMode mode, const char* title, uint32_t style, sfWindowState state, const sfContextSettings* settings);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Construct a new window (with a UTF-32 title) /// \brief Construct a new window (with a UTF-32 title)
@@ -104,12 +105,13 @@ CSFML_WINDOW_API sfWindow* sfWindow_create(sfVideoMode mode, const char* title,
/// \param mode Video mode to use (defines the width, height and depth of the rendering area of the window) /// \param mode Video mode to use (defines the width, height and depth of the rendering area of the window)
/// \param title Title of the window (UTF-32) /// \param title Title of the window (UTF-32)
/// \param style Window style /// \param style Window style
/// \param state Window state
/// \param settings Additional settings for the underlying OpenGL context /// \param settings Additional settings for the underlying OpenGL context
/// ///
/// \return A new sfWindow object /// \return A new sfWindow object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfWindow* sfWindow_createUnicode(sfVideoMode mode, const uint32_t* title, uint32_t style, const sfContextSettings* settings); CSFML_WINDOW_API sfWindow* sfWindow_createUnicode(sfVideoMode mode, const sfChar32* title, uint32_t style, sfWindowState state, const sfContextSettings* settings);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Construct a window from an existing control /// \brief Construct a window from an existing control
@@ -277,7 +279,7 @@ CSFML_WINDOW_API void sfWindow_setTitle(sfWindow* window, const char* title);
/// \param title New title /// \param title New title
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_setUnicodeTitle(sfWindow* window, const uint32_t* title); CSFML_WINDOW_API void sfWindow_setUnicodeTitle(sfWindow* window, const sfChar32* title);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change a window's icon /// \brief Change a window's icon
@@ -472,7 +474,7 @@ CSFML_WINDOW_API void sfWindow_display(sfWindow* window);
/// \return System handle of the window /// \return System handle of the window
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfWindowHandle sfWindow_getSystemHandle(const sfWindow* window); CSFML_WINDOW_API sfWindowHandle sfWindow_getNativeHandle(const sfWindow* window);
#endif // SFML_WINDOW_H #endif // SFML_WINDOW_H
+15 -4
View File
@@ -47,11 +47,22 @@ typedef enum
sfTitlebar = 1 << 0, ///< Title bar + fixed border sfTitlebar = 1 << 0, ///< Title bar + fixed border
sfResize = 1 << 1, ///< Titlebar + resizable border + maximize button sfResize = 1 << 1, ///< Titlebar + resizable border + maximize button
sfClose = 1 << 2, ///< Titlebar + close button sfClose = 1 << 2, ///< Titlebar + close button
sfFullscreen = 1 << 3, ///< Fullscreen mode (this flag and all others are mutually exclusive)
sfDefaultStyle = sfTitlebar | sfResize | sfClose ///< Default window style sfDefaultStyle = sfTitlebar | sfResize | sfClose ///< Default window style
} sfWindowStyle; } sfWindowStyle;
////////////////////////////////////////////////////////////
/// \brief Enumeration of the window states
///
////////////////////////////////////////////////////////////
typedef enum
{
sfWindowed, //!< Floating window
sfFullscreen //!< Fullscreen window
} sfWindowState;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Construct a new window /// \brief Construct a new window
/// ///
@@ -86,7 +97,7 @@ CSFML_WINDOW_API sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char*
/// \return A new sfWindow object /// \return A new sfWindow object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfWindowBase* sfWindowBase_createUnicode(sfVideoMode mode, const uint32_t* title, uint32_t style); CSFML_WINDOW_API sfWindowBase* sfWindowBase_createUnicode(sfVideoMode mode, const sfChar32* title, uint32_t style);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Construct a window from an existing control /// \brief Construct a window from an existing control
@@ -231,7 +242,7 @@ CSFML_WINDOW_API void sfWindowBase_setTitle(sfWindowBase* windowBase, const char
/// \param title New title /// \param title New title
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setUnicodeTitle(sfWindowBase* windowBase, const uint32_t* title); CSFML_WINDOW_API void sfWindowBase_setUnicodeTitle(sfWindowBase* windowBase, const sfChar32* title);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change a window's icon /// \brief Change a window's icon
@@ -366,7 +377,7 @@ CSFML_WINDOW_API bool sfWindowBase_hasFocus(const sfWindowBase* windowBase);
/// \return System handle of the window /// \return System handle of the window
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_WINDOW_API sfWindowHandle sfWindowBase_getSystemHandle(const sfWindowBase* windowBase); CSFML_WINDOW_API sfWindowHandle sfWindowBase_getNativeHandle(const sfWindowBase* windowBase);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create a Vulkan rendering surface /// \brief Create a Vulkan rendering surface
+1 -1
View File
@@ -32,4 +32,4 @@ set(SRC
# define the csfml-audio target # define the csfml-audio target
csfml_add_library(csfml-audio csfml_add_library(csfml-audio
SOURCES ${SRC} SOURCES ${SRC}
DEPENDS sfml-audio) DEPENDS SFML::Audio)
+3 -3
View File
@@ -47,7 +47,7 @@ float sfListener_getGlobalVolume(void)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfListener_setPosition(sfVector3f position) void sfListener_setPosition(sfVector3f position)
{ {
sf::Listener::setPosition(position.x, position.y, position.z); sf::Listener::setPosition({ position.x, position.y, position.z });
} }
@@ -63,7 +63,7 @@ sfVector3f sfListener_getPosition()
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfListener_setDirection(sfVector3f direction) void sfListener_setDirection(sfVector3f direction)
{ {
sf::Listener::setDirection(direction.x, direction.y, direction.z); sf::Listener::setDirection({ direction.x, direction.y, direction.z });
} }
@@ -79,7 +79,7 @@ sfVector3f sfListener_getDirection()
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfListener_setUpVector(sfVector3f upVector) void sfListener_setUpVector(sfVector3f upVector)
{ {
sf::Listener::setUpVector(upVector.x, upVector.y, upVector.z); sf::Listener::setUpVector({ upVector.x, upVector.y, upVector.z });
} }
+2 -2
View File
@@ -125,8 +125,8 @@ sfTimeSpan sfMusic_getLoopPoints(const sfMusic* music)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfMusic_setLoopPoints(sfMusic* music, sfTimeSpan timePoints) void sfMusic_setLoopPoints(sfMusic* music, sfTimeSpan timePoints)
{ {
CSFML_CALL(music, setLoopPoints(sf::Music::TimeSpan(sf::microseconds(timePoints.offset.microseconds), CSFML_CALL(music, setLoopPoints(sf::Music::TimeSpan({ sf::microseconds(timePoints.offset.microseconds),
sf::microseconds(timePoints.length.microseconds)))); sf::microseconds(timePoints.length.microseconds)})));
} }
+4 -2
View File
@@ -31,9 +31,11 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfSound* sfSound_create(void) sfSound* sfSound_create(const sfSoundBuffer* buffer)
{ {
return new sfSound; CSFML_CHECK_RETURN(buffer, nullptr);
return new sfSound{ sf::Sound{ buffer->This }, buffer };
} }
+1 -1
View File
@@ -66,7 +66,7 @@ private :
return true; return true;
} }
bool onProcessSamples(const sf::Int16* samples, std::size_t sampleCount) override bool onProcessSamples(const std::int16_t* samples, std::size_t sampleCount) override
{ {
if (myProcessCallback) if (myProcessCallback)
return myProcessCallback(samples, sampleCount, myUserData); return myProcessCallback(samples, sampleCount, myUserData);
+1 -1
View File
@@ -109,7 +109,7 @@ void sfSoundStream_setVolume(sfSoundStream* soundStream, float volume)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfSoundStream_setPosition(sfSoundStream* soundStream, sfVector3f position) void sfSoundStream_setPosition(sfSoundStream* soundStream, sfVector3f position)
{ {
CSFML_CALL(soundStream, setPosition(position.x, position.y, position.z)); CSFML_CALL(soundStream, setPosition({ position.x, position.y, position.z }));
} }
+1 -1
View File
@@ -21,7 +21,7 @@ if(CSFML_LINK_SFML_STATICALLY)
set(SFML_STATIC_LIBRARIES TRUE) set(SFML_STATIC_LIBRARIES TRUE)
add_definitions(-DSFML_STATIC) add_definitions(-DSFML_STATIC)
endif() endif()
find_package(SFML 2.6 COMPONENTS network graphics audio REQUIRED) find_package(SFML 3.0.0 COMPONENTS Network Graphics Audio REQUIRED)
# add the modules subdirectories # add the modules subdirectories
add_subdirectory(System) add_subdirectory(System)
+4 -4
View File
@@ -66,7 +66,7 @@ public:
/// \return The number of bytes actually read /// \return The number of bytes actually read
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sf::Int64 read(void* data, sf::Int64 size) override std::int64_t read(void* data, std::int64_t size) override
{ {
return myStream.read ? myStream.read(data, size, myStream.userData) : -1; return myStream.read ? myStream.read(data, size, myStream.userData) : -1;
} }
@@ -79,7 +79,7 @@ public:
/// \return The position actually seeked to, or -1 on error /// \return The position actually seeked to, or -1 on error
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sf::Int64 seek(sf::Int64 position) override std::int64_t seek(std::int64_t position) override
{ {
return myStream.seek ? myStream.seek(position, myStream.userData) : -1; return myStream.seek ? myStream.seek(position, myStream.userData) : -1;
} }
@@ -90,7 +90,7 @@ public:
/// \return The current position, or -1 on error. /// \return The current position, or -1 on error.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sf::Int64 tell() override std::int64_t tell() override
{ {
return myStream.tell ? myStream.tell(myStream.userData) : -1; return myStream.tell ? myStream.tell(myStream.userData) : -1;
} }
@@ -101,7 +101,7 @@ public:
/// \return The total number of bytes available in the stream, or -1 on error /// \return The total number of bytes available in the stream, or -1 on error
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sf::Int64 getSize() override std::int64_t getSize() override
{ {
return myStream.getSize ? myStream.getSize(myStream.userData) : -1; return myStream.getSize ? myStream.getSize(myStream.userData) : -1;
} }
@@ -22,37 +22,28 @@
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_CHAR32_HPP
#define SFML_CHAR32_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System/Mutex.h> #include <SFML/System/String.hpp>
#include <SFML/System/MutexStruct.h> #include <SFML/Config.h>
#include <SFML/Internal.h> #include <string.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfMutex* sfMutex_create(void) // Define utils to copy from / to sfChar32 and sf::String
{
return new sfMutex;
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfMutex_destroy(sfMutex* mutex) inline sfChar32* copyToChar32(const sf::String& str)
{ {
delete mutex; std::size_t byteCount = sizeof(sfChar32) * str.getSize();
sfChar32* utf32 = static_cast<sfChar32*>(malloc(byteCount + sizeof(sfChar32)));
memcpy(utf32, str.getData(), byteCount);
utf32[str.getSize()] = 0;
return utf32;
} }
#endif // SFML_CHAR32_HPP
////////////////////////////////////////////////////////////
void sfMutex_lock(sfMutex* mutex)
{
CSFML_CALL(mutex, lock());
}
////////////////////////////////////////////////////////////
void sfMutex_unlock(sfMutex* mutex)
{
CSFML_CALL(mutex, unlock());
}
+1 -1
View File
@@ -73,4 +73,4 @@ set(SRC
# define the csfml-graphics target # define the csfml-graphics target
csfml_add_library(csfml-graphics csfml_add_library(csfml-graphics
SOURCES ${SRC} SOURCES ${SRC}
DEPENDS sfml-graphics) DEPENDS SFML::Graphics)
+9 -9
View File
@@ -61,28 +61,28 @@ void sfCircleShape_destroy(sfCircleShape* shape)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfCircleShape_setPosition(sfCircleShape* shape, sfVector2f position) void sfCircleShape_setPosition(sfCircleShape* shape, sfVector2f position)
{ {
CSFML_CALL(shape, setPosition(position.x, position.y)); CSFML_CALL(shape, setPosition({ position.x, position.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfCircleShape_setRotation(sfCircleShape* shape, float angle) void sfCircleShape_setRotation(sfCircleShape* shape, float angle)
{ {
CSFML_CALL(shape, setRotation(angle)); CSFML_CALL(shape, setRotation(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfCircleShape_setScale(sfCircleShape* shape, sfVector2f scale) void sfCircleShape_setScale(sfCircleShape* shape, sfVector2f scale)
{ {
CSFML_CALL(shape, setScale(scale.x, scale.y)); CSFML_CALL(shape, setScale({ scale.x, scale.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfCircleShape_setOrigin(sfCircleShape* shape, sfVector2f origin) void sfCircleShape_setOrigin(sfCircleShape* shape, sfVector2f origin)
{ {
CSFML_CALL(shape, setOrigin(origin.x, origin.y)); CSFML_CALL(shape, setOrigin({ origin.x, origin.y }));
} }
@@ -103,7 +103,7 @@ sfVector2f sfCircleShape_getPosition(const sfCircleShape* shape)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfCircleShape_getRotation(const sfCircleShape* shape) float sfCircleShape_getRotation(const sfCircleShape* shape)
{ {
CSFML_CALL_RETURN(shape, getRotation(), 0.f); CSFML_CALL_RETURN(shape, getRotation().asDegrees(), 0.f);
} }
@@ -138,21 +138,21 @@ sfVector2f sfCircleShape_getOrigin(const sfCircleShape* shape)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfCircleShape_move(sfCircleShape* shape, sfVector2f offset) void sfCircleShape_move(sfCircleShape* shape, sfVector2f offset)
{ {
CSFML_CALL(shape, move(offset.x, offset.y)); CSFML_CALL(shape, move({ offset.x, offset.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfCircleShape_rotate(sfCircleShape* shape, float angle) void sfCircleShape_rotate(sfCircleShape* shape, float angle)
{ {
CSFML_CALL(shape, rotate(angle)); CSFML_CALL(shape, rotate(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfCircleShape_scale(sfCircleShape* shape, sfVector2f factors) void sfCircleShape_scale(sfCircleShape* shape, sfVector2f factors)
{ {
CSFML_CALL(shape, scale(factors.x, factors.y)); CSFML_CALL(shape, scale({ factors.x, factors.y }));
} }
@@ -187,7 +187,7 @@ void sfCircleShape_setTexture(sfCircleShape* shape, const sfTexture* texture, bo
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfCircleShape_setTextureRect(sfCircleShape* shape, sfIntRect rect) void sfCircleShape_setTextureRect(sfCircleShape* shape, sfIntRect rect)
{ {
CSFML_CALL(shape, setTextureRect(sf::IntRect(rect.left, rect.top, rect.width, rect.height))); CSFML_CALL(shape, setTextureRect(sf::IntRect({ rect.left, rect.top }, { rect.width, rect.height })));
} }
+9 -9
View File
@@ -58,28 +58,28 @@ void sfConvexShape_destroy(sfConvexShape* shape)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfConvexShape_setPosition(sfConvexShape* shape, sfVector2f position) void sfConvexShape_setPosition(sfConvexShape* shape, sfVector2f position)
{ {
CSFML_CALL(shape, setPosition(position.x, position.y)); CSFML_CALL(shape, setPosition({ position.x, position.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfConvexShape_setRotation(sfConvexShape* shape, float angle) void sfConvexShape_setRotation(sfConvexShape* shape, float angle)
{ {
CSFML_CALL(shape, setRotation(angle)); CSFML_CALL(shape, setRotation(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfConvexShape_setScale(sfConvexShape* shape, sfVector2f scale) void sfConvexShape_setScale(sfConvexShape* shape, sfVector2f scale)
{ {
CSFML_CALL(shape, setScale(scale.x, scale.y)); CSFML_CALL(shape, setScale({ scale.x, scale.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfConvexShape_setOrigin(sfConvexShape* shape, sfVector2f origin) void sfConvexShape_setOrigin(sfConvexShape* shape, sfVector2f origin)
{ {
CSFML_CALL(shape, setOrigin(origin.x, origin.y)); CSFML_CALL(shape, setOrigin({ origin.x, origin.y }));
} }
@@ -100,7 +100,7 @@ sfVector2f sfConvexShape_getPosition(const sfConvexShape* shape)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfConvexShape_getRotation(const sfConvexShape* shape) float sfConvexShape_getRotation(const sfConvexShape* shape)
{ {
CSFML_CALL_RETURN(shape, getRotation(), 0.f); CSFML_CALL_RETURN(shape, getRotation().asDegrees(), 0.f);
} }
@@ -135,21 +135,21 @@ sfVector2f sfConvexShape_getOrigin(const sfConvexShape* shape)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfConvexShape_move(sfConvexShape* shape, sfVector2f offset) void sfConvexShape_move(sfConvexShape* shape, sfVector2f offset)
{ {
CSFML_CALL(shape, move(offset.x, offset.y)); CSFML_CALL(shape, move({ offset.x, offset.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfConvexShape_rotate(sfConvexShape* shape, float angle) void sfConvexShape_rotate(sfConvexShape* shape, float angle)
{ {
CSFML_CALL(shape, rotate(angle)); CSFML_CALL(shape, rotate(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfConvexShape_scale(sfConvexShape* shape, sfVector2f factors) void sfConvexShape_scale(sfConvexShape* shape, sfVector2f factors)
{ {
CSFML_CALL(shape, scale(factors.x, factors.y)); CSFML_CALL(shape, scale({ factors.x, factors.y }));
} }
@@ -184,7 +184,7 @@ void sfConvexShape_setTexture(sfConvexShape* shape, const sfTexture* texture, bo
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfConvexShape_setTextureRect(sfConvexShape* shape, sfIntRect rect) void sfConvexShape_setTextureRect(sfConvexShape* shape, sfIntRect rect)
{ {
CSFML_CALL(shape, setTextureRect(sf::IntRect(rect.left, rect.top, rect.width, rect.height))); CSFML_CALL(shape, setTextureRect(sf::IntRect({ rect.left, rect.top }, { rect.width, rect.height })));
} }
+23 -10
View File
@@ -36,7 +36,7 @@
sfImage* sfImage_create(unsigned int width, unsigned int height) sfImage* sfImage_create(unsigned int width, unsigned int height)
{ {
sfImage* image = new sfImage; sfImage* image = new sfImage;
image->This.create(width, height); image->This.create({ width, height });
return image; return image;
} }
@@ -46,7 +46,7 @@ sfImage* sfImage_create(unsigned int width, unsigned int height)
sfImage* sfImage_createFromColor(unsigned int width, unsigned int height, sfColor color) sfImage* sfImage_createFromColor(unsigned int width, unsigned int height, sfColor color)
{ {
sfImage* image = new sfImage; sfImage* image = new sfImage;
image->This.create(width, height, sf::Color(color.r, color.g, color.b, color.a)); image->This.create({ width, height }, sf::Color(color.r, color.g, color.b, color.a));
return image; return image;
} }
@@ -56,7 +56,7 @@ sfImage* sfImage_createFromColor(unsigned int width, unsigned int height, sfColo
sfImage* sfImage_createFromPixels(unsigned int width, unsigned int height, const uint8_t* data) sfImage* sfImage_createFromPixels(unsigned int width, unsigned int height, const uint8_t* data)
{ {
sfImage* image = new sfImage; sfImage* image = new sfImage;
image->This.create(width, height, data); image->This.create({ width, height }, data);
return image; return image;
} }
@@ -137,7 +137,17 @@ bool sfImage_saveToFile(const sfImage* image, const char* filename)
bool sfImage_saveToMemory(const sfImage* image, sfBuffer* output, const char* format) bool sfImage_saveToMemory(const sfImage* image, sfBuffer* output, const char* format)
{ {
CSFML_CHECK_RETURN(output, false); CSFML_CHECK_RETURN(output, false);
CSFML_CALL_RETURN(image, saveToMemory(output->buffer, format), false); CSFML_CHECK_RETURN(image, false);
auto data = image->This.saveToMemory(format);
if (data)
{
output->buffer = std::move(*data);
return true;
}
return false;
} }
@@ -149,18 +159,21 @@ void sfImage_createMaskFromColor(sfImage* image, sfColor colorKey, uint8_t alpha
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfImage_copyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect, bool applyAlpha) bool sfImage_copyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect, bool applyAlpha)
{ {
CSFML_CHECK(source); CSFML_CHECK_RETURN(image, false);
sf::IntRect sfmlRect(sourceRect.left, sourceRect.top, sourceRect.width, sourceRect.height); CSFML_CHECK_RETURN(source, false);
CSFML_CALL(image, copy(source->This, destX, destY, sfmlRect, applyAlpha));
sf::IntRect sfmlRect({ sourceRect.left, sourceRect.top }, { sourceRect.width, sourceRect.height });
return image->This.copy(source->This, { destX, destY }, sfmlRect, applyAlpha);
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfImage_setPixel(sfImage* image, unsigned int x, unsigned int y, sfColor color) void sfImage_setPixel(sfImage* image, unsigned int x, unsigned int y, sfColor color)
{ {
CSFML_CALL(image, setPixel(x, y, sf::Color(color.r, color.g, color.b, color.a))); CSFML_CALL(image, setPixel({ x, y }, sf::Color(color.r, color.g, color.b, color.a)));
} }
@@ -170,7 +183,7 @@ sfColor sfImage_getPixel(const sfImage* image, unsigned int x, unsigned int y)
sfColor color = {0, 0, 0, 0}; sfColor color = {0, 0, 0, 0};
CSFML_CHECK_RETURN(image, color); CSFML_CHECK_RETURN(image, color);
sf::Color sfmlColor = image->This.getPixel(x, y); sf::Color sfmlColor = image->This.getPixel({ x, y });
return sfColor_fromRGBA(sfmlColor.r, sfmlColor.g, sfmlColor.b, sfmlColor.a); return sfColor_fromRGBA(sfmlColor.r, sfmlColor.g, sfmlColor.b, sfmlColor.a);
} }
+30 -26
View File
@@ -51,12 +51,12 @@ sfVector2i toCType(const sf::Vector2i& vector)
bool sfFloatRect_contains(const sfFloatRect* rect, float x, float y) bool sfFloatRect_contains(const sfFloatRect* rect, float x, float y)
{ {
CSFML_CHECK_RETURN(rect, false); CSFML_CHECK_RETURN(rect, false);
return sf::FloatRect(rect->left, rect->top, rect->width, rect->height).contains(x, y); return sf::FloatRect({ rect->left, rect->top }, { rect->width, rect->height }).contains({ x, y });
} }
bool sfIntRect_contains(const sfIntRect* rect, int x, int y) bool sfIntRect_contains(const sfIntRect* rect, int x, int y)
{ {
CSFML_CHECK_RETURN(rect, false); CSFML_CHECK_RETURN(rect, false);
return sf::IntRect(rect->left, rect->top, rect->width, rect->height).contains(x, y); return sf::IntRect({ rect->left, rect->top }, { rect->width, rect->height }).contains({ x, y });
} }
@@ -68,24 +68,26 @@ bool sfFloatRect_intersects(const sfFloatRect* rect1, const sfFloatRect* rect2,
CSFML_CHECK_RETURN(rect1, false); CSFML_CHECK_RETURN(rect1, false);
CSFML_CHECK_RETURN(rect2, false); CSFML_CHECK_RETURN(rect2, false);
sf::FloatRect SFMLRect1(rect1->left, rect1->top, rect1->width, rect1->height); sf::FloatRect SFMLRect1({ rect1->left, rect1->top }, { rect1->width, rect1->height });
sf::FloatRect SFMLRect2(rect2->left, rect2->top, rect2->width, rect2->height); sf::FloatRect SFMLRect2({ rect2->left, rect2->top }, { rect2->width, rect2->height });
if (intersection) if (intersection)
{ {
sf::FloatRect overlap; std::optional<sf::FloatRect> overlap = SFMLRect1.findIntersection(SFMLRect2);
bool intersects = SFMLRect1.intersects(SFMLRect2, overlap);
intersection->left = overlap.left; if (overlap)
intersection->top = overlap.top; {
intersection->width = overlap.width; intersection->left = overlap->left;
intersection->height = overlap.height; intersection->top = overlap->top;
intersection->width = overlap->width;
intersection->height = overlap->height;
}
return intersects; return overlap.has_value();
} }
else else
{ {
return SFMLRect1.intersects(SFMLRect2); return SFMLRect1.findIntersection(SFMLRect2).has_value();
} }
} }
bool sfIntRect_intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIntRect* intersection) bool sfIntRect_intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIntRect* intersection)
@@ -93,24 +95,26 @@ bool sfIntRect_intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIntR
CSFML_CHECK_RETURN(rect1, false); CSFML_CHECK_RETURN(rect1, false);
CSFML_CHECK_RETURN(rect2, false); CSFML_CHECK_RETURN(rect2, false);
sf::IntRect SFMLRect1(rect1->left, rect1->top, rect1->width, rect1->height); sf::IntRect SFMLRect1({ rect1->left, rect1->top }, { rect1->width, rect1->height });
sf::IntRect SFMLRect2(rect2->left, rect2->top, rect2->width, rect2->height); sf::IntRect SFMLRect2({ rect2->left, rect2->top }, { rect2->width, rect2->height });
if (intersection) if (intersection)
{ {
sf::IntRect overlap; std::optional<sf::IntRect> overlap = SFMLRect1.findIntersection(SFMLRect2);
bool intersects = SFMLRect1.intersects(SFMLRect2, overlap);
intersection->left = overlap.left; if (overlap)
intersection->top = overlap.top; {
intersection->width = overlap.width; intersection->left = overlap->left;
intersection->height = overlap.height; intersection->top = overlap->top;
intersection->width = overlap->width;
intersection->height = overlap->height;
}
return intersects; return overlap.has_value();
} }
else else
{ {
return SFMLRect1.intersects(SFMLRect2); return SFMLRect1.findIntersection(SFMLRect2).has_value();
} }
} }
@@ -120,11 +124,11 @@ bool sfIntRect_intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIntR
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfVector2f sfFloatRect_getPosition(const sfFloatRect* rect) sfVector2f sfFloatRect_getPosition(const sfFloatRect* rect)
{ {
return toCType(sf::FloatRect(rect->left, rect->top, rect->width, rect->height).getPosition()); return toCType(sf::FloatRect({ rect->left, rect->top }, { rect->width, rect->height }).getPosition());
} }
sfVector2i sfIntRect_getPosition(const sfIntRect* rect) sfVector2i sfIntRect_getPosition(const sfIntRect* rect)
{ {
return toCType(sf::IntRect(rect->left, rect->top, rect->width, rect->height).getPosition()); return toCType(sf::IntRect({ rect->left, rect->top }, { rect->width, rect->height }).getPosition());
} }
@@ -133,9 +137,9 @@ sfVector2i sfIntRect_getPosition(const sfIntRect* rect)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfVector2f sfFloatRect_getSize(const sfFloatRect* rect) sfVector2f sfFloatRect_getSize(const sfFloatRect* rect)
{ {
return toCType(sf::FloatRect(rect->left, rect->top, rect->width, rect->height).getSize()); return toCType(sf::FloatRect({ rect->left, rect->top }, { rect->width, rect->height }).getSize());
} }
sfVector2i sfIntRect_getSize(const sfIntRect* rect) sfVector2i sfIntRect_getSize(const sfIntRect* rect)
{ {
return toCType(sf::IntRect(rect->left, rect->top, rect->width, rect->height).getSize()); return toCType(sf::IntRect({ rect->left, rect->top }, { rect->width, rect->height }).getSize());
} }
+9 -9
View File
@@ -58,28 +58,28 @@ void sfRectangleShape_destroy(sfRectangleShape* shape)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfRectangleShape_setPosition(sfRectangleShape* shape, sfVector2f position) void sfRectangleShape_setPosition(sfRectangleShape* shape, sfVector2f position)
{ {
CSFML_CALL(shape, setPosition(position.x, position.y)); CSFML_CALL(shape, setPosition({ position.x, position.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfRectangleShape_setRotation(sfRectangleShape* shape, float angle) void sfRectangleShape_setRotation(sfRectangleShape* shape, float angle)
{ {
CSFML_CALL(shape, setRotation(angle)); CSFML_CALL(shape, setRotation(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfRectangleShape_setScale(sfRectangleShape* shape, sfVector2f scale) void sfRectangleShape_setScale(sfRectangleShape* shape, sfVector2f scale)
{ {
CSFML_CALL(shape, setScale(scale.x, scale.y)); CSFML_CALL(shape, setScale({ scale.x, scale.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfRectangleShape_setOrigin(sfRectangleShape* shape, sfVector2f origin) void sfRectangleShape_setOrigin(sfRectangleShape* shape, sfVector2f origin)
{ {
CSFML_CALL(shape, setOrigin(origin.x, origin.y)); CSFML_CALL(shape, setOrigin({ origin.x, origin.y }));
} }
@@ -100,7 +100,7 @@ sfVector2f sfRectangleShape_getPosition(const sfRectangleShape* shape)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfRectangleShape_getRotation(const sfRectangleShape* shape) float sfRectangleShape_getRotation(const sfRectangleShape* shape)
{ {
CSFML_CALL_RETURN(shape, getRotation(), 0.f); CSFML_CALL_RETURN(shape, getRotation().asDegrees(), 0.f);
} }
@@ -135,21 +135,21 @@ sfVector2f sfRectangleShape_getOrigin(const sfRectangleShape* shape)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfRectangleShape_move(sfRectangleShape* shape, sfVector2f offset) void sfRectangleShape_move(sfRectangleShape* shape, sfVector2f offset)
{ {
CSFML_CALL(shape, move(offset.x, offset.y)); CSFML_CALL(shape, move({ offset.x, offset.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfRectangleShape_rotate(sfRectangleShape* shape, float angle) void sfRectangleShape_rotate(sfRectangleShape* shape, float angle)
{ {
CSFML_CALL(shape, rotate(angle)); CSFML_CALL(shape, rotate(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfRectangleShape_scale(sfRectangleShape* shape, sfVector2f factors) void sfRectangleShape_scale(sfRectangleShape* shape, sfVector2f factors)
{ {
CSFML_CALL(shape, scale(factors.x, factors.y)); CSFML_CALL(shape, scale({ factors.x, factors.y }));
} }
@@ -184,7 +184,7 @@ void sfRectangleShape_setTexture(sfRectangleShape* shape, const sfTexture* textu
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfRectangleShape_setTextureRect(sfRectangleShape* shape, sfIntRect rect) void sfRectangleShape_setTextureRect(sfRectangleShape* shape, sfIntRect rect)
{ {
CSFML_CALL(shape, setTextureRect(sf::IntRect(rect.left, rect.top, rect.width, rect.height))); CSFML_CALL(shape, setTextureRect(sf::IntRect({ rect.left, rect.top }, { rect.width, rect.height })));
} }
+8 -15
View File
@@ -41,20 +41,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfRenderTexture* sfRenderTexture_create(unsigned int width, unsigned int height, bool depthBuffer) sfRenderTexture* sfRenderTexture_create(unsigned int width, unsigned int height, const sfContextSettings* settings)
{
sfRenderTexture* renderTexture = new sfRenderTexture;
renderTexture->This.create(width, height, depthBuffer);
renderTexture->Target = new sfTexture(const_cast<sf::Texture*>(&renderTexture->This.getTexture()));
renderTexture->DefaultView.This = renderTexture->This.getDefaultView();
renderTexture->CurrentView.This = renderTexture->This.getView();
return renderTexture;
}
////////////////////////////////////////////////////////////
sfRenderTexture* sfRenderTexture_createWithSettings(unsigned int width, unsigned int height, const sfContextSettings* settings)
{ {
// Convert context settings // Convert context settings
sf::ContextSettings params; sf::ContextSettings params;
@@ -65,7 +52,13 @@ sfRenderTexture* sfRenderTexture_createWithSettings(unsigned int width, unsigned
// Create the render texture // Create the render texture
sfRenderTexture* renderTexture = new sfRenderTexture; sfRenderTexture* renderTexture = new sfRenderTexture;
renderTexture->This.create(width, height, params);
if (!renderTexture->This.create({ width, height }, params))
{
delete renderTexture;
return nullptr;
}
renderTexture->Target = new sfTexture(const_cast<sf::Texture*>(&renderTexture->This.getTexture())); renderTexture->Target = new sfTexture(const_cast<sf::Texture*>(&renderTexture->This.getTexture()));
renderTexture->DefaultView.This = renderTexture->This.getDefaultView(); renderTexture->DefaultView.This = renderTexture->This.getDefaultView();
renderTexture->CurrentView.This = renderTexture->This.getView(); renderTexture->CurrentView.This = renderTexture->This.getView();
+11 -11
View File
@@ -45,10 +45,10 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const char* title, uint32_t style, const sfContextSettings* settings) sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const char* title, uint32_t style, sfWindowState state, const sfContextSettings* settings)
{ {
// Convert video mode // Convert video mode
sf::VideoMode videoMode(mode.width, mode.height, mode.bitsPerPixel); sf::VideoMode videoMode({ mode.width, mode.height }, mode.bitsPerPixel);
// Convert context settings // Convert context settings
sf::ContextSettings params; sf::ContextSettings params;
@@ -59,7 +59,7 @@ sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const char* title, uint3
// Create the window // Create the window
sfRenderWindow* renderWindow = new sfRenderWindow; sfRenderWindow* renderWindow = new sfRenderWindow;
renderWindow->This.create(videoMode, title, style, params); renderWindow->This.create(videoMode, title, style, static_cast<sf::State>(state), params);
renderWindow->DefaultView.This = renderWindow->This.getDefaultView(); renderWindow->DefaultView.This = renderWindow->This.getDefaultView();
renderWindow->CurrentView.This = renderWindow->This.getView(); renderWindow->CurrentView.This = renderWindow->This.getView();
@@ -67,10 +67,10 @@ sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const char* title, uint3
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfRenderWindow* sfRenderWindow_createUnicode(sfVideoMode mode, const uint32_t* title, uint32_t style, const sfContextSettings* settings) sfRenderWindow* sfRenderWindow_createUnicode(sfVideoMode mode, const sfChar32* title, uint32_t style, sfWindowState state, const sfContextSettings* settings)
{ {
// Convert video mode // Convert video mode
sf::VideoMode videoMode(mode.width, mode.height, mode.bitsPerPixel); sf::VideoMode videoMode({ mode.width, mode.height }, mode.bitsPerPixel);
// Convert context settings // Convert context settings
sf::ContextSettings params; sf::ContextSettings params;
@@ -81,7 +81,7 @@ sfRenderWindow* sfRenderWindow_createUnicode(sfVideoMode mode, const uint32_t* t
// Create the window // Create the window
sfRenderWindow* renderWindow = new sfRenderWindow; sfRenderWindow* renderWindow = new sfRenderWindow;
renderWindow->This.create(videoMode, title, style, params); renderWindow->This.create(videoMode, reinterpret_cast<const char32_t*>(title), style, static_cast<sf::State>(state), params);
renderWindow->DefaultView.This = renderWindow->This.getDefaultView(); renderWindow->DefaultView.This = renderWindow->This.getDefaultView();
renderWindow->CurrentView.This = renderWindow->This.getView(); renderWindow->CurrentView.This = renderWindow->This.getView();
@@ -243,16 +243,16 @@ void sfRenderWindow_setTitle(sfRenderWindow* renderWindow, const char* title)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfRenderWindow_setUnicodeTitle(sfRenderWindow* renderWindow, const uint32_t* title) void sfRenderWindow_setUnicodeTitle(sfRenderWindow* renderWindow, const sfChar32* title)
{ {
CSFML_CALL(renderWindow, setTitle(title)); CSFML_CALL(renderWindow, setTitle(reinterpret_cast<const char32_t*>(title)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const uint8_t* pixels) void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const uint8_t* pixels)
{ {
CSFML_CALL(renderWindow, setIcon(width, height, pixels)); CSFML_CALL(renderWindow, setIcon({ width, height }, pixels));
} }
@@ -343,11 +343,11 @@ void sfRenderWindow_setJoystickThreshold(sfRenderWindow* renderWindow, float thr
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfWindowHandle sfRenderWindow_getSystemHandle(const sfRenderWindow* renderWindow) sfWindowHandle sfRenderWindow_getNativeHandle(const sfRenderWindow* renderWindow)
{ {
CSFML_CHECK_RETURN(renderWindow, 0); CSFML_CHECK_RETURN(renderWindow, 0);
return static_cast<sfWindowHandle>(renderWindow->This.getSystemHandle()); return static_cast<sfWindowHandle>(renderWindow->This.getNativeHandle());
} }
+10 -10
View File
@@ -45,12 +45,12 @@ sfShader* sfShader_createFromFile(const char* vertexShaderFilename, const char*
if (!vertexShaderFilename) if (!vertexShaderFilename)
{ {
// fragment shader only // fragment shader only
success = shader->This.loadFromFile(fragmentShaderFilename, sf::Shader::Fragment); success = shader->This.loadFromFile(fragmentShaderFilename, sf::Shader::Type::Fragment);
} }
else if (!fragmentShaderFilename) else if (!fragmentShaderFilename)
{ {
// vertex shader only // vertex shader only
success = shader->This.loadFromFile(vertexShaderFilename, sf::Shader::Vertex); success = shader->This.loadFromFile(vertexShaderFilename, sf::Shader::Type::Vertex);
} }
else else
{ {
@@ -63,7 +63,7 @@ sfShader* sfShader_createFromFile(const char* vertexShaderFilename, const char*
if (!vertexShaderFilename && !fragmentShaderFilename) if (!vertexShaderFilename && !fragmentShaderFilename)
{ {
// geometry shader only // geometry shader only
success = shader->This.loadFromFile(geometryShaderFilename, sf::Shader::Geometry); success = shader->This.loadFromFile(geometryShaderFilename, sf::Shader::Type::Geometry);
} }
else else
{ {
@@ -95,12 +95,12 @@ sfShader* sfShader_createFromMemory(const char* vertexShader, const char* geomet
if (!vertexShader) if (!vertexShader)
{ {
// fragment shader only // fragment shader only
success = shader->This.loadFromMemory(fragmentShader, sf::Shader::Fragment); success = shader->This.loadFromMemory(fragmentShader, sf::Shader::Type::Fragment);
} }
else if (!fragmentShader) else if (!fragmentShader)
{ {
// vertex shader only // vertex shader only
success = shader->This.loadFromMemory(vertexShader, sf::Shader::Vertex); success = shader->This.loadFromMemory(vertexShader, sf::Shader::Type::Vertex);
} }
else else
{ {
@@ -113,7 +113,7 @@ sfShader* sfShader_createFromMemory(const char* vertexShader, const char* geomet
if (!vertexShader && !fragmentShader) if (!vertexShader && !fragmentShader)
{ {
// geometry shader only // geometry shader only
success = shader->This.loadFromMemory(geometryShader, sf::Shader::Geometry); success = shader->This.loadFromMemory(geometryShader, sf::Shader::Type::Geometry);
} }
else else
{ {
@@ -146,13 +146,13 @@ sfShader* sfShader_createFromStream(sfInputStream* vertexShaderStream, sfInputSt
{ {
// fragment shader only // fragment shader only
CallbackStream stream(fragmentShaderStream); CallbackStream stream(fragmentShaderStream);
success = shader->This.loadFromStream(stream, sf::Shader::Fragment); success = shader->This.loadFromStream(stream, sf::Shader::Type::Fragment);
} }
else if (!fragmentShaderStream) else if (!fragmentShaderStream)
{ {
// vertex shader only // vertex shader only
CallbackStream stream(vertexShaderStream); CallbackStream stream(vertexShaderStream);
success = shader->This.loadFromStream(stream, sf::Shader::Vertex); success = shader->This.loadFromStream(stream, sf::Shader::Type::Vertex);
} }
else else
{ {
@@ -168,7 +168,7 @@ sfShader* sfShader_createFromStream(sfInputStream* vertexShaderStream, sfInputSt
if (!vertexShaderStream && !fragmentShaderStream) if (!vertexShaderStream && !fragmentShaderStream)
{ {
// geometry shader only // geometry shader only
success = shader->This.loadFromStream(geometryStream, sf::Shader::Geometry); success = shader->This.loadFromStream(geometryStream, sf::Shader::Type::Geometry);
} }
else else
{ {
@@ -379,7 +379,7 @@ void sfShader_setMat4UniformArray(sfShader* shader, const char* name, const sfGl
void sfShader_setTextureParameter(sfShader* shader, const char* name, const sfTexture* texture) void sfShader_setTextureParameter(sfShader* shader, const char* name, const sfTexture* texture)
{ {
CSFML_CHECK(texture); CSFML_CHECK(texture);
CSFML_CALL(shader, setParameter(name,*texture->This)); CSFML_CALL(shader, setUniform(name, *texture->This));
} }
+9 -9
View File
@@ -51,28 +51,28 @@ void sfShape_destroy(sfShape* shape)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfShape_setPosition(sfShape* shape, sfVector2f position) void sfShape_setPosition(sfShape* shape, sfVector2f position)
{ {
CSFML_CALL(shape, setPosition(position.x, position.y)); CSFML_CALL(shape, setPosition({ position.x, position.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfShape_setRotation(sfShape* shape, float angle) void sfShape_setRotation(sfShape* shape, float angle)
{ {
CSFML_CALL(shape, setRotation(angle)); CSFML_CALL(shape, setRotation(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfShape_setScale(sfShape* shape, sfVector2f scale) void sfShape_setScale(sfShape* shape, sfVector2f scale)
{ {
CSFML_CALL(shape, setScale(scale.x, scale.y)); CSFML_CALL(shape, setScale({ scale.x, scale.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfShape_setOrigin(sfShape* shape, sfVector2f origin) void sfShape_setOrigin(sfShape* shape, sfVector2f origin)
{ {
CSFML_CALL(shape, setOrigin(origin.x, origin.y)); CSFML_CALL(shape, setOrigin({ origin.x, origin.y }));
} }
@@ -93,7 +93,7 @@ sfVector2f sfShape_getPosition(const sfShape* shape)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfShape_getRotation(const sfShape* shape) float sfShape_getRotation(const sfShape* shape)
{ {
CSFML_CALL_RETURN(shape, getRotation(), 0.f); CSFML_CALL_RETURN(shape, getRotation().asDegrees(), 0.f);
} }
@@ -128,21 +128,21 @@ sfVector2f sfShape_getOrigin(const sfShape* shape)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfShape_move(sfShape* shape, sfVector2f offset) void sfShape_move(sfShape* shape, sfVector2f offset)
{ {
CSFML_CALL(shape, move(offset.x, offset.y)); CSFML_CALL(shape, move({ offset.x, offset.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfShape_rotate(sfShape* shape, float angle) void sfShape_rotate(sfShape* shape, float angle)
{ {
CSFML_CALL(shape, rotate(angle)); CSFML_CALL(shape, rotate(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfShape_scale(sfShape* shape, sfVector2f factors) void sfShape_scale(sfShape* shape, sfVector2f factors)
{ {
CSFML_CALL(shape, scale(factors.x, factors.y)); CSFML_CALL(shape, scale({ factors.x, factors.y }));
} }
@@ -177,7 +177,7 @@ void sfShape_setTexture(sfShape* shape, const sfTexture* texture, bool resetRect
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfShape_setTextureRect(sfShape* shape, sfIntRect rect) void sfShape_setTextureRect(sfShape* shape, sfIntRect rect)
{ {
CSFML_CALL(shape, setTextureRect(sf::IntRect(rect.left, rect.top, rect.width, rect.height))); CSFML_CALL(shape, setTextureRect(sf::IntRect({ rect.left, rect.top }, { rect.width, rect.height })));
} }
+13 -13
View File
@@ -34,12 +34,12 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfSprite* sfSprite_create(void) sfSprite* sfSprite_create(const sfTexture* texture)
{ {
sfSprite* sprite = new sfSprite; CSFML_CHECK_RETURN(texture, nullptr);
sprite->Texture = nullptr; CSFML_CHECK_RETURN(texture->This, nullptr);
return sprite; return new sfSprite{ sf::Sprite{*texture->This}, texture, {}, {} };
} }
@@ -62,28 +62,28 @@ void sfSprite_destroy(sfSprite* sprite)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfSprite_setPosition(sfSprite* sprite, sfVector2f position) void sfSprite_setPosition(sfSprite* sprite, sfVector2f position)
{ {
CSFML_CALL(sprite, setPosition(position.x, position.y)); CSFML_CALL(sprite, setPosition({ position.x, position.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfSprite_setRotation(sfSprite* sprite, float angle) void sfSprite_setRotation(sfSprite* sprite, float angle)
{ {
CSFML_CALL(sprite, setRotation(angle)); CSFML_CALL(sprite, setRotation(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfSprite_setScale(sfSprite* sprite, sfVector2f scale) void sfSprite_setScale(sfSprite* sprite, sfVector2f scale)
{ {
CSFML_CALL(sprite, setScale(scale.x, scale.y)); CSFML_CALL(sprite, setScale({ scale.x, scale.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfSprite_setOrigin(sfSprite* sprite, sfVector2f origin) void sfSprite_setOrigin(sfSprite* sprite, sfVector2f origin)
{ {
CSFML_CALL(sprite, setOrigin(origin.x, origin.y)); CSFML_CALL(sprite, setOrigin({ origin.x, origin.y }));
} }
@@ -104,7 +104,7 @@ sfVector2f sfSprite_getPosition(const sfSprite* sprite)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfSprite_getRotation(const sfSprite* sprite) float sfSprite_getRotation(const sfSprite* sprite)
{ {
CSFML_CALL_RETURN(sprite, getRotation(), 0.f); CSFML_CALL_RETURN(sprite, getRotation().asDegrees(), 0.f);
} }
@@ -139,21 +139,21 @@ sfVector2f sfSprite_getOrigin(const sfSprite* sprite)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfSprite_move(sfSprite* sprite, sfVector2f offset) void sfSprite_move(sfSprite* sprite, sfVector2f offset)
{ {
CSFML_CALL(sprite, move(offset.x, offset.y)); CSFML_CALL(sprite, move({ offset.x, offset.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfSprite_rotate(sfSprite* sprite, float angle) void sfSprite_rotate(sfSprite* sprite, float angle)
{ {
CSFML_CALL(sprite, rotate(angle)); CSFML_CALL(sprite, rotate(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfSprite_scale(sfSprite* sprite, sfVector2f factors) void sfSprite_scale(sfSprite* sprite, sfVector2f factors)
{ {
CSFML_CALL(sprite, scale(factors.x, factors.y)); CSFML_CALL(sprite, scale({ factors.x, factors.y }));
} }
@@ -191,7 +191,7 @@ void sfSprite_setTexture(sfSprite* sprite, const sfTexture* texture, bool resetR
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfSprite_setTextureRect(sfSprite* sprite, sfIntRect rectangle) void sfSprite_setTextureRect(sfSprite* sprite, sfIntRect rectangle)
{ {
CSFML_CALL(sprite, setTextureRect(sf::IntRect(rectangle.left, rectangle.top, rectangle.width, rectangle.height))); CSFML_CALL(sprite, setTextureRect(sf::IntRect({ rectangle.left, rectangle.top }, { rectangle.width, rectangle.height })));
} }
+15 -16
View File
@@ -34,12 +34,11 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfText* sfText_create(void) sfText* sfText_create(const sfFont* font)
{ {
sfText* text = new sfText; CSFML_CHECK_RETURN(font, nullptr);
text->Font = nullptr;
return text; return new sfText{ sf::Text{font->This}, font, {}, {}, {} };
} }
@@ -62,28 +61,28 @@ void sfText_destroy(sfText* text)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfText_setPosition(sfText* text, sfVector2f position) void sfText_setPosition(sfText* text, sfVector2f position)
{ {
CSFML_CALL(text, setPosition(position.x, position.y)); CSFML_CALL(text, setPosition({ position.x, position.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfText_setRotation(sfText* text, float angle) void sfText_setRotation(sfText* text, float angle)
{ {
CSFML_CALL(text, setRotation(angle)); CSFML_CALL(text, setRotation(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfText_setScale(sfText* text, sfVector2f scale) void sfText_setScale(sfText* text, sfVector2f scale)
{ {
CSFML_CALL(text, setScale(scale.x, scale.y)); CSFML_CALL(text, setScale({ scale.x, scale.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfText_setOrigin(sfText* text, sfVector2f origin) void sfText_setOrigin(sfText* text, sfVector2f origin)
{ {
CSFML_CALL(text, setOrigin(origin.x, origin.y)); CSFML_CALL(text, setOrigin({ origin.x, origin.y }));
} }
@@ -104,7 +103,7 @@ sfVector2f sfText_getPosition(const sfText* text)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfText_getRotation(const sfText* text) float sfText_getRotation(const sfText* text)
{ {
CSFML_CALL_RETURN(text, getRotation(), 0.f); CSFML_CALL_RETURN(text, getRotation().asDegrees(), 0.f);
} }
@@ -139,21 +138,21 @@ sfVector2f sfText_getOrigin(const sfText* text)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfText_move(sfText* text, sfVector2f offset) void sfText_move(sfText* text, sfVector2f offset)
{ {
CSFML_CALL(text, move(offset.x, offset.y)); CSFML_CALL(text, move({ offset.x, offset.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfText_rotate(sfText* text, float angle) void sfText_rotate(sfText* text, float angle)
{ {
CSFML_CALL(text, rotate(angle)); CSFML_CALL(text, rotate(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfText_scale(sfText* text, sfVector2f factors) void sfText_scale(sfText* text, sfVector2f factors)
{ {
CSFML_CALL(text, scale(factors.x, factors.y)); CSFML_CALL(text, scale({ factors.x, factors.y }));
} }
@@ -185,9 +184,9 @@ void sfText_setString(sfText* text, const char* string)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfText_setUnicodeString(sfText* text, const uint32_t* string) void sfText_setUnicodeString(sfText* text, const sfChar32* string)
{ {
sf::String UTF32Text = string; sf::String UTF32Text = reinterpret_cast<const char32_t*>(string);
CSFML_CALL(text, setString(UTF32Text)); CSFML_CALL(text, setString(UTF32Text));
} }
@@ -270,11 +269,11 @@ const char* sfText_getString(const sfText* text)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const uint32_t* sfText_getUnicodeString(const sfText* text) const sfChar32* sfText_getUnicodeString(const sfText* text)
{ {
CSFML_CHECK_RETURN(text, nullptr); CSFML_CHECK_RETURN(text, nullptr);
return text->This.getString().getData(); return reinterpret_cast<const sfChar32*>(text->This.getString().getData());
} }
+15 -15
View File
@@ -39,7 +39,7 @@ sfTexture* sfTexture_create(unsigned int width, unsigned int height)
{ {
sfTexture* texture = new sfTexture; sfTexture* texture = new sfTexture;
if (!texture->This->create(width, height)) if (!texture->This->create({ width, height }))
{ {
delete texture; delete texture;
texture = nullptr; texture = nullptr;
@@ -56,7 +56,7 @@ sfTexture* sfTexture_createFromFile(const char* filename, const sfIntRect* area)
sf::IntRect rect; sf::IntRect rect;
if (area) if (area)
rect = sf::IntRect(area->left, area->top, area->width, area->height); rect = sf::IntRect({ area->left, area->top }, { area->width, area->height });
if (!texture->This->loadFromFile(filename, rect)) if (!texture->This->loadFromFile(filename, rect))
{ {
@@ -74,7 +74,7 @@ sfTexture* sfTexture_createSrgbFromFile(const char* filename, const sfIntRect* a
sf::IntRect rect; sf::IntRect rect;
if (area) if (area)
rect = sf::IntRect(area->left, area->top, area->width, area->height); rect = sf::IntRect({ area->left, area->top }, { area->width, area->height });
texture->This->setSrgb(true); texture->This->setSrgb(true);
@@ -94,7 +94,7 @@ sfTexture* sfTexture_createFromMemory(const void* data, size_t sizeInBytes, cons
sf::IntRect rect; sf::IntRect rect;
if (area) if (area)
rect = sf::IntRect(area->left, area->top, area->width, area->height); rect = sf::IntRect({ area->left, area->top }, { area->width, area->height });
if (!texture->This->loadFromMemory(data, sizeInBytes, rect)) if (!texture->This->loadFromMemory(data, sizeInBytes, rect))
{ {
@@ -112,7 +112,7 @@ sfTexture* sfTexture_createSrgbFromMemory(const void* data, size_t sizeInBytes,
sf::IntRect rect; sf::IntRect rect;
if (area) if (area)
rect = sf::IntRect(area->left, area->top, area->width, area->height); rect = sf::IntRect({ area->left, area->top }, { area->width, area->height });
texture->This->setSrgb(true); texture->This->setSrgb(true);
@@ -135,7 +135,7 @@ sfTexture* sfTexture_createFromStream(sfInputStream* stream, const sfIntRect* ar
sf::IntRect rect; sf::IntRect rect;
if (area) if (area)
rect = sf::IntRect(area->left, area->top, area->width, area->height); rect = sf::IntRect({ area->left, area->top }, { area->width, area->height });
CallbackStream sfmlStream(stream); CallbackStream sfmlStream(stream);
if (!texture->This->loadFromStream(sfmlStream, rect)) if (!texture->This->loadFromStream(sfmlStream, rect))
@@ -156,7 +156,7 @@ sfTexture* sfTexture_createSrgbFromStream(sfInputStream* stream, const sfIntRect
sf::IntRect rect; sf::IntRect rect;
if (area) if (area)
rect = sf::IntRect(area->left, area->top, area->width, area->height); rect = sf::IntRect({ area->left, area->top }, { area->width, area->height });
texture->This->setSrgb(true); texture->This->setSrgb(true);
@@ -180,7 +180,7 @@ sfTexture* sfTexture_createFromImage(const sfImage* image, const sfIntRect* area
sf::IntRect rect; sf::IntRect rect;
if (area) if (area)
rect = sf::IntRect(area->left, area->top, area->width, area->height); rect = sf::IntRect({ area->left, area->top }, { area->width, area->height });
if (!texture->This->loadFromImage(image->This, rect)) if (!texture->This->loadFromImage(image->This, rect))
{ {
@@ -200,7 +200,7 @@ sfTexture* sfTexture_createSrgbFromImage(const sfImage* image, const sfIntRect*
sf::IntRect rect; sf::IntRect rect;
if (area) if (area)
rect = sf::IntRect(area->left, area->top, area->width, area->height); rect = sf::IntRect({ area->left, area->top }, { area->width, area->height });
texture->This->setSrgb(true); texture->This->setSrgb(true);
@@ -260,7 +260,7 @@ sfImage* sfTexture_copyToImage(const sfTexture* texture)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTexture_updateFromPixels(sfTexture* texture, const uint8_t* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y) void sfTexture_updateFromPixels(sfTexture* texture, const uint8_t* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y)
{ {
CSFML_CALL_PTR(texture, update(pixels, width, height, x, y)); CSFML_CALL_PTR(texture, update(pixels, { width, height }, { x, y }));
} }
@@ -270,7 +270,7 @@ void sfTexture_updateFromTexture(sfTexture* destination, const sfTexture* textur
CSFML_CHECK(texture); CSFML_CHECK(texture);
CSFML_CHECK(texture->This); CSFML_CHECK(texture->This);
CSFML_CALL_PTR(destination, update(*texture->This, x, y)); CSFML_CALL_PTR(destination, update(*texture->This, { x, y }));
} }
@@ -279,7 +279,7 @@ void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, unsigne
{ {
CSFML_CHECK(image); CSFML_CHECK(image);
CSFML_CALL_PTR(texture, update(image->This, x, y)); CSFML_CALL_PTR(texture, update(image->This, { x, y }));
} }
@@ -288,7 +288,7 @@ void sfTexture_updateFromWindow(sfTexture* texture, const sfWindow* window, unsi
{ {
CSFML_CHECK(window); CSFML_CHECK(window);
CSFML_CALL_PTR(texture, update(window->This, x, y)); CSFML_CALL_PTR(texture, update(window->This, { x, y }));
} }
@@ -297,7 +297,7 @@ void sfTexture_updateFromRenderWindow(sfTexture* texture, const sfRenderWindow*
{ {
CSFML_CHECK(renderWindow); CSFML_CHECK(renderWindow);
CSFML_CALL_PTR(texture, update(renderWindow->This, x, y)); CSFML_CALL_PTR(texture, update(renderWindow->This, { x, y }));
} }
@@ -367,7 +367,7 @@ unsigned int sfTexture_getNativeHandle(const sfTexture* texture)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTexture_bind(const sfTexture* texture, sfTextureCoordinateType type) void sfTexture_bind(const sfTexture* texture, sfTextureCoordinateType type)
{ {
sf::Texture::bind(texture ? texture->This : nullptr, static_cast<sf::Texture::CoordinateType>(type)); sf::Texture::bind(texture ? texture->This : nullptr, static_cast<sf::CoordinateType>(type));
} }
+7 -7
View File
@@ -77,7 +77,7 @@ sfVector2f sfTransform_transformPoint(const sfTransform* transform, sfVector2f p
sfVector2f p = {0, 0}; sfVector2f p = {0, 0};
CSFML_CHECK_RETURN(transform, p); CSFML_CHECK_RETURN(transform, p);
sf::Vector2f sfmlPoint = convertTransform(*transform).transformPoint(point.x, point.y); sf::Vector2f sfmlPoint = convertTransform(*transform).transformPoint({ point.x, point.y });
p.x = sfmlPoint.x; p.x = sfmlPoint.x;
p.y = sfmlPoint.y; p.y = sfmlPoint.y;
@@ -92,7 +92,7 @@ sfFloatRect sfTransform_transformRect(const sfTransform* transform, sfFloatRect
sfFloatRect rect = {0, 0, 0, 0}; sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(transform, rect); CSFML_CHECK_RETURN(transform, rect);
sf::FloatRect sfmlRect = convertTransform(*transform).transformRect(sf::FloatRect(rectangle.left, rectangle.top, rectangle.width, rectangle.height)); sf::FloatRect sfmlRect = convertTransform(*transform).transformRect(sf::FloatRect({ rectangle.left, rectangle.top }, { rectangle.width, rectangle.height }));
rect.left = sfmlRect.left; rect.left = sfmlRect.left;
rect.top = sfmlRect.top; rect.top = sfmlRect.top;
@@ -118,7 +118,7 @@ void sfTransform_translate(sfTransform* transform, float x, float y)
{ {
CSFML_CHECK(transform); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).translate(x, y)); *transform = convertTransform(convertTransform(*transform).translate({ x, y }));
} }
@@ -127,7 +127,7 @@ void sfTransform_rotate(sfTransform* transform, float angle)
{ {
CSFML_CHECK(transform); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).rotate(angle)); *transform = convertTransform(convertTransform(*transform).rotate(sf::degrees(angle)));
} }
@@ -136,7 +136,7 @@ void sfTransform_rotateWithCenter(sfTransform* transform, float angle, float cen
{ {
CSFML_CHECK(transform); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).rotate(angle, centerX, centerY)); *transform = convertTransform(convertTransform(*transform).rotate(sf::degrees(angle), { centerX, centerY }));
} }
@@ -145,7 +145,7 @@ void sfTransform_scale(sfTransform* transform, float scaleX, float scaleY)
{ {
CSFML_CHECK(transform); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).scale(scaleX, scaleY)); *transform = convertTransform(convertTransform(*transform).scale({ scaleX, scaleY }));
} }
@@ -154,7 +154,7 @@ void sfTransform_scaleWithCenter(sfTransform* transform, float scaleX, float sca
{ {
CSFML_CHECK(transform); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).scale(scaleX, scaleY, centerX, centerY)); *transform = convertTransform(convertTransform(*transform).scale({ scaleX, scaleY }, { centerX, centerY }));
} }
+8 -8
View File
@@ -59,28 +59,28 @@ void sfTransformable_destroy(sfTransformable* transformable)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransformable_setPosition(sfTransformable* transformable, sfVector2f position) void sfTransformable_setPosition(sfTransformable* transformable, sfVector2f position)
{ {
CSFML_CALL(transformable, setPosition(position.x, position.y)); CSFML_CALL(transformable, setPosition({ position.x, position.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransformable_setRotation(sfTransformable* transformable, float angle) void sfTransformable_setRotation(sfTransformable* transformable, float angle)
{ {
CSFML_CALL(transformable, setRotation(angle)); CSFML_CALL(transformable, setRotation(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransformable_setScale(sfTransformable* transformable, sfVector2f scale) void sfTransformable_setScale(sfTransformable* transformable, sfVector2f scale)
{ {
CSFML_CALL(transformable, setScale(scale.x, scale.y)); CSFML_CALL(transformable, setScale({ scale.x, scale.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransformable_setOrigin(sfTransformable* transformable, sfVector2f origin) void sfTransformable_setOrigin(sfTransformable* transformable, sfVector2f origin)
{ {
CSFML_CALL(transformable, setOrigin(origin.x, origin.y)); CSFML_CALL(transformable, setOrigin({ origin.x, origin.y }));
} }
@@ -101,7 +101,7 @@ sfVector2f sfTransformable_getPosition(const sfTransformable* transformable)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfTransformable_getRotation(const sfTransformable* transformable) float sfTransformable_getRotation(const sfTransformable* transformable)
{ {
CSFML_CALL_RETURN(transformable, getRotation(), 0.f); CSFML_CALL_RETURN(transformable, getRotation().asDegrees(), 0.f);
} }
@@ -136,21 +136,21 @@ sfVector2f sfTransformable_getOrigin(const sfTransformable* transformable)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransformable_move(sfTransformable* transformable, sfVector2f offset) void sfTransformable_move(sfTransformable* transformable, sfVector2f offset)
{ {
CSFML_CALL(transformable, move(offset.x, offset.y)); CSFML_CALL(transformable, move({ offset.x, offset.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransformable_rotate(sfTransformable* transformable, float angle) void sfTransformable_rotate(sfTransformable* transformable, float angle)
{ {
CSFML_CALL(transformable, rotate(angle)); CSFML_CALL(transformable, rotate(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransformable_scale(sfTransformable* transformable, sfVector2f factors) void sfTransformable_scale(sfTransformable* transformable, sfVector2f factors)
{ {
CSFML_CALL(transformable, scale(factors.x, factors.y)); CSFML_CALL(transformable, scale({ factors.x, factors.y }));
} }
+8 -8
View File
@@ -66,35 +66,35 @@ void sfView_destroy(sfView* view)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_setCenter(sfView* view, sfVector2f center) void sfView_setCenter(sfView* view, sfVector2f center)
{ {
CSFML_CALL(view, setCenter(center.x, center.y)); CSFML_CALL(view, setCenter({ center.x, center.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_setSize(sfView* view, sfVector2f size) void sfView_setSize(sfView* view, sfVector2f size)
{ {
CSFML_CALL(view, setSize(size.x, size.y)); CSFML_CALL(view, setSize({ size.x, size.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_setRotation(sfView* view, float angle) void sfView_setRotation(sfView* view, float angle)
{ {
CSFML_CALL(view, setRotation(angle)); CSFML_CALL(view, setRotation(sf::degrees(angle)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_setViewport(sfView* view, sfFloatRect viewport) void sfView_setViewport(sfView* view, sfFloatRect viewport)
{ {
CSFML_CALL(view, setViewport(sf::FloatRect(viewport.left, viewport.top, viewport.width, viewport.height))); CSFML_CALL(view, setViewport(sf::FloatRect({ viewport.left, viewport.top }, { viewport.width, viewport.height })));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_reset(sfView* view, sfFloatRect rectangle) void sfView_reset(sfView* view, sfFloatRect rectangle)
{ {
CSFML_CALL(view, reset(sf::FloatRect(rectangle.left, rectangle.top, rectangle.width, rectangle.height))); CSFML_CALL(view, reset(sf::FloatRect({ rectangle.left, rectangle.top }, { rectangle.width, rectangle.height })));
} }
@@ -129,7 +129,7 @@ sfVector2f sfView_getSize(const sfView* view)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float sfView_getRotation(const sfView* view) float sfView_getRotation(const sfView* view)
{ {
CSFML_CALL_RETURN(view, getRotation(), 0.f); CSFML_CALL_RETURN(view, getRotation().asDegrees(), 0.f);
} }
@@ -152,14 +152,14 @@ sfFloatRect sfView_getViewport(const sfView* view)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_move(sfView* view, sfVector2f offset) void sfView_move(sfView* view, sfVector2f offset)
{ {
CSFML_CALL(view, move(offset.x, offset.y)); CSFML_CALL(view, move({ offset.x, offset.y }));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfView_rotate(sfView* view, float angle) void sfView_rotate(sfView* view, float angle)
{ {
CSFML_CALL(view, rotate(angle)); CSFML_CALL(view, rotate(sf::degrees(angle)));
} }
+11
View File
@@ -25,10 +25,13 @@
#ifndef SFML_INTERNAL_H #ifndef SFML_INTERNAL_H
#define SFML_INTERNAL_H #define SFML_INTERNAL_H
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Define macros to check the validity of CSFML objects in debug run // Define macros to check the validity of CSFML objects in debug run
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System/Err.hpp> #include <SFML/System/Err.hpp>
#include <SFML/Config.h>
#include <ostream>
#ifndef NDEBUG #ifndef NDEBUG
@@ -131,4 +134,12 @@
#endif #endif
////////////////////////////////////////////////////////////
// Ensure char32_t has the same size as sfChar32 (uint32_t)
// Identical alignment and size is required because we're type punning
// when doing sfChar32* <-> char32_t* casts
////////////////////////////////////////////////////////////
static_assert(sizeof(sfChar32) == sizeof(char32_t));
static_assert(alignof(sfChar32) == alignof(char32_t));
#endif // SFML_INTERNAL_H #endif // SFML_INTERNAL_H
+1 -1
View File
@@ -35,4 +35,4 @@ set(SRC
# define the csfml-network target # define the csfml-network target
csfml_add_library(csfml-network csfml_add_library(csfml-network
SOURCES ${SRC} SOURCES ${SRC}
DEPENDS sfml-network) DEPENDS SFML::Network)
+18 -3
View File
@@ -28,7 +28,10 @@
#include <SFML/Network/Ftp.h> #include <SFML/Network/Ftp.h>
#include <SFML/Network/FtpStruct.h> #include <SFML/Network/FtpStruct.h>
#include <SFML/Network/IpAddress.hpp> #include <SFML/Network/IpAddress.hpp>
#include <SFML/System/String.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
#include <string.h>
#include <SFML/Char32.hpp>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@@ -117,8 +120,17 @@ const char* sfFtpDirectoryResponse_getMessage(const sfFtpDirectoryResponse* ftpD
const char* sfFtpDirectoryResponse_getDirectory(const sfFtpDirectoryResponse* ftpDirectoryResponse) const char* sfFtpDirectoryResponse_getDirectory(const sfFtpDirectoryResponse* ftpDirectoryResponse)
{ {
CSFML_CHECK_RETURN(ftpDirectoryResponse, nullptr); CSFML_CHECK_RETURN(ftpDirectoryResponse, nullptr);
return strdup(ftpDirectoryResponse->This.getDirectory().string().c_str());
}
return ftpDirectoryResponse->This.getDirectory().c_str();
////////////////////////////////////////////////////////////
const sfChar32* sfFtpDirectoryResponse_getDirectoryUnicode(const sfFtpDirectoryResponse* ftpDirectoryResponse)
{
CSFML_CHECK_RETURN(ftpDirectoryResponse, nullptr);
sf::String str = sf::String(ftpDirectoryResponse->This.getDirectory().c_str());
return copyToChar32(str);
} }
@@ -173,9 +185,12 @@ sfFtpResponse* sfFtp_connect(sfFtp* ftp, sfIpAddress server, unsigned short port
{ {
CSFML_CHECK_RETURN(ftp, nullptr); CSFML_CHECK_RETURN(ftp, nullptr);
sf::IpAddress SFMLServer(server.address); std::optional<sf::IpAddress> SFMLServer = sf::IpAddress::resolve(server.address);
return new sfFtpResponse(ftp->This.connect(SFMLServer, port, sf::microseconds(timeout.microseconds))); if (!SFMLServer)
return nullptr;
return new sfFtpResponse(ftp->This.connect(*SFMLServer, port, sf::microseconds(timeout.microseconds)));
} }
+11 -6
View File
@@ -33,18 +33,22 @@
namespace namespace
{ {
// Helper function for converting a SFML address to a CSFML one // Helper function for converting a SFML address to a CSFML one
sfIpAddress fromSFMLAddress(sf::IpAddress address) sfIpAddress fromSFMLAddress(std::optional<sf::IpAddress> address)
{ {
sfIpAddress result = {0}; sfIpAddress result = {0};
strncpy(result.address, address.toString().c_str(), 15);
if (address)
{
strncpy(result.address, address->toString().c_str(), 15);
}
return result; return result;
} }
// Helper function for converting a CSFML address to a SFML one // Helper function for converting a CSFML address to a SFML one
sf::IpAddress toSFMLAddress(sfIpAddress address) std::optional<sf::IpAddress> toSFMLAddress(sfIpAddress address)
{ {
return sf::IpAddress(address.address); return sf::IpAddress::resolve(address.address);
} }
} }
@@ -68,7 +72,7 @@ const sfIpAddress sfIpAddress_Broadcast = sfIpAddress_fromBytes(255, 255, 255, 2
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfIpAddress sfIpAddress_fromString(const char* address) sfIpAddress sfIpAddress_fromString(const char* address)
{ {
return fromSFMLAddress(sf::IpAddress(address)); return fromSFMLAddress(sf::IpAddress::resolve(address));
} }
@@ -97,7 +101,8 @@ void sfIpAddress_toString(sfIpAddress address, char* string)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
uint32_t sfIpAddress_toInteger(sfIpAddress address) uint32_t sfIpAddress_toInteger(sfIpAddress address)
{ {
return toSFMLAddress(address).toInteger(); auto sfmlAddress = toSFMLAddress(address);
return sfmlAddress ? sfmlAddress->toInteger() : 0;
} }
+1 -1
View File
@@ -99,7 +99,7 @@ bool sfPacket_endOfPacket(const sfPacket* packet)
bool sfPacket_canRead(const sfPacket* packet) bool sfPacket_canRead(const sfPacket* packet)
{ {
CSFML_CHECK_RETURN(packet, false); CSFML_CHECK_RETURN(packet, false);
return packet->This; return static_cast<bool>(packet->This);
} }
+8 -2
View File
@@ -71,8 +71,14 @@ sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, unsigned short port
{ {
CSFML_CHECK_RETURN(listener, sfSocketError); CSFML_CHECK_RETURN(listener, sfSocketError);
sf::IpAddress sfmlAddress(address.address); std::optional<sf::IpAddress> sfmlAddress = sf::IpAddress::resolve(address.address);
return static_cast<sfSocketStatus>(listener->This.listen(port, sfmlAddress));
if (!sfmlAddress)
{
return sfSocketError;
}
return static_cast<sfSocketStatus>(listener->This.listen(port, *sfmlAddress));
} }
+13 -4
View File
@@ -74,8 +74,12 @@ sfIpAddress sfTcpSocket_getRemoteAddress(const sfTcpSocket* socket)
sfIpAddress result = sfIpAddress_None; sfIpAddress result = sfIpAddress_None;
CSFML_CHECK_RETURN(socket, result); CSFML_CHECK_RETURN(socket, result);
sf::IpAddress address = socket->This.getRemoteAddress(); std::optional<sf::IpAddress> address = socket->This.getRemoteAddress();
strncpy(result.address, address.toString().c_str(), 15);
if (address)
{
strncpy(result.address, address->toString().c_str(), 15);
}
return result; return result;
} }
@@ -91,11 +95,16 @@ unsigned short sfTcpSocket_getRemotePort(const sfTcpSocket* socket)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfSocketStatus sfTcpSocket_connect(sfTcpSocket* socket, sfIpAddress remoteAddress, unsigned short remotePort, sfTime timeout) sfSocketStatus sfTcpSocket_connect(sfTcpSocket* socket, sfIpAddress remoteAddress, unsigned short remotePort, sfTime timeout)
{ {
sf::IpAddress address(remoteAddress.address); std::optional<sf::IpAddress> address = sf::IpAddress::resolve(remoteAddress.address);
if (!address)
{
return sfSocketError;
}
CSFML_CHECK_RETURN(socket, sfSocketError); CSFML_CHECK_RETURN(socket, sfSocketError);
return static_cast<sfSocketStatus>(socket->This.connect(address, remotePort, sf::microseconds(timeout.microseconds))); return static_cast<sfSocketStatus>(socket->This.connect(*address, remotePort, sf::microseconds(timeout.microseconds)));
} }
+36 -12
View File
@@ -72,8 +72,14 @@ sfSocketStatus sfUdpSocket_bind(sfUdpSocket* socket, unsigned short port, sfIpAd
{ {
CSFML_CHECK_RETURN(socket, sfSocketError); CSFML_CHECK_RETURN(socket, sfSocketError);
sf::IpAddress sfmlAddress(address.address); std::optional<sf::IpAddress> sfmlAddress = sf::IpAddress::resolve(address.address);
return static_cast<sfSocketStatus>(socket->This.bind(port, sfmlAddress));
if (!sfmlAddress)
{
return sfSocketError;
}
return static_cast<sfSocketStatus>(socket->This.bind(port, *sfmlAddress));
} }
@@ -90,9 +96,14 @@ sfSocketStatus sfUdpSocket_send(sfUdpSocket* socket, const void* data, size_t si
CSFML_CHECK_RETURN(socket, sfSocketError); CSFML_CHECK_RETURN(socket, sfSocketError);
// Convert the address // Convert the address
sf::IpAddress address(remoteAddress.address); std::optional<sf::IpAddress> address = sf::IpAddress::resolve(remoteAddress.address);
return static_cast<sfSocketStatus>(socket->This.send(data, size, address, remotePort)); if (!address)
{
return sfSocketError;
}
return static_cast<sfSocketStatus>(socket->This.send(data, size, *address, remotePort));
} }
@@ -101,12 +112,12 @@ sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket, void* data, size_t size,
{ {
CSFML_CHECK_RETURN(socket, sfSocketError); CSFML_CHECK_RETURN(socket, sfSocketError);
sf::IpAddress address; std::optional<sf::IpAddress> address;
unsigned short port; unsigned short port;
std::size_t sizeReceived; std::size_t sizeReceived;
sf::Socket::Status status = socket->This.receive(data, size, sizeReceived, address, port); sf::Socket::Status status = socket->This.receive(data, size, sizeReceived, address, port);
if (status != sf::Socket::Done) if (status != sf::Socket::Status::Done)
return static_cast<sfSocketStatus>(status); return static_cast<sfSocketStatus>(status);
if (received) if (received)
@@ -115,7 +126,11 @@ sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket, void* data, size_t size,
if (remoteAddress) if (remoteAddress)
{ {
*remoteAddress = sfIpAddress_None; *remoteAddress = sfIpAddress_None;
strncpy(remoteAddress->address, address.toString().c_str(), 15);
if (address)
{
strncpy(remoteAddress->address, address->toString().c_str(), 15);
}
} }
if (remotePort) if (remotePort)
@@ -132,9 +147,14 @@ sfSocketStatus sfUdpSocket_sendPacket(sfUdpSocket* socket, sfPacket* packet, sfI
CSFML_CHECK_RETURN(packet, sfSocketError); CSFML_CHECK_RETURN(packet, sfSocketError);
// Convert the address // Convert the address
sf::IpAddress address(remoteAddress.address); std::optional<sf::IpAddress> address = sf::IpAddress::resolve(remoteAddress.address);
return static_cast<sfSocketStatus>(socket->This.send(packet->This, address, remotePort)); if (!address)
{
return sfSocketError;
}
return static_cast<sfSocketStatus>(socket->This.send(packet->This, *address, remotePort));
} }
@@ -144,17 +164,21 @@ sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet,
CSFML_CHECK_RETURN(socket, sfSocketError); CSFML_CHECK_RETURN(socket, sfSocketError);
CSFML_CHECK_RETURN(packet, sfSocketError); CSFML_CHECK_RETURN(packet, sfSocketError);
sf::IpAddress address; std::optional<sf::IpAddress> address;
unsigned short port; unsigned short port;
sf::Socket::Status status = socket->This.receive(packet->This, address, port); sf::Socket::Status status = socket->This.receive(packet->This, address, port);
if (status != sf::Socket::Done) if (status != sf::Socket::Status::Done)
return static_cast<sfSocketStatus>(status); return static_cast<sfSocketStatus>(status);
if (remoteAddress) if (remoteAddress)
{ {
*remoteAddress = sfIpAddress_None; *remoteAddress = sfIpAddress_None;
strncpy(remoteAddress->address, address.toString().c_str(), 15);
if (address)
{
strncpy(remoteAddress->address, address->toString().c_str(), 15);
}
} }
if (remotePort) if (remotePort)
+2 -1
View File
@@ -30,6 +30,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Config.hpp> #include <SFML/Config.hpp>
#include <vector> #include <vector>
#include <cstdint>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@@ -37,7 +38,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct sfBuffer struct sfBuffer
{ {
std::vector<sf::Uint8> buffer; std::vector<std::uint8_t> buffer;
}; };
+1 -7
View File
@@ -13,14 +13,8 @@ set(SRC
${SRCROOT}/ClockStruct.h ${SRCROOT}/ClockStruct.h
${INCROOT}/Clock.h ${INCROOT}/Clock.h
${INCROOT}/InputStream.h ${INCROOT}/InputStream.h
${SRCROOT}/Mutex.cpp
${SRCROOT}/MutexStruct.h
${INCROOT}/Mutex.h
${SRCROOT}/Sleep.cpp ${SRCROOT}/Sleep.cpp
${INCROOT}/Sleep.h ${INCROOT}/Sleep.h
${SRCROOT}/Thread.cpp
${SRCROOT}/ThreadStruct.h
${INCROOT}/Thread.h
${SRCROOT}/Time.cpp ${SRCROOT}/Time.cpp
${INCROOT}/Time.h ${INCROOT}/Time.h
${INCROOT}/Types.h ${INCROOT}/Types.h
@@ -31,4 +25,4 @@ set(SRC
# define the csfml-system target # define the csfml-system target
csfml_add_library(csfml-system csfml_add_library(csfml-system
SOURCES ${SRC} SOURCES ${SRC}
DEPENDS sfml-system) DEPENDS SFML::System)
+1
View File
@@ -27,6 +27,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System/Clock.h> #include <SFML/System/Clock.h>
#include <SFML/System/ClockStruct.h> #include <SFML/System/ClockStruct.h>
#include <SFML/System/Time.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
-43
View File
@@ -1,43 +0,0 @@
////////////////////////////////////////////////////////////
//
// 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_MUTEXSTRUCT_H
#define SFML_MUTEXSTRUCT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Mutex.hpp>
////////////////////////////////////////////////////////////
// Internal structure of sfMutex
////////////////////////////////////////////////////////////
struct sfMutex
{
sf::Mutex This;
};
#endif // SFML_MUTEXSTRUCT_H
+1
View File
@@ -27,6 +27,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System/Sleep.h> #include <SFML/System/Sleep.h>
#include <SFML/System/Sleep.hpp> #include <SFML/System/Sleep.hpp>
#include <SFML/System/Time.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
-65
View File
@@ -1,65 +0,0 @@
////////////////////////////////////////////////////////////
//
// 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/Thread.h>
#include <SFML/System/ThreadStruct.h>
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
sfThread* sfThread_create(void (*function)(void*), void* userData)
{
return new sfThread(function, userData);
}
////////////////////////////////////////////////////////////
void sfThread_destroy(sfThread* thread)
{
delete thread;
}
////////////////////////////////////////////////////////////
void sfThread_launch(sfThread* thread)
{
CSFML_CALL(thread, launch());
}
////////////////////////////////////////////////////////////
void sfThread_wait(sfThread* thread)
{
CSFML_CALL(thread, wait());
}
////////////////////////////////////////////////////////////
void sfThread_terminate(sfThread* thread)
{
CSFML_CALL(thread, terminate());
}
-48
View File
@@ -1,48 +0,0 @@
////////////////////////////////////////////////////////////
//
// 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_THREADSTRUCT_H
#define SFML_THREADSTRUCT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/Thread.hpp>
////////////////////////////////////////////////////////////
// Internal structure of sfThread
////////////////////////////////////////////////////////////
struct sfThread
{
sfThread(void (*function)(void*), void* userData) :
This(function, userData)
{
}
sf::Thread This;
};
#endif // SFML_THREADSTRUCT_H
+1 -1
View File
@@ -43,4 +43,4 @@ set(SRC
# define the csfml-window target # define the csfml-window target
csfml_add_library(csfml-window csfml_add_library(csfml-window
SOURCES ${SRC} SOURCES ${SRC}
DEPENDS sfml-window) DEPENDS SFML::Window)
+6 -4
View File
@@ -25,9 +25,11 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System/String.hpp>
#include <SFML/Window/Clipboard.h> #include <SFML/Window/Clipboard.h>
#include <SFML/Window/Clipboard.hpp> #include <SFML/Window/Clipboard.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
#include <string>
namespace namespace
@@ -46,10 +48,10 @@ const char* sfClipboard_getString()
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const uint32_t* sfClipboard_getUnicodeString() const sfChar32* sfClipboard_getUnicodeString()
{ {
ClipboardString = sf::Clipboard::getString(); ClipboardString = sf::Clipboard::getString();
return ClipboardString.getData(); return reinterpret_cast<const sfChar32*>(ClipboardString.getData());
} }
@@ -61,7 +63,7 @@ void sfClipboard_setString(const char* text)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfClipboard_setUnicodeString(const uint32_t* text) void sfClipboard_setUnicodeString(const sfChar32* text)
{ {
sf::Clipboard::setString(text); sf::Clipboard::setString(reinterpret_cast<const char32_t*>(text));
} }
+5 -5
View File
@@ -35,8 +35,8 @@ sfVideoMode sfVideoMode_getDesktopMode(void)
{ {
sf::VideoMode desktop = sf::VideoMode::getDesktopMode(); sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
sfVideoMode ret; sfVideoMode ret;
ret.width = desktop.width; ret.width = desktop.size.x;
ret.height = desktop.height; ret.height = desktop.size.y;
ret.bitsPerPixel = desktop.bitsPerPixel; ret.bitsPerPixel = desktop.bitsPerPixel;
return ret; return ret;
@@ -55,8 +55,8 @@ const sfVideoMode* sfVideoMode_getFullscreenModes(size_t* count)
for (const auto& sfmlMode : sfmlModes) for (const auto& sfmlMode : sfmlModes)
{ {
sfVideoMode mode; sfVideoMode mode;
mode.width = sfmlMode.width; mode.width = sfmlMode.size.x;
mode.height = sfmlMode.height; mode.height = sfmlMode.size.y;
mode.bitsPerPixel = sfmlMode.bitsPerPixel; mode.bitsPerPixel = sfmlMode.bitsPerPixel;
modes.push_back(mode); modes.push_back(mode);
} }
@@ -72,6 +72,6 @@ const sfVideoMode* sfVideoMode_getFullscreenModes(size_t* count)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool sfVideoMode_isValid(sfVideoMode mode) bool sfVideoMode_isValid(sfVideoMode mode)
{ {
sf::VideoMode videoMode(mode.width, mode.height, mode.bitsPerPixel); sf::VideoMode videoMode({ mode.width, mode.height }, mode.bitsPerPixel);
return videoMode.isValid(); return videoMode.isValid();
} }
+11 -11
View File
@@ -34,10 +34,10 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfWindow* sfWindow_create(sfVideoMode mode, const char* title, uint32_t style, const sfContextSettings* settings) sfWindow* sfWindow_create(sfVideoMode mode, const char* title, uint32_t style, sfWindowState state, const sfContextSettings* settings)
{ {
// Convert video mode // Convert video mode
sf::VideoMode videoMode(mode.width, mode.height, mode.bitsPerPixel); sf::VideoMode videoMode({ mode.width, mode.height }, mode.bitsPerPixel);
// Convert context settings // Convert context settings
sf::ContextSettings params; sf::ContextSettings params;
@@ -48,16 +48,16 @@ sfWindow* sfWindow_create(sfVideoMode mode, const char* title, uint32_t style, c
// Create the window // Create the window
sfWindow* window = new sfWindow; sfWindow* window = new sfWindow;
window->This.create(videoMode, title, style, params); window->This.create(videoMode, title, style, static_cast<sf::State>(state), params);
return window; return window;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfWindow* sfWindow_createUnicode(sfVideoMode mode, const uint32_t* title, uint32_t style, const sfContextSettings* settings) sfWindow* sfWindow_createUnicode(sfVideoMode mode, const sfChar32* title, uint32_t style, sfWindowState state, const sfContextSettings* settings)
{ {
// Convert video mode // Convert video mode
sf::VideoMode videoMode(mode.width, mode.height, mode.bitsPerPixel); sf::VideoMode videoMode({ mode.width, mode.height }, mode.bitsPerPixel);
// Convert context settings // Convert context settings
sf::ContextSettings params; sf::ContextSettings params;
@@ -68,7 +68,7 @@ sfWindow* sfWindow_createUnicode(sfVideoMode mode, const uint32_t* title, uint32
// Create the window // Create the window
sfWindow* window = new sfWindow; sfWindow* window = new sfWindow;
window->This.create(videoMode, title, style, params); window->This.create(videoMode, reinterpret_cast<const char32_t*>(title), style, static_cast<sf::State>(state), params);
return window; return window;
} }
@@ -217,16 +217,16 @@ void sfWindow_setTitle(sfWindow* window, const char* title)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfWindow_setUnicodeTitle(sfWindow* window, const uint32_t* title) void sfWindow_setUnicodeTitle(sfWindow* window, const sfChar32* title)
{ {
CSFML_CALL(window, setTitle(title)); CSFML_CALL(window, setTitle(reinterpret_cast<const char32_t*>(title)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfWindow_setIcon(sfWindow* window, unsigned int width, unsigned int height, const uint8_t* pixels) void sfWindow_setIcon(sfWindow* window, unsigned int width, unsigned int height, const uint8_t* pixels)
{ {
CSFML_CALL(window, setIcon(width, height, pixels)); CSFML_CALL(window, setIcon({ width, height }, pixels));
} }
@@ -316,9 +316,9 @@ void sfWindow_setJoystickThreshold(sfWindow* window, float threshold)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfWindowHandle sfWindow_getSystemHandle(const sfWindow* window) sfWindowHandle sfWindow_getNativeHandle(const sfWindow* window)
{ {
CSFML_CHECK_RETURN(window, 0); CSFML_CHECK_RETURN(window, 0);
return static_cast<sfWindowHandle>(window->This.getSystemHandle()); return static_cast<sfWindowHandle>(window->This.getNativeHandle());
} }
+10 -9
View File
@@ -29,6 +29,7 @@
#include <SFML/Window/WindowBaseStruct.h> #include <SFML/Window/WindowBaseStruct.h>
#include <SFML/Internal.h> #include <SFML/Internal.h>
#include <SFML/Window/CursorStruct.h> #include <SFML/Window/CursorStruct.h>
#include <SFML/Window/VideoMode.hpp>
#include <SFML/ConvertEvent.h> #include <SFML/ConvertEvent.h>
@@ -36,7 +37,7 @@
sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char* title, uint32_t style) sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char* title, uint32_t style)
{ {
// Convert video mode // Convert video mode
sf::VideoMode videoMode(mode.width, mode.height, mode.bitsPerPixel); sf::VideoMode videoMode({ mode.width, mode.height }, mode.bitsPerPixel);
// Create the window // Create the window
sfWindowBase* windowBase = new sfWindowBase; sfWindowBase* windowBase = new sfWindowBase;
@@ -47,14 +48,14 @@ sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char* title, uint32_t
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfWindowBase* sfWindowBase_createUnicode(sfVideoMode mode, const uint32_t* title, uint32_t style) sfWindowBase* sfWindowBase_createUnicode(sfVideoMode mode, const sfChar32* title, uint32_t style)
{ {
// Convert video mode // Convert video mode
sf::VideoMode videoMode(mode.width, mode.height, mode.bitsPerPixel); sf::VideoMode videoMode({ mode.width, mode.height }, mode.bitsPerPixel);
// Create the window // Create the window
sfWindowBase* windowBase = new sfWindowBase; sfWindowBase* windowBase = new sfWindowBase;
windowBase->This.create(videoMode, title, style); windowBase->This.create(videoMode, reinterpret_cast<const char32_t*>(title), style);
return windowBase; return windowBase;
} }
@@ -184,16 +185,16 @@ void sfWindowBase_setTitle(sfWindowBase* windowBase, const char* title)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfWindowBase_setUnicodeTitle(sfWindowBase* windowBase, const uint32_t* title) void sfWindowBase_setUnicodeTitle(sfWindowBase* windowBase, const sfChar32* title)
{ {
CSFML_CALL(windowBase, setTitle(title)); CSFML_CALL(windowBase, setTitle(reinterpret_cast<const char32_t*>(title)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfWindowBase_setIcon(sfWindowBase* windowBase, unsigned int width, unsigned int height, const uint8_t* pixels) void sfWindowBase_setIcon(sfWindowBase* windowBase, unsigned int width, unsigned int height, const uint8_t* pixels)
{ {
CSFML_CALL(windowBase, setIcon(width, height, pixels)); CSFML_CALL(windowBase, setIcon({ width, height }, pixels));
} }
@@ -256,11 +257,11 @@ bool sfWindowBase_hasFocus(const sfWindowBase* windowBase)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfWindowHandle sfWindowBase_getSystemHandle(const sfWindowBase* windowBase) sfWindowHandle sfWindowBase_getNativeHandle(const sfWindowBase* windowBase)
{ {
CSFML_CHECK_RETURN(windowBase, 0); CSFML_CHECK_RETURN(windowBase, 0);
return static_cast<sfWindowHandle>(windowBase->This.getSystemHandle()); return static_cast<sfWindowHandle>(windowBase->This.getNativeHandle());
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////