2019-11-23 20:27:39 +08:00
|
|
|
/****************************************************************************
|
|
|
|
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.
|
2021-06-10 16:51:30 +08:00
|
|
|
Copyright (c) 2020-2021 c4games.com
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "base/CCConfiguration.h"
|
|
|
|
#include "platform/CCFileUtils.h"
|
|
|
|
#include "base/CCEventCustom.h"
|
|
|
|
#include "base/CCDirector.h"
|
|
|
|
#include "base/CCEventDispatcher.h"
|
|
|
|
#include "renderer/backend/Device.h"
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2021-10-25 20:29:40 +08:00
|
|
|
extern const char* adxeVersion();
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
Configuration* Configuration::s_sharedConfiguration = nullptr;
|
|
|
|
|
|
|
|
const char* Configuration::CONFIG_FILE_LOADED = "config_file_loaded";
|
|
|
|
|
|
|
|
Configuration::Configuration()
|
2021-12-25 10:04:45 +08:00
|
|
|
: _maxModelviewStackDepth(0)
|
|
|
|
, _supportsPVRTC(false)
|
|
|
|
, _supportsETC1(false)
|
|
|
|
, _supportsETC2(false)
|
|
|
|
, _supportsS3TC(false)
|
|
|
|
, _supportsATITC(false)
|
|
|
|
, _supportsASTC(false)
|
|
|
|
, _supportsNPOT(false)
|
|
|
|
, _supportsBGRA8888(false)
|
|
|
|
, _supportsDiscardFramebuffer(false)
|
|
|
|
, _supportsShareableVAO(false)
|
|
|
|
, _supportsOESMapBuffer(false)
|
|
|
|
, _supportsOESDepth24(false)
|
|
|
|
, _supportsOESPackedDepthStencil(false)
|
|
|
|
, _maxDirLightInShader(1)
|
|
|
|
, _maxPointLightInShader(1)
|
|
|
|
, _maxSpotLightInShader(1)
|
|
|
|
, _animate3DQuality(Animate3DQuality::QUALITY_LOW)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
_loadedEvent = new EventCustom(CONFIG_FILE_LOADED);
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Configuration::init()
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
_valueDict["adxe.version"] = Value(adxeVersion());
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
#if CC_ENABLE_PROFILERS
|
2021-12-25 10:04:45 +08:00
|
|
|
_valueDict["adxe.compiled_with_profiler"] = Value(true);
|
2019-11-23 20:27:39 +08:00
|
|
|
#else
|
2021-12-25 10:04:45 +08:00
|
|
|
_valueDict["adxe.compiled_with_profiler"] = Value(false);
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CC_ENABLE_GL_STATE_CACHE == 0
|
2021-12-25 10:04:45 +08:00
|
|
|
_valueDict["adxe.compiled_with_gl_state_cache"] = Value(false);
|
2019-11-23 20:27:39 +08:00
|
|
|
#else
|
2021-05-18 16:40:30 +08:00
|
|
|
_valueDict["adxe.compiled_with_gl_state_cache"] = Value(true);
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG
|
2021-12-25 10:04:45 +08:00
|
|
|
_valueDict["adxe.build_type"] = Value("DEBUG");
|
2019-11-23 20:27:39 +08:00
|
|
|
#else
|
2021-12-25 10:04:45 +08:00
|
|
|
_valueDict["adxe.build_type"] = Value("RELEASE");
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
return true;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Configuration::~Configuration()
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(_loadedEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Configuration::getInfo() const
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
// And Dump some warnings as well
|
2019-11-23 20:27:39 +08:00
|
|
|
#if CC_ENABLE_PROFILERS
|
2021-12-25 10:04:45 +08:00
|
|
|
CCLOG(
|
|
|
|
"cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from "
|
|
|
|
"ccConfig.h)\n");
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CC_ENABLE_GL_STATE_CACHE == 0
|
2021-12-25 10:04:45 +08:00
|
|
|
CCLOG(
|
|
|
|
"cocos2d: **** WARNING **** CC_ENABLE_GL_STATE_CACHE is disabled. To improve performance, enable it (from "
|
|
|
|
"ccConfig.h)\n");
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Dump
|
|
|
|
Value forDump = Value(_valueDict);
|
|
|
|
return forDump.getDescription();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Configuration::gatherGPUInfo()
|
|
|
|
{
|
|
|
|
auto _deviceInfo = backend::Device::getInstance()->getDeviceInfo();
|
2021-12-25 10:04:45 +08:00
|
|
|
CCLOG("Supported extensions: %s", _deviceInfo->getExtension());
|
2020-02-12 20:24:29 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
_valueDict["vendor"] = Value(_deviceInfo->getVendor());
|
2019-11-23 20:27:39 +08:00
|
|
|
_valueDict["renderer"] = Value(_deviceInfo->getRenderer());
|
2021-12-25 10:04:45 +08:00
|
|
|
_valueDict["version"] = Value(_deviceInfo->getVersion());
|
|
|
|
|
|
|
|
_valueDict["max_texture_size"] = Value(_deviceInfo->getMaxTextureSize());
|
2019-11-23 20:27:39 +08:00
|
|
|
_valueDict["max_vertex_attributes"] = Value(_deviceInfo->getMaxAttributes());
|
2021-12-25 10:04:45 +08:00
|
|
|
_valueDict["max_texture_units"] = Value(_deviceInfo->getMaxTextureUnits());
|
|
|
|
_valueDict["max_samples_allowed"] = Value(_deviceInfo->getMaxSamplesAllowed());
|
|
|
|
|
|
|
|
_supportsNPOT = true;
|
2019-11-23 20:27:39 +08:00
|
|
|
_valueDict["supports_NPOT"] = Value(_supportsNPOT);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
_supportsETC1 = _deviceInfo->checkForFeatureSupported(backend::FeatureType::ETC1);
|
2019-11-23 20:27:39 +08:00
|
|
|
_valueDict["supports_ETC1"] = Value(_supportsETC1);
|
2020-08-31 21:04:47 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
_supportsETC2 = _deviceInfo->checkForFeatureSupported(backend::FeatureType::ETC2);
|
2020-08-31 21:04:47 +08:00
|
|
|
_valueDict["supports_ETC2"] = Value(_supportsETC2);
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
_supportsS3TC = _deviceInfo->checkForFeatureSupported(backend::FeatureType::S3TC);
|
2019-11-23 20:27:39 +08:00
|
|
|
_valueDict["supports_S3TC"] = Value(_supportsS3TC);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
_supportsATITC = _deviceInfo->checkForFeatureSupported(backend::FeatureType::AMD_COMPRESSED_ATC);
|
2019-11-23 20:27:39 +08:00
|
|
|
_valueDict["supports_ATITC"] = Value(_supportsATITC);
|
2020-02-12 20:24:29 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
_supportsASTC = _deviceInfo->checkForFeatureSupported(backend::FeatureType::ASTC);
|
2021-06-10 16:51:30 +08:00
|
|
|
_valueDict["supports_ASTC"] = Value(_supportsASTC);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
_supportsPVRTC = _deviceInfo->checkForFeatureSupported(backend::FeatureType::PVRTC);
|
2019-11-23 20:27:39 +08:00
|
|
|
_valueDict["supports_PVRTC"] = Value(_supportsPVRTC);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
_supportsBGRA8888 = _deviceInfo->checkForFeatureSupported(backend::FeatureType::IMG_FORMAT_BGRA8888);
|
2019-11-23 20:27:39 +08:00
|
|
|
_valueDict["supports_BGRA8888"] = Value(_supportsBGRA8888);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
_supportsDiscardFramebuffer = _deviceInfo->checkForFeatureSupported(backend::FeatureType::DISCARD_FRAMEBUFFER);
|
|
|
|
_valueDict["supports_discard_framebuffer"] = Value(_supportsDiscardFramebuffer);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
_supportsOESPackedDepthStencil = _deviceInfo->checkForFeatureSupported(backend::FeatureType::PACKED_DEPTH_STENCIL);
|
|
|
|
_valueDict["supports_OES_packed_depth_stencil"] = Value(_supportsOESPackedDepthStencil);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
_supportsShareableVAO = _deviceInfo->checkForFeatureSupported(backend::FeatureType::VAO);
|
2019-11-23 20:27:39 +08:00
|
|
|
_valueDict["supports_vertex_array_object"] = Value(_supportsShareableVAO);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
_supportsOESMapBuffer = _deviceInfo->checkForFeatureSupported(backend::FeatureType::MAPBUFFER);
|
2019-11-23 20:27:39 +08:00
|
|
|
_valueDict["supports_OES_map_buffer"] = Value(_supportsOESMapBuffer);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
_supportsOESDepth24 = _deviceInfo->checkForFeatureSupported(backend::FeatureType::DEPTH24);
|
2019-11-23 20:27:39 +08:00
|
|
|
_valueDict["supports_OES_depth24"] = Value(_supportsOESDepth24);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
_glExtensions = _deviceInfo->getExtension();
|
|
|
|
}
|
|
|
|
|
|
|
|
Configuration* Configuration::getInstance()
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!s_sharedConfiguration)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
s_sharedConfiguration = new Configuration();
|
2019-11-23 20:27:39 +08:00
|
|
|
s_sharedConfiguration->init();
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
return s_sharedConfiguration;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Configuration::destroyInstance()
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE_NULL(s_sharedConfiguration);
|
|
|
|
}
|
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
bool Configuration::checkForGLExtension(std::string_view searchName) const
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
return _glExtensions.find(searchName) != std::string::npos;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// getters for specific variables.
|
|
|
|
// Maintained for backward compatibility reasons only.
|
|
|
|
//
|
|
|
|
int Configuration::getMaxTextureSize() const
|
|
|
|
{
|
|
|
|
auto _deviceInfo = backend::Device::getInstance()->getDeviceInfo();
|
|
|
|
return _deviceInfo->getMaxTextureSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
int Configuration::getMaxModelviewStackDepth() const
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
return _maxModelviewStackDepth;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int Configuration::getMaxTextureUnits() const
|
|
|
|
{
|
|
|
|
auto _deviceInfo = backend::Device::getInstance()->getDeviceInfo();
|
|
|
|
return _deviceInfo->getMaxTextureUnits();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Configuration::supportsNPOT() const
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
return _supportsNPOT;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Configuration::supportsPVRTC() const
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
return _supportsPVRTC;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
2020-09-01 11:43:03 +08:00
|
|
|
bool Configuration::supportsETC1() const
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
return _supportsETC1;
|
|
|
|
}
|
|
|
|
|
2020-08-31 21:04:47 +08:00
|
|
|
bool Configuration::supportsETC2() const
|
|
|
|
{
|
|
|
|
return _supportsETC2;
|
|
|
|
}
|
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
bool Configuration::supportsS3TC() const
|
|
|
|
{
|
|
|
|
return _supportsS3TC;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Configuration::supportsATITC() const
|
|
|
|
{
|
|
|
|
return _supportsATITC;
|
|
|
|
}
|
|
|
|
|
2020-02-12 20:24:29 +08:00
|
|
|
bool Configuration::supportsASTC() const
|
|
|
|
{
|
|
|
|
return _supportsASTC;
|
|
|
|
}
|
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
bool Configuration::supportsBGRA8888() const
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
return _supportsBGRA8888;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Configuration::supportsDiscardFramebuffer() const
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
return _supportsDiscardFramebuffer;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Configuration::supportsShareableVAO() const
|
|
|
|
{
|
|
|
|
#if CC_TEXTURE_ATLAS_USE_VAO
|
|
|
|
return _supportsShareableVAO;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Configuration::supportsMapBuffer() const
|
|
|
|
{
|
|
|
|
// Fixes Github issue #16123
|
|
|
|
//
|
|
|
|
// XXX: Fixme. Should check GL ES and not iOS or Android
|
|
|
|
// For example, linux could be compiled with GL ES. Or perhaps in the future Android will
|
|
|
|
// support OpenGL. This is because glMapBufferOES() is an extension of OpenGL ES. And glMapBuffer()
|
|
|
|
// is always implemented in OpenGL.
|
|
|
|
|
|
|
|
// XXX: Warning. On iOS this is always `true`. Avoiding the comparison.
|
2020-08-28 12:57:00 +08:00
|
|
|
#if defined(CC_USE_GLES) && !defined(__APPLE__)
|
2019-11-23 20:27:39 +08:00
|
|
|
return _supportsOESMapBuffer;
|
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Configuration::supportsOESDepth24() const
|
|
|
|
{
|
|
|
|
return _supportsOESDepth24;
|
|
|
|
}
|
|
|
|
bool Configuration::supportsOESPackedDepthStencil() const
|
|
|
|
{
|
|
|
|
return _supportsOESPackedDepthStencil;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Configuration::getMaxSupportDirLightInShader() const
|
|
|
|
{
|
|
|
|
return _maxDirLightInShader;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Configuration::getMaxSupportPointLightInShader() const
|
|
|
|
{
|
|
|
|
return _maxPointLightInShader;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Configuration::getMaxSupportSpotLightInShader() const
|
|
|
|
{
|
|
|
|
return _maxSpotLightInShader;
|
|
|
|
}
|
|
|
|
|
|
|
|
Animate3DQuality Configuration::getAnimate3DQuality() const
|
|
|
|
{
|
|
|
|
return _animate3DQuality;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// generic getters for properties
|
|
|
|
//
|
2021-12-26 23:26:34 +08:00
|
|
|
const Value& Configuration::getValue(std::string_view key, const Value& defaultValue) const
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
auto iter = _valueDict.find(key);
|
|
|
|
if (iter != _valueDict.cend())
|
|
|
|
return iter->second;
|
|
|
|
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
void Configuration::setValue(std::string_view key, const Value& value)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-26 23:26:34 +08:00
|
|
|
hlookup::set_item(_valueDict, key, value); // _valueDict[key] = value;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// load file
|
|
|
|
//
|
2021-12-26 23:26:34 +08:00
|
|
|
void Configuration::loadConfigFile(std::string_view filename)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(filename);
|
|
|
|
CCASSERT(!dict.empty(), "cannot create dictionary");
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
// search for metadata
|
|
|
|
bool validMetadata = false;
|
|
|
|
auto metadataIter = dict.find("metadata");
|
|
|
|
if (metadataIter != dict.cend() && metadataIter->second.getType() == Value::Type::MAP)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
const auto& metadata = metadataIter->second.asValueMap();
|
|
|
|
auto formatIter = metadata.find("format");
|
|
|
|
|
|
|
|
if (formatIter != metadata.cend())
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int format = formatIter->second.asInt();
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
// Support format: 1
|
|
|
|
if (format == 1)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
validMetadata = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!validMetadata)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-26 23:26:34 +08:00
|
|
|
CCLOG("Invalid config format for file: %s", filename.data());
|
2021-12-25 10:04:45 +08:00
|
|
|
return;
|
|
|
|
}
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
auto dataIter = dict.find("data");
|
|
|
|
if (dataIter == dict.cend() || dataIter->second.getType() != Value::Type::MAP)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-26 23:26:34 +08:00
|
|
|
CCLOG("Expected 'data' dict, but not found. Config file: %s", filename.data());
|
2021-12-25 10:04:45 +08:00
|
|
|
return;
|
|
|
|
}
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
// Add all keys in the existing dictionary
|
|
|
|
|
|
|
|
const auto& dataMap = dataIter->second.asValueMap();
|
2019-11-23 20:27:39 +08:00
|
|
|
for (const auto& dataMapIter : dataMap)
|
|
|
|
{
|
|
|
|
if (_valueDict.find(dataMapIter.first) == _valueDict.cend())
|
|
|
|
_valueDict[dataMapIter.first] = dataMapIter.second;
|
|
|
|
else
|
2021-12-25 10:04:45 +08:00
|
|
|
CCLOG("Key already present. Ignoring '%s'", dataMapIter.first.c_str());
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
// light info
|
2021-05-18 16:40:30 +08:00
|
|
|
std::string name = "adxe.3d.max_dir_light_in_shader";
|
2021-12-25 10:04:45 +08:00
|
|
|
if (_valueDict.find(name) != _valueDict.end())
|
2020-08-18 11:33:18 +08:00
|
|
|
_maxDirLightInShader = _valueDict[name].asInt();
|
2019-11-23 20:27:39 +08:00
|
|
|
else
|
|
|
|
_valueDict[name] = Value(_maxDirLightInShader);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2021-05-18 16:40:30 +08:00
|
|
|
name = "adxe.3d.max_point_light_in_shader";
|
2021-12-25 10:04:45 +08:00
|
|
|
if (_valueDict.find(name) != _valueDict.end())
|
2020-08-18 11:33:18 +08:00
|
|
|
_maxPointLightInShader = _valueDict[name].asInt();
|
2019-11-23 20:27:39 +08:00
|
|
|
else
|
|
|
|
_valueDict[name] = Value(_maxPointLightInShader);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2021-05-18 16:40:30 +08:00
|
|
|
name = "adxe.3d.max_spot_light_in_shader";
|
2021-12-25 10:04:45 +08:00
|
|
|
if (_valueDict.find(name) != _valueDict.end())
|
2020-08-18 11:33:18 +08:00
|
|
|
_maxSpotLightInShader = _valueDict[name].asInt();
|
2019-11-23 20:27:39 +08:00
|
|
|
else
|
|
|
|
_valueDict[name] = Value(_maxSpotLightInShader);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2021-05-18 16:40:30 +08:00
|
|
|
name = "adxe.3d.animate_quality";
|
2019-11-23 20:27:39 +08:00
|
|
|
if (_valueDict.find(name) != _valueDict.end())
|
2020-08-18 11:33:18 +08:00
|
|
|
_animate3DQuality = (Animate3DQuality)_valueDict[name].asInt();
|
2019-11-23 20:27:39 +08:00
|
|
|
else
|
|
|
|
_valueDict[name] = Value((int)_animate3DQuality);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
Director::getInstance()->getEventDispatcher()->dispatchEvent(_loadedEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
int Configuration::getMaxAttributes() const
|
|
|
|
{
|
|
|
|
auto _deviceInfo = backend::Device::getInstance()->getDeviceInfo();
|
|
|
|
return _deviceInfo->getMaxAttributes();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_END
|