Startup
The VMD startup process is somewhat system dependent. Generally speaking, VMD performs various initialization tasks that depend on command line options, environment variables, and Windows Registry keys, depending on the platform.
On Unix systems, VMD is started via a shell script which is created when the program is initially installed. The startup script sets a few key environment variables. The most important environment variable is the VMDDIR variable, which tells VMD where to find its installation directory, so that it can source various initialization scripts and find helper programs such as Surf, MSMS, and Tachyon. The VMDGetOptions() routine processes the environment variables and command line options. On Windows, a special win32vmdstart() routine does some initial registry queries and environment variable manipulations to get the program bootstrapped.
Command line options affect the choice of display device which can be a text-only command interpreter, text + full GUI and OpenGL, or special CAVE and FreeVR modes which can be run with or without the regular GUI forms. The command line display device options and the environment variables are all documented in the User's Guide. After the main routine gets the appropriate VMDApp state initialized, the DisplayDevice is initialized and the title screen is displayed.
Scripts can be executed at startup time through the use of the -e command line option. These scripts are then "played" after VMD is initialized but before the user's .vmdrc file is read. This is done inside of the VMDreadStartup() routine.
Once the initialization stages are complete, VMD enters an event loop that continues until the user quits or the program terminates itself due to errors. The main event loop simply calls the VMDApp::VMDupdate() method to check for events and act on them.
Roughly speaking the event loop looks like this:
When the user quits VMD via the GUI or by text commands, or when VMD encounters an unrecoverable error or some kind, the program frees all dynamically allocated data, destroys the GUI forms and the DisplayDevice in use, and calls any special termination routines before returning from main.