   NeHE SDK, using global variables
  I am programming just for fun, and I am really a beginner when it comes to object oriented programming. I downloaded the latest SDK from the website of NeHe. And I want to code a simple program, and I need to know, if the user has changed the window width, height. Ofcourse in my Draw() routine. ReshapeGL() function gets these parameters. And I want to have 2 global variables, and just after the ReshapeGL() is called, I will set myglobal_width=width;myglobal_height=height;Just at the beginning of ReshapeGL. And my draw() function will use the global variables, for drawing routines. But I can not do that.PS: I know I can pass parameters to Draw function, when calling it frmo the main loop. But it seems not that much elegant to me. Because I don''t want to pass lots of values to each function, and I might also use the variables within other functions.   inferno* artist 
  Why can''t you do that?Are you coding in C++?There global variables supported, should be no problem   Corrailcorrail@gmx.atICQ#59184081 ;  The problem is:The ReshapeGL() function is in another .cpp file. And My draw() function is in another .cpp file. And if I define the same variable, at the beginning of both .cpp files. I get an error, that variable is alredy defined.Yes, I am using VC++ 6.0;  You''d want to declare it in a header file that''s shared between the two source files, and then define it in one of the source files. Like so:shared.h:extern int myglobal_width;another.cpp:int myglobal_width;Then everyone who includes shared.h can alter the values of myglobal_width. ;quote:Original post by Anonymous Poster  You''d want to declare it in a header file that''s shared between the two source files, and then define it in one of the source files. Like so:shared.h:extern int myglobal_width;another.cpp:int myglobal_width;Then everyone who includes shared.h can alter the values of myglobal_width.   Thanks a lot. This really worked. You helped a C++ novice like me, thanks you for your time.