Sign in to follow this  
giugio

OpenGL .jpg and opengl texture

Recommended Posts

I use Devil for get a jpg image . I'm must adapt an existing library for work with a jpg texture . This is the code that load the image with devil:
	ilInit();
	ILuint imageID = -1;
	ILboolean imageLoaded;
	
	ilGenImages( 1, &imageID );

	
	const wchar_t* pk = char2wchar( "c:\\Waterfall.jpg");

	imageLoaded = ilLoadImage( pk );

	if ( !imageLoaded )
	{
		ilDeleteImages( 1, &imageID );
		return false;
	}
	else
	{
		imageLoaded = ilConvertImage( IL_RGBA, IL_UNSIGNED_BYTE );

		if ( !imageLoaded )
		{
			ilDeleteImages( 1, &imageID );
			return false;
		}

		ILint width = ilGetInteger( IL_IMAGE_WIDTH );
		ILint height = ilGetInteger( IL_IMAGE_HEIGHT );
		ILint bpp = ilGetInteger( IL_IMAGE_BPP );
		ILint format = ilGetInteger( IL_IMAGE_FORMAT );

		Image::m_iDimension = 2;
	 
		int IMGWidth, IMGHeight;

		IMGWidth = (int)width;
		IMGHeight = (int)height;
		Image::m_aucData = (unsigned char*) ilGetData();
	}
	return this;
}

Image::m_aucData is an unsigned char* of the base class , is a protected method And i have assigned to it a cast ilGetData. But don't work. What can be? Thaks

Share this post


Link to post
Share on other sites
It looks like your assigning the array of bytes to a class static variable? So your intention is that all derived classes point to exactly the same set of bytes? That seems wrong. You haven't really posted enough code to see if that's what is really happening though.

Also, define "don't work"? Does it crash? Does it no compile? When you debug it what are the values of the various variables and how is it exactly doing the wrong thing?

-me

Share this post


Link to post
Share on other sites
Image::m_aucData = (unsigned char*) ilGetData();
Please show m_aucData type and ilGetData prototype. From your current code, nothing can be get.
By the way, compile error or runtime error?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this