[.net] Best way to create a tile engine

Started by
1 comment, last by slyprid 18 years, 10 months ago
I'm currently experimenting with making a tile engine. I've created two engines so far with the exact same capabilities. The only problem i'm having is the one I created in Direct3D only runs at max of 30-40fps, whereas the one created in DirectDraw runs at 60+fps. I know that directdraw isn't supported anymore, but is it worth going to Direct3D because of that? Or is there a better method in Direct3D to render tiles. The way i'm currently doing it is creating primitives that consist of 4 verticies, than I texture them. I picked up some speed by having it texture the primitives with the same tiles all at once, but I would like to use a tileset instead of just a list of textures. (reason I want to use tileset, is that since it runs slower with more textures loading, why not load one texture with all the tiles you need) Slyprid
Advertisement
I assume you used some kind of rendertotexture stuff to access the backbuffer directly in the D3d engine to yield such low results.

My suggestion would be to exploit the power of d3d and use actual triangles/squares rendered in orthagonal mode. This would allow you to use hardware acceleration to the max.

Technically speaking: go load up quake 3 and the first thing you see is a hud. That hud is probably drawn very quickly and dirtily through a similar orthagonal operation. Accessing the backbuffer is time consuming at best because you have to check the context, lock, copy, and unlock the buffer (via that rendertotexture func or an UpdateXXXXX func).

30 fps is unreasonable, even for software emulation mode in most sample apps.

Actualy, you can do this with as few as 30 lines of code (to setup this view mode, render your triangles with "textures" as tiles, and reset the view mode to perspective).

g/l
Well I went and rewrote my program to see if it was my coding slowing it down, but found out that if I use vertexBuffers instead of just writing a vertex at a time than it speeds it up alot. I'm currently running at 100+ fps right now (only 1 tile texture on screen atm though) But it is running alot better now. Thanks for the advice, I also changed to rendering in orthogonal mode.

Slyprid

This topic is closed to new replies.

Advertisement