ain@s.cc.purdue.edu (Patrick White) (06/27/88)
[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
ain@s.cc.purdue.edu (Patrick White) (07/06/88)
I finally figured areafills out.. my thanks goes out to John M. Olsen, and Steve Berry who both made suggestions and sent me sample code. In case anyone was wondering what I was doing wrong, all I know it that I was not linking the TmpRas structure into the RastPort after initializing it.. and something else was wrong too which I never figured out -- it just started working again (probably compiled something with the wrong option at some point). Since I just figured this stuff out, I was thinking of writing a function that would init and link in a TmpRas structure... anybody be interested in such a beast? -- 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