nick5454

I need to make a clipping region like the mini-map on need for speed.

What I plan on doing is this.

Draw the map on a texture, then creat a clipping region and just show whats in the map circle, clipping off whats on the outside.

Does anyone know how to do this or links to achieve this

Thanks,

Nick



Re: XNA Framework Setting a Clipping region

Shawn Hargreaves - MSFT

If your clipping region is rectangular, you can use the scissor rectangle on the graphics device to control this.

For arbitrary shapes, the easiest ways are probably either to draw your map onto a rendertarget, then draw your mask shape into the alpha channel of that rendertarget (disabling color writes) after which you can alpha blend the whole rendertarget onto the screen.

Alternatively you could use the stencil buffer. Draw your mask shape to the screen with color writes disabled and the stencil buffer set to write a special mask value, then draw your map graphics directly to the screen with the stencil buffer set to only accept pixels that match the mask value.





Re: XNA Framework Setting a Clipping region

nick5454

Is there any plan to simply this at all

It seems overly complicated to do something so simple.





Re: XNA Framework Setting a Clipping region

jsedlak

nick5454 wrote:

Is there any plan to simply this at all

It seems overly complicated to do something so simple.

Yes and no. No because there is no simple way to say "Render this here in this shape" in XNA/C#/DirectX. You have to build that functionality, or grab someone else's component that does. Yes it is easy because you could just render a RenderTarget.Texture over a Quad that takes up only a certain amount of space. That will give you a square "viewport" for the Map. Just render the map to the RenderTarget and be done with it. This requires limited knowledge of shaders and 3D programming. You could probably even just render the RenderTarget.Texture through a SpriteBatch, making it even easier.






Re: XNA Framework Setting a Clipping region

Tito Jermaine

From a performance standpoint, is there a significant difference between either of these methods Just curious.