Android OpenGL ES Transparent Background
Just some simple changes that I did to get this to work.
On my GLSurfaceView.Renderer
:
public void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glDisable(GL10.GL_DITHER); gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST); gl.glClearColor(0,0,0,0); gl.glEnable(GL10.GL_CULL_FACE); gl.glShadeModel(GL10.GL_SMOOTH); gl.glEnable(GL10.GL_DEPTH_TEST);}
On my GLSurfaceView
:
setEGLConfigChooser(8, 8, 8, 8, 16, 0);getHolder().setFormat(PixelFormat.TRANSLUCENT);
I use my own GLSurfaceView class to display charts (transparent background / overlay).My extended GLSurfaceView is embed via XML into a popover window.
<com.dsignmatters.iq_fitfunlite.GLPieChartView android:id="@+id/gameprogress_chart" android:layout_height="wrap_content" android:layout_width="wrap_content" ...
As part of the activity I added this code:
mGamesuccessPieChart = (GLSurfaceView) gameprogressView.findViewById(R.id.gameprogress_chart);mGamesuccessPieChart.setZOrderOnTop(true);
Last but not least my GLSurfaceView looks like this:
public class GLPieChartView extends GLSurfaceView { public GLPieChartView(Context context) { super(context); initGL(); } public GLPieChartView(Context context, AttributeSet attrs) { super(context, attrs); initGL(); } void initGL() { setEGLContextClientVersion(2); setEGLConfigChooser(8,8,8,8,16,0); setRenderer(new GLPieChartRenderer()); setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); getHolder().setFormat(PixelFormat.TRANSLUCENT); } }
My renderer class GLPieChartRenderer
does not call glClearColor
at all.