Fastest Simplest way to use PNG textures in OpenGL
I am 开发者_如何学Golooking for the fastest and easiest way to use PNG (with alpha values) textures in OpenGL. I have tried many different libraries but most are bloated and hard to get compiled/working on a Mac.
I'm not very familiar with OpenGL textures and all of the "Gotchas" so I am putting emphasis on the Simple.
It would be very helpful if someone could give me a nice makefile example if the solution involves linking a library.
Thanks!
You might give SOIL a whirl.
sdl and sdl_image is the simplest way I know of: http://www.libsdl.org/ http://www.libsdl.org/projects/SDL_image/
However, this is for cross-platform. For Mac-only I guess there is a native alternative.
DevIL can do this pretty simply and easily, for quite a few formats. It also have a very, very similar API to OpenGL (by design, most constants are identical, etc). It took me just a few minutes to hook it into an OpenGL app I had. The docs aren't great, but it does the job and supports a lot of formats.
glpng is a png opengl loader utility library although one can do what it does with just libpng and gl it loads from a png file into a texture for you in one call
精彩评论