Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3_bu_fix

This commit is contained in:
samuele3hu 2014-06-27 18:00:34 +08:00
commit 67423e0dd2
19 changed files with 441 additions and 128 deletions

View File

@ -903,6 +903,9 @@ Developers:
billtt
Fixed a bug that Node::setScale(float) may not work properly
Teivaz
Custom uniform search optimization
Retired Core Developers:
WenSheng Yang

View File

@ -1,4 +1,5 @@
cocos2d-x-3.2 ???
[NEW] GLProgramState: can use uniform location to get/set uniform values
[NEW] HttpClient: added sendImmediate()
[NEW] Label: support setting line height and additional kerning of label that not using system font
[NEW] Lua-binding: Animation3D supported

View File

@ -995,6 +995,8 @@
299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; };
299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; };
299754F7193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; };
29BDBA53195D597A003225C9 /* UIDeprecated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29BDBA52195D597A003225C9 /* UIDeprecated.cpp */; };
29BDBA54195D597A003225C9 /* UIDeprecated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29BDBA52195D597A003225C9 /* UIDeprecated.cpp */; };
29CB8F4C1929D1BB00C841D6 /* UILayoutManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */; };
29CB8F4D1929D1BB00C841D6 /* UILayoutManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */; };
29CB8F4E1929D1BB00C841D6 /* UILayoutManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */; };
@ -2311,6 +2313,7 @@
2986667918B1B079000E39CA /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = "<group>"; };
299754F2193EC95400A54AC3 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFactory.cpp; path = ../base/ObjectFactory.cpp; sourceTree = "<group>"; };
299754F3193EC95400A54AC3 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactory.h; path = ../base/ObjectFactory.h; sourceTree = "<group>"; };
29BDBA52195D597A003225C9 /* UIDeprecated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIDeprecated.cpp; sourceTree = "<group>"; };
29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutManager.cpp; sourceTree = "<group>"; };
29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutManager.h; sourceTree = "<group>"; };
29E99D1C1957BA7000046604 /* CocoLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocoLoader.cpp; sourceTree = "<group>"; };
@ -4030,6 +4033,7 @@
isa = PBXGroup;
children = (
29080DEB191B82CE0066F8DF /* UIDeprecated.h */,
29BDBA52195D597A003225C9 /* UIDeprecated.cpp */,
2905FA1318CF08D100240AA3 /* UIWidget.cpp */,
2905FA1418CF08D100240AA3 /* UIWidget.h */,
50E6D30C18DADB5D0051CA34 /* CCProtectedNode.cpp */,
@ -6360,6 +6364,7 @@
503DD8F71926B0DB00CD74DD /* CCIMEDispatcher.cpp in Sources */,
1AD71EB1180E26E600808F54 /* Bone.cpp in Sources */,
1AD71EB5180E26E600808F54 /* BoneData.cpp in Sources */,
29BDBA53195D597A003225C9 /* UIDeprecated.cpp in Sources */,
1AD71EB9180E26E600808F54 /* CCSkeleton.cpp in Sources */,
50ABBE751925AB6F00A911A9 /* CCEventListenerTouch.cpp in Sources */,
1AD71EBD180E26E600808F54 /* CCSkeletonAnimation.cpp in Sources */,
@ -6855,6 +6860,7 @@
50ABBD5D1925AB0000A911A9 /* Vec3.cpp in Sources */,
50ABC0121926664800A911A9 /* CCGLViewProtocol.cpp in Sources */,
50ABC0021926664800A911A9 /* CCLock.cpp in Sources */,
29BDBA54195D597A003225C9 /* UIDeprecated.cpp in Sources */,
50FCEBAC18C72017004AD434 /* PageViewReader.cpp in Sources */,
1A8C598C180E930E00EF57C3 /* CCActionFrame.cpp in Sources */,
1A8C5990180E930E00EF57C3 /* CCActionFrameEasing.cpp in Sources */,

View File

