DEADSOFTWARE

sdl1/2: fix invalid window title
[d2df-sdl.git] / src / game / sdl / g_system.pas
index 7593b02398811605b2981aed31267e8760e8a20c..0df28dc724dc5b391f37dc85b7a8373a12070727 100644 (file)
@@ -103,7 +103,13 @@ implementation
       // store real window size in gWinSize, downscale resolution now
       w := round(w / r_pixel_scale);
       h := round(h / r_pixel_scale);
-      e_ResizeFramebuffer(w, h);
+      if not e_ResizeFramebuffer(w, h) then
+      begin
+        e_LogWriteln('GL: could not create framebuffer, falling back to --no-fbo');
+        glRenderToFBO := False;
+        w := gWinSizeX;
+        h := gWinSizeY;
+      end;
     end;
     gScreenWidth := w;
     gScreenHeight := h;
@@ -118,17 +124,17 @@ implementation
     g_Game_ClearLoading;
   end;
 
-  function GetTitle (): PChar;
+  function GetTitle (): AnsiString;
     var info: AnsiString;
   begin
     info := g_GetBuildHash(false);
     if info = 'custom build' then
       info := info + ' by ' + g_GetBuilderName() + ' ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME;
-    result := PChar(Format(GameTitle, [info]))
+    result := Format(GameTitle, [info]);
   end;
 
   function InitWindow (w, h, bpp: Integer; fullScreen: Boolean): Boolean;
-    var flags: Uint32;
+    var flags: Uint32; title: AnsiString;
   begin
     e_LogWritefln('InitWindow %s %s %s %s', [w, h, bpp, fullScreen]);
     result := false;
@@ -152,7 +158,8 @@ implementation
           e_LogWriteln('GL: unable to load OpenGL functions', TMsgType.Fatal);
           exit;
         end;
-        SDL_WM_SetCaption(GetTitle(), nil);
+        title := GetTitle();
+        SDL_WM_SetCaption(PChar(title), nil);
         gFullScreen := fullscreen;
         gRC_FullScreen := fullscreen;
         UpdateSize(w, h);
@@ -167,8 +174,6 @@ implementation
 
   procedure sys_Repaint;
   begin
-    if glRenderToFBO then
-      e_BlitFramebuffer(gWinSizeX, gWinSizeY);
     SDL_GL_SwapBuffers
   end;
 
@@ -180,7 +185,7 @@ implementation
   function sys_GetDisplayModes (bpp: Integer): SSArray;
     var m: PPSDL_Rect; f: TSDL_PixelFormat; i, count: Integer;
   begin
-    SetLength(result, 0);
+    result := nil;
     FillChar(f, sizeof(f), 0);
     f.palette := nil;
     f.BitsPerPixel := bpp;
@@ -445,9 +450,9 @@ implementation
       e_KeyUpDown(key, down);
       g_Console_ProcessBind(key, down);
     end
-    else if gConsoleShow or gChatShow or (g_ActiveWindow <> nil) then
+    else
     begin
-      KeyPress(key) // key repeat in menus and shit
+      g_Console_ProcessBindRepeat(key)
     end;
     if down and IsValid1251(ev.keysym.unicode) and IsPrintable1251(ch) then
       CharPress(ch)