本文整理汇总了C++中ccGLEnableVertexAttribs函数的典型用法代码示例。如果您正苦于以下问题:C++ ccGLEnableVertexAttribs函数的具体用法?C++ ccGLEnableVertexAttribs怎么用?C++ ccGLEnableVertexAttribs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ccGLEnableVertexAttribs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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 );
}
示例3: ccGLEnableVertexAttribs
void B2DLayer::draw(){
CCLayer::draw();
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
kmGLPushMatrix();
world->DrawDebugData();
kmGLPopMatrix();
}
示例4: 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);
}
示例5: ccDrawQuadBezier
void ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, const CCPoint& destination, unsigned int segments)
{
lazy_init();
ccVertex2F* vertices = new ccVertex2F[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_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);
}
示例6: 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);
}
示例7: CC_NODE_DRAW_SETUP
void CCControlSwitchSprite::draw()
{
CC_NODE_DRAW_SETUP();
ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex);
ccGLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
getShaderProgram()->setUniformForModelViewProjectionMatrix();
glActiveTexture(GL_TEXTURE0);
glBindTexture( GL_TEXTURE_2D, getTexture()->getName());
glUniform1i(m_uTextureLocation, 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture( GL_TEXTURE_2D, m_pMaskTexture->getName() );
glUniform1i(m_uMaskLocation, 1);
#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);
glActiveTexture(GL_TEXTURE0);
}
示例8: ccDrawPoints
void ccDrawPoints( const CCPoint *points, unsigned int numberOfPoints )
{
lazy_init();
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
shader_->use();
shader_->setUniformForModelViewProjectionMatrix();
shader_->setUniformLocationWith4fv(colorLocation_, (GLfloat*) &color_.r, 1);
shader_->setUniformLocationWith1f(pointSizeLocation_, pointSize_);
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
ccVertex2F* newPoints = new ccVertex2F[numberOfPoints];
// iPhone and 32-bit machines optimization
if( sizeof(CCPoint) == sizeof(ccVertex2F) )
{
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, points);
}
else
{
// Mac on 64-bit
for( unsigned int i=0; i<numberOfPoints;i++) {
newPoints[i].x = points[i].x;
newPoints[i].y = points[i].y;
}
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoints);
}
glDrawArrays(GL_POINTS, 0, (GLsizei) numberOfPoints);
CC_SAFE_DELETE_ARRAY(newPoints);
CC_INCREMENT_GL_DRAWS(1);
}
示例9: ccDrawPoint
void ccDrawPoint( const CCPoint& point )
{
lazy_init();
ccVertex2F p;
p.x = point.x;
p.y = point.y;
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
s_pShader->use();
s_pShader->setUniformsForBuiltins();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
s_pShader->setUniformLocationWith1f(s_nPointSizeLocation, s_fPointSize);
#ifdef EMSCRIPTEN
setGLBufferData(&p, 8);
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, &p);
#endif // EMSCRIPTEN
glDrawArrays(GL_POINTS, 0, 1);
CC_INCREMENT_GL_DRAWS(1);
}
示例10: 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 );
#ifdef EMSCRIPTEN
setGLBufferData(vertices, (segments + 1) * sizeof(ccVertex2F));
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(kCCVertexAttrib_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);
}
示例11: ccGLEnableVertexAttribs
void BloodFlashSprite::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);
}
示例12: ccGLEnableVertexAttribs
void SpriteBlur::draw()
{
ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex );
ccGLBlendFunc( m_sBlendFunc.src, m_sBlendFunc.dst );
getShaderProgram()->use();
getShaderProgram()->setUniformForModelViewProjectionMatrix();
getShaderProgram()->setUniformLocationWith2f(blurLocation, blur_.x, blur_.y);
getShaderProgram()->setUniformLocationWith4fv(subLocation, sub_, 1);
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);
}
示例13: 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);
}
示例14: 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);
}
示例15: 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);
}