Article View: comp.sys.amiga.tech
Article #9200Help with area fills
From: Patrick White
Date: Sun, 26 Jun 1988 22:05
Date: Sun, 26 Jun 1988 22:05
80 lines
3313 bytes
3313 bytes
[my wisdom teeth for *decent* graphics library documentation -- RKM is
*not* decent!]
Hi,
I've been trying to get a program I'm writing to draw and fill hexes on the
screen. I'm using Manx 3.4a right now -- small code and data, 16-bit ints.
So far, I have managed to draw the hexes and flood fill them, but that
was just too slow to be of use (20 sec. to flood a hex about 1 in x 1 in).
So, I decided to try using area fills (both to learn it and in the hopes
they would be faster). So, I initialized a vertex area with InitArea
(think I did this right), and then I tried to initialize a TmpRas area
via InitTmpRas (think I did this right too).. so far, no crashes. Now,
when I try to do an AreaMove, my machine GURU's with an illegal instruction
area (probably tried to execute data somewhere in the AreaMove call).
For brevity, I'm going to chop a lot of the error checking out and
only show code fragments... note that I did get drawing and flood fills
(via area outlining mode) to work and just hacked the drawing/flood calls
to try area fills. It's probably safe to assume that I opened graphics
library correctly.
/* init areamove stuff */
#define NVERT 10
register struct AreaInfo *ai; /* area info structure */
register BYTE *buf; /* buffer for NVERT verticies */
ai = AllocMem( (LONG) sizeof(struct AreaInfo), MEMF_PUBLIC | MEMF_CHIP |
MEMF_CLEAR );
buf = AllocMem( (LONG) 5*NVERT, MEMF_PUBLIC | MEMF_CHIP | MEMF_CLEAR );
/* hook them into the screen's rastport */
InitArea( ai, buf, (LONG) NVERT );
/*-----------------------------------------*/
/* init TmpRas according to RKM docs */
register struct TmpRas *tmpras; /* tmpras structure */
register UBYTE *buf; /* buffer */
tmpras = AllocMem( (LONG) sizeof(struct TmpRas), MEMF_PUBLIC | MEMF_CHIP |
MEMF_CLEAR);
buf = AllocMem( 16384L, MEMF_PUBLIC | MEMF_CHIP | MEMF_CLEAR);
/* link both into rast port */
InitTmpRas( tmpras, buf, 16384L );
/*----------------------------------------*/
/* now I try doing the area fill */
LONG x, y;
register LONG x1, x2, x3, x4, y1, y2; /* verticies of hexagon */
struct RastPort *rport;
/* this is what I'm trying to get to work */
SetAPen( rport, 2L );
SetOPen( rport, 1L );
AreaMove( rport, x1, y );
AreaDraw( rport, x2, y1 );
AreaDraw( rport, x3, y1 );
AreaDraw( rport, x4, y );
AreaDraw( rport, x3, y2 );
AreaDraw( rport, x2, y2 );
AreaDraw( rport, x1, y );
AreaEnd( rport );
Any help -- either in the form of an example that works, or suggestions
as to what I might be doing wrong would be greatly appreciated.
Many thanks.
-- Pat White
ARPA/UUCP: j.cc.purdue.edu!ain BITNET: PATWHITE@PURCCVM PHONE: (317) 743-8421
U.S. Mail: 320 Brown St. apt. 406, West Lafayette, IN 47906
Technical Details
Message-ID:
<3270@s.cc.purdue.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!mailrus!purdue!i.cc.purdue.edu!h.cc.purdue.edu!s.cc.purdue.edu!ainShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!mailrus!purdue!i.cc.purdue.edu!h.cc.purdue.edu!s.cc.purdue.edu!ain From: ain@s.cc.purdue.edu (Patrick White) Newsgroups: comp.sys.amiga.tech Subject: Help with area fills Message-ID: <3270@s.cc.purdue.edu> Date: 26 Jun 88 22:05:10 GMT Reply-To: ain@k.cc.purdue.edu (Patrick White) Organization: PUCC Land, USA Lines: 80