mirror of https://github.com/axmolengine/axmol.git
remove CCShaderNode
This commit is contained in:
parent
6fc0eaf5b1
commit
ac6d4e5cbb
|
@ -320,9 +320,14 @@ CCAffineTransform CCBone::nodeToArmatureTransform()
|
||||||
return m_tWorldTransform;
|
return m_tWorldTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCBone::addDisplay(CCDisplayData *_displayData, int _index)
|
void CCBone::addDisplay(CCDisplayData *displayData, int index)
|
||||||
{
|
{
|
||||||
m_pDisplayManager->addDisplay(_displayData, _index);
|
m_pDisplayManager->addDisplay(displayData, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCBone::addDisplay(CCNode *display, int index)
|
||||||
|
{
|
||||||
|
m_pDisplayManager->addDisplay(display, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCBone::changeDisplayByIndex(int _index, bool _force)
|
void CCBone::changeDisplayByIndex(int _index, bool _force)
|
||||||
|
|
|
@ -80,6 +80,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void addDisplay(CCDisplayData *displayData, int index);
|
void addDisplay(CCDisplayData *displayData, int index);
|
||||||
|
|
||||||
|
void addDisplay(CCNode *display, int index);
|
||||||
|
|
||||||
void changeDisplayByIndex(int index, bool force);
|
void changeDisplayByIndex(int index, bool force);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,7 +26,6 @@ THE SOFTWARE.
|
||||||
#include "../CCBone.h"
|
#include "../CCBone.h"
|
||||||
#include "../CCArmature.h"
|
#include "../CCArmature.h"
|
||||||
#include "../display/CCSkin.h"
|
#include "../display/CCSkin.h"
|
||||||
#include "../display/CCShaderNode.h"
|
|
||||||
#include "../utils/CCSpriteFrameCacheHelper.h"
|
#include "../utils/CCSpriteFrameCacheHelper.h"
|
||||||
#include "../utils/CCArmatureDataManager.h"
|
#include "../utils/CCArmatureDataManager.h"
|
||||||
#include "../utils/CCTransformHelp.h"
|
#include "../utils/CCTransformHelp.h"
|
||||||
|
@ -251,20 +250,4 @@ void CCDisplayFactory::updateParticleDisplay(CCBone *bone, CCDecorativeDisplay *
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CCDisplayFactory::addShaderDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay, CCDisplayData *displayData)
|
|
||||||
{
|
|
||||||
CCShaderDisplayData *sdp = CCShaderDisplayData::create();
|
|
||||||
sdp->copy((CCShaderDisplayData *)displayData);
|
|
||||||
decoDisplay->setDisplayData(sdp);
|
|
||||||
|
|
||||||
createShaderDisplay(bone, decoDisplay);
|
|
||||||
}
|
|
||||||
void CCDisplayFactory::createShaderDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay)
|
|
||||||
{
|
|
||||||
CCShaderDisplayData *displayData = (CCShaderDisplayData *)decoDisplay->getDisplayData();
|
|
||||||
CCShaderNode *sn = CCShaderNode::shaderNodeWithVertex(displayData->vert.c_str(), displayData->frag.c_str());
|
|
||||||
decoDisplay->setDisplay(sn);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_CC_EXT_END
|
NS_CC_EXT_END
|
||||||
|
|
|
@ -53,10 +53,6 @@ public:
|
||||||
static void addParticleDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay, CCDisplayData *displayData);
|
static void addParticleDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay, CCDisplayData *displayData);
|
||||||
static void createParticleDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay);
|
static void createParticleDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay);
|
||||||
static void updateParticleDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay, float dt, bool dirty);
|
static void updateParticleDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay, float dt, bool dirty);
|
||||||
|
|
||||||
static void addShaderDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay, CCDisplayData *displayData);
|
|
||||||
static void createShaderDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,11 @@ void CCDisplayManager::addDisplay(CCDisplayData *displayData, int index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCDisplayManager::addDisplay(CCNode *display, int index)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CCDisplayManager::removeDisplay(int index)
|
void CCDisplayManager::removeDisplay(int index)
|
||||||
{
|
{
|
||||||
m_pDecoDisplayList->removeObjectAtIndex(index);
|
m_pDecoDisplayList->removeObjectAtIndex(index);
|
||||||
|
|
|
@ -65,6 +65,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void addDisplay(CCDisplayData *displayData, int index);
|
void addDisplay(CCDisplayData *displayData, int index);
|
||||||
|
|
||||||
|
void addDisplay(CCNode *display, int index);
|
||||||
|
|
||||||
void removeDisplay(int index);
|
void removeDisplay(int index);
|
||||||
|
|
||||||
CCArray *getDecorativeDisplayList();
|
CCArray *getDecorativeDisplayList();
|
||||||
|
|
|
@ -1,136 +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 "CCShaderNode.h"
|
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
SIZE_X = 128,
|
|
||||||
SIZE_Y = 128,
|
|
||||||
};
|
|
||||||
|
|
||||||
CCShaderNode::CCShaderNode()
|
|
||||||
: m_center(vertex2(0.0f, 0.0f))
|
|
||||||
, m_resolution(vertex2(0.0f, 0.0f))
|
|
||||||
, m_time(0.0f)
|
|
||||||
, m_uniformCenter(0)
|
|
||||||
, m_uniformResolution(0)
|
|
||||||
, m_uniformTime(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
CCShaderNode *CCShaderNode::shaderNodeWithVertex(const char *vert, const char *frag)
|
|
||||||
{
|
|
||||||
CCShaderNode *node = new CCShaderNode();
|
|
||||||
node->initWithVertex(vert, frag);
|
|
||||||
node->autorelease();
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CCShaderNode::initWithVertex(const char *vert, const char *frag)
|
|
||||||
{
|
|
||||||
|
|
||||||
loadShaderVertex(vert, frag);
|
|
||||||
|
|
||||||
m_time = 0;
|
|
||||||
m_resolution = vertex2(SIZE_X, SIZE_Y);
|
|
||||||
|
|
||||||
scheduleUpdate();
|
|
||||||
|
|
||||||
setContentSize(CCSizeMake(SIZE_X, SIZE_Y));
|
|
||||||
setAnchorPoint(ccp(0.5f, 0.5f));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCShaderNode::loadShaderVertex(const char *vert, const char *frag)
|
|
||||||
{
|
|
||||||
CCGLProgram *shader = new CCGLProgram();
|
|
||||||
shader->initWithVertexShaderFilename(vert, frag);
|
|
||||||
|
|
||||||
shader->addAttribute("aVertex", kCCVertexAttrib_Position);
|
|
||||||
shader->link();
|
|
||||||
|
|
||||||
shader->updateUniforms();
|
|
||||||
|
|
||||||
m_uniformCenter = glGetUniformLocation(shader->getProgram(), "center");
|
|
||||||
m_uniformResolution = glGetUniformLocation(shader->getProgram(), "resolution");
|
|
||||||
m_uniformTime = glGetUniformLocation(shader->getProgram(), "time");
|
|
||||||
|
|
||||||
this->setShaderProgram(shader);
|
|
||||||
|
|
||||||
shader->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCShaderNode::update(float dt)
|
|
||||||
{
|
|
||||||
m_time += dt;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCShaderNode::translateFormOtherNode(CCAffineTransform &transform)
|
|
||||||
{
|
|
||||||
CCNode::setAdditionalTransform(transform);
|
|
||||||
|
|
||||||
m_center = vertex2(m_sAdditionalTransform.tx * CC_CONTENT_SCALE_FACTOR(), m_sAdditionalTransform.ty * CC_CONTENT_SCALE_FACTOR());
|
|
||||||
m_resolution = vertex2( SIZE_X * m_sAdditionalTransform.a, SIZE_Y * m_sAdditionalTransform.d);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCShaderNode::setPosition(const CCPoint &newPosition)
|
|
||||||
{
|
|
||||||
CCNode::setPosition(newPosition);
|
|
||||||
CCPoint position = getPosition();
|
|
||||||
m_center = vertex2(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCShaderNode::draw()
|
|
||||||
{
|
|
||||||
CC_NODE_DRAW_SETUP();
|
|
||||||
|
|
||||||
float w = SIZE_X, h = SIZE_Y;
|
|
||||||
GLfloat vertices[12] = {0, 0, w, 0, w, h, 0, 0, 0, h, w, h};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Uniforms
|
|
||||||
//
|
|
||||||
getShaderProgram()->setUniformLocationWith2f(m_uniformCenter, m_center.x, m_center.y);
|
|
||||||
getShaderProgram()->setUniformLocationWith2f(m_uniformResolution, m_resolution.x, m_resolution.y);
|
|
||||||
|
|
||||||
|
|
||||||
// time changes all the time, so it is Ok to call OpenGL directly, and not the "cached" version
|
|
||||||
glUniform1f(m_uniformTime, m_time);
|
|
||||||
|
|
||||||
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
|
|
||||||
|
|
||||||
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
|
||||||
|
|
||||||
CC_INCREMENT_GL_DRAWS(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NS_CC_EXT_END
|
|
|
@ -1,57 +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 __CCSHADERNODE_H__
|
|
||||||
#define __CCSHADERNODE_H__
|
|
||||||
|
|
||||||
#include "../utils/CCArmatureDefine.h"
|
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
|
||||||
|
|
||||||
class CCShaderNode : public CCNode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CCShaderNode();
|
|
||||||
|
|
||||||
bool initWithVertex(const char *vert, const char *frag);
|
|
||||||
void loadShaderVertex(const char *vert, const char *frag);
|
|
||||||
|
|
||||||
virtual void update(float dt);
|
|
||||||
virtual void setPosition(const CCPoint &newPosition);
|
|
||||||
virtual void translateFormOtherNode(CCAffineTransform &transform);
|
|
||||||
virtual void draw();
|
|
||||||
|
|
||||||
static CCShaderNode *shaderNodeWithVertex(const char *vert, const char *frag);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
ccVertex2F m_center;
|
|
||||||
ccVertex2F m_resolution;
|
|
||||||
float m_time;
|
|
||||||
GLuint m_uniformCenter, m_uniformResolution, m_uniformTime;
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_CC_EXT_END
|
|
||||||
|
|
||||||
#endif /*__CCSHADERNODE_H__*/
|
|
|
@ -102,7 +102,6 @@
|
||||||
<ClCompile Include="..\CCArmature\display\CCDecorativeDisplay.cpp" />
|
<ClCompile Include="..\CCArmature\display\CCDecorativeDisplay.cpp" />
|
||||||
<ClCompile Include="..\CCArmature\display\CCDisplayFactory.cpp" />
|
<ClCompile Include="..\CCArmature\display\CCDisplayFactory.cpp" />
|
||||||
<ClCompile Include="..\CCArmature\display\CCDisplayManager.cpp" />
|
<ClCompile Include="..\CCArmature\display\CCDisplayManager.cpp" />
|
||||||
<ClCompile Include="..\CCArmature\display\CCShaderNode.cpp" />
|
|
||||||
<ClCompile Include="..\CCArmature\display\CCSkin.cpp" />
|
<ClCompile Include="..\CCArmature\display\CCSkin.cpp" />
|
||||||
<ClCompile Include="..\CCArmature\external_tool\CCTexture2DMutable.cpp" />
|
<ClCompile Include="..\CCArmature\external_tool\CCTexture2DMutable.cpp" />
|
||||||
<ClCompile Include="..\CCArmature\external_tool\GLES-Render.cpp" />
|
<ClCompile Include="..\CCArmature\external_tool\GLES-Render.cpp" />
|
||||||
|
@ -204,7 +203,6 @@
|
||||||
<ClInclude Include="..\CCArmature\display\CCDecorativeDisplay.h" />
|
<ClInclude Include="..\CCArmature\display\CCDecorativeDisplay.h" />
|
||||||
<ClInclude Include="..\CCArmature\display\CCDisplayFactory.h" />
|
<ClInclude Include="..\CCArmature\display\CCDisplayFactory.h" />
|
||||||
<ClInclude Include="..\CCArmature\display\CCDisplayManager.h" />
|
<ClInclude Include="..\CCArmature\display\CCDisplayManager.h" />
|
||||||
<ClInclude Include="..\CCArmature\display\CCShaderNode.h" />
|
|
||||||
<ClInclude Include="..\CCArmature\display\CCSkin.h" />
|
<ClInclude Include="..\CCArmature\display\CCSkin.h" />
|
||||||
<ClInclude Include="..\CCArmature\external_tool\CCTexture2DMutable.h" />
|
<ClInclude Include="..\CCArmature\external_tool\CCTexture2DMutable.h" />
|
||||||
<ClInclude Include="..\CCArmature\external_tool\GLES-Render.h" />
|
<ClInclude Include="..\CCArmature\external_tool\GLES-Render.h" />
|
||||||
|
|
|
@ -228,9 +228,6 @@
|
||||||
<ClCompile Include="..\CCArmature\display\CCDisplayManager.cpp">
|
<ClCompile Include="..\CCArmature\display\CCDisplayManager.cpp">
|
||||||
<Filter>CCArmature\display</Filter>
|
<Filter>CCArmature\display</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\CCArmature\display\CCShaderNode.cpp">
|
|
||||||
<Filter>CCArmature\display</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\CCArmature\display\CCSkin.cpp">
|
<ClCompile Include="..\CCArmature\display\CCSkin.cpp">
|
||||||
<Filter>CCArmature\display</Filter>
|
<Filter>CCArmature\display</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -556,9 +553,6 @@
|
||||||
<ClInclude Include="..\CCArmature\display\CCDisplayManager.h">
|
<ClInclude Include="..\CCArmature\display\CCDisplayManager.h">
|
||||||
<Filter>CCArmature\display</Filter>
|
<Filter>CCArmature\display</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\CCArmature\display\CCShaderNode.h">
|
|
||||||
<Filter>CCArmature\display</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\CCArmature\display\CCSkin.h">
|
<ClInclude Include="..\CCArmature\display\CCSkin.h">
|
||||||
<Filter>CCArmature\display</Filter>
|
<Filter>CCArmature\display</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
Loading…
Reference in New Issue