Cocos2dx 绘制流程总结
1. 创建CCDirector.
代码:CCDirector *pDirector = CCDirector::sharedDirector();
2. 设置openglView.
代码:
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
重要内容:setOpenglGLView->setGLDefaultValues,其中设置了视口大小,颜色混合,深度检测,清屏颜色,摄像机透视类型等。
3.主循环mainloop->drawScene
visit方法访问了所有子节点的draw方法。
4.单个节点绘制
以CCSprite为例:
void CCSprite::draw(void)
{
CC_PROFILER_START_CATEGORY(kCCProfilerCategorySprite,"CCSprite - draw");
CCAssert(!m_pobBatchNode,"If CCSprite is being rendered byCCSpriteBatchNode, CCSprite#draw SHOULD NOT be called");
CC_NODE_DRAW_SETUP();
c