5

I have a GLSurfaceView with a drawable as background, however only the background is visible when rendered without surfaceView.setZOrderOnTop(true)

I need to avoid using setZOrderOnTop(true) because there are static TextView's being used on top of the GLSurfaceView.

Any suggestions for getting this to work?

anticafe
  • 6,816
  • 9
  • 43
  • 74
Jlam
  • 1,932
  • 1
  • 21
  • 26

4 Answers4

9

GLSurfaceView cannot really have a background. The way a surface view works is by cutting a hole through your Activity's window and showing another surface behind. Setting setZOrderOnTop(true) moves the surface above the Activity's window.

Romain Guy
  • 97,993
  • 18
  • 219
  • 200
  • Thank you that was very helpful! Is there a way that you could recommend for achieving what I needed: static background image -> 3d content -> additional views buttons on top or is the only way to just render the static background as texture on a polygon? – Jlam Oct 04 '10 at 17:00
  • 1
    I ended up just rendering the background on a polygon behind everything else.. thanks for the tip! – Jlam Oct 12 '10 at 17:37
7

false! You can do it. Just an example to show how it works.

glRenderer  = new OpenGLRenderer(context);
view = new GLSurfaceView(context);
view.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
view.setRenderer(glRenderer);
view.getHolder().setFormat(PixelFormat.RGBA_8888);
view.getHolder().setFormat(PixelFormat.TRANSLUCENT);
view.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);

Then use framelayout to put a view under glsurfaceview!

McDowell
  • 107,573
  • 31
  • 204
  • 267
jonathan
  • 71
  • 1
  • 1
2

Try setZOrderMediaOverlay(true); which should put the gl layer above the background but below the window.

Justin Buser
  • 2,813
  • 25
  • 32
1

Well, since GLSurfaceView is just another view, why not use a FrameLayout to place the GLSurfaceView on top of the ImageView (or whatever you're using to display the drawable.)

Miguel Morales
  • 1,707
  • 10
  • 10
  • Tired it but it wasn't working because of the following conditions: 1. The gl layer has a constant background image. 2. there are additional elements on top of the gl layer such as buttons etc. It wasn't possible to set the static image as a background on the gl layer because the actual 3d content would not render unless I setZOrderOnTop(true) on the gl layer. But if I do that then the additional elements would end up under the gl layer. – Jlam Oct 04 '10 at 16:54