question regarding vertex buffer

Started by dezcont, December 25, 2011, 05:33:20

Previous topic - Next topic

dezcont

I am currently working on learning OpenGL through an online book
and I have come a cross this snippet of code that they use:
"void InitializeVertexBuffer()
{
   glGenBuffers(1, &positionBufferObject);
   
   glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject);
   glBufferData(GL_ARRAY_BUFFER, sizeof(vertexPositions), vertexPositions, GL_STATIC_DRAW);
   glBindBuffer(GL_ARRAY_BUFFER, 0);
}"
I proceed to try and replicate this snippet in lwjgl, at which point some of the
gl commands do not match up. I have consulted the posted tutorials
on the wiki site, which confused me even more....could someone help explain to me
how some of the vertex buffer API works for lwjgl? o.O

EDIT: I had realized this morning that I forgot some information. The vertices of the
object I want to draw is predefined in an array(which I named vertexPositions), so how
exactly would I replicate the above quoted code?

delt0r

Anything that takes a C array or pointer takes a *direct* buffer in lwjgl. Since the buffer has a type as well, some calls can drop the f/d/i suffix from the gl call conventions. There is the added convention that a single int or number is not passed via a buffer.

So glGenBuffers(int number,int* results) is  glGenBuffers(int, IntegerBuffer buffer); in  java. note that lwjgl honors limits etc so rewind the buffers. And glBindBuffer(GL_ARRAY_BUFFER,int) is the java...

Also you need to consider what version of opengl you are (static) importing. If you have only imported 1.1 then VBO are not in it... But just importing 2.1 doesn't  import everything below 2.1 (IIRC these buffer objects are in about 1.5 or something).
If you want a plot read a book and leave Hollywood out of it.

dezcont

Thank you so much good sir/ma'am ^^