Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Additive blended lines with Fblend

This thread is locked; no one can reply to it. rss feed Print
Additive blended lines with Fblend
Paul whoknows
Member #5,081
September 2004
avatar

I need a fast additive blended line function, and I think it would be possible to use some of the fblend's internal functions to do this.
Fblend has 2 primitive blenders functions:

void fblend_rect_add (BITMAP *dst, int x, int y, int w, int h, int color, int fact)  
void fblend_rect_trans (BITMAP *dst, int x, int y, int w, int h, int color, int fact)

I think it souldn't be so hard to modify some of its code to get a fblend_line_add(). However, I am not a Fblend expert, I am using this library since a few months. So is there any experienced Fblend user who can help me with this?
Or if this is not possible, does someone know a good way to achieve this?(in software)

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Ceagon Xylas
Member #5,495
February 2005
avatar

Fblend has built in pixel functions too I believe. If nothing else, try replacing allegro's native line function's putpixel calls with fblend's.

Thomas Fjellstrom
Member #476
June 2000
avatar

You know, a line really is a rectangle.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

James Stanley
Member #7,275
May 2006
avatar

Not... really...
A rectanle is a bunch of lines? Yes. A line is not a rectangle. Not as far as the code's concerned anyway...

gnolam
Member #2,030
March 2002
avatar

That depends on if the lines are axis-aligned or not.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Paul whoknows
Member #5,081
September 2004
avatar

Quote:

You know, a line really is a rectangle.

I am not sure about that. With rect() I can draw lines, but only horizontal and vertical ones. Not very useful in my case, that's why I need a true line_additive() function.

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Jonatan Hedborg
Member #4,886
July 2004
avatar

Maybe openlayer/allegroGL is what you want?

Paul whoknows
Member #5,081
September 2004
avatar

My game supports OpenGL and software drivers. I need an additive blender line() function only for the software driver(Allegro + Fblend).

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Bob
Free Market Evangelist
September 2000
avatar

Considering that most of the time drawing the line won't be in the blending routines, I think you can just use Allegro's do_line() and be done with it.

--
- Bob
[ -- All my signature links are 404 -- ]

Ceagon Xylas
Member #5,495
February 2005
avatar

I, myself said:

Fblend has built in pixel functions too I believe.

After looking through the code I found it doesn't. So never mind that idea.

Paul whoknows
Member #5,081
September 2004
avatar

Quote:

Considering that most of the time drawing the line won't be in the blending routines, I think you can just use Allegro's do_line() and be done with it.

The line algorithm is not the problem, the problem is that I need a put_pixel_additive/16/32/MMX() function, just like rect_add().

I thought that Fblend used some kind of 'put_pixel_add()' in the function rect_add(), so I wanted to use that to make my line_add() function, but as Ceagon Xylas said, there is no such a function.

Bob, can you tell me if is there a way to obtain a 'put_pixel_add()' function from Fblend?
If not, any advise or link or code it would be greatly appreciated.

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Thomas Fjellstrom
Member #476
June 2000
avatar

You won't beable to use MMX/SSE properly on lines that aren't horizontal. The data just isn't in the same area, so you'd have to do it pixel by pixel. which is what you get from do_line and a custom function that does the reading and writing of bitmap data.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Matt Smith
Member #783
November 2000

I suppose in theory you could write a breshenham line routine that decomposes to short horizontal or vertical lines, but it's barely worth it.

Thomas Harte
Member #33
April 2000
avatar

Quote:

You won't beable to use MMX/SSE properly on lines that aren't horizontal.

Surely it'd still be helpful though? You're taking two (r, g, b) vectors, multiplying each by a scalar and then adding them together.

Matt Smith
Member #783
November 2000

Good point, but for simplicity you'd prolly have to assume that the RGB is in the bottom 24 bits, which won't be 100% reliable. I suppose 2 versions would be OK, as you are passing a callback to do_line() anyway, so no need to test inside the my_putpixel().

I'm not doing this. I've had my fill of asm lately :P

Paul whoknows
Member #5,081
September 2004
avatar

Right now I am using this:

set_add_blender(255,255,255, 127);
drawing_mode(DRAW_MODE_TRANS,NULL,NULL,NULL);
//draw primitive here (lines, circles, rect, etc.)
drawing_mode(DRAW_MODE_SOLID,NULL,NULL,NULL);

If you know a faster way of doing this, please let me know.

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Go to: