Gamedev Framework (gf)
0.3.0
A C++11 framework for 2D games
|
A drawable for buffers. More...
#include <gf/BufferedGeometry.h>
Public Member Functions | |
BufferedGeometry () | |
Default constructor. More... | |
BufferedGeometry (const VertexBuffer &buffer) | |
Constructor with a buffer. More... | |
BufferedGeometry (const VertexBuffer &buffer, const VertexBuffer &outlineBuffer) | |
Constructor with a buffer and an outline buffer. More... | |
void | setBuffer (const VertexBuffer &buffer) |
Set the vertex buffer. More... | |
void | setOutlineBuffer (const VertexBuffer &outlineBuffer) |
Set the outline buffer, if any. More... | |
void | setTexture (const BareTexture &texture) |
Change the source texture of the geometry. More... | |
const BareTexture * | getTexture () const |
Get the source texture of the geometry. More... | |
void | unsetTexture () |
Unset the source texture of the geometry. More... | |
void | setLocalBounds (const RectF &bounds) |
Set the local bounds of the geometry. More... | |
RectF | getLocalBounds () const |
Get the local bounding rectangle of the entity. More... | |
void | setAnchor (Anchor anchor) |
Set the anchor origin of the entity. More... | |
virtual void | draw (RenderTarget &target, RenderStates states) override |
Draw the object to a render target. More... | |
Public Member Functions inherited from gf::Transformable | |
Transformable () | |
Default constructor. More... | |
void | setOrigin (Vector2f origin) |
Set the local origin of the object. More... | |
Vector2f | getOrigin () const |
Get the local origin of the object. More... | |
void | setPosition (Vector2f position) |
Set the position of the object. More... | |
Vector2f | getPosition () const |
Get the position of the object. More... | |
void | move (Vector2f offset) |
Move the object by a given offset. More... | |
void | setRotation (float angle) |
Set the orientation of the object. More... | |
float | getRotation () const |
Get the orientation of the object. More... | |
void | rotate (float angle) |
Rotate the object. More... | |
void | setScale (Vector2f factors) |
Set the scale factors of the object. More... | |
void | setScale (float factor) |
Set the scale factor of the object. More... | |
Vector2f | getScale () const |
Get the current scale of the object. More... | |
void | scale (Vector2f factors) |
Scale the object. More... | |
void | scale (float factor) |
Scale the object. More... | |
Matrix3f | getTransform () const |
Get the combined transform of the object. More... | |
Matrix3f | getInverseTransform () const |
Get the inverse of the combined transform of the object. More... | |
Public Member Functions inherited from gf::Drawable | |
virtual | ~Drawable () |
Virtual desctructor. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from gf::Transformable | |
void | setOriginFromAnchorAndBounds (Anchor anchor, const RectF &bounds) |
Set the origin from an anchor and bounds. More... | |
A drawable for buffers.
A buffered geometry is a lightweight object to draw vertex buffers. It can handle two vertex buffers, one for the main object and one for the outline when it exists. The outline is drawn first and the main object second.
In addition to the geometry, a buffered geometry can store a texture if needed because a vertex buffer has no notion of texture.
Finally, a buffered geometry can remember the local bounds of the original object, so that it can be used for setting an anchor.
gf::BufferedGeometry::BufferedGeometry | ( | ) |
Default constructor.
gf::BufferedGeometry::BufferedGeometry | ( | const VertexBuffer & | buffer | ) |
Constructor with a buffer.
buffer | A vertex buffer |
gf::BufferedGeometry::BufferedGeometry | ( | const VertexBuffer & | buffer, |
const VertexBuffer & | outlineBuffer | ||
) |
Constructor with a buffer and an outline buffer.
buffer | A vertex buffer |
outlineBuffer | An outline buffer |
|
overridevirtual |
Draw the object to a render target.
This is a pure virtual function that has to be implemented by the derived class to define how the drawable should be drawn.
target | Render target to draw to |
states | Current render states |
Implements gf::Drawable.
|
inline |
Get the local bounding rectangle of the entity.
The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.
|
inline |
Get the source texture of the geometry.
If the geometry has no source texture, a nullptr
pointer is returned. The returned pointer is const, which means that you can't modify the texture when you retrieve it with this function.
void gf::BufferedGeometry::setAnchor | ( | Anchor | anchor | ) |
Set the anchor origin of the entity.
Compute the origin of the entity based on the local bounds and the specified anchor. Internally, this function calls Transformable::setOrigin()
.
anchor | The anchor of the entity |
|
inline |
|
inline |
Set the local bounds of the geometry.
There is no way to compute the bounds of the object with the vertex buffer. So you have to set it directly with this function when you create the geometry.
bounds | The local bounds of the object |
|
inline |
|
inline |
Change the source texture of the geometry.
The texture must exist as long as the geometry uses it. Indeed, the geometry 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 geometry tries to use it, the behavior is undefined.
texture | The texture |
|
inline |
Unset the source texture of the geometry.
After a call to this function, the geometry has no source texture.