• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setupVBO函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中setupVBO函数的典型用法代码示例。如果您正苦于以下问题:C++ setupVBO函数的具体用法?C++ setupVBO怎么用?C++ setupVBO使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setupVBO函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: initIndices

//implementation ParticleSystemQuad
// overriding the init method
bool ParticleSystemQuad::initWithTotalParticles(int numberOfParticles)
{
    // base initialization
    if( ParticleSystem::initWithTotalParticles(numberOfParticles) )
    {
        // allocating data space
        if( ! this->allocMemory() ) {
            this->release();
            return false;
        }

        initIndices();
        if (Configuration::getInstance()->supportsShareableVAO())
        {
            setupVBOandVAO();
        }
        else
        {
            setupVBO();
        }

        setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));

#if CC_ENABLE_CACHE_TEXTURE_DATA
        // Need to listen the event only when not use batchnode, because it will use VBO
        auto listener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(ParticleSystemQuad::listenRendererRecreated, this));
        _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
#endif

        return true;
    }
    return false;
}
开发者ID:253056965,项目名称:cocos2d-x-lite,代码行数:35,代码来源:CCParticleSystemQuad.cpp


示例2: setupIndices

NS_CC_BEGIN

//implementation CCParticleSystemQuad
// overriding the init method
bool CCParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles)
{
    // base initialization
    if( CCParticleSystem::initWithTotalParticles(numberOfParticles) )
    {
        // allocating data space
        if( ! this->allocMemory() ) {
            this->release();
            return false;
        }

        setupIndices();
#if CC_TEXTURE_ATLAS_USE_VAO
        setupVBOandVAO();
#else
        setupVBO();
#endif

        setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor));


        // Need to listen the event only when not use batchnode, because it will use VBO
        CCNotificationCenter::sharedNotificationCenter()->addObserver(this,
                callfuncO_selector(CCParticleSystemQuad::listenBackToForeground),
                EVNET_COME_TO_FOREGROUND,
                NULL);

        return true;
    }
    return false;
}
开发者ID:Ratel13,项目名称:super-animation-samples,代码行数:35,代码来源:CCParticleSystemQuad.cpp


示例3: setupVBOandVAO

void CCParticleSystemQuad::listenBackToForeground(CCObject *obj)
{
#if CC_TEXTURE_ATLAS_USE_VAO
        setupVBOandVAO();
#else
        setupVBO();
#endif
}
开发者ID:caoguoping,项目名称:warCraft,代码行数:8,代码来源:CCParticleSystemQuad.cpp


示例4: initOpenGL

//procedura inicjuj¹ca ró¿ne sprawy zwi¹zane z rysowaniem w OpenGL
void initOpenGL() {
	tex0 = readTexture("metal.tga");
	tex1 = readTexture("stones2.tga");
	tex2 = readTexture("latarka.tga");
	setupShaders();
	setupVBO();
	setupVAO();
	glEnable(GL_DEPTH_TEST);
}
开发者ID:kkapitan,项目名称:Maze,代码行数:10,代码来源:main_file.cpp


示例5: draw

void Polyhedron::init(GLuint program)
{
	//Generate the vertices needed for VBO and VAO
	draw();
	//Setup the VBO
	setupVBO();
	//Setup the VAO
	setupVAO(program);
}
开发者ID:rbVessal,项目名称:GeometryWarz,代码行数:9,代码来源:Polyhedron.cpp


示例6: setupVBOandVAO

void TextureAtlas::listenBackToForeground(Object *obj)
{  
#if CC_TEXTURE_ATLAS_USE_VAO
    setupVBOandVAO();    
#else    
    setupVBO();
#endif
    
    // set _dirty to true to force it rebinding buffer
    _dirty = true;
}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:11,代码来源:CCTextureAtlas.cpp


示例7: setupVBOandVAO

KDvoid CCTextureAtlas::listenBackToForeground ( CCObject* pObject )
{  
#if CC_TEXTURE_ATLAS_USE_VAO
    setupVBOandVAO ( );    
#else    
    setupVBO ( );
#endif
    
    // set m_bDirty to true to force it rebinding buffer
    m_bDirty = KD_TRUE;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:11,代码来源:CCTextureAtlas.cpp


示例8: setupVBOandVAO

void ParticleSystemQuad::listenRendererRecreated(EventCustom* event)
{
    if (Configuration::getInstance()->supportsShareableVAO())
    {
        setupVBOandVAO();
    }
    else
    {
        setupVBO();
    }
}
开发者ID:CatalystApps,项目名称:Cocos2dxv3_GAFSampleGame,代码行数:11,代码来源:CCParticleSystemQuad.cpp


示例9: setupVBOAndVAO

void Renderer::setupBuffer()
{
    if(Configuration::getInstance()->supportsShareableVAO())
    {
        setupVBOAndVAO();
    }
    else
    {
        setupVBO();
    }
}
开发者ID:0xiaohui00,项目名称:Cocos2dx-Wechat,代码行数:11,代码来源:CCRenderer.cpp


示例10: CCASSERT

bool TextureAtlas::initWithTexture(Texture2D *texture, ssize_t capacity)
{
    CCASSERT(capacity>=0, "Capacity must be >= 0");
    
//    CCASSERT(texture != nullptr, "texture should not be null");
    _capacity = capacity;
    _totalQuads = 0;

    // retained in property
    this->_texture = texture;
    CC_SAFE_RETAIN(_texture);

    // Re-initialization is not allowed
    CCASSERT(_quads == nullptr && _indices == nullptr, "");

    _quads = (V3F_C4B_T2F_Quad*)malloc( _capacity * sizeof(V3F_C4B_T2F_Quad) );
    _indices = (GLushort *)malloc( _capacity * 6 * sizeof(GLushort) );
    
    if( ! ( _quads && _indices) && _capacity > 0) 
    {
        //CCLOG("cocos2d: TextureAtlas: not enough memory");
        CC_SAFE_FREE(_quads);
        CC_SAFE_FREE(_indices);

        // release texture, should set it to null, because the destruction will
        // release it too. see cocos2d-x issue #484
        CC_SAFE_RELEASE_NULL(_texture);
        return false;
    }

    memset( _quads, 0, _capacity * sizeof(V3F_C4B_T2F_Quad) );
    memset( _indices, 0, _capacity * 6 * sizeof(GLushort) );
    
#if CC_ENABLE_CACHE_TEXTURE_DATA
    /** listen the event that renderer was recreated on Android/WP8 */
    _rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(TextureAtlas::listenRendererRecreated, this));
    Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_rendererRecreatedListener, -1);
#endif
    
    this->setupIndices();

    if (Configuration::getInstance()->supportsShareableVAO())
    {
        setupVBOandVAO();
    }
    else
    {
        setupVBO();
    }

    _dirty = true;

    return true;
}
开发者ID:akinlin,项目名称:PowerOfTheMind,代码行数:54,代码来源:CCTextureAtlas.cpp


示例11: setupVBOandVAO

void CCTextureAtlas::listenBackToForeground(const char* noteName, CCDictionary* params)
{  
#if CC_TEXTURE_ATLAS_USE_VAO
    setupVBOandVAO();
#else    
    setupVBO();
#endif
    
    // set m_bDirty to true to force it rebinding buffer
    m_bDirty = true;
}
开发者ID:BradB132,项目名称:cocos2d-x,代码行数:11,代码来源:CCTextureAtlas.cpp


示例12: CCASSERT

