Jump to content
  • Advertisement
Sign in to follow this  
giugio

OpenGL .jpg and opengl texture

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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!