LWJGL
June 20, 2013, 04:39:36 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL is now using GitHub
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: question regarding vertex buffer  (Read 769 times)
dezcont
Newbie
*
Posts: 2


« on: December 24, 2011, 21: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?
Logged
delt0r
Newbie
*
Posts: 40



« Reply #1 on: December 28, 2011, 05: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).
Logged

If you want a plot read a book and leave Hollywood out of it.
dezcont
Newbie
*
Posts: 2


« Reply #2 on: December 29, 2011, 20:50:24 »

Thank you so much good sir/ma'am ^^
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!