本文整理汇总了C++中CC_NODE_DRAW_SETUP函数的典型用法代码示例。如果您正苦于以下问题:C++ CC_NODE_DRAW_SETUP函数的具体用法?C++ CC_NODE_DRAW_SETUP怎么用?C++ CC_NODE_DRAW_SETUP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CC_NODE_DRAW_SETUP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CC_NODE_DRAW_SETUP
void BatchNode::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
if (_children.empty())
{
return;
}
CC_NODE_DRAW_SETUP();
bool pushed = false;
for(auto object : _children)
{
Armature *armature = dynamic_cast<Armature *>(object);
if (armature)
{
if (!pushed)
{
generateGroupCommand();
pushed = true;
}
armature->visit(renderer, transform, transformUpdated);
}
else
{
renderer->popGroup();
pushed = false;
((Node *)object)->visit(renderer, transform, transformUpdated);
}
}
}
示例2: CC_NODE_DRAW_SETUP
void TextureSprite::draw()
{
if (!m_bVisible) return;
CC_NODE_DRAW_SETUP();
ccGLBlendFunc(m_sBlendFunc.src, m_sBlendFunc.dst);
ccGLBindTexture2D(mTexture2D->getName());
ccGLEnableVertexAttribs(kCCVertexAttribFlag_Position | kCCVertexAttribFlag_TexCoords);
/// Time offset
getShaderProgram()->setUniformLocationWith2f(mTimeLocation, mTime.x, mTime.y);
/// Color
getShaderProgram()->setUniformLocationWith4f(mColorLocation, mColor.r, mColor.g, mColor.b, mColor.a);
/// Vertex
glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, sizeof(ccVertex3F), (void*)&mVertexPos[0]);
/// Texture coord.
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccTex2F), (void*)&mTexCoords[0]);
/// Available mode: GL_TRIANGLES, GL_TRIANGLES_STRIP and GL_TRIANGLE_FAN
glDrawArrays(GL_TRIANGLES, 0, mVertexPos.size());
/// Do NOT call glFlush or performance will decrease drastically!
/// glFlush();
CHECK_GL_ERROR_DEBUG();
CC_INCREMENT_GL_DRAWS(1);
}
示例3: CC_NODE_DRAW_SETUP
void CADrawView::draw()
{
CC_NODE_DRAW_SETUP();
ccGLBlendFunc(m_sBlendFunc.src, m_sBlendFunc.dst);
render();
}
示例4: CC_NODE_DRAW_SETUP
KDvoid Controller::draw ( KDvoid )
{
CC_NODE_DRAW_SETUP ( );
GLfloat fVertices [ ] =
{
0, 512,
1024, 512,
0, 0,
1024, 0,
};
GLfloat fCoords [ ] =
{
0, 0,
1, 0,
0, 1,
1, 1,
};
ccGLBindTexture2D ( m_uTexture );
ccGLEnableVertexAttribs ( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_TexCoords );
if ( m_pDrawFunc )
{
m_pDrawFunc ( KD_GET_UST2MSEC );
}
ccGLVertexAttribPointer ( kCCVertexAttrib_Position , 2, GL_FLOAT, GL_FALSE, 0, fVertices );
ccGLVertexAttribPointer ( kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, fCoords );
glDrawArrays ( GL_TRIANGLE_STRIP, 0, 4 );
ccGLBindTexture2D ( 0 );
}
示例5: CC_NODE_DRAW_SETUP
void BBWater::draw()
{
CC_NODE_DRAW_SETUP();
// ccGLBlendFunc( m_sBlendFunc.src, m_sBlendFunc.dst );
ccGLBindTexture2D( m_sprite->getTexture()->getName() );
// ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
// glBindBuffer(GL_ARRAY_BUFFER, m_vertexVbo);
// glBufferData(GL_ARRAY_BUFFER, sizeof(float)*vertexArray.size(), &vertexArray[0], GL_STATIC_DRAW);
glEnableVertexAttribArray( kCCVertexAttrib_Position );
// vertex
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3, &vertexArray[0]);
// // texCoods
// diff = offsetof( ccV3F_C4B_T2F, texCoords);
// glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));
//
// // color
// diff = offsetof( ccV3F_C4B_T2F, colors);
// glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
glDrawArrays(GL_TRIANGLES, 0, m_faceCount);
CHECK_GL_ERROR_DEBUG();
}
示例6: CC_NODE_DRAW_SETUP
void CCEPixelNode::draw()
{
CC_NODE_DRAW_SETUP();
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_Color );
//
// Attributes
//
ccePixelPart* pt = m_pPixels;
while(pt!=NULL) {
if(!pt->hide) {
for(int i=0;i<pt->len;i++) {
ccePixelInfo* p = pt->pixels+i;
if(p->hide)continue;
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, p->square);
glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, p->color);
ccGLBlendFunc( m_tBlendFunc.src, m_tBlendFunc.dst );
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
}
pt = pt->next;
}
CC_INCREMENT_GL_DRAWS(1);
}
示例7: CC_NODE_DRAW_SETUP
void CCMenuItemColor::draw(Renderer *renderer, const kmMat4& transform, bool transformUpdated) {
CC_NODE_DRAW_SETUP();
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_Color );
//
// Attributes
//
#ifdef EMSCRIPTEN
setGLBufferData(m_pSquareVertices, 4 * sizeof(ccVertex2F), 0);
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(m_pSquareColors, 4 * sizeof(ccColor4F), 1);
glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, m_pSquareVertices);
glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, m_pSquareColors);
#endif // EMSCRIPTEN
ccGLBlendFunc(m_tBlendFunc.src, m_tBlendFunc.dst);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
CC_INCREMENT_GL_DRAWS(1);
}
示例8: CC_PROFILER_START
void Label::onDraw()
{
CC_PROFILER_START("Label - draw");
// Optimization: Fast Dispatch
if( _batchNodes.size() == 1 && _textureAtlas->getTotalQuads() == 0 )
{
return;
}
CC_NODE_DRAW_SETUP();
if (_useDistanceField && _currLabelEffect != LabelEffect::NORMAL)
{
_shaderProgram->setUniformLocationWith3f(_uniformEffectColor, _effectColor.r/255.0f,_effectColor.g/255.0f,_effectColor.b/255.0f);
}
for(const auto &child: _children)
{
child->updateTransform();
}
GL::blendFunc( _blendFunc.src, _blendFunc.dst );
for (const auto& batchNode:_batchNodes)
{
batchNode->getTextureAtlas()->drawQuads();
}
CC_PROFILER_STOP("Label - draw");
}
示例9: CC_NODE_DRAW_SETUP
void CCDrawNode::draw()
{
CC_NODE_DRAW_SETUP();
ccGLBlendFunc(m_sBlendFunc.src, m_sBlendFunc.dst);
render();
}
示例10: CC_NODE_DRAW_SETUP
void MotionStreak::draw()
{
if(_nuPoints <= 1)
return;
CC_NODE_DRAW_SETUP();
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
GL::blendFunc( _blendFunc.src, _blendFunc.dst );
GL::bindTexture2D( _texture->getName() );
#ifdef EMSCRIPTEN
// Size calculations from ::initWithFade
setGLBufferData(_vertices, (sizeof(Vertex2F) * _maxPoints * 2), 0);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(_colorPointer, (sizeof(GLubyte) * _maxPoints * 2 * 4), 2);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _vertices);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoords);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, _colorPointer);
#endif // EMSCRIPTEN
glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nuPoints*2);
CC_INCREMENT_GL_DRAWS(1);
}
示例11: CC_NODE_DRAW_SETUP
void CCMotionStreak::draw()
{
if(m_uNuPoints <= 1)
return;
CC_NODE_DRAW_SETUP(this);
ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex );
ccGLBlendFunc( m_tBlendFunc.src, m_tBlendFunc.dst );
ccGLBindTexture2D( m_pTexture->getName() );
if(m_pTexture->isETC()) {
getShaderProgram()->useSeparatedAlphaChannel(m_pTexture->getAlphaChannel()->getName());
}
#ifdef EMSCRIPTEN
// Size calculations from ::initWithFade
setGLBufferData(m_pVertices, (sizeof(ccVertex2F) * m_uMaxPoints * 2), 0);
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(m_pTexCoords, (sizeof(ccTex2F) * m_uMaxPoints * 2), 1);
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(m_pColorPointer, (sizeof(GLubyte) * m_uMaxPoints * 2 * 4), 2);
glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0);
#else
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, m_pVertices);
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, m_pTexCoords);
glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, m_pColorPointer);
#endif // EMSCRIPTEN
glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)m_uNuPoints*2);
CC_INCREMENT_GL_DRAWS(1);
}
示例12: CC_NODE_DRAW_SETUP
void BatchNode::draw()
{
if (_children.empty())
{
return;
}
CC_NODE_DRAW_SETUP();
bool pushed = false;
for(auto object : _children)
{
Armature *armature = dynamic_cast<Armature *>(object);
if (armature)
{
if (!pushed)
{
generateGroupCommand();
pushed = true;
}
armature->visit();
}
else
{
Director::getInstance()->getRenderer()->popGroup();
pushed = false;
((Node *)object)->visit();
}
}
}
示例13: CC_NODE_DRAW_SETUP
void Sky::draw(Renderer *renderer, const Mat4& transform, uint32_t flags) {
cocos2d::Size s = Director::getInstance()->getWinSize();
DoodleTruck *doodleTruck = DoodleTruck::sharedDoodleTruck();
CC_NODE_DRAW_SETUP();
Vec2 _skyVertices[4];
Vec2 _skyTexCoords[4];
_skyVertices[0] = Vec2(0, 0);
_skyTexCoords[0] = Vec2(1.0, 1.0f);
_skyVertices[1] = Vec2(s.width, 0);
_skyTexCoords[1] = Vec2(1.0f, 1.0f);
_skyVertices[2] = Vec2(0, s.height);
_skyTexCoords[2] = Vec2(31.0f, 63.0f);
_skyVertices[3] = Vec2(s.width, s.height);
_skyTexCoords[3] = Vec2(31.0f, 63.0f);
Texture2D * tex = Director::getInstance()->getTextureCache()->textureForKey("sky-bg-rainbow.png");
GL::bindTexture2D(tex->getName());
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORD);
ccDrawColor4F(1.0f, 1.0f, 1.0f, 1.0f);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _skyVertices);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, _skyTexCoords);
glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)4);
// ccDrawColor4F(1.0, 1.0, 1.0, 1.0);*/
}
示例14: CC_PROFILER_START_CATEGORY
//--------------------------------------------------------
void CRemoveBKSprite::draw(void)
{
CC_PROFILER_START_CATEGORY(kCCProfilerCategorySprite, "CCSprite - draw");
CCAssert(!m_pobBatchNode, "If CCSprite is being rendered by CCSpriteBatchNode, CCSprite#draw SHOULD NOT be called");
CC_NODE_DRAW_SETUP();
// 启用attributes变量输入,顶点坐标,纹理坐标,颜色
ccGLEnableVertexAttribs( kCCVertexAttribFlag_PosColorTex );
ccGLBlendFunc(m_sBlendFunc.src, m_sBlendFunc.dst);
m_pShaderProgram->use();
m_pShaderProgram->setUniformsForBuiltins();
// 绑定纹理到纹理槽0
ccGLBindTexture2D(m_pobTexture->getName());
long offset = (long)&m_sQuad;
// vertex
int diff = offsetof( ccV3F_C4B_T2F, vertices);
glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, sizeof(m_sQuad.bl), (void*) (offset + diff));
// texCoods
diff = offsetof( ccV3F_C4B_T2F, texCoords);
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(m_sQuad.bl), (void*)(offset + diff));
// color
diff = offsetof( ccV3F_C4B_T2F, colors);
glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(m_sQuad.bl), (void*)(offset + diff));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
CHECK_GL_ERROR_DEBUG();
CC_INCREMENT_GL_DRAWS(1);
CC_PROFILER_STOP_CATEGORY(kCCProfilerCategorySprite, "CCSprite - draw");
}
示例15: CC_NODE_DRAW_SETUP
void ShaderNode::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);
}