How to avoid args and argv for generation of panda window


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.


my codes are like these:

class PandaWindow
	PandaFramework framework;
	WindowFramework *window;
	PandaWindow(int argc, char *argv[]);

#include "../Header_Files/pandawindow.h"
    PandaWindow::PandaWindow(int argc, char *argv[])
    	framework.open_framework(argc, argv);
    	window = framework.open_window();

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:


You do not actually need to pass anything into this function. Panda does not actually use them for anything any more. You can just do this:

int argc = 0;
char **argv = nullptr;
framework.open_framework(argc, argv);


Yes, I also think this is more of a C/C++ programming question but I’m new to C++.
Thanks for your help! it really benefits a lot.


Thank you so much, it will help a lot and make things much more easier.