28 #include <SFML/Graphics/Drawable.hpp> 29 #include <SFML/Graphics/GraphicsContext.hpp> 30 #include <SFML/Window/Window.hpp> 40 myPosition (Position),
43 myRotation (Rotation),
45 myBlendMode (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);
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());
void Rotate(float Angle)
Rotate the object.
Uint8 a
Alpha (transparency) component.
sf::Vector2f TransformToGlobal(const sf::Vector2f &Point) const
Transform a point from local coordinates into global coordinates (ie it applies the object's center...
const Matrix3 & GetMatrix() const
Get the transform matrix of the drawable.
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 & GetInverseMatrix() const
Get the inverse transform matrix of the drawable.
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.
T x
X coordinate of the vector.
const Vector2f & GetScale() const
Get the current scale of the object.
const Color & GetColor() const
Get the color of the object.
void SetBlendMode(Blend::Mode Mode)
Set the blending mode for the object.
void SetColor(const Color &Col)
Set the color of the object.
void SetY(float Y)
Set the Y position of the object.
void SetX(float X)
Set the X position of the object.
Pixel = Src * a + Dest * (1 - a)
void SetScaleY(float FactorY)
Set the Y scale factor of the object.
Utility class to manipulate 3x3 matrices representing 2D transformations.
float GetRotation() const
Get the orientation of the object.
void SetPosition(float X, float Y)
Set the position of the object (take 2 values)
void SetScale(float ScaleX, float ScaleY)
Set the scale of the object (take 2 values)
Vector2f Transform(const Vector2f &Point) const
Transform a point by the matrix.
void SetScaleX(float FactorX)
Set the X scale factor of the object.
const Vector2f & GetCenter() const
Get the center of the object.
virtual ~Drawable()
Virtual destructor.
void SetRotation(float Rotation)
Set the orientation of the object.
Color is an utility class for manipulating 32-bits RGBA colors.
void Scale(float FactorX, float FactorY)
Scale the object (take 2 values)
T y
Y coordinate of the vector.
const Vector2f & GetPosition() const
Get the position of the object.
Blend::Mode GetBlendMode() const
Get the current blending mode.
Matrix3 GetInverse() const
Return the inverse of the matrix.
Base class for all render targets (window, image, ...)
void Move(float OffsetX, float OffsetY)
Move the object of a given offset (take 2 values)
sf::Vector2f TransformToLocal(const sf::Vector2f &Point) const
Transform a point from global coordinates into local coordinates (ie it applies the inverse of object...
void SetFromTransformations(const Vector2f &Center, const Vector2f &Translation, float Rotation, const Vector2f &Scale)
Build a matrix from a set of transformations.