Hello there
I have a strange problem with drawing sprites on screen.
Here is an example:
main.cpp
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600, 32), "SFML works!");
sf::Text text("Hello SFML\nand here am i");
sf::Font font;
font.loadFromFile("XPDR06.TTF");
text.setFont(font);
text.setCharacterSize(8);
sf::Texture texture;
texture.loadFromFile("sprite.png");
sf::Sprite sprite(texture);
sf::Clock clock;
while (window.isOpen())
{
if(clock.getElapsedTime().asMilliseconds() > 1000/30)
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(text);
sprite.move(1,0);
window.draw(sprite);
window.display();
clock.restart();
}
}
return 0;
}
It works fine, but if i delete "window.draw(text);" it freeze drawing on about second frame.
What i do wrong?
I spend a lot of time to find the place, that affect on process...
Is it bug? or it's my mistake?
Thanks anyway =)
PS: Sorry for bad English