Bonzai Engine Forum

Bonzai Engine & Tools => Bonzai Engine on Android => Topic started by: amirr on May 19, 2013, 12:49:21 PM

Title: Transparent Background for surfaceview
Post by: amirr on May 19, 2013, 12:49:21 PM
Hello,
I'm newbie to Bonzai library, all what am searching for is to make the background of the surfaceview that get from "sceneTarget.getGLSurface()".

i tried those and it's failed:
Those 2 lines before
sceneTarget.init(scene, dc/* caps */, null);
mGLSurfaceView.setZOrderOnTop(true);
sceneTarget.getGLSurface().setEGLConfigChooser(8, 8, 8, 8, 16, 0);

and this one after init
mGLSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);

any advice ?
Title: Re: Transparent Background for surfaceview
Post by: jerome_j on May 19, 2013, 01:12:21 PM
You probably forgot to clear the color buffer with alpha of 0 (or filled it later with 1 everywhere), see glClearColor of BeStandaloneTutorial.

For setting up theGLSurfaceView, the best way is probably (but should work with what you showed me):

Ps: no need to send me forum post notification by mail, the forum already do that automatically.
Title: Re: Transparent Background for surfaceview
Post by: amirr on May 19, 2013, 01:22:29 PM
Setting this value ( caps.setNumAlphaBits(8/*or other non 0 value*/); ) causes a crash.

FATAL EXCEPTION: GLThread 1911
java.lang.IllegalArgumentException: No config chosen
at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:874)
at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1024)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1401)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
Title: Re: Transparent Background for surfaceview
Post by: jerome_j on May 19, 2013, 01:31:21 PM
You certainly have to set r/g/b bits to 8 too (if it still fails, which it should not, use your egl config line instead of setAlphaNumBits).
Title: Re: Transparent Background for surfaceview
Post by: amirr on May 19, 2013, 02:57:23 PM
It works fine :).
Thank you for your help :) and +1 for the library :)