trace: Adds support for on-demand tracing of OpenGL on Windows, Linux, and OSX.
This change targets Core Profile of OpenGL 3.3 and newer.

Object creation is tracked from the beginning of the application; immediately prior to the first frame to trace a snapshot of all state and objects will be created and emitted into the trace file, recreating all the state at the beginning of that frame. The back buffer is then cleared and a SwapBuffers calls is made. The resulting trace will show all the object creation and state recreation in Frame 0.

The remaining frames in the trace will be recorded the same as they have been in the past. The tracing will stop after a user-supplied number of frames.

This functionality will only be enabled if the --frame or -f command line options are used. Full tracing of all frames will still behave as it previously did.

The generated trace files are fully replayable. Using glretrace with the --loop option allows the last frame to be easily debuggable using other 3rd party tools (AMD's GPU PerfStudio 2, NVidia's Parallel NSight, Intel's Graphics Performance Analyzer, etc)

When the trace is completed, a message will be output to indicate how many frames were traced, and the trace file will be closed so that it can immediately be inspected with qapitrace. Currently only a single trace file can be generated per run of the application, and the file detection (see below) is disabled to ensure that users don't start a second on-demand trace. I have this on my desired feature list though, so hopefully this will not be a limitation in the future.

Also, when the state snapshot is taking place at the start of on-demand tracing, there will be a few second pause during which all the state is being queried and the trace calls are being emitted. This is expected and not likely to experience much improvement in the future. The duration of the pause is heavily dependent on the complexity of the application and the number of shader and texture objects that need to be queried.

There are various ways to benefit from this functionality:
--frame=50    Will generate a trace file that recreates all the state at the beginning of frame 50 and then only frame 50.

--frame=50-50  Should behave the same as --frame=50

--frame=50-120 Will generate a trace file that recreates all the state at the beginning of frame 50 and will then trace the next 71 frames (between frame 50 and frame 120, inclusive).

--frame=x    (or any other alphabetic character) will enable file-based on-demand tracing which uses the existence/creation of files to control tracing.

The follow commands demonstrate how to use on-demand tracing:
'touch snap'   when a file called 'snap' is detected in the app's working directory the state will be recreated and the next single frame will be traced.

'echo 71 > snap'  The state will be recreated and the 71 frames after 'snap' is detected will be traced. (Note that I have experienced the 'snap' file being detected before the number was written into the file, which resulted in a single frame being traced, so this may not be the best approach to use)

'touch starttrace'  The state will be recreated when 'starttrace' is detected, and all frames after that will be traced until a file called 'stoptrace' is detected or the application exits.

'touch stoptrace' Stops on-demand tracing.