From 0995204abc9fa682c74396fa4894251e8ca4dade Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 1 May 2014 12:12:39 +0800 Subject: [PATCH 001/174] Optimization for Value --- cocos/base/CCValue.cpp | 543 ++++++++++++++++++++--------------------- cocos/base/CCValue.h | 63 ++--- 2 files changed, 296 insertions(+), 310 deletions(-) diff --git a/cocos/base/CCValue.cpp b/cocos/base/CCValue.cpp index 80536fdeaa..e4fa545128 100644 --- a/cocos/base/CCValue.cpp +++ b/cocos/base/CCValue.cpp @@ -1,18 +1,18 @@ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies - + 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 @@ -20,7 +20,7 @@ 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/CCValue.h" #include @@ -31,143 +31,106 @@ NS_CC_BEGIN const Value Value::Null; Value::Value() -: _vectorData(nullptr) -, _mapData(nullptr) -, _intKeyMapData(nullptr) -, _type(Type::NONE) +: _type(Type::NONE) { - + } Value::Value(unsigned char v) -: _vectorData(nullptr) -, _mapData(nullptr) -, _intKeyMapData(nullptr) -, _type(Type::BYTE) +: _type(Type::BYTE) { - _baseData.byteVal = v; + _field.byteVal = v; } Value::Value(int v) -: _vectorData(nullptr) -, _mapData(nullptr) -, _intKeyMapData(nullptr) -, _type(Type::INTEGER) +: _type(Type::INTEGER) { - _baseData.intVal = v; + _field.intVal = v; } Value::Value(float v) -: _vectorData(nullptr) -, _mapData(nullptr) -, _intKeyMapData(nullptr) -, _type(Type::FLOAT) +: _type(Type::FLOAT) { - _baseData.floatVal = v; + _field.floatVal = v; } Value::Value(double v) -: _vectorData(nullptr) -, _mapData(nullptr) -, _intKeyMapData(nullptr) -, _type(Type::DOUBLE) +: _type(Type::DOUBLE) { - _baseData.doubleVal = v; + _field.doubleVal = v; } Value::Value(bool v) -: _vectorData(nullptr) -, _mapData(nullptr) -, _intKeyMapData(nullptr) -, _type(Type::BOOLEAN) +: _type(Type::BOOLEAN) { - _baseData.boolVal = v; + _field.boolVal = v; } Value::Value(const char* v) -: _vectorData(nullptr) -, _mapData(nullptr) -, _intKeyMapData(nullptr) -, _type(Type::STRING) +: _type(Type::STRING) { - _strData = v; + _field.strVal = new std::string(); + if (v) + { + *_field.strVal = v; + } } Value::Value(const std::string& v) -: _vectorData(nullptr) -, _mapData(nullptr) -, _intKeyMapData(nullptr) -, _type(Type::STRING) +: _type(Type::STRING) { - _strData = v; + _field.strVal = new std::string(); + *_field.strVal = v; } Value::Value(const ValueVector& v) -: _vectorData(new ValueVector()) -, _mapData(nullptr) -, _intKeyMapData(nullptr) -, _type(Type::VECTOR) +: _type(Type::VECTOR) { - *_vectorData = v; + _field.vectorVal = new ValueVector(); + *_field.vectorVal = v; } Value::Value(ValueVector&& v) -: _vectorData(new ValueVector()) -, _mapData(nullptr) -, _intKeyMapData(nullptr) -, _type(Type::VECTOR) +: _type(Type::VECTOR) { - *_vectorData = std::move(v); + _field.vectorVal = new ValueVector(); + *_field.vectorVal = std::move(v); } Value::Value(const ValueMap& v) -: _vectorData(nullptr) -, _mapData(new ValueMap()) -, _intKeyMapData(nullptr) -, _type(Type::MAP) +: _type(Type::MAP) { - *_mapData = v; + _field.mapVal = new ValueMap(); + *_field.mapVal = v; } Value::Value(ValueMap&& v) -: _vectorData(nullptr) -, _mapData(new ValueMap()) -, _intKeyMapData(nullptr) -, _type(Type::MAP) +: _type(Type::MAP) { - *_mapData = std::move(v); + _field.mapVal = new ValueMap(); + *_field.mapVal = std::move(v); } Value::Value(const ValueMapIntKey& v) -: _vectorData(nullptr) -, _mapData(nullptr) -, _intKeyMapData(new ValueMapIntKey()) -, _type(Type::INT_KEY_MAP) +: _type(Type::INT_KEY_MAP) { - *_intKeyMapData = v; + _field.intKeyMapVal = new ValueMapIntKey(); + *_field.intKeyMapVal = v; } Value::Value(ValueMapIntKey&& v) -: _vectorData(nullptr) -, _mapData(nullptr) -, _intKeyMapData(new ValueMapIntKey()) -, _type(Type::INT_KEY_MAP) +: _type(Type::INT_KEY_MAP) { - *_intKeyMapData = std::move(v); + _field.intKeyMapVal = new ValueMapIntKey(); + *_field.intKeyMapVal = std::move(v); } Value::Value(const Value& other) -: _vectorData(nullptr) -, _mapData(nullptr) -, _intKeyMapData(nullptr) { *this = other; } Value::Value(Value&& other) -: _vectorData(nullptr) -, _mapData(nullptr) -, _intKeyMapData(nullptr) { *this = std::move(other); } @@ -180,39 +143,35 @@ Value::~Value() Value& Value::operator= (const Value& other) { if (this != &other) { + reset(other._type); + switch (other._type) { case Type::BYTE: - _baseData.byteVal = other._baseData.byteVal; + _field.byteVal = other._field.byteVal; break; case Type::INTEGER: - _baseData.intVal = other._baseData.intVal; + _field.intVal = other._field.intVal; break; case Type::FLOAT: - _baseData.floatVal = other._baseData.floatVal; + _field.floatVal = other._field.floatVal; break; case Type::DOUBLE: - _baseData.doubleVal = other._baseData.doubleVal; + _field.doubleVal = other._field.doubleVal; break; case Type::BOOLEAN: - _baseData.boolVal = other._baseData.boolVal; + _field.boolVal = other._field.boolVal; break; case Type::STRING: - _strData = other._strData; + *_field.strVal = *other._field.strVal; break; case Type::VECTOR: - if (_vectorData == nullptr) - _vectorData = new ValueVector(); - *_vectorData = *other._vectorData; + *_field.vectorVal = *other._field.vectorVal; break; case Type::MAP: - if (_mapData == nullptr) - _mapData = new ValueMap(); - *_mapData = *other._mapData; + *_field.mapVal = *other._field.mapVal; break; case Type::INT_KEY_MAP: - if (_intKeyMapData == nullptr) - _intKeyMapData = new ValueMapIntKey(); - *_intKeyMapData = *other._intKeyMapData; + *_field.intKeyMapVal = *other._field.intKeyMapVal; break; default: break; @@ -224,371 +183,350 @@ Value& Value::operator= (const Value& other) Value& Value::operator= (Value&& other) { - if (this != &other) { - switch (other._type) { + if (this != &other) + { + reset(other._type); + switch (other._type) + { case Type::BYTE: - _baseData.byteVal = other._baseData.byteVal; + _field.byteVal = other._field.byteVal; break; case Type::INTEGER: - _baseData.intVal = other._baseData.intVal; + _field.intVal = other._field.intVal; break; case Type::FLOAT: - _baseData.floatVal = other._baseData.floatVal; + _field.floatVal = other._field.floatVal; break; case Type::DOUBLE: - _baseData.doubleVal = other._baseData.doubleVal; + _field.doubleVal = other._field.doubleVal; break; case Type::BOOLEAN: - _baseData.boolVal = other._baseData.boolVal; + _field.boolVal = other._field.boolVal; break; case Type::STRING: - _strData = other._strData; + _field.strVal = other._field.strVal; break; case Type::VECTOR: - CC_SAFE_DELETE(_vectorData); - _vectorData = other._vectorData; + _field.vectorVal = other._field.vectorVal; break; case Type::MAP: - CC_SAFE_DELETE(_mapData); - _mapData = other._mapData; + _field.mapVal = other._field.mapVal; break; case Type::INT_KEY_MAP: - CC_SAFE_DELETE(_intKeyMapData); - _intKeyMapData = other._intKeyMapData; + _field.intKeyMapVal = other._field.intKeyMapVal; break; default: break; } _type = other._type; - - other._vectorData = nullptr; - other._mapData = nullptr; - other._intKeyMapData = nullptr; + + memset(&other._field, 0, sizeof(other._field)); other._type = Type::NONE; } - + return *this; } Value& Value::operator= (unsigned char v) { - clear(); - _type = Type::BYTE; - _baseData.byteVal = v; + reset(Type::BYTE); + _field.byteVal = v; return *this; } Value& Value::operator= (int v) { - clear(); - _type = Type::INTEGER; - _baseData.intVal = v; + reset(Type::INTEGER); + _field.intVal = v; return *this; } Value& Value::operator= (float v) { - clear(); - _type = Type::FLOAT; - _baseData.floatVal = v; + reset(Type::FLOAT); + _field.floatVal = v; return *this; } Value& Value::operator= (double v) { - clear(); - _type = Type::DOUBLE; - _baseData.doubleVal = v; + reset(Type::DOUBLE); + _field.doubleVal = v; return *this; } Value& Value::operator= (bool v) { - clear(); - _type = Type::BOOLEAN; - _baseData.boolVal = v; + reset(Type::BOOLEAN); + _field.boolVal = v; return *this; } Value& Value::operator= (const char* v) { - clear(); - _type = Type::STRING; - _strData = v ? v : ""; + reset(Type::STRING); + *_field.strVal = v ? v : ""; return *this; } Value& Value::operator= (const std::string& v) { - clear(); - _type = Type::STRING; - _strData = v; + reset(Type::STRING); + *_field.strVal = v; return *this; } Value& Value::operator= (const ValueVector& v) { - clear(); - _type = Type::VECTOR; - _vectorData = new ValueVector(); - *_vectorData = v; + reset(Type::VECTOR); + *_field.vectorVal = v; return *this; } Value& Value::operator= (ValueVector&& v) { - clear(); - _type = Type::VECTOR; - _vectorData = new ValueVector(); - *_vectorData = std::move(v); + reset(Type::VECTOR); + *_field.vectorVal = std::move(v); return *this; } Value& Value::operator= (const ValueMap& v) { - clear(); - _type = Type::MAP; - _mapData = new ValueMap(); - *_mapData = v; + reset(Type::MAP); + *_field.mapVal = v; return *this; } Value& Value::operator= (ValueMap&& v) { - clear(); - _type = Type::MAP; - _mapData = new ValueMap(); - *_mapData = std::move(v); + reset(Type::MAP); + *_field.mapVal = std::move(v); return *this; } Value& Value::operator= (const ValueMapIntKey& v) { - clear(); - _type = Type::INT_KEY_MAP; - _intKeyMapData = new ValueMapIntKey(); - *_intKeyMapData = v; + reset(Type::INT_KEY_MAP); + *_field.intKeyMapVal = v; return *this; } Value& Value::operator= (ValueMapIntKey&& v) { - clear(); - _type = Type::INT_KEY_MAP; - _intKeyMapData = new ValueMapIntKey(); - *_intKeyMapData = std::move(v); + reset(Type::INT_KEY_MAP); + *_field.intKeyMapVal = std::move(v); return *this; } -/// +/// Convert value to a specified type unsigned char Value::asByte() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP, ""); - + CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); + if (_type == Type::BYTE) { - return _baseData.byteVal; + return _field.byteVal; } - + if (_type == Type::INTEGER) { - return static_cast(_baseData.intVal); + return static_cast(_field.intVal); } - + if (_type == Type::STRING) { - return static_cast(atoi(_strData.c_str())); + return static_cast(atoi(_field.strVal->c_str())); } - + if (_type == Type::FLOAT) { - return static_cast(_baseData.floatVal); + return static_cast(_field.floatVal); } - + if (_type == Type::DOUBLE) { - return static_cast(_baseData.doubleVal); + return static_cast(_field.doubleVal); } - + if (_type == Type::BOOLEAN) { - return _baseData.boolVal ? 1 : 0; + return _field.boolVal ? 1 : 0; } - + return 0; } int Value::asInt() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP, ""); + CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); if (_type == Type::INTEGER) { - return _baseData.intVal; + return _field.intVal; } - + if (_type == Type::BYTE) { - return _baseData.byteVal; + return _field.byteVal; } - + if (_type == Type::STRING) { - return atoi(_strData.c_str()); + return atoi(_field.strVal->c_str()); } - + if (_type == Type::FLOAT) { - return static_cast(_baseData.floatVal); + return static_cast(_field.floatVal); } - + if (_type == Type::DOUBLE) { - return static_cast(_baseData.doubleVal); + return static_cast(_field.doubleVal); } - + if (_type == Type::BOOLEAN) { - return _baseData.boolVal ? 1 : 0; + return _field.boolVal ? 1 : 0; } - + return 0; } float Value::asFloat() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP, ""); + CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); if (_type == Type::FLOAT) { - return _baseData.floatVal; + return _field.floatVal; } - + if (_type == Type::BYTE) { - return static_cast(_baseData.byteVal); + return static_cast(_field.byteVal); } - + if (_type == Type::STRING) { - return atof(_strData.c_str()); + return atof(_field.strVal->c_str()); } - + if (_type == Type::INTEGER) { - return static_cast(_baseData.intVal); + return static_cast(_field.intVal); } - + if (_type == Type::DOUBLE) { - return static_cast(_baseData.doubleVal); + return static_cast(_field.doubleVal); } - + if (_type == Type::BOOLEAN) { - return _baseData.boolVal ? 1.0f : 0.0f; + return _field.boolVal ? 1.0f : 0.0f; } - + return 0.0f; } double Value::asDouble() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP, ""); + CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); if (_type == Type::DOUBLE) { - return _baseData.doubleVal; + return _field.doubleVal; } - + if (_type == Type::BYTE) { - return static_cast(_baseData.byteVal); + return static_cast(_field.byteVal); } - + if (_type == Type::STRING) { - return static_cast(atof(_strData.c_str())); + return static_cast(atof(_field.strVal->c_str())); } - + if (_type == Type::INTEGER) { - return static_cast(_baseData.intVal); + return static_cast(_field.intVal); } - + if (_type == Type::FLOAT) { - return static_cast(_baseData.floatVal); + return static_cast(_field.floatVal); } - + if (_type == Type::BOOLEAN) { - return _baseData.boolVal ? 1.0 : 0.0; + return _field.boolVal ? 1.0 : 0.0; } - + return 0.0; } bool Value::asBool() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP, ""); + CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); if (_type == Type::BOOLEAN) { - return _baseData.boolVal; + return _field.boolVal; } - + if (_type == Type::BYTE) { - return _baseData.byteVal == 0 ? false : true; + return _field.byteVal == 0 ? false : true; } - + if (_type == Type::STRING) { - return (_strData == "0" || _strData == "false") ? false : true; + return (*_field.strVal == "0" || *_field.strVal == "false") ? false : true; } - + if (_type == Type::INTEGER) { - return _baseData.intVal == 0 ? false : true; + return _field.intVal == 0 ? false : true; } - + if (_type == Type::FLOAT) { - return _baseData.floatVal == 0.0f ? false : true; + return _field.floatVal == 0.0f ? false : true; } - + if (_type == Type::DOUBLE) { - return _baseData.doubleVal == 0.0 ? false : true; + return _field.doubleVal == 0.0 ? false : true; } - + return false; } std::string Value::asString() const { - CCASSERT(_type != Type::VECTOR && _type != Type::MAP, ""); - + CCASSERT(_type != Type::VECTOR && _type != Type::MAP && _type != Type::INT_KEY_MAP, "Only base type (bool, string, float, double, int) could be converted"); + if (_type == Type::STRING) { - return _strData; + return *_field.strVal; } - + std::stringstream ret; - - - switch (_type) { + + switch (_type) + { case Type::BYTE: - ret << _baseData.byteVal; + ret << _field.byteVal; break; case Type::INTEGER: - ret << _baseData.intVal; + ret << _field.intVal; break; case Type::FLOAT: - ret << std::fixed << std::setprecision( 7 )<< _baseData.floatVal; + ret << std::fixed << std::setprecision( 7 )<< _field.floatVal; break; case Type::DOUBLE: - ret << std::fixed << std::setprecision( 16 ) << _baseData.doubleVal; + ret << std::fixed << std::setprecision( 16 ) << _field.doubleVal; break; case Type::BOOLEAN: - ret << (_baseData.boolVal ? "true" : "false"); + ret << (_field.boolVal ? "true" : "false"); break; default: break; @@ -598,58 +536,49 @@ std::string Value::asString() const ValueVector& Value::asValueVector() { - if (nullptr == _vectorData) - _vectorData = new ValueVector(); - return *_vectorData; + CCASSERT(_type == Type::VECTOR, "The value type isn't Type::VECTOR"); + return *_field.vectorVal; } const ValueVector& Value::asValueVector() const { - static const ValueVector EMPTY_VALUEVECTOR; - if (nullptr == _vectorData) - return EMPTY_VALUEVECTOR; - return *_vectorData; + CCASSERT(_type == Type::VECTOR, "The value type isn't Type::VECTOR"); + return *_field.vectorVal; } ValueMap& Value::asValueMap() { - if (nullptr == _mapData) - _mapData = new ValueMap(); - return *_mapData; + CCASSERT(_type == Type::MAP, "The value type isn't Type::MAP"); + return *_field.mapVal; } const ValueMap& Value::asValueMap() const { - static const ValueMap EMPTY_VALUEMAP; - if (nullptr == _mapData) - return EMPTY_VALUEMAP; - return *_mapData; + CCASSERT(_type == Type::MAP, "The value type isn't Type::MAP"); + return *_field.mapVal; } ValueMapIntKey& Value::asIntKeyMap() { - if (nullptr == _intKeyMapData) - _intKeyMapData = new ValueMapIntKey(); - return *_intKeyMapData; + CCASSERT(_type == Type::INT_KEY_MAP, "The value type isn't Type::INT_KEY_MAP"); + return *_field.intKeyMapVal; } const ValueMapIntKey& Value::asIntKeyMap() const { - static const ValueMapIntKey EMPTY_VALUEMAP_INT_KEY; - if (nullptr == _intKeyMapData) - return EMPTY_VALUEMAP_INT_KEY; - return *_intKeyMapData; + CCASSERT(_type == Type::INT_KEY_MAP, "The value type isn't Type::INT_KEY_MAP"); + return *_field.intKeyMapVal; } static std::string getTabs(int depth) { std::string tabWidth; - + for (int i = 0; i < depth; ++i) { tabWidth += "\t"; } - + return tabWidth; } @@ -658,21 +587,21 @@ static std::string visit(const Value& v, int depth); static std::string visitVector(const ValueVector& v, int depth) { std::stringstream ret; - + if (depth > 0) ret << "\n"; - + ret << getTabs(depth) << "[\n"; - + int i = 0; for (const auto& child : v) { ret << getTabs(depth+1) << i << ": " << visit(child, depth + 1); ++i; } - + ret << getTabs(depth) << "]\n"; - + return ret.str(); } @@ -680,20 +609,20 @@ template static std::string visitMap(const T& v, int depth) { std::stringstream ret; - + if (depth > 0) ret << "\n"; - + ret << getTabs(depth) << "{\n"; - + for (auto iter = v.begin(); iter != v.end(); ++iter) { ret << getTabs(depth + 1) << iter->first << ": "; ret << visit(iter->second, depth + 1); } - + ret << getTabs(depth) << "}\n"; - + return ret.str(); } @@ -725,7 +654,7 @@ static std::string visit(const Value& v, int depth) CCASSERT(false, "Invalid type!"); break; } - + return ret.str(); } @@ -738,12 +667,68 @@ std::string Value::getDescription() void Value::clear() { - _type = Type::NONE; - _baseData.doubleVal = 0.0; - _strData.clear(); - CC_SAFE_DELETE(_vectorData); - CC_SAFE_DELETE(_mapData); - CC_SAFE_DELETE(_intKeyMapData); + reset(Type::NONE); +} + +void Value::reset(Type type) +{ + if (_type == type) + return; + + // Free memory the old value allocated + switch (_type) + { + case Type::BYTE: + _field.byteVal = 0; + break; + case Type::INTEGER: + _field.intVal = 0; + break; + case Type::FLOAT: + _field.floatVal = 0.0f; + break; + case Type::DOUBLE: + _field.doubleVal = 0.0; + break; + case Type::BOOLEAN: + _field.boolVal = false; + break; + case Type::STRING: + CC_SAFE_DELETE(_field.strVal); + break; + case Type::VECTOR: + CC_SAFE_DELETE(_field.vectorVal); + break; + case Type::MAP: + CC_SAFE_DELETE(_field.mapVal); + break; + case Type::INT_KEY_MAP: + CC_SAFE_DELETE(_field.intKeyMapVal); + break; + default: + break; + } + + // Allocate memory for the new value + switch (type) + { + case Type::STRING: + _field.strVal = new std::string(); + break; + case Type::VECTOR: + _field.vectorVal = new ValueVector(); + break; + case Type::MAP: + _field.mapVal = new ValueMap(); + break; + case Type::INT_KEY_MAP: + _field.intKeyMapVal = new ValueMapIntKey(); + break; + default: + break; + } + + _type = type; } NS_CC_END diff --git a/cocos/base/CCValue.h b/cocos/base/CCValue.h index fd0615e686..6e5792d7c7 100644 --- a/cocos/base/CCValue.h +++ b/cocos/base/CCValue.h @@ -1,18 +1,18 @@ /**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies - + 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 @@ -43,7 +43,7 @@ class Value { public: static const Value Null; - + Value(); explicit Value(unsigned char v); explicit Value(int v); @@ -52,24 +52,24 @@ public: explicit Value(bool v); explicit Value(const char* v); explicit Value(const std::string& v); - + explicit Value(const ValueVector& v); explicit Value(ValueVector&& v); - + explicit Value(const ValueMap& v); - explicit Value(ValueMap&& v); - + explicit Value(ValueMap&& v); + explicit Value(const ValueMapIntKey& v); explicit Value(ValueMapIntKey&& v); - + Value(const Value& other); Value(Value&& other); ~Value(); - + // assignment operator Value& operator= (const Value& other); Value& operator= (Value&& other); - + Value& operator= (unsigned char v); Value& operator= (int v); Value& operator= (float v); @@ -77,37 +77,37 @@ public: Value& operator= (bool v); Value& operator= (const char* v); Value& operator= (const std::string& v); - + Value& operator= (const ValueVector& v); Value& operator= (ValueVector&& v); - + Value& operator= (const ValueMap& v); - Value& operator= (ValueMap&& v); - + Value& operator= (ValueMap&& v); + Value& operator= (const ValueMapIntKey& v); Value& operator= (ValueMapIntKey&& v); - + unsigned char asByte() const; int asInt() const; float asFloat() const; double asDouble() const; bool asBool() const; std::string asString() const; - + ValueVector& asValueVector(); const ValueVector& asValueVector() const; - + ValueMap& asValueMap(); const ValueMap& asValueMap() const; - + ValueMapIntKey& asIntKeyMap(); const ValueMapIntKey& asIntKeyMap() const; inline bool isNull() const { return _type == Type::NONE; } - + enum class Type { - NONE, + NONE = 0, BYTE, INTEGER, FLOAT, @@ -120,12 +120,13 @@ public: }; inline Type getType() const { return _type; }; - + std::string getDescription(); - + private: void clear(); - + void reset(Type type); + union { unsigned char byteVal; @@ -133,12 +134,12 @@ private: float floatVal; double doubleVal; bool boolVal; - }_baseData; - - std::string _strData; - ValueVector* _vectorData; - ValueMap* _mapData; - ValueMapIntKey* _intKeyMapData; + + std::string* strVal; + ValueVector* vectorVal; + ValueMap* mapVal; + ValueMapIntKey* intKeyMapVal; + }_field; Type _type; }; From bbd4533c5ec9c73b3e2a334c30ec50d491e671ae Mon Sep 17 00:00:00 2001 From: yangxiao Date: Tue, 6 May 2014 11:03:24 -0700 Subject: [PATCH 002/174] Improves GLProgram Adds vetex attrib bind class --- build/cocos2d_libs.xcodeproj/project.pbxproj | 12 + cocos/2d/CCGLProgram.cpp | 407 ++++++++++++++++++- cocos/2d/CCGLProgram.h | 107 ++++- cocos/2d/CCVertexAttribBind.cpp | 118 ++++++ cocos/2d/CCVertexAttribBind.h | 72 ++++ 5 files changed, 714 insertions(+), 2 deletions(-) create mode 100644 cocos/2d/CCVertexAttribBind.cpp create mode 100644 cocos/2d/CCVertexAttribBind.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index a4eda8c14e..a737cca32e 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1115,6 +1115,10 @@ 3E26D40518ACB5D100834404 /* CCImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E26D40418ACB5D100834404 /* CCImage.cpp */; }; 3E26D40618ACB5D100834404 /* CCImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E26D40418ACB5D100834404 /* CCImage.cpp */; }; 3E26D40818ACB63900834404 /* CCDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E26D40718ACB63900834404 /* CCDevice.mm */; }; + 3E9D30DF19195B22008EB309 /* CCVertexAttribBind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9D30DD19195B22008EB309 /* CCVertexAttribBind.cpp */; }; + 3E9D30E019195B22008EB309 /* CCVertexAttribBind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9D30DD19195B22008EB309 /* CCVertexAttribBind.cpp */; }; + 3E9D30E119195B22008EB309 /* CCVertexAttribBind.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9D30DE19195B22008EB309 /* CCVertexAttribBind.h */; }; + 3E9D30E219195B22008EB309 /* CCVertexAttribBind.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9D30DE19195B22008EB309 /* CCVertexAttribBind.h */; }; 460E468118080832000CDD6D /* cocos-ext.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A167D21807AF4D005B8026 /* cocos-ext.h */; }; 460E468218080836000CDD6D /* cocos-ext.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A167D21807AF4D005B8026 /* cocos-ext.h */; }; 460E477B180808F5000CDD6D /* ExtensionMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168321807AF4E005B8026 /* ExtensionMacros.h */; }; @@ -2302,6 +2306,8 @@ 37936A3E1869B76800E974DD /* writer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = writer.h; sourceTree = ""; }; 3E26D40418ACB5D100834404 /* CCImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCImage.cpp; sourceTree = ""; }; 3E26D40718ACB63900834404 /* CCDevice.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CCDevice.mm; sourceTree = ""; }; + 3E9D30DD19195B22008EB309 /* CCVertexAttribBind.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCVertexAttribBind.cpp; sourceTree = ""; }; + 3E9D30DE19195B22008EB309 /* CCVertexAttribBind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVertexAttribBind.h; sourceTree = ""; }; 46A15FCC1807A544005B8026 /* AUTHORS */ = {isa = PBXFileReference; lastKnownFileType = text; name = AUTHORS; path = ../AUTHORS; sourceTree = ""; }; 46A15FCE1807A544005B8026 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; name = README.md; path = ../README.md; sourceTree = ""; }; 46A15FE11807A56F005B8026 /* Export.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Export.h; sourceTree = ""; }; @@ -3226,6 +3232,8 @@ 1A570238180BCC580088DEC7 /* shaders */ = { isa = PBXGroup; children = ( + 3E9D30DD19195B22008EB309 /* CCVertexAttribBind.cpp */, + 3E9D30DE19195B22008EB309 /* CCVertexAttribBind.h */, 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */, 1A570530180BD9500088DEC7 /* CCGLProgram.h */, 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */, @@ -4929,6 +4937,7 @@ 1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */, 1A01C69A18F57BE800EFE3A6 /* CCSet.h in Headers */, A023FA36185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, + 3E9D30E119195B22008EB309 /* CCVertexAttribBind.h in Headers */, 1A570083180BC5A10088DEC7 /* CCActionManager.h in Headers */, 1A570087180BC5A10088DEC7 /* CCActionPageTurn3D.h in Headers */, ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */, @@ -5501,6 +5510,7 @@ 50FCEBA618C72017004AD434 /* ListViewReader.h in Headers */, 1A57025A180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */, 500DC9B919106E6D007B91BF /* TransformUtils.h in Headers */, + 3E9D30E219195B22008EB309 /* CCVertexAttribBind.h in Headers */, 1A57025C180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */, 1A57025E180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */, 1A570260180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */, @@ -6311,6 +6321,7 @@ 1A8C59B3180E930E00EF57C3 /* CCBone.cpp in Sources */, 1A8C59B7180E930E00EF57C3 /* CCColliderDetector.cpp in Sources */, 1A8C59BB180E930E00EF57C3 /* CCComAttribute.cpp in Sources */, + 3E9D30DF19195B22008EB309 /* CCVertexAttribBind.cpp in Sources */, 1A8C59BF180E930E00EF57C3 /* CCComAudio.cpp in Sources */, 1A8C59C3180E930E00EF57C3 /* CCComController.cpp in Sources */, 2905FA5218CF08D100240AA3 /* UIImageView.cpp in Sources */, @@ -6692,6 +6703,7 @@ 1A01C68B18F57BE800EFE3A6 /* CCDeprecated.cpp in Sources */, 1AD71EBE180E26E600808F54 /* CCSkeletonAnimation.cpp in Sources */, 500DC94119106300007B91BF /* CCData.cpp in Sources */, + 3E9D30E019195B22008EB309 /* CCVertexAttribBind.cpp in Sources */, 50FCEBBC18C72017004AD434 /* TextBMFontReader.cpp in Sources */, 500DC8BB19105D41007B91BF /* CCQuadCommand.cpp in Sources */, 1AD71EC2180E26E600808F54 /* extension.cpp in Sources */, diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index fd8a5a91fe..80d7318ac3 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -90,6 +90,7 @@ GLProgram::GLProgram() , _flags() { memset(_uniforms, 0, sizeof(_uniforms)); + _programDate = new GLProgramData(); } GLProgram::~GLProgram() @@ -114,6 +115,8 @@ GLProgram::~GLProgram() free(current_element->value); free(current_element); } + + CC_SAFE_DELETE(_programDate); } bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) @@ -205,6 +208,200 @@ bool GLProgram::initWithFilenames(const std::string &vShaderFilename, const std: return initWithByteArrays(vertexSource.c_str(), fragmentSource.c_str()); } + + +void GLProgram::setUniformsForUserDef() +{ + Director* director = Director::getInstance(); + CCASSERT(nullptr != director, "Director is null when seting matrix stack"); + + Matrix matrixMV; + matrixMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); + + Matrix matrixP = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + +} + + +void GLProgram::setVertexAttrib(const GLvoid* vertex) +{ + GLint vertexsize = _programDate->getVertexSize(); + for(unsigned int i = 0, count = _programDate->getAttribCount(); i < count; ++i) + { + GLProgramData::VertexAttib* _attrib = _programDate->getAttrib(i); + std::string name = _attrib->_name; + GLint size = _attrib->_size; + GLenum type = _attrib->_type; + + glVertexAttribPointer(i, size, type, GL_FALSE, vertexsize, vertex); + + } + // glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 2, vertex); +} + +void GLProgram::autoParse() +{ + + // Link program + GLint status = GL_TRUE; + glLinkProgram(_program); + + // Delete shaders after linking + if (_vertShader) + { + glDeleteShader(_vertShader); + } + + if (_fragShader) + { + glDeleteShader(_fragShader); + } + + _vertShader = _fragShader = 0; + + // Query and store vertex attribute meta-data from the program. + GLint activeAttributes; + GLint length; + glGetProgramiv(_program, GL_ACTIVE_ATTRIBUTES, &activeAttributes); + if(activeAttributes > 0) + { + glGetProgramiv(_program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); + if(length > 0) + { + GLchar* attribName = new GLchar[length + 1]; + GLint attribSize; + GLenum attribType; + GLint attribLocation; + GLint vertexsize = 0; + + for(int i = 0; i < activeAttributes; ++i) + { + // Query attribute info. + glGetActiveAttrib(_program, i, length, NULL, &attribSize, &attribType, attribName); + attribName[length] = '\0'; + + // Query the pre-assigned attribute location + attribLocation = glGetAttribLocation(_program, attribName); + std::string name = attribName; + + GLuint size; + switch (attribType) { + case GL_FLOAT: + size = 1; + attribType = GL_FLOAT; + break; + case GL_FLOAT_VEC2: + attribType = GL_FLOAT; + size = 2; + break; + case GL_FLOAT_VEC3: + attribType = GL_FLOAT; + size = 3; + break; + case GL_FLOAT_VEC4: + attribType = GL_FLOAT; + size = 4; + break; + case GL_FLOAT_MAT4: + attribType = GL_FLOAT; + size = 16; + break; + case GL_INT: + size = 1; + attribType = GL_INT; + break; + case GL_INT_VEC2: + size = 2; + attribType = GL_INT; + break; + case GL_INT_VEC3: + size = 3; + attribType = GL_INT; + break; + case GL_INT_VEC4: + size = 4; + attribType = GL_INT; + break; + default: + size = 1; + break; + } + + GLProgramData::_VertexAttib* attrib = new GLProgramData::_VertexAttib(); + attrib->_name = name; + attrib->_size = size; + attrib->_type = attribType; + attrib->_index = attribLocation; + vertexsize +=size; + + + _programDate->addAttrib(name, attrib); + + //_user_vertAttributes[attribName] = attribLocation; + + } + _programDate->setVertexSize(vertexsize); + CC_SAFE_DELETE_ARRAY(attribName); + } + } + + // Query and store uniforms from the program. + GLint activeUniforms; + glGetProgramiv(_program, GL_ACTIVE_UNIFORMS, &activeUniforms); + if(activeUniforms > 0) + { + glGetProgramiv(_program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &length); + if(length > 0) + { + GLchar* uniformName = new char[length + 1]; + GLint uniformSize; + GLenum uniformType; + GLint uniformLocation; + + unsigned int sampleIndex = 0; + for(int i = 0; i < activeUniforms; ++i) + { + // Query uniform info. + glGetActiveUniform(_program, i, length, NULL, &uniformSize, &uniformType, uniformName); + uniformName[length] = '\0'; + + if(uniformSize > 1 && length > 3) + { + char* c = strrchr(uniformName, '['); + if(c) + { + *c = '\0'; + } + } + + uniformLocation = glGetUniformLocation(_program, uniformName); + //_user_uniforms[uniformName] = uniformLocation; + std::string name = uniformName; + GLProgramData::_Uniform* uniform = new GLProgramData::_Uniform(); + + uniform->_location = uniformLocation; + uniform->_name = uniformName; + uniform->_size = uniformSize; + uniform->_type = uniformType; + + UniformValue* uniformvalue = new UniformValue(); + uniform->_uniformvalue = uniformvalue; + uniformvalue->init(this, uniform); + + _programDate->addUniform(name, uniform); + } + CC_SAFE_DELETE_ARRAY(uniformName); + } + } +} + +UniformValue* GLProgram::getUniformValue(const std::string &name) +{ + GLProgramData::Uniform* uniform = _programDate->getUniform(name); + return uniform->_uniformvalue; +} + + std::string GLProgram::getDescription() const { return StringUtils::format("::iterator itr = _uniforms.begin(); itr != _uniforms.end(); itr++) + { + CC_SAFE_DELETE(itr->second); + } + + for(std::map::iterator itr = _vertAttributes.begin(); itr != _vertAttributes.end(); itr++) + { + CC_SAFE_DELETE(itr->second); + } +} + +void GLProgramData::addUniform(std::string &name, Uniform* uniform) +{ + _uniforms[name] = uniform; +} + +void GLProgramData::addAttrib(std::string &name, VertexAttib* attrib) +{ + _vertAttributes[name] = attrib; +} + +GLProgramData::Uniform* GLProgramData::getUniform(unsigned int index) +{ + unsigned int i = 0; + for (std::map::const_iterator itr = _uniforms.begin(); itr != _uniforms.end(); itr++, i++) + { + if (i == index) + { + return itr->second; + } + } + return NULL; +} + +GLProgramData::Uniform* GLProgramData::getUniform(const std::string& name) +{ + std::map::const_iterator itr = _uniforms.find(name); + if(itr != _uniforms.end()) + return itr->second; + else + return NULL; +} + +GLProgramData::VertexAttib* GLProgramData::getAttrib(unsigned int index) +{ + unsigned int i = 0; + for (std::map::const_iterator itr = _vertAttributes.begin(); itr != _vertAttributes.end(); itr++, i++) + { + if (i == index) + { + return itr->second; + } + } + return NULL; +} + +std::vector GLProgramData::getVertexAttributes(const std::string* attrNames, int count) +{ + std::vector attribs; + for (auto i = 0; i < count; i++) { + auto it = _vertAttributes.find(attrNames[i]); + CCASSERT(it != _vertAttributes.end(), "attribute not find"); + attribs.push_back(it->second); + } + return attribs; +} + +unsigned int GLProgramData::getUniformCount() +{ + return _uniforms.size(); +} + +unsigned int GLProgramData::getAttribCount() +{ + return _vertAttributes.size(); +} + + +UniformValue::UniformValue(): _uniform(nullptr), _program(nullptr) +{ + +} + +UniformValue::~UniformValue() +{ +} + +bool UniformValue::init(GLProgram* program, GLProgramData::Uniform* uniform) +{ + _program = program; + _uniform = uniform; + return program && program && uniform->_location != -1; +} + +bool UniformValue::setValue(float value) +{ + CCASSERT (_uniform && _uniform->_type == GL_FLOAT, ""); + _program->setUniformLocationWith1f(_uniform->_location, value); + + return true; +} + +bool UniformValue::setValue(int value) +{ + CCASSERT (_uniform && (_uniform->_type == GL_INT || _uniform->_type == GL_SAMPLER_2D), ""); + _program->setUniformLocationWith1i(_uniform->_location, value); + + return true; +} + +bool UniformValue::setValue(const Vector2& value) +{ + CCASSERT (_uniform && _uniform->_type == GL_FLOAT_VEC2, ""); + _program->setUniformLocationWith2f(_uniform->_location, value.x, value.y); + + return true; +} + +bool UniformValue::setValue(const Vector3& value) +{ + CCASSERT (_uniform && _uniform->_type == GL_FLOAT_VEC3, ""); + _program->setUniformLocationWith3f(_uniform->_location, value.x, value.y, value.z); + + return true; +} + +bool UniformValue::setValue(const Vector4& value) +{ + CCASSERT (_uniform && _uniform->_type == GL_FLOAT_VEC4, ""); + _program->setUniformLocationWith4f(_uniform->_location, value.x, value.y, value.z, value.w); + + return true; +} + +bool UniformValue::setValue(const Matrix& value) +{ + CCASSERT(_uniform && _uniform->_type == GL_FLOAT_MAT4, ""); + _program->setUniformLocationWithMatrix4fv(_uniform->_location, value.m, 1); + + return true; +} + +bool UniformValue::setValue(const Vector2* value, int count) +{ + CCASSERT (_uniform && _uniform->_type == GL_FLOAT_VEC2 && _uniform->_size == count, ""); + GLfloat* array = new GLfloat[count * 2]; + for (auto i = 0; i < count; i++) { + array[2*i] = value[i].x; + array[2*i + 1] = value[i].y; + } + _program->setUniformLocationWith2fv(_uniform->_location, array, count); + delete[] array; + return true; +} + +bool UniformValue::setValue(const Vector3* value, int count) +{ + CCASSERT (_uniform && _uniform->_type == GL_FLOAT_VEC3 && _uniform->_size == count, ""); + GLfloat* array = new GLfloat[count * 3]; + for (auto i = 0; i < count; i++) { + array[3*i] = value[i].x; + array[3*i + 1] = value[i].y; + array[3*i + 2] = value[i].z; + } + _program->setUniformLocationWith3fv(_uniform->_location, array, count); + delete[] array; + return true; +} + +bool UniformValue::setValue(const Vector4* value, int count) +{ + CCASSERT (_uniform && _uniform->_type == GL_FLOAT_VEC4 && _uniform->_size == count, ""); + GLfloat* array = new GLfloat[count * 4]; + for (auto i = 0; i < count; i++) { + array[4*i] = value[i].x; + array[4*i + 1] = value[i].y; + array[4*i + 2] = value[i].z; + array[4*i + 3] = value[i].w; + } + _program->setUniformLocationWith4fv(_uniform->_location, array, count); + delete[] array; + return true; +} + +bool UniformValue::setValue(const Matrix* value, int count) +{ + CCASSERT (_uniform && _uniform->_type == GL_FLOAT_MAT4 && _uniform->_size == count, ""); + GLfloat* array = new GLfloat[count * 16]; + for (auto i = 0; i < count; i++) { + memcpy(&array[i * 16], value[i].m, 16 * sizeof(GLfloat)); + } + _program->setUniformLocationWithMatrix4fv(_uniform->_location, array, count); + delete[] array; + return true; +} + NS_CC_END diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index 5cd493cfdd..9aaddacc22 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -46,6 +46,8 @@ USING_NS_CC_MATH; */ struct _hashUniformEntry; +class GLProgramData; +class UniformValue; typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params); typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); @@ -146,6 +148,15 @@ public: * @lua init */ bool initWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename); + + //void bindAttirbForUserdef(); + void setUniformsForUserDef(); + void setVertexAttrib(const GLvoid* vertex); + void autoParse(); + + //void bindUniformValue(std::string uniformName, int value); + UniformValue* getUniformValue(const std::string &name); + /** It will add a new attribute to the shader by calling glBindAttribLocation */ void bindAttribLocation(const char* attributeName, GLuint index) const; @@ -259,7 +270,9 @@ public: void reset(); inline const GLuint getProgram() const { return _program; } + + GLProgramData* getProgramData() { return _programDate; } // DEPRECATED CC_DEPRECATED_ATTRIBUTE bool initWithVertexShaderByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) { return initWithByteArrays(vShaderByteArray, fShaderByteArray); } @@ -274,13 +287,19 @@ private: bool compileShader(GLuint * shader, GLenum type, const GLchar* source); std::string logForOpenGLObject(GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc) const; -private: +protected: GLuint _program; + +private: + GLuint _vertShader; GLuint _fragShader; GLint _uniforms[UNIFORM_MAX]; struct _hashUniformEntry* _hashForUniforms; bool _hasShaderCompiler; + + GLProgramData* _programDate; + #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) std::string _shaderId; #endif @@ -302,6 +321,92 @@ public: // end of shaders group /// @} + +/** GLProgramData + Class store user defined vertexAttributes and uniforms + */ +class GLProgramData +{ +public: + typedef struct _VertexAttib + { + GLuint _index; + GLint _size; + GLenum _type; + std::string _name; + } VertexAttib; + + typedef struct _Uniform + { + GLint _location; + GLint _size; + std::string _name; + GLenum _type; + UniformValue* _uniformvalue; + } Uniform; + +public: + GLProgramData(); + ~GLProgramData(); + + + void addUniform(std::string &name, Uniform* uniform); + void addAttrib(std::string &name, VertexAttib* attrib); + + Uniform* getUniform(unsigned int index); + Uniform* getUniform(const std::string& name); + VertexAttib* getAttrib(unsigned int index); + + std::vector getVertexAttributes(const std::string* attrNames, int count); + + unsigned int getUniformCount(); + unsigned int getAttribCount(); + + void setVertexSize(GLint size) { _vertexsize = size;} + GLint getVertexSize() {return _vertexsize;} + +private: + GLint _vertexsize; + + std::map _uniforms; + std::map _vertAttributes; +}; + + +class UniformValue +{ +public: + UniformValue(); + ~UniformValue(); + + bool init(GLProgram* program, GLProgramData::Uniform* uniform); + + bool setValue(float value); + + bool setValue(int value); + + bool setValue(const Vector2& value); + + bool setValue(const Vector3& value); + + bool setValue(const Vector4& value); + + bool setValue(const Matrix& value); + + bool setValue(const Vector2* value, int count); + + bool setValue(const Vector3* value, int count); + + bool setValue(const Vector4* value, int count); + + bool setValue(const Matrix* value, int count); + +protected: + GLProgram* _program; + GLProgramData::Uniform* _uniform; +}; + + NS_CC_END #endif /* __CCGLPROGRAM_H__ */ diff --git a/cocos/2d/CCVertexAttribBind.cpp b/cocos/2d/CCVertexAttribBind.cpp new file mode 100644 index 0000000000..eea0f51b3f --- /dev/null +++ b/cocos/2d/CCVertexAttribBind.cpp @@ -0,0 +1,118 @@ + + +#include "base/CCDirector.h" +#include "2d/CCVertexAttribBind.h" +#include "2d/ccGLStateCache.h" +#include "base/ccMacros.h" +#include "2d/platform/CCFileUtils.h" +#include "2d/uthash.h" +#include "deprecated/CCString.h" + +NS_CC_BEGIN + +VertexAttribType::VertexAttribType(): _type(GL_FLOAT), _size(0), _location(-1), _offset(0) +{ +} +VertexAttribType::VertexAttribType(GLenum type, int size): _type(type), _size(size), _location(-1), _offset(0) +{ + switch (type) { + case GL_FLOAT_VEC2: + _type = GL_FLOAT; + _size = 2; + break; + case GL_FLOAT_VEC3: + _type = GL_FLOAT; + _size = 3; + break; + case GL_FLOAT_VEC4: + _type = GL_FLOAT; + _size = 4; + break; + + default: + break; + } +} + + +int VertexAttribType::getByteSize() +{ + int byteSize = 0; + switch (_type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + byteSize = _size; + break; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + byteSize = _size * sizeof(GLshort); + break; + case GL_FLOAT: + byteSize = _size * sizeof(GLfloat); + break; + default: + CCASSERT(0,"type error"); + break; + } + return byteSize; +} + +VertexAttribBind::VertexAttribBind(const VertexAttribType* elem, int count) +{ + setVertexAttribElems(elem, count); +} + +VertexAttribBind::VertexAttribBind(const std::vector& elems) +{ + setVertexAttribElems(&elems[0], elems.size()); +} + +VertexAttribBind::VertexAttribBind(const std::vector& attribs) +{ + std::vector elems; + for (auto it = attribs.begin(); it != attribs.end(); it++) { + VertexAttribType type((*it)->_type, (*it)->_size); + type._location = (*it)->_index; + elems.push_back(type); + } + setVertexAttribElems(&elems[0], elems.size()); +} + +VertexAttribBind::~VertexAttribBind() +{ + delete[] _vertexAttribs; +} + +void VertexAttribBind::bindAttribute(int index, int attribLocation) +{ + //make sure index and attribute location are validate + _vertexAttribs[index]._location = attribLocation; +} + +//bind attributes pointer +void VertexAttribBind::bindAttributePtr(void* vertexPointer) +{ + for (auto i = 0; i < _vertexAtttribCount; i++) { + auto elem = _vertexAttribs[i]; + if (elem._location != -1) + { + glEnableVertexAttribArray(elem._location); + void* pointer = vertexPointer ? (void*)(((unsigned char*)vertexPointer) + elem._offset) : (void*)elem._offset; + glVertexAttribPointer(elem._location, elem._size, elem._type, GL_FALSE, _stride, pointer); + } + } +} + +void VertexAttribBind::setVertexAttribElems(const VertexAttribType* elem, int count) +{ + _vertexAtttribCount = count; + _vertexAttribs = new VertexAttribType[count]; + _stride = 0; + for (auto i = 0; i < count; i++) { + _vertexAttribs[i] = elem[i]; + _vertexAttribs[i]._offset = _stride; + _stride += _vertexAttribs[i].getByteSize(); + } +} + +NS_CC_END diff --git a/cocos/2d/CCVertexAttribBind.h b/cocos/2d/CCVertexAttribBind.h new file mode 100644 index 0000000000..257dd5cf9e --- /dev/null +++ b/cocos/2d/CCVertexAttribBind.h @@ -0,0 +1,72 @@ +/**************************************************************************** + +****************************************************************************/ + +#ifndef __CCVRETEXATTRIBBIND_H__ +#define __CCVRETEXATTRIBBIND_H__ + +#include "base/ccMacros.h" +#include "base/CCRef.h" +#include "CCGL.h" +#include "math/CCMath.h" +#include "2d/CCGLProgram.h" +#include + +NS_CC_BEGIN + +USING_NS_CC_MATH; + +////vertex attribute///// +class VertexAttribType +{ + friend class VertexAttribBind; + friend class GLProgram; +public: + VertexAttribType(); + + VertexAttribType(GLenum type, int size); + + int getByteSize(); + +protected: + GLenum _type; + int _size; + int _location; + int _offset; +}; + +////vertex attributes bind +class VertexAttribBind +{ +public: + VertexAttribBind(const VertexAttribType* elem, int count); + + VertexAttribBind(const std::vector& elems); + + VertexAttribBind(const std::vector& attribs); + + virtual ~VertexAttribBind(); + + /** + * bind vertex attributes. + * + * @param index Position in _vertexAttribs + * @param attribLocation location in shader. It can be queried from GLProgram, eg. program->getAttribLocation("a_position") + */ + void bindAttribute(int index, int attribLocation); + + /**bind attributes pointer**/ + void bindAttributePtr(void* vertexPointer = nullptr); + +protected: + + void setVertexAttribElems(const VertexAttribType* elem, int count); + + VertexAttribType* _vertexAttribs; + int _vertexAtttribCount; + int _stride; +}; + +NS_CC_END + +#endif /* __CCVRETEXATTRIBBIND_H__ */ From 720852681e35cdaf037b1a74796bba47995fa4ba Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 6 May 2014 11:15:40 -0700 Subject: [PATCH 003/174] Adds license to VertexAttribBind --- cocos/2d/CCVertexAttribBind.cpp | 22 ++++++++++++++++++++++ cocos/2d/CCVertexAttribBind.h | 22 +++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCVertexAttribBind.cpp b/cocos/2d/CCVertexAttribBind.cpp index eea0f51b3f..03b8685b3b 100644 --- a/cocos/2d/CCVertexAttribBind.cpp +++ b/cocos/2d/CCVertexAttribBind.cpp @@ -1,4 +1,26 @@ +/**************************************************************************** + Copyright 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 false 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/CCDirector.h" #include "2d/CCVertexAttribBind.h" diff --git a/cocos/2d/CCVertexAttribBind.h b/cocos/2d/CCVertexAttribBind.h index 257dd5cf9e..962f9ffb8e 100644 --- a/cocos/2d/CCVertexAttribBind.h +++ b/cocos/2d/CCVertexAttribBind.h @@ -1,6 +1,26 @@ /**************************************************************************** + Copyright 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 false 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 __CCVRETEXATTRIBBIND_H__ #define __CCVRETEXATTRIBBIND_H__ From 69fd841b306df3664d0cee4e715a7c5fbc2e1891 Mon Sep 17 00:00:00 2001 From: Trace Date: Tue, 6 May 2014 11:19:51 -0700 Subject: [PATCH 004/174] fix the include error --- cocos/2d/CCGLProgram.cpp | 540 +++++++++++++++++- cocos/2d/CCGLProgram.h | 130 ++++- .../Classes/ShaderTest/ShaderTest.cpp | 2 + .../Classes/ShaderTest/ShaderTest2.cpp | 255 ++++++++- .../Classes/ShaderTest/ShaderTest2.h | 24 + .../Resources/Shaders/example_normal.vsh | 20 + 6 files changed, 965 insertions(+), 6 deletions(-) create mode 100644 tests/cpp-tests/Resources/Shaders/example_normal.vsh diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index fd8a5a91fe..d17c26df40 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -33,6 +33,7 @@ THE SOFTWARE. #include "2d/platform/CCFileUtils.h" #include "2d/uthash.h" #include "deprecated/CCString.h" +#include "CCGL.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) #include "CCPrecompiledShaders.h" @@ -88,8 +89,10 @@ GLProgram::GLProgram() , _fragShader(0) , _hashForUniforms(nullptr) , _flags() +,_isTight(false) { memset(_uniforms, 0, sizeof(_uniforms)); + _programData = new GLProgramData(); } GLProgram::~GLProgram() @@ -114,6 +117,8 @@ GLProgram::~GLProgram() free(current_element->value); free(current_element); } + + CC_SAFE_DELETE(_programData); } bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) @@ -205,6 +210,256 @@ bool GLProgram::initWithFilenames(const std::string &vShaderFilename, const std: return initWithByteArrays(vertexSource.c_str(), fragmentSource.c_str()); } +void GLProgram::setUniformsForUserDef() +{ + Director* director = Director::getInstance(); + CCASSERT(nullptr != director, "Director is null when seting matrix stack"); + + Matrix matrixMV; + matrixMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); + + Matrix matrixP = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + + // Set Uniform value + + for(unsigned int i = 0, count = _programData->getUniformCount(); i < count; ++i) + { + _programData->getUniform(i)->_uniformvalue->bindUniform(this); + } +} + +void GLProgram::setAttribForUserDef() +{ + for(unsigned int i = 0, count = _programData->getAttribCount(); i < count; ++i) + { + GLProgramData::VertexAttrib* attrib = _programData->getAttrib(i); + if(i == 0) + { + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); + } + else if(attrib->_type == GL_FLOAT_VEC4) + { + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); + } + else if(attrib->_type == GL_FLOAT_VEC2) + { + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); + } + } +} + +// have some questions. +void GLProgram::setVertexAttrib(const GLvoid* vertex, bool isTight) +{ + static GLint vertexsize = 0; + if(vertexsize == 0) + { + for(unsigned int i = 0, count = _programData->getAttribCount(); i < count; ++i) + { + GLProgramData::VertexAttrib* _attrib = _programData->getAttrib(i); + + if(_attrib->_type == GL_UNSIGNED_BYTE) + vertexsize += _attrib->_size ; + else + vertexsize += _attrib->_size * 4; + } + } + if(isTight) + vertexsize = 0; + + size_t offset = 0; + for(unsigned int i = 0, count = _programData->getAttribCount(); i < count; ++i) + { + + GLProgramData::VertexAttrib* _attrib = _programData->getAttrib(i); + std::string name = _attrib->_name; + GLint size = _attrib->_size; + GLenum type = _attrib->_type; + bool normalized = GL_FALSE; + + glVertexAttribPointer(i, size, type, normalized, vertexsize, (size_t*)(vertex)+ offset); + if(_attrib->_type != GL_UNSIGNED_BYTE) + offset += size * 4 ; + else + offset += size; + } +} + +void GLProgram::autoParse() +{ + // Link program + GLint status = GL_TRUE; + glLinkProgram(_program); + + // Delete shaders after linking + if (_vertShader) + { + glDeleteShader(_vertShader); + } + + if (_fragShader) + { + glDeleteShader(_fragShader); + } + + _vertShader = _fragShader = 0; + + // Query and store vertex attribute meta-data from the program. + GLint activeAttributes; + GLint length; + glGetProgramiv(_program, GL_ACTIVE_ATTRIBUTES, &activeAttributes); + if(activeAttributes > 0) + { + glGetProgramiv(_program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); + if(length > 0) + { + GLchar* attribName = new GLchar[length + 1]; + GLint attribSize; + GLenum attribType; + GLint attribLocation; + GLint vertexsize = 0; + + for(int i = 0; i < activeAttributes; ++i) + { + // Query attribute info. + glGetActiveAttrib(_program, i, length, NULL, &attribSize, &attribType, attribName); + attribName[length] = '\0'; + + // Query the pre-assigned attribute location + attribLocation = glGetAttribLocation(_program, attribName); + std::string name = attribName; + + GLuint size; + switch (attribType) { + case GL_FLOAT: + size = 1; + attribType = GL_FLOAT; + break; + case GL_FLOAT_VEC2: + attribType = GL_FLOAT; + size = 2; + break; + case GL_FLOAT_VEC3: + attribType = GL_FLOAT; + size = 3; + break; + case GL_FLOAT_VEC4: + attribType = GL_FLOAT; + size = 4; + break; + case GL_FLOAT_MAT4: + attribType = GL_FLOAT; + size = 16; + break; + case GL_INT: + size = 1; + attribType = GL_INT; + break; + case GL_INT_VEC2: + size = 2; + attribType = GL_INT; + break; + case GL_INT_VEC3: + size = 3; + attribType = GL_INT; + break; + case GL_INT_VEC4: + size = 4; + attribType = GL_INT; + break; + default: + size = 1; + break; + } + + GLProgramData::_VertexAttrib* attrib = new GLProgramData::_VertexAttrib(); + attrib->_name = name; + attrib->_size = size; + attrib->_type = attribType; + attrib->_index = i; + //vertexsize +=size; + + _programData->addAttrib(name, attrib); + + //_user_vertAttributes[attribName] = attribLocation; + // bindAttribLocation(attribName,attribLocation); + } + CC_SAFE_DELETE_ARRAY(attribName); + } + } + + // Query and store uniforms from the program. + GLint activeUniforms; + glGetProgramiv(_program, GL_ACTIVE_UNIFORMS, &activeUniforms); + if(activeUniforms > 0) + { + glGetProgramiv(_program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &length); + if(length > 0) + { + GLchar* uniformName = new char[length + 1]; + GLint uniformSize; + GLenum uniformType; + GLint uniformLocation; + + unsigned int sampleIndex = 0; + for(int i = 0; i < activeUniforms; ++i) + { + // Query uniform info. + glGetActiveUniform(_program, i, length, NULL, &uniformSize, &uniformType, uniformName); + uniformName[length] = '\0'; + + if(uniformSize > 1 && length > 3) + { + char* c = strrchr(uniformName, '['); + if(c) + { + *c = '\0'; + } + } + + uniformLocation = glGetUniformLocation(_program, uniformName); + //_user_uniforms[uniformName] = uniformLocation; + std::string name = uniformName; + GLProgramData::_Uniform* uniform = new GLProgramData::_Uniform(); + + uniform->_location = uniformLocation; + uniform->_name = uniformName; + uniform->_size = uniformSize; + uniform->_type = uniformType; + + UniformValue* uniformvalue = new UniformValue(); + uniform->_uniformvalue = uniformvalue; + uniformvalue->init(uniform); + + _programData->addUniform(name, uniform); + } + CC_SAFE_DELETE_ARRAY(uniformName); + } + } + + for(unsigned int i = 0, count = _programData->getAttribCount(); i < count; ++i) + { + GLProgramData::VertexAttrib* _attrib = _programData->getAttrib(i); + std::string name = _attrib->_name; + GLint attribLocation = getAttribLocation(name.c_str()); + bindAttribLocation( name.c_str(),attribLocation); + } + +} + +UniformValue* GLProgram::getUniform(std::string &name) +{ + GLProgramData::Uniform* uniform = _programData->getUniform(name); + return uniform->_uniformvalue; +} + +GLProgramData::VertexAttrib* GLProgram::getAttrib(std::string &name) +{ + GLProgramData::VertexAttrib* attrib = _programData->getAttrib(name); + return attrib; +} + + std::string GLProgram::getDescription() const { return StringUtils::format("::iterator itr = _uniforms.begin(); itr != _uniforms.end(); itr++) + { + CC_SAFE_DELETE(itr->second); + } + + for(std::map::iterator itr = _vertAttributes.begin(); itr != _vertAttributes.end(); itr++) + { + CC_SAFE_DELETE(itr->second); + } +} + +void GLProgramData::addUniform(std::string &name, Uniform* uniform) +{ + _uniforms[name] = uniform; +} + +void GLProgramData::addAttrib(std::string &name, VertexAttrib* attrib) +{ + _vertAttributes[name] = attrib; +} + +GLProgramData::Uniform* GLProgramData::getUniform(unsigned int index) +{ + unsigned int i = 0; + for (std::map::const_iterator itr = _uniforms.begin(); itr != _uniforms.end(); itr++, i++) + { + if (i == index) + { + return itr->second; + } + } + return NULL; +} + +GLProgramData::Uniform* GLProgramData::getUniform(std::string& name) +{ + std::map::const_iterator itr = _uniforms.find(name); + if(itr != _uniforms.end()) + return itr->second; + else + return NULL; +} + +GLProgramData::VertexAttrib* GLProgramData::getAttrib(unsigned int index) +{ + //unsigned int i = 0; + for (std::map::const_iterator itr = _vertAttributes.begin(); itr != _vertAttributes.end(); itr++) + { + if (itr->second->_index == index) + { + return itr->second; + } + } + return NULL; +} + +GLProgramData::VertexAttrib* GLProgramData::getAttrib(std::string& name) +{ + std::map::const_iterator itr = _vertAttributes.find(name); + if(itr != _vertAttributes.end()) + return itr->second; + else + return NULL; +} + +unsigned int GLProgramData::getUniformCount() +{ + return _uniforms.size(); +} + +unsigned int GLProgramData::getAttribCount() +{ + return _vertAttributes.size(); +} + + +UniformValue::UniformValue(): _count(0),_type(UniformValue::NONE),_update(false) +{ + +} + +UniformValue::~UniformValue() +{ + resetValue(); +} + +bool UniformValue::init(GLProgramData::Uniform* uniform) +{ + resetValue(); + _uniform = uniform; + return true; +} + +void UniformValue::bindUniform(GLProgram* program) +{ + switch(_type){ + case UniformValue::FLOAT: + program->setUniformLocationWith1f(_uniform->_location, *_value.floatPtrValue); + break; + case UniformValue::INT: + program->setUniformLocationWith1i(_uniform->_location, *_value.intPtrValue); + break; + case UniformValue::VECTOR2: + program->setUniformLocationWith2f(_uniform->_location, _value.vec2PtrValue->x, _value.vec2PtrValue->y); + break; + case UniformValue::VECTOR3: + program->setUniformLocationWith3f(_uniform->_location, _value.vec3PtrValue->x, _value.vec3PtrValue->y, _value.vec3PtrValue->z); + break; + case UniformValue::VECTOR4: + program->setUniformLocationWith4f(_uniform->_location, _value.vec4PtrValue->x, _value.vec4PtrValue->y, _value.vec4PtrValue->z, _value.vec4PtrValue->w); + break; + case UniformValue::MATRIX: + program->setUniformLocationWithMatrix4fv(_uniform->_location, _value.matPtrValue->m, _count); + break; + default: + break; + } +} + +bool UniformValue::setValue(float value) +{ + _update = false; + if(*(_value.floatPtrValue) == value) + return true; + + if(_uniform && _uniform->_type == GL_FLOAT) + { + _count = 1; + _type = UniformValue::FLOAT; + if(_value.floatPtrValue == nullptr) + _value.floatPtrValue = new float[_count]; + + *(_value.floatPtrValue) = value; + _update = true; + return true; + } + return false; +} + +bool UniformValue::setValue(int value) +{ + _update = false; + if(_value.intPtrValue != nullptr) + if(*(_value.intPtrValue) == value) + return true; + + if(_uniform && _uniform->_type == GL_INT) + { + _count = 1; + _type = UniformValue::INT; + if(_value.floatPtrValue == nullptr) + _value.floatPtrValue = new float[_count]; + + *(_value.floatPtrValue) = value; + _update = true; + return true; + } + return false; +} + +bool UniformValue::setValue(const Vector2& value) +{ + _update = false; + if(_value.vec2PtrValue != nullptr) + if(*(_value.vec2PtrValue) == value) + return true; + + if(_uniform && _uniform->_type == GL_FLOAT_VEC2) + { + _count = 1; + _type = UniformValue::VECTOR2; + if(_value.vec2PtrValue == nullptr) + _value.vec2PtrValue = new Vector2[_count]; + + *(_value.vec2PtrValue) = value; + return true; + } + return false; +} + +bool UniformValue::setValue(const Vector3& value) +{ + _update = false; + if(_value.vec3PtrValue != nullptr) + if(*(_value.vec3PtrValue) == value) + return true; + + if(_uniform && _uniform->_type == GL_FLOAT_VEC3) + { + _count = 1; + _type = UniformValue::VECTOR3; + if(_value.vec3PtrValue == nullptr) + _value.vec3PtrValue = new Vector3[_count]; + + *(_value.vec3PtrValue) = value; + return true; + } + return false; +} + +bool UniformValue::setValue(const Vector4& value) +{ + _update = false; + if(_value.vec4PtrValue != nullptr) + if(*(_value.vec4PtrValue) == value) + return true; + + if(_uniform && _uniform->_type == GL_FLOAT_VEC4) + { + _count = 1; + _type = UniformValue::VECTOR4; + if(_value.vec4PtrValue == nullptr) + _value.vec4PtrValue = new Vector4[_count]; + + *(_value.vec4PtrValue) = value; + return true; + } + return false; +} + +bool UniformValue::setValue(const Matrix& value) +{ + _update = false; + // if(_value.matPtrValue != nullptr) + // if(*(_value.matPtrValue) == value) + // return true; + + if(_uniform && _uniform->_type == GL_FLOAT_MAT4) + { + _count = 1; + _type = UniformValue::MATRIX; + if(_value.matPtrValue == nullptr) + _value.matPtrValue = new Matrix[_count]; + + *(_value.matPtrValue) = value; + return true; + } + return false; +} + +void UniformValue::resetValue() +{ + switch(_type) + { + case UniformValue::FLOAT : + CC_SAFE_DELETE(_value.floatPtrValue); + break; + case UniformValue::INT: + CC_SAFE_DELETE(_value.intPtrValue); + break; + case UniformValue::VECTOR2: + CC_SAFE_DELETE(_value.vec2PtrValue); + break; + case UniformValue::VECTOR3: + CC_SAFE_DELETE(_value.vec3PtrValue); + break; + case UniformValue::VECTOR4: + CC_SAFE_DELETE(_value.vec4PtrValue); + break; + case UniformValue::MATRIX: + CC_SAFE_DELETE(_value.matPtrValue); + break; + default: + break; + } + + memset(&_value,0, sizeof(_value)); + _count = 0; + _type = UniformValue::NONE; +} + NS_CC_END diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index 5cd493cfdd..083d1d65c7 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -46,10 +46,65 @@ USING_NS_CC_MATH; */ struct _hashUniformEntry; +class GLProgramData; +class UniformValue; +struct VertexAttrib; typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params); typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); + + +/** GLProgramData + Class store user defined vertexAttributes and uniforms + */ +class GLProgramData +{ +public: + typedef struct _VertexAttrib + { + GLuint _index; + GLint _size; + GLenum _type; + std::string _name; + } VertexAttrib; + + typedef struct _Uniform + { + GLint _location; + GLint _size; + std::string _name; + GLenum _type; + UniformValue* _uniformvalue; + } Uniform; + +public: + GLProgramData(); + ~GLProgramData(); + + + void addUniform(std::string &name, Uniform* uniform); + void addAttrib(std::string &name, VertexAttrib* attrib); + + Uniform* getUniform(unsigned int index); + Uniform* getUniform(std::string& name); + VertexAttrib* getAttrib(unsigned int index); + VertexAttrib* getAttrib(std::string& name); + + unsigned int getUniformCount(); + unsigned int getAttribCount(); + + void setVertexSize(GLint size) { _vertexsize = size;} + GLint getVertexSize() {return _vertexsize;} + +private: + GLint _vertexsize; + + std::map _uniforms; + std::map _vertAttributes; +}; + + /** GLProgram Class that implements a glProgram @@ -146,6 +201,18 @@ public: * @lua init */ bool initWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename); + + //void bindAttirbForUserdef(); + void setUniformsForUserDef(); + void setAttribForUserDef(); + void setVertexAttrib(const GLvoid* vertex, bool isTight); + void autoParse(); + + //void bindUniformValue(std::string uniformName, int value); + UniformValue* getUniform(std::string &name); + GLProgramData::VertexAttrib* getAttrib(std::string& name); + + void bindAllAttrib(); /** It will add a new attribute to the shader by calling glBindAttribLocation */ void bindAttribLocation(const char* attributeName, GLuint index) const; @@ -274,13 +341,20 @@ private: bool compileShader(GLuint * shader, GLenum type, const GLchar* source); std::string logForOpenGLObject(GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc) const; -private: +protected: GLuint _program; + +private: + GLuint _vertShader; GLuint _fragShader; GLint _uniforms[UNIFORM_MAX]; struct _hashUniformEntry* _hashForUniforms; bool _hasShaderCompiler; + bool _isTight; + + GLProgramData* _programData; + #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) std::string _shaderId; #endif @@ -302,6 +376,60 @@ public: // end of shaders group /// @} + + +class UniformValue +{ +public: + UniformValue(); + ~UniformValue(); + + bool init(GLProgramData::Uniform* uniform); + + void bindUniform(GLProgram* program); + + bool setValue(float value); + + bool setValue(int value); + + bool setValue(const Vector2& value); + + bool setValue(const Vector3& value); + + bool setValue(const Vector4& value); + + bool setValue(const Matrix& value); + + void resetValue(); + +protected: + GLProgramData::Uniform* _uniform; + bool _update; + int _count; + union + { + float* floatPtrValue; + int* intPtrValue; + Vector2* vec2PtrValue; + Vector3* vec3PtrValue; + Vector4* vec4PtrValue; + Matrix* matPtrValue; + + //const Texture2D* textureValue; + }_value; + enum + { + NONE, + FLOAT, + INT, + VECTOR2, + VECTOR3, + VECTOR4, + MATRIX, + }_type; +}; + + NS_CC_END #endif /* __CCGLPROGRAM_H__ */ diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 84d925e66c..7fa1bd644c 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -1,6 +1,8 @@ #include "ShaderTest.h" #include "../testResource.h" #include "cocos2d.h" +#include "renderer/CCCustomCommand.h" +#include "renderer/CCRenderer.h" static int sceneIdx = -1; diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 7c2a4a6fea..0c338704d1 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -1,4 +1,4 @@ -#include "ShaderTest2.h" + #include "ShaderTest2.h" #include "ShaderTest.h" #include "../testResource.h" #include "cocos2d.h" @@ -9,6 +9,7 @@ namespace ShaderTest2 { static std::function createFunctions[] = { + CL(AttribShaderTest), CL(NormalSpriteTest), CL(GreyScaleSpriteTest), CL(BlurSpriteTest), @@ -17,7 +18,11 @@ namespace ShaderTest2 CL(BloomSpriteTest), CL(CelShadingSpriteTest), CL(LensFlareSpriteTest), - CL(OutlineShadingSpriteTest) + CL(OutlineShadingSpriteTest), + CL(UniformShaderTest), + + CL(UniformAttribShaderTest) + }; static unsigned int TEST_CASE_COUNT = sizeof(ShaderTest2::createFunctions) / sizeof(ShaderTest2::createFunctions[0]); @@ -693,10 +698,252 @@ OutlineShadingSpriteTest::OutlineShadingSpriteTest() if (ShaderTestDemo2::init()) { auto s = Director::getInstance()->getWinSize(); OutlineSprite* sprite = OutlineSprite::createSprite("Images/grossini_dance_10.png"); - sprite->setPosition(Vector2(s.width * 0.75, s.height/2)); + sprite->setPosition(Point(s.width * 0.75, s.height/2)); auto sprite2 = Sprite::create("Images/grossini_dance_10.png"); - sprite2->setPosition(Vector2(s.width * 0.25, s.height/2)); + sprite2->setPosition(Point(s.width * 0.25, s.height/2)); addChild(sprite); addChild(sprite2); } } + +class UniformSprite : public Sprite +{ +public: + UniformSprite(); + ~UniformSprite(); + CREATE_FUNC(UniformSprite); + + virtual void initShader(); + // void setBackgroundNotification(); + + virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + // void listenBackToForeground(Ref *obj); + +protected: +// virtual void buildCustomUniforms(); + virtual void setCustomUniforms(); +protected: + std::string _fragSourceFile; + std::string _vertSourceFile; +protected: + CustomCommand _renderCommand; + void onDraw(const Matrix &transform, bool transformUpdated); + +}; + +UniformSprite::UniformSprite() +{ + _vertSourceFile = "Shaders/example_Heart.vsh"; + _fragSourceFile = "Shaders/example_Heart.fsh"; +} + +UniformSprite::~UniformSprite() +{ + +} + +void UniformSprite::initShader() +{ + auto shader = new GLProgram(); + shader->initWithFilenames(_vertSourceFile, _fragSourceFile); + shader->autoParse(); + //shader->link(); + + shader->updateUniforms(); + + this->setShaderProgram(shader); + + std::string attribname ="a_position"; + shader->getAttrib(attribname)->_size = 2; + + shader->release(); +} + +void UniformSprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +{ + _renderCommand.init(_globalZOrder); + _renderCommand.func = CC_CALLBACK_0(UniformSprite::onDraw, this, transform, transformUpdated); + renderer->addCommand(&_renderCommand); +} + +void UniformSprite::setCustomUniforms() +{ + + std::string name = "center"; + _shaderProgram->getUniform(name)->setValue(Vector2(480,320)); + name = "resolution"; + _shaderProgram->getUniform(name)->setValue(Vector2(256,256)); + + _shaderProgram->setUniformsForUserDef(); +} + +void UniformSprite::onDraw(const Matrix &transform, bool transformUpdated) +{ + // Set Shader GLProgram + auto program = getShaderProgram(); + program->use(); + program->setUniformsForBuiltins(transform); + + setCustomUniforms(); + //GL::bindTexture2D( getTexture()->getName()); + program->setAttribForUserDef(); + + + float w = 256, h = 256; + GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h}; + program->setVertexAttrib(vertices, true); + + // Draw Call Test + glDrawArrays(GL_TRIANGLES, 0, 6); + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,6); + + CHECK_GL_ERROR_DEBUG(); +} + + +UniformShaderTest::UniformShaderTest() +{ + if (ShaderTestDemo2::init()) { + auto s = Director::getInstance()->getWinSize(); + UniformSprite* sprite = UniformSprite::create(); + setContentSize(Size(256, 256)); + setAnchorPoint(Vector2(0.5f, 0.5f)); + sprite->initShader(); + sprite->setPosition(64,64); + addChild(sprite); + } +} + + +class AttribSprite : public Sprite +{ +public: + AttribSprite(); + ~AttribSprite(); + CREATE_FUNC(AttribSprite); + + virtual void initShader(); + // void setBackgroundNotification(); + + virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + // void listenBackToForeground(Ref *obj); + +protected: + // virtual void buildCustomUniforms(); + virtual void setCustomUniforms(); +protected: + std::string _fragSourceFile; + std::string _vertSourceFile; +protected: + CustomCommand _renderCommand; + void onDraw(const Matrix &transform, bool transformUpdated); +}; + +AttribSprite::AttribSprite() +{ + _fragSourceFile = "Shaders/example_normal.fsh"; + _vertSourceFile = "Shaders/example_normal.vsh"; +} + +AttribSprite::~AttribSprite() +{ + +} + +void AttribSprite::initShader() +{ + auto shader = new GLProgram(); + shader->initWithFilenames(_vertSourceFile, _fragSourceFile); + + shader->autoParse(); + shader->updateUniforms(); + this->setShaderProgram(shader); + + shader->release(); + + std::string attribname ="a_position"; + shader->getAttrib(attribname)->_size = 3; + shader->getAttrib(attribname)->_index = 0; + + attribname ="a_color"; + shader->getAttrib(attribname)->_type = GL_UNSIGNED_BYTE; + shader->getAttrib(attribname)->_index = 1; + + attribname ="a_texCoord"; + shader->getAttrib(attribname)->_index = 2; + +} + +void AttribSprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +{ + _renderCommand.init(_globalZOrder); + _renderCommand.func = CC_CALLBACK_0(AttribSprite::onDraw, this, transform, transformUpdated); + renderer->addCommand(&_renderCommand); +} + +void AttribSprite::setCustomUniforms() +{ + + +} + +void AttribSprite::onDraw(const Matrix &transform, bool transformUpdated) +{ + + // Set Shader GLProgram + auto program = getShaderProgram(); + program->use(); + program->setUniformsForBuiltins(transform); + + setCustomUniforms(); + + // Set + //glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); + //GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); + GL::blendFunc(_blendFunc.src, _blendFunc.dst); + GL::bindTexture2D( getTexture()->getName()); + + // + // Attributes + // + #define kQuadSize sizeof(_quad.bl) + size_t offset = (size_t)&_quad; + size_t stride = kQuadSize; + /* + // vertex + int diff = offsetof( V3F_C4B_T2F, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + + // texCoods + diff = offsetof( V3F_C4B_T2F, texCoords); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); + + // color + diff = offsetof( V3F_C4B_T2F, colors); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); + */ + program->setVertexAttrib((void*)offset, false); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4); + + CHECK_GL_ERROR_DEBUG(); +} + +AttribShaderTest::AttribShaderTest() +{ + if (ShaderTestDemo2::init()) + { + auto s = Director::getInstance()->getWinSize(); + AttribSprite* sprite = AttribSprite::create(); + sprite->setTexture("Images/powered.png"); + sprite->initShader(); + sprite->setPosition(Vector2(s.width/2, s.height/2)); + addChild(sprite); + } + +} + +UniformAttribShaderTest::UniformAttribShaderTest() +{ + +} diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h index c67d701ea4..8f57487228 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h @@ -102,4 +102,28 @@ public: virtual std::string subtitle() const {return "OutlineShadingSpriteTest";} }; +class UniformShaderTest : public ShaderTestDemo2 +{ +public: + CREATE_FUNC(UniformShaderTest); + UniformShaderTest(); + virtual std::string subtitle() const {return "UniformShaderTest";} +}; + +class AttribShaderTest : public ShaderTestDemo2 +{ +public: + CREATE_FUNC(AttribShaderTest); + AttribShaderTest(); + virtual std::string subtitle() const {return "AttribShaderTest";} +}; + +class UniformAttribShaderTest : public ShaderTestDemo2 +{ +public: + CREATE_FUNC(UniformAttribShaderTest); + UniformAttribShaderTest(); + virtual std::string subtitle() const {return "UniformAndShaderTest";} +}; + #endif \ No newline at end of file diff --git a/tests/cpp-tests/Resources/Shaders/example_normal.vsh b/tests/cpp-tests/Resources/Shaders/example_normal.vsh new file mode 100644 index 0000000000..be38f6ec20 --- /dev/null +++ b/tests/cpp-tests/Resources/Shaders/example_normal.vsh @@ -0,0 +1,20 @@ + +attribute vec4 a_position; +attribute vec4 a_color; +attribute vec2 a_texCoord; + +#ifdef GL_ES +varying lowp vec4 v_fragmentColor; +varying mediump vec2 v_texCoord; +#else +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +#endif + +void main() +{ + gl_Position = CC_MVPMatrix * a_position; + v_fragmentColor = a_color; + v_texCoord = a_texCoord; + +} From 21dd6fef694a222fd34c1ac5ce72beed214d46da Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 6 May 2014 12:46:35 -0700 Subject: [PATCH 005/174] Improves code a little bit --- cocos/2d/CCGLProgram.cpp | 122 +++++++++--------- cocos/2d/CCGLProgram.h | 45 +++---- .../Classes/ShaderTest/ShaderTest2.cpp | 1 + 3 files changed, 86 insertions(+), 82 deletions(-) diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index c66a44308b..6471144ff0 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -225,9 +225,9 @@ void GLProgram::setUniformsForUserDef() void GLProgram::setAttribForUserDef() { - for(unsigned int i = 0, count = _programData->getAttribCount(); i < count; ++i) + for(ssize_t i = 0, count = _programData->getAttribCount(); i < count; ++i) { - GLProgramData::VertexAttrib* attrib = _programData->getAttrib(i); + GLProgramData::VertexAttrib* attrib = _programData->getVertexAttribByIndex(i); if(i == 0) { glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); @@ -249,9 +249,9 @@ void GLProgram::setVertexAttrib(const GLvoid* vertex, bool isTight) static GLint vertexsize = 0; if(vertexsize == 0) { - for(unsigned int i = 0, count = _programData->getAttribCount(); i < count; ++i) + for(ssize_t i = 0, count = _programData->getAttribCount(); i < count; ++i) { - GLProgramData::VertexAttrib* _attrib = _programData->getAttrib(i); + GLProgramData::VertexAttrib* _attrib = _programData->getVertexAttribByIndex(i); if(_attrib->_type == GL_UNSIGNED_BYTE) vertexsize += _attrib->_size ; @@ -263,10 +263,10 @@ void GLProgram::setVertexAttrib(const GLvoid* vertex, bool isTight) vertexsize = 0; size_t offset = 0; - for(unsigned int i = 0, count = _programData->getAttribCount(); i < count; ++i) + for(ssize_t i = 0, count = _programData->getAttribCount(); i < count; ++i) { - GLProgramData::VertexAttrib* _attrib = _programData->getAttrib(i); + GLProgramData::VertexAttrib* _attrib = _programData->getVertexAttribByIndex(i); std::string name = _attrib->_name; GLint size = _attrib->_size; GLenum type = _attrib->_type; @@ -374,7 +374,7 @@ void GLProgram::autoParse() attrib->_index = i; //vertexsize +=size; - _programData->addAttrib(name, attrib); + _programData->addVertexAttrib(name, attrib); //_user_vertAttributes[attribName] = attribLocation; // bindAttribLocation(attribName,attribLocation); @@ -434,7 +434,7 @@ void GLProgram::autoParse() for(unsigned int i = 0, count = _programData->getAttribCount(); i < count; ++i) { - GLProgramData::VertexAttrib* _attrib = _programData->getAttrib(i); + GLProgramData::VertexAttrib* _attrib = _programData->getVertexAttribByIndex(i); std::string name = _attrib->_name; GLint attribLocation = getAttribLocation(name.c_str()); bindAttribLocation( name.c_str(),attribLocation); @@ -444,13 +444,13 @@ void GLProgram::autoParse() UniformValue* GLProgram::getUniformValue(const std::string &name) { - GLProgramData::Uniform* uniform = _programData->getUniform(name); + GLProgramData::Uniform* uniform = _programData->getUniformByName(name); return uniform->_uniformvalue; } -GLProgramData::VertexAttrib* GLProgram::getAttrib(std::string &name) +GLProgramData::VertexAttrib* GLProgram::getAttrib(const std::string &name) { - GLProgramData::VertexAttrib* attrib = _programData->getAttrib(name); + GLProgramData::VertexAttrib* attrib = _programData->getVertexAttribByName(name); return attrib; } @@ -950,60 +950,80 @@ _vertexsize(0) GLProgramData::~GLProgramData() { - for(std::map::iterator itr = _uniforms.begin(); itr != _uniforms.end(); itr++) + for(auto itr : _uniforms) { - CC_SAFE_DELETE(itr->second); + CC_SAFE_DELETE(itr.second); } - for(std::map::iterator itr = _vertAttributes.begin(); itr != _vertAttributes.end(); itr++) + for(auto itr : _vertAttributes) { - CC_SAFE_DELETE(itr->second); + CC_SAFE_DELETE(itr.second); } } +// +// Uniform +// + void GLProgramData::addUniform(const std::string &name, Uniform* uniform) { _uniforms[name] = uniform; } -void GLProgramData::addAttrib(const std::string &name, VertexAttrib* attrib) +GLProgramData::Uniform* GLProgramData::getUniformByLocation(GLint location) +{ + for (const auto &itr : _uniforms) + { + if (itr.second->_location == location) + { + return itr.second; + } + } + return nullptr; +} + +GLProgramData::Uniform* GLProgramData::getUniformByName(const std::string& name) +{ + const auto& itr = _uniforms.find(name); + if(itr != _uniforms.end()) + return itr->second; + + return nullptr; +} + +ssize_t GLProgramData::getUniformCount() +{ + return _uniforms.size(); +} + +// +// VertexAttrib +// + +void GLProgramData::addVertexAttrib(const std::string &name, VertexAttrib* attrib) { _vertAttributes[name] = attrib; } -GLProgramData::Uniform* GLProgramData::getUniform(unsigned int index) -{ - unsigned int i = 0; - for (std::map::const_iterator itr = _uniforms.begin(); itr != _uniforms.end(); itr++, i++) - { - if (i == index) - { - return itr->second; - } - } - return NULL; -} - -GLProgramData::Uniform* GLProgramData::getUniform(const std::string& name) -{ - std::map::const_iterator itr = _uniforms.find(name); - if(itr != _uniforms.end()) - return itr->second; - else - return NULL; -} - -GLProgramData::VertexAttrib* GLProgramData::getAttrib(unsigned int index) +GLProgramData::VertexAttrib* GLProgramData::getVertexAttribByIndex(unsigned int index) { //unsigned int i = 0; - for (std::map::const_iterator itr = _vertAttributes.begin(); itr != _vertAttributes.end(); itr++) + for (const auto& itr : _vertAttributes ) { - if (itr->second->_index == index) + if (itr.second->_index == index) { - return itr->second; + return itr.second; } } - return NULL; + return nullptr; +} + +GLProgramData::VertexAttrib* GLProgramData::getVertexAttribByName(const std::string& name) +{ + const auto &itr = _vertAttributes.find(name); + if(itr != _vertAttributes.end()) + return itr->second; + return nullptr; } std::vector GLProgramData::getVertexAttributes(const std::string* attrNames, int count) @@ -1017,21 +1037,7 @@ std::vector GLProgramData::getVertexAttributes(con return attribs; } -GLProgramData::VertexAttrib* GLProgramData::getAttrib(const std::string& name) -{ - std::map::const_iterator itr = _vertAttributes.find(name); - if(itr != _vertAttributes.end()) - return itr->second; - else - return NULL; -} - -unsigned int GLProgramData::getUniformCount() -{ - return _uniforms.size(); -} - -unsigned int GLProgramData::getAttribCount() +ssize_t GLProgramData::getAttribCount() { return _vertAttributes.size(); } diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index 83fd82eb5b..696395430f 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -35,6 +35,7 @@ THE SOFTWARE. #include "CCGL.h" #include "math/CCMath.h" #include +#include NS_CC_BEGIN @@ -60,12 +61,15 @@ typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length, */ class GLProgramData { + friend class GLProgram; + public: typedef struct _VertexAttrib { GLuint _index; GLint _size; GLenum _type; + GLboolean _normalized; std::string _name; } VertexAttrib; @@ -77,34 +81,27 @@ public: GLenum _type; UniformValue* _uniformvalue; } Uniform; - -public: + GLProgramData(); ~GLProgramData(); - - - void addUniform(const std::string &name, Uniform* uniform); - void addAttrib(const std::string &name, VertexAttrib* attrib); - - - - Uniform* getUniform(unsigned int index); - Uniform* getUniform(const std::string& name); - VertexAttrib* getAttrib(unsigned int index); - VertexAttrib* getAttrib(const std::string& name); + + Uniform* getUniformByLocation(GLint location); + Uniform* getUniformByName(const std::string& name); + VertexAttrib* getVertexAttribByIndex(unsigned int index); + VertexAttrib* getVertexAttribByName(const std::string& name); std::vector getVertexAttributes(const std::string* attrNames, int count); - - unsigned int getUniformCount(); - unsigned int getAttribCount(); - - void setVertexSize(GLint size) { _vertexsize = size;} + ssize_t getUniformCount(); + ssize_t getAttribCount(); GLint getVertexSize() {return _vertexsize;} - -private: + +protected: + void addUniform(const std::string &name, Uniform* uniform); + void addVertexAttrib(const std::string &name, VertexAttrib* attrib); + void setVertexSize(GLint size) { _vertexsize = size;} + GLint _vertexsize; - - std::map _uniforms; - std::map _vertAttributes; + std::unordered_map _uniforms; + std::unordered_map _vertAttributes; }; @@ -214,7 +211,7 @@ public: //void bindUniformValue(std::string uniformName, int value); UniformValue* getUniformValue(const std::string &name); - GLProgramData::VertexAttrib* getAttrib(std::string& name); + GLProgramData::VertexAttrib* getAttrib(const std::string& name); void bindAllAttrib(); diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 655022554a..ccd3f5f99b 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -867,6 +867,7 @@ void AttribSprite::initShader() attribname ="a_color"; shader->getAttrib(attribname)->_type = GL_UNSIGNED_BYTE; + shader->getAttrib(attribname)->_normalized = GL_TRUE; shader->getAttrib(attribname)->_index = 1; attribname ="a_texCoord"; From db759005e0ef953c709b5305c14f0dedb4066c45 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 6 May 2014 17:58:14 -0700 Subject: [PATCH 006/174] Improvements for Attributes and Uniform API --- cocos/2d/CCGLProgram.cpp | 338 ++++-------------- cocos/2d/CCGLProgram.h | 153 ++++---- cocos/2d/CCVertexAttribBind.cpp | 6 +- cocos/2d/CCVertexAttribBind.h | 2 +- .../Classes/ShaderTest/ShaderTest2.cpp | 22 +- 5 files changed, 165 insertions(+), 356 deletions(-) diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 6471144ff0..035b6aab6c 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -34,6 +34,7 @@ THE SOFTWARE. #include "2d/uthash.h" #include "deprecated/CCString.h" #include "CCGL.h" +#include #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) #include "CCPrecompiledShaders.h" @@ -89,10 +90,8 @@ GLProgram::GLProgram() , _fragShader(0) , _hashForUniforms(nullptr) , _flags() -,_isTight(false) { memset(_uniforms, 0, sizeof(_uniforms)); - _programData = new GLProgramData(); } GLProgram::~GLProgram() @@ -117,8 +116,6 @@ GLProgram::~GLProgram() free(current_element->value); free(current_element); } - - CC_SAFE_DELETE(_programData); } bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) @@ -210,200 +207,63 @@ bool GLProgram::initWithFilenames(const std::string &vShaderFilename, const std: return initWithByteArrays(vertexSource.c_str(), fragmentSource.c_str()); } -void GLProgram::setUniformsForUserDef() +void GLProgram::parseVertexAttribs() { - Director* director = Director::getInstance(); - CCASSERT(nullptr != director, "Director is null when seting matrix stack"); - - Matrix matrixMV; - matrixMV = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - - Matrix matrixP = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - - // Set Uniform value -} + _attributesDictionary.clear(); -void GLProgram::setAttribForUserDef() -{ - for(ssize_t i = 0, count = _programData->getAttribCount(); i < count; ++i) - { - GLProgramData::VertexAttrib* attrib = _programData->getVertexAttribByIndex(i); - if(i == 0) - { - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); - } - else if(attrib->_type == GL_FLOAT_VEC4) - { - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); - } - else if(attrib->_type == GL_FLOAT_VEC2) - { - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); - } - } -} - -// have some questions. -void GLProgram::setVertexAttrib(const GLvoid* vertex, bool isTight) -{ - static GLint vertexsize = 0; - if(vertexsize == 0) - { - for(ssize_t i = 0, count = _programData->getAttribCount(); i < count; ++i) - { - GLProgramData::VertexAttrib* _attrib = _programData->getVertexAttribByIndex(i); - - if(_attrib->_type == GL_UNSIGNED_BYTE) - vertexsize += _attrib->_size ; - else - vertexsize += _attrib->_size * 4; - } - } - if(isTight) - vertexsize = 0; - - size_t offset = 0; - for(ssize_t i = 0, count = _programData->getAttribCount(); i < count; ++i) - { - - GLProgramData::VertexAttrib* _attrib = _programData->getVertexAttribByIndex(i); - std::string name = _attrib->_name; - GLint size = _attrib->_size; - GLenum type = _attrib->_type; - bool normalized = GL_FALSE; - - glVertexAttribPointer(i, size, type, normalized, vertexsize, (size_t*)(vertex)+ offset); - if(_attrib->_type != GL_UNSIGNED_BYTE) - offset += size * 4 ; - else - offset += size; - } -} - -void GLProgram::autoParse() -{ - // Link program - GLint status = GL_TRUE; - glLinkProgram(_program); - - // Delete shaders after linking - if (_vertShader) - { - glDeleteShader(_vertShader); - } - - if (_fragShader) - { - glDeleteShader(_fragShader); - } - - _vertShader = _fragShader = 0; - // Query and store vertex attribute meta-data from the program. GLint activeAttributes; GLint length; glGetProgramiv(_program, GL_ACTIVE_ATTRIBUTES, &activeAttributes); if(activeAttributes > 0) { + VertexAttrib attribute; + glGetProgramiv(_program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); if(length > 0) { - GLchar* attribName = new GLchar[length + 1]; - GLint attribSize; - GLenum attribType; - GLint attribLocation; - GLint vertexsize = 0; - + GLchar* attribName = (GLchar*) alloca(length + 1); + for(int i = 0; i < activeAttributes; ++i) { // Query attribute info. - glGetActiveAttrib(_program, i, length, NULL, &attribSize, &attribType, attribName); + glGetActiveAttrib(_program, i, length, NULL, &attribute.size, &attribute.type, attribName); attribName[length] = '\0'; - + attribute.name = std::string(attribName); + // Query the pre-assigned attribute location - attribLocation = glGetAttribLocation(_program, attribName); - std::string name = attribName; - - GLuint size; - switch (attribType) { - case GL_FLOAT: - size = 1; - attribType = GL_FLOAT; - break; - case GL_FLOAT_VEC2: - attribType = GL_FLOAT; - size = 2; - break; - case GL_FLOAT_VEC3: - attribType = GL_FLOAT; - size = 3; - break; - case GL_FLOAT_VEC4: - attribType = GL_FLOAT; - size = 4; - break; - case GL_FLOAT_MAT4: - attribType = GL_FLOAT; - size = 16; - break; - case GL_INT: - size = 1; - attribType = GL_INT; - break; - case GL_INT_VEC2: - size = 2; - attribType = GL_INT; - break; - case GL_INT_VEC3: - size = 3; - attribType = GL_INT; - break; - case GL_INT_VEC4: - size = 4; - attribType = GL_INT; - break; - default: - size = 1; - break; - } - - GLProgramData::_VertexAttrib* attrib = new GLProgramData::_VertexAttrib(); - attrib->_name = name; - attrib->_size = size; - attrib->_type = attribType; - attrib->_index = i; - //vertexsize +=size; - - _programData->addVertexAttrib(name, attrib); - - //_user_vertAttributes[attribName] = attribLocation; - // bindAttribLocation(attribName,attribLocation); + attribute.index = glGetAttribLocation(_program, attribName); + + _attributesDictionary[attribute.name] = attribute; } - CC_SAFE_DELETE_ARRAY(attribName); } } +} + +void GLProgram::parseUniforms() +{ + _uniformsDictionary.clear(); // Query and store uniforms from the program. GLint activeUniforms; glGetProgramiv(_program, GL_ACTIVE_UNIFORMS, &activeUniforms); if(activeUniforms > 0) { + GLint length; glGetProgramiv(_program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &length); if(length > 0) { - GLchar* uniformName = new char[length + 1]; - GLint uniformSize; - GLenum uniformType; - GLint uniformLocation; - - unsigned int sampleIndex = 0; + Uniform uniform; + + GLchar* uniformName = (GLchar*)alloca(length + 1); + for(int i = 0; i < activeUniforms; ++i) { // Query uniform info. - glGetActiveUniform(_program, i, length, NULL, &uniformSize, &uniformType, uniformName); + glGetActiveUniform(_program, i, length, NULL, &uniform.size, &uniform.type, uniformName); uniformName[length] = '\0'; - - if(uniformSize > 1 && length > 3) + // remove possible array '[]' from uniform name + if(uniform.size > 1 && length > 3) { char* c = strrchr(uniformName, '['); if(c) @@ -411,47 +271,30 @@ void GLProgram::autoParse() *c = '\0'; } } - - uniformLocation = glGetUniformLocation(_program, uniformName); - //_user_uniforms[uniformName] = uniformLocation; - std::string name = uniformName; - GLProgramData::_Uniform* uniform = new GLProgramData::_Uniform(); - - uniform->_location = uniformLocation; - uniform->_name = uniformName; - uniform->_size = uniformSize; - uniform->_type = uniformType; - - UniformValue* uniformvalue = new UniformValue(); - uniform->_uniformvalue = uniformvalue; - uniformvalue->init(this, uniform); - - _programData->addUniform(name, uniform); + uniform.name = std::string(uniformName); + uniform.location = glGetUniformLocation(_program, uniformName); + uniform.value.init(this, &uniform); + + _uniformsDictionary[uniform.name] = uniform; } - CC_SAFE_DELETE_ARRAY(uniformName); } } - - for(unsigned int i = 0, count = _programData->getAttribCount(); i < count; ++i) - { - GLProgramData::VertexAttrib* _attrib = _programData->getVertexAttribByIndex(i); - std::string name = _attrib->_name; - GLint attribLocation = getAttribLocation(name.c_str()); - bindAttribLocation( name.c_str(),attribLocation); - } - } UniformValue* GLProgram::getUniformValue(const std::string &name) { - GLProgramData::Uniform* uniform = _programData->getUniformByName(name); - return uniform->_uniformvalue; + const auto itr = _uniformsDictionary.find(name); + if( itr != _uniformsDictionary.end()) + return &itr->second.value; + return nullptr; } -GLProgramData::VertexAttrib* GLProgram::getAttrib(const std::string &name) +VertexAttrib* GLProgram::getVertexAttrib(const std::string &name) { - GLProgramData::VertexAttrib* attrib = _programData->getVertexAttribByName(name); - return attrib; + const auto itr = _attributesDictionary.find(name); + if( itr != _attributesDictionary.end()) + return &itr->second; + return nullptr; } std::string GLProgram::getDescription() const @@ -516,19 +359,19 @@ bool GLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* source return (status == GL_TRUE); } -GLint GLProgram::getAttribLocation(const char* attributeName) const +GLint GLProgram::getAttribLocation(const std::string &attributeName) const { - return glGetAttribLocation(_program, attributeName); + return glGetAttribLocation(_program, attributeName.c_str()); } -GLint GLProgram::getUniformLocation(const char* attributeName) const +GLint GLProgram::getUniformLocation(const std::string &attributeName) const { - return glGetUniformLocation(_program, attributeName); + return glGetUniformLocation(_program, attributeName.c_str()); } -void GLProgram::bindAttribLocation(const char* attributeName, GLuint index) const +void GLProgram::bindAttribLocation(const std::string &attributeName, GLuint index) const { - glBindAttribLocation(_program, index, attributeName); + glBindAttribLocation(_program, index, attributeName.c_str()); } void GLProgram::updateUniforms() @@ -608,6 +451,9 @@ bool GLProgram::link() } #endif + parseVertexAttribs(); + parseUniforms(); + return (status == GL_TRUE); } @@ -970,11 +816,11 @@ void GLProgramData::addUniform(const std::string &name, Uniform* uniform) _uniforms[name] = uniform; } -GLProgramData::Uniform* GLProgramData::getUniformByLocation(GLint location) +Uniform* GLProgramData::getUniformByLocation(GLint location) { for (const auto &itr : _uniforms) { - if (itr.second->_location == location) + if (itr.second->location == location) { return itr.second; } @@ -982,7 +828,7 @@ GLProgramData::Uniform* GLProgramData::getUniformByLocation(GLint location) return nullptr; } -GLProgramData::Uniform* GLProgramData::getUniformByName(const std::string& name) +Uniform* GLProgramData::getUniformByName(const std::string& name) { const auto& itr = _uniforms.find(name); if(itr != _uniforms.end()) @@ -1005,12 +851,12 @@ void GLProgramData::addVertexAttrib(const std::string &name, VertexAttrib* attri _vertAttributes[name] = attrib; } -GLProgramData::VertexAttrib* GLProgramData::getVertexAttribByIndex(unsigned int index) +VertexAttrib* GLProgramData::getVertexAttribByIndex(unsigned int index) { //unsigned int i = 0; for (const auto& itr : _vertAttributes ) { - if (itr.second->_index == index) + if (itr.second->index == index) { return itr.second; } @@ -1018,7 +864,7 @@ GLProgramData::VertexAttrib* GLProgramData::getVertexAttribByIndex(unsigned int return nullptr; } -GLProgramData::VertexAttrib* GLProgramData::getVertexAttribByName(const std::string& name) +VertexAttrib* GLProgramData::getVertexAttribByName(const std::string& name) { const auto &itr = _vertAttributes.find(name); if(itr != _vertAttributes.end()) @@ -1026,9 +872,9 @@ GLProgramData::VertexAttrib* GLProgramData::getVertexAttribByName(const std::str return nullptr; } -std::vector GLProgramData::getVertexAttributes(const std::string* attrNames, int count) +std::vector GLProgramData::getVertexAttributes(const std::string* attrNames, int count) { - std::vector attribs; + std::vector attribs; for (auto i = 0; i < count; i++) { auto it = _vertAttributes.find(attrNames[i]); CCASSERT(it != _vertAttributes.end(), "attribute not find"); @@ -1054,112 +900,86 @@ UniformValue::~UniformValue() { } -bool UniformValue::init(GLProgram* program, GLProgramData::Uniform* uniform) +bool UniformValue::init(GLProgram* program, Uniform* uniform) { _program = program; _uniform = uniform; - return program && program && uniform->_location != -1; + return program && program && uniform->location != -1; } bool UniformValue::setValue(float value) { - CCASSERT (_uniform && _uniform->_type == GL_FLOAT, ""); - _program->setUniformLocationWith1f(_uniform->_location, value); + CCASSERT (_uniform && _uniform->type == GL_FLOAT, ""); + _program->setUniformLocationWith1f(_uniform->location, value); return true; } bool UniformValue::setValue(int value) { - CCASSERT (_uniform && (_uniform->_type == GL_INT || _uniform->_type == GL_SAMPLER_2D), ""); - _program->setUniformLocationWith1i(_uniform->_location, value); + CCASSERT (_uniform && (_uniform->type == GL_INT || _uniform->type == GL_SAMPLER_2D), ""); + _program->setUniformLocationWith1i(_uniform->location, value); return true; } bool UniformValue::setValue(const Vector2& value) { - CCASSERT (_uniform && _uniform->_type == GL_FLOAT_VEC2, ""); - _program->setUniformLocationWith2f(_uniform->_location, value.x, value.y); + CCASSERT (_uniform && _uniform->type == GL_FLOAT_VEC2, ""); + _program->setUniformLocationWith2f(_uniform->location, value.x, value.y); return true; } bool UniformValue::setValue(const Vector3& value) { - CCASSERT (_uniform && _uniform->_type == GL_FLOAT_VEC3, ""); - _program->setUniformLocationWith3f(_uniform->_location, value.x, value.y, value.z); + CCASSERT (_uniform && _uniform->type == GL_FLOAT_VEC3, ""); + _program->setUniformLocationWith3f(_uniform->location, value.x, value.y, value.z); return true; } bool UniformValue::setValue(const Vector4& value) { - CCASSERT (_uniform && _uniform->_type == GL_FLOAT_VEC4, ""); - _program->setUniformLocationWith4f(_uniform->_location, value.x, value.y, value.z, value.w); + CCASSERT (_uniform && _uniform->type == GL_FLOAT_VEC4, ""); + _program->setUniformLocationWith4f(_uniform->location, value.x, value.y, value.z, value.w); return true; } bool UniformValue::setValue(const Matrix& value) { - CCASSERT(_uniform && _uniform->_type == GL_FLOAT_MAT4, ""); - _program->setUniformLocationWithMatrix4fv(_uniform->_location, value.m, 1); + CCASSERT(_uniform && _uniform->type == GL_FLOAT_MAT4, ""); + _program->setUniformLocationWithMatrix4fv(_uniform->location, value.m, 1); return true; } bool UniformValue::setValue(const Vector2* value, int count) { - CCASSERT (_uniform && _uniform->_type == GL_FLOAT_VEC2 && _uniform->_size == count, ""); - GLfloat* array = new GLfloat[count * 2]; - for (auto i = 0; i < count; i++) { - array[2*i] = value[i].x; - array[2*i + 1] = value[i].y; - } - _program->setUniformLocationWith2fv(_uniform->_location, array, count); - delete[] array; + CCASSERT (_uniform && _uniform->type == GL_FLOAT_VEC2 && _uniform->size == count, ""); + _program->setUniformLocationWith2fv(_uniform->location, (GLfloat*)value, count); return true; } bool UniformValue::setValue(const Vector3* value, int count) { - CCASSERT (_uniform && _uniform->_type == GL_FLOAT_VEC3 && _uniform->_size == count, ""); - GLfloat* array = new GLfloat[count * 3]; - for (auto i = 0; i < count; i++) { - array[3*i] = value[i].x; - array[3*i + 1] = value[i].y; - array[3*i + 2] = value[i].z; - } - _program->setUniformLocationWith3fv(_uniform->_location, array, count); - delete[] array; + CCASSERT (_uniform && _uniform->type == GL_FLOAT_VEC3 && _uniform->size == count, ""); + _program->setUniformLocationWith3fv(_uniform->location, (GLfloat*)value, count); return true; } bool UniformValue::setValue(const Vector4* value, int count) { - CCASSERT (_uniform && _uniform->_type == GL_FLOAT_VEC4 && _uniform->_size == count, ""); - GLfloat* array = new GLfloat[count * 4]; - for (auto i = 0; i < count; i++) { - array[4*i] = value[i].x; - array[4*i + 1] = value[i].y; - array[4*i + 2] = value[i].z; - array[4*i + 3] = value[i].w; - } - _program->setUniformLocationWith4fv(_uniform->_location, array, count); - delete[] array; + CCASSERT (_uniform && _uniform->type == GL_FLOAT_VEC4 && _uniform->size == count, ""); + _program->setUniformLocationWith4fv(_uniform->location, (GLfloat*)value, count); return true; } bool UniformValue::setValue(const Matrix* value, int count) { - CCASSERT (_uniform && _uniform->_type == GL_FLOAT_MAT4 && _uniform->_size == count, ""); - GLfloat* array = new GLfloat[count * 16]; - for (auto i = 0; i < count; i++) { - memcpy(&array[i * 16], value[i].m, 16 * sizeof(GLfloat)); - } - _program->setUniformLocationWithMatrix4fv(_uniform->_location, array, count); - delete[] array; + CCASSERT (_uniform && _uniform->type == GL_FLOAT_MAT4 && _uniform->size == count, ""); + _program->setUniformLocationWithMatrix4fv(_uniform->location, (GLfloat*)value, count); return true; } diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index 696395430f..a98aa7c287 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -49,12 +49,64 @@ USING_NS_CC_MATH; struct _hashUniformEntry; class GLProgramData; class UniformValue; -struct VertexAttrib; +class GLProgram; +struct _Uniform; typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params); typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); +class UniformValue +{ +public: + UniformValue(); + ~UniformValue(); + + bool init(GLProgram* program, struct _Uniform* uniform); + + bool setValue(float value); + + bool setValue(int value); + + bool setValue(const Vector2& value); + + bool setValue(const Vector3& value); + + bool setValue(const Vector4& value); + + bool setValue(const Matrix& value); + + bool setValue(const Vector2* value, int count); + + bool setValue(const Vector3* value, int count); + + bool setValue(const Vector4* value, int count); + + bool setValue(const Matrix* value, int count); + +protected: + GLProgram* _program; // weak ref + struct _Uniform* _uniform; // weak ref +}; + +typedef struct _VertexAttrib +{ + GLuint index; + GLint size; + GLenum type; + GLboolean normalized; + std::string name; +} VertexAttrib; + +typedef struct _Uniform +{ + GLint location; + GLint size; + std::string name; + GLenum type; + UniformValue value; +} Uniform; + /** GLProgramData Class store user defined vertexAttributes and uniforms @@ -64,23 +116,6 @@ class GLProgramData friend class GLProgram; public: - typedef struct _VertexAttrib - { - GLuint _index; - GLint _size; - GLenum _type; - GLboolean _normalized; - std::string _name; - } VertexAttrib; - - typedef struct _Uniform - { - GLint _location; - GLint _size; - std::string _name; - GLenum _type; - UniformValue* _uniformvalue; - } Uniform; GLProgramData(); ~GLProgramData(); @@ -89,7 +124,7 @@ public: Uniform* getUniformByName(const std::string& name); VertexAttrib* getVertexAttribByIndex(unsigned int index); VertexAttrib* getVertexAttribByName(const std::string& name); - std::vector getVertexAttributes(const std::string* attrNames, int count); + std::vector getVertexAttributes(const std::string* attrNames, int count); ssize_t getUniformCount(); ssize_t getAttribCount(); GLint getVertexSize() {return _vertexsize;} @@ -201,28 +236,19 @@ public: * @lua init */ bool initWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename); - - //void bindAttirbForUserdef(); - void setUniformsForUserDef(); - void setAttribForUserDef(); - void setVertexAttrib(const GLvoid* vertex, bool isTight); - void autoParse(); - //void bindUniformValue(std::string uniformName, int value); - UniformValue* getUniformValue(const std::string &name); - GLProgramData::VertexAttrib* getAttrib(const std::string& name); - - void bindAllAttrib(); + UniformValue* getUniformValue(const std::string& name); + VertexAttrib* getVertexAttrib(const std::string& name); /** It will add a new attribute to the shader by calling glBindAttribLocation */ - void bindAttribLocation(const char* attributeName, GLuint index) const; + void bindAttribLocation(const std::string& attributeName, GLuint index) const; /** calls glGetAttribLocation */ - GLint getAttribLocation(const char* attributeName) const; + GLint getAttribLocation(const std::string& attributeName) const; /** calls glGetUniformLocation() */ - GLint getUniformLocation(const char* attributeName) const; + GLint getUniformLocation(const std::string& attributeName) const; /** links the glProgram */ bool link(); @@ -313,6 +339,11 @@ public: void setUniformsForBuiltins(); void setUniformsForBuiltins(const Matrix &modelView); + void setUniformByName(const std::string& uniformName, const UniformValue &value); + + + // Attribute + /** returns the vertexShader error log */ std::string getVertexShaderLog() const; @@ -327,9 +358,7 @@ public: void reset(); inline const GLuint getProgram() const { return _program; } - - GLProgramData* getProgramData() { return _programData; } // DEPRECATED CC_DEPRECATED_ATTRIBUTE bool initWithVertexShaderByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) { return initWithByteArrays(vShaderByteArray, fShaderByteArray); } @@ -337,27 +366,24 @@ public: { return initWithFilenames(vShaderByteArray, fShaderByteArray); } CC_DEPRECATED_ATTRIBUTE void addAttribute(const char* attributeName, GLuint index) const { return bindAttribLocation(attributeName, index); } -private: + +protected: bool updateUniformLocation(GLint location, const GLvoid* data, unsigned int bytes); virtual std::string getDescription() const; + void parseVertexAttribs(); + void parseUniforms(); bool compileShader(GLuint * shader, GLenum type, const GLchar* source); std::string logForOpenGLObject(GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc) const; -protected: GLuint _program; - -private: GLuint _vertShader; GLuint _fragShader; GLint _uniforms[UNIFORM_MAX]; struct _hashUniformEntry* _hashForUniforms; bool _hasShaderCompiler; - bool _isTight; - - GLProgramData* _programData; - + #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) std::string _shaderId; #endif @@ -372,49 +398,14 @@ private: // handy way to initialize the bitfield flag_struct() { memset(this, 0, sizeof(*this)); } } _flags; -public: - static const GLuint _maxMaterialIDNumber; + + std::unordered_map _uniformsDictionary; + std::unordered_map _attributesDictionary; }; // end of shaders group /// @} - - -class UniformValue -{ -public: - UniformValue(); - ~UniformValue(); - - bool init(GLProgram* program, GLProgramData::Uniform* uniform); - - bool setValue(float value); - - bool setValue(int value); - - bool setValue(const Vector2& value); - - bool setValue(const Vector3& value); - - bool setValue(const Vector4& value); - - bool setValue(const Matrix& value); - - bool setValue(const Vector2* value, int count); - - bool setValue(const Vector3* value, int count); - - bool setValue(const Vector4* value, int count); - - bool setValue(const Matrix* value, int count); - -protected: - GLProgram* _program; - GLProgramData::Uniform* _uniform; -}; - - NS_CC_END #endif /* __CCGLPROGRAM_H__ */ diff --git a/cocos/2d/CCVertexAttribBind.cpp b/cocos/2d/CCVertexAttribBind.cpp index 3527aecf19..c2e96241aa 100644 --- a/cocos/2d/CCVertexAttribBind.cpp +++ b/cocos/2d/CCVertexAttribBind.cpp @@ -89,12 +89,12 @@ VertexAttribBind::VertexAttribBind(const std::vector& elems) setVertexAttribElems(&elems[0], elems.size()); } -VertexAttribBind::VertexAttribBind(const std::vector& attribs) +VertexAttribBind::VertexAttribBind(const std::vector& attribs) { std::vector elems; for (auto it = attribs.begin(); it != attribs.end(); it++) { - VertexAttribType type((*it)->_type, (*it)->_size); - type._location = (*it)->_index; + VertexAttribType type((*it)->type, (*it)->size); + type._location = (*it)->index; elems.push_back(type); } setVertexAttribElems(&elems[0], elems.size()); diff --git a/cocos/2d/CCVertexAttribBind.h b/cocos/2d/CCVertexAttribBind.h index 3da623ad84..f56059becf 100644 --- a/cocos/2d/CCVertexAttribBind.h +++ b/cocos/2d/CCVertexAttribBind.h @@ -63,7 +63,7 @@ public: VertexAttribBind(const std::vector& elems); - VertexAttribBind(const std::vector& attribs); + VertexAttribBind(const std::vector& attribs); virtual ~VertexAttribBind(); diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index ccd3f5f99b..066f28e656 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -746,7 +746,6 @@ void UniformSprite::initShader() { auto shader = new GLProgram(); shader->initWithFilenames(_vertSourceFile, _fragSourceFile); - shader->autoParse(); //shader->link(); shader->updateUniforms(); @@ -754,7 +753,7 @@ void UniformSprite::initShader() this->setShaderProgram(shader); std::string attribname ="a_position"; - shader->getAttrib(attribname)->_size = 2; + shader->getAttrib(attribname)->size = 2; shader->release(); } @@ -791,8 +790,8 @@ void UniformSprite::onDraw(const Matrix &transform, bool transformUpdated) float w = 256, h = 256; GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h}; - program->setVertexAttrib(vertices, true); - +// program->setVertexAttrib(vertices, true); + // Draw Call Test glDrawArrays(GL_TRIANGLES, 0, 6); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,6); @@ -855,23 +854,22 @@ void AttribSprite::initShader() auto shader = new GLProgram(); shader->initWithFilenames(_vertSourceFile, _fragSourceFile); - shader->autoParse(); shader->updateUniforms(); this->setShaderProgram(shader); shader->release(); std::string attribname ="a_position"; - shader->getAttrib(attribname)->_size = 3; - shader->getAttrib(attribname)->_index = 0; + shader->getAttrib(attribname)->size = 3; + shader->getAttrib(attribname)->index = 0; attribname ="a_color"; - shader->getAttrib(attribname)->_type = GL_UNSIGNED_BYTE; - shader->getAttrib(attribname)->_normalized = GL_TRUE; - shader->getAttrib(attribname)->_index = 1; + shader->getAttrib(attribname)->type = GL_UNSIGNED_BYTE; + shader->getAttrib(attribname)->normalized = GL_TRUE; + shader->getAttrib(attribname)->index = 1; attribname ="a_texCoord"; - shader->getAttrib(attribname)->_index = 2; + shader->getAttrib(attribname)->index = 2; } @@ -923,7 +921,7 @@ void AttribSprite::onDraw(const Matrix &transform, bool transformUpdated) diff = offsetof( V3F_C4B_T2F, colors); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); */ - program->setVertexAttrib((void*)offset, false); +// program->setVertexAttrib((void*)offset, false); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4); From 1cbe29071bb7006756490204c1cdaaa0abd2f6a1 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 7 May 2014 16:49:32 +0800 Subject: [PATCH 007/174] remove unneeded codes --- cocos/2d/CCTexture2D.cpp | 12 ------------ cocos/2d/CCTexture2D.h | 11 ----------- 2 files changed, 23 deletions(-) diff --git a/cocos/2d/CCTexture2D.cpp b/cocos/2d/CCTexture2D.cpp index 520fafc409..00df26bea1 100644 --- a/cocos/2d/CCTexture2D.cpp +++ b/cocos/2d/CCTexture2D.cpp @@ -518,18 +518,6 @@ void Texture2D::setShaderProgram(GLProgram* shaderProgram) _shaderProgram = shaderProgram; } -void Texture2D::releaseData(void *data) -{ - free(data); -} - -void* Texture2D::keepData(void *data, unsigned int length) -{ - CC_UNUSED_PARAM(length); - //The texture data mustn't be saved because it isn't a mutable texture. - return data; -} - bool Texture2D::hasPremultipliedAlpha() const { return _hasPremultipliedAlpha; diff --git a/cocos/2d/CCTexture2D.h b/cocos/2d/CCTexture2D.h index ce06b9e1f0..988d75ef9a 100644 --- a/cocos/2d/CCTexture2D.h +++ b/cocos/2d/CCTexture2D.h @@ -203,17 +203,6 @@ public: */ virtual std::string getDescription() const; - /** These functions are needed to create mutable textures - * @js NA - * @lua NA - */ - void releaseData(void *data); - /** - * @js NA - * @lua NA - */ - void* keepData(void *data, unsigned int length); - /** Initializes with a texture2d with data * @js NA * @lua NA From 5190fb27c837f253f1378d73e7f575f64654ef88 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Wed, 7 May 2014 09:27:44 -0700 Subject: [PATCH 008/174] use proposed vertex attribute api --- cocos/2d/CCGLProgram.cpp | 2 + cocos/2d/CCGLProgram.h | 24 ++++++++++ .../Classes/ShaderTest/ShaderTest2.cpp | 48 +++++++++++-------- .../Shaders/example_attribautobind.fsh | 13 +++++ .../Shaders/example_attribautobind.vsh | 19 ++++++++ .../Resources/Shaders/example_normal.vsh | 4 +- 6 files changed, 88 insertions(+), 22 deletions(-) create mode 100755 tests/cpp-tests/Resources/Shaders/example_attribautobind.fsh create mode 100644 tests/cpp-tests/Resources/Shaders/example_attribautobind.vsh diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 035b6aab6c..f7345b7164 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -273,6 +273,8 @@ void GLProgram::parseUniforms() } uniform.name = std::string(uniformName); uniform.location = glGetUniformLocation(_program, uniformName); + + //something wrong, uniform is an object not a pointer, may be released soon uniform.value.init(this, &uniform); _uniformsDictionary[uniform.name] = uniform; diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index a98aa7c287..fa603a3b50 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -96,6 +96,30 @@ typedef struct _VertexAttrib GLenum type; GLboolean normalized; std::string name; + void setPointer(GLsizei stride, void* pointer = nullptr, GLboolean isNormalized = GL_FALSE) + { + GLenum elemtype = type; + GLint elemsize = size; + switch (type) { + case GL_FLOAT_VEC2: + elemtype = GL_FLOAT; + elemsize = 2; + break; + case GL_FLOAT_VEC3: + elemtype = GL_FLOAT; + elemsize = 3; + break; + case GL_FLOAT_VEC4: + elemtype = GL_FLOAT; + elemsize = 4; + break; + + default: + break; + } + glVertexAttribPointer(index, elemsize, elemtype, isNormalized, stride, pointer); + } + } VertexAttrib; typedef struct _Uniform diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 066f28e656..666662a73c 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -746,14 +746,14 @@ void UniformSprite::initShader() { auto shader = new GLProgram(); shader->initWithFilenames(_vertSourceFile, _fragSourceFile); - //shader->link(); + shader->link(); shader->updateUniforms(); this->setShaderProgram(shader); - std::string attribname ="a_position"; - shader->getAttrib(attribname)->size = 2; +// std::string attribname ="a_position"; +// shader->getAttrib(attribname)->size = 2; shader->release(); } @@ -772,8 +772,6 @@ void UniformSprite::setCustomUniforms() _shaderProgram->getUniformValue(name)->setValue(Vector2(480,320)); name = "resolution"; _shaderProgram->getUniformValue(name)->setValue(Vector2(256,256)); - - _shaderProgram->setUniformsForUserDef(); } void UniformSprite::onDraw(const Matrix &transform, bool transformUpdated) @@ -785,8 +783,6 @@ void UniformSprite::onDraw(const Matrix &transform, bool transformUpdated) setCustomUniforms(); //GL::bindTexture2D( getTexture()->getName()); - program->setAttribForUserDef(); - float w = 256, h = 256; GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h}; @@ -852,24 +848,28 @@ AttribSprite::~AttribSprite() void AttribSprite::initShader() { auto shader = new GLProgram(); - shader->initWithFilenames(_vertSourceFile, _fragSourceFile); - + //shader->initWithFilenames(_vertSourceFile, _fragSourceFile); + shader->initWithFilenames("Shaders/example_attribautobind.vsh", "Shaders/example_attribautobind.fsh"); + shader->link(); shader->updateUniforms(); this->setShaderProgram(shader); shader->release(); - std::string attribname ="a_position"; - shader->getAttrib(attribname)->size = 3; - shader->getAttrib(attribname)->index = 0; - attribname ="a_color"; - shader->getAttrib(attribname)->type = GL_UNSIGNED_BYTE; - shader->getAttrib(attribname)->normalized = GL_TRUE; - shader->getAttrib(attribname)->index = 1; - attribname ="a_texCoord"; - shader->getAttrib(attribname)->index = 2; + +// std::string attribname ="a_position"; +// shader->getAttrib(attribname)->size = 3; +// shader->getAttrib(attribname)->index = 0; +// +// attribname ="a_color"; +// shader->getAttrib(attribname)->type = GL_UNSIGNED_BYTE; +// shader->getAttrib(attribname)->normalized = GL_TRUE; +// shader->getAttrib(attribname)->index = 1; +// +// attribname ="a_texCoord"; +// shader->getAttrib(attribname)->index = 2; } @@ -898,7 +898,7 @@ void AttribSprite::onDraw(const Matrix &transform, bool transformUpdated) // Set //glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); - //GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); + GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); GL::blendFunc(_blendFunc.src, _blendFunc.dst); GL::bindTexture2D( getTexture()->getName()); @@ -922,7 +922,15 @@ void AttribSprite::onDraw(const Matrix &transform, bool transformUpdated) glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); */ // program->setVertexAttrib((void*)offset, false); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + float a = getDisplayedOpacity() / 255.f; + GLfloat vertices[] = {0,0,0,1,0,0,a, 30,0,0,0,1,0,a, 30,30,0,0,0,1,a}; + stride = 28; + program->getVertexAttrib("a_position")->setPointer(stride, (void*)(vertices)); + program->getVertexAttrib("a_color")->setPointer(stride, (void*)(vertices + 3*sizeof(GL_FLOAT))); + //program->getUniformValue("u_diffuseColor")->setValue(Vector4(1,1,1,1)); + + glDrawArrays(GL_TRIANGLES, 0, 3); + //glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4); CHECK_GL_ERROR_DEBUG(); diff --git a/tests/cpp-tests/Resources/Shaders/example_attribautobind.fsh b/tests/cpp-tests/Resources/Shaders/example_attribautobind.fsh new file mode 100755 index 0000000000..80a030ad2d --- /dev/null +++ b/tests/cpp-tests/Resources/Shaders/example_attribautobind.fsh @@ -0,0 +1,13 @@ +#ifdef GL_ES +precision mediump float; +#endif + +varying vec4 v_fragmentColor; +varying vec4 v_diffColor; + +uniform sampler2D CC_Texture0; + +void main(void) +{ + gl_FragColor = v_fragmentColor;// * v_diffColor; +} \ No newline at end of file diff --git a/tests/cpp-tests/Resources/Shaders/example_attribautobind.vsh b/tests/cpp-tests/Resources/Shaders/example_attribautobind.vsh new file mode 100644 index 0000000000..a0794484a5 --- /dev/null +++ b/tests/cpp-tests/Resources/Shaders/example_attribautobind.vsh @@ -0,0 +1,19 @@ +attribute vec3 a_position; +attribute vec4 a_color; + +uniform vec4 u_diffuseColor; + +#ifdef GL_ES +varying lowp vec4 v_fragmentColor; +varying mediump vec4 v_diffColor; +#else +varying vec4 v_fragmentColor; +varying vec4 v_diffColor; +#endif + +void main() +{ + gl_Position = CC_MVPMatrix * vec4(a_position, 1); + v_fragmentColor = a_color; + v_diffColor = u_diffuseColor; +} diff --git a/tests/cpp-tests/Resources/Shaders/example_normal.vsh b/tests/cpp-tests/Resources/Shaders/example_normal.vsh index be38f6ec20..57c3a902a0 100644 --- a/tests/cpp-tests/Resources/Shaders/example_normal.vsh +++ b/tests/cpp-tests/Resources/Shaders/example_normal.vsh @@ -1,5 +1,5 @@ -attribute vec4 a_position; +attribute vec3 a_position; attribute vec4 a_color; attribute vec2 a_texCoord; @@ -13,7 +13,7 @@ varying vec2 v_texCoord; void main() { - gl_Position = CC_MVPMatrix * a_position; + gl_Position = CC_MVPMatrix * vec4(a_position, 1); v_fragmentColor = a_color; v_texCoord = a_texCoord; From b1ed7178fe683a4c29d855f43214b2a1b8726baa Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 7 May 2014 10:44:45 -0700 Subject: [PATCH 009/174] Improved API for Uniforms --- cocos/2d/CCGLProgram.cpp | 204 ++++++------------ cocos/2d/CCGLProgram.h | 121 +++-------- .../Classes/ShaderTest/ShaderTest2.cpp | 3 +- 3 files changed, 94 insertions(+), 234 deletions(-) diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index f7345b7164..8fa3544c61 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -275,7 +275,7 @@ void GLProgram::parseUniforms() uniform.location = glGetUniformLocation(_program, uniformName); //something wrong, uniform is an object not a pointer, may be released soon - uniform.value.init(this, &uniform); + uniform.init(this); _uniformsDictionary[uniform.name] = uniform; } @@ -283,11 +283,11 @@ void GLProgram::parseUniforms() } } -UniformValue* GLProgram::getUniformValue(const std::string &name) +Uniform* GLProgram::getUniform(const std::string &name) { const auto itr = _uniformsDictionary.find(name); if( itr != _uniformsDictionary.end()) - return &itr->second.value; + return &itr->second; return nullptr; } @@ -786,202 +786,134 @@ void GLProgram::reset() _hashForUniforms = nullptr; } - - - -GLProgramData::GLProgramData(): -_vertexsize(0) +// +// VertexAttrib +// +VertexAttrib::VertexAttrib() { - _uniforms.clear(); - _vertAttributes.clear(); } -GLProgramData::~GLProgramData() +VertexAttrib::~VertexAttrib() { - for(auto itr : _uniforms) - { - CC_SAFE_DELETE(itr.second); - } - - for(auto itr : _vertAttributes) - { - CC_SAFE_DELETE(itr.second); - } +} + +void VertexAttrib::setPointer(GLsizei stride, void* pointer, GLboolean isNormalized) +{ + GLenum elemtype = type; + GLint elemsize = size; + switch (type) { + case GL_FLOAT_VEC2: + elemtype = GL_FLOAT; + elemsize = 2; + break; + case GL_FLOAT_VEC3: + elemtype = GL_FLOAT; + elemsize = 3; + break; + case GL_FLOAT_VEC4: + elemtype = GL_FLOAT; + elemsize = 4; + break; + + default: + break; + } + glVertexAttribPointer(index, elemsize, elemtype, isNormalized, stride, pointer); } // // Uniform // -void GLProgramData::addUniform(const std::string &name, Uniform* uniform) +Uniform::Uniform() +:_program(nullptr) { - _uniforms[name] = uniform; + } -Uniform* GLProgramData::getUniformByLocation(GLint location) -{ - for (const auto &itr : _uniforms) - { - if (itr.second->location == location) - { - return itr.second; - } - } - return nullptr; -} - -Uniform* GLProgramData::getUniformByName(const std::string& name) -{ - const auto& itr = _uniforms.find(name); - if(itr != _uniforms.end()) - return itr->second; - - return nullptr; -} - -ssize_t GLProgramData::getUniformCount() -{ - return _uniforms.size(); -} - -// -// VertexAttrib -// - -void GLProgramData::addVertexAttrib(const std::string &name, VertexAttrib* attrib) -{ - _vertAttributes[name] = attrib; -} - -VertexAttrib* GLProgramData::getVertexAttribByIndex(unsigned int index) -{ - //unsigned int i = 0; - for (const auto& itr : _vertAttributes ) - { - if (itr.second->index == index) - { - return itr.second; - } - } - return nullptr; -} - -VertexAttrib* GLProgramData::getVertexAttribByName(const std::string& name) -{ - const auto &itr = _vertAttributes.find(name); - if(itr != _vertAttributes.end()) - return itr->second; - return nullptr; -} - -std::vector GLProgramData::getVertexAttributes(const std::string* attrNames, int count) -{ - std::vector attribs; - for (auto i = 0; i < count; i++) { - auto it = _vertAttributes.find(attrNames[i]); - CCASSERT(it != _vertAttributes.end(), "attribute not find"); - attribs.push_back(it->second); - } - return attribs; -} - -ssize_t GLProgramData::getAttribCount() -{ - return _vertAttributes.size(); -} - - -UniformValue::UniformValue() -:_uniform(nullptr) -,_program(nullptr) -{ - -} - -UniformValue::~UniformValue() +Uniform::~Uniform() { } -bool UniformValue::init(GLProgram* program, Uniform* uniform) +bool Uniform::init(GLProgram* program) { _program = program; - _uniform = uniform; - return program && program && uniform->location != -1; + return program && program && location != -1; } -bool UniformValue::setValue(float value) +bool Uniform::setValue(float value) { - CCASSERT (_uniform && _uniform->type == GL_FLOAT, ""); - _program->setUniformLocationWith1f(_uniform->location, value); + CCASSERT (type == GL_FLOAT, ""); + _program->setUniformLocationWith1f(location, value); return true; } -bool UniformValue::setValue(int value) +bool Uniform::setValue(int value) { - CCASSERT (_uniform && (_uniform->type == GL_INT || _uniform->type == GL_SAMPLER_2D), ""); - _program->setUniformLocationWith1i(_uniform->location, value); + CCASSERT ((type == GL_INT || type == GL_SAMPLER_2D), ""); + _program->setUniformLocationWith1i(location, value); return true; } -bool UniformValue::setValue(const Vector2& value) +bool Uniform::setValue(const Vector2& value) { - CCASSERT (_uniform && _uniform->type == GL_FLOAT_VEC2, ""); - _program->setUniformLocationWith2f(_uniform->location, value.x, value.y); + CCASSERT (type == GL_FLOAT_VEC2, ""); + _program->setUniformLocationWith2f(location, value.x, value.y); return true; } -bool UniformValue::setValue(const Vector3& value) +bool Uniform::setValue(const Vector3& value) { - CCASSERT (_uniform && _uniform->type == GL_FLOAT_VEC3, ""); - _program->setUniformLocationWith3f(_uniform->location, value.x, value.y, value.z); + CCASSERT (type == GL_FLOAT_VEC3, ""); + _program->setUniformLocationWith3f(location, value.x, value.y, value.z); return true; } -bool UniformValue::setValue(const Vector4& value) +bool Uniform::setValue(const Vector4& value) { - CCASSERT (_uniform && _uniform->type == GL_FLOAT_VEC4, ""); - _program->setUniformLocationWith4f(_uniform->location, value.x, value.y, value.z, value.w); + CCASSERT (type == GL_FLOAT_VEC4, ""); + _program->setUniformLocationWith4f(location, value.x, value.y, value.z, value.w); return true; } -bool UniformValue::setValue(const Matrix& value) +bool Uniform::setValue(const Matrix& value) { - CCASSERT(_uniform && _uniform->type == GL_FLOAT_MAT4, ""); - _program->setUniformLocationWithMatrix4fv(_uniform->location, value.m, 1); + CCASSERT(type == GL_FLOAT_MAT4, ""); + _program->setUniformLocationWithMatrix4fv(location, value.m, 1); return true; } -bool UniformValue::setValue(const Vector2* value, int count) +bool Uniform::setValue(const Vector2* value, int count) { - CCASSERT (_uniform && _uniform->type == GL_FLOAT_VEC2 && _uniform->size == count, ""); - _program->setUniformLocationWith2fv(_uniform->location, (GLfloat*)value, count); + CCASSERT (type == GL_FLOAT_VEC2 && size == count, ""); + _program->setUniformLocationWith2fv(location, (GLfloat*)value, count); return true; } -bool UniformValue::setValue(const Vector3* value, int count) +bool Uniform::setValue(const Vector3* value, int count) { - CCASSERT (_uniform && _uniform->type == GL_FLOAT_VEC3 && _uniform->size == count, ""); - _program->setUniformLocationWith3fv(_uniform->location, (GLfloat*)value, count); + CCASSERT (type == GL_FLOAT_VEC3 && size == count, ""); + _program->setUniformLocationWith3fv(location, (GLfloat*)value, count); return true; } -bool UniformValue::setValue(const Vector4* value, int count) +bool Uniform::setValue(const Vector4* value, int count) { - CCASSERT (_uniform && _uniform->type == GL_FLOAT_VEC4 && _uniform->size == count, ""); - _program->setUniformLocationWith4fv(_uniform->location, (GLfloat*)value, count); + CCASSERT (type == GL_FLOAT_VEC4 && size == count, ""); + _program->setUniformLocationWith4fv(location, (GLfloat*)value, count); return true; } -bool UniformValue::setValue(const Matrix* value, int count) +bool Uniform::setValue(const Matrix* value, int count) { - CCASSERT (_uniform && _uniform->type == GL_FLOAT_MAT4 && _uniform->size == count, ""); - _program->setUniformLocationWithMatrix4fv(_uniform->location, (GLfloat*)value, count); + CCASSERT (type == GL_FLOAT_MAT4 && size == count, ""); + _program->setUniformLocationWithMatrix4fv(location, (GLfloat*)value, count); return true; } diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index fa603a3b50..92f528e27b 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -47,120 +47,49 @@ USING_NS_CC_MATH; */ struct _hashUniformEntry; -class GLProgramData; -class UniformValue; class GLProgram; -struct _Uniform; typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params); typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); -class UniformValue +class VertexAttrib { public: - UniformValue(); - ~UniformValue(); + VertexAttrib(); + ~VertexAttrib(); + void setPointer(GLsizei stride, void* pointer = nullptr, GLboolean isNormalized = GL_FALSE); - bool init(GLProgram* program, struct _Uniform* uniform); - - bool setValue(float value); - - bool setValue(int value); - - bool setValue(const Vector2& value); - - bool setValue(const Vector3& value); - - bool setValue(const Vector4& value); - - bool setValue(const Matrix& value); - - bool setValue(const Vector2* value, int count); - - bool setValue(const Vector3* value, int count); - - bool setValue(const Vector4* value, int count); - - bool setValue(const Matrix* value, int count); - -protected: - GLProgram* _program; // weak ref - struct _Uniform* _uniform; // weak ref -}; - -typedef struct _VertexAttrib -{ GLuint index; GLint size; GLenum type; GLboolean normalized; std::string name; - void setPointer(GLsizei stride, void* pointer = nullptr, GLboolean isNormalized = GL_FALSE) - { - GLenum elemtype = type; - GLint elemsize = size; - switch (type) { - case GL_FLOAT_VEC2: - elemtype = GL_FLOAT; - elemsize = 2; - break; - case GL_FLOAT_VEC3: - elemtype = GL_FLOAT; - elemsize = 3; - break; - case GL_FLOAT_VEC4: - elemtype = GL_FLOAT; - elemsize = 4; - break; - - default: - break; - } - glVertexAttribPointer(index, elemsize, elemtype, isNormalized, stride, pointer); - } - -} VertexAttrib; +}; -typedef struct _Uniform +class Uniform { +public: + Uniform(); + ~Uniform(); + bool init(GLProgram* program); + bool setValue(float value); + bool setValue(int value); + bool setValue(const Vector2& value); + bool setValue(const Vector3& value); + bool setValue(const Vector4& value); + bool setValue(const Matrix& value); + bool setValue(const Vector2* value, int count); + bool setValue(const Vector3* value, int count); + bool setValue(const Vector4* value, int count); + bool setValue(const Matrix* value, int count); + GLint location; GLint size; std::string name; GLenum type; - UniformValue value; -} Uniform; - -/** GLProgramData - Class store user defined vertexAttributes and uniforms - */ -class GLProgramData -{ - friend class GLProgram; - -public: - - GLProgramData(); - ~GLProgramData(); - - Uniform* getUniformByLocation(GLint location); - Uniform* getUniformByName(const std::string& name); - VertexAttrib* getVertexAttribByIndex(unsigned int index); - VertexAttrib* getVertexAttribByName(const std::string& name); - std::vector getVertexAttributes(const std::string* attrNames, int count); - ssize_t getUniformCount(); - ssize_t getAttribCount(); - GLint getVertexSize() {return _vertexsize;} - -protected: - void addUniform(const std::string &name, Uniform* uniform); - void addVertexAttrib(const std::string &name, VertexAttrib* attrib); - void setVertexSize(GLint size) { _vertexsize = size;} - - GLint _vertexsize; - std::unordered_map _uniforms; - std::unordered_map _vertAttributes; + GLProgram* _program; // weak ref }; @@ -261,8 +190,8 @@ public: */ bool initWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename); - //void bindUniformValue(std::string uniformName, int value); - UniformValue* getUniformValue(const std::string& name); + //void bindUniform(std::string uniformName, int value); + Uniform* getUniform(const std::string& name); VertexAttrib* getVertexAttrib(const std::string& name); /** It will add a new attribute to the shader by calling glBindAttribLocation */ @@ -363,7 +292,7 @@ public: void setUniformsForBuiltins(); void setUniformsForBuiltins(const Matrix &modelView); - void setUniformByName(const std::string& uniformName, const UniformValue &value); + void setUniformByName(const std::string& uniformName, const Uniform &value); // Attribute diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 666662a73c..90a737d1c5 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -888,7 +888,6 @@ void AttribSprite::setCustomUniforms() void AttribSprite::onDraw(const Matrix &transform, bool transformUpdated) { - // Set Shader GLProgram auto program = getShaderProgram(); program->use(); @@ -924,7 +923,7 @@ void AttribSprite::onDraw(const Matrix &transform, bool transformUpdated) // program->setVertexAttrib((void*)offset, false); float a = getDisplayedOpacity() / 255.f; GLfloat vertices[] = {0,0,0,1,0,0,a, 30,0,0,0,1,0,a, 30,30,0,0,0,1,a}; - stride = 28; + stride = sizeof(vertices)/3; program->getVertexAttrib("a_position")->setPointer(stride, (void*)(vertices)); program->getVertexAttrib("a_color")->setPointer(stride, (void*)(vertices + 3*sizeof(GL_FLOAT))); //program->getUniformValue("u_diffuseColor")->setValue(Vector4(1,1,1,1)); From a2c4ddf028c599d048ec14d3b207de8e770f5382 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 7 May 2014 11:26:26 -0700 Subject: [PATCH 010/174] beautify Uniform and VertexAttrib --- cocos/2d/CCGLProgram.cpp | 72 +++++++++++++++++---------------- cocos/2d/CCGLProgram.h | 27 ++++++++----- cocos/2d/CCVertexAttribBind.cpp | 4 +- 3 files changed, 57 insertions(+), 46 deletions(-) diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 8fa3544c61..713b60b7c4 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -227,14 +227,14 @@ void GLProgram::parseVertexAttribs() for(int i = 0; i < activeAttributes; ++i) { // Query attribute info. - glGetActiveAttrib(_program, i, length, NULL, &attribute.size, &attribute.type, attribName); + glGetActiveAttrib(_program, i, length, NULL, &attribute._size, &attribute._type, attribName); attribName[length] = '\0'; - attribute.name = std::string(attribName); + attribute._name = std::string(attribName); // Query the pre-assigned attribute location - attribute.index = glGetAttribLocation(_program, attribName); + attribute._index = glGetAttribLocation(_program, attribName); - _attributesDictionary[attribute.name] = attribute; + _attributesDictionary[attribute._name] = attribute; } } } @@ -260,10 +260,10 @@ void GLProgram::parseUniforms() for(int i = 0; i < activeUniforms; ++i) { // Query uniform info. - glGetActiveUniform(_program, i, length, NULL, &uniform.size, &uniform.type, uniformName); + glGetActiveUniform(_program, i, length, NULL, &uniform._size, &uniform._type, uniformName); uniformName[length] = '\0'; // remove possible array '[]' from uniform name - if(uniform.size > 1 && length > 3) + if(uniform._size > 1 && length > 3) { char* c = strrchr(uniformName, '['); if(c) @@ -271,13 +271,13 @@ void GLProgram::parseUniforms() *c = '\0'; } } - uniform.name = std::string(uniformName); - uniform.location = glGetUniformLocation(_program, uniformName); + uniform._name = std::string(uniformName); + uniform._location = glGetUniformLocation(_program, uniformName); //something wrong, uniform is an object not a pointer, may be released soon uniform.init(this); - _uniformsDictionary[uniform.name] = uniform; + _uniformsDictionary[uniform._name] = uniform; } } } @@ -799,9 +799,9 @@ VertexAttrib::~VertexAttrib() void VertexAttrib::setPointer(GLsizei stride, void* pointer, GLboolean isNormalized) { - GLenum elemtype = type; - GLint elemsize = size; - switch (type) { + GLenum elemtype = _type; + GLint elemsize = _size; + switch (_type) { case GL_FLOAT_VEC2: elemtype = GL_FLOAT; elemsize = 2; @@ -818,7 +818,11 @@ void VertexAttrib::setPointer(GLsizei stride, void* pointer, GLboolean isNormali default: break; } - glVertexAttribPointer(index, elemsize, elemtype, isNormalized, stride, pointer); + glVertexAttribPointer(_index, elemsize, elemtype, isNormalized, stride, pointer); +} + +void VertexAttrib::redefineType(GLenum type, GLint size, GLboolean normalized) +{ } // @@ -838,82 +842,82 @@ Uniform::~Uniform() bool Uniform::init(GLProgram* program) { _program = program; - return program && program && location != -1; + return program && program && _location != -1; } bool Uniform::setValue(float value) { - CCASSERT (type == GL_FLOAT, ""); - _program->setUniformLocationWith1f(location, value); + CCASSERT (_type == GL_FLOAT, ""); + _program->setUniformLocationWith1f(_location, value); return true; } bool Uniform::setValue(int value) { - CCASSERT ((type == GL_INT || type == GL_SAMPLER_2D), ""); - _program->setUniformLocationWith1i(location, value); + CCASSERT ((_type == GL_INT || _type == GL_SAMPLER_2D), ""); + _program->setUniformLocationWith1i(_location, value); return true; } bool Uniform::setValue(const Vector2& value) { - CCASSERT (type == GL_FLOAT_VEC2, ""); - _program->setUniformLocationWith2f(location, value.x, value.y); + CCASSERT (_type == GL_FLOAT_VEC2, ""); + _program->setUniformLocationWith2f(_location, value.x, value.y); return true; } bool Uniform::setValue(const Vector3& value) { - CCASSERT (type == GL_FLOAT_VEC3, ""); - _program->setUniformLocationWith3f(location, value.x, value.y, value.z); + CCASSERT (_type == GL_FLOAT_VEC3, ""); + _program->setUniformLocationWith3f(_location, value.x, value.y, value.z); return true; } bool Uniform::setValue(const Vector4& value) { - CCASSERT (type == GL_FLOAT_VEC4, ""); - _program->setUniformLocationWith4f(location, value.x, value.y, value.z, value.w); + CCASSERT (_type == GL_FLOAT_VEC4, ""); + _program->setUniformLocationWith4f(_location, value.x, value.y, value.z, value.w); return true; } bool Uniform::setValue(const Matrix& value) { - CCASSERT(type == GL_FLOAT_MAT4, ""); - _program->setUniformLocationWithMatrix4fv(location, value.m, 1); + CCASSERT(_type == GL_FLOAT_MAT4, ""); + _program->setUniformLocationWithMatrix4fv(_location, value.m, 1); return true; } bool Uniform::setValue(const Vector2* value, int count) { - CCASSERT (type == GL_FLOAT_VEC2 && size == count, ""); - _program->setUniformLocationWith2fv(location, (GLfloat*)value, count); + CCASSERT (_type == GL_FLOAT_VEC2 && _size == count, ""); + _program->setUniformLocationWith2fv(_location, (GLfloat*)value, count); return true; } bool Uniform::setValue(const Vector3* value, int count) { - CCASSERT (type == GL_FLOAT_VEC3 && size == count, ""); - _program->setUniformLocationWith3fv(location, (GLfloat*)value, count); + CCASSERT (_type == GL_FLOAT_VEC3 && _size == count, ""); + _program->setUniformLocationWith3fv(_location, (GLfloat*)value, count); return true; } bool Uniform::setValue(const Vector4* value, int count) { - CCASSERT (type == GL_FLOAT_VEC4 && size == count, ""); - _program->setUniformLocationWith4fv(location, (GLfloat*)value, count); + CCASSERT (_type == GL_FLOAT_VEC4 && _size == count, ""); + _program->setUniformLocationWith4fv(_location, (GLfloat*)value, count); return true; } bool Uniform::setValue(const Matrix* value, int count) { - CCASSERT (type == GL_FLOAT_MAT4 && size == count, ""); - _program->setUniformLocationWithMatrix4fv(location, (GLfloat*)value, count); + CCASSERT (_type == GL_FLOAT_MAT4 && _size == count, ""); + _program->setUniformLocationWithMatrix4fv(_location, (GLfloat*)value, count); return true; } diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index 92f528e27b..daac3862a6 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -55,20 +55,27 @@ typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length, class VertexAttrib { + friend class GLProgram; + friend class VertexAttribBind; + public: VertexAttrib(); ~VertexAttrib(); void setPointer(GLsizei stride, void* pointer = nullptr, GLboolean isNormalized = GL_FALSE); + void redefineType(GLenum type, GLint size, GLboolean normalized); - GLuint index; - GLint size; - GLenum type; - GLboolean normalized; - std::string name; +protected: + GLuint _index; + GLint _size; + GLenum _type; + GLboolean _normalized; + std::string _name; }; class Uniform { + friend class GLProgram; + public: Uniform(); ~Uniform(); @@ -84,11 +91,11 @@ public: bool setValue(const Vector4* value, int count); bool setValue(const Matrix* value, int count); - GLint location; - GLint size; - std::string name; - GLenum type; - +protected: + GLint _location; + GLint _size; + std::string _name; + GLenum _type; GLProgram* _program; // weak ref }; diff --git a/cocos/2d/CCVertexAttribBind.cpp b/cocos/2d/CCVertexAttribBind.cpp index c2e96241aa..3b657af9ab 100644 --- a/cocos/2d/CCVertexAttribBind.cpp +++ b/cocos/2d/CCVertexAttribBind.cpp @@ -93,8 +93,8 @@ VertexAttribBind::VertexAttribBind(const std::vector& attribs) { std::vector elems; for (auto it = attribs.begin(); it != attribs.end(); it++) { - VertexAttribType type((*it)->type, (*it)->size); - type._location = (*it)->index; + VertexAttribType type((*it)->_type, (*it)->_size); + type._location = (*it)->_index; elems.push_back(type); } setVertexAttribElems(&elems[0], elems.size()); From 02405a8efeab47e1e5c2654bf5639bf51aaf7353 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 7 May 2014 12:41:04 -0700 Subject: [PATCH 011/174] Improved samples --- cocos/2d/CCGLProgram.cpp | 60 +++++++++++---- cocos/2d/CCGLProgram.h | 10 ++- .../Classes/ShaderTest/ShaderTest2.cpp | 77 ++++++------------- 3 files changed, 76 insertions(+), 71 deletions(-) diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 713b60b7c4..be0dd15435 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -227,14 +227,14 @@ void GLProgram::parseVertexAttribs() for(int i = 0; i < activeAttributes; ++i) { // Query attribute info. - glGetActiveAttrib(_program, i, length, NULL, &attribute._size, &attribute._type, attribName); + glGetActiveAttrib(_program, i, length, NULL, &attribute._originalSize, &attribute._originalType, attribName); attribName[length] = '\0'; attribute._name = std::string(attribName); // Query the pre-assigned attribute location attribute._index = glGetAttribLocation(_program, attribName); - _attributesDictionary[attribute._name] = attribute; + attribute.updateTypeAndSize(); } } } @@ -423,6 +423,10 @@ bool GLProgram::link() glLinkProgram(_program); + + parseVertexAttribs(); + parseUniforms(); + if (_vertShader) { glDeleteShader(_vertShader); @@ -453,9 +457,6 @@ bool GLProgram::link() } #endif - parseVertexAttribs(); - parseUniforms(); - return (status == GL_TRUE); } @@ -790,6 +791,9 @@ void GLProgram::reset() // VertexAttrib // VertexAttrib::VertexAttrib() +: _size(-1) +, _type(-1) +, _normalized(false) { } @@ -797,32 +801,54 @@ VertexAttrib::~VertexAttrib() { } -void VertexAttrib::setPointer(GLsizei stride, void* pointer, GLboolean isNormalized) +void VertexAttrib::updateTypeAndSize() { - GLenum elemtype = _type; - GLint elemsize = _size; - switch (_type) { + switch (_originalType) { case GL_FLOAT_VEC2: - elemtype = GL_FLOAT; - elemsize = 2; + _type = GL_FLOAT; + _size = 2; break; case GL_FLOAT_VEC3: - elemtype = GL_FLOAT; - elemsize = 3; + _type = GL_FLOAT; + _size = 3; break; case GL_FLOAT_VEC4: - elemtype = GL_FLOAT; - elemsize = 4; + _type = GL_FLOAT; + _size = 4; + break; + case GL_FLOAT_MAT2: + _type = GL_FLOAT; + _size = 4; + break; + case GL_FLOAT_MAT3: + _type = GL_FLOAT; + _size = 9; + break; + case GL_FLOAT_MAT4: + _type = GL_FLOAT; + _size = 16; break; default: break; } - glVertexAttribPointer(_index, elemsize, elemtype, isNormalized, stride, pointer); } -void VertexAttrib::redefineType(GLenum type, GLint size, GLboolean normalized) +void VertexAttrib::setPointer(GLsizei stride, const GLvoid *pointer) { + glVertexAttribPointer(_index, _size, _type, _normalized, stride, pointer); +} + +void VertexAttrib::setPointer(GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) +{ + glVertexAttribPointer(_index, size, type, normalized, stride, pointer); +} + +void VertexAttrib::redefineTypeAndSize(GLenum type, GLint size, GLboolean normalized) +{ + _type = type; + _size = size; + _normalized = normalized; } // diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index daac3862a6..5d2325134a 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -61,13 +61,19 @@ class VertexAttrib public: VertexAttrib(); ~VertexAttrib(); - void setPointer(GLsizei stride, void* pointer = nullptr, GLboolean isNormalized = GL_FALSE); - void redefineType(GLenum type, GLint size, GLboolean normalized); + + void setPointer(GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); + void setPointer(GLsizei stride, const GLvoid *pointer); + + void redefineTypeAndSize(GLenum type, GLint size, GLboolean normalized); + void updateTypeAndSize(); protected: GLuint _index; GLint _size; + GLint _originalSize; GLenum _type; + GLenum _originalType; GLboolean _normalized; std::string _name; }; diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 90a737d1c5..f615116ab8 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -172,13 +172,7 @@ void ShaderSprite::initShader() program->release(); CHECK_GL_ERROR_DEBUG(); - - program->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - program->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - program->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - - CHECK_GL_ERROR_DEBUG(); - + program->link(); CHECK_GL_ERROR_DEBUG(); @@ -190,6 +184,10 @@ void ShaderSprite::initShader() buildCustomUniforms(); CHECK_GL_ERROR_DEBUG(); + + program->getVertexAttrib("a_color")->redefineTypeAndSize(GL_UNSIGNED_BYTE, 4, GL_TRUE); + program->getVertexAttrib("a_position")->redefineTypeAndSize(GL_FLOAT, 3, GL_FALSE); + program->getVertexAttrib("a_texCoord")->redefineTypeAndSize(GL_FLOAT, 2, GL_FALSE); } void ShaderSprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -220,16 +218,16 @@ void ShaderSprite::onDraw(const Matrix &transform, bool transformUpdated) // vertex int diff = offsetof( V3F_C4B_T2F, vertices); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); - + shader->getVertexAttrib("a_position")->setPointer(kQuadSize, (void*) (offset + diff)); + // texCoods diff = offsetof( V3F_C4B_T2F, texCoords); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); - + shader->getVertexAttrib("a_texCoord")->setPointer(kQuadSize, (void*) (offset + diff)); + // color diff = offsetof( V3F_C4B_T2F, colors); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); - + shader->getVertexAttrib("a_color")->setPointer(kQuadSize, (void*) (offset + diff)); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4); } @@ -769,9 +767,9 @@ void UniformSprite::setCustomUniforms() { std::string name = "center"; - _shaderProgram->getUniformValue(name)->setValue(Vector2(480,320)); + _shaderProgram->getUniform(name)->setValue(Vector2(480,320)); name = "resolution"; - _shaderProgram->getUniformValue(name)->setValue(Vector2(256,256)); + _shaderProgram->getUniform(name)->setValue(Vector2(256,256)); } void UniformSprite::onDraw(const Matrix &transform, bool transformUpdated) @@ -848,29 +846,13 @@ AttribSprite::~AttribSprite() void AttribSprite::initShader() { auto shader = new GLProgram(); - //shader->initWithFilenames(_vertSourceFile, _fragSourceFile); - shader->initWithFilenames("Shaders/example_attribautobind.vsh", "Shaders/example_attribautobind.fsh"); + + shader->initWithFilenames(_vertSourceFile, _fragSourceFile); shader->link(); shader->updateUniforms(); this->setShaderProgram(shader); shader->release(); - - - - -// std::string attribname ="a_position"; -// shader->getAttrib(attribname)->size = 3; -// shader->getAttrib(attribname)->index = 0; -// -// attribname ="a_color"; -// shader->getAttrib(attribname)->type = GL_UNSIGNED_BYTE; -// shader->getAttrib(attribname)->normalized = GL_TRUE; -// shader->getAttrib(attribname)->index = 1; -// -// attribname ="a_texCoord"; -// shader->getAttrib(attribname)->index = 2; - } void AttribSprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -907,29 +889,20 @@ void AttribSprite::onDraw(const Matrix &transform, bool transformUpdated) #define kQuadSize sizeof(_quad.bl) size_t offset = (size_t)&_quad; size_t stride = kQuadSize; - /* - // vertex + int diff = offsetof( V3F_C4B_T2F, vertices); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); - - // texCoods - diff = offsetof( V3F_C4B_T2F, texCoords); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); - - // color + program->getVertexAttrib("a_position")->setPointer(3, GL_FLOAT, GL_FALSE, stride, (void*) (offset + diff)); + diff = offsetof( V3F_C4B_T2F, colors); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); - */ -// program->setVertexAttrib((void*)offset, false); - float a = getDisplayedOpacity() / 255.f; - GLfloat vertices[] = {0,0,0,1,0,0,a, 30,0,0,0,1,0,a, 30,30,0,0,0,1,a}; - stride = sizeof(vertices)/3; - program->getVertexAttrib("a_position")->setPointer(stride, (void*)(vertices)); - program->getVertexAttrib("a_color")->setPointer(stride, (void*)(vertices + 3*sizeof(GL_FLOAT))); + program->getVertexAttrib("a_color")->setPointer(4, GL_UNSIGNED_BYTE, GL_TRUE, stride, (void*) (offset + diff)); + + diff = offsetof( V3F_C4B_T2F, texCoords); + program->getVertexAttrib("a_texCoord")->setPointer(2, GL_FLOAT, GL_FALSE, stride, (void*) (offset + diff)); + //program->getUniformValue("u_diffuseColor")->setValue(Vector4(1,1,1,1)); - glDrawArrays(GL_TRIANGLES, 0, 3); - //glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); +// glDrawArrays(GL_TRIANGLES, 0, 3); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4); CHECK_GL_ERROR_DEBUG(); From 98454eeb69c1eb7d3baf959791862aa75e2a979d Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 7 May 2014 14:38:41 -0700 Subject: [PATCH 012/174] Adds GLProgram::createXXX() --- cocos/2d/CCGLProgram.cpp | 36 +++++++++++++ cocos/2d/CCGLProgram.h | 11 ++-- cocos/deprecated/CCString.cpp | 2 +- cocos/deprecated/CCString.h | 2 +- .../Classes/ShaderTest/ShaderTest.cpp | 52 +++++-------------- .../cpp-tests/Classes/ShaderTest/ShaderTest.h | 1 - .../Classes/ShaderTest/ShaderTest2.cpp | 19 ++----- 7 files changed, 60 insertions(+), 63 deletions(-) diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index be0dd15435..3c0f696024 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -84,6 +84,30 @@ const char* GLProgram::ATTRIBUTE_NAME_POSITION = "a_position"; const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD = "a_texCoord"; +GLProgram* GLProgram::createWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) +{ + auto ret = new (std::nothrow) GLProgram(); + if(ret && ret->initWithByteArrays(vShaderByteArray, fShaderByteArray)) { + ret->autorelease(); + return ret; + } + + CC_SAFE_DELETE(ret); + return nullptr; +} + +GLProgram* GLProgram::createWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename) +{ + auto ret = new (std::nothrow) GLProgram(); + if(ret && ret->initWithFilenames(vShaderFilename, fShaderFilename)) { + ret->autorelease(); + return ret; + } + + CC_SAFE_DELETE(ret); + return nullptr; +} + GLProgram::GLProgram() : _program(0) , _vertShader(0) @@ -178,6 +202,18 @@ bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* } #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) +GLProgram* GLProgram::createWithPrecompiledProgramByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) +{ + auto ret = new (std::nothrow) GLProgram(); + if(ret && ret->initWithPrecompiledProgramByteArray(vShaderByteArray, fShaderByteArray)) { + ret->autorelease(); + return ret; + } + + CC_SAFE_DELETE(ret); + return nullptr; +} + bool GLProgram::initWithPrecompiledProgramByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) { bool haveProgram = false; diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index 5d2325134a..36f9c67cd6 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -172,14 +172,8 @@ public: static const char* ATTRIBUTE_NAME_COLOR; static const char* ATTRIBUTE_NAME_POSITION; static const char* ATTRIBUTE_NAME_TEX_COORD; - /** - * @js ctor - */ + GLProgram(); - /** - * @js NA - * @lua NA - */ virtual ~GLProgram(); /** Initializes the GLProgram with a vertex and fragment with bytes array * @js initWithString @@ -188,6 +182,7 @@ public: #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) /** Initializes the CCGLProgram with precompiled shader program */ + static GLProgram* createWithPrecompiledProgramByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); bool initWithPrecompiledProgramByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); #endif @@ -195,12 +190,14 @@ public: * @js initWithString * @lua initWithString */ + static GLProgram* createWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); bool initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); /** Initializes the GLProgram with a vertex and fragment with contents of filenames * @js init * @lua init */ + static GLProgram* createWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename); bool initWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename); //void bindUniform(std::string uniformName, int value); diff --git a/cocos/deprecated/CCString.cpp b/cocos/deprecated/CCString.cpp index 27218ca1d1..475d4f41f8 100644 --- a/cocos/deprecated/CCString.cpp +++ b/cocos/deprecated/CCString.cpp @@ -256,7 +256,7 @@ __String* __String::createWithFormat(const char* format, ...) return ret; } -__String* __String::createWithContentsOfFile(const char* filename) +__String* __String::createWithContentsOfFile(const std::string &filename) { std::string str = FileUtils::getInstance()->getStringFromFile(filename); return __String::create(std::move(str)); diff --git a/cocos/deprecated/CCString.h b/cocos/deprecated/CCString.h index d4917fb9ef..f4cd92b866 100644 --- a/cocos/deprecated/CCString.h +++ b/cocos/deprecated/CCString.h @@ -174,7 +174,7 @@ public: * it means that you needn't do a release operation unless you retain it. * @js NA */ - static __String* createWithContentsOfFile(const char* filename); + static __String* createWithContentsOfFile(const std::string& filename); /** * @js NA * @lua NA diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 7fa1bd644c..077897401f 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -1,8 +1,6 @@ #include "ShaderTest.h" #include "../testResource.h" #include "cocos2d.h" -#include "renderer/CCCustomCommand.h" -#include "renderer/CCRenderer.h" static int sceneIdx = -1; @@ -113,9 +111,6 @@ ShaderNode::ShaderNode() :_center(Vector2(0.0f, 0.0f)) ,_resolution(Vector2(0.0f, 0.0f)) ,_time(0.0f) -,_uniformCenter(0) -,_uniformResolution(0) -,_uniformTime(0) { } @@ -161,21 +156,14 @@ bool ShaderNode::initWithVertex(const char *vert, const char *frag) void ShaderNode::loadShaderVertex(const char *vert, const char *frag) { - auto shader = new GLProgram(); - shader->initWithFilenames(vert, frag); + auto shader = GLProgram::createWithFilenames(vert, frag); shader->bindAttribLocation("aVertex", GLProgram::VERTEX_ATTRIB_POSITION); shader->link(); shader->updateUniforms(); - _uniformCenter = shader->getUniformLocation("center"); - _uniformResolution = shader->getUniformLocation("resolution"); - _uniformTime = shader->getUniformLocation("time"); - this->setShaderProgram(shader); - - shader->release(); } void ShaderNode::update(float dt) @@ -202,12 +190,10 @@ void ShaderNode::onDraw(const Matrix &transform, bool transformUpdated) auto shader = getShaderProgram(); shader->use(); shader->setUniformsForBuiltins(transform); - shader->setUniformLocationWith2f(_uniformCenter, _center.x, _center.y); - shader->setUniformLocationWith2f(_uniformResolution, _resolution.x, _resolution.y); - - // time changes all the time, so it is Ok to call OpenGL directly, and not the "cached" version - glUniform1f(_uniformTime, _time); - + + shader->getUniform("center")->setValue(_center); + shader->getUniform("resolution")->setValue(_resolution); + GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION ); float w = SIZE_X, h = SIZE_Y; @@ -447,9 +433,6 @@ protected: float _cons; float _weightSum; - GLuint pixelSizeLocation; - GLuint coefficientLocation; - CustomCommand _customCommand; }; @@ -502,11 +485,9 @@ void SpriteBlur::initProgram() { GLchar * fragSource = (GLchar*) String::createWithContentsOfFile( FileUtils::getInstance()->fullPathForFilename("Shaders/example_Blur.fsh").c_str())->getCString(); - auto program = new GLProgram(); - program->initWithByteArrays(ccPositionTextureColor_vert, fragSource); + auto program = GLProgram::createWithByteArrays(ccPositionTextureColor_vert, fragSource); setShaderProgram(program); - program->release(); - + CHECK_GL_ERROR_DEBUG(); program->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); @@ -521,12 +502,7 @@ void SpriteBlur::initProgram() program->updateUniforms(); - CHECK_GL_ERROR_DEBUG(); - - pixelSizeLocation = program->getUniformLocation("onePixelSize"); - coefficientLocation = program->getUniformLocation("gaussianCoefficient"); - - CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); } void SpriteBlur::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -545,8 +521,9 @@ void SpriteBlur::onDraw(const Matrix &transform, bool transformUpdated) auto program = getShaderProgram(); program->use(); program->setUniformsForBuiltins(transform); - program->setUniformLocationWith2f(pixelSizeLocation, _pixelSize.x, _pixelSize.y); - program->setUniformLocationWith4f(coefficientLocation, _samplingRadius, _scale,_cons,_weightSum); + + program->getUniform("onePixelSize")->setValue(_pixelSize); + program->getUniform("gaussianCoefficient")->setValue(Vector4(_samplingRadius, _scale, _cons, _weightSum)); GL::bindTexture2D( getTexture()->getName()); @@ -687,9 +664,8 @@ bool ShaderRetroEffect::init() { if( ShaderTestDemo::init() ) { - GLchar * fragSource = (GLchar*) String::createWithContentsOfFile(FileUtils::getInstance()->fullPathForFilename("Shaders/example_HorizontalColor.fsh").c_str())->getCString(); - auto p = new GLProgram(); - p->initWithByteArrays(ccPositionTexture_vert, fragSource); + GLchar * fragSource = (GLchar*) String::createWithContentsOfFile(FileUtils::getInstance()->fullPathForFilename("Shaders/example_HorizontalColor.fsh"))->getCString(); + auto p = GLProgram::createWithByteArrays(ccPositionTexture_vert, fragSource); p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); @@ -704,8 +680,6 @@ bool ShaderRetroEffect::init() _label->setAnchorPoint(Vector2::ANCHOR_MIDDLE); _label->setShaderProgram(p); - p->release(); - _label->setPosition(Vector2(s.width/2,s.height/2)); addChild(_label); diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h index 3ef09eae2a..c1dea61c66 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h @@ -131,7 +131,6 @@ protected: Vector2 _center; Vector2 _resolution; float _time; - GLuint _uniformCenter, _uniformResolution, _uniformTime; std::string _vertFileName; std::string _fragFileName; CustomCommand _customCommand; diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index f615116ab8..ce1425acd1 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -166,11 +166,9 @@ void ShaderSprite::initShader() vertSource = fileUtiles->getStringFromFile(vertexFilePath); } - auto program = new GLProgram(); - program->initWithByteArrays(vertSource.c_str(), fragSource.c_str()); + auto program = GLProgram::createWithByteArrays(vertSource.c_str(), fragSource.c_str()); setShaderProgram(program); - program->release(); - + CHECK_GL_ERROR_DEBUG(); program->link(); @@ -742,8 +740,7 @@ UniformSprite::~UniformSprite() void UniformSprite::initShader() { - auto shader = new GLProgram(); - shader->initWithFilenames(_vertSourceFile, _fragSourceFile); + auto shader = GLProgram::createWithFilenames(_vertSourceFile, _fragSourceFile); shader->link(); shader->updateUniforms(); @@ -752,8 +749,6 @@ void UniformSprite::initShader() // std::string attribname ="a_position"; // shader->getAttrib(attribname)->size = 2; - - shader->release(); } void UniformSprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -845,14 +840,10 @@ AttribSprite::~AttribSprite() void AttribSprite::initShader() { - auto shader = new GLProgram(); - - shader->initWithFilenames(_vertSourceFile, _fragSourceFile); + auto shader = GLProgram::createWithFilenames(_vertSourceFile, _fragSourceFile); shader->link(); shader->updateUniforms(); - this->setShaderProgram(shader); - - shader->release(); + this->setShaderProgram(shader); } void AttribSprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) From b401f6adc1d94bb9743e73f4b0d1d181223316f1 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 7 May 2014 20:20:19 -0700 Subject: [PATCH 013/174] Lots of new code Adds GLProgramState --- build/cocos2d_libs.xcodeproj/project.pbxproj | 12 + cocos/2d/CCGLProgram.cpp | 112 ++------ cocos/2d/CCGLProgram.h | 21 +- cocos/2d/CCGLProgramState.cpp | 272 ++++++++++++++++++ cocos/2d/CCGLProgramState.h | 166 +++++++++++ cocos/2d/ccGLStateCache.cpp | 60 ++-- .../Classes/ShaderTest/ShaderTest.cpp | 12 +- .../Classes/ShaderTest/ShaderTest2.cpp | 12 +- 8 files changed, 505 insertions(+), 162 deletions(-) create mode 100644 cocos/2d/CCGLProgramState.cpp create mode 100644 cocos/2d/CCGLProgramState.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index a737cca32e..d9fa6f4268 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1604,6 +1604,10 @@ 500DC9BD19106E89007B91BF /* CCProfiling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9BA19106E89007B91BF /* CCProfiling.cpp */; }; 500DC9BE19106E89007B91BF /* CCProfiling.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9BB19106E89007B91BF /* CCProfiling.h */; }; 500DC9BF19106E89007B91BF /* CCProfiling.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9BB19106E89007B91BF /* CCProfiling.h */; }; + 500DC9D9191B0175007B91BF /* CCGLProgramState.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9D7191B0175007B91BF /* CCGLProgramState.h */; }; + 500DC9DA191B0175007B91BF /* CCGLProgramState.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9D7191B0175007B91BF /* CCGLProgramState.h */; }; + 500DC9DB191B0175007B91BF /* CCGLProgramState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9D8191B0175007B91BF /* CCGLProgramState.cpp */; }; + 500DC9DC191B0175007B91BF /* CCGLProgramState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9D8191B0175007B91BF /* CCGLProgramState.cpp */; }; 5027253A190BF1B900AAF4ED /* cocos2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 50272538190BF1B900AAF4ED /* cocos2d.h */; }; 5027253B190BF1B900AAF4ED /* cocos2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 50272538190BF1B900AAF4ED /* cocos2d.h */; }; 5027253C190BF1B900AAF4ED /* cocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50272539190BF1B900AAF4ED /* cocos2d.cpp */; }; @@ -2682,6 +2686,8 @@ 500DC9B519106E6D007B91BF /* TransformUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransformUtils.h; sourceTree = ""; }; 500DC9BA19106E89007B91BF /* CCProfiling.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCProfiling.cpp; path = ../base/CCProfiling.cpp; sourceTree = ""; }; 500DC9BB19106E89007B91BF /* CCProfiling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCProfiling.h; path = ../base/CCProfiling.h; sourceTree = ""; }; + 500DC9D7191B0175007B91BF /* CCGLProgramState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgramState.h; sourceTree = ""; }; + 500DC9D8191B0175007B91BF /* CCGLProgramState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgramState.cpp; sourceTree = ""; }; 50272538190BF1B900AAF4ED /* cocos2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cocos2d.h; path = ../cocos/cocos2d.h; sourceTree = ""; }; 50272539190BF1B900AAF4ED /* cocos2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cocos2d.cpp; path = ../cocos/cocos2d.cpp; sourceTree = ""; }; 50DC5180187B817900A9C23F /* RELEASE_NOTES.md */ = {isa = PBXFileReference; lastKnownFileType = text; name = RELEASE_NOTES.md; path = ../docs/RELEASE_NOTES.md; sourceTree = ""; }; @@ -3232,6 +3238,8 @@ 1A570238180BCC580088DEC7 /* shaders */ = { isa = PBXGroup; children = ( + 500DC9D7191B0175007B91BF /* CCGLProgramState.h */, + 500DC9D8191B0175007B91BF /* CCGLProgramState.cpp */, 3E9D30DD19195B22008EB309 /* CCVertexAttribBind.cpp */, 3E9D30DE19195B22008EB309 /* CCVertexAttribBind.h */, 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */, @@ -4921,6 +4929,7 @@ 500DC98C19106300007B91BF /* CCPlatformMacros.h in Headers */, 46A170131807CBFC005B8026 /* CCFileUtilsApple.h in Headers */, 46A1701F1807CBFC005B8026 /* CCImage.h in Headers */, + 500DC9D9191B0175007B91BF /* CCGLProgramState.h in Headers */, 46A170181807CBFC005B8026 /* CCApplicationProtocol.h in Headers */, 1A570063180BC5A10088DEC7 /* CCAction.h in Headers */, 1A570067180BC5A10088DEC7 /* CCActionCamera.h in Headers */, @@ -5417,6 +5426,7 @@ 500DC9AD19106300007B91BF /* ZipUtils.h in Headers */, 50FCEBC218C72017004AD434 /* TextFieldReader.h in Headers */, 1A570068180BC5A10088DEC7 /* CCActionCamera.h in Headers */, + 500DC9DA191B0175007B91BF /* CCGLProgramState.h in Headers */, 1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */, 1A570070180BC5A10088DEC7 /* CCActionEase.h in Headers */, 1A570074180BC5A10088DEC7 /* CCActionGrid.h in Headers */, @@ -6213,6 +6223,7 @@ 1A5702FA180BCE750088DEC7 /* CCTMXXMLParser.cpp in Sources */, 1A570300180BCE890088DEC7 /* CCParallaxNode.cpp in Sources */, 1A570305180BCED90088DEC7 /* ccUtils.cpp in Sources */, + 500DC9DB191B0175007B91BF /* CCGLProgramState.cpp in Sources */, 1A57030C180BCF190088DEC7 /* CCComponent.cpp in Sources */, 500DC96019106300007B91BF /* CCEventListener.cpp in Sources */, 1A570310180BCF190088DEC7 /* CCComponentContainer.cpp in Sources */, @@ -6525,6 +6536,7 @@ 1A01C68F18F57BE800EFE3A6 /* CCDictionary.cpp in Sources */, 06CAAACC186AD7F50012A414 /* TriggerMng.cpp in Sources */, 46A1703D1807CC07005B8026 /* CCCommon.mm in Sources */, + 500DC9DC191B0175007B91BF /* CCGLProgramState.cpp in Sources */, 50FCEBC818C72017004AD434 /* WidgetReader.cpp in Sources */, 46A1702F1807CBFE005B8026 /* CCGLViewProtocol.cpp in Sources */, 46A170FC1807CECB005B8026 /* CCPhysicsBody.cpp in Sources */, diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 3c0f696024..1df5b0c9b3 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -298,22 +298,28 @@ void GLProgram::parseUniforms() // Query uniform info. glGetActiveUniform(_program, i, length, NULL, &uniform._size, &uniform._type, uniformName); uniformName[length] = '\0'; - // remove possible array '[]' from uniform name - if(uniform._size > 1 && length > 3) - { - char* c = strrchr(uniformName, '['); - if(c) - { - *c = '\0'; - } - } - uniform._name = std::string(uniformName); - uniform._location = glGetUniformLocation(_program, uniformName); - - //something wrong, uniform is an object not a pointer, may be released soon - uniform.init(this); - _uniformsDictionary[uniform._name] = uniform; + // Only add uniforms that are not build-in. + // The ones that start with 'CC_' are built-ins + if(strncmp("CC_", uniformName, 3) != 0) { + + // remove possible array '[]' from uniform name + if(uniform._size > 1 && length > 3) + { + char* c = strrchr(uniformName, '['); + if(c) + { + *c = '\0'; + } + } + uniform._name = std::string(uniformName); + uniform._location = glGetUniformLocation(_program, uniformName); + + //something wrong, uniform is an object not a pointer, may be released soon + uniform.init(this); + + _uniformsDictionary[uniform._name] = uniform; + } } } } @@ -907,80 +913,4 @@ bool Uniform::init(GLProgram* program) return program && program && _location != -1; } -bool Uniform::setValue(float value) -{ - CCASSERT (_type == GL_FLOAT, ""); - _program->setUniformLocationWith1f(_location, value); - - return true; -} - -bool Uniform::setValue(int value) -{ - CCASSERT ((_type == GL_INT || _type == GL_SAMPLER_2D), ""); - _program->setUniformLocationWith1i(_location, value); - - return true; -} - -bool Uniform::setValue(const Vector2& value) -{ - CCASSERT (_type == GL_FLOAT_VEC2, ""); - _program->setUniformLocationWith2f(_location, value.x, value.y); - - return true; -} - -bool Uniform::setValue(const Vector3& value) -{ - CCASSERT (_type == GL_FLOAT_VEC3, ""); - _program->setUniformLocationWith3f(_location, value.x, value.y, value.z); - - return true; -} - -bool Uniform::setValue(const Vector4& value) -{ - CCASSERT (_type == GL_FLOAT_VEC4, ""); - _program->setUniformLocationWith4f(_location, value.x, value.y, value.z, value.w); - - return true; -} - -bool Uniform::setValue(const Matrix& value) -{ - CCASSERT(_type == GL_FLOAT_MAT4, ""); - _program->setUniformLocationWithMatrix4fv(_location, value.m, 1); - - return true; -} - -bool Uniform::setValue(const Vector2* value, int count) -{ - CCASSERT (_type == GL_FLOAT_VEC2 && _size == count, ""); - _program->setUniformLocationWith2fv(_location, (GLfloat*)value, count); - return true; -} - -bool Uniform::setValue(const Vector3* value, int count) -{ - CCASSERT (_type == GL_FLOAT_VEC3 && _size == count, ""); - _program->setUniformLocationWith3fv(_location, (GLfloat*)value, count); - return true; -} - -bool Uniform::setValue(const Vector4* value, int count) -{ - CCASSERT (_type == GL_FLOAT_VEC4 && _size == count, ""); - _program->setUniformLocationWith4fv(_location, (GLfloat*)value, count); - return true; -} - -bool Uniform::setValue(const Matrix* value, int count) -{ - CCASSERT (_type == GL_FLOAT_MAT4 && _size == count, ""); - _program->setUniformLocationWithMatrix4fv(_location, (GLfloat*)value, count); - return true; -} - NS_CC_END diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index 36f9c67cd6..603af3ec38 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -32,9 +32,9 @@ THE SOFTWARE. #include "base/ccMacros.h" #include "base/CCRef.h" +#include "base/ccTypes.h" #include "CCGL.h" #include "math/CCMath.h" -#include #include NS_CC_BEGIN @@ -56,6 +56,7 @@ typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length, class VertexAttrib { friend class GLProgram; + friend class VertexAttribValue; friend class VertexAttribBind; public: @@ -81,21 +82,13 @@ protected: class Uniform { friend class GLProgram; + friend class UniformValue; public: Uniform(); ~Uniform(); bool init(GLProgram* program); - bool setValue(float value); - bool setValue(int value); - bool setValue(const Vector2& value); - bool setValue(const Vector3& value); - bool setValue(const Vector4& value); - bool setValue(const Matrix& value); - bool setValue(const Vector2* value, int count); - bool setValue(const Vector3* value, int count); - bool setValue(const Vector4* value, int count); - bool setValue(const Matrix* value, int count); + void apply(); protected: GLint _location; @@ -105,7 +98,6 @@ protected: GLProgram* _program; // weak ref }; - /** GLProgram Class that implements a glProgram @@ -114,6 +106,8 @@ protected: */ class CC_DLL GLProgram : public Ref { + friend class GLProgramState; + public: enum { @@ -366,9 +360,6 @@ protected: std::unordered_map _attributesDictionary; }; -// end of shaders group -/// @} - NS_CC_END #endif /* __CCGLPROGRAM_H__ */ diff --git a/cocos/2d/CCGLProgramState.cpp b/cocos/2d/CCGLProgramState.cpp new file mode 100644 index 0000000000..8297a66627 --- /dev/null +++ b/cocos/2d/CCGLProgramState.cpp @@ -0,0 +1,272 @@ +/**************************************************************************** +Copyright 2011 Jeff Lamarche +Copyright 2012 Goffredo Marocchi +Copyright 2012 Ricardo Quesada +Copyright 2012 cocos2d-x.org +Copyright 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 false 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 "2d/CCGLProgramState.h" +#include "2d/CCGLProgram.h" +#include "2d/ccGLStateCache.h" + +NS_CC_BEGIN + +// +// +// UniformValue +// +// + +UniformValue::UniformValue() +: _useCallback(false) +, _uniform(nullptr) +{ +} + +UniformValue::UniformValue(Uniform *uniform) +: _useCallback(false) +, _uniform(uniform) +{ +} + +void UniformValue::apply() +{ + if(_useCallback) { + _value.callback(_uniform); + } + else + { + switch (_uniform->_type) { + case GL_FLOAT: + _uniform->_program->setUniformLocationWith1f(_uniform->_location, _value.floatValue); + break; + + case GL_INT: + case GL_SAMPLER_2D: + _uniform->_program->setUniformLocationWith1i(_uniform->_location, _value.intValue); + break; + + case GL_FLOAT_VEC2: + _uniform->_program->setUniformLocationWith2f(_uniform->_location, _value.v2Value.x, _value.v2Value.y); + break; + + case GL_FLOAT_VEC3: + _uniform->_program->setUniformLocationWith3f(_uniform->_location, _value.v3Value.x, _value.v3Value.y, _value.v3Value.z); + break; + + case GL_FLOAT_VEC4: + _uniform->_program->setUniformLocationWith4f(_uniform->_location, _value.v4Value.x, _value.v4Value.y, _value.v4Value.z, _value.v4Value.w); + break; + + case GL_FLOAT_MAT4: + _uniform->_program->setUniformLocationWithMatrix4fv(_uniform->_location, (GLfloat*)&_value.matrixValue, 1); + break; + + default: + CCASSERT(false, "Invalid UniformValue"); + break; + } + } +} + +void UniformValue::setValue(const std::function callback) +{ + _value.callback = callback; + _useCallback = true; +} + +void UniformValue::setValue(float value) +{ + CCASSERT (_uniform->_type == GL_FLOAT, ""); + _value.floatValue = value; +} + +void UniformValue::setValue(int value) +{ + CCASSERT ((_uniform->_type == GL_INT || _uniform->_type == GL_SAMPLER_2D), ""); + _value.intValue = value; +} + +void UniformValue::setValue(const Vector2& value) +{ + CCASSERT (_uniform->_type == GL_FLOAT_VEC2, ""); + _value.v2Value = value; +} + +void UniformValue::setValue(const Vector3& value) +{ + CCASSERT (_uniform->_type == GL_FLOAT_VEC3, ""); + _value.v3Value = value; +} + +void UniformValue::setValue(const Vector4& value) +{ + CCASSERT (_uniform->_type == GL_FLOAT_VEC4, ""); + _value.v4Value = value; +} + +void UniformValue::setValue(const Matrix& value) +{ + CCASSERT(_uniform->_type == GL_FLOAT_MAT4, ""); + _value.matrixValue = value; +} + +// +// +// VertexAttribValue +// +// + +VertexAttribValue::VertexAttribValue() +: _useCallback(false) +, _vertexAttrib(nullptr) +{ +} + +VertexAttribValue::VertexAttribValue(VertexAttrib *vertexAttrib) +: _useCallback(false) +, _vertexAttrib(vertexAttrib) +{ +} + +void VertexAttribValue::apply() +{ + GL::enableVertexAttribs(0); + + if(_useCallback) { + _value.callback(_vertexAttrib); + } + else + { + glVertexAttribPointer(_vertexAttrib->_index, + _value.pointer.size, + _value.pointer.type, + _value.pointer.normalized, + _value.pointer.stride, + _value.pointer.pointer); + } +} + +void VertexAttribValue::setValue(const std::function callback) +{ + _value.callback = callback; + _useCallback = true; +} + +void VertexAttribValue::setValue(GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer) +{ + _value.pointer.size = size; + _value.pointer.type = type; + _value.pointer.normalized = normalized; + _value.pointer.stride = stride; + _value.pointer.pointer = pointer; +} + +// +// +// GLProgramState +// +// + +GLProgramState* GLProgramState::create(GLProgram *glprogram) +{ + CCASSERT(glprogram, "invalid shader"); + + auto ret = new (std::nothrow) GLProgramState; + if(ret && ret->init(glprogram)) { + ret->autorelease(); + return ret; + } + CC_SAFE_RELEASE(ret); + return nullptr; +} + +GLProgramState::~GLProgramState() +{ + _glprogram->release(); +} + +bool GLProgramState::init(GLProgram* glprogram) +{ + _glprogram = glprogram; + _glprogram->retain(); + + for(auto &attrib : _glprogram->_attributesDictionary) { + VertexAttribValue value(&attrib.second); + _attributes[attrib.first] = value; + } + + for(auto &uniform : _glprogram->_uniformsDictionary) { + UniformValue value(&uniform.second); + _uniforms[uniform.first] = value; + } + + return true; +} +void GLProgramState::apply() +{ + CCASSERT(_glprogram, "invalid glprogram"); + + // set shader + _glprogram->use(); + + + // set texture + int i = 0; + for(const auto& texture : _textures) { + GL::bindTexture2DN(i++, texture->getName()); + } + + // set blending function + GL::blendFunc(_blendFunc.src, _blendFunc.dst); + + + // set uniforms + for(auto& uniform : _uniforms) { + uniform.second.apply(); + } + + // set attributes + for(auto &attribute : _attributes) { + attribute.second.apply(); + } +} + +UniformValue* GLProgramState::getUniformValue(const std::string &name) +{ + const auto itr = _uniforms.find(name); + if( itr != _uniforms.end()) + return &itr->second; + return nullptr; +} + +VertexAttribValue* GLProgramState::getVertexAttribValue(const std::string &name) +{ + const auto itr = _attributes.find(name); + if( itr != _attributes.end()) + return &itr->second; + return nullptr; +} + +NS_CC_END diff --git a/cocos/2d/CCGLProgramState.h b/cocos/2d/CCGLProgramState.h new file mode 100644 index 0000000000..0c7ab8026b --- /dev/null +++ b/cocos/2d/CCGLProgramState.h @@ -0,0 +1,166 @@ +/**************************************************************************** +Copyright 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 __CCGLPROGRAMSTATE_H__ +#define __CCGLPROGRAMSTATE_H__ + +#include "base/ccTypes.h" +#include "base/CCVector.h" +#include "2d/CCTexture2D.h" +#include "math/Vector2.h" +#include "math/Vector3.h" +#include "math/Vector4.h" + +#include + +NS_CC_BEGIN + +class GLProgram; +class Uniform; +class VertexAttrib; + +// +// +// UniformValue +// +// +class UniformValue +{ + friend class GLProgram; + +public: + UniformValue(); + UniformValue(Uniform *uniform); + ~UniformValue(); + + void setValue(float value); + void setValue(int value); + void setValue(const Vector2& value); + void setValue(const Vector3& value); + void setValue(const Vector4& value); + void setValue(const Matrix& value); + void setValue(const std::function callback); + + void apply(); + +protected: + Uniform* _uniform; // weak ref + bool _useCallback; + + union U{ + float floatValue; + int intValue; + Vector2 v2Value; + Vector3 v3Value; + Vector4 v4Value; + Matrix matrixValue; + std::function callback; + + U() { memset( this, 0, sizeof(*this) ); } + ~U(){} + U& operator=( const U& other ) { + memcpy(this, &other, sizeof(*this)); + return *this; + } + } _value; +}; + +// +// +// VertexAttribValue +// +// +class VertexAttribValue +{ + friend class GLProgram; + +public: + VertexAttribValue(VertexAttrib *vertexAttrib); + VertexAttribValue(); + ~VertexAttribValue(); + + void setValue(GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer); + void setValue(const std::function callback); + void apply(); + +protected: + VertexAttrib* _vertexAttrib; // weak ref + bool _useCallback; + + union U{ + struct { + GLint size; + GLenum type; + GLboolean normalized; + GLsizei stride; + GLvoid *pointer; + } pointer; + std::function callback; + + U() { memset( this, 0, sizeof(*this) ); } + ~U(){} + U& operator=( const U& other ) { + memcpy(this, &other, sizeof(*this)); + return *this; + } + } _value; +}; + + +// +// +// GLProgramState +// +// +class GLProgramState : public Ref +{ +public: + GLProgramState* create(GLProgram* glprogram); + + void apply(); + void setTexture(Texture2D *texture) { _textures.insert(0, texture); } + Texture2D* getTexture() const { return _textures.at(0); } + + void setBlendFunc(const BlendFunc& blendFunc) { _blendFunc = blendFunc; } + const BlendFunc& getBlendFunc() const { return _blendFunc; } + + UniformValue* getUniformValue(const std::string &uniformName); + VertexAttribValue* getVertexAttribValue(const std::string &attributeName); + +protected: + GLProgramState(); + ~GLProgramState(); + bool init(GLProgram* program); + + std::unordered_map _uniforms; + std::unordered_map _attributes; + + GLProgram *_glprogram; + Vector _textures; + BlendFunc _blendFunc; +}; + +NS_CC_END + +#endif /* __CCGLPROGRAMSTATE_H__ */ diff --git a/cocos/2d/ccGLStateCache.cpp b/cocos/2d/ccGLStateCache.cpp index 82fd077350..466e202189 100644 --- a/cocos/2d/ccGLStateCache.cpp +++ b/cocos/2d/ccGLStateCache.cpp @@ -35,11 +35,9 @@ NS_CC_BEGIN namespace { - static GLuint s_currentProjectionMatrix = -1; - static bool s_vertexAttribPosition = false; - static bool s_vertexAttribColor = false; - static bool s_vertexAttribTexCoords = false; - + static GLuint s_currentProjectionMatrix = -1; + static unsigned int s_attributeFlags = 0; + #if CC_ENABLE_GL_STATE_CACHE #define kMaxActiveTexture 16 @@ -63,10 +61,8 @@ void invalidateStateCache( void ) { Director::getInstance()->resetMatrixStack(); s_currentProjectionMatrix = -1; - s_vertexAttribPosition = false; - s_vertexAttribColor = false; - s_vertexAttribTexCoords = false; - + s_attributeFlags = 0; + #if CC_ENABLE_GL_STATE_CACHE s_currentShaderProgram = -1; for( int i=0; i < kMaxActiveTexture; i++ ) @@ -217,42 +213,20 @@ void bindVAO(GLuint vaoId) void enableVertexAttribs( unsigned int flags ) { bindVAO(0); - - /* Position */ - bool enablePosition = flags & VERTEX_ATTRIB_FLAG_POSITION; - if( enablePosition != s_vertexAttribPosition ) { - if( enablePosition ) - glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_POSITION ); - else - glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_POSITION ); - - s_vertexAttribPosition = enablePosition; - } - - /* Color */ - bool enableColor = (flags & VERTEX_ATTRIB_FLAG_COLOR) != 0 ? true : false; - - if( enableColor != s_vertexAttribColor ) { - if( enableColor ) - glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_COLOR ); - else - glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_COLOR ); - - s_vertexAttribColor = enableColor; - } - - /* Tex Coords */ - bool enableTexCoords = (flags & VERTEX_ATTRIB_FLAG_TEX_COORDS) != 0 ? true : false; - - if( enableTexCoords != s_vertexAttribTexCoords ) { - if( enableTexCoords ) - glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_TEX_COORDS ); - else - glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_TEX_COORDS ); - - s_vertexAttribTexCoords = enableTexCoords; + // hardcoded! + for(int i=0; i < 16; i++) { + unsigned int bit = 1 << i; + bool enabled = flags & bit; + bool enabledBefore = s_attributeFlags & bit; + if(enabled != enabledBefore) { + if( enabled ) + glEnableVertexAttribArray(i); + else + glDisableVertexAttribArray(i); + } } + s_attributeFlags = flags; } // GL Uniforms functions diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 077897401f..5a816b4152 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -191,8 +191,9 @@ void ShaderNode::onDraw(const Matrix &transform, bool transformUpdated) shader->use(); shader->setUniformsForBuiltins(transform); - shader->getUniform("center")->setValue(_center); - shader->getUniform("resolution")->setValue(_resolution); + // TODO: riq FIXME +// shader->getUniform("center")->setValue(_center); +// shader->getUniform("resolution")->setValue(_resolution); GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION ); @@ -522,9 +523,10 @@ void SpriteBlur::onDraw(const Matrix &transform, bool transformUpdated) program->use(); program->setUniformsForBuiltins(transform); - program->getUniform("onePixelSize")->setValue(_pixelSize); - program->getUniform("gaussianCoefficient")->setValue(Vector4(_samplingRadius, _scale, _cons, _weightSum)); - + // TODO: riq FIXME +// program->getUniform("onePixelSize")->setValue(_pixelSize); +// program->getUniform("gaussianCoefficient")->setValue(Vector4(_samplingRadius, _scale, _cons, _weightSum)); + GL::bindTexture2D( getTexture()->getName()); // diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index ce1425acd1..1cfad92cb3 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -760,11 +760,9 @@ void UniformSprite::draw(Renderer *renderer, const Matrix &transform, bool trans void UniformSprite::setCustomUniforms() { - - std::string name = "center"; - _shaderProgram->getUniform(name)->setValue(Vector2(480,320)); - name = "resolution"; - _shaderProgram->getUniform(name)->setValue(Vector2(256,256)); + // FIXME riq TODO +// _shaderProgram->getUniform("center")->setValue(Vector2(480,320)); +// _shaderProgram->getUniform("resolution")->setValue(Vector2(256,256)); } void UniformSprite::onDraw(const Matrix &transform, bool transformUpdated) @@ -843,7 +841,7 @@ void AttribSprite::initShader() auto shader = GLProgram::createWithFilenames(_vertSourceFile, _fragSourceFile); shader->link(); shader->updateUniforms(); - this->setShaderProgram(shader); + this->setShaderProgram(shader); } void AttribSprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -855,8 +853,6 @@ void AttribSprite::draw(Renderer *renderer, const Matrix &transform, bool transf void AttribSprite::setCustomUniforms() { - - } void AttribSprite::onDraw(const Matrix &transform, bool transformUpdated) From 420439cdea131853583c10df0f85a301052155b9 Mon Sep 17 00:00:00 2001 From: Hector Date: Thu, 8 May 2014 11:20:25 +0800 Subject: [PATCH 014/174] update cpp-default-template for android *Eclipse* --- .../cocos-project-template.json | 1 + .../proj.android/.classpath | 1 + .../proj.android/.cproject | 103 ++++++++++++++++++ .../proj.android/.project | 82 ++++++++++++-- .../org.eclipse.cdt.codan.core.prefs | 68 ++++++++++++ .../.settings/org.eclipse.cdt.core.prefs | 3 + .../org.eclipse.ltk.core.refactoring.prefs | 2 + .../proj.android/README.md | 73 ++----------- 8 files changed, 261 insertions(+), 72 deletions(-) create mode 100644 templates/cpp-template-default/proj.android/.cproject create mode 100644 templates/cpp-template-default/proj.android/.settings/org.eclipse.cdt.codan.core.prefs create mode 100644 templates/cpp-template-default/proj.android/.settings/org.eclipse.cdt.core.prefs create mode 100644 templates/cpp-template-default/proj.android/.settings/org.eclipse.ltk.core.refactoring.prefs diff --git a/templates/cpp-template-default/cocos-project-template.json b/templates/cpp-template-default/cocos-project-template.json index f9da88c963..7246f50171 100644 --- a/templates/cpp-template-default/cocos-project-template.json +++ b/templates/cpp-template-default/cocos-project-template.json @@ -23,6 +23,7 @@ "proj.win32/PROJECT_NAME.sln", "proj.win32/main.cpp", "proj.android/.project", + "proj.android/.cproject", "proj.android/AndroidManifest.xml", "proj.android/build.xml", "proj.android/res/values/strings.xml", diff --git a/templates/cpp-template-default/proj.android/.classpath b/templates/cpp-template-default/proj.android/.classpath index 0b08408342..b3e30abe7f 100644 --- a/templates/cpp-template-default/proj.android/.classpath +++ b/templates/cpp-template-default/proj.android/.classpath @@ -4,6 +4,7 @@ + diff --git a/templates/cpp-template-default/proj.android/.cproject b/templates/cpp-template-default/proj.android/.cproject new file mode 100644 index 0000000000..9b9df7c251 --- /dev/null +++ b/templates/cpp-template-default/proj.android/.cproject @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/cpp-template-default/proj.android/.project b/templates/cpp-template-default/proj.android/.project index ca9146dc08..13490a653a 100644 --- a/templates/cpp-template-default/proj.android/.project +++ b/templates/cpp-template-default/proj.android/.project @@ -3,6 +3,7 @@ HelloCpp + libcocos2dx @@ -20,6 +21,72 @@ + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?children? + ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + ${ProjDirPath}/build_native.py + + + org.eclipse.cdt.make.core.buildCommand + python + + + org.eclipse.cdt.make.core.buildLocation + ${ProjDirPath} + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + false + + + com.android.ide.eclipse.adt.ApkBuilder @@ -44,22 +111,17 @@ Classes 2 - COCOS2DX/projects/HelloCpp/Classes + $%7BPARENT-1-PROJECT_LOC%7D/Classes - cocos2dx + cocos2d 2 - COCOS2DX/cocos2dx + $%7BPARENT-1-PROJECT_LOC%7D/cocos2d - extensions + libcocos2d 2 - COCOS2DX/extensions - - - scripting - 2 - COCOS2DX/scripting + PARENT-1-PROJECT_LOC/cocos2d/cocos/2d/platform/android/java/src diff --git a/templates/cpp-template-default/proj.android/.settings/org.eclipse.cdt.codan.core.prefs b/templates/cpp-template-default/proj.android/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 0000000000..777dc0a30f --- /dev/null +++ b/templates/cpp-template-default/proj.android/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,68 @@ +eclipse.preferences.version=1 +org.eclipse.cdt.codan.checkers.errnoreturn=Warning +org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} +org.eclipse.cdt.codan.checkers.errreturnvalue=-Error +org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.checkers.noreturn=-Error +org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=-Error +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=-Error +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=-Error +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false} +org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning +org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=-Error +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true} +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidArguments=-Error +org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=-Error +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=-Error +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=-Error +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.OverloadProblem=-Error +org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=-Error +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false} +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false} +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")} +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +useParentScope=false diff --git a/templates/cpp-template-default/proj.android/.settings/org.eclipse.cdt.core.prefs b/templates/cpp-template-default/proj.android/.settings/org.eclipse.cdt.core.prefs new file mode 100644 index 0000000000..f91f6d5001 --- /dev/null +++ b/templates/cpp-template-default/proj.android/.settings/org.eclipse.cdt.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +environment/project/0.1230402123/append=true +environment/project/0.1230402123/appendContributed=true diff --git a/templates/cpp-template-default/proj.android/.settings/org.eclipse.ltk.core.refactoring.prefs b/templates/cpp-template-default/proj.android/.settings/org.eclipse.ltk.core.refactoring.prefs new file mode 100644 index 0000000000..b196c64a34 --- /dev/null +++ b/templates/cpp-template-default/proj.android/.settings/org.eclipse.ltk.core.refactoring.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/templates/cpp-template-default/proj.android/README.md b/templates/cpp-template-default/proj.android/README.md index 53cb259634..ff6c44369c 100644 --- a/templates/cpp-template-default/proj.android/README.md +++ b/templates/cpp-template-default/proj.android/README.md @@ -13,75 +13,24 @@ There are two ways of building Android projects. ### Import Project in Eclipse -#### Features: +####Step 1: C/C++ Environment Variable `NDK_ROOT` -1. Complete workflow from Eclipse, including: - * Build C++. - * Clean C++. - * Build and Run whole project. - * Logcat view. - * Debug Java code. - * Javascript editor. - * Project management. -2. True C++ editing, including: - * Code completion. - * Jump to definition. - * Refactoring tools etc. - * Quick open C++ files. +* Eclipse->Preferences->C/C++->Build->**Environment**. +* Click **Add** button and add a new variable `NDK_ROOT` pointing to the root NDK directory. + ![Example](https://lh3.googleusercontent.com/-AVcY8IAT0_g/UUOYltoRobI/AAAAAAAAsdM/22D2J9u3sig/s400/cocos2d-x-eclipse-ndk.png) +* Only for Windows: Add new variables **CYGWIN** with value `nodosfilewarning` and **SHELLOPTS** with value `igncr` - -#### Setup Eclipse Environment (only once) - - -**NOTE:** This step needs to be done only once to setup the Eclipse environment for cocos2d-x projects. Skip this section if you've done this before. - -1. Download Eclipse ADT bundle from [Google ADT homepage](http://developer.android.com/sdk/index.html) - - **OR** - - Install Eclipse with Java. Add ADT and CDT plugins. - -2. Only for Windows - 1. Install [Cygwin](http://www.cygwin.com/) with make (select make package from the list during the install). - 2. Add `Cygwin\bin` directory to system PATH variable. - 3. Add this line `none /cygdrive cygdrive binary,noacl,posix=0,user 0 0` to `Cygwin\etc\fstab` file. - -3. Set up Variables: - 1. Path Variable `COCOS2DX`: - * Eclipse->Preferences->General->Workspace->**Linked Resources** - * Click **New** button to add a Path Variable `COCOS2DX` pointing to the root cocos2d-x directory. - ![Example](https://lh5.googleusercontent.com/-oPpk9kg3e5w/UUOYlq8n7aI/AAAAAAAAsdQ/zLA4eghBH9U/s400/cocos2d-x-eclipse-vars.png) - - 2. C/C++ Environment Variable `NDK_ROOT`: - * Eclipse->Preferences->C/C++->Build->**Environment**. - * Click **Add** button and add a new variable `NDK_ROOT` pointing to the root NDK directory. - ![Example](https://lh3.googleusercontent.com/-AVcY8IAT0_g/UUOYltoRobI/AAAAAAAAsdM/22D2J9u3sig/s400/cocos2d-x-eclipse-ndk.png) - * Only for Windows: Add new variables **CYGWIN** with value `nodosfilewarning` and **SHELLOPTS** with value `igncr` - -4. Import libcocos2dx library project: - 1. File->New->Project->Android Project From Existing Code. - 2. Click **Browse** button and open `cocos2d-x/cocos2dx/platform/android/java` directory. - 3. Click **Finish** to add project. - -#### Adding and running from Eclipse +####Step 2: Adding and running from Eclipse ![Example](https://lh3.googleusercontent.com/-SLBOu6e3QbE/UUOcOXYaGqI/AAAAAAAAsdo/tYBY2SylOSM/s288/cocos2d-x-eclipse-project-from-code.png) ![Import](https://lh5.googleusercontent.com/-XzC9Pn65USc/UUOcOTAwizI/AAAAAAAAsdk/4b6YM-oim9Y/s400/cocos2d-x-eclipse-import-project.png) 1. File->New->Project->Android Project From Existing Code -2. **Browse** to your project directory. eg: `cocos2d-x/cocos2dx/samples/Cpp/TestCpp/proj.android/` -3. Add the project -4. Click **Run** or **Debug** to compile C++ followed by Java and to run on connected device or emulator. +2. **Browse** to your project directory and Add the project +3. Click **Run as Android Application** to run on connected device or emulator. +That's all !!! ### Running project from Command Line - $ cd cocos2d-x/samples/Cpp/TestCpp/proj.android/ - $ export NDK_ROOT=/path/to/ndk - $ ./build_native.sh - $ ant debug install - -If the last command results in sdk.dir missing error then do: - - $ android list target - $ android update project -p . -t (id from step 6) - $ android update project -p cocos2d/cocos/2d/platform/android/java/ -t (id from step 6) + $ cd NEW_PROJECTS_DIR/MyGame + $ cocos run -p android -j 4 From 4b15b884e7057535ae03d3698b69ecb9db137708 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 7 May 2014 20:38:15 -0700 Subject: [PATCH 015/174] Uniform is a struct --- cocos/2d/CCGLProgram.cpp | 33 +++++---------------------------- cocos/2d/CCGLProgram.h | 21 +++++---------------- cocos/2d/CCGLProgramState.cpp | 32 +++++++++++++++++--------------- cocos/2d/CCGLProgramState.h | 5 +++-- 4 files changed, 30 insertions(+), 61 deletions(-) diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 1df5b0c9b3..0daa935b77 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -296,7 +296,7 @@ void GLProgram::parseUniforms() for(int i = 0; i < activeUniforms; ++i) { // Query uniform info. - glGetActiveUniform(_program, i, length, NULL, &uniform._size, &uniform._type, uniformName); + glGetActiveUniform(_program, i, length, NULL, &uniform.size, &uniform.type, uniformName); uniformName[length] = '\0'; // Only add uniforms that are not build-in. @@ -304,7 +304,7 @@ void GLProgram::parseUniforms() if(strncmp("CC_", uniformName, 3) != 0) { // remove possible array '[]' from uniform name - if(uniform._size > 1 && length > 3) + if(uniform.size > 1 && length > 3) { char* c = strrchr(uniformName, '['); if(c) @@ -312,13 +312,10 @@ void GLProgram::parseUniforms() *c = '\0'; } } - uniform._name = std::string(uniformName); - uniform._location = glGetUniformLocation(_program, uniformName); + uniform.name = std::string(uniformName); + uniform.location = glGetUniformLocation(_program, uniformName); - //something wrong, uniform is an object not a pointer, may be released soon - uniform.init(this); - - _uniformsDictionary[uniform._name] = uniform; + _uniformsDictionary[uniform.name] = uniform; } } } @@ -893,24 +890,4 @@ void VertexAttrib::redefineTypeAndSize(GLenum type, GLint size, GLboolean normal _normalized = normalized; } -// -// Uniform -// - -Uniform::Uniform() -:_program(nullptr) -{ - -} - -Uniform::~Uniform() -{ -} - -bool Uniform::init(GLProgram* program) -{ - _program = program; - return program && program && _location != -1; -} - NS_CC_END diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index 603af3ec38..525e30dbf7 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -79,23 +79,12 @@ protected: std::string _name; }; -class Uniform +struct Uniform { - friend class GLProgram; - friend class UniformValue; - -public: - Uniform(); - ~Uniform(); - bool init(GLProgram* program); - void apply(); - -protected: - GLint _location; - GLint _size; - std::string _name; - GLenum _type; - GLProgram* _program; // weak ref + GLint location; + GLint size; + std::string name; + GLenum type; }; /** GLProgram diff --git a/cocos/2d/CCGLProgramState.cpp b/cocos/2d/CCGLProgramState.cpp index 8297a66627..b5326ad7d9 100644 --- a/cocos/2d/CCGLProgramState.cpp +++ b/cocos/2d/CCGLProgramState.cpp @@ -41,12 +41,14 @@ NS_CC_BEGIN UniformValue::UniformValue() : _useCallback(false) , _uniform(nullptr) +, _glprogram(nullptr) { } -UniformValue::UniformValue(Uniform *uniform) +UniformValue::UniformValue(Uniform *uniform, GLProgram* glprogram) : _useCallback(false) , _uniform(uniform) +, _glprogram(glprogram) { } @@ -57,30 +59,30 @@ void UniformValue::apply() } else { - switch (_uniform->_type) { + switch (_uniform->type) { case GL_FLOAT: - _uniform->_program->setUniformLocationWith1f(_uniform->_location, _value.floatValue); + _glprogram->setUniformLocationWith1f(_uniform->location, _value.floatValue); break; case GL_INT: case GL_SAMPLER_2D: - _uniform->_program->setUniformLocationWith1i(_uniform->_location, _value.intValue); + _glprogram->setUniformLocationWith1i(_uniform->location, _value.intValue); break; case GL_FLOAT_VEC2: - _uniform->_program->setUniformLocationWith2f(_uniform->_location, _value.v2Value.x, _value.v2Value.y); + _glprogram->setUniformLocationWith2f(_uniform->location, _value.v2Value.x, _value.v2Value.y); break; case GL_FLOAT_VEC3: - _uniform->_program->setUniformLocationWith3f(_uniform->_location, _value.v3Value.x, _value.v3Value.y, _value.v3Value.z); + _glprogram->setUniformLocationWith3f(_uniform->location, _value.v3Value.x, _value.v3Value.y, _value.v3Value.z); break; case GL_FLOAT_VEC4: - _uniform->_program->setUniformLocationWith4f(_uniform->_location, _value.v4Value.x, _value.v4Value.y, _value.v4Value.z, _value.v4Value.w); + _glprogram->setUniformLocationWith4f(_uniform->location, _value.v4Value.x, _value.v4Value.y, _value.v4Value.z, _value.v4Value.w); break; case GL_FLOAT_MAT4: - _uniform->_program->setUniformLocationWithMatrix4fv(_uniform->_location, (GLfloat*)&_value.matrixValue, 1); + _glprogram->setUniformLocationWithMatrix4fv(_uniform->location, (GLfloat*)&_value.matrixValue, 1); break; default: @@ -98,37 +100,37 @@ void UniformValue::setValue(const std::function callback) void UniformValue::setValue(float value) { - CCASSERT (_uniform->_type == GL_FLOAT, ""); + CCASSERT (_uniform->type == GL_FLOAT, ""); _value.floatValue = value; } void UniformValue::setValue(int value) { - CCASSERT ((_uniform->_type == GL_INT || _uniform->_type == GL_SAMPLER_2D), ""); + CCASSERT ((_uniform->type == GL_INT || _uniform->type == GL_SAMPLER_2D), ""); _value.intValue = value; } void UniformValue::setValue(const Vector2& value) { - CCASSERT (_uniform->_type == GL_FLOAT_VEC2, ""); + CCASSERT (_uniform->type == GL_FLOAT_VEC2, ""); _value.v2Value = value; } void UniformValue::setValue(const Vector3& value) { - CCASSERT (_uniform->_type == GL_FLOAT_VEC3, ""); + CCASSERT (_uniform->type == GL_FLOAT_VEC3, ""); _value.v3Value = value; } void UniformValue::setValue(const Vector4& value) { - CCASSERT (_uniform->_type == GL_FLOAT_VEC4, ""); + CCASSERT (_uniform->type == GL_FLOAT_VEC4, ""); _value.v4Value = value; } void UniformValue::setValue(const Matrix& value) { - CCASSERT(_uniform->_type == GL_FLOAT_MAT4, ""); + CCASSERT(_uniform->type == GL_FLOAT_MAT4, ""); _value.matrixValue = value; } @@ -218,7 +220,7 @@ bool GLProgramState::init(GLProgram* glprogram) } for(auto &uniform : _glprogram->_uniformsDictionary) { - UniformValue value(&uniform.second); + UniformValue value(&uniform.second, _glprogram); _uniforms[uniform.first] = value; } diff --git a/cocos/2d/CCGLProgramState.h b/cocos/2d/CCGLProgramState.h index 0c7ab8026b..9b150dbd7c 100644 --- a/cocos/2d/CCGLProgramState.h +++ b/cocos/2d/CCGLProgramState.h @@ -51,7 +51,7 @@ class UniformValue public: UniformValue(); - UniformValue(Uniform *uniform); + UniformValue(Uniform *uniform, GLProgram* glprogram); ~UniformValue(); void setValue(float value); @@ -66,8 +66,9 @@ public: protected: Uniform* _uniform; // weak ref + GLProgram* _glprogram; // weak ref bool _useCallback; - + union U{ float floatValue; int intValue; From 0c2fd977eac6d967277f3bc6dd29cc5f3343a9cf Mon Sep 17 00:00:00 2001 From: andyque Date: Thu, 8 May 2014 18:10:21 +0800 Subject: [PATCH 016/174] issue #5057. add UIDeprecated.h and refactor FocusDirection to inner class of Widget and also simplify the enum value --- build/cocos2d_libs.xcodeproj/project.pbxproj | 2 + cocos/ui/CocosGUI.h | 1 + cocos/ui/UIDeprecated.h | 25 +++++++++ cocos/ui/UILayout.cpp | 56 +++++++++---------- cocos/ui/UIWidget.cpp | 3 +- cocos/ui/UIWidget.h | 16 +++--- .../UIFocusTest/UIFocusTest.cpp | 8 +-- 7 files changed, 71 insertions(+), 40 deletions(-) create mode 100644 cocos/ui/UIDeprecated.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 4b7d3d067b..d5c4ce007d 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -2287,6 +2287,7 @@ 2905FA1218CF08D100240AA3 /* UITextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UITextField.h; sourceTree = ""; }; 2905FA1318CF08D100240AA3 /* UIWidget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIWidget.cpp; sourceTree = ""; }; 2905FA1418CF08D100240AA3 /* UIWidget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWidget.h; sourceTree = ""; }; + 29080DEB191B82CE0066F8DF /* UIDeprecated.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIDeprecated.h; sourceTree = ""; }; 296CAD201915EC8000C64FBF /* CCEventFocus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCEventFocus.cpp; path = ../base/CCEventFocus.cpp; sourceTree = ""; }; 296CAD211915EC8000C64FBF /* CCEventFocus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCEventFocus.h; path = ../base/CCEventFocus.h; sourceTree = ""; }; 296CAD261915EC9900C64FBF /* CCEventListenerFocus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCEventListenerFocus.cpp; path = ../base/CCEventListenerFocus.cpp; sourceTree = ""; }; @@ -4021,6 +4022,7 @@ 50E6D33118E174130051CA34 /* UIRelativeBox.h */, 50E6D33218E174130051CA34 /* UIVBox.cpp */, 50E6D33318E174130051CA34 /* UIVBox.h */, + 29080DEB191B82CE0066F8DF /* UIDeprecated.h */, ); name = ui; path = ../cocos/ui; diff --git a/cocos/ui/CocosGUI.h b/cocos/ui/CocosGUI.h index 296f0508fb..1df97eb225 100644 --- a/cocos/ui/CocosGUI.h +++ b/cocos/ui/CocosGUI.h @@ -45,6 +45,7 @@ THE SOFTWARE. #include "ui/UIHBox.h" #include "ui/UIVBox.h" #include "ui/UIRelativeBox.h" +#include "ui/UIDeprecated.h" NS_CC_BEGIN namespace ui { diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h new file mode 100644 index 0000000000..c693101562 --- /dev/null +++ b/cocos/ui/UIDeprecated.h @@ -0,0 +1,25 @@ +// +// UIDeprecated.h +// cocos2d_libs +// +// Created by guanghui on 5/8/14. +// +// + +#ifndef cocos2d_libs_UIDeprecated_h +#define cocos2d_libs_UIDeprecated_h + +#include "base/CCPlatformMacros.h" +#include "UIWidget.h" + +NS_CC_BEGIN + +namespace ui { + + +} + + +NS_CC_END + +#endif diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 9c32d8d3aa..73682844c6 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -1675,7 +1675,7 @@ int Layout::findNearestChildWidgetIndex(FocusDirection direction, Widget* baseWi float distance = FLT_MAX; int found = 0; - if (direction == FocusDirection::FocusDirection_Left || direction == FocusDirection::FocusDirection_Right) + if (direction == FocusDirection::LEFT || direction == FocusDirection::RIGHT) { Vector2 widgetPosition = this->getWorldCenterPoint(baseWidget); while (index < count) @@ -1709,7 +1709,7 @@ int Layout::findNearestChildWidgetIndex(FocusDirection direction, Widget* baseWi index = 0; found = 0; distance = FLT_MAX; - if (direction == FocusDirection::FocusDirection_Down || direction == FocusDirection::FocusDirection_Up) { + if (direction == FocusDirection::DOWN || direction == FocusDirection::UP) { Vector2 widgetPosition = this->getWorldCenterPoint(baseWidget); while (index < count) { @@ -1743,7 +1743,7 @@ int Layout::findNearestChildWidgetIndex(FocusDirection direction, Widget* baseWi return 0; } -int Layout::findFarestChildWidgetIndex(cocos2d::ui::FocusDirection direction, cocos2d::ui::Widget *baseWidget) +int Layout::findFarestChildWidgetIndex(FocusDirection direction, cocos2d::ui::Widget *baseWidget) { if (baseWidget == nullptr || baseWidget == this) { @@ -1754,7 +1754,7 @@ int Layout::findFarestChildWidgetIndex(cocos2d::ui::FocusDirection direction, co float distance = -FLT_MAX; int found = 0; - if (direction == FocusDirection::FocusDirection_Left || direction == FocusDirection::FocusDirection_Right) + if (direction == FocusDirection::LEFT || direction == FocusDirection::RIGHT) { Vector2 widgetPosition = this->getWorldCenterPoint(baseWidget); while (index < count) @@ -1788,7 +1788,7 @@ int Layout::findFarestChildWidgetIndex(cocos2d::ui::FocusDirection direction, co index = 0; found = 0; distance = -FLT_MAX; - if (direction == FocusDirection::FocusDirection_Down || direction == FocusDirection::FocusDirection_Up) { + if (direction == FocusDirection::DOWN || direction == FocusDirection::UP) { Vector2 widgetPosition = this->getWorldCenterPoint(baseWidget); while (index < count) { @@ -1873,27 +1873,27 @@ void Layout::findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget) Vector2 layoutPosition = this->getWorldCenterPoint(this->findFirstNonLayoutWidget()); - if (dir == FocusDirection::FocusDirection_Left) { + if (dir == FocusDirection::LEFT) { if (previousWidgetPosition.x > layoutPosition.x) { onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this); } else{ onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this); } - }else if(dir == FocusDirection::FocusDirection_Right){ + }else if(dir == FocusDirection::RIGHT){ if (previousWidgetPosition.x > layoutPosition.x) { onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this); } else{ onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this); } - }else if(dir == FocusDirection::FocusDirection_Down){ + }else if(dir == FocusDirection::DOWN){ if (previousWidgetPosition.y > layoutPosition.y) { onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this); }else{ onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this); } - }else if(dir == FocusDirection::FocusDirection_Up){ + }else if(dir == FocusDirection::UP){ if (previousWidgetPosition.y < layoutPosition.y) { onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this); }else{ @@ -1906,7 +1906,7 @@ void Layout::findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget) } -Widget* Layout::passFocusToChild(cocos2d::ui::FocusDirection dir, cocos2d::ui::Widget *current) +Widget* Layout::passFocusToChild(FocusDirection dir, cocos2d::ui::Widget *current) { if (checkFocusEnabledChild()) { @@ -2188,7 +2188,7 @@ bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction) ssize_t index = container.getIndex(widget); if (parent->getLayoutType() == LAYOUT_LINEAR_HORIZONTAL) { - if (direction == FocusDirection::FocusDirection_Left) { + if (direction == FocusDirection::LEFT) { if (index == 0) { return true * isLastWidgetInContainer(parent, direction); @@ -2198,7 +2198,7 @@ bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction) return false; } } - if (direction == FocusDirection::FocusDirection_Right) { + if (direction == FocusDirection::RIGHT) { if (index == container.size()-1) { return true * isLastWidgetInContainer(parent, direction); @@ -2208,19 +2208,19 @@ bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction) return false; } } - if (direction == FocusDirection::FocusDirection_Down) + if (direction == FocusDirection::DOWN) { return isLastWidgetInContainer(parent, direction); } - if (direction == FocusDirection::FocusDirection_Up) + if (direction == FocusDirection::UP) { return isLastWidgetInContainer(parent, direction); } } else if(parent->getLayoutType() == LAYOUT_LINEAR_VERTICAL) { - if (direction == FocusDirection::FocusDirection_Up) + if (direction == FocusDirection::UP) { if (index == 0) { @@ -2232,7 +2232,7 @@ bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction) return false; } } - if (direction == FocusDirection::FocusDirection_Down) + if (direction == FocusDirection::DOWN) { if (index == container.size() - 1) { @@ -2243,12 +2243,12 @@ bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction) return false; } } - if (direction == FocusDirection::FocusDirection_Left) + if (direction == FocusDirection::LEFT) { return isLastWidgetInContainer(parent, direction); } - if (direction == FocusDirection::FocusDirection_Right) + if (direction == FocusDirection::RIGHT) { return isLastWidgetInContainer(parent, direction); } @@ -2274,7 +2274,7 @@ bool Layout::isWidgetAncestorSupportLoopFocus(Widget* widget, FocusDirection di auto layoutType = parent->getLayoutType(); if (layoutType == LAYOUT_LINEAR_HORIZONTAL) { - if (direction == FocusDirection::FocusDirection_Left || direction == FocusDirection::FocusDirection_Right) + if (direction == FocusDirection::LEFT || direction == FocusDirection::RIGHT) { return true; } @@ -2285,7 +2285,7 @@ bool Layout::isWidgetAncestorSupportLoopFocus(Widget* widget, FocusDirection di } if (layoutType == LAYOUT_LINEAR_VERTICAL) { - if (direction == FocusDirection::FocusDirection_Down || direction == FocusDirection::FocusDirection_Up) + if (direction == FocusDirection::DOWN || direction == FocusDirection::UP) { return true; } @@ -2338,16 +2338,16 @@ Widget* Layout::findNextFocusedWidget(FocusDirection direction, Widget* current) { switch (direction) { - case FocusDirection::FocusDirection_Left: + case FocusDirection::LEFT: { return this->getPreviousFocusedWidget(direction, current); }break; - case FocusDirection::FocusDirection_Right: + case FocusDirection::RIGHT: { return this->getNextFocusedWidget(direction, current); }break; - case FocusDirection::FocusDirection_Down: - case FocusDirection::FocusDirection_Up: + case FocusDirection::DOWN: + case FocusDirection::UP: { if (isLastWidgetInContainer(this, direction)) { @@ -2375,8 +2375,8 @@ Widget* Layout::findNextFocusedWidget(FocusDirection direction, Widget* current) { switch (direction) { - case FocusDirection::FocusDirection_Left: - case FocusDirection::FocusDirection_Right: + case FocusDirection::LEFT: + case FocusDirection::RIGHT: { if (isLastWidgetInContainer(this, direction)) { @@ -2393,12 +2393,12 @@ Widget* Layout::findNextFocusedWidget(FocusDirection direction, Widget* current) return Widget::findNextFocusedWidget(direction, this); } } break; - case FocusDirection::FocusDirection_Down: + case FocusDirection::DOWN: { return getNextFocusedWidget(direction, current); } break; - case FocusDirection::FocusDirection_Up: + case FocusDirection::UP: { return getPreviousFocusedWidget(direction, current); } diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index f1cb8a1f02..877f95f13a 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -984,12 +984,13 @@ bool Widget::isFocusEnabled() return _focusEnabled; } -Widget* Widget::findNextFocusedWidget(cocos2d::ui::FocusDirection direction, Widget* current) +Widget* Widget::findNextFocusedWidget(FocusDirection direction, Widget* current) { if (nullptr == onNextFocusedWidget || nullptr == onNextFocusedWidget(direction) ) { if (this->isFocused() || !current->isFocusEnabled()) { Node* parent = this->getParent(); + Layout* layout = dynamic_cast(parent); if (nullptr == layout) { diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index 17ed80494d..31d284f3f6 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -73,13 +73,7 @@ typedef enum POSITION_PERCENT }PositionType; -enum class FocusDirection -{ - FocusDirection_Left, - FocusDirection_Right, - FocusDirection_Up, - FocusDirection_Down -}; + typedef void (Ref::*SEL_TouchEvent)(Ref*,TouchEventType); @@ -91,6 +85,14 @@ typedef void (Ref::*SEL_TouchEvent)(Ref*,TouchEventType); class Widget : public ProtectedNode { public: + enum class FocusDirection + { + LEFT, + RIGHT, + UP, + DOWN + }; + /** * Default constructor */ diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp index f811652b99..4dec52d51d 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp @@ -80,7 +80,7 @@ void UIFocusTestBase::onLeftKeyPressed() if (!_firstFocusedWidget->isFocused()) { _firstFocusedWidget = _firstFocusedWidget->getCurrentFocusedWidget(false); } - _firstFocusedWidget = _firstFocusedWidget->findNextFocusedWidget(FocusDirection::FocusDirection_Left, _firstFocusedWidget); + _firstFocusedWidget = _firstFocusedWidget->findNextFocusedWidget(Widget::FocusDirection::LEFT, _firstFocusedWidget); } } @@ -90,7 +90,7 @@ void UIFocusTestBase::onRightKeyPressed() if (!_firstFocusedWidget->isFocused()) { _firstFocusedWidget = _firstFocusedWidget->getCurrentFocusedWidget(false); } - _firstFocusedWidget = _firstFocusedWidget->findNextFocusedWidget(FocusDirection::FocusDirection_Right, _firstFocusedWidget); + _firstFocusedWidget = _firstFocusedWidget->findNextFocusedWidget(Widget::FocusDirection::RIGHT, _firstFocusedWidget); } } @@ -100,7 +100,7 @@ void UIFocusTestBase::onUpKeyPressed() if (!_firstFocusedWidget->isFocused()) { _firstFocusedWidget = _firstFocusedWidget->getCurrentFocusedWidget(false); } - _firstFocusedWidget = _firstFocusedWidget->findNextFocusedWidget(FocusDirection::FocusDirection_Up, _firstFocusedWidget); + _firstFocusedWidget = _firstFocusedWidget->findNextFocusedWidget(Widget::FocusDirection::UP, _firstFocusedWidget); } } @@ -111,7 +111,7 @@ void UIFocusTestBase::onDownKeyPressed() if (!_firstFocusedWidget->isFocused()) { _firstFocusedWidget = _firstFocusedWidget->getCurrentFocusedWidget(false); } - _firstFocusedWidget = _firstFocusedWidget->findNextFocusedWidget(FocusDirection::FocusDirection_Down, _firstFocusedWidget); + _firstFocusedWidget = _firstFocusedWidget->findNextFocusedWidget(Widget::FocusDirection::DOWN, _firstFocusedWidget); } } From fd362d2ace19b38ce1e091d400dd5ec5a3eb6e74 Mon Sep 17 00:00:00 2001 From: andyque Date: Thu, 8 May 2014 18:25:49 +0800 Subject: [PATCH 017/174] issue #5057. deprcated PositionType and make a new enum class instead --- cocos/editor-support/cocostudio/CCSGUIReader.cpp | 2 +- .../cocostudio/WidgetReader/WidgetReader.cpp | 2 +- cocos/ui/UIDeprecated.h | 3 +++ cocos/ui/UIWidget.cpp | 9 +++++---- cocos/ui/UIWidget.h | 13 ++++++------- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index badc94bc75..387e651e1c 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -1134,7 +1134,7 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(Widget*widg } widget->setSizeType((SizeType)DICTOOL->getIntValue_json(options, "sizeType")); - widget->setPositionType((PositionType)DICTOOL->getIntValue_json(options, "positionType")); + widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, "positionType")); widget->setSizePercent(Vector2(DICTOOL->getFloatValue_json(options, "sizePercentX"), DICTOOL->getFloatValue_json(options, "sizePercentY"))); widget->setPositionPercent(Vector2(DICTOOL->getFloatValue_json(options, "positionPercentX"), DICTOOL->getFloatValue_json(options, "positionPercentY"))); diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index 2a34bddeef..ea25ec0e70 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -44,7 +44,7 @@ namespace cocostudio } widget->setSizeType((SizeType)DICTOOL->getIntValue_json(options, "sizeType")); - widget->setPositionType((PositionType)DICTOOL->getIntValue_json(options, "positionType")); + widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, "positionType")); widget->setSizePercent(Vector2(DICTOOL->getFloatValue_json(options, "sizePercentX"), DICTOOL->getFloatValue_json(options, "sizePercentY"))); widget->setPositionPercent(Vector2(DICTOOL->getFloatValue_json(options, "positionPercentX"), DICTOOL->getFloatValue_json(options, "positionPercentY"))); diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index c693101562..de82e96d42 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -16,6 +16,9 @@ NS_CC_BEGIN namespace ui { +CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_ABSOLUTE = Widget::PositionType::ABSOLUTE; +CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_PERCENT = Widget::PositionType::PERCENT; + } diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index 877f95f13a..2a6d048d73 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -25,6 +25,7 @@ THE SOFTWARE. #include "ui/UIWidget.h" #include "ui/UILayout.h" #include "ui/UIHelper.h" +#include "ui/UIDeprecated.h" NS_CC_BEGIN @@ -54,7 +55,7 @@ _ignoreSize(false), _affectByClipping(false), _sizeType(SIZE_ABSOLUTE), _sizePercent(Vector2::ZERO), -_positionType(POSITION_ABSOLUTE), +_positionType(PositionType::ABSOLUTE), _positionPercent(Vector2::ZERO), _reorderWidgetChildDirty(true), _hitted(false), @@ -314,7 +315,7 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize) Vector2 absPos = getPosition(); switch (_positionType) { - case POSITION_ABSOLUTE: + case PositionType::ABSOLUTE: { if (parentSize.width <= 0.0f || parentSize.height <= 0.0f) { @@ -326,7 +327,7 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize) } break; } - case POSITION_PERCENT: + case PositionType::PERCENT: { absPos = Vector2(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); break; @@ -750,7 +751,7 @@ void Widget::setPositionType(PositionType type) _positionType = type; } -PositionType Widget::getPositionType() const +Widget::PositionType Widget::getPositionType() const { return _positionType; } diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index 31d284f3f6..b944953bbc 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -67,13 +67,6 @@ typedef enum SIZE_PERCENT }SizeType; -typedef enum -{ - POSITION_ABSOLUTE, - POSITION_PERCENT -}PositionType; - - typedef void (Ref::*SEL_TouchEvent)(Ref*,TouchEventType); @@ -93,6 +86,12 @@ public: DOWN }; + enum class PositionType + { + ABSOLUTE, + PERCENT + }; + /** * Default constructor */ From 815f0b7bd92e75f5394b3c82a5952a553043cfd9 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Thu, 8 May 2014 10:12:12 -0700 Subject: [PATCH 018/174] useCallback to false --- cocos/2d/CCGLProgramState.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cocos/2d/CCGLProgramState.cpp b/cocos/2d/CCGLProgramState.cpp index b5326ad7d9..5b0de942dc 100644 --- a/cocos/2d/CCGLProgramState.cpp +++ b/cocos/2d/CCGLProgramState.cpp @@ -102,36 +102,42 @@ void UniformValue::setValue(float value) { CCASSERT (_uniform->type == GL_FLOAT, ""); _value.floatValue = value; + _useCallback = false; } void UniformValue::setValue(int value) { CCASSERT ((_uniform->type == GL_INT || _uniform->type == GL_SAMPLER_2D), ""); _value.intValue = value; + _useCallback = false; } void UniformValue::setValue(const Vector2& value) { CCASSERT (_uniform->type == GL_FLOAT_VEC2, ""); _value.v2Value = value; + _useCallback = false; } void UniformValue::setValue(const Vector3& value) { CCASSERT (_uniform->type == GL_FLOAT_VEC3, ""); _value.v3Value = value; + _useCallback = false; } void UniformValue::setValue(const Vector4& value) { CCASSERT (_uniform->type == GL_FLOAT_VEC4, ""); _value.v4Value = value; + _useCallback = false; } void UniformValue::setValue(const Matrix& value) { CCASSERT(_uniform->type == GL_FLOAT_MAT4, ""); _value.matrixValue = value; + _useCallback = false; } // From 8f2ba467ff44f59940403c8ade2af279de5e822b Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 8 May 2014 12:34:26 -0700 Subject: [PATCH 019/174] Yeahhhhhh it is working --- cocos/2d/CCDrawNode.cpp | 6 +- cocos/2d/CCGLProgram.cpp | 27 +++++- cocos/2d/CCGLProgram.h | 12 ++- cocos/2d/CCGLProgramState.cpp | 81 ++++++++++++++--- cocos/2d/CCGLProgramState.h | 25 ++++-- cocos/2d/CCGrid.cpp | 8 +- cocos/2d/CCMotionStreak.cpp | 4 +- cocos/2d/CCParticleSystemQuad.cpp | 4 +- cocos/2d/CCProgressTimer.cpp | 4 +- cocos/2d/CCShaderCache.cpp | 67 -------------- cocos/2d/CCTexture2D.cpp | 8 +- cocos/2d/CCTextureAtlas.cpp | 6 +- cocos/2d/ccGLStateCache.cpp | 19 ++-- cocos/2d/ccGLStateCache.h | 2 +- cocos/deprecated/CCDeprecated.h | 2 +- cocos/renderer/CCRenderer.cpp | 6 +- .../lua-bindings/script/Cocos2dConstants.lua | 2 +- tests/cpp-tests/Classes/NodeTest/NodeTest.cpp | 2 +- .../Classes/ShaderTest/ShaderTest.cpp | 89 ++++++++----------- .../cpp-tests/Classes/ShaderTest/ShaderTest.h | 3 + tests/lua-tests/src/OpenGLTest/OpenGLTest.lua | 4 +- 21 files changed, 201 insertions(+), 180 deletions(-) diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 48408b3133..cce3539a07 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -178,8 +178,8 @@ bool DrawNode::init() glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORD); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -241,7 +241,7 @@ void DrawNode::onDraw(const Matrix &transform, bool transformUpdated) glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); // texcood - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); } glDrawArrays(GL_TRIANGLES, 0, _bufferCount); diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 0daa935b77..18972df2d2 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -82,6 +82,7 @@ const char* GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE = "CC_alpha_value"; const char* GLProgram::ATTRIBUTE_NAME_COLOR = "a_color"; const char* GLProgram::ATTRIBUTE_NAME_POSITION = "a_position"; const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD = "a_texCoord"; +const char* GLProgram::ATTRIBUTE_NAME_NORMAL = "a_normal"; GLProgram* GLProgram::createWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) @@ -243,6 +244,26 @@ bool GLProgram::initWithFilenames(const std::string &vShaderFilename, const std: return initWithByteArrays(vertexSource.c_str(), fragmentSource.c_str()); } +void GLProgram::bindPredefinedVertexAttribs() +{ + static const struct { + const char *attributeName; + int location; + } attribute_locations[] = + { + {GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION}, + {GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR}, + {GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD}, + {GLProgram::ATTRIBUTE_NAME_NORMAL, GLProgram::VERTEX_ATTRIB_NORMAL}, + }; + + const int size = sizeof(attribute_locations) / sizeof(attribute_locations[0]); + + for(int i=0; i callback) +void VertexAttribValue::setCallback(const std::function callback) { _value.callback = callback; _useCallback = true; } -void VertexAttribValue::setValue(GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer) +void VertexAttribValue::setPointer(GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer) { _value.pointer.size = size; _value.pointer.type = type; @@ -199,8 +205,6 @@ void VertexAttribValue::setValue(GLint size, GLenum type, GLboolean normalized, GLProgramState* GLProgramState::create(GLProgram *glprogram) { - CCASSERT(glprogram, "invalid shader"); - auto ret = new (std::nothrow) GLProgramState; if(ret && ret->init(glprogram)) { ret->autorelease(); @@ -210,6 +214,12 @@ GLProgramState* GLProgramState::create(GLProgram *glprogram) return nullptr; } +GLProgramState::GLProgramState() +: _vertexAttribsFlags(0) +, _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED) +{ +} + GLProgramState::~GLProgramState() { _glprogram->release(); @@ -217,6 +227,8 @@ GLProgramState::~GLProgramState() bool GLProgramState::init(GLProgram* glprogram) { + CCASSERT(glprogram, "invalid shader"); + _glprogram = glprogram; _glprogram->retain(); @@ -232,13 +244,22 @@ bool GLProgramState::init(GLProgram* glprogram) return true; } -void GLProgramState::apply() + +void GLProgramState::resetGLProgram() +{ + CC_SAFE_RELEASE(_glprogram); + _uniforms.clear(); + _attributes.clear(); +} + +void GLProgramState::apply(const Matrix& modelView) { CCASSERT(_glprogram, "invalid glprogram"); // set shader _glprogram->use(); + _glprogram->setUniformsForBuiltins(modelView); // set texture int i = 0; @@ -250,15 +271,36 @@ void GLProgramState::apply() GL::blendFunc(_blendFunc.src, _blendFunc.dst); - // set uniforms - for(auto& uniform : _uniforms) { - uniform.second.apply(); - } + // enable/disable vertex attribs + GL::enableVertexAttribs(_vertexAttribsFlags); // set attributes for(auto &attribute : _attributes) { attribute.second.apply(); } + + // set uniforms + for(auto& uniform : _uniforms) { + uniform.second.apply(); + } +} + +void GLProgramState::setGLProgram(GLProgram *glprogram) +{ + CCASSERT(glprogram, "invalid GLProgram"); + + if( _glprogram != glprogram) { + resetGLProgram(); + init(glprogram); + } +} + +void GLProgramState::setTexture(cocos2d::Texture2D *texture) +{ + if(_textures.size()>0) + _textures.replace(0, texture); + else + _textures.pushBack(texture); } UniformValue* GLProgramState::getUniformValue(const std::string &name) @@ -277,4 +319,19 @@ VertexAttribValue* GLProgramState::getVertexAttribValue(const std::string &name) return nullptr; } +void GLProgramState::setVertexAttribCallback(const std::string &name, const std::function callback) +{ + VertexAttribValue *v = getVertexAttribValue(name); + v->setCallback(callback); + _vertexAttribsFlags |= 1 << v->_vertexAttrib->_index; +} + +void GLProgramState::setVertexAttribPointer(const std::string &name, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer) +{ + auto v = getVertexAttribValue(name); + v->setPointer(size, type, normalized, stride, pointer); + _vertexAttribsFlags |= 1 << v->_vertexAttrib->_index; +} + + NS_CC_END diff --git a/cocos/2d/CCGLProgramState.h b/cocos/2d/CCGLProgramState.h index 9b150dbd7c..ab54ca3230 100644 --- a/cocos/2d/CCGLProgramState.h +++ b/cocos/2d/CCGLProgramState.h @@ -95,14 +95,15 @@ protected: class VertexAttribValue { friend class GLProgram; + friend class GLProgramState; public: VertexAttribValue(VertexAttrib *vertexAttrib); VertexAttribValue(); ~VertexAttribValue(); - void setValue(GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer); - void setValue(const std::function callback); + void setPointer(GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer); + void setCallback(const std::function callback); void apply(); protected: @@ -137,26 +138,36 @@ protected: class GLProgramState : public Ref { public: - GLProgramState* create(GLProgram* glprogram); + static GLProgramState* create(GLProgram* glprogram); - void apply(); - void setTexture(Texture2D *texture) { _textures.insert(0, texture); } + void apply(const Matrix& modelView); + + void setGLProgram(GLProgram* glprogram); + GLProgram* getGLProgram() const { return _glprogram; } + + void setTexture(Texture2D *texture); Texture2D* getTexture() const { return _textures.at(0); } void setBlendFunc(const BlendFunc& blendFunc) { _blendFunc = blendFunc; } const BlendFunc& getBlendFunc() const { return _blendFunc; } + void setVertexAttribCallback(const std::string &name, const std::function callback); + void setVertexAttribPointer(const std::string &name, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer); + UniformValue* getUniformValue(const std::string &uniformName); - VertexAttribValue* getVertexAttribValue(const std::string &attributeName); protected: GLProgramState(); ~GLProgramState(); bool init(GLProgram* program); + void resetGLProgram(); + VertexAttribValue* getVertexAttribValue(const std::string &attributeName); std::unordered_map _uniforms; std::unordered_map _attributes; - + + uint32_t _vertexAttribsFlags; + GLProgram *_glprogram; Vector _textures; BlendFunc _blendFunc; diff --git a/cocos/2d/CCGrid.cpp b/cocos/2d/CCGrid.cpp index 968a0dccd2..f6ce871961 100644 --- a/cocos/2d/CCGrid.cpp +++ b/cocos/2d/CCGrid.cpp @@ -330,7 +330,7 @@ void Grid3D::blit(void) // texCoords setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vector2), 1); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLIndexData(_indices, n * 12, 0); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0); @@ -339,7 +339,7 @@ void Grid3D::blit(void) glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _vertices); // texCoords - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, _indices); #endif // EMSCRIPTEN @@ -545,7 +545,7 @@ void TiledGrid3D::blit(void) // texCoords setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vector2)), 1); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLIndexData(_indices, n * 12, 0); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0); @@ -554,7 +554,7 @@ void TiledGrid3D::blit(void) glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _vertices); // texCoords - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates); glDrawElements(GL_TRIANGLES, (GLsizei)n*6, GL_UNSIGNED_SHORT, _indices); #endif // EMSCRIPTEN diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp index 24782265fe..0e163dfcba 100644 --- a/cocos/2d/CCMotionStreak.cpp +++ b/cocos/2d/CCMotionStreak.cpp @@ -389,13 +389,13 @@ void MotionStreak::onDraw(const Matrix &transform, bool transformUpdated) glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(_colorPointer, (sizeof(GLubyte) * _maxPoints * 2 * 4), 2); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _vertices); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoords); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, _texCoords); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, _colorPointer); #endif // EMSCRIPTEN diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index 283e6692cf..297c273084 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -478,8 +478,8 @@ void ParticleSystemQuad::setupVBOandVAO() glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORD); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _totalParticles * 6, _indices, GL_STATIC_DRAW); diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp index c71b43ba4b..fea8de6573 100644 --- a/cocos/2d/CCProgressTimer.cpp +++ b/cocos/2d/CCProgressTimer.cpp @@ -521,10 +521,10 @@ void ProgressTimer::onDraw(const Matrix &transform, bool transformUpdated) glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); offset += sizeof(Color4B); - glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); + glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); #else glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]) , &_vertexData[0].vertices); - glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]), &_vertexData[0].texCoords); + glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]), &_vertexData[0].texCoords); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(_vertexData[0]), &_vertexData[0].colors); #endif // EMSCRIPTEN diff --git a/cocos/2d/CCShaderCache.cpp b/cocos/2d/CCShaderCache.cpp index c92bd71565..ef0ef30277 100644 --- a/cocos/2d/CCShaderCache.cpp +++ b/cocos/2d/CCShaderCache.cpp @@ -283,118 +283,51 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type) switch (type) { case kShaderType_PositionTextureColor: p->initWithByteArrays(ccPositionTextureColor_vert, ccPositionTextureColor_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - break; case kShaderType_PositionTextureColor_noMVP: p->initWithByteArrays(ccPositionTextureColor_noMVP_vert, ccPositionTextureColor_noMVP_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - break; case kShaderType_PositionTextureColorAlphaTest: p->initWithByteArrays(ccPositionTextureColor_vert, ccPositionTextureColorAlphaTest_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - break; case kShaderType_PositionTextureColorAlphaTestNoMV: p->initWithByteArrays(ccPositionTextureColor_noMVP_vert, ccPositionTextureColorAlphaTest_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - break; case kShaderType_PositionColor: p->initWithByteArrays(ccPositionColor_vert ,ccPositionColor_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - break; case kShaderType_PositionColor_noMVP: p->initWithByteArrays(ccPositionTextureColor_noMVP_vert ,ccPositionColor_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); break; case kShaderType_PositionTexture: p->initWithByteArrays(ccPositionTexture_vert ,ccPositionTexture_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - break; case kShaderType_PositionTexture_uColor: p->initWithByteArrays(ccPositionTexture_uColor_vert, ccPositionTexture_uColor_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - break; case kShaderType_PositionTextureA8Color: p->initWithByteArrays(ccPositionTextureA8Color_vert, ccPositionTextureA8Color_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - break; case kShaderType_Position_uColor: p->initWithByteArrays(ccPosition_uColor_vert, ccPosition_uColor_frag); - p->bindAttribLocation("aVertex", GLProgram::VERTEX_ATTRIB_POSITION); - break; case kShaderType_PositionLengthTexureColor: p->initWithByteArrays(ccPositionColorLengthTexture_vert, ccPositionColorLengthTexture_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - break; case kShaderType_LabelDistanceFieldNormal: p->initWithByteArrays(ccLabel_vert, ccLabelDistanceFieldNormal_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - break; case kShaderType_LabelDistanceFieldGlow: p->initWithByteArrays(ccLabel_vert, ccLabelDistanceFieldGlow_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - break; case kShaderType_LabelNormal: p->initWithByteArrays(ccLabel_vert, ccLabelNormal_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - break; case kShaderType_LabelOutline: p->initWithByteArrays(ccLabel_vert, ccLabelOutline_frag); - - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - break; default: CCLOG("cocos2d: %s:%d, error shader type", __FUNCTION__, __LINE__); diff --git a/cocos/2d/CCTexture2D.cpp b/cocos/2d/CCTexture2D.cpp index 520fafc409..562005d5f0 100644 --- a/cocos/2d/CCTexture2D.cpp +++ b/cocos/2d/CCTexture2D.cpp @@ -1181,10 +1181,10 @@ void Texture2D::drawAtPoint(const Vector2& point) glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(coordinates, 8 * sizeof(GLfloat), 1); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, coordinates); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, coordinates); #endif // EMSCRIPTEN glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); @@ -1214,10 +1214,10 @@ void Texture2D::drawInRect(const Rect& rect) glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(coordinates, 8 * sizeof(GLfloat), 1); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0); #else glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, coordinates); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, coordinates); #endif // EMSCRIPTEN glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } diff --git a/cocos/2d/CCTextureAtlas.cpp b/cocos/2d/CCTextureAtlas.cpp index 68299ce028..51670313ef 100644 --- a/cocos/2d/CCTextureAtlas.cpp +++ b/cocos/2d/CCTextureAtlas.cpp @@ -274,8 +274,8 @@ void TextureAtlas::setupVBOandVAO() glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORD); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _capacity * 6, _indices, GL_STATIC_DRAW); @@ -673,7 +673,7 @@ void TextureAtlas::drawNumberOfQuads(ssize_t numberOfQuads, ssize_t start) glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors)); // tex coords - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); diff --git a/cocos/2d/ccGLStateCache.cpp b/cocos/2d/ccGLStateCache.cpp index 466e202189..3974b26dad 100644 --- a/cocos/2d/ccGLStateCache.cpp +++ b/cocos/2d/ccGLStateCache.cpp @@ -33,17 +33,18 @@ THE SOFTWARE. NS_CC_BEGIN +static const int MAX_ATTRIBUTES = 16; +static const int MAX_ACTIVE_TEXTURE = 16; + namespace { static GLuint s_currentProjectionMatrix = -1; - static unsigned int s_attributeFlags = 0; + static uint32_t s_attributeFlags = 0; // 32 attributes max #if CC_ENABLE_GL_STATE_CACHE - -#define kMaxActiveTexture 16 - + static GLuint s_currentShaderProgram = -1; - static GLuint s_currentBoundTexture[kMaxActiveTexture] = {(GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, }; + static GLuint s_currentBoundTexture[MAX_ACTIVE_TEXTURE] = {(GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, }; static GLenum s_blendingSource = -1; static GLenum s_blendingDest = -1; static int s_GLServerState = 0; @@ -65,7 +66,7 @@ void invalidateStateCache( void ) #if CC_ENABLE_GL_STATE_CACHE s_currentShaderProgram = -1; - for( int i=0; i < kMaxActiveTexture; i++ ) + for( int i=0; i < MAX_ACTIVE_TEXTURE; i++ ) { s_currentBoundTexture[i] = -1; } @@ -147,7 +148,7 @@ void bindTexture2D(GLuint textureId) void bindTexture2DN(GLuint textureUnit, GLuint textureId) { #if CC_ENABLE_GL_STATE_CACHE - CCASSERT(textureUnit < kMaxActiveTexture, "textureUnit is too big"); + CCASSERT(textureUnit < MAX_ACTIVE_TEXTURE, "textureUnit is too big"); if (s_currentBoundTexture[textureUnit] != textureId) { s_currentBoundTexture[textureUnit] = textureId; @@ -210,12 +211,12 @@ void bindVAO(GLuint vaoId) // GL Vertex Attrib functions -void enableVertexAttribs( unsigned int flags ) +void enableVertexAttribs(uint32_t flags) { bindVAO(0); // hardcoded! - for(int i=0; i < 16; i++) { + for(int i=0; i < MAX_ATTRIBUTES; i++) { unsigned int bit = 1 << i; bool enabled = flags & bit; bool enabledBefore = s_attributeFlags & bit; diff --git a/cocos/2d/ccGLStateCache.h b/cocos/2d/ccGLStateCache.h index 9709032c67..dcc3cb0ec9 100644 --- a/cocos/2d/ccGLStateCache.h +++ b/cocos/2d/ccGLStateCache.h @@ -102,7 +102,7 @@ void CC_DLL setProjectionMatrixDirty(void); @since v2.0.0 */ -void CC_DLL enableVertexAttribs(unsigned int flags); +void CC_DLL enableVertexAttribs(uint32_t flags); /** If the texture is not already bound to texture unit 0, it binds it. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. diff --git a/cocos/deprecated/CCDeprecated.h b/cocos/deprecated/CCDeprecated.h index 525a72942b..38cc1c4999 100644 --- a/cocos/deprecated/CCDeprecated.h +++ b/cocos/deprecated/CCDeprecated.h @@ -806,7 +806,7 @@ CC_DEPRECATED_ATTRIBUTE typedef void* CCZone; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_Position = GLProgram::VERTEX_ATTRIB_POSITION; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_Color = GLProgram::VERTEX_ATTRIB_COLOR; -CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_TexCoords = GLProgram::VERTEX_ATTRIB_TEX_COORDS; +CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_TexCoords = GLProgram::VERTEX_ATTRIB_TEX_COORD; CC_DEPRECATED_ATTRIBUTE const int kCCVertexAttrib_MAX = GLProgram::VERTEX_ATTRIB_MAX; CC_DEPRECATED_ATTRIBUTE const int kCCUniformPMatrix = GLProgram::UNIFORM_P_MATRIX; diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index f89f5cc79d..fe0b5e2286 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -202,8 +202,8 @@ void Renderer::setupVBOAndVAO() glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B_T2F), (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORD); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * VBO_SIZE * 6, _indices, GL_STATIC_DRAW); @@ -444,7 +444,7 @@ void Renderer::drawBatchedQuads() glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors)); // tex coords - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); } diff --git a/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua b/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua index 67b3978b4c..78027543f5 100644 --- a/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua +++ b/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua @@ -131,7 +131,7 @@ cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 0x4 cc.VERTEX_ATTRIB_COLOR = 0x1 cc.VERTEX_ATTRIB_MAX = 0x3 cc.VERTEX_ATTRIB_POSITION = 0x0 -cc.VERTEX_ATTRIB_TEX_COORDS = 0x2 +cc.VERTEX_ATTRIB_TEX_COORD = 0x2 cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2 cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1 cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0 diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index 11248cfbed..970aff65ce 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -1027,7 +1027,7 @@ void MySprite::onDraw(const Matrix &transform, bool transformUpdated) // texCoods diff = offsetof( V3F_C4B_T2F, texCoords); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); // color diff = offsetof( V3F_C4B_T2F, colors); diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 5a816b4152..9dbb8d7e93 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -116,6 +116,7 @@ ShaderNode::ShaderNode() ShaderNode::~ShaderNode() { + CC_SAFE_RELEASE(_glProgramState); } ShaderNode* ShaderNode::shaderNodeWithVertex(const char *vert, const char *frag) @@ -142,6 +143,7 @@ bool ShaderNode::initWithVertex(const char *vert, const char *frag) _time = 0; _resolution = Vector2(SIZE_X, SIZE_Y); + _glProgramState->getUniformValue("resolution")->setValue(_resolution); scheduleUpdate(); @@ -164,6 +166,9 @@ void ShaderNode::loadShaderVertex(const char *vert, const char *frag) shader->updateUniforms(); this->setShaderProgram(shader); + + _glProgramState = GLProgramState::create(shader); + _glProgramState->retain(); } void ShaderNode::update(float dt) @@ -176,6 +181,7 @@ void ShaderNode::setPosition(const Vector2 &newPosition) Node::setPosition(newPosition); auto position = getPosition(); _center = Vector2(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR()); + _glProgramState->getUniformValue("center")->setValue(_center); } void ShaderNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -187,25 +193,16 @@ void ShaderNode::draw(Renderer *renderer, const Matrix &transform, bool transfor void ShaderNode::onDraw(const Matrix &transform, bool transformUpdated) { - auto shader = getShaderProgram(); - shader->use(); - shader->setUniformsForBuiltins(transform); - - // TODO: riq FIXME -// shader->getUniform("center")->setValue(_center); -// shader->getUniform("resolution")->setValue(_resolution); - - GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION ); float w = SIZE_X, h = SIZE_Y; GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h}; - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); - + _glProgramState->setVertexAttribPointer("a_position", 2, GL_FLOAT, GL_FALSE, 0, vertices); + _glProgramState->apply(transform); + glDrawArrays(GL_TRIANGLES, 0, 6); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,6); - } /// ShaderMonjori @@ -435,10 +432,12 @@ protected: float _weightSum; CustomCommand _customCommand; + GLProgramState *_glProgramState; }; SpriteBlur::~SpriteBlur() { + CC_SAFE_RELEASE(_glProgramState); } SpriteBlur* SpriteBlur::create(const char *pszFileName) @@ -473,9 +472,12 @@ bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect) auto s = getTexture()->getContentSizeInPixels(); _pixelSize = Vector2(1/s.width, 1/s.height); + _samplingRadius = 0; this->initProgram(); + _glProgramState->getUniformValue("onePixelSize")->setValue(_pixelSize); + return true; } @@ -490,20 +492,30 @@ void SpriteBlur::initProgram() setShaderProgram(program); CHECK_GL_ERROR_DEBUG(); - - program->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - program->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); - program->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); - CHECK_GL_ERROR_DEBUG(); - program->link(); CHECK_GL_ERROR_DEBUG(); program->updateUniforms(); - CHECK_GL_ERROR_DEBUG(); + CHECK_GL_ERROR_DEBUG(); + + _glProgramState = GLProgramState::create(program); + _glProgramState->retain(); + +#define kQuadSize sizeof(_quad.bl) + size_t offset = (size_t)&_quad; + + // position + int diff = offsetof( V3F_C4B_T2F, vertices); + _glProgramState->setVertexAttribPointer("a_position", 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + // texcoord + diff = offsetof( V3F_C4B_T2F, texCoords); + _glProgramState->setVertexAttribPointer("a_texCoord", 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); + // color + diff = offsetof( V3F_C4B_T2F, colors); + _glProgramState->setVertexAttribPointer("a_color", 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); } void SpriteBlur::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -515,38 +527,11 @@ void SpriteBlur::draw(Renderer *renderer, const Matrix &transform, bool transfor void SpriteBlur::onDraw(const Matrix &transform, bool transformUpdated) { - GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); - BlendFunc blend = getBlendFunc(); - GL::blendFunc(blend.src, blend.dst); + _glProgramState->setTexture(getTexture()); + _glProgramState->setBlendFunc(getBlendFunc()); + + _glProgramState->apply(transform); - auto program = getShaderProgram(); - program->use(); - program->setUniformsForBuiltins(transform); - - // TODO: riq FIXME -// program->getUniform("onePixelSize")->setValue(_pixelSize); -// program->getUniform("gaussianCoefficient")->setValue(Vector4(_samplingRadius, _scale, _cons, _weightSum)); - - GL::bindTexture2D( getTexture()->getName()); - - // - // Attributes - // - #define kQuadSize sizeof(_quad.bl) - size_t offset = (size_t)&_quad; - - // vertex - int diff = offsetof( V3F_C4B_T2F, vertices); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); - - // texCoods - diff = offsetof( V3F_C4B_T2F, texCoords); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); - - // color - diff = offsetof( V3F_C4B_T2F, colors); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,4); @@ -585,6 +570,8 @@ void SpriteBlur::setBlurSize(float f) } } log("_blurRadius:%d",_blurRadius); + + _glProgramState->getUniformValue("gaussianCoefficient")->setValue(Vector4(_samplingRadius, _scale, _cons, _weightSum)); } // ShaderBlur @@ -670,7 +657,7 @@ bool ShaderRetroEffect::init() auto p = GLProgram::createWithByteArrays(ccPositionTexture_vert, fragSource); p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); + p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD); p->link(); p->updateUniforms(); diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h index c1dea61c66..0a5cc13b80 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h @@ -5,6 +5,8 @@ #include "extensions/cocos-ext.h" #include "../BaseTest.h" +#include "2d/CCGLProgramState.h" + USING_NS_CC_EXT; class ShaderTestDemo : public BaseTest @@ -134,6 +136,7 @@ protected: std::string _vertFileName; std::string _fragFileName; CustomCommand _customCommand; + GLProgramState *_glProgramState; }; class ShaderTestScene : public TestScene diff --git a/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua b/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua index b76c19bb4d..ec37d20617 100644 --- a/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua +++ b/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua @@ -158,7 +158,7 @@ local function OpenGLTestMainLayer() InitTitle(RetroEffectlayer) local program = cc.GLProgram:create("Shaders/example_ColorBars.vsh", "Shaders/example_ColorBars.fsh") program:bindAttribLocation(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION) - program:bindAttribLocation(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS) + program:bindAttribLocation(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORD) program:link() program:updateUniforms() @@ -653,7 +653,7 @@ local function OpenGLTestMainLayer() gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexTextureBuffer.buffer_id) - gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,gl.FLOAT,false,0,0) + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORD,2,gl.FLOAT,false,0,0) gl.drawArrays(gl.TRIANGLE_STRIP,0,4) From 9ea4aa1e169f76a01af5161c85b1ab796f319901 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 8 May 2014 14:01:03 -0700 Subject: [PATCH 020/174] Simplified VertexAttrib --- cocos/2d/CCGLProgram.cpp | 73 ++------------------------------- cocos/2d/CCGLProgram.h | 31 +++----------- cocos/2d/CCGLProgramState.cpp | 6 +-- cocos/2d/CCVertexAttribBind.cpp | 4 +- 4 files changed, 15 insertions(+), 99 deletions(-) diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 18972df2d2..e9bfb1a4a4 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -284,14 +284,13 @@ void GLProgram::parseVertexAttribs() for(int i = 0; i < activeAttributes; ++i) { // Query attribute info. - glGetActiveAttrib(_program, i, length, NULL, &attribute._originalSize, &attribute._originalType, attribName); + glGetActiveAttrib(_program, i, length, NULL, &attribute.size, &attribute.type, attribName); attribName[length] = '\0'; - attribute._name = std::string(attribName); + attribute.name = std::string(attribName); // Query the pre-assigned attribute location - attribute._index = glGetAttribLocation(_program, attribName); - _attributesDictionary[attribute._name] = attribute; - attribute.updateTypeAndSize(); + attribute.index = glGetAttribLocation(_program, attribName); + _attributesDictionary[attribute.name] = attribute; } } } @@ -847,68 +846,4 @@ void GLProgram::reset() _hashForUniforms = nullptr; } -// -// VertexAttrib -// -VertexAttrib::VertexAttrib() -: _size(-1) -, _type(-1) -, _normalized(false) -{ -} - -VertexAttrib::~VertexAttrib() -{ -} - -void VertexAttrib::updateTypeAndSize() -{ - switch (_originalType) { - case GL_FLOAT_VEC2: - _type = GL_FLOAT; - _size = 2; - break; - case GL_FLOAT_VEC3: - _type = GL_FLOAT; - _size = 3; - break; - case GL_FLOAT_VEC4: - _type = GL_FLOAT; - _size = 4; - break; - case GL_FLOAT_MAT2: - _type = GL_FLOAT; - _size = 4; - break; - case GL_FLOAT_MAT3: - _type = GL_FLOAT; - _size = 9; - break; - case GL_FLOAT_MAT4: - _type = GL_FLOAT; - _size = 16; - break; - - default: - break; - } -} - -void VertexAttrib::setPointer(GLsizei stride, const GLvoid *pointer) -{ - glVertexAttribPointer(_index, _size, _type, _normalized, stride, pointer); -} - -void VertexAttrib::setPointer(GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) -{ - glVertexAttribPointer(_index, size, type, normalized, stride, pointer); -} - -void VertexAttrib::redefineTypeAndSize(GLenum type, GLint size, GLboolean normalized) -{ - _type = type; - _size = size; - _normalized = normalized; -} - NS_CC_END diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index f7b9e332ab..448af919d6 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -53,39 +53,20 @@ typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params); typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); -class VertexAttrib +struct VertexAttrib { - friend class GLProgram; - friend class GLProgramState; - friend class VertexAttribValue; - friend class VertexAttribBind; - -public: - VertexAttrib(); - ~VertexAttrib(); - - void setPointer(GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); - void setPointer(GLsizei stride, const GLvoid *pointer); - - void redefineTypeAndSize(GLenum type, GLint size, GLboolean normalized); - void updateTypeAndSize(); - -protected: - GLuint _index; - GLint _size; - GLint _originalSize; - GLenum _type; - GLenum _originalType; - GLboolean _normalized; - std::string _name; + GLuint index; + GLint size; + GLenum type; + std::string name; }; struct Uniform { GLint location; GLint size; - std::string name; GLenum type; + std::string name; }; /** GLProgram diff --git a/cocos/2d/CCGLProgramState.cpp b/cocos/2d/CCGLProgramState.cpp index 3be14fc01e..5c4cb1e9ed 100644 --- a/cocos/2d/CCGLProgramState.cpp +++ b/cocos/2d/CCGLProgramState.cpp @@ -173,7 +173,7 @@ void VertexAttribValue::apply() } else { - glVertexAttribPointer(_vertexAttrib->_index, + glVertexAttribPointer(_vertexAttrib->index, _value.pointer.size, _value.pointer.type, _value.pointer.normalized, @@ -323,14 +323,14 @@ void GLProgramState::setVertexAttribCallback(const std::string &name, const std: { VertexAttribValue *v = getVertexAttribValue(name); v->setCallback(callback); - _vertexAttribsFlags |= 1 << v->_vertexAttrib->_index; + _vertexAttribsFlags |= 1 << v->_vertexAttrib->index; } void GLProgramState::setVertexAttribPointer(const std::string &name, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer) { auto v = getVertexAttribValue(name); v->setPointer(size, type, normalized, stride, pointer); - _vertexAttribsFlags |= 1 << v->_vertexAttrib->_index; + _vertexAttribsFlags |= 1 << v->_vertexAttrib->index; } diff --git a/cocos/2d/CCVertexAttribBind.cpp b/cocos/2d/CCVertexAttribBind.cpp index 3b657af9ab..c2e96241aa 100644 --- a/cocos/2d/CCVertexAttribBind.cpp +++ b/cocos/2d/CCVertexAttribBind.cpp @@ -93,8 +93,8 @@ VertexAttribBind::VertexAttribBind(const std::vector& attribs) { std::vector elems; for (auto it = attribs.begin(); it != attribs.end(); it++) { - VertexAttribType type((*it)->_type, (*it)->_size); - type._location = (*it)->_index; + VertexAttribType type((*it)->type, (*it)->size); + type._location = (*it)->index; elems.push_back(type); } setVertexAttribElems(&elems[0], elems.size()); From 453b670ad2fe76f6698fd3df036d0e2f5c8f71c8 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 8 May 2014 14:01:26 -0700 Subject: [PATCH 021/174] Removes CCVertexAttribBind --- build/cocos2d_libs.xcodeproj/project.pbxproj | 12 -- cocos/2d/CCVertexAttribBind.cpp | 140 ------------------- cocos/2d/CCVertexAttribBind.h | 92 ------------ 3 files changed, 244 deletions(-) delete mode 100644 cocos/2d/CCVertexAttribBind.cpp delete mode 100644 cocos/2d/CCVertexAttribBind.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 878c1a95f8..c453202c31 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1610,10 +1610,6 @@ 500DC9BD19106E89007B91BF /* CCProfiling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9BA19106E89007B91BF /* CCProfiling.cpp */; }; 500DC9BE19106E89007B91BF /* CCProfiling.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9BB19106E89007B91BF /* CCProfiling.h */; }; 500DC9BF19106E89007B91BF /* CCProfiling.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9BB19106E89007B91BF /* CCProfiling.h */; }; - 500DC9E5191BF301007B91BF /* CCVertexAttribBind.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9E1191BF301007B91BF /* CCVertexAttribBind.h */; }; - 500DC9E6191BF301007B91BF /* CCVertexAttribBind.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9E1191BF301007B91BF /* CCVertexAttribBind.h */; }; - 500DC9E7191BF301007B91BF /* CCVertexAttribBind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9E2191BF301007B91BF /* CCVertexAttribBind.cpp */; }; - 500DC9E8191BF301007B91BF /* CCVertexAttribBind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9E2191BF301007B91BF /* CCVertexAttribBind.cpp */; }; 500DC9E9191BF301007B91BF /* CCGLProgramState.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9E3191BF301007B91BF /* CCGLProgramState.h */; }; 500DC9EA191BF301007B91BF /* CCGLProgramState.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9E3191BF301007B91BF /* CCGLProgramState.h */; }; 500DC9EB191BF301007B91BF /* CCGLProgramState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9E4191BF301007B91BF /* CCGLProgramState.cpp */; }; @@ -2700,8 +2696,6 @@ 500DC9B519106E6D007B91BF /* TransformUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransformUtils.h; sourceTree = ""; }; 500DC9BA19106E89007B91BF /* CCProfiling.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCProfiling.cpp; path = ../base/CCProfiling.cpp; sourceTree = ""; }; 500DC9BB19106E89007B91BF /* CCProfiling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCProfiling.h; path = ../base/CCProfiling.h; sourceTree = ""; }; - 500DC9E1191BF301007B91BF /* CCVertexAttribBind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVertexAttribBind.h; sourceTree = ""; }; - 500DC9E2191BF301007B91BF /* CCVertexAttribBind.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCVertexAttribBind.cpp; sourceTree = ""; }; 500DC9E3191BF301007B91BF /* CCGLProgramState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgramState.h; sourceTree = ""; }; 500DC9E4191BF301007B91BF /* CCGLProgramState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgramState.cpp; sourceTree = ""; }; 50272538190BF1B900AAF4ED /* cocos2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cocos2d.h; path = ../cocos/cocos2d.h; sourceTree = ""; }; @@ -3258,8 +3252,6 @@ 1A570238180BCC580088DEC7 /* shaders */ = { isa = PBXGroup; children = ( - 500DC9E1191BF301007B91BF /* CCVertexAttribBind.h */, - 500DC9E2191BF301007B91BF /* CCVertexAttribBind.cpp */, 500DC9E3191BF301007B91BF /* CCGLProgramState.h */, 500DC9E4191BF301007B91BF /* CCGLProgramState.cpp */, 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */, @@ -5042,7 +5034,6 @@ 1A57022F180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */, 500DC96A19106300007B91BF /* CCEventListenerCustom.h in Headers */, B2AF2F9718EBAEAE00C5807C /* MathUtil.h in Headers */, - 500DC9E5191BF301007B91BF /* CCVertexAttribBind.h in Headers */, 1A570236180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */, 1A57024D180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */, 1A57024F180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */, @@ -5653,7 +5644,6 @@ 1AD71EAC180E26E600808F54 /* Attachment.h in Headers */, 500DC94719106300007B91BF /* CCDataVisitor.h in Headers */, 2905FA4918CF08D100240AA3 /* UIButton.h in Headers */, - 500DC9E6191BF301007B91BF /* CCVertexAttribBind.h in Headers */, 500DC96719106300007B91BF /* CCEventListenerAcceleration.h in Headers */, 1AD71EB0180E26E600808F54 /* AttachmentLoader.h in Headers */, 1AD71EB4180E26E600808F54 /* Bone.h in Headers */, @@ -6216,7 +6206,6 @@ 1A570225180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */, 1A570229180BCC1A0088DEC7 /* CCParticleSystem.cpp in Sources */, 1A57022D180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp in Sources */, - 500DC9E7191BF301007B91BF /* CCVertexAttribBind.cpp in Sources */, 500DC9B01910633C007B91BF /* CCTouch.cpp in Sources */, 50FCEB9B18C72017004AD434 /* ImageViewReader.cpp in Sources */, 500DC9AA19106300007B91BF /* ZipUtils.cpp in Sources */, @@ -6774,7 +6763,6 @@ 1AAF5854180E40B9000584C8 /* LocalStorageAndroid.cpp in Sources */, 1A9DCA24180E6955007A3AD4 /* ccFPSImages.c in Sources */, 1A9DCA28180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */, - 500DC9E8191BF301007B91BF /* CCVertexAttribBind.cpp in Sources */, 50FCEBA018C72017004AD434 /* LayoutReader.cpp in Sources */, 50E6D33518E174130051CA34 /* UIHBox.cpp in Sources */, 500DC98F19106300007B91BF /* CCRef.cpp in Sources */, diff --git a/cocos/2d/CCVertexAttribBind.cpp b/cocos/2d/CCVertexAttribBind.cpp deleted file mode 100644 index c2e96241aa..0000000000 --- a/cocos/2d/CCVertexAttribBind.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** - Copyright 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 false 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/CCDirector.h" -#include "2d/CCVertexAttribBind.h" -#include "2d/ccGLStateCache.h" -#include "base/ccMacros.h" -#include "2d/platform/CCFileUtils.h" -#include "2d/uthash.h" -#include "deprecated/CCString.h" - -NS_CC_BEGIN - -VertexAttribType::VertexAttribType(): _type(GL_FLOAT), _size(0), _location(-1), _offset(0) -{ -} -VertexAttribType::VertexAttribType(GLenum type, int size): _type(type), _size(size), _location(-1), _offset(0) -{ - switch (type) { - case GL_FLOAT_VEC2: - _type = GL_FLOAT; - _size = 2; - break; - case GL_FLOAT_VEC3: - _type = GL_FLOAT; - _size = 3; - break; - case GL_FLOAT_VEC4: - _type = GL_FLOAT; - _size = 4; - break; - - default: - break; - } -} - - -int VertexAttribType::getByteSize() -{ - int byteSize = 0; - switch (_type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - byteSize = _size; - break; - case GL_SHORT: - case GL_UNSIGNED_SHORT: - byteSize = _size * sizeof(GLshort); - break; - case GL_FLOAT: - byteSize = _size * sizeof(GLfloat); - break; - default: - CCASSERT(0,"type error"); - break; - } - return byteSize; -} - -VertexAttribBind::VertexAttribBind(const VertexAttribType* elem, int count) -{ - setVertexAttribElems(elem, count); -} - -VertexAttribBind::VertexAttribBind(const std::vector& elems) -{ - setVertexAttribElems(&elems[0], elems.size()); -} - -VertexAttribBind::VertexAttribBind(const std::vector& attribs) -{ - std::vector elems; - for (auto it = attribs.begin(); it != attribs.end(); it++) { - VertexAttribType type((*it)->type, (*it)->size); - type._location = (*it)->index; - elems.push_back(type); - } - setVertexAttribElems(&elems[0], elems.size()); -} - -VertexAttribBind::~VertexAttribBind() -{ - delete[] _vertexAttribs; -} - -void VertexAttribBind::bindAttribute(int index, int attribLocation) -{ - //make sure index and attribute location are validate - _vertexAttribs[index]._location = attribLocation; -} - -//bind attributes pointer -void VertexAttribBind::bindAttributePtr(void* vertexPointer) -{ - for (auto i = 0; i < _vertexAtttribCount; i++) { - auto elem = _vertexAttribs[i]; - if (elem._location != -1) - { - glEnableVertexAttribArray(elem._location); - void* pointer = vertexPointer ? (void*)(((unsigned char*)vertexPointer) + elem._offset) : (void*)elem._offset; - glVertexAttribPointer(elem._location, elem._size, elem._type, GL_FALSE, _stride, pointer); - } - } -} - -void VertexAttribBind::setVertexAttribElems(const VertexAttribType* elem, int count) -{ - _vertexAtttribCount = count; - _vertexAttribs = new VertexAttribType[count]; - _stride = 0; - for (auto i = 0; i < count; i++) { - _vertexAttribs[i] = elem[i]; - _vertexAttribs[i]._offset = _stride; - _stride += _vertexAttribs[i].getByteSize(); - } -} - -NS_CC_END diff --git a/cocos/2d/CCVertexAttribBind.h b/cocos/2d/CCVertexAttribBind.h deleted file mode 100644 index f56059becf..0000000000 --- a/cocos/2d/CCVertexAttribBind.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** - Copyright 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 false 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 __CCVRETEXATTRIBBIND_H__ -#define __CCVRETEXATTRIBBIND_H__ - -#include "base/ccMacros.h" -#include "base/CCRef.h" -#include "CCGL.h" -#include "math/CCMath.h" -#include "2d/CCGLProgram.h" -#include - -NS_CC_BEGIN - -USING_NS_CC_MATH; - -////vertex attribute///// -class VertexAttribType -{ - friend class VertexAttribBind; - friend class GLProgram; -public: - VertexAttribType(); - - VertexAttribType(GLenum type, int size); - - int getByteSize(); - -protected: - GLenum _type; - int _size; - int _location; - int _offset; -}; - -////vertex attributes bind -class VertexAttribBind -{ -public: - VertexAttribBind(const VertexAttribType* elem, int count); - - VertexAttribBind(const std::vector& elems); - - VertexAttribBind(const std::vector& attribs); - - virtual ~VertexAttribBind(); - - /** - * bind vertex attributes. - * - * @param index Position in _vertexAttribs - * @param attribLocation location in shader. It can be queried from GLProgram, eg. program->getAttribLocation("a_position") - */ - void bindAttribute(int index, int attribLocation); - - /**bind attributes pointer**/ - void bindAttributePtr(void* vertexPointer = nullptr); - -protected: - - void setVertexAttribElems(const VertexAttribType* elem, int count); - - VertexAttribType* _vertexAttribs; - int _vertexAtttribCount; - int _stride; -}; - -NS_CC_END - -#endif /* __CCVRETEXATTRIBBIND_H__ */ From 580ebf939fd818a5032dd9314964135601148f9e Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 8 May 2014 15:43:12 -0700 Subject: [PATCH 022/174] working Ok with new API --- cocos/2d/CCAtlasNode.cpp | 2 +- cocos/2d/CCGLProgramState.cpp | 20 +- cocos/2d/CCLabel.cpp | 17 +- cocos/2d/CCNode.cpp | 59 ++- cocos/2d/CCNode.h | 23 +- cocos/2d/CCParticleBatchNode.cpp | 2 +- cocos/2d/CCParticleSystemQuad.cpp | 2 +- cocos/2d/CCSprite.cpp | 2 +- cocos/2d/CCSpriteBatchNode.cpp | 2 +- cocos/editor-support/cocostudio/CCSkin.cpp | 2 +- .../Classes/ShaderTest/ShaderTest.cpp | 46 +-- .../cpp-tests/Classes/ShaderTest/ShaderTest.h | 1 - .../Classes/ShaderTest/ShaderTest2.cpp | 381 +++++++----------- 13 files changed, 249 insertions(+), 310 deletions(-) diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index 64e36f5956..ed366910fe 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -138,7 +138,7 @@ void AtlasNode::draw(Renderer *renderer, const Matrix &transform, bool transform _quadCommand.init( _globalZOrder, _textureAtlas->getTexture()->getName(), - _shaderProgram, + getGLProgram(), _blendFunc, _textureAtlas->getQuads(), _quadsToDraw, diff --git a/cocos/2d/CCGLProgramState.cpp b/cocos/2d/CCGLProgramState.cpp index 5c4cb1e9ed..526e213b83 100644 --- a/cocos/2d/CCGLProgramState.cpp +++ b/cocos/2d/CCGLProgramState.cpp @@ -322,15 +322,27 @@ VertexAttribValue* GLProgramState::getVertexAttribValue(const std::string &name) void GLProgramState::setVertexAttribCallback(const std::string &name, const std::function callback) { VertexAttribValue *v = getVertexAttribValue(name); - v->setCallback(callback); - _vertexAttribsFlags |= 1 << v->_vertexAttrib->index; + if(v) { + v->setCallback(callback); + _vertexAttribsFlags |= 1 << v->_vertexAttrib->index; + } + else + { + CCASSERT(false, "attribute not found"); + } } void GLProgramState::setVertexAttribPointer(const std::string &name, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer) { auto v = getVertexAttribValue(name); - v->setPointer(size, type, normalized, stride, pointer); - _vertexAttribsFlags |= 1 << v->_vertexAttrib->index; + if(v) { + v->setPointer(size, type, normalized, stride, pointer); + _vertexAttribsFlags |= 1 << v->_vertexAttrib->index; + } + else + { + CCASSERT(false, "attribute not found"); + } } diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 746944c579..0837ace14c 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -351,20 +351,20 @@ void Label::updateShaderProgram() break; case cocos2d::LabelEffect::OUTLINE: setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_OUTLINE)); - _uniformEffectColor = glGetUniformLocation(_shaderProgram->getProgram(), "v_effectColor"); + _uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "v_effectColor"); break; case cocos2d::LabelEffect::GLOW: if (_useDistanceField) { setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW)); - _uniformEffectColor = glGetUniformLocation(_shaderProgram->getProgram(), "v_effectColor"); + _uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "v_effectColor"); } break; default: return; } - _uniformTextColor = glGetUniformLocation(_shaderProgram->getProgram(), "v_textColor"); + _uniformTextColor = glGetUniformLocation(getGLProgram()->getProgram(), "v_textColor"); } void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false */, bool useA8Shader /* = false */) @@ -846,18 +846,19 @@ void Label::onDraw(const Matrix& transform, bool transformUpdated) return; } - _shaderProgram->use(); + auto glprogram = getGLProgram(); + glprogram->use(); GL::blendFunc( _blendFunc.src, _blendFunc.dst ); if (_currentLabelType == LabelType::TTF) { - _shaderProgram->setUniformLocationWith4f(_uniformTextColor, + glprogram->setUniformLocationWith4f(_uniformTextColor, _textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a); } if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW) { - _shaderProgram->setUniformLocationWith4f(_uniformEffectColor, + glprogram->setUniformLocationWith4f(_uniformEffectColor, _effectColorF.r,_effectColorF.g,_effectColorF.b,_effectColorF.a); } @@ -866,7 +867,7 @@ void Label::onDraw(const Matrix& transform, bool transformUpdated) drawShadowWithoutBlur(); } - _shaderProgram->setUniformsForBuiltins(transform); + glprogram->setUniformsForBuiltins(transform); for(const auto &child: _children) { @@ -889,7 +890,7 @@ void Label::drawShadowWithoutBlur() _displayedOpacity = _shadowOpacity * _displayedOpacity; setColor(_shadowColor); - _shaderProgram->setUniformsForBuiltins(_shadowTransform); + getGLProgram()->setUniformsForBuiltins(_shadowTransform); for(const auto &child: _children) { child->updateTransform(); diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 7bfd23019b..65cc8b68d4 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -30,30 +30,29 @@ THE SOFTWARE. #include -#include "deprecated/CCString.h" -#include "2d/ccCArray.h" -#include "math/TransformUtils.h" -#include "2d/CCGrid.h" #include "base/CCDirector.h" #include "base/CCScheduler.h" #include "base/CCTouch.h" -#include "2d/CCActionManager.h" -#include "2d/CCScriptSupport.h" -#include "2d/CCGLProgram.h" #include "base/CCEventDispatcher.h" #include "base/CCEvent.h" #include "base/CCEventTouch.h" +#include "2d/ccCArray.h" +#include "2d/CCGrid.h" +#include "2d/CCActionManager.h" +#include "2d/CCScriptSupport.h" +#include "2d/CCGLProgram.h" #include "2d/CCScene.h" +#include "2d/CCGLProgramState.h" +#include "2d/CCComponent.h" +#include "2d/CCComponentContainer.h" +#include "math/TransformUtils.h" + +#include "deprecated/CCString.h" #if CC_USE_PHYSICS #include "physics/CCPhysicsBody.h" #endif -// externals -#include "2d/CCComponent.h" -#include "2d/CCComponentContainer.h" - - #if CC_NODE_RENDER_SUBPIXEL #define RENDER_IN_SUBPIXEL @@ -102,7 +101,7 @@ Node::Node(void) // userData is always inited as nil , _userData(nullptr) , _userObject(nullptr) -, _shaderProgram(nullptr) +, _glProgramState(nullptr) , _orderOfArrival(0) , _running(false) , _visible(true) @@ -155,7 +154,7 @@ Node::~Node() CC_SAFE_RELEASE_NULL(_userObject); // attributes - CC_SAFE_RELEASE_NULL(_shaderProgram); + CC_SAFE_RELEASE_NULL(_glProgramState); for (auto& child : _children) { @@ -629,11 +628,35 @@ void Node::setUserObject(Ref *pUserObject) _userObject = pUserObject; } -void Node::setShaderProgram(GLProgram *pShaderProgram) +GLProgramState* Node::getGLProgramState() { - CC_SAFE_RETAIN(pShaderProgram); - CC_SAFE_RELEASE(_shaderProgram); - _shaderProgram = pShaderProgram; + return _glProgramState; +} + +void Node::setGLProgramState(cocos2d::GLProgramState *glProgramState) +{ + if(glProgramState != _glProgramState) { + CC_SAFE_RELEASE(_glProgramState); + _glProgramState = glProgramState; + CC_SAFE_RETAIN(_glProgramState); + } +} + +void Node::setGLProgram(GLProgram *glProgram) +{ + if(_glProgramState == nullptr) { + _glProgramState = GLProgramState::create(glProgram); + _glProgramState->retain(); + } + else + { + _glProgramState->setGLProgram(glProgram); + } +} + +GLProgram * Node::getGLProgram() +{ + return _glProgramState ? _glProgramState->getGLProgram() : nullptr; } Scene* Node::getScene() diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index dd8451bfa9..a8270b62ee 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -33,7 +33,6 @@ #include "math/CCAffineTransform.h" #include "CCGL.h" #include "2d/ccGLStateCache.h" -#include "2d/CCGLProgram.h" #include "2d/CCScriptSupport.h" #include "2d/CCProtocols.h" #include "base/CCEventDispatcher.h" @@ -53,6 +52,8 @@ class ComponentContainer; class EventDispatcher; class Scene; class Renderer; +class GLProgram; +class GLProgramState; #if CC_USE_PHYSICS class PhysicsBody; #endif @@ -821,14 +822,17 @@ public: /// @{ - /// @name Shader Program + /// @name GLProgram /** - * Return the shader program currently used for this node + * Return the GLProgram (shader) currently used for this node * - * @return The shader program currently used for this node + * @return The GLProgram (shader) currently used for this node */ - virtual GLProgram* getShaderProgram() { return _shaderProgram; } - virtual const GLProgram* getShaderProgram() const { return _shaderProgram; } + GLProgram* getGLProgram(); + CC_DEPRECATED_ATTRIBUTE GLProgram* getShaderProgram() { return getGLProgram(); } + + GLProgramState *getGLProgramState(); + void setGLProgramState(GLProgramState *glProgramState); /** * Sets the shader program for this node @@ -836,12 +840,13 @@ public: * Since v2.0, each rendering node must set its shader program. * It should be set in initialize phase. @code - node->setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + node->setGLrProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); @endcode * * @param shaderProgram The shader program */ - virtual void setShaderProgram(GLProgram *shaderProgram); + void setGLProgram(GLProgram *glprogram); + CC_DEPRECATED_ATTRIBUTE void setShaderProgram(GLProgram *glprogram) { setGLProgram(glprogram); } /// @} end of Shader Program @@ -1417,7 +1422,7 @@ protected: void *_userData; ///< A user assingned void pointer, Can be point to any cpp object Ref *_userObject; ///< A user assigned Object - GLProgram *_shaderProgram; ///< OpenGL shader + GLProgramState *_glProgramState; ///< OpenGL Program State int _orderOfArrival; ///< used to preserve sequence while sorting children with the same localZOrder diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index 0c049b7059..dd74d3b33e 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -392,7 +392,7 @@ void ParticleBatchNode::draw(Renderer *renderer, const Matrix &transform, bool t _batchCommand.init( _globalZOrder, - _shaderProgram, + getGLProgram(), _blendFunc, _textureAtlas, _modelViewTransform); diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index 297c273084..ef17b8e1d2 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -374,7 +374,7 @@ void ParticleSystemQuad::draw(Renderer *renderer, const Matrix &transform, bool //quad command if(_particleIdx > 0) { - _quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, _quads, _particleIdx, transform); + _quadCommand.init(_globalZOrder, _texture->getName(), getGLProgram(), _blendFunc, _quads, _particleIdx, transform); renderer->addCommand(&_quadCommand); } } diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 7129bd6e98..81dd180c99 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -590,7 +590,7 @@ void Sprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpd if(_insideBounds) { - _quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, transform); + _quadCommand.init(_globalZOrder, _texture->getName(), getGLProgram(), _blendFunc, &_quad, 1, transform); renderer->addCommand(&_quadCommand); #if CC_SPRITE_DEBUG_DRAW _customDebugDrawCommand.init(_globalZOrder); diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index 2fc94ee92b..c65d34b041 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -368,7 +368,7 @@ void SpriteBatchNode::draw(Renderer *renderer, const Matrix &transform, bool tra _batchCommand.init( _globalZOrder, - _shaderProgram, + getGLProgram(), _blendFunc, _textureAtlas, transform); diff --git a/cocos/editor-support/cocostudio/CCSkin.cpp b/cocos/editor-support/cocostudio/CCSkin.cpp index 68213600a9..4c891c261a 100644 --- a/cocos/editor-support/cocostudio/CCSkin.cpp +++ b/cocos/editor-support/cocostudio/CCSkin.cpp @@ -224,7 +224,7 @@ void Skin::draw(Renderer *renderer, const Matrix &transform, bool transformUpdat Matrix mv = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); //TODO implement z order - _quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv); + _quadCommand.init(_globalZOrder, _texture->getName(), getGLProgram(), _blendFunc, &_quad, 1, mv); renderer->addCommand(&_quadCommand); } diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 9dbb8d7e93..7925123aba 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -116,7 +116,6 @@ ShaderNode::ShaderNode() ShaderNode::~ShaderNode() { - CC_SAFE_RELEASE(_glProgramState); } ShaderNode* ShaderNode::shaderNodeWithVertex(const char *vert, const char *frag) @@ -143,7 +142,7 @@ bool ShaderNode::initWithVertex(const char *vert, const char *frag) _time = 0; _resolution = Vector2(SIZE_X, SIZE_Y); - _glProgramState->getUniformValue("resolution")->setValue(_resolution); + getGLProgramState()->getUniformValue("resolution")->setValue(_resolution); scheduleUpdate(); @@ -165,10 +164,7 @@ void ShaderNode::loadShaderVertex(const char *vert, const char *frag) shader->updateUniforms(); - this->setShaderProgram(shader); - - _glProgramState = GLProgramState::create(shader); - _glProgramState->retain(); + this->setGLProgram(shader); } void ShaderNode::update(float dt) @@ -181,7 +177,7 @@ void ShaderNode::setPosition(const Vector2 &newPosition) Node::setPosition(newPosition); auto position = getPosition(); _center = Vector2(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR()); - _glProgramState->getUniformValue("center")->setValue(_center); + getGLProgramState()->getUniformValue("center")->setValue(_center); } void ShaderNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -197,8 +193,9 @@ void ShaderNode::onDraw(const Matrix &transform, bool transformUpdated) float w = SIZE_X, h = SIZE_Y; GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h}; - _glProgramState->setVertexAttribPointer("a_position", 2, GL_FLOAT, GL_FALSE, 0, vertices); - _glProgramState->apply(transform); + auto glProgramState = getGLProgramState(); + glProgramState->setVertexAttribPointer("a_position", 2, GL_FLOAT, GL_FALSE, 0, vertices); + glProgramState->apply(transform); glDrawArrays(GL_TRIANGLES, 0, 6); @@ -432,12 +429,10 @@ protected: float _weightSum; CustomCommand _customCommand; - GLProgramState *_glProgramState; }; SpriteBlur::~SpriteBlur() { - CC_SAFE_RELEASE(_glProgramState); } SpriteBlur* SpriteBlur::create(const char *pszFileName) @@ -476,7 +471,7 @@ bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect) _samplingRadius = 0; this->initProgram(); - _glProgramState->getUniformValue("onePixelSize")->setValue(_pixelSize); + getGLProgramState()->getUniformValue("onePixelSize")->setValue(_pixelSize); return true; } @@ -489,33 +484,25 @@ void SpriteBlur::initProgram() GLchar * fragSource = (GLchar*) String::createWithContentsOfFile( FileUtils::getInstance()->fullPathForFilename("Shaders/example_Blur.fsh").c_str())->getCString(); auto program = GLProgram::createWithByteArrays(ccPositionTextureColor_vert, fragSource); - setShaderProgram(program); - - CHECK_GL_ERROR_DEBUG(); - program->link(); - - CHECK_GL_ERROR_DEBUG(); - program->updateUniforms(); CHECK_GL_ERROR_DEBUG(); + setGLProgram(program); - _glProgramState = GLProgramState::create(program); - _glProgramState->retain(); - + auto glProgramState = getGLProgramState(); #define kQuadSize sizeof(_quad.bl) size_t offset = (size_t)&_quad; // position int diff = offsetof( V3F_C4B_T2F, vertices); - _glProgramState->setVertexAttribPointer("a_position", 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + glProgramState->setVertexAttribPointer("a_position", 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); // texcoord diff = offsetof( V3F_C4B_T2F, texCoords); - _glProgramState->setVertexAttribPointer("a_texCoord", 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); + glProgramState->setVertexAttribPointer("a_texCoord", 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); // color diff = offsetof( V3F_C4B_T2F, colors); - _glProgramState->setVertexAttribPointer("a_color", 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); + glProgramState->setVertexAttribPointer("a_color", 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); } void SpriteBlur::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -527,10 +514,11 @@ void SpriteBlur::draw(Renderer *renderer, const Matrix &transform, bool transfor void SpriteBlur::onDraw(const Matrix &transform, bool transformUpdated) { - _glProgramState->setTexture(getTexture()); - _glProgramState->setBlendFunc(getBlendFunc()); + auto glProgramState = getGLProgramState(); + glProgramState->setTexture(getTexture()); + glProgramState->setBlendFunc(getBlendFunc()); - _glProgramState->apply(transform); + glProgramState->apply(transform); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); @@ -571,7 +559,7 @@ void SpriteBlur::setBlurSize(float f) } log("_blurRadius:%d",_blurRadius); - _glProgramState->getUniformValue("gaussianCoefficient")->setValue(Vector4(_samplingRadius, _scale, _cons, _weightSum)); + getGLProgramState()->getUniformValue("gaussianCoefficient")->setValue(Vector4(_samplingRadius, _scale, _cons, _weightSum)); } // ShaderBlur diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h index 0a5cc13b80..3bb1fb1b78 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h @@ -136,7 +136,6 @@ protected: std::string _vertFileName; std::string _fragFileName; CustomCommand _customCommand; - GLProgramState *_glProgramState; }; class ShaderTestScene : public TestScene diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 1cfad92cb3..1f7585233b 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -1,9 +1,31 @@ - #include "ShaderTest2.h" +/**************************************************************************** + Copyright (c) 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. + ****************************************************************************/ + +#include "ShaderTest2.h" #include "ShaderTest.h" #include "../testResource.h" #include "cocos2d.h" -#include "renderer/CCRenderCommand.h" -#include "renderer/CCCustomCommand.h" namespace ShaderTest2 { @@ -122,15 +144,13 @@ public: void listenBackToForeground(Ref *obj); protected: - virtual void buildCustomUniforms() = 0; virtual void setCustomUniforms() = 0; -protected: + std::string _fragSourceFile; std::string _vertSourceFile; -protected: + CustomCommand _renderCommand; void onDraw(const Matrix &transform, bool transformUpdated); - }; ShaderSprite::ShaderSprite() @@ -167,25 +187,31 @@ void ShaderSprite::initShader() } auto program = GLProgram::createWithByteArrays(vertSource.c_str(), fragSource.c_str()); - setShaderProgram(program); - - CHECK_GL_ERROR_DEBUG(); - program->link(); - - CHECK_GL_ERROR_DEBUG(); - program->updateUniforms(); - - CHECK_GL_ERROR_DEBUG(); - - buildCustomUniforms(); - - CHECK_GL_ERROR_DEBUG(); + setGLProgram(program); + + auto glprogramState = getGLProgramState(); + + // hack, fix it later + glprogramState->setTexture(getTexture()); + glprogramState->setBlendFunc(getBlendFunc()); + + setCustomUniforms(); + +#define kQuadSize sizeof(_quad.bl) + size_t offset = (size_t)&_quad; + + // vertex + int diff = offsetof( V3F_C4B_T2F, vertices); + glprogramState->setVertexAttribPointer("a_position", 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + // texCoods + diff = offsetof( V3F_C4B_T2F, texCoords); + glprogramState->setVertexAttribPointer("a_texCoord", 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + // color + diff = offsetof( V3F_C4B_T2F, colors); + glprogramState->setVertexAttribPointer("a_color", 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*) (offset + diff)); - program->getVertexAttrib("a_color")->redefineTypeAndSize(GL_UNSIGNED_BYTE, 4, GL_TRUE); - program->getVertexAttrib("a_position")->redefineTypeAndSize(GL_FLOAT, 3, GL_FALSE); - program->getVertexAttrib("a_texCoord")->redefineTypeAndSize(GL_FLOAT, 2, GL_FALSE); } void ShaderSprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -198,34 +224,10 @@ void ShaderSprite::draw(Renderer *renderer, const Matrix &transform, bool transf void ShaderSprite::onDraw(const Matrix &transform, bool transformUpdated) { - auto shader = getShaderProgram(); - shader->use(); - shader->setUniformsForBuiltins(transform); - - setCustomUniforms(); - - GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); - GL::blendFunc(_blendFunc.src, _blendFunc.dst); - GL::bindTexture2D( getTexture()->getName()); - - // - // Attributes - // - #define kQuadSize sizeof(_quad.bl) - size_t offset = (size_t)&_quad; - - // vertex - int diff = offsetof( V3F_C4B_T2F, vertices); - shader->getVertexAttrib("a_position")->setPointer(kQuadSize, (void*) (offset + diff)); - - // texCoods - diff = offsetof( V3F_C4B_T2F, texCoords); - shader->getVertexAttrib("a_texCoord")->setPointer(kQuadSize, (void*) (offset + diff)); - - // color - diff = offsetof( V3F_C4B_T2F, colors); - shader->getVertexAttrib("a_color")->setPointer(kQuadSize, (void*) (offset + diff)); + getGLProgramState()->setTexture(getTexture()); + getGLProgramState()->setBlendFunc(getBlendFunc()); + getGLProgramState()->apply(transform); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4); } @@ -235,9 +237,9 @@ class NormalSprite : public ShaderSprite, public ShaderSpriteCreator @@ -286,10 +277,10 @@ public: CREATE_FUNC(BlurSprite); BlurSprite(); void setBlurSize(float f); + protected: - virtual void buildCustomUniforms(); - virtual void setCustomUniforms(); -protected: + virtual void setCustomUniforms() override; + int _blurRadius; Vector2 _pixelSize; @@ -297,9 +288,6 @@ protected: float _scale; float _cons; float _weightSum; - - GLuint pixelSizeLocation; - GLuint coefficientLocation; }; BlurSprite::BlurSprite() @@ -307,7 +295,7 @@ BlurSprite::BlurSprite() _fragSourceFile = "Shaders/example_Blur.fsh"; } -void BlurSprite::buildCustomUniforms() +void BlurSprite::setCustomUniforms() { auto s = getTexture()->getContentSizeInPixels(); _blurRadius = 0; @@ -315,16 +303,10 @@ void BlurSprite::buildCustomUniforms() _samplingRadius = 0; setBlurSize(3.0f); - auto program = getShaderProgram(); - pixelSizeLocation = program->getUniformLocation("onePixelSize"); - coefficientLocation = program->getUniformLocation("gaussianCoefficient"); -} -void BlurSprite::setCustomUniforms() -{ - auto program = getShaderProgram(); - program->setUniformLocationWith2f(pixelSizeLocation, _pixelSize.x, _pixelSize.y); - program->setUniformLocationWith4f(coefficientLocation, _samplingRadius, _scale,_cons,_weightSum); + auto programState = getGLProgramState(); + programState->getUniformValue("onePixelSize")->setValue(_pixelSize); + programState->getUniformValue("gaussianCoefficient")->setValue(Vector4(_samplingRadius, _scale, _cons, _weightSum)); } void BlurSprite::setBlurSize(float f) @@ -367,13 +349,11 @@ class NoiseSprite : public ShaderSprite, public ShaderSpriteCreator public: CREATE_FUNC(NoiseSprite); NoiseSprite(); - -private: - GLfloat _resolution[2]; - GLuint _resolutionLoc; + protected: - virtual void buildCustomUniforms(); - virtual void setCustomUniforms(); + virtual void setCustomUniforms() override; + + GLfloat _resolution[2]; }; NoiseSprite::NoiseSprite() @@ -381,18 +361,11 @@ NoiseSprite::NoiseSprite() _fragSourceFile = "Shaders/example_Noisy.fsh"; } -void NoiseSprite::buildCustomUniforms() -{ - auto program = getShaderProgram(); - _resolutionLoc = program->getUniformLocation("resolution"); -} - void NoiseSprite::setCustomUniforms() { _resolution[0] = getTexture()->getContentSizeInPixels().width; _resolution[1] = getTexture()->getContentSizeInPixels().height; - - getShaderProgram()->setUniformLocationWith2fv(_resolutionLoc, _resolution, 1); + getGLProgramState()->getUniformValue("resolution")->setValue(Vector2(_resolution[0],_resolution[1])); } class EdgeDetectionSprite : public ShaderSprite, public ShaderSpriteCreator @@ -401,12 +374,10 @@ public: CREATE_FUNC(EdgeDetectionSprite); EdgeDetectionSprite(); -private: - GLfloat _resolution[2]; - GLuint _resolutionLoc; protected: - virtual void buildCustomUniforms(); - virtual void setCustomUniforms(); + virtual void setCustomUniforms() override; + + GLfloat _resolution[2]; }; EdgeDetectionSprite::EdgeDetectionSprite() @@ -414,18 +385,14 @@ EdgeDetectionSprite::EdgeDetectionSprite() _fragSourceFile = "Shaders/example_edgeDetection.fsh"; } -void EdgeDetectionSprite::buildCustomUniforms() -{ - auto program = getShaderProgram(); - _resolutionLoc = program->getUniformLocation("resolution"); -} - void EdgeDetectionSprite::setCustomUniforms() { - _resolution[0] = getTexture()->getContentSizeInPixels().width; - _resolution[1] = getTexture()->getContentSizeInPixels().height; - - getShaderProgram()->setUniformLocationWith2fv(_resolutionLoc, _resolution, 1); + auto programState = getGLProgramState(); + + _resolution[0] = getContentSize().width; + _resolution[1] = getContentSize().height; + + programState->getUniformValue("resolution")->setValue(Vector2(_resolution[0], _resolution[1])); } class BloomSprite : public ShaderSprite, public ShaderSpriteCreator @@ -434,12 +401,10 @@ public: CREATE_FUNC(BloomSprite); BloomSprite(); -private: - GLfloat _resolution[2]; - GLuint _resolutionLoc; protected: - virtual void buildCustomUniforms(); - virtual void setCustomUniforms(); + virtual void setCustomUniforms() override; + + GLfloat _resolution[2]; }; BloomSprite::BloomSprite() @@ -447,18 +412,8 @@ BloomSprite::BloomSprite() _fragSourceFile = "Shaders/example_bloom.fsh"; } -void BloomSprite::buildCustomUniforms() -{ - auto program = getShaderProgram(); - _resolutionLoc = program->getUniformLocation("resolution"); -} - void BloomSprite::setCustomUniforms() { - _resolution[0] = getTexture()->getContentSizeInPixels().width; - _resolution[1] = getTexture()->getContentSizeInPixels().height; - - getShaderProgram()->setUniformLocationWith2fv(_resolutionLoc, _resolution, 1); } class CelShadingSprite : public ShaderSprite, public ShaderSpriteCreator @@ -467,12 +422,10 @@ public: CREATE_FUNC(CelShadingSprite); CelShadingSprite(); -private: - GLfloat _resolution[2]; - GLuint _resolutionLoc; protected: - virtual void buildCustomUniforms(); - virtual void setCustomUniforms(); + virtual void setCustomUniforms() override; + + GLfloat _resolution[2]; }; CelShadingSprite::CelShadingSprite() @@ -480,18 +433,14 @@ CelShadingSprite::CelShadingSprite() _fragSourceFile = "Shaders/example_celShading.fsh"; } -void CelShadingSprite::buildCustomUniforms() -{ - auto program = getShaderProgram(); - _resolutionLoc = program->getUniformLocation("resolution"); -} - void CelShadingSprite::setCustomUniforms() { - _resolution[0] = getTexture()->getContentSizeInPixels().width; - _resolution[1] = getTexture()->getContentSizeInPixels().height; - - getShaderProgram()->setUniformLocationWith2fv(_resolutionLoc, _resolution, 1); + auto programState = getGLProgramState(); + + _resolution[0] = getContentSize().width; + _resolution[1] = getContentSize().height; + + programState->getUniformValue("resolution")->setValue(Vector2(_resolution[0], _resolution[1])); } class LensFlareSprite : public ShaderSprite, public ShaderSpriteCreator @@ -499,15 +448,12 @@ class LensFlareSprite : public ShaderSprite, public ShaderSpriteCreatorgetUniformLocation("resolution"); - _textureResolutionLoc = program->getUniformLocation("textureResolution"); -} - void LensFlareSprite::setCustomUniforms() { + auto programState = getGLProgramState(); + _textureResolution[0] = getTexture()->getContentSizeInPixels().width; _textureResolution[1] = getTexture()->getContentSizeInPixels().height; - _resolution[0] = getContentSize().width; _resolution[1] = getContentSize().height; - - getShaderProgram()->setUniformLocationWith2fv(_resolutionLoc, _resolution, 1); - getShaderProgram()->setUniformLocationWith2fv(_textureResolutionLoc, _textureResolution, 1); + + programState->getUniformValue("resolution")->setValue(Vector2(_resolution[0], _resolution[1])); + programState->getUniformValue("textureResolution")->setValue(Vector2(_textureResolution[0], _textureResolution[1])); } NormalSpriteTest::NormalSpriteTest() @@ -652,13 +592,8 @@ public: CREATE_FUNC(OutlineSprite); OutlineSprite(); -private: - GLuint _outlineColorUniformLocation; - GLuint _thresdholdUniformLocation; - GLuint _radiusUniformLocation; protected: - virtual void buildCustomUniforms(); - virtual void setCustomUniforms(); + virtual void setCustomUniforms() override; }; @@ -669,23 +604,17 @@ OutlineSprite::OutlineSprite() _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; } -void OutlineSprite::buildCustomUniforms() -{ - auto program = getShaderProgram(); - _outlineColorUniformLocation = program->getUniformLocation("u_outlineColor"); - _thresdholdUniformLocation = program->getUniformLocation("u_threshold"); - _radiusUniformLocation = program->getUniformLocation("u_radius"); -} - void OutlineSprite::setCustomUniforms() { - GLfloat color[3] = {1.0, 0.2, 0.3}; + Vector3 color(1.0, 0.2, 0.3); GLfloat radius = 0.01; GLfloat threshold = 1.75; - - getShaderProgram()->setUniformLocationWith3fv(_outlineColorUniformLocation, color, 1); - getShaderProgram()->setUniformLocationWith1f(_radiusUniformLocation, radius); - getShaderProgram()->setUniformLocationWith1f(_thresdholdUniformLocation, threshold); + + auto programState = getGLProgramState(); + + programState->getUniformValue("u_outlineColor")->setValue(color); + programState->getUniformValue("u_radius")->setValue(radius); + programState->getUniformValue("u_threshold")->setValue(threshold); } @@ -716,15 +645,13 @@ public: // void listenBackToForeground(Ref *obj); protected: -// virtual void buildCustomUniforms(); virtual void setCustomUniforms(); -protected: + std::string _fragSourceFile; std::string _vertSourceFile; -protected: + CustomCommand _renderCommand; void onDraw(const Matrix &transform, bool transformUpdated); - }; UniformSprite::UniformSprite() @@ -742,13 +669,9 @@ void UniformSprite::initShader() { auto shader = GLProgram::createWithFilenames(_vertSourceFile, _fragSourceFile); shader->link(); - shader->updateUniforms(); - - this->setShaderProgram(shader); - -// std::string attribname ="a_position"; -// shader->getAttrib(attribname)->size = 2; + + this->setGLProgram(shader); } void UniformSprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -760,24 +683,23 @@ void UniformSprite::draw(Renderer *renderer, const Matrix &transform, bool trans void UniformSprite::setCustomUniforms() { - // FIXME riq TODO -// _shaderProgram->getUniform("center")->setValue(Vector2(480,320)); -// _shaderProgram->getUniform("resolution")->setValue(Vector2(256,256)); + auto glprogramstate = getGLProgramState(); + glprogramstate->getUniformValue("center")->setValue(Vector2(480,320)); + glprogramstate->getUniformValue("resolution")->setValue(Vector2(256,256)); } void UniformSprite::onDraw(const Matrix &transform, bool transformUpdated) { - // Set Shader GLProgram - auto program = getShaderProgram(); - program->use(); - program->setUniformsForBuiltins(transform); - - setCustomUniforms(); - //GL::bindTexture2D( getTexture()->getName()); + auto glprogramstate = getGLProgramState(); float w = 256, h = 256; GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h}; -// program->setVertexAttrib(vertices, true); + + glprogramstate->setVertexAttribPointer("a_position", 2, GL_FLOAT, GL_FALSE, 0, vertices); + + // Set Shader GLProgram + glprogramstate->apply(transform); + // Draw Call Test glDrawArrays(GL_TRIANGLES, 0, 6); @@ -815,12 +737,11 @@ public: // void listenBackToForeground(Ref *obj); protected: - // virtual void buildCustomUniforms(); virtual void setCustomUniforms(); -protected: + std::string _fragSourceFile; std::string _vertSourceFile; -protected: + CustomCommand _renderCommand; void onDraw(const Matrix &transform, bool transformUpdated); }; @@ -838,10 +759,27 @@ AttribSprite::~AttribSprite() void AttribSprite::initShader() { - auto shader = GLProgram::createWithFilenames(_vertSourceFile, _fragSourceFile); - shader->link(); - shader->updateUniforms(); - this->setShaderProgram(shader); + auto glProgram = GLProgram::createWithFilenames(_vertSourceFile, _fragSourceFile); + glProgram->link(); + glProgram->updateUniforms(); + setGLProgram(glProgram); + + auto glProgramState = getGLProgramState(); + +#define kQuadSize sizeof(_quad.bl) + size_t offset = (size_t)&_quad; + + // vertex + int diff = offsetof( V3F_C4B_T2F, vertices); + glProgramState->setVertexAttribPointer("a_position", 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + // texCoods + diff = offsetof( V3F_C4B_T2F, texCoords); + glProgramState->setVertexAttribPointer("a_texCoord", 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + // color + diff = offsetof( V3F_C4B_T2F, colors); + glProgramState->setVertexAttribPointer("a_color", 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*) (offset + diff)); + + //program->getUniformValue("u_diffuseColor")->setValue(Vector4(1,1,1,1)); } void AttribSprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -857,37 +795,10 @@ void AttribSprite::setCustomUniforms() void AttribSprite::onDraw(const Matrix &transform, bool transformUpdated) { - // Set Shader GLProgram - auto program = getShaderProgram(); - program->use(); - program->setUniformsForBuiltins(transform); - - setCustomUniforms(); - - // Set - //glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); - GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); - GL::blendFunc(_blendFunc.src, _blendFunc.dst); - GL::bindTexture2D( getTexture()->getName()); - - // - // Attributes - // - #define kQuadSize sizeof(_quad.bl) - size_t offset = (size_t)&_quad; - size_t stride = kQuadSize; + getGLProgramState()->setTexture(getTexture()); + getGLProgramState()->setBlendFunc(getBlendFunc()); + getGLProgramState()->apply(transform); - int diff = offsetof( V3F_C4B_T2F, vertices); - program->getVertexAttrib("a_position")->setPointer(3, GL_FLOAT, GL_FALSE, stride, (void*) (offset + diff)); - - diff = offsetof( V3F_C4B_T2F, colors); - program->getVertexAttrib("a_color")->setPointer(4, GL_UNSIGNED_BYTE, GL_TRUE, stride, (void*) (offset + diff)); - - diff = offsetof( V3F_C4B_T2F, texCoords); - program->getVertexAttrib("a_texCoord")->setPointer(2, GL_FLOAT, GL_FALSE, stride, (void*) (offset + diff)); - - //program->getUniformValue("u_diffuseColor")->setValue(Vector4(1,1,1,1)); - // glDrawArrays(GL_TRIANGLES, 0, 3); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4); From 2e669c1d2809d20787c32240a67d1f5c7aa980d8 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 8 May 2014 16:04:59 -0700 Subject: [PATCH 023/174] GLProgram::create() returns a linked GLProgram --- cocos/2d/CCGLProgram.cpp | 6 ++++ cocos/2d/CCGLProgramState.cpp | 18 ---------- cocos/2d/CCGLProgramState.h | 9 ----- .../Classes/ShaderTest/ShaderTest.cpp | 26 +++------------ .../Classes/ShaderTest/ShaderTest2.cpp | 33 ++++++------------- 5 files changed, 20 insertions(+), 72 deletions(-) diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index e9bfb1a4a4..b621f31103 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -89,6 +89,8 @@ GLProgram* GLProgram::createWithByteArrays(const GLchar* vShaderByteArray, const { auto ret = new (std::nothrow) GLProgram(); if(ret && ret->initWithByteArrays(vShaderByteArray, fShaderByteArray)) { + ret->link(); + ret->updateUniforms(); ret->autorelease(); return ret; } @@ -101,6 +103,8 @@ GLProgram* GLProgram::createWithFilenames(const std::string& vShaderFilename, co { auto ret = new (std::nothrow) GLProgram(); if(ret && ret->initWithFilenames(vShaderFilename, fShaderFilename)) { + ret->link(); + ret->updateUniforms(); ret->autorelease(); return ret; } @@ -207,6 +211,8 @@ GLProgram* GLProgram::createWithPrecompiledProgramByteArray(const GLchar* vShade { auto ret = new (std::nothrow) GLProgram(); if(ret && ret->initWithPrecompiledProgramByteArray(vShaderByteArray, fShaderByteArray)) { + ret->link(); + ret->updateUniforms(); ret->autorelease(); return ret; } diff --git a/cocos/2d/CCGLProgramState.cpp b/cocos/2d/CCGLProgramState.cpp index 526e213b83..094dc1d29a 100644 --- a/cocos/2d/CCGLProgramState.cpp +++ b/cocos/2d/CCGLProgramState.cpp @@ -216,7 +216,6 @@ GLProgramState* GLProgramState::create(GLProgram *glprogram) GLProgramState::GLProgramState() : _vertexAttribsFlags(0) -, _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED) { } @@ -261,15 +260,6 @@ void GLProgramState::apply(const Matrix& modelView) _glprogram->setUniformsForBuiltins(modelView); - // set texture - int i = 0; - for(const auto& texture : _textures) { - GL::bindTexture2DN(i++, texture->getName()); - } - - // set blending function - GL::blendFunc(_blendFunc.src, _blendFunc.dst); - // enable/disable vertex attribs GL::enableVertexAttribs(_vertexAttribsFlags); @@ -295,14 +285,6 @@ void GLProgramState::setGLProgram(GLProgram *glprogram) } } -void GLProgramState::setTexture(cocos2d::Texture2D *texture) -{ - if(_textures.size()>0) - _textures.replace(0, texture); - else - _textures.pushBack(texture); -} - UniformValue* GLProgramState::getUniformValue(const std::string &name) { const auto itr = _uniforms.find(name); diff --git a/cocos/2d/CCGLProgramState.h b/cocos/2d/CCGLProgramState.h index ab54ca3230..bcce3b57a0 100644 --- a/cocos/2d/CCGLProgramState.h +++ b/cocos/2d/CCGLProgramState.h @@ -27,7 +27,6 @@ THE SOFTWARE. #include "base/ccTypes.h" #include "base/CCVector.h" -#include "2d/CCTexture2D.h" #include "math/Vector2.h" #include "math/Vector3.h" #include "math/Vector4.h" @@ -145,12 +144,6 @@ public: void setGLProgram(GLProgram* glprogram); GLProgram* getGLProgram() const { return _glprogram; } - void setTexture(Texture2D *texture); - Texture2D* getTexture() const { return _textures.at(0); } - - void setBlendFunc(const BlendFunc& blendFunc) { _blendFunc = blendFunc; } - const BlendFunc& getBlendFunc() const { return _blendFunc; } - void setVertexAttribCallback(const std::string &name, const std::function callback); void setVertexAttribPointer(const std::string &name, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer); @@ -169,8 +162,6 @@ protected: uint32_t _vertexAttribsFlags; GLProgram *_glprogram; - Vector _textures; - BlendFunc _blendFunc; }; NS_CC_END diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 7925123aba..e670230614 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -158,12 +158,6 @@ bool ShaderNode::initWithVertex(const char *vert, const char *frag) void ShaderNode::loadShaderVertex(const char *vert, const char *frag) { auto shader = GLProgram::createWithFilenames(vert, frag); - - shader->bindAttribLocation("aVertex", GLProgram::VERTEX_ATTRIB_POSITION); - shader->link(); - - shader->updateUniforms(); - this->setGLProgram(shader); } @@ -189,7 +183,6 @@ void ShaderNode::draw(Renderer *renderer, const Matrix &transform, bool transfor void ShaderNode::onDraw(const Matrix &transform, bool transformUpdated) { - float w = SIZE_X, h = SIZE_Y; GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h}; @@ -484,10 +477,6 @@ void SpriteBlur::initProgram() GLchar * fragSource = (GLchar*) String::createWithContentsOfFile( FileUtils::getInstance()->fullPathForFilename("Shaders/example_Blur.fsh").c_str())->getCString(); auto program = GLProgram::createWithByteArrays(ccPositionTextureColor_vert, fragSource); - program->link(); - program->updateUniforms(); - - CHECK_GL_ERROR_DEBUG(); setGLProgram(program); auto glProgramState = getGLProgramState(); @@ -514,14 +503,13 @@ void SpriteBlur::draw(Renderer *renderer, const Matrix &transform, bool transfor void SpriteBlur::onDraw(const Matrix &transform, bool transformUpdated) { + GL::blendFunc(_blendFunc.src, _blendFunc.dst); + GL::bindTexture2D(_texture->getName()); + auto glProgramState = getGLProgramState(); - glProgramState->setTexture(getTexture()); - glProgramState->setBlendFunc(getBlendFunc()); - glProgramState->apply(transform); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,4); } @@ -644,18 +632,12 @@ bool ShaderRetroEffect::init() GLchar * fragSource = (GLchar*) String::createWithContentsOfFile(FileUtils::getInstance()->fullPathForFilename("Shaders/example_HorizontalColor.fsh"))->getCString(); auto p = GLProgram::createWithByteArrays(ccPositionTexture_vert, fragSource); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); - p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD); - - p->link(); - p->updateUniforms(); - auto director = Director::getInstance(); auto s = director->getWinSize(); _label = Label::createWithBMFont("fonts/west_england-64.fnt","RETRO EFFECT"); _label->setAnchorPoint(Vector2::ANCHOR_MIDDLE); - _label->setShaderProgram(p); + _label->setGLProgram(p); _label->setPosition(Vector2(s.width/2,s.height/2)); diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 1f7585233b..4910076219 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -187,16 +187,10 @@ void ShaderSprite::initShader() } auto program = GLProgram::createWithByteArrays(vertSource.c_str(), fragSource.c_str()); - program->link(); - program->updateUniforms(); setGLProgram(program); auto glprogramState = getGLProgramState(); - // hack, fix it later - glprogramState->setTexture(getTexture()); - glprogramState->setBlendFunc(getBlendFunc()); - setCustomUniforms(); #define kQuadSize sizeof(_quad.bl) @@ -219,13 +213,12 @@ void ShaderSprite::draw(Renderer *renderer, const Matrix &transform, bool transf _renderCommand.init(_globalZOrder); _renderCommand.func = CC_CALLBACK_0(ShaderSprite::onDraw, this, transform, transformUpdated); renderer->addCommand(&_renderCommand); - } void ShaderSprite::onDraw(const Matrix &transform, bool transformUpdated) { - getGLProgramState()->setTexture(getTexture()); - getGLProgramState()->setBlendFunc(getBlendFunc()); + GL::blendFunc(_blendFunc.src, _blendFunc.dst); + GL::bindTexture2D(_texture->getName()); getGLProgramState()->apply(transform); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); @@ -249,7 +242,6 @@ NormalSprite::NormalSprite() void NormalSprite::setCustomUniforms() { - } class GreyScaleSprite : public ShaderSprite, public ShaderSpriteCreator @@ -623,9 +615,9 @@ OutlineShadingSpriteTest::OutlineShadingSpriteTest() if (ShaderTestDemo2::init()) { auto s = Director::getInstance()->getWinSize(); OutlineSprite* sprite = OutlineSprite::createSprite("Images/grossini_dance_10.png"); - sprite->setPosition(Point(s.width * 0.75, s.height/2)); + sprite->setPosition(Vector2(s.width * 0.75, s.height/2)); auto sprite2 = Sprite::create("Images/grossini_dance_10.png"); - sprite2->setPosition(Point(s.width * 0.25, s.height/2)); + sprite2->setPosition(Vector2(s.width * 0.25, s.height/2)); addChild(sprite); addChild(sprite2); } @@ -668,9 +660,6 @@ UniformSprite::~UniformSprite() void UniformSprite::initShader() { auto shader = GLProgram::createWithFilenames(_vertSourceFile, _fragSourceFile); - shader->link(); - shader->updateUniforms(); - this->setGLProgram(shader); } @@ -690,14 +679,14 @@ void UniformSprite::setCustomUniforms() void UniformSprite::onDraw(const Matrix &transform, bool transformUpdated) { - auto glprogramstate = getGLProgramState(); + GL::blendFunc(_blendFunc.src, _blendFunc.dst); + GL::bindTexture2D(_texture->getName()); float w = 256, h = 256; GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h}; + auto glprogramstate = getGLProgramState(); glprogramstate->setVertexAttribPointer("a_position", 2, GL_FLOAT, GL_FALSE, 0, vertices); - - // Set Shader GLProgram glprogramstate->apply(transform); @@ -760,8 +749,6 @@ AttribSprite::~AttribSprite() void AttribSprite::initShader() { auto glProgram = GLProgram::createWithFilenames(_vertSourceFile, _fragSourceFile); - glProgram->link(); - glProgram->updateUniforms(); setGLProgram(glProgram); auto glProgramState = getGLProgramState(); @@ -795,11 +782,11 @@ void AttribSprite::setCustomUniforms() void AttribSprite::onDraw(const Matrix &transform, bool transformUpdated) { - getGLProgramState()->setTexture(getTexture()); - getGLProgramState()->setBlendFunc(getBlendFunc()); + GL::blendFunc(_blendFunc.src, _blendFunc.dst); + GL::bindTexture2D(_texture->getName()); + getGLProgramState()->apply(transform); -// glDrawArrays(GL_TRIANGLES, 0, 3); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4); From 51f498fc9459aaac56b1796dbbb4866b9eed2550 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 8 May 2014 16:42:36 -0700 Subject: [PATCH 024/174] fixed deprecation warnings --- build/cocos2d_libs.xcodeproj/project.pbxproj | 16 ++++++++-------- build/cocos2d_tests.xcodeproj/project.pbxproj | 12 ++++++------ cocos/2d/CCAtlasNode.cpp | 2 +- cocos/2d/CCClippingNode.cpp | 2 +- cocos/2d/CCDrawNode.cpp | 7 ++++--- cocos/2d/CCLabel.cpp | 10 +++++----- cocos/2d/CCLayer.cpp | 6 +++--- cocos/2d/CCMotionStreak.cpp | 6 +++--- cocos/2d/CCParticleBatchNode.cpp | 2 +- cocos/2d/CCParticleSystemQuad.cpp | 2 +- cocos/2d/CCProgressTimer.cpp | 6 +++--- cocos/2d/CCSprite.cpp | 2 +- cocos/2d/CCSpriteBatchNode.cpp | 2 +- cocos/2d/CCTMXLayer.cpp | 8 ++++---- cocos/2d/CCTexture2D.cpp | 6 +++--- cocos/2d/CCTexture2D.h | 4 ++-- cocos/base/ccMacros.h | 6 +++--- cocos/editor-support/cocostudio/CCArmature.cpp | 2 +- cocos/editor-support/cocostudio/CCBatchNode.cpp | 2 +- cocos/editor-support/spine/CCSkeleton.cpp | 6 +++--- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 14 +++++++------- .../scripting/lua-bindings/manual/LuaOpengl.cpp | 2 +- .../project.pbxproj | 4 ++-- .../ClippingNodeTest/ClippingNodeTest.cpp | 2 +- .../CocoStudioArmatureTest/ArmatureScene.cpp | 6 +++--- .../CocoStudioSceneTest/SceneEditorTest.cpp | 2 +- tests/cpp-tests/Classes/LabelTest/LabelTest.cpp | 6 +++--- .../Classes/MutiTouchTest/MutiTouchTest.cpp | 2 +- tests/cpp-tests/Classes/NodeTest/NodeTest.cpp | 6 +++--- .../cpp-tests/Classes/ShaderTest/ShaderTest.cpp | 4 ++-- .../cpp-tests/Classes/ShaderTest/ShaderTest2.cpp | 2 +- .../cpp-tests/Classes/SpriteTest/SpriteTest.cpp | 14 +++++++------- tests/lua-tests/src/OpenGLTest/OpenGLTest.lua | 16 ++++++++-------- 33 files changed, 95 insertions(+), 94 deletions(-) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index c453202c31..0f145ae4d2 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1904,10 +1904,10 @@ 1A57005E180BC5A10088DEC7 /* CCActionTiledGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionTiledGrid.h; sourceTree = ""; }; 1A57005F180BC5A10088DEC7 /* CCActionTween.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionTween.cpp; sourceTree = ""; }; 1A570060180BC5A10088DEC7 /* CCActionTween.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionTween.h; sourceTree = ""; }; - 1A570096180BC5C10088DEC7 /* CCAtlasNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAtlasNode.cpp; sourceTree = ""; }; + 1A570096180BC5C10088DEC7 /* CCAtlasNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCAtlasNode.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A570097180BC5C10088DEC7 /* CCAtlasNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAtlasNode.h; sourceTree = ""; }; 1A57009C180BC5D20088DEC7 /* CCNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNode.cpp; sourceTree = ""; }; - 1A57009D180BC5D20088DEC7 /* CCNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNode.h; sourceTree = ""; }; + 1A57009D180BC5D20088DEC7 /* CCNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CCNode.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 1A57010A180BC8ED0088DEC7 /* CCDrawingPrimitives.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDrawingPrimitives.cpp; sourceTree = ""; }; 1A57010B180BC8EE0088DEC7 /* CCDrawingPrimitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDrawingPrimitives.h; sourceTree = ""; }; 1A57010C180BC8EE0088DEC7 /* CCDrawNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCDrawNode.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; @@ -1958,7 +1958,7 @@ 1A57020D180BCBF40088DEC7 /* CCProgressTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProgressTimer.h; sourceTree = ""; }; 1A57020E180BCBF40088DEC7 /* CCRenderTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCRenderTexture.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A57020F180BCBF40088DEC7 /* CCRenderTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCRenderTexture.h; sourceTree = ""; }; - 1A570219180BCC1A0088DEC7 /* CCParticleBatchNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCParticleBatchNode.cpp; sourceTree = ""; }; + 1A570219180BCC1A0088DEC7 /* CCParticleBatchNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCParticleBatchNode.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A57021A180BCC1A0088DEC7 /* CCParticleBatchNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleBatchNode.h; sourceTree = ""; }; 1A57021B180BCC1A0088DEC7 /* CCParticleExamples.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCParticleExamples.cpp; sourceTree = ""; }; 1A57021C180BCC1A0088DEC7 /* CCParticleExamples.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleExamples.h; sourceTree = ""; }; @@ -1989,7 +1989,7 @@ 1A57024C180BCC6F0088DEC7 /* ccShaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShaders.h; sourceTree = ""; }; 1A570276180BCC900088DEC7 /* CCSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCSprite.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A570277180BCC900088DEC7 /* CCSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSprite.h; sourceTree = ""; }; - 1A570278180BCC900088DEC7 /* CCSpriteBatchNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteBatchNode.cpp; sourceTree = ""; }; + 1A570278180BCC900088DEC7 /* CCSpriteBatchNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCSpriteBatchNode.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A570279180BCC900088DEC7 /* CCSpriteBatchNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpriteBatchNode.h; sourceTree = ""; }; 1A57027A180BCC900088DEC7 /* CCSpriteFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteFrame.cpp; sourceTree = ""; }; 1A57027B180BCC900088DEC7 /* CCSpriteFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpriteFrame.h; sourceTree = ""; }; @@ -2009,8 +2009,8 @@ 1A5702BF180BCE2A0088DEC7 /* CCIMEDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCIMEDispatcher.h; sourceTree = ""; }; 1A5702C6180BCE370088DEC7 /* CCTextFieldTTF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCTextFieldTTF.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A5702C7180BCE370088DEC7 /* CCTextFieldTTF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTextFieldTTF.h; sourceTree = ""; }; - 1A5702CD180BCE560088DEC7 /* CCTexture2D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTexture2D.cpp; sourceTree = ""; }; - 1A5702CE180BCE570088DEC7 /* CCTexture2D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTexture2D.h; sourceTree = ""; }; + 1A5702CD180BCE560088DEC7 /* CCTexture2D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCTexture2D.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; + 1A5702CE180BCE570088DEC7 /* CCTexture2D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CCTexture2D.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 1A5702CF180BCE570088DEC7 /* CCTextureAtlas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTextureAtlas.cpp; sourceTree = ""; }; 1A5702D0180BCE570088DEC7 /* CCTextureAtlas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTextureAtlas.h; sourceTree = ""; }; 1A5702D1180BCE570088DEC7 /* CCTextureCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTextureCache.cpp; sourceTree = ""; }; @@ -2074,7 +2074,7 @@ 1A8C594F180E930E00EF57C3 /* CCActionNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionNode.h; sourceTree = ""; }; 1A8C5950180E930E00EF57C3 /* CCActionObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionObject.cpp; sourceTree = ""; }; 1A8C5951180E930E00EF57C3 /* CCActionObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionObject.h; sourceTree = ""; }; - 1A8C5952180E930E00EF57C3 /* CCArmature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCArmature.cpp; sourceTree = ""; }; + 1A8C5952180E930E00EF57C3 /* CCArmature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCArmature.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A8C5953180E930E00EF57C3 /* CCArmature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCArmature.h; sourceTree = ""; }; 1A8C5954180E930E00EF57C3 /* CCArmatureAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCArmatureAnimation.cpp; sourceTree = ""; }; 1A8C5955180E930E00EF57C3 /* CCArmatureAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCArmatureAnimation.h; sourceTree = ""; }; @@ -2667,7 +2667,7 @@ 500DC91019106300007B91BF /* CCEventTouch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCEventTouch.cpp; path = ../base/CCEventTouch.cpp; sourceTree = ""; }; 500DC91119106300007B91BF /* CCEventTouch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCEventTouch.h; path = ../base/CCEventTouch.h; sourceTree = ""; }; 500DC91219106300007B91BF /* CCEventType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCEventType.h; path = ../base/CCEventType.h; sourceTree = ""; }; - 500DC91319106300007B91BF /* ccMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ccMacros.h; path = ../base/ccMacros.h; sourceTree = ""; }; + 500DC91319106300007B91BF /* ccMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = ccMacros.h; path = ../base/ccMacros.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 500DC91419106300007B91BF /* CCMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCMap.h; path = ../base/CCMap.h; sourceTree = ""; }; 500DC91519106300007B91BF /* CCNS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCNS.cpp; path = ../base/CCNS.cpp; sourceTree = ""; }; 500DC91619106300007B91BF /* CCNS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCNS.h; path = ../base/CCNS.h; sourceTree = ""; }; diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index 8042d5055b..b54af7d616 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -1426,7 +1426,7 @@ 1AC3599018CECF0B00F37B72 /* ChipmunkTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChipmunkTest.h; sourceTree = ""; }; 1AC3599218CECF0B00F37B72 /* ClickAndMoveTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClickAndMoveTest.cpp; sourceTree = ""; }; 1AC3599318CECF0B00F37B72 /* ClickAndMoveTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClickAndMoveTest.h; sourceTree = ""; }; - 1AC3599518CECF0B00F37B72 /* ClippingNodeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClippingNodeTest.cpp; sourceTree = ""; }; + 1AC3599518CECF0B00F37B72 /* ClippingNodeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = ClippingNodeTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AC3599618CECF0B00F37B72 /* ClippingNodeTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClippingNodeTest.h; sourceTree = ""; }; 1AC3599818CECF0B00F37B72 /* CocosDenshionTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocosDenshionTest.cpp; sourceTree = ""; }; 1AC3599918CECF0B00F37B72 /* CocosDenshionTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosDenshionTest.h; sourceTree = ""; }; @@ -1476,7 +1476,7 @@ 1AC359D918CECF0B00F37B72 /* TimelineCallbackLayerLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimelineCallbackLayerLoader.h; sourceTree = ""; }; 1AC359DA18CECF0B00F37B72 /* TimelineCallbackTestLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimelineCallbackTestLayer.cpp; sourceTree = ""; }; 1AC359DB18CECF0B00F37B72 /* TimelineCallbackTestLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimelineCallbackTestLayer.h; sourceTree = ""; }; - 1AC359DD18CECF0B00F37B72 /* ArmatureScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArmatureScene.cpp; sourceTree = ""; }; + 1AC359DD18CECF0B00F37B72 /* ArmatureScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = ArmatureScene.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AC359DE18CECF0B00F37B72 /* ArmatureScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArmatureScene.h; sourceTree = ""; }; 1AC359E018CECF0B00F37B72 /* ComponentsTestScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComponentsTestScene.cpp; sourceTree = ""; }; 1AC359E118CECF0B00F37B72 /* ComponentsTestScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComponentsTestScene.h; sourceTree = ""; }; @@ -1543,7 +1543,7 @@ 1AC35A9D18CECF0B00F37B72 /* KeyboardTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyboardTest.h; sourceTree = ""; }; 1AC35A9F18CECF0B00F37B72 /* KeypadTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeypadTest.cpp; sourceTree = ""; }; 1AC35AA018CECF0B00F37B72 /* KeypadTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeypadTest.h; sourceTree = ""; }; - 1AC35AA218CECF0C00F37B72 /* LabelTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LabelTest.cpp; sourceTree = ""; }; + 1AC35AA218CECF0C00F37B72 /* LabelTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = LabelTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AC35AA318CECF0C00F37B72 /* LabelTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelTest.h; sourceTree = ""; }; 1AC35AA418CECF0C00F37B72 /* LabelTestNew.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LabelTestNew.cpp; sourceTree = ""; }; 1AC35AA518CECF0C00F37B72 /* LabelTestNew.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelTestNew.h; sourceTree = ""; }; @@ -1553,13 +1553,13 @@ 1AC35AAB18CECF0C00F37B72 /* MenuTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuTest.h; sourceTree = ""; }; 1AC35AAD18CECF0C00F37B72 /* MotionStreakTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MotionStreakTest.cpp; sourceTree = ""; }; 1AC35AAE18CECF0C00F37B72 /* MotionStreakTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MotionStreakTest.h; sourceTree = ""; }; - 1AC35AB018CECF0C00F37B72 /* MutiTouchTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MutiTouchTest.cpp; sourceTree = ""; }; + 1AC35AB018CECF0C00F37B72 /* MutiTouchTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = MutiTouchTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AC35AB118CECF0C00F37B72 /* MutiTouchTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MutiTouchTest.h; sourceTree = ""; }; 1AC35AB318CECF0C00F37B72 /* NewEventDispatcherTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewEventDispatcherTest.cpp; sourceTree = ""; }; 1AC35AB418CECF0C00F37B72 /* NewEventDispatcherTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewEventDispatcherTest.h; sourceTree = ""; }; 1AC35AB618CECF0C00F37B72 /* NewRendererTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewRendererTest.cpp; sourceTree = ""; }; 1AC35AB718CECF0C00F37B72 /* NewRendererTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewRendererTest.h; sourceTree = ""; }; - 1AC35AB918CECF0C00F37B72 /* NodeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NodeTest.cpp; sourceTree = ""; }; + 1AC35AB918CECF0C00F37B72 /* NodeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = NodeTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AC35ABA18CECF0C00F37B72 /* NodeTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeTest.h; sourceTree = ""; }; 1AC35ABC18CECF0C00F37B72 /* ParallaxTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParallaxTest.cpp; sourceTree = ""; }; 1AC35ABD18CECF0C00F37B72 /* ParallaxTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParallaxTest.h; sourceTree = ""; }; @@ -1607,7 +1607,7 @@ 1AC35AF018CECF0C00F37B72 /* ShaderTest2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShaderTest2.h; sourceTree = ""; }; 1AC35AF218CECF0C00F37B72 /* SpineTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpineTest.cpp; sourceTree = ""; }; 1AC35AF318CECF0C00F37B72 /* SpineTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpineTest.h; sourceTree = ""; }; - 1AC35AF518CECF0C00F37B72 /* SpriteTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpriteTest.cpp; sourceTree = ""; }; + 1AC35AF518CECF0C00F37B72 /* SpriteTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = SpriteTest.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AC35AF618CECF0C00F37B72 /* SpriteTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpriteTest.h; sourceTree = ""; }; 1AC35AF718CECF0C00F37B72 /* testBasic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = testBasic.cpp; sourceTree = ""; }; 1AC35AF818CECF0C00F37B72 /* testBasic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testBasic.h; sourceTree = ""; }; diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index ed366910fe..808e25bcea 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -106,7 +106,7 @@ bool AtlasNode::initWithTexture(Texture2D* texture, int tileWidth, int tileHeigh _quadsToDraw = itemsToRender; // shader stuff - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); return true; } diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index a1687400fa..a27dd1b11d 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -45,7 +45,7 @@ static GLint s_layer = -1; static void setProgram(Node *n, GLProgram *p) { - n->setShaderProgram(p); + n->setGLProgram(p); auto& children = n->getChildren(); for(const auto &child : children) { diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index cce3539a07..c5cc3c3915 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -158,7 +158,7 @@ bool DrawNode::init() { _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR)); ensureCapacity(512); @@ -214,8 +214,9 @@ void DrawNode::draw(Renderer *renderer, const Matrix &transform, bool transformU void DrawNode::onDraw(const Matrix &transform, bool transformUpdated) { - getShaderProgram()->use(); - getShaderProgram()->setUniformsForBuiltins(transform); + auto glProgram = getGLProgram(); + glProgram->use(); + glProgram->setUniformsForBuiltins(transform); GL::blendFunc(_blendFunc.src, _blendFunc.dst); diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 0837ace14c..301f0275a5 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -342,21 +342,21 @@ void Label::updateShaderProgram() { case cocos2d::LabelEffect::NORMAL: if (_useDistanceField) - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL)); else if (_useA8Shader) - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_NORMAL)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_NORMAL)); else - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); break; case cocos2d::LabelEffect::OUTLINE: - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_OUTLINE)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_OUTLINE)); _uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "v_effectColor"); break; case cocos2d::LabelEffect::GLOW: if (_useDistanceField) { - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW)); _uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "v_effectColor"); } break; diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index cc6990c0e7..a1665577c6 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -534,7 +534,7 @@ bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h) updateColor(); setContentSize(Size(w, h)); - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP)); return true; } return false; @@ -602,8 +602,8 @@ void LayerColor::draw(Renderer *renderer, const Matrix &transform, bool transfor void LayerColor::onDraw(const Matrix& transform, bool transformUpdated) { - getShaderProgram()->use(); - getShaderProgram()->setUniformsForBuiltins(transform); + getGLProgram()->use(); + getGLProgram()->setUniformsForBuiltins(transform); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR ); // diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp index 0e163dfcba..50a3e9febc 100644 --- a/cocos/2d/CCMotionStreak.cpp +++ b/cocos/2d/CCMotionStreak.cpp @@ -128,7 +128,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; // shader program - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); setTexture(texture); setColor(color); @@ -375,8 +375,8 @@ void MotionStreak::reset() void MotionStreak::onDraw(const Matrix &transform, bool transformUpdated) { - getShaderProgram()->use(); - getShaderProgram()->setUniformsForBuiltins(transform); + getGLProgram()->use(); + getGLProgram()->setUniformsForBuiltins(transform); GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); GL::blendFunc( _blendFunc.src, _blendFunc.dst ); diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index dd74d3b33e..bdd736bf9b 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -101,7 +101,7 @@ bool ParticleBatchNode::initWithTexture(Texture2D *tex, int capacity) _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return true; } diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index ef17b8e1d2..cc5e604ac2 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -131,7 +131,7 @@ bool ParticleSystemQuad::initWithTotalParticles(int numberOfParticles) setupVBO(); } - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); #if CC_ENABLE_CACHE_TEXTURE_DATA // Need to listen the event only when not use batchnode, because it will use VBO diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp index fea8de6573..2e2163426b 100644 --- a/cocos/2d/CCProgressTimer.cpp +++ b/cocos/2d/CCProgressTimer.cpp @@ -86,7 +86,7 @@ bool ProgressTimer::initWithSprite(Sprite* sp) setBarChangeRate(Vector2(1,1)); setSprite(sp); // shader program - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return true; } @@ -502,8 +502,8 @@ Vector2 ProgressTimer::boundaryTexCoord(char index) void ProgressTimer::onDraw(const Matrix &transform, bool transformUpdated) { - getShaderProgram()->use(); - getShaderProgram()->setUniformsForBuiltins(transform); + getGLProgram()->use(); + getGLProgram()->setUniformsForBuiltins(transform); GL::blendFunc( _sprite->getBlendFunc().src, _sprite->getBlendFunc().dst ); diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 81dd180c99..3b797ba673 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -249,7 +249,7 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) _quad.tr.colors = Color4B::WHITE; // shader program - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); // update texture (calls updateBlendFunc) setTexture(texture); diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index c65d34b041..802169d66e 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -99,7 +99,7 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity) _descendants.reserve(capacity); - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return true; } diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp index b1cd6596b4..cfa675a54e 100644 --- a/cocos/2d/CCTMXLayer.cpp +++ b/cocos/2d/CCTMXLayer.cpp @@ -205,15 +205,15 @@ void TMXLayer::parseInternalProperties() _useAutomaticVertexZ = true; auto alphaFuncVal = getProperty("cc_alpha_func"); float alphaFuncValue = alphaFuncVal.asFloat(); - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST)); - GLint alphaValueLocation = glGetUniformLocation(getShaderProgram()->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); + GLint alphaValueLocation = glGetUniformLocation(getGLProgram()->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison // use shader program to set uniform - getShaderProgram()->use(); - getShaderProgram()->setUniformLocationWith1f(alphaValueLocation, alphaFuncValue); + getGLProgram()->use(); + getGLProgram()->setUniformLocationWith1f(alphaValueLocation, alphaFuncValue); CHECK_GL_ERROR_DEBUG(); } else diff --git a/cocos/2d/CCTexture2D.cpp b/cocos/2d/CCTexture2D.cpp index 562005d5f0..89da4a613b 100644 --- a/cocos/2d/CCTexture2D.cpp +++ b/cocos/2d/CCTexture2D.cpp @@ -506,12 +506,12 @@ void Texture2D::setMaxT(GLfloat maxT) _maxT = maxT; } -GLProgram* Texture2D::getShaderProgram() const +GLProgram* Texture2D::getGLProgram() const { return _shaderProgram; } -void Texture2D::setShaderProgram(GLProgram* shaderProgram) +void Texture2D::setGLProgram(GLProgram* shaderProgram) { CC_SAFE_RETAIN(shaderProgram); CC_SAFE_RELEASE(_shaderProgram); @@ -692,7 +692,7 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat _hasPremultipliedAlpha = false; _hasMipmaps = mipmapsNum > 1; - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE)); return true; } diff --git a/cocos/2d/CCTexture2D.h b/cocos/2d/CCTexture2D.h index ce06b9e1f0..f1239c9c29 100644 --- a/cocos/2d/CCTexture2D.h +++ b/cocos/2d/CCTexture2D.h @@ -350,8 +350,8 @@ public: Size getContentSize() const; - void setShaderProgram(GLProgram* program); - GLProgram* getShaderProgram() const; + void setGLProgram(GLProgram* program); + GLProgram* getGLProgram() const; public: static const PixelFormatInfoMap& getPixelFormatInfoMap(); diff --git a/cocos/base/ccMacros.h b/cocos/base/ccMacros.h index 422330266b..917f7329da 100644 --- a/cocos/base/ccMacros.h +++ b/cocos/base/ccMacros.h @@ -105,10 +105,10 @@ default gl blend src function. Compatible with premultiplied alpha images. */ #define CC_NODE_DRAW_SETUP() \ do { \ - CCASSERT(getShaderProgram(), "No shader program set for this node"); \ + CCASSERT(getGLProgram(), "No shader program set for this node"); \ { \ - getShaderProgram()->use(); \ - getShaderProgram()->setUniformsForBuiltins(_modelViewTransform); \ + getGLProgram()->use(); \ + getGLProgram()->setUniformsForBuiltins(_modelViewTransform); \ } \ } while(0) diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index c4bdf202e4..00aeed1aa8 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -182,7 +182,7 @@ bool Armature::init(const std::string& name) } - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); setCascadeOpacityEnabled(true); setCascadeColorEnabled(true); diff --git a/cocos/editor-support/cocostudio/CCBatchNode.cpp b/cocos/editor-support/cocostudio/CCBatchNode.cpp index 6b39bce761..006a9b50eb 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.cpp +++ b/cocos/editor-support/cocostudio/CCBatchNode.cpp @@ -61,7 +61,7 @@ BatchNode::~BatchNode() bool BatchNode::init() { bool ret = Node::init(); - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return ret; } diff --git a/cocos/editor-support/spine/CCSkeleton.cpp b/cocos/editor-support/spine/CCSkeleton.cpp index de6209ad22..c74a4d4192 100644 --- a/cocos/editor-support/spine/CCSkeleton.cpp +++ b/cocos/editor-support/spine/CCSkeleton.cpp @@ -69,7 +69,7 @@ void Skeleton::initialize () { setOpacityModifyRGB(true); - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } void Skeleton::setSkeletonData (spSkeletonData *skeletonData, bool isOwnsSkeletonData) { @@ -135,8 +135,8 @@ void Skeleton::draw(cocos2d::Renderer *renderer, const Matrix &transform, bool t void Skeleton::onDraw(const Matrix &transform, bool transformUpdated) { - getShaderProgram()->use(); - getShaderProgram()->setUniformsForBuiltins(transform); + getGLProgram()->use(); + getGLProgram()->setUniformsForBuiltins(transform); GL::blendFunc(blendFunc.src, blendFunc.dst); Color3B color = getColor(); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 0100483d75..e91326b67d 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -2468,7 +2468,7 @@ int lua_cocos2dx_Texture2D_getShaderProgram(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::GLProgram* ret = cobj->getShaderProgram(); + cocos2d::GLProgram* ret = cobj->getGLProgram(); object_to_luaval(tolua_S, "cc.GLProgram",(cocos2d::GLProgram*)ret); return 1; } @@ -2629,7 +2629,7 @@ int lua_cocos2dx_Texture2D_initWithImage(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Texture2D_setShaderProgram(lua_State* tolua_S) +int lua_cocos2dx_Texture2D_setGLProgram(lua_State* tolua_S) { int argc = 0; cocos2d::Texture2D* cobj = nullptr; @@ -2662,7 +2662,7 @@ int lua_cocos2dx_Texture2D_setShaderProgram(lua_State* tolua_S) ok &= luaval_to_object(tolua_S, 2, "cc.GLProgram",&arg0); if(!ok) return 0; - cobj->setShaderProgram(arg0); + cobj->setGLProgram(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setShaderProgram",argc, 1); @@ -5082,7 +5082,7 @@ int lua_cocos2dx_Node_getShaderProgram(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; do{ if (argc == 0) { - const cocos2d::GLProgram* ret = cobj->getShaderProgram(); + const cocos2d::GLProgram* ret = cobj->getGLProgram(); object_to_luaval(tolua_S, "cc.GLProgram",(cocos2d::GLProgram*)ret); return 1; } @@ -5090,7 +5090,7 @@ int lua_cocos2dx_Node_getShaderProgram(lua_State* tolua_S) ok = true; do{ if (argc == 0) { - cocos2d::GLProgram* ret = cobj->getShaderProgram(); + cocos2d::GLProgram* ret = cobj->getGLProgram(); object_to_luaval(tolua_S, "cc.GLProgram",(cocos2d::GLProgram*)ret); return 1; } @@ -7534,7 +7534,7 @@ int lua_cocos2dx_Node_addComponent(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Node_setShaderProgram(lua_State* tolua_S) +int lua_cocos2dx_Node_setGLProgram(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; @@ -7567,7 +7567,7 @@ int lua_cocos2dx_Node_setShaderProgram(lua_State* tolua_S) ok &= luaval_to_object(tolua_S, 2, "cc.GLProgram",&arg0); if(!ok) return 0; - cobj->setShaderProgram(arg0); + cobj->setGLProgram(arg0); return 0; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setShaderProgram",argc, 1); diff --git a/cocos/scripting/lua-bindings/manual/LuaOpengl.cpp b/cocos/scripting/lua-bindings/manual/LuaOpengl.cpp index c5303c3fd6..91cb42cd38 100644 --- a/cocos/scripting/lua-bindings/manual/LuaOpengl.cpp +++ b/cocos/scripting/lua-bindings/manual/LuaOpengl.cpp @@ -137,7 +137,7 @@ static int tolua_Cocos2d_GLNode_setShaderProgram00(lua_State* tolua_S) if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setShaderProgram'", NULL); #endif if(NULL != self) - self->setShaderProgram(pShaderProgram); + self->setGLProgram(pShaderProgram); } return 0; #ifndef TOLUA_RELEASE diff --git a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj index 92750fe0e5..90a9e92d9f 100644 --- a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj @@ -217,7 +217,7 @@ 1A262AB718BEEF5900D2DB92 /* tolua_fix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tolua_fix.cpp; sourceTree = ""; }; 1AACE74618BC45A000215002 /* libluabindings Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libluabindings Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 1AACE74718BC45A000215002 /* libluabindings iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libluabindings iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AACE74918BC45C200215002 /* lua_cocos2dx_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_auto.cpp; sourceTree = ""; }; + 1AACE74918BC45C200215002 /* lua_cocos2dx_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = lua_cocos2dx_auto.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AACE74A18BC45C200215002 /* lua_cocos2dx_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_auto.hpp; sourceTree = ""; }; 1AACE74C18BC45C200215002 /* lua_cocos2dx_extension_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_extension_auto.cpp; sourceTree = ""; }; 1AACE74D18BC45C200215002 /* lua_cocos2dx_extension_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_extension_auto.hpp; sourceTree = ""; }; @@ -259,7 +259,7 @@ 1AACE77D18BC45C200215002 /* lua_xml_http_request.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_xml_http_request.h; sourceTree = ""; }; 1AACE77E18BC45C200215002 /* LuaBasicConversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaBasicConversions.cpp; sourceTree = ""; }; 1AACE77F18BC45C200215002 /* LuaBasicConversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaBasicConversions.h; sourceTree = ""; }; - 1AACE78018BC45C200215002 /* LuaOpengl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaOpengl.cpp; sourceTree = ""; }; + 1AACE78018BC45C200215002 /* LuaOpengl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = LuaOpengl.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1AACE78118BC45C200215002 /* LuaOpengl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaOpengl.h; sourceTree = ""; }; 1AACE78218BC45C200215002 /* LuaScriptHandlerMgr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaScriptHandlerMgr.cpp; sourceTree = ""; }; 1AACE78318BC45C200215002 /* LuaScriptHandlerMgr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaScriptHandlerMgr.h; sourceTree = ""; }; diff --git a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp index a0e09f2e05..bbbec220e8 100644 --- a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -751,7 +751,7 @@ void RawStencilBufferTestAlphaTest::setup() auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); for(int i = 0; i < _planeCount; ++i) { - _spritesStencil.at(i)->setShaderProgram(program ); + _spritesStencil.at(i)->setGLProgram(program ); } } //@implementation RawStencilBufferTest4 diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 0e523849ab..2117dd580d 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -185,7 +185,7 @@ void ArmatureTestLayer::onEnter() addChild(menu, 100); - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } void ArmatureTestLayer::onExit() @@ -1116,8 +1116,8 @@ void TestBoundingBox::draw(Renderer *renderer, const Matrix &transform, bool tra void TestBoundingBox::onDraw(const Matrix &transform, bool transformUpdated) { - getShaderProgram()->use(); - getShaderProgram()->setUniformsForBuiltins(transform); + getGLProgram()->use(); + getGLProgram()->setUniformsForBuiltins(transform); rect = armature->getBoundingBox(); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index 53a0d0697b..2858031670 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -150,7 +150,7 @@ void SceneEditorTestLayer::onEnter() addChild(menu, 100); - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } void SceneEditorTestLayer::onExit() diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp index 6bfaeb05a2..9bbd29753f 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp @@ -169,7 +169,7 @@ void AtlasDemo::backCallback(Ref* sender) //------------------------------------------------------------------ Atlas1::Atlas1() { - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE)); _textureAtlas = TextureAtlas::create(s_AtlasTest, 3); _textureAtlas->retain(); auto s = Director::getInstance()->getWinSize(); @@ -222,8 +222,8 @@ void Atlas1::draw(Renderer *renderer, const Matrix &transform, bool transformUpd void Atlas1::onDraw(const Matrix &transform, bool transformUpdated) { - getShaderProgram()->use(); - getShaderProgram()->setUniformsForBuiltins(transform); + getGLProgram()->use(); + getGLProgram()->setUniformsForBuiltins(transform); _textureAtlas->drawQuads(); } diff --git a/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp b/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp index 13072dfb19..c8b6b7b94f 100644 --- a/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp +++ b/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp @@ -14,7 +14,7 @@ class TouchPoint : public Node public: TouchPoint() { - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index 970aff65ce..6fe19b6d7a 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -990,7 +990,7 @@ public: sprite->autorelease(); auto shader = CCShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR); - sprite->setShaderProgram(shader); + sprite->setGLProgram(shader); return sprite; } virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; @@ -1010,8 +1010,8 @@ void MySprite::draw(Renderer *renderer, const Matrix &transform, bool transformU void MySprite::onDraw(const Matrix &transform, bool transformUpdated) { - getShaderProgram()->use(); - getShaderProgram()->setUniformsForBuiltins(transform); + getGLProgram()->use(); + getGLProgram()->setUniformsForBuiltins(transform); GL::blendFunc( _blendFunc.src, _blendFunc.dst ); diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index e670230614..6d3155ad8d 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -131,7 +131,7 @@ bool ShaderNode::initWithVertex(const char *vert, const char *frag) { #if CC_ENABLE_CACHE_TEXTURE_DATA auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ - this->setShaderProgram(nullptr); + this->setGLProgram(nullptr); loadShaderVertex(_vertFileName.c_str(), _fragFileName.c_str()); }); @@ -450,7 +450,7 @@ bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect) { #if CC_ENABLE_CACHE_TEXTURE_DATA auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ - setShaderProgram(nullptr); + setGLProgram(nullptr); initProgram(); }); diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 4910076219..69af1af718 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -166,7 +166,7 @@ void ShaderSprite::setBackgroundNotification() { #if CC_ENABLE_CACHE_TEXTURE_DATA auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ - this->setShaderProgram(nullptr); + this->setGLProgram(nullptr); this->initShader(); }); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); diff --git a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp index 0c9520c8a9..9623232d40 100644 --- a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp +++ b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp @@ -950,9 +950,9 @@ SpriteZVertex::SpriteZVertex() // set alpha test value // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison - if (getShaderProgram()) + if (getGLProgram()) { - getShaderProgram()->setUniformLocationWith1f(alphaValueLocation, 0.0f); + getGLProgram()->setUniformLocationWith1f(alphaValueLocation, 0.0f); } @@ -975,7 +975,7 @@ SpriteZVertex::SpriteZVertex() auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*0, 121*1, 85, 121)); sprite->setPosition( Vector2((i+1)*step, s.height/2) ); sprite->setPositionZ( 10 + i*40 ); - sprite->setShaderProgram(alphaTestShader); + sprite->setGLProgram(alphaTestShader); node->addChild(sprite, 0); } @@ -985,7 +985,7 @@ SpriteZVertex::SpriteZVertex() auto sprite = Sprite::create("Images/grossini_dance_atlas.png", Rect(85*1, 121*0, 85, 121)); sprite->setPosition( Vector2( (i+1)*step, s.height/2) ); sprite->setPositionZ( 10 + (10-i)*40 ); - sprite->setShaderProgram(alphaTestShader); + sprite->setGLProgram(alphaTestShader); node->addChild(sprite, 0); } @@ -1040,9 +1040,9 @@ SpriteBatchNodeZVertex::SpriteBatchNodeZVertex() // set alpha test value // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison - if (getShaderProgram()) + if (getGLProgram()) { - getShaderProgram()->setUniformLocationWith1f(alphaValueLocation, 0.0f); + getGLProgram()->setUniformLocationWith1f(alphaValueLocation, 0.0f); } auto s = Director::getInstance()->getWinSize(); @@ -1056,7 +1056,7 @@ SpriteBatchNodeZVertex::SpriteBatchNodeZVertex() batch->setAnchorPoint( Vector2::ANCHOR_MIDDLE); batch->setPosition( Vector2(s.width/2, s.height/2)); - batch->setShaderProgram(alphaTestShader); + batch->setGLProgram(alphaTestShader); addChild(batch, 0, kTagSpriteBatchNode); for(int i=0;i<5;i++) diff --git a/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua b/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua index ec37d20617..53235537f0 100644 --- a/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua +++ b/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua @@ -164,7 +164,7 @@ local function OpenGLTestMainLayer() label = cc.Label:createWithBMFont("fonts/west_england-64.fnt", "RETRO EFFECT") label:setAnchorPoint(cc.p(0.5, 0.5)) - label:setShaderProgram( program ) + label:setGLProgram( program ) label:setPosition(size.width/2, size.height/2) RetroEffectlayer:addChild(label) @@ -195,7 +195,7 @@ local function OpenGLTestMainLayer() glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") - glNode:setShaderProgram(shader) + glNode:setGLProgram(shader) local function initBuffer() squareVertexPositionBuffer = gl.createBuffer() @@ -258,7 +258,7 @@ local function OpenGLTestMainLayer() glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") - glNode:setShaderProgram(shader) + glNode:setGLProgram(shader) local function initBuffer() squareVertexPositionBuffer.buffer_id = gl.createBuffer() @@ -320,7 +320,7 @@ local function OpenGLTestMainLayer() glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") - glNode:setShaderProgram(shader) + glNode:setGLProgram(shader) local function initBuffer() squareVertexPositionBuffer.buffer_id = gl.createBuffer() @@ -382,7 +382,7 @@ local function OpenGLTestMainLayer() glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") - glNode:setShaderProgram(shader) + glNode:setGLProgram(shader) local function initBuffer() squareVertexPositionBuffer.buffer_id = gl.createBuffer() @@ -444,7 +444,7 @@ local function OpenGLTestMainLayer() glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") - glNode:setShaderProgram(shader) + glNode:setGLProgram(shader) local function initBuffer() squareVertexPositionBuffer.buffer_id = gl.createBuffer() @@ -506,7 +506,7 @@ local function OpenGLTestMainLayer() glNode:setAnchorPoint(cc.p(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") - glNode:setShaderProgram(shader) + glNode:setGLProgram(shader) local function initBuffer() squareVertexPositionBuffer.buffer_id = gl.createBuffer() @@ -558,7 +558,7 @@ local function OpenGLTestMainLayer() local function getCurrentResult() local var = {} - local glProgam = sprite:getShaderProgram() + local glProgam = sprite:getGLProgram() if nil ~= glProgam then local p = glProgam:getProgram() local aaSize,aaType,aaName = gl.getActiveAttrib(p,0) From 1d5bfb5a10d5ece04d06c173a338cb29d27d92b8 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 8 May 2014 16:45:08 -0700 Subject: [PATCH 025/174] roll back _yCoordFlipped changes --- cocos/2d/CCParticleSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/2d/CCParticleSystem.cpp b/cocos/2d/CCParticleSystem.cpp index 8dc9e3ff02..170350cc32 100644 --- a/cocos/2d/CCParticleSystem.cpp +++ b/cocos/2d/CCParticleSystem.cpp @@ -726,7 +726,7 @@ void ParticleSystem::update(float dt) tmp = radial + tangential + modeA.gravity; tmp = tmp * dt; p->modeA.dir = p->modeA.dir + tmp; - if (_configName.length()>0 && _yCoordFlipped == -1) + if (_configName.length()>0 && _yCoordFlipped != -1) { tmp = p->modeA.dir * -dt; } From 62d9c24518c6fb9436bc70d13202969c78d64d39 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 8 May 2014 18:01:48 -0700 Subject: [PATCH 026/174] moves shaders files from 2d/ to renderer/ --- build/cocos2d_libs.xcodeproj/project.pbxproj | 400 +++++++++--------- cocos/2d/CCAtlasNode.cpp | 6 +- cocos/2d/CCClippingNode.cpp | 4 +- cocos/2d/CCDrawNode.cpp | 2 +- cocos/2d/CCDrawingPrimitives.cpp | 6 +- cocos/2d/CCGrid.cpp | 6 +- cocos/2d/CCLabel.cpp | 2 +- cocos/2d/CCLabelAtlas.cpp | 6 +- cocos/2d/CCLayer.cpp | 6 +- cocos/2d/CCMotionStreak.cpp | 6 +- cocos/2d/CCNode.cpp | 4 +- cocos/2d/CCNode.h | 10 +- cocos/2d/CCParticleBatchNode.cpp | 6 +- cocos/2d/CCParticleSystemQuad.cpp | 6 +- cocos/2d/CCProgressTimer.cpp | 6 +- cocos/2d/CCRenderTexture.cpp | 4 +- cocos/2d/CCSprite.cpp | 6 +- cocos/2d/CCSpriteBatchNode.cpp | 6 +- cocos/2d/CCTMXLayer.cpp | 4 +- cocos/2d/CCTexture2D.cpp | 6 +- cocos/2d/CCTextureAtlas.cpp | 4 +- cocos/base/CCDirector.cpp | 4 +- cocos/cocos2d.h | 11 +- .../editor-support/cocostudio/CCArmature.cpp | 2 +- .../editor-support/cocostudio/CCBatchNode.cpp | 2 +- cocos/renderer/CCBatchCommand.cpp | 2 +- cocos/renderer/CCBatchCommand.h | 2 +- cocos/{2d => renderer}/CCGLProgram.cpp | 4 +- cocos/{2d => renderer}/CCGLProgram.h | 0 cocos/{2d => renderer}/CCGLProgramState.cpp | 76 +++- cocos/{2d => renderer}/CCGLProgramState.h | 27 +- cocos/renderer/CCQuadCommand.cpp | 2 +- cocos/renderer/CCQuadCommand.h | 2 +- cocos/renderer/CCRenderer.cpp | 4 +- cocos/renderer/CCRenderer.h | 2 +- cocos/{2d => renderer}/CCShaderCache.cpp | 6 +- cocos/{2d => renderer}/CCShaderCache.h | 0 cocos/{2d => renderer}/ccGLStateCache.cpp | 4 +- cocos/{2d => renderer}/ccGLStateCache.h | 0 .../{2d => renderer}/ccShader_Label_frag_df.h | 0 .../ccShader_Label_frag_df_glow.h | 0 .../ccShader_Label_frag_normal.h | 0 .../ccShader_Label_frag_outline.h | 0 cocos/{2d => renderer}/ccShader_Label_vert.h | 0 ...ccShader_PositionColorLengthTexture_frag.h | 0 ...ccShader_PositionColorLengthTexture_vert.h | 0 .../ccShader_PositionColor_frag.h | 0 .../ccShader_PositionColor_vert.h | 0 .../ccShader_PositionTextureA8Color_frag.h | 0 .../ccShader_PositionTextureA8Color_vert.h | 0 ...hader_PositionTextureColorAlphaTest_frag.h | 0 .../ccShader_PositionTextureColor_frag.h | 0 ...ccShader_PositionTextureColor_noMVP_frag.h | 0 ...ccShader_PositionTextureColor_noMVP_vert.h | 0 .../ccShader_PositionTextureColor_vert.h | 0 .../ccShader_PositionTexture_frag.h | 0 .../ccShader_PositionTexture_uColor_frag.h | 0 .../ccShader_PositionTexture_uColor_vert.h | 0 .../ccShader_PositionTexture_vert.h | 0 .../ccShader_Position_uColor_frag.h | 0 .../ccShader_Position_uColor_vert.h | 0 cocos/{2d => renderer}/ccShaders.cpp | 2 +- cocos/{2d => renderer}/ccShaders.h | 0 cocos/ui/UILayout.cpp | 4 +- .../CCControlExtension/CCControlSwitch.cpp | 2 +- .../Classes/ShaderTest/ShaderTest.cpp | 8 +- .../cpp-tests/Classes/ShaderTest/ShaderTest.h | 2 - .../Classes/ShaderTest/ShaderTest2.cpp | 25 +- 68 files changed, 378 insertions(+), 321 deletions(-) rename cocos/{2d => renderer}/CCGLProgram.cpp (99%) rename cocos/{2d => renderer}/CCGLProgram.h (100%) rename cocos/{2d => renderer}/CCGLProgramState.cpp (79%) rename cocos/{2d => renderer}/CCGLProgramState.h (81%) rename cocos/{2d => renderer}/CCShaderCache.cpp (99%) rename cocos/{2d => renderer}/CCShaderCache.h (100%) rename cocos/{2d => renderer}/ccGLStateCache.cpp (98%) rename cocos/{2d => renderer}/ccGLStateCache.h (100%) rename cocos/{2d => renderer}/ccShader_Label_frag_df.h (100%) rename cocos/{2d => renderer}/ccShader_Label_frag_df_glow.h (100%) rename cocos/{2d => renderer}/ccShader_Label_frag_normal.h (100%) rename cocos/{2d => renderer}/ccShader_Label_frag_outline.h (100%) rename cocos/{2d => renderer}/ccShader_Label_vert.h (100%) rename cocos/{2d => renderer}/ccShader_PositionColorLengthTexture_frag.h (100%) rename cocos/{2d => renderer}/ccShader_PositionColorLengthTexture_vert.h (100%) rename cocos/{2d => renderer}/ccShader_PositionColor_frag.h (100%) rename cocos/{2d => renderer}/ccShader_PositionColor_vert.h (100%) rename cocos/{2d => renderer}/ccShader_PositionTextureA8Color_frag.h (100%) rename cocos/{2d => renderer}/ccShader_PositionTextureA8Color_vert.h (100%) rename cocos/{2d => renderer}/ccShader_PositionTextureColorAlphaTest_frag.h (100%) rename cocos/{2d => renderer}/ccShader_PositionTextureColor_frag.h (100%) rename cocos/{2d => renderer}/ccShader_PositionTextureColor_noMVP_frag.h (100%) rename cocos/{2d => renderer}/ccShader_PositionTextureColor_noMVP_vert.h (100%) rename cocos/{2d => renderer}/ccShader_PositionTextureColor_vert.h (100%) rename cocos/{2d => renderer}/ccShader_PositionTexture_frag.h (100%) rename cocos/{2d => renderer}/ccShader_PositionTexture_uColor_frag.h (100%) rename cocos/{2d => renderer}/ccShader_PositionTexture_uColor_vert.h (100%) rename cocos/{2d => renderer}/ccShader_PositionTexture_vert.h (100%) rename cocos/{2d => renderer}/ccShader_Position_uColor_frag.h (100%) rename cocos/{2d => renderer}/ccShader_Position_uColor_vert.h (100%) rename cocos/{2d => renderer}/ccShaders.cpp (99%) rename cocos/{2d => renderer}/ccShaders.h (100%) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 0f145ae4d2..496a2b75d0 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -278,44 +278,6 @@ 1A570235180BCC4D0088DEC7 /* CCScriptSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570232180BCC4D0088DEC7 /* CCScriptSupport.cpp */; }; 1A570236180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570233180BCC4D0088DEC7 /* CCScriptSupport.h */; }; 1A570237180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570233180BCC4D0088DEC7 /* CCScriptSupport.h */; }; - 1A57024D180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570239180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h */; }; - 1A57024E180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570239180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h */; }; - 1A57024F180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023A180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h */; }; - 1A570250180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023A180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h */; }; - 1A570251180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023B180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h */; }; - 1A570252180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023B180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h */; }; - 1A570253180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023C180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h */; }; - 1A570254180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023C180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h */; }; - 1A570255180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023D180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h */; }; - 1A570256180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023D180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h */; }; - 1A570257180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023E180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h */; }; - 1A570258180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023E180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h */; }; - 1A570259180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023F180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h */; }; - 1A57025A180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023F180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h */; }; - 1A57025B180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570240180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h */; }; - 1A57025C180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570240180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h */; }; - 1A57025D180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570241180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h */; }; - 1A57025E180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570241180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h */; }; - 1A57025F180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570242180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h */; }; - 1A570260180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570242180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h */; }; - 1A570261180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570243180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h */; }; - 1A570262180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570243180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h */; }; - 1A570263180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570244180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h */; }; - 1A570264180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570244180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h */; }; - 1A570265180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570245180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h */; }; - 1A570266180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570245180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h */; }; - 1A570267180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570246180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h */; }; - 1A570268180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570246180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h */; }; - 1A570269180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570247180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h */; }; - 1A57026A180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570247180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h */; }; - 1A57026B180BCC6F0088DEC7 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570248180BCC6F0088DEC7 /* CCShaderCache.cpp */; }; - 1A57026C180BCC6F0088DEC7 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570248180BCC6F0088DEC7 /* CCShaderCache.cpp */; }; - 1A57026D180BCC6F0088DEC7 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570249180BCC6F0088DEC7 /* CCShaderCache.h */; }; - 1A57026E180BCC6F0088DEC7 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570249180BCC6F0088DEC7 /* CCShaderCache.h */; }; - 1A570271180BCC6F0088DEC7 /* ccShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57024B180BCC6F0088DEC7 /* ccShaders.cpp */; }; - 1A570272180BCC6F0088DEC7 /* ccShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57024B180BCC6F0088DEC7 /* ccShaders.cpp */; }; - 1A570273180BCC6F0088DEC7 /* ccShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57024C180BCC6F0088DEC7 /* ccShaders.h */; }; - 1A570274180BCC6F0088DEC7 /* ccShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57024C180BCC6F0088DEC7 /* ccShaders.h */; }; 1A57027E180BCC900088DEC7 /* CCSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570276180BCC900088DEC7 /* CCSprite.cpp */; }; 1A57027F180BCC900088DEC7 /* CCSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570276180BCC900088DEC7 /* CCSprite.cpp */; }; 1A570280180BCC900088DEC7 /* CCSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570277180BCC900088DEC7 /* CCSprite.h */; }; @@ -449,14 +411,6 @@ 1A5703BB180BD2800088DEC7 /* libwebp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A5703BA180BD2800088DEC7 /* libwebp.a */; }; 1A57052B180BD31F0088DEC7 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A57052A180BD31F0088DEC7 /* libfreetype.a */; }; 1A57052E180BD3280088DEC7 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A57052D180BD3280088DEC7 /* libfreetype.a */; }; - 1A570533180BD9500088DEC7 /* CCGLProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */; }; - 1A570534180BD9500088DEC7 /* CCGLProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */; }; - 1A570535180BD9500088DEC7 /* CCGLProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570530180BD9500088DEC7 /* CCGLProgram.h */; }; - 1A570536180BD9500088DEC7 /* CCGLProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570530180BD9500088DEC7 /* CCGLProgram.h */; }; - 1A570537180BD9500088DEC7 /* ccGLStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */; }; - 1A570538180BD9500088DEC7 /* ccGLStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */; }; - 1A570539180BD9500088DEC7 /* ccGLStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570532180BD9500088DEC7 /* ccGLStateCache.h */; }; - 1A57053A180BD9500088DEC7 /* ccGLStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570532180BD9500088DEC7 /* ccGLStateCache.h */; }; 1A8C598B180E930E00EF57C3 /* CCActionFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5948180E930E00EF57C3 /* CCActionFrame.cpp */; }; 1A8C598C180E930E00EF57C3 /* CCActionFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5948180E930E00EF57C3 /* CCActionFrame.cpp */; }; 1A8C598D180E930E00EF57C3 /* CCActionFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5949180E930E00EF57C3 /* CCActionFrame.h */; }; @@ -596,16 +550,6 @@ 1A9DCA2E180E6955007A3AD4 /* CCProtocols.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA05180E6955007A3AD4 /* CCProtocols.h */; }; 1A9DCA3B180E6955007A3AD4 /* firePngData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA0C180E6955007A3AD4 /* firePngData.h */; }; 1A9DCA3C180E6955007A3AD4 /* firePngData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA0C180E6955007A3AD4 /* firePngData.h */; }; - 1AA95FDE18EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FD918EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h */; }; - 1AA95FDF18EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FD918EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h */; }; - 1AA95FE018EBB8EF00AE7485 /* ccShader_Label_frag_df.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDA18EBB8EF00AE7485 /* ccShader_Label_frag_df.h */; }; - 1AA95FE118EBB8EF00AE7485 /* ccShader_Label_frag_df.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDA18EBB8EF00AE7485 /* ccShader_Label_frag_df.h */; }; - 1AA95FE218EBB8EF00AE7485 /* ccShader_Label_frag_normal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDB18EBB8EF00AE7485 /* ccShader_Label_frag_normal.h */; }; - 1AA95FE318EBB8EF00AE7485 /* ccShader_Label_frag_normal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDB18EBB8EF00AE7485 /* ccShader_Label_frag_normal.h */; }; - 1AA95FE418EBB8EF00AE7485 /* ccShader_Label_frag_outline.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDC18EBB8EF00AE7485 /* ccShader_Label_frag_outline.h */; }; - 1AA95FE518EBB8EF00AE7485 /* ccShader_Label_frag_outline.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDC18EBB8EF00AE7485 /* ccShader_Label_frag_outline.h */; }; - 1AA95FE618EBB8EF00AE7485 /* ccShader_Label_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDD18EBB8EF00AE7485 /* ccShader_Label_vert.h */; }; - 1AA95FE718EBB8EF00AE7485 /* ccShader_Label_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDD18EBB8EF00AE7485 /* ccShader_Label_vert.h */; }; 1AAF528B180E2ECC000584C8 /* b2BroadPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168B61807AF9C005B8026 /* b2BroadPhase.cpp */; }; 1AAF528C180E2ECC000584C8 /* b2BroadPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168B71807AF9C005B8026 /* b2BroadPhase.h */; }; 1AAF528D180E2ECC000584C8 /* b2CollideCircle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168B81807AF9C005B8026 /* b2CollideCircle.cpp */; }; @@ -1610,14 +1554,74 @@ 500DC9BD19106E89007B91BF /* CCProfiling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9BA19106E89007B91BF /* CCProfiling.cpp */; }; 500DC9BE19106E89007B91BF /* CCProfiling.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9BB19106E89007B91BF /* CCProfiling.h */; }; 500DC9BF19106E89007B91BF /* CCProfiling.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9BB19106E89007B91BF /* CCProfiling.h */; }; - 500DC9E9191BF301007B91BF /* CCGLProgramState.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9E3191BF301007B91BF /* CCGLProgramState.h */; }; - 500DC9EA191BF301007B91BF /* CCGLProgramState.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9E3191BF301007B91BF /* CCGLProgramState.h */; }; - 500DC9EB191BF301007B91BF /* CCGLProgramState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9E4191BF301007B91BF /* CCGLProgramState.cpp */; }; - 500DC9EC191BF301007B91BF /* CCGLProgramState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9E4191BF301007B91BF /* CCGLProgramState.cpp */; }; 5027253A190BF1B900AAF4ED /* cocos2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 50272538190BF1B900AAF4ED /* cocos2d.h */; }; 5027253B190BF1B900AAF4ED /* cocos2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 50272538190BF1B900AAF4ED /* cocos2d.h */; }; 5027253C190BF1B900AAF4ED /* cocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50272539190BF1B900AAF4ED /* cocos2d.cpp */; }; 5027253D190BF1B900AAF4ED /* cocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50272539190BF1B900AAF4ED /* cocos2d.cpp */; }; + 5034C9B3191C5D4500CE6051 /* ccShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C993191C5D4500CE6051 /* ccShaders.h */; }; + 5034C9B4191C5D4500CE6051 /* ccShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C993191C5D4500CE6051 /* ccShaders.h */; }; + 5034C9B5191C5D4500CE6051 /* ccShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C994191C5D4500CE6051 /* ccShaders.cpp */; }; + 5034C9B6191C5D4500CE6051 /* ccShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C994191C5D4500CE6051 /* ccShaders.cpp */; }; + 5034C9B7191C5D4500CE6051 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C995191C5D4500CE6051 /* CCShaderCache.h */; }; + 5034C9B8191C5D4500CE6051 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C995191C5D4500CE6051 /* CCShaderCache.h */; }; + 5034C9B9191C5D4500CE6051 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C996191C5D4500CE6051 /* CCShaderCache.cpp */; }; + 5034C9BA191C5D4500CE6051 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C996191C5D4500CE6051 /* CCShaderCache.cpp */; }; + 5034C9BB191C5D4500CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C997191C5D4500CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h */; }; + 5034C9BC191C5D4500CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C997191C5D4500CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h */; }; + 5034C9BD191C5D4500CE6051 /* ccShader_PositionTextureColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C998191C5D4500CE6051 /* ccShader_PositionTextureColor_vert.h */; }; + 5034C9BE191C5D4500CE6051 /* ccShader_PositionTextureColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C998191C5D4500CE6051 /* ccShader_PositionTextureColor_vert.h */; }; + 5034C9BF191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C999191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h */; }; + 5034C9C0191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C999191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h */; }; + 5034C9C1191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C99A191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h */; }; + 5034C9C2191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C99A191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h */; }; + 5034C9C3191C5D4500CE6051 /* ccShader_PositionTextureColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C99B191C5D4500CE6051 /* ccShader_PositionTextureColor_frag.h */; }; + 5034C9C4191C5D4500CE6051 /* ccShader_PositionTextureColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C99B191C5D4500CE6051 /* ccShader_PositionTextureColor_frag.h */; }; + 5034C9C5191C5D4500CE6051 /* ccShader_PositionTextureA8Color_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C99C191C5D4500CE6051 /* ccShader_PositionTextureA8Color_vert.h */; }; + 5034C9C6191C5D4500CE6051 /* ccShader_PositionTextureA8Color_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C99C191C5D4500CE6051 /* ccShader_PositionTextureA8Color_vert.h */; }; + 5034C9C7191C5D4500CE6051 /* ccShader_PositionTextureA8Color_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C99D191C5D4500CE6051 /* ccShader_PositionTextureA8Color_frag.h */; }; + 5034C9C8191C5D4500CE6051 /* ccShader_PositionTextureA8Color_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C99D191C5D4500CE6051 /* ccShader_PositionTextureA8Color_frag.h */; }; + 5034C9C9191C5D4500CE6051 /* ccShader_PositionTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C99E191C5D4500CE6051 /* ccShader_PositionTexture_vert.h */; }; + 5034C9CA191C5D4500CE6051 /* ccShader_PositionTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C99E191C5D4500CE6051 /* ccShader_PositionTexture_vert.h */; }; + 5034C9CB191C5D4500CE6051 /* ccShader_PositionTexture_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C99F191C5D4500CE6051 /* ccShader_PositionTexture_uColor_vert.h */; }; + 5034C9CC191C5D4500CE6051 /* ccShader_PositionTexture_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C99F191C5D4500CE6051 /* ccShader_PositionTexture_uColor_vert.h */; }; + 5034C9CD191C5D4500CE6051 /* ccShader_PositionTexture_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A0191C5D4500CE6051 /* ccShader_PositionTexture_uColor_frag.h */; }; + 5034C9CE191C5D4500CE6051 /* ccShader_PositionTexture_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A0191C5D4500CE6051 /* ccShader_PositionTexture_uColor_frag.h */; }; + 5034C9CF191C5D4500CE6051 /* ccShader_PositionTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A1191C5D4500CE6051 /* ccShader_PositionTexture_frag.h */; }; + 5034C9D0191C5D4500CE6051 /* ccShader_PositionTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A1191C5D4500CE6051 /* ccShader_PositionTexture_frag.h */; }; + 5034C9D1191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A2191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_vert.h */; }; + 5034C9D2191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A2191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_vert.h */; }; + 5034C9D3191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A3191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_frag.h */; }; + 5034C9D4191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A3191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_frag.h */; }; + 5034C9D5191C5D4500CE6051 /* ccShader_PositionColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A4191C5D4500CE6051 /* ccShader_PositionColor_vert.h */; }; + 5034C9D6191C5D4500CE6051 /* ccShader_PositionColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A4191C5D4500CE6051 /* ccShader_PositionColor_vert.h */; }; + 5034C9D7191C5D4500CE6051 /* ccShader_PositionColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A5191C5D4500CE6051 /* ccShader_PositionColor_frag.h */; }; + 5034C9D8191C5D4500CE6051 /* ccShader_PositionColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A5191C5D4500CE6051 /* ccShader_PositionColor_frag.h */; }; + 5034C9D9191C5D4500CE6051 /* ccShader_Position_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A6191C5D4500CE6051 /* ccShader_Position_uColor_vert.h */; }; + 5034C9DA191C5D4500CE6051 /* ccShader_Position_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A6191C5D4500CE6051 /* ccShader_Position_uColor_vert.h */; }; + 5034C9DB191C5D4500CE6051 /* ccShader_Position_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A7191C5D4500CE6051 /* ccShader_Position_uColor_frag.h */; }; + 5034C9DC191C5D4500CE6051 /* ccShader_Position_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A7191C5D4500CE6051 /* ccShader_Position_uColor_frag.h */; }; + 5034C9DD191C5D4500CE6051 /* ccShader_Label_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A8191C5D4500CE6051 /* ccShader_Label_vert.h */; }; + 5034C9DE191C5D4500CE6051 /* ccShader_Label_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A8191C5D4500CE6051 /* ccShader_Label_vert.h */; }; + 5034C9DF191C5D4500CE6051 /* ccShader_Label_frag_outline.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A9191C5D4500CE6051 /* ccShader_Label_frag_outline.h */; }; + 5034C9E0191C5D4500CE6051 /* ccShader_Label_frag_outline.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9A9191C5D4500CE6051 /* ccShader_Label_frag_outline.h */; }; + 5034C9E1191C5D4500CE6051 /* ccShader_Label_frag_normal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9AA191C5D4500CE6051 /* ccShader_Label_frag_normal.h */; }; + 5034C9E2191C5D4500CE6051 /* ccShader_Label_frag_normal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9AA191C5D4500CE6051 /* ccShader_Label_frag_normal.h */; }; + 5034C9E3191C5D4500CE6051 /* ccShader_Label_frag_df.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9AB191C5D4500CE6051 /* ccShader_Label_frag_df.h */; }; + 5034C9E4191C5D4500CE6051 /* ccShader_Label_frag_df.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9AB191C5D4500CE6051 /* ccShader_Label_frag_df.h */; }; + 5034C9E5191C5D4500CE6051 /* ccShader_Label_frag_df_glow.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9AC191C5D4500CE6051 /* ccShader_Label_frag_df_glow.h */; }; + 5034C9E6191C5D4500CE6051 /* ccShader_Label_frag_df_glow.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9AC191C5D4500CE6051 /* ccShader_Label_frag_df_glow.h */; }; + 5034C9E7191C5D4500CE6051 /* ccGLStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9AD191C5D4500CE6051 /* ccGLStateCache.h */; }; + 5034C9E8191C5D4500CE6051 /* ccGLStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9AD191C5D4500CE6051 /* ccGLStateCache.h */; }; + 5034C9E9191C5D4500CE6051 /* ccGLStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9AE191C5D4500CE6051 /* ccGLStateCache.cpp */; }; + 5034C9EA191C5D4500CE6051 /* ccGLStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9AE191C5D4500CE6051 /* ccGLStateCache.cpp */; }; + 5034C9EB191C5D4500CE6051 /* CCGLProgramState.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9AF191C5D4500CE6051 /* CCGLProgramState.h */; }; + 5034C9EC191C5D4500CE6051 /* CCGLProgramState.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9AF191C5D4500CE6051 /* CCGLProgramState.h */; }; + 5034C9ED191C5D4500CE6051 /* CCGLProgramState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9B0191C5D4500CE6051 /* CCGLProgramState.cpp */; }; + 5034C9EE191C5D4500CE6051 /* CCGLProgramState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9B0191C5D4500CE6051 /* CCGLProgramState.cpp */; }; + 5034C9EF191C5D4500CE6051 /* CCGLProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9B1191C5D4500CE6051 /* CCGLProgram.h */; }; + 5034C9F0191C5D4500CE6051 /* CCGLProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9B1191C5D4500CE6051 /* CCGLProgram.h */; }; + 5034C9F1191C5D4500CE6051 /* CCGLProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9B2191C5D4500CE6051 /* CCGLProgram.cpp */; }; + 5034C9F2191C5D4500CE6051 /* CCGLProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9B2191C5D4500CE6051 /* CCGLProgram.cpp */; }; 50E6D30E18DADB5D0051CA34 /* CCProtectedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E6D30C18DADB5D0051CA34 /* CCProtectedNode.cpp */; }; 50E6D30F18DADB5D0051CA34 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 50E6D30D18DADB5D0051CA34 /* CCProtectedNode.h */; }; 50E6D31018DAF01A0051CA34 /* CCProtectedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E6D30C18DADB5D0051CA34 /* CCProtectedNode.cpp */; }; @@ -1692,10 +1696,6 @@ 50FCEBCA18C72017004AD434 /* WidgetReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 50FCEB9118C72017004AD434 /* WidgetReader.h */; }; 50FCEBCB18C72017004AD434 /* WidgetReaderProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 50FCEB9218C72017004AD434 /* WidgetReaderProtocol.h */; }; 50FCEBCC18C72017004AD434 /* WidgetReaderProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 50FCEB9218C72017004AD434 /* WidgetReaderProtocol.h */; }; - A023FA34185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = A023FA32185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h */; }; - A023FA35185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = A023FA32185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h */; }; - A023FA36185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = A023FA33185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h */; }; - A023FA37185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = A023FA33185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h */; }; A04583F2189053B500E32FE8 /* CCGLView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A04583F0189053B500E32FE8 /* CCGLView.cpp */; }; A04583F3189053B500E32FE8 /* CCGLView.h in Headers */ = {isa = PBXBuildFile; fileRef = A04583F1189053B500E32FE8 /* CCGLView.h */; }; A07A4CAF1783777C0073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A342158F2AB200E66CFE /* Foundation.framework */; }; @@ -1968,25 +1968,6 @@ 1A570220180BCC1A0088DEC7 /* CCParticleSystemQuad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleSystemQuad.h; sourceTree = ""; }; 1A570232180BCC4D0088DEC7 /* CCScriptSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScriptSupport.cpp; sourceTree = ""; }; 1A570233180BCC4D0088DEC7 /* CCScriptSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScriptSupport.h; sourceTree = ""; }; - 1A570239180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Position_uColor_frag.h; sourceTree = ""; }; - 1A57023A180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Position_uColor_vert.h; sourceTree = ""; }; - 1A57023B180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColor_frag.h; sourceTree = ""; }; - 1A57023C180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColor_vert.h; sourceTree = ""; }; - 1A57023D180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColorLengthTexture_frag.h; sourceTree = ""; }; - 1A57023E180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColorLengthTexture_vert.h; sourceTree = ""; }; - 1A57023F180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_frag.h; sourceTree = ""; }; - 1A570240180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_uColor_frag.h; sourceTree = ""; }; - 1A570241180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_uColor_vert.h; sourceTree = ""; }; - 1A570242180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_vert.h; sourceTree = ""; }; - 1A570243180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureA8Color_frag.h; sourceTree = ""; }; - 1A570244180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureA8Color_vert.h; sourceTree = ""; }; - 1A570245180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_frag.h; sourceTree = ""; }; - 1A570246180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_vert.h; sourceTree = ""; }; - 1A570247180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColorAlphaTest_frag.h; sourceTree = ""; }; - 1A570248180BCC6F0088DEC7 /* CCShaderCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCShaderCache.cpp; sourceTree = ""; }; - 1A570249180BCC6F0088DEC7 /* CCShaderCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCShaderCache.h; sourceTree = ""; }; - 1A57024B180BCC6F0088DEC7 /* ccShaders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccShaders.cpp; sourceTree = ""; }; - 1A57024C180BCC6F0088DEC7 /* ccShaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShaders.h; sourceTree = ""; }; 1A570276180BCC900088DEC7 /* CCSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCSprite.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A570277180BCC900088DEC7 /* CCSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSprite.h; sourceTree = ""; }; 1A570278180BCC900088DEC7 /* CCSpriteBatchNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCSpriteBatchNode.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; @@ -2059,10 +2040,6 @@ 1A5703BA180BD2800088DEC7 /* libwebp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwebp.a; sourceTree = ""; }; 1A57052A180BD31F0088DEC7 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfreetype.a; sourceTree = ""; }; 1A57052D180BD3280088DEC7 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfreetype.a; sourceTree = ""; }; - 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgram.cpp; sourceTree = ""; }; - 1A570530180BD9500088DEC7 /* CCGLProgram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgram.h; sourceTree = ""; }; - 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccGLStateCache.cpp; sourceTree = ""; }; - 1A570532180BD9500088DEC7 /* ccGLStateCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccGLStateCache.h; sourceTree = ""; }; 1A57FFF7180BC5160088DEC7 /* CHANGELOG */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; lineEnding = 0; name = CHANGELOG; path = ../CHANGELOG; sourceTree = ""; }; 1A8C5948180E930E00EF57C3 /* CCActionFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionFrame.cpp; sourceTree = ""; }; 1A8C5949180E930E00EF57C3 /* CCActionFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionFrame.h; sourceTree = ""; }; @@ -2133,11 +2110,6 @@ 1A9DCA03180E6955007A3AD4 /* CCGLBufferedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLBufferedNode.h; sourceTree = ""; }; 1A9DCA05180E6955007A3AD4 /* CCProtocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProtocols.h; sourceTree = ""; }; 1A9DCA0C180E6955007A3AD4 /* firePngData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = firePngData.h; sourceTree = ""; }; - 1AA95FD918EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_df_glow.h; sourceTree = ""; }; - 1AA95FDA18EBB8EF00AE7485 /* ccShader_Label_frag_df.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_df.h; sourceTree = ""; }; - 1AA95FDB18EBB8EF00AE7485 /* ccShader_Label_frag_normal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_normal.h; sourceTree = ""; }; - 1AA95FDC18EBB8EF00AE7485 /* ccShader_Label_frag_outline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_outline.h; sourceTree = ""; }; - 1AA95FDD18EBB8EF00AE7485 /* ccShader_Label_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_vert.h; sourceTree = ""; }; 1AAF5351180E3060000584C8 /* AssetsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AssetsManager.cpp; sourceTree = ""; }; 1AAF5352180E3060000584C8 /* AssetsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AssetsManager.h; sourceTree = ""; }; 1AAF5362180E3374000584C8 /* HttpClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HttpClient.cpp; sourceTree = ""; }; @@ -2696,10 +2668,40 @@ 500DC9B519106E6D007B91BF /* TransformUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransformUtils.h; sourceTree = ""; }; 500DC9BA19106E89007B91BF /* CCProfiling.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCProfiling.cpp; path = ../base/CCProfiling.cpp; sourceTree = ""; }; 500DC9BB19106E89007B91BF /* CCProfiling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCProfiling.h; path = ../base/CCProfiling.h; sourceTree = ""; }; - 500DC9E3191BF301007B91BF /* CCGLProgramState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgramState.h; sourceTree = ""; }; - 500DC9E4191BF301007B91BF /* CCGLProgramState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgramState.cpp; sourceTree = ""; }; 50272538190BF1B900AAF4ED /* cocos2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cocos2d.h; path = ../cocos/cocos2d.h; sourceTree = ""; }; 50272539190BF1B900AAF4ED /* cocos2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cocos2d.cpp; path = ../cocos/cocos2d.cpp; sourceTree = ""; }; + 5034C993191C5D4500CE6051 /* ccShaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShaders.h; sourceTree = ""; }; + 5034C994191C5D4500CE6051 /* ccShaders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccShaders.cpp; sourceTree = ""; }; + 5034C995191C5D4500CE6051 /* CCShaderCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCShaderCache.h; sourceTree = ""; }; + 5034C996191C5D4500CE6051 /* CCShaderCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCShaderCache.cpp; sourceTree = ""; }; + 5034C997191C5D4500CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColorAlphaTest_frag.h; sourceTree = ""; }; + 5034C998191C5D4500CE6051 /* ccShader_PositionTextureColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_vert.h; sourceTree = ""; }; + 5034C999191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_noMVP_vert.h; sourceTree = ""; }; + 5034C99A191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_noMVP_frag.h; sourceTree = ""; }; + 5034C99B191C5D4500CE6051 /* ccShader_PositionTextureColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_frag.h; sourceTree = ""; }; + 5034C99C191C5D4500CE6051 /* ccShader_PositionTextureA8Color_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureA8Color_vert.h; sourceTree = ""; }; + 5034C99D191C5D4500CE6051 /* ccShader_PositionTextureA8Color_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureA8Color_frag.h; sourceTree = ""; }; + 5034C99E191C5D4500CE6051 /* ccShader_PositionTexture_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_vert.h; sourceTree = ""; }; + 5034C99F191C5D4500CE6051 /* ccShader_PositionTexture_uColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_uColor_vert.h; sourceTree = ""; }; + 5034C9A0191C5D4500CE6051 /* ccShader_PositionTexture_uColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_uColor_frag.h; sourceTree = ""; }; + 5034C9A1191C5D4500CE6051 /* ccShader_PositionTexture_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_frag.h; sourceTree = ""; }; + 5034C9A2191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColorLengthTexture_vert.h; sourceTree = ""; }; + 5034C9A3191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColorLengthTexture_frag.h; sourceTree = ""; }; + 5034C9A4191C5D4500CE6051 /* ccShader_PositionColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColor_vert.h; sourceTree = ""; }; + 5034C9A5191C5D4500CE6051 /* ccShader_PositionColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColor_frag.h; sourceTree = ""; }; + 5034C9A6191C5D4500CE6051 /* ccShader_Position_uColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Position_uColor_vert.h; sourceTree = ""; }; + 5034C9A7191C5D4500CE6051 /* ccShader_Position_uColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Position_uColor_frag.h; sourceTree = ""; }; + 5034C9A8191C5D4500CE6051 /* ccShader_Label_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_vert.h; sourceTree = ""; }; + 5034C9A9191C5D4500CE6051 /* ccShader_Label_frag_outline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_outline.h; sourceTree = ""; }; + 5034C9AA191C5D4500CE6051 /* ccShader_Label_frag_normal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_normal.h; sourceTree = ""; }; + 5034C9AB191C5D4500CE6051 /* ccShader_Label_frag_df.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_df.h; sourceTree = ""; }; + 5034C9AC191C5D4500CE6051 /* ccShader_Label_frag_df_glow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_df_glow.h; sourceTree = ""; }; + 5034C9AD191C5D4500CE6051 /* ccGLStateCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccGLStateCache.h; sourceTree = ""; }; + 5034C9AE191C5D4500CE6051 /* ccGLStateCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccGLStateCache.cpp; sourceTree = ""; }; + 5034C9AF191C5D4500CE6051 /* CCGLProgramState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgramState.h; sourceTree = ""; }; + 5034C9B0191C5D4500CE6051 /* CCGLProgramState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgramState.cpp; sourceTree = ""; }; + 5034C9B1191C5D4500CE6051 /* CCGLProgram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgram.h; sourceTree = ""; }; + 5034C9B2191C5D4500CE6051 /* CCGLProgram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgram.cpp; sourceTree = ""; }; 50DC5180187B817900A9C23F /* RELEASE_NOTES.md */ = {isa = PBXFileReference; lastKnownFileType = text; name = RELEASE_NOTES.md; path = ../docs/RELEASE_NOTES.md; sourceTree = ""; }; 50E6D30C18DADB5D0051CA34 /* CCProtectedNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCProtectedNode.cpp; sourceTree = ""; }; 50E6D30D18DADB5D0051CA34 /* CCProtectedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProtectedNode.h; sourceTree = ""; }; @@ -2770,8 +2772,6 @@ A0053FBE189B2BEA0035A564 /* CCPlatformDefine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCPlatformDefine.h; sourceTree = ""; }; A0053FBF189B2BEA0035A564 /* CCStdC.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCStdC.cpp; sourceTree = ""; }; A0053FC0189B2BEA0035A564 /* CCStdC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCStdC.h; sourceTree = ""; }; - A023FA32185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_noMVP_frag.h; sourceTree = ""; }; - A023FA33185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_noMVP_vert.h; sourceTree = ""; }; A03F2CB81780BD04006731B9 /* libchipmunk Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libchipmunk Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A03F2D9B1780BDF7006731B9 /* libbox2d Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libbox2d Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A03F2ED617814268006731B9 /* libCocosDenshion Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libCocosDenshion Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -3249,45 +3249,6 @@ name = "script-support"; sourceTree = ""; }; - 1A570238180BCC580088DEC7 /* shaders */ = { - isa = PBXGroup; - children = ( - 500DC9E3191BF301007B91BF /* CCGLProgramState.h */, - 500DC9E4191BF301007B91BF /* CCGLProgramState.cpp */, - 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */, - 1A570530180BD9500088DEC7 /* CCGLProgram.h */, - 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */, - 1A570532180BD9500088DEC7 /* ccGLStateCache.h */, - 1AA95FDA18EBB8EF00AE7485 /* ccShader_Label_frag_df.h */, - 1AA95FD918EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h */, - 1AA95FDB18EBB8EF00AE7485 /* ccShader_Label_frag_normal.h */, - 1AA95FDC18EBB8EF00AE7485 /* ccShader_Label_frag_outline.h */, - 1AA95FDD18EBB8EF00AE7485 /* ccShader_Label_vert.h */, - 1A570239180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h */, - 1A57023A180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h */, - 1A57023B180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h */, - 1A57023C180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h */, - 1A57023D180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h */, - 1A57023E180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h */, - 1A57023F180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h */, - 1A570240180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h */, - 1A570241180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h */, - 1A570242180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h */, - 1A570243180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h */, - 1A570244180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h */, - 1A570245180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h */, - A023FA32185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h */, - A023FA33185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h */, - 1A570246180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h */, - 1A570247180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h */, - 1A570248180BCC6F0088DEC7 /* CCShaderCache.cpp */, - 1A570249180BCC6F0088DEC7 /* CCShaderCache.h */, - 1A57024B180BCC6F0088DEC7 /* ccShaders.cpp */, - 1A57024C180BCC6F0088DEC7 /* ccShaders.h */, - ); - name = shaders; - sourceTree = ""; - }; 1A570275180BCC840088DEC7 /* sprite-nodes */ = { isa = PBXGroup; children = ( @@ -4475,7 +4436,6 @@ 1A570218180BCC000088DEC7 /* particle-nodes */, 46A16A5A1807B038005B8026 /* platform */, 1A570231180BCC380088DEC7 /* script-support */, - 1A570238180BCC580088DEC7 /* shaders */, 1A570275180BCC840088DEC7 /* sprite-nodes */, 1A57029A180BCD4F0088DEC7 /* support */, 1A5702BC180BCE0A0088DEC7 /* text-input-node */, @@ -4649,6 +4609,17 @@ 500DC89819105D41007B91BF /* renderer */ = { isa = PBXGroup; children = ( + 5034C9F4191C5D6800CE6051 /* Shaders */, + 5034C993191C5D4500CE6051 /* ccShaders.h */, + 5034C994191C5D4500CE6051 /* ccShaders.cpp */, + 5034C995191C5D4500CE6051 /* CCShaderCache.h */, + 5034C996191C5D4500CE6051 /* CCShaderCache.cpp */, + 5034C9AD191C5D4500CE6051 /* ccGLStateCache.h */, + 5034C9AE191C5D4500CE6051 /* ccGLStateCache.cpp */, + 5034C9AF191C5D4500CE6051 /* CCGLProgramState.h */, + 5034C9B0191C5D4500CE6051 /* CCGLProgramState.cpp */, + 5034C9B1191C5D4500CE6051 /* CCGLProgram.h */, + 5034C9B2191C5D4500CE6051 /* CCGLProgram.cpp */, 500DC89919105D41007B91BF /* CCBatchCommand.cpp */, 500DC89A19105D41007B91BF /* CCBatchCommand.h */, 500DC89B19105D41007B91BF /* CCCustomCommand.cpp */, @@ -4667,6 +4638,35 @@ path = ../cocos/renderer; sourceTree = ""; }; + 5034C9F4191C5D6800CE6051 /* Shaders */ = { + isa = PBXGroup; + children = ( + 5034C997191C5D4500CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h */, + 5034C998191C5D4500CE6051 /* ccShader_PositionTextureColor_vert.h */, + 5034C999191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h */, + 5034C99A191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h */, + 5034C99B191C5D4500CE6051 /* ccShader_PositionTextureColor_frag.h */, + 5034C99C191C5D4500CE6051 /* ccShader_PositionTextureA8Color_vert.h */, + 5034C99D191C5D4500CE6051 /* ccShader_PositionTextureA8Color_frag.h */, + 5034C99E191C5D4500CE6051 /* ccShader_PositionTexture_vert.h */, + 5034C99F191C5D4500CE6051 /* ccShader_PositionTexture_uColor_vert.h */, + 5034C9A0191C5D4500CE6051 /* ccShader_PositionTexture_uColor_frag.h */, + 5034C9A1191C5D4500CE6051 /* ccShader_PositionTexture_frag.h */, + 5034C9A2191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_vert.h */, + 5034C9A3191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_frag.h */, + 5034C9A4191C5D4500CE6051 /* ccShader_PositionColor_vert.h */, + 5034C9A5191C5D4500CE6051 /* ccShader_PositionColor_frag.h */, + 5034C9A6191C5D4500CE6051 /* ccShader_Position_uColor_vert.h */, + 5034C9A7191C5D4500CE6051 /* ccShader_Position_uColor_frag.h */, + 5034C9A8191C5D4500CE6051 /* ccShader_Label_vert.h */, + 5034C9A9191C5D4500CE6051 /* ccShader_Label_frag_outline.h */, + 5034C9AA191C5D4500CE6051 /* ccShader_Label_frag_normal.h */, + 5034C9AB191C5D4500CE6051 /* ccShader_Label_frag_df.h */, + 5034C9AC191C5D4500CE6051 /* ccShader_Label_frag_df_glow.h */, + ); + name = Shaders; + sourceTree = ""; + }; 50FCEB6818C72017004AD434 /* WidgetReader */ = { isa = PBXGroup; children = ( @@ -4914,9 +4914,11 @@ 06CAAAC9186AD7EE0012A414 /* TriggerMng.h in Headers */, 2905FA6018CF08D100240AA3 /* UILayoutParameter.h in Headers */, 1ABA68B01888D700007D1BB4 /* CCFontCharMap.h in Headers */, + 5034C9D3191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_frag.h in Headers */, 500DC8B419105D41007B91BF /* CCGroupCommand.h in Headers */, 500DC8D319105F7D007B91BF /* CCAffineTransform.h in Headers */, 46A170191807CBFC005B8026 /* CCCommon.h in Headers */, + 5034C9D7191C5D4500CE6051 /* ccShader_PositionColor_frag.h in Headers */, 46A170E71807CECA005B8026 /* CCPhysicsBody.h in Headers */, 2905FA4818CF08D100240AA3 /* UIButton.h in Headers */, 46A170EB1807CECA005B8026 /* CCPhysicsJoint.h in Headers */, @@ -4926,18 +4928,22 @@ 46A170161807CBFC005B8026 /* CCLock.h in Headers */, 46A1701C1807CBFC005B8026 /* CCGLViewProtocol.h in Headers */, 46A1701E1807CBFC005B8026 /* CCFileUtils.h in Headers */, + 5034C9E7191C5D4500CE6051 /* ccGLStateCache.h in Headers */, 2905FA4418CF08D100240AA3 /* GUIDefine.h in Headers */, B37510771823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */, 46A1705B1807CC1C005B8026 /* CCPlatformDefine.h in Headers */, 46A170EE1807CECA005B8026 /* CCPhysicsShape.h in Headers */, + 5034C9E5191C5D4500CE6051 /* ccShader_Label_frag_df_glow.h in Headers */, 2905FA5018CF08D100240AA3 /* UIHelper.h in Headers */, 46A170261807CBFC005B8026 /* CCThread.h in Headers */, + 5034C9DD191C5D4500CE6051 /* ccShader_Label_vert.h in Headers */, 46A170E91807CECA005B8026 /* CCPhysicsContact.h in Headers */, B375107B1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */, 2905FA6818CF08D100240AA3 /* UILoadingBar.h in Headers */, 500DC99A19106300007B91BF /* ccTypes.h in Headers */, 46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */, 500DC8C219105D41007B91BF /* CCRenderCommandPool.h in Headers */, + 5034C9EB191C5D4500CE6051 /* CCGLProgramState.h in Headers */, 46A1705C1807CC1C005B8026 /* CCStdC.h in Headers */, 46A1704F1807CC1C005B8026 /* CCApplication.h in Headers */, 500DC98C19106300007B91BF /* CCPlatformMacros.h in Headers */, @@ -4949,9 +4955,10 @@ 1A57006B180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */, 1A57006F180BC5A10088DEC7 /* CCActionEase.h in Headers */, 1A570073180BC5A10088DEC7 /* CCActionGrid.h in Headers */, + 5034C9C5191C5D4500CE6051 /* ccShader_PositionTextureA8Color_vert.h in Headers */, + 5034C9EF191C5D4500CE6051 /* CCGLProgram.h in Headers */, 50FCEBB518C72017004AD434 /* SliderReader.h in Headers */, 06CAAAD1186AD8010012A414 /* ObjectFactory.h in Headers */, - A023FA34185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */, 1A570077180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */, 1A57007B180BC5A10088DEC7 /* CCActionInstant.h in Headers */, 500DC8BC19105D41007B91BF /* CCQuadCommand.h in Headers */, @@ -4959,7 +4966,7 @@ 1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */, 1A01C69A18F57BE800EFE3A6 /* CCSet.h in Headers */, 296CAD2A1915EC9900C64FBF /* CCEventListenerFocus.h in Headers */, - A023FA36185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, + 5034C9C3191C5D4500CE6051 /* ccShader_PositionTextureColor_frag.h in Headers */, 1A570083180BC5A10088DEC7 /* CCActionManager.h in Headers */, 1A570087180BC5A10088DEC7 /* CCActionPageTurn3D.h in Headers */, ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */, @@ -4976,12 +4983,14 @@ 46C02E0918E91123004B7456 /* xxhash.h in Headers */, B2AF2FA318EBAEAE00C5807C /* Vector2.h in Headers */, 06CAAAC6186AD7E60012A414 /* TriggerObj.h in Headers */, + 5034C9CD191C5D4500CE6051 /* ccShader_PositionTexture_uColor_frag.h in Headers */, 500DC8B019105D41007B91BF /* CCCustomCommand.h in Headers */, 500DC8AC19105D41007B91BF /* CCBatchCommand.h in Headers */, A04583F3189053B500E32FE8 /* CCGLView.h in Headers */, B2AF2FA718EBAEAE00C5807C /* Vector3.h in Headers */, 1A570110180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */, 500DC8D719105F7D007B91BF /* CCGeometry.h in Headers */, + 5034C9E3191C5D4500CE6051 /* ccShader_Label_frag_df.h in Headers */, 500DC96619106300007B91BF /* CCEventListenerAcceleration.h in Headers */, B37510791823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */, 1A570114180BC8EE0088DEC7 /* CCDrawNode.h in Headers */, @@ -4992,6 +5001,7 @@ 500DC8C619105D41007B91BF /* CCRenderer.h in Headers */, 50E6D30F18DADB5D0051CA34 /* CCProtectedNode.h in Headers */, 500DC9BE19106E89007B91BF /* CCProfiling.h in Headers */, + 5034C9D5191C5D4500CE6051 /* ccShader_PositionColor_vert.h in Headers */, 50FCEB9918C72017004AD434 /* CheckBoxReader.h in Headers */, 50E6D33E18E174130051CA34 /* UIVBox.h in Headers */, 500DC9AC19106300007B91BF /* ZipUtils.h in Headers */, @@ -5007,8 +5017,8 @@ 1A5701C3180BCB5A0088DEC7 /* CCLabelBMFont.h in Headers */, 500DC93A19106300007B91BF /* CCConfiguration.h in Headers */, 1A5701C9180BCB5A0088DEC7 /* CCLabelTextFormatter.h in Headers */, - 1AA95FE618EBB8EF00AE7485 /* ccShader_Label_vert.h in Headers */, 1A5701CD180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */, + 5034C9C9191C5D4500CE6051 /* ccShader_PositionTexture_vert.h in Headers */, 1A5701E0180BCB8C0088DEC7 /* CCLayer.h in Headers */, 1A5701E4180BCB8C0088DEC7 /* CCScene.h in Headers */, 1A01C68818F57BE800EFE3A6 /* CCBool.h in Headers */, @@ -5017,13 +5027,13 @@ 2905FA4C18CF08D100240AA3 /* UICheckBox.h in Headers */, 1A5701EC180BCB8C0088DEC7 /* CCTransitionPageTurn.h in Headers */, 1A5701F0180BCB8C0088DEC7 /* CCTransitionProgress.h in Headers */, + 5034C9CB191C5D4500CE6051 /* ccShader_PositionTexture_uColor_vert.h in Headers */, 1A5701F9180BCBAD0088DEC7 /* CCMenu.h in Headers */, 1A5701FD180BCBAD0088DEC7 /* CCMenuItem.h in Headers */, 1A570204180BCBD40088DEC7 /* CCClippingNode.h in Headers */, 1A01C6A618F58F7500EFE3A6 /* CCNotificationCenter.h in Headers */, 1A57020A180BCBDF0088DEC7 /* CCMotionStreak.h in Headers */, 1A570212180BCBF40088DEC7 /* CCProgressTimer.h in Headers */, - 500DC9E9191BF301007B91BF /* CCGLProgramState.h in Headers */, 1A570216180BCBF40088DEC7 /* CCRenderTexture.h in Headers */, 500DC95219106300007B91BF /* CCEventAcceleration.h in Headers */, 500DC99E19106300007B91BF /* CCValue.h in Headers */, @@ -5035,34 +5045,15 @@ 500DC96A19106300007B91BF /* CCEventListenerCustom.h in Headers */, B2AF2F9718EBAEAE00C5807C /* MathUtil.h in Headers */, 1A570236180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */, - 1A57024D180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */, - 1A57024F180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */, - 1AA95FE418EBB8EF00AE7485 /* ccShader_Label_frag_outline.h in Headers */, 500DC95E19106300007B91BF /* CCEventKeyboard.h in Headers */, 2905FA4218CF08D100240AA3 /* CocosGUI.h in Headers */, - 1A570251180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h in Headers */, 500DC95A19106300007B91BF /* CCEventDispatcher.h in Headers */, - 1A570253180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h in Headers */, - 1A570255180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h in Headers */, - 1A570257180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h in Headers */, - 1A570259180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */, - 1A57025B180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */, 500DC9A019106300007B91BF /* CCVector.h in Headers */, - 1A57025D180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */, - 1A57025F180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */, 500DC92C19106300007B91BF /* atitc.h in Headers */, 1A01C68C18F57BE800EFE3A6 /* CCDeprecated.h in Headers */, - 1A570261180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h in Headers */, 500DC98419106300007B91BF /* CCMap.h in Headers */, - 1A570263180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h in Headers */, - 1AA95FDE18EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h in Headers */, 2905FA6418CF08D100240AA3 /* UIListView.h in Headers */, - 1A570265180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h in Headers */, 50FCEBB918C72017004AD434 /* TextAtlasReader.h in Headers */, - 1A570267180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h in Headers */, - 1A570269180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */, - 1A57026D180BCC6F0088DEC7 /* CCShaderCache.h in Headers */, - 1A570273180BCC6F0088DEC7 /* ccShaders.h in Headers */, 1A570280180BCC900088DEC7 /* CCSprite.h in Headers */, 1A570284180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */, 500DC9A419106300007B91BF /* etc1.h in Headers */, @@ -5082,8 +5073,10 @@ 1A5702C4180BCE2A0088DEC7 /* CCIMEDispatcher.h in Headers */, 1A12775B18DFCC540005F345 /* CCTweenFunction.h in Headers */, 1A5702CA180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */, + 5034C9C7191C5D4500CE6051 /* ccShader_PositionTextureA8Color_frag.h in Headers */, 1A5702D5180BCE570088DEC7 /* CCTexture2D.h in Headers */, 1A5702D9180BCE570088DEC7 /* CCTextureAtlas.h in Headers */, + 5034C9BD191C5D4500CE6051 /* ccShader_PositionTextureColor_vert.h in Headers */, 1A5702DD180BCE570088DEC7 /* CCTextureCache.h in Headers */, 1A5702EC180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */, 1A5702F0180BCE750088DEC7 /* CCTMXLayer.h in Headers */, @@ -5096,11 +5089,13 @@ 1A570312180BCF190088DEC7 /* CCComponentContainer.h in Headers */, 50FCEBC918C72017004AD434 /* WidgetReader.h in Headers */, B37510751823AC9F00B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */, + 5034C9BF191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, 500DC94619106300007B91BF /* CCDataVisitor.h in Headers */, B2AF2FAB18EBAEAE00C5807C /* Vector4.h in Headers */, 1A57031B180BCF430088DEC7 /* ccCArray.h in Headers */, 1A57031D180BCF430088DEC7 /* uthash.h in Headers */, 1A57031F180BCF430088DEC7 /* utlist.h in Headers */, + 5034C9CF191C5D4500CE6051 /* ccShader_PositionTexture_frag.h in Headers */, 1A01C69418F57BE800EFE3A6 /* CCFloat.h in Headers */, 1A570326180BCF660088DEC7 /* TGAlib.h in Headers */, 1A570331180BCFD50088DEC7 /* CCUserDefault.h in Headers */, @@ -5111,16 +5106,14 @@ 500DC99619106300007B91BF /* CCScheduler.h in Headers */, 1A57035A180BD0B00088DEC7 /* unzip.h in Headers */, 296CAD241915EC8000C64FBF /* CCEventFocus.h in Headers */, - 1A570535180BD9500088DEC7 /* CCGLProgram.h in Headers */, - 1AA95FE018EBB8EF00AE7485 /* ccShader_Label_frag_df.h in Headers */, 500DC98819106300007B91BF /* CCNS.h in Headers */, - 1A570539180BD9500088DEC7 /* ccGLStateCache.h in Headers */, 1AD71DAB180E26E600808F54 /* CCBAnimationManager.h in Headers */, 1AD71DAF180E26E600808F54 /* CCBFileLoader.h in Headers */, B37510741823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */, 2905FA8E18CF08D100240AA3 /* UIWidget.h in Headers */, 1AD71DB3180E26E600808F54 /* CCBKeyframe.h in Headers */, 1AD71DB5180E26E600808F54 /* CCBMemberVariableAssigner.h in Headers */, + 5034C9B3191C5D4500CE6051 /* ccShaders.h in Headers */, 1AD71DB9180E26E600808F54 /* CCBReader.h in Headers */, 2905FA7E18CF08D100240AA3 /* UIText.h in Headers */, 1AD71DBB180E26E600808F54 /* CCBSelectorResolver.h in Headers */, @@ -5142,12 +5135,14 @@ 2905FA5C18CF08D100240AA3 /* UILayoutDefine.h in Headers */, 2905FA7218CF08D100240AA3 /* UIScrollInterface.h in Headers */, B2AF2F9B18EBAEAE00C5807C /* Matrix.h in Headers */, + 5034C9D1191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_vert.h in Headers */, 1AD71DF5180E26E600808F54 /* CCNodeLoader.h in Headers */, 1AD71DF9180E26E600808F54 /* CCNodeLoaderLibrary.h in Headers */, 2905FA8A18CF08D100240AA3 /* UITextField.h in Headers */, 1AD71DFB180E26E600808F54 /* CCNodeLoaderListener.h in Headers */, 1AD71DFF180E26E600808F54 /* CCParticleSystemQuadLoader.h in Headers */, 1AD71E03180E26E600808F54 /* CCScale9SpriteLoader.h in Headers */, + 5034C9DB191C5D4500CE6051 /* ccShader_Position_uColor_frag.h in Headers */, 1AD71E07180E26E600808F54 /* CCScrollViewLoader.h in Headers */, 1AD71E0B180E26E600808F54 /* CCSpriteLoader.h in Headers */, 1AD71E0D180E26E600808F54 /* CocosBuilder.h in Headers */, @@ -5160,6 +5155,7 @@ 1AD71EAB180E26E600808F54 /* Attachment.h in Headers */, 500DC97E19106300007B91BF /* CCEventTouch.h in Headers */, 50FCEBC118C72017004AD434 /* TextFieldReader.h in Headers */, + 5034C9D9191C5D4500CE6051 /* ccShader_Position_uColor_vert.h in Headers */, 1AD71EAF180E26E600808F54 /* AttachmentLoader.h in Headers */, 1AD71EB3180E26E600808F54 /* Bone.h in Headers */, 2905FA8218CF08D100240AA3 /* UITextAtlas.h in Headers */, @@ -5167,6 +5163,7 @@ 500DC99219106300007B91BF /* CCRefPtr.h in Headers */, 1AD71EBB180E26E600808F54 /* CCSkeleton.h in Headers */, 500DC97619106300007B91BF /* CCEventListenerTouch.h in Headers */, + 5034C9C1191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */, 50FCEBA118C72017004AD434 /* LayoutReader.h in Headers */, 1AD71EBF180E26E600808F54 /* CCSkeletonAnimation.h in Headers */, 2905FA7018CF08D100240AA3 /* UIRichText.h in Headers */, @@ -5193,7 +5190,9 @@ 500DC99019106300007B91BF /* CCRef.h in Headers */, 1AAF5370180E3374000584C8 /* HttpResponse.h in Headers */, 1AAF5374180E3374000584C8 /* SocketIO.h in Headers */, + 5034C9DF191C5D4500CE6051 /* ccShader_Label_frag_outline.h in Headers */, 373B9129187891F400198F86 /* CCComBase.h in Headers */, + 5034C9BB191C5D4500CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */, 1AAF5378180E3374000584C8 /* WebSocket.h in Headers */, 1AAF5851180E40B9000584C8 /* LocalStorage.h in Headers */, 1A01C69018F57BE800EFE3A6 /* CCDictionary.h in Headers */, @@ -5205,7 +5204,6 @@ 1A9DCA3B180E6955007A3AD4 /* firePngData.h in Headers */, B37510721823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */, 50FCEBA518C72017004AD434 /* ListViewReader.h in Headers */, - 1AA95FE218EBB8EF00AE7485 /* ccShader_Label_frag_normal.h in Headers */, 1A8C598D180E930E00EF57C3 /* CCActionFrame.h in Headers */, 1A8C5991180E930E00EF57C3 /* CCActionFrameEasing.h in Headers */, 1A8C5995180E930E00EF57C3 /* CCActionManagerEx.h in Headers */, @@ -5224,6 +5222,7 @@ 1A8C59B9180E930E00EF57C3 /* CCColliderDetector.h in Headers */, 1A8C59BD180E930E00EF57C3 /* CCComAttribute.h in Headers */, 1A8C59C1180E930E00EF57C3 /* CCComAudio.h in Headers */, + 5034C9E1191C5D4500CE6051 /* ccShader_Label_frag_normal.h in Headers */, B2AF2FB118EBBDA100C5807C /* CCMath.h in Headers */, 1A8C59C5180E930E00EF57C3 /* CCComController.h in Headers */, 1A8C59C9180E930E00EF57C3 /* CCComRender.h in Headers */, @@ -5233,6 +5232,7 @@ 1A8C59D9180E930E00EF57C3 /* CCDisplayFactory.h in Headers */, 1A8C59DD180E930E00EF57C3 /* CCDisplayManager.h in Headers */, 1A8C59E1180E930E00EF57C3 /* CCInputDelegate.h in Headers */, + 5034C9B7191C5D4500CE6051 /* CCShaderCache.h in Headers */, 1A8C59E5180E930E00EF57C3 /* CCProcessBase.h in Headers */, 1A8C59E9180E930E00EF57C3 /* CCSGUIReader.h in Headers */, 1A8C59ED180E930E00EF57C3 /* CCSkin.h in Headers */, @@ -5394,6 +5394,7 @@ 500DC9B31910633C007B91BF /* CCTouch.h in Headers */, 2AC795E71862875D005EC8E1 /* SkeletonBounds.h in Headers */, 2AC795E81862875D005EC8E1 /* Event.h in Headers */, + 5034C9DE191C5D4500CE6051 /* ccShader_Label_vert.h in Headers */, 500DC97B19106300007B91BF /* CCEventMouse.h in Headers */, 2AC795E91862875D005EC8E1 /* EventData.h in Headers */, 2AC795EA1862875D005EC8E1 /* BoundingBoxAttachment.h in Headers */, @@ -5403,6 +5404,7 @@ 46A171041807CECB005B8026 /* CCPhysicsShape.h in Headers */, 500DC95719106300007B91BF /* CCEventCustom.h in Headers */, 500DC95319106300007B91BF /* CCEventAcceleration.h in Headers */, + 5034C9C4191C5D4500CE6051 /* ccShader_PositionTextureColor_frag.h in Headers */, B2AF2F9818EBAEAE00C5807C /* MathUtil.h in Headers */, 500DC9BF19106E89007B91BF /* CCProfiling.h in Headers */, 500DC8D819105F7D007B91BF /* CCGeometry.h in Headers */, @@ -5416,8 +5418,6 @@ 46A170451807CC07005B8026 /* CCESRenderer.h in Headers */, 46A171011807CECB005B8026 /* CCPhysicsJoint.h in Headers */, 46A170411807CC07005B8026 /* CCGLView.h in Headers */, - A023FA37185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, - 1AA95FE118EBB8EF00AE7485 /* ccShader_Label_frag_df.h in Headers */, 46A170301807CBFE005B8026 /* CCGLViewProtocol.h in Headers */, 500DC8B119105D41007B91BF /* CCCustomCommand.h in Headers */, 500DC8DA19105F7D007B91BF /* CCMathBase.h in Headers */, @@ -5427,6 +5427,7 @@ 2905FA6118CF08D100240AA3 /* UILayoutParameter.h in Headers */, 500DC8BD19105D41007B91BF /* CCQuadCommand.h in Headers */, 46A171061807CECB005B8026 /* CCPhysicsWorld.h in Headers */, + 5034C9CC191C5D4500CE6051 /* ccShader_PositionTexture_uColor_vert.h in Headers */, 46A170491807CC07005B8026 /* CCStdC.h in Headers */, 46A1703B1807CC07005B8026 /* CCApplication.h in Headers */, 46A170271807CBFE005B8026 /* CCFileUtilsApple.h in Headers */, @@ -5436,6 +5437,7 @@ 46A170481807CC07005B8026 /* CCPlatformDefine.h in Headers */, 46A1704C1807CC07005B8026 /* OpenGL_Internal.h in Headers */, 46A1702C1807CBFE005B8026 /* CCApplicationProtocol.h in Headers */, + 5034C9CA191C5D4500CE6051 /* ccShader_PositionTexture_vert.h in Headers */, 1A570064180BC5A10088DEC7 /* CCAction.h in Headers */, 06CAAACE186AD7FA0012A414 /* TriggerBase.h in Headers */, 500DC9AD19106300007B91BF /* ZipUtils.h in Headers */, @@ -5465,6 +5467,7 @@ 2905FA7118CF08D100240AA3 /* UIRichText.h in Headers */, 2905FA6D18CF08D100240AA3 /* UIPageView.h in Headers */, 2905FA7318CF08D100240AA3 /* UIScrollInterface.h in Headers */, + 5034C9CE191C5D4500CE6051 /* ccShader_PositionTexture_uColor_frag.h in Headers */, 2905FA4318CF08D100240AA3 /* CocosGUI.h in Headers */, 500DC93119106300007B91BF /* base64.h in Headers */, B2AF2FA018EBAEAE00C5807C /* Quaternion.h in Headers */, @@ -5478,6 +5481,7 @@ 1A570122180BC90D0088DEC7 /* CCGrid.h in Headers */, 500DC8C319105D41007B91BF /* CCRenderCommandPool.h in Headers */, 500DC8C719105D41007B91BF /* CCRenderer.h in Headers */, + 5034C9E4191C5D4500CE6051 /* ccShader_Label_frag_df.h in Headers */, 500DC98519106300007B91BF /* CCMap.h in Headers */, 50FCEBBA18C72017004AD434 /* TextAtlasReader.h in Headers */, 1A5701A0180BCB590088DEC7 /* CCFont.h in Headers */, @@ -5495,7 +5499,8 @@ 1A01C69518F57BE800EFE3A6 /* CCFloat.h in Headers */, 1A5701CA180BCB5A0088DEC7 /* CCLabelTextFormatter.h in Headers */, 2905FA7B18CF08D100240AA3 /* UISlider.h in Headers */, - 1AA95FE318EBB8EF00AE7485 /* ccShader_Label_frag_normal.h in Headers */, + 5034C9E8191C5D4500CE6051 /* ccGLStateCache.h in Headers */, + 5034C9D4191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_frag.h in Headers */, 1A5701CE180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */, 296CAD251915EC8000C64FBF /* CCEventFocus.h in Headers */, 50FCEBCA18C72017004AD434 /* WidgetReader.h in Headers */, @@ -5507,7 +5512,9 @@ 500DC8C119105D41007B91BF /* CCRenderCommand.h in Headers */, 1A5701F1180BCB8C0088DEC7 /* CCTransitionProgress.h in Headers */, 1A5701FA180BCBAD0088DEC7 /* CCMenu.h in Headers */, + 5034C9DC191C5D4500CE6051 /* ccShader_Position_uColor_frag.h in Headers */, 50FCEBBE18C72017004AD434 /* TextBMFontReader.h in Headers */, + 5034C9D2191C5D4500CE6051 /* ccShader_PositionColorLengthTexture_vert.h in Headers */, 1A5701FE180BCBAD0088DEC7 /* CCMenuItem.h in Headers */, 1A570205180BCBD40088DEC7 /* CCClippingNode.h in Headers */, 1A57020B180BCBDF0088DEC7 /* CCMotionStreak.h in Headers */, @@ -5516,42 +5523,28 @@ 1A570217180BCBF40088DEC7 /* CCRenderTexture.h in Headers */, 1A570224180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */, 500DC95F19106300007B91BF /* CCEventKeyboard.h in Headers */, - 1AA95FE518EBB8EF00AE7485 /* ccShader_Label_frag_outline.h in Headers */, 500DC95B19106300007B91BF /* CCEventDispatcher.h in Headers */, + 5034C9D6191C5D4500CE6051 /* ccShader_PositionColor_vert.h in Headers */, 373B912A187891FB00198F86 /* CCComBase.h in Headers */, 500DC8D419105F7D007B91BF /* CCAffineTransform.h in Headers */, 1A570228180BCC1A0088DEC7 /* CCParticleExamples.h in Headers */, 1A57022C180BCC1A0088DEC7 /* CCParticleSystem.h in Headers */, + 5034C9BE191C5D4500CE6051 /* ccShader_PositionTextureColor_vert.h in Headers */, 1A570230180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */, 1A570237180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */, - 1A57024E180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */, - 1A570250180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */, 2905FA8B18CF08D100240AA3 /* UITextField.h in Headers */, - 1A570252180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h in Headers */, - 1A570254180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h in Headers */, 500DC96F19106300007B91BF /* CCEventListenerKeyboard.h in Headers */, - 1A570256180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h in Headers */, - 1A570258180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h in Headers */, 500DC8B519105D41007B91BF /* CCGroupCommand.h in Headers */, 50FCEBA618C72017004AD434 /* ListViewReader.h in Headers */, - 1A57025A180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */, + 5034C9C6191C5D4500CE6051 /* ccShader_PositionTextureA8Color_vert.h in Headers */, 500DC9B919106E6D007B91BF /* TransformUtils.h in Headers */, - 1A57025C180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */, - 1A57025E180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */, - 1A570260180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */, - 1A570262180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h in Headers */, 500DC99119106300007B91BF /* CCRef.h in Headers */, - 1A570264180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h in Headers */, - 1A570266180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h in Headers */, - 1A570268180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h in Headers */, - 1A57026A180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */, - 1A57026E180BCC6F0088DEC7 /* CCShaderCache.h in Headers */, - 1A570274180BCC6F0088DEC7 /* ccShaders.h in Headers */, 1A570281180BCC900088DEC7 /* CCSprite.h in Headers */, 1A570285180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */, 1A570289180BCC900088DEC7 /* CCSpriteFrame.h in Headers */, 1A57028D180BCC900088DEC7 /* CCSpriteFrameCache.h in Headers */, 1A570295180BCCAB0088DEC7 /* CCAnimation.h in Headers */, + 5034C9E2191C5D4500CE6051 /* ccShader_Label_frag_normal.h in Headers */, 1A570299180BCCAB0088DEC7 /* CCAnimationCache.h in Headers */, 1A5702B2180BCDBC0088DEC7 /* ccUTF8.h in Headers */, 1A5702B8180BCDF40088DEC7 /* CCVertex.h in Headers */, @@ -5565,6 +5558,7 @@ 500DC8AD19105D41007B91BF /* CCBatchCommand.h in Headers */, 1A5702CB180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */, 2905FA7F18CF08D100240AA3 /* UIText.h in Headers */, + 5034C9D8191C5D4500CE6051 /* ccShader_PositionColor_frag.h in Headers */, 1A5702D6180BCE570088DEC7 /* CCTexture2D.h in Headers */, 1A5702DA180BCE570088DEC7 /* CCTextureAtlas.h in Headers */, 1A5702DE180BCE570088DEC7 /* CCTextureCache.h in Headers */, @@ -5573,6 +5567,7 @@ 1A5702F1180BCE750088DEC7 /* CCTMXLayer.h in Headers */, 1A5702F5180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */, 1A5702F9180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */, + 5034C9E0191C5D4500CE6051 /* ccShader_Label_frag_outline.h in Headers */, 500DC9A119106300007B91BF /* CCVector.h in Headers */, 1A5702FD180BCE750088DEC7 /* CCTMXXMLParser.h in Headers */, 1A570303180BCE890088DEC7 /* CCParallaxNode.h in Headers */, @@ -5585,20 +5580,19 @@ B2AF2FA818EBAEAE00C5807C /* Vector3.h in Headers */, 1A57031E180BCF430088DEC7 /* uthash.h in Headers */, 500DC98B19106300007B91BF /* CCPlatformConfig.h in Headers */, + 5034C9B4191C5D4500CE6051 /* ccShaders.h in Headers */, 1A570320180BCF430088DEC7 /* utlist.h in Headers */, 50FCEBC618C72017004AD434 /* TextReader.h in Headers */, + 5034C9D0191C5D4500CE6051 /* ccShader_PositionTexture_frag.h in Headers */, 2905FA7718CF08D100240AA3 /* UIScrollView.h in Headers */, B375107F1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */, 1A570327180BCF660088DEC7 /* TGAlib.h in Headers */, 1A570332180BCFD50088DEC7 /* CCUserDefault.h in Headers */, 500DC94319106300007B91BF /* CCData.h in Headers */, - 1AA95FE718EBB8EF00AE7485 /* ccShader_Label_vert.h in Headers */, 1A57034E180BD09B0088DEC7 /* tinyxml2.h in Headers */, 1A570357180BD0B00088DEC7 /* ioapi.h in Headers */, 1A01C69B18F57BE800EFE3A6 /* CCSet.h in Headers */, 1A57035B180BD0B00088DEC7 /* unzip.h in Headers */, - 1A570536180BD9500088DEC7 /* CCGLProgram.h in Headers */, - 1A57053A180BD9500088DEC7 /* ccGLStateCache.h in Headers */, 1AD71DAC180E26E600808F54 /* CCBAnimationManager.h in Headers */, 1AD71DB0180E26E600808F54 /* CCBFileLoader.h in Headers */, 1AD71DB4180E26E600808F54 /* CCBKeyframe.h in Headers */, @@ -5632,15 +5626,20 @@ 1AD71E08180E26E600808F54 /* CCScrollViewLoader.h in Headers */, 1AD71E0C180E26E600808F54 /* CCSpriteLoader.h in Headers */, 1AD71E0E180E26E600808F54 /* CocosBuilder.h in Headers */, + 5034C9C8191C5D4500CE6051 /* ccShader_PositionTextureA8Color_frag.h in Headers */, 500DC93719106300007B91BF /* ccConfig.h in Headers */, + 5034C9BC191C5D4500CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */, 1AD71E98180E26E600808F54 /* Animation.h in Headers */, 1AD71E9C180E26E600808F54 /* AnimationState.h in Headers */, 1AD71EA0180E26E600808F54 /* AnimationStateData.h in Headers */, + 5034C9B8191C5D4500CE6051 /* CCShaderCache.h in Headers */, 50FCEB9E18C72017004AD434 /* ImageViewReader.h in Headers */, + 5034C9EC191C5D4500CE6051 /* CCGLProgramState.h in Headers */, 500DC98119106300007B91BF /* CCEventType.h in Headers */, 1AD71EA4180E26E600808F54 /* Atlas.h in Headers */, 1AD71EA8180E26E600808F54 /* AtlasAttachmentLoader.h in Headers */, 1ABA68B11888D700007D1BB4 /* CCFontCharMap.h in Headers */, + 5034C9E6191C5D4500CE6051 /* ccShader_Label_frag_df_glow.h in Headers */, 1AD71EAC180E26E600808F54 /* Attachment.h in Headers */, 500DC94719106300007B91BF /* CCDataVisitor.h in Headers */, 2905FA4918CF08D100240AA3 /* UIButton.h in Headers */, @@ -5667,7 +5666,9 @@ 1AD71EE4180E26E600808F54 /* SlotData.h in Headers */, 1AD71EE8180E26E600808F54 /* spine-cocos2dx.h in Headers */, B2AF2F9C18EBAEAE00C5807C /* Matrix.h in Headers */, + 5034C9C0191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, 1AD71EEA180E26E600808F54 /* spine.h in Headers */, + 5034C9C2191C5D4500CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */, 1AAF536D180E3374000584C8 /* HttpClient.h in Headers */, 1AAF536F180E3374000584C8 /* HttpRequest.h in Headers */, 1AAF5371180E3374000584C8 /* HttpResponse.h in Headers */, @@ -5677,11 +5678,10 @@ 1A9DCA26180E6955007A3AD4 /* ccFPSImages.h in Headers */, 1A9DCA2A180E6955007A3AD4 /* CCGLBufferedNode.h in Headers */, 1A0DB7321823827C0025743D /* CCGL.h in Headers */, - 500DC9EA191BF301007B91BF /* CCGLProgramState.h in Headers */, 1A9DCA2E180E6955007A3AD4 /* CCProtocols.h in Headers */, 500DC96B19106300007B91BF /* CCEventListenerCustom.h in Headers */, 1A9DCA3C180E6955007A3AD4 /* firePngData.h in Headers */, - 1AA95FDF18EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h in Headers */, + 5034C9DA191C5D4500CE6051 /* ccShader_Position_uColor_vert.h in Headers */, 1A01C69F18F57BE800EFE3A6 /* CCString.h in Headers */, 296CAD2B1915EC9900C64FBF /* CCEventListenerFocus.h in Headers */, 1A01C69118F57BE800EFE3A6 /* CCDictionary.h in Headers */, @@ -5703,6 +5703,7 @@ 1A8C59B2180E930E00EF57C3 /* CCBatchNode.h in Headers */, 1A8C59B6180E930E00EF57C3 /* CCBone.h in Headers */, 500DC9A919106300007B91BF /* s3tc.h in Headers */, + 5034C9F0191C5D4500CE6051 /* CCGLProgram.h in Headers */, 1A8C59BA180E930E00EF57C3 /* CCColliderDetector.h in Headers */, 1A8C59BE180E930E00EF57C3 /* CCComAttribute.h in Headers */, 1A8C59C2180E930E00EF57C3 /* CCComAudio.h in Headers */, @@ -5732,7 +5733,6 @@ 1A8C59EE180E930E00EF57C3 /* CCSkin.h in Headers */, B37510801823ACA100B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */, 500DC94B19106300007B91BF /* CCDirector.h in Headers */, - A023FA35185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */, 50FCEBA218C72017004AD434 /* LayoutReader.h in Headers */, 1A8C59F2180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h in Headers */, 1A8C59F6180E930E00EF57C3 /* CCSSceneReader.h in Headers */, @@ -6113,6 +6113,7 @@ 46A1701D1807CBFC005B8026 /* CCFileUtils.cpp in Sources */, 46A170EF1807CECA005B8026 /* CCPhysicsWorld.cpp in Sources */, 500DC96C19106300007B91BF /* CCEventListenerKeyboard.cpp in Sources */, + 5034C9B9191C5D4500CE6051 /* CCShaderCache.cpp in Sources */, 46A170231807CBFC005B8026 /* CCSAXParser.cpp in Sources */, B2AF2FA918EBAEAE00C5807C /* Vector4.cpp in Sources */, 46A170ED1807CECA005B8026 /* CCPhysicsShape.cpp in Sources */, @@ -6210,8 +6211,6 @@ 50FCEB9B18C72017004AD434 /* ImageViewReader.cpp in Sources */, 500DC9AA19106300007B91BF /* ZipUtils.cpp in Sources */, 1A570234180BCC4D0088DEC7 /* CCScriptSupport.cpp in Sources */, - 1A57026B180BCC6F0088DEC7 /* CCShaderCache.cpp in Sources */, - 1A570271180BCC6F0088DEC7 /* ccShaders.cpp in Sources */, 1A57027E180BCC900088DEC7 /* CCSprite.cpp in Sources */, 1A570282180BCC900088DEC7 /* CCSpriteBatchNode.cpp in Sources */, 1A570286180BCC900088DEC7 /* CCSpriteFrame.cpp in Sources */, @@ -6236,16 +6235,17 @@ 1A5702EA180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */, 1A5702EE180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */, 500DC97C19106300007B91BF /* CCEventTouch.cpp in Sources */, + 5034C9B5191C5D4500CE6051 /* ccShaders.cpp in Sources */, 1A5702F2180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */, 1A5702F6180BCE750088DEC7 /* CCTMXTiledMap.cpp in Sources */, 1A5702FA180BCE750088DEC7 /* CCTMXXMLParser.cpp in Sources */, 1A570300180BCE890088DEC7 /* CCParallaxNode.cpp in Sources */, + 5034C9ED191C5D4500CE6051 /* CCGLProgramState.cpp in Sources */, 1A570305180BCED90088DEC7 /* ccUtils.cpp in Sources */, 1A57030C180BCF190088DEC7 /* CCComponent.cpp in Sources */, 500DC96019106300007B91BF /* CCEventListener.cpp in Sources */, 1A570310180BCF190088DEC7 /* CCComponentContainer.cpp in Sources */, 1A570319180BCF430088DEC7 /* ccCArray.cpp in Sources */, - 500DC9EB191BF301007B91BF /* CCGLProgramState.cpp in Sources */, B37510711823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */, 1A570324180BCF660088DEC7 /* TGAlib.cpp in Sources */, 1A01C69C18F57BE800EFE3A6 /* CCString.cpp in Sources */, @@ -6257,8 +6257,6 @@ 1A57034B180BD09B0088DEC7 /* tinyxml2.cpp in Sources */, 1A570354180BD0B00088DEC7 /* ioapi.cpp in Sources */, 1A570358180BD0B00088DEC7 /* unzip.cpp in Sources */, - 1A570533180BD9500088DEC7 /* CCGLProgram.cpp in Sources */, - 1A570537180BD9500088DEC7 /* ccGLStateCache.cpp in Sources */, 1AD71DA9180E26E600808F54 /* CCBAnimationManager.cpp in Sources */, 500DC95419106300007B91BF /* CCEventCustom.cpp in Sources */, 1AD71DAD180E26E600808F54 /* CCBFileLoader.cpp in Sources */, @@ -6300,6 +6298,7 @@ 500DC97419106300007B91BF /* CCEventListenerTouch.cpp in Sources */, 1AD71EA5180E26E600808F54 /* AtlasAttachmentLoader.cpp in Sources */, 500DC8D119105F7D007B91BF /* CCAffineTransform.cpp in Sources */, + 5034C9E9191C5D4500CE6051 /* ccGLStateCache.cpp in Sources */, 1AD71EA9180E26E600808F54 /* Attachment.cpp in Sources */, 1AD71EAD180E26E600808F54 /* AttachmentLoader.cpp in Sources */, 1AD71EB1180E26E600808F54 /* Bone.cpp in Sources */, @@ -6370,6 +6369,7 @@ 500DC99419106300007B91BF /* CCScheduler.cpp in Sources */, 1A8C59E3180E930E00EF57C3 /* CCProcessBase.cpp in Sources */, 500DC98E19106300007B91BF /* CCRef.cpp in Sources */, + 5034C9F1191C5D4500CE6051 /* CCGLProgram.cpp in Sources */, 1A8C59E7180E930E00EF57C3 /* CCSGUIReader.cpp in Sources */, 1A8C59EB180E930E00EF57C3 /* CCSkin.cpp in Sources */, 1A8C59EF180E930E00EF57C3 /* CCSpriteFrameCacheHelper.cpp in Sources */, @@ -6561,6 +6561,7 @@ 46A170291807CBFE005B8026 /* CCLock.cpp in Sources */, 500DC97119106300007B91BF /* CCEventListenerMouse.cpp in Sources */, 500DC8AB19105D41007B91BF /* CCBatchCommand.cpp in Sources */, + 5034C9BA191C5D4500CE6051 /* CCShaderCache.cpp in Sources */, 500DC92B19106300007B91BF /* atitc.cpp in Sources */, 46A170FE1807CECB005B8026 /* CCPhysicsContact.cpp in Sources */, 46A170391807CBFE005B8026 /* CCThread.cpp in Sources */, @@ -6639,8 +6640,6 @@ 2905FA5718CF08D100240AA3 /* UILayout.cpp in Sources */, 2905FA7D18CF08D100240AA3 /* UIText.cpp in Sources */, 50E6D33D18E174130051CA34 /* UIVBox.cpp in Sources */, - 1A57026C180BCC6F0088DEC7 /* CCShaderCache.cpp in Sources */, - 1A570272180BCC6F0088DEC7 /* ccShaders.cpp in Sources */, 1A57027F180BCC900088DEC7 /* CCSprite.cpp in Sources */, 500DC93319106300007B91BF /* CCAutoreleasePool.cpp in Sources */, 1A570283180BCC900088DEC7 /* CCSpriteBatchNode.cpp in Sources */, @@ -6660,6 +6659,7 @@ 1A5702D8180BCE570088DEC7 /* CCTextureAtlas.cpp in Sources */, 1A5702DC180BCE570088DEC7 /* CCTextureCache.cpp in Sources */, 1A5702EB180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */, + 5034C9B6191C5D4500CE6051 /* ccShaders.cpp in Sources */, 1A5702EF180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */, 1A5702F3180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */, 2905FA5B18CF08D100240AA3 /* UILayoutDefine.cpp in Sources */, @@ -6685,9 +6685,7 @@ 1A57034C180BD09B0088DEC7 /* tinyxml2.cpp in Sources */, 1A570355180BD0B00088DEC7 /* ioapi.cpp in Sources */, 1A570359180BD0B00088DEC7 /* unzip.cpp in Sources */, - 1A570534180BD9500088DEC7 /* CCGLProgram.cpp in Sources */, 500DC96519106300007B91BF /* CCEventListenerAcceleration.cpp in Sources */, - 1A570538180BD9500088DEC7 /* ccGLStateCache.cpp in Sources */, 500DC94D19106300007B91BF /* CCEvent.cpp in Sources */, 1AD71DAA180E26E600808F54 /* CCBAnimationManager.cpp in Sources */, 1AD71DAE180E26E600808F54 /* CCBFileLoader.cpp in Sources */, @@ -6721,6 +6719,7 @@ 1AD71E96180E26E600808F54 /* Animation.cpp in Sources */, 1AD71E9A180E26E600808F54 /* AnimationState.cpp in Sources */, 1AD71E9E180E26E600808F54 /* AnimationStateData.cpp in Sources */, + 5034C9EE191C5D4500CE6051 /* CCGLProgramState.cpp in Sources */, 1AD71EA2180E26E600808F54 /* Atlas.cpp in Sources */, 1AD71EA6180E26E600808F54 /* AtlasAttachmentLoader.cpp in Sources */, 1AD71EAA180E26E600808F54 /* Attachment.cpp in Sources */, @@ -6731,7 +6730,6 @@ 1AD71EB6180E26E600808F54 /* BoneData.cpp in Sources */, 500DC8D619105F7D007B91BF /* CCGeometry.cpp in Sources */, 50FCEB9C18C72017004AD434 /* ImageViewReader.cpp in Sources */, - 500DC9EC191BF301007B91BF /* CCGLProgramState.cpp in Sources */, 1AD71EBA180E26E600808F54 /* CCSkeleton.cpp in Sources */, 1A01C68B18F57BE800EFE3A6 /* CCDeprecated.cpp in Sources */, 1AD71EBE180E26E600808F54 /* CCSkeletonAnimation.cpp in Sources */, @@ -6760,6 +6758,7 @@ 1AAF5377180E3374000584C8 /* WebSocket.cpp in Sources */, 500DC93D19106300007B91BF /* CCConsole.cpp in Sources */, 1AAF5850180E40B9000584C8 /* LocalStorage.cpp in Sources */, + 5034C9EA191C5D4500CE6051 /* ccGLStateCache.cpp in Sources */, 1AAF5854180E40B9000584C8 /* LocalStorageAndroid.cpp in Sources */, 1A9DCA24180E6955007A3AD4 /* ccFPSImages.c in Sources */, 1A9DCA28180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */, @@ -6783,6 +6782,7 @@ 1A8C59AC180E930E00EF57C3 /* CCArmatureDefine.cpp in Sources */, 500DC98719106300007B91BF /* CCNS.cpp in Sources */, 1A8C59B0180E930E00EF57C3 /* CCBatchNode.cpp in Sources */, + 5034C9F2191C5D4500CE6051 /* CCGLProgram.cpp in Sources */, 1A8C59B4180E930E00EF57C3 /* CCBone.cpp in Sources */, 1A8C59B8180E930E00EF57C3 /* CCColliderDetector.cpp in Sources */, 1A8C59BC180E930E00EF57C3 /* CCComAttribute.cpp in Sources */, diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index 808e25bcea..fe049bc4af 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -29,9 +29,9 @@ THE SOFTWARE. #include "2d/CCTextureAtlas.h" #include "2d/CCTextureCache.h" #include "base/CCDirector.h" -#include "2d/CCGLProgram.h" -#include "2d/CCShaderCache.h" -#include "2d/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCShaderCache.h" +#include "renderer/ccGLStateCache.h" #include "base/CCDirector.h" #include "math/TransformUtils.h" #include "renderer/CCRenderer.h" diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index a27dd1b11d..2cd827a66e 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -26,8 +26,8 @@ */ #include "2d/CCClippingNode.h" -#include "2d/CCGLProgram.h" -#include "2d/CCShaderCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCShaderCache.h" #include "2d/CCDrawingPrimitives.h" #include "base/CCDirector.h" diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index c5cc3c3915..0490e5da09 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -22,7 +22,7 @@ */ #include "2d/CCDrawNode.h" -#include "2d/CCShaderCache.h" +#include "renderer/CCShaderCache.h" #include "CCGL.h" #include "base/CCEventType.h" #include "base/CCConfiguration.h" diff --git a/cocos/2d/CCDrawingPrimitives.cpp b/cocos/2d/CCDrawingPrimitives.cpp index 7a591a2ca4..44ea905483 100644 --- a/cocos/2d/CCDrawingPrimitives.cpp +++ b/cocos/2d/CCDrawingPrimitives.cpp @@ -45,9 +45,9 @@ THE SOFTWARE. #include "base/ccMacros.h" #include "CCGL.h" #include "base/CCDirector.h" -#include "2d/ccGLStateCache.h" -#include "2d/CCShaderCache.h" -#include "2d/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgram.h" #include "2d/CCActionCatmullRom.h" #include "renderer/CCRenderer.h" diff --git a/cocos/2d/CCGrid.cpp b/cocos/2d/CCGrid.cpp index f6ce871961..70e07ac3c1 100644 --- a/cocos/2d/CCGrid.cpp +++ b/cocos/2d/CCGrid.cpp @@ -28,9 +28,9 @@ THE SOFTWARE. #include "base/CCDirector.h" #include "CCGrabber.h" #include "2d/ccUtils.h" -#include "2d/CCGLProgram.h" -#include "2d/CCShaderCache.h" -#include "2d/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCShaderCache.h" +#include "renderer/ccGLStateCache.h" #include "CCGL.h" #include "renderer/CCRenderer.h" #include "math/TransformUtils.h" diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 301f0275a5..db5e63afe3 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -27,7 +27,7 @@ #include "2d/CCFontAtlasCache.h" #include "CCLabelTextFormatter.h" #include "2d/CCSprite.h" -#include "2d/CCShaderCache.h" +#include "renderer/CCShaderCache.h" #include "ccUTF8.h" #include "2d/CCSpriteFrame.h" #include "base/CCDirector.h" diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index 19d5973b49..5d060eed90 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -29,9 +29,9 @@ THE SOFTWARE. #include "2d/CCTextureCache.h" #include "2d/CCDrawingPrimitives.h" #include "base/ccConfig.h" -#include "2d/CCShaderCache.h" -#include "2d/CCGLProgram.h" -#include "2d/ccGLStateCache.h" +#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" #include "base/CCDirector.h" #include "math/TransformUtils.h" #include "2d/platform/CCFileUtils.h" diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index a1665577c6..6e30028b32 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -29,9 +29,9 @@ THE SOFTWARE. #include "2d/CCLayer.h" #include "base/CCDirector.h" #include "2d/CCScriptSupport.h" -#include "2d/CCShaderCache.h" -#include "2d/CCGLProgram.h" -#include "2d/ccGLStateCache.h" +#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" #include "math/TransformUtils.h" // extern #include "base/CCEventDispatcher.h" diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp index 50a3e9febc..6ae0a6403c 100644 --- a/cocos/2d/CCMotionStreak.cpp +++ b/cocos/2d/CCMotionStreak.cpp @@ -25,9 +25,9 @@ THE SOFTWARE. ****************************************************************************/ #include "2d/CCMotionStreak.h" #include "2d/CCTextureCache.h" -#include "2d/ccGLStateCache.h" -#include "2d/CCGLProgram.h" -#include "2d/CCShaderCache.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCShaderCache.h" #include "2d/CCVertex.h" #include "base/ccMacros.h" #include "base/CCDirector.h" diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 65cc8b68d4..273b3427fe 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -40,11 +40,11 @@ THE SOFTWARE. #include "2d/CCGrid.h" #include "2d/CCActionManager.h" #include "2d/CCScriptSupport.h" -#include "2d/CCGLProgram.h" #include "2d/CCScene.h" -#include "2d/CCGLProgramState.h" #include "2d/CCComponent.h" #include "2d/CCComponentContainer.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCGLProgramState.h" #include "math/TransformUtils.h" #include "deprecated/CCString.h" diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index a8270b62ee..4a1680eed0 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -30,14 +30,14 @@ #define __CCNODE_H__ #include "base/ccMacros.h" -#include "math/CCAffineTransform.h" -#include "CCGL.h" -#include "2d/ccGLStateCache.h" -#include "2d/CCScriptSupport.h" -#include "2d/CCProtocols.h" #include "base/CCEventDispatcher.h" #include "base/CCVector.h" +#include "math/CCAffineTransform.h" #include "math/CCMath.h" +#include "renderer/ccGLStateCache.h" +#include "2d/CCScriptSupport.h" +#include "2d/CCProtocols.h" +#include "CCGL.h" NS_CC_BEGIN diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index bdd736bf9b..6f5f605981 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -35,9 +35,9 @@ #include "base/ccMacros.h" #include "2d/CCGrid.h" #include "CCParticleSystem.h" -#include "2d/CCShaderCache.h" -#include "2d/CCGLProgram.h" -#include "2d/ccGLStateCache.h" +#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" #include "base/base64.h" #include "base/ZipUtils.h" #include "2d/platform/CCFileUtils.h" diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index cc5e604ac2..98f7a6c05a 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -32,9 +32,9 @@ THE SOFTWARE. #include "base/CCDirector.h" #include "CCParticleBatchNode.h" #include "2d/CCTextureAtlas.h" -#include "2d/CCShaderCache.h" -#include "2d/ccGLStateCache.h" -#include "2d/CCGLProgram.h" +#include "renderer/CCShaderCache.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" #include "math/TransformUtils.h" #include "base/CCEventType.h" #include "base/CCConfiguration.h" diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp index 2e2163426b..d0d02dd545 100644 --- a/cocos/2d/CCProgressTimer.cpp +++ b/cocos/2d/CCProgressTimer.cpp @@ -27,9 +27,9 @@ THE SOFTWARE. #include "base/ccMacros.h" #include "2d/CCTextureCache.h" -#include "2d/CCGLProgram.h" -#include "2d/CCShaderCache.h" -#include "2d/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCShaderCache.h" +#include "renderer/ccGLStateCache.h" #include "base/CCDirector.h" #include "math/TransformUtils.h" #include "2d/CCDrawingPrimitives.h" diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index 5ad6859d1a..52addc63a4 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -28,8 +28,8 @@ THE SOFTWARE. #include "2d/CCRenderTexture.h" #include "base/CCDirector.h" #include "2d/platform/CCImage.h" -#include "2d/CCGLProgram.h" -#include "2d/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" #include "base/CCConfiguration.h" #include "2d/ccUtils.h" #include "2d/CCTextureCache.h" diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 3b797ba673..0a49c1e93a 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -33,9 +33,9 @@ THE SOFTWARE. #include "2d/CCSpriteFrameCache.h" #include "2d/CCTextureCache.h" #include "2d/CCDrawingPrimitives.h" -#include "2d/CCShaderCache.h" -#include "2d/ccGLStateCache.h" -#include "2d/CCGLProgram.h" +#include "renderer/CCShaderCache.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" #include "2d/CCTexture2D.h" #include "base/CCProfiling.h" #include "base/CCDirector.h" diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index 802169d66e..a9d79c46ea 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -32,9 +32,9 @@ THE SOFTWARE. #include "2d/CCGrid.h" #include "2d/CCDrawingPrimitives.h" #include "2d/CCTextureCache.h" -#include "2d/CCShaderCache.h" -#include "2d/CCGLProgram.h" -#include "2d/ccGLStateCache.h" +#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" #include "base/CCDirector.h" #include "math/TransformUtils.h" #include "base/CCProfiling.h" diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp index cfa675a54e..1105ee809e 100644 --- a/cocos/2d/CCTMXLayer.cpp +++ b/cocos/2d/CCTMXLayer.cpp @@ -29,8 +29,8 @@ THE SOFTWARE. #include "CCTMXTiledMap.h" #include "2d/CCSprite.h" #include "2d/CCTextureCache.h" -#include "2d/CCShaderCache.h" -#include "2d/CCGLProgram.h" +#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgram.h" #include "2d/ccCArray.h" #include "base/CCDirector.h" diff --git a/cocos/2d/CCTexture2D.cpp b/cocos/2d/CCTexture2D.cpp index 89da4a613b..fed3e5b808 100644 --- a/cocos/2d/CCTexture2D.cpp +++ b/cocos/2d/CCTexture2D.cpp @@ -40,9 +40,9 @@ THE SOFTWARE. #include "2d/ccUtils.h" #include "base/CCPlatformMacros.h" #include "base/CCDirector.h" -#include "2d/CCGLProgram.h" -#include "2d/ccGLStateCache.h" -#include "2d/CCShaderCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCShaderCache.h" #include "2d/platform/CCDevice.h" #include "deprecated/CCString.h" diff --git a/cocos/2d/CCTextureAtlas.cpp b/cocos/2d/CCTextureAtlas.cpp index 51670313ef..847149e520 100644 --- a/cocos/2d/CCTextureAtlas.cpp +++ b/cocos/2d/CCTextureAtlas.cpp @@ -29,8 +29,8 @@ THE SOFTWARE. #include "2d/CCTextureAtlas.h" #include "2d/CCTextureCache.h" #include "base/ccMacros.h" -#include "2d/CCGLProgram.h" -#include "2d/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" #include "base/CCEventType.h" #include "base/CCDirector.h" #include "CCGL.h" diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 94c0aa7270..97483f305f 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -36,14 +36,14 @@ THE SOFTWARE. #include "2d/CCScene.h" #include "2d/CCSpriteFrameCache.h" #include "2d/platform/CCFileUtils.h" -#include "2d/ccGLStateCache.h" +#include "renderer/ccGLStateCache.h" #include "2d/platform/CCImage.h" #include "2d/CCActionManager.h" #include "2d/CCFontFNT.h" #include "2d/CCFontAtlasCache.h" #include "2d/CCAnimationCache.h" #include "2d/CCUserDefault.h" -#include "2d/CCShaderCache.h" +#include "renderer/CCShaderCache.h" #include "2d/CCTransition.h" #include "2d/CCTextureCache.h" #include "2d/CCFontFreeType.h" diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 35f75e3159..9cff4cb22d 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -140,6 +140,11 @@ THE SOFTWARE. #include "renderer/CCRenderCommand.h" #include "renderer/CCRenderCommandPool.h" #include "renderer/CCRenderer.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCGLProgramState.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCShaderCache.h" +#include "renderer/ccShaders.h" // physics #include "physics/CCPhysicsBody.h" @@ -219,12 +224,6 @@ THE SOFTWARE. // script_support #include "2d/CCScriptSupport.h" -// shaders -#include "2d/CCGLProgram.h" -#include "2d/ccGLStateCache.h" -#include "2d/CCShaderCache.h" -#include "2d/ccShaders.h" - // sprite_nodes #include "2d/CCAnimation.h" #include "2d/CCAnimationCache.h" diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 00aeed1aa8..42d508bdb2 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -31,7 +31,7 @@ THE SOFTWARE. #include "renderer/CCRenderer.h" #include "renderer/CCGroupCommand.h" -#include "2d/CCShaderCache.h" +#include "renderer/CCShaderCache.h" #include "2d/CCDrawingPrimitives.h" #include "base/CCDirector.h" diff --git a/cocos/editor-support/cocostudio/CCBatchNode.cpp b/cocos/editor-support/cocostudio/CCBatchNode.cpp index 006a9b50eb..4ec7b9efa1 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.cpp +++ b/cocos/editor-support/cocostudio/CCBatchNode.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. #include "renderer/CCRenderer.h" #include "renderer/CCGroupCommand.h" -#include "2d/CCShaderCache.h" +#include "renderer/CCShaderCache.h" #include "base/CCDirector.h" using namespace cocos2d; diff --git a/cocos/renderer/CCBatchCommand.cpp b/cocos/renderer/CCBatchCommand.cpp index 98e945dbb4..ce7dd90a6c 100644 --- a/cocos/renderer/CCBatchCommand.cpp +++ b/cocos/renderer/CCBatchCommand.cpp @@ -24,7 +24,7 @@ #include "renderer/CCBatchCommand.h" -#include "2d/ccGLStateCache.h" +#include "renderer/ccGLStateCache.h" #include "2d/CCTextureAtlas.h" #include "2d/CCTexture2D.h" diff --git a/cocos/renderer/CCBatchCommand.h b/cocos/renderer/CCBatchCommand.h index 31e3394493..1861d0021c 100644 --- a/cocos/renderer/CCBatchCommand.h +++ b/cocos/renderer/CCBatchCommand.h @@ -26,7 +26,7 @@ #define _CC_BATCHCOMMAND_H_ #include "CCRenderCommand.h" -#include "2d/CCGLProgram.h" +#include "renderer/CCGLProgram.h" #include "CCRenderCommandPool.h" NS_CC_BEGIN diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp similarity index 99% rename from cocos/2d/CCGLProgram.cpp rename to cocos/renderer/CCGLProgram.cpp index b621f31103..cc4df344e1 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -27,8 +27,8 @@ THE SOFTWARE. ****************************************************************************/ #include "base/CCDirector.h" -#include "2d/CCGLProgram.h" -#include "2d/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" #include "base/ccMacros.h" #include "2d/platform/CCFileUtils.h" #include "2d/uthash.h" diff --git a/cocos/2d/CCGLProgram.h b/cocos/renderer/CCGLProgram.h similarity index 100% rename from cocos/2d/CCGLProgram.h rename to cocos/renderer/CCGLProgram.h diff --git a/cocos/2d/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp similarity index 79% rename from cocos/2d/CCGLProgramState.cpp rename to cocos/renderer/CCGLProgramState.cpp index 094dc1d29a..6bdb2aaab0 100644 --- a/cocos/2d/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -26,9 +26,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "2d/CCGLProgramState.h" -#include "2d/CCGLProgram.h" -#include "2d/ccGLStateCache.h" +#include "renderer/CCGLProgramState.h" +#include "renderer/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" NS_CC_BEGIN @@ -96,48 +96,48 @@ void UniformValue::apply() } } -void UniformValue::setValue(const std::function callback) +void UniformValue::setCallback(const std::function &callback) { _value.callback = callback; _useCallback = true; } -void UniformValue::setValue(float value) +void UniformValue::setFloat(float value) { CCASSERT (_uniform->type == GL_FLOAT, ""); _value.floatValue = value; _useCallback = false; } -void UniformValue::setValue(int value) +void UniformValue::setInt(int value) { CCASSERT ((_uniform->type == GL_INT || _uniform->type == GL_SAMPLER_2D), ""); _value.intValue = value; _useCallback = false; } -void UniformValue::setValue(const Vector2& value) +void UniformValue::setVec2(const Vector2& value) { CCASSERT (_uniform->type == GL_FLOAT_VEC2, ""); _value.v2Value = value; _useCallback = false; } -void UniformValue::setValue(const Vector3& value) +void UniformValue::setVec3(const Vector3& value) { CCASSERT (_uniform->type == GL_FLOAT_VEC3, ""); _value.v3Value = value; _useCallback = false; } -void UniformValue::setValue(const Vector4& value) +void UniformValue::setVec4(const Vector4& value) { CCASSERT (_uniform->type == GL_FLOAT_VEC4, ""); _value.v4Value = value; _useCallback = false; } -void UniformValue::setValue(const Matrix& value) +void UniformValue::setMat4(const Matrix& value) { CCASSERT(_uniform->type == GL_FLOAT_MAT4, ""); _value.matrixValue = value; @@ -182,7 +182,7 @@ void VertexAttribValue::apply() } } -void VertexAttribValue::setCallback(const std::function callback) +void VertexAttribValue::setCallback(const std::function &callback) { _value.callback = callback; _useCallback = true; @@ -301,7 +301,8 @@ VertexAttribValue* GLProgramState::getVertexAttribValue(const std::string &name) return nullptr; } -void GLProgramState::setVertexAttribCallback(const std::string &name, const std::function callback) +// VertexAttrib Setters +void GLProgramState::setVertexAttribCallback(const std::string &name, const std::function &callback) { VertexAttribValue *v = getVertexAttribValue(name); if(v) { @@ -327,5 +328,56 @@ void GLProgramState::setVertexAttribPointer(const std::string &name, GLint size, } } +// Uniform Setters + +void GLProgramState::setUniformCallback(const std::string &uniformName, const std::function &callback) +{ + auto v = getUniformValue(uniformName); + CCASSERT(v, "unknown uniform value"); + v->setCallback(callback); +} + +void GLProgramState::setUniformFloat(const std::string &uniformName, float value) +{ + auto v = getUniformValue(uniformName); + CCASSERT(v, "unknown uniform value"); + v->setFloat(value); +} + +void GLProgramState::setUniformInt(const std::string &uniformName, int value) +{ + auto v = getUniformValue(uniformName); + CCASSERT(v, "unknown uniform value"); + v->setInt(value); +} + +void GLProgramState::setUniformVec2(const std::string &uniformName, const Vector2& value) +{ + auto v = getUniformValue(uniformName); + CCASSERT(v, "unknown uniform value"); + v->setVec2(value); +} + +void GLProgramState::setUniformVec3(const std::string &uniformName, const Vector3& value) +{ + auto v = getUniformValue(uniformName); + CCASSERT(v, "unknown uniform value"); + v->setVec3(value); +} + +void GLProgramState::setUniformVec4(const std::string &uniformName, const Vector4& value) +{ + auto v = getUniformValue(uniformName); + CCASSERT(v, "unknown uniform value"); + v->setVec4(value); +} + +void GLProgramState::setUniformMat4(const std::string &uniformName, const Matrix& value) +{ + auto v = getUniformValue(uniformName); + CCASSERT(v, "unknown uniform value"); + v->setMat4(value); +} + NS_CC_END diff --git a/cocos/2d/CCGLProgramState.h b/cocos/renderer/CCGLProgramState.h similarity index 81% rename from cocos/2d/CCGLProgramState.h rename to cocos/renderer/CCGLProgramState.h index bcce3b57a0..b52d08fd09 100644 --- a/cocos/2d/CCGLProgramState.h +++ b/cocos/renderer/CCGLProgramState.h @@ -53,13 +53,13 @@ public: UniformValue(Uniform *uniform, GLProgram* glprogram); ~UniformValue(); - void setValue(float value); - void setValue(int value); - void setValue(const Vector2& value); - void setValue(const Vector3& value); - void setValue(const Vector4& value); - void setValue(const Matrix& value); - void setValue(const std::function callback); + void setFloat(float value); + void setInt(int value); + void setVec2(const Vector2& value); + void setVec3(const Vector3& value); + void setVec4(const Vector4& value); + void setMat4(const Matrix& value); + void setCallback(const std::function &callback); void apply(); @@ -102,7 +102,7 @@ public: ~VertexAttribValue(); void setPointer(GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer); - void setCallback(const std::function callback); + void setCallback(const std::function &callback); void apply(); protected: @@ -144,10 +144,16 @@ public: void setGLProgram(GLProgram* glprogram); GLProgram* getGLProgram() const { return _glprogram; } - void setVertexAttribCallback(const std::string &name, const std::function callback); + void setVertexAttribCallback(const std::string &name, const std::function &callback); void setVertexAttribPointer(const std::string &name, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer); - UniformValue* getUniformValue(const std::string &uniformName); + void setUniformFloat(const std::string &uniformName, float value); + void setUniformInt(const std::string &uniformName, int value); + void setUniformVec2(const std::string &uniformName, const Vector2& value); + void setUniformVec3(const std::string &uniformName, const Vector3& value); + void setUniformVec4(const std::string &uniformName, const Vector4& value); + void setUniformMat4(const std::string &uniformName, const Matrix& value); + void setUniformCallback(const std::string &uniformName, const std::function &callback); protected: GLProgramState(); @@ -155,6 +161,7 @@ protected: bool init(GLProgram* program); void resetGLProgram(); VertexAttribValue* getVertexAttribValue(const std::string &attributeName); + UniformValue* getUniformValue(const std::string &uniformName); std::unordered_map _uniforms; std::unordered_map _attributes; diff --git a/cocos/renderer/CCQuadCommand.cpp b/cocos/renderer/CCQuadCommand.cpp index 5e8a02ca2f..6e7b9c701f 100644 --- a/cocos/renderer/CCQuadCommand.cpp +++ b/cocos/renderer/CCQuadCommand.cpp @@ -24,7 +24,7 @@ #include "renderer/CCQuadCommand.h" -#include "2d/ccGLStateCache.h" +#include "renderer/ccGLStateCache.h" #include "xxhash.h" NS_CC_BEGIN diff --git a/cocos/renderer/CCQuadCommand.h b/cocos/renderer/CCQuadCommand.h index c1c37e700c..bace79ed04 100644 --- a/cocos/renderer/CCQuadCommand.h +++ b/cocos/renderer/CCQuadCommand.h @@ -26,7 +26,7 @@ #define _CC_QUADCOMMAND_H_ #include "CCRenderCommand.h" -#include "2d/CCGLProgram.h" +#include "renderer/CCGLProgram.h" #include "CCRenderCommandPool.h" NS_CC_BEGIN diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index fe0b5e2286..ff9532ff5e 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -30,8 +30,8 @@ #include "renderer/CCBatchCommand.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCGroupCommand.h" -#include "2d/CCShaderCache.h" -#include "2d/ccGLStateCache.h" +#include "renderer/CCShaderCache.h" +#include "renderer/ccGLStateCache.h" #include "base/CCConfiguration.h" #include "base/CCDirector.h" #include "base/CCEventDispatcher.h" diff --git a/cocos/renderer/CCRenderer.h b/cocos/renderer/CCRenderer.h index 02bcff345a..94c9da4794 100644 --- a/cocos/renderer/CCRenderer.h +++ b/cocos/renderer/CCRenderer.h @@ -28,7 +28,7 @@ #include "base/CCPlatformMacros.h" #include "CCRenderCommand.h" -#include "2d/CCGLProgram.h" +#include "renderer/CCGLProgram.h" #include "CCGL.h" #include #include diff --git a/cocos/2d/CCShaderCache.cpp b/cocos/renderer/CCShaderCache.cpp similarity index 99% rename from cocos/2d/CCShaderCache.cpp rename to cocos/renderer/CCShaderCache.cpp index ef0ef30277..d9f21e0910 100644 --- a/cocos/2d/CCShaderCache.cpp +++ b/cocos/renderer/CCShaderCache.cpp @@ -25,10 +25,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "2d/CCShaderCache.h" -#include "2d/CCGLProgram.h" +#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/ccShaders.h" #include "base/ccMacros.h" -#include "2d/ccShaders.h" NS_CC_BEGIN diff --git a/cocos/2d/CCShaderCache.h b/cocos/renderer/CCShaderCache.h similarity index 100% rename from cocos/2d/CCShaderCache.h rename to cocos/renderer/CCShaderCache.h diff --git a/cocos/2d/ccGLStateCache.cpp b/cocos/renderer/ccGLStateCache.cpp similarity index 98% rename from cocos/2d/ccGLStateCache.cpp rename to cocos/renderer/ccGLStateCache.cpp index 3974b26dad..7f4db72592 100644 --- a/cocos/2d/ccGLStateCache.cpp +++ b/cocos/renderer/ccGLStateCache.cpp @@ -25,8 +25,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "2d/ccGLStateCache.h" -#include "2d/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" #include "base/CCDirector.h" #include "base/ccConfig.h" #include "base/CCConfiguration.h" diff --git a/cocos/2d/ccGLStateCache.h b/cocos/renderer/ccGLStateCache.h similarity index 100% rename from cocos/2d/ccGLStateCache.h rename to cocos/renderer/ccGLStateCache.h diff --git a/cocos/2d/ccShader_Label_frag_df.h b/cocos/renderer/ccShader_Label_frag_df.h similarity index 100% rename from cocos/2d/ccShader_Label_frag_df.h rename to cocos/renderer/ccShader_Label_frag_df.h diff --git a/cocos/2d/ccShader_Label_frag_df_glow.h b/cocos/renderer/ccShader_Label_frag_df_glow.h similarity index 100% rename from cocos/2d/ccShader_Label_frag_df_glow.h rename to cocos/renderer/ccShader_Label_frag_df_glow.h diff --git a/cocos/2d/ccShader_Label_frag_normal.h b/cocos/renderer/ccShader_Label_frag_normal.h similarity index 100% rename from cocos/2d/ccShader_Label_frag_normal.h rename to cocos/renderer/ccShader_Label_frag_normal.h diff --git a/cocos/2d/ccShader_Label_frag_outline.h b/cocos/renderer/ccShader_Label_frag_outline.h similarity index 100% rename from cocos/2d/ccShader_Label_frag_outline.h rename to cocos/renderer/ccShader_Label_frag_outline.h diff --git a/cocos/2d/ccShader_Label_vert.h b/cocos/renderer/ccShader_Label_vert.h similarity index 100% rename from cocos/2d/ccShader_Label_vert.h rename to cocos/renderer/ccShader_Label_vert.h diff --git a/cocos/2d/ccShader_PositionColorLengthTexture_frag.h b/cocos/renderer/ccShader_PositionColorLengthTexture_frag.h similarity index 100% rename from cocos/2d/ccShader_PositionColorLengthTexture_frag.h rename to cocos/renderer/ccShader_PositionColorLengthTexture_frag.h diff --git a/cocos/2d/ccShader_PositionColorLengthTexture_vert.h b/cocos/renderer/ccShader_PositionColorLengthTexture_vert.h similarity index 100% rename from cocos/2d/ccShader_PositionColorLengthTexture_vert.h rename to cocos/renderer/ccShader_PositionColorLengthTexture_vert.h diff --git a/cocos/2d/ccShader_PositionColor_frag.h b/cocos/renderer/ccShader_PositionColor_frag.h similarity index 100% rename from cocos/2d/ccShader_PositionColor_frag.h rename to cocos/renderer/ccShader_PositionColor_frag.h diff --git a/cocos/2d/ccShader_PositionColor_vert.h b/cocos/renderer/ccShader_PositionColor_vert.h similarity index 100% rename from cocos/2d/ccShader_PositionColor_vert.h rename to cocos/renderer/ccShader_PositionColor_vert.h diff --git a/cocos/2d/ccShader_PositionTextureA8Color_frag.h b/cocos/renderer/ccShader_PositionTextureA8Color_frag.h similarity index 100% rename from cocos/2d/ccShader_PositionTextureA8Color_frag.h rename to cocos/renderer/ccShader_PositionTextureA8Color_frag.h diff --git a/cocos/2d/ccShader_PositionTextureA8Color_vert.h b/cocos/renderer/ccShader_PositionTextureA8Color_vert.h similarity index 100% rename from cocos/2d/ccShader_PositionTextureA8Color_vert.h rename to cocos/renderer/ccShader_PositionTextureA8Color_vert.h diff --git a/cocos/2d/ccShader_PositionTextureColorAlphaTest_frag.h b/cocos/renderer/ccShader_PositionTextureColorAlphaTest_frag.h similarity index 100% rename from cocos/2d/ccShader_PositionTextureColorAlphaTest_frag.h rename to cocos/renderer/ccShader_PositionTextureColorAlphaTest_frag.h diff --git a/cocos/2d/ccShader_PositionTextureColor_frag.h b/cocos/renderer/ccShader_PositionTextureColor_frag.h similarity index 100% rename from cocos/2d/ccShader_PositionTextureColor_frag.h rename to cocos/renderer/ccShader_PositionTextureColor_frag.h diff --git a/cocos/2d/ccShader_PositionTextureColor_noMVP_frag.h b/cocos/renderer/ccShader_PositionTextureColor_noMVP_frag.h similarity index 100% rename from cocos/2d/ccShader_PositionTextureColor_noMVP_frag.h rename to cocos/renderer/ccShader_PositionTextureColor_noMVP_frag.h diff --git a/cocos/2d/ccShader_PositionTextureColor_noMVP_vert.h b/cocos/renderer/ccShader_PositionTextureColor_noMVP_vert.h similarity index 100% rename from cocos/2d/ccShader_PositionTextureColor_noMVP_vert.h rename to cocos/renderer/ccShader_PositionTextureColor_noMVP_vert.h diff --git a/cocos/2d/ccShader_PositionTextureColor_vert.h b/cocos/renderer/ccShader_PositionTextureColor_vert.h similarity index 100% rename from cocos/2d/ccShader_PositionTextureColor_vert.h rename to cocos/renderer/ccShader_PositionTextureColor_vert.h diff --git a/cocos/2d/ccShader_PositionTexture_frag.h b/cocos/renderer/ccShader_PositionTexture_frag.h similarity index 100% rename from cocos/2d/ccShader_PositionTexture_frag.h rename to cocos/renderer/ccShader_PositionTexture_frag.h diff --git a/cocos/2d/ccShader_PositionTexture_uColor_frag.h b/cocos/renderer/ccShader_PositionTexture_uColor_frag.h similarity index 100% rename from cocos/2d/ccShader_PositionTexture_uColor_frag.h rename to cocos/renderer/ccShader_PositionTexture_uColor_frag.h diff --git a/cocos/2d/ccShader_PositionTexture_uColor_vert.h b/cocos/renderer/ccShader_PositionTexture_uColor_vert.h similarity index 100% rename from cocos/2d/ccShader_PositionTexture_uColor_vert.h rename to cocos/renderer/ccShader_PositionTexture_uColor_vert.h diff --git a/cocos/2d/ccShader_PositionTexture_vert.h b/cocos/renderer/ccShader_PositionTexture_vert.h similarity index 100% rename from cocos/2d/ccShader_PositionTexture_vert.h rename to cocos/renderer/ccShader_PositionTexture_vert.h diff --git a/cocos/2d/ccShader_Position_uColor_frag.h b/cocos/renderer/ccShader_Position_uColor_frag.h similarity index 100% rename from cocos/2d/ccShader_Position_uColor_frag.h rename to cocos/renderer/ccShader_Position_uColor_frag.h diff --git a/cocos/2d/ccShader_Position_uColor_vert.h b/cocos/renderer/ccShader_Position_uColor_vert.h similarity index 100% rename from cocos/2d/ccShader_Position_uColor_vert.h rename to cocos/renderer/ccShader_Position_uColor_vert.h diff --git a/cocos/2d/ccShaders.cpp b/cocos/renderer/ccShaders.cpp similarity index 99% rename from cocos/2d/ccShaders.cpp rename to cocos/renderer/ccShaders.cpp index 8cfda5fc12..af48caa9fd 100644 --- a/cocos/2d/ccShaders.cpp +++ b/cocos/renderer/ccShaders.cpp @@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "2d/ccShaders.h" +#include "renderer/ccShaders.h" NS_CC_BEGIN // diff --git a/cocos/2d/ccShaders.h b/cocos/renderer/ccShaders.h similarity index 100% rename from cocos/2d/ccShaders.h rename to cocos/renderer/ccShaders.h diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 9c32d8d3aa..ed45b31083 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -25,8 +25,8 @@ THE SOFTWARE. #include "ui/UILayout.h" #include "ui/UIHelper.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" -#include "2d/CCGLProgram.h" -#include "2d/CCShaderCache.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCShaderCache.h" #include "base/CCDirector.h" #include "2d/CCDrawingPrimitives.h" #include "renderer/CCRenderer.h" diff --git a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp index a84b78cccd..a11a849541 100644 --- a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp @@ -30,7 +30,7 @@ #include "2d/CCActionTween.h" #include "2d/CCLabel.h" #include "2d/CCClippingNode.h" -#include "2d/ccShaders.h" +#include "renderer/ccShaders.h" #include "2d/CCRenderTexture.h" NS_CC_EXT_BEGIN diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 6d3155ad8d..820e2701f8 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -142,7 +142,7 @@ bool ShaderNode::initWithVertex(const char *vert, const char *frag) _time = 0; _resolution = Vector2(SIZE_X, SIZE_Y); - getGLProgramState()->getUniformValue("resolution")->setValue(_resolution); + getGLProgramState()->setUniformVec2("resolution", _resolution); scheduleUpdate(); @@ -171,7 +171,7 @@ void ShaderNode::setPosition(const Vector2 &newPosition) Node::setPosition(newPosition); auto position = getPosition(); _center = Vector2(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR()); - getGLProgramState()->getUniformValue("center")->setValue(_center); + getGLProgramState()->setUniformVec2("center", _center); } void ShaderNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -464,7 +464,7 @@ bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect) _samplingRadius = 0; this->initProgram(); - getGLProgramState()->getUniformValue("onePixelSize")->setValue(_pixelSize); + getGLProgramState()->setUniformVec2("onePixelSize", _pixelSize); return true; } @@ -547,7 +547,7 @@ void SpriteBlur::setBlurSize(float f) } log("_blurRadius:%d",_blurRadius); - getGLProgramState()->getUniformValue("gaussianCoefficient")->setValue(Vector4(_samplingRadius, _scale, _cons, _weightSum)); + getGLProgramState()->setUniformVec4("gaussianCoefficient", Vector4(_samplingRadius, _scale, _cons, _weightSum)); } // ShaderBlur diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h index 3bb1fb1b78..c1dea61c66 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h @@ -5,8 +5,6 @@ #include "extensions/cocos-ext.h" #include "../BaseTest.h" -#include "2d/CCGLProgramState.h" - USING_NS_CC_EXT; class ShaderTestDemo : public BaseTest diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 69af1af718..9d0ca4c730 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -22,6 +22,7 @@ THE SOFTWARE. ****************************************************************************/ + #include "ShaderTest2.h" #include "ShaderTest.h" #include "../testResource.h" @@ -297,8 +298,8 @@ void BlurSprite::setCustomUniforms() setBlurSize(3.0f); auto programState = getGLProgramState(); - programState->getUniformValue("onePixelSize")->setValue(_pixelSize); - programState->getUniformValue("gaussianCoefficient")->setValue(Vector4(_samplingRadius, _scale, _cons, _weightSum)); + programState->setUniformVec2("onePixelSize", _pixelSize); + programState->setUniformVec4("gaussianCoefficient", Vector4(_samplingRadius, _scale, _cons, _weightSum)); } void BlurSprite::setBlurSize(float f) @@ -357,7 +358,7 @@ void NoiseSprite::setCustomUniforms() { _resolution[0] = getTexture()->getContentSizeInPixels().width; _resolution[1] = getTexture()->getContentSizeInPixels().height; - getGLProgramState()->getUniformValue("resolution")->setValue(Vector2(_resolution[0],_resolution[1])); + getGLProgramState()->setUniformVec2("resolution", Vector2(_resolution[0],_resolution[1])); } class EdgeDetectionSprite : public ShaderSprite, public ShaderSpriteCreator @@ -384,7 +385,7 @@ void EdgeDetectionSprite::setCustomUniforms() _resolution[0] = getContentSize().width; _resolution[1] = getContentSize().height; - programState->getUniformValue("resolution")->setValue(Vector2(_resolution[0], _resolution[1])); + programState->setUniformVec2("resolution", Vector2(_resolution[0], _resolution[1])); } class BloomSprite : public ShaderSprite, public ShaderSpriteCreator @@ -432,7 +433,7 @@ void CelShadingSprite::setCustomUniforms() _resolution[0] = getContentSize().width; _resolution[1] = getContentSize().height; - programState->getUniformValue("resolution")->setValue(Vector2(_resolution[0], _resolution[1])); + programState->setUniformVec2("resolution", Vector2(_resolution[0], _resolution[1])); } class LensFlareSprite : public ShaderSprite, public ShaderSpriteCreator @@ -462,8 +463,8 @@ void LensFlareSprite::setCustomUniforms() _resolution[0] = getContentSize().width; _resolution[1] = getContentSize().height; - programState->getUniformValue("resolution")->setValue(Vector2(_resolution[0], _resolution[1])); - programState->getUniformValue("textureResolution")->setValue(Vector2(_textureResolution[0], _textureResolution[1])); + programState->setUniformVec2("resolution", Vector2(_resolution[0], _resolution[1])); + programState->setUniformVec2("textureResolution", Vector2(_textureResolution[0], _textureResolution[1])); } NormalSpriteTest::NormalSpriteTest() @@ -604,9 +605,9 @@ void OutlineSprite::setCustomUniforms() auto programState = getGLProgramState(); - programState->getUniformValue("u_outlineColor")->setValue(color); - programState->getUniformValue("u_radius")->setValue(radius); - programState->getUniformValue("u_threshold")->setValue(threshold); + programState->setUniformVec3("u_outlineColor", color); + programState->setUniformFloat("u_radius", radius); + programState->setUniformFloat("u_threshold", threshold); } @@ -673,8 +674,8 @@ void UniformSprite::draw(Renderer *renderer, const Matrix &transform, bool trans void UniformSprite::setCustomUniforms() { auto glprogramstate = getGLProgramState(); - glprogramstate->getUniformValue("center")->setValue(Vector2(480,320)); - glprogramstate->getUniformValue("resolution")->setValue(Vector2(256,256)); + glprogramstate->setUniformVec2("center", Vector2(480,320)); + glprogramstate->setUniformVec2("resolution", Vector2(256,256)); } void UniformSprite::onDraw(const Matrix &transform, bool transformUpdated) From 3ef1facfb04bef8cacdaa828b9933012a51c8112 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 09:29:07 +0800 Subject: [PATCH 027/174] issue #5057, replace deprecated enum with strong typed enum --- cocos/editor-support/cocostudio/CCSGUIReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 387e651e1c..f9daed77c2 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -1111,7 +1111,7 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va { if (!dynamic_cast(widget)) { - if (child->getPositionType() == cocos2d::ui::POSITION_PERCENT) + if (child->getPositionType() == ui::Widget::PositionType::PERCENT) { child->setPositionPercent(Vector2(child->getPositionPercent().x + 0.5f, child->getPositionPercent().y + 0.5f)); } From 1d7726133c9d0a6c19b50351fbd7509ad3871f7f Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 09:37:51 +0800 Subject: [PATCH 028/174] issue #5057, refactor enum SizeType to strong typed enum --- cocos/editor-support/cocostudio/CCSGUIReader.cpp | 2 +- .../cocostudio/WidgetReader/WidgetReader.cpp | 2 +- cocos/ui/UIDeprecated.h | 2 ++ cocos/ui/UIWidget.cpp | 8 ++++---- cocos/ui/UIWidget.h | 13 ++++++------- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index f9daed77c2..770f558da5 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -1133,7 +1133,7 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(Widget*widg widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, "ignoreSize")); } - widget->setSizeType((SizeType)DICTOOL->getIntValue_json(options, "sizeType")); + widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, "sizeType")); widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, "positionType")); widget->setSizePercent(Vector2(DICTOOL->getFloatValue_json(options, "sizePercentX"), DICTOOL->getFloatValue_json(options, "sizePercentY"))); diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index ea25ec0e70..f511bf3605 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -43,7 +43,7 @@ namespace cocostudio widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, "ignoreSize")); } - widget->setSizeType((SizeType)DICTOOL->getIntValue_json(options, "sizeType")); + widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, "sizeType")); widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, "positionType")); widget->setSizePercent(Vector2(DICTOOL->getFloatValue_json(options, "sizePercentX"), DICTOOL->getFloatValue_json(options, "sizePercentY"))); diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index de82e96d42..4d16d9da5b 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -18,6 +18,8 @@ namespace ui { CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_ABSOLUTE = Widget::PositionType::ABSOLUTE; CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_PERCENT = Widget::PositionType::PERCENT; +CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_ABSOLUTE = Widget::SizeType::ABSOLUTE; +CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_PERCENT = Widget::SizeType::PERCENT; } diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index 2a6d048d73..13a42b90b0 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -53,7 +53,7 @@ _size(Size::ZERO), _customSize(Size::ZERO), _ignoreSize(false), _affectByClipping(false), -_sizeType(SIZE_ABSOLUTE), +_sizeType(SizeType::ABSOLUTE), _sizePercent(Vector2::ZERO), _positionType(PositionType::ABSOLUTE), _positionPercent(Vector2::ZERO), @@ -271,7 +271,7 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize) { switch (_sizeType) { - case SIZE_ABSOLUTE: + case SizeType::ABSOLUTE: { if (_ignoreSize) { @@ -294,7 +294,7 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize) _sizePercent = Vector2(spx, spy); break; } - case SIZE_PERCENT: + case SizeType::PERCENT: { Size cSize = Size(parentSize.width * _sizePercent.x , parentSize.height * _sizePercent.y); if (_ignoreSize) @@ -343,7 +343,7 @@ void Widget::setSizeType(SizeType type) _sizeType = type; } -SizeType Widget::getSizeType() const +Widget::SizeType Widget::getSizeType() const { return _sizeType; } diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index b944953bbc..a60c71115a 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -60,13 +60,6 @@ typedef enum TOUCH_EVENT_ENDED, TOUCH_EVENT_CANCELED }TouchEventType; - -typedef enum -{ - SIZE_ABSOLUTE, - SIZE_PERCENT -}SizeType; - typedef void (Ref::*SEL_TouchEvent)(Ref*,TouchEventType); @@ -92,6 +85,12 @@ public: PERCENT }; + enum class SizeType + { + ABSOLUTE, + PERCENT + }; + /** * Default constructor */ From a699230e75b9ee539f64f4ae9bb10d7d4c962d10 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 09:39:18 +0800 Subject: [PATCH 029/174] issue #5057, replace license --- cocos/ui/UIDeprecated.h | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index 4d16d9da5b..12378de064 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -1,10 +1,26 @@ -// -// UIDeprecated.h -// cocos2d_libs -// -// Created by guanghui on 5/8/14. -// -// +/**************************************************************************** + 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 cocos2d_libs_UIDeprecated_h #define cocos2d_libs_UIDeprecated_h From 21e4d05e6e16851abaef957bae098dccd2d9f4b7 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 11:28:36 +0800 Subject: [PATCH 030/174] issue #5057, refactor SEL_TouchEvent to std::function --- cocos/ui/UIDeprecated.h | 5 ++++- cocos/ui/UIWidget.cpp | 35 ++++++++++++++++++++++++++++++++--- cocos/ui/UIWidget.h | 32 ++++++++++++++++++++++++++------ 3 files changed, 62 insertions(+), 10 deletions(-) diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index 12378de064..6e84204775 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -26,11 +26,12 @@ #define cocos2d_libs_UIDeprecated_h #include "base/CCPlatformMacros.h" -#include "UIWidget.h" +//#include "ui/UIWidget.h" NS_CC_BEGIN namespace ui { + CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_ABSOLUTE = Widget::PositionType::ABSOLUTE; CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_PERCENT = Widget::PositionType::PERCENT; @@ -38,6 +39,8 @@ CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_ABSOLUTE = Widget::SizeType: CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_PERCENT = Widget::SizeType::PERCENT; + + } diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index 13a42b90b0..f09d31ca8c 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -25,7 +25,6 @@ THE SOFTWARE. #include "ui/UIWidget.h" #include "ui/UILayout.h" #include "ui/UIHelper.h" -#include "ui/UIDeprecated.h" NS_CC_BEGIN @@ -73,15 +72,18 @@ _focusEnabled(true) Widget::~Widget() { - _touchEventListener = nullptr; - _touchEventSelector = nullptr; setTouchEnabled(false); + + //cleanup focused widget if (_focusedWidget == this) { _focusedWidget = nullptr; } if (_realFocusedWidget == this) { _realFocusedWidget = nullptr; } + + CC_SAFE_RELEASE_NULL(_touchEventListener); + } Widget* Widget::create() @@ -606,6 +608,10 @@ void Widget::onTouchCancelled(Touch *touch, Event *unusedEvent) void Widget::pushDownEvent() { + if (_touchEventCallback) { + _touchEventCallback(this, TouchEventType::BEGAN); + } + if (_touchEventListener && _touchEventSelector) { (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_BEGAN); @@ -614,6 +620,10 @@ void Widget::pushDownEvent() void Widget::moveEvent() { + if (_touchEventCallback) { + _touchEventCallback(this, TouchEventType::MOVED); + } + if (_touchEventListener && _touchEventSelector) { (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_MOVED); @@ -622,6 +632,11 @@ void Widget::moveEvent() void Widget::releaseUpEvent() { + + if (_touchEventCallback) { + _touchEventCallback(this, TouchEventType::ENDED); + } + if (_touchEventListener && _touchEventSelector) { (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_ENDED); @@ -630,16 +645,30 @@ void Widget::releaseUpEvent() void Widget::cancelUpEvent() { + if (_touchEventCallback) + { + _touchEventCallback(this, TouchEventType::CANCELED); + } + if (_touchEventListener && _touchEventSelector) { (_touchEventListener->*_touchEventSelector)(this,TOUCH_EVENT_CANCELED); } + } void Widget::addTouchEventListener(Ref *target, SEL_TouchEvent selector) { _touchEventListener = target; _touchEventSelector = selector; + CC_SAFE_RETAIN(target); + + +} + +void Widget::addTouchEventListener(Widget::ccWidgetTouchCallback callback) +{ + this->_touchEventCallback = callback; } bool Widget::hitTest(const Vector2 &pt) diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index a60c71115a..de6b8d86da 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -52,8 +52,10 @@ typedef enum UI_TEX_TYPE_LOCAL = 0, UI_TEX_TYPE_PLIST = 1 }TextureResType; - -typedef enum + + + +CC_DEPRECATED_ATTRIBUTE typedef enum { TOUCH_EVENT_BEGAN, TOUCH_EVENT_MOVED, @@ -61,9 +63,10 @@ typedef enum TOUCH_EVENT_CANCELED }TouchEventType; - -typedef void (Ref::*SEL_TouchEvent)(Ref*,TouchEventType); +CC_DEPRECATED_ATTRIBUTE typedef void (Ref::*SEL_TouchEvent)(Ref*,TouchEventType); #define toucheventselector(_SELECTOR) (SEL_TouchEvent)(&_SELECTOR) + + /** * @js NA * @lua NA @@ -91,6 +94,18 @@ public: PERCENT }; + enum class TouchEventType + { + BEGAN, + MOVED, + ENDED, + CANCELED + }; + + + typedef std::function ccWidgetTouchCallback; + + /** * Default constructor */ @@ -222,8 +237,8 @@ public: /** * Sets the touch event target/selector of the menu item */ - void addTouchEventListener(Ref* target,SEL_TouchEvent selector); - + CC_DEPRECATED_ATTRIBUTE void addTouchEventListener(Ref* target,SEL_TouchEvent selector); + void addTouchEventListener(ccWidgetTouchCallback callback); //cocos2d property @@ -639,8 +654,13 @@ protected: Vector2 _touchStartPos; ///< touch began point Vector2 _touchMovePos; ///< touch moved point Vector2 _touchEndPos; ///< touch ended point + + //if use the old API, we must retain the _touchEventListener Ref* _touchEventListener; SEL_TouchEvent _touchEventSelector; + + ccWidgetTouchCallback _touchEventCallback; + std::string _name; WidgetType _widgetType; int _actionTag; From 7d1cb7af47f2a343dbb6812fd688b358268cc55a Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 11:52:51 +0800 Subject: [PATCH 031/174] issue #5057, refactor UILoadingBarTest --- .../UILoadingBarTest/UILoadingBarTest.cpp | 52 +++++++++---------- .../UILoadingBarTest/UILoadingBarTest.h | 24 ++++----- .../UILoadingBarTest_Editor.cpp | 8 +-- .../UILoadingBarTest_Editor.h | 2 +- .../UITest/CocoStudioGUITest/UIScene.cpp | 28 +++++----- .../UITest/CocoStudioGUITest/UIScene.h | 10 ++-- .../CocoStudioGUITest/UIScene_Editor.cpp | 18 +++---- .../UITest/CocoStudioGUITest/UIScene_Editor.h | 6 +-- 8 files changed, 74 insertions(+), 74 deletions(-) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index 0e9abc1290..21f3e2dc7f 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -54,27 +54,27 @@ void UILoadingBarTest_Left::update(float delta) loadingBar->setPercent(_count); } -void UILoadingBarTest_Left::previousCallback(Ref* sender, TouchEventType type) +void UILoadingBarTest_Left::previousCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { unscheduleUpdate(); UIScene::previousCallback(sender, type); } } -void UILoadingBarTest_Left::restartCallback(Ref* sender, TouchEventType type) +void UILoadingBarTest_Left::restartCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { unscheduleUpdate(); UIScene::restartCallback(sender, type); } } -void UILoadingBarTest_Left::nextCallback(Ref* sender, TouchEventType type) +void UILoadingBarTest_Left::nextCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { unscheduleUpdate(); UIScene::nextCallback(sender, type); @@ -134,27 +134,27 @@ void UILoadingBarTest_Right::update(float delta) loadingBar->setPercent(_count); } -void UILoadingBarTest_Right::previousCallback(Ref* sender, TouchEventType type) +void UILoadingBarTest_Right::previousCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { unscheduleUpdate(); UIScene::previousCallback(sender, type); } } -void UILoadingBarTest_Right::restartCallback(Ref* sender, TouchEventType type) +void UILoadingBarTest_Right::restartCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { unscheduleUpdate(); UIScene::restartCallback(sender, type); } } -void UILoadingBarTest_Right::nextCallback(Ref* sender, TouchEventType type) +void UILoadingBarTest_Right::nextCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { unscheduleUpdate(); UIScene::nextCallback(sender, type); @@ -216,27 +216,27 @@ void UILoadingBarTest_Left_Scale9::update(float delta) loadingBar->setPercent(_count); } -void UILoadingBarTest_Left_Scale9::previousCallback(Ref* sender, TouchEventType type) +void UILoadingBarTest_Left_Scale9::previousCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { unscheduleUpdate(); UIScene::previousCallback(sender, type); } } -void UILoadingBarTest_Left_Scale9::restartCallback(Ref* sender, TouchEventType type) +void UILoadingBarTest_Left_Scale9::restartCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { unscheduleUpdate(); - UIScene::restartCallback(sender, type); + UIScene::restartCallback(sender, type); } } -void UILoadingBarTest_Left_Scale9::nextCallback(Ref* sender, TouchEventType type) +void UILoadingBarTest_Left_Scale9::nextCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { unscheduleUpdate(); UIScene::nextCallback(sender, type); @@ -299,27 +299,27 @@ void UILoadingBarTest_Right_Scale9::update(float delta) loadingBar->setPercent(_count); } -void UILoadingBarTest_Right_Scale9::previousCallback(Ref* sender, TouchEventType type) +void UILoadingBarTest_Right_Scale9::previousCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { unscheduleUpdate(); UIScene::previousCallback(sender, type); } } -void UILoadingBarTest_Right_Scale9::restartCallback(Ref* sender, TouchEventType type) +void UILoadingBarTest_Right_Scale9::restartCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { unscheduleUpdate(); - UIScene::restartCallback(sender, type); + UIScene::restartCallback(sender, type); } } -void UILoadingBarTest_Right_Scale9::nextCallback(Ref* sender, TouchEventType type) +void UILoadingBarTest_Right_Scale9::nextCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { unscheduleUpdate(); UIScene::nextCallback(sender, type); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h index 7afae165b8..7bb1406672 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h @@ -35,9 +35,9 @@ public: bool init(); void update(float delta); - virtual void previousCallback(Ref* sender, TouchEventType type) override; - virtual void restartCallback(Ref* sender, TouchEventType type) override; - virtual void nextCallback(Ref* sender, TouchEventType type) override; + virtual void previousCallback(Ref* sender, Widget::TouchEventType type) override; + virtual void restartCallback(Ref* sender, Widget::TouchEventType type) override; + virtual void nextCallback(Ref* sender, Widget::TouchEventType type) override; protected: UI_SCENE_CREATE_FUNC(UILoadingBarTest_Left) @@ -52,9 +52,9 @@ public: bool init(); void update(float delta); - virtual void previousCallback(Ref* sender, TouchEventType type) override; - virtual void restartCallback(Ref* sender, TouchEventType type) override; - virtual void nextCallback(Ref* sender, TouchEventType type) override; + virtual void previousCallback(Ref* sender, Widget::TouchEventType type) override; + virtual void restartCallback(Ref* sender, Widget::TouchEventType type) override; + virtual void nextCallback(Ref* sender, Widget::TouchEventType type) override; protected: UI_SCENE_CREATE_FUNC(UILoadingBarTest_Right) @@ -69,9 +69,9 @@ public: bool init(); void update(float delta); - virtual void previousCallback(Ref* sender, TouchEventType type) override; - virtual void restartCallback(Ref* sender, TouchEventType type) override; - virtual void nextCallback(Ref* sender, TouchEventType type) override; + virtual void previousCallback(Ref* sender, Widget::TouchEventType type) override; + virtual void restartCallback(Ref* sender, Widget::TouchEventType type) override; + virtual void nextCallback(Ref* sender, Widget::TouchEventType type) override; protected: UI_SCENE_CREATE_FUNC(UILoadingBarTest_Left_Scale9) @@ -86,9 +86,9 @@ public: bool init(); void update(float delta); - virtual void previousCallback(Ref* sender, TouchEventType type) override; - virtual void restartCallback(Ref* sender, TouchEventType type) override; - virtual void nextCallback(Ref* sender, TouchEventType type) override; + virtual void previousCallback(Ref* sender, Widget::TouchEventType type) override; + virtual void restartCallback(Ref* sender, Widget::TouchEventType type) override; + virtual void nextCallback(Ref* sender, Widget::TouchEventType type) override; protected: UI_SCENE_CREATE_FUNC(UILoadingBarTest_Right_Scale9) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp index 7d5f9b3ac8..e13deddca0 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp @@ -64,15 +64,15 @@ void UILoadingBarTest_Editor::update(float delta) loadingBar_right_to_left->setPercent(_count); } -void UILoadingBarTest_Editor::toCocosGUITestScene(Ref *sender, TouchEventType type) +void UILoadingBarTest_Editor::toCocosGUITestScene(Widget::TouchEventType event) { - switch (type) + switch (event) { - case TOUCH_EVENT_ENDED: + case Widget::TouchEventType::ENDED: { unscheduleUpdate(); - UIScene_Editor::toGUIEditorTestScene(sender, type); + UIScene_Editor::toGUIEditorTestScene(event); } break; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.h index 84d9fedf1f..890caa38cf 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.h @@ -12,7 +12,7 @@ public: ~UILoadingBarTest_Editor(); bool init(); void update(float delta); - void toCocosGUITestScene(Ref* sender, TouchEventType type); + void toCocosGUITestScene(Widget::TouchEventType event); protected: UI_SCENE_EDITOR_CREATE_FUNC(UILoadingBarTest_Editor) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.cpp index 7c7608295c..5f95948878 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.cpp @@ -39,16 +39,16 @@ bool UIScene::init() _sceneTitle = dynamic_cast(root->getChildByName("UItest")); Text* back_label = dynamic_cast(root->getChildByName("back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene::toCocosGUITestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene::toCocosGUITestScene, this)); Button* left_button = dynamic_cast(root->getChildByName("left_Button")); - left_button->addTouchEventListener(this, toucheventselector(UIScene::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene::previousCallback, this)); Button* middle_button = dynamic_cast(root->getChildByName("middle_Button")); - middle_button->addTouchEventListener(this, toucheventselector(UIScene::restartCallback)); + middle_button->addTouchEventListener(CC_CALLBACK_2(UIScene::restartCallback, this)); Button* right_button = dynamic_cast(root->getChildByName("right_Button")); - right_button->addTouchEventListener(this, toucheventselector(UIScene::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene::nextCallback, this)); /* Text* mainMenuLabel = Text::create(); @@ -67,18 +67,18 @@ bool UIScene::init() return false; } -void UIScene::menuCloseCallback(Ref* pSender, TouchEventType type) +void UIScene::menuCloseCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { _uiLayer->removeFromParent(); } } -void UIScene::toCocosGUITestScene(Ref* sender, TouchEventType type) +void UIScene::toCocosGUITestScene(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { UISceneManager::purgeUISceneManager(); @@ -88,25 +88,25 @@ void UIScene::toCocosGUITestScene(Ref* sender, TouchEventType type) } } -void UIScene::previousCallback(Ref* sender, TouchEventType type) +void UIScene::previousCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { CCDirector::getInstance()->replaceScene(UISceneManager::sharedUISceneManager()->previousUIScene()); } } -void UIScene::restartCallback(Ref* sender, TouchEventType type) +void UIScene::restartCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { CCDirector::getInstance()->replaceScene(UISceneManager::sharedUISceneManager()->currentUIScene()); } } -void UIScene::nextCallback(Ref* sender, TouchEventType type) +void UIScene::nextCallback(Ref* sender, Widget::TouchEventType type) { - if (type == TOUCH_EVENT_ENDED) + if (type == Widget::TouchEventType::ENDED) { CCDirector::getInstance()->replaceScene(UISceneManager::sharedUISceneManager()->nextUIScene()); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.h index 99b0ae12ee..eb1c77c1a2 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.h @@ -59,10 +59,10 @@ public: ~UIScene(); bool init(); // Menu Callbacks - void toCocosGUITestScene(Ref* sender, TouchEventType type); - virtual void previousCallback(Ref* sender, TouchEventType type); - virtual void restartCallback(Ref* sender, TouchEventType type); - virtual void nextCallback(Ref* sender, TouchEventType type); + void toCocosGUITestScene(Ref* sender, Widget::TouchEventType type); + virtual void previousCallback(Ref* sender, Widget::TouchEventType type); + virtual void restartCallback(Ref* sender, Widget::TouchEventType type); + virtual void nextCallback(Ref* sender, Widget::TouchEventType type); /** Title label of the scene. */ CC_SYNTHESIZE_READONLY(Text*, _sceneTitle, SceneTitle) @@ -71,7 +71,7 @@ public: protected: // a selector callback - void menuCloseCallback(Ref* pSender, TouchEventType type); + void menuCloseCallback(Ref* sender, Widget::TouchEventType type); protected: Layer* _uiLayer; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp index 2480dfc3ba..a7155df080 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp @@ -32,11 +32,11 @@ bool UIScene_Editor::init() return false; } -void UIScene_Editor::previousCallback(Ref *sender, TouchEventType type) +void UIScene_Editor::previousCallback(Widget::TouchEventType event) { - switch (type) + switch (event) { - case TOUCH_EVENT_ENDED: + case Widget::TouchEventType::ENDED: CCDirector::getInstance()->replaceScene(UISceneManager_Editor::sharedUISceneManager_Editor()->previousUIScene()); break; @@ -45,11 +45,11 @@ void UIScene_Editor::previousCallback(Ref *sender, TouchEventType type) } } -void UIScene_Editor::nextCallback(Ref *sender, TouchEventType type) +void UIScene_Editor::nextCallback(Widget::TouchEventType event) { - switch (type) + switch (event) { - case TOUCH_EVENT_ENDED: + case Widget::TouchEventType::ENDED: CCDirector::getInstance()->replaceScene(UISceneManager_Editor::sharedUISceneManager_Editor()->nextUIScene()); break; @@ -58,11 +58,11 @@ void UIScene_Editor::nextCallback(Ref *sender, TouchEventType type) } } -void UIScene_Editor::toGUIEditorTestScene(Ref *sender, TouchEventType type) +void UIScene_Editor::toGUIEditorTestScene(Widget::TouchEventType event) { - switch (type) + switch (event) { - case TOUCH_EVENT_ENDED: + case Widget::TouchEventType::ENDED: { UISceneManager_Editor::sharedUISceneManager_Editor()->purge(); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.h index cf3ce97fab..5602b7beb1 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.h @@ -60,10 +60,10 @@ public: ~UIScene_Editor(); bool init(); - virtual void previousCallback(Ref* sender, TouchEventType type); - virtual void nextCallback(Ref* sender, TouchEventType type); + virtual void previousCallback(Widget::TouchEventType event); + virtual void nextCallback(Widget::TouchEventType event); - void toGUIEditorTestScene(Ref* sender, TouchEventType type); + void toGUIEditorTestScene(Widget::TouchEventType event); /** Title label of the scene.*/ CC_SYNTHESIZE_READONLY(Text*, _sceneTitle, SceneTitle) From 95e036dd1b95d74dd3ff52d35387fb87d1bbfd17 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Thu, 8 May 2014 21:54:49 -0700 Subject: [PATCH 032/174] GLProgramStateCache --- build/cocos2d_libs.xcodeproj/project.pbxproj | 12 +++ cocos/2d/CCNode.cpp | 8 +- cocos/renderer/CCGLProgramState.cpp | 22 +++-- cocos/renderer/CCGLProgramState.h | 3 +- cocos/renderer/CCGLProgramStateCache.cpp | 89 ++++++++++++++++++++ cocos/renderer/CCGLProgramStateCache.h | 69 +++++++++++++++ 6 files changed, 190 insertions(+), 13 deletions(-) create mode 100644 cocos/renderer/CCGLProgramStateCache.cpp create mode 100644 cocos/renderer/CCGLProgramStateCache.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 496a2b75d0..e9a80d99ff 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1067,6 +1067,10 @@ 3E26D40518ACB5D100834404 /* CCImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E26D40418ACB5D100834404 /* CCImage.cpp */; }; 3E26D40618ACB5D100834404 /* CCImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E26D40418ACB5D100834404 /* CCImage.cpp */; }; 3E26D40818ACB63900834404 /* CCDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E26D40718ACB63900834404 /* CCDevice.mm */; }; + 3E9C7E5C191C61EB00429574 /* CCGLProgramStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9C7E5A191C61EB00429574 /* CCGLProgramStateCache.cpp */; }; + 3E9C7E5D191C61EB00429574 /* CCGLProgramStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9C7E5A191C61EB00429574 /* CCGLProgramStateCache.cpp */; }; + 3E9C7E5E191C61EB00429574 /* CCGLProgramStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9C7E5B191C61EB00429574 /* CCGLProgramStateCache.h */; }; + 3E9C7E5F191C61EB00429574 /* CCGLProgramStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9C7E5B191C61EB00429574 /* CCGLProgramStateCache.h */; }; 3EA0FB5B191B92CC00B170C8 /* UIVideoWidget.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA0FB59191B92CC00B170C8 /* UIVideoWidget.h */; }; 3EA0FB5C191B92CC00B170C8 /* UIVideoWidgetIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3EA0FB5A191B92CC00B170C8 /* UIVideoWidgetIOS.mm */; }; 460E468118080832000CDD6D /* cocos-ext.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A167D21807AF4D005B8026 /* cocos-ext.h */; }; @@ -2292,6 +2296,8 @@ 37936A3E1869B76800E974DD /* writer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = writer.h; sourceTree = ""; }; 3E26D40418ACB5D100834404 /* CCImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCImage.cpp; sourceTree = ""; }; 3E26D40718ACB63900834404 /* CCDevice.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CCDevice.mm; sourceTree = ""; }; + 3E9C7E5A191C61EB00429574 /* CCGLProgramStateCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgramStateCache.cpp; sourceTree = ""; }; + 3E9C7E5B191C61EB00429574 /* CCGLProgramStateCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgramStateCache.h; sourceTree = ""; }; 3EA0FB59191B92CC00B170C8 /* UIVideoWidget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIVideoWidget.h; sourceTree = ""; }; 3EA0FB5A191B92CC00B170C8 /* UIVideoWidgetIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIVideoWidgetIOS.mm; sourceTree = ""; }; 46A15FCC1807A544005B8026 /* AUTHORS */ = {isa = PBXFileReference; lastKnownFileType = text; name = AUTHORS; path = ../AUTHORS; sourceTree = ""; }; @@ -4609,6 +4615,8 @@ 500DC89819105D41007B91BF /* renderer */ = { isa = PBXGroup; children = ( + 3E9C7E5A191C61EB00429574 /* CCGLProgramStateCache.cpp */, + 3E9C7E5B191C61EB00429574 /* CCGLProgramStateCache.h */, 5034C9F4191C5D6800CE6051 /* Shaders */, 5034C993191C5D4500CE6051 /* ccShaders.h */, 5034C994191C5D4500CE6051 /* ccShaders.cpp */, @@ -4923,6 +4931,7 @@ 2905FA4818CF08D100240AA3 /* UIButton.h in Headers */, 46A170EB1807CECA005B8026 /* CCPhysicsJoint.h in Headers */, 46A170241807CBFC005B8026 /* CCSAXParser.h in Headers */, + 3E9C7E5E191C61EB00429574 /* CCGLProgramStateCache.h in Headers */, 46A1701A1807CBFC005B8026 /* CCDevice.h in Headers */, B2AF2F9F18EBAEAE00C5807C /* Quaternion.h in Headers */, 46A170161807CBFC005B8026 /* CCLock.h in Headers */, @@ -5590,6 +5599,7 @@ 1A570332180BCFD50088DEC7 /* CCUserDefault.h in Headers */, 500DC94319106300007B91BF /* CCData.h in Headers */, 1A57034E180BD09B0088DEC7 /* tinyxml2.h in Headers */, + 3E9C7E5F191C61EB00429574 /* CCGLProgramStateCache.h in Headers */, 1A570357180BD0B00088DEC7 /* ioapi.h in Headers */, 1A01C69B18F57BE800EFE3A6 /* CCSet.h in Headers */, 1A57035B180BD0B00088DEC7 /* unzip.h in Headers */, @@ -6271,6 +6281,7 @@ 1AD71DCD180E26E600808F54 /* CCControlLoader.cpp in Sources */, 50FCEBC718C72017004AD434 /* WidgetReader.cpp in Sources */, 1AD71DD1180E26E600808F54 /* CCLabelBMFontLoader.cpp in Sources */, + 3E9C7E5C191C61EB00429574 /* CCGLProgramStateCache.cpp in Sources */, 1AD71DD5180E26E600808F54 /* CCLabelTTFLoader.cpp in Sources */, 1AD71DD9180E26E600808F54 /* CCLayerColorLoader.cpp in Sources */, 500DC94C19106300007B91BF /* CCEvent.cpp in Sources */, @@ -6576,6 +6587,7 @@ 50FCEB9818C72017004AD434 /* CheckBoxReader.cpp in Sources */, 1A570076180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */, 500DC99D19106300007B91BF /* CCValue.cpp in Sources */, + 3E9C7E5D191C61EB00429574 /* CCGLProgramStateCache.cpp in Sources */, 3EA0FB5C191B92CC00B170C8 /* UIVideoWidgetIOS.mm in Sources */, B37510851823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */, 1A57007A180BC5A10088DEC7 /* CCActionInstant.cpp in Sources */, diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 273b3427fe..268995e87d 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -644,14 +644,12 @@ void Node::setGLProgramState(cocos2d::GLProgramState *glProgramState) void Node::setGLProgram(GLProgram *glProgram) { - if(_glProgramState == nullptr) { + if (_glProgramState == nullptr || (_glProgramState && _glProgramState->getGLProgram() != glProgram)) + { + CC_SAFE_RELEASE(_glProgramState); _glProgramState = GLProgramState::create(glProgram); _glProgramState->retain(); } - else - { - _glProgramState->setGLProgram(glProgram); - } } GLProgram * Node::getGLProgram() diff --git a/cocos/renderer/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp index 6bdb2aaab0..ef212b98bf 100644 --- a/cocos/renderer/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -29,6 +29,7 @@ THE SOFTWARE. #include "renderer/CCGLProgramState.h" #include "renderer/CCGLProgram.h" #include "renderer/ccGLStateCache.h" +#include "renderer/CCGLProgramStateCache.h" NS_CC_BEGIN @@ -203,15 +204,21 @@ void VertexAttribValue::setPointer(GLint size, GLenum type, GLboolean normalized // // -GLProgramState* GLProgramState::create(GLProgram *glprogram) +GLProgramState* GLProgramState::create(GLProgram *glprogram, bool useCache) { - auto ret = new (std::nothrow) GLProgramState; - if(ret && ret->init(glprogram)) { - ret->autorelease(); - return ret; + GLProgramState* ret = nullptr; + if (useCache) + { + ret = GLProgramStateCache::getInstance()->getProgramState(glprogram); } - CC_SAFE_RELEASE(ret); - return nullptr; + else + { + ret = new (std::nothrow) GLProgramState; + if(!ret || !ret->init(glprogram)) + CC_SAFE_RELEASE(ret); + } + + return ret; } GLProgramState::GLProgramState() @@ -221,6 +228,7 @@ GLProgramState::GLProgramState() GLProgramState::~GLProgramState() { + GLProgramStateCache::getInstance()->removeProgramState(_glprogram); _glprogram->release(); } diff --git a/cocos/renderer/CCGLProgramState.h b/cocos/renderer/CCGLProgramState.h index b52d08fd09..ee37f56635 100644 --- a/cocos/renderer/CCGLProgramState.h +++ b/cocos/renderer/CCGLProgramState.h @@ -136,8 +136,9 @@ protected: // class GLProgramState : public Ref { + friend class GLProgramStateCache; public: - static GLProgramState* create(GLProgram* glprogram); + static GLProgramState* create(GLProgram* glprogram, bool useCache = true); void apply(const Matrix& modelView); diff --git a/cocos/renderer/CCGLProgramStateCache.cpp b/cocos/renderer/CCGLProgramStateCache.cpp new file mode 100644 index 0000000000..35b52f95c6 --- /dev/null +++ b/cocos/renderer/CCGLProgramStateCache.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +Copyright 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 false 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 "renderer/CCGLProgramStateCache.h" +#include "renderer/CCGLProgramState.h" +#include "renderer/CCGLProgram.h" + + +NS_CC_BEGIN + +GLProgramStateCache* GLProgramStateCache::s_instance = nullptr; + +GLProgramStateCache::GLProgramStateCache() +{ + s_instance = nullptr; +} + +GLProgramStateCache::~GLProgramStateCache() +{ + for (auto itr = _glProgramStates.begin(); itr != _glProgramStates.end(); itr++) { + itr->second->release(); + } + _glProgramStates.clear(); + s_instance = nullptr; +} + +GLProgramStateCache* GLProgramStateCache::getInstance() +{ + if (s_instance == nullptr) + s_instance = new GLProgramStateCache(); + + return s_instance; +} + +void GLProgramStateCache::destroyInstance() +{ + delete s_instance; +} + +GLProgramState* GLProgramStateCache::getProgramState(GLProgram* glprogram) +{ + const auto& itr = _glProgramStates.find(glprogram); + if (itr != _glProgramStates.end()) + { + return itr->second; + } + + auto ret = new (std::nothrow) GLProgramState; + if(ret && ret->init(glprogram)) { + _glProgramStates[glprogram] = ret; + ret->autorelease(); + return ret; + } + + CC_SAFE_RELEASE(ret); + return ret; +} + +void GLProgramStateCache::removeProgramState(GLProgram* program) +{ + auto itr = _glProgramStates.find(program); + if (itr != _glProgramStates.end()) + { + _glProgramStates.erase(itr); + } +} + +NS_CC_END diff --git a/cocos/renderer/CCGLProgramStateCache.h b/cocos/renderer/CCGLProgramStateCache.h new file mode 100644 index 0000000000..5a1564a8be --- /dev/null +++ b/cocos/renderer/CCGLProgramStateCache.h @@ -0,0 +1,69 @@ +/**************************************************************************** +Copyright 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 __CCGLPROGRAMSTATECACHE_H__ +#define __CCGLPROGRAMSTATECACHE_H__ + +#include "base/ccTypes.h" +#include "base/CCVector.h" +#include "math/Vector2.h" +#include "math/Vector3.h" +#include "math/Vector4.h" + +#include + +NS_CC_BEGIN + +class GLProgram; + +class GLProgramState; + +// +// +// GLProgramStateCache +// +// +class GLProgramStateCache +{ +public: + static GLProgramStateCache* getInstance(); + + static void destroyInstance(); + + GLProgramState* getProgramState(GLProgram* program); + + void removeProgramState(GLProgram* program); + +protected: + GLProgramStateCache(); + + ~GLProgramStateCache(); + + std::unordered_map _glProgramStates; + static GLProgramStateCache* s_instance; +}; + +NS_CC_END + +#endif /* __CCGLPROGRAMSTATECACHE_H__ */ From 57ce0ee2cf01d836285dd727f2c80fec5beba364 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 14:30:39 +0800 Subject: [PATCH 033/174] issue #5057, refactor addTouchEventListener to std::function<> --- cocos/ui/UIDeprecated.h | 1 + .../CocoStudioSceneTest/SceneEditorTest.cpp | 7 +-- .../CocoStudioSceneTest/SceneEditorTest.h | 2 +- .../UITest/CocoStudioGUITest/CustomGUIScene.h | 2 +- .../UIButtonTest/UIButtonTest.cpp | 52 +++++++++--------- .../UIButtonTest/UIButtonTest.h | 8 +-- .../UIButtonTest/UIButtonTest_Editor.cpp | 22 ++++---- .../UIButtonTest/UIButtonTest_Editor.h | 2 +- .../UICheckBoxTest/UICheckBoxTest_Editor.cpp | 2 +- .../UIFocusTest/UIFocusTest.cpp | 54 +++++++++---------- .../UIFocusTest/UIFocusTest.h | 12 ++--- .../UIImageViewTest_Editor.cpp | 2 +- .../UILayoutTest/UILayoutTest_Editor.cpp | 54 +++++++++---------- .../UIListViewTest/UIListViewTest_Editor.cpp | 14 ++--- .../UILoadingBarTest_Editor.cpp | 7 +-- .../UILoadingBarTest_Editor.h | 2 +- .../UIPageViewTest/UIPageViewTest_Editor.cpp | 6 +-- .../UIRichTextTest/UIRichTextTest.cpp | 7 +-- .../UIRichTextTest/UIRichTextTest.h | 2 +- .../CocoStudioGUITest/UIScene_Editor.cpp | 6 +-- .../UITest/CocoStudioGUITest/UIScene_Editor.h | 6 +-- .../UIScrollViewTest_Editor.cpp | 30 +++++------ .../UISliderTest/UISliderTest_Editor.cpp | 2 +- .../UITextAtlasTest_Editor.cpp | 2 +- .../UITextBMFontTest_Editor.cpp | 2 +- .../UITextFieldTest_Editor.cpp | 2 +- .../UITextTest/UITextTest_Editor.cpp | 2 +- .../UIWidgetAddNodeTest_Editor.cpp | 2 +- 28 files changed, 163 insertions(+), 149 deletions(-) diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index 6e84204775..997e930fd3 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -39,6 +39,7 @@ CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_ABSOLUTE = Widget::SizeType: CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_PERCENT = Widget::SizeType::PERCENT; + } diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index 53a0d0697b..d2f2781d42 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -399,16 +399,17 @@ cocos2d::Node* UIComponentTest::createGameScene() ComRender *render = static_cast(_node->getChildByTag(10025)->getComponent("GUIComponent")); Widget* widget = static_cast(render->getNode()); Button* button = static_cast(widget->getChildByName("Button_156")); - button->addTouchEventListener(this, toucheventselector(UIComponentTest::touchEvent)); +// button->addTouchEventListener(this, toucheventselector(UIComponentTest::touchEvent)); + button->addTouchEventListener(CC_CALLBACK_2(UIComponentTest::touchEvent, this)); return node; } -void UIComponentTest::touchEvent(Ref *pSender, TouchEventType type) +void UIComponentTest::touchEvent(Ref *pSender, ui::Widget::TouchEventType type) { switch (type) { - case TOUCH_EVENT_BEGAN: + case ui::Widget::TouchEventType::BEGAN: { ComRender *pBlowFish = static_cast(_node->getChildByTag(10010)->getComponent("CCArmature")); pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, Vector2(-1000.0f, 0))); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h index 050e5339a7..3b3704e474 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h @@ -100,7 +100,7 @@ public: virtual void onEnter() override; virtual void onExit() override; cocos2d::Node* createGameScene(); - void touchEvent(cocos2d::Ref *pSender, cocos2d::ui::TouchEventType type); + void touchEvent(cocos2d::Ref *pSender, ui::Widget::TouchEventType type); private: cocos2d::Node* _node; }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomGUIScene.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomGUIScene.h index 09e14a24af..b685b6b1d5 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomGUIScene.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomGUIScene.h @@ -19,7 +19,7 @@ public: void onTouchesBegan(const std::vector& touches, Event *event); // void onTouchesMoved(const std::vector& touches, Event *event); - void touchEvent(Ref* pSender, TouchEventType type); + void touchEvent(Ref* pSender, Widget::TouchEventType type); private: Vector2 _beginPos; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp index 221196c2b0..bcc8146bfe 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp @@ -39,7 +39,8 @@ bool UIButtonTest::init() Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - button->addTouchEventListener(this, toucheventselector(UIButtonTest::touchEvent)); +// button->addTouchEventListener(this, toucheventselector(UIButtonTest::touchEvent)); + button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest::touchEvent, this)); _uiLayer->addChild(button); return true; @@ -47,23 +48,23 @@ bool UIButtonTest::init() return false; } -void UIButtonTest::touchEvent(Ref *pSender, TouchEventType type) +void UIButtonTest::touchEvent(Ref *pSender, Widget::TouchEventType type) { switch (type) { - case TOUCH_EVENT_BEGAN: + case Widget::TouchEventType::BEGAN: _displayValueLabel->setText(String::createWithFormat("Touch Down")->getCString()); break; - case TOUCH_EVENT_MOVED: + case Widget::TouchEventType::MOVED: _displayValueLabel->setText(String::createWithFormat("Touch Move")->getCString()); break; - case TOUCH_EVENT_ENDED: + case Widget::TouchEventType::ENDED: _displayValueLabel->setText(String::createWithFormat("Touch Up")->getCString()); break; - case TOUCH_EVENT_CANCELED: + case Widget::TouchEventType::CANCELED: _displayValueLabel->setText(String::createWithFormat("Touch Cancelled")->getCString()); break; @@ -110,7 +111,8 @@ bool UIButtonTest_Scale9::init() button->setScale9Enabled(true); button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); button->setSize(Size(150, 70)); - button->addTouchEventListener(this, toucheventselector(UIButtonTest_Scale9::touchEvent)); +// button->addTouchEventListener(this, toucheventselector(UIButtonTest_Scale9::touchEvent)); + button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Scale9::touchEvent, this)); _uiLayer->addChild(button); return true; @@ -118,23 +120,23 @@ bool UIButtonTest_Scale9::init() return false; } -void UIButtonTest_Scale9::touchEvent(Ref *pSender, TouchEventType type) +void UIButtonTest_Scale9::touchEvent(Ref *pSender, Widget::TouchEventType type) { switch (type) { - case TOUCH_EVENT_BEGAN: + case Widget::TouchEventType::BEGAN: _displayValueLabel->setText(String::createWithFormat("Touch Down")->getCString()); break; - case TOUCH_EVENT_MOVED: + case Widget::TouchEventType::MOVED: _displayValueLabel->setText(String::createWithFormat("Touch Move")->getCString()); break; - case TOUCH_EVENT_ENDED: + case Widget::TouchEventType::ENDED: _displayValueLabel->setText(String::createWithFormat("Touch Up")->getCString()); break; - case TOUCH_EVENT_CANCELED: + case Widget::TouchEventType::CANCELED: _displayValueLabel->setText(String::createWithFormat("Touch Cancelled")->getCString()); break; @@ -178,7 +180,8 @@ bool UIButtonTest_PressedAction::init() Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png"); button->setPressedActionEnabled(true); button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - button->addTouchEventListener(this, toucheventselector(UIButtonTest_PressedAction::touchEvent)); +// button->addTouchEventListener(this, toucheventselector(UIButtonTest_PressedAction::touchEvent)); + button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_PressedAction::touchEvent, this)); _uiLayer->addChild(button); return true; @@ -186,23 +189,23 @@ bool UIButtonTest_PressedAction::init() return false; } -void UIButtonTest_PressedAction::touchEvent(Ref *pSender, TouchEventType type) +void UIButtonTest_PressedAction::touchEvent(Ref *pSender, Widget::TouchEventType type) { switch (type) { - case TOUCH_EVENT_BEGAN: + case Widget::TouchEventType::BEGAN: _displayValueLabel->setText(String::createWithFormat("Touch Down")->getCString()); break; - case TOUCH_EVENT_MOVED: + case Widget::TouchEventType::MOVED: _displayValueLabel->setText(String::createWithFormat("Touch Move")->getCString()); break; - case TOUCH_EVENT_ENDED: + case Widget::TouchEventType::ENDED: _displayValueLabel->setText(String::createWithFormat("Touch Up")->getCString()); break; - case TOUCH_EVENT_CANCELED: + case Widget::TouchEventType::CANCELED: _displayValueLabel->setText(String::createWithFormat("Touch Cancelled")->getCString()); break; @@ -246,7 +249,8 @@ bool UIButtonTest_Title::init() Button* button = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png"); button->setTitleText("Title Button"); button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - button->addTouchEventListener(this, toucheventselector(UIButtonTest_Title::touchEvent)); +// button->addTouchEventListener(this, toucheventselector(UIButtonTest_Title::touchEvent)); + button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Title::touchEvent, this)); _uiLayer->addChild(button); return true; @@ -255,23 +259,23 @@ bool UIButtonTest_Title::init() } -void UIButtonTest_Title::touchEvent(Ref *pSender, TouchEventType type) +void UIButtonTest_Title::touchEvent(Ref *pSender, Widget::TouchEventType type) { switch (type) { - case TOUCH_EVENT_BEGAN: + case Widget::TouchEventType::BEGAN: _displayValueLabel->setText(String::createWithFormat("Touch Down")->getCString()); break; - case TOUCH_EVENT_MOVED: + case Widget::TouchEventType::MOVED: _displayValueLabel->setText(String::createWithFormat("Touch Move")->getCString()); break; - case TOUCH_EVENT_ENDED: + case Widget::TouchEventType::ENDED: _displayValueLabel->setText(String::createWithFormat("Touch Up")->getCString()); break; - case TOUCH_EVENT_CANCELED: + case Widget::TouchEventType::CANCELED: _displayValueLabel->setText(String::createWithFormat("Touch Cancelled")->getCString()); break; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h index 7ac14a24f2..0cf2f01c8f 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h @@ -33,7 +33,7 @@ public: UIButtonTest(); ~UIButtonTest(); bool init(); - void touchEvent(Ref *pSender, TouchEventType type); + void touchEvent(Ref *pSender, Widget::TouchEventType type); protected: UI_SCENE_CREATE_FUNC(UIButtonTest) @@ -46,7 +46,7 @@ public: UIButtonTest_Scale9(); ~UIButtonTest_Scale9(); bool init(); - void touchEvent(Ref *pSender, TouchEventType type); + void touchEvent(Ref *pSender, Widget::TouchEventType type); protected: UI_SCENE_CREATE_FUNC(UIButtonTest_Scale9) @@ -59,7 +59,7 @@ public: UIButtonTest_PressedAction(); ~UIButtonTest_PressedAction(); bool init(); - void touchEvent(Ref *pSender, TouchEventType type); + void touchEvent(Ref *pSender, Widget::TouchEventType type); protected: UI_SCENE_CREATE_FUNC(UIButtonTest_PressedAction) @@ -72,7 +72,7 @@ public: UIButtonTest_Title(); ~UIButtonTest_Title(); bool init(); - void touchEvent(Ref *pSender, TouchEventType type); + void touchEvent(Ref *pSender, Widget::TouchEventType type); protected: UI_SCENE_CREATE_FUNC(UIButtonTest_Title) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp index 554e7763a0..26ab2f1ee6 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp @@ -30,18 +30,22 @@ bool UIButtonTest_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); +// back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); Button* button = static_cast(Helper::seekWidgetByName(root, "Button_123")); - button->addTouchEventListener(this, toucheventselector(UIButtonTest_Editor::touchEvent)); +// button->addTouchEventListener(this, toucheventselector(UIButtonTest_Editor::touchEvent)); + button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this)); Button* title_button = static_cast(Helper::seekWidgetByName(root, "Button_126")); - title_button->addTouchEventListener(this, toucheventselector(UIButtonTest_Editor::touchEvent)); +// title_button->addTouchEventListener(this, toucheventselector(UIButtonTest_Editor::touchEvent)); + title_button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this)); Button* scale9_button = static_cast(Helper::seekWidgetByName(root, "Button_129")); - scale9_button->addTouchEventListener(this, toucheventselector(UIButtonTest_Editor::touchEvent)); +// scale9_button->addTouchEventListener(this, toucheventselector(UIButtonTest_Editor::touchEvent)); + scale9_button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this)); _displayValueLabel = Text::create(); _displayValueLabel->setFontName("fonts/Marker Felt.ttf"); @@ -57,23 +61,23 @@ bool UIButtonTest_Editor::init() return false; } -void UIButtonTest_Editor::touchEvent(Ref *pSender, TouchEventType type) +void UIButtonTest_Editor::touchEvent(Ref *pSender, Widget::TouchEventType type) { switch (type) { - case TOUCH_EVENT_BEGAN: + case Widget::TouchEventType::BEGAN: _displayValueLabel->setText("Touch Down"); break; - case TOUCH_EVENT_MOVED: + case Widget::TouchEventType::MOVED: _displayValueLabel->setText("Touch Moved"); break; - case TOUCH_EVENT_ENDED: + case Widget::TouchEventType::ENDED: _displayValueLabel->setText("Touch Ended"); break; - case TOUCH_EVENT_CANCELED: + case Widget::TouchEventType::CANCELED: _displayValueLabel->setText("Touch Canceled"); break; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.h index 9fac7b9590..1985dcb907 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.h @@ -34,7 +34,7 @@ public: ~UIButtonTest_Editor(); bool init(); - void touchEvent(Ref* pSender, TouchEventType type); + void touchEvent(Ref* pSender, Widget::TouchEventType type); protected: UI_SCENE_EDITOR_CREATE_FUNC(UIButtonTest_Editor); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp index d267f8fa47..5fc82d4238 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp @@ -30,7 +30,7 @@ bool UICheckBoxTest_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp index 4dec52d51d..22059a3f78 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp @@ -60,9 +60,9 @@ bool UIFocusTestBase::init() return false; } -void UIFocusTestBase::onImageViewClicked(cocos2d::Ref *ref, TouchEventType touchType) +void UIFocusTestBase::onImageViewClicked(cocos2d::Ref *ref, Widget::TouchEventType touchType) { - if (touchType == TouchEventType::TOUCH_EVENT_ENDED) { + if (touchType == Widget::TouchEventType::ENDED) { Widget *w = (Widget*)ref; if (w->isFocusEnabled()) { w->setFocusEnabled(false); @@ -166,7 +166,7 @@ bool UIFocusTestHorizontal::init() ImageView *w = ImageView::create("cocosui/scrollviewbg.png"); w->setTouchEnabled(true); w->setTag(i); - w->addTouchEventListener(this, toucheventselector(UIFocusTestHorizontal::onImageViewClicked)); + w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestHorizontal::onImageViewClicked, this)); _horizontalLayout->addChild(w); } @@ -179,7 +179,7 @@ bool UIFocusTestHorizontal::init() btn->setTitleText("Toggle Loop"); btn->setPosition(Vector2(60, winSize.height - 50)); btn->setTitleColor(Color3B::RED); - btn->addTouchEventListener(this, toucheventselector(UIFocusTestHorizontal::toggleFocusLoop)); + btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestHorizontal::toggleFocusLoop,this)); this->addChild(btn); @@ -191,9 +191,9 @@ bool UIFocusTestHorizontal::init() -void UIFocusTestHorizontal::toggleFocusLoop(cocos2d::Ref * pObjc, TouchEventType type) +void UIFocusTestHorizontal::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchEventType type) { - if (type == TouchEventType::TOUCH_EVENT_ENDED) { + if (type == Widget::TouchEventType::ENDED) { _horizontalLayout->setLoopFocus(!_horizontalLayout->isLoopFocus()); if (_horizontalLayout->isLoopFocus()) { _loopText->setText("loop enabled"); @@ -236,7 +236,7 @@ bool UIFocusTestVertical::init() ImageView *w = ImageView::create("cocosui/scrollviewbg.png"); w->setTouchEnabled(true); w->setTag(i); - w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked)); + w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestVertical::onImageViewClicked, this)); _verticalLayout->addChild(w); if (i == 2) { w->requestFocus(); @@ -252,7 +252,7 @@ bool UIFocusTestVertical::init() btn->setTitleText("Toggle Loop"); btn->setPosition(Vector2(60, winSize.height - 50)); btn->setTitleColor(Color3B::RED); - btn->addTouchEventListener(this, toucheventselector(UIFocusTestHorizontal::toggleFocusLoop)); + btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestVertical::toggleFocusLoop, this)); this->addChild(btn); @@ -262,9 +262,9 @@ bool UIFocusTestVertical::init() } -void UIFocusTestVertical::toggleFocusLoop(cocos2d::Ref * pObjc, TouchEventType type) +void UIFocusTestVertical::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchEventType type) { - if (type == TouchEventType::TOUCH_EVENT_ENDED) { + if (type == Widget::TouchEventType::ENDED) { _verticalLayout->setLoopFocus(!_verticalLayout->isLoopFocus()); if (_verticalLayout->isLoopFocus()) { _loopText->setText("loop enabled"); @@ -308,7 +308,7 @@ bool UIFocusTestNestedLayout1::init() w->setTouchEnabled(true); w->setScaleX(2.5); w->setTag(i+count1); - w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked)); + w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::onImageViewClicked, this)); _verticalLayout->addChild(w); } @@ -325,7 +325,7 @@ bool UIFocusTestNestedLayout1::init() w->setScaleY(2.0); w->setTouchEnabled(true); w->setTag(i+count1+count2); - w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked)); + w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::onImageViewClicked, this)); hbox->addChild(w); } @@ -341,7 +341,7 @@ bool UIFocusTestNestedLayout1::init() ImageView *w = ImageView::create("cocosui/scrollviewbg.png"); w->setTouchEnabled(true); w->setTag(i+count1+count2+count3); - w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked)); + w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::onImageViewClicked, this)); innerVBox->addChild(w); } @@ -354,7 +354,7 @@ bool UIFocusTestNestedLayout1::init() btn->setTitleText("Toggle Loop"); btn->setPosition(Vector2(60, winSize.height - 50)); btn->setTitleColor(Color3B::RED); - btn->addTouchEventListener(this, toucheventselector(UIFocusTestHorizontal::toggleFocusLoop)); + btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::toggleFocusLoop, this)); this->addChild(btn); @@ -364,9 +364,9 @@ bool UIFocusTestNestedLayout1::init() } -void UIFocusTestNestedLayout1::toggleFocusLoop(cocos2d::Ref * pObjc, TouchEventType type) +void UIFocusTestNestedLayout1::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchEventType type) { - if (type == TouchEventType::TOUCH_EVENT_ENDED) { + if (type == Widget::TouchEventType::ENDED) { _verticalLayout->setLoopFocus(!_verticalLayout->isLoopFocus()); if (_verticalLayout->isLoopFocus()) { _loopText->setText("loop enabled"); @@ -410,7 +410,7 @@ bool UIFocusTestNestedLayout2::init() w->setTouchEnabled(true); w->setTag(i+count1); w->setScaleY(2.4); - w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked)); + w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::onImageViewClicked, this)); _horizontalLayout->addChild(w); } @@ -427,7 +427,7 @@ bool UIFocusTestNestedLayout2::init() w->setScaleX(2.0); w->setTouchEnabled(true); w->setTag(i+count1+count2); - w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked)); + w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::onImageViewClicked, this)); vbox->addChild(w); } @@ -443,7 +443,7 @@ bool UIFocusTestNestedLayout2::init() ImageView *w = ImageView::create("cocosui/scrollviewbg.png"); w->setTouchEnabled(true); w->setTag(i+count1+count2+count3); - w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked)); + w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::onImageViewClicked, this)); innerHBox->addChild(w); } @@ -456,7 +456,7 @@ bool UIFocusTestNestedLayout2::init() btn->setTitleText("Toggle Loop"); btn->setPosition(Vector2(60, winSize.height - 50)); btn->setTitleColor(Color3B::RED); - btn->addTouchEventListener(this, toucheventselector(UIFocusTestHorizontal::toggleFocusLoop)); + btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::toggleFocusLoop, this)); this->addChild(btn); @@ -466,9 +466,9 @@ bool UIFocusTestNestedLayout2::init() } -void UIFocusTestNestedLayout2::toggleFocusLoop(cocos2d::Ref * pObjc, TouchEventType type) +void UIFocusTestNestedLayout2::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchEventType type) { - if (type == TouchEventType::TOUCH_EVENT_ENDED) { + if (type == Widget::TouchEventType::ENDED) { _horizontalLayout->setLoopFocus(!_horizontalLayout->isLoopFocus()); if (_horizontalLayout->isLoopFocus()) { _loopText->setText("loop enabled"); @@ -529,7 +529,7 @@ bool UIFocusTestNestedLayout3::init() ImageView *w = ImageView::create("cocosui/scrollviewbg.png"); w->setTouchEnabled(true); w->setTag(j+firstVbox->getTag()+1); - w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked)); + w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestBase::onImageViewClicked, this)); firstVbox->addChild(w); } @@ -550,7 +550,7 @@ bool UIFocusTestNestedLayout3::init() w->setLayoutParameter(bottomParams); w->setTouchEnabled(true); w->setTag(i+601); - w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked)); + w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestBase::onImageViewClicked, this)); bottomHBox->addChild(w); } _verticalLayout->addChild(bottomHBox); @@ -566,7 +566,7 @@ bool UIFocusTestNestedLayout3::init() btn->setTitleText("Toggle Loop"); btn->setPosition(Vector2(60, winSize.height - 50)); btn->setTitleColor(Color3B::RED); - btn->addTouchEventListener(this, toucheventselector(UIFocusTestHorizontal::toggleFocusLoop)); + btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout3::toggleFocusLoop, this)); this->addChild(btn); @@ -576,9 +576,9 @@ bool UIFocusTestNestedLayout3::init() } -void UIFocusTestNestedLayout3::toggleFocusLoop(cocos2d::Ref * pObjc, TouchEventType type) +void UIFocusTestNestedLayout3::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchEventType type) { - if (type == TouchEventType::TOUCH_EVENT_ENDED) { + if (type == Widget::TouchEventType::ENDED) { _verticalLayout->setLoopFocus(!_verticalLayout->isLoopFocus()); if (_verticalLayout->isLoopFocus()) { _loopText->setText("loop enabled"); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.h index db06c4149d..9f152487f7 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.h @@ -26,7 +26,7 @@ public: virtual void onDownKeyPressed(); virtual void onFocusChanged(Widget* widgetLostFocus, Widget* widgetGetFocus); - void onImageViewClicked(Ref* ref, TouchEventType touchType); + void onImageViewClicked(Ref* ref, Widget::TouchEventType touchType); protected: Menu *_dpadMenu; @@ -42,7 +42,7 @@ public: bool init(); - void toggleFocusLoop(Ref*,TouchEventType); + void toggleFocusLoop(Ref*,Widget::TouchEventType); protected: UI_SCENE_CREATE_FUNC(UIFocusTestHorizontal); @@ -58,7 +58,7 @@ public: bool init(); - void toggleFocusLoop(Ref*,TouchEventType); + void toggleFocusLoop(Ref*,Widget::TouchEventType); protected: UI_SCENE_CREATE_FUNC(UIFocusTestVertical); Layout *_verticalLayout; @@ -73,7 +73,7 @@ public: bool init(); - void toggleFocusLoop(Ref*,TouchEventType); + void toggleFocusLoop(Ref*,Widget::TouchEventType); protected: UI_SCENE_CREATE_FUNC(UIFocusTestNestedLayout1); Layout *_verticalLayout; @@ -88,7 +88,7 @@ public: bool init(); - void toggleFocusLoop(Ref*,TouchEventType); + void toggleFocusLoop(Ref*,Widget::TouchEventType); protected: UI_SCENE_CREATE_FUNC(UIFocusTestNestedLayout2); Layout *_horizontalLayout; @@ -103,7 +103,7 @@ public: bool init(); - void toggleFocusLoop(Ref*,TouchEventType); + void toggleFocusLoop(Ref*,Widget::TouchEventType); protected: UI_SCENE_CREATE_FUNC(UIFocusTestNestedLayout3); Layout *_verticalLayout; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest_Editor.cpp index ffcab55cdd..c0cf97ad2e 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest_Editor.cpp @@ -19,7 +19,7 @@ bool UIImageViewTest_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest_Editor.cpp index e734cfa542..73bb29be55 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest_Editor.cpp @@ -29,7 +29,7 @@ bool UILayoutTest_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -38,7 +38,7 @@ bool UILayoutTest_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -48,7 +48,7 @@ bool UILayoutTest_Editor::init() right_button->getSize().height)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; @@ -84,7 +84,7 @@ bool UILayoutTest_Color_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -93,7 +93,7 @@ bool UILayoutTest_Color_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -103,7 +103,7 @@ bool UILayoutTest_Color_Editor::init() right_button->getSize().height)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; @@ -139,7 +139,7 @@ bool UILayoutTest_Gradient_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -148,7 +148,7 @@ bool UILayoutTest_Gradient_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -158,7 +158,7 @@ bool UILayoutTest_Gradient_Editor::init() right_button->getSize().height)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; @@ -194,7 +194,7 @@ bool UILayoutTest_BackGroundImage_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -203,7 +203,7 @@ bool UILayoutTest_BackGroundImage_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -213,7 +213,7 @@ bool UILayoutTest_BackGroundImage_Editor::init() right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; @@ -249,7 +249,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -258,7 +258,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -268,7 +268,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init() right_button->getSize().height)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; @@ -304,7 +304,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -313,7 +313,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -323,7 +323,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init() right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; @@ -359,7 +359,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -368,7 +368,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -378,7 +378,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init() right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); @@ -415,7 +415,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -424,7 +424,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -434,7 +434,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init() right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; @@ -470,7 +470,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -479,7 +479,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -489,7 +489,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init() right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest_Editor.cpp index ae64e9ea1a..a1ac86f748 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest_Editor.cpp @@ -29,7 +29,7 @@ bool UIListViewTest_Vertical_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene,this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -41,7 +41,9 @@ bool UIListViewTest_Vertical_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback,this)); + + left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -51,7 +53,7 @@ bool UIListViewTest_Vertical_Editor::init() right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback,this)); _layout->addChild(right_button); return true; @@ -88,7 +90,7 @@ bool UIListViewTest_Horizontal_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene,this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -97,7 +99,7 @@ bool UIListViewTest_Horizontal_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback,this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -107,7 +109,7 @@ bool UIListViewTest_Horizontal_Editor::init() right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp index e13deddca0..7e5b0e9d75 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp @@ -31,7 +31,8 @@ bool UILoadingBarTest_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); +// back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -64,7 +65,7 @@ void UILoadingBarTest_Editor::update(float delta) loadingBar_right_to_left->setPercent(_count); } -void UILoadingBarTest_Editor::toCocosGUITestScene(Widget::TouchEventType event) +void UILoadingBarTest_Editor::toCocosGUITestScene(Ref* sender, Widget::TouchEventType event) { switch (event) { @@ -72,7 +73,7 @@ void UILoadingBarTest_Editor::toCocosGUITestScene(Widget::TouchEventType event) { unscheduleUpdate(); - UIScene_Editor::toGUIEditorTestScene(event); + UIScene_Editor::toGUIEditorTestScene(sender, event); } break; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.h index 890caa38cf..1cb987c22d 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.h @@ -12,7 +12,7 @@ public: ~UILoadingBarTest_Editor(); bool init(); void update(float delta); - void toCocosGUITestScene(Widget::TouchEventType event); + void toCocosGUITestScene(Ref* sender, Widget::TouchEventType event); protected: UI_SCENE_EDITOR_CREATE_FUNC(UILoadingBarTest_Editor) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest_Editor.cpp index 691e310394..2e672da0ed 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest_Editor.cpp @@ -30,7 +30,7 @@ bool UIPageViewTest_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -39,7 +39,7 @@ bool UIPageViewTest_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -49,7 +49,7 @@ bool UIPageViewTest_Editor::init() right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp index afa6b6ba80..c2de04c2ba 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp @@ -31,7 +31,8 @@ bool UIRichTextTest::init() button->setTouchEnabled(true); button->setTitleText("switch"); button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + button->getSize().height * 2.5)); - button->addTouchEventListener(this, toucheventselector(UIRichTextTest::touchEvent)); +// button->addTouchEventListener(this, toucheventselector(UIRichTextTest::touchEvent)); + button->addTouchEventListener(CC_CALLBACK_2(UIRichTextTest::touchEvent, this)); button->setLocalZOrder(10); _widget->addChild(button); @@ -75,11 +76,11 @@ bool UIRichTextTest::init() return false; } -void UIRichTextTest::touchEvent(Ref *pSender, TouchEventType type) +void UIRichTextTest::touchEvent(Ref *pSender, Widget::TouchEventType type) { switch (type) { - case TOUCH_EVENT_ENDED: + case Widget::TouchEventType::ENDED: { if (_richText->isIgnoreContentAdaptWithSize()) { diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.h index 0fd2db97f4..0563fec64e 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.h @@ -11,7 +11,7 @@ public: UIRichTextTest(); ~UIRichTextTest(); bool init(); - void touchEvent(Ref *pSender, TouchEventType type); + void touchEvent(Ref *pSender, Widget::TouchEventType type); protected: UI_SCENE_CREATE_FUNC(UIRichTextTest) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp index a7155df080..92976538e8 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp @@ -32,7 +32,7 @@ bool UIScene_Editor::init() return false; } -void UIScene_Editor::previousCallback(Widget::TouchEventType event) +void UIScene_Editor::previousCallback(Ref* sender, Widget::TouchEventType event) { switch (event) { @@ -45,7 +45,7 @@ void UIScene_Editor::previousCallback(Widget::TouchEventType event) } } -void UIScene_Editor::nextCallback(Widget::TouchEventType event) +void UIScene_Editor::nextCallback(Ref* sender, Widget::TouchEventType event) { switch (event) { @@ -58,7 +58,7 @@ void UIScene_Editor::nextCallback(Widget::TouchEventType event) } } -void UIScene_Editor::toGUIEditorTestScene(Widget::TouchEventType event) +void UIScene_Editor::toGUIEditorTestScene(Ref* sender, Widget::TouchEventType event) { switch (event) { diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.h index 5602b7beb1..b485871969 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene_Editor.h @@ -60,10 +60,10 @@ public: ~UIScene_Editor(); bool init(); - virtual void previousCallback(Widget::TouchEventType event); - virtual void nextCallback(Widget::TouchEventType event); + virtual void previousCallback(Ref* sender, Widget::TouchEventType event); + virtual void nextCallback(Ref* sender, Widget::TouchEventType event); - void toGUIEditorTestScene(Widget::TouchEventType event); + void toGUIEditorTestScene(Ref* sender, Widget::TouchEventType event); /** Title label of the scene.*/ CC_SYNTHESIZE_READONLY(Text*, _sceneTitle, SceneTitle) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest_Editor.cpp index 6eb3da1c6f..44b4a3f5d2 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest_Editor.cpp @@ -29,7 +29,7 @@ bool UIScrollViewTest_Vertical_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -38,7 +38,7 @@ bool UIScrollViewTest_Vertical_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -48,7 +48,7 @@ bool UIScrollViewTest_Vertical_Editor::init() right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; @@ -84,7 +84,7 @@ bool UIScrollViewTest_Horizontal_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -93,7 +93,7 @@ bool UIScrollViewTest_Horizontal_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -103,7 +103,7 @@ bool UIScrollViewTest_Horizontal_Editor::init() right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; @@ -139,7 +139,7 @@ bool UIScrollViewTest_Both_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); @@ -148,7 +148,7 @@ bool UIScrollViewTest_Both_Editor::init() left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width, left_button->getSize().height * 0.625)); left_button->setTouchEnabled(true); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); left_button->setLocalZOrder(_layout->getLocalZOrder() + 1); _layout->addChild(left_button); @@ -158,7 +158,7 @@ bool UIScrollViewTest_Both_Editor::init() right_button->getSize().height * 0.625)); right_button->setTouchEnabled(true); right_button->setLocalZOrder(_layout->getLocalZOrder() + 1); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); _layout->addChild(right_button); return true; @@ -194,18 +194,18 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); Button* left_button = static_cast(Helper::seekWidgetByName(root, "left_Button")); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); Button* middle_button = static_cast(Helper::seekWidgetByName(root, "middle_Button")); middle_button->setVisible(false); Button* right_button = static_cast(Helper::seekWidgetByName(root, "right_Button")); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); return true; } @@ -240,18 +240,18 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); Button* left_button = static_cast(Helper::seekWidgetByName(root, "left_Button")); - left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback)); + left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this)); Button* middle_button = static_cast(Helper::seekWidgetByName(root, "middle_Button")); middle_button->setVisible(false); Button* right_button = static_cast(Helper::seekWidgetByName(root, "right_Button")); - right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback)); + right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this)); return true; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp index 2325e9d3b6..a9179de983 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp @@ -30,7 +30,7 @@ bool UISliderTest_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp index 4f614d979b..6077d19e18 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp @@ -18,7 +18,7 @@ bool UITextAtlasTest_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp index 0ce7e6d7c7..b053f267b4 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp @@ -19,7 +19,7 @@ bool UITextBMFontTest_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp index 5704ba62b4..31e8e37213 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp @@ -30,7 +30,7 @@ bool UITextFieldTest_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp index 22918cafd8..effd3883e3 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp @@ -21,7 +21,7 @@ bool UITextTest_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp index f8b5d766ba..cb91a6dad4 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp @@ -29,7 +29,7 @@ bool UIWidgetAddNodeTest_Editor::init() Layout* root = static_cast(_layout->getChildByName("root_Panel")); Text* back_label = static_cast(Helper::seekWidgetByName(root, "back")); - back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene)); + back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this)); _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); From 6a7277c38fc5e8ecef87d6e785d4c693de0bca19 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 14:56:05 +0800 Subject: [PATCH 034/174] issue #5057, refactor TextureResType to strong typed enum --- .../ButtonReader/ButtonReader.cpp | 12 ++++---- .../CheckBoxReader/CheckBoxReader.cpp | 20 ++++++------- .../ImageViewReader/ImageViewReader.cpp | 4 +-- .../LayoutReader/LayoutReader.cpp | 4 +-- .../LoadingBarReader/LoadingBarReader.cpp | 4 +-- .../SliderReader/SliderReader.cpp | 20 ++++++------- .../cocostudio/WidgetReader/WidgetReader.cpp | 6 ++-- .../cocostudio/WidgetReader/WidgetReader.h | 2 +- cocos/ui/UIButton.cpp | 30 +++++++++---------- cocos/ui/UIButton.h | 12 ++++---- cocos/ui/UICheckBox.cpp | 30 +++++++++---------- cocos/ui/UICheckBox.h | 16 +++++----- cocos/ui/UIDeprecated.h | 6 ++++ cocos/ui/UIImageView.cpp | 8 ++--- cocos/ui/UIImageView.h | 6 ++-- cocos/ui/UILayout.cpp | 10 +++---- cocos/ui/UILayout.h | 2 +- cocos/ui/UILoadingBar.cpp | 6 ++-- cocos/ui/UILoadingBar.h | 2 +- cocos/ui/UISlider.cpp | 30 +++++++++---------- cocos/ui/UISlider.h | 12 ++++---- cocos/ui/UIWidget.h | 12 ++++---- 22 files changed, 130 insertions(+), 124 deletions(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp index fe475ed136..b26507dbe5 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp @@ -48,22 +48,22 @@ namespace cocostudio const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "normalData"); int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType"); - std::string normalTexturePath = this->getResourcePath(normalDic, "path", (TextureResType)normalType); - button->loadTextureNormal(normalTexturePath, (TextureResType)normalType); + std::string normalTexturePath = this->getResourcePath(normalDic, "path", (Widget::TextureResType)normalType); + button->loadTextureNormal(normalTexturePath, (Widget::TextureResType)normalType); const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "pressedData"); int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType"); - std::string pressedTexturePath = this->getResourcePath(pressedDic, "path", (TextureResType)pressedType); - button->loadTexturePressed(pressedTexturePath, (TextureResType)pressedType); + std::string pressedTexturePath = this->getResourcePath(pressedDic, "path", (Widget::TextureResType)pressedType); + button->loadTexturePressed(pressedTexturePath, (Widget::TextureResType)pressedType); const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "disabledData"); int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType"); - std::string disabledTexturePath = this->getResourcePath(disabledDic, "path", (TextureResType)disabledType); - button->loadTextureDisabled(disabledTexturePath, (TextureResType)disabledType); + std::string disabledTexturePath = this->getResourcePath(disabledDic, "path", (Widget::TextureResType)disabledType); + button->loadTextureDisabled(disabledTexturePath, (Widget::TextureResType)disabledType); if (scale9Enable) { diff --git a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp index 72bc3193d8..0d24ac68b2 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp @@ -41,32 +41,32 @@ namespace cocostudio //load background image const rapidjson::Value& backGroundDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxData"); int backGroundType = DICTOOL->getIntValue_json(backGroundDic, "resourceType"); - std::string backGroundTexturePath = this->getResourcePath(backGroundDic, "path", (TextureResType)backGroundType); - checkBox->loadTextureBackGround(backGroundTexturePath, (TextureResType)backGroundType); + std::string backGroundTexturePath = this->getResourcePath(backGroundDic, "path", (Widget::TextureResType)backGroundType); + checkBox->loadTextureBackGround(backGroundTexturePath, (Widget::TextureResType)backGroundType); //load background selected image const rapidjson::Value& backGroundSelectedDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxSelectedData"); int backGroundSelectedType = DICTOOL->getIntValue_json(backGroundSelectedDic, "resourceType"); - std::string backGroundSelectedTexturePath = this->getResourcePath(backGroundSelectedDic, "path", (TextureResType)backGroundSelectedType); - checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (TextureResType)backGroundSelectedType); + std::string backGroundSelectedTexturePath = this->getResourcePath(backGroundSelectedDic, "path", (Widget::TextureResType)backGroundSelectedType); + checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (Widget::TextureResType)backGroundSelectedType); //load frontCross image const rapidjson::Value& frontCrossDic = DICTOOL->getSubDictionary_json(options, "frontCrossData"); int frontCrossType = DICTOOL->getIntValue_json(frontCrossDic, "resourceType"); - std::string frontCrossFileName = this->getResourcePath(frontCrossDic, "path", (TextureResType)frontCrossType); - checkBox->loadTextureFrontCross(frontCrossFileName, (TextureResType)frontCrossType); + std::string frontCrossFileName = this->getResourcePath(frontCrossDic, "path", (Widget::TextureResType)frontCrossType); + checkBox->loadTextureFrontCross(frontCrossFileName, (Widget::TextureResType)frontCrossType); //load backGroundBoxDisabledData const rapidjson::Value& backGroundDisabledDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxDisabledData"); int backGroundDisabledType = DICTOOL->getIntValue_json(backGroundDisabledDic, "resourceType"); - std::string backGroundDisabledFileName = this->getResourcePath(backGroundDisabledDic, "path", (TextureResType)backGroundDisabledType); - checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (TextureResType)backGroundDisabledType); + std::string backGroundDisabledFileName = this->getResourcePath(backGroundDisabledDic, "path", (Widget::TextureResType)backGroundDisabledType); + checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (Widget::TextureResType)backGroundDisabledType); ///load frontCrossDisabledData const rapidjson::Value& frontCrossDisabledDic = DICTOOL->getSubDictionary_json(options, "frontCrossDisabledData"); int frontCrossDisabledType = DICTOOL->getIntValue_json(frontCrossDisabledDic, "resourceType"); - std::string frontCrossDisabledFileName = this->getResourcePath(frontCrossDisabledDic, "path", (TextureResType)frontCrossDisabledType); - checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName, (TextureResType)frontCrossDisabledType); + std::string frontCrossDisabledFileName = this->getResourcePath(frontCrossDisabledDic, "path", (Widget::TextureResType)frontCrossDisabledType); + checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName, (Widget::TextureResType)frontCrossDisabledType); WidgetReader::setColorPropsFromJsonDictionary(widget, options); diff --git a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp index 42b05593e0..7518098731 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp @@ -41,8 +41,8 @@ namespace cocostudio const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "fileNameData"); int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType); - imageView->loadTexture(imageFileName, (TextureResType)imageFileNameType); + std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (Widget::TextureResType)imageFileNameType); + imageView->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType); bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable"); diff --git a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp index edcf5aead1..fcc690e3b6 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp @@ -85,8 +85,8 @@ namespace cocostudio const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "backGroundImageData"); int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType); - panel->setBackGroundImage(imageFileName, (TextureResType)imageFileNameType); + std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (Widget::TextureResType)imageFileNameType); + panel->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType); if (backGroundScale9Enable) diff --git a/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp index caa6bc2714..6b5c77785d 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp @@ -40,8 +40,8 @@ namespace cocostudio const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "textureData"); int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType); - loadingBar->loadTexture(imageFileName, (TextureResType)imageFileNameType); + std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (Widget::TextureResType)imageFileNameType); + loadingBar->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType); /* gui mark add load bar scale9 parse */ diff --git a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp index 564dd1866b..ca92886ef6 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp @@ -50,8 +50,8 @@ namespace cocostudio { const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData"); int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType); - slider->loadBarTexture(imageFileName, (TextureResType)imageFileNameType); + std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (Widget::TextureResType)imageFileNameType); + slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType); if (barTextureScale9Enable) { @@ -62,27 +62,27 @@ namespace cocostudio //loading normal slider ball texture const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "ballNormalData"); int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType"); - std::string imageFileName = this->getResourcePath(normalDic, "path", (TextureResType)normalType); - slider->loadSlidBallTextureNormal(imageFileName, (TextureResType)normalType); + std::string imageFileName = this->getResourcePath(normalDic, "path", (Widget::TextureResType)normalType); + slider->loadSlidBallTextureNormal(imageFileName, (Widget::TextureResType)normalType); //loading slider ball press texture const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "ballPressedData"); int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType"); - std::string pressedFileName = this->getResourcePath(pressedDic, "path", (TextureResType)pressedType); - slider->loadSlidBallTexturePressed(pressedFileName, (TextureResType)pressedType); + std::string pressedFileName = this->getResourcePath(pressedDic, "path", (Widget::TextureResType)pressedType); + slider->loadSlidBallTexturePressed(pressedFileName, (Widget::TextureResType)pressedType); //loading silder ball disable texture const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "ballDisabledData"); int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType"); - std::string disabledFileName = this->getResourcePath(disabledDic, "path", (TextureResType)disabledType); - slider->loadSlidBallTextureDisabled(disabledFileName, (TextureResType)disabledType); + std::string disabledFileName = this->getResourcePath(disabledDic, "path", (Widget::TextureResType)disabledType); + slider->loadSlidBallTextureDisabled(disabledFileName, (Widget::TextureResType)disabledType); //load slider progress texture const rapidjson::Value& progressBarDic = DICTOOL->getSubDictionary_json(options, "progressBarData"); int progressBarType = DICTOOL->getIntValue_json(progressBarDic, "resourceType"); - std::string progressBarFileName = this->getResourcePath(progressBarDic, "path", (TextureResType)progressBarType); - slider->loadProgressBarTexture(progressBarFileName, (TextureResType)progressBarType); + std::string progressBarFileName = this->getResourcePath(progressBarDic, "path", (Widget::TextureResType)progressBarType); + slider->loadProgressBarTexture(progressBarFileName, (Widget::TextureResType)progressBarType); diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index f511bf3605..cdcd9b841b 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -175,17 +175,17 @@ namespace cocostudio std::string WidgetReader::getResourcePath(const rapidjson::Value &dict, const std::string &key, - cocos2d::ui::TextureResType texType) + cocos2d::ui::Widget::TextureResType texType) { std::string jsonPath = GUIReader::getInstance()->getFilePath(); const char* imageFileName = DICTOOL->getStringValue_json(dict, key.c_str()); std::string imageFileName_tp; if (nullptr != imageFileName) { - if (texType == UI_TEX_TYPE_LOCAL) { + if (texType == ui::Widget::TextureResType::LOCAL) { imageFileName_tp = jsonPath + imageFileName; } - else if(texType == UI_TEX_TYPE_PLIST){ + else if(texType == ui::Widget::TextureResType::PLIST){ imageFileName_tp = imageFileName; } else{ diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h index fe0bb7c5c8..681f02224a 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h @@ -52,7 +52,7 @@ namespace cocostudio protected: std::string getResourcePath(const rapidjson::Value& dict, const std::string& key, - cocos2d::ui::TextureResType texType); + cocos2d::ui::Widget::TextureResType texType); }; } diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 3faf819508..f61d1e096c 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -49,9 +49,9 @@ _scale9Enabled(false), _capInsetsNormal(Rect::ZERO), _capInsetsPressed(Rect::ZERO), _capInsetsDisabled(Rect::ZERO), -_normalTexType(UI_TEX_TYPE_LOCAL), -_pressedTexType(UI_TEX_TYPE_LOCAL), -_disabledTexType(UI_TEX_TYPE_LOCAL), +_normalTexType(TextureResType::LOCAL), +_pressedTexType(TextureResType::LOCAL), +_disabledTexType(TextureResType::LOCAL), _normalTextureSize(_size), _pressedTextureSize(_size), _disabledTextureSize(_size), @@ -229,10 +229,10 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) extension::Scale9Sprite* normalRendererScale9 = static_cast(_buttonNormalRenderer); switch (_normalTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: normalRendererScale9->initWithFile(normal); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: normalRendererScale9->initWithSpriteFrameName(normal); break; default: @@ -245,10 +245,10 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) Sprite* normalRenderer = static_cast(_buttonNormalRenderer); switch (_normalTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: normalRenderer->setTexture(normal); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: normalRenderer->setSpriteFrame(normal); break; default: @@ -277,10 +277,10 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy extension::Scale9Sprite* clickedRendererScale9 = static_cast(_buttonClickedRenderer); switch (_pressedTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: clickedRendererScale9->initWithFile(selected); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: clickedRendererScale9->initWithSpriteFrameName(selected); break; default: @@ -293,10 +293,10 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy Sprite* clickedRenderer = static_cast(_buttonClickedRenderer); switch (_pressedTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: clickedRenderer->setTexture(selected); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: clickedRenderer->setSpriteFrame(selected); break; default: @@ -324,10 +324,10 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT extension::Scale9Sprite* disabledScale9 = static_cast(_buttonDisableRenderer); switch (_disabledTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: disabledScale9->initWithFile(disabled); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: disabledScale9->initWithSpriteFrameName(disabled); break; default: @@ -340,10 +340,10 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT Sprite* disabledRenderer = static_cast(_buttonDisableRenderer); switch (_disabledTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: disabledRenderer->setTexture(disabled); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: disabledRenderer->setSpriteFrame(disabled); break; default: diff --git a/cocos/ui/UIButton.h b/cocos/ui/UIButton.h index a67cfdd064..3f37b4554a 100644 --- a/cocos/ui/UIButton.h +++ b/cocos/ui/UIButton.h @@ -66,7 +66,7 @@ public: static Button* create(const std::string& normalImage, const std::string& selectedImage = "", const std::string& disableImage = "", - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); /** @@ -83,7 +83,7 @@ public: void loadTextures(const std::string& normal, const std::string& selected, const std::string& disabled = "", - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); /** * Load normal state texture for button. @@ -92,7 +92,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureNormal(const std::string& normal, TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTextureNormal(const std::string& normal, TextureResType texType = TextureResType::LOCAL); /** * Load selected state texture for button. @@ -101,7 +101,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTexturePressed(const std::string& selected, TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTexturePressed(const std::string& selected, TextureResType texType = TextureResType::LOCAL); /** * Load dark state texture for button. @@ -110,7 +110,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureDisabled(const std::string& disabled, TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTextureDisabled(const std::string& disabled, TextureResType texType = TextureResType::LOCAL); /** * Sets capinsets for button, if button is using scale9 renderer. @@ -190,7 +190,7 @@ CC_CONSTRUCTOR_ACCESS: virtual bool init(const std::string& normalImage, const std::string& selectedImage = "", const std::string& disableImage = "", - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); protected: diff --git a/cocos/ui/UICheckBox.cpp b/cocos/ui/UICheckBox.cpp index b0552e72f2..cfb8933c6e 100644 --- a/cocos/ui/UICheckBox.cpp +++ b/cocos/ui/UICheckBox.cpp @@ -45,11 +45,11 @@ _frontCrossDisabledRenderer(nullptr), _isSelected(true), _checkBoxEventListener(nullptr), _checkBoxEventSelector(nullptr), -_backGroundTexType(UI_TEX_TYPE_LOCAL), -_backGroundSelectedTexType(UI_TEX_TYPE_LOCAL), -_frontCrossTexType(UI_TEX_TYPE_LOCAL), -_backGroundDisabledTexType(UI_TEX_TYPE_LOCAL), -_frontCrossDisabledTexType(UI_TEX_TYPE_LOCAL), +_backGroundTexType(TextureResType::LOCAL), +_backGroundSelectedTexType(TextureResType::LOCAL), +_frontCrossTexType(TextureResType::LOCAL), +_backGroundDisabledTexType(TextureResType::LOCAL), +_frontCrossDisabledTexType(TextureResType::LOCAL), _backGroundFileName(""), _backGroundSelectedFileName(""), _frontCrossFileName(""), @@ -174,10 +174,10 @@ void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResTyp _backGroundTexType = texType; switch (_backGroundTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _backGroundBoxRenderer->setTexture(backGround); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _backGroundBoxRenderer->setSpriteFrame(backGround); break; default: @@ -200,10 +200,10 @@ void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelect _backGroundSelectedTexType = texType; switch (_backGroundSelectedTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _backGroundSelectedBoxRenderer->setTexture(backGroundSelected); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _backGroundSelectedBoxRenderer->setSpriteFrame(backGroundSelected); break; default: @@ -225,10 +225,10 @@ void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType tex _frontCrossTexType = texType; switch (_frontCrossTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _frontCrossRenderer->setTexture(cross); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _frontCrossRenderer->setSpriteFrame(cross); break; default: @@ -250,10 +250,10 @@ void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabl _backGroundDisabledTexType = texType; switch (_backGroundDisabledTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _backGroundBoxDisabledRenderer->setTexture(backGroundDisabled); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _backGroundBoxDisabledRenderer->setSpriteFrame(backGroundDisabled); break; default: @@ -275,10 +275,10 @@ void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabl _frontCrossDisabledTexType = texType; switch (_frontCrossDisabledTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _frontCrossDisabledRenderer->setTexture(frontCrossDisabled); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _frontCrossDisabledRenderer->setSpriteFrame(frontCrossDisabled); break; default: diff --git a/cocos/ui/UICheckBox.h b/cocos/ui/UICheckBox.h index cceb4596b1..5d10b824b5 100644 --- a/cocos/ui/UICheckBox.h +++ b/cocos/ui/UICheckBox.h @@ -83,7 +83,7 @@ public: const std::string& cross, const std::string& backGroundDisabled, const std::string& frontCrossDisabled, - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); /** * Load textures for checkbox. @@ -103,7 +103,7 @@ public: const std::string& cross, const std::string& backGroundDisabled, const std::string& frontCrossDisabled, - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); /** * Load backGround texture for checkbox. @@ -112,7 +112,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureBackGround(const std::string& backGround,TextureResType type = UI_TEX_TYPE_LOCAL); + void loadTextureBackGround(const std::string& backGround,TextureResType type = TextureResType::LOCAL); /** * Load backGroundSelected texture for checkbox. @@ -121,7 +121,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType = TextureResType::LOCAL); /** * Load cross texture for checkbox. @@ -130,7 +130,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureFrontCross(const std::string&,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTextureFrontCross(const std::string&,TextureResType texType = TextureResType::LOCAL); /** * Load backGroundDisabled texture for checkbox. @@ -139,7 +139,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType = TextureResType::LOCAL); /** * Load frontCrossDisabled texture for checkbox. @@ -148,7 +148,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType = TextureResType::LOCAL); /** * Sets selcted state for checkbox. @@ -188,7 +188,7 @@ CC_CONSTRUCTOR_ACCESS: const std::string& cross, const std::string& backGroundDisabled, const std::string& frontCrossDisabled, - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); protected: virtual void initRenderer() override; diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index 997e930fd3..3b22249e8a 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -37,6 +37,12 @@ CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_ABSOLUTE = Widget::P CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_PERCENT = Widget::PositionType::PERCENT; CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_ABSOLUTE = Widget::SizeType::ABSOLUTE; CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_PERCENT = Widget::SizeType::PERCENT; +CC_DEPRECATED_ATTRIBUTE const Widget::TextureResType UI_TEX_TYPE_LOCAL = Widget::TextureResType::LOCAL; +CC_DEPRECATED_ATTRIBUTE const Widget::TextureResType UI_TEX_TYPE_PLIST = Widget::TextureResType::PLIST; + +CC_DEPRECATED_ATTRIBUTE typedef Widget::TextureResType TextureResType; +CC_DEPRECATED_ATTRIBUTE typedef Widget::PositionType PositionType; +CC_DEPRECATED_ATTRIBUTE typedef Widget::SizeType SizeType; diff --git a/cocos/ui/UIImageView.cpp b/cocos/ui/UIImageView.cpp index eb25b4b4fd..d67fe503e3 100644 --- a/cocos/ui/UIImageView.cpp +++ b/cocos/ui/UIImageView.cpp @@ -43,7 +43,7 @@ _prevIgnoreSize(true), _capInsets(Rect::ZERO), _imageRenderer(nullptr), _textureFile(""), -_imageTexType(UI_TEX_TYPE_LOCAL), +_imageTexType(TextureResType::LOCAL), _imageTextureSize(_size), _imageRendererAdaptDirty(true) { @@ -86,7 +86,7 @@ bool ImageView::init() ret = false; break; } - _imageTexType = UI_TEX_TYPE_LOCAL; + _imageTexType = TextureResType::LOCAL; } while (0); return ret; } @@ -121,7 +121,7 @@ void ImageView::loadTexture(const std::string& fileName, TextureResType texType) _imageTexType = texType; switch (_imageTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: if (_scale9Enabled) { extension::Scale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE; @@ -134,7 +134,7 @@ void ImageView::loadTexture(const std::string& fileName, TextureResType texType) imageRenderer->setTexture(fileName); } break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: if (_scale9Enabled) { extension::Scale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE; diff --git a/cocos/ui/UIImageView.h b/cocos/ui/UIImageView.h index 8b88b8e09b..2bf9bd43b3 100644 --- a/cocos/ui/UIImageView.h +++ b/cocos/ui/UIImageView.h @@ -63,7 +63,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - static ImageView* create(const std::string& imageFileName, TextureResType texType = UI_TEX_TYPE_LOCAL); + static ImageView* create(const std::string& imageFileName, TextureResType texType = TextureResType::LOCAL); /** @@ -73,7 +73,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTexture(const std::string& fileName,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTexture(const std::string& fileName,TextureResType texType = TextureResType::LOCAL); /** * Updates the texture rect of the ImageView in points. @@ -113,7 +113,7 @@ public: CC_CONSTRUCTOR_ACCESS: //initializes state of widget. virtual bool init() override; - virtual bool init(const std::string& imageFileName, TextureResType texType = UI_TEX_TYPE_LOCAL); + virtual bool init(const std::string& imageFileName, TextureResType texType = TextureResType::LOCAL); protected: virtual void initRenderer() override; diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 73682844c6..a36b04c626 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -573,7 +573,7 @@ _backGroundImage(nullptr), _backGroundImageFileName(""), _backGroundImageCapInsets(Rect::ZERO), _colorType(LAYOUT_COLOR_NONE), -_bgImageTexType(UI_TEX_TYPE_LOCAL), +_bgImageTexType(TextureResType::LOCAL), _colorRender(nullptr), _gradientRender(nullptr), _cColor(Color3B::WHITE), @@ -1123,10 +1123,10 @@ void Layout::setBackGroundImage(const std::string& fileName,TextureResType texTy extension::Scale9Sprite* bgiScale9 = static_cast(_backGroundImage); switch (_bgImageTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: bgiScale9->initWithFile(fileName); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: bgiScale9->initWithSpriteFrameName(fileName); break; default: @@ -1138,10 +1138,10 @@ void Layout::setBackGroundImage(const std::string& fileName,TextureResType texTy { switch (_bgImageTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: static_cast(_backGroundImage)->setTexture(fileName); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: static_cast(_backGroundImage)->setSpriteFrame(fileName); break; default: diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index 316354961e..96b6fce71b 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -86,7 +86,7 @@ public: * * @param texType @see TextureResType. UI_TEX_TYPE_LOCAL means local file, UI_TEX_TYPE_PLIST means sprite frame. */ - void setBackGroundImage(const std::string& fileName,TextureResType texType = UI_TEX_TYPE_LOCAL); + void setBackGroundImage(const std::string& fileName,TextureResType texType = TextureResType::LOCAL); /** * Sets a background image capinsets for layout, if the background image is a scale9 render. diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index e54b24d04e..901d69a0de 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -38,7 +38,7 @@ _barType(LoadingBarTypeLeft), _percent(100), _totalLength(0), _barRenderer(nullptr), -_renderBarTexType(UI_TEX_TYPE_LOCAL), +_renderBarTexType(TextureResType::LOCAL), _barRendererTextureSize(Size::ZERO), _scale9Enabled(false), _prevIgnoreSize(true), @@ -129,7 +129,7 @@ int LoadingBar::getDirection() _textureFile = texture; switch (_renderBarTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: if (_scale9Enabled) { extension::Scale9Sprite* barRendererScale9 = static_cast(_barRenderer); @@ -141,7 +141,7 @@ int LoadingBar::getDirection() static_cast(_barRenderer)->setTexture(texture); } break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: if (_scale9Enabled) { extension::Scale9Sprite* barRendererScale9 = static_cast(_barRenderer); diff --git a/cocos/ui/UILoadingBar.h b/cocos/ui/UILoadingBar.h index f00de91acf..f23e2e4b89 100644 --- a/cocos/ui/UILoadingBar.h +++ b/cocos/ui/UILoadingBar.h @@ -91,7 +91,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadTexture(const std::string& texture,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadTexture(const std::string& texture,TextureResType texType = TextureResType::LOCAL); /** * Changes the progress direction of loadingbar. diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index b85a3da8e7..331988025e 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -56,11 +56,11 @@ _capInsetsBarRenderer(Rect::ZERO), _capInsetsProgressBarRenderer(Rect::ZERO), _sliderEventListener(nullptr), _sliderEventSelector(nullptr), -_barTexType(UI_TEX_TYPE_LOCAL), -_progressBarTexType(UI_TEX_TYPE_LOCAL), -_ballNTexType(UI_TEX_TYPE_LOCAL), -_ballPTexType(UI_TEX_TYPE_LOCAL), -_ballDTexType(UI_TEX_TYPE_LOCAL), +_barTexType(TextureResType::LOCAL), +_progressBarTexType(TextureResType::LOCAL), +_ballNTexType(TextureResType::LOCAL), +_ballPTexType(TextureResType::LOCAL), +_ballDTexType(TextureResType::LOCAL), _barRendererAdaptDirty(true), _progressBarRendererDirty(true) { @@ -123,7 +123,7 @@ void Slider::loadBarTexture(const std::string& fileName, TextureResType texType) _barTexType = texType; switch (_barTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: if (_scale9Enabled) { static_cast(_barRenderer)->initWithFile(fileName); @@ -133,7 +133,7 @@ void Slider::loadBarTexture(const std::string& fileName, TextureResType texType) static_cast(_barRenderer)->setTexture(fileName); } break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: if (_scale9Enabled) { static_cast(_barRenderer)->initWithSpriteFrameName(fileName); @@ -162,7 +162,7 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType _progressBarTexType = texType; switch (_progressBarTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: if (_scale9Enabled) { static_cast(_progressBarRenderer)->initWithFile(fileName); @@ -172,7 +172,7 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType static_cast(_progressBarRenderer)->setTexture(fileName); } break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: if (_scale9Enabled) { static_cast(_progressBarRenderer)->initWithSpriteFrameName(fileName); @@ -298,10 +298,10 @@ void Slider::loadSlidBallTextureNormal(const std::string& normal,TextureResType _ballNTexType = texType; switch (_ballNTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _slidBallNormalRenderer->setTexture(normal); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _slidBallNormalRenderer->setSpriteFrame(normal); break; default: @@ -320,10 +320,10 @@ void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResTyp _ballPTexType = texType; switch (_ballPTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _slidBallPressedRenderer->setTexture(pressed); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _slidBallPressedRenderer->setSpriteFrame(pressed); break; default: @@ -342,10 +342,10 @@ void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResTyp _ballDTexType = texType; switch (_ballDTexType) { - case UI_TEX_TYPE_LOCAL: + case TextureResType::LOCAL: _slidBallDisabledRenderer->setTexture(disabled); break; - case UI_TEX_TYPE_PLIST: + case TextureResType::PLIST: _slidBallDisabledRenderer->setSpriteFrame(disabled); break; default: diff --git a/cocos/ui/UISlider.h b/cocos/ui/UISlider.h index ba8a8928ae..52974d4560 100644 --- a/cocos/ui/UISlider.h +++ b/cocos/ui/UISlider.h @@ -71,7 +71,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadBarTexture(const std::string& fileName,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadBarTexture(const std::string& fileName,TextureResType texType = TextureResType::LOCAL); /** * Sets if slider is using scale9 renderer. @@ -121,7 +121,7 @@ public: void loadSlidBallTextures(const std::string& normal, const std::string& pressed, const std::string& disabled, - TextureResType texType = UI_TEX_TYPE_LOCAL); + TextureResType texType = TextureResType::LOCAL); /** * Load normal state texture for slider ball. @@ -130,7 +130,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadSlidBallTextureNormal(const std::string& normal,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadSlidBallTextureNormal(const std::string& normal,TextureResType texType = TextureResType::LOCAL); /** * Load selected state texture for slider ball. @@ -139,7 +139,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadSlidBallTexturePressed(const std::string& pressed,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadSlidBallTexturePressed(const std::string& pressed,TextureResType texType = TextureResType::LOCAL); /** * Load dark state texture for slider ball. @@ -148,7 +148,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadSlidBallTextureDisabled(const std::string& disabled,TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadSlidBallTextureDisabled(const std::string& disabled,TextureResType texType = TextureResType::LOCAL); /** * Load dark state texture for slider progress bar. @@ -157,7 +157,7 @@ public: * * @param texType @see UI_TEX_TYPE_LOCAL */ - void loadProgressBarTexture(const std::string& fileName, TextureResType texType = UI_TEX_TYPE_LOCAL); + void loadProgressBarTexture(const std::string& fileName, TextureResType texType = TextureResType::LOCAL); /** * Changes the progress direction of slider. diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index de6b8d86da..77bce664cd 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -46,12 +46,6 @@ typedef enum WidgetTypeWidget, //control WidgetTypeContainer //container }WidgetType; - -typedef enum -{ - UI_TEX_TYPE_LOCAL = 0, - UI_TEX_TYPE_PLIST = 1 -}TextureResType; @@ -101,6 +95,12 @@ public: ENDED, CANCELED }; + + enum class TextureResType + { + LOCAL = 0, + PLIST = 1 + }; typedef std::function ccWidgetTouchCallback; From 762e8d9249b8c1aa7c5080f7dbb3c639d4040f6a Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 15:16:33 +0800 Subject: [PATCH 035/174] issue #5057, refactor WidgetType to strong typed enum --- .../cocostudio/CCSGUIReader.cpp | 66 +++++++++---------- .../cocostudio/WidgetReader/WidgetReader.cpp | 4 +- cocos/ui/UIDeprecated.h | 4 ++ cocos/ui/UILayout.cpp | 2 +- cocos/ui/UIPageView.cpp | 4 +- cocos/ui/UIWidget.cpp | 4 +- cocos/ui/UIWidget.h | 16 ++--- 7 files changed, 52 insertions(+), 48 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 770f558da5..b78a9f78e2 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -412,9 +412,9 @@ void WidgetPropertiesReader0250::setColorPropsForWidgetFromJsonDictionary(Widget int colorB = cb ? DICTOOL->getIntValue_json(options, "colorB") : 255; widget->setColor(Color3B(colorR, colorG, colorB)); bool apx = DICTOOL->checkObjectExist_json(options, "anchorPointX"); - float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); + float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == Widget::Type::ELEMENT) ? 0.5f : 0.0f); bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY"); - float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); + float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == Widget::Type::ELEMENT) ? 0.5f : 0.0f); widget->setAnchorPoint(Vector2(apxf, apyf)); bool flipX = DICTOOL->getBooleanValue_json(options, "flipX"); bool flipY = DICTOOL->getBooleanValue_json(options, "flipY"); @@ -450,7 +450,7 @@ void WidgetPropertiesReader0250::setPropsForButtonFromJsonDictionary(Widget*widg if (useMergedTexture) { - button->loadTextures(normalFileName, pressedFileName, disabledFileName,UI_TEX_TYPE_PLIST); + button->loadTextures(normalFileName, pressedFileName, disabledFileName,TextureResType::PLIST); } else { @@ -470,7 +470,7 @@ void WidgetPropertiesReader0250::setPropsForButtonFromJsonDictionary(Widget*widg { if (useMergedTexture) { - button->loadTextures(normalFileName, pressedFileName, disabledFileName,UI_TEX_TYPE_PLIST); + button->loadTextures(normalFileName, pressedFileName, disabledFileName,TextureResType::PLIST); } else { @@ -531,7 +531,7 @@ void WidgetPropertiesReader0250::setPropsForCheckBoxFromJsonDictionary(Widget*wi if (useMergedTexture) { - checkBox->loadTextures(backGroundFileName, backGroundSelectedFileName, frontCrossFileName,backGroundDisabledFileName,frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); + checkBox->loadTextures(backGroundFileName, backGroundSelectedFileName, frontCrossFileName,backGroundDisabledFileName,frontCrossDisabledFileName,TextureResType::PLIST); } else { @@ -566,7 +566,7 @@ void WidgetPropertiesReader0250::setPropsForImageViewFromJsonDictionary(Widget*w { if (useMergedTexture) { - imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + imageView->loadTexture(imageFileName,TextureResType::PLIST); } else { @@ -593,7 +593,7 @@ void WidgetPropertiesReader0250::setPropsForImageViewFromJsonDictionary(Widget*w { if (useMergedTexture) { - imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + imageView->loadTexture(imageFileName,TextureResType::PLIST); } else { @@ -711,7 +711,7 @@ void WidgetPropertiesReader0250::setPropsForLayoutFromJsonDictionary(Widget*widg float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); if (useMergedTexture) { - panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); + panel->setBackGroundImage(imageFileName,TextureResType::PLIST); } else { @@ -724,7 +724,7 @@ void WidgetPropertiesReader0250::setPropsForLayoutFromJsonDictionary(Widget*widg if (useMergedTexture) { - panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); + panel->setBackGroundImage(imageFileName,TextureResType::PLIST); } else { @@ -766,7 +766,7 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(Widget*widg const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; if (useMergedTexture) { - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + slider->loadBarTexture(imageFileName,TextureResType::PLIST); } else { @@ -781,7 +781,7 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(Widget*widg const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; if (useMergedTexture) { - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + slider->loadBarTexture(imageFileName,TextureResType::PLIST); } else { @@ -802,7 +802,7 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(Widget*widg const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr; if (useMergedTexture) { - slider->loadSlidBallTextures(normalFileName,pressedFileName,disabledFileName,UI_TEX_TYPE_PLIST); + slider->loadSlidBallTextures(normalFileName,pressedFileName,disabledFileName,TextureResType::PLIST); } else { @@ -815,7 +815,7 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(Widget*widg const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; if (useMergedTexture) { - slider->loadProgressBarTexture(imageFileName, UI_TEX_TYPE_PLIST); + slider->loadProgressBarTexture(imageFileName, TextureResType::PLIST); } else { @@ -884,7 +884,7 @@ void WidgetPropertiesReader0250::setPropsForLoadingBarFromJsonDictionary(Widget const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; if (useMergedTexture) { - loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + loadingBar->loadTexture(imageFileName,TextureResType::PLIST); } else { @@ -1234,9 +1234,9 @@ void WidgetPropertiesReader0300::setColorPropsForWidgetFromJsonDictionary(Widget int colorB = cb ? DICTOOL->getIntValue_json(options, "colorB") : 255; widget->setColor(Color3B(colorR, colorG, colorB)); bool apx = DICTOOL->checkObjectExist_json(options, "anchorPointX"); - float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); + float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == Widget::Type::ELEMENT) ? 0.5f : 0.0f); bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY"); - float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); + float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == Widget::Type::ELEMENT) ? 0.5f : 0.0f); widget->setAnchorPoint(Vector2(apxf, apyf)); bool flipX = DICTOOL->getBooleanValue_json(options, "flipX"); bool flipY = DICTOOL->getBooleanValue_json(options, "flipY"); @@ -1266,7 +1266,7 @@ void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(Widget*widg case 1: { const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - button->loadTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); + button->loadTextureNormal(normalFileName,TextureResType::PLIST); break; } default: @@ -1287,7 +1287,7 @@ void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(Widget*widg case 1: { const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - button->loadTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); + button->loadTexturePressed(pressedFileName,TextureResType::PLIST); break; } default: @@ -1308,7 +1308,7 @@ void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(Widget*widg case 1: { const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - button->loadTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); + button->loadTextureDisabled(disabledFileName,TextureResType::PLIST); break; } default: @@ -1381,7 +1381,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(Widget*wi case 1: { const char* backGroundFileName = DICTOOL->getStringValue_json(backGroundDic, "path"); - checkBox->loadTextureBackGround(backGroundFileName,UI_TEX_TYPE_PLIST); + checkBox->loadTextureBackGround(backGroundFileName,TextureResType::PLIST); break; } default: @@ -1403,7 +1403,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(Widget*wi case 1: { const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(backGroundSelectedDic, "path"); - checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName,UI_TEX_TYPE_PLIST); + checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName,TextureResType::PLIST); break; } default: @@ -1425,7 +1425,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(Widget*wi case 1: { const char* frontCrossFileName = DICTOOL->getStringValue_json(frontCrossDic, "path"); - checkBox->loadTextureFrontCross(frontCrossFileName,UI_TEX_TYPE_PLIST); + checkBox->loadTextureFrontCross(frontCrossFileName,TextureResType::PLIST); break; } default: @@ -1447,7 +1447,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(Widget*wi case 1: { const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(backGroundDisabledDic, "path"); - checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName,UI_TEX_TYPE_PLIST); + checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName,TextureResType::PLIST); break; } default: @@ -1469,7 +1469,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(Widget*wi case 1: { const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "path"); - checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); + checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName,TextureResType::PLIST); break; } default: @@ -1504,7 +1504,7 @@ void WidgetPropertiesReader0300::setPropsForImageViewFromJsonDictionary(Widget*w case 1: { const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + imageView->loadTexture(imageFileName,TextureResType::PLIST); break; } default: @@ -1679,7 +1679,7 @@ void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(Widget*widg case 1: { const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); + panel->setBackGroundImage(imageFileName,TextureResType::PLIST); break; } default: @@ -1740,7 +1740,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(Widget*widg case 1: { const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + slider->loadBarTexture(imageFileName,TextureResType::PLIST); break; } default: @@ -1766,7 +1766,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(Widget*widg case 1: { const char*imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + slider->loadBarTexture(imageFileName,TextureResType::PLIST); break; } default: @@ -1790,7 +1790,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(Widget*widg case 1: { const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - slider->loadSlidBallTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); + slider->loadSlidBallTextureNormal(normalFileName,TextureResType::PLIST); break; } default: @@ -1812,7 +1812,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(Widget*widg case 1: { const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - slider->loadSlidBallTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); + slider->loadSlidBallTexturePressed(pressedFileName,TextureResType::PLIST); break; } default: @@ -1834,7 +1834,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(Widget*widg case 1: { const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - slider->loadSlidBallTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); + slider->loadSlidBallTextureDisabled(disabledFileName,TextureResType::PLIST); break; } default: @@ -1858,7 +1858,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(Widget*widg case 1: { const char* imageFileName = DICTOOL->getStringValue_json(progressBarDic, "path"); - slider->loadProgressBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + slider->loadProgressBarTexture(imageFileName,TextureResType::PLIST); break; } default: @@ -1941,7 +1941,7 @@ void WidgetPropertiesReader0300::setPropsForLoadingBarFromJsonDictionary(Widget case 1: { const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + loadingBar->loadTexture(imageFileName,TextureResType::PLIST); break; } default: diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index cdcd9b841b..349440aa19 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -163,9 +163,9 @@ namespace cocostudio int colorB = cb ? DICTOOL->getIntValue_json(options, "colorB") : 255; widget->setColor(Color3B(colorR, colorG, colorB)); bool apx = DICTOOL->checkObjectExist_json(options, "anchorPointX"); - float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); + float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == Widget::Type::ELEMENT) ? 0.5f : 0.0f); bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY"); - float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); + float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == Widget::Type::ELEMENT) ? 0.5f : 0.0f); widget->setAnchorPoint(Vector2(apxf, apyf)); bool flipX = DICTOOL->getBooleanValue_json(options, "flipX"); bool flipY = DICTOOL->getBooleanValue_json(options, "flipY"); diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index 3b22249e8a..1ffa855647 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -39,10 +39,14 @@ CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_ABSOLUTE = Widget::SizeType: CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_PERCENT = Widget::SizeType::PERCENT; CC_DEPRECATED_ATTRIBUTE const Widget::TextureResType UI_TEX_TYPE_LOCAL = Widget::TextureResType::LOCAL; CC_DEPRECATED_ATTRIBUTE const Widget::TextureResType UI_TEX_TYPE_PLIST = Widget::TextureResType::PLIST; +CC_DEPRECATED_ATTRIBUTE const Widget::Type WidgetTypeWidget = Widget::Type::ELEMENT; +CC_DEPRECATED_ATTRIBUTE const Widget::Type WidgetTypeContainer = Widget::Type::CONTAINER; + CC_DEPRECATED_ATTRIBUTE typedef Widget::TextureResType TextureResType; CC_DEPRECATED_ATTRIBUTE typedef Widget::PositionType PositionType; CC_DEPRECATED_ATTRIBUTE typedef Widget::SizeType SizeType; +CC_DEPRECATED_ATTRIBUTE typedef Widget::Type WidgetType; diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index a36b04c626..a0235410f3 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -608,7 +608,7 @@ _curLayoutExecutant(nullptr), _passFocusToChild(true), _loopFocus(false) { - _widgetType = WidgetTypeContainer; + _widgetType = Type::CONTAINER; onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this); } diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index ad0fa59c06..18fd7b19ef 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -130,7 +130,7 @@ void PageView::addPage(Layout* page) { return; } - if (page->getWidgetType() != WidgetTypeContainer) + if (page->getWidgetType() != Widget::Type::CONTAINER) { return; } @@ -161,7 +161,7 @@ void PageView::insertPage(Layout* page, int idx) { return; } - if (page->getWidgetType() != WidgetTypeContainer) + if (page->getWidgetType() != Widget::Type::CONTAINER) { return; } diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index f09d31ca8c..f7ac907f47 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -46,7 +46,7 @@ _touchEndPos(Vector2::ZERO), _touchEventListener(nullptr), _touchEventSelector(nullptr), _name("default"), -_widgetType(WidgetTypeWidget), +_widgetType(Type::ELEMENT), _actionTag(0), _size(Size::ZERO), _customSize(Size::ZERO), @@ -840,7 +840,7 @@ const char* Widget::getName() const return _name.c_str(); } -WidgetType Widget::getWidgetType() const +Widget::Type Widget::getWidgetType() const { return _widgetType; } diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index 77bce664cd..d4c30fff7c 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -40,12 +40,6 @@ typedef enum BRIGHT_NORMAL, BRIGHT_HIGHLIGHT }BrightStyle; - -typedef enum -{ - WidgetTypeWidget, //control - WidgetTypeContainer //container -}WidgetType; @@ -101,6 +95,12 @@ public: LOCAL = 0, PLIST = 1 }; + + enum class Type + { + ELEMENT, + CONTAINER + }; typedef std::function ccWidgetTouchCallback; @@ -407,7 +407,7 @@ public: * * @return A WidgetType */ - WidgetType getWidgetType() const; + Type getWidgetType() const; /** * Changes the size that is widget's size @@ -662,7 +662,7 @@ protected: ccWidgetTouchCallback _touchEventCallback; std::string _name; - WidgetType _widgetType; + Type _widgetType; int _actionTag; Size _size; Size _customSize; From f070fc335fce64f0571ad2e8069a2bd748f2cbb6 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 15:23:34 +0800 Subject: [PATCH 036/174] issue #5057, refactor BrightStyle to strong typed enum --- cocos/ui/UIButton.cpp | 6 +++--- cocos/ui/UIDeprecated.h | 5 +++++ cocos/ui/UIWidget.cpp | 14 +++++++------- cocos/ui/UIWidget.h | 16 +++++++--------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index f61d1e096c..b54c7816bd 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -149,7 +149,7 @@ void Button::setScale9Enabled(bool able) { return; } - _brightStyle = BRIGHT_NONE; + _brightStyle = BrightStyle::NONE; _scale9Enabled = able; removeProtectedChild(_buttonNormalRenderer); removeProtectedChild(_buttonClickedRenderer); @@ -562,9 +562,9 @@ Node* Button::getVirtualRenderer() { switch (_brightStyle) { - case BRIGHT_NORMAL: + case BrightStyle::NORMAL: return _buttonNormalRenderer; - case BRIGHT_HIGHLIGHT: + case BrightStyle::HIGHLIGHT: return _buttonClickedRenderer; default: return nullptr; diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index 1ffa855647..27e4d87f0b 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -41,12 +41,17 @@ CC_DEPRECATED_ATTRIBUTE const Widget::TextureResType UI_TEX_TYPE_LOCAL = Widget: CC_DEPRECATED_ATTRIBUTE const Widget::TextureResType UI_TEX_TYPE_PLIST = Widget::TextureResType::PLIST; CC_DEPRECATED_ATTRIBUTE const Widget::Type WidgetTypeWidget = Widget::Type::ELEMENT; CC_DEPRECATED_ATTRIBUTE const Widget::Type WidgetTypeContainer = Widget::Type::CONTAINER; +CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_NONE = Widget::BrightStyle::NONE; +CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_NORMAL = Widget::BrightStyle::NORMAL; +CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_HIGHLIGHT = Widget::BrightStyle::HIGHLIGHT; + CC_DEPRECATED_ATTRIBUTE typedef Widget::TextureResType TextureResType; CC_DEPRECATED_ATTRIBUTE typedef Widget::PositionType PositionType; CC_DEPRECATED_ATTRIBUTE typedef Widget::SizeType SizeType; CC_DEPRECATED_ATTRIBUTE typedef Widget::Type WidgetType; +CC_DEPRECATED_ATTRIBUTE typedef Widget::BrightStyle BrightStyle; diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index f7ac907f47..326b120982 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -39,7 +39,7 @@ _bright(true), _touchEnabled(false), _touchPassedEnabled(false), _highlight(false), -_brightStyle(BRIGHT_NONE), +_brightStyle(BrightStyle::NONE), _touchStartPos(Vector2::ZERO), _touchMovePos(Vector2::ZERO), _touchEndPos(Vector2::ZERO), @@ -476,11 +476,11 @@ void Widget::setHighlighted(bool hilight) { if (_highlight) { - setBrightStyle(BRIGHT_HIGHLIGHT); + setBrightStyle(BrightStyle::HIGHLIGHT); } else { - setBrightStyle(BRIGHT_NORMAL); + setBrightStyle(BrightStyle::NORMAL); } } else @@ -494,8 +494,8 @@ void Widget::setBright(bool bright) _bright = bright; if (_bright) { - _brightStyle = BRIGHT_NONE; - setBrightStyle(BRIGHT_NORMAL); + _brightStyle = BrightStyle::NONE; + setBrightStyle(BrightStyle::NORMAL); } else { @@ -512,10 +512,10 @@ void Widget::setBrightStyle(BrightStyle style) _brightStyle = style; switch (_brightStyle) { - case BRIGHT_NORMAL: + case BrightStyle::NORMAL: onPressStateChangedToNormal(); break; - case BRIGHT_HIGHLIGHT: + case BrightStyle::HIGHLIGHT: onPressStateChangedToPressed(); break; default: diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index d4c30fff7c..cab96dec0b 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -33,15 +33,6 @@ THE SOFTWARE. NS_CC_BEGIN namespace ui { - -typedef enum -{ - BRIGHT_NONE = -1, - BRIGHT_NORMAL, - BRIGHT_HIGHLIGHT -}BrightStyle; - - CC_DEPRECATED_ATTRIBUTE typedef enum { @@ -101,6 +92,13 @@ public: ELEMENT, CONTAINER }; + + enum class BrightStyle + { + NONE = -1, + NORMAL, + HIGHLIGHT + }; typedef std::function ccWidgetTouchCallback; From d799ffce404f9aaa14b4160dc8c60e3f62ab1bcb Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 15:32:51 +0800 Subject: [PATCH 037/174] issue #5057, remove include dependency --- cocos/ui/GUIDefine.h | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos/ui/GUIDefine.h b/cocos/ui/GUIDefine.h index 0fcdccc8a0..751fb66791 100644 --- a/cocos/ui/GUIDefine.h +++ b/cocos/ui/GUIDefine.h @@ -26,7 +26,6 @@ #define __TestCpp__GUIDefine__ #include "cocos2d.h" -#include "../../extensions/ExtensionMacros.h" #include #include "cocostudio/ObjectFactory.h" From 70d7d5b493babdf9dda63ddfb11079d7140e02ca Mon Sep 17 00:00:00 2001 From: Mircea Rila Date: Fri, 9 May 2014 10:53:44 +0300 Subject: [PATCH 038/174] add VS2013 support for box2d, chipmunk --- external/Box2D/proj.win32/Box2D.vcxproj | 4 ++++ external/chipmunk/proj.win32/chipmunk.vcxproj | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/external/Box2D/proj.win32/Box2D.vcxproj b/external/Box2D/proj.win32/Box2D.vcxproj index ed59a2460d..60b7f280ea 100644 --- a/external/Box2D/proj.win32/Box2D.vcxproj +++ b/external/Box2D/proj.win32/Box2D.vcxproj @@ -23,6 +23,8 @@ v100 v110 v110_xp + v120 + v120_xp StaticLibrary @@ -30,6 +32,8 @@ v100 v110 v110_xp + v120 + v120_xp diff --git a/external/chipmunk/proj.win32/chipmunk.vcxproj b/external/chipmunk/proj.win32/chipmunk.vcxproj index 0cdc2e835b..2114cd34ec 100644 --- a/external/chipmunk/proj.win32/chipmunk.vcxproj +++ b/external/chipmunk/proj.win32/chipmunk.vcxproj @@ -22,13 +22,17 @@ v100 v110 v110_xp - + v120 + v120_xp + StaticLibrary Unicode v100 v110 v110_xp + v120 + v120_xp From 451b7a1b6b376e00edc19dc08193830906d3f5c6 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 16:04:55 +0800 Subject: [PATCH 039/174] issue #5057, refactor UICheckBox event callback --- cocos/ui/UICheckBox.cpp | 14 +++++++++++++- cocos/ui/UICheckBox.h | 18 ++++++++++++++---- cocos/ui/UIDeprecated.h | 6 ------ cocos/ui/UIWidget.cpp | 6 ------ .../UICheckBoxTest/UICheckBoxTest.cpp | 8 ++++---- .../UICheckBoxTest/UICheckBoxTest.h | 2 +- .../UICheckBoxTest/UICheckBoxTest_Editor.cpp | 8 ++++---- .../UICheckBoxTest/UICheckBoxTest_Editor.h | 2 +- 8 files changed, 37 insertions(+), 27 deletions(-) diff --git a/cocos/ui/UICheckBox.cpp b/cocos/ui/UICheckBox.cpp index cfb8933c6e..003b5623c9 100644 --- a/cocos/ui/UICheckBox.cpp +++ b/cocos/ui/UICheckBox.cpp @@ -65,7 +65,6 @@ _frontCrossDisabledRendererAdaptDirty(true) CheckBox::~CheckBox() { - _checkBoxEventListener = nullptr; _checkBoxEventSelector = nullptr; } @@ -359,6 +358,11 @@ bool CheckBox::getSelectedState() void CheckBox::selectedEvent() { + if (_checkBoxEventCallback) + { + _checkBoxEventCallback(this, EventType::SELECTED); + } + if (_checkBoxEventListener && _checkBoxEventSelector) { (_checkBoxEventListener->*_checkBoxEventSelector)(this,CHECKBOX_STATE_EVENT_SELECTED); @@ -367,6 +371,9 @@ void CheckBox::selectedEvent() void CheckBox::unSelectedEvent() { + if (_checkBoxEventCallback) { + _checkBoxEventCallback(this, EventType::UNSELECTED); + } if (_checkBoxEventListener && _checkBoxEventSelector) { (_checkBoxEventListener->*_checkBoxEventSelector)(this,CHECKBOX_STATE_EVENT_UNSELECTED); @@ -378,6 +385,11 @@ void CheckBox::addEventListenerCheckBox(Ref *target, SEL_SelectedStateEvent sele _checkBoxEventListener = target; _checkBoxEventSelector = selector; } + +void CheckBox::addEventListener(ccCheckBoxCallback callback) +{ + _checkBoxEventCallback = callback; +} void CheckBox::updateFlippedX() { diff --git a/cocos/ui/UICheckBox.h b/cocos/ui/UICheckBox.h index 5d10b824b5..74d82eebd5 100644 --- a/cocos/ui/UICheckBox.h +++ b/cocos/ui/UICheckBox.h @@ -31,13 +31,13 @@ NS_CC_BEGIN namespace ui { -typedef enum +CC_DEPRECATED_ATTRIBUTE typedef enum { CHECKBOX_STATE_EVENT_SELECTED, CHECKBOX_STATE_EVENT_UNSELECTED }CheckBoxEventType; -typedef void (Ref::*SEL_SelectedStateEvent)(Ref*,CheckBoxEventType); +CC_DEPRECATED_ATTRIBUTE typedef void (Ref::*SEL_SelectedStateEvent)(Ref*,CheckBoxEventType); #define checkboxselectedeventselector(_SELECTOR) (SEL_SelectedStateEvent)(&_SELECTOR) /** @@ -50,6 +50,14 @@ class CheckBox : public Widget DECLARE_CLASS_GUI_INFO public: + enum class EventType + { + SELECTED, + UNSELECTED + }; + + typedef std::function ccCheckBoxCallback; + /** * Default constructor */ @@ -165,7 +173,8 @@ public: bool getSelectedState(); //add a call back function would called when checkbox is selected or unselected. - void addEventListenerCheckBox(Ref* target,SEL_SelectedStateEvent selector); + CC_DEPRECATED_ATTRIBUTE void addEventListenerCheckBox(Ref* target,SEL_SelectedStateEvent selector); + void addEventListener(ccCheckBoxCallback callback); //override "onTouchEnded" method of widget. virtual void onTouchEnded(Touch *touch, Event *unusedEvent); @@ -218,9 +227,10 @@ protected: Sprite* _backGroundBoxDisabledRenderer; Sprite* _frontCrossDisabledRenderer; bool _isSelected; - + //if you use the old event callback, it will retain the _checkBoxEventListener Ref* _checkBoxEventListener; SEL_SelectedStateEvent _checkBoxEventSelector; + ccCheckBoxCallback _checkBoxEventCallback; TextureResType _backGroundTexType; TextureResType _backGroundSelectedTexType; diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index 27e4d87f0b..37a413da48 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -26,7 +26,6 @@ #define cocos2d_libs_UIDeprecated_h #include "base/CCPlatformMacros.h" -//#include "ui/UIWidget.h" NS_CC_BEGIN @@ -45,7 +44,6 @@ CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_NONE = Widget::BrightSt CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_NORMAL = Widget::BrightStyle::NORMAL; CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_HIGHLIGHT = Widget::BrightStyle::HIGHLIGHT; - CC_DEPRECATED_ATTRIBUTE typedef Widget::TextureResType TextureResType; CC_DEPRECATED_ATTRIBUTE typedef Widget::PositionType PositionType; @@ -53,10 +51,6 @@ CC_DEPRECATED_ATTRIBUTE typedef Widget::SizeType SizeType; CC_DEPRECATED_ATTRIBUTE typedef Widget::Type WidgetType; CC_DEPRECATED_ATTRIBUTE typedef Widget::BrightStyle BrightStyle; - - - - } diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index 326b120982..61362399c3 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -81,9 +81,6 @@ Widget::~Widget() if (_realFocusedWidget == this) { _realFocusedWidget = nullptr; } - - CC_SAFE_RELEASE_NULL(_touchEventListener); - } Widget* Widget::create() @@ -661,9 +658,6 @@ void Widget::addTouchEventListener(Ref *target, SEL_TouchEvent selector) { _touchEventListener = target; _touchEventSelector = selector; - CC_SAFE_RETAIN(target); - - } void Widget::addTouchEventListener(Widget::ccWidgetTouchCallback callback) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp index 3b7209978f..8b076fc264 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp @@ -40,7 +40,7 @@ bool UICheckBoxTest::init() "cocosui/check_box_active_disable.png"); checkBox->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - checkBox->addEventListenerCheckBox(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent)); + checkBox->addEventListener(CC_CALLBACK_2(UICheckBoxTest::selectedEvent, this)); _uiLayer->addChild(checkBox); return true; @@ -48,15 +48,15 @@ bool UICheckBoxTest::init() return false; } -void UICheckBoxTest::selectedEvent(Ref* pSender,CheckBoxEventType type) +void UICheckBoxTest::selectedEvent(Ref* pSender,CheckBox::EventType type) { switch (type) { - case CHECKBOX_STATE_EVENT_SELECTED: + case CheckBox::EventType::SELECTED: _displayValueLabel->setText(String::createWithFormat("Selected")->getCString()); break; - case CHECKBOX_STATE_EVENT_UNSELECTED: + case CheckBox::EventType::UNSELECTED: _displayValueLabel->setText(String::createWithFormat("Unselected")->getCString()); break; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h index ef136a4524..7ebcec8b5d 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h @@ -33,7 +33,7 @@ public: UICheckBoxTest(); ~UICheckBoxTest(); bool init(); - void selectedEvent(Ref* pSender,CheckBoxEventType type); + void selectedEvent(Ref* pSender,CheckBox::EventType type); protected: UI_SCENE_CREATE_FUNC(UICheckBoxTest) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp index 5fc82d4238..1b1ff152b8 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp @@ -35,7 +35,7 @@ bool UICheckBoxTest_Editor::init() _sceneTitle = static_cast(Helper::seekWidgetByName(root, "UItest")); CheckBox* checkbox = static_cast(Helper::seekWidgetByName(root, "CheckBox_540")); - checkbox->addEventListenerCheckBox(this, checkboxselectedeventselector(UICheckBoxTest_Editor::selectedStateEvent)); + checkbox->addEventListener(CC_CALLBACK_2(UICheckBoxTest_Editor::selectedStateEvent, this)); _displayValueLabel = Text::create(); _displayValueLabel->setFontName("fonts/Marker Felt.ttf"); @@ -51,15 +51,15 @@ bool UICheckBoxTest_Editor::init() return false; } -void UICheckBoxTest_Editor::selectedStateEvent(Ref *pSender, CheckBoxEventType type) +void UICheckBoxTest_Editor::selectedStateEvent(Ref *pSender, CheckBox::EventType type) { switch (type) { - case CHECKBOX_STATE_EVENT_UNSELECTED: + case CheckBox::EventType::UNSELECTED: _displayValueLabel->setText("Unselected"); break; - case CHECKBOX_STATE_EVENT_SELECTED: + case CheckBox::EventType::SELECTED: _displayValueLabel->setText("Selected"); break; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.h index cd1b75993f..c9ed1cb988 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.h @@ -33,7 +33,7 @@ public: UICheckBoxTest_Editor(); ~UICheckBoxTest_Editor(); bool init(); - void selectedStateEvent(Ref* pSender, CheckBoxEventType type); + void selectedStateEvent(Ref* pSender, CheckBox::EventType type); protected: UI_SCENE_EDITOR_CREATE_FUNC(UICheckBoxTest_Editor) From ebfbf0eba3ca07913a5b19bf3e76a3e81984538b Mon Sep 17 00:00:00 2001 From: Mircea Rila Date: Fri, 9 May 2014 11:10:08 +0300 Subject: [PATCH 040/174] fix box2d win32 project --- external/Box2D/proj.win32/Box2D.vcxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/Box2D/proj.win32/Box2D.vcxproj b/external/Box2D/proj.win32/Box2D.vcxproj index 60b7f280ea..ba55486c3a 100644 --- a/external/Box2D/proj.win32/Box2D.vcxproj +++ b/external/Box2D/proj.win32/Box2D.vcxproj @@ -24,7 +24,7 @@ v110 v110_xp v120 - v120_xp + v120_xp StaticLibrary @@ -33,7 +33,7 @@ v110 v110_xp v120 - v120_xp + v120_xp From 305f052344612db9741ac8280318efad56146203 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 16:31:22 +0800 Subject: [PATCH 041/174] issue #5057, refactor LayoutClippingType --- cocos/ui/UIDeprecated.h | 7 +++++-- cocos/ui/UILayout.cpp | 14 +++++++------- cocos/ui/UILayout.h | 16 +++++++++------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index 37a413da48..c7ae434002 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -30,8 +30,7 @@ NS_CC_BEGIN namespace ui { - - + CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_ABSOLUTE = Widget::PositionType::ABSOLUTE; CC_DEPRECATED_ATTRIBUTE const Widget::PositionType POSITION_PERCENT = Widget::PositionType::PERCENT; CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_ABSOLUTE = Widget::SizeType::ABSOLUTE; @@ -43,6 +42,8 @@ CC_DEPRECATED_ATTRIBUTE const Widget::Type WidgetTypeContainer = Widget::Type::C CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_NONE = Widget::BrightStyle::NONE; CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_NORMAL = Widget::BrightStyle::NORMAL; CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_HIGHLIGHT = Widget::BrightStyle::HIGHLIGHT; +CC_DEPRECATED_ATTRIBUTE const Layout::ClippingType LAYOUT_CLIPPING_STENCIL = Layout::ClippingType::STENCIL; +CC_DEPRECATED_ATTRIBUTE const Layout::ClippingType LAYOUT_CLIPPING_SCISSOR = Layout::ClippingType::SCISSOR; CC_DEPRECATED_ATTRIBUTE typedef Widget::TextureResType TextureResType; @@ -50,6 +51,8 @@ CC_DEPRECATED_ATTRIBUTE typedef Widget::PositionType PositionType; CC_DEPRECATED_ATTRIBUTE typedef Widget::SizeType SizeType; CC_DEPRECATED_ATTRIBUTE typedef Widget::Type WidgetType; CC_DEPRECATED_ATTRIBUTE typedef Widget::BrightStyle BrightStyle; + CC_DEPRECATED_ATTRIBUTE typedef Layout::ClippingType LayoutClippingType; + } diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index a0235410f3..756f67ce7c 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -583,7 +583,7 @@ _alongVector(Vector2(0.0f, -1.0f)), _cOpacity(255), _backGroundImageTextureSize(Size::ZERO), _layoutType(LAYOUT_ABSOLUTE), -_clippingType(LAYOUT_CLIPPING_STENCIL), +_clippingType(ClippingType::STENCIL), _clippingStencil(nullptr), _scissorRectDirty(false), _clippingRect(Rect::ZERO), @@ -714,10 +714,10 @@ void Layout::visit(Renderer *renderer, const Matrix &parentTransform, bool paren { switch (_clippingType) { - case LAYOUT_CLIPPING_STENCIL: + case ClippingType::STENCIL: stencilClippingVisit(renderer, parentTransform, parentTransformUpdated); break; - case LAYOUT_CLIPPING_SCISSOR: + case ClippingType::SCISSOR: scissorClippingVisit(renderer, parentTransform, parentTransformUpdated); break; default: @@ -916,7 +916,7 @@ void Layout::setClippingEnabled(bool able) _clippingEnabled = able; switch (_clippingType) { - case LAYOUT_CLIPPING_STENCIL: + case ClippingType::STENCIL: if (able) { static bool once = true; @@ -952,7 +952,7 @@ void Layout::setClippingEnabled(bool able) } } -void Layout::setClippingType(LayoutClippingType type) +void Layout::setClippingType(ClippingType type) { if (type == _clippingType) { @@ -964,14 +964,14 @@ void Layout::setClippingType(LayoutClippingType type) setClippingEnabled(clippingEnabled); } -LayoutClippingType Layout::getClippingType() +Layout::ClippingType Layout::getClippingType() { return _clippingType; } void Layout::setStencilClippingSize(const Size &size) { - if (_clippingEnabled && _clippingType == LAYOUT_CLIPPING_STENCIL) + if (_clippingEnabled && _clippingType == ClippingType::STENCIL) { Vector2 rect[4]; rect[0] = Vector2::ZERO; diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index 96b6fce71b..490ccf30f2 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -46,10 +46,7 @@ typedef enum LAYOUT_RELATIVE }LayoutType; -typedef enum { - LAYOUT_CLIPPING_STENCIL, - LAYOUT_CLIPPING_SCISSOR -}LayoutClippingType; + /** * @js NA @@ -63,6 +60,11 @@ class Layout : public Widget DECLARE_CLASS_GUI_INFO public: + enum class ClippingType + { + STENCIL, + SCISSOR + }; /** * Default constructor */ @@ -185,9 +187,9 @@ public: */ virtual void setClippingEnabled(bool enabled); - void setClippingType(LayoutClippingType type); + void setClippingType(ClippingType type); - LayoutClippingType getClippingType(); + ClippingType getClippingType(); /** * Gets if layout is clipping enabled. @@ -461,7 +463,7 @@ protected: GLubyte _cOpacity; Size _backGroundImageTextureSize; LayoutType _layoutType; - LayoutClippingType _clippingType; + ClippingType _clippingType; DrawNode* _clippingStencil; bool _scissorRectDirty; Rect _clippingRect; From e8e0d007bdebd5f8754acf7b7cef0f90d5a52a09 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 16:49:00 +0800 Subject: [PATCH 042/174] issue #5057, refactor LayoutType --- .../LayoutReader/LayoutReader.cpp | 2 +- cocos/ui/UIDeprecated.h | 8 ++++- cocos/ui/UIHBox.cpp | 2 +- cocos/ui/UILayout.cpp | 34 +++++++++---------- cocos/ui/UILayout.h | 15 ++++---- cocos/ui/UIListView.cpp | 6 ++-- cocos/ui/UIPageView.h | 2 +- cocos/ui/UIRelativeBox.cpp | 2 +- cocos/ui/UIScrollView.cpp | 2 +- cocos/ui/UIVBox.cpp | 2 +- .../UILayoutTest/UILayoutTest.cpp | 8 ++--- 11 files changed, 45 insertions(+), 38 deletions(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp index fcc690e3b6..3db4368ad7 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp @@ -97,7 +97,7 @@ namespace cocostudio float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); } - panel->setLayoutType((LayoutType)DICTOOL->getIntValue_json(options, "layoutType")); + panel->setLayoutType((Layout::LayoutType)DICTOOL->getIntValue_json(options, "layoutType")); int bgimgcr = DICTOOL->getIntValue_json(options, "colorR"); int bgimgcg = DICTOOL->getIntValue_json(options, "colorG"); diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index c7ae434002..5e6d531058 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -44,6 +44,11 @@ CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_NORMAL = Widget::Bright CC_DEPRECATED_ATTRIBUTE const Widget::BrightStyle BRIGHT_HIGHLIGHT = Widget::BrightStyle::HIGHLIGHT; CC_DEPRECATED_ATTRIBUTE const Layout::ClippingType LAYOUT_CLIPPING_STENCIL = Layout::ClippingType::STENCIL; CC_DEPRECATED_ATTRIBUTE const Layout::ClippingType LAYOUT_CLIPPING_SCISSOR = Layout::ClippingType::SCISSOR; +CC_DEPRECATED_ATTRIBUTE const Layout::LayoutType LAYOUT_ABSOLUTE = Layout::LayoutType::ABSOLUTE; +CC_DEPRECATED_ATTRIBUTE const Layout::LayoutType LAYOUT_LINEAR_VERTICAL = Layout::LayoutType::VERTICAL; +CC_DEPRECATED_ATTRIBUTE const Layout::LayoutType LAYOUT_LINEAR_HORIZONTAL = Layout::LayoutType::HORIZONTAL; +CC_DEPRECATED_ATTRIBUTE const Layout::LayoutType LAYOUT_RELATIVE = Layout::LayoutType::VERTICAL; + CC_DEPRECATED_ATTRIBUTE typedef Widget::TextureResType TextureResType; @@ -51,7 +56,8 @@ CC_DEPRECATED_ATTRIBUTE typedef Widget::PositionType PositionType; CC_DEPRECATED_ATTRIBUTE typedef Widget::SizeType SizeType; CC_DEPRECATED_ATTRIBUTE typedef Widget::Type WidgetType; CC_DEPRECATED_ATTRIBUTE typedef Widget::BrightStyle BrightStyle; - CC_DEPRECATED_ATTRIBUTE typedef Layout::ClippingType LayoutClippingType; +CC_DEPRECATED_ATTRIBUTE typedef Layout::ClippingType LayoutClippingType; +CC_DEPRECATED_ATTRIBUTE typedef Layout::LayoutType LayoutType; } diff --git a/cocos/ui/UIHBox.cpp b/cocos/ui/UIHBox.cpp index 08fc052a14..fa49d611ce 100644 --- a/cocos/ui/UIHBox.cpp +++ b/cocos/ui/UIHBox.cpp @@ -64,7 +64,7 @@ bool HBox::init() { if (Layout::init()) { - setLayoutType(LAYOUT_LINEAR_HORIZONTAL); + setLayoutType(LayoutType::HORIZONTAL); return true; } return false; diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 756f67ce7c..b8803c024b 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -582,7 +582,7 @@ _gEndColor(Color3B::WHITE), _alongVector(Vector2(0.0f, -1.0f)), _cOpacity(255), _backGroundImageTextureSize(Size::ZERO), -_layoutType(LAYOUT_ABSOLUTE), +_layoutType(LayoutType::ABSOLUTE), _clippingType(ClippingType::STENCIL), _clippingStencil(nullptr), _scissorRectDirty(false), @@ -1175,10 +1175,10 @@ void Layout::supplyTheLayoutParameterLackToChild(Widget *child) } switch (_layoutType) { - case LAYOUT_ABSOLUTE: + case LayoutType::ABSOLUTE: break; - case LAYOUT_LINEAR_HORIZONTAL: - case LAYOUT_LINEAR_VERTICAL: + case LayoutType::HORIZONTAL: + case LayoutType::VERTICAL: { LinearLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_LINEAR)); if (!layoutParameter) @@ -1187,7 +1187,7 @@ void Layout::supplyTheLayoutParameterLackToChild(Widget *child) } break; } - case LAYOUT_RELATIVE: + case LayoutType::RELATIVE: { RelativeLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_RELATIVE)); if (!layoutParameter) @@ -1446,13 +1446,13 @@ LayoutExecutant* Layout::createCurrentLayoutExecutant() LayoutExecutant* exe = nullptr; switch (_layoutType) { - case LAYOUT_LINEAR_VERTICAL: + case LayoutType::VERTICAL: exe = LinearVerticalLayoutExecutant::create(); break; - case LAYOUT_LINEAR_HORIZONTAL: + case LayoutType::HORIZONTAL: exe = LinearHorizontalLayoutExecutant::create(); break; - case LAYOUT_RELATIVE: + case LayoutType::RELATIVE: exe = RelativeLayoutExecutant::create(); break; default: @@ -1461,7 +1461,7 @@ LayoutExecutant* Layout::createCurrentLayoutExecutant() return exe; } -LayoutType Layout::getLayoutType() const +Layout::LayoutType Layout::getLayoutType() const { return _layoutType; } @@ -1565,11 +1565,11 @@ Size Layout::getLayoutContentSize()const //substract extra size LayoutType type = this->getLayoutType(); - if (type == LAYOUT_LINEAR_HORIZONTAL) + if (type == LayoutType::HORIZONTAL) { layoutSize = layoutSize - Size(0, layoutSize.height/widgetCount * (widgetCount-1)); } - if (type == LAYOUT_LINEAR_VERTICAL) + if (type == LayoutType::VERTICAL) { layoutSize = layoutSize - Size(layoutSize.width/widgetCount * (widgetCount-1), 0); } @@ -2186,7 +2186,7 @@ bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction) auto container = parent->getChildren(); ssize_t index = container.getIndex(widget); - if (parent->getLayoutType() == LAYOUT_LINEAR_HORIZONTAL) + if (parent->getLayoutType() == LayoutType::HORIZONTAL) { if (direction == FocusDirection::LEFT) { if (index == 0) @@ -2218,7 +2218,7 @@ bool Layout::isLastWidgetInContainer(Widget* widget, FocusDirection direction) return isLastWidgetInContainer(parent, direction); } } - else if(parent->getLayoutType() == LAYOUT_LINEAR_VERTICAL) + else if(parent->getLayoutType() == LayoutType::VERTICAL) { if (direction == FocusDirection::UP) { @@ -2272,7 +2272,7 @@ bool Layout::isWidgetAncestorSupportLoopFocus(Widget* widget, FocusDirection di if (parent->isLoopFocus()) { auto layoutType = parent->getLayoutType(); - if (layoutType == LAYOUT_LINEAR_HORIZONTAL) + if (layoutType == LayoutType::HORIZONTAL) { if (direction == FocusDirection::LEFT || direction == FocusDirection::RIGHT) { @@ -2283,7 +2283,7 @@ bool Layout::isWidgetAncestorSupportLoopFocus(Widget* widget, FocusDirection di return isWidgetAncestorSupportLoopFocus(parent, direction); } } - if (layoutType == LAYOUT_LINEAR_VERTICAL) + if (layoutType == LayoutType::VERTICAL) { if (direction == FocusDirection::DOWN || direction == FocusDirection::UP) { @@ -2334,7 +2334,7 @@ Widget* Layout::findNextFocusedWidget(FocusDirection direction, Widget* current) } else if(current->isFocused() || !current->isFocusEnabled()) { - if (_layoutType == LAYOUT_LINEAR_HORIZONTAL) + if (_layoutType == LayoutType::HORIZONTAL) { switch (direction) { @@ -2371,7 +2371,7 @@ Widget* Layout::findNextFocusedWidget(FocusDirection direction, Widget* current) break; } } - else if (_layoutType == LAYOUT_LINEAR_VERTICAL) + else if (_layoutType == LayoutType::VERTICAL) { switch (direction) { diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index 490ccf30f2..6beaa40cc5 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -38,13 +38,6 @@ typedef enum LAYOUT_COLOR_GRADIENT }LayoutBackGroundColorType; -typedef enum -{ - LAYOUT_ABSOLUTE, - LAYOUT_LINEAR_VERTICAL, - LAYOUT_LINEAR_HORIZONTAL, - LAYOUT_RELATIVE -}LayoutType; @@ -65,6 +58,14 @@ public: STENCIL, SCISSOR }; + + enum class LayoutType + { + ABSOLUTE, + VERTICAL, + HORIZONTAL, + RELATIVE + }; /** * Default constructor */ diff --git a/cocos/ui/UIListView.cpp b/cocos/ui/UIListView.cpp index 7552c4c490..1edbd4270b 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -68,7 +68,7 @@ bool ListView::init() { if (ScrollView::init()) { - setLayoutType(LAYOUT_LINEAR_VERTICAL); + setLayoutType(LayoutType::VERTICAL); return true; } return false; @@ -361,10 +361,10 @@ void ListView::setDirection(SCROLLVIEW_DIR dir) switch (dir) { case SCROLLVIEW_DIR_VERTICAL: - setLayoutType(LAYOUT_LINEAR_VERTICAL); + setLayoutType(LayoutType::VERTICAL); break; case SCROLLVIEW_DIR_HORIZONTAL: - setLayoutType(LAYOUT_LINEAR_HORIZONTAL); + setLayoutType(LayoutType::HORIZONTAL); break; case SCROLLVIEW_DIR_BOTH: return; diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index e403c40a41..fd68cb98ea 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -154,7 +154,7 @@ public: * * @return LayoutType */ - virtual LayoutType getLayoutType() const override{return LAYOUT_ABSOLUTE;}; + virtual LayoutType getLayoutType() const override{return LayoutType::ABSOLUTE;}; /** * Returns the "class name" of widget. diff --git a/cocos/ui/UIRelativeBox.cpp b/cocos/ui/UIRelativeBox.cpp index ccad3f62cf..6209a604cc 100644 --- a/cocos/ui/UIRelativeBox.cpp +++ b/cocos/ui/UIRelativeBox.cpp @@ -64,7 +64,7 @@ bool RelativeBox::init() { if (Layout::init()) { - setLayoutType(LAYOUT_RELATIVE); + setLayoutType(LayoutType::RELATIVE); return true; } return false; diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index cd69c209ed..db13b67508 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -1667,7 +1667,7 @@ void ScrollView::setLayoutType(LayoutType type) _innerContainer->setLayoutType(type); } -LayoutType ScrollView::getLayoutType() const +Layout::LayoutType ScrollView::getLayoutType() const { return _innerContainer->getLayoutType(); } diff --git a/cocos/ui/UIVBox.cpp b/cocos/ui/UIVBox.cpp index 86a832c7d3..0b81440403 100644 --- a/cocos/ui/UIVBox.cpp +++ b/cocos/ui/UIVBox.cpp @@ -64,7 +64,7 @@ bool VBox::init() { if (Layout::init()) { - setLayoutType(LAYOUT_LINEAR_VERTICAL); + setLayoutType(LayoutType::VERTICAL); return true; } return false; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp index e94057c19c..fcbd2c9b32 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp @@ -345,7 +345,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init() // Create the layout Layout* layout = Layout::create(); - layout->setLayoutType(LAYOUT_LINEAR_VERTICAL); + layout->setLayoutType(LayoutType::VERTICAL); layout->setSize(Size(280, 150)); Size backgroundSize = background->getSize(); layout->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + @@ -419,7 +419,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init() // Create the layout Layout* layout = Layout::create(); - layout->setLayoutType(LAYOUT_LINEAR_HORIZONTAL); + layout->setLayoutType(LayoutType::HORIZONTAL); layout->setClippingEnabled(true); layout->setSize(Size(280, 150)); Size backgroundSize = background->getSize(); @@ -493,7 +493,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() // Create the layout Layout* layout = Layout::create(); - layout->setLayoutType(LAYOUT_RELATIVE); + layout->setLayoutType(LayoutType::RELATIVE); layout->setSize(Size(280, 150)); layout->setBackGroundColorType(LAYOUT_COLOR_SOLID); layout->setBackGroundColor(Color3B::GREEN); @@ -628,7 +628,7 @@ bool UILayoutTest_Layout_Relative_Location::init() // Create the layout Layout* layout = Layout::create(); - layout->setLayoutType(LAYOUT_RELATIVE); + layout->setLayoutType(LayoutType::RELATIVE); layout->setSize(Size(280, 150)); Size backgroundSize = background->getSize(); layout->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + From 09a53e7b03e9e56714625c05a967d0317708683e Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 17:05:36 +0800 Subject: [PATCH 043/174] issue #5057, refactor BackGroundColorType --- .../cocostudio/CCSGUIReader.cpp | 6 ++--- .../LayoutReader/LayoutReader.cpp | 2 +- cocos/ui/UIDeprecated.h | 5 ++++ cocos/ui/UILayout.cpp | 24 +++++++++---------- cocos/ui/UILayout.h | 23 ++++++++---------- .../UILayoutTest/UILayoutTest.cpp | 6 ++--- .../UIScrollViewTest/UIScrollViewTest.cpp | 4 ++-- 7 files changed, 36 insertions(+), 34 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index cfb1cd9ace..39ce7574eb 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -694,7 +694,7 @@ void WidgetPropertiesReader0250::setPropsForLayoutFromJsonDictionary(Widget*widg int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); int colorType = DICTOOL->getIntValue_json(options, "colorType"); - panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); + panel->setBackGroundColorType(Layout::BackGroundColorType(colorType)); panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); panel->setBackGroundColor(Color3B(cr, cg, cb)); panel->setBackGroundColorOpacity(co); @@ -1658,7 +1658,7 @@ void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(Widget*widg int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); int colorType = DICTOOL->getIntValue_json(options, "colorType"); - panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); + panel->setBackGroundColorType(Layout::BackGroundColorType(colorType)); panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); panel->setBackGroundColor(Color3B(cr, cg, cb)); panel->setBackGroundColorOpacity(co); @@ -1694,7 +1694,7 @@ void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(Widget*widg float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); } - panel->setLayoutType((LayoutType)DICTOOL->getIntValue_json(options, "layoutType")); + panel->setLayoutType((Layout::LayoutType)DICTOOL->getIntValue_json(options, "layoutType")); setColorPropsForWidgetFromJsonDictionary(widget,options); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp index 3db4368ad7..ffc826ed4c 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp @@ -77,7 +77,7 @@ namespace cocostudio int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); int colorType = DICTOOL->getIntValue_json(options, "colorType"); - panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); + panel->setBackGroundColorType(Layout::BackGroundColorType(colorType)); panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); panel->setBackGroundColor(Color3B(cr, cg, cb)); panel->setBackGroundColorOpacity(co); diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index 5e6d531058..509b472248 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -48,6 +48,10 @@ CC_DEPRECATED_ATTRIBUTE const Layout::LayoutType LAYOUT_ABSOLUTE = Layout::Layou CC_DEPRECATED_ATTRIBUTE const Layout::LayoutType LAYOUT_LINEAR_VERTICAL = Layout::LayoutType::VERTICAL; CC_DEPRECATED_ATTRIBUTE const Layout::LayoutType LAYOUT_LINEAR_HORIZONTAL = Layout::LayoutType::HORIZONTAL; CC_DEPRECATED_ATTRIBUTE const Layout::LayoutType LAYOUT_RELATIVE = Layout::LayoutType::VERTICAL; +CC_DEPRECATED_ATTRIBUTE const Layout::BackGroundColorType LAYOUT_COLOR_NONE = Layout::BackGroundColorType::NONE; +CC_DEPRECATED_ATTRIBUTE const Layout::BackGroundColorType LAYOUT_COLOR_SOLID = Layout::BackGroundColorType::SOLID; +CC_DEPRECATED_ATTRIBUTE const Layout::BackGroundColorType LAYOUT_COLOR_GRADIENT + = Layout::BackGroundColorType::GRADIENT; @@ -58,6 +62,7 @@ CC_DEPRECATED_ATTRIBUTE typedef Widget::Type WidgetType; CC_DEPRECATED_ATTRIBUTE typedef Widget::BrightStyle BrightStyle; CC_DEPRECATED_ATTRIBUTE typedef Layout::ClippingType LayoutClippingType; CC_DEPRECATED_ATTRIBUTE typedef Layout::LayoutType LayoutType; +CC_DEPRECATED_ATTRIBUTE typedef Layout::BackGroundColorType LayoutBackGroundColorType; } diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index b8803c024b..3de8a03df6 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -572,7 +572,7 @@ _backGroundScale9Enabled(false), _backGroundImage(nullptr), _backGroundImageFileName(""), _backGroundImageCapInsets(Rect::ZERO), -_colorType(LAYOUT_COLOR_NONE), +_colorType(BackGroundColorType::NONE), _bgImageTexType(TextureResType::LOCAL), _colorRender(nullptr), _gradientRender(nullptr), @@ -1229,7 +1229,7 @@ void Layout::removeBackGroundImage() _backGroundImageTextureSize = Size::ZERO; } -void Layout::setBackGroundColorType(LayoutBackGroundColorType type) +void Layout::setBackGroundColorType(BackGroundColorType type) { if (_colorType == type) { @@ -1237,7 +1237,7 @@ void Layout::setBackGroundColorType(LayoutBackGroundColorType type) } switch (_colorType) { - case LAYOUT_COLOR_NONE: + case BackGroundColorType::NONE: if (_colorRender) { removeProtectedChild(_colorRender); @@ -1249,14 +1249,14 @@ void Layout::setBackGroundColorType(LayoutBackGroundColorType type) _gradientRender = nullptr; } break; - case LAYOUT_COLOR_SOLID: + case BackGroundColorType::SOLID: if (_colorRender) { removeProtectedChild(_colorRender); _colorRender = nullptr; } break; - case LAYOUT_COLOR_GRADIENT: + case BackGroundColorType::GRADIENT: if (_gradientRender) { removeProtectedChild(_gradientRender); @@ -1269,16 +1269,16 @@ void Layout::setBackGroundColorType(LayoutBackGroundColorType type) _colorType = type; switch (_colorType) { - case LAYOUT_COLOR_NONE: + case BackGroundColorType::NONE: break; - case LAYOUT_COLOR_SOLID: + case BackGroundColorType::SOLID: _colorRender = LayerColor::create(); _colorRender->setContentSize(_size); _colorRender->setOpacity(_cOpacity); _colorRender->setColor(_cColor); addProtectedChild(_colorRender, BCAKGROUNDCOLORRENDERER_Z, -1); break; - case LAYOUT_COLOR_GRADIENT: + case BackGroundColorType::GRADIENT: _gradientRender = LayerGradient::create(); _gradientRender->setContentSize(_size); _gradientRender->setOpacity(_cOpacity); @@ -1292,7 +1292,7 @@ void Layout::setBackGroundColorType(LayoutBackGroundColorType type) } } -LayoutBackGroundColorType Layout::getBackGroundColorType() +Layout::BackGroundColorType Layout::getBackGroundColorType() { return _colorType; } @@ -1340,12 +1340,12 @@ void Layout::setBackGroundColorOpacity(GLubyte opacity) _cOpacity = opacity; switch (_colorType) { - case LAYOUT_COLOR_NONE: + case BackGroundColorType::NONE: break; - case LAYOUT_COLOR_SOLID: + case BackGroundColorType::SOLID: _colorRender->setOpacity(opacity); break; - case LAYOUT_COLOR_GRADIENT: + case BackGroundColorType::GRADIENT: _gradientRender->setOpacity(opacity); break; default: diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index 6beaa40cc5..6e5bc39dbf 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -31,16 +31,6 @@ NS_CC_BEGIN namespace ui { -typedef enum -{ - LAYOUT_COLOR_NONE, - LAYOUT_COLOR_SOLID, - LAYOUT_COLOR_GRADIENT -}LayoutBackGroundColorType; - - - - /** * @js NA * @lua NA @@ -66,6 +56,13 @@ public: HORIZONTAL, RELATIVE }; + + enum class BackGroundColorType + { + NONE, + SOLID, + GRADIENT + }; /** * Default constructor */ @@ -106,9 +103,9 @@ public: * * @param type @see LayoutBackGroundColorType. */ - void setBackGroundColorType(LayoutBackGroundColorType type); + void setBackGroundColorType(BackGroundColorType type); - LayoutBackGroundColorType getBackGroundColorType(); + BackGroundColorType getBackGroundColorType(); /** * Sets background iamge use scale9 renderer. @@ -453,7 +450,7 @@ protected: Node* _backGroundImage; std::string _backGroundImageFileName; Rect _backGroundImageCapInsets; - LayoutBackGroundColorType _colorType; + BackGroundColorType _colorType; TextureResType _bgImageTexType; LayerColor* _colorRender; LayerGradient* _gradientRender; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp index fcbd2c9b32..34b59eec14 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp @@ -95,7 +95,7 @@ bool UILayoutTest_Color::init() // Create the layout with color render Layout* layout = Layout::create(); - layout->setBackGroundColorType(LAYOUT_COLOR_SOLID); + layout->setBackGroundColorType(Layout::BackGroundColorType::SOLID); layout->setBackGroundColor(Color3B(128, 128, 128)); layout->setSize(Size(280, 150)); Size backgroundSize = background->getContentSize(); @@ -159,7 +159,7 @@ bool UILayoutTest_Gradient::init() // Create the layout with gradient render Layout* layout = Layout::create(); - layout->setBackGroundColorType(LAYOUT_COLOR_GRADIENT); + layout->setBackGroundColorType(Layout::BackGroundColorType::GRADIENT); layout->setBackGroundColor(Color3B(64, 64, 64), Color3B(192, 192, 192)); layout->setSize(Size(280, 150)); Size backgroundSize = background->getContentSize(); @@ -495,7 +495,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() Layout* layout = Layout::create(); layout->setLayoutType(LayoutType::RELATIVE); layout->setSize(Size(280, 150)); - layout->setBackGroundColorType(LAYOUT_COLOR_SOLID); + layout->setBackGroundColorType(Layout::BackGroundColorType::SOLID); layout->setBackGroundColor(Color3B::GREEN); Size backgroundSize = background->getSize(); layout->setPosition(Vector2((widgetSize.width - backgroundSize.width) / 2.0f + diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp index 992c2455b1..2b7af27bc3 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp @@ -254,7 +254,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection::init() ui::ScrollView* sc = ui::ScrollView::create(); sc->setBackGroundColor(Color3B::GREEN); - sc->setBackGroundColorType(LAYOUT_COLOR_SOLID); + sc->setBackGroundColorType(Layout::BackGroundColorType::SOLID); sc->setDirection(SCROLLVIEW_DIR_BOTH); sc->setInnerContainerSize(Size(480, 320)); sc->setSize(Size(100,100)); @@ -309,7 +309,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce::init() ui::ScrollView* sc = ui::ScrollView::create(); sc->setBackGroundColor(Color3B::GREEN); - sc->setBackGroundColorType(LAYOUT_COLOR_SOLID); + sc->setBackGroundColorType(Layout::BackGroundColorType::SOLID); sc->setBounceEnabled(true); sc->setDirection(SCROLLVIEW_DIR_BOTH); sc->setInnerContainerSize(Size(480, 320)); From d12a71f738d43b1ea40f96b6df451c2f80a6818a Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 17:16:11 +0800 Subject: [PATCH 044/174] issue #5057, refactor UILayoutDefine --- build/cocos2d_libs.xcodeproj/project.pbxproj | 12 --- cocos/ui/UILayoutDefine.cpp | 64 ------------- cocos/ui/UILayoutDefine.h | 96 -------------------- cocos/ui/UILayoutParameter.cpp | 31 +++++++ cocos/ui/UILayoutParameter.h | 65 ++++++++++++- cocos/ui/UIWidget.h | 1 - 6 files changed, 95 insertions(+), 174 deletions(-) delete mode 100644 cocos/ui/UILayoutDefine.cpp delete mode 100644 cocos/ui/UILayoutDefine.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 47fbfdc242..eaa1004453 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1039,10 +1039,6 @@ 2905FA5718CF08D100240AA3 /* UILayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2905F9F818CF08D000240AA3 /* UILayout.cpp */; }; 2905FA5818CF08D100240AA3 /* UILayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905F9F918CF08D000240AA3 /* UILayout.h */; }; 2905FA5918CF08D100240AA3 /* UILayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905F9F918CF08D000240AA3 /* UILayout.h */; }; - 2905FA5A18CF08D100240AA3 /* UILayoutDefine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2905F9FA18CF08D000240AA3 /* UILayoutDefine.cpp */; }; - 2905FA5B18CF08D100240AA3 /* UILayoutDefine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2905F9FA18CF08D000240AA3 /* UILayoutDefine.cpp */; }; - 2905FA5C18CF08D100240AA3 /* UILayoutDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905F9FB18CF08D000240AA3 /* UILayoutDefine.h */; }; - 2905FA5D18CF08D100240AA3 /* UILayoutDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905F9FB18CF08D000240AA3 /* UILayoutDefine.h */; }; 2905FA5E18CF08D100240AA3 /* UILayoutParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2905F9FC18CF08D000240AA3 /* UILayoutParameter.cpp */; }; 2905FA5F18CF08D100240AA3 /* UILayoutParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2905F9FC18CF08D000240AA3 /* UILayoutParameter.cpp */; }; 2905FA6018CF08D100240AA3 /* UILayoutParameter.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905F9FD18CF08D000240AA3 /* UILayoutParameter.h */; }; @@ -2262,8 +2258,6 @@ 2905F9F718CF08D000240AA3 /* UIImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIImageView.h; sourceTree = ""; }; 2905F9F818CF08D000240AA3 /* UILayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayout.cpp; sourceTree = ""; }; 2905F9F918CF08D000240AA3 /* UILayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayout.h; sourceTree = ""; }; - 2905F9FA18CF08D000240AA3 /* UILayoutDefine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutDefine.cpp; sourceTree = ""; }; - 2905F9FB18CF08D000240AA3 /* UILayoutDefine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutDefine.h; sourceTree = ""; }; 2905F9FC18CF08D000240AA3 /* UILayoutParameter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutParameter.cpp; sourceTree = ""; }; 2905F9FD18CF08D000240AA3 /* UILayoutParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutParameter.h; sourceTree = ""; }; 2905F9FE18CF08D000240AA3 /* UIListView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIListView.cpp; sourceTree = ""; }; @@ -3993,8 +3987,6 @@ 2905F9F718CF08D000240AA3 /* UIImageView.h */, 2905F9F818CF08D000240AA3 /* UILayout.cpp */, 2905F9F918CF08D000240AA3 /* UILayout.h */, - 2905F9FA18CF08D000240AA3 /* UILayoutDefine.cpp */, - 2905F9FB18CF08D000240AA3 /* UILayoutDefine.h */, 2905F9FC18CF08D000240AA3 /* UILayoutParameter.cpp */, 2905F9FD18CF08D000240AA3 /* UILayoutParameter.h */, 2905F9FE18CF08D000240AA3 /* UIListView.cpp */, @@ -5132,7 +5124,6 @@ 1AD71DEB180E26E600808F54 /* CCMenuItemLoader.h in Headers */, 1AD71DED180E26E600808F54 /* CCMenuLoader.h in Headers */, 1AD71DF1180E26E600808F54 /* CCNode+CCBRelativePositioning.h in Headers */, - 2905FA5C18CF08D100240AA3 /* UILayoutDefine.h in Headers */, 2905FA7218CF08D100240AA3 /* UIScrollInterface.h in Headers */, B2AF2F9B18EBAEAE00C5807C /* Matrix.h in Headers */, 1AD71DF5180E26E600808F54 /* CCNodeLoader.h in Headers */, @@ -5466,7 +5457,6 @@ 50E6D33F18E174130051CA34 /* UIVBox.h in Headers */, 1A570115180BC8EE0088DEC7 /* CCDrawNode.h in Headers */, 06CAAAC5186AD7E50012A414 /* TriggerObj.h in Headers */, - 2905FA5D18CF08D100240AA3 /* UILayoutDefine.h in Headers */, 1A57011E180BC90D0088DEC7 /* CCGrabber.h in Headers */, 1A570122180BC90D0088DEC7 /* CCGrid.h in Headers */, 500DC8C319105D41007B91BF /* CCRenderCommandPool.h in Headers */, @@ -6143,7 +6133,6 @@ 1A57008D180BC5A10088DEC7 /* CCActionTiledGrid.cpp in Sources */, 1A570091180BC5A10088DEC7 /* CCActionTween.cpp in Sources */, B2AF2F9918EBAEAE00C5807C /* Matrix.cpp in Sources */, - 2905FA5A18CF08D100240AA3 /* UILayoutDefine.cpp in Sources */, 500DC94419106300007B91BF /* CCDataVisitor.cpp in Sources */, 1A570098180BC5C10088DEC7 /* CCAtlasNode.cpp in Sources */, 1A57009E180BC5D20088DEC7 /* CCNode.cpp in Sources */, @@ -6653,7 +6642,6 @@ 1A5702EB180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */, 1A5702EF180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */, 1A5702F3180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */, - 2905FA5B18CF08D100240AA3 /* UILayoutDefine.cpp in Sources */, 50E6D31018DAF01A0051CA34 /* CCProtectedNode.cpp in Sources */, 1A5702F7180BCE750088DEC7 /* CCTMXTiledMap.cpp in Sources */, 1A5702FB180BCE750088DEC7 /* CCTMXXMLParser.cpp in Sources */, diff --git a/cocos/ui/UILayoutDefine.cpp b/cocos/ui/UILayoutDefine.cpp deleted file mode 100644 index b1cc88d46b..0000000000 --- a/cocos/ui/UILayoutDefine.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -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. -****************************************************************************/ -#include "UILayoutDefine.h" - -NS_CC_BEGIN - -namespace ui { - - -Margin::Margin(void) : left(0), top(0), right(0), bottom(0) -{ -} - -Margin::Margin(float l, float t, float r, float b) : left(l), top(t), right(r), bottom(b) -{ -} - -Margin::Margin(const Margin& other) : left(other.left), top(other.top), right(other.right), bottom(other.bottom) -{ -} - -Margin& Margin::operator= (const Margin& other) -{ - setMargin(other.left, other.top, other.right, other.bottom); - return *this; -} - -void Margin::setMargin(float l, float t, float r, float b) -{ - left = l; - top = t; - right = r; - bottom = b; -} - -bool Margin::equals(const Margin &target) const -{ - return (left == target.left && top == target.top && right == target.right && bottom == target.bottom); -} - -} - -NS_CC_END diff --git a/cocos/ui/UILayoutDefine.h b/cocos/ui/UILayoutDefine.h deleted file mode 100644 index dc1af74a65..0000000000 --- a/cocos/ui/UILayoutDefine.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -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 __UILAYOUTDEFINE_H__ -#define __UILAYOUTDEFINE_H__ - -#include "cocos2d.h" - -NS_CC_BEGIN - -namespace ui { -/** -* @js NA -* @lua NA -*/ -class Margin -{ -public: - float left; - float top; - float right; - float bottom; - -public: - Margin(); - Margin(float l, float t, float r, float b); - Margin(const Margin& other); - Margin& operator= (const Margin& other); - void setMargin(float l, float t, float r, float b); - bool equals(const Margin& target) const; -}; - -const Margin MarginZero = Margin(); - -typedef enum -{ - LINEAR_GRAVITY_NONE, - LINEAR_GRAVITY_LEFT, - LINEAR_GRAVITY_TOP, - LINEAR_GRAVITY_RIGHT, - LINEAR_GRAVITY_BOTTOM, - LINEAR_GRAVITY_CENTER_VERTICAL, - LINEAR_GRAVITY_CENTER_HORIZONTAL -}LinearGravity; - -typedef enum -{ - RELATIVE_ALIGN_NONE, - RELATIVE_ALIGN_PARENT_TOP_LEFT, - RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL, - RELATIVE_ALIGN_PARENT_TOP_RIGHT, - RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL, - RELATIVE_CENTER_IN_PARENT, - RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL, - RELATIVE_ALIGN_PARENT_LEFT_BOTTOM, - RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL, - RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM, - - RELATIVE_LOCATION_ABOVE_LEFTALIGN, - RELATIVE_LOCATION_ABOVE_CENTER, - RELATIVE_LOCATION_ABOVE_RIGHTALIGN, - RELATIVE_LOCATION_LEFT_OF_TOPALIGN, - RELATIVE_LOCATION_LEFT_OF_CENTER, - RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN, - RELATIVE_LOCATION_RIGHT_OF_TOPALIGN, - RELATIVE_LOCATION_RIGHT_OF_CENTER, - RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN, - RELATIVE_LOCATION_BELOW_LEFTALIGN, - RELATIVE_LOCATION_BELOW_CENTER, - RELATIVE_LOCATION_BELOW_RIGHTALIGN -}RelativeAlign; - -} -NS_CC_END -#endif /* defined(__UILayoutDefine__) */ diff --git a/cocos/ui/UILayoutParameter.cpp b/cocos/ui/UILayoutParameter.cpp index 0957980f74..5fd32c589a 100644 --- a/cocos/ui/UILayoutParameter.cpp +++ b/cocos/ui/UILayoutParameter.cpp @@ -28,7 +28,38 @@ NS_CC_BEGIN namespace ui { + +Margin::Margin(void) : left(0), top(0), right(0), bottom(0) +{ +} +Margin::Margin(float l, float t, float r, float b) : left(l), top(t), right(r), bottom(b) +{ +} + +Margin::Margin(const Margin& other) : left(other.left), top(other.top), right(other.right), bottom(other.bottom) +{ +} + +Margin& Margin::operator= (const Margin& other) +{ + setMargin(other.left, other.top, other.right, other.bottom); + return *this; +} + +void Margin::setMargin(float l, float t, float r, float b) +{ + left = l; + top = t; + right = r; + bottom = b; +} + +bool Margin::equals(const Margin &target) const +{ + return (left == target.left && top == target.top && right == target.right && bottom == target.bottom); +} + LayoutParameter* LayoutParameter::create() { diff --git a/cocos/ui/UILayoutParameter.h b/cocos/ui/UILayoutParameter.h index c087d8bde3..4f135cfd3c 100644 --- a/cocos/ui/UILayoutParameter.h +++ b/cocos/ui/UILayoutParameter.h @@ -25,18 +25,81 @@ #ifndef __LAYOUTPARMETER_H__ #define __LAYOUTPARMETER_H__ -#include "ui/UILayoutDefine.h" +#include +#include "base/CCRef.h" + NS_CC_BEGIN namespace ui { +/** + * @js NA + * @lua NA + */ +class Margin +{ +public: + float left; + float top; + float right; + float bottom; + +public: + Margin(); + Margin(float l, float t, float r, float b); + Margin(const Margin& other); + Margin& operator= (const Margin& other); + void setMargin(float l, float t, float r, float b); + bool equals(const Margin& target) const; +}; + +const Margin MarginZero = Margin(); + typedef enum { LAYOUT_PARAMETER_NONE, LAYOUT_PARAMETER_LINEAR, LAYOUT_PARAMETER_RELATIVE }LayoutParameterType; + +typedef enum +{ + LINEAR_GRAVITY_NONE, + LINEAR_GRAVITY_LEFT, + LINEAR_GRAVITY_TOP, + LINEAR_GRAVITY_RIGHT, + LINEAR_GRAVITY_BOTTOM, + LINEAR_GRAVITY_CENTER_VERTICAL, + LINEAR_GRAVITY_CENTER_HORIZONTAL +}LinearGravity; + +typedef enum +{ + RELATIVE_ALIGN_NONE, + RELATIVE_ALIGN_PARENT_TOP_LEFT, + RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL, + RELATIVE_ALIGN_PARENT_TOP_RIGHT, + RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL, + RELATIVE_CENTER_IN_PARENT, + RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL, + RELATIVE_ALIGN_PARENT_LEFT_BOTTOM, + RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL, + RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM, + + RELATIVE_LOCATION_ABOVE_LEFTALIGN, + RELATIVE_LOCATION_ABOVE_CENTER, + RELATIVE_LOCATION_ABOVE_RIGHTALIGN, + RELATIVE_LOCATION_LEFT_OF_TOPALIGN, + RELATIVE_LOCATION_LEFT_OF_CENTER, + RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN, + RELATIVE_LOCATION_RIGHT_OF_TOPALIGN, + RELATIVE_LOCATION_RIGHT_OF_CENTER, + RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN, + RELATIVE_LOCATION_BELOW_LEFTALIGN, + RELATIVE_LOCATION_BELOW_CENTER, + RELATIVE_LOCATION_BELOW_RIGHTALIGN +}RelativeAlign; /** * @js NA * @lua NA diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index cab96dec0b..b304ecc123 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -26,7 +26,6 @@ THE SOFTWARE. #define __UIWIDGET_H__ #include "ui/CCProtectedNode.h" -#include "ui/UILayoutDefine.h" #include "ui/UILayoutParameter.h" #include "ui/GUIDefine.h" From 0c0f18e7f3966ddecbb2b7e1474708cc428f752f Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 17:38:05 +0800 Subject: [PATCH 045/174] issue #5047, refactor LayoutParameterType --- cocos/ui/UIDeprecated.h | 4 ++++ cocos/ui/UILayout.cpp | 16 ++++++++-------- cocos/ui/UILayoutParameter.cpp | 2 +- cocos/ui/UILayoutParameter.h | 35 +++++++++++++++++++++++----------- cocos/ui/UIListView.cpp | 4 ++-- cocos/ui/UIWidget.cpp | 7 ++++--- cocos/ui/UIWidget.h | 2 +- 7 files changed, 44 insertions(+), 26 deletions(-) diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index 509b472248..d44f36c8ae 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -52,6 +52,9 @@ CC_DEPRECATED_ATTRIBUTE const Layout::BackGroundColorType LAYOUT_COLOR_NONE = La CC_DEPRECATED_ATTRIBUTE const Layout::BackGroundColorType LAYOUT_COLOR_SOLID = Layout::BackGroundColorType::SOLID; CC_DEPRECATED_ATTRIBUTE const Layout::BackGroundColorType LAYOUT_COLOR_GRADIENT = Layout::BackGroundColorType::GRADIENT; +CC_DEPRECATED_ATTRIBUTE const LayoutParameter::Type LAYOUT_PARAMETER_NONE = LayoutParameter::Type::NONE; +CC_DEPRECATED_ATTRIBUTE const LayoutParameter::Type LAYOUT_PARAMETER_LINEAR = LayoutParameter::Type::LINEAR; +CC_DEPRECATED_ATTRIBUTE const LayoutParameter::Type LAYOUT_PARAMETER_RELATIVE = LayoutParameter::Type::RELATIVE; @@ -63,6 +66,7 @@ CC_DEPRECATED_ATTRIBUTE typedef Widget::BrightStyle BrightStyle; CC_DEPRECATED_ATTRIBUTE typedef Layout::ClippingType LayoutClippingType; CC_DEPRECATED_ATTRIBUTE typedef Layout::LayoutType LayoutType; CC_DEPRECATED_ATTRIBUTE typedef Layout::BackGroundColorType LayoutBackGroundColorType; +CC_DEPRECATED_ATTRIBUTE typedef LayoutParameter::Type LayoutParameterType; } diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 3de8a03df6..5440581334 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -130,7 +130,7 @@ void LinearVerticalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Ve Widget* child = dynamic_cast(subWidget); if (child) { - LinearLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_LINEAR)); + LinearLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LayoutParameter::Type::LINEAR)); if (layoutParameter) { @@ -171,7 +171,7 @@ void LinearHorizontalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Widget* child = dynamic_cast(subWidget); if (child) { - LinearLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_LINEAR)); + LinearLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LayoutParameter::Type::LINEAR)); if (layoutParameter) { LinearGravity childGravity = layoutParameter->getGravity(); @@ -212,7 +212,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector(subWidget); if (child) { - RelativeLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_RELATIVE)); + RelativeLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LayoutParameter::Type::RELATIVE)); layoutParameter->_put = false; unlayoutChildCount++; widgetChildren.pushBack(child); @@ -223,7 +223,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector(subWidget); - RelativeLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_RELATIVE)); + RelativeLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LayoutParameter::Type::RELATIVE)); if (layoutParameter) { @@ -245,7 +245,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector(sWidget->getLayoutParameter(LAYOUT_PARAMETER_RELATIVE)); + RelativeLayoutParameter* rlayoutParameter = dynamic_cast(sWidget->getLayoutParameter(LayoutParameter::Type::RELATIVE)); if (rlayoutParameter && strcmp(rlayoutParameter->getRelativeName(), relativeName) == 0) { relativeWidget = sWidget; @@ -1180,7 +1180,7 @@ void Layout::supplyTheLayoutParameterLackToChild(Widget *child) case LayoutType::HORIZONTAL: case LayoutType::VERTICAL: { - LinearLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_LINEAR)); + LinearLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LayoutParameter::Type::LINEAR)); if (!layoutParameter) { child->setLayoutParameter(LinearLayoutParameter::create()); @@ -1189,7 +1189,7 @@ void Layout::supplyTheLayoutParameterLackToChild(Widget *child) } case LayoutType::RELATIVE: { - RelativeLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LAYOUT_PARAMETER_RELATIVE)); + RelativeLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LayoutParameter::Type::RELATIVE)); if (!layoutParameter) { child->setLayoutParameter(RelativeLayoutParameter::create()); @@ -1557,7 +1557,7 @@ Size Layout::getLayoutContentSize()const if (w) { widgetCount++; - Margin m = w->getLayoutParameter(LAYOUT_PARAMETER_LINEAR)->getMargin(); + Margin m = w->getLayoutParameter(LayoutParameter::Type::LINEAR)->getMargin(); layoutSize = layoutSize + w->getSize() + Size(m.right + m.left, m.top + m.bottom) * 0.5; } } diff --git a/cocos/ui/UILayoutParameter.cpp b/cocos/ui/UILayoutParameter.cpp index 5fd32c589a..ca2eb798df 100644 --- a/cocos/ui/UILayoutParameter.cpp +++ b/cocos/ui/UILayoutParameter.cpp @@ -83,7 +83,7 @@ const Margin& LayoutParameter::getMargin() const return _margin; } -LayoutParameterType LayoutParameter::getLayoutType() const +LayoutParameter::Type LayoutParameter::getLayoutType() const { return _layoutParameterType; } diff --git a/cocos/ui/UILayoutParameter.h b/cocos/ui/UILayoutParameter.h index 4f135cfd3c..8b48e2d23d 100644 --- a/cocos/ui/UILayoutParameter.h +++ b/cocos/ui/UILayoutParameter.h @@ -56,12 +56,6 @@ public: const Margin MarginZero = Margin(); -typedef enum -{ - LAYOUT_PARAMETER_NONE, - LAYOUT_PARAMETER_LINEAR, - LAYOUT_PARAMETER_RELATIVE -}LayoutParameterType; typedef enum { @@ -107,10 +101,19 @@ typedef enum class LayoutParameter : public Ref { public: + enum class Type : int + { + NONE = 0, + LINEAR, + RELATIVE + }; /** * Default constructor */ - LayoutParameter() : _margin(Margin()){_layoutParameterType = LAYOUT_PARAMETER_NONE;}; + LayoutParameter() : _margin(Margin()) + { + _layoutParameterType = Type::NONE; + }; /** * Default destructor @@ -148,14 +151,14 @@ public: * * @return LayoutParameterType */ - LayoutParameterType getLayoutType() const; + Type getLayoutType() const; LayoutParameter* clone(); virtual LayoutParameter* createCloneInstance(); virtual void copyProperties(LayoutParameter* model); protected: Margin _margin; - LayoutParameterType _layoutParameterType; + Type _layoutParameterType; }; /** * @js NA @@ -167,7 +170,10 @@ public: /** * Default constructor */ - LinearLayoutParameter() : _linearGravity(LINEAR_GRAVITY_NONE){_layoutParameterType = LAYOUT_PARAMETER_LINEAR;}; + LinearLayoutParameter() : _linearGravity(LINEAR_GRAVITY_NONE) + { + _layoutParameterType = Type::LINEAR; + }; /** * Default destructor @@ -213,7 +219,14 @@ public: /** * Default constructor */ - RelativeLayoutParameter() : _relativeAlign(RELATIVE_ALIGN_NONE),_relativeWidgetName(""),_relativeLayoutName(""),_put(false){_layoutParameterType = LAYOUT_PARAMETER_RELATIVE;}; + RelativeLayoutParameter() + : _relativeAlign(RELATIVE_ALIGN_NONE), + _relativeWidgetName(""), + _relativeLayoutName(""), + _put(false) + { + _layoutParameterType = Type::RELATIVE; + }; /** * Default destructor diff --git a/cocos/ui/UIListView.cpp b/cocos/ui/UIListView.cpp index 1edbd4270b..02a48d23bc 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -129,7 +129,7 @@ void ListView::remedyLayoutParameter(Widget *item) switch (_direction) { case SCROLLVIEW_DIR_VERTICAL: { - LinearLayoutParameter* llp = (LinearLayoutParameter*)(item->getLayoutParameter(LAYOUT_PARAMETER_LINEAR)); + LinearLayoutParameter* llp = (LinearLayoutParameter*)(item->getLayoutParameter(LayoutParameter::Type::LINEAR)); if (!llp) { LinearLayoutParameter* defaultLp = LinearLayoutParameter::create(); @@ -184,7 +184,7 @@ void ListView::remedyLayoutParameter(Widget *item) } case SCROLLVIEW_DIR_HORIZONTAL: { - LinearLayoutParameter* llp = (LinearLayoutParameter*)(item->getLayoutParameter(LAYOUT_PARAMETER_LINEAR)); + LinearLayoutParameter* llp = (LinearLayoutParameter*)(item->getLayoutParameter(LayoutParameter::Type::LINEAR)); if (!llp) { LinearLayoutParameter* defaultLp = LinearLayoutParameter::create(); diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index 61362399c3..bd3d4c7e27 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -845,12 +845,12 @@ void Widget::setLayoutParameter(LayoutParameter *parameter) { return; } - _layoutParameterDictionary.insert(parameter->getLayoutType(), parameter); + _layoutParameterDictionary.insert((int)parameter->getLayoutType(), parameter); } -LayoutParameter* Widget::getLayoutParameter(LayoutParameterType type) +LayoutParameter* Widget::getLayoutParameter(LayoutParameter::Type type) { - return dynamic_cast(_layoutParameterDictionary.at(type)); + return dynamic_cast(_layoutParameterDictionary.at((int)type)); } std::string Widget::getDescription() const @@ -920,6 +920,7 @@ void Widget::copyProperties(Widget *widget) setFlippedY(widget->isFlippedY()); setColor(widget->getColor()); setOpacity(widget->getOpacity()); + //FIXME:copy focus properties, also make sure all the subclass the copy behavior is correct Map& layoutParameterDic = widget->_layoutParameterDictionary; for (auto iter = layoutParameterDic.begin(); iter != layoutParameterDic.end(); ++iter) { diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index b304ecc123..7e2a2ee058 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -490,7 +490,7 @@ public: * * @return LayoutParameter */ - LayoutParameter* getLayoutParameter(LayoutParameterType type); + LayoutParameter* getLayoutParameter(LayoutParameter::Type type); /** * Ignore the widget size From 264769f8141165e28e5e23aa953218da89d1670d Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 17:54:25 +0800 Subject: [PATCH 046/174] issue #5057, refactor LinearGravity --- .../cocostudio/CCSGUIReader.cpp | 2 +- .../cocostudio/WidgetReader/WidgetReader.cpp | 2 +- cocos/ui/UIDeprecated.h | 16 +++++++++++- cocos/ui/UILayout.cpp | 20 +++++++------- cocos/ui/UILayoutParameter.cpp | 2 +- cocos/ui/UILayoutParameter.h | 26 +++++++++++-------- cocos/ui/UIListView.cpp | 24 ++++++++--------- .../UILayoutTest/UILayoutTest.cpp | 12 ++++----- 8 files changed, 61 insertions(+), 43 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 39ce7574eb..d0dcc72460 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -1189,7 +1189,7 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(Widget*widg { parameter = LinearLayoutParameter::create(); int gravity = DICTOOL->getIntValue_json(layoutParameterDic, "gravity"); - ((LinearLayoutParameter*)parameter)->setGravity((LinearGravity)gravity); + ((LinearLayoutParameter*)parameter)->setGravity((LinearLayoutParameter::LinearGravity)gravity); break; } case 2: diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index 349440aa19..11afa32b14 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -118,7 +118,7 @@ namespace cocostudio { parameter = LinearLayoutParameter::create(); int gravity = DICTOOL->getIntValue_json(layoutParameterDic, "gravity"); - ((LinearLayoutParameter*)parameter)->setGravity((LinearGravity)gravity); + ((LinearLayoutParameter*)parameter)->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)gravity); break; } case 2: diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index d44f36c8ae..6f92d94965 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -55,7 +55,20 @@ CC_DEPRECATED_ATTRIBUTE const Layout::BackGroundColorType LAYOUT_COLOR_GRADIENT CC_DEPRECATED_ATTRIBUTE const LayoutParameter::Type LAYOUT_PARAMETER_NONE = LayoutParameter::Type::NONE; CC_DEPRECATED_ATTRIBUTE const LayoutParameter::Type LAYOUT_PARAMETER_LINEAR = LayoutParameter::Type::LINEAR; CC_DEPRECATED_ATTRIBUTE const LayoutParameter::Type LAYOUT_PARAMETER_RELATIVE = LayoutParameter::Type::RELATIVE; - +CC_DEPRECATED_ATTRIBUTE const LinearLayoutParameter::LinearGravity LINEAR_GRAVITY_NONE + = LinearLayoutParameter::LinearGravity::NONE; +CC_DEPRECATED_ATTRIBUTE const LinearLayoutParameter::LinearGravity LINEAR_GRAVITY_LEFT + = LinearLayoutParameter::LinearGravity::LEFT; +CC_DEPRECATED_ATTRIBUTE const LinearLayoutParameter::LinearGravity LINEAR_GRAVITY_TOP + = LinearLayoutParameter::LinearGravity::TOP; +CC_DEPRECATED_ATTRIBUTE const LinearLayoutParameter::LinearGravity LINEAR_GRAVITY_RIGHT + = LinearLayoutParameter::LinearGravity::RIGHT; +CC_DEPRECATED_ATTRIBUTE const LinearLayoutParameter::LinearGravity LINEAR_GRAVITY_BOTTOM + = LinearLayoutParameter::LinearGravity::BOTTOM; +CC_DEPRECATED_ATTRIBUTE const LinearLayoutParameter::LinearGravity LINEAR_GRAVITY_CENTER_VERTICAL + = LinearLayoutParameter::LinearGravity::CENTER_VERTICAL; +CC_DEPRECATED_ATTRIBUTE const LinearLayoutParameter::LinearGravity LINEAR_GRAVITY_CENTER_HORIZONTAL + = LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL; CC_DEPRECATED_ATTRIBUTE typedef Widget::TextureResType TextureResType; @@ -67,6 +80,7 @@ CC_DEPRECATED_ATTRIBUTE typedef Layout::ClippingType LayoutClippingType; CC_DEPRECATED_ATTRIBUTE typedef Layout::LayoutType LayoutType; CC_DEPRECATED_ATTRIBUTE typedef Layout::BackGroundColorType LayoutBackGroundColorType; CC_DEPRECATED_ATTRIBUTE typedef LayoutParameter::Type LayoutParameterType; +CC_DEPRECATED_ATTRIBUTE typedef LinearLayoutParameter::LinearGravity LinearGravity; } diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 5440581334..7bfedee338 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -134,20 +134,20 @@ void LinearVerticalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Ve if (layoutParameter) { - LinearGravity childGravity = layoutParameter->getGravity(); + LinearLayoutParameter::LinearGravity childGravity = layoutParameter->getGravity(); Vector2 ap = child->getAnchorPoint(); Size cs = child->getSize(); float finalPosX = ap.x * cs.width; float finalPosY = topBoundary - ((1.0f-ap.y) * cs.height); switch (childGravity) { - case LINEAR_GRAVITY_NONE: - case LINEAR_GRAVITY_LEFT: + case LinearLayoutParameter::LinearGravity::NONE: + case LinearLayoutParameter::LinearGravity::LEFT: break; - case LINEAR_GRAVITY_RIGHT: + case LinearLayoutParameter::LinearGravity::RIGHT: finalPosX = layoutSize.width - ((1.0f - ap.x) * cs.width); break; - case LINEAR_GRAVITY_CENTER_HORIZONTAL: + case LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL: finalPosX = layoutSize.width / 2.0f - cs.width * (0.5f-ap.x); break; default: @@ -174,20 +174,20 @@ void LinearHorizontalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, LinearLayoutParameter* layoutParameter = dynamic_cast(child->getLayoutParameter(LayoutParameter::Type::LINEAR)); if (layoutParameter) { - LinearGravity childGravity = layoutParameter->getGravity(); + LinearLayoutParameter::LinearGravity childGravity = layoutParameter->getGravity(); Vector2 ap = child->getAnchorPoint(); Size cs = child->getSize(); float finalPosX = leftBoundary + (ap.x * cs.width); float finalPosY = layoutSize.height - (1.0f - ap.y) * cs.height; switch (childGravity) { - case LINEAR_GRAVITY_NONE: - case LINEAR_GRAVITY_TOP: + case LinearLayoutParameter::LinearGravity::NONE: + case LinearLayoutParameter::LinearGravity::TOP: break; - case LINEAR_GRAVITY_BOTTOM: + case LinearLayoutParameter::LinearGravity::BOTTOM: finalPosY = ap.y * cs.height; break; - case LINEAR_GRAVITY_CENTER_VERTICAL: + case LinearLayoutParameter::LinearGravity::CENTER_VERTICAL: finalPosY = layoutSize.height / 2.0f - cs.height * (0.5f - ap.y); break; default: diff --git a/cocos/ui/UILayoutParameter.cpp b/cocos/ui/UILayoutParameter.cpp index ca2eb798df..a5941c257f 100644 --- a/cocos/ui/UILayoutParameter.cpp +++ b/cocos/ui/UILayoutParameter.cpp @@ -122,7 +122,7 @@ void LinearLayoutParameter::setGravity(LinearGravity gravity) _linearGravity = gravity; } -LinearGravity LinearLayoutParameter::getGravity() const +LinearLayoutParameter::LinearGravity LinearLayoutParameter::getGravity() const { return _linearGravity; } diff --git a/cocos/ui/UILayoutParameter.h b/cocos/ui/UILayoutParameter.h index 8b48e2d23d..6ff180c5c9 100644 --- a/cocos/ui/UILayoutParameter.h +++ b/cocos/ui/UILayoutParameter.h @@ -57,16 +57,7 @@ public: const Margin MarginZero = Margin(); -typedef enum -{ - LINEAR_GRAVITY_NONE, - LINEAR_GRAVITY_LEFT, - LINEAR_GRAVITY_TOP, - LINEAR_GRAVITY_RIGHT, - LINEAR_GRAVITY_BOTTOM, - LINEAR_GRAVITY_CENTER_VERTICAL, - LINEAR_GRAVITY_CENTER_HORIZONTAL -}LinearGravity; + typedef enum { @@ -160,6 +151,8 @@ protected: Margin _margin; Type _layoutParameterType; }; + + /** * @js NA * @lua NA @@ -167,10 +160,21 @@ protected: class LinearLayoutParameter : public LayoutParameter { public: + enum class LinearGravity + { + NONE, + LEFT, + TOP, + RIGHT, + BOTTOM, + CENTER_VERTICAL, + CENTER_HORIZONTAL + }; /** * Default constructor */ - LinearLayoutParameter() : _linearGravity(LINEAR_GRAVITY_NONE) + LinearLayoutParameter() + : _linearGravity(LinearGravity::NONE) { _layoutParameterType = Type::LINEAR; }; diff --git a/cocos/ui/UIListView.cpp b/cocos/ui/UIListView.cpp index 02a48d23bc..edcaa30e28 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -135,13 +135,13 @@ void ListView::remedyLayoutParameter(Widget *item) LinearLayoutParameter* defaultLp = LinearLayoutParameter::create(); switch (_gravity) { case LISTVIEW_GRAVITY_LEFT: - defaultLp->setGravity(LINEAR_GRAVITY_LEFT); + defaultLp->setGravity(LinearLayoutParameter::LinearGravity::LEFT); break; case LISTVIEW_GRAVITY_RIGHT: - defaultLp->setGravity(LINEAR_GRAVITY_RIGHT); + defaultLp->setGravity(LinearLayoutParameter::LinearGravity::RIGHT); break; case LISTVIEW_GRAVITY_CENTER_HORIZONTAL: - defaultLp->setGravity(LINEAR_GRAVITY_CENTER_HORIZONTAL); + defaultLp->setGravity(LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL); break; default: break; @@ -168,13 +168,13 @@ void ListView::remedyLayoutParameter(Widget *item) } switch (_gravity) { case LISTVIEW_GRAVITY_LEFT: - llp->setGravity(LINEAR_GRAVITY_LEFT); + llp->setGravity(LinearLayoutParameter::LinearGravity::LEFT); break; case LISTVIEW_GRAVITY_RIGHT: - llp->setGravity(LINEAR_GRAVITY_RIGHT); + llp->setGravity(LinearLayoutParameter::LinearGravity::RIGHT); break; case LISTVIEW_GRAVITY_CENTER_HORIZONTAL: - llp->setGravity(LINEAR_GRAVITY_CENTER_HORIZONTAL); + llp->setGravity(LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL); break; default: break; @@ -190,13 +190,13 @@ void ListView::remedyLayoutParameter(Widget *item) LinearLayoutParameter* defaultLp = LinearLayoutParameter::create(); switch (_gravity) { case LISTVIEW_GRAVITY_TOP: - defaultLp->setGravity(LINEAR_GRAVITY_TOP); + defaultLp->setGravity(LinearLayoutParameter::LinearGravity::TOP); break; case LISTVIEW_GRAVITY_BOTTOM: - defaultLp->setGravity(LINEAR_GRAVITY_BOTTOM); + defaultLp->setGravity(LinearLayoutParameter::LinearGravity::BOTTOM); break; case LISTVIEW_GRAVITY_CENTER_VERTICAL: - defaultLp->setGravity(LINEAR_GRAVITY_CENTER_VERTICAL); + defaultLp->setGravity(LinearLayoutParameter::LinearGravity::CENTER_VERTICAL); break; default: break; @@ -223,13 +223,13 @@ void ListView::remedyLayoutParameter(Widget *item) } switch (_gravity) { case LISTVIEW_GRAVITY_TOP: - llp->setGravity(LINEAR_GRAVITY_TOP); + llp->setGravity(LinearLayoutParameter::LinearGravity::TOP); break; case LISTVIEW_GRAVITY_BOTTOM: - llp->setGravity(LINEAR_GRAVITY_BOTTOM); + llp->setGravity(LinearLayoutParameter::LinearGravity::BOTTOM); break; case LISTVIEW_GRAVITY_CENTER_VERTICAL: - llp->setGravity(LINEAR_GRAVITY_CENTER_VERTICAL); + llp->setGravity(LinearLayoutParameter::LinearGravity::CENTER_VERTICAL); break; default: break; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp index 34b59eec14..4b34b5610e 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp @@ -360,7 +360,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init() LinearLayoutParameter* lp1 = LinearLayoutParameter::create(); button->setLayoutParameter(lp1); - lp1->setGravity(LINEAR_GRAVITY_CENTER_HORIZONTAL); + lp1->setGravity(LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL); lp1->setMargin(Margin(0.0f, 5.0f, 0.0f, 10.0f)); @@ -370,7 +370,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init() LinearLayoutParameter* lp2 = LinearLayoutParameter::create(); titleButton->setLayoutParameter(lp2); - lp2->setGravity(LINEAR_GRAVITY_CENTER_HORIZONTAL); + lp2->setGravity(LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL); lp2->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f)); @@ -381,7 +381,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init() LinearLayoutParameter* lp3 = LinearLayoutParameter::create(); button_scale9->setLayoutParameter(lp3); - lp3->setGravity(LINEAR_GRAVITY_CENTER_HORIZONTAL); + lp3->setGravity(LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL); lp3->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f)); @@ -434,7 +434,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init() LinearLayoutParameter* lp1 = LinearLayoutParameter::create(); button->setLayoutParameter(lp1); - lp1->setGravity(LINEAR_GRAVITY_CENTER_VERTICAL); + lp1->setGravity(LinearLayoutParameter::LinearGravity::CENTER_VERTICAL); lp1->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f)); @@ -444,7 +444,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init() LinearLayoutParameter* lp2 = LinearLayoutParameter::create(); titleButton->setLayoutParameter(lp2); - lp2->setGravity(LINEAR_GRAVITY_CENTER_VERTICAL); + lp2->setGravity(LinearLayoutParameter::LinearGravity::CENTER_VERTICAL); lp2->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f)); @@ -455,7 +455,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init() LinearLayoutParameter* lp3 = LinearLayoutParameter::create(); button_scale9->setLayoutParameter(lp3); - lp3->setGravity(LINEAR_GRAVITY_CENTER_VERTICAL); + lp3->setGravity(LinearLayoutParameter::LinearGravity::CENTER_VERTICAL); lp3->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f)); From e1fe26543d6153b477e10e1161d9cb4729324722 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 9 May 2014 18:37:22 +0800 Subject: [PATCH 047/174] issue #5057, refactor & remove deprecated warnings --- .../cocostudio/CCSGUIReader.cpp | 2 +- .../cocostudio/WidgetReader/WidgetReader.cpp | 2 +- cocos/ui/UICheckBox.h | 13 +++ cocos/ui/UIDeprecated.h | 46 ++++++++++ cocos/ui/UILayout.cpp | 90 +++++++++---------- cocos/ui/UILayoutParameter.cpp | 2 +- cocos/ui/UILayoutParameter.h | 62 ++++++------- cocos/ui/UIWidget.h | 12 +++ .../UILayoutTest/UILayoutTest.cpp | 28 +++--- 9 files changed, 165 insertions(+), 92 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index d0dcc72460..769dde259d 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -1201,7 +1201,7 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(Widget*widg const char* relativeToName = DICTOOL->getStringValue_json(layoutParameterDic, "relativeToName"); rParameter->setRelativeToWidgetName(relativeToName); int align = DICTOOL->getIntValue_json(layoutParameterDic, "align"); - rParameter->setAlign((RelativeAlign)align); + rParameter->setAlign((RelativeLayoutParameter::RelativeAlign)align); break; } default: diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index 11afa32b14..7f89d2e8e5 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -130,7 +130,7 @@ namespace cocostudio const char* relativeToName = DICTOOL->getStringValue_json(layoutParameterDic, "relativeToName"); rParameter->setRelativeToWidgetName(relativeToName); int align = DICTOOL->getIntValue_json(layoutParameterDic, "align"); - rParameter->setAlign((RelativeAlign)align); + rParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)align); break; } default: diff --git a/cocos/ui/UICheckBox.h b/cocos/ui/UICheckBox.h index 74d82eebd5..f05d282ec9 100644 --- a/cocos/ui/UICheckBox.h +++ b/cocos/ui/UICheckBox.h @@ -229,7 +229,20 @@ protected: bool _isSelected; //if you use the old event callback, it will retain the _checkBoxEventListener Ref* _checkBoxEventListener; + +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif _MSC_VER >= 1400 //vs 2005 or higher +#pragma warning (push) +#pragma warning (disable: 4996) +#endif SEL_SelectedStateEvent _checkBoxEventSelector; +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#pragma GCC diagnostic warning "-Wdeprecated-declarations" +#elif _MSC_VER >= 1400 //vs 2005 or higher +#pragma warning (pop) +#endif + ccCheckBoxCallback _checkBoxEventCallback; TextureResType _backGroundTexType; diff --git a/cocos/ui/UIDeprecated.h b/cocos/ui/UIDeprecated.h index 6f92d94965..5a11695afc 100644 --- a/cocos/ui/UIDeprecated.h +++ b/cocos/ui/UIDeprecated.h @@ -69,6 +69,51 @@ CC_DEPRECATED_ATTRIBUTE const LinearLayoutParameter::LinearGravity LINEAR_GRAVIT = LinearLayoutParameter::LinearGravity::CENTER_VERTICAL; CC_DEPRECATED_ATTRIBUTE const LinearLayoutParameter::LinearGravity LINEAR_GRAVITY_CENTER_HORIZONTAL = LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL; + +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_ALIGN_NONE + = RelativeLayoutParameter::RelativeAlign::NONE; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_ALIGN_PARENT_TOP_LEFT + = RelativeLayoutParameter::RelativeAlign::PARENT_TOP_LEFT; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL + = RelativeLayoutParameter::RelativeAlign::PARENT_TOP_CENTER_HORIZONTAL; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_ALIGN_PARENT_TOP_RIGHT + = RelativeLayoutParameter::RelativeAlign::PARENT_TOP_RIGHT; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL + = RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_CENTER_VERTICAL; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_CENTER_IN_PARENT + = RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL + = RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_CENTER_VERTICAL; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_ALIGN_PARENT_LEFT_BOTTOM + = RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_BOTTOM; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL + = RelativeLayoutParameter::RelativeAlign::PARENT_BOTTOM_CENTER_HORIZONTAL; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM + = RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_BOTTOM; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_LOCATION_ABOVE_LEFTALIGN + = RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_LEFTALIGN; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_LOCATION_ABOVE_CENTER + = RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_CENTER; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_LOCATION_ABOVE_RIGHTALIGN + = RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_RIGHTALIGN; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_LOCATION_LEFT_OF_TOPALIGN + = RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_TOPALIGN; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_LOCATION_LEFT_OF_CENTER + = RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_CENTER; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN + = RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_BOTTOMALIGN; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_LOCATION_RIGHT_OF_TOPALIGN + = RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_TOPALIGN; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_LOCATION_RIGHT_OF_CENTER + = RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_CENTER; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN + = RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_BOTTOMALIGN; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_LOCATION_BELOW_LEFTALIGN + = RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_LEFTALIGN; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_LOCATION_BELOW_CENTER + = RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_CENTER; +CC_DEPRECATED_ATTRIBUTE const RelativeLayoutParameter::RelativeAlign RELATIVE_LOCATION_BELOW_RIGHTALIGN + = RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_RIGHTALIGN; CC_DEPRECATED_ATTRIBUTE typedef Widget::TextureResType TextureResType; @@ -81,6 +126,7 @@ CC_DEPRECATED_ATTRIBUTE typedef Layout::LayoutType LayoutType; CC_DEPRECATED_ATTRIBUTE typedef Layout::BackGroundColorType LayoutBackGroundColorType; CC_DEPRECATED_ATTRIBUTE typedef LayoutParameter::Type LayoutParameterType; CC_DEPRECATED_ATTRIBUTE typedef LinearLayoutParameter::LinearGravity LinearGravity; +CC_DEPRECATED_ATTRIBUTE typedef RelativeLayoutParameter::RelativeAlign RelativeAlign; } diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 7bfedee338..e89a846697 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -233,7 +233,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, VectorgetAnchorPoint(); Size cs = child->getSize(); - RelativeAlign align = layoutParameter->getAlign(); + RelativeLayoutParameter::RelativeAlign align = layoutParameter->getAlign(); const char* relativeName = layoutParameter->getRelativeToWidgetName(); Widget* relativeWidget = nullptr; RelativeLayoutParameter* relativeWidgetLP = nullptr; @@ -257,45 +257,45 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector_put) @@ -308,7 +308,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector_put) @@ -322,7 +322,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, VectorgetLeftInParent() + rbs.width * 0.5f + ap.x * cs.width - cs.width * 0.5f; } break; - case RELATIVE_LOCATION_ABOVE_RIGHTALIGN: + case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_RIGHTALIGN: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) @@ -335,7 +335,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector_put) @@ -348,7 +348,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector_put) @@ -362,7 +362,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, VectorgetBottomInParent() + rbs.height * 0.5f + ap.y * cs.height - cs.height * 0.5f; } break; - case RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN: + case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_BOTTOMALIGN: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) @@ -375,7 +375,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector_put) @@ -388,7 +388,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector_put) @@ -402,7 +402,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, VectorgetBottomInParent() + rbs.height * 0.5f + ap.y * cs.height - cs.height * 0.5f; } break; - case RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN: + case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_BOTTOMALIGN: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) @@ -415,7 +415,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector_put) @@ -428,7 +428,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector_put) @@ -442,7 +442,7 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, VectorgetLeftInParent() + rbs.width * 0.5f + ap.x * cs.width - cs.width * 0.5f; } break; - case RELATIVE_LOCATION_BELOW_RIGHTALIGN: + case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_RIGHTALIGN: if (relativeWidget) { if (relativeWidgetLP && !relativeWidgetLP->_put) @@ -467,83 +467,83 @@ void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif _MSC_VER >= 1400 //vs 2005 or higher +#pragma warning (push) +#pragma warning (disable: 4996) +#endif SEL_TouchEvent _touchEventSelector; +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#pragma GCC diagnostic warning "-Wdeprecated-declarations" +#elif _MSC_VER >= 1400 //vs 2005 or higher +#pragma warning (pop) +#endif ccWidgetTouchCallback _touchEventCallback; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp index 4b34b5610e..9d0d26090e 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp @@ -510,7 +510,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() layout->addChild(button_TopLeft); RelativeLayoutParameter* rp_TopLeft = RelativeLayoutParameter::create(); - rp_TopLeft->setAlign(RELATIVE_ALIGN_PARENT_TOP_LEFT); + rp_TopLeft->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_TOP_LEFT); button_TopLeft->setLayoutParameter(rp_TopLeft); @@ -520,7 +520,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() layout->addChild(button_TopCenter); RelativeLayoutParameter* rp_TopCenter = RelativeLayoutParameter::create(); - rp_TopCenter->setAlign(RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL); + rp_TopCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_TOP_CENTER_HORIZONTAL); button_TopCenter->setLayoutParameter(rp_TopCenter); @@ -530,7 +530,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() layout->addChild(button_TopRight); RelativeLayoutParameter* rp_TopRight = RelativeLayoutParameter::create(); - rp_TopRight->setAlign(RELATIVE_ALIGN_PARENT_TOP_RIGHT); + rp_TopRight->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_TOP_RIGHT); button_TopRight->setLayoutParameter(rp_TopRight); @@ -540,7 +540,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() layout->addChild(button_LeftCenter); RelativeLayoutParameter* rp_LeftCenter = RelativeLayoutParameter::create(); - rp_LeftCenter->setAlign(RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL); + rp_LeftCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_CENTER_VERTICAL); button_LeftCenter->setLayoutParameter(rp_LeftCenter); @@ -550,7 +550,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() layout->addChild(buttonCenter); RelativeLayoutParameter* rpCenter = RelativeLayoutParameter::create(); - rpCenter->setAlign(RELATIVE_CENTER_IN_PARENT); + rpCenter->setAlign(RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT); buttonCenter->setLayoutParameter(rpCenter); @@ -560,7 +560,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() layout->addChild(button_RightCenter); RelativeLayoutParameter* rp_RightCenter = RelativeLayoutParameter::create(); - rp_RightCenter->setAlign(RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL); + rp_RightCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_CENTER_VERTICAL); button_RightCenter->setLayoutParameter(rp_RightCenter); @@ -570,7 +570,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() layout->addChild(button_LeftBottom); RelativeLayoutParameter* rp_LeftBottom = RelativeLayoutParameter::create(); - rp_LeftBottom->setAlign(RELATIVE_ALIGN_PARENT_LEFT_BOTTOM); + rp_LeftBottom->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_BOTTOM); button_LeftBottom->setLayoutParameter(rp_LeftBottom); @@ -580,7 +580,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() layout->addChild(button_BottomCenter); RelativeLayoutParameter* rp_BottomCenter = RelativeLayoutParameter::create(); - rp_BottomCenter->setAlign(RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL); + rp_BottomCenter->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_BOTTOM_CENTER_HORIZONTAL); button_BottomCenter->setLayoutParameter(rp_BottomCenter); @@ -590,7 +590,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() layout->addChild(button_RightBottom); RelativeLayoutParameter* rp_RightBottom = RelativeLayoutParameter::create(); - rp_RightBottom->setAlign(RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM); + rp_RightBottom->setAlign(RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_BOTTOM); button_RightBottom->setLayoutParameter(rp_RightBottom); @@ -643,7 +643,7 @@ bool UILayoutTest_Layout_Relative_Location::init() RelativeLayoutParameter* rp_Center = RelativeLayoutParameter::create(); rp_Center->setRelativeName("rp_Center"); - rp_Center->setAlign(RELATIVE_CENTER_IN_PARENT); + rp_Center->setAlign(RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT); imageView_Center->setLayoutParameter(rp_Center); @@ -653,7 +653,7 @@ bool UILayoutTest_Layout_Relative_Location::init() RelativeLayoutParameter* rp_AboveCenter = RelativeLayoutParameter::create(); rp_AboveCenter->setRelativeToWidgetName("rp_Center"); - rp_AboveCenter->setAlign(RELATIVE_LOCATION_ABOVE_CENTER); + rp_AboveCenter->setAlign(RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_CENTER); imageView_AboveCenter->setLayoutParameter(rp_AboveCenter); @@ -663,7 +663,7 @@ bool UILayoutTest_Layout_Relative_Location::init() RelativeLayoutParameter* rp_BelowCenter = RelativeLayoutParameter::create(); rp_BelowCenter->setRelativeToWidgetName("rp_Center"); - rp_BelowCenter->setAlign(RELATIVE_LOCATION_BELOW_CENTER); + rp_BelowCenter->setAlign(RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_CENTER); imageView_BelowCenter->setLayoutParameter(rp_BelowCenter); @@ -673,7 +673,7 @@ bool UILayoutTest_Layout_Relative_Location::init() RelativeLayoutParameter* rp_LeftCenter = RelativeLayoutParameter::create(); rp_LeftCenter->setRelativeToWidgetName("rp_Center"); - rp_LeftCenter->setAlign(RELATIVE_LOCATION_LEFT_OF_CENTER); + rp_LeftCenter->setAlign(RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_CENTER); imageView_LeftCenter->setLayoutParameter(rp_LeftCenter); @@ -684,7 +684,7 @@ bool UILayoutTest_Layout_Relative_Location::init() RelativeLayoutParameter* rp_RightCenter = RelativeLayoutParameter::create(); rp_RightCenter->setRelativeToWidgetName("rp_Center"); - rp_RightCenter->setAlign(RELATIVE_LOCATION_RIGHT_OF_CENTER); + rp_RightCenter->setAlign(RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_CENTER); imageView_RightCenter->setLayoutParameter(rp_RightCenter); From a986455e63cfb3e9b903149f6da43b19fe3a2e41 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 9 May 2014 10:23:24 -0700 Subject: [PATCH 048/174] store useCache in GLProgramState --- cocos/renderer/CCGLProgramState.cpp | 10 ++++++++-- cocos/renderer/CCGLProgramState.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cocos/renderer/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp index ef212b98bf..5e2b349f08 100644 --- a/cocos/renderer/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -210,12 +210,14 @@ GLProgramState* GLProgramState::create(GLProgram *glprogram, bool useCache) if (useCache) { ret = GLProgramStateCache::getInstance()->getProgramState(glprogram); + ret->_useCache = useCache; } else { ret = new (std::nothrow) GLProgramState; if(!ret || !ret->init(glprogram)) CC_SAFE_RELEASE(ret); + ret->_useCache = useCache; } return ret; @@ -223,13 +225,17 @@ GLProgramState* GLProgramState::create(GLProgram *glprogram, bool useCache) GLProgramState::GLProgramState() : _vertexAttribsFlags(0) +, _useCache(false) +, _glprogram(nullptr) { } GLProgramState::~GLProgramState() { - GLProgramStateCache::getInstance()->removeProgramState(_glprogram); - _glprogram->release(); + if (_useCache) + GLProgramStateCache::getInstance()->removeProgramState(_glprogram); + + CC_SAFE_RELEASE(_glprogram); } bool GLProgramState::init(GLProgram* glprogram) diff --git a/cocos/renderer/CCGLProgramState.h b/cocos/renderer/CCGLProgramState.h index ee37f56635..97f4dc5a1c 100644 --- a/cocos/renderer/CCGLProgramState.h +++ b/cocos/renderer/CCGLProgramState.h @@ -170,6 +170,7 @@ protected: uint32_t _vertexAttribsFlags; GLProgram *_glprogram; + bool _useCache; }; NS_CC_END From 00834b1d6e5122c3f34d57ac5f0870fb9052d686 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 11:28:06 -0700 Subject: [PATCH 049/174] adds missing files for Windows --- cocos/2d/cocos2d.vcxproj.filters | 174 ++++++++++++++++++------------- cocos/renderer/ccGLStateCache.h | 2 + 2 files changed, 101 insertions(+), 75 deletions(-) diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters index f60c30a84f..7a9c3e1061 100644 --- a/cocos/2d/cocos2d.vcxproj.filters +++ b/cocos/2d/cocos2d.vcxproj.filters @@ -61,9 +61,6 @@ {5b082c5c-d396-43ca-b3b1-997d0f6247d0} - - {163895ae-8a8e-46bf-bdf2-98bb2c1347fc} - {1179d205-d065-49f0-8457-bc4c3f1d0cb3} @@ -103,6 +100,9 @@ {02a21a86-8f65-441b-ae13-11dec1c45ee5} + + {406577df-e0cd-4148-8e00-9bc159e0a799} + @@ -291,18 +291,6 @@ platform - - shaders - - - shaders - - - shaders - - - shaders - sprite_nodes @@ -576,6 +564,21 @@ base + + renderer + + + renderer + + + renderer + + + renderer + + + renderer + @@ -785,66 +788,6 @@ platform - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - - - shaders - sprite_nodes @@ -1166,6 +1109,87 @@ base + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer + + + renderer + + + renderer + + + renderer + + + renderer + diff --git a/cocos/renderer/ccGLStateCache.h b/cocos/renderer/ccGLStateCache.h index dcc3cb0ec9..77cd03127e 100644 --- a/cocos/renderer/ccGLStateCache.h +++ b/cocos/renderer/ccGLStateCache.h @@ -28,6 +28,8 @@ THE SOFTWARE. #ifndef __CCGLSTATE_H__ #define __CCGLSTATE_H__ +#include + #include "CCGL.h" #include "base/CCPlatformMacros.h" From 8565e899f97cec72e83384826529163bf1081c57 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 11:38:43 -0700 Subject: [PATCH 050/174] adds missing files to VisualStudio --- cocos/2d/cocos2d.vcxproj | 34 ++++++++++++++++++++++ cocos/2d/cocos2d.vcxproj.filters | 50 +++++++++++++++++++++++++------- 2 files changed, 74 insertions(+), 10 deletions(-) diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj index 511c5d4659..5ce0071f9e 100644 --- a/cocos/2d/cocos2d.vcxproj +++ b/cocos/2d/cocos2d.vcxproj @@ -234,10 +234,16 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + + + + + + @@ -410,11 +416,39 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters index 7a9c3e1061..1c5ff71669 100644 --- a/cocos/2d/cocos2d.vcxproj.filters +++ b/cocos/2d/cocos2d.vcxproj.filters @@ -564,10 +564,11 @@ base - - renderer - - + + + + + renderer @@ -579,6 +580,12 @@ renderer + + renderer + + + renderer + @@ -1109,6 +1116,29 @@ base + + + + + + + + + + + + + + + + + + + + + + renderer + renderer\Shaders @@ -1175,12 +1205,6 @@ renderer\Shaders - - renderer - - - renderer - renderer @@ -1190,6 +1214,12 @@ renderer + + renderer + + + renderer + From 6727c6d19cacb5fb819c1be39d2afcf84b3d3996 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 11:45:12 -0700 Subject: [PATCH 051/174] Adds missing files to xcode --- build/cocos2d_libs.xcodeproj/project.pbxproj | 400 ++++++++++--------- 1 file changed, 212 insertions(+), 188 deletions(-) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 9c1daa1267..33a32c6c8e 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -278,44 +278,6 @@ 1A570235180BCC4D0088DEC7 /* CCScriptSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570232180BCC4D0088DEC7 /* CCScriptSupport.cpp */; }; 1A570236180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570233180BCC4D0088DEC7 /* CCScriptSupport.h */; }; 1A570237180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570233180BCC4D0088DEC7 /* CCScriptSupport.h */; }; - 1A57024D180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570239180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h */; }; - 1A57024E180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570239180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h */; }; - 1A57024F180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023A180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h */; }; - 1A570250180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023A180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h */; }; - 1A570251180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023B180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h */; }; - 1A570252180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023B180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h */; }; - 1A570253180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023C180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h */; }; - 1A570254180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023C180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h */; }; - 1A570255180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023D180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h */; }; - 1A570256180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023D180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h */; }; - 1A570257180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023E180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h */; }; - 1A570258180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023E180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h */; }; - 1A570259180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023F180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h */; }; - 1A57025A180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57023F180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h */; }; - 1A57025B180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570240180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h */; }; - 1A57025C180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570240180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h */; }; - 1A57025D180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570241180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h */; }; - 1A57025E180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570241180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h */; }; - 1A57025F180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570242180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h */; }; - 1A570260180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570242180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h */; }; - 1A570261180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570243180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h */; }; - 1A570262180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570243180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h */; }; - 1A570263180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570244180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h */; }; - 1A570264180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570244180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h */; }; - 1A570265180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570245180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h */; }; - 1A570266180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570245180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h */; }; - 1A570267180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570246180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h */; }; - 1A570268180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570246180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h */; }; - 1A570269180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570247180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h */; }; - 1A57026A180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570247180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h */; }; - 1A57026B180BCC6F0088DEC7 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570248180BCC6F0088DEC7 /* CCShaderCache.cpp */; }; - 1A57026C180BCC6F0088DEC7 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570248180BCC6F0088DEC7 /* CCShaderCache.cpp */; }; - 1A57026D180BCC6F0088DEC7 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570249180BCC6F0088DEC7 /* CCShaderCache.h */; }; - 1A57026E180BCC6F0088DEC7 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570249180BCC6F0088DEC7 /* CCShaderCache.h */; }; - 1A570271180BCC6F0088DEC7 /* ccShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57024B180BCC6F0088DEC7 /* ccShaders.cpp */; }; - 1A570272180BCC6F0088DEC7 /* ccShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57024B180BCC6F0088DEC7 /* ccShaders.cpp */; }; - 1A570273180BCC6F0088DEC7 /* ccShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57024C180BCC6F0088DEC7 /* ccShaders.h */; }; - 1A570274180BCC6F0088DEC7 /* ccShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A57024C180BCC6F0088DEC7 /* ccShaders.h */; }; 1A57027E180BCC900088DEC7 /* CCSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570276180BCC900088DEC7 /* CCSprite.cpp */; }; 1A57027F180BCC900088DEC7 /* CCSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570276180BCC900088DEC7 /* CCSprite.cpp */; }; 1A570280180BCC900088DEC7 /* CCSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570277180BCC900088DEC7 /* CCSprite.h */; }; @@ -449,14 +411,6 @@ 1A5703BB180BD2800088DEC7 /* libwebp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A5703BA180BD2800088DEC7 /* libwebp.a */; }; 1A57052B180BD31F0088DEC7 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A57052A180BD31F0088DEC7 /* libfreetype.a */; }; 1A57052E180BD3280088DEC7 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A57052D180BD3280088DEC7 /* libfreetype.a */; }; - 1A570533180BD9500088DEC7 /* CCGLProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */; }; - 1A570534180BD9500088DEC7 /* CCGLProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */; }; - 1A570535180BD9500088DEC7 /* CCGLProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570530180BD9500088DEC7 /* CCGLProgram.h */; }; - 1A570536180BD9500088DEC7 /* CCGLProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570530180BD9500088DEC7 /* CCGLProgram.h */; }; - 1A570537180BD9500088DEC7 /* ccGLStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */; }; - 1A570538180BD9500088DEC7 /* ccGLStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */; }; - 1A570539180BD9500088DEC7 /* ccGLStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570532180BD9500088DEC7 /* ccGLStateCache.h */; }; - 1A57053A180BD9500088DEC7 /* ccGLStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A570532180BD9500088DEC7 /* ccGLStateCache.h */; }; 1A8C598B180E930E00EF57C3 /* CCActionFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5948180E930E00EF57C3 /* CCActionFrame.cpp */; }; 1A8C598C180E930E00EF57C3 /* CCActionFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A8C5948180E930E00EF57C3 /* CCActionFrame.cpp */; }; 1A8C598D180E930E00EF57C3 /* CCActionFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8C5949180E930E00EF57C3 /* CCActionFrame.h */; }; @@ -596,16 +550,6 @@ 1A9DCA2E180E6955007A3AD4 /* CCProtocols.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA05180E6955007A3AD4 /* CCProtocols.h */; }; 1A9DCA3B180E6955007A3AD4 /* firePngData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA0C180E6955007A3AD4 /* firePngData.h */; }; 1A9DCA3C180E6955007A3AD4 /* firePngData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9DCA0C180E6955007A3AD4 /* firePngData.h */; }; - 1AA95FDE18EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FD918EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h */; }; - 1AA95FDF18EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FD918EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h */; }; - 1AA95FE018EBB8EF00AE7485 /* ccShader_Label_frag_df.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDA18EBB8EF00AE7485 /* ccShader_Label_frag_df.h */; }; - 1AA95FE118EBB8EF00AE7485 /* ccShader_Label_frag_df.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDA18EBB8EF00AE7485 /* ccShader_Label_frag_df.h */; }; - 1AA95FE218EBB8EF00AE7485 /* ccShader_Label_frag_normal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDB18EBB8EF00AE7485 /* ccShader_Label_frag_normal.h */; }; - 1AA95FE318EBB8EF00AE7485 /* ccShader_Label_frag_normal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDB18EBB8EF00AE7485 /* ccShader_Label_frag_normal.h */; }; - 1AA95FE418EBB8EF00AE7485 /* ccShader_Label_frag_outline.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDC18EBB8EF00AE7485 /* ccShader_Label_frag_outline.h */; }; - 1AA95FE518EBB8EF00AE7485 /* ccShader_Label_frag_outline.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDC18EBB8EF00AE7485 /* ccShader_Label_frag_outline.h */; }; - 1AA95FE618EBB8EF00AE7485 /* ccShader_Label_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDD18EBB8EF00AE7485 /* ccShader_Label_vert.h */; }; - 1AA95FE718EBB8EF00AE7485 /* ccShader_Label_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA95FDD18EBB8EF00AE7485 /* ccShader_Label_vert.h */; }; 1AAF528B180E2ECC000584C8 /* b2BroadPhase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168B61807AF9C005B8026 /* b2BroadPhase.cpp */; }; 1AAF528C180E2ECC000584C8 /* b2BroadPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168B71807AF9C005B8026 /* b2BroadPhase.h */; }; 1AAF528D180E2ECC000584C8 /* b2CollideCircle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168B81807AF9C005B8026 /* b2CollideCircle.cpp */; }; @@ -1614,6 +1558,74 @@ 5027253B190BF1B900AAF4ED /* cocos2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 50272538190BF1B900AAF4ED /* cocos2d.h */; }; 5027253C190BF1B900AAF4ED /* cocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50272539190BF1B900AAF4ED /* cocos2d.cpp */; }; 5027253D190BF1B900AAF4ED /* cocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50272539190BF1B900AAF4ED /* cocos2d.cpp */; }; + 5034CA19191D591000CE6051 /* ccShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9F7191D591000CE6051 /* ccShaders.h */; }; + 5034CA1A191D591100CE6051 /* ccShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9F7191D591000CE6051 /* ccShaders.h */; }; + 5034CA1B191D591100CE6051 /* ccShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9F8191D591000CE6051 /* ccShaders.cpp */; }; + 5034CA1C191D591100CE6051 /* ccShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9F8191D591000CE6051 /* ccShaders.cpp */; }; + 5034CA1D191D591100CE6051 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9F9191D591000CE6051 /* CCShaderCache.h */; }; + 5034CA1E191D591100CE6051 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9F9191D591000CE6051 /* CCShaderCache.h */; }; + 5034CA1F191D591100CE6051 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9FA191D591000CE6051 /* CCShaderCache.cpp */; }; + 5034CA20191D591100CE6051 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9FA191D591000CE6051 /* CCShaderCache.cpp */; }; + 5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h */; }; + 5034CA22191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h */; }; + 5034CA23191D591100CE6051 /* ccShader_PositionTextureColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FC191D591000CE6051 /* ccShader_PositionTextureColor_vert.h */; }; + 5034CA24191D591100CE6051 /* ccShader_PositionTextureColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FC191D591000CE6051 /* ccShader_PositionTextureColor_vert.h */; }; + 5034CA25191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FD191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h */; }; + 5034CA26191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FD191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h */; }; + 5034CA27191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FE191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h */; }; + 5034CA28191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FE191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h */; }; + 5034CA29191D591100CE6051 /* ccShader_PositionTextureColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FF191D591000CE6051 /* ccShader_PositionTextureColor_frag.h */; }; + 5034CA2A191D591100CE6051 /* ccShader_PositionTextureColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FF191D591000CE6051 /* ccShader_PositionTextureColor_frag.h */; }; + 5034CA2B191D591100CE6051 /* ccShader_PositionTextureA8Color_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color_vert.h */; }; + 5034CA2C191D591100CE6051 /* ccShader_PositionTextureA8Color_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color_vert.h */; }; + 5034CA2D191D591100CE6051 /* ccShader_PositionTextureA8Color_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color_frag.h */; }; + 5034CA2E191D591100CE6051 /* ccShader_PositionTextureA8Color_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color_frag.h */; }; + 5034CA2F191D591100CE6051 /* ccShader_PositionTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA02191D591000CE6051 /* ccShader_PositionTexture_vert.h */; }; + 5034CA30191D591100CE6051 /* ccShader_PositionTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA02191D591000CE6051 /* ccShader_PositionTexture_vert.h */; }; + 5034CA31191D591100CE6051 /* ccShader_PositionTexture_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA03191D591000CE6051 /* ccShader_PositionTexture_uColor_vert.h */; }; + 5034CA32191D591100CE6051 /* ccShader_PositionTexture_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA03191D591000CE6051 /* ccShader_PositionTexture_uColor_vert.h */; }; + 5034CA33191D591100CE6051 /* ccShader_PositionTexture_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA04191D591000CE6051 /* ccShader_PositionTexture_uColor_frag.h */; }; + 5034CA34191D591100CE6051 /* ccShader_PositionTexture_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA04191D591000CE6051 /* ccShader_PositionTexture_uColor_frag.h */; }; + 5034CA35191D591100CE6051 /* ccShader_PositionTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA05191D591000CE6051 /* ccShader_PositionTexture_frag.h */; }; + 5034CA36191D591100CE6051 /* ccShader_PositionTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA05191D591000CE6051 /* ccShader_PositionTexture_frag.h */; }; + 5034CA37191D591100CE6051 /* ccShader_PositionColorLengthTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA06191D591000CE6051 /* ccShader_PositionColorLengthTexture_vert.h */; }; + 5034CA38191D591100CE6051 /* ccShader_PositionColorLengthTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA06191D591000CE6051 /* ccShader_PositionColorLengthTexture_vert.h */; }; + 5034CA39191D591100CE6051 /* ccShader_PositionColorLengthTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA07191D591000CE6051 /* ccShader_PositionColorLengthTexture_frag.h */; }; + 5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA07191D591000CE6051 /* ccShader_PositionColorLengthTexture_frag.h */; }; + 5034CA3B191D591100CE6051 /* ccShader_PositionColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA08191D591000CE6051 /* ccShader_PositionColor_vert.h */; }; + 5034CA3C191D591100CE6051 /* ccShader_PositionColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA08191D591000CE6051 /* ccShader_PositionColor_vert.h */; }; + 5034CA3D191D591100CE6051 /* ccShader_PositionColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA09191D591000CE6051 /* ccShader_PositionColor_frag.h */; }; + 5034CA3E191D591100CE6051 /* ccShader_PositionColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA09191D591000CE6051 /* ccShader_PositionColor_frag.h */; }; + 5034CA3F191D591100CE6051 /* ccShader_Position_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0A191D591000CE6051 /* ccShader_Position_uColor_vert.h */; }; + 5034CA40191D591100CE6051 /* ccShader_Position_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0A191D591000CE6051 /* ccShader_Position_uColor_vert.h */; }; + 5034CA41191D591100CE6051 /* ccShader_Position_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0B191D591000CE6051 /* ccShader_Position_uColor_frag.h */; }; + 5034CA42191D591100CE6051 /* ccShader_Position_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0B191D591000CE6051 /* ccShader_Position_uColor_frag.h */; }; + 5034CA43191D591100CE6051 /* ccShader_Label_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0C191D591000CE6051 /* ccShader_Label_vert.h */; }; + 5034CA44191D591100CE6051 /* ccShader_Label_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0C191D591000CE6051 /* ccShader_Label_vert.h */; }; + 5034CA45191D591100CE6051 /* ccShader_Label_frag_outline.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0D191D591000CE6051 /* ccShader_Label_frag_outline.h */; }; + 5034CA46191D591100CE6051 /* ccShader_Label_frag_outline.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0D191D591000CE6051 /* ccShader_Label_frag_outline.h */; }; + 5034CA47191D591100CE6051 /* ccShader_Label_frag_normal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0E191D591000CE6051 /* ccShader_Label_frag_normal.h */; }; + 5034CA48191D591100CE6051 /* ccShader_Label_frag_normal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0E191D591000CE6051 /* ccShader_Label_frag_normal.h */; }; + 5034CA49191D591100CE6051 /* ccShader_Label_frag_df.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0F191D591000CE6051 /* ccShader_Label_frag_df.h */; }; + 5034CA4A191D591100CE6051 /* ccShader_Label_frag_df.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0F191D591000CE6051 /* ccShader_Label_frag_df.h */; }; + 5034CA4B191D591100CE6051 /* ccShader_Label_frag_df_glow.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA10191D591000CE6051 /* ccShader_Label_frag_df_glow.h */; }; + 5034CA4C191D591100CE6051 /* ccShader_Label_frag_df_glow.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA10191D591000CE6051 /* ccShader_Label_frag_df_glow.h */; }; + 5034CA4D191D591100CE6051 /* ccGLStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA11191D591000CE6051 /* ccGLStateCache.h */; }; + 5034CA4E191D591100CE6051 /* ccGLStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA11191D591000CE6051 /* ccGLStateCache.h */; }; + 5034CA4F191D591100CE6051 /* ccGLStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034CA12191D591000CE6051 /* ccGLStateCache.cpp */; }; + 5034CA50191D591100CE6051 /* ccGLStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034CA12191D591000CE6051 /* ccGLStateCache.cpp */; }; + 5034CA51191D591100CE6051 /* CCGLProgramStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA13191D591000CE6051 /* CCGLProgramStateCache.h */; }; + 5034CA52191D591100CE6051 /* CCGLProgramStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA13191D591000CE6051 /* CCGLProgramStateCache.h */; }; + 5034CA53191D591100CE6051 /* CCGLProgramStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034CA14191D591000CE6051 /* CCGLProgramStateCache.cpp */; }; + 5034CA54191D591100CE6051 /* CCGLProgramStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034CA14191D591000CE6051 /* CCGLProgramStateCache.cpp */; }; + 5034CA55191D591100CE6051 /* CCGLProgramState.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA15191D591000CE6051 /* CCGLProgramState.h */; }; + 5034CA56191D591100CE6051 /* CCGLProgramState.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA15191D591000CE6051 /* CCGLProgramState.h */; }; + 5034CA57191D591100CE6051 /* CCGLProgramState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034CA16191D591000CE6051 /* CCGLProgramState.cpp */; }; + 5034CA58191D591100CE6051 /* CCGLProgramState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034CA16191D591000CE6051 /* CCGLProgramState.cpp */; }; + 5034CA59191D591100CE6051 /* CCGLProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA17191D591000CE6051 /* CCGLProgram.h */; }; + 5034CA5A191D591100CE6051 /* CCGLProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA17191D591000CE6051 /* CCGLProgram.h */; }; + 5034CA5B191D591100CE6051 /* CCGLProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034CA18191D591000CE6051 /* CCGLProgram.cpp */; }; + 5034CA5C191D591100CE6051 /* CCGLProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034CA18191D591000CE6051 /* CCGLProgram.cpp */; }; 50E6D30E18DADB5D0051CA34 /* CCProtectedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E6D30C18DADB5D0051CA34 /* CCProtectedNode.cpp */; }; 50E6D30F18DADB5D0051CA34 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 50E6D30D18DADB5D0051CA34 /* CCProtectedNode.h */; }; 50E6D31018DAF01A0051CA34 /* CCProtectedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E6D30C18DADB5D0051CA34 /* CCProtectedNode.cpp */; }; @@ -1688,10 +1700,6 @@ 50FCEBCA18C72017004AD434 /* WidgetReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 50FCEB9118C72017004AD434 /* WidgetReader.h */; }; 50FCEBCB18C72017004AD434 /* WidgetReaderProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 50FCEB9218C72017004AD434 /* WidgetReaderProtocol.h */; }; 50FCEBCC18C72017004AD434 /* WidgetReaderProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 50FCEB9218C72017004AD434 /* WidgetReaderProtocol.h */; }; - A023FA34185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = A023FA32185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h */; }; - A023FA35185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = A023FA32185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h */; }; - A023FA36185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = A023FA33185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h */; }; - A023FA37185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = A023FA33185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h */; }; A04583F2189053B500E32FE8 /* CCGLView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A04583F0189053B500E32FE8 /* CCGLView.cpp */; }; A04583F3189053B500E32FE8 /* CCGLView.h in Headers */ = {isa = PBXBuildFile; fileRef = A04583F1189053B500E32FE8 /* CCGLView.h */; }; A07A4CAF1783777C0073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A342158F2AB200E66CFE /* Foundation.framework */; }; @@ -1964,25 +1972,6 @@ 1A570220180BCC1A0088DEC7 /* CCParticleSystemQuad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCParticleSystemQuad.h; sourceTree = ""; }; 1A570232180BCC4D0088DEC7 /* CCScriptSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCScriptSupport.cpp; sourceTree = ""; }; 1A570233180BCC4D0088DEC7 /* CCScriptSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCScriptSupport.h; sourceTree = ""; }; - 1A570239180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Position_uColor_frag.h; sourceTree = ""; }; - 1A57023A180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Position_uColor_vert.h; sourceTree = ""; }; - 1A57023B180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColor_frag.h; sourceTree = ""; }; - 1A57023C180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColor_vert.h; sourceTree = ""; }; - 1A57023D180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColorLengthTexture_frag.h; sourceTree = ""; }; - 1A57023E180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColorLengthTexture_vert.h; sourceTree = ""; }; - 1A57023F180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_frag.h; sourceTree = ""; }; - 1A570240180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_uColor_frag.h; sourceTree = ""; }; - 1A570241180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_uColor_vert.h; sourceTree = ""; }; - 1A570242180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_vert.h; sourceTree = ""; }; - 1A570243180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureA8Color_frag.h; sourceTree = ""; }; - 1A570244180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureA8Color_vert.h; sourceTree = ""; }; - 1A570245180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_frag.h; sourceTree = ""; }; - 1A570246180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_vert.h; sourceTree = ""; }; - 1A570247180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColorAlphaTest_frag.h; sourceTree = ""; }; - 1A570248180BCC6F0088DEC7 /* CCShaderCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCShaderCache.cpp; sourceTree = ""; }; - 1A570249180BCC6F0088DEC7 /* CCShaderCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCShaderCache.h; sourceTree = ""; }; - 1A57024B180BCC6F0088DEC7 /* ccShaders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccShaders.cpp; sourceTree = ""; }; - 1A57024C180BCC6F0088DEC7 /* ccShaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShaders.h; sourceTree = ""; }; 1A570276180BCC900088DEC7 /* CCSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCSprite.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 1A570277180BCC900088DEC7 /* CCSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSprite.h; sourceTree = ""; }; 1A570278180BCC900088DEC7 /* CCSpriteBatchNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteBatchNode.cpp; sourceTree = ""; }; @@ -2055,10 +2044,6 @@ 1A5703BA180BD2800088DEC7 /* libwebp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwebp.a; sourceTree = ""; }; 1A57052A180BD31F0088DEC7 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfreetype.a; sourceTree = ""; }; 1A57052D180BD3280088DEC7 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfreetype.a; sourceTree = ""; }; - 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgram.cpp; sourceTree = ""; }; - 1A570530180BD9500088DEC7 /* CCGLProgram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgram.h; sourceTree = ""; }; - 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccGLStateCache.cpp; sourceTree = ""; }; - 1A570532180BD9500088DEC7 /* ccGLStateCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccGLStateCache.h; sourceTree = ""; }; 1A57FFF7180BC5160088DEC7 /* CHANGELOG */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; lineEnding = 0; name = CHANGELOG; path = ../CHANGELOG; sourceTree = ""; }; 1A8C5948180E930E00EF57C3 /* CCActionFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionFrame.cpp; sourceTree = ""; }; 1A8C5949180E930E00EF57C3 /* CCActionFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionFrame.h; sourceTree = ""; }; @@ -2129,11 +2114,6 @@ 1A9DCA03180E6955007A3AD4 /* CCGLBufferedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLBufferedNode.h; sourceTree = ""; }; 1A9DCA05180E6955007A3AD4 /* CCProtocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProtocols.h; sourceTree = ""; }; 1A9DCA0C180E6955007A3AD4 /* firePngData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = firePngData.h; sourceTree = ""; }; - 1AA95FD918EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_df_glow.h; sourceTree = ""; }; - 1AA95FDA18EBB8EF00AE7485 /* ccShader_Label_frag_df.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_df.h; sourceTree = ""; }; - 1AA95FDB18EBB8EF00AE7485 /* ccShader_Label_frag_normal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_normal.h; sourceTree = ""; }; - 1AA95FDC18EBB8EF00AE7485 /* ccShader_Label_frag_outline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_outline.h; sourceTree = ""; }; - 1AA95FDD18EBB8EF00AE7485 /* ccShader_Label_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_vert.h; sourceTree = ""; }; 1AAF5351180E3060000584C8 /* AssetsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AssetsManager.cpp; sourceTree = ""; }; 1AAF5352180E3060000584C8 /* AssetsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AssetsManager.h; sourceTree = ""; }; 1AAF5362180E3374000584C8 /* HttpClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HttpClient.cpp; sourceTree = ""; }; @@ -2694,6 +2674,40 @@ 500DC9BB19106E89007B91BF /* CCProfiling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCProfiling.h; path = ../base/CCProfiling.h; sourceTree = ""; }; 50272538190BF1B900AAF4ED /* cocos2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cocos2d.h; path = ../cocos/cocos2d.h; sourceTree = ""; }; 50272539190BF1B900AAF4ED /* cocos2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cocos2d.cpp; path = ../cocos/cocos2d.cpp; sourceTree = ""; }; + 5034C9F7191D591000CE6051 /* ccShaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShaders.h; sourceTree = ""; }; + 5034C9F8191D591000CE6051 /* ccShaders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccShaders.cpp; sourceTree = ""; }; + 5034C9F9191D591000CE6051 /* CCShaderCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCShaderCache.h; sourceTree = ""; }; + 5034C9FA191D591000CE6051 /* CCShaderCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCShaderCache.cpp; sourceTree = ""; }; + 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColorAlphaTest_frag.h; sourceTree = ""; }; + 5034C9FC191D591000CE6051 /* ccShader_PositionTextureColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_vert.h; sourceTree = ""; }; + 5034C9FD191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_noMVP_vert.h; sourceTree = ""; }; + 5034C9FE191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_noMVP_frag.h; sourceTree = ""; }; + 5034C9FF191D591000CE6051 /* ccShader_PositionTextureColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_frag.h; sourceTree = ""; }; + 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureA8Color_vert.h; sourceTree = ""; }; + 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureA8Color_frag.h; sourceTree = ""; }; + 5034CA02191D591000CE6051 /* ccShader_PositionTexture_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_vert.h; sourceTree = ""; }; + 5034CA03191D591000CE6051 /* ccShader_PositionTexture_uColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_uColor_vert.h; sourceTree = ""; }; + 5034CA04191D591000CE6051 /* ccShader_PositionTexture_uColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_uColor_frag.h; sourceTree = ""; }; + 5034CA05191D591000CE6051 /* ccShader_PositionTexture_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_frag.h; sourceTree = ""; }; + 5034CA06191D591000CE6051 /* ccShader_PositionColorLengthTexture_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColorLengthTexture_vert.h; sourceTree = ""; }; + 5034CA07191D591000CE6051 /* ccShader_PositionColorLengthTexture_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColorLengthTexture_frag.h; sourceTree = ""; }; + 5034CA08191D591000CE6051 /* ccShader_PositionColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColor_vert.h; sourceTree = ""; }; + 5034CA09191D591000CE6051 /* ccShader_PositionColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColor_frag.h; sourceTree = ""; }; + 5034CA0A191D591000CE6051 /* ccShader_Position_uColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Position_uColor_vert.h; sourceTree = ""; }; + 5034CA0B191D591000CE6051 /* ccShader_Position_uColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Position_uColor_frag.h; sourceTree = ""; }; + 5034CA0C191D591000CE6051 /* ccShader_Label_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_vert.h; sourceTree = ""; }; + 5034CA0D191D591000CE6051 /* ccShader_Label_frag_outline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_outline.h; sourceTree = ""; }; + 5034CA0E191D591000CE6051 /* ccShader_Label_frag_normal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_normal.h; sourceTree = ""; }; + 5034CA0F191D591000CE6051 /* ccShader_Label_frag_df.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_df.h; sourceTree = ""; }; + 5034CA10191D591000CE6051 /* ccShader_Label_frag_df_glow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_df_glow.h; sourceTree = ""; }; + 5034CA11191D591000CE6051 /* ccGLStateCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccGLStateCache.h; sourceTree = ""; }; + 5034CA12191D591000CE6051 /* ccGLStateCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccGLStateCache.cpp; sourceTree = ""; }; + 5034CA13191D591000CE6051 /* CCGLProgramStateCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgramStateCache.h; sourceTree = ""; }; + 5034CA14191D591000CE6051 /* CCGLProgramStateCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgramStateCache.cpp; sourceTree = ""; }; + 5034CA15191D591000CE6051 /* CCGLProgramState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgramState.h; sourceTree = ""; }; + 5034CA16191D591000CE6051 /* CCGLProgramState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgramState.cpp; sourceTree = ""; }; + 5034CA17191D591000CE6051 /* CCGLProgram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgram.h; sourceTree = ""; }; + 5034CA18191D591000CE6051 /* CCGLProgram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgram.cpp; sourceTree = ""; }; 50DC5180187B817900A9C23F /* RELEASE_NOTES.md */ = {isa = PBXFileReference; lastKnownFileType = text; name = RELEASE_NOTES.md; path = ../docs/RELEASE_NOTES.md; sourceTree = ""; }; 50E6D30C18DADB5D0051CA34 /* CCProtectedNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCProtectedNode.cpp; sourceTree = ""; }; 50E6D30D18DADB5D0051CA34 /* CCProtectedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProtectedNode.h; sourceTree = ""; }; @@ -2764,8 +2778,6 @@ A0053FBE189B2BEA0035A564 /* CCPlatformDefine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCPlatformDefine.h; sourceTree = ""; }; A0053FBF189B2BEA0035A564 /* CCStdC.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCStdC.cpp; sourceTree = ""; }; A0053FC0189B2BEA0035A564 /* CCStdC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCStdC.h; sourceTree = ""; }; - A023FA32185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_noMVP_frag.h; sourceTree = ""; }; - A023FA33185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_noMVP_vert.h; sourceTree = ""; }; A03F2CB81780BD04006731B9 /* libchipmunk Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libchipmunk Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A03F2D9B1780BDF7006731B9 /* libbox2d Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libbox2d Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A03F2ED617814268006731B9 /* libCocosDenshion Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libCocosDenshion Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -3243,43 +3255,6 @@ name = "script-support"; sourceTree = ""; }; - 1A570238180BCC580088DEC7 /* shaders */ = { - isa = PBXGroup; - children = ( - 1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */, - 1A570530180BD9500088DEC7 /* CCGLProgram.h */, - 1A570531180BD9500088DEC7 /* ccGLStateCache.cpp */, - 1A570532180BD9500088DEC7 /* ccGLStateCache.h */, - 1AA95FDA18EBB8EF00AE7485 /* ccShader_Label_frag_df.h */, - 1AA95FD918EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h */, - 1AA95FDB18EBB8EF00AE7485 /* ccShader_Label_frag_normal.h */, - 1AA95FDC18EBB8EF00AE7485 /* ccShader_Label_frag_outline.h */, - 1AA95FDD18EBB8EF00AE7485 /* ccShader_Label_vert.h */, - 1A570239180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h */, - 1A57023A180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h */, - 1A57023B180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h */, - 1A57023C180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h */, - 1A57023D180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h */, - 1A57023E180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h */, - 1A57023F180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h */, - 1A570240180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h */, - 1A570241180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h */, - 1A570242180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h */, - 1A570243180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h */, - 1A570244180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h */, - 1A570245180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h */, - A023FA32185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h */, - A023FA33185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h */, - 1A570246180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h */, - 1A570247180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h */, - 1A570248180BCC6F0088DEC7 /* CCShaderCache.cpp */, - 1A570249180BCC6F0088DEC7 /* CCShaderCache.h */, - 1A57024B180BCC6F0088DEC7 /* ccShaders.cpp */, - 1A57024C180BCC6F0088DEC7 /* ccShaders.h */, - ); - name = shaders; - sourceTree = ""; - }; 1A570275180BCC840088DEC7 /* sprite-nodes */ = { isa = PBXGroup; children = ( @@ -4467,7 +4442,6 @@ 1A570218180BCC000088DEC7 /* particle-nodes */, 46A16A5A1807B038005B8026 /* platform */, 1A570231180BCC380088DEC7 /* script-support */, - 1A570238180BCC580088DEC7 /* shaders */, 1A570275180BCC840088DEC7 /* sprite-nodes */, 1A57029A180BCD4F0088DEC7 /* support */, 1A5702BC180BCE0A0088DEC7 /* text-input-node */, @@ -4641,6 +4615,19 @@ 500DC89819105D41007B91BF /* renderer */ = { isa = PBXGroup; children = ( + 5034CA5D191D591900CE6051 /* shaders */, + 5034C9F7191D591000CE6051 /* ccShaders.h */, + 5034C9F8191D591000CE6051 /* ccShaders.cpp */, + 5034C9F9191D591000CE6051 /* CCShaderCache.h */, + 5034C9FA191D591000CE6051 /* CCShaderCache.cpp */, + 5034CA11191D591000CE6051 /* ccGLStateCache.h */, + 5034CA12191D591000CE6051 /* ccGLStateCache.cpp */, + 5034CA13191D591000CE6051 /* CCGLProgramStateCache.h */, + 5034CA14191D591000CE6051 /* CCGLProgramStateCache.cpp */, + 5034CA15191D591000CE6051 /* CCGLProgramState.h */, + 5034CA16191D591000CE6051 /* CCGLProgramState.cpp */, + 5034CA17191D591000CE6051 /* CCGLProgram.h */, + 5034CA18191D591000CE6051 /* CCGLProgram.cpp */, 500DC89919105D41007B91BF /* CCBatchCommand.cpp */, 500DC89A19105D41007B91BF /* CCBatchCommand.h */, 500DC89B19105D41007B91BF /* CCCustomCommand.cpp */, @@ -4659,6 +4646,35 @@ path = ../cocos/renderer; sourceTree = ""; }; + 5034CA5D191D591900CE6051 /* shaders */ = { + isa = PBXGroup; + children = ( + 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h */, + 5034C9FC191D591000CE6051 /* ccShader_PositionTextureColor_vert.h */, + 5034C9FD191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h */, + 5034C9FE191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h */, + 5034C9FF191D591000CE6051 /* ccShader_PositionTextureColor_frag.h */, + 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color_vert.h */, + 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color_frag.h */, + 5034CA02191D591000CE6051 /* ccShader_PositionTexture_vert.h */, + 5034CA03191D591000CE6051 /* ccShader_PositionTexture_uColor_vert.h */, + 5034CA04191D591000CE6051 /* ccShader_PositionTexture_uColor_frag.h */, + 5034CA05191D591000CE6051 /* ccShader_PositionTexture_frag.h */, + 5034CA06191D591000CE6051 /* ccShader_PositionColorLengthTexture_vert.h */, + 5034CA07191D591000CE6051 /* ccShader_PositionColorLengthTexture_frag.h */, + 5034CA08191D591000CE6051 /* ccShader_PositionColor_vert.h */, + 5034CA09191D591000CE6051 /* ccShader_PositionColor_frag.h */, + 5034CA0A191D591000CE6051 /* ccShader_Position_uColor_vert.h */, + 5034CA0B191D591000CE6051 /* ccShader_Position_uColor_frag.h */, + 5034CA0C191D591000CE6051 /* ccShader_Label_vert.h */, + 5034CA0D191D591000CE6051 /* ccShader_Label_frag_outline.h */, + 5034CA0E191D591000CE6051 /* ccShader_Label_frag_normal.h */, + 5034CA0F191D591000CE6051 /* ccShader_Label_frag_df.h */, + 5034CA10191D591000CE6051 /* ccShader_Label_frag_df_glow.h */, + ); + name = shaders; + sourceTree = ""; + }; 50FCEB6818C72017004AD434 /* WidgetReader */ = { isa = PBXGroup; children = ( @@ -4896,6 +4912,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 5034CA39191D591100CE6051 /* ccShader_PositionColorLengthTexture_frag.h in Headers */, 2AC795DF18628723005EC8E1 /* SkeletonBounds.h in Headers */, 2AC795E018628723005EC8E1 /* Event.h in Headers */, 2AC795E118628723005EC8E1 /* EventData.h in Headers */, @@ -4906,6 +4923,7 @@ 06CAAAC9186AD7EE0012A414 /* TriggerMng.h in Headers */, 2905FA6018CF08D100240AA3 /* UILayoutParameter.h in Headers */, 1ABA68B01888D700007D1BB4 /* CCFontCharMap.h in Headers */, + 5034CA3F191D591100CE6051 /* ccShader_Position_uColor_vert.h in Headers */, 500DC8B419105D41007B91BF /* CCGroupCommand.h in Headers */, 500DC8D319105F7D007B91BF /* CCAffineTransform.h in Headers */, 46A170191807CBFC005B8026 /* CCCommon.h in Headers */, @@ -4930,6 +4948,7 @@ 500DC99A19106300007B91BF /* ccTypes.h in Headers */, 46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */, 500DC8C219105D41007B91BF /* CCRenderCommandPool.h in Headers */, + 5034CA4D191D591100CE6051 /* ccGLStateCache.h in Headers */, 46A1705C1807CC1C005B8026 /* CCStdC.h in Headers */, 46A1704F1807CC1C005B8026 /* CCApplication.h in Headers */, 500DC98C19106300007B91BF /* CCPlatformMacros.h in Headers */, @@ -4942,16 +4961,16 @@ 1A57006F180BC5A10088DEC7 /* CCActionEase.h in Headers */, 1A570073180BC5A10088DEC7 /* CCActionGrid.h in Headers */, 50FCEBB518C72017004AD434 /* SliderReader.h in Headers */, + 5034CA3B191D591100CE6051 /* ccShader_PositionColor_vert.h in Headers */, 06CAAAD1186AD8010012A414 /* ObjectFactory.h in Headers */, - A023FA34185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */, 1A570077180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */, 1A57007B180BC5A10088DEC7 /* CCActionInstant.h in Headers */, 500DC8BC19105D41007B91BF /* CCQuadCommand.h in Headers */, 500DC94E19106300007B91BF /* CCEvent.h in Headers */, 1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */, 1A01C69A18F57BE800EFE3A6 /* CCSet.h in Headers */, + 5034CA23191D591100CE6051 /* ccShader_PositionTextureColor_vert.h in Headers */, 296CAD2A1915EC9900C64FBF /* CCEventListenerFocus.h in Headers */, - A023FA36185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, 1A570083180BC5A10088DEC7 /* CCActionManager.h in Headers */, 1A570087180BC5A10088DEC7 /* CCActionPageTurn3D.h in Headers */, ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */, @@ -4980,6 +4999,7 @@ 500DC98219106300007B91BF /* ccMacros.h in Headers */, 1A57011D180BC90D0088DEC7 /* CCGrabber.h in Headers */, 1A570121180BC90D0088DEC7 /* CCGrid.h in Headers */, + 5034CA2D191D591100CE6051 /* ccShader_PositionTextureA8Color_frag.h in Headers */, 50E6D33A18E174130051CA34 /* UIRelativeBox.h in Headers */, 500DC8C619105D41007B91BF /* CCRenderer.h in Headers */, 50E6D30F18DADB5D0051CA34 /* CCProtectedNode.h in Headers */, @@ -4992,6 +5012,7 @@ 1A01C68618F57BE800EFE3A6 /* CCArray.h in Headers */, 1A5701A7180BCB590088DEC7 /* CCFontAtlasCache.h in Headers */, 1A5701B3180BCB590088DEC7 /* CCFontFNT.h in Headers */, + 5034CA47191D591100CE6051 /* ccShader_Label_frag_normal.h in Headers */, 1A5701B7180BCB5A0088DEC7 /* CCFontFreeType.h in Headers */, 500DC94219106300007B91BF /* CCData.h in Headers */, 1A5701BB180BCB5A0088DEC7 /* CCLabel.h in Headers */, @@ -4999,7 +5020,7 @@ 1A5701C3180BCB5A0088DEC7 /* CCLabelBMFont.h in Headers */, 500DC93A19106300007B91BF /* CCConfiguration.h in Headers */, 1A5701C9180BCB5A0088DEC7 /* CCLabelTextFormatter.h in Headers */, - 1AA95FE618EBB8EF00AE7485 /* ccShader_Label_vert.h in Headers */, + 5034CA37191D591100CE6051 /* ccShader_PositionColorLengthTexture_vert.h in Headers */, 1A5701CD180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */, 1A5701E0180BCB8C0088DEC7 /* CCLayer.h in Headers */, 1A5701E4180BCB8C0088DEC7 /* CCScene.h in Headers */, @@ -5020,43 +5041,31 @@ 500DC99E19106300007B91BF /* CCValue.h in Headers */, 1A01C69618F57BE800EFE3A6 /* CCInteger.h in Headers */, 1A570223180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */, + 5034CA43191D591100CE6051 /* ccShader_Label_vert.h in Headers */, 1A570227180BCC1A0088DEC7 /* CCParticleExamples.h in Headers */, 1A57022B180BCC1A0088DEC7 /* CCParticleSystem.h in Headers */, + 5034CA2F191D591100CE6051 /* ccShader_PositionTexture_vert.h in Headers */, + 5034CA4B191D591100CE6051 /* ccShader_Label_frag_df_glow.h in Headers */, 1A57022F180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */, 500DC96A19106300007B91BF /* CCEventListenerCustom.h in Headers */, B2AF2F9718EBAEAE00C5807C /* MathUtil.h in Headers */, 1A570236180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */, - 1A57024D180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */, - 1A57024F180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */, - 1AA95FE418EBB8EF00AE7485 /* ccShader_Label_frag_outline.h in Headers */, 500DC95E19106300007B91BF /* CCEventKeyboard.h in Headers */, 2905FA4218CF08D100240AA3 /* CocosGUI.h in Headers */, - 1A570251180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h in Headers */, 500DC95A19106300007B91BF /* CCEventDispatcher.h in Headers */, - 1A570253180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h in Headers */, - 1A570255180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h in Headers */, - 1A570257180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h in Headers */, - 1A570259180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */, - 1A57025B180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */, + 5034CA49191D591100CE6051 /* ccShader_Label_frag_df.h in Headers */, 500DC9A019106300007B91BF /* CCVector.h in Headers */, - 1A57025D180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */, - 1A57025F180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */, 500DC92C19106300007B91BF /* atitc.h in Headers */, 1A01C68C18F57BE800EFE3A6 /* CCDeprecated.h in Headers */, - 1A570261180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h in Headers */, 500DC98419106300007B91BF /* CCMap.h in Headers */, - 1A570263180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h in Headers */, - 1AA95FDE18EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h in Headers */, 2905FA6418CF08D100240AA3 /* UIListView.h in Headers */, - 1A570265180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h in Headers */, 50FCEBB918C72017004AD434 /* TextAtlasReader.h in Headers */, - 1A570267180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h in Headers */, - 1A570269180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */, - 1A57026D180BCC6F0088DEC7 /* CCShaderCache.h in Headers */, - 1A570273180BCC6F0088DEC7 /* ccShaders.h in Headers */, + 5034CA3D191D591100CE6051 /* ccShader_PositionColor_frag.h in Headers */, 1A570280180BCC900088DEC7 /* CCSprite.h in Headers */, 1A570284180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */, 500DC9A419106300007B91BF /* etc1.h in Headers */, + 5034CA55191D591100CE6051 /* CCGLProgramState.h in Headers */, + 5034CA2B191D591100CE6051 /* ccShader_PositionTextureA8Color_vert.h in Headers */, 1A570288180BCC900088DEC7 /* CCSpriteFrame.h in Headers */, 1A57028C180BCC900088DEC7 /* CCSpriteFrameCache.h in Headers */, 5027253A190BF1B900AAF4ED /* cocos2d.h in Headers */, @@ -5071,6 +5080,7 @@ 1A5702C0180BCE2A0088DEC7 /* CCIMEDelegate.h in Headers */, 2905FA7618CF08D100240AA3 /* UIScrollView.h in Headers */, 1A5702C4180BCE2A0088DEC7 /* CCIMEDispatcher.h in Headers */, + 5034CA25191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, 1A12775B18DFCC540005F345 /* CCTweenFunction.h in Headers */, 1A5702CA180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */, 1A5702D5180BCE570088DEC7 /* CCTexture2D.h in Headers */, @@ -5081,6 +5091,7 @@ 50FCEBAD18C72017004AD434 /* PageViewReader.h in Headers */, 1A5702F4180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */, 1A5702F8180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */, + 5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */, 1A5702FC180BCE750088DEC7 /* CCTMXXMLParser.h in Headers */, 1A570302180BCE890088DEC7 /* CCParallaxNode.h in Headers */, 1A57030E180BCF190088DEC7 /* CCComponent.h in Headers */, @@ -5102,10 +5113,7 @@ 500DC99619106300007B91BF /* CCScheduler.h in Headers */, 1A57035A180BD0B00088DEC7 /* unzip.h in Headers */, 296CAD241915EC8000C64FBF /* CCEventFocus.h in Headers */, - 1A570535180BD9500088DEC7 /* CCGLProgram.h in Headers */, - 1AA95FE018EBB8EF00AE7485 /* ccShader_Label_frag_df.h in Headers */, 500DC98819106300007B91BF /* CCNS.h in Headers */, - 1A570539180BD9500088DEC7 /* ccGLStateCache.h in Headers */, 1AD71DAB180E26E600808F54 /* CCBAnimationManager.h in Headers */, 1AD71DAF180E26E600808F54 /* CCBFileLoader.h in Headers */, B37510741823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */, @@ -5115,9 +5123,12 @@ 1AD71DB9180E26E600808F54 /* CCBReader.h in Headers */, 2905FA7E18CF08D100240AA3 /* UIText.h in Headers */, 1AD71DBB180E26E600808F54 /* CCBSelectorResolver.h in Headers */, + 5034CA29191D591100CE6051 /* ccShader_PositionTextureColor_frag.h in Headers */, + 5034CA35191D591100CE6051 /* ccShader_PositionTexture_frag.h in Headers */, 500DC98019106300007B91BF /* CCEventType.h in Headers */, 1AD71DBF180E26E600808F54 /* CCBSequence.h in Headers */, 1AD71DC3180E26E600808F54 /* CCBSequenceProperty.h in Headers */, + 5034CA31191D591100CE6051 /* ccShader_PositionTexture_uColor_vert.h in Headers */, 1AD71DCB180E26E600808F54 /* CCControlButtonLoader.h in Headers */, 1AD71DCF180E26E600808F54 /* CCControlLoader.h in Headers */, 1AD71DD3180E26E600808F54 /* CCLabelBMFontLoader.h in Headers */, @@ -5139,6 +5150,7 @@ 1AD71DFB180E26E600808F54 /* CCNodeLoaderListener.h in Headers */, 1AD71DFF180E26E600808F54 /* CCParticleSystemQuadLoader.h in Headers */, 1AD71E03180E26E600808F54 /* CCScale9SpriteLoader.h in Headers */, + 5034CA51191D591100CE6051 /* CCGLProgramStateCache.h in Headers */, 1AD71E07180E26E600808F54 /* CCScrollViewLoader.h in Headers */, 1AD71E0B180E26E600808F54 /* CCSpriteLoader.h in Headers */, 1AD71E0D180E26E600808F54 /* CocosBuilder.h in Headers */, @@ -5167,8 +5179,10 @@ 500DC8D919105F7D007B91BF /* CCMathBase.h in Headers */, 06CAAACD186AD7F90012A414 /* TriggerBase.h in Headers */, 1AD71ECB180E26E600808F54 /* RegionAttachment.h in Headers */, + 5034CA27191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */, 2905FA8618CF08D100240AA3 /* UITextBMFont.h in Headers */, 1AD71ECF180E26E600808F54 /* Skeleton.h in Headers */, + 5034CA41191D591100CE6051 /* ccShader_Position_uColor_frag.h in Headers */, 1A01C69E18F57BE800EFE3A6 /* CCString.h in Headers */, 500DC9B819106E6D007B91BF /* TransformUtils.h in Headers */, 1AD71ED3180E26E600808F54 /* SkeletonData.h in Headers */, @@ -5193,10 +5207,10 @@ 1A9DCA2D180E6955007A3AD4 /* CCProtocols.h in Headers */, 50FCEBB118C72017004AD434 /* ScrollViewReader.h in Headers */, 500DC98A19106300007B91BF /* CCPlatformConfig.h in Headers */, + 5034CA19191D591000CE6051 /* ccShaders.h in Headers */, 1A9DCA3B180E6955007A3AD4 /* firePngData.h in Headers */, B37510721823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */, 50FCEBA518C72017004AD434 /* ListViewReader.h in Headers */, - 1AA95FE218EBB8EF00AE7485 /* ccShader_Label_frag_normal.h in Headers */, 1A8C598D180E930E00EF57C3 /* CCActionFrame.h in Headers */, 1A8C5991180E930E00EF57C3 /* CCActionFrameEasing.h in Headers */, 1A8C5995180E930E00EF57C3 /* CCActionManagerEx.h in Headers */, @@ -5211,6 +5225,7 @@ 1A8C59B1180E930E00EF57C3 /* CCBatchNode.h in Headers */, 2905FA5418CF08D100240AA3 /* UIImageView.h in Headers */, 1A8C59B5180E930E00EF57C3 /* CCBone.h in Headers */, + 5034CA45191D591100CE6051 /* ccShader_Label_frag_outline.h in Headers */, 500DC96219106300007B91BF /* CCEventListener.h in Headers */, 1A8C59B9180E930E00EF57C3 /* CCColliderDetector.h in Headers */, 1A8C59BD180E930E00EF57C3 /* CCComAttribute.h in Headers */, @@ -5218,6 +5233,7 @@ B2AF2FB118EBBDA100C5807C /* CCMath.h in Headers */, 1A8C59C5180E930E00EF57C3 /* CCComController.h in Headers */, 1A8C59C9180E930E00EF57C3 /* CCComRender.h in Headers */, + 5034CA59191D591100CE6051 /* CCGLProgram.h in Headers */, 1A8C59CD180E930E00EF57C3 /* CCDataReaderHelper.h in Headers */, 1A8C59D1180E930E00EF57C3 /* CCDatas.h in Headers */, 1A8C59D5180E930E00EF57C3 /* CCDecorativeDisplay.h in Headers */, @@ -5226,7 +5242,9 @@ 1A8C59E1180E930E00EF57C3 /* CCInputDelegate.h in Headers */, 1A8C59E5180E930E00EF57C3 /* CCProcessBase.h in Headers */, 1A8C59E9180E930E00EF57C3 /* CCSGUIReader.h in Headers */, + 5034CA33191D591100CE6051 /* ccShader_PositionTexture_uColor_frag.h in Headers */, 1A8C59ED180E930E00EF57C3 /* CCSkin.h in Headers */, + 5034CA1D191D591100CE6051 /* CCShaderCache.h in Headers */, 1A8C59F1180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h in Headers */, 1A8C59F5180E930E00EF57C3 /* CCSSceneReader.h in Headers */, 1A8C59F9180E930E00EF57C3 /* CCTransformHelp.h in Headers */, @@ -5389,6 +5407,7 @@ 2AC795E91862875D005EC8E1 /* EventData.h in Headers */, 2AC795EA1862875D005EC8E1 /* BoundingBoxAttachment.h in Headers */, 500DC93519106300007B91BF /* CCAutoreleasePool.h in Headers */, + 5034CA1A191D591100CE6051 /* ccShaders.h in Headers */, 46A1702D1807CBFE005B8026 /* CCCommon.h in Headers */, 46A170FF1807CECB005B8026 /* CCPhysicsContact.h in Headers */, 46A171041807CECB005B8026 /* CCPhysicsShape.h in Headers */, @@ -5400,6 +5419,7 @@ 50FCEBAE18C72017004AD434 /* PageViewReader.h in Headers */, 46A1703F1807CC07005B8026 /* CCDirectorCaller.h in Headers */, 46A170381807CBFE005B8026 /* CCSAXParser.h in Headers */, + 5034CA38191D591100CE6051 /* ccShader_PositionColorLengthTexture_vert.h in Headers */, 500DC97319106300007B91BF /* CCEventListenerMouse.h in Headers */, 500DC99319106300007B91BF /* CCRefPtr.h in Headers */, 46A1702E1807CBFE005B8026 /* CCDevice.h in Headers */, @@ -5407,9 +5427,8 @@ 46A170451807CC07005B8026 /* CCESRenderer.h in Headers */, 46A171011807CECB005B8026 /* CCPhysicsJoint.h in Headers */, 46A170411807CC07005B8026 /* CCGLView.h in Headers */, - A023FA37185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, - 1AA95FE118EBB8EF00AE7485 /* ccShader_Label_frag_df.h in Headers */, 46A170301807CBFE005B8026 /* CCGLViewProtocol.h in Headers */, + 5034CA4E191D591100CE6051 /* ccGLStateCache.h in Headers */, 500DC8B119105D41007B91BF /* CCCustomCommand.h in Headers */, 500DC8DA19105F7D007B91BF /* CCMathBase.h in Headers */, 46A170321807CBFE005B8026 /* CCFileUtils.h in Headers */, @@ -5423,7 +5442,9 @@ 46A170271807CBFE005B8026 /* CCFileUtilsApple.h in Headers */, 46A170431807CC07005B8026 /* CCES2Renderer.h in Headers */, 46A170331807CBFE005B8026 /* CCImage.h in Headers */, + 5034CA40191D591100CE6051 /* ccShader_Position_uColor_vert.h in Headers */, 2905FA5518CF08D100240AA3 /* UIImageView.h in Headers */, + 5034CA28191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */, 46A170481807CC07005B8026 /* CCPlatformDefine.h in Headers */, 46A1704C1807CC07005B8026 /* OpenGL_Internal.h in Headers */, 46A1702C1807CBFE005B8026 /* CCApplicationProtocol.h in Headers */, @@ -5433,9 +5454,11 @@ 50FCEBC218C72017004AD434 /* TextFieldReader.h in Headers */, 1A570068180BC5A10088DEC7 /* CCActionCamera.h in Headers */, 1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */, + 5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture_frag.h in Headers */, 1A570070180BC5A10088DEC7 /* CCActionEase.h in Headers */, 1A570074180BC5A10088DEC7 /* CCActionGrid.h in Headers */, B37510841823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */, + 5034CA46191D591100CE6051 /* ccShader_Label_frag_outline.h in Headers */, 1A570078180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */, 1A01C68918F57BE800EFE3A6 /* CCBool.h in Headers */, 1A57007C180BC5A10088DEC7 /* CCActionInstant.h in Headers */, @@ -5457,6 +5480,7 @@ 2905FA6D18CF08D100240AA3 /* UIPageView.h in Headers */, 2905FA7318CF08D100240AA3 /* UIScrollInterface.h in Headers */, 2905FA4318CF08D100240AA3 /* CocosGUI.h in Headers */, + 5034CA30191D591100CE6051 /* ccShader_PositionTexture_vert.h in Headers */, 500DC93119106300007B91BF /* base64.h in Headers */, B2AF2FA018EBAEAE00C5807C /* Quaternion.h in Headers */, 50E6D33718E174130051CA34 /* UIHBox.h in Headers */, @@ -5468,9 +5492,11 @@ 1A57011E180BC90D0088DEC7 /* CCGrabber.h in Headers */, 1A570122180BC90D0088DEC7 /* CCGrid.h in Headers */, 500DC8C319105D41007B91BF /* CCRenderCommandPool.h in Headers */, + 5034CA52191D591100CE6051 /* CCGLProgramStateCache.h in Headers */, 500DC8C719105D41007B91BF /* CCRenderer.h in Headers */, 500DC98519106300007B91BF /* CCMap.h in Headers */, 50FCEBBA18C72017004AD434 /* TextAtlasReader.h in Headers */, + 5034CA2E191D591100CE6051 /* ccShader_PositionTextureA8Color_frag.h in Headers */, 1A5701A0180BCB590088DEC7 /* CCFont.h in Headers */, 1A5701A4180BCB590088DEC7 /* CCFontAtlas.h in Headers */, 1A5701A8180BCB590088DEC7 /* CCFontAtlasCache.h in Headers */, @@ -5479,13 +5505,14 @@ 1A5701B8180BCB5A0088DEC7 /* CCFontFreeType.h in Headers */, 1A5701BC180BCB5A0088DEC7 /* CCLabel.h in Headers */, 1A5701C0180BCB5A0088DEC7 /* CCLabelAtlas.h in Headers */, + 5034CA42191D591100CE6051 /* ccShader_Position_uColor_frag.h in Headers */, 500DC97719106300007B91BF /* CCEventListenerTouch.h in Headers */, 500DC93F19106300007B91BF /* CCConsole.h in Headers */, 1A5701C4180BCB5A0088DEC7 /* CCLabelBMFont.h in Headers */, 1A01C69518F57BE800EFE3A6 /* CCFloat.h in Headers */, 1A5701CA180BCB5A0088DEC7 /* CCLabelTextFormatter.h in Headers */, 2905FA7B18CF08D100240AA3 /* UISlider.h in Headers */, - 1AA95FE318EBB8EF00AE7485 /* ccShader_Label_frag_normal.h in Headers */, + 5034CA22191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */, 1A5701CE180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */, 296CAD251915EC8000C64FBF /* CCEventFocus.h in Headers */, 50FCEBCA18C72017004AD434 /* WidgetReader.h in Headers */, @@ -5500,43 +5527,30 @@ 50FCEBBE18C72017004AD434 /* TextBMFontReader.h in Headers */, 1A5701FE180BCBAD0088DEC7 /* CCMenuItem.h in Headers */, 1A570205180BCBD40088DEC7 /* CCClippingNode.h in Headers */, + 5034CA34191D591100CE6051 /* ccShader_PositionTexture_uColor_frag.h in Headers */, 1A57020B180BCBDF0088DEC7 /* CCMotionStreak.h in Headers */, 1A570213180BCBF40088DEC7 /* CCProgressTimer.h in Headers */, B37510821823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */, 1A570217180BCBF40088DEC7 /* CCRenderTexture.h in Headers */, 1A570224180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */, 500DC95F19106300007B91BF /* CCEventKeyboard.h in Headers */, - 1AA95FE518EBB8EF00AE7485 /* ccShader_Label_frag_outline.h in Headers */, 500DC95B19106300007B91BF /* CCEventDispatcher.h in Headers */, 373B912A187891FB00198F86 /* CCComBase.h in Headers */, 500DC8D419105F7D007B91BF /* CCAffineTransform.h in Headers */, 1A570228180BCC1A0088DEC7 /* CCParticleExamples.h in Headers */, 1A57022C180BCC1A0088DEC7 /* CCParticleSystem.h in Headers */, 1A570230180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */, + 5034CA24191D591100CE6051 /* ccShader_PositionTextureColor_vert.h in Headers */, + 5034CA2C191D591100CE6051 /* ccShader_PositionTextureA8Color_vert.h in Headers */, 1A570237180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */, - 1A57024E180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */, - 1A570250180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */, 2905FA8B18CF08D100240AA3 /* UITextField.h in Headers */, - 1A570252180BCC6F0088DEC7 /* ccShader_PositionColor_frag.h in Headers */, - 1A570254180BCC6F0088DEC7 /* ccShader_PositionColor_vert.h in Headers */, + 5034CA26191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, 500DC96F19106300007B91BF /* CCEventListenerKeyboard.h in Headers */, - 1A570256180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_frag.h in Headers */, - 1A570258180BCC6F0088DEC7 /* ccShader_PositionColorLengthTexture_vert.h in Headers */, 500DC8B519105D41007B91BF /* CCGroupCommand.h in Headers */, 50FCEBA618C72017004AD434 /* ListViewReader.h in Headers */, - 1A57025A180BCC6F0088DEC7 /* ccShader_PositionTexture_frag.h in Headers */, 500DC9B919106E6D007B91BF /* TransformUtils.h in Headers */, - 1A57025C180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_frag.h in Headers */, - 1A57025E180BCC6F0088DEC7 /* ccShader_PositionTexture_uColor_vert.h in Headers */, - 1A570260180BCC6F0088DEC7 /* ccShader_PositionTexture_vert.h in Headers */, - 1A570262180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_frag.h in Headers */, + 5034CA4A191D591100CE6051 /* ccShader_Label_frag_df.h in Headers */, 500DC99119106300007B91BF /* CCRef.h in Headers */, - 1A570264180BCC6F0088DEC7 /* ccShader_PositionTextureA8Color_vert.h in Headers */, - 1A570266180BCC6F0088DEC7 /* ccShader_PositionTextureColor_frag.h in Headers */, - 1A570268180BCC6F0088DEC7 /* ccShader_PositionTextureColor_vert.h in Headers */, - 1A57026A180BCC6F0088DEC7 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */, - 1A57026E180BCC6F0088DEC7 /* CCShaderCache.h in Headers */, - 1A570274180BCC6F0088DEC7 /* ccShaders.h in Headers */, 1A570281180BCC900088DEC7 /* CCSprite.h in Headers */, 1A570285180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */, 1A570289180BCC900088DEC7 /* CCSpriteFrame.h in Headers */, @@ -5551,6 +5565,7 @@ 2905FA6918CF08D100240AA3 /* UILoadingBar.h in Headers */, 2905FA8F18CF08D100240AA3 /* UIWidget.h in Headers */, 1A5702C5180BCE2A0088DEC7 /* CCIMEDispatcher.h in Headers */, + 5034CA1E191D591100CE6051 /* CCShaderCache.h in Headers */, 50FCEB9A18C72017004AD434 /* CheckBoxReader.h in Headers */, 500DC8AD19105D41007B91BF /* CCBatchCommand.h in Headers */, 1A5702CB180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */, @@ -5561,6 +5576,7 @@ 1A5702ED180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */, 500DC99F19106300007B91BF /* CCValue.h in Headers */, 1A5702F1180BCE750088DEC7 /* CCTMXLayer.h in Headers */, + 5034CA44191D591100CE6051 /* ccShader_Label_vert.h in Headers */, 1A5702F5180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */, 1A5702F9180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */, 500DC9A119106300007B91BF /* CCVector.h in Headers */, @@ -5582,16 +5598,15 @@ 1A570327180BCF660088DEC7 /* TGAlib.h in Headers */, 1A570332180BCFD50088DEC7 /* CCUserDefault.h in Headers */, 500DC94319106300007B91BF /* CCData.h in Headers */, - 1AA95FE718EBB8EF00AE7485 /* ccShader_Label_vert.h in Headers */, 1A57034E180BD09B0088DEC7 /* tinyxml2.h in Headers */, 1A570357180BD0B00088DEC7 /* ioapi.h in Headers */, 1A01C69B18F57BE800EFE3A6 /* CCSet.h in Headers */, 1A57035B180BD0B00088DEC7 /* unzip.h in Headers */, - 1A570536180BD9500088DEC7 /* CCGLProgram.h in Headers */, - 1A57053A180BD9500088DEC7 /* ccGLStateCache.h in Headers */, + 5034CA48191D591100CE6051 /* ccShader_Label_frag_normal.h in Headers */, 1AD71DAC180E26E600808F54 /* CCBAnimationManager.h in Headers */, 1AD71DB0180E26E600808F54 /* CCBFileLoader.h in Headers */, 1AD71DB4180E26E600808F54 /* CCBKeyframe.h in Headers */, + 5034CA3E191D591100CE6051 /* ccShader_PositionColor_frag.h in Headers */, 1AD71DB6180E26E600808F54 /* CCBMemberVariableAssigner.h in Headers */, 1AD71DBA180E26E600808F54 /* CCBReader.h in Headers */, 1AD71DBC180E26E600808F54 /* CCBSelectorResolver.h in Headers */, @@ -5601,7 +5616,9 @@ 1AD71DCC180E26E600808F54 /* CCControlButtonLoader.h in Headers */, 1AD71DD0180E26E600808F54 /* CCControlLoader.h in Headers */, 1AD71DD4180E26E600808F54 /* CCLabelBMFontLoader.h in Headers */, + 5034CA3C191D591100CE6051 /* ccShader_PositionColor_vert.h in Headers */, 46C02E0A18E91123004B7456 /* xxhash.h in Headers */, + 5034CA4C191D591100CE6051 /* ccShader_Label_frag_df_glow.h in Headers */, 50E6D33B18E174130051CA34 /* UIRelativeBox.h in Headers */, 1AD71DD8180E26E600808F54 /* CCLabelTTFLoader.h in Headers */, 1AD71DDC180E26E600808F54 /* CCLayerColorLoader.h in Headers */, @@ -5618,6 +5635,7 @@ 5027253B190BF1B900AAF4ED /* cocos2d.h in Headers */, 1AD71DFC180E26E600808F54 /* CCNodeLoaderListener.h in Headers */, 3EA0FB6B191C841D00B170C8 /* UIVideoPlayer.h in Headers */, + 5034CA2A191D591100CE6051 /* ccShader_PositionTextureColor_frag.h in Headers */, 1AD71E00180E26E600808F54 /* CCParticleSystemQuadLoader.h in Headers */, 1AD71E04180E26E600808F54 /* CCScale9SpriteLoader.h in Headers */, 1AD71E08180E26E600808F54 /* CCScrollViewLoader.h in Headers */, @@ -5637,6 +5655,7 @@ 2905FA4918CF08D100240AA3 /* UIButton.h in Headers */, 500DC96719106300007B91BF /* CCEventListenerAcceleration.h in Headers */, 1AD71EB0180E26E600808F54 /* AttachmentLoader.h in Headers */, + 5034CA32191D591100CE6051 /* ccShader_PositionTexture_uColor_vert.h in Headers */, 1AD71EB4180E26E600808F54 /* Bone.h in Headers */, 1AD71EB8180E26E600808F54 /* BoneData.h in Headers */, 06CAAACA186AD7EF0012A414 /* TriggerMng.h in Headers */, @@ -5666,18 +5685,20 @@ 1AAF5379180E3374000584C8 /* WebSocket.h in Headers */, 1AAF5852180E40B9000584C8 /* LocalStorage.h in Headers */, 1A9DCA26180E6955007A3AD4 /* ccFPSImages.h in Headers */, + 5034CA5A191D591100CE6051 /* CCGLProgram.h in Headers */, 1A9DCA2A180E6955007A3AD4 /* CCGLBufferedNode.h in Headers */, 1A0DB7321823827C0025743D /* CCGL.h in Headers */, 1A9DCA2E180E6955007A3AD4 /* CCProtocols.h in Headers */, 500DC96B19106300007B91BF /* CCEventListenerCustom.h in Headers */, 1A9DCA3C180E6955007A3AD4 /* firePngData.h in Headers */, - 1AA95FDF18EBB8EF00AE7485 /* ccShader_Label_frag_df_glow.h in Headers */, 1A01C69F18F57BE800EFE3A6 /* CCString.h in Headers */, 296CAD2B1915EC9900C64FBF /* CCEventListenerFocus.h in Headers */, 1A01C69118F57BE800EFE3A6 /* CCDictionary.h in Headers */, 500DC99B19106300007B91BF /* ccTypes.h in Headers */, 1A8C598E180E930E00EF57C3 /* CCActionFrame.h in Headers */, 1A8C5992180E930E00EF57C3 /* CCActionFrameEasing.h in Headers */, + 5034CA36191D591100CE6051 /* ccShader_PositionTexture_frag.h in Headers */, + 5034CA56191D591100CE6051 /* CCGLProgramState.h in Headers */, 1A8C5996180E930E00EF57C3 /* CCActionManagerEx.h in Headers */, 2905FA4D18CF08D100240AA3 /* UICheckBox.h in Headers */, 500DC9A519106300007B91BF /* etc1.h in Headers */, @@ -5722,7 +5743,6 @@ 1A8C59EE180E930E00EF57C3 /* CCSkin.h in Headers */, B37510801823ACA100B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */, 500DC94B19106300007B91BF /* CCDirector.h in Headers */, - A023FA35185198C800E10CD1 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */, 50FCEBA218C72017004AD434 /* LayoutReader.h in Headers */, 1A8C59F2180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h in Headers */, 1A8C59F6180E930E00EF57C3 /* CCSSceneReader.h in Headers */, @@ -6119,6 +6139,7 @@ 46A170E81807CECA005B8026 /* CCPhysicsContact.cpp in Sources */, 46A170251807CBFC005B8026 /* CCThread.cpp in Sources */, 1A570061180BC5A10088DEC7 /* CCAction.cpp in Sources */, + 5034CA4F191D591100CE6051 /* ccGLStateCache.cpp in Sources */, 50FCEB9718C72017004AD434 /* CheckBoxReader.cpp in Sources */, 1A570065180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */, 500DC8BE19105D41007B91BF /* CCRenderCommand.cpp in Sources */, @@ -6158,14 +6179,17 @@ 1A57011F180BC90D0088DEC7 /* CCGrid.cpp in Sources */, 50FCEBA718C72017004AD434 /* LoadingBarReader.cpp in Sources */, 06C0F2EF186AD822003594D5 /* ObjectFactory.cpp in Sources */, + 5034CA53191D591100CE6051 /* CCGLProgramStateCache.cpp in Sources */, 500DC96419106300007B91BF /* CCEventListenerAcceleration.cpp in Sources */, 1A57019D180BCB590088DEC7 /* CCFont.cpp in Sources */, 1A5701A1180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */, 1A5701A5180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */, 500DC96819106300007B91BF /* CCEventListenerCustom.cpp in Sources */, 500DC95019106300007B91BF /* CCEventAcceleration.cpp in Sources */, + 5034CA1B191D591100CE6051 /* ccShaders.cpp in Sources */, 1A5701B1180BCB590088DEC7 /* CCFontFNT.cpp in Sources */, 1A5701B5180BCB590088DEC7 /* CCFontFreeType.cpp in Sources */, + 5034CA1F191D591100CE6051 /* CCShaderCache.cpp in Sources */, 1A5701B9180BCB5A0088DEC7 /* CCLabel.cpp in Sources */, 500DC93819106300007B91BF /* CCConfiguration.cpp in Sources */, 500DC9A619106300007B91BF /* s3tc.cpp in Sources */, @@ -6200,8 +6224,6 @@ 50FCEB9B18C72017004AD434 /* ImageViewReader.cpp in Sources */, 500DC9AA19106300007B91BF /* ZipUtils.cpp in Sources */, 1A570234180BCC4D0088DEC7 /* CCScriptSupport.cpp in Sources */, - 1A57026B180BCC6F0088DEC7 /* CCShaderCache.cpp in Sources */, - 1A570271180BCC6F0088DEC7 /* ccShaders.cpp in Sources */, 1A57027E180BCC900088DEC7 /* CCSprite.cpp in Sources */, 1A570282180BCC900088DEC7 /* CCSpriteBatchNode.cpp in Sources */, 1A570286180BCC900088DEC7 /* CCSpriteFrame.cpp in Sources */, @@ -6246,8 +6268,6 @@ 1A57034B180BD09B0088DEC7 /* tinyxml2.cpp in Sources */, 1A570354180BD0B00088DEC7 /* ioapi.cpp in Sources */, 1A570358180BD0B00088DEC7 /* unzip.cpp in Sources */, - 1A570533180BD9500088DEC7 /* CCGLProgram.cpp in Sources */, - 1A570537180BD9500088DEC7 /* ccGLStateCache.cpp in Sources */, 1AD71DA9180E26E600808F54 /* CCBAnimationManager.cpp in Sources */, 500DC95419106300007B91BF /* CCEventCustom.cpp in Sources */, 1AD71DAD180E26E600808F54 /* CCBFileLoader.cpp in Sources */, @@ -6277,6 +6297,7 @@ 1AD71DF7180E26E600808F54 /* CCNodeLoaderLibrary.cpp in Sources */, 1AD71DFD180E26E600808F54 /* CCParticleSystemQuadLoader.cpp in Sources */, 50FCEB9318C72017004AD434 /* ButtonReader.cpp in Sources */, + 5034CA57191D591100CE6051 /* CCGLProgramState.cpp in Sources */, 1AD71E01180E26E600808F54 /* CCScale9SpriteLoader.cpp in Sources */, 1AD71E05180E26E600808F54 /* CCScrollViewLoader.cpp in Sources */, 1AD71E09180E26E600808F54 /* CCSpriteLoader.cpp in Sources */, @@ -6339,6 +6360,7 @@ 1A8C59AF180E930E00EF57C3 /* CCBatchNode.cpp in Sources */, 1A8C59B3180E930E00EF57C3 /* CCBone.cpp in Sources */, 1A8C59B7180E930E00EF57C3 /* CCColliderDetector.cpp in Sources */, + 5034CA5B191D591100CE6051 /* CCGLProgram.cpp in Sources */, 1A8C59BB180E930E00EF57C3 /* CCComAttribute.cpp in Sources */, 1A8C59BF180E930E00EF57C3 /* CCComAudio.cpp in Sources */, 1A8C59C3180E930E00EF57C3 /* CCComController.cpp in Sources */, @@ -6606,6 +6628,7 @@ 1A5701DF180BCB8C0088DEC7 /* CCLayer.cpp in Sources */, 1A5701E3180BCB8C0088DEC7 /* CCScene.cpp in Sources */, 500DC95119106300007B91BF /* CCEventAcceleration.cpp in Sources */, + 5034CA5C191D591100CE6051 /* CCGLProgram.cpp in Sources */, 500DC9B11910633C007B91BF /* CCTouch.cpp in Sources */, 1A5701E7180BCB8C0088DEC7 /* CCTransition.cpp in Sources */, 1A5701EB180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp in Sources */, @@ -6628,8 +6651,6 @@ 2905FA5718CF08D100240AA3 /* UILayout.cpp in Sources */, 2905FA7D18CF08D100240AA3 /* UIText.cpp in Sources */, 50E6D33D18E174130051CA34 /* UIVBox.cpp in Sources */, - 1A57026C180BCC6F0088DEC7 /* CCShaderCache.cpp in Sources */, - 1A570272180BCC6F0088DEC7 /* ccShaders.cpp in Sources */, 1A57027F180BCC900088DEC7 /* CCSprite.cpp in Sources */, 500DC93319106300007B91BF /* CCAutoreleasePool.cpp in Sources */, 1A570283180BCC900088DEC7 /* CCSpriteBatchNode.cpp in Sources */, @@ -6674,9 +6695,7 @@ 1A57034C180BD09B0088DEC7 /* tinyxml2.cpp in Sources */, 1A570355180BD0B00088DEC7 /* ioapi.cpp in Sources */, 1A570359180BD0B00088DEC7 /* unzip.cpp in Sources */, - 1A570534180BD9500088DEC7 /* CCGLProgram.cpp in Sources */, 500DC96519106300007B91BF /* CCEventListenerAcceleration.cpp in Sources */, - 1A570538180BD9500088DEC7 /* ccGLStateCache.cpp in Sources */, 500DC94D19106300007B91BF /* CCEvent.cpp in Sources */, 1AD71DAA180E26E600808F54 /* CCBAnimationManager.cpp in Sources */, 1AD71DAE180E26E600808F54 /* CCBFileLoader.cpp in Sources */, @@ -6701,9 +6720,11 @@ 06CAAAC8186AD7EB0012A414 /* TriggerObj.cpp in Sources */, 1AD71DF0180E26E600808F54 /* CCNode+CCBRelativePositioning.cpp in Sources */, 5027253D190BF1B900AAF4ED /* cocos2d.cpp in Sources */, + 5034CA50191D591100CE6051 /* ccGLStateCache.cpp in Sources */, 1AD71DF4180E26E600808F54 /* CCNodeLoader.cpp in Sources */, 1AD71DF8180E26E600808F54 /* CCNodeLoaderLibrary.cpp in Sources */, 1AD71DFE180E26E600808F54 /* CCParticleSystemQuadLoader.cpp in Sources */, + 5034CA54191D591100CE6051 /* CCGLProgramStateCache.cpp in Sources */, 1AD71E02180E26E600808F54 /* CCScale9SpriteLoader.cpp in Sources */, 1AD71E06180E26E600808F54 /* CCScrollViewLoader.cpp in Sources */, 1AD71E0A180E26E600808F54 /* CCSpriteLoader.cpp in Sources */, @@ -6748,11 +6769,13 @@ 1AAF5377180E3374000584C8 /* WebSocket.cpp in Sources */, 500DC93D19106300007B91BF /* CCConsole.cpp in Sources */, 1AAF5850180E40B9000584C8 /* LocalStorage.cpp in Sources */, + 5034CA58191D591100CE6051 /* CCGLProgramState.cpp in Sources */, 1AAF5854180E40B9000584C8 /* LocalStorageAndroid.cpp in Sources */, 1A9DCA24180E6955007A3AD4 /* ccFPSImages.c in Sources */, 1A9DCA28180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */, 50FCEBA018C72017004AD434 /* LayoutReader.cpp in Sources */, 50E6D33518E174130051CA34 /* UIHBox.cpp in Sources */, + 5034CA1C191D591100CE6051 /* ccShaders.cpp in Sources */, 500DC98F19106300007B91BF /* CCRef.cpp in Sources */, 50FCEBB018C72017004AD434 /* ScrollViewReader.cpp in Sources */, 50FCEBAC18C72017004AD434 /* PageViewReader.cpp in Sources */, @@ -6787,6 +6810,7 @@ 46C02E0818E91123004B7456 /* xxhash.c in Sources */, 500DC95D19106300007B91BF /* CCEventKeyboard.cpp in Sources */, 2905FA4118CF08D100240AA3 /* CocosGUI.cpp in Sources */, + 5034CA20191D591100CE6051 /* CCShaderCache.cpp in Sources */, 1A01C68518F57BE800EFE3A6 /* CCArray.cpp in Sources */, 1A8C59DC180E930E00EF57C3 /* CCDisplayManager.cpp in Sources */, 1A8C59E0180E930E00EF57C3 /* CCInputDelegate.cpp in Sources */, From 88f1d8ac4ec88c400203456bfabf9b4fffc943fe Mon Sep 17 00:00:00 2001 From: Trace Date: Fri, 9 May 2014 11:48:11 -0700 Subject: [PATCH 052/174] Add ShaderTest sample and shader code --- build/cocos2d_tests.xcodeproj/project.pbxproj | 4 + .../Classes/ShaderTest/ShaderTest.cpp | 201 +++++++- .../cpp-tests/Classes/ShaderTest/ShaderTest.h | 60 +++ .../Classes/ShaderTest/ShaderTest.vsh.h | 11 + .../Classes/ShaderTest/shaderTest.psh.h | 474 ++++++++++++++++++ 5 files changed, 748 insertions(+), 2 deletions(-) create mode 100644 tests/cpp-tests/Classes/ShaderTest/ShaderTest.vsh.h create mode 100644 tests/cpp-tests/Classes/ShaderTest/shaderTest.psh.h diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index b54af7d616..b0c5e382e6 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -1852,6 +1852,8 @@ 3EA0FB63191B931500B170C8 /* UIVideoWidgetTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIVideoWidgetTest.h; sourceTree = ""; }; 3EA0FB65191B933000B170C8 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/MediaPlayer.framework; sourceTree = DEVELOPER_DIR; }; 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = cocos2d_libs.xcodeproj; sourceTree = ""; }; + 70A7F72D191D3E4900F0F206 /* shaderTest.psh.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = shaderTest.psh.h; sourceTree = ""; }; + 70A7F730191D421B00F0F206 /* ShaderTest.vsh.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShaderTest.vsh.h; sourceTree = ""; }; A035A71117822E9E00987F6C /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; A07A52291783A1D20073F6A7 /* cpp-tests iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "cpp-tests iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; A07A52B71783AE6D0073F6A7 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; @@ -3092,6 +3094,8 @@ 1AC35AEE18CECF0C00F37B72 /* ShaderTest.h */, 1AC35AEF18CECF0C00F37B72 /* ShaderTest2.cpp */, 1AC35AF018CECF0C00F37B72 /* ShaderTest2.h */, + 70A7F72D191D3E4900F0F206 /* shaderTest.psh.h */, + 70A7F730191D421B00F0F206 /* ShaderTest.vsh.h */, ); path = ShaderTest; sourceTree = ""; diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 820e2701f8..085e53b434 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -1,16 +1,18 @@ #include "ShaderTest.h" #include "../testResource.h" #include "cocos2d.h" +#include "ShaderTest.vsh.h" +#include "shaderTest.psh.h" static int sceneIdx = -1; -#define MAX_LAYER 8 +#define MAX_LAYER 11 static Layer* createShaderLayer(int nIndex) { switch (sceneIdx) { - case 0: return new ShaderMonjori(); + case 0: return new ShaderFalme(); case 1: return new ShaderMandelbrot(); case 2: return new ShaderJulia(); case 3: return new ShaderHeart(); @@ -18,6 +20,9 @@ static Layer* createShaderLayer(int nIndex) case 5: return new ShaderPlasma(); case 6: return new ShaderBlur(); case 7: return new ShaderRetroEffect(); + case 8: return new ShaderMonjori(); + case 9: return new ShaderStarNest(); + case 10: return new ShaderRelentless(); } return NULL; @@ -677,6 +682,198 @@ std::string ShaderRetroEffect::subtitle() const return "sin() effect with moving colors"; } + + +UniformShaderNode::UniformShaderNode() +:_center(Vector2(0.0f, 0.0f)) +,_resolution(Vector2(0.0f, 0.0f)) +,_time(0.0f) +{ + +} + +UniformShaderNode::~UniformShaderNode() +{ + +} + +bool UniformShaderNode::initWithVertex(const char *vert, const char *frag) +{ + +#if CC_ENABLE_CACHE_TEXTURE_DATA + auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ + this->setGLProgram(nullptr); + loadShaderVertex(_vertFileName.c_str(), _fragFileName.c_str()); + }); + + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); +#endif + + loadShaderVertex(vert, frag); + + _time = 0; + auto s = Director::getInstance()->getWinSize(); + _resolution = Vector2(s.width * CC_CONTENT_SCALE_FACTOR(), s.height * CC_CONTENT_SCALE_FACTOR()); + getGLProgramState()->setUniformVec2("resolution", _resolution); + + scheduleUpdate(); + + //setContentSize(Size(getContentSize().width, getContentSize().height)); + setAnchorPoint(Vector2(0.5f, 0.5f)); + + _vertFileName = vert; + _fragFileName = frag; +} + +void UniformShaderNode::loadShaderVertex(const char *vert, const char *frag) +{ + auto shader = GLProgram::createWithByteArrays(vert, frag); + this->setGLProgram(shader); +} + +void UniformShaderNode::update(float dt) +{ + _time += dt; +} + +void UniformShaderNode::setPosition(const Vector2 &newPosition) +{ + Node::setPosition(newPosition); + auto position = getPosition(); +//_center = Vector2(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR()); + // getGLProgramState()->setUniformVec2("center", _center); +} + +void UniformShaderNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) +{ + _customCommand.init(_globalZOrder); + _customCommand.func = CC_CALLBACK_0(UniformShaderNode::onDraw, this, transform, transformUpdated); + renderer->addCommand(&_customCommand); + +} + +UniformShaderNode* UniformShaderNode::shaderNodeWithVertex(const char *vert, const char *frag) +{ + auto node = new UniformShaderNode(); + node->initWithVertex(vert, frag); + node->autorelease(); + + return node; +} + +void UniformShaderNode::onDraw(const Matrix &transform, bool transformUpdated) +{ + float w = getContentSize().width, h = getContentSize().height; + GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h}; + + auto glProgramState = getGLProgramState(); + glProgramState->setVertexAttribPointer("a_position", 2, GL_FLOAT, GL_FALSE, 0, vertices); + glProgramState->apply(transform); + + glDrawArrays(GL_TRIANGLES, 0, 6); + + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,6); + +} + +ShaderRelentless::ShaderRelentless() +{ + init(); +} + +std::string ShaderRelentless::title() const +{ + return "ShaderToy Test"; +} + +std::string ShaderRelentless::subtitle() const +{ + return "Relentless"; +} + +bool ShaderRelentless::init() +{ + if (ShaderTestDemo::init()) + { + auto sn = UniformShaderNode::shaderNodeWithVertex(shadertestvsh, shadertoyRelentlessFrag); + + auto s = Director::getInstance()->getWinSize(); + sn->setPosition(Vector2(s.width/2, s.height/2)); + sn->setContentSize(Size(s.width,s.height)); + addChild(sn); + + return true; + } + + return false; +} + +ShaderStarNest::ShaderStarNest() +{ + init(); +} + +std::string ShaderStarNest::title() const +{ + return "ShaderToy Test"; +} + +std::string ShaderStarNest::subtitle() const +{ + return "Star Nest"; +} + +bool ShaderStarNest::init() +{ + if (ShaderTestDemo::init()) + { + auto sn = UniformShaderNode::shaderNodeWithVertex(shadertestvsh, starNestFrg); + + auto s = Director::getInstance()->getWinSize(); + sn->setPosition(Vector2(s.width/2, s.height/2)); + sn->setContentSize(Size(s.width,s.height)); + addChild(sn); + + return true; + } + + return false; +} + + +ShaderFalme::ShaderFalme() +{ + init(); +} + +std::string ShaderFalme::title() const +{ + return "ShaderToy Test"; +} + +std::string ShaderFalme::subtitle() const +{ + return "Flame"; +} + +bool ShaderFalme::init() +{ + if (ShaderTestDemo::init()) + { + auto sn = UniformShaderNode::shaderNodeWithVertex(shadertestvsh, starFlame); + + auto s = Director::getInstance()->getWinSize(); + sn->setPosition(Vector2(s.width/2, s.height/2)); + sn->setContentSize(Size(s.width,s.height)); + addChild(sn); + + return true; + } + + return false; +} + + ///--------------------------------------- // // ShaderTestScene diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h index c1dea61c66..511e808740 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h @@ -142,6 +142,66 @@ public: virtual void runThisTest(); }; + +class UniformShaderNode : public Node +{ +public: + UniformShaderNode(); + ~UniformShaderNode(); + + bool initWithVertex(const char *vert, const char *frag); + void loadShaderVertex(const char *vert, const char *frag); + + virtual void update(float dt); + virtual void setPosition(const Vector2 &newPosition); + virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; + + static UniformShaderNode* shaderNodeWithVertex(const char *vert, const char *frag); + +protected: + void onDraw(const Matrix &transform, bool transformUpdated); + + Vector2 _center; + Vector2 _resolution; + float _time; + std::string _vertFileName; + std::string _fragFileName; + CustomCommand _customCommand; + +}; + +class ShaderRelentless : public ShaderTestDemo +{ +public: + ShaderRelentless(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + virtual bool init(); +}; + +class ShaderStarNest : public ShaderTestDemo +{ +public: + ShaderStarNest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + virtual bool init(); +}; + +class ShaderFalme : public ShaderTestDemo +{ +public: + ShaderFalme(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + virtual bool init(); +}; + + + //CCLayer* nextAction(); #endif diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.vsh.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.vsh.h new file mode 100644 index 0000000000..e0b6231014 --- /dev/null +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.vsh.h @@ -0,0 +1,11 @@ +#define STRINGIFY(A) #A +static const char* shadertestvsh = R"( + +attribute vec4 a_position; + +void main() +{ + gl_Position = CC_MVPMatrix * a_position; +} + +)"; \ No newline at end of file diff --git a/tests/cpp-tests/Classes/ShaderTest/shaderTest.psh.h b/tests/cpp-tests/Classes/ShaderTest/shaderTest.psh.h new file mode 100644 index 0000000000..e21759b9b8 --- /dev/null +++ b/tests/cpp-tests/Classes/ShaderTest/shaderTest.psh.h @@ -0,0 +1,474 @@ +#define STRINGIFY(A) #A + +static const char* starFlame = STRINGIFY( + + + uniform vec2 center; + uniform vec2 resolution; + + + vec2 iResolution = resolution; // viewport resolution (in pixels) + float iGlobalTime = CC_Time[1]; // shader playback time (in seconds) + //uniform float iChannelTime[4]; // channel playback time (in seconds) + //uniform vec3 iChannelResolution[4]; // channel resolution (in pixels) + vec4 iMouse = vec4(0,0,0,0); // mouse pixel coords. xy: current (if MLB down), zw: click + //uniform sampler2D iChannel0; // input channel. XX = 2D/Cube + + float noise(vec3 p) //Thx to Las^Mercury +{ + vec3 i = floor(p); + vec4 a = dot(i, vec3(1., 57., 21.)) + vec4(0., 57., 21., 78.); + vec3 f = cos((p-i)*acos(-1.))*(-.5)+.5; + a = mix(sin(cos(a)*a),sin(cos(1.+a)*(1.+a)), f.x); + a.xy = mix(a.xz, a.yw, f.y); + return mix(a.x, a.y, f.z); +} + + float sphere(vec3 p, vec4 spr) +{ + return length(spr.xyz-p) - spr.w; +} + + float flame(vec3 p) +{ + float d = sphere(p*vec3(1.,.5,1.), vec4(.0,-1.,.0,1.)); + return d + (noise(p+vec3(.0,iGlobalTime*2.,.0)) + noise(p*3.)*.5)*.25*(p.y) ; +} + + float scene(vec3 p) +{ + return min(100.-length(p) , abs(flame(p)) ); +} + + vec4 raymarch(vec3 org, vec3 dir) +{ + float d = 0.0 ; + float glow = 0.0; + float eps = 0.02; + vec3 p = org; + bool glowed = false; + + for(int i=0; i<64; i++) + { + d = scene(p) + eps; + p += d * dir; + if( d>eps ) + { + if(flame(p) < .0) + glowed=true; + if(glowed) + glow = float(i)/64.; + } + } + return vec4(p,glow); +} + + void main() +{ + vec2 v = -1.0 + (2.0 * gl_FragCoord.xy)/ iResolution.xy; + //vec2 v = 2.0 * gl_FragCoord.xy / iResolution.xy; + v.x *= iResolution.x/iResolution.y; + + vec3 org = vec3(0., -2., 4.); + vec3 dir = normalize(vec3(v.x*1.6, -v.y, -1.5)); + + vec4 p = raymarch(org, dir); + float glow = p.w; + + vec4 col = mix(vec4(1.,.5,.1,1.), vec4(0.1,.5,1.,1.), p.y*.02+.4); + + gl_FragColor = mix(vec4(0.), col, pow(glow*2.,4.)); + //gl_FragColor = col; + //gl_FragColor = mix(vec4(1.), mix(vec4(1.,.5,.1,1.),vec4(0.1,.5,1.,1.),p.y*.02+.4), pow(glow*2.,4.)); + +} + +); + + + + +static const char* starNestFrg = STRINGIFY( + + + + uniform vec2 center; + uniform vec2 resolution; + + vec2 iCenter = center; + vec2 iResolution = resolution; // viewport resolution (in pixels) + float iGlobalTime = CC_Time[1]; // shader playback time (in seconds) + //uniform float iChannelTime[4]; // channel playback time (in seconds) + //uniform vec3 iChannelResolution[4]; // channel resolution (in pixels) + vec4 iMouse = vec4(0,0,0,0); // mouse pixel coords. xy: current (if MLB down), zw: click + //uniform sampler2D iChannel0; // input channel. XX = 2D/Cube + + // Star Nest by Pablo Román Andrioli + + // This content is under the MIT License. + + int iterations = 17; + float formuparam = 0.53; + + int volsteps = 20; + float stepsize = 0.1; + + float zoom = 0.800; + float tile = 0.850; + float speed = 0.010; + + float brightness = 0.0015; + float darkmatter = 0.300; + float distfading = 0.730; + float saturation = 0.850; + + +void main(void) +{ + // iCenter = vec2(300, 300); + //get coords and direction + vec2 uv=gl_FragCoord.xy/iResolution.xy -.5; + //vec2 uv=gl_FragCoord.xy/iResolution.xy ; + //vec2 uv = ( 2* gl_FragCoord.xy - iCenter.xy) / resolution.xy; + uv.y*=iResolution.y/iResolution.x; + + //vec2 uv = 2.0* (gl_FragCoord.xy-iResolution.xy)/min(iResolution.y,iResolution.x); + + vec3 dir=vec3(uv*zoom,1.); + float time=iGlobalTime*speed+.25; + + //mouse rotation + float a1=.5+iMouse.x/iResolution.x*2.; + float a2=.8+iMouse.y/iResolution.y*2.; + mat2 rot1=mat2(cos(a1),sin(a1),-sin(a1),cos(a1)); + mat2 rot2=mat2(cos(a2),sin(a2),-sin(a2),cos(a2)); + dir.xz*=rot1; + dir.xy*=rot2; + vec3 from=vec3(1.,.5,0.5); + from+=vec3(time*2.,time,-2.); + from.xz*=rot1; + from.xy*=rot2; + + //volumetric rendering + float s=0.1; + float fade=1.; + vec3 v=vec3(0.); + for (int r=0; r6) fade*=1.-dm; // dark matter, don't render near + //v+=vec3(dm,dm*.5,0.); + v+=fade; + v+=vec3(s,s*s,s*s*s*s)*a*brightness*fade; // coloring based on distance + fade*=distfading; // distance fading + s+=stepsize; + } + v=mix(vec3(length(v)),v,saturation); //color adjust + gl_FragColor = vec4(v*.01,1.); + +} +); + + +static const char* shadertoyRelentlessFrag = STRINGIFY( + + +uniform vec2 center; +uniform vec2 resolution; + +vec2 iCenter = center; +vec2 iResolution = resolution; // viewport resolution (in pixels) +float iGlobalTime = CC_Time[1]; // shader playback time (in seconds) + //uniform float iChannelTime[4]; // channel playback time (in seconds) +//uniform vec3 iChannelResolution[4]; // channel resolution (in pixels) + +vec4 iMouse = vec4(0,0,0,0); // mouse pixel coords. xy: current (if MLB down), zw: click +//uniform sampler2D iChannel0; // input channel. XX = 2D/Cube + +// srtuss, 2013 +// collecting some design ideas for a new game project. +// no raymarching is used. + +// if i could add a custom soundtrack, it'd use this one (essential for desired sensation) +// http://www.youtube.com/watch?v=1uFAu65tZpo + + +//#define GREEN_VERSION + +// ** improved camera shaking +// ** cleaned up code +// ** added stuff to the gates + + + +float time = iGlobalTime; + +vec2 rotate(vec2 p, float a) +{ + return vec2(p.x * cos(a) - p.y * sin(a), p.x * sin(a) + p.y * cos(a)); +} + float box(vec2 p, vec2 b, float r) +{ + return length(max(abs(p) - b, 0.0)) - r; +} + +// iq's ray-plane-intersection code +vec3 intersect(in vec3 o, in vec3 d, vec3 c, vec3 u, vec3 v) +{ + vec3 q = o - c; + return vec3( + dot(cross(u, v), q), + dot(cross(q, u), d), + dot(cross(v, q), d)) / dot(cross(v, u), d); +} + +// some noise functions for fast developing +float rand11(float p) +{ + return fract(sin(p * 591.32) * 43758.5357); +} + +float rand12(vec2 p) +{ + return fract(sin(dot(p.xy, vec2(12.9898, 78.233))) * 43758.5357); +} + +vec2 rand21(float p) +{ + return fract(vec2(sin(p * 591.32), cos(p * 391.32))); +} + +vec2 rand22(in vec2 p) +{ + return fract(vec2(sin(p.x * 591.32 + p.y * 154.077), cos(p.x * 391.32 + p.y * 49.077))); +} + + +float noise11(float p) +{ + float fl = floor(p); + return mix(rand11(fl), rand11(fl + 1.0), fract(p));//smoothstep(0.0, 1.0, fract(p))); +} + +float fbm11(float p) +{ + return noise11(p) * 0.5 + noise11(p * 2.0) * 0.25 + noise11(p * 5.0) * 0.125; +} + +vec3 noise31(float p) +{ + return vec3(noise11(p), noise11(p + 18.952), noise11(p - 11.372)) * 2.0 - 1.0; +} + +// something that looks a bit like godrays coming from the surface +float sky(vec3 p) +{ + float a = atan(p.x, p.z); + float t = time * 0.1; + float v = rand11(floor(a * 4.0 + t)) * 0.5 + rand11(floor(a * 8.0 - t)) * 0.25 + rand11(floor(a * 16.0 + t)) * 0.125; + return v; +} + +vec3 voronoi(in vec2 x) +{ + vec2 n = floor(x); // grid cell id + vec2 f = fract(x); // grid internal position + vec2 mg; // shortest distance... + vec2 mr; // ..and second shortest distance + float md = 8.0; + float md2 = 8.0; + for(int j = -1; j <= 1; j ++) + { + for(int i = -1; i <= 1; i ++) + { + vec2 g = vec2(float(i), float(j)); // cell id + vec2 o = rand22(n + g); // offset to edge point + vec2 r = g + o - f; + + float d = max(abs(r.x), abs(r.y)); // distance to the edge + + if(d < md) + {md2 = md; md = d; mr = r; mg = g;} + else if(d < md2) + {md2 = d;} + } + } + return vec3(n + mg, md2 - md); +} + +//#define A2V(a) vec2(sin((a) * 6.28318531 / 100.0), cos((a) * 6.28318531 / 100.0)) +vec2 A2V(float a) +{ + return vec2(sin((a) * 6.28318531 / 100.0), cos((a) * 6.28318531 / 100.0)); +} + + + +float circles(vec2 p) +{ + float v; + float w; + float l; + float c; + vec2 pp; + l = length(p); + + + pp = rotate(p, time * 3.0); + c = max(dot(pp, normalize(vec2(-0.2, 0.5))), -dot(pp, normalize(vec2(0.2, 0.5)))); + c = min(c, max(dot(pp, normalize(vec2(0.5, -0.5))), -dot(pp, normalize(vec2(0.2, -0.5))))); + c = min(c, max(dot(pp, normalize(vec2(0.3, 0.5))), -dot(pp, normalize(vec2(0.2, 0.5))))); + + // innerest stuff + v = abs(l - 0.5) - 0.03; + v = max(v, -c); + v = min(v, abs(l - 0.54) - 0.02); + v = min(v, abs(l - 0.64) - 0.05); + + pp = rotate(p, time * -1.333); + c = max(dot(pp, A2V(-5.0)), -dot(pp, A2V(5.0))); + c = min(c, max(dot(pp, A2V(25.0 - 5.0)), -dot(pp, A2V(25.0 + 5.0)))); + c = min(c, max(dot(pp, A2V(50.0 - 5.0)), -dot(pp, A2V(50.0 + 5.0)))); + c = min(c, max(dot(pp, A2V(75.0 - 5.0)), -dot(pp, A2V(75.0 + 5.0)))); + + w = abs(l - 0.83) - 0.09; + v = min(v, max(w, c)); + + return v; +} + +float shade1(float d) +{ + float v = 1.0 - smoothstep(0.0, mix(0.012, 0.2, 0.0), d); + float g = exp(d * -20.0); + return v + g * 0.5; +} + +void main(void) +{ + vec2 uv = gl_FragCoord.xy / iResolution.xy; + uv = uv * 2.0 - 1.0; + uv.x *= iResolution.x / iResolution.y; + + + // using an iq styled camera this time :) + // ray origin + vec3 ro = 0.7 * vec3(cos(0.2 * time), 0.0, sin(0.2 * time)); + ro.y = cos(0.6 * time) * 0.3 + 0.65; + // camera look at + vec3 ta = vec3(0.0, 0.2, 0.0); + + // camera shake intensity + float shake = clamp(3.0 * (1.0 - length(ro.yz)), 0.3, 1.0); + float st = mod(time, 10.0) * 143.0; + + // build camera matrix + vec3 ww = normalize(ta - ro + noise31(st) * shake * 0.01); + vec3 uu = normalize(cross(ww, normalize(vec3(0.0, 1.0, 0.2 * sin(time))))); + vec3 vv = normalize(cross(uu, ww)); + // obtain ray direction + vec3 rd = normalize(uv.x * uu + uv.y * vv + 1.0 * ww); + + // shaking and movement + ro += noise31(-st) * shake * 0.015; + ro.x += time * 2.0; + + float inten = 0.0; + + // background + float sd = dot(rd, vec3(0.0, 1.0, 0.0)); + inten = pow(1.0 - abs(sd), 20.0) + pow(sky(rd), 5.0) * step(0.0, rd.y) * 0.2; + + vec3 its; + float v; + float g; + + // voronoi floor layers + for(int i = 0; i < 4; i ++) + { + float layer = float(i); + its = intersect(ro, rd, vec3(0.0, -5.0 - layer * 5.0, 0.0), vec3(1.0, 0.0, 0.0), vec3(0.0, 0.0, 1.0)); + if(its.x > 0.0) + { + vec3 vo = voronoi((its.yz) * 0.05 + 8.0 * rand21(float(i))); + v = exp(-100.0 * (vo.z - 0.02)); + + float fx = 0.0; + + // add some special fx to lowest layer + if(i == 3) + { + float crd = 0.0;//fract(time * 0.2) * 50.0 - 25.0; + float fxi = cos(vo.x * 0.2 + time * 1.5);//abs(crd - vo.x); + fx = clamp(smoothstep(0.9, 1.0, fxi), 0.0, 0.9) * 1.0 * rand12(vo.xy); + fx *= exp(-3.0 * vo.z) * 2.0; + } + inten += v * 0.1 + fx; + } + } + + // draw the gates, 4 should be enough + float gatex = floor(ro.x / 8.0 + 0.5) * 8.0 + 4.0; + float go = -16.0; + for(int i = 0; i < 4; i ++) + { + its = intersect(ro, rd, vec3(gatex + go, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0)); + if(dot(its.yz, its.yz) < 2.0 && its.x > 0.0) + { + v = circles(its.yz); + inten += shade1(v); + } + + go += 8.0; + } + + // draw the stream + for(int j = 0; j < 20; j ++) + { + float id = float(j); + + vec3 bp = vec3(0.0, (rand11(id) * 2.0 - 1.0) * 0.25, 0.0); + vec3 its = intersect(ro, rd, bp, vec3(1.0, 0.0, 0.0), vec3(0.0, 0.0, 1.0)); + + if(its.x > 0.0) + { + vec2 pp = its.yz; + float spd = (1.0 + rand11(id) * 3.0) * 2.5; + pp.y += time * spd; + pp += (rand21(id) * 2.0 - 1.0) * vec2(0.3, 1.0); + float rep = rand11(id) + 1.5; + pp.y = mod(pp.y, rep * 2.0) - rep; + float d = box(pp, vec2(0.02, 0.3), 0.1); + float foc = 0.0; + float v = 1.0 - smoothstep(0.0, 0.03, abs(d) - 0.001); + float g = min(exp(d * -20.0), 2.0); + + inten += (v + g * 0.7) * 0.5; + + } + } + + inten *= 0.4 + (sin(time) * 0.5 + 0.5) * 0.6; + + // find a color for the computed intensity +#ifdef GREEN_VERSION + vec3 col = pow(vec3(inten), vec3(2.0, 0.15, 9.0)); +#else + vec3 col = pow(vec3(inten), 1.5 * vec3(0.15, 2.0, 9.0)); +#endif + + gl_FragColor = vec4(col, 1.0); +} + + +); \ No newline at end of file From 168ff78e181ea9e120a03c617244629efc4e9a23 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 9 May 2014 11:49:51 -0700 Subject: [PATCH 053/174] add test case for y flipped coord --- .../Classes/ParticleTest/ParticleTest.cpp | 32 ++--- .../Resources/Particles/ButterFly.plist | 120 ++++++++++++++++++ .../Particles/ButterFlyYFlipped.plist | 120 ++++++++++++++++++ 3 files changed, 257 insertions(+), 15 deletions(-) create mode 100644 tests/cpp-tests/Resources/Particles/ButterFly.plist create mode 100644 tests/cpp-tests/Resources/Particles/ButterFlyYFlipped.plist diff --git a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp index 8f5f82b743..570c7fa72b 100644 --- a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp +++ b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp @@ -995,28 +995,30 @@ Layer* createParticleLayer(int nIndex) case 30: return new DemoParticleFromFile("Galaxy"); case 31: return new DemoParticleFromFile("Phoenix"); case 32: return new DemoParticleFromFile("lines"); - case 33: return new RadiusMode1(); - case 34: return new RadiusMode2(); - case 35: return new Issue704(); - case 36: return new Issue870(); - case 37: return new Issue1201(); + case 33: return new DemoParticleFromFile("ButterFly"); + case 34: return new DemoParticleFromFile("ButterFlyYFlipped"); + case 35: return new RadiusMode1(); + case 36: return new RadiusMode2(); + case 37: return new Issue704(); + case 38: return new Issue870(); + case 39: return new Issue1201(); // v1.1 tests - case 38: return new MultipleParticleSystems(); - case 39: return new MultipleParticleSystemsBatched(); - case 40: return new AddAndDeleteParticleSystems(); - case 41: return new ReorderParticleSystems(); - case 42: return new PremultipliedAlphaTest(); - case 43: return new PremultipliedAlphaTest2(); - case 44: return new Issue3990(); - case 45: return new ParticleAutoBatching(); - case 46: return new ParticleVisibleTest(); + case 40: return new MultipleParticleSystems(); + case 41: return new MultipleParticleSystemsBatched(); + case 42: return new AddAndDeleteParticleSystems(); + case 43: return new ReorderParticleSystems(); + case 44: return new PremultipliedAlphaTest(); + case 45: return new PremultipliedAlphaTest2(); + case 46: return new Issue3990(); + case 47: return new ParticleAutoBatching(); + case 48: return new ParticleVisibleTest(); default: break; } return NULL; } -#define MAX_LAYER 47 +#define MAX_LAYER 49 Layer* nextParticleAction() diff --git a/tests/cpp-tests/Resources/Particles/ButterFly.plist b/tests/cpp-tests/Resources/Particles/ButterFly.plist new file mode 100644 index 0000000000..30482d6642 --- /dev/null +++ b/tests/cpp-tests/Resources/Particles/ButterFly.plist @@ -0,0 +1,120 @@ + + + + + absolutePosition + + angle + 0 + angleVariance + 360 + blendFuncDestination + 771 + blendFuncSource + 770 + configName + ButterFly + duration + -1 + emitterType + 0 + finishColorAlpha + 1 + finishColorBlue + 1 + finishColorGreen + 1 + finishColorRed + 0.9999960064888 + finishColorVarianceAlpha + 0 + finishColorVarianceBlue + 1 + finishColorVarianceGreen + 1 + finishColorVarianceRed + 1 + finishParticleSize + 64 + finishParticleSizeVariance + 0 + gravityx + 0 + gravityy + 434.2099914550781 + maxParticles + 197 + maxRadius + 100 + maxRadiusVariance + 0 + minRadius + 0 + minRadiusVariance + 0 + particleLifespan + 10 + particleLifespanVariance + 0 + positionType + 0 + radialAccelVariance + 13.16 + radialAcceleration + 144.74 + rotatePerSecond + 0 + rotatePerSecondVariance + 0 + rotationEnd + 0 + rotationEndVariance + 0 + rotationStart + 0 + rotationStartVariance + 0 + sourcePositionVariancex + 167 + sourcePositionVariancey + 7 + sourcePositionx + 160 + sourcePositiony + 240 + speed + 46.05 + speedVariance + 0 + startColorAlpha + 1 + startColorBlue + 1 + startColorGreen + 1 + startColorRed + 0.9999960064888 + startColorVarianceAlpha + 0 + startColorVarianceBlue + 1 + startColorVarianceGreen + 1 + startColorVarianceRed + 1 + startParticleSize + 64 + startParticleSizeVariance + 11.37 + tangentialAccelVariance + 0 + tangentialAcceleration + -92.11000061035156 + textureFileName + Untitled 2.png + textureImageData + H4sIAAAAAAAAA9V7B3xVVbb+ub33knvTe++9QioJIQESQhJCDUkIoSWkkdBCQhJIAFEUpCgqOiLigCIioiIivXedsYw+n+M448zozDiOpHz/tc8NjE5TfDPv/f6X3+HunHvO2Xutvda3vrX2PoWFXDDHpctXrVrF/aujY9UqQVdnJ9fT3UN/dwhWrlwp/r57/veODq6DxtPT3c319fdzlbMrR00sKpq5Zk0vt7JjpXBk/P+T5ws6uzq5pUuXqufNmxfa00P99PWx86KOjg7h/7H8AhqDaM2atdy8+YvsEZFROziOAzumTZuav2bNGqYb0arOH9/HypUrxGtJ3sTEpPvZc93cPV4rn1KR0bl6Nbe6ezXnsIXO/125SR6m+0767u3t5crLJs8uzUv6k5ezEd6u1gE2TolU9uslS5aYVnd1cT92nth93WRXLS0tFolE+qVUIoJGIUViqBcm5GftaWpuNjAd8zr4H+j4Xo7OkXF1kVzMNv38/A4yed1tJgR4Od/OTAiBQaf+xqiVIyw8/LG1a8kGOn6cv9J9wp6eXi46KvIp1oerk+l2SW7CoK+HbVAlFZGdCb6cPbsyndnHipUrJf8b8jMs6iQsWr26iwsKCuBlLypIHbDbzMN3bL+6fMxAekIQ/PyDdq5fv4634c577quD74fkEtht1vcbKsfB19M+dKePosJRt416NWsP8zpY28fs4D+uAzb3vT1ruJi4uAfZOOJiAr459frGYS83KxbPK0agnzs/Jh8PO/R6/S+WLGk1dvE+sEpwj/0IVpOPNzQ0uGvU6t9GBntDIBAMzZ42FvExAVjVNg07tzQO3NHH7KqqOIZDzBfuXdc/7GD6ZXoeX5C/nNl3XIjHgLubE4JCfKCjudi6YQ4MBseceLraIJVK/7S4cbFbN8lB998TBjCfWbt2LVdUVFQhFgnh5+U6yOScXpqOmpk5vMyhYb6ICnIfTI/1QbCPy59bmxcHre7uJsztEP0nZGdYU1U1O82oVSIlwhPZSYG8zZcm2jE6xIkfk1atwIaOWUNmo5p0YXyHMFLAYwbZ8z3Ov5DN/9L2NiM99zeRIZ4oLUzh7d+qU6Iu2wNhLgqIpRLEh7oPKAkP3FxdrjCfWcVs7R7t7YeMZfnypSqlWvPRiM0NqanPJ8vdca7RH6kBJl5+D2cTWueOR7Cv26CviwWjR6cv66N5vEcMZBxHxLBz9OjRq21GDQqzYgZ6W8v4PjiBEKsK3XGl3huTg3UYGc837Ds6Nv7+9ev6uX8nR3L4fA8XFBb5qEkhgkgsHtArxNg9zgk/LbQgyKJAjKsWk2Jd74wFUaHeA3FhXkgbld7W33/v42HXM54TFxf78KjYQLIrJe/rziY1psU7w6qWIddLiZOlVjTFGXmfS/A0DXvoZZg4qXTCWsa//g06YHa/jsafk184K9YqQl2q+21OIMDjuU44PM6IEIsSSxNNeK/OFc9Wh8Nk1GJ6WToKcuKG4iJ8YLY4nekmzsbbf8cPn3/2zfzGw9391LSiNFQUjx6Kjg5AWpANH7aH4/ViAxLsSswI0uBKmQ0zQnSwapVDa3PdYFTL/9C6pE3HYtS9+t3fjoPx7rb2pRq9TvvJqmwXeBoVQ0sTDDhWZEW6qxobk/R4t1iLrVk6pPvpkZUSguceb4HRqBuQSYWEUWG7HDyQ50A/eCzMj5ctX6agGPLfDP9Gp4QOP7ezGXajCpPD9Nifq8W7JSYsDNdjZpAaJ0kHhb5qZAWYbqe4KxGTkNLN5m3Fih8ZE4lPMU7B4ndickqvTsIh3N1we2KAGmdnOKPMX4WHRpnx8lgrkq0SBDhp4WdRQS6TQiqRIDbSb6C5bjyio2M3/Bj7ZxjOcoig4KD9yxtK4GwzDei1apjUciR7m6CSijHJS4WD4+x4KNOK1TSWI9Nd4W5UDOtVCh6XZ8+encpiyI/xgzvcs76+3ksulX7l8GvBcEOaBRMIcx4tdENHkhl2jQJOKjni3QyYm+IJLzcTZpSkQKVQDFpNGvj7+7/IOPLKjnuKSQKWN7B8Lzgo8LC3uxUudtNAzdR0xPlaUB7jCjeNHInOOrhpZViVZkNpuAluBjkSfHSw6eWDcomQxYOLDll4u7snP2A66yf8CQ+PeMKqlyDSW3t7bo4zxXQxPMjn/QnzSB9ojzThdKEnfA0qHveSItyxZsl4qJXKgczkcERGRT12Nw+6R/2zWB4cFPBGGnFqk1Ez+MCqSTDpFXw/DZHOuDrBA+kuGkfcJTxO8dNhXLQR2+d4IcLPfNvVJMGEopIiFg/uhR8z3t3b28PNmTsvwNmsgJ+HHrU5VjQU2FE7yoTyBAvfJ4u5TZEW1AUYIBOL+HOJ4a6YVRTL2jxe5+blLdiwYQP54QrpvchP14uZ36SljeoS0HNEItHg1MJomCj2s+ea5BJU+BkQYHToQ0oYsavGC/mROoxPNEOrlAwXZdhgNmh/tbixycri96qO78fgjhHdM9vz8vZ+dXyakWKPdFBN+nUxKbBkvDM8zDK+T6GAG4l3ApgUElhUjvNm4oAa8sEJYxMR4OfxeU3NnGCWt//gPJDstYuwu7m5VR0XHXoze1QE4YpkiD1XIhQS7mvhz9uB8Dvj8HdWwdemuBuDkyINt2eM0yEmNmn9hg3rR+bgX+fKjHf09a3hSkpnjM5P02JKvpVxrru5jUAovPt8JneGhxoPUvx7IVGHA3nOCCTfWNdWhKKcSESF+91m12Xn5M67Fwx0jKGPG1dQMEMs4hAZ5jvQMCsLjdXZyCDOd3GcFa8na7Ar3YjSMAM/jr+OiYNYdPfv4dWL3ZAUrRkqLZ+d2N/HcuXvwSHCqe7VvVxIkPfRVQ1WmI1y3o5FQnqm4K+6Nqgk6Mgy4ESxCucyRLiQKMStiWaMDzbDw81C/i9lOhuMCfdF3pjstQwDGQb8kNyEcQ4mf17emLbwIE/elwyEdxazDjMjzLiUp8O5VCEu5ApxcaoS/QU6qOQO/5OMyK5WiZAar0NyrHZgGcnh7uZ8qcMx94IRTvB3eMgwYt26Pm50en7NxHwNppZYB2eVGjG5wPgdO1PIRNhUpsWNeRJcKhPhZIEC2xM1yCdbEIrE/DUxod6IC/cdSksIJR3qv2xqajbzfOT7eDn5KNMRxQvO2W67lkr3R4Z4DUY69AABPT/HXYPuWC1eyFdRLJbgRrMUG8rVMGslI/Mvgr+XGhdf8RlumW9G+WTn2xlpCuTkFM5cv57Z4QrJ39ZL7uSbra1tGnd3/a+nV9jI7tRDr+51R321Dd7ulNcR79OpRXhojg43upQ4UK1CY5IKY301SPXQIsdThdp4G+QSEeVrzoRV6rs4WDFlSjHLTzu+xwdY3O8hW5lbWxsncmDqkEopY/Gfj2+r050wN5zygQAdUr01yA1QYn2JBmfX6LB7hQ0ahRDRYTrU1zgjOU6DmAgVxGLhUEyUjjiZ4YOlS5eqGLf67jx0Mr8gvr2WS8/IajGbhHBxUfK+G0R8Z9liC9at9IBWI8H6xXb8tMOC6mwtAghvMoLVWE3tE+UGXJioxJUK6jvVys+DXqtifHggPMQPcbExB7pIvx3fwwMYRrB6zvjCwoXeHnbqUzVgtzpyq3X5FPMmK3C5SIrzU9X46XQd5mToEB+goUON+ZOMaJ7tDFe7HC/ttuHBdXp4ejgwWa6Q3nbEo9ymdevWfyce8vXlri6ura3NoFQqfsvHE4l02MNdjv4eHW6eMSMnQ4nwQB1Kx5rh4ypHfqIKO+frcbFNjct1Ypwo5XB6AocrpVLsn+FF/EdKOEDzoVbwOaubi/2jpcuWS7u6mA/+U04uYDypt3cNFx8X+yQ/bpl0wMlsgJ5iy3PTPHC9QoELk4U4M12A8wuEuLpKjpP9OiyfpUZ+uhqJ0XoIOAmWtejxzhUljh/VobxMB71OyWO4Wq1/l9WS+Tx5BAMcudZarrBwQiWPIRLpQP5YE14+aMDFMxIcPqCH1SKFp5sMXc1mvPCABpe3K3CuT4jTSzlcbJLgXK0KL0zS4P4xRsoF1XexOCbCfzg00GvYbjVi1qzKeL5e+c9sYISnsRjs7eV5ydVuQWpC2OCdZ/mYlagI02J9jhYHK7U406bExTVinLmfw9UnRbj6vBIv7jIgPFQBHx853npDg3OnaE4ualAwjvEG8YCHuxglJaXFa/vW8nU5Zo8sN+/pWcMlJYUecHISQSYTDuz+iRoXzghxnuRvbzXSOTH2PWnE1SNSnN4twNmdQlzepsDBZVrUjyG9Uy7qYpAhkmTP8lMj2ddhs67OFug0al6GWbNmZo7Ua/+ZD9zJ+wRGk+kaz+s0qiGWT0xJdMWiVCNy/VRI9NHATliQFaZG13QtDt+vxfk9FBdfFOLacSH2Pa3jMXD5Uj2uXiRfOc3h+BtqxMepB8soX46NDXmhp3sN60/YTXk943ozZ9aGjhplHEofbcbK5arhqxfFOHmcw9EjJlitMkyZLMeNczJceI30vV+Dh1fqkZuggpVk9nSSY1aaHjtL9ThFdnihWouzreGozAq5YwdDjjWBabnfJz+zS7IPobOz860791blhOHq8mhcIby9VqPAibk6bJ6mR1GSBu7k696uCkweqyGM0uLlfSrcvKxH9WwtdDopXjlk4ufxxhUxtm3RDgcG6oYNBhFmzpqdSHPPTZs6tfg+4qeRkdHb/HzpOSXGgQtnVTjxJtn1OTUqCNfcXGV46YANe3+ix7xqwpsoDUL8lchMUGLDfB3e6NThyjLyy7lCnJrG4eQ0Ic7Ve+KF9lzoNSryJ/EA2TGKi4rmrFnL7P8fxwCGQyxGLlnSJssalfABcVde/q1zR5GP+eHkdIq19PzTtQJcWibGpQ0KvPmQFpvIBssnqhAfq2YxCxMn6NDcaINSKUFqCsXIkzo6yEcuKjGlzMDHo/DwsKdKSoof9/Rwx4zp09rMZuPP1SoptjyoH75wltm9FGt7jTy3iozUIJu4jp+fEkkJcqxsVeO13Vpc2UtYvEOM070CnGzhcKpOgNOzBDg1U4TTC+w4sjSLsJL3gwGRkMOkSZOmsHz0X8RAmv8ubtnSpUqdXvepI5aLh7bOSSb5vXGqkvqqpD4I906103c/h7M7yL/3i3DzTRlOHNFg5zbiSNNJDxFq8lkHH2ioJxs4q8S1y2Ks71MPqyiH1moVX0VGRPzBx8cLrq5uX7m6ar+OoFh5+KAS58+KsGc38X6Ng8v4EpbUL9Bg7zManDmuxNWTNI4XSeaf0FxvJbn7SOal9PcCaldzOEFjPNfohmcXpzHezuOuQqH4vKWlhc9DKPb+0zyAbEPEfCQpMem+Efsf6KqIJ/sPwalaKU7NoT4WUb/L6dhA7Ueo32fpeIkw6RjZBY39xhUp+a4avd16ksHBC7tX63HjqhQHn1cOj8kyka1Y/6DXW37p7OxE8rveSEl0GphTrSdfkeG1w1qkJjswvGyyGsde1+DaJQnZBMWdt6jf16i/gyTnM9Q/6f/MBup7FfXdJsJligWXW4gLrIrBOMrTne3W21kpofDy8nmxv7/ve2vTHXzdcy03pWJaSmyYD/Iz44csWjkemxuDs+0euNSupZhHPGOdHFe3S3HlGTHOHxDiLI3pzDEaywk6CPPPn+Fw86oEmx/QQk7cWEPchcWzy2cVmDFFjzDiTwaDAf5+vjCbNRQ3TcOrV2pwk2JmY4OBl318oRJHX6U4R/jJsPD0Ccfzzx0X4PIxCa68pMSpxzV4heLvT9v02Falw/opRrQUuGBUCM+BhoP93BBNXLh40qQJax3873vyD56Lirop/8zOztho0PL53ICMOGU4cczRxLfGRqkxM1uPhSV6dNfrsXebEW+8RP54jrDvqozmiubhPM0J6eHcaeLq9+uIl4uQn6fBB5cNaKpRwqJTwWbVw+Zkg0mvGrab5Nj7sBbPP22AQCDCOOLWL+wn+Wi+GX5euyzB9ctykl+LF/cZsKpdj7LxOkQGqeDprISfmwoediWCvYysHk++J2PrNTzWpKaObu3vu4caGKs9MS5OOOjj5fZLjVoJg04zuHhqKhrLQjEr14ICwv4IfwWcKDZZLQrYKQ6kj1ajucmAHdv0OPC8juZLw4/5BulkxzYtrE6Eb51m7Os3QUdYp1BSTmUxQyGXw8tO+PGoBfkZamQQ1zt5XINL5+UkvwbP7jZgWTtxvxItggJVZC9yuND1YUFSTCfO2z9fg8dbNHi5xxtvPZiLR5YVUkwyD2k1CowZHYOl7W1mfr30X/j93/tBh5jZQNXMKWutJseaUnyw6/D21lTc3BmGi5s1OLGVeO42JbavV2DJYiVhtAw2uwQmkww6rQwBAXLMmEbx4X6Ky8eNePoxO9JitNi3wpVsSQaJXA27k5meTfwilXgV5TkFuQYcPWzH1i1a1NboKU4o4UTx3dVFhlGUQ1VXqbChX4lXX1DizEE5Lj0nxeXHxbixU4cX1oSgMJXP03jMU6mUX5aUTJq5gtl8hyO+/WD5KR+jQ8xy1qys7EaWSzvbDJQHGYYrcpzx8npXnH5UhfPPER6/rsL1s1qyUQNhtwGHDurw0CYd2lr1GDdOhYR4FeGYHsubLCwfRpyPFmWpdqg0espPDMSJ1ciLMvP1rPFjDJg11YAcymkqpuiIC+nx+KNGvHmUuPA5A86dMeLVwwbiWFo89wgdmwx4vMOI1uk26NVihAY6Y8rEeGb7xDEqU7Zs3sytZfW/jpH9Gj9gnZ7JzmLhapp/4gKaylmVozmh9BfxkR7ITQ8ecvBCKQI85cigPCQ/S4OkeDkyM1WYNVNNcmtJfjMe2GjC5gcpd+uzYWmbHfVzKCeMNPDcUCYVw6DXURzU8jrg19WMxH9y7airstEz7FjSYkb9Qj1q5+gxbaqWMIF4T7AcdpuMzwXlcjH5uehuHYqvfZm09FwV+ZR02G63XQ8LC3tqcmlZFqunMZ/+Z9xn1UgeyuIDqzv3EC8tL5s8x9lm+R17bny4L29X4d4GxPlp4W6Wkr4ld2s/Ko3mW3UgAVRKMfR6EXFXEWGDEB4eYgQHUl7grgSr5fG5EN1jNpmgVChH6nYyuDjJEOgvRVSkBGGhInh4CukZQuKSIrB1CEcNQkr5hYlyOzH5uRQTU7SYmaFFU6EJ/ZXBMNPchIf6IiGKHzMm5CUhNiZ6T2trq47F9hX/cI2607GvgnS0pK1d5Ont+0RYoCeyR8eSLXGDUeH+wxkRrjjVE4tTy604RnHwEPG+R5q16KnTYPEsE0YT13NxkcDZWYJRo5SoqdJSLNMS/9GhabEB8+sshA+O+mBCpIn5EnR6A8UBLSKCHOuIfr4aut6ChkUGzJurxQLKcSumaJGUqISPt5z3i4XE77d36HBkow5nNmpwsUeBqytluLJchRvdPti9OAHBHhZWKxwSCoUDYcE+fP6jVKo+rqqqieLXJFZ81w74egTb77BiJTdxXPpxo57V0wXf6LUq3t6zo7xxvDMLN1d64doS4iNtclzpoHi3QY1bO4gTUNw6c9COzhXOcHNTYvIkPRbM06KqknxihpryATXZsx6dHTakJLF1Khvl5OT7hAEernrEhJoQG00Y2G/D8mUa1C9Ske2ryW/UWNujw9xaA+GpGosXWfHSLite3WzES11aHGjW4MBCyjvmafAG6ezEYjvNTwI212VCq5SxvTCICOEx8XbZxFTUzhj7+/LyijTHmvBfuRDDRmbzoSHB+9sXFMPdzekbZ6uB8CiBn5dgTxsmJ3mgZpQNxdE65IZpkOxPsYq+00LUGEPxMJDmx99PjueeseD6FTVuXpPh1nUJH7vf/znFwSs6dHVYEENyBgdS7uSmI4zWkR50xOtNiIjQkI6MuHheg/d/JgPLAa9dprz6EuH7VQVxYxM8PWVQEK+OCdYg2leJxAANglxVfO053F2DYMp/XUzM/x11FzHxgKy0KL5tsRhuhwW5MTv4pL2tTd85sofoDuctLp5U5thDoBx0s42sp5NthrkZEGxTYZSvDtnU3+RIFealKrE8T42NFXrsarBiQbEV/p5q7NpiwLWLMp6rsePiOcaH1dixVY/xBWQPs43o63UlfJCQTysoVhoIA+V8jFvT7YLKGXqUUqy4b52OuBOrAVAeTLkgOy5S+2XiAimkv4ZSJxxZ5YQ3l5E9zDfgqWkabC5WY12BAW2ZhJtpdtSmuqIhxw9RHka2Zo7yvHjIpVJ+nT4nZ8xiVuNlnIhhIqv5jE5NeoLVeaODPG/XlWciI8QZz8+Lw1sLQnCi1geXF7jjZw0WvEd2/PYSI05QPHtktglzx+pRlW/Gc8Rrrh6S4vRRjriLkGxAhaefNKC8TI9Ckn37wxq8c9OJYoSZfNpC/NY4LJfrUV5qJn8xE77rcOmCBS8+Tz5frkNeLt2z1cjXTy6do5znddLB8yIcvE+DhRNNGBOjw5QkNTaVUcytNeIq8ea3Kdd6Z5EdN+a74dI8L1yoD8bx1jRkRbghNzUcVoN2cEJGJNlEwtGRerSwk19jXibITI6+MiGDt5UhLXGzvfMScbU+EJfmuuHKPHccq3LD5glWzEnWI9lHCW+rA8vGUH56Yo0O1x+h3GOvHGcPa3D4gBljx6oQFcHyIJLrnBLv3NCiiPLkhZSbPrLNGa3NTlCr3OnbTj5uHZ5fZ6e51+D0ScYblTxvTh9NnHu0Co9uNeHoPj0uPqPCtR0y3HhAiY7JjrUHpUIObycVQl2UmBlvwsZCFxyY4Y4LdZ64WOeB643BeKw64e6axOgYfwT7ef6ita1dzuqB7Ghvb1cZDPpfGrT8OuLQzMxg3FiVjpdm+2LjeHeUR1thIttg/bE6cKo/4bdRiQWZBtxaa8HZHjU2L9KhaqIWMcTZVMRvC8ZqcZx4yw3Kg65c0FAM16G60kL6cBp+dJsFcbHmP7m4+AwGBOoGtm0xo2+N01DVbCsmFWspf1LTvIuJN+pQVqLjY7ynqwxjksnvpunwIvH/m70mPFnthHgfHQqjnVAea4GzVsqPUa+SI8lLj/mpNjxe4Y832zMxOc1RD/L3caWYY/qqYXGjrbt7NdfT28PV1tZ5+3u7Ds6YnO3Y35YSiIJod5jJN00qGaJIt1NC1bg/3wnrxnsgLcCEzgnueKLSztugK78mR3FfLuXvnzpBi4tvkA+/JcD1i4QXcw1YUGfEozvsww8/ZKN4YPutn1/ESx7udvj5Rx6orfH4sInsd+tm23AnYeTECWqcPKbic72Lr1PsqNWzWgSczSq2FsnXFlKD1DQGM3bO8EKkuxYTwkgfpe7YWWjGwgQtxvoRNjopSQYFfO0G+Lny66bDleVjhiJDvDF+QtEElhP30ZGbm9vgqL2KB9Vk+4FuRlTEOJG8NhwgPLpWZcLhCivGj+z3cdIr+D55mYnLTSRe31jkgqw4C1oJEy8+qcYZys9vHFViLvGAZa06vHbIgpJi3cAKmrvk5JR1+fn5q00mPYqLJrZlZOQsWUKxbPEiy8Dzz5qxvseAsmINxVQlTj9NOeDjCjxYb8TYJCuqcm1YPNaMOA/HGqRSRjzIorq7N6k1zYjzZGdvVxvw5jQTni53R1ehP8Yl+hHH4tereT7g4e7x1urV3cRxlxgpB/vdnT0G6XHk85um4nJTKG7MteNylRU7ye+zfTTw00tQHmqGTCKGXCxEfSLF3ioL+iZbYTPKsaxYh5vkm2fvE+DKY5SbNRrx4EodzlJOMLNcP9BDeJ2c5H+sq3MNV1FRXmU0UEzJytzU3r5CNCot/LmuNjOmlegHTr+gw8OrdGiYrseFR9R8jeNivwzPNJgR5qHCtGTKk+ZZsWWcFlleDtnzyCdrIvTIdFegOESHHWQHFymnYvh1vjkK17ZXIS020MEhBQJeB+VTpkyYXFIyma8zeboNiEY45qbaDJxekoI1+W7IC6R8O8MJL4/X4laFGdPDzYixq/DMGB1uTVOjK9Phn2sK9bjcrsDRJsL/PiVaSw14iMb70X4tVtTohppm25Gdqh+oqlngc99967nZlZX5jPuPHz++ZePGDVx9Q5syK83tvZXz7WiYqh16/1ktNhL/mzFGj9OELyeXCHC+VYrna8wwqmXI8JLjwlQ1ThOm1oZqCJeUeCrPjHfLNfgpjWV6lInitREbJnji7IpsLC6Kc6wjCgVMVsf6UlDwnrq6ujC5TPa1QialXN4wPL+qBN52I7ycdAiwqdGf54QTpWrcoJhUSvE/xKzAqzSmy9kiHMrTwE65bl8Oxb45xH3KKUY1K1GbRViYbcAvthrQX6XBvBLnwcpxhOfZBZX9fWs5lmMUFBQsZ/F/fGHhMvZ339pebtLkGWnlOcQTxtuGqvPkw+9u1mFWugbjotQ436LGW9Uc2bYYBysssJMP9iYQ/x0jxuVcBVbGGOBEGP0T0sHVUiVeK6WcM8sGf5sWUT5O0BImLm+ahbBgRy4jpByxtLR0EsOA8eMLq3ie5+85mJ4cyft1+agg7K2Jxo4CE85QTrooVo8UFxXeIpnPpBGu5cgw3U+NUn8Nfl6mwp4sDm9OkaKT7CKJsOf6CsrJicdOTDJ90zDRSDlN6LO9axjnWC7rJb5FfVebTUaKiROb2Pr0ihUrZGzPS2ra6FW1ecT5gw23t81U4T3iuRmB1A/p4Hq1Ai/kcTg7XoqtGWakOKtxIpuOZA7Xx8jwcJoBMXRuX5EFRyZTHlpox6H6FORG+/Bzn5EShaRYx5pOcnJy37r16zjHHrN2pc3J8sv0pMiR+oEA7eWjUDcmDPsop+rNc0UcxYDTFN/OZNIcjBJgd7IaJRR7LuTq8VyCAGdzRXiuQAcvwqKD0wy4NF+BWSmG2yuKnBAVYP24qaVd2b26i1/7Y/JOnz6txGI28fKvYevzxMPYftVVnau5tISwF3rLnDAzzfzN6yTzyRrKETy06E6l2JgvxqNRHK7kKNEWaUQ9xYFrmRK8Rjp4p1CCzRSTE4gLvzDDF+uLfFE7JhxzC+Lu5sjFY0cNGrRKwv+JU/rW9t2teQYGBu5z+IdwwDay5pkU6IIFuaEIcdbitRluOEd+8NoY4uSEBZMpV9uT6YTVoQo8Fi7AGeJrAWYllsbr8P5sLZpTDQMteS5ku5avps6siehb63hXgOXYrBZZVFRUr9dpKNZNaOH3aK3sEDv2fa3mmpYsF6WGu92ak2ZCZZz+9vUZGuzKNcKbOMfBbCOOJRPeBEtxdpwNs4ONeDpdh1O5YuxOF+HtShN6xtjhQniwYlLM3b1BdquZ4R5fG5KIxV83NTU5r3bUBESsRjJlSnkhn8srFXzd0MVmxqT8NP7exfmhxHfjsTzbBedqvFEXrcfceFfURVkxP1COD8apMMlbh2IvJd4t0mH9KONAVqAZ2WGuv66cM9+nf+1I3s3WvknfvWt6Cf+nTGH+P6m4uH7Nt/bJ8e+0UC42f1GTJSXU62oGYVhjnPGbm2R7q6O0iHYizMtWYW+qAhWBevRkeGBKuAXHprrgiUluPF+7tnIU5UZ2fuwzS3Mp1zbzbZnUsQ6dlpbW6+D/HSLH+0EdApb7+/v5H+I5kq/nQEigNwJ8HHtqI7yJpxCHKEvxw+w0L8f+K+I6wXYNbtV4oJNy2lh3mvdKFzyVY74tccSTWwvrF7uyvbCUVzPbvlNfErFcs6amZpTd5oSSSZMWsf29d2rz/P4LsoU1xMval68QBPh4nuPXEBKNtz+eTtcHGzDOW4UPquyoiSO5hCLo2R4FrQSbpschzs+O3ChP2I2ONYT8rES4u5I9ODvxfq/X6z9ia9Bdjv2pQr72wd53WMXe8ermLFank4lxYXC2O/G5ktmo558jkrCakxRe7jZolHL+XGaIHYdbR8OsliDSTYNleZ63ZQLqw2y9vGzZMjmT4W/fj2H2xuy9Zk5NqtFA+U95WeWa3u++p8KvQ5LOWFwgfqL38vV7kfXXle85WJXszPf9eFUUNkyLuevXRvIlm9kA9p7OnXOsds3X1iymoYrJY/k6wPz580N6+XF1fLcGQuNkOFQ3d27knfuDfD0GvdwddrSpvxXBAd6YPy0PXm5OlLdboVPLEervCYlUSnHF+y9Gsx52V/dDq7vYOyqO96NG5v3vaq9MD/UN9QHtS5fqRvbN/4Oa1Ep+7zvbHxASGvaogHw5LzOet2E3uwmp4d5QKFhNQIq6ilyMS49G0fhMLGmY6Ri/vxf5sYX5PH/P2LF59fz+i3+4H7CTHy+bG/b+mFwu/72/lwtxYsk3xNMGgwN9hoUj+8/8vN0wZ3oh3x6bnUay+33D9ie52K2fNDY22nt6e//le1Gs3sTsnGEdq0P8q3f02Ho10w+zBU9393MapZSN6S+zKsYPy+QKJEYHoWVBOb+OwLiNs92K/DGj+DxOr9UMpMSG8uOMjIrayWzy23sv/mF/HWz/21pu8eLFHhQH/8zjRUI4/wzyowG2rsLyBMajWazgBNygm4sTrFbrzabGJkvvHZv//nUWwciexDtj+Ydj6hwZE1vDoPErTSbzWZ1GRXJahqUS8W2G6Uq5nM3xsFgsHlKrVYMyqWQwMzX2rh/k5IxpWr9+Pde56l/uf/mWzleIGUbV1tbGJKckr/f19d2vUin/xJ4lp3zHx9P5O3v+wsJC9/H+2tP9H3sHiO1bYfkK+a2woGDccophd/uXkF9Ehfo55sjF8S6Mm6vzu15eXm/OmDEjY+1IrceBdz+kv867OM04AuMHTc1NtszMzJaYmJhHXV1dz7D8KTkpaUN1dXUCGxezYzZP/265v2sHHXy9ho2nuromLiQk9Fm1SvUZcdkhitu3zSbTz0JCQ3eWl5dPbGtrUzGfcez/vjOue3tXk+ma1cdYnHTgUB/HYjWzRebj7O9eHrvv2PJ/9l1Q3q46eH/gcYrVLZcuW6aaP29eyMIFC33Y72yvK3t3p6vTsd/x3/Y+Vofj3Wfejjr4d2+Fjvphh/B/9o7xj/YHNjci9n4y20fE5trBHVaKOhyxTcDej/439/s32PFvf/49HyNzwa/vjazd/Z+P6f+ng9MKOE5EiCng0uk/wbfaQr4t5rj0QwLRyHm6WCAdaQvpPwP7nZ3l5ALjt66xjLTpV4H1W890unN9Oidw/db1xd965qS7/R5d08TJOE6dR+1THPvIR/4JRv7RbwV1i+qFeo5buKi5sTg307N8SoWn7BI9ScFJuSiOq6xqaiicNKaE3T42J8uziS7ivvP58y1eAu56WN5ET0/u3j6GqobGZhr1RGrHVNc0VVG7m9oLljQ3sPNfUNs8ez5rC5ns5kYaILVtrF3raIfy1zja6axdvXBRNbXZmBuqF1az9glqr21tqaG2qIDava11NUuofYPavgtaFtZR+y/s3oU1lU2kPjU731xTNZfajNGqG0uKs6idSkpU136rPftb7eaatmYmVFZ9Q3tjXe3cZs/AqiDPqKSkRM+8miULapqbwyZWVs2vbKz2zKpf2FC5qJ3jHDLzHyPTrScpOT4qKT4+LDo86luK+pc//sAPm1tH649F/JwJrBf+eu4fXVe/i+MSvyLd3P/Xc7O3cdzLPRxn+/lfz/k+znE6mrdDl78lj5XZy9zm5obkiAhKRMLraqrCmULvfr73gh/w+VZ/4exxd9XjmV0zp7JlQbMn01tV/YL6lkbPpobKqhrPsL814h994z8eR2gxpWeNNYvojlKysrpFtTTdi6rrmuvqF3nWLfpnk/gjb/ubj8Ou6WN6apgzzwzn9JfNnOi3FzixScWJpu2kXwR3561AUcoxzyvz+NRh9/xH8PdPFW5k/zXV1fL3ZRWXeFa1NLY6fmNuyUk4JafjzJydc+d8uEAujIvmErgUAqocLp+bwJVwU7gZXBU3l1vINXJLuOVcJ9fLrePu5zZz27nHuKe4Pdw+7gD3Mvca9yZ3ijvPXeFucu9yH3KfcL/hvuD+zLHcQSbQCEwCu8BD4CcIEUQLEgWjBDmCAkGxYIpglqBWsEjQIlguWC1YJ9gk2C54QrBH8ILgFcGbgrOCq4KfCT4SfCb4g+C2UCRUC81CN6G/MEKYKMwQjhOWCKcLa4WLhUuF3cL7hFuFu4TPCQ8J3xSeF94Ufij8jfArAnCVyCryEoWJEkVZogmiCtEcUaNopahftEW0S7RPdER0WnRd9KHoc9E3YqnYJPYUh4lTxHniyeIq8WLxSvF68XbxM+JD4hPi6+KPxF+IhyUaiaskRJIsGSspl9RKlkh6JVskT0tekpyU3JR8IvmzVCq1SgOkCdI86RTpPOky6Xrpo9L90mPSq9KPpV/JZDK7LESWJpsgq5Q1y3pl22TPyd6QXZN9IvuLXCX3kEfLx8gr5IvkXfIt8mflR+XX5J/KBxR6hZ8iWTFBUa1oV2xUPKU4oris+EQxoDQoA5RpyhLlPGWncqtyn/Kk8j3lH1UqlbcqSVWkqlOtUm1VPa86o/pI9Y3aqA5WZ6mnqVvU96l3q4+pf6b+o0aj8dekayo0zZr7NHs0b2k+0PxFa9KGa8dqq7Ud2h3aQ9pr2t/pFDo/XYZuhm6pbovuRd1l3ed6hd5fn6Wv1K/U79C/on9b/5XBZIgyTDAsNKw3PGs4a/iVUWb0N+YYq43dxieNbxk/NolMPqYsU5Vptekp00nTJ2apOcA81jzPvM78U/Ml8xcWoyXWUmpps+ywvG750Cqy+lvHWhdYN1oPWG9Zbzu5OWU41Tj1Oe1zuub0tc3Flm6rsfXb9ttu2m7bPe059vn2B+wv2993FjsHOxc5L3He6XzS+XMXs0uKS5VLv8sBl5+7Cl2DXYtdl7k+6XrB9Ss3d7dctwa3bW5vuX3ubnVPd5/n/pD7UffPPEweozzqPB7yeMPj154WzwzPBZ5bPU94fuHl6pXn1eL1hNclrwHvAO/J3l3e+73f91H6JPrM8XnI57jPF74evoW+y333+v7cT+GX6DfX72G/035f+wf4l/mv8X/Z/1cBtoCxAUsD9ga8F6gJHB24OHBX4I0gaVBi0PygR4OuBAuD44LnBu8IvhwiDIkPqQt5NORqqCQ0KXRR6K7Qt8PUYRlhrWF7wz4Kt4YXhHeFvxz+uwjfiIqIByJORwxHxkUuiHwq8t0oY1R+VFfUkag/RAdHV0XviL4Ro4kZE9MRczjmy9iQ2JrYnbHvxJniCuPWxB2PG4pPiG+M3xf/WYJvwqyERxLeTjQnTkxcn3gmSZKUmdSR9FrSN8nxyc3JB5J/nxKWMj/l2ZRfpQak1qQ+lfpxmndaZdoTaR+O8hw1a9Tjoz4c7TW6cvSu0f+V7pNenf50+qcZQRnzMp7L+F1mZGZj5kuZX2clZ63IOpYtys7N7s++lGPMmZyzPeeDMd5jasfsHfNFblzustxjeZK8cXkP5L091m1s1dg9Y7/IT8hfkX9inHrcpHHbx/1XQXBBY8GRQmFhfuGDhe+N9xu/aPzLE7gJYyc8OOH9iQETF098tUhaNLFoR9Evi6OKlxefnmSaNHPSs5P+XJJZsrHk3cmBk1smHy/VlU4r3VP6dVl22aayD8sjyleUn5/iPKVuyuEKWUVpxdMVX03Nmbp56ifT4qb1Trs1PWB62/SzM5xnLJjx+kzdzMqZL86SzCqb9eyswcoJlbsqv5o9dvYjs7+oyqp6uOo31enVD1V/VpNWs6nm0zlpczbN+VVtWu2DtZ/NHT13y9zP67Lqttd9OS9v3mPzvp4/Yf7u+VhQtmD/QvnCWQtfWWRcNH/RiXr3+rb6qw0hDb0NHy5OXrx58ReN4xqfbhI0TW863GwmMnWhJbClp+Wj1lGtO1r/sqR0yYtthrZFbRfag9v72j9dOmbpT5aJl1UtO77ca3nn8o9WZKx4YqVg5eyVxzt8Oro7PlmVu+qZTmXn/M6LXZFdm7r+tLps9ZFut+5V3R/35Pbs7dX2Nva+vSZlzWNrxWvr1l7qi+nb1jfcX91/bl3kui3rBtdXrT+3IWrD1g24b859lzbGb9x5v/T+RfffemD0A89sMmxauunjBwsfPPSQ50P9D/1p88zNZ7fEbnnsYeXDLQ9/uLVg6+Ftvtvu3za4fe72mzsyd+x/xPWRvke+frT60Ws703fue8ztsXWP3X687vF3nsh94tAu/11bnpQ+2frkL58qfer0TxJ/sudp56fXPT20e9HuD58pfubEnoQ9e551fXbjXuHelr2fPTftuSs/zf7p4X1h+57Yb92/7nnu+Zbnf/3CrBduHRh34PiLiS/uO+h38JGXTC/1HxIcaj/0xctzX/7w8JTDV1/Jf+X4kZQjL70a/uru17xe2/G65fWNR5VHu4/ijaVvfHWs4djnb9a++fHxmcfffav8rRsnik5cOjnu5JlTY069dTrj9Btn0s68djb57CvnEs+9fD7+/KELcRdeuhh38aVL8ZcOXU64fPhK0pUjV1OvHr02+tqb17Ovn7ox9sb5m+NvXr01+dY7b097+8N3qt/51c8W/OzLn7f+fODdVe9J3ut/X//+lg9cP9j1i6Bf7P8w/sPXP8r+6MJ/Tfqvdz+u+vg3/93034OfdP9S88stn3p8uudX0b967bMxn1359dRff/Kbht8MfN77W8NvH/ld4O8O/j799xe+KP/iky8bv8Qf1v/R/sfdf4r90/GvJn71wZ8X/nng6/6/2P/yzDeJ35y+XXb704Elg7LBrUNBQ0eGxw2/h4XA/wPk5EZUDk0AAA== + yCoordFlipped + 1 + + diff --git a/tests/cpp-tests/Resources/Particles/ButterFlyYFlipped.plist b/tests/cpp-tests/Resources/Particles/ButterFlyYFlipped.plist new file mode 100644 index 0000000000..7fee179601 --- /dev/null +++ b/tests/cpp-tests/Resources/Particles/ButterFlyYFlipped.plist @@ -0,0 +1,120 @@ + + + + + absolutePosition + + angle + 0 + angleVariance + -360 + blendFuncDestination + 771 + blendFuncSource + 770 + configName + ButterFlyYFlipped + duration + -1 + emitterType + 0 + finishColorAlpha + 1 + finishColorBlue + 1 + finishColorGreen + 1 + finishColorRed + 0.9999960064888 + finishColorVarianceAlpha + 0 + finishColorVarianceBlue + 1 + finishColorVarianceGreen + 1 + finishColorVarianceRed + 1 + finishParticleSize + 64 + finishParticleSizeVariance + 0 + gravityx + 0 + gravityy + -434.2099914550781 + maxParticles + 197 + maxRadius + 100 + maxRadiusVariance + 0 + minRadius + 0 + minRadiusVariance + 0 + particleLifespan + 10 + particleLifespanVariance + 0 + positionType + 0 + radialAccelVariance + 13.16 + radialAcceleration + 144.74 + rotatePerSecond + 0 + rotatePerSecondVariance + 0 + rotationEnd + 0 + rotationEndVariance + 0 + rotationStart + 0 + rotationStartVariance + 0 + sourcePositionVariancex + 167 + sourcePositionVariancey + 7 + sourcePositionx + 160 + sourcePositiony + 240 + speed + 46.05 + speedVariance + 0 + startColorAlpha + 1 + startColorBlue + 1 + startColorGreen + 1 + startColorRed + 0.9999960064888 + startColorVarianceAlpha + 0 + startColorVarianceBlue + 1 + startColorVarianceGreen + 1 + startColorVarianceRed + 1 + startParticleSize + 64 + startParticleSizeVariance + 11.37 + tangentialAccelVariance + 0 + tangentialAcceleration + 92.11000061035156 + textureFileName + Untitled 1.png + textureImageData + H4sIAAAAAAAAA9V7B3xVVbb+ub33knvTe++9QioJIQESQhJCDUkIoSWkkdBCQhJIAFEUpCgqOiLigCIioiIivXedsYw+n+M448zozDiOpHz/tc8NjE5TfDPv/f6X3+HunHvO2Xutvda3vrX2PoWFXDDHpctXrVrF/aujY9UqQVdnJ9fT3UN/dwhWrlwp/r57/veODq6DxtPT3c319fdzlbMrR00sKpq5Zk0vt7JjpXBk/P+T5ws6uzq5pUuXqufNmxfa00P99PWx86KOjg7h/7H8AhqDaM2atdy8+YvsEZFROziOAzumTZuav2bNGqYb0arOH9/HypUrxGtJ3sTEpPvZc93cPV4rn1KR0bl6Nbe6ezXnsIXO/125SR6m+0767u3t5crLJs8uzUv6k5ezEd6u1gE2TolU9uslS5aYVnd1cT92nth93WRXLS0tFolE+qVUIoJGIUViqBcm5GftaWpuNjAd8zr4H+j4Xo7OkXF1kVzMNv38/A4yed1tJgR4Od/OTAiBQaf+xqiVIyw8/LG1a8kGOn6cv9J9wp6eXi46KvIp1oerk+l2SW7CoK+HbVAlFZGdCb6cPbsyndnHipUrJf8b8jMs6iQsWr26iwsKCuBlLypIHbDbzMN3bL+6fMxAekIQ/PyDdq5fv4634c577quD74fkEtht1vcbKsfB19M+dKePosJRt416NWsP8zpY28fs4D+uAzb3vT1ruJi4uAfZOOJiAr459frGYS83KxbPK0agnzs/Jh8PO/R6/S+WLGk1dvE+sEpwj/0IVpOPNzQ0uGvU6t9GBntDIBAMzZ42FvExAVjVNg07tzQO3NHH7KqqOIZDzBfuXdc/7GD6ZXoeX5C/nNl3XIjHgLubE4JCfKCjudi6YQ4MBseceLraIJVK/7S4cbFbN8lB998TBjCfWbt2LVdUVFQhFgnh5+U6yOScXpqOmpk5vMyhYb6ICnIfTI/1QbCPy59bmxcHre7uJsztEP0nZGdYU1U1O82oVSIlwhPZSYG8zZcm2jE6xIkfk1atwIaOWUNmo5p0YXyHMFLAYwbZ8z3Ov5DN/9L2NiM99zeRIZ4oLUzh7d+qU6Iu2wNhLgqIpRLEh7oPKAkP3FxdrjCfWcVs7R7t7YeMZfnypSqlWvPRiM0NqanPJ8vdca7RH6kBJl5+D2cTWueOR7Cv26CviwWjR6cv66N5vEcMZBxHxLBz9OjRq21GDQqzYgZ6W8v4PjiBEKsK3XGl3huTg3UYGc837Ds6Nv7+9ev6uX8nR3L4fA8XFBb5qEkhgkgsHtArxNg9zgk/LbQgyKJAjKsWk2Jd74wFUaHeA3FhXkgbld7W33/v42HXM54TFxf78KjYQLIrJe/rziY1psU7w6qWIddLiZOlVjTFGXmfS/A0DXvoZZg4qXTCWsa//g06YHa/jsafk184K9YqQl2q+21OIMDjuU44PM6IEIsSSxNNeK/OFc9Wh8Nk1GJ6WToKcuKG4iJ8YLY4nekmzsbbf8cPn3/2zfzGw9391LSiNFQUjx6Kjg5AWpANH7aH4/ViAxLsSswI0uBKmQ0zQnSwapVDa3PdYFTL/9C6pE3HYtS9+t3fjoPx7rb2pRq9TvvJqmwXeBoVQ0sTDDhWZEW6qxobk/R4t1iLrVk6pPvpkZUSguceb4HRqBuQSYWEUWG7HDyQ50A/eCzMj5ctX6agGPLfDP9Gp4QOP7ezGXajCpPD9Nifq8W7JSYsDNdjZpAaJ0kHhb5qZAWYbqe4KxGTkNLN5m3Fih8ZE4lPMU7B4ndickqvTsIh3N1we2KAGmdnOKPMX4WHRpnx8lgrkq0SBDhp4WdRQS6TQiqRIDbSb6C5bjyio2M3/Bj7ZxjOcoig4KD9yxtK4GwzDei1apjUciR7m6CSijHJS4WD4+x4KNOK1TSWI9Nd4W5UDOtVCh6XZ8+encpiyI/xgzvcs76+3ksulX7l8GvBcEOaBRMIcx4tdENHkhl2jQJOKjni3QyYm+IJLzcTZpSkQKVQDFpNGvj7+7/IOPLKjnuKSQKWN7B8Lzgo8LC3uxUudtNAzdR0xPlaUB7jCjeNHInOOrhpZViVZkNpuAluBjkSfHSw6eWDcomQxYOLDll4u7snP2A66yf8CQ+PeMKqlyDSW3t7bo4zxXQxPMjn/QnzSB9ojzThdKEnfA0qHveSItyxZsl4qJXKgczkcERGRT12Nw+6R/2zWB4cFPBGGnFqk1Ez+MCqSTDpFXw/DZHOuDrBA+kuGkfcJTxO8dNhXLQR2+d4IcLPfNvVJMGEopIiFg/uhR8z3t3b28PNmTsvwNmsgJ+HHrU5VjQU2FE7yoTyBAvfJ4u5TZEW1AUYIBOL+HOJ4a6YVRTL2jxe5+blLdiwYQP54QrpvchP14uZ36SljeoS0HNEItHg1MJomCj2s+ea5BJU+BkQYHToQ0oYsavGC/mROoxPNEOrlAwXZdhgNmh/tbixycri96qO78fgjhHdM9vz8vZ+dXyakWKPdFBN+nUxKbBkvDM8zDK+T6GAG4l3ApgUElhUjvNm4oAa8sEJYxMR4OfxeU3NnGCWt//gPJDstYuwu7m5VR0XHXoze1QE4YpkiD1XIhQS7mvhz9uB8Dvj8HdWwdemuBuDkyINt2eM0yEmNmn9hg3rR+bgX+fKjHf09a3hSkpnjM5P02JKvpVxrru5jUAovPt8JneGhxoPUvx7IVGHA3nOCCTfWNdWhKKcSESF+91m12Xn5M67Fwx0jKGPG1dQMEMs4hAZ5jvQMCsLjdXZyCDOd3GcFa8na7Ar3YjSMAM/jr+OiYNYdPfv4dWL3ZAUrRkqLZ+d2N/HcuXvwSHCqe7VvVxIkPfRVQ1WmI1y3o5FQnqm4K+6Nqgk6Mgy4ESxCucyRLiQKMStiWaMDzbDw81C/i9lOhuMCfdF3pjstQwDGQb8kNyEcQ4mf17emLbwIE/elwyEdxazDjMjzLiUp8O5VCEu5ApxcaoS/QU6qOQO/5OMyK5WiZAar0NyrHZgGcnh7uZ8qcMx94IRTvB3eMgwYt26Pm50en7NxHwNppZYB2eVGjG5wPgdO1PIRNhUpsWNeRJcKhPhZIEC2xM1yCdbEIrE/DUxod6IC/cdSksIJR3qv2xqajbzfOT7eDn5KNMRxQvO2W67lkr3R4Z4DUY69AABPT/HXYPuWC1eyFdRLJbgRrMUG8rVMGslI/Mvgr+XGhdf8RlumW9G+WTn2xlpCuTkFM5cv57Z4QrJ39ZL7uSbra1tGnd3/a+nV9jI7tRDr+51R321Dd7ulNcR79OpRXhojg43upQ4UK1CY5IKY301SPXQIsdThdp4G+QSEeVrzoRV6rs4WDFlSjHLTzu+xwdY3O8hW5lbWxsncmDqkEopY/Gfj2+r050wN5zygQAdUr01yA1QYn2JBmfX6LB7hQ0ahRDRYTrU1zgjOU6DmAgVxGLhUEyUjjiZ4YOlS5eqGLf67jx0Mr8gvr2WS8/IajGbhHBxUfK+G0R8Z9liC9at9IBWI8H6xXb8tMOC6mwtAghvMoLVWE3tE+UGXJioxJUK6jvVys+DXqtifHggPMQPcbExB7pIvx3fwwMYRrB6zvjCwoXeHnbqUzVgtzpyq3X5FPMmK3C5SIrzU9X46XQd5mToEB+goUON+ZOMaJ7tDFe7HC/ttuHBdXp4ejgwWa6Q3nbEo9ymdevWfyce8vXlri6ura3NoFQqfsvHE4l02MNdjv4eHW6eMSMnQ4nwQB1Kx5rh4ypHfqIKO+frcbFNjct1Ypwo5XB6AocrpVLsn+FF/EdKOEDzoVbwOaubi/2jpcuWS7u6mA/+U04uYDypt3cNFx8X+yQ/bpl0wMlsgJ5iy3PTPHC9QoELk4U4M12A8wuEuLpKjpP9OiyfpUZ+uhqJ0XoIOAmWtejxzhUljh/VobxMB71OyWO4Wq1/l9WS+Tx5BAMcudZarrBwQiWPIRLpQP5YE14+aMDFMxIcPqCH1SKFp5sMXc1mvPCABpe3K3CuT4jTSzlcbJLgXK0KL0zS4P4xRsoF1XexOCbCfzg00GvYbjVi1qzKeL5e+c9sYISnsRjs7eV5ydVuQWpC2OCdZ/mYlagI02J9jhYHK7U406bExTVinLmfw9UnRbj6vBIv7jIgPFQBHx853npDg3OnaE4ualAwjvEG8YCHuxglJaXFa/vW8nU5Zo8sN+/pWcMlJYUecHISQSYTDuz+iRoXzghxnuRvbzXSOTH2PWnE1SNSnN4twNmdQlzepsDBZVrUjyG9Uy7qYpAhkmTP8lMj2ddhs67OFug0al6GWbNmZo7Ua/+ZD9zJ+wRGk+kaz+s0qiGWT0xJdMWiVCNy/VRI9NHATliQFaZG13QtDt+vxfk9FBdfFOLacSH2Pa3jMXD5Uj2uXiRfOc3h+BtqxMepB8soX46NDXmhp3sN60/YTXk943ozZ9aGjhplHEofbcbK5arhqxfFOHmcw9EjJlitMkyZLMeNczJceI30vV+Dh1fqkZuggpVk9nSSY1aaHjtL9ThFdnihWouzreGozAq5YwdDjjWBabnfJz+zS7IPobOz860791blhOHq8mhcIby9VqPAibk6bJ6mR1GSBu7k696uCkweqyGM0uLlfSrcvKxH9WwtdDopXjlk4ufxxhUxtm3RDgcG6oYNBhFmzpqdSHPPTZs6tfg+4qeRkdHb/HzpOSXGgQtnVTjxJtn1OTUqCNfcXGV46YANe3+ix7xqwpsoDUL8lchMUGLDfB3e6NThyjLyy7lCnJrG4eQ0Ic7Ve+KF9lzoNSryJ/EA2TGKi4rmrFnL7P8fxwCGQyxGLlnSJssalfABcVde/q1zR5GP+eHkdIq19PzTtQJcWibGpQ0KvPmQFpvIBssnqhAfq2YxCxMn6NDcaINSKUFqCsXIkzo6yEcuKjGlzMDHo/DwsKdKSoof9/Rwx4zp09rMZuPP1SoptjyoH75wltm9FGt7jTy3iozUIJu4jp+fEkkJcqxsVeO13Vpc2UtYvEOM070CnGzhcKpOgNOzBDg1U4TTC+w4sjSLsJL3gwGRkMOkSZOmsHz0X8RAmv8ubtnSpUqdXvepI5aLh7bOSSb5vXGqkvqqpD4I906103c/h7M7yL/3i3DzTRlOHNFg5zbiSNNJDxFq8lkHH2ioJxs4q8S1y2Ks71MPqyiH1moVX0VGRPzBx8cLrq5uX7m6ar+OoFh5+KAS58+KsGc38X6Ng8v4EpbUL9Bg7zManDmuxNWTNI4XSeaf0FxvJbn7SOal9PcCaldzOEFjPNfohmcXpzHezuOuQqH4vKWlhc9DKPb+0zyAbEPEfCQpMem+Efsf6KqIJ/sPwalaKU7NoT4WUb/L6dhA7Ueo32fpeIkw6RjZBY39xhUp+a4avd16ksHBC7tX63HjqhQHn1cOj8kyka1Y/6DXW37p7OxE8rveSEl0GphTrSdfkeG1w1qkJjswvGyyGsde1+DaJQnZBMWdt6jf16i/gyTnM9Q/6f/MBup7FfXdJsJligWXW4gLrIrBOMrTne3W21kpofDy8nmxv7/ve2vTHXzdcy03pWJaSmyYD/Iz44csWjkemxuDs+0euNSupZhHPGOdHFe3S3HlGTHOHxDiLI3pzDEaywk6CPPPn+Fw86oEmx/QQk7cWEPchcWzy2cVmDFFjzDiTwaDAf5+vjCbNRQ3TcOrV2pwk2JmY4OBl318oRJHX6U4R/jJsPD0Ccfzzx0X4PIxCa68pMSpxzV4heLvT9v02Falw/opRrQUuGBUCM+BhoP93BBNXLh40qQJax3873vyD56Lirop/8zOztho0PL53ICMOGU4cczRxLfGRqkxM1uPhSV6dNfrsXebEW+8RP54jrDvqozmiubhPM0J6eHcaeLq9+uIl4uQn6fBB5cNaKpRwqJTwWbVw+Zkg0mvGrab5Nj7sBbPP22AQCDCOOLWL+wn+Wi+GX5euyzB9ctykl+LF/cZsKpdj7LxOkQGqeDprISfmwoediWCvYysHk++J2PrNTzWpKaObu3vu4caGKs9MS5OOOjj5fZLjVoJg04zuHhqKhrLQjEr14ICwv4IfwWcKDZZLQrYKQ6kj1ajucmAHdv0OPC8juZLw4/5BulkxzYtrE6Eb51m7Os3QUdYp1BSTmUxQyGXw8tO+PGoBfkZamQQ1zt5XINL5+UkvwbP7jZgWTtxvxItggJVZC9yuND1YUFSTCfO2z9fg8dbNHi5xxtvPZiLR5YVUkwyD2k1CowZHYOl7W1mfr30X/j93/tBh5jZQNXMKWutJseaUnyw6/D21lTc3BmGi5s1OLGVeO42JbavV2DJYiVhtAw2uwQmkww6rQwBAXLMmEbx4X6Ky8eNePoxO9JitNi3wpVsSQaJXA27k5meTfwilXgV5TkFuQYcPWzH1i1a1NboKU4o4UTx3dVFhlGUQ1VXqbChX4lXX1DizEE5Lj0nxeXHxbixU4cX1oSgMJXP03jMU6mUX5aUTJq5gtl8hyO+/WD5KR+jQ8xy1qys7EaWSzvbDJQHGYYrcpzx8npXnH5UhfPPER6/rsL1s1qyUQNhtwGHDurw0CYd2lr1GDdOhYR4FeGYHsubLCwfRpyPFmWpdqg0espPDMSJ1ciLMvP1rPFjDJg11YAcymkqpuiIC+nx+KNGvHmUuPA5A86dMeLVwwbiWFo89wgdmwx4vMOI1uk26NVihAY6Y8rEeGb7xDEqU7Zs3sytZfW/jpH9Gj9gnZ7JzmLhapp/4gKaylmVozmh9BfxkR7ITQ8ecvBCKQI85cigPCQ/S4OkeDkyM1WYNVNNcmtJfjMe2GjC5gcpd+uzYWmbHfVzKCeMNPDcUCYVw6DXURzU8jrg19WMxH9y7airstEz7FjSYkb9Qj1q5+gxbaqWMIF4T7AcdpuMzwXlcjH5uehuHYqvfZm09FwV+ZR02G63XQ8LC3tqcmlZFqunMZ/+Z9xn1UgeyuIDqzv3EC8tL5s8x9lm+R17bny4L29X4d4GxPlp4W6Wkr4ld2s/Ko3mW3UgAVRKMfR6EXFXEWGDEB4eYgQHUl7grgSr5fG5EN1jNpmgVChH6nYyuDjJEOgvRVSkBGGhInh4CukZQuKSIrB1CEcNQkr5hYlyOzH5uRQTU7SYmaFFU6EJ/ZXBMNPchIf6IiGKHzMm5CUhNiZ6T2trq47F9hX/cI2607GvgnS0pK1d5Ont+0RYoCeyR8eSLXGDUeH+wxkRrjjVE4tTy604RnHwEPG+R5q16KnTYPEsE0YT13NxkcDZWYJRo5SoqdJSLNMS/9GhabEB8+sshA+O+mBCpIn5EnR6A8UBLSKCHOuIfr4aut6ChkUGzJurxQLKcSumaJGUqISPt5z3i4XE77d36HBkow5nNmpwsUeBqytluLJchRvdPti9OAHBHhZWKxwSCoUDYcE+fP6jVKo+rqqqieLXJFZ81w74egTb77BiJTdxXPpxo57V0wXf6LUq3t6zo7xxvDMLN1d64doS4iNtclzpoHi3QY1bO4gTUNw6c9COzhXOcHNTYvIkPRbM06KqknxihpryATXZsx6dHTakJLF1Khvl5OT7hAEernrEhJoQG00Y2G/D8mUa1C9Ske2ryW/UWNujw9xaA+GpGosXWfHSLite3WzES11aHGjW4MBCyjvmafAG6ezEYjvNTwI212VCq5SxvTCICOEx8XbZxFTUzhj7+/LyijTHmvBfuRDDRmbzoSHB+9sXFMPdzekbZ6uB8CiBn5dgTxsmJ3mgZpQNxdE65IZpkOxPsYq+00LUGEPxMJDmx99PjueeseD6FTVuXpPh1nUJH7vf/znFwSs6dHVYEENyBgdS7uSmI4zWkR50xOtNiIjQkI6MuHheg/d/JgPLAa9dprz6EuH7VQVxYxM8PWVQEK+OCdYg2leJxAANglxVfO053F2DYMp/XUzM/x11FzHxgKy0KL5tsRhuhwW5MTv4pL2tTd85sofoDuctLp5U5thDoBx0s42sp5NthrkZEGxTYZSvDtnU3+RIFealKrE8T42NFXrsarBiQbEV/p5q7NpiwLWLMp6rsePiOcaH1dixVY/xBWQPs43o63UlfJCQTysoVhoIA+V8jFvT7YLKGXqUUqy4b52OuBOrAVAeTLkgOy5S+2XiAimkv4ZSJxxZ5YQ3l5E9zDfgqWkabC5WY12BAW2ZhJtpdtSmuqIhxw9RHka2Zo7yvHjIpVJ+nT4nZ8xiVuNlnIhhIqv5jE5NeoLVeaODPG/XlWciI8QZz8+Lw1sLQnCi1geXF7jjZw0WvEd2/PYSI05QPHtktglzx+pRlW/Gc8Rrrh6S4vRRjriLkGxAhaefNKC8TI9Ckn37wxq8c9OJYoSZfNpC/NY4LJfrUV5qJn8xE77rcOmCBS8+Tz5frkNeLt2z1cjXTy6do5znddLB8yIcvE+DhRNNGBOjw5QkNTaVUcytNeIq8ea3Kdd6Z5EdN+a74dI8L1yoD8bx1jRkRbghNzUcVoN2cEJGJNlEwtGRerSwk19jXibITI6+MiGDt5UhLXGzvfMScbU+EJfmuuHKPHccq3LD5glWzEnWI9lHCW+rA8vGUH56Yo0O1x+h3GOvHGcPa3D4gBljx6oQFcHyIJLrnBLv3NCiiPLkhZSbPrLNGa3NTlCr3OnbTj5uHZ5fZ6e51+D0ScYblTxvTh9NnHu0Co9uNeHoPj0uPqPCtR0y3HhAiY7JjrUHpUIObycVQl2UmBlvwsZCFxyY4Y4LdZ64WOeB643BeKw64e6axOgYfwT7ef6ita1dzuqB7Ghvb1cZDPpfGrT8OuLQzMxg3FiVjpdm+2LjeHeUR1thIttg/bE6cKo/4bdRiQWZBtxaa8HZHjU2L9KhaqIWMcTZVMRvC8ZqcZx4yw3Kg65c0FAM16G60kL6cBp+dJsFcbHmP7m4+AwGBOoGtm0xo2+N01DVbCsmFWspf1LTvIuJN+pQVqLjY7ynqwxjksnvpunwIvH/m70mPFnthHgfHQqjnVAea4GzVsqPUa+SI8lLj/mpNjxe4Y832zMxOc1RD/L3caWYY/qqYXGjrbt7NdfT28PV1tZ5+3u7Ds6YnO3Y35YSiIJod5jJN00qGaJIt1NC1bg/3wnrxnsgLcCEzgnueKLSztugK78mR3FfLuXvnzpBi4tvkA+/JcD1i4QXcw1YUGfEozvsww8/ZKN4YPutn1/ESx7udvj5Rx6orfH4sInsd+tm23AnYeTECWqcPKbic72Lr1PsqNWzWgSczSq2FsnXFlKD1DQGM3bO8EKkuxYTwkgfpe7YWWjGwgQtxvoRNjopSQYFfO0G+Lny66bDleVjhiJDvDF+QtEElhP30ZGbm9vgqL2KB9Vk+4FuRlTEOJG8NhwgPLpWZcLhCivGj+z3cdIr+D55mYnLTSRe31jkgqw4C1oJEy8+qcYZys9vHFViLvGAZa06vHbIgpJi3cAKmrvk5JR1+fn5q00mPYqLJrZlZOQsWUKxbPEiy8Dzz5qxvseAsmINxVQlTj9NOeDjCjxYb8TYJCuqcm1YPNaMOA/HGqRSRjzIorq7N6k1zYjzZGdvVxvw5jQTni53R1ehP8Yl+hHH4tereT7g4e7x1urV3cRxlxgpB/vdnT0G6XHk85um4nJTKG7MteNylRU7ye+zfTTw00tQHmqGTCKGXCxEfSLF3ioL+iZbYTPKsaxYh5vkm2fvE+DKY5SbNRrx4EodzlJOMLNcP9BDeJ2c5H+sq3MNV1FRXmU0UEzJytzU3r5CNCot/LmuNjOmlegHTr+gw8OrdGiYrseFR9R8jeNivwzPNJgR5qHCtGTKk+ZZsWWcFlleDtnzyCdrIvTIdFegOESHHWQHFymnYvh1vjkK17ZXIS020MEhBQJeB+VTpkyYXFIyma8zeboNiEY45qbaDJxekoI1+W7IC6R8O8MJL4/X4laFGdPDzYixq/DMGB1uTVOjK9Phn2sK9bjcrsDRJsL/PiVaSw14iMb70X4tVtTohppm25Gdqh+oqlngc99967nZlZX5jPuPHz++ZePGDVx9Q5syK83tvZXz7WiYqh16/1ktNhL/mzFGj9OELyeXCHC+VYrna8wwqmXI8JLjwlQ1ThOm1oZqCJeUeCrPjHfLNfgpjWV6lInitREbJnji7IpsLC6Kc6wjCgVMVsf6UlDwnrq6ujC5TPa1QialXN4wPL+qBN52I7ycdAiwqdGf54QTpWrcoJhUSvE/xKzAqzSmy9kiHMrTwE65bl8Oxb45xH3KKUY1K1GbRViYbcAvthrQX6XBvBLnwcpxhOfZBZX9fWs5lmMUFBQsZ/F/fGHhMvZ339pebtLkGWnlOcQTxtuGqvPkw+9u1mFWugbjotQ436LGW9Uc2bYYBysssJMP9iYQ/x0jxuVcBVbGGOBEGP0T0sHVUiVeK6WcM8sGf5sWUT5O0BImLm+ahbBgRy4jpByxtLR0EsOA8eMLq3ie5+85mJ4cyft1+agg7K2Jxo4CE85QTrooVo8UFxXeIpnPpBGu5cgw3U+NUn8Nfl6mwp4sDm9OkaKT7CKJsOf6CsrJicdOTDJ90zDRSDlN6LO9axjnWC7rJb5FfVebTUaKiROb2Pr0ihUrZGzPS2ra6FW1ecT5gw23t81U4T3iuRmB1A/p4Hq1Ai/kcTg7XoqtGWakOKtxIpuOZA7Xx8jwcJoBMXRuX5EFRyZTHlpox6H6FORG+/Bzn5EShaRYx5pOcnJy37r16zjHHrN2pc3J8sv0pMiR+oEA7eWjUDcmDPsop+rNc0UcxYDTFN/OZNIcjBJgd7IaJRR7LuTq8VyCAGdzRXiuQAcvwqKD0wy4NF+BWSmG2yuKnBAVYP24qaVd2b26i1/7Y/JOnz6txGI28fKvYevzxMPYftVVnau5tISwF3rLnDAzzfzN6yTzyRrKETy06E6l2JgvxqNRHK7kKNEWaUQ9xYFrmRK8Rjp4p1CCzRSTE4gLvzDDF+uLfFE7JhxzC+Lu5sjFY0cNGrRKwv+JU/rW9t2teQYGBu5z+IdwwDay5pkU6IIFuaEIcdbitRluOEd+8NoY4uSEBZMpV9uT6YTVoQo8Fi7AGeJrAWYllsbr8P5sLZpTDQMteS5ku5avps6siehb63hXgOXYrBZZVFRUr9dpKNZNaOH3aK3sEDv2fa3mmpYsF6WGu92ak2ZCZZz+9vUZGuzKNcKbOMfBbCOOJRPeBEtxdpwNs4ONeDpdh1O5YuxOF+HtShN6xtjhQniwYlLM3b1BdquZ4R5fG5KIxV83NTU5r3bUBESsRjJlSnkhn8srFXzd0MVmxqT8NP7exfmhxHfjsTzbBedqvFEXrcfceFfURVkxP1COD8apMMlbh2IvJd4t0mH9KONAVqAZ2WGuv66cM9+nf+1I3s3WvknfvWt6Cf+nTGH+P6m4uH7Nt/bJ8e+0UC42f1GTJSXU62oGYVhjnPGbm2R7q6O0iHYizMtWYW+qAhWBevRkeGBKuAXHprrgiUluPF+7tnIU5UZ2fuwzS3Mp1zbzbZnUsQ6dlpbW6+D/HSLH+0EdApb7+/v5H+I5kq/nQEigNwJ8HHtqI7yJpxCHKEvxw+w0L8f+K+I6wXYNbtV4oJNy2lh3mvdKFzyVY74tccSTWwvrF7uyvbCUVzPbvlNfErFcs6amZpTd5oSSSZMWsf29d2rz/P4LsoU1xMval68QBPh4nuPXEBKNtz+eTtcHGzDOW4UPquyoiSO5hCLo2R4FrQSbpschzs+O3ChP2I2ONYT8rES4u5I9ODvxfq/X6z9ia9Bdjv2pQr72wd53WMXe8ermLFank4lxYXC2O/G5ktmo558jkrCakxRe7jZolHL+XGaIHYdbR8OsliDSTYNleZ63ZQLqw2y9vGzZMjmT4W/fj2H2xuy9Zk5NqtFA+U95WeWa3u++p8KvQ5LOWFwgfqL38vV7kfXXle85WJXszPf9eFUUNkyLuevXRvIlm9kA9p7OnXOsds3X1iymoYrJY/k6wPz580N6+XF1fLcGQuNkOFQ3d27knfuDfD0GvdwddrSpvxXBAd6YPy0PXm5OlLdboVPLEervCYlUSnHF+y9Gsx52V/dDq7vYOyqO96NG5v3vaq9MD/UN9QHtS5fqRvbN/4Oa1Ep+7zvbHxASGvaogHw5LzOet2E3uwmp4d5QKFhNQIq6ilyMS49G0fhMLGmY6Ri/vxf5sYX5PH/P2LF59fz+i3+4H7CTHy+bG/b+mFwu/72/lwtxYsk3xNMGgwN9hoUj+8/8vN0wZ3oh3x6bnUay+33D9ie52K2fNDY22nt6e//le1Gs3sTsnGEdq0P8q3f02Ho10w+zBU9393MapZSN6S+zKsYPy+QKJEYHoWVBOb+OwLiNs92K/DGj+DxOr9UMpMSG8uOMjIrayWzy23sv/mF/HWz/21pu8eLFHhQH/8zjRUI4/wzyowG2rsLyBMajWazgBNygm4sTrFbrzabGJkvvHZv//nUWwciexDtj+Ydj6hwZE1vDoPErTSbzWZ1GRXJahqUS8W2G6Uq5nM3xsFgsHlKrVYMyqWQwMzX2rh/k5IxpWr9+Pde56l/uf/mWzleIGUbV1tbGJKckr/f19d2vUin/xJ4lp3zHx9P5O3v+wsJC9/H+2tP9H3sHiO1bYfkK+a2woGDccophd/uXkF9Ehfo55sjF8S6Mm6vzu15eXm/OmDEjY+1IrceBdz+kv867OM04AuMHTc1NtszMzJaYmJhHXV1dz7D8KTkpaUN1dXUCGxezYzZP/265v2sHHXy9ho2nuromLiQk9Fm1SvUZcdkhitu3zSbTz0JCQ3eWl5dPbGtrUzGfcez/vjOue3tXk+ma1cdYnHTgUB/HYjWzRebj7O9eHrvv2PJ/9l1Q3q46eH/gcYrVLZcuW6aaP29eyMIFC33Y72yvK3t3p6vTsd/x3/Y+Vofj3Wfejjr4d2+Fjvphh/B/9o7xj/YHNjci9n4y20fE5trBHVaKOhyxTcDej/439/s32PFvf/49HyNzwa/vjazd/Z+P6f+ng9MKOE5EiCng0uk/wbfaQr4t5rj0QwLRyHm6WCAdaQvpPwP7nZ3l5ALjt66xjLTpV4H1W890unN9Oidw/db1xd965qS7/R5d08TJOE6dR+1THPvIR/4JRv7RbwV1i+qFeo5buKi5sTg307N8SoWn7BI9ScFJuSiOq6xqaiicNKaE3T42J8uziS7ivvP58y1eAu56WN5ET0/u3j6GqobGZhr1RGrHVNc0VVG7m9oLljQ3sPNfUNs8ez5rC5ns5kYaILVtrF3raIfy1zja6axdvXBRNbXZmBuqF1az9glqr21tqaG2qIDava11NUuofYPavgtaFtZR+y/s3oU1lU2kPjU731xTNZfajNGqG0uKs6idSkpU136rPftb7eaatmYmVFZ9Q3tjXe3cZs/AqiDPqKSkRM+8miULapqbwyZWVs2vbKz2zKpf2FC5qJ3jHDLzHyPTrScpOT4qKT4+LDo86luK+pc//sAPm1tH649F/JwJrBf+eu4fXVe/i+MSvyLd3P/Xc7O3cdzLPRxn+/lfz/k+znE6mrdDl78lj5XZy9zm5obkiAhKRMLraqrCmULvfr73gh/w+VZ/4exxd9XjmV0zp7JlQbMn01tV/YL6lkbPpobKqhrPsL814h994z8eR2gxpWeNNYvojlKysrpFtTTdi6rrmuvqF3nWLfpnk/gjb/ubj8Ou6WN6apgzzwzn9JfNnOi3FzixScWJpu2kXwR3561AUcoxzyvz+NRh9/xH8PdPFW5k/zXV1fL3ZRWXeFa1NLY6fmNuyUk4JafjzJydc+d8uEAujIvmErgUAqocLp+bwJVwU7gZXBU3l1vINXJLuOVcJ9fLrePu5zZz27nHuKe4Pdw+7gD3Mvca9yZ3ijvPXeFucu9yH3KfcL/hvuD+zLHcQSbQCEwCu8BD4CcIEUQLEgWjBDmCAkGxYIpglqBWsEjQIlguWC1YJ9gk2C54QrBH8ILgFcGbgrOCq4KfCT4SfCb4g+C2UCRUC81CN6G/MEKYKMwQjhOWCKcLa4WLhUuF3cL7hFuFu4TPCQ8J3xSeF94Ufij8jfArAnCVyCryEoWJEkVZogmiCtEcUaNopahftEW0S7RPdER0WnRd9KHoc9E3YqnYJPYUh4lTxHniyeIq8WLxSvF68XbxM+JD4hPi6+KPxF+IhyUaiaskRJIsGSspl9RKlkh6JVskT0tekpyU3JR8IvmzVCq1SgOkCdI86RTpPOky6Xrpo9L90mPSq9KPpV/JZDK7LESWJpsgq5Q1y3pl22TPyd6QXZN9IvuLXCX3kEfLx8gr5IvkXfIt8mflR+XX5J/KBxR6hZ8iWTFBUa1oV2xUPKU4oris+EQxoDQoA5RpyhLlPGWncqtyn/Kk8j3lH1UqlbcqSVWkqlOtUm1VPa86o/pI9Y3aqA5WZ6mnqVvU96l3q4+pf6b+o0aj8dekayo0zZr7NHs0b2k+0PxFa9KGa8dqq7Ud2h3aQ9pr2t/pFDo/XYZuhm6pbovuRd1l3ed6hd5fn6Wv1K/U79C/on9b/5XBZIgyTDAsNKw3PGs4a/iVUWb0N+YYq43dxieNbxk/NolMPqYsU5Vptekp00nTJ2apOcA81jzPvM78U/Ml8xcWoyXWUmpps+ywvG750Cqy+lvHWhdYN1oPWG9Zbzu5OWU41Tj1Oe1zuub0tc3Flm6rsfXb9ttu2m7bPe059vn2B+wv2993FjsHOxc5L3He6XzS+XMXs0uKS5VLv8sBl5+7Cl2DXYtdl7k+6XrB9Ss3d7dctwa3bW5vuX3ubnVPd5/n/pD7UffPPEweozzqPB7yeMPj154WzwzPBZ5bPU94fuHl6pXn1eL1hNclrwHvAO/J3l3e+73f91H6JPrM8XnI57jPF74evoW+y333+v7cT+GX6DfX72G/035f+wf4l/mv8X/Z/1cBtoCxAUsD9ga8F6gJHB24OHBX4I0gaVBi0PygR4OuBAuD44LnBu8IvhwiDIkPqQt5NORqqCQ0KXRR6K7Qt8PUYRlhrWF7wz4Kt4YXhHeFvxz+uwjfiIqIByJORwxHxkUuiHwq8t0oY1R+VFfUkag/RAdHV0XviL4Ro4kZE9MRczjmy9iQ2JrYnbHvxJniCuPWxB2PG4pPiG+M3xf/WYJvwqyERxLeTjQnTkxcn3gmSZKUmdSR9FrSN8nxyc3JB5J/nxKWMj/l2ZRfpQak1qQ+lfpxmndaZdoTaR+O8hw1a9Tjoz4c7TW6cvSu0f+V7pNenf50+qcZQRnzMp7L+F1mZGZj5kuZX2clZ63IOpYtys7N7s++lGPMmZyzPeeDMd5jasfsHfNFblzustxjeZK8cXkP5L091m1s1dg9Y7/IT8hfkX9inHrcpHHbx/1XQXBBY8GRQmFhfuGDhe+N9xu/aPzLE7gJYyc8OOH9iQETF098tUhaNLFoR9Evi6OKlxefnmSaNHPSs5P+XJJZsrHk3cmBk1smHy/VlU4r3VP6dVl22aayD8sjyleUn5/iPKVuyuEKWUVpxdMVX03Nmbp56ifT4qb1Trs1PWB62/SzM5xnLJjx+kzdzMqZL86SzCqb9eyswcoJlbsqv5o9dvYjs7+oyqp6uOo31enVD1V/VpNWs6nm0zlpczbN+VVtWu2DtZ/NHT13y9zP67Lqttd9OS9v3mPzvp4/Yf7u+VhQtmD/QvnCWQtfWWRcNH/RiXr3+rb6qw0hDb0NHy5OXrx58ReN4xqfbhI0TW863GwmMnWhJbClp+Wj1lGtO1r/sqR0yYtthrZFbRfag9v72j9dOmbpT5aJl1UtO77ca3nn8o9WZKx4YqVg5eyVxzt8Oro7PlmVu+qZTmXn/M6LXZFdm7r+tLps9ZFut+5V3R/35Pbs7dX2Nva+vSZlzWNrxWvr1l7qi+nb1jfcX91/bl3kui3rBtdXrT+3IWrD1g24b859lzbGb9x5v/T+RfffemD0A89sMmxauunjBwsfPPSQ50P9D/1p88zNZ7fEbnnsYeXDLQ9/uLVg6+Ftvtvu3za4fe72mzsyd+x/xPWRvke+frT60Ws703fue8ztsXWP3X687vF3nsh94tAu/11bnpQ+2frkL58qfer0TxJ/sudp56fXPT20e9HuD58pfubEnoQ9e551fXbjXuHelr2fPTftuSs/zf7p4X1h+57Yb92/7nnu+Zbnf/3CrBduHRh34PiLiS/uO+h38JGXTC/1HxIcaj/0xctzX/7w8JTDV1/Jf+X4kZQjL70a/uru17xe2/G65fWNR5VHu4/ijaVvfHWs4djnb9a++fHxmcfffav8rRsnik5cOjnu5JlTY069dTrj9Btn0s68djb57CvnEs+9fD7+/KELcRdeuhh38aVL8ZcOXU64fPhK0pUjV1OvHr02+tqb17Ovn7ox9sb5m+NvXr01+dY7b097+8N3qt/51c8W/OzLn7f+fODdVe9J3ut/X//+lg9cP9j1i6Bf7P8w/sPXP8r+6MJ/Tfqvdz+u+vg3/93034OfdP9S88stn3p8uudX0b967bMxn1359dRff/Kbht8MfN77W8NvH/ld4O8O/j799xe+KP/iky8bv8Qf1v/R/sfdf4r90/GvJn71wZ8X/nng6/6/2P/yzDeJ35y+XXb704Elg7LBrUNBQ0eGxw2/h4XA/wPk5EZUDk0AAA== + yCoordFlipped + -1 + + From a8b27de799784ae661479529c8bb4655a5d52570 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 9 May 2014 11:50:37 -0700 Subject: [PATCH 054/174] fix bug for y flipped coord (particle system) --- cocos/2d/CCParticleSystem.cpp | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/cocos/2d/CCParticleSystem.cpp b/cocos/2d/CCParticleSystem.cpp index 170350cc32..368e99a582 100644 --- a/cocos/2d/CCParticleSystem.cpp +++ b/cocos/2d/CCParticleSystem.cpp @@ -117,7 +117,7 @@ ParticleSystem::ParticleSystem() , _texture(nullptr) , _blendFunc(BlendFunc::ALPHA_PREMULTIPLIED) , _opacityModifyRGB(false) -, _yCoordFlipped(0) +, _yCoordFlipped(1) , _positionType(PositionType::FREE) { modeA.gravity = Vector2::ZERO; @@ -416,10 +416,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string& } } - if (!_configName.empty()) - { - _yCoordFlipped = dictionary["yCoordFlipped"].asInt(); - } + _yCoordFlipped = dictionary.find("yCoordFlipped") == dictionary.end() ? 1 : dictionary.at("yCoordFlipped").asInt(); if( !this->_texture) CCLOGWARN("cocos2d: Warning: ParticleSystemQuad system without a texture"); @@ -726,14 +723,12 @@ void ParticleSystem::update(float dt) tmp = radial + tangential + modeA.gravity; tmp = tmp * dt; p->modeA.dir = p->modeA.dir + tmp; - if (_configName.length()>0 && _yCoordFlipped != -1) - { - tmp = p->modeA.dir * -dt; - } - else - { - tmp = p->modeA.dir * dt; - } + + // this is cocos2d-x v3.0 +// if (_configName.length()>0 && _yCoordFlipped != -1) + + // this is cocos2d-x v3.0 + tmp = p->modeA.dir * dt * _yCoordFlipped; p->pos = p->pos + tmp; } @@ -746,10 +741,7 @@ void ParticleSystem::update(float dt) p->pos.x = - cosf(p->modeB.angle) * p->modeB.radius; p->pos.y = - sinf(p->modeB.angle) * p->modeB.radius; - if (_yCoordFlipped == 1) - { - p->pos.y = -p->pos.y; - } + p->pos.y *= _yCoordFlipped; } // color From 16c6b2163db885108e67e7f47e9d2b08e64e41f2 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 11:59:52 -0700 Subject: [PATCH 055/174] More VisualStudio fixes --- cocos/2d/cocos2d.vcxproj | 24 ------------------------ cocos/2d/cocos2d.vcxproj.filters | 24 ------------------------ 2 files changed, 48 deletions(-) diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj index 5ce0071f9e..55f16dd01b 100644 --- a/cocos/2d/cocos2d.vcxproj +++ b/cocos/2d/cocos2d.vcxproj @@ -273,8 +273,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - - @@ -298,8 +296,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - - @@ -478,8 +474,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - - @@ -505,24 +499,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - - - - - - - - - - - - - - - - - - diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters index 1c5ff71669..381aca0050 100644 --- a/cocos/2d/cocos2d.vcxproj.filters +++ b/cocos/2d/cocos2d.vcxproj.filters @@ -564,10 +564,6 @@ base - - - - renderer @@ -1116,26 +1112,6 @@ base - - - - - - - - - - - - - - - - - - - - renderer From 4c4a97428735f847f33ac05d923fbb6ef992813c Mon Sep 17 00:00:00 2001 From: Trace Date: Fri, 9 May 2014 12:03:09 -0700 Subject: [PATCH 056/174] use STRINGGIFY(A) instead R"" --- tests/cpp-tests/Classes/ShaderTest/ShaderTest.vsh.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.vsh.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.vsh.h index e0b6231014..3193d9fe3b 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.vsh.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.vsh.h @@ -1,5 +1,5 @@ #define STRINGIFY(A) #A -static const char* shadertestvsh = R"( +static const char* shadertestvsh = STRINGIFY( attribute vec4 a_position; @@ -8,4 +8,4 @@ void main() gl_Position = CC_MVPMatrix * a_position; } -)"; \ No newline at end of file +); \ No newline at end of file From 739af170ad5b0b6972d055637a9959af9b742092 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 13:24:56 -0700 Subject: [PATCH 057/174] compiles and runs on Windows!!! --- cocos/renderer/CCGLProgram.cpp | 3 + cocos/renderer/CCGLProgramState.cpp | 94 +++++++++++++++++++---------- cocos/renderer/CCGLProgramState.h | 15 ++++- 3 files changed, 77 insertions(+), 35 deletions(-) diff --git a/cocos/renderer/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp index cc4df344e1..43a2f09e43 100644 --- a/cocos/renderer/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -34,7 +34,10 @@ THE SOFTWARE. #include "2d/uthash.h" #include "deprecated/CCString.h" #include "CCGL.h" + +#ifndef WIN32 #include +#endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) #include "CCPrecompiledShaders.h" diff --git a/cocos/renderer/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp index 5e2b349f08..8487312a12 100644 --- a/cocos/renderer/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -55,12 +55,14 @@ UniformValue::UniformValue(Uniform *uniform, GLProgram* glprogram) UniformValue::~UniformValue() { + if (_useCallback) + delete _value.callback; } void UniformValue::apply() { if(_useCallback) { - _value.callback(_uniform); + (*_value.callback)(_uniform); } else { @@ -75,15 +77,15 @@ void UniformValue::apply() break; case GL_FLOAT_VEC2: - _glprogram->setUniformLocationWith2f(_uniform->location, _value.v2Value.x, _value.v2Value.y); + _glprogram->setUniformLocationWith2f(_uniform->location, _value.v2Value[0], _value.v2Value[1]); break; case GL_FLOAT_VEC3: - _glprogram->setUniformLocationWith3f(_uniform->location, _value.v3Value.x, _value.v3Value.y, _value.v3Value.z); + _glprogram->setUniformLocationWith3f(_uniform->location, _value.v3Value[0], _value.v3Value[1], _value.v3Value[2]); break; case GL_FLOAT_VEC4: - _glprogram->setUniformLocationWith4f(_uniform->location, _value.v4Value.x, _value.v4Value.y, _value.v4Value.z, _value.v4Value.w); + _glprogram->setUniformLocationWith4f(_uniform->location, _value.v4Value[0], _value.v4Value[1], _value.v4Value[2], _value.v4Value[3]); break; case GL_FLOAT_MAT4: @@ -99,7 +101,16 @@ void UniformValue::apply() void UniformValue::setCallback(const std::function &callback) { - _value.callback = callback; + // delete previously set callback + // XXX TODO: memory will leak if the user does: + // value->setCallback(); + // value->setFloat(); + if (_useCallback) + delete _value.callback; + + _value.callback = new std::function(); + *_value.callback = callback; + _useCallback = true; } @@ -120,29 +131,29 @@ void UniformValue::setInt(int value) void UniformValue::setVec2(const Vector2& value) { CCASSERT (_uniform->type == GL_FLOAT_VEC2, ""); - _value.v2Value = value; + memcpy(_value.v2Value, &value, sizeof(_value.v2Value)); _useCallback = false; } void UniformValue::setVec3(const Vector3& value) { CCASSERT (_uniform->type == GL_FLOAT_VEC3, ""); - _value.v3Value = value; - _useCallback = false; + memcpy(_value.v3Value, &value, sizeof(_value.v3Value)); + _useCallback = false; } void UniformValue::setVec4(const Vector4& value) { CCASSERT (_uniform->type == GL_FLOAT_VEC4, ""); - _value.v4Value = value; - _useCallback = false; + memcpy(_value.v4Value, &value, sizeof(_value.v4Value)); + _useCallback = false; } void UniformValue::setMat4(const Matrix& value) { CCASSERT(_uniform->type == GL_FLOAT_MAT4, ""); - _value.matrixValue = value; - _useCallback = false; + memcpy(_value.matrixValue, &value, sizeof(_value.matrixValue)); + _useCallback = false; } // @@ -165,12 +176,14 @@ VertexAttribValue::VertexAttribValue(VertexAttrib *vertexAttrib) VertexAttribValue::~VertexAttribValue() { + if (_useCallback) + delete _value.callback; } void VertexAttribValue::apply() { if(_useCallback) { - _value.callback(_vertexAttrib); + (*_value.callback)(_vertexAttrib); } else { @@ -185,7 +198,8 @@ void VertexAttribValue::apply() void VertexAttribValue::setCallback(const std::function &callback) { - _value.callback = callback; + _value.callback = new std::function(); + *_value.callback = callback; _useCallback = true; } @@ -325,8 +339,8 @@ void GLProgramState::setVertexAttribCallback(const std::string &name, const std: } else { - CCASSERT(false, "attribute not found"); - } + CCLOG("cocos2d: warning: Attribute not found: %s", name.c_str()); + } } void GLProgramState::setVertexAttribPointer(const std::string &name, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer) @@ -338,7 +352,7 @@ void GLProgramState::setVertexAttribPointer(const std::string &name, GLint size, } else { - CCASSERT(false, "attribute not found"); + CCLOG("cocos2d: warning: Attribute not found: %s", name.c_str()); } } @@ -347,51 +361,67 @@ void GLProgramState::setVertexAttribPointer(const std::string &name, GLint size, void GLProgramState::setUniformCallback(const std::string &uniformName, const std::function &callback) { auto v = getUniformValue(uniformName); - CCASSERT(v, "unknown uniform value"); - v->setCallback(callback); + if (v) + v->setCallback(callback); + else + CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); } void GLProgramState::setUniformFloat(const std::string &uniformName, float value) { auto v = getUniformValue(uniformName); - CCASSERT(v, "unknown uniform value"); - v->setFloat(value); + if (v) + v->setFloat(value); + else + CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); + } void GLProgramState::setUniformInt(const std::string &uniformName, int value) { auto v = getUniformValue(uniformName); - CCASSERT(v, "unknown uniform value"); - v->setInt(value); + if(v) + v->setInt(value); + else + CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); + } void GLProgramState::setUniformVec2(const std::string &uniformName, const Vector2& value) { auto v = getUniformValue(uniformName); - CCASSERT(v, "unknown uniform value"); - v->setVec2(value); + if (v) + v->setVec2(value); + else + CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); + } void GLProgramState::setUniformVec3(const std::string &uniformName, const Vector3& value) { auto v = getUniformValue(uniformName); - CCASSERT(v, "unknown uniform value"); - v->setVec3(value); + if (v) + v->setVec3(value); + else + CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); } void GLProgramState::setUniformVec4(const std::string &uniformName, const Vector4& value) { auto v = getUniformValue(uniformName); - CCASSERT(v, "unknown uniform value"); - v->setVec4(value); + if (v) + v->setVec4(value); + else + CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); } void GLProgramState::setUniformMat4(const std::string &uniformName, const Matrix& value) { auto v = getUniformValue(uniformName); - CCASSERT(v, "unknown uniform value"); - v->setMat4(value); + if (v) + v->setMat4(value); + else + CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); } - NS_CC_END diff --git a/cocos/renderer/CCGLProgramState.h b/cocos/renderer/CCGLProgramState.h index 97f4dc5a1c..f68745911e 100644 --- a/cocos/renderer/CCGLProgramState.h +++ b/cocos/renderer/CCGLProgramState.h @@ -69,14 +69,23 @@ protected: bool _useCallback; union U{ - float floatValue; +#ifndef WIN32 + float floatValue; int intValue; Vector2 v2Value; Vector3 v3Value; Vector4 v4Value; Matrix matrixValue; std::function callback; - +#else + float floatValue; + int intValue; + float v2Value[2]; + float v3Value[3]; + float v4Value[4]; + float matrixValue[16]; + std::function *callback; +#endif U() { memset( this, 0, sizeof(*this) ); } ~U(){} U& operator=( const U& other ) { @@ -117,7 +126,7 @@ protected: GLsizei stride; GLvoid *pointer; } pointer; - std::function callback; + std::function *callback; U() { memset( this, 0, sizeof(*this) ); } ~U(){} From 879958855b37767bebad4999d90aacaf5f870b8b Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 9 May 2014 14:38:36 -0700 Subject: [PATCH 058/174] UniformValue use union array --- cocos/Android.mk | 12 ++++++++---- cocos/renderer/CCGLProgramState.h | 11 +---------- tools/cocos2d-console | 2 +- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/cocos/Android.mk b/cocos/Android.mk index bdd8f7bc73..3898dbeb33 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -8,9 +8,9 @@ LOCAL_MODULE_FILENAME := libcocos2d LOCAL_SRC_FILES := \ cocos2d.cpp \ +2d/CCAction.cpp \ 2d/CCActionCamera.cpp \ 2d/CCActionCatmullRom.cpp \ -2d/CCAction.cpp \ 2d/CCActionEase.cpp \ 2d/CCActionGrid3D.cpp \ 2d/CCActionGrid.cpp \ @@ -37,8 +37,6 @@ cocos2d.cpp \ 2d/CCFontFNT.cpp \ 2d/CCFontFreeType.cpp \ 2d/CCGLBufferedNode.cpp \ -2d/CCGLProgram.cpp \ -2d/ccGLStateCache.cpp \ 2d/CCGrabber.cpp \ 2d/CCGrid.cpp \ 2d/CCIMEDispatcher.cpp \ @@ -135,12 +133,18 @@ base/base64.cpp \ base/ccTypes.cpp \ base/etc1.cpp \ base/s3tc.cpp \ +renderer/CCBatchCommand.cpp \ renderer/CCCustomCommand.cpp \ +renderer/CCGLProgram.cpp \ +renderer/CCGLProgramState.cpp \ +renderer/CCGLProgramStateCache.cpp \ +renderer/CCGLStateCache.cpp \ renderer/CCGroupCommand.cpp \ renderer/CCQuadCommand.cpp \ -renderer/CCBatchCommand.cpp \ renderer/CCRenderCommand.cpp \ renderer/CCRenderer.cpp \ +renderer/CCShaderCache.cpp \ +renderer/CCShaderCache.cpp \ deprecated/CCArray.cpp \ deprecated/CCSet.cpp \ deprecated/CCString.cpp \ diff --git a/cocos/renderer/CCGLProgramState.h b/cocos/renderer/CCGLProgramState.h index f68745911e..98c6f26ac4 100644 --- a/cocos/renderer/CCGLProgramState.h +++ b/cocos/renderer/CCGLProgramState.h @@ -69,15 +69,6 @@ protected: bool _useCallback; union U{ -#ifndef WIN32 - float floatValue; - int intValue; - Vector2 v2Value; - Vector3 v3Value; - Vector4 v4Value; - Matrix matrixValue; - std::function callback; -#else float floatValue; int intValue; float v2Value[2]; @@ -85,7 +76,7 @@ protected: float v4Value[4]; float matrixValue[16]; std::function *callback; -#endif + U() { memset( this, 0, sizeof(*this) ); } ~U(){} U& operator=( const U& other ) { diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 7876808788..4dbfa174de 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 7876808788c0666d5f4510ea214e97e10eeaa9a8 +Subproject commit 4dbfa174debb2e98422510d7e0490b1ddb2a0b3d From 47f6f8871fd73114a5d329866a932a4f2c07bd06 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 14:43:20 -0700 Subject: [PATCH 059/174] compiles on windows --- tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 085e53b434..25af88ac72 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -723,6 +723,8 @@ bool UniformShaderNode::initWithVertex(const char *vert, const char *frag) _vertFileName = vert; _fragFileName = frag; + + return true; } void UniformShaderNode::loadShaderVertex(const char *vert, const char *frag) From 4c623f1f5ec6269a197689257307cc59015d6aea Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 15:14:50 -0700 Subject: [PATCH 060/174] compiles and runs on Windows Phone 8 What's missing is to have the pre-compiled shaders from MS to test the the ShaderTest --- cocos/2d/cocos2d_wp8.vcxproj | 42 ++++-- cocos/2d/cocos2d_wp8.vcxproj.filters | 132 ++++++++++++++---- .../platform/winrt/CCPrecompiledShaders.cpp | 2 +- 3 files changed, 140 insertions(+), 36 deletions(-) diff --git a/cocos/2d/cocos2d_wp8.vcxproj b/cocos/2d/cocos2d_wp8.vcxproj index 0168beeb97..62c951f214 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj +++ b/cocos/2d/cocos2d_wp8.vcxproj @@ -270,10 +270,16 @@ + + + + + + @@ -320,8 +326,6 @@ - - @@ -345,8 +349,6 @@ - - @@ -494,11 +496,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -530,8 +560,6 @@ - - @@ -558,8 +586,6 @@ - - diff --git a/cocos/2d/cocos2d_wp8.vcxproj.filters b/cocos/2d/cocos2d_wp8.vcxproj.filters index 2fe7279e70..58d4bf9436 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj.filters +++ b/cocos/2d/cocos2d_wp8.vcxproj.filters @@ -58,9 +58,6 @@ {5b082c5c-d396-43ca-b3b1-997d0f6247d0} - - {163895ae-8a8e-46bf-bdf2-98bb2c1347fc} - {1179d205-d065-49f0-8457-bc4c3f1d0cb3} @@ -103,6 +100,9 @@ {9bbf7050-757b-41b1-ab15-418db52c2023} + + {3237780d-1154-4049-bf53-151c421f26e9} + @@ -276,18 +276,6 @@ platform - - shaders - - - shaders - - - shaders - - - shaders - sprite_nodes @@ -600,6 +588,24 @@ base + + renderer + + + renderer + + + renderer + + + renderer + + + renderer + + + renderer + @@ -809,18 +815,6 @@ platform - - shaders - - - shaders - - - shaders - - - shaders - sprite_nodes @@ -1186,6 +1180,90 @@ base + + renderer + + + renderer + + + renderer + + + renderer + + + renderer + + + renderer + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + diff --git a/cocos/2d/platform/winrt/CCPrecompiledShaders.cpp b/cocos/2d/platform/winrt/CCPrecompiledShaders.cpp index a1d82a0c01..3ec3131651 100644 --- a/cocos/2d/platform/winrt/CCPrecompiledShaders.cpp +++ b/cocos/2d/platform/winrt/CCPrecompiledShaders.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCPrecompiledShaders.h" #include "CCWinRTUtils.h" -#include "CCGLProgram.h" +#include "renderer/CCGLProgram.h" #include "sha1.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) From 9cad6cf0277afb5100eed2a1edce2652078e2c84 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 15:35:53 -0700 Subject: [PATCH 061/174] removes some unused directories from the propery sheet ... for Visual Studio --- cocos/2d/cocos2d_headers.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/2d/cocos2d_headers.props b/cocos/2d/cocos2d_headers.props index 76fa51e023..51362bbae4 100644 --- a/cocos/2d/cocos2d_headers.props +++ b/cocos/2d/cocos2d_headers.props @@ -7,7 +7,7 @@ - $(EngineRoot)cocos;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath;$(EngineRoot)cocos\2d\platform\win32;$(EngineRoot)cocos\2d\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES + $(EngineRoot)cocos;$(EngineRoot)cocos\2d\platform\win32;$(EngineRoot)cocos\2d\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES _VARIADIC_MAX=10;%(PreprocessorDefinitions) From 808561705a13a3335f6ad49390dcc52b251bbac8 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 15:40:48 -0700 Subject: [PATCH 062/174] new files for template --- templates/cocos2dx_files.json | 70 +++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 287e5e013b..7a2219b17e 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -103,8 +103,6 @@ "cocos/2d/CCFontFreeType.h", "cocos/2d/CCGLBufferedNode.cpp", "cocos/2d/CCGLBufferedNode.h", - "cocos/2d/CCGLProgram.cpp", - "cocos/2d/CCGLProgram.h", "cocos/2d/CCGrabber.cpp", "cocos/2d/CCGrabber.h", "cocos/2d/CCGrid.cpp", @@ -153,8 +151,6 @@ "cocos/2d/CCScene.h", "cocos/2d/CCScriptSupport.cpp", "cocos/2d/CCScriptSupport.h", - "cocos/2d/CCShaderCache.cpp", - "cocos/2d/CCShaderCache.h", "cocos/2d/CCSprite.cpp", "cocos/2d/CCSprite.h", "cocos/2d/CCSpriteBatchNode.cpp", @@ -202,32 +198,6 @@ "cocos/2d/ccCArray.h", "cocos/2d/ccFPSImages.c", "cocos/2d/ccFPSImages.h", - "cocos/2d/ccGLStateCache.cpp", - "cocos/2d/ccGLStateCache.h", - "cocos/2d/ccShader_Label_frag_df.h", - "cocos/2d/ccShader_Label_frag_df_glow.h", - "cocos/2d/ccShader_Label_frag_normal.h", - "cocos/2d/ccShader_Label_frag_outline.h", - "cocos/2d/ccShader_Label_vert.h", - "cocos/2d/ccShader_PositionColorLengthTexture_frag.h", - "cocos/2d/ccShader_PositionColorLengthTexture_vert.h", - "cocos/2d/ccShader_PositionColor_frag.h", - "cocos/2d/ccShader_PositionColor_vert.h", - "cocos/2d/ccShader_PositionTextureA8Color_frag.h", - "cocos/2d/ccShader_PositionTextureA8Color_vert.h", - "cocos/2d/ccShader_PositionTextureColorAlphaTest_frag.h", - "cocos/2d/ccShader_PositionTextureColor_frag.h", - "cocos/2d/ccShader_PositionTextureColor_noMVP_frag.h", - "cocos/2d/ccShader_PositionTextureColor_noMVP_vert.h", - "cocos/2d/ccShader_PositionTextureColor_vert.h", - "cocos/2d/ccShader_PositionTexture_frag.h", - "cocos/2d/ccShader_PositionTexture_uColor_frag.h", - "cocos/2d/ccShader_PositionTexture_uColor_vert.h", - "cocos/2d/ccShader_PositionTexture_vert.h", - "cocos/2d/ccShader_Position_uColor_frag.h", - "cocos/2d/ccShader_Position_uColor_vert.h", - "cocos/2d/ccShaders.cpp", - "cocos/2d/ccShaders.h", "cocos/2d/ccUTF8.cpp", "cocos/2d/ccUTF8.h", "cocos/2d/ccUtils.cpp", @@ -880,6 +850,12 @@ "cocos/renderer/CCBatchCommand.h", "cocos/renderer/CCCustomCommand.cpp", "cocos/renderer/CCCustomCommand.h", + "cocos/renderer/CCGLProgram.cpp", + "cocos/renderer/CCGLProgram.h", + "cocos/renderer/CCGLProgramState.cpp", + "cocos/renderer/CCGLProgramState.h", + "cocos/renderer/CCGLProgramStateCache.cpp", + "cocos/renderer/CCGLProgramStateCache.h", "cocos/renderer/CCGroupCommand.cpp", "cocos/renderer/CCGroupCommand.h", "cocos/renderer/CCQuadCommand.cpp", @@ -889,7 +865,35 @@ "cocos/renderer/CCRenderCommandPool.h", "cocos/renderer/CCRenderer.cpp", "cocos/renderer/CCRenderer.h", + "cocos/renderer/CCShaderCache.cpp", + "cocos/renderer/CCShaderCache.h", "cocos/renderer/CMakeLists.txt", + "cocos/renderer/ccGLStateCache.cpp", + "cocos/renderer/ccGLStateCache.h", + "cocos/renderer/ccShader_Label_frag_df.h", + "cocos/renderer/ccShader_Label_frag_df_glow.h", + "cocos/renderer/ccShader_Label_frag_normal.h", + "cocos/renderer/ccShader_Label_frag_outline.h", + "cocos/renderer/ccShader_Label_vert.h", + "cocos/renderer/ccShader_PositionColorLengthTexture_frag.h", + "cocos/renderer/ccShader_PositionColorLengthTexture_vert.h", + "cocos/renderer/ccShader_PositionColor_frag.h", + "cocos/renderer/ccShader_PositionColor_vert.h", + "cocos/renderer/ccShader_PositionTextureA8Color_frag.h", + "cocos/renderer/ccShader_PositionTextureA8Color_vert.h", + "cocos/renderer/ccShader_PositionTextureColorAlphaTest_frag.h", + "cocos/renderer/ccShader_PositionTextureColor_frag.h", + "cocos/renderer/ccShader_PositionTextureColor_noMVP_frag.h", + "cocos/renderer/ccShader_PositionTextureColor_noMVP_vert.h", + "cocos/renderer/ccShader_PositionTextureColor_vert.h", + "cocos/renderer/ccShader_PositionTexture_frag.h", + "cocos/renderer/ccShader_PositionTexture_uColor_frag.h", + "cocos/renderer/ccShader_PositionTexture_uColor_vert.h", + "cocos/renderer/ccShader_PositionTexture_vert.h", + "cocos/renderer/ccShader_Position_uColor_frag.h", + "cocos/renderer/ccShader_Position_uColor_vert.h", + "cocos/renderer/ccShaders.cpp", + "cocos/renderer/ccShaders.h", "cocos/storage/CMakeLists.txt", "cocos/storage/local-storage/Android.mk", "cocos/storage/local-storage/LocalStorage.cpp", @@ -1126,8 +1130,10 @@ "external/Box2D/Rope/b2Rope.h", "external/Box2D/proj.win32/Box2D.vcxproj", "external/Box2D/proj.win32/Box2D.vcxproj.filters", + "external/Box2D/proj.win32/Box2D.vcxproj.user", "external/Box2D/proj.wp8/Box2D.vcxproj", "external/Box2D/proj.wp8/Box2D.vcxproj.filters", + "external/Box2D/proj.wp8/Box2D.vcxproj.user", "external/chipmunk/Android.mk", "external/chipmunk/LICENSE.txt", "external/chipmunk/README.txt", @@ -1159,10 +1165,12 @@ "external/chipmunk/include/chipmunk/cpVect.h", "external/chipmunk/proj.win32/chipmunk.vcxproj", "external/chipmunk/proj.win32/chipmunk.vcxproj.filters", + "external/chipmunk/proj.win32/chipmunk.vcxproj.user", "external/chipmunk/proj.winrt/chipmunk.vcxproj", "external/chipmunk/proj.winrt/chipmunk.vcxproj.filters", "external/chipmunk/proj.wp8/chipmunk.vcxproj", "external/chipmunk/proj.wp8/chipmunk.vcxproj.filters", + "external/chipmunk/proj.wp8/chipmunk.vcxproj.user", "external/chipmunk/src/CMakeLists.txt", "external/chipmunk/src/chipmunk.c", "external/chipmunk/src/constraints/cpConstraint.c", @@ -2034,7 +2042,7 @@ "external/unzip/ioapi.h", "external/unzip/unzip.cpp", "external/unzip/unzip.h", - "external/version.json", + "external/version.txt", "external/webp/include/android/decode.h", "external/webp/include/android/encode.h", "external/webp/include/android/types.h", From 877d8dd77125a9ce6adf33724ed10a615b6a69d7 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 9 May 2014 15:59:49 -0700 Subject: [PATCH 063/174] android works!! --- cocos/2d/platform/android/Android.mk | 3 ++- cocos/2d/platform/android/java/project.properties | 2 +- .../java/src/org/cocos2dx/lib/Cocos2dxVideoView.java | 7 ++++++- cocos/Android.mk | 4 +--- tests/cpp-tests/proj.android/project.properties | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cocos/2d/platform/android/Android.mk b/cocos/2d/platform/android/Android.mk index 244d5a85f5..ee3a4c6ccb 100644 --- a/cocos/2d/platform/android/Android.mk +++ b/cocos/2d/platform/android/Android.mk @@ -29,7 +29,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../.. \ $(LOCAL_PATH)/../../../base \ $(LOCAL_PATH)/../../../math \ - $(LOCAL_PATH)/../../../physics + $(LOCAL_PATH)/../../../physics \ + $(LOCAL_PATH)/../../../renderer LOCAL_LDLIBS := -lGLESv1_CM \ -lGLESv2 \ diff --git a/cocos/2d/platform/android/java/project.properties b/cocos/2d/platform/android/java/project.properties index 88ca83f9d0..61afc8fe54 100644 --- a/cocos/2d/platform/android/java/project.properties +++ b/cocos/2d/platform/android/java/project.properties @@ -12,4 +12,4 @@ android.library=true # Project target. -target=android-10 +target=android-19 diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java index 1679051a11..7ea5c007f7 100644 --- a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java +++ b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java @@ -682,5 +682,10 @@ public class Cocos2dxVideoView extends SurfaceView implements MediaPlayerControl // TODO Auto-generated method stub return true; } - + + @Override + public int getAudioSessionId () { + // TODO Auto-generated method stub + return 0; + } } diff --git a/cocos/Android.mk b/cocos/Android.mk index 3898dbeb33..60cc78bb1c 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -60,8 +60,6 @@ cocos2d.cpp \ 2d/CCRenderTexture.cpp \ 2d/CCScene.cpp \ 2d/CCScriptSupport.cpp \ -2d/CCShaderCache.cpp \ -2d/ccShaders.cpp \ 2d/CCSpriteBatchNode.cpp \ 2d/CCSprite.cpp \ 2d/CCSpriteFrameCache.cpp \ @@ -144,7 +142,7 @@ renderer/CCQuadCommand.cpp \ renderer/CCRenderCommand.cpp \ renderer/CCRenderer.cpp \ renderer/CCShaderCache.cpp \ -renderer/CCShaderCache.cpp \ +renderer/CCShaders.cpp \ deprecated/CCArray.cpp \ deprecated/CCSet.cpp \ deprecated/CCString.cpp \ diff --git a/tests/cpp-tests/proj.android/project.properties b/tests/cpp-tests/proj.android/project.properties index 16f145cfc9..5a1770fd8f 100644 --- a/tests/cpp-tests/proj.android/project.properties +++ b/tests/cpp-tests/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-10 +target=android-19 android.library.reference.1=../../../cocos/2d/platform/android/java From fec1b82c0a5257526deb41e11420f6a9762ba7b6 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 16:45:42 -0700 Subject: [PATCH 064/174] Shader files use STRINGIFY --- build/cocos2d_libs.xcodeproj/project.pbxproj | 248 ++++++++---------- ...tionTexture_frag.h => ccShader_Label.vert} | 34 ++- cocos/renderer/ccShader_Label_df.frag | 26 ++ cocos/renderer/ccShader_Label_df_glow.frag | 26 ++ cocos/renderer/ccShader_Label_frag_df.h | 25 -- cocos/renderer/ccShader_Label_frag_df_glow.h | 25 -- cocos/renderer/ccShader_Label_frag_normal.h | 42 --- cocos/renderer/ccShader_Label_frag_outline.h | 25 -- cocos/renderer/ccShader_Label_normal.frag | 42 +++ cocos/renderer/ccShader_Label_outline.frag | 25 ++ cocos/renderer/ccShader_Label_vert.h | 45 ---- ...lor_frag.h => ccShader_PositionColor.frag} | 25 +- ...MVP_frag.h => ccShader_PositionColor.vert} | 31 ++- .../ccShader_PositionColorLengthTexture.frag | 42 +++ .../ccShader_PositionColorLengthTexture.vert | 49 ++++ ...ccShader_PositionColorLengthTexture_frag.h | 41 --- ...ccShader_PositionColorLengthTexture_vert.h | 47 ---- ...r_frag.h => ccShader_PositionTexture.frag} | 26 +- ...r_frag.h => ccShader_PositionTexture.vert} | 31 ++- ...h => ccShader_PositionTextureA8Color.frag} | 33 +-- .../ccShader_PositionTextureA8Color.vert | 46 ++++ .../ccShader_PositionTextureA8Color_frag.h | 41 --- .../ccShader_PositionTextureA8Color_vert.h | 45 ---- .../ccShader_PositionTextureColor.frag | 39 +++ .../ccShader_PositionTextureColor.vert | 46 ++++ ...Shader_PositionTextureColorAlphaTest.frag} | 42 +-- ...hader_PositionTextureColorAlphaTest_frag.h | 47 ---- .../ccShader_PositionTextureColor_noMVP.frag | 40 +++ .../ccShader_PositionTextureColor_noMVP.vert | 45 ++++ ...ccShader_PositionTextureColor_noMVP_vert.h | 45 ---- .../ccShader_PositionTextureColor_vert.h | 45 ---- .../ccShader_PositionTexture_uColor.frag | 42 +++ .../ccShader_PositionTexture_uColor.vert | 42 +++ .../ccShader_PositionTexture_uColor_vert.h | 41 --- .../renderer/ccShader_PositionTexture_vert.h | 41 --- cocos/renderer/ccShader_Position_uColor.frag | 38 +++ cocos/renderer/ccShader_Position_uColor.vert | 44 ++++ .../renderer/ccShader_Position_uColor_vert.h | 43 --- cocos/renderer/ccShaders.cpp | 73 ++---- templates/cocos2dx_files.json | 44 ++-- 40 files changed, 879 insertions(+), 898 deletions(-) rename cocos/renderer/{ccShader_PositionTexture_frag.h => ccShader_Label.vert} (75%) create mode 100644 cocos/renderer/ccShader_Label_df.frag create mode 100644 cocos/renderer/ccShader_Label_df_glow.frag delete mode 100644 cocos/renderer/ccShader_Label_frag_df.h delete mode 100644 cocos/renderer/ccShader_Label_frag_df_glow.h delete mode 100644 cocos/renderer/ccShader_Label_frag_normal.h delete mode 100644 cocos/renderer/ccShader_Label_frag_outline.h create mode 100644 cocos/renderer/ccShader_Label_normal.frag create mode 100644 cocos/renderer/ccShader_Label_outline.frag delete mode 100644 cocos/renderer/ccShader_Label_vert.h rename cocos/renderer/{ccShader_Position_uColor_frag.h => ccShader_PositionColor.frag} (83%) rename cocos/renderer/{ccShader_PositionTextureColor_noMVP_frag.h => ccShader_PositionColor.vert} (76%) create mode 100644 cocos/renderer/ccShader_PositionColorLengthTexture.frag create mode 100644 cocos/renderer/ccShader_PositionColorLengthTexture.vert delete mode 100644 cocos/renderer/ccShader_PositionColorLengthTexture_frag.h delete mode 100644 cocos/renderer/ccShader_PositionColorLengthTexture_vert.h rename cocos/renderer/{ccShader_PositionColor_frag.h => ccShader_PositionTexture.frag} (81%) rename cocos/renderer/{ccShader_PositionTextureColor_frag.h => ccShader_PositionTexture.vert} (76%) rename cocos/renderer/{ccShader_PositionTexture_uColor_frag.h => ccShader_PositionTextureA8Color.frag} (76%) create mode 100644 cocos/renderer/ccShader_PositionTextureA8Color.vert delete mode 100644 cocos/renderer/ccShader_PositionTextureA8Color_frag.h delete mode 100644 cocos/renderer/ccShader_PositionTextureA8Color_vert.h create mode 100644 cocos/renderer/ccShader_PositionTextureColor.frag create mode 100644 cocos/renderer/ccShader_PositionTextureColor.vert rename cocos/renderer/{ccShader_PositionColor_vert.h => ccShader_PositionTextureColorAlphaTest.frag} (66%) delete mode 100644 cocos/renderer/ccShader_PositionTextureColorAlphaTest_frag.h create mode 100644 cocos/renderer/ccShader_PositionTextureColor_noMVP.frag create mode 100644 cocos/renderer/ccShader_PositionTextureColor_noMVP.vert delete mode 100644 cocos/renderer/ccShader_PositionTextureColor_noMVP_vert.h delete mode 100644 cocos/renderer/ccShader_PositionTextureColor_vert.h create mode 100644 cocos/renderer/ccShader_PositionTexture_uColor.frag create mode 100644 cocos/renderer/ccShader_PositionTexture_uColor.vert delete mode 100644 cocos/renderer/ccShader_PositionTexture_uColor_vert.h delete mode 100644 cocos/renderer/ccShader_PositionTexture_vert.h create mode 100644 cocos/renderer/ccShader_Position_uColor.frag create mode 100644 cocos/renderer/ccShader_Position_uColor.vert delete mode 100644 cocos/renderer/ccShader_Position_uColor_vert.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 33a32c6c8e..780efa2102 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1566,50 +1566,42 @@ 5034CA1E191D591100CE6051 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9F9191D591000CE6051 /* CCShaderCache.h */; }; 5034CA1F191D591100CE6051 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9FA191D591000CE6051 /* CCShaderCache.cpp */; }; 5034CA20191D591100CE6051 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9FA191D591000CE6051 /* CCShaderCache.cpp */; }; - 5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h */; }; - 5034CA22191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h */; }; - 5034CA23191D591100CE6051 /* ccShader_PositionTextureColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FC191D591000CE6051 /* ccShader_PositionTextureColor_vert.h */; }; - 5034CA24191D591100CE6051 /* ccShader_PositionTextureColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FC191D591000CE6051 /* ccShader_PositionTextureColor_vert.h */; }; - 5034CA25191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FD191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h */; }; - 5034CA26191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FD191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h */; }; - 5034CA27191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FE191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h */; }; - 5034CA28191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FE191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h */; }; - 5034CA29191D591100CE6051 /* ccShader_PositionTextureColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FF191D591000CE6051 /* ccShader_PositionTextureColor_frag.h */; }; - 5034CA2A191D591100CE6051 /* ccShader_PositionTextureColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FF191D591000CE6051 /* ccShader_PositionTextureColor_frag.h */; }; - 5034CA2B191D591100CE6051 /* ccShader_PositionTextureA8Color_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color_vert.h */; }; - 5034CA2C191D591100CE6051 /* ccShader_PositionTextureA8Color_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color_vert.h */; }; - 5034CA2D191D591100CE6051 /* ccShader_PositionTextureA8Color_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color_frag.h */; }; - 5034CA2E191D591100CE6051 /* ccShader_PositionTextureA8Color_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color_frag.h */; }; - 5034CA2F191D591100CE6051 /* ccShader_PositionTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA02191D591000CE6051 /* ccShader_PositionTexture_vert.h */; }; - 5034CA30191D591100CE6051 /* ccShader_PositionTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA02191D591000CE6051 /* ccShader_PositionTexture_vert.h */; }; - 5034CA31191D591100CE6051 /* ccShader_PositionTexture_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA03191D591000CE6051 /* ccShader_PositionTexture_uColor_vert.h */; }; - 5034CA32191D591100CE6051 /* ccShader_PositionTexture_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA03191D591000CE6051 /* ccShader_PositionTexture_uColor_vert.h */; }; - 5034CA33191D591100CE6051 /* ccShader_PositionTexture_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA04191D591000CE6051 /* ccShader_PositionTexture_uColor_frag.h */; }; - 5034CA34191D591100CE6051 /* ccShader_PositionTexture_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA04191D591000CE6051 /* ccShader_PositionTexture_uColor_frag.h */; }; - 5034CA35191D591100CE6051 /* ccShader_PositionTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA05191D591000CE6051 /* ccShader_PositionTexture_frag.h */; }; - 5034CA36191D591100CE6051 /* ccShader_PositionTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA05191D591000CE6051 /* ccShader_PositionTexture_frag.h */; }; - 5034CA37191D591100CE6051 /* ccShader_PositionColorLengthTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA06191D591000CE6051 /* ccShader_PositionColorLengthTexture_vert.h */; }; - 5034CA38191D591100CE6051 /* ccShader_PositionColorLengthTexture_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA06191D591000CE6051 /* ccShader_PositionColorLengthTexture_vert.h */; }; - 5034CA39191D591100CE6051 /* ccShader_PositionColorLengthTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA07191D591000CE6051 /* ccShader_PositionColorLengthTexture_frag.h */; }; - 5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA07191D591000CE6051 /* ccShader_PositionColorLengthTexture_frag.h */; }; - 5034CA3B191D591100CE6051 /* ccShader_PositionColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA08191D591000CE6051 /* ccShader_PositionColor_vert.h */; }; - 5034CA3C191D591100CE6051 /* ccShader_PositionColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA08191D591000CE6051 /* ccShader_PositionColor_vert.h */; }; - 5034CA3D191D591100CE6051 /* ccShader_PositionColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA09191D591000CE6051 /* ccShader_PositionColor_frag.h */; }; - 5034CA3E191D591100CE6051 /* ccShader_PositionColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA09191D591000CE6051 /* ccShader_PositionColor_frag.h */; }; - 5034CA3F191D591100CE6051 /* ccShader_Position_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0A191D591000CE6051 /* ccShader_Position_uColor_vert.h */; }; - 5034CA40191D591100CE6051 /* ccShader_Position_uColor_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0A191D591000CE6051 /* ccShader_Position_uColor_vert.h */; }; - 5034CA41191D591100CE6051 /* ccShader_Position_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0B191D591000CE6051 /* ccShader_Position_uColor_frag.h */; }; - 5034CA42191D591100CE6051 /* ccShader_Position_uColor_frag.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0B191D591000CE6051 /* ccShader_Position_uColor_frag.h */; }; - 5034CA43191D591100CE6051 /* ccShader_Label_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0C191D591000CE6051 /* ccShader_Label_vert.h */; }; - 5034CA44191D591100CE6051 /* ccShader_Label_vert.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0C191D591000CE6051 /* ccShader_Label_vert.h */; }; - 5034CA45191D591100CE6051 /* ccShader_Label_frag_outline.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0D191D591000CE6051 /* ccShader_Label_frag_outline.h */; }; - 5034CA46191D591100CE6051 /* ccShader_Label_frag_outline.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0D191D591000CE6051 /* ccShader_Label_frag_outline.h */; }; - 5034CA47191D591100CE6051 /* ccShader_Label_frag_normal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0E191D591000CE6051 /* ccShader_Label_frag_normal.h */; }; - 5034CA48191D591100CE6051 /* ccShader_Label_frag_normal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0E191D591000CE6051 /* ccShader_Label_frag_normal.h */; }; - 5034CA49191D591100CE6051 /* ccShader_Label_frag_df.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0F191D591000CE6051 /* ccShader_Label_frag_df.h */; }; - 5034CA4A191D591100CE6051 /* ccShader_Label_frag_df.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0F191D591000CE6051 /* ccShader_Label_frag_df.h */; }; - 5034CA4B191D591100CE6051 /* ccShader_Label_frag_df_glow.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA10191D591000CE6051 /* ccShader_Label_frag_df_glow.h */; }; - 5034CA4C191D591100CE6051 /* ccShader_Label_frag_df_glow.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA10191D591000CE6051 /* ccShader_Label_frag_df_glow.h */; }; + 5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */; }; + 5034CA22191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */; }; + 5034CA2B191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color.vert */; }; + 5034CA2C191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color.vert */; }; + 5034CA2D191D591100CE6051 /* ccShader_PositionTextureA8Color.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color.frag */; }; + 5034CA2E191D591100CE6051 /* ccShader_PositionTextureA8Color.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color.frag */; }; + 5034CA2F191D591100CE6051 /* ccShader_PositionTexture.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA02191D591000CE6051 /* ccShader_PositionTexture.vert */; }; + 5034CA30191D591100CE6051 /* ccShader_PositionTexture.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA02191D591000CE6051 /* ccShader_PositionTexture.vert */; }; + 5034CA31191D591100CE6051 /* ccShader_PositionTexture_uColor.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA03191D591000CE6051 /* ccShader_PositionTexture_uColor.vert */; }; + 5034CA32191D591100CE6051 /* ccShader_PositionTexture_uColor.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA03191D591000CE6051 /* ccShader_PositionTexture_uColor.vert */; }; + 5034CA33191D591100CE6051 /* ccShader_PositionTexture_uColor.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA04191D591000CE6051 /* ccShader_PositionTexture_uColor.frag */; }; + 5034CA34191D591100CE6051 /* ccShader_PositionTexture_uColor.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA04191D591000CE6051 /* ccShader_PositionTexture_uColor.frag */; }; + 5034CA35191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA05191D591000CE6051 /* ccShader_PositionTexture.frag */; }; + 5034CA36191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA05191D591000CE6051 /* ccShader_PositionTexture.frag */; }; + 5034CA37191D591100CE6051 /* ccShader_PositionColorLengthTexture.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA06191D591000CE6051 /* ccShader_PositionColorLengthTexture.vert */; }; + 5034CA38191D591100CE6051 /* ccShader_PositionColorLengthTexture.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA06191D591000CE6051 /* ccShader_PositionColorLengthTexture.vert */; }; + 5034CA39191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA07191D591000CE6051 /* ccShader_PositionColorLengthTexture.frag */; }; + 5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA07191D591000CE6051 /* ccShader_PositionColorLengthTexture.frag */; }; + 5034CA3B191D591100CE6051 /* ccShader_PositionColor.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA08191D591000CE6051 /* ccShader_PositionColor.vert */; }; + 5034CA3C191D591100CE6051 /* ccShader_PositionColor.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA08191D591000CE6051 /* ccShader_PositionColor.vert */; }; + 5034CA3D191D591100CE6051 /* ccShader_PositionColor.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA09191D591000CE6051 /* ccShader_PositionColor.frag */; }; + 5034CA3E191D591100CE6051 /* ccShader_PositionColor.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA09191D591000CE6051 /* ccShader_PositionColor.frag */; }; + 5034CA3F191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0A191D591000CE6051 /* ccShader_Position_uColor.vert */; }; + 5034CA40191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0A191D591000CE6051 /* ccShader_Position_uColor.vert */; }; + 5034CA41191D591100CE6051 /* ccShader_Position_uColor.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0B191D591000CE6051 /* ccShader_Position_uColor.frag */; }; + 5034CA42191D591100CE6051 /* ccShader_Position_uColor.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0B191D591000CE6051 /* ccShader_Position_uColor.frag */; }; + 5034CA43191D591100CE6051 /* ccShader_Label.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0C191D591000CE6051 /* ccShader_Label.vert */; }; + 5034CA44191D591100CE6051 /* ccShader_Label.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0C191D591000CE6051 /* ccShader_Label.vert */; }; + 5034CA45191D591100CE6051 /* ccShader_Label_outline.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0D191D591000CE6051 /* ccShader_Label_outline.frag */; }; + 5034CA46191D591100CE6051 /* ccShader_Label_outline.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0D191D591000CE6051 /* ccShader_Label_outline.frag */; }; + 5034CA47191D591100CE6051 /* ccShader_Label_normal.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0E191D591000CE6051 /* ccShader_Label_normal.frag */; }; + 5034CA48191D591100CE6051 /* ccShader_Label_normal.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0E191D591000CE6051 /* ccShader_Label_normal.frag */; }; + 5034CA49191D591100CE6051 /* ccShader_Label_df.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0F191D591000CE6051 /* ccShader_Label_df.frag */; }; + 5034CA4A191D591100CE6051 /* ccShader_Label_df.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0F191D591000CE6051 /* ccShader_Label_df.frag */; }; + 5034CA4B191D591100CE6051 /* ccShader_Label_df_glow.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA10191D591000CE6051 /* ccShader_Label_df_glow.frag */; }; + 5034CA4C191D591100CE6051 /* ccShader_Label_df_glow.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA10191D591000CE6051 /* ccShader_Label_df_glow.frag */; }; 5034CA4D191D591100CE6051 /* ccGLStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA11191D591000CE6051 /* ccGLStateCache.h */; }; 5034CA4E191D591100CE6051 /* ccGLStateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA11191D591000CE6051 /* ccGLStateCache.h */; }; 5034CA4F191D591100CE6051 /* ccGLStateCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034CA12191D591000CE6051 /* ccGLStateCache.cpp */; }; @@ -2678,28 +2670,24 @@ 5034C9F8191D591000CE6051 /* ccShaders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccShaders.cpp; sourceTree = ""; }; 5034C9F9191D591000CE6051 /* CCShaderCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCShaderCache.h; sourceTree = ""; }; 5034C9FA191D591000CE6051 /* CCShaderCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCShaderCache.cpp; sourceTree = ""; }; - 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColorAlphaTest_frag.h; sourceTree = ""; }; - 5034C9FC191D591000CE6051 /* ccShader_PositionTextureColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_vert.h; sourceTree = ""; }; - 5034C9FD191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_noMVP_vert.h; sourceTree = ""; }; - 5034C9FE191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_noMVP_frag.h; sourceTree = ""; }; - 5034C9FF191D591000CE6051 /* ccShader_PositionTextureColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureColor_frag.h; sourceTree = ""; }; - 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureA8Color_vert.h; sourceTree = ""; }; - 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTextureA8Color_frag.h; sourceTree = ""; }; - 5034CA02191D591000CE6051 /* ccShader_PositionTexture_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_vert.h; sourceTree = ""; }; - 5034CA03191D591000CE6051 /* ccShader_PositionTexture_uColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_uColor_vert.h; sourceTree = ""; }; - 5034CA04191D591000CE6051 /* ccShader_PositionTexture_uColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_uColor_frag.h; sourceTree = ""; }; - 5034CA05191D591000CE6051 /* ccShader_PositionTexture_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionTexture_frag.h; sourceTree = ""; }; - 5034CA06191D591000CE6051 /* ccShader_PositionColorLengthTexture_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColorLengthTexture_vert.h; sourceTree = ""; }; - 5034CA07191D591000CE6051 /* ccShader_PositionColorLengthTexture_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColorLengthTexture_frag.h; sourceTree = ""; }; - 5034CA08191D591000CE6051 /* ccShader_PositionColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColor_vert.h; sourceTree = ""; }; - 5034CA09191D591000CE6051 /* ccShader_PositionColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_PositionColor_frag.h; sourceTree = ""; }; - 5034CA0A191D591000CE6051 /* ccShader_Position_uColor_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Position_uColor_vert.h; sourceTree = ""; }; - 5034CA0B191D591000CE6051 /* ccShader_Position_uColor_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Position_uColor_frag.h; sourceTree = ""; }; - 5034CA0C191D591000CE6051 /* ccShader_Label_vert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_vert.h; sourceTree = ""; }; - 5034CA0D191D591000CE6051 /* ccShader_Label_frag_outline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_outline.h; sourceTree = ""; }; - 5034CA0E191D591000CE6051 /* ccShader_Label_frag_normal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_normal.h; sourceTree = ""; }; - 5034CA0F191D591000CE6051 /* ccShader_Label_frag_df.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_df.h; sourceTree = ""; }; - 5034CA10191D591000CE6051 /* ccShader_Label_frag_df_glow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShader_Label_frag_df_glow.h; sourceTree = ""; }; + 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColorAlphaTest.frag; sourceTree = ""; }; + 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureA8Color.vert; sourceTree = ""; }; + 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureA8Color.frag; sourceTree = ""; }; + 5034CA02191D591000CE6051 /* ccShader_PositionTexture.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTexture.vert; sourceTree = ""; }; + 5034CA03191D591000CE6051 /* ccShader_PositionTexture_uColor.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTexture_uColor.vert; sourceTree = ""; }; + 5034CA04191D591000CE6051 /* ccShader_PositionTexture_uColor.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTexture_uColor.frag; sourceTree = ""; }; + 5034CA05191D591000CE6051 /* ccShader_PositionTexture.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTexture.frag; sourceTree = ""; }; + 5034CA06191D591000CE6051 /* ccShader_PositionColorLengthTexture.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionColorLengthTexture.vert; sourceTree = ""; }; + 5034CA07191D591000CE6051 /* ccShader_PositionColorLengthTexture.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionColorLengthTexture.frag; sourceTree = ""; }; + 5034CA08191D591000CE6051 /* ccShader_PositionColor.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionColor.vert; sourceTree = ""; }; + 5034CA09191D591000CE6051 /* ccShader_PositionColor.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionColor.frag; sourceTree = ""; }; + 5034CA0A191D591000CE6051 /* ccShader_Position_uColor.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_Position_uColor.vert; sourceTree = ""; }; + 5034CA0B191D591000CE6051 /* ccShader_Position_uColor.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_Position_uColor.frag; sourceTree = ""; }; + 5034CA0C191D591000CE6051 /* ccShader_Label.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_Label.vert; sourceTree = ""; }; + 5034CA0D191D591000CE6051 /* ccShader_Label_outline.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_Label_outline.frag; sourceTree = ""; }; + 5034CA0E191D591000CE6051 /* ccShader_Label_normal.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_Label_normal.frag; sourceTree = ""; }; + 5034CA0F191D591000CE6051 /* ccShader_Label_df.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_Label_df.frag; sourceTree = ""; }; + 5034CA10191D591000CE6051 /* ccShader_Label_df_glow.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_Label_df_glow.frag; sourceTree = ""; }; 5034CA11191D591000CE6051 /* ccGLStateCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccGLStateCache.h; sourceTree = ""; }; 5034CA12191D591000CE6051 /* ccGLStateCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccGLStateCache.cpp; sourceTree = ""; }; 5034CA13191D591000CE6051 /* CCGLProgramStateCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgramStateCache.h; sourceTree = ""; }; @@ -2708,6 +2696,10 @@ 5034CA16191D591000CE6051 /* CCGLProgramState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgramState.cpp; sourceTree = ""; }; 5034CA17191D591000CE6051 /* CCGLProgram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgram.h; sourceTree = ""; }; 5034CA18191D591000CE6051 /* CCGLProgram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgram.cpp; sourceTree = ""; }; + 5034CA60191D91CF00CE6051 /* ccShader_PositionTextureColor.vert */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColor.vert; sourceTree = ""; }; + 5034CA61191D91CF00CE6051 /* ccShader_PositionTextureColor.frag */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColor.frag; sourceTree = ""; }; + 5034CA62191D91CF00CE6051 /* ccShader_PositionTextureColor_noMVP.vert */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColor_noMVP.vert; sourceTree = ""; }; + 5034CA63191D91CF00CE6051 /* ccShader_PositionTextureColor_noMVP.frag */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColor_noMVP.frag; sourceTree = ""; }; 50DC5180187B817900A9C23F /* RELEASE_NOTES.md */ = {isa = PBXFileReference; lastKnownFileType = text; name = RELEASE_NOTES.md; path = ../docs/RELEASE_NOTES.md; sourceTree = ""; }; 50E6D30C18DADB5D0051CA34 /* CCProtectedNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCProtectedNode.cpp; sourceTree = ""; }; 50E6D30D18DADB5D0051CA34 /* CCProtectedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProtectedNode.h; sourceTree = ""; }; @@ -4649,28 +4641,28 @@ 5034CA5D191D591900CE6051 /* shaders */ = { isa = PBXGroup; children = ( - 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h */, - 5034C9FC191D591000CE6051 /* ccShader_PositionTextureColor_vert.h */, - 5034C9FD191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h */, - 5034C9FE191D591000CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h */, - 5034C9FF191D591000CE6051 /* ccShader_PositionTextureColor_frag.h */, - 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color_vert.h */, - 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color_frag.h */, - 5034CA02191D591000CE6051 /* ccShader_PositionTexture_vert.h */, - 5034CA03191D591000CE6051 /* ccShader_PositionTexture_uColor_vert.h */, - 5034CA04191D591000CE6051 /* ccShader_PositionTexture_uColor_frag.h */, - 5034CA05191D591000CE6051 /* ccShader_PositionTexture_frag.h */, - 5034CA06191D591000CE6051 /* ccShader_PositionColorLengthTexture_vert.h */, - 5034CA07191D591000CE6051 /* ccShader_PositionColorLengthTexture_frag.h */, - 5034CA08191D591000CE6051 /* ccShader_PositionColor_vert.h */, - 5034CA09191D591000CE6051 /* ccShader_PositionColor_frag.h */, - 5034CA0A191D591000CE6051 /* ccShader_Position_uColor_vert.h */, - 5034CA0B191D591000CE6051 /* ccShader_Position_uColor_frag.h */, - 5034CA0C191D591000CE6051 /* ccShader_Label_vert.h */, - 5034CA0D191D591000CE6051 /* ccShader_Label_frag_outline.h */, - 5034CA0E191D591000CE6051 /* ccShader_Label_frag_normal.h */, - 5034CA0F191D591000CE6051 /* ccShader_Label_frag_df.h */, - 5034CA10191D591000CE6051 /* ccShader_Label_frag_df_glow.h */, + 5034CA60191D91CF00CE6051 /* ccShader_PositionTextureColor.vert */, + 5034CA61191D91CF00CE6051 /* ccShader_PositionTextureColor.frag */, + 5034CA62191D91CF00CE6051 /* ccShader_PositionTextureColor_noMVP.vert */, + 5034CA63191D91CF00CE6051 /* ccShader_PositionTextureColor_noMVP.frag */, + 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */, + 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color.vert */, + 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color.frag */, + 5034CA02191D591000CE6051 /* ccShader_PositionTexture.vert */, + 5034CA05191D591000CE6051 /* ccShader_PositionTexture.frag */, + 5034CA03191D591000CE6051 /* ccShader_PositionTexture_uColor.vert */, + 5034CA04191D591000CE6051 /* ccShader_PositionTexture_uColor.frag */, + 5034CA06191D591000CE6051 /* ccShader_PositionColorLengthTexture.vert */, + 5034CA07191D591000CE6051 /* ccShader_PositionColorLengthTexture.frag */, + 5034CA08191D591000CE6051 /* ccShader_PositionColor.vert */, + 5034CA09191D591000CE6051 /* ccShader_PositionColor.frag */, + 5034CA0A191D591000CE6051 /* ccShader_Position_uColor.vert */, + 5034CA0B191D591000CE6051 /* ccShader_Position_uColor.frag */, + 5034CA0C191D591000CE6051 /* ccShader_Label.vert */, + 5034CA0D191D591000CE6051 /* ccShader_Label_outline.frag */, + 5034CA0E191D591000CE6051 /* ccShader_Label_normal.frag */, + 5034CA0F191D591000CE6051 /* ccShader_Label_df.frag */, + 5034CA10191D591000CE6051 /* ccShader_Label_df_glow.frag */, ); name = shaders; sourceTree = ""; @@ -4912,7 +4904,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 5034CA39191D591100CE6051 /* ccShader_PositionColorLengthTexture_frag.h in Headers */, + 5034CA39191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */, 2AC795DF18628723005EC8E1 /* SkeletonBounds.h in Headers */, 2AC795E018628723005EC8E1 /* Event.h in Headers */, 2AC795E118628723005EC8E1 /* EventData.h in Headers */, @@ -4923,7 +4915,7 @@ 06CAAAC9186AD7EE0012A414 /* TriggerMng.h in Headers */, 2905FA6018CF08D100240AA3 /* UILayoutParameter.h in Headers */, 1ABA68B01888D700007D1BB4 /* CCFontCharMap.h in Headers */, - 5034CA3F191D591100CE6051 /* ccShader_Position_uColor_vert.h in Headers */, + 5034CA3F191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */, 500DC8B419105D41007B91BF /* CCGroupCommand.h in Headers */, 500DC8D319105F7D007B91BF /* CCAffineTransform.h in Headers */, 46A170191807CBFC005B8026 /* CCCommon.h in Headers */, @@ -4961,7 +4953,7 @@ 1A57006F180BC5A10088DEC7 /* CCActionEase.h in Headers */, 1A570073180BC5A10088DEC7 /* CCActionGrid.h in Headers */, 50FCEBB518C72017004AD434 /* SliderReader.h in Headers */, - 5034CA3B191D591100CE6051 /* ccShader_PositionColor_vert.h in Headers */, + 5034CA3B191D591100CE6051 /* ccShader_PositionColor.vert in Headers */, 06CAAAD1186AD8010012A414 /* ObjectFactory.h in Headers */, 1A570077180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */, 1A57007B180BC5A10088DEC7 /* CCActionInstant.h in Headers */, @@ -4969,7 +4961,6 @@ 500DC94E19106300007B91BF /* CCEvent.h in Headers */, 1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */, 1A01C69A18F57BE800EFE3A6 /* CCSet.h in Headers */, - 5034CA23191D591100CE6051 /* ccShader_PositionTextureColor_vert.h in Headers */, 296CAD2A1915EC9900C64FBF /* CCEventListenerFocus.h in Headers */, 1A570083180BC5A10088DEC7 /* CCActionManager.h in Headers */, 1A570087180BC5A10088DEC7 /* CCActionPageTurn3D.h in Headers */, @@ -4999,7 +4990,7 @@ 500DC98219106300007B91BF /* ccMacros.h in Headers */, 1A57011D180BC90D0088DEC7 /* CCGrabber.h in Headers */, 1A570121180BC90D0088DEC7 /* CCGrid.h in Headers */, - 5034CA2D191D591100CE6051 /* ccShader_PositionTextureA8Color_frag.h in Headers */, + 5034CA2D191D591100CE6051 /* ccShader_PositionTextureA8Color.frag in Headers */, 50E6D33A18E174130051CA34 /* UIRelativeBox.h in Headers */, 500DC8C619105D41007B91BF /* CCRenderer.h in Headers */, 50E6D30F18DADB5D0051CA34 /* CCProtectedNode.h in Headers */, @@ -5012,7 +5003,7 @@ 1A01C68618F57BE800EFE3A6 /* CCArray.h in Headers */, 1A5701A7180BCB590088DEC7 /* CCFontAtlasCache.h in Headers */, 1A5701B3180BCB590088DEC7 /* CCFontFNT.h in Headers */, - 5034CA47191D591100CE6051 /* ccShader_Label_frag_normal.h in Headers */, + 5034CA47191D591100CE6051 /* ccShader_Label_normal.frag in Headers */, 1A5701B7180BCB5A0088DEC7 /* CCFontFreeType.h in Headers */, 500DC94219106300007B91BF /* CCData.h in Headers */, 1A5701BB180BCB5A0088DEC7 /* CCLabel.h in Headers */, @@ -5020,7 +5011,7 @@ 1A5701C3180BCB5A0088DEC7 /* CCLabelBMFont.h in Headers */, 500DC93A19106300007B91BF /* CCConfiguration.h in Headers */, 1A5701C9180BCB5A0088DEC7 /* CCLabelTextFormatter.h in Headers */, - 5034CA37191D591100CE6051 /* ccShader_PositionColorLengthTexture_vert.h in Headers */, + 5034CA37191D591100CE6051 /* ccShader_PositionColorLengthTexture.vert in Headers */, 1A5701CD180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */, 1A5701E0180BCB8C0088DEC7 /* CCLayer.h in Headers */, 1A5701E4180BCB8C0088DEC7 /* CCScene.h in Headers */, @@ -5041,11 +5032,11 @@ 500DC99E19106300007B91BF /* CCValue.h in Headers */, 1A01C69618F57BE800EFE3A6 /* CCInteger.h in Headers */, 1A570223180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */, - 5034CA43191D591100CE6051 /* ccShader_Label_vert.h in Headers */, + 5034CA43191D591100CE6051 /* ccShader_Label.vert in Headers */, 1A570227180BCC1A0088DEC7 /* CCParticleExamples.h in Headers */, 1A57022B180BCC1A0088DEC7 /* CCParticleSystem.h in Headers */, - 5034CA2F191D591100CE6051 /* ccShader_PositionTexture_vert.h in Headers */, - 5034CA4B191D591100CE6051 /* ccShader_Label_frag_df_glow.h in Headers */, + 5034CA2F191D591100CE6051 /* ccShader_PositionTexture.vert in Headers */, + 5034CA4B191D591100CE6051 /* ccShader_Label_df_glow.frag in Headers */, 1A57022F180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */, 500DC96A19106300007B91BF /* CCEventListenerCustom.h in Headers */, B2AF2F9718EBAEAE00C5807C /* MathUtil.h in Headers */, @@ -5053,19 +5044,19 @@ 500DC95E19106300007B91BF /* CCEventKeyboard.h in Headers */, 2905FA4218CF08D100240AA3 /* CocosGUI.h in Headers */, 500DC95A19106300007B91BF /* CCEventDispatcher.h in Headers */, - 5034CA49191D591100CE6051 /* ccShader_Label_frag_df.h in Headers */, + 5034CA49191D591100CE6051 /* ccShader_Label_df.frag in Headers */, 500DC9A019106300007B91BF /* CCVector.h in Headers */, 500DC92C19106300007B91BF /* atitc.h in Headers */, 1A01C68C18F57BE800EFE3A6 /* CCDeprecated.h in Headers */, 500DC98419106300007B91BF /* CCMap.h in Headers */, 2905FA6418CF08D100240AA3 /* UIListView.h in Headers */, 50FCEBB918C72017004AD434 /* TextAtlasReader.h in Headers */, - 5034CA3D191D591100CE6051 /* ccShader_PositionColor_frag.h in Headers */, + 5034CA3D191D591100CE6051 /* ccShader_PositionColor.frag in Headers */, 1A570280180BCC900088DEC7 /* CCSprite.h in Headers */, 1A570284180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */, 500DC9A419106300007B91BF /* etc1.h in Headers */, 5034CA55191D591100CE6051 /* CCGLProgramState.h in Headers */, - 5034CA2B191D591100CE6051 /* ccShader_PositionTextureA8Color_vert.h in Headers */, + 5034CA2B191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */, 1A570288180BCC900088DEC7 /* CCSpriteFrame.h in Headers */, 1A57028C180BCC900088DEC7 /* CCSpriteFrameCache.h in Headers */, 5027253A190BF1B900AAF4ED /* cocos2d.h in Headers */, @@ -5080,7 +5071,6 @@ 1A5702C0180BCE2A0088DEC7 /* CCIMEDelegate.h in Headers */, 2905FA7618CF08D100240AA3 /* UIScrollView.h in Headers */, 1A5702C4180BCE2A0088DEC7 /* CCIMEDispatcher.h in Headers */, - 5034CA25191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, 1A12775B18DFCC540005F345 /* CCTweenFunction.h in Headers */, 1A5702CA180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */, 1A5702D5180BCE570088DEC7 /* CCTexture2D.h in Headers */, @@ -5091,7 +5081,7 @@ 50FCEBAD18C72017004AD434 /* PageViewReader.h in Headers */, 1A5702F4180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */, 1A5702F8180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */, - 5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */, + 5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */, 1A5702FC180BCE750088DEC7 /* CCTMXXMLParser.h in Headers */, 1A570302180BCE890088DEC7 /* CCParallaxNode.h in Headers */, 1A57030E180BCF190088DEC7 /* CCComponent.h in Headers */, @@ -5123,12 +5113,11 @@ 1AD71DB9180E26E600808F54 /* CCBReader.h in Headers */, 2905FA7E18CF08D100240AA3 /* UIText.h in Headers */, 1AD71DBB180E26E600808F54 /* CCBSelectorResolver.h in Headers */, - 5034CA29191D591100CE6051 /* ccShader_PositionTextureColor_frag.h in Headers */, - 5034CA35191D591100CE6051 /* ccShader_PositionTexture_frag.h in Headers */, + 5034CA35191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */, 500DC98019106300007B91BF /* CCEventType.h in Headers */, 1AD71DBF180E26E600808F54 /* CCBSequence.h in Headers */, 1AD71DC3180E26E600808F54 /* CCBSequenceProperty.h in Headers */, - 5034CA31191D591100CE6051 /* ccShader_PositionTexture_uColor_vert.h in Headers */, + 5034CA31191D591100CE6051 /* ccShader_PositionTexture_uColor.vert in Headers */, 1AD71DCB180E26E600808F54 /* CCControlButtonLoader.h in Headers */, 1AD71DCF180E26E600808F54 /* CCControlLoader.h in Headers */, 1AD71DD3180E26E600808F54 /* CCLabelBMFontLoader.h in Headers */, @@ -5179,10 +5168,9 @@ 500DC8D919105F7D007B91BF /* CCMathBase.h in Headers */, 06CAAACD186AD7F90012A414 /* TriggerBase.h in Headers */, 1AD71ECB180E26E600808F54 /* RegionAttachment.h in Headers */, - 5034CA27191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */, 2905FA8618CF08D100240AA3 /* UITextBMFont.h in Headers */, 1AD71ECF180E26E600808F54 /* Skeleton.h in Headers */, - 5034CA41191D591100CE6051 /* ccShader_Position_uColor_frag.h in Headers */, + 5034CA41191D591100CE6051 /* ccShader_Position_uColor.frag in Headers */, 1A01C69E18F57BE800EFE3A6 /* CCString.h in Headers */, 500DC9B819106E6D007B91BF /* TransformUtils.h in Headers */, 1AD71ED3180E26E600808F54 /* SkeletonData.h in Headers */, @@ -5225,7 +5213,7 @@ 1A8C59B1180E930E00EF57C3 /* CCBatchNode.h in Headers */, 2905FA5418CF08D100240AA3 /* UIImageView.h in Headers */, 1A8C59B5180E930E00EF57C3 /* CCBone.h in Headers */, - 5034CA45191D591100CE6051 /* ccShader_Label_frag_outline.h in Headers */, + 5034CA45191D591100CE6051 /* ccShader_Label_outline.frag in Headers */, 500DC96219106300007B91BF /* CCEventListener.h in Headers */, 1A8C59B9180E930E00EF57C3 /* CCColliderDetector.h in Headers */, 1A8C59BD180E930E00EF57C3 /* CCComAttribute.h in Headers */, @@ -5242,7 +5230,7 @@ 1A8C59E1180E930E00EF57C3 /* CCInputDelegate.h in Headers */, 1A8C59E5180E930E00EF57C3 /* CCProcessBase.h in Headers */, 1A8C59E9180E930E00EF57C3 /* CCSGUIReader.h in Headers */, - 5034CA33191D591100CE6051 /* ccShader_PositionTexture_uColor_frag.h in Headers */, + 5034CA33191D591100CE6051 /* ccShader_PositionTexture_uColor.frag in Headers */, 1A8C59ED180E930E00EF57C3 /* CCSkin.h in Headers */, 5034CA1D191D591100CE6051 /* CCShaderCache.h in Headers */, 1A8C59F1180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h in Headers */, @@ -5419,7 +5407,7 @@ 50FCEBAE18C72017004AD434 /* PageViewReader.h in Headers */, 46A1703F1807CC07005B8026 /* CCDirectorCaller.h in Headers */, 46A170381807CBFE005B8026 /* CCSAXParser.h in Headers */, - 5034CA38191D591100CE6051 /* ccShader_PositionColorLengthTexture_vert.h in Headers */, + 5034CA38191D591100CE6051 /* ccShader_PositionColorLengthTexture.vert in Headers */, 500DC97319106300007B91BF /* CCEventListenerMouse.h in Headers */, 500DC99319106300007B91BF /* CCRefPtr.h in Headers */, 46A1702E1807CBFE005B8026 /* CCDevice.h in Headers */, @@ -5442,9 +5430,8 @@ 46A170271807CBFE005B8026 /* CCFileUtilsApple.h in Headers */, 46A170431807CC07005B8026 /* CCES2Renderer.h in Headers */, 46A170331807CBFE005B8026 /* CCImage.h in Headers */, - 5034CA40191D591100CE6051 /* ccShader_Position_uColor_vert.h in Headers */, + 5034CA40191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */, 2905FA5518CF08D100240AA3 /* UIImageView.h in Headers */, - 5034CA28191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_frag.h in Headers */, 46A170481807CC07005B8026 /* CCPlatformDefine.h in Headers */, 46A1704C1807CC07005B8026 /* OpenGL_Internal.h in Headers */, 46A1702C1807CBFE005B8026 /* CCApplicationProtocol.h in Headers */, @@ -5454,11 +5441,11 @@ 50FCEBC218C72017004AD434 /* TextFieldReader.h in Headers */, 1A570068180BC5A10088DEC7 /* CCActionCamera.h in Headers */, 1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */, - 5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture_frag.h in Headers */, + 5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */, 1A570070180BC5A10088DEC7 /* CCActionEase.h in Headers */, 1A570074180BC5A10088DEC7 /* CCActionGrid.h in Headers */, B37510841823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */, - 5034CA46191D591100CE6051 /* ccShader_Label_frag_outline.h in Headers */, + 5034CA46191D591100CE6051 /* ccShader_Label_outline.frag in Headers */, 1A570078180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */, 1A01C68918F57BE800EFE3A6 /* CCBool.h in Headers */, 1A57007C180BC5A10088DEC7 /* CCActionInstant.h in Headers */, @@ -5480,7 +5467,7 @@ 2905FA6D18CF08D100240AA3 /* UIPageView.h in Headers */, 2905FA7318CF08D100240AA3 /* UIScrollInterface.h in Headers */, 2905FA4318CF08D100240AA3 /* CocosGUI.h in Headers */, - 5034CA30191D591100CE6051 /* ccShader_PositionTexture_vert.h in Headers */, + 5034CA30191D591100CE6051 /* ccShader_PositionTexture.vert in Headers */, 500DC93119106300007B91BF /* base64.h in Headers */, B2AF2FA018EBAEAE00C5807C /* Quaternion.h in Headers */, 50E6D33718E174130051CA34 /* UIHBox.h in Headers */, @@ -5496,7 +5483,7 @@ 500DC8C719105D41007B91BF /* CCRenderer.h in Headers */, 500DC98519106300007B91BF /* CCMap.h in Headers */, 50FCEBBA18C72017004AD434 /* TextAtlasReader.h in Headers */, - 5034CA2E191D591100CE6051 /* ccShader_PositionTextureA8Color_frag.h in Headers */, + 5034CA2E191D591100CE6051 /* ccShader_PositionTextureA8Color.frag in Headers */, 1A5701A0180BCB590088DEC7 /* CCFont.h in Headers */, 1A5701A4180BCB590088DEC7 /* CCFontAtlas.h in Headers */, 1A5701A8180BCB590088DEC7 /* CCFontAtlasCache.h in Headers */, @@ -5505,14 +5492,14 @@ 1A5701B8180BCB5A0088DEC7 /* CCFontFreeType.h in Headers */, 1A5701BC180BCB5A0088DEC7 /* CCLabel.h in Headers */, 1A5701C0180BCB5A0088DEC7 /* CCLabelAtlas.h in Headers */, - 5034CA42191D591100CE6051 /* ccShader_Position_uColor_frag.h in Headers */, + 5034CA42191D591100CE6051 /* ccShader_Position_uColor.frag in Headers */, 500DC97719106300007B91BF /* CCEventListenerTouch.h in Headers */, 500DC93F19106300007B91BF /* CCConsole.h in Headers */, 1A5701C4180BCB5A0088DEC7 /* CCLabelBMFont.h in Headers */, 1A01C69518F57BE800EFE3A6 /* CCFloat.h in Headers */, 1A5701CA180BCB5A0088DEC7 /* CCLabelTextFormatter.h in Headers */, 2905FA7B18CF08D100240AA3 /* UISlider.h in Headers */, - 5034CA22191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest_frag.h in Headers */, + 5034CA22191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */, 1A5701CE180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */, 296CAD251915EC8000C64FBF /* CCEventFocus.h in Headers */, 50FCEBCA18C72017004AD434 /* WidgetReader.h in Headers */, @@ -5527,7 +5514,7 @@ 50FCEBBE18C72017004AD434 /* TextBMFontReader.h in Headers */, 1A5701FE180BCBAD0088DEC7 /* CCMenuItem.h in Headers */, 1A570205180BCBD40088DEC7 /* CCClippingNode.h in Headers */, - 5034CA34191D591100CE6051 /* ccShader_PositionTexture_uColor_frag.h in Headers */, + 5034CA34191D591100CE6051 /* ccShader_PositionTexture_uColor.frag in Headers */, 1A57020B180BCBDF0088DEC7 /* CCMotionStreak.h in Headers */, 1A570213180BCBF40088DEC7 /* CCProgressTimer.h in Headers */, B37510821823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */, @@ -5540,16 +5527,14 @@ 1A570228180BCC1A0088DEC7 /* CCParticleExamples.h in Headers */, 1A57022C180BCC1A0088DEC7 /* CCParticleSystem.h in Headers */, 1A570230180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */, - 5034CA24191D591100CE6051 /* ccShader_PositionTextureColor_vert.h in Headers */, - 5034CA2C191D591100CE6051 /* ccShader_PositionTextureA8Color_vert.h in Headers */, + 5034CA2C191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */, 1A570237180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */, 2905FA8B18CF08D100240AA3 /* UITextField.h in Headers */, - 5034CA26191D591100CE6051 /* ccShader_PositionTextureColor_noMVP_vert.h in Headers */, 500DC96F19106300007B91BF /* CCEventListenerKeyboard.h in Headers */, 500DC8B519105D41007B91BF /* CCGroupCommand.h in Headers */, 50FCEBA618C72017004AD434 /* ListViewReader.h in Headers */, 500DC9B919106E6D007B91BF /* TransformUtils.h in Headers */, - 5034CA4A191D591100CE6051 /* ccShader_Label_frag_df.h in Headers */, + 5034CA4A191D591100CE6051 /* ccShader_Label_df.frag in Headers */, 500DC99119106300007B91BF /* CCRef.h in Headers */, 1A570281180BCC900088DEC7 /* CCSprite.h in Headers */, 1A570285180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */, @@ -5576,7 +5561,7 @@ 1A5702ED180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */, 500DC99F19106300007B91BF /* CCValue.h in Headers */, 1A5702F1180BCE750088DEC7 /* CCTMXLayer.h in Headers */, - 5034CA44191D591100CE6051 /* ccShader_Label_vert.h in Headers */, + 5034CA44191D591100CE6051 /* ccShader_Label.vert in Headers */, 1A5702F5180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */, 1A5702F9180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */, 500DC9A119106300007B91BF /* CCVector.h in Headers */, @@ -5602,11 +5587,11 @@ 1A570357180BD0B00088DEC7 /* ioapi.h in Headers */, 1A01C69B18F57BE800EFE3A6 /* CCSet.h in Headers */, 1A57035B180BD0B00088DEC7 /* unzip.h in Headers */, - 5034CA48191D591100CE6051 /* ccShader_Label_frag_normal.h in Headers */, + 5034CA48191D591100CE6051 /* ccShader_Label_normal.frag in Headers */, 1AD71DAC180E26E600808F54 /* CCBAnimationManager.h in Headers */, 1AD71DB0180E26E600808F54 /* CCBFileLoader.h in Headers */, 1AD71DB4180E26E600808F54 /* CCBKeyframe.h in Headers */, - 5034CA3E191D591100CE6051 /* ccShader_PositionColor_frag.h in Headers */, + 5034CA3E191D591100CE6051 /* ccShader_PositionColor.frag in Headers */, 1AD71DB6180E26E600808F54 /* CCBMemberVariableAssigner.h in Headers */, 1AD71DBA180E26E600808F54 /* CCBReader.h in Headers */, 1AD71DBC180E26E600808F54 /* CCBSelectorResolver.h in Headers */, @@ -5616,9 +5601,9 @@ 1AD71DCC180E26E600808F54 /* CCControlButtonLoader.h in Headers */, 1AD71DD0180E26E600808F54 /* CCControlLoader.h in Headers */, 1AD71DD4180E26E600808F54 /* CCLabelBMFontLoader.h in Headers */, - 5034CA3C191D591100CE6051 /* ccShader_PositionColor_vert.h in Headers */, + 5034CA3C191D591100CE6051 /* ccShader_PositionColor.vert in Headers */, 46C02E0A18E91123004B7456 /* xxhash.h in Headers */, - 5034CA4C191D591100CE6051 /* ccShader_Label_frag_df_glow.h in Headers */, + 5034CA4C191D591100CE6051 /* ccShader_Label_df_glow.frag in Headers */, 50E6D33B18E174130051CA34 /* UIRelativeBox.h in Headers */, 1AD71DD8180E26E600808F54 /* CCLabelTTFLoader.h in Headers */, 1AD71DDC180E26E600808F54 /* CCLayerColorLoader.h in Headers */, @@ -5635,7 +5620,6 @@ 5027253B190BF1B900AAF4ED /* cocos2d.h in Headers */, 1AD71DFC180E26E600808F54 /* CCNodeLoaderListener.h in Headers */, 3EA0FB6B191C841D00B170C8 /* UIVideoPlayer.h in Headers */, - 5034CA2A191D591100CE6051 /* ccShader_PositionTextureColor_frag.h in Headers */, 1AD71E00180E26E600808F54 /* CCParticleSystemQuadLoader.h in Headers */, 1AD71E04180E26E600808F54 /* CCScale9SpriteLoader.h in Headers */, 1AD71E08180E26E600808F54 /* CCScrollViewLoader.h in Headers */, @@ -5655,7 +5639,7 @@ 2905FA4918CF08D100240AA3 /* UIButton.h in Headers */, 500DC96719106300007B91BF /* CCEventListenerAcceleration.h in Headers */, 1AD71EB0180E26E600808F54 /* AttachmentLoader.h in Headers */, - 5034CA32191D591100CE6051 /* ccShader_PositionTexture_uColor_vert.h in Headers */, + 5034CA32191D591100CE6051 /* ccShader_PositionTexture_uColor.vert in Headers */, 1AD71EB4180E26E600808F54 /* Bone.h in Headers */, 1AD71EB8180E26E600808F54 /* BoneData.h in Headers */, 06CAAACA186AD7EF0012A414 /* TriggerMng.h in Headers */, @@ -5697,7 +5681,7 @@ 500DC99B19106300007B91BF /* ccTypes.h in Headers */, 1A8C598E180E930E00EF57C3 /* CCActionFrame.h in Headers */, 1A8C5992180E930E00EF57C3 /* CCActionFrameEasing.h in Headers */, - 5034CA36191D591100CE6051 /* ccShader_PositionTexture_frag.h in Headers */, + 5034CA36191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */, 5034CA56191D591100CE6051 /* CCGLProgramState.h in Headers */, 1A8C5996180E930E00EF57C3 /* CCActionManagerEx.h in Headers */, 2905FA4D18CF08D100240AA3 /* UICheckBox.h in Headers */, diff --git a/cocos/renderer/ccShader_PositionTexture_frag.h b/cocos/renderer/ccShader_Label.vert similarity index 75% rename from cocos/renderer/ccShader_PositionTexture_frag.h rename to cocos/renderer/ccShader_Label.vert index 93a8f0eda6..02b3790504 100644 --- a/cocos/renderer/ccShader_PositionTexture_frag.h +++ b/cocos/renderer/ccShader_Label.vert @@ -23,16 +23,24 @@ * THE SOFTWARE. */ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D CC_Texture0; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = texture2D(CC_Texture0, v_texCoord); \n\ -} \n\ -"; +const char* ccLabel_vert = STRINGIFY( + +attribute vec4 a_position; +attribute vec2 a_texCoord; +attribute vec4 a_color; + +#ifdef GL_ES +varying lowp vec4 v_fragmentColor; +varying mediump vec2 v_texCoord; +#else +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +#endif + +void main() +{ + gl_Position = CC_MVPMatrix * a_position; + v_fragmentColor = a_color; + v_texCoord = a_texCoord; +} +); diff --git a/cocos/renderer/ccShader_Label_df.frag b/cocos/renderer/ccShader_Label_df.frag new file mode 100644 index 0000000000..31c9ec0336 --- /dev/null +++ b/cocos/renderer/ccShader_Label_df.frag @@ -0,0 +1,26 @@ +const char* ccLabelDistanceFieldNormal_frag = STRINGIFY( + +#ifdef GL_ES +precision lowp float; +#endif + +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +uniform sampler2D CC_Texture0; +uniform vec4 v_textColor; + +void main() +{ + vec4 color = texture2D(CC_Texture0, v_texCoord); + //the texture use dual channel 16-bit output for distance_map + //float dist = color.b+color.g/256.0; + // the texture use single channel 8-bit output for distance_map + float dist = color.a; + //todo:Implementation 'fwidth' for glsl 1.0 + //float width = fwidth(dist); + //assign width for constant will lead to a little bit fuzzy,it's temporary measure. + float width = 0.04; + float alpha = smoothstep(0.5-width, 0.5+width, dist) * v_textColor.a; + gl_FragColor = v_fragmentColor * vec4(v_textColor.rgb,alpha); +} +); diff --git a/cocos/renderer/ccShader_Label_df_glow.frag b/cocos/renderer/ccShader_Label_df_glow.frag new file mode 100644 index 0000000000..9d6ab500af --- /dev/null +++ b/cocos/renderer/ccShader_Label_df_glow.frag @@ -0,0 +1,26 @@ +const char* ccLabelDistanceFieldGlow_frag = STRINGIFY( + +#ifdef GL_ES +precision lowp float; +#endif + +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +uniform sampler2D CC_Texture0; +uniform vec4 v_effectColor; +uniform vec4 v_textColor; + +void main() +{ + float dist = texture2D(CC_Texture0, v_texCoord).a; + //todo:Implementation 'fwidth' for glsl 1.0 + //float width = fwidth(dist); + //assign width for constant will lead to a little bit fuzzy,it's temporary measure. + float width = 0.04; + float alpha = smoothstep(0.5-width, 0.5+width, dist); + //glow + float mu = smoothstep(0.5, 1.0, sqrt(dist)); + vec4 color = v_effectColor*(1.0-alpha) + v_textColor*alpha; + gl_FragColor = v_fragmentColor * vec4(color.rgb, max(alpha,mu)*color.a); +} +); diff --git a/cocos/renderer/ccShader_Label_frag_df.h b/cocos/renderer/ccShader_Label_frag_df.h deleted file mode 100644 index 30ff80cdc4..0000000000 --- a/cocos/renderer/ccShader_Label_frag_df.h +++ /dev/null @@ -1,25 +0,0 @@ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D CC_Texture0; \n\ -uniform vec4 v_textColor; \n\ - \n\ -void main() \n\ -{ \n\ - vec4 color = texture2D(CC_Texture0, v_texCoord); \n\ - //the texture use dual channel 16-bit output for distance_map \n\ - //float dist = color.b+color.g/256.0; \n\ - // the texture use single channel 8-bit output for distance_map \n\ - float dist = color.a; \n\ - //todo:Implementation 'fwidth' for glsl 1.0 \n\ - //float width = fwidth(dist); \n\ - //assign width for constant will lead to a little bit fuzzy,it's temporary measure.\n\ - float width = 0.04; \n\ - float alpha = smoothstep(0.5-width, 0.5+width, dist) * v_textColor.a; \n\ - gl_FragColor = v_fragmentColor * vec4(v_textColor.rgb,alpha); \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_Label_frag_df_glow.h b/cocos/renderer/ccShader_Label_frag_df_glow.h deleted file mode 100644 index d481f4c0b7..0000000000 --- a/cocos/renderer/ccShader_Label_frag_df_glow.h +++ /dev/null @@ -1,25 +0,0 @@ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D CC_Texture0; \n\ -uniform vec4 v_effectColor; \n\ -uniform vec4 v_textColor; \n\ - \n\ -void main() \n\ -{ \n\ - float dist = texture2D(CC_Texture0, v_texCoord).a; \n\ - //todo:Implementation 'fwidth' for glsl 1.0 \n\ - //float width = fwidth(dist); \n\ - //assign width for constant will lead to a little bit fuzzy,it's temporary measure.\n\ - float width = 0.04; \n\ - float alpha = smoothstep(0.5-width, 0.5+width, dist); \n\ - //glow \n\ - float mu = smoothstep(0.5, 1.0, sqrt(dist)); \n\ - vec4 color = v_effectColor*(1.0-alpha) + v_textColor*alpha; \n\ - gl_FragColor = v_fragmentColor * vec4(color.rgb, max(alpha,mu)*color.a); \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_Label_frag_normal.h b/cocos/renderer/ccShader_Label_frag_normal.h deleted file mode 100644 index 26623a3024..0000000000 --- a/cocos/renderer/ccShader_Label_frag_normal.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2011 Ricardo Quesada - * Copyright (c) 2012 Zynga Inc. - * - * 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. - */ - -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D CC_Texture0; \n\ -uniform vec4 v_textColor; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = v_fragmentColor * vec4( v_textColor.rgb, // RGB from uniform \n\ - v_textColor.a * texture2D(CC_Texture0, v_texCoord).a // A from texture & uniform \n\ - ); \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_Label_frag_outline.h b/cocos/renderer/ccShader_Label_frag_outline.h deleted file mode 100644 index ca3972a474..0000000000 --- a/cocos/renderer/ccShader_Label_frag_outline.h +++ /dev/null @@ -1,25 +0,0 @@ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D CC_Texture0; \n\ -uniform vec4 v_effectColor; \n\ -uniform vec4 v_textColor; \n\ - \n\ -void main() \n\ -{ \n\ - vec4 sample = texture2D(CC_Texture0, v_texCoord); \n\ - float fontAlpha = sample.a; \n\ - float outlineAlpha = sample.r; \n\ - if (outlineAlpha > 0.0){ \n\ - vec4 color = v_textColor * fontAlpha + v_effectColor * (1.0 - fontAlpha);\n\ - gl_FragColor = v_fragmentColor * vec4( color.rgb,max(fontAlpha,outlineAlpha)*color.a); \n\ - } \n\ - else { \n\ - discard; \n\ - } \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_Label_normal.frag b/cocos/renderer/ccShader_Label_normal.frag new file mode 100644 index 0000000000..0d4d2788d1 --- /dev/null +++ b/cocos/renderer/ccShader_Label_normal.frag @@ -0,0 +1,42 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +const char* ccLabelNormal_frag = STRINGIFY( +#ifdef GL_ES +precision lowp float; +#endif + +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +uniform sampler2D CC_Texture0; +uniform vec4 v_textColor; + +void main() +{ + gl_FragColor = v_fragmentColor * vec4( v_textColor.rgb,// RGB from uniform + v_textColor.a * texture2D(CC_Texture0, v_texCoord).a// A from texture & uniform + ); +} +); diff --git a/cocos/renderer/ccShader_Label_outline.frag b/cocos/renderer/ccShader_Label_outline.frag new file mode 100644 index 0000000000..967f83c0b9 --- /dev/null +++ b/cocos/renderer/ccShader_Label_outline.frag @@ -0,0 +1,25 @@ +const char* ccLabelOutline_frag = STRINGIFY( +#ifdef GL_ES +precision lowp float; +#endif + +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +uniform sampler2D CC_Texture0; +uniform vec4 v_effectColor; +uniform vec4 v_textColor; + +void main() +{ + vec4 sample = texture2D(CC_Texture0, v_texCoord); + float fontAlpha = sample.a; + float outlineAlpha = sample.r; + if (outlineAlpha > 0.0){ + vec4 color = v_textColor * fontAlpha + v_effectColor * (1.0 - fontAlpha); + gl_FragColor = v_fragmentColor * vec4( color.rgb,max(fontAlpha,outlineAlpha)*color.a); + } + else { + discard; + } +} +); diff --git a/cocos/renderer/ccShader_Label_vert.h b/cocos/renderer/ccShader_Label_vert.h deleted file mode 100644 index f509caf016..0000000000 --- a/cocos/renderer/ccShader_Label_vert.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2011 Ricardo Quesada - * Copyright (c) 2012 Zynga Inc. - * - * 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. - */ - -" \n\ -attribute vec4 a_position; \n\ -attribute vec2 a_texCoord; \n\ -attribute vec4 a_color; \n\ - \n\ -#ifdef GL_ES \n\ -varying lowp vec4 v_fragmentColor; \n\ -varying mediump vec2 v_texCoord; \n\ -#else \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = CC_MVPMatrix * a_position; \n\ - v_fragmentColor = a_color; \n\ - v_texCoord = a_texCoord; \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_Position_uColor_frag.h b/cocos/renderer/ccShader_PositionColor.frag similarity index 83% rename from cocos/renderer/ccShader_Position_uColor_frag.h rename to cocos/renderer/ccShader_PositionColor.frag index d882c88f76..a42854f1fb 100644 --- a/cocos/renderer/ccShader_Position_uColor_frag.h +++ b/cocos/renderer/ccShader_PositionColor.frag @@ -23,15 +23,16 @@ * THE SOFTWARE. */ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = v_fragmentColor; \n\ -} \n\ -"; +const char* ccPositionColor_frag = STRINGIFY( + +#ifdef GL_ES +precision lowp float; +#endif + +varying vec4 v_fragmentColor; + +void main() +{ + gl_FragColor = v_fragmentColor; +} +); diff --git a/cocos/renderer/ccShader_PositionTextureColor_noMVP_frag.h b/cocos/renderer/ccShader_PositionColor.vert similarity index 76% rename from cocos/renderer/ccShader_PositionTextureColor_noMVP_frag.h rename to cocos/renderer/ccShader_PositionColor.vert index df5527ef56..fd1694df4e 100644 --- a/cocos/renderer/ccShader_PositionTextureColor_noMVP_frag.h +++ b/cocos/renderer/ccShader_PositionColor.vert @@ -23,17 +23,20 @@ * THE SOFTWARE. */ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D CC_Texture0; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n\ -} \n\ -"; +const char* ccPositionColor_vert = STRINGIFY( + +attribute vec4 a_position; +attribute vec4 a_color; + +#ifdef GL_ES +varying lowp vec4 v_fragmentColor; +#else +varying vec4 v_fragmentColor; +#endif + +void main() +{ + gl_Position = CC_MVPMatrix * a_position; + v_fragmentColor = a_color; +} +); diff --git a/cocos/renderer/ccShader_PositionColorLengthTexture.frag b/cocos/renderer/ccShader_PositionColorLengthTexture.frag new file mode 100644 index 0000000000..e47ebf20c3 --- /dev/null +++ b/cocos/renderer/ccShader_PositionColorLengthTexture.frag @@ -0,0 +1,42 @@ +/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software + * + * 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. + */ + +const char* ccPositionColorLengthTexture_frag = STRINGIFY( + +#ifdef GL_ES +// #extension GL_OES_standard_derivatives : enable + +varying mediump vec4 v_color; +varying mediump vec2 v_texcoord; +#else +varying vec4 v_color; +varying vec2 v_texcoord; +#endif + +void main() +{ +// #if defined GL_OES_standard_derivatives +// gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); +// #else + gl_FragColor = v_color*step(0.0, 1.0 - length(v_texcoord)); +// #endif +} +); diff --git a/cocos/renderer/ccShader_PositionColorLengthTexture.vert b/cocos/renderer/ccShader_PositionColorLengthTexture.vert new file mode 100644 index 0000000000..0693b74659 --- /dev/null +++ b/cocos/renderer/ccShader_PositionColorLengthTexture.vert @@ -0,0 +1,49 @@ +/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software + * + * 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. + */ + +const char* ccPositionColorLengthTexture_vert = STRINGIFY( + +#ifdef GL_ES +attribute mediump vec4 a_position; +attribute mediump vec2 a_texcoord; +attribute mediump vec4 a_color; + +varying mediump vec4 v_color; +varying mediump vec2 v_texcoord; + +#else + +attribute vec4 a_position; +attribute vec2 a_texcoord; +attribute vec4 a_color; + +varying vec4 v_color; +varying vec2 v_texcoord; +#endif + +void main() +{ + v_color = vec4(a_color.rgb * a_color.a, a_color.a); + v_texcoord = a_texcoord; + + gl_Position = CC_MVPMatrix * a_position; +} +); diff --git a/cocos/renderer/ccShader_PositionColorLengthTexture_frag.h b/cocos/renderer/ccShader_PositionColorLengthTexture_frag.h deleted file mode 100644 index 803664a506..0000000000 --- a/cocos/renderer/ccShader_PositionColorLengthTexture_frag.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -" \n\ -#ifdef GL_ES \n\ -// #extension GL_OES_standard_derivatives : enable \n\ - \n\ -varying mediump vec4 v_color; \n\ -varying mediump vec2 v_texcoord; \n\ -#else \n\ -varying vec4 v_color; \n\ -varying vec2 v_texcoord; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ -// #if defined GL_OES_standard_derivatives \n\ - // gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); \n\ -// #else \n\ - gl_FragColor = v_color*step(0.0, 1.0 - length(v_texcoord)); \n\ -// #endif \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_PositionColorLengthTexture_vert.h b/cocos/renderer/ccShader_PositionColorLengthTexture_vert.h deleted file mode 100644 index 3a8e96d467..0000000000 --- a/cocos/renderer/ccShader_PositionColorLengthTexture_vert.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -" \n\ -#ifdef GL_ES \n\ -attribute mediump vec4 a_position; \n\ -attribute mediump vec2 a_texcoord; \n\ -attribute mediump vec4 a_color; \n\ - \n\ -varying mediump vec4 v_color; \n\ -varying mediump vec2 v_texcoord; \n\ - \n\ -#else \n\ -attribute vec4 a_position; \n\ -attribute vec2 a_texcoord; \n\ -attribute vec4 a_color; \n\ - \n\ -varying vec4 v_color; \n\ -varying vec2 v_texcoord; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - v_color = vec4(a_color.rgb * a_color.a, a_color.a); \n\ - v_texcoord = a_texcoord; \n\ - \n\ - gl_Position = CC_MVPMatrix * a_position; \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_PositionColor_frag.h b/cocos/renderer/ccShader_PositionTexture.frag similarity index 81% rename from cocos/renderer/ccShader_PositionColor_frag.h rename to cocos/renderer/ccShader_PositionTexture.frag index 910903d2e7..bb072775bd 100644 --- a/cocos/renderer/ccShader_PositionColor_frag.h +++ b/cocos/renderer/ccShader_PositionTexture.frag @@ -23,15 +23,17 @@ * THE SOFTWARE. */ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = v_fragmentColor; \n\ -} \n\ -"; +const char* ccPositionTexture_frag = STRINGIFY( + +#ifdef GL_ES +precision lowp float; +#endif + +varying vec2 v_texCoord; +uniform sampler2D CC_Texture0; + +void main() +{ + gl_FragColor = texture2D(CC_Texture0, v_texCoord); +} +); diff --git a/cocos/renderer/ccShader_PositionTextureColor_frag.h b/cocos/renderer/ccShader_PositionTexture.vert similarity index 76% rename from cocos/renderer/ccShader_PositionTextureColor_frag.h rename to cocos/renderer/ccShader_PositionTexture.vert index df5527ef56..288e860505 100644 --- a/cocos/renderer/ccShader_PositionTextureColor_frag.h +++ b/cocos/renderer/ccShader_PositionTexture.vert @@ -23,17 +23,20 @@ * THE SOFTWARE. */ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D CC_Texture0; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n\ -} \n\ -"; +const char* ccPositionTexture_vert = STRINGIFY( + +attribute vec4 a_position; +attribute vec2 a_texCoord; + +#ifdef GL_ES +varying mediump vec2 v_texCoord; +#else +varying vec2 v_texCoord; +#endif + +void main() +{ + gl_Position = CC_MVPMatrix * a_position; + v_texCoord = a_texCoord; +} +); \ No newline at end of file diff --git a/cocos/renderer/ccShader_PositionTexture_uColor_frag.h b/cocos/renderer/ccShader_PositionTextureA8Color.frag similarity index 76% rename from cocos/renderer/ccShader_PositionTexture_uColor_frag.h rename to cocos/renderer/ccShader_PositionTextureA8Color.frag index a97d25077e..6c5e6cdd0a 100644 --- a/cocos/renderer/ccShader_PositionTexture_uColor_frag.h +++ b/cocos/renderer/ccShader_PositionTextureA8Color.frag @@ -23,19 +23,20 @@ * THE SOFTWARE. */ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -uniform vec4 u_color; \n\ - \n\ -varying vec2 v_texCoord; \n\ - \n\ -uniform sampler2D CC_Texture0; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = texture2D(CC_Texture0, v_texCoord) * u_color; \n\ -} \n\ -"; +const char* ccPositionTextureA8Color_frag = STRINGIFY( + +#ifdef GL_ES +precision lowp float; +#endif + +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +uniform sampler2D CC_Texture0; + +void main() +{ + gl_FragColor = vec4( v_fragmentColor.rgb,// RGB from uniform + v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a // A from texture & uniform + ); +} +); diff --git a/cocos/renderer/ccShader_PositionTextureA8Color.vert b/cocos/renderer/ccShader_PositionTextureA8Color.vert new file mode 100644 index 0000000000..a4d8a833d1 --- /dev/null +++ b/cocos/renderer/ccShader_PositionTextureA8Color.vert @@ -0,0 +1,46 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +const char* ccPositionTextureA8Color_vert = STRINGIFY( + +attribute vec4 a_position; +attribute vec2 a_texCoord; +attribute vec4 a_color; + +#ifdef GL_ES +varying lowp vec4 v_fragmentColor; +varying mediump vec2 v_texCoord; +#else +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +#endif + +void main() +{ + gl_Position = CC_MVPMatrix * a_position; + v_fragmentColor = a_color; + v_texCoord = a_texCoord; +} +); diff --git a/cocos/renderer/ccShader_PositionTextureA8Color_frag.h b/cocos/renderer/ccShader_PositionTextureA8Color_frag.h deleted file mode 100644 index 6a8fb85ae1..0000000000 --- a/cocos/renderer/ccShader_PositionTextureA8Color_frag.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2011 Ricardo Quesada - * Copyright (c) 2012 Zynga Inc. - * - * 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. - */ - -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D CC_Texture0; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = vec4( v_fragmentColor.rgb, // RGB from uniform \n\ - v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a // A from texture & uniform \n\ - ); \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_PositionTextureA8Color_vert.h b/cocos/renderer/ccShader_PositionTextureA8Color_vert.h deleted file mode 100644 index bb29e7d93a..0000000000 --- a/cocos/renderer/ccShader_PositionTextureA8Color_vert.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2011 Ricardo Quesada - * Copyright (c) 2012 Zynga Inc. - * - * 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. - */ - -" \n\ -attribute vec4 a_position; \n\ -attribute vec2 a_texCoord; \n\ -attribute vec4 a_color; \n\ - \n\ -#ifdef GL_ES \n\ -varying lowp vec4 v_fragmentColor; \n\ -varying mediump vec2 v_texCoord; \n\ -#else \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = CC_MVPMatrix * a_position; \n\ - v_fragmentColor = a_color; \n\ - v_texCoord = a_texCoord; \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_PositionTextureColor.frag b/cocos/renderer/ccShader_PositionTextureColor.frag new file mode 100644 index 0000000000..d31c530775 --- /dev/null +++ b/cocos/renderer/ccShader_PositionTextureColor.frag @@ -0,0 +1,39 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +const char* ccPositionTextureColor_frag = STRINGIFY( +#ifdef GL_ES +precision lowp float; +#endif + +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +uniform sampler2D CC_Texture0; + +void main() +{ + gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); +} +); diff --git a/cocos/renderer/ccShader_PositionTextureColor.vert b/cocos/renderer/ccShader_PositionTextureColor.vert new file mode 100644 index 0000000000..1c3128eece --- /dev/null +++ b/cocos/renderer/ccShader_PositionTextureColor.vert @@ -0,0 +1,46 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +const char* ccPositionTextureColor_vert = STRINGIFY( +attribute vec4 a_position; +attribute vec2 a_texCoord; +attribute vec4 a_color; + +#ifdef GL_ES +varying lowp vec4 v_fragmentColor; +varying mediump vec2 v_texCoord; +#else +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +#endif + +void main() +{ + gl_Position = CC_MVPMatrix * a_position; + v_fragmentColor = a_color; + v_texCoord = a_texCoord; +} +); + diff --git a/cocos/renderer/ccShader_PositionColor_vert.h b/cocos/renderer/ccShader_PositionTextureColorAlphaTest.frag similarity index 66% rename from cocos/renderer/ccShader_PositionColor_vert.h rename to cocos/renderer/ccShader_PositionTextureColorAlphaTest.frag index 633f338a9a..437c181f12 100644 --- a/cocos/renderer/ccShader_PositionColor_vert.h +++ b/cocos/renderer/ccShader_PositionTextureColorAlphaTest.frag @@ -1,8 +1,7 @@ /* * cocos2d for iPhone: http://www.cocos2d-iphone.org * - * Copyright (c) 2011 Ricardo Quesada - * Copyright (c) 2012 Zynga Inc. + * Copyright (c) 2011 Brian Chapados * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,18 +22,27 @@ * THE SOFTWARE. */ -" \n\ -attribute vec4 a_position; \n\ -attribute vec4 a_color; \n\ -#ifdef GL_ES \n\ -varying lowp vec4 v_fragmentColor; \n\ -#else \n\ -varying vec4 v_fragmentColor; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = CC_MVPMatrix * a_position; \n\ - v_fragmentColor = a_color; \n\ -} \n\ -"; +const char* ccPositionTextureColorAlphaTest_frag = STRINGIFY( + +#ifdef GL_ES +precision lowp float; +#endif + +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +uniform sampler2D CC_Texture0; +uniform float CC_alpha_value; + +void main() +{ + vec4 texColor = texture2D(CC_Texture0, v_texCoord); + +// mimic: glAlphaFunc(GL_GREATER) +// pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value + + if ( texColor.a <= CC_alpha_value ) + discard; + + gl_FragColor = texColor * v_fragmentColor; +} +); diff --git a/cocos/renderer/ccShader_PositionTextureColorAlphaTest_frag.h b/cocos/renderer/ccShader_PositionTextureColorAlphaTest_frag.h deleted file mode 100644 index fe321ba222..0000000000 --- a/cocos/renderer/ccShader_PositionTextureColorAlphaTest_frag.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2011 Brian Chapados - * - * 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. - */ - -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D CC_Texture0; \n\ -uniform float CC_alpha_value; \n\ - \n\ -void main() \n\ -{ \n\ - vec4 texColor = texture2D(CC_Texture0, v_texCoord); \n\ - \n\ - // mimic: glAlphaFunc(GL_GREATER) \n\ - // pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value \n\ - \n\ - if ( texColor.a <= CC_alpha_value ) \n\ - discard; \n\ - \n\ - gl_FragColor = texColor * v_fragmentColor; \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_PositionTextureColor_noMVP.frag b/cocos/renderer/ccShader_PositionTextureColor_noMVP.frag new file mode 100644 index 0000000000..cd37da4233 --- /dev/null +++ b/cocos/renderer/ccShader_PositionTextureColor_noMVP.frag @@ -0,0 +1,40 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +const char* ccPositionTextureColor_noMVP_frag = STRINGIFY( +#ifdef GL_ES +precision lowp float; +#endif + +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +uniform sampler2D CC_Texture0; + +void main() +{ + gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); +} +); + diff --git a/cocos/renderer/ccShader_PositionTextureColor_noMVP.vert b/cocos/renderer/ccShader_PositionTextureColor_noMVP.vert new file mode 100644 index 0000000000..9b5a226c1c --- /dev/null +++ b/cocos/renderer/ccShader_PositionTextureColor_noMVP.vert @@ -0,0 +1,45 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +const char* ccPositionTextureColor_noMVP_vert = STRINGIFY( +attribute vec4 a_position; +attribute vec2 a_texCoord; +attribute vec4 a_color; + +#ifdef GL_ES +varying lowp vec4 v_fragmentColor; +varying mediump vec2 v_texCoord; +#else +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +#endif + +void main() +{ + gl_Position = CC_PMatrix * a_position; + v_fragmentColor = a_color; + v_texCoord = a_texCoord; +} +); diff --git a/cocos/renderer/ccShader_PositionTextureColor_noMVP_vert.h b/cocos/renderer/ccShader_PositionTextureColor_noMVP_vert.h deleted file mode 100644 index f2d39c3c10..0000000000 --- a/cocos/renderer/ccShader_PositionTextureColor_noMVP_vert.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2011 Ricardo Quesada - * Copyright (c) 2012 Zynga Inc. - * - * 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. - */ - -" \n\ -attribute vec4 a_position; \n\ -attribute vec2 a_texCoord; \n\ -attribute vec4 a_color; \n\ - \n\ -#ifdef GL_ES \n\ -varying lowp vec4 v_fragmentColor; \n\ -varying mediump vec2 v_texCoord; \n\ -#else \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = CC_PMatrix * a_position; \n\ - v_fragmentColor = a_color; \n\ - v_texCoord = a_texCoord; \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_PositionTextureColor_vert.h b/cocos/renderer/ccShader_PositionTextureColor_vert.h deleted file mode 100644 index bb29e7d93a..0000000000 --- a/cocos/renderer/ccShader_PositionTextureColor_vert.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2011 Ricardo Quesada - * Copyright (c) 2012 Zynga Inc. - * - * 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. - */ - -" \n\ -attribute vec4 a_position; \n\ -attribute vec2 a_texCoord; \n\ -attribute vec4 a_color; \n\ - \n\ -#ifdef GL_ES \n\ -varying lowp vec4 v_fragmentColor; \n\ -varying mediump vec2 v_texCoord; \n\ -#else \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = CC_MVPMatrix * a_position; \n\ - v_fragmentColor = a_color; \n\ - v_texCoord = a_texCoord; \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_PositionTexture_uColor.frag b/cocos/renderer/ccShader_PositionTexture_uColor.frag new file mode 100644 index 0000000000..8b13f64bab --- /dev/null +++ b/cocos/renderer/ccShader_PositionTexture_uColor.frag @@ -0,0 +1,42 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +const char* ccPositionTexture_uColor_frag = STRINGIFY( + +#ifdef GL_ES +precision lowp float; +#endif + +uniform vec4 u_color; + +varying vec2 v_texCoord; + +uniform sampler2D CC_Texture0; + +void main() +{ + gl_FragColor = texture2D(CC_Texture0, v_texCoord) * u_color; +} +); diff --git a/cocos/renderer/ccShader_PositionTexture_uColor.vert b/cocos/renderer/ccShader_PositionTexture_uColor.vert new file mode 100644 index 0000000000..d24fbd61f8 --- /dev/null +++ b/cocos/renderer/ccShader_PositionTexture_uColor.vert @@ -0,0 +1,42 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +const char* ccPositionTexture_uColor_vert = STRINGIFY( + +attribute vec4 a_position; +attribute vec2 a_texCoord; + +#ifdef GL_ES +varying mediump vec2 v_texCoord; +#else +varying vec2 v_texCoord; +#endif + +void main() +{ + gl_Position = CC_MVPMatrix * a_position; + v_texCoord = a_texCoord; +} +); diff --git a/cocos/renderer/ccShader_PositionTexture_uColor_vert.h b/cocos/renderer/ccShader_PositionTexture_uColor_vert.h deleted file mode 100644 index 9d2bfd3e2d..0000000000 --- a/cocos/renderer/ccShader_PositionTexture_uColor_vert.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2011 Ricardo Quesada - * Copyright (c) 2012 Zynga Inc. - * - * 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. - */ - -" \n\ -attribute vec4 a_position; \n\ -attribute vec2 a_texCoord; \n\ - \n\ -#ifdef GL_ES \n\ -varying mediump vec2 v_texCoord; \n\ -#else \n\ -varying vec2 v_texCoord; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = CC_MVPMatrix * a_position; \n\ - v_texCoord = a_texCoord; \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_PositionTexture_vert.h b/cocos/renderer/ccShader_PositionTexture_vert.h deleted file mode 100644 index 1278ab0e80..0000000000 --- a/cocos/renderer/ccShader_PositionTexture_vert.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2011 Ricardo Quesada - * Copyright (c) 2012 Zynga Inc. - * - * 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. - */ - -" \n\ -attribute vec4 a_position; \n\ -attribute vec2 a_texCoord; \n\ - \n\ -#ifdef GL_ES \n\ -varying mediump vec2 v_texCoord; \n\ -#else \n\ -varying vec2 v_texCoord; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = CC_MVPMatrix * a_position; \n\ - v_texCoord = a_texCoord; \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShader_Position_uColor.frag b/cocos/renderer/ccShader_Position_uColor.frag new file mode 100644 index 0000000000..268e36ec7d --- /dev/null +++ b/cocos/renderer/ccShader_Position_uColor.frag @@ -0,0 +1,38 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +const char* ccPosition_uColor_frag = STRINGIFY( + +#ifdef GL_ES +precision lowp float; +#endif + +varying vec4 v_fragmentColor; + +void main() +{ + gl_FragColor = v_fragmentColor; +} +); diff --git a/cocos/renderer/ccShader_Position_uColor.vert b/cocos/renderer/ccShader_Position_uColor.vert new file mode 100644 index 0000000000..63301dc1b6 --- /dev/null +++ b/cocos/renderer/ccShader_Position_uColor.vert @@ -0,0 +1,44 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +const char* ccPosition_uColor_vert = STRINGIFY( + +attribute vec4 a_position; +uniform vec4 u_color; +uniform float u_pointSize; + +#ifdef GL_ES +varying lowp vec4 v_fragmentColor; +#else +varying vec4 v_fragmentColor; +#endif + +void main() +{ + gl_Position = CC_MVPMatrix * a_position; + gl_PointSize = u_pointSize; + v_fragmentColor = u_color; +} +); diff --git a/cocos/renderer/ccShader_Position_uColor_vert.h b/cocos/renderer/ccShader_Position_uColor_vert.h deleted file mode 100644 index c50e38b3f8..0000000000 --- a/cocos/renderer/ccShader_Position_uColor_vert.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2011 Ricardo Quesada - * Copyright (c) 2012 Zynga Inc. - * - * 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. - */ - -" \n\ -attribute vec4 a_position; \n\ -uniform vec4 u_color; \n\ -uniform float u_pointSize; \n\ - \n\ -#ifdef GL_ES \n\ -varying lowp vec4 v_fragmentColor; \n\ -#else \n\ -varying vec4 v_fragmentColor; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = CC_MVPMatrix * a_position; \n\ - gl_PointSize = u_pointSize; \n\ - v_fragmentColor = u_color; \n\ -} \n\ -"; diff --git a/cocos/renderer/ccShaders.cpp b/cocos/renderer/ccShaders.cpp index af48caa9fd..4f825e9c75 100644 --- a/cocos/renderer/ccShaders.cpp +++ b/cocos/renderer/ccShaders.cpp @@ -26,71 +26,48 @@ THE SOFTWARE. #include "renderer/ccShaders.h" +#define STRINGIFY(A) #A + NS_CC_BEGIN // -const GLchar * ccPosition_uColor_frag = -#include "ccShader_Position_uColor_frag.h" -const GLchar * ccPosition_uColor_vert = -#include "ccShader_Position_uColor_vert.h" +#include "ccShader_Position_uColor.frag" +#include "ccShader_Position_uColor.vert" // -const GLchar * ccPositionColor_frag = -#include "ccShader_PositionColor_frag.h" -const GLchar * ccPositionColor_vert = -#include "ccShader_PositionColor_vert.h" +#include "ccShader_PositionColor.frag" +#include "ccShader_PositionColor.vert" // -const GLchar * ccPositionTexture_frag = -#include "ccShader_PositionTexture_frag.h" -const GLchar * ccPositionTexture_vert = -#include "ccShader_PositionTexture_vert.h" +#include "ccShader_PositionTexture.frag" +#include "ccShader_PositionTexture.vert" // -const GLchar * ccPositionTextureA8Color_frag = -#include "ccShader_PositionTextureA8Color_frag.h" -const GLchar * ccPositionTextureA8Color_vert = -#include "ccShader_PositionTextureA8Color_vert.h" +#include "ccShader_PositionTextureA8Color.frag" +#include "ccShader_PositionTextureA8Color.vert" // -const GLchar * ccPositionTextureColor_frag = -#include "ccShader_PositionTextureColor_frag.h" -const GLchar * ccPositionTextureColor_vert = -#include "ccShader_PositionTextureColor_vert.h" +#include "ccShader_PositionTextureColor.frag" +#include "ccShader_PositionTextureColor.vert" // -const GLchar * ccPositionTextureColor_noMVP_frag = -#include "ccShader_PositionTextureColor_noMVP_frag.h" -const GLchar * ccPositionTextureColor_noMVP_vert = -#include "ccShader_PositionTextureColor_noMVP_vert.h" +#include "ccShader_PositionTextureColor_noMVP.frag" +#include "ccShader_PositionTextureColor_noMVP.vert" // -const GLchar * ccPositionTextureColorAlphaTest_frag = -#include "ccShader_PositionTextureColorAlphaTest_frag.h" +#include "ccShader_PositionTextureColorAlphaTest.frag" // -const GLchar * ccPositionTexture_uColor_frag = -#include "ccShader_PositionTexture_uColor_frag.h" -const GLchar * ccPositionTexture_uColor_vert = -#include "ccShader_PositionTexture_uColor_vert.h" +#include "ccShader_PositionTexture_uColor.frag" +#include "ccShader_PositionTexture_uColor.vert" -const GLchar * ccPositionColorLengthTexture_frag = -#include "ccShader_PositionColorLengthTexture_frag.h" -const GLchar * ccPositionColorLengthTexture_vert = -#include "ccShader_PositionColorLengthTexture_vert.h" +#include "ccShader_PositionColorLengthTexture.frag" +#include "ccShader_PositionColorLengthTexture.vert" -const GLchar * ccLabelDistanceFieldNormal_frag = -#include "ccShader_Label_frag_df.h" - -const GLchar * ccLabelDistanceFieldGlow_frag = -#include "ccShader_Label_frag_df_glow.h" - -const GLchar * ccLabelNormal_frag = -#include "ccShader_Label_frag_normal.h" - -const GLchar * ccLabelOutline_frag = -#include "ccShader_Label_frag_outline.h" - -const GLchar * ccLabel_vert = -#include "ccShader_Label_vert.h" +// +#include "ccShader_Label.vert" +#include "ccShader_Label_df.frag" +#include "ccShader_Label_df_glow.frag" +#include "ccShader_Label_normal.frag" +#include "ccShader_Label_outline.frag" NS_CC_END diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 7a2219b17e..ed840d9629 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -870,28 +870,28 @@ "cocos/renderer/CMakeLists.txt", "cocos/renderer/ccGLStateCache.cpp", "cocos/renderer/ccGLStateCache.h", - "cocos/renderer/ccShader_Label_frag_df.h", - "cocos/renderer/ccShader_Label_frag_df_glow.h", - "cocos/renderer/ccShader_Label_frag_normal.h", - "cocos/renderer/ccShader_Label_frag_outline.h", - "cocos/renderer/ccShader_Label_vert.h", - "cocos/renderer/ccShader_PositionColorLengthTexture_frag.h", - "cocos/renderer/ccShader_PositionColorLengthTexture_vert.h", - "cocos/renderer/ccShader_PositionColor_frag.h", - "cocos/renderer/ccShader_PositionColor_vert.h", - "cocos/renderer/ccShader_PositionTextureA8Color_frag.h", - "cocos/renderer/ccShader_PositionTextureA8Color_vert.h", - "cocos/renderer/ccShader_PositionTextureColorAlphaTest_frag.h", - "cocos/renderer/ccShader_PositionTextureColor_frag.h", - "cocos/renderer/ccShader_PositionTextureColor_noMVP_frag.h", - "cocos/renderer/ccShader_PositionTextureColor_noMVP_vert.h", - "cocos/renderer/ccShader_PositionTextureColor_vert.h", - "cocos/renderer/ccShader_PositionTexture_frag.h", - "cocos/renderer/ccShader_PositionTexture_uColor_frag.h", - "cocos/renderer/ccShader_PositionTexture_uColor_vert.h", - "cocos/renderer/ccShader_PositionTexture_vert.h", - "cocos/renderer/ccShader_Position_uColor_frag.h", - "cocos/renderer/ccShader_Position_uColor_vert.h", + "cocos/renderer/ccShader_Label.vert", + "cocos/renderer/ccShader_Label_df.frag", + "cocos/renderer/ccShader_Label_df_glow.frag", + "cocos/renderer/ccShader_Label_normal.frag", + "cocos/renderer/ccShader_Label_outline.frag", + "cocos/renderer/ccShader_PositionColor.frag", + "cocos/renderer/ccShader_PositionColor.vert", + "cocos/renderer/ccShader_PositionColorLengthTexture.frag", + "cocos/renderer/ccShader_PositionColorLengthTexture.vert", + "cocos/renderer/ccShader_PositionTexture.frag", + "cocos/renderer/ccShader_PositionTexture.vert", + "cocos/renderer/ccShader_PositionTextureA8Color.frag", + "cocos/renderer/ccShader_PositionTextureA8Color.vert", + "cocos/renderer/ccShader_PositionTextureColor.frag", + "cocos/renderer/ccShader_PositionTextureColor.vert", + "cocos/renderer/ccShader_PositionTextureColorAlphaTest.frag", + "cocos/renderer/ccShader_PositionTextureColor_noMVP.frag", + "cocos/renderer/ccShader_PositionTextureColor_noMVP.vert", + "cocos/renderer/ccShader_PositionTexture_uColor.frag", + "cocos/renderer/ccShader_PositionTexture_uColor.vert", + "cocos/renderer/ccShader_Position_uColor.frag", + "cocos/renderer/ccShader_Position_uColor.vert", "cocos/renderer/ccShaders.cpp", "cocos/renderer/ccShaders.h", "cocos/storage/CMakeLists.txt", From faf617bc37651b32144f1fc5f527086f035c5d8a Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 16:57:11 -0700 Subject: [PATCH 065/174] fixes for Linux --- cocos/2d/CMakeLists.txt | 46 ++++++++++++++++------------------- cocos/renderer/CMakeLists.txt | 6 +++++ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index c0fb594217..89c61a8636 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -28,12 +28,13 @@ endif() set(COCOS_2D_SRC + 2d/ccFPSImages.c + 2d/CCAction.cpp 2d/CCActionCamera.cpp 2d/CCActionCatmullRom.cpp - 2d/CCAction.cpp 2d/CCActionEase.cpp - 2d/CCActionGrid3D.cpp 2d/CCActionGrid.cpp + 2d/CCActionGrid3D.cpp 2d/CCActionInstant.cpp 2d/CCActionInterval.cpp 2d/CCActionManager.cpp @@ -41,32 +42,29 @@ set(COCOS_2D_SRC 2d/CCActionProgressTimer.cpp 2d/CCActionTiledGrid.cpp 2d/CCActionTween.cpp - 2d/CCAnimationCache.cpp 2d/CCAnimation.cpp + 2d/CCAnimationCache.cpp 2d/CCAtlasNode.cpp - 2d/ccCArray.cpp 2d/CCClippingNode.cpp - 2d/CCComponentContainer.cpp 2d/CCComponent.cpp - 2d/CCDrawingPrimitives.cpp + 2d/CCComponentContainer.cpp 2d/CCDrawNode.cpp - 2d/CCFontAtlasCache.cpp - 2d/CCFontAtlas.cpp - 2d/CCFontCharMap.cpp + 2d/CCDrawingPrimitives.cpp 2d/CCFont.cpp + 2d/CCFontAtlas.cpp + 2d/CCFontAtlasCache.cpp + 2d/CCFontCharMap.cpp 2d/CCFontFNT.cpp 2d/CCFontFreeType.cpp 2d/CCGLBufferedNode.cpp - 2d/CCGLProgram.cpp - 2d/ccGLStateCache.cpp 2d/CCGrabber.cpp 2d/CCGrid.cpp 2d/CCIMEDispatcher.cpp + 2d/CCLabel.cpp 2d/CCLabelAtlas.cpp 2d/CCLabelBMFont.cpp - 2d/CCLabel.cpp - 2d/CCLabelTextFormatter.cpp 2d/CCLabelTTF.cpp + 2d/CCLabelTextFormatter.cpp 2d/CCLayer.cpp 2d/CCMenu.cpp 2d/CCMenuItem.cpp @@ -82,37 +80,35 @@ set(COCOS_2D_SRC 2d/CCRenderTexture.cpp 2d/CCScene.cpp 2d/CCScriptSupport.cpp - 2d/CCShaderCache.cpp - 2d/ccShaders.cpp - 2d/CCSpriteBatchNode.cpp 2d/CCSprite.cpp - 2d/CCSpriteFrameCache.cpp + 2d/CCSpriteBatchNode.cpp 2d/CCSpriteFrame.cpp + 2d/CCSpriteFrameCache.cpp + 2d/CCTMXLayer.cpp + 2d/CCTMXObjectGroup.cpp + 2d/CCTMXTiledMap.cpp + 2d/CCTMXXMLParser.cpp 2d/CCTextFieldTTF.cpp 2d/CCTexture2D.cpp 2d/CCTextureAtlas.cpp 2d/CCTextureCache.cpp 2d/CCTileMapAtlas.cpp - 2d/CCTMXLayer.cpp - 2d/CCTMXObjectGroup.cpp - 2d/CCTMXTiledMap.cpp - 2d/CCTMXXMLParser.cpp 2d/CCTransition.cpp 2d/CCTransitionPageTurn.cpp 2d/CCTransitionProgress.cpp 2d/CCTweenFunction.cpp - 2d/CCUserDefaultAndroid.cpp 2d/CCUserDefault.cpp - 2d/ccUTF8.cpp - 2d/ccUtils.cpp + 2d/CCUserDefaultAndroid.cpp 2d/CCVertex.cpp 2d/TGAlib.cpp + 2d/ccCArray.cpp + 2d/ccUTF8.cpp + 2d/ccUtils.cpp 2d/platform/CCSAXParser.cpp 2d/platform/CCThread.cpp 2d/platform/CCGLViewProtocol.cpp 2d/platform/CCFileUtils.cpp 2d/platform/CCImage.cpp - 2d/ccFPSImages.c ../external/edtaa3func/edtaa3func.cpp ) diff --git a/cocos/renderer/CMakeLists.txt b/cocos/renderer/CMakeLists.txt index 10cda1cbe1..a51f6640cb 100644 --- a/cocos/renderer/CMakeLists.txt +++ b/cocos/renderer/CMakeLists.txt @@ -1,9 +1,15 @@ set(COCOS_RENDERER_SRC renderer/CCBatchCommand.cpp renderer/CCCustomCommand.cpp + renderer/CCGLProgram.cpp + renderer/CCGLProgramState.cpp + renderer/CCGLProgramStateCache.cpp renderer/CCGroupCommand.cpp renderer/CCQuadCommand.cpp renderer/CCRenderCommand.cpp renderer/CCRenderer.cpp + renderer/CCShaderCache.cpp + renderer/ccGLStateCache.cpp + renderer/ccShaders.cpp ) From b5fdbf2d49d2437bfa1de311f939ebe89da9e9de Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 17:03:34 -0700 Subject: [PATCH 066/174] it is v3.1-alpha1 --- cocos/cocos2d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/cocos2d.cpp b/cocos/cocos2d.cpp index 513fc4796e..22251fb170 100644 --- a/cocos/cocos2d.cpp +++ b/cocos/cocos2d.cpp @@ -31,7 +31,7 @@ NS_CC_BEGIN const char* cocos2dVersion() { - return "cocos2d-x 3.1alpha0"; + return "cocos2d-x 3.1alpha1"; } NS_CC_END From c16d07249144d541083068ee2e82cbc2044c5e8a Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 9 May 2014 17:26:51 -0700 Subject: [PATCH 067/174] added conversion script for convert yCoordFlipped --- tools/particle/convert_YCoordFlipped.py | 66 +++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 tools/particle/convert_YCoordFlipped.py diff --git a/tools/particle/convert_YCoordFlipped.py b/tools/particle/convert_YCoordFlipped.py new file mode 100755 index 0000000000..9325db94c2 --- /dev/null +++ b/tools/particle/convert_YCoordFlipped.py @@ -0,0 +1,66 @@ +#!/usr/bin/python +#ConvertYCoordFlipped.py + +import plistlib +import os.path +import argparse +import glob + +#keys in dictionary +metaDataKey = 'metaData' +yCoordFlippedConvertedKey = 'yCoordFlippedConverted' +yCoordFlippedKey = 'yCoordFlipped' + +#check if the particle file has been converted +def checkFlippedConvertFlag(plistDict): + if(not plistDict.has_key(metaDataKey)): + return False + else: + metaDict = plistDict.get(metaDataKey) + if(not metaDict.has_key(yCoordFlippedConvertedKey)): + return False + else: + return metaDict.get(yCoordFlippedConvertedKey) is 1 + +#write flag to indicate to file has been converted +def writeFlippedConvertFlag(plistDict): + metaDict = dict() + metaDict.update(yCoordFlippedConverted = 1) + plistDict.update(metaData = metaDict) + +#process file +def processConvertFile(filename): + #print a line to seperate files + print ('') + if(not os.path.isfile(filename)): + print(filename + ' dose not exist!') + return + print('Begin process particle file: ' + filename) + fp = open(filename, 'r') + pl = plistlib.readPlist(fp) + backupFileName = filename+'.backup' + print('Write backup file to ' + backupFileName) + plistlib.writePlist(pl,backupFileName) + + if (not pl.has_key(yCoordFlippedKey)): + print('Skip plist file: ' + filename + ' for there is no key for yCoordFlipped,') + else: + if(not checkFlippedConvertFlag(pl)): + print('converting...') + pl[yCoordFlippedKey] = -pl[yCoordFlippedKey] + writeFlippedConvertFlag(pl) + print('converted...') + print('Write new plist file to ' + filename) + plistlib.writePlist(pl,filename) + else: + print('Skip a converted file ' + filename) + +# -------------- entrance -------------- +if __name__ == '__main__': + argparser = argparse.ArgumentParser() + argparser.add_argument("file", nargs = "+",help = "specify a file or a patten") + #argparser.add_argument("-r", "--recursive",action = "store_true", help = "recursive folder or not") + args = argparser.parse_args() + + for file in args.file: + processConvertFile(file) From 06de5d79916b96f4892e40e486ea95d32dc9bb27 Mon Sep 17 00:00:00 2001 From: AlexV Date: Tue, 29 Apr 2014 13:58:58 +0900 Subject: [PATCH 068/174] added detection of android tools path --- setup.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/setup.py b/setup.py index 31a4dc7d0b..26cb315978 100755 --- a/setup.py +++ b/setup.py @@ -536,9 +536,43 @@ class SetEnvVar(object): print(" ->Command ant not found\n") return ret + def _get_android_path(self): + print(" ->Find command android in system...") + ret = None + if not self._isWindows(): + import commands + state, result = commands.getstatusoutput("which android") + if state == 0: + ret = os.path.dirname(result) + + if ret is not None: + print(" ->Path \"%s\" was found\n" % ret) + else: + print(" ->Command android not found\n") + return ret + + def _get_ndkbuild_path(self): + print(" ->Find command ndk-build in system...") + ret = None + if not self._isWindows(): + import commands + state, result = commands.getstatusoutput("which ndk-build") + if state == 0: + ret = os.path.dirname(result) + + if ret is not None: + print(" ->Path \"%s\" was found\n" % ret) + else: + print(" ->Command ndk-build not found\n") + return ret + def _find_value_from_sys(self, var_name): if var_name == ANT_ROOT: return self._get_ant_path() + elif var_name == NDK_ROOT: + return os.path.abspath(os.path.join(self._get_ndkbuild_path(),os.pardir)) + elif var_name == ANDROID_SDK_ROOT: + return os.path.abspath(os.path.join(self._get_android_path(),os.pardir)) else: return None From 9b84a21f52008f7b3f8e2048f702ca703898b6e7 Mon Sep 17 00:00:00 2001 From: AlexV Date: Tue, 29 Apr 2014 14:10:51 +0900 Subject: [PATCH 069/174] fixing handling of error when trying to detect android tools --- setup.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 26cb315978..8eb626d72e 100755 --- a/setup.py +++ b/setup.py @@ -318,11 +318,11 @@ class SetEnvVar(object): def _check_valid(self, var_name, value): ret = False - if var_name == NDK_ROOT: + if value is not None and var_name == NDK_ROOT: ret = self._is_ndk_root_valid(value) - elif var_name == ANDROID_SDK_ROOT: + elif value is not None and var_name == ANDROID_SDK_ROOT: ret = self._is_android_sdk_root_valid(value) - elif var_name == ANT_ROOT: + elif value is not None and var_name == ANT_ROOT: ret = self._is_ant_root_valid(value) else: ret = False @@ -570,9 +570,17 @@ class SetEnvVar(object): if var_name == ANT_ROOT: return self._get_ant_path() elif var_name == NDK_ROOT: - return os.path.abspath(os.path.join(self._get_ndkbuild_path(),os.pardir)) + ndkpath = self._get_ndkbuild_path() + if ndkpath is not None: + return os.path.abspath(os.path.join(ndkpath,os.pardir)) + else : + return None elif var_name == ANDROID_SDK_ROOT: - return os.path.abspath(os.path.join(self._get_android_path(),os.pardir)) + sdkpath = self._get_android_path() + if sdkpath is not None: + return os.path.abspath(os.path.join(sdkpath,os.pardir)) + else : + return None else: return None From 2e461182b0540c57f50b2a040f7240c240dc8f7d Mon Sep 17 00:00:00 2001 From: AlexV Date: Tue, 29 Apr 2014 14:13:40 +0900 Subject: [PATCH 070/174] removed duplicated check on deteted values from system --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 8eb626d72e..3e34dfa897 100755 --- a/setup.py +++ b/setup.py @@ -318,11 +318,11 @@ class SetEnvVar(object): def _check_valid(self, var_name, value): ret = False - if value is not None and var_name == NDK_ROOT: + if var_name == NDK_ROOT: ret = self._is_ndk_root_valid(value) - elif value is not None and var_name == ANDROID_SDK_ROOT: + elif var_name == ANDROID_SDK_ROOT: ret = self._is_android_sdk_root_valid(value) - elif value is not None and var_name == ANT_ROOT: + elif var_name == ANT_ROOT: ret = self._is_ant_root_valid(value) else: ret = False From 556eab4a61f7c80fb11ed348c01011399dc8d303 Mon Sep 17 00:00:00 2001 From: AlexV Date: Sat, 3 May 2014 18:39:51 +0900 Subject: [PATCH 071/174] fixed tabs space issues. fixed problem with ndk detection. simplified code for androidsdk detection. --- setup.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index 3e34dfa897..9a309edd02 100755 --- a/setup.py +++ b/setup.py @@ -536,7 +536,7 @@ class SetEnvVar(object): print(" ->Command ant not found\n") return ret - def _get_android_path(self): + def _get_androidsdk_path(self): print(" ->Find command android in system...") ret = None if not self._isWindows(): @@ -546,6 +546,7 @@ class SetEnvVar(object): ret = os.path.dirname(result) if ret is not None: + ret = os.path.abspath(os.path.join(ret,os.pardir)) print(" ->Path \"%s\" was found\n" % ret) else: print(" ->Command android not found\n") @@ -569,18 +570,10 @@ class SetEnvVar(object): def _find_value_from_sys(self, var_name): if var_name == ANT_ROOT: return self._get_ant_path() - elif var_name == NDK_ROOT: - ndkpath = self._get_ndkbuild_path() - if ndkpath is not None: - return os.path.abspath(os.path.join(ndkpath,os.pardir)) - else : - return None - elif var_name == ANDROID_SDK_ROOT: - sdkpath = self._get_android_path() - if sdkpath is not None: - return os.path.abspath(os.path.join(sdkpath,os.pardir)) - else : - return None + elif var_name == NDK_ROOT: + return self._get_ndkbuild_path() + elif var_name == ANDROID_SDK_ROOT: + return self._get_androidsdk_path() else: return None From 77c03fcf114369bc2dda138daedc13c93b132367 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 18:39:25 -0700 Subject: [PATCH 072/174] ShaderCache -> GLProgramCache --- build/cocos2d_libs.xcodeproj/project.pbxproj | 24 +-- cocos/2d/CCAtlasNode.cpp | 10 +- cocos/2d/CCClippingNode.cpp | 4 +- cocos/2d/CCDrawNode.cpp | 4 +- cocos/2d/CCDrawingPrimitives.cpp | 4 +- cocos/2d/CCGrid.cpp | 11 +- cocos/2d/CCLabel.cpp | 12 +- cocos/2d/CCLabelAtlas.cpp | 2 +- cocos/2d/CCLayer.cpp | 4 +- cocos/2d/CCMotionStreak.cpp | 12 +- cocos/2d/CCNode.h | 2 +- cocos/2d/CCParticleBatchNode.cpp | 22 +-- cocos/2d/CCParticleSystemQuad.cpp | 14 +- cocos/2d/CCProgressTimer.cpp | 15 +- cocos/2d/CCSprite.cpp | 12 +- cocos/2d/CCSpriteBatchNode.cpp | 19 +-- cocos/2d/CCTMXLayer.cpp | 12 +- cocos/2d/CCTexture2D.cpp | 16 +- cocos/base/CCDirector.cpp | 6 +- cocos/cocos2d.h | 2 +- cocos/deprecated/CCDeprecated.h | 3 +- .../editor-support/cocostudio/CCArmature.cpp | 4 +- .../editor-support/cocostudio/CCBatchNode.cpp | 4 +- cocos/editor-support/spine/CCSkeleton.cpp | 2 +- ...CCShaderCache.cpp => CCGLProgramCache.cpp} | 138 +++++++++--------- .../{CCShaderCache.h => CCGLProgramCache.h} | 42 +++--- cocos/renderer/CCGLProgramState.cpp | 45 +++--- cocos/renderer/CCGLProgramState.h | 21 ++- cocos/renderer/CCGLProgramStateCache.cpp | 29 ++-- cocos/renderer/CCGLProgramStateCache.h | 14 +- cocos/renderer/CCRenderer.cpp | 2 +- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 2 +- cocos/ui/UILayout.cpp | 2 +- docs/RELEASE_NOTES.md | 2 +- .../Classes/Box2DTestBed/GLES-Render.cpp | 2 +- .../ClippingNodeTest/ClippingNodeTest.cpp | 10 +- .../CocoStudioArmatureTest/ArmatureScene.cpp | 2 +- .../CocoStudioSceneTest/SceneEditorTest.cpp | 2 +- .../cpp-tests/Classes/LabelTest/LabelTest.cpp | 2 +- .../Classes/MutiTouchTest/MutiTouchTest.cpp | 2 +- tests/cpp-tests/Classes/NodeTest/NodeTest.cpp | 4 +- .../Classes/SpriteTest/SpriteTest.cpp | 4 +- 42 files changed, 288 insertions(+), 257 deletions(-) rename cocos/renderer/{CCShaderCache.cpp => CCGLProgramCache.cpp} (67%) rename cocos/renderer/{CCShaderCache.h => CCGLProgramCache.h} (68%) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 780efa2102..6c0f8cdefb 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1562,10 +1562,10 @@ 5034CA1A191D591100CE6051 /* ccShaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9F7191D591000CE6051 /* ccShaders.h */; }; 5034CA1B191D591100CE6051 /* ccShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9F8191D591000CE6051 /* ccShaders.cpp */; }; 5034CA1C191D591100CE6051 /* ccShaders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9F8191D591000CE6051 /* ccShaders.cpp */; }; - 5034CA1D191D591100CE6051 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9F9191D591000CE6051 /* CCShaderCache.h */; }; - 5034CA1E191D591100CE6051 /* CCShaderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9F9191D591000CE6051 /* CCShaderCache.h */; }; - 5034CA1F191D591100CE6051 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9FA191D591000CE6051 /* CCShaderCache.cpp */; }; - 5034CA20191D591100CE6051 /* CCShaderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9FA191D591000CE6051 /* CCShaderCache.cpp */; }; + 5034CA1D191D591100CE6051 /* CCGLProgramCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9F9191D591000CE6051 /* CCGLProgramCache.h */; }; + 5034CA1E191D591100CE6051 /* CCGLProgramCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9F9191D591000CE6051 /* CCGLProgramCache.h */; }; + 5034CA1F191D591100CE6051 /* CCGLProgramCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9FA191D591000CE6051 /* CCGLProgramCache.cpp */; }; + 5034CA20191D591100CE6051 /* CCGLProgramCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5034C9FA191D591000CE6051 /* CCGLProgramCache.cpp */; }; 5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */; }; 5034CA22191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */; }; 5034CA2B191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color.vert */; }; @@ -2668,8 +2668,8 @@ 50272539190BF1B900AAF4ED /* cocos2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cocos2d.cpp; path = ../cocos/cocos2d.cpp; sourceTree = ""; }; 5034C9F7191D591000CE6051 /* ccShaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccShaders.h; sourceTree = ""; }; 5034C9F8191D591000CE6051 /* ccShaders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccShaders.cpp; sourceTree = ""; }; - 5034C9F9191D591000CE6051 /* CCShaderCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCShaderCache.h; sourceTree = ""; }; - 5034C9FA191D591000CE6051 /* CCShaderCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCShaderCache.cpp; sourceTree = ""; }; + 5034C9F9191D591000CE6051 /* CCGLProgramCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgramCache.h; sourceTree = ""; }; + 5034C9FA191D591000CE6051 /* CCGLProgramCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgramCache.cpp; sourceTree = ""; }; 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColorAlphaTest.frag; sourceTree = ""; }; 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureA8Color.vert; sourceTree = ""; }; 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureA8Color.frag; sourceTree = ""; }; @@ -4610,8 +4610,8 @@ 5034CA5D191D591900CE6051 /* shaders */, 5034C9F7191D591000CE6051 /* ccShaders.h */, 5034C9F8191D591000CE6051 /* ccShaders.cpp */, - 5034C9F9191D591000CE6051 /* CCShaderCache.h */, - 5034C9FA191D591000CE6051 /* CCShaderCache.cpp */, + 5034C9F9191D591000CE6051 /* CCGLProgramCache.h */, + 5034C9FA191D591000CE6051 /* CCGLProgramCache.cpp */, 5034CA11191D591000CE6051 /* ccGLStateCache.h */, 5034CA12191D591000CE6051 /* ccGLStateCache.cpp */, 5034CA13191D591000CE6051 /* CCGLProgramStateCache.h */, @@ -5232,7 +5232,7 @@ 1A8C59E9180E930E00EF57C3 /* CCSGUIReader.h in Headers */, 5034CA33191D591100CE6051 /* ccShader_PositionTexture_uColor.frag in Headers */, 1A8C59ED180E930E00EF57C3 /* CCSkin.h in Headers */, - 5034CA1D191D591100CE6051 /* CCShaderCache.h in Headers */, + 5034CA1D191D591100CE6051 /* CCGLProgramCache.h in Headers */, 1A8C59F1180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h in Headers */, 1A8C59F5180E930E00EF57C3 /* CCSSceneReader.h in Headers */, 1A8C59F9180E930E00EF57C3 /* CCTransformHelp.h in Headers */, @@ -5550,7 +5550,7 @@ 2905FA6918CF08D100240AA3 /* UILoadingBar.h in Headers */, 2905FA8F18CF08D100240AA3 /* UIWidget.h in Headers */, 1A5702C5180BCE2A0088DEC7 /* CCIMEDispatcher.h in Headers */, - 5034CA1E191D591100CE6051 /* CCShaderCache.h in Headers */, + 5034CA1E191D591100CE6051 /* CCGLProgramCache.h in Headers */, 50FCEB9A18C72017004AD434 /* CheckBoxReader.h in Headers */, 500DC8AD19105D41007B91BF /* CCBatchCommand.h in Headers */, 1A5702CB180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */, @@ -6173,7 +6173,7 @@ 5034CA1B191D591100CE6051 /* ccShaders.cpp in Sources */, 1A5701B1180BCB590088DEC7 /* CCFontFNT.cpp in Sources */, 1A5701B5180BCB590088DEC7 /* CCFontFreeType.cpp in Sources */, - 5034CA1F191D591100CE6051 /* CCShaderCache.cpp in Sources */, + 5034CA1F191D591100CE6051 /* CCGLProgramCache.cpp in Sources */, 1A5701B9180BCB5A0088DEC7 /* CCLabel.cpp in Sources */, 500DC93819106300007B91BF /* CCConfiguration.cpp in Sources */, 500DC9A619106300007B91BF /* s3tc.cpp in Sources */, @@ -6794,7 +6794,7 @@ 46C02E0818E91123004B7456 /* xxhash.c in Sources */, 500DC95D19106300007B91BF /* CCEventKeyboard.cpp in Sources */, 2905FA4118CF08D100240AA3 /* CocosGUI.cpp in Sources */, - 5034CA20191D591100CE6051 /* CCShaderCache.cpp in Sources */, + 5034CA20191D591100CE6051 /* CCGLProgramCache.cpp in Sources */, 1A01C68518F57BE800EFE3A6 /* CCArray.cpp in Sources */, 1A8C59DC180E930E00EF57C3 /* CCDisplayManager.cpp in Sources */, 1A8C59E0180E930E00EF57C3 /* CCInputDelegate.cpp in Sources */, diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index fe049bc4af..e2927f744a 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -29,12 +29,12 @@ THE SOFTWARE. #include "2d/CCTextureAtlas.h" #include "2d/CCTextureCache.h" #include "base/CCDirector.h" -#include "renderer/CCGLProgram.h" -#include "renderer/CCShaderCache.h" -#include "renderer/ccGLStateCache.h" #include "base/CCDirector.h" -#include "math/TransformUtils.h" #include "renderer/CCRenderer.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCGLProgramState.h" +#include "renderer/ccGLStateCache.h" +#include "math/TransformUtils.h" NS_CC_BEGIN @@ -106,7 +106,7 @@ bool AtlasNode::initWithTexture(Texture2D* texture, int tileWidth, int tileHeigh _quadsToDraw = itemsToRender; // shader stuff - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); return true; } diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index 2cd827a66e..4d310523cc 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -27,7 +27,7 @@ #include "2d/CCClippingNode.h" #include "renderer/CCGLProgram.h" -#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgramCache.h" #include "2d/CCDrawingPrimitives.h" #include "base/CCDirector.h" @@ -237,7 +237,7 @@ void ClippingNode::visit(Renderer *renderer, const Matrix &parentTransform, bool #else // since glAlphaTest do not exists in OES, use a shader that writes // pixel only if greater than an alpha threshold - GLProgram *program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); + GLProgram *program = GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); // set our alphaThreshold program->use(); diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 0490e5da09..7a225a9483 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -22,12 +22,12 @@ */ #include "2d/CCDrawNode.h" -#include "renderer/CCShaderCache.h" #include "CCGL.h" #include "base/CCEventType.h" #include "base/CCConfiguration.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCRenderer.h" +#include "renderer/CCGLProgramState.h" #include "base/CCDirector.h" #include "base/CCEventListenerCustom.h" #include "base/CCEventDispatcher.h" @@ -158,7 +158,7 @@ bool DrawNode::init() { _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR)); ensureCapacity(512); diff --git a/cocos/2d/CCDrawingPrimitives.cpp b/cocos/2d/CCDrawingPrimitives.cpp index 44ea905483..3af2401d45 100644 --- a/cocos/2d/CCDrawingPrimitives.cpp +++ b/cocos/2d/CCDrawingPrimitives.cpp @@ -46,7 +46,7 @@ THE SOFTWARE. #include "CCGL.h" #include "base/CCDirector.h" #include "renderer/ccGLStateCache.h" -#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgramCache.h" #include "renderer/CCGLProgram.h" #include "2d/CCActionCatmullRom.h" #include "renderer/CCRenderer.h" @@ -99,7 +99,7 @@ static void lazy_init( void ) // // Position and 1 color passed as a uniform (to simulate glColor4ub ) // - s_shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR); + s_shader = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR); s_shader->retain(); s_colorLocation = s_shader->getUniformLocation("u_color"); diff --git a/cocos/2d/CCGrid.cpp b/cocos/2d/CCGrid.cpp index 70e07ac3c1..92924b0204 100644 --- a/cocos/2d/CCGrid.cpp +++ b/cocos/2d/CCGrid.cpp @@ -23,16 +23,17 @@ 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/ccMacros.h" -#include "2d/CCGrid.h" #include "base/CCDirector.h" -#include "CCGrabber.h" +#include "2d/CCGrabber.h" #include "2d/ccUtils.h" +#include "2d/CCGrid.h" #include "renderer/CCGLProgram.h" -#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgramCache.h" #include "renderer/ccGLStateCache.h" -#include "CCGL.h" #include "renderer/CCRenderer.h" +#include "CCGL.h" #include "math/TransformUtils.h" NS_CC_BEGIN @@ -102,7 +103,7 @@ bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool flipp ret = false; } - _shaderProgram = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE); + _shaderProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE); calculateVertexPoints(); return ret; diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index db5e63afe3..a08c048b6e 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -27,7 +27,7 @@ #include "2d/CCFontAtlasCache.h" #include "CCLabelTextFormatter.h" #include "2d/CCSprite.h" -#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgramCache.h" #include "ccUTF8.h" #include "2d/CCSpriteFrame.h" #include "base/CCDirector.h" @@ -342,21 +342,21 @@ void Label::updateShaderProgram() { case cocos2d::LabelEffect::NORMAL: if (_useDistanceField) - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL)); + setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL)); else if (_useA8Shader) - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_NORMAL)); + setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_NORMAL)); else - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); break; case cocos2d::LabelEffect::OUTLINE: - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_OUTLINE)); + setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_OUTLINE)); _uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "v_effectColor"); break; case cocos2d::LabelEffect::GLOW: if (_useDistanceField) { - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW)); + setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW)); _uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "v_effectColor"); } break; diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index 5d060eed90..dbdcee017f 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. #include "2d/CCTextureCache.h" #include "2d/CCDrawingPrimitives.h" #include "base/ccConfig.h" -#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgramCache.h" #include "renderer/CCGLProgram.h" #include "renderer/ccGLStateCache.h" #include "base/CCDirector.h" diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index 6e30028b32..b3cc93c582 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. #include "2d/CCLayer.h" #include "base/CCDirector.h" #include "2d/CCScriptSupport.h" -#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgramCache.h" #include "renderer/CCGLProgram.h" #include "renderer/ccGLStateCache.h" #include "math/TransformUtils.h" @@ -534,7 +534,7 @@ bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h) updateColor(); setContentSize(Size(w, h)); - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP)); + setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP)); return true; } return false; diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp index 6ae0a6403c..f3fcd43fc5 100644 --- a/cocos/2d/CCMotionStreak.cpp +++ b/cocos/2d/CCMotionStreak.cpp @@ -25,14 +25,14 @@ THE SOFTWARE. ****************************************************************************/ #include "2d/CCMotionStreak.h" #include "2d/CCTextureCache.h" +#include "2d/CCVertex.h" #include "renderer/ccGLStateCache.h" #include "renderer/CCGLProgram.h" -#include "renderer/CCShaderCache.h" -#include "2d/CCVertex.h" -#include "base/ccMacros.h" -#include "base/CCDirector.h" +#include "renderer/CCGLProgramState.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCRenderer.h" +#include "base/ccMacros.h" +#include "base/CCDirector.h" NS_CC_BEGIN @@ -127,8 +127,8 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co // Set blend mode _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; - // shader program - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + // shader state + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); setTexture(texture); setColor(color); diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 4a1680eed0..e12688151f 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -840,7 +840,7 @@ public: * Since v2.0, each rendering node must set its shader program. * It should be set in initialize phase. @code - node->setGLrProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + node->setGLrProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); @endcode * * @param shaderProgram The shader program diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index 6f5f605981..0d8296dd80 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -28,23 +28,25 @@ * */ -#include "CCParticleBatchNode.h" +#include "2d/CCParticleBatchNode.h" + #include "2d/CCTextureCache.h" #include "2d/CCTextureAtlas.h" -#include "base/ccConfig.h" -#include "base/ccMacros.h" #include "2d/CCGrid.h" -#include "CCParticleSystem.h" -#include "renderer/CCShaderCache.h" -#include "renderer/CCGLProgram.h" -#include "renderer/ccGLStateCache.h" -#include "base/base64.h" -#include "base/ZipUtils.h" +#include "2d/CCParticleSystem.h" #include "2d/platform/CCFileUtils.h" #include "base/CCProfiling.h" +#include "base/ccConfig.h" +#include "base/ccMacros.h" +#include "base/base64.h" +#include "base/ZipUtils.h" +#include "renderer/CCGLProgramState.h" +#include "renderer/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" #include "renderer/CCQuadCommand.h" #include "renderer/CCRenderer.h" + NS_CC_BEGIN ParticleBatchNode::ParticleBatchNode() @@ -101,7 +103,7 @@ bool ParticleBatchNode::initWithTexture(Texture2D *tex, int capacity) _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return true; } diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index 98f7a6c05a..887ef92569 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -29,15 +29,15 @@ THE SOFTWARE. #include "CCGL.h" #include "2d/CCParticleSystemQuad.h" #include "2d/CCSpriteFrame.h" -#include "base/CCDirector.h" -#include "CCParticleBatchNode.h" +#include "2d/CCParticleBatchNode.h" #include "2d/CCTextureAtlas.h" -#include "renderer/CCShaderCache.h" -#include "renderer/ccGLStateCache.h" -#include "renderer/CCGLProgram.h" -#include "math/TransformUtils.h" +#include "base/CCDirector.h" #include "base/CCEventType.h" #include "base/CCConfiguration.h" +#include "math/TransformUtils.h" +#include "renderer/CCGLProgramState.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCGLProgram.h" #include "renderer/CCRenderer.h" #include "renderer/CCQuadCommand.h" #include "renderer/CCCustomCommand.h" @@ -131,7 +131,7 @@ bool ParticleSystemQuad::initWithTotalParticles(int numberOfParticles) setupVBO(); } - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); #if CC_ENABLE_CACHE_TEXTURE_DATA // Need to listen the event only when not use batchnode, because it will use VBO diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp index d0d02dd545..2d9f8edb89 100644 --- a/cocos/2d/CCProgressTimer.cpp +++ b/cocos/2d/CCProgressTimer.cpp @@ -26,15 +26,15 @@ THE SOFTWARE. #include "2d/CCProgressTimer.h" #include "base/ccMacros.h" -#include "2d/CCTextureCache.h" -#include "renderer/CCGLProgram.h" -#include "renderer/CCShaderCache.h" -#include "renderer/ccGLStateCache.h" #include "base/CCDirector.h" -#include "math/TransformUtils.h" +#include "2d/CCTextureCache.h" #include "2d/CCDrawingPrimitives.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCGLProgramState.h" +#include "renderer/ccGLStateCache.h" #include "renderer/CCRenderer.h" #include "renderer/CCCustomCommand.h" +#include "math/TransformUtils.h" // extern #include @@ -85,8 +85,9 @@ bool ProgressTimer::initWithSprite(Sprite* sp) setMidpoint(Vector2(0.5f, 0.5f)); setBarChangeRate(Vector2(1,1)); setSprite(sp); - // shader program - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + + // shader state + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return true; } diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 0a49c1e93a..8e038b3603 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -33,10 +33,11 @@ THE SOFTWARE. #include "2d/CCSpriteFrameCache.h" #include "2d/CCTextureCache.h" #include "2d/CCDrawingPrimitives.h" -#include "renderer/CCShaderCache.h" +#include "2d/CCTexture2D.h" +#include "renderer/CCGLProgramState.h" #include "renderer/ccGLStateCache.h" #include "renderer/CCGLProgram.h" -#include "2d/CCTexture2D.h" +#include "renderer/CCRenderer.h" #include "base/CCProfiling.h" #include "base/CCDirector.h" #include "base/CCDirector.h" @@ -44,7 +45,6 @@ THE SOFTWARE. #include "math/CCGeometry.h" #include "math/CCAffineTransform.h" #include "math/TransformUtils.h" -#include "renderer/CCRenderer.h" #include "deprecated/CCString.h" @@ -248,9 +248,9 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) _quad.tl.colors = Color4B::WHITE; _quad.tr.colors = Color4B::WHITE; - // shader program - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); - + // shader state + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); + // update texture (calls updateBlendFunc) setTexture(texture); setTextureRect(rect, rotated, rect.size); diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index a9d79c46ea..1e363f04b8 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -27,25 +27,26 @@ THE SOFTWARE. ****************************************************************************/ #include "2d/CCSpriteBatchNode.h" -#include "base/ccConfig.h" + #include "2d/CCSprite.h" #include "2d/CCGrid.h" #include "2d/CCDrawingPrimitives.h" #include "2d/CCTextureCache.h" -#include "renderer/CCShaderCache.h" -#include "renderer/CCGLProgram.h" -#include "renderer/ccGLStateCache.h" -#include "base/CCDirector.h" -#include "math/TransformUtils.h" -#include "base/CCProfiling.h" #include "2d/CCLayer.h" #include "2d/CCScene.h" +#include "base/ccConfig.h" +#include "base/CCDirector.h" +#include "base/CCProfiling.h" +#include "renderer/CCGLProgramState.h" +#include "renderer/CCGLProgram.h" +#include "renderer/ccGLStateCache.h" #include "renderer/CCRenderer.h" #include "renderer/CCQuadCommand.h" -// external +#include "math/TransformUtils.h" #include "deprecated/CCString.h" // For StringUtils::format +// external #include NS_CC_BEGIN @@ -99,7 +100,7 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity) _descendants.reserve(capacity); - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return true; } diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp index 1105ee809e..e6d75570c4 100644 --- a/cocos/2d/CCTMXLayer.cpp +++ b/cocos/2d/CCTMXLayer.cpp @@ -24,14 +24,14 @@ 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 "CCTMXLayer.h" -#include "CCTMXXMLParser.h" -#include "CCTMXTiledMap.h" +#include "2d/CCTMXLayer.h" +#include "2d/CCTMXXMLParser.h" +#include "2d/CCTMXTiledMap.h" #include "2d/CCSprite.h" #include "2d/CCTextureCache.h" -#include "renderer/CCShaderCache.h" -#include "renderer/CCGLProgram.h" #include "2d/ccCArray.h" +#include "renderer/CCGLProgramState.h" +#include "renderer/CCGLProgram.h" #include "base/CCDirector.h" #include "deprecated/CCString.h" // For StringUtils::format @@ -205,7 +205,7 @@ void TMXLayer::parseInternalProperties() _useAutomaticVertexZ = true; auto alphaFuncVal = getProperty("cc_alpha_func"); float alphaFuncValue = alphaFuncVal.asFloat(); - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST)); GLint alphaValueLocation = glGetUniformLocation(getGLProgram()->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); diff --git a/cocos/2d/CCTexture2D.cpp b/cocos/2d/CCTexture2D.cpp index fed3e5b808..bd12b3a49a 100644 --- a/cocos/2d/CCTexture2D.cpp +++ b/cocos/2d/CCTexture2D.cpp @@ -31,21 +31,23 @@ THE SOFTWARE. * https://devforums.apple.com/message/37855#37855 by a1studmuffin */ +#include "CCGL.h" #include "2d/CCTexture2D.h" +#include "2d/platform/CCImage.h" +#include "2d/ccUtils.h" +#include "2d/platform/CCDevice.h" #include "base/ccConfig.h" #include "base/ccMacros.h" #include "base/CCConfiguration.h" -#include "2d/platform/CCImage.h" -#include "CCGL.h" -#include "2d/ccUtils.h" #include "base/CCPlatformMacros.h" #include "base/CCDirector.h" #include "renderer/CCGLProgram.h" #include "renderer/ccGLStateCache.h" -#include "renderer/CCShaderCache.h" -#include "2d/platform/CCDevice.h" +#include "renderer/CCGLProgramCache.h" + #include "deprecated/CCString.h" + #if CC_ENABLE_CACHE_TEXTURE_DATA #include "2d/CCTextureCache.h" #endif @@ -692,8 +694,8 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat _hasPremultipliedAlpha = false; _hasMipmaps = mipmapsNum > 1; - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE)); - + // shader + setGLProgram(GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE)); return true; } diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 97483f305f..53e9b53eea 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -43,7 +43,8 @@ THE SOFTWARE. #include "2d/CCFontAtlasCache.h" #include "2d/CCAnimationCache.h" #include "2d/CCUserDefault.h" -#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgramCache.h" +#include "renderer/CCGLProgramStateCache.h" #include "2d/CCTransition.h" #include "2d/CCTextureCache.h" #include "2d/CCFontFreeType.h" @@ -952,7 +953,8 @@ void Director::purgeDirector() DrawPrimitives::free(); AnimationCache::destroyInstance(); SpriteFrameCache::destroyInstance(); - ShaderCache::destroyInstance(); + GLProgramCache::destroyInstance(); + GLProgramStateCache::destroyInstance(); FileUtils::destroyInstance(); Configuration::destroyInstance(); diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 9cff4cb22d..143678e877 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -141,9 +141,9 @@ THE SOFTWARE. #include "renderer/CCRenderCommandPool.h" #include "renderer/CCRenderer.h" #include "renderer/CCGLProgram.h" +#include "renderer/CCGLProgramCache.h" #include "renderer/CCGLProgramState.h" #include "renderer/ccGLStateCache.h" -#include "renderer/CCShaderCache.h" #include "renderer/ccShaders.h" // physics diff --git a/cocos/deprecated/CCDeprecated.h b/cocos/deprecated/CCDeprecated.h index 38cc1c4999..7c302b0f05 100644 --- a/cocos/deprecated/CCDeprecated.h +++ b/cocos/deprecated/CCDeprecated.h @@ -751,7 +751,8 @@ CC_DEPRECATED_ATTRIBUTE typedef ParticleSnow CCParticleSnow; CC_DEPRECATED_ATTRIBUTE typedef ParticleRain CCParticleRain; CC_DEPRECATED_ATTRIBUTE typedef FileUtils CCFileUtils; CC_DEPRECATED_ATTRIBUTE typedef Application CCApplication; -CC_DEPRECATED_ATTRIBUTE typedef ShaderCache CCShaderCache; +CC_DEPRECATED_ATTRIBUTE typedef GLProgramCache CCShaderCache; +CC_DEPRECATED_ATTRIBUTE typedef GLProgramCache ShaderCache; CC_DEPRECATED_ATTRIBUTE typedef AnimationCache CCAnimationCache; CC_DEPRECATED_ATTRIBUTE typedef SpriteFrameCache CCSpriteFrameCache; CC_DEPRECATED_ATTRIBUTE typedef TextureCache CCTextureCache; diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 42d508bdb2..526631fbc2 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -31,7 +31,7 @@ THE SOFTWARE. #include "renderer/CCRenderer.h" #include "renderer/CCGroupCommand.h" -#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgramState.h" #include "2d/CCDrawingPrimitives.h" #include "base/CCDirector.h" @@ -182,7 +182,7 @@ bool Armature::init(const std::string& name) } - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); setCascadeOpacityEnabled(true); setCascadeColorEnabled(true); diff --git a/cocos/editor-support/cocostudio/CCBatchNode.cpp b/cocos/editor-support/cocostudio/CCBatchNode.cpp index 4ec7b9efa1..90f6e0c24e 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.cpp +++ b/cocos/editor-support/cocostudio/CCBatchNode.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. #include "renderer/CCRenderer.h" #include "renderer/CCGroupCommand.h" -#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgramState.h" #include "base/CCDirector.h" using namespace cocos2d; @@ -61,7 +61,7 @@ BatchNode::~BatchNode() bool BatchNode::init() { bool ret = Node::init(); - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return ret; } diff --git a/cocos/editor-support/spine/CCSkeleton.cpp b/cocos/editor-support/spine/CCSkeleton.cpp index c74a4d4192..e84355cc79 100644 --- a/cocos/editor-support/spine/CCSkeleton.cpp +++ b/cocos/editor-support/spine/CCSkeleton.cpp @@ -69,7 +69,7 @@ void Skeleton::initialize () { setOpacityModifyRGB(true); - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } void Skeleton::setSkeletonData (spSkeletonData *skeletonData, bool isOwnsSkeletonData) { diff --git a/cocos/renderer/CCShaderCache.cpp b/cocos/renderer/CCGLProgramCache.cpp similarity index 67% rename from cocos/renderer/CCShaderCache.cpp rename to cocos/renderer/CCGLProgramCache.cpp index d9f21e0910..9ea37905e0 100644 --- a/cocos/renderer/CCShaderCache.cpp +++ b/cocos/renderer/CCGLProgramCache.cpp @@ -25,7 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgramCache.h" #include "renderer/CCGLProgram.h" #include "renderer/ccShaders.h" #include "base/ccMacros.h" @@ -51,234 +51,234 @@ enum { kShaderType_MAX, }; -static ShaderCache *_sharedShaderCache = 0; +static GLProgramCache *_sharedGLProgramCache = 0; -ShaderCache* ShaderCache::getInstance() +GLProgramCache* GLProgramCache::getInstance() { - if (!_sharedShaderCache) { - _sharedShaderCache = new ShaderCache(); - if (!_sharedShaderCache->init()) + if (!_sharedGLProgramCache) { + _sharedGLProgramCache = new GLProgramCache(); + if (!_sharedGLProgramCache->init()) { - CC_SAFE_DELETE(_sharedShaderCache); + CC_SAFE_DELETE(_sharedGLProgramCache); } } - return _sharedShaderCache; + return _sharedGLProgramCache; } -void ShaderCache::destroyInstance() +void GLProgramCache::destroyInstance() { - CC_SAFE_RELEASE_NULL(_sharedShaderCache); + CC_SAFE_RELEASE_NULL(_sharedGLProgramCache); } // XXX: deprecated -ShaderCache* ShaderCache::sharedShaderCache() +GLProgramCache* GLProgramCache::sharedShaderCache() { - return ShaderCache::getInstance(); + return GLProgramCache::getInstance(); } // XXX: deprecated -void ShaderCache::purgeSharedShaderCache() +void GLProgramCache::purgeSharedShaderCache() { - ShaderCache::destroyInstance(); + GLProgramCache::destroyInstance(); } -ShaderCache::ShaderCache() +GLProgramCache::GLProgramCache() : _programs() { } -ShaderCache::~ShaderCache() +GLProgramCache::~GLProgramCache() { for( auto it = _programs.begin(); it != _programs.end(); ++it ) { (it->second)->release(); } - CCLOGINFO("deallocing ShaderCache: %p", this); + CCLOGINFO("deallocing GLProgramCache: %p", this); } -bool ShaderCache::init() +bool GLProgramCache::init() { - loadDefaultShaders(); + loadDefaultGLPrograms(); return true; } -void ShaderCache::loadDefaultShaders() +void GLProgramCache::loadDefaultGLPrograms() { // Position Texture Color shader GLProgram *p = new GLProgram(); - loadDefaultShader(p, kShaderType_PositionTextureColor); + loadDefaultGLProgram(p, kShaderType_PositionTextureColor); _programs.insert( std::make_pair( GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR, p ) ); // Position Texture Color without MVP shader p = new GLProgram(); - loadDefaultShader(p, kShaderType_PositionTextureColor_noMVP); + loadDefaultGLProgram(p, kShaderType_PositionTextureColor_noMVP); _programs.insert( std::make_pair( GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, p ) ); // Position Texture Color alpha test p = new GLProgram(); - loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest); + loadDefaultGLProgram(p, kShaderType_PositionTextureColorAlphaTest); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST, p) ); // Position Texture Color alpha test p = new GLProgram(); - loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTestNoMV); + loadDefaultGLProgram(p, kShaderType_PositionTextureColorAlphaTestNoMV); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV, p) ); // // Position, Color shader // p = new GLProgram(); - loadDefaultShader(p, kShaderType_PositionColor); + loadDefaultGLProgram(p, kShaderType_PositionColor); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_COLOR, p) ); // // Position, Color shader no MVP // p = new GLProgram(); - loadDefaultShader(p, kShaderType_PositionColor_noMVP); + loadDefaultGLProgram(p, kShaderType_PositionColor_noMVP); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP, p) ); // // Position Texture shader // p = new GLProgram(); - loadDefaultShader(p, kShaderType_PositionTexture); + loadDefaultGLProgram(p, kShaderType_PositionTexture); _programs.insert( std::make_pair( GLProgram::SHADER_NAME_POSITION_TEXTURE, p) ); // // Position, Texture attribs, 1 Color as uniform shader // p = new GLProgram(); - loadDefaultShader(p, kShaderType_PositionTexture_uColor); + loadDefaultGLProgram(p, kShaderType_PositionTexture_uColor); _programs.insert( std::make_pair( GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR, p) ); // // Position Texture A8 Color shader // p = new GLProgram(); - loadDefaultShader(p, kShaderType_PositionTextureA8Color); + loadDefaultGLProgram(p, kShaderType_PositionTextureA8Color); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR, p) ); // // Position and 1 color passed as a uniform (to simulate glColor4ub ) // p = new GLProgram(); - loadDefaultShader(p, kShaderType_Position_uColor); + loadDefaultGLProgram(p, kShaderType_Position_uColor); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_U_COLOR, p) ); // // Position, Legth(TexCoords, Color (used by Draw Node basically ) // p = new GLProgram(); - loadDefaultShader(p, kShaderType_PositionLengthTexureColor); + loadDefaultGLProgram(p, kShaderType_PositionLengthTexureColor); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR, p) ); p = new GLProgram(); - loadDefaultShader(p, kShaderType_LabelDistanceFieldNormal); + loadDefaultGLProgram(p, kShaderType_LabelDistanceFieldNormal); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL, p) ); p = new GLProgram(); - loadDefaultShader(p, kShaderType_LabelDistanceFieldGlow); + loadDefaultGLProgram(p, kShaderType_LabelDistanceFieldGlow); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW, p) ); p = new GLProgram(); - loadDefaultShader(p, kShaderType_LabelNormal); + loadDefaultGLProgram(p, kShaderType_LabelNormal); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_LABEL_NORMAL, p) ); p = new GLProgram(); - loadDefaultShader(p, kShaderType_LabelOutline); + loadDefaultGLProgram(p, kShaderType_LabelOutline); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_LABEL_OUTLINE, p) ); } -void ShaderCache::reloadDefaultShaders() +void GLProgramCache::reloadDefaultGLPrograms() { // reset all programs and reload them // Position Texture Color shader - GLProgram *p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR); + GLProgram *p = getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR); p->reset(); - loadDefaultShader(p, kShaderType_PositionTextureColor); + loadDefaultGLProgram(p, kShaderType_PositionTextureColor); // Position Texture Color without MVP shader - p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); + p = getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); p->reset(); - loadDefaultShader(p, kShaderType_PositionTextureColor_noMVP); + loadDefaultGLProgram(p, kShaderType_PositionTextureColor_noMVP); // Position Texture Color alpha test - p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + p = getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); p->reset(); - loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest); + loadDefaultGLProgram(p, kShaderType_PositionTextureColorAlphaTest); // Position Texture Color alpha test - p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); + p = getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); p->reset(); - loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTestNoMV); + loadDefaultGLProgram(p, kShaderType_PositionTextureColorAlphaTestNoMV); // // Position, Color shader // - p = getProgram(GLProgram::SHADER_NAME_POSITION_COLOR); + p = getGLProgram(GLProgram::SHADER_NAME_POSITION_COLOR); p->reset(); - loadDefaultShader(p, kShaderType_PositionColor); + loadDefaultGLProgram(p, kShaderType_PositionColor); // // Position, Color shader no MVP // - p = getProgram(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP); - loadDefaultShader(p, kShaderType_PositionColor_noMVP); + p = getGLProgram(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP); + loadDefaultGLProgram(p, kShaderType_PositionColor_noMVP); // // Position Texture shader // - p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE); + p = getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE); p->reset(); - loadDefaultShader(p, kShaderType_PositionTexture); + loadDefaultGLProgram(p, kShaderType_PositionTexture); // // Position, Texture attribs, 1 Color as uniform shader // - p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR); + p = getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR); p->reset(); - loadDefaultShader(p, kShaderType_PositionTexture_uColor); + loadDefaultGLProgram(p, kShaderType_PositionTexture_uColor); // // Position Texture A8 Color shader // - p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR); + p = getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR); p->reset(); - loadDefaultShader(p, kShaderType_PositionTextureA8Color); + loadDefaultGLProgram(p, kShaderType_PositionTextureA8Color); // // Position and 1 color passed as a uniform (to simulate glColor4ub ) // - p = getProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR); + p = getGLProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR); p->reset(); - loadDefaultShader(p, kShaderType_Position_uColor); + loadDefaultGLProgram(p, kShaderType_Position_uColor); // // Position, Legth(TexCoords, Color (used by Draw Node basically ) // - p = getProgram(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR); + p = getGLProgram(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR); p->reset(); - loadDefaultShader(p, kShaderType_PositionLengthTexureColor); + loadDefaultGLProgram(p, kShaderType_PositionLengthTexureColor); - p = getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL); + p = getGLProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL); p->reset(); - loadDefaultShader(p, kShaderType_LabelDistanceFieldNormal); + loadDefaultGLProgram(p, kShaderType_LabelDistanceFieldNormal); - p = getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW); + p = getGLProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW); p->reset(); - loadDefaultShader(p, kShaderType_LabelDistanceFieldGlow); + loadDefaultGLProgram(p, kShaderType_LabelDistanceFieldGlow); - p = getProgram(GLProgram::SHADER_NAME_LABEL_NORMAL); + p = getGLProgram(GLProgram::SHADER_NAME_LABEL_NORMAL); p->reset(); - loadDefaultShader(p, kShaderType_LabelNormal); + loadDefaultGLProgram(p, kShaderType_LabelNormal); - p = getProgram(GLProgram::SHADER_NAME_LABEL_OUTLINE); + p = getGLProgram(GLProgram::SHADER_NAME_LABEL_OUTLINE); p->reset(); - loadDefaultShader(p, kShaderType_LabelOutline); + loadDefaultGLProgram(p, kShaderType_LabelOutline); } -void ShaderCache::loadDefaultShader(GLProgram *p, int type) +void GLProgramCache::loadDefaultGLProgram(GLProgram *p, int type) { switch (type) { case kShaderType_PositionTextureColor: @@ -340,7 +340,7 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type) CHECK_GL_ERROR_DEBUG(); } -GLProgram* ShaderCache::getProgram(const std::string &key) +GLProgram* GLProgramCache::getGLProgram(const std::string &key) { auto it = _programs.find(key); if( it != _programs.end() ) @@ -348,7 +348,7 @@ GLProgram* ShaderCache::getProgram(const std::string &key) return nullptr; } -void ShaderCache::addProgram(GLProgram* program, const std::string &key) +void GLProgramCache::addGLProgram(GLProgram* program, const std::string &key) { program->retain(); _programs.insert( std::make_pair( key, program) ); diff --git a/cocos/renderer/CCShaderCache.h b/cocos/renderer/CCGLProgramCache.h similarity index 68% rename from cocos/renderer/CCShaderCache.h rename to cocos/renderer/CCGLProgramCache.h index 9c0cf198b2..1f9914f0f8 100644 --- a/cocos/renderer/CCShaderCache.h +++ b/cocos/renderer/CCGLProgramCache.h @@ -25,8 +25,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __CCSHADERCACHE_H__ -#define __CCSHADERCACHE_H__ +#ifndef __CCGLPROGRAMCACHE_H__ +#define __CCGLPROGRAMCACHE_H__ #include "base/CCRef.h" @@ -42,56 +42,56 @@ class GLProgram; * @{ */ -/** ShaderCache - Singleton that stores manages GL shaders +/** GLProgramCache + Singleton that stores manages GLProgram objects (shaders) @since v2.0 */ -class CC_DLL ShaderCache : public Ref +class CC_DLL GLProgramCache : public Ref { public: /** * @js ctor */ - ShaderCache(); + GLProgramCache(); /** * @js NA * @lua NA */ - virtual ~ShaderCache(); + ~GLProgramCache(); /** returns the shared instance */ - static ShaderCache* getInstance(); + static GLProgramCache* getInstance(); /** purges the cache. It releases the retained instance. */ static void destroyInstance(); /** @deprecated Use getInstance() instead */ - CC_DEPRECATED_ATTRIBUTE static ShaderCache* sharedShaderCache(); + CC_DEPRECATED_ATTRIBUTE static GLProgramCache* sharedShaderCache(); /** @deprecated Use destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purgeSharedShaderCache(); /** loads the default shaders */ - void loadDefaultShaders(); - + void loadDefaultGLPrograms(); + CC_DEPRECATED_ATTRIBUTE void loadDefaultShaders() { loadDefaultGLPrograms(); } + /** reload the default shaders */ - void reloadDefaultShaders(); + void reloadDefaultGLPrograms(); + CC_DEPRECATED_ATTRIBUTE void reloadDefaultShaders() { reloadDefaultGLPrograms(); } /** returns a GL program for a given key */ - GLProgram * getProgram(const std::string &key); - /** @deprecated Use getProgram() instead - * @js NA - * @lua NA - */ - CC_DEPRECATED_ATTRIBUTE GLProgram * programForKey(const std::string &key){ return getProgram(key); } + GLProgram * getGLProgram(const std::string &key); + CC_DEPRECATED_ATTRIBUTE GLProgram * getProgram(const std::string &key) { return getGLProgram(key); } + CC_DEPRECATED_ATTRIBUTE GLProgram * programForKey(const std::string &key){ return getGLProgram(key); } /** adds a GLProgram to the cache for a given name */ - void addProgram(GLProgram* program, const std::string &key); + void addGLProgram(GLProgram* program, const std::string &key); + CC_DEPRECATED_ATTRIBUTE void addProgram(GLProgram* program, const std::string &key) { addGLProgram(program, key); } private: bool init(); - void loadDefaultShader(GLProgram *program, int type); + void loadDefaultGLProgram(GLProgram *program, int type); // Dictionary* _programs; std::unordered_map _programs; @@ -102,4 +102,4 @@ private: NS_CC_END -#endif /* __CCSHADERCACHE_H__ */ +#endif /* __CCGLPROGRAMCACHE_H__ */ diff --git a/cocos/renderer/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp index 8487312a12..db2d3abad3 100644 --- a/cocos/renderer/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -28,8 +28,9 @@ THE SOFTWARE. #include "renderer/CCGLProgramState.h" #include "renderer/CCGLProgram.h" -#include "renderer/ccGLStateCache.h" #include "renderer/CCGLProgramStateCache.h" +#include "renderer/CCGLProgramCache.h" +#include "renderer/ccGLStateCache.h" NS_CC_BEGIN @@ -218,37 +219,41 @@ void VertexAttribValue::setPointer(GLint size, GLenum type, GLboolean normalized // // -GLProgramState* GLProgramState::create(GLProgram *glprogram, bool useCache) +GLProgramState* GLProgramState::create(GLProgram *glprogram) { GLProgramState* ret = nullptr; - if (useCache) - { - ret = GLProgramStateCache::getInstance()->getProgramState(glprogram); - ret->_useCache = useCache; - } - else - { - ret = new (std::nothrow) GLProgramState; - if(!ret || !ret->init(glprogram)) - CC_SAFE_RELEASE(ret); - ret->_useCache = useCache; - } - + ret = new (std::nothrow) GLProgramState; + if(!ret || !ret->init(glprogram)) + CC_SAFE_RELEASE(ret); + + return ret; +} + +GLProgramState* GLProgramState::getWithGLProgramName(const std::string &glProgramName ) +{ + GLProgram *glProgram = GLProgramCache::getInstance()->getGLProgram(glProgramName); + if( glProgram ) + return get(glProgram); + + CCLOG("cocos2d: warning: GLProgram '%s' not found", glProgramName.c_str()); + return nullptr; +} + + +GLProgramState* GLProgramState::get(GLProgram *glprogram) +{ + GLProgramState* ret = GLProgramStateCache::getInstance()->getGLProgramState(glprogram); return ret; } GLProgramState::GLProgramState() : _vertexAttribsFlags(0) -, _useCache(false) , _glprogram(nullptr) { } GLProgramState::~GLProgramState() -{ - if (_useCache) - GLProgramStateCache::getInstance()->removeProgramState(_glprogram); - +{ CC_SAFE_RELEASE(_glprogram); } diff --git a/cocos/renderer/CCGLProgramState.h b/cocos/renderer/CCGLProgramState.h index 98c6f26ac4..355bb959f6 100644 --- a/cocos/renderer/CCGLProgramState.h +++ b/cocos/renderer/CCGLProgramState.h @@ -129,16 +129,24 @@ protected: }; -// -// -// GLProgramState -// -// +/** + GLProgramState holds the 'state' (uniforms and attributes) of the GLProgram. + A GLProgram can be used by thousands of Nodes, but if different uniform values + are going to be used, then each node will need its own GLProgramState + */ class GLProgramState : public Ref { friend class GLProgramStateCache; public: - static GLProgramState* create(GLProgram* glprogram, bool useCache = true); + + /** returns a new instance of GLProgramState for a given GLProgram */ + static GLProgramState* create(GLProgram* glprogram); + + /** gets-or-creates an instance of GLProgramState for a given GLProgram */ + static GLProgramState* get(GLProgram* glprogram); + + /** gets-or-creates an instance of GLProgramState for a given GLProgramName */ + static GLProgramState* getWithGLProgramName(const std::string &glProgramName ); void apply(const Matrix& modelView); @@ -170,7 +178,6 @@ protected: uint32_t _vertexAttribsFlags; GLProgram *_glprogram; - bool _useCache; }; NS_CC_END diff --git a/cocos/renderer/CCGLProgramStateCache.cpp b/cocos/renderer/CCGLProgramStateCache.cpp index 35b52f95c6..a22755381a 100644 --- a/cocos/renderer/CCGLProgramStateCache.cpp +++ b/cocos/renderer/CCGLProgramStateCache.cpp @@ -55,10 +55,10 @@ GLProgramStateCache* GLProgramStateCache::getInstance() void GLProgramStateCache::destroyInstance() { - delete s_instance; + CC_SAFE_DELETE(s_instance); } -GLProgramState* GLProgramStateCache::getProgramState(GLProgram* glprogram) +GLProgramState* GLProgramStateCache::getGLProgramState(GLProgram* glprogram) { const auto& itr = _glProgramStates.find(glprogram); if (itr != _glProgramStates.end()) @@ -68,8 +68,8 @@ GLProgramState* GLProgramStateCache::getProgramState(GLProgram* glprogram) auto ret = new (std::nothrow) GLProgramState; if(ret && ret->init(glprogram)) { - _glProgramStates[glprogram] = ret; - ret->autorelease(); + _glProgramStates.insert(glprogram, ret); + ret->release(); return ret; } @@ -77,13 +77,24 @@ GLProgramState* GLProgramStateCache::getProgramState(GLProgram* glprogram) return ret; } -void GLProgramStateCache::removeProgramState(GLProgram* program) +void GLProgramStateCache::removeUnusedGLProgramState() { - auto itr = _glProgramStates.find(program); - if (itr != _glProgramStates.end()) - { - _glProgramStates.erase(itr); + for( auto it=_glProgramStates.cbegin(); it!=_glProgramStates.cend(); /* nothing */) { + auto value = it->second; + if( value->getReferenceCount() == 1 ) { + CCLOG("cocos2d: GLProgramStateCache: removing unused GLProgramState"); + + value->release(); + _glProgramStates.erase(it++); + } else { + ++it; + } } } +void GLProgramStateCache::removeAllGLProgramState() +{ + _glProgramStates.clear(); +} + NS_CC_END diff --git a/cocos/renderer/CCGLProgramStateCache.h b/cocos/renderer/CCGLProgramStateCache.h index 5a1564a8be..ed0bdbe499 100644 --- a/cocos/renderer/CCGLProgramStateCache.h +++ b/cocos/renderer/CCGLProgramStateCache.h @@ -31,7 +31,7 @@ THE SOFTWARE. #include "math/Vector3.h" #include "math/Vector4.h" -#include +#include "base/CCMap.h" NS_CC_BEGIN @@ -48,19 +48,17 @@ class GLProgramStateCache { public: static GLProgramStateCache* getInstance(); - static void destroyInstance(); - GLProgramState* getProgramState(GLProgram* program); - - void removeProgramState(GLProgram* program); - + GLProgramState* getGLProgramState(GLProgram* program); + void removeAllGLProgramState(); + void removeUnusedGLProgramState(); + protected: GLProgramStateCache(); - ~GLProgramStateCache(); - std::unordered_map _glProgramStates; + Map _glProgramStates; static GLProgramStateCache* s_instance; }; diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index ff9532ff5e..8831f135fa 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -30,7 +30,7 @@ #include "renderer/CCBatchCommand.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCGroupCommand.h" -#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgramCache.h" #include "renderer/ccGLStateCache.h" #include "base/CCConfiguration.h" #include "base/CCDirector.h" diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index e91326b67d..bd3ed6399a 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -56094,7 +56094,7 @@ int lua_cocos2dx_ShaderCache_getInstance(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::ShaderCache* ret = cocos2d::ShaderCache::getInstance(); + cocos2d::ShaderCache* ret = cocos2d::GLProgramCache::getInstance(); object_to_luaval(tolua_S, "cc.ShaderCache",(cocos2d::ShaderCache*)ret); return 1; } diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index ed45b31083..0494639b94 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -26,7 +26,7 @@ THE SOFTWARE. #include "ui/UIHelper.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" #include "renderer/CCGLProgram.h" -#include "renderer/CCShaderCache.h" +#include "renderer/CCGLProgramCache.h" #include "base/CCDirector.h" #include "2d/CCDrawingPrimitives.h" #include "renderer/CCRenderer.h" diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 2585d08b3c..10e66b06e9 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -615,7 +615,7 @@ color3B = Color3B::WHITE; | FileUtils::sharedFileUtils | FileUtils::getInstance | | FileUtils::purgeFileUtils | FileUtils::destroyInstance | | GLView::sharedOpenGLView | GLView::getInstance | - | ShaderCache::sharedShaderCache | ShaderCache::getInstance | + | ShaderCache::sharedShaderCache | GLProgramCache::getInstance | | ShaderCache::purgeSharedShaderCache | ShaderCache::destroyInstance | | AnimationCache::sharedAnimationCache | AnimationCache::getInstance | | AnimationCache::purgeSharedAnimationCache | AnimationCache::destroyInstance | diff --git a/tests/cpp-tests/Classes/Box2DTestBed/GLES-Render.cpp b/tests/cpp-tests/Classes/Box2DTestBed/GLES-Render.cpp index e39dafb36e..7996fd737e 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/GLES-Render.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/GLES-Render.cpp @@ -40,7 +40,7 @@ GLESDebugDraw::GLESDebugDraw( float32 ratio ) void GLESDebugDraw::initShader( void ) { - mShaderProgram = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR); + mShaderProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR); mColorLocation = glGetUniformLocation( mShaderProgram->getProgram(), "u_color"); } diff --git a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp index bbbec220e8..8deebd8368 100644 --- a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -748,10 +748,10 @@ void RawStencilBufferTest3::setupStencilForDrawingOnPlane(GLint plane) void RawStencilBufferTestAlphaTest::setup() { RawStencilBufferTest::setup(); - auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); + auto programState = GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); for(int i = 0; i < _planeCount; ++i) { - _spritesStencil.at(i)->setGLProgram(program ); + _spritesStencil.at(i)->setGLProgramState(programState); } } //@implementation RawStencilBufferTest4 @@ -770,7 +770,7 @@ void RawStencilBufferTest4::setupStencilForClippingOnPlane(GLint plane) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, _alphaThreshold); #else - auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); + auto program = GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->use(); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); @@ -803,7 +803,7 @@ void RawStencilBufferTest5::setupStencilForClippingOnPlane(GLint plane) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, _alphaThreshold); #else - auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); + auto program = GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->use(); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); @@ -869,7 +869,7 @@ void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, _alphaThreshold); #else - auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); + auto program = GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->use(); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 2117dd580d..cf2c2671c6 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -185,7 +185,7 @@ void ArmatureTestLayer::onEnter() addChild(menu, 100); - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } void ArmatureTestLayer::onExit() diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index 2858031670..cfff010240 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -150,7 +150,7 @@ void SceneEditorTestLayer::onEnter() addChild(menu, 100); - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } void SceneEditorTestLayer::onExit() diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp index 9bbd29753f..812fd1c13f 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp @@ -169,7 +169,7 @@ void AtlasDemo::backCallback(Ref* sender) //------------------------------------------------------------------ Atlas1::Atlas1() { - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE)); + setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE)); _textureAtlas = TextureAtlas::create(s_AtlasTest, 3); _textureAtlas->retain(); auto s = Director::getInstance()->getWinSize(); diff --git a/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp b/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp index c8b6b7b94f..b12eb3c6b7 100644 --- a/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp +++ b/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp @@ -14,7 +14,7 @@ class TouchPoint : public Node public: TouchPoint() { - setGLProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index 6fe19b6d7a..3965b96546 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -989,8 +989,8 @@ public: sprite->initWithFile(spritefilename); sprite->autorelease(); - auto shader = CCShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR); - sprite->setGLProgram(shader); + auto shaderState = GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR); + sprite->setGLProgramState(shaderState); return sprite; } virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override; diff --git a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp index 9623232d40..cee3b33ac0 100644 --- a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp +++ b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp @@ -945,7 +945,7 @@ SpriteZVertex::SpriteZVertex() // // Configure shader to mimic glAlphaTest // - auto alphaTestShader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + auto alphaTestShader = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); GLint alphaValueLocation = glGetUniformLocation(alphaTestShader->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); // set alpha test value @@ -1035,7 +1035,7 @@ SpriteBatchNodeZVertex::SpriteBatchNodeZVertex() // // Configure shader to mimic glAlphaTest // - auto alphaTestShader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + auto alphaTestShader = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); GLint alphaValueLocation = glGetUniformLocation(alphaTestShader->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); // set alpha test value From b62f4e51a454b356bfaaeb712c4d1ad2a670667a Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 18:40:53 -0700 Subject: [PATCH 073/174] Updates Linux project --- cocos/renderer/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/renderer/CMakeLists.txt b/cocos/renderer/CMakeLists.txt index a51f6640cb..35cc09b4d8 100644 --- a/cocos/renderer/CMakeLists.txt +++ b/cocos/renderer/CMakeLists.txt @@ -8,7 +8,7 @@ set(COCOS_RENDERER_SRC renderer/CCQuadCommand.cpp renderer/CCRenderCommand.cpp renderer/CCRenderer.cpp - renderer/CCShaderCache.cpp + renderer/CCGLProgramCache.cpp renderer/ccGLStateCache.cpp renderer/ccShaders.cpp ) From 63c7c6a05ceabd5010e684cf726e449b7ebb983c Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 18:41:12 -0700 Subject: [PATCH 074/174] Updates template files --- templates/cocos2dx_files.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index ed840d9629..348d1e1e7a 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -852,6 +852,8 @@ "cocos/renderer/CCCustomCommand.h", "cocos/renderer/CCGLProgram.cpp", "cocos/renderer/CCGLProgram.h", + "cocos/renderer/CCGLProgramCache.cpp", + "cocos/renderer/CCGLProgramCache.h", "cocos/renderer/CCGLProgramState.cpp", "cocos/renderer/CCGLProgramState.h", "cocos/renderer/CCGLProgramStateCache.cpp", @@ -865,8 +867,6 @@ "cocos/renderer/CCRenderCommandPool.h", "cocos/renderer/CCRenderer.cpp", "cocos/renderer/CCRenderer.h", - "cocos/renderer/CCShaderCache.cpp", - "cocos/renderer/CCShaderCache.h", "cocos/renderer/CMakeLists.txt", "cocos/renderer/ccGLStateCache.cpp", "cocos/renderer/ccGLStateCache.h", @@ -3474,6 +3474,7 @@ "plugin/tools/toolsForPublish/checkEnvironment.sh", "plugin/tools/toolsForPublish/genPrebuildMK.sh", "plugin/tools/toolsForPublish/publishPlugin.sh", + "tools/particle/convert_YCoordFlipped.py", "v3-deps-1.zip" ], "lua": [ From d46729862cd403eea86ca21a082a1df5d3c82913 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 9 May 2014 19:05:39 -0700 Subject: [PATCH 075/174] android rename ShaderCahe to GLProgramCache --- cocos/2d/platform/android/javaactivity.cpp | 4 ++-- cocos/Android.mk | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/2d/platform/android/javaactivity.cpp b/cocos/2d/platform/android/javaactivity.cpp index 52190a117a..b4d265d162 100644 --- a/cocos/2d/platform/android/javaactivity.cpp +++ b/cocos/2d/platform/android/javaactivity.cpp @@ -28,7 +28,7 @@ THE SOFTWARE. #include "CCEventCustom.h" #include "CCEventType.h" #include "CCGLView.h" -#include "CCShaderCache.h" +#include "CCGLProgramCache.h" #include "CCTextureCache.h" #include "platform/android/jni/JniHelper.h" #include @@ -68,7 +68,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi else { cocos2d::GL::invalidateStateCache(); - cocos2d::ShaderCache::getInstance()->reloadDefaultShaders(); + cocos2d::GLProgramCache::getInstance()->reloadDefaultGLPrograms(); cocos2d::DrawPrimitives::init(); cocos2d::VolatileTextureMgr::reloadAllTextures(); diff --git a/cocos/Android.mk b/cocos/Android.mk index 60cc78bb1c..75a09812f2 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -141,7 +141,7 @@ renderer/CCGroupCommand.cpp \ renderer/CCQuadCommand.cpp \ renderer/CCRenderCommand.cpp \ renderer/CCRenderer.cpp \ -renderer/CCShaderCache.cpp \ +renderer/CCGLProgramCache.cpp \ renderer/CCShaders.cpp \ deprecated/CCArray.cpp \ deprecated/CCSet.cpp \ From 8f71e65482778238f32584cfa5cfcea3cb5b21a4 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 19:07:22 -0700 Subject: [PATCH 076/174] Compiles on windows, sort of --- cocos/2d/cocos2d.vcxproj | 45 +++--- cocos/2d/cocos2d.vcxproj.filters | 135 ++++++++---------- cocos/renderer/ccShader_Label.vert | 6 +- cocos/renderer/ccShader_Label_df.frag | 4 +- cocos/renderer/ccShader_Label_df_glow.frag | 4 +- cocos/renderer/ccShader_Label_normal.frag | 4 +- cocos/renderer/ccShader_Label_outline.frag | 4 +- cocos/renderer/ccShader_PositionColor.frag | 4 +- cocos/renderer/ccShader_PositionColor.vert | 6 +- .../ccShader_PositionColorLengthTexture.frag | 12 +- .../ccShader_PositionColorLengthTexture.vert | 6 +- cocos/renderer/ccShader_PositionTexture.frag | 4 +- cocos/renderer/ccShader_PositionTexture.vert | 6 +- .../ccShader_PositionTextureA8Color.frag | 4 +- .../ccShader_PositionTextureA8Color.vert | 6 +- .../ccShader_PositionTextureColor.frag | 4 +- .../ccShader_PositionTextureColor.vert | 6 +- .../ccShader_PositionTexture_uColor.frag | 4 +- .../ccShader_PositionTexture_uColor.vert | 6 +- cocos/renderer/ccShader_Position_uColor.frag | 4 +- cocos/renderer/ccShader_Position_uColor.vert | 6 +- 21 files changed, 134 insertions(+), 146 deletions(-) diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj index 55f16dd01b..33a199b37e 100644 --- a/cocos/2d/cocos2d.vcxproj +++ b/cocos/2d/cocos2d.vcxproj @@ -235,6 +235,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + @@ -242,7 +243,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - @@ -413,6 +413,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + @@ -421,30 +422,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - - - - - - - - - - - - - - - - - - - - - - - @@ -549,6 +527,25 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + + + + + + + + + + + + + + + + + + + diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters index 381aca0050..7c04d6a9f0 100644 --- a/cocos/2d/cocos2d.vcxproj.filters +++ b/cocos/2d/cocos2d.vcxproj.filters @@ -100,8 +100,8 @@ {02a21a86-8f65-441b-ae13-11dec1c45ee5} - - {406577df-e0cd-4148-8e00-9bc159e0a799} + + {438e71df-3684-4619-9659-10e07ed6cd62} @@ -576,10 +576,10 @@ renderer - + renderer - + renderer @@ -1115,72 +1115,6 @@ renderer - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - renderer @@ -1190,10 +1124,10 @@ renderer - + renderer - + renderer @@ -1224,5 +1158,62 @@ math + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + + + renderer\shaders + \ No newline at end of file diff --git a/cocos/renderer/ccShader_Label.vert b/cocos/renderer/ccShader_Label.vert index 02b3790504..3e39b68c20 100644 --- a/cocos/renderer/ccShader_Label.vert +++ b/cocos/renderer/ccShader_Label.vert @@ -29,13 +29,13 @@ attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec4 a_color; -#ifdef GL_ES +#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; varying mediump vec2 v_texCoord; -#else +#else\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; -#endif +#endif\n void main() { diff --git a/cocos/renderer/ccShader_Label_df.frag b/cocos/renderer/ccShader_Label_df.frag index 31c9ec0336..29b3b95669 100644 --- a/cocos/renderer/ccShader_Label_df.frag +++ b/cocos/renderer/ccShader_Label_df.frag @@ -1,8 +1,8 @@ const char* ccLabelDistanceFieldNormal_frag = STRINGIFY( -#ifdef GL_ES +#ifdef GL_ES\n precision lowp float; -#endif +#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; diff --git a/cocos/renderer/ccShader_Label_df_glow.frag b/cocos/renderer/ccShader_Label_df_glow.frag index 9d6ab500af..0c7dbef1f0 100644 --- a/cocos/renderer/ccShader_Label_df_glow.frag +++ b/cocos/renderer/ccShader_Label_df_glow.frag @@ -1,8 +1,8 @@ const char* ccLabelDistanceFieldGlow_frag = STRINGIFY( -#ifdef GL_ES +#ifdef GL_ES\n precision lowp float; -#endif +#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; diff --git a/cocos/renderer/ccShader_Label_normal.frag b/cocos/renderer/ccShader_Label_normal.frag index 0d4d2788d1..42d68c4b8e 100644 --- a/cocos/renderer/ccShader_Label_normal.frag +++ b/cocos/renderer/ccShader_Label_normal.frag @@ -24,9 +24,9 @@ */ const char* ccLabelNormal_frag = STRINGIFY( -#ifdef GL_ES +#ifdef GL_ES\n precision lowp float; -#endif +#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; diff --git a/cocos/renderer/ccShader_Label_outline.frag b/cocos/renderer/ccShader_Label_outline.frag index 967f83c0b9..cc94cdc499 100644 --- a/cocos/renderer/ccShader_Label_outline.frag +++ b/cocos/renderer/ccShader_Label_outline.frag @@ -1,7 +1,7 @@ const char* ccLabelOutline_frag = STRINGIFY( -#ifdef GL_ES +#ifdef GL_ES\n precision lowp float; -#endif +#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; diff --git a/cocos/renderer/ccShader_PositionColor.frag b/cocos/renderer/ccShader_PositionColor.frag index a42854f1fb..0ad897f79d 100644 --- a/cocos/renderer/ccShader_PositionColor.frag +++ b/cocos/renderer/ccShader_PositionColor.frag @@ -25,9 +25,9 @@ const char* ccPositionColor_frag = STRINGIFY( -#ifdef GL_ES +#ifdef GL_ES\n precision lowp float; -#endif +#endif\n varying vec4 v_fragmentColor; diff --git a/cocos/renderer/ccShader_PositionColor.vert b/cocos/renderer/ccShader_PositionColor.vert index fd1694df4e..4e23b6aa9c 100644 --- a/cocos/renderer/ccShader_PositionColor.vert +++ b/cocos/renderer/ccShader_PositionColor.vert @@ -28,11 +28,11 @@ const char* ccPositionColor_vert = STRINGIFY( attribute vec4 a_position; attribute vec4 a_color; -#ifdef GL_ES +#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; -#else +#else\n varying vec4 v_fragmentColor; -#endif +#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionColorLengthTexture.frag b/cocos/renderer/ccShader_PositionColorLengthTexture.frag index e47ebf20c3..e4bba63b31 100644 --- a/cocos/renderer/ccShader_PositionColorLengthTexture.frag +++ b/cocos/renderer/ccShader_PositionColorLengthTexture.frag @@ -21,22 +21,22 @@ const char* ccPositionColorLengthTexture_frag = STRINGIFY( -#ifdef GL_ES +#ifdef GL_ES\n // #extension GL_OES_standard_derivatives : enable - +\n varying mediump vec4 v_color; varying mediump vec2 v_texcoord; -#else +#else\n varying vec4 v_color; varying vec2 v_texcoord; -#endif +#endif\n void main() { // #if defined GL_OES_standard_derivatives // gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); -// #else +// #else\n gl_FragColor = v_color*step(0.0, 1.0 - length(v_texcoord)); -// #endif +// #endif\n } ); diff --git a/cocos/renderer/ccShader_PositionColorLengthTexture.vert b/cocos/renderer/ccShader_PositionColorLengthTexture.vert index 0693b74659..68276f83fe 100644 --- a/cocos/renderer/ccShader_PositionColorLengthTexture.vert +++ b/cocos/renderer/ccShader_PositionColorLengthTexture.vert @@ -21,7 +21,7 @@ const char* ccPositionColorLengthTexture_vert = STRINGIFY( -#ifdef GL_ES +#ifdef GL_ES\n attribute mediump vec4 a_position; attribute mediump vec2 a_texcoord; attribute mediump vec4 a_color; @@ -29,7 +29,7 @@ attribute mediump vec4 a_color; varying mediump vec4 v_color; varying mediump vec2 v_texcoord; -#else +#else\n attribute vec4 a_position; attribute vec2 a_texcoord; @@ -37,7 +37,7 @@ attribute vec4 a_color; varying vec4 v_color; varying vec2 v_texcoord; -#endif +#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionTexture.frag b/cocos/renderer/ccShader_PositionTexture.frag index bb072775bd..80d901d43e 100644 --- a/cocos/renderer/ccShader_PositionTexture.frag +++ b/cocos/renderer/ccShader_PositionTexture.frag @@ -25,9 +25,9 @@ const char* ccPositionTexture_frag = STRINGIFY( -#ifdef GL_ES +#ifdef GL_ES\n precision lowp float; -#endif +#endif\n varying vec2 v_texCoord; uniform sampler2D CC_Texture0; diff --git a/cocos/renderer/ccShader_PositionTexture.vert b/cocos/renderer/ccShader_PositionTexture.vert index 288e860505..df8b8c5606 100644 --- a/cocos/renderer/ccShader_PositionTexture.vert +++ b/cocos/renderer/ccShader_PositionTexture.vert @@ -28,11 +28,11 @@ const char* ccPositionTexture_vert = STRINGIFY( attribute vec4 a_position; attribute vec2 a_texCoord; -#ifdef GL_ES +#ifdef GL_ES\n varying mediump vec2 v_texCoord; -#else +#else\n varying vec2 v_texCoord; -#endif +#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionTextureA8Color.frag b/cocos/renderer/ccShader_PositionTextureA8Color.frag index 6c5e6cdd0a..44e3e9d9aa 100644 --- a/cocos/renderer/ccShader_PositionTextureA8Color.frag +++ b/cocos/renderer/ccShader_PositionTextureA8Color.frag @@ -25,9 +25,9 @@ const char* ccPositionTextureA8Color_frag = STRINGIFY( -#ifdef GL_ES +#ifdef GL_ES\n precision lowp float; -#endif +#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; diff --git a/cocos/renderer/ccShader_PositionTextureA8Color.vert b/cocos/renderer/ccShader_PositionTextureA8Color.vert index a4d8a833d1..bd250628c7 100644 --- a/cocos/renderer/ccShader_PositionTextureA8Color.vert +++ b/cocos/renderer/ccShader_PositionTextureA8Color.vert @@ -29,13 +29,13 @@ attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec4 a_color; -#ifdef GL_ES +#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; varying mediump vec2 v_texCoord; -#else +#else\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; -#endif +#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionTextureColor.frag b/cocos/renderer/ccShader_PositionTextureColor.frag index d31c530775..e3f2b93ff5 100644 --- a/cocos/renderer/ccShader_PositionTextureColor.frag +++ b/cocos/renderer/ccShader_PositionTextureColor.frag @@ -24,9 +24,9 @@ */ const char* ccPositionTextureColor_frag = STRINGIFY( -#ifdef GL_ES +\n#ifdef GL_ES\n precision lowp float; -#endif +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; diff --git a/cocos/renderer/ccShader_PositionTextureColor.vert b/cocos/renderer/ccShader_PositionTextureColor.vert index 1c3128eece..bf73900da8 100644 --- a/cocos/renderer/ccShader_PositionTextureColor.vert +++ b/cocos/renderer/ccShader_PositionTextureColor.vert @@ -28,13 +28,13 @@ attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec4 a_color; -#ifdef GL_ES +\n#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; varying mediump vec2 v_texCoord; -#else +\n#else\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; -#endif +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionTexture_uColor.frag b/cocos/renderer/ccShader_PositionTexture_uColor.frag index 8b13f64bab..12ea811d46 100644 --- a/cocos/renderer/ccShader_PositionTexture_uColor.frag +++ b/cocos/renderer/ccShader_PositionTexture_uColor.frag @@ -25,9 +25,9 @@ const char* ccPositionTexture_uColor_frag = STRINGIFY( -#ifdef GL_ES +#ifdef GL_ES\n precision lowp float; -#endif +#endif\n uniform vec4 u_color; diff --git a/cocos/renderer/ccShader_PositionTexture_uColor.vert b/cocos/renderer/ccShader_PositionTexture_uColor.vert index d24fbd61f8..33f56d1c50 100644 --- a/cocos/renderer/ccShader_PositionTexture_uColor.vert +++ b/cocos/renderer/ccShader_PositionTexture_uColor.vert @@ -28,11 +28,11 @@ const char* ccPositionTexture_uColor_vert = STRINGIFY( attribute vec4 a_position; attribute vec2 a_texCoord; -#ifdef GL_ES +#ifdef GL_ES\n varying mediump vec2 v_texCoord; -#else +#else\n varying vec2 v_texCoord; -#endif +#endif\n void main() { diff --git a/cocos/renderer/ccShader_Position_uColor.frag b/cocos/renderer/ccShader_Position_uColor.frag index 268e36ec7d..ce71bbe1e7 100644 --- a/cocos/renderer/ccShader_Position_uColor.frag +++ b/cocos/renderer/ccShader_Position_uColor.frag @@ -25,9 +25,9 @@ const char* ccPosition_uColor_frag = STRINGIFY( -#ifdef GL_ES +#ifdef GL_ES\n precision lowp float; -#endif +#endif\n varying vec4 v_fragmentColor; diff --git a/cocos/renderer/ccShader_Position_uColor.vert b/cocos/renderer/ccShader_Position_uColor.vert index 63301dc1b6..7470142216 100644 --- a/cocos/renderer/ccShader_Position_uColor.vert +++ b/cocos/renderer/ccShader_Position_uColor.vert @@ -29,11 +29,11 @@ attribute vec4 a_position; uniform vec4 u_color; uniform float u_pointSize; -#ifdef GL_ES +#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; -#else +#else\n varying vec4 v_fragmentColor; -#endif +#endif\n void main() { From 488a8deae95b5881c7cf8a194064656f2e395df1 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 19:13:12 -0700 Subject: [PATCH 077/174] Shader fixes for windows --- cocos/renderer/ccShader_Label.vert | 6 +++--- cocos/renderer/ccShader_Label_df.frag | 16 ++++++++-------- cocos/renderer/ccShader_Label_df_glow.frag | 12 ++++++------ cocos/renderer/ccShader_Label_normal.frag | 8 ++++---- cocos/renderer/ccShader_Label_outline.frag | 7 +++++-- cocos/renderer/ccShader_PositionColor.frag | 4 ++-- cocos/renderer/ccShader_PositionColor.vert | 6 +++--- .../ccShader_PositionColorLengthTexture.frag | 14 +++++++------- .../ccShader_PositionColorLengthTexture.vert | 7 ++++--- cocos/renderer/ccShader_PositionTexture.frag | 4 ++-- cocos/renderer/ccShader_PositionTexture.vert | 6 +++--- .../ccShader_PositionTextureA8Color.frag | 8 ++++---- .../ccShader_PositionTextureA8Color.vert | 6 +++--- .../ccShader_PositionTextureColorAlphaTest.frag | 8 ++++---- .../ccShader_PositionTextureColor_noMVP.frag | 4 ++-- .../ccShader_PositionTextureColor_noMVP.vert | 6 +++--- .../ccShader_PositionTexture_uColor.frag | 4 ++-- .../ccShader_PositionTexture_uColor.vert | 6 +++--- cocos/renderer/ccShader_Position_uColor.frag | 4 ++-- cocos/renderer/ccShader_Position_uColor.vert | 6 +++--- 20 files changed, 73 insertions(+), 69 deletions(-) diff --git a/cocos/renderer/ccShader_Label.vert b/cocos/renderer/ccShader_Label.vert index 3e39b68c20..a5d41eb356 100644 --- a/cocos/renderer/ccShader_Label.vert +++ b/cocos/renderer/ccShader_Label.vert @@ -29,13 +29,13 @@ attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec4 a_color; -#ifdef GL_ES\n +\n#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; varying mediump vec2 v_texCoord; -#else\n +\n#else\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; -#endif\n +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_Label_df.frag b/cocos/renderer/ccShader_Label_df.frag index 29b3b95669..5d4c4cce2a 100644 --- a/cocos/renderer/ccShader_Label_df.frag +++ b/cocos/renderer/ccShader_Label_df.frag @@ -1,8 +1,8 @@ const char* ccLabelDistanceFieldNormal_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; @@ -12,13 +12,13 @@ uniform vec4 v_textColor; void main() { vec4 color = texture2D(CC_Texture0, v_texCoord); - //the texture use dual channel 16-bit output for distance_map - //float dist = color.b+color.g/256.0; - // the texture use single channel 8-bit output for distance_map + //the texture use dual channel 16-bit output for distance_map \n + //float dist = color.b+color.g/256.0; \n + // the texture use single channel 8-bit output for distance_map \n float dist = color.a; - //todo:Implementation 'fwidth' for glsl 1.0 - //float width = fwidth(dist); - //assign width for constant will lead to a little bit fuzzy,it's temporary measure. + //todo:Implementation 'fwidth' for glsl 1.0 \n + //float width = fwidth(dist); \n + //assign width for constant will lead to a little bit fuzzy,it's temporary measure.\n float width = 0.04; float alpha = smoothstep(0.5-width, 0.5+width, dist) * v_textColor.a; gl_FragColor = v_fragmentColor * vec4(v_textColor.rgb,alpha); diff --git a/cocos/renderer/ccShader_Label_df_glow.frag b/cocos/renderer/ccShader_Label_df_glow.frag index 0c7dbef1f0..6b5c37c346 100644 --- a/cocos/renderer/ccShader_Label_df_glow.frag +++ b/cocos/renderer/ccShader_Label_df_glow.frag @@ -1,8 +1,8 @@ const char* ccLabelDistanceFieldGlow_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; @@ -13,12 +13,12 @@ uniform vec4 v_textColor; void main() { float dist = texture2D(CC_Texture0, v_texCoord).a; - //todo:Implementation 'fwidth' for glsl 1.0 - //float width = fwidth(dist); - //assign width for constant will lead to a little bit fuzzy,it's temporary measure. + //todo:Implementation 'fwidth' for glsl 1.0 \n + //float width = fwidth(dist); \n + //assign width for constant will lead to a little bit fuzzy,it's temporary measure.\n float width = 0.04; float alpha = smoothstep(0.5-width, 0.5+width, dist); - //glow + //glow \n float mu = smoothstep(0.5, 1.0, sqrt(dist)); vec4 color = v_effectColor*(1.0-alpha) + v_textColor*alpha; gl_FragColor = v_fragmentColor * vec4(color.rgb, max(alpha,mu)*color.a); diff --git a/cocos/renderer/ccShader_Label_normal.frag b/cocos/renderer/ccShader_Label_normal.frag index 42d68c4b8e..df527aa4a6 100644 --- a/cocos/renderer/ccShader_Label_normal.frag +++ b/cocos/renderer/ccShader_Label_normal.frag @@ -24,9 +24,9 @@ */ const char* ccLabelNormal_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; @@ -35,8 +35,8 @@ uniform vec4 v_textColor; void main() { - gl_FragColor = v_fragmentColor * vec4( v_textColor.rgb,// RGB from uniform - v_textColor.a * texture2D(CC_Texture0, v_texCoord).a// A from texture & uniform + gl_FragColor = v_fragmentColor * vec4( v_textColor.rgb,// RGB from uniform\n + v_textColor.a * texture2D(CC_Texture0, v_texCoord).a// A from texture & uniform\n ); } ); diff --git a/cocos/renderer/ccShader_Label_outline.frag b/cocos/renderer/ccShader_Label_outline.frag index cc94cdc499..1dbd0010f0 100644 --- a/cocos/renderer/ccShader_Label_outline.frag +++ b/cocos/renderer/ccShader_Label_outline.frag @@ -1,7 +1,10 @@ +/* + * LICENSE ??? + */ const char* ccLabelOutline_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; diff --git a/cocos/renderer/ccShader_PositionColor.frag b/cocos/renderer/ccShader_PositionColor.frag index 0ad897f79d..21d6af569b 100644 --- a/cocos/renderer/ccShader_PositionColor.frag +++ b/cocos/renderer/ccShader_PositionColor.frag @@ -25,9 +25,9 @@ const char* ccPositionColor_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; diff --git a/cocos/renderer/ccShader_PositionColor.vert b/cocos/renderer/ccShader_PositionColor.vert index 4e23b6aa9c..c3350505fb 100644 --- a/cocos/renderer/ccShader_PositionColor.vert +++ b/cocos/renderer/ccShader_PositionColor.vert @@ -28,11 +28,11 @@ const char* ccPositionColor_vert = STRINGIFY( attribute vec4 a_position; attribute vec4 a_color; -#ifdef GL_ES\n +\n#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; -#else\n +\n#else\n varying vec4 v_fragmentColor; -#endif\n +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionColorLengthTexture.frag b/cocos/renderer/ccShader_PositionColorLengthTexture.frag index e4bba63b31..4b3d69a3e2 100644 --- a/cocos/renderer/ccShader_PositionColorLengthTexture.frag +++ b/cocos/renderer/ccShader_PositionColorLengthTexture.frag @@ -21,20 +21,20 @@ const char* ccPositionColorLengthTexture_frag = STRINGIFY( -#ifdef GL_ES\n -// #extension GL_OES_standard_derivatives : enable -\n +\n#ifdef GL_ES\n +// #extension GL_OES_standard_derivatives : enable\n + varying mediump vec4 v_color; varying mediump vec2 v_texcoord; -#else\n +\n#else\n varying vec4 v_color; varying vec2 v_texcoord; -#endif\n +\n#endif\n void main() { -// #if defined GL_OES_standard_derivatives -// gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); +// #if defined GL_OES_standard_derivatives\n +// gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord));\n // #else\n gl_FragColor = v_color*step(0.0, 1.0 - length(v_texcoord)); // #endif\n diff --git a/cocos/renderer/ccShader_PositionColorLengthTexture.vert b/cocos/renderer/ccShader_PositionColorLengthTexture.vert index 68276f83fe..cebc2c7b13 100644 --- a/cocos/renderer/ccShader_PositionColorLengthTexture.vert +++ b/cocos/renderer/ccShader_PositionColorLengthTexture.vert @@ -21,7 +21,7 @@ const char* ccPositionColorLengthTexture_vert = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n attribute mediump vec4 a_position; attribute mediump vec2 a_texcoord; attribute mediump vec4 a_color; @@ -29,7 +29,7 @@ attribute mediump vec4 a_color; varying mediump vec4 v_color; varying mediump vec2 v_texcoord; -#else\n +\n#else\n attribute vec4 a_position; attribute vec2 a_texcoord; @@ -37,7 +37,8 @@ attribute vec4 a_color; varying vec4 v_color; varying vec2 v_texcoord; -#endif\n + +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionTexture.frag b/cocos/renderer/ccShader_PositionTexture.frag index 80d901d43e..b6bef35075 100644 --- a/cocos/renderer/ccShader_PositionTexture.frag +++ b/cocos/renderer/ccShader_PositionTexture.frag @@ -25,9 +25,9 @@ const char* ccPositionTexture_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec2 v_texCoord; uniform sampler2D CC_Texture0; diff --git a/cocos/renderer/ccShader_PositionTexture.vert b/cocos/renderer/ccShader_PositionTexture.vert index df8b8c5606..8fc2c442b6 100644 --- a/cocos/renderer/ccShader_PositionTexture.vert +++ b/cocos/renderer/ccShader_PositionTexture.vert @@ -28,11 +28,11 @@ const char* ccPositionTexture_vert = STRINGIFY( attribute vec4 a_position; attribute vec2 a_texCoord; -#ifdef GL_ES\n +\n#ifdef GL_ES\n varying mediump vec2 v_texCoord; -#else\n +\n#else\n varying vec2 v_texCoord; -#endif\n +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionTextureA8Color.frag b/cocos/renderer/ccShader_PositionTextureA8Color.frag index 44e3e9d9aa..e393b97f77 100644 --- a/cocos/renderer/ccShader_PositionTextureA8Color.frag +++ b/cocos/renderer/ccShader_PositionTextureA8Color.frag @@ -25,9 +25,9 @@ const char* ccPositionTextureA8Color_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; @@ -35,8 +35,8 @@ uniform sampler2D CC_Texture0; void main() { - gl_FragColor = vec4( v_fragmentColor.rgb,// RGB from uniform - v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a // A from texture & uniform + gl_FragColor = vec4( v_fragmentColor.rgb,// RGB from uniform\n + v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a // A from texture & uniform\n ); } ); diff --git a/cocos/renderer/ccShader_PositionTextureA8Color.vert b/cocos/renderer/ccShader_PositionTextureA8Color.vert index bd250628c7..a4c8e7be69 100644 --- a/cocos/renderer/ccShader_PositionTextureA8Color.vert +++ b/cocos/renderer/ccShader_PositionTextureA8Color.vert @@ -29,13 +29,13 @@ attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec4 a_color; -#ifdef GL_ES\n +\n#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; varying mediump vec2 v_texCoord; -#else\n +\n#else\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; -#endif\n +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionTextureColorAlphaTest.frag b/cocos/renderer/ccShader_PositionTextureColorAlphaTest.frag index 437c181f12..e0495191a9 100644 --- a/cocos/renderer/ccShader_PositionTextureColorAlphaTest.frag +++ b/cocos/renderer/ccShader_PositionTextureColorAlphaTest.frag @@ -24,9 +24,9 @@ const char* ccPositionTextureColorAlphaTest_frag = STRINGIFY( -#ifdef GL_ES +\n#ifdef GL_ES\n precision lowp float; -#endif +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; @@ -37,8 +37,8 @@ void main() { vec4 texColor = texture2D(CC_Texture0, v_texCoord); -// mimic: glAlphaFunc(GL_GREATER) -// pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value +\n// mimic: glAlphaFunc(GL_GREATER) +\n// pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value\n if ( texColor.a <= CC_alpha_value ) discard; diff --git a/cocos/renderer/ccShader_PositionTextureColor_noMVP.frag b/cocos/renderer/ccShader_PositionTextureColor_noMVP.frag index cd37da4233..e2c1efdc1c 100644 --- a/cocos/renderer/ccShader_PositionTextureColor_noMVP.frag +++ b/cocos/renderer/ccShader_PositionTextureColor_noMVP.frag @@ -24,9 +24,9 @@ */ const char* ccPositionTextureColor_noMVP_frag = STRINGIFY( -#ifdef GL_ES +\n#ifdef GL_ES\n precision lowp float; -#endif +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; diff --git a/cocos/renderer/ccShader_PositionTextureColor_noMVP.vert b/cocos/renderer/ccShader_PositionTextureColor_noMVP.vert index 9b5a226c1c..df4763ce77 100644 --- a/cocos/renderer/ccShader_PositionTextureColor_noMVP.vert +++ b/cocos/renderer/ccShader_PositionTextureColor_noMVP.vert @@ -28,13 +28,13 @@ attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec4 a_color; -#ifdef GL_ES +\n#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; varying mediump vec2 v_texCoord; -#else +\n#else\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; -#endif +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionTexture_uColor.frag b/cocos/renderer/ccShader_PositionTexture_uColor.frag index 12ea811d46..f5b8d8ff31 100644 --- a/cocos/renderer/ccShader_PositionTexture_uColor.frag +++ b/cocos/renderer/ccShader_PositionTexture_uColor.frag @@ -25,9 +25,9 @@ const char* ccPositionTexture_uColor_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n uniform vec4 u_color; diff --git a/cocos/renderer/ccShader_PositionTexture_uColor.vert b/cocos/renderer/ccShader_PositionTexture_uColor.vert index 33f56d1c50..53f6aad578 100644 --- a/cocos/renderer/ccShader_PositionTexture_uColor.vert +++ b/cocos/renderer/ccShader_PositionTexture_uColor.vert @@ -28,11 +28,11 @@ const char* ccPositionTexture_uColor_vert = STRINGIFY( attribute vec4 a_position; attribute vec2 a_texCoord; -#ifdef GL_ES\n +\n#ifdef GL_ES\n varying mediump vec2 v_texCoord; -#else\n +\n#else\n varying vec2 v_texCoord; -#endif\n +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_Position_uColor.frag b/cocos/renderer/ccShader_Position_uColor.frag index ce71bbe1e7..1f99562171 100644 --- a/cocos/renderer/ccShader_Position_uColor.frag +++ b/cocos/renderer/ccShader_Position_uColor.frag @@ -25,9 +25,9 @@ const char* ccPosition_uColor_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; diff --git a/cocos/renderer/ccShader_Position_uColor.vert b/cocos/renderer/ccShader_Position_uColor.vert index 7470142216..329f172606 100644 --- a/cocos/renderer/ccShader_Position_uColor.vert +++ b/cocos/renderer/ccShader_Position_uColor.vert @@ -29,11 +29,11 @@ attribute vec4 a_position; uniform vec4 u_color; uniform float u_pointSize; -#ifdef GL_ES\n +\n#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; -#else\n +\n#else\n varying vec4 v_fragmentColor; -#endif\n +\n#endif\n void main() { From 32d96ca9adef58ecfbd8434bfd54614ae60d686c Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 19:42:57 -0700 Subject: [PATCH 078/174] Compiles on Windows Phone 8 ... but does not run --- cocos/2d/cocos2d_wp8.vcxproj | 48 ++++----- cocos/2d/cocos2d_wp8.vcxproj.filters | 140 +++++++++++++-------------- 2 files changed, 94 insertions(+), 94 deletions(-) diff --git a/cocos/2d/cocos2d_wp8.vcxproj b/cocos/2d/cocos2d_wp8.vcxproj index 62c951f214..046820ed06 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj +++ b/cocos/2d/cocos2d_wp8.vcxproj @@ -271,6 +271,7 @@ + @@ -278,7 +279,6 @@ - @@ -497,6 +497,7 @@ + @@ -505,30 +506,7 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -645,6 +623,28 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/cocos/2d/cocos2d_wp8.vcxproj.filters b/cocos/2d/cocos2d_wp8.vcxproj.filters index 58d4bf9436..c739f13ae5 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj.filters +++ b/cocos/2d/cocos2d_wp8.vcxproj.filters @@ -600,10 +600,10 @@ renderer - + renderer - + renderer @@ -1192,77 +1192,11 @@ renderer - - renderer - renderer - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders - - - renderer\Shaders + + renderer @@ -1287,6 +1221,72 @@ math + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + + + renderer\Shaders + From c3a255e2d034e73d57365169e961443b66862e0c Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 9 May 2014 20:07:26 -0700 Subject: [PATCH 079/174] do not generate backupFile if it is not needed for convert particle file yCoordFlipped --- tools/particle/convert_YCoordFlipped.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/particle/convert_YCoordFlipped.py b/tools/particle/convert_YCoordFlipped.py index 9325db94c2..0626ebd894 100755 --- a/tools/particle/convert_YCoordFlipped.py +++ b/tools/particle/convert_YCoordFlipped.py @@ -5,6 +5,7 @@ import plistlib import os.path import argparse import glob +import shutil #keys in dictionary metaDataKey = 'metaData' @@ -38,14 +39,14 @@ def processConvertFile(filename): print('Begin process particle file: ' + filename) fp = open(filename, 'r') pl = plistlib.readPlist(fp) - backupFileName = filename+'.backup' - print('Write backup file to ' + backupFileName) - plistlib.writePlist(pl,backupFileName) if (not pl.has_key(yCoordFlippedKey)): print('Skip plist file: ' + filename + ' for there is no key for yCoordFlipped,') else: if(not checkFlippedConvertFlag(pl)): + backupFileName = filename+'.backup' + print('Write backup file to ' + backupFileName) + shutil.copyfile(filename,backupFileName) print('converting...') pl[yCoordFlippedKey] = -pl[yCoordFlippedKey] writeFlippedConvertFlag(pl) From 4a496689407226894b15d71b7e014f2db5e89f33 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 20:11:36 -0700 Subject: [PATCH 080/174] plist are not executable files --- tests/cpp-tests/Resources/Particles/BoilingFoam.plist | 0 tests/cpp-tests/Resources/Particles/BurstPipe.plist | 0 tests/cpp-tests/Resources/Particles/Comet.plist | 0 tests/cpp-tests/Resources/Particles/ExplodingRing.plist | 0 tests/cpp-tests/Resources/Particles/Flower.plist | 0 tests/cpp-tests/Resources/Particles/Galaxy.plist | 0 tests/cpp-tests/Resources/Particles/LavaFlow.plist | 0 tests/cpp-tests/Resources/Particles/Phoenix.plist | 0 tests/cpp-tests/Resources/Particles/SmallSun.plist | 0 tests/cpp-tests/Resources/Particles/SpinningPeas.plist | 0 tests/cpp-tests/Resources/Particles/Spiral.plist | 0 tests/cpp-tests/Resources/Particles/SpookyPeas.plist | 0 tests/cpp-tests/Resources/Particles/TestPremultipliedAlpha.plist | 0 tests/cpp-tests/Resources/Particles/Upsidedown.plist | 0 tests/cpp-tests/Resources/Particles/debian.plist | 0 tests/cpp-tests/Resources/Particles/lines.plist | 0 16 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/BoilingFoam.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/BurstPipe.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/Comet.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/ExplodingRing.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/Flower.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/Galaxy.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/LavaFlow.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/Phoenix.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/SmallSun.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/SpinningPeas.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/Spiral.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/SpookyPeas.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/TestPremultipliedAlpha.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/Upsidedown.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/debian.plist mode change 100755 => 100644 tests/cpp-tests/Resources/Particles/lines.plist diff --git a/tests/cpp-tests/Resources/Particles/BoilingFoam.plist b/tests/cpp-tests/Resources/Particles/BoilingFoam.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/BurstPipe.plist b/tests/cpp-tests/Resources/Particles/BurstPipe.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/Comet.plist b/tests/cpp-tests/Resources/Particles/Comet.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/ExplodingRing.plist b/tests/cpp-tests/Resources/Particles/ExplodingRing.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/Flower.plist b/tests/cpp-tests/Resources/Particles/Flower.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/Galaxy.plist b/tests/cpp-tests/Resources/Particles/Galaxy.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/LavaFlow.plist b/tests/cpp-tests/Resources/Particles/LavaFlow.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/Phoenix.plist b/tests/cpp-tests/Resources/Particles/Phoenix.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/SmallSun.plist b/tests/cpp-tests/Resources/Particles/SmallSun.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/SpinningPeas.plist b/tests/cpp-tests/Resources/Particles/SpinningPeas.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/Spiral.plist b/tests/cpp-tests/Resources/Particles/Spiral.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/SpookyPeas.plist b/tests/cpp-tests/Resources/Particles/SpookyPeas.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/TestPremultipliedAlpha.plist b/tests/cpp-tests/Resources/Particles/TestPremultipliedAlpha.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/Upsidedown.plist b/tests/cpp-tests/Resources/Particles/Upsidedown.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/debian.plist b/tests/cpp-tests/Resources/Particles/debian.plist old mode 100755 new mode 100644 diff --git a/tests/cpp-tests/Resources/Particles/lines.plist b/tests/cpp-tests/Resources/Particles/lines.plist old mode 100755 new mode 100644 From e84d96234b6fa1725eca40277f00dae87ea010ba Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 9 May 2014 20:34:15 -0700 Subject: [PATCH 081/174] add two shaderTest case for Trace comment out one(it is not working on IOS device) --- .../Classes/ShaderTest/ShaderTest.cpp | 61 +++++----- .../cpp-tests/Classes/ShaderTest/ShaderTest.h | 12 +- .../Resources/Shaders/shadertoy_FireBall.fsh | 55 +++++++++ .../Resources/Shaders/shadertoy_Glow.fsh | 108 ++++++++++++++++++ .../Resources/Shaders/shadertoy_LensFlare.fsh | 100 ++++++++++++++++ 5 files changed, 298 insertions(+), 38 deletions(-) create mode 100644 tests/cpp-tests/Resources/Shaders/shadertoy_FireBall.fsh create mode 100644 tests/cpp-tests/Resources/Shaders/shadertoy_Glow.fsh create mode 100644 tests/cpp-tests/Resources/Shaders/shadertoy_LensFlare.fsh diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index 25af88ac72..e22e9c6791 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -1,8 +1,6 @@ #include "ShaderTest.h" #include "../testResource.h" #include "cocos2d.h" -#include "ShaderTest.vsh.h" -#include "shaderTest.psh.h" static int sceneIdx = -1; @@ -12,7 +10,7 @@ static Layer* createShaderLayer(int nIndex) { switch (sceneIdx) { - case 0: return new ShaderFalme(); + case 0: return new ShaderLensFlare(); case 1: return new ShaderMandelbrot(); case 2: return new ShaderJulia(); case 3: return new ShaderHeart(); @@ -21,10 +19,9 @@ static Layer* createShaderLayer(int nIndex) case 6: return new ShaderBlur(); case 7: return new ShaderRetroEffect(); case 8: return new ShaderMonjori(); - case 9: return new ShaderStarNest(); - case 10: return new ShaderRelentless(); + //case 9: return new ShaderFireBall(); + case 9: return new ShaderGlow(); } - return NULL; } @@ -713,7 +710,7 @@ bool UniformShaderNode::initWithVertex(const char *vert, const char *frag) _time = 0; auto s = Director::getInstance()->getWinSize(); - _resolution = Vector2(s.width * CC_CONTENT_SCALE_FACTOR(), s.height * CC_CONTENT_SCALE_FACTOR()); + _resolution = Vector2(s.width , s.height ); getGLProgramState()->setUniformVec2("resolution", _resolution); scheduleUpdate(); @@ -723,13 +720,13 @@ bool UniformShaderNode::initWithVertex(const char *vert, const char *frag) _vertFileName = vert; _fragFileName = frag; - + return true; } void UniformShaderNode::loadShaderVertex(const char *vert, const char *frag) { - auto shader = GLProgram::createWithByteArrays(vert, frag); + auto shader = GLProgram::createWithFilenames(vert, frag); this->setGLProgram(shader); } @@ -742,8 +739,8 @@ void UniformShaderNode::setPosition(const Vector2 &newPosition) { Node::setPosition(newPosition); auto position = getPosition(); -//_center = Vector2(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR()); - // getGLProgramState()->setUniformVec2("center", _center); + _center = Vector2(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR()); + getGLProgramState()->setUniformVec2("center", _center); } void UniformShaderNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) @@ -778,30 +775,30 @@ void UniformShaderNode::onDraw(const Matrix &transform, bool transformUpdated) } -ShaderRelentless::ShaderRelentless() +ShaderLensFlare::ShaderLensFlare() { init(); } -std::string ShaderRelentless::title() const +std::string ShaderLensFlare::title() const { return "ShaderToy Test"; } -std::string ShaderRelentless::subtitle() const +std::string ShaderLensFlare::subtitle() const { - return "Relentless"; + return "Lens Flare "; } -bool ShaderRelentless::init() +bool ShaderLensFlare::init() { if (ShaderTestDemo::init()) { - auto sn = UniformShaderNode::shaderNodeWithVertex(shadertestvsh, shadertoyRelentlessFrag); + auto sn = UniformShaderNode::shaderNodeWithVertex("Shaders/example_Heart.vsh", "Shaders/shadertoy_LensFlare.fsh"); auto s = Director::getInstance()->getWinSize(); sn->setPosition(Vector2(s.width/2, s.height/2)); - sn->setContentSize(Size(s.width,s.height)); + sn->setContentSize(Size(s.width/2,s.height/2)); addChild(sn); return true; @@ -810,30 +807,30 @@ bool ShaderRelentless::init() return false; } -ShaderStarNest::ShaderStarNest() +ShaderFireBall::ShaderFireBall() { init(); } -std::string ShaderStarNest::title() const +std::string ShaderFireBall::title() const { return "ShaderToy Test"; } -std::string ShaderStarNest::subtitle() const +std::string ShaderFireBall::subtitle() const { - return "Star Nest"; + return "Fire Ball"; } -bool ShaderStarNest::init() +bool ShaderFireBall::init() { if (ShaderTestDemo::init()) { - auto sn = UniformShaderNode::shaderNodeWithVertex(shadertestvsh, starNestFrg); + auto sn = UniformShaderNode::shaderNodeWithVertex("Shaders/example_Heart.vsh", "Shaders/shadertoy_FireBall.fsh"); auto s = Director::getInstance()->getWinSize(); sn->setPosition(Vector2(s.width/2, s.height/2)); - sn->setContentSize(Size(s.width,s.height)); + sn->setContentSize(Size(s.width/2,s.height/2)); addChild(sn); return true; @@ -843,30 +840,30 @@ bool ShaderStarNest::init() } -ShaderFalme::ShaderFalme() +ShaderGlow::ShaderGlow() { init(); } -std::string ShaderFalme::title() const +std::string ShaderGlow::title() const { return "ShaderToy Test"; } -std::string ShaderFalme::subtitle() const +std::string ShaderGlow::subtitle() const { - return "Flame"; + return "Glow"; } -bool ShaderFalme::init() +bool ShaderGlow::init() { if (ShaderTestDemo::init()) { - auto sn = UniformShaderNode::shaderNodeWithVertex(shadertestvsh, starFlame); + auto sn = UniformShaderNode::shaderNodeWithVertex("Shaders/example_Heart.vsh", "Shaders/shadertoy_Glow.fsh"); auto s = Director::getInstance()->getWinSize(); sn->setPosition(Vector2(s.width/2, s.height/2)); - sn->setContentSize(Size(s.width,s.height)); + sn->setContentSize(Size(s.width/2,s.height/2)); addChild(sn); return true; diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h index 511e808740..e5722961dc 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h @@ -170,30 +170,30 @@ protected: }; -class ShaderRelentless : public ShaderTestDemo +class ShaderLensFlare : public ShaderTestDemo { public: - ShaderRelentless(); + ShaderLensFlare(); virtual std::string title() const override; virtual std::string subtitle() const override; virtual bool init(); }; -class ShaderStarNest : public ShaderTestDemo +class ShaderFireBall : public ShaderTestDemo { public: - ShaderStarNest(); + ShaderFireBall(); virtual std::string title() const override; virtual std::string subtitle() const override; virtual bool init(); }; -class ShaderFalme : public ShaderTestDemo +class ShaderGlow : public ShaderTestDemo { public: - ShaderFalme(); + ShaderGlow(); virtual std::string title() const override; virtual std::string subtitle() const override; diff --git a/tests/cpp-tests/Resources/Shaders/shadertoy_FireBall.fsh b/tests/cpp-tests/Resources/Shaders/shadertoy_FireBall.fsh new file mode 100644 index 0000000000..6aa906167f --- /dev/null +++ b/tests/cpp-tests/Resources/Shaders/shadertoy_FireBall.fsh @@ -0,0 +1,55 @@ + +uniform vec2 center; +uniform vec2 resolution; + +vec2 iCenter = center; +vec2 iResolution = resolution; // viewport resolution (in pixels) +float iGlobalTime = CC_Time[1]; // shader playback time (in seconds) +//uniform float iChannelTime[4]; // channel playback time (in seconds) +//uniform vec3 iChannelResolution[4]; // channel resolution (in pixels) +vec4 iMouse = vec4(0,0,0,0); // mouse pixel coords. xy: current (if MLB down), + + + +float snoise(vec3 uv, float res) +{ + const vec3 s = vec3(1e0, 1e2, 1e4); + + uv *= res; + + vec3 uv0 = floor(mod(uv, res))*s; + vec3 uv1 = floor(mod(uv+vec3(1.), res))*s; + + vec3 f = fract(uv); f = f*f*(3.0-2.0*f); + + vec4 v = vec4(uv0.x+uv0.y+uv0.z, uv1.x+uv0.y+uv0.z, + uv0.x+uv1.y+uv0.z, uv1.x+uv1.y+uv0.z); + + vec4 r = fract(sin(v*1e-3)*1e5); + float r0 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y); + + r = fract(sin((v + uv1.z - uv0.z)*1e-3)*1e5); + float r1 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y); + + return mix(r0, r1, f.z)*2.-1.; +} + +void main(void) +{ + //vec2 p = -.5 + gl_FragCoord.xy / iResolution.xy; + + vec2 p = (gl_FragCoord.xy - center.xy) / iResolution.xy; + p.x *= iResolution.x/iResolution.y; + + float color = 3.0 - (3.*length(2.*p)); + + vec3 coord = vec3(atan(p.x,p.y)/6.2832+.5, length(p)*.4, .5); + + for(int i = 1; i <= 3; i++) + { + float power = pow(2.0, float(i)); + color += (1.5 / power) * snoise(coord + vec3(0.,-iGlobalTime*.05, iGlobalTime*.01), power*16.); + } + gl_FragColor = vec4( color, pow(max(color,0.),2.)*0.4, pow(max(color,0.),3.)*0.15 , 1.0); +} + diff --git a/tests/cpp-tests/Resources/Shaders/shadertoy_Glow.fsh b/tests/cpp-tests/Resources/Shaders/shadertoy_Glow.fsh new file mode 100644 index 0000000000..93331de0c1 --- /dev/null +++ b/tests/cpp-tests/Resources/Shaders/shadertoy_Glow.fsh @@ -0,0 +1,108 @@ + +uniform vec2 center; +uniform vec2 resolution; + + +vec2 iResolution = resolution; // viewport resolution (in pixels) +float iGlobalTime = CC_Time[1]; // shader playback time (in seconds) +//uniform float iChannelTime[4]; // channel playback time (in seconds) +//uniform vec3 iChannelResolution[4]; // channel resolution (in pixels) +vec4 iMouse = vec4(0,0,0,0); // mouse pixel coords. xy: current (if MLB down), zw: click +//uniform sampler2D iChannel0; // input channel. XX = 2D/Cube + + + +void main(void) +{ + float pointRadius = 0.06; + float linkSize = 0.04; + float noiseStrength = 0.08; // range: 0-1 + + float minDimension = min(iResolution.x, iResolution.y); + vec2 bounds = vec2(iResolution.x / minDimension, iResolution.y / minDimension); + //vec2 uv = gl_FragCoord.xy / minDimension; + vec2 uv = (2. * gl_FragCoord.xy - center.xy) / iResolution.xy; + + vec3 pointR = vec3(0.0, 0.0, 1.0); + vec3 pointG = vec3(0.0, 0.0, 1.0); + vec3 pointB = vec3(0.0, 0.0, 1.0); + + // Make the points orbit round the origin in 3 dimensions. + // Coefficients are arbitrary to give different behaviours. + // The Z coordinate should always be >0.0, as it's used directly to + // multiply the radius to give the impression of depth. + pointR.x += 0.32 * sin(1.32 * iGlobalTime); + pointR.y += 0.3 * sin(1.03 * iGlobalTime); + pointR.z += 0.4 * sin(1.32 * iGlobalTime); + + pointG.x += 0.31 * sin(0.92 * iGlobalTime); + pointG.y += 0.29 * sin(0.99 * iGlobalTime); + pointG.z += 0.38 * sin(1.24 * iGlobalTime); + + pointB.x += 0.33 * sin(1.245 * iGlobalTime); + pointB.y += 0.3 * sin(1.41 * iGlobalTime); + pointB.z += 0.41 * sin(1.11 * iGlobalTime); + + // Centre the points in the display + vec2 midUV = vec2(bounds.x * 0.5, bounds.y * 0.5); + pointR.xy += midUV; + pointG.xy += midUV; + pointB.xy += midUV; + + // Calculate the vectors from the current fragment to the coloured points + vec2 vecToR = pointR.xy - uv; + vec2 vecToG = pointG.xy - uv; + vec2 vecToB = pointB.xy - uv; + + vec2 dirToR = normalize(vecToR.xy); + vec2 dirToG = normalize(vecToG.xy); + vec2 dirToB = normalize(vecToB.xy); + + float distToR = length(vecToR); + float distToG = length(vecToG); + float distToB = length(vecToB); + + // Calculate the dot product between vectors from the current fragment to each pair + // of adjacent coloured points. This helps us determine how close the current fragment + // is to a link between points. + float dotRG = dot(dirToR, dirToG); + float dotGB = dot(dirToG, dirToB); + float dotBR = dot(dirToB, dirToR); + + // Start with a bright coloured dot around each point + gl_FragColor.x = 1.0 - smoothstep(distToR, 0.0, pointRadius * pointR.z); + gl_FragColor.y = 1.0 - smoothstep(distToG, 0.0, pointRadius * pointG.z); + gl_FragColor.z = 1.0 - smoothstep(distToB, 0.0, pointRadius * pointB.z); + gl_FragColor.w = 1.0; + + // We want to show a coloured link between adjacent points. + // Determine the strength of each link at the current fragment. + // This tends towards 1.0 as the vectors to each point tend towards opposite directions. + float linkStrengthRG = 1.0 - smoothstep(dotRG, -1.01, -1.0 + (linkSize * pointR.z * pointG.z)); + float linkStrengthGB = 1.0 - smoothstep(dotGB, -1.01, -1.0 + (linkSize * pointG.z * pointB.z)); + float linkStrengthBR = 1.0 - smoothstep(dotBR, -1.01, -1.0 + (linkSize * pointB.z * pointR.z)); + + // If the current fragment is in a link, we need to know how much the + // linked points contribute of their colour. + float sumDistRG = distToR + distToG; + float sumDistGB = distToG + distToB; + float sumDistBR = distToB + distToR; + + float contribRonRG = 1.0 - (distToR / sumDistRG); + float contribRonBR = 1.0 - (distToR / sumDistBR); + + float contribGonRG = 1.0 - (distToG / sumDistRG); + float contribGonGB = 1.0 - (distToG / sumDistGB); + + float contribBonGB = 1.0 - (distToB / sumDistGB); + float contribBonBR = 1.0 - (distToB / sumDistBR); + + // Additively blend the link colours into the fragment. + gl_FragColor.x += (linkStrengthRG * contribRonRG) + (linkStrengthBR * contribRonBR); + gl_FragColor.y += (linkStrengthGB * contribGonGB) + (linkStrengthRG * contribGonRG); + gl_FragColor.z += (linkStrengthBR * contribBonBR) + (linkStrengthGB * contribBonGB); + + // Use an underlying texture to provide some noise + float noiseMin = 1.0 - noiseStrength; + gl_FragColor.xyz *= (1.0 - noiseStrength) + (noiseStrength * 0.); +} \ No newline at end of file diff --git a/tests/cpp-tests/Resources/Shaders/shadertoy_LensFlare.fsh b/tests/cpp-tests/Resources/Shaders/shadertoy_LensFlare.fsh new file mode 100644 index 0000000000..06cde33a52 --- /dev/null +++ b/tests/cpp-tests/Resources/Shaders/shadertoy_LensFlare.fsh @@ -0,0 +1,100 @@ + +uniform vec2 center; +uniform vec2 resolution; + + +vec2 iResolution = resolution; // viewport resolution (in pixels) +float iGlobalTime = CC_Time[1]; // shader playback time (in seconds) +//uniform float iChannelTime[4]; // channel playback time (in seconds) +//uniform vec3 iChannelResolution[4]; // channel resolution (in pixels) +vec4 iMouse = vec4(0,0,0,0); // mouse pixel coords. xy: current (if MLB down), zw: click +//uniform sampler2D iChannel0; // input channel. XX = 2D/Cube + +/*by musk License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. + + Trying to get some interesting looking lens flares. + + 13/08/13: + published + + muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusk!*/ + +float noise(float t) +{ + return 0.; +} +float noise(vec2 t) +{ + return 0.; +} + +vec3 lensflare(vec2 uv,vec2 pos) +{ + vec2 main = uv-pos; + vec2 uvd = uv*(length(uv)); + + float ang = atan(main.x,main.y); + float dist=length(main); dist = pow(dist,.1); + float n = noise(vec2(ang*16.0,dist*32.0)); + + float f0 = 1.0/(length(uv-pos)*16.0+1.0); + + f0 = f0+f0*(sin(noise((pos.x+pos.y)*2.2+ang*4.0+5.954)*16.0)*.1+dist*.1+.8); + + float f1 = max(0.01-pow(length(uv+1.2*pos),1.9),.0)*7.0; + + float f2 = max(1.0/(1.0+32.0*pow(length(uvd+0.8*pos),2.0)),.0)*00.25; + float f22 = max(1.0/(1.0+32.0*pow(length(uvd+0.85*pos),2.0)),.0)*00.23; + float f23 = max(1.0/(1.0+32.0*pow(length(uvd+0.9*pos),2.0)),.0)*00.21; + + vec2 uvx = mix(uv,uvd,-0.5); + + float f4 = max(0.01-pow(length(uvx+0.4*pos),2.4),.0)*6.0; + float f42 = max(0.01-pow(length(uvx+0.45*pos),2.4),.0)*5.0; + float f43 = max(0.01-pow(length(uvx+0.5*pos),2.4),.0)*3.0; + + uvx = mix(uv,uvd,-.4); + + float f5 = max(0.01-pow(length(uvx+0.2*pos),5.5),.0)*2.0; + float f52 = max(0.01-pow(length(uvx+0.4*pos),5.5),.0)*2.0; + float f53 = max(0.01-pow(length(uvx+0.6*pos),5.5),.0)*2.0; + + uvx = mix(uv,uvd,-0.5); + + float f6 = max(0.01-pow(length(uvx-0.3*pos),1.6),.0)*6.0; + float f62 = max(0.01-pow(length(uvx-0.325*pos),1.6),.0)*3.0; + float f63 = max(0.01-pow(length(uvx-0.35*pos),1.6),.0)*5.0; + + vec3 c = vec3(.0); + + c.r+=f2+f4+f5+f6; c.g+=f22+f42+f52+f62; c.b+=f23+f43+f53+f63; + c = c*1.3 - vec3(length(uvd)*.05); + c+=vec3(f0); + + return c; +} + +vec3 cc(vec3 color, float factor,float factor2) // color modifier +{ + float w = color.x+color.y+color.z; + return mix(color,vec3(w)*factor,w*factor2); +} + +void main(void) +{ + //vec2 uv = gl_FragCoord.xy / iResolution.xy - 0.5; + vec2 uv = (gl_FragCoord.xy - center.xy) / iResolution.xy; + uv.x *= iResolution.x/iResolution.y; //fix aspect ratio + vec3 mouse = vec3(iMouse.xy/iResolution.xy - 0.5,iMouse.z-.5); + mouse.x *= iResolution.x/iResolution.y; //fix aspect ratio + if (iMouse.z<.5) + { + mouse.x=sin(iGlobalTime)*.5; + mouse.y=sin(iGlobalTime*.913)*.5; + } + + vec3 color = vec3(1.4,1.2,1.0)*lensflare(uv,mouse.xy); + color -= noise(gl_FragCoord.xy)*.015; + color = cc(color,.5,.1); + gl_FragColor = vec4(color,1.0); +} \ No newline at end of file From f0c240f88548ca38aa293803e394690da6f58df2 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Sat, 10 May 2014 03:47:56 +0000 Subject: [PATCH 082/174] [AUTO]: updating luabinding automatically --- .../lua-bindings/auto/api/GLProgram.lua | 32 +- .../scripting/lua-bindings/auto/api/Node.lua | 46 +- .../lua-bindings/auto/api/ShaderCache.lua | 39 - .../lua-bindings/auto/api/Texture2D.lua | 20 +- .../auto/api/lua_cocos2dx_auto_api.lua | 39 +- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 5281 ++++++++--------- .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 2 - 7 files changed, 2699 insertions(+), 2760 deletions(-) delete mode 100644 cocos/scripting/lua-bindings/auto/api/ShaderCache.lua diff --git a/cocos/scripting/lua-bindings/auto/api/GLProgram.lua b/cocos/scripting/lua-bindings/auto/api/GLProgram.lua index c58c1a78c0..8ffd3739df 100644 --- a/cocos/scripting/lua-bindings/auto/api/GLProgram.lua +++ b/cocos/scripting/lua-bindings/auto/api/GLProgram.lua @@ -44,6 +44,12 @@ -- @param self -- @return string#string ret (return value: string) +-------------------------------- +-- @function [parent=#GLProgram] getUniform +-- @param self +-- @param #string str +-- @return Uniform#Uniform ret (return value: cc.Uniform) + -------------------------------- -- overload function: setUniformsForBuiltins(matrix_table) -- @@ -82,7 +88,7 @@ -------------------------------- -- @function [parent=#GLProgram] getUniformLocation -- @param self --- @param #char char +-- @param #string str -- @return int#int ret (return value: int) -------------------------------- @@ -112,15 +118,21 @@ -------------------------------- -- @function [parent=#GLProgram] bindAttribLocation -- @param self --- @param #char char +-- @param #string str -- @param #unsigned int int -------------------------------- -- @function [parent=#GLProgram] getAttribLocation -- @param self --- @param #char char +-- @param #string str -- @return int#int ret (return value: int) +-------------------------------- +-- @function [parent=#GLProgram] getVertexAttrib +-- @param self +-- @param #string str +-- @return VertexAttrib#VertexAttrib ret (return value: cc.VertexAttrib) + -------------------------------- -- @function [parent=#GLProgram] setUniformLocationWithMatrix2fv -- @param self @@ -149,6 +161,20 @@ -- @param #int int -- @param #int int +-------------------------------- +-- @function [parent=#GLProgram] createWithByteArrays +-- @param self +-- @param #char char +-- @param #char char +-- @return GLProgram#GLProgram ret (return value: cc.GLProgram) + +-------------------------------- +-- @function [parent=#GLProgram] createWithFilenames +-- @param self +-- @param #string str +-- @param #string str +-- @return GLProgram#GLProgram ret (return value: cc.GLProgram) + -------------------------------- -- @function [parent=#GLProgram] GLProgram -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/Node.lua b/cocos/scripting/lua-bindings/auto/api/Node.lua index d2a68061ed..59d2257b5d 100644 --- a/cocos/scripting/lua-bindings/auto/api/Node.lua +++ b/cocos/scripting/lua-bindings/auto/api/Node.lua @@ -27,15 +27,6 @@ -- @param self -- @param #cc.PhysicsBody physicsbody --------------------------------- --- overload function: getShaderProgram() --- --- overload function: getShaderProgram() --- --- @function [parent=#Node] getShaderProgram --- @param self --- @return GLProgram#GLProgram ret (retunr value: cc.GLProgram) - -------------------------------- -- @function [parent=#Node] getDescription -- @param self @@ -125,9 +116,9 @@ -- @return int#int ret (return value: int) -------------------------------- --- @function [parent=#Node] getNodeToWorldAffineTransform +-- @function [parent=#Node] getGLProgram -- @param self --- @return AffineTransform#AffineTransform ret (return value: cc.AffineTransform) +-- @return GLProgram#GLProgram ret (return value: cc.GLProgram) -------------------------------- -- @function [parent=#Node] getNodeToWorldTransform @@ -167,9 +158,9 @@ -- @param #float float -------------------------------- --- @function [parent=#Node] setSkewY +-- @function [parent=#Node] setGLProgramState -- @param self --- @param #float float +-- @param #cc.GLProgramState glprogramstate -------------------------------- -- @function [parent=#Node] getOpacity @@ -263,6 +254,11 @@ -- @param self -- @param #bool bool +-------------------------------- +-- @function [parent=#Node] setSkewY +-- @param self +-- @param #float float + -------------------------------- -- @function [parent=#Node] setPositionZ -- @param self @@ -320,9 +316,9 @@ -- @return bool#bool ret (return value: bool) -------------------------------- --- @function [parent=#Node] setShaderProgram +-- @function [parent=#Node] isOpacityModifyRGB -- @param self --- @param #cc.GLProgram glprogram +-- @return bool#bool ret (return value: bool) -------------------------------- -- @function [parent=#Node] getRotation @@ -340,6 +336,11 @@ -- @param #cc.Action action -- @return Action#Action ret (return value: cc.Action) +-------------------------------- +-- @function [parent=#Node] getGLProgramState +-- @param self +-- @return GLProgramState#GLProgramState ret (return value: cc.GLProgramState) + -------------------------------- -- @function [parent=#Node] setScheduler -- @param self @@ -458,6 +459,11 @@ -- @param self -- @param #float float +-------------------------------- +-- @function [parent=#Node] getNodeToWorldAffineTransform +-- @param self +-- @return AffineTransform#AffineTransform ret (return value: cc.AffineTransform) + -------------------------------- -- @function [parent=#Node] updateDisplayedColor -- @param self @@ -613,6 +619,11 @@ -- @param self -- @return matrix_table#matrix_table ret (return value: matrix_table) +-------------------------------- +-- @function [parent=#Node] setGLProgram +-- @param self +-- @param #cc.GLProgram glprogram + -------------------------------- -- @function [parent=#Node] getScale -- @param self @@ -638,11 +649,6 @@ -- @param self -- @return bool#bool ret (return value: bool) --------------------------------- --- @function [parent=#Node] isOpacityModifyRGB --- @param self --- @return bool#bool ret (return value: bool) - -------------------------------- -- @function [parent=#Node] stopAction -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/ShaderCache.lua b/cocos/scripting/lua-bindings/auto/api/ShaderCache.lua deleted file mode 100644 index 3447ae9099..0000000000 --- a/cocos/scripting/lua-bindings/auto/api/ShaderCache.lua +++ /dev/null @@ -1,39 +0,0 @@ - --------------------------------- --- @module ShaderCache --- @extend Ref - --------------------------------- --- @function [parent=#ShaderCache] reloadDefaultShaders --- @param self - --------------------------------- --- @function [parent=#ShaderCache] addProgram --- @param self --- @param #cc.GLProgram glprogram --- @param #string str - --------------------------------- --- @function [parent=#ShaderCache] getProgram --- @param self --- @param #string str --- @return GLProgram#GLProgram ret (return value: cc.GLProgram) - --------------------------------- --- @function [parent=#ShaderCache] loadDefaultShaders --- @param self - --------------------------------- --- @function [parent=#ShaderCache] destroyInstance --- @param self - --------------------------------- --- @function [parent=#ShaderCache] getInstance --- @param self --- @return ShaderCache#ShaderCache ret (return value: cc.ShaderCache) - --------------------------------- --- @function [parent=#ShaderCache] ShaderCache --- @param self - -return nil diff --git a/cocos/scripting/lua-bindings/auto/api/Texture2D.lua b/cocos/scripting/lua-bindings/auto/api/Texture2D.lua index e9af28e4d3..f4a70229a3 100644 --- a/cocos/scripting/lua-bindings/auto/api/Texture2D.lua +++ b/cocos/scripting/lua-bindings/auto/api/Texture2D.lua @@ -3,11 +3,6 @@ -- @module Texture2D -- @extend Ref --------------------------------- --- @function [parent=#Texture2D] getShaderProgram --- @param self --- @return GLProgram#GLProgram ret (return value: cc.GLProgram) - -------------------------------- -- @function [parent=#Texture2D] getMaxT -- @param self @@ -29,11 +24,6 @@ -- @param #cc.Texture2D::PixelFormat pixelformat -- @return bool#bool ret (retunr value: bool) --------------------------------- --- @function [parent=#Texture2D] setShaderProgram --- @param self --- @param #cc.GLProgram glprogram - -------------------------------- -- @function [parent=#Texture2D] getMaxS -- @param self @@ -151,11 +141,21 @@ -- @param self -- @param #vector2_table array +-------------------------------- +-- @function [parent=#Texture2D] getGLProgram +-- @param self +-- @return GLProgram#GLProgram ret (return value: cc.GLProgram) + -------------------------------- -- @function [parent=#Texture2D] hasMipmaps -- @param self -- @return bool#bool ret (return value: bool) +-------------------------------- +-- @function [parent=#Texture2D] setGLProgram +-- @param self +-- @param #cc.GLProgram glprogram + -------------------------------- -- @function [parent=#Texture2D] setMaxS -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua index f813648fbb..71b233f7b1 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua @@ -12,13 +12,8 @@ -------------------------------------------------------- --- the cc GLProgram --- @field [parent=#cc] GLProgram#GLProgram GLProgram preloaded module - - --------------------------------------------------------- --- the cc Touch --- @field [parent=#cc] Touch#Touch Touch preloaded module +-- the cc EventListener +-- @field [parent=#cc] EventListener#EventListener EventListener preloaded module -------------------------------------------------------- @@ -26,6 +21,16 @@ -- @field [parent=#cc] Event#Event Event preloaded module +-------------------------------------------------------- +-- the cc EventDispatcher +-- @field [parent=#cc] EventDispatcher#EventDispatcher EventDispatcher preloaded module + + +-------------------------------------------------------- +-- the cc Touch +-- @field [parent=#cc] Touch#Touch Touch preloaded module + + -------------------------------------------------------- -- the cc EventTouch -- @field [parent=#cc] EventTouch#EventTouch EventTouch preloaded module @@ -41,21 +46,16 @@ -- @field [parent=#cc] Texture2D#Texture2D Texture2D preloaded module --------------------------------------------------------- --- the cc EventListener --- @field [parent=#cc] EventListener#EventListener EventListener preloaded module - - --------------------------------------------------------- --- the cc EventDispatcher --- @field [parent=#cc] EventDispatcher#EventDispatcher EventDispatcher preloaded module - - -------------------------------------------------------- -- the cc Node -- @field [parent=#cc] Node#Node Node preloaded module +-------------------------------------------------------- +-- the cc GLProgram +-- @field [parent=#cc] GLProgram#GLProgram GLProgram preloaded module + + -------------------------------------------------------- -- the cc AtlasNode -- @field [parent=#cc] AtlasNode#AtlasNode AtlasNode preloaded module @@ -1136,11 +1136,6 @@ -- @field [parent=#cc] GLView#GLView GLView preloaded module --------------------------------------------------------- --- the cc ShaderCache --- @field [parent=#cc] ShaderCache#ShaderCache ShaderCache preloaded module - - -------------------------------------------------------- -- the cc AnimationCache -- @field [parent=#cc] AnimationCache#AnimationCache AnimationCache preloaded module diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index bd3ed6399a..dbf7698af5 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -365,10 +365,10 @@ int lua_register_cocos2dx_Console(lua_State* tolua_S) return 1; } -int lua_cocos2dx_GLProgram_getFragmentShaderLog(lua_State* tolua_S) +int lua_cocos2dx_EventListener_setEnabled(lua_State* tolua_S) { int argc = 0; - cocos2d::GLProgram* cobj = nullptr; + cocos2d::EventListener* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -377,15 +377,61 @@ int lua_cocos2dx_GLProgram_getFragmentShaderLog(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.EventListener",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::EventListener*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getFragmentShaderLog'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventListener_setEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0); + if(!ok) + return 0; + cobj->setEnabled(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventListener_setEnabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_EventListener_clone(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventListener* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventListener",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventListener*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventListener_clone'", nullptr); return 0; } #endif @@ -395,24 +441,24 @@ int lua_cocos2dx_GLProgram_getFragmentShaderLog(lua_State* tolua_S) { if(!ok) return 0; - std::string ret = cobj->getFragmentShaderLog(); - tolua_pushcppstring(tolua_S,ret); + cocos2d::EventListener* ret = cobj->clone(); + object_to_luaval(tolua_S, "cc.EventListener",(cocos2d::EventListener*)ret); return 1; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFragmentShaderLog",argc, 0); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getFragmentShaderLog'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventListener_clone'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_GLProgram_initWithByteArrays(lua_State* tolua_S) +int lua_cocos2dx_EventListener_isEnabled(lua_State* tolua_S) { int argc = 0; - cocos2d::GLProgram* cobj = nullptr; + cocos2d::EventListener* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -421,15 +467,383 @@ int lua_cocos2dx_GLProgram_initWithByteArrays(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.EventListener",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::EventListener*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_initWithByteArrays'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventListener_isEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + bool ret = cobj->isEnabled(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isEnabled",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventListener_isEnabled'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_EventListener_checkAvailable(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventListener* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventListener",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventListener*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventListener_checkAvailable'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + bool ret = cobj->checkAvailable(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "checkAvailable",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventListener_checkAvailable'.",&tolua_err); +#endif + + return 0; +} +static int lua_cocos2dx_EventListener_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (EventListener)"); + return 0; +} + +int lua_register_cocos2dx_EventListener(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.EventListener"); + tolua_cclass(tolua_S,"EventListener","cc.EventListener","cc.Ref",nullptr); + + tolua_beginmodule(tolua_S,"EventListener"); + tolua_function(tolua_S,"setEnabled",lua_cocos2dx_EventListener_setEnabled); + tolua_function(tolua_S,"clone",lua_cocos2dx_EventListener_clone); + tolua_function(tolua_S,"isEnabled",lua_cocos2dx_EventListener_isEnabled); + tolua_function(tolua_S,"checkAvailable",lua_cocos2dx_EventListener_checkAvailable); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::EventListener).name(); + g_luaType[typeName] = "cc.EventListener"; + g_typeCast["EventListener"] = "cc.EventListener"; + return 1; +} + +int lua_cocos2dx_Event_isStopped(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Event* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Event",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Event*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Event_isStopped'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + bool ret = cobj->isStopped(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isStopped",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Event_isStopped'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Event_getType(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Event* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Event",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Event*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Event_getType'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + int ret = (int)cobj->getType(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getType",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Event_getType'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Event_getCurrentTarget(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Event* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Event",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Event*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Event_getCurrentTarget'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cocos2d::Node* ret = cobj->getCurrentTarget(); + object_to_luaval(tolua_S, "cc.Node",(cocos2d::Node*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurrentTarget",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Event_getCurrentTarget'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Event_stopPropagation(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Event* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Event",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Event*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Event_stopPropagation'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cobj->stopPropagation(); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopPropagation",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Event_stopPropagation'.",&tolua_err); +#endif + + return 0; +} +static int lua_cocos2dx_Event_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (Event)"); + return 0; +} + +int lua_register_cocos2dx_Event(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.Event"); + tolua_cclass(tolua_S,"Event","cc.Event","cc.Ref",nullptr); + + tolua_beginmodule(tolua_S,"Event"); + tolua_function(tolua_S,"isStopped",lua_cocos2dx_Event_isStopped); + tolua_function(tolua_S,"getType",lua_cocos2dx_Event_getType); + tolua_function(tolua_S,"getCurrentTarget",lua_cocos2dx_Event_getCurrentTarget); + tolua_function(tolua_S,"stopPropagation",lua_cocos2dx_Event_stopPropagation); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::Event).name(); + g_luaType[typeName] = "cc.Event"; + g_typeCast["Event"] = "cc.Event"; + return 1; +} + +int lua_cocos2dx_EventDispatcher_pauseEventListenersForTarget(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventDispatcher* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_pauseEventListenersForTarget'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Node* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); + if(!ok) + return 0; + cobj->pauseEventListenersForTarget(arg0); + return 0; + } + if (argc == 2) + { + cocos2d::Node* arg0; + bool arg1; + + ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); + + ok &= luaval_to_boolean(tolua_S, 3,&arg1); + if(!ok) + return 0; + cobj->pauseEventListenersForTarget(arg0, arg1); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pauseEventListenersForTarget",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_pauseEventListenersForTarget'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventDispatcher* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority'", nullptr); return 0; } #endif @@ -437,32 +851,31 @@ int lua_cocos2dx_GLProgram_initWithByteArrays(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 2) { - const char* arg0; - const char* arg1; + cocos2d::EventListener* arg0; + cocos2d::Node* arg1; - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); + ok &= luaval_to_object(tolua_S, 2, "cc.EventListener",&arg0); - std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); + ok &= luaval_to_object(tolua_S, 3, "cc.Node",&arg1); if(!ok) return 0; - bool ret = cobj->initWithByteArrays(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; + cobj->addEventListenerWithSceneGraphPriority(arg0, arg1); + return 0; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithByteArrays",argc, 2); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addEventListenerWithSceneGraphPriority",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_initWithByteArrays'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv(lua_State* tolua_S) +int lua_cocos2dx_EventDispatcher_setEnabled(lua_State* tolua_S) { int argc = 0; - cocos2d::GLProgram* cobj = nullptr; + cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -471,50 +884,44 @@ int lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_setEnabled'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 3) + if (argc == 1) { - int arg0; - const float* arg1; - unsigned int arg2; + bool arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - - #pragma warning NO CONVERSION TO NATIVE FOR float*; - - ok &= luaval_to_uint32(tolua_S, 4,&arg2); + ok &= luaval_to_boolean(tolua_S, 2,&arg0); if(!ok) return 0; - cobj->setUniformLocationWithMatrix4fv(arg0, arg1, arg2); + cobj->setEnabled(arg0); return 0; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWithMatrix4fv",argc, 3); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_setEnabled'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_GLProgram_initWithFilenames(lua_State* tolua_S) +int lua_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority(lua_State* tolua_S) { int argc = 0; - cocos2d::GLProgram* cobj = nullptr; + cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -523,15 +930,277 @@ int lua_cocos2dx_GLProgram_initWithFilenames(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_initWithFilenames'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + cocos2d::EventListener* arg0; + int arg1; + + ok &= luaval_to_object(tolua_S, 2, "cc.EventListener",&arg0); + + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); + if(!ok) + return 0; + cobj->addEventListenerWithFixedPriority(arg0, arg1); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addEventListenerWithFixedPriority",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_EventDispatcher_removeEventListener(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventDispatcher* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeEventListener'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::EventListener* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.EventListener",&arg0); + if(!ok) + return 0; + cobj->removeEventListener(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeEventListener",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeEventListener'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_EventDispatcher_resumeEventListenersForTarget(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventDispatcher* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_resumeEventListenersForTarget'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Node* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); + if(!ok) + return 0; + cobj->resumeEventListenersForTarget(arg0); + return 0; + } + if (argc == 2) + { + cocos2d::Node* arg0; + bool arg1; + + ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); + + ok &= luaval_to_boolean(tolua_S, 3,&arg1); + if(!ok) + return 0; + cobj->resumeEventListenersForTarget(arg0, arg1); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resumeEventListenersForTarget",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_resumeEventListenersForTarget'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_EventDispatcher_removeEventListenersForTarget(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventDispatcher* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeEventListenersForTarget'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Node* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); + if(!ok) + return 0; + cobj->removeEventListenersForTarget(arg0); + return 0; + } + if (argc == 2) + { + cocos2d::Node* arg0; + bool arg1; + + ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); + + ok &= luaval_to_boolean(tolua_S, 3,&arg1); + if(!ok) + return 0; + cobj->removeEventListenersForTarget(arg0, arg1); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeEventListenersForTarget",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeEventListenersForTarget'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_EventDispatcher_setPriority(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventDispatcher* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_setPriority'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + cocos2d::EventListener* arg0; + int arg1; + + ok &= luaval_to_object(tolua_S, 2, "cc.EventListener",&arg0); + + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); + if(!ok) + return 0; + cobj->setPriority(arg0, arg1); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPriority",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_setPriority'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_EventDispatcher_addCustomEventListener(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventDispatcher* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_addCustomEventListener'", nullptr); return 0; } #endif @@ -540,31 +1209,214 @@ int lua_cocos2dx_GLProgram_initWithFilenames(lua_State* tolua_S) if (argc == 2) { std::string arg0; - std::string arg1; + std::function arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); - ok &= luaval_to_std_string(tolua_S, 3,&arg1); + do { + // Lambda binding for lua is not supported. + assert(false); + } while(0) + ; if(!ok) return 0; - bool ret = cobj->initWithFilenames(arg0, arg1); + cocos2d::EventListenerCustom* ret = cobj->addCustomEventListener(arg0, arg1); + object_to_luaval(tolua_S, "cc.EventListenerCustom",(cocos2d::EventListenerCustom*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addCustomEventListener",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_addCustomEventListener'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_EventDispatcher_dispatchEvent(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventDispatcher* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_dispatchEvent'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Event* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Event",&arg0); + if(!ok) + return 0; + cobj->dispatchEvent(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "dispatchEvent",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_dispatchEvent'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_EventDispatcher_removeAllEventListeners(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventDispatcher* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeAllEventListeners'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cobj->removeAllEventListeners(); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllEventListeners",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeAllEventListeners'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_EventDispatcher_removeCustomEventListeners(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventDispatcher* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeCustomEventListeners'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0); + if(!ok) + return 0; + cobj->removeCustomEventListeners(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeCustomEventListeners",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeCustomEventListeners'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_EventDispatcher_isEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventDispatcher* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_isEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + bool ret = cobj->isEnabled(); tolua_pushboolean(tolua_S,(bool)ret); return 1; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithFilenames",argc, 2); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_initWithFilenames'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_isEnabled'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_GLProgram_getUniformLocationForName(lua_State* tolua_S) +int lua_cocos2dx_EventDispatcher_removeEventListenersForType(lua_State* tolua_S) { int argc = 0; - cocos2d::GLProgram* cobj = nullptr; + cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -573,15 +1425,15 @@ int lua_cocos2dx_GLProgram_getUniformLocationForName(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getUniformLocationForName'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeEventListenersForType'", nullptr); return 0; } #endif @@ -589,912 +1441,28 @@ int lua_cocos2dx_GLProgram_getUniformLocationForName(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - const char* arg0; - - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); - if(!ok) - return 0; - int ret = cobj->getUniformLocationForName(arg0); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUniformLocationForName",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getUniformLocationForName'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_use(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_use'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj->use(); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "use",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_use'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_getVertexShaderLog(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getVertexShaderLog'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - std::string ret = cobj->getVertexShaderLog(); - tolua_pushcppstring(tolua_S,ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVertexShaderLog",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getVertexShaderLog'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_setUniformsForBuiltins(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformsForBuiltins'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 1) { - cocos2d::Matrix arg0; - ok &= luaval_to_matrix(tolua_S, 2, &arg0); - - if (!ok) { break; } - cobj->setUniformsForBuiltins(arg0); - return 0; - } - }while(0); - ok = true; - do{ - if (argc == 0) { - cobj->setUniformsForBuiltins(); - return 0; - } - }while(0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformsForBuiltins",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformsForBuiltins'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_setUniformLocationWith3i(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith3i'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 4) - { - int arg0; - int arg1; - int arg2; - int arg3; + cocos2d::EventListener::Type arg0; ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); - - ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); - - ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); if(!ok) return 0; - cobj->setUniformLocationWith3i(arg0, arg1, arg2, arg3); + cobj->removeEventListenersForType(arg0); return 0; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith3i",argc, 4); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeEventListenersForType",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith3i'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeEventListenersForType'.",&tolua_err); #endif return 0; } -int lua_cocos2dx_GLProgram_setUniformLocationWith3iv(lua_State* tolua_S) +int lua_cocos2dx_EventDispatcher_constructor(lua_State* tolua_S) { int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith3iv'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 3) - { - int arg0; - int* arg1; - unsigned int arg2; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - - #pragma warning NO CONVERSION TO NATIVE FOR int*; - - ok &= luaval_to_uint32(tolua_S, 4,&arg2); - if(!ok) - return 0; - cobj->setUniformLocationWith3iv(arg0, arg1, arg2); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith3iv",argc, 3); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith3iv'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_updateUniforms(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_updateUniforms'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj->updateUniforms(); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateUniforms",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_updateUniforms'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_setUniformLocationWith4iv(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith4iv'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 3) - { - int arg0; - int* arg1; - unsigned int arg2; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - - #pragma warning NO CONVERSION TO NATIVE FOR int*; - - ok &= luaval_to_uint32(tolua_S, 4,&arg2); - if(!ok) - return 0; - cobj->setUniformLocationWith4iv(arg0, arg1, arg2); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith4iv",argc, 3); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith4iv'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_getUniformLocation(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getUniformLocation'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - const char* arg0; - - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); - if(!ok) - return 0; - int ret = cobj->getUniformLocation(arg0); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUniformLocation",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getUniformLocation'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_setUniformLocationWith1i(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith1i'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - int arg0; - int arg1; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); - if(!ok) - return 0; - cobj->setUniformLocationWith1i(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith1i",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith1i'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_setUniformLocationWith2iv(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith2iv'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 3) - { - int arg0; - int* arg1; - unsigned int arg2; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - - #pragma warning NO CONVERSION TO NATIVE FOR int*; - - ok &= luaval_to_uint32(tolua_S, 4,&arg2); - if(!ok) - return 0; - cobj->setUniformLocationWith2iv(arg0, arg1, arg2); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith2iv",argc, 3); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith2iv'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 3) - { - int arg0; - const float* arg1; - unsigned int arg2; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - - #pragma warning NO CONVERSION TO NATIVE FOR float*; - - ok &= luaval_to_uint32(tolua_S, 4,&arg2); - if(!ok) - return 0; - cobj->setUniformLocationWithMatrix3fv(arg0, arg1, arg2); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWithMatrix3fv",argc, 3); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_reset(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_reset'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj->reset(); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reset",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_reset'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_bindAttribLocation(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_bindAttribLocation'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - const char* arg0; - unsigned int arg1; - - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); - - ok &= luaval_to_uint32(tolua_S, 3,&arg1); - if(!ok) - return 0; - cobj->bindAttribLocation(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "bindAttribLocation",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_bindAttribLocation'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_getAttribLocation(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getAttribLocation'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - const char* arg0; - - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); - if(!ok) - return 0; - int ret = cobj->getAttribLocation(arg0); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAttribLocation",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getAttribLocation'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 3) - { - int arg0; - const float* arg1; - unsigned int arg2; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - - #pragma warning NO CONVERSION TO NATIVE FOR float*; - - ok &= luaval_to_uint32(tolua_S, 4,&arg2); - if(!ok) - return 0; - cobj->setUniformLocationWithMatrix2fv(arg0, arg1, arg2); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWithMatrix2fv",argc, 3); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_setUniformLocationWith4i(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith4i'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 5) - { - int arg0; - int arg1; - int arg2; - int arg3; - int arg4; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); - - ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); - - ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); - - ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); - if(!ok) - return 0; - cobj->setUniformLocationWith4i(arg0, arg1, arg2, arg3, arg4); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith4i",argc, 5); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith4i'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_link(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_link'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - bool ret = cobj->link(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "link",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_link'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_setUniformLocationWith2i(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith2i'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 3) - { - int arg0; - int arg1; - int arg2; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); - - ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); - if(!ok) - return 0; - cobj->setUniformLocationWith2i(arg0, arg1, arg2); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith2i",argc, 3); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith2i'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_GLProgram_constructor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::GLProgram* cobj = nullptr; + cocos2d::EventDispatcher* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 @@ -1508,63 +1476,54 @@ int lua_cocos2dx_GLProgram_constructor(lua_State* tolua_S) { if(!ok) return 0; - cobj = new cocos2d::GLProgram(); + cobj = new cocos2d::EventDispatcher(); cobj->autorelease(); int ID = (int)cobj->_ID ; int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.GLProgram"); + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventDispatcher"); return 1; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "GLProgram",argc, 0); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "EventDispatcher",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_constructor'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_constructor'.",&tolua_err); #endif return 0; } -static int lua_cocos2dx_GLProgram_finalize(lua_State* tolua_S) +static int lua_cocos2dx_EventDispatcher_finalize(lua_State* tolua_S) { - printf("luabindings: finalizing LUA object (GLProgram)"); + printf("luabindings: finalizing LUA object (EventDispatcher)"); return 0; } -int lua_register_cocos2dx_GLProgram(lua_State* tolua_S) +int lua_register_cocos2dx_EventDispatcher(lua_State* tolua_S) { - tolua_usertype(tolua_S,"cc.GLProgram"); - tolua_cclass(tolua_S,"GLProgram","cc.GLProgram","cc.Ref",nullptr); + tolua_usertype(tolua_S,"cc.EventDispatcher"); + tolua_cclass(tolua_S,"EventDispatcher","cc.EventDispatcher","cc.Ref",nullptr); - tolua_beginmodule(tolua_S,"GLProgram"); - tolua_function(tolua_S,"getFragmentShaderLog",lua_cocos2dx_GLProgram_getFragmentShaderLog); - tolua_function(tolua_S,"initWithByteArrays",lua_cocos2dx_GLProgram_initWithByteArrays); - tolua_function(tolua_S,"setUniformLocationWithMatrix4fv",lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv); - tolua_function(tolua_S,"initWithFilenames",lua_cocos2dx_GLProgram_initWithFilenames); - tolua_function(tolua_S,"getUniformLocationForName",lua_cocos2dx_GLProgram_getUniformLocationForName); - tolua_function(tolua_S,"use",lua_cocos2dx_GLProgram_use); - tolua_function(tolua_S,"getVertexShaderLog",lua_cocos2dx_GLProgram_getVertexShaderLog); - tolua_function(tolua_S,"setUniformsForBuiltins",lua_cocos2dx_GLProgram_setUniformsForBuiltins); - tolua_function(tolua_S,"setUniformLocationWith3i",lua_cocos2dx_GLProgram_setUniformLocationWith3i); - tolua_function(tolua_S,"setUniformLocationWith3iv",lua_cocos2dx_GLProgram_setUniformLocationWith3iv); - tolua_function(tolua_S,"updateUniforms",lua_cocos2dx_GLProgram_updateUniforms); - tolua_function(tolua_S,"setUniformLocationWith4iv",lua_cocos2dx_GLProgram_setUniformLocationWith4iv); - tolua_function(tolua_S,"getUniformLocation",lua_cocos2dx_GLProgram_getUniformLocation); - tolua_function(tolua_S,"setUniformLocationI32",lua_cocos2dx_GLProgram_setUniformLocationWith1i); - tolua_function(tolua_S,"setUniformLocationWith2iv",lua_cocos2dx_GLProgram_setUniformLocationWith2iv); - tolua_function(tolua_S,"setUniformLocationWithMatrix3fv",lua_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv); - tolua_function(tolua_S,"reset",lua_cocos2dx_GLProgram_reset); - tolua_function(tolua_S,"bindAttribLocation",lua_cocos2dx_GLProgram_bindAttribLocation); - tolua_function(tolua_S,"getAttribLocation",lua_cocos2dx_GLProgram_getAttribLocation); - tolua_function(tolua_S,"setUniformLocationWithMatrix2fv",lua_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv); - tolua_function(tolua_S,"setUniformLocationWith4i",lua_cocos2dx_GLProgram_setUniformLocationWith4i); - tolua_function(tolua_S,"link",lua_cocos2dx_GLProgram_link); - tolua_function(tolua_S,"setUniformLocationWith2i",lua_cocos2dx_GLProgram_setUniformLocationWith2i); - tolua_function(tolua_S,"new",lua_cocos2dx_GLProgram_constructor); + tolua_beginmodule(tolua_S,"EventDispatcher"); + tolua_function(tolua_S,"pauseEventListenersForTarget",lua_cocos2dx_EventDispatcher_pauseEventListenersForTarget); + tolua_function(tolua_S,"addEventListenerWithSceneGraphPriority",lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority); + tolua_function(tolua_S,"setEnabled",lua_cocos2dx_EventDispatcher_setEnabled); + tolua_function(tolua_S,"addEventListenerWithFixedPriority",lua_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority); + tolua_function(tolua_S,"removeEventListener",lua_cocos2dx_EventDispatcher_removeEventListener); + tolua_function(tolua_S,"resumeEventListenersForTarget",lua_cocos2dx_EventDispatcher_resumeEventListenersForTarget); + tolua_function(tolua_S,"removeEventListenersForTarget",lua_cocos2dx_EventDispatcher_removeEventListenersForTarget); + tolua_function(tolua_S,"setPriority",lua_cocos2dx_EventDispatcher_setPriority); + tolua_function(tolua_S,"addCustomEventListener",lua_cocos2dx_EventDispatcher_addCustomEventListener); + tolua_function(tolua_S,"dispatchEvent",lua_cocos2dx_EventDispatcher_dispatchEvent); + tolua_function(tolua_S,"removeAllEventListeners",lua_cocos2dx_EventDispatcher_removeAllEventListeners); + tolua_function(tolua_S,"removeCustomEventListeners",lua_cocos2dx_EventDispatcher_removeCustomEventListeners); + tolua_function(tolua_S,"isEnabled",lua_cocos2dx_EventDispatcher_isEnabled); + tolua_function(tolua_S,"removeEventListenersForType",lua_cocos2dx_EventDispatcher_removeEventListenersForType); + tolua_function(tolua_S,"new",lua_cocos2dx_EventDispatcher_constructor); tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::GLProgram).name(); - g_luaType[typeName] = "cc.GLProgram"; - g_typeCast["GLProgram"] = "cc.GLProgram"; + std::string typeName = typeid(cocos2d::EventDispatcher).name(); + g_luaType[typeName] = "cc.EventDispatcher"; + g_typeCast["EventDispatcher"] = "cc.EventDispatcher"; return 1; } @@ -2035,204 +1994,6 @@ int lua_register_cocos2dx_Touch(lua_State* tolua_S) return 1; } -int lua_cocos2dx_Event_isStopped(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Event* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Event",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Event*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Event_isStopped'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - bool ret = cobj->isStopped(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isStopped",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Event_isStopped'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Event_getType(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Event* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Event",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Event*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Event_getType'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - int ret = (int)cobj->getType(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getType",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Event_getType'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Event_getCurrentTarget(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Event* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Event",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Event*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Event_getCurrentTarget'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cocos2d::Node* ret = cobj->getCurrentTarget(); - object_to_luaval(tolua_S, "cc.Node",(cocos2d::Node*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurrentTarget",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Event_getCurrentTarget'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Event_stopPropagation(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Event* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Event",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Event*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Event_stopPropagation'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj->stopPropagation(); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "stopPropagation",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Event_stopPropagation'.",&tolua_err); -#endif - - return 0; -} -static int lua_cocos2dx_Event_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (Event)"); - return 0; -} - -int lua_register_cocos2dx_Event(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.Event"); - tolua_cclass(tolua_S,"Event","cc.Event","cc.Ref",nullptr); - - tolua_beginmodule(tolua_S,"Event"); - tolua_function(tolua_S,"isStopped",lua_cocos2dx_Event_isStopped); - tolua_function(tolua_S,"getType",lua_cocos2dx_Event_getType); - tolua_function(tolua_S,"getCurrentTarget",lua_cocos2dx_Event_getCurrentTarget); - tolua_function(tolua_S,"stopPropagation",lua_cocos2dx_Event_stopPropagation); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::Event).name(); - g_luaType[typeName] = "cc.Event"; - g_typeCast["Event"] = "cc.Event"; - return 1; -} - int lua_cocos2dx_EventTouch_getEventCode(lua_State* tolua_S) { int argc = 0; @@ -2438,50 +2199,6 @@ int lua_register_cocos2dx_EventKeyboard(lua_State* tolua_S) return 1; } -int lua_cocos2dx_Texture2D_getShaderProgram(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Texture2D* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getShaderProgram'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cocos2d::GLProgram* ret = cobj->getGLProgram(); - object_to_luaval(tolua_S, "cc.GLProgram",(cocos2d::GLProgram*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getShaderProgram",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getShaderProgram'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Texture2D_getMaxT(lua_State* tolua_S) { int argc = 0; @@ -2629,52 +2346,6 @@ int lua_cocos2dx_Texture2D_initWithImage(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Texture2D_setGLProgram(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Texture2D* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_setShaderProgram'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::GLProgram* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.GLProgram",&arg0); - if(!ok) - return 0; - cobj->setGLProgram(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setShaderProgram",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_setShaderProgram'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Texture2D_getMaxS(lua_State* tolua_S) { int argc = 0; @@ -3658,6 +3329,50 @@ int lua_cocos2dx_Texture2D_drawAtPoint(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Texture2D_getGLProgram(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Texture2D* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_getGLProgram'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cocos2d::GLProgram* ret = cobj->getGLProgram(); + object_to_luaval(tolua_S, "cc.GLProgram",(cocos2d::GLProgram*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGLProgram",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_getGLProgram'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Texture2D_hasMipmaps(lua_State* tolua_S) { int argc = 0; @@ -3702,6 +3417,52 @@ int lua_cocos2dx_Texture2D_hasMipmaps(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Texture2D_setGLProgram(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Texture2D* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_setGLProgram'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::GLProgram* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.GLProgram",&arg0); + if(!ok) + return 0; + cobj->setGLProgram(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGLProgram",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_setGLProgram'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Texture2D_setMaxS(lua_State* tolua_S) { int argc = 0; @@ -3889,11 +3650,9 @@ int lua_register_cocos2dx_Texture2D(lua_State* tolua_S) tolua_cclass(tolua_S,"Texture2D","cc.Texture2D","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"Texture2D"); - tolua_function(tolua_S,"getShaderProgram",lua_cocos2dx_Texture2D_getShaderProgram); tolua_function(tolua_S,"getMaxT",lua_cocos2dx_Texture2D_getMaxT); tolua_function(tolua_S,"getStringForFormat",lua_cocos2dx_Texture2D_getStringForFormat); tolua_function(tolua_S,"initWithImage",lua_cocos2dx_Texture2D_initWithImage); - tolua_function(tolua_S,"setShaderProgram",lua_cocos2dx_Texture2D_setShaderProgram); tolua_function(tolua_S,"getMaxS",lua_cocos2dx_Texture2D_getMaxS); tolua_function(tolua_S,"updateWithData",lua_cocos2dx_Texture2D_updateWithData); tolua_function(tolua_S,"hasPremultipliedAlpha",lua_cocos2dx_Texture2D_hasPremultipliedAlpha); @@ -3913,7 +3672,9 @@ int lua_register_cocos2dx_Texture2D(lua_State* tolua_S) tolua_function(tolua_S,"getContentSizeInPixels",lua_cocos2dx_Texture2D_getContentSizeInPixels); tolua_function(tolua_S,"getPixelsWide",lua_cocos2dx_Texture2D_getPixelsWide); tolua_function(tolua_S,"drawAtPoint",lua_cocos2dx_Texture2D_drawAtPoint); + tolua_function(tolua_S,"getGLProgram",lua_cocos2dx_Texture2D_getGLProgram); tolua_function(tolua_S,"hasMipmaps",lua_cocos2dx_Texture2D_hasMipmaps); + tolua_function(tolua_S,"setGLProgram",lua_cocos2dx_Texture2D_setGLProgram); tolua_function(tolua_S,"setMaxS",lua_cocos2dx_Texture2D_setMaxS); tolua_function(tolua_S,"new",lua_cocos2dx_Texture2D_constructor); tolua_function(tolua_S,"setDefaultAlphaPixelFormat", lua_cocos2dx_Texture2D_setDefaultAlphaPixelFormat); @@ -3926,970 +3687,6 @@ int lua_register_cocos2dx_Texture2D(lua_State* tolua_S) return 1; } -int lua_cocos2dx_EventListener_setEnabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventListener* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventListener",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventListener*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventListener_setEnabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0); - if(!ok) - return 0; - cobj->setEnabled(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventListener_setEnabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventListener_clone(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventListener* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventListener",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventListener*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventListener_clone'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cocos2d::EventListener* ret = cobj->clone(); - object_to_luaval(tolua_S, "cc.EventListener",(cocos2d::EventListener*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clone",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventListener_clone'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventListener_isEnabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventListener* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventListener",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventListener*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventListener_isEnabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - bool ret = cobj->isEnabled(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isEnabled",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventListener_isEnabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventListener_checkAvailable(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventListener* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventListener",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventListener*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventListener_checkAvailable'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - bool ret = cobj->checkAvailable(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "checkAvailable",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventListener_checkAvailable'.",&tolua_err); -#endif - - return 0; -} -static int lua_cocos2dx_EventListener_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (EventListener)"); - return 0; -} - -int lua_register_cocos2dx_EventListener(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.EventListener"); - tolua_cclass(tolua_S,"EventListener","cc.EventListener","cc.Ref",nullptr); - - tolua_beginmodule(tolua_S,"EventListener"); - tolua_function(tolua_S,"setEnabled",lua_cocos2dx_EventListener_setEnabled); - tolua_function(tolua_S,"clone",lua_cocos2dx_EventListener_clone); - tolua_function(tolua_S,"isEnabled",lua_cocos2dx_EventListener_isEnabled); - tolua_function(tolua_S,"checkAvailable",lua_cocos2dx_EventListener_checkAvailable); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::EventListener).name(); - g_luaType[typeName] = "cc.EventListener"; - g_typeCast["EventListener"] = "cc.EventListener"; - return 1; -} - -int lua_cocos2dx_EventDispatcher_pauseEventListenersForTarget(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_pauseEventListenersForTarget'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Node* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); - if(!ok) - return 0; - cobj->pauseEventListenersForTarget(arg0); - return 0; - } - if (argc == 2) - { - cocos2d::Node* arg0; - bool arg1; - - ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); - - ok &= luaval_to_boolean(tolua_S, 3,&arg1); - if(!ok) - return 0; - cobj->pauseEventListenersForTarget(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "pauseEventListenersForTarget",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_pauseEventListenersForTarget'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - cocos2d::EventListener* arg0; - cocos2d::Node* arg1; - - ok &= luaval_to_object(tolua_S, 2, "cc.EventListener",&arg0); - - ok &= luaval_to_object(tolua_S, 3, "cc.Node",&arg1); - if(!ok) - return 0; - cobj->addEventListenerWithSceneGraphPriority(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addEventListenerWithSceneGraphPriority",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_setEnabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_setEnabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0); - if(!ok) - return 0; - cobj->setEnabled(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setEnabled",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_setEnabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - cocos2d::EventListener* arg0; - int arg1; - - ok &= luaval_to_object(tolua_S, 2, "cc.EventListener",&arg0); - - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); - if(!ok) - return 0; - cobj->addEventListenerWithFixedPriority(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addEventListenerWithFixedPriority",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_removeEventListener(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeEventListener'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::EventListener* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.EventListener",&arg0); - if(!ok) - return 0; - cobj->removeEventListener(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeEventListener",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeEventListener'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_resumeEventListenersForTarget(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_resumeEventListenersForTarget'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Node* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); - if(!ok) - return 0; - cobj->resumeEventListenersForTarget(arg0); - return 0; - } - if (argc == 2) - { - cocos2d::Node* arg0; - bool arg1; - - ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); - - ok &= luaval_to_boolean(tolua_S, 3,&arg1); - if(!ok) - return 0; - cobj->resumeEventListenersForTarget(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resumeEventListenersForTarget",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_resumeEventListenersForTarget'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_removeEventListenersForTarget(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeEventListenersForTarget'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Node* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); - if(!ok) - return 0; - cobj->removeEventListenersForTarget(arg0); - return 0; - } - if (argc == 2) - { - cocos2d::Node* arg0; - bool arg1; - - ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); - - ok &= luaval_to_boolean(tolua_S, 3,&arg1); - if(!ok) - return 0; - cobj->removeEventListenersForTarget(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeEventListenersForTarget",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeEventListenersForTarget'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_setPriority(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_setPriority'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - cocos2d::EventListener* arg0; - int arg1; - - ok &= luaval_to_object(tolua_S, 2, "cc.EventListener",&arg0); - - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); - if(!ok) - return 0; - cobj->setPriority(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setPriority",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_setPriority'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_addCustomEventListener(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_addCustomEventListener'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - std::string arg0; - std::function arg1; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0); - - do { - // Lambda binding for lua is not supported. - assert(false); - } while(0) - ; - if(!ok) - return 0; - cocos2d::EventListenerCustom* ret = cobj->addCustomEventListener(arg0, arg1); - object_to_luaval(tolua_S, "cc.EventListenerCustom",(cocos2d::EventListenerCustom*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addCustomEventListener",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_addCustomEventListener'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_dispatchEvent(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_dispatchEvent'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Event* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Event",&arg0); - if(!ok) - return 0; - cobj->dispatchEvent(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "dispatchEvent",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_dispatchEvent'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_removeAllEventListeners(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeAllEventListeners'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj->removeAllEventListeners(); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllEventListeners",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeAllEventListeners'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_removeCustomEventListeners(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeCustomEventListeners'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0); - if(!ok) - return 0; - cobj->removeCustomEventListeners(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeCustomEventListeners",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeCustomEventListeners'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_isEnabled(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_isEnabled'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - bool ret = cobj->isEnabled(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isEnabled",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_isEnabled'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_removeEventListenersForType(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EventDispatcher",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventDispatcher*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventDispatcher_removeEventListenersForType'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::EventListener::Type arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - if(!ok) - return 0; - cobj->removeEventListenersForType(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeEventListenersForType",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_removeEventListenersForType'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_EventDispatcher_constructor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventDispatcher* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj = new cocos2d::EventDispatcher(); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventDispatcher"); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "EventDispatcher",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventDispatcher_constructor'.",&tolua_err); -#endif - - return 0; -} - -static int lua_cocos2dx_EventDispatcher_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (EventDispatcher)"); - return 0; -} - -int lua_register_cocos2dx_EventDispatcher(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.EventDispatcher"); - tolua_cclass(tolua_S,"EventDispatcher","cc.EventDispatcher","cc.Ref",nullptr); - - tolua_beginmodule(tolua_S,"EventDispatcher"); - tolua_function(tolua_S,"pauseEventListenersForTarget",lua_cocos2dx_EventDispatcher_pauseEventListenersForTarget); - tolua_function(tolua_S,"addEventListenerWithSceneGraphPriority",lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority); - tolua_function(tolua_S,"setEnabled",lua_cocos2dx_EventDispatcher_setEnabled); - tolua_function(tolua_S,"addEventListenerWithFixedPriority",lua_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority); - tolua_function(tolua_S,"removeEventListener",lua_cocos2dx_EventDispatcher_removeEventListener); - tolua_function(tolua_S,"resumeEventListenersForTarget",lua_cocos2dx_EventDispatcher_resumeEventListenersForTarget); - tolua_function(tolua_S,"removeEventListenersForTarget",lua_cocos2dx_EventDispatcher_removeEventListenersForTarget); - tolua_function(tolua_S,"setPriority",lua_cocos2dx_EventDispatcher_setPriority); - tolua_function(tolua_S,"addCustomEventListener",lua_cocos2dx_EventDispatcher_addCustomEventListener); - tolua_function(tolua_S,"dispatchEvent",lua_cocos2dx_EventDispatcher_dispatchEvent); - tolua_function(tolua_S,"removeAllEventListeners",lua_cocos2dx_EventDispatcher_removeAllEventListeners); - tolua_function(tolua_S,"removeCustomEventListeners",lua_cocos2dx_EventDispatcher_removeCustomEventListeners); - tolua_function(tolua_S,"isEnabled",lua_cocos2dx_EventDispatcher_isEnabled); - tolua_function(tolua_S,"removeEventListenersForType",lua_cocos2dx_EventDispatcher_removeEventListenersForType); - tolua_function(tolua_S,"new",lua_cocos2dx_EventDispatcher_constructor); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::EventDispatcher).name(); - g_luaType[typeName] = "cc.EventDispatcher"; - g_typeCast["EventDispatcher"] = "cc.EventDispatcher"; - return 1; -} - int lua_cocos2dx_Node_addChild(lua_State* tolua_S) { int argc = 0; @@ -5059,53 +3856,6 @@ int lua_cocos2dx_Node_setPhysicsBody(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Node_getShaderProgram(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Node* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getShaderProgram'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 0) { - const cocos2d::GLProgram* ret = cobj->getGLProgram(); - object_to_luaval(tolua_S, "cc.GLProgram",(cocos2d::GLProgram*)ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 0) { - cocos2d::GLProgram* ret = cobj->getGLProgram(); - object_to_luaval(tolua_S, "cc.GLProgram",(cocos2d::GLProgram*)ret); - return 1; - } - }while(0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getShaderProgram",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getShaderProgram'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Node_getDescription(lua_State* tolua_S) { int argc = 0; @@ -5878,7 +4628,7 @@ int lua_cocos2dx_Node_getTag(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Node_getNodeToWorldAffineTransform(lua_State* tolua_S) +int lua_cocos2dx_Node_getGLProgram(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; @@ -5898,7 +4648,7 @@ int lua_cocos2dx_Node_getNodeToWorldAffineTransform(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getNodeToWorldAffineTransform'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getGLProgram'", nullptr); return 0; } #endif @@ -5908,16 +4658,16 @@ int lua_cocos2dx_Node_getNodeToWorldAffineTransform(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::AffineTransform ret = cobj->getNodeToWorldAffineTransform(); - affinetransform_to_luaval(tolua_S, ret); + cocos2d::GLProgram* ret = cobj->getGLProgram(); + object_to_luaval(tolua_S, "cc.GLProgram",(cocos2d::GLProgram*)ret); return 1; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNodeToWorldAffineTransform",argc, 0); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGLProgram",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getNodeToWorldAffineTransform'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getGLProgram'.",&tolua_err); #endif return 0; @@ -6250,7 +5000,7 @@ int lua_cocos2dx_Node_setSkewX(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Node_setSkewY(lua_State* tolua_S) +int lua_cocos2dx_Node_setGLProgramState(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; @@ -6270,7 +5020,7 @@ int lua_cocos2dx_Node_setSkewY(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setSkewY'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setGLProgramState'", nullptr); return 0; } #endif @@ -6278,20 +5028,20 @@ int lua_cocos2dx_Node_setSkewY(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - double arg0; + cocos2d::GLProgramState* arg0; - ok &= luaval_to_number(tolua_S, 2,&arg0); + ok &= luaval_to_object(tolua_S, 2, "cc.GLProgramState",&arg0); if(!ok) return 0; - cobj->setSkewY(arg0); + cobj->setGLProgramState(arg0); return 0; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSkewY",argc, 1); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGLProgramState",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setSkewY'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setGLProgramState'.",&tolua_err); #endif return 0; @@ -7037,6 +5787,52 @@ int lua_cocos2dx_Node_ignoreAnchorPointForPosition(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Node_setSkewY(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Node* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setSkewY'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + double arg0; + + ok &= luaval_to_number(tolua_S, 2,&arg0); + if(!ok) + return 0; + cobj->setSkewY(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSkewY",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setSkewY'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Node_setPositionZ(lua_State* tolua_S) { int argc = 0; @@ -7534,7 +6330,7 @@ int lua_cocos2dx_Node_addComponent(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Node_setGLProgram(lua_State* tolua_S) +int lua_cocos2dx_Node_isOpacityModifyRGB(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; @@ -7554,28 +6350,26 @@ int lua_cocos2dx_Node_setGLProgram(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setShaderProgram'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_isOpacityModifyRGB'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 0) { - cocos2d::GLProgram* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.GLProgram",&arg0); if(!ok) return 0; - cobj->setGLProgram(arg0); - return 0; + bool ret = cobj->isOpacityModifyRGB(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setShaderProgram",argc, 1); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isOpacityModifyRGB",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setShaderProgram'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_isOpacityModifyRGB'.",&tolua_err); #endif return 0; @@ -7715,6 +6509,50 @@ int lua_cocos2dx_Node_runAction(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Node_getGLProgramState(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Node* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getGLProgramState'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cocos2d::GLProgramState* ret = cobj->getGLProgramState(); + object_to_luaval(tolua_S, "cc.GLProgramState",(cocos2d::GLProgramState*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getGLProgramState",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getGLProgramState'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Node_setScheduler(lua_State* tolua_S) { int argc = 0; @@ -8679,6 +7517,50 @@ int lua_cocos2dx_Node_setPositionY(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Node_getNodeToWorldAffineTransform(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Node* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getNodeToWorldAffineTransform'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cocos2d::AffineTransform ret = cobj->getNodeToWorldAffineTransform(); + affinetransform_to_luaval(tolua_S, ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNodeToWorldAffineTransform",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getNodeToWorldAffineTransform'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Node_updateDisplayedColor(lua_State* tolua_S) { int argc = 0; @@ -9968,6 +8850,52 @@ int lua_cocos2dx_Node_getWorldToNodeTransform(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Node_setGLProgram(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Node* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setGLProgram'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::GLProgram* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.GLProgram",&arg0); + if(!ok) + return 0; + cobj->setGLProgram(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGLProgram",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setGLProgram'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Node_getScale(lua_State* tolua_S) { int argc = 0; @@ -10190,50 +9118,6 @@ int lua_cocos2dx_Node_isCascadeColorEnabled(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Node_isOpacityModifyRGB(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Node* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_isOpacityModifyRGB'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - bool ret = cobj->isOpacityModifyRGB(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isOpacityModifyRGB",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_isOpacityModifyRGB'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Node_stopAction(lua_State* tolua_S) { int argc = 0; @@ -10373,7 +9257,6 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) tolua_function(tolua_S,"addChild",lua_cocos2dx_Node_addChild); tolua_function(tolua_S,"removeComponent",lua_cocos2dx_Node_removeComponent); tolua_function(tolua_S,"setPhysicsBody",lua_cocos2dx_Node_setPhysicsBody); - tolua_function(tolua_S,"getShaderProgram",lua_cocos2dx_Node_getShaderProgram); tolua_function(tolua_S,"getDescription",lua_cocos2dx_Node_getDescription); tolua_function(tolua_S,"setRotationSkewY",lua_cocos2dx_Node_setRotationSkewY); tolua_function(tolua_S,"setOpacityModifyRGB",lua_cocos2dx_Node_setOpacityModifyRGB); @@ -10391,7 +9274,7 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) tolua_function(tolua_S,"removeAllComponents",lua_cocos2dx_Node_removeAllComponents); tolua_function(tolua_S,"_setLocalZOrder",lua_cocos2dx_Node__setLocalZOrder); tolua_function(tolua_S,"getTag",lua_cocos2dx_Node_getTag); - tolua_function(tolua_S,"getNodeToWorldAffineTransform",lua_cocos2dx_Node_getNodeToWorldAffineTransform); + tolua_function(tolua_S,"getGLProgram",lua_cocos2dx_Node_getGLProgram); tolua_function(tolua_S,"getNodeToWorldTransform",lua_cocos2dx_Node_getNodeToWorldTransform); tolua_function(tolua_S,"getPosition3D",lua_cocos2dx_Node_getPosition3D); tolua_function(tolua_S,"removeChild",lua_cocos2dx_Node_removeChild); @@ -10399,7 +9282,7 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) tolua_function(tolua_S,"getScene",lua_cocos2dx_Node_getScene); tolua_function(tolua_S,"getEventDispatcher",lua_cocos2dx_Node_getEventDispatcher); tolua_function(tolua_S,"setSkewX",lua_cocos2dx_Node_setSkewX); - tolua_function(tolua_S,"setSkewY",lua_cocos2dx_Node_setSkewY); + tolua_function(tolua_S,"setGLProgramState",lua_cocos2dx_Node_setGLProgramState); tolua_function(tolua_S,"getOpacity",lua_cocos2dx_Node_getOpacity); tolua_function(tolua_S,"convertTouchToNodeSpace",lua_cocos2dx_Node_convertTouchToNodeSpace); tolua_function(tolua_S,"removeAllChildren",lua_cocos2dx_Node_removeAllChildrenWithCleanup); @@ -10416,6 +9299,7 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) tolua_function(tolua_S,"stopActionByTag",lua_cocos2dx_Node_stopActionByTag); tolua_function(tolua_S,"reorderChild",lua_cocos2dx_Node_reorderChild); tolua_function(tolua_S,"ignoreAnchorPointForPosition",lua_cocos2dx_Node_ignoreAnchorPointForPosition); + tolua_function(tolua_S,"setSkewY",lua_cocos2dx_Node_setSkewY); tolua_function(tolua_S,"setPositionZ",lua_cocos2dx_Node_setPositionZ); tolua_function(tolua_S,"setRotation3D",lua_cocos2dx_Node_setRotation3D); tolua_function(tolua_S,"setPositionX",lua_cocos2dx_Node_setPositionX); @@ -10427,10 +9311,11 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) tolua_function(tolua_S,"getChildrenCount",lua_cocos2dx_Node_getChildrenCount); tolua_function(tolua_S,"convertToNodeSpaceAR",lua_cocos2dx_Node_convertToNodeSpaceAR); tolua_function(tolua_S,"addComponent",lua_cocos2dx_Node_addComponent); - tolua_function(tolua_S,"setShaderProgram",lua_cocos2dx_Node_setShaderProgram); + tolua_function(tolua_S,"isOpacityModifyRGB",lua_cocos2dx_Node_isOpacityModifyRGB); tolua_function(tolua_S,"getRotation",lua_cocos2dx_Node_getRotation); tolua_function(tolua_S,"getAnchorPointInPoints",lua_cocos2dx_Node_getAnchorPointInPoints); tolua_function(tolua_S,"runAction",lua_cocos2dx_Node_runAction); + tolua_function(tolua_S,"getGLProgramState",lua_cocos2dx_Node_getGLProgramState); tolua_function(tolua_S,"setScheduler",lua_cocos2dx_Node_setScheduler); tolua_function(tolua_S,"stopAllActions",lua_cocos2dx_Node_stopAllActions); tolua_function(tolua_S,"getSkewX",lua_cocos2dx_Node_getSkewX); @@ -10452,6 +9337,7 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) tolua_function(tolua_S,"getPositionX",lua_cocos2dx_Node_getPositionX); tolua_function(tolua_S,"removeChildByTag",lua_cocos2dx_Node_removeChildByTag); tolua_function(tolua_S,"setPositionY",lua_cocos2dx_Node_setPositionY); + tolua_function(tolua_S,"getNodeToWorldAffineTransform",lua_cocos2dx_Node_getNodeToWorldAffineTransform); tolua_function(tolua_S,"updateDisplayedColor",lua_cocos2dx_Node_updateDisplayedColor); tolua_function(tolua_S,"setVisible",lua_cocos2dx_Node_setVisible); tolua_function(tolua_S,"getParentToNodeTransform",lua_cocos2dx_Node_getParentToNodeTransform); @@ -10480,12 +9366,12 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) tolua_function(tolua_S,"update",lua_cocos2dx_Node_update); tolua_function(tolua_S,"sortAllChildren",lua_cocos2dx_Node_sortAllChildren); tolua_function(tolua_S,"getWorldToNodeTransform",lua_cocos2dx_Node_getWorldToNodeTransform); + tolua_function(tolua_S,"setGLProgram",lua_cocos2dx_Node_setGLProgram); tolua_function(tolua_S,"getScale",lua_cocos2dx_Node_getScale); tolua_function(tolua_S,"getRotationSkewX",lua_cocos2dx_Node_getRotationSkewX); tolua_function(tolua_S,"getRotationSkewY",lua_cocos2dx_Node_getRotationSkewY); tolua_function(tolua_S,"setTag",lua_cocos2dx_Node_setTag); tolua_function(tolua_S,"isCascadeColorEnabled",lua_cocos2dx_Node_isCascadeColorEnabled); - tolua_function(tolua_S,"isOpacityModifyRGB",lua_cocos2dx_Node_isOpacityModifyRGB); tolua_function(tolua_S,"stopAction",lua_cocos2dx_Node_stopAction); tolua_function(tolua_S,"getActionManager",lua_cocos2dx_Node_getActionManager); tolua_function(tolua_S,"create", lua_cocos2dx_Node_create); @@ -10496,6 +9382,1377 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) return 1; } +int lua_cocos2dx_GLProgram_getFragmentShaderLog(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getFragmentShaderLog'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + std::string ret = cobj->getFragmentShaderLog(); + tolua_pushcppstring(tolua_S,ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getFragmentShaderLog",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getFragmentShaderLog'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_initWithByteArrays(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_initWithByteArrays'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + const char* arg0; + const char* arg1; + + std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); + + std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); + if(!ok) + return 0; + bool ret = cobj->initWithByteArrays(arg0, arg1); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithByteArrays",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_initWithByteArrays'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 3) + { + int arg0; + const float* arg1; + unsigned int arg2; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); + + #pragma warning NO CONVERSION TO NATIVE FOR float*; + + ok &= luaval_to_uint32(tolua_S, 4,&arg2); + if(!ok) + return 0; + cobj->setUniformLocationWithMatrix4fv(arg0, arg1, arg2); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWithMatrix4fv",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_initWithFilenames(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_initWithFilenames'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + std::string arg0; + std::string arg1; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0); + + ok &= luaval_to_std_string(tolua_S, 3,&arg1); + if(!ok) + return 0; + bool ret = cobj->initWithFilenames(arg0, arg1); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithFilenames",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_initWithFilenames'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_getUniformLocationForName(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getUniformLocationForName'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + const char* arg0; + + std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); + if(!ok) + return 0; + int ret = cobj->getUniformLocationForName(arg0); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUniformLocationForName",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getUniformLocationForName'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_use(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_use'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cobj->use(); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "use",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_use'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_getVertexShaderLog(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getVertexShaderLog'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + std::string ret = cobj->getVertexShaderLog(); + tolua_pushcppstring(tolua_S,ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVertexShaderLog",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getVertexShaderLog'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_getUniform(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getUniform'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0); + if(!ok) + return 0; + cocos2d::Uniform* ret = cobj->getUniform(arg0); + #pragma warning NO CONVERSION FROM NATIVE FOR Uniform*; + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUniform",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getUniform'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_setUniformsForBuiltins(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformsForBuiltins'", nullptr); + return 0; + } +#endif + argc = lua_gettop(tolua_S)-1; + do{ + if (argc == 1) { + cocos2d::Matrix arg0; + ok &= luaval_to_matrix(tolua_S, 2, &arg0); + + if (!ok) { break; } + cobj->setUniformsForBuiltins(arg0); + return 0; + } + }while(0); + ok = true; + do{ + if (argc == 0) { + cobj->setUniformsForBuiltins(); + return 0; + } + }while(0); + ok = true; + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformsForBuiltins",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformsForBuiltins'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_setUniformLocationWith3i(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith3i'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 4) + { + int arg0; + int arg1; + int arg2; + int arg3; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); + + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); + + ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); + + ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); + if(!ok) + return 0; + cobj->setUniformLocationWith3i(arg0, arg1, arg2, arg3); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith3i",argc, 4); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith3i'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_setUniformLocationWith3iv(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith3iv'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 3) + { + int arg0; + int* arg1; + unsigned int arg2; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); + + #pragma warning NO CONVERSION TO NATIVE FOR int*; + + ok &= luaval_to_uint32(tolua_S, 4,&arg2); + if(!ok) + return 0; + cobj->setUniformLocationWith3iv(arg0, arg1, arg2); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith3iv",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith3iv'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_updateUniforms(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_updateUniforms'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cobj->updateUniforms(); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateUniforms",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_updateUniforms'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_setUniformLocationWith4iv(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith4iv'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 3) + { + int arg0; + int* arg1; + unsigned int arg2; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); + + #pragma warning NO CONVERSION TO NATIVE FOR int*; + + ok &= luaval_to_uint32(tolua_S, 4,&arg2); + if(!ok) + return 0; + cobj->setUniformLocationWith4iv(arg0, arg1, arg2); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith4iv",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith4iv'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_getUniformLocation(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getUniformLocation'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0); + if(!ok) + return 0; + int ret = cobj->getUniformLocation(arg0); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getUniformLocation",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getUniformLocation'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_setUniformLocationWith1i(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith1i'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + int arg0; + int arg1; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); + + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); + if(!ok) + return 0; + cobj->setUniformLocationWith1i(arg0, arg1); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith1i",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith1i'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_setUniformLocationWith2iv(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith2iv'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 3) + { + int arg0; + int* arg1; + unsigned int arg2; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); + + #pragma warning NO CONVERSION TO NATIVE FOR int*; + + ok &= luaval_to_uint32(tolua_S, 4,&arg2); + if(!ok) + return 0; + cobj->setUniformLocationWith2iv(arg0, arg1, arg2); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith2iv",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith2iv'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 3) + { + int arg0; + const float* arg1; + unsigned int arg2; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); + + #pragma warning NO CONVERSION TO NATIVE FOR float*; + + ok &= luaval_to_uint32(tolua_S, 4,&arg2); + if(!ok) + return 0; + cobj->setUniformLocationWithMatrix3fv(arg0, arg1, arg2); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWithMatrix3fv",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_reset(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_reset'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cobj->reset(); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reset",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_reset'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_bindAttribLocation(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_bindAttribLocation'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + std::string arg0; + unsigned int arg1; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0); + + ok &= luaval_to_uint32(tolua_S, 3,&arg1); + if(!ok) + return 0; + cobj->bindAttribLocation(arg0, arg1); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "bindAttribLocation",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_bindAttribLocation'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_getAttribLocation(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getAttribLocation'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0); + if(!ok) + return 0; + int ret = cobj->getAttribLocation(arg0); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getAttribLocation",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getAttribLocation'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_getVertexAttrib(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_getVertexAttrib'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0); + if(!ok) + return 0; + cocos2d::VertexAttrib* ret = cobj->getVertexAttrib(arg0); + #pragma warning NO CONVERSION FROM NATIVE FOR VertexAttrib*; + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getVertexAttrib",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_getVertexAttrib'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 3) + { + int arg0; + const float* arg1; + unsigned int arg2; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); + + #pragma warning NO CONVERSION TO NATIVE FOR float*; + + ok &= luaval_to_uint32(tolua_S, 4,&arg2); + if(!ok) + return 0; + cobj->setUniformLocationWithMatrix2fv(arg0, arg1, arg2); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWithMatrix2fv",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_setUniformLocationWith4i(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith4i'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 5) + { + int arg0; + int arg1; + int arg2; + int arg3; + int arg4; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); + + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); + + ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); + + ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3); + + ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4); + if(!ok) + return 0; + cobj->setUniformLocationWith4i(arg0, arg1, arg2, arg3, arg4); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith4i",argc, 5); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith4i'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_link(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_link'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + bool ret = cobj->link(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "link",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_link'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_setUniformLocationWith2i(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::GLProgram*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgram_setUniformLocationWith2i'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 3) + { + int arg0; + int arg1; + int arg2; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); + + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); + + ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); + if(!ok) + return 0; + cobj->setUniformLocationWith2i(arg0, arg1, arg2); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformLocationWith2i",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_setUniformLocationWith2i'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_GLProgram_createWithByteArrays(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + const char* arg0; + const char* arg1; + std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp); arg0 = arg0_tmp.c_str(); + std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp); arg1 = arg1_tmp.c_str(); + if(!ok) + return 0; + cocos2d::GLProgram* ret = cocos2d::GLProgram::createWithByteArrays(arg0, arg1); + object_to_luaval(tolua_S, "cc.GLProgram",(cocos2d::GLProgram*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithByteArrays",argc, 2); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_createWithByteArrays'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_GLProgram_createWithFilenames(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.GLProgram",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 2) + { + std::string arg0; + std::string arg1; + ok &= luaval_to_std_string(tolua_S, 2,&arg0); + ok &= luaval_to_std_string(tolua_S, 3,&arg1); + if(!ok) + return 0; + cocos2d::GLProgram* ret = cocos2d::GLProgram::createWithFilenames(arg0, arg1); + object_to_luaval(tolua_S, "cc.GLProgram",(cocos2d::GLProgram*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithFilenames",argc, 2); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_createWithFilenames'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_GLProgram_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::GLProgram* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cobj = new cocos2d::GLProgram(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.GLProgram"); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "GLProgram",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_GLProgram_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_GLProgram_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (GLProgram)"); + return 0; +} + +int lua_register_cocos2dx_GLProgram(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.GLProgram"); + tolua_cclass(tolua_S,"GLProgram","cc.GLProgram","cc.Ref",nullptr); + + tolua_beginmodule(tolua_S,"GLProgram"); + tolua_function(tolua_S,"getFragmentShaderLog",lua_cocos2dx_GLProgram_getFragmentShaderLog); + tolua_function(tolua_S,"initWithByteArrays",lua_cocos2dx_GLProgram_initWithByteArrays); + tolua_function(tolua_S,"setUniformLocationWithMatrix4fv",lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv); + tolua_function(tolua_S,"initWithFilenames",lua_cocos2dx_GLProgram_initWithFilenames); + tolua_function(tolua_S,"getUniformLocationForName",lua_cocos2dx_GLProgram_getUniformLocationForName); + tolua_function(tolua_S,"use",lua_cocos2dx_GLProgram_use); + tolua_function(tolua_S,"getVertexShaderLog",lua_cocos2dx_GLProgram_getVertexShaderLog); + tolua_function(tolua_S,"getUniform",lua_cocos2dx_GLProgram_getUniform); + tolua_function(tolua_S,"setUniformsForBuiltins",lua_cocos2dx_GLProgram_setUniformsForBuiltins); + tolua_function(tolua_S,"setUniformLocationWith3i",lua_cocos2dx_GLProgram_setUniformLocationWith3i); + tolua_function(tolua_S,"setUniformLocationWith3iv",lua_cocos2dx_GLProgram_setUniformLocationWith3iv); + tolua_function(tolua_S,"updateUniforms",lua_cocos2dx_GLProgram_updateUniforms); + tolua_function(tolua_S,"setUniformLocationWith4iv",lua_cocos2dx_GLProgram_setUniformLocationWith4iv); + tolua_function(tolua_S,"getUniformLocation",lua_cocos2dx_GLProgram_getUniformLocation); + tolua_function(tolua_S,"setUniformLocationI32",lua_cocos2dx_GLProgram_setUniformLocationWith1i); + tolua_function(tolua_S,"setUniformLocationWith2iv",lua_cocos2dx_GLProgram_setUniformLocationWith2iv); + tolua_function(tolua_S,"setUniformLocationWithMatrix3fv",lua_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv); + tolua_function(tolua_S,"reset",lua_cocos2dx_GLProgram_reset); + tolua_function(tolua_S,"bindAttribLocation",lua_cocos2dx_GLProgram_bindAttribLocation); + tolua_function(tolua_S,"getAttribLocation",lua_cocos2dx_GLProgram_getAttribLocation); + tolua_function(tolua_S,"getVertexAttrib",lua_cocos2dx_GLProgram_getVertexAttrib); + tolua_function(tolua_S,"setUniformLocationWithMatrix2fv",lua_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv); + tolua_function(tolua_S,"setUniformLocationWith4i",lua_cocos2dx_GLProgram_setUniformLocationWith4i); + tolua_function(tolua_S,"link",lua_cocos2dx_GLProgram_link); + tolua_function(tolua_S,"setUniformLocationWith2i",lua_cocos2dx_GLProgram_setUniformLocationWith2i); + tolua_function(tolua_S,"new",lua_cocos2dx_GLProgram_constructor); + tolua_function(tolua_S,"createWithByteArrays", lua_cocos2dx_GLProgram_createWithByteArrays); + tolua_function(tolua_S,"createWithFilenames", lua_cocos2dx_GLProgram_createWithFilenames); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::GLProgram).name(); + g_luaType[typeName] = "cc.GLProgram"; + g_typeCast["GLProgram"] = "cc.GLProgram"; + return 1; +} + int lua_cocos2dx_AtlasNode_updateAtlasValues(lua_State* tolua_S) { int argc = 0; @@ -55863,309 +56120,6 @@ int lua_register_cocos2dx_GLView(lua_State* tolua_S) return 1; } -int lua_cocos2dx_ShaderCache_reloadDefaultShaders(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ShaderCache* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.ShaderCache",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ShaderCache*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ShaderCache_reloadDefaultShaders'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj->reloadDefaultShaders(); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "reloadDefaultShaders",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_reloadDefaultShaders'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ShaderCache_addProgram(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ShaderCache* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.ShaderCache",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ShaderCache*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ShaderCache_addProgram'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - cocos2d::GLProgram* arg0; - std::string arg1; - - ok &= luaval_to_object(tolua_S, 2, "cc.GLProgram",&arg0); - - ok &= luaval_to_std_string(tolua_S, 3,&arg1); - if(!ok) - return 0; - cobj->addProgram(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addProgram",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_addProgram'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ShaderCache_getProgram(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ShaderCache* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.ShaderCache",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ShaderCache*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ShaderCache_getProgram'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0); - if(!ok) - return 0; - cocos2d::GLProgram* ret = cobj->getProgram(arg0); - object_to_luaval(tolua_S, "cc.GLProgram",(cocos2d::GLProgram*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getProgram",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_getProgram'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ShaderCache_loadDefaultShaders(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ShaderCache* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.ShaderCache",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ShaderCache*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ShaderCache_loadDefaultShaders'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj->loadDefaultShaders(); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "loadDefaultShaders",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_loadDefaultShaders'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ShaderCache_destroyInstance(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.ShaderCache",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 0) - { - if(!ok) - return 0; - cocos2d::ShaderCache::destroyInstance(); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "destroyInstance",argc, 0); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_destroyInstance'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_ShaderCache_getInstance(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.ShaderCache",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 0) - { - if(!ok) - return 0; - cocos2d::ShaderCache* ret = cocos2d::GLProgramCache::getInstance(); - object_to_luaval(tolua_S, "cc.ShaderCache",(cocos2d::ShaderCache*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getInstance",argc, 0); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_getInstance'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_ShaderCache_constructor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ShaderCache* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj = new cocos2d::ShaderCache(); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.ShaderCache"); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ShaderCache",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ShaderCache_constructor'.",&tolua_err); -#endif - - return 0; -} - -static int lua_cocos2dx_ShaderCache_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (ShaderCache)"); - return 0; -} - -int lua_register_cocos2dx_ShaderCache(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.ShaderCache"); - tolua_cclass(tolua_S,"ShaderCache","cc.ShaderCache","cc.Ref",nullptr); - - tolua_beginmodule(tolua_S,"ShaderCache"); - tolua_function(tolua_S,"reloadDefaultShaders",lua_cocos2dx_ShaderCache_reloadDefaultShaders); - tolua_function(tolua_S,"addProgram",lua_cocos2dx_ShaderCache_addProgram); - tolua_function(tolua_S,"getProgram",lua_cocos2dx_ShaderCache_getProgram); - tolua_function(tolua_S,"loadDefaultShaders",lua_cocos2dx_ShaderCache_loadDefaultShaders); - tolua_function(tolua_S,"new",lua_cocos2dx_ShaderCache_constructor); - tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_ShaderCache_destroyInstance); - tolua_function(tolua_S,"getInstance", lua_cocos2dx_ShaderCache_getInstance); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::ShaderCache).name(); - g_luaType[typeName] = "cc.ShaderCache"; - g_typeCast["ShaderCache"] = "cc.ShaderCache"; - return 1; -} - int lua_cocos2dx_AnimationCache_getAnimation(lua_State* tolua_S) { int argc = 0; @@ -65220,7 +65174,9 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_FiniteTimeAction(tolua_S); lua_register_cocos2dx_ActionInstant(tolua_S); lua_register_cocos2dx_Hide(tolua_S); - lua_register_cocos2dx_Scheduler(tolua_S); + lua_register_cocos2dx_ParticleSystem(tolua_S); + lua_register_cocos2dx_ParticleSystemQuad(tolua_S); + lua_register_cocos2dx_ParticleSpiral(tolua_S); lua_register_cocos2dx_GridBase(tolua_S); lua_register_cocos2dx_AnimationCache(tolua_S); lua_register_cocos2dx_ActionInterval(tolua_S); @@ -65234,16 +65190,15 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_EventListenerMouse(tolua_S); lua_register_cocos2dx_TransitionRotoZoom(tolua_S); lua_register_cocos2dx_Director(tolua_S); - lua_register_cocos2dx_Texture2D(tolua_S); + lua_register_cocos2dx_Scheduler(tolua_S); lua_register_cocos2dx_ActionEase(tolua_S); lua_register_cocos2dx_EaseElastic(tolua_S); lua_register_cocos2dx_EaseElasticOut(tolua_S); lua_register_cocos2dx_EaseQuadraticActionInOut(tolua_S); lua_register_cocos2dx_EaseBackOut(tolua_S); + lua_register_cocos2dx_Texture2D(tolua_S); lua_register_cocos2dx_TransitionSceneOriented(tolua_S); lua_register_cocos2dx_TransitionFlipX(tolua_S); - lua_register_cocos2dx_ParticleSystem(tolua_S); - lua_register_cocos2dx_ParticleSystemQuad(tolua_S); lua_register_cocos2dx_GridAction(tolua_S); lua_register_cocos2dx_TiledGrid3DAction(tolua_S); lua_register_cocos2dx_FadeOutTRTiles(tolua_S); @@ -65251,7 +65206,6 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_FadeOutDownTiles(tolua_S); lua_register_cocos2dx_StopGrid(tolua_S); lua_register_cocos2dx_SimpleAudioEngine(tolua_S); - lua_register_cocos2dx_ParticleSpiral(tolua_S); lua_register_cocos2dx_SkewTo(tolua_S); lua_register_cocos2dx_SkewBy(tolua_S); lua_register_cocos2dx_EaseQuadraticActionOut(tolua_S); @@ -65329,7 +65283,6 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_Image(tolua_S); lua_register_cocos2dx_LayerMultiplex(tolua_S); lua_register_cocos2dx_Blink(tolua_S); - lua_register_cocos2dx_ShaderCache(tolua_S); lua_register_cocos2dx_JumpTo(tolua_S); lua_register_cocos2dx_ParticleExplosion(tolua_S); lua_register_cocos2dx_TransitionJumpZoom(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 8969923520..682e55e5be 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -1561,8 +1561,6 @@ int register_all_cocos2dx(lua_State* tolua_S); - - From 1a0ab4bf92c0fcdc4a76649683bde7f8b46b56c7 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 20:51:46 -0700 Subject: [PATCH 083/174] 10 tests --- tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index e22e9c6791..91badc1207 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -4,7 +4,7 @@ static int sceneIdx = -1; -#define MAX_LAYER 11 +#define MAX_LAYER 10 static Layer* createShaderLayer(int nIndex) { From b1ff6bfd1f0c8ebf948bfb3bb0db670d2734d93e Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Sat, 10 May 2014 03:55:21 +0000 Subject: [PATCH 084/174] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 348d1e1e7a..d285591473 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -1130,10 +1130,8 @@ "external/Box2D/Rope/b2Rope.h", "external/Box2D/proj.win32/Box2D.vcxproj", "external/Box2D/proj.win32/Box2D.vcxproj.filters", - "external/Box2D/proj.win32/Box2D.vcxproj.user", "external/Box2D/proj.wp8/Box2D.vcxproj", "external/Box2D/proj.wp8/Box2D.vcxproj.filters", - "external/Box2D/proj.wp8/Box2D.vcxproj.user", "external/chipmunk/Android.mk", "external/chipmunk/LICENSE.txt", "external/chipmunk/README.txt", @@ -1165,12 +1163,10 @@ "external/chipmunk/include/chipmunk/cpVect.h", "external/chipmunk/proj.win32/chipmunk.vcxproj", "external/chipmunk/proj.win32/chipmunk.vcxproj.filters", - "external/chipmunk/proj.win32/chipmunk.vcxproj.user", "external/chipmunk/proj.winrt/chipmunk.vcxproj", "external/chipmunk/proj.winrt/chipmunk.vcxproj.filters", "external/chipmunk/proj.wp8/chipmunk.vcxproj", "external/chipmunk/proj.wp8/chipmunk.vcxproj.filters", - "external/chipmunk/proj.wp8/chipmunk.vcxproj.user", "external/chipmunk/src/CMakeLists.txt", "external/chipmunk/src/chipmunk.c", "external/chipmunk/src/constraints/cpConstraint.c", @@ -2042,7 +2038,7 @@ "external/unzip/ioapi.h", "external/unzip/unzip.cpp", "external/unzip/unzip.h", - "external/version.txt", + "external/version.json", "external/webp/include/android/decode.h", "external/webp/include/android/encode.h", "external/webp/include/android/types.h", From 4ce297458f8fcfd5b7c02bea4599cafca9d46af6 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Sat, 10 May 2014 03:58:12 +0000 Subject: [PATCH 085/174] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 348d1e1e7a..5f41054ef8 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -1130,10 +1130,8 @@ "external/Box2D/Rope/b2Rope.h", "external/Box2D/proj.win32/Box2D.vcxproj", "external/Box2D/proj.win32/Box2D.vcxproj.filters", - "external/Box2D/proj.win32/Box2D.vcxproj.user", "external/Box2D/proj.wp8/Box2D.vcxproj", "external/Box2D/proj.wp8/Box2D.vcxproj.filters", - "external/Box2D/proj.wp8/Box2D.vcxproj.user", "external/chipmunk/Android.mk", "external/chipmunk/LICENSE.txt", "external/chipmunk/README.txt", @@ -1165,12 +1163,10 @@ "external/chipmunk/include/chipmunk/cpVect.h", "external/chipmunk/proj.win32/chipmunk.vcxproj", "external/chipmunk/proj.win32/chipmunk.vcxproj.filters", - "external/chipmunk/proj.win32/chipmunk.vcxproj.user", "external/chipmunk/proj.winrt/chipmunk.vcxproj", "external/chipmunk/proj.winrt/chipmunk.vcxproj.filters", "external/chipmunk/proj.wp8/chipmunk.vcxproj", "external/chipmunk/proj.wp8/chipmunk.vcxproj.filters", - "external/chipmunk/proj.wp8/chipmunk.vcxproj.user", "external/chipmunk/src/CMakeLists.txt", "external/chipmunk/src/chipmunk.c", "external/chipmunk/src/constraints/cpConstraint.c", @@ -2042,7 +2038,7 @@ "external/unzip/ioapi.h", "external/unzip/unzip.cpp", "external/unzip/unzip.h", - "external/version.txt", + "external/version.json", "external/webp/include/android/decode.h", "external/webp/include/android/encode.h", "external/webp/include/android/types.h", @@ -3731,7 +3727,6 @@ "cocos/scripting/lua-bindings/auto/api/Scheduler.lua", "cocos/scripting/lua-bindings/auto/api/ScrollView.lua", "cocos/scripting/lua-bindings/auto/api/Sequence.lua", - "cocos/scripting/lua-bindings/auto/api/ShaderCache.lua", "cocos/scripting/lua-bindings/auto/api/Shaky3D.lua", "cocos/scripting/lua-bindings/auto/api/ShakyTiles3D.lua", "cocos/scripting/lua-bindings/auto/api/ShatteredTiles3D.lua", From 605fe8e4f31aa0bf8368f58737e7373f475eb268 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 21:06:02 -0700 Subject: [PATCH 086/174] fixes double free crash on GLProgramStateCache --- cocos/renderer/CCGLProgramStateCache.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cocos/renderer/CCGLProgramStateCache.cpp b/cocos/renderer/CCGLProgramStateCache.cpp index a22755381a..51ddef546a 100644 --- a/cocos/renderer/CCGLProgramStateCache.cpp +++ b/cocos/renderer/CCGLProgramStateCache.cpp @@ -33,16 +33,11 @@ GLProgramStateCache* GLProgramStateCache::s_instance = nullptr; GLProgramStateCache::GLProgramStateCache() { - s_instance = nullptr; } GLProgramStateCache::~GLProgramStateCache() { - for (auto itr = _glProgramStates.begin(); itr != _glProgramStates.end(); itr++) { - itr->second->release(); - } _glProgramStates.clear(); - s_instance = nullptr; } GLProgramStateCache* GLProgramStateCache::getInstance() From a8c2fb5431f8324a5de0062b5b7bf2f843195995 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 21:29:24 -0700 Subject: [PATCH 087/174] Fixes deprecated warnings --- cocos/2d/CCClippingNode.cpp | 2 +- cocos/2d/CCLabel.cpp | 25 ++++++++++--------- cocos/2d/CCLayer.cpp | 18 ++++++------- cocos/2d/CCNode.cpp | 2 +- .../ClippingNodeTest/ClippingNodeTest.cpp | 6 ++--- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index 4d310523cc..f82fa5231d 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -237,7 +237,7 @@ void ClippingNode::visit(Renderer *renderer, const Matrix &parentTransform, bool #else // since glAlphaTest do not exists in OES, use a shader that writes // pixel only if greater than an alpha threshold - GLProgram *program = GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); + GLProgram *program = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); // set our alphaThreshold program->use(); diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index a08c048b6e..0eda61ddd2 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -25,22 +25,23 @@ #include "2d/CCLabel.h" #include "2d/CCFontAtlasCache.h" -#include "CCLabelTextFormatter.h" #include "2d/CCSprite.h" -#include "renderer/CCGLProgramCache.h" -#include "ccUTF8.h" +#include "2d/CCLabelTextFormatter.h" +#include "2d/ccUTF8.h" #include "2d/CCSpriteFrame.h" -#include "base/CCDirector.h" +#include "2d/platform/CCFileUtils.h" +#include "2d/CCFont.h" +#include "renderer/CCGLProgramState.h" #include "renderer/CCRenderer.h" -#include "CCFont.h" +#include "base/CCDirector.h" #include "base/CCEventListenerCustom.h" #include "base/CCEventDispatcher.h" #include "base/CCEventType.h" #include "base/CCEventCustom.h" -#include "2d/platform/CCFileUtils.h" -#include "deprecated/CCString.h" #include "base/CCProfiling.h" +#include "deprecated/CCString.h" + NS_CC_BEGIN const int Label::DistanceFieldFontSize = 50; @@ -342,21 +343,21 @@ void Label::updateShaderProgram() { case cocos2d::LabelEffect::NORMAL: if (_useDistanceField) - setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL)); else if (_useA8Shader) - setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_NORMAL)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_LABEL_NORMAL)); else - setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); break; case cocos2d::LabelEffect::OUTLINE: - setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_OUTLINE)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_LABEL_OUTLINE)); _uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "v_effectColor"); break; case cocos2d::LabelEffect::GLOW: if (_useDistanceField) { - setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW)); _uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "v_effectColor"); } break; diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index b3cc93c582..e27f5e1989 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -27,13 +27,15 @@ THE SOFTWARE. #include #include "2d/CCLayer.h" -#include "base/CCDirector.h" #include "2d/CCScriptSupport.h" -#include "renderer/CCGLProgramCache.h" +#include "2d/platform/CCDevice.h" +#include "2d/CCScene.h" +#include "renderer/CCGLProgramState.h" #include "renderer/CCGLProgram.h" +#include "renderer/CCCustomCommand.h" +#include "renderer/CCRenderer.h" #include "renderer/ccGLStateCache.h" -#include "math/TransformUtils.h" -// extern +#include "base/CCDirector.h" #include "base/CCEventDispatcher.h" #include "base/CCEventListenerTouch.h" #include "base/CCEventTouch.h" @@ -41,10 +43,8 @@ THE SOFTWARE. #include "base/CCEventListenerKeyboard.h" #include "base/CCEventAcceleration.h" #include "base/CCEventListenerAcceleration.h" -#include "2d/platform/CCDevice.h" -#include "2d/CCScene.h" -#include "renderer/CCCustomCommand.h" -#include "renderer/CCRenderer.h" +#include "math/TransformUtils.h" + #include "deprecated/CCString.h" #if CC_USE_PHYSICS @@ -534,7 +534,7 @@ bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h) updateColor(); setContentSize(Size(w, h)); - setGLProgram(GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP)); + setGLProgramState(GLProgramState::getWithGLProgramName(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP)); return true; } return false; diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 268995e87d..3622946209 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -647,7 +647,7 @@ void Node::setGLProgram(GLProgram *glProgram) if (_glProgramState == nullptr || (_glProgramState && _glProgramState->getGLProgram() != glProgram)) { CC_SAFE_RELEASE(_glProgramState); - _glProgramState = GLProgramState::create(glProgram); + _glProgramState = GLProgramState::get(glProgram); _glProgramState->retain(); } } diff --git a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 8deebd8368..ab367dc7d2 100644 --- a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -770,7 +770,7 @@ void RawStencilBufferTest4::setupStencilForClippingOnPlane(GLint plane) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, _alphaThreshold); #else - auto program = GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); + auto program = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->use(); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); @@ -803,7 +803,7 @@ void RawStencilBufferTest5::setupStencilForClippingOnPlane(GLint plane) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, _alphaThreshold); #else - auto program = GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); + auto program = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->use(); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); @@ -869,7 +869,7 @@ void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, _alphaThreshold); #else - auto program = GLProgramCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); + auto program = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->use(); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); From b80a1e7c3c1767751bcbd0b6f8643f39e7dfe176 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 9 May 2014 21:31:15 -0700 Subject: [PATCH 088/174] roll back submodule changes --- tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 4dbfa174de..7876808788 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 4dbfa174debb2e98422510d7e0490b1ddb2a0b3d +Subproject commit 7876808788c0666d5f4510ea214e97e10eeaa9a8 From cb3bd52d9a83d9619f1408f23e1ce0a8ee48dad3 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 9 May 2014 21:34:59 -0700 Subject: [PATCH 089/174] remove unused shadertest --- .../Classes/ShaderTest/ShaderTest2.cpp | 39 ------------------- .../Classes/ShaderTest/ShaderTest2.h | 23 ----------- 2 files changed, 62 deletions(-) diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 9d0ca4c730..3f7d645df7 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -32,7 +32,6 @@ namespace ShaderTest2 { static std::function createFunctions[] = { - CL(AttribShaderTest), CL(NormalSpriteTest), CL(GreyScaleSpriteTest), CL(BlurSpriteTest), @@ -42,10 +41,6 @@ namespace ShaderTest2 CL(CelShadingSpriteTest), CL(LensFlareSpriteTest), CL(OutlineShadingSpriteTest), - CL(UniformShaderTest), - - CL(UniformAttribShaderTest) - }; static unsigned int TEST_CASE_COUNT = sizeof(ShaderTest2::createFunctions) / sizeof(ShaderTest2::createFunctions[0]); @@ -698,21 +693,6 @@ void UniformSprite::onDraw(const Matrix &transform, bool transformUpdated) CHECK_GL_ERROR_DEBUG(); } - -UniformShaderTest::UniformShaderTest() -{ - if (ShaderTestDemo2::init()) { - auto s = Director::getInstance()->getWinSize(); - UniformSprite* sprite = UniformSprite::create(); - setContentSize(Size(256, 256)); - setAnchorPoint(Vector2(0.5f, 0.5f)); - sprite->initShader(); - sprite->setPosition(64,64); - addChild(sprite); - } -} - - class AttribSprite : public Sprite { public: @@ -793,22 +773,3 @@ void AttribSprite::onDraw(const Matrix &transform, bool transformUpdated) CHECK_GL_ERROR_DEBUG(); } - -AttribShaderTest::AttribShaderTest() -{ - if (ShaderTestDemo2::init()) - { - auto s = Director::getInstance()->getWinSize(); - AttribSprite* sprite = AttribSprite::create(); - sprite->setTexture("Images/powered.png"); - sprite->initShader(); - sprite->setPosition(Vector2(s.width/2, s.height/2)); - addChild(sprite); - } - -} - -UniformAttribShaderTest::UniformAttribShaderTest() -{ - -} diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h index 8f57487228..4d38d755d0 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h @@ -102,28 +102,5 @@ public: virtual std::string subtitle() const {return "OutlineShadingSpriteTest";} }; -class UniformShaderTest : public ShaderTestDemo2 -{ -public: - CREATE_FUNC(UniformShaderTest); - UniformShaderTest(); - virtual std::string subtitle() const {return "UniformShaderTest";} -}; - -class AttribShaderTest : public ShaderTestDemo2 -{ -public: - CREATE_FUNC(AttribShaderTest); - AttribShaderTest(); - virtual std::string subtitle() const {return "AttribShaderTest";} -}; - -class UniformAttribShaderTest : public ShaderTestDemo2 -{ -public: - CREATE_FUNC(UniformAttribShaderTest); - UniformAttribShaderTest(); - virtual std::string subtitle() const {return "UniformAndShaderTest";} -}; #endif \ No newline at end of file From ba63befa5e5e4f67ee1cf482b678ae29ff9321fe Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 9 May 2014 21:36:35 -0700 Subject: [PATCH 090/174] roll back target=android-10 --- cocos/2d/platform/android/java/project.properties | 2 +- tests/cpp-tests/proj.android/project.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/2d/platform/android/java/project.properties b/cocos/2d/platform/android/java/project.properties index 61afc8fe54..88ca83f9d0 100644 --- a/cocos/2d/platform/android/java/project.properties +++ b/cocos/2d/platform/android/java/project.properties @@ -12,4 +12,4 @@ android.library=true # Project target. -target=android-19 +target=android-10 diff --git a/tests/cpp-tests/proj.android/project.properties b/tests/cpp-tests/proj.android/project.properties index 5a1770fd8f..16f145cfc9 100644 --- a/tests/cpp-tests/proj.android/project.properties +++ b/tests/cpp-tests/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-19 +target=android-10 android.library.reference.1=../../../cocos/2d/platform/android/java From bbac0be9a6497da3e74eb8abc9b776a38f70d672 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 9 May 2014 22:04:19 -0700 Subject: [PATCH 091/174] add deprecated alias cc.VERTEX_ATTRIB_TEX_COORDS --- cocos/scripting/lua-bindings/script/Cocos2dConstants.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua b/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua index 78027543f5..e07724a7ba 100644 --- a/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua +++ b/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua @@ -132,6 +132,8 @@ cc.VERTEX_ATTRIB_COLOR = 0x1 cc.VERTEX_ATTRIB_MAX = 0x3 cc.VERTEX_ATTRIB_POSITION = 0x0 cc.VERTEX_ATTRIB_TEX_COORD = 0x2 + +cc.VERTEX_ATTRIB_TEX_COORDS = 0x2 cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2 cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1 cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0 From 42ffd25fca35321fa38b9f396c9f93d43f7529e4 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 8 May 2014 11:10:03 +0800 Subject: [PATCH 092/174] issue #4660: Adds ConvertUTF lib and adds license (LLVM and unicode license). --- external/ConvertUTF/ConvertUTF.cpp | 587 +++++++++++++++++++++++++++++ external/ConvertUTF/ConvertUTF.h | 166 ++++++++ licenses/LICENSE_llvm.txt | 43 +++ licenses/LICENSE_unicode.txt | 80 ++++ 4 files changed, 876 insertions(+) create mode 100644 external/ConvertUTF/ConvertUTF.cpp create mode 100644 external/ConvertUTF/ConvertUTF.h create mode 100644 licenses/LICENSE_llvm.txt create mode 100644 licenses/LICENSE_unicode.txt diff --git a/external/ConvertUTF/ConvertUTF.cpp b/external/ConvertUTF/ConvertUTF.cpp new file mode 100644 index 0000000000..4a3bee4a70 --- /dev/null +++ b/external/ConvertUTF/ConvertUTF.cpp @@ -0,0 +1,587 @@ +/*===--- ConvertUTF.c - Universal Character Names conversions ---------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + *===------------------------------------------------------------------------=*/ +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Source code file. + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Sept 2001: fixed const & error conditions per + mods suggested by S. Parent & A. Lillich. + June 2002: Tim Dodd added detection and handling of incomplete + source sequences, enhanced error detection, added casts + to eliminate compiler warnings. + July 2003: slight mods to back out aggressive FFFE detection. + Jan 2004: updated switches in from-UTF8 conversions. + Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. + + See the header file "ConvertUTF.h" for complete documentation. + +------------------------------------------------------------------------ */ + + +#include "ConvertUTF.h" +#ifdef CVTUTF_DEBUG +#include +#endif +#include + +static const int halfShift = 10; /* used for shifting by 10 bits */ + +static const UTF32 halfBase = 0x0010000UL; +static const UTF32 halfMask = 0x3FFUL; + +#define UNI_SUR_HIGH_START (UTF32)0xD800 +#define UNI_SUR_HIGH_END (UTF32)0xDBFF +#define UNI_SUR_LOW_START (UTF32)0xDC00 +#define UNI_SUR_LOW_END (UTF32)0xDFFF +#define false 0 +#define true 1 + +/* --------------------------------------------------------------------- */ + +/* + * Index into the table below with the first byte of a UTF-8 sequence to + * get the number of trailing bytes that are supposed to follow it. + * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is + * left as-is for anyone who may want to do such conversion, which was + * allowed in earlier algorithms. + */ +static const char trailingBytesForUTF8[256] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 +}; + +/* + * Magic values subtracted from a buffer value during UTF8 conversion. + * This table contains as many values as there might be trailing bytes + * in a UTF-8 sequence. + */ +static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, + 0x03C82080UL, 0xFA082080UL, 0x82082080UL }; + +/* + * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed + * into the first byte, depending on how many bytes follow. There are + * as many entries in this table as there are UTF-8 sequence types. + * (I.e., one byte sequence, two byte... etc.). Remember that sequencs + * for *legal* UTF-8 will be 4 or fewer bytes total. + */ +static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + +/* --------------------------------------------------------------------- */ + +/* The interface converts a whole buffer to avoid function-call overhead. + * Constants have been gathered. Loops & conditionals have been removed as + * much as possible for efficiency, in favor of drop-through switches. + * (See "Note A" at the bottom of the file for equivalent code.) + * If your compiler supports it, the "isLegalUTF8" call can be turned + * into an inline function. + */ + + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF32toUTF16 ( + const UTF32** sourceStart, const UTF32* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF32* source = *sourceStart; + UTF16* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + if (target >= targetEnd) { + result = targetExhausted; break; + } + ch = *source++; + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_LEGAL_UTF32) { + if (flags == strictConversion) { + result = sourceIllegal; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + --source; /* Back up source pointer! */ + result = targetExhausted; break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF16toUTF32 ( + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16* source = *sourceStart; + UTF32* target = *targetStart; + UTF32 ch, ch2; + while (source < sourceEnd) { + const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + if (target >= targetEnd) { + source = oldSource; /* Back up source pointer! */ + result = targetExhausted; break; + } + *target++ = ch; + } + *sourceStart = source; + *targetStart = target; +#ifdef CVTUTF_DEBUG +if (result == sourceIllegal) { + fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); + fflush(stderr); +} +#endif + return result; +} +ConversionResult ConvertUTF16toUTF8 ( + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16* source = *sourceStart; + UTF8* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { + /* If the 16 bits following the high surrogate are in the source buffer... */ + if (source < sourceEnd) { + UTF32 ch2 = *source; + /* If it's a low surrogate, convert to UTF32. */ + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else { /* We don't have the 16 bits following the high surrogate. */ + --source; /* return to the high surrogate */ + result = sourceExhausted; + break; + } + } else if (flags == strictConversion) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* Figure out how many bytes the result will require */ + if (ch < (UTF32)0x80) { bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { bytesToWrite = 3; + } else if (ch < (UTF32)0x110000) { bytesToWrite = 4; + } else { bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + } + + target += bytesToWrite; + if (target > targetEnd) { + source = oldSource; /* Back up source pointer! */ + target -= bytesToWrite; result = targetExhausted; break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF32toUTF8 ( + const UTF32** sourceStart, const UTF32* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF32* source = *sourceStart; + UTF8* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + ch = *source++; + if (flags == strictConversion ) { + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* + * Figure out how many bytes the result will require. Turn any + * illegally large UTF32 things (> Plane 17) into replacement chars. + */ + if (ch < (UTF32)0x80) { bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { bytesToWrite = 3; + } else if (ch <= UNI_MAX_LEGAL_UTF32) { bytesToWrite = 4; + } else { bytesToWrite = 3; + ch = UNI_REPLACEMENT_CHAR; + result = sourceIllegal; + } + + target += bytesToWrite; + if (target > targetEnd) { + --source; /* Back up source pointer! */ + target -= bytesToWrite; result = targetExhausted; break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6; + case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +/* + * Utility routine to tell whether a sequence of bytes is legal UTF-8. + * This must be called with the length pre-determined by the first byte. + * If not calling this from ConvertUTF8to*, then the length can be set by: + * length = trailingBytesForUTF8[*source]+1; + * and the sequence is illegal right away if there aren't that many bytes + * available. + * If presented with a length > 4, this returns false. The Unicode + * definition of UTF-8 goes up to 4-byte sequences. + */ + +static Boolean isLegalUTF8(const UTF8 *source, int length) { + UTF8 a; + const UTF8 *srcptr = source+length; + switch (length) { + default: return false; + /* Everything else falls through when "true"... */ + case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 2: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + + switch (*source) { + /* no fall-through in this inner switch */ + case 0xE0: if (a < 0xA0) return false; break; + case 0xED: if (a > 0x9F) return false; break; + case 0xF0: if (a < 0x90) return false; break; + case 0xF4: if (a > 0x8F) return false; break; + default: if (a < 0x80) return false; + } + + case 1: if (*source >= 0x80 && *source < 0xC2) return false; + } + if (*source > 0xF4) return false; + return true; +} + +/* --------------------------------------------------------------------- */ + +/* + * Exported function to return whether a UTF-8 sequence is legal or not. + * This is not used here; it's just exported. + */ +Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { + int length = trailingBytesForUTF8[*source]+1; + if (length > sourceEnd - source) { + return false; + } + return isLegalUTF8(source, length); +} + +/* --------------------------------------------------------------------- */ + +/* + * Exported function to return the total number of bytes in a codepoint + * represented in UTF-8, given the value of the first byte. + */ +unsigned getNumBytesForUTF8(UTF8 first) { + return trailingBytesForUTF8[first] + 1; +} + +/* --------------------------------------------------------------------- */ + +/* + * Exported function to return whether a UTF-8 string is legal or not. + * This is not used here; it's just exported. + */ +Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd) { + while (*source != sourceEnd) { + int length = trailingBytesForUTF8[**source] + 1; + if (length > sourceEnd - *source || !isLegalUTF8(*source, length)) + return false; + *source += length; + } + return true; +} + +int getUTF8StringLength(const UTF8* utf8) +{ + const UTF8** source = &utf8; + const UTF8* sourceEnd = utf8 + strlen((char*)utf8); + int ret = 0; + while (*source != sourceEnd) { + int length = trailingBytesForUTF8[**source] + 1; + if (length > sourceEnd - *source || !isLegalUTF8(*source, length)) + return 0; + *source += length; + ++ret; + } + return ret; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF8toUTF16 ( + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8* source = *sourceStart; + UTF16* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (extraBytesToRead >= sourceEnd - source) { + result = sourceExhausted; break; + } + /* Do this check whether lenient or strict */ + if (!isLegalUTF8(source, extraBytesToRead+1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ + case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ + case 3: ch += *source++; ch <<= 6; + case 2: ch += *source++; ch <<= 6; + case 1: ch += *source++; ch <<= 6; + case 0: ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + source -= (extraBytesToRead+1); /* Back up source pointer! */ + result = targetExhausted; break; + } + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead+1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = (UTF16)ch; /* normal case */ + } + } else if (ch > UNI_MAX_UTF16) { + if (flags == strictConversion) { + result = sourceIllegal; + source -= (extraBytesToRead+1); /* return to the start */ + break; /* Bail out; shouldn't continue */ + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + source -= (extraBytesToRead+1); /* Back up source pointer! */ + result = targetExhausted; break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF8toUTF32 ( + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8* source = *sourceStart; + UTF32* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (extraBytesToRead >= sourceEnd - source) { + result = sourceExhausted; break; + } + /* Do this check whether lenient or strict */ + if (!isLegalUTF8(source, extraBytesToRead+1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: ch += *source++; ch <<= 6; + case 4: ch += *source++; ch <<= 6; + case 3: ch += *source++; ch <<= 6; + case 2: ch += *source++; ch <<= 6; + case 1: ch += *source++; ch <<= 6; + case 0: ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + source -= (extraBytesToRead+1); /* Back up the source pointer! */ + result = targetExhausted; break; + } + if (ch <= UNI_MAX_LEGAL_UTF32) { + /* + * UTF-16 surrogate values are illegal in UTF-32, and anything + * over Plane 17 (> 0x10FFFF) is illegal. + */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead+1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + *target++ = ch; + } + } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */ + result = sourceIllegal; + *target++ = UNI_REPLACEMENT_CHAR; + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- + + Note A. + The fall-through switches in UTF-8 reading code save a + temp variable, some decrements & conditionals. The switches + are equivalent to the following loop: + { + int tmpBytesToRead = extraBytesToRead+1; + do { + ch += *source++; + --tmpBytesToRead; + if (tmpBytesToRead) ch <<= 6; + } while (tmpBytesToRead > 0); + } + In UTF-8 writing code, the switches on "bytesToWrite" are + similarly unrolled loops. + + --------------------------------------------------------------------- */ diff --git a/external/ConvertUTF/ConvertUTF.h b/external/ConvertUTF/ConvertUTF.h new file mode 100644 index 0000000000..2535a8ac9d --- /dev/null +++ b/external/ConvertUTF/ConvertUTF.h @@ -0,0 +1,166 @@ +/*===--- ConvertUTF.h - Universal Character Names conversions ---------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + *==------------------------------------------------------------------------==*/ +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Header file. + + Several funtions are included here, forming a complete set of + conversions between the three formats. UTF-7 is not included + here, but is handled in a separate source file. + + Each of these routines takes pointers to input buffers and output + buffers. The input buffers are const. + + Each routine converts the text between *sourceStart and sourceEnd, + putting the result into the buffer between *targetStart and + targetEnd. Note: the end pointers are *after* the last item: e.g. + *(sourceEnd - 1) is the last item. + + The return result indicates whether the conversion was successful, + and if not, whether the problem was in the source or target buffers. + (Only the first encountered problem is indicated.) + + After the conversion, *sourceStart and *targetStart are both + updated to point to the end of last text successfully converted in + the respective buffers. + + Input parameters: + sourceStart - pointer to a pointer to the source buffer. + The contents of this are modified on return so that + it points at the next thing to be converted. + targetStart - similarly, pointer to pointer to the target buffer. + sourceEnd, targetEnd - respectively pointers to the ends of the + two buffers, for overflow checking only. + + These conversion functions take a ConversionFlags argument. When this + flag is set to strict, both irregular sequences and isolated surrogates + will cause an error. When the flag is set to lenient, both irregular + sequences and isolated surrogates are converted. + + Whether the flag is strict or lenient, all illegal sequences will cause + an error return. This includes sequences such as: , , + or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code + must check for illegal sequences. + + When the flag is set to lenient, characters over 0x10FFFF are converted + to the replacement character; otherwise (when the flag is set to strict) + they constitute an error. + + Output parameters: + The value "sourceIllegal" is returned from some routines if the input + sequence is malformed. When "sourceIllegal" is returned, the source + value will point to the illegal value that caused the problem. E.g., + in UTF-8 when a sequence is malformed, it points to the start of the + malformed sequence. + + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Fixes & updates, Sept 2001. + +------------------------------------------------------------------------ */ + +#ifndef CC_LLVM_SUPPORT_CONVERTUTF_H +#define CC_LLVM_SUPPORT_CONVERTUTF_H + +/* --------------------------------------------------------------------- + The following 4 definitions are compiler-specific. + The C standard does not guarantee that char16_t has at least + 16 bits, so char16_t is no less portable than unsigned short! + All should be unsigned values to avoid sign extension during + bit mask & shift operations. +------------------------------------------------------------------------ */ + +typedef unsigned int UTF32; /* at least 32 bits */ +typedef unsigned short UTF16; /* at least 16 bits */ +typedef unsigned char UTF8; /* typically 8 bits */ +typedef unsigned char Boolean; /* 0 or 1 */ + +/* Some fundamental constants */ +#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD +#define UNI_MAX_BMP (UTF32)0x0000FFFF +#define UNI_MAX_UTF16 (UTF32)0x0010FFFF +#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF +#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF + +#define UNI_MAX_UTF8_BYTES_PER_CODE_POINT 4 + +#define UNI_UTF16_BYTE_ORDER_MARK_NATIVE 0xFEFF +#define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED 0xFFFE + +typedef enum { + conversionOK, /* conversion successful */ + sourceExhausted, /* partial character in source, but hit end */ + targetExhausted, /* insuff. room in target for conversion */ + sourceIllegal /* source sequence is illegal/malformed */ +} ConversionResult; + +typedef enum { + strictConversion = 0, + lenientConversion +} ConversionFlags; + + +ConversionResult ConvertUTF8toUTF16 ( + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF8toUTF32 ( + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF16toUTF8 ( + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF32toUTF8 ( + const UTF32** sourceStart, const UTF32* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF16toUTF32 ( + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF32toUTF16 ( + const UTF32** sourceStart, const UTF32* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); + +Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); + +Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd); + +unsigned getNumBytesForUTF8(UTF8 firstByte); + +int getUTF8StringLength(const UTF8* utf8); + + +/* --------------------------------------------------------------------- */ + +#endif // CC_LLVM_SUPPORT_CONVERTUTF_H diff --git a/licenses/LICENSE_llvm.txt b/licenses/LICENSE_llvm.txt new file mode 100644 index 0000000000..78bf75e2e6 --- /dev/null +++ b/licenses/LICENSE_llvm.txt @@ -0,0 +1,43 @@ +============================================================================== +LLVM Release License +============================================================================== +University of Illinois/NCSA +Open Source License + +Copyright (c) 2003-2013 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.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 with +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: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +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 +CONTRIBUTORS 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 WITH THE +SOFTWARE. \ No newline at end of file diff --git a/licenses/LICENSE_unicode.txt b/licenses/LICENSE_unicode.txt new file mode 100644 index 0000000000..7c8ea59a64 --- /dev/null +++ b/licenses/LICENSE_unicode.txt @@ -0,0 +1,80 @@ +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Header file. + + Several funtions are included here, forming a complete set of + conversions between the three formats. UTF-7 is not included + here, but is handled in a separate source file. + + Each of these routines takes pointers to input buffers and output + buffers. The input buffers are const. + + Each routine converts the text between *sourceStart and sourceEnd, + putting the result into the buffer between *targetStart and + targetEnd. Note: the end pointers are *after* the last item: e.g. + *(sourceEnd - 1) is the last item. + + The return result indicates whether the conversion was successful, + and if not, whether the problem was in the source or target buffers. + (Only the first encountered problem is indicated.) + + After the conversion, *sourceStart and *targetStart are both + updated to point to the end of last text successfully converted in + the respective buffers. + + Input parameters: + sourceStart - pointer to a pointer to the source buffer. + The contents of this are modified on return so that + it points at the next thing to be converted. + targetStart - similarly, pointer to pointer to the target buffer. + sourceEnd, targetEnd - respectively pointers to the ends of the + two buffers, for overflow checking only. + + These conversion functions take a ConversionFlags argument. When this + flag is set to strict, both irregular sequences and isolated surrogates + will cause an error. When the flag is set to lenient, both irregular + sequences and isolated surrogates are converted. + + Whether the flag is strict or lenient, all illegal sequences will cause + an error return. This includes sequences such as: , , + or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code + must check for illegal sequences. + + When the flag is set to lenient, characters over 0x10FFFF are converted + to the replacement character; otherwise (when the flag is set to strict) + they constitute an error. + + Output parameters: + The value "sourceIllegal" is returned from some routines if the input + sequence is malformed. When "sourceIllegal" is returned, the source + value will point to the illegal value that caused the problem. E.g., + in UTF-8 when a sequence is malformed, it points to the start of the + malformed sequence. + + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Fixes & updates, Sept 2001. + +------------------------------------------------------------------------ */ \ No newline at end of file From 20a8808b78563dd9d7290c6f6cd90b2399c5744b Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 8 May 2014 11:10:54 +0800 Subject: [PATCH 093/174] issue #4660: Refactors utf8 api, make it safer and easier to use. --- cocos/2d/ccUTF8.cpp | 602 +++++++++++++++----------------------------- cocos/2d/ccUTF8.h | 153 ++++++++--- 2 files changed, 321 insertions(+), 434 deletions(-) diff --git a/cocos/2d/ccUTF8.cpp b/cocos/2d/ccUTF8.cpp index 336314e696..98aa52e6b3 100644 --- a/cocos/2d/ccUTF8.cpp +++ b/cocos/2d/ccUTF8.cpp @@ -1,127 +1,36 @@ -/* - * This file uses some implementations of gutf8.c in glib. - * - * gutf8.c - Operations on UTF-8 strings. - * - * Copyright (C) 1999 Tom Tromey - * Copyright (C) 2000 Red Hat, Inc. - * Copyright (c) 2013-2014 Chukong Technologies Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ +/**************************************************************************** + Copyright (c) 2014 cocos2d-x.org + Copyright (c) 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. + ****************************************************************************/ #include "ccUTF8.h" #include "2d/platform/CCCommon.h" #include "base/CCConsole.h" +#include "ConvertUTF.h" NS_CC_BEGIN -int cc_wcslen(const unsigned short* str) -{ - int i=0; - while(*str++) i++; - return i; -} - -/* Code from GLIB gutf8.c starts here. */ - -#define UTF8_COMPUTE(Char, Mask, Len) \ -if (Char < 128) \ -{ \ -Len = 1; \ -Mask = 0x7f; \ -} \ -else if ((Char & 0xe0) == 0xc0) \ -{ \ -Len = 2; \ -Mask = 0x1f; \ -} \ -else if ((Char & 0xf0) == 0xe0) \ -{ \ -Len = 3; \ -Mask = 0x0f; \ -} \ -else if ((Char & 0xf8) == 0xf0) \ -{ \ -Len = 4; \ -Mask = 0x07; \ -} \ -else if ((Char & 0xfc) == 0xf8) \ -{ \ -Len = 5; \ -Mask = 0x03; \ -} \ -else if ((Char & 0xfe) == 0xfc) \ -{ \ -Len = 6; \ -Mask = 0x01; \ -} \ -else \ -Len = -1; - -#define UTF8_LENGTH(Char) \ -((Char) < 0x80 ? 1 : \ -((Char) < 0x800 ? 2 : \ -((Char) < 0x10000 ? 3 : \ -((Char) < 0x200000 ? 4 : \ -((Char) < 0x4000000 ? 5 : 6))))) - - -#define UTF8_GET(Result, Chars, Count, Mask, Len) \ -(Result) = (Chars)[0] & (Mask); \ -for ((Count) = 1; (Count) < (Len); ++(Count)) \ -{ \ -if (((Chars)[(Count)] & 0xc0) != 0x80) \ -{ \ -(Result) = -1; \ -break; \ -} \ -(Result) <<= 6; \ -(Result) |= ((Chars)[(Count)] & 0x3f); \ -} - -#define UNICODE_VALID(Char) \ -((Char) < 0x110000 && \ -(((Char) & 0xFFFFF800) != 0xD800) && \ -((Char) < 0xFDD0 || (Char) > 0xFDEF) && \ -((Char) & 0xFFFE) != 0xFFFE) - - -static const char utf8_skip_data[256] = { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, - 5, 5, 5, 6, 6, 1, 1 -}; - -static const char *const g_utf8_skip = utf8_skip_data; - -#define cc_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(unsigned char *)(p)]) +namespace StringUtils { /* * @str: the string to search through. @@ -129,14 +38,14 @@ static const char *const g_utf8_skip = utf8_skip_data; * * Return value: the index of the last character that is not c. * */ -unsigned int cc_utf8_find_last_not_char(std::vector str, unsigned short c) +unsigned int getIndexOfLastNotChar16(const std::vector& str, char16_t c) { int len = static_cast(str.size()); - + int i = len - 1; for (; i >= 0; --i) if (str[i] != c) return i; - + return i; } @@ -148,13 +57,13 @@ unsigned int cc_utf8_find_last_not_char(std::vector str, unsigne * * Return value: the trimmed string. * */ -static void cc_utf8_trim_from(std::vector* str, int index) +static void trimUTF16VectorFromIndex(std::vector& str, int index) { - int size = static_cast(str->size()); + int size = static_cast(str.size()); if (index >= size || index < 0) return; - - str->erase(str->begin() + index, str->begin() + size); + + str.erase(str.begin() + index, str.begin() + size); } /* @@ -164,14 +73,14 @@ static void cc_utf8_trim_from(std::vector* str, int index) * * Return value: weather the character is a whitespace character. * */ -bool isspace_unicode(unsigned short ch) +bool isUnicodeSpace(char16_t ch) { return (ch >= 0x0009 && ch <= 0x000D) || ch == 0x0020 || ch == 0x0085 || ch == 0x00A0 || ch == 0x1680 || (ch >= 0x2000 && ch <= 0x200A) || ch == 0x2028 || ch == 0x2029 || ch == 0x202F || ch == 0x205F || ch == 0x3000; } -bool iscjk_unicode(unsigned short ch) +bool isCJKUnicode(char16_t ch) { return (ch >= 0x4E00 && ch <= 0x9FBF) // CJK Unified Ideographs || (ch >= 0x2E80 && ch <= 0x2FDF) // CJK Radicals Supplement & Kangxi Radicals @@ -183,131 +92,165 @@ bool iscjk_unicode(unsigned short ch) || (ch >= 0x31C0 && ch <= 0x4DFF); // Other exiensions } -void cc_utf8_trim_ws(std::vector* str) +void trimUTF16Vector(std::vector& str) { - int len = static_cast(str->size()); - + int len = static_cast(str.size()); + if ( len <= 0 ) return; - + int last_index = len - 1; - + // Only start trimming if the last character is whitespace.. - if (isspace_unicode((*str)[last_index])) + if (isUnicodeSpace(str[last_index])) { for (int i = last_index - 1; i >= 0; --i) { - if (isspace_unicode((*str)[i])) + if (isUnicodeSpace(str[i])) last_index = i; else break; } - - cc_utf8_trim_from(str, last_index); + + trimUTF16VectorFromIndex(str, last_index); } } -/* - * cc_utf8_strlen: - * @p: pointer to the start of a UTF-8 encoded string. - * @max: the maximum number of bytes to examine. If @max - * is less than 0, then the string is assumed to be - * null-terminated. If @max is 0, @p will not be examined and - * may be %nullptr. - * - * Returns the length of the string in characters. - * - * Return value: the length of the string in characters - **/ -long -cc_utf8_strlen (const char * p, int max) +bool UTF8ToUTF16(const std::string& utf8, std::u16string& outUtf16) { - long len = 0; - const char *start = p; - - if (!(p != nullptr || max == 0)) + if (utf8.empty()) { - return 0; + outUtf16.clear(); + return true; } - - if (max < 0) + + bool ret = false; + const size_t utf16Bytes = (utf8.length()+1) << 1; + char16_t* utf16 = (char16_t*)malloc(utf16Bytes); + memset(utf16, 0, utf16Bytes); + + UTF16* utf16Start = (UTF16*)utf16; + UTF16* utf16End = ((UTF16*)utf16) + (utf8.length()); + + const UTF8* utf8Start = (const UTF8*)utf8.data(); + const UTF8* utf8End = ((const UTF8*)utf8.data()) + utf8.length(); + + if (conversionOK == ConvertUTF8toUTF16((const UTF8 **) &utf8Start, utf8End, &utf16Start, utf16End, strictConversion)) { - while (*p) - { - p = cc_utf8_next_char (p); - ++len; - } + outUtf16 = utf16; + ret = true; } - else - { - if (max == 0 || !*p) - return 0; - - p = cc_utf8_next_char (p); - - while (p - start < max && *p) - { - ++len; - p = cc_utf8_next_char (p); - } - - /* only do the last len increment if we got a complete - * char (don't count partial chars) - */ - if (p - start == max) - ++len; - } - - return len; + + free(utf16); + + return ret; } -/* - * g_utf8_get_char: - * @p: a pointer to Unicode character encoded as UTF-8 - * - * Converts a sequence of bytes encoded as UTF-8 to a Unicode character. - * If @p does not point to a valid UTF-8 encoded character, results are - * undefined. If you are not sure that the bytes are complete - * valid Unicode characters, you should use g_utf8_get_char_validated() - * instead. - * - * Return value: the resulting character - **/ -static unsigned int -cc_utf8_get_char (const char * p) +bool UTF16ToUTF8(const std::u16string& utf16, std::string& outUtf8) { - int i, mask = 0, len; - unsigned int result; - unsigned char c = (unsigned char) *p; - - UTF8_COMPUTE (c, mask, len); - if (len == -1) - return (unsigned int) - 1; - UTF8_GET (result, p, i, mask, len); - - return result; + if (utf16.empty()) + { + outUtf8.clear(); + return true; + } + + bool ret = false; + const size_t utf8Bytes = (utf16.length() << 2) + 1; + char* utf8 = (char*)malloc(utf8Bytes); + memset(utf8, 0, utf8Bytes); + + UTF8 *utf8Start = (UTF8*)utf8; + UTF8 *utf8End = ((UTF8*)utf8) + (utf8Bytes -1); + + const UTF16* utf16Start = (const UTF16*)utf16.data(); + const UTF16* utf16End = ((const UTF16*)utf16.data()) + utf16.length(); + + if (conversionOK == ConvertUTF16toUTF8(&utf16Start, utf16End, &utf8Start, utf8End, strictConversion)) + { + outUtf8 = utf8; + ret = true; + } + + free(utf8); + + return ret; } - -unsigned short* cc_utf8_to_utf16(const char* str_old, int length/* = -1 */, int* rUtf16Size/* = nullptr */) +std::vector getUTF16VectorFromUTF16String(const std::u16string& str) { - long len = cc_utf8_strlen(str_old, length); - if (rUtf16Size != nullptr) { - *rUtf16Size = static_cast(len); - } - - unsigned short* str_new = new unsigned short[len + 1]; - str_new[len] = 0; - - for (int i = 0; i < len; ++i) + std::vector str_new; + + size_t len = str.length(); + for (size_t i = 0; i < len; ++i) { - str_new[i] = cc_utf8_get_char(str_old); - str_old = cc_utf8_next_char(str_old); + str_new.push_back(str[i]); } - return str_new; } +std::vector getChar16VectorFromUTF16String(const std::u16string& utf16) +{ + std::vector ret; + size_t len = utf16.length(); + ret.reserve(len); + for (size_t i = 0; i < len; ++i) + { + ret.push_back(utf16[i]); + } + return ret; +} + +long getCharacterCountInUTF8String(const std::string& utf8) +{ + return getUTF8StringLength((const UTF8*)utf8.c_str()); +} + +} //namespace StringUtils { + + +int cc_wcslen(const unsigned short* str) +{ + int i=0; + while(*str++) i++; + return i; +} + +void cc_utf8_trim_ws(std::vector* str) +{ + // unsigned short and char16_t are both 2 bytes + std::vector* ret = reinterpret_cast*>(str); + StringUtils::trimUTF16Vector(*ret); +} + +bool isspace_unicode(unsigned short ch) +{ + return StringUtils::isUnicodeSpace(ch); +} + + +bool iscjk_unicode(unsigned short ch) +{ + return StringUtils::isCJKUnicode(ch); +} + + +long cc_utf8_strlen (const char * p, int max) +{ + CC_UNUSED_PARAM(max); + return StringUtils::getCharacterCountInUTF8String(p); +} + +unsigned int cc_utf8_find_last_not_char(const std::vector& str, unsigned short c) +{ + std::vector char16Vector; + for (const auto& e : str) + { + char16Vector.push_back(e); + } + + return StringUtils::getIndexOfLastNotChar16(char16Vector, c); +} + std::vector cc_utf16_vec_from_utf16_str(const unsigned short* str) { int len = cc_wcslen(str); @@ -320,209 +263,56 @@ std::vector cc_utf16_vec_from_utf16_str(const unsigned short* st return str_new; } -/** - * cc_unichar_to_utf8: - * @c: a ISO10646 character code - * @outbuf: output buffer, must have at least 6 bytes of space. - * If %nullptr, the length will be computed and returned - * and nothing will be written to @outbuf. - * - * Converts a single character to UTF-8. - * - * Return value: number of bytes written - **/ -int -cc_unichar_to_utf8 (unsigned int c, - char *outbuf) +unsigned short* cc_utf8_to_utf16(const char* str_old, int length/* = -1*/, int* rUtf16Size/* = nullptr*/) { - int len = 0; - int first; - int i; + if (str_old == nullptr) + return nullptr; - if (c < 0x80) + unsigned short* ret = nullptr; + + std::u16string outUtf16; + bool succeed = StringUtils::UTF8ToUTF16(str_old, outUtf16); + + if (succeed) { - first = 0; - len = 1; - } - else if (c < 0x800) - { - first = 0xc0; - len = 2; - } - else if (c < 0x10000) - { - first = 0xe0; - len = 3; - } - else if (c < 0x200000) - { - first = 0xf0; - len = 4; - } - else if (c < 0x4000000) - { - first = 0xf8; - len = 5; - } - else - { - first = 0xfc; - len = 6; + ret = new unsigned short[outUtf16.length() + 1]; + ret[outUtf16.length()] = 0; + memcpy(ret, outUtf16.data(), outUtf16.length()); } - if (outbuf) - { - for (i = len - 1; i > 0; --i) - { - outbuf[i] = (c & 0x3f) | 0x80; - c >>= 6; - } - outbuf[0] = c | first; - } - - return len; + return ret; } -#define SURROGATE_VALUE(h,l) (((h) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000) - -/** - * cc_utf16_to_utf8: - * @str: a UTF-16 encoded string - * @len: the maximum length of @str to use. If @len < 0, then - * the string is terminated with a 0 character. - * @items_read: location to store number of words read, or %nullptr. - * If %nullptr, then %G_CONVERT_ERROR_PARTIAL_INPUT will be - * returned in case @str contains a trailing partial - * character. If an error occurs then the index of the - * invalid input is stored here. - * @items_written: location to store number of bytes written, or %nullptr. - * The value stored here does not include the trailing - * 0 byte. - * @error: location to store the error occuring, or %nullptr to ignore - * errors. Any of the errors in #GConvertError other than - * %G_CONVERT_ERROR_NO_CONVERSION may occur. - * - * Convert a string from UTF-16 to UTF-8. The result will be - * terminated with a 0 byte. - * - * Return value: a pointer to a newly allocated UTF-8 string. - * This value must be freed with free(). If an - * error occurs, %nullptr will be returned and - * @error set. - **/ -char * -cc_utf16_to_utf8 (const unsigned short *str, - int len, - long *items_read, - long *items_written) +char * cc_utf16_to_utf8 (const unsigned short *str, + int len, + long *items_read, + long *items_written) { - /* This function and g_utf16_to_ucs4 are almost exactly identical - The lines that differ - * are marked. - */ - const unsigned short *in; - char *out; - char *result = nullptr; - int n_bytes; - unsigned int high_surrogate; + if (str == nullptr) + return nullptr; - if (str == 0) return nullptr; - n_bytes = 0; - in = str; - high_surrogate = 0; - while ((len < 0 || in - str < len) && *in) + std::u16string utf16; + int utf16Len = len < 0 ? cc_wcslen(str) : len; + + for (int i = 0; i < utf16Len; ++i) { - unsigned short c = *in; - unsigned int wc; - - if (c >= 0xdc00 && c < 0xe000) /* low surrogate */ - { - if (high_surrogate) - { - wc = SURROGATE_VALUE (high_surrogate, c); - high_surrogate = 0; - } - else - { - CCLOGERROR("Invalid sequence in conversion input"); - goto err_out; - } - } - else - { - if (high_surrogate) - { - CCLOGERROR("Invalid sequence in conversion input"); - goto err_out; - } - - if (c >= 0xd800 && c < 0xdc00) /* high surrogate */ - { - high_surrogate = c; - goto next1; - } - else - wc = c; - } - - /********** DIFFERENT for UTF8/UCS4 **********/ - n_bytes += UTF8_LENGTH (wc); - - next1: - in++; + utf16.push_back(str[i]); } - if (high_surrogate && !items_read) - { - CCLOGERROR("Partial character sequence at end of input"); - goto err_out; - } + char* ret = nullptr; + std::string outUtf8; + bool succeed = StringUtils::UTF16ToUTF8(utf16, outUtf8); - /* At this point, everything is valid, and we just need to convert - */ - /********** DIFFERENT for UTF8/UCS4 **********/ - result = new char[n_bytes + 1]; - - high_surrogate = 0; - out = result; - in = str; - while (out < result + n_bytes) + if (succeed) { - unsigned short c = *in; - unsigned int wc; - - if (c >= 0xdc00 && c < 0xe000) /* low surrogate */ - { - wc = SURROGATE_VALUE (high_surrogate, c); - high_surrogate = 0; - } - else if (c >= 0xd800 && c < 0xdc00) /* high surrogate */ - { - high_surrogate = c; - goto next2; - } - else - wc = c; - - /********** DIFFERENT for UTF8/UCS4 **********/ - out += cc_unichar_to_utf8 (wc, out); - - next2: - in++; + ret = new char[outUtf8.length() + 1]; + ret[outUtf8.length()] = '\0'; + memcpy(ret, outUtf8.data(), outUtf8.length()); } - /********** DIFFERENT for UTF8/UCS4 **********/ - *out = '\0'; - - if (items_written) - /********** DIFFERENT for UTF8/UCS4 **********/ - *items_written = out - result; - -err_out: - if (items_read) - *items_read = in - str; - - return result; + return ret; } + NS_CC_END diff --git a/cocos/2d/ccUTF8.h b/cocos/2d/ccUTF8.h index 17c5dd0cc2..91e66ce10c 100644 --- a/cocos/2d/ccUTF8.h +++ b/cocos/2d/ccUTF8.h @@ -1,35 +1,131 @@ -/* - * Copyright (C) 1999 Tom Tromey - * Copyright (C) 2000 Red Hat, Inc. - * Copyright (c) 2013-2014 Chukong Technologies Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ +/**************************************************************************** + Copyright (c) 2014 cocos2d-x.org + Copyright (c) 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 __cocos2dx__ccUTF8__ #define __cocos2dx__ccUTF8__ #include "base/CCPlatformMacros.h" #include +#include NS_CC_BEGIN +namespace StringUtils { + +/** + * @brief Converts utf8 string to utf16 string + * @param utf8 The utf8 string to be converted + * @param outUtf16 The output utf16 string + * @return true if succeed, otherwise false + * @note Please check the return value before using \p outUtf16 + * e.g. + * @code + * std::u16string utf16; + * bool ret = StringUtils::UTF8ToUTF16("你好hello", utf16); + * if (ret) { + * do_some_thing_with_utf16(utf16); + * } + * @endcode + */ +CC_DLL bool UTF8ToUTF16(const std::string& utf8, std::u16string& outUtf16); + +/** + * @brief Converts utf16 string to utf8 string + * @param utf16 The utf16 string to be converted + * @param outUtf8 The output utf8 string + * @return true if succeed, otherwise false + * @note Please check the return value before using \p outUtf8 + * e.g. + * @code + * std::string utf8; + * bool ret = StringUtils::UTF16ToUTF8(u"\u4f60\u597d", utf16); + * if (ret) { + * do_some_thing_with_utf8(utf8); + * } + * @endcode + */ +CC_DLL bool UTF16ToUTF8(const std::u16string& utf16, std::string& outUtf8); + +/** + * @brief Trims the unicode spaces at the end of char16_t vector + */ +CC_DLL void trimUTF16Vector(std::vector& str); + +/** + * @brief Whether the character is a whitespace character. + * + * @param ch the unicode character + * @returns whether the character is a white space character. + * + * @see http://en.wikipedia.org/wiki/Whitespace_character#Unicode + * + */ +CC_DLL bool isUnicodeSpace(char16_t ch); + +/** + * @brief Whether the character is a Chinese/Japanese/Korean character. + * + * @param ch the unicode character + * @returns whether the character is a Chinese character. + * + * @see http://www.searchtb.com/2012/04/chinese_encode.html + * @see http://tieba.baidu.com/p/748765987 + * + */ +CC_DLL bool isCJKUnicode(char16_t ch); + +/** + * @brief Returns the length of the string in characters. + * + * @param utf8 an UTF-8 encoded string. + * @returns the length of the string in characters + */ +CC_DLL long getCharacterCountInUTF8String(const std::string& utf8); + +/** + * @brief Gets the index of the last character that is not equal to the character given. + * + * @param str the string to be searched. + * @param c the character to be searched for. + * + * @returns the index of the last character that is not \p c. + * + */ +CC_DLL unsigned int getIndexOfLastNotChar16(const std::vector& str, char16_t c); + +/** + * @brief Gets char16_t vector from a given utf16 string + */ +CC_DLL std::vector getChar16VectorFromUTF16String(const std::u16string& utf16); + +} // namespace StringUtils { + + CC_DLL int cc_wcslen(const unsigned short* str); -CC_DLL void cc_utf8_trim_ws(std::vector* str); +CC_DEPRECATED_ATTRIBUTE void cc_utf8_trim_ws(std::vector* str); /** * Whether the character is a whitespace character. @@ -39,7 +135,7 @@ CC_DLL void cc_utf8_trim_ws(std::vector* str); * * @see http://en.wikipedia.org/wiki/Whitespace_character#Unicode * */ -CC_DLL bool isspace_unicode(unsigned short ch); +CC_DEPRECATED_ATTRIBUTE bool isspace_unicode(unsigned short ch); /** * Whether the character is a Chinese/Japanese/Korean character. @@ -50,7 +146,7 @@ CC_DLL bool isspace_unicode(unsigned short ch); * @see http://www.searchtb.com/2012/04/chinese_encode.html * @see http://tieba.baidu.com/p/748765987 * */ -CC_DLL bool iscjk_unicode(unsigned short ch); +CC_DEPRECATED_ATTRIBUTE bool iscjk_unicode(unsigned short ch); /** * Returns the length of the string in characters. @@ -62,7 +158,7 @@ CC_DLL bool iscjk_unicode(unsigned short ch); * * @returns the length of the string in characters **/ -CC_DLL long +CC_DEPRECATED_ATTRIBUTE long cc_utf8_strlen (const char * p, int max); /** @@ -73,9 +169,9 @@ cc_utf8_strlen (const char * p, int max); * * @returns the index of the last character that is not \p c. * */ -CC_DLL unsigned int cc_utf8_find_last_not_char(std::vector str, unsigned short c); +CC_DEPRECATED_ATTRIBUTE unsigned int cc_utf8_find_last_not_char(const std::vector& str, unsigned short c); -CC_DLL std::vector cc_utf16_vec_from_utf16_str(const unsigned short* str); +CC_DEPRECATED_ATTRIBUTE std::vector cc_utf16_vec_from_utf16_str(const unsigned short* str); /** * Creates a utf8 string from a cstring. @@ -84,7 +180,7 @@ CC_DLL std::vector cc_utf16_vec_from_utf16_str(const unsigned sh * * @returns the newly created utf8 string. * */ -CC_DLL unsigned short* cc_utf8_to_utf16(const char* str_old, int length = -1, int* rUtf16Size = nullptr); +CC_DEPRECATED_ATTRIBUTE unsigned short* cc_utf8_to_utf16(const char* str_old, int length = -1, int* rUtf16Size = nullptr); /** * Convert a string from UTF-16 to UTF-8. The result will be null terminated. @@ -103,12 +199,13 @@ CC_DLL unsigned short* cc_utf8_to_utf16(const char* str_old, int length = -1, in * @returns a pointer to a newly allocated UTF-8 string. This value must be * freed with free(). If an error occurs, %nullptr will be returned. **/ -CC_DLL char * +CC_DEPRECATED_ATTRIBUTE char * cc_utf16_to_utf8 (const unsigned short *str, int len, long *items_read, long *items_written); + NS_CC_END #endif /* defined(__cocos2dx__ccUTF8__) */ From 9f4d2acaeef253926a978ea6df1fb3278e8b2e3b Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 8 May 2014 11:11:38 +0800 Subject: [PATCH 094/174] issue #4660: StringUtils is a namespace now --- cocos/deprecated/CCString.cpp | 25 ++++++++++++++++++++ cocos/deprecated/CCString.h | 43 +++++++++-------------------------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/cocos/deprecated/CCString.cpp b/cocos/deprecated/CCString.cpp index 475d4f41f8..311c250bc0 100644 --- a/cocos/deprecated/CCString.cpp +++ b/cocos/deprecated/CCString.cpp @@ -272,4 +272,29 @@ __String* __String::clone() const return __String::create(_string); } +namespace StringUtils { + +std::string format(const char* format, ...) +{ +#define CC_MAX_STRING_LENGTH (1024*100) + + std::string ret; + + va_list ap; + va_start(ap, format); + + char* buf = (char*)malloc(CC_MAX_STRING_LENGTH); + if (buf != nullptr) + { + vsnprintf(buf, CC_MAX_STRING_LENGTH, format, ap); + ret = buf; + free(buf); + } + va_end(ap); + + return ret; +} + +} // namespace StringUtils { + NS_CC_END diff --git a/cocos/deprecated/CCString.h b/cocos/deprecated/CCString.h index f4cd92b866..0bf66dcf8e 100644 --- a/cocos/deprecated/CCString.h +++ b/cocos/deprecated/CCString.h @@ -205,40 +205,19 @@ struct StringCompare : public std::binary_function<__String *, __String *, bool> #define StringMake(str) String::create(str) #define ccs StringMake -class StringUtils +namespace StringUtils { + +template +std::string toString(T arg) { -public: + std::stringstream ss; + ss << arg; + return ss.str(); +} + +std::string format(const char* format, ...) CC_FORMAT_PRINTF(1, 2); - template - static std::string toString(T arg) - { - std::stringstream ss; - ss << arg; - return ss.str(); - } - - static std::string format(const char* format, ...) CC_FORMAT_PRINTF(1, 2) - { - #define CC_MAX_STRING_LENGTH (1024*100) - - std::string ret; - - va_list ap; - va_start(ap, format); - - char* buf = (char*)malloc(CC_MAX_STRING_LENGTH); - if (buf != nullptr) - { - vsnprintf(buf, CC_MAX_STRING_LENGTH, format, ap); - ret = buf; - free(buf); - } - va_end(ap); - - return ret; - } - -}; +} // namespace StringUtils { // end of data_structure group /// @} From e84ccc8914d6a8f9e881cb980189f78a50682a5d Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 8 May 2014 11:12:00 +0800 Subject: [PATCH 095/174] issue #4660: Updates Xcode project --- build/cocos2d_libs.xcodeproj/project.pbxproj | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 6c0f8cdefb..0fb28c3cbf 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -765,6 +765,10 @@ 1ABA68AF1888D700007D1BB4 /* CCFontCharMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ABA68AC1888D700007D1BB4 /* CCFontCharMap.cpp */; }; 1ABA68B01888D700007D1BB4 /* CCFontCharMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ABA68AD1888D700007D1BB4 /* CCFontCharMap.h */; }; 1ABA68B11888D700007D1BB4 /* CCFontCharMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ABA68AD1888D700007D1BB4 /* CCFontCharMap.h */; }; + 1AC0269A1914068200FA920D /* ConvertUTF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC026981914068200FA920D /* ConvertUTF.cpp */; }; + 1AC0269B1914068200FA920D /* ConvertUTF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC026981914068200FA920D /* ConvertUTF.cpp */; }; + 1AC0269C1914068200FA920D /* ConvertUTF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC026991914068200FA920D /* ConvertUTF.h */; }; + 1AC0269D1914068200FA920D /* ConvertUTF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC026991914068200FA920D /* ConvertUTF.h */; }; 1AD71DA9180E26E600808F54 /* CCBAnimationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71CFA180E26E600808F54 /* CCBAnimationManager.cpp */; }; 1AD71DAA180E26E600808F54 /* CCBAnimationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71CFA180E26E600808F54 /* CCBAnimationManager.cpp */; }; 1AD71DAB180E26E600808F54 /* CCBAnimationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71CFB180E26E600808F54 /* CCBAnimationManager.h */; }; @@ -2125,6 +2129,8 @@ 1AAF584E180E40B9000584C8 /* LocalStorageAndroid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalStorageAndroid.cpp; sourceTree = ""; }; 1ABA68AC1888D700007D1BB4 /* CCFontCharMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFontCharMap.cpp; sourceTree = ""; }; 1ABA68AD1888D700007D1BB4 /* CCFontCharMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFontCharMap.h; sourceTree = ""; }; + 1AC026981914068200FA920D /* ConvertUTF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertUTF.cpp; sourceTree = ""; }; + 1AC026991914068200FA920D /* ConvertUTF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConvertUTF.h; sourceTree = ""; }; 1AD71CFA180E26E600808F54 /* CCBAnimationManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBAnimationManager.cpp; sourceTree = ""; }; 1AD71CFB180E26E600808F54 /* CCBAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBAnimationManager.h; sourceTree = ""; }; 1AD71CFC180E26E600808F54 /* CCBFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBFileLoader.cpp; sourceTree = ""; }; @@ -3372,6 +3378,7 @@ 1A57033E180BD0490088DEC7 /* external */ = { isa = PBXGroup; children = ( + 1AC026971914068200FA920D /* ConvertUTF */, 46C02E0418E91123004B7456 /* xxhash */, 46A168B21807AF9C005B8026 /* Box2D */, 46A1693A1807AFD6005B8026 /* chipmunk */, @@ -3789,6 +3796,16 @@ path = "local-storage"; sourceTree = ""; }; + 1AC026971914068200FA920D /* ConvertUTF */ = { + isa = PBXGroup; + children = ( + 1AC026981914068200FA920D /* ConvertUTF.cpp */, + 1AC026991914068200FA920D /* ConvertUTF.h */, + ); + name = ConvertUTF; + path = ../external/ConvertUTF; + sourceTree = ""; + }; 1AD71CF7180E26E600808F54 /* editor-support */ = { isa = PBXGroup; children = ( @@ -4998,6 +5015,7 @@ 50FCEB9918C72017004AD434 /* CheckBoxReader.h in Headers */, 50E6D33E18E174130051CA34 /* UIVBox.h in Headers */, 500DC9AC19106300007B91BF /* ZipUtils.h in Headers */, + 1AC0269C1914068200FA920D /* ConvertUTF.h in Headers */, 1A57019F180BCB590088DEC7 /* CCFont.h in Headers */, 1A5701A3180BCB590088DEC7 /* CCFontAtlas.h in Headers */, 1A01C68618F57BE800EFE3A6 /* CCArray.h in Headers */, @@ -5564,6 +5582,7 @@ 5034CA44191D591100CE6051 /* ccShader_Label.vert in Headers */, 1A5702F5180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */, 1A5702F9180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */, + 1AC0269D1914068200FA920D /* ConvertUTF.h in Headers */, 500DC9A119106300007B91BF /* CCVector.h in Headers */, 1A5702FD180BCE750088DEC7 /* CCTMXXMLParser.h in Headers */, 1A570303180BCE890088DEC7 /* CCParallaxNode.h in Headers */, @@ -6093,6 +6112,7 @@ 2AC795DB1862870F005EC8E1 /* SkeletonBounds.cpp in Sources */, 2AC795DC1862870F005EC8E1 /* Event.cpp in Sources */, 1A01C68A18F57BE800EFE3A6 /* CCDeprecated.cpp in Sources */, + 1AC0269A1914068200FA920D /* ConvertUTF.cpp in Sources */, 500DC93219106300007B91BF /* CCAutoreleasePool.cpp in Sources */, 2905FA5618CF08D100240AA3 /* UILayout.cpp in Sources */, 2AC795DD1862870F005EC8E1 /* EventData.cpp in Sources */, @@ -6803,6 +6823,7 @@ 1A8C59EC180E930E00EF57C3 /* CCSkin.cpp in Sources */, 2905FA4718CF08D100240AA3 /* UIButton.cpp in Sources */, 1A8C59F0180E930E00EF57C3 /* CCSpriteFrameCacheHelper.cpp in Sources */, + 1AC0269B1914068200FA920D /* ConvertUTF.cpp in Sources */, B2AF2FA218EBAEAE00C5807C /* Vector2.cpp in Sources */, 500DC8D219105F7D007B91BF /* CCAffineTransform.cpp in Sources */, 1A8C59F4180E930E00EF57C3 /* CCSSceneReader.cpp in Sources */, From ed8633141fe537c074cfdbf50a7336d517262eef Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 8 May 2014 11:12:22 +0800 Subject: [PATCH 096/174] issue #4660: Updates android.mk --- cocos/Android.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos/Android.mk b/cocos/Android.mk index 75a09812f2..882ae1f2d7 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -159,6 +159,7 @@ physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp \ physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp \ physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp \ physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp \ +../external/ConvertUTF/ConvertUTF.cpp \ ../external/tinyxml2/tinyxml2.cpp \ ../external/unzip/ioapi.cpp \ ../external/unzip/unzip.cpp \ @@ -182,7 +183,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../external/unzip \ $(LOCAL_PATH)/../external/chipmunk/include/chipmunk \ $(LOCAL_PATH)/../external/edtaa3func \ - $(LOCAL_PATH)/../external/xxhash + $(LOCAL_PATH)/../external/xxhash \ + $(LOCAL_PATH)/../external/ConvertUTF LOCAL_LDLIBS := -lGLESv2 \ From 5fda13639dc2ce65df3af47da33d2049814c24d7 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 8 May 2014 11:12:59 +0800 Subject: [PATCH 097/174] issue #4660: Uses new utf api for Label. --- cocos/2d/CCFont.cpp | 41 ---------------------- cocos/2d/CCFont.h | 6 +--- cocos/2d/CCFontAtlas.cpp | 8 ++--- cocos/2d/CCFontAtlas.h | 7 ++-- cocos/2d/CCFontCharMap.cpp | 7 ++-- cocos/2d/CCFontCharMap.h | 2 +- cocos/2d/CCFontFNT.cpp | 7 ++-- cocos/2d/CCFontFNT.h | 2 +- cocos/2d/CCFontFreeType.cpp | 14 ++++---- cocos/2d/CCFontFreeType.h | 2 +- cocos/2d/CCLabel.cpp | 57 ++++++++++++------------------- cocos/2d/CCLabel.h | 10 +++--- cocos/2d/CCLabelTextFormatter.cpp | 41 +++++++++------------- 13 files changed, 66 insertions(+), 138 deletions(-) diff --git a/cocos/2d/CCFont.cpp b/cocos/2d/CCFont.cpp index 1a158af323..8e18fc4a66 100644 --- a/cocos/2d/CCFont.cpp +++ b/cocos/2d/CCFont.cpp @@ -100,47 +100,6 @@ const char * Font::getCurrentGlyphCollection() const } } -unsigned short* Font::getUTF16Text(const char *text, int &outNumLetters) const -{ - unsigned short* utf16String = cc_utf8_to_utf16(text); - - if(!utf16String) - return 0; - - outNumLetters = cc_wcslen(utf16String); - return utf16String; -} - -int Font::getUTF16TextLenght(unsigned short int *text) const -{ - return cc_wcslen(text); -} - -unsigned short * Font::trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const -{ - if ( newBegin < 0 || newEnd <= 0 ) - return 0; - - if ( newBegin >= newEnd ) - return 0; - - if (newEnd >= cc_wcslen(text)) - return 0; - - int newLenght = newEnd - newBegin + 2; - unsigned short* trimmedString = new unsigned short[newLenght]; - - for(int c = 0; c < (newLenght - 1); ++c) - { - trimmedString[c] = text[newBegin + c]; - } - - // last char - trimmedString[newLenght-1] = 0x0000; - - // done - return trimmedString; -} NS_CC_END diff --git a/cocos/2d/CCFont.h b/cocos/2d/CCFont.h index 1fd7859b70..d11acc2f09 100644 --- a/cocos/2d/CCFont.h +++ b/cocos/2d/CCFont.h @@ -41,16 +41,12 @@ class CC_DLL Font : public Ref public: virtual FontAtlas *createFontAtlas() = 0; - virtual int* getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const = 0; + virtual int* getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const = 0; virtual const char* getCurrentGlyphCollection() const; virtual int getFontMaxHeight() const { return 0; } - virtual int getUTF16TextLenght(unsigned short int *text) const; - virtual unsigned short * getUTF16Text(const char *text, int &outNumLetters) const; - virtual unsigned short * trimUTF16Text(unsigned short int *text, int newBegin, int newEnd) const; - protected: Font(); diff --git a/cocos/2d/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp index fd2d32e1c1..de8797e090 100644 --- a/cocos/2d/CCFontAtlas.cpp +++ b/cocos/2d/CCFontAtlas.cpp @@ -202,7 +202,7 @@ void FontAtlas::addLetterDefinition(const FontLetterDefinition &letterDefinition _fontLetterDefinitions[letterDefinition.letteCharUTF16] = letterDefinition; } -bool FontAtlas::getLetterDefinitionForChar(unsigned short letteCharUTF16, FontLetterDefinition &outDefinition) +bool FontAtlas::getLetterDefinitionForChar(char16_t letteCharUTF16, FontLetterDefinition &outDefinition) { auto outIterator = _fontLetterDefinitions.find(letteCharUTF16); @@ -218,13 +218,13 @@ bool FontAtlas::getLetterDefinitionForChar(unsigned short letteCharUTF16, FontL } } -bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String) +bool FontAtlas::prepareLetterDefinitions(const std::u16string& utf16String) { FontFreeType* fontTTf = dynamic_cast(_font); - if(fontTTf == nullptr || utf16String == nullptr) + if(fontTTf == nullptr) return false; - int length = cc_wcslen(utf16String); + size_t length = utf16String.length(); float offsetAdjust = _letterPadding / 2; long bitmapWidth; diff --git a/cocos/2d/CCFontAtlas.h b/cocos/2d/CCFontAtlas.h index 78c9b44d6e..f55c6938d9 100644 --- a/cocos/2d/CCFontAtlas.h +++ b/cocos/2d/CCFontAtlas.h @@ -25,10 +25,11 @@ #ifndef _CCFontAtlas_h_ #define _CCFontAtlas_h_ -#include #include "base/CCPlatformMacros.h" #include "base/CCRef.h" #include "CCStdC.h" +#include +#include NS_CC_BEGIN @@ -71,9 +72,9 @@ public: virtual ~FontAtlas(); void addLetterDefinition(const FontLetterDefinition &letterDefinition); - bool getLetterDefinitionForChar(unsigned short letteCharUTF16, FontLetterDefinition &outDefinition); + bool getLetterDefinitionForChar(char16_t letteCharUTF16, FontLetterDefinition &outDefinition); - bool prepareLetterDefinitions(unsigned short *utf16String); + bool prepareLetterDefinitions(const std::u16string& utf16String); inline const std::unordered_map& getTextures() const{ return _atlasTextures;} void addTexture(Texture2D *texture, int slot); diff --git a/cocos/2d/CCFontCharMap.cpp b/cocos/2d/CCFontCharMap.cpp index 1200118bb5..75e802e31e 100644 --- a/cocos/2d/CCFontCharMap.cpp +++ b/cocos/2d/CCFontCharMap.cpp @@ -99,12 +99,9 @@ FontCharMap::~FontCharMap() } -int * FontCharMap::getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const +int * FontCharMap::getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const { - if (!text) - return 0; - - outNumLetters = cc_wcslen(text); + outNumLetters = static_cast(text.length()); if (!outNumLetters) return 0; diff --git a/cocos/2d/CCFontCharMap.h b/cocos/2d/CCFontCharMap.h index d91d12e2bc..76b4fb7e10 100644 --- a/cocos/2d/CCFontCharMap.h +++ b/cocos/2d/CCFontCharMap.h @@ -37,7 +37,7 @@ public: static FontCharMap * create(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap); static FontCharMap * create(const std::string& plistFile); - virtual int* getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const override; + virtual int* getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const override; virtual FontAtlas *createFontAtlas() override; protected: diff --git a/cocos/2d/CCFontFNT.cpp b/cocos/2d/CCFontFNT.cpp index 0792daf094..714567cad4 100644 --- a/cocos/2d/CCFontFNT.cpp +++ b/cocos/2d/CCFontFNT.cpp @@ -711,12 +711,9 @@ void FontFNT::purgeCachedData() } } -int * FontFNT::getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const +int * FontFNT::getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const { - if (!text) - return 0; - - outNumLetters = cc_wcslen(text); + outNumLetters = static_cast(text.length()); if (!outNumLetters) return 0; diff --git a/cocos/2d/CCFontFNT.h b/cocos/2d/CCFontFNT.h index 3b6d036be2..fb32fbc4fe 100644 --- a/cocos/2d/CCFontFNT.h +++ b/cocos/2d/CCFontFNT.h @@ -42,7 +42,7 @@ public: Removes from memory the cached configurations and the atlas name dictionary. */ static void purgeCachedData(); - virtual int* getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const override; + virtual int* getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const override; virtual FontAtlas *createFontAtlas() override; protected: diff --git a/cocos/2d/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp index a36d2b9db7..588bb4b4ac 100644 --- a/cocos/2d/CCFontFreeType.cpp +++ b/cocos/2d/CCFontFreeType.cpp @@ -175,20 +175,22 @@ FontAtlas * FontFreeType::createFontAtlas() FontAtlas *atlas = new FontAtlas(*this); if (_usedGlyphs != GlyphCollection::DYNAMIC) { - unsigned short* utf16 = cc_utf8_to_utf16(getCurrentGlyphCollection()); - atlas->prepareLetterDefinitions(utf16); - CC_SAFE_DELETE_ARRAY(utf16); + std::u16string utf16; + if (StringUtils::UTF8ToUTF16(getCurrentGlyphCollection(), utf16)) + { + atlas->prepareLetterDefinitions(utf16); + } } this->release(); return atlas; } -int * FontFreeType::getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const +int * FontFreeType::getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const { - if (!text || !_fontRef) + if (!_fontRef) return nullptr; - outNumLetters = cc_wcslen(text); + outNumLetters = static_cast(text.length()); if (!outNumLetters) return nullptr; diff --git a/cocos/2d/CCFontFreeType.h b/cocos/2d/CCFontFreeType.h index ece5c6dbf4..9c38e979b8 100644 --- a/cocos/2d/CCFontFreeType.h +++ b/cocos/2d/CCFontFreeType.h @@ -62,7 +62,7 @@ public: void renderCharAt(unsigned char *dest,int posX, int posY, unsigned char* bitmap,long bitmapWidth,long bitmapHeight); virtual FontAtlas * createFontAtlas() override; - virtual int * getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const override; + virtual int * getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const override; unsigned char * getGlyphBitmap(unsigned short theChar, long &outWidth, long &outHeight, Rect &outRect,int &xAdvance); diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 0eda61ddd2..f74510fa73 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -247,8 +247,6 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te , _labelDimensions(Size::ZERO) , _hAlignment(hAlignment) , _vAlignment(vAlignment) -, _currentUTF16String(nullptr) -, _originalUTF16String(nullptr) , _horizontalKernings(nullptr) , _fontAtlas(atlas) , _isOpacityModifyRGB(false) @@ -287,9 +285,7 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te } Label::~Label() -{ - delete [] _currentUTF16String; - delete [] _originalUTF16String; +{ delete [] _horizontalKernings; if (_fontAtlas) @@ -574,7 +570,7 @@ float Label::getScaleX() const void Label::alignText() { - if (_fontAtlas == nullptr || _currentUTF16String == nullptr) + if (_fontAtlas == nullptr || _currentUTF16String.empty()) { return; } @@ -603,7 +599,7 @@ void Label::alignText() if(_labelWidth > 0 || (_currNumLines > 1 && _hAlignment != TextHAlignment::LEFT)) LabelTextFormatter::alignText(this); - int strLen = cc_wcslen(_currentUTF16String); + int strLen = static_cast(_currentUTF16String.length()); Rect uvRect; Sprite* letterSprite; for(const auto &child : _children) { @@ -633,7 +629,7 @@ void Label::alignText() updateColor(); } -bool Label::computeHorizontalKernings(unsigned short int *stringToRender) +bool Label::computeHorizontalKernings(const std::u16string& stringToRender) { if (_horizontalKernings) { @@ -650,30 +646,14 @@ bool Label::computeHorizontalKernings(unsigned short int *stringToRender) return true; } -bool Label::setOriginalString(unsigned short *stringToSet) +bool Label::setOriginalString(const std::u16string& stringToSet) { - if (_originalUTF16String) - { - delete [] _originalUTF16String; - } - - int newStringLenght = cc_wcslen(stringToSet); - _originalUTF16String = new unsigned short int [newStringLenght + 1]; - memset(_originalUTF16String, 0, (newStringLenght + 1) * 2); - memcpy(_originalUTF16String, stringToSet, (newStringLenght * 2)); - _originalUTF16String[newStringLenght] = 0; - + _originalUTF16String = stringToSet; return true; } -bool Label::setCurrentString(unsigned short *stringToSet) +bool Label::setCurrentString(const std::u16string& stringToSet) { - // set the new string - if (_currentUTF16String) - { - delete [] _currentUTF16String; - } - _currentUTF16String = stringToSet; computeStringNumLines(); @@ -959,9 +939,12 @@ void Label::setFontDefinition(const FontDefinition& textDefinition) void Label::updateContent() { - auto utf16String = cc_utf8_to_utf16(_originalUTF8String.c_str()); - setCurrentString(utf16String); - setOriginalString(utf16String); + std::u16string utf16String; + if (StringUtils::UTF8ToUTF16(_originalUTF8String, utf16String)) + { + setCurrentString(utf16String); + setOriginalString(utf16String); + } if (_textSprite) { @@ -1203,15 +1186,15 @@ void Label::computeStringNumLines() { int quantityOfLines = 1; - int stringLen = _currentUTF16String ? cc_wcslen(_currentUTF16String) : -1; - if (stringLen < 1) + if (_currentUTF16String.empty()) { - _currNumLines = stringLen; + _currNumLines = 0; return; } // count number of lines - for (int i = 0; i < stringLen - 1; ++i) + size_t stringLen = _currentUTF16String.length(); + for (size_t i = 0; i < stringLen-1; ++i) { if (_currentUTF16String[i] == '\n') { @@ -1224,7 +1207,7 @@ void Label::computeStringNumLines() int Label::getStringLength() const { - return _currentUTF16String ? cc_wcslen(_currentUTF16String) : (int)_originalUTF8String.length(); + return _currentUTF16String.length(); } // RGBA protocol @@ -1323,7 +1306,9 @@ void Label::updateColor() std::string Label::getDescription() const { - return StringUtils::format("