Basic Texture Questions
I've been screwing around with XNA, making little 2D programs here and there, and I was wondering if it was at all possible to do a few things:
1) Tile textures. I know I could write a for loop to print our my texture, but that a _huge_ waste of resources. Is there a better way to do this?
2) Manipulate textures in general. Say, invert them, etc.
3) Is there any kind of image/pixel manipulation/checking functionality? Say I want to get the information for a single pixel, get the alpha value, find what SpriteBatch it belongs to, etc.
Any help on any of these would be _greatly_ appreciated.
Thanks in advanced!
[653 byte] By [
SlaserX] at [2007-12-24]
1) Simply half your texture coordinates and set your addressing to warp.
graphics.GraphicsDevice.SamplerStates[ n ]AddressU = TextureAddressMode.Wrap;
graphics.GraphicsDevice.SamplerStates[ n ]AddressV = TextureAddressMode.Wrap;
Where n is the sampler for the texture. Or have a sampler state block in your .fx file.
2) As above, invert the texture coords, or manually copy the pixels in the opposite direction.
3) You operate on specific pixels in a pixel shader (but all of them sequentially being presented to screen from whatever you are drawing).
Another option is to find the coords of the pixel you are interested in, and render that to a 1x1 texture. You can then lock that texture and get the pixel values.
Another alternative would be to downsample a specific texture iteratively until it is 1x1, then do the same as above. (This would usually be more like averaging the values).
Hope that helps, good luck!