我想凹凸貼圖應用到2D紋理,從我在本教程中所看到的代碼:http://www.paulsprojects.net/tutorials/simplebump/simplebump.htmlOpenGL的凹凸貼圖沒有工作
我已經改變了代碼與我的設置工作(不使用客戶端的狀態,繪畫與glVertex代替glDrawElements等... verticies),但是當我運行該程序,我得到這樣的輸出:
http://www.tiikoni.com/tis/view/?id=cf02ea7
這是代碼:(X,Y,Z ,w,h,st都是有效值)
//Bind normal map to texture unit 0
glBindTexture(GL_TEXTURE_2D, bump->texnum);
glEnable(GL_TEXTURE_2D);
//Bind normalisation cube map to texture unit 1
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, draw_ncm);
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glActiveTextureARB(GL_TEXTURE0_ARB);
//Set up texture environment to do (tex0 dot tex1)*color
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
glActiveTextureARB(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_DOT3_RGB_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
glActiveTextureARB(GL_TEXTURE0_ARB);
glBegin(GL_QUADS);
glTexCoord2f(st[0], st[1]);
glVertex3f(x, y, z);
glTexCoord2f(st[0], st[3]);
glVertex3f(x, y+h, z);
glTexCoord2f(st[2], st[3]);
glVertex3f(x+w, y+h, z);
glTexCoord2f(st[2], st[1]);
glVertex3f(x+w, y, z);
glEnd();
// texture pass
glBindTexture (GL_TEXTURE_2D, pic->texnum);
glBegin(GL_QUADS);
glTexCoord2f(st[0], st[1]);
glVertex3f(x, y, z);
glTexCoord2f(st[0], st[3]);
glVertex3f(x, y+h, z);
glTexCoord2f(st[2], st[3]);
glVertex3f(x+w, y+h, z);
glTexCoord2f(st[2], st[1]);
glVertex3f(x+w, y, z);
glEnd();
你爲什麼用glTexEnv打擾?只需使用着色器並完成! – datenwolf