OpenGL Mipmaps and SOIL Flag
So i got the SOIL loading my images now, but it says you can set a flag for the MipMap generation. I set the flag and as far as I know O开发者_JS百科penGL does the rest when it comes to using the MipMaps at certain times.
Am I wrong in this? and if I am, how do I get the MipMaps to work?
EDIT: So this is my init function where I call SOIL to load my image with the FLAG for MIPMAPS
//========================================
// init
//========================================
void init(void) {
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glShadeModel(GL_SMOOTH);
glEnable (GL_BLEND); //transparency
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
timerSpeed = 1000.0/60.0;
for(int i=0; i<6; i++) {
TextureNames[i] = TextureNames[i]+".bmp";
TextureArray[i] = SOIL_load_OGL_texture((char*)TextureNames[i].c_str(),3,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_POWER_OF_TWO |
SOIL_FLAG_MIPMAPS);
}
}
And this is where I call bindtexture and texparam (cut it short because its just the other faces of the cube, popmatrix and end } for the function
void drawCube(void) {
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, TextureArray[1]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//FRONT FACE OF CUBE
glNormal3f(0.0,0.0,1.0);
glBegin(GL_POLYGON);
glTexCoord2f(0.0,0.0); glVertex3f(-1.0,-1.0,1.0);
glTexCoord2f(1.0,0.0); glVertex3f(1.0,-1.0,1.0);
glTexCoord2f(1.0,1.0); glVertex3f(1.0,1.0,1.0);
glTexCoord2f(0.0,1.0); glVertex3f(-1.0,1.0,1.0);
glEnd();
//LEFT FACE OF CUBE
glNormal3f(-1.0,0.0,0.0);
glBegin(GL_POLYGON);
glTexCoord2f(0.0,0.0); glVertex3f(-1.0,-1.0,-1.0);
glTexCoord2f(1.0,0.0); glVertex3f(-1.0,-1.0,1.0);
glTexCoord2f(1.0,1.0); glVertex3f(-1.0,1.0,1.0);
glTexCoord2f(0.0,1.0); glVertex3f(-1.0,1.0,-1.0);
glEnd();
You need to switch texture filtering to use mipmapping:
glBindTexture(GL_TEXTURE_2D, theTextureID);
glTexParamteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
You also may want to look into anisotropic filtering modes for increased filtering quality: http://www.opengl.org/registry/specs/EXT/texture_filter_anisotropic.txt
精彩评论