cocos2dx 源码学习3 CCConfiguration

前端之家收集整理的这篇文章主要介绍了cocos2dx 源码学习3 CCConfiguration前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

CCConfiguration对一些配置信息进行设置,在源码中是用字典来存储这些信息的,及key/value的方式。CCConfiguration也提供了很多函数来返回这些信息。其次CCConfiguration被设计成了单例。下面看下CCConfiguration的成员:

protected:
GLint m_nMaxTextureSize;/**OpenGL最大texture尺寸.*/
GLint m_nMaxModelviewStackDepth;/**OpenGL最大ModelviewStackDepth.*/
bool m_bSupportsPVRTC;/**是否支持PVRTexture压缩*/
bool m_bSupportsNPOT;/**GPU(图形处理器)是否支持NPOT(NonPowerOfTwo)textures.
bool m_bSupportsBGRA8888;/**是否支持BGRA8888textures.
bool m_bSupportsDiscardFramebuffer;/**是否支持glDiscardFramebufferEXT
bool m_bSupportsShareableVAO;/**是否支持VAOs(的增值运营与服务)
GLint m_nMaxSamplesAllowed;
GLint m_nMaxTextureUnits;/**returnsthemaximum(最大)textureunits(单元)
char * m_pGlExtensions;

CCDictionary *m_pValueDict;


可以看出m_pValueDict及是用来保存的字典变量。同时可以看到一些这些私有变量的获取方法以及设置方法

/** OpenGL Max texture size. */
int getMaxTextureSize(void) const;

/** OpenGL Max Modelview Stack Depth. */
int getMaxModelviewStackDepth(void) const;

/** returns the maximum texture units*/
int getMaxTextureUnits(void) const;


/** Whether or not the GPU supports NPOT (Non Power Of Two) textures.
OpenGL ES 2.0 already supports NPOT (iOS).*/

bool supportsNPOT(void) const;

/** Whether or not PVR Texture Compressed is supported */
bool supportsPVRTC(void) const;

/** Whether or not BGRA8888 textures are supported.*/
bool supportsBGRA8888(void) const;

/** Whether or not glDiscardFramebufferEXT is supported*/
bool supportsDiscardFramebuffer(void) const;

/** Whether or not shareable VAOs are supported.*/
bool supportsShareableVAO(void) const;

/** returns whether or not an OpenGL is supported */
bool checkForGLExtension(const std::string &searchName) const;

/** returns the value of a given key as a string.If the key is not found,it will return the default value */
const char* getCString( const char *key,const char *default_value=NULL ) const;


/** returns the value of a given key as a boolean.If the key is not found,it will return the default value */
bool getBool( const char *key,bool default_value=false ) const;

/** returns the value of a given key as a double.If the key is not found,it will return the default value */
double getNumber( const char *key,double default_value=0.0 ) const;

/** returns the value of a given key as a double */
CCObject * getObject( const char *key ) const;

/** sets a new key/value pair in the configuration dictionary */
void setObject( const char *key,CCObject *value );

具体可以参考这篇文章:http://blog.csdn.net/runaying/article/details/15026685

猜你在找的Cocos2d-x相关文章