• Advertisement
Sign in to follow this  

DevIL without GLUT = bad?

This topic is 4350 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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 );

I have tried with ilut and I got the same result.
ilutInit();

tu->m_iTextureID = ilutGLLoadImage((ILstring)FileName.c_str());

Share this post


Link to post
Share on other sites
Advertisement
how where you loading the images when u where using glut?

Share this post


Link to post
Share on other sites
oh.. forgot to write that, I'm using the ilut version in GLUT.

Share this post


Link to post
Share on other sites
When do you load the images? I can't say for sure, but I believe if you're trying to load the images before you've created your OpenGL context, it might fail.

Share this post


Link to post
Share on other sites
You may have to have a valid GL context before initialising IL or setting the ILUT renderer to ILUT_OPENGL.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement