2

私は OpenGL ES 2.0 を使用しており、Stencil Buffer を使用しています。以下は、私が作成した単純な Stencil Buffer Demo のコードです。ステンシルは 1 つのデバイスでのみ正常に動作します。

デバイスは次のとおりです。

Android 4.2.2、PowerVR SGX 544MP (GPU)、Allwinner A10 タブレット。(ステンシル バッファはこのデバイスで完全に動作します)

Android 4.1.2、Adreno 225 (GPU)、Galaxy S III 電話。(ステンシル バッファは機能しません。まれにステンシルのゴースト イメージがちらつくことがあります。

Android 4.2.2、Mali-400MP (GPU)、Rockchip rk30sdk タブレット。(最初のテストでは、ステンシル バッファーは機能していませんでした。多くの変更を行った後、現在は機能しているように見えます。ステータスは疑問です。この時点で動作中のステンシル バッファーを修正した特定の変更は不明です)

同じ最新の .APK で上記の結果が得られました。

「Play Store」のアプリケーション「OpenGL 3D Showcase」は 3 つのデバイスすべてで実行され、「showcase」 #18 「Stencil Buffer Shadows」[OGL 1.1] はエラー メッセージなしで完全に動作します。ソース コードはアプリと共に提供されますが、役に立たないことが確認されています。

以下は私のステンシルコードです:

public void onDrawFrame(GL10 glUnused) {
    // Clear the rendering surface.
     glClear( GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );

    multiplyMM(viewProjectionMatrix, 0, projectionMatrix, 0, viewMatrix, 0);

    invertM(invertedViewProjectionMatrix, 0, viewProjectionMatrix, 0);

    //Start using the stencil
    glEnable( GL_STENCIL_TEST );
    //Disable rendering to the color buffer
    glColorMask( false, false, false, false );


   //Place a 1 where rendered
   glStencilFunc( GL_ALWAYS, 1, 1 );

   //Replace where rendered
   glStencilOp( GL_REPLACE, GL_REPLACE, GL_REPLACE );

   glDisable(GL_DEPTH_TEST); 

   glStencilMask(0xFF);//value used when writing to stencil buffer      

    // draw stencil triangle
    rotateObjectInScene(0.0f, 0.0f, 0.0f);//x,y,z Object is rottated one full rotation ever 3 seconds within
    colorProgram.useProgram();
    colorProgram.setUniforms(modelViewProjectionMatrix, 0f, 0f, 1f);
    DemoTriangleStencilObj.bindData(colorProgram);
    DemoTriangleStencilObj.draw();

    //Reenable color
    glColorMask( true, true, true, true );
    //Where a 1 was not rendered
    glStencilFunc( GL_EQUAL, 1, 1 );//GL_EQUAL GL_NOTEQUAL
    //Keep the pixel
    glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );

    glStencilMask(0x00);//disable writing to stencil buffer by setting value used to 0.

    positionObjectInScene1(0.0f, 0.0f, 0.0f);//leave image/object fixed in center of screen
    textureProgram1.useProgram();
    textureProgram1.setUniforms(modelViewProjectionMatrix, texture_opengl);
    openglImageDemoObj.bindData(textureProgram1);
    openglImagerectanDemoObj.draw();

    //Finished using stencil
    glDisable( GL_STENCIL_TEST );

}

初期化:

public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

}

public void onSurfaceChanged(GL10 glUnused, int width, int height) {
    // Set the OpenGL viewport to fill the entire surface.
    glViewport(0, 0, width, height);

    // Landscape
    orthoM(projectionMatrix, 0, -1, 1, -1f, 1f, -1f, 20f);

    setLookAtM(viewMatrix, 0, 0f, 2.0f, 0.1f, 0.0f, 0f, 0f, 0f, 1f, 0f);

}

初期化 2:

コメントされたすべての「setEGLConfigChooser」呼び出しが試行されました。

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //Remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    //Remove notification bar
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //setContentView(R.layout.activity_fist_open_glproject_aactivity);
    glSurfaceView = new GLSurfaceView(this);
    final TheSurfaceRenderer theSurfaceRenderer = new TheSurfaceRenderer(this);

    this.getApplicationContext();
    final ActivityManager activityManager =
            (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    final ConfigurationInfo configurationInfo =
            activityManager.getDeviceConfigurationInfo();
    //final boolean supportsEs2 = false;//configurationInfo.reqGlEsVersion >= 0x20000;
    final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;

    if (supportsEs2) {
        // Request an OpenGL ES 2.0 compatible context.
        glSurfaceView.setEGLContextClientVersion(2);

        //glSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);//when use emulator, may be needed.
        glSurfaceView.setEGLConfigChooser(new MultiSampleConfigChooser());
        //glSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 8);
        //glSurfaceView.setEGLConfigChooser(5,6,5,0,24,8);
        //glSurfaceView.setEGLConfigChooser(5,6,5,0,16,8);
        //glSurfaceView.setEGLConfigChooser(5,6,5,8,16,8);

        // Assign our renderer.
        //glSurfaceView.setRenderer(new AirHockeyRenderer(this));
        glSurfaceView.setRenderer(theSurfaceRenderer);
        rendererSet = true;
        //Toast.makeText(this, "Renderer started", Toast.LENGTH_LONG).show();
    } else {
        Toast.makeText(this, "This device does not support OpenGL ES 2.0.",
        Toast.LENGTH_LONG).show();
        return;
    }

    setContentView(glSurfaceView);
}

問題を追跡するためのアイデアはありますか? 他に助けが得られる可能性のある場所はありますか?(必要な場合は、MFG/Android/Google に連絡してどこにでも行くことができますか?)

4

1 に答える 1