Jump to content
  • Advertisement

Archived

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

MARS_999

I need help on setting up VBO's in my code

This topic is 5562 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

I have looked all over the net for a good tutorial on how to use "GL_ARB_vertex_buffer_object" as an extension and haven''t found one. I have a Radeon 9700. I would appreciate any help on find a good tutorial or some example code. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Try this:
http://www.devmaster.net/articles/oglVertexBuffer/oglVertexBuffer.php

Corrail
corrail@gmx.at
ICQ#59184081

Share this post


Link to post
Share on other sites
hm... isnt it sad when this ( http://oss.sgi.com/projects/ogl-sample/registry/ARB/vertex_buffer_object.txt ) will not just explain them a lot better but also offer about 4 times as many examples?

Share this post


Link to post
Share on other sites
Yeah, don''t bother with tutorials... just read the extension spec. You''ll get a much better feel for VBOs.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
Ok I am assuming this because it says arrays that I can use 3D arrays with VBO's.

float terrain[y][x][z];

struct Vertex
{
float x;
float y;
float z;
};

Vertex terrain[MAP_Z][MAP_X];


Can I use multi-dimension arrays with VBO's?
Will their be any performance decrease for 3D arrays? I am also assuming I can't send a array of structures?

[edited by - Mars_999 on August 7, 2003 3:58:16 PM]

Share this post


Link to post
Share on other sites
Anyone? Anyone? Here using VBO''s this way? Is it even allowed? Or does the buffer have to be a float array[]. Thanks

Share this post


Link to post
Share on other sites
Ok, I got the code up and running for VBO's. I am using vertex arrays and trying to use VBO's also and my FPS drop about 80fps!!! What gives? Don't you have to use vertex arrays first before you can use VBO's? Here is my code.


//init functino

glGenBuffersARB(1, &vertex_buffer);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, (sizeof(float) * 3) * MAP_Z * MAP_X, terrain, GL_STATIC_DRAW_ARB);

glGenBuffersARB(1, &indices_buffer);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indices_buffer);
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, (sizeof(unsigned int) * 2) * MAP_Z * MAP_X, indices, GL_STATIC_DRAW_ARB);

//draw function

glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buffer);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indices_buffer);

for(int z = 0; z < MAP_Z - 1; z++)
glDrawElements(GL_TRIANGLE_STRIP, MAP_X * 2, GL_UNSIGNED_INT, &indices[z * MAP_X * 2]);

//and of course I have deleted the buffers also



What is wrong with my code? I get a atioglxx.dll access violation error if I remember right. Do I need to setup my arrays with dynamic memory? Thanks

[edited by - Mars_999 on August 16, 2003 11:59:04 PM]

Share this post


Link to post
Share on other sites
somehow im missing a call to glvertexpointer. also i trust your indices are all below 65xxx and with deleting the buffers you mean deleting them when you close the app.

Share this post


Link to post
Share on other sites
Don''t call GenBuffers every single time you render. Do it once at initialization, and then for rendering all you have to do is bind your buffers and call DrawElements.

Share this post


Link to post
Share on other sites
quote:
Original post by Trienco
somehow im missing a call to glvertexpointer. also i trust your indices are all below 65xxx and with deleting the buffers you mean deleting them when you close the app.


Do I need to call glVertexPointer() everytime in my rendering function? I call it in my initialization function. And no my indices isn't below 65k its 132k so what am I to do about that? My vertex array isn't either.

struct Vertex
{
float x,y,z;
};
Vertex terrain[256][256] = {0};
thats 65k elements and 786k bytes right?
and
indices is
unsigned int indices[MAP_Z * MAP_X * 2];
thats 256*256*2 = 131k elements or 524k bytes right?

So my indices would have to be reduced to 65k how is that going to work? Could I make the indices like my Vertex struct using two floats such as
struct Vertex2
{
unsigned int x;
unsigned int y;
};

Vertex2 indices[256][256] = {0};

or not?

Also I get the error on this line??
glDrawElements(GL_TRIANGLE_STRIP, MAP_X * 2, GL_UNSIGNED_INT, &indices[z * MAP_X * 2]);


[edited by - Mars_999 on August 17, 2003 8:58:40 PM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!