Author Topic: FrameBuffer transparent  (Read 2134 times)

Offline rtSJ

  • byte
  • *
  • Posts: 21
    • View Profile
FrameBuffer transparent
« on: April 18, 2014, 10:40:45 am »
Hello everyone !

I'm actually coding a 3D engine for visualize object and overlaying it on the preview of the camera of the device. It's work fine except one problem, I can't have the models and the preview on overlay because the render background is black... And when I want to specify an alpha color for my framebuffer, it's ignore !

Actuallt my code is like that :

Code: [Select]
fb.clear(new RGBColor(0,0,0, 255);
world.renderScene(fb);
world.draw(fb);
fb.display();

And I try to change Config.useFramebufferWithAlpha to true, but I can't access on this variable (I don't know if it's not supported or if I do bad manipulation).

I'm totaly lost on what I can do to resolve this problem.

Anyone have an idea ?

PS : Sorry for m'y bad english, I'm a french programmer and I do a lot of efforts to improve it, but it's hard ! =)
« Last Edit: April 28, 2014, 11:59:31 am by rtSJ »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: FrameBuffer transparent
« Reply #1 on: April 18, 2014, 11:42:38 am »
You can't access that variable, because it doesn't exist in the Android version. Clearing the buffer with alpha is sufficient. However, you have to setup your surface to support alpha too. Just google for jPCT-ae camera background and you should be able to find what to do.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: FrameBuffer transparent
« Reply #2 on: April 18, 2014, 12:56:16 pm »
This should contain the needed information (among many others...): http://www.jpct.net/forum2/index.php/topic,1586.0.html. I think the key is this line:

Code: [Select]
glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);

Offline rtSJ

  • byte
  • *
  • Posts: 21
    • View Profile
Re: FrameBuffer transparent
« Reply #3 on: April 18, 2014, 02:16:32 pm »
Ah okay, sorry for the variable, I haven't see that.

I have found a solution. I use :
Code: [Select]
getWindow().setFormat(PixelFormat.TRANSLUCENT);
GLSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);

And my bad is not a problem with jPCT, sorry for that. It's with my layout. I create all with code and to add layout on my scene I do :
Code: [Select]
setContentView(new CameraView(this));
setContentView(rl);

But it's not the way to do. Because the second replace the first. I need to do :
Code: [Select]
rl.addView(new CameraView(this));
setContentView(rl);

So, thanks a lot ! And sorry for my bad.

Have a nice day.