Hi,
i have a problem. I cant pack Indices into buffer …
This is data to draw:
NumVertices = 3;
NumIndices = 3;
Vertices = new SVertex[NumVertices];
Colors = new SColor[NumVertices];
Indices = new GLuint[NumIndices];
Vertices[0].x = 0;
Vertices[0].y = 0;
Vertices[0].z = 0;
Vertices[1].x = 1;
Vertices[1].y = 0;
Vertices[1].z = 0;
Vertices[2].x = 1;
Vertices[2].y = 1;
Vertices[2].z = 0;
Colors[0].r = 1;
Colors[0].g = 0;
Colors[0].b = 0;
Colors[1].r = 1;
Colors[1].g = 0;
Colors[1].b = 0;
Colors[2].r = 1;
Colors[2].g = 0;
Colors[2].b = 0;
Indices[0]=0;
Indices[1]=1;
Indices[2]=2;
This is drawing function:
Ok, i forgot about that. So now mu drawing function looks like this:
glGenBuffersARB( 1, &Colr );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, Colr );
glBufferDataARB( GL_ARRAY_BUFFER_ARB, NumVertices*sizeof(SColor), Colors, GL_STATIC_DRAW_ARB );
glColorPointer(3,GL_FLOAT,0,0);
glGenBuffersARB( 1, &VertV );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, VertV );
glBufferDataARB( GL_ARRAY_BUFFER_ARB, NumVertices*sizeof(Svertex), Vertices, GL_STATIC_DRAW_ARB );
glVertexPointer(3,GL_FLOAT,0,0);
glGenBuffersARB( 1, &Indict );
glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, Indict );
glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, NumIndices*sizeof(GLuint), Indices, GL_STATIC_DRAW_ARB );
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawElements( GL_TRIANGLES,3,GL_UNSIGNED_INT, 0); //if I give here "Indices" it works but not drawing everything
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBufferARB( GL_ARRAY_BUFFER_ARB,0);
glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB,0);
EDIT - updated to actual version