PDA

View Full Version : tricks for drawing portions of a grid?



gmeed
08-29-2004, 01:12 PM
I have a large grid, stored in a vbo, that I'm using for terrain data. I don't simply draw the whole thing - I need to draw just a few rectangular areas of it at a time. These areas move every frame, and I'm wondering if there's a better way to handle this than just resending every index I want to draw when these areas move. (Other than doing texture lookups in the vertex shader.)

The best thing I can come up with is to get the indices for an area of the grid into a vbo on the gpu, then move the selection area around (ie - sliding a window) by using glVertexPointer on the vbo that holds the geometry. I'm always hearing about how slow glVertexPointer is, but for this case shouldn't it be pretty fast as long as I don't modify the geometry vbo. Will most recent cards/drivers be able to implement this use of glVertexPointer without shuffling any data around, or anything else slow?

08-29-2004, 04:14 PM
you could just update the indices in the sub-region of interest. leave the vertices alone, just move a "sub-index window" over the area.

gmeed
08-29-2004, 04:52 PM
Originally posted by <bonehead>:
you could just update the indices in the sub-region of interest. leave the vertices alone, just move a "sub-index window" over the area.Right, that's what I'm doing now. It just seems like a waste to have to respecify all the indices in the window, when it would suffice to just add an offset to each one. I just don't know if OpenGL has the machinery to specify an offset like that, short of using the slow glVertexPointer on the geometry vbo.

08-29-2004, 05:11 PM
there was a discussion along these lines in the advanced forum. an extension was proposed, but who knows -- it would be a nice addition. directx has this ability in its DrawIndexedPrimitve function.

how big is your window? uploading a index sub-buffer shouldnt be too bad if its within reason, even if its a pain in the arse.

gmeed
08-29-2004, 05:38 PM
Originally posted by <bonehead>:
there was a discussion along these lines in the advanced forum. an extension was proposed, but who knows -- it would be a nice addition. directx has this ability in its DrawIndexedPrimitve function.

how big is your window? uploading a index sub-buffer shouldnt be too bad if its within reason, even if its a pain in the arse.Thanks for the pointer to the other discussion (http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=012219) . That's exactly what I want to do.

The total number of indices could reach into the millions, with a significant portion of those needing an update every few frames, so the proposed extension would help quite a bit.