diff --git a/include/SFML/Graphics/RenderTexture.h b/include/SFML/Graphics/RenderTexture.h index 9d8e518..9416f6b 100644 --- a/include/SFML/Graphics/RenderTexture.h +++ b/include/SFML/Graphics/RenderTexture.h @@ -35,6 +35,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////// @@ -58,24 +59,14 @@ CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_Create(unsigned int width, u CSFML_GRAPHICS_API void sfRenderTexture_Destroy(sfRenderTexture* renderTexture); //////////////////////////////////////////////////////////// -/// \brief Get the width of the rendering region of a render texture +/// \brief Get the size of the rendering region of a render texture /// /// \param renderTexture Render texture object /// -/// \return Width in pixels +/// \return Size in pixels /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API unsigned int sfRenderTexture_GetWidth(const sfRenderTexture* renderTexture); - -//////////////////////////////////////////////////////////// -/// \brief Get the height of the rendering region of a render texture -/// -/// \param renderTexture Render texture object -/// -/// \return Height in pixels -/// -//////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API unsigned int sfRenderTexture_GetHeight(const sfRenderTexture* renderTexture); +CSFML_GRAPHICS_API sfVector2u sfRenderTexture_GetSize(const sfRenderTexture* renderTexture); //////////////////////////////////////////////////////////// /// \brief Activate or deactivate a render texture as the current target for rendering diff --git a/include/SFML/Graphics/RenderWindow.h b/include/SFML/Graphics/RenderWindow.h index 85f7e97..fd421f5 100644 --- a/include/SFML/Graphics/RenderWindow.h +++ b/include/SFML/Graphics/RenderWindow.h @@ -39,6 +39,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////// @@ -85,26 +86,6 @@ CSFML_GRAPHICS_API void sfRenderWindow_Close(sfRenderWindow* renderWindow); //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfBool sfRenderWindow_IsOpen(const sfRenderWindow* renderWindow); -//////////////////////////////////////////////////////////// -/// \brief Get the width of the rendering region of a render window -/// -/// \param renderWindow Render window object -/// -/// \return Width in pixels -/// -//////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API unsigned int sfRenderWindow_GetWidth(const sfRenderWindow* renderWindow); - -//////////////////////////////////////////////////////////// -/// \brief Get the height of the rendering region of a render window -/// -/// \param renderWindow Render window object -/// -/// \return Height in pixels -/// -//////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API unsigned int sfRenderWindow_GetHeight(const sfRenderWindow* renderWindow); - //////////////////////////////////////////////////////////// /// \brief Get the creation settings of a render window /// @@ -138,22 +119,14 @@ CSFML_GRAPHICS_API sfBool sfRenderWindow_PollEvent(sfRenderWindow* renderWindow, CSFML_GRAPHICS_API sfBool sfRenderWindow_WaitEvent(sfRenderWindow* renderWindow, sfEvent* event); //////////////////////////////////////////////////////////// -/// \brief Enable / disable vertical synchronization on a render window +/// \brief Get the position of a render window /// /// \param renderWindow Render window object -/// \param enabled sfTrue to enable v-sync, sfFalse to deactivate +/// +/// \return Position in pixels /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfRenderWindow_EnableVerticalSync(sfRenderWindow* renderWindow, sfBool enabled); - -//////////////////////////////////////////////////////////// -/// \brief Show or hide the mouse cursor on a render window -/// -/// \param renderWindow Render window object -/// \param show sfTrue to show, sfFalse to hide -/// -//////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show); +CSFML_GRAPHICS_API sfVector2i sfRenderWindow_GetPosition(const sfRenderWindow* renderWindow); //////////////////////////////////////////////////////////// /// \brief Change the position of a render window on screen @@ -161,21 +134,29 @@ CSFML_GRAPHICS_API void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWin /// Only works for top-level windows /// /// \param renderWindow Render window object -/// \param left Left position -/// \param top Top position +/// \param position New position, in pixels /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, int left, int top); +CSFML_GRAPHICS_API void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, sfVector2i position); + +//////////////////////////////////////////////////////////// +/// \brief Get the size of the rendering region of a render window +/// +/// \param renderWindow Render window object +/// +/// \return Size in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfVector2u sfRenderWindow_GetSize(const sfRenderWindow* renderWindow); //////////////////////////////////////////////////////////// /// \brief Change the size of the rendering region of a render window /// /// \param renderWindow Render window object -/// \param width New Width -/// \param height New Height +/// \param size New size, in pixels /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, unsigned int width, unsigned int height); +CSFML_GRAPHICS_API void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, sfVector2u size); //////////////////////////////////////////////////////////// /// \brief Change the title of a render window @@ -186,14 +167,43 @@ CSFML_GRAPHICS_API void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, uns //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API void sfRenderWindow_SetTitle(sfRenderWindow* renderWindow, const char* title); +//////////////////////////////////////////////////////////// +/// \brief Change a render window's icon +/// +/// \param renderWindow Renderw indow object +/// \param width Icon's width, in pixels +/// \param height Icon's height, in pixels +/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels); + //////////////////////////////////////////////////////////// /// \brief Show or hide a render window /// /// \param renderWindow Render window object +/// \param visible sfTrue to show the window, sfFalse to hide it +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API void sfRenderWindow_SetVisible(sfRenderWindow* renderWindow, sfBool visible); + +//////////////////////////////////////////////////////////// +/// \brief Show or hide the mouse cursor on a render window +/// +/// \param renderWindow Render window object /// \param show sfTrue to show, sfFalse to hide /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfRenderWindow_Show(sfRenderWindow* renderWindow, sfBool show); +CSFML_GRAPHICS_API void sfRenderWindow_SetMouseCursorVisible(sfRenderWindow* renderWindow, sfBool show); + +//////////////////////////////////////////////////////////// +/// \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 Enable or disable automatic key-repeat for keydown events @@ -204,18 +214,7 @@ CSFML_GRAPHICS_API void sfRenderWindow_Show(sfRenderWindow* renderWindow, sfBool /// \param enabled sfTrue to enable, sfFalse to disable /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfRenderWindow_EnableKeyRepeat(sfRenderWindow* renderWindow, sfBool enabled); - -//////////////////////////////////////////////////////////// -/// \brief Change a render window's icon -/// -/// \param renderWindow Renderw indow object -/// \param width Icon's width, in pixels -/// \param height Icon's height, in pixels -/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits -/// -//////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels); +CSFML_GRAPHICS_API void sfRenderWindow_SetKeyRepeatEnabled(sfRenderWindow* renderWindow, sfBool enabled); //////////////////////////////////////////////////////////// /// \brief Activate or deactivate a render window as the current target for rendering diff --git a/include/SFML/System.h b/include/SFML/System.h index f57718e..7a155a4 100644 --- a/include/SFML/System.h +++ b/include/SFML/System.h @@ -35,6 +35,8 @@ #include #include #include +#include +#include #endif // SFML_SYSTEM_H diff --git a/include/SFML/System/Vector2.h b/include/SFML/System/Vector2.h new file mode 100644 index 0000000..bc30d06 --- /dev/null +++ b/include/SFML/System/Vector2.h @@ -0,0 +1,67 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// 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_VECTOR2_H +#define SFML_VECTOR2_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// \brief 2-component vector of integers +/// +//////////////////////////////////////////////////////////// +typedef struct +{ + int x; + int y; +} sfVector2i; + + +//////////////////////////////////////////////////////////// +/// \brief 2-component vector of unsigned integers +/// +//////////////////////////////////////////////////////////// +typedef struct +{ + unsigned int x; + unsigned int y; +} sfVector2u; + + +//////////////////////////////////////////////////////////// +/// \brief 2-component vector of floats +/// +//////////////////////////////////////////////////////////// +typedef struct +{ + float x; + float y; +} sfVector2f; + + +#endif // SFML_VECTOR2_H diff --git a/include/SFML/System/Vector3.h b/include/SFML/System/Vector3.h new file mode 100644 index 0000000..599cdad --- /dev/null +++ b/include/SFML/System/Vector3.h @@ -0,0 +1,46 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// 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_VECTOR3_H +#define SFML_VECTOR3_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +//////////////////////////////////////////////////////////// +/// \brief 3-component vector of floats +/// +//////////////////////////////////////////////////////////// +typedef struct +{ + float x; + float y; + float z; +} sfVector3f; + + +#endif // SFML_VECTOR3_H diff --git a/include/SFML/Window/Window.h b/include/SFML/Window/Window.h index 8f3dc5b..286e17d 100644 --- a/include/SFML/Window/Window.h +++ b/include/SFML/Window/Window.h @@ -33,6 +33,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////// @@ -141,32 +142,6 @@ CSFML_WINDOW_API void sfWindow_Close(sfWindow* window); //////////////////////////////////////////////////////////// CSFML_WINDOW_API sfBool sfWindow_IsOpen(const sfWindow* window); -//////////////////////////////////////////////////////////// -/// \brief Get the width of the rendering region of a window -/// -/// The width doesn't include the titlebar and borders -/// of the window. -/// -/// \param window Window object -/// -/// \return Width in pixels -/// -//////////////////////////////////////////////////////////// -CSFML_WINDOW_API unsigned int sfWindow_GetWidth(const sfWindow* window); - -//////////////////////////////////////////////////////////// -/// \brief Get the height of the rendering region of a window -/// -/// The height doesn't include the titlebar and borders -/// of the window. -/// -/// \param window Window object -/// -/// \return Height in pixels -/// -//////////////////////////////////////////////////////////// -CSFML_WINDOW_API unsigned int sfWindow_GetHeight(const sfWindow* window); - //////////////////////////////////////////////////////////// /// \brief Get the settings of the OpenGL context of a window /// @@ -219,27 +194,14 @@ CSFML_WINDOW_API sfBool sfWindow_PollEvent(sfWindow* window, sfEvent* event); CSFML_WINDOW_API sfBool sfWindow_WaitEvent(sfWindow* window, sfEvent* event); //////////////////////////////////////////////////////////// -/// \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_EnableVerticalSync(sfWindow* window, sfBool enabled); - -//////////////////////////////////////////////////////////// -/// \brief Show or hide the mouse cursor +/// \brief Get the position of a window /// /// \param window Window object -/// \param show sfTrue to show, sfFalse to hide +/// +/// \return Position in pixels /// //////////////////////////////////////////////////////////// -CSFML_WINDOW_API void sfWindow_ShowMouseCursor(sfWindow* window, sfBool show); +CSFML_WINDOW_API sfVector2i sfWindow_GetPosition(const sfWindow* window); //////////////////////////////////////////////////////////// /// \brief Change the position of a window on screen @@ -248,22 +210,33 @@ CSFML_WINDOW_API void sfWindow_ShowMouseCursor(sfWindow* window, sfBool show); /// (i.e. it will be ignored for windows created from /// the handle of a child window/control). /// -/// \param window Window object -/// \param x Left position -/// \param y Top position +/// \param window Window object +/// \param position New position of the window, in pixels /// //////////////////////////////////////////////////////////// -CSFML_WINDOW_API void sfWindow_SetPosition(sfWindow* window, int left, int top); +CSFML_WINDOW_API void sfWindow_SetPosition(sfWindow* window, sfVector2i position); + +//////////////////////////////////////////////////////////// +/// \brief Get the size of the rendering region of a window +/// +/// The size doesn't include the titlebar and borders +/// of the window. +/// +/// \param window Window object +/// +/// \return Size in pixels +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API sfVector2u sfWindow_GetSize(const sfWindow* window); //////////////////////////////////////////////////////////// /// \brief Change the size of the rendering region of a window /// /// \param window Window object -/// \param width New width, in pixels -/// \param height New height, in pixels +/// \param size New size, in pixels /// //////////////////////////////////////////////////////////// -CSFML_WINDOW_API void sfWindow_SetSize(sfWindow* window, unsigned int width, unsigned int height); +CSFML_WINDOW_API void sfWindow_SetSize(sfWindow* window, sfVector2u size); //////////////////////////////////////////////////////////// /// \brief Change the title of a window @@ -274,30 +247,6 @@ CSFML_WINDOW_API void sfWindow_SetSize(sfWindow* window, unsigned int width, uns //////////////////////////////////////////////////////////// CSFML_WINDOW_API void sfWindow_SetTitle(sfWindow* window, const char* title); -//////////////////////////////////////////////////////////// -/// \brief Show or hide a window -/// -/// \param window Window object -/// \param show sfTrue to show, sfFalse to hide -/// -//////////////////////////////////////////////////////////// -CSFML_WINDOW_API void sfWindow_Show(sfWindow* window, sfBool show); - -//////////////////////////////////////////////////////////// -/// \brief Enable or disable automatic key-repeat -/// -/// If key repeat is enabled, you will receive repeated -/// KeyPress events while keeping a key pressed. If it is disabled, -/// you will only get a single event when the key is pressed. -/// -/// Key repeat is enabled by default. -/// -/// \param window Window object -/// \param enabled sfTrue to enable, sfFalse to disable -/// -//////////////////////////////////////////////////////////// -CSFML_WINDOW_API void sfWindow_EnableKeyRepeat(sfWindow* window, sfBool enabled); - //////////////////////////////////////////////////////////// /// \brief Change a window's icon /// @@ -312,6 +261,53 @@ CSFML_WINDOW_API void sfWindow_EnableKeyRepeat(sfWindow* window, sfBool enabled) //////////////////////////////////////////////////////////// CSFML_WINDOW_API void sfWindow_SetIcon(sfWindow* window, unsigned int width, unsigned int height, const sfUint8* pixels); +//////////////////////////////////////////////////////////// +/// \brief Show or hide a window +/// +/// \param window Window object +/// \param visible sfTrue to show the window, sfFalse to hide it +/// +//////////////////////////////////////////////////////////// +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 +/// +/// 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 Enable or disable automatic key-repeat +/// +/// If key repeat is enabled, you will receive repeated +/// KeyPress events while keeping a key pressed. If it is disabled, +/// you will only get a single event when the key is pressed. +/// +/// Key repeat is enabled by default. +/// +/// \param window Window object +/// \param enabled sfTrue to enable, sfFalse to disable +/// +//////////////////////////////////////////////////////////// +CSFML_WINDOW_API void sfWindow_SetKeyRepeatEnabled(sfWindow* window, sfBool enabled); + //////////////////////////////////////////////////////////// /// \brief Activate or deactivate a window as the current target /// for OpenGL rendering diff --git a/src/SFML/Graphics/RenderTexture.cpp b/src/SFML/Graphics/RenderTexture.cpp index c0ab3bf..1400a26 100644 --- a/src/SFML/Graphics/RenderTexture.cpp +++ b/src/SFML/Graphics/RenderTexture.cpp @@ -60,16 +60,16 @@ void sfRenderTexture_Destroy(sfRenderTexture* renderTexture) //////////////////////////////////////////////////////////// -unsigned int sfRenderTexture_GetWidth(const sfRenderTexture* renderTexture) +sfVector2u sfRenderTexture_GetSize(const sfRenderTexture* renderTexture) { - CSFML_CALL_RETURN(renderTexture, GetWidth(), 0); -} + sfVector2u size = {0, 0}; + CSFML_CHECK_RETURN(renderTexture, size); + sf::Vector2u sfmlSize = renderTexture->This.GetSize(); + size.x = sfmlSize.x; + size.y = sfmlSize.y; -//////////////////////////////////////////////////////////// -unsigned int sfRenderTexture_GetHeight(const sfRenderTexture* renderTexture) -{ - CSFML_CALL_RETURN(renderTexture, GetHeight(), 0); + return size; } diff --git a/src/SFML/Graphics/RenderWindow.cpp b/src/SFML/Graphics/RenderWindow.cpp index 94b853d..32677df 100644 --- a/src/SFML/Graphics/RenderWindow.cpp +++ b/src/SFML/Graphics/RenderWindow.cpp @@ -112,20 +112,6 @@ sfBool sfRenderWindow_IsOpen(const sfRenderWindow* renderWindow) } -//////////////////////////////////////////////////////////// -unsigned int sfRenderWindow_GetWidth(const sfRenderWindow* renderWindow) -{ - CSFML_CALL_RETURN(renderWindow, GetWidth(), 0); -} - - -//////////////////////////////////////////////////////////// -unsigned int sfRenderWindow_GetHeight(const sfRenderWindow* renderWindow) -{ - CSFML_CALL_RETURN(renderWindow, GetHeight(), 0); -} - - //////////////////////////////////////////////////////////// sfContextSettings sfRenderWindow_GetSettings(const sfRenderWindow* renderWindow) { @@ -184,30 +170,44 @@ sfBool sfRenderWindow_WaitEvent(sfRenderWindow* renderWindow, sfEvent* event) //////////////////////////////////////////////////////////// -void sfRenderWindow_EnableVerticalSync(sfRenderWindow* renderWindow, sfBool enabled) +sfVector2i sfRenderWindow_GetPosition(const sfRenderWindow* renderWindow) { - CSFML_CALL(renderWindow, EnableVerticalSync(enabled == sfTrue)); + sfVector2i position = {0, 0}; + CSFML_CHECK_RETURN(renderWindow, position); + + sf::Vector2i sfmlPos = renderWindow->This.GetPosition(); + position.x = sfmlPos.x; + position.y = sfmlPos.y; + + return position; } //////////////////////////////////////////////////////////// -void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show) +void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, sfVector2i position) { - CSFML_CALL(renderWindow, ShowMouseCursor(show == sfTrue)); + CSFML_CALL(renderWindow, SetPosition(sf::Vector2i(position.x, position.y))); } //////////////////////////////////////////////////////////// -void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, int left, int top) +sfVector2u sfRenderWindow_GetSize(const sfRenderWindow* renderWindow) { - CSFML_CALL(renderWindow, SetPosition(left, top)); + sfVector2u size = {0, 0}; + CSFML_CHECK_RETURN(renderWindow, size); + + sf::Vector2u sfmlSize = renderWindow->This.GetSize(); + size.x = sfmlSize.x; + size.y = sfmlSize.y; + + return size; } //////////////////////////////////////////////////////////// -void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, unsigned int width, unsigned int height) +void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, sfVector2u size) { - CSFML_CALL(renderWindow, SetSize(width, height)); + CSFML_CALL(renderWindow, SetSize(sf::Vector2u(size.x, size.y))); } @@ -218,20 +218,6 @@ void sfRenderWindow_SetTitle(sfRenderWindow* renderWindow, const char* title) } -//////////////////////////////////////////////////////////// -void sfRenderWindow_Show(sfRenderWindow* renderWindow, sfBool show) -{ - CSFML_CALL(renderWindow, Show(show == sfTrue)); -} - - -//////////////////////////////////////////////////////////// -void sfRenderWindow_EnableKeyRepeat(sfRenderWindow* renderWindow, sfBool enabled) -{ - CSFML_CALL(renderWindow, EnableKeyRepeat(enabled == sfTrue)); -} - - //////////////////////////////////////////////////////////// void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels) { @@ -239,6 +225,34 @@ void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, un } +//////////////////////////////////////////////////////////// +void sfRenderWindow_SetVisible(sfRenderWindow* renderWindow, sfBool visible) +{ + CSFML_CALL(renderWindow, SetVisible(visible == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +void sfRenderWindow_SetMouseCursorVisible(sfRenderWindow* renderWindow, sfBool visible) +{ + CSFML_CALL(renderWindow, SetMouseCursorVisible(visible == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +void sfRenderWindow_SetVerticalSyncEnabled(sfRenderWindow* renderWindow, sfBool enabled) +{ + CSFML_CALL(renderWindow, SetVerticalSyncEnabled(enabled == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +void sfRenderWindow_SetKeyRepeatEnabled(sfRenderWindow* renderWindow, sfBool enabled) +{ + CSFML_CALL(renderWindow, SetKeyRepeatEnabled(enabled == sfTrue)); +} + + //////////////////////////////////////////////////////////// sfBool sfRenderWindow_SetActive(sfRenderWindow* renderWindow, sfBool active) { diff --git a/src/SFML/System/CMakeLists.txt b/src/SFML/System/CMakeLists.txt index 6b5a11c..4500d22 100644 --- a/src/SFML/System/CMakeLists.txt +++ b/src/SFML/System/CMakeLists.txt @@ -20,6 +20,8 @@ set(SRC ${SRCROOT}/Time.cpp ${INCROOT}/Time.h ${INCROOT}/Types.h + ${INCROOT}/Vector2.h + ${INCROOT}/Vector3.h ) # define the csfml-system target diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 0925fc3..6565a91 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -98,20 +98,6 @@ sfBool sfWindow_IsOpen(const sfWindow* window) } -//////////////////////////////////////////////////////////// -unsigned int sfWindow_GetWidth(const sfWindow* window) -{ - CSFML_CALL_RETURN(window, GetWidth(), 0); -} - - -//////////////////////////////////////////////////////////// -unsigned int sfWindow_GetHeight(const sfWindow* window) -{ - CSFML_CALL_RETURN(window, GetHeight(), 0); -} - - //////////////////////////////////////////////////////////// sfContextSettings sfWindow_GetSettings(const sfWindow* window) { @@ -172,30 +158,44 @@ sfBool sfWindow_WaitEvent(sfWindow* window, sfEvent* event) //////////////////////////////////////////////////////////// -void sfWindow_EnableVerticalSync(sfWindow* window, sfBool enabled) +sfVector2i sfWindow_GetPosition(const sfWindow* window) { - CSFML_CALL(window, EnableVerticalSync(enabled == sfTrue)); + sfVector2i position = {0, 0}; + CSFML_CHECK_RETURN(window, position); + + sf::Vector2i sfmlPos = window->This.GetPosition(); + position.x = sfmlPos.x; + position.y = sfmlPos.y; + + return position; } //////////////////////////////////////////////////////////// -void sfWindow_ShowMouseCursor(sfWindow* window, sfBool show) +void sfWindow_SetPosition(sfWindow* window, sfVector2i position) { - CSFML_CALL(window, ShowMouseCursor(show == sfTrue)); + CSFML_CALL(window, SetPosition(sf::Vector2i(position.x, position.y))); } //////////////////////////////////////////////////////////// -void sfWindow_SetPosition(sfWindow* window, int left, int top) +sfVector2u sfWindow_GetSize(const sfWindow* window) { - CSFML_CALL(window, SetPosition(left, top)); + sfVector2u size = {0, 0}; + CSFML_CHECK_RETURN(window, size); + + sf::Vector2u sfmlSize = window->This.GetSize(); + size.x = sfmlSize.x; + size.y = sfmlSize.y; + + return size; } //////////////////////////////////////////////////////////// -void sfWindow_SetSize(sfWindow* window, unsigned int width, unsigned int height) +void sfWindow_SetSize(sfWindow* window, sfVector2u size) { - CSFML_CALL(window, SetSize(width, height)); + CSFML_CALL(window, SetSize(sf::Vector2u(size.x, size.y))); } @@ -206,20 +206,6 @@ void sfWindow_SetTitle(sfWindow* window, const char* title) } -//////////////////////////////////////////////////////////// -void sfWindow_Show(sfWindow* window, sfBool show) -{ - CSFML_CALL(window, Show(show == sfTrue)); -} - - -//////////////////////////////////////////////////////////// -void sfWindow_EnableKeyRepeat(sfWindow* window, sfBool enabled) -{ - CSFML_CALL(window, EnableKeyRepeat(enabled == sfTrue)); -} - - //////////////////////////////////////////////////////////// void sfWindow_SetIcon(sfWindow* window, unsigned int width, unsigned int height, const sfUint8* pixels) { @@ -227,6 +213,34 @@ void sfWindow_SetIcon(sfWindow* window, unsigned int width, unsigned int height, } +//////////////////////////////////////////////////////////// +void sfWindow_SetVisible(sfWindow* window, sfBool visible) +{ + CSFML_CALL(window, SetVisible(visible == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +void sfWindow_SetMouseCursorVisible(sfWindow* window, sfBool visible) +{ + CSFML_CALL(window, SetMouseCursorVisible(visible == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +void sfWindow_SetVerticalSyncEnabled(sfWindow* window, sfBool enabled) +{ + CSFML_CALL(window, SetVerticalSyncEnabled(enabled == sfTrue)); +} + + +//////////////////////////////////////////////////////////// +void sfWindow_SetKeyRepeatEnabled(sfWindow* window, sfBool enabled) +{ + CSFML_CALL(window, SetKeyRepeatEnabled(enabled == sfTrue)); +} + + //////////////////////////////////////////////////////////// sfBool sfWindow_SetActive(sfWindow* window, sfBool active) {