Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am looking for simple, self-contained C library for Linux to load images from files into OpenGL textures. The licence should be quite liberal: zlib, bsd, mit or something. I have found SOIL, however it hasn't been updated for a long time. Is there something else, or do I have to write my own?

P.S. I use glfw. There are only deprecated functions for loading images.

share|improve this question

7 Answers 7

up vote 3 down vote accepted

I use STB Image for most image loading. A small self contained no strings attached implementation of png and other file formats.

share|improve this answer
2  
SOIL is a light wrapper around stb_image. –  user744 Feb 27 '11 at 17:52
    
Ah, I was not aware of that. –  void Feb 27 '11 at 18:12

SOIL works great. Who cares if it hasn't been updated in a "long time"? That just means it's stable and well-understood.

(It actually was updated in 2008, which is not long ago at all.)

share|improve this answer
    
For those seeing this now - SOIL doesn't seem to work on iOS, so if portability is your aim, using stb_image directly may be a better option. –  Ed Ropple Oct 6 '13 at 6:43

SDL can load BMPs. SDL_Image can load most other formats.

You can then upload these SDL_Surfaces to OpenGL. There is an example here: http://gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL

If you are already using SDL, this is a good fit.

share|improve this answer
    
I use glfw. There are only deprecated functions for loading images so I don't want to use them. –  Michas Feb 27 '11 at 13:29

Have a look at DevIL.

share|improve this answer
    
DevIL is under LGPL. This is little too restrictive for me. –  Michas Feb 27 '11 at 15:07
1  
Keep in mind that as long as you don't modify the original source code, you can link to a LGPL library and keep your main code closed/private/used for commercial purposes. –  r2d2rigo Feb 27 '11 at 15:58
    
I know. However I want to link everything into single file. –  Michas Feb 27 '11 at 16:22

Check out FreeImage. It's dual-licensed, you may choose either GPL or the liberal FreeImage license. It supports far more image formats than SOIL and development is active.

The library itself is written in C++, but it has an ANSI C interface.

From its introduction:

Thanks to it's ANSI C interface, FreeImage is usable in many languages including C, C++, VB, C#, Delphi, Java and also in common scripting languages such as Perl, Python, PHP, TCL or Ruby.

share|improve this answer
    
It looks the licence is not liberal enough. –  Michas Feb 27 '11 at 15:57
    
@Michas All it requires you is to acknowledge the use of the library, otherwise you are free to modify the sources and use in commercial projects. Or maybe I did not read the license carefully enough? –  Oskar N. Feb 27 '11 at 16:14
    
I may be forced to publish some of source code. –  Michas Feb 27 '11 at 16:19
    
I'm not sure where you are getting that idea... are you actually going to modify the FreeImage library (hint: probably not; be honest with yourself)? –  ChrisE Feb 28 '11 at 17:42
    
It is not a practical requirement. I know. I just would be happier with more liberal licence. –  Michas Mar 2 '11 at 17:57

Silly is produced the the CEGUI guys.

I supports loading PNG, TGA, JPG, etc. And it's released with an MIT license.

You'd have to write a C wrapper yourself as the library is written in C++.

share|improve this answer
    
The problem is I want to compile everything with a C compiler. –  Michas Apr 28 '11 at 11:02

If you don't need to read many formats, consider writing your own loader code. I use libjpeg and libpng directly and they're quite easy to use. Both have very simple functions that essentially fetch a scanline of RGBA data, just put that into an array and then upload to OpenGL. Both have very useful and straightforward example programs.

I have no experience with other formats, though. But to be honest, PNG+JPEG cover 100% of our needs (which aren't trivial nor hobbyist level - see http://www.mysterystudio.com)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.