bool TextureAtlas::initWithTexture(Texture2D *texture, int capacity)
{
    CCASSERT(capacity>=0, "Capacity must be >= 0");
    
//    CCASSERT(texture != NULL, "texture should not be null");
    _capacity = capacity;
    _totalQuads = 0;

    // retained in property
    this->_texture = texture;
    CC_SAFE_RETAIN(_texture);

    // Re-initialization is not allowed
    CCASSERT(_quads == NULL && _indices == NULL, "");

    _quads = (V3F_C4B_T2F_Quad*)malloc( _capacity * sizeof(V3F_C4B_T2F_Quad) );
    _indices = (GLushort *)malloc( _capacity * 6 * sizeof(GLushort) );
    
    if( ! ( _quads && _indices) && _capacity > 0) 
    {
        //CCLOG("cocos2d: TextureAtlas: not enough memory");
        CC_SAFE_FREE(_quads);
        CC_SAFE_FREE(_indices);

        // release texture, should set it to null, because the destruction will
        // release it too. see cocos2d-x issue #484
        CC_SAFE_RELEASE_NULL(_texture);
        return false;
    }

    memset( _quads, 0, _capacity * sizeof(V3F_C4B_T2F_Quad) );
    memset( _indices, 0, _capacity * 6 * sizeof(GLushort) );
    
#if CC_ENABLE_CACHE_TEXTURE_DATA
    // listen the event when app go to background
    NotificationCenter::getInstance()->addObserver(this,
                                                           callfuncO_selector(TextureAtlas::listenBackToForeground),
                                                           EVNET_COME_TO_FOREGROUND,
                                                           NULL);
#endif
    
    this->setupIndices();

#if CC_TEXTURE_ATLAS_USE_VAO
    setupVBOandVAO();    
#else    
    setupVBO();
#endif

    _dirty = true;

    return true;
}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:53,代码来源:CCTextureAtlas.cpp


示例13: CC_SAFE_RETAIN

KDbool CCTextureAtlas::initWithTexture ( CCTexture2D* pTexture, KDuint uCapacity )
{
//	CCAssert ( pTexture != KD_NULL, "texture should not be null" );
    
	m_uCapacity   = uCapacity;
	m_uTotalQuads = 0;

	// retained in property
	m_pTexture = pTexture;
	CC_SAFE_RETAIN ( m_pTexture );

	// Re-initialization is not allowed
	CCAssert ( m_pQuads == KD_NULL && m_pIndices == KD_NULL, "" );

	m_pQuads   = (ccV3F_C4B_T2F_Quad *) kdCalloc ( 1, sizeof ( ccV3F_C4B_T2F_Quad ) * m_uCapacity );
	m_pIndices = (GLushort *) kdCalloc ( 1, sizeof ( GLushort ) * m_uCapacity * 6 );
	if ( !( m_pQuads && m_pIndices ) && m_uCapacity > 0 ) 
	{
		//CCLOG ( "XMCocos2D : CCTextureAtlas: not enough memory" );

		CC_SAFE_FREE ( m_pQuads );
		CC_SAFE_FREE ( m_pIndices );

		// release texture, should set it to null, because the destruction will
		// release it too. see cocos2d-x issue #484
		CC_SAFE_RELEASE ( m_pTexture );

		return KD_FALSE;
	}

#if CC_ENABLE_CACHE_TEXTURE_DATA
    // listen the event when app go to background
    CCNotificationCenter::sharedNotificationCenter ( )->addObserver 
	(
		this, callfuncO_selector ( CCTextureAtlas::listenBackToForeground ),
		EVENT_COME_TO_FOREGROUND, KD_NULL 
	);
#endif

	this->setupIndices ( );

#if CC_TEXTURE_ATLAS_USE_VAO
    setupVBOandVAO ( );    
#else    
    setupVBO ( );
#endif

	m_bDirty = KD_TRUE;	

	return KD_TRUE;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:51,代码来源:CCTextureAtlas.cpp


示例14: setupVBOandVAO

void TextureAtlas::listenRendererRecreated(EventCustom* event)
{  
    if (Configuration::getInstance()->supportsShareableVAO())
    {
        setupVBOandVAO();
    }
    else
    {
        setupVBO();
    }
    
    // set _dirty to true to force it rebinding buffer
    _dirty = true;
}
开发者ID:akinlin,项目名称:PowerOfTheMind,代码行数:14,代码来源:CCTextureAtlas.cpp


示例15: init

void init() {

    glClearColor(0.5, 0.5, 0.5, 1.0);
    glShadeModel(GL_SMOOTH);
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHT1);
    glEnable(GL_LIGHT2);


    glLightfv(GL_LIGHT0, GL_AMBIENT, red_light);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, red_light);
    glLightfv(GL_LIGHT0, GL_SPECULAR, red_light);

    glLightfv(GL_LIGHT1, GL_AMBIENT, white_light);
    glLightfv(GL_LIGHT1, GL_DIFFUSE, white_light);
    glLightfv(GL_LIGHT1, GL_SPECULAR, white_light);

    glLightfv(GL_LIGHT2, GL_AMBIENT, white_light);
    glLightfv(GL_LIGHT2, GL_DIFFUSE, white_light);
    glLightfv(GL_LIGHT2, GL_SPECULAR, white_light);

    glLightf(GL_LIGHT2, GL_SPOT_CUTOFF, 10.0);
    glLightf(GL_LIGHT2, GL_SPOT_EXPONENT, 5.0);

    angle = 0.0f;
    ye    = 5.0;
    xe    = 0.0f;
    ze    = 0.0f;

    setupShaders(
            (char*)"pointlight.vert", 
            (char*)"pointlight.frag",
            &ProgramA, 
            &vertexShaderObjectA,
            &fragmentShaderObjectA);
    setupShaders(
            (char*)"dirLightAmbDiffSpecPix.vert", 
            (char*)"dirLightAmbDiffSpecPix.frag",
            &ProgramA, 
            &vertexShaderObjectA,
            &fragmentShaderObjectA);
    setupVBO();
    setupVBOfromObj((char*)"rev2.obj");
    glUseProgram(ProgramA);
}
开发者ID:kgadek,项目名称:kpfp,代码行数:49,代码来源:gadekkonrad_projekt.cpp


