Article View: comp.os.msdos.programmer
Article #6090Re: Solid filled triangles
From: Michael Cree
Date: Tue, 07 May 1991 22:21
Date: Tue, 07 May 1991 22:21
34 lines
2310 bytes
2310 bytes
In article <1991May07.025853.7837@lynx.CS.ORST.EDU>, murrayk@prism.CS.ORST.EDU writes:
>
> I am currently trying to write some code that will draw a solid-fill
> triangle on the VGA 640 x 350 screen (I am using this resolution so I can
> easily write an EGA version also). What the routine needs to do is to
> take in as input three points (x, y), a color, and a page number (0 or 1)
> and then as output the routine will draw a filled triangle with the three
> given points as the vertices. The routine needs to be really fast.
[...]
> Keith Murray (503) 757-2753 "A little man with a big eraser,
> murrayk@prism.cs.orst.ed changing history..."
> -MEGADEATH-
I will just address the problem of an algorithm to draw the
triangles. Probably the best way is to first write a
routine to draw horizontal lines starting at a point (x,y)
and of length l. Such a routine can take advantage of the
graphics hardware and works much faster than drawing pixels
separately (and faster than an arbitary angle line drawing
routine).
The triangle drawing routine then uses the horizontal
line drawer to render the filled triangles. It is a
matter of finding the highest corner (that is, lowest
row index in vertice coordinate), and then drawing
horizontal lines of correct lengths and starting
positions at each consecutive line. A little bit of maths,
but can be keeped to simple integer arithmetic.
I have an example of the code in 6502 assembler at
home (from a Dr Dobbs). Could paraphrase it into pseudo
code and mail it if you would like.
Just send me email if interested.
Michael Cree
cree@elec.canterbury.ac.nz
Technical Details
Message-ID:
<1991May8.102130.656@csc.canterbury.ac.nz>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!spool.mu.edu!sdd.hp.com!wuarchive!waikato.ac.nz!canterbury!betelgeux!creeReferences:
<1991May07.025853.7837@lynx.CS.ORST.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!spool.mu.edu!sdd.hp.com!wuarchive!waikato.ac.nz!canterbury!betelgeux!cree From: cree@elec.canterbury.ac.nz (Michael Cree) Newsgroups: comp.os.msdos.programmer Subject: Re: Solid filled triangles Keywords: triangles, code. Message-ID: <1991May8.102130.656@csc.canterbury.ac.nz> Date: 7 May 91 22:21:29 GMT References: <1991May07.025853.7837@lynx.CS.ORST.EDU> Sender: cree@betelgeux (Michael Cree) Followup-To: comp.sys.ibm.pc.programmer Organization: University of Canterbury, Christchurch, New Zealand Lines: 34 Nntp-Posting-Host: betelgeux.elec.canterbury.ac.nz