2

i am following nehe's tutorials. i intent to make a menu or at least buttons with opengl, yet object overlap on the menu

this is objects in the center with menu buttons on the right below

when menu buttons gets in the overlapping my code on the drawFrame function in the renderer

gl.glLoadIdentity();
    gl.glScalef(0.05f, 0.05f, 0.05f);
    gl.glTranslatef(0.0f, 0.0f, z-zKonum);
    gl.glRotatef(xAcisi, 1.0f, 0.0f, 0.0f);
    gl.glRotatef(yAcisi, 0.0f, 1.0f, 0.0f);
    dokukup.ciz(gl);
gl.glLoadIdentity();
    gl.glTranslatef(3.6f, -1.5f, z);
    tusYukari.ciz(gl);

    gl.glLoadIdentity();
    gl.glTranslatef(2.5f, -1.5f, z);
    tusAsagi.ciz(gl);

how do i get my menu buttons dominant(always on the top) on the overlapping?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Alp
  • 1,863
  • 1
  • 20
  • 38

1 Answers1

2

You can get the buttons to appear always on top by drawing the buttons last and disabling depth testing when drawing the buttons. Then make sure to enable depth testing again before drawing the next frame so that your 3D geometry renders properly.

In your drawFrame function you would do the following steps:

  1. Enable depth testing
  2. Draw the main scene geometry
  3. Disable depth testing
  4. Draw the buttons
user3256930
  • 1,123
  • 7
  • 12
  • in the draw function of tus add first gl.glDisable(GL10.GL_DEPTH_TEST); to the last of the function gl.glEnable(GL10.GL_DEPTH_TEST); – Alp Jan 31 '14 at 12:16