Expose BestColor() to ZScript
Moderator: GZDoom Developers
Expose BestColor() to ZScript
DTA_FillColor is exposed to ZScript, but computing the correct palette color for it requires a color-matching function. Since there already is one in C++ (BestColor), please consider exposing it to ZScript as well.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Expose BestColor() to ZScript
I think it'd be better to make the entire interface palette agnostic throughout instead of exposing this.
Re: Expose BestColor() to ZScript
Is it possible, maybe, for the 3.3 version of ZScript the Palette color arguments to be removed completely for these commands, and be calculated in their VM hooks instead?
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Expose BestColor() to ZScript
I don't think it's that easy to change the signature of an existing function, this will require maintaining different variants.
Re: Expose BestColor() to ZScript
You might simply ignore the alpha channel given to DTA_FillColor, and always use a palette search. I doubt anyone would use it to intentionally draw completely different colors in paletted mode.
This would come at a performance penalty, though, since then the search would be done every time that draw call is made, even if the fill color is the same every time. Unless the VM can optimize this away somehow?
This would come at a performance penalty, though, since then the search would be done every time that draw call is made, even if the fill color is the same every time. Unless the VM can optimize this away somehow?
Re: Expose BestColor() to ZScript
There is no search done if you simply use the RGB256k table, and that would be the ideal way to do it, because inevitably someone will be calling this function a thousand times per frame and we'll have to account for that.
The call would simply be something like "palcolor = RGB256k.All[(r&0xfc)<<10|(g&0xfc)<<4|(b&0xfc)>>2];" - modified, obviously, accounting for rgb being a uint32_t variable (I'd do it myself if I remembered in what order it stores those values).
That is actually how I did stencil draw calls in the palette renderer, anyhow, since that was originally broken in the true-color merge.
The call would simply be something like "palcolor = RGB256k.All[(r&0xfc)<<10|(g&0xfc)<<4|(b&0xfc)>>2];" - modified, obviously, accounting for rgb being a uint32_t variable (I'd do it myself if I remembered in what order it stores those values).
That is actually how I did stencil draw calls in the palette renderer, anyhow, since that was originally broken in the true-color merge.