Jump to content
  • Advertisement
Sign in to follow this  
Andy474

[Solved] Rendering a Tiled Game using a Custom Texture2D

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

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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!