Jump to content

  • Log In with Google      Sign In   
  • Create Account

Initializing DevIL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Seabolt   Members   -  Reputation: 633

Like
0Likes
Like

Posted 31 August 2012 - 09:21 PM

Hey GameDev,

I'm currently working on getting DevIL to work with loading textures. Now I know that some people will not like DevIL, and I'm up for hearing any better approaches, but this is what I'm using right now.

Now my issue is that upon calling ilutInit() glGetError will return GL_INVALID_ENUM. This seems strange to me, and it's only set by the call. Now is this a known issue and I should ignore it? I should mention that ilGetError return no problems.

Here's my initialization code:

//
// Check for a valid context
//
if( context == NULL )
{
  assert( context && "Need a valid context" );
  return;
}
//
// Create our temp context
//
HGLRC tempGLContext = NULL;
#if WIN32
tempGLContext = wglCreateContext( context );
//
// Check for a valid temp context
//
if( tempGLContext == NULL )
{
  assert( "Failed to create a temp context" && tempGLContext );
  return;
}
//
// Attempt to make the context current
//
if( wglMakeCurrent( context, tempGLContext ) == false )
{
  assert( "Failed to make the temp context current" && 0 );
}
CheckGLCall();
//
// Now we need to initialize GLEW
//
GLenum result = glewInit();
assert( "Failed to initialize GLEW" && result == GLEW_OK );
assert( wglewIsSupported("WGL_ARB_create_context") == 1 );
//
// Next we setup our attrib array, this determines the context we want
//
int attribs[] =
{
  WGL_CONTEXT_MAJOR_VERSION_ARB, 3,  // Set our major version
  WGL_CONTEXT_MINOR_VERSION_ARB, 1,  // Set our minor version
  WGL_CONTEXT_FLAGS_ARB,	 // Use ARB functions
  WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, // We want forward compatability. Good performance gains
  0		  // Zero indicates the end of the array
};
//
// Attempt to create our context
//
mhGLRenderContext = wglCreateContextAttribsARB( context, 0, attribs );
CheckGLCall();
if( mhGLRenderContext == NULL )
{
  assert( "Failed to create our desired context" && mhGLRenderContext );
  return;
}
//
// Clear the active context
//

if( wglMakeCurrent( NULL, NULL ) == false )
{
  assert( "Failed to clear context current" && 0 );
  return;
}
//
// Delete the previous temp context
//
if( wglDeleteContext( tempGLContext ) == false )
{
  assert( "Failed to delete the temporary context" && 0 );
  return;
}
//
// Set our current context
//
if( wglMakeCurrent( context, mhGLRenderContext ) == false )
{
  assert( "Failed to make our desired context current" && 0 );
  return;
}
CheckGLCall();
if ( ilGetInteger(IL_VERSION_NUM) < IL_VERSION ||
   iluGetInteger(ILU_VERSION_NUM) < ILU_VERSION ||
   ilutGetInteger(ILUT_VERSION_NUM) < ILUT_VERSION )
{
  assert( "DevIL versions don't match, aborting!" && 0 );
  return;
}
ilInit();
iluInit();
ilutInit();
ilutRenderer( ILUT_OPENGL );
CheckGLCall();

Now if anyone has a better choice then DevIL for texture loading, let me know :)
Perception is when one imagination clashes with another

Sponsor:

#2 Lazy Foo   Members   -  Reputation: 1105

Like
0Likes
Like

Posted 31 August 2012 - 11:04 PM

I could never get the DevIL/OpenGL texture loading to work.

What I do instead when I load an OpenGL texture with DevIL is create a function that loads pixels from a set of bytes and pass the DevIL pixels in. It also makes it trivial to support other image loaders when working on platforms that don't support DevIL.

Learn to make games with my SDL 2 Tutorials


#3 Waterlimon   Crossbones+   -  Reputation: 2562

Like
0Likes
Like

Posted 01 September 2012 - 07:48 AM

I think DevIL is really old... I just switched to FreeImage (as i had only a few lines to load a single image, it didnt take long)

o3o


#4 Seabolt   Members   -  Reputation: 633

Like
0Likes
Like

Posted 01 September 2012 - 08:38 AM

Yeah I've been looking at FreeImage as well, it's just getting the build solutions to load in VS2010 is a pain. But I guess I'll have to download a x86 VS2008 and see if it will work then.

And Lazy Foo, I can't even get pass initialization without getting an error with glGetError(). Sigh, why does everything have to be a decade old haha.
Perception is when one imagination clashes with another

#5 larspensjo   Members   -  Reputation: 1540

Like
1Likes
Like

Posted 01 September 2012 - 10:53 AM

Just a question, but why are you using Devil?

Do you have an application where the requirement is that it shall be able to load general purpose image formats?

Or is it that you have control over the images yourself, and can use any format that is easiest?

I ask because I think it is common to see people struggle with decoding various formats when they might as well convert the images using a 3:rd party application to something that is easy to decode.
Current project: Ephenation.
Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/

#6 Murdocki   Members   -  Reputation: 274

Like
1Likes
Like

Posted 01 September 2012 - 03:29 PM

Are you sure you have to init ilu and ilut yourself? I'm not and i can use them just fine:

..context creation..
ilInit();
ilutRenderer( ILUT_OPENGL );
..texture loading..
GLuint textureID = ilutGLLoadImage( charArr );
ilutGLBuildMipmaps();

provided charArr is a proper file, textureID then contains the id of the opengl texture you can use.

#7 Seabolt   Members   -  Reputation: 633

Like
0Likes
Like

Posted 02 September 2012 - 09:10 AM

@larspensjo: We're just trying to get a general purpose image loader up and running, since we're fairly early in the project and don't have much of an established tool pipeline. Eventually I'd like to just load DXTn textures, but currently it would be more of a pain to remember to "rip" every texture before use.

@Murdocki: I've tried that, but glGetError() will still throw GL_INVALID_ENUM after ilutRenderer( ILUT_OPENGL );

And yesterday I got FreeImage working, so hopefully that won't turn out to be a pain in it's own rite.
Perception is when one imagination clashes with another




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS