|
Additive Blending? |
Kikaru
Member #7,616
August 2006
|
Well, I was thinking, and worked this out: int blend(int col1, int col2, int fade) { int ncol; int inv_fade = 255 - fade; ncol = ((col1*fade)+(col2*inv_fade)) >> 8; return ncol; } Is this how you do additive blending? |
Jonatan Hedborg
Member #4,886
July 2004
|
I would guess more like: But more to the point; why? There is already an additive blending function in allegro. EDIT: fixed my code
|
Kitty Cat
Member #2,815
October 2002
|
int blend(int col1, int col2, int fade) { return MIN(((col1*fade)+col2, 255); } Assuming single-component 0..255 values. -- |
Jonatan Hedborg
Member #4,886
July 2004
|
Don't you have to do something funky with fade, assuming 0..255 range?
|
Kitty Cat
Member #2,815
October 2002
|
Oh, right. int blend(int col1, int col2, int fade) { return MIN( ((col1*fade)>>8) + col2, 255); }
-- |
Kikaru
Member #7,616
August 2006
|
I didn't know there was one in Allegro. Well, Thanks! |
Ceagon Xylas
Member #5,495
February 2005
|
Fblend's much, much faster than the allegro blending routines. Linkage |
Paul whoknows
Member #5,081
September 2004
|
Is there a good reason not to merge Fblend with allegro? ____ "The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner. |
Kitty Cat
Member #2,815
October 2002
|
Allegro wouldn't be able to take advantage of FBlend's improvements due to API design differences. -- |
HardTranceFan
Member #7,317
June 2006
|
I'm keen to try out FBlend. However, I'm very much in the dark on how to use it. I assume I need to compile allegro with FBlend in order to get it working. Question is, how do I do this? I downloaded the Allegro 4.2.1 binary files, and I'm not familiar with command line compilations using makefiles. Do I need to recompile allegro with FBlend, or is there a binary version which I can bung onto my program? -- |
Ceagon Xylas
Member #5,495
February 2005
|
There's a binary version here. Just link the library, copy the headers, and you're ready to go. It's extremely easy to use. Even easier than allegro's blender routines. Everything you need to know is in the docs. |
Neil Walker
Member #210
April 2000
|
I agree, fblend is much faster and much simpler. There's no need for setting up the blender types, you just call for bitmaps: fblend_add(src,dst,x,y,factor) and for primitives theres similar ones, e.g. fblend_rect_add, fblend_rect_trans. There's also a few others that may or may not be useful like 2x stretch. there's also an undocumented fblend_fade_to_color,which does exactly what it says though I can't remember if this works or not. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
HardTranceFan
Member #7,317
June 2006
|
Ceagon Xylas: Thanks. -- |
|