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 @@ -208,6 +208,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 /// @@ -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 @@ -237,6 +252,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 /// @@ -282,24 +315,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 /// @@ -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. +/// sfRenderTexture class. /// -/// \param renderWindow Render window object -/// -/// \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/Window/Window.h b/include/SFML/Window/Window.h index 8ccdb0c..0c60a05 100644 --- a/include/SFML/Window/Window.h +++ b/include/SFML/Window/Window.h @@ -315,15 +315,6 @@ CSFML_WINDOW_API void sfWindow_setIcon(sfWindow* window, unsigned int width, uns //////////////////////////////////////////////////////////// CSFML_WINDOW_API void sfWindow_setVisible(sfWindow* window, sfBool visible); -//////////////////////////////////////////////////////////// -/// \brief Show or hide the mouse cursor -/// -/// \param window Window object -/// \param visible sfTrue to show, sfFalse to hide -/// -//////////////////////////////////////////////////////////// -CSFML_WINDOW_API void sfWindow_setMouseCursorVisible(sfWindow* window, sfBool visible); - //////////////////////////////////////////////////////////// /// \brief Enable or disable vertical synchronization /// @@ -338,6 +329,30 @@ CSFML_WINDOW_API void sfWindow_setMouseCursorVisible(sfWindow* window, sfBool vi //////////////////////////////////////////////////////////// CSFML_WINDOW_API void sfWindow_setVerticalSyncEnabled(sfWindow* window, sfBool enabled); +//////////////////////////////////////////////////////////// +/// \brief Show or hide the mouse cursor +/// +/// \param window Window object +/// \param visible sfTrue to show, sfFalse to hide +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API void sfWindow_setMouseCursorVisible(sfWindow* window, sfBool visible); + +//////////////////////////////////////////////////////////// +/// \brief Grab or release the mouse cursor +/// +/// 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_WINDOW_API void sfWindow_setMouseCursorGrabbed(sfWindow* window, sfBool grabbed); + //////////////////////////////////////////////////////////// /// \brief Enable or disable automatic key-repeat /// @@ -353,6 +368,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 @@ -411,31 +451,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 /// diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp index 8ead1ae..d586ab4 100644 --- a/src/SFML/Graphics/RenderWindow.cpp +++ b/src/SFML/Graphics/RenderWindow.cpp @@ -272,6 +272,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) { @@ -280,9 +287,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/Window/Window.cpp b/src/SFML/Window/Window.cpp index 6507a3d..996871b 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -262,6 +262,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) {