Sign in to follow this  
Matthew Shockley

DirectX Drawing Rectangles

Recommended Posts

Graphics cards really can only draw triangles. A rectangle is 2 triangles:


A B
*------*
|\ |
| \ |
| \ |
| \ |
| \ |
| \|
*------*
C D


So to draw the rectangle you draw 2 triangles: ABC and ADC

-me

Share this post


Link to post
Share on other sites
Quote:
Original post by Matthew Shockley
Why is that? It seems to me that rectangles would be easier to draw than triangles, but ok.... lol.


You can make just about everything out of triangles except for smooth curves, but how do you make a triangle out of a rectangle? You can't. But you can make rectangles out of triangles. The hardware is designed to do one thing and do it fast, that thing is triangles.

-me

Share this post


Link to post
Share on other sites
what? they're all free. Or many of the other sites are. You can't draw a triangle yet, those ones are definitely free.

If you're copy-pasting the code, you're doing it wrong and not learning anything.

-me

Share this post


Link to post
Share on other sites
what? they're all free.(turns out they are for pay now) Or many of the other sites are. You can't draw a triangle yet, those ones are definitely free.

If you're copy-pasting the code, you're doing it wrong and not learning anything. Anyway, I'm pretty sure that the SDK comes with excellent documentation and good examples.

-me

Share this post


Link to post
Share on other sites
Quote:
Original post by Matthew Shockley
Why is that? It seems to me that rectangles would be easier to draw than triangles, but ok.... lol.


Any three points in three-dimensional space lie within the same plane (i.e. a two-dimensional "surface"). That is, if you take any three points in space and connect them up to make a triangle, you get a flat triangle. If you add a fourth point, that isn't true any more. So drawing a rectangle means, in general, that you have to specify how it "bends" to accommodate the non-flatness. The easiest way to do that is to "crease" it along one or the other diagonal, making two triangles. :)

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