FrameBuffer transparent

Started by rtSJ, April 18, 2014, 10:40:45 AM

Previous topic - Next topic

rtSJ

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 :

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 ! =)

EgonOlsen

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.

EgonOlsen

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:


glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);

rtSJ

Ah okay, sorry for the variable, I haven't see that.

I have found a solution. I use :
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 :

setContentView(new CameraView(this));
setContentView(rl);


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


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

Have a nice day.