Jump to content
  • Advertisement
Sign in to follow this  
vladic2000x

SOIL_load_image and mipmaps

This topic is 1950 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

Hello! Is there a way to get access to different mipmap levels using SOIL_load_image()?
 
The code below crashes the app:
 
int width, height, mipMapLeveCount;
unsigned char* imageDataPtr =SOIL_load_image( "texture/checker.dds", &width, &height, &mipMapLeveCount, SOIL_LOAD_RGB);
unsigned char* tempPtr=imageDataPtr;
 
for(int mipmapLevel = 0; mipmapLevel < mipMapLeveCount; mipmapLevel++)
{
glTexImage2D( GL_TEXTURE_2D, mipmapLevel, GL_RGB, width, height, 0, GL_RGB,GL_UNSIGNED_BYTE, imageDataPtr );
imageDataPtr+=width*height*3;
width/=2;
height/=2;
}
 
SOIL_free_image_data( tempPtr );

Share this post


Link to post
Share on other sites
Advertisement

The third parameter isn't the number of mipmaps, it is the number of channels (which in your case will be 3, since you specify RGB).

 

The number of mipmaps should be roughly floor( log2( min(width, height) ) ).

 

Provided, of course, that your image has mipmaps, and SOIL is actually loading them. I haven't stared at the code in a while, but I seem to remember that one needed to use SOIL itself to do the upload to OpenGL, all in one shot, and specify the SOIL_FLAG_DDS_LOAD_DIRECT flag...

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!