Results 1 to 1 of 1

Thread: Fullscreen mode

  1. #1

    Fullscreen mode

    I don't wish to continue a whole topic in nxPascal thread, so here's more. Maybe it also makes it easier to find it with forum search. I tested what happens if i have some textures on screen, and make F1 key switch from normal window to fullscreen, and back to normal window with another F1 press. The code works, but you need to know that all the textures are manually reloaded in the process.

    Code:
    procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    begin
      if game<>nil then begin
        game.KeyDown(key, shift);
        case key of
          VK_F1: begin
            if BorderStyle<>bsNone then begin
              BorderStyle:=bsNone;
              WindowState:=wsMaximized;
            end else begin
              WindowState:=wsNormal;
              BorderStyle:=bsSizeable; // Or you might use a variable to store the last style
              // Good to note that BorderStyle must be set after Windowstate, or your form will
              // not remember its old size and remain fullscreen sized bordered window.
            end;
    
            nx.KillGLWindow(true);
            // Force parameter is available in next SVN release.
            // Without it, it doesn't .Free the LazOpenGLContext, leaving it as "ghost" behind.
            // Mainform would destroy it on application exit though, but that's a problem
            // if you switch the mode many times in 1 run (normally people don't).
    
            nx.CreateGlWindow(self);
            game.Create;
            // All textures and gl stuff are lost, and in need of recreation. Even simple command like
            // nx.SetClearColor(0.1, 0.2, 0.4); must be called again.
            // Curious thing is that i call a constructor through existing object, i assume it doesn't
            // actually create a new object, but call it as a procedure.
    
          end;
          VK_ESCAPE: Close;
        end;
      end;
    end;
    As you see from the code, switching to maximized fullscreen mode isn't something that i can just implement a SetFullscreen(enable: boolean) function. It depends on your own application implementation. But also notably it seems easy if you use the gametemplate demo as a base, or similar structuring of your code.

    edit: Scrap that, i can put all apart game.Create; in a function.

    Simplified:
    Code:
          VK_F1: begin
            nx.ToggleMaxFullscreen;
            game.Create;
          end;
    There is also SetMaxFullscreen(enable: boolean), which is used by toggle.
    Last edited by User137; 28-11-2012 at 06:15 AM.

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
  •