This is an automated email from the git hooks/post-receive script. jcowgill pushed a commit to branch upstream in repository libcsfml.
commit 8346a2df0099d8f6528d397c931d51d6e0ce1ee2 Author: James Cowgill <[email protected]> Date: Fri Mar 3 22:30:12 2017 +0000 New upstream version 2.4 --- CMakeLists.txt | 2 +- doc/CMakeLists.txt | 2 +- doc/doxyfile.in | 6 +- include/SFML/Audio/SoundBufferRecorder.h | 30 +- include/SFML/Audio/SoundRecorder.h | 32 +- include/SFML/Config.h | 38 ++- include/SFML/Graphics/BlendMode.h | 5 +- include/SFML/Graphics/CircleShape.h | 2 +- include/SFML/Graphics/ConvexShape.h | 2 +- include/SFML/Graphics/Font.h | 11 +- .../Context.cpp => include/SFML/Graphics/Glsl.h | 79 ++++- include/SFML/Graphics/PrimitiveType.h | 18 +- include/SFML/Graphics/RectangleShape.h | 2 +- include/SFML/Graphics/RenderTexture.h | 17 + include/SFML/Graphics/RenderWindow.h | 84 +++-- include/SFML/Graphics/Shader.h | 364 +++++++++++++++++++-- include/SFML/Graphics/Shape.h | 2 +- include/SFML/Graphics/Text.h | 87 ++++- include/SFML/Graphics/Texture.h | 60 ++++ include/SFML/Graphics/Transform.h | 2 +- include/SFML/Network/Ftp.h | 26 +- include/SFML/Network/IpAddress.h | 9 +- include/SFML/Network/TcpListener.h | 6 +- include/SFML/Network/TcpSocket.h | 4 +- include/SFML/Network/UdpSocket.h | 17 +- include/SFML/Window/Context.h | 17 +- include/SFML/Window/Event.h | 33 +- include/SFML/Window/Keyboard.h | 13 + include/SFML/Window/VideoMode.h | 2 +- include/SFML/Window/Window.h | 82 +++-- readme.txt | 4 +- src/SFML/Audio/SoundBufferRecorder.cpp | 20 +- src/SFML/Audio/SoundBufferRecorderStruct.h | 1 + src/SFML/Audio/SoundRecorder.cpp | 17 + src/SFML/Graphics/Font.cpp | 4 +- src/SFML/Graphics/RenderTexture.cpp | 7 + src/SFML/Graphics/RenderWindow.cpp | 42 +-- src/SFML/Graphics/Shader.cpp | 318 +++++++++++++++--- src/SFML/Graphics/Text.cpp | 55 +++- src/SFML/Graphics/Texture.cpp | 21 ++ src/SFML/Network/Ftp.cpp | 23 +- src/SFML/Network/IpAddress.cpp | 4 + src/SFML/Network/TcpListener.cpp | 5 +- src/SFML/Network/TcpSocket.cpp | 16 +- src/SFML/Network/UdpSocket.cpp | 57 ++-- src/SFML/Window/CMakeLists.txt | 1 + src/SFML/Window/Context.cpp | 17 +- src/SFML/Window/ContextSettingsInternal.h | 75 +++++ src/SFML/Window/Keyboard.cpp | 6 + src/SFML/Window/Window.cpp | 38 +-- 50 files changed, 1456 insertions(+), 329 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36d666e..7cdff25 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 3) +set(VERSION_MINOR 4) set(VERSION_PATCH 0) # add the CSFML header path diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index d10d266..1a0c721 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -42,7 +42,7 @@ install(DIRECTORY ${DOXYGEN_OUTPUT_DIR}/html DESTINATION ${INSTALL_MISC_DIR}/doc COMPONENT doc) if(DOXYGEN_HHC_PROGRAM) - install(FILES ${DOXYGEN_OUTPUT_DIR}/SFML.chm + install(FILES ${DOXYGEN_OUTPUT_DIR}/CSFML.chm DESTINATION ${INSTALL_MISC_DIR}/doc COMPONENT doc) endif() diff --git a/doc/doxyfile.in b/doc/doxyfile.in index 72b1c82..2b7bdd2 100644 --- a/doc/doxyfile.in +++ b/doc/doxyfile.in @@ -25,7 +25,7 @@ DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. -PROJECT_NAME = SFML +PROJECT_NAME = CSFML # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or @@ -851,7 +851,7 @@ GENERATE_HTMLHELP = @DOXYGEN_GENERATE_HTMLHELP@ # can add a path in front of the file if the result should not be # written to the html output directory. -CHM_FILE = ../SFML.chm +CHM_FILE = ../CSFML.chm # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of @@ -1329,7 +1329,7 @@ CLASS_DIAGRAMS = YES # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = D:/Programmes/mscgen +MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented diff --git a/include/SFML/Audio/SoundBufferRecorder.h b/include/SFML/Audio/SoundBufferRecorder.h index ed53121..41674f5 100644 --- a/include/SFML/Audio/SoundBufferRecorder.h +++ b/include/SFML/Audio/SoundBufferRecorder.h @@ -61,8 +61,10 @@ CSFML_AUDIO_API void sfSoundBufferRecorder_destroy(sfSoundBufferRecorder* soundB /// \param soundBufferRecorder Sound buffer recorder object /// \param sampleRate Desired capture rate, in number of samples per second /// +/// \return sfTrue, if it was able to start recording +/// //////////////////////////////////////////////////////////// -CSFML_AUDIO_API void sfSoundBufferRecorder_start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate); +CSFML_AUDIO_API sfBool sfSoundBufferRecorder_start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate); //////////////////////////////////////////////////////////// /// \brief Stop the capture of a sound recorder @@ -101,5 +103,31 @@ CSFML_AUDIO_API unsigned int sfSoundBufferRecorder_getSampleRate(const sfSoundBu //////////////////////////////////////////////////////////// CSFML_AUDIO_API const sfSoundBuffer* sfSoundBufferRecorder_getBuffer(const sfSoundBufferRecorder* soundBufferRecorder); +//////////////////////////////////////////////////////////// +/// \brief Set the audio capture device +/// +/// This function sets the audio capture device to the device +/// with the given name. It can be called on the fly (i.e: +/// while recording). If you do so while recording and +/// opening the device fails, it stops the recording. +/// +/// \param soundBufferRecorder Sound buffer recorder object +/// \param name The name of the audio capture device +/// +/// \return sfTrue, if it was able to set the requested device +/// +//////////////////////////////////////////////////////////// +CSFML_AUDIO_API sfBool sfSoundBufferRecorder_setDevice(sfSoundBufferRecorder* soundBufferRecorder, const char* name); + +//////////////////////////////////////////////////////////// +/// \brief Get the name of the current audio capture device +/// +/// \param soundBufferRecorder Sound buffer recorder object +/// +/// \return The name of the current audio capture device +/// +//////////////////////////////////////////////////////////// +CSFML_AUDIO_API const char* sfSoundBufferRecorder_getDevice(sfSoundBufferRecorder* soundBufferRecorder); + #endif // SFML_SOUNDBUFFERRECORDER_H diff --git a/include/SFML/Audio/SoundRecorder.h b/include/SFML/Audio/SoundRecorder.h index 41caa54..610d8de 100644 --- a/include/SFML/Audio/SoundRecorder.h +++ b/include/SFML/Audio/SoundRecorder.h @@ -129,7 +129,7 @@ CSFML_AUDIO_API sfBool sfSoundRecorder_isAvailable(void); /// The default processing interval is 100 ms. /// /// \param soundRecorder Sound recorder object -/// \param interval Processing interval +/// \param interval Processing interval /// //////////////////////////////////////////////////////////// CSFML_AUDIO_API void sfSoundRecorder_setProcessingInterval(sfSoundRecorder* soundRecorder, sfTime interval); @@ -168,7 +168,7 @@ CSFML_AUDIO_API const char* sfSoundRecorder_getDefaultDevice(); /// opening the device fails, it stops the recording. /// /// \param soundRecorder Sound recorder object -/// \param The name of the audio capture device +/// \param name The name of the audio capture device /// /// \return sfTrue, if it was able to set the requested device /// @@ -185,5 +185,33 @@ CSFML_AUDIO_API sfBool sfSoundRecorder_setDevice(sfSoundRecorder* soundRecorder, //////////////////////////////////////////////////////////// CSFML_AUDIO_API const char* sfSoundRecorder_getDevice(sfSoundRecorder* soundRecorder); +//////////////////////////////////////////////////////////// +/// \brief Set the channel count of the audio capture device +/// +/// This method allows you to specify the number of channels +/// used for recording. Currently only 16-bit mono and +/// 16-bit stereo are supported. +/// +/// \param channelCount Number of channels. Currently only +/// mono (1) and stereo (2) are supported. +/// +/// \see sfSoundRecorder_getChannelCount +/// +//////////////////////////////////////////////////////////// +CSFML_AUDIO_API void sfSoundRecorder_setChannelCount(sfSoundRecorder* soundRecorder, unsigned int channelCount); + +//////////////////////////////////////////////////////////// +/// \brief Get the number of channels used by this recorder +/// +/// Currently only mono and stereo are supported, so the +/// value is either 1 (for mono) or 2 (for stereo). +/// +/// \return Number of channels +/// +/// \see sfSoundRecorder_setChannelCount +/// +//////////////////////////////////////////////////////////// +CSFML_AUDIO_API unsigned int sfSoundRecorder_getChannelCount(const sfSoundRecorder* soundRecorder); + #endif // SFML_SOUNDRECORDER_H diff --git a/include/SFML/Config.h b/include/SFML/Config.h index 01d706f..421cd61 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 3 +#define CSFML_VERSION_MINOR 4 #define CSFML_VERSION_PATCH 0 @@ -110,6 +110,42 @@ #endif +//////////////////////////////////////////////////////////// +// Cross-platform warning for deprecated functions and classes +// +// Usage: +// struct CSFML_DEPRECATED MyStruct +// { +// ... +// }; +// +// CSFML_DEPRECATED void globalFunc(); +//////////////////////////////////////////////////////////// +#if defined(CSFML_NO_DEPRECATED_WARNINGS) + + // User explicitly requests to disable deprecation warnings + #define CSFML_DEPRECATED + +#elif defined(_MSC_VER) + + // Microsoft C++ compiler + // Note: On newer MSVC versions, using deprecated functions causes a compiler error. In order to + // trigger a warning instead of an error, the compiler flag /sdl- (instead of /sdl) must be specified. + #define CSFML_DEPRECATED __declspec(deprecated) + +#elif defined(__GNUC__) + + // g++ and Clang + #define CSFML_DEPRECATED __attribute__ ((deprecated)) + +#else + + // Other compilers are not supported, leave class or function as-is. + // With a bit of luck, the #pragma directive works, otherwise users get a warning (no error!) for unrecognized #pragma. + #pragma message("CSFML_DEPRECATED is not supported for your compiler, please contact the CSFML team") + #define CSFML_DEPRECATED + +#endif //////////////////////////////////////////////////////////// // Define a portable boolean type diff --git a/include/SFML/Graphics/BlendMode.h b/include/SFML/Graphics/BlendMode.h index 93ea84b..8d3c144 100644 --- a/include/SFML/Graphics/BlendMode.h +++ b/include/SFML/Graphics/BlendMode.h @@ -56,8 +56,9 @@ typedef enum //////////////////////////////////////////////////////////// typedef enum { - sfBlendEquationAdd, ///< Pixel = Src * SrcFactor + Dst * DstFactor - sfBlendEquationSubtract ///< Pixel = Src * SrcFactor - Dst * DstFactor + sfBlendEquationAdd, ///< Pixel = Src * SrcFactor + Dst * DstFactor + sfBlendEquationSubtract, ///< Pixel = Src * SrcFactor - Dst * DstFactor + sfBlendEquationReverseSubtract ///< Pixel = Dst * DstFactor - Src * SrcFactor } sfBlendEquation; diff --git a/include/SFML/Graphics/CircleShape.h b/include/SFML/Graphics/CircleShape.h index 764029d..ae3038e 100644 --- a/include/SFML/Graphics/CircleShape.h +++ b/include/SFML/Graphics/CircleShape.h @@ -58,7 +58,7 @@ CSFML_GRAPHICS_API sfCircleShape* sfCircleShape_copy(const sfCircleShape* shape) //////////////////////////////////////////////////////////// /// \brief Destroy an existing circle Shape /// -/// \param Shape Shape to delete +/// \param shape Shape to delete /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfCircleShape_destroy(sfCircleShape* shape); diff --git a/include/SFML/Graphics/ConvexShape.h b/include/SFML/Graphics/ConvexShape.h index 08438e7..4b62fa5 100644 --- a/include/SFML/Graphics/ConvexShape.h +++ b/include/SFML/Graphics/ConvexShape.h @@ -58,7 +58,7 @@ CSFML_GRAPHICS_API sfConvexShape* sfConvexShape_copy(const sfConvexShape* shape) //////////////////////////////////////////////////////////// /// \brief Destroy an existing convex Shape /// -/// \param Shape Shape to delete +/// \param shape Shape to delete /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfConvexShape_destroy(sfConvexShape* shape); diff --git a/include/SFML/Graphics/Font.h b/include/SFML/Graphics/Font.h index 1c028b9..9b1aa09 100644 --- a/include/SFML/Graphics/Font.h +++ b/include/SFML/Graphics/Font.h @@ -88,15 +88,16 @@ CSFML_GRAPHICS_API void sfFont_destroy(sfFont* font); //////////////////////////////////////////////////////////// /// \brief Get a glyph in a font /// -/// \param font Source font -/// \param codePoint Unicode code point of the character to get -/// \param characterSize Character size, in pixels -/// \param bold Retrieve the bold version or the regular one? +/// \param font Source font +/// \param codePoint Unicode code point of the character to get +/// \param characterSize Character size, in pixels +/// \param bold Retrieve the bold version or the regular one? +/// \param outlineThickness Thickness of outline (when != 0 the glyph will not be filled) /// /// \return The corresponding glyph /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API sfGlyph sfFont_getGlyph(sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold); +CSFML_GRAPHICS_API sfGlyph sfFont_getGlyph(sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold, float outlineThickness); //////////////////////////////////////////////////////////// /// \brief Get the kerning value corresponding to a given pair of characters in a font diff --git a/src/SFML/Window/Context.cpp b/include/SFML/Graphics/Glsl.h similarity index 58% copy from src/SFML/Window/Context.cpp copy to include/SFML/Graphics/Glsl.h index 80b853e..16cb142 100644 --- a/src/SFML/Window/Context.cpp +++ b/include/SFML/Graphics/Glsl.h @@ -22,30 +22,79 @@ // //////////////////////////////////////////////////////////// +#ifndef SFML_GLSL_H +#define SFML_GLSL_H + //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// -#include <SFML/Window/Context.h> -#include <SFML/Window/ContextStruct.h> -#include <SFML/Internal.h> +#include <SFML/Graphics/Transform.h> +#include <SFML/Graphics/Color.h> +#include <SFML/System/Vector2.h> +#include <SFML/System/Vector3.h> +// 2D vectors +typedef sfVector2f sfGlslVec2; +typedef sfVector2i sfGlslIvec2; -//////////////////////////////////////////////////////////// -sfContext* sfContext_create(void) +typedef struct { - return new sfContext; -} + sfBool x; + sfBool y; +} sfGlslBvec2; +// 3D vectors +typedef sfVector3f sfGlslVec3; -//////////////////////////////////////////////////////////// -void sfContext_destroy(sfContext* context) +typedef struct +{ + int x; + int y; + int z; +} sfGlslIvec3; + +typedef struct { - delete context; -} + sfBool x; + sfBool y; + sfBool z; +} sfGlslBvec3; +// 4D vectors +typedef struct +{ + float x; + float y; + float z; + float w; +} sfGlslVec4; -//////////////////////////////////////////////////////////// -void sfContext_setActive(sfContext* context, sfBool active) +typedef struct { - CSFML_CALL(context, setActive(active == sfTrue)); -} + int x; + int y; + int z; + int w; +} sfGlslIvec4; + +typedef struct +{ + sfBool x; + sfBool y; + sfBool z; + sfBool w; +} sfGlslBvec4; + +// matrices +typedef struct +{ + float array[3 * 3]; +} sfGlslMat3; + +typedef struct +{ + float array[4 * 4]; +} sfGlslMat4; + + +#endif // SFML_GLSL_H diff --git a/include/SFML/Graphics/PrimitiveType.h b/include/SFML/Graphics/PrimitiveType.h index aa41baa..642335d 100644 --- a/include/SFML/Graphics/PrimitiveType.h +++ b/include/SFML/Graphics/PrimitiveType.h @@ -41,13 +41,17 @@ //////////////////////////////////////////////////////////// typedef enum { - sfPoints, ///< List of individual points - sfLines, ///< List of individual lines - sfLinesStrip, ///< List of connected lines, a point uses the previous point to form a line - sfTriangles, ///< List of individual triangles - sfTrianglesStrip, ///< List of connected triangles, a point uses the two previous points to form a triangle - sfTrianglesFan, ///< List of connected triangles, a point uses the common center and the previous point to form a triangle - sfQuads ///< List of individual quads + sfPoints, ///< List of individual points + sfLines, ///< List of individual lines + sfLineStrip, ///< List of connected lines, a point uses the previous point to form a line + sfTriangles, ///< List of individual triangles + sfTriangleStrip, ///< List of connected triangles, a point uses the two previous points to form a triangle + sfTriangleFan, ///< List of connected triangles, a point uses the common center and the previous point to form a triangle + sfQuads, ///< List of individual quads + + sfLinesStrip = sfLineStrip, ///< \deprecated Use sfLineStrip instead + sfTrianglesStrip = sfTriangleStrip, ///< \deprecated Use sfTriangleStrip instead + sfTrianglesFan = sfTriangleFan ///< \deprecated Use sfTriangleFan instead } sfPrimitiveType; diff --git a/include/SFML/Graphics/RectangleShape.h b/include/SFML/Graphics/RectangleShape.h index beca257..987a13c 100644 --- a/include/SFML/Graphics/RectangleShape.h +++ b/include/SFML/Graphics/RectangleShape.h @@ -58,7 +58,7 @@ CSFML_GRAPHICS_API sfRectangleShape* sfRectangleShape_copy(const sfRectangleShap //////////////////////////////////////////////////////////// /// \brief Destroy an existing rectangle shape /// -/// \param Shape Shape to delete +/// \param shape Shape to delete /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfRectangleShape_destroy(sfRectangleShape* shape); diff --git a/include/SFML/Graphics/RenderTexture.h b/include/SFML/Graphics/RenderTexture.h index 754aacf..5bc3fed 100644 --- a/include/SFML/Graphics/RenderTexture.h +++ b/include/SFML/Graphics/RenderTexture.h @@ -316,4 +316,21 @@ CSFML_GRAPHICS_API void sfRenderTexture_setRepeated(sfRenderTexture* renderTextu //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfBool sfRenderTexture_isRepeated(const sfRenderTexture* renderTexture); +//////////////////////////////////////////////////////////// +/// \brief Generate a mipmap using the current texture data +/// +/// This function is similar to sfTexture_generateMipmap and operates +/// on the texture used as the target for drawing. +/// Be aware that any draw operation may modify the base level image data. +/// For this reason, calling this function only makes sense after all +/// drawing is completed and display has been called. Not calling display +/// after subsequent drawing will lead to undefined behavior if a mipmap +/// had been previously generated. +/// +/// \return sfTrue if mipmap generation was successful, sfFalse if unsuccessful +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfBool sfRenderTexture_generateMipmap(sfRenderTexture* renderTexture); + + #endif // SFML_RENDERTEXTURE_H diff --git a/include/SFML/Graphics/RenderWindow.h b/include/SFML/Graphics/RenderWindow.h index 41c13f5..e55a549 100644 --- a/include/SFML/Graphics/RenderWindow.h +++ b/include/SFML/Graphics/RenderWindow.h @@ -209,6 +209,15 @@ CSFML_GRAPHICS_API void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, uns CSFML_GRAPHICS_API void sfRenderWindow_setVisible(sfRenderWindow* renderWindow, sfBool visible); //////////////////////////////////////////////////////////// +/// \brief Enable / disable vertical synchronization on a render window +/// +/// \param renderWindow Render window object +/// \param enabled sfTrue to enable v-sync, sfFalse to deactivate +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfRenderWindow_setVerticalSyncEnabled(sfRenderWindow* renderWindow, sfBool enabled); + +//////////////////////////////////////////////////////////// /// \brief Show or hide the mouse cursor on a render window /// /// \param renderWindow Render window object @@ -218,13 +227,19 @@ CSFML_GRAPHICS_API void sfRenderWindow_setVisible(sfRenderWindow* renderWindow, CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursorVisible(sfRenderWindow* renderWindow, sfBool show); //////////////////////////////////////////////////////////// -/// \brief Enable / disable vertical synchronization on a render window +/// \brief Grab or release the mouse cursor /// -/// \param renderWindow Render window object -/// \param enabled sfTrue to enable v-sync, sfFalse to deactivate +/// If set, grabs the mouse cursor inside this window's client +/// area so it may no longer be moved outside its bounds. +/// Note that grabbing is only active while the window has +/// focus and calling this function for fullscreen windows +/// won't have any effect (fullscreen windows always grab the +/// cursor). +/// +/// \param grabbed sfTrue to enable, sfFalse to disable /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfRenderWindow_setVerticalSyncEnabled(sfRenderWindow* renderWindow, sfBool enabled); +CSFML_GRAPHICS_API void sfRenderWindow_setMouseCursorGrabbed(sfRenderWindow* renderWindow, sfBool grabbed); //////////////////////////////////////////////////////////// /// \brief Enable or disable automatic key-repeat for keydown events @@ -238,6 +253,24 @@ CSFML_GRAPHICS_API void sfRenderWindow_setVerticalSyncEnabled(sfRenderWindow* re CSFML_GRAPHICS_API void sfRenderWindow_setKeyRepeatEnabled(sfRenderWindow* renderWindow, sfBool enabled); //////////////////////////////////////////////////////////// +/// \brief Limit the framerate to a maximum fixed frequency for a render window +/// +/// \param renderWindow Render window object +/// \param limit Framerate limit, in frames per seconds (use 0 to disable limit) +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfRenderWindow_setFramerateLimit(sfRenderWindow* renderWindow, unsigned int limit); + +//////////////////////////////////////////////////////////// +/// \brief Change the joystick threshold, ie. the value below which no move event will be generated +/// +/// \param renderWindow Render window object +/// \param threshold New threshold, in range [0, 100] +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfRenderWindow_setJoystickThreshold(sfRenderWindow* renderWindow, float threshold); + +//////////////////////////////////////////////////////////// /// \brief Activate or deactivate a render window as the current target for rendering /// /// \param renderWindow Render window object @@ -283,24 +316,6 @@ CSFML_GRAPHICS_API sfBool sfRenderWindow_hasFocus(const sfRenderWindow* renderWi CSFML_GRAPHICS_API void sfRenderWindow_display(sfRenderWindow* renderWindow); //////////////////////////////////////////////////////////// -/// \brief Limit the framerate to a maximum fixed frequency for a render window -/// -/// \param renderWindow Render window object -/// \param limit Framerate limit, in frames per seconds (use 0 to disable limit) -/// -//////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfRenderWindow_setFramerateLimit(sfRenderWindow* renderWindow, unsigned int limit); - -//////////////////////////////////////////////////////////// -/// \brief Change the joystick threshold, ie. the value below which no move event will be generated -/// -/// \param renderWindow Render window object -/// \param threshold New threshold, in range [0, 100] -/// -//////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfRenderWindow_setJoystickThreshold(sfRenderWindow* renderWindow, float threshold); - -//////////////////////////////////////////////////////////// /// \brief Retrieve the OS-specific handle of a render window /// /// \param renderWindow Render window object @@ -494,22 +509,31 @@ CSFML_GRAPHICS_API void sfRenderWindow_popGLStates(sfRenderWindow* renderWindow) CSFML_GRAPHICS_API void sfRenderWindow_resetGLStates(sfRenderWindow* renderWindow); //////////////////////////////////////////////////////////// -/// \brief Copy the current contents of a render window to an image +/// \brief Copy the current contents of the window to an image +/// +/// \deprecated +/// Use a sfTexture and its +/// sfTexture_updateFromRenderWindow(sfTexture*, const sfRenderWindow*, unsigned int, unsigned int) +/// function and copy its contents into an sfImage instead. +/// \code +/// sfVector2u windowSize = sfRenderWindow_getSize(window); +/// sfTexture* texture = sfTexture_create(windowSize.x, windowSize.y); +/// sfTexture_updateFromRenderWindow(texture, window, windowSize.x, windowSize.y); +/// sfImage* screenshot = sfTexture_copyToImage(texture); +/// \endcode /// /// This is a slow operation, whose main purpose is to make /// screenshots of the application. If you want to update an /// image with the contents of the window and then use it for -/// drawing, you should rather use a sfTexture and its -/// update(sfWindow*) function. +/// drawing, you should rather use a sfTexture and the +/// sfTexture_updateFromWindow(sfTexture*, const sfWindow*, unsigned int, unsigned int) function. /// You can also draw things directly to a texture with the -/// sfRenderWindow class. -/// -/// \param renderWindow Render window object +/// sfRenderTexture class. /// -/// \return New image containing the captured contents +/// \return sfImage containing the captured contents. /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API sfImage* sfRenderWindow_capture(const sfRenderWindow* renderWindow); +CSFML_GRAPHICS_API CSFML_DEPRECATED sfImage* sfRenderWindow_capture(const sfRenderWindow* renderWindow); //////////////////////////////////////////////////////////// /// \brief Get the current position of the mouse relative to a render-window diff --git a/include/SFML/Graphics/Shader.h b/include/SFML/Graphics/Shader.h index 7172c51..003b44e 100644 --- a/include/SFML/Graphics/Shader.h +++ b/include/SFML/Graphics/Shader.h @@ -30,69 +30,74 @@ //////////////////////////////////////////////////////////// #include <SFML/Graphics/Export.h> #include <SFML/Graphics/Color.h> +#include <SFML/Graphics/Glsl.h> #include <SFML/Graphics/Transform.h> #include <SFML/Graphics/Types.h> #include <SFML/System/InputStream.h> #include <SFML/System/Vector2.h> #include <SFML/System/Vector3.h> +#include <stddef.h> //////////////////////////////////////////////////////////// -/// \brief Load both the vertex and fragment shaders from files +/// \brief Load the vertex, geometry and fragment shaders from files /// -/// This function can load both the vertex and the fragment -/// shaders, or only one of them: pass NULL if you don't want to load -/// either the vertex shader or the fragment shader. +/// This function loads the vertex, geometry and fragment +/// shaders. Pass NULL if you don't want to load +/// a specific shader. /// The sources must be text files containing valid shaders /// in GLSL language. GLSL is a C-like language dedicated to /// OpenGL shaders; you'll probably need to read a good documentation /// for it before writing your own shaders. /// /// \param vertexShaderFilename Path of the vertex shader file to load, or NULL to skip this shader +/// \param geometryShaderFilename Path of the geometry shader file to load, or NULL to skip this shader /// \param fragmentShaderFilename Path of the fragment shader file to load, or NULL to skip this shader /// /// \return A new sfShader object, or NULL if it failed /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API sfShader* sfShader_createFromFile(const char* vertexShaderFilename, const char* fragmentShaderFilename); +CSFML_GRAPHICS_API sfShader* sfShader_createFromFile(const char* vertexShaderFilename, const char* geometryShaderFilename, const char* fragmentShaderFilename); //////////////////////////////////////////////////////////// -/// \brief Load both the vertex and fragment shaders from source codes in memory +/// \brief Load the vertex, geometry and fragment shaders from source code in memory /// -/// This function can load both the vertex and the fragment -/// shaders, or only one of them: pass NULL if you don't want to load -/// either the vertex shader or the fragment shader. +/// This function loads the vertex, geometry and fragment +/// shaders. Pass NULL if you don't want to load +/// a specific shader. /// The sources must be valid shaders in GLSL language. GLSL is /// a C-like language dedicated to OpenGL shaders; you'll /// probably need to read a good documentation for it before /// writing your own shaders. /// /// \param vertexShader String containing the source code of the vertex shader, or NULL to skip this shader +/// \param geometryShader String containing the source code of the geometry shader, or NULL to skip this shader /// \param fragmentShader String containing the source code of the fragment shader, or NULL to skip this shader /// /// \return A new sfShader object, or NULL if it failed /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API sfShader* sfShader_createFromMemory(const char* vertexShader, const char* fragmentShader); +CSFML_GRAPHICS_API sfShader* sfShader_createFromMemory(const char* vertexShader, const char* geometryShader, const char* fragmentShader); //////////////////////////////////////////////////////////// -/// \brief Load both the vertex and fragment shaders from custom streams +/// \brief Load the vertex, geometry and fragment shaders from custom streams /// -/// This function can load both the vertex and the fragment -/// shaders, or only one of them: pass NULL if you don't want to load -/// either the vertex shader or the fragment shader. +/// This function loads the vertex, geometry and fragment +/// shaders. Pass NULL if you don't want to load +/// a specific shader. /// The source codes must be valid shaders in GLSL language. /// GLSL is a C-like language dedicated to OpenGL shaders; /// you'll probably need to read a good documentation for /// it before writing your own shaders. /// /// \param vertexShaderStream Source stream to read the vertex shader from, or NULL to skip this shader +/// \param geometryShaderStream Source stream to read the geometry shader from, or NULL to skip this shader /// \param fragmentShaderStream Source stream to read the fragment shader from, or NULL to skip this shader /// /// \return A new sfShader object, or NULL if it failed /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API sfShader* sfShader_createFromStream(sfInputStream* vertexShaderStream, sfInputStream* fragmentShaderStream); +CSFML_GRAPHICS_API sfShader* sfShader_createFromStream(sfInputStream* vertexShaderStream, sfInputStream* geometryShaderStream, sfInputStream* fragmentShaderStream); //////////////////////////////////////////////////////////// /// \brief Destroy an existing shader @@ -103,6 +108,297 @@ CSFML_GRAPHICS_API sfShader* sfShader_createFromStream(sfInputStream* vertexShad CSFML_GRAPHICS_API void sfShader_destroy(sfShader* shader); //////////////////////////////////////////////////////////// +/// \brief Specify value for \p float uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param x Value of the float scalar +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setFloatUniform(sfShader* shader, const char* name, float x); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p vec2 uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param vector Value of the vec2 vector +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setVec2Uniform(sfShader* shader, const char* name, sfGlslVec2 vector); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p vec3 uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param vector Value of the vec3 vector +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setVec3Uniform(sfShader* shader, const char* name, sfGlslVec3 vector); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p vec4 uniform +/// +/// sfColor objects can be passed to this function via +/// the use of sfGlslVec4_fromsfColor(sfColor); +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param vector Value of the vec4 vector +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setVec4Uniform(sfShader* shader, const char* name, sfGlslVec4 vector); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p vec4 uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param color Value of the vec4 vector +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setColorUniform(sfShader* shader, const char* name, sfColor color); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p int uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param x Value of the integer scalar +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setIntUniform(sfShader* shader, const char* name, int x); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p ivec2 uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param vector Value of the ivec2 vector +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setIvec2Uniform(sfShader* shader, const char* name, sfGlslIvec2 vector); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p ivec3 uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param vector Value of the ivec3 vector +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setIvec3Uniform(sfShader* shader, const char* name, sfGlslIvec3 vector); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p ivec4 uniform +/// +/// sfColor objects can be passed to this function via +/// the use of sfGlslIvec4_fromsfColor(sfColor); +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param vector Value of the ivec4 vector +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setIvec4Uniform(sfShader* shader, const char* name, sfGlslIvec4 vector); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p ivec4 uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param color Value of the ivec4 vector +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setIntColorUniform(sfShader* shader, const char* name, sfColor color); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p bool uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param x Value of the bool scalar +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setBoolUniform(sfShader* shader, const char* name, sfBool x); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p bvec2 uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param vector Value of the bvec2 vector +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setBvec2Uniform(sfShader* shader, const char* name, sfGlslBvec2 vector); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p Bvec3 uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param vector Value of the Bvec3 vector +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setBvec3Uniform(sfShader* shader, const char* name, sfGlslBvec3 vector); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p bvec4 uniform +/// +/// sfColor objects can be passed to this function via +/// the use of sfGlslIvec4_fromsfColor(sfColor); +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param vector Value of the bvec4 vector +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setBvec4Uniform(sfShader* shader, const char* name, sfGlslBvec4 vector); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p mat3 matrix +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param matrix Value of the mat3 matrix +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setMat3Uniform(sfShader* shader, const char* name, const sfGlslMat3* matrix); + +//////////////////////////////////////////////////////////// +/// \brief Specify value for \p mat4 matrix +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param matrix Value of the mat4 matrix +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setMat4Uniform(sfShader* shader, const char* name, const sfGlslMat4* matrix); + +//////////////////////////////////////////////////////////// +/// \brief Specify a texture as \p sampler2D uniform +/// +/// \a name is the name of the variable to change in the shader. +/// The corresponding parameter in the shader must be a 2D texture +/// (\p sampler2D GLSL type). +/// +/// Example: +/// \code +/// uniform sampler2D the_texture; // this is the variable in the shader +/// \endcode +/// \code +/// sfTexture texture; +/// ... +/// sfShader_setTextureUniform(shader, "the_texture", &texture); +/// \endcode +/// It is important to note that \a texture must remain alive as long +/// as the shader uses it, no copy is made internally. +/// +/// To use the texture of the object being drawn, which cannot be +/// known in advance, you can pass the special value +/// sf::Shader::CurrentTexture: +/// \code +/// shader.setUniform("the_texture", sf::Shader::CurrentTexture). +/// \endcode +/// +/// \param shader Shader object +/// \param name Name of the texture in the shader +/// \param texture Texture to assign +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setTextureUniform(sfShader* shader, const char* name, const sfTexture* texture); + +//////////////////////////////////////////////////////////// +/// \brief Specify current texture as \p sampler2D uniform +/// +/// This overload maps a shader texture variable to the +/// texture of the object being drawn, which cannot be +/// known in advance. +/// The corresponding parameter in the shader must be a 2D texture +/// (\p sampler2D GLSL type). +/// +/// Example: +/// \code +/// uniform sampler2D current; // this is the variable in the shader +/// \endcode +/// \code +/// sfShader_setCurrentTextureUniform(shader, "current"); +/// \endcode +/// +/// \param shader Shader object +/// \param name Name of the texture in the shader +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setCurrentTextureUniform(sfShader* shader, const char* name); + +//////////////////////////////////////////////////////////// +/// \brief Specify values for \p float[] array uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param scalarArray pointer to array of \p float values +/// \param length Number of elements in the array +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setFloatUniformArray(sfShader* shader, const char* name, const float* scalarArray, size_t length); + +//////////////////////////////////////////////////////////// +/// \brief Specify values for \p vec2[] array uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param vectorArray pointer to array of \p vec2 values +/// \param length Number of elements in the array +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setVec2UniformArray(sfShader* shader, const char* name, const sfGlslVec2* vectorArray, size_t length); + +//////////////////////////////////////////////////////////// +/// \brief Specify values for \p vec3[] array uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param vectorArray pointer to array of \p vec3 values +/// \param length Number of elements in the array +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setVec3UniformArray(sfShader* shader, const char* name, const sfGlslVec3* vectorArray, size_t length); + +//////////////////////////////////////////////////////////// +/// \brief Specify values for \p vec4[] array uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param vectorArray pointer to array of \p vec4 values +/// \param length Number of elements in the array +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setVec4UniformArray(sfShader* shader, const char* name, const sfGlslVec4* vectorArray, size_t length); + +//////////////////////////////////////////////////////////// +/// \brief Specify values for \p mat3[] array uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param matrixArray pointer to array of \p mat3 values +/// \param length Number of elements in the array +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setMat3UniformArray(sfShader* shader, const char* name, const sfGlslMat3* matrixArray, size_t length); + +//////////////////////////////////////////////////////////// +/// \brief Specify values for \p mat4[] array uniform +/// +/// \param shader Shader object +/// \param name Name of the uniform variable in GLSL +/// \param matrixArray pointer to array of \p mat4 values +/// \param length Number of elements in the array +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfShader_setMat4UniformArray(sfShader* shader, const char* name, const sfGlslMat4* matrixArray, size_t length); + +//////////////////////////////////////////////////////////// /// \brief Change a float parameter of a shader /// /// \a name is the name of the variable to change in the shader. @@ -122,7 +418,7 @@ CSFML_GRAPHICS_API void sfShader_destroy(sfShader* shader); /// \param x Value to assign /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfShader_setFloatParameter(sfShader* shader, const char* name, float x); +CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setFloatParameter(sfShader* shader, const char* name, float x); //////////////////////////////////////////////////////////// /// \brief Change a 2-components vector parameter of a shader @@ -145,7 +441,7 @@ CSFML_GRAPHICS_API void sfShader_setFloatParameter(sfShader* shader, const char* /// \param y Second component of the value to assign /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfShader_setFloat2Parameter(sfShader* shader, const char* name, float x, float y); +CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setFloat2Parameter(sfShader* shader, const char* name, float x, float y); //////////////////////////////////////////////////////////// /// \brief Change a 3-components vector parameter of a shader @@ -169,7 +465,7 @@ CSFML_GRAPHICS_API void sfShader_setFloat2Parameter(sfShader* shader, const char /// \param z Third component of the value to assign /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfShader_setFloat3Parameter(sfShader* shader, const char* name, float x, float y, float z); +CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setFloat3Parameter(sfShader* shader, const char* name, float x, float y, float z); //////////////////////////////////////////////////////////// /// \brief Change a 4-components vector parameter of a shader @@ -194,7 +490,7 @@ CSFML_GRAPHICS_API void sfShader_setFloat3Parameter(sfShader* shader, const char /// \param w Fourth component of the value to assign /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfShader_setFloat4Parameter(sfShader* shader, const char* name, float x, float y, float z, float w); +CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setFloat4Parameter(sfShader* shader, const char* name, float x, float y, float z, float w); //////////////////////////////////////////////////////////// /// \brief Change a 2-components vector parameter of a shader @@ -217,7 +513,7 @@ CSFML_GRAPHICS_API void sfShader_setFloat4Parameter(sfShader* shader, const char /// \param vector Vector to assign /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfShader_setVector2Parameter(sfShader* shader, const char* name, sfVector2f vector); +CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setVector2Parameter(sfShader* shader, const char* name, sfVector2f vector); //////////////////////////////////////////////////////////// /// \brief Change a 3-components vector parameter of a shader @@ -240,7 +536,7 @@ CSFML_GRAPHICS_API void sfShader_setVector2Parameter(sfShader* shader, const cha /// \param vector Vector to assign /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfShader_setVector3Parameter(sfShader* shader, const char* name, sfVector3f vector); +CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setVector3Parameter(sfShader* shader, const char* name, sfVector3f vector); //////////////////////////////////////////////////////////// /// \brief Change a color parameter of a shader @@ -268,7 +564,7 @@ CSFML_GRAPHICS_API void sfShader_setVector3Parameter(sfShader* shader, const cha /// \param color Color to assign /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfShader_setColorParameter(sfShader* shader, const char* name, sfColor color); +CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setColorParameter(sfShader* shader, const char* name, sfColor color); //////////////////////////////////////////////////////////// /// \brief Change a matrix parameter of a shader @@ -291,7 +587,7 @@ CSFML_GRAPHICS_API void sfShader_setColorParameter(sfShader* shader, const char* /// \param transform Transform to assign /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfShader_setTransformParameter(sfShader* shader, const char* name, sfTransform transform); +CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setTransformParameter(sfShader* shader, const char* name, sfTransform transform); //////////////////////////////////////////////////////////// /// \brief Change a texture parameter of a shader @@ -324,7 +620,7 @@ CSFML_GRAPHICS_API void sfShader_setTransformParameter(sfShader* shader, const c /// \param texture Texture to assign /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfShader_setTextureParameter(sfShader* shader, const char* name, const sfTexture* texture); +CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setTextureParameter(sfShader* shader, const char* name, const sfTexture* texture); //////////////////////////////////////////////////////////// /// \brief Change a texture parameter of a shader @@ -347,7 +643,7 @@ CSFML_GRAPHICS_API void sfShader_setTextureParameter(sfShader* shader, const cha /// \param name Name of the texture in the shader /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfShader_setCurrentTextureParameter(sfShader* shader, const char* name); +CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setCurrentTextureParameter(sfShader* shader, const char* name); //////////////////////////////////////////////////////////// /// \brief Get the underlying OpenGL handle of the shader. @@ -398,5 +694,23 @@ CSFML_GRAPHICS_API void sfShader_bind(const sfShader* shader); //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfBool sfShader_isAvailable(void); +//////////////////////////////////////////////////////////// +/// \brief Tell whether or not the system supports geometry shaders +/// +/// This function should always be called before using +/// the geometry shader features. If it returns false, then +/// any attempt to use sfShader geometry shader features will fail. +/// +/// This function can only return true if isAvailable() would also +/// return true, since shaders in general have to be supported in +/// order for geometry shaders to be supported as well. +/// +/// Note: The first call to this function, whether by your +/// code or SFML will result in a context switch. +/// +/// \return True if geometry shaders are supported, false otherwise +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfBool sfShader_isGeometryAvailable(void); #endif // SFML_SHADER_H diff --git a/include/SFML/Graphics/Shape.h b/include/SFML/Graphics/Shape.h index 60c90aa..b8cdc25 100644 --- a/include/SFML/Graphics/Shape.h +++ b/include/SFML/Graphics/Shape.h @@ -57,7 +57,7 @@ CSFML_GRAPHICS_API sfShape* sfShape_create(sfShapeGetPointCountCallback getPoint //////////////////////////////////////////////////////////// /// \brief Destroy an existing shape /// -/// \param Shape Shape to delete +/// \param shape Shape to delete /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfShape_destroy(sfShape* shape); diff --git a/include/SFML/Graphics/Text.h b/include/SFML/Graphics/Text.h index ff9383f..0eaa6d3 100644 --- a/include/SFML/Graphics/Text.h +++ b/include/SFML/Graphics/Text.h @@ -290,17 +290,61 @@ CSFML_GRAPHICS_API void sfText_setCharacterSize(sfText* text, unsigned int size) CSFML_GRAPHICS_API void sfText_setStyle(sfText* text, sfUint32 style); //////////////////////////////////////////////////////////// -/// \brief Set the global color of a text +/// \brief Set the fill color of a text /// -/// By default, the text's color is opaque white. +/// By default, the text's fill color is opaque white. +/// Setting the fill color to a transparent color with an outline +/// will cause the outline to be displayed in the fill area of the text. /// /// \param text Text object -/// \param color New color of the text +/// \param color New fill color of the text +/// +/// \deprecated This function is deprecated and may be removed in future releases. +/// Use sfText_setFillColor instead. /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfText_setColor(sfText* text, sfColor color); //////////////////////////////////////////////////////////// +/// \brief Set the fill color of a text +/// +/// By default, the text's fill color is opaque white. +/// Setting the fill color to a transparent color with an outline +/// will cause the outline to be displayed in the fill area of the text. +/// +/// \param text Text object +/// \param color New fill color of the text +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfText_setFillColor(sfText* text, sfColor color); + +//////////////////////////////////////////////////////////// +/// \brief Set the outline color of the text +/// +/// By default, the text's outline color is opaque black. +/// +/// \param text Text object +/// \param color New outline color of the text +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfText_setOutlineColor(sfText* text, sfColor color); + +//////////////////////////////////////////////////////////// +/// \brief Set the thickness of the text's outline +/// +/// By default, the outline thickness is 0. +/// +/// Be aware that using a negative value for the outline +/// thickness will cause distorted rendering. +/// +/// \param thickness New outline thickness, in pixels +/// +/// \see getOutlineThickness +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfText_setOutlineThickness(sfText* text, float thickness); + +//////////////////////////////////////////////////////////// /// \brief Get the string of a text (returns an ANSI string) /// /// \param text Text object @@ -355,16 +399,49 @@ CSFML_GRAPHICS_API unsigned int sfText_getCharacterSize(const sfText* text); CSFML_GRAPHICS_API sfUint32 sfText_getStyle(const sfText* text); //////////////////////////////////////////////////////////// -/// \brief Get the global color of a text +/// \brief Get the fill color of a text /// /// \param text Text object /// -/// \return Global color of the text +/// \return Fill color of the text +/// +/// \deprecated This function is deprecated and may be removed in future releases. +/// Use sfText_getFillColor instead. /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfColor sfText_getColor(const sfText* text); //////////////////////////////////////////////////////////// +/// \brief Get the fill color of a text +/// +/// \param text Text object +/// +/// \return Fill color of the text +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfColor sfText_getFillColor(const sfText* text); + +//////////////////////////////////////////////////////////// +/// \brief Get the outline color of a text +/// +/// \param text Text object +/// +/// \return Outline color of the text +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfColor sfText_getOutlineColor(const sfText* text); + +//////////////////////////////////////////////////////////// +/// \brief Get the outline thickness of a text +/// +/// \param text Text object +/// +/// \return Outline thickness of a text, in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API float sfText_getOutlineThickness(const sfText* text); + +//////////////////////////////////////////////////////////// /// \brief Return the position of the \a index-th character in a text /// /// This function computes the visual position of a character diff --git a/include/SFML/Graphics/Texture.h b/include/SFML/Graphics/Texture.h index 4f4f094..3c83527 100644 --- a/include/SFML/Graphics/Texture.h +++ b/include/SFML/Graphics/Texture.h @@ -197,6 +197,41 @@ CSFML_GRAPHICS_API void sfTexture_setSmooth(sfTexture* texture, sfBool smooth); CSFML_GRAPHICS_API sfBool sfTexture_isSmooth(const sfTexture* texture); //////////////////////////////////////////////////////////// +/// \brief Enable or disable conversion from sRGB +/// +/// When providing texture data from an image file or memory, it can +/// either be stored in a linear color space or an sRGB color space. +/// Most digital images account for gamma correction already, so they +/// would need to be "uncorrected" back to linear color space before +/// being processed by the hardware. The hardware can automatically +/// convert it from the sRGB color space to a linear color space when +/// it gets sampled. When the rendered image gets output to the final +/// framebuffer, it gets converted back to sRGB. +/// +/// After enabling or disabling sRGB conversion, make sure to reload +/// the texture data in order for the setting to take effect. +/// +/// This option is only useful in conjunction with an sRGB capable +/// framebuffer. This can be requested during window creation. +/// +/// \param sRgb True to enable sRGB conversion, false to disable it +/// +/// \see sfTexture_isSrgb +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfTexture_setSrgb(sfTexture* texture, sfBool sRgb); + +//////////////////////////////////////////////////////////// +/// \brief Tell whether the texture source is converted from sRGB or not +/// +/// \return True if the texture source is converted from sRGB, false if not +/// +/// \see sfTexture_setSrgb +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfBool sfTexture_isSrgb(const sfTexture* texture); + +//////////////////////////////////////////////////////////// /// \brief Enable or disable repeating for a texture /// /// Repeating is involved when using texture coordinates @@ -230,6 +265,31 @@ CSFML_GRAPHICS_API void sfTexture_setRepeated(sfTexture* texture, sfBool repeate CSFML_GRAPHICS_API sfBool sfTexture_isRepeated(const sfTexture* texture); //////////////////////////////////////////////////////////// +/// \brief Generate a mipmap using the current texture data +/// +/// Mipmaps are pre-computed chains of optimized textures. Each +/// level of texture in a mipmap is generated by halving each of +/// the previous level's dimensions. This is done until the final +/// level has the size of 1x1. The textures generated in this process may +/// make use of more advanced filters which might improve the visual quality +/// of textures when they are applied to objects much smaller than they are. +/// This is known as minification. Because fewer texels (texture elements) +/// have to be sampled from when heavily minified, usage of mipmaps +/// can also improve rendering performance in certain scenarios. +/// +/// Mipmap generation relies on the necessary OpenGL extension being +/// available. If it is unavailable or generation fails due to another +/// reason, this function will return false. Mipmap data is only valid from +/// the time it is generated until the next time the base level image is +/// modified, at which point this function will have to be called again to +/// regenerate it. +/// +/// \return sfTrue if mipmap generation was successful, sfFalse if unsuccessful +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfBool sfTexture_generateMipmap(sfTexture* texture); + +//////////////////////////////////////////////////////////// /// \brief Get the underlying OpenGL handle of the texture. /// /// You shouldn't need to use this function, unless you have diff --git a/include/SFML/Graphics/Transform.h b/include/SFML/Graphics/Transform.h index 7237fbb..74f9a18 100644 --- a/include/SFML/Graphics/Transform.h +++ b/include/SFML/Graphics/Transform.h @@ -139,7 +139,7 @@ CSFML_GRAPHICS_API sfFloatRect sfTransform_transformRect(const sfTransform* tran /// equivalent to a matrix multiplication. /// /// \param transform Transform object -/// \param right Transform to combine to \a transform +/// \param other Transform to combine to \a transform /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfTransform_combine(sfTransform* transform, const sfTransform* other); diff --git a/include/SFML/Network/Ftp.h b/include/SFML/Network/Ftp.h index 34009a8..f15b840 100644 --- a/include/SFML/Network/Ftp.h +++ b/include/SFML/Network/Ftp.h @@ -332,7 +332,7 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_loginAnonymous(sfFtp* ftp); /// \return Server response to the request /// //////////////////////////////////////////////////////////// -CSFML_NETWORK_API sfFtpResponse* sfFtp_login(sfFtp* ftp, const char* userName, const char* password); +CSFML_NETWORK_API sfFtpResponse* sfFtp_login(sfFtp* ftp, const char* name, const char* password); //////////////////////////////////////////////////////////// /// \brief Close the connection with the server @@ -486,7 +486,7 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_deleteFile(sfFtp* ftp, const char* name); /// \return Server response to the request /// //////////////////////////////////////////////////////////// -CSFML_NETWORK_API sfFtpResponse* sfFtp_download(sfFtp* ftp, const char* distantFile, const char* destPath, sfFtpTransferMode mode); +CSFML_NETWORK_API sfFtpResponse* sfFtp_download(sfFtp* ftp, const char* remoteFile, const char* localPath, sfFtpTransferMode mode); //////////////////////////////////////////////////////////// /// \brief Upload a file to a FTP server @@ -504,7 +504,27 @@ CSFML_NETWORK_API sfFtpResponse* sfFtp_download(sfFtp* ftp, const char* distantF /// \return Server response to the request /// //////////////////////////////////////////////////////////// -CSFML_NETWORK_API sfFtpResponse* sfFtp_upload(sfFtp* ftp, const char* localFile, const char* destPath, sfFtpTransferMode mode); +CSFML_NETWORK_API sfFtpResponse* sfFtp_upload(sfFtp* ftp, const char* localFile, const char* remotePath, sfFtpTransferMode mode); + +//////////////////////////////////////////////////////////// +/// \brief Send a command to the FTP server +/// +/// While the most often used commands are provided as +/// specific functions, this function can be used to send +/// any FTP command to the server. If the command requires +/// one or more parameters, they can be specified in +/// \a parameter. Otherwise you should pass NULL. +/// If the server returns information, you can extract it +/// from the response using sfResponse_getMessage(). +/// +/// \param ftp Ftp object +/// \param command Command to send +/// \param parameter Command parameter +/// +/// \return Server response to the request +/// +//////////////////////////////////////////////////////////// +CSFML_NETWORK_API sfFtpResponse* sfFtp_sendCommand(sfFtp* ftp, const char* command, const char* parameter); #endif // SFML_FTP_H diff --git a/include/SFML/Network/IpAddress.h b/include/SFML/Network/IpAddress.h index 3295662..7ca444c 100644 --- a/include/SFML/Network/IpAddress.h +++ b/include/SFML/Network/IpAddress.h @@ -49,6 +49,12 @@ typedef struct CSFML_NETWORK_API const sfIpAddress sfIpAddress_None; //////////////////////////////////////////////////////////// +/// \brief Value representing any address (0.0.0.0) +/// +//////////////////////////////////////////////////////////// +CSFML_NETWORK_API const sfIpAddress sfIpAddress_Any; + +//////////////////////////////////////////////////////////// /// \brief Local host IP address (127.0.0.1, or "localhost") /// //////////////////////////////////////////////////////////// @@ -114,8 +120,7 @@ CSFML_NETWORK_API sfIpAddress sfIpAddress_fromInteger(sfUint32 address); /// from a host name. /// /// \param address Address object -/// -/// \return String representation of the address +/// \param string String where the string representation will be stored /// //////////////////////////////////////////////////////////// CSFML_NETWORK_API void sfIpAddress_toString(sfIpAddress address, char* string); diff --git a/include/SFML/Network/TcpListener.h b/include/SFML/Network/TcpListener.h index 3ac3507..9e65c58 100644 --- a/include/SFML/Network/TcpListener.h +++ b/include/SFML/Network/TcpListener.h @@ -30,6 +30,7 @@ //////////////////////////////////////////////////////////// #include <SFML/Network/Export.h> #include <SFML/Network/SocketStatus.h> +#include <SFML/Network/IpAddress.h> #include <SFML/Network/Types.h> @@ -98,13 +99,16 @@ CSFML_NETWORK_API unsigned short sfTcpListener_getLocalPort(const sfTcpListener* /// If the socket was previously listening to another port, /// it will be stopped first and bound to the new port. /// +/// If there is no specific address to listen to, pass sfIpAddress_Any +/// /// \param listener TCP listener object /// \param port Port to listen for new connections +/// \param address Address of the interface to listen on /// /// \return Status code /// //////////////////////////////////////////////////////////// -CSFML_NETWORK_API sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, unsigned short port); +CSFML_NETWORK_API sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, unsigned short port, sfIpAddress address); //////////////////////////////////////////////////////////// /// \brief Accept a new connection diff --git a/include/SFML/Network/TcpSocket.h b/include/SFML/Network/TcpSocket.h index 7f549a4..cd1b2cc 100644 --- a/include/SFML/Network/TcpSocket.h +++ b/include/SFML/Network/TcpSocket.h @@ -134,7 +134,7 @@ CSFML_NETWORK_API unsigned short sfTcpSocket_getRemotePort(const sfTcpSocket* so /// \return Status code /// //////////////////////////////////////////////////////////// -CSFML_NETWORK_API sfSocketStatus sfTcpSocket_connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, sfTime timeout); +CSFML_NETWORK_API sfSocketStatus sfTcpSocket_connect(sfTcpSocket* socket, sfIpAddress remoteAddress, unsigned short remotePort, sfTime timeout); //////////////////////////////////////////////////////////// /// \brief Disconnect a TCP socket from its remote peer @@ -194,7 +194,7 @@ CSFML_NETWORK_API sfSocketStatus sfTcpSocket_sendPartial(sfTcpSocket* socket, co /// \return Status code /// //////////////////////////////////////////////////////////// -CSFML_NETWORK_API sfSocketStatus sfTcpSocket_receive(sfTcpSocket* socket, void* data, size_t maxSize, size_t* sizeReceived); +CSFML_NETWORK_API sfSocketStatus sfTcpSocket_receive(sfTcpSocket* socket, void* data, size_t size, size_t* received); //////////////////////////////////////////////////////////// /// \brief Send a formatted packet of data to the remote peer of a TCP socket diff --git a/include/SFML/Network/UdpSocket.h b/include/SFML/Network/UdpSocket.h index a4ca69e..e0d9fba 100644 --- a/include/SFML/Network/UdpSocket.h +++ b/include/SFML/Network/UdpSocket.h @@ -101,13 +101,16 @@ CSFML_NETWORK_API unsigned short sfUdpSocket_getLocalPort(const sfUdpSocket* soc /// system to automatically pick an available port, and then /// call sfUdpSocket_getLocalPort to retrieve the chosen port. /// -/// \param socket UDP socket object -/// \param port Port to bind the socket to +/// If there is no specific address to listen to, pass sfIpAddress_Any +/// +/// \param socket UDP socket object +/// \param port Port to bind the socket to +/// \param address Address of the interface to bind to /// /// \return Status code /// //////////////////////////////////////////////////////////// -CSFML_NETWORK_API sfSocketStatus sfUdpSocket_bind(sfUdpSocket* socket, unsigned short port); +CSFML_NETWORK_API sfSocketStatus sfUdpSocket_bind(sfUdpSocket* socket, unsigned short port, sfIpAddress address); //////////////////////////////////////////////////////////// /// \brief Unbind a UDP socket from the local port to which it is bound @@ -137,7 +140,7 @@ CSFML_NETWORK_API void sfUdpSocket_unbind(sfUdpSocket* socket); /// \return Status code /// //////////////////////////////////////////////////////////// -CSFML_NETWORK_API sfSocketStatus sfUdpSocket_send(sfUdpSocket* socket, const void* data, size_t size, sfIpAddress address, unsigned short port); +CSFML_NETWORK_API sfSocketStatus sfUdpSocket_send(sfUdpSocket* socket, const void* data, size_t size, sfIpAddress remoteAddress, unsigned short remotePort); //////////////////////////////////////////////////////////// /// \brief Receive raw data from a remote peer with a UDP socket @@ -159,7 +162,7 @@ CSFML_NETWORK_API sfSocketStatus sfUdpSocket_send(sfUdpSocket* socket, const voi /// \return Status code /// //////////////////////////////////////////////////////////// -CSFML_NETWORK_API sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket, void* data, size_t maxSize, size_t* sizeReceived, sfIpAddress* address, unsigned short* port); +CSFML_NETWORK_API sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket, void* data, size_t size, size_t* received, sfIpAddress* remoteAddress, unsigned short* remotePort); //////////////////////////////////////////////////////////// /// \brief Send a formatted packet of data to a remote peer with a UDP socket @@ -176,7 +179,7 @@ CSFML_NETWORK_API sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket, void* /// \return Status code /// //////////////////////////////////////////////////////////// -CSFML_NETWORK_API sfSocketStatus sfUdpSocket_sendPacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress address, unsigned short port); +CSFML_NETWORK_API sfSocketStatus sfUdpSocket_sendPacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress remoteAddress, unsigned short remotePort); //////////////////////////////////////////////////////////// /// \brief Receive a formatted packet of data from a remote peer with a UDP socket @@ -191,7 +194,7 @@ CSFML_NETWORK_API sfSocketStatus sfUdpSocket_sendPacket(sfUdpSocket* socket, sfP /// \return Status code /// //////////////////////////////////////////////////////////// -CSFML_NETWORK_API sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress* address, unsigned short* port); +CSFML_NETWORK_API sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress* remoteAddress, unsigned short* remotePort); //////////////////////////////////////////////////////////// /// \brief Return the maximum number of bytes that can be diff --git a/include/SFML/Window/Context.h b/include/SFML/Window/Context.h index afa5bac..9bb651f 100644 --- a/include/SFML/Window/Context.h +++ b/include/SFML/Window/Context.h @@ -30,7 +30,7 @@ //////////////////////////////////////////////////////////// #include <SFML/Window/Export.h> #include <SFML/Window/Types.h> - +#include <SFML/Window/Window.h> //////////////////////////////////////////////////////////// /// \brief Create a new context @@ -56,8 +56,21 @@ CSFML_WINDOW_API void sfContext_destroy(sfContext* context); /// \param context Context object /// \param active sfTrue to activate, sfFalse to deactivate /// +/// \return sfTrue on success, sfFalse on failure +/// //////////////////////////////////////////////////////////// -CSFML_WINDOW_API void sfContext_setActive(sfContext* context, sfBool active); +CSFML_WINDOW_API sfBool sfContext_setActive(sfContext* context, sfBool active); +//////////////////////////////////////////////////////////// +/// \brief Get the settings of the context. +/// +/// Note that these settings may be different than the ones passed to the +/// constructor; they are indeed adjusted if the original settings are not +/// directly supported by the system. +/// +/// \return Structure containing the settings +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API sfContextSettings sfContext_getSettings(const sfContext* context); #endif // SFML_CONTEXT_H diff --git a/include/SFML/Window/Event.h b/include/SFML/Window/Event.h index 12354aa..c4f13d9 100644 --- a/include/SFML/Window/Event.h +++ b/include/SFML/Window/Event.h @@ -117,10 +117,13 @@ typedef struct } sfMouseButtonEvent; //////////////////////////////////////////////////////////// -/// \brief Mouse wheel events parameters (deprecated) +/// \brief Mouse wheel events parameters /// +/// \deprecated +/// Use sfMouseWheelScrollEvent instead. +/// //////////////////////////////////////////////////////////// -typedef struct +typedef struct CSFML_DEPRECATED { sfEventType type; int delta; @@ -216,19 +219,19 @@ typedef struct //////////////////////////////////////////////////////////// typedef union { - sfEventType type; ///< Type of the event - sfSizeEvent size; ///< Size event parameters - sfKeyEvent key; ///< Key event parameters - sfTextEvent text; ///< Text event parameters - sfMouseMoveEvent mouseMove; ///< Mouse move event parameters - sfMouseButtonEvent mouseButton; ///< Mouse button event parameters - sfMouseWheelEvent mouseWheel; ///< Mouse wheel event parameters (deprecated) - sfMouseWheelScrollEvent mouseWheelScroll; ///< Mouse wheel event parameters - sfJoystickMoveEvent joystickMove; ///< Joystick move event parameters - sfJoystickButtonEvent joystickButton; ///< Joystick button event parameters - sfJoystickConnectEvent joystickConnect; ///< Joystick (dis)connect event parameters - sfTouchEvent touch; ///< Touch events parameters - sfSensorEvent sensor; ///< Sensor event parameters + sfEventType type; ///< Type of the event + sfSizeEvent size; ///< Size event parameters + sfKeyEvent key; ///< Key event parameters + sfTextEvent text; ///< Text event parameters + sfMouseMoveEvent mouseMove; ///< Mouse move event parameters + sfMouseButtonEvent mouseButton; ///< Mouse button event parameters + sfMouseWheelEvent mouseWheel; ///< Mouse wheel event parameters (deprecated) + sfMouseWheelScrollEvent mouseWheelScroll; ///< Mouse wheel event parameters + sfJoystickMoveEvent joystickMove; ///< Joystick move event parameters + sfJoystickButtonEvent joystickButton; ///< Joystick button event parameters + sfJoystickConnectEvent joystickConnect; ///< Joystick (dis)connect event parameters + sfTouchEvent touch; ///< Touch events parameters + sfSensorEvent sensor; ///< Sensor event parameters } sfEvent; diff --git a/include/SFML/Window/Keyboard.h b/include/SFML/Window/Keyboard.h index 5b17687..9e79155 100644 --- a/include/SFML/Window/Keyboard.h +++ b/include/SFML/Window/Keyboard.h @@ -154,5 +154,18 @@ typedef enum //////////////////////////////////////////////////////////// CSFML_WINDOW_API sfBool sfKeyboard_isKeyPressed(sfKeyCode key); +//////////////////////////////////////////////////////////// +/// \brief Show or hide the virtual keyboard. +/// +/// Warning: the virtual keyboard is not supported on all systems. +/// It will typically be implemented on mobile OSes (Android, iOS) +/// but not on desktop OSes (Windows, Linux, ...). +/// +/// If the virtual keyboard is not available, this function does nothing. +/// +/// \param visible True to show, false to hide +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API void sfKeyboard_setVirtualKeyboardVisible(sfBool visible); #endif // SFML_KEYBOARD_H diff --git a/include/SFML/Window/VideoMode.h b/include/SFML/Window/VideoMode.h index 71b8843..90f9b8e 100644 --- a/include/SFML/Window/VideoMode.h +++ b/include/SFML/Window/VideoMode.h @@ -70,7 +70,7 @@ CSFML_WINDOW_API sfVideoMode sfVideoMode_getDesktopMode(void); /// \return Pointer to an array containing all the supported fullscreen modes /// //////////////////////////////////////////////////////////// -CSFML_WINDOW_API const sfVideoMode* sfVideoMode_getFullscreenModes(size_t* Count); +CSFML_WINDOW_API const sfVideoMode* sfVideoMode_getFullscreenModes(size_t* count); //////////////////////////////////////////////////////////// /// \brief Tell whether or not a video mode is valid diff --git a/include/SFML/Window/Window.h b/include/SFML/Window/Window.h index 8ccdb0c..6fe24de 100644 --- a/include/SFML/Window/Window.h +++ b/include/SFML/Window/Window.h @@ -75,6 +75,7 @@ typedef struct unsigned int majorVersion; ///< Major number of the context version to create unsigned int minorVersion; ///< Minor number of the context version to create sfUint32 attributeFlags; ///< The attribute flags to create the context with + sfBool sRgbCapable; ///< Whether the context framebuffer is sRGB capable } sfContextSettings; @@ -316,6 +317,20 @@ CSFML_WINDOW_API void sfWindow_setIcon(sfWindow* window, unsigned int width, uns CSFML_WINDOW_API void sfWindow_setVisible(sfWindow* window, sfBool visible); //////////////////////////////////////////////////////////// +/// \brief Enable or disable vertical synchronization +/// +/// Activating vertical synchronization will limit the number +/// of frames displayed to the refresh rate of the monitor. +/// This can avoid some visual artifacts, and limit the framerate +/// to a good value (but not constant across different computers). +/// +/// \param window Window object +/// \param enabled sfTrue to enable v-sync, sfFalse to deactivate +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API void sfWindow_setVerticalSyncEnabled(sfWindow* window, sfBool enabled); + +//////////////////////////////////////////////////////////// /// \brief Show or hide the mouse cursor /// /// \param window Window object @@ -325,18 +340,19 @@ CSFML_WINDOW_API void sfWindow_setVisible(sfWindow* window, sfBool visible); CSFML_WINDOW_API void sfWindow_setMouseCursorVisible(sfWindow* window, sfBool visible); //////////////////////////////////////////////////////////// -/// \brief Enable or disable vertical synchronization +/// \brief Grab or release the mouse cursor /// -/// Activating vertical synchronization will limit the number -/// of frames displayed to the refresh rate of the monitor. -/// This can avoid some visual artifacts, and limit the framerate -/// to a good value (but not constant across different computers). +/// If set, grabs the mouse cursor inside this window's client +/// area so it may no longer be moved outside its bounds. +/// Note that grabbing is only active while the window has +/// focus and calling this function for fullscreen windows +/// won't have any effect (fullscreen windows always grab the +/// cursor). /// -/// \param window Window object -/// \param enabled sfTrue to enable v-sync, sfFalse to deactivate +/// \param grabbed sfTrue to enable, sfFalse to disable /// //////////////////////////////////////////////////////////// -CSFML_WINDOW_API void sfWindow_setVerticalSyncEnabled(sfWindow* window, sfBool enabled); +CSFML_WINDOW_API void sfWindow_setMouseCursorGrabbed(sfWindow* window, sfBool grabbed); //////////////////////////////////////////////////////////// /// \brief Enable or disable automatic key-repeat @@ -354,6 +370,31 @@ CSFML_WINDOW_API void sfWindow_setVerticalSyncEnabled(sfWindow* window, sfBool e CSFML_WINDOW_API void sfWindow_setKeyRepeatEnabled(sfWindow* window, sfBool enabled); //////////////////////////////////////////////////////////// +/// \brief Limit the framerate to a maximum fixed frequency +/// +/// If a limit is set, the window will use a small delay after +/// each call to sfWindow_display to ensure that the current frame +/// lasted long enough to match the framerate limit. +/// +/// \param window Window object +/// \param limit Framerate limit, in frames per seconds (use 0 to disable limit) +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API void sfWindow_setFramerateLimit(sfWindow* window, unsigned int limit); + +//////////////////////////////////////////////////////////// +/// \brief Change the joystick threshold +/// +/// The joystick threshold is the value below which +/// no JoyMoved event will be generated. +/// +/// \param window Window object +/// \param threshold New threshold, in the range [0, 100] +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API void sfWindow_setJoystickThreshold(sfWindow* window, float threshold); + +//////////////////////////////////////////////////////////// /// \brief Activate or deactivate a window as the current target /// for OpenGL rendering /// @@ -412,31 +453,6 @@ CSFML_WINDOW_API sfBool sfWindow_hasFocus(const sfWindow* window); CSFML_WINDOW_API void sfWindow_display(sfWindow* window); //////////////////////////////////////////////////////////// -/// \brief Limit the framerate to a maximum fixed frequency -/// -/// If a limit is set, the window will use a small delay after -/// each call to sfWindow_display to ensure that the current frame -/// lasted long enough to match the framerate limit. -/// -/// \param window Window object -/// \param limit Framerate limit, in frames per seconds (use 0 to disable limit) -/// -//////////////////////////////////////////////////////////// -CSFML_WINDOW_API void sfWindow_setFramerateLimit(sfWindow* window, unsigned int limit); - -//////////////////////////////////////////////////////////// -/// \brief Change the joystick threshold -/// -/// The joystick threshold is the value below which -/// no JoyMoved event will be generated. -/// -/// \param window Window object -/// \param threshold New threshold, in the range [0, 100] -/// -//////////////////////////////////////////////////////////// -CSFML_WINDOW_API void sfWindow_setJoystickThreshold(sfWindow* window, float threshold); - -//////////////////////////////////////////////////////////// /// \brief Get the OS-specific handle of the window /// /// The type of the returned handle is sfWindowHandle, diff --git a/readme.txt b/readme.txt index cfc1774..8e304ca 100644 --- a/readme.txt +++ b/readme.txt @@ -9,7 +9,7 @@ Authors ------- Laurent Gomila - main developer ([email protected]) -Zachariah Brown - active maintainer ([email protected]) +Zachariah Brown - active maintainer ([email protected]) Download -------- @@ -26,7 +26,7 @@ There is no tutorial for CSFML, but since it's a binding you can use the C++ res * The community wiki (https://github.com/SFML/SFML/wiki/) * The community forum (http://en.sfml-dev.org/forums/) (or http://fr.sfml-dev.org/forums/ for French people) -Of course, you can also find the CSFM API documentation in the SDK. +Of course, you can also find the CSFML API documentation in the SDK. Building -------- diff --git a/src/SFML/Audio/SoundBufferRecorder.cpp b/src/SFML/Audio/SoundBufferRecorder.cpp index 31d14d9..94e1b84 100644 --- a/src/SFML/Audio/SoundBufferRecorder.cpp +++ b/src/SFML/Audio/SoundBufferRecorder.cpp @@ -45,9 +45,9 @@ void sfSoundBufferRecorder_destroy(sfSoundBufferRecorder* soundBufferRecorder) //////////////////////////////////////////////////////////// -void sfSoundBufferRecorder_start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate) +sfBool sfSoundBufferRecorder_start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate) { - CSFML_CALL(soundBufferRecorder, start(sampleRate)); + CSFML_CALL_RETURN(soundBufferRecorder, start(sampleRate), sfFalse); } @@ -74,3 +74,19 @@ const sfSoundBuffer* sfSoundBufferRecorder_getBuffer(const sfSoundBufferRecorder return &soundBufferRecorder->SoundBuffer; } + +//////////////////////////////////////////////////////////// +sfBool sfSoundBufferRecorder_setDevice(sfSoundBufferRecorder* soundBufferRecorder, const char* name) +{ + CSFML_CALL_RETURN(soundBufferRecorder, setDevice(name), sfFalse); +} + +//////////////////////////////////////////////////////////// +const char* sfSoundBufferRecorder_getDevice(sfSoundBufferRecorder* soundBufferRecorder) +{ + CSFML_CHECK_RETURN(soundBufferRecorder, NULL); + + soundBufferRecorder->DeviceName = soundBufferRecorder->This.getDevice(); + + return soundBufferRecorder->DeviceName.c_str(); +} diff --git a/src/SFML/Audio/SoundBufferRecorderStruct.h b/src/SFML/Audio/SoundBufferRecorderStruct.h index 1ea85a1..322c50a 100644 --- a/src/SFML/Audio/SoundBufferRecorderStruct.h +++ b/src/SFML/Audio/SoundBufferRecorderStruct.h @@ -39,6 +39,7 @@ struct sfSoundBufferRecorder { sf::SoundBufferRecorder This; mutable sfSoundBuffer SoundBuffer; + std::string DeviceName; }; diff --git a/src/SFML/Audio/SoundRecorder.cpp b/src/SFML/Audio/SoundRecorder.cpp index c27e922..69a59fd 100644 --- a/src/SFML/Audio/SoundRecorder.cpp +++ b/src/SFML/Audio/SoundRecorder.cpp @@ -102,6 +102,7 @@ const char** sfSoundRecorder_getAvailableDevices(size_t* count) return !cstringDevices.empty() ? &cstringDevices[0] : NULL; } + //////////////////////////////////////////////////////////// const char* sfSoundRecorder_getDefaultDevice() { @@ -110,12 +111,14 @@ const char* sfSoundRecorder_getDefaultDevice() return !defaultDevice.empty() ? defaultDevice.c_str() : NULL; } + //////////////////////////////////////////////////////////// sfBool sfSoundRecorder_setDevice(sfSoundRecorder* soundRecorder, const char* name) { CSFML_CALL_RETURN(soundRecorder, setDevice(name), sfFalse); } + //////////////////////////////////////////////////////////// const char* sfSoundRecorder_getDevice(sfSoundRecorder* soundRecorder) { @@ -125,3 +128,17 @@ const char* sfSoundRecorder_getDevice(sfSoundRecorder* soundRecorder) return soundRecorder->DeviceName.c_str(); } + + +//////////////////////////////////////////////////////////// +void sfSoundRecorder_setChannelCount(sfSoundRecorder* soundRecorder, unsigned int channelCount) +{ + CSFML_CALL(soundRecorder, setChannelCount(channelCount)); +} + + +//////////////////////////////////////////////////////////// +unsigned int sfSoundRecorder_getChannelCount(const sfSoundRecorder* soundRecorder) +{ + CSFML_CALL_RETURN(soundRecorder, getChannelCount(), 0); +} diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index b2b82a7..1f54e4a 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -93,12 +93,12 @@ void sfFont_destroy(sfFont* font) //////////////////////////////////////////////////////////// -sfGlyph sfFont_getGlyph(sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold) +sfGlyph sfFont_getGlyph(sfFont* font, sfUint32 codePoint, unsigned int characterSize, sfBool bold, float outlineThickness) { sfGlyph glyph = {0, {0, 0, 0, 0}, {0, 0, 0, 0}}; CSFML_CHECK_RETURN(font, glyph); - sf::Glyph SFMLGlyph = font->This.getGlyph(codePoint, characterSize, bold == sfTrue); + sf::Glyph SFMLGlyph = font->This.getGlyph(codePoint, characterSize, bold == sfTrue, outlineThickness); glyph.advance = SFMLGlyph.advance; glyph.bounds.left = SFMLGlyph.bounds.left; diff --git a/src/SFML/Graphics/RenderTexture.cpp b/src/SFML/Graphics/RenderTexture.cpp index d80b13f..57b5554 100644 --- a/src/SFML/Graphics/RenderTexture.cpp +++ b/src/SFML/Graphics/RenderTexture.cpp @@ -281,3 +281,10 @@ sfBool sfRenderTexture_isRepeated(const sfRenderTexture* renderTexture) { CSFML_CALL_RETURN(renderTexture, isRepeated(), sfFalse); } + + +//////////////////////////////////////////////////////////// +sfBool sfRenderTexture_generateMipmap(sfRenderTexture* renderTexture) +{ + CSFML_CALL_RETURN(renderTexture, generateMipmap(), sfFalse); +} diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp index 8ead1ae..b1fa344 100644 --- a/src/SFML/Graphics/RenderWindow.cpp +++ b/src/SFML/Graphics/RenderWindow.cpp @@ -38,6 +38,7 @@ #include <SFML/Graphics/ConvertRenderStates.hpp> #include <SFML/Window/Touch.hpp> #include <SFML/Internal.h> +#include <SFML/Window/ContextSettingsInternal.h> #include <SFML/ConvertEvent.h> @@ -51,12 +52,7 @@ sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const char* title, sfUin sf::ContextSettings params; if (settings) { - params.depthBits = settings->depthBits; - params.stencilBits = settings->stencilBits; - params.antialiasingLevel = settings->antialiasingLevel; - params.majorVersion = settings->majorVersion; - params.minorVersion = settings->minorVersion; - params.attributeFlags = settings->attributeFlags; + priv::sfContextSettings_writeToCpp(*settings, params); } // Create the window @@ -78,12 +74,7 @@ sfRenderWindow* sfRenderWindow_createUnicode(sfVideoMode mode, const sfUint32* t sf::ContextSettings params; if (settings) { - params.depthBits = settings->depthBits; - params.stencilBits = settings->stencilBits; - params.antialiasingLevel = settings->antialiasingLevel; - params.majorVersion = settings->majorVersion; - params.minorVersion = settings->minorVersion; - params.attributeFlags = settings->attributeFlags; + priv::sfContextSettings_writeToCpp(*settings, params); } // Create the window @@ -103,12 +94,7 @@ sfRenderWindow* sfRenderWindow_createFromHandle(sfWindowHandle handle, const sfC sf::ContextSettings params; if (settings) { - params.depthBits = settings->depthBits; - params.stencilBits = settings->stencilBits; - params.antialiasingLevel = settings->antialiasingLevel; - params.majorVersion = settings->majorVersion; - params.minorVersion = settings->minorVersion; - params.attributeFlags = settings->attributeFlags; + priv::sfContextSettings_writeToCpp(*settings, params); } // Create the window @@ -145,16 +131,11 @@ sfBool sfRenderWindow_isOpen(const sfRenderWindow* renderWindow) //////////////////////////////////////////////////////////// sfContextSettings sfRenderWindow_getSettings(const sfRenderWindow* renderWindow) { - sfContextSettings settings = {0, 0, 0, 2, 0}; + sfContextSettings settings = priv::sfContextSettings_null(); CSFML_CHECK_RETURN(renderWindow, settings); const sf::ContextSettings& params = renderWindow->This.getSettings(); - settings.depthBits = params.depthBits; - settings.stencilBits = params.stencilBits; - settings.antialiasingLevel = params.antialiasingLevel; - settings.majorVersion = params.majorVersion; - settings.minorVersion = params.minorVersion; - settings.attributeFlags = params.attributeFlags; + priv::sfContextSettings_readFromCpp(params, settings); return settings; } @@ -273,6 +254,13 @@ void sfRenderWindow_setVisible(sfRenderWindow* renderWindow, sfBool visible) //////////////////////////////////////////////////////////// +void sfRenderWindow_setVerticalSyncEnabled(sfRenderWindow* renderWindow, sfBool enabled) +{ + CSFML_CALL(renderWindow, setVerticalSyncEnabled(enabled == sfTrue)); +} + + +//////////////////////////////////////////////////////////// void sfRenderWindow_setMouseCursorVisible(sfRenderWindow* renderWindow, sfBool visible) { CSFML_CALL(renderWindow, setMouseCursorVisible(visible == sfTrue)); @@ -280,9 +268,9 @@ void sfRenderWindow_setMouseCursorVisible(sfRenderWindow* renderWindow, sfBool v //////////////////////////////////////////////////////////// -void sfRenderWindow_setVerticalSyncEnabled(sfRenderWindow* renderWindow, sfBool enabled) +void sfRenderWindow_setMouseCursorGrabbed(sfRenderWindow* renderWindow, sfBool grabbed) { - CSFML_CALL(renderWindow, setVerticalSyncEnabled(enabled == sfTrue)); + CSFML_CALL(renderWindow, setMouseCursorGrabbed(grabbed == sfTrue)); } diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index e90da6d..fdaeb32 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -34,26 +34,34 @@ //////////////////////////////////////////////////////////// -sfShader* sfShader_createFromFile(const char* vertexShaderFilename, const char* fragmentShaderFilename) +sfShader* sfShader_createFromFile(const char* vertexShaderFilename, const char* geometryShaderFilename, const char* fragmentShaderFilename) { bool success = false; sfShader* shader = new sfShader; - if (vertexShaderFilename || fragmentShaderFilename) + if (vertexShaderFilename || geometryShaderFilename || fragmentShaderFilename) { - if (!vertexShaderFilename) + if (!geometryShaderFilename) { - // fragment shader only - success = shader->This.loadFromFile(fragmentShaderFilename, sf::Shader::Fragment); - } - else if (!fragmentShaderFilename) - { - // vertex shader only - success = shader->This.loadFromFile(vertexShaderFilename, sf::Shader::Vertex); + if (!vertexShaderFilename) + { + // fragment shader only + success = shader->This.loadFromFile(fragmentShaderFilename, sf::Shader::Fragment); + } + else if (!fragmentShaderFilename) + { + // vertex shader only + success = shader->This.loadFromFile(vertexShaderFilename, sf::Shader::Vertex); + } + else + { + // vertex + fragment shaders + success = shader->This.loadFromFile(vertexShaderFilename, fragmentShaderFilename); + } } else { - // vertex + fragment shaders - success = shader->This.loadFromFile(vertexShaderFilename, fragmentShaderFilename); + // vertex + geometry + fragment shaders + success = shader->This.loadFromFile(vertexShaderFilename, geometryShaderFilename, fragmentShaderFilename); } } @@ -68,26 +76,34 @@ sfShader* sfShader_createFromFile(const char* vertexShaderFilename, const char* //////////////////////////////////////////////////////////// -sfShader* sfShader_createFromMemory(const char* vertexShader, const char* fragmentShader) +sfShader* sfShader_createFromMemory(const char* vertexShader, const char* geometryShader, const char* fragmentShader) { bool success = false; sfShader* shader = new sfShader; - if (vertexShader || fragmentShader) + if (vertexShader || geometryShader || fragmentShader) { - if (!vertexShader) + if (!geometryShader) { - // fragment shader only - success = shader->This.loadFromMemory(fragmentShader, sf::Shader::Fragment); - } - else if (!fragmentShader) - { - // vertex shader only - success = shader->This.loadFromMemory(vertexShader, sf::Shader::Vertex); + if (!vertexShader) + { + // fragment shader only + success = shader->This.loadFromMemory(fragmentShader, sf::Shader::Fragment); + } + else if (!fragmentShader) + { + // vertex shader only + success = shader->This.loadFromMemory(vertexShader, sf::Shader::Vertex); + } + else + { + // vertex + fragment shaders + success = shader->This.loadFromMemory(vertexShader, fragmentShader); + } } else { - // vertex + fragment shaders - success = shader->This.loadFromMemory(vertexShader, fragmentShader); + // vertex + geometry + fragment shaders + success = shader->This.loadFromMemory(vertexShader, geometryShader, fragmentShader); } } @@ -102,30 +118,41 @@ sfShader* sfShader_createFromMemory(const char* vertexShader, const char* fragme //////////////////////////////////////////////////////////// -sfShader* sfShader_createFromStream(sfInputStream* vertexShaderStream, sfInputStream* fragmentShaderStream) +sfShader* sfShader_createFromStream(sfInputStream* vertexShaderStream, sfInputStream* geometryShaderStream, sfInputStream* fragmentShaderStream) { bool success = false; sfShader* shader = new sfShader; - if (vertexShaderStream || fragmentShaderStream) + if (vertexShaderStream || geometryShaderStream || fragmentShaderStream) { - if (!vertexShaderStream) + if (!geometryShaderStream) { - // fragment shader only - CallbackStream stream(fragmentShaderStream); - success = shader->This.loadFromStream(stream, sf::Shader::Fragment); - } - else if (!fragmentShaderStream) - { - // vertex shader only - CallbackStream stream(vertexShaderStream); - success = shader->This.loadFromStream(stream, sf::Shader::Vertex); + if (!vertexShaderStream) + { + // fragment shader only + CallbackStream stream(fragmentShaderStream); + success = shader->This.loadFromStream(stream, sf::Shader::Fragment); + } + else if (!fragmentShaderStream) + { + // vertex shader only + CallbackStream stream(vertexShaderStream); + success = shader->This.loadFromStream(stream, sf::Shader::Vertex); + } + else + { + // vertex + fragment shaders + CallbackStream vertexStream(vertexShaderStream); + CallbackStream fragmentStream(fragmentShaderStream); + success = shader->This.loadFromStream(vertexStream, fragmentStream); + } } else { - // vertex + fragment shaders + // vertex + geometry + fragment shaders CallbackStream vertexStream(vertexShaderStream); + CallbackStream geometryStream(geometryShaderStream); CallbackStream fragmentStream(fragmentShaderStream); - success = shader->This.loadFromStream(vertexStream, fragmentStream); + success = shader->This.loadFromStream(vertexStream, geometryStream, fragmentStream); } } @@ -142,97 +169,282 @@ sfShader* sfShader_createFromStream(sfInputStream* vertexShaderStream, sfInputSt //////////////////////////////////////////////////////////// void sfShader_destroy(sfShader* shader) { - delete shader; + delete shader; +} + + +//////////////////////////////////////////////////////////// +void sfShader_setFloatUniform(sfShader* shader, const char* name, float x) +{ + CSFML_CALL(shader, setUniform(name, x)); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setVec2Uniform(sfShader* shader, const char* name, sfGlslVec2 vector) +{ + CSFML_CALL(shader, setUniform(name, sf::Glsl::Vec2(vector.x, vector.y))); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setVec3Uniform(sfShader* shader, const char* name, sfGlslVec3 vector) +{ + CSFML_CALL(shader, setUniform(name, sf::Glsl::Vec3(vector.x, vector.y, vector.z))); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setVec4Uniform(sfShader* shader, const char* name, sfGlslVec4 vector) +{ + CSFML_CALL(shader, setUniform(name, sf::Glsl::Vec4(vector.x, vector.y, vector.z, vector.w))); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setColorUniform(sfShader* shader, const char* name, sfColor color) +{ + sfGlslVec4 vec4; + vec4.x = color.r / 255.f; + vec4.y = color.g / 255.f; + vec4.z = color.b / 255.f; + vec4.w = color.a / 255.f; + + sfShader_setVec4Uniform(shader, name, vec4); +} + +//////////////////////////////////////////////////////////// +void sfShader_setIntUniform(sfShader* shader, const char* name, int x) +{ + CSFML_CALL(shader, setUniform(name, x)); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setIvec2Uniform(sfShader* shader, const char* name, sfGlslIvec2 vector) +{ + CSFML_CALL(shader, setUniform(name, sf::Glsl::Ivec2(vector.x, vector.y))); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setIvec3Uniform(sfShader* shader, const char* name, sfGlslIvec3 vector) +{ + CSFML_CALL(shader, setUniform(name, sf::Glsl::Ivec3(vector.x, vector.y, vector.z))); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setIvec4Uniform(sfShader* shader, const char* name, sfGlslIvec4 vector) +{ + CSFML_CALL(shader, setUniform(name, sf::Glsl::Ivec4(vector.x, vector.y, vector.z, vector.w))); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setIntColorUniform(sfShader* shader, const char* name, sfColor color) +{ + sfGlslIvec4 ivec4; + ivec4.x = (int)color.r; + ivec4.y = (int)color.g; + ivec4.z = (int)color.b; + ivec4.w = (int)color.a; + + sfShader_setIvec4Uniform(shader, name, ivec4); +} + +//////////////////////////////////////////////////////////// +void sfShader_setBoolUniform(sfShader* shader, const char* name, sfBool x) +{ + CSFML_CALL(shader, setUniform(name, x != sfFalse)); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setBvec2Uniform(sfShader* shader, const char* name, sfGlslBvec2 vector) +{ + CSFML_CALL(shader, setUniform(name, sf::Glsl::Bvec2(vector.x != sfFalse, vector.y != sfFalse))); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setBvec3Uniform(sfShader* shader, const char* name, sfGlslBvec3 vector) +{ + CSFML_CALL(shader, setUniform(name, sf::Glsl::Bvec3(vector.x != sfFalse, vector.y != sfFalse, vector.z != sfFalse))); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setBvec4Uniform(sfShader* shader, const char* name, sfGlslBvec4 vector) +{ + CSFML_CALL(shader, setUniform(name, sf::Glsl::Bvec4(vector.x != sfFalse, vector.y != sfFalse, vector.z != sfFalse, vector.w != sfFalse))); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setMat3Uniform(sfShader* shader, const char* name, const sfGlslMat3* matrix) +{ + CSFML_CALL(shader, setUniform(name, sf::Glsl::Mat3(matrix->array))); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setMat4Uniform(sfShader* shader, const char* name, const sfGlslMat4* matrix) +{ + CSFML_CALL(shader, setUniform(name, sf::Glsl::Mat4(matrix->array))); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setTextureUniform(sfShader* shader, const char* name, const sfTexture* texture) +{ + CSFML_CALL(shader, setUniform(name, *texture->This)); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setCurrentTextureUniform(sfShader* shader, const char* name) +{ + CSFML_CALL(shader, setUniform(name, sf::Shader::CurrentTexture)); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setFloatUniformArray(sfShader* shader, const char* name, const float* scalarArray, size_t length) +{ + CSFML_CALL(shader, setUniformArray(name, scalarArray, length)); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setVec2UniformArray(sfShader* shader, const char* name, const sfGlslVec2* vectorArray, size_t length) +{ + CSFML_CALL(shader, setUniformArray(name, reinterpret_cast<const sf::Glsl::Vec2*>(vectorArray), length)); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setVec3UniformArray(sfShader* shader, const char* name, const sfGlslVec3* vectorArray, size_t length) +{ + CSFML_CALL(shader, setUniformArray(name, reinterpret_cast<const sf::Glsl::Vec3*>(vectorArray), length)); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setVec4UniformArray(sfShader* shader, const char* name, const sfGlslVec4* vectorArray, size_t length) +{ + CSFML_CALL(shader, setUniformArray(name, reinterpret_cast<const sf::Glsl::Vec4*>(vectorArray), length)); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setMat3UniformArray(sfShader* shader, const char* name, const sfGlslMat3* matrixArray, size_t length) +{ + CSFML_CALL(shader, setUniformArray(name, reinterpret_cast<const sf::Glsl::Mat3*>(matrixArray), length)); +} + + +//////////////////////////////////////////////////////////// +void sfShader_setMat4UniformArray(sfShader* shader, const char* name, const sfGlslMat4* matrixArray, size_t length) +{ + CSFML_CALL(shader, setUniformArray(name, reinterpret_cast<const sf::Glsl::Mat4*>(matrixArray), length)); } //////////////////////////////////////////////////////////// void sfShader_setFloatParameter(sfShader* shader, const char* name, float x) { - CSFML_CALL(shader, setParameter(name, x)); + CSFML_CALL(shader, setParameter(name, x)); } //////////////////////////////////////////////////////////// void sfShader_setFloat2Parameter(sfShader* shader, const char* name, float x, float y) { - CSFML_CALL(shader, setParameter(name, x, y)); + CSFML_CALL(shader, setParameter(name, x, y)); } //////////////////////////////////////////////////////////// void sfShader_setFloat3Parameter(sfShader* shader, const char* name, float x, float y, float z) { - CSFML_CALL(shader, setParameter(name, x, y, z)); + CSFML_CALL(shader, setParameter(name, x, y, z)); } //////////////////////////////////////////////////////////// void sfShader_setFloat4Parameter(sfShader* shader, const char* name, float x, float y, float z, float w) { - CSFML_CALL(shader, setParameter(name, x, y, z, w)); + CSFML_CALL(shader, setParameter(name, x, y, z, w)); } //////////////////////////////////////////////////////////// void sfShader_setVector2Parameter(sfShader* shader, const char* name, sfVector2f vector) { - CSFML_CALL(shader, setParameter(name, sf::Vector2f(vector.x, vector.y))); + CSFML_CALL(shader, setParameter(name, sf::Vector2f(vector.x, vector.y))); } //////////////////////////////////////////////////////////// void sfShader_setVector3Parameter(sfShader* shader, const char* name, sfVector3f vector) { - CSFML_CALL(shader, setParameter(name, sf::Vector3f(vector.x, vector.y, vector.z))); + CSFML_CALL(shader, setParameter(name, sf::Vector3f(vector.x, vector.y, vector.z))); } //////////////////////////////////////////////////////////// void sfShader_setColorParameter(sfShader* shader, const char* name, sfColor color) { - CSFML_CALL(shader, setParameter(name, sf::Color(color.r, color.g, color.b, color.a))); + CSFML_CALL(shader, setParameter(name, sf::Color(color.r, color.g, color.b, color.a))); } //////////////////////////////////////////////////////////// void sfShader_setTransformParameter(sfShader* shader, const char* name, sfTransform transform) { - CSFML_CALL(shader, setParameter(name, convertTransform(transform))); + CSFML_CALL(shader, setParameter(name, convertTransform(transform))); } //////////////////////////////////////////////////////////// void sfShader_setTextureParameter(sfShader* shader, const char* name, const sfTexture* texture) { - CSFML_CHECK(texture); - CSFML_CALL(shader, setParameter(name, *texture->This)); + CSFML_CHECK(texture); + CSFML_CALL(shader, setParameter(name,*texture->This)); } //////////////////////////////////////////////////////////// void sfShader_setCurrentTextureParameter(sfShader* shader, const char* name) { - CSFML_CALL(shader, setParameter(name, sf::Shader::CurrentTexture)); + CSFML_CALL(shader, setParameter(name, sf::Shader::CurrentTexture)); } //////////////////////////////////////////////////////////// unsigned int sfShader_getNativeHandle(const sfShader* shader) { - CSFML_CALL_RETURN(shader, getNativeHandle(), 0); + CSFML_CALL_RETURN(shader, getNativeHandle(), 0); } //////////////////////////////////////////////////////////// void sfShader_bind(const sfShader* shader) { - sf::Shader::bind(shader ? &shader->This : NULL); + sf::Shader::bind(shader ? &shader->This : NULL); } //////////////////////////////////////////////////////////// sfBool sfShader_isAvailable(void) { - return sf::Shader::isAvailable() ? sfTrue : sfFalse; + return sf::Shader::isAvailable() ? sfTrue : sfFalse; +} + + +//////////////////////////////////////////////////////////// +sfBool sfShader_isGeometryAvailable(void) +{ + return sf::Shader::isGeometryAvailable() ? sfTrue : sfFalse; } diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index cd6e51c..27578ed 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -219,7 +219,28 @@ void sfText_setStyle(sfText* text, sfUint32 style) //////////////////////////////////////////////////////////// void sfText_setColor(sfText* text, sfColor color) { - CSFML_CALL(text, setColor(sf::Color(color.r, color.g, color.b, color.a))); + sfText_setFillColor(text, color); +} + + +//////////////////////////////////////////////////////////// +void sfText_setFillColor(sfText* text, sfColor color) +{ + CSFML_CALL(text, setFillColor(sf::Color(color.r, color.g, color.b, color.a))); +} + + +//////////////////////////////////////////////////////////// +void sfText_setOutlineColor(sfText* text, sfColor color) +{ + CSFML_CALL(text, setOutlineColor(sf::Color(color.r, color.g, color.b, color.a))); +} + + +//////////////////////////////////////////////////////////// +void sfText_setOutlineThickness(sfText* text, float thickness) +{ + CSFML_CALL(text, setOutlineThickness(thickness)); } @@ -269,10 +290,17 @@ sfUint32 sfText_getStyle(const sfText* text) //////////////////////////////////////////////////////////// sfColor sfText_getColor(const sfText* text) { + return sfText_getFillColor(text); +} + + +//////////////////////////////////////////////////////////// +sfColor sfText_getFillColor(const sfText* text) +{ sfColor color = {0, 0, 0, 0}; CSFML_CHECK_RETURN(text, color); - sf::Color sfmlColor = text->This.getColor(); + sf::Color sfmlColor = text->This.getFillColor(); color.r = sfmlColor.r; color.g = sfmlColor.g; color.b = sfmlColor.b; @@ -283,6 +311,29 @@ sfColor sfText_getColor(const sfText* text) //////////////////////////////////////////////////////////// +sfColor sfText_getOutlineColor(const sfText* text) +{ + sfColor color = { 0, 0, 0, 0 }; + CSFML_CHECK_RETURN(text, color); + + sf::Color sfmlColor = text->This.getOutlineColor(); + color.r = sfmlColor.r; + color.g = sfmlColor.g; + color.b = sfmlColor.b; + color.a = sfmlColor.a; + + return color; +} + + +//////////////////////////////////////////////////////////// +float sfText_getOutlineThickness(const sfText* text) +{ + CSFML_CALL_RETURN(text, getOutlineThickness(), 0.f); +} + + +//////////////////////////////////////////////////////////// sfVector2f sfText_findCharacterPos(const sfText* text, size_t index) { sfVector2f position = {0, 0}; diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index efe328f..a224351 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -226,6 +226,20 @@ sfBool sfTexture_isSmooth(const sfTexture* texture) //////////////////////////////////////////////////////////// +void sfTexture_setSrgb(sfTexture* texture, sfBool sRgb) +{ + CSFML_CALL_PTR(texture, setSrgb(sRgb == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +sfBool sfTexture_isSrgb(const sfTexture* texture) +{ + CSFML_CALL_PTR_RETURN(texture, isSrgb(), sfFalse); +} + + +//////////////////////////////////////////////////////////// void sfTexture_setRepeated(sfTexture* texture, sfBool repeated) { CSFML_CALL_PTR(texture, setRepeated(repeated == sfTrue)); @@ -243,6 +257,13 @@ sfBool sfTexture_isRepeated(const sfTexture* texture) //////////////////////////////////////////////////////////// +sfBool sfTexture_generateMipmap(sfTexture* texture) +{ + CSFML_CALL_PTR_RETURN(texture, generateMipmap(), sfFalse); +} + + +//////////////////////////////////////////////////////////// unsigned int sfTexture_getNativeHandle(const sfTexture* texture) { CSFML_CALL_PTR_RETURN(texture, getNativeHandle(), 0); diff --git a/src/SFML/Network/Ftp.cpp b/src/SFML/Network/Ftp.cpp index 26dac6f..5916668 100644 --- a/src/SFML/Network/Ftp.cpp +++ b/src/SFML/Network/Ftp.cpp @@ -189,11 +189,11 @@ sfFtpResponse* sfFtp_loginAnonymous(sfFtp* ftp) //////////////////////////////////////////////////////////// -sfFtpResponse* sfFtp_login(sfFtp* ftp, const char* userName, const char* password) +sfFtpResponse* sfFtp_login(sfFtp* ftp, const char* name, const char* password) { CSFML_CHECK_RETURN(ftp, NULL); - return new sfFtpResponse(ftp->This.login(userName ? userName : "", password ? password : "")); + return new sfFtpResponse(ftp->This.login(name ? name : "", password ? password : "")); } @@ -288,22 +288,31 @@ sfFtpResponse* sfFtp_deleteFile(sfFtp* ftp, const char* name) //////////////////////////////////////////////////////////// -sfFtpResponse* sfFtp_download(sfFtp* ftp, const char* distantFile, const char* destPath, sfFtpTransferMode mode) +sfFtpResponse* sfFtp_download(sfFtp* ftp, const char* remoteFile, const char* localPath, sfFtpTransferMode mode) { CSFML_CHECK_RETURN(ftp, NULL); - return new sfFtpResponse(ftp->This.download(distantFile ? distantFile : "", - destPath ? destPath : "", + return new sfFtpResponse(ftp->This.download(remoteFile ? remoteFile : "", + localPath ? localPath : "", static_cast<sf::Ftp::TransferMode>(mode))); } //////////////////////////////////////////////////////////// -sfFtpResponse* sfFtp_upload(sfFtp* ftp, const char* localFile, const char* destPath, sfFtpTransferMode mode) +sfFtpResponse* sfFtp_upload(sfFtp* ftp, const char* localFile, const char* remotePath, sfFtpTransferMode mode) { CSFML_CHECK_RETURN(ftp, NULL); return new sfFtpResponse(ftp->This.upload(localFile ? localFile : "", - destPath ? destPath : "", + remotePath ? remotePath : "", static_cast<sf::Ftp::TransferMode>(mode))); } + + +//////////////////////////////////////////////////////////// +sfFtpResponse* sfFtp_sendCommand(sfFtp* ftp, const char* command, const char* parameter) +{ + CSFML_CHECK_RETURN(ftp, NULL); + + return new sfFtpResponse(ftp->This.sendCommand(command ? command : "", parameter ? parameter : "")); +} diff --git a/src/SFML/Network/IpAddress.cpp b/src/SFML/Network/IpAddress.cpp index 9f0e6de..07bfe71 100644 --- a/src/SFML/Network/IpAddress.cpp +++ b/src/SFML/Network/IpAddress.cpp @@ -54,6 +54,10 @@ const sfIpAddress sfIpAddress_None = sfIpAddress_fromBytes(0, 0, 0, 0); //////////////////////////////////////////////////////////// +const sfIpAddress sfIpAddress_Any = sfIpAddress_fromBytes(0, 0, 0, 0); + + +//////////////////////////////////////////////////////////// const sfIpAddress sfIpAddress_LocalHost = sfIpAddress_fromBytes(127, 0, 0, 1); diff --git a/src/SFML/Network/TcpListener.cpp b/src/SFML/Network/TcpListener.cpp index dded940..f64a0d2 100644 --- a/src/SFML/Network/TcpListener.cpp +++ b/src/SFML/Network/TcpListener.cpp @@ -67,11 +67,12 @@ unsigned short sfTcpListener_getLocalPort(const sfTcpListener* listener) //////////////////////////////////////////////////////////// -sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, unsigned short port) +sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, unsigned short port, sfIpAddress address) { CSFML_CHECK_RETURN(listener, sfSocketError); - return static_cast<sfSocketStatus>(listener->This.listen(port)); + sf::IpAddress sfmlAddress(address.address); + return static_cast<sfSocketStatus>(listener->This.listen(port, sfmlAddress)); } diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp index ed1a674..1d4e015 100644 --- a/src/SFML/Network/TcpSocket.cpp +++ b/src/SFML/Network/TcpSocket.cpp @@ -89,13 +89,13 @@ unsigned short sfTcpSocket_getRemotePort(const sfTcpSocket* socket) //////////////////////////////////////////////////////////// -sfSocketStatus sfTcpSocket_connect(sfTcpSocket* socket, sfIpAddress host, unsigned short port, sfTime timeout) +sfSocketStatus sfTcpSocket_connect(sfTcpSocket* socket, sfIpAddress remoteAddress, unsigned short remotePort, sfTime timeout) { - sf::IpAddress address(host.address); + sf::IpAddress address(remoteAddress.address); CSFML_CHECK_RETURN(socket, sfSocketError); - return static_cast<sfSocketStatus>(socket->This.connect(address, port, sf::microseconds(timeout.microseconds))); + return static_cast<sfSocketStatus>(socket->This.connect(address, remotePort, sf::microseconds(timeout.microseconds))); } @@ -125,18 +125,18 @@ sfSocketStatus sfTcpSocket_sendPartial(sfTcpSocket* socket, const void* data, si //////////////////////////////////////////////////////////// -sfSocketStatus sfTcpSocket_receive(sfTcpSocket* socket, void* data, size_t maxSize, size_t* sizeReceived) +sfSocketStatus sfTcpSocket_receive(sfTcpSocket* socket, void* data, size_t size, size_t* received) { CSFML_CHECK_RETURN(socket, sfSocketError); - if (sizeReceived) + if (received) { - return static_cast<sfSocketStatus>(socket->This.receive(data, maxSize, *sizeReceived)); + return static_cast<sfSocketStatus>(socket->This.receive(data, size, *received)); } else { - std::size_t size = 0; - return static_cast<sfSocketStatus>(socket->This.receive(data, maxSize, size)); + std::size_t tempReceived = 0; + return static_cast<sfSocketStatus>(socket->This.receive(data, size, tempReceived)); } } diff --git a/src/SFML/Network/UdpSocket.cpp b/src/SFML/Network/UdpSocket.cpp index cfd545a..60dd518 100644 --- a/src/SFML/Network/UdpSocket.cpp +++ b/src/SFML/Network/UdpSocket.cpp @@ -68,11 +68,12 @@ unsigned short sfUdpSocket_getLocalPort(const sfUdpSocket* socket) //////////////////////////////////////////////////////////// -sfSocketStatus sfUdpSocket_bind(sfUdpSocket* socket, unsigned short port) +sfSocketStatus sfUdpSocket_bind(sfUdpSocket* socket, unsigned short port, sfIpAddress address) { CSFML_CHECK_RETURN(socket, sfSocketError); - return static_cast<sfSocketStatus>(socket->This.bind(port)); + sf::IpAddress sfmlAddress(address.address); + return static_cast<sfSocketStatus>(socket->This.bind(port, sfmlAddress)); } @@ -84,74 +85,74 @@ void sfUdpSocket_unbind(sfUdpSocket* socket) //////////////////////////////////////////////////////////// -sfSocketStatus sfUdpSocket_send(sfUdpSocket* socket, const void* data, size_t size, sfIpAddress address, unsigned short port) +sfSocketStatus sfUdpSocket_send(sfUdpSocket* socket, const void* data, size_t size, sfIpAddress remoteAddress, unsigned short remotePort) { CSFML_CHECK_RETURN(socket, sfSocketError); // Convert the address - sf::IpAddress receiver(address.address); + sf::IpAddress address(remoteAddress.address); - return static_cast<sfSocketStatus>(socket->This.send(data, size, receiver, port)); + return static_cast<sfSocketStatus>(socket->This.send(data, size, address, remotePort)); } //////////////////////////////////////////////////////////// -sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket, void* data, size_t maxSize, size_t* sizeReceived, sfIpAddress* address, unsigned short* port) +sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket, void* data, size_t size, size_t* received, sfIpAddress* remoteAddress, unsigned short* remotePort) { CSFML_CHECK_RETURN(socket, sfSocketError); - // Call SFML internal function - sf::IpAddress sender; - unsigned short senderPort; - std::size_t received; + sf::IpAddress address; + unsigned short port; + std::size_t sizeReceived; - sf::Socket::Status status = socket->This.receive(data, maxSize, received, sender, senderPort); + sf::Socket::Status status = socket->This.receive(data, size, sizeReceived, address, port); if (status != sf::Socket::Done) return static_cast<sfSocketStatus>(status); - if (sizeReceived) - *sizeReceived = received; + if (received) + *received = sizeReceived; - if (address) - strncpy(address->address, sender.toString().c_str(), 16); + if (remoteAddress) + strncpy(remoteAddress->address, address.toString().c_str(), 16); - if (port) - *port = senderPort; + if (remotePort) + *remotePort = port; return sfSocketDone; } //////////////////////////////////////////////////////////// -sfSocketStatus sfUdpSocket_sendPacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress address, unsigned short port) +sfSocketStatus sfUdpSocket_sendPacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress remoteAddress, unsigned short remotePort) { CSFML_CHECK_RETURN(socket, sfSocketError); CSFML_CHECK_RETURN(packet, sfSocketError); // Convert the address - sf::IpAddress receiver(address.address); + sf::IpAddress address(remoteAddress.address); - return static_cast<sfSocketStatus>(socket->This.send(packet->This, receiver, port)); + return static_cast<sfSocketStatus>(socket->This.send(packet->This, address, remotePort)); } //////////////////////////////////////////////////////////// -sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress* address, unsigned short* port) +sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet, sfIpAddress* remoteAddress, unsigned short* remotePort) { CSFML_CHECK_RETURN(socket, sfSocketError); CSFML_CHECK_RETURN(packet, sfSocketError); - sf::IpAddress sender; - unsigned short senderPort; - sf::Socket::Status status = socket->This.receive(packet->This, sender, senderPort); + sf::IpAddress address; + unsigned short port; + + sf::Socket::Status status = socket->This.receive(packet->This, address, port); if (status != sf::Socket::Done) return static_cast<sfSocketStatus>(status); - if (address) - strncpy(address->address, sender.toString().c_str(), 16); + if (remoteAddress) + strncpy(remoteAddress->address, address.toString().c_str(), 16); - if (port) - *port = senderPort; + if (remotePort) + *remotePort = port; return sfSocketDone; } diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index 521b71d..ee0d89a 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -6,6 +6,7 @@ set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/Window) set(SRC ${INCROOT}/Export.h ${SRCROOT}/Context.cpp + ${SRCROOT}/ContextSettingsInternal.h ${SRCROOT}/ContextStruct.h ${INCROOT}/Context.h ${INCROOT}/Event.h diff --git a/src/SFML/Window/Context.cpp b/src/SFML/Window/Context.cpp index 80b853e..c420665 100644 --- a/src/SFML/Window/Context.cpp +++ b/src/SFML/Window/Context.cpp @@ -28,6 +28,7 @@ #include <SFML/Window/Context.h> #include <SFML/Window/ContextStruct.h> #include <SFML/Internal.h> +#include <SFML/Window/ContextSettingsInternal.h> //////////////////////////////////////////////////////////// @@ -45,7 +46,19 @@ void sfContext_destroy(sfContext* context) //////////////////////////////////////////////////////////// -void sfContext_setActive(sfContext* context, sfBool active) +sfBool sfContext_setActive(sfContext* context, sfBool active) { - CSFML_CALL(context, setActive(active == sfTrue)); + CSFML_CALL_RETURN(context, setActive(active == sfTrue), false) +} + +//////////////////////////////////////////////////////////// +sfContextSettings sfContext_getSettings(const sfContext* context) +{ + sfContextSettings settings = priv::sfContextSettings_null(); + CSFML_CHECK_RETURN(context, settings); + + const sf::ContextSettings& params = context->This.getSettings(); + priv::sfContextSettings_readFromCpp(params, settings); + + return settings; } diff --git a/src/SFML/Window/ContextSettingsInternal.h b/src/SFML/Window/ContextSettingsInternal.h new file mode 100644 index 0000000..d1ce7af --- /dev/null +++ b/src/SFML/Window/ContextSettingsInternal.h @@ -0,0 +1,75 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2016 Laurent Gomila ([email protected]) +// +// 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_CONTEXTSETTINGSINTERNAL_H +#define SFML_CONTEXTSETTINGSINTERNAL_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include <SFML/Window.h> +#include <SFML/Window.hpp> + +namespace priv +{ + //////////////////////////////////////////////////////////// + // Create a "null" sfContextSettings that's returned in case of an error. + //////////////////////////////////////////////////////////// + inline sfContextSettings sfContextSettings_null() + { + sfContextSettings settings = {0, 0, 0, 0, 0, 0, sfFalse}; + + return settings; + } + + //////////////////////////////////////////////////////////// + // Read the data of an sf::ContextSettings into an sfContextSettings + //////////////////////////////////////////////////////////// + inline void sfContextSettings_readFromCpp(const sf::ContextSettings& from, sfContextSettings& to) + { + to.depthBits = from.depthBits; + to.stencilBits = from.stencilBits; + to.antialiasingLevel = from.antialiasingLevel; + to.majorVersion = from.majorVersion; + to.minorVersion = from.minorVersion; + to.attributeFlags = from.attributeFlags; + to.sRgbCapable = from.sRgbCapable ? sfTrue : sfFalse; + } + + //////////////////////////////////////////////////////////// + // Write the data of an sfContextSettings into an sf::ContextSettings + //////////////////////////////////////////////////////////// + inline void sfContextSettings_writeToCpp(const sfContextSettings& from, sf::ContextSettings& to) + { + to.depthBits = from.depthBits; + to.stencilBits = from.stencilBits; + to.antialiasingLevel = from.antialiasingLevel; + to.majorVersion = from.majorVersion; + to.minorVersion = from.minorVersion; + to.attributeFlags = from.attributeFlags; + to.sRgbCapable = from.sRgbCapable == sfTrue; + } +} + +#endif // SFML_CONTEXTSETTINGSINTERNAL_H diff --git a/src/SFML/Window/Keyboard.cpp b/src/SFML/Window/Keyboard.cpp index ab0c66b..ff65cfb 100644 --- a/src/SFML/Window/Keyboard.cpp +++ b/src/SFML/Window/Keyboard.cpp @@ -35,3 +35,9 @@ sfBool sfKeyboard_isKeyPressed(sfKeyCode key) { return sf::Keyboard::isKeyPressed(static_cast<sf::Keyboard::Key>(key)); } + +//////////////////////////////////////////////////////////// +void sfKeyboard_setVirtualKeyboardVisible(sfBool visible) +{ + sf::Keyboard::setVirtualKeyboardVisible(visible == sfTrue); +} diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 6507a3d..421010d 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -28,6 +28,7 @@ #include <SFML/Window/Window.h> #include <SFML/Window/WindowStruct.h> #include <SFML/Internal.h> +#include <SFML/Window/ContextSettingsInternal.h> #include <SFML/ConvertEvent.h> @@ -41,12 +42,7 @@ sfWindow* sfWindow_create(sfVideoMode mode, const char* title, sfUint32 style, c sf::ContextSettings params; if (settings) { - params.depthBits = settings->depthBits; - params.stencilBits = settings->stencilBits; - params.antialiasingLevel = settings->antialiasingLevel; - params.majorVersion = settings->majorVersion; - params.minorVersion = settings->minorVersion; - params.attributeFlags = settings->attributeFlags; + priv::sfContextSettings_writeToCpp(*settings, params); } // Create the window @@ -66,12 +62,7 @@ sfWindow* sfWindow_createUnicode(sfVideoMode mode, const sfUint32* title, sfUint sf::ContextSettings params; if (settings) { - params.depthBits = settings->depthBits; - params.stencilBits = settings->stencilBits; - params.antialiasingLevel = settings->antialiasingLevel; - params.majorVersion = settings->majorVersion; - params.minorVersion = settings->minorVersion; - params.attributeFlags = settings->attributeFlags; + priv::sfContextSettings_writeToCpp(*settings, params); } // Create the window @@ -89,12 +80,7 @@ sfWindow* sfWindow_createFromHandle(sfWindowHandle handle, const sfContextSettin sf::ContextSettings params; if (settings) { - params.depthBits = settings->depthBits; - params.stencilBits = settings->stencilBits; - params.antialiasingLevel = settings->antialiasingLevel; - params.majorVersion = settings->majorVersion; - params.minorVersion = settings->minorVersion; - params.attributeFlags = settings->attributeFlags; + priv::sfContextSettings_writeToCpp(*settings, params); } // Create the window @@ -128,16 +114,11 @@ sfBool sfWindow_isOpen(const sfWindow* window) //////////////////////////////////////////////////////////// sfContextSettings sfWindow_getSettings(const sfWindow* window) { - sfContextSettings settings = {0, 0, 0, 0, 0}; + sfContextSettings settings = priv::sfContextSettings_null(); CSFML_CHECK_RETURN(window, settings); const sf::ContextSettings& params = window->This.getSettings(); - settings.depthBits = params.depthBits; - settings.stencilBits = params.stencilBits; - settings.antialiasingLevel = params.antialiasingLevel; - settings.majorVersion = params.majorVersion; - settings.minorVersion = params.minorVersion; - settings.attributeFlags = params.attributeFlags; + priv::sfContextSettings_readFromCpp(params, settings); return settings; } @@ -263,6 +244,13 @@ void sfWindow_setMouseCursorVisible(sfWindow* window, sfBool visible) //////////////////////////////////////////////////////////// +void sfWindow_setMouseCursorGrabbed(sfWindow* window, sfBool grabbed) +{ + CSFML_CALL(window, setMouseCursorGrabbed(grabbed == sfTrue)); +} + + +//////////////////////////////////////////////////////////// void sfWindow_setVerticalSyncEnabled(sfWindow* window, sfBool enabled) { CSFML_CALL(window, setVerticalSyncEnabled(enabled == sfTrue)); -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/libcsfml.git _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

