Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Solution?

  1. #1

    Solution?

    Well, ive read and heard that DelphiX's FillRectAlpha method was slow as heck. And now that I actually try and use it, IT IS! In my RPG, I was trying to FillRectAlpha to darken the whole scene to simulate night time... And man it dropped to ~8 FPS... FROM 210 FPS! So im here hoping someone knows a better way to do the alpha recting, or possibly a suggestion on another way of darkening the picture to simulate night time. Thanks for all your help by the way, you've all be wonderfull here.
    I have a 2005 CRF 250 so <^>(>&lt<^>
    <br />http://www.gtrpg.com/

  2. #2

    Solution?

    Well, if you're using 8 Bit color mode, you can darken your image by darken the 256 colors in your palette. If you're using hi- or true color mode, you could try to do it manually by darkening each pixel of your image. Alpha blending requires more complicated calculations than darkening so you might be able to speed everything up if you do it yourself.
    Another alternative would be to use different wrappers. DelphiX is based on DirectDraw which doesn't use hardware acceleration for alpha blending. You could try DelphiX' Direct3D component, but I've never worked with that so I can't help you there.
    Ask me about the xcess game development kit

  3. #3

    Solution?

    Well i've been trying to darken every pixel, but.. imagine this.. can't figure out how to darken a TColor. Any idea?
    I have a 2005 CRF 250 so &lt;^&gt;(&gt;&lt&lt;^&gt;
    <br />http://www.gtrpg.com/

  4. #4

    Solution?

    [pascal]

    function ClipByte(X: Integer): Byte;
    begin
    if X > 255 then
    Result := 255
    else if X < 0 then
    Result := 0
    else
    Result := X;
    end;

    var
    Color, DarkenedColor: TColor;
    ColorInt: Integer;
    R, G, B: Byte;
    NewR, NewG, NewB: Byte;
    DarkenBy: Byte;
    begin
    DarkenBy := 10;
    ColorInt := ColorToRGB(Color);
    R := GetRValue(ColorInt);
    G := GetGValue(ColorInt);
    B := GetBValue(ColorInt);
    NewR := ClipByte(R - DarkenBy);
    NewG := ClipByte(G - DarkenBy);
    NewB := ClipByte(B - DarkenBy);
    DarkenedColor := RGB(NewR, NewG, NewB);
    end;

    [/pascal]
    Ask me about the xcess game development kit

  5. #5

    Solution?

    [pascal] r:= color and $ff;
    g:= color shr 8 and $ff;
    b:= color shr 16;
    dec(r, DarkenBy);
    dec(g, DarkenBy);
    dec(b, DarkenBy);
    if r<0 then r:= 0;
    if g<0 then g:= 0;
    if b<0 then b:= 0;
    color:= r or (g shl or (b shl 16);[/pascal]
    What Harray said only without function calls; r, g, b are integers
    edit: wrote and instead of or

  6. #6

    Solution?

    I really appreciate the help, but that ended up being slower then DelphiX's FillRectAlpha.... so, im still looking for a solution
    I have a 2005 CRF 250 so &lt;^&gt;(&gt;&lt&lt;^&gt;
    <br />http://www.gtrpg.com/

  7. #7

    Solution?

    Then I guess you'll have to say "goodbye" to DelphiX.
    Ask me about the xcess game development kit

  8. #8

    Solution?

    Or post you're surface darkening procedure and we'll try to optimize it.

  9. #9

  10. #10

    Solution?

    Well, it's basicly what you guys offered me above:

    [pascal]Procedure TConsole.FillRectDarken(Const DestRect: TRect; Const DarkenBy: Integer);
    Var
    Color: TColor;
    R, G, B, I, N: Integer;
    Begin

    For I := DestRect.Top to DestRect.Bottom Do
    For N := DestRect.Left to DestRect.Right Do
    Begin
    color := gmScreen.Surface.Pixels[N,I];
    r:= color and $ff;
    g:= color shr 8 and $ff;
    b:= color shr 16;
    dec(r, DarkenBy);
    dec(g, DarkenBy);
    dec(b, DarkenBy);
    if r<0 then r:= 0;
    if g<0 then g:= 0;
    if b<0 then b:= 0;
    gmScreen.Surface.Pixels[N,I]:= r and (g shl and (b shl 16);
    End;

    End;[/pascal]
    I have a 2005 CRF 250 so &lt;^&gt;(&gt;&lt&lt;^&gt;
    <br />http://www.gtrpg.com/

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •