1

好的,所以我的深度缓冲区不起作用,因为当我在演示中移动时,它会改变显示的顶点,并使模型扭曲和“闪烁”。我的问题是,我做或不做任何可能导致这种影响的事情?

@Override
       public void onSurfaceCreated(GL10 gl, EGLConfig config) {
          gl.glClearColor(0.0f, 0.4f, 0.4f, 1.0f);  // Set color's clear-value to black
          /*Enable back face culling*/
          gl.glEnable(GL10.GL_CULL_FACE);
          gl.glCullFace(GL10.GL_BACK);
          gl.glFrontFace(GL10.GL_CCW);
          gl.glClearDepthf(1.0f);            // Set depth's clear-value to farthest
          gl.glEnable(GL10.GL_DEPTH_TEST);   // Enables depth-buffer for hidden surface removal
          gl.glDepthFunc(GL10.GL_LEQUAL);    // The type of depth testing to do
          gl.glDepthMask(true);
          gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);  // nice perspective view
          gl.glShadeModel(GL10.GL_SMOOTH);   // Enable smooth shading of color

          neroburst.model.loadTexture(gl, context);    // Load image into Texture (NEW)
          gl.glEnable(GL10.GL_TEXTURE_2D);  // Enable texture (NEW)
       }

       // Call back after onSurfaceCreated() or whenever the window's size changes
       @Override
       public void onSurfaceChanged(GL10 gl, int width, int height) {
          if (height == 0) height = 1;   // To prevent divide by zero
          float aspect = (float)width / height;

          // Set the viewport (display area) to cover the entire window
          gl.glViewport(0, 0, width, height);

          // Setup perspective projection, with aspect ratio matches viewport
          gl.glMatrixMode(GL10.GL_PROJECTION); // Select projection matrix
          gl.glLoadIdentity();                 // Reset projection matrix
          // Use perspective projection
          GLU.gluPerspective(gl, 45, aspect, 0.1f, 300.f);

          gl.glMatrixMode(GL10.GL_MODELVIEW);  // Select model-view matrix
          gl.glLoadIdentity();                 // Reset
       }

       // Call back to draw the current frame.
       @Override
       public void onDrawFrame(GL10 gl) {
          // Clear color and depth buffers using clear-value set earlier
          gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

          gl.glLoadIdentity();                 // Reset model-view matrix ( NEW )
           gl.glRotatef(neroburst.player.yaw, 0, 1, 0);
           gl.glTranslatef(-neroburst.player.pos.x, neroburst.player.pos.y, -neroburst.player.pos.z); 

          neroburst.model.draw(gl);
       }
4

1 回答 1

0

解决它。我起飞了

  gl.glEnable(GL10.GL_CULL_FACE);
  gl.glCullFace(GL10.GL_BACK);
  gl.glFrontFace(GL10.GL_CCW);

将 gl.glHint 从最快更改为最佳,我的视角接近值从 0.1f 更改为 1。

还添加了禁用抖动

于 2013-01-18T23:15:02.877 回答