>>>>> "Karl" == Karl M Hegbloom <bittersweet.inetarena.com at karlheg> writes:
>>>>> "Steven" == Steven G Chappell <nh.ultranet.com at sgc> writes:
>>> What graphics options are available under ACL/Linux? We need to
>>> do 2-d and 3-d graphics and animation. Is there an OpenGL or
>>> similar available?
>> I used Mesa 2.1 (the Linux OpenGL look-a-like library) on the
>> Slackware 3.1 release for about two months with no
>> difficulties. This use, however, was not in conjuction with
>> ACL. Mesa can be had from ftp:/iris.ssec.wisc.edu/pub/Mesa. It
>> looks like they are up to rev 2.5-2 now.
Karl> I remember seeing a mail go by, maybe on the `gcl' list, from a guy
Karl> who has created GCL bindings to the MESA library. You might get
Karl> answers with an altavista search, or by posting in the comp.lang.lisp
Karl> newsgrope.
Here is the posting from Dec. 1996; I saved it but I have not
investigated it any further.
>>>>> "Richard" == Richard Mann <orasis.vis.toronto.edu at mann> writes:
Richard> Dear Lisp Hackers,
Richard> I have created a set of bindings that allow calls to OpenGL/Mesa from Gnu
Richard> Common Lisp (GCL).
Richard> If anyone is interested, you can download the code at:
Richard> http://ftp.cs.toronto.edu/pub/mann/Lisp/GCL-GL.tar.gz
Richard> This is only preliminary work, but since people have expressed interest, I
Richard> would like to release this as soon as possible. Details of the distribution
Richard> are included at the end of this message.
Richard> Please send me Email if you have any questions or comments.
Richard> Richard.
Richard> Encl: README file from distribution
Richard> -----------------------------------
Richard> OPENGL/MESA Bindings for GCL (Gnu Common Lisp)
Richard> OpenGL is a 3d graphics package from Silicon Graphics, Inc. Mesa is a (free)
Richard> OpenGL workalike available at:
Richard> http://www.ssec.wisc.edu/~brianp/Mesa.html
Richard> These bindings allow calls to OPENGL/MESA functions from GCL. The makefile
Richard> creates a new LISP image, xgcl, and installs GL functions in the package :GL.
Richard> In addition, I have created a set of bindings to XLIB (in the package :XLIB).
Richard> This package is similar to XGCL-2 shipped with gcl-2.2, except that I have put
Richard> all the definitions in one file, removed the dwdraw stuff, and cleaned up the
Richard> definitions a bit.
Richard> These bindings are specialized to GCL. It should be possible to modify them,
Richard> but I have not tried. In addition, these bindings have only been tested with
Richard> MESA and not with OPENGL.
Richard> This code is preliminary, incomplete, and largely untested. Since people have
Richard> expressed interest, however, I want to distribute it as soon as possible.
Richard> If you have any suggestions, or find this interface useful, please let me
Richard> know. In particular, I would like to know how many people are using GCL (or
Richard> any other LISP or Scheme implementation) for vision, graphics, and application
Richard> programming. I don't want to use C or C++ just because the required libraries
Richard> (GL, XLIB) are in those languagues!
Richard> Thanks,
Richard> Richard Mann
Richard> <cs.toronto.edu at mann>
Richard> 14 November 1996
Richard> HISTORY
Richard> 14 Nov 1996: Announcement to GCL mailing list <cli.com). at (gcl>
Richard> 16 Nov 1996: Bug fixes to pnm.lsp (pnm image routines).
Richard> 12 Dec 1996: Announcement to Comp.lang.lisp newsgroup. Changes to this file.
Richard> FILES
Richard> gl-bindings.lsp: Bindings to GL. Contains bindings to all C functions and
Richard> macros in gl.h, glu.h, and glx.h.
Richard> xlib-bindings.lsp, xlib-bindings-c.c: Bindings for X stuff in Xlib.h and
Richard> Xutil.h. The LISP part contains the bindings for functions, macros and
Richard> accessors while the C part contains accessors for all required structures.
Richard> misc-bindings.lsp, misc-bindings-c.c: Accessors for primitive C types (both
Richard> scalars and arrays). May add other system stuff (such as stdio, file access,
Richard> etc.) here later on.
Richard> foreign.lsp: Utility file to link foreign function definitions above into the
Richard> GCL system. (See below for details.)
Richard> makefile: Edit this to conform to your system. You need to say where to find
Richard> the GCL distribution, the OPENGL/MESA includes and libraries, and the XLIB
Richard> includes and libraries.
Richard> sysdef.lsp, sysinit.lsp: extra programs that are needed to build a LISP image
Richard> containing the above components. (See the makefile for details.)
Richard> pnm.lsp: A set of accessors for PNM images (PBM images are bitmap; PGM images
Richard> are grey level; PPM images are color). These functions allow reading and
Richard> writing of images. Images are stored as "packed" byte arrays. In addition,
Richard> this file provides accessors that give pointers to the pixel arrays to pass to
Richard> XLIB or GL functions requiring image data.
Richard> glxdemo.lsp, glspin.lsp, gltest0.lsp, glimage.lsp: Sample programs showing how
Richard> to use GL and XLIB functions. Glxdemo shows a simple program that uses XLIB
Richard> to open a window and GLX to initialize GL. Glimage shows how to put up images
Richard> with GL. (This program shows how to use various Visual types in XLIB.)
Richard> sample.pgm, sample.ppm: sample images (for use by program glimage.lsp).
Richard> INSTALLATION
Richard> 0. You need to have a GCL 2.2 source distribution, and have write access to
Richard> the installation directory. You also need Mesa or OpenGL libraries.
Richard> 1. Edit the makefile to conform to your system.
Richard> 2. Type make. It should create a file "xgcl" in the current directory.
Richard> Note: ignore the compiler error messages:
Richard> ;; Warning: The package operation (EXPORT '(....)) was in a bad place.
Richard> (Each time, this dumps a huge mess of symbols to the screen.)
Richard> 3. % xgcl
>> (load "glxdemo.lsp") ; load a demo program
>> (main) ; run a demo program
Richard> NOTES ON THE FOREIGN FUNCTION INTERFACE
Richard> To interface to the GL and XLIB libraries I need to build a foreign function
Richard> interface to these functions in LISP. The general philosophy is to write
Richard> "general" definitions for the C functions and macros (see the files
Richard> gl-bindings, xlib-bindings, and misc-bindings). I then use the macros in
Richard> foreign.lsp to translate these definitions to the specific form needed by GCL
Richard> (ie., the "defentry", "defCfun", "clines", commands). (It should be possible
Richard> to modify foreign.lsp (or write some small preprocessor program) that
Richard> translates the bindings into those needed for another LISP or Scheme
Richard> implementation.)
Richard> For most functions, LISP can call C functions directly. (The conversion of
Richard> types is done automatically by GCL.) This works when the arguments are
Richard> primitive types (char, int, float, ddouble) or strings. Problems arise,
Richard> however, when we want a C function to return a value to one of its arguments
Richard> or when we need to pass a pointer to some "composite" data structure (ie., an
Richard> array or a structure).
Richard> The general philosophy adopted here is to treat "composite" values (pointers
Richard> to primitive objects, pointers to structs, pointers to arrays) as raw
Richard> pointers. Pointers are represented by INTs in GCL and void* in C.
Richard> Typically, we allocate arrays in LISP and pass a pointer to any C function
Richard> that needs to access the array. The main thing to watch out for is that in
Richard> the LISP arrays must be "contiguous" and of the correct type (such as byte,
Richard> fixnum, float or double). We could also allocate the arrays on the C side,
Richard> but in most cases, we choose to allocate on the LISP side since we don't want
Richard> to build a whole new set of accessors for low-level C arrays. (There are a
Richard> few accessors in misc-bindings-c.c, but these are only for one-dimensional
Richard> arrays, and there is no bounds checking for these functions.)
Richard> For structs, however, we generally allocate and access them on the C side. It
Richard> is possible to allocate structs on the LISP side and pass pointers to C
Richard> functions, but we do not do this here.
Richard> For examples of how to use this FFI, see the sample programs described above.
Richard> NOTE ON GL, XLIB and GLX
Richard> GL provides functions to do rendering, but it doesn't provide any functions to
Richard> open windows and manage events. In these programs I use XLIB to open windows
Richard> and manage events. The GLX routines (in glx.h) are necessary to interface
Richard> between GL and XLIB. In particular, the GLX routines are needed to: 1) bind
Richard> GL so that it outputs to an X window; 2) control when GL output is flushed to
Richard> the X window, when buffers are swapped, etc.
Richard> There are other ways to interface GL to the windowing system. Examples
Richard> include GLAUX, GLUT, GLTK, etc. I did not use any of these methods since they
Richard> all seem to require callbacks. In each of these approaches the event loop is
Richard> automatically done for you, but you need to pass the redraw and resize
Richard> code to a C function. I don't know how to do this in GCL.
Richard> THINGS TO DO
Richard> 1. Check compatability with OpenGL. In particular, in SGI OpenGL, double
Richard> buffering doesn't seem to work and display updates seem to work differently
Richard> than in Mesa.
Richard> 2. Make a proper makefile (ie., that doesn't waste time recompiling LISP
Richard> images). I need to understand the building of the LISP image better (see
Richard> makefile and sysinit.lsp). This code is taken from the distribution of XGCL-2
Richard> in GCL 2.2, but I don't understand it.
Richard> 3. Understand LISP packages better. In particular, I want to automatically
Richard> export all foreign symbols in each of the GL and XLIB packages. Right now it
Richard> works, but gives a silly warning during compilation. I don't know why!
Richard> 4. Try to interface to GCL-TK. Is there a way to either: get GL to output
Richard> to an existing GCL-TK window; or, use GCL-TK to control an X window that
Richard> GL/XLIB opened?
Richard> 5. Improve the format of the foreign-function interface. In particular,
Richard> definitions should appear in the same order as they do in the original include
Richard> (.h) files. Also, I want to extend the foreign definition style. In
Richard> particular, I intend to still allow generic "POINTER" and "(POINTER STRUCT)",
Richard> but also allow pointers to particular structs. Eg., "(POINTER (STRUCT
Richard> DISPLAY))". This would allow more sophisticated interface policies, such as
Richard> those that automatically declare structs and accessors on the LISP side.
Richard> Right now, however, it does not seem worth the bother.
Richard> ACKNOWLEDGEMENTS
Richard> Thanks to Brian Paul, for providing a free alternative to OpenGL!
Richard> The original bindings were generated using (a modified version of) FFIGEN from
Richard> Lars Thomas Hansen <cs.uoregon.edu). at (lth>
Richard> The generation of GCL "defentry" syntax is based on foreign.lsp by Paul Viola.