Jump to content
  • Advertisement
Sign in to follow this  
McZ

DevIL without GLUT = bad?

This topic is 4437 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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!