2011-04-22 98 views
1

所以我現在加載了我的圖像,但它說你可以爲MipMap生成一個標誌 。我設置了標誌,據我所知,在某些時候使用MipMaps時,OpenGL會做 休息。OpenGL Mipmap和土壤標誌

我錯了嗎?如果我是,我如何讓MipMaps工作?

編輯:所以這是我的初始化函數,其中我打電話土壤與FLAG載入我的圖像的貼圖

//======================================== 
// 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和結束}爲函數

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(); 
+0

爲什麼要傳遞3而不是SOIL_LOAD_RGB? – 2011-04-26 05:11:04

+0

嗨,對於遲到的響應RTS感到抱歉,自從我搞亂這個以來已經有一段時間了,但是如果我記得正確地將一個數字放在一起,就像調用SOIL_LOAD_RGB一樣。我可能是錯的,但我認爲這是沿着這些線的東西! – 2011-05-27 17:51:11

回答

2

需要切換紋理過濾使用mipmap處理的:

glBindTexture(GL_TEXTURE_2D, theTextureID); 
glTexParamteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 

您也可能希望查看各向異性過濾模式以提高過濾質量:http://www.opengl.org/registry/specs/EXT/texture_filter_anisotropic.txt

+0

嗯..以及我做 glBindTexture glTexParamteri 但我做他們,當我調用紋理來應用它。 – 2011-04-22 20:21:17

+0

請如果你有機會看看我的編輯上面,也許我做了完全錯誤的事情。 (上面的代碼確實加載圖像很好,但沒有發生mipmapping) – 2011-04-22 20:37:55

+0

嗯,沒關係!必須將MIN_FILTER和MAG_FILTER都設置爲使用GL_LINEAR_MIPMAP_LINEAR! – 2011-04-23 08:23:29