Milfoh
From MaurizioHomepage
Contents |
Overview
Milfoh:
- Maurizio's Image Library For OpenGL and Haskell
or, if you think that i chosed a too egocentric name :-)
- Minimal Image Library For OpenGL and Haskell
This is a small library for loading images to textures that i wrote
putting together SDL_image with a very little subset of SDL, because i
was getting frustrated by having very good OpenGL/GLUT Haskell bindings
but no image loading library (as SDL's bindings are still not complete).
All SDL_ symbols where renamed with a script to SDLx_ to avoid possible conflicts with real SDL.
This library is licensed as LGPL.
Download
You can get here the latest version:
milfoh-0.5.2.tar.gz (13 May 2006)
- Fix for a bug in BMP image format (the fix has been submitted to SDL_image too)
- Slightly better Makefile
- Some cleanups
milfoh-0.5.1.tar.gz (10 May 2006)
- Applied a little patch to better handle async exceptions (thanks to Roberto Zunino)
- Added simple support for exceptions
- Included glut while compiling
- Updated TODO
milfoh-0.5.tar.gz (09 May 2006)
- Initial release
Compiling
You can compile it by just running 'make', it will create Milfoh.hi and libMilfoh.a that you can use with in haskell programs, and milfoh_test_c and milfoh_test_hs that are basically the same test written in haskell and C, it just loads a texture from an image and displays it using GLUT.
./milfoh_test_hs flags/kiribati.xcf
Functions
The only exported function (in the Milfoh module) is:
imageToTexture :: String -> TextureTarget -> Proxy -> Level ->
PixelInternalFormat -> Maybe TextureSize2D ->
Border -> IO ()
imageToTexture filename target proxy mipmap_level
pixel_format texture_size border
as you can see it is very similar to texImage2D, but instead of taking the 'PixelData' parameter (to specify the data being loaded) you will just have to supply a filename as a string.
There are also two other little differences:
- the first parameter after the filename is a TextureTarget instead of a Maybe CubeMap, so that you will also be able to specify a TextureRect target (in facts, i think that this is a bug of texImage2D binding).
- the TextureSize2D parameter is a Maybe, and if set to Nothing the texture will be of the same size as the image file. If it is set and it is different from the size of the image, the image will be scaled.
If the file could not be loaded an exception is raised.
