Hello Guest

VBO question

  • 10 Replies
  • 11446 Views
VBO question
« on: July 10, 2006, 20:17:08 »
Hi everbody,

My OpenGL knowledge is limited. Anyways, I would like to use dynamic VBO.
Consulting gamedev forum and this one, I understand it is recomanded to create two VBO :
- The first one with vertex, normals, textures coords, like pricec suggested in the thread http://lwjgl.org/forum/viewtopic.php?t=757&highlight=vbo  :
Quote

Niels, what you should be doing is packing vertex data thus:

x,y,z,nx,ny,nz,tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3

You write all the data but once, linearly, from start to finish, every frame, optionally skipping data that has not changed.


- The second contains index.


My questions are :

1. How can I implement the first VBO, I mean in opengl : should I use glBufferSubDataARB ? like it is shown in http://www.spec.org/gpc/opc.static/vbo_whitepaper.html

2. I think the second VBO can help me to solve my first question, but I don't know how. (due probably to my lack of knowledge).

3. As dynamic VBO, the first one change every time, I think I have to create and bind a new vbo every time, is it exact ?

Thanks in advance.

VBO question
« Reply #1 on: July 13, 2006, 12:59:26 »
Some usefull links to help me to deal with my questions ?

VBO question
« Reply #2 on: July 17, 2006, 03:01:34 »
igg -- Take me off for great justice?

*

Offline ndhb

  • **
  • 70
Tutorials
« Reply #3 on: July 17, 2006, 21:29:55 »
Hi Kokoni. I'm new to VBO's myself.

I followed the steps in the wiki and it worked for me:

http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/opengl/basicvbo

It doesn't go into the details, but it will get you started.

Yes, you need to bind the buffers every time you render (you probably dont want to / shouldn't create a new VBO every frame though). Don't worry about the binding state change it's very cheap (the "work" is in done glXXXPointers which you cant avoid).
« Last Edit: February 10, 2015, 23:45:16 by ndhb »

VBO question
« Reply #4 on: July 20, 2006, 11:30:10 »
Thanks all for yours answers.  I'm going to try to learn more about VBO throught the links you have provided me.

VBO question
« Reply #5 on: July 23, 2006, 00:24:47 »
Here you go: http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/opengl/speedyvbo

Wrote a nice tutorial for you. Let me know if its helpful or not...

DP

VBO question
« Reply #6 on: July 23, 2006, 07:49:56 »
Darkprophet,

You are great ! You have full answered my first question and also create a good tutorial for everybody.

I have a doubt, I often read we need a second vbo which contains index. With your way to implement/rendre the interleaved vbo, what is the aim of such "index vbo" ? to speed up  :?:

VBO question
« Reply #7 on: July 23, 2006, 10:20:26 »
You do need a second VBO that contains the indices whether the other mesh components have been interleaved or not. This is because indices are special and when buffering, you must use GL_ELEMENT_ARRAY_BUFFER_ARB instead of GL_ARRAY_BUFFER_ARB.

As for the 3rd question, if the entire buffer changes, use glBufferDataARB, if only a certain known portion of the VBO changes, then use glMapDataARB. But there is no need to create a VBO every frame, but you do need to bind it everyframe.

DP

Re: VBO question
« Reply #8 on: May 07, 2007, 20:59:42 »
I'm back from a long period without programming my 3D Java engine  ;)

I'm trying to set up the interleaved VBO from your tutorial, here is my render() method :
   public void render() {
      
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
        GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
       
      ARBVertexBufferObject.glBindBufferARB( ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, iVBOID );
      setupGLPointer();

      GL12.glDrawRangeElements(GL11.GL_TRIANGLES, 0, maxIndex, indexBufferSize,GL11.GL_UNSIGNED_INT, 0);
   }


Of course I assume I populated the buffer with this code :
ARBVertexBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, data, ARBVertexBufferObject.GL_STATIC_READ_ARB);

My question is : does it make sense ? Do I have to setup the GL pointers (like discribded in the speedy vbo tutorial) at every render step ?

All comments are of course welcomed (my return is hard!) Thanks in advance,
Kokoni.

*

Offline ndhb

  • **
  • 70
Re: VBO question
« Reply #9 on: May 15, 2007, 08:22:55 »

Re: VBO question
« Reply #10 on: June 06, 2007, 08:37:02 »
note that if you can render without providing indices using glDrawArrays(). In that case you only need a single VBO containing the vertex data. I'm not quite sure if this is faster or slower than providing indices. It doesn't allow to share vertices tough (vertices used by multiple triangles).

greets,
phil