Is there any way that I can make rounded corners on a rectangle rendered in XNA through primitives (line-strips)? I want to make my UI a bit more fancy than it is already, and I would like the code to be flexible, without too many textures involved.
|
|
You can render your primitive, and make a shader that can create these rounded corners.
Result of this pixel shader: If you use shaders, you can make really fancy UI, even an animated one. For me great to prototype simple pixel shaders is program EvalDraw |
||||
|
|
|
Another way to do this is to use a 'button stretch' (also called a 'box stretch' or 'nine-patch'). Essentially you create an image that is made up of 9 parts:
In order to draw that button at any size, you draw each piece (from top to bottom, left to right):
If you look at the button you will see that it doesn't matter if (2), (5) and (7) get scaled horizontally (because it is essentially a straight line); in the same manner (4), (5) and (6) can be scaled vertically without affecting the quality of the image. |
|||||||
|


