本文整理汇总了C++中CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES函数的典型用法代码示例。如果您正苦于以下问题:C++ CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES函数的具体用法?C++ CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES怎么用?C++ CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glDrawElements
void MeshCommand::batchDraw()
{
if (_material)
{
for(const auto& pass: _material->_currentTechnique->_passes)
{
pass->bind(_m);
glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _indexCount);
pass->unbind();
}
}
else
{
_glProgramState->applyGLProgram(_m);
// set render state
applyRenderState();
// Draw
glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _indexCount);
}
}
示例2: getGLProgram
void BoneNode::onDraw(const cocos2d::Mat4 &transform, uint32_t flags)
{
getGLProgram()->use();
getGLProgram()->setUniformsForBuiltins(transform);
cocos2d::GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION | cocos2d::GL::VERTEX_ATTRIB_FLAG_COLOR);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glVertexAttribPointer(cocos2d::GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _noMVPVertices);
glVertexAttribPointer(cocos2d::GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, _squareColors);
cocos2d::GL::blendFunc(_blendFunc.src, _blendFunc.dst);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
#ifdef CC_STUDIO_ENABLED_VIEW
glVertexAttribPointer(cocos2d::GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _noMVPVertices);
glVertexAttribPointer(cocos2d::GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, _squareColors);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
glDrawArrays(GL_LINE_LOOP, 0, 4);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 8);
#else
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4);
#endif //CC_STUDIO_ENABLED_VIEW
}
示例3: glBindBuffer
void MeshCommand::execute()
{
// Draw without VAO
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);
if (_material)
{
for(const auto& pass: _material->_currentTechnique->_passes)
{
pass->bind(_mv, true);
glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _indexCount);
pass->unbind();
}
}
else
{
// set render state
_glProgramState->apply(_mv);
applyRenderState();
// Draw
glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _indexCount);
}
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
示例4: drawSolidCircle
void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY)
{
lazy_init();
const float coef = 2.0f * (float)M_PI/segments;
GLfloat *vertices = (GLfloat*)calloc( sizeof(GLfloat)*2*(segments+2), 1);
if( ! vertices )
return;
for(unsigned int i = 0;i <= segments; i++) {
float rads = i*coef;
GLfloat j = radius * cosf(rads + angle) * scaleX + center.x;
GLfloat k = radius * sinf(rads + angle) * scaleY + center.y;
vertices[i*2] = j;
vertices[i*2+1] = k;
}
vertices[(segments+1)*2] = center.x;
vertices[(segments+1)*2+1] = center.y;
s_shader->use();
s_shader->setUniformsForBuiltins();
s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1);
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) segments+1);
::free( vertices );
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+1);
}
示例5: glBindBuffer
void NavMeshDebugDraw::drawImplement(const cocos2d::Mat4& transform, uint32_t flags)
{
_program->use();
_program->setUniformsForBuiltins(transform);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4F), (GLvoid *)offsetof(V3F_C4F, position));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(V3F_C4F), (GLvoid *)offsetof(V3F_C4F, color));
if (_dirtyBuffer){
glBufferData(GL_ARRAY_BUFFER, sizeof(V3F_C4F)* _vertices.size(), &_vertices[0], GL_STATIC_DRAW);
_dirtyBuffer = false;
}
for (auto &iter : _primitiveList){
_stateBlock->setDepthWrite(iter->depthMask);
if (iter->type == GL_POINTS){
//glPointSize(iter->size);
}
else if (iter->type == GL_LINES){
glLineWidth(iter->size);
}
_stateBlock->bind();
glDrawArrays(iter->type, iter->start, iter->end - iter->start);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, iter->end - iter->start);
}
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
示例6: getGLProgramState
/**
* Draw a primitive.
*
* @param transform Transform matrix
* @param flags Flags to draw
*/
void ShaderTextureNode::onDraw(const Mat4 &transform, uint32_t flags)
{
GLfloat vertices[48] = {
-1, -1, 0, 1, 1, 1, 1, 1, // Lower-Left
1, -1, 1, 1, 1, 1, 1, 1, // Lower-Right
1, 1, 1, 0, 1, 1, 1, 1, // Upper-Right
-1, -1, 0, 1, 1, 1, 1, 1, // Lower-Left
1, 1, 1, 0, 1, 1, 1, 1, // Upper-Right
-1, 1, 0, 0, 1, 1, 1, 1, // Upper-Left
};
auto glProgramState = getGLProgramState();
glProgramState->setVertexAttribPointer("a_position", 2, GL_FLOAT, GL_FALSE, 32, vertices);
glProgramState->setVertexAttribPointer("a_texCoord", 2, GL_FLOAT, GL_FALSE, 32, vertices + 2);
glProgramState->setVertexAttribPointer("a_color", 4, GL_FLOAT, GL_FALSE, 32, vertices + 4);
glProgramState->apply(transform);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glDisable(GL_DEPTH_TEST);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
// Alpha blending
// glEnable(GL_BLEND);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_TRIANGLES, 0, 6);
// glDisable(GL_BLEND);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 6);
}
示例7: glBindBuffer
void MGRDrawNode::onDrawGLPoint(const Mat4 &transform, uint32_t flags)
{
auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_COLOR_TEXASPOINTSIZE);
glProgram->use();
glProgram->setUniformsForBuiltins(transform);
GL::blendFunc(_blendFunc.src, _blendFunc.dst);
if (_dirtyGLPoint)
{
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW);
_dirtyGLPoint = false;
}
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
// vertex
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offsetof(V2F_C4B_T2F, vertices));
// color
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offsetof(V2F_C4B_T2F, colors));
// texcoord
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offsetof(V2F_C4B_T2F, texCoords));
glDrawArrays(GL_POINTS, 0, _bufferCountGLPoint);
glBindBuffer(GL_ARRAY_BUFFER, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _bufferCountGLPoint);
CHECK_GL_ERROR_DEBUG();
}
示例8: 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);
}
示例9: glGetUniformLocation
void DrawTextureScene::onDraw(){
Director::getInstance()->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
Director::getInstance()->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
Director::getInstance()->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
Director::getInstance()->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
auto glProgram=getGLProgram();
glProgram->use();
//更新CC_MVPMatrix
glProgram->setUniformsForBuiltins();
GLuint textureLocation = glGetUniformLocation(glProgram->getProgram(), "CC_Texture0");
// Set our sampler to user Texture Unit 0
glUniform1i(textureLocation, 0);
// GLuint uColorLocation = glGetUniformLocation(glProgram->getProgram(), "u_color");
// GLfloat uColor[]={1.0,1.0,1.0,1.0};
// glUniform4fv(uColorLocation, 1, uColor);
glBindVertexArray(vao);
//在调用draw call之前,我们需要绑定纹理
GL::bindTexture2D(textureID);//activeTexture(GL_TEXTURE0); //glBindTexture(GL_TEXTURE_2D, textureID);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, (GLvoid*)0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 6);
CHECK_GL_ERROR_DEBUG();
Director::getInstance()->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
Director::getInstance()->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
}
示例10: CHECK_GL_ERROR_DEBUG
void RawStencilBufferTest::onBeforeDrawSprite(int planeIndex, const Vec2& pt)
{
this->setupStencilForDrawingOnPlane(planeIndex);
CHECK_GL_ERROR_DEBUG();
Vec2 vertices[] = {
Vec2::ZERO,
Vec2(pt.x, 0),
pt,
Vec2(0, pt.y)
};
auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR);
int colorLocation = glProgram->getUniformLocation("u_color");
CHECK_GL_ERROR_DEBUG();
Color4F color = _planeColor[planeIndex];
glProgram->use();
glProgram->setUniformsForBuiltins();
glProgram->setUniformLocationWith4fv(colorLocation, (GLfloat*) &color.r, 1);
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4);
}
示例11: getShaderProgram
void ShaderSprite::onDraw(const kmMat4 &transform, bool transformUpdated)
{
auto shader = getShaderProgram();
shader->use();
shader->setUniformsForBuiltins(transform);
setCustomUniforms();
GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
GL::blendFunc(_blendFunc.src, _blendFunc.dst);
GL::bindTexture2D( getTexture()->getName());
//
// Attributes
//
#define kQuadSize sizeof(_quad.bl)
size_t offset = (size_t)&_quad;
// vertex
int diff = offsetof( V3F_C4B_T2F, vertices);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));
// texCoods
diff = offsetof( V3F_C4B_T2F, texCoords);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));
// color
diff = offsetof( V3F_C4B_T2F, colors);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 4);
}
示例12: 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);
}
示例13: 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);
}
示例14: 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(GLProgram::VERTEX_ATTRIB_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_DRAWN_BATCHES_AND_VERTICES(2,vertexCount*2);
CHECK_GL_ERROR_DEBUG();
delete[] vertices;
}
示例15: 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(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices);
glDrawArrays(GL_LINE_LOOP, 0, vertexCount);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,vertexCount);
CHECK_GL_ERROR_DEBUG();
delete[] glVertices;
}