From 7ef69e3b1c209bebc69dc9fd18d63536a1746c40 Mon Sep 17 00:00:00 2001 From: spacechase0 Date: Tue, 8 May 2018 10:25:58 -0400 Subject: [PATCH] Update for 2.5.0 --- CMakeLists.txt | 4 +- include/SFML/Audio/Music.h | 50 +++++ include/SFML/Config.h | 2 +- include/SFML/GPUPreference.h | 74 +++++++ include/SFML/Graphics.h | 1 + include/SFML/Graphics/RenderTexture.h | 26 +++ include/SFML/Graphics/RenderWindow.h | 20 ++ include/SFML/Graphics/Text.h | 59 ++++++ include/SFML/Graphics/Texture.h | 27 +++ include/SFML/Graphics/Transform.h | 13 ++ include/SFML/Graphics/Types.h | 1 + include/SFML/Graphics/VertexBuffer.h | 254 +++++++++++++++++++++++++ include/SFML/Network/Ftp.h | 3 +- include/SFML/Window.h | 2 + include/SFML/Window/Clipboard.h | 85 +++++++++ include/SFML/Window/Context.h | 11 ++ include/SFML/Window/Cursor.h | 132 +++++++++++++ include/SFML/Window/Keyboard.h | 28 ++- include/SFML/Window/Types.h | 1 + include/SFML/Window/Window.h | 20 ++ src/SFML/Audio/CMakeLists.txt | 2 +- src/SFML/Audio/Music.cpp | 23 +++ src/SFML/CMakeLists.txt | 3 +- src/SFML/Graphics/CMakeLists.txt | 5 +- src/SFML/Graphics/RenderTexture.cpp | 35 ++++ src/SFML/Graphics/RenderWindow.cpp | 16 ++ src/SFML/Graphics/Text.cpp | 29 +++ src/SFML/Graphics/Texture.cpp | 11 +- src/SFML/Graphics/Transform.cpp | 11 ++ src/SFML/Graphics/VertexBuffer.cpp | 148 ++++++++++++++ src/SFML/Graphics/VertexBufferStruct.h | 43 +++++ src/SFML/Network/CMakeLists.txt | 2 +- src/SFML/Network/Ftp.cpp | 5 +- src/SFML/System/CMakeLists.txt | 3 +- src/SFML/Window/CMakeLists.txt | 7 +- src/SFML/Window/Clipboard.cpp | 67 +++++++ src/SFML/Window/Context.cpp | 8 + src/SFML/Window/Cursor.cpp | 68 +++++++ src/SFML/Window/CursorStruct.h | 43 +++++ src/SFML/Window/Window.cpp | 9 + 40 files changed, 1327 insertions(+), 24 deletions(-) create mode 100644 include/SFML/GPUPreference.h create mode 100644 include/SFML/Graphics/VertexBuffer.h create mode 100644 include/SFML/Window/Clipboard.h create mode 100644 include/SFML/Window/Cursor.h create mode 100644 src/SFML/Graphics/VertexBuffer.cpp create mode 100644 src/SFML/Graphics/VertexBufferStruct.h create mode 100644 src/SFML/Window/Clipboard.cpp create mode 100644 src/SFML/Window/Cursor.cpp create mode 100644 src/SFML/Window/CursorStruct.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cdff25..b10b974 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ include(${CMAKE_SOURCE_DIR}/cmake/Config.cmake) # setup version numbers set(VERSION_MAJOR 2) -set(VERSION_MINOR 4) +set(VERSION_MINOR 5) set(VERSION_PATCH 0) # add the CSFML header path @@ -42,7 +42,7 @@ set(CMAKE_SKIP_BUILD_RPATH TRUE) # define an option for choosing between static and dynamic C runtime (Windows only) if(SFML_OS_WINDOWS) set(STATIC_STD_LIBS FALSE CACHE BOOL "TRUE to statically link to the standard libraries, FALSE to use them as DLLs") - + # for VC++, we can apply it globally by modifying the compiler flags if(SFML_COMPILER_MSVC AND STATIC_STD_LIBS) foreach(flag diff --git a/include/SFML/Audio/Music.h b/include/SFML/Audio/Music.h index 706ad36..8ee4289 100644 --- a/include/SFML/Audio/Music.h +++ b/include/SFML/Audio/Music.h @@ -37,6 +37,17 @@ #include +//////////////////////////////////////////////////////////// +/// \brief Structure defining a time range +/// +//////////////////////////////////////////////////////////// +typedef struct +{ + sfTime offset; ///< The beginning offset of the time range + sfTime length; ///< The length of the time range +} sfTimeSpan; + + //////////////////////////////////////////////////////////// /// \brief Create a new music and load it from a file /// @@ -128,6 +139,45 @@ CSFML_AUDIO_API sfBool sfMusic_getLoop(const sfMusic* music); //////////////////////////////////////////////////////////// CSFML_AUDIO_API sfTime sfMusic_getDuration(const sfMusic* music); +//////////////////////////////////////////////////////////// +/// \brief Get the positions of the of the sound's looping sequence +/// +/// \return Loop Time position class. +/// +/// \warning Since sfMusic_setLoopPoints() performs some adjustments on the +/// provided values and rounds them to internal samples, a call to +/// sfMusic_getLoopPoints() is not guaranteed to return the same times passed +/// into a previous call to sfMusic_setLoopPoints(). However, it is guaranteed +/// to return times that will map to the valid internal samples of +/// this Music if they are later passed to sfMusic_setLoopPoints(). +/// +/// \see setLoopPoints +/// +//////////////////////////////////////////////////////////// +CSFML_AUDIO_API sfTimeSpan sfMusic_getLoopPoints(const sfMusic* music); + +//////////////////////////////////////////////////////////// +/// \brief Sets the beginning and end of the sound's looping sequence using sf::Time +/// +/// Loop points allow one to specify a pair of positions such that, when the music +/// is enabled for looping, it will seamlessly seek to the beginning whenever it +/// encounters the end. Valid ranges for timePoints.offset and timePoints.length are +/// [0, Dur) and (0, Dur-offset] respectively, where Dur is the value returned by sfMusic_getDuration(). +/// Note that the EOF "loop point" from the end to the beginning of the stream is still honored, +/// in case the caller seeks to a point after the end of the loop range. This function can be +/// safely called at any point after a stream is opened, and will be applied to a playing sound +/// without affecting the current playing offset. +/// +/// \warning Setting the loop points while the stream's status is Paused +/// will set its status to Stopped. The playing offset will be unaffected. +/// +/// \param timePoints The definition of the loop. Can be any time points within the sound's length +/// +/// \see getLoopPoints +/// +//////////////////////////////////////////////////////////// +CSFML_AUDIO_API void sfMusic_setLoopPoints(sfMusic* music, sfTimeSpan timePoints); + //////////////////////////////////////////////////////////// /// \brief Start or resume playing a music /// diff --git a/include/SFML/Config.h b/include/SFML/Config.h index 421cd61..52b3e50 100644 --- a/include/SFML/Config.h +++ b/include/SFML/Config.h @@ -30,7 +30,7 @@ // Define the CSFML version //////////////////////////////////////////////////////////// #define CSFML_VERSION_MAJOR 2 -#define CSFML_VERSION_MINOR 4 +#define CSFML_VERSION_MINOR 5 #define CSFML_VERSION_PATCH 0 diff --git a/include/SFML/GPUPreference.h b/include/SFML/GPUPreference.h new file mode 100644 index 0000000..2045e89 --- /dev/null +++ b/include/SFML/GPUPreference.h @@ -0,0 +1,74 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2018 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_GPUPREFERENCE_H +#define SFML_GPUPREFERENCE_H + + +//////////////////////////////////////////////////////////// +/// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// \file +/// +/// \brief File containing SFML_DEFINE_DISCRETE_GPU_PREFERENCE +/// +//////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////// +/// \def SFML_DEFINE_DISCRETE_GPU_PREFERENCE +/// +/// \brief A macro to encourage usage of the discrete GPU +/// +/// In order to inform the Nvidia/AMD driver that an SFML +/// application could benefit from using the more powerful +/// discrete GPU, special symbols have to be publicly +/// exported from the final executable. +/// +/// SFML defines a helper macro to easily do this. +/// +/// Place SFML_DEFINE_DISCRETE_GPU_PREFERENCE in the +/// global scope of a source file that will be linked into +/// the final executable. Typically it is best to place it +/// where the main function is also defined. +/// +//////////////////////////////////////////////////////////// +#if defined(SFML_SYSTEM_WINDOWS) + + #define SFML_DEFINE_DISCRETE_GPU_PREFERENCE \ + CSFML_EXTERN_C __declspec(dllexport) unsigned long NvOptimusEnablement = 1; \ + CSFML_EXTERN_C __declspec(dllexport) unsigned long AmdPowerXpressRequestHighPerformance = 1; + +#else + + #define SFML_DEFINE_DISCRETE_GPU_PREFERENCE + +#endif + + +#endif // SFML_GPUPREFERENCE_H diff --git a/include/SFML/Graphics.h b/include/SFML/Graphics.h index 87be02a..727f449 100644 --- a/include/SFML/Graphics.h +++ b/include/SFML/Graphics.h @@ -53,6 +53,7 @@ #include #include #include +#include #include diff --git a/include/SFML/Graphics/RenderTexture.h b/include/SFML/Graphics/RenderTexture.h index 5bc3fed..e987a39 100644 --- a/include/SFML/Graphics/RenderTexture.h +++ b/include/SFML/Graphics/RenderTexture.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -48,9 +49,24 @@ /// /// \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, sfBool depthBuffer); +//////////////////////////////////////////////////////////// +/// \brief Construct a new render texture +/// +/// \param width Width of the render texture +/// \param height Height of the render texture +/// \param settings Settings of the render texture +/// +/// \return A new sfRenderTexture object, or NULL if it failed +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_createWithSettings(unsigned int width, unsigned int height, sfContextSettings settings); + //////////////////////////////////////////////////////////// /// \brief Destroy an existing render texture /// @@ -205,6 +221,7 @@ CSFML_GRAPHICS_API void sfRenderTexture_drawCircleShape(sfRenderTexture* renderT CSFML_GRAPHICS_API void sfRenderTexture_drawConvexShape(sfRenderTexture* renderTexture, const sfConvexShape* object, const sfRenderStates* states); CSFML_GRAPHICS_API void sfRenderTexture_drawRectangleShape(sfRenderTexture* renderTexture, const sfRectangleShape* object, const sfRenderStates* states); CSFML_GRAPHICS_API void sfRenderTexture_drawVertexArray(sfRenderTexture* renderTexture, const sfVertexArray* object, const sfRenderStates* states); +CSFML_GRAPHICS_API void sfRenderTexture_drawVertexBuffer(sfRenderTexture* renderTexture, const sfVertexBuffer* object, const sfRenderStates* states); //////////////////////////////////////////////////////////// /// \brief Draw primitives defined by an array of vertices to a render texture @@ -278,6 +295,15 @@ CSFML_GRAPHICS_API void sfRenderTexture_resetGLStates(sfRenderTexture* renderTex //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API const sfTexture* sfRenderTexture_getTexture(const sfRenderTexture* renderTexture); + +//////////////////////////////////////////////////////////// +/// \brief Get the maximum anti-aliasing level supported by the system +/// +/// \return The maximum anti-aliasing level supported by the system +/// +//////////////////////////////////////////////////////////// +unsigned int sfRenderTexture_getMaximumAntialiasingLevel(); + //////////////////////////////////////////////////////////// /// \brief Enable or disable the smooth filter on a render texture /// diff --git a/include/SFML/Graphics/RenderWindow.h b/include/SFML/Graphics/RenderWindow.h index e55a549..b27a088 100644 --- a/include/SFML/Graphics/RenderWindow.h +++ b/include/SFML/Graphics/RenderWindow.h @@ -241,6 +241,25 @@ CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursorVisible(sfRenderWindow* ren //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursorGrabbed(sfRenderWindow* renderWindow, sfBool grabbed); +//////////////////////////////////////////////////////////// +/// \brief Set the displayed cursor to a native system cursor +/// +/// Upon window creation, the arrow cursor is used by default. +/// +/// \warning The cursor must not be destroyed while in use by +/// the window. +/// +/// \warning Features related to Cursor are not supported on +/// iOS and Android. +/// +/// \param cursor Native system cursor type to display +/// +/// \see sfCursor_createFromSystem +/// \see sfCursor_createFromPixels +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursor(sfRenderWindow* window, const sfCursor* cursor); + //////////////////////////////////////////////////////////// /// \brief Enable or disable automatic key-repeat for keydown events /// @@ -445,6 +464,7 @@ CSFML_GRAPHICS_API void sfRenderWindow_drawCircleShape(sfRenderWindow* renderWin CSFML_GRAPHICS_API void sfRenderWindow_drawConvexShape(sfRenderWindow* renderWindow, const sfConvexShape* object, const sfRenderStates* states); CSFML_GRAPHICS_API void sfRenderWindow_drawRectangleShape(sfRenderWindow* renderWindow, const sfRectangleShape* object, const sfRenderStates* states); CSFML_GRAPHICS_API void sfRenderWindow_drawVertexArray(sfRenderWindow* renderWindow, const sfVertexArray* object, const sfRenderStates* states); +CSFML_GRAPHICS_API void sfRenderWindow_drawVertexBuffer(sfRenderWindow* renderWindow, const sfVertexBuffer* object, const sfRenderStates* states); //////////////////////////////////////////////////////////// /// \brief Draw primitives defined by an array of vertices to a render window diff --git a/include/SFML/Graphics/Text.h b/include/SFML/Graphics/Text.h index 0eaa6d3..03a52a5 100644 --- a/include/SFML/Graphics/Text.h +++ b/include/SFML/Graphics/Text.h @@ -276,6 +276,41 @@ CSFML_GRAPHICS_API void sfText_setFont(sfText* text, const sfFont* font); //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfText_setCharacterSize(sfText* text, unsigned int size); + //////////////////////////////////////////////////////////// +/// \brief Set the line spacing factor +/// +/// The default spacing between lines is defined by the font. +/// This method enables you to set a factor for the spacing +/// between lines. By default the line spacing factor is 1. +/// +/// \param text Text object +/// \param spacingFactor New line spacing factor +/// +/// \see sfText_getLineSpacing +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfText_setLineSpacing(sfText* text, float spacingFactor); + +//////////////////////////////////////////////////////////// +/// \brief Set the letter spacing factor +/// +/// The default spacing between letters is defined by the font. +/// This factor doesn't directly apply to the existing +/// spacing between each character, it rather adds a fixed +/// space between them which is calculated from the font +/// metrics and the character size. +/// Note that factors below 1 (including negative numbers) bring +/// characters closer to each other. +/// By default the letter spacing factor is 1. +/// +/// \param text Text object +/// \param spacingFactor New letter spacing factor +/// +/// \see sfText_getLetterSpacing +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfText_setLetterSpacing(sfText* text, float spacingFactor); + //////////////////////////////////////////////////////////// /// \brief Set the style of a text /// @@ -388,6 +423,30 @@ CSFML_GRAPHICS_API const sfFont* sfText_getFont(const sfText* text); //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API unsigned int sfText_getCharacterSize(const sfText* text); +//////////////////////////////////////////////////////////// +/// \brief Get the size of the letter spacing factor +/// +/// \param text Text object +/// +/// \return Size of the letter spacing factor +/// +/// \see sfText_setLetterSpacing +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API float sfText_getLetterSpacing(const sfText* text); + +//////////////////////////////////////////////////////////// +/// \brief Get the size of the line spacing factor +/// +/// \param text Text object +/// +/// \return Size of the line spacing factor +/// +/// \see sfText_setLineSpacing +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API float getLineSpacing(const sfText* text); + //////////////////////////////////////////////////////////// /// \brief Get the style of a text /// diff --git a/include/SFML/Graphics/Texture.h b/include/SFML/Graphics/Texture.h index 3c83527..1d22290 100644 --- a/include/SFML/Graphics/Texture.h +++ b/include/SFML/Graphics/Texture.h @@ -144,6 +144,24 @@ CSFML_GRAPHICS_API sfImage* sfTexture_copyToImage(const sfTexture* texture); //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfTexture_updateFromPixels(sfTexture* texture, const sfUint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y); +//////////////////////////////////////////////////////////// +/// \brief Update a part of this texture from another texture +/// +/// No additional check is performed on the size of the texture, +/// passing an invalid combination of texture size and offset +/// will lead to an undefined behavior. +/// +/// This function does nothing if either texture was not +/// previously created. +/// +/// \param destination Destination texture to copy source texture to +/// \param source Source texture to copy to destination texture +/// \param x X offset in this texture where to copy the source texture +/// \param y Y offset in this texture where to copy the source texture +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfTexture_updateFromTexture(sfTexture* destination, const sfTexture* source, unsigned int x, unsigned int y); + //////////////////////////////////////////////////////////// /// \brief Update a texture from an image /// @@ -289,6 +307,15 @@ CSFML_GRAPHICS_API sfBool sfTexture_isRepeated(const sfTexture* texture); //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfBool sfTexture_generateMipmap(sfTexture* texture); +//////////////////////////////////////////////////////////// +/// \brief Swap the contents of a texture with those of another +/// +/// \param left Instance to swap from +/// \param right Instance to swap with +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfTexture_swap(sfTexture* left, sfTexture* right); + //////////////////////////////////////////////////////////// /// \brief Get the underlying OpenGL handle of the texture. /// diff --git a/include/SFML/Graphics/Transform.h b/include/SFML/Graphics/Transform.h index 74f9a18..a986ca4 100644 --- a/include/SFML/Graphics/Transform.h +++ b/include/SFML/Graphics/Transform.h @@ -206,5 +206,18 @@ CSFML_GRAPHICS_API void sfTransform_scale(sfTransform* transform, float scaleX, //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfTransform_scaleWithCenter(sfTransform* transform, float scaleX, float scaleY, float centerX, float centerY); +//////////////////////////////////////////////////////////// +/// \brief Compare two transforms for equality +/// +/// Performs an element-wise comparison of the elements of the +/// left transform with the elements of the right transform. +/// +/// \param left Left operand (the first transform) +/// \param right Right operand (the second transform) +/// +/// \return true if the transforms are equal, false otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfBool sfTransform_equal(sfTransform* left, sfTransform* right); #endif // SFML_TRANSFORM_H diff --git a/include/SFML/Graphics/Types.h b/include/SFML/Graphics/Types.h index b6f8e93..9cc2b98 100644 --- a/include/SFML/Graphics/Types.h +++ b/include/SFML/Graphics/Types.h @@ -40,6 +40,7 @@ typedef struct sfText sfText; typedef struct sfTexture sfTexture; typedef struct sfTransformable sfTransformable; typedef struct sfVertexArray sfVertexArray; +typedef struct sfVertexBuffer sfVertexBuffer; typedef struct sfView sfView; diff --git a/include/SFML/Graphics/VertexBuffer.h b/include/SFML/Graphics/VertexBuffer.h new file mode 100644 index 0000000..ead603f --- /dev/null +++ b/include/SFML/Graphics/VertexBuffer.h @@ -0,0 +1,254 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2015 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_VERTEXBUFFER_H +#define SFML_VERTEXBUFFER_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// \brief Usage specifiers +/// +/// If data is going to be updated once or more every frame, +/// set the usage to sfVertexBufferStream. If data is going +/// to be set once and used for a long time without being +/// modified, set the usage to sfVertexBufferUsageStatic. +/// For everything else sfVertexBufferUsageDynamic should +/// be a good compromise. +/// +//////////////////////////////////////////////////////////// +typedef enum +{ + sfVertexBufferStream, ///< Constantly changing data + sfVertexBufferDynamic, ///< Occasionally changing data + sfVertexBufferStatic ///< Rarely changing data +} sfVertexBufferUsage; + +//////////////////////////////////////////////////////////// +/// \brief Create a new vertex buffer with a specific +/// sfPrimitiveType and usage specifier. +/// +/// Creates the vertex buffer, allocating enough graphcis +/// memory to hold \p vertexCount vertices, and sets its +/// primitive type to \p type and usage to \p usage. +/// +/// \param vertexCount Amount of vertices +/// \param type Type of primitive +/// \param usage Usage specifier +/// +/// \return A new sfVertexBuffer object +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfVertexBuffer* sfVertexBuffer_create(unsigned int vertexCount, sfPrimitiveType type, sfVertexBufferUsage usage); + +//////////////////////////////////////////////////////////// +/// \brief Copy an existing vertex buffer +/// +/// \param vertexBuffer Vertex buffer to copy +/// +/// \return Copied object +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfVertexBuffer* sfVertexBuffer_copy(const sfVertexBuffer* vertexBuffer); + +//////////////////////////////////////////////////////////// +/// \brief Destroy an existing vertex buffer +/// +/// \param vertexBuffer Vertex buffer to delete +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfVertexBuffer_destroy(sfVertexBuffer* vertexBuffer); + +//////////////////////////////////////////////////////////// +/// \brief Return the vertex count +/// +/// \param vertexBuffer Vertex buffer object +/// +/// \return Number of vertices in the vertex buffer +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API unsigned int sfVertexBuffer_getVertexCount(const sfVertexBuffer* vertexBuffer); + +//////////////////////////////////////////////////////////// +/// \brief Update a part of the buffer from an array of vertices +/// +/// \p offset is specified as the number of vertices to skip +/// from the beginning of the buffer. +/// +/// If \p offset is 0 and \p vertexCount is equal to the size of +/// the currently created buffer, its whole contents are replaced. +/// +/// If \p offset is 0 and \p vertexCount is greater than the +/// size of the currently created buffer, a new buffer is created +/// containing the vertex data. +/// +/// If \p offset is 0 and \p vertexCount is less than the size of +/// the currently created buffer, only the corresponding region +/// is updated. +/// +/// If \p offset is not 0 and \p offset + \p vertexCount is greater +/// than the size of the currently created buffer, the update fails. +/// +/// No additional check is performed on the size of the vertex +/// array, passing invalid arguments will lead to undefined +/// behavior. +/// +/// \param vertices Array of vertices to copy to the buffer +/// \param vertexCount Number of vertices to copy +/// \param offset Offset in the buffer to copy to +/// +/// \return sfTrue if the update was successful +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfBool sfVertexBuffer_update(sfVertexBuffer* vertexBuffer, const sfVertex* vertices, unsigned int vertexCount, unsigned int offset); + +//////////////////////////////////////////////////////////// +/// \brief Copy the contents of another buffer into this buffer +/// +/// \param vertexBuffer Vertex buffer object +/// \param other Vertex buffer whose contents to copy into first vertex buffer +/// +/// \return sfTrue if the copy was successful +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfBool sfVertexBuffer_updateFromVertexBuffer(sfVertexBuffer* vertexBuffer, const sfVertexBuffer* other); + +//////////////////////////////////////////////////////////// +/// \brief Swap the contents of this vertex buffer with those of another +/// +/// \param left Instance to swap +/// \param right Instance to swap with +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfVertexBuffer_swap(sfVertexBuffer* left, sfVertexBuffer* right); + +//////////////////////////////////////////////////////////// +/// \brief Get the underlying OpenGL handle of the vertex buffer. +/// +/// You shouldn't need to use this function, unless you have +/// very specific stuff to implement that SFML doesn't support, +/// or implement a temporary workaround until a bug is fixed. +/// +/// \return OpenGL handle of the vertex buffer or 0 if not yet created +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API unsigned int sfVertexBuffer_getNativeHandle(sfVertexBuffer* vertexBuffer); + +//////////////////////////////////////////////////////////// +/// \brief Set the type of primitives to draw +/// +/// This function defines how the vertices must be interpreted +/// when it's time to draw them. +/// +/// The default primitive type is sf::Points. +/// +/// \param vertexBuffer Vertex buffer object +/// \param type Type of primitive +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfVertexBuffer_setPrimitiveType(sfVertexBuffer* vertexBuffer, sfPrimitiveType type); + +//////////////////////////////////////////////////////////// +/// \brief Get the type of primitives drawn by the vertex buffer +/// +/// \param vertexBuffer Vertex buffer object +/// +/// \return Primitive type +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfPrimitiveType sfVertexBuffer_getPrimitiveType(const sfVertexBuffer* vertexBuffer); + +//////////////////////////////////////////////////////////// +/// \brief Set the usage specifier of this vertex buffer +/// +/// This function provides a hint about how this vertex buffer is +/// going to be used in terms of data update frequency. +/// +/// After changing the usage specifier, the vertex buffer has +/// to be updated with new data for the usage specifier to +/// take effect. +/// +/// The default primitive type is sfVertexBufferStream. +/// +/// \param vertexBuffer Vertex buffer object +/// \param usage Usage specifier +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfVertexBuffer_setUsage(sfVertexBuffer* vertexBuffer, sfVertexBufferUsage usage); + +//////////////////////////////////////////////////////////// +/// \brief Get the usage specifier of this vertex buffer +/// +/// \param vertexBuffer Vertex buffer object +/// +/// \return Usage specifier +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfVertexBufferUsage sfVertexBuffer_getUsage(const sfVertexBuffer* vertexBuffer); + +//////////////////////////////////////////////////////////// +/// \brief Bind a vertex buffer for rendering +/// +/// This function is not part of the graphics API, it mustn't be +/// used when drawing SFML entities. It must be used only if you +/// mix sfVertexBuffer with OpenGL code. +/// +/// \code +/// sfVertexBuffer* vb1, vb2; +/// ... +/// sfVertexBuffer_bind(vb1); +/// // draw OpenGL stuff that use vb1... +/// sfVertexBuffer_bind(vb2); +/// // draw OpenGL stuff that use vb2... +/// sfVertexBuffer_bind(NULL); +/// // draw OpenGL stuff that use no vertex buffer... +/// \endcode +/// +/// \param vertexBuffer Pointer to the vertex buffer to bind, can be null to use no vertex buffer +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfVertexBuffer_bind(const sfVertexBuffer* vertexBuffer); + +//////////////////////////////////////////////////////////// +/// \brief Tell whether or not the system supports vertex buffers +/// +/// This function should always be called before using +/// the vertex buffer features. If it returns false, then +/// any attempt to use sf::VertexBuffer will fail. +/// +/// \return True if vertex buffers are supported, false otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfBool sfVertexBuffer_isAvailable(); + + +#endif // SFML_VERTEXBUFFER_H diff --git a/include/SFML/Network/Ftp.h b/include/SFML/Network/Ftp.h index f15b840..aa3b700 100644 --- a/include/SFML/Network/Ftp.h +++ b/include/SFML/Network/Ftp.h @@ -500,11 +500,12 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_download(sfFtp* ftp, const char* remoteFi /// \param localFile Path of the local file to upload /// \param remotePath Where to put to file on the server /// \param mode Transfer mode +/// \param append Pass sfTrue to append to or sfFalse to overwrite the remote file if it already exists /// /// \return Server response to the request /// //////////////////////////////////////////////////////////// -CSFML_NETWORK_API sfFtpResponse* sfFtp_upload(sfFtp* ftp, const char* localFile, const char* remotePath, sfFtpTransferMode mode); +CSFML_NETWORK_API sfFtpResponse* sfFtp_upload(sfFtp* ftp, const char* localFile, const char* remotePath, sfFtpTransferMode mode, sfBool append); //////////////////////////////////////////////////////////// /// \brief Send a command to the FTP server diff --git a/include/SFML/Window.h b/include/SFML/Window.h index 742454b..a2792fd 100644 --- a/include/SFML/Window.h +++ b/include/SFML/Window.h @@ -30,7 +30,9 @@ //////////////////////////////////////////////////////////// #include +#include #include +#include #include #include #include diff --git a/include/SFML/Window/Clipboard.h b/include/SFML/Window/Clipboard.h new file mode 100644 index 0000000..a27f616 --- /dev/null +++ b/include/SFML/Window/Clipboard.h @@ -0,0 +1,85 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2015 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_CLIPBOARD_H +#define SFML_CLIPBOARD_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +//////////////////////////////////////////////////////////// +/// \brief Get the content of the clipboard as string data (returns an ANSI string) +/// +/// This function returns the content of the clipboard +/// as a string. If the clipboard does not contain string +/// it returns an empty string. +/// +/// \return Clipboard contents as a locale-dependent ANSI string +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API const char* sfClipboard_getString(); + + +//////////////////////////////////////////////////////////// +/// \brief Get the content of the clipboard as string data (returns a Unicode string) +/// +/// This function returns the content of the clipboard +/// as a string. If the clipboard does not contain string +/// it returns an empty string. +/// +/// \return Clipboard contents as UTF-32 +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API const sfUint32* sfClipboard_getUnicodeString(); + +//////////////////////////////////////////////////////////// +/// \brief Set the content of the clipboard as ANSI string data +/// +/// This function sets the content of the clipboard as an +/// ANSI string. +/// +/// \param text ANSI string containing the data to be sent +/// to the clipboard +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API void sfClipboard_setString(const char* text); + +//////////////////////////////////////////////////////////// +/// \brief Set the content of the clipboard as Unicode string data +/// +/// This function sets the content of the clipboard as a +/// Unicode string. +/// +/// \param text Unicode string containing the data to be sent +/// to the clipboard +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API void sfClipboard_setUnicodeString(const sfUint32* text); + + +#endif // SFML_CURSOR_H diff --git a/include/SFML/Window/Context.h b/include/SFML/Window/Context.h index 9bb651f..c91d674 100644 --- a/include/SFML/Window/Context.h +++ b/include/SFML/Window/Context.h @@ -73,4 +73,15 @@ CSFML_WINDOW_API sfBool sfContext_setActive(sfContext* context, sfBool active); //////////////////////////////////////////////////////////// CSFML_WINDOW_API sfContextSettings sfContext_getSettings(const sfContext* context); +//////////////////////////////////////////////////////////// +/// \brief Get the currently active context's ID +/// +/// The context ID is used to identify contexts when +/// managing unshareable OpenGL resources. +/// +/// \return The active context's ID or 0 if no context is currently active +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API sfUint64 sfContext_getActiveContextId(); + #endif // SFML_CONTEXT_H diff --git a/include/SFML/Window/Cursor.h b/include/SFML/Window/Cursor.h new file mode 100644 index 0000000..f4ac033 --- /dev/null +++ b/include/SFML/Window/Cursor.h @@ -0,0 +1,132 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2015 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_CURSOR_H +#define SFML_CURSOR_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +/// \brief Enumeration of the native system cursor types +/// +/// Refer to the following table to determine which cursor +/// is available on which platform. +/// +/// Type | Linux | Mac OS X | Windows +/// ------------------------------------|:-----:|:--------:|:--------: +/// sfCursorArrow | yes | yes | yes +/// sfCursorArrowWait | no | no | yes +/// sfCursorWait | yes | no | yes +/// sfCursorText | yes | yes | yes +/// sfCursorHand | yes | yes | yes +/// sfCursorSizeHorizontal | yes | yes | yes +/// sfCursorSizeVertical | yes | yes | yes +/// sfCursorSizeTopLeftBottomRight | no | no | yes +/// sfCursorSizeBottomLeftTopRight | no | no | yes +/// sfCursorSizeAll | yes | no | yes +/// sfCursorCross | yes | yes | yes +/// sfCursorHelp | yes | no | yes +/// sfCursorNotAllowed | yes | yes | yes +/// +//////////////////////////////////////////////////////////// +typedef enum +{ + sfCursorArrow, ///< Arrow cursor (default) + sfCursorArrowWait, ///< Busy arrow cursor + sfCursorWait, ///< Busy cursor + sfCursorText, ///< I-beam, cursor when hovering over a field allowing text entry + sfCursorHand, ///< Pointing hand cursor + sfCursorSizeHorizontal, ///< Horizontal double arrow cursor + sfCursorSizeVertical, ///< Vertical double arrow cursor + sfCursorSizeTopLeftBottomRight, ///< Double arrow cursor going from top-left to bottom-right + sfCursorSizeBottomLeftTopRight, ///< Double arrow cursor going from bottom-left to top-right + sfCursorSizeAll, ///< Combination of SizeHorizontal and SizeVertical + sfCursorCross, ///< Crosshair cursor + sfCursorHelp, ///< Help cursor + sfCursorNotAllowed ///< Action not allowed cursor +} sfCursorType; + + +//////////////////////////////////////////////////////////// +/// \brief Create a cursor with the provided image +/// +/// \a pixels must be an array of \a width by \a height pixels +/// in 32-bit RGBA format. If not, this will cause undefined behavior. +/// +/// If \a pixels is null or either \a width or \a height are 0, +/// the current cursor is left unchanged and the function will +/// return false. +/// +/// In addition to specifying the pixel data, you can also +/// specify the location of the hotspot of the cursor. The +/// hotspot is the pixel coordinate within the cursor image +/// which will be located exactly where the mouse pointer +/// position is. Any mouse actions that are performed will +/// return the window/screen location of the hotspot. +/// +/// \warning On Unix, the pixels are mapped into a monochrome +/// bitmap: pixels with an alpha channel to 0 are +/// transparent, black if the RGB channel are close +/// to zero, and white otherwise. +/// +/// \param pixels Array of pixels of the image +/// \param size Width and height of the image +/// \param hotspot (x,y) location of the hotspot +/// \return A new sfCursor object +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API sfCursor* sfCursor_createFromPixels(const sfUint8* pixels, sfVector2u size, sfVector2u hotspot); + + +//////////////////////////////////////////////////////////// +/// \brief Create a native system cursor +/// +/// Refer to the list of cursor available on each system +/// (see sfCursorType) to know whether a given cursor is +/// expected to load successfully or is not supported by +/// the operating system. +/// +/// \param type Native system cursor type +/// \return A new sfCursor object +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API sfCursor* sfCursor_createFromSystem(sfCursorType type); + + +//////////////////////////////////////////////////////////// +/// \brief Destroy a cursor +/// +/// \param cursor Cursor to destroy +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API void sfCursor_destroy(sfCursor* cursor); + + +#endif // SFML_CURSOR_H diff --git a/include/SFML/Window/Keyboard.h b/include/SFML/Window/Keyboard.h index 9e79155..f294723 100644 --- a/include/SFML/Window/Keyboard.h +++ b/include/SFML/Window/Keyboard.h @@ -86,18 +86,18 @@ typedef enum sfKeyMenu, ///< The Menu key sfKeyLBracket, ///< The [ key sfKeyRBracket, ///< The ] key - sfKeySemiColon, ///< The ; key + sfKeySemicolon, ///< The ; key sfKeyComma, ///< The , key sfKeyPeriod, ///< The . key sfKeyQuote, ///< The ' key sfKeySlash, ///< The / key - sfKeyBackSlash, ///< The \ key + sfKeyBackslash, ///< The \ key sfKeyTilde, ///< The ~ key sfKeyEqual, ///< The = key - sfKeyDash, ///< The - key + sfKeyHyphen, ///< The - key (hyphen) sfKeySpace, ///< The Space key - sfKeyReturn, ///< The Return key - sfKeyBack, ///< The Backspace key + sfKeyEnter, ///< The Enter/Return key + sfKeyBackspace, ///< The Backspace key sfKeyTab, ///< The Tabulation key sfKeyPageUp, ///< The Page up key sfKeyPageDown, ///< The Page down key @@ -105,10 +105,10 @@ typedef enum sfKeyHome, ///< The Home key sfKeyInsert, ///< The Insert key sfKeyDelete, ///< The Delete key - sfKeyAdd, ///< + - sfKeySubtract, ///< - - sfKeyMultiply, ///< * - sfKeyDivide, ///< / + sfKeyAdd, ///< The + key + sfKeySubtract, ///< The - key (minus, usually from numpad) + sfKeyMultiply, ///< The * key + sfKeyDivide, ///< The / key sfKeyLeft, ///< Left arrow sfKeyRight, ///< Right arrow sfKeyUp, ///< Up arrow @@ -140,7 +140,15 @@ typedef enum sfKeyF15, ///< The F15 key sfKeyPause, ///< The Pause key - sfKeyCount ///< Keep last -- the total number of keyboard keys + sfKeyCount, ///< Keep last -- the total number of keyboard keys + + // Deprecated values: + + sfKeyDash = sfKeyHyphen, ///< \deprecated Use Hyphen instead + sfKeyBack = sfKeyBackspace, ///< \deprecated Use Backspace instead + sfKeyBackSlash = sfKeyBackslash, ///< \deprecated Use Backslash instead + sfKeySemiColon = sfKeySemicolon, ///< \deprecated Use Semicolon instead + sfKeyReturn = sfKeyEnter ///< \deprecated Use Enter instead } sfKeyCode; diff --git a/include/SFML/Window/Types.h b/include/SFML/Window/Types.h index 21152a9..b859f2f 100644 --- a/include/SFML/Window/Types.h +++ b/include/SFML/Window/Types.h @@ -27,6 +27,7 @@ typedef struct sfContext sfContext; +typedef struct sfCursor sfCursor; typedef struct sfWindow sfWindow; diff --git a/include/SFML/Window/Window.h b/include/SFML/Window/Window.h index 5333633..74314f1 100644 --- a/include/SFML/Window/Window.h +++ b/include/SFML/Window/Window.h @@ -354,6 +354,26 @@ CSFML_WINDOW_API void sfWindow_setMouseCursorVisible(sfWindow* window, sfBool vi //////////////////////////////////////////////////////////// CSFML_WINDOW_API void sfWindow_setMouseCursorGrabbed(sfWindow* window, sfBool grabbed); +//////////////////////////////////////////////////////////// +/// \brief Set the displayed cursor to a native system cursor +/// +/// Upon window creation, the arrow cursor is used by default. +/// +/// \warning The cursor must not be destroyed while in use by +/// the window. +/// +/// \warning Features related to Cursor are not supported on +/// iOS and Android. +/// +/// \param window Window object +/// \param cursor Native system cursor type to display +/// +/// \see sfCursor_createFromSystem +/// \see sfCursor_createFromPixels +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API void sfWindow_setMouseCursor(sfWindow* window, const sfCursor* cursor); + //////////////////////////////////////////////////////////// /// \brief Enable or disable automatic key-repeat /// diff --git a/src/SFML/Audio/CMakeLists.txt b/src/SFML/Audio/CMakeLists.txt index 416d39c..b661d60 100644 --- a/src/SFML/Audio/CMakeLists.txt +++ b/src/SFML/Audio/CMakeLists.txt @@ -32,4 +32,4 @@ set(SRC # define the csfml-audio target csfml_add_library(csfml-audio SOURCES ${SRC} - DEPENDS ${SFML_AUDIO_LIBRARY} ${SFML_SYSTEM_LIBRARY} ${SFML_AUDIO_DEPENDENCIES} ${SFML_SYSTEM_DEPENDENCIES}) + DEPENDS sfml-audio) diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp index 3c08979..f0c3f8d 100644 --- a/src/SFML/Audio/Music.cpp +++ b/src/SFML/Audio/Music.cpp @@ -107,6 +107,29 @@ sfTime sfMusic_getDuration(const sfMusic* music) } +//////////////////////////////////////////////////////////// +sfTimeSpan sfMusic_getLoopPoints(const sfMusic* music) +{ + sfTimeSpan timeSpan = {{0}, {0}}; + CSFML_CHECK_RETURN(music, timeSpan); + + sf::Music::TimeSpan span = music->This.getLoopPoints(); + + timeSpan.offset.microseconds = span.offset.asMicroseconds(); + timeSpan.length.microseconds = span.length.asMicroseconds(); + + return timeSpan; +} + + +//////////////////////////////////////////////////////////// +void sfMusic_setLoopPoints(sfMusic* music, sfTimeSpan timePoints) +{ + CSFML_CALL(music, setLoopPoints(sf::Music::TimeSpan(sf::microseconds(timePoints.offset.microseconds), + sf::microseconds(timePoints.length.microseconds)))); +} + + //////////////////////////////////////////////////////////// void sfMusic_play(sfMusic* music) { diff --git a/src/SFML/CMakeLists.txt b/src/SFML/CMakeLists.txt index 1c97187..bcc0962 100644 --- a/src/SFML/CMakeLists.txt +++ b/src/SFML/CMakeLists.txt @@ -23,8 +23,7 @@ if(SFML_OS_WINDOWS) add_definitions(-DSFML_STATIC) endif() endif() -find_package(SFML 2 COMPONENTS system window network graphics audio REQUIRED) -include_directories(${SFML_INCLUDE_DIR}) +find_package(SFML 2 COMPONENTS network graphics audio REQUIRED) # add the modules subdirectories add_subdirectory(System) diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt index a68ce3b..5e56f32 100644 --- a/src/SFML/Graphics/CMakeLists.txt +++ b/src/SFML/Graphics/CMakeLists.txt @@ -61,6 +61,9 @@ set(SRC ${SRCROOT}/VertexArray.cpp ${SRCROOT}/VertexArrayStruct.h ${INCROOT}/VertexArray.h + ${INCROOT}/VertexBuffer.h + ${SRCROOT}/VertexBuffer.cpp + ${SRCROOT}/VertexBufferStruct.h ${SRCROOT}/View.cpp ${SRCROOT}/ViewStruct.h ${INCROOT}/View.h @@ -69,4 +72,4 @@ set(SRC # define the csfml-graphics target csfml_add_library(csfml-graphics SOURCES ${SRC} - DEPENDS ${SFML_GRAPHICS_LIBRARY} ${SFML_WINDOW_LIBRARY} ${SFML_SYSTEM_LIBRARY} ${SFML_GRAPHICS_DEPENDENCIES} ${SFML_WINDOW_DEPENDENCIES} ${SFML_SYSTEM_DEPENDENCIES}) + DEPENDS sfml-graphics) diff --git a/src/SFML/Graphics/RenderTexture.cpp b/src/SFML/Graphics/RenderTexture.cpp index 57b5554..610ec34 100644 --- a/src/SFML/Graphics/RenderTexture.cpp +++ b/src/SFML/Graphics/RenderTexture.cpp @@ -34,8 +34,10 @@ #include #include #include +#include #include #include +#include //////////////////////////////////////////////////////////// @@ -51,6 +53,27 @@ sfRenderTexture* sfRenderTexture_create(unsigned int width, unsigned int height, } +//////////////////////////////////////////////////////////// +sfRenderTexture* sfRenderTexture_createWithSettings(unsigned int width, unsigned int height, const sfContextSettings* settings) +{ + // Convert context settings + sf::ContextSettings params; + if (settings) + { + priv::sfContextSettings_writeToCpp(*settings, params); + } + + // Create the render texture + sfRenderTexture* renderTexture = new sfRenderTexture; + renderTexture->This.create(width, height, params); + renderTexture->Target = new sfTexture(const_cast(&renderTexture->This.getTexture())); + renderTexture->DefaultView.This = renderTexture->This.getDefaultView(); + renderTexture->CurrentView.This = renderTexture->This.getView(); + + return renderTexture; +} + + //////////////////////////////////////////////////////////// void sfRenderTexture_destroy(sfRenderTexture* renderTexture) { @@ -214,6 +237,11 @@ void sfRenderTexture_drawVertexArray(sfRenderTexture* renderTexture, const sfVer CSFML_CHECK(object); CSFML_CALL(renderTexture, draw(object->This, convertRenderStates(states))); } +void sfRenderTexture_drawVertexBuffer(sfRenderTexture* renderTexture, const sfVertexBuffer* object, const sfRenderStates* states) +{ + CSFML_CHECK(object); + CSFML_CALL(renderTexture, draw(object->This, convertRenderStates(states))); +} //////////////////////////////////////////////////////////// @@ -263,6 +291,13 @@ void sfRenderTexture_setSmooth(sfRenderTexture* renderTexture, sfBool smooth) } +//////////////////////////////////////////////////////////// +unsigned int sfRenderTexture_getMaximumAntialiasingLevel() +{ + return sf::RenderTexture::getMaximumAntialiasingLevel(); +} + + //////////////////////////////////////////////////////////// sfBool sfRenderTexture_isSmooth(const sfRenderTexture* renderTexture) { diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp index b1fa344..da8dbfd 100644 --- a/src/SFML/Graphics/RenderWindow.cpp +++ b/src/SFML/Graphics/RenderWindow.cpp @@ -35,10 +35,12 @@ #include #include #include +#include #include #include #include #include +#include #include @@ -274,6 +276,15 @@ void sfRenderWindow_setMouseCursorGrabbed(sfRenderWindow* renderWindow, sfBool g } +//////////////////////////////////////////////////////////// +void sfRenderWindow_setMouseCursor(sfRenderWindow* window, const sfCursor* cursor) +{ + CSFML_CHECK(cursor); + + CSFML_CALL(window, setMouseCursor(cursor->This)); +} + + //////////////////////////////////////////////////////////// void sfRenderWindow_setKeyRepeatEnabled(sfRenderWindow* renderWindow, sfBool enabled) { @@ -459,6 +470,11 @@ void sfRenderWindow_drawVertexArray(sfRenderWindow* renderWindow, const sfVertex CSFML_CHECK(object); CSFML_CALL(renderWindow, draw(object->This, convertRenderStates(states))); } +void sfRenderWindow_drawVertexBuffer(sfRenderWindow* renderWindow, const sfVertexBuffer* object, const sfRenderStates* states) +{ + CSFML_CHECK(object); + CSFML_CALL(renderWindow, draw(object->This, convertRenderStates(states))); +} //////////////////////////////////////////////////////////// diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index 27578ed..8403569 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -209,6 +209,20 @@ void sfText_setCharacterSize(sfText* text, unsigned int size) } +//////////////////////////////////////////////////////////// +void sfText_setLineSpacing(sfText* text, float spacingFactor) +{ + CSFML_CALL(text, setLineSpacing(spacingFactor)); +} + + +//////////////////////////////////////////////////////////// +void sfText_setLetterSpacing(sfText* text, float spacingFactor) +{ + CSFML_CALL(text, setLetterSpacing(spacingFactor)); +} + + //////////////////////////////////////////////////////////// void sfText_setStyle(sfText* text, sfUint32 style) { @@ -280,6 +294,21 @@ unsigned int sfText_getCharacterSize(const sfText* text) } +//////////////////////////////////////////////////////////// +float sfText_getLetterSpacing(const sfText* text) +{ + CSFML_CALL_RETURN(text, getLetterSpacing(), 1); +} + + +//////////////////////////////////////////////////////////// +float sfText_getLineSpacing(const sfText* text) +{ + CSFML_CALL_RETURN(text, getLineSpacing(), 1); +} + + + //////////////////////////////////////////////////////////// sfUint32 sfText_getStyle(const sfText* text) { diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index a224351..c505d88 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -38,7 +38,7 @@ sfTexture* sfTexture_create(unsigned int width, unsigned int height) { sfTexture* texture = new sfTexture; - + if (!texture->This->create(width, height)) { delete texture; @@ -263,6 +263,15 @@ sfBool sfTexture_generateMipmap(sfTexture* texture) } +//////////////////////////////////////////////////////////// +void sfTexture_swap(sfTexture* left, sfTexture* right) +{ + CSFML_CHECK(right); + + CSFML_CALL_PTR(left, swap(*right->This)); +} + + //////////////////////////////////////////////////////////// unsigned int sfTexture_getNativeHandle(const sfTexture* texture) { diff --git a/src/SFML/Graphics/Transform.cpp b/src/SFML/Graphics/Transform.cpp index 83a98c9..d2a91c2 100644 --- a/src/SFML/Graphics/Transform.cpp +++ b/src/SFML/Graphics/Transform.cpp @@ -156,3 +156,14 @@ void sfTransform_scaleWithCenter(sfTransform* transform, float scaleX, float sca *transform = convertTransform(convertTransform(*transform).scale(scaleX, scaleY, centerX, centerY)); } + + +//////////////////////////////////////////////////////////// +sfBool sfTransform_equal(sfTransform* left, sfTransform* right) +{ + CSFML_CHECK_RETURN(left, false); + CSFML_CHECK_RETURN(right, false); + + return (left->matrix == right->matrix) ? sfTrue : sfFalse; +} + diff --git a/src/SFML/Graphics/VertexBuffer.cpp b/src/SFML/Graphics/VertexBuffer.cpp new file mode 100644 index 0000000..5ef2c18 --- /dev/null +++ b/src/SFML/Graphics/VertexBuffer.cpp @@ -0,0 +1,148 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +sfVertexBuffer* sfVertexBuffer_create(unsigned int vertexCount, sfPrimitiveType type, sfVertexBufferUsage usage) +{ + sfVertexBuffer* buffer = new sfVertexBuffer; + + if (!buffer->This.create(vertexCount)) + { + delete buffer; + buffer = NULL; + } + else + { + buffer->This.setPrimitiveType(static_cast(type)); + buffer->This.setUsage(static_cast(usage)); + } + + return buffer; +} + + +//////////////////////////////////////////////////////////// +sfVertexBuffer* sfVertexBuffer_copy(const sfVertexBuffer* vertexBuffer) +{ + sfVertexBuffer* buffer = new sfVertexBuffer; + buffer->This = sf::VertexBuffer( vertexBuffer->This ); + return buffer; +} + + +//////////////////////////////////////////////////////////// +void sfVertexBuffer_destroy(sfVertexBuffer* vertexBuffer) +{ + delete vertexBuffer; +} + + +//////////////////////////////////////////////////////////// +unsigned int sfVertexBuffer_getVertexCount(const sfVertexBuffer* vertexBuffer) +{ + CSFML_CALL_RETURN(vertexBuffer, getVertexCount(), 0); +} + + +//////////////////////////////////////////////////////////// +sfBool sfVertexBuffer_update(sfVertexBuffer* vertexBuffer, const sfVertex* vertices, unsigned int vertexCount, unsigned int offset) +{ + // the cast is safe, sfVertex has to be binary compatible with sf::Vertex + CSFML_CALL_RETURN(vertexBuffer, update(reinterpret_cast(vertices), vertexCount, offset), sfFalse); +} + + +//////////////////////////////////////////////////////////// +sfBool sfVertexBuffer_updateFromVertexBuffer(sfVertexBuffer* vertexBuffer, const sfVertexBuffer* other) +{ + CSFML_CALL_RETURN(vertexBuffer, update(other->This), sfFalse); +} + + +/////////////////////////////////////////////////////////// +void sfVertexBuffer_swap(sfVertexBuffer* left, sfVertexBuffer* right) +{ + CSFML_CHECK(right); + + CSFML_CALL(left, swap(right->This)); +} + + +//////////////////////////////////////////////////////////// +unsigned int sfVertexBuffer_getNativeHandle(sfVertexBuffer* vertexBuffer) +{ + CSFML_CALL_RETURN(vertexBuffer, getNativeHandle(), 0); +} + + +//////////////////////////////////////////////////////////// +void sfVertexBuffer_setPrimitiveType(sfVertexBuffer* vertexBuffer, sfPrimitiveType type) +{ + CSFML_CALL(vertexBuffer, setPrimitiveType(static_cast(type))); +} + + +//////////////////////////////////////////////////////////// +sfPrimitiveType sfVertexBuffer_getPrimitiveType(const sfVertexBuffer* vertexBuffer) +{ + CSFML_CHECK_RETURN(vertexBuffer, sfPoints); + return static_cast(vertexBuffer->This.getPrimitiveType()); +} + + +//////////////////////////////////////////////////////////// +void sfVertexBuffer_setUsage(sfVertexBuffer* vertexBuffer, sfVertexBufferUsage usage) +{ + CSFML_CALL(vertexBuffer, setUsage(static_cast(usage))); +} + + +//////////////////////////////////////////////////////////// +sfVertexBufferUsage sfVertexBuffer_getUsage(const sfVertexBuffer* vertexBuffer) +{ + CSFML_CHECK_RETURN(vertexBuffer, sfVertexBufferStream); + return static_cast(vertexBuffer->This.getUsage()); +} + + +//////////////////////////////////////////////////////////// +void sfVertexBuffer_bind(const sfVertexBuffer* vertexBuffer) +{ + sf::VertexBuffer::bind(&vertexBuffer->This); +} + + +//////////////////////////////////////////////////////////// +sfBool sfVertexBuffer_isAvailable() +{ + return sf::VertexBuffer::isAvailable() ? sfTrue : sfFalse; +} diff --git a/src/SFML/Graphics/VertexBufferStruct.h b/src/SFML/Graphics/VertexBufferStruct.h new file mode 100644 index 0000000..671f1a3 --- /dev/null +++ b/src/SFML/Graphics/VertexBufferStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2015 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_VERTEXBUFFERSTRUCT_H +#define SFML_VERTEXBUFFERSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfVertexBuffer +//////////////////////////////////////////////////////////// +struct sfVertexBuffer +{ + sf::VertexBuffer This; +}; + + +#endif // SFML_VERTEXBUFFERSTRUCT_H diff --git a/src/SFML/Network/CMakeLists.txt b/src/SFML/Network/CMakeLists.txt index a9d3030..cda03eb 100644 --- a/src/SFML/Network/CMakeLists.txt +++ b/src/SFML/Network/CMakeLists.txt @@ -35,4 +35,4 @@ set(SRC # define the csfml-network target csfml_add_library(csfml-network SOURCES ${SRC} - DEPENDS ${SFML_NETWORK_LIBRARY} ${SFML_SYSTEM_LIBRARY} ${SFML_NETWORK_DEPENDENCIES} ${SFML_SYSTEM_DEPENDENCIES}) + DEPENDS sfml-network) diff --git a/src/SFML/Network/Ftp.cpp b/src/SFML/Network/Ftp.cpp index 5916668..993383b 100644 --- a/src/SFML/Network/Ftp.cpp +++ b/src/SFML/Network/Ftp.cpp @@ -299,13 +299,14 @@ sfFtpResponse* sfFtp_download(sfFtp* ftp, const char* remoteFile, const char* lo //////////////////////////////////////////////////////////// -sfFtpResponse* sfFtp_upload(sfFtp* ftp, const char* localFile, const char* remotePath, sfFtpTransferMode mode) +sfFtpResponse* sfFtp_upload(sfFtp* ftp, const char* localFile, const char* remotePath, sfFtpTransferMode mode, sfBool append) { CSFML_CHECK_RETURN(ftp, NULL); return new sfFtpResponse(ftp->This.upload(localFile ? localFile : "", remotePath ? remotePath : "", - static_cast(mode))); + static_cast(mode), + append == sfTrue)); } diff --git a/src/SFML/System/CMakeLists.txt b/src/SFML/System/CMakeLists.txt index d227862..2e62ec1 100644 --- a/src/SFML/System/CMakeLists.txt +++ b/src/SFML/System/CMakeLists.txt @@ -4,6 +4,7 @@ set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/System) # all source files set(SRC + ${CMAKE_SOURCE_DIR}/include/SFML/GPUPreference.h ${INCROOT}/Export.h ${SRCROOT}/Clock.cpp ${SRCROOT}/ClockStruct.h @@ -27,4 +28,4 @@ set(SRC # define the csfml-system target csfml_add_library(csfml-system SOURCES ${SRC} - DEPENDS ${SFML_SYSTEM_LIBRARY} ${SFML_SYSTEM_DEPENDENCIES}) + DEPENDS sfml-system) diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index ee0d89a..6438ce3 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -5,6 +5,11 @@ set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/Window) # all source files set(SRC ${INCROOT}/Export.h + ${INCROOT}/Clipboard.h + ${SRCROOT}/Clipboard.cpp + ${INCROOT}/Cursor.h + ${SRCROOT}/Cursor.cpp + ${SRCROOT}/CursorStruct.h ${SRCROOT}/Context.cpp ${SRCROOT}/ContextSettingsInternal.h ${SRCROOT}/ContextStruct.h @@ -33,4 +38,4 @@ set(SRC # define the csfml-window target csfml_add_library(csfml-window SOURCES ${SRC} - DEPENDS ${SFML_WINDOW_LIBRARY} ${SFML_SYSTEM_LIBRARY} ${SFML_WINDOW_DEPENDENCIES} ${SFML_SYSTEM_DEPENDENCIES}) + DEPENDS sfml-window) diff --git a/src/SFML/Window/Clipboard.cpp b/src/SFML/Window/Clipboard.cpp new file mode 100644 index 0000000..3602094 --- /dev/null +++ b/src/SFML/Window/Clipboard.cpp @@ -0,0 +1,67 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +namespace +{ + sf::String ClipboardString; + std::string ClipboardStringAnsi; +} + + +//////////////////////////////////////////////////////////// +const char* sfClipboard_getString() +{ + ClipboardStringAnsi = sf::Clipboard::getString().toAnsiString(); + return ClipboardStringAnsi.c_str(); +} + + +//////////////////////////////////////////////////////////// +const sfUint32* sfClipboard_getUnicodeString() +{ + ClipboardString = sf::Clipboard::getString(); + return ClipboardString.getData(); +} + + +//////////////////////////////////////////////////////////// +void sfClipboard_setString(const char* text) +{ + sf::Clipboard::setString(text); +} + + +//////////////////////////////////////////////////////////// +void sfClipboard_setUnicodeString(const sfUint32* text) +{ + sf::Clipboard::setString(text); +} diff --git a/src/SFML/Window/Context.cpp b/src/SFML/Window/Context.cpp index c420665..0b60149 100644 --- a/src/SFML/Window/Context.cpp +++ b/src/SFML/Window/Context.cpp @@ -51,6 +51,7 @@ sfBool sfContext_setActive(sfContext* context, sfBool active) CSFML_CALL_RETURN(context, setActive(active == sfTrue), false) } + //////////////////////////////////////////////////////////// sfContextSettings sfContext_getSettings(const sfContext* context) { @@ -62,3 +63,10 @@ sfContextSettings sfContext_getSettings(const sfContext* context) return settings; } + + +//////////////////////////////////////////////////////////// +sfUint64 sfContext_getActiveContextId() +{ + return sf::Context::getActiveContextId(); +} diff --git a/src/SFML/Window/Cursor.cpp b/src/SFML/Window/Cursor.cpp new file mode 100644 index 0000000..9bc0e6b --- /dev/null +++ b/src/SFML/Window/Cursor.cpp @@ -0,0 +1,68 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +//////////////////////////////////////////////////////////// +sfCursor* sfCursor_createFromPixels(const sfUint8* pixels, sfVector2u size, sfVector2u hotspot) +{ + sfCursor* cursor = new sfCursor; + + if (!cursor->This.loadFromPixels(pixels, sf::Vector2u(size.x, size.y), sf::Vector2u(hotspot.x, hotspot.y))) + { + delete cursor; + cursor = NULL; + } + + return cursor; +} + + +//////////////////////////////////////////////////////////// +sfCursor* sfCursor_createFromSystem(sfCursorType type) +{ + sfCursor* cursor = new sfCursor; + + if (!cursor->This.loadFromSystem(static_cast(type))) + { + delete cursor; + cursor = NULL; + } + + return cursor; +} + + +//////////////////////////////////////////////////////////// +void sfCursor_destroy(sfCursor* cursor) +{ + delete cursor; +} + diff --git a/src/SFML/Window/CursorStruct.h b/src/SFML/Window/CursorStruct.h new file mode 100644 index 0000000..9678de8 --- /dev/null +++ b/src/SFML/Window/CursorStruct.h @@ -0,0 +1,43 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2015 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_CURSORSTRUCT_H +#define SFML_CURSORSTRUCT_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +// Internal structure of sfCursor +//////////////////////////////////////////////////////////// +struct sfCursor +{ + sf::Cursor This; +}; + + +#endif // SFML_CURSORSTRUCT_H diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 421010d..df3aa7d 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -250,6 +251,14 @@ void sfWindow_setMouseCursorGrabbed(sfWindow* window, sfBool grabbed) } +//////////////////////////////////////////////////////////// +void sfWindow_setMouseCursor(sfWindow* window, const sfCursor* cursor) +{ + CSFML_CHECK(cursor); + + CSFML_CALL(window, setMouseCursor(cursor->This)); +} + //////////////////////////////////////////////////////////// void sfWindow_setVerticalSyncEnabled(sfWindow* window, sfBool enabled) {