Cocos3d: - [EAGLView swapBuffers]中的OpenGL错误0x0506和空白场景

时间:2013-04-15 15:49:28

标签: cocos3d

在我的cocos3d应用程序中,我有一个UIViewController作为rootview控制器,从那里我将在使用时点击一个选项再次启动Cocos3d场景。

以下是我的代码,用于从此视图控制器启动场景。问题是,如果我打开uiviewcontroller然后通过单击一个选项移动到场景两次以上,那么我得到错误为“OpenGL错误0x0506 in - [EAGLView swapBuffers] 在绘制HomeOwners3DScene未命名:1691之前,[ GL错误 ]未知GL错误(1286)。要进一步调查,请在项目构建设置中设置预处理器宏GL_ERROR_TRACING_ENABLED = 1。“

[这个问题不是我第一次看到现场,它显示正确。但是,如果我返回并单击返回以显示场景超过两次或更多,那么它似乎是空白场景,xcode中出现以下错误

以下代码从我的viewcontroller移动到更多场景:

    -(void) launchMainScene :(UIViewController *) uiViewCrtller
{
[uiViewCrtller.view removeFromSuperview];

// This must be the first thing we do and must be done before establishing view controller.
if( ! [CCDirector setDirectorType: kCCDirectorTypeDisplayLink] )
[CCDirector setDirectorType: kCCDirectorTypeDefault];

// Default texture format for PNG/BMP/TIFF/JPEG/GIF images.
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565. You can change anytime.
CCTexture2D.defaultAlphaPixelFormat = kCCTexture2DPixelFormat_RGBA8888;

// Create the view controller for the 3D view.
viewController = [CC3DeviceCameraOverlayUIViewController new];
//viewController.supportedInterfaceOrientations = UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;

// Create the CCDirector, set the frame rate, and attach the view.
CCDirector *director = CCDirector.sharedDirector;
//director.runLoopCommon = YES;  // Improves display link integration with UIKit
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
director.animationInterval = (1.0f / kAnimationFrameRate);
director.displayFPS = YES;
director.openGLView = viewController.view;

// Enables High Res mode on Retina Displays and maintains low res on all other devices
// This must be done after the GL view is assigned to the director!
[director enableRetinaDisplay: YES];

[director setDepthTest:NO];

// Create the window, make the controller (and its view) the root of the window, and present the window

[window addSubview: viewController.view];

CCDirector.sharedDirector.displayFPS = NO;

[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];

// Set to YES for Augmented Reality 3D overlay on device camera.
// This must be done after the window is made visible!
viewController.isOverlayingDeviceCamera = NO;

// Create the customized CC3Layer that supports 3D rendering and schedule it for automatic updates.
CC3Layer* cc3Layer = [HomeOwners3DLayer node];
[cc3Layer scheduleUpdate];

// Create the customized 3D scene and attach it to the layer.
// Could also just create this inside the customer layer.
cc3Layer.cc3Scene = [HomeOwners3DScene scene];

// Assign to a generic variable so we can uncomment options below to play with the capabilities
CC3ControllableLayer* mainLayer = cc3Layer;

CCScene *scene = [CCScene node];
[scene addChild: mainLayer];
[[CCDirector sharedDirector] runWithScene: scene];

}

当我启动场景并且在场景中显示空白屏幕时多次返回viewcontroller和启动场景时, Error Error会抛出Xcode控制台: * [这个问题不是我第一次看到现场,它显示正确。但如果我返回并单击返回以显示场景超过两次或更多,那么它似乎是空白场景,xcode中出现以下错误 * OpenGL错误0x0506 in - [EAGLView swapBuffers] 在绘制HomeOwners3DScene未命名:1691之前,[ GL错误 ]未知GL错误(1286)。要进一步调查,请在项目构建设置中设置预处理器宏GL_ERROR_TRACING_ENABLED = 1。

请帮助解决我的问题。

谢谢。

0 个答案:

没有答案