Re: XForms: OpenGl canvas

Steve Lamont (
Tue, 12 May 98 09:19:51 PDT

# To subscribers of the xforms list from (Steve Lamont) :

> Here I have the following problem with a glcanvas. The canvas is integrated
> inside the user interface and I want to display grey level images images
> in it.
> I have trouble to initialize the colormap.

I've put my mildly hacked version of gl.c in

It has the color table mods as well as a couple of other modifications
which I found necessary or useful. First off, it handles finding an
appropriate Visual in a little different manner. Second, it adds
three new callback options: glcanvas_init_callback,
glcanvas_activate_callback, and glcanvas_cleanup_callback. The
callbacks may be called at init, activate, and cleanup, respectively.
The funcitons to set them are

void fl_set_glcanvas_init_callback( FL_OBJECT *ob,
void (*callback)( FL_OBJECT *ob ) )
void fl_set_glcanvas_activate_callback( FL_OBJECT *ob,
void (*callback)( FL_OBJECT *ob ) )
void fl_set_glcanvas_cleanup_callback( FL_OBJECT *ob,
void (*callback)( FL_OBJECT *ob ) )

and the function called is of the form

void glcanvas_callback( FL_OBJECT *ob )

[There probably should be a `void *data' parameter there but I didn't
have need for it at the time I added them].

Finally, error conditions are handled though a user supplied function,
abend() [yes, my old IBM mainframe roots are showing]. In this case,
it can be as simple as

void abend( char *message )


fprintf( stderr, "%s\n", message );
exit( 1 );


[my own private library version is somewhat more elaborate, taking
varargs arguments and acting more like fprintf()].

To unsubscribe, send the message "unsubscribe" to or see
XForms Home Page:
List Archive: