These days I want to rewritten my codes into several .h and .cpp files.
I think some common nodepaths, such as camera, window->get_render()… are used frequently and thus I want to state them as global variables so that they can be passed to different class and functions conveniently.
However, I found that the function open_framework needs two parameters (int argc, char *argv[]), which prevent me to initialize my framework and window unless in the main function. (I only know how to get the two parameters in main function).
so how can I initialize my framework out of the main function ? or it is necessary and must be finished in the main function?
Thanks in advance.
such statements are okay.
But when I use PandaWindow * panda_window = new PandaWindow(argc, argv);
out of the main function, there are red lines under “argc” and “argv”,
so I can only to use it in my main function now…
Please help
I think this is more of a C/C++ programming question.
You have to make those values available either by storing them in global variables when you first access them in main() or by passing them around as function parameters.
There is very similar question in SO, whether you want to process them in your program, or just pass them to another framework (Panda in this example), the suggestions still help: