mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into const_char_star_to_std_string
Conflicts: cocos/2d/renderer/CCNewSprite.cpp cocos/2d/renderer/CCNewSprite.h cocos/2d/renderer/CCNewTextureAtlas.cpp cocos/2d/renderer/CCNewTextureAtlas.h
This commit is contained in:
commit
8e329501ba
|
@ -1 +1 @@
|
|||
1df2ba5492ecdbe0c160d2429733c1371b35b21a
|
||||
d5c3a61431f7098ddeabd3d035d501e3cc02c6b1
|
|
@ -117,10 +117,7 @@ platform/CCEGLViewProtocol.cpp \
|
|||
platform/CCFileUtils.cpp \
|
||||
platform/CCSAXParser.cpp \
|
||||
platform/CCThread.cpp \
|
||||
renderer/CCNewRenderTexture.cpp \
|
||||
renderer/CCNewSprite.cpp \
|
||||
renderer/CCNewSpriteBatchNode.cpp \
|
||||
renderer/CCNewTextureAtlas.cpp \
|
||||
renderer/CCCustomCommand.cpp \
|
||||
renderer/CCFrustum.cpp \
|
||||
renderer/CCGroupCommand.cpp \
|
||||
|
|
|
@ -867,6 +867,8 @@ void LabelBMFont::updateLabel()
|
|||
startOfLine = startOfWord;
|
||||
start_line = true;
|
||||
}
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Whitespace.
|
||||
|
|
|
@ -25,8 +25,8 @@ THE SOFTWARE.
|
|||
#ifndef __CCLABELTTF_H__
|
||||
#define __CCLABELTTF_H__
|
||||
|
||||
#include "renderer/CCNewSprite.h"
|
||||
#include "CCTexture2D.h"
|
||||
#include "CCSprite.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -54,7 +54,7 @@ NS_CC_BEGIN
|
|||
* @endcode
|
||||
*
|
||||
*/
|
||||
class CC_DLL LabelTTF : public NewSprite, public LabelProtocol
|
||||
class CC_DLL LabelTTF : public Sprite, public LabelProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -143,16 +143,6 @@ void ParticleBatchNode::visit()
|
|||
}
|
||||
|
||||
// override addChild:
|
||||
void ParticleBatchNode::addChild(Node * child)
|
||||
{
|
||||
Node::addChild(child);
|
||||
}
|
||||
|
||||
void ParticleBatchNode::addChild(Node * child, int zOrder)
|
||||
{
|
||||
Node::addChild(child, zOrder);
|
||||
}
|
||||
|
||||
void ParticleBatchNode::addChild(Node * aChild, int zOrder, int tag)
|
||||
{
|
||||
CCASSERT( aChild != nullptr, "Argument must be non-nullptr");
|
||||
|
|
|
@ -105,8 +105,8 @@ public:
|
|||
|
||||
// Overrides
|
||||
void visit();
|
||||
virtual void addChild(Node * child) override;
|
||||
virtual void addChild(Node * child, int zOrder) override;
|
||||
|
||||
using Node::addChild;
|
||||
virtual void addChild(Node * child, int zOrder, int tag) override;
|
||||
virtual void removeChild(Node* child, bool cleanup) override;
|
||||
virtual void reorderChild(Node * child, int zOrder) override;
|
||||
|
|
|
@ -37,6 +37,11 @@ THE SOFTWARE.
|
|||
#include "CCNotificationCenter.h"
|
||||
#include "CCEventType.h"
|
||||
#include "CCGrid.h"
|
||||
|
||||
#include "CCRenderer.h"
|
||||
#include "CCGroupCommand.h"
|
||||
#include "CCCustomCommand.h"
|
||||
|
||||
// extern
|
||||
#include "kazmath/GL/matrix.h"
|
||||
|
||||
|
@ -296,47 +301,6 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
|
|||
return ret;
|
||||
}
|
||||
|
||||
void RenderTexture::begin()
|
||||
{
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLPushMatrix();
|
||||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLPushMatrix();
|
||||
|
||||
Director *director = Director::getInstance();
|
||||
director->setProjection(director->getProjection());
|
||||
|
||||
const Size& texSize = _texture->getContentSizeInPixels();
|
||||
|
||||
// Calculate the adjustment ratios based on the old and new projections
|
||||
Size size = director->getWinSizeInPixels();
|
||||
float widthRatio = size.width / texSize.width;
|
||||
float heightRatio = size.height / texSize.height;
|
||||
|
||||
// Adjust the orthographic projection and viewport
|
||||
glViewport(0, 0, (GLsizei)texSize.width, (GLsizei)texSize.height);
|
||||
|
||||
|
||||
kmMat4 orthoMatrix;
|
||||
kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio, (float)1.0 / widthRatio,
|
||||
(float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 );
|
||||
kmGLMultMatrix(&orthoMatrix);
|
||||
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _FBO);
|
||||
|
||||
/* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. Create a temporary texture to overcome this. At the end of RenderTexture::begin(), switch the attached texture to the second one, call glClear, and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers.
|
||||
*/
|
||||
if (Configuration::getInstance()->checkForGLExtension("GL_QCOM"))
|
||||
{
|
||||
// -- bind a temporary texture so we can clear the render buffer without losing our texture
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _textureCopy->getName(), 0);
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture->getName(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderTexture::beginWithClear(float r, float g, float b, float a)
|
||||
{
|
||||
beginWithClear(r, g, b, a, 0, 0, GL_COLOR_BUFFER_BIT);
|
||||
|
@ -354,61 +318,21 @@ void RenderTexture::beginWithClear(float r, float g, float b, float a, float dep
|
|||
|
||||
void RenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags)
|
||||
{
|
||||
setClearColor(Color4F(r, g, b, a));
|
||||
|
||||
setClearDepth(depthValue);
|
||||
|
||||
setClearStencil(stencilValue);
|
||||
|
||||
setClearFlags(flags);
|
||||
|
||||
this->begin();
|
||||
|
||||
// save clear color
|
||||
GLfloat clearColor[4] = {0.0f};
|
||||
GLfloat depthClearValue = 0.0f;
|
||||
int stencilClearValue = 0;
|
||||
|
||||
if (flags & GL_COLOR_BUFFER_BIT)
|
||||
{
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE,clearColor);
|
||||
glClearColor(r, g, b, a);
|
||||
}
|
||||
|
||||
if (flags & GL_DEPTH_BUFFER_BIT)
|
||||
{
|
||||
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue);
|
||||
glClearDepth(depthValue);
|
||||
}
|
||||
|
||||
if (flags & GL_STENCIL_BUFFER_BIT)
|
||||
{
|
||||
glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilClearValue);
|
||||
glClearStencil(stencilValue);
|
||||
}
|
||||
|
||||
glClear(flags);
|
||||
|
||||
// restore
|
||||
if (flags & GL_COLOR_BUFFER_BIT)
|
||||
{
|
||||
glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
|
||||
}
|
||||
if (flags & GL_DEPTH_BUFFER_BIT)
|
||||
{
|
||||
glClearDepth(depthClearValue);
|
||||
}
|
||||
if (flags & GL_STENCIL_BUFFER_BIT)
|
||||
{
|
||||
glClearStencil(stencilClearValue);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderTexture::end()
|
||||
{
|
||||
Director *director = Director::getInstance();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO);
|
||||
|
||||
// restore viewport
|
||||
director->setViewport();
|
||||
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLPopMatrix();
|
||||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLPopMatrix();
|
||||
//clear screen
|
||||
CustomCommand* clearCmd = CustomCommand::getCommandPool().generateCommand();
|
||||
clearCmd->init(0, _vertexZ);
|
||||
clearCmd->func = CC_CALLBACK_0(RenderTexture::onClear, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(clearCmd);
|
||||
}
|
||||
|
||||
//TODO find a better way to clear the screen, there is no need to rebind render buffer there.
|
||||
|
@ -420,16 +344,16 @@ void RenderTexture::clear(float r, float g, float b, float a)
|
|||
|
||||
void RenderTexture::clearDepth(float depthValue)
|
||||
{
|
||||
setClearDepth(depthValue);
|
||||
|
||||
this->begin();
|
||||
//! save old depth value
|
||||
GLfloat depthClearValue;
|
||||
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue);
|
||||
|
||||
glClearDepth(depthValue);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
|
||||
cmd->init(0, _vertexZ);
|
||||
cmd->func = CC_CALLBACK_0(RenderTexture::onClearDepth, this);
|
||||
|
||||
Director::getInstance()->getRenderer()->addCommand(cmd);
|
||||
|
||||
// restore clear color
|
||||
glClearDepth(depthClearValue);
|
||||
this->end();
|
||||
}
|
||||
|
||||
|
@ -466,69 +390,6 @@ void RenderTexture::visit()
|
|||
_orderOfArrival = 0;
|
||||
}
|
||||
|
||||
void RenderTexture::draw()
|
||||
{
|
||||
if( _autoDraw)
|
||||
{
|
||||
begin();
|
||||
|
||||
if (_clearFlags)
|
||||
{
|
||||
GLfloat oldClearColor[4] = {0.0f};
|
||||
GLfloat oldDepthClearValue = 0.0f;
|
||||
GLint oldStencilClearValue = 0;
|
||||
|
||||
// backup and set
|
||||
if (_clearFlags & GL_COLOR_BUFFER_BIT)
|
||||
{
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, oldClearColor);
|
||||
glClearColor(_clearColor.r, _clearColor.g, _clearColor.b, _clearColor.a);
|
||||
}
|
||||
|
||||
if (_clearFlags & GL_DEPTH_BUFFER_BIT)
|
||||
{
|
||||
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &oldDepthClearValue);
|
||||
glClearDepth(_clearDepth);
|
||||
}
|
||||
|
||||
if (_clearFlags & GL_STENCIL_BUFFER_BIT)
|
||||
{
|
||||
glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &oldStencilClearValue);
|
||||
glClearStencil(_clearStencil);
|
||||
}
|
||||
|
||||
// clear
|
||||
glClear(_clearFlags);
|
||||
|
||||
// restore
|
||||
if (_clearFlags & GL_COLOR_BUFFER_BIT)
|
||||
{
|
||||
glClearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]);
|
||||
}
|
||||
if (_clearFlags & GL_DEPTH_BUFFER_BIT)
|
||||
{
|
||||
glClearDepth(oldDepthClearValue);
|
||||
}
|
||||
if (_clearFlags & GL_STENCIL_BUFFER_BIT)
|
||||
{
|
||||
glClearStencil(oldStencilClearValue);
|
||||
}
|
||||
}
|
||||
|
||||
//! make sure all children are drawn
|
||||
sortAllChildren();
|
||||
|
||||
for(const auto &child : _children) {
|
||||
if (child != _sprite)
|
||||
{
|
||||
child->visit();
|
||||
}
|
||||
}
|
||||
|
||||
end();
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderTexture::saveToFile(const std::string& filename)
|
||||
{
|
||||
bool ret = false;
|
||||
|
@ -625,4 +486,186 @@ Image* RenderTexture::newImage(bool fliimage)
|
|||
return image;
|
||||
}
|
||||
|
||||
void RenderTexture::onBegin()
|
||||
{
|
||||
//
|
||||
kmGLGetMatrix(KM_GL_PROJECTION, &_oldProjMatrix);
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLLoadMatrix(&_projectionMatrix);
|
||||
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix);
|
||||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLLoadMatrix(&_transformMatrix);
|
||||
|
||||
Director *director = Director::getInstance();
|
||||
director->setProjection(director->getProjection());
|
||||
|
||||
const Size& texSize = _texture->getContentSizeInPixels();
|
||||
|
||||
// Calculate the adjustment ratios based on the old and new projections
|
||||
Size size = director->getWinSizeInPixels();
|
||||
float widthRatio = size.width / texSize.width;
|
||||
float heightRatio = size.height / texSize.height;
|
||||
|
||||
// Adjust the orthographic projection and viewport
|
||||
glViewport(0, 0, (GLsizei)texSize.width, (GLsizei)texSize.height);
|
||||
|
||||
|
||||
kmMat4 orthoMatrix;
|
||||
kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio, (float)1.0 / widthRatio,
|
||||
(float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 );
|
||||
kmGLMultMatrix(&orthoMatrix);
|
||||
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _FBO);
|
||||
|
||||
//TODO move this to configration, so we don't check it every time
|
||||
/* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. Create a temporary texture to overcome this. At the end of RenderTexture::begin(), switch the attached texture to the second one, call glClear, and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers.
|
||||
*/
|
||||
if (Configuration::getInstance()->checkForGLExtension("GL_QCOM"))
|
||||
{
|
||||
// -- bind a temporary texture so we can clear the render buffer without losing our texture
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _textureCopy->getName(), 0);
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture->getName(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderTexture::onEnd()
|
||||
{
|
||||
Director *director = Director::getInstance();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO);
|
||||
|
||||
// restore viewport
|
||||
director->setViewport();
|
||||
|
||||
//
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLLoadMatrix(&_oldProjMatrix);
|
||||
|
||||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLLoadMatrix(&_oldTransMatrix);
|
||||
}
|
||||
|
||||
void RenderTexture::onClear()
|
||||
{
|
||||
// save clear color
|
||||
GLfloat oldClearColor[4] = {0.0f};
|
||||
GLfloat oldDepthClearValue = 0.0f;
|
||||
GLint oldStencilClearValue = 0;
|
||||
|
||||
// backup and set
|
||||
if (_clearFlags & GL_COLOR_BUFFER_BIT)
|
||||
{
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, oldClearColor);
|
||||
glClearColor(_clearColor.r, _clearColor.g, _clearColor.b, _clearColor.a);
|
||||
}
|
||||
|
||||
if (_clearFlags & GL_DEPTH_BUFFER_BIT)
|
||||
{
|
||||
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &oldDepthClearValue);
|
||||
glClearDepth(_clearDepth);
|
||||
}
|
||||
|
||||
if (_clearFlags & GL_STENCIL_BUFFER_BIT)
|
||||
{
|
||||
glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &oldStencilClearValue);
|
||||
glClearStencil(_clearStencil);
|
||||
}
|
||||
|
||||
// clear
|
||||
glClear(_clearFlags);
|
||||
|
||||
// restore
|
||||
if (_clearFlags & GL_COLOR_BUFFER_BIT)
|
||||
{
|
||||
glClearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]);
|
||||
}
|
||||
if (_clearFlags & GL_DEPTH_BUFFER_BIT)
|
||||
{
|
||||
glClearDepth(oldDepthClearValue);
|
||||
}
|
||||
if (_clearFlags & GL_STENCIL_BUFFER_BIT)
|
||||
{
|
||||
glClearStencil(oldStencilClearValue);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderTexture::onClearDepth()
|
||||
{
|
||||
//! save old depth value
|
||||
GLfloat depthClearValue;
|
||||
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue);
|
||||
|
||||
glClearDepth(_clearDepth);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// restore clear color
|
||||
glClearDepth(depthClearValue);
|
||||
}
|
||||
|
||||
void RenderTexture::draw()
|
||||
{
|
||||
if (_autoDraw)
|
||||
{
|
||||
//Begin will create a render group using new render target
|
||||
begin();
|
||||
|
||||
//clear screen
|
||||
CustomCommand* clearCmd = CustomCommand::getCommandPool().generateCommand();
|
||||
clearCmd->init(0, _vertexZ);
|
||||
clearCmd->func = CC_CALLBACK_0(RenderTexture::onClear, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(clearCmd);
|
||||
|
||||
//! make sure all children are drawn
|
||||
sortAllChildren();
|
||||
|
||||
for(const auto &child: _children)
|
||||
{
|
||||
if (child != _sprite)
|
||||
child->visit();
|
||||
}
|
||||
|
||||
//End will pop the current render group
|
||||
end();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderTexture::begin()
|
||||
{
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLPushMatrix();
|
||||
kmGLGetMatrix(KM_GL_PROJECTION, &_projectionMatrix);
|
||||
|
||||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLPushMatrix();
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix);
|
||||
|
||||
GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand();
|
||||
groupCommand->init(0, _vertexZ);
|
||||
|
||||
Renderer *renderer = Director::getInstance()->getRenderer();
|
||||
renderer->addCommand(groupCommand);
|
||||
renderer->pushGroup(groupCommand->getRenderQueueID());
|
||||
|
||||
CustomCommand* beginCmd = CustomCommand::getCommandPool().generateCommand();
|
||||
beginCmd->init(0, _vertexZ);
|
||||
beginCmd->func = CC_CALLBACK_0(RenderTexture::onBegin, this);
|
||||
|
||||
Director::getInstance()->getRenderer()->addCommand(beginCmd);
|
||||
}
|
||||
|
||||
void RenderTexture::end()
|
||||
{
|
||||
CustomCommand* endCmd = CustomCommand::getCommandPool().generateCommand();
|
||||
endCmd->init(0, _vertexZ);
|
||||
endCmd->func = CC_CALLBACK_0(RenderTexture::onEnd, this);
|
||||
|
||||
Renderer *renderer = Director::getInstance()->getRenderer();
|
||||
renderer->addCommand(endCmd);
|
||||
renderer->popGroup();
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -187,7 +187,16 @@ protected:
|
|||
- [[renderTexture sprite] setBlendFunc:(BlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];
|
||||
*/
|
||||
Sprite* _sprite;
|
||||
protected:
|
||||
//renderer caches and callbacks
|
||||
void onBegin();
|
||||
void onEnd();
|
||||
|
||||
void onClear();
|
||||
void onClearDepth();
|
||||
|
||||
kmMat4 _oldTransMatrix, _oldProjMatrix;
|
||||
kmMat4 _transformMatrix, _projectionMatrix;
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(RenderTexture);
|
||||
|
||||
|
|
|
@ -121,16 +121,6 @@ bool Scene::initWithPhysics()
|
|||
return ret;
|
||||
}
|
||||
|
||||
void Scene::addChild(Node* child)
|
||||
{
|
||||
Node::addChild(child);
|
||||
}
|
||||
|
||||
void Scene::addChild(Node* child, int zOrder)
|
||||
{
|
||||
Node::addChild(child, zOrder);
|
||||
}
|
||||
|
||||
void Scene::addChild(Node* child, int zOrder, int tag)
|
||||
{
|
||||
Node::addChild(child, zOrder, tag);
|
||||
|
|
|
@ -64,8 +64,7 @@ public:
|
|||
|
||||
inline PhysicsWorld* getPhysicsWorld() { return _physicsWorld; }
|
||||
|
||||
virtual void addChild(Node* child) override;
|
||||
virtual void addChild(Node* child, int zOrder) override;
|
||||
using Node::addChild;
|
||||
virtual void addChild(Node* child, int zOrder, int tag) override;
|
||||
virtual void update(float delta) override;
|
||||
virtual std::string getDescription() const override;
|
||||
|
|
|
@ -222,6 +222,7 @@ bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame)
|
|||
// designated initializer
|
||||
bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
|
||||
{
|
||||
bool result;
|
||||
if (Node::init())
|
||||
{
|
||||
_batchNode = nullptr;
|
||||
|
@ -262,13 +263,15 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
|
|||
// by default use "Self Render".
|
||||
// if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render"
|
||||
setBatchNode(nullptr);
|
||||
|
||||
return true;
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
result = false;
|
||||
}
|
||||
_recursiveDirty = true;
|
||||
setDirty(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
Sprite::Sprite(void)
|
||||
|
@ -694,7 +697,7 @@ bool Sprite::culling() const
|
|||
Rect newRect = RectApplyTransform(_rect, worldTM);
|
||||
|
||||
kmVec3 point = {newRect.getMinX(), newRect.getMinY(), _vertexZ};
|
||||
|
||||
|
||||
AABB aabb(point,point);
|
||||
kmVec3Fill(&point,newRect.getMaxX(), newRect.getMinY(), _vertexZ);
|
||||
aabb.expand(point);
|
||||
|
@ -725,8 +728,8 @@ void Sprite::updateQuadVertices()
|
|||
// }
|
||||
// else
|
||||
// {
|
||||
// CCASSERT( dynamic_cast<NewSprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite");
|
||||
// _transformToBatch = AffineTransformConcat( getNodeToParentTransform() , static_cast<NewSprite*>(_parent)->_transformToBatch );
|
||||
// CCASSERT( dynamic_cast<Sprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite");
|
||||
// _transformToBatch = AffineTransformConcat( getNodeToParentTransform() , static_cast<Sprite*>(_parent)->_transformToBatch );
|
||||
// }
|
||||
|
||||
//TODO optimize this transformation, should use parent's transformation instead
|
||||
|
@ -749,16 +752,6 @@ void Sprite::updateQuadVertices()
|
|||
|
||||
// Node overrides
|
||||
|
||||
void Sprite::addChild(Node *child)
|
||||
{
|
||||
Node::addChild(child);
|
||||
}
|
||||
|
||||
void Sprite::addChild(Node *child, int zOrder)
|
||||
{
|
||||
Node::addChild(child, zOrder);
|
||||
}
|
||||
|
||||
void Sprite::addChild(Node *child, int zOrder, int tag)
|
||||
{
|
||||
CCASSERT(child != nullptr, "Argument must be non-nullptr");
|
||||
|
|
|
@ -413,10 +413,7 @@ public:
|
|||
virtual void removeChild(Node* child, bool cleanup) override;
|
||||
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
|
||||
virtual void reorderChild(Node *child, int zOrder) override;
|
||||
// Should also override addChild(Node*) and addChild(Node*, int), or binding generator will only
|
||||
// bind addChild(Node*, int, int);
|
||||
virtual void addChild(Node* child) override;
|
||||
virtual void addChild(Node* child, int zOrder) override;
|
||||
using Node::addChild;
|
||||
virtual void addChild(Node *child, int zOrder, int tag) override;
|
||||
virtual void sortAllChildren() override;
|
||||
virtual void setScale(float scale) override;
|
||||
|
|
|
@ -154,8 +154,8 @@ public:
|
|||
virtual const BlendFunc& getBlendFunc() const override;
|
||||
|
||||
virtual void visit() override;
|
||||
virtual void addChild(Node* child) override{ Node::addChild(child);}
|
||||
virtual void addChild(Node * child, int zOrder) override { Node::addChild(child, zOrder);}
|
||||
|
||||
using Node::addChild;
|
||||
virtual void addChild(Node * child, int zOrder, int tag) override;
|
||||
virtual void reorderChild(Node *child, int zOrder) override;
|
||||
|
||||
|
|
|
@ -185,6 +185,7 @@ public:
|
|||
/** TMXLayer doesn't support adding a Sprite manually.
|
||||
@warning addchild(z, tag); is not supported on TMXLayer. Instead of setTileGID.
|
||||
*/
|
||||
using SpriteBatchNode::addChild;
|
||||
virtual void addChild(Node * child, int zOrder, int tag) override;
|
||||
// super method
|
||||
void removeChild(Node* child, bool cleanup) override;
|
||||
|
|
|
@ -35,8 +35,6 @@ THE SOFTWARE.
|
|||
#include "CCLayer.h"
|
||||
#include "CCRenderTexture.h"
|
||||
#include "CCNodeGrid.h"
|
||||
#include "CCNewRenderTexture.h"
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -1275,7 +1273,7 @@ void TransitionCrossFade::onEnter()
|
|||
LayerColor* layer = LayerColor::create(color);
|
||||
|
||||
// create the first render texture for inScene
|
||||
RenderTexture* inTexture = NewRenderTexture::create((int)size.width, (int)size.height);
|
||||
RenderTexture* inTexture = RenderTexture::create((int)size.width, (int)size.height);
|
||||
|
||||
if (nullptr == inTexture)
|
||||
{
|
||||
|
@ -1292,7 +1290,7 @@ void TransitionCrossFade::onEnter()
|
|||
inTexture->end();
|
||||
|
||||
// create the second render texture for outScene
|
||||
RenderTexture* outTexture = NewRenderTexture::create((int)size.width, (int)size.height);
|
||||
RenderTexture* outTexture = RenderTexture::create((int)size.width, (int)size.height);
|
||||
outTexture->getSprite()->setAnchorPoint( Point(0.5f,0.5f) );
|
||||
outTexture->setPosition( Point(size.width/2, size.height/2) );
|
||||
outTexture->setAnchorPoint( Point(0.5f,0.5f) );
|
||||
|
|
|
@ -32,7 +32,6 @@ THE SOFTWARE.
|
|||
#include "CCLayer.h"
|
||||
#include "CCActionInstant.h"
|
||||
#include "CCActionProgressTimer.h"
|
||||
#include "CCNewRenderTexture.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -72,7 +71,7 @@ void TransitionProgress::onEnter()
|
|||
Size size = Director::getInstance()->getWinSize();
|
||||
|
||||
// create the second render texture for outScene
|
||||
RenderTexture *texture = NewRenderTexture::create((int)size.width, (int)size.height);
|
||||
RenderTexture *texture = RenderTexture::create((int)size.width, (int)size.height);
|
||||
texture->getSprite()->setAnchorPoint(Point(0.5f,0.5f));
|
||||
texture->setPosition(Point(size.width/2, size.height/2));
|
||||
texture->setAnchorPoint(Point(0.5f,0.5f));
|
||||
|
|
|
@ -139,10 +139,7 @@ set(COCOS2D_SRC
|
|||
platform/CCEGLViewProtocol.cpp
|
||||
platform/CCFileUtils.cpp
|
||||
../../external/edtaa3func/edtaa3func.cpp
|
||||
renderer/CCNewRenderTexture.cpp
|
||||
renderer/CCNewSprite.cpp
|
||||
renderer/CCNewSpriteBatchNode.cpp
|
||||
renderer/CCNewTextureAtlas.cpp
|
||||
renderer/CCCustomCommand.cpp
|
||||
renderer/CCFrustum.cpp
|
||||
renderer/CCGroupCommand.cpp
|
||||
|
|
|
@ -119,10 +119,7 @@ THE SOFTWARE.
|
|||
#include "CCParticleSystemQuad.h"
|
||||
|
||||
// new renderer
|
||||
#include "renderer/CCNewRenderTexture.h"
|
||||
#include "renderer/CCNewSprite.h"
|
||||
#include "renderer/CCNewSpriteBatchNode.h"
|
||||
#include "renderer/CCNewTextureAtlas.h"
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
#include "renderer/CCFrustum.h"
|
||||
#include "renderer/CCGroupCommand.h"
|
||||
|
|
|
@ -1,316 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "CCNewRenderTexture.h"
|
||||
#include "CCCustomCommand.h"
|
||||
#include "CCRenderer.h"
|
||||
#include "CCGroupCommand.h"
|
||||
#include "CCConfiguration.h"
|
||||
#include "CCDirector.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
NewRenderTexture* NewRenderTexture::create(int w, int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat)
|
||||
{
|
||||
NewRenderTexture* pRet = new NewRenderTexture();
|
||||
|
||||
if(pRet && pRet->initWithWidthAndHeight(w, h, eFormat, uDepthStencilFormat))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CC_SAFE_DELETE(pRet);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NewRenderTexture* NewRenderTexture::create(int w, int h, Texture2D::PixelFormat eFormat)
|
||||
{
|
||||
NewRenderTexture* pRet = new NewRenderTexture();
|
||||
|
||||
if(pRet && pRet->initWithWidthAndHeight(w, h, eFormat))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CC_SAFE_DELETE(pRet);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NewRenderTexture* NewRenderTexture::create(int w, int h)
|
||||
{
|
||||
NewRenderTexture* pRet = new NewRenderTexture();
|
||||
|
||||
if(pRet && pRet->initWithWidthAndHeight(w, h, Texture2D::PixelFormat::RGB888 , 0))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CC_SAFE_DELETE(pRet);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NewRenderTexture::draw()
|
||||
{
|
||||
if (_autoDraw)
|
||||
{
|
||||
//Begin will create a render group using new render target
|
||||
begin();
|
||||
|
||||
//clear screen
|
||||
CustomCommand* clearCmd = CustomCommand::getCommandPool().generateCommand();
|
||||
clearCmd->init(0, _vertexZ);
|
||||
clearCmd->func = CC_CALLBACK_0(NewRenderTexture::onClear, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(clearCmd);
|
||||
|
||||
//! make sure all children are drawn
|
||||
sortAllChildren();
|
||||
|
||||
for(const auto &child: _children)
|
||||
{
|
||||
if (child != _sprite)
|
||||
child->visit();
|
||||
}
|
||||
|
||||
//End will pop the current render group
|
||||
end();
|
||||
}
|
||||
}
|
||||
|
||||
void NewRenderTexture::beginWithClear(float r, float g, float b, float a)
|
||||
{
|
||||
beginWithClear(r, g, b, a, 0, 0, GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void NewRenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue)
|
||||
{
|
||||
beginWithClear(r, g, b, a, depthValue, 0, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void NewRenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue)
|
||||
{
|
||||
beginWithClear(r, g, b, a, depthValue, stencilValue, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void NewRenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags)
|
||||
{
|
||||
setClearColor(Color4F(r, g, b, a));
|
||||
|
||||
setClearDepth(depthValue);
|
||||
|
||||
setClearStencil(stencilValue);
|
||||
|
||||
setClearFlags(flags);
|
||||
|
||||
this->begin();
|
||||
|
||||
//clear screen
|
||||
CustomCommand* clearCmd = CustomCommand::getCommandPool().generateCommand();
|
||||
clearCmd->init(0, _vertexZ);
|
||||
clearCmd->func = CC_CALLBACK_0(NewRenderTexture::onClear, this);
|
||||
Director::getInstance()->getRenderer()->addCommand(clearCmd);
|
||||
}
|
||||
|
||||
void NewRenderTexture::begin()
|
||||
{
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLPushMatrix();
|
||||
kmGLGetMatrix(KM_GL_PROJECTION, &_projectionMatrix);
|
||||
|
||||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLPushMatrix();
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix);
|
||||
|
||||
GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand();
|
||||
groupCommand->init(0, _vertexZ);
|
||||
|
||||
Renderer *renderer = Director::getInstance()->getRenderer();
|
||||
renderer->addCommand(groupCommand);
|
||||
renderer->pushGroup(groupCommand->getRenderQueueID());
|
||||
|
||||
CustomCommand* beginCmd = CustomCommand::getCommandPool().generateCommand();
|
||||
beginCmd->init(0, _vertexZ);
|
||||
beginCmd->func = CC_CALLBACK_0(NewRenderTexture::onBegin, this);
|
||||
|
||||
Director::getInstance()->getRenderer()->addCommand(beginCmd);
|
||||
}
|
||||
|
||||
void NewRenderTexture::end()
|
||||
{
|
||||
CustomCommand* endCmd = CustomCommand::getCommandPool().generateCommand();
|
||||
endCmd->init(0, _vertexZ);
|
||||
endCmd->func = CC_CALLBACK_0(NewRenderTexture::onEnd, this);
|
||||
|
||||
Renderer *renderer = Director::getInstance()->getRenderer();
|
||||
renderer->addCommand(endCmd);
|
||||
renderer->popGroup();
|
||||
}
|
||||
|
||||
void NewRenderTexture::onBegin()
|
||||
{
|
||||
//
|
||||
kmGLGetMatrix(KM_GL_PROJECTION, &_oldProjMatrix);
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLLoadMatrix(&_projectionMatrix);
|
||||
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix);
|
||||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLLoadMatrix(&_transformMatrix);
|
||||
|
||||
Director *director = Director::getInstance();
|
||||
director->setProjection(director->getProjection());
|
||||
|
||||
const Size& texSize = _texture->getContentSizeInPixels();
|
||||
|
||||
// Calculate the adjustment ratios based on the old and new projections
|
||||
Size size = director->getWinSizeInPixels();
|
||||
float widthRatio = size.width / texSize.width;
|
||||
float heightRatio = size.height / texSize.height;
|
||||
|
||||
// Adjust the orthographic projection and viewport
|
||||
glViewport(0, 0, (GLsizei)texSize.width, (GLsizei)texSize.height);
|
||||
|
||||
|
||||
kmMat4 orthoMatrix;
|
||||
kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio, (float)1.0 / widthRatio,
|
||||
(float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 );
|
||||
kmGLMultMatrix(&orthoMatrix);
|
||||
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _FBO);
|
||||
|
||||
//TODO move this to configration, so we don't check it every time
|
||||
/* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. Create a temporary texture to overcome this. At the end of RenderTexture::begin(), switch the attached texture to the second one, call glClear, and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers.
|
||||
*/
|
||||
if (Configuration::getInstance()->checkForGLExtension("GL_QCOM"))
|
||||
{
|
||||
// -- bind a temporary texture so we can clear the render buffer without losing our texture
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _textureCopy->getName(), 0);
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture->getName(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void NewRenderTexture::onEnd()
|
||||
{
|
||||
Director *director = Director::getInstance();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO);
|
||||
|
||||
// restore viewport
|
||||
director->setViewport();
|
||||
|
||||
//
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLLoadMatrix(&_oldProjMatrix);
|
||||
|
||||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLLoadMatrix(&_oldTransMatrix);
|
||||
}
|
||||
|
||||
void NewRenderTexture::onClear()
|
||||
{
|
||||
// save clear color
|
||||
GLfloat oldClearColor[4] = {0.0f};
|
||||
GLfloat oldDepthClearValue = 0.0f;
|
||||
GLint oldStencilClearValue = 0;
|
||||
|
||||
// backup and set
|
||||
if (_clearFlags & GL_COLOR_BUFFER_BIT)
|
||||
{
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, oldClearColor);
|
||||
glClearColor(_clearColor.r, _clearColor.g, _clearColor.b, _clearColor.a);
|
||||
}
|
||||
|
||||
if (_clearFlags & GL_DEPTH_BUFFER_BIT)
|
||||
{
|
||||
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &oldDepthClearValue);
|
||||
glClearDepth(_clearDepth);
|
||||
}
|
||||
|
||||
if (_clearFlags & GL_STENCIL_BUFFER_BIT)
|
||||
{
|
||||
glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &oldStencilClearValue);
|
||||
glClearStencil(_clearStencil);
|
||||
}
|
||||
|
||||
// clear
|
||||
glClear(_clearFlags);
|
||||
|
||||
// restore
|
||||
if (_clearFlags & GL_COLOR_BUFFER_BIT)
|
||||
{
|
||||
glClearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]);
|
||||
}
|
||||
if (_clearFlags & GL_DEPTH_BUFFER_BIT)
|
||||
{
|
||||
glClearDepth(oldDepthClearValue);
|
||||
}
|
||||
if (_clearFlags & GL_STENCIL_BUFFER_BIT)
|
||||
{
|
||||
glClearStencil(oldStencilClearValue);
|
||||
}
|
||||
}
|
||||
|
||||
void NewRenderTexture::clearDepth(float depthValue)
|
||||
{
|
||||
setClearDepth(depthValue);
|
||||
|
||||
this->begin();
|
||||
|
||||
CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand();
|
||||
cmd->init(0, _vertexZ);
|
||||
cmd->func = CC_CALLBACK_0(NewRenderTexture::onClearDepth, this);
|
||||
|
||||
Director::getInstance()->getRenderer()->addCommand(cmd);
|
||||
|
||||
this->end();
|
||||
}
|
||||
|
||||
void NewRenderTexture::onClearDepth()
|
||||
{
|
||||
//! save old depth value
|
||||
GLfloat depthClearValue;
|
||||
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue);
|
||||
|
||||
glClearDepth(_clearDepth);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// restore clear color
|
||||
glClearDepth(depthClearValue);
|
||||
}
|
||||
|
||||
NewRenderTexture::NewRenderTexture()
|
||||
:RenderTexture()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NewRenderTexture::~NewRenderTexture()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -1,67 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCNewRenderTexture_H_
|
||||
#define __CCNewRenderTexture_H_
|
||||
|
||||
#include "CCRenderTexture.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class NewRenderTexture : public RenderTexture
|
||||
{
|
||||
public:
|
||||
static NewRenderTexture* create(int w, int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat);
|
||||
static NewRenderTexture* create(int w, int h, Texture2D::PixelFormat eFormat);
|
||||
static NewRenderTexture* create(int w, int h);
|
||||
|
||||
void beginWithClear(float r, float g, float b, float a);
|
||||
void beginWithClear(float r, float g, float b, float a, float depthValue);
|
||||
void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue);
|
||||
void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags);
|
||||
|
||||
virtual void begin() override;
|
||||
virtual void end() override;
|
||||
virtual void draw() override;
|
||||
|
||||
void clearDepth(float depthValue);
|
||||
|
||||
protected:
|
||||
NewRenderTexture();
|
||||
virtual ~NewRenderTexture();
|
||||
|
||||
void onBegin();
|
||||
void onEnd();
|
||||
|
||||
//Clear render buffer
|
||||
void onClear();
|
||||
void onClearDepth();
|
||||
|
||||
kmMat4 _oldTransMatrix, _oldProjMatrix;
|
||||
kmMat4 _transformMatrix, _projectionMatrix;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif //__CCNewRenderTexture_H_
|
|
@ -1,165 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCNewSprite.h"
|
||||
#include "CCRenderer.h"
|
||||
#include "CCFrustum.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCQuadCommand.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
#if CC_SPRITEBATCHNODE_RENDER_SUBPIXEL
|
||||
#define RENDER_IN_SUBPIXEL
|
||||
#else
|
||||
#define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__))
|
||||
#endif
|
||||
|
||||
NewSprite* NewSprite::create()
|
||||
{
|
||||
NewSprite* sprite = new NewSprite();
|
||||
if(sprite && sprite->init())
|
||||
{
|
||||
sprite->autorelease();
|
||||
return sprite;
|
||||
}
|
||||
CC_SAFE_DELETE(sprite);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NewSprite* NewSprite::create(const std::string& filename)
|
||||
{
|
||||
NewSprite* sprite = new NewSprite();
|
||||
if(sprite && sprite->initWithFile(filename))
|
||||
{
|
||||
sprite->autorelease();
|
||||
return sprite;
|
||||
}
|
||||
CC_SAFE_DELETE(sprite);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NewSprite::NewSprite()
|
||||
:Sprite()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NewSprite::~NewSprite(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool NewSprite::initWithTexture(Texture2D *texture, const Rect &rect, bool rotated)
|
||||
{
|
||||
bool result = Sprite::initWithTexture(texture, rect, rotated);
|
||||
_recursiveDirty = true;
|
||||
setDirty(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
void NewSprite::updateQuadVertices()
|
||||
{
|
||||
#ifdef CC_USE_PHYSICS
|
||||
updatePhysicsTransform();
|
||||
setDirty(true);
|
||||
#endif
|
||||
|
||||
//TODO optimize the performance cache affineTransformation
|
||||
|
||||
// recalculate matrix only if it is dirty
|
||||
if(isDirty())
|
||||
{
|
||||
|
||||
// if( ! _parent || _parent == (Node*)_batchNode )
|
||||
// {
|
||||
// _transformToBatch = getNodeToParentTransform();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// CCASSERT( dynamic_cast<NewSprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite");
|
||||
// _transformToBatch = AffineTransformConcat( getNodeToParentTransform() , static_cast<NewSprite*>(_parent)->_transformToBatch );
|
||||
// }
|
||||
|
||||
//TODO optimize this transformation, should use parent's transformation instead
|
||||
_transformToBatch = getNodeToWorldTransform();
|
||||
|
||||
//
|
||||
// calculate the Quad based on the Affine Matrix
|
||||
//
|
||||
Rect newRect = RectApplyTransform(_rect, _transformToBatch);
|
||||
|
||||
_quad.bl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(newRect.getMinX()), RENDER_IN_SUBPIXEL(newRect.getMinY()), _vertexZ );
|
||||
_quad.br.vertices = Vertex3F( RENDER_IN_SUBPIXEL(newRect.getMaxX()), RENDER_IN_SUBPIXEL(newRect.getMinY()), _vertexZ );
|
||||
_quad.tl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(newRect.getMinX()), RENDER_IN_SUBPIXEL(newRect.getMaxY()), _vertexZ );
|
||||
_quad.tr.vertices = Vertex3F( RENDER_IN_SUBPIXEL(newRect.getMaxX()), RENDER_IN_SUBPIXEL(newRect.getMaxY()), _vertexZ );
|
||||
|
||||
_recursiveDirty = false;
|
||||
setDirty(false);
|
||||
}
|
||||
}
|
||||
|
||||
void NewSprite::draw(void)
|
||||
{
|
||||
kmMat4 mv;
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &mv);
|
||||
//TODO implement z order
|
||||
QuadCommand* renderCommand = QuadCommand::getCommandPool().generateCommand();
|
||||
renderCommand->init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv);
|
||||
|
||||
if(!culling())
|
||||
{
|
||||
renderCommand->releaseToCommandPool();
|
||||
return;
|
||||
}
|
||||
|
||||
Director::getInstance()->getRenderer()->addCommand(renderCommand);
|
||||
}
|
||||
|
||||
bool NewSprite::culling() const
|
||||
{
|
||||
Frustum* frustum = Director::getInstance()->getFrustum();
|
||||
//TODO optimize this transformation, should use parent's transformation instead
|
||||
kmMat4 worldTM = getNodeToWorldTransform();
|
||||
//generate aabb
|
||||
|
||||
//
|
||||
// calculate the Quad based on the Affine Matrix
|
||||
//
|
||||
Rect newRect = RectApplyTransform(_rect, worldTM);
|
||||
|
||||
kmVec3 point = {newRect.getMinX(), newRect.getMinY(), _vertexZ};
|
||||
|
||||
AABB aabb(point,point);
|
||||
kmVec3Fill(&point,newRect.getMaxX(), newRect.getMinY(), _vertexZ);
|
||||
aabb.expand(point);
|
||||
kmVec3Fill(&point,newRect.getMinX(), newRect.getMaxY(), _vertexZ);
|
||||
aabb.expand(point);
|
||||
kmVec3Fill(&point,newRect.getMaxX(), newRect.getMaxY(), _vertexZ);
|
||||
aabb.expand(point);
|
||||
|
||||
return Frustum::IntersectResult::OUTSIDE !=frustum->intersectAABB(aabb);
|
||||
}
|
||||
|
||||
|
||||
NS_CC_END
|
|
@ -1,54 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCNEWSPRITE_H_
|
||||
#define __CCNEWSPRITE_H_
|
||||
|
||||
#include "CCSprite.h"
|
||||
#include "CCPlatformMacros.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class NewSprite : public Sprite
|
||||
{
|
||||
|
||||
public:
|
||||
static NewSprite* create();
|
||||
static NewSprite* create(const std::string& filename);
|
||||
|
||||
virtual void updateQuadVertices();
|
||||
virtual void draw(void) override;
|
||||
|
||||
bool culling() const;
|
||||
|
||||
protected:
|
||||
NewSprite(void);
|
||||
~NewSprite();
|
||||
|
||||
virtual bool initWithTexture(Texture2D *texture, const Rect& rect, bool rotated);
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif /* defined(__CCNEWSPRITE_H_) */
|
|
@ -27,7 +27,6 @@
|
|||
#include "CCShaderCache.h"
|
||||
#include "CCTextureCache.h"
|
||||
#include "CCSprite.h"
|
||||
#include "CCNewSprite.h"
|
||||
#include "CCQuadCommand.h"
|
||||
#include "CCRenderer.h"
|
||||
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCNewTextureAtlas.h"
|
||||
#include "CCTexture2D.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCRenderer.h"
|
||||
#include "CCQuadCommand.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
NewTextureAtlas::NewTextureAtlas()
|
||||
:TextureAtlas()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NewTextureAtlas::~NewTextureAtlas()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NewTextureAtlas *NewTextureAtlas::create(const std::string& file, long capacity)
|
||||
{
|
||||
NewTextureAtlas * textureAtlas = new NewTextureAtlas();
|
||||
if(textureAtlas && textureAtlas->initWithFile(file, capacity))
|
||||
{
|
||||
textureAtlas->autorelease();
|
||||
return textureAtlas;
|
||||
}
|
||||
CC_SAFE_DELETE(textureAtlas);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NewTextureAtlas *NewTextureAtlas::createWithTexture(Texture2D *texture, long capacity)
|
||||
{
|
||||
NewTextureAtlas * textureAtlas = new NewTextureAtlas();
|
||||
if (textureAtlas && textureAtlas->initWithTexture(texture, capacity))
|
||||
{
|
||||
textureAtlas->autorelease();
|
||||
return textureAtlas;
|
||||
}
|
||||
CC_SAFE_DELETE(textureAtlas);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void NewTextureAtlas::drawNumberOfQuads(long numberOfQuads, long start)
|
||||
{
|
||||
// updateTransform();
|
||||
// QuadCommand* renderCommand = new QuadCommand(0, 0,_texture->getName(), _shaderProgram, _blendFunc, _quad);
|
||||
//
|
||||
// Renderer::getInstance()->addCommand(renderCommand);
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -1,50 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#ifndef __CCNewTextureAtlas_H_
|
||||
#define __CCNewTextureAtlas_H_
|
||||
|
||||
#include "CCPlatformMacros.h"
|
||||
#include "CCTextureAtlas.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class NewTextureAtlas : public TextureAtlas
|
||||
{
|
||||
public:
|
||||
static NewTextureAtlas* create(const std::string& file, long capacity);
|
||||
static NewTextureAtlas* createWithTexture(Texture2D *texture, long capacity);
|
||||
|
||||
void drawNumberOfQuads(long numberOfQuads, long start);
|
||||
|
||||
protected:
|
||||
NewTextureAtlas();
|
||||
virtual ~NewTextureAtlas();
|
||||
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif //__CCNewTextureAtlas_H_
|
|
@ -555,7 +555,7 @@ void PhysicsBody::setVelocity(const Point& velocity)
|
|||
{
|
||||
if (!_dynamic)
|
||||
{
|
||||
CCLOG("physics warning: your cann't set velocity for a static body.");
|
||||
CCLOG("physics warning: your can't set velocity for a static body.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -581,7 +581,7 @@ void PhysicsBody::setAngularVelocity(float velocity)
|
|||
{
|
||||
if (!_dynamic)
|
||||
{
|
||||
CCLOG("physics warning: your cann't set angular velocity for a static body.");
|
||||
CCLOG("physics warning: your can't set angular velocity for a static body.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit a388e918ef871c0fcfeb69bd71b1c784747871b8
|
||||
Subproject commit 3b8073deee86beb5ede81a24e3ccbfef711bfa41
|
|
@ -1 +1 @@
|
|||
4f58619fbbaa2bb184766db408386d247df236ce
|
||||
4ff49d7d50964fb117a48243d728d75dd6d5ef77
|
|
@ -350,7 +350,7 @@ private:
|
|||
return false;
|
||||
}
|
||||
|
||||
bool callJSDelegate(TableView* table, long idx, std::string jsFunctionName, jsval& retVal)
|
||||
bool callJSDelegate(TableView* table, ssize_t idx, std::string jsFunctionName, jsval& retVal)
|
||||
{
|
||||
js_proxy_t * p = jsb_get_native_proxy(table);
|
||||
if (!p) return false;
|
||||
|
@ -360,7 +360,7 @@ private:
|
|||
JS::RootedValue temp_retval(cx);
|
||||
jsval dataVal[2];
|
||||
dataVal[0] = OBJECT_TO_JSVAL(p->obj);
|
||||
dataVal[1] = long_to_jsval(cx,idx);
|
||||
dataVal[1] = ssize_to_jsval(cx,idx);
|
||||
|
||||
JSObject* obj = _JSTableViewDataSource;
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
|
@ -377,9 +377,9 @@ private:
|
|||
return false;
|
||||
}
|
||||
|
||||
JS_CallFunctionName(cx, obj, jsFunctionName.c_str(),
|
||||
JSBool ret = JS_CallFunctionName(cx, obj, jsFunctionName.c_str(),
|
||||
2, dataVal, &retVal);
|
||||
return true;
|
||||
return ret == JS_TRUE ? true : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1425,14 +1425,81 @@ bool luaval_to_ccvaluevector(lua_State* L, int lo, cocos2d::ValueVector* ret)
|
|||
|
||||
bool luaval_to_std_vector_string(lua_State* L, int lo, std::vector<std::string>* ret)
|
||||
{
|
||||
// TO BE DONE IN CPP FILE
|
||||
return false;
|
||||
if (nullptr == L || nullptr == ret || lua_gettop(L) < lo)
|
||||
return false;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
bool ok = true;
|
||||
if (!tolua_istable(L, lo, 0, &tolua_err))
|
||||
{
|
||||
#if COCOS2D_DEBUG >=1
|
||||
luaval_to_native_err(L,"#ferror:",&tolua_err);
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
size_t len = lua_objlen(L, lo);
|
||||
std::string value = "";
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
lua_pushnumber(L, i + 1);
|
||||
lua_gettable(L,lo);
|
||||
if(lua_isstring(L, -1))
|
||||
{
|
||||
ok = luaval_to_std_string(L, -1, &value);
|
||||
if(ok)
|
||||
ret->push_back(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCASSERT(false, "string type is needed");
|
||||
}
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool luaval_to_std_vector_int(lua_State* L, int lo, std::vector<int>* ret)
|
||||
{
|
||||
// TO BE DONE IN CPP FILE
|
||||
return false;
|
||||
if (nullptr == L || nullptr == ret || lua_gettop(L) < lo)
|
||||
return false;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
bool ok = true;
|
||||
if (!tolua_istable(L, lo, 0, &tolua_err))
|
||||
{
|
||||
#if COCOS2D_DEBUG >=1
|
||||
luaval_to_native_err(L,"#ferror:",&tolua_err);
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
size_t len = lua_objlen(L, lo);
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
lua_pushnumber(L, i + 1);
|
||||
lua_gettable(L,lo);
|
||||
if(lua_isnumber(L, -1))
|
||||
{
|
||||
ret->push_back((int)tolua_tonumber(L, -1, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
CCASSERT(false, "int type is needed");
|
||||
}
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
void point_to_luaval(lua_State* L,const Point& pt)
|
||||
|
|
|
@ -120,8 +120,47 @@ bool luaval_to_std_vector_int(lua_State* L, int lo, std::vector<int>* ret);
|
|||
template <class T>
|
||||
bool luaval_to_ccmap_string_key(lua_State* L, int lo, cocos2d::Map<std::string, T>* ret)
|
||||
{
|
||||
// TO BE DONE:
|
||||
return false;
|
||||
if(nullptr == L || nullptr == ret || lua_gettop(L) < lo)
|
||||
return false;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
bool ok = true;
|
||||
if (!tolua_istable(L, lo, 0, &tolua_err))
|
||||
{
|
||||
#if COCOS2D_DEBUG >=1
|
||||
luaval_to_native_err(L,"#ferror:",&tolua_err);
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
std::string stringKey = "";
|
||||
lua_pushnil(L); /* first key L: lotable ..... nil */
|
||||
while ( 0 != lua_next(L, lo ) ) /* L: lotable ..... key value */
|
||||
{
|
||||
if (!lua_isstring(L, -2))
|
||||
{
|
||||
lua_pop(L, 1); /* removes 'value'; keep 'key' for next iteration*/
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lua_isnil(L, -1) || !lua_isuserdata(L, -1))
|
||||
{
|
||||
lua_pop(L, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
luaval_to_std_string(L, -2, &stringKey);
|
||||
T obj = static_cast<T>(tolua_tousertype(L, -1, NULL) );
|
||||
if (nullptr != obj)
|
||||
ret->insert(stringKey, obj);
|
||||
|
||||
lua_pop(L, 1); /* L: lotable ..... key */
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
|
@ -179,7 +218,29 @@ void ccvector_to_luaval(lua_State* L,const cocos2d::Vector<T>& inValue)
|
|||
template <class T>
|
||||
void ccmap_string_key_to_luaval(lua_State* L, const cocos2d::Map<std::string, T>& v)
|
||||
{
|
||||
// TO BE DONE:
|
||||
lua_newtable(L);
|
||||
|
||||
if(nullptr == L)
|
||||
return;
|
||||
|
||||
for (auto iter = v.begin(); iter != v.end(); ++iter)
|
||||
{
|
||||
std::string key = iter->first;
|
||||
T obj = iter->second;
|
||||
if (nullptr != dynamic_cast<cocos2d::Object *>(obj))
|
||||
{
|
||||
std::string name = typeid(*obj).name();
|
||||
auto typeIter = g_luaType.find(name);
|
||||
if (g_luaType.end() != typeIter)
|
||||
{
|
||||
lua_pushstring(L, name.c_str());
|
||||
int ID = (obj) ? (int)obj->_ID : -1;
|
||||
int* luaID = (obj) ? &obj->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)obj,typeIter->second.c_str());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ccvalue_to_luaval(lua_State* L,const cocos2d::Value& inValue);
|
||||
|
|
|
@ -53,7 +53,8 @@ TOLUA_API int toluafix_pushusertype_ccobject(lua_State* L,
|
|||
//printf("[LUA] push CCObject OK - refid: %d, ptr: %x, type: %s\n", *p_refid, (int)ptr, type);
|
||||
}
|
||||
|
||||
tolua_pushusertype(L, ptr, type);
|
||||
tolua_pushusertype_and_addtoroot(L, ptr, type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -118,6 +119,10 @@ TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid)
|
|||
lua_pushstring(L, "tolua_ubox"); /* stack: mt key */
|
||||
lua_rawget(L, LUA_REGISTRYINDEX); /* stack: mt ubox */
|
||||
};
|
||||
|
||||
|
||||
// cleanup root
|
||||
tolua_remove_value_from_root(L, ptr);
|
||||
|
||||
lua_pushlightuserdata(L, ptr); /* stack: mt ubox ptr */
|
||||
lua_rawget(L,-2); /* stack: mt ubox ud */
|
||||
|
|
|
@ -485,16 +485,6 @@ void ScrollView::addChild(Node * child, int zOrder, int tag)
|
|||
}
|
||||
}
|
||||
|
||||
void ScrollView::addChild(Node * child, int zOrder)
|
||||
{
|
||||
this->addChild(child, zOrder, child->getTag());
|
||||
}
|
||||
|
||||
void ScrollView::addChild(Node * child)
|
||||
{
|
||||
this->addChild(child, child->getZOrder(), child->getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
* clip this view so that outside of the visible bounds can be hidden.
|
||||
*/
|
||||
|
|
|
@ -224,9 +224,9 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual void visit() override;
|
||||
|
||||
using Node::addChild;
|
||||
virtual void addChild(Node * child, int zOrder, int tag) override;
|
||||
virtual void addChild(Node * child, int zOrder) override;
|
||||
virtual void addChild(Node * child) override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
|
|
@ -41,6 +41,8 @@ extern "C" {
|
|||
#define TOLUA_PROTECTED_DESTRUCTOR
|
||||
#define TOLUA_PROPERTY_TYPE(p)
|
||||
|
||||
#define TOLUA_VALUE_ROOT "tolua_value_root"
|
||||
|
||||
typedef int lua_Object;
|
||||
|
||||
#include "lua.h"
|
||||
|
@ -117,6 +119,10 @@ TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const cha
|
|||
TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v);
|
||||
TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type);
|
||||
TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type);
|
||||
|
||||
TOLUA_API void tolua_pushusertype_and_addtoroot (lua_State* L, void* value, const char* type);
|
||||
TOLUA_API void tolua_add_value_to_root (lua_State* L,void* value);
|
||||
TOLUA_API void tolua_remove_value_from_root (lua_State* L, void* value);
|
||||
|
||||
TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def);
|
||||
TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def);
|
||||
|
|
|
@ -304,6 +304,11 @@ TOLUA_API void tolua_open (lua_State* L)
|
|||
lua_pushstring(L,"tolua_opened");
|
||||
lua_pushboolean(L,1);
|
||||
lua_rawset(L,LUA_REGISTRYINDEX);
|
||||
|
||||
// create value root table
|
||||
lua_pushstring(L, TOLUA_VALUE_ROOT);
|
||||
lua_newtable(L);
|
||||
lua_rawset(L, LUA_REGISTRYINDEX);
|
||||
|
||||
#ifndef LUA_VERSION_NUM /* only prior to lua 5.1 */
|
||||
/* create peer object table */
|
||||
|
|
|
@ -17,6 +17,82 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
void tolua_pushusertype_internal (lua_State* L, void* value, const char* type, int addToRoot)
|
||||
{
|
||||
if (value == NULL)
|
||||
lua_pushnil(L);
|
||||
else
|
||||
{
|
||||
luaL_getmetatable(L, type); /* stack: mt */
|
||||
if (lua_isnil(L, -1)) { /* NOT FOUND metatable */
|
||||
lua_pop(L, 1);
|
||||
return;
|
||||
}
|
||||
lua_pushstring(L,"tolua_ubox");
|
||||
lua_rawget(L,-2); /* stack: mt ubox */
|
||||
if (lua_isnil(L, -1)) {
|
||||
lua_pop(L, 1);
|
||||
lua_pushstring(L, "tolua_ubox");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
};
|
||||
|
||||
lua_pushlightuserdata(L,value); /* stack: mt ubox key<value> */
|
||||
lua_rawget(L,-2); /* stack: mt ubox ubox[value] */
|
||||
|
||||
if (lua_isnil(L,-1))
|
||||
{
|
||||
lua_pop(L,1); /* stack: mt ubox */
|
||||
lua_pushlightuserdata(L,value);
|
||||
*(void**)lua_newuserdata(L,sizeof(void *)) = value; /* stack: mt ubox value newud */
|
||||
lua_pushvalue(L,-1); /* stack: mt ubox value newud newud */
|
||||
lua_insert(L,-4); /* stack: mt newud ubox value newud */
|
||||
lua_rawset(L,-3); /* ubox[value] = newud, stack: mt newud ubox */
|
||||
lua_pop(L,1); /* stack: mt newud */
|
||||
/*luaL_getmetatable(L,type);*/
|
||||
lua_pushvalue(L, -2); /* stack: mt newud mt */
|
||||
lua_setmetatable(L,-2); /* update mt, stack: mt newud */
|
||||
|
||||
#ifdef LUA_VERSION_NUM
|
||||
lua_pushvalue(L, TOLUA_NOPEER); /* stack: mt newud peer */
|
||||
lua_setfenv(L, -2); /* stack: mt newud */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* check the need of updating the metatable to a more specialized class */
|
||||
lua_insert(L,-2); /* stack: mt ubox[u] ubox */
|
||||
lua_pop(L,1); /* stack: mt ubox[u] */
|
||||
lua_pushstring(L,"tolua_super");
|
||||
lua_rawget(L,LUA_REGISTRYINDEX); /* stack: mt ubox[u] super */
|
||||
lua_getmetatable(L,-2); /* stack: mt ubox[u] super mt */
|
||||
lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] */
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
lua_pushstring(L,type); /* stack: mt ubox[u] super super[mt] type */
|
||||
lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] flag */
|
||||
if (lua_toboolean(L,-1) == 1) /* if true */
|
||||
{
|
||||
lua_pop(L,3); /* mt ubox[u]*/
|
||||
lua_remove(L, -2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* type represents a more specilized type */
|
||||
/*luaL_getmetatable(L,type); // stack: mt ubox[u] super super[mt] flag mt */
|
||||
lua_pushvalue(L, -5); /* stack: mt ubox[u] super super[mt] flag mt */
|
||||
lua_setmetatable(L,-5); /* stack: mt ubox[u] super super[mt] flag */
|
||||
lua_pop(L,3); /* stack: mt ubox[u] */
|
||||
}
|
||||
lua_remove(L, -2); /* stack: ubox[u]*/
|
||||
|
||||
if (0 != addToRoot)
|
||||
{
|
||||
lua_pushvalue(L, -1);
|
||||
tolua_add_value_to_root(L, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TOLUA_API void tolua_pushvalue (lua_State* L, int lo)
|
||||
{
|
||||
lua_pushvalue(L,lo);
|
||||
|
@ -50,72 +126,12 @@ TOLUA_API void tolua_pushuserdata (lua_State* L, void* value)
|
|||
|
||||
TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type)
|
||||
{
|
||||
if (value == NULL)
|
||||
lua_pushnil(L);
|
||||
else
|
||||
{
|
||||
luaL_getmetatable(L, type); /* stack: mt */
|
||||
if (lua_isnil(L, -1)) { /* NOT FOUND metatable */
|
||||
lua_pop(L, 1);
|
||||
return;
|
||||
}
|
||||
lua_pushstring(L,"tolua_ubox");
|
||||
lua_rawget(L,-2); /* stack: mt ubox */
|
||||
if (lua_isnil(L, -1)) {
|
||||
lua_pop(L, 1);
|
||||
lua_pushstring(L, "tolua_ubox");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
};
|
||||
|
||||
lua_pushlightuserdata(L,value); /* stack: mt ubox key<value> */
|
||||
lua_rawget(L,-2); /* stack: mt ubox ubox[value] */
|
||||
|
||||
if (lua_isnil(L,-1))
|
||||
{
|
||||
lua_pop(L,1); /* stack: mt ubox */
|
||||
lua_pushlightuserdata(L,value);
|
||||
*(void**)lua_newuserdata(L,sizeof(void *)) = value; /* stack: mt ubox value newud */
|
||||
lua_pushvalue(L,-1); /* stack: mt ubox value newud newud */
|
||||
lua_insert(L,-4); /* stack: mt newud ubox value newud */
|
||||
lua_rawset(L,-3); /* ubox[value] = newud, stack: mt newud ubox */
|
||||
lua_pop(L,1); /* stack: mt newud */
|
||||
/*luaL_getmetatable(L,type);*/
|
||||
lua_pushvalue(L, -2); /* stack: mt newud mt */
|
||||
lua_setmetatable(L,-2); /* update mt, stack: mt newud */
|
||||
tolua_pushusertype_internal(L, value, type, 0);
|
||||
}
|
||||
|
||||
#ifdef LUA_VERSION_NUM
|
||||
lua_pushvalue(L, TOLUA_NOPEER);
|
||||
lua_setfenv(L, -2);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* check the need of updating the metatable to a more specialized class */
|
||||
lua_insert(L,-2); /* stack: mt ubox[u] ubox */
|
||||
lua_pop(L,1); /* stack: mt ubox[u] */
|
||||
lua_pushstring(L,"tolua_super");
|
||||
lua_rawget(L,LUA_REGISTRYINDEX); /* stack: mt ubox[u] super */
|
||||
lua_getmetatable(L,-2); /* stack: mt ubox[u] super mt */
|
||||
lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] */
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
lua_pushstring(L,type); /* stack: mt ubox[u] super super[mt] type */
|
||||
lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] flag */
|
||||
if (lua_toboolean(L,-1) == 1) /* if true */
|
||||
{
|
||||
lua_pop(L,3); /* mt ubox[u]*/
|
||||
lua_remove(L, -2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* type represents a more specilized type */
|
||||
/*luaL_getmetatable(L,type); // stack: mt ubox[u] super super[mt] flag mt */
|
||||
lua_pushvalue(L, -5); /* stack: mt ubox[u] super super[mt] flag mt */
|
||||
lua_setmetatable(L,-5); /* stack: mt ubox[u] super super[mt] flag */
|
||||
lua_pop(L,3); /* stack: mt ubox[u] */
|
||||
}
|
||||
lua_remove(L, -2); /* stack: ubox[u]*/
|
||||
}
|
||||
TOLUA_API void tolua_pushusertype_and_addtoroot (lua_State* L, void* value, const char* type)
|
||||
{
|
||||
tolua_pushusertype_internal(L, value, type, 1);
|
||||
}
|
||||
|
||||
TOLUA_API void tolua_pushusertype_and_takeownership (lua_State* L, void* value, const char* type)
|
||||
|
@ -124,6 +140,30 @@ TOLUA_API void tolua_pushusertype_and_takeownership (lua_State* L, void* value,
|
|||
tolua_register_gc(L,lua_gettop(L));
|
||||
}
|
||||
|
||||
TOLUA_API void tolua_add_value_to_root(lua_State* L, void* ptr)
|
||||
{
|
||||
|
||||
lua_pushstring(L, TOLUA_VALUE_ROOT);
|
||||
lua_rawget(L, LUA_REGISTRYINDEX); /* stack: value root */
|
||||
lua_insert(L, -2); /* stack: root value */
|
||||
lua_pushlightuserdata(L, ptr); /* stack: root value ptr */
|
||||
lua_insert(L, -2); /* stack: root ptr value */
|
||||
lua_rawset(L, -3); /* root[ptr] = value, stack: root */
|
||||
lua_pop(L, 1); /* stack: - */
|
||||
}
|
||||
|
||||
|
||||
TOLUA_API void tolua_remove_value_from_root (lua_State* L, void* ptr)
|
||||
{
|
||||
lua_pushstring(L, TOLUA_VALUE_ROOT);
|
||||
lua_rawget(L, LUA_REGISTRYINDEX); /* stack: root */
|
||||
lua_pushlightuserdata(L, ptr); /* stack: root ptr */
|
||||
|
||||
lua_pushnil(L); /* stack: root ptr nil */
|
||||
lua_rawset(L, -3); /* root[ptr] = nil, stack: root */
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v)
|
||||
{
|
||||
lua_pushnumber(L,index);
|
||||
|
|
|
@ -179,21 +179,21 @@ void NewSpriteTest::createNewSpriteTest()
|
|||
{
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
|
||||
NewSprite* parent = NewSprite::create("Images/grossini.png");
|
||||
Sprite* parent = Sprite::create("Images/grossini.png");
|
||||
parent->setPosition(winSize.width*2/3, winSize.height/2);
|
||||
NewSprite* child1 = NewSprite::create("Images/grossinis_sister1.png");
|
||||
Sprite* child1 = Sprite::create("Images/grossinis_sister1.png");
|
||||
child1->setPosition(0.0f, -20.0f);
|
||||
NewSprite* child2 = NewSprite::create("Images/grossinis_sister2.png");
|
||||
Sprite* child2 = Sprite::create("Images/grossinis_sister2.png");
|
||||
child2->setPosition(20.0f, -20.0f);
|
||||
NewSprite* child3 = NewSprite::create("Images/grossinis_sister1.png");
|
||||
Sprite* child3 = Sprite::create("Images/grossinis_sister1.png");
|
||||
child3->setPosition(40.0f, -20.0f);
|
||||
NewSprite* child4 = NewSprite::create("Images/grossinis_sister2.png");
|
||||
Sprite* child4 = Sprite::create("Images/grossinis_sister2.png");
|
||||
child4->setPosition(60.0f, -20.0f);
|
||||
NewSprite* child5 = NewSprite::create("Images/grossinis_sister2.png");
|
||||
Sprite* child5 = Sprite::create("Images/grossinis_sister2.png");
|
||||
child5->setPosition(80.0f, -20.0f);
|
||||
NewSprite* child6 = NewSprite::create("Images/grossinis_sister2.png");
|
||||
Sprite* child6 = Sprite::create("Images/grossinis_sister2.png");
|
||||
child6->setPosition(100.0f, -20.0f);
|
||||
NewSprite* child7 = NewSprite::create("Images/grossinis_sister2.png");
|
||||
Sprite* child7 = Sprite::create("Images/grossinis_sister2.png");
|
||||
child7->setPosition(120.0f, -20.0f);
|
||||
|
||||
parent->addChild(child1);
|
||||
|
@ -266,7 +266,7 @@ void NewSpriteBatchTest::addNewSpriteWithCoords(Point p)
|
|||
int y = (idx/5) * 121;
|
||||
|
||||
|
||||
auto sprite = NewSprite::createWithTexture(BatchNode->getTexture(), Rect(x,y,85,121));
|
||||
auto sprite = Sprite::createWithTexture(BatchNode->getTexture(), Rect(x,y,85,121));
|
||||
BatchNode->addChild(sprite);
|
||||
|
||||
sprite->setPosition( Point( p.x, p.y) );
|
||||
|
@ -318,11 +318,11 @@ NewClippingNodeTest::NewClippingNodeTest()
|
|||
|
||||
//Test with alpha Test
|
||||
clipper->setAlphaThreshold(0.05f);
|
||||
auto stencil = NewSprite::create("Images/grossini.png");
|
||||
auto stencil = Sprite::create("Images/grossini.png");
|
||||
stencil->setPosition(s.width/2, s.height/2);
|
||||
clipper->setStencil(stencil);
|
||||
|
||||
auto content = NewSprite::create("Images/background2.png");
|
||||
auto content = Sprite::create("Images/background2.png");
|
||||
content->setTag( kTagContentNode );
|
||||
content->setAnchorPoint( Point(0.5, 0.5) );
|
||||
content->setPosition( Point(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) );
|
||||
|
@ -448,7 +448,7 @@ NewCullingTest::NewCullingTest()
|
|||
parent->addChild(parent2);
|
||||
parent2->setPosition(-50,0);
|
||||
parent2->runAction(RepeatForever::create((JumpBy::create(10, Point(0,0), 400, 1))));
|
||||
NewSprite* sprite = NewSprite::create(images[index % images.size()].c_str());
|
||||
Sprite* sprite = Sprite::create(images[index % images.size()].c_str());
|
||||
sprite->setPosition(Point(0,0));
|
||||
//sprite->runAction(RepeatForever::create(RotateBy::create(3, 360)));
|
||||
sprite->runAction(RepeatForever::create(Sequence::createWithTwoActions(ScaleBy::create(2, 2), ScaleBy::create(2,0.5))));
|
||||
|
@ -461,7 +461,7 @@ NewCullingTest::NewCullingTest()
|
|||
parent->addChild(parent2);
|
||||
parent2->setPosition(50,0);
|
||||
parent2->runAction(RepeatForever::create((JumpBy::create(7, Point(0,0), 400, 1))));
|
||||
NewSprite* sprite = NewSprite::create(images[index % images.size()].c_str());
|
||||
Sprite* sprite = Sprite::create(images[index % images.size()].c_str());
|
||||
sprite->setPosition(Point(0,0));
|
||||
//sprite->runAction(RepeatForever::create(RotateBy::create(3, 360)));
|
||||
sprite->runAction(RepeatForever::create(Sequence::createWithTwoActions(ScaleBy::create(2, 2), ScaleBy::create(2,0.5))));
|
||||
|
|
|
@ -396,7 +396,6 @@ void PhysicsDemo::onTouchMoved(Touch* touch, Event* event)
|
|||
|
||||
if (it != _mouses.end())
|
||||
{
|
||||
it->second->getPhysicsBody()->setVelocity((touch->getLocation() - it->second->getPosition()) * 60.0f);
|
||||
it->second->setPosition(touch->getLocation());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "CCConfiguration.h"
|
||||
#include "RenderTextureTest.h"
|
||||
#include "../testBasic.h"
|
||||
#include "renderer/CCNewRenderTexture.h"
|
||||
|
||||
// Test #1 by Jason Booth (slipster216)
|
||||
// Test #3 by David Deaco (ddeaco)
|
||||
|
@ -93,7 +92,7 @@ RenderTextureSave::RenderTextureSave()
|
|||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
// create a render texture, this is what we are going to draw into
|
||||
_target = NewRenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888);
|
||||
_target = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888);
|
||||
_target->retain();
|
||||
_target->setPosition(Point(s.width / 2, s.height / 2));
|
||||
|
||||
|
@ -241,7 +240,7 @@ RenderTextureIssue937::RenderTextureIssue937()
|
|||
|
||||
|
||||
/* A2 & B2 setup */
|
||||
auto rend = NewRenderTexture::create(32, 64, Texture2D::PixelFormat::RGBA8888);
|
||||
auto rend = RenderTexture::create(32, 64, Texture2D::PixelFormat::RGBA8888);
|
||||
|
||||
if (NULL == rend)
|
||||
{
|
||||
|
@ -410,7 +409,7 @@ void RenderTextureZbuffer::onTouchesEnded(const std::vector<Touch*>& touches, Ev
|
|||
|
||||
void RenderTextureZbuffer::renderScreenShot()
|
||||
{
|
||||
auto texture = NewRenderTexture::create(512, 512);
|
||||
auto texture = RenderTexture::create(512, 512);
|
||||
if (NULL == texture)
|
||||
{
|
||||
return;
|
||||
|
@ -444,7 +443,7 @@ RenderTextureTestDepthStencil::RenderTextureTestDepthStencil()
|
|||
auto sprite = Sprite::create("Images/fire.png");
|
||||
sprite->setPosition(Point(s.width * 0.25f, 0));
|
||||
sprite->setScale(10);
|
||||
auto rend = NewRenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444, GL_DEPTH24_STENCIL8);
|
||||
auto rend = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444, GL_DEPTH24_STENCIL8);
|
||||
|
||||
glStencilMask(0xFF);
|
||||
rend->beginWithClear(0, 0, 0, 0, 0, 0);
|
||||
|
@ -506,7 +505,7 @@ RenderTextureTargetNode::RenderTextureTargetNode()
|
|||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
/* Create the render texture */
|
||||
auto renderTexture = NewRenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444);
|
||||
auto renderTexture = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444);
|
||||
this->renderTexture = renderTexture;
|
||||
|
||||
renderTexture->setPosition(Point(s.width/2, s.height/2));
|
||||
|
@ -591,7 +590,7 @@ void SpriteRenderTextureBug::SimpleSprite::draw()
|
|||
if (_rt == nullptr)
|
||||
{
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
_rt = NewRenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888);
|
||||
_rt = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888);
|
||||
_rt->retain();
|
||||
}
|
||||
_rt->beginWithClear(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
#include "renderer/CCNewRenderTexture.h"
|
||||
|
||||
class RenderTextureTest : public BaseTest
|
||||
{
|
||||
|
@ -31,7 +30,7 @@ public:
|
|||
void saveImage(Object *pSender);
|
||||
|
||||
private:
|
||||
NewRenderTexture *_target;
|
||||
RenderTexture *_target;
|
||||
Sprite *_brush;
|
||||
};
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 148868f7f4407a12444f07cb5e5378b1dbd7511c
|
||||
Subproject commit fda861cde4387948e95811966d9c4ceea04dc758
|
|
@ -1 +1 @@
|
|||
Subproject commit ad532012457e2eaff15d73d9ba28a638fa748d2d
|
||||
Subproject commit 1b34f5852fcf494499be7eb5ce2bada72a0b16a2
|
|
@ -37,7 +37,7 @@ classes_need_extend = Node Layer.* Sprite MenuItemFont Scene DrawNode
|
|||
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||
# functions from all classes.
|
||||
|
||||
skip = Node::[^setPosition$ setGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule],
|
||||
skip = Node::[^setPosition$ setGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule setContentSize setAnchorPoint],
|
||||
Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc],
|
||||
SpriteBatchNode::[getBlendFunc setBlendFunc getDescendants],
|
||||
MotionStreak::[getBlendFunc setBlendFunc draw update],
|
||||
|
|
|
@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/2d/cocos2d.h %(cocosdir)s/cocos/audio/include/Simpl
|
|||
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||
classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image Event.*
|
||||
classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image Event.* DisplayLinkDirector
|
||||
|
||||
# what should we skip? in the format ClassName::[function function]
|
||||
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||
|
@ -111,7 +111,8 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
|
|||
Label::[getLettersInfo],
|
||||
EGLViewProtocol::[setTouchDelegate],
|
||||
EGLView::[end swapBuffers],
|
||||
NewTextureAtlas::[*]
|
||||
NewTextureAtlas::[*],
|
||||
DisplayLinkDirector::[mainLoop setAnimationInterval startAnimation stopAnimation]
|
||||
|
||||
rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame],
|
||||
ProgressTimer::[setReverseProgress=setReverseDirection],
|
||||
|
@ -142,7 +143,7 @@ base_classes_to_skip = Clonable
|
|||
|
||||
# classes that create no constructor
|
||||
# Set is special and we will use a hand-written constructor
|
||||
abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application ClippingNode Label EGLViewProtocol EGLView EventAcceleration
|
||||
abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application ClippingNode Label EGLViewProtocol EGLView EventAcceleration DisplayLinkDirector
|
||||
|
||||
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
|
||||
script_control_cpp = no
|
||||
|
|
Loading…
Reference in New Issue