hedgewars/uStore.pas
branchhedgeroid
changeset 5530 25d4118056e1
parent 5341 479b4108789a
parent 5518 4b0ea752dec7
child 5577 272c82f82cee
equal deleted inserted replaced
5516:8710987d3484 5530:25d4118056e1
   523         AddFileLog('OpenGL - "' + extension + '" failed to load');
   523         AddFileLog('OpenGL - "' + extension + '" failed to load');
   524 {$ENDIF}
   524 {$ENDIF}
   525 end;
   525 end;
   526 
   526 
   527 procedure SetupOpenGL;
   527 procedure SetupOpenGL;
   528 {$IFNDEF IPHONEOS}
   528 var vendor: shortstring = '';
   529 var vendor: shortstring;
       
   530 {$IFDEF DARWIN}
   529 {$IFDEF DARWIN}
   531 const one : LongInt = 1;
   530 const one : LongInt = 1;
   532 {$ENDIF}
   531 {$ENDIF}
   533 {$ENDIF}
   532 begin
   534 begin
   533 {$IFDEF SDL13}
   535 
   534     // this function creates an opengles1.1 context by default on mobile devices
   536 {$IFDEF MOBILE}
   535     // use SDL_GL_SetAttribute to change this behaviour
       
   536     SDLGLcontext:=SDL_GL_CreateContext(SDLwindow);
       
   537     SDLTry(SDLGLcontext <> nil, true);
       
   538     SDL_GL_SetSwapInterval(1);
       
   539 {$ENDIF}
       
   540 
       
   541 {$IFDEF IHPONE}
   537     SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
   542     SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
   538     SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1);
   543     SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1);
       
   544     vendor:= vendor; // avoid hint
       
   545     one:= one; // avoid hint
   539 {$ELSE}
   546 {$ELSE}
   540     SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
   547     SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
   541     vendor:= LowerCase(shortstring(pchar(glGetString(GL_VENDOR))));
   548     vendor:= LowerCase(shortstring(pchar(glGetString(GL_VENDOR))));
   542 {$IFNDEF SDL13}
   549 {$IFNDEF SDL13}
   543 // this attribute is default in 1.3 and must be enabled in MacOSX
   550 // this attribute is default in 1.3 and must be enabled in MacOSX
   707     r.h:= squaresize;
   714     r.h:= squaresize;
   708 
   715 
   709     DrawFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex);
   716     DrawFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex);
   710 
   717 
   711 {$IFDEF SDL13}
   718 {$IFDEF SDL13}
   712     SDL_RenderPresent(SDLrender);
   719     SDL_GL_SwapWindow(SDLwindow);
   713 {$ELSE}
   720 {$ELSE}
   714     SDL_GL_SwapBuffers();
   721     SDL_GL_SwapBuffers();
   715 {$ENDIF}
   722 {$ENDIF}
   716     inc(Step);
   723     inc(Step);
   717 
   724 
   812     r2:= r;
   819     r2:= r;
   813     if tmpline <> '' then
   820     if tmpline <> '' then
   814         begin
   821         begin
   815         r:= WriteInRect(tmpsurf, FontBorder + 2, r.y + r.h, $ff707070, font, tmpline);
   822         r:= WriteInRect(tmpsurf, FontBorder + 2, r.y + r.h, $ff707070, font, tmpline);
   816 
   823 
   817         // render highlighted caption (if there's a ':')
   824         // render highlighted caption (if there is a ':')
   818         tmpline2:= '';
   825         tmpline2:= '';
   819         SplitByChar(tmpline, tmpline2, ':');
   826         SplitByChar(tmpline, tmpline2, ':');
   820         if tmpline2 <> '' then
   827         if tmpline2 <> '' then
   821             WriteInRect(tmpsurf, FontBorder + 2, r2.y + r2.h, $ffc7c7c7, font, tmpline + ':');
   828             WriteInRect(tmpsurf, FontBorder + 2, r2.y + r2.h, $ffc7c7c7, font, tmpline + ':');
   822         end
   829         end
   866 if (CurrentTeam <> nil) and (Ammoz[atype].SkipTurns >= CurrentTeam^.Clan^.TurnNumber) then // weapon or utility is not yet available
   873 if (CurrentTeam <> nil) and (Ammoz[atype].SkipTurns >= CurrentTeam^.Clan^.TurnNumber) then // weapon or utility is not yet available
   867     begin
   874     begin
   868     extra:= trmsg[sidNotYetAvailable];
   875     extra:= trmsg[sidNotYetAvailable];
   869     extracolor:= LongInt($ffc77070);
   876     extracolor:= LongInt($ffc77070);
   870     end
   877     end
   871 else if (Ammoz[atype].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then // weapon or utility won't end your turn
   878 else if (Ammoz[atype].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then // weapon or utility will not end your turn
   872     begin
   879     begin
   873     extra:= trmsg[sidNoEndTurn];
   880     extra:= trmsg[sidNoEndTurn];
   874     extracolor:= LongInt($ff70c770);
   881     extracolor:= LongInt($ff70c770);
   875     end
   882     end
   876 else
   883 else
   955 {$IFDEF MOBILE}
   962 {$IFDEF MOBILE}
   956     // make the sdl window appear on the second monitor when present
   963     // make the sdl window appear on the second monitor when present
   957     x:= x or (SDL_GetNumVideoDisplays() - 1);
   964     x:= x or (SDL_GetNumVideoDisplays() - 1);
   958     y:= y or (SDL_GetNumVideoDisplays() - 1);
   965     y:= y or (SDL_GetNumVideoDisplays() - 1);
   959 
   966 
   960     // hardcode the opengles driver as we do our own drawing
   967     flags:= flags or SDL_WINDOW_BORDERLESS; // do not use SDL_WINDOW_RESIZABLE on ios (yet)
   961     SDL_SetHint('SDL_RENDER_DRIVER','opengles');
       
   962     flags:= flags or SDL_WINDOW_BORDERLESS;  // do not set SDL_WINDOW_RESIZABLE on iOS
       
   963 {$ENDIF}
   968 {$ENDIF}
   964 
   969 
   965     SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags);
   970     SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags);
   966     SDLTry(SDLwindow <> nil, true);
   971     SDLTry(SDLwindow <> nil, true);
   967     SDLrender:= SDL_CreateRenderer(SDLwindow, -1, SDL_RENDERER_ACCELERATED or SDL_RENDERER_PRESENTVSYNC);
       
   968     SDLTry(SDLrender <> nil, true);
       
   969 
       
   970     // clean the renderer before using it
       
   971     SDL_SetRenderDrawColor(SDLrender, 0, 0, 0, 255);
       
   972     SDL_RenderClear(SDLrender);
       
   973     SDL_RenderPresent(SDLrender);
       
   974 
       
   975     // reset the gl context from the one created by SDL (as we have our own drawing system)
       
   976     glMatrixMode(GL_PROJECTION);
       
   977     glLoadIdentity();
       
   978 {$ELSE}
   972 {$ELSE}
   979     if not cOnlyStats then
   973     if not cOnlyStats then
   980         begin
   974         begin
   981         SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
   975         SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
   982         SDLTry(SDLPrimSurface <> nil, true);
   976         SDLTry(SDLPrimSurface <> nil, true);