Alpha混合使用iPhone上的Apple UI

时间:2011-11-09 20:15:42

标签: iphone opengl-es cocos2d-iphone

我正在尝试使用UIImageView在标准UIView上放置一个OpenGL视图。当我在OpenGL视图中绘制任何内容时,我会看到轻微的alpha混合问题,导致下面的白线: white alpha blending

CCDirector *director = [CCDirector sharedDirector];
EAGLView *glView = [EAGLView viewWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)
                               pixelFormat:kEAGLColorFormatRGBA8    // kEAGLColorFormatRGBA8
                               depthFormat:0                        // GL_DEPTH_COMPONENT16_OES
                    ];
[glView setMultipleTouchEnabled:YES];

[director setOpenGLView:glView];

if(![director enableRetinaDisplay:YES]) NSLog(@"Retina Display Not supported");
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
[director setAnimationInterval:1.0/60];

[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];

[[CCDirector sharedDirector] runWithScene:[PPAvatarEditorScene scene]];
[[CCDirector sharedDirector] resume];
[glView setOpaque:NO];
[avatarImage addSubview:glView];

我正在使用Cocos2D绘制到OpenGL视图中。 Alpha像素格式或纹理格式是否存在问题?

1 个答案:

答案 0 :(得分:1)

尝试将glClearColor设置为黑色:

glClearColor(0, 0, 0, 0);