Jump to content
  • Advertisement
Sign in to follow this  
Night_Dweller

OpenGL Issue with mipmapping - Textures fade to black

This topic is 3540 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, I am trying to enable mipmapping within my opengl code and am having trouble getting it to work correctly. The textures seem to fade to black with this being directly related to the resolution of the texture. The smaller the resolution the further the viewable distance. I have included some screenshots to more adequately convey what I am saying: Texture size 512x512: http://img357.imageshack.us/img357/8711/mipmappingissuetexturespm4.png Texture size 256x256: http://img339.imageshack.us/img339/8998/mipmappingissuetextureshz3.png Texture size 128x128: http://img357.imageshack.us/img357/8683/mipmappingissuetexturesmv9.png Texture size 64x64: http://img339.imageshack.us/img339/7831/mipmappingissuetexturesvh6.png Those screenshots were all taken with these lines in my code:
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_RGB, GL_UNSIGNED_INT, image);

If these lines are instead replaced with (essentially disabling mipmapping):
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGB, GL_UNSIGNED_INT, image);

then I get the following output (which is what I'd expect): Without mipmapping - Texture size 512x512: http://img392.imageshack.us/img392/1125/mipmappingdisabled512x5zi4.png I'm using the ppm file format for my textures, and my best guess is that the issue may be related to how the image data is stored, or that it may be due to the large file sizes (the 512x512 is 2.4MB) I wanted to check that this wasn't something else before I write a file loader for another format so that I can test this theory. I've worked on the problem on and off for a few days now and haven't been able to find a solution. Any advice that anyone has will be appreciated. Thank you all for your time.

Share this post


Link to post
Share on other sites
Advertisement
Just a thought, but could it have anything to do with using GL_UNSIGNED_INT? Are you sure your texture data is stored as unsigned integers?

Share this post


Link to post
Share on other sites
Yeah my texture is stored as an unsigned int,


GLuint *image;



unless I've done it wrong some how, but I don't think so.

I've read the link you supplied V-man. As far as I can tell I'm setting everything up correctly. I'm mostly looking for ideas about what might be wrong, if I've got an idea about where to look I should be able to track down the problem.

Thanks.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!