SFML community forums

Help => General => Topic started by: zchary on July 09, 2018, 05:54:57 am

Title: Black screen showing after running program.
Post by: zchary on July 09, 2018, 05:54:57 am
I'm running an example of SFML tutorial on Xcode(macOS), showing a black screen instead of Cyan circle. After a few trying, I find that the circle only shows after I Maximizing the window. So I think that there might be some problems on the SFML package or the system.

anyone has the same problem? please help...
Title: Re: Black screen showing after running program.
Post by: eXpl0it3r on July 10, 2018, 10:02:22 am
What's your code?
Title: Re: Black screen showing after running program.
Post by: zchary on July 10, 2018, 10:39:20 am
here's my code:
#include<SFML/Graphics.hpp>
int main(int argc, char const *argv[])
{
   sf::RenderWindow window(sf::VideoMode(640,800),"TEST");
   sf::CircleShape shape;

   shape.setRadius(40.f);
   shape.setPosition(100.f, 100.f);
   shape.setFillColor(sf::color::Cyan);

   while(window.isOpen())
   {
      sf::Event event;
      while(window.pollEvent(event))
      {
         if(event.type==sf::Event::Closed)
            window.close();
      }
      window.clear();
      window.draw(shape);
      window.display();
   }


   return 0;
}

the `shape` only shows after I max maximizing the window.
Title: Re: Black screen showing after running program.
Post by: eXpl0it3r on July 10, 2018, 11:09:35 am
What SFML version are you using?
Title: Re: Black screen showing after running program.
Post by: zchary on July 13, 2018, 05:01:36 am
SFML version is the newest 2.5.0, my computer system is macOS Mojave 10.14 Beta, MacBook Pro (Retina, 13-inch, Early 2015), Xcode version is 9.3, CLion version is 2018.1.5. :)
Title: Re: Black screen showing after running program.
Post by: Stauricus on July 13, 2018, 12:25:01 pm
well, your code works for me, so that isn't the problem.
oh, just one thing is wrong. instead of
shape.setFillColor(sf::color::Cyan);
use
shape.setFillColor(sf::Color::Cyan);
(with a capital C in Color).

probably a OS related bug?
Title: Re: Black screen showing after running program.
Post by: Dschoonmaker on July 17, 2018, 03:42:40 pm
Maybe you setup SFML wrong.
Does it give you any errors?
Have you tried any other code?

I think your code is ok...
Title: Re: Black screen showing after running program.
Post by: Hapax on July 17, 2018, 03:47:14 pm
Since the code was incorrect (needs a capital c as shown in a post above), it might not have been copied directly and instead been rewritten better than the code being tested. The problem could have simply been an accidental misplacement of a closing curly bracket. That is, the clear/draw/display ended up in the event loop.