Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

SOIL_load_image and mipmaps

4: Adsense

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
2 replies to this topic

#1 vladic2000x   Members   

252
Like
0Likes
Like

Posted 16 May 2013 - 12:34 AM

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 );


#2 swiftcoder   Senior Moderators   

18223
Like
0Likes
Like

Posted 16 May 2013 - 01:58 PM

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...


Tristam MacDonald - Software Engineer @ Amazon - [swiftcoding] [GitHub]


#3 vladic2000x   Members   

252
Like
0Likes
Like

Posted 20 May 2013 - 12:46 PM

Thanks! 


Edited by vladic2000x, 20 May 2013 - 12:59 PM.





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.