Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GLSurfaceView/SurfaceView overlap

I asked a question about this earlier but received no responses, so I'm trying again.

I need to do a rendered 2D picture with some accompanying labels and graphics on a Motorola Xoom, Android 3.0. Although what I need can be done with just a SurfaceView (Canvas) or just a GLSurfaceView, I would really like to use both because the rendering is faster with the GLSurfaceView, and the labeling and graphics are easier with the SurfaceView. The visual layout is as shown below. SurfaceView/GLSurfaceView visual layout

I tried to put the SurfaceView on top by declaring it in the layout XML after the GLSurfaceView. The SurfaceView is transparent (except for where I explicitly draw stuff) so that the GLSurfaceView can still be seen.

This approach has worked pretty well with one huge exception. Anything that I draw on the SurfaceView that is in the GLSurfaceView region does not show up at all. To verify this I drew some text that was right on the boundary (some in the shared region, some just in the SurfaceView region), and it was chopped off at the GLSurfaceView boundary. I have tried using the "bringToFront" method to fix this, but it hasn't worked.

Can anyone give me some ideas on why this isn't working or what I can do about it? Is it that the GLSurfaceView is in front, or is that the GLSurfaceView writes directly to the video memory, so it doesn't matter if something is in front of it?

like image 941
Jim Clay Avatar asked Jul 01 '26 13:07

Jim Clay


2 Answers

The way SurfaceViews work will make it impossible to do what you want. You will have to render your text inside the GLSurfaceView.

like image 173
Romain Guy Avatar answered Jul 03 '26 03:07

Romain Guy


Never try to overlap a GLSurfaceView with anything (above or below). At best it breaks on your device and you catch it early, at worst it works on one device and not others. Bite the bullet and do everything in a GL view or none of it. If you need the speed then GL is the way to go.

like image 41
Andrew White Avatar answered Jul 03 '26 03:07

Andrew White



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!