CCEGLView background transparent

Hi all, I’m trying to make a CCEGLView with a transparent background, in iPhone is easy to achieve because objective C manages that, but is there any option to achieve this in an android phone?? even hacking cocos2dx ? thanks in advance

I think you should do it in java code.
Try to add the code

this.getHolder().setFormat(PixelFormat.TRANSPARENT);

in Cocos2dxGLSurfaceview.initView().

Let me know the result.
Thank you.

Hi Minggo Zhang. Finally I achieve this some a couple of days ago.

I had to add some code in Cocos2dxGLSurfaceView.java

in the initView method :

mRenderer = new Cocos2dxRenderer(); setFocusableInTouchMode(true); setEGLConfigChooser(8, 8, 8, 8, 16, 0); setRenderer(mRenderer); getHolder().setFormat (PixelFormat.TRANSLUCENT);

and in the Cocos2dxRenderer

modify the onSurfaceCreated(GL10 gl, EGLConfig config) method:

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
nativeInit(Cocos2dxActivity.screenWidth, Cocos2dxActivity.screenHeight);
last = System.nanoTime();
gl.glDisable(GL10.GL_DITHER);
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
GL10.GL_FASTEST);
gl.glClearColor(0,0,0,0);
gl.glEnable(GL10.GL_CULL_FACE);
gl.glShadeModel(GL10.GL_SMOOTH);
gl.glEnable(GL10.GL_DEPTH_TEST);
}

With this I get a transparent openGLview background by the way I will make a post about my application done with cocos2dx for iPhone and android very soon :slight_smile:

Great. I think you not only want to get transparent background, but also more feathers. Don’t you?

nope, I was looking for the transparent background to be able to put the android device camera picture behind the opengl to be able to make an screenshot of the opengl + the camera picture.

Finally i had to save the camera picture after making the photo to load it as an sprite and make an screenshot of the openGl view only. Im waiting for the android market to approve our app so all the forum can take a look to it :slight_smile:

Waiting for it.

Sorry, I posted here : http://www.cocos2d-x.org/boards/6/topics/4899

hi, how to make a transparent background in IOS, thanks

I did it, but my SurfaceView cannot transparent.
I make game android, using cocos2d-x 3.10.

sombody do it succees help me, please !