@ -309,7 +309,8 @@ bool GLProgramState::init(GLProgram* glprogram)
for(auto &uniform : _glprogram->_userUniforms) {
UniformValue value(&uniform.second, _glprogram);
_uniforms[uniform.first] = value;
_uniforms[uniform.second.location] = value;
_uniformsByName[uniform.first] = uniform.second.location;
}
return true;
@ -329,9 +330,9 @@ void GLProgramState::apply(const Mat4& modelView)
CCASSERT(_glprogram, "invalid glprogram");
if(_uniformAttributeValueDirty)
{
for(auto& uniformValue : _uniforms)
for(auto& uniformLocation : _uniformsByName)
{
uniformValue.second._uniform = _glprogram->getUniform(uniformValue.first);
_uniforms[uniformLocation.second]._uniform = _glprogram->getUniform(uniformLocation.first);
}
_vertexAttribsFlags = 0;
@ -377,11 +378,19 @@ void GLProgramState::setGLProgram(GLProgram *glprogram)
}
}
UniformValue* GLProgramState::getUniformValue(GLint uniformLocation)
{
const auto itr = _uniforms.find(uniformLocation);
if (itr != _uniforms.end())
return &itr->second;
return nullptr;
}
UniformValue* GLProgramState::getUniformValue(const std::string &name)
{
const auto itr = _uniforms.find(name);
if( itr != _uniforms.end())
return &itr->second;
const auto itr = _uniformsByName.find(name);
if (itr != _uniformsByName.end())
return &_uniforms[itr->second];
return nullptr;
}
@ -431,6 +440,15 @@ void GLProgramState::setUniformCallback(const std::string &uniformName, const st
CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str());
}
void GLProgramState::setUniformCallback(GLint uniformLocation, const std::function<void(GLProgram*, Uniform*)> &callback)
{
auto v = getUniformValue(uniformLocation);
if (v)
v->setCallback(callback);
else
CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation);
}
void GLProgramState::setUniformFloat(const std::string &uniformName, float value)
{
auto v = getUniformValue(uniformName);
@ -440,6 +458,15 @@ void GLProgramState::setUniformFloat(const std::string &uniformName, float value
CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str());
}
void GLProgramState::setUniformFloat(GLint uniformLocation, float value)
{
auto v = getUniformValue(uniformLocation);
if (v)
v->setFloat(value);
else
CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation);
}
void GLProgramState::setUniformInt(const std::string &uniformName, int value)
{
auto v = getUniformValue(uniformName);
@ -449,6 +476,16 @@ void GLProgramState::setUniformInt(const std::string &uniformName, int value)
CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str());
}
void GLProgramState::setUniformInt(GLint uniformLocation, int value)
{
auto v = getUniformValue(uniformLocation);
if (v)
v->setInt(value);
else
CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation);
}
void GLProgramState::setUniformVec2(const std::string &uniformName, const Vec2& value)
{
auto v = getUniformValue(uniformName);
@ -458,6 +495,15 @@ void GLProgramState::setUniformVec2(const std::string &uniformName, const Vec2&
CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str());
}
void GLProgramState::setUniformVec2(GLint uniformLocation, const Vec2& value)
{
auto v = getUniformValue(uniformLocation);
if (v)
v->setVec2(value);
else
CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation);
}
void GLProgramState::setUniformVec3(const std::string &uniformName, const Vec3& value)
{
auto v = getUniformValue(uniformName);
@ -467,6 +513,15 @@ void GLProgramState::setUniformVec3(const std::string &uniformName, const Vec3&
CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str());
}
void GLProgramState::setUniformVec3(GLint uniformLocation, const Vec3& value)
{
auto v = getUniformValue(uniformLocation);
if (v)
v->setVec3(value);
else
CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation);
}
void GLProgramState::setUniformVec4(const std::string &uniformName, const Vec4& value)
{
auto v = getUniformValue(uniformName);
@ -476,6 +531,15 @@ void GLProgramState::setUniformVec4(const std::string &uniformName, const Vec4&
CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str());
}
void GLProgramState::setUniformVec4(GLint uniformLocation, const Vec4& value)
{
auto v = getUniformValue(uniformLocation);
if (v)
v->setVec4(value);
else
CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation);
}
void GLProgramState::setUniformMat4(const std::string &uniformName, const Mat4& value)
{
auto v = getUniformValue(uniformName);
@ -485,6 +549,15 @@ void GLProgramState::setUniformMat4(const std::string &uniformName, const Mat4&
CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str());
}
void GLProgramState::setUniformMat4(GLint uniformLocation, const Mat4& value)
{
auto v = getUniformValue(uniformLocation);
if (v)
v->setMat4(value);
else
CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation);
}
// Textures
void GLProgramState::setUniformTexture(const std::string &uniformName, Texture2D *texture)
@ -493,6 +566,12 @@ void GLProgramState::setUniformTexture(const std::string &uniformName, Texture2D
setUniformTexture(uniformName, texture->getName());
}
void GLProgramState::setUniformTexture(GLint uniformLocation, Texture2D *texture)
{
CCASSERT(texture, "Invalid texture");
setUniformTexture(uniformLocation, texture->getName());
}
void GLProgramState::setUniformTexture(const std::string &uniformName, GLuint textureId)
{
auto v = getUniformValue(uniformName);
@ -514,5 +593,25 @@ void GLProgramState::setUniformTexture(const std::string &uniformName, GLuint te
}
}
void GLProgramState::setUniformTexture(GLint uniformLocation, GLuint textureId)
{
auto v = getUniformValue(uniformLocation);
if (v)
{
if (_boundTextureUnits.find(v->_uniform->name) != _boundTextureUnits.end())
{
v->setTexture(textureId, _boundTextureUnits[v->_uniform->name]);
}
else
{
v->setTexture(textureId, _textureUnitIndex);
_boundTextureUnits[v->_uniform->name] = _textureUnitIndex++;
}
}
else
{
CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation);
}
}
NS_CC_END

