28 March 2017, 06:57 | #1 |
Registered User
Join Date: Dec 2016
Location: USA
Posts: 101
|
Area-fill operation examples?
I'm working on a board game that draws to a full-screen Intuition window and I'm trying to find an example of using the graphics.library area fill functions to draw a solid-filled circle. The setup is pretty complicated and the graphics.library documentation is pretty confusing.
I set up my window's RastPort with a TmpRas and it works... once. When I close the application and restart it, the system crashes with a CHK instruction error and Enforcer hits so I'm not cleaning up after myself right. What's the right way to set up a window for area fill drawing and then clean it up afterward? |
28 March 2017, 07:08 | #2 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
|
The reason for the temprast is to hold a mask, if that helps. Once the mask is created it blits to the rastport in jam1 mode.
How do you allocate and deallocate the temprast? |
28 March 2017, 07:37 | #3 |
Registered User
Join Date: Dec 2016
Location: USA
Posts: 101
|
I initialize the TmpRas with InitTmpRas() and toss it some chip memory. It doesn't look like I deallocate the buffer, that's probably the problem... I'm not sure when it's safe to deallocate since I don't see a destructor equivalent to InitTmpRas().
And the note in the documentation: "Would be nice if RastPorts could share one TmpRas." Does that mean I need a new TmpRas for each area draw I do or is it just complaining that you can't have multiple RastPorts use the same TmpRas? |
28 March 2017, 19:19 | #4 | |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
|
Quote:
And multiple rastports cannot use a single temprast. It was wishful thinking. |
|
28 March 2017, 20:50 | #5 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
In order to use AreaXXX commands you need to initialize both TmpRas and AreaInfo and link them into the RastPort.
You can free both when you no longer need them, i.e. when you are finished with all the AreaXXX stuff. Example: http://thomas-rapp.homepage.t-online...les/piechart.c To draw a solid circle, you can use AreaCircle() followed by AreaEnd(). A single TmpRas can only be used by one RastPort at a time. But I don't see a reason why you should not reuse the same TmpRas for a different RastPort. |
29 March 2017, 21:15 | #6 |
Registered User
Join Date: Dec 2016
Location: USA
Posts: 101
|
I was able to get my routine going and draw all the filled-in circles I want. Thanks!
|
08 April 2017, 00:19 | #7 |
Registered User
Join Date: Dec 2016
Location: USA
Posts: 101
|
I've got an unrelated question but I don't want to keep spamming threads in this forum since it's pretty slow.
I have an ILBM IFF file containing a 64x32 4-color bitmap. I want to draw the bitmap into my window (on a 16-color low-res screen) using the IFF datatype so I don't have to wrestle with inflarse.library again. I can create an Object from my IFF but I'm not sure how to get the BitMap for use with BltBitMapRastPort. The datatypes docs are not so good. Do I need to put it into a Gadtools gadget somehow first or can I just blit it into the RastPort somehow? It's just a static image. |
08 April 2017, 02:35 | #8 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
|
With datatypes, you need to be prepared to lock pen colors and wait for palette remapping because they are a pain on paletted screenmodes.
|
08 April 2017, 03:26 | #9 |
Registered User
Join Date: Dec 2016
Location: USA
Posts: 101
|
My game is a one-screen Reversi game so I'm fine with having just one global palette on my screen. So far I'm just using the 4 base Workbench colors.
|
08 April 2017, 10:53 | #10 | |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
Quote:
Here is an example how to load an image with datatypes: dtimage.c It also shows the difference whether you load the image without remapping or if you let datatypes map the bitmap into your screen's palette. The latter lets you load images of any number of colors, even JPEG, which will then be dithered to match your screen's colors. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Games and examples with source available | TurboCrash | Coders. Blitz Basic | 3 | 06 January 2016 17:50 |
Interrupts and Multitasking: Examples? | tygre | Coders. General | 13 | 22 December 2015 04:56 |
Boot block examples? | h0ffman | Coders. General | 3 | 04 March 2011 16:44 |
Area fill advice | pmc | Coders. General | 4 | 11 October 2010 08:50 |
Plasma examples anyone? | jobro | Coders. General | 5 | 27 November 2005 17:25 |
|
|