2015-11-22 21 views
-1

我已經創建了6個平面作爲JOGL中的一個房間,現在我想用不同的圖像紋理它們,所以我怎樣才能在每個平面上做到這一點?還有如何推薦紋理圖像資源,我可以用它來裝飾房間?如何紋理JOGL中的不同平面

謝謝。

public void render(GL2 gl) { 
    gl.glClear(GL2.GL_COLOR_BUFFER_BIT|GL2.GL_DEPTH_BUFFER_BIT); 
    gl.glLoadIdentity(); 
    camera.view(glu);     // Orientate the camera 
    doLight(gl);      // Place the light 

doLight2(gl); 

if (axes.getSwitchedOn()) 
    axes.display(gl, glut); 

if (objectsOn) {     // Render the objects 
    gl.glPushMatrix(); 
    //Making the room. 
    double planeParam = animationScene.getParam(animationScene.PLANE_PARAM); 
    //red x, blue z, green y. 
    gl.glTranslated(planeParam,0,0); 
    //Base 
    plane.renderDisplayList(gl); 
    //Back wall 
    gl.glTranslated(0,25,-25); 
    gl.glRotated(90, 1, 0, 0); 
    plane.renderDisplayList(gl); 
    //Right wall 
    gl.glTranslated(25,25,0); 
    gl.glRotated(90, 0, 0, 1); 
    plane.renderDisplayList(gl); 
    //Front wall 
    gl.glTranslated(25,25,0); 
    gl.glRotated(90, 0, 0, 1); 
    plane.renderDisplayList(gl); 
    //Roof 
    gl.glTranslated(0,25,-25); 
    gl.glRotated(90, 1, 0, 0); 
    plane.renderDisplayList(gl); 

    //Left wall 
    gl.glTranslated(25,25,0); 
    gl.glRotated(90, 0, 0, 1); 
    plane.renderDisplayList(gl); 


    gl.glPopMatrix(); 


} 
+0

你不應該使用任何顯示列表,這個功能在許多驅動程序(甚至是一些舊驅動程序)中是半分的。而是使用編譯的頂點數組或靜態VBO。 – gouessej

回答

0

您可以使用TextureIO(推薦)或AWTTextureIO從圖像文件創建紋理。

您可以使用包含所有紋理的單個圖像,並將它們作爲單個紋理進行管理,也可以對每個紋理使用一個圖像。

你必須在使用它之前綁定紋理(參見Texture.bind()或glBindTexture)。

您必須爲頂點分配一些紋理座標。如果使用直接模式,請使用glTexCoord。