Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Haskell graphics library? [closed]

I'd like to experiment with Haskell a bit, and I'm hoping to write a small 2D arcade game (Tetris or Breakout). Can you recommend a simple graphics library that will help me to get started quickly?

Btw, I've been experimenting with SDL and wxWidgets, but haven't yet succeeded in running any samples because of dependency problems, working on it...

like image 848
StackedCrooked Avatar asked Jul 08 '09 01:07

StackedCrooked


2 Answers

It's not exactly a "simple" library, but there is a lot of information online about OpenGL and GLUT, as well as some very good tutorials and a ton of example code.

The biggest issue you're up against is that the OpenGL and GLUT bindings in Haskell do not include the libraries that they bind to. (This is true for wxWidgets as well.) A lot of Linux distros come with OpenGL binaries bundled, but not Windows. The Haskell Platform was supposed to fix this, but it didn't seem to for me.

So, assuming you're installing on Windows, here's what I'd recommend you try:

  1. Follow the directions in this blog to the letter. They're complicated -- involving installs of MinGW, MSys, and hand-compilation of a GLUT project from SourceForge, but it's the only way I've gotten OpenGL to work. I've now successfully installed on three separate machines, including XP and Vista, so I can safely say that these are very good directions.
  2. Once it does work, check out these two awesome tutorials. They really opened my eyes about just how powerful Haskell can be when it comes to graphics. You'll find the code involved a lot simpler than you may have anticipated.
  3. Check out the sample games on the Haskell OpenGL page. They're very experimental -- which is good, as it means less code to wade through than you'll find in a production system -- but they're also surprisingly sophisticated. (And yes, there's already more than one bare-bones Tetris implementation, but don't let that stop you.)
  4. Another good source of sample code is Haskell's GLUT binding itself. Look for the examples directory and you'll find many ports of sample code from the OpenGL Red Book.

OpenGL is very stateful, so you may find the Haskell code a little daunting if you haven't fully grokked Monads yet. I'm using my OpenGL experiments as motivation to finally wrap my mind around the concept.

Good luck!

like image 129
rtperson Avatar answered Oct 15 '22 15:10

rtperson


Have you perused the following lists:

Haskell Graphics Libraries: There appears to be quite a few interfaces to OpenGL, SDL, and other graphic libs here.

Haskell GUI: There's some wxWidget libs here as well.

like image 42
Jay Atkinson Avatar answered Oct 15 '22 15:10

Jay Atkinson