From: DeaDDooMER Date: Sat, 12 Oct 2019 19:33:23 +0000 (+0300) Subject: fix android X-Git-Url: https://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=commitdiff_plain;h=4171d8dd0b8d733da27c584616e431811bf0fdcf fix android --- diff --git a/src/engine/e_sound_sdl.inc b/src/engine/e_sound_sdl.inc index ccfd9c4..175f474 100644 --- a/src/engine/e_sound_sdl.inc +++ b/src/engine/e_sound_sdl.inc @@ -181,7 +181,7 @@ begin {$IFDEF HEADLESS} // HACK: shit this into env and hope for the best SetEnvVar('SDL_AUDIODRIVER', 'dummy'); - {$ELSEIF} + {$ENDIF} if NoOutput then begin Result := true; Exit end; diff --git a/src/game/g_main.pas b/src/game/g_main.pas index 7d0dfb2..6a6df2a 100644 --- a/src/game/g_main.pas +++ b/src/game/g_main.pas @@ -84,22 +84,17 @@ begin {$ENDIF} e_WriteToStdOut := False; //{$IFDEF HEADLESS}True;{$ELSE}False;{$ENDIF} - e_WriteLog('Init Input', TMsgType.Notify); e_InitInput; - e_WriteLog('Read config file', TMsgType.Notify); + sys_Init; g_Options_Read(GameDir + '/' + CONFIG_FILENAME); - g_Console_SysInit; - - //GetSystemDefaultLCID() + if sys_SetDisplayMode(gScreenWidth, gScreenHeight, gBPP, gFullScreen) = False then + raise Exception.Create('Failed to set videomode on startup.'); - //e_WriteLog('Read language file', MSG_NOTIFY); - //g_Language_Load(DataDir + gLanguage + '.txt'); + g_Console_SysInit; e_WriteLog(gLanguage, TMsgType.Notify); g_Language_Set(gLanguage); - sys_Init; - {$IF not DEFINED(HEADLESS) and DEFINED(ENABLE_HOLMES)} flexloaded := true; if not fuiAddWad('flexui.wad') then diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 3ffef26..6cbc68e 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -2899,12 +2899,11 @@ begin begin Name := 'mOptionsControlsJoystickMenu'; for i := 0 to e_MaxJoys - 1 do - if e_JoystickAvailable[i] then - with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do - begin - Name := 'scDeadzone' + IntToStr(i); - Max := 20 - end + with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do + begin + Name := 'scDeadzone' + IntToStr(i); + Max := 20 + end end; Menu.DefControl := 'mOptionsControlsJoystickMenu'; g_GUI_AddWindow(Menu); diff --git a/src/game/g_options.pas b/src/game/g_options.pas index ac80a1b..f889ea3 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -125,13 +125,20 @@ var percentage: Integer; begin (* Display 0 = Primary display *) - SDL_GetDesktopDisplayMode(0, @display); - {$IF DEFINED(ANDROID)} + gScreenWidth := 640; + gScreenHeight := 480; + //gBPP := SDL_BITSPERPIXEL(dispaly.format); + gBPP := 32; + {$IFDEF ANDROID} + gFullScreen := True; (* rotation not allowed? *) + {$ELSE} + gFullScreen := False; + {$ENDIF} + if SDL_GetDesktopDisplayMode(0, @display) = 0 then + begin + {$IFDEF ANDROID} gScreenWidth := display.w; gScreenHeight := display.h; - //gBPP := SDL_BITSPERPIXEL(dispaly.format); - gBPP := 32; - gFullScreen := True; (* rotation not allowed? *) {$ELSE} (* Window must be smaller than display *) closest.w := display.w; @@ -156,9 +163,12 @@ begin gScreenWidth := closest.w; gScreenHeight := closest.h; //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *) - gBPP := 32; - gFullScreen := False; {$ENDIF} + end + else + begin + e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError]) + end; (* Must be positioned on primary display *) gWinRealPosX := SDL_WINDOWPOS_CENTERED; gWinRealPosY := SDL_WINDOWPOS_CENTERED; diff --git a/src/game/sdl/g_system.pas b/src/game/sdl/g_system.pas index 4120c02..4a4a3cb 100644 --- a/src/game/sdl/g_system.pas +++ b/src/game/sdl/g_system.pas @@ -41,6 +41,7 @@ implementation uses SysUtils, SDL, Math, + {$INCLUDE ../nogl/noGLuses.inc} e_log, e_graphics, e_input, e_sound, g_options, g_window, g_console, g_game, g_menu, g_gui, g_main; @@ -108,6 +109,9 @@ implementation screen := SDL_SetVideoMode(w, h, bpp, flags); if screen <> nil then begin + {$IFDEF USE_NOGL} + nogl_Init; + {$ENDIF} SDL_WM_SetCaption(GameTitle, nil); UpdateSize(w, h); result := True @@ -444,7 +448,7 @@ implementation (* --------- Init --------- *) procedure sys_Init; - var flags: Uint32; ok: Boolean; i: Integer; + var flags: Uint32; i: Integer; begin e_WriteLog('Init SDL', TMsgType.Notify); flags := SDL_INIT_VIDEO or SDL_INIT_AUDIO or @@ -452,9 +456,6 @@ implementation (*or SDL_INIT_NOPARACHUTE*); if SDL_Init(flags) <> 0 then raise Exception.Create('SDL: Init failed: ' + SDL_GetError); - ok := InitWindow(gScreenWidth, gScreenHeight, gBPP, gFullScreen); - if not ok then - raise Exception.Create('SDL: Failed to set videomode: ' + SDL_GetError); SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); for i := 0 to e_MaxJoys - 1 do @@ -467,7 +468,13 @@ implementation e_WriteLog('Releasing SDL', TMsgType.Notify); for i := 0 to e_MaxJoys - 1 do RemoveJoystick(i); - SDL_FreeSurface(screen); + if screen <> nil then + begin + {$IFDEF USE_NOGL} + nogl_Quit; + {$ENDIF} + SDL_FreeSurface(screen) + end; SDL_Quit end; diff --git a/src/game/sdl2/g_system.pas b/src/game/sdl2/g_system.pas index 3e55f45..9485fd9 100644 --- a/src/game/sdl2/g_system.pas +++ b/src/game/sdl2/g_system.pas @@ -42,6 +42,7 @@ implementation uses SysUtils, SDL2, Math, e_log, e_graphics, e_input, e_sound, + {$INCLUDE ../nogl/noGLuses.inc} {$IFDEF ENABLE_HOLMES} g_holmes, sdlcarcass, fui_ctls, {$ENDIF} @@ -87,7 +88,10 @@ implementation e_ResizeWindow(w, h); e_InitGL; g_Game_SetupScreenSize; - g_Menu_Reset; + {$IFNDEF ANDOIRD} + (* This will fix menu reset on keyboard showing *) + g_Menu_Reset; + {$ENDIF} g_Game_ClearLoading; {$IFDEF ENABLE_HOLMES} if assigned(oglInitCB) then oglInitCB; @@ -124,6 +128,9 @@ implementation context := SDL_GL_CreateContext(window); if context <> nil then begin + {$IFDEF USE_NOGL} + nogl_Init; + {$ENDIF} UpdateSize(w, h); result := true end @@ -445,7 +452,7 @@ implementation (* --------- Init --------- *) procedure sys_Init; - var flags: UInt32; ok: Boolean; + var flags: UInt32; begin e_WriteLog('Init SDL2', TMsgType.Notify); {$IFDEF HEADLESS} @@ -460,9 +467,6 @@ implementation SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, '0'); if SDL_Init(flags) <> 0 then raise Exception.Create('SDL: Init failed: ' + SDL_GetError); - ok := InitWindow(gScreenWidth, gScreenHeight, gBPP, gFullscreen); - if not ok then - raise Exception.Create('SDL: Failed to set videomode: ' + SDL_GetError); SDL_ShowCursor(SDL_DISABLE); end; @@ -470,11 +474,18 @@ implementation begin e_WriteLog('Releasing SDL2', TMsgType.Notify); if context <> nil then + begin + {$IFDEF USE_NOGL} + nogl_Quit; + {$ENDIF} SDL_GL_DeleteContext(context); + context := nil; + end; if window <> nil then + begin SDL_DestroyWindow(window); - window := nil; - context := nil; + window := nil; + end; SDL_Quit end; diff --git a/src/lib/enet/enet.pp b/src/lib/enet/enet.pp index f0c27be..cbb96b0 100644 --- a/src/lib/enet/enet.pp +++ b/src/lib/enet/enet.pp @@ -37,7 +37,7 @@ {$ENDIF} {$ELSE} {$IFDEF DARWIN} - {$LINKLIB libenet.a} + {$LINKLIB libenet} {$DEFINE libraryLibENetDecl := cdecl} {$DEFINE libraryLibENetImp := cdecl; external} {$DEFINE libraryLibENetVar := cvar; external} diff --git a/src/nogl/noGL.pas b/src/nogl/noGL.pas index 20d18bc..941c8d2 100644 --- a/src/nogl/noGL.pas +++ b/src/nogl/noGL.pas @@ -82,11 +82,16 @@ interface GL_KEEP = $1E00; GL_INCR = $1E02; GL_LINEAR = $2601; - GL_EXTENSIONS = $1F03; GL_TEXTURE_ENV = $2300; GL_TEXTURE_ENV_MODE = $2200; GL_MODULATE = $2100; + GL_VENDOR = $1F00; + GL_RENDERER = $1F01; + GL_VERSION = $1F02; + GL_EXTENSIONS = $1F03; + GL_SHADING_LANGUAGE_VERSION = $8B8C; + // const // GL_CULL_FACE = $0B44; // GL_FLOAT = $1406;