axmol/cocos/base/CCConfiguration.h

273 lines
7.7 KiB
C
Raw Normal View History

/****************************************************************************
Copyright (c) 2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
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__
2014-09-10 07:50:02 +08:00
#include <string>
#include "base/CCRef.h"
2014-04-27 01:35:57 +08:00
#include "base/CCValue.h"
2014-09-10 07:50:02 +08:00
#include "platform/CCGL.h"
2015-04-24 11:49:28 +08:00
#include "3d/CCAnimate3D.h"
2012-06-20 18:09:11 +08:00
/**
2015-03-24 18:22:52 +08:00
* @addtogroup base
2012-06-20 18:09:11 +08:00
* @{
*/
2015-03-27 12:01:20 +08:00
NS_CC_BEGIN
2015-07-24 16:38:30 +08:00
class EventCustom;
/** @class Configuration
* @brief Configuration contains some openGL variables
* @since v0.99.0
* @js NA
*/
class CC_DLL Configuration : public Ref
{
public:
/** Returns a shared instance of Configuration.
*
* @return An autoreleased Configuration object.
*/
static Configuration *getInstance();
/** Purge the shared instance of Configuration.
*/
static void destroyInstance();
/** @deprecated Use getInstance() instead */
2013-08-08 16:31:44 +08:00
CC_DEPRECATED_ATTRIBUTE static Configuration *sharedConfiguration();
/** @deprecated Use destroyInstance() instead */
2013-08-08 16:31:44 +08:00
CC_DEPRECATED_ATTRIBUTE static void purgeConfiguration();
public:
/** Destructor
* @js NA
* @lua NA
*/
2013-08-08 16:31:44 +08:00
virtual ~Configuration();
/** OpenGL Max texture size.
*
* @return The OpenGL Max texture size.
*/
2013-08-08 16:31:44 +08:00
int getMaxTextureSize() const;
/** OpenGL Max Modelview Stack Depth.
*
* @return The OpenGL Max Modelview Stack Depth.
*/
2013-08-08 16:31:44 +08:00
int getMaxModelviewStackDepth() const;
/** Returns the maximum texture units.
*
* @return The maximum texture units.
* @since v2.0.0
*/
2013-08-08 16:31:44 +08:00
int getMaxTextureUnits() const;
/** Whether or not the GPU supports NPOT (Non Power Of Two) textures.
OpenGL ES 2.0 already supports NPOT (iOS).
*
* @return Is true if supports NPOT.
* @since v0.99.2
*/
2013-08-08 16:31:44 +08:00
bool supportsNPOT() const;
/** Whether or not PVR Texture Compressed is supported.
*
* @return Is true if supports PVR Texture Compressed.
*/
2013-08-08 16:31:44 +08:00
bool supportsPVRTC() const;
/** Whether or not ETC Texture Compressed is supported.
*
*
* @return Is true if supports ETC Texture Compressed.
*/
2013-08-08 16:31:44 +08:00
bool supportsETC() const;
/** Whether or not S3TC Texture Compressed is supported.
*
* @return Is true if supports S3TC Texture Compressed.
*/
bool supportsS3TC() const;
/** Whether or not ATITC Texture Compressed is supported.
*
* @return Is true if supports ATITC Texture Compressed.
*/
bool supportsATITC() const;
2013-08-06 11:19:45 +08:00
/** Whether or not BGRA8888 textures are supported.
*
* @return Is true if supports BGRA8888 textures.
* @since v0.99.2
*/
2013-08-08 16:31:44 +08:00
bool supportsBGRA8888() const;
/** Whether or not glDiscardFramebufferEXT is supported.
* @return Is true if supports glDiscardFramebufferEXT.
* @since v0.99.2
*/
2013-08-08 16:31:44 +08:00
bool supportsDiscardFramebuffer() const;
/** Whether or not shareable VAOs are supported.
*
* @return Is true if supports shareable VAOs.
* @since v2.0.0
2012-06-12 01:43:07 +08:00
*/
2013-08-08 16:31:44 +08:00
bool supportsShareableVAO() const;
2015-12-17 14:40:16 +08:00
/** Whether or not OES_depth24 is supported.
*
* @return Is true if supports OES_depth24.
* @since v2.0.0
*/
bool supportsOESDepth24() const;
/** Whether or not OES_Packed_depth_stencil is supported.
*
* @return Is true if supports OES_Packed_depth_stencil.
* @since v2.0.0
*/
bool supportsOESPackedDepthStencil() const;
/** Max support directional light in shader, for Sprite3D.
*
* @return Maximum supports directional light in shader.
* @since v3.3
*/
int getMaxSupportDirLightInShader() const;
/** Max support point light in shader, for Sprite3D.
*
* @return Maximum supports point light in shader.
* @since v3.3
*/
int getMaxSupportPointLightInShader() const;
/** Max support spot light in shader, for Sprite3D.
*
* @return Maximum supports spot light in shader.
* @since v3.3
*/
int getMaxSupportSpotLightInShader() const;
2012-06-12 01:43:07 +08:00
2015-04-24 11:49:28 +08:00
/** get 3d animate quality*/
Animate3DQuality getAnimate3DQuality() const;
2015-03-26 11:30:22 +08:00
/** Returns whether or not an OpenGL is supported.
*
* @param searchName A given search name.
* @return Is true if an OpenGL is supported.
*/
bool checkForGLExtension(const std::string &searchName) const;
/** Initialize method.
*
* @return Is true if initialize success.
*/
2013-08-08 16:31:44 +08:00
bool init();
/** Returns the value of a given key as a double.
*
* @param key A given key.
* @param defaultValue if not find the value, return the defaultValue.
* @return
*/
const Value& getValue(const std::string& key, const Value& defaultValue = Value::Null) const;
/** Sets a new key/value pair in the configuration dictionary.
*
* @param key A given key.
* @param value A given value.
*/
void setValue(const std::string& key, const Value& value);
/** Returns the Configuration info.
*
* @return The Configuration info.
*/
std::string getInfo() const;
/** Gathers OpenGL / GPU information.
*/
2013-08-08 16:31:44 +08:00
void gatherGPUInfo();
/** Loads a config file. If the keys are already present, then they are going to be replaced. Otherwise the new keys are added.
*
* @param filename Config file name.
*/
void loadConfigFile(const std::string& filename);
2015-07-24 16:38:30 +08:00
static const char* CONFIG_FILE_LOADED;
private:
Configuration(void);
2013-08-08 16:31:44 +08:00
static Configuration *s_sharedConfiguration;
static std::string s_configfile;
protected:
GLint _maxTextureSize;
GLint _maxModelviewStackDepth;
bool _supportsPVRTC;
bool _supportsETC1;
2013-08-06 11:19:45 +08:00
bool _supportsS3TC;
bool _supportsATITC;
bool _supportsNPOT;
bool _supportsBGRA8888;
bool _supportsDiscardFramebuffer;
bool _supportsShareableVAO;
2015-12-17 14:40:16 +08:00
bool _supportsOESDepth24;
bool _supportsOESPackedDepthStencil;
GLint _maxSamplesAllowed;
GLint _maxTextureUnits;
char * _glExtensions;
int _maxDirLightInShader; //max support directional light in shader
int _maxPointLightInShader; // max support point light in shader
int _maxSpotLightInShader; // max support spot light in shader
2015-04-24 11:49:28 +08:00
Animate3DQuality _animate3DQuality; // animate 3d quality
ValueMap _valueDict;
2015-07-24 16:38:30 +08:00
EventCustom* _loadedEvent;
};
2012-06-20 18:09:11 +08:00
NS_CC_END
2015-03-27 12:01:20 +08:00
// end of base group
/// @}
#endif // __CCCONFIGURATION_H__