388 var ii: TSprite; |
388 var ii: TSprite; |
389 ai: TAmmoType; |
389 ai: TAmmoType; |
390 i, t: LongInt; |
390 i, t: LongInt; |
391 begin |
391 begin |
392 for ii:= Low(TSprite) to High(TSprite) do |
392 for ii:= Low(TSprite) to High(TSprite) do |
393 begin |
393 begin |
394 FreeTexture(SpritesData[ii].Texture); |
394 FreeTexture(SpritesData[ii].Texture); |
395 SpritesData[ii].Texture:= nil; |
395 SpritesData[ii].Texture:= nil; |
396 if SpritesData[ii].Surface <> nil then |
396 if SpritesData[ii].Surface <> nil then |
397 SDL_FreeSurface(SpritesData[ii].Surface); |
397 SDL_FreeSurface(SpritesData[ii].Surface); |
398 SpritesData[ii].Surface:= nil; |
398 SpritesData[ii].Surface:= nil; |
399 end; |
399 end; |
400 SDL_FreeSurface(MissionIcons); |
400 SDL_FreeSurface(MissionIcons); |
401 FreeTexture(ropeIconTex); |
401 FreeTexture(ropeIconTex); |
402 FreeTexture(HHTexture); |
402 FreeTexture(HHTexture); |
403 FreeTexture(PauseTexture); |
403 FreeTexture(PauseTexture); |
404 FreeTexture(ConfirmTexture); |
404 FreeTexture(ConfirmTexture); |
405 FreeTexture(SyncTexture); |
405 FreeTexture(SyncTexture); |
406 // free all ammo name textures |
406 // free all ammo name textures |
407 for ai:= Low(TAmmoType) to High(TAmmoType) do |
407 for ai:= Low(TAmmoType) to High(TAmmoType) do |
408 begin |
|
409 FreeTexture(Ammoz[ai].NameTex); |
408 FreeTexture(Ammoz[ai].NameTex); |
410 end; |
409 |
411 // free all count textures |
410 // free all count textures |
412 for i:= Low(CountTexz) to High(CountTexz) do |
411 for i:= Low(CountTexz) to High(CountTexz) do |
413 begin |
|
414 FreeTexture(CountTexz[i]); |
412 FreeTexture(CountTexz[i]); |
415 end; |
413 |
416 // free all team and hedgehog textures |
414 // free all team and hedgehog textures |
417 for t:= 0 to Pred(TeamsCount) do |
415 for t:= 0 to Pred(TeamsCount) do |
418 begin |
416 begin |
419 if TeamsArray[t] <> nil then |
417 if TeamsArray[t] <> nil then |
420 begin |
418 begin |
463 |
461 |
464 s:= filename + '.png'; |
462 s:= filename + '.png'; |
465 tmpsurf:= IMG_Load(Str2PChar(s)); |
463 tmpsurf:= IMG_Load(Str2PChar(s)); |
466 |
464 |
467 if tmpsurf = nil then |
465 if tmpsurf = nil then |
468 begin |
466 begin |
469 OutError(msgFailed, (imageFlags and ifCritical) <> 0); |
467 OutError(msgFailed, (imageFlags and ifCritical) <> 0); |
470 exit(nil) |
468 exit(nil) |
471 end; |
469 end; |
472 |
470 |
473 if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then |
471 if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then |
474 begin |
472 begin |
475 SDL_FreeSurface(tmpsurf); |
473 SDL_FreeSurface(tmpsurf); |
476 OutError(msgFailedSize, (imageFlags and ifCritical) <> 0); |
474 OutError(msgFailedSize, (imageFlags and ifCritical) <> 0); |
941 begin |
939 begin |
942 SDL_WM_SetIcon(ico, 0); |
940 SDL_WM_SetIcon(ico, 0); |
943 SDL_FreeSurface(ico) |
941 SDL_FreeSurface(ico) |
944 end; |
942 end; |
945 |
943 |
946 // set window caption |
944 // set window title |
947 SDL_WM_SetCaption('Hedgewars', nil); |
945 SDL_WM_SetCaption('Hedgewars', nil); |
948 |
946 |
949 if SDLPrimSurface <> nil then |
947 if SDLPrimSurface <> nil then |
950 begin |
948 begin |
951 AddFileLog('Freeing old primary surface...'); |
949 AddFileLog('Freeing old primary surface...'); |
970 SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags); |
968 SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags); |
971 SDLTry(SDLwindow <> nil, true); |
969 SDLTry(SDLwindow <> nil, true); |
972 {$ELSE} |
970 {$ELSE} |
973 if not cOnlyStats then |
971 if not cOnlyStats then |
974 begin |
972 begin |
|
973 {$IFDEF WIN32} |
|
974 s:= SDL_getenv('SDL_VIDEO_CENTERED'); |
|
975 SDL_putenv('SDL_VIDEO_CENTERED=1'); |
|
976 {$ENDIF} |
975 SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
977 SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
976 SDLTry(SDLPrimSurface <> nil, true); |
978 SDLTry(SDLPrimSurface <> nil, true); |
|
979 {$IFDEF WIN32}SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));{$ENDIF} |
977 end; |
980 end; |
978 {$ENDIF} |
981 {$ENDIF} |
979 |
982 |
980 AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')'); |
983 AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')'); |
981 SetupOpenGL(); |
984 SetupOpenGL(); |