Jump to content
  • Advertisement

Archived

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

sj

Vertex information with tiles

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

Would anyone have any ideas how could I make tiles with DirectX 8? As far as I know, tile-based games use arrays to hold the map or tile information, and in DX 8 I need to make vertex buffers for the rectangles to hold the vertex information. So, If I had a 200x200 map, should I make vertex buffers for each tile (so I would have 20000 vertex buffers) or is there another way? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
You are saying vertex, and vertex buffer - these terms are from Direct3D, if you just create a DirectDraw Surface, and paint to it, (using the blt (or bltfast) to blit the section to lprect) for each tile? That would be atleast a start. Jag_007

Share this post


Link to post
Share on other sites
If you''re going to display all the tiles at once, you should consider using one big vertex buffer to do the job, but you''ll most likely want to display just a small part of the map (like 10x10 tiles). In this case you would just need 100 vertex buffers. If your map is flat you just need one vertex buffer to draw all triangles. Just change the texture and the transformation matrix!

Share this post


Link to post
Share on other sites
IceDragon is right, you should only need 1 vertex buffer. I was always under the impression that vertex buffers should be created at load time and not touched during the game. But you actually don''t get a performance hit if you write to them every frame. Just make sure you create the vertex buffer with the WRITE-ONLY flag, and there is not too much code between the lock() and unlock() calls for writing you vertex data.

In your case, every frame you need to workout which tiles are visible for that frame, then write their verices to the vertex buffer and finally render the vertex buffer.

Share this post


Link to post
Share on other sites
Be sure to also make the buffer D3DUSAGE_DYNAMIC as well if you want to re-write it every frame.

BTW: another, maybe even faster way is to keep all vertices in a static vertex buffer and fill a dynamic index-buffer once per frame that contains the indices to the vertices to render. (see nvidia's HP for an example wrapper implementation for static/dynamic index/vertex buffers )

VizOne

Edited by - VizOne on February 25, 2002 5:26:57 AM

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!