English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 28 March 2017, 06:57   #1
LuigiThirty
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?
LuigiThirty is offline  
Old 28 March 2017, 07:08   #2
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
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?
Samurai_Crow is offline  
Old 28 March 2017, 07:37   #3
LuigiThirty
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?
LuigiThirty is offline  
Old 28 March 2017, 19:19   #4
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
Quote:
Originally Posted by LuigiThirty View Post
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?
Are you watching for edge clipping as the RKRM states? http://amigadev.elowar.com/read/ADCD.../node035D.html

And multiple rastports cannot use a single temprast. It was wishful thinking.
Samurai_Crow is offline  
Old 28 March 2017, 20:50   #5
thomas
Registered User
 
thomas's Avatar
 
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.
thomas is offline  
Old 29 March 2017, 21:15   #6
LuigiThirty
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!
LuigiThirty is offline  
Old 08 April 2017, 00:19   #7
LuigiThirty
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.
LuigiThirty is offline  
Old 08 April 2017, 02:35   #8
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
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.
Samurai_Crow is offline  
Old 08 April 2017, 03:26   #9
LuigiThirty
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.
LuigiThirty is offline  
Old 08 April 2017, 10:53   #10
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
Quote:
Originally Posted by LuigiThirty View Post
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.

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.
thomas is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:05.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.24042 seconds with 16 queries