当前位置: 首页>>代码示例>>C++>>正文


C++ CC_INCREMENT_GL_DRAWS函数代码示例

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


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

示例1: b2Vec2

			void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color)
			{
				mShaderProgram->use();
				mShaderProgram->setUniformsForBuiltins();

				const float32 k_segments = 16.0f;
				int vertexCount=16;
				const float32 k_increment = 2.0f * b2_pi / k_segments;
				float32 theta = 0.0f;

				GLfloat*    glVertices = new GLfloat[vertexCount*2];
				for (int i = 0; i < k_segments; ++i)
				{
					b2Vec2 v = center + radius * b2Vec2(cosf(theta), sinf(theta));
					glVertices[i*2]=v.x * mRatio;
					glVertices[i*2+1]=v.y * mRatio;
					theta += k_increment;
				}

				mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1);
				glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices);

				glDrawArrays(GL_LINE_LOOP, 0, vertexCount);

				CC_INCREMENT_GL_DRAWS(1);

				CHECK_GL_ERROR_DEBUG();

				delete[] glVertices;
			}
开发者ID:DukeWong,项目名称:PokerMan,代码行数:30,代码来源:GLES-Render.cpp

示例2: glVertexAttribPointer

			void GLESDebugDraw::DrawSolidPolygon(const b2Vec2* old_vertices, int vertexCount, const b2Color& color)
			{
				mShaderProgram->use();
				mShaderProgram->setUniformsForBuiltins();

				b2Vec2* vertices = new b2Vec2[vertexCount];
				for( int i=0;i<vertexCount;i++) {
					vertices[i] = old_vertices[i];
					vertices[i] *= mRatio;
				}

				mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f);

				glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);

				glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount);

				mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1);
				glDrawArrays(GL_LINE_LOOP, 0, vertexCount);

				CC_INCREMENT_GL_DRAWS(2);

				CHECK_GL_ERROR_DEBUG();

				delete[] vertices;
			}
开发者ID:DukeWong,项目名称:PokerMan,代码行数:26,代码来源:GLES-Render.cpp

示例3: ccGLEnableVertexAttribs

void CCGSpell::onDraw(const Mat4 &transform, uint32_t flags)
{
	// 启用attributes变量输入,顶点坐标,纹理坐标,颜色
	ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex);

	_pShaderProgram->use();
	_pShaderProgram->setUniformsForBuiltins(transform);

	// 绑定纹理到纹理槽0
	ccGLBindTexture2D(_texture->getName());
	long offset = (long)&_quad;

	// vertex
	int diff = offsetof(V3F_C4B_T2F, vertices);
	glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), (void*)(offset + diff));

	// texCoods
	diff = offsetof(V3F_C4B_T2F, texCoords);
	glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), (void*)(offset + diff));

	// color
	diff = offsetof(V3F_C4B_T2F, colors);
	glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B_T2F), (void*)(offset + diff));

	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
	CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:gameboy12615,项目名称:CCGEditor,代码行数:27,代码来源:CCGSpell.cpp

示例4: drawPoint

void drawPoint( const Point& point )
{
    lazy_init();

    Vertex2F p;
    p.x = point.x;
    p.y = point.y;

    GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
    s_shader->use();
    s_shader->setUniformsForBuiltins();

    s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1);
    s_shader->setUniformLocationWith1f(s_pointSizeLocation, s_pointSize);

#ifdef EMSCRIPTEN
    setGLBufferData(&p, 8);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, &p);
#endif // EMSCRIPTEN

    glDrawArrays(GL_POINTS, 0, 1);

    CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:Gamex,项目名称:GameX,代码行数:26,代码来源:CCDrawingPrimitives.cpp

示例5: CC_NODE_DRAW_SETUP

void CCLayerColor::draw()
{
    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:brooklynpacket,项目名称:cocos2d-x,代码行数:26,代码来源:CCLayer.cpp

示例6: ccDrawSolidPoly

void ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color )
{
    lazy_init();

    s_pShader->use();
    s_pShader->setUniformsForBuiltins();
    s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &color.r, 1);

    ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );

    // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
    ccVertex2F* newPoli = new ccVertex2F[numberOfPoints];

    // iPhone and 32-bit machines optimization
    if( sizeof(CCPoint) == sizeof(ccVertex2F) )
    {
        glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli);
    }
    else
    {
        // Mac on 64-bit
        for( unsigned int i=0; i<numberOfPoints; i++)
        {
            newPoli[i] = vertex2( poli[i].x, poli[i].y );
        }
        glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
    }

    glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) numberOfPoints);

    CC_SAFE_DELETE_ARRAY(newPoli);
    CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:Ratel13,项目名称:cocos2dx-swf,代码行数:33,代码来源:CCDrawingPrimitives.cpp

示例7: ccGLEnableVertexAttribs

void EXSunShineSprite::draw()
{
	ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex);
    m_sBlendFunc.src = GL_DST_COLOR;
    m_sBlendFunc.dst = GL_ONE;
	ccGLBlendFunc( m_sBlendFunc.src, m_sBlendFunc.dst );
    
	this->getShaderProgram()->use();
	this->getShaderProgram()->setUniformsForBuiltins();
    
	ccGLBindTexture2D(  this->getTexture()->getName() );
    
#define kQuadSize sizeof(m_sQuad.bl)
	long offset = (long)&m_sQuad;
    
	// vertex
	int diff = offsetof( ccV3F_C4B_T2F, vertices);
	glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));
    
	// 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_TRIANGLE_STRIP, 0, 4);
	CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:grefZhou,项目名称:cocos2dx-extensions-master,代码行数:29,代码来源:EXSunShineSprite.cpp

示例8: ccDrawCubicBezier

void ccDrawCubicBezier(const CCPoint& origin, const CCPoint& control1, const CCPoint& control2, const CCPoint& destination, unsigned int segments)
{
    lazy_init();

    ccVertex2F* vertices = new ccVertex2F[segments + 1];

    float t = 0;
    for(unsigned int i = 0; i < segments; i++)
    {
        vertices[i].x = powf(1 - t, 3) * origin.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * destination.x;
        vertices[i].y = powf(1 - t, 3) * origin.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * destination.y;
        t += 1.0f / segments;
    }
    vertices[segments].x = destination.x;
    vertices[segments].y = destination.y;

    s_pShader->use();
    s_pShader->setUniformsForBuiltins();
    s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);

    ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );

    glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
    glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1);
    CC_SAFE_DELETE_ARRAY(vertices);

    CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:Ratel13,项目名称:cocos2dx-swf,代码行数:28,代码来源:CCDrawingPrimitives.cpp

示例9: ccGLEnableVertexAttribs

void RedSprite::draw()
{
    ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex);
    ccGLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    getShaderProgram()->use();
    getShaderProgram()->setUniformsForBuiltins();

    ccGLBindTexture2D(getTexture()->getName());

    // attributes.
#define kQuadSize sizeof(m_sQuad.bl)
    long offset = (long)&m_sQuad;

    //vertex
    int diff = offsetof(ccV3F_C4B_T2F, vertices);
    glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));

    // 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_TRIANGLE_STRIP, 0, 4);

    CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:elloop,项目名称:cocos2d-x-cpp-demos-2.x,代码行数:30,代码来源:CustomSpritePage.cpp

示例10: drawQuadBezier

void drawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments)
{
    lazy_init();

    Vertex2F* vertices = new Vertex2F[segments + 1];

    float t = 0.0f;
    for(unsigned int i = 0; i < segments; i++)
    {
        vertices[i].x = powf(1 - t, 2) * origin.x + 2.0f * (1 - t) * t * control.x + t * t * destination.x;
        vertices[i].y = powf(1 - t, 2) * origin.y + 2.0f * (1 - t) * t * control.y + t * t * destination.y;
        t += 1.0f / segments;
    }
    vertices[segments].x = destination.x;
    vertices[segments].y = destination.y;

    s_shader->use();
    s_shader->setUniformsForBuiltins();
    s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1);

    GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );

#ifdef EMSCRIPTEN
    setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F));
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
#endif // EMSCRIPTEN
    glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1);
    CC_SAFE_DELETE_ARRAY(vertices);

    CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:Gamex,项目名称:GameX,代码行数:33,代码来源:CCDrawingPrimitives.cpp

示例11: atan2f

