多个OpenGL视图(Cocos2D) [英] Multiple OpenGL views (Cocos2D)

查看:403
本文介绍了多个OpenGL视图(Cocos2D)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意: 注意:

在我的应用程序中我混合UIKit与Cocos2D在一起,我做一些简单的自定义视图动画使用addSubview和removeFromSuperview调用。我最近需要添加另一个CCScene到我的应用程序,以摆脱一些复杂的UIKit代码Cocos2D可以轻松处理。所以我有一个基本视图在我的应用程序,它是一个UIViewController与一些按钮上。在这些按钮后面是一个CCGLView Cocos2D将做任何事情。这工作伟大。然后当我想去我的第二个视图控制器(让我称之为我的游戏视图),我做我的视图动画后,viewdidload被调用(这是我的导演初始化为第二个CCScene)并没有发生任何事情,或者我在控制台中得到如下的错误。现在在我原来的项目中,下面的错误是我得到的,在这个示例项目什么也没有发生。这些是错误:

  DrawSolidPolygon中的OpenGL错误0x0501 104 
DrawSolidPolygon中的OpenGL错误0x0502 104
OpenGL错误0x0501在 - [CCTextureAtlas drawNumberOfQuads:fromIndex:] 556
OpenGL错误0x0502在 - [CCTextureAtlas drawNumberOfQuads:fromIndex:] 556
OpenGL错误0x0502在 - [CCTextureAtlas drawNumberOfQuads:fromIndex:] 556
OpenGL错误0x0501 in - [CCParticleSystemQuad postStep] 411
OpenGL错误0x0506在 - [CCSprite draw] 532
OpenGL错误0x0502在 - [CCParticleSystemQuad draw] 434
OpenGL错误0x0502在 - [CCSprite draw ] 532
OpenGL错误0x0502 in - [CCSprite draw] 532

场景在我原来的项目没有像这样发生,它只发生现在,我使用2 CCScenes。因此,示例项目中的代码是我的原始项目的一个很多副本,所以任何错误都很可能导致我解决这里的问题,希望摆脱这些OpenGL错误。



经过几个小时的测试和收集信息后,似乎我的问题类似于: iOS和多个OpenGL视图。我也看到了这个链接: http://gamesfromwithin.com/using-multiple-opengl-views-and -uikit 。但是这两个链接对我没有任何意义,因为我不知道如何与它关联到Cocos2D。我认为这整个问题是当前版本的Cocos2D的限制,但如果有人可以下载我的项目,并以某种方式将这两个链接的修复应用到我的项目,并完全解决它,这将是伟大的,将解决我的所有问题!



现在我的项目中的Cocos2D版本是2.0版本的最新下载版本。如果任何人会很好下载项目,看看我做错了我想这将解决我和其他人遇到类似的问题类似的问题。



以下链接是示例项目的下载链接,其中包含我的问题:
http: //www.gogofile.com/Default.aspx?p=sc&ID=634818635814123750_4340



更新为9/3 / 12 ,我目前只想联系@riq,这是Cocos2D for iOS的主要创建者。然而在我这样做之前,大家肯定没有办法只有一个CCGLView,我可以在任何UIViewController,因为技术上我不会使用两个视图,它只是一个共享视图之间的控制器。

解决方案

好吧,所以我发现我几乎有 em> @Riq告诉我,对于多个CCDirectors的支持将在2.2版本中发布,所以玩等待游戏,直到2.2 beta出来。 更新 :2.1最后一次已从6月中旬开始,所以我猜测2.2版应该在一两个月内发布。



2。 只有一个UIViewController保存CCGLView。然后无论什么UIViewController我需要glView在我只是使用 addChildViewController (iOS 5+)和我只保留UIViewController保留,当我切换视图,只是做replaceScene在那时间太(也许在UIView动画完成回调)。



/ em>:我已经使用并完全测试这个解决方案,它似乎工作很好。我建议这样做,直到2.2出来。我的应用程式以60FPS执行,看起来不错。



