[Solved] Rendering a Tiled Game using a Custom Texture2D

Started by
0 comments, last by Andy474 14 years, 7 months ago
Hi, a quick performance Question here. I am current working on a tile engine which is drawn using a int[,] and foreach tile I draw a Texture in a rectangle using

t_bgTexture = new Texture2D(deviceRef, 1, 1, 1, TextureUsage.None,          SurfaceFormat.Color);
t_bgTexture.SetData<Color>(new Color[] { c_tilebgColor });
my Question. Is Drawing these custom textures every time I draw going to cause latency(lag) in my game? Currently I am using a cameraPosition Vector to control movement and simply subtract the current cameraPosition from each tile when it is drawn. And for some reason it is extremely jumpy, as in not smooth scrolling. I have used this method before and it worked fine, the only thing that I can see is different is that last time I was using Textures loaded from a file. N.B I have an array 23x23 and each tile is 2 textures 23^2 = 529 * 2 = 1058 ... therefore 1058 Textures being Drawn all of different Colors. (sory i cant be more specific .. rushing off to bed gotta be up in 4 hours :S) [Edited by - Andy474 on September 14, 2009 2:55:59 PM]
Advertisement
Solved ::

It turns out I was actually adding a tile to a List every time I rendered it ... therefore Basic maths :

1058 tiles per Draw
6 draws per second

1058 * 6 = 6348 tiles being added to the list per second ... and 380,880 per min

so no-wonder I was experiencing massive performance issues :P

This topic is closed to new replies.

Advertisement