1

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

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

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

下面的代码从我的视图控制器移动到更多场景:

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

}

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

请帮助解决我的问题。

谢谢你。

4

0 回答 0