mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-25 21:06:12 +01:00
Updated to the new graphics API
This commit is contained in:
1 parent
06997db9e8
commit
44670984af
51 files changed
+4607
-2573
No files matched your search
+65
-226
@@ -32,8 +32,6 @@
|
||||
#include <SFML/Internal.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a new text
|
||||
////////////////////////////////////////////////////////////
|
||||
sfText* sfText_Create(void)
|
||||
{
|
||||
@@ -44,8 +42,6 @@ sfText* sfText_Create(void)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Copy an existing text
|
||||
////////////////////////////////////////////////////////////
|
||||
sfText* sfText_Copy(sfText* text)
|
||||
{
|
||||
@@ -55,8 +51,6 @@ sfText* sfText_Copy(sfText* text)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destroy an existing text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_Destroy(sfText* text)
|
||||
{
|
||||
@@ -64,241 +58,124 @@ void sfText_Destroy(sfText* text)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the X position of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetX(sfText* text, float x)
|
||||
{
|
||||
CSFML_CALL(text, SetX(x))
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the Y position of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetY(sfText* text, float y)
|
||||
{
|
||||
CSFML_CALL(text, SetY(y))
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the position of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetPosition(sfText* text, float x, float y)
|
||||
{
|
||||
CSFML_CALL(text, SetPosition(sf::Vector2f(x, y)))
|
||||
CSFML_CALL(text, SetPosition(x, y));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the horizontal scale of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetScaleX(sfText* text, float scale)
|
||||
void sfText_SetRotation(sfText* text, float angle)
|
||||
{
|
||||
CSFML_CALL(text, SetScaleX(scale))
|
||||
CSFML_CALL(text, SetRotation(angle));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the vertical scale of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetScaleY(sfText* text, float scale)
|
||||
void sfText_SetScale(sfText* text, float factorX, float factorY)
|
||||
{
|
||||
CSFML_CALL(text, SetScaleY(scale))
|
||||
CSFML_CALL(text, SetScale(factorX, factorY));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the scale of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetScale(sfText* text, float scaleX, float scaleY)
|
||||
{
|
||||
CSFML_CALL(text, SetScale(sf::Vector2f(scaleX, scaleY)))
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the orientation of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetRotation(sfText* text, float rotation)
|
||||
{
|
||||
CSFML_CALL(text, SetRotation(rotation))
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the local origin of a text, in coordinates
|
||||
/// relative to its left-top corner
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetOrigin(sfText* text, float x, float y)
|
||||
{
|
||||
CSFML_CALL(text, SetOrigin(sf::Vector2f(x, y)))
|
||||
CSFML_CALL(text, SetOrigin(x, y));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the color of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetColor(sfText* text, sfColor color)
|
||||
void sfText_GetPosition(const sfText* text, float* x, float* y)
|
||||
{
|
||||
CSFML_CALL(text, SetColor(sf::Color(color.r, color.g, color.b, color.a)))
|
||||
CSFML_CHECK(text);
|
||||
|
||||
sf::Vector2f point = text->This.GetPosition();
|
||||
|
||||
if (x)
|
||||
*x = point.x;
|
||||
if (y)
|
||||
*y = point.y;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the blending mode for a text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetBlendMode(sfText* text, sfBlendMode mode)
|
||||
{
|
||||
CSFML_CALL(text, SetBlendMode(static_cast<sf::Blend::Mode>(mode)))
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the X position of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfText_GetX(const sfText* text)
|
||||
{
|
||||
CSFML_CALL_RETURN(text, GetPosition().x, 0.f)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the Y position of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfText_GetY(const sfText* text)
|
||||
{
|
||||
CSFML_CALL_RETURN(text, GetPosition().y, 0.f)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the horizontal scale of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfText_GetScaleX(const sfText* text)
|
||||
{
|
||||
CSFML_CALL_RETURN(text, GetScale().x, 0.f)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the vertical scale of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfText_GetScaleY(const sfText* text)
|
||||
{
|
||||
CSFML_CALL_RETURN(text, GetScale().y, 0.f)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the orientation of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfText_GetRotation(const sfText* text)
|
||||
{
|
||||
CSFML_CALL_RETURN(text, GetRotation(), 0.f)
|
||||
CSFML_CALL_RETURN(text, GetRotation(), 0.f);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the X position of the origin a text
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfText_GetOriginX(const sfText* text)
|
||||
void sfText_GetScale(const sfText* text, float* x, float* y)
|
||||
{
|
||||
CSFML_CALL_RETURN(text, GetOrigin().x, 0.f)
|
||||
CSFML_CHECK(text);
|
||||
|
||||
sf::Vector2f point = text->This.GetScale();
|
||||
|
||||
if (x)
|
||||
*x = point.x;
|
||||
if (y)
|
||||
*y = point.y;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the top Y of the origin of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfText_GetOriginY(const sfText* text)
|
||||
void sfText_GetOrigin(const sfText* text, float* x, float* y)
|
||||
{
|
||||
CSFML_CALL_RETURN(text, GetOrigin().y, 0.f)
|
||||
CSFML_CHECK(text);
|
||||
|
||||
sf::Vector2f point = text->This.GetOrigin();
|
||||
|
||||
if (x)
|
||||
*x = point.x;
|
||||
if (y)
|
||||
*y = point.y;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the color of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfText_GetColor(const sfText* text)
|
||||
{
|
||||
sfColor color = {0, 0, 0, 0};
|
||||
CSFML_CHECK_RETURN(text, color)
|
||||
|
||||
sf::Color SFMLColor = text->This.GetColor();
|
||||
return sfColor_FromRGBA(SFMLColor.r, SFMLColor.g, SFMLColor.b, SFMLColor.a);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the current blending mode of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
sfBlendMode sfText_GetBlendMode(const sfText* text)
|
||||
{
|
||||
CSFML_CHECK_RETURN(text, sfBlendNone)
|
||||
|
||||
return static_cast<sfBlendMode>(text->This.GetBlendMode());
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Move a text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_Move(sfText* text, float offsetX, float offsetY)
|
||||
{
|
||||
CSFML_CALL(text, Move(sf::Vector2f(offsetX, offsetY)))
|
||||
CSFML_CALL(text, Move(offsetX, offsetY));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Scale a text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_Scale(sfText* text, float factorX, float factorY)
|
||||
{
|
||||
CSFML_CALL(text, Scale(sf::Vector2f(factorX, factorY)))
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Rotate a text
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_Rotate(sfText* text, float angle)
|
||||
{
|
||||
CSFML_CALL(text, Rotate(angle))
|
||||
CSFML_CALL(text, Rotate(angle));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Transform a point from global coordinates into the text's local coordinates
|
||||
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_TransformToLocal(const sfText* text, float pointX, float pointY, float* x, float* y)
|
||||
void sfText_Scale(sfText* text, float factorX, float factorY)
|
||||
{
|
||||
CSFML_CHECK(text)
|
||||
|
||||
sf::Vector2f point = text->This.TransformToLocal(sf::Vector2f(pointX, pointY));
|
||||
if (x) *x = point.x;
|
||||
if (y) *y = point.y;
|
||||
CSFML_CALL(text, Scale(factorX, factorY));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Transform a point from the text's local coordinates into global coordinates
|
||||
/// (ie it applies the object's origin, translation, rotation and scale to the point)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_TransformToGlobal(const sfText* text, float pointX, float pointY, float* x, float* y)
|
||||
const sfTransform* sfText_GetTransform(const sfText* text)
|
||||
{
|
||||
CSFML_CHECK(text)
|
||||
CSFML_CHECK_RETURN(text, NULL);
|
||||
|
||||
sf::Vector2f point = text->This.TransformToGlobal(sf::Vector2f(pointX, pointY));
|
||||
if (x) *x = point.x;
|
||||
if (y) *y = point.y;
|
||||
text->Transform.This = text->This.GetTransform();
|
||||
return &text->Transform;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the string of a text (from a multibyte string)
|
||||
const sfTransform* sfText_GetInverseTransform(const sfText* text)
|
||||
{
|
||||
CSFML_CHECK_RETURN(text, NULL);
|
||||
|
||||
text->InverseTransform.This = text->This.GetInverseTransform();
|
||||
return &text->InverseTransform;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetString(sfText* text, const char* string)
|
||||
{
|
||||
@@ -306,8 +183,6 @@ void sfText_SetString(sfText* text, const char* string)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the string of a text (from a unicode string)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetUnicodeString(sfText* text, const sfUint32* string)
|
||||
{
|
||||
@@ -316,8 +191,6 @@ void sfText_SetUnicodeString(sfText* text, const sfUint32* string)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the font of a string
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetFont(sfText* text, const sfFont* font)
|
||||
{
|
||||
@@ -328,8 +201,6 @@ void sfText_SetFont(sfText* text, const sfFont* font)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the size of a string
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetCharacterSize(sfText* text, unsigned int size)
|
||||
{
|
||||
@@ -337,8 +208,6 @@ void sfText_SetCharacterSize(sfText* text, unsigned int size)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the style of a string
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_SetStyle(sfText* text, sfUint32 style)
|
||||
{
|
||||
@@ -346,19 +215,6 @@ void sfText_SetStyle(sfText* text, sfUint32 style)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the string of a text (returns a unicode string)
|
||||
////////////////////////////////////////////////////////////
|
||||
const sfUint32* sfText_GetUnicodeString(const sfText* text)
|
||||
{
|
||||
CSFML_CHECK_RETURN(text, NULL)
|
||||
|
||||
return text->This.GetString().GetData();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the string of a text (returns an ANSI string)
|
||||
////////////////////////////////////////////////////////////
|
||||
const char* sfText_GetString(const sfText* text)
|
||||
{
|
||||
@@ -371,7 +227,14 @@ const char* sfText_GetString(const sfText* text)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the font used by a text
|
||||
const sfUint32* sfText_GetUnicodeString(const sfText* text)
|
||||
{
|
||||
CSFML_CHECK_RETURN(text, NULL)
|
||||
|
||||
return text->This.GetString().GetData();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const sfFont* sfText_GetFont(const sfText* text)
|
||||
{
|
||||
@@ -381,8 +244,6 @@ const sfFont* sfText_GetFont(const sfText* text)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the size of the characters of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int sfText_GetCharacterSize(const sfText* text)
|
||||
{
|
||||
@@ -390,8 +251,6 @@ unsigned int sfText_GetCharacterSize(const sfText* text)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the style of a text
|
||||
////////////////////////////////////////////////////////////
|
||||
sfUint32 sfText_GetStyle(const sfText* text)
|
||||
{
|
||||
@@ -400,33 +259,13 @@ sfUint32 sfText_GetStyle(const sfText* text)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Return the visual position of the Index-th character of the text,
|
||||
/// in coordinates relative to the text
|
||||
/// (note : translation, origin, rotation and scale are not applied)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfText_GetCharacterPos(const sfText* text, size_t index, float* x, float* y)
|
||||
void sfText_FindCharacterPos(const sfText* text, size_t index, float* x, float* y)
|
||||
{
|
||||
CSFML_CHECK(text);
|
||||
|
||||
sf::Vector2f pos = text->This.GetCharacterPos(index);
|
||||
if (x) *x = pos.x;
|
||||
if (y) *y = pos.y;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the bounding rectangle of a text on screen
|
||||
////////////////////////////////////////////////////////////
|
||||
sfFloatRect sfText_GetRect(const sfText* text)
|
||||
{
|
||||
sfFloatRect rect = {0.f, 0.f, 0.f, 0.f};
|
||||
CSFML_CHECK_RETURN(text, rect)
|
||||
|
||||
sf::FloatRect SFMLRect = text->This.GetRect();
|
||||
text->Rect.Left = SFMLRect.Left;
|
||||
text->Rect.Top = SFMLRect.Top;
|
||||
text->Rect.Width = SFMLRect.Width;
|
||||
text->Rect.Height = SFMLRect.Height;
|
||||
|
||||
return text->Rect;
|
||||
sf::Vector2f pos = text->This.FindCharacterPos(index);
|
||||
if (x)
|
||||
*x = pos.x;
|
||||
if (y)
|
||||
*y = pos.y;
|
||||
}
|
||||
Reference in new issue
Block a user