Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

akn81

GL_ARB_vertex_buffer_object

This topic is 5542 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, is anyone familiar with how to use this extension? I''ve heard that it has replaced VAR, but I don''t understand how to use it. I''m working on a 3d space sim, and was thinking for situations where many identical ships are onscreen perhaps it might be better to upload a single mesh to the video card, then call glTranslatef() for each ship before rendering the mesh. Is that a good idea?

Share this post


Link to post
Share on other sites
Advertisement
Generate a buffer:


  
glGenBuffersARB(1, &m_BufferObject);


Bind the buffer and initilialize it with your geometry data:


  
glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_BufferObject);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, memorysize, m_Memory, GL_STATIC_DRAW_ARB);


Or GL_DYNAMIC_DRAW_ARB for a dynamic array.

And for drawing bind your buffer again:


  
glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_BufferObject);


Tell OpenGL what data you''ve got:


  
glVertexPointer(3, GL_FLOAT, m_StructureSize, BUFFER_OFFSET(0));
glEnableClientState(GL_VERTEX_ARRAY);


BUFFER_OFFSET is something like this:


  
#define BUFFER_OFFSET(i) ((char *)NULL + (i))


And then draw like this:

  
glDrawElements(mode, count, GL_UNSIGNED_SHORT, indices);

Share this post


Link to post
Share on other sites
Thanks for giving me the steps, but what is m_BufferObject and m_Memory? I''m sorry I couldn''t find any examples using vertex_buffer_object on Nvidia''s page, at best I got the specification from oss.sgi.com, but I just want a practical example, lets say to draw a cube. Can you help me out with that please?

Share this post


Link to post
Share on other sites
at the end of extension documentation there are a bunch of examples how to use ARB_VBO with different settings (static/dynamic,....)

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
Sorry, here are my variables:


    
GLuint m_BufferObject; // holds the buffer

int memorysize; // total size of vertex memory

char *m_Memory; // pointer to the vertex memory

// (need only a pointer, char not necessary)

int m_StructureSize; // size in bytes of one vertex in memory



And in the call to glDrawElements():


mode = GL_TRIANGLES, GL_TRIANGLE_STRIPS or whatsoever
count = number of vertices
indices = pointer to the index array


[edited by - The_Fallen on April 21, 2003 2:54:33 PM]

Share this post


Link to post
Share on other sites
Thank you! I''ll go and test it out now, if I run into problems I''ll let you know

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!