2012-01-07 158 views
0

我想通過opengl es實現類似colorsplash效果的效果,所以我通過網站搜索並獲取指南(http://www.idevgames.com/forums/thread-899.html)OpenGL ES紋理遮罩

現在我在第三步爲繪圖時間進行阻擋,我不知道如何創建多紋理跟隨指南,你能幫助我嗎?給我一些建議或關於它的一些代碼

回答

1

要做多紋理,你需要把不同的紋理放到不同的紋理單元中,併爲它們設置紋理座標。就像這樣:

// Put a texture into texture unit 0 
glActiveTexture (GL_TEXTURE0); 
glBindTexture (GL_TEXTURE_RECTANGLE_EXT, texID0); 
...  
// Put a texture into texture unit 1 
glActiveTexture (GL_TEXTURE1); 
glBindTexture (GL_TEXTURE_RECTANGLE_EXT, texID1); 
... 
// Now draw our textured quad - you could also use VBOs 
glBegin (GL_QUADS); 
// Set up the texture coordinates for each texture unit for the first vertex 
glMultiTexCoord2f (GL_TEXTURE0, x0, y0); 
glMultiTexCoord2f (GL_TEXTURE1, x1, y1); 
// Define the first vertex's location 
glVertex2f (x, y); 
... // Do the other 3 vertexes 
glEnd();