Timeline for XNA - Drawing 2D Primitives (Boxes) and Understanding Matrices in Computer Graphics
Current License: CC BY-SA 3.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 16, 2020 at 10:15 | history | edited | CommunityBot |
Commonmark migration
|
|
Feb 23, 2012 at 22:02 | comment | added | John McDonald |
A friend and I have actually written a small open-source library to draw primitives in XNA that does exactly this and more. It seems relatively popular: sourceforge.net/projects/primitives2d Since it uses extension methods, you'd just call spriteBatch.DrawRectangle(rect, Color.Blue, 1.0, Math.PI); for example.
|
|
Nov 29, 2011 at 3:38 | comment | added | electroflame | Actually, I never said it would have less overhead. I said that my way could be faster. It all depends on the implementation. | |
Nov 29, 2011 at 2:48 | comment | added | cwharris | I have absolutely no doubt the using a SpriteBatch works quickly, and I never said it didn't. I just find it it silly that you think it has less overhead than drawing wireframe. | |
Nov 28, 2011 at 23:23 | history | edited | electroflame | CC BY-SA 3.0 |
Edited formatting; fixed code error; fixed spelling error; reworded statement
|
Nov 28, 2011 at 23:19 | comment | added | electroflame | @xixonia I have this very code in my game, so I can say with 100% certainty that there is little to no overhead with this method. The single-pixel sprite is assigned and allocated when the game does it's first initial load. All I'm doing while the game is running is scaling it, coloring it, and drawing it. Your method below may prove to be faster, but I went with what I know will work and what will be fast 100% of the time. I'm not saying that your method won't be fast, but I posted an easy-to-implement solution, that is fast with most, if not all, of it's initial allocations upfront. | |
Nov 28, 2011 at 22:33 | comment | added | cwharris | Also, since when is drawing 4 textured quads (16 vertices and 24 indicies) faster than drawing 4 line segments (4 vertices and 8 indicies) ? | |
Nov 28, 2011 at 22:31 | comment | added | cwharris | You claim that SpriteBatch is going to be less overhead than drawing user indexed lines. This is ridiculous. Drawing a colored line doesn't do any alpha blending or color interpolation, using SpriteBatch obviously does. Also, SpriteBatch is drawing textured quads. This is texture interpolation, AND it's occurring even for pixels that never get drawn. Using a simple primitive drawer has MUCH less overhead. | |
Nov 28, 2011 at 21:03 | comment | added | electroflame | @Drackir Updated my answer, thanks for the suggestion! I hadn't thought of using it like that. | |
Nov 28, 2011 at 20:58 | history | edited | electroflame | CC BY-SA 3.0 |
Fixed formatting, improved readability
|
Nov 28, 2011 at 17:14 | comment | added | Richard Marskell - Drackir | You could also draw four lines using the same technique. | |
Nov 27, 2011 at 19:11 | history | answered | electroflame | CC BY-SA 3.0 |