0

I am trying to make transparent openGLView for my game, I want it transparent only for one feature within my game. Actually, it is a feature related with camera of the device. I am using UIImagePickerController for my camera, but I am unable to make the GLView transparent.

I have tried using Ray's tutorial, And I am posting some of my code here:

glClearColor(0,0,0,0);

[CCDirector sharedDirector].openGLView.backgroundColor = [UIColor clearColor];
[CCDirector sharedDirector].openGLView.opaque = NO;

Then I am having a UIView which I am adding as a subView to the UIWindow and then I am adding the Picker view to UIView.

Any ideas's on how can I make this openGLView transparent?

Thanks for your time.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Shailesh
  • 3,072
  • 3
  • 24
  • 33

1 Answers1

2

Please Try following code for transparent.

glLayer.opaque = NO;      
glLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
Nimit Parekh
  • 16,776
  • 8
  • 50
  • 72
  • 1
    It says property "drawableProperties" not found on object type of EAGLView ..! – Shailesh Sep 10 '12 at 07:09
  • 2
    That's because glLayer is an instance of [CAEGLLayer](http://developer.apple.com/library/ios/#documentation/QuartzCore/Reference/CAEAGLLayer_Class/CAEGLLayer/CAEGLLayer.html), not EAGLView. CAEGLLayer is the layer in EAGLView. So just do view.layer.drawableProperties = ... – EmilioPelaez Sep 10 '12 at 07:30
  • Okay ..Got it ..But now when I am trying to add some Sprites, Why is the background BLACK ..? I want to them appear on the transparent background – Shailesh Sep 10 '12 at 07:48