2

Android Emulator に問題があります。gles 1 でテクスチャ キューブをレンダリングすると、境界線に背面が表示されます。

問題の画像

私の深度テストのセットアップは次のとおりです。

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);  // Set color's clear-value to black
    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.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);  // nice perspective view
    gl.glShadeModel(GL10.GL_SMOOTH);   // Enable smooth shading of color
    gl.glDisable(GL10.GL_DITHER);      // Disable dithering for better performance

そして私の視点:

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, 1000.f);

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

    // You OpenGL|ES display re-sizing code here
    // ......
}
4

1 に答える 1

2

深度バッファに十分な精度がないように見えるため、顔が多少重なっています。

可能であれば、深度範囲を減らすことをお勧めします。近面を増やして (たとえば 1 に)、遠面を減らします。平面が離れているほど、既存の範囲で得られる精度は低くなります。

于 2012-08-27T16:38:12.530 に答える