void FXLightning::render(){

	float angle = atan2f(end.y - start.y , end.x - start.x);
	float x = cosf(angle - M_PI/2.0) * width;
	float y = sinf(angle - M_PI/2.0) * width;
	float rx = cosf(angle - M_PI/2.0) * spread;
	float ry = sinf(angle - M_PI/2.0) * spread;
    static int counter = 0;
	
	int n_samples = ccpDistance(start, end)/480 * K_NUMBER_OF_LIGHTNING_SAMPLES;
	if (n_samples > K_NUMBER_OF_LIGHTNING_SAMPLES) {
		n_samples = K_NUMBER_OF_LIGHTNING_SAMPLES;
	}
   
	for (int i=0; i < n_samples; i+=2) {
        CCPoint p = ccpLerp(start, end, i/(float)(n_samples-1));
		float r = ((rand()%100) / 100.0 - 0.5) * 7;
//        float r = 20* noise1(counter*speed);
        float w = 0;
        if (i < n_samples*0.5) {
            w = i/(float)n_samples * 3;
        }
        else{
            w = (n_samples-i-2)/(float)n_samples * 3;
        }
        w = clampf(w, 0, 1);
        if (tapper == 0) {
            vtx[ i+0 ].x = p.x + x + rx*r*w;
            vtx[ i+0 ].y = p.y + y + ry*r*w;
            
            vtx[ i+1 ].x = p.x - x + rx*r*w;
            vtx[ i+1 ].y = p.y - y + ry*r*w;
        }
        else{
            vtx[ i+0 ].x = p.x + x*tapper*(1-i/(float)n_samples) + rx*r;
            vtx[ i+0 ].y = p.y + y*tapper*(1-i/(float)n_samples) + ry*r;
            
            vtx[ i+1 ].x = p.x - x*tapper*(1-i/(float)n_samples) + rx*r;
            vtx[ i+1 ].y = p.y - y*tapper*(1-i/(float)n_samples) + ry*r;
        }
        counter+=5;
	}
    
    
    
    pShaderProgram->use();
    pShaderProgram->setUniformsForBuiltins();
    
    ccGLBindTexture2D(texture->getName());
    
    glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vtx);
    glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, uvs);
    glDrawArrays(GL_TRIANGLE_STRIP, 0,n_samples);
    
    //DEBUG
//    glDrawArrays(GL_LINE_STRIP, 0, n_samples);
    
    CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:asd235614,项目名称:diamond,代码行数:59,代码来源:FXLightning.cpp

示例12: CC_PROFILER_START_CATEGORY

void HueSprite::draw()
{

    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();
	ccGLEnable( m_eGLServerState );
        
	ccGLBlendFunc( m_sBlendFunc.src, m_sBlendFunc.dst );
        
	m_shader->use();
    m_shader->setUniformsForBuiltins();


	if (m_pobTexture != NULL)
	{
		//ccGLBindTexture2D( m_texure1->getName());
		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, m_pobTexture->getName());
	}
	else
	{
		ccGLBindTexture2D(0);
	}


	glUniformMatrix3fv(m_loc_hue, 1, GL_FALSE, (GLfloat*)&m_mat);

	//
	// Attributes
	//
	ccGLEnableVertexAttribs( kCCVertexAttribFlag_PosColorTex );
        
#define kQuadSize sizeof(m_sQuad.bl)
	long offset = (long)&m_sQuad;
        
	// vertex
	int diff = offsetof( ccV3F_C4B_T2F, vertices);
	glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));
        
	// 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_TRIANGLE_STRIP, 0, 4);
        
	CHECK_GL_ERROR_DEBUG();
        
	CC_INCREMENT_GL_DRAWS(1);
        
	CC_PROFILER_STOP_CATEGORY(kCCProfilerCategorySprite, "CCSprite - draw");
}
开发者ID:AdamWu,项目名称:cocos2dx-extension,代码行数:59,代码来源:hue_sprite.cpp

示例13: CCAssert

// overriding draw method
void CCParticleSystemQuad::draw()
{    
    CCAssert(!m_pBatchNode,"draw should not be called when added to a particleBatchNode");

    CC_NODE_DRAW_SETUP();

    ccGLBindTexture2D( m_pTexture->getName() );
    ccGLBlendFunc( m_tBlendFunc.src, m_tBlendFunc.dst );

    CCAssert( m_uParticleIdx == m_uParticleCount, "Abnormal error in particle quad");

#if CC_TEXTURE_ATLAS_USE_VAO
    //
    // Using VBO and VAO
    //
    glBindVertexArray( m_uVAOname );

#if CC_REBIND_INDICES_BUFFER
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_pBuffersVBO[1]);
#endif

    glDrawElements(GL_TRIANGLES, (GLsizei) m_uParticleIdx*6, GL_UNSIGNED_SHORT, 0);

