axmol/cocos/2d/renderer/CCNewDrawNode.cpp

67 lines
1.0 KiB
C++
Raw Normal View History

2013-11-16 03:29:11 +08:00
//
// Created by NiTe Luo on 11/14/13.
//
#include "CCNewDrawNode.h"
2013-11-19 06:58:41 +08:00
#include "QuadCommand.h"
2013-11-20 03:06:26 +08:00
#include "Renderer.h"
2013-11-20 05:57:39 +08:00
#include "CustomCommand.h"
2013-11-16 03:29:11 +08:00
NS_CC_BEGIN
NewDrawNode *NewDrawNode::create()
{
NewDrawNode* pRet = new NewDrawNode();
if (pRet && pRet->init())
{
pRet->autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
NewDrawNode::NewDrawNode()
{
}
NewDrawNode::~NewDrawNode()
{
}
bool NewDrawNode::init()
{
2013-11-16 09:32:29 +08:00
return DrawNode::init();
2013-11-16 03:29:11 +08:00
}
2013-11-20 05:57:39 +08:00
void NewDrawNode::draw()
2013-11-20 03:06:26 +08:00
{
2013-11-26 08:33:05 +08:00
kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix);
2013-11-20 03:06:26 +08:00
2013-11-20 05:57:39 +08:00
CustomCommand* cmd = new CustomCommand(0, _vertexZ);
cmd->func = CC_CALLBACK_0(NewDrawNode::onDraw, this);
Renderer::getInstance()->addCommand(cmd);
2013-11-20 03:06:26 +08:00
}
2013-11-20 05:57:39 +08:00
void NewDrawNode::onDraw()
2013-11-16 03:29:11 +08:00
{
2013-11-26 08:33:05 +08:00
kmMat4 prevMatrix;
kmGLGetMatrix(KM_GL_MODELVIEW, &prevMatrix);
kmGLLoadMatrix(&_transformMatrix);
2013-11-20 05:57:39 +08:00
CC_NODE_DRAW_SETUP();
GL::blendFunc(_blendFunc.src, _blendFunc.dst);
render();
2013-11-16 03:29:11 +08:00
2013-11-26 08:33:05 +08:00
kmGLLoadMatrix(&prevMatrix);
2013-11-16 03:29:11 +08:00
}
NS_CC_END