BOINC applications can optionally generate graphics. Graphics are displayed either in an application window or in a full-screen window (when acting as a screensaver). Applications that do graphics must call
    void boinc_init_graphics();
at the start and
    void boinc_finish_graphics();
prior to exiting.

The main application thread is called the worker thread. boinc_init_graphics() creates a second thread, called the graphics thread. The two threads communicate through application-defined shared memory structures. Typically these structures contain information about the computation, which is used to generate graphics.

The worker must initialize the shared data structure before calling boinc_init_graphics().

Graphical applications must supply the following functions:

    bool app_graphics_render(int xs, ys, double time_of_day);
This will be called periodically in the graphics thread. It should generate the current graphic. xs and ys are the X and Y sizes of the window, and time_of_day is the relative time in seconds. The function should return true if it actually drew anything. It can refer to the user name, CPU time etc. obtained from boinc_get_init_data(). Applications that don't do graphics must also supply a dummy app_graphics_render() to link with the API.
    void app_graphics_init();
This is called in the graphics thread when a window is created. It must make any calls needed to initialize graphics in the window.
    void app_graphics_resize(int x, int y);
Called when the window size changes.
    void app_graphics_reread_prefs();
This is called, in the graphics thread, whenever the user's project preferences change. It can call
    boinc_parse_init_data_file();
    boinc_get_init_data(APP_INIT_DATA&);
to get the new preferences.

Limiting frame rate

The following global variables control frame rate:

boinc_max_fps is an upper bound on the number of frames per second (default 30).

boinc_max_gfx_cpu_frac is an upper bound on the fraction of CPU time used for graphics (default 0.5).

Support classes

Several graphics-related classes were developed for SETI@home/BOINC. They may be of general utility.

REDUCED_ARRAY
Represents a two-dimensional array of data, which is reduced to a smaller dimension by averaging or taking extrema. Includes member functions for drawing the reduced data as a 3D graph.
PROGRESS and PROGRESS_2D
Represent progress bars, depicted in 3 or 2 dimensions.
RIBBON_GRAPH
Represents of 3D graph of a function of 1 variable.
MOVING_TEXT_PANEL
Represents a flanged 3D panel, moving cyclically in 3 dimentions, on which text is displayed.
STARFIELD
Represents a set of randomly-generated stars that move forwards or backwards in 3 dimensions.
TEXTURE_DESC
Represents an image (JPEG, Targa, BMP or PNG) displayed in 3 dimensions.
"; page_tail(); ?>