如何使cocos3D场景透明(具有透明背景的EAGLView)?我知道这会是个重复的问题。--但我尝试过各种来源的所有建议,但它们都不是为我工作的,。
只需在这里列出它们作为参考:
1)改变CCDirector.m中setGLDefaultValues方法中的不透明和清晰的颜色
openGLView_.opaque = NO;
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);2)在EAGLView initWithCoder中
CAEAGLLayer *eaglLayer = (CAEAGLLayer*)[self layer];
pixelformat_ = kEAGLColorFormatRGBA8;
depthFormat_ = 0; // GL_DEPTH_COMPONENT24_OES;
multiSampling_= NO;
requestedSamples_ = 0;
size_ = [eaglLayer bounds].size;
eaglLayer.opaque = NO;
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
const CGFloat myColor[] = {0.0, 0.0, 0.0, 0.0};
eaglLayer.backgroundColor = CGColorCreate(rgb, myColor);
CGColorSpaceRelease(rgb);
eaglLayer.drawableProperties = eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
if( ! [self setupSurfaceWithSharegroup:nil] ) {
[self release];
return nil;
}3)改变了my CCViewController的CCViewController方法
viewController.isOverlayingDeviceCamera = YES;我正在使用EAGLView.hVersion1.3我尝试使用更新的版本(1.7),但是我无法继续,因为它给这个导入带来编译器错误
#import <OpenGL/OpenGL.h>请帮我一把,因为我把一整天都浪费在这里玩了
发布于 2013-11-27 10:54:58
我相信你把OpenGL透明的颜色误认为是UIView透明的颜色:
而不是
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);使用
openGLView_.backgroundColor = [UIColor clearColor];发布于 2013-12-01 17:23:30
在cocos3d 2.0中,查看一下hello、world项目模板或CC3DemoMashUp演示应用程序中的AppDelegate类。
如果您取消对这一行的评论:
_viewController.isOverlayingDeviceCamera = YES;它会做你想做的。
一定要遵循那些AppDelegates中的模式来创建导演、控制器和视图。特别是,对于cocos3d,您应该使用CC3UIViewController (或者像CC3DeviceCameraOverlayUIViewController这样的子类来显示摄像机),并让它配置和创建CC3GLView。远离EAGLView等。
如果您在使用 cocos3d 之前的2.0版本,同样,它也是类似的,并查看如何在示例cocos3d AppDelegates中处理控制器和视图。
https://stackoverflow.com/questions/20240147
复制相似问题