Hi,
I've started quite recently with Gambit Scheme with the aim of using it for OpenGL development on OS X (and eventually on iOS and other platforms too). I plan to write a post on what I've learned once I am at a point I am happy with. Before then I would like to mention the useful things I've found out so far, and also raise some questions.
* I'll start out with what I've learned.
The most useful thing I've discovered (that doesn't seem to be mentioned widely) is that I can pass OS X frameworks in to gsc:
"gsc -cc-options "-iframeworkGLUT -iframeworkOpenGL" -ld-options "-framework GLUT -framework OpenGL" -exe test.scm"
With the frameworks supplied, I can do this in scheme code:
"(c-declare "#include <GLUT/glut.h>")"
The foreign function interface has been fairly easy to get to grips with. I had to look about to understand how to make a function written in scheme available to c code as a call back. This is described in the docs, but I skimmed over it without realising its relevance until until I found this article:
http://permalink.gmane.org/gmane.lisp.scheme.gambit/4005
With these facts in place I was delighted that getting a GLUT window open and rendering a square with OpenGL using Scheme was fairly painless. I'm usually terrible at the operating system side of languages (getting them to compile and link without the help of an IDE), so it's a tribute to Gambit that I've got this far!
* Here are the questions.
1) I've written a very specific wrapper generator for OS X's OpenGL and iOS's OpenGLES 1 & 2 headers – I'll post this and the resulting code when I write this up. It's a ruby script, but I hope of some use. However, I'd prefer to be using existing well maintained wrappers :-) If there are some, please let me know!
2) I'm turning my OpenGL bindings in to a dynamic library like this:
"gsc -cc-options "-iframeworkGLUT -iframeworkOpenGL" -ld-options "-framework GLUT -framework OpenGL" -dynamic gl_binding.scm"
I then have a file "test.scm" that contains (load "gl_binding.o1"). When I compile this I get the following:
*** WARNING -- "GL_COLOR_BUFFER_BIT" is not defined, *** WARNING -- "GL_MODELVIEW" is not defined, *** referenced in: ("/Users/benjohn/Code/gambit/test.c") *** WARNING -- "GL_PROJECTION" is not defined, *** referenced in: ("/Users/benjohn/Code/gambit/test.c") ...
The final executable runs fine, but is there a way to not get these warnings when the loaded library does supply them (as it does in this case).
3) The final executable ends up being nearly 4 Meg. I think it must be statically linking to the gambit run time and also the opengl bindings. How would I ensure that these are dynamically linked to keep the executable svelte?
Do I seem to have got completely the wrong idea here? :-) If so, please let me know!
Thanks very much, Benjohn