Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Light in Andorra.

General
Frozzy61
2012-08-24
2013-05-14
  • Frozzy61
    Frozzy61
    2012-08-24

    Hello.
    I have a question. Do Andorra has light?
    If yes, what kind of light Andorra has?
    And how to realize that?
    I saw the simples and find just:

    procedure TBall.DoDraw;
    var
      old: TAndorraColor;
    begin
      with Engine.Surface.Canvas do
      begin
        Brush.BlendMode := bmAdd;
        Brush.Color := Ad_ARGB(round(Alpha/2),255,255,255);
        Brush.GradientColor := Ad_ARGB(0,255,255,255);
        Pen.Style := apNone;
        Circle(BoundsRect.Left+round(Width/2),BoundsRect.Top+round(Height/2),300);
        Release;
        Brush.BlendMode := bmAlpha;
      end;
      Image.Color := Color;
      old := Engine.Surface.Scene.AmbientColor;
      Engine.Surface.Scene.AmbientColor := Ad_ARGB(255, 255, 255, 255);
      inherited DoDraw;
      Engine.Surface.Scene.AmbientColor := old;
    end;
    

    How to do light better.
    Also, in help I find type TAD2dLight, but I don't understand how to use that in 2d application. =( Help plz.

     
  • Hi,

    TAd2dLight realises per-vertex lighting and directly wraps around the corresponding 3D-API functions. If you want to use it, you might want to increae the vertex count of the TAdImage instances (there's a property for that, just don't know its name anymore) you're drawing.

    If you want to use per-pixel lighting, have a look at this post (it's in german though):
    http://www.delphipraxis.net/154186-%5Bandorra-2d%5D-licht-stufiger-uebergang-realisieren.html

     
  • Frozzy61
    Frozzy61
    2012-08-26

    igel457, Thank you very much.
    I have to use StencilBuffer.
    Am I understood rightly?

    P.S. I would appreciate If you give demo for this lighting.

     
  • Hi,

    yes, you can use the stencil buffer. Just in case you want to render a "soft" light (with gradient) you should use the "bmMultiply" technique discussed in the link above.

    Sorry that I can't provide a demo, I neither have a running Delphi-/Lazarus installation somwhere, nor do I have the time to setup one.

    I hope this helps a bit,
    Andreas