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:
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)
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.
You know, a line really is a rectangle.
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...
That depends on if the lines are axis-aligned or not.
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.
Maybe openlayer/allegroGL is what you want?
My game supports OpenGL and software drivers. I need an additive blender line() function only for the software driver(Allegro + Fblend).
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.
Fblend has built in pixel functions too I believe.
After looking through the code I found it doesn't. So never mind that idea.
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.
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.
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.
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.
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
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.