Hey folks
i just want to show a small example about scope when dealing with preprocessor and functions that i have a little problem with
So.... i have the main functions and another function in a header... heres my code.
//MAIN.CPP
#include <SFML\Graphics.hpp>
#include "world1.h"
sf::RenderWindow mywindow(sf::VideoMode(800,600,32),"dsadsa");
sf::Event ev;
int main()
{
while(mywindow.isOpen())
{
while(mywindow.pollEvent(ev))
{
if(ev.type == sf::Event::Closed)
mywindow.close();
}
world1();
}
}
//WORLD1.H
#include <SFML\Graphics.hpp>
void world1()
{
mywindow.clear(sf::Color(0,200,0));
mywindow.display();
}
So basically, the problem is that an error aqquires and says that mywindow is unidentified.
I actually tried to define my RenderWindow variable "before" i #included the world1.h.
And that worked.... but is that really how you should do it to make my renderwindow variable be accessed in all function in other headers?