SFML community forums

Help => Window => Topic started by: Noirad on December 17, 2013, 07:41:03 am

Title: Window won't launch
Post by: Noirad on December 17, 2013, 07:41:03 am
Beginner testing out RenderWindow. When I run the build, the app icon continues to jump up and down but never actually launches. I assume from the code that a blank window should be shown until it recieves user input? I'm using Xcode 5.0.1 ... the Xcode 5 template runs just fine, even when pasting that same code into my project.

#include <SFML/graphics.hpp>
#include <iostream>


int main()
{
    sf::RenderWindow window(sf::VideoMode(800,600),"SFML Game");
    std::cin.get();
    return 0;
   
}
Title: AW: Window won't launch
Post by: eXpl0it3r on December 17, 2013, 08:00:12 am
cin.get() will block the whole thread, thus your window is blocked as well and it doesn't sound odd that the OS won't show it to you properly
Use the code from the tutorials, don't block the main thread and make sure to process events. ;)
Title: Re: Window won't launch
Post by: Noirad on December 19, 2013, 06:55:48 pm
I see. The code from the template does work. I am following a lecture online and the programmer is using visual basic c++ on windows  ... hes using that exact code and his window opens up and closes until a key is pressed; will it function differently on windows vs. mac/xcode?

Thank you!
Title: Re: Window won't launch
Post by: zsbzsb on December 19, 2013, 10:54:21 pm
Well I have never heard of the "visual basic c++" language, but whatever  :P

std::cin.get() might function differently on windows than mac because the implementation differs. What I suggest you do is buy a good C++ book and learn from that. Online tutorials/videos generally suck and they leave out lots of important details.
Title: Re: Window won't launch
Post by: Noirad on December 22, 2013, 04:31:45 am
Ehh, he is using Visual Studio on windows os is what I meant to say ... I am using Xcode on a mac.

Yeah, looks like the code just works differently on mac, because his program ran until it received user input. Thanks.