Use vectors for pairs of scalar parameters

This commit is contained in:
Chris Thrasher committed 2024-08-31 12:03:21 -06:00
1 parent 10685c7d0d
commit 86d52f4712
20 files changed
+101 -123

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@
/// ///
/// int main() /// int main()
/// { /// {
/// sfVideoMode mode = {800, 600, 32}; /// sfVideoMode mode = {{800, 600}, 32};
/// sfRenderWindow* window; /// sfRenderWindow* window;
/// sfTexture* texture; /// sfTexture* texture;
/// sfSprite* sprite; /// sfSprite* sprite;
+1 -1
View File
@@ -6,7 +6,7 @@
int main(void) int main(void)
{ {
// Create the main window // Create the main window
const sfVideoMode mode = {800, 600, 32}; const sfVideoMode mode = {{800, 600}, 32};
sfRenderWindow* window = sfRenderWindow_create(mode, "SFML window", sfResize | sfClose, sfWindowed, NULL); sfRenderWindow* window = sfRenderWindow_create(mode, "SFML window", sfResize | sfClose, sfWindowed, NULL);
if (!window) if (!window)
return EXIT_FAILURE; return EXIT_FAILURE;
+16 -22
View File
@@ -42,25 +42,23 @@
/// ///
/// This image is filled with black pixels. /// This image is filled with black pixels.
/// ///
/// \param width Width of the image /// \param size Size of the image
/// \param height Height of the image
/// ///
/// \return A new sfImage object /// \return A new sfImage object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfImage* sfImage_create(unsigned int width, unsigned int height); CSFML_GRAPHICS_API sfImage* sfImage_create(sfVector2u size);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create an image and fill it with a unique color /// \brief Create an image and fill it with a unique color
/// ///
/// \param width Width of the image /// \param size Size of the image
/// \param height Height of the image /// \param color Fill color
/// \param color Fill color
/// ///
/// \return A new sfImage object /// \return A new sfImage object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfImage* sfImage_createFromColor(unsigned int width, unsigned int height, sfColor color); CSFML_GRAPHICS_API sfImage* sfImage_createFromColor(sfVector2u size, sfColor color);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create an image from an array of pixels /// \brief Create an image from an array of pixels
@@ -70,14 +68,13 @@ CSFML_GRAPHICS_API sfImage* sfImage_createFromColor(unsigned int width, unsigned
/// an undefined behaviour. /// an undefined behaviour.
/// If \a pixels is null, an empty image is created. /// If \a pixels is null, an empty image is created.
/// ///
/// \param width Width of the image /// \param size Size of the image
/// \param height Height of the image
/// \param pixels Array of pixels to copy to the image /// \param pixels Array of pixels to copy to the image
/// ///
/// \return A new sfImage object /// \return A new sfImage object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfImage* sfImage_createFromPixels(unsigned int width, unsigned int height, const uint8_t* pixels); CSFML_GRAPHICS_API sfImage* sfImage_createFromPixels(sfVector2u size, const uint8_t* pixels);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create an image from a file on disk /// \brief Create an image from a file on disk
@@ -219,15 +216,14 @@ CSFML_GRAPHICS_API void sfImage_createMaskFromColor(sfImage* image, sfColor colo
/// ///
/// \param image Image object /// \param image Image object
/// \param source Source image to copy /// \param source Source image to copy
/// \param destX X coordinate of the destination position /// \param dest Coordinates of the destination position
/// \param destY Y coordinate of the destination position
/// \param sourceRect Sub-rectangle of the source image to copy /// \param sourceRect Sub-rectangle of the source image to copy
/// \param applyAlpha Should the copy take in account the source transparency? /// \param applyAlpha Should the copy take in account the source transparency?
/// ///
/// \return True if the operation was successful, false otherwise /// \return True if the operation was successful, false otherwise
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API bool sfImage_copyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect, bool applyAlpha); CSFML_GRAPHICS_API bool sfImage_copyImage(sfImage* image, const sfImage* source, sfVector2u dest, sfIntRect sourceRect, bool applyAlpha);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change the color of a pixel in an image /// \brief Change the color of a pixel in an image
@@ -236,13 +232,12 @@ CSFML_GRAPHICS_API bool sfImage_copyImage(sfImage* image, const sfImage* source,
/// coordinates, using out-of-range values will result in /// coordinates, using out-of-range values will result in
/// an undefined behaviour. /// an undefined behaviour.
/// ///
/// \param image Image object /// \param image Image object
/// \param x X coordinate of pixel to change /// \param coords Coordinates of pixel to change
/// \param y Y coordinate of pixel to change /// \param color New color of the pixel
/// \param color New color of the pixel
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfImage_setPixel(sfImage* image, unsigned int x, unsigned int y, sfColor color); CSFML_GRAPHICS_API void sfImage_setPixel(sfImage* image, sfVector2u coords, sfColor color);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the color of a pixel in an image /// \brief Get the color of a pixel in an image
@@ -251,14 +246,13 @@ CSFML_GRAPHICS_API void sfImage_setPixel(sfImage* image, unsigned int x, unsigne
/// coordinates, using out-of-range values will result in /// coordinates, using out-of-range values will result in
/// an undefined behaviour. /// an undefined behaviour.
/// ///
/// \param image Image object /// \param image Image object
/// \param x X coordinate of pixel to get /// \param coords Coordinates of pixel to get
/// \param y Y coordinate of pixel to get
/// ///
/// \return Color of the pixel at coordinates (x, y) /// \return Color of the pixel at coordinates (x, y)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfColor sfImage_getPixel(const sfImage* image, unsigned int x, unsigned int y); CSFML_GRAPHICS_API sfColor sfImage_getPixel(const sfImage* image, sfVector2u coords);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get a read-only pointer to the array of pixels of an image /// \brief Get a read-only pointer to the array of pixels of an image
+4 -5
View File
@@ -51,15 +51,14 @@ typedef struct
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Check if a point is inside a rectangle's area /// \brief Check if a point is inside a rectangle's area
/// ///
/// \param rect Rectangle to test /// \param rect Rectangle to test
/// \param x X coordinate of the point to test /// \param point Coordinates of the point to test
/// \param y Y coordinate of the point to test
/// ///
/// \return true if the point is inside /// \return true if the point is inside
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API bool sfFloatRect_contains(const sfFloatRect* rect, float x, float y); CSFML_GRAPHICS_API bool sfFloatRect_contains(const sfFloatRect* rect, sfVector2f point);
CSFML_GRAPHICS_API bool sfIntRect_contains(const sfIntRect* rect, int x, int y); CSFML_GRAPHICS_API bool sfIntRect_contains(const sfIntRect* rect, sfVector2i point);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Check intersection between two rectangles /// \brief Check intersection between two rectangles
+2 -3
View File
@@ -42,14 +42,13 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Construct a new render texture /// \brief Construct a new render texture
/// ///
/// \param width Width of the render texture /// \param size Size of the render texture
/// \param height Height of the render texture
/// \param settings Settings of the render texture /// \param settings Settings of the render texture
/// ///
/// \return A new sfRenderTexture object, or NULL if it failed /// \return A new sfRenderTexture object, or NULL if it failed
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_create(unsigned int width, unsigned int height, const sfContextSettings* settings); CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_create(sfVector2u size, const sfContextSettings* settings);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Destroy an existing render texture /// \brief Destroy an existing render texture
+2 -3
View File
@@ -201,12 +201,11 @@ CSFML_GRAPHICS_API void sfRenderWindow_setUnicodeTitle(sfRenderWindow* renderWin
/// \brief Change a render window's icon /// \brief Change a render window's icon
/// ///
/// \param renderWindow Render window object /// \param renderWindow Render window object
/// \param width Icon's width, in pixels /// \param size Icon's size, in pixels
/// \param height Icon's height, in pixels
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits /// \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 uint8_t* pixels); CSFML_GRAPHICS_API void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, sfVector2u size, const uint8_t* pixels);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Show or hide a render window /// \brief Show or hide a render window
+13 -20
View File
@@ -48,13 +48,12 @@ typedef enum
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create a new texture /// \brief Create a new texture
/// ///
/// \param width Texture width /// \param size Texture size
/// \param height Texture height
/// ///
/// \return A new sfTexture object, or NULL if it failed /// \return A new sfTexture object, or NULL if it failed
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTexture* sfTexture_create(unsigned int width, unsigned int height); CSFML_GRAPHICS_API sfTexture* sfTexture_create(sfVector2u size);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create a new texture from a file /// \brief Create a new texture from a file
@@ -201,13 +200,11 @@ CSFML_GRAPHICS_API sfImage* sfTexture_copyToImage(const sfTexture* texture);
/// ///
/// \param texture Texture to update /// \param texture Texture to update
/// \param pixels Array of pixels to copy to the texture /// \param pixels Array of pixels to copy to the texture
/// \param width Width of the pixel region contained in \a pixels /// \param size size of the pixel region contained in \a pixels
/// \param height Height of the pixel region contained in \a pixels /// \param offset Offset in the texture where to copy the source pixels
/// \param x X offset in the texture where to copy the source pixels
/// \param y Y offset in the texture where to copy the source pixels
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromPixels(sfTexture* texture, const uint8_t* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y); CSFML_GRAPHICS_API void sfTexture_updateFromPixels(sfTexture* texture, const uint8_t* pixels, sfVector2u size, sfVector2u offset);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Update a part of this texture from another texture /// \brief Update a part of this texture from another texture
@@ -221,44 +218,40 @@ CSFML_GRAPHICS_API void sfTexture_updateFromPixels(sfTexture* texture, const uin
/// ///
/// \param destination Destination texture to copy source texture to /// \param destination Destination texture to copy source texture to
/// \param source Source texture to copy to destination texture /// \param source Source texture to copy to destination texture
/// \param x X offset in this texture where to copy the source texture /// \param offset Offset in this texture where to copy the source texture
/// \param y Y offset in this texture where to copy the source texture
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromTexture(sfTexture* destination, const sfTexture* source, unsigned int x, unsigned int y); CSFML_GRAPHICS_API void sfTexture_updateFromTexture(sfTexture* destination, const sfTexture* source, sfVector2u offset);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Update a texture from an image /// \brief Update a texture from an image
/// ///
/// \param texture Texture to update /// \param texture Texture to update
/// \param image Image to copy to the texture /// \param image Image to copy to the texture
/// \param x X offset in the texture where to copy the source pixels /// \param offset Offset in the texture where to copy the source pixels
/// \param y Y offset in the texture where to copy the source pixels
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, unsigned int x, unsigned int y); CSFML_GRAPHICS_API void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, sfVector2u offset);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Update a texture from the contents of a window /// \brief Update a texture from the contents of a window
/// ///
/// \param texture Texture to update /// \param texture Texture to update
/// \param window Window to copy to the texture /// \param window Window to copy to the texture
/// \param x X offset in the texture where to copy the source pixels /// \param offset Offset in the texture where to copy the source pixels
/// \param y Y offset in the texture where to copy the source pixels
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromWindow(sfTexture* texture, const sfWindow* window, unsigned int x, unsigned int y); CSFML_GRAPHICS_API void sfTexture_updateFromWindow(sfTexture* texture, const sfWindow* window, sfVector2u offset);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Update a texture from the contents of a render-window /// \brief Update a texture from the contents of a render-window
/// ///
/// \param texture Texture to update /// \param texture Texture to update
/// \param renderWindow Render-window to copy to the texture /// \param renderWindow Render-window to copy to the texture
/// \param x X offset in the texture where to copy the source pixels /// \param offset Offset in the texture where to copy the source pixels
/// \param y Y offset in the texture where to copy the source pixels
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_updateFromRenderWindow(sfTexture* texture, const sfRenderWindow* renderWindow, unsigned int x, unsigned int y); CSFML_GRAPHICS_API void sfTexture_updateFromRenderWindow(sfTexture* texture, const sfRenderWindow* renderWindow, sfVector2u offset);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Enable or disable the smooth filter on a texture /// \brief Enable or disable the smooth filter on a texture
+9 -14
View File
@@ -147,11 +147,10 @@ CSFML_GRAPHICS_API void sfTransform_combine(sfTransform* transform, const sfTran
/// \brief Combine a transform with a translation /// \brief Combine a transform with a translation
/// ///
/// \param transform Transform object /// \param transform Transform object
/// \param x Offset to apply on X axis /// \param offset Offset to apply
/// \param y Offset to apply on Y axis
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_translate(sfTransform* transform, float x, float y); CSFML_GRAPHICS_API void sfTransform_translate(sfTransform* transform, sfVector2f offset);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a rotation /// \brief Combine the current transform with a rotation
@@ -172,21 +171,19 @@ CSFML_GRAPHICS_API void sfTransform_rotate(sfTransform* transform, float angle);
/// ///
/// \param transform Transform object /// \param transform Transform object
/// \param angle Rotation angle, in degrees /// \param angle Rotation angle, in degrees
/// \param centerX X coordinate of the center of rotation /// \param center Coordinates of the center of rotation
/// \param centerY Y coordinate of the center of rotation
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_rotateWithCenter(sfTransform* transform, float angle, float centerX, float centerY); CSFML_GRAPHICS_API void sfTransform_rotateWithCenter(sfTransform* transform, float angle, sfVector2f center);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a scaling /// \brief Combine the current transform with a scaling
/// ///
/// \param transform Transform object /// \param transform Transform object
/// \param scaleX Scaling factor on the X axis /// \param scale Scaling factor
/// \param scaleY Scaling factor on the Y axis
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_scale(sfTransform* transform, float scaleX, float scaleY); CSFML_GRAPHICS_API void sfTransform_scale(sfTransform* transform, sfVector2f scale);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a scaling /// \brief Combine the current transform with a scaling
@@ -197,13 +194,11 @@ CSFML_GRAPHICS_API void sfTransform_scale(sfTransform* transform, float scaleX,
/// [translate(-center), scale(factors), translate(center)] /// [translate(-center), scale(factors), translate(center)]
/// ///
/// \param transform Transform object /// \param transform Transform object
/// \param scaleX Scaling factor on X axis /// \param scale Scaling factor
/// \param scaleY Scaling factor on Y axis /// \param center Coordinates of the center of scaling
/// \param centerX X coordinate of the center of scaling
/// \param centerY Y coordinate of the center of scaling
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_scaleWithCenter(sfTransform* transform, float scaleX, float scaleY, float centerX, float centerY); CSFML_GRAPHICS_API void sfTransform_scaleWithCenter(sfTransform* transform, sfVector2f scale, sfVector2f center);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Compare two transforms for equality /// \brief Compare two transforms for equality
+2 -2
View File
@@ -28,6 +28,7 @@
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <CSFML/Window/Export.h> #include <CSFML/Window/Export.h>
#include <CSFML/System/Vector2.h>
#include <stddef.h> #include <stddef.h>
@@ -39,8 +40,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
typedef struct typedef struct
{ {
unsigned int width; ///< Video mode width, in pixels sfVector2u size; ///< Video mode size, in pixels
unsigned int height; ///< Video mode height, in pixels
unsigned int bitsPerPixel; ///< Video mode pixel depth, in bits per pixels unsigned int bitsPerPixel; ///< Video mode pixel depth, in bits per pixels
} sfVideoMode; } sfVideoMode;
+2 -3
View File
@@ -287,12 +287,11 @@ CSFML_WINDOW_API void sfWindow_setUnicodeTitle(sfWindow* window, const sfChar32*
/// in 32-bits RGBA format. /// in 32-bits RGBA format.
/// ///
/// \param window Window object /// \param window Window object
/// \param width Icon's width, in pixels /// \param size Icon's size, in pixels
/// \param height Icon's height, in pixels
/// \param pixels Pointer to the array of pixels in memory /// \param pixels Pointer to the array of pixels in memory
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindow_setIcon(sfWindow* window, unsigned int width, unsigned int height, const uint8_t* pixels); CSFML_WINDOW_API void sfWindow_setIcon(sfWindow* window, sfVector2u size, const uint8_t* pixels);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Show or hide a window /// \brief Show or hide a window
+2 -3
View File
@@ -250,12 +250,11 @@ CSFML_WINDOW_API void sfWindowBase_setUnicodeTitle(sfWindowBase* windowBase, con
/// in 32-bits RGBA format. /// in 32-bits RGBA format.
/// ///
/// \param windowBase Window object /// \param windowBase Window object
/// \param width Icon's width, in pixels /// \param size Icon's size, in pixels
/// \param height Icon's height, in pixels
/// \param pixels Pointer to the array of pixels in memory /// \param pixels Pointer to the array of pixels in memory
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_WINDOW_API void sfWindowBase_setIcon(sfWindowBase* windowBase, unsigned int width, unsigned int height, const uint8_t* pixels); CSFML_WINDOW_API void sfWindowBase_setIcon(sfWindowBase* windowBase, sfVector2u size, const uint8_t* pixels);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Show or hide a window /// \brief Show or hide a window
+12 -12
View File
@@ -36,23 +36,23 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfImage* sfImage_create(unsigned int width, unsigned int height) sfImage* sfImage_create(sfVector2u size)
{ {
return new sfImage{sf::Image(sf::Vector2u(width, height))}; return new sfImage{sf::Image(convertVector2(size))};
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfImage* sfImage_createFromColor(unsigned int width, unsigned int height, sfColor color) sfImage* sfImage_createFromColor(sfVector2u size, sfColor color)
{ {
return new sfImage{sf::Image({ width, height }, convertColor(color))}; return new sfImage{sf::Image(convertVector2(size), convertColor(color))};
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfImage* sfImage_createFromPixels(unsigned int width, unsigned int height, const uint8_t* data) sfImage* sfImage_createFromPixels(sfVector2u size, const uint8_t* data)
{ {
return new sfImage{sf::Image({ width, height }, data)}; return new sfImage{sf::Image(convertVector2(size), data)};
} }
@@ -141,28 +141,28 @@ void sfImage_createMaskFromColor(sfImage* image, sfColor colorKey, uint8_t alpha
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool sfImage_copyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect, bool applyAlpha) bool sfImage_copyImage(sfImage* image, const sfImage* source, sfVector2u dest, sfIntRect sourceRect, bool applyAlpha)
{ {
CSFML_CHECK_RETURN(image, false); CSFML_CHECK_RETURN(image, false);
CSFML_CHECK_RETURN(source, false); CSFML_CHECK_RETURN(source, false);
return image->This.copy(source->This, { destX, destY }, convertRect(sourceRect), applyAlpha); return image->This.copy(source->This, convertVector2(dest), convertRect(sourceRect), applyAlpha);
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfImage_setPixel(sfImage* image, unsigned int x, unsigned int y, sfColor color) void sfImage_setPixel(sfImage* image, sfVector2u coords, sfColor color)
{ {
CSFML_CALL(image, setPixel({ x, y }, convertColor(color))); CSFML_CALL(image, setPixel(convertVector2(coords), convertColor(color)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfColor sfImage_getPixel(const sfImage* image, unsigned int x, unsigned int y) sfColor sfImage_getPixel(const sfImage* image, sfVector2u coords)
{ {
CSFML_CHECK_RETURN(image, {}); CSFML_CHECK_RETURN(image, {});
return convertColor(image->This.getPixel({ x, y })); return convertColor(image->This.getPixel(convertVector2(coords)));
} }
+5 -4
View File
@@ -28,21 +28,22 @@
#include <CSFML/Graphics/Rect.h> #include <CSFML/Graphics/Rect.h>
#include <SFML/Graphics/Rect.hpp> #include <SFML/Graphics/Rect.hpp>
#include <CSFML/Graphics/ConvertRect.hpp> #include <CSFML/Graphics/ConvertRect.hpp>
#include <CSFML/System/ConvertVector2.hpp>
#include <CSFML/Internal.hpp> #include <CSFML/Internal.hpp>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Check if a point is inside a rectangle's area /// Check if a point is inside a rectangle's area
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool sfFloatRect_contains(const sfFloatRect* rect, float x, float y) bool sfFloatRect_contains(const sfFloatRect* rect, sfVector2f point)
{ {
CSFML_CHECK_RETURN(rect, false); CSFML_CHECK_RETURN(rect, false);
return convertRect(*rect).contains({ x, y }); return convertRect(*rect).contains(convertVector2(point));
} }
bool sfIntRect_contains(const sfIntRect* rect, int x, int y) bool sfIntRect_contains(const sfIntRect* rect, sfVector2i point)
{ {
CSFML_CHECK_RETURN(rect, false); CSFML_CHECK_RETURN(rect, false);
return convertRect(*rect).contains({ x, y }); return convertRect(*rect).contains(convertVector2(point));
} }
+2 -2
View File
@@ -44,14 +44,14 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfRenderTexture* sfRenderTexture_create(unsigned int width, unsigned int height, const sfContextSettings* settings) sfRenderTexture* sfRenderTexture_create(sfVector2u size, const sfContextSettings* settings)
{ {
// Convert context settings // Convert context settings
const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings(); const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings();
// Create the render texture // Create the render texture
sf::RenderTexture renderTexture; sf::RenderTexture renderTexture;
if (!renderTexture.resize({ width, height }, params)) if (!renderTexture.resize(convertVector2(size), params))
return nullptr; return nullptr;
auto* texture = new sfTexture(const_cast<sf::Texture*>(&renderTexture.getTexture())); auto* texture = new sfTexture(const_cast<sf::Texture*>(&renderTexture.getTexture()));
+2 -2
View File
@@ -220,9 +220,9 @@ void sfRenderWindow_setUnicodeTitle(sfRenderWindow* renderWindow, const sfChar32
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const uint8_t* pixels) void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, sfVector2u size, const uint8_t* pixels)
{ {
CSFML_CALL(renderWindow, setIcon({ width, height }, pixels)); CSFML_CALL(renderWindow, setIcon(convertVector2(size), pixels));
} }
+12 -12
View File
@@ -37,11 +37,11 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfTexture* sfTexture_create(unsigned int width, unsigned int height) sfTexture* sfTexture_create(sfVector2u size)
{ {
sfTexture* texture = new sfTexture; sfTexture* texture = new sfTexture;
if (!texture->This->resize({ width, height })) if (!texture->This->resize(convertVector2(size)))
{ {
delete texture; delete texture;
texture = nullptr; texture = nullptr;
@@ -227,46 +227,46 @@ sfImage* sfTexture_copyToImage(const sfTexture* texture)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTexture_updateFromPixels(sfTexture* texture, const uint8_t* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y) void sfTexture_updateFromPixels(sfTexture* texture, const uint8_t* pixels, sfVector2u size, sfVector2u offset)
{ {
CSFML_CALL_PTR(texture, update(pixels, { width, height }, { x, y })); CSFML_CALL_PTR(texture, update(pixels, convertVector2(size), convertVector2(offset)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTexture_updateFromTexture(sfTexture* destination, const sfTexture* texture, unsigned int x, unsigned int y) void sfTexture_updateFromTexture(sfTexture* destination, const sfTexture* texture, sfVector2u offset)
{ {
CSFML_CHECK(texture); CSFML_CHECK(texture);
CSFML_CHECK(texture->This); CSFML_CHECK(texture->This);
CSFML_CALL_PTR(destination, update(*texture->This, { x, y })); CSFML_CALL_PTR(destination, update(*texture->This, convertVector2(offset)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, unsigned int x, unsigned int y) void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, sfVector2u offset)
{ {
CSFML_CHECK(image); CSFML_CHECK(image);
CSFML_CALL_PTR(texture, update(image->This, { x, y })); CSFML_CALL_PTR(texture, update(image->This, convertVector2(offset)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTexture_updateFromWindow(sfTexture* texture, const sfWindow* window, unsigned int x, unsigned int y) void sfTexture_updateFromWindow(sfTexture* texture, const sfWindow* window, sfVector2u offset)
{ {
CSFML_CHECK(window); CSFML_CHECK(window);
CSFML_CALL_PTR(texture, update(window->This, { x, y })); CSFML_CALL_PTR(texture, update(window->This, convertVector2(offset)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTexture_updateFromRenderWindow(sfTexture* texture, const sfRenderWindow* renderWindow, unsigned int x, unsigned int y) void sfTexture_updateFromRenderWindow(sfTexture* texture, const sfRenderWindow* renderWindow, sfVector2u offset)
{ {
CSFML_CHECK(renderWindow); CSFML_CHECK(renderWindow);
CSFML_CALL_PTR(texture, update(renderWindow->This, { x, y })); CSFML_CALL_PTR(texture, update(renderWindow->This, convertVector2(offset)));
} }
+8 -8
View File
@@ -102,11 +102,11 @@ void sfTransform_combine(sfTransform* transform, const sfTransform* other)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransform_translate(sfTransform* transform, float x, float y) void sfTransform_translate(sfTransform* transform, sfVector2f offset)
{ {
CSFML_CHECK(transform); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).translate({ x, y })); *transform = convertTransform(convertTransform(*transform).translate(convertVector2(offset)));
} }
@@ -120,29 +120,29 @@ void sfTransform_rotate(sfTransform* transform, float angle)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransform_rotateWithCenter(sfTransform* transform, float angle, float centerX, float centerY) void sfTransform_rotateWithCenter(sfTransform* transform, float angle, sfVector2f center)
{ {
CSFML_CHECK(transform); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).rotate(sf::degrees(angle), { centerX, centerY })); *transform = convertTransform(convertTransform(*transform).rotate(sf::degrees(angle), convertVector2(center)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransform_scale(sfTransform* transform, float scaleX, float scaleY) void sfTransform_scale(sfTransform* transform, sfVector2f scale)
{ {
CSFML_CHECK(transform); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).scale({ scaleX, scaleY })); *transform = convertTransform(convertTransform(*transform).scale(convertVector2(scale)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransform_scaleWithCenter(sfTransform* transform, float scaleX, float scaleY, float centerX, float centerY) void sfTransform_scaleWithCenter(sfTransform* transform, sfVector2f scale, sfVector2f center)
{ {
CSFML_CHECK(transform); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).scale({ scaleX, scaleY }, { centerX, centerY })); *transform = convertTransform(convertTransform(*transform).scale(convertVector2(scale), convertVector2(center)));
} }
+2 -2
View File
@@ -36,7 +36,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
[[nodiscard]] inline sfVideoMode convertVideoMode(const sf::VideoMode& videoMode) [[nodiscard]] inline sfVideoMode convertVideoMode(const sf::VideoMode& videoMode)
{ {
return {videoMode.size.x, videoMode.size.y, videoMode.bitsPerPixel}; return {{videoMode.size.x, videoMode.size.y}, videoMode.bitsPerPixel};
} }
@@ -45,5 +45,5 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
[[nodiscard]] inline sf::VideoMode convertVideoMode(const sfVideoMode& videoMode) [[nodiscard]] inline sf::VideoMode convertVideoMode(const sfVideoMode& videoMode)
{ {
return sf::VideoMode({videoMode.width, videoMode.height}, videoMode.bitsPerPixel); return sf::VideoMode({videoMode.size.x, videoMode.size.y}, videoMode.bitsPerPixel);
} }
+2 -2
View File
@@ -192,9 +192,9 @@ void sfWindow_setUnicodeTitle(sfWindow* window, const sfChar32* title)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfWindow_setIcon(sfWindow* window, unsigned int width, unsigned int height, const uint8_t* pixels) void sfWindow_setIcon(sfWindow* window, sfVector2u size, const uint8_t* pixels)
{ {
CSFML_CALL(window, setIcon({ width, height }, pixels)); CSFML_CALL(window, setIcon(convertVector2(size), pixels));
} }
+2 -2
View File
@@ -176,9 +176,9 @@ void sfWindowBase_setUnicodeTitle(sfWindowBase* windowBase, const sfChar32* titl
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfWindowBase_setIcon(sfWindowBase* windowBase, unsigned int width, unsigned int height, const uint8_t* pixels) void sfWindowBase_setIcon(sfWindowBase* windowBase, sfVector2u size, const uint8_t* pixels)
{ {
CSFML_CALL(windowBase, setIcon({ width, height }, pixels)); CSFML_CALL(windowBase, setIcon(convertVector2(size), pixels));
} }