#if CC_REBIND_INDICES_BUFFER
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#endif

    glBindVertexArray( 0 );

#else
    //
    // Using VBO without VAO
    //

    #define kQuadSize sizeof(m_pQuads[0].bl)

    ccGLEnableVertexAttribs( kCCVertexAttribFlag_PosColorTex );

    glBindBuffer(GL_ARRAY_BUFFER, m_pBuffersVBO[0]);
    // vertices
    glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( ccV3F_C4B_T2F, vertices));
    // colors
    glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( ccV3F_C4B_T2F, colors));
    // tex coords
    glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( ccV3F_C4B_T2F, texCoords));
    
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_pBuffersVBO[1]);

    glDrawElements(GL_TRIANGLES, (GLsizei) m_uParticleIdx*6, GL_UNSIGNED_SHORT, 0);

    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

#endif

    CC_INCREMENT_GL_DRAWS(1);
    CHECK_GL_ERROR_DEBUG();
}
开发者ID:Atomz,项目名称:super-animation-samples,代码行数:59,代码来源:CCParticleSystemQuad.cpp

示例14: CCASSERT

// overriding draw method
void ParticleSystemQuad::draw()
{    
    CCASSERT(!_batchNode,"draw should not be called when added to a particleBatchNode");

    CC_NODE_DRAW_SETUP();

    GL::bindTexture2D( _texture->getName() );
    GL::blendFunc( _blendFunc.src, _blendFunc.dst );

    CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad");

#if CC_TEXTURE_ATLAS_USE_VAO
    //
    // Using VBO and VAO
    //
    GL::bindVAO(_VAOname);

#if CC_REBIND_INDICES_BUFFER
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
#endif

    glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0);

#if CC_REBIND_INDICES_BUFFER
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#endif

#else
    //
    // Using VBO without VAO
    //

    #define kQuadSize sizeof(_quads[0].bl)

    GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );

    glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
    // vertices
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
    // colors
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
    // tex coords
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords));
    
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);

    glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0);

    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

#endif

    CC_INCREMENT_GL_DRAWS(1);
    CHECK_GL_ERROR_DEBUG();
}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:57,代码来源:CCParticleSystemQuad.cpp

示例15: CC_NODE_DRAW_SETUP

void CCSprite3D::draw()
{
//    m_bDepthTestEnabled = 0 == glIsEnabled(GL_DEPTH_TEST) ? false : true;
//
//    CCDirector::sharedDirector()->setDepthTest(true);
//
    CC_NODE_DRAW_SETUP();

//    getShaderProgram()->use();
//    getShaderProgram()->setUniformsForBuiltins();

    CCPoint const & origin = ccp(0, 0);
    CCPoint const & destination = ccp(100, 100);

    ccVertex3F vertices[3] = {
//        {origin.x, origin.y, 100},
            {destination.x, origin.y, 200},
            {destination.x, destination.y, 100},
            {origin.x, destination.y, 200}
    };

    ccTex2F uv[3] = {
//        {0.0f, 0.0f},
            {1.0f, 0.0f},
            {1.0f, 1.0f},
            {0.0f, 1.0f}
    };

    ccColor4B colors[3] = {
//        {255, 255, 255, 255},
            {128, 128, 128, 128},
            {128, 128, 128, 128},
            {255, 255, 255, 255}
    };

    ccGLBindTexture2D(mCustSkin->getName());

    ccGLEnableVertexAttribs( kCCVertexAttribFlag_PosColorTex );
    glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, vertices);
    glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, uv);
    glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, colors);
    glDrawArrays(GL_TRIANGLES, 0, 3);

    CHECK_GL_ERROR_DEBUG();

    CC_INCREMENT_GL_DRAWS(1);

//    m_pModel->draw();
//    static unsigned int uiStartFrame = 0, uiEndFrame = 182;
//    static float fAnimSpeed = 16.5f;
//   ((CCModelMd2*)m_pModel)->animate(fAnimSpeed, uiStartFrame, uiEndFrame, true);
//   CCDirector::sharedDirector()->setDepthTest(m_bDepthTestEnabled);
}
开发者ID:vedi,项目名称:cocos2d-x,代码行数:53,代码来源:CCSprite3D.cpp


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