RGB rastport functions.

This forum is for general developer support questions.
Post Reply
Deniil
Posts: 109
Joined: Mon Jul 11, 2011 6:59 pm

RGB rastport functions.

Post by Deniil »

The Amiga graphics.library lags so completely behind when it comes to handling RGB. Everything has to go via the ancient pens.

I just learned that MorphOS and AROS has a new function (or atleast new attributes) that amend this by letting you set an RGB value directly as A-pen and presumably B-pen without actually having to mess with a pen:
SetRPAttrs(rp, RPTAG_PenMode, FALSE, RPTAG_FgColor, 0xFFCC88, TAG_DONE);

I would really like to see this exact implementation (to ease portability) in AmigaOS4.1.3 or OS4.2, unless there is already such a functionality implemented that I have missed of course.
User avatar
ssolie
Beta Tester
Beta Tester
Posts: 1010
Joined: Mon Dec 20, 2010 8:51 pm
Location: Canada
Contact:

Re: RGB rastport functions.

Post by ssolie »

Deniil wrote:The Amiga graphics.library lags so completely behind when it comes to handling RGB. Everything has to go via the ancient pens.
You are incorrect. Check the autodocs and includes again. You can set RGB values directly.
I would really like to see this exact implementation (to ease portability) in AmigaOS4.1.3 or OS4.2, unless there is already such a functionality implemented that I have missed of course.
Let be clear on something. AmigaOS is the leader. AmigaOS defines the Amiga's API. The clones are the followers. We will not be implementing API changes to "ease portability" because clones are the ones who must change to match the official API. As a developer, you should expect the platforms to continue to diverge.
ExecSG Team Lead
User avatar
ChrisH
Beta Tester
Beta Tester
Posts: 920
Joined: Mon Dec 20, 2010 9:09 pm
Contact:

Re: RGB rastport functions.

Post by ChrisH »

Deniil wrote:I just learned that MorphOS and AROS has a new function (or atleast new attributes) that amend this by letting you set an RGB value directly as A-pen and presumably B-pen without actually having to mess with a pen:
SetRPAttrs(rp, RPTAG_PenMode, FALSE, RPTAG_FgColor, 0xFFCC88, TAG_DONE);

I would really like to see this exact implementation (to ease portability) in AmigaOS4.1.3 or OS4.2, unless there is already such a functionality implemented that I have missed of course.
PortablE already has some declarations in it's 'CSH/pAmigaGraphics' module that make AmigaOS4 source-code compatible with the MorphOS & AROS way of doing it:
#ifdef pe_TargetOS_AmigaOS4
->make OS4 emulate how MorphOS & AROS do it
PRIVATE
CONST RPTAG_FGCOLOR = RPTAG_APENCOLOR
CONST RPTAG_BGCOLOR = RPTAG_BPENCOLOR
CONST RPTAG_PENMODE = TAG_IGNORE
PUBLIC
#endif
(I'd have made MOS & AROS behave like OS4, but that's not possible.)

Although I made those constants private, since I hide the implementation entirely with some procedures:
PROC setRPAttrsFGCOLOR(rastport:PTR TO rastport, rgb) IS SetRPAttrsA(rastport, [RPTAG_FGCOLOR, rgb, RPTAG_PENMODE, FALSE, TAG_END]:tagitem)

PROC setRPAttrsBGCOLOR(rastport:PTR TO rastport, rgb) IS SetRPAttrsA(rastport, [RPTAG_BGCOLOR, rgb, RPTAG_PENMODE, FALSE, TAG_END]:tagitem)

PROC getRPAttrsFGCOLOR(rastport:PTR TO rastport) RETURNS rgb
GetRPAttrsA(rastport, [RPTAG_FGCOLOR, ADDRESSOF rgb, TAG_END]:tagitem)
ENDPROC
User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 1446
Joined: Wed Mar 09, 2011 1:36 pm
Location: Sydney, Australia

Re: RGB rastport functions.

Post by tonyw »

@Deniil:

Look up the docs for IGraphics->SetRPAttrs in graphics.doc. You will probably be interested in the tags RPTAG_APen and RPTAG_BPen. I can give you a code snippet if you like.

Good to see that the clones have partly caught up.
cheers
tony
User avatar
tboeckel
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 68
Joined: Mon Jun 20, 2011 8:56 am
Contact:

Re: RGB rastport functions.

Post by tboeckel »

While setting direct RGB values as foreground and background colors works perfectly, what is missing is the full support for the alpha channel. MUI could make much more use of transparency effects for texts if the alpha byte would not be ignored. Even the Autodocs state this fact: The alpha part is currently ignored and should be set to 0xFF.
Deniil
Posts: 109
Joined: Mon Jul 11, 2011 6:59 pm

Re: RGB rastport functions.

Post by Deniil »

It's amazing I managed to forgot I asked this question and didn't see it again in 10 years!!

I see the APenColor tag has been there since v51, which is what, OS4.0.0 public/full release?
It works beautifully. The MOS PenMode on the other hand, not so much. It doesn't make any sense. Why should it matter from where an RGB triplet comes from (palette or color wheel or whatever) when put on a pen?? No, you can't pick one color from a palette and another from a color wheel. Not possible.
Post Reply