996 else |
996 else |
997 cFullScreen:= s = '1'; |
997 cFullScreen:= s = '1'; |
998 |
998 |
999 AddFileLog('Preparing to change video parameters...'); |
999 AddFileLog('Preparing to change video parameters...'); |
1000 {$IFNDEF IPHONEOS} |
1000 {$IFNDEF IPHONEOS} |
|
1001 {$IFDEF SDL13} |
|
1002 if SDLwindow = nil then |
|
1003 {$ELSE} |
1001 if SDLPrimSurface = nil then |
1004 if SDLPrimSurface = nil then |
|
1005 {$ENDIF} |
1002 begin |
1006 begin |
1003 // set window title |
1007 // set window title |
1004 SDL_WM_SetCaption('Hedgewars', nil); |
1008 SDL_WM_SetCaption('Hedgewars', nil); |
1005 WriteToConsole('Init SDL_image... '); |
1009 WriteToConsole('Init SDL_image... '); |
1006 SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, true); |
1010 SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, true); |
1007 WriteLnToConsole(msgOK); |
1011 WriteLnToConsole(msgOK); |
1008 // load engine icon |
1012 // load engine icon |
1009 {$IFNDEF DARWIN} |
1013 {$IFNDEF DARWIN} |
1010 ico:= LoadImage(UserPathz[ptGraphics] + '/hwengine', ifIgnoreCaps); |
1014 ico:= LoadImage(UserPathz[ptGraphics] + '/hwengine', ifIgnoreCaps); |
1011 if ico = nil then |
1015 if ico = nil then |
1012 ico:= LoadImage(Pathz[ptGraphics] + '/hwengine', ifIgnoreCaps); |
1016 ico:= LoadImage(Pathz[ptGraphics] + '/hwengine', ifIgnoreCaps); |
1013 if ico <> nil then |
1017 if ico <> nil then |
1014 begin |
1018 begin |
1015 SDL_WM_SetIcon(ico, 0); |
1019 SDL_WM_SetIcon(ico, 0); |
1016 SDL_FreeSurface(ico) |
1020 SDL_FreeSurface(ico) |
1017 end; |
1021 end; |
1018 {$ENDIF} |
1022 {$ENDIF} |
1019 end |
1023 end |
1020 else |
1024 else |
1021 begin |
1025 begin |
1022 SetScale(cDefaultZoomLevel); |
1026 SetScale(cDefaultZoomLevel); |
1023 {$IF DEFINED(DARWIN) OR DEFINED(WIN32)} |
1027 {$IF DEFINED(DARWIN) OR DEFINED(WIN32) or DEFINED(ANDROID)} |
1024 reinit:= true; |
1028 reinit:= true; |
1025 StoreRelease(true); |
1029 StoreRelease(true); |
1026 ResetLand; |
1030 ResetLand; |
1027 ResetWorldTex; |
1031 ResetWorldTex; |
1028 //uTextures.freeModule; //DEBUG ONLY |
1032 //uTextures.freeModule; //DEBUG ONLY |
1029 {$ENDIF} |
1033 {$ENDIF} |
1030 AddFileLog('Freeing old primary surface...'); |
1034 AddFileLog('Freeing old primary surface...'); |
1031 SDL_FreeSurface(SDLPrimSurface); |
1035 SDL_FreeSurface(SDLPrimSurface); |
1032 SDLPrimSurface:= nil; |
1036 SDLPrimSurface:= nil; |
1033 end; |
1037 end; |
1034 {$ENDIF} |
1038 {$ENDIF} |
1045 // these values in x and y make the window appear in the center |
1049 // these values in x and y make the window appear in the center |
1046 x:= SDL_WINDOWPOS_CENTERED_MASK; |
1050 x:= SDL_WINDOWPOS_CENTERED_MASK; |
1047 y:= SDL_WINDOWPOS_CENTERED_MASK; |
1051 y:= SDL_WINDOWPOS_CENTERED_MASK; |
1048 flags:= SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN; |
1052 flags:= SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN; |
1049 |
1053 |
1050 {$IFDEF MOBILE} |
1054 {$IFDEF MOBILE} |
1051 // make the sdl window appear on the second monitor when present |
1055 // make the sdl window appear on the second monitor when present |
1052 x:= x or (SDL_GetNumVideoDisplays() - 1); |
1056 x:= x or (SDL_GetNumVideoDisplays() - 1); |
1053 y:= y or (SDL_GetNumVideoDisplays() - 1); |
1057 y:= y or (SDL_GetNumVideoDisplays() - 1); |
1054 |
1058 |
1055 SDL_SetHint('SDL_IOS_ORIENTATIONS','LandscapeLeft LandscapeRight'); |
1059 SDL_SetHint('SDL_IOS_ORIENTATIONS','LandscapeLeft LandscapeRight'); |
1056 flags:= flags or SDL_WINDOW_BORDERLESS or SDL_WINDOW_RESIZABLE; |
1060 flags:= flags or SDL_WINDOW_BORDERLESS or SDL_WINDOW_RESIZABLE; |
1057 {$ENDIF} |
1061 {$ENDIF} |
1058 |
1062 |
1059 if SDLwindow = nil then |
1063 if SDLwindow = nil then |
1060 if cFullScreen then |
1064 if cFullScreen then |
1061 SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cOrigScreenWidth, cOrigScreenHeight, flags or SDL_WINDOW_FULLSCREEN) |
1065 SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cOrigScreenWidth, cOrigScreenHeight, flags or SDL_WINDOW_FULLSCREEN) |
1062 else |
1066 else |
1067 if cFullScreen then |
1071 if cFullScreen then |
1068 flags:= flags or SDL_FULLSCREEN; |
1072 flags:= flags or SDL_FULLSCREEN; |
1069 |
1073 |
1070 if not cOnlyStats then |
1074 if not cOnlyStats then |
1071 begin |
1075 begin |
1072 {$IFDEF WIN32} |
1076 {$IFDEF WIN32} |
1073 s:= SDL_getenv('SDL_VIDEO_CENTERED'); |
1077 s:= SDL_getenv('SDL_VIDEO_CENTERED'); |
1074 SDL_putenv('SDL_VIDEO_CENTERED=1'); |
1078 SDL_putenv('SDL_VIDEO_CENTERED=1'); |
1075 {$ENDIF} |
1079 {$ENDIF} |
1076 SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
1080 SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
1077 SDLTry(SDLPrimSurface <> nil, true); |
1081 SDLTry(SDLPrimSurface <> nil, true); |
1078 {$IFDEF WIN32}SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));{$ENDIF} |
1082 {$IFDEF WIN32}SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));{$ENDIF} |
1079 end; |
1083 end; |
1080 {$ENDIF} |
1084 {$ENDIF} |
1081 |
1085 |
1082 SetupOpenGL(); |
1086 SetupOpenGL(); |
1083 if reinit then |
1087 if reinit then |