首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenGL ES安卓系统中的深度缓冲区问题

OpenGL ES安卓系统中的深度缓冲区问题
EN

Stack Overflow用户
提问于 2013-01-19 04:19:45
回答 1查看 924关注 0票数 1

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

代码语言:javascript
复制
@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);
       }
EN

回答 1

Stack Overflow用户

发布于 2013-01-19 07:15:03

修好了。我离开了

代码语言:javascript
复制
  gl.glEnable(GL10.GL_CULL_FACE);
  gl.glCullFace(GL10.GL_BACK);
  gl.glFrontFace(GL10.GL_CCW);

将gl.glHint从最快改为最好,我的透视图的近似值从0.1f变为1。

还添加了禁用抖动

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14406993

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档