Sign in to follow this  
juanpaco

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this