Problem in vertex_buffer_object

Please reply to this

hi,

i am by allot of hard work come at a point that now i draw a point without Begin/End and Vertex2f :smiley:
but i have some Question regarding to the following code:

I Declared


GLuint Vertex;
GLfloat TriVert[] = {0.0f,0.5f,
0.0f,0.0f,
-0.5f,0.0f};

What i call for Display
Thsee are inside Push/Pop Matrix and MatrixMode with LoadIdentity


glVertexPointer(2,GL_FLOAT,0,0);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,Vertex);

glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_READ_WRITE_ARB);

glEnableClientState(GL_VERTEX_ARRAY);
glColor3f(1.0f,1.0f,1.0f);
glDrawElements(GL_POINTS,1,GL_UNSIGNED_SHORT,&TriVert[0]);
glDrawElements(GL_POINTS,1,GL_UNSIGNED_SHORT,&TriVert[2]);
glDrawElements(GL_POINTS,1,GL_UNSIGNED_SHORT,&TriVert[4]);
glDisableClientState(GL_VERTEX_ARRAY);


Here a GLEW help Me


if(GLEW_ARB_vertex_buffer_object)
{
printf("Let's try some VBO and job on the almost AGP/VGA i915
");

glGenBuffersARB(1,&Vertex);

glBindBufferARB(GL_ARRAY_BUFFER_ARB,Vertex);

glBufferDataARB(GL_ARRAY_BUFFER_ARB,sizeof(TriVert),0,GL_STREAM_DRAW_ARB);

glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(TriVert), TriVert);

glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &bufferSize);
        fprintf(stdout,"Vertex size %i bytes
",bufferSize);


}


My Question are

Q1.Is The job i do is in My VGA/AGP(anything that is) Memory
:confused:
Q2.As for getting result i try POINTS instead of TRIANGLES but i got only one point in my screen at (0.0,0.5)
while there are 3 DrawElement Functions are Called
so what ido for 2 more so there is a triangle job
:mad:

Please reply this and

Thanks for just reading my Topic post and also thanks for just thinking on My Questions

Thanks in advance

Problem solved but with Question

Hey any one who read this

i resolved my problem by just one hit of glDrawArrays in place of glDrawElements which just need GLfloat Array’s starting an ending position [0] and [end]

and it draw the triangle for me
but there still some :confused:

Q1.Is the triangle goes in AGP/VGA Memory or it is a
done in just a way Vertexf do

Q2. Primitive drawn by that single hit command is ye good but
what id that glDrawElement can it used

please reply
and thanks for just reading and thinking on it

thanks in advance
:cool: vivek :cool:

Your questions are getting lost in the language barrier.

There are some issues in your code. First, you should bind your VBO buffer before you latch it with a “gl*Pointer” call. Second, you should put “all” of your vertex data in vertex attribute arrays (either client side OR server side, don’t mix as that leads to bad performance).

I’d suggest you take one smaller step. Don’t use server arrays (aka VBOs) for a minute. Just use client arrays (i.e. comment out all the buffer stuff). That is, do this if you just need vertex positions and colors:

glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
glVertexPointer( size, type, stride, cpu_pointer );
glColorPointer( size, type, stride, cpu_pointer );
glDrawArrays( … )
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );

Get comfy with that. Then, switch to tfDrawElements(). For the indices argument, pass in a pointer to an array that contains 0,1,2. For one triangle its overkill, but for big meshes it can save the GPU a lot of work!

Now switch your two vertex attribute arrays from client arrays to server arrays (aka VBOs) but putting them both and the index list in buffer objects. Start with putting them each in their own VBO. Get that working. Then realize you can put both vertex attribute arrays in one VBO, interleaving the values. Consider trying that as well.