所以我现在让 SOIL 加载我的图像,但它说你可以为 MipMap 生成设置一个标志。我设置了标志,据我所知,在某些时候使用 MipMaps 时,OpenGL 会完成其余的工作。
我错了吗?如果我是,我如何让 MipMaps 工作?
编辑:所以这是我的初始化函数,我在其中调用 SOIL 以使用 FLAG 为 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);
}
}
这就是我调用 bindtexture 和 texparam 的地方(缩短它,因为它只是立方体的其他面,popmatrix 和 end } 用于函数
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();