Hello. I want to add more blending modes into Tilengine, such as logical OR, logical AND, and so on. I know I can define a custom blending function, but I want to implement it right into the library. How can I achieve that please?
Thanks for your answer.
Hi!
Built-in blending tables are created in file Tables.c, in
CreateBlendTables() function:
https://github.com/megamarc/Tilengine/bl...bles.c#L20
To add new modes, just expand the public enumeration
TLN_Blend here:
https://github.com/megamarc/Tilengine/bl...gine.h#L83
And add the corresponding blend formula in the aforementioned
CreateBlendTables() with the desired effect.
For example formula for hypothetical logical AND should be:
Code:
_blend_tables[BLEND_AND][offset] = (a & b);
Parameters
a and
b are brightness levels between 0 and 255
(05-09-2022, 08:55 PM)megamarc Wrote: [ -> ]Hi!
Built-in blending tables are created in file Tables.c, in CreateBlendTables() function:
https://github.com/megamarc/Tilengine/bl...bles.c#L20
To add new modes, just expand the public enumeration TLN_Blend here:
https://github.com/megamarc/Tilengine/bl...gine.h#L83
And add the corresponding blend formula in the aforementioned CreateBlendTables() with the desired effect.
For example formula for hypothetical logical AND should be:
Code:
_blend_tables[BLEND_AND][offset] = (a & b);
Parameters a and b are brightness levels between 0 and 255
Ah thanks! I will try this!
I added new blend modes in my fork. Thanks for your help!