2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
2012-06-12 01:43:07 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2012-04-19 14:35:52 +08:00
|
|
|
Copyright (c) 2010 Ricardo Quesada
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CCCONFIGURATION_H__
|
|
|
|
#define __CCCONFIGURATION_H__
|
|
|
|
|
2012-06-19 13:50:11 +08:00
|
|
|
#include "cocoa/CCObject.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "CCGL.h"
|
2013-05-23 04:00:34 +08:00
|
|
|
#include "cocoa/CCString.h"
|
2012-06-19 13:50:11 +08:00
|
|
|
#include <string>
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-05-23 04:00:34 +08:00
|
|
|
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2013-05-23 04:00:34 +08:00
|
|
|
typedef enum _ccConfigurationType {
|
|
|
|
ConfigurationError,
|
|
|
|
ConfigurationString,
|
|
|
|
ConfigurationInt,
|
|
|
|
ConfigurationDouble,
|
|
|
|
ConfigurationBoolean
|
|
|
|
} ccConfigurationType;
|
|
|
|
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup global
|
|
|
|
* @{
|
|
|
|
*/
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
|
|
|
@brief CCConfiguration contains some openGL variables
|
|
|
|
@since v0.99.0
|
|
|
|
*/
|
|
|
|
class CC_DLL CCConfiguration : public CCObject
|
|
|
|
{
|
2012-04-20 11:39:12 +08:00
|
|
|
public:
|
2012-05-23 12:11:53 +08:00
|
|
|
/** returns a shared instance of CCConfiguration */
|
2012-04-20 11:39:12 +08:00
|
|
|
static CCConfiguration *sharedConfiguration(void);
|
2013-05-23 08:03:00 +08:00
|
|
|
|
2012-05-23 12:11:53 +08:00
|
|
|
/** purge the shared instance of CCConfiguration */
|
|
|
|
static void purgeConfiguration(void);
|
2013-05-23 08:03:00 +08:00
|
|
|
|
|
|
|
public:
|
2013-05-23 04:00:34 +08:00
|
|
|
|
|
|
|
virtual ~CCConfiguration(void);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** OpenGL Max texture size. */
|
2013-05-23 04:00:34 +08:00
|
|
|
int getMaxTextureSize(void) const;
|
|
|
|
|
2012-04-20 11:39:12 +08:00
|
|
|
/** OpenGL Max Modelview Stack Depth. */
|
2013-05-23 04:00:34 +08:00
|
|
|
int getMaxModelviewStackDepth(void) const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-04-20 11:39:12 +08:00
|
|
|
/** returns the maximum texture units
|
|
|
|
@since v2.0.0
|
|
|
|
*/
|
2013-05-23 04:00:34 +08:00
|
|
|
int getMaxTextureUnits(void) const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** Whether or not the GPU supports NPOT (Non Power Of Two) textures.
|
2012-04-20 11:39:12 +08:00
|
|
|
OpenGL ES 2.0 already supports NPOT (iOS).
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
@since v0.99.2
|
|
|
|
*/
|
2013-05-23 04:00:34 +08:00
|
|
|
bool supportsNPOT(void) const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** Whether or not PVR Texture Compressed is supported */
|
2013-05-23 04:00:34 +08:00
|
|
|
bool supportsPVRTC(void) const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** Whether or not BGRA8888 textures are supported.
|
|
|
|
@since v0.99.2
|
|
|
|
*/
|
2013-05-23 04:00:34 +08:00
|
|
|
bool supportsBGRA8888(void) const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** Whether or not glDiscardFramebufferEXT is supported
|
|
|
|
@since v0.99.2
|
|
|
|
*/
|
2013-05-23 04:00:34 +08:00
|
|
|
bool supportsDiscardFramebuffer(void) const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-14 05:26:28 +08:00
|
|
|
/** Whether or not shareable VAOs are supported.
|
|
|
|
@since v2.0.0
|
2012-06-12 01:43:07 +08:00
|
|
|
*/
|
2013-05-23 04:00:34 +08:00
|
|
|
bool supportsShareableVAO(void) const;
|
2012-06-12 01:43:07 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** returns whether or not an OpenGL is supported */
|
2013-05-23 04:00:34 +08:00
|
|
|
bool checkForGLExtension(const std::string &searchName) const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
bool init(void);
|
|
|
|
|
2013-05-23 04:00:34 +08:00
|
|
|
/** returns the value of a given key as a string */
|
|
|
|
const char* getCString( const char *key ) const;
|
|
|
|
|
|
|
|
/** returns the value of a given key as a boolean */
|
|
|
|
bool getBool( const char *key ) const;
|
|
|
|
|
|
|
|
/** returns the value of a given key as a double */
|
|
|
|
double getNumber( const char *key ) const;
|
|
|
|
|
|
|
|
/** returns the value of a given key as a double */
|
|
|
|
CCObject * getObject( const char *key ) const;
|
|
|
|
|
|
|
|
/** dumps the current configuration on the console */
|
|
|
|
void dumpInfo(void) const;
|
|
|
|
|
|
|
|
/** gathers OpenGL / GPU information */
|
|
|
|
void gatherGPUInfo( void );
|
|
|
|
|
2013-05-23 08:03:00 +08:00
|
|
|
/** Loads a config file. If the keys are already present, then they are going to be replaced. Otherwise the new keys are added. */
|
|
|
|
void loadConfigFile( const char *filename );
|
|
|
|
|
2012-04-20 11:39:12 +08:00
|
|
|
private:
|
|
|
|
CCConfiguration(void);
|
|
|
|
static CCConfiguration *s_gSharedConfiguration;
|
2013-05-23 08:03:00 +08:00
|
|
|
static std::string s_sConfigfile;
|
2012-04-20 11:39:12 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
GLint m_nMaxTextureSize;
|
|
|
|
GLint m_nMaxModelviewStackDepth;
|
|
|
|
bool m_bSupportsPVRTC;
|
|
|
|
bool m_bSupportsNPOT;
|
|
|
|
bool m_bSupportsBGRA8888;
|
|
|
|
bool m_bSupportsDiscardFramebuffer;
|
2012-06-12 01:43:07 +08:00
|
|
|
bool m_bSupportsShareableVAO;
|
2012-04-20 11:39:12 +08:00
|
|
|
GLint m_nMaxSamplesAllowed;
|
|
|
|
GLint m_nMaxTextureUnits;
|
|
|
|
char * m_pGlExtensions;
|
2013-05-23 04:00:34 +08:00
|
|
|
CCDictionary *m_pDefaults;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of global group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif // __CCCONFIGURATION_H__
|