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
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup global
|
|
|
|
* @{
|
|
|
|
*/
|
2012-04-19 14:35:52 +08:00
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
@brief Configuration contains some openGL variables
|
2012-04-19 14:35:52 +08:00
|
|
|
@since v0.99.0
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL Configuration : public Object
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-04-20 11:39:12 +08:00
|
|
|
public:
|
2013-07-25 14:47:12 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** returns a shared instance of Configuration */
|
2013-07-12 06:24:23 +08:00
|
|
|
static Configuration *getInstance();
|
2013-05-23 08:03:00 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** purge the shared instance of Configuration */
|
2013-07-12 06:24:23 +08:00
|
|
|
static void destroyInstance();
|
|
|
|
|
|
|
|
/** @deprecated Use getInstance() instead */
|
2013-08-08 16:31:44 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static Configuration *sharedConfiguration();
|
2013-07-12 06:24:23 +08:00
|
|
|
|
|
|
|
/** @deprecated Use destroyInstance() instead */
|
2013-08-08 16:31:44 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static void purgeConfiguration();
|
2013-05-23 08:03:00 +08:00
|
|
|
|
|
|
|
public:
|
2013-05-23 04:00:34 +08:00
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
virtual ~Configuration();
|
2013-05-23 04:00:34 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** OpenGL Max texture size. */
|
2013-08-08 16:31:44 +08:00
|
|
|
int getMaxTextureSize() const;
|
2013-05-23 04:00:34 +08:00
|
|
|
|
2012-04-20 11:39:12 +08:00
|
|
|
/** OpenGL Max Modelview Stack Depth. */
|
2013-08-08 16:31:44 +08:00
|
|
|
int getMaxModelviewStackDepth() 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-08-08 16:31:44 +08:00
|
|
|
int getMaxTextureUnits() 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-08-08 16:31:44 +08:00
|
|
|
bool supportsNPOT() const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** Whether or not PVR Texture Compressed is supported */
|
2013-08-08 16:31:44 +08:00
|
|
|
bool supportsPVRTC() const;
|
2013-07-01 17:40:57 +08:00
|
|
|
|
|
|
|
/** Whether or not ETC Texture Compressed is supported */
|
2013-08-08 16:31:44 +08:00
|
|
|
bool supportsETC() const;
|
2013-07-01 17:40:57 +08:00
|
|
|
|
2013-08-06 11:19:45 +08:00
|
|
|
/** Whether or not S3TC Texture Compressed is supported */
|
2013-08-16 11:02:44 +08:00
|
|
|
bool supportsS3TC() const;
|
|
|
|
|
|
|
|
/** Whether or not ATITC Texture Compressed is supported */
|
|
|
|
bool supportsATITC() const;
|
2013-08-06 11:19:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Whether or not BGRA8888 textures are supported.
|
|
|
|
@since v0.99.2
|
|
|
|
*/
|
2013-08-08 16:31:44 +08:00
|
|
|
bool supportsBGRA8888() const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
/** Whether or not glDiscardFramebufferEXT is supported
|
|
|
|
@since v0.99.2
|
|
|
|
*/
|
2013-08-08 16:31:44 +08:00
|
|
|
bool supportsDiscardFramebuffer() 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-08-08 16:31:44 +08:00
|
|
|
bool supportsShareableVAO() 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
|
|
|
|
2013-08-08 16:31:44 +08:00
|
|
|
bool init();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-05-31 07:10:31 +08:00
|
|
|
/** returns the value of a given key as a string.
|
|
|
|
If the key is not found, it will return the default value */
|
2013-08-08 16:31:44 +08:00
|
|
|
const char* getCString(const char *key, const char *defaultValue = nullptr) const;
|
2013-05-23 04:00:34 +08:00
|
|
|
|
2013-05-31 07:10:31 +08:00
|
|
|
/** returns the value of a given key as a boolean.
|
|
|
|
If the key is not found, it will return the default value */
|
2013-08-08 16:31:44 +08:00
|
|
|
bool getBool(const char *key, bool defaultValue = false) const;
|
2013-05-23 04:00:34 +08:00
|
|
|
|
2013-05-31 07:10:31 +08:00
|
|
|
/** returns the value of a given key as a double.
|
|
|
|
If the key is not found, it will return the default value */
|
2013-08-08 16:31:44 +08:00
|
|
|
double getNumber(const char *key, double defaultValue = 0.0) const;
|
2013-05-23 04:00:34 +08:00
|
|
|
|
|
|
|
/** returns the value of a given key as a double */
|
2013-08-08 16:31:44 +08:00
|
|
|
Object * getObject(const char *key) const;
|
2013-05-23 04:00:34 +08:00
|
|
|
|
2013-06-04 04:49:06 +08:00
|
|
|
/** sets a new key/value pair in the configuration dictionary */
|
2013-08-08 16:31:44 +08:00
|
|
|
void setObject(const char *key, Object *value);
|
2013-06-04 04:49:06 +08:00
|
|
|
|
2013-05-23 04:00:34 +08:00
|
|
|
/** dumps the current configuration on the console */
|
2013-08-08 16:31:44 +08:00
|
|
|
void dumpInfo() const;
|
2013-05-23 04:00:34 +08:00
|
|
|
|
|
|
|
/** gathers OpenGL / GPU information */
|
2013-08-08 16:31:44 +08:00
|
|
|
void gatherGPUInfo();
|
2013-05-23 04:00:34 +08:00
|
|
|
|
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. */
|
2013-08-08 16:31:44 +08:00
|
|
|
void loadConfigFile(const char *filename);
|
2013-05-23 08:03:00 +08:00
|
|
|
|
2012-04-20 11:39:12 +08:00
|
|
|
private:
|
2013-06-20 14:13:12 +08:00
|
|
|
Configuration(void);
|
2013-08-08 16:31:44 +08:00
|
|
|
static Configuration *s_sharedConfiguration;
|
|
|
|
static std::string s_configfile;
|
2012-04-20 11:39:12 +08:00
|
|
|
|
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
GLint _maxTextureSize;
|
|
|
|
GLint _maxModelviewStackDepth;
|
|
|
|
bool _supportsPVRTC;
|
2013-07-01 17:40:57 +08:00
|
|
|
bool _supportsETC;
|
2013-08-06 11:19:45 +08:00
|
|
|
bool _supportsS3TC;
|
2013-08-16 11:02:44 +08:00
|
|
|
bool _supportsATITC;
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _supportsNPOT;
|
|
|
|
bool _supportsBGRA8888;
|
|
|
|
bool _supportsDiscardFramebuffer;
|
|
|
|
bool _supportsShareableVAO;
|
|
|
|
GLint _maxSamplesAllowed;
|
|
|
|
GLint _maxTextureUnits;
|
|
|
|
char * _glExtensions;
|
2013-06-04 04:49:06 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Dictionary *_valueDict;
|
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__
|