Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding more blending modes
#1
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.
Reply
#2
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
Reply
#3
(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!
Reply
#4
I added new blend modes in my fork. Thanks for your help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)