Scheme with opengl
« Saturday, October 05, 2013 »

OpenGL Scheme

Using scheme to make a 3d engine was a badass idea. I guess that few understands why I'm attempting this and even I don't know exactly why. Writing code in scheme is quite particular, I'm not always sure of what I'm doing but it kind of work.

Recently, I've been working to make new OpenGL functions to work in chicken scheme. I heard that there are bindings in the allegro scheme egg but I prefered to go on with the original scheme egg opengl. I modified it to include new opengl header from my OSx machine. It worked!

OpenGL did change over the years

That was quite of a shock to be honest, I tried working with the old good glPushMatrix and glPopMatrix to find out that it was still kind of working. But if I was to use vertex shaders and fragment shaders, then it would simply not work anymore. Since my goal in this project is to use modern opengl, I figured out that I had to install the glm egg. GLM is a library to handle matrices and vectors the same way GLSL shaders would. Fortunately, someone wrote some bindings for chicken scheme.

Loading textures

I'd expect that texture loader should be standard nowadays. Python as the PIL package that lets you modify images really easily, it can load many formats but having support for every formats seems to be still a big problem.

For my project, I decided to go for a lightweight library. I doesn't handle many formats, but it is quite enough. SOIL is an image library for opengl. Ths library is quite old and unupdated, though it works. There is even a chicken egg for libsoil. If you happen to have SOIL installed on your system then good, if not. You'll have to install it by yourself because it doesn't seem to get packaged anywhere else.

Compiling the chicken egg will ask for the egg to be installed as a framework on OSx. You can change that if you use brew to link the chicken extension to lSOIL instead.

After a couple of days of try an error

It's just the beggining. After a couple of days and a bug report. I got things to work. It looks pretty well with shaders and I even have a tweening animation. The other interesting part is that it works on OSx and Gentoo.

Even though I wasn't thinking about making it work on multiple platforms, It currently is working on linux too. I haven't tried on windows because compiling Chicken using windows seems a bit awkward.

comments powered by Disqus

Copyright © 2015 Loïc Faure-Lacroix