Change brightness of blitted bitmap using Allegro
I'm using the Allegro game library to make a tile game. I want the tiles to get exponentially brighter. Unfortunately Allegro does not have a "Brighten" feature. What I then decided to do, was blit a tile to the buffer, then for each pixel that it just blited for that tile, I in开发者_开发知识库creased their rgb values and putpixel. The big problem with this is it severely decreased my framerate since it does twice as much work. Is there any way I can achieve this without having a tile bitmap for each tile that is slightly brighter (which would be ridiculous). Thanks
You can use:
draw_lit_sprite
what it does is take a BITMAP and draw it using a "light" that you have to set before by using this function:
set_trans_blender
so basically, what you have to do is:
//Init allegro code here
init_allegro_stuff();
//It takes as arguments red, green, blue, alpha
//so in this case it's a white light
set_trans_blender(255, 255, 255, 255);
//Draws the sprite like draw_sprite but with intensity
draw_lit_sprite(buffer, yourSprite, x, y, intensity);
hope it helps :)
It might be possible with palettes: http://alleg.sourceforge.net/stabledocs/en/alleg011.html
I don't know much about Allegro, but I know that in the 8-bit games of old, fading is usually accomplished by altering the color table that the video card reads from when rendering, hence giving a constant-time way to update many pixels on the screen simultaneously.
Hope that helps :)
精彩评论