Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problems with sf::RenderWindow::draw ()  (Read 2961 times)

0 Members and 2 Guests are viewing this topic.

hansefred

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Problems with sf::RenderWindow::draw ()
« 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 ();
 
« Last Edit: November 15, 2013, 12:14:42 pm by hansefred »

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Problems with sf::RenderWindow::draw ()
« Reply #1 on: November 14, 2013, 09:02:47 pm »
There is a lot wrong with your code. Take a look at the official tutorials. Especially the open a window, events and 2D drawing ones.

lockandstrike

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Problems with sf::RenderWindow::draw ()
« Reply #2 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.

KarmaKilledtheCat

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Problems with sf::RenderWindow::draw ()
« Reply #3 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Problems with sf::RenderWindow::draw ()
« Reply #4 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

hansefred

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Problems with sf::RenderWindow::draw ()
« Reply #5 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 .

hansefred

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Problems with sf::RenderWindow::draw ()
« Reply #6 on: November 15, 2013, 12:54:39 pm »
Thats not my normal code thx for answer

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: Problems with sf::RenderWindow::draw ()
« Reply #7 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?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Problems with sf::RenderWindow::draw ()
« Reply #8 on: November 15, 2013, 05:30:45 pm »
I agree with wintertime. Please read this thread and ask your question again :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: