當前位置: 首頁>>代碼示例>>C++>>正文


C++ CC_NODE_DRAW_SETUP函數代碼示例

本文整理匯總了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);
        }
    }
}
開發者ID:BellyWong,項目名稱:EarthWarrior3D,代碼行數:32,代碼來源:CCBatchNode.cpp

示例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);
}
開發者ID:xoraphics,項目名稱:yummyjump,代碼行數:29,代碼來源:texturesprite.cpp

示例3: CC_NODE_DRAW_SETUP

void CADrawView::draw()
{
    CC_NODE_DRAW_SETUP();
    ccGLBlendFunc(m_sBlendFunc.src, m_sBlendFunc.dst);
    
    render();
}
開發者ID:Brian1900,項目名稱:CrossApp,代碼行數:7,代碼來源:CADrawView.cpp

示例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 );
}
開發者ID:mcodegeeks,項目名稱:OpenKODE-Framework,代碼行數:35,代碼來源:Controller.cpp

示例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();
}
開發者ID:newcl,項目名稱:boom,代碼行數:30,代碼來源:BBWater.cpp

示例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);	
}
開發者ID:catyguan,項目名稱:gamedev.platform,代碼行數:26,代碼來源:CCEPixelNode.cpp

示例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);
}
開發者ID:ourgames,項目名稱:dc208,代碼行數:25,代碼來源:CCMenuItemColor.cpp

示例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");
}
開發者ID:12white,項目名稱:CocoStudioSamples,代碼行數:31,代碼來源:CCLabel.cpp

示例9: CC_NODE_DRAW_SETUP

void CCDrawNode::draw()
{
    CC_NODE_DRAW_SETUP();
    ccGLBlendFunc(m_sBlendFunc.src, m_sBlendFunc.dst);
    
    render();
}
開發者ID:wenhulove333,項目名稱:ScutServer,代碼行數:7,代碼來源:CCDrawNode.cpp

示例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);
}
開發者ID:Gamex,項目名稱:GameX,代碼行數:32,代碼來源:CCMotionStreak.cpp

示例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);
}
開發者ID:boruis,項目名稱:cocos2dx-classical,代碼行數:35,代碼來源:CCMotionStreak.cpp

示例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();
        }
    }
}
開發者ID:leanlyne,項目名稱:ShootColorX,代碼行數:32,代碼來源:CCBatchNode.cpp

示例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);*/
}
開發者ID:HoaPham98,項目名稱:HillClimb,代碼行數:33,代碼來源:Sky.cpp

示例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");
}
開發者ID:Pancho2wang,項目名稱:cocos2dx_shader_demo,代碼行數:35,代碼來源:RemoveBKSprite.cpp

示例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);
}
開發者ID:1vs1,項目名稱:quick-cocos2d-x,代碼行數:25,代碼來源:CSShaderNode.cpp


注:本文中的CC_NODE_DRAW_SETUP函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。