When I'm trying to draw a triangle by using VBO + indices it's not working
vertices.push_back(0.5f);
vertices.push_back(-0.5f);
vertices.push_back(-2.0f);
vertices.push_back(-0.5f);
vertices.push_back(-0.5f);
vertices.push_back(-2.0f);
vertices.push_back(0.5f);
vertices.push_back(-0.5f);
vertices.push_back(-2.0f);
indices.push_back(0);
indices.push_back(1);
indices.push_back(2);
GLuint bufferID,bufferID2;
glGenBuffers(1,&bufferID);
glGenBuffers(1,&bufferID2);
glBindBuffer(GL_ARRAY_BUFFER,bufferID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,bufferID2);
glBufferData(GL_ARRAY_BUFFER,sizeof(GLfloat)*3,&vertices[0],GL_STATIC_DRAW);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,0,0);
glDrawElements(GL_TRIANGLES,indices.size(),GL_UNSIGNED_INT,&indices[0]);
glDisableClientState(GL_VERTEX_ARRAY);
glDeleteBuffers(1,&bufferID);
glDeleteBuffers(1,&bufferID2);
but drawing a point with VBO it's working
vertices.push_back(0.5f);
vertices.push_back(-0.5f);
vertices.push_back(-2.0f);
GLuint bufferID;
glGenBuffers(1,&bufferID);
glBindBuffer(GL_ARRAY_BUFFER,bufferID);
glBufferData(GL_ARRAY_BUFFER,sizeof(GLfloat)*3,&vertices[0],GL_STATIC_DRAW);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,0,0);
glPointSize(100.0f);
glDrawArrays(GL_POINTS,0,1);
glDisableClientState(GL_VERTEX_ARRAY);
glDeleteBuffers(1,&bufferID);
I already read through some tutorials and other posts, but nothing works. mby I'm not using the indices correctly ?
anyone can help me with this problem?