I recall reading this post:
http://en.sfml-dev.org/forums/index.php?topic=10855.msg74954#msg74954Although I did a quick test and it does compile/run (though I think I misread the post now that I look back at it ;]):
#include <SFML/Graphics.hpp>
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Playground");
int main( int argc, char* argv[])
{
sf::RectangleShape rectangle;
rectangle.setSize(sf::Vector2f(100, 50));
rectangle.setOutlineColor(sf::Color::Red);
rectangle.setOutlineThickness(5);
rectangle.setPosition(10, 20);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
}
window.draw( rectangle );
window.display();
window.clear();
}
return 0;
}
But why exactly would you need it global? If you have your main game loop drawing and updating states, it should be limited to that scope?
Any object can define its own draw function
private:
//we use this so we can have a nice draw(object) format
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
void Face::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
target.draw( *m_LeftEye );
target.draw( *m_RightEye );
target.draw( *m_Mouth );
target.draw( *m_Nose );
}
That way in main you can just do a window.draw(face)