CCConfiguration.h
7.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/****************************************************************************
Copyright (c) 2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
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__
#include <string>
#include "base/CCRef.h"
#include "base/CCValue.h"
#include "3d/CCAnimate3D.h"
/**
* @addtogroup base
* @{
*/
NS_CC_BEGIN
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();
public:
/** Destructor
* @js NA
* @lua NA
*/
virtual ~Configuration();
/** OpenGL Max texture size.
*
* @return The OpenGL Max texture size.
*/
int getMaxTextureSize() const;
/** OpenGL Max Modelview Stack Depth.
*
* @return The OpenGL Max Modelview Stack Depth.
*/
int getMaxModelviewStackDepth() const;
/** Returns the maximum texture units.
*
* @return The maximum texture units.
* @since v2.0.0
*/
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
*/
bool supportsNPOT() const;
/** Whether or not PVR Texture Compressed is supported.
*
* @return Is true if supports PVR Texture Compressed.
*/
bool supportsPVRTC() const;
/** Whether or not ETC Texture Compressed is supported.
*
*
* @return Is true if supports ETC Texture Compressed.
*/
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;
/** Whether or not BGRA8888 textures are supported.
*
* @return Is true if supports BGRA8888 textures.
* @since v0.99.2
*/
bool supportsBGRA8888() const;
/** Whether or not glDiscardFramebufferEXT is supported.
* @return Is true if supports glDiscardFramebufferEXT.
* @since v0.99.2
*/
bool supportsDiscardFramebuffer() const;
/** Whether or not shareable VAOs are supported.
*
* @return Is true if supports shareable VAOs.
* @since v2.0.0
*/
bool supportsShareableVAO() const;
/** 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;
/** 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;
/** 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;
/** get 3d animate quality*/
Animate3DQuality getAnimate3DQuality() const;
/** 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.
*/
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.
*/
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);
static const char* CONFIG_FILE_LOADED;
int getMaxAttributes() const;
private:
Configuration();
static Configuration *s_sharedConfiguration;
static std::string s_configfile;
protected:
int _maxModelviewStackDepth;
bool _supportsPVRTC;
bool _supportsETC1;
bool _supportsS3TC;
bool _supportsATITC;
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;
};
NS_CC_END
// end of base group
/// @}
#endif // __CCCONFIGURATION_H__