X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_options.pas;h=86761de063a688abc621149e2b2adc531c906755;hb=a5056ac53bbdf8d6060df07a91ee318ba4feccf5;hp=42b3ef70704fe4fb9469680c8fbc802f83728a0a;hpb=92c7868df227201d6914f9f07c9a29ba0e2863cb;p=d2df-sdl.git diff --git a/src/game/g_options.pas b/src/game/g_options.pas index 42b3ef7..86761de 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -140,37 +140,53 @@ uses g_items, wadreader, e_graphics, g_touch, SDL2; procedure g_Options_SetDefaultVideo; -{$IF DEFINED(ANDROID)} var - display: PSDL_DisplayMode; -{$ENDIF} + target, closest, display: TSDL_DisplayMode; + percentage: Integer; begin + (* Display 0 = Primary display *) + SDL_GetDesktopDisplayMode(0, @display); {$IF DEFINED(ANDROID)} - (* On android set max screen size *) - SDL_GetCurrentDisplayMode(0, display); gScreenWidth := display.w; gScreenHeight := display.h; - gWinRealPosX := 0; - gWinRealPosY := 0; - gWinMaximized := False; - gFullScreen := False; (* if True then rotation not allowed *) + //gBPP := SDL_BITSPERPIXEL(dispaly.format); gBPP := 32; - gVSync := True; - gTextureFilter := True; - glLegacyNPOT := False; + gFullScreen := True; (* rotation not allowed? *) {$ELSE} - (* On other systems use default 800x600 *) - gScreenWidth := 800; - gScreenHeight := 600; - gWinRealPosX := 0; - gWinRealPosY := 0; - gWinMaximized := False; - gFullScreen := False; + (* Window must be smaller than display *) + closest.w := display.w; + closest.h := display.h; + percentage := 75; + while (display.w - closest.w < 48) or (display.h - closest.h < 48) do + begin + if percentage < 25 then + begin + closest.w := display.w * 75 div 100; + closest.h := display.h * 75 div 100; + break; + end; + target.w := display.w * percentage div 100; + target.h := display.h * percentage div 100; + target.format := 0; (* didn't care *) + target.refresh_rate := 0; (* didn't care *) + target.driverdata := nil; (* init *) + SDL_GetClosestDisplayMode(0, @target, @closest); + Dec(percentage); + end; + gScreenWidth := closest.w; + gScreenHeight := closest.h; + //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *) gBPP := 32; - gVSync := True; - gTextureFilter := True; - glLegacyNPOT := False; + gFullScreen := False; {$ENDIF} + (* Must be positioned on primary display *) + gWinRealPosX := SDL_WINDOWPOS_CENTERED; + gWinRealPosY := SDL_WINDOWPOS_CENTERED; + gWinMaximized := False; + gVSync := True; + gTextureFilter := True; + glLegacyNPOT := False; + e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight)); end; procedure g_Options_SetDefault();