本文整理汇总了C++中setGLBufferData函数的典型用法代码示例。如果您正苦于以下问题:C++ setGLBufferData函数的具体用法?C++ setGLBufferData怎么用?C++ setGLBufferData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setGLBufferData函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: getShaderProgram
void MotionStreak::onDraw(const kmMat4 &transform, bool transformUpdated)
{
getShaderProgram()->use();
getShaderProgram()->setUniformsForBuiltins(transform);
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_DRAWN_BATCHES_AND_VERTICES(1, _nuPoints*2);
}
示例3: getShaderProgram
void LayerColor::onDraw(const kmMat4& transform, bool transformUpdated)
{
getShaderProgram()->use();
getShaderProgram()->setUniformsForBuiltins(transform);
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR );
//
// Attributes
//
#ifdef EMSCRIPTEN
setGLBufferData(_noMVPVertices, 4 * sizeof(Vertex3F), 0);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _noMVPVertices);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, _squareColors);
#endif // EMSCRIPTEN
GL::blendFunc( _blendFunc.src, _blendFunc.dst );
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,4);
}
示例4: CC_NODE_DRAW_SETUP
void LightLayer::draw()
{
CC_NODE_DRAW_SETUP();
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR);
glUniform3f(_spotLocation, _spotPoint.x, _spotPoint.y, 0);
glUniform4f(_innerColor, 0, 0, 0, 0);
glUniform1f(_spotInnerRadius, 50);
glUniform1f(_spotOuterRadius, 220);
//
// Attributes
//
#ifdef EMSCRIPTEN
setGLBufferData(_squareVertices, 4 * sizeof(Vertex2F), 0);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _squareVertices);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, _squareColors);
#endif // EMSCRIPTEN
GL::blendFunc(_blendFunc.src, _blendFunc.dst);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
CC_INCREMENT_GL_DRAWS(1);
}
示例5: 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);
}
示例6: 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);
}
示例7: ccDrawPoly
void ccDrawPoly( const CCPoint *poli, unsigned int numberOfPoints, bool closePolygon )
{
lazy_init();
s_pShader->use();
s_pShader->setUniformsForBuiltins();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
glLineWidth(1);
// iPhone and 32-bit machines optimization
if( sizeof(CCPoint) == sizeof(ccVertex2F) )
{
#ifdef EMSCRIPTEN
setGLBufferData((void*) poli, numberOfPoints * sizeof(CCPoint));
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli);
#endif // EMSCRIPTEN
if( closePolygon )
glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) numberOfPoints);
else
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) numberOfPoints);
}
else
{
// Mac on 64-bit
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
ccVertex2F* newPoli = new ccVertex2F[numberOfPoints];
for( unsigned int i=0; i<numberOfPoints;i++) {
newPoli[i].x = poli[i].x;
newPoli[i].y = poli[i].y;
}
#ifdef EMSCRIPTEN
setGLBufferData(newPoli, numberOfPoints * sizeof(ccVertex2F));
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
#endif // EMSCRIPTEN
if( closePolygon )
glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) numberOfPoints);
else
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) numberOfPoints);
CC_SAFE_DELETE_ARRAY(newPoli);
}
CC_INCREMENT_GL_DRAWS(1);
}
示例8: drawPoly
void drawPoly(const Vec2 *poli, unsigned int numberOfPoints, bool closePolygon)
{
lazy_init();
s_shader->use();
s_shader->setUniformsForBuiltins();
s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1);
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
// iPhone and 32-bit machines optimization
if( sizeof(Vec2) == sizeof(Vec2) )
{
#ifdef EMSCRIPTEN
setGLBufferData((void*) poli, numberOfPoints * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli);
#endif // EMSCRIPTEN
if( closePolygon )
glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) numberOfPoints);
else
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) numberOfPoints);
}
else
{
// Mac on 64-bit
// FIXME: Mac OpenGL error. arrays can't go out of scope before draw is executed
Vec2* newPoli = new (std::nothrow) Vec2[numberOfPoints];
for( unsigned int i=0; i<numberOfPoints;i++) {
newPoli[i].x = poli[i].x;
newPoli[i].y = poli[i].y;
}
#ifdef EMSCRIPTEN
setGLBufferData(newPoli, numberOfPoints * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
#endif // EMSCRIPTEN
if( closePolygon )
glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) numberOfPoints);
else
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) numberOfPoints);
CC_SAFE_DELETE_ARRAY(newPoli);
}
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints);
}
示例9: drawPoint
void drawPoint(const Vec2& point)
{
lazy_init();
Vec2 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_DRAWN_BATCHES_AND_VERTICES(1,1);
}
示例10: 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);
}
示例11: 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);
}
示例12: drawCubicBezier
void drawCubicBezier(const Vec2& origin, const Vec2& control1, const Vec2& control2, const Vec2& destination, unsigned int segments)
{
lazy_init();
Vec2* vertices = new (std::nothrow) Vec2[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_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(Vec2));
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_DRAWN_BATCHES_AND_VERTICES(1,segments+1);
}
示例13: drawPoints
void drawPoints( const Vec2 *points, unsigned int numberOfPoints )
{
lazy_init();
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);
// FIXME: Mac OpenGL error. arrays can't go out of scope before draw is executed
Vec2* newPoints = new (std::nothrow) Vec2[numberOfPoints];
// iPhone and 32-bit machines optimization
if( sizeof(Vec2) == sizeof(Vec2) )
{
#ifdef EMSCRIPTEN
setGLBufferData((void*) points, numberOfPoints * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, points);
#endif // EMSCRIPTEN
}
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;
}
#ifdef EMSCRIPTEN
// Suspect Emscripten won't be emitting 64-bit code for a while yet,
// but want to make sure this continues to work even if they do.
setGLBufferData(newPoints, numberOfPoints * sizeof(Vec2));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoints);
#endif // EMSCRIPTEN
}
glDrawArrays(GL_POINTS, 0, (GLsizei) numberOfPoints);
CC_SAFE_DELETE_ARRAY(newPoints);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints);
}
示例14: ccDrawPoints
void ccDrawPoints( const CCPoint *points, unsigned int numberOfPoints )
{
lazy_init();
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);
// 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) )
{
#ifdef EMSCRIPTEN
setGLBufferData((void*) points, numberOfPoints * sizeof(CCPoint));
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, points);
#endif // EMSCRIPTEN
}
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;
}
#ifdef EMSCRIPTEN
// Suspect Emscripten won't be emitting 64-bit code for a while yet,
// but want to make sure this continues to work even if they do.
setGLBufferData(newPoints, numberOfPoints * sizeof(ccVertex2F));
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoints);
#endif // EMSCRIPTEN
}
glDrawArrays(GL_POINTS, 0, (GLsizei) numberOfPoints);
CC_SAFE_DELETE_ARRAY(newPoints);
CC_INCREMENT_GL_DRAWS(1);
}
示例15: drawSolidPoly
void drawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color )
{
lazy_init();
s_shader->use();
s_shader->setUniformsForBuiltins();
s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &color.r, 1);
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
Vertex2F* newPoli = new Vertex2F[numberOfPoints];
// iPhone and 32-bit machines optimization
if( sizeof(Point) == sizeof(Vertex2F) )
{
#ifdef EMSCRIPTEN
setGLBufferData((void*) poli, numberOfPoints * sizeof(Point));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli);
#endif // EMSCRIPTEN
}
else
{
// Mac on 64-bit
for( unsigned int i=0; i<numberOfPoints;i++)
{
newPoli[i] = Vertex2F( poli[i].x, poli[i].y );
}
#ifdef EMSCRIPTEN
setGLBufferData(newPoli, numberOfPoints * 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, newPoli);
#endif // EMSCRIPTEN
}
glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) numberOfPoints);
CC_SAFE_DELETE_ARRAY(newPoli);
CC_INCREMENT_GL_DRAWS(1);
}