This Isis interface library provides full support for every aspect of OpenGL, including the GL, GLU, GLUT, and GLX libraries. The interface routines are efficient and direct. Callbacks are also fully supported.
The functions available in Isis are identical to their counterparts in C. The function names, argument types, return types, and constants are exactly the same. Therefore, if you know how to use OpenGL in C, you can start writing OpenGL scripts in Isis immediately. The only difference is in the way strings and callbacks are handled, and this explained below.
Obviously, OpenGL must be installed on your system in order for anything to work. If you are unsure, check with your system administrator.
This library also provides a number of utility routines, written directly in Isis, for simplifying things like drawing simple shapes, creating and manipulating texture maps, and rendering texture-mapped text.
would be called in Isis like this:
void glColor3f (GLfloat red, GLfloat green, GLfloat blue);
In general, calling a function with no arguments will display a short help message about the arguments that it expects (unless, of course, it actually expects no arguments).
(glColor3f 0.3 0.7 1.0)
-> (glColor3f) ** glColor3f: Expects 3 arguments. ** red, green, blue
(glClear GL_COLOR_BUFFER_BIT) (glBegin GL_TRIANGLES)
If the OpenGL function expects a string (a pointer to characters), you may pass a regular Isis string. Similarly, if the OpenGL function returns a pointer to characters, then it will be converted to an Isis string (list of characters).
Otherwise, if the OpenGL function expects a pointer to data of any other type, you must pass an Isis address that points to data of the corresponding C type. Similarly, if the OpenGL function returns a pointer, it is returned in Isis as an address. The utilities in the memory manipulation library can be used to convert between Isis lists and arrays of the appropriate C type.
The table below shows the correspondence between types used by OpenGL, C, and Isis.
|OpenGL type||C type||Isis type|
For example, take the following OpenGL C function:
This function expects a pointer to characters. Therefore, you can pass a regular Isis string, like this:
int glutCreateWindow(char *title);
Now take this OpenGL C function:
(glutCreateWindow "single triangle")
This function expects a pointer to data of type GLfloat, which from the table above, we know corresponds to the C type c-float. Therefore, you need to use pack to create an array of floats to pass to the function. If you do not intend to use the array after the function is called, be sure to free it. Here is an example:
void glColor3fv (GLfloat *v);
(set colbuf (pack [0.4 0.7 0.2] c-float)) (glColor3fv colbuf) (free colbuf)
Middleman C functions have already been defined for every possible OpenGL callback, and addresses of these functions are bound in Isis (see table below). When you register a callback, you must pass the address of the appropriate middleman C function directly to OpenGL. Then you must tell that middleman C function which Isis procedure it should call by updating its "callback slot" (see table below). Use these functions to update callback slots:
For example, suppose you want to set the window reshape callback in GLUT. As described in the OpenGL documentation, the reshape function should take two arguments: a width and height. Here is an example of how to define the callback procedure and register it with OpenGL:
First, the reshape Isis procedure is created. Then, the address of the appropriate middleman C function (found in the table below) is registered directly with OpenGL. Then the callback slot for that middleman C function (also found in the table below) is updated to the Isis reshape procedure.
(set reshape (proc (w h) (print "Window resized to: " [w h] newline))) (glutReshapeFunc glut_reshape) (update-glut-callback-slot glut_reshape_slot reshape)
The addresses of the middleman C functions are defined in Isis under the names listed below:
glut_create_menu glut_display glut_reshape glut_keyboard glut_mouse glut_motion glut_passive_motion glut_entry glut_visibility glut_idle glut_timer glut_menu_state glut_special glut_spaceball_motion glut_spaceball_rotate glut_spaceball_button glut_button_box glut_dials glut_tablet_motion glut_tablet_button glut_menu_status glut_overlay_display glu_tess_begin glu_tess_begin_data glu_tess_edge_flag glu_tess_edge_flag_data glu_tess_vertex glu_tess_vertex_data glu_tess_end glu_tess_end_data glu_tess_combine glu_tess_combine_data glu_tess_error glu_tess_error_data glu_quadric_error glu_nurbs_error
Below is the list of callback slots corresponding to each of the middleman functions:
glut_create_menu_slot glut_display_slot glut_reshape_slot glut_keyboard_slot glut_mouse_slot glut_motion_slot glut_passive_motion_slot glut_entry_slot glut_visibility_slot glut_idle_slot glut_timer_slot glut_menu_state_slot glut_special_slot glut_spaceball_motion_slot glut_spaceball_rotate_slot glut_spaceball_button_slot glut_button_box_slot glut_dials_slot glut_tablet_motion_slot glut_tablet_button_slot glut_menu_status_slot glut_overlay_display_slot glu_tess_begin_slot glu_tess_begin_data_slot glu_tess_edge_flag_slot glu_tess_edge_flag_data_slot glu_tess_vertex_slot glu_tess_vertex_data_slot glu_tess_end_slot glu_tess_end_data_slot glu_tess_combine_slot glu_tess_combine_data_slot glu_tess_error_slot glu_tess_error_data_slot glu_quadric_error_slot glu_nurbs_error_slot
gl-transfer-convert-rgba will convert an arbitrary image into RGBA format. inbuf should be a byte-sampled buffer consisting of between 1 and 4 channels. outbuf should be a 4-channel byte-sampled buffer, perhaps one allocated with gl-new-image. The output image is formed differently depending on the number of channels in the input image. If the input has only 1 channel (intensity), that channel is duplicated into the first three channels of the output, and the output alpha channel is filled with 255. If the input has 2 channels (intensity and alpha), the second channel is used as the output alpha channel. If the input has 3 channels (RGB), they are duplicated into the first 3 channels of the output, and the alpha channel is again filled with 255. If the input has 4 channels (RGB with alpha), it is transferred without any change.
These fonts have been developed especially for Isis. They are typically stored in the fonts subdirectory of the Isis root directory on your system. gl-load-font will automatically search for fonts there. Check the directory for a full list of what's available.
gl-generate-texture-image loads an arbitrary Isis image into the specified texture object. A scale factor (a list of 2 real numbers) indicates how the image should be scaled before creating a texture from it. Normally you would pass [1.0 1.0], but you could provide smaller scale factors if texture memory is limited.
internal-format specifies the format of the image in internal texture memory (read about them on the man page for glTexImage2D()). In most cases you will want it to be just GL_RGBA or GL_RGB, depending on the number of channels.
gl-find-texture-size accepts an image size and returns the closest valid texture size that will hold the entire image. gl-set-texture-image loads the given image directly into the texture. It must be an interleaved byte-sampled image (such as one created with gl-new-image) with valid texture dimensions (usually the horizontal and vertical sizes must be powers of 2). gl-update-texture-image updates a portion of the texture with the given image, starting at the given position. Again it must be a 4-channel interleaved image, but it need not have valid texture dimensions.