Tile Engine

Started by
0 comments, last by Vampir 21 years, 8 months ago
Hi! I want to start to code a tile engine, but i need some suggestions how to render the tiles. I thought of 2 methods First: I have one VertexBuffer with just one Quad. Then changing the WorldPosition and Texture Position for every Tile (with Matrices) and draw it. I do it for all Layers in my map. 2. I have a big VertexBuffer for the whole screen. Lock it once per frame and write the new tile data in it. i will arrange the vertex data in the buffer in a way, that first the tiles will be rendered wich are on the first texture then tiles of the secon texture and so on to prevent setting for every tile a new Texture. Next thing are the layers of the map. At the moment i don''t how to do this. One VertexBuffer for every layer? or big big Vertexbuffer arranged that renders first, second,...xxxLayer. When i''m using the big big vertexbuffer method i need to have a list of texture used in each layer and arrange the buffer in a way that every texture is only set once per layer(so that the z order of the layers will be correct) The second method is much more complicated than the first but i can imagine its faster although i lock a vertex buffer but i minimize the other operations like calculating the position in World and in Texture What do you use for rendering maps? Do you think my methods are usable? Please give me your opininons or make suggestions to make it better
Advertisement
Both of them seem kind of slow. I would do it this way:

- Create a vertex buffer for every tile set (you probably only need one of two of these, you can probably store all of your tiles in one texture)

- determine the visible tiles and update the index buffer so only they are drawn (you can probably just do this with an offset)

-translate the all of the visible tiles.

This way you should have minimal texture changes and can probably use static vertex and index buffers. You can speed up the first method by only changing textures when the tile set changes, I''m thinking the second method will be slow though, because you keep locking and unlocking your VBs, but I''m not sure about dynamic vertex buffer performance.

This topic is closed to new replies.

Advertisement