GLSurfaceView - how to make translucent background

后端 未结 5 1468
日久生厌
日久生厌 2021-01-04 19:08

I try to render using GLSurfaceView, and by docs I set format:

getHolder().setFormat(PixelFormat.TRANSLUCENT);

The I use GLSurfaceView.Rend

5条回答
  •  春和景丽
    2021-01-04 19:47

    I'm not sure what the problem is exactly but an alternative could be covering the screen with a translucent colored rectangle and just clearing the depth buffer bit.

    Is there any alternative for GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT)?

    Otherwise make sure your depth buffer bit is 1

    I'll be back later to try and recreate the problem on my phone in a bit when I can.

    Edit: I just realized that the reason it appears blue may be that you set it to .5f so it only takes 2 calls for it to get to full 1f opacity. meaning that it takes at 30fps 1/15th of a second to go fully blue.

    Try lowering the alpha transparency value to 0.01f or 0.05f

提交回复
热议问题