Archived

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

Vertex Arrays for changable heightmap...

This topic is 4981 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 haven''t fully understood how to use them yet (because I haven''t looked so hard yet ), but it seems as the steps to take is to: 1) Construct an array of vertices. 2) Call glVertexPointer with the array of vertices. This, I assume, sends the data to the graphics card''s memory. And then, each frame: 3) Decide which indices to use (i.e. which elements in the vertex array) and put them in an array. 3) Call glDrawElements (not sure if this is the one) with the array of indices. The problem is, in our game, the player is allowed to change the map - the inhabitants will only build houses on (more-or-less) flat ground, which means that the player will raise and lower parts of the map. Therefore, it seems that we would have to do the (1) and (2) steps each frame as well, and... well, it would seem that the benifit is gone (since the vertex array has to be sent down the pipeline every time). Since only 12 heights will be changed betweeen frames (that is how big the player''s tool is), it would be great if we could just send those down the pipeline. Or even better, if we could directly access the vertex array on the graphic card''s memory. If we''ve got it all wrong, please tell us. And yes, the game is inspired by Populous (I and II).

Share this post


Link to post
Share on other sites
iirc a standard Vertex array ISNT copied to gfx memory, infact, if it was it would kinda defeat the point of the vertex_buffer_object extension (VBO).

I think you can do what you want to do via VBOs using the mapping method which, iirc, allows you to write to a pointer as if its a normal memory address, thus you could push you changed verts into the correct place in a vertex array on the gfx card

Another way of doing it would be to use VBOs again to keep the data you are rendering on the gfx card (or at least inside OpenGL its self) and keep a copy in system memory, then when the hight is changed you just update the vertex data then, this would accure one frame every so often and shouldnt impact the game at all.

Depending on the amount of textures/vertex data etc you are using it might not all fit on the video card so you could end up in AGP RAM space, however this should still be plenty plenty fast enuff

Share this post


Link to post
Share on other sites