Author Topic: Transparent Background for surfaceview  (Read 7632 times)

amirr

  • Jr. Member
  • **
  • Posts: 6
Transparent Background for surfaceview
« 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 ?

jerome_j

  • Administrator
  • *****
  • Posts: 116
    • Bonzai Engine
Re: Transparent Background for surfaceview
« Reply #1 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.

amirr

  • Jr. Member
  • **
  • Posts: 6
Re: Transparent Background for surfaceview
« Reply #2 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)

jerome_j

  • Administrator
  • *****
  • Posts: 116
    • Bonzai Engine
Re: Transparent Background for surfaceview
« Reply #3 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).
« Last Edit: May 19, 2013, 01:34:52 PM by jerome_j »

amirr

  • Jr. Member
  • **
  • Posts: 6
Re: Transparent Background for surfaceview
« Reply #4 on: May 19, 2013, 02:57:23 PM »
It works fine :).
Thank you for your help :) and +1 for the library :)