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

Author Topic: Window refuses to draw if I don't include iostream + other issues (solved)  (Read 4654 times)

0 Members and 1 Guest are viewing this topic.

two-tone-

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Window refuses to draw if I don't include iostream + other issues
« Reply #15 on: September 17, 2013, 11:15:09 pm »
The if statement at the beginning was removed, but other than that the sources are the exact same.  Yup, completely clean and rebuild.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Window refuses to draw if I don't include iostream + other issues
« Reply #16 on: September 17, 2013, 11:30:14 pm »
Kojay's right.  Taking the sources you posted, commenting out the uninitialized check and using create() makes the program work perfectly fine (it draws a red window I can actually move around and detects the escape key correctly).

Did you actually change Game::Start() to use create() as he suggested?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10914
    • View Profile
    • development blog
    • Email
Re: Window refuses to draw if I don't include iostream + other issues
« Reply #17 on: September 17, 2013, 11:32:00 pm »
Can you clarify what you mean with "But for some reason if I don't include iostream that function is either skipped or the window is not drawn."

What is "window" for you? And what do you understand with "draw".

As Kojay pointed out, the issue is with the locally created render window. Since it only gets created locally in the Start() function, all the clear/display function will get applied to a none existing window, thus nothing gets shown. Not sure what you did that it seemed to be still not working, but changing from
sf::RenderWindow mainWindow(sf::VideoMode(800, 800), "Heros of Late - Extreme Pre Alpha");
to
mainWindow.create(sf::VideoMode(800, 800), "Heros of Late - Extreme Pre Alpha");
should resolve the issue.

Also use the constructor for initializing variables.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

two-tone-

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Window refuses to draw if I don't include iostream + other issues
« Reply #18 on: September 17, 2013, 11:44:14 pm »
Ah ha, fixed it.  Simple misunderstanding on what Kojay said

I did

sf::RenderWindow mainWindow;
mainWindow.create(sf::VideoMode(800, 800), "Heros of Late - Extreme Pre Alpha");
    instead of just mainWindow.create(etc).  Oops ^^