Overlay Transparent GLSurfaceview onto existing view in android?
Asked Answered
M

2

6

Hi I have been trying to overlay a GLSurfaceview onto an existing view.The code below shows how I overlay. The only thing that doesnt work is the transparency of the glsurfaceview on top.

    view = new GLSurfaceView(this);

    view.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    view.getHolder().setFormat(PixelFormat.TRANSLUCENT);

    view.setRenderer(new Level1Renderer(this));

    setContentView(R.layout.test);


    addContentView(view, new LayoutParams(100,400));

I have then set the background colour in my renderer as

        gl.glClearColor(0.0f, 0.0f, 0.0f, 0);

Can someone advise me as to what I am leaving out?

Munt answered 6/4, 2011 at 10:57 Comment(0)
G
3

the code is correct, you may want to add

glView.setZOrderOnTop(true);
glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

(in case your view is hidden by other view and you need it on top.)

Goldy answered 8/2, 2012 at 21:27 Comment(0)
U
1

I had an issue with this too. I was trying to 'fade' my whole screen out by tweening alpha values of a view overlaying glSurfaceView (plus others). Other views all faded, but not the glSurfaceView.

I found that setZOrderMediaOverlay(true)...rather than setZOrderOnTop(true) on the glSurfaceView worked for me.

Undergo answered 17/3, 2013 at 0:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.