Updated to the new graphics API

This commit is contained in:
Laurent Gomila committed 2012-01-29 11:29:09 +01:00
1 parent 06997db9e8
commit 44670984af
51 files changed
+4607 -2573

No files matched your search

+2 -1
View File
@@ -32,7 +32,8 @@
////////////////////////////////////////////////////////////
/// Enumerate the blending modes for drawable objects
/// \brief Available blending modes for drawing
///
////////////////////////////////////////////////////////////
typedef enum
{
+402
View File
@@ -0,0 +1,402 @@
////////////////////////////////////////////////////////////
//
// 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_CIRCLESHAPE_H
#define SFML_CIRCLESHAPE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// \brief Create a new circle shape
///
/// \return A new sfCircleShape object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfCircleShape* sfCircleShape_Create(void);
////////////////////////////////////////////////////////////
/// \brief Copy an existing circle shape
///
/// \param shape Shape to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfCircleShape* sfCircleShape_Copy(sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Destroy an existing circle Shape
///
/// \param Shape Shape to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_Destroy(sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Set the position of a circle shape
///
/// This function completely overwrites the previous position.
/// See sfCircleShape_Move to apply an offset based on the previous position instead.
/// The default position of a circle Shape object is (0, 0).
///
/// \param shape Shape object
/// \param x X coordinate of the new position
/// \param y Y coordinate of the new position
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_SetPosition(sfCircleShape* shape, float x, float y);
////////////////////////////////////////////////////////////
/// \brief Set the orientation of a circle shape
///
/// This function completely overwrites the previous rotation.
/// See sfCircleShape_Rotate to add an angle based on the previous rotation instead.
/// The default rotation of a circle Shape object is 0.
///
/// \param shape Shape object
/// \param angle New rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_SetRotation(sfCircleShape* shape, float angle);
////////////////////////////////////////////////////////////
/// \brief Set the scale factors of a circle shape
///
/// This function completely overwrites the previous scale.
/// See sfCircleShape_Scale to add a factor based on the previous scale instead.
/// The default scale of a circle Shape object is (1, 1).
///
/// \param shape Shape object
/// \param factorX New horizontal scale factor
/// \param factorY New vertical scale factor
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_SetScale(sfCircleShape* shape, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// \brief Set the local origin of a circle shape
///
/// The origin of an object defines the center point for
/// all transformations (position, scale, rotation).
/// The coordinates of this point must be relative to the
/// top-left corner of the object, and ignore all
/// transformations (position, scale, rotation).
/// The default origin of a circle Shape object is (0, 0).
///
/// \param shape Shape object
/// \param x X coordinate of the new origin
/// \param y Y coordinate of the new origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_SetOrigin(sfCircleShape* shape, float x, float y);
////////////////////////////////////////////////////////////
/// \brief Get the position of a circle shape
///
/// \param shape Shape object
///
/// \return Current position
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_GetPosition(const sfCircleShape* shape, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Get the orientation of a circle shape
///
/// The rotation is always in the range [0, 360].
///
/// \param shape Shape object
///
/// \return Current rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API float sfCircleShape_GetRotation(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the current scale of a circle shape
///
/// \param shape Shape object
///
/// \return Current scale factors
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_GetScale(const sfCircleShape* shape, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Get the local origin of a circle shape
///
/// \param shape Shape object
///
/// \return Current origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_GetOrigin(const sfCircleShape* shape, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Move a circle shape by a given offset
///
/// This function adds to the current position of the object,
/// unlike sfCircleShape_SetPosition which overwrites it.
///
/// \param shape Shape object
/// \param offsetX X offset
/// \param offsetY Y offset
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_Move(sfCircleShape* shape, float offsetX, float offsetY);
////////////////////////////////////////////////////////////
/// \brief Rotate a circle shape
///
/// This function adds to the current rotation of the object,
/// unlike sfCircleShape_SetRotation which overwrites it.
///
/// \param shape Shape object
/// \param angle Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_Rotate(sfCircleShape* shape, float angle);
////////////////////////////////////////////////////////////
/// \brief Scale a circle shape
///
/// This function multiplies the current scale of the object,
/// unlike sfCircleShape_SetScale which overwrites it.
///
/// \param shape Shape object
/// \param factorX Horizontal scale factor
/// \param factorY Vertical scale factor
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_Scale(sfCircleShape* shape, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// \brief Get the combined transform of a circle shape
///
/// \param shape Shape object
///
/// \return Transform combining the position/rotation/scale/origin of the object
///
////////////////////////////////////////////////////////////
CSFML_API const sfTransform* sfCircleShape_GetTransform(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the inverse of the combined transform of a circle shape
///
/// \param shape Shape object
///
/// \return Inverse of the combined transformations applied to the object
///
////////////////////////////////////////////////////////////
CSFML_API const sfTransform* sfCircleShape_GetInverseTransform(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Change the source texture of a circle shape
///
/// The \a texture argument refers to a texture that must
/// exist as long as the shape uses it. Indeed, the shape
/// doesn't store its own copy of the texture, but rather keeps
/// a pointer to the one that you passed to this function.
/// If the source texture is destroyed and the shape tries to
/// use it, the behaviour is undefined.
/// \a texture can be NULL to disable texturing.
/// If \a resetRect is true, the TextureRect property of
/// the shape is automatically adjusted to the size of the new
/// texture. If it is false, the texture rect is left unchanged.
///
/// \param shape Shape object
/// \param texture New texture
/// \param resetRect Should the texture rect be reset to the size of the new texture?
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_SetTexture(sfCircleShape* shape, const sfTexture* texture, sfBool resetRect);
////////////////////////////////////////////////////////////
/// \brief Set the sub-rectangle of the texture that a circle shape will display
///
/// The texture rect is useful when you don't want to display
/// the whole texture, but rather a part of it.
/// By default, the texture rect covers the entire texture.
///
/// \param shape Shape object
/// \param rect Rectangle defining the region of the texture to display
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_SetTextureRect(sfCircleShape* shape, sfIntRect rect);
////////////////////////////////////////////////////////////
/// \brief Set the fill color of a circle shape
///
/// This color is modulated (multiplied) with the shape's
/// texture if any. It can be used to colorize the shape,
/// or change its global opacity.
/// You can use sf::Color::Transparent to make the inside of
/// the shape transparent, and have the outline alone.
/// By default, the shape's fill color is opaque white.
///
/// \param shape Shape object
/// \param color New color of the shape
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_SetFillColor(sfCircleShape* shape, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Set the outline color of a circle shape
///
/// You can use sf::Color::Transparent to disable the outline.
/// By default, the shape's outline color is opaque white.
///
/// \param shape Shape object
/// \param color New outline color of the shape
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_SetOutlineColor(sfCircleShape* shape, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Set the thickness of a circle shape's outline
///
/// This number cannot be negative. Using zero disables
/// the outline.
/// By default, the outline thickness is 0.
///
/// \param shape Shape object
/// \param thickness New outline thickness
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_SetOutlineThickness(sfCircleShape* shape, float thickness);
////////////////////////////////////////////////////////////
/// \brief Get the source texture of a circle shape
///
/// If the shape has no source texture, a NULL pointer is returned.
/// The returned pointer is const, which means that you can't
/// modify the texture when you retrieve it with this function.
///
/// \param shape Shape object
///
/// \return Pointer to the shape's texture
///
////////////////////////////////////////////////////////////
CSFML_API const sfTexture* sfCircleShape_GetTexture(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the sub-rectangle of the texture displayed by a circle shape
///
/// \param shape Shape object
///
/// \return Texture rectangle of the shape
///
////////////////////////////////////////////////////////////
CSFML_API sfIntRect sfCircleShape_GetTextureRect(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the fill color of a circle shape
///
/// \param shape Shape object
///
/// \return Fill color of the shape
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfCircleShape_GetFillColor(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the outline color of a circle shape
///
/// \param shape Shape object
///
/// \return Outline color of the shape
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfCircleShape_GetOutlineColor(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the outline thickness of a circle shape
///
/// \param shape Shape object
///
/// \return Outline thickness of the shape
///
////////////////////////////////////////////////////////////
CSFML_API float sfCircleShape_GetOutlineThickness(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the total number of points of a circle shape
///
/// \param shape Shape object
///
/// \return Number of points of the shape
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfCircleShape_GetPointCount(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get a point of a circle shape
///
/// The result is undefined if \a index is out of the valid range.
///
/// \param shape Shape object
/// \param index Index of the point to get, in range [0 .. GetPointCount() - 1]
///
/// \return Index-th point of the shape
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_GetPoint(const sfCircleShape* shape, unsigned int index, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Set the radius of a circle
///
/// \param shape Shape object
/// \param radius New radius of the circle
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_SetRadius(sfCircleShape* shape, float radius);
////////////////////////////////////////////////////////////
/// \brief Get the radius of a circle
///
/// \param shape Shape object
///
/// \return Radius of the circle
///
////////////////////////////////////////////////////////////
CSFML_API float sfCircleShape_GetRadius(const sfCircleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Set the number of points of a circle
///
/// \param shape Shape object
/// \param count New number of points of the circle
///
////////////////////////////////////////////////////////////
CSFML_API void sfCircleShape_SetPointCount(sfCircleShape* shape, unsigned int count);
#endif // SFML_CIRCLESHAPE_H
+402
View File
@@ -0,0 +1,402 @@
////////////////////////////////////////////////////////////
//
// 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_CONVEXSHAPE_H
#define SFML_CONVEXSHAPE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// \brief Create a new convex shape
///
/// \return A new sfConvexShape object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfConvexShape* sfConvexShape_Create(void);
////////////////////////////////////////////////////////////
/// \brief Copy an existing convex shape
///
/// \param shape Shape to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfConvexShape* sfConvexShape_Copy(sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Destroy an existing convex Shape
///
/// \param Shape Shape to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_Destroy(sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Set the position of a convex shape
///
/// This function completely overwrites the previous position.
/// See sfConvexShape_Move to apply an offset based on the previous position instead.
/// The default position of a convex shape object is (0, 0).
///
/// \param shape Shape object
/// \param x X coordinate of the new position
/// \param y Y coordinate of the new position
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_SetPosition(sfConvexShape* shape, float x, float y);
////////////////////////////////////////////////////////////
/// \brief Set the orientation of a convex shape
///
/// This function completely overwrites the previous rotation.
/// See sfConvexShape_Rotate to add an angle based on the previous rotation instead.
/// The default rotation of a convex shape object is 0.
///
/// \param shape Shape object
/// \param angle New rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_SetRotation(sfConvexShape* shape, float angle);
////////////////////////////////////////////////////////////
/// \brief Set the scale factors of a convex shape
///
/// This function completely overwrites the previous scale.
/// See sfConvexShape_Scale to add a factor based on the previous scale instead.
/// The default scale of a convex shape object is (1, 1).
///
/// \param shape Shape object
/// \param factorX New horizontal scale factor
/// \param factorY New vertical scale factor
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_SetScale(sfConvexShape* shape, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// \brief Set the local origin of a convex shape
///
/// The origin of an object defines the center point for
/// all transformations (position, scale, rotation).
/// The coordinates of this point must be relative to the
/// top-left corner of the object, and ignore all
/// transformations (position, scale, rotation).
/// The default origin of a convex shape object is (0, 0).
///
/// \param shape Shape object
/// \param x X coordinate of the new origin
/// \param y Y coordinate of the new origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_SetOrigin(sfConvexShape* shape, float x, float y);
////////////////////////////////////////////////////////////
/// \brief Get the position of a convex shape
///
/// \param shape Shape object
///
/// \return Current position
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_GetPosition(const sfConvexShape* shape, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Get the orientation of a convex shape
///
/// The rotation is always in the range [0, 360].
///
/// \param shape Shape object
///
/// \return Current rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API float sfConvexShape_GetRotation(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the current scale of a convex shape
///
/// \param shape Shape object
///
/// \return Current scale factors
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_GetScale(const sfConvexShape* shape, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Get the local origin of a convex shape
///
/// \param shape Shape object
///
/// \return Current origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_GetOrigin(const sfConvexShape* shape, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Move a convex shape by a given offset
///
/// This function adds to the current position of the object,
/// unlike sfConvexShape_SetPosition which overwrites it.
///
/// \param shape Shape object
/// \param offsetX X offset
/// \param offsetY Y offset
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_Move(sfConvexShape* shape, float offsetX, float offsetY);
////////////////////////////////////////////////////////////
/// \brief Rotate a convex shape
///
/// This function adds to the current rotation of the object,
/// unlike sfConvexShape_SetRotation which overwrites it.
///
/// \param shape Shape object
/// \param angle Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_Rotate(sfConvexShape* shape, float angle);
////////////////////////////////////////////////////////////
/// \brief Scale a convex shape
///
/// This function multiplies the current scale of the object,
/// unlike sfConvexShape_SetScale which overwrites it.
///
/// \param shape Shape object
/// \param factorX Horizontal scale factor
/// \param factorY Vertical scale factor
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_Scale(sfConvexShape* shape, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// \brief Get the combined transform of a convex shape
///
/// \param shape shape object
///
/// \return Transform combining the position/rotation/scale/origin of the object
///
////////////////////////////////////////////////////////////
CSFML_API const sfTransform* sfConvexShape_GetTransform(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the inverse of the combined transform of a convex shape
///
/// \param shape shape object
///
/// \return Inverse of the combined transformations applied to the object
///
////////////////////////////////////////////////////////////
CSFML_API const sfTransform* sfConvexShape_GetInverseTransform(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Change the source texture of a convex shape
///
/// The \a texture argument refers to a texture that must
/// exist as long as the shape uses it. Indeed, the shape
/// doesn't store its own copy of the texture, but rather keeps
/// a pointer to the one that you passed to this function.
/// If the source texture is destroyed and the shape tries to
/// use it, the behaviour is undefined.
/// \a texture can be NULL to disable texturing.
/// If \a resetRect is true, the TextureRect property of
/// the shape is automatically adjusted to the size of the new
/// texture. If it is false, the texture rect is left unchanged.
///
/// \param shape Shape object
/// \param texture New texture
/// \param resetRect Should the texture rect be reset to the size of the new texture?
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_SetTexture(sfConvexShape* shape, const sfTexture* texture, sfBool resetRect);
////////////////////////////////////////////////////////////
/// \brief Set the sub-rectangle of the texture that a convex shape will display
///
/// The texture rect is useful when you don't want to display
/// the whole texture, but rather a part of it.
/// By default, the texture rect covers the entire texture.
///
/// \param shape Shape object
/// \param rect Rectangle defining the region of the texture to display
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_SetTextureRect(sfConvexShape* shape, sfIntRect rect);
////////////////////////////////////////////////////////////
/// \brief Set the fill color of a convex shape
///
/// This color is modulated (multiplied) with the shape's
/// texture if any. It can be used to colorize the shape,
/// or change its global opacity.
/// You can use sf::Color::Transparent to make the inside of
/// the shape transparent, and have the outline alone.
/// By default, the shape's fill color is opaque white.
///
/// \param shape Shape object
/// \param color New color of the shape
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_SetFillColor(sfConvexShape* shape, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Set the outline color of a convex shape
///
/// You can use sf::Color::Transparent to disable the outline.
/// By default, the shape's outline color is opaque white.
///
/// \param shape Shape object
/// \param color New outline color of the shape
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_SetOutlineColor(sfConvexShape* shape, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Set the thickness of a convex shape's outline
///
/// This number cannot be negative. Using zero disables
/// the outline.
/// By default, the outline thickness is 0.
///
/// \param shape Shape object
/// \param thickness New outline thickness
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_SetOutlineThickness(sfConvexShape* shape, float thickness);
////////////////////////////////////////////////////////////
/// \brief Get the source texture of a convex shape
///
/// If the shape has no source texture, a NULL pointer is returned.
/// The returned pointer is const, which means that you can't
/// modify the texture when you retrieve it with this function.
///
/// \param shape Shape object
///
/// \return Pointer to the shape's texture
///
////////////////////////////////////////////////////////////
CSFML_API const sfTexture* sfConvexShape_GetTexture(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the sub-rectangle of the texture displayed by a convex shape
///
/// \param shape Shape object
///
/// \return Texture rectangle of the shape
///
////////////////////////////////////////////////////////////
CSFML_API sfIntRect sfConvexShape_GetTextureRect(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the fill color of a convex shape
///
/// \param shape Shape object
///
/// \return Fill color of the shape
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfConvexShape_GetFillColor(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the outline color of a convex shape
///
/// \param shape Shape object
///
/// \return Outline color of the shape
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfConvexShape_GetOutlineColor(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the outline thickness of a convex shape
///
/// \param shape Shape object
///
/// \return Outline thickness of the shape
///
////////////////////////////////////////////////////////////
CSFML_API float sfConvexShape_GetOutlineThickness(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the total number of points of a convex shape
///
/// \param shape Shape object
///
/// \return Number of points of the shape
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfConvexShape_GetPointCount(const sfConvexShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get a point of a convex shape
///
/// The result is undefined if \a index is out of the valid range.
///
/// \param shape Shape object
/// \param index Index of the point to get, in range [0 .. GetPointCount() - 1]
///
/// \return Index-th point of the shape
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_GetPoint(const sfConvexShape* shape, unsigned int index, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Set the number of points of a convex shap
///
/// \a count must be greater than 2 to define a valid shape.
///
/// \param shape Shape object
/// \param count New number of points of the shape
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_SetPointCount(sfConvexShape* shape, unsigned int count);
////////////////////////////////////////////////////////////
/// \brief Set the position of a point in a convex shape
///
/// Don't forget that the polygon must remain convex, and
/// the points need to stay ordered!
/// SetPointCount must be called first in order to set the total
/// number of points. The result is undefined if \a index is out
/// of the valid range.
///
/// \param shape Shape object
/// \param index Index of the point to change, in range [0 .. GetPointCount() - 1]
/// \param x New X coordinate of the point
/// \param y New Y coordinate of the point
///
////////////////////////////////////////////////////////////
CSFML_API void sfConvexShape_SetPoint(sfConvexShape* shape, unsigned int index, float x, float y);
#endif // SFML_CONVEXSHAPE_H
+3 -3
View File
@@ -36,9 +36,9 @@
////////////////////////////////////////////////////////////
typedef struct
{
int Advance; ///< Offset to move horizontically to the next character
sfIntRect Bounds; ///< Bounding rectangle of the glyph, in coordinates relative to the baseline
sfIntRect SubRect; ///< Texture coordinates of the glyph inside the font's image
int Advance; ///< Offset to move horizontically to the next character
sfIntRect Bounds; ///< Bounding rectangle of the glyph, in coordinates relative to the baseline
sfIntRect TextureRect; ///< Texture coordinates of the glyph inside the font's image
} sfGlyph;
+54
View File
@@ -0,0 +1,54 @@
////////////////////////////////////////////////////////////
//
// 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_PRIMITIVETYPE_H
#define SFML_PRIMITIVETYPE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// \brief Types of primitives that a sf::VertexArray can render
///
/// Points and lines have no area, therefore their thickness
/// will always be 1 pixel, regarldess the current transform
/// and view.
///
////////////////////////////////////////////////////////////
typedef enum
{
sfPoints, ///< List of individual points
sfLines, ///< List of individual lines
sfLinesStrip, ///< List of connected lines, a point uses the previous point to form a line
sfTriangles, ///< List of individual triangles
sfTrianglesStrip, ///< List of connected triangles, a point uses the two previous points to form a triangle
sfTrianglesFan, ///< List of connected triangles, a point uses the common center and the previous point to form a triangle
sfQuads ///< List of individual quads
} sfPrimitiveType;
#endif // SFML_BLENDMODE_H
+394
View File
@@ -0,0 +1,394 @@
////////////////////////////////////////////////////////////
//
// 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_RECTANGLESHAPE_H
#define SFML_RECTANGLESHAPE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// \brief Create a new rectangle shape
///
/// \return A new sfRectangleShape object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfRectangleShape* sfRectangleShape_Create(void);
////////////////////////////////////////////////////////////
/// \brief Copy an existing rectangle shape
///
/// \param shape Shape to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfRectangleShape* sfRectangleShape_Copy(sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Destroy an existing rectangle Shape
///
/// \param Shape Shape to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_Destroy(sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Set the position of a rectangle shape
///
/// This function completely overwrites the previous position.
/// See sfRectangleShape_Move to apply an offset based on the previous position instead.
/// The default position of a rectangle shape object is (0, 0).
///
/// \param shape Shape object
/// \param x X coordinate of the new position
/// \param y Y coordinate of the new position
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_SetPosition(sfRectangleShape* shape, float x, float y);
////////////////////////////////////////////////////////////
/// \brief Set the orientation of a rectangle shape
///
/// This function completely overwrites the previous rotation.
/// See sfRectangleShape_Rotate to add an angle based on the previous rotation instead.
/// The default rotation of a rectangle shape object is 0.
///
/// \param shape Shape object
/// \param angle New rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_SetRotation(sfRectangleShape* shape, float angle);
////////////////////////////////////////////////////////////
/// \brief Set the scale factors of a rectangle shape
///
/// This function completely overwrites the previous scale.
/// See sfRectangleShape_Scale to add a factor based on the previous scale instead.
/// The default scale of a rectangle shape object is (1, 1).
///
/// \param shape Shape object
/// \param factorX New horizontal scale factor
/// \param factorY New vertical scale factor
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_SetScale(sfRectangleShape* shape, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// \brief Set the local origin of a rectangle shape
///
/// The origin of an object defines the center point for
/// all transformations (position, scale, rotation).
/// The coordinates of this point must be relative to the
/// top-left corner of the object, and ignore all
/// transformations (position, scale, rotation).
/// The default origin of a rectangle shape object is (0, 0).
///
/// \param shape Shape object
/// \param x X coordinate of the new origin
/// \param y Y coordinate of the new origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_SetOrigin(sfRectangleShape* shape, float x, float y);
////////////////////////////////////////////////////////////
/// \brief Get the position of a rectangle shape
///
/// \param shape Shape object
///
/// \return Current position
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_GetPosition(const sfRectangleShape* shape, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Get the orientation of a rectangle shape
///
/// The rotation is always in the range [0, 360].
///
/// \param shape Shape object
///
/// \return Current rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API float sfRectangleShape_GetRotation(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the current scale of a rectangle shape
///
/// \param shape Shape object
///
/// \return Current scale factors
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_GetScale(const sfRectangleShape* shape, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Get the local origin of a rectangle shape
///
/// \param shape Shape object
///
/// \return Current origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_GetOrigin(const sfRectangleShape* shape, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Move a rectangle shape by a given offset
///
/// This function adds to the current position of the object,
/// unlike sfRectangleShape_SetPosition which overwrites it.
///
/// \param shape Shape object
/// \param offsetX X offset
/// \param offsetY Y offset
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_Move(sfRectangleShape* shape, float offsetX, float offsetY);
////////////////////////////////////////////////////////////
/// \brief Rotate a rectangle shape
///
/// This function adds to the current rotation of the object,
/// unlike sfRectangleShape_SetRotation which overwrites it.
///
/// \param shape Shape object
/// \param angle Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_Rotate(sfRectangleShape* shape, float angle);
////////////////////////////////////////////////////////////
/// \brief Scale a rectangle shape
///
/// This function multiplies the current scale of the object,
/// unlike sfRectangleShape_SetScale which overwrites it.
///
/// \param shape Shape object
/// \param factorX Horizontal scale factor
/// \param factorY Vertical scale factor
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_Scale(sfRectangleShape* shape, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// \brief Get the combined transform of a rectangle shape
///
/// \param shape shape object
///
/// \return Transform combining the position/rotation/scale/origin of the object
///
////////////////////////////////////////////////////////////
CSFML_API const sfTransform* sfRectangleShape_GetTransform(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the inverse of the combined transform of a rectangle shape
///
/// \param shape shape object
///
/// \return Inverse of the combined transformations applied to the object
///
////////////////////////////////////////////////////////////
CSFML_API const sfTransform* sfRectangleShape_GetInverseTransform(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Change the source texture of a rectangle shape
///
/// The \a texture argument refers to a texture that must
/// exist as long as the shape uses it. Indeed, the shape
/// doesn't store its own copy of the texture, but rather keeps
/// a pointer to the one that you passed to this function.
/// If the source texture is destroyed and the shape tries to
/// use it, the behaviour is undefined.
/// \a texture can be NULL to disable texturing.
/// If \a resetRect is true, the TextureRect property of
/// the shape is automatically adjusted to the size of the new
/// texture. If it is false, the texture rect is left unchanged.
///
/// \param shape Shape object
/// \param texture New texture
/// \param resetRect Should the texture rect be reset to the size of the new texture?
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_SetTexture(sfRectangleShape* shape, const sfTexture* texture, sfBool resetRect);
////////////////////////////////////////////////////////////
/// \brief Set the sub-rectangle of the texture that a rectangle shape will display
///
/// The texture rect is useful when you don't want to display
/// the whole texture, but rather a part of it.
/// By default, the texture rect covers the entire texture.
///
/// \param shape Shape object
/// \param rect Rectangle defining the region of the texture to display
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_SetTextureRect(sfRectangleShape* shape, sfIntRect rect);
////////////////////////////////////////////////////////////
/// \brief Set the fill color of a rectangle shape
///
/// This color is modulated (multiplied) with the shape's
/// texture if any. It can be used to colorize the shape,
/// or change its global opacity.
/// You can use sf::Color::Transparent to make the inside of
/// the shape transparent, and have the outline alone.
/// By default, the shape's fill color is opaque white.
///
/// \param shape Shape object
/// \param color New color of the shape
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_SetFillColor(sfRectangleShape* shape, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Set the outline color of a rectangle shape
///
/// You can use sf::Color::Transparent to disable the outline.
/// By default, the shape's outline color is opaque white.
///
/// \param shape Shape object
/// \param color New outline color of the shape
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_SetOutlineColor(sfRectangleShape* shape, sfColor color);
////////////////////////////////////////////////////////////
/// \brief Set the thickness of a rectangle shape's outline
///
/// This number cannot be negative. Using zero disables
/// the outline.
/// By default, the outline thickness is 0.
///
/// \param shape Shape object
/// \param thickness New outline thickness
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_SetOutlineThickness(sfRectangleShape* shape, float thickness);
////////////////////////////////////////////////////////////
/// \brief Get the source texture of a rectangle shape
///
/// If the shape has no source texture, a NULL pointer is returned.
/// The returned pointer is const, which means that you can't
/// modify the texture when you retrieve it with this function.
///
/// \param shape Shape object
///
/// \return Pointer to the shape's texture
///
////////////////////////////////////////////////////////////
CSFML_API const sfTexture* sfRectangleShape_GetTexture(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the sub-rectangle of the texture displayed by a rectangle shape
///
/// \param shape Shape object
///
/// \return Texture rectangle of the shape
///
////////////////////////////////////////////////////////////
CSFML_API sfIntRect sfRectangleShape_GetTextureRect(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the fill color of a rectangle shape
///
/// \param shape Shape object
///
/// \return Fill color of the shape
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfRectangleShape_GetFillColor(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the outline color of a rectangle shape
///
/// \param shape Shape object
///
/// \return Outline color of the shape
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfRectangleShape_GetOutlineColor(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the outline thickness of a rectangle shape
///
/// \param shape Shape object
///
/// \return Outline thickness of the shape
///
////////////////////////////////////////////////////////////
CSFML_API float sfRectangleShape_GetOutlineThickness(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get the total number of points of a rectangle shape
///
/// \param shape Shape object
///
/// \return Number of points of the shape
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfRectangleShape_GetPointCount(const sfRectangleShape* shape);
////////////////////////////////////////////////////////////
/// \brief Get a point of a rectangle shape
///
/// The result is undefined if \a index is out of the valid range.
///
/// \param shape Shape object
/// \param index Index of the point to get, in range [0 .. GetPointCount() - 1]
///
/// \return Index-th point of the shape
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_GetPoint(const sfRectangleShape* shape, unsigned int index, float* x, float* y);
////////////////////////////////////////////////////////////
/// \brief Set the size of a rectangle shape
///
/// \param shape Shape object
/// \param width New width of the rectangle
/// \param height New height of the rectangle
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_SetSize(sfRectangleShape* shape, float width, float height);
////////////////////////////////////////////////////////////
/// \brief Get the size of a rectangle shape
///
/// \param shape Shape object
/// \param width Returned width of the rectangle
/// \param height Returned height of the rectangle
///
////////////////////////////////////////////////////////////
CSFML_API void sfRectangleShape_GetSize(const sfRectangleShape* shape, float* width, float* height);
#endif // SFML_RECTANGLESHAPE_H
+48
View File
@@ -0,0 +1,48 @@
////////////////////////////////////////////////////////////
//
// 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_RENDERSTATES_H
#define SFML_RENDERSTATES_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/BlendMode.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// \brief Define the states used for drawing to a RenderTarget
///
////////////////////////////////////////////////////////////
typedef struct
{
sfBlendMode BlendMode; ///< Blending mode
sfTransform* Transform; ///< Transform
const sfTexture* Texture; ///< Texture
const sfShader* Shader; ///< Shader
} sfRenderStates;
#endif // SFML_RENDERSTATES_H
+119 -76
View File
@@ -32,30 +32,35 @@
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/Graphics/PrimitiveType.h>
#include <SFML/Graphics/RenderStates.h>
#include <SFML/Graphics/Vertex.h>
////////////////////////////////////////////////////////////
/// Construct a new rendertexture
/// \brief Construct a new render texture
///
/// \param width : Width of the rendertexture
/// \param height : Height of the rendertexture
/// \param depthBuffer : Do you want a depth-buffer attached? (useful only if you're doing 3D OpenGL on the rendertexture)
/// \param width Width of the render texture
/// \param height Height of the render texture
/// \param depthBuffer Do you want a depth-buffer attached? (useful only if you're doing 3D OpenGL on the rendertexture)
///
/// \return A new sfRenderTexture object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfRenderTexture* sfRenderTexture_Create(unsigned int width, unsigned int height, sfBool depthBuffer);
////////////////////////////////////////////////////////////
/// Destroy an existing rendertexture
/// \brief Destroy an existing render texture
///
/// \param renderTexture : rendertexture to destroy
/// \param renderTexture Render texture to destroy
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_Destroy(sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// Get the width of the rendering region of a rendertexture
/// \brief Get the width of the rendering region of a render texture
///
/// \param renderTexture : Rendertexture object
/// \param renderTexture Render texture object
///
/// \return Width in pixels
///
@@ -63,9 +68,9 @@ CSFML_API void sfRenderTexture_Destroy(sfRenderTexture* renderTexture);
CSFML_API unsigned int sfRenderTexture_GetWidth(const sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// Get the height of the rendering region of a rendertexture
/// \brief Get the height of the rendering region of a render texture
///
/// \param renderTexture : Rendertexture object
/// \param renderTexture Render texture object
///
/// \return Height in pixels
///
@@ -73,10 +78,10 @@ CSFML_API unsigned int sfRenderTexture_GetWidth(const sfRenderTexture* renderTex
CSFML_API unsigned int sfRenderTexture_GetHeight(const sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// Activate or deactivate a rendertexture as the current target for rendering
/// \brief Activate or deactivate a render texture as the current target for rendering
///
/// \param renderTexture : Rendertexture object
/// \param active : sfTrue to activate, sfFalse to deactivate
/// \param renderTexture Render texture object
/// \param active sfTrue to activate, sfFalse to deactivate
///
/// \return True if operation was successful, false otherwise
///
@@ -84,74 +89,35 @@ CSFML_API unsigned int sfRenderTexture_GetHeight(const sfRenderTexture* renderTe
CSFML_API sfBool sfRenderTexture_SetActive(sfRenderTexture* renderTexture, sfBool active);
////////////////////////////////////////////////////////////
/// Save the current OpenGL render states and matrices
/// \brief Update the contents of the target texture
///
/// \param renderWindow : Renderwindow object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_SaveGLStates(sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// Restore the previously saved OpenGL render states and matrices
///
/// \param renderWindow : Renderwindow object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_RestoreGLStates(sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// Update the contents of the target texture
///
/// \param renderTexture : Rendertexture object
/// \param renderTexture Render texture object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_Display(sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// Draw something on a rendertexture
/// \brief Clear the rendertexture with the given color
///
/// \param renderTexture : Rendertexture to draw in
/// \param sprite / text / shape : Object to draw
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_DrawSprite(sfRenderTexture* renderTexture, const sfSprite* sprite);
CSFML_API void sfRenderTexture_DrawShape (sfRenderTexture* renderTexture, const sfShape* shape);
CSFML_API void sfRenderTexture_DrawText (sfRenderTexture* renderTexture, const sfText* text);
////////////////////////////////////////////////////////////
/// Draw something on a rendertexture with a shader
///
/// \param renderTexture : Rendertexture to draw in
/// \param sprite / text / shape : Object to draw
/// \param shader : Shader to use
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_DrawSpriteWithShader(sfRenderTexture* renderTexture, const sfSprite* sprite, const sfShader* shader);
CSFML_API void sfRenderTexture_DrawShapeWithShader (sfRenderTexture* renderTexture, const sfShape* shape, const sfShader* shader);
CSFML_API void sfRenderTexture_DrawTextWithShader (sfRenderTexture* renderTexture, const sfText* text, const sfShader* shader);
////////////////////////////////////////////////////////////
/// Clear the rendertexture with the given color
///
/// \param renderTexture : Rendertexture to modify
/// \param color : Fill color
/// \param renderTexture Render texture object
/// \param color Fill color
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_Clear(sfRenderTexture* renderTexture, sfColor color);
////////////////////////////////////////////////////////////
/// Change the current active view of a rendertexture
/// \brief Change the current active view of a render texture
///
/// \param renderTexture : Rendertexture to modify
/// \param view : Pointer to the new view
/// \param renderTexture Render texture object
/// \param view Pointer to the new view
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_SetView(sfRenderTexture* renderTexture, const sfView* view);
////////////////////////////////////////////////////////////
/// Get the current active view of a rendertexture
/// \brief Get the current active view of a render texture
///
/// \param renderTexture : Rendertexture
/// \param renderTexture Render texture object
///
/// \return Current active view
///
@@ -159,9 +125,9 @@ CSFML_API void sfRenderTexture_SetView(sfRenderTexture* renderTexture, const sfV
CSFML_API const sfView* sfRenderTexture_GetView(const sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// Get the default view of a rendertexture
/// \brief Get the default view of a render texture
///
/// \param renderTexture : Rendertexture
/// \param renderTexture Render texture object
///
/// \return Default view of the rendertexture
///
@@ -169,10 +135,10 @@ CSFML_API const sfView* sfRenderTexture_GetView(const sfRenderTexture* renderTex
CSFML_API const sfView* sfRenderTexture_GetDefaultView(const sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// Get the viewport of a view applied to this target
/// \brief Get the viewport of a view applied to this target
///
/// \param renderTexture : Rendertexture object
/// \param view : Target view
/// \param renderTexture Render texture object
/// \param view Target view
///
/// \return Viewport rectangle, expressed in pixels in the current target
///
@@ -180,22 +146,99 @@ CSFML_API const sfView* sfRenderTexture_GetDefaultView(const sfRenderTexture* re
CSFML_API sfIntRect sfRenderTexture_GetViewport(const sfRenderTexture* renderTexture, const sfView* view);
////////////////////////////////////////////////////////////
/// Convert a point in texture coordinates into view coordinates
/// \brief Convert a point in texture coordinates into view coordinates
///
/// \param renderTexture : Rendertexture object
/// \param windowX : X coordinate of the point to convert, relative to the texture
/// \param windowY : Y coordinate of the point to convert, relative to the texture
/// \param viewX : Pointer to fill with the X coordinate of the converted point
/// \param viewY : Pointer to fill with the Y coordinate of the converted point
/// \param targetView : Target view to convert the point to (pass NULL to use the current view)
/// \param renderTexture Render texture object
/// \param windowX X coordinate of the point to convert, relative to the texture
/// \param windowY Y coordinate of the point to convert, relative to the texture
/// \param viewX Pointer to fill with the X coordinate of the converted point
/// \param viewY Pointer to fill with the Y coordinate of the converted point
/// \param targetView Target view to convert the point to (pass NULL to use the current view)
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_ConvertCoords(const sfRenderTexture* renderTexture, unsigned int windowX, unsigned int windowY, float* viewX, float* viewY, const sfView* targetView);
////////////////////////////////////////////////////////////
/// Get the target texture
/// \brief Draw a drawable object to the render-target
///
/// \param renderTexture : Render-texture object
/// \param renderTexture Render texture object
/// \param object Object to draw
/// \param states Render states to use for drawing (NULL to use the default states)
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_DrawSprite(sfRenderTexture* renderTexture, const sfSprite* object, const sfRenderStates* states);
CSFML_API void sfRenderTexture_DrawText(sfRenderTexture* renderTexture, const sfText* object, const sfRenderStates* states);
CSFML_API void sfRenderTexture_DrawCircleShape(sfRenderTexture* renderTexture, const sfCircleShape* object, const sfRenderStates* states);
CSFML_API void sfRenderTexture_DrawConvexShape(sfRenderTexture* renderTexture, const sfConvexShape* object, const sfRenderStates* states);
CSFML_API void sfRenderTexture_DrawRectangleShape(sfRenderTexture* renderTexture, const sfRectangleShape* object, const sfRenderStates* states);
CSFML_API void sfRenderTexture_DrawVertexArray(sfRenderTexture* renderTexture, const sfVertexArray* object, const sfRenderStates* states);
////////////////////////////////////////////////////////////
/// \brief Draw primitives defined by an array of vertices to a render texture
///
/// \param renderTexture Render texture object
/// \param vertices Pointer to the vertices
/// \param vertexCount Number of vertices in the array
/// \param type Type of primitives to draw
/// \param states Render states to use for drawing (NULL to use the default states)
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_DrawPrimitives(sfRenderTexture* renderTexture,
const sfVertex* vertices, unsigned int vertexCount,
sfPrimitiveType type, const sfRenderStates* states);
////////////////////////////////////////////////////////////
/// \brief Save the current OpenGL render states and matrices
///
/// This function can be used when you mix SFML drawing
/// and direct OpenGL rendering. Combined with PopGLStates,
/// it ensures that:
/// \li SFML's internal states are not messed up by your OpenGL code
/// \li your OpenGL states are not modified by a call to a SFML function
///
/// Note that this function is quite expensive: it saves all the
/// possible OpenGL states and matrices, even the ones you
/// don't care about. Therefore it should be used wisely.
/// It is provided for convenience, but the best results will
/// be achieved if you handle OpenGL states yourself (because
/// you know which states have really changed, and need to be
/// saved and restored). Take a look at the ResetGLStates
/// function if you do so.
///
/// \param renderTexture Render texture object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_PushGLStates(sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// \brief Restore the previously saved OpenGL render states and matrices
///
/// See the description of PushGLStates to get a detailed
/// description of these functions.
///
/// \param renderTexture Render texture object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_PopGLStates(sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// \brief Reset the internal OpenGL states so that the target is ready for drawing
///
/// This function can be used when you mix SFML drawing
/// and direct OpenGL rendering, if you choose not to use
/// PushGLStates/PopGLStates. It makes sure that all OpenGL
/// states needed by SFML are set, so that subsequent sfRenderTexture_Draw*()
/// calls will work as expected.
///
/// \param renderTexture Render texture object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_ResetGLStates(sfRenderTexture* renderTexture);
////////////////////////////////////////////////////////////
/// \brief Get the target texture of a render texture
///
/// \param renderTexture Render texture object
///
/// \return Pointer to the target texture
///
+173 -141
View File
@@ -32,6 +32,9 @@
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/Graphics/PrimitiveType.h>
#include <SFML/Graphics/RenderStates.h>
#include <SFML/Graphics/Vertex.h>
#include <SFML/Window/Event.h>
#include <SFML/Window/VideoMode.h>
#include <SFML/Window/WindowHandle.h>
@@ -39,53 +42,53 @@
////////////////////////////////////////////////////////////
/// Construct a new renderwindow
/// \brief Construct a new render window
///
/// \param mode : Video mode to use
/// \param title : Title of the window
/// \param style : Window style
/// \param settings : Creation settings (pass NULL to use default values)
/// \param mode Video mode to use
/// \param title Title of the window
/// \param style Window style
/// \param settings Creation settings (pass NULL to use default values)
///
////////////////////////////////////////////////////////////
CSFML_API sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, sfUint32 style, const sfContextSettings* settings);
////////////////////////////////////////////////////////////
/// Construct a renderwindow from an existing control
/// \brief Construct a render window from an existing control
///
/// \param handle : Platform-specific handle of the control
/// \param settings : Creation settings (pass NULL to use default values)
/// \param handle Platform-specific handle of the control
/// \param settings Creation settings (pass NULL to use default values)
///
////////////////////////////////////////////////////////////
CSFML_API sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, const sfContextSettings* settings);
////////////////////////////////////////////////////////////
/// Destroy an existing renderwindow
/// \brief Destroy an existing render window
///
/// \param renderWindow : Renderwindow to destroy
/// \param renderWindow Render window to destroy
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_Destroy(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Close a renderwindow (but doesn't destroy the internal data)
/// \brief Close a render window (but doesn't destroy the internal data)
///
/// \param renderWindow : Renderwindow to close
/// \param renderWindow Render window to close
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_Close(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Tell whether or not a renderwindow is opened
/// \brief Tell whether or not a render window is opened
///
/// \param renderWindow : Renderwindow object
/// \param renderWindow Render window object
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfRenderWindow_IsOpened(const sfRenderWindow* renderWindow);
CSFML_API sfBool sfRenderWindow_IsOpen(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the width of the rendering region of a window
/// \brief Get the width of the rendering region of a render window
///
/// \param renderWindow : Renderwindow object
/// \param renderWindow Render window object
///
/// \return Width in pixels
///
@@ -93,9 +96,9 @@ CSFML_API sfBool sfRenderWindow_IsOpened(const sfRenderWindow* renderWindow);
CSFML_API unsigned int sfRenderWindow_GetWidth(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the height of the rendering region of a window
/// \brief Get the height of the rendering region of a render window
///
/// \param renderWindow : Renderwindow object
/// \param renderWindow Render window object
///
/// \return Height in pixels
///
@@ -103,9 +106,9 @@ CSFML_API unsigned int sfRenderWindow_GetWidth(const sfRenderWindow* renderWindo
CSFML_API unsigned int sfRenderWindow_GetHeight(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the creation settings of a window
/// \brief Get the creation settings of a render window
///
/// \param renderWindow : Renderwindow object
/// \param renderWindow Render window object
///
/// \return Settings used to create the window
///
@@ -113,10 +116,10 @@ CSFML_API unsigned int sfRenderWindow_GetHeight(const sfRenderWindow* renderWind
CSFML_API sfContextSettings sfRenderWindow_GetSettings(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the event on top of events stack of a window, if any, and pop it
/// \brief Get the event on top of events stack of a render window, if any, and pop it
///
/// \param renderWindow : Renderwindow object
/// \param event : Event to fill, if any
/// \param renderWindow Render window object
/// \param event Event to fill, if any
///
/// \return sfTrue if an event was returned, sfFalse if events stack was empty
///
@@ -124,10 +127,10 @@ CSFML_API sfContextSettings sfRenderWindow_GetSettings(const sfRenderWindow* ren
CSFML_API sfBool sfRenderWindow_PollEvent(sfRenderWindow* renderWindow, sfEvent* event);
////////////////////////////////////////////////////////////
/// Wait for an event and return it
/// \brief Wait for an event and return it
///
/// \param renderWindow : Renderwindow object
/// \param event : Event to fill
/// \param renderWindow Render window object
/// \param event Event to fill
///
/// \return sfFalse if an error occured
///
@@ -135,88 +138,90 @@ CSFML_API sfBool sfRenderWindow_PollEvent(sfRenderWindow* renderWindow, sfEvent*
CSFML_API sfBool sfRenderWindow_WaitEvent(sfRenderWindow* renderWindow, sfEvent* event);
////////////////////////////////////////////////////////////
/// Enable / disable vertical synchronization on a window
/// \brief Enable / disable vertical synchronization on a render window
///
/// \param renderWindow : Renderwindow object
/// \param enabled : sfTrue to enable v-sync, sfFalse to deactivate
/// \param renderWindow Render window object
/// \param enabled sfTrue to enable v-sync, sfFalse to deactivate
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_EnableVerticalSync(sfRenderWindow* renderWindow, sfBool enabled);
////////////////////////////////////////////////////////////
/// Show or hide the mouse cursor on a window
/// \brief Show or hide the mouse cursor on a render window
///
/// \param renderWindow : RenderWindow object
/// \param show : sfTrue to show, sfFalse to hide
/// \param renderWindow Render window object
/// \param show sfTrue to show, sfFalse to hide
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show);
////////////////////////////////////////////////////////////
/// Change the position of a window on screen.
/// \brief Change the position of a render window on screen
///
/// Only works for top-level windows
///
/// \param renderWindow : Renderwindow object
/// \param left : Left position
/// \param top : Top position
/// \param renderWindow Render window object
/// \param left Left position
/// \param top Top position
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, int left, int top);
////////////////////////////////////////////////////////////
/// Change the size of the rendering region of a window
/// \brief Change the size of the rendering region of a render window
///
/// \param renderWindow : Renderwindow object
/// \param width : New Width
/// \param height : New Height
/// \param renderWindow Render window object
/// \param width New Width
/// \param height New Height
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, unsigned int width, unsigned int height);
////////////////////////////////////////////////////////////
/// Change the title of a window
/// \brief Change the title of a render window
///
/// \param renderWindow : Renderwindow object
/// \param title : New title
/// \param renderWindow Render window object
/// \param title New title
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetTitle(sfRenderWindow* renderWindow, const char* title);
////////////////////////////////////////////////////////////
/// Show or hide a window
/// \brief Show or hide a render window
///
/// \param renderWindow : Renderwindow object
/// \param show : sfTrue to show, sfFalse to hide
/// \param renderWindow Render window object
/// \param show sfTrue to show, sfFalse to hide
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_Show(sfRenderWindow* renderWindow, sfBool show);
////////////////////////////////////////////////////////////
/// Enable or disable automatic key-repeat for keydown events.
/// \brief Enable or disable automatic key-repeat for keydown events
///
/// Automatic key-repeat is enabled by default
///
/// \param renderWindow : Renderwindow object
/// \param enabled : sfTrue to enable, sfFalse to disable
/// \param renderWindow Render window object
/// \param enabled sfTrue to enable, sfFalse to disable
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_EnableKeyRepeat(sfRenderWindow* renderWindow, sfBool enabled);
////////////////////////////////////////////////////////////
/// Change the window's icon
/// \brief Change a render window's icon
///
/// \param renderWindow : Renderwindow 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
/// \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_API void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels);
////////////////////////////////////////////////////////////
/// Activate or deactivate a window as the current target for rendering
/// \brief Activate or deactivate a render window as the current target for rendering
///
/// \param renderWindow : Renderwindow object
/// \param active : sfTrue to activate, sfFalse to deactivate
/// \param renderWindow Render window object
/// \param active sfTrue to activate, sfFalse to deactivate
///
/// \return True if operation was successful, false otherwise
///
@@ -224,62 +229,35 @@ CSFML_API void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int
CSFML_API sfBool sfRenderWindow_SetActive(sfRenderWindow* renderWindow, sfBool active);
////////////////////////////////////////////////////////////
/// Save the current OpenGL render states and matrices
/// \brief Display a render window on screen
///
/// \param renderWindow : Renderwindow object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SaveGLStates(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Restore the previously saved OpenGL render states and matrices
///
/// \param renderWindow : Renderwindow object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_RestoreGLStates(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Display a window on screen
///
/// \param renderWindow : Renderwindow object
/// \param renderWindow Render window object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_Display(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Limit the framerate to a maximum fixed frequency for a window
/// \brief Limit the framerate to a maximum fixed frequency for a render window
///
/// \param renderWindow : Renderwindow object
/// \param limit : Framerate limit, in frames per seconds (use 0 to disable limit)
/// \param renderWindow Render window object
/// \param limit Framerate limit, in frames per seconds (use 0 to disable limit)
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetFramerateLimit(sfRenderWindow* renderWindow, unsigned int limit);
////////////////////////////////////////////////////////////
/// Get time elapsed since last frame of a window
/// \brief Change the joystick threshold, ie. the value below which no move event will be generated
///
/// \param renderWindow : Renderwindow object
///
/// \return Time elapsed, in milliseconds
///
////////////////////////////////////////////////////////////
CSFML_API sfUint32 sfRenderWindow_GetFrameTime(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Change the joystick threshold, ie. the value below which
/// no move event will be generated
///
/// \param renderWindow : Renderwindow object
/// \param threshold : New threshold, in range [0, 100]
/// \param renderWindow Render window object
/// \param threshold New threshold, in range [0, 100]
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow, float threshold);
////////////////////////////////////////////////////////////
/// Retrieve the Os-specific handle of a window
/// \brief Retrieve the OS-specific handle of a render window
///
/// \param renderWindow : Renderwindow object
/// \param renderWindow Render window object
///
/// \return Window handle
///
@@ -287,50 +265,27 @@ CSFML_API void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow,
CSFML_API sfWindowHandle sfRenderWindow_GetSystemHandle(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Draw something on a renderwindow
/// \brief Clear a render window with the given color
///
/// \param renderWindow : Renderwindow to draw in
/// \param sprite / text / shape : Object to draw
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_DrawSprite(sfRenderWindow* renderWindow, const sfSprite* sprite);
CSFML_API void sfRenderWindow_DrawShape (sfRenderWindow* renderWindow, const sfShape* shape);
CSFML_API void sfRenderWindow_DrawText (sfRenderWindow* renderWindow, const sfText* text);
////////////////////////////////////////////////////////////
/// Draw something on a renderwindow with a shader
///
/// \param renderWindow : Renderwindow to draw in
/// \param sprite / text / shape : Object to draw
/// \param shader : Shader to use
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_DrawSpriteWithShader(sfRenderWindow* renderWindow, const sfSprite* sprite, const sfShader* shader);
CSFML_API void sfRenderWindow_DrawShapeWithShader (sfRenderWindow* renderWindow, const sfShape* shape, const sfShader* shader);
CSFML_API void sfRenderWindow_DrawTextWithShader (sfRenderWindow* renderWindow, const sfText* text, const sfShader* shader);
////////////////////////////////////////////////////////////
/// Clear the screen with the given color
///
/// \param renderWindow : Renderwindow to modify
/// \param color : Fill color
/// \param renderWindow Render window object
/// \param color Fill color
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_Clear(sfRenderWindow* renderWindow, sfColor color);
////////////////////////////////////////////////////////////
/// Change the current active view of a renderwindow
/// \brief Change the current active view of a render window
///
/// \param renderWindow : Renderwindow to modify
/// \param view : Pointer to the new view
/// \param renderWindow Render window object
/// \param view Pointer to the new view
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetView(sfRenderWindow* renderWindow, const sfView* view);
////////////////////////////////////////////////////////////
/// Get the current active view of a renderwindow
/// \brief Get the current active view of a render window
///
/// \param renderWindow : Renderwindow
/// \param renderWindow Render window object
///
/// \return Current active view
///
@@ -338,9 +293,9 @@ CSFML_API void sfRenderWindow_SetView(sfRenderWindow* renderWindow, const sfView
CSFML_API const sfView* sfRenderWindow_GetView(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the default view of a renderwindow
/// \brief Get the default view of a render window
///
/// \param renderWindow : Renderwindow
/// \param renderWindow Render window object
///
/// \return Default view of the render window
///
@@ -348,10 +303,10 @@ CSFML_API const sfView* sfRenderWindow_GetView(const sfRenderWindow* renderWindo
CSFML_API const sfView* sfRenderWindow_GetDefaultView(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the viewport of a view applied to this target
/// \brief Get the viewport of a view applied to this target
///
/// \param renderWindow : Renderwindow
/// \param view : Target view
/// \param renderWindow Render window object
/// \param view Target view
///
/// \return Viewport rectangle, expressed in pixels in the current target
///
@@ -359,20 +314,97 @@ CSFML_API const sfView* sfRenderWindow_GetDefaultView(const sfRenderWindow* rend
CSFML_API sfIntRect sfRenderWindow_GetViewport(const sfRenderWindow* renderWindow, const sfView* view);
////////////////////////////////////////////////////////////
/// Convert a point in window coordinates into view coordinates
/// \brief Convert a point in window coordinates into view coordinates
///
/// \param renderWindow : Target Renderwindow
/// \param windowX : X coordinate of the point to convert, relative to the window
/// \param windowY : Y coordinate of the point to convert, relative to the window
/// \param viewX : Pointer to fill with the X coordinate of the converted point
/// \param viewY : Pointer to fill with the Y coordinate of the converted point
/// \param targetView : Target view to convert the point to (pass NULL to use the current view)
/// \param renderWindow Render window object
/// \param windowX X coordinate of the point to convert, relative to the window
/// \param windowY Y coordinate of the point to convert, relative to the window
/// \param viewX Pointer to fill with the X coordinate of the converted point
/// \param viewY Pointer to fill with the Y coordinate of the converted point
/// \param targetView Target view to convert the point to (pass NULL to use the current view)
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_ConvertCoords(const sfRenderWindow* renderWindow, unsigned int windowX, unsigned int windowY, float* viewX, float* viewY, const sfView* targetView);
////////////////////////////////////////////////////////////
/// Copy the current contents of a window to an image
/// \brief Draw a drawable object to the render-target
///
/// \param renderWindow render window object
/// \param object Object to draw
/// \param states Render states to use for drawing (NULL to use the default states)
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_DrawSprite(sfRenderWindow* renderWindow, const sfSprite* object, const sfRenderStates* states);
CSFML_API void sfRenderWindow_DrawText(sfRenderWindow* renderWindow, const sfText* object, const sfRenderStates* states);
CSFML_API void sfRenderWindow_DrawCircleShape(sfRenderWindow* renderWindow, const sfCircleShape* object, const sfRenderStates* states);
CSFML_API void sfRenderWindow_DrawConvexShape(sfRenderWindow* renderWindow, const sfConvexShape* object, const sfRenderStates* states);
CSFML_API void sfRenderWindow_DrawRectangleShape(sfRenderWindow* renderWindow, const sfRectangleShape* object, const sfRenderStates* states);
CSFML_API void sfRenderWindow_DrawVertexArray(sfRenderWindow* renderWindow, const sfVertexArray* object, const sfRenderStates* states);
////////////////////////////////////////////////////////////
/// \brief Draw primitives defined by an array of vertices to a render window
///
/// \param renderWindow render window object
/// \param vertices Pointer to the vertices
/// \param vertexCount Number of vertices in the array
/// \param type Type of primitives to draw
/// \param states Render states to use for drawing (NULL to use the default states)
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_DrawPrimitives(sfRenderWindow* renderWindow,
const sfVertex* vertices, unsigned int vertexCount,
sfPrimitiveType type, const sfRenderStates* states);
////////////////////////////////////////////////////////////
/// \brief Save the current OpenGL render states and matrices
///
/// This function can be used when you mix SFML drawing
/// and direct OpenGL rendering. Combined with PopGLStates,
/// it ensures that:
/// \li SFML's internal states are not messed up by your OpenGL code
/// \li your OpenGL states are not modified by a call to a SFML function
///
/// Note that this function is quite expensive: it saves all the
/// possible OpenGL states and matrices, even the ones you
/// don't care about. Therefore it should be used wisely.
/// It is provided for convenience, but the best results will
/// be achieved if you handle OpenGL states yourself (because
/// you know which states have really changed, and need to be
/// saved and restored). Take a look at the ResetGLStates
/// function if you do so.
///
/// \param renderWindow render window object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_PushGLStates(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Restore the previously saved OpenGL render states and matrices
///
/// See the description of PushGLStates to get a detailed
/// description of these functions.
///
/// \param renderWindow render window object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_PopGLStates(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Reset the internal OpenGL states so that the target is ready for drawing
///
/// This function can be used when you mix SFML drawing
/// and direct OpenGL rendering, if you choose not to use
/// PushGLStates/PopGLStates. It makes sure that all OpenGL
/// states needed by SFML are set, so that subsequent sfRenderWindow_Draw*()
/// calls will work as expected.
///
/// \param renderWindow render window object
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_ResetGLStates(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// \brief Copy the current contents of a render window to an image
///
/// This is a slow operation, whose main purpose is to make
/// screenshots of the application. If you want to update an
@@ -380,9 +412,9 @@ CSFML_API void sfRenderWindow_ConvertCoords(const sfRenderWindow* renderWindow,
/// drawing, you should rather use a sfTexture and its
/// Update(sfWindow*) function.
/// You can also draw things directly to a texture with the
/// sfRenderTexture class.
/// sfRenderWindow class.
///
/// \param renderWindow : Render window to capture
/// \param renderWindow Render window object
///
/// \return New image containing the captured contents
///
+234 -56
View File
@@ -29,137 +29,315 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/InputStream.h>
////////////////////////////////////////////////////////////
/// Create a new shader from a file
/// \brief Load both the vertex and fragment shaders from files
///
/// \param filename : File to load
/// This function can load both the vertex and the fragment
/// shaders, or only one of them: pass NULL if you don't want to load
/// either the vertex shader or the fragment shader.
/// The sources must be text files containing valid shaders
/// in GLSL language. GLSL is a C-like language dedicated to
/// OpenGL shaders; you'll probably need to read a good documentation
/// for it before writing your own shaders.
///
/// \param vertexShaderFilename Path of the vertex shader file to load, or NULL to skip this shader
/// \param fragmentShaderFilename Path of the fragment shader file to load, or NULL to skip this shader
///
/// \return A new sfShader object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfShader* sfShader_CreateFromFile(const char* filename);
CSFML_API sfShader* sfShader_CreateFromFile(const char* vertexShaderFilename, const char* fragmentShaderFilename);
////////////////////////////////////////////////////////////
/// Create a new shader from an effect source code
/// \brief Load both the vertex and fragment shaders from source codes in memory
///
/// \param effect : Source code of the effect
/// This function can load both the vertex and the fragment
/// shaders, or only one of them: pass NULL if you don't want to load
/// either the vertex shader or the fragment shader.
/// The sources must be valid shaders in GLSL language. GLSL is
/// a C-like language dedicated to OpenGL shaders; you'll
/// probably need to read a good documentation for it before
/// writing your own shaders.
///
/// \param vertexShader String containing the source code of the vertex shader, or NULL to skip this shader
/// \param fragmentShader String containing the source code of the fragment shader, or NULL to skip this shader
///
/// \return A new sfShader object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfShader* sfShader_CreateFromMemory(const char* effect);
CSFML_API sfShader* sfShader_CreateFromMemory(const char* vertexShader, const char* fragmentShader);
////////////////////////////////////////////////////////////
/// Create a new shader from a custom stream
/// \brief Load both the vertex and fragment shaders from custom streams
///
/// \param stream : Source stream to read from
/// This function can load both the vertex and the fragment
/// shaders, or only one of them: pass NULL if you don't want to load
/// either the vertex shader or the fragment shader.
/// The source codes must be valid shaders in GLSL language.
/// GLSL is a C-like language dedicated to OpenGL shaders;
/// you'll probably need to read a good documentation for
/// it before writing your own shaders.
///
/// \param vertexShaderStream Source stream to read the vertex shader from, or NULL to skip this shader
/// \param fragmentShaderStream Source stream to read the fragment shader from, or NULL to skip this shader
///
/// \return A new sfShader object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfShader* sfShader_CreateFromStream(sfInputStream* stream);
CSFML_API sfShader* sfShader_CreateFromStream(sfInputStream* vertexShaderStream, sfInputStream* fragmentShaderStream);
////////////////////////////////////////////////////////////
/// Copy an existing shader
/// \brief Destroy an existing shader
///
/// \param shader : Shader to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfShader* sfShader_Copy(sfShader* shader);
////////////////////////////////////////////////////////////
/// Destroy an existing shader
///
/// \param shader : Shader to delete
/// \param shader Shader to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_Destroy(sfShader* shader);
////////////////////////////////////////////////////////////
/// Change a parameter of a shader (1 float)
/// \brief Change a float parameter of a shader
///
/// \param shader : Shader to modify
/// \param name : Parameter name in the effect
/// \param x : Value to assign
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a float
/// (float GLSL type).
///
/// Example:
/// \code
/// uniform float myparam; // this is the variable in the shader
/// \endcode
/// \code
/// sfShader_SetFloatParameter(shader, "myparam", 5.2f);
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param x Value to assign
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetParameter1(sfShader* shader, const char* name, float x);
CSFML_API void sfShader_SetFloatParameter(sfShader* shader, const char* name, float x);
////////////////////////////////////////////////////////////
/// Change a parameter of a shader (2 floats)
/// \brief Change a 2-components vector parameter of a shader
///
/// \param shader : Shader to modify
/// \param name : Parameter name in the effect
/// \param x, y : Values to assign
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 2x1 vector
/// (vec2 GLSL type).
///
/// Example:
/// \code
/// uniform vec2 myparam; // this is the variable in the shader
/// \endcode
/// \code
/// sfShader_SetFloat2Parameter(shader, "myparam", 5.2f, 6.0f);
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param x First component of the value to assign
/// \param y Second component of the value to assign
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetParameter2(sfShader* shader, const char* name, float x, float y);
CSFML_API void sfShader_SetFloat2Parameter(sfShader* shader, const char* name, float x, float y);
////////////////////////////////////////////////////////////
/// Change a parameter of a shader (3 floats)
/// \brief Change a 3-components vector parameter of a shader
///
/// \param shader : Shader to modify
/// \param name : Parameter name in the effect
/// \param x, y, z : Values to assign
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 3x1 vector
/// (vec3 GLSL type).
///
/// Example:
/// \code
/// uniform vec3 myparam; // this is the variable in the shader
/// \endcode
/// \code
/// sfShader_SetFloat3Parameter(shader, "myparam", 5.2f, 6.0f, -8.1f);
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param x First component of the value to assign
/// \param y Second component of the value to assign
/// \param z Third component of the value to assign
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetParameter3(sfShader* shader, const char* name, float x, float y, float z);
CSFML_API void sfShader_SetFloat3Parameter(sfShader* shader, const char* name, float x, float y, float z);
////////////////////////////////////////////////////////////
/// Change a parameter of a shader (4 floats)
/// \brief Change a 4-components vector parameter of a shader
///
/// \param shader : Shader to modify
/// \param name : Parameter name in the effect
/// \param x, y, z, w : Values to assign
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 4x1 vector
/// (vec4 GLSL type).
///
/// Example:
/// \code
/// uniform vec4 myparam; // this is the variable in the shader
/// \endcode
/// \code
/// sfShader_SetFloat4Parameter(shader, "myparam", 5.2f, 6.0f, -8.1f, 0.4f);
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param x First component of the value to assign
/// \param y Second component of the value to assign
/// \param z Third component of the value to assign
/// \param w Fourth component of the value to assign
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetParameter4(sfShader* shader, const char* name, float x, float y, float z, float w);
CSFML_API void sfShader_SetFloat4Parameter(sfShader* shader, const char* name, float x, float y, float z, float w);
////////////////////////////////////////////////////////////
/// Set a texture parameter in a shader
/// \brief Change a color parameter of a shader
///
/// \param shader : Shader to modify
/// \param name : Texture name in the effect
/// \param texture : Texture to set
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 4x1 vector
/// (vec4 GLSL type).
///
/// It is important to note that the components of the color are
/// normalized before being passed to the shader. Therefore,
/// they are converted from range [0 .. 255] to range [0 .. 1].
/// For example, a sf::Color(255, 125, 0, 255) will be transformed
/// to a vec4(1.0, 0.5, 0.0, 1.0) in the shader.
///
/// Example:
/// \code
/// uniform vec4 color; // this is the variable in the shader
/// \endcode
/// \code
/// sfShader_SetColorParameter(shader, "color", sfColor_FromRGB(255, 128, 0));
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param color Color to assign
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetTexture(sfShader* shader, const char* name, const sfTexture* texture);
CSFML_API void sfShader_SetColorParameter(sfShader* shader, const char* name, sfColor color);
////////////////////////////////////////////////////////////
/// Set the current texture parameter in a shader
/// \brief Change a matrix parameter of a shader
///
/// \param shader : Shader to modify
/// \param name : Texture name in the effect
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 4x4 matrix
/// (mat4 GLSL type).
///
/// Example:
/// \code
/// uniform mat4 matrix; // this is the variable in the shader
/// \endcode
/// \code
/// @todo
/// sfShader_SetTransformParameter(shader, "matrix", transform);
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the parameter in the shader
/// \param transform Transform to assign
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetCurrentTexture(sfShader* shader, const char* name);
CSFML_API void sfShader_SetTransformParameter(sfShader* shader, const char* name, const sfTransform* transform);
////////////////////////////////////////////////////////////
/// Bind a shader for rendering
/// \brief Change a texture parameter of a shader
///
/// \param shader : Shader to bind
/// \a name is the name of the variable to change in the shader.
/// The corresponding parameter in the shader must be a 2D texture
/// (sampler2D GLSL type).
///
/// Example:
/// \code
/// uniform sampler2D the_texture; // this is the variable in the shader
/// \endcode
/// \code
/// sf::Texture texture;
/// ...
/// sfShader_SetTextureParameter(shader, "the_texture", texture);
/// \endcode
/// It is important to note that \a texture must remain alive as long
/// as the shader uses it, no copy is made internally.
///
/// To use the texture of the object being draw, which cannot be
/// known in advance, you can use the special function
/// sfShader_SetCurrentTextureParameter:
/// \code
/// sfShader_SetCurrentTextureParameter(shader, "the_texture").
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the texture in the shader
/// \param texture Texture to assign
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetTextureParameter(sfShader* shader, const char* name, const sfTexture* texture);
////////////////////////////////////////////////////////////
/// \brief Change a texture parameter of a shader
///
/// This function maps a shader texture variable to the
/// texture of the object being drawn, which cannot be
/// known in advance.
/// The corresponding parameter in the shader must be a 2D texture
/// (sampler2D GLSL type).
///
/// Example:
/// \code
/// uniform sampler2D current; // this is the variable in the shader
/// \endcode
/// \code
/// sfShader_SetCurrentTextureParameter(shader, "current");
/// \endcode
///
/// \param shader Shader object
/// \param name Name of the texture in the shader
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_SetCurrentTextureParameter(sfShader* shader, const char* name);
////////////////////////////////////////////////////////////
/// \brief Bind a shader for rendering (activate it)
///
/// This function is normally for internal use only, unless
/// you want to use the shader with a custom OpenGL rendering
/// instead of a SFML drawable.
/// \code
/// sfWindow_SetActive(window, sfTrue);
/// sfShader_Bind(shader);
/// ... render OpenGL geometry ...
/// sfShader_Unbind(shader);
/// \endcode
///
/// \param shader Shader to bind
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_Bind(const sfShader* shader);
////////////////////////////////////////////////////////////
/// Unbind a shader
/// \brief Unbind a shader (deactivate it)
///
/// \param shader : Shader to unbind
/// This function is normally for internal use only, unless
/// you want to use the shader with a custom OpenGL rendering
/// instead of a SFML drawable.
///
/// \param shader Shader to unbind
///
////////////////////////////////////////////////////////////
CSFML_API void sfShader_Unbind(const sfShader* shader);
////////////////////////////////////////////////////////////
/// Tell whether or not the system supports shaders
/// \brief Tell whether or not the system supports shaders
///
/// \return sfTrue if the system can use shaders
/// This function should always be called before using
/// the shader features. If it returns false, then
/// any attempt to use sfShader will fail.
///
/// \return sfTrue if the system can use shaders, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfShader_IsAvailable(void);
-464
View File
@@ -1,464 +0,0 @@
////////////////////////////////////////////////////////////
//
// 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_SHAPE_H
#define SFML_SHAPE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/BlendMode.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// Create a new shape
///
/// \return A new sfShape object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfShape* sfShape_Create(void);
////////////////////////////////////////////////////////////
/// Create a new shape made of a single line
///
/// \param p1x, p1y : Position of the first point
/// \param p2x, p2y : Position second point
/// \param thickness : Line thickness
/// \param color : Color used to draw the line
/// \param outline : Outline thickness
/// \param outlineColor : Color used to draw the outline
///
////////////////////////////////////////////////////////////
CSFML_API sfShape* sfShape_CreateLine(float p1x, float p1y, float p2x, float p2y, float thickness, sfColor color, float outline, sfColor outlineColor);
////////////////////////////////////////////////////////////
/// Create a new shape made of a single rectangle
///
/// \param left, top : Top-left corner of the rectangle
/// \param width, height : Size of the rectangle
/// \param color : Color used to fill the rectangle
/// \param outline : Outline thickness
/// \param outlineColor : Color used to draw the outline
///
////////////////////////////////////////////////////////////
CSFML_API sfShape* sfShape_CreateRectangle(float left, float top, float width, float height, sfColor color, float outline, sfColor outlineColor);
////////////////////////////////////////////////////////////
/// Create a new shape made of a single circle
///
/// \param x, y : Position of the center
/// \param radius : Radius
/// \param color : Color used to fill the circle
/// \param outline : Outline thickness
/// \param outlineColor : Color used to draw the outline
///
////////////////////////////////////////////////////////////
CSFML_API sfShape* sfShape_CreateCircle(float x, float y, float radius, sfColor color, float outline, sfColor outlineColor);
////////////////////////////////////////////////////////////
/// Copy an existing shape
///
/// \param shape : Shape to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfShape* sfShape_Copy(sfShape* shape);
////////////////////////////////////////////////////////////
/// Destroy an existing Shape
///
/// \param Shape : Shape to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_Destroy(sfShape* shape);
////////////////////////////////////////////////////////////
/// Set the X position of a shape
///
/// \param shape : Shape to modify
/// \param x : New X coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetX(sfShape* shape, float x);
////////////////////////////////////////////////////////////
/// Set the Y position of a shape
///
/// \param shape : Shape to modify
/// \param y : New Y coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetY(sfShape* shape, float y);
////////////////////////////////////////////////////////////
/// Set the position of a shape
///
/// \param shape : Shape to modify
/// \param x : New X coordinate
/// \param y : New Y coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetPosition(sfShape* shape, float x, float y);
////////////////////////////////////////////////////////////
/// Set the horizontal scale of a shape
///
/// \param shape : Shape to modify
/// \param scale : New scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetScaleX(sfShape* shape, float scale);
////////////////////////////////////////////////////////////
/// Set the vertical scale of a shape
///
/// \param shape : Shape to modify
/// \param scale : New scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetScaleY(sfShape* shape, float scale);
////////////////////////////////////////////////////////////
/// Set the scale of a shape
///
/// \param shape : Shape to modify
/// \param scaleX : New horizontal scale (must be strictly positive)
/// \param scaleY : New vertical scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetScale(sfShape* shape, float scaleX, float scaleY);
////////////////////////////////////////////////////////////
/// Set the orientation of a shape
///
/// \param shape : Shape to modify
/// \param rotation : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetRotation(sfShape* shape, float rotation);
////////////////////////////////////////////////////////////
/// Set the local origin of a shape, in coordinates relative to
/// its left-top corner
///
/// \param shape : Shape to modify
/// \param x : X coordinate of the origin
/// \param y : Y coordinate of the origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetOrigin(sfShape* shape, float x, float y);
////////////////////////////////////////////////////////////
/// Set the color of a shape
///
/// \param shape : Shape to modify
/// \param color : New color
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetColor(sfShape* shape, sfColor color);
////////////////////////////////////////////////////////////
/// Set the blending mode for a shape
///
/// \param shape : Shape to modify
/// \param mode : New blending mode
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetBlendMode(sfShape* shape, sfBlendMode mode);
////////////////////////////////////////////////////////////
/// Get the X position of a shape
///
/// \param shape : Shape to read
///
/// \return Current X position
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetX(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the Y position of a shape
///
/// \param shape : Shape to read
///
/// \return Current Y position
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetY(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the horizontal scale of a shape
///
/// \param shape : Shape to read
///
/// \return Current X scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetScaleX(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the vertical scale of a shape
///
/// \param shape : Shape to read
///
/// \return Current Y scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetScaleY(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the orientation of a shape
///
/// \param shape : Shape to read
///
/// \return Current rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetRotation(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the X position of the origin a shape
///
/// \param shape : Shape to read
///
/// \return Current X origin
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetOriginX(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the Y position of the origin a shape
///
/// \param shape : Shape to read
///
/// \return Current Y origin
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetOriginY(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the color of a shape
///
/// \param shape : Shape to read
///
/// \return Current color
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfShape_GetColor(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the current blending mode of a shape
///
/// \param shape : Shape to read
///
/// \return Current blending mode
///
////////////////////////////////////////////////////////////
CSFML_API sfBlendMode sfShape_GetBlendMode(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Move a shape
///
/// \param shape : Shape to modify
/// \param offsetX : Offset on the X axis
/// \param offsetY : Offset on the Y axis
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_Move(sfShape* shape, float offsetX, float offsetY);
////////////////////////////////////////////////////////////
/// Scale a shape
///
/// \param shape : Shape to modify
/// \param factorX : Horizontal scaling factor (must be strictly positive)
/// \param factorY : Vertical scaling factor (must be strictly positive)
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_Scale(sfShape* shape, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// Rotate a shape
///
/// \param shape : Shape to modify
/// \param angle : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_Rotate(sfShape* shape, float angle);
////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into the shape's local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
///
/// \param shape : Shape object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_TransformToLocal(const sfShape* shape, float pointX, float pointY, float* x, float* y);
////////////////////////////////////////////////////////////
/// Transform a point from the shape's local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
///
/// \param shape : Shape object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_TransformToGlobal(const sfShape* shape, float pointX, float pointY, float* x, float* y);
////////////////////////////////////////////////////////////
/// Add a point to a shape
///
/// \param shape : Shape to modify
/// \param x, y : Position of the point
/// \param color : Color of the point
/// \param outlineColor : Outline color of the point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_AddPoint(sfShape* shape, float x, float y, sfColor color, sfColor outlineColor);
////////////////////////////////////////////////////////////
/// Enable or disable filling a shape.
/// Fill is enabled by default
///
/// \param shape : Shape to modify
/// \param enable : True to enable, false to disable
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_EnableFill(sfShape* shape, sfBool enable);
////////////////////////////////////////////////////////////
/// Enable or disable drawing a shape outline.
/// Outline is enabled by default
///
/// \param shape : Shape to modify
/// \param enable : True to enable, false to disable
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_EnableOutline(sfShape* shape, sfBool enable);
////////////////////////////////////////////////////////////
/// Change the thickness of a shape outline
///
/// \param shape : Shape to modify
/// \param thickness : New thickness
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetOutlineThickness(sfShape* shape, float thickness);
////////////////////////////////////////////////////////////
/// Get the thickness of a shape outline
///
/// \param shape : Shape to read
///
/// \param return Current outline thickness
///
////////////////////////////////////////////////////////////
CSFML_API float sfShape_GetOutlineThickness(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get the number of points composing a shape
///
/// \param shape : Shape to read
///
/// \return Total number of points
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfShape_GetPointsCount(const sfShape* shape);
////////////////////////////////////////////////////////////
/// Get a the position of a shape's point
///
/// \param shape : Shape to read
/// \param index : Index of the point to get
/// \param x : Variable to fill with the X coordinate of the point
/// \param y : Variable to fill with the Y coordinate of the point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_GetPointPosition(const sfShape* shape, unsigned int index, float* x, float* y);
////////////////////////////////////////////////////////////
/// Get a the color of a shape's point
///
/// \param shape : Shape to read
/// \param index : Index of the point to get
///
/// \return Color of the point
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfShape_GetPointColor(const sfShape* shape, unsigned int index);
////////////////////////////////////////////////////////////
/// Get a the outline color of a shape's point
///
/// \param shape : Shape to read
/// \param index : Index of the point to get
///
/// \return Outline color of the point
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfShape_GetPointOutlineColor(const sfShape* shape, unsigned int index);
////////////////////////////////////////////////////////////
/// Set a the position of a shape's point
///
/// \param shape : Shape to read
/// \param index : Index of the point to get
/// \param x : X coordinate of the point
/// \param y : Y coordinate of the point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetPointPosition(sfShape* shape, unsigned int index, float x, float y);
////////////////////////////////////////////////////////////
/// Set a the color of a shape's point
///
/// \param shape : Shape to read
/// \param index : Index of the point to get
/// \param color : Color of the point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetPointColor(sfShape* shape, unsigned int index, sfColor color);
////////////////////////////////////////////////////////////
/// Set a the outline color of a shape's point
///
/// \param shape : Shape to read
/// \param index : Index of the point to get
/// \param color : Outline color of the point
///
////////////////////////////////////////////////////////////
CSFML_API void sfShape_SetPointOutlineColor(sfShape* shape, unsigned int index, sfColor color);
#endif // SFML_SHAPE_H
+130 -217
View File
@@ -36,7 +36,7 @@
////////////////////////////////////////////////////////////
/// Create a new sprite
/// \brief Create a new sprite
///
/// \return A new sfSprite object, or NULL if it failed
///
@@ -44,9 +44,9 @@
CSFML_API sfSprite* sfSprite_Create(void);
////////////////////////////////////////////////////////////
/// Copy an existing sprite
/// \brief Copy an existing sprite
///
/// \param sprite : Sprite to copy
/// \param sprite Sprite to copy
///
/// \return Copied object
///
@@ -54,151 +54,87 @@ CSFML_API sfSprite* sfSprite_Create(void);
CSFML_API sfSprite* sfSprite_Copy(sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Destroy an existing sprite
/// \brief Destroy an existing sprite
///
/// \param sprite : Sprite to delete
/// \param sprite Sprite to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_Destroy(sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Set the X position of a sprite
/// \brief Set the position of a sprite
///
/// \param sprite : Sprite to modify
/// \param x : New X coordinate
/// This function completely overwrites the previous position.
/// See sfSprite_Move to apply an offset based on the previous position instead.
/// The default position of a sprite object is (0, 0).
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetX(sfSprite* sprite, float x);
////////////////////////////////////////////////////////////
/// Set the T position of a sprite
///
/// \param sprite : Sprite to modify
/// \param y : New Y coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetY(sfSprite* sprite, float y);
////////////////////////////////////////////////////////////
/// Set the position of a sprite
///
/// \param sprite : Sprite to modify
/// \param x : New X coordinate
/// \param y : New Y coordinate
/// \param sprite Sprite object
/// \param x X coordinate of the new position
/// \param y Y coordinate of the new position
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetPosition(sfSprite* sprite, float x, float y);
////////////////////////////////////////////////////////////
/// Set the horizontal scale of a sprite
/// \brief Set the orientation of a sprite
///
/// \param sprite : Sprite to modify
/// \param scale : New scale (must be strictly positive)
/// This function completely overwrites the previous rotation.
/// See sfSprite_Rotate to add an angle based on the previous rotation instead.
/// The default rotation of a sprite object is 0.
///
/// \param sprite Sprite object
/// \param angle New rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetScaleX(sfSprite* sprite, float scale);
CSFML_API void sfSprite_SetRotation(sfSprite* sprite, float angle);
////////////////////////////////////////////////////////////
/// Set the vertical scale of a sprite
/// \brief Set the scale factors of a sprite
///
/// \param sprite : Sprite to modify
/// \param scale : New scale (must be strictly positive)
/// This function completely overwrites the previous scale.
/// See sfSprite_Scale to add a factor based on the previous scale instead.
/// The default scale of a sprite object is (1, 1).
///
/// \param sprite Sprite object
/// \param factorX New horizontal scale factor
/// \param factorY New vertical scale factor
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetScaleY(sfSprite* sprite, float scale);
CSFML_API void sfSprite_SetScale(sfSprite* sprite, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// Set the scale of a sprite
/// \brief Set the local origin of a sprite
///
/// \param sprite : Sprite to modify
/// \param scaleX : New horizontal scale (must be strictly positive)
/// \param scaleY : New vertical scale (must be strictly positive)
/// The origin of an object defines the center point for
/// all transformations (position, scale, rotation).
/// The coordinates of this point must be relative to the
/// top-left corner of the object, and ignore all
/// transformations (position, scale, rotation).
/// The default origin of a sprite object is (0, 0).
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetScale(sfSprite* sprite, float scaleX, float scaleY);
////////////////////////////////////////////////////////////
/// Set the orientation of a sprite
///
/// \param sprite : Sprite to modify
/// \param rotation : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetRotation(sfSprite* sprite, float rotation);
////////////////////////////////////////////////////////////
/// Set the local origin of a sprite, in coordinates relative to
/// its left-top corner
///
/// \param sprite : Sprite to modify
/// \param x : X coordinate of the origin
/// \param y : Y coordinate of the origin
/// \param sprite Sprite object
/// \param x X coordinate of the new origin
/// \param y Y coordinate of the new origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetOrigin(sfSprite* sprite, float x, float y);
////////////////////////////////////////////////////////////
/// Set the color of a sprite
/// \brief Get the position of a sprite
///
/// \param sprite : Sprite to modify
/// \param color : New color
/// \param sprite Sprite object
///
/// \return Current position
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetColor(sfSprite* sprite, sfColor color);
CSFML_API void sfSprite_GetPosition(const sfSprite* sprite, float* x, float* y);
////////////////////////////////////////////////////////////
/// Set the blending mode for a sprite
/// \brief Get the orientation of a sprite
///
/// \param sprite : Sprite to modify
/// \param mode : New blending mode
/// The rotation is always in the range [0, 360].
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetBlendMode(sfSprite* sprite, sfBlendMode mode);
////////////////////////////////////////////////////////////
/// Get the X position of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current X position
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetX(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the Y position of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current Y position
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetY(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the horizontal scale of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current X scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetScaleX(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the vertical scale of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current Y scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetScaleY(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the orientation of a sprite
///
/// \param sprite : Sprite to read
/// \param sprite Sprite object
///
/// \return Current rotation, in degrees
///
@@ -206,186 +142,163 @@ CSFML_API float sfSprite_GetScaleY(const sfSprite* sprite);
CSFML_API float sfSprite_GetRotation(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the X position of the origin a sprite
/// \brief Get the current scale of a sprite
///
/// \param sprite : Sprite to read
/// \param sprite Sprite object
///
/// \return Current X origin
/// \return Current scale factors
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetOriginX(const sfSprite* sprite);
CSFML_API void sfSprite_GetScale(const sfSprite* sprite, float* x, float* y);
////////////////////////////////////////////////////////////
/// Get the Y position of the origin a sprite
/// \brief Get the local origin of a sprite
///
/// \param sprite : Sprite to read
/// \param sprite Sprite object
///
/// \return Current Y origin
/// \return Current origin
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetOriginY(const sfSprite* sprite);
CSFML_API void sfSprite_GetOrigin(const sfSprite* sprite, float* x, float* y);
////////////////////////////////////////////////////////////
/// Get the color of a sprite
/// \brief Move a sprite by a given offset
///
/// \param sprite : Sprite to read
/// This function adds to the current position of the object,
/// unlike sfSprite_SetPosition which overwrites it.
///
/// \return Current color
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfSprite_GetColor(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the current blending mode of a sprite
///
/// \param sprite : Sprite to read
///
/// \return Current blending mode
///
////////////////////////////////////////////////////////////
CSFML_API sfBlendMode sfSprite_GetBlendMode(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Move a sprite
///
/// \param sprite : Sprite to modify
/// \param offsetX : Offset on the X axis
/// \param offsetY : Offset on the Y axis
/// \param sprite Sprite object
/// \param offsetX X offset
/// \param offsetY Y offset
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_Move(sfSprite* sprite, float offsetX, float offsetY);
////////////////////////////////////////////////////////////
/// Scale a sprite
/// \brief Rotate a sprite
///
/// \param sprite : Sprite to modify
/// \param factorX : Horizontal scaling factor (must be strictly positive)
/// \param factorY : Vertical scaling factor (must be strictly positive)
/// This function adds to the current rotation of the object,
/// unlike sfSprite_SetRotation which overwrites it.
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_Scale(sfSprite* sprite, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// Rotate a sprite
///
/// \param sprite : Sprite to modify
/// \param angle : Angle of rotation, in degrees
/// \param sprite Sprite object
/// \param angle Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_Rotate(sfSprite* sprite, float angle);
////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into the sprite's local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
/// \brief Scale a sprite
///
/// \param sprite : Sprite object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
/// This function multiplies the current scale of the object,
/// unlike sfSprite_SetScale which overwrites it.
///
/// \param sprite Sprite object
/// \param factorX Horizontal scale factor
/// \param factorY Vertical scale factor
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_TransformToLocal(const sfSprite* sprite, float pointX, float pointY, float* x, float* y);
CSFML_API void sfSprite_Scale(sfSprite* sprite, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// Transform a point from the sprite's local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
/// \brief Get the combined transform of a sprite
///
/// \param sprite : Sprite object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
/// \param sprite Sprite object
///
/// \return Transform combining the position/rotation/scale/origin of the object
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_TransformToGlobal(const sfSprite* sprite, float pointX, float pointY, float* x, float* y);
CSFML_API const sfTransform* sfSprite_GetTransform(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Change the texture of a sprite
/// \brief Get the inverse of the combined transform of a sprite
///
/// \param sprite : Sprite to modify
/// \param texture : New texture
/// \param adjustToNewSize : If true, the SubRect of the sprite will be adjusted to the size of the new texture
/// \param sprite Sprite object
///
/// \return Inverse of the combined transformations applied to the object
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetTexture(sfSprite* sprite, const sfTexture* texture, sfBool adjustToNewSize);
CSFML_API const sfTransform* sfSprite_GetInverseTransform(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Set the sub-rectangle of a sprite inside the source image
/// \brief Change the source texture of a sprite
///
/// \param sprite : Sprite to modify
/// \param rectangle : New sub-rectangle
/// The \a texture argument refers to a texture that must
/// exist as long as the sprite uses it. Indeed, the sprite
/// doesn't store its own copy of the texture, but rather keeps
/// a pointer to the one that you passed to this function.
/// If the source texture is destroyed and the sprite tries to
/// use it, the behaviour is undefined.
/// If \a resetRect is true, the TextureRect property of
/// the sprite is automatically adjusted to the size of the new
/// texture. If it is false, the texture rect is left unchanged.
///
/// \param sprite Sprite object
/// \param texture New texture
/// \param resetRect Should the texture rect be reset to the size of the new texture?
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_SetSubRect(sfSprite* sprite, sfIntRect rectangle);
CSFML_API void sfSprite_SetTexture(sfSprite* sprite, const sfTexture* texture, sfBool resetRect);
////////////////////////////////////////////////////////////
/// Resize a sprite (by changing its scale factors)
/// \brief Set the sub-rectangle of the texture that a sprite will display
///
/// \param sprite : Sprite to modify
/// \param width : New width (must be strictly positive)
/// \param height : New height (must be strictly positive)
/// The texture rect is useful when you don't want to display
/// the whole texture, but rather a part of it.
/// By default, the texture rect covers the entire texture.
///
/// \param sprite Sprite object
/// \param rectangle Rectangle defining the region of the texture to display
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_Resize(sfSprite* sprite, float width, float height);
CSFML_API void sfSprite_SetTextureRect(sfSprite* sprite, sfIntRect rectangle);
////////////////////////////////////////////////////////////
/// Flip a sprite horizontally
/// \brief Set the global color of a sprite
///
/// \param sprite : Sprite to modify
/// \param flipped : sfTrue to flip the sprite
/// This color is modulated (multiplied) with the sprite's
/// texture. It can be used to colorize the sprite, or change
/// its global opacity.
/// By default, the sprite's color is opaque white.
///
/// \param sprite Sprite object
/// \param color New color of the sprite
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_FlipX(sfSprite* sprite, sfBool flipped);
CSFML_API void sfSprite_SetColor(sfSprite* sprite, sfColor color);
////////////////////////////////////////////////////////////
/// Flip a sprite vertically
/// \brief Get the source texture of a sprite
///
/// \param sprite : Sprite to modify
/// \param flipped : sfTrue to flip the sprite
/// If the sprite has no source texture, a NULL pointer is returned.
/// The returned pointer is const, which means that you can't
/// modify the texture when you retrieve it with this function.
///
////////////////////////////////////////////////////////////
CSFML_API void sfSprite_FlipY(sfSprite* sprite, sfBool flipped);
////////////////////////////////////////////////////////////
/// Get the source texture of a sprite
/// \param sprite Sprite object
///
/// \param sprite : Sprite to read
///
/// \return Pointer to the texture (can be NULL)
/// \return Pointer to the sprite's texture
///
////////////////////////////////////////////////////////////
CSFML_API const sfTexture* sfSprite_GetTexture(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get the sub-rectangle of a sprite inside the source image
/// \brief Get the sub-rectangle of the texture displayed by a sprite
///
/// \param sprite : Sprite to read
/// \param sprite Sprite object
///
/// \return Sub-rectangle
/// \return Texture rectangle of the sprite
///
////////////////////////////////////////////////////////////
CSFML_API sfIntRect sfSprite_GetSubRect(const sfSprite* sprite);
CSFML_API sfIntRect sfSprite_GetTextureRect(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get a sprite width
/// \brief Get the global color of a sprite
///
/// \param sprite : Sprite to read
/// \param sprite Sprite object
///
/// \return Width of the sprite
/// \return Global color of the sprite
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetWidth(const sfSprite* sprite);
////////////////////////////////////////////////////////////
/// Get a sprite height
///
/// \param sprite : Sprite to read
///
/// \return Height of the sprite
///
////////////////////////////////////////////////////////////
CSFML_API float sfSprite_GetHeight(const sfSprite* sprite);
CSFML_API sfColor sfSprite_GetColor(const sfSprite* sprite);
#endif // SFML_SPRITE_H
+161 -210
View File
@@ -29,7 +29,6 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/BlendMode.h>
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
@@ -49,7 +48,7 @@ typedef enum
////////////////////////////////////////////////////////////
/// Create a new text
/// \brief Create a new text
///
/// \return A new sfText object, or NULL if it failed
///
@@ -57,9 +56,9 @@ typedef enum
CSFML_API sfText* sfText_Create(void);
////////////////////////////////////////////////////////////
/// Copy an existing text
/// \brief Copy an existing text
///
/// \param text : Text to copy
/// \param text Text to copy
///
/// \return Copied object
///
@@ -67,151 +66,87 @@ CSFML_API sfText* sfText_Create(void);
CSFML_API sfText* sfText_Copy(sfText* text);
////////////////////////////////////////////////////////////
/// Destroy an existing text
/// \brief Destroy an existing text
///
/// \param text : Text to delete
/// \param text Text to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_Destroy(sfText* text);
////////////////////////////////////////////////////////////
/// Set the X position of a text
/// \brief Set the position of a text
///
/// \param text : String to modify
/// \param x : New X coordinate
/// This function completely overwrites the previous position.
/// See sfText_Move to apply an offset based on the previous position instead.
/// The default position of a text object is (0, 0).
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetX(sfText* text, float x);
////////////////////////////////////////////////////////////
/// Set the Y position of a text
///
/// \param text : String to modify
/// \param y : New Y coordinate
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetY(sfText* text, float y);
////////////////////////////////////////////////////////////
/// Set the position of a text
///
/// \param text : String to modify
/// \param x : New X coordinate
/// \param y : New Y coordinate
/// \param text Text object
/// \param x X coordinate of the new position
/// \param y Y coordinate of the new position
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetPosition(sfText* text, float x, float y);
////////////////////////////////////////////////////////////
/// Set the horizontal scale of a text
/// \brief Set the orientation of a text
///
/// \param text : String to modify
/// \param scale : New scale (must be strictly positive)
/// This function completely overwrites the previous rotation.
/// See sfText_Rotate to add an angle based on the previous rotation instead.
/// The default rotation of a text object is 0.
///
/// \param text Text object
/// \param angle New rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetScaleX(sfText* text, float scale);
CSFML_API void sfText_SetRotation(sfText* text, float angle);
////////////////////////////////////////////////////////////
/// Set the vertical scale of a text
/// \brief Set the scale factors of a text
///
/// \param text : String to modify
/// \param scale : New scale (must be strictly positive)
/// This function completely overwrites the previous scale.
/// See sfText_Scale to add a factor based on the previous scale instead.
/// The default scale of a text object is (1, 1).
///
/// \param text Text object
/// \param factorX New horizontal scale factor
/// \param factorY New vertical scale factor
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetScaleY(sfText* text, float scale);
CSFML_API void sfText_SetScale(sfText* text, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// Set the scale of a text
/// \brief Set the local origin of a text
///
/// \param text : String to modify
/// \param scaleX : New horizontal scale (must be strictly positive)
/// \param scaleY : New vertical scale (must be strictly positive)
/// The origin of an object defines the center point for
/// all transformations (position, scale, rotation).
/// The coordinates of this point must be relative to the
/// top-left corner of the object, and ignore all
/// transformations (position, scale, rotation).
/// The default origin of a text object is (0, 0).
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetScale(sfText* text, float scaleX, float scaleY);
////////////////////////////////////////////////////////////
/// Set the orientation of a text
///
/// \param text : String to modify
/// \param rotation : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetRotation(sfText* text, float rotation);
////////////////////////////////////////////////////////////
/// Set the local origin of a text, in coordinates
/// relative to its left-top corner
///
/// \param text : String to modify
/// \param x : X coordinate of the origin
/// \param y : Y coordinate of the origin
/// \param text Text object
/// \param x X coordinate of the new origin
/// \param y Y coordinate of the new origin
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetOrigin(sfText* text, float x, float y);
////////////////////////////////////////////////////////////
/// Set the color of a text
/// \brief Get the position of a text
///
/// \param text : String to modify
/// \param color : New color
/// \param text Text object
///
/// \return Current position
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetColor(sfText* text, sfColor color);
CSFML_API void sfText_GetPosition(const sfText* text, float* x, float* y);
////////////////////////////////////////////////////////////
/// Set the blending mode for a text
/// \brief Get the orientation of a text
///
/// \param text : String to modify
/// \param mode : New blending mode
/// The rotation is always in the range [0, 360].
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetBlendMode(sfText* text, sfBlendMode mode);
////////////////////////////////////////////////////////////
/// Get the X position of a text
///
/// \param text : String to read
///
/// \return Current X position
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetX(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the top Y of a text
///
/// \param text : String to read
///
/// \return Current Y position
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetY(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the horizontal scale of a text
///
/// \param text : String to read
///
/// \return Current X scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetScaleX(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the vertical scale of a text
///
/// \param text : String to read
///
/// \return Current Y scale factor (always positive)
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetScaleY(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the orientation of a text
///
/// \param text : String to read
/// \param text Text object
///
/// \return Current rotation, in degrees
///
@@ -219,159 +154,160 @@ CSFML_API float sfText_GetScaleY(const sfText* text);
CSFML_API float sfText_GetRotation(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the X position of the origin a text
/// \brief Get the current scale of a text
///
/// \param text : String to read
/// \param text Text object
///
/// \return Current X origin position
/// \return Current scale factors
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetOriginX(const sfText* text);
CSFML_API void sfText_GetScale(const sfText* text, float* x, float* y);
////////////////////////////////////////////////////////////
/// Get the top Y of the origin of a text
/// \brief Get the local origin of a text
///
/// \param text : String to read
/// \param text Text object
///
/// \return Current Y origin position
/// \return Current origin
///
////////////////////////////////////////////////////////////
CSFML_API float sfText_GetOriginY(const sfText* text);
CSFML_API void sfText_GetOrigin(const sfText* text, float* x, float* y);
////////////////////////////////////////////////////////////
/// Get the color of a text
/// \brief Move a text by a given offset
///
/// \param text : String to read
/// This function adds to the current position of the object,
/// unlike sfText_SetPosition which overwrites it.
///
/// \return Current color
///
////////////////////////////////////////////////////////////
CSFML_API sfColor sfText_GetColor(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the current blending mode of a text
///
/// \param text : String to read
///
/// \return Current blending mode
///
////////////////////////////////////////////////////////////
CSFML_API sfBlendMode sfText_GetBlendMode(const sfText* text);
////////////////////////////////////////////////////////////
/// Move a text
///
/// \param text : String to modify
/// \param offsetX : Offset on the X axis
/// \param offsetY : Offset on the Y axis
/// \param text Text object
/// \param offsetX X offset
/// \param offsetY Y offset
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_Move(sfText* text, float offsetX, float offsetY);
////////////////////////////////////////////////////////////
/// Scale a text
/// \brief Rotate a text
///
/// \param text : String to modify
/// \param factorX : Horizontal scaling factor (must be strictly positive)
/// \param factorY : Vertical scaling factor (must be strictly positive)
/// This function adds to the current rotation of the object,
/// unlike sfText_SetRotation which overwrites it.
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_Scale(sfText* text, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// Rotate a text
///
/// \param text : String to modify
/// \param angle : Angle of rotation, in degrees
/// \param text Text object
/// \param angle Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_Rotate(sfText* text, float angle);
////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into the string's local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
/// \brief Scale a text
///
/// \param text : String object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
/// This function multiplies the current scale of the object,
/// unlike sfText_SetScale which overwrites it.
///
/// \param text Text object
/// \param factorX Horizontal scale factor
/// \param factorY Vertical scale factor
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_TransformToLocal(const sfText* text, float pointX, float pointY, float* x, float* y);
CSFML_API void sfText_Scale(sfText* text, float factorX, float factorY);
////////////////////////////////////////////////////////////
/// Transform a point from the string's local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
/// \brief Get the combined transform of a text
///
/// \param text : String object
/// \param pointX : X coordinate of the point to transform
/// \param pointY : Y coordinate of the point to transform
/// \param x : Value to fill with the X coordinate of the converted point
/// \param y : Value to fill with the y coordinate of the converted point
/// \param text Text object
///
/// \return Transform combining the position/rotation/scale/origin of the object
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_TransformToGlobal(const sfText* text, float pointX, float pointY, float* X, float* y);
CSFML_API const sfTransform* sfText_GetTransform(const sfText* text);
////////////////////////////////////////////////////////////
/// Set the string of a text (from a multibyte string)
/// \brief Get the inverse of the combined transform of a text
///
/// \param text : Text to modify
/// \param string : New string
/// \param text Text object
///
/// \return Inverse of the combined transformations applied to the object
///
////////////////////////////////////////////////////////////
CSFML_API const sfTransform* sfText_GetInverseTransform(const sfText* text);
////////////////////////////////////////////////////////////
/// \brief Set the string of a text (from an ANSI string)
///
/// A text's string is empty by default.
///
/// \param text Text object
/// \param string New string
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetString(sfText* text, const char* string);
////////////////////////////////////////////////////////////
/// Set the string of a text (from a unicode string)
/// \brief Set the string of a text (from a unicode string)
///
/// \param text : Text to modify
/// \param string : New string
/// \param text Text object
/// \param string New string
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetUnicodeString(sfText* text, const sfUint32* string);
////////////////////////////////////////////////////////////
/// Set the font of a text
/// \brief Set the font of a text
///
/// \param text : String to modify
/// \param font : Font to use
/// The \a font argument refers to a texture that must
/// exist as long as the text uses it. Indeed, the text
/// doesn't store its own copy of the font, but rather keeps
/// a pointer to the one that you passed to this function.
/// If the font is destroyed and the text tries to
/// use it, the behaviour is undefined.
/// Texts have a valid font by default, which the built-in
/// sfFont_GetDefaultFont().
///
/// \param text Text object
/// \param font New font
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetFont(sfText* text, const sfFont* font);
////////////////////////////////////////////////////////////
/// Set the size of a text
/// \brief Set the character size of a text
///
/// \param text : String to modify
/// \param size : New size, in pixels
/// The default size is 30.
///
/// \param text Text object
/// \param size New character size, in pixels
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetCharacterSize(sfText* text, unsigned int size);
////////////////////////////////////////////////////////////
/// Set the style of a text
/// \brief Set the style of a text
///
/// \param text : String to modify
/// \param style : New style (see sfTextStyle enum)
/// You can pass a combination of one or more styles, for
/// example sfTextBold | sfTextItalic.
/// The default style is sfTextRegular.
///
/// \param text Text object
/// \param style New style
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_SetStyle(sfText* text, sfUint32 style);
////////////////////////////////////////////////////////////
/// Get the string of a text (returns a unicode string)
/// \brief Set the global color of a text
///
/// \param text : String to read
/// By default, the text's color is opaque white.
///
/// \return String as UTF-32
/// \param text Text object
/// \param color New color of the text
///
////////////////////////////////////////////////////////////
CSFML_API const sfUint32* sfText_GetUnicodeString(const sfText* text);
CSFML_API void sfText_SetColor(sfText* text, sfColor color);
////////////////////////////////////////////////////////////
/// Get the text of a text (returns an ANSI string)
/// \brief Get the text of a text (returns an ANSI string)
///
/// \param text : String to read
/// \param text Text object
///
/// \return String an a locale-dependant ANSI string
///
@@ -379,9 +315,19 @@ CSFML_API const sfUint32* sfText_GetUnicodeString(const sfText* text);
CSFML_API const char* sfText_GetString(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the font used by a text
/// \brief Get the string of a text (returns a unicode string)
///
/// \param text : String to read
/// \param text Text object
///
/// \return String as UTF-32
///
////////////////////////////////////////////////////////////
CSFML_API const sfUint32* sfText_GetUnicodeString(const sfText* text);
////////////////////////////////////////////////////////////
/// \brief Get the font used by a text
///
/// \param text Text object
///
/// \return Pointer to the font
///
@@ -389,9 +335,9 @@ CSFML_API const char* sfText_GetString(const sfText* text);
CSFML_API const sfFont* sfText_GetFont(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the size of the characters of a text
/// \brief Get the size of the characters of a text
///
/// \param text : String to read
/// \param text Text object
///
/// \return Size of the characters
///
@@ -399,9 +345,9 @@ CSFML_API const sfFont* sfText_GetFont(const sfText* text);
CSFML_API unsigned int sfText_GetCharacterSize(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the style of a text
/// \brief Get the style of a text
///
/// \param text : String to read
/// \param text Text object
///
/// \return Current string style (see sfTextStyle enum)
///
@@ -409,27 +355,32 @@ CSFML_API unsigned int sfText_GetCharacterSize(const sfText* text);
CSFML_API sfUint32 sfText_GetStyle(const sfText* text);
////////////////////////////////////////////////////////////
/// Return the visual position of the Index-th character of the text,
/// in coordinates relative to the string
/// (note : translation, origin, rotation and scale are not applied)
/// \brief Get the global color of a text
///
/// \param text : String to read
/// \param index : Index of the character
/// \param x : Value to fill with the X coordinate of the position
/// \param y : Value to fill with the y coordinate of the position
/// \param text Text object
///
/// \return Global color of the text
///
////////////////////////////////////////////////////////////
CSFML_API void sfText_GetCharacterPos(const sfText* text, size_t index, float* x, float* y);
CSFML_API sfColor sfText_GetColor(const sfText* text);
////////////////////////////////////////////////////////////
/// Get the bounding rectangle of a text on screen
/// \brief Return the position of the \a index-th character in a text
///
/// \param text : String to read
/// This function computes the visual position of a character
/// from its index in the string. The returned position is
/// in global coordinates (translation, rotation, scale and
/// origin are applied).
/// If \a index is out of range, the position of the end of
/// the string is returned.
///
/// \return Rectangle contaning the string in screen coordinates
/// \param text Text object
/// \param index Index of the character
/// \param x The returned x position of the character
/// \param y The returned y position of the character
///
////////////////////////////////////////////////////////////
CSFML_API sfFloatRect sfText_GetRect(const sfText* text);
CSFML_API void sfText_FindCharacterPos(const sfText* text, size_t index, float* x, float* y);
#endif // SFML_TEXT_H
+92 -59
View File
@@ -37,10 +37,10 @@
////////////////////////////////////////////////////////////
/// Create a new texture
/// \brief Create a new texture
///
/// \param width : Texture width
/// \param height : Texture height
/// \param width Texture width
/// \param height Texture height
///
/// \return A new sfTexture object, or NULL if it failed
///
@@ -48,10 +48,10 @@
CSFML_API sfTexture* sfTexture_Create(unsigned int width, unsigned int height);
////////////////////////////////////////////////////////////
/// Create a new texture from a file
/// \brief Create a new texture from a file
///
/// \param filename : Path of the image file to load
/// \param area : Area of the source image to load (NULL to load the entire image)
/// \param filename Path of the image file to load
/// \param area Area of the source image to load (NULL to load the entire image)
///
/// \return A new sfTexture object, or NULL if it failed
///
@@ -59,11 +59,11 @@ CSFML_API sfTexture* sfTexture_Create(unsigned int width, unsigned int height);
CSFML_API sfTexture* sfTexture_CreateFromFile(const char* filename, const sfIntRect* area);
////////////////////////////////////////////////////////////
/// Create a new texture from a file in memory
/// \brief Create a new texture from a file in memory
///
/// \param data : Pointer to the file data in memory
/// \param sizeInBytes : Size of the data to load, in bytes
/// \param area : Area of the source image to load (NULL to load the entire image)
/// \param data Pointer to the file data in memory
/// \param sizeInBytes Size of the data to load, in bytes
/// \param area Area of the source image to load (NULL to load the entire image)
///
/// \return A new sfTexture object, or NULL if it failed
///
@@ -71,10 +71,10 @@ CSFML_API sfTexture* sfTexture_CreateFromFile(const char* filename, const sfIntR
CSFML_API sfTexture* sfTexture_CreateFromMemory(const void* data, size_t sizeInBytes, const sfIntRect* area);
////////////////////////////////////////////////////////////
/// Create a new texture from a custom stream
/// \brief Create a new texture from a custom stream
///
/// \param stream : Source stream to read from
/// \param area : Area of the source image to load (NULL to load the entire image)
/// \param stream Source stream to read from
/// \param area Area of the source image to load (NULL to load the entire image)
///
/// \return A new sfTexture object, or NULL if it failed
///
@@ -82,10 +82,10 @@ CSFML_API sfTexture* sfTexture_CreateFromMemory(const void* data, size_t sizeInB
CSFML_API sfTexture* sfTexture_CreateFromStream(sfInputStream* stream, const sfIntRect* area);
////////////////////////////////////////////////////////////
/// Create a new texture from an image
/// \brief Create a new texture from an image
///
/// \param image : Image to upload to the texture
/// \param area : Area of the source image to load (NULL to load the entire image)
/// \param image Image to upload to the texture
/// \param area Area of the source image to load (NULL to load the entire image)
///
/// \return A new sfTexture object, or NULL if it failed
///
@@ -93,9 +93,9 @@ CSFML_API sfTexture* sfTexture_CreateFromStream(sfInputStream* stream, const sfI
CSFML_API sfTexture* sfTexture_CreateFromImage(const sfImage* image, const sfIntRect* area);
////////////////////////////////////////////////////////////
/// Copy an existing texture
/// \brief Copy an existing texture
///
/// \param texture : Texture to copy
/// \param texture Texture to copy
///
/// \return Copied object
///
@@ -103,17 +103,17 @@ CSFML_API sfTexture* sfTexture_CreateFromImage(const sfImage* image, const sfInt
CSFML_API sfTexture* sfTexture_Copy(sfTexture* texture);
////////////////////////////////////////////////////////////
/// Destroy an existing texture
/// \brief Destroy an existing texture
///
/// \param texture : Texture to delete
/// \param texture Texture to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfTexture_Destroy(sfTexture* texture);
////////////////////////////////////////////////////////////
/// Return the width of the texture
/// \brief Return the width of the texture
///
/// \param texture : Texture to read
/// \param texture Texture to read
///
/// \return Width in pixels
///
@@ -121,9 +121,9 @@ CSFML_API void sfTexture_Destroy(sfTexture* texture);
CSFML_API unsigned int sfTexture_GetWidth(const sfTexture* texture);
////////////////////////////////////////////////////////////
/// Return the height of the texture
/// \brief Return the height of the texture
///
/// \param texture : Texture to read
/// \param texture Texture to read
///
/// \return Height in pixels
///
@@ -131,9 +131,9 @@ CSFML_API unsigned int sfTexture_GetWidth(const sfTexture* texture);
CSFML_API unsigned int sfTexture_GetHeight(const sfTexture* texture);
////////////////////////////////////////////////////////////
/// Copy a texture's pixels to an image
/// \brief Copy a texture's pixels to an image
///
/// \param texture : Texture to copy
/// \param texture Texture to copy
///
/// \return Image containing the texture's pixels
///
@@ -141,72 +141,72 @@ CSFML_API unsigned int sfTexture_GetHeight(const sfTexture* texture);
CSFML_API sfImage* sfTexture_CopyToImage(const sfTexture* texture);
////////////////////////////////////////////////////////////
/// Update a texture from an array of pixels
/// \brief Update a texture from an array of pixels
///
/// \param texture : Texture to update
/// \param pixels : Array of pixels to copy to the texture
/// \param width : Width of the pixel region contained in \a pixels
/// \param height : Height of the pixel region contained in \a 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
/// \param texture Texture to update
/// \param pixels Array of pixels to copy to the texture
/// \param width Width of the pixel region contained in \a pixels
/// \param height Height of the pixel region contained in \a 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_API void sfTexture_UpdateFromPixels(sfTexture* texture, const sfUint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y);
////////////////////////////////////////////////////////////
/// Update a texture from an image
/// \brief Update a texture from an image
///
/// \param texture : Texture to update
/// \param image : Image to copy to the texture
/// \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
/// \param texture Texture to update
/// \param image Image to copy to the texture
/// \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_API void sfTexture_UpdateFromImage(sfTexture* texture, const sfImage* image, unsigned int x, unsigned int y);
////////////////////////////////////////////////////////////
/// 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 window : Window to copy to the texture
/// \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
/// \param texture Texture to update
/// \param window Window to copy to the texture
/// \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_API void sfTexture_UpdateFromWindow(sfTexture* texture, const sfWindow* window, unsigned int x, unsigned int y);
////////////////////////////////////////////////////////////
/// 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 renderWindow : Render-window to copy to the texture
/// \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
/// \param texture Texture to update
/// \param renderWindow Render-window to copy to the texture
/// \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_API void sfTexture_UpdateFromRenderWindow(sfTexture* texture, const sfRenderWindow* renderWindow, unsigned int x, unsigned int y);
////////////////////////////////////////////////////////////
/// Activate a texture for rendering
/// \brief Activate a texture for rendering
///
/// \param texture : Texture to bind
/// \param texture Texture to bind
///
////////////////////////////////////////////////////////////
CSFML_API void sfTexture_Bind(const sfTexture* texture);
////////////////////////////////////////////////////////////
/// Enable or disable the smooth filter on a texture
/// \brief Enable or disable the smooth filter on a texture
///
/// \param texture : The texture object
/// \param smooth : sfTrue to enable smoothing, sfFalse to disable it
/// \param texture The texture object
/// \param smooth sfTrue to enable smoothing, sfFalse to disable it
///
////////////////////////////////////////////////////////////
CSFML_API void sfTexture_SetSmooth(sfTexture* texture, sfBool smooth);
////////////////////////////////////////////////////////////
/// Tell whether the smooth filter is enabled or not for a texture
/// \brief Tell whether the smooth filter is enabled or not for a texture
///
/// \param texture : The texture object
/// \param texture The texture object
///
/// \return sfTrue if smoothing is enabled, sfFalse if it is disabled
///
@@ -214,10 +214,43 @@ CSFML_API void sfTexture_SetSmooth(sfTexture* texture, sfBool smooth);
CSFML_API sfBool sfTexture_IsSmooth(const sfTexture* texture);
////////////////////////////////////////////////////////////
/// Convert a rectangle of pixels into texture coordinates
/// \brief Enable or disable repeating for a texture
///
/// \param texture : Texture to use for conversion
/// \param rectangle : Rectangle to convert
/// Repeating is involved when using texture coordinates
/// outside the texture rectangle [0, 0, width, height].
/// In this case, if repeat mode is enabled, the whole texture
/// will be repeated as many times as needed to reach the
/// coordinate (for example, if the X texture coordinate is
/// 3 * width, the texture will be repeated 3 times).
/// If repeat mode is disabled, the "extra space" will instead
/// be filled with border pixels.
/// Warning: on very old graphics cards, white pixels may appear
/// when the texture is repeated. With such cards, repeat mode
/// can be used reliably only if the texture has power-of-two
/// dimensions (such as 256x128).
/// Repeating is disabled by default.
///
/// \param texture The texture object
/// \param repeated True to repeat the texture, false to disable repeating
///
////////////////////////////////////////////////////////////
CSFML_API void sfTexture_SetRepeated(sfTexture* texture, sfBool repeated);
////////////////////////////////////////////////////////////
/// \brief Tell whether a texture is repeated or not
///
/// \param texture The texture object
///
/// \return sfTrue if repeat mode is enabled, sfFalse if it is disabled
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfTexture_IsRepeated(const sfTexture* texture);
////////////////////////////////////////////////////////////
/// \brief Convert a rectangle of pixels into texture coordinates
///
/// \param texture Texture to use for conversion
/// \param rectangle Rectangle to convert
///
/// \return Texture coordinates corresponding to \a rectangle
///
@@ -225,7 +258,7 @@ CSFML_API sfBool sfTexture_IsSmooth(const sfTexture* texture);
CSFML_API sfFloatRect sfTexture_GetTexCoords(const sfTexture* texture, sfIntRect rectangle);
////////////////////////////////////////////////////////////
/// Get the maximum texture size allowed
/// \brief Get the maximum texture size allowed
///
/// \return Maximum size allowed for textures, in pixels
///
+222
View File
@@ -0,0 +1,222 @@
////////////////////////////////////////////////////////////
//
// 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_TRANSFORM_H
#define SFML_TRANSFORM_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
////////////////////////////////////////////////////////////
/// \brief Create a new transform
///
/// This function creates an identity transform.
///
/// \return A new sfTransform object
///
////////////////////////////////////////////////////////////
CSFML_API sfTransform* sfTransform_Create(void);
////////////////////////////////////////////////////////////
/// \brief Create a new transform from a matrix
///
///
/// \param a00 Element (0, 0) of the matrix
/// \param a01 Element (0, 1) of the matrix
/// \param a02 Element (0, 2) of the matrix
/// \param a10 Element (1, 0) of the matrix
/// \param a11 Element (1, 1) of the matrix
/// \param a12 Element (1, 2) of the matrix
/// \param a20 Element (2, 0) of the matrix
/// \param a21 Element (2, 1) of the matrix
/// \param a22 Element (2, 2) of the matrix
///
/// \return A new sfTransform object
///
////////////////////////////////////////////////////////////
CSFML_API sfTransform* sfTransform_CreateFromMatrix(float a00, float a01, float a02,
float a10, float a11, float a12,
float a20, float a21, float a22);
////////////////////////////////////////////////////////////
/// \brief Copy an existing transform
///
/// \param transform Transform to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfTransform* sfTransform_Copy(sfTransform* transform);
////////////////////////////////////////////////////////////
/// \brief Destroy an existing transform
///
/// \param transform Transform to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfTransform_Destroy(sfTransform* transform);
////////////////////////////////////////////////////////////
/// \brief Return the 4x4 matrix of a transform
///
/// This function returns a pointer to an array of 16 floats
/// containing the transform elements as a 4x4 matrix, which
/// is directly compatible with OpenGL functions.
///
/// \code
/// sfTransform* transform = ...;
/// glLoadMatrixf(sfTransform_GetMatrix(transform));
/// \endcode
///
/// \param transform Transform object
///
/// \return Pointer to a 4x4 matrix
///
////////////////////////////////////////////////////////////
const float* sfTransform_GetMatrix(const sfTransform* transform);
////////////////////////////////////////////////////////////
/// \brief Return the inverse of a transform
///
/// If the inverse cannot be computed, a new identity transform
/// is returned.
///
/// \param transform Transform object
///
/// \return A new transform which is the inverse of self
///
////////////////////////////////////////////////////////////
sfTransform* sfTransform_GetInverse(const sfTransform* transform);
////////////////////////////////////////////////////////////
/// \brief Apply a transform to a 2D point
///
/// \param transform Transform object
/// \param x X coordinate of the point to transform
/// \param y Y coordinate of the point to transform
/// \param transformedX X coordinate of the transformed point
/// \param transformedY Y coordinate of the transformed point
///
////////////////////////////////////////////////////////////
void sfTransform_TransformPoint(const sfTransform* transform, float x, float y, float* transformedX, float* transformedY);
////////////////////////////////////////////////////////////
/// \brief Apply a transform to a rectangle
///
/// Since SFML doesn't provide support for oriented rectangles,
/// the result of this function is always an axis-aligned
/// rectangle. Which means that if the transform contains a
/// rotation, the bounding rectangle of the transformed rectangle
/// is returned.
///
/// \param transform Transform object
/// \param rectangle Rectangle to transform
/// \param transformedRectangle Transformed rectangle
///
////////////////////////////////////////////////////////////
void sfTransform_TransformRect(const sfTransform* transform, sfFloatRect rectangle, sfFloatRect* transformedRectangle);
////////////////////////////////////////////////////////////
/// \brief Combine two transforms
///
/// The result is a transform that is equivalent to applying
/// \a left followed by \a right. Mathematically, it is
/// equivalent to a matrix multiplication.
///
/// \param left First transform to combine
/// \param right Second transform to combine
/// \param result Result of the operation (must point to a valid sfTransform instance)
///
////////////////////////////////////////////////////////////
void sfTransform_Combine(const sfTransform* left, const sfTransform* right, sfTransform* result);
////////////////////////////////////////////////////////////
/// \brief Combine a transform with a translation
///
/// \param transform Transform object
/// \param x Offset to apply on X axis
/// \param y Offset to apply on Y axis
///
////////////////////////////////////////////////////////////
CSFML_API void sfTransform_Translate(sfTransform* transform, float x, float y);
////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a rotation
///
/// \param transform Transform object
/// \param angle Rotation angle, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfTransform_Rotate(sfTransform* transform, float angle);
////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a rotation
///
/// The center of rotation is provided for convenience as a second
/// argument, so that you can build rotations around arbitrary points
/// more easily (and efficiently) than the usual
/// [Translate(-center), Rotate(angle), Translate(center)].
///
/// \param transform Transform object
/// \param angle Rotation angle, in degrees
/// \param centerX X coordinate of the center of rotation
/// \param centerY Y coordinate of the center of rotation
///
////////////////////////////////////////////////////////////
CSFML_API void sfTransform_RotateWithCenter(sfTransform* transform, float angle, float centerX, float centerY);
////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a scaling
///
/// \param transform Transform object
/// \param scaleX Scaling factor on the X axis
/// \param scaleY Scaling factor on the Y axis
///
////////////////////////////////////////////////////////////
CSFML_API void sfTransform_Scale(sfTransform* transform, float scaleX, float scaleY);
////////////////////////////////////////////////////////////
/// \brief Combine the current transform with a scaling
///
/// The center of scaling is provided for convenience as a second
/// argument, so that you can build scaling around arbitrary points
/// more easily (and efficiently) than the usual
/// [Translate(-center), Scale(factors), Translate(center)]
///
/// \param transform Transform object
/// \param scaleX Scaling factor on X axis
/// \param scaleY Scaling factor on Y axis
/// \param centerX X coordinate of the center of scaling
/// \param centerY Y coordinate of the center of scaling
///
////////////////////////////////////////////////////////////
CSFML_API void sfTransform_ScaleWithCenter(sfTransform* transform, float scaleX, float scaleY, float centerX, float centerY);
#endif // SFML_TEXTURE_H
+5
View File
@@ -26,15 +26,20 @@
#define SFML_GRAPHICS_TYPES_H
typedef struct sfCircleShape sfCircleShape;
typedef struct sfConvexShape sfConvexShape;
typedef struct sfFont sfFont;
typedef struct sfImage sfImage;
typedef struct sfShader sfShader;
typedef struct sfRectangleShape sfRectangleShape;
typedef struct sfRenderTexture sfRenderTexture;
typedef struct sfRenderWindow sfRenderWindow;
typedef struct sfShape sfShape;
typedef struct sfSprite sfSprite;
typedef struct sfText sfText;
typedef struct sfTexture sfTexture;
typedef struct sfTransform sfTransform;
typedef struct sfVertexArray sfVertexArray;
typedef struct sfView sfView;
+47
View File
@@ -0,0 +1,47 @@
////////////////////////////////////////////////////////////
//
// 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_VERTEX_H
#define SFML_VERTEX_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Color.h>
////////////////////////////////////////////////////////////
/// Define a point with color and texture coordinates
////////////////////////////////////////////////////////////
typedef struct
{
float X; ///< X coordinate of the position of the vertex
float Y; ///< Y coordinate of the position of the vertex
sfColor Color; ///< Color of the vertex
float TexCoordX; ///< X coordinate of the texture's pixel to map to the vertex
float TexCoordY; ///< Y coordinate of the texture's pixel to map to the vertex
} sfVertex;
#endif // SFML_VERTEX_H
+167
View File
@@ -0,0 +1,167 @@
////////////////////////////////////////////////////////////
//
// 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_VERTEXARRAY_H
#define SFML_VERTEXARRAY_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/PrimitiveType.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/Graphics/Vertex.h>
////////////////////////////////////////////////////////////
/// \brief Create a new vertex array
///
/// \return A new sfVertexArray object
///
////////////////////////////////////////////////////////////
CSFML_API sfVertexArray* sfVertexArray_Create(void);
////////////////////////////////////////////////////////////
/// \brief Copy an existing vertex array
///
/// \param vertexArray Vertex array to copy
///
/// \return Copied object
///
////////////////////////////////////////////////////////////
CSFML_API sfVertexArray* sfTransform_Copy(sfVertexArray* vertexArray);
////////////////////////////////////////////////////////////
/// \brief Destroy an existing vertex array
///
/// \param vertexArray Vertex array to delete
///
////////////////////////////////////////////////////////////
CSFML_API void sfVertexArray_Destroy(sfVertexArray* vertexArray);
////////////////////////////////////////////////////////////
/// \brief Return the vertex count of a vertex array
///
/// \param vertexArray Vertex array object
///
/// \return Number of vertices in the array
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfVertexArray_GetVertexCount(const sfVertexArray* vertexArray);
////////////////////////////////////////////////////////////
/// \brief Get access to a vertex by its index
///
/// This function doesn't check \a index, it must be in range
/// [0, vertex count - 1]. The behaviour is undefined
/// otherwise.
///
/// \param vertexArray Vertex array object
/// \param index Index of the vertex to get
///
/// \return Pointer to the index-th vertex
///
////////////////////////////////////////////////////////////
CSFML_API sfVertex* sfVertexArray_At(sfVertexArray* vertexArray, unsigned int index);
////////////////////////////////////////////////////////////
/// \brief Clear a vertex array
///
/// This function removes all the vertices from the array.
/// It doesn't deallocate the corresponding memory, so that
/// adding new vertices after clearing doesn't involve
/// reallocating all the memory.
///
/// \param vertexArray Vertex array object
///
////////////////////////////////////////////////////////////
CSFML_API void sfVertexArray_Clear(sfVertexArray* vertexArray);
////////////////////////////////////////////////////////////
/// \brief Resize the vertex array
///
/// If \a vertexCount is greater than the current size, the previous
/// vertices are kept and new (default-constructed) vertices are
/// added.
/// If \a vertexCount is less than the current size, existing vertices
/// are removed from the array.
///
/// \param vertexArray Vertex array objet
/// \param vertexCount New size of the array (number of vertices)
///
////////////////////////////////////////////////////////////
CSFML_API void sfVertexArray_Resize(sfVertexArray* vertexArray, unsigned int vertexCount);
////////////////////////////////////////////////////////////
/// \brief Add a vertex to a vertex array array
///
/// \param vertexArray Vertex array objet
/// \param vertex Vertex to add
///
////////////////////////////////////////////////////////////
CSFML_API void sfVertexArray_Append(sfVertexArray* vertexArray, sfVertex vertex);
////////////////////////////////////////////////////////////
/// \brief Set the type of primitives of a vertex array
///
/// This function defines how the vertices must be interpreted
/// when it's time to draw them:
/// \li As points
/// \li As lines
/// \li As triangles
/// \li As quads
/// The default primitive type is sfPoints.
///
/// \param vertexArray Vertex array objet
/// \param type Type of primitive
///
////////////////////////////////////////////////////////////
CSFML_API void sfVertexArray_SetPrimitiveType(sfVertexArray* vertexArray, sfPrimitiveType type);
////////////////////////////////////////////////////////////
/// \brief Get the type of primitives drawn by a vertex array
///
/// \param vertexArray Vertex array objet
///
/// \return Primitive type
///
////////////////////////////////////////////////////////////
CSFML_API sfPrimitiveType sfVertexArray_GetPrimitiveType(sfVertexArray* vertexArray);
////////////////////////////////////////////////////////////
/// \brief Compute the bounding rectangle of a vertex array
///
/// This function returns the axis-aligned rectangle that
/// contains all the vertices of the array.
///
/// \param vertexArray Vertex array objet
///
/// \return Bounding rectangle of the vertex array
///
////////////////////////////////////////////////////////////
CSFML_API sfFloatRect sfVertexArray_GetBounds(sfVertexArray* vertexArray);
#endif // SFML_VERTEXARRAY_H