I am trying to draw a top down view of the ground in my game world by patching a bunch of tiles next to each other. The thing is that my world is out doors/natural and I don't like hard edges between my tiles. To solve this I would like to blend the colors from one tile into it's adjoining tile.
However the only way I can see to do this with allegro is to pull the RGB color values of a pixel from one tile and average it with the RGB values of another tile. Then making a new color from the averaged RGB values and put it where it belongs. Needless to say this is very slow and unacceptable for the speed I want my ground to scroll.
Is there anyway, with allegro, to draw a tile with Alpha softened edges? I will need a smooth Alpha transition like in a .tga file or else I would just use magenta .bmp files. I tried RTM but a function name would be most helpfull.
something like this ?
set_alpha_blender(); draw_trans_sprite( bmp , sprite -> spr[ frame ] , x - sprite -> x , y - sprite -> y );
The only thing I do not know ( If someone can tell ):
After a call to set_alpha_blender, can I use several call to draw_trans_sprite or do I need to call it each time before draw_trans_sprite ?
You need to call it only once. Better to pre-calculate the results, though. Allegro's blenders are really slow.
Wilson Saunders, could you tell us if the answer was the one you were waiting for ?
( Thanks Flad ;-) I only use allegro's blender as fallback, I tend to use allegrogl instead. )
Well I will try set_alph_blender() but I will need to know how you load a bmp which has an alpha layer. Also if blending is slow I may have to forgo this entirely. I am needing to do a lot of blends on 64x64 or 128x128 tiles. I guess the real test will be in game performance. I just got off my 10 hour shift at work so I am not going ot impliment this now.
For a map assuming 16x16 pixels, just make all the tiles 18x18 and make them overlap each other by that 1 extra pixel per side. Use draw_trans_sprite() to put them into their places, and the edges will blend by themselves.
Oh yea... the game might run a little slow, but that's alright, right?
Or draw the tiles so they wrap properly...