This example describes how to use a transparent background to draw OpenGL images. The procedure is as follows:
1. Use transparent theme for Activity
<Activity android: name = ". graphics. TranslucentGLSurfaceViewActivity"
Android: label = "Graphics/OpenGL ES/Translucent GLSurfaceView"
Android: theme = "@ style/Theme. Translucent"
Android: configChanges = "keyboardHidden | orientation | screenLayout | screenSize | smallestScreenSize">
<Intent-filter>
<Action android: name = "android. intent. action. MAIN"/>
<Category android: name = "android. intent. category. SAMPLE_CODE"/>
</Intent-filter>
</Activity>
2. In the 8888 (RGBA) format, the Alpha channel is required to display transparent images.
[Java]
1. // We want an 8888 pixel format because that's required
2. // a translucent window.
3. // And we want a depth buffer.
4. mGLSurfaceView. setEGLConfigChooser (8, 8, 8, 8, 16, 0 );
3. Specify the Alpha channel for GLSurfaceView
[Java]
1. mGLSurfaceView. getHolder (). setFormat (PixelFormat. TRANSLUCENT );
4. the background color of the drawn graph line is)
[Java]
1. gl. glClearColor (0, 0, 0 );
Author: mapdigit