URL87
URL87

Reputation: 11012

Cube with multiple texture

I have a cube with single texture -

public class TextureDemo implements GLEventListener, KeyListener {    
    private Texture texture;    
}
public void init(GLAutoDrawable gLDrawable) {
    String filename="Picture1.jpg"; // the FileName to open
    texture=TextureIO.newTexture(new File( filename ),true);
}

public void display(GLAutoDrawable gLDrawable) {
    texture.bind();
    gl.glBegin(GL.GL_QUADS);
    // Front Face
    gl.glTexCoord2f(0.0f, 0.0f);
    gl.glVertex3f(-1.0f, -1.0f, 1.0f);
    gl.glTexCoord2f(2f, 0.0f);
    gl.glVertex3f(1.0f, -1.0f, 1.0f);
    gl.glTexCoord2f(2f, 1.0f);
    gl.glVertex3f(1.0f, 1.0f, 1.0f);
    gl.glTexCoord2f(0.0f, 1.0f);
    gl.glVertex3f(-1.0f, 1.0f, 1.0f);
    // Back Face
    ...

}

I trying to set multiple texture on the above cube , means after the "Front Face" , replace to another texture which will take effect on the other cube face's .

How could I accomplish this ?

Upvotes: 0

Views: 188

Answers (1)

Xabster
Xabster

Reputation: 3720

You bind a new texture. That tells GL that whatever we're about to draw will use that texture.

So, create new texture for a different JPG file, then bind it, then draw some vertices.

Upvotes: 2

Related Questions