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

Thread: Fade and TRect and windowed mode

  1. #1

    Fade and TRect and windowed mode

    WinXP
    Delphi 6
    Lib: unDelphiX

    Hi everyone, I have the following constructor to implement a fade routine in my game made with DelphiX. Problem is that it only works in full screen mode and not windowed mode. It seems as if image rect tries to draw a rectangle over the whole screen area whereas I need it to draw a rectangle over the control’s client area (the window). Any help is appreciated :-)

    Code:
    Constructor TFade.Create(Parent: TSprite);
    var ImageRect : TRect;
        Alpha: integer;
    begin
      inherited Create(Parent);
      Alpha := Min(Round(255*0.3),255); 
      ImageRect.Left := round(0);
      ImageRect.Top := round(0);
      ImageRect.Right := ImageRect.Left + formGame.dxdrawgame.Width;
      ImageRect.Bottom := ImageRect.Top + formGame.dxdrawgame.Height;
      formGame.DXImageList.Items[formGame.fadingImageIndex].DrawAlpha(formGame.DXDrawGame.Surface,ImageRect,0,Alpha);
    end;
    Wake up from the dream and live your life to the full

  2. #2

    Fade and TRect and windowed mode

    This is really strange, if it works in full screen mode why not in windowed mode?

    And even more strange - it works on my LapTop in windowed mode but not on my PC ... same Delphi, same code and same unDelphiX and the same OS.

    Anyone here had the same problem?
    Wake up from the dream and live your life to the full

  3. #3

    Fade and TRect and windowed mode

    Got it to work by setting DoFullScreen and DoNoWindowChange and display to 1024 x 768. But, the solution is not desired as there is now an ugly transition from full screen to windowed mode before the app starts :twisted:

    So it would seem that the fade can only work properly in full screen mode on my pc, which is very irritating. Unless I'm missing something :?:
    Wake up from the dream and live your life to the full

  4. #4

    Fade and TRect and windowed mode

    Quote Originally Posted by Wizard
    ... there is now an ugly transition from full screen to windowed mode before the app starts :twisted:
    Sounds like badly initialized video, or it is done twice. Have you tried putting off Autoinitialize and then manually call DXDraw.Initialize in formCreate?

    Edit: Also you should check if resize events (form or DXDraw) do something undesired when app starts.

  5. #5

    Fade and TRect and windowed mode

    Thanks, it help's a bit but I can still see how it goes from full screen to the window and it's still ugly. And it's not initialized twice.

    I have no rezize events. This is what I now have in formCreate:
    Code:
      DXDrawGame.Finalize;
      RestoreWindow;
      DXDrawGame.Options := DXDrawGame.Options + [doFullScreen];
      DXDrawGame.Options := DXDrawGame.Options + [doNoWindowChange];
      DXDrawGame.Display.Width := 1024;
      DXDrawGame.Display.Height := 768;
      DXDrawGame.Display.BitCount := 16;
      DXDrawGame.Initialize;
    It works better but not perfectly, when the rezize finishes the icons on my desktop needs to be refreshed. So I suppose I have a choice between that and full screen mode. Unless there's another way to do fade in windowed mode?

    Thanks for your help!
    Wake up from the dream and live your life to the full

  6. #6

    Fade and TRect and windowed mode

    You can remove these lines i think
    [pascal]DXDrawGame.Finalize;
    RestoreWindow;[/pascal]

  7. #7

    Fade and TRect and windowed mode

    Thanks but I got it to work without initializing full screen. The following needs to be set to true in DXDraw options for the fade routine to work in windowed mode:

    doHardware, doDirectX7Mode and do3D, without these set to true it won't work.

    One more problem. I'm using stateMachines and now the fade screen is so fast between the title screen/fade/Play that you can hardly see it. However if I use sleep(1000) in the fade create it works and you can properly see the fade.

    My question is: is it safe to use sleep() like I'm doing? It seems to be working 100% without any errors...
    Wake up from the dream and live your life to the full

  8. #8

    Fade and TRect and windowed mode

    rather then use sleep, why not try a delay function, something like..

    [pascal]
    procedure Delay(secs: Cardinal);
    var
    tick: longint;
    begin
    tick := GetTickCount;
    while (GetTickCount-tick) < secs do Application.ProcessMessages;
    end;
    [/pascal]

    -MM

  9. #9

    Fade and TRect and windowed mode

    Ok, that also works and I suppose it's safer than sleep().

    Thanks!

    I now have:
    StartTime : cardinal;
    Duration : cardinal;
    where StartTime := 0 and
    Duration := 1000.

    Code:
    StartTime &#58;= GetTickCount;
      while &#40;GetTickCount - StartTime&#41; < Duration do
      begin
      application.ProcessMessages;
      end;
    Wake up from the dream and live your life to the full

  10. #10

    Fade and TRect and windowed mode

    for the sake of better assembling, it is worth removing the begin and end....

    Code:
    while &#40;GetTickCount - StartTime&#41; < Duration do
      Application.ProcessMessages;
    -MM

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
  •