Results 1 to 1 of 1

Thread: Changing from fullscreen to window and vv

  1. #1

    Changing from fullscreen to window and vv

    System: Windows XP, P4 3GHz, nVidia 4400
    Compiler/IDE: Delphi 6 Personal
    API: DirectX 7 (DirectDraw)

    I'm working in an game using DirectDraw(not Direct 3D) and I have a little problem changing from fullscreen to window mode and vise-versa:

    If I'm in window mode and change to fullscreen the screen resolution changes correctly but nothing is drawn (I see the empty window background) Here is my code:


    Code:
    var
    g_pDD: IDirectDraw7 = nil; // DirectDraw object
    g_pDDSPrimary: IDirectDrawSurface7 = nil;// DirectDraw primary surface
    g_pDDScreen: IDirectDrawSurface7 = nil; // DirectDraw surface
    
    
    // ................
    ......
    procedure SetupDrirectDraw;
    begin
    .....
    end;
    
    procedure I_ChangeFullScreen;
    var
    hres: HRESULT;
    
    begin
    if fullscreen then
    begin
    hres := g_pDD.SetCooperativeLevel(hMainWnd, DDSCL_NORMAL);
    if hres <> DD_OK then
    begin
    Error;
    exit;
    end;
    end
    else
    begin
    hres := g_pDD.SetCooperativeLevel(hMainWnd, DDSCL_EXCLUSIVE or DDSCL_FULLSCREEN);
    if hres <> DD_OK then
    begin
    Error(true);
    exit;
    end;
    end;
    hres := g_pDD.SetDisplayMode(SCREENWIDTH, SCREENHEIGHT, 32, 0, 0);
    if hres <> DD_OK then
    Error(fullscreen);
    
    fullscreen := not fullscreen;
    end;


    The I_ChangeFullScreen procedure tries to change from fullscreen to window mode and from window to fullscreen. The error function never called (i.e. DirectDraw does not return an error) but when I call my drawing function nothing is drawn:

    Code:
    procedure I_FinishUpdate;
    var
    srcrect: TRect;
    begin
    
    srcrect.Left := 0;
    srcrect.Top := 0;
    srcrect.Right := SCREENWIDTH;
    srcrect.Bottom := SCREENHEIGHT;
    
    if g_pDDSPrimary.BltFast(0, 0, g_pDDScreen, srcrect, DDBLTFAST_DONOTWAIT or DDBLTFAST_NOCOLORKEY) = DDERR_SURFACELOST then
    g_pDDSPrimary.Restore;
    
    end;

    Starting the program I call the SetupDrirectDraw procedure that setup DirectDraw. After that everything works fine. But when the I_ChangeFullScreen() is called (using ALT+ENTER keys) the computer's monitor change resolution but nothing is drawn.

    The SCREENWIDTH and SCREENHEIGHT are 640 and 480.

    Any ideas?
    Last edited by Jimmy Valavanis; 30-03-2012 at 04:52 PM.

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
  •