### Finding Available Display Modes

Before any of the drawing functions can be called, one of the supported display modes must be initialized by the application program by calling the SetVideoMode function. The SciTech SNAP Graphics Architecture does not define a standard display mode numbering scheme but rather relies on the application to search through the list of available display modes for one that has the desired resolution and pixel depth. In order to find a valid video mode number to be passed to SetVideoMode, the GetVideoModeInfo function is used to obtain specific information about all of the available video modes supported by the loaded driver. The list of available video modes is stored in the AvailableModes field of the GA_devCtx structure. Once the desired display mode has been identified, this display mode number can be used in the call to SetVideoMode.

The general procedure you would normally follow to find the identifier for a display mode with a particular X and Y resolution is as follows:

N_uint16 FindGraphicsMode(
GA_devCtx *dc,
int xRes,
int yRes,
int bitsPerPixel)
{
GA_initFuncs init;
GA_modeInfo modeInfo;
N_uint16 *modes;
/* Load the driver init functions */
init.dwSize = sizeof(init);
if (!GA_queryFunctions(dc,GA_GET_INITFUNCS,&init))
return 0xFFFF;
/* Search for the display mode */
for (modes = dc->AvailableModes; *modes != 0xFFFF; modes++) {
modeInfo.dwSize = sizeof(modeInfo);
if (init.GetVideoModeInfo(*modes,&modeInfo) != 0)
continue;
if (modeInfo.Attributes & gaIsTextMode)
continue;
if (modeInfo.XResolution == xRes &&
modeInfo.YResolution == yRes &&
modeInfo.BitsPerPixel == bitsPerPixel)
return *modes;
}
return 0xFFFF;
}

Copyright © 2002 SciTech Software, Inc. Visit our web site at http://www.scitechsoft.com