28#include <SFML/Graphics/Drawable.hpp>
29#include <SFML/Graphics/GraphicsContext.hpp>
30#include <SFML/Window/Window.hpp>
45myBlendMode (
Blend::Alpha),
89 myInvNeedUpdate =
true;
100 myInvNeedUpdate =
true;
133 myInvNeedUpdate =
true;
147 myInvNeedUpdate =
true;
159 myCenter.x = CenterX;
160 myCenter.y = CenterY;
162 myInvNeedUpdate =
true;
182 myRotation =
static_cast<float>(fmod(Rotation, 360));
186 myInvNeedUpdate =
true;
270 SetX(myPosition.x + OffsetX);
271 SetY(myPosition.y + OffsetY);
339 myMatrix.SetFromTransformations(myCenter, myPosition, myRotation, myScale);
340 myNeedUpdate =
false;
356 myInvNeedUpdate =
false;
369 GLCheck(glMatrixMode(GL_MODELVIEW));
370 GLCheck(glPushMatrix());
371 GLCheck(glMultMatrixf(
GetMatrix().Get4x4Elements()));
376 GLCheck(glDisable(GL_BLEND));
380 GLCheck(glEnable(GL_BLEND));
384 case Blend::Alpha : GLCheck(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
break;
385 case Blend::Add : GLCheck(glBlendFunc(GL_SRC_ALPHA, GL_ONE));
break;
386 case Blend::Multiply : GLCheck(glBlendFunc(GL_DST_COLOR, GL_ZERO));
break;
392 GLCheck(glColor4f(myColor.r / 255.f, myColor.g / 255.f, myColor.b / 255.f, myColor.a / 255.f));
398 GLCheck(glMatrixMode(GL_MODELVIEW));
399 GLCheck(glPopMatrix());
Color is an utility class for manipulating 32-bits RGBA colors.
void SetScale(float ScaleX, float ScaleY)
Set the scale of the object (take 2 values).
void SetScaleX(float FactorX)
Set the X scale factor of the object.
void SetCenter(float CenterX, float CenterY)
Set the center of the object, in coordinates relative to the top-left of the object (take 2 values).
const Matrix3 & GetMatrix() const
Get the transform matrix of the drawable.
virtual ~Drawable()
Virtual destructor.
void Scale(float FactorX, float FactorY)
Scale the object (take 2 values).
const Vector2f & GetPosition() const
Get the position of the object.
const Vector2f & GetScale() const
Get the current scale of the object.
void Rotate(float Angle)
Rotate the object.
void SetPosition(float X, float Y)
Set the position of the object (take 2 values).
const Matrix3 & GetInverseMatrix() const
Get the inverse transform matrix of the drawable.
void Move(float OffsetX, float OffsetY)
Move the object of a given offset (take 2 values).
void SetRotation(float Rotation)
Set the orientation of the object.
sf::Vector2f TransformToGlobal(const sf::Vector2f &Point) const
Transform a point from local coordinates into global coordinates (ie it applies the object's center,...
Drawable(const Vector2f &Position=Vector2f(0, 0), const Vector2f &Scale=Vector2f(1, 1), float Rotation=0.f, const Color &Col=Color(255, 255, 255, 255))
Default constructor.
Blend::Mode GetBlendMode() const
Get the current blending mode.
const Color & GetColor() const
Get the color of the object.
void SetY(float Y)
Set the Y position of the object.
void SetScaleY(float FactorY)
Set the Y scale factor of the object.
void SetColor(const Color &Col)
Set the color of the object.
void SetBlendMode(Blend::Mode Mode)
Set the blending mode for the object.
const Vector2f & GetCenter() const
Get the center of the object.
void SetX(float X)
Set the X position of the object.
sf::Vector2f TransformToLocal(const sf::Vector2f &Point) const
Transform a point from global coordinates into local coordinates (ie it applies the inverse of object...
float GetRotation() const
Get the orientation of the object.
Utility class to manipulate 3x3 matrices representing 2D transformations.
Matrix3 GetInverse() const
Return the inverse of the matrix.
Vector2f Transform(const Vector2f &Point) const
Transform a point by the matrix.
Base class for all render targets (window, image, ...).
T x
X coordinate of the vector.
T y
Y coordinate of the vector.
Enumerate the blending modes for drawable objects.
@ Alpha
Pixel = Src * a + Dest * (1 - a).
@ Multiply
Pixel = Src * Dest.