Domanda

I have a problem in which my opengl doesn't render properly on HTC devices.

I've tested it on a few other devices on which it renders properly. is an example on a normal device: Here is an example on a normal device. And here is an example with the HTC Desire and Desire S.

The problem when I added in

GLES20.glEnable(GLES20.GL_DEPTH_TEST);

and goes again when I comment it out, but I can't just leave it out as then half my walls go invisible.

Is it possible it has something to do with this? Is there anything I can do? I can supply more code.

È stato utile?

Soluzione

Most probably you've forgot to explicitly specify some stuff. Defaults differ between devices, and code which works on one GPU will fail on another one. Please make sure you've set all of these:

GLES20.glEnable(GLES20.GL_DEPTH_TEST); // enable depth test
GLES20.glDepthMask(true); // write to z-buffer
GLES20.glDepthFunc(GLES20.GL_LEQUAL); // specify the way depth test works

When drawing geometry, always clean both color and depth buffers:

GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); // clear both color and z-buffer

And finally, ensure that you've properly initialized your OpenGL context and you do have depth buffer for used EGL config (EGL_DEPTH_SIZE is not 0). You can find a list of all available EGL configs for Desire S here: http://gfxbench.com/device.jsp?benchmark=gfx27&D=HTC+Desire+S&testgroup=egl

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top