ggiCheckMode

Name

ggiCheckMode, ggiCheckTextMode, ggiCheckGraphMode, ggiCheckSimpleMode -- Check or negotiate a text/graphics mode on a visual

Synopsis

#include <ggi/ggi.h>

int ggiCheckMode(ggi_visual_t vis, ggi_mode *tm);

int ggiCheckTextMode(ggi_visual_t visual, int cols, int rows, int vcols, int vrows, int fontx, int fonty, ggi_mode *suggested_mode);

int ggiCheckGraphMode(ggi_visual_t visual, int x, int y, int xv, int yv, ggi_graphtype type, ggi_mode *suggested_mode);

int ggiCheckSimpleMode(ggi_visual_t visual, int x, int y, int frames, ggi_graphtype type, ggi_mode *suggested_mode);

Description

ggiCheckMode checks whether or not the given mode will work on the visual. If it does not work, it will modify the values of passed ggi_mode structure so that the mode works. This mode negotiation allows the application to discover modes that are both supported by the visual and suitable to the application.

ggiCheckTextMode checks whether the text mode with the given visible and virtual dimensions and the font size is supported.

ggiCheckGraphMode checks whether the graphics mode with the given visible and virtual dimensions and type is supported.

ggiCheckSimpleMode checks wheter the graphics mode with the given visible dimensions, type, and number of buffers is supported. This is used in lieu of ggiCheckGraphMode if multiple buffering is desired.

For ggiCheckTextMode, ggiCheckGraphMode and ggiCheckSimpleMode, suggested_mode is either NULL or a pointer to a ggi_mode which will be filled in with the negotiated mode parameters.

Return value

For ggiCheckTextMode and ggiCheckGraphMode, a return of 0 means that the corresponding set mode call for this mode would succeed. Otherwise, the mode given cannot be set. In this case, suggested_mode is changed to the suggested mode.

If the only modifications made to the structure is replacing GGI_AUTO or GT_AUTO value, the functions return success.

Rules for mode negotiation

First, if GGI_AUTO (or GT_AUTO for the graphtype) is specified for any of the members of *tm, these are filled in with the recommended values. The values could be to a maximum, preferred, or GGI_DEFMODE resolution, and will be compatible with any other constraints.

An application that does not care about a specific paramater should always specify GGI_AUTO or GT_AUTO for it.

The resulting mode is guaranteed to be valid; if not, the application can assume that it cannot set any mode on the given visual and give up.

The suggested mode is derived as follows:

Examples

Example 1. Try a 320x200x8 mode

err = ggiCheckGraphMode(vis, 320, 200, GGI_AUTO, GGI_AUTO, GT_8BIT, 
                        &sug_mode, NULL);
if(err) {
        /* Check if returned mode is ok... */
}
else {
        ggiSetMode(&sug_mode);
}

See Also

ggiOpen(3ggi), ggiSetMode(3ggi)