Discussion:
[Larceny-users] GLUT and GL bindings ported from Ypsilon
Eduardo Cavazos
2009-02-03 06:49:56 UTC
Permalink
Hello,

I ported the gl and glut FFI bindings which come with Ypsilon to
Larceny. Well actually, this is just a first take; I'd like to clean
them. It's getting late tonight though so I thought I'd share this. I'll
get back to you with the cleaned up versions...

Here's they are:

http://proteus.freeshell.org/_gl-larceny-a.scm
http://proteus.freeshell.org/_glut-larceny-a.scm

They are solid enough to run this demo:

http://proteus.freeshell.org/golden-section.scm

Which draws this picture:

Loading Image...

Larceny is so disgustingly fast. I'm impressed.

Ed
William D Clinger
2009-02-03 23:10:38 UTC
Permalink
Post by Eduardo Cavazos
I ported the gl and glut FFI bindings which come with Ypsilon to
Larceny....
Very nice! Thank you!

Will
Raffael Cavallaro
2009-02-04 19:58:12 UTC
Permalink
Post by Eduardo Cavazos
Hello,
I ported the gl and glut FFI bindings which come with Ypsilon to
Larceny. Well actually, this is just a first take; I'd like to clean
them. It's getting late tonight though so I thought I'd share this. I'll
get back to you with the cleaned up versions...
http://proteus.freeshell.org/_gl-larceny-a.scm
http://proteus.freeshell.org/_glut-larceny-a.scm
http://proteus.freeshell.org/golden-section.scm
http://proteus.freeshell.org/web/ypsilon-golden-section.png
I modified your code minimally to use the GL and GLUT frameworks on
Mac OS X, works nicely. Thanks for this!
Post by Eduardo Cavazos
Larceny is so disgustingly fast. I'm impressed.
Ed
Yes, larceny is impressive.

regards,

Ralph




Raffael Cavallaro, Ph.D.
***@mac.com
Eduardo Cavazos
2009-02-04 21:24:26 UTC
Permalink
Post by Raffael Cavallaro
I modified your code minimally to use the GL and GLUT frameworks on
Mac OS X, works nicely. Thanks for this!
Wonderful! I don't have a Mac so I'm greatful for your testing it on
that platform.

The original ypsilon 'gl.scm' has this bit of code to make the library
work on 5 different platforms:

(define libGL (cond (on-darwin (load-shared-object
"OpenGL.framework/OpenGL"))
(on-windows (load-shared-object "opengl32.dll"))
(on-linux (load-shared-object "libGL.so.1"))
(on-freebsd (load-shared-object "libGL.so"))
(on-openbsd (load-shared-object "libGL.so.7.3"))
(else
(assertion-violation #f "can not locate OpenGL
library, unknown operating system"))))


Larceny team, is there a similar form which can be used in our version
of this file?

By the way, just yesterday I noticed that the development branch of
Ikarus includes ports of these same Ypsilon gl and glut libraries.
Things are looking up for OpenGL in the Scheme world. :-)

Ed
Eduardo Cavazos
2009-02-05 05:45:47 UTC
Permalink
Post by Raffael Cavallaro
I modified your code minimally to use the GL and GLUT frameworks on
Mac OS X, works nicely. Thanks for this!
Raffael,

Going with Will's suggestion, I added a 'cond' to switch on the OS.
Here's a new version of the 'gl' library which incorporates this:

http://proteus.freeshell.org/_gl-larceny-b.scm

Feel free to test it.

I also included the copyright notice which the Ypsilon license requires.

Ed

William D Clinger
2009-02-04 23:57:54 UTC
Permalink
Post by Eduardo Cavazos
Larceny team, is there a similar form which can be used
in our version of this file?
In Larceny, the closest equivalent would be something like

(define libGL
(let ((os (cdr (assq 'os-name (system-features)))))
(cond ((string=? os "MacOS X")
(load-shared-object "OpenGL.framework/OpenGL"))
((string=? os "Win32")
(load-shared-object "opengl32.dll"))
((string=? os "Linux")
(load-shared-object "libGL.so.1"))
((string=? os "BSD Unix")
(if (file-exists? "libGL.so")
(load-shared-object "libGL.so")
(load-shared-object "libGL.so.7.3")))
((string=? os "SunOS") ???) ; Solaris
((string=? os "MacOS") ???) ; MacOS 9
((string=? os "Unix") ???) ; unknown Unix
(else
(assertion-violation #f
(string-append "can not locate OpenGL library,"
" unknown operating system"))))))

That's the current set of strings for recognized operating
systems. The relevant code is in src/Rts/Sys/primitive.c
and src/Lib/Common/system-interface.sch

Will
Loading...