3。拉请求,也没有@Riq所以这将是我的最后一个选项。 http://www.cocos2d-iphone.org/forum/topic/33480 http://www.cocos2d-iphone.org/forum/topic/17821


Note: Anyone who can help me properly fix this completely gets the 100 point bounty!!!

In my application I am mixing UIKit with Cocos2D together, I do some simple custom view animations using addSubview and removeFromSuperview calls. I recently needed to add another CCScene to my app to get rid of some complicated UIKit code that Cocos2D can easily handle. So I have a base view in my app, it is a UIViewController with some buttons on it. Behind those buttons is a CCGLView which Cocos2D will do whatever on. That works great. Then when I want to go to my second view controller (lets call it my game view), after I do my view animations, the viewdidload gets called (thats where my director initialization is for the 2nd CCScene) and either nothing happens or I get errors like below in the console. Now in my original project the errors below are what I get, and in this sample project nothing happens. These are the errors:

OpenGL error 0x0501 in DrawSolidPolygon 104
OpenGL error 0x0502 in DrawSolidPolygon 104
OpenGL error 0x0501 in -[CCTextureAtlas drawNumberOfQuads:fromIndex:] 556
OpenGL error 0x0502 in -[CCTextureAtlas drawNumberOfQuads:fromIndex:] 556
OpenGL error 0x0502 in -[CCTextureAtlas drawNumberOfQuads:fromIndex:] 556
OpenGL error 0x0501 in -[CCParticleSystemQuad postStep] 411
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCParticleSystemQuad draw] 434
OpenGL error 0x0502 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCSprite draw] 532

Now when I had one scene in my original project nothing like this happens, it only happens now that I am using 2 CCScenes. So the code in the sample project is a pretty much copy of my original project so anything wrong in there will most likely lead me to fix the issue at hand here and hopefully get rid of those OpenGL errors.

After a few more hours of testing and gathering information, it seems that my issue is similar to: iOS and multiple OpenGL views. I have also seen this link: http://gamesfromwithin.com/using-multiple-opengl-views-and-uikit. However both of these links do not make any sense to me since I do not know how to relate it to Cocos2D. I think this whole issue is a limitation of the current version of Cocos2D but if someone can download my project and somehow apply these past two links' fixes to my project and fully fix it, that would be great and would fix all of my issues!

Now the version of Cocos2D in my project is the latest available to download for the 2.0 version. If anyone would be nice enough to download the project and see what I am doing wrong I think this will solve the issue for me and others who are experiencing issues similar to mine.

The link below is a download link for the sample project with my issue: http://www.gogofile.com/Default.aspx?p=sc&ID=634818635814123750_4340

Update as of 9/3/12, I am currently thinking just to contact @riq, the main creator behind Cocos2D for iOS. However before I do so, is everyone sure there isn't a way to just have one CCGLView and I can just plop it in any UIViewController because technically I will not be using two views, it will just be one shared view between the controllers. Is this way possible?

解决方案

Okay so I found out that I pretty much have 3 options:

1. @Riq told me that support for multiple CCDirectors is coming in version 2.2 which will be released in May 2013. So play the waiting game until the 2.2 beta comes out. Update: 2.1 final has been out since the middle of June so I would guess that the 2.2 beta should be out within a month or two.

2. Just have one UIViewController that holds the CCGLView. Then whatever UIViewController I need the glView in I would just use addChildViewController (iOS 5+) and I would just keep that UIViewController retained when I am switching views and just do replaceScene at that time too (maybe in the UIView animation completion callback). I think this way would work too but I am not sure of its efficiency.

Edit: I have used and fully tested this solution and it seems to work great. I recommend doing this until 2.2 comes out. My app runs at 60FPS and looks good.

3. I personally have not tried any of these links/pull requests and neither has @Riq so this would be my last option. http://www.cocos2d-iphone.org/forum/topic/33480 AND http://www.cocos2d-iphone.org/forum/topic/17821

这篇关于多个OpenGL视图(Cocos2D)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