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

Author Topic: Window won't launch  (Read 1664 times)

0 Members and 1 Guest are viewing this topic.

Noirad

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • www.darionmccoy.com
Window won't launch
« 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;
   
}
twitter/tumblr: @darionmccoy

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
AW: Window won't launch
« Reply #1 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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Noirad

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • www.darionmccoy.com
Re: Window won't launch
« Reply #2 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!
twitter/tumblr: @darionmccoy

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Window won't launch
« Reply #3 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.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Noirad

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • www.darionmccoy.com
Re: Window won't launch
« Reply #4 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.
twitter/tumblr: @darionmccoy