From 069800b98c96095b08168ff48f1b51521170cbd3 Mon Sep 17 00:00:00 2001 From: Arnold <397136899@qq.com> Date: Thu, 14 Mar 2019 13:43:40 +0800 Subject: [PATCH 01/18] enable test case --- cocos/2d/CCSprite.cpp | 20 +- cocos/2d/CCSprite.h | 5 + cocos/renderer/CCMaterial.cpp | 21 +- cocos/renderer/CCPass.cpp | 4 +- cocos/renderer/CCPass.h | 5 +- tests/cpp-tests/CMakeLists.txt | 2 +- .../MaterialSystemTest/MaterialSystemTest.cpp | 331 ++++++------------ .../MaterialSystemTest/MaterialSystemTest.h | 56 +-- tests/cpp-tests/Classes/controller.cpp | 2 +- .../Resources/Shaders/example_Blur.fsh | 6 +- .../Shaders/example_EdgeDetection.fsh | 3 +- .../Resources/Shaders/example_Noisy.fsh | 4 +- .../Resources/Shaders/example_Outline.fsh | 12 +- .../Resources/Shaders/example_Simple.vsh | 4 +- .../Shaders3D/3d_position_normal_tex.vert | 9 +- 15 files changed, 189 insertions(+), 295 deletions(-) diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index c5c6ece109..b74dc0f578 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -383,17 +383,29 @@ void Sprite::setVertexLayout() void Sprite::updateShaders(const char* vert, const char* frag) { + auto programState = new (std::nothrow) backend::ProgramState(vert, frag); + setProgramState(programState); + CC_SAFE_RELEASE_NULL(programState); +} + +void Sprite::setProgramState(backend::ProgramState *programState) +{ + CCASSERT(programState, "argument should not be nullptr"); auto& pipelineDescriptor = _trianglesCommand.getPipelineDescriptor(); - CC_SAFE_RELEASE(_programState); - _programState = new (std::nothrow) backend::ProgramState(vert, frag); + if (_programState != programState) + { + CC_SAFE_RELEASE(_programState); + _programState = programState; + CC_SAFE_RETAIN(programState); + } pipelineDescriptor.programState = _programState; - + _mvpMatrixLocation = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix"); setMVPMatrixUniform(); _textureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture"); _alphaTextureLocation = pipelineDescriptor.programState->getUniformLocation("u_texture1"); - + setVertexLayout(); updateProgramState(); } diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index a7159387e0..06cb9b874f 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -418,6 +418,11 @@ public: */ TextureAtlas* getTextureAtlas() const { return _textureAtlas; } + /** + * Set ProgramState + */ + void setProgramState(backend::ProgramState *programState); + /** * Sets the weak reference of the TextureAtlas when the sprite is rendered using via SpriteBatchNode. */ diff --git a/cocos/renderer/CCMaterial.cpp b/cocos/renderer/CCMaterial.cpp index 81538d796d..cc54e6ed76 100644 --- a/cocos/renderer/CCMaterial.cpp +++ b/cocos/renderer/CCMaterial.cpp @@ -35,7 +35,7 @@ #include "base/CCProperties.h" #include "base/CCDirector.h" #include "platform/CCFileUtils.h" - +#include "base/CCConsole.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #define strcasecmp _stricmp @@ -194,6 +194,8 @@ bool Material::parsePass(Technique* technique, Properties* passProperties) auto pass = Pass::create(technique); technique->addPass(pass); + pass->setName(passProperties->getId()); + // Pass can have 3 different namespaces: // - one or more "sampler" // - one "renderState" @@ -339,7 +341,22 @@ bool Material::parseShader(Pass* pass, Properties* shaderProperties) auto vertShaderSrc = fu->getStringFromFile(vertShader); auto fragShaderSrc = fu->getStringFromFile(fragShader); - std::string defs = compileTimeDefines; + + auto defineParts = Console::Utility::split(compileTimeDefines, ';'); + std::stringstream ss; + for (auto &p : defineParts) + { + if (p.find("#define ") == std::string::npos) + { + ss << "#define " << p << std::endl; + } + else + { + ss << p << std::endl; + } + } + + std::string defs = ss.str(); vertShaderSrc = defs + "\n" + vertShaderSrc; fragShaderSrc = defs + "\n" + fragShaderSrc; diff --git a/cocos/renderer/CCPass.cpp b/cocos/renderer/CCPass.cpp index 5840d7c2ae..dd5f90410f 100644 --- a/cocos/renderer/CCPass.cpp +++ b/cocos/renderer/CCPass.cpp @@ -120,7 +120,7 @@ Pass* Pass::clone() const pass->_renderState = _renderState; pass->setProgramState(_programState->clone()); - + pass->_vertexAttribBinding = _vertexAttribBinding; CC_SAFE_RETAIN(pass->_vertexAttribBinding); @@ -266,8 +266,8 @@ void Pass::onBeforeVisitCmd() _rendererDepthWrite = renderer->getDepthWrite(); _rendererWinding = renderer->getWinding(); - _renderState.bindPass(this); renderer->setDepthTest(true); + _renderState.bindPass(this); } void Pass::onAfterVisitCmd() diff --git a/cocos/renderer/CCPass.h b/cocos/renderer/CCPass.h index 3e439db2d5..cd6858d8bc 100644 --- a/cocos/renderer/CCPass.h +++ b/cocos/renderer/CCPass.h @@ -100,6 +100,9 @@ public: */ VertexAttribBinding* getVertexAttributeBinding() const; + void setName(const std::string &name) { _name = name; } + const std::string &getName() const { return _name; } + //TODO arnold //uint32_t getHash() const; @@ -147,7 +150,7 @@ protected: Technique * _technique = nullptr; bool _hashDirty = true; RenderState _renderState; - + std::string _name; private: diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index df33fcffee..901968b854 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -263,7 +263,7 @@ list(APPEND GAME_SOURCE # Classes/LabelTest/LabelTestNew.cpp Classes/LayerTest/LayerTest.cpp # Classes/LightTest/LightTest.cpp -# Classes/MaterialSystemTest/MaterialSystemTest.cpp + Classes/MaterialSystemTest/MaterialSystemTest.cpp Classes/MenuTest/MenuTest.cpp Classes/MotionStreakTest/MotionStreakTest.cpp Classes/MultiTouchTest/MultiTouchTest.cpp diff --git a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp index 721fcd0a33..ccb5fd8604 100644 --- a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp +++ b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp @@ -43,14 +43,12 @@ static void printProperties(Properties* properties, int indent); MaterialSystemTest::MaterialSystemTest() { ADD_TEST_CASE(Material_2DEffects); - ADD_TEST_CASE(Material_AutoBindings); + //ADD_TEST_CASE(Material_AutoBindings); ADD_TEST_CASE(Material_setTechnique); ADD_TEST_CASE(Material_clone); ADD_TEST_CASE(Material_MultipleSprite3D); ADD_TEST_CASE(Material_Sprite3DTest); ADD_TEST_CASE(Material_parsePerformance); - ADD_TEST_CASE(Material_invalidate); - ADD_TEST_CASE(Material_renderState); } std::string MaterialSystemBaseTest::title() const @@ -126,22 +124,22 @@ void Material_2DEffects::onEnter() auto spriteBlur = Sprite::create("Images/grossini.png"); spriteBlur->setPositionNormalized(Vec2(0.2f, 0.5f)); this->addChild(spriteBlur); - spriteBlur->setGLProgramState(mat1->getTechniqueByName("blur")->getPassByIndex(0)->getGLProgramState()); + spriteBlur->setProgramState(mat1->getTechniqueByName("blur")->getPassByIndex(0)->getProgramState()); auto spriteOutline = Sprite::create("Images/grossini.png"); spriteOutline->setPositionNormalized(Vec2(0.4f, 0.5f)); this->addChild(spriteOutline); - spriteOutline->setGLProgramState(mat1->getTechniqueByName("outline")->getPassByIndex(0)->getGLProgramState()); + spriteOutline->setProgramState(mat1->getTechniqueByName("outline")->getPassByIndex(0)->getProgramState()); auto spriteNoise = Sprite::create("Images/grossini.png"); spriteNoise->setPositionNormalized(Vec2(0.6f, 0.5f)); this->addChild(spriteNoise); - spriteNoise->setGLProgramState(mat1->getTechniqueByName("noise")->getPassByIndex(0)->getGLProgramState()); + spriteNoise->setProgramState(mat1->getTechniqueByName("noise")->getPassByIndex(0)->getProgramState()); auto spriteEdgeDetect = Sprite::create("Images/grossini.png"); spriteEdgeDetect->setPositionNormalized(Vec2(0.8f, 0.5f)); this->addChild(spriteEdgeDetect); - spriteEdgeDetect->setGLProgramState(mat1->getTechniqueByName("edge_detect")->getPassByIndex(0)->getGLProgramState()); + spriteEdgeDetect->setProgramState(mat1->getTechniqueByName("edge_detect")->getPassByIndex(0)->getProgramState()); // properties is not a "Ref" object CC_SAFE_DELETE(properties); @@ -152,102 +150,102 @@ std::string Material_2DEffects::subtitle() const return "Testing effects on Sprite"; } +//// +//// MARK: Material_AutoBindings +//// // -// MARK: Material_AutoBindings +///* +// * Custom material auto-binding resolver for terrain. +// */ +//class EffectAutoBindingResolver : public GLProgramState::AutoBindingResolver +//{ +// bool resolveAutoBinding(GLProgramState* glProgramState, Node* node, const std::string& uniform, const std::string& autoBinding); // - -/* - * Custom material auto-binding resolver for terrain. - */ -class EffectAutoBindingResolver : public GLProgramState::AutoBindingResolver -{ - bool resolveAutoBinding(GLProgramState* glProgramState, Node* node, const std::string& uniform, const std::string& autoBinding); - - void callbackRadius(GLProgram* glProgram, Uniform* uniform); - void callbackColor(GLProgram* glProgram, Uniform* uniform); -}; - -bool EffectAutoBindingResolver::resolveAutoBinding(GLProgramState* glProgramState, Node* node, const std::string& uniform, const std::string& autoBinding) -{ - if (autoBinding.compare("DYNAMIC_RADIUS")==0) - { - glProgramState->setUniformCallback(uniform, CC_CALLBACK_2(EffectAutoBindingResolver::callbackRadius, this)); - return true; - } - else if (autoBinding.compare("OUTLINE_COLOR")==0) - { - glProgramState->setUniformCallback(uniform, CC_CALLBACK_2(EffectAutoBindingResolver::callbackColor, this)); - return true; - } - return false; -} - -void EffectAutoBindingResolver::callbackRadius(GLProgram* glProgram, Uniform* uniform) -{ - float f = CCRANDOM_0_1() * 10; - glProgram->setUniformLocationWith1f(uniform->location, f); -} - -void EffectAutoBindingResolver::callbackColor(GLProgram* glProgram, Uniform* uniform) -{ - float r = CCRANDOM_0_1(); - float g = CCRANDOM_0_1(); - float b = CCRANDOM_0_1(); - - glProgram->setUniformLocationWith3f(uniform->location, r, g, b); -} - -Material_AutoBindings::Material_AutoBindings() -{ - _resolver = new EffectAutoBindingResolver; -} - -Material_AutoBindings::~Material_AutoBindings() -{ - delete _resolver; -} - - -void Material_AutoBindings::onEnter() -{ - MaterialSystemBaseTest::onEnter(); - -// auto properties = Properties::createNonRefCounted("Materials/2d_effects.material#sample"); - auto properties = Properties::createNonRefCounted("Materials/auto_binding_test.material#sample"); - - // Print the properties of every namespace within this one. - printProperties(properties, 0); - - Material *mat1 = Material::createWithProperties(properties); - - auto spriteBlur = Sprite::create("Images/grossini.png"); - spriteBlur->setPositionNormalized(Vec2(0.2f, 0.5f)); - this->addChild(spriteBlur); - spriteBlur->setGLProgramState(mat1->getTechniqueByName("blur")->getPassByIndex(0)->getGLProgramState()); - - auto spriteOutline = Sprite::create("Images/grossini.png"); - spriteOutline->setPositionNormalized(Vec2(0.4f, 0.5f)); - this->addChild(spriteOutline); - spriteOutline->setGLProgramState(mat1->getTechniqueByName("outline")->getPassByIndex(0)->getGLProgramState()); - - auto spriteNoise = Sprite::create("Images/grossini.png"); - spriteNoise->setPositionNormalized(Vec2(0.6f, 0.5f)); - this->addChild(spriteNoise); - spriteNoise->setGLProgramState(mat1->getTechniqueByName("noise")->getPassByIndex(0)->getGLProgramState()); - - auto spriteEdgeDetect = Sprite::create("Images/grossini.png"); - spriteEdgeDetect->setPositionNormalized(Vec2(0.8f, 0.5f)); - this->addChild(spriteEdgeDetect); - spriteEdgeDetect->setGLProgramState(mat1->getTechniqueByName("edge_detect")->getPassByIndex(0)->getGLProgramState()); - - // properties is not a "Ref" object - CC_SAFE_DELETE(properties); -} - -std::string Material_AutoBindings::subtitle() const -{ - return "Testing auto-bindings uniforms"; -} +// void callbackRadius(GLProgram* glProgram, Uniform* uniform); +// void callbackColor(GLProgram* glProgram, Uniform* uniform); +//}; +// +//bool EffectAutoBindingResolver::resolveAutoBinding(GLProgramState* glProgramState, Node* node, const std::string& uniform, const std::string& autoBinding) +//{ +// if (autoBinding.compare("DYNAMIC_RADIUS")==0) +// { +// glProgramState->setUniformCallback(uniform, CC_CALLBACK_2(EffectAutoBindingResolver::callbackRadius, this)); +// return true; +// } +// else if (autoBinding.compare("OUTLINE_COLOR")==0) +// { +// glProgramState->setUniformCallback(uniform, CC_CALLBACK_2(EffectAutoBindingResolver::callbackColor, this)); +// return true; +// } +// return false; +//} +// +//void EffectAutoBindingResolver::callbackRadius(GLProgram* glProgram, Uniform* uniform) +//{ +// float f = CCRANDOM_0_1() * 10; +// glProgram->setUniformLocationWith1f(uniform->location, f); +//} +// +//void EffectAutoBindingResolver::callbackColor(GLProgram* glProgram, Uniform* uniform) +//{ +// float r = CCRANDOM_0_1(); +// float g = CCRANDOM_0_1(); +// float b = CCRANDOM_0_1(); +// +// glProgram->setUniformLocationWith3f(uniform->location, r, g, b); +//} +// +//Material_AutoBindings::Material_AutoBindings() +//{ +// _resolver = new EffectAutoBindingResolver; +//} +// +//Material_AutoBindings::~Material_AutoBindings() +//{ +// delete _resolver; +//} +// +// +//void Material_AutoBindings::onEnter() +//{ +// MaterialSystemBaseTest::onEnter(); +// +//// auto properties = Properties::createNonRefCounted("Materials/2d_effects.material#sample"); +// auto properties = Properties::createNonRefCounted("Materials/auto_binding_test.material#sample"); +// +// // Print the properties of every namespace within this one. +// printProperties(properties, 0); +// +// Material *mat1 = Material::createWithProperties(properties); +// +// auto spriteBlur = Sprite::create("Images/grossini.png"); +// spriteBlur->setPositionNormalized(Vec2(0.2f, 0.5f)); +// this->addChild(spriteBlur); +// spriteBlur->setGLProgramState(mat1->getTechniqueByName("blur")->getPassByIndex(0)->getGLProgramState()); +// +// auto spriteOutline = Sprite::create("Images/grossini.png"); +// spriteOutline->setPositionNormalized(Vec2(0.4f, 0.5f)); +// this->addChild(spriteOutline); +// spriteOutline->setGLProgramState(mat1->getTechniqueByName("outline")->getPassByIndex(0)->getGLProgramState()); +// +// auto spriteNoise = Sprite::create("Images/grossini.png"); +// spriteNoise->setPositionNormalized(Vec2(0.6f, 0.5f)); +// this->addChild(spriteNoise); +// spriteNoise->setGLProgramState(mat1->getTechniqueByName("noise")->getPassByIndex(0)->getGLProgramState()); +// +// auto spriteEdgeDetect = Sprite::create("Images/grossini.png"); +// spriteEdgeDetect->setPositionNormalized(Vec2(0.8f, 0.5f)); +// this->addChild(spriteEdgeDetect); +// spriteEdgeDetect->setGLProgramState(mat1->getTechniqueByName("edge_detect")->getPassByIndex(0)->getGLProgramState()); +// +// // properties is not a "Ref" object +// CC_SAFE_DELETE(properties); +//} +// +//std::string Material_AutoBindings::subtitle() const +//{ +// return "Testing auto-bindings uniforms"; +//} // // @@ -304,9 +302,7 @@ void Material_setTechnique::changeMaterial(float dt) break; } - _techniqueState++; - if (_techniqueState>2) - _techniqueState = 0; + _techniqueState = (_techniqueState + 1) % 3; } // @@ -333,7 +329,7 @@ void Material_clone::onEnter() sprite2->setScale(3); this->addChild(sprite2); sprite2->setPositionNormalized(Vec2(0.5, 0.5)); - sprite2->setMaterial(mat); + sprite2->setMaterial(mat->clone()); sprite2->runAction(repeat->clone()); // sprite 3... using cloned material @@ -446,131 +442,6 @@ std::string Material_parsePerformance::subtitle() const return "Testing parsing performance"; } -// -// -// -void Material_invalidate::onEnter() -{ - MaterialSystemBaseTest::onEnter(); - - // ORC - auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); - sprite->setScale(5); - sprite->setRotation3D(Vec3(0,180,0)); - addChild(sprite); - sprite->setPositionNormalized(Vec2(0.3f,0.3f)); - - auto rotate = RotateBy::create(5, Vec3(0,360,0)); - auto repeat = RepeatForever::create(rotate); - sprite->runAction(repeat); - - // SPINE - auto skeletonNode = spine::SkeletonAnimation::createWithJsonFile("spine/goblins-pro.json", "spine/goblins.atlas", 1.5f); - skeletonNode->setAnimation(0, "walk", true); - skeletonNode->setSkin("goblin"); - - skeletonNode->setScale(0.25); - skeletonNode->setPositionNormalized(Vec2(0.6f,0.3f)); - this->addChild(skeletonNode); -} - -std::string Material_invalidate::subtitle() const -{ - return "Testing RenderState::StateBlock::invalidate()"; -} - -void Material_invalidate::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) -{ - _customCommand.init(_globalZOrder, transform, flags); - _customCommand.func = []() { - glDisable(GL_DEPTH_TEST); - CHECK_GL_ERROR_DEBUG(); - - glDepthMask(false); - CHECK_GL_ERROR_DEBUG(); - - glEnable(GL_CULL_FACE); - CHECK_GL_ERROR_DEBUG(); - - glCullFace((GLenum)GL_FRONT); - CHECK_GL_ERROR_DEBUG(); - - glFrontFace((GLenum)GL_CW); - CHECK_GL_ERROR_DEBUG(); - - glDisable(GL_BLEND); - CHECK_GL_ERROR_DEBUG(); - - // a non-optimal way is to pass all bits, but that would be very inefficient -// RenderState::StateBlock::invalidate(RenderState::StateBlock::RS_ALL_ONES); - - RenderState::StateBlock::invalidate(RenderState::StateBlock::RS_DEPTH_TEST | - RenderState::StateBlock::RS_DEPTH_WRITE | - RenderState::StateBlock::RS_CULL_FACE | - RenderState::StateBlock::RS_CULL_FACE_SIDE | - RenderState::StateBlock::RS_FRONT_FACE | - RenderState::StateBlock::RS_BLEND); - }; - - renderer->addCommand(&_customCommand); -} - -// -// -// -void Material_renderState::onEnter() -{ - MaterialSystemBaseTest::onEnter(); - - // ORC - auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); - sprite->setScale(5); - sprite->setRotation3D(Vec3(0,180,0)); - addChild(sprite); - sprite->setPositionNormalized(Vec2(0.3f,0.3f)); - - auto rotate = RotateBy::create(5, Vec3(0,360,0)); - auto repeat = RepeatForever::create(rotate); - sprite->runAction(repeat); - - // SPINE - auto skeletonNode = spine::SkeletonAnimation::createWithJsonFile("spine/goblins-pro.json", "spine/goblins.atlas", 1.5f); - skeletonNode->setAnimation(0, "walk", true); - skeletonNode->setSkin("goblin"); - - skeletonNode->setScale(0.25); - skeletonNode->setPositionNormalized(Vec2(0.6f,0.3f)); - this->addChild(skeletonNode); - - _stateBlock.setDepthTest(false); - _stateBlock.setDepthWrite(false); - _stateBlock.setCullFace(true); - _stateBlock.setCullFaceSide(RenderState::CULL_FACE_SIDE_FRONT); - _stateBlock.setFrontFace(RenderState::FRONT_FACE_CW); - _stateBlock.setBlend(false); -} - -std::string Material_renderState::subtitle() const -{ - return "You should see a Spine animation on the right"; -} - -void Material_renderState::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) -{ - _customCommand.init(_globalZOrder, transform, flags); - _customCommand.func = [this]() { - - this->_stateBlock.bind(); - - // should do something... - // and after that, restore - - this->_stateBlock.restore(0); - }; - - renderer->addCommand(&_customCommand); -} - // MARK: Helper functions static void printProperties(Properties* properties, int indent) diff --git a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h index 882cd1683d..02a1c91566 100644 --- a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h +++ b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h @@ -62,21 +62,21 @@ public: virtual std::string subtitle() const override; }; -class EffectAutoBindingResolver; -class Material_AutoBindings : public MaterialSystemBaseTest -{ -public: - CREATE_FUNC(Material_AutoBindings); - - Material_AutoBindings(); - virtual ~Material_AutoBindings(); - - virtual void onEnter() override; - virtual std::string subtitle() const override; - -private: - EffectAutoBindingResolver *_resolver; -}; +//class EffectAutoBindingResolver; +//class Material_AcutoBindings : public MaterialSystemBaseTest +//{ +//public: +// CREATE_FUNC(Material_AutoBindings); +// +// Material_AutoBindings(); +// virtual ~Material_AutoBindings(); +// +// virtual void onEnter() override; +// virtual std::string subtitle() const override; +// +//private: +// EffectAutoBindingResolver *_resolver; +//}; class Material_setTechnique : public MaterialSystemBaseTest { @@ -114,31 +114,5 @@ protected: unsigned int _maxParsingCoumt; }; -class Material_invalidate : public MaterialSystemBaseTest -{ -public: - CREATE_FUNC(Material_invalidate); - - virtual void onEnter() override; - virtual std::string subtitle() const override; - - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override; - - cocos2d::CustomCommand _customCommand; -}; - -class Material_renderState : public MaterialSystemBaseTest -{ -public: - CREATE_FUNC(Material_renderState); - - virtual void onEnter() override; - virtual std::string subtitle() const override; - - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override; - - cocos2d::RenderState::StateBlock _stateBlock; - cocos2d::CustomCommand _customCommand; -}; diff --git a/tests/cpp-tests/Classes/controller.cpp b/tests/cpp-tests/Classes/controller.cpp index aee8312f00..30f7299b4e 100644 --- a/tests/cpp-tests/Classes/controller.cpp +++ b/tests/cpp-tests/Classes/controller.cpp @@ -77,7 +77,7 @@ public: #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) addTest("JNIHelper", []() { return new JNITests(); }); #endif -// addTest("Material System", [](){return new MaterialSystemTest(); }); + addTest("Material System", [](){return new MaterialSystemTest(); }); // addTest("Navigation Mesh", [](){return new NavMeshTests(); }); addTest("Node: BillBoard Test", [](){ return new BillBoardTests(); }); // addTest("Node: Camera 3D Test", [](){ return new Camera3DTests(); }); diff --git a/tests/cpp-tests/Resources/Shaders/example_Blur.fsh b/tests/cpp-tests/Resources/Shaders/example_Blur.fsh index 3841f862b7..c7a2020e0f 100644 --- a/tests/cpp-tests/Resources/Shaders/example_Blur.fsh +++ b/tests/cpp-tests/Resources/Shaders/example_Blur.fsh @@ -9,6 +9,8 @@ uniform vec2 resolution; uniform float blurRadius; uniform float sampleNum; +uniform sampler2D u_texture; + vec4 blur(vec2); void main(void) @@ -34,7 +36,7 @@ vec4 blur(vec2 p) for(float y = -r; y < r; y += sampleStep) { float weight = (r - abs(x)) * (r - abs(y)); - col += texture2D(CC_Texture0, p + vec2(x * unit.x, y * unit.y)) * weight; + col += texture2D(u_texture, p + vec2(x * unit.x, y * unit.y)) * weight; count += weight; } } @@ -42,5 +44,5 @@ vec4 blur(vec2 p) return col / count; } - return texture2D(CC_Texture0, p); + return texture2D(u_texture, p); } diff --git a/tests/cpp-tests/Resources/Shaders/example_EdgeDetection.fsh b/tests/cpp-tests/Resources/Shaders/example_EdgeDetection.fsh index a39f3cfd5e..20e4350c9b 100644 --- a/tests/cpp-tests/Resources/Shaders/example_EdgeDetection.fsh +++ b/tests/cpp-tests/Resources/Shaders/example_EdgeDetection.fsh @@ -6,11 +6,12 @@ varying vec4 v_fragmentColor; varying vec2 v_texCoord; uniform vec2 resolution; +uniform sampler2D u_texture; float lookup(vec2 p, float dx, float dy) { vec2 uv = p.xy + vec2(dx , dy ) / resolution.xy; - vec4 c = texture2D(CC_Texture0, uv.xy); + vec4 c = texture2D(u_texture, uv.xy); return 0.2126*c.r + 0.7152*c.g + 0.0722*c.b; } diff --git a/tests/cpp-tests/Resources/Shaders/example_Noisy.fsh b/tests/cpp-tests/Resources/Shaders/example_Noisy.fsh index e7ef423d65..9cefa36bfa 100644 --- a/tests/cpp-tests/Resources/Shaders/example_Noisy.fsh +++ b/tests/cpp-tests/Resources/Shaders/example_Noisy.fsh @@ -8,6 +8,8 @@ varying vec4 v_fragmentColor; varying vec2 v_texCoord; uniform vec2 resolution; +uniform sampler2D u_texture; +uniform vec4 CC_Time; const float intensity = 0.05; vec3 noise(vec2 uv) @@ -21,6 +23,6 @@ vec3 noise(vec2 uv) void main(void) { gl_FragColor.xyz = intensity * noise(gl_FragCoord.xy / sin(resolution.xy * CC_Time[1] * 0.01)) + (1. - intensity) * - texture2D(CC_Texture0,v_texCoord.xy).xyz; + texture2D(u_texture,v_texCoord.xy).xyz; gl_FragColor.w = 1.; } \ No newline at end of file diff --git a/tests/cpp-tests/Resources/Shaders/example_Outline.fsh b/tests/cpp-tests/Resources/Shaders/example_Outline.fsh index d478eadb36..aa62a7ee02 100644 --- a/tests/cpp-tests/Resources/Shaders/example_Outline.fsh +++ b/tests/cpp-tests/Resources/Shaders/example_Outline.fsh @@ -10,18 +10,20 @@ uniform vec3 u_outlineColor; uniform float u_threshold; uniform float u_radius; +uniform sampler2D u_texture; + void main() { float radius = u_radius; vec4 accum = vec4(0.0); vec4 normal = vec4(0.0); - normal = texture2D(CC_Texture0, vec2(v_texCoord.x, v_texCoord.y)); + normal = texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y)); - accum += texture2D(CC_Texture0, vec2(v_texCoord.x - radius, v_texCoord.y - radius)); - accum += texture2D(CC_Texture0, vec2(v_texCoord.x + radius, v_texCoord.y - radius)); - accum += texture2D(CC_Texture0, vec2(v_texCoord.x + radius, v_texCoord.y + radius)); - accum += texture2D(CC_Texture0, vec2(v_texCoord.x - radius, v_texCoord.y + radius)); + accum += texture2D(u_texture, vec2(v_texCoord.x - radius, v_texCoord.y - radius)); + accum += texture2D(u_texture, vec2(v_texCoord.x + radius, v_texCoord.y - radius)); + accum += texture2D(u_texture, vec2(v_texCoord.x + radius, v_texCoord.y + radius)); + accum += texture2D(u_texture, vec2(v_texCoord.x - radius, v_texCoord.y + radius)); accum *= u_threshold; accum.rgb = u_outlineColor * accum.a; diff --git a/tests/cpp-tests/Resources/Shaders/example_Simple.vsh b/tests/cpp-tests/Resources/Shaders/example_Simple.vsh index d6b899fd45..cfa80395c2 100644 --- a/tests/cpp-tests/Resources/Shaders/example_Simple.vsh +++ b/tests/cpp-tests/Resources/Shaders/example_Simple.vsh @@ -10,9 +10,11 @@ varying vec4 v_fragmentColor; varying vec2 v_texCoord; #endif +uniform mat4 u_MVPMatrix; + void main() { - gl_Position = CC_PMatrix * a_position; + gl_Position = u_MVPMatrix * a_position; v_fragmentColor = a_color; v_texCoord = a_texCoord; } diff --git a/tests/cpp-tests/Resources/Shaders3D/3d_position_normal_tex.vert b/tests/cpp-tests/Resources/Shaders3D/3d_position_normal_tex.vert index ce6aa82a48..6387b4bee0 100644 --- a/tests/cpp-tests/Resources/Shaders3D/3d_position_normal_tex.vert +++ b/tests/cpp-tests/Resources/Shaders3D/3d_position_normal_tex.vert @@ -20,9 +20,12 @@ varying vec3 v_vertexToSpotLightDirection[MAX_SPOT_LIGHT_NUM]; varying vec3 v_normal; #endif +uniform mat4 u_MVMatrix; +uniform mat4 u_PMatrix; +uniform mat3 u_NormalMatrix; void main(void) { - vec4 ePosition = CC_MVMatrix * a_position; + vec4 ePosition = u_MVMatrix * a_position; #if (MAX_POINT_LIGHT_NUM > 0) for (int i = 0; i < MAX_POINT_LIGHT_NUM; ++i) { @@ -38,11 +41,11 @@ void main(void) #endif #if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0)) - v_normal = CC_NormalMatrix * a_normal; + v_normal = u_NormalMatrix * a_normal; #endif TextureCoordOut = a_texCoord; TextureCoordOut.y = 1.0 - TextureCoordOut.y; - gl_Position = CC_PMatrix * ePosition; + gl_Position = u_PMatrix * ePosition; } From c35c4e23471df9a69a8eb37cd44a822f26f18953 Mon Sep 17 00:00:00 2001 From: Arnold <397136899@qq.com> Date: Thu, 14 Mar 2019 16:22:54 +0800 Subject: [PATCH 02/18] fix ccpass --- cocos/3d/CCMesh.cpp | 14 ++++- cocos/3d/CCMesh.h | 8 +-- cocos/3d/CCVertexAttribBinding.cpp | 9 +-- cocos/3d/CCVertexAttribBinding.h | 4 +- cocos/renderer/CCCustomCommand.h | 2 + cocos/renderer/CCMaterial.cpp | 6 +- cocos/renderer/CCMaterial.h | 2 +- cocos/renderer/CCMeshCommand.cpp | 6 ++ cocos/renderer/CCMeshCommand.h | 3 + cocos/renderer/CCPass.cpp | 58 ++++++++++++------- cocos/renderer/CCPass.h | 24 ++++---- cocos/renderer/CCRenderCommand.h | 4 ++ cocos/renderer/CCRenderState.cpp | 8 +-- cocos/renderer/CCRenderState.h | 5 +- .../backend/opengl/CommandBufferGL.cpp | 2 +- .../MaterialSystemTest/MaterialSystemTest.cpp | 2 +- 16 files changed, 99 insertions(+), 58 deletions(-) diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index 2c160d1706..15455f14a6 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -322,11 +322,18 @@ void Mesh::setMaterial(Material* material) _material = material; CC_SAFE_RETAIN(_material); } + _meshCommands.clear(); if (_material) { for (auto technique: _material->getTechniques()) { + //allocate MeshCommand vector for technique + //allocate MeshCommand for each pass + _meshCommands[technique->getName()] = std::vector(technique->getPasses().size()); + auto &list = _meshCommands[technique->getName()]; + + int i = 0; for (auto pass: technique->getPasses()) { #ifdef COCOS2D_DEBUG @@ -341,8 +348,9 @@ void Mesh::setMaterial(Material* material) } #endif //TODO - auto vertexAttribBinding = VertexAttribBinding::create(_meshIndexData, pass); + auto vertexAttribBinding = VertexAttribBinding::create(_meshIndexData, pass, &list[i]); pass->setVertexAttribBinding(vertexAttribBinding); + i += 1; } } } @@ -413,8 +421,8 @@ void Mesh::draw(Renderer* renderer, float globalZOrder, const Mat4& transform, u setLightUniforms(pass, scene, color, lightMask); } } - - _material->draw(globalZ, + auto &commands = _meshCommands[technique->getName()]; + _material->draw(commands.data(), globalZ, getVertexBuffer(), getIndexBuffer(), getPrimitiveType(), diff --git a/cocos/3d/CCMesh.h b/cocos/3d/CCMesh.h index cf1d8c6d6f..2d5bdeddeb 100644 --- a/cocos/3d/CCMesh.h +++ b/cocos/3d/CCMesh.h @@ -247,18 +247,18 @@ protected: bool _force2DQueue; // add this mesh to 2D render queue std::string _name; - //MeshCommand _meshCommand; MeshIndexData* _meshIndexData; //GLProgramState* _glProgramState; BlendFunc _blend; bool _blendDirty; Material* _material; AABB _aabb; - std::function _visibleChanged; + std::function _visibleChanged; + std::unordered_map > _meshCommands; ///light parameters - std::vector _dirLightUniformColorValues; - std::vector _dirLightUniformDirValues; + std::vector _dirLightUniformColorValues; + std::vector _dirLightUniformDirValues; std::vector _pointLightUniformColorValues; std::vector _pointLightUniformPositionValues; diff --git a/cocos/3d/CCVertexAttribBinding.cpp b/cocos/3d/CCVertexAttribBinding.cpp index de8d16f8e0..cc580971a8 100644 --- a/cocos/3d/CCVertexAttribBinding.cpp +++ b/cocos/3d/CCVertexAttribBinding.cpp @@ -58,7 +58,7 @@ VertexAttribBinding::~VertexAttribBinding() } } -VertexAttribBinding* VertexAttribBinding::create(MeshIndexData* meshIndexData, Pass* pass) +VertexAttribBinding* VertexAttribBinding::create(MeshIndexData* meshIndexData, Pass* pass, MeshCommand *command) { CCASSERT(meshIndexData && pass && pass->getProgramState(), "Invalid MeshIndexData and/or programState"); @@ -71,12 +71,13 @@ VertexAttribBinding* VertexAttribBinding::create(MeshIndexData* meshIndexData, P if (b->_meshIndexData == meshIndexData && b->_programState == pass->getProgramState()) { // Found a match! + command->getPipelineDescriptor().vertexLayout = *b->_vertexLayout; return b; } } b = new (std::nothrow) VertexAttribBinding(); - if (b && b->init(meshIndexData, pass)) + if (b && b->init(meshIndexData, pass, command)) { b->autorelease(); __vertexAttribBindingCache.push_back(b); @@ -85,14 +86,14 @@ VertexAttribBinding* VertexAttribBinding::create(MeshIndexData* meshIndexData, P return b; } -bool VertexAttribBinding::init(MeshIndexData* meshIndexData, Pass* pass) +bool VertexAttribBinding::init(MeshIndexData* meshIndexData, Pass* pass, MeshCommand *command) { CCASSERT(meshIndexData && pass && pass->getProgramState(), "Invalid arguments"); auto programState = pass->getProgramState(); - _vertexLayout = pass->getVertexLayout(); + _vertexLayout = &command->getPipelineDescriptor().vertexLayout; // One-time initialization. //TODO arnold diff --git a/cocos/3d/CCVertexAttribBinding.h b/cocos/3d/CCVertexAttribBinding.h index 256bcac232..84870761e8 100644 --- a/cocos/3d/CCVertexAttribBinding.h +++ b/cocos/3d/CCVertexAttribBinding.h @@ -72,7 +72,7 @@ public: * * @return A VertexAttribBinding for the requested parameters. */ - static VertexAttribBinding* create(MeshIndexData* meshIndexData, Pass *pass); + static VertexAttribBinding* create(MeshIndexData* meshIndexData, Pass *pass, MeshCommand *); /** * Binds this vertex array object. @@ -107,7 +107,7 @@ private: */ VertexAttribBinding& operator=(const VertexAttribBinding&); - bool init(MeshIndexData* meshIndexData, Pass *pass); + bool init(MeshIndexData* meshIndexData, Pass *pass, MeshCommand *); void setVertexAttribPointer(const std::string& name, backend::VertexFormat type, GLboolean normalized, int offset, int flag); backend::AttributeBindInfo* getVertexAttribValue(const std::string &name); void parseAttributes(); diff --git a/cocos/renderer/CCCustomCommand.h b/cocos/renderer/CCCustomCommand.h index 10b53fa800..9e1d7f638a 100644 --- a/cocos/renderer/CCCustomCommand.h +++ b/cocos/renderer/CCCustomCommand.h @@ -71,6 +71,8 @@ public: /**Destructor.*/ ~CustomCommand(); + CustomCommand(const CustomCommand &) = default; + public: /** TODO: should remove it. diff --git a/cocos/renderer/CCMaterial.cpp b/cocos/renderer/CCMaterial.cpp index cc54e6ed76..3d61874c0b 100644 --- a/cocos/renderer/CCMaterial.cpp +++ b/cocos/renderer/CCMaterial.cpp @@ -118,13 +118,15 @@ bool Material::initWithProperties(Properties* materialProperties) return parseProperties(materialProperties); } -void Material::draw(float globalZOrder, backend::Buffer* vertexBuffer, backend::Buffer* indexBuffer, +void Material::draw(MeshCommand* meshCommands, float globalZOrder, backend::Buffer* vertexBuffer, backend::Buffer* indexBuffer, CustomCommand::PrimitiveType primitive, CustomCommand::IndexFormat indexFormat, unsigned int indexCount, const Mat4& modelView) { + int i = 0; for (const auto& pass: _currentTechnique->_passes) { - pass->draw(globalZOrder, vertexBuffer, indexBuffer,primitive, indexFormat, indexCount, modelView); + pass->draw(&meshCommands[i], globalZOrder, vertexBuffer, indexBuffer,primitive, indexFormat, indexCount, modelView); + i++; } } diff --git a/cocos/renderer/CCMaterial.h b/cocos/renderer/CCMaterial.h index 723444485b..ab2c4bf06f 100644 --- a/cocos/renderer/CCMaterial.h +++ b/cocos/renderer/CCMaterial.h @@ -96,7 +96,7 @@ public: */ static Material* createWithProperties(Properties* materialProperties); - void draw(float globalZOrder, backend::Buffer* vertexBuffer, backend::Buffer* indexBuffer, + void draw(MeshCommand* meshCommand, float globalZOrder, backend::Buffer* vertexBuffer, backend::Buffer* indexBuffer, CustomCommand::PrimitiveType primitive, CustomCommand::IndexFormat indexFormat, unsigned int indexCount, const Mat4& modelView); diff --git a/cocos/renderer/CCMeshCommand.cpp b/cocos/renderer/CCMeshCommand.cpp index c0d981e825..c96f5d1792 100644 --- a/cocos/renderer/CCMeshCommand.cpp +++ b/cocos/renderer/CCMeshCommand.cpp @@ -62,6 +62,12 @@ void MeshCommand::init(float globalZOrder) CustomCommand::init(globalZOrder); } +void MeshCommand::init(float globalZOrder, const Mat4 &transform) +{ + CustomCommand::init(globalZOrder); + _mv = transform; +} + MeshCommand::~MeshCommand() { #if CC_ENABLE_CACHE_TEXTURE_DATA diff --git a/cocos/renderer/CCMeshCommand.h b/cocos/renderer/CCMeshCommand.h index 83b6fa1091..a440623baa 100644 --- a/cocos/renderer/CCMeshCommand.h +++ b/cocos/renderer/CCMeshCommand.h @@ -58,6 +58,7 @@ public: MeshCommand(); virtual ~MeshCommand(); + MeshCommand(const MeshCommand &) = default; /** Init function. The render command will be in 2D mode. @@ -65,6 +66,8 @@ public: */ void init(float globalZOrder); + void init(float globalZOrder, const Mat4 &transform); + #if CC_ENABLE_CACHE_TEXTURE_DATA void listenRendererRecreated(EventCustom* event); #endif diff --git a/cocos/renderer/CCPass.cpp b/cocos/renderer/CCPass.cpp index dd5f90410f..188c82c4ed 100644 --- a/cocos/renderer/CCPass.cpp +++ b/cocos/renderer/CCPass.cpp @@ -101,8 +101,7 @@ bool Pass::initWithProgramState(Technique* technique, backend::ProgramState *pro Pass::Pass() { - _meshCommand.setBeforeCallback(CC_CALLBACK_0(Pass::onBeforeVisitCmd, this)); - _meshCommand.setAfterCallback(CC_CALLBACK_0(Pass::onAfterVisitCmd, this)); + } Pass::~Pass() @@ -136,6 +135,15 @@ backend::ProgramState* Pass::getProgramState() const return _programState; } +//backend::VertexLayout* Pass::getVertexLayout() +//{ +// if (auto command = _meshCommand.lock()) +// { +// return &(command->getPipelineDescriptor().vertexLayout); +// } +// return nullptr; +//} + void Pass::setProgramState(backend::ProgramState* programState) { if (_programState != programState) @@ -143,7 +151,6 @@ void Pass::setProgramState(backend::ProgramState* programState) CC_SAFE_RELEASE(_programState); _programState = programState; CC_SAFE_RETAIN(_programState); - _meshCommand.getPipelineDescriptor().programState = _programState; initUniformLocations(); _hashDirty = true; } @@ -218,24 +225,36 @@ void Pass::initUniformLocations() // RenderState::bind(this); //} -void Pass::draw(float globalZOrder, backend::Buffer* vertexBuffer, backend::Buffer* indexBuffer, +void Pass::draw(MeshCommand *meshCommand, float globalZOrder, backend::Buffer* vertexBuffer, backend::Buffer* indexBuffer, MeshCommand::PrimitiveType primitive, MeshCommand::IndexFormat indexFormat, unsigned int indexCount, const Mat4& modelView) { - _meshCommand.init(globalZOrder); - _meshCommand.setPrimitiveType(primitive); - _meshCommand.setIndexBuffer(indexBuffer, indexFormat); - _meshCommand.setVertexBuffer(vertexBuffer); - _meshCommand.setIndexDrawInfo(0, indexCount); + meshCommand->setBeforeCallback(CC_CALLBACK_0(Pass::onBeforeVisitCmd, this, meshCommand)); + meshCommand->setAfterCallback(CC_CALLBACK_0(Pass::onAfterVisitCmd, this, meshCommand)); + meshCommand->init(globalZOrder, modelView); + meshCommand->setPrimitiveType(primitive); + meshCommand->setIndexBuffer(indexBuffer, indexFormat); + meshCommand->setVertexBuffer(vertexBuffer); + meshCommand->setIndexDrawInfo(0, indexCount); + meshCommand->getPipelineDescriptor().programState = _programState; + + + auto *renderer = Director::getInstance()->getRenderer(); + + renderer->addCommand(meshCommand); +} + +void Pass::updateMVPUniform(const Mat4& modelView) +{ auto &matrixP = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); auto mvp = matrixP * modelView; _programState->setUniform(_locMVPMatrix, mvp.m, sizeof(mvp.m)); - if (_locMVMatrix) + if (_locMVMatrix) { _programState->setUniform(_locMVMatrix, modelView.m, sizeof(modelView.m)); } - + if (_locPMatrix) { _programState->setUniform(_locPMatrix, matrixP.m, sizeof(matrixP.m)); @@ -247,17 +266,11 @@ void Pass::draw(float globalZOrder, backend::Buffer* vertexBuffer, backend::Buff _programState->setUniform(_locNormalMatrix, normalMatrix.data(), sizeof(normalMatrix[0]) * normalMatrix.size()); } - auto *renderer = Director::getInstance()->getRenderer(); - - renderer->addCommand(&_meshCommand); } -void Pass::onBeforeVisitCmd() +void Pass::onBeforeVisitCmd(MeshCommand *command) { auto *renderer = Director::getInstance()->getRenderer(); - //_oldDepthEnabledState = renderer->getDepthTest(); - - auto &pipelineDescriptor = _meshCommand.getPipelineDescriptor(); _rendererDepthTestEnabled = renderer->getDepthTest(); _rendererDepthCmpFunc = renderer->getDepthCompareFunction(); @@ -265,15 +278,16 @@ void Pass::onBeforeVisitCmd() _rendererDepthWrite = renderer->getDepthWrite(); _rendererWinding = renderer->getWinding(); - renderer->setDepthTest(true); - _renderState.bindPass(this); + _renderState.bindPass(this, command); + + updateMVPUniform(command->getMV()); } -void Pass::onAfterVisitCmd() +void Pass::onAfterVisitCmd(MeshCommand *command) { auto *renderer = Director::getInstance()->getRenderer(); - _renderState.unbindPass(this); + _renderState.unbindPass(this, command); renderer->setDepthTest(_rendererDepthTestEnabled); renderer->setDepthCompareFunction(_rendererDepthCmpFunc); renderer->setCullMode(_rendererCullMode); diff --git a/cocos/renderer/CCPass.h b/cocos/renderer/CCPass.h index cd6858d8bc..5ee3cff579 100644 --- a/cocos/renderer/CCPass.h +++ b/cocos/renderer/CCPass.h @@ -66,7 +66,7 @@ public: /** Returns the ProgramState */ backend::ProgramState* getProgramState() const; - backend::VertexLayout* getVertexLayout() { return &(_meshCommand.getPipelineDescriptor().vertexLayout); } + //backend::VertexLayout* getVertexLayout(); /** Binds the GLProgramState and the RenderState. This method must be called before call the actual draw call. @@ -74,7 +74,7 @@ public: //void bind(const Mat4& modelView); //void bind(const Mat4& modelView, bool bindAttributes); - void draw(float globalZOrder, backend::Buffer* vertexBuffer, backend::Buffer* indexBuffer, + void draw(MeshCommand *meshCommand, float globalZOrder, backend::Buffer* vertexBuffer, backend::Buffer* indexBuffer, MeshCommand::PrimitiveType primitive, MeshCommand::IndexFormat indexFormat, unsigned int indexCount, const Mat4& modelView); @@ -112,6 +112,7 @@ public: void setTechnique(Technique *technique); + void updateMVPUniform(const Mat4& modelView); void setUniformTexture(uint32_t slot, backend::Texture *); //u_texture void setUniformNormTexture(uint32_t slot, backend::Texture *); //u_texture @@ -145,22 +146,21 @@ protected: void setProgramState(backend::ProgramState* programState); Node* getTarget() const; - VertexAttribBinding* _vertexAttribBinding = nullptr; - MeshCommand _meshCommand; - Technique * _technique = nullptr; - bool _hashDirty = true; - RenderState _renderState; - std::string _name; + VertexAttribBinding* _vertexAttribBinding = nullptr; + backend::ProgramState * _programState = nullptr; + Technique * _technique = nullptr; + bool _hashDirty = true; + RenderState _renderState; + std::string _name; + //std::weak_ptr _meshCommand; private: //bool _oldDepthEnabledState; void initUniformLocations(); - void onBeforeVisitCmd(); - void onAfterVisitCmd(); - - backend::ProgramState* _programState = nullptr; + void onBeforeVisitCmd(MeshCommand *); + void onAfterVisitCmd(MeshCommand *); backend::UniformLocation _locMVPMatrix; backend::UniformLocation _locMVMatrix; diff --git a/cocos/renderer/CCRenderCommand.h b/cocos/renderer/CCRenderCommand.h index 80eecc7bbd..5b5b3de544 100644 --- a/cocos/renderer/CCRenderCommand.h +++ b/cocos/renderer/CCRenderCommand.h @@ -95,6 +95,8 @@ public: // Can use the result to change the descriptor content. inline PipelineDescriptor& getPipelineDescriptor() { return _pipelineDescriptor; } + const Mat4 & getMV() const { return _mv; } + protected: /**Constructor.*/ RenderCommand(); @@ -124,6 +126,8 @@ protected: /** Depth from the model view matrix.*/ float _depth = 0.f; + Mat4 _mv; + PipelineDescriptor _pipelineDescriptor; }; diff --git a/cocos/renderer/CCRenderState.cpp b/cocos/renderer/CCRenderState.cpp index 8e8bda51c7..265decafce 100644 --- a/cocos/renderer/CCRenderState.cpp +++ b/cocos/renderer/CCRenderState.cpp @@ -46,13 +46,13 @@ std::string RenderState::getName() const } -void RenderState::bindPass(Pass* pass) +void RenderState::bindPass(Pass* pass, MeshCommand* command) { CC_ASSERT(pass); assert(pass->_technique && pass->_technique->_material); auto *technique = pass->_technique; auto *material = technique->_material; - auto &pipelineDescriptor = pass->_meshCommand.getPipelineDescriptor(); + auto &pipelineDescriptor = command->getPipelineDescriptor(); //need reset all state //pipelineDescriptor.blendDescriptor.blendEnabled = true; @@ -71,9 +71,9 @@ void RenderState::bindPass(Pass* pass) } -void RenderState::unbindPass(Pass* pass) +void RenderState::unbindPass(Pass* pass, MeshCommand* command) { - auto &pipelineDescriptor = pass->_meshCommand.getPipelineDescriptor(); + auto &pipelineDescriptor = command->getPipelineDescriptor(); RenderState::StateBlock::restore(0, &pipelineDescriptor); } diff --git a/cocos/renderer/CCRenderState.h b/cocos/renderer/CCRenderState.h index a72c1d9ddd..d5fd4f1a22 100644 --- a/cocos/renderer/CCRenderState.h +++ b/cocos/renderer/CCRenderState.h @@ -37,6 +37,7 @@ #include "renderer/CCPipelineDescriptor.h" #include "renderer/backend/Types.h" +#include "renderer/CCMeshCommand.h" NS_CC_BEGIN @@ -64,10 +65,10 @@ public: * Binds the render state for this RenderState and any of its parents, top-down, * for the given pass. */ - void bindPass(Pass* pass); + void bindPass(Pass* pass, MeshCommand *); - void unbindPass(Pass* pass); + void unbindPass(Pass* pass, MeshCommand *); /** * Defines a block of fixed-function render states that can be applied to a diff --git a/cocos/renderer/backend/opengl/CommandBufferGL.cpp b/cocos/renderer/backend/opengl/CommandBufferGL.cpp index 2d0869d335..fa51f036f6 100644 --- a/cocos/renderer/backend/opengl/CommandBufferGL.cpp +++ b/cocos/renderer/backend/opengl/CommandBufferGL.cpp @@ -329,7 +329,7 @@ void CommandBufferGL::bindVertexBuffer(ProgramGL *program) const const auto& vertexLayouts = getVertexLayouts(); for (const auto& vertexBuffer : _vertexBuffers) { - if (! vertexBuffer) + if (! vertexBuffer || attributeInfos.empty()) continue; glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer->getHandler()); diff --git a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp index ccb5fd8604..edee4f295f 100644 --- a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp +++ b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp @@ -329,7 +329,7 @@ void Material_clone::onEnter() sprite2->setScale(3); this->addChild(sprite2); sprite2->setPositionNormalized(Vec2(0.5, 0.5)); - sprite2->setMaterial(mat->clone()); + sprite2->setMaterial(mat); sprite2->runAction(repeat->clone()); // sprite 3... using cloned material From d75c2f3c5ea8ac2ab9de089edb974b2cd40eb566 Mon Sep 17 00:00:00 2001 From: Arnold <397136899@qq.com> Date: Fri, 15 Mar 2019 14:11:50 +0800 Subject: [PATCH 03/18] add uniform callback --- cocos/2d/CCSprite.h | 5 + cocos/renderer/CCMaterial.cpp | 5 +- cocos/renderer/CMakeLists.txt | 1 + cocos/renderer/backend/ProgramState.cpp | 34 + cocos/renderer/backend/ProgramState.h | 36 +- cocos/renderer/backend/Types.cpp | 16 + cocos/renderer/backend/Types.h | 5 + .../backend/opengl/CommandBufferGL.cpp | 7 + .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 619 +++++++----- .../auto/lua_cocos2dx_controller_auto.cpp | 910 ------------------ .../auto/lua_cocos2dx_controller_auto.hpp | 24 - .../MaterialSystemTest/MaterialSystemTest.cpp | 229 +++-- .../MaterialSystemTest/MaterialSystemTest.h | 50 +- 13 files changed, 660 insertions(+), 1281 deletions(-) create mode 100644 cocos/renderer/backend/Types.cpp diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index 06cb9b874f..afbbe1414f 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -423,6 +423,11 @@ public: */ void setProgramState(backend::ProgramState *programState); + /** + * Get current ProgramState + */ + inline backend::ProgramState *getProgramState() const { return _programState; } + /** * Sets the weak reference of the TextureAtlas when the sprite is rendered using via SpriteBatchNode. */ diff --git a/cocos/renderer/CCMaterial.cpp b/cocos/renderer/CCMaterial.cpp index 3d61874c0b..c99e4522bb 100644 --- a/cocos/renderer/CCMaterial.cpp +++ b/cocos/renderer/CCMaterial.cpp @@ -446,11 +446,8 @@ bool Material::parseUniform(backend::ProgramState* programState, Properties* pro case Properties::Type::STRING: default: { - - CCASSERT(false, "auto binding is nolonger supported"); - //TODO arnold // Assume this is a parameter auto-binding. - //programState->setParameterAutoBinding(uniformName, properties->getString()); + programState->setParameterAutoBinding(uniformName, properties->getString()); break; } } diff --git a/cocos/renderer/CMakeLists.txt b/cocos/renderer/CMakeLists.txt index 4025f1a73a..0951a47990 100644 --- a/cocos/renderer/CMakeLists.txt +++ b/cocos/renderer/CMakeLists.txt @@ -68,6 +68,7 @@ set(COCOS_RENDERER_SRC renderer/backend/ShaderModule.cpp renderer/backend/StringUtils.cpp renderer/backend/Texture.cpp + renderer/backend/Types.cpp renderer/backend/VertexLayout.cpp renderer/backend/ProgramCache.cpp renderer/backend/Program.cpp diff --git a/cocos/renderer/backend/ProgramState.cpp b/cocos/renderer/backend/ProgramState.cpp index 5ca55bc4ec..70a89f2fe1 100644 --- a/cocos/renderer/backend/ProgramState.cpp +++ b/cocos/renderer/backend/ProgramState.cpp @@ -52,6 +52,8 @@ namespace { } } +//static field +std::vector ProgramState::_customAutoBindingResolvers; UniformBuffer::UniformBuffer(const backend::UniformInfo &_uniformInfo) : uniformInfo(_uniformInfo) @@ -228,6 +230,11 @@ backend::UniformLocation ProgramState::getUniformLocation(const std::string& uni return _program->getUniformLocation(uniform); } +void ProgramState::setUniformCallback(const backend::UniformLocation& uniformLocation,const UniformCallback& callback) +{ + _callbackUniforms[uniformLocation] = callback; +} + void ProgramState::setUniform(const backend::UniformLocation& uniformLocation, const void* data, uint32_t size) { switch (uniformLocation.shaderStage) @@ -407,5 +414,32 @@ void ProgramState::setTextureArray(int location, const std::vector& sl textureInfo[location] = std::move(info); } +void ProgramState::setParameterAutoBinding(const std::string &uniform, const std::string &autoBinding) +{ + _autoBindings.emplace(uniform, autoBinding); + applyAutoBinding(uniform, autoBinding); +} + +void ProgramState::applyAutoBinding(const std::string &uniformName, const std::string &autoBinding) +{ + bool resolved = false; + for (const auto resolver : _customAutoBindingResolvers) + { + resolved = resolver->resolveAutoBinding(this, uniformName, autoBinding); + if (resolved) break; + } +} + +ProgramState::AutoBindingResolver::AutoBindingResolver() +{ + _customAutoBindingResolvers.emplace_back(this); +} + +ProgramState::AutoBindingResolver::~AutoBindingResolver() +{ + auto it = std::find(std::begin(_customAutoBindingResolvers), std::end(_customAutoBindingResolvers), this); + if (it != std::end(_customAutoBindingResolvers)) _customAutoBindingResolvers.erase(it); +} + CC_BACKEND_END diff --git a/cocos/renderer/backend/ProgramState.h b/cocos/renderer/backend/ProgramState.h index 1c5fc93c7a..3e2e4d850a 100644 --- a/cocos/renderer/backend/ProgramState.h +++ b/cocos/renderer/backend/ProgramState.h @@ -48,6 +48,9 @@ struct TextureInfo class ProgramState : public Ref { public: + + using UniformCallback = std::function; + ProgramState(const std::string& vertexShader, const std::string& fragmentShader); virtual ~ProgramState(); @@ -66,13 +69,27 @@ public: inline std::vector& getVertexUniformInfos() { return _vertexUniformInfos; } inline const std::vector& getFragmentUniformInfos() const { return _fragmentUniformInfos; } + void setUniformCallback(const backend::UniformLocation&, const UniformCallback &); + //set textures void setTexture(const backend::UniformLocation& uniformLocation, uint32_t slot, backend::Texture* texture); void setTextureArray(const backend::UniformLocation& uniformLocation, const std::vector& slots, const std::vector textures); inline const std::unordered_map& getVertexTextureInfos() const { return _vertexTextureInfos; } inline const std::unordered_map& getFragmentTextureInfos() const { return _fragmentTextureInfos; } - + inline const std::unordered_map& getUniformCallbacks() const { return _callbackUniforms; } + + class CC_DLL AutoBindingResolver { + public: + virtual ~AutoBindingResolver(); + //TODO doc + virtual bool resolveAutoBinding(ProgramState *, const std::string &uniformName, const std::string &autoBinding) = 0; + protected: + AutoBindingResolver(); + }; + + void setParameterAutoBinding(const std::string &, const std::string &); + protected: ProgramState(); @@ -89,12 +106,19 @@ protected: void convertUniformData(const backend::UniformInfo& uniformInfo, const void* srcData, uint32_t srcSize, std::vector& uniformData); #endif - backend::Program* _program = nullptr; - std::vector _vertexUniformInfos; - std::vector _fragmentUniformInfos; + void applyAutoBinding(const std::string &, const std::string &); + + backend::Program* _program = nullptr; + std::vector _vertexUniformInfos; + std::vector _fragmentUniformInfos; + std::unordered_map _callbackUniforms; - std::unordered_map _vertexTextureInfos; - std::unordered_map _fragmentTextureInfos; + std::unordered_map _vertexTextureInfos; + std::unordered_map _fragmentTextureInfos; + + std::unordered_map _autoBindings; + + static std::vector _customAutoBindingResolvers; }; CC_BACKEND_END diff --git a/cocos/renderer/backend/Types.cpp b/cocos/renderer/backend/Types.cpp new file mode 100644 index 0000000000..aff36c910e --- /dev/null +++ b/cocos/renderer/backend/Types.cpp @@ -0,0 +1,16 @@ +#include "Types.h" + + +CC_BACKEND_BEGIN + + +bool UniformLocation::operator==(const UniformLocation &other) const +{ + return shaderStage == other.shaderStage && location == other.location; +} + +std::size_t UniformLocation::operator()(const UniformLocation &uniform) const { + return (size_t)(shaderStage) || (size_t)(location & 0xFFFFFFF0); +} + +CC_BACKEND_END diff --git a/cocos/renderer/backend/Types.h b/cocos/renderer/backend/Types.h index 71059d4cc9..d497dbe839 100644 --- a/cocos/renderer/backend/Types.h +++ b/cocos/renderer/backend/Types.h @@ -247,10 +247,15 @@ struct UniformLocation { int location = -1; ShaderStage shaderStage = ShaderStage::VERTEX; + UniformLocation() = default; operator bool() { return location >= 0; } void reset() { location = -1; } + + bool operator == (const UniformLocation &other) const; + std::size_t operator()(const UniformLocation &uniform) const; }; + struct AttributeBindInfo { std::string attributeName; diff --git a/cocos/renderer/backend/opengl/CommandBufferGL.cpp b/cocos/renderer/backend/opengl/CommandBufferGL.cpp index fa51f036f6..eb8ae613b3 100644 --- a/cocos/renderer/backend/opengl/CommandBufferGL.cpp +++ b/cocos/renderer/backend/opengl/CommandBufferGL.cpp @@ -357,7 +357,14 @@ void CommandBufferGL::setUniforms(ProgramGL* program) const { if (_programState) { + auto& callbacks = _programState->getUniformCallbacks(); auto& uniformInfos = _programState->getVertexUniformInfos(); + + for (auto &cb : callbacks) + { + cb.second(_programState, cb.first); + } + int i = 0; for(auto& iter : uniformInfos) { diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 4b129a33bc..83672bce35 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -49000,7 +49000,7 @@ int lua_register_cocos2dx_ActionTween(lua_State* tolua_S) return 1; } -int lua_cocos2dx_AtlasNode_updateAtlasValues(lua_State* tolua_S) +int lua_cocos2dx_AtlasNode_getBlendFunc(lua_State* tolua_S) { int argc = 0; cocos2d::AtlasNode* cobj = nullptr; @@ -49020,7 +49020,7 @@ int lua_cocos2dx_AtlasNode_updateAtlasValues(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_getBlendFunc'", nullptr); return 0; } #endif @@ -49030,19 +49030,19 @@ int lua_cocos2dx_AtlasNode_updateAtlasValues(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AtlasNode_getBlendFunc'", nullptr); return 0; } - cobj->updateAtlasValues(); - lua_settop(tolua_S, 1); + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + blendfunc_to_luaval(tolua_S, ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AtlasNode:updateAtlasValues",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AtlasNode:getBlendFunc",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_getBlendFunc'.",&tolua_err); #endif return 0; @@ -49300,7 +49300,7 @@ int lua_cocos2dx_AtlasNode_getTextureAtlas(lua_State* tolua_S) return 0; } -int lua_cocos2dx_AtlasNode_getBlendFunc(lua_State* tolua_S) +int lua_cocos2dx_AtlasNode_updateAtlasValues(lua_State* tolua_S) { int argc = 0; cocos2d::AtlasNode* cobj = nullptr; @@ -49320,7 +49320,7 @@ int lua_cocos2dx_AtlasNode_getBlendFunc(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_getBlendFunc'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'", nullptr); return 0; } #endif @@ -49330,19 +49330,19 @@ int lua_cocos2dx_AtlasNode_getBlendFunc(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AtlasNode_getBlendFunc'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'", nullptr); return 0; } - const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); - blendfunc_to_luaval(tolua_S, ret); + cobj->updateAtlasValues(); + lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AtlasNode:getBlendFunc",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AtlasNode:updateAtlasValues",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_getBlendFunc'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'.",&tolua_err); #endif return 0; @@ -49645,13 +49645,13 @@ int lua_register_cocos2dx_AtlasNode(lua_State* tolua_S) tolua_beginmodule(tolua_S,"AtlasNode"); tolua_function(tolua_S,"new",lua_cocos2dx_AtlasNode_constructor); - tolua_function(tolua_S,"updateAtlasValues",lua_cocos2dx_AtlasNode_updateAtlasValues); + tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_AtlasNode_getBlendFunc); tolua_function(tolua_S,"initWithTileFile",lua_cocos2dx_AtlasNode_initWithTileFile); tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_AtlasNode_setBlendFunc); tolua_function(tolua_S,"setTextureAtlas",lua_cocos2dx_AtlasNode_setTextureAtlas); tolua_function(tolua_S,"getTexture",lua_cocos2dx_AtlasNode_getTexture); tolua_function(tolua_S,"getTextureAtlas",lua_cocos2dx_AtlasNode_getTextureAtlas); - tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_AtlasNode_getBlendFunc); + tolua_function(tolua_S,"updateAtlasValues",lua_cocos2dx_AtlasNode_updateAtlasValues); tolua_function(tolua_S,"setTexture",lua_cocos2dx_AtlasNode_setTexture); tolua_function(tolua_S,"initWithTexture",lua_cocos2dx_AtlasNode_initWithTexture); tolua_function(tolua_S,"getQuadsToDraw",lua_cocos2dx_AtlasNode_getQuadsToDraw); @@ -61737,7 +61737,7 @@ int lua_cocos2dx_MotionStreak_reset(lua_State* tolua_S) return 0; } -int lua_cocos2dx_MotionStreak_setTexture(lua_State* tolua_S) +int lua_cocos2dx_MotionStreak_getBlendFunc(lua_State* tolua_S) { int argc = 0; cocos2d::MotionStreak* cobj = nullptr; @@ -61757,32 +61757,29 @@ int lua_cocos2dx_MotionStreak_setTexture(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_setTexture'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_getBlendFunc'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 0) { - cocos2d::Texture2D* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "cc.MotionStreak:setTexture"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_MotionStreak_setTexture'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_MotionStreak_getBlendFunc'", nullptr); return 0; } - cobj->setTexture(arg0); - lua_settop(tolua_S, 1); + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + blendfunc_to_luaval(tolua_S, ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MotionStreak:setTexture",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MotionStreak:getBlendFunc",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_setTexture'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_getBlendFunc'.",&tolua_err); #endif return 0; @@ -61984,7 +61981,7 @@ int lua_cocos2dx_MotionStreak_setStartingPositionInitialized(lua_State* tolua_S) return 0; } -int lua_cocos2dx_MotionStreak_getBlendFunc(lua_State* tolua_S) +int lua_cocos2dx_MotionStreak_setTexture(lua_State* tolua_S) { int argc = 0; cocos2d::MotionStreak* cobj = nullptr; @@ -62004,29 +62001,32 @@ int lua_cocos2dx_MotionStreak_getBlendFunc(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_getBlendFunc'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_setTexture'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 0) + if (argc == 1) { + cocos2d::Texture2D* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "cc.MotionStreak:setTexture"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_MotionStreak_getBlendFunc'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_MotionStreak_setTexture'", nullptr); return 0; } - const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); - blendfunc_to_luaval(tolua_S, ret); + cobj->setTexture(arg0); + lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MotionStreak:getBlendFunc",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MotionStreak:setTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_getBlendFunc'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_setTexture'.",&tolua_err); #endif return 0; @@ -62482,12 +62482,12 @@ int lua_register_cocos2dx_MotionStreak(lua_State* tolua_S) tolua_beginmodule(tolua_S,"MotionStreak"); tolua_function(tolua_S,"new",lua_cocos2dx_MotionStreak_constructor); tolua_function(tolua_S,"reset",lua_cocos2dx_MotionStreak_reset); - tolua_function(tolua_S,"setTexture",lua_cocos2dx_MotionStreak_setTexture); + tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_MotionStreak_getBlendFunc); tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_MotionStreak_setBlendFunc); tolua_function(tolua_S,"tintWithColor",lua_cocos2dx_MotionStreak_tintWithColor); tolua_function(tolua_S,"getTexture",lua_cocos2dx_MotionStreak_getTexture); tolua_function(tolua_S,"setStartingPositionInitialized",lua_cocos2dx_MotionStreak_setStartingPositionInitialized); - tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_MotionStreak_getBlendFunc); + tolua_function(tolua_S,"setTexture",lua_cocos2dx_MotionStreak_setTexture); tolua_function(tolua_S,"isStartingPositionInitialized",lua_cocos2dx_MotionStreak_isStartingPositionInitialized); tolua_function(tolua_S,"isFastMode",lua_cocos2dx_MotionStreak_isFastMode); tolua_function(tolua_S,"getStroke",lua_cocos2dx_MotionStreak_getStroke); @@ -73663,6 +73663,56 @@ int lua_cocos2dx_Sprite_setFlippedX(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Sprite_setProgramState(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Sprite* 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.Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setProgramState'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::backend::ProgramState* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.ProgramState",&arg0, "cc.Sprite:setProgramState"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Sprite_setProgramState'", nullptr); + return 0; + } + cobj->setProgramState(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite:setProgramState",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setProgramState'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Sprite_getResourceType(lua_State* tolua_S) { int argc = 0; @@ -75616,6 +75666,7 @@ int lua_register_cocos2dx_Sprite(lua_State* tolua_S) tolua_function(tolua_S,"getTexture",lua_cocos2dx_Sprite_getTexture); tolua_function(tolua_S,"setFlippedY",lua_cocos2dx_Sprite_setFlippedY); tolua_function(tolua_S,"setFlippedX",lua_cocos2dx_Sprite_setFlippedX); + tolua_function(tolua_S,"setProgramState",lua_cocos2dx_Sprite_setProgramState); tolua_function(tolua_S,"getResourceType",lua_cocos2dx_Sprite_getResourceType); tolua_function(tolua_S,"setDisplayFrameWithAnimationName",lua_cocos2dx_Sprite_setDisplayFrameWithAnimationName); tolua_function(tolua_S,"getBatchNode",lua_cocos2dx_Sprite_getBatchNode); @@ -87665,21 +87716,24 @@ int lua_cocos2dx_RenderState_unbindPass(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 2) { cocos2d::Pass* arg0; + cocos2d::MeshCommand* arg1; ok &= luaval_to_object(tolua_S, 2, "cc.Pass",&arg0, "cc.RenderState:unbindPass"); + + ok &= luaval_to_object(tolua_S, 3, "cc.MeshCommand",&arg1, "cc.RenderState:unbindPass"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_RenderState_unbindPass'", nullptr); return 0; } - cobj->unbindPass(arg0); + cobj->unbindPass(arg0, arg1); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:unbindPass",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:unbindPass",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 @@ -87715,21 +87769,24 @@ int lua_cocos2dx_RenderState_bindPass(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 2) { cocos2d::Pass* arg0; + cocos2d::MeshCommand* arg1; ok &= luaval_to_object(tolua_S, 2, "cc.Pass",&arg0, "cc.RenderState:bindPass"); + + ok &= luaval_to_object(tolua_S, 3, "cc.MeshCommand",&arg1, "cc.RenderState:bindPass"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_RenderState_bindPass'", nullptr); return 0; } - cobj->bindPass(arg0); + cobj->bindPass(arg0, arg1); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:bindPass",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:bindPass",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 @@ -88274,39 +88331,42 @@ int lua_cocos2dx_Material_draw(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 7) + if (argc == 8) { - double arg0; - cocos2d::backend::Buffer* arg1; + cocos2d::MeshCommand* arg0; + double arg1; cocos2d::backend::Buffer* arg2; - cocos2d::backend::PrimitiveType arg3; - cocos2d::backend::IndexFormat arg4; - unsigned int arg5; - cocos2d::Mat4 arg6; + cocos2d::backend::Buffer* arg3; + cocos2d::backend::PrimitiveType arg4; + cocos2d::backend::IndexFormat arg5; + unsigned int arg6; + cocos2d::Mat4 arg7; - ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Material:draw"); + ok &= luaval_to_object(tolua_S, 2, "cc.MeshCommand",&arg0, "cc.Material:draw"); - ok &= luaval_to_object(tolua_S, 3, "cc.Buffer",&arg1, "cc.Material:draw"); + ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.Material:draw"); ok &= luaval_to_object(tolua_S, 4, "cc.Buffer",&arg2, "cc.Material:draw"); - ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "cc.Material:draw"); + ok &= luaval_to_object(tolua_S, 5, "cc.Buffer",&arg3, "cc.Material:draw"); ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "cc.Material:draw"); - ok &= luaval_to_uint32(tolua_S, 7,&arg5, "cc.Material:draw"); + ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5, "cc.Material:draw"); - ok &= luaval_to_mat4(tolua_S, 8, &arg6, "cc.Material:draw"); + ok &= luaval_to_uint32(tolua_S, 8,&arg6, "cc.Material:draw"); + + ok &= luaval_to_mat4(tolua_S, 9, &arg7, "cc.Material:draw"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Material_draw'", nullptr); return 0; } - cobj->draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + cobj->draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Material:draw",argc, 7); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Material:draw",argc, 8); return 0; #if COCOS2D_DEBUG >= 1 @@ -89148,7 +89208,7 @@ int lua_cocos2dx_Pass_getVertexAttributeBinding(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_setUniformPointLightRangeInverse(lua_State* tolua_S) +int lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos(lua_State* tolua_S) { int argc = 0; cocos2d::Pass* cobj = nullptr; @@ -89168,7 +89228,7 @@ int lua_cocos2dx_Pass_setUniformPointLightRangeInverse(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'", nullptr); return 0; } #endif @@ -89182,22 +89242,22 @@ int lua_cocos2dx_Pass_setUniformPointLightRangeInverse(lua_State* tolua_S) #pragma warning NO CONVERSION TO NATIVE FOR void* ok = false; - ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.Pass:setUniformPointLightRangeInverse"); + ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.Pass:setUniformSpotLightOuterAngleCos"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'", nullptr); return 0; } - cobj->setUniformPointLightRangeInverse(arg0, arg1); + cobj->setUniformSpotLightOuterAngleCos(arg0, arg1); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setUniformPointLightRangeInverse",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setUniformSpotLightOuterAngleCos",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'.",&tolua_err); #endif return 0; @@ -89310,6 +89370,103 @@ int lua_cocos2dx_Pass_setUniformMatrixPalette(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Pass_setName(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Pass* 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.Pass",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Pass*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setName'", 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, "cc.Pass:setName"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setName'", nullptr); + return 0; + } + cobj->setName(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setName",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setName'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Pass_getName(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Pass* 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.Pass",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Pass*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_getName'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_getName'", nullptr); + return 0; + } + const std::string& ret = cobj->getName(); + lua_pushlstring(tolua_S,ret.c_str(),ret.length()); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:getName",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_getName'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Pass_setUniformSpotLightRangeInverse(lua_State* tolua_S) { int argc = 0; @@ -89364,6 +89521,53 @@ int lua_cocos2dx_Pass_setUniformSpotLightRangeInverse(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Pass_clone(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Pass* 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.Pass",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Pass*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_clone'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_clone'", nullptr); + return 0; + } + cocos2d::Pass* ret = cobj->clone(); + object_to_luaval(tolua_S, "cc.Pass",(cocos2d::Pass*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:clone",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_clone'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Pass_draw(lua_State* tolua_S) { int argc = 0; @@ -89390,39 +89594,42 @@ int lua_cocos2dx_Pass_draw(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 7) + if (argc == 8) { - double arg0; - cocos2d::backend::Buffer* arg1; + cocos2d::MeshCommand* arg0; + double arg1; cocos2d::backend::Buffer* arg2; - cocos2d::backend::PrimitiveType arg3; - cocos2d::backend::IndexFormat arg4; - unsigned int arg5; - cocos2d::Mat4 arg6; + cocos2d::backend::Buffer* arg3; + cocos2d::backend::PrimitiveType arg4; + cocos2d::backend::IndexFormat arg5; + unsigned int arg6; + cocos2d::Mat4 arg7; - ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Pass:draw"); + ok &= luaval_to_object(tolua_S, 2, "cc.MeshCommand",&arg0, "cc.Pass:draw"); - ok &= luaval_to_object(tolua_S, 3, "cc.Buffer",&arg1, "cc.Pass:draw"); + ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.Pass:draw"); ok &= luaval_to_object(tolua_S, 4, "cc.Buffer",&arg2, "cc.Pass:draw"); - ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "cc.Pass:draw"); + ok &= luaval_to_object(tolua_S, 5, "cc.Buffer",&arg3, "cc.Pass:draw"); ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "cc.Pass:draw"); - ok &= luaval_to_uint32(tolua_S, 7,&arg5, "cc.Pass:draw"); + ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5, "cc.Pass:draw"); - ok &= luaval_to_mat4(tolua_S, 8, &arg6, "cc.Pass:draw"); + ok &= luaval_to_uint32(tolua_S, 8,&arg6, "cc.Pass:draw"); + + ok &= luaval_to_mat4(tolua_S, 9, &arg7, "cc.Pass:draw"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_draw'", nullptr); return 0; } - cobj->draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + cobj->draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:draw",argc, 7); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:draw",argc, 8); return 0; #if COCOS2D_DEBUG >= 1 @@ -89432,7 +89639,7 @@ int lua_cocos2dx_Pass_draw(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_getVertexLayout(lua_State* tolua_S) +int lua_cocos2dx_Pass_setUniformPointLightRangeInverse(lua_State* tolua_S) { int argc = 0; cocos2d::Pass* cobj = nullptr; @@ -89452,29 +89659,36 @@ int lua_cocos2dx_Pass_getVertexLayout(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_getVertexLayout'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 0) + if (argc == 2) { + const void* arg0; + unsigned int arg1; + + #pragma warning NO CONVERSION TO NATIVE FOR void* + ok = false; + + ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.Pass:setUniformPointLightRangeInverse"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_getVertexLayout'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'", nullptr); return 0; } - cocos2d::backend::VertexLayout* ret = cobj->getVertexLayout(); - object_to_luaval(tolua_S, "cc.VertexLayout",(cocos2d::backend::VertexLayout*)ret); + cobj->setUniformPointLightRangeInverse(arg0, arg1); + lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:getVertexLayout",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setUniformPointLightRangeInverse",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_getVertexLayout'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'.",&tolua_err); #endif return 0; @@ -89532,7 +89746,7 @@ int lua_cocos2dx_Pass_setUniformNormTexture(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_clone(lua_State* tolua_S) +int lua_cocos2dx_Pass_updateMVPUniform(lua_State* tolua_S) { int argc = 0; cocos2d::Pass* cobj = nullptr; @@ -89552,29 +89766,32 @@ int lua_cocos2dx_Pass_clone(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_clone'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_updateMVPUniform'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 0) + if (argc == 1) { + cocos2d::Mat4 arg0; + + ok &= luaval_to_mat4(tolua_S, 2, &arg0, "cc.Pass:updateMVPUniform"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_clone'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_updateMVPUniform'", nullptr); return 0; } - cocos2d::Pass* ret = cobj->clone(); - object_to_luaval(tolua_S, "cc.Pass",(cocos2d::Pass*)ret); + cobj->updateMVPUniform(arg0); + lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:clone",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:updateMVPUniform",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_clone'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_updateMVPUniform'.",&tolua_err); #endif return 0; @@ -89999,60 +90216,6 @@ int lua_cocos2dx_Pass_setUniformTexture(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Pass* 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.Pass",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Pass*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - const void* arg0; - unsigned int arg1; - - #pragma warning NO CONVERSION TO NATIVE FOR void* - ok = false; - - ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.Pass:setUniformSpotLightOuterAngleCos"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'", nullptr); - return 0; - } - cobj->setUniformSpotLightOuterAngleCos(arg0, arg1); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setUniformSpotLightOuterAngleCos",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Pass_setUniformColor(lua_State* tolua_S) { int argc = 0; @@ -90251,14 +90414,17 @@ int lua_register_cocos2dx_Pass(lua_State* tolua_S) tolua_function(tolua_S,"setUniformSpotLightInnerAngleCos",lua_cocos2dx_Pass_setUniformSpotLightInnerAngleCos); tolua_function(tolua_S,"setTechnique",lua_cocos2dx_Pass_setTechnique); tolua_function(tolua_S,"getVertexAttributeBinding",lua_cocos2dx_Pass_getVertexAttributeBinding); - tolua_function(tolua_S,"setUniformPointLightRangeInverse",lua_cocos2dx_Pass_setUniformPointLightRangeInverse); + tolua_function(tolua_S,"setUniformSpotLightOuterAngleCos",lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos); tolua_function(tolua_S,"setUniformSpotLightDir",lua_cocos2dx_Pass_setUniformSpotLightDir); tolua_function(tolua_S,"setUniformMatrixPalette",lua_cocos2dx_Pass_setUniformMatrixPalette); + tolua_function(tolua_S,"setName",lua_cocos2dx_Pass_setName); + tolua_function(tolua_S,"getName",lua_cocos2dx_Pass_getName); tolua_function(tolua_S,"setUniformSpotLightRangeInverse",lua_cocos2dx_Pass_setUniformSpotLightRangeInverse); - tolua_function(tolua_S,"draw",lua_cocos2dx_Pass_draw); - tolua_function(tolua_S,"getVertexLayout",lua_cocos2dx_Pass_getVertexLayout); - tolua_function(tolua_S,"setUniformNormTexture",lua_cocos2dx_Pass_setUniformNormTexture); tolua_function(tolua_S,"clone",lua_cocos2dx_Pass_clone); + tolua_function(tolua_S,"draw",lua_cocos2dx_Pass_draw); + tolua_function(tolua_S,"setUniformPointLightRangeInverse",lua_cocos2dx_Pass_setUniformPointLightRangeInverse); + tolua_function(tolua_S,"setUniformNormTexture",lua_cocos2dx_Pass_setUniformNormTexture); + tolua_function(tolua_S,"updateMVPUniform",lua_cocos2dx_Pass_updateMVPUniform); tolua_function(tolua_S,"setUniformDirLightDir",lua_cocos2dx_Pass_setUniformDirLightDir); tolua_function(tolua_S,"getProgramState",lua_cocos2dx_Pass_getProgramState); tolua_function(tolua_S,"setUniformSpotLightColor",lua_cocos2dx_Pass_setUniformSpotLightColor); @@ -90267,7 +90433,6 @@ int lua_register_cocos2dx_Pass(lua_State* tolua_S) tolua_function(tolua_S,"setUniformSpotLightPosition",lua_cocos2dx_Pass_setUniformSpotLightPosition); tolua_function(tolua_S,"setVertexAttribBinding",lua_cocos2dx_Pass_setVertexAttribBinding); tolua_function(tolua_S,"setUniformTexture",lua_cocos2dx_Pass_setUniformTexture); - tolua_function(tolua_S,"setUniformSpotLightOuterAngleCos",lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos); tolua_function(tolua_S,"setUniformColor",lua_cocos2dx_Pass_setUniformColor); tolua_function(tolua_S,"setUniformPointLightColor",lua_cocos2dx_Pass_setUniformPointLightColor); tolua_function(tolua_S,"createWithProgramState", lua_cocos2dx_Pass_createWithProgramState); @@ -95466,56 +95631,6 @@ int lua_cocos2dx_TMXMapInfo_setTileSize(lua_State* tolua_S) return 0; } -int lua_cocos2dx_TMXMapInfo_initWithTMXFile(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::TMXMapInfo* 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.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'", 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, "cc.TMXMapInfo:initWithTMXFile"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'", nullptr); - return 0; - } - bool ret = cobj->initWithTMXFile(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TMXMapInfo:initWithTMXFile",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_TMXMapInfo_getOrientation(lua_State* tolua_S) { int argc = 0; @@ -96004,49 +96119,52 @@ int lua_cocos2dx_TMXMapInfo_setHexSideLength(lua_State* tolua_S) return 0; } -int lua_cocos2dx_TMXMapInfo_getTilesets(lua_State* tolua_S) +int lua_cocos2dx_TMXMapInfo_initWithTMXFile(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* 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.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif + cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); + #if COCOS2D_DEBUG >= 1 - if (!cobj) + if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getTilesets'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'", nullptr); return 0; } #endif + argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 0) { - cocos2d::Vector& ret = cobj->getTilesets(); - ccvector_to_luaval(tolua_S, ret); - return 1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.TMXMapInfo:initWithTMXFile"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'", nullptr); + return 0; } - }while(0); - ok = true; - do{ - if (argc == 0) { - const cocos2d::Vector& ret = cobj->getTilesets(); - ccvector_to_luaval(tolua_S, ret); - return 1; - } - }while(0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TMXMapInfo:getTilesets",argc, 0); + bool ret = cobj->initWithTMXFile(arg0); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TMXMapInfo:initWithTMXFile",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getTilesets'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'.",&tolua_err); #endif return 0; @@ -96098,6 +96216,53 @@ int lua_cocos2dx_TMXMapInfo_getParentGID(lua_State* tolua_S) return 0; } +int lua_cocos2dx_TMXMapInfo_getTilesets(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::TMXMapInfo* 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.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; +#endif + cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getTilesets'", nullptr); + return 0; + } +#endif + argc = lua_gettop(tolua_S)-1; + do{ + if (argc == 0) { + cocos2d::Vector& ret = cobj->getTilesets(); + ccvector_to_luaval(tolua_S, ret); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getTilesets(); + ccvector_to_luaval(tolua_S, ret); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TMXMapInfo:getTilesets",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getTilesets'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_TMXMapInfo_setParentElement(lua_State* tolua_S) { int argc = 0; @@ -97345,7 +97510,6 @@ int lua_register_cocos2dx_TMXMapInfo(lua_State* tolua_S) tolua_function(tolua_S,"setCurrentString",lua_cocos2dx_TMXMapInfo_setCurrentString); tolua_function(tolua_S,"getHexSideLength",lua_cocos2dx_TMXMapInfo_getHexSideLength); tolua_function(tolua_S,"setTileSize",lua_cocos2dx_TMXMapInfo_setTileSize); - tolua_function(tolua_S,"initWithTMXFile",lua_cocos2dx_TMXMapInfo_initWithTMXFile); tolua_function(tolua_S,"getOrientation",lua_cocos2dx_TMXMapInfo_getOrientation); tolua_function(tolua_S,"setObjectGroups",lua_cocos2dx_TMXMapInfo_setObjectGroups); tolua_function(tolua_S,"setLayers",lua_cocos2dx_TMXMapInfo_setLayers); @@ -97356,8 +97520,9 @@ int lua_register_cocos2dx_TMXMapInfo(lua_State* tolua_S) tolua_function(tolua_S,"getLayers",lua_cocos2dx_TMXMapInfo_getLayers); tolua_function(tolua_S,"getStaggerAxis",lua_cocos2dx_TMXMapInfo_getStaggerAxis); tolua_function(tolua_S,"setHexSideLength",lua_cocos2dx_TMXMapInfo_setHexSideLength); - tolua_function(tolua_S,"getTilesets",lua_cocos2dx_TMXMapInfo_getTilesets); + tolua_function(tolua_S,"initWithTMXFile",lua_cocos2dx_TMXMapInfo_initWithTMXFile); tolua_function(tolua_S,"getParentGID",lua_cocos2dx_TMXMapInfo_getParentGID); + tolua_function(tolua_S,"getTilesets",lua_cocos2dx_TMXMapInfo_getTilesets); tolua_function(tolua_S,"setParentElement",lua_cocos2dx_TMXMapInfo_setParentElement); tolua_function(tolua_S,"initWithXML",lua_cocos2dx_TMXMapInfo_initWithXML); tolua_function(tolua_S,"setParentGID",lua_cocos2dx_TMXMapInfo_setParentGID); @@ -101014,8 +101179,6 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_ShakyTiles3D(tolua_S); lua_register_cocos2dx_PageTurn3D(tolua_S); lua_register_cocos2dx_PolygonInfo(tolua_S); - lua_register_cocos2dx_TransitionSlideInL(tolua_S); - lua_register_cocos2dx_TransitionSlideInT(tolua_S); lua_register_cocos2dx_Grid3D(tolua_S); lua_register_cocos2dx_EventListenerController(tolua_S); lua_register_cocos2dx_TransitionProgressInOut(tolua_S); @@ -101054,6 +101217,7 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_ComponentLua(tolua_S); lua_register_cocos2dx_MotionStreak3D(tolua_S); lua_register_cocos2dx_EaseOut(tolua_S); + lua_register_cocos2dx_TransitionSlideInL(tolua_S); lua_register_cocos2dx_MenuItemFont(tolua_S); lua_register_cocos2dx_TransitionFadeUp(tolua_S); lua_register_cocos2dx_LayerRadialGradient(tolua_S); @@ -101067,6 +101231,7 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_RotateBy(tolua_S); lua_register_cocos2dx_FileUtils(tolua_S); lua_register_cocos2dx_Sprite(tolua_S); + lua_register_cocos2dx_TransitionSlideInT(tolua_S); lua_register_cocos2dx_ProgressTo(tolua_S); lua_register_cocos2dx_TransitionProgressOutIn(tolua_S); lua_register_cocos2dx_AnimationFrame(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.cpp index 795ca1c207..2c543bc115 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.cpp @@ -3,913 +3,3 @@ #include "base/CCGameController.h" #include "scripting/lua-bindings/manual/tolua_fix.h" #include "scripting/lua-bindings/manual/LuaBasicConversions.h" - -int lua_cocos2dx_controller_Controller_receiveExternalKeyEvent(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Controller* 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.Controller",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_receiveExternalKeyEvent'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - int arg0; - bool arg1; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Controller:receiveExternalKeyEvent"); - - ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.Controller:receiveExternalKeyEvent"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_receiveExternalKeyEvent'", nullptr); - return 0; - } - cobj->receiveExternalKeyEvent(arg0, arg1); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Controller:receiveExternalKeyEvent",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_receiveExternalKeyEvent'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_controller_Controller_getDeviceName(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Controller* 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.Controller",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_getDeviceName'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_getDeviceName'", nullptr); - return 0; - } - const std::string& ret = cobj->getDeviceName(); - lua_pushlstring(tolua_S,ret.c_str(),ret.length()); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Controller:getDeviceName",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getDeviceName'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_controller_Controller_isConnected(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Controller* 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.Controller",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_isConnected'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_isConnected'", nullptr); - return 0; - } - bool ret = cobj->isConnected(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Controller:isConnected",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_isConnected'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_controller_Controller_getDeviceId(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Controller* 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.Controller",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_getDeviceId'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_getDeviceId'", nullptr); - return 0; - } - int ret = cobj->getDeviceId(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Controller:getDeviceId",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getDeviceId'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_controller_Controller_setTag(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Controller* 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.Controller",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_setTag'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - int arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Controller:setTag"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_setTag'", nullptr); - return 0; - } - cobj->setTag(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Controller:setTag",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_setTag'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_controller_Controller_getTag(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Controller* 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.Controller",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_getTag'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_getTag'", nullptr); - return 0; - } - int ret = cobj->getTag(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Controller:getTag",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getTag'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_controller_Controller_startDiscoveryController(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.Controller",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_startDiscoveryController'", nullptr); - return 0; - } - cocos2d::Controller::startDiscoveryController(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Controller:startDiscoveryController",argc, 0); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_startDiscoveryController'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_controller_Controller_stopDiscoveryController(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.Controller",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_stopDiscoveryController'", nullptr); - return 0; - } - cocos2d::Controller::stopDiscoveryController(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Controller:stopDiscoveryController",argc, 0); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_stopDiscoveryController'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_controller_Controller_getControllerByDeviceId(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.Controller",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 1) - { - int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Controller:getControllerByDeviceId"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_getControllerByDeviceId'", nullptr); - return 0; - } - cocos2d::Controller* ret = cocos2d::Controller::getControllerByDeviceId(arg0); - object_to_luaval(tolua_S, "cc.Controller",(cocos2d::Controller*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Controller:getControllerByDeviceId",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getControllerByDeviceId'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_controller_Controller_getControllerByTag(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.Controller",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 1) - { - int arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Controller:getControllerByTag"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_getControllerByTag'", nullptr); - return 0; - } - cocos2d::Controller* ret = cocos2d::Controller::getControllerByTag(arg0); - object_to_luaval(tolua_S, "cc.Controller",(cocos2d::Controller*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Controller:getControllerByTag",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getControllerByTag'.",&tolua_err); -#endif - return 0; -} -static int lua_cocos2dx_controller_Controller_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (Controller)"); - return 0; -} - -int lua_register_cocos2dx_controller_Controller(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.Controller"); - tolua_cclass(tolua_S,"Controller","cc.Controller","",nullptr); - - tolua_beginmodule(tolua_S,"Controller"); - tolua_function(tolua_S,"receiveExternalKeyEvent",lua_cocos2dx_controller_Controller_receiveExternalKeyEvent); - tolua_function(tolua_S,"getDeviceName",lua_cocos2dx_controller_Controller_getDeviceName); - tolua_function(tolua_S,"isConnected",lua_cocos2dx_controller_Controller_isConnected); - tolua_function(tolua_S,"getDeviceId",lua_cocos2dx_controller_Controller_getDeviceId); - tolua_function(tolua_S,"setTag",lua_cocos2dx_controller_Controller_setTag); - tolua_function(tolua_S,"getTag",lua_cocos2dx_controller_Controller_getTag); - tolua_function(tolua_S,"startDiscoveryController", lua_cocos2dx_controller_Controller_startDiscoveryController); - tolua_function(tolua_S,"stopDiscoveryController", lua_cocos2dx_controller_Controller_stopDiscoveryController); - tolua_function(tolua_S,"getControllerByDeviceId", lua_cocos2dx_controller_Controller_getControllerByDeviceId); - tolua_function(tolua_S,"getControllerByTag", lua_cocos2dx_controller_Controller_getControllerByTag); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::Controller).name(); - g_luaType[typeName] = "cc.Controller"; - g_typeCast["Controller"] = "cc.Controller"; - return 1; -} - -int lua_cocos2dx_controller_EventController_getControllerEventType(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventController* 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.EventController",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_getControllerEventType'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventController_getControllerEventType'", nullptr); - return 0; - } - int ret = (int)cobj->getControllerEventType(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:getControllerEventType",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_getControllerEventType'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_controller_EventController_setConnectStatus(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventController* 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.EventController",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_setConnectStatus'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.EventController:setConnectStatus"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventController_setConnectStatus'", nullptr); - return 0; - } - cobj->setConnectStatus(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:setConnectStatus",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_setConnectStatus'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_controller_EventController_isConnected(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventController* 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.EventController",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_isConnected'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventController_isConnected'", nullptr); - return 0; - } - bool ret = cobj->isConnected(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:isConnected",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_isConnected'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_controller_EventController_setKeyCode(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventController* 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.EventController",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_setKeyCode'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - int arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EventController:setKeyCode"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventController_setKeyCode'", nullptr); - return 0; - } - cobj->setKeyCode(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:setKeyCode",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_setKeyCode'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_controller_EventController_getController(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventController* 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.EventController",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_getController'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventController_getController'", nullptr); - return 0; - } - cocos2d::Controller* ret = cobj->getController(); - object_to_luaval(tolua_S, "cc.Controller",(cocos2d::Controller*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:getController",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_getController'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_controller_EventController_getKeyCode(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventController* 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.EventController",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_getKeyCode'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventController_getKeyCode'", nullptr); - return 0; - } - int ret = cobj->getKeyCode(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:getKeyCode",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_getKeyCode'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_controller_EventController_constructor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::EventController* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 3) { - cocos2d::EventController::ControllerEventType arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EventController:EventController"); - - if (!ok) { break; } - cocos2d::Controller* arg1; - ok &= luaval_to_object(tolua_S, 3, "cc.Controller",&arg1, "cc.EventController:EventController"); - - if (!ok) { break; } - bool arg2; - ok &= luaval_to_boolean(tolua_S, 4,&arg2, "cc.EventController:EventController"); - - if (!ok) { break; } - cobj = new cocos2d::EventController(arg0, arg1, arg2); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventController"); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 3) { - cocos2d::EventController::ControllerEventType arg0; - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EventController:EventController"); - - if (!ok) { break; } - cocos2d::Controller* arg1; - ok &= luaval_to_object(tolua_S, 3, "cc.Controller",&arg1, "cc.EventController:EventController"); - - if (!ok) { break; } - int arg2; - ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "cc.EventController:EventController"); - - if (!ok) { break; } - cobj = new cocos2d::EventController(arg0, arg1, arg2); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventController"); - return 1; - } - }while(0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:EventController",argc, 3); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_constructor'.",&tolua_err); -#endif - - return 0; -} - -static int lua_cocos2dx_controller_EventController_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (EventController)"); - return 0; -} - -int lua_register_cocos2dx_controller_EventController(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.EventController"); - tolua_cclass(tolua_S,"EventController","cc.EventController","cc.Event",nullptr); - - tolua_beginmodule(tolua_S,"EventController"); - tolua_function(tolua_S,"new",lua_cocos2dx_controller_EventController_constructor); - tolua_function(tolua_S,"getControllerEventType",lua_cocos2dx_controller_EventController_getControllerEventType); - tolua_function(tolua_S,"setConnectStatus",lua_cocos2dx_controller_EventController_setConnectStatus); - tolua_function(tolua_S,"isConnected",lua_cocos2dx_controller_EventController_isConnected); - tolua_function(tolua_S,"setKeyCode",lua_cocos2dx_controller_EventController_setKeyCode); - tolua_function(tolua_S,"getController",lua_cocos2dx_controller_EventController_getController); - tolua_function(tolua_S,"getKeyCode",lua_cocos2dx_controller_EventController_getKeyCode); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::EventController).name(); - g_luaType[typeName] = "cc.EventController"; - g_typeCast["EventController"] = "cc.EventController"; - return 1; -} - -int lua_cocos2dx_controller_EventListenerController_create(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.EventListenerController",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventListenerController_create'", nullptr); - return 0; - } - cocos2d::EventListenerController* ret = cocos2d::EventListenerController::create(); - object_to_luaval(tolua_S, "cc.EventListenerController",(cocos2d::EventListenerController*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.EventListenerController:create",argc, 0); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventListenerController_create'.",&tolua_err); -#endif - return 0; -} -static int lua_cocos2dx_controller_EventListenerController_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (EventListenerController)"); - return 0; -} - -int lua_register_cocos2dx_controller_EventListenerController(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.EventListenerController"); - tolua_cclass(tolua_S,"EventListenerController","cc.EventListenerController","cc.EventListener",nullptr); - - tolua_beginmodule(tolua_S,"EventListenerController"); - tolua_function(tolua_S,"create", lua_cocos2dx_controller_EventListenerController_create); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::EventListenerController).name(); - g_luaType[typeName] = "cc.EventListenerController"; - g_typeCast["EventListenerController"] = "cc.EventListenerController"; - return 1; -} -TOLUA_API int register_all_cocos2dx_controller(lua_State* tolua_S) -{ - tolua_open(tolua_S); - - tolua_module(tolua_S,"cc",0); - tolua_beginmodule(tolua_S,"cc"); - - lua_register_cocos2dx_controller_EventListenerController(tolua_S); - lua_register_cocos2dx_controller_Controller(tolua_S); - lua_register_cocos2dx_controller_EventController(tolua_S); - - tolua_endmodule(tolua_S); - return 1; -} - -#endif diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.hpp index 4d8bdd50ec..ed9e0e1b1c 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.hpp @@ -12,27 +12,3 @@ extern "C" { #endif int register_all_cocos2dx_controller(lua_State* tolua_S); - - - - - - - - - - - - - - - - - - - - - - -#endif // __cocos2dx_controller_h__ -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) diff --git a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp index edee4f295f..3dd211d99a 100644 --- a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp +++ b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp @@ -43,7 +43,7 @@ static void printProperties(Properties* properties, int indent); MaterialSystemTest::MaterialSystemTest() { ADD_TEST_CASE(Material_2DEffects); - //ADD_TEST_CASE(Material_AutoBindings); + ADD_TEST_CASE(Material_AutoBindings); ADD_TEST_CASE(Material_setTechnique); ADD_TEST_CASE(Material_clone); ADD_TEST_CASE(Material_MultipleSprite3D); @@ -141,6 +141,21 @@ void Material_2DEffects::onEnter() this->addChild(spriteEdgeDetect); spriteEdgeDetect->setProgramState(mat1->getTechniqueByName("edge_detect")->getPassByIndex(0)->getProgramState()); + timeUniforms.clear(); + +#define PUSH_LOCATION(sprite) do { \ + auto programState = sprite->getProgramState(); \ + auto location = programState->getUniformLocation("CC_Time"); \ + timeUniforms.emplace_back(programState, location); \ + }while(0) + + PUSH_LOCATION(spriteBlur); + PUSH_LOCATION(spriteOutline); + PUSH_LOCATION(spriteNoise); + PUSH_LOCATION(spriteEdgeDetect); + + schedule(CC_SCHEDULE_SELECTOR(Material_2DEffects::updateCCTimeUniforms)); + // properties is not a "Ref" object CC_SAFE_DELETE(properties); } @@ -150,102 +165,126 @@ std::string Material_2DEffects::subtitle() const return "Testing effects on Sprite"; } -//// -//// MARK: Material_AutoBindings -//// +void Material_2DEffects::updateCCTimeUniforms(float) +{ + float time = Director::getInstance()->getTotalFrames() * Director::getInstance()->getAnimationInterval(); + Vec4 random(time / 10.0f, time, time * 2.0f, time * 4.0f); + for (auto &loc : timeUniforms) + { + loc.programState->setUniform(loc.location, &random, sizeof(random)); + } +} + // -///* -// * Custom material auto-binding resolver for terrain. -// */ -//class EffectAutoBindingResolver : public GLProgramState::AutoBindingResolver -//{ -// bool resolveAutoBinding(GLProgramState* glProgramState, Node* node, const std::string& uniform, const std::string& autoBinding); +// MARK: Material_AutoBindings // -// void callbackRadius(GLProgram* glProgram, Uniform* uniform); -// void callbackColor(GLProgram* glProgram, Uniform* uniform); -//}; -// -//bool EffectAutoBindingResolver::resolveAutoBinding(GLProgramState* glProgramState, Node* node, const std::string& uniform, const std::string& autoBinding) -//{ -// if (autoBinding.compare("DYNAMIC_RADIUS")==0) -// { -// glProgramState->setUniformCallback(uniform, CC_CALLBACK_2(EffectAutoBindingResolver::callbackRadius, this)); -// return true; -// } -// else if (autoBinding.compare("OUTLINE_COLOR")==0) -// { -// glProgramState->setUniformCallback(uniform, CC_CALLBACK_2(EffectAutoBindingResolver::callbackColor, this)); -// return true; -// } -// return false; -//} -// -//void EffectAutoBindingResolver::callbackRadius(GLProgram* glProgram, Uniform* uniform) -//{ -// float f = CCRANDOM_0_1() * 10; -// glProgram->setUniformLocationWith1f(uniform->location, f); -//} -// -//void EffectAutoBindingResolver::callbackColor(GLProgram* glProgram, Uniform* uniform) -//{ -// float r = CCRANDOM_0_1(); -// float g = CCRANDOM_0_1(); -// float b = CCRANDOM_0_1(); -// -// glProgram->setUniformLocationWith3f(uniform->location, r, g, b); -//} -// -//Material_AutoBindings::Material_AutoBindings() -//{ -// _resolver = new EffectAutoBindingResolver; -//} -// -//Material_AutoBindings::~Material_AutoBindings() -//{ -// delete _resolver; -//} -// -// -//void Material_AutoBindings::onEnter() -//{ -// MaterialSystemBaseTest::onEnter(); -// -//// auto properties = Properties::createNonRefCounted("Materials/2d_effects.material#sample"); -// auto properties = Properties::createNonRefCounted("Materials/auto_binding_test.material#sample"); -// -// // Print the properties of every namespace within this one. -// printProperties(properties, 0); -// -// Material *mat1 = Material::createWithProperties(properties); -// -// auto spriteBlur = Sprite::create("Images/grossini.png"); -// spriteBlur->setPositionNormalized(Vec2(0.2f, 0.5f)); -// this->addChild(spriteBlur); -// spriteBlur->setGLProgramState(mat1->getTechniqueByName("blur")->getPassByIndex(0)->getGLProgramState()); -// -// auto spriteOutline = Sprite::create("Images/grossini.png"); -// spriteOutline->setPositionNormalized(Vec2(0.4f, 0.5f)); -// this->addChild(spriteOutline); -// spriteOutline->setGLProgramState(mat1->getTechniqueByName("outline")->getPassByIndex(0)->getGLProgramState()); -// -// auto spriteNoise = Sprite::create("Images/grossini.png"); -// spriteNoise->setPositionNormalized(Vec2(0.6f, 0.5f)); -// this->addChild(spriteNoise); -// spriteNoise->setGLProgramState(mat1->getTechniqueByName("noise")->getPassByIndex(0)->getGLProgramState()); -// -// auto spriteEdgeDetect = Sprite::create("Images/grossini.png"); -// spriteEdgeDetect->setPositionNormalized(Vec2(0.8f, 0.5f)); -// this->addChild(spriteEdgeDetect); -// spriteEdgeDetect->setGLProgramState(mat1->getTechniqueByName("edge_detect")->getPassByIndex(0)->getGLProgramState()); -// -// // properties is not a "Ref" object -// CC_SAFE_DELETE(properties); -//} -// -//std::string Material_AutoBindings::subtitle() const -//{ -// return "Testing auto-bindings uniforms"; -//} + +/* + * Custom material auto-binding resolver for terrain. + */ +class EffectAutoBindingResolver : public backend::ProgramState::AutoBindingResolver +{ + virtual bool resolveAutoBinding(backend::ProgramState* programState,/* Node* node,*/ const std::string& uniform, const std::string& autoBinding) override; + + void callbackRadius(backend::ProgramState* programState, backend::UniformLocation uniform); + void callbackColor(backend::ProgramState* programState, backend::UniformLocation uniform); +}; + +bool EffectAutoBindingResolver::resolveAutoBinding(backend::ProgramState* programState, /*Node* node,*/ const std::string& uniform, const std::string& autoBinding) +{ + if (autoBinding.compare("DYNAMIC_RADIUS")==0) + { + auto loc = programState->getUniformLocation(uniform); + programState->setUniformCallback(loc, CC_CALLBACK_2(EffectAutoBindingResolver::callbackRadius, this)); + return true; + } + else if (autoBinding.compare("OUTLINE_COLOR")==0) + { + auto loc = programState->getUniformLocation(uniform); + programState->setUniformCallback(loc, CC_CALLBACK_2(EffectAutoBindingResolver::callbackColor, this)); + return true; + } + return false; +} + +void EffectAutoBindingResolver::callbackRadius(backend::ProgramState *programState, backend::UniformLocation uniform) +{ + float f = CCRANDOM_0_1() * 10; + programState->setUniform(uniform, &f, sizeof(f)); +} + +void EffectAutoBindingResolver::callbackColor(backend::ProgramState *programState, backend::UniformLocation uniform) +{ + float r = CCRANDOM_0_1(); + float g = CCRANDOM_0_1(); + float b = CCRANDOM_0_1(); + Vec3 color(r, g, b); + + programState->setUniform(uniform, &color, sizeof(color)); +} + +Material_AutoBindings::Material_AutoBindings() +{ + _resolver = new EffectAutoBindingResolver; +} + +Material_AutoBindings::~Material_AutoBindings() +{ + delete _resolver; +} + + +void Material_AutoBindings::onEnter() +{ + MaterialSystemBaseTest::onEnter(); + +// auto properties = Properties::createNonRefCounted("Materials/2d_effects.material#sample"); + auto properties = Properties::createNonRefCounted("Materials/auto_binding_test.material#sample"); + + // Print the properties of every namespace within this one. + printProperties(properties, 0); + + Material *mat1 = Material::createWithProperties(properties); + + auto spriteBlur = Sprite::create("Images/grossini.png"); + spriteBlur->setPositionNormalized(Vec2(0.2f, 0.5f)); + this->addChild(spriteBlur); + spriteBlur->setProgramState(mat1->getTechniqueByName("blur")->getPassByIndex(0)->getProgramState()); + + auto spriteOutline = Sprite::create("Images/grossini.png"); + spriteOutline->setPositionNormalized(Vec2(0.4f, 0.5f)); + this->addChild(spriteOutline); + spriteOutline->setProgramState(mat1->getTechniqueByName("outline")->getPassByIndex(0)->getProgramState()); + + auto spriteNoise = Sprite::create("Images/grossini.png"); + spriteNoise->setPositionNormalized(Vec2(0.6f, 0.5f)); + this->addChild(spriteNoise); + spriteNoise->setProgramState(mat1->getTechniqueByName("noise")->getPassByIndex(0)->getProgramState()); + + auto spriteEdgeDetect = Sprite::create("Images/grossini.png"); + spriteEdgeDetect->setPositionNormalized(Vec2(0.8f, 0.5f)); + this->addChild(spriteEdgeDetect); + spriteEdgeDetect->setProgramState(mat1->getTechniqueByName("edge_detect")->getPassByIndex(0)->getProgramState()); + + _noiseProgramState = spriteNoise->getProgramState(); + _locationTime = _noiseProgramState->getUniformLocation("CC_Time"); + + schedule(CC_SCHEDULE_SELECTOR(Material_AutoBindings::updateUniformTime)); + // properties is not a "Ref" object + CC_SAFE_DELETE(properties); +} + +std::string Material_AutoBindings::subtitle() const +{ + return "Testing auto-bindings uniforms"; +} + +void Material_AutoBindings::updateUniformTime(float dt) +{ + float time = Director::getInstance()->getTotalFrames() * Director::getInstance()->getAnimationInterval(); + Vec4 random(time / 10.0f, time, time * 2.0f, time * 4.0f); + _noiseProgramState->setUniform(_locationTime, &random, sizeof(random)); +} // // diff --git a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h index 02a1c91566..5262858f9e 100644 --- a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h +++ b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h @@ -26,6 +26,10 @@ #pragma once #include "../BaseTest.h" +#include "renderer/backend/Types.h" +#include "renderer/backend/ProgramState.h" + +#include DEFINE_TEST_SUITE(MaterialSystemTest); @@ -42,6 +46,7 @@ public: virtual void onEnter() override; virtual std::string subtitle() const override; + }; class Material_MultipleSprite3D : public MaterialSystemBaseTest @@ -60,23 +65,38 @@ public: virtual void onEnter() override; virtual std::string subtitle() const override; + void updateCCTimeUniforms(float); + +private: + struct Locations { + Locations(cocos2d::backend::ProgramState *ps, cocos2d::backend::UniformLocation loc) + : programState(ps), location(loc) {} + + cocos2d::backend::ProgramState *programState = nullptr; + cocos2d::backend::UniformLocation location; + }; + std::vector timeUniforms; }; -//class EffectAutoBindingResolver; -//class Material_AcutoBindings : public MaterialSystemBaseTest -//{ -//public: -// CREATE_FUNC(Material_AutoBindings); -// -// Material_AutoBindings(); -// virtual ~Material_AutoBindings(); -// -// virtual void onEnter() override; -// virtual std::string subtitle() const override; -// -//private: -// EffectAutoBindingResolver *_resolver; -//}; +class EffectAutoBindingResolver; +class Material_AutoBindings : public MaterialSystemBaseTest +{ +public: + CREATE_FUNC(Material_AutoBindings); + + Material_AutoBindings(); + virtual ~Material_AutoBindings(); + + virtual void onEnter() override; + virtual std::string subtitle() const override; + + void updateUniformTime(float); + +private: + cocos2d::backend::UniformLocation _locationTime; + EffectAutoBindingResolver *_resolver = nullptr; + cocos2d::backend::ProgramState *_noiseProgramState = nullptr; +}; class Material_setTechnique : public MaterialSystemBaseTest { From 9f55e8ee7b9918d001a6c1644f39347ac2162f40 Mon Sep 17 00:00:00 2001 From: patricejiang Date: Fri, 15 Mar 2019 14:26:27 +0800 Subject: [PATCH 04/18] fix macosx compile error --- cocos/renderer/CCMaterial.cpp | 2 ++ cocos/renderer/CCRenderState.h | 1 + 2 files changed, 3 insertions(+) diff --git a/cocos/renderer/CCMaterial.cpp b/cocos/renderer/CCMaterial.cpp index c99e4522bb..d5b1a178b5 100644 --- a/cocos/renderer/CCMaterial.cpp +++ b/cocos/renderer/CCMaterial.cpp @@ -37,6 +37,8 @@ #include "platform/CCFileUtils.h" #include "base/CCConsole.h" +#include + #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #define strcasecmp _stricmp #endif diff --git a/cocos/renderer/CCRenderState.h b/cocos/renderer/CCRenderState.h index d5fd4f1a22..4005e48b36 100644 --- a/cocos/renderer/CCRenderState.h +++ b/cocos/renderer/CCRenderState.h @@ -43,6 +43,7 @@ NS_CC_BEGIN class Texture2D; class Pass; +class MeshCommand; using CullFaceSide = backend::CullMode; using FrontFace = backend::Winding; From 7280457fbbbe534c28319c6a28626e9d89a5f921 Mon Sep 17 00:00:00 2001 From: patricejiang Date: Fri, 15 Mar 2019 14:37:16 +0800 Subject: [PATCH 05/18] add callback uniform to metal --- cocos/renderer/backend/metal/CommandBufferMTL.mm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cocos/renderer/backend/metal/CommandBufferMTL.mm b/cocos/renderer/backend/metal/CommandBufferMTL.mm index 0d08ab93b8..8e4cd8e8f0 100644 --- a/cocos/renderer/backend/metal/CommandBufferMTL.mm +++ b/cocos/renderer/backend/metal/CommandBufferMTL.mm @@ -385,6 +385,13 @@ void CommandBufferMTL::setUniformBuffer() const { if (_programState) { + auto &callbackUniforms = _programState->getUniformCallbacks(); + + for(auto &cb : callbackUniforms) + { + cb.second(_programState, cb.first); + } + // Uniform buffer is bound to index 1. const auto& vertexUniformBuffer = _renderPipelineMTL->getVertexUniformBuffer(); const auto& vertexUniformInfo = _programState->getVertexUniformInfos(); From e3385e0e581cf4cfbb2a2b0f1ed7e459bef33296 Mon Sep 17 00:00:00 2001 From: Arnold <397136899@qq.com> Date: Fri, 15 Mar 2019 14:51:33 +0800 Subject: [PATCH 06/18] revert binding --- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 617 +++++------- .../auto/lua_cocos2dx_controller_auto.cpp | 910 ++++++++++++++++++ .../auto/lua_cocos2dx_controller_auto.hpp | 24 + 3 files changed, 1160 insertions(+), 391 deletions(-) diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 83672bce35..4b129a33bc 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -49000,7 +49000,7 @@ int lua_register_cocos2dx_ActionTween(lua_State* tolua_S) return 1; } -int lua_cocos2dx_AtlasNode_getBlendFunc(lua_State* tolua_S) +int lua_cocos2dx_AtlasNode_updateAtlasValues(lua_State* tolua_S) { int argc = 0; cocos2d::AtlasNode* cobj = nullptr; @@ -49020,7 +49020,7 @@ int lua_cocos2dx_AtlasNode_getBlendFunc(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_getBlendFunc'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'", nullptr); return 0; } #endif @@ -49030,19 +49030,19 @@ int lua_cocos2dx_AtlasNode_getBlendFunc(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AtlasNode_getBlendFunc'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'", nullptr); return 0; } - const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); - blendfunc_to_luaval(tolua_S, ret); + cobj->updateAtlasValues(); + lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AtlasNode:getBlendFunc",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AtlasNode:updateAtlasValues",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_getBlendFunc'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'.",&tolua_err); #endif return 0; @@ -49300,7 +49300,7 @@ int lua_cocos2dx_AtlasNode_getTextureAtlas(lua_State* tolua_S) return 0; } -int lua_cocos2dx_AtlasNode_updateAtlasValues(lua_State* tolua_S) +int lua_cocos2dx_AtlasNode_getBlendFunc(lua_State* tolua_S) { int argc = 0; cocos2d::AtlasNode* cobj = nullptr; @@ -49320,7 +49320,7 @@ int lua_cocos2dx_AtlasNode_updateAtlasValues(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AtlasNode_getBlendFunc'", nullptr); return 0; } #endif @@ -49330,19 +49330,19 @@ int lua_cocos2dx_AtlasNode_updateAtlasValues(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AtlasNode_getBlendFunc'", nullptr); return 0; } - cobj->updateAtlasValues(); - lua_settop(tolua_S, 1); + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + blendfunc_to_luaval(tolua_S, ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AtlasNode:updateAtlasValues",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AtlasNode:getBlendFunc",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_updateAtlasValues'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AtlasNode_getBlendFunc'.",&tolua_err); #endif return 0; @@ -49645,13 +49645,13 @@ int lua_register_cocos2dx_AtlasNode(lua_State* tolua_S) tolua_beginmodule(tolua_S,"AtlasNode"); tolua_function(tolua_S,"new",lua_cocos2dx_AtlasNode_constructor); - tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_AtlasNode_getBlendFunc); + tolua_function(tolua_S,"updateAtlasValues",lua_cocos2dx_AtlasNode_updateAtlasValues); tolua_function(tolua_S,"initWithTileFile",lua_cocos2dx_AtlasNode_initWithTileFile); tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_AtlasNode_setBlendFunc); tolua_function(tolua_S,"setTextureAtlas",lua_cocos2dx_AtlasNode_setTextureAtlas); tolua_function(tolua_S,"getTexture",lua_cocos2dx_AtlasNode_getTexture); tolua_function(tolua_S,"getTextureAtlas",lua_cocos2dx_AtlasNode_getTextureAtlas); - tolua_function(tolua_S,"updateAtlasValues",lua_cocos2dx_AtlasNode_updateAtlasValues); + tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_AtlasNode_getBlendFunc); tolua_function(tolua_S,"setTexture",lua_cocos2dx_AtlasNode_setTexture); tolua_function(tolua_S,"initWithTexture",lua_cocos2dx_AtlasNode_initWithTexture); tolua_function(tolua_S,"getQuadsToDraw",lua_cocos2dx_AtlasNode_getQuadsToDraw); @@ -61737,7 +61737,7 @@ int lua_cocos2dx_MotionStreak_reset(lua_State* tolua_S) return 0; } -int lua_cocos2dx_MotionStreak_getBlendFunc(lua_State* tolua_S) +int lua_cocos2dx_MotionStreak_setTexture(lua_State* tolua_S) { int argc = 0; cocos2d::MotionStreak* cobj = nullptr; @@ -61757,29 +61757,32 @@ int lua_cocos2dx_MotionStreak_getBlendFunc(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_getBlendFunc'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_setTexture'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 0) + if (argc == 1) { + cocos2d::Texture2D* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "cc.MotionStreak:setTexture"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_MotionStreak_getBlendFunc'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_MotionStreak_setTexture'", nullptr); return 0; } - const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); - blendfunc_to_luaval(tolua_S, ret); + cobj->setTexture(arg0); + lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MotionStreak:getBlendFunc",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MotionStreak:setTexture",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_getBlendFunc'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_setTexture'.",&tolua_err); #endif return 0; @@ -61981,7 +61984,7 @@ int lua_cocos2dx_MotionStreak_setStartingPositionInitialized(lua_State* tolua_S) return 0; } -int lua_cocos2dx_MotionStreak_setTexture(lua_State* tolua_S) +int lua_cocos2dx_MotionStreak_getBlendFunc(lua_State* tolua_S) { int argc = 0; cocos2d::MotionStreak* cobj = nullptr; @@ -62001,32 +62004,29 @@ int lua_cocos2dx_MotionStreak_setTexture(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_setTexture'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_MotionStreak_getBlendFunc'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 0) { - cocos2d::Texture2D* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "cc.MotionStreak:setTexture"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_MotionStreak_setTexture'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_MotionStreak_getBlendFunc'", nullptr); return 0; } - cobj->setTexture(arg0); - lua_settop(tolua_S, 1); + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + blendfunc_to_luaval(tolua_S, ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MotionStreak:setTexture",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.MotionStreak:getBlendFunc",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_setTexture'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_MotionStreak_getBlendFunc'.",&tolua_err); #endif return 0; @@ -62482,12 +62482,12 @@ int lua_register_cocos2dx_MotionStreak(lua_State* tolua_S) tolua_beginmodule(tolua_S,"MotionStreak"); tolua_function(tolua_S,"new",lua_cocos2dx_MotionStreak_constructor); tolua_function(tolua_S,"reset",lua_cocos2dx_MotionStreak_reset); - tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_MotionStreak_getBlendFunc); + tolua_function(tolua_S,"setTexture",lua_cocos2dx_MotionStreak_setTexture); tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_MotionStreak_setBlendFunc); tolua_function(tolua_S,"tintWithColor",lua_cocos2dx_MotionStreak_tintWithColor); tolua_function(tolua_S,"getTexture",lua_cocos2dx_MotionStreak_getTexture); tolua_function(tolua_S,"setStartingPositionInitialized",lua_cocos2dx_MotionStreak_setStartingPositionInitialized); - tolua_function(tolua_S,"setTexture",lua_cocos2dx_MotionStreak_setTexture); + tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_MotionStreak_getBlendFunc); tolua_function(tolua_S,"isStartingPositionInitialized",lua_cocos2dx_MotionStreak_isStartingPositionInitialized); tolua_function(tolua_S,"isFastMode",lua_cocos2dx_MotionStreak_isFastMode); tolua_function(tolua_S,"getStroke",lua_cocos2dx_MotionStreak_getStroke); @@ -73663,56 +73663,6 @@ int lua_cocos2dx_Sprite_setFlippedX(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Sprite_setProgramState(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Sprite* 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.Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setProgramState'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::backend::ProgramState* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.ProgramState",&arg0, "cc.Sprite:setProgramState"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Sprite_setProgramState'", nullptr); - return 0; - } - cobj->setProgramState(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite:setProgramState",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setProgramState'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Sprite_getResourceType(lua_State* tolua_S) { int argc = 0; @@ -75666,7 +75616,6 @@ int lua_register_cocos2dx_Sprite(lua_State* tolua_S) tolua_function(tolua_S,"getTexture",lua_cocos2dx_Sprite_getTexture); tolua_function(tolua_S,"setFlippedY",lua_cocos2dx_Sprite_setFlippedY); tolua_function(tolua_S,"setFlippedX",lua_cocos2dx_Sprite_setFlippedX); - tolua_function(tolua_S,"setProgramState",lua_cocos2dx_Sprite_setProgramState); tolua_function(tolua_S,"getResourceType",lua_cocos2dx_Sprite_getResourceType); tolua_function(tolua_S,"setDisplayFrameWithAnimationName",lua_cocos2dx_Sprite_setDisplayFrameWithAnimationName); tolua_function(tolua_S,"getBatchNode",lua_cocos2dx_Sprite_getBatchNode); @@ -87716,24 +87665,21 @@ int lua_cocos2dx_RenderState_unbindPass(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 2) + if (argc == 1) { cocos2d::Pass* arg0; - cocos2d::MeshCommand* arg1; ok &= luaval_to_object(tolua_S, 2, "cc.Pass",&arg0, "cc.RenderState:unbindPass"); - - ok &= luaval_to_object(tolua_S, 3, "cc.MeshCommand",&arg1, "cc.RenderState:unbindPass"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_RenderState_unbindPass'", nullptr); return 0; } - cobj->unbindPass(arg0, arg1); + cobj->unbindPass(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:unbindPass",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:unbindPass",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -87769,24 +87715,21 @@ int lua_cocos2dx_RenderState_bindPass(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 2) + if (argc == 1) { cocos2d::Pass* arg0; - cocos2d::MeshCommand* arg1; ok &= luaval_to_object(tolua_S, 2, "cc.Pass",&arg0, "cc.RenderState:bindPass"); - - ok &= luaval_to_object(tolua_S, 3, "cc.MeshCommand",&arg1, "cc.RenderState:bindPass"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_RenderState_bindPass'", nullptr); return 0; } - cobj->bindPass(arg0, arg1); + cobj->bindPass(arg0); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:bindPass",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:bindPass",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -88331,42 +88274,39 @@ int lua_cocos2dx_Material_draw(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 8) + if (argc == 7) { - cocos2d::MeshCommand* arg0; - double arg1; + double arg0; + cocos2d::backend::Buffer* arg1; cocos2d::backend::Buffer* arg2; - cocos2d::backend::Buffer* arg3; - cocos2d::backend::PrimitiveType arg4; - cocos2d::backend::IndexFormat arg5; - unsigned int arg6; - cocos2d::Mat4 arg7; + cocos2d::backend::PrimitiveType arg3; + cocos2d::backend::IndexFormat arg4; + unsigned int arg5; + cocos2d::Mat4 arg6; - ok &= luaval_to_object(tolua_S, 2, "cc.MeshCommand",&arg0, "cc.Material:draw"); + ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Material:draw"); - ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.Material:draw"); + ok &= luaval_to_object(tolua_S, 3, "cc.Buffer",&arg1, "cc.Material:draw"); ok &= luaval_to_object(tolua_S, 4, "cc.Buffer",&arg2, "cc.Material:draw"); - ok &= luaval_to_object(tolua_S, 5, "cc.Buffer",&arg3, "cc.Material:draw"); + ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "cc.Material:draw"); ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "cc.Material:draw"); - ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5, "cc.Material:draw"); + ok &= luaval_to_uint32(tolua_S, 7,&arg5, "cc.Material:draw"); - ok &= luaval_to_uint32(tolua_S, 8,&arg6, "cc.Material:draw"); - - ok &= luaval_to_mat4(tolua_S, 9, &arg7, "cc.Material:draw"); + ok &= luaval_to_mat4(tolua_S, 8, &arg6, "cc.Material:draw"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Material_draw'", nullptr); return 0; } - cobj->draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + cobj->draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Material:draw",argc, 8); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Material:draw",argc, 7); return 0; #if COCOS2D_DEBUG >= 1 @@ -89208,7 +89148,7 @@ int lua_cocos2dx_Pass_getVertexAttributeBinding(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos(lua_State* tolua_S) +int lua_cocos2dx_Pass_setUniformPointLightRangeInverse(lua_State* tolua_S) { int argc = 0; cocos2d::Pass* cobj = nullptr; @@ -89228,7 +89168,7 @@ int lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'", nullptr); return 0; } #endif @@ -89242,22 +89182,22 @@ int lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos(lua_State* tolua_S) #pragma warning NO CONVERSION TO NATIVE FOR void* ok = false; - ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.Pass:setUniformSpotLightOuterAngleCos"); + ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.Pass:setUniformPointLightRangeInverse"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'", nullptr); return 0; } - cobj->setUniformSpotLightOuterAngleCos(arg0, arg1); + cobj->setUniformPointLightRangeInverse(arg0, arg1); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setUniformSpotLightOuterAngleCos",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setUniformPointLightRangeInverse",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'.",&tolua_err); #endif return 0; @@ -89370,103 +89310,6 @@ int lua_cocos2dx_Pass_setUniformMatrixPalette(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_setName(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Pass* 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.Pass",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Pass*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setName'", 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, "cc.Pass:setName"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setName'", nullptr); - return 0; - } - cobj->setName(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setName",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setName'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Pass_getName(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Pass* 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.Pass",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Pass*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_getName'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_getName'", nullptr); - return 0; - } - const std::string& ret = cobj->getName(); - lua_pushlstring(tolua_S,ret.c_str(),ret.length()); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:getName",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_getName'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Pass_setUniformSpotLightRangeInverse(lua_State* tolua_S) { int argc = 0; @@ -89521,53 +89364,6 @@ int lua_cocos2dx_Pass_setUniformSpotLightRangeInverse(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_clone(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Pass* 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.Pass",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Pass*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_clone'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_clone'", nullptr); - return 0; - } - cocos2d::Pass* ret = cobj->clone(); - object_to_luaval(tolua_S, "cc.Pass",(cocos2d::Pass*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:clone",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_clone'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Pass_draw(lua_State* tolua_S) { int argc = 0; @@ -89594,42 +89390,39 @@ int lua_cocos2dx_Pass_draw(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 8) + if (argc == 7) { - cocos2d::MeshCommand* arg0; - double arg1; + double arg0; + cocos2d::backend::Buffer* arg1; cocos2d::backend::Buffer* arg2; - cocos2d::backend::Buffer* arg3; - cocos2d::backend::PrimitiveType arg4; - cocos2d::backend::IndexFormat arg5; - unsigned int arg6; - cocos2d::Mat4 arg7; + cocos2d::backend::PrimitiveType arg3; + cocos2d::backend::IndexFormat arg4; + unsigned int arg5; + cocos2d::Mat4 arg6; - ok &= luaval_to_object(tolua_S, 2, "cc.MeshCommand",&arg0, "cc.Pass:draw"); + ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Pass:draw"); - ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.Pass:draw"); + ok &= luaval_to_object(tolua_S, 3, "cc.Buffer",&arg1, "cc.Pass:draw"); ok &= luaval_to_object(tolua_S, 4, "cc.Buffer",&arg2, "cc.Pass:draw"); - ok &= luaval_to_object(tolua_S, 5, "cc.Buffer",&arg3, "cc.Pass:draw"); + ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "cc.Pass:draw"); ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "cc.Pass:draw"); - ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5, "cc.Pass:draw"); + ok &= luaval_to_uint32(tolua_S, 7,&arg5, "cc.Pass:draw"); - ok &= luaval_to_uint32(tolua_S, 8,&arg6, "cc.Pass:draw"); - - ok &= luaval_to_mat4(tolua_S, 9, &arg7, "cc.Pass:draw"); + ok &= luaval_to_mat4(tolua_S, 8, &arg6, "cc.Pass:draw"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_draw'", nullptr); return 0; } - cobj->draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + cobj->draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:draw",argc, 8); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:draw",argc, 7); return 0; #if COCOS2D_DEBUG >= 1 @@ -89639,7 +89432,7 @@ int lua_cocos2dx_Pass_draw(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_setUniformPointLightRangeInverse(lua_State* tolua_S) +int lua_cocos2dx_Pass_getVertexLayout(lua_State* tolua_S) { int argc = 0; cocos2d::Pass* cobj = nullptr; @@ -89659,36 +89452,29 @@ int lua_cocos2dx_Pass_setUniformPointLightRangeInverse(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_getVertexLayout'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 2) + if (argc == 0) { - const void* arg0; - unsigned int arg1; - - #pragma warning NO CONVERSION TO NATIVE FOR void* - ok = false; - - ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.Pass:setUniformPointLightRangeInverse"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_getVertexLayout'", nullptr); return 0; } - cobj->setUniformPointLightRangeInverse(arg0, arg1); - lua_settop(tolua_S, 1); + cocos2d::backend::VertexLayout* ret = cobj->getVertexLayout(); + object_to_luaval(tolua_S, "cc.VertexLayout",(cocos2d::backend::VertexLayout*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setUniformPointLightRangeInverse",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:getVertexLayout",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_getVertexLayout'.",&tolua_err); #endif return 0; @@ -89746,7 +89532,7 @@ int lua_cocos2dx_Pass_setUniformNormTexture(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_updateMVPUniform(lua_State* tolua_S) +int lua_cocos2dx_Pass_clone(lua_State* tolua_S) { int argc = 0; cocos2d::Pass* cobj = nullptr; @@ -89766,32 +89552,29 @@ int lua_cocos2dx_Pass_updateMVPUniform(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_updateMVPUniform'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_clone'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 0) { - cocos2d::Mat4 arg0; - - ok &= luaval_to_mat4(tolua_S, 2, &arg0, "cc.Pass:updateMVPUniform"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_updateMVPUniform'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_clone'", nullptr); return 0; } - cobj->updateMVPUniform(arg0); - lua_settop(tolua_S, 1); + cocos2d::Pass* ret = cobj->clone(); + object_to_luaval(tolua_S, "cc.Pass",(cocos2d::Pass*)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:updateMVPUniform",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:clone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_updateMVPUniform'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_clone'.",&tolua_err); #endif return 0; @@ -90216,6 +89999,60 @@ int lua_cocos2dx_Pass_setUniformTexture(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Pass* 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.Pass",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Pass*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + const void* arg0; + unsigned int arg1; + + #pragma warning NO CONVERSION TO NATIVE FOR void* + ok = false; + + ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.Pass:setUniformSpotLightOuterAngleCos"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'", nullptr); + return 0; + } + cobj->setUniformSpotLightOuterAngleCos(arg0, arg1); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setUniformSpotLightOuterAngleCos",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Pass_setUniformColor(lua_State* tolua_S) { int argc = 0; @@ -90414,17 +90251,14 @@ int lua_register_cocos2dx_Pass(lua_State* tolua_S) tolua_function(tolua_S,"setUniformSpotLightInnerAngleCos",lua_cocos2dx_Pass_setUniformSpotLightInnerAngleCos); tolua_function(tolua_S,"setTechnique",lua_cocos2dx_Pass_setTechnique); tolua_function(tolua_S,"getVertexAttributeBinding",lua_cocos2dx_Pass_getVertexAttributeBinding); - tolua_function(tolua_S,"setUniformSpotLightOuterAngleCos",lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos); + tolua_function(tolua_S,"setUniformPointLightRangeInverse",lua_cocos2dx_Pass_setUniformPointLightRangeInverse); tolua_function(tolua_S,"setUniformSpotLightDir",lua_cocos2dx_Pass_setUniformSpotLightDir); tolua_function(tolua_S,"setUniformMatrixPalette",lua_cocos2dx_Pass_setUniformMatrixPalette); - tolua_function(tolua_S,"setName",lua_cocos2dx_Pass_setName); - tolua_function(tolua_S,"getName",lua_cocos2dx_Pass_getName); tolua_function(tolua_S,"setUniformSpotLightRangeInverse",lua_cocos2dx_Pass_setUniformSpotLightRangeInverse); - tolua_function(tolua_S,"clone",lua_cocos2dx_Pass_clone); tolua_function(tolua_S,"draw",lua_cocos2dx_Pass_draw); - tolua_function(tolua_S,"setUniformPointLightRangeInverse",lua_cocos2dx_Pass_setUniformPointLightRangeInverse); + tolua_function(tolua_S,"getVertexLayout",lua_cocos2dx_Pass_getVertexLayout); tolua_function(tolua_S,"setUniformNormTexture",lua_cocos2dx_Pass_setUniformNormTexture); - tolua_function(tolua_S,"updateMVPUniform",lua_cocos2dx_Pass_updateMVPUniform); + tolua_function(tolua_S,"clone",lua_cocos2dx_Pass_clone); tolua_function(tolua_S,"setUniformDirLightDir",lua_cocos2dx_Pass_setUniformDirLightDir); tolua_function(tolua_S,"getProgramState",lua_cocos2dx_Pass_getProgramState); tolua_function(tolua_S,"setUniformSpotLightColor",lua_cocos2dx_Pass_setUniformSpotLightColor); @@ -90433,6 +90267,7 @@ int lua_register_cocos2dx_Pass(lua_State* tolua_S) tolua_function(tolua_S,"setUniformSpotLightPosition",lua_cocos2dx_Pass_setUniformSpotLightPosition); tolua_function(tolua_S,"setVertexAttribBinding",lua_cocos2dx_Pass_setVertexAttribBinding); tolua_function(tolua_S,"setUniformTexture",lua_cocos2dx_Pass_setUniformTexture); + tolua_function(tolua_S,"setUniformSpotLightOuterAngleCos",lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos); tolua_function(tolua_S,"setUniformColor",lua_cocos2dx_Pass_setUniformColor); tolua_function(tolua_S,"setUniformPointLightColor",lua_cocos2dx_Pass_setUniformPointLightColor); tolua_function(tolua_S,"createWithProgramState", lua_cocos2dx_Pass_createWithProgramState); @@ -95631,6 +95466,56 @@ int lua_cocos2dx_TMXMapInfo_setTileSize(lua_State* tolua_S) return 0; } +int lua_cocos2dx_TMXMapInfo_initWithTMXFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::TMXMapInfo* 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.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'", 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, "cc.TMXMapInfo:initWithTMXFile"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'", nullptr); + return 0; + } + bool ret = cobj->initWithTMXFile(arg0); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TMXMapInfo:initWithTMXFile",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_TMXMapInfo_getOrientation(lua_State* tolua_S) { int argc = 0; @@ -96119,52 +96004,49 @@ int lua_cocos2dx_TMXMapInfo_setHexSideLength(lua_State* tolua_S) return 0; } -int lua_cocos2dx_TMXMapInfo_initWithTMXFile(lua_State* tolua_S) +int lua_cocos2dx_TMXMapInfo_getTilesets(lua_State* tolua_S) { int argc = 0; cocos2d::TMXMapInfo* 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.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); - #if COCOS2D_DEBUG >= 1 - if (!cobj) + if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getTilesets'", 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, "cc.TMXMapInfo:initWithTMXFile"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'", nullptr); - return 0; + do{ + if (argc == 0) { + cocos2d::Vector& ret = cobj->getTilesets(); + ccvector_to_luaval(tolua_S, ret); + return 1; } - bool ret = cobj->initWithTMXFile(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TMXMapInfo:initWithTMXFile",argc, 1); + }while(0); + ok = true; + do{ + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getTilesets(); + ccvector_to_luaval(tolua_S, ret); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TMXMapInfo:getTilesets",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_initWithTMXFile'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getTilesets'.",&tolua_err); #endif return 0; @@ -96216,53 +96098,6 @@ int lua_cocos2dx_TMXMapInfo_getParentGID(lua_State* tolua_S) return 0; } -int lua_cocos2dx_TMXMapInfo_getTilesets(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::TMXMapInfo* 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.TMXMapInfo",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::TMXMapInfo*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TMXMapInfo_getTilesets'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 0) { - cocos2d::Vector& ret = cobj->getTilesets(); - ccvector_to_luaval(tolua_S, ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 0) { - const cocos2d::Vector& ret = cobj->getTilesets(); - ccvector_to_luaval(tolua_S, ret); - return 1; - } - }while(0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TMXMapInfo:getTilesets",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TMXMapInfo_getTilesets'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_TMXMapInfo_setParentElement(lua_State* tolua_S) { int argc = 0; @@ -97510,6 +97345,7 @@ int lua_register_cocos2dx_TMXMapInfo(lua_State* tolua_S) tolua_function(tolua_S,"setCurrentString",lua_cocos2dx_TMXMapInfo_setCurrentString); tolua_function(tolua_S,"getHexSideLength",lua_cocos2dx_TMXMapInfo_getHexSideLength); tolua_function(tolua_S,"setTileSize",lua_cocos2dx_TMXMapInfo_setTileSize); + tolua_function(tolua_S,"initWithTMXFile",lua_cocos2dx_TMXMapInfo_initWithTMXFile); tolua_function(tolua_S,"getOrientation",lua_cocos2dx_TMXMapInfo_getOrientation); tolua_function(tolua_S,"setObjectGroups",lua_cocos2dx_TMXMapInfo_setObjectGroups); tolua_function(tolua_S,"setLayers",lua_cocos2dx_TMXMapInfo_setLayers); @@ -97520,9 +97356,8 @@ int lua_register_cocos2dx_TMXMapInfo(lua_State* tolua_S) tolua_function(tolua_S,"getLayers",lua_cocos2dx_TMXMapInfo_getLayers); tolua_function(tolua_S,"getStaggerAxis",lua_cocos2dx_TMXMapInfo_getStaggerAxis); tolua_function(tolua_S,"setHexSideLength",lua_cocos2dx_TMXMapInfo_setHexSideLength); - tolua_function(tolua_S,"initWithTMXFile",lua_cocos2dx_TMXMapInfo_initWithTMXFile); - tolua_function(tolua_S,"getParentGID",lua_cocos2dx_TMXMapInfo_getParentGID); tolua_function(tolua_S,"getTilesets",lua_cocos2dx_TMXMapInfo_getTilesets); + tolua_function(tolua_S,"getParentGID",lua_cocos2dx_TMXMapInfo_getParentGID); tolua_function(tolua_S,"setParentElement",lua_cocos2dx_TMXMapInfo_setParentElement); tolua_function(tolua_S,"initWithXML",lua_cocos2dx_TMXMapInfo_initWithXML); tolua_function(tolua_S,"setParentGID",lua_cocos2dx_TMXMapInfo_setParentGID); @@ -101179,6 +101014,8 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_ShakyTiles3D(tolua_S); lua_register_cocos2dx_PageTurn3D(tolua_S); lua_register_cocos2dx_PolygonInfo(tolua_S); + lua_register_cocos2dx_TransitionSlideInL(tolua_S); + lua_register_cocos2dx_TransitionSlideInT(tolua_S); lua_register_cocos2dx_Grid3D(tolua_S); lua_register_cocos2dx_EventListenerController(tolua_S); lua_register_cocos2dx_TransitionProgressInOut(tolua_S); @@ -101217,7 +101054,6 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_ComponentLua(tolua_S); lua_register_cocos2dx_MotionStreak3D(tolua_S); lua_register_cocos2dx_EaseOut(tolua_S); - lua_register_cocos2dx_TransitionSlideInL(tolua_S); lua_register_cocos2dx_MenuItemFont(tolua_S); lua_register_cocos2dx_TransitionFadeUp(tolua_S); lua_register_cocos2dx_LayerRadialGradient(tolua_S); @@ -101231,7 +101067,6 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_RotateBy(tolua_S); lua_register_cocos2dx_FileUtils(tolua_S); lua_register_cocos2dx_Sprite(tolua_S); - lua_register_cocos2dx_TransitionSlideInT(tolua_S); lua_register_cocos2dx_ProgressTo(tolua_S); lua_register_cocos2dx_TransitionProgressOutIn(tolua_S); lua_register_cocos2dx_AnimationFrame(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.cpp index 2c543bc115..795ca1c207 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.cpp @@ -3,3 +3,913 @@ #include "base/CCGameController.h" #include "scripting/lua-bindings/manual/tolua_fix.h" #include "scripting/lua-bindings/manual/LuaBasicConversions.h" + +int lua_cocos2dx_controller_Controller_receiveExternalKeyEvent(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Controller* 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.Controller",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_receiveExternalKeyEvent'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + int arg0; + bool arg1; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Controller:receiveExternalKeyEvent"); + + ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.Controller:receiveExternalKeyEvent"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_receiveExternalKeyEvent'", nullptr); + return 0; + } + cobj->receiveExternalKeyEvent(arg0, arg1); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Controller:receiveExternalKeyEvent",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_receiveExternalKeyEvent'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_controller_Controller_getDeviceName(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Controller* 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.Controller",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_getDeviceName'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_getDeviceName'", nullptr); + return 0; + } + const std::string& ret = cobj->getDeviceName(); + lua_pushlstring(tolua_S,ret.c_str(),ret.length()); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Controller:getDeviceName",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getDeviceName'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_controller_Controller_isConnected(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Controller* 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.Controller",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_isConnected'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_isConnected'", nullptr); + return 0; + } + bool ret = cobj->isConnected(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Controller:isConnected",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_isConnected'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_controller_Controller_getDeviceId(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Controller* 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.Controller",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_getDeviceId'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_getDeviceId'", nullptr); + return 0; + } + int ret = cobj->getDeviceId(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Controller:getDeviceId",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getDeviceId'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_controller_Controller_setTag(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Controller* 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.Controller",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_setTag'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + int arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Controller:setTag"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_setTag'", nullptr); + return 0; + } + cobj->setTag(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Controller:setTag",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_setTag'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_controller_Controller_getTag(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Controller* 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.Controller",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_getTag'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_getTag'", nullptr); + return 0; + } + int ret = cobj->getTag(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Controller:getTag",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getTag'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_controller_Controller_startDiscoveryController(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.Controller",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_startDiscoveryController'", nullptr); + return 0; + } + cocos2d::Controller::startDiscoveryController(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Controller:startDiscoveryController",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_startDiscoveryController'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_controller_Controller_stopDiscoveryController(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.Controller",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_stopDiscoveryController'", nullptr); + return 0; + } + cocos2d::Controller::stopDiscoveryController(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Controller:stopDiscoveryController",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_stopDiscoveryController'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_controller_Controller_getControllerByDeviceId(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.Controller",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + int arg0; + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Controller:getControllerByDeviceId"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_getControllerByDeviceId'", nullptr); + return 0; + } + cocos2d::Controller* ret = cocos2d::Controller::getControllerByDeviceId(arg0); + object_to_luaval(tolua_S, "cc.Controller",(cocos2d::Controller*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Controller:getControllerByDeviceId",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getControllerByDeviceId'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_controller_Controller_getControllerByTag(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.Controller",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + int arg0; + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.Controller:getControllerByTag"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_Controller_getControllerByTag'", nullptr); + return 0; + } + cocos2d::Controller* ret = cocos2d::Controller::getControllerByTag(arg0); + object_to_luaval(tolua_S, "cc.Controller",(cocos2d::Controller*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Controller:getControllerByTag",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getControllerByTag'.",&tolua_err); +#endif + return 0; +} +static int lua_cocos2dx_controller_Controller_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (Controller)"); + return 0; +} + +int lua_register_cocos2dx_controller_Controller(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.Controller"); + tolua_cclass(tolua_S,"Controller","cc.Controller","",nullptr); + + tolua_beginmodule(tolua_S,"Controller"); + tolua_function(tolua_S,"receiveExternalKeyEvent",lua_cocos2dx_controller_Controller_receiveExternalKeyEvent); + tolua_function(tolua_S,"getDeviceName",lua_cocos2dx_controller_Controller_getDeviceName); + tolua_function(tolua_S,"isConnected",lua_cocos2dx_controller_Controller_isConnected); + tolua_function(tolua_S,"getDeviceId",lua_cocos2dx_controller_Controller_getDeviceId); + tolua_function(tolua_S,"setTag",lua_cocos2dx_controller_Controller_setTag); + tolua_function(tolua_S,"getTag",lua_cocos2dx_controller_Controller_getTag); + tolua_function(tolua_S,"startDiscoveryController", lua_cocos2dx_controller_Controller_startDiscoveryController); + tolua_function(tolua_S,"stopDiscoveryController", lua_cocos2dx_controller_Controller_stopDiscoveryController); + tolua_function(tolua_S,"getControllerByDeviceId", lua_cocos2dx_controller_Controller_getControllerByDeviceId); + tolua_function(tolua_S,"getControllerByTag", lua_cocos2dx_controller_Controller_getControllerByTag); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::Controller).name(); + g_luaType[typeName] = "cc.Controller"; + g_typeCast["Controller"] = "cc.Controller"; + return 1; +} + +int lua_cocos2dx_controller_EventController_getControllerEventType(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventController* 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.EventController",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_getControllerEventType'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventController_getControllerEventType'", nullptr); + return 0; + } + int ret = (int)cobj->getControllerEventType(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:getControllerEventType",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_getControllerEventType'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_controller_EventController_setConnectStatus(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventController* 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.EventController",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_setConnectStatus'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.EventController:setConnectStatus"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventController_setConnectStatus'", nullptr); + return 0; + } + cobj->setConnectStatus(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:setConnectStatus",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_setConnectStatus'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_controller_EventController_isConnected(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventController* 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.EventController",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_isConnected'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventController_isConnected'", nullptr); + return 0; + } + bool ret = cobj->isConnected(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:isConnected",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_isConnected'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_controller_EventController_setKeyCode(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventController* 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.EventController",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_setKeyCode'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + int arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EventController:setKeyCode"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventController_setKeyCode'", nullptr); + return 0; + } + cobj->setKeyCode(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:setKeyCode",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_setKeyCode'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_controller_EventController_getController(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventController* 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.EventController",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_getController'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventController_getController'", nullptr); + return 0; + } + cocos2d::Controller* ret = cobj->getController(); + object_to_luaval(tolua_S, "cc.Controller",(cocos2d::Controller*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:getController",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_getController'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_controller_EventController_getKeyCode(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventController* 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.EventController",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_getKeyCode'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventController_getKeyCode'", nullptr); + return 0; + } + int ret = cobj->getKeyCode(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:getKeyCode",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_getKeyCode'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_controller_EventController_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::EventController* cobj = nullptr; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + argc = lua_gettop(tolua_S)-1; + do{ + if (argc == 3) { + cocos2d::EventController::ControllerEventType arg0; + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EventController:EventController"); + + if (!ok) { break; } + cocos2d::Controller* arg1; + ok &= luaval_to_object(tolua_S, 3, "cc.Controller",&arg1, "cc.EventController:EventController"); + + if (!ok) { break; } + bool arg2; + ok &= luaval_to_boolean(tolua_S, 4,&arg2, "cc.EventController:EventController"); + + if (!ok) { break; } + cobj = new cocos2d::EventController(arg0, arg1, arg2); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventController"); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 3) { + cocos2d::EventController::ControllerEventType arg0; + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EventController:EventController"); + + if (!ok) { break; } + cocos2d::Controller* arg1; + ok &= luaval_to_object(tolua_S, 3, "cc.Controller",&arg1, "cc.EventController:EventController"); + + if (!ok) { break; } + int arg2; + ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "cc.EventController:EventController"); + + if (!ok) { break; } + cobj = new cocos2d::EventController(arg0, arg1, arg2); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventController"); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventController:EventController",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_controller_EventController_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (EventController)"); + return 0; +} + +int lua_register_cocos2dx_controller_EventController(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.EventController"); + tolua_cclass(tolua_S,"EventController","cc.EventController","cc.Event",nullptr); + + tolua_beginmodule(tolua_S,"EventController"); + tolua_function(tolua_S,"new",lua_cocos2dx_controller_EventController_constructor); + tolua_function(tolua_S,"getControllerEventType",lua_cocos2dx_controller_EventController_getControllerEventType); + tolua_function(tolua_S,"setConnectStatus",lua_cocos2dx_controller_EventController_setConnectStatus); + tolua_function(tolua_S,"isConnected",lua_cocos2dx_controller_EventController_isConnected); + tolua_function(tolua_S,"setKeyCode",lua_cocos2dx_controller_EventController_setKeyCode); + tolua_function(tolua_S,"getController",lua_cocos2dx_controller_EventController_getController); + tolua_function(tolua_S,"getKeyCode",lua_cocos2dx_controller_EventController_getKeyCode); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::EventController).name(); + g_luaType[typeName] = "cc.EventController"; + g_typeCast["EventController"] = "cc.EventController"; + return 1; +} + +int lua_cocos2dx_controller_EventListenerController_create(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.EventListenerController",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_controller_EventListenerController_create'", nullptr); + return 0; + } + cocos2d::EventListenerController* ret = cocos2d::EventListenerController::create(); + object_to_luaval(tolua_S, "cc.EventListenerController",(cocos2d::EventListenerController*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.EventListenerController:create",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventListenerController_create'.",&tolua_err); +#endif + return 0; +} +static int lua_cocos2dx_controller_EventListenerController_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (EventListenerController)"); + return 0; +} + +int lua_register_cocos2dx_controller_EventListenerController(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.EventListenerController"); + tolua_cclass(tolua_S,"EventListenerController","cc.EventListenerController","cc.EventListener",nullptr); + + tolua_beginmodule(tolua_S,"EventListenerController"); + tolua_function(tolua_S,"create", lua_cocos2dx_controller_EventListenerController_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::EventListenerController).name(); + g_luaType[typeName] = "cc.EventListenerController"; + g_typeCast["EventListenerController"] = "cc.EventListenerController"; + return 1; +} +TOLUA_API int register_all_cocos2dx_controller(lua_State* tolua_S) +{ + tolua_open(tolua_S); + + tolua_module(tolua_S,"cc",0); + tolua_beginmodule(tolua_S,"cc"); + + lua_register_cocos2dx_controller_EventListenerController(tolua_S); + lua_register_cocos2dx_controller_Controller(tolua_S); + lua_register_cocos2dx_controller_EventController(tolua_S); + + tolua_endmodule(tolua_S); + return 1; +} + +#endif diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.hpp index ed9e0e1b1c..4d8bdd50ec 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.hpp @@ -12,3 +12,27 @@ extern "C" { #endif int register_all_cocos2dx_controller(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + + +#endif // __cocos2dx_controller_h__ +#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) From c1ba0d866b214fffacb2d387bc387ce9311c239a Mon Sep 17 00:00:00 2001 From: Arnold <397136899@qq.com> Date: Fri, 15 Mar 2019 15:09:39 +0800 Subject: [PATCH 07/18] remove comments --- cocos/renderer/CCPass.cpp | 57 ------------------- cocos/renderer/CCPass.h | 19 ------- cocos/renderer/backend/ProgramState.cpp | 2 +- cocos/renderer/backend/ProgramState.h | 4 +- .../backend/metal/CommandBufferMTL.mm | 2 +- .../backend/opengl/CommandBufferGL.cpp | 2 +- .../MaterialSystemTest/MaterialSystemTest.cpp | 14 ++--- 7 files changed, 12 insertions(+), 88 deletions(-) diff --git a/cocos/renderer/CCPass.cpp b/cocos/renderer/CCPass.cpp index 188c82c4ed..70b2da3e44 100644 --- a/cocos/renderer/CCPass.cpp +++ b/cocos/renderer/CCPass.cpp @@ -115,7 +115,6 @@ Pass* Pass::clone() const auto pass = new (std::nothrow) Pass(); if (pass) { - //RenderState::cloneInto(pass); pass->_renderState = _renderState; pass->setProgramState(_programState->clone()); @@ -135,15 +134,6 @@ backend::ProgramState* Pass::getProgramState() const return _programState; } -//backend::VertexLayout* Pass::getVertexLayout() -//{ -// if (auto command = _meshCommand.lock()) -// { -// return &(command->getPipelineDescriptor().vertexLayout); -// } -// return nullptr; -//} - void Pass::setProgramState(backend::ProgramState* programState) { if (_programState != programState) @@ -188,43 +178,6 @@ void Pass::initUniformLocations() _locAmbientLigthColor = ps->getUniformLocation(s_ambientLightUniformColorName); } -//uint32_t Pass::getHash() const -//{ -// if (_hashDirty || _state->isDirty()) -// { -// //FIXME: loose information? -// uint32_t program = (uint32_t)(intptr_t)(_programState->getProgram()); -// uint32_t textureid = _texture ? _texture->getName() : -1; -// uint32_t stateblockid = _state->getHash(); -// -// _hash = program ^ textureid ^ stateblockid; -// -// _hashDirty = false; -// } -// -// return _hash; -//} - -//void Pass::bind(const Mat4& modelView) -//{ -// bind(modelView, true); -//} - -//void Pass::bind(const Mat4& modelView, bool bindAttributes) -//{ -// // vertex attribs -// if (bindAttributes && _vertexAttribBinding) -// _vertexAttribBinding->bind(); -// -// auto glprogramstate = _glProgramState ? _glProgramState : getTarget()->getGLProgramState(); -// -// glprogramstate->applyGLProgram(modelView); -// glprogramstate->applyUniforms(); -// -// //set render state -// RenderState::bind(this); -//} - void Pass::draw(MeshCommand *meshCommand, float globalZOrder, backend::Buffer* vertexBuffer, backend::Buffer* indexBuffer, MeshCommand::PrimitiveType primitive, MeshCommand::IndexFormat indexFormat, unsigned int indexCount, const Mat4& modelView) @@ -309,14 +262,6 @@ void Pass::setTechnique(Technique *technique) _technique = technique; //weak reference } - -//void Pass::unbind() -//{ -// RenderState::StateBlock::restore(0); -// -//// _vertexAttribBinding->unbind(); -//} - void Pass::setVertexAttribBinding(VertexAttribBinding* binding) { if (_vertexAttribBinding != binding) @@ -423,6 +368,4 @@ void Pass::setUniformAmbientLigthColor(const void *data, size_t dataLen) TRY_SET_UNIFORM(_locAmbientLigthColor); } - - NS_CC_END diff --git a/cocos/renderer/CCPass.h b/cocos/renderer/CCPass.h index 5ee3cff579..5334c9fd42 100644 --- a/cocos/renderer/CCPass.h +++ b/cocos/renderer/CCPass.h @@ -66,23 +66,10 @@ public: /** Returns the ProgramState */ backend::ProgramState* getProgramState() const; - //backend::VertexLayout* getVertexLayout(); - - /** Binds the GLProgramState and the RenderState. - This method must be called before call the actual draw call. - */ - //void bind(const Mat4& modelView); - //void bind(const Mat4& modelView, bool bindAttributes); - void draw(MeshCommand *meshCommand, float globalZOrder, backend::Buffer* vertexBuffer, backend::Buffer* indexBuffer, MeshCommand::PrimitiveType primitive, MeshCommand::IndexFormat indexFormat, unsigned int indexCount, const Mat4& modelView); - /** Unbinds the Pass. - This method must be called AFTER calling the actual draw call - */ - //void unbind(); - /** * Sets a vertex attribute binding for this pass. * @@ -103,9 +90,6 @@ public: void setName(const std::string &name) { _name = name; } const std::string &getName() const { return _name; } - //TODO arnold - //uint32_t getHash() const; - /** * Returns a clone (deep-copy) of this instance */ Pass* clone() const; @@ -152,12 +136,9 @@ protected: bool _hashDirty = true; RenderState _renderState; std::string _name; - //std::weak_ptr _meshCommand; private: - - //bool _oldDepthEnabledState; void initUniformLocations(); void onBeforeVisitCmd(MeshCommand *); void onAfterVisitCmd(MeshCommand *); diff --git a/cocos/renderer/backend/ProgramState.cpp b/cocos/renderer/backend/ProgramState.cpp index 70a89f2fe1..51caeade02 100644 --- a/cocos/renderer/backend/ProgramState.cpp +++ b/cocos/renderer/backend/ProgramState.cpp @@ -230,7 +230,7 @@ backend::UniformLocation ProgramState::getUniformLocation(const std::string& uni return _program->getUniformLocation(uniform); } -void ProgramState::setUniformCallback(const backend::UniformLocation& uniformLocation,const UniformCallback& callback) +void ProgramState::setCallbackUniform(const backend::UniformLocation& uniformLocation,const UniformCallback& callback) { _callbackUniforms[uniformLocation] = callback; } diff --git a/cocos/renderer/backend/ProgramState.h b/cocos/renderer/backend/ProgramState.h index 3e2e4d850a..48e82e4ff6 100644 --- a/cocos/renderer/backend/ProgramState.h +++ b/cocos/renderer/backend/ProgramState.h @@ -69,7 +69,7 @@ public: inline std::vector& getVertexUniformInfos() { return _vertexUniformInfos; } inline const std::vector& getFragmentUniformInfos() const { return _fragmentUniformInfos; } - void setUniformCallback(const backend::UniformLocation&, const UniformCallback &); + void setCallbackUniform(const backend::UniformLocation&, const UniformCallback &); //set textures void setTexture(const backend::UniformLocation& uniformLocation, uint32_t slot, backend::Texture* texture); @@ -77,7 +77,7 @@ public: inline const std::unordered_map& getVertexTextureInfos() const { return _vertexTextureInfos; } inline const std::unordered_map& getFragmentTextureInfos() const { return _fragmentTextureInfos; } - inline const std::unordered_map& getUniformCallbacks() const { return _callbackUniforms; } + inline const std::unordered_map& getCallbackUniforms() const { return _callbackUniforms; } class CC_DLL AutoBindingResolver { public: diff --git a/cocos/renderer/backend/metal/CommandBufferMTL.mm b/cocos/renderer/backend/metal/CommandBufferMTL.mm index 8e4cd8e8f0..f2d7fb22e1 100644 --- a/cocos/renderer/backend/metal/CommandBufferMTL.mm +++ b/cocos/renderer/backend/metal/CommandBufferMTL.mm @@ -385,7 +385,7 @@ void CommandBufferMTL::setUniformBuffer() const { if (_programState) { - auto &callbackUniforms = _programState->getUniformCallbacks(); + auto &callbackUniforms = _programState->getCallbackUniforms(); for(auto &cb : callbackUniforms) { diff --git a/cocos/renderer/backend/opengl/CommandBufferGL.cpp b/cocos/renderer/backend/opengl/CommandBufferGL.cpp index eb8ae613b3..ef2024a378 100644 --- a/cocos/renderer/backend/opengl/CommandBufferGL.cpp +++ b/cocos/renderer/backend/opengl/CommandBufferGL.cpp @@ -357,7 +357,7 @@ void CommandBufferGL::setUniforms(ProgramGL* program) const { if (_programState) { - auto& callbacks = _programState->getUniformCallbacks(); + auto& callbacks = _programState->getCallbackUniforms(); auto& uniformInfos = _programState->getVertexUniformInfos(); for (auto &cb : callbacks) diff --git a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp index 3dd211d99a..4110ff594f 100644 --- a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp +++ b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp @@ -143,16 +143,16 @@ void Material_2DEffects::onEnter() timeUniforms.clear(); -#define PUSH_LOCATION(sprite) do { \ +#define FETCH_CCTIME_LOCATION(sprite) do { \ auto programState = sprite->getProgramState(); \ auto location = programState->getUniformLocation("CC_Time"); \ timeUniforms.emplace_back(programState, location); \ }while(0) - PUSH_LOCATION(spriteBlur); - PUSH_LOCATION(spriteOutline); - PUSH_LOCATION(spriteNoise); - PUSH_LOCATION(spriteEdgeDetect); + FETCH_CCTIME_LOCATION(spriteBlur); + FETCH_CCTIME_LOCATION(spriteOutline); + FETCH_CCTIME_LOCATION(spriteNoise); + FETCH_CCTIME_LOCATION(spriteEdgeDetect); schedule(CC_SCHEDULE_SELECTOR(Material_2DEffects::updateCCTimeUniforms)); @@ -195,13 +195,13 @@ bool EffectAutoBindingResolver::resolveAutoBinding(backend::ProgramState* progra if (autoBinding.compare("DYNAMIC_RADIUS")==0) { auto loc = programState->getUniformLocation(uniform); - programState->setUniformCallback(loc, CC_CALLBACK_2(EffectAutoBindingResolver::callbackRadius, this)); + programState->setCallbackUniform(loc, CC_CALLBACK_2(EffectAutoBindingResolver::callbackRadius, this)); return true; } else if (autoBinding.compare("OUTLINE_COLOR")==0) { auto loc = programState->getUniformLocation(uniform); - programState->setUniformCallback(loc, CC_CALLBACK_2(EffectAutoBindingResolver::callbackColor, this)); + programState->setCallbackUniform(loc, CC_CALLBACK_2(EffectAutoBindingResolver::callbackColor, this)); return true; } return false; From e77edfddf595f8dda4b35b1029a6a6d66ae5a019 Mon Sep 17 00:00:00 2001 From: Arnold <40414978+PatriceJiang@users.noreply.github.com> Date: Fri, 15 Mar 2019 15:44:43 +0800 Subject: [PATCH 08/18] Update cocos/renderer/CCCustomCommand.h --- cocos/renderer/CCCustomCommand.h | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos/renderer/CCCustomCommand.h b/cocos/renderer/CCCustomCommand.h index 9e1d7f638a..b952be8241 100644 --- a/cocos/renderer/CCCustomCommand.h +++ b/cocos/renderer/CCCustomCommand.h @@ -71,7 +71,6 @@ public: /**Destructor.*/ ~CustomCommand(); - CustomCommand(const CustomCommand &) = default; public: /** From c8324db21ef2b70832e74cbb8c67a5db2f9eae22 Mon Sep 17 00:00:00 2001 From: Arnold <397136899@qq.com> Date: Fri, 15 Mar 2019 16:43:46 +0800 Subject: [PATCH 09/18] move compiletimedefinations to a sperate func --- cocos/renderer/CCMaterial.cpp | 37 +++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/cocos/renderer/CCMaterial.cpp b/cocos/renderer/CCMaterial.cpp index d5b1a178b5..33398dc16f 100644 --- a/cocos/renderer/CCMaterial.cpp +++ b/cocos/renderer/CCMaterial.cpp @@ -45,6 +45,27 @@ NS_CC_BEGIN +namespace { + std::string replaceDefines(const std::string &compileTimeDefines) { + + auto defineParts = Console::Utility::split(compileTimeDefines, ';'); + std::stringstream ss; + for (auto &p : defineParts) + { + if (p.find("#define ") == std::string::npos) + { + ss << "#define " << p << std::endl; + } + else + { + ss << p << std::endl; + } + } + return ss.str(); + + } +} + // Helpers declaration static const char* getOptionalString(Properties* properties, const char* key, const char* defaultValue); static bool isValidUniform(const char* name); @@ -346,21 +367,7 @@ bool Material::parseShader(Pass* pass, Properties* shaderProperties) auto vertShaderSrc = fu->getStringFromFile(vertShader); auto fragShaderSrc = fu->getStringFromFile(fragShader); - auto defineParts = Console::Utility::split(compileTimeDefines, ';'); - std::stringstream ss; - for (auto &p : defineParts) - { - if (p.find("#define ") == std::string::npos) - { - ss << "#define " << p << std::endl; - } - else - { - ss << p << std::endl; - } - } - - std::string defs = ss.str(); + auto defs = replaceDefines(compileTimeDefines); vertShaderSrc = defs + "\n" + vertShaderSrc; fragShaderSrc = defs + "\n" + fragShaderSrc; From 4b5121c70b018aacaeceba152b02797fcdcf5ff3 Mon Sep 17 00:00:00 2001 From: Arnold <40414978+PatriceJiang@users.noreply.github.com> Date: Fri, 15 Mar 2019 17:10:31 +0800 Subject: [PATCH 10/18] Update cocos/renderer/backend/Types.cpp --- cocos/renderer/backend/Types.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/renderer/backend/Types.cpp b/cocos/renderer/backend/Types.cpp index aff36c910e..a7c4afd68c 100644 --- a/cocos/renderer/backend/Types.cpp +++ b/cocos/renderer/backend/Types.cpp @@ -10,7 +10,7 @@ bool UniformLocation::operator==(const UniformLocation &other) const } std::size_t UniformLocation::operator()(const UniformLocation &uniform) const { - return (size_t)(shaderStage) || (size_t)(location & 0xFFFFFFF0); + return (size_t)(shaderStage) || (size_t)((location << 4)& 0xFFFFFFF0); } CC_BACKEND_END From e46e286a18aa68818d6405c667e3d92c7b03cf70 Mon Sep 17 00:00:00 2001 From: Arnold <397136899@qq.com> Date: Fri, 15 Mar 2019 17:19:04 +0800 Subject: [PATCH 11/18] fix hash function --- cocos/renderer/backend/Types.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/renderer/backend/Types.cpp b/cocos/renderer/backend/Types.cpp index a7c4afd68c..61a375f466 100644 --- a/cocos/renderer/backend/Types.cpp +++ b/cocos/renderer/backend/Types.cpp @@ -10,7 +10,7 @@ bool UniformLocation::operator==(const UniformLocation &other) const } std::size_t UniformLocation::operator()(const UniformLocation &uniform) const { - return (size_t)(shaderStage) || (size_t)((location << 4)& 0xFFFFFFF0); + return (((size_t) shaderStage) & 0xFFFFFFF0 )|((size_t)(location << 4)); } CC_BACKEND_END From 5146fa3c93f23e6951149751899f3561400d47cb Mon Sep 17 00:00:00 2001 From: Arnold <40414978+PatriceJiang@users.noreply.github.com> Date: Fri, 15 Mar 2019 17:28:57 +0800 Subject: [PATCH 12/18] Update cocos/renderer/backend/Types.cpp --- cocos/renderer/backend/Types.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/renderer/backend/Types.cpp b/cocos/renderer/backend/Types.cpp index 61a375f466..ae8e08650a 100644 --- a/cocos/renderer/backend/Types.cpp +++ b/cocos/renderer/backend/Types.cpp @@ -10,7 +10,7 @@ bool UniformLocation::operator==(const UniformLocation &other) const } std::size_t UniformLocation::operator()(const UniformLocation &uniform) const { - return (((size_t) shaderStage) & 0xFFFFFFF0 )|((size_t)(location << 4)); + return (((size_t) shaderStage) & 0xF)|((size_t)(location << 4)); } CC_BACKEND_END From 40304860e6720a3d9fae9a19aa0b8d33a05b79be Mon Sep 17 00:00:00 2001 From: Arnold <40414978+PatriceJiang@users.noreply.github.com> Date: Mon, 18 Mar 2019 09:33:43 +0800 Subject: [PATCH 13/18] Apply suggestions from code review --- cocos/renderer/backend/opengl/CommandBufferGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/renderer/backend/opengl/CommandBufferGL.cpp b/cocos/renderer/backend/opengl/CommandBufferGL.cpp index ef2024a378..72732c37ec 100644 --- a/cocos/renderer/backend/opengl/CommandBufferGL.cpp +++ b/cocos/renderer/backend/opengl/CommandBufferGL.cpp @@ -329,7 +329,7 @@ void CommandBufferGL::bindVertexBuffer(ProgramGL *program) const const auto& vertexLayouts = getVertexLayouts(); for (const auto& vertexBuffer : _vertexBuffers) { - if (! vertexBuffer || attributeInfos.empty()) + if (! vertexBuffer) continue; glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer->getHandler()); From e211fd4e61619013f4de0a43c5f23376e06cb9df Mon Sep 17 00:00:00 2001 From: Arnold <397136899@qq.com> Date: Mon, 18 Mar 2019 09:35:36 +0800 Subject: [PATCH 14/18] fix index --- cocos/renderer/backend/opengl/CommandBufferGL.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos/renderer/backend/opengl/CommandBufferGL.cpp b/cocos/renderer/backend/opengl/CommandBufferGL.cpp index 72732c37ec..b264ac10f6 100644 --- a/cocos/renderer/backend/opengl/CommandBufferGL.cpp +++ b/cocos/renderer/backend/opengl/CommandBufferGL.cpp @@ -331,10 +331,11 @@ void CommandBufferGL::bindVertexBuffer(ProgramGL *program) const { if (! vertexBuffer) continue; + if (i >= attributeInfos.size()) + break; glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer->getHandler()); - const auto& attributeInfo = attributeInfos[i]; const auto &layouts = vertexLayouts->at(i); for (const auto& attribute : attributeInfo) From be579d1c4ceaeaa601471f43189f77b372f16bf1 Mon Sep 17 00:00:00 2001 From: Arnold <397136899@qq.com> Date: Mon, 18 Mar 2019 09:41:14 +0800 Subject: [PATCH 15/18] add doc --- cocos/renderer/backend/ProgramState.h | 71 ++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/cocos/renderer/backend/ProgramState.h b/cocos/renderer/backend/ProgramState.h index 48e82e4ff6..3185a33c6e 100644 --- a/cocos/renderer/backend/ProgramState.h +++ b/cocos/renderer/backend/ProgramState.h @@ -78,16 +78,68 @@ public: inline const std::unordered_map& getVertexTextureInfos() const { return _vertexTextureInfos; } inline const std::unordered_map& getFragmentTextureInfos() const { return _fragmentTextureInfos; } inline const std::unordered_map& getCallbackUniforms() const { return _callbackUniforms; } - + + /** + * An abstract base class that can be extended to support custom material auto bindings. + * + * Implementing a custom auto binding resolver allows the set of built-in parameter auto + * bindings to be extended or overridden. Any parameter auto binding that is set on a + * material will be forwarded to any custom auto binding resolvers, in the order in which + * they are registered. If a registered resolver returns true (specifying that it handles + * the specified autoBinding), no further code will be executed for that autoBinding. + * This allows auto binding resolvers to not only implement new/custom binding strings, + * but it also lets them override existing/built-in ones. For this reason, you should + * ensure that you ONLY return true if you explicitly handle a custom auto binding; return + * false otherwise. + * + * Note that the custom resolver is called only once for a GLProgramState object when its + * node binding is initially set. This occurs when a material is initially bound to a + * Node. The resolver is NOT called each frame or each time the GLProgramState is bound. + * + * If no registered resolvers explicitly handle an auto binding, the binding will attempt + * to be resolved using the internal/built-in resolver, which is able to handle any + * auto bindings found in the GLProgramState::AutoBinding enumeration. + * + * When an instance of a class that extends AutoBindingResolver is created, it is automatically + * registered as a custom auto binding handler. Likewise, it is automatically unregistered + * on destruction. + * + * @script{ignore} + */ class CC_DLL AutoBindingResolver { public: - virtual ~AutoBindingResolver(); - //TODO doc - virtual bool resolveAutoBinding(ProgramState *, const std::string &uniformName, const std::string &autoBinding) = 0; - protected: AutoBindingResolver(); + virtual ~AutoBindingResolver(); + /** + * Called when an unrecognized uniform variable is encountered + * during material loading. + * + * Implementations of this method should do a string comparison on the passed + * in name parameter and decide whether or not they should handle the + * parameter. If the parameter is not handled, false should be returned so + * that other auto binding resolvers get a chance to handle the parameter. + * Otherwise, the parameter should be set or bound and true should be returned. + * + * @param glProgramState The glProgramState + * @param node The node that the material is attached to. + * @param uniformName Name of the uniform + * @param autoBinding Name of the auto binding to be resolved. + * + * @return True if the auto binding is handled and the associated parameter is + * bound, false otherwise. + */ + virtual bool resolveAutoBinding(ProgramState *, const std::string &uniformName, const std::string &autoBinding) = 0; }; - + /** + * Sets a uniform auto-binding. + * + * This method parses the passed in autoBinding string and attempts to convert it + * to an enumeration value. If it matches to one of the predefined strings, it will create a + * callback to get the correct value at runtime. + * + * @param uniformName The name of the material parameter to store an auto-binding for. + * @param autoBinding A string matching one of the built-in AutoBinding enum constants. + */ void setParameterAutoBinding(const std::string &, const std::string &); protected: @@ -105,7 +157,12 @@ protected: //float3 etc in Metal has both sizeof and alignment same as float4, convert it before fill into uniform buffer void convertUniformData(const backend::UniformInfo& uniformInfo, const void* srcData, uint32_t srcSize, std::vector& uniformData); #endif - + /** + * Applies the specified custom auto-binding. + * + * @param uniformName Name of the shader uniform. + * @param autoBinding Name of the auto binding. + */ void applyAutoBinding(const std::string &, const std::string &); backend::Program* _program = nullptr; From bfd390af3577a60fb8d41c268dd9d238b56a4e10 Mon Sep 17 00:00:00 2001 From: patricejiang Date: Mon, 18 Mar 2019 10:30:05 +0800 Subject: [PATCH 16/18] auto generate luabindings --- .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 445 +++++++++++++----- .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 4 + 2 files changed, 333 insertions(+), 116 deletions(-) diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 4b129a33bc..16948a8c4f 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -73663,6 +73663,56 @@ int lua_cocos2dx_Sprite_setFlippedX(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Sprite_setProgramState(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Sprite* 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.Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setProgramState'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::backend::ProgramState* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.ProgramState",&arg0, "cc.Sprite:setProgramState"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Sprite_setProgramState'", nullptr); + return 0; + } + cobj->setProgramState(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite:setProgramState",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setProgramState'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Sprite_getResourceType(lua_State* tolua_S) { int argc = 0; @@ -74696,6 +74746,53 @@ int lua_cocos2dx_Sprite_isDirty(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Sprite_getProgramState(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Sprite* 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.Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_getProgramState'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Sprite_getProgramState'", nullptr); + return 0; + } + cocos2d::backend::ProgramState* ret = cobj->getProgramState(); + object_to_luaval(tolua_S, "cc.ProgramState",(cocos2d::backend::ProgramState*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite:getProgramState",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_getProgramState'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Sprite_getCenterRectNormalized(lua_State* tolua_S) { int argc = 0; @@ -75616,6 +75713,7 @@ int lua_register_cocos2dx_Sprite(lua_State* tolua_S) tolua_function(tolua_S,"getTexture",lua_cocos2dx_Sprite_getTexture); tolua_function(tolua_S,"setFlippedY",lua_cocos2dx_Sprite_setFlippedY); tolua_function(tolua_S,"setFlippedX",lua_cocos2dx_Sprite_setFlippedX); + tolua_function(tolua_S,"setProgramState",lua_cocos2dx_Sprite_setProgramState); tolua_function(tolua_S,"getResourceType",lua_cocos2dx_Sprite_getResourceType); tolua_function(tolua_S,"setDisplayFrameWithAnimationName",lua_cocos2dx_Sprite_setDisplayFrameWithAnimationName); tolua_function(tolua_S,"getBatchNode",lua_cocos2dx_Sprite_getBatchNode); @@ -75637,6 +75735,7 @@ int lua_register_cocos2dx_Sprite(lua_State* tolua_S) tolua_function(tolua_S,"removeAllChildrenWithCleanup",lua_cocos2dx_Sprite_removeAllChildrenWithCleanup); tolua_function(tolua_S,"getResourceName",lua_cocos2dx_Sprite_getResourceName); tolua_function(tolua_S,"isDirty",lua_cocos2dx_Sprite_isDirty); + tolua_function(tolua_S,"getProgramState",lua_cocos2dx_Sprite_getProgramState); tolua_function(tolua_S,"getCenterRectNormalized",lua_cocos2dx_Sprite_getCenterRectNormalized); tolua_function(tolua_S,"setAtlasIndex",lua_cocos2dx_Sprite_setAtlasIndex); tolua_function(tolua_S,"initWithTexture",lua_cocos2dx_Sprite_initWithTexture); @@ -87665,21 +87764,24 @@ int lua_cocos2dx_RenderState_unbindPass(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 2) { cocos2d::Pass* arg0; + cocos2d::MeshCommand* arg1; ok &= luaval_to_object(tolua_S, 2, "cc.Pass",&arg0, "cc.RenderState:unbindPass"); + + ok &= luaval_to_object(tolua_S, 3, "cc.MeshCommand",&arg1, "cc.RenderState:unbindPass"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_RenderState_unbindPass'", nullptr); return 0; } - cobj->unbindPass(arg0); + cobj->unbindPass(arg0, arg1); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:unbindPass",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:unbindPass",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 @@ -87715,21 +87817,24 @@ int lua_cocos2dx_RenderState_bindPass(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 2) { cocos2d::Pass* arg0; + cocos2d::MeshCommand* arg1; ok &= luaval_to_object(tolua_S, 2, "cc.Pass",&arg0, "cc.RenderState:bindPass"); + + ok &= luaval_to_object(tolua_S, 3, "cc.MeshCommand",&arg1, "cc.RenderState:bindPass"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_RenderState_bindPass'", nullptr); return 0; } - cobj->bindPass(arg0); + cobj->bindPass(arg0, arg1); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:bindPass",argc, 1); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.RenderState:bindPass",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 @@ -88274,39 +88379,42 @@ int lua_cocos2dx_Material_draw(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 7) + if (argc == 8) { - double arg0; - cocos2d::backend::Buffer* arg1; + cocos2d::MeshCommand* arg0; + double arg1; cocos2d::backend::Buffer* arg2; - cocos2d::backend::PrimitiveType arg3; - cocos2d::backend::IndexFormat arg4; - unsigned int arg5; - cocos2d::Mat4 arg6; + cocos2d::backend::Buffer* arg3; + cocos2d::backend::PrimitiveType arg4; + cocos2d::backend::IndexFormat arg5; + unsigned int arg6; + cocos2d::Mat4 arg7; - ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Material:draw"); + ok &= luaval_to_object(tolua_S, 2, "cc.MeshCommand",&arg0, "cc.Material:draw"); - ok &= luaval_to_object(tolua_S, 3, "cc.Buffer",&arg1, "cc.Material:draw"); + ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.Material:draw"); ok &= luaval_to_object(tolua_S, 4, "cc.Buffer",&arg2, "cc.Material:draw"); - ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "cc.Material:draw"); + ok &= luaval_to_object(tolua_S, 5, "cc.Buffer",&arg3, "cc.Material:draw"); ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "cc.Material:draw"); - ok &= luaval_to_uint32(tolua_S, 7,&arg5, "cc.Material:draw"); + ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5, "cc.Material:draw"); - ok &= luaval_to_mat4(tolua_S, 8, &arg6, "cc.Material:draw"); + ok &= luaval_to_uint32(tolua_S, 8,&arg6, "cc.Material:draw"); + + ok &= luaval_to_mat4(tolua_S, 9, &arg7, "cc.Material:draw"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Material_draw'", nullptr); return 0; } - cobj->draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + cobj->draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Material:draw",argc, 7); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Material:draw",argc, 8); return 0; #if COCOS2D_DEBUG >= 1 @@ -89148,7 +89256,7 @@ int lua_cocos2dx_Pass_getVertexAttributeBinding(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_setUniformPointLightRangeInverse(lua_State* tolua_S) +int lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos(lua_State* tolua_S) { int argc = 0; cocos2d::Pass* cobj = nullptr; @@ -89168,7 +89276,7 @@ int lua_cocos2dx_Pass_setUniformPointLightRangeInverse(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'", nullptr); return 0; } #endif @@ -89182,22 +89290,22 @@ int lua_cocos2dx_Pass_setUniformPointLightRangeInverse(lua_State* tolua_S) #pragma warning NO CONVERSION TO NATIVE FOR void* ok = false; - ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.Pass:setUniformPointLightRangeInverse"); + ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.Pass:setUniformSpotLightOuterAngleCos"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'", nullptr); return 0; } - cobj->setUniformPointLightRangeInverse(arg0, arg1); + cobj->setUniformSpotLightOuterAngleCos(arg0, arg1); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setUniformPointLightRangeInverse",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setUniformSpotLightOuterAngleCos",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'.",&tolua_err); #endif return 0; @@ -89310,6 +89418,103 @@ int lua_cocos2dx_Pass_setUniformMatrixPalette(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Pass_setName(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Pass* 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.Pass",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Pass*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setName'", 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, "cc.Pass:setName"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setName'", nullptr); + return 0; + } + cobj->setName(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setName",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setName'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Pass_getName(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Pass* 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.Pass",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Pass*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_getName'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_getName'", nullptr); + return 0; + } + const std::string& ret = cobj->getName(); + lua_pushlstring(tolua_S,ret.c_str(),ret.length()); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:getName",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_getName'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Pass_setUniformSpotLightRangeInverse(lua_State* tolua_S) { int argc = 0; @@ -89364,6 +89569,53 @@ int lua_cocos2dx_Pass_setUniformSpotLightRangeInverse(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Pass_clone(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Pass* 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.Pass",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Pass*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_clone'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_clone'", nullptr); + return 0; + } + cocos2d::Pass* ret = cobj->clone(); + object_to_luaval(tolua_S, "cc.Pass",(cocos2d::Pass*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:clone",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_clone'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Pass_draw(lua_State* tolua_S) { int argc = 0; @@ -89390,39 +89642,42 @@ int lua_cocos2dx_Pass_draw(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 7) + if (argc == 8) { - double arg0; - cocos2d::backend::Buffer* arg1; + cocos2d::MeshCommand* arg0; + double arg1; cocos2d::backend::Buffer* arg2; - cocos2d::backend::PrimitiveType arg3; - cocos2d::backend::IndexFormat arg4; - unsigned int arg5; - cocos2d::Mat4 arg6; + cocos2d::backend::Buffer* arg3; + cocos2d::backend::PrimitiveType arg4; + cocos2d::backend::IndexFormat arg5; + unsigned int arg6; + cocos2d::Mat4 arg7; - ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Pass:draw"); + ok &= luaval_to_object(tolua_S, 2, "cc.MeshCommand",&arg0, "cc.Pass:draw"); - ok &= luaval_to_object(tolua_S, 3, "cc.Buffer",&arg1, "cc.Pass:draw"); + ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.Pass:draw"); ok &= luaval_to_object(tolua_S, 4, "cc.Buffer",&arg2, "cc.Pass:draw"); - ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "cc.Pass:draw"); + ok &= luaval_to_object(tolua_S, 5, "cc.Buffer",&arg3, "cc.Pass:draw"); ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "cc.Pass:draw"); - ok &= luaval_to_uint32(tolua_S, 7,&arg5, "cc.Pass:draw"); + ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5, "cc.Pass:draw"); - ok &= luaval_to_mat4(tolua_S, 8, &arg6, "cc.Pass:draw"); + ok &= luaval_to_uint32(tolua_S, 8,&arg6, "cc.Pass:draw"); + + ok &= luaval_to_mat4(tolua_S, 9, &arg7, "cc.Pass:draw"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_draw'", nullptr); return 0; } - cobj->draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + cobj->draw(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:draw",argc, 7); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:draw",argc, 8); return 0; #if COCOS2D_DEBUG >= 1 @@ -89432,7 +89687,7 @@ int lua_cocos2dx_Pass_draw(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_getVertexLayout(lua_State* tolua_S) +int lua_cocos2dx_Pass_setUniformPointLightRangeInverse(lua_State* tolua_S) { int argc = 0; cocos2d::Pass* cobj = nullptr; @@ -89452,29 +89707,36 @@ int lua_cocos2dx_Pass_getVertexLayout(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_getVertexLayout'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 0) + if (argc == 2) { + const void* arg0; + unsigned int arg1; + + #pragma warning NO CONVERSION TO NATIVE FOR void* + ok = false; + + ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.Pass:setUniformPointLightRangeInverse"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_getVertexLayout'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'", nullptr); return 0; } - cocos2d::backend::VertexLayout* ret = cobj->getVertexLayout(); - object_to_luaval(tolua_S, "cc.VertexLayout",(cocos2d::backend::VertexLayout*)ret); + cobj->setUniformPointLightRangeInverse(arg0, arg1); + lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:getVertexLayout",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setUniformPointLightRangeInverse",argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_getVertexLayout'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setUniformPointLightRangeInverse'.",&tolua_err); #endif return 0; @@ -89532,7 +89794,7 @@ int lua_cocos2dx_Pass_setUniformNormTexture(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_clone(lua_State* tolua_S) +int lua_cocos2dx_Pass_updateMVPUniform(lua_State* tolua_S) { int argc = 0; cocos2d::Pass* cobj = nullptr; @@ -89552,29 +89814,32 @@ int lua_cocos2dx_Pass_clone(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_clone'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_updateMVPUniform'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 0) + if (argc == 1) { + cocos2d::Mat4 arg0; + + ok &= luaval_to_mat4(tolua_S, 2, &arg0, "cc.Pass:updateMVPUniform"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_clone'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_updateMVPUniform'", nullptr); return 0; } - cocos2d::Pass* ret = cobj->clone(); - object_to_luaval(tolua_S, "cc.Pass",(cocos2d::Pass*)ret); + cobj->updateMVPUniform(arg0); + lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:clone",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:updateMVPUniform",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_clone'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_updateMVPUniform'.",&tolua_err); #endif return 0; @@ -89999,60 +90264,6 @@ int lua_cocos2dx_Pass_setUniformTexture(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Pass* 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.Pass",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Pass*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - const void* arg0; - unsigned int arg1; - - #pragma warning NO CONVERSION TO NATIVE FOR void* - ok = false; - - ok &= luaval_to_uint32(tolua_S, 3,&arg1, "cc.Pass:setUniformSpotLightOuterAngleCos"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'", nullptr); - return 0; - } - cobj->setUniformSpotLightOuterAngleCos(arg0, arg1); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Pass:setUniformSpotLightOuterAngleCos",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Pass_setUniformColor(lua_State* tolua_S) { int argc = 0; @@ -90251,14 +90462,17 @@ int lua_register_cocos2dx_Pass(lua_State* tolua_S) tolua_function(tolua_S,"setUniformSpotLightInnerAngleCos",lua_cocos2dx_Pass_setUniformSpotLightInnerAngleCos); tolua_function(tolua_S,"setTechnique",lua_cocos2dx_Pass_setTechnique); tolua_function(tolua_S,"getVertexAttributeBinding",lua_cocos2dx_Pass_getVertexAttributeBinding); - tolua_function(tolua_S,"setUniformPointLightRangeInverse",lua_cocos2dx_Pass_setUniformPointLightRangeInverse); + tolua_function(tolua_S,"setUniformSpotLightOuterAngleCos",lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos); tolua_function(tolua_S,"setUniformSpotLightDir",lua_cocos2dx_Pass_setUniformSpotLightDir); tolua_function(tolua_S,"setUniformMatrixPalette",lua_cocos2dx_Pass_setUniformMatrixPalette); + tolua_function(tolua_S,"setName",lua_cocos2dx_Pass_setName); + tolua_function(tolua_S,"getName",lua_cocos2dx_Pass_getName); tolua_function(tolua_S,"setUniformSpotLightRangeInverse",lua_cocos2dx_Pass_setUniformSpotLightRangeInverse); - tolua_function(tolua_S,"draw",lua_cocos2dx_Pass_draw); - tolua_function(tolua_S,"getVertexLayout",lua_cocos2dx_Pass_getVertexLayout); - tolua_function(tolua_S,"setUniformNormTexture",lua_cocos2dx_Pass_setUniformNormTexture); tolua_function(tolua_S,"clone",lua_cocos2dx_Pass_clone); + tolua_function(tolua_S,"draw",lua_cocos2dx_Pass_draw); + tolua_function(tolua_S,"setUniformPointLightRangeInverse",lua_cocos2dx_Pass_setUniformPointLightRangeInverse); + tolua_function(tolua_S,"setUniformNormTexture",lua_cocos2dx_Pass_setUniformNormTexture); + tolua_function(tolua_S,"updateMVPUniform",lua_cocos2dx_Pass_updateMVPUniform); tolua_function(tolua_S,"setUniformDirLightDir",lua_cocos2dx_Pass_setUniformDirLightDir); tolua_function(tolua_S,"getProgramState",lua_cocos2dx_Pass_getProgramState); tolua_function(tolua_S,"setUniformSpotLightColor",lua_cocos2dx_Pass_setUniformSpotLightColor); @@ -90267,7 +90481,6 @@ int lua_register_cocos2dx_Pass(lua_State* tolua_S) tolua_function(tolua_S,"setUniformSpotLightPosition",lua_cocos2dx_Pass_setUniformSpotLightPosition); tolua_function(tolua_S,"setVertexAttribBinding",lua_cocos2dx_Pass_setVertexAttribBinding); tolua_function(tolua_S,"setUniformTexture",lua_cocos2dx_Pass_setUniformTexture); - tolua_function(tolua_S,"setUniformSpotLightOuterAngleCos",lua_cocos2dx_Pass_setUniformSpotLightOuterAngleCos); tolua_function(tolua_S,"setUniformColor",lua_cocos2dx_Pass_setUniformColor); tolua_function(tolua_S,"setUniformPointLightColor",lua_cocos2dx_Pass_setUniformPointLightColor); tolua_function(tolua_S,"createWithProgramState", lua_cocos2dx_Pass_createWithProgramState); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index f579d32336..9709afcdf8 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2223,6 +2223,10 @@ int register_all_cocos2dx(lua_State* tolua_S); + + + + From 811b66b51e141ce9ee37ef725d2ca60ec7f26f7d Mon Sep 17 00:00:00 2001 From: patricejiang Date: Mon, 18 Mar 2019 10:31:56 +0800 Subject: [PATCH 17/18] fix doc of ProgramState::AutoBindingResolver --- cocos/renderer/backend/ProgramState.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos/renderer/backend/ProgramState.h b/cocos/renderer/backend/ProgramState.h index 3185a33c6e..72a8d86740 100644 --- a/cocos/renderer/backend/ProgramState.h +++ b/cocos/renderer/backend/ProgramState.h @@ -120,8 +120,7 @@ public: * that other auto binding resolvers get a chance to handle the parameter. * Otherwise, the parameter should be set or bound and true should be returned. * - * @param glProgramState The glProgramState - * @param node The node that the material is attached to. + * @param programState The ProgramState * @param uniformName Name of the uniform * @param autoBinding Name of the auto binding to be resolved. * @@ -140,7 +139,7 @@ public: * @param uniformName The name of the material parameter to store an auto-binding for. * @param autoBinding A string matching one of the built-in AutoBinding enum constants. */ - void setParameterAutoBinding(const std::string &, const std::string &); + void setParameterAutoBinding(const std::string &uniformName, const std::string &autoBinding); protected: From 98fa7af850e502c81386cd9712c3b8c2f288fee5 Mon Sep 17 00:00:00 2001 From: Arnold <397136899@qq.com> Date: Mon, 18 Mar 2019 14:54:35 +0800 Subject: [PATCH 18/18] fix linux compile error --- cocos/renderer/backend/ProgramState.cpp | 7 +++++-- cocos/renderer/backend/ProgramState.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cocos/renderer/backend/ProgramState.cpp b/cocos/renderer/backend/ProgramState.cpp index 51caeade02..cdc4c2138c 100644 --- a/cocos/renderer/backend/ProgramState.cpp +++ b/cocos/renderer/backend/ProgramState.cpp @@ -3,6 +3,9 @@ #include "renderer/backend/Program.h" #include "renderer/backend/Texture.h" #include "renderer/backend/Types.h" + +#include + #ifdef CC_USE_METAL #include "glsl_optimizer.h" #endif @@ -437,8 +440,8 @@ ProgramState::AutoBindingResolver::AutoBindingResolver() ProgramState::AutoBindingResolver::~AutoBindingResolver() { - auto it = std::find(std::begin(_customAutoBindingResolvers), std::end(_customAutoBindingResolvers), this); - if (it != std::end(_customAutoBindingResolvers)) _customAutoBindingResolvers.erase(it); + auto &list = _customAutoBindingResolvers; + list.erase(std::remove(list.begin(), list.end(), this), list.end()); } CC_BACKEND_END diff --git a/cocos/renderer/backend/ProgramState.h b/cocos/renderer/backend/ProgramState.h index 72a8d86740..101eab1d36 100644 --- a/cocos/renderer/backend/ProgramState.h +++ b/cocos/renderer/backend/ProgramState.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "platform/CCPlatformMacros.h" #include "base/CCRef.h" #include "renderer/backend/Types.h"