Jump to content
  • Advertisement
Sign in to follow this  
Cristobal Garib

How to draw just the visible texture

This topic is 4211 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 I'm doing a 2D game and i whant to improve efficiency. My level background is a Big 6000x1200 texture and my screen only shows 800x600 of it. I whant to just draw the 800x600 part of the texture. Here is my code: SpriteBatch.Draw2D(texture, Rectangle.Empty , textureSize, new Point(X,Y), color); This works fine Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Any modern graphics API will clip the texture, only drawing what's needed. Since your code works fine, there's only a reason to change it if it is the source of a slowdown.

If you identify it as a major slowdown, the following actions may improve it:
1. Make the texture size a power of two, ie. 2^13 x 2^10 = 8192x1024.
2. Split it up in smaller textures (possibly applying 1.) and tile it, only drawing the tiles that intersects the viewing rectangle.

They may also worsen it, so none of this is worth doing if you don't know for sure that it's slowing your game down.

Share this post


Link to post
Share on other sites
Only the latest-n-greatest hardware supports a 6000 pixel wide texture. Off the top of my head the SM3/D3D9 generation hardware topped out at 4096 - it's only the latest G80 and R600's that allow 8192 width textures.

Consequently you're probably losing about 1/3rd of your original texture regardless of what you do with it at render-time....

hth
Jack

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!