DEADSOFTWARE

Game: Fixed missing check for the availability of stencil buffer
[d2df-sdl.git] / src / game / sdl2 / g_system.pas
index 8842b6794b7362b7cf4860c09abacbbaa0ca91f4..b3005d56b637b464dfa8341f756ef63c12ba21f7 100644 (file)
@@ -75,12 +75,22 @@ implementation
   (* --------- Graphics --------- *)
 
   function LoadGL: Boolean;
+  {$IFNDEF NOGL_INIT}
+  var
+    ltmp: Integer;
+  {$ENDIF}
   begin
     result := true;
     {$IFDEF NOGL_INIT}
     nogl_Init;
     if glRenderToFBO and (not nogl_ExtensionSupported('GL_OES_framebuffer_object')) then
     {$ELSE}
+    if SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, @ltmp) = 0 then
+    begin
+      e_LogWritefln('stencil buffer size: %s', [ltmp]);
+      gwin_has_stencil := (ltmp > 0);
+    end;
+
     if glRenderToFBO and (not Load_GL_ARB_framebuffer_object) then
     {$ENDIF}
     begin
@@ -134,17 +144,17 @@ implementation
     {$ENDIF}
   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, maximized: Boolean): Boolean;
-    var flags: UInt32; x, y: cint;
+    var flags: UInt32; x, y: cint; title: AnsiString;
   begin
     // note: on window close make: if assigned(oglDeinitCB) then oglDeinitCB;
     e_LogWritefln('InitWindow %s %s %s %s', [w, h, bpp, fullScreen]);
@@ -178,7 +188,8 @@ implementation
         x := wx;
         y := wy
       end;
-      window := SDL_CreateWindow(GetTitle(), x, y, w, h, flags);
+      title := GetTitle();
+      window := SDL_CreateWindow(PChar(title), x, y, w, h, flags);
       if window <> nil then
       begin
         context := SDL_GL_CreateContext(window);
@@ -507,9 +518,11 @@ 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
+      if g_dbg_input then
+        e_LogWritefln('Input Debug: keyrep, scancode=%s', [key]);
+      g_Console_ProcessBindRepeat(key);
     end
   end;