2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 Ricardo Quesada
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2022-07-09 01:23:11 +08:00
|
|
|
https://axis-project.github.io/
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
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>
|
|
|
|
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "base/CCRef.h"
|
2014-04-27 01:35:57 +08:00
|
|
|
#include "base/CCValue.h"
|
2015-04-24 11:49:28 +08:00
|
|
|
#include "3d/CCAnimate3D.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
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
|
|
|
* @{
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2015-03-27 12:01:20 +08:00
|
|
|
|
2015-07-24 16:38:30 +08:00
|
|
|
class EventCustom;
|
|
|
|
|
2015-03-19 21:32:19 +08:00
|
|
|
/** @class Configuration
|
|
|
|
* @brief Configuration contains some openGL variables
|
|
|
|
* @since v0.99.0
|
2015-03-23 20:27:13 +08:00
|
|
|
* @js NA
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
class AX_DLL Configuration : public Ref
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-04-20 11:39:12 +08:00
|
|
|
public:
|
2015-03-19 21:32:19 +08:00
|
|
|
/** Returns a shared instance of Configuration.
|
2021-12-25 10:04:45 +08:00
|
|
|
*
|
2015-03-19 21:32:19 +08:00
|
|
|
* @return An autoreleased Configuration object.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
static Configuration* getInstance();
|
2013-05-23 08:03:00 +08:00
|
|
|
|
2015-03-19 21:32:19 +08:00
|
|
|
/** Purge the shared instance of Configuration.
|
|
|
|
*/
|
2013-07-12 06:24:23 +08:00
|
|
|
static void destroyInstance();
|
|
|
|
|
2013-05-23 08:03:00 +08:00
|
|
|
public:
|
2015-03-19 21:32:19 +08:00
|
|
|
/** Destructor
|
2013-09-13 13:52:42 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual ~Configuration();
|
2013-05-23 04:00:34 +08:00
|
|
|
|
2015-03-19 21:32:19 +08:00
|
|
|
/** OpenGL Max texture size.
|
2021-12-25 10:04:45 +08:00
|
|
|
*
|
2015-03-19 21:32:19 +08:00
|
|
|
* @return The OpenGL Max texture size.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
int getMaxTextureSize() const;
|
2013-05-23 04:00:34 +08:00
|
|
|
|
2015-03-19 21:32:19 +08:00
|
|
|
/** OpenGL Max Modelview Stack Depth.
|
|
|
|
*
|
|
|
|
* @return The OpenGL Max Modelview Stack Depth.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
int getMaxModelviewStackDepth() const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-19 21:32:19 +08:00
|
|
|
/** Returns the maximum texture units.
|
|
|
|
*
|
|
|
|
* @return The maximum texture units.
|
|
|
|
* @since v2.0.0
|
2012-04-20 11:39:12 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +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).
|
2021-12-25 10:04:45 +08:00
|
|
|
*
|
2015-03-19 21:32:19 +08:00
|
|
|
* @return Is true if supports NPOT.
|
|
|
|
* @since v0.99.2
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
bool supportsNPOT() const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-19 21:32:19 +08:00
|
|
|
/** Whether or not PVR Texture Compressed is supported.
|
|
|
|
*
|
|
|
|
* @return Is true if supports PVR Texture Compressed.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
bool supportsPVRTC() const;
|
|
|
|
|
2020-09-01 11:43:03 +08:00
|
|
|
/** Whether or not ETC1 Texture Compressed is supported.
|
2021-12-25 10:04:45 +08:00
|
|
|
*
|
2015-03-19 21:32:19 +08:00
|
|
|
*
|
2020-09-01 11:43:03 +08:00
|
|
|
* @return Is true if supports ETC1 Texture Compressed.
|
2015-03-19 21:32:19 +08:00
|
|
|
*/
|
2020-09-01 11:43:03 +08:00
|
|
|
bool supportsETC1() const;
|
2020-08-30 17:58:39 +08:00
|
|
|
|
|
|
|
/** Whether or not ETC2 Texture Compressed is supported.
|
|
|
|
*
|
|
|
|
*
|
2020-09-01 11:43:03 +08:00
|
|
|
* @return Is true if supports ETC2 Texture Compressed.
|
2020-08-30 17:58:39 +08:00
|
|
|
*/
|
|
|
|
bool supportsETC2() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-19 21:32:19 +08:00
|
|
|
/** Whether or not S3TC Texture Compressed is supported.
|
|
|
|
*
|
|
|
|
* @return Is true if supports S3TC Texture Compressed.
|
|
|
|
*/
|
2013-08-16 11:02:44 +08:00
|
|
|
bool supportsS3TC() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-19 21:32:19 +08:00
|
|
|
/** Whether or not ATITC Texture Compressed is supported.
|
|
|
|
*
|
|
|
|
* @return Is true if supports ATITC Texture Compressed.
|
|
|
|
*/
|
2013-08-16 11:02:44 +08:00
|
|
|
bool supportsATITC() const;
|
2020-02-05 22:45:19 +08:00
|
|
|
|
|
|
|
/** Whether or not ASTC Texture Compressed is supported.
|
|
|
|
*
|
|
|
|
* @return Is true if supports ASTC Texture Compressed.
|
|
|
|
*/
|
|
|
|
bool supportsASTC() const;
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
/** Whether or not BGRA8888 textures are supported.
|
2015-03-19 21:32:19 +08:00
|
|
|
*
|
|
|
|
* @return Is true if supports BGRA8888 textures.
|
|
|
|
* @since v0.99.2
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
bool supportsBGRA8888() const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-19 21:32:19 +08:00
|
|
|
/** Whether or not glDiscardFramebufferEXT is supported.
|
|
|
|
* @return Is true if supports glDiscardFramebufferEXT.
|
|
|
|
* @since v0.99.2
|
2012-04-19 14:35:52 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +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.
|
2015-03-19 21:32:19 +08:00
|
|
|
*
|
|
|
|
* @return Is true if supports shareable VAOs.
|
|
|
|
* @since v2.0.0
|
2012-06-12 01:43:07 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +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;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-12-17 14:40:16 +08:00
|
|
|
/** 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;
|
|
|
|
|
2016-07-15 07:45:04 +08:00
|
|
|
/** Whether or not glMapBuffer() is supported.
|
|
|
|
*
|
|
|
|
* On Desktop it returns `true`.
|
|
|
|
* On Mobile it checks for the extension `GL_OES_mapbuffer`
|
|
|
|
*
|
|
|
|
* @return Whether or not `glMapBuffer()` is supported.
|
|
|
|
* @since v3.13
|
|
|
|
*/
|
|
|
|
bool supportsMapBuffer() const;
|
|
|
|
|
2022-07-05 14:48:46 +08:00
|
|
|
/** Max supported directional lights in a shader, for MeshRenderer.
|
2015-03-19 21:32:19 +08:00
|
|
|
*
|
2022-07-05 14:48:46 +08:00
|
|
|
* @return Maximum supported directional lights in a shader.
|
2015-03-19 21:32:19 +08:00
|
|
|
* @since v3.3
|
2014-09-25 15:29:32 +08:00
|
|
|
*/
|
|
|
|
int getMaxSupportDirLightInShader() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-05 14:48:46 +08:00
|
|
|
/** Max supported point lights in a shader, for MeshRenderer.
|
2015-03-19 21:32:19 +08:00
|
|
|
*
|
2022-07-05 14:48:46 +08:00
|
|
|
* @return Maximum supported point lights in a shader.
|
2015-03-19 21:32:19 +08:00
|
|
|
* @since v3.3
|
2014-09-25 15:29:32 +08:00
|
|
|
*/
|
|
|
|
int getMaxSupportPointLightInShader() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-05 14:48:46 +08:00
|
|
|
/** Max supported spot lights in a shader, for MeshRenderer.
|
2015-03-19 21:32:19 +08:00
|
|
|
*
|
2022-07-05 14:48:46 +08:00
|
|
|
* @return Maximum supported spot lights in a shader.
|
2015-03-19 21:32:19 +08:00
|
|
|
* @since v3.3
|
2014-09-25 15:29:32 +08:00
|
|
|
*/
|
|
|
|
int getMaxSupportSpotLightInShader() const;
|
2012-06-12 01:43:07 +08:00
|
|
|
|
2022-07-05 14:48:46 +08:00
|
|
|
/** get 3d animate quality */
|
2015-04-24 11:49:28 +08:00
|
|
|
Animate3DQuality getAnimate3DQuality() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-05 14:48:46 +08:00
|
|
|
/** Returns whether or not an OpenGL extension is supported.
|
2015-03-19 21:32:19 +08:00
|
|
|
*
|
|
|
|
* @param searchName A given search name.
|
2022-07-05 14:48:46 +08:00
|
|
|
* @return Is true if an OpenGL extension is supported.
|
2015-03-19 21:32:19 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
bool checkForGLExtension(std::string_view searchName) const;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-03-19 21:32:19 +08:00
|
|
|
/** Initialize method.
|
|
|
|
*
|
|
|
|
* @return Is true if initialize success.
|
|
|
|
*/
|
2013-08-08 16:31:44 +08:00
|
|
|
bool init();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Returns the value of a given key as a double.
|
2015-03-19 21:32:19 +08:00
|
|
|
*
|
|
|
|
* @param key A given key.
|
|
|
|
* @param defaultValue if not find the value, return the defaultValue.
|
2021-12-25 10:04:45 +08:00
|
|
|
* @return
|
2015-03-19 21:32:19 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
const Value& getValue(std::string_view key, const Value& defaultValue = Value::Null) const;
|
2013-05-23 04:00:34 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Sets a new key/value pair in the configuration dictionary.
|
2015-03-19 21:32:19 +08:00
|
|
|
*
|
|
|
|
* @param key A given key.
|
|
|
|
* @param value A given value.
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void setValue(std::string_view key, const Value& value);
|
2013-06-04 04:49:06 +08:00
|
|
|
|
2015-03-19 21:32:19 +08:00
|
|
|
/** Returns the Configuration info.
|
|
|
|
*
|
|
|
|
* @return The Configuration info.
|
|
|
|
*/
|
2014-01-15 09:22:45 +08:00
|
|
|
std::string getInfo() const;
|
2013-05-23 04:00:34 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Gathers OpenGL / GPU information.
|
2015-03-19 21:32:19 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void gatherGPUInfo();
|
2013-05-23 04:00:34 +08:00
|
|
|
|
2021-12-25 10:04:45 +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.
|
|
|
|
*
|
2015-03-19 21:32:19 +08:00
|
|
|
* @param filename Config file name.
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
void loadConfigFile(std::string_view filename);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-07-24 16:38:30 +08:00
|
|
|
static const char* CONFIG_FILE_LOADED;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-16 09:26:00 +08:00
|
|
|
int getMaxAttributes() const;
|
2013-05-23 08:03:00 +08:00
|
|
|
|
2012-04-20 11:39:12 +08:00
|
|
|
private:
|
2019-07-22 09:38:46 +08:00
|
|
|
Configuration();
|
2021-12-25 10:04:45 +08:00
|
|
|
static Configuration* s_sharedConfiguration;
|
|
|
|
static std::string s_configfile;
|
|
|
|
|
2012-04-20 11:39:12 +08:00
|
|
|
protected:
|
2021-12-25 10:04:45 +08:00
|
|
|
int _maxModelviewStackDepth;
|
|
|
|
bool _supportsPVRTC;
|
|
|
|
bool _supportsETC1;
|
|
|
|
bool _supportsETC2;
|
|
|
|
bool _supportsS3TC;
|
|
|
|
bool _supportsATITC;
|
|
|
|
bool _supportsASTC;
|
|
|
|
bool _supportsNPOT;
|
|
|
|
bool _supportsBGRA8888;
|
|
|
|
bool _supportsDiscardFramebuffer;
|
|
|
|
bool _supportsShareableVAO;
|
|
|
|
bool _supportsOESMapBuffer;
|
|
|
|
bool _supportsOESDepth24;
|
|
|
|
bool _supportsOESPackedDepthStencil;
|
|
|
|
|
|
|
|
std::string _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
|
|
|
|
Animate3DQuality _animate3DQuality; // animate 3d quality
|
|
|
|
|
|
|
|
ValueMap _valueDict;
|
|
|
|
|
|
|
|
EventCustom* _loadedEvent;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_END
|
2015-03-27 12:01:20 +08:00
|
|
|
// end of base group
|
|
|
|
/// @}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
#endif // __CCCONFIGURATION_H__
|