Jump to content
  • Advertisement
Sign in to follow this  
juanpaco

[.net] [XNA] large background from small texture

This topic is 4229 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 all. I'm trying to do a 2D game in XNA, and I have this cool little texture that I want to tile to be the background. I've found tutorials on using a texture for the background, but all the examples I've found just stretch the texture which of course = loss of resolution. I know I could "manually" tile it (just draw it myself a bunch of times), but I was wondering if there's some better way of doing that. I did some OpenGL stuff a few years ago, and tiling was supported by the api. Does anyone know of some way in XNA to just give a large surface whose size is a multiple of my texture and have the framework automatically tile it? Thanks in advance for any replies.

Share this post


Link to post
Share on other sites
Advertisement
I would just draw a large quad, but set the texture wrapping mode to REPEAT. This way the texture will be repeated, and not scaled to fit the quad.

Share this post


Link to post
Share on other sites
Thanks for the reply tompp.

I'm using the SpriteBatch class in the XNA framework to handle 2D stuff. I've been going through the documentation, but I haven't found anywhere that XNA exposes an option to repeat a texture in that way. I don't see it in SpriteBatch, and it's not clear to me how to slap a texture with repeat on a quad. That is trivial in OpenGL. It's possible that XNA just doesn't support this in the framework.

I couldn't gather from your post where to do this in XNA. If you are referring to a technique in XNA, could you elaborate?

Share this post


Link to post
Share on other sites
He was telling you to manually render a Quad (4 vertices) and set the texture wrapping mode. This can be done in Dx,OpenGL,MDX,XNA, etc...

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!