3 Racket-Style OpenGL
(require sgl) |
The functions in sgl use Racket style names instead of C style names. To convert a C OpenGL name to a Racket OpenGL name, change the gl prefix to gl-, separate adjacent words with hyphens, and convert to all lower case. Functions that have several variants to accommodate different numbers and types of arguments are collapsed into one or two functions in sgl. For example, sgl provides two vertex functions: vertex and vertex-v. The vertex function accepts 2, 3 or 4 numerical arguments, and the vertex-v function accepts gl-vectors of length 2, 3 or 4. The C language OpenGL interface, in contrast, has 24 vertex functions: glVertex3i, glVertex4fv, etc.
Functions in sgl take symbols instead of integers for GLenum arguments. Each function checks that the given symbol is an acceptable argument and raises an exception if it is not. Given the name of a C-language #define constant, determine the corresponding symbolic argument by removing the leading GL_, converting the letters to lower-case and replacing each _ with -. For example, GL_TRIANGLES becomes 'triangles, and GL_TRIANGLE_STRIP becomes 'triangle-strip. Additionally, the functions check the length of any array arguments to ensure that OpenGL does not attempt to write or read after the array.
The sgl module is not as complete as the sgl/gl module.
Examples: | |||||
|
struct
(struct gl-selection-record (min-z max-z stack) #:extra-constructor-name make-gl-selection-record) min-z : real? max-z : real? stack : ....
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
procedure
(gl-process-selection vec hits) → (listof gl-selection-record?)
vec : gl-uint-vector? hits : exact-nonnegative-integer?
procedure
procedure