SFML community forums

Help => Graphics => Topic started by: hansefred on November 14, 2013, 08:52:17 pm

Title: Problems with sf::RenderWindow::draw ()
Post by: hansefred on November 14, 2013, 08:52:17 pm
I add simple draw function to my project but now every time i start the .exe the window don't answer

 sf::RenderWindow a (sf::VideoMode (1280,720),"TRY");
       
        sf::Text b ("HELLO");
        sf::Text c ("HELLO");

       
       
        a.clear (sf::Color::Blue);
        a.draw (b);
        a.draw (c);
        a.display ();
 
Title: Re: Problems with sf::RenderWindow::draw ()
Post by: Foaly on November 14, 2013, 09:02:47 pm
There is a lot wrong with your code. Take a look at the official tutorials (http://www.sfml-dev.org/tutorials/2.1/). Especially the open a window, events and 2D drawing ones.
Title: Re: Problems with sf::RenderWindow::draw ()
Post by: lockandstrike on November 14, 2013, 11:09:16 pm
As Foaly sad there is a lot going wrong there but your app is not responding due to this line of code:

a.draw (a);

You are probably looking for this:

a.draw (b);

But the text won't draw anything because you don't specify a font (At least I think SFML 2.x doesn't have a default font). Another thing is you shouldn't name your variables like a,b and c. Name them after what they are for.
Title: Re: Problems with sf::RenderWindow::draw ()
Post by: KarmaKilledtheCat on November 15, 2013, 01:39:36 am
To draw and sf::Text, you need an sf::Font that contains the font of the text. Look through the sf::Text tutorial more carefully.
Title: Re: Problems with sf::RenderWindow::draw ()
Post by: eXpl0it3r on November 15, 2013, 08:21:05 am
The code snipped shouldn't even compile, since you can't draw a RenderWindow. ;)

The "Not Responding" dialog pops up when you don't process events. If you don't check for events Windows starts to think that you application is hung up, that's why it shows a "Not Responding" dialog. You should follow the tutorials to see how to handle events.
Title: Re: Problems with sf::RenderWindow::draw ()
Post by: hansefred on November 15, 2013, 12:16:42 pm
That was not my code it was only an example.  normaly i named my variable not a or b .
Title: Re: Problems with sf::RenderWindow::draw ()
Post by: hansefred on November 15, 2013, 12:54:39 pm
Thats not my normal code thx for answer
Title: Re: Problems with sf::RenderWindow::draw ()
Post by: wintertime on November 15, 2013, 02:54:19 pm
If you show something else with typos you just typed in its even worse than not providing code as you mislead the people who want to help. Or how do you expect them to know what your real problem is if you dont show the interesting parts of your real code?
Title: Re: Problems with sf::RenderWindow::draw ()
Post by: Nexus on November 15, 2013, 05:30:45 pm
I agree with wintertime. Please read this thread (http://en.sfml-dev.org/forums/index.php?topic=5559.0) and ask your question again :)