c++ - SFML Window Not Rendering Shape -


#include <sfml/graphics.hpp> int main() {     sf::renderwindow window(sf::videomode(200, 200), "sfml works!");     sf::circleshape shape(100.f);     shape.setfillcolor(sf::color::green);      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; } 

this directly tutorial's page, , i've checked , rechecked, know not syntax or linker error.

when run program, window contents same whatever place located in. yet, if remove window.draw(shape) command, see black window, should.

i'm compiling on windows 7 (32 bit) using mingw32-g++.exe (4.7.1). oh, , it's same if compile debug or release , static or dynamic, that's not problem either.

your code correct, me looks need set position of circle. maybe wrong here position value , why isn't displaying.

could try updating code please.

sf::circleshape shape(100.f); shape.setfillcolor(sf::color::green); shape.setposition(50f, 50f); shape.setscale(2,2); // can remove line if want to, put there debugging  while (window.isopen()) {     ... 

here sfml documentation setposition (http://www.sfml-dev.org/documentation/2.0/classsf_1_1transformable.php#a4dbfb1a7c80688b0b4c477d706550208)

here sfml documentation setscale (http://www.sfml-dev.org/documentation/2.0/classsf_1_1transformable.php#aaec50b46b3f41b054763304d1e727471)

let me know if fixes problem.


Comments