I haven't had a lot of time to work on this lately, but here are some news anyway.
First, I renamed classes to Vertex and VertexArray. If someone tells me that Point/Mesh were better names, I kill him :mrgreen:
The second point is a new concept. I was thinking about changing how render states (transform, texture, shader, blend mode) were managed. Currently, they can be read/written with accessors in sf::RenderTarget, and they are persistent between two calls to Draw.
window.SetTexture(texture);
window.SetTransform(transform1);
window.Draw(geometry1);
window.SetTransform(transform2);
window.Draw(geometry2);
I don't like persistent states because when you draw something you never know what value each state has, and you have to overwrite them all to be safe. But you also have to push/pop them so that the parent entity can find its states back if it needs to render other children.
My idea was to get rid of all getters and setters, and instead implement a new class named RenderStates, that would hold the states to use for a drawing operation.
class RenderStates
{
BlendMode blendMode;
Transform transform;
const Texture* texture;
const Shader* shader;
};
class RenderTarget
{
void Draw(const Drawable& drawable, RenderStates states = RenderStates::Default);
};
States would be forwarded, modified if needed, along the hierarchy of Draw calls:
class Sprite : public Drawable, public Transformable
{
void Draw(RenderTarget& target, RenderStates states)
{
states.transform *= GetTransform();
states.texture = myTexture;
target.Draw(myVertexArray, states);
}
};
... and finally applied at the lowest level, when drawing a vertex array
class RenderTarget
{
void Draw(const VertexArray& vertexArray, RenderStates states = RenderStates::Default)
{
// apply states
// render vertex array
}
};
For convenience, RenderStates will have implicit constructors taking a single state, so that you can write this kind of code:
window.Draw(entity, transform);
window.Draw(sprite, shader);
...