// Allocate memory
vec *data;
data = new vec[4];
// Fill data
data[0].x = 0; data[0].y = 0; data[0].z = 0;
data[1].x = 6; data[1].y = 0; data[1].z = 0;
data[2].x = 6; data[2].y = 6; data[2].z = 0;
data[3].x = 0; data[3].y = 6; data[3].z = 0;
// Create buffer object
glBindBufferARB( GL_ARRAY_BUFFER_ARB, 1 );
// Initialize data store of buffer object
glBufferDataARB( GL_ARRAY_BUFFER_ARB, 4, data, GL_STATIC_DRAW_ARB);
// free data
delete data;
// Define arrays
glBindBufferARB( GL_ARRAY_BUFFER_ARB, 1);
glVertexPointer( 3, GL_FLOAT, 0, BUFFER_OFFSET(0) );
// Enable arrays
glEnableClientState(GL_VERTEX_ARRAY);
// Draw arrays
glDrawArrays( GL_QUADS, 0, 4 );
// Disable arrays
glDisableClientState( GL_VERTEX_ARRAY );
// Delete buffer object
GLuint buffer[1] = {1};
glDeleteBuffersARB( 1, buffer );
Thanks!!!
Getting started with VBO
I''m having some trouble with implanting the VBO extension. Here is a little code snippet, which shows how I render a quad. But the problem is that nothing appears on the screen. So I must have done something wrong ;-) !! BUt because of the fact that these extensions are too well documented I cannot
find out what the problem is....
i have no idea of VBO yet but is there something like
glGenBuffer
textures and OpenAL use this as well
glGenBuffer
textures and OpenAL use this as well
I think ur size parameter is incorrect (according to the spec it should be in basic machine units (bytes))
If you still have more problems take a look at the vbo example at
http://www.delphi3d.net/
It''s in Delphi but it''s really straight forward. Also if all else fails, try commenting out the vbo stuff (so ur just using normal vertex array) just to see if it''s not anything else. hope it helps.
If you still have more problems take a look at the vbo example at
http://www.delphi3d.net/
It''s in Delphi but it''s really straight forward. Also if all else fails, try commenting out the vbo stuff (so ur just using normal vertex array) just to see if it''s not anything else. hope it helps.
Yeah, the size should be in bytes, not the number of elements in the array that you specify ( you are actually specifying a pointer to the start of the memory that you want to be copied, and the size of that memory ). So put 48 in there ( assuming you're using floats in your vec structure ).
[edit: can't add up]
Death of one is a tragedy, death of a million is just a statistic.
[edited by - python_regious on June 17, 2003 6:26:58 PM]
[edit: can't add up]
Death of one is a tragedy, death of a million is just a statistic.
[edited by - python_regious on June 17, 2003 6:26:58 PM]
Could it be the fact that your Z values are 0? Is the polygon getting clipped by the near plane?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement