CCEGLView background transparent

CCEGLView background transparent
0.0 0


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

Video in Android (cocos2dx)

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


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

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();

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:

Set Cocos2dxGLSurfaceView background transparent

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 :


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 !