Testing for Graphics Capabilities

Testing for Graphics Capabilities — Checking whether the library supports graphics

Types and Values

Includes

#include <libchimara/glk.h>

Description

Before calling Glk graphics functions, you should use the gestalt selector gestalt_Graphics. To test for additional capabilities, you can also use the gestalt_DrawImage and gestalt_GraphicsTransparency selectors.

Functions

Types and Values

GLK_MODULE_IMAGE

#define GLK_MODULE_IMAGE

If you are writing a C program, there is an additional complication. A library which does not support graphics may not implement the graphics functions at all. Even if you put gestalt tests around your graphics calls, you may get link-time errors. If the glk.h file is so old that it does not declare the graphics functions and constants, you may even get compile-time errors.

To avoid this, you can perform a preprocessor test for the existence of GLK_MODULE_IMAGE. If this is defined, so are all the functions and constants described in this section. If not, not.

To be extremely specific, there are two ways this can happen. If the glk.h file that comes with the library is too old to have the graphics declarations in it, it will of course lack GLK_MODULE_IMAGE as well. If the glk.h file is recent, but the library is old, the definition of GLK_MODULE_IMAGE should be removed from glk.h, to avoid link errors. This is not a great solution. A better one is for the library to implement the graphics functions as stubs that do nothing (or cause run-time errors). Since no program will call the stubs without testing gestalt_Graphics, this is sufficient.