Next: , Up: API Conventions   [Index]


2.1 Enumerations

The OpenGL API defines many symbolic constants, most of which are collected together as named enumerations or bitfields. Access to these constants is the same for the low-level bindings and high-level interface.

For each OpenGL enumeration type, there is a similarly named Scheme type whose constructor takes an unquoted Scheme symbol naming one of the values. Guile-OpenGL translates the names to a more common Scheme style:

For example, the OpenGL API defines an enumeration with symbolic constants whose C names are GL_POINTS, GL_LINES, GL_TRIANGLES, and so on. Collectively they form the BeginMode enumeration type. To access these constants in Guile, apply the constant name to the enumeration type: (begin-mode triangles).

Bitfields are similar, though the constructor accepts multiple symbols and produces an appropriate mask. In the GLUT API there is the DisplayMode bitfield, with symbolic constants GLUT_RGB, GLUT_INDEX, GLUT_SINGLE, and so on. To create a mask representing a double-buffered, rgb display-mode with a depth buffer: (display-mode double rgb depth).

Enumeration and bitfield values, once constructed, can be compared using eqv?. For example, to determine if modelview is the current matrix mode use (eqv? (gl-matrix-mode) (matrix-mode modelview)).