i am writing an SDL / OpenGL application that runs under OSX. I have to use existing code which uses the DevIL library for loading JPG and PNG textures. Unfortunately, this
Take a look at freeimage. It supports all major formats and is easily built with macports. Nice to work with as well. Auto-detects image format etc.
FREE_IMAGE_FORMAT format = FreeImage_GetFileType(filename.c_str(), 0);
FIBITMAP *bitmap = FreeImage_Load(format, filename.c_str());
if (!bitmap)
{
LOG_ERROR("Unable to load texture: " + filename);
return false;
}
mlWidth = FreeImage_GetWidth(bitmap);
mlHeight = FreeImage_GetHeight(bitmap);
glGenTextures(1, &mpTextures[0]);
glBindTexture(GL_TEXTURE_2D, mpTextures[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mlWidth, mlHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE,
(GLvoid*)FreeImage_GetBits(bitmap));
FreeImage_Unload(bitmap);