SFML community forums
Help => Graphics => Topic started by: strongdrink on September 09, 2011, 09:51:30 pm
-
Hello, I'm running into this issue.. I'm not sure why its doing this.. but here is some of my code
main.h
#include <SFML/Graphics.hpp>
sf::RenderWindow App;
main.cpp
...
#include "main.h"
App.Create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0x20), "Kinect Particles");
...
thanks!
-
Erhm.. do you do the include inside main? I believe that could result in some errors. Also why are you declaring the window in a header? That would mean you want it as a global variable?
-
Hello, I'm running into this issue.. I'm not sure why its doing this.. but here is some of my code
thanks!
Dont think you can do that :S
Keep class declarations etc in .hpp files, and code in .cpp files!
For this simple thing just put both lines in main.h into main.cpp, and delete include "main.h" in main.cpp
-
No, I'm not including in main
Yes, I need it in another file (a file with the class to render particles)
-
@Haikarainen: I need the declaration to be included in another file
-
But does the App.Create call come directly after you include the .h file? Like it does in the example?
Also if you want to use it in another file then you use the keyword extern, otherwise the variable might be copied several times and then you define it normally in a .cpp file which will create the global variable.
Anyway doing it like this is so much hazzle that it is one of the key points WHY you don't have globals.
-
Ok I got it... App.Create needed to be inside main.. thanks! :P