Graphics and Lisp

I’ve been having fits with this for almost a year now.

I’ve written about some of the pain involved elsewhere. Someday, I may even dig up those angst-driven pieces for others to share my woes.

Until then. I think I may be onto something.

First, start with downloading the zip file from sourceforge (yeah, I know…they obviously aren’t very interested in playing nicely with others). Extract it somewhere. I stuck it in ~/downloads and extracted it into ~/downloads/extract.

Do a `lein new app best-name-ever` to initialize the project you actually want. Or add this piece to an existing project.

Inside your project, `mkdir native` to set up a folder where your native dependencies can live.

The lwjgl binary you extracted [from sourceforge…this entire thing is pretty ridiculous] should have a folder named ‘native’.

There should be a folder that matches your architecture (i.e. macosx, linux, or windows…if you’re using anything else, you probably think you know *way* more about computers than I, so why would you be wasting your time reading this?) under there.

Copy the contents of that folder into the native/ folder you created inside your leiningen project. Add an entry to the :dependencies vector. For me, that seems to be:

[org.lwjgl.lwjgl/lwjgl “2.9.0”]

Then I need to add that piece to…beats me. It looks like the kind of BS that drove me to get into higher-level languages in the first place:

:jvm-opts [~(str “-Djava.library.path=native/:” (System/getProperty “java.library.path”))

I feel bad for even thinking about publishing this. I can’t take any credit at all. Someone else devoted a lot of hours to figuring out that little detail. And I’m not giving that person anywhere near enough credit.

It’s not fair, but I’m really just trying to pass information along. And maybe add a little bit.

Since, after all, this is where the shit really gets interesting. Up until now, it’s all been configuration (and, if you’re like me, wondering how to make this work for consumers). That’s still just sysadmin stuff.

What about actual code? How does it match all those frustrating examples that just assume the imports (if they’re shown at all) magically happen and you can get busy doing your thing?

I pretty much have 2 lines of code to show at this point:

(org.lwjgl.opengl.DisplayMode. 800 600)


(import ‘[org.lwjgl.opengl)

No, those aren’t helpful at all. But they’re a start. And, dammit, newbs across the clojure community still struggle to try to figure out the what and how behind (import). Much less the why.

Hopefully this will provide a hint. Either to them or to me in the morning. Whichever.

Based on that import:

(org.lwjgl.opengl.DisplayMode. 800 600)

creates a new DisplayMode instance.

At this point, I was able to follow along with the basic examples at Roger Allen’s hello_lwjgl, and life is looking promising.

Leave a Reply

Your email address will not be published. Required fields are marked *