Original Post
I'm trying to write my own 3D engine without using GLUT... But it failes when I try to load an image with DevIL
Top image is a screenshot with Win32 code and no glut lower image is from my GLUT engine.. the texture files are the same and is in JPG format. this is how I do in the non GLUT engine I have tried with ilut and I got the same result.
ILuint ilImage;
ilGenImages( 1, &ilImage );
ilBindImage( ilImage );
const bool loaded = ilLoadImage( (const ILstring)FileName.c_str() ) == 1;
if( !loaded )
{
CLog::errorMessage( "Failed to load texture %s", FileName.c_str() );
return NULL;
}
ILenum ilFormat = IL_RGB;
if( ilGetInteger(IL_IMAGE_BITS_PER_PIXEL) == 32 )
ilFormat = IL_RGBA;
const bool converted = ilConvertImage( ilFormat, IL_UNSIGNED_BYTE ) == 1;
if( !converted )
{
CLog::errorMessage("Failed to convert image data for texture %s", FileName.c_str() );
return NULL;
}
GLenum target = GL_TEXTURE_2D;
GLint MagFilter = GL_LINEAR;
GLint MinFilter = GL_LINEAR;
GLint format = GL_RGB;
if( ilFormat == IL_RGBA )
format = GL_RGBA;
glGenTextures( 1, &tu->m_iTextureID );
glBindTexture( target, tu->m_iTextureID );
// Set texture filter
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, MagFilter);
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, MinFilter);
// Upload image data
glTexImage2D(target, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE, ilGetData());
ilDeleteImages( 1, &ilImage );
ilutInit();
tu->m_iTextureID = ilutGLLoadImage((ILstring)FileName.c_str());