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

Author Topic: Black screen showing after running program.  (Read 3968 times)

0 Members and 2 Guests are viewing this topic.

zchary

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Black screen showing after running program.
« 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...

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Black screen showing after running program.
« Reply #1 on: July 10, 2018, 10:02:22 am »
What's your code?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

zchary

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Black screen showing after running program.
« Reply #2 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Black screen showing after running program.
« Reply #3 on: July 10, 2018, 11:09:35 am »
What SFML version are you using?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

zchary

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Black screen showing after running program.
« Reply #4 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. :)

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Black screen showing after running program.
« Reply #5 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?
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Dschoonmaker

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Black screen showing after running program.
« Reply #6 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...

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Black screen showing after running program.
« Reply #7 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*