1

Is there any way to make an entire Android OpenGL ES scene transparent? This would be useful for widgets and wallpapers.

There is one Android-specific answer here. But my understanding is that this technique creates a transparent background, upon which one could furthermore draw transparent shapes.

I am looking for a way to make the entire scene transparent after it has been drawn. For instance, is there any way to change the alpha of the entire color buffer after the scene has been drawn?

Community
  • 1
  • 1
Mountains
  • 123
  • 1
  • 2
  • 9

2 Answers2

3

Yes, and it's quite easy. You need to blend the values in the color buffer, by covering the whole view with a quad using the right color and blending function. I think this will do the trick:

  • Draw your scene as normal
  • set glBlendFunc(GL10.GL_ZERO, GL10.GL_SRC_COLOR)
  • Draw an untextured colored quad that covers the whole view with (R,G,B,A) = (1,1,1,a) where a is your desired opacity

This should scale the alpha of the colorbuffer with a, which I think is what you want.

Aert
  • 1,989
  • 2
  • 15
  • 17
0

If you can require API 14 (Android 4.0) then there's a new class that addresses this very issue: TextureView. There's some info about it in this Android Developers blog post. Unfortunately I don't think there's an easy way to do this in previous versions of Android.

kabuko
  • 36,028
  • 10
  • 80
  • 93