Cocos2d 2.0:CC_ENABLE_GL_STATE_CACHE的含义和用法

时间:2013-04-02 15:58:22

标签: ios opengl-es cocos2d-iphone memcached

我想知道我should何时启用 CC_ENABLE_GL_STATE_CACHE 以及使用此功能的限制。我发现一些posts表明在某些具有某些OpenGL操作的设备上存在潜在问题

编辑:这是我从配置文件中读取的内容。保持这种禁用的主要原因是我使用的是使用OpenGL 1.x ES函数的先前代码,因此,从头开始使用OpenGL 2.0 ES我应该没问题。

/** @def CC_ENABLE_GL_STATE_CACHE
 If enabled, cocos2d will maintain an OpenGL state cache internally to avoid unnecessary switches.
 In order to use them, you have to use the following functions, insead of the the GL ones:
    - ccGLUseProgram() instead of glUseProgram()
    - ccGLDeleteProgram() instead of glDeleteProgram()
    - ccGLBlendFunc() instead of glBlendFunc()

 If this functionality is disabled, then ccGLUseProgram(), ccGLDeleteProgram(), ccGLBlendFunc() will call the GL ones, without using the cache.

 It is recommened to enable it whenever possible to improve speed.
 If you are migrating your code from GL ES 1.1, then keep it disabled. Once all your code works as expected, turn it on.

 Default value: Disabled by default

 @since v2.0.0
 */

1 个答案:

答案 0 :(得分:2)

默认情况下应该启用它。

我知道默认情况下它没有打开的唯一原因就是你所说的:向后兼容性。但由于你不应该在cocos2d 2.0中使用GL ES 1.1函数,这可能只适用于那些从cocos2d 1.x升级到2.x并逐渐将其GL ES 1.1代码迁移到2.0的人 - 尽管你必须改变大多数,如果不是所有自定义GL代码,无论如何都是这种情况。

我从2012年10月开始在KoboldTouch中启用了状态缓存(在KT发布之前)并且它没有给我带来任何问题,也没有任何与KT合作的人报告与状态缓存有关的问题。 / p>