Hi all
I'm actually having a little (but really anoying) problem.
I have my own class to draw a sprite on sceen, instead of using the sf::Sprite. This works pretty fine.
I wanted to add some text on my screen, so i simply created a sfml::Text object then drew it, as i do with other drawables items.
This works, no problem. But i wanted to add something else :
Moving my scene. I working in a 2D scene (i mean, i don't use gluOrtho or whatever to draw in 2D, i just use the draw method of sf::RenderWindow)
So, to move the scene, i use glTranslatef(), wich works pretty fine, as far as i don't draw the text on the screen.
Well, it's a little bit hard to explain what's happening.
In one of my function, i first draw my sprite, then some text over it. Simply drawing the text after my own sprite makes glTranslatef do nothing.
And the most strange thing is that if i draw the text before my sprite, glTranslatef() works fine, and the world is moving (but the text is under my sprite so it doesn't appear)
What the hell ?
Here is the draw() function of my sprite class :
void FixedSprite::draw(sf::RenderTarget &target, sf::RenderStates states) const
{
if (_texture)
{
states.texture = _texture;
states.transform *= getTransform();
target.draw(_vertex, 4, sf::Quads, states);
}
}
I have _texture wich is a pointer on a texture i load before.
_vertex is an array of 4 sf::Vertex
Do you have any idea why drawing the text after drawing the sprite make glTranslatef() do nothing ?
Or do you have a better way to move the whole scene, without having to go through all my objects and moving'em one by one ?
Thanks.