PDA

View Full Version : mimap level error



noobiegl
12-05-2010, 08:18 PM
got some problem ..texture no showing up.
i tried mipmap levels and changed filter settings. but still undenfined !! :confused: help!



glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

randall
12-06-2010, 03:59 AM
Please, post some more information/code. How do you render your object?

ZbuffeR
12-06-2010, 05:30 AM
When you ask for mipmaps in MIN filter, you have to provide each mipmap level with glTexImage2D or use it automatically with one of these methods :
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); // GL 1.4, deprecated in GL3.0 : generate mipmaps each time glTexImage2D changes the base level
glGenerateMipmap(GL_TEXTURE_2D); // for GL3.0+ : when called, generates mipmaps from base level, once

_arts_
12-06-2010, 06:43 AM
I personally use gluBuild2DMipmaps. Even if many people here will say we shouldn't use glu... This is easy and simple.

After, from what ZbuffeR said, we should ensure gluBuild2DMipmaps will behave correctly depending on the GL version it is running on...

ZbuffeR
12-06-2010, 07:03 AM
No need to worry, because gluBuild makes the mipmaps by hand on the cpu, and uploads each level with glTexImage2D. Bigger problem though : it will convert NPOT to POT texture silently, so be careful.

noobiegl
12-06-2010, 07:37 AM
This is how i create texture environment


glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, IMG_WIDTH, IMG_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, texture);

This is how i setup texture....


glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, teximage);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
gluBuild2DMipmaps( GL_TEXTURE_2D, 3, IMG_WIDTH, IMG_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, texture );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );


many thanks...

ZbuffeR
12-06-2010, 08:58 AM
First, try with GL_TEXTURE_MIN_FILTER, GL_LINEAR and no gluBuild2DMipmaps, to eliminate any problem with mipmaps. If texture stil has problem, then check you have correct data in *texture : size, values, ...