views:

841

answers:

8

I have tried everything from SDL to DevIL, and they have all failed for various reasons.

SDL segfaults for various reasons, and DevIL is having some weird problem where even after i include IL/ilut.h and linking everything, and including the other headers, it is not defining the functions i need to load images into opengl textures (something about USE_OPEN_GL not being defined). I am asking for any other lib out there for loading bitmaps or png's into a format i can easily convert to opengl, or a solution to the devil problem.

thanks

A: 

you dont need ILUT to do what you want. you can simply use ilGetData() and glTexImage2d()

banister
A: 

Loading bitmaps (.bmp) and netpbm images (.pbm, pgm, .pnm) is fairly trivial, since they store images uncompressed. For loading PNGs, use libpng. For loading JPEGs, use libjpeg. For other image types, use an appropriate library. There's a good change that slapping on 'lib' to the beginning of the image name will give you such a library, e.g. libtiff, libtga, etc.

Once you've loaded and uncompressed the raw image data, loading it into an OpenGL texture is just a matter of calling glTexImage2D() with the right parameters, and a couple of other GL state changes (e.g. how to do mipmapping).

Adam Rosenfield
A: 

Image Magick with either the C or C++ bindings?

http://www.imagemagick.org/script/index.php

MichaelM
A: 

LodePNG is a highly compact PNG Loader with no dependencies.

Comment on your experience with DevIL - it works flawlessly for me and many others. Why not try again to resolve your build problems? - shouldn't be too hard)

Alexander Gessler
A: 

SOIL is a decent lightweight one I've used before. It's actually specialized for loading OpenGL textures too.

http://lonesock.net/soil.html

Ron Warholic
+1  A: 

As Adam suggests, I would also recommend to use libpng and libjpeg. You are not specifying if you write in C or C++, but if in C++, then I'd suggest to take a look at two handy thin wrappers on the both libraries: pngxx and jpegxx

mloskot
+1  A: 

You can also try FreeImage library. It supports loading different image types and is functionally similar to DevIL, may work out of the box for you.

And about your problem with DevIL, you do not have to build ilu or ilut libraries to make DevIL functional. I would recommend you manage the OpenGL texture objects yourself, including uploading image data to OpenGL side.

tersyon
+1  A: 

Both libpng and libjpeg can be rather daunting to build & use -- no wonder there are all sorts of wrapper libraries for both.

A very simple and minimal no-nonsense loader for jpg/png (and some other stuff aswell) without dependencies in a single C file is Sean Barrett's stb_image.c, if you just want to load some image files it adds absolutely minimal overhead to your program and is straightforward to use:

http://nothings.org/stb_image.c

Ákos
Thanks for this link, this is great