LWJGL Forum

Programming => OpenGL => Topic started by: dezcont on December 25, 2011, 05:33:20

Title: question regarding vertex buffer
Post by: dezcont on December 25, 2011, 05:33:20
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?
Title: Re: question regarding vertex buffer
Post by: delt0r on December 28, 2011, 13:45:43
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).
Title: Re: question regarding vertex buffer
Post by: dezcont on December 30, 2011, 04:50:24
Thank you so much good sir/ma'am ^^