示例16: CC_SAFE_RETAIN

bool CCTextureAtlas::initWithTexture(CCTexture2D *texture, unsigned int capacity)
{
//    CCAssert(texture != NULL, "texture should not be null");
    m_uCapacity = capacity;
    m_uTotalQuads = 0;

    // retained in property
    this->m_pTexture = texture;
    CC_SAFE_RETAIN(m_pTexture);

    // Re-initialization is not allowed
    CCAssert(m_pQuads == NULL && m_pIndices == NULL, "");

    m_pQuads = (ccV3F_C4B_T2F_Quad*)malloc( m_uCapacity * sizeof(ccV3F_C4B_T2F_Quad) );
    m_pIndices = (GLushort *)malloc( m_uCapacity * 6 * sizeof(GLushort) );
    
    if( ! ( m_pQuads && m_pIndices) && m_uCapacity > 0) 
    {
        //CCLOG("cocos2d: CCTextureAtlas: not enough memory");
        CC_SAFE_FREE(m_pQuads);
        CC_SAFE_FREE(m_pIndices);

        // release texture, should set it to null, because the destruction will
        // release it too. see cocos2d-x issue #484
        CC_SAFE_RELEASE_NULL(m_pTexture);
        return false;
    }

    memset( m_pQuads, 0, m_uCapacity * sizeof(ccV3F_C4B_T2F_Quad) );
    memset( m_pIndices, 0, m_uCapacity * 6 * sizeof(GLushort) );
    
    // listen the event when app go to background
    extension::CCNotificationCenter::sharedNotificationCenter()->addObserver(this,
                                                           callfuncO_selector(CCTextureAtlas::listenBackToForeground),
                                                           EVNET_COME_TO_FOREGROUND,
                                                           NULL);

    this->setupIndices();

#if CC_TEXTURE_ATLAS_USE_VAO
    setupVBOandVAO();    
#else    
    setupVBO();
#endif

    m_bDirty = true;

    return true;
}
开发者ID:136446529,项目名称:book-code,代码行数:49,代码来源:CCTextureAtlas.cpp


示例17: memset

void ParticleSystemQuad::listenRendererRecreated(EventCustom* event)
{
    //when comes to foreground in android, _buffersVBO and _VAOname is a wild handle
    //before recreating, we need to reset them to 0
    memset(_buffersVBO, 0, sizeof(_buffersVBO));
    if (Configuration::getInstance()->supportsShareableVAO())
    {
        _VAOname = 0;
        setupVBOandVAO();
    }
    else
    {
        setupVBO();
    }
}
开发者ID:253056965,项目名称:cocos2d-x-lite,代码行数:15,代码来源:CCParticleSystemQuad.cpp


示例18: allocMemory

void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode)
{
    if( _batchNode != batchNode )
    {
        ParticleBatchNode* oldBatch = _batchNode;

        ParticleSystem::setBatchNode(batchNode);

        // NEW: is self render ?
        if( ! batchNode )
        {
            allocMemory();
            initIndices();
            setTexture(oldBatch->getTexture());
            if (Configuration::getInstance()->supportsShareableVAO())
            {
                setupVBOandVAO();
            }
            else
            {
                setupVBO();
            }
        }
        // OLD: was it self render ? cleanup
        else if( !oldBatch )
        {
            // copy current state to batch
            V3F_C4B_T2F_Quad *batchQuads = _batchNode->getTextureAtlas()->getQuads();
            V3F_C4B_T2F_Quad *quad = &(batchQuads[_atlasIndex] );
            memcpy( quad, _quads, _totalParticles * sizeof(_quads[0]) );

            CC_SAFE_FREE(_quads);
            CC_SAFE_FREE(_indices);

            glDeleteBuffers(2, &_buffersVBO[0]);
            memset(_buffersVBO, 0, sizeof(_buffersVBO));
            if (Configuration::getInstance()->supportsShareableVAO())
            {
                glDeleteVertexArrays(1, &_VAOname);
                GL::bindVAO(0);
                _VAOname = 0;
            }
        }
    }
}
开发者ID:253056965,项目名称:cocos2d-x-lite,代码行数:45,代码来源:CCParticleSystemQuad.cpp


示例19: allocMemory

void CCParticleSystemQuad::setBatchNode(CCParticleBatchNode * batchNode)
{
    if( m_pBatchNode != batchNode ) 
    {
        CCParticleBatchNode* oldBatch = m_pBatchNode;

        CCParticleSystem::setBatchNode(batchNode);

        // NEW: is self render ?
        if( ! batchNode ) 
        {
            allocMemory();
            initIndices();
            setTexture(oldBatch->getTexture());
#if CC_TEXTURE_ATLAS_USE_VAO
            setupVBOandVAO();
#else
            setupVBO();
#endif
        }
        // OLD: was it self render ? cleanup
        else if( !oldBatch )
        {
            // copy current state to batch
            ccV3F_C4B_T2F_Quad *batchQuads = m_pBatchNode->getTextureAtlas()->getQuads();
            ccV3F_C4B_T2F_Quad *quad = &(batchQuads[m_uAtlasIndex] );
            memcpy( quad, m_pQuads, m_uTotalParticles * sizeof(m_pQuads[0]) );

            CC_SAFE_FREE(m_pQuads);
            CC_SAFE_FREE(m_pIndices);

            glDeleteBuffers(2, &m_pBuffersVBO[0]);
            memset(m_pBuffersVBO, 0, sizeof(m_pBuffersVBO));
#if CC_TEXTURE_ATLAS_USE_VAO
            glDeleteVertexArrays(1, &m_uVAOname);
            ccGLBindVAO(0);
            m_uVAOname = 0;
#endif
        }
    }
}
开发者ID:caoguoping,项目名称:warCraft,代码行数:41,代码来源:CCParticleSystemQuad.cpp


示例20: initIndices

NS_CC_BEGIN

//implementation ParticleSystemQuad
// overriding the init method
bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles)
{
    // base initialization
    if( ParticleSystem::initWithTotalParticles(numberOfParticles) ) 
    {
        // allocating data space
        if( ! this->allocMemory() ) {
            this->release();
            return false;
        }

        initIndices();
#if CC_TEXTURE_ATLAS_USE_VAO
        setupVBOandVAO();
#else
        setupVBO();
#endif

        setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
        
#if CC_ENABLE_CACHE_TEXTURE_DATA
        // Need to listen the event only when not use batchnode, because it will use VBO
        NotificationCenter::getInstance()->addObserver(this,
                                                                      callfuncO_selector(ParticleSystemQuad::listenBackToForeground),
                                                                      EVNET_COME_TO_FOREGROUND,
                                                                      NULL);
#endif

        return true;
    }
    return false;
}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:36,代码来源:CCParticleSystemQuad.cpp



注:本文中的setupVBO函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setup_adc函数代码示例发布时间:2022-05-30
下一篇:
C++ setupResources函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap