hedgewars/uStore.pas
branchhedgeroid
changeset 6023 a28be05b20bc
parent 5932 5164d17b6374
parent 6021 652a199d4f38
child 6025 cac1d5601d7c
equal deleted inserted replaced
5943:5b2b86a37089 6023:a28be05b20bc
   585     SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); // try to prefer hardware rendering
   585     SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); // try to prefer hardware rendering
   586 end;
   586 end;
   587 
   587 
   588 procedure SetupOpenGL;
   588 procedure SetupOpenGL;
   589 //var vendor: shortstring = '';
   589 //var vendor: shortstring = '';
   590 begin
   590 var buf: array[byte] of char;
       
   591 begin
       
   592     buf[0]:= char(0); // avoid compiler hint
       
   593     AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')');
       
   594 
   591 {$IFDEF SDL13}
   595 {$IFDEF SDL13}
   592     // this function creates an opengles1.1 context by default on mobile devices
   596     // this function creates an opengles1.1 context by default on mobile devices
   593     // use SDL_GL_SetAttribute to change this behaviour
   597     // use SDL_GL_SetAttribute to change this behaviour
   594     SDLGLcontext:=SDL_GL_CreateContext(SDLwindow);
   598     SDLGLcontext:=SDL_GL_CreateContext(SDLwindow);
   595     SDLTry(SDLGLcontext <> nil, true);
   599     SDLTry(SDLGLcontext <> nil, true);
   943 WeaponTooltipTex:= nil
   947 WeaponTooltipTex:= nil
   944 end;
   948 end;
   945 
   949 
   946 procedure chFullScr(var s: shortstring);
   950 procedure chFullScr(var s: shortstring);
   947 var flags: Longword = 0;
   951 var flags: Longword = 0;
   948     ico: PSDL_Surface;
   952     {$IFNDEF IPHONEOS}ico: PSDL_Surface;{$ENDIF}
   949     buf: array[byte] of char;
       
   950     reinit: boolean;
   953     reinit: boolean;
   951     {$IFDEF SDL13}x, y: LongInt;{$ENDIF}
   954     {$IFDEF SDL13}x, y: LongInt;{$ENDIF}
   952 begin
   955 begin
   953     if Length(s) = 0 then cFullScreen:= not cFullScreen
   956     if Length(s) = 0 then cFullScreen:= not cFullScreen
   954     else cFullScreen:= s = '1';
   957     else cFullScreen:= s = '1';
   955 
   958 
   956     buf[0]:= char(0); // avoid compiler hint
       
   957     AddFileLog('Preparing to change video parameters...');
   959     AddFileLog('Preparing to change video parameters...');
   958 
       
   959     reinit:= false;
   960     reinit:= false;
       
   961 {$IFNDEF IPHONEOS}
   960     if SDLPrimSurface = nil then
   962     if SDLPrimSurface = nil then
   961         begin
   963         begin
   962         // set window title
   964         // set window title
   963         SDL_WM_SetCaption('Hedgewars', nil);
   965         SDL_WM_SetCaption('Hedgewars', nil);
   964 {$IFDEF SDL_IMAGE_NEWER}
   966 {$IFDEF SDL_IMAGE_NEWER}
   988 {$ENDIF}
   990 {$ENDIF}
   989         AddFileLog('Freeing old primary surface...');
   991         AddFileLog('Freeing old primary surface...');
   990         SDL_FreeSurface(SDLPrimSurface);
   992         SDL_FreeSurface(SDLPrimSurface);
   991         SDLPrimSurface:= nil;
   993         SDLPrimSurface:= nil;
   992         end;
   994         end;
       
   995 {$ENDIF}
   993 
   996 
   994     // these attributes must be set up before creating the sdl window
   997     // these attributes must be set up before creating the sdl window
   995 {$IFNDEF WIN32}
   998 {$IFNDEF WIN32}
   996 (* On a large number of testers machines, SDL default to software rendering when opengl attributes were set.
   999 (* On a large number of testers machines, SDL default to software rendering when opengl attributes were set.
   997    These attributes were "set" after CreateWindow in .15, which probably did nothing.
  1000    These attributes were "set" after CreateWindow in .15, which probably did nothing.
  1012 
  1015 
  1013     SDL_SetHint('SDL_IOS_ORIENTATIONS','LandscapeLeft LandscapeRight');
  1016     SDL_SetHint('SDL_IOS_ORIENTATIONS','LandscapeLeft LandscapeRight');
  1014     flags:= flags or SDL_WINDOW_BORDERLESS or SDL_WINDOW_RESIZABLE;
  1017     flags:= flags or SDL_WINDOW_BORDERLESS or SDL_WINDOW_RESIZABLE;
  1015 {$ENDIF}
  1018 {$ENDIF}
  1016 
  1019 
  1017     if cFullScreen then SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cOrigScreenWidth, cOrigScreenHeight, flags or SDL_WINDOW_FULLSCREEN)
  1020     if SDLwindow = nil then
  1018     else SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags);
  1021         if cFullScreen then SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cOrigScreenWidth, cOrigScreenHeight, flags or SDL_WINDOW_FULLSCREEN)
       
  1022         else SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags);
  1019     SDLTry(SDLwindow <> nil, true);
  1023     SDLTry(SDLwindow <> nil, true);
  1020 {$ELSE}
  1024 {$ELSE}
  1021     flags:= SDL_OPENGL or SDL_RESIZABLE;
  1025     flags:= SDL_OPENGL or SDL_RESIZABLE;
  1022     if cFullScreen then
  1026     if cFullScreen then
  1023         flags:= flags or SDL_FULLSCREEN;
  1027         flags:= flags or SDL_FULLSCREEN;
  1032         SDLTry(SDLPrimSurface <> nil, true);
  1036         SDLTry(SDLPrimSurface <> nil, true);
  1033 {$IFDEF WIN32}SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));{$ENDIF}
  1037 {$IFDEF WIN32}SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));{$ENDIF}
  1034         end;
  1038         end;
  1035 {$ENDIF}
  1039 {$ENDIF}
  1036 
  1040 
  1037     AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')');
       
  1038     SetupOpenGL();
  1041     SetupOpenGL();
  1039     if reinit then
  1042     if reinit then
  1040         begin
  1043         begin
  1041         if SuddenDeathDmg then
  1044         if SuddenDeathDmg then
  1042              glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99)
  1045              glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99)