Depth Test not working even though enabled. [SOLVED]

Problems with Canvas, OpenGL, etc...

Depth Test not working even though enabled. [SOLVED]

Postby millerni456 » Wed Oct 05, 2011 12:51 am

SOLUTION: GLSurfaceView.setEGLConfigChooser() was set improperly. Because of this, Depth was disabled.
To correctly set this up, choose setEGLConfigChooser(true) or simple do not call the function.
_______________________________________________________________________________


Hello, my name is Nick and I'm new to this forum. Hopefully this will help me to learn OpenGL and Android!
Lately I've had problems with depth testing in opengl (only with rectangular primitives oddly enough).

So I have a texture cube. And for some reason only the insides of the cube appear, meaning that the external faces are culled. Why these are culled I believe has to do with depth testing.

FYI: I have not messed around with culling settings. I'm using the defaults which means nothing will cull. (Both faces of a normal are seen).

So even though It can't be culling, theoretically it shouldn't be depth testing either. On other applications I made (that have no errors with depth), I follow the same procedure:

First I set up depth clearing like such:
Code: Select all
gl.glClearDepthf(1);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT|GL10.GL_DEPTH_BUFFER_BIT);


Next I enable depth testing:
Code: Select all
gl.glEnable(GL10.GL_DEPTH_TEST);


So theoretically this should work since it does with my non-Android applications.
Another note is that the order of vertices (even though I believe they are correct since they match other apps I made), does not matter. Remember culling doesn't take effect.

Help is greatly appreciated for this. And I hope this helps other having similar problems. After spending some time looking online. I found that this made be some problem with rectangles. (pairs of triangles)

I have other shapes in my scene (a single triangle and a pentagon) that do not interfere with depth testing. They render correctly.

continued to 2nd post...
Last edited by millerni456 on Sat Oct 08, 2011 3:29 am, edited 2 times in total.
millerni456
Junior Developer
Junior Developer
 
Posts: 12
Joined: Wed Oct 05, 2011 12:39 am

Top

Re: Depth Test not working even though enabled.

Postby millerni456 » Wed Oct 05, 2011 3:16 am

I now notice that it is happening to other primitives I have.
I currently have a truncated cone (no top and bottom, sorta looks like a megaphone)
And the back side renders on top :?

[EDIT]

I am using VBO's to render my objects. That being said my data is being sent to the GPU and stored. That may be causing problems with the rendering. This would be the only difference between this and my other applications.

Also let me through out there that I think this either has something to do with Indices or Texture coordinates.


So I hope this gives a clear understanding of the trouble I'm having.

Thanks- Nick.
millerni456
Junior Developer
Junior Developer
 
Posts: 12
Joined: Wed Oct 05, 2011 12:39 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 3 guests