(Android) No puedo hacer que el búfer de profundidad funcione en opengl es2
Frecuentes
Visto 1,071 veces
0
I already spent several hours trying to make depth buffer work, but no luck. Initialization code:
class MyGLSurfaceView extends GLSurfaceView {
public BasicGLSurfaceView(Context context) {
super(context);
[...]
setEGLContextClientVersion(2);
setEGLConfigChooser(8, 8, 8, 8, 16, 0);
[...]
m_rend = new ViewRenderer(context, m_app);
setRenderer(m_rend);
}
rendering funcrtion looks like this:
public void Render() {
[...]
GLES20.glClearColor(m_backColor.x(), m_backColor.y(), m_backColor.z(), 1.0f);
GLES20.glClearDepthf(1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
[...]
GLES20.glEnable(GLES20.GL_DEPTH_TEST);
GLES20.glDepthFunc(GLES20.GL_LEQUAL);
GLES20.glDepthMask(true);
GLES20.glDepthRangef(m_depthNear, m_depthFar);
[...]
[...rendering...]
}
I assume that there are two things can be wrong: first is depth buffer wasn't initialized successfully, but setEGLConfigChooser returns no error, and second if I setup rendering states incorrrectly. What's wrong with my code?
BTW. I've made it work in my NativeActivity project, but i can't do the same in java :(
Gracias de antemano!
0 Respuestas
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas android opengl-es-2.0 or haz tu propia pregunta.
Please define what 'not work' means exactly. Also what is your 'depthNear/depthFar' set to? Have you tested errors with glGetError? - Tim
Not work means that it draws like there is no depth buffer at all. And yes, I tried glGetLastError, please, read the question carefully. - Tutankhamen
The problem was solved by rebooting my galaxy tab and restarting Eclipse... In other words, it wasn't actually application bug, but troubles somewhere in Eclipse or Android SDK internals. - Tutankhamen