|
[A5] Draw a red light on a bitmap |
anto80
Member #3,230
February 2003
|
Hello all, Since thread 615620 is locked, here is another chance for me to explain what I want to do.
In Allegro 4 in 256 colors, we were using draw_lit_sprite to do this. In Allegro 5, al_draw_tinted_bitmap can't do the job. I have read the al_set_blender documentation as well as other "Most helpful discussions" on al_set_blender page. How would I do this? Thank you ___________ |
Neil Roy
Member #2,229
April 2002
|
I would simply draw the red or white bitmap over the first at 50% transparency. In my own game I use al_draw_tinted_bitmap(bitmap, al_map_rgb_f(.5, .5, .5), x, y, 0); to draw something at 50% transparency. I also have the following settings for my game which would effect this... --- |
anto80
Member #3,230
February 2003
|
Thank you for your reply but I'm still confused. NiteHackr said: I would simply draw the red or white bitmap over the first at 50% transparency. In my own game I use al_draw_tinted_bitmap(bitmap, al_map_rgb_f(.5, .5, .5), x, y, 0); to draw something at 50% transparency.
Hmm when you say "the red or white bitmap", are you assuming that I must store 3 copies or the bitmap (the original, a full red one, and a full white one)? NiteHackr said: I also have the following settings for my game which would effect this...
Manual/5 said: ALLEGRO_MAG_LINEAR I don't see the point. Could you please explain? NiteHackr said: al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); Is this the way you can specify to display a red "version" of the sprite? ___________ |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Your best option was given to you in your last thread - use shaders. anto80 said: I don't see the point. Could you please explain? ALLEGRO_MAG_LINEAR is for when you are drawing magnified versions of your sprites - it uses smooth shading instead of blocky pixels. Quote: al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); Is this the way you can specify to display a red "version" of the sprite? No, what that does is set the blender for using premultiplied alpha. When using premultiplied alpha you specify colors by multiplying the rgb components by the alpha. float alpha = .75; ALLEGRO_COLOR c = al_map_rgba_f(alpha*red , alpha*green , alpha*blue , alpha); This will give you a 75% opaque color. Really, shaders are the way to go, because to 'light' your sprites you need to draw a light source over the top of them. One way is as NiteHackr suggests, to draw a light mask / map over your sprites. The second way is to use a shader, which you can set up to blend specified light levels with your sprites. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
anto80
Member #3,230
February 2003
|
OK I see now. and you certainly mean Shaders (which require to upgrade from 5.0 to the currently "unstable" 5.1 version) Is this correct? [Edit] But i can't compile (Error C1083: Cannot open include file: 'd3dx9.h': No such file or directory c:\allegro5-msvc9\include\allegro5\allegro_direct3d.h) c:\allegro5-msvc9\include\allegro5\allegro_direct3d.h: #include <d3d9.h> #if defined ALLEGRO_CFG_SHADER_HLSL && defined __cplusplus #include <d3dx9.h> #endif #include "allegro5/platform/alplatf.h"
What can I do ? ___________ |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You need DirectX to compile Allegro. You can get it here : Extract it and then merge the folders with the appropriate compiler folders. Or you can install the DirectX SDK. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Neil Roy
Member #2,229
April 2002
|
Ah, okay, you weren't very clear on what you wanted to do. But if you're sprites are not going to be that big, I don't know why you are worried about there being copies of them. You're not programming for DOS on an 8bit machine anymore. My video card alone has 2gigs of RAM which is more than enough for most graphics, they really don't take up that much space, especially smaller ones so I couldn't jump through hoops to limit numbers like that. For my own game I have a circle I use for different spawns, I made it a white one with some alpha for the transparent areas, then I can set the colour using Allegro. I use the MAG_LINEAR stuff because then I can adjust my sprite sizes for any resolution monitor and they will still look nice. These days that is a breeze for all video cards anyhow, even cheap ones. I would redesign how you plan to display them to make things simpler. Shaders would work, but if you are having a difficult time with the simple commands I laid out, than I wouldn't suggest going anywhere near shaders just yet. What you could do is just make a shaded white sphere, then when you draw it, set the colour to whatever you wish and it will be drawn that colour using a tinted sprite. This way you're using one sprite and you can make it any colour you wish at runtime. --- |
|