Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining a Canvas and OpenGL ES Renderer?

I have an app that uses a Class with an extension SurfaceView to draw to a canvas, but i'm looking at moving over to openGL. I noticed that if I merely change the SurfaceView extension to a GLSurfaceView, the app still runs the same. I've also been able to start basic drawing in another app using openGL ES.

I took it the next step and instantiated another class for the renderer in GLSurfaceView, and I instruct the render to draw a triangle. This all compiles and runs fine, but it runs exactly like the original App, with no triangle rendered, but the rest of the canvas draws properly.

I can't think of why it's not rendering, or why it wouldn't render. Or maybe it is rendering, but it's simply being overridden by the canvas?

I know it seems odd to try to use both methods, Since my app is live, I would rather implement switching the rendering over to GL at my own pace so that it doesn't take me a month to get the next update out.

So Anybody ever tried do do this? Run a Gl renderer OVER a canvas?

like image 780
cody Avatar asked Oct 18 '25 07:10

cody


2 Answers

You cannot use both OpenGL and a Canvas to render on a single SurfaceView. You can however put another View on top of the SurfaceView to achieve the desired effect.

like image 128
Romain Guy Avatar answered Oct 19 '25 22:10

Romain Guy


Try the following:

addContentView(SurfaceView);
addContentView(GLSurfaceView);

or create a relative layout with both views.

like image 23
Audrius Butkevicius Avatar answered Oct 19 '25 21:10

Audrius Butkevicius



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!