我有 6 个立方体连接在一起,如下图所示:
但是当我旋转它时。问题是后面的立方体没有被前面的立方体覆盖
虽然我使用:
gl.glEnable(GL10.GL_CULL_FACE); // Enable cull face
gl.glCullFace(GL10.GL_BACK); // Cull the back face (don't display)
Run Code Online (Sandbox Code Playgroud)
这是我的 onDrawFrame 重写函数:
@Override
public void onDrawFrame(GL10 gl) {
// Clear color and depth buffers
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glFrontFace(GL10.GL_CCW); // Front face in counter-clockwise
gl.glEnable(GL10.GL_CULL_FACE); // Enable cull face
gl.glCullFace(GL10.GL_BACK); // Cull the back face (don't display)
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); // Enable texture-coords-array (NEW)
// ----- Render the Cube -----
update();
if (currentTransperent != newTransperent) {
cube.loadTexture(gl, context, newTransperent);
currentTransperent = newTransperent; …Run Code Online (Sandbox Code Playgroud) opengl ×1