View File

@ -179,7 +179,17 @@ public:
void setUniformCallback(const std::string &uniformName, const std::function<void(GLProgram*, Uniform*)> &callback);
void setUniformTexture(const std::string &uniformName, Texture2D *texture);
void setUniformTexture(const std::string &uniformName, GLuint textureId);
void setUniformInt(GLint uniformLocation, int value);
void setUniformFloat(GLint uniformLocation, float value);
void setUniformVec2(GLint uniformLocation, const Vec2& value);
void setUniformVec3(GLint uniformLocation, const Vec3& value);
void setUniformVec4(GLint uniformLocation, const Vec4& value);
void setUniformMat4(GLint uniformLocation, const Mat4& value);
void setUniformCallback(GLint uniformLocation, const std::function<void(GLProgram*, Uniform*)> &callback);
void setUniformTexture(GLint uniformLocation, Texture2D *texture);
void setUniformTexture(GLint uniformLocation, GLuint textureId);
protected:
GLProgramState();
~GLProgramState();
@ -187,9 +197,11 @@ protected:
void resetGLProgram();
VertexAttribValue* getVertexAttribValue(const std::string &attributeName);
UniformValue* getUniformValue(const std::string &uniformName);
UniformValue* getUniformValue(GLint uniformLocation);
bool _uniformAttributeValueDirty;
std::unordered_map<std::string, UniformValue> _uniforms;
std::unordered_map<std::string, GLint> _uniformsByName;
std::unordered_map<GLint, UniformValue> _uniforms;
std::unordered_map<std::string, VertexAttribValue> _attributes;
std::unordered_map<std::string, int> _boundTextureUnits;

View File

@ -9,62 +9,90 @@
--
-- overload function: setUniformTexture(string, cc.Texture2D)
--
-- overload function: setUniformTexture(int, cc.Texture2D)
--
-- overload function: setUniformTexture(int, unsigned int)
--
-- @function [parent=#GLProgramState] setUniformTexture
-- @param self
-- @param #string str
-- @param #cc.Texture2D texture2d
-- @param #int int
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgramState] setUniformMat4
-- overload function: setUniformMat4(int, mat4_table)
--
-- overload function: setUniformMat4(string, mat4_table)
--
-- @function [parent=#GLProgramState] setUniformMat4
-- @param self
-- @param #string str
-- @param #mat4_table mat4
--------------------------------
-- @function [parent=#GLProgramState] getUniformCount
-- @param self
-- @return long#long ret (return value: long)
--------------------------------
-- @function [parent=#GLProgramState] setUniformFloat
-- overload function: setUniformFloat(int, float)
--
-- overload function: setUniformFloat(string, float)
--
-- @function [parent=#GLProgramState] setUniformFloat
-- @param self
-- @param #string str
-- @param #float float
--------------------------------
-- @function [parent=#GLProgramState] setUniformVec3
-- overload function: setUniformVec3(int, vec3_table)
--
-- overload function: setUniformVec3(string, vec3_table)
--
-- @function [parent=#GLProgramState] setUniformVec3
-- @param self
-- @param #string str
-- @param #vec3_table vec3
--------------------------------
-- @function [parent=#GLProgramState] setGLProgram
-- @param self
-- @param #cc.GLProgram glprogram
--------------------------------
-- @function [parent=#GLProgramState] setUniformVec4
-- overload function: setUniformVec4(int, vec4_table)
--
-- overload function: setUniformVec4(string, vec4_table)
--
-- @function [parent=#GLProgramState] setUniformVec4
-- @param self
-- @param #string str
-- @param #vec4_table vec4
--------------------------------
-- @function [parent=#GLProgramState] getVertexAttribCount
-- @param self
-- @return long#long ret (return value: long)
--------------------------------
-- @function [parent=#GLProgramState] setUniformInt
-- overload function: setUniformInt(int, int)
--
-- overload function: setUniformInt(string, int)
--
-- @function [parent=#GLProgramState] setUniformInt
-- @param self
-- @param #string str
-- @param #int int
--------------------------------
-- @function [parent=#GLProgramState] setUniformVec2
-- overload function: setUniformVec2(int, vec2_table)
--
-- overload function: setUniformVec2(string, vec2_table)
--
-- @function [parent=#GLProgramState] setUniformVec2
-- @param self
-- @param #string str
-- @param #vec2_table vec2
--------------------------------
-- @function [parent=#GLProgramState] getVertexAttribsFlags
-- @param self

View File

@ -9783,6 +9783,36 @@ int lua_cocos2dx_GLProgramState_setUniformTexture(lua_State* tolua_S)
}
}while(0);
ok = true;
do{
if (argc == 2) {
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
if (!ok) { break; }
cocos2d::Texture2D* arg1;
ok &= luaval_to_object<cocos2d::Texture2D>(tolua_S, 3, "cc.Texture2D",&arg1);
if (!ok) { break; }
cobj->setUniformTexture(arg0, arg1);
return 0;
}
}while(0);
ok = true;
do{
if (argc == 2) {
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
if (!ok) { break; }
unsigned int arg1;
ok &= luaval_to_uint32(tolua_S, 3,&arg1);
if (!ok) { break; }
cobj->setUniformTexture(arg0, arg1);
return 0;
}
}while(0);
ok = true;
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformTexture",argc, 2);
return 0;
@ -9798,40 +9828,52 @@ int lua_cocos2dx_GLProgramState_setUniformMat4(lua_State* tolua_S)
int argc = 0;
cocos2d::GLProgramState* 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.GLProgramState",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::GLProgramState*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgramState_setUniformMat4'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 2)
{
std::string arg0;
cocos2d::Mat4 arg1;
do{
if (argc == 2) {
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (!ok) { break; }
cocos2d::Mat4 arg1;
ok &= luaval_to_mat4(tolua_S, 3, &arg1);
ok &= luaval_to_mat4(tolua_S, 3, &arg1);
if(!ok)
if (!ok) { break; }
cobj->setUniformMat4(arg0, arg1);
return 0;
cobj->setUniformMat4(arg0, arg1);
return 0;
}
}
}while(0);
ok = true;
do{
if (argc == 2) {
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (!ok) { break; }
cocos2d::Mat4 arg1;
ok &= luaval_to_mat4(tolua_S, 3, &arg1);
if (!ok) { break; }
cobj->setUniformMat4(arg0, arg1);
return 0;
}
}while(0);
ok = true;
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformMat4",argc, 2);
return 0;
@ -9891,40 +9933,52 @@ int lua_cocos2dx_GLProgramState_setUniformFloat(lua_State* tolua_S)
int argc = 0;
cocos2d::GLProgramState* 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.GLProgramState",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::GLProgramState*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgramState_setUniformFloat'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 2)
{
std::string arg0;
double arg1;
do{
if (argc == 2) {
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (!ok) { break; }
double arg1;
ok &= luaval_to_number(tolua_S, 3,&arg1);
ok &= luaval_to_number(tolua_S, 3,&arg1);
if(!ok)
if (!ok) { break; }
cobj->setUniformFloat(arg0, arg1);
return 0;
cobj->setUniformFloat(arg0, arg1);
return 0;
}
}
}while(0);
ok = true;
do{
if (argc == 2) {
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (!ok) { break; }
double arg1;
ok &= luaval_to_number(tolua_S, 3,&arg1);
if (!ok) { break; }
cobj->setUniformFloat(arg0, arg1);
return 0;
}
}while(0);
ok = true;
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformFloat",argc, 2);
return 0;
@ -9940,40 +9994,52 @@ int lua_cocos2dx_GLProgramState_setUniformVec3(lua_State* tolua_S)
int argc = 0;
cocos2d::GLProgramState* 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.GLProgramState",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::GLProgramState*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgramState_setUniformVec3'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 2)
{
std::string arg0;
cocos2d::Vec3 arg1;
do{
if (argc == 2) {
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (!ok) { break; }
cocos2d::Vec3 arg1;
ok &= luaval_to_vec3(tolua_S, 3, &arg1);
ok &= luaval_to_vec3(tolua_S, 3, &arg1);
if(!ok)
if (!ok) { break; }
cobj->setUniformVec3(arg0, arg1);
return 0;
cobj->setUniformVec3(arg0, arg1);
return 0;
}
}
}while(0);
ok = true;
do{
if (argc == 2) {
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (!ok) { break; }
cocos2d::Vec3 arg1;
ok &= luaval_to_vec3(tolua_S, 3, &arg1);
if (!ok) { break; }
cobj->setUniformVec3(arg0, arg1);
return 0;
}
}while(0);
ok = true;
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformVec3",argc, 2);
return 0;
@ -10035,40 +10101,52 @@ int lua_cocos2dx_GLProgramState_setUniformVec4(lua_State* tolua_S)
int argc = 0;
cocos2d::GLProgramState* 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.GLProgramState",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::GLProgramState*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgramState_setUniformVec4'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 2)
{
std::string arg0;
cocos2d::Vec4 arg1;
do{
if (argc == 2) {
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (!ok) { break; }
cocos2d::Vec4 arg1;
ok &= luaval_to_vec4(tolua_S, 3, &arg1);
ok &= luaval_to_vec4(tolua_S, 3, &arg1);
if(!ok)
if (!ok) { break; }
cobj->setUniformVec4(arg0, arg1);
return 0;
cobj->setUniformVec4(arg0, arg1);
return 0;
}
}
}while(0);
ok = true;
do{
if (argc == 2) {
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (!ok) { break; }
cocos2d::Vec4 arg1;
ok &= luaval_to_vec4(tolua_S, 3, &arg1);
if (!ok) { break; }
cobj->setUniformVec4(arg0, arg1);
return 0;
}
}while(0);
ok = true;
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformVec4",argc, 2);
return 0;
@ -10128,40 +10206,52 @@ int lua_cocos2dx_GLProgramState_setUniformInt(lua_State* tolua_S)
int argc = 0;
cocos2d::GLProgramState* 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.GLProgramState",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::GLProgramState*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgramState_setUniformInt'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 2)
{
std::string arg0;
int arg1;
do{
if (argc == 2) {
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (!ok) { break; }
int arg1;
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1);
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1);
if(!ok)
if (!ok) { break; }
cobj->setUniformInt(arg0, arg1);
return 0;
cobj->setUniformInt(arg0, arg1);
return 0;
}
}
}while(0);
ok = true;
do{
if (argc == 2) {
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (!ok) { break; }
int arg1;
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1);
if (!ok) { break; }
cobj->setUniformInt(arg0, arg1);
return 0;
}
}while(0);
ok = true;
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformInt",argc, 2);
return 0;
@ -10177,40 +10267,52 @@ int lua_cocos2dx_GLProgramState_setUniformVec2(lua_State* tolua_S)
int argc = 0;
cocos2d::GLProgramState* 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.GLProgramState",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::GLProgramState*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_GLProgramState_setUniformVec2'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 2)
{
std::string arg0;
cocos2d::Vec2 arg1;
do{
if (argc == 2) {
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (!ok) { break; }
cocos2d::Vec2 arg1;
ok &= luaval_to_vec2(tolua_S, 3, &arg1);
ok &= luaval_to_vec2(tolua_S, 3, &arg1);
if(!ok)
if (!ok) { break; }
cobj->setUniformVec2(arg0, arg1);
return 0;
cobj->setUniformVec2(arg0, arg1);
return 0;
}
}
}while(0);
ok = true;
do{
if (argc == 2) {
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (!ok) { break; }
cocos2d::Vec2 arg1;
ok &= luaval_to_vec2(tolua_S, 3, &arg1);
if (!ok) { break; }
cobj->setUniformVec2(arg0, arg1);
return 0;
}
}while(0);
ok = true;
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setUniformVec2",argc, 2);
return 0;

View File

@ -29,7 +29,8 @@ CCProtectedNode.cpp \
UIHBox.cpp \
UIVBox.cpp \
UIRelativeBox.cpp \
UIVideoPlayerAndroid.cpp
UIVideoPlayerAndroid.cpp \
UIDeprecated.cpp \
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \
$(LOCAL_PATH)/../editor-support

View File

@ -22,5 +22,6 @@ set(COCOS_UI_SRC
ui/UITextField.cpp
ui/UIVBox.cpp
ui/UIWidget.cpp
ui/UIDeprecated.cpp
)

33
cocos/ui/UIDeprecated.cpp Normal file
View File

@ -0,0 +1,33 @@
/****************************************************************************
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 "ui/UIDeprecated.h"
NS_CC_BEGIN
namespace ui {
const Margin MarginZero = Margin::ZERO ;
}}

View File

@ -26,6 +26,12 @@
#define cocos2d_libs_UIDeprecated_h
#include "base/CCPlatformMacros.h"
#include "ui/UIWidget.h"
#include "ui/UILayout.h"
#include "ui/UIListView.h"
#include "ui/UILoadingBar.h"
#include "ui/UIPageView.h"
#include "ui/UIRichText.h"
NS_CC_BEGIN
@ -147,7 +153,7 @@ CC_DEPRECATED_ATTRIBUTE typedef LoadingBar::Direction LoadingBarType;
CC_DEPRECATED_ATTRIBUTE typedef PageView::TouchDirection PVTouchDir;
CC_DEPRECATED_ATTRIBUTE typedef RichElement::Type RichElementType;
CC_DEPRECATED_ATTRIBUTE typedef ScrollView::Direction SCROLLVIEW_DIR;
CC_DEPRECATED_ATTRIBUTE extern const Margin MarginZero;
}

View File

@ -29,6 +29,8 @@ NS_CC_BEGIN
namespace ui {
const Margin Margin::ZERO = Margin(0,0,0,0);
Margin::Margin(void) : left(0), top(0), right(0), bottom(0)
{
}

View File

@ -52,9 +52,11 @@ public:
Margin& operator= (const Margin& other);
void setMargin(float l, float t, float r, float b);
bool equals(const Margin& target) const;
static const Margin ZERO;
};
const Margin MarginZero = Margin();
/**
* @js NA

View File

@ -149,7 +149,7 @@ void ListView::remedyLayoutParameter(Widget *item)
}
if (getIndex(item) == 0)
{
defaultLp->setMargin(MarginZero);
defaultLp->setMargin(Margin::ZERO);
}
else
{
@ -161,7 +161,7 @@ void ListView::remedyLayoutParameter(Widget *item)
{
if (getIndex(item) == 0)
{
llp->setMargin(MarginZero);
llp->setMargin(Margin::ZERO);
}
else
{
@ -204,7 +204,7 @@ void ListView::remedyLayoutParameter(Widget *item)
}
if (getIndex(item) == 0)
{
defaultLp->setMargin(MarginZero);
defaultLp->setMargin(Margin::ZERO);
}
else
{
@ -216,7 +216,7 @@ void ListView::remedyLayoutParameter(Widget *item)
{
if (getIndex(item) == 0)
{
llp->setMargin(MarginZero);
llp->setMargin(Margin::ZERO);
}
else
{

View File

@ -15,6 +15,7 @@
<ClInclude Include="..\CocosGUI.h" />
<ClInclude Include="..\UIButton.h" />
<ClInclude Include="..\UICheckBox.h" />
<ClInclude Include="..\UIDeprecated.h" />
<ClInclude Include="..\UIHBox.h" />
<ClInclude Include="..\UIHelper.h" />
<ClInclude Include="..\UIImageView.h" />
@ -40,6 +41,7 @@
<ClCompile Include="..\CocosGUI.cpp" />
<ClCompile Include="..\UIButton.cpp" />
<ClCompile Include="..\UICheckBox.cpp" />
<ClCompile Include="..\UIDeprecated.cpp" />
<ClCompile Include="..\UIHBox.cpp" />
<ClCompile Include="..\UIHelper.cpp" />
<ClCompile Include="..\UIImageView.cpp" />

View File

@ -87,6 +87,9 @@
<ClInclude Include="..\UILayoutManager.h">
<Filter>Layouts</Filter>
</ClInclude>
<ClInclude Include="..\UIDeprecated.h">
<Filter>System</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\UIScrollView.cpp">
@ -158,5 +161,8 @@
<ClCompile Include="..\UILayoutManager.cpp">
<Filter>Layouts</Filter>
</ClCompile>
<ClCompile Include="..\UIDeprecated.cpp">
<Filter>System</Filter>
</ClCompile>
</ItemGroup>
</Project>
</Project>

View File

@ -184,6 +184,7 @@
<ClInclude Include="..\..\ui\UITextField.h" />
<ClInclude Include="..\..\ui\UIVBox.h" />
<ClInclude Include="..\..\ui\UIWidget.h" />
<ClInclude Include="..\UIDeprecated.h" />
<ClInclude Include="..\UIHBox.h" />
<ClInclude Include="..\UILayoutManager.h" />
<ClInclude Include="..\UIRelativeBox.h" />
@ -209,8 +210,9 @@
<ClCompile Include="..\..\ui\UITextField.cpp" />
<ClCompile Include="..\..\ui\UIVBox.cpp" />
<ClCompile Include="..\..\ui\UIWidget.cpp" />
<ClCompile Include="..\UIDeprecated.cpp" />
<ClCompile Include="..\UIHBox.cpp" />
<ClCompile Include="..\UILayoutManager.cpp" />
<ClCompile Include="..\UIRelativeBox.cpp" />
</ItemGroup>
</Project>
</Project>

View File

@ -84,6 +84,9 @@
<ClInclude Include="..\UILayoutManager.h">
<Filter>Layouts</Filter>
</ClInclude>
<ClInclude Include="..\UIDeprecated.h">
<Filter>System</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\ui\UILayout.cpp">
@ -155,5 +158,8 @@
<ClCompile Include="..\UILayoutManager.cpp">
<Filter>Layouts</Filter>
</ClCompile>
<ClCompile Include="..\UIDeprecated.cpp">
<Filter>System</Filter>
</ClCompile>
</ItemGroup>
</Project>
</Project>

View File

@ -957,6 +957,7 @@
"cocos/ui/UIButton.h",
"cocos/ui/UICheckBox.cpp",
"cocos/ui/UICheckBox.h",
"cocos/ui/UIDeprecated.cpp",
"cocos/ui/UIDeprecated.h",
"cocos/ui/UIHBox.cpp",
"cocos/ui/UIHBox.h",