sfTransform is no longer a wrapper around a sf::Transform*, it is a simple structure

This commit is contained in:
Laurent Gomila committed 2012-05-22 17:56:01 +02:00
1 parent bf614690ad
commit bfebe0aab4
30 files changed
+179 -159

No files matched your search

+3 -2
View File
@@ -31,6 +31,7 @@
#include <SFML/Graphics/Export.h> #include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h> #include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h> #include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h> #include <SFML/Graphics/Types.h>
#include <SFML/System/Vector2.h> #include <SFML/System/Vector2.h>
@@ -202,7 +203,7 @@ CSFML_GRAPHICS_API void sfCircleShape_scale(sfCircleShape* shape, sfVector2f fac
/// \return Transform combining the position/rotation/scale/origin of the object /// \return Transform combining the position/rotation/scale/origin of the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfCircleShape_getTransform(const sfCircleShape* shape); CSFML_GRAPHICS_API sfTransform sfCircleShape_getTransform(const sfCircleShape* shape);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the inverse of the combined transform of a circle shape /// \brief Get the inverse of the combined transform of a circle shape
@@ -212,7 +213,7 @@ CSFML_GRAPHICS_API const sfTransform* sfCircleShape_getTransform(const sfCircleS
/// \return Inverse of the combined transformations applied to the object /// \return Inverse of the combined transformations applied to the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfCircleShape_getInverseTransform(const sfCircleShape* shape); CSFML_GRAPHICS_API sfTransform sfCircleShape_getInverseTransform(const sfCircleShape* shape);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change the source texture of a circle shape /// \brief Change the source texture of a circle shape
+3 -2
View File
@@ -31,6 +31,7 @@
#include <SFML/Graphics/Export.h> #include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h> #include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h> #include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h> #include <SFML/Graphics/Types.h>
#include <SFML/System/Vector2.h> #include <SFML/System/Vector2.h>
@@ -202,7 +203,7 @@ CSFML_GRAPHICS_API void sfConvexShape_scale(sfConvexShape* shape, sfVector2f fac
/// \return Transform combining the position/rotation/scale/origin of the object /// \return Transform combining the position/rotation/scale/origin of the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfConvexShape_getTransform(const sfConvexShape* shape); CSFML_GRAPHICS_API sfTransform sfConvexShape_getTransform(const sfConvexShape* shape);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the inverse of the combined transform of a convex shape /// \brief Get the inverse of the combined transform of a convex shape
@@ -212,7 +213,7 @@ CSFML_GRAPHICS_API const sfTransform* sfConvexShape_getTransform(const sfConvexS
/// \return Inverse of the combined transformations applied to the object /// \return Inverse of the combined transformations applied to the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfConvexShape_getInverseTransform(const sfConvexShape* shape); CSFML_GRAPHICS_API sfTransform sfConvexShape_getInverseTransform(const sfConvexShape* shape);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change the source texture of a convex shape /// \brief Change the source texture of a convex shape
+3 -2
View File
@@ -31,6 +31,7 @@
#include <SFML/Graphics/Export.h> #include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h> #include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h> #include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h> #include <SFML/Graphics/Types.h>
#include <SFML/System/Vector2.h> #include <SFML/System/Vector2.h>
@@ -202,7 +203,7 @@ CSFML_GRAPHICS_API void sfRectangleShape_scale(sfRectangleShape* shape, sfVector
/// \return Transform combining the position/rotation/scale/origin of the object /// \return Transform combining the position/rotation/scale/origin of the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfRectangleShape_getTransform(const sfRectangleShape* shape); CSFML_GRAPHICS_API sfTransform sfRectangleShape_getTransform(const sfRectangleShape* shape);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the inverse of the combined transform of a rectangle shape /// \brief Get the inverse of the combined transform of a rectangle shape
@@ -212,7 +213,7 @@ CSFML_GRAPHICS_API const sfTransform* sfRectangleShape_getTransform(const sfRect
/// \return Inverse of the combined transformations applied to the object /// \return Inverse of the combined transformations applied to the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfRectangleShape_getInverseTransform(const sfRectangleShape* shape); CSFML_GRAPHICS_API sfTransform sfRectangleShape_getInverseTransform(const sfRectangleShape* shape);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change the source texture of a rectangle shape /// \brief Change the source texture of a rectangle shape
+2 -1
View File
@@ -30,6 +30,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h> #include <SFML/Graphics/Export.h>
#include <SFML/Graphics/BlendMode.h> #include <SFML/Graphics/BlendMode.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h> #include <SFML/Graphics/Types.h>
@@ -40,7 +41,7 @@
typedef struct typedef struct
{ {
sfBlendMode blendMode; ///< Blending mode sfBlendMode blendMode; ///< Blending mode
sfTransform* transform; ///< Transform sfTransform transform; ///< Transform
const sfTexture* texture; ///< Texture const sfTexture* texture; ///< Texture
const sfShader* shader; ///< Shader const sfShader* shader; ///< Shader
} sfRenderStates; } sfRenderStates;
+2 -1
View File
@@ -30,6 +30,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h> #include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h> #include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h> #include <SFML/Graphics/Types.h>
#include <SFML/System/InputStream.h> #include <SFML/System/InputStream.h>
#include <SFML/System/Vector2.h> #include <SFML/System/Vector2.h>
@@ -290,7 +291,7 @@ CSFML_GRAPHICS_API void sfShader_setColorParameter(sfShader* shader, const char*
/// \param transform Transform to assign /// \param transform Transform to assign
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfShader_setTransformParameter(sfShader* shader, const char* name, const sfTransform* transform); CSFML_GRAPHICS_API void sfShader_setTransformParameter(sfShader* shader, const char* name, sfTransform transform);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change a texture parameter of a shader /// \brief Change a texture parameter of a shader
+3 -2
View File
@@ -31,6 +31,7 @@
#include <SFML/Graphics/Export.h> #include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Color.h> #include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h> #include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h> #include <SFML/Graphics/Types.h>
#include <SFML/System/Vector2.h> #include <SFML/System/Vector2.h>
@@ -201,7 +202,7 @@ CSFML_GRAPHICS_API void sfShape_scale(sfShape* shape, sfVector2f factors);
/// \return Transform combining the position/rotation/scale/origin of the object /// \return Transform combining the position/rotation/scale/origin of the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfShape_getTransform(const sfShape* shape); CSFML_GRAPHICS_API sfTransform sfShape_getTransform(const sfShape* shape);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the inverse of the combined transform of a shape /// \brief Get the inverse of the combined transform of a shape
@@ -211,7 +212,7 @@ CSFML_GRAPHICS_API const sfTransform* sfShape_getTransform(const sfShape* shape)
/// \return Inverse of the combined transformations applied to the object /// \return Inverse of the combined transformations applied to the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfShape_getInverseTransform(const sfShape* shape); CSFML_GRAPHICS_API sfTransform sfShape_getInverseTransform(const sfShape* shape);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change the source texture of a shape /// \brief Change the source texture of a shape
+3 -2
View File
@@ -32,6 +32,7 @@
#include <SFML/Graphics/BlendMode.h> #include <SFML/Graphics/BlendMode.h>
#include <SFML/Graphics/Color.h> #include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h> #include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Types.h> #include <SFML/Graphics/Types.h>
#include <SFML/System/Vector2.h> #include <SFML/System/Vector2.h>
@@ -203,7 +204,7 @@ CSFML_GRAPHICS_API void sfSprite_scale(sfSprite* sprite, sfVector2f factors);
/// \return Transform combining the position/rotation/scale/origin of the object /// \return Transform combining the position/rotation/scale/origin of the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfSprite_getTransform(const sfSprite* sprite); CSFML_GRAPHICS_API sfTransform sfSprite_getTransform(const sfSprite* sprite);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the inverse of the combined transform of a sprite /// \brief Get the inverse of the combined transform of a sprite
@@ -213,7 +214,7 @@ CSFML_GRAPHICS_API const sfTransform* sfSprite_getTransform(const sfSprite* spri
/// \return Inverse of the combined transformations applied to the object /// \return Inverse of the combined transformations applied to the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfSprite_getInverseTransform(const sfSprite* sprite); CSFML_GRAPHICS_API sfTransform sfSprite_getInverseTransform(const sfSprite* sprite);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Change the source texture of a sprite /// \brief Change the source texture of a sprite
+3 -2
View File
@@ -32,6 +32,7 @@
#include <SFML/Graphics/Color.h> #include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h> #include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h> #include <SFML/Graphics/Types.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/System/Vector2.h> #include <SFML/System/Vector2.h>
#include <stddef.h> #include <stddef.h>
@@ -215,7 +216,7 @@ CSFML_GRAPHICS_API void sfText_scale(sfText* text, sfVector2f factors);
/// \return Transform combining the position/rotation/scale/origin of the object /// \return Transform combining the position/rotation/scale/origin of the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfText_getTransform(const sfText* text); CSFML_GRAPHICS_API sfTransform sfText_getTransform(const sfText* text);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the inverse of the combined transform of a text /// \brief Get the inverse of the combined transform of a text
@@ -225,7 +226,7 @@ CSFML_GRAPHICS_API const sfTransform* sfText_getTransform(const sfText* text);
/// \return Inverse of the combined transformations applied to the object /// \return Inverse of the combined transformations applied to the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfText_getInverseTransform(const sfText* text); CSFML_GRAPHICS_API sfTransform sfText_getInverseTransform(const sfText* text);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set the string of a text (from an ANSI string) /// \brief Set the string of a text (from an ANSI string)
+27 -37
View File
@@ -34,15 +34,22 @@
#include <SFML/System/Vector2.h> #include <SFML/System/Vector2.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create a new transform /// \brief Encapsulate a 3x3 transform matrix
///
/// This function creates an identity transform.
///
/// \return A new sfTransform object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTransform* sfTransform_create(void); typedef struct
{
float matrix[9];
} sfTransform;
////////////////////////////////////////////////////////////
/// \brief Identity transform (does nothing)
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTransform sfTransform_Identity;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Create a new transform from a matrix /// \brief Create a new transform from a matrix
@@ -60,46 +67,29 @@ CSFML_GRAPHICS_API sfTransform* sfTransform_create(void);
/// \return A new sfTransform object /// \return A new sfTransform object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTransform* sfTransform_createFromMatrix(float a00, float a01, float a02, CSFML_GRAPHICS_API sfTransform sfTransform_fromMatrix(float a00, float a01, float a02,
float a10, float a11, float a12, float a10, float a11, float a12,
float a20, float a21, float a22); float a20, float a21, float a22);
////////////////////////////////////////////////////////////
/// \brief Copy an existing transform
///
/// \param transform Transform to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfTransform* sfTransform_copy(sfTransform* transform);
////////////////////////////////////////////////////////////
/// \brief Destroy an existing transform
///
/// \param transform Transform to delete
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_destroy(sfTransform* transform);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Return the 4x4 matrix of a transform /// \brief Return the 4x4 matrix of a transform
/// ///
/// This function returns a pointer to an array of 16 floats /// This function fills an array of 16 floats with the transform
/// containing the transform elements as a 4x4 matrix, which /// converted as a 4x4 matrix, which is directly compatible with
/// is directly compatible with OpenGL functions. /// OpenGL functions.
/// ///
/// \code /// \code
/// sfTransform* transform = ...; /// sfTransform transform = ...;
/// glLoadMatrixf(sfTransform_getMatrix(transform)); /// float matrix[16];
/// sfTransform_getMatrix(&transform, matrix)
/// glLoadMatrixf(matrix);
/// \endcode /// \endcode
/// ///
/// \param transform Transform object /// \param transform Transform object
/// /// \param matrix Pointer to the 16-element array to fill with the matrix
/// \return Pointer to a 4x4 matrix
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const float* sfTransform_getMatrix(const sfTransform* transform); CSFML_GRAPHICS_API void sfTransform_getMatrix(const sfTransform* transform, float* matrix);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Return the inverse of a transform /// \brief Return the inverse of a transform
@@ -108,10 +98,10 @@ CSFML_GRAPHICS_API const float* sfTransform_getMatrix(const sfTransform* transfo
/// is returned. /// is returned.
/// ///
/// \param transform Transform object /// \param transform Transform object
/// \param result Returned inverse matrix /// \return The inverse matrix
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTransform_getInverse(const sfTransform* transform, sfTransform* result); CSFML_GRAPHICS_API sfTransform sfTransform_getInverse(const sfTransform* transform);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Apply a transform to a 2D point /// \brief Apply a transform to a 2D point
+3 -2
View File
@@ -30,6 +30,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/Export.h> #include <SFML/Graphics/Export.h>
#include <SFML/Graphics/Types.h> #include <SFML/Graphics/Types.h>
#include <SFML/Graphics/Transform.h>
#include <SFML/System/Vector2.h> #include <SFML/System/Vector2.h>
@@ -200,7 +201,7 @@ CSFML_GRAPHICS_API void sfTransformable_scale(sfTransformable* transformable, sf
/// \return Transform combining the position/rotation/scale/origin of the object /// \return Transform combining the position/rotation/scale/origin of the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfTransformable_getTransform(const sfTransformable* transformable); CSFML_GRAPHICS_API sfTransform sfTransformable_getTransform(const sfTransformable* transformable);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get the inverse of the combined transform of a transformable /// \brief Get the inverse of the combined transform of a transformable
@@ -210,7 +211,7 @@ CSFML_GRAPHICS_API const sfTransform* sfTransformable_getTransform(const sfTrans
/// \return Inverse of the combined transformations applied to the object /// \return Inverse of the combined transformations applied to the object
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API const sfTransform* sfTransformable_getInverseTransform(const sfTransformable* transformable); CSFML_GRAPHICS_API sfTransform sfTransformable_getInverseTransform(const sfTransformable* transformable);
#endif // SFML_TRANSFORMABLE_H #endif // SFML_TRANSFORMABLE_H
-1
View File
@@ -38,7 +38,6 @@ typedef struct sfShape sfShape;
typedef struct sfSprite sfSprite; typedef struct sfSprite sfSprite;
typedef struct sfText sfText; typedef struct sfText sfText;
typedef struct sfTexture sfTexture; typedef struct sfTexture sfTexture;
typedef struct sfTransform sfTransform;
typedef struct sfTransformable sfTransformable; typedef struct sfTransformable sfTransformable;
typedef struct sfVertexArray sfVertexArray; typedef struct sfVertexArray sfVertexArray;
typedef struct sfView sfView; typedef struct sfView sfView;
+1 -1
View File
@@ -12,6 +12,7 @@ set(SRC
${SRCROOT}/Color.cpp ${SRCROOT}/Color.cpp
${INCROOT}/Color.h ${INCROOT}/Color.h
${SRCROOT}/ConvertRenderStates.hpp ${SRCROOT}/ConvertRenderStates.hpp
${SRCROOT}/ConvertTransform.hpp
${SRCROOT}/ConvexShape.cpp ${SRCROOT}/ConvexShape.cpp
${SRCROOT}/ConvexShapeStruct.h ${SRCROOT}/ConvexShapeStruct.h
${INCROOT}/ConvexShape.h ${INCROOT}/ConvexShape.h
@@ -49,7 +50,6 @@ set(SRC
${SRCROOT}/TextureStruct.h ${SRCROOT}/TextureStruct.h
${INCROOT}/Texture.h ${INCROOT}/Texture.h
${SRCROOT}/Transform.cpp ${SRCROOT}/Transform.cpp
${SRCROOT}/TransformStruct.h
${INCROOT}/Transform.h ${INCROOT}/Transform.h
${SRCROOT}/Transformable.cpp ${SRCROOT}/Transformable.cpp
${SRCROOT}/TransformableStruct.h ${SRCROOT}/TransformableStruct.h
+7 -6
View File
@@ -28,6 +28,7 @@
#include <SFML/Graphics/CircleShape.h> #include <SFML/Graphics/CircleShape.h>
#include <SFML/Graphics/CircleShapeStruct.h> #include <SFML/Graphics/CircleShapeStruct.h>
#include <SFML/Graphics/Color.hpp> #include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/ConvertTransform.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
@@ -156,22 +157,22 @@ void sfCircleShape_scale(sfCircleShape* shape, sfVector2f factors)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfCircleShape_getTransform(const sfCircleShape* shape) sfTransform sfCircleShape_getTransform(const sfCircleShape* shape)
{ {
CSFML_CHECK_RETURN(shape, NULL); CSFML_CHECK_RETURN(shape, NULL);
shape->Transform.This = shape->This.getTransform(); shape->Transform = convertTransform(shape->This.getTransform());
return &shape->Transform; return shape->Transform;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfCircleShape_getInverseTransform(const sfCircleShape* shape) sfTransform sfCircleShape_getInverseTransform(const sfCircleShape* shape)
{ {
CSFML_CHECK_RETURN(shape, NULL); CSFML_CHECK_RETURN(shape, NULL);
shape->InverseTransform.This = shape->This.getInverseTransform(); shape->InverseTransform = convertTransform(shape->This.getInverseTransform());
return &shape->InverseTransform; return shape->InverseTransform;
} }
+1 -1
View File
@@ -30,7 +30,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/CircleShape.hpp> #include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/TextureStruct.h> #include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/TransformStruct.h> #include <SFML/Graphics/Transform.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
+2 -2
View File
@@ -30,7 +30,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/RenderStates.h> #include <SFML/Graphics/RenderStates.h>
#include <SFML/Graphics/RenderStates.hpp> #include <SFML/Graphics/RenderStates.hpp>
#include <SFML/Graphics/TransformStruct.h> #include <SFML/Graphics/ConvertTransform.hpp>
#include <SFML/Graphics/TextureStruct.h> #include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/ShaderStruct.h> #include <SFML/Graphics/ShaderStruct.h>
@@ -45,7 +45,7 @@ inline sf::RenderStates convertRenderStates(const sfRenderStates* states)
if (states) if (states)
{ {
sfmlStates.blendMode = static_cast<sf::BlendMode>(states->blendMode); sfmlStates.blendMode = static_cast<sf::BlendMode>(states->blendMode);
sfmlStates.transform = states->transform ? states->transform->This : sf::Transform::Identity; sfmlStates.transform = convertTransform(states->transform);
sfmlStates.texture = states->texture ? states->texture->This : NULL; sfmlStates.texture = states->texture ? states->texture->This : NULL;
sfmlStates.shader = states->shader ? &states->shader->This : NULL; sfmlStates.shader = states->shader ? &states->shader->This : NULL;
} }
@@ -22,22 +22,37 @@
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_TRANSFORMSTRUCT_H #ifndef SFML_CONVERTTRANSFORM_H
#define SFML_TRANSFORMSTRUCT_H #define SFML_CONVERTTRANSFORM_H
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/Transform.hpp> #include <SFML/Graphics/Transform.hpp>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Internal structure of sfTransform // Convert sf::Transform to sfTransform
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct sfTransform inline sfTransform convertTransform(const sf::Transform& transform)
{ {
sf::Transform This; const float* m = transform.getMatrix();
}; sfTransform converted = {m[0], m[4], m[12], m[1], m[5], m[13], m[3], m[7], m[15]};
return converted;
}
#endif // SFML_TRANSFORMSTRUCT_H ////////////////////////////////////////////////////////////
// Convert sfTransform to sf::Transform
////////////////////////////////////////////////////////////
inline sf::Transform convertTransform(const sfTransform& transform)
{
const float* m = transform.matrix;
return sf::Transform(m[0], m[1], m[2],
m[3], m[4], m[5],
m[6], m[7], m[8]);
}
#endif // SFML_CONVERTTRANSFORM_H
+7 -6
View File
@@ -28,6 +28,7 @@
#include <SFML/Graphics/ConvexShape.h> #include <SFML/Graphics/ConvexShape.h>
#include <SFML/Graphics/ConvexShapeStruct.h> #include <SFML/Graphics/ConvexShapeStruct.h>
#include <SFML/Graphics/Color.hpp> #include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/ConvertTransform.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
@@ -153,22 +154,22 @@ void sfConvexShape_scale(sfConvexShape* shape, sfVector2f factors)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfConvexShape_getTransform(const sfConvexShape* shape) sfTransform sfConvexShape_getTransform(const sfConvexShape* shape)
{ {
CSFML_CHECK_RETURN(shape, NULL); CSFML_CHECK_RETURN(shape, NULL);
shape->Transform.This = shape->This.getTransform(); shape->Transform = convertTransform(shape->This.getTransform());
return &shape->Transform; return shape->Transform;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfConvexShape_getInverseTransform(const sfConvexShape* shape) sfTransform sfConvexShape_getInverseTransform(const sfConvexShape* shape)
{ {
CSFML_CHECK_RETURN(shape, NULL); CSFML_CHECK_RETURN(shape, NULL);
shape->InverseTransform.This = shape->This.getInverseTransform(); shape->InverseTransform = convertTransform(shape->This.getInverseTransform());
return &shape->InverseTransform; return shape->InverseTransform;
} }
+1 -1
View File
@@ -30,7 +30,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/ConvexShape.hpp> #include <SFML/Graphics/ConvexShape.hpp>
#include <SFML/Graphics/TextureStruct.h> #include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/TransformStruct.h> #include <SFML/Graphics/Transform.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
+7 -6
View File
@@ -28,6 +28,7 @@
#include <SFML/Graphics/RectangleShape.h> #include <SFML/Graphics/RectangleShape.h>
#include <SFML/Graphics/RectangleShapeStruct.h> #include <SFML/Graphics/RectangleShapeStruct.h>
#include <SFML/Graphics/Color.hpp> #include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/ConvertTransform.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
@@ -153,22 +154,22 @@ void sfRectangleShape_scale(sfRectangleShape* shape, sfVector2f factors)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfRectangleShape_getTransform(const sfRectangleShape* shape) sfTransform sfRectangleShape_getTransform(const sfRectangleShape* shape)
{ {
CSFML_CHECK_RETURN(shape, NULL); CSFML_CHECK_RETURN(shape, NULL);
shape->Transform.This = shape->This.getTransform(); shape->Transform = convertTransform(shape->This.getTransform());
return &shape->Transform; return shape->Transform;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfRectangleShape_getInverseTransform(const sfRectangleShape* shape) sfTransform sfRectangleShape_getInverseTransform(const sfRectangleShape* shape)
{ {
CSFML_CHECK_RETURN(shape, NULL); CSFML_CHECK_RETURN(shape, NULL);
shape->InverseTransform.This = shape->This.getInverseTransform(); shape->InverseTransform = convertTransform(shape->This.getInverseTransform());
return &shape->InverseTransform; return shape->InverseTransform;
} }
+1 -1
View File
@@ -30,7 +30,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/RectangleShape.hpp> #include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/TextureStruct.h> #include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/TransformStruct.h> #include <SFML/Graphics/Transform.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
+3 -3
View File
@@ -28,7 +28,7 @@
#include <SFML/Graphics/Shader.h> #include <SFML/Graphics/Shader.h>
#include <SFML/Graphics/ShaderStruct.h> #include <SFML/Graphics/ShaderStruct.h>
#include <SFML/Graphics/TextureStruct.h> #include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/TransformStruct.h> #include <SFML/Graphics/ConvertTransform.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
#include <SFML/CallbackStream.h> #include <SFML/CallbackStream.h>
@@ -196,9 +196,9 @@ void sfShader_setColorParameter(sfShader* shader, const char* name, sfColor colo
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfShader_setTransformParameter(sfShader* shader, const char* name, const sfTransform* transform) void sfShader_setTransformParameter(sfShader* shader, const char* name, sfTransform transform)
{ {
CSFML_CALL(shader, setParameter(name, transform ? transform->This : sf::Transform::Identity)); CSFML_CALL(shader, setParameter(name, convertTransform(transform)));
} }
+7 -6
View File
@@ -28,6 +28,7 @@
#include <SFML/Graphics/Shape.h> #include <SFML/Graphics/Shape.h>
#include <SFML/Graphics/ShapeStruct.h> #include <SFML/Graphics/ShapeStruct.h>
#include <SFML/Graphics/Color.hpp> #include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/ConvertTransform.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
@@ -146,22 +147,22 @@ void sfShape_scale(sfShape* shape, sfVector2f factors)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfShape_getTransform(const sfShape* shape) sfTransform sfShape_getTransform(const sfShape* shape)
{ {
CSFML_CHECK_RETURN(shape, NULL); CSFML_CHECK_RETURN(shape, NULL);
shape->Transform.This = shape->This.getTransform(); shape->Transform = convertTransform(shape->This.getTransform());
return &shape->Transform; return shape->Transform;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfShape_getInverseTransform(const sfShape* shape) sfTransform sfShape_getInverseTransform(const sfShape* shape)
{ {
CSFML_CHECK_RETURN(shape, NULL); CSFML_CHECK_RETURN(shape, NULL);
shape->InverseTransform.This = shape->This.getInverseTransform(); shape->InverseTransform = convertTransform(shape->This.getInverseTransform());
return &shape->InverseTransform; return shape->InverseTransform;
} }
+1 -1
View File
@@ -31,7 +31,7 @@
#include <SFML/Graphics/Shape.h> #include <SFML/Graphics/Shape.h>
#include <SFML/Graphics/Shape.hpp> #include <SFML/Graphics/Shape.hpp>
#include <SFML/Graphics/TextureStruct.h> #include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/TransformStruct.h> #include <SFML/Graphics/Transform.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
+7 -6
View File
@@ -29,6 +29,7 @@
#include <SFML/Graphics/SpriteStruct.h> #include <SFML/Graphics/SpriteStruct.h>
#include <SFML/Graphics/Color.hpp> #include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/Image.hpp> #include <SFML/Graphics/Image.hpp>
#include <SFML/Graphics/ConvertTransform.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
@@ -157,22 +158,22 @@ void sfSprite_scale(sfSprite* sprite, sfVector2f factors)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfSprite_getTransform(const sfSprite* sprite) sfTransform sfSprite_getTransform(const sfSprite* sprite)
{ {
CSFML_CHECK_RETURN(sprite, NULL); CSFML_CHECK_RETURN(sprite, NULL);
sprite->Transform.This = sprite->This.getTransform(); sprite->Transform = convertTransform(sprite->This.getTransform());
return &sprite->Transform; return sprite->Transform;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfSprite_getInverseTransform(const sfSprite* sprite) sfTransform sfSprite_getInverseTransform(const sfSprite* sprite)
{ {
CSFML_CHECK_RETURN(sprite, NULL); CSFML_CHECK_RETURN(sprite, NULL);
sprite->InverseTransform.This = sprite->This.getInverseTransform(); sprite->InverseTransform = convertTransform(sprite->This.getInverseTransform());
return &sprite->InverseTransform; return sprite->InverseTransform;
} }
+1 -1
View File
@@ -30,7 +30,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/Sprite.hpp> #include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/TextureStruct.h> #include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/TransformStruct.h> #include <SFML/Graphics/Transform.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
+7 -6
View File
@@ -29,6 +29,7 @@
#include <SFML/Graphics/TextStruct.h> #include <SFML/Graphics/TextStruct.h>
#include <SFML/Graphics/Font.h> #include <SFML/Graphics/Font.h>
#include <SFML/Graphics/Color.hpp> #include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/ConvertTransform.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
@@ -157,22 +158,22 @@ void sfText_scale(sfText* text, sfVector2f factors)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfText_getTransform(const sfText* text) sfTransform sfText_getTransform(const sfText* text)
{ {
CSFML_CHECK_RETURN(text, NULL); CSFML_CHECK_RETURN(text, NULL);
text->Transform.This = text->This.getTransform(); text->Transform = convertTransform(text->This.getTransform());
return &text->Transform; return text->Transform;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfText_getInverseTransform(const sfText* text) sfTransform sfText_getInverseTransform(const sfText* text)
{ {
CSFML_CHECK_RETURN(text, NULL); CSFML_CHECK_RETURN(text, NULL);
text->InverseTransform.This = text->This.getInverseTransform(); text->InverseTransform = convertTransform(text->This.getInverseTransform());
return &text->InverseTransform; return text->InverseTransform;
} }
+1 -1
View File
@@ -31,7 +31,7 @@
#include <SFML/Graphics/Text.hpp> #include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/FontStruct.h> #include <SFML/Graphics/FontStruct.h>
#include <SFML/Graphics/Rect.h> #include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/TransformStruct.h> #include <SFML/Graphics/Transform.h>
#include <string> #include <string>
+43 -43
View File
@@ -26,58 +26,47 @@
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/Transform.h> #include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/TransformStruct.h> #include <SFML/Graphics/Transform.hpp>
#include <SFML/Graphics/ConvertTransform.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfTransform* sfTransform_create(void) sfTransform sfTransform_Identity =
{ {
return new sfTransform; 1, 0, 0,
} 0, 1, 0,
0, 0, 1,
};
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfTransform* sfTransform_createFromMatrix(float a00, float a01, float a02, sfTransform sfTransform_fromMatrix(float a00, float a01, float a02,
float a10, float a11, float a12, float a10, float a11, float a12,
float a20, float a21, float a22) float a20, float a21, float a22)
{ {
sfTransform* transform = new sfTransform; sfTransform transform = {a00, a01, a02, a10, a11, a12, a20, a21, a22};
transform->This = sf::Transform(a00, a01, a02, a10, a11, a12, a20, a21, a22);
return transform; return transform;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfTransform* sfTransform_copy(sfTransform* transform) void sfTransform_getMatrix(const sfTransform* transform, float* matrix)
{
CSFML_CHECK_RETURN(transform, NULL);
return new sfTransform(*transform);
}
////////////////////////////////////////////////////////////
void sfTransform_destroy(sfTransform* transform)
{
delete transform;
}
////////////////////////////////////////////////////////////
const float* sfTransform_getMatrix(const sfTransform* transform)
{
CSFML_CALL_RETURN(transform, getMatrix(), NULL);
}
////////////////////////////////////////////////////////////
void sfTransform_getInverse(const sfTransform* transform, sfTransform* result)
{ {
CSFML_CHECK(transform); CSFML_CHECK(transform);
if (result) sf::Transform converted = convertTransform(*transform);
result->This = transform->This.getInverse(); if (matrix)
std::memcpy(matrix, converted.getMatrix(), 16 * sizeof(float));
}
////////////////////////////////////////////////////////////
sfTransform sfTransform_getInverse(const sfTransform* transform)
{
CSFML_CHECK(transform);
return convertTransform(convertTransform(*transform).getInverse());
} }
@@ -87,7 +76,7 @@ sfVector2f sfTransform_transformPoint(const sfTransform* transform, sfVector2f p
sfVector2f p = {0, 0}; sfVector2f p = {0, 0};
CSFML_CHECK_RETURN(transform, p); CSFML_CHECK_RETURN(transform, p);
sf::Vector2f sfmlPoint = transform->This.transformPoint(point.x, point.y); sf::Vector2f sfmlPoint = convertTransform(*transform).transformPoint(point.x, point.y);
p.x = sfmlPoint.x; p.x = sfmlPoint.x;
p.y = sfmlPoint.y; p.y = sfmlPoint.y;
@@ -102,7 +91,7 @@ sfFloatRect sfTransform_transformRect(const sfTransform* transform, sfFloatRect
sfFloatRect rect = {0, 0, 0, 0}; sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(transform, rect); CSFML_CHECK_RETURN(transform, rect);
sf::FloatRect sfmlRect = transform->This.transformRect(sf::FloatRect(rectangle.left, rectangle.top, rectangle.width, rectangle.height)); sf::FloatRect sfmlRect = convertTransform(*transform).transformRect(sf::FloatRect(rectangle.left, rectangle.top, rectangle.width, rectangle.height));
rect.left = sfmlRect.left; rect.left = sfmlRect.left;
rect.top = sfmlRect.top; rect.top = sfmlRect.top;
@@ -116,42 +105,53 @@ sfFloatRect sfTransform_transformRect(const sfTransform* transform, sfFloatRect
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransform_combine(sfTransform* transform, const sfTransform* other) void sfTransform_combine(sfTransform* transform, const sfTransform* other)
{ {
CSFML_CHECK(transform);
CSFML_CHECK(other); CSFML_CHECK(other);
CSFML_CALL(transform, combine(other->This)); *transform = convertTransform(convertTransform(*transform).combine(convertTransform(*other)));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransform_translate(sfTransform* transform, float x, float y) void sfTransform_translate(sfTransform* transform, float x, float y)
{ {
CSFML_CALL(transform, translate(x, y)); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).translate(x, y));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransform_rotate(sfTransform* transform, float angle) void sfTransform_rotate(sfTransform* transform, float angle)
{ {
CSFML_CALL(transform, rotate(angle)); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).rotate(angle));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransform_rotateWithCenter(sfTransform* transform, float angle, float centerX, float centerY) void sfTransform_rotateWithCenter(sfTransform* transform, float angle, float centerX, float centerY)
{ {
CSFML_CALL(transform, rotate(angle, centerX, centerY)); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).rotate(angle, centerX, centerY));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransform_scale(sfTransform* transform, float scaleX, float scaleY) void sfTransform_scale(sfTransform* transform, float scaleX, float scaleY)
{ {
CSFML_CALL(transform, scale(scaleX, scaleY)); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).scale(scaleX, scaleY));
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void sfTransform_scaleWithCenter(sfTransform* transform, float scaleX, float scaleY, float centerX, float centerY) void sfTransform_scaleWithCenter(sfTransform* transform, float scaleX, float scaleY, float centerX, float centerY)
{ {
CSFML_CALL(transform, scale(scaleX, scaleY, centerX, centerY)); CSFML_CHECK(transform);
*transform = convertTransform(convertTransform(*transform).scale(scaleX, scaleY, centerX, centerY));
} }
+7 -6
View File
@@ -27,6 +27,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/Transformable.h> #include <SFML/Graphics/Transformable.h>
#include <SFML/Graphics/TransformableStruct.h> #include <SFML/Graphics/TransformableStruct.h>
#include <SFML/Graphics/ConvertTransform.hpp>
#include <SFML/Internal.h> #include <SFML/Internal.h>
@@ -154,20 +155,20 @@ void sfTransformable_scale(sfTransformable* transformable, sfVector2f factors)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfTransformable_getTransform(const sfTransformable* transformable) sfTransform sfTransformable_getTransform(const sfTransformable* transformable)
{ {
CSFML_CHECK_RETURN(transformable, NULL); CSFML_CHECK_RETURN(transformable, NULL);
transformable->Transform.This = transformable->This.getTransform(); transformable->Transform = convertTransform(transformable->This.getTransform());
return &transformable->Transform; return transformable->Transform;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const sfTransform* sfTransformable_getInverseTransform(const sfTransformable* transformable) sfTransform sfTransformable_getInverseTransform(const sfTransformable* transformable)
{ {
CSFML_CHECK_RETURN(transformable, NULL); CSFML_CHECK_RETURN(transformable, NULL);
transformable->InverseTransform.This = transformable->This.getInverseTransform(); transformable->InverseTransform = convertTransform(transformable->This.getInverseTransform());
return &transformable->InverseTransform; return transformable->InverseTransform;
} }
+1 -1
View File
@@ -29,7 +29,7 @@
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/Transformable.hpp> #include <SFML/Graphics/Transformable.hpp>
#include <SFML/Graphics/TransformStruct.h> #include <SFML/Graphics/Transform.h>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////