-1

I've created 6 planes as a room in JOGL, now I want to texture them each with different images, so how can I do this on each plane? And also how is there any recommended texture image resource that I can use it to decorate the room?

Thank you.

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


}
wsm
  • 143
  • 1
  • 1
  • 5
  • You shouldn't use any display lists, this feature is semi-broken in numerous drivers (even some old ones). Rather use compiled vertex arrays or static VBOs instead. – gouessej Nov 22 '15 at 15:23

1 Answers1

0

You can use TextureIO (recommended) or AWTTextureIO to create a texture from an image file.

You can use a single image containing all your textures and manage them as a single texture or you can use one image per texture.

You have to bind a texture before using it (see Texture.bind() or glBindTexture).

You have to assign some texture coordinates to your vertices. Use glTexCoord if you use the immediate mode.

gouessej
  • 3,640
  • 3
  • 33
  • 67