hedgewars/uStore.pas
changeset 753 40fc0deb388f
parent 704 9b096d05004e
child 754 94ac14829085
equal deleted inserted replaced
752:69f1dc50a1fa 753:40fc0deb388f
    36 function  RenderString(s: string; Color: Longword; font: THWFont): PSDL_Surface;
    36 function  RenderString(s: string; Color: Longword; font: THWFont): PSDL_Surface;
    37 procedure RenderHealth(var Hedgehog: THedgehog);
    37 procedure RenderHealth(var Hedgehog: THedgehog);
    38 procedure AddProgress;
    38 procedure AddProgress;
    39 procedure FinishProgress;
    39 procedure FinishProgress;
    40 function  LoadImage(const filename: string; hasAlpha, critical, setTransparent: boolean): PSDL_Surface;
    40 function  LoadImage(const filename: string; hasAlpha, critical, setTransparent: boolean): PSDL_Surface;
       
    41 procedure SetupOpenGL;
    41 
    42 
    42 var PixelFormat: PSDL_PixelFormat;
    43 var PixelFormat: PSDL_PixelFormat;
    43  SDLPrimSurface: PSDL_Surface;
    44  SDLPrimSurface: PSDL_Surface;
    44    PauseSurface: PSDL_Surface;
    45    PauseSurface: PSDL_Surface;
    45 
    46 
    46 implementation
    47 implementation
    47 uses uMisc, uConsole, uLand, uLocale;
    48 uses uMisc, uConsole, uLand, uLocale, GL, GLU;
    48 
    49 
    49 var
    50 var
    50     HHSurface: PSDL_Surface;
    51     HHSurface: PSDL_Surface;
    51 
    52 
    52 procedure StoreInit;
    53 procedure StoreInit;
   204          1: cSkyColor:= PByte(p)^;
   205          1: cSkyColor:= PByte(p)^;
   205          2: cSkyColor:= PWord(p)^;
   206          2: cSkyColor:= PWord(p)^;
   206          3: cSkyColor:= (p^[0]) or (p^[1] shl 8) or (p^[2] shl 16);
   207          3: cSkyColor:= (p^[0]) or (p^[1] shl 8) or (p^[2] shl 16);
   207          4: cSkyColor:= PLongword(p)^;
   208          4: cSkyColor:= PLongword(p)^;
   208          end;
   209          end;
       
   210     glClearColor((cSkyColor shr 16) / 255, ((cSkyColor shr 8) and $FF) / 255, (cSkyColor and $FF) / 255, 0);
       
   211 
   209     if SDL_MustLock(SpritesData[sprSky].Surface) then
   212     if SDL_MustLock(SpritesData[sprSky].Surface) then
   210        SDL_UnlockSurface(SpritesData[sprSky].Surface)
   213        SDL_UnlockSurface(SpritesData[sprSky].Surface)
   211     end;
   214     end;
   212 
   215 
   213     procedure GetExplosionBorderColor;
   216     procedure GetExplosionBorderColor;
   358 end;
   361 end;
   359 
   362 
   360 procedure DrawLand(X, Y: LongInt; Surface: PSDL_Surface);
   363 procedure DrawLand(X, Y: LongInt; Surface: PSDL_Surface);
   361 const r: TSDL_Rect = (x: 0; y: 0; w: 2048; h: 1024);
   364 const r: TSDL_Rect = (x: 0; y: 0; w: 2048; h: 1024);
   362 begin
   365 begin
   363 DrawFromRect(X, Y, @r, LandSurface, Surface)
   366 glBindTexture(GL_TEXTURE_2D, LandTexture);
       
   367 glEnable(GL_TEXTURE_2D);
       
   368 
       
   369         glBegin(GL_QUADS);
       
   370 
       
   371         // top left
       
   372         glTexCoord2f(0, 0);
       
   373         glVertex2f(0, 0);
       
   374 
       
   375         // top right
       
   376         glTexCoord2f(1, 0);
       
   377         glVertex2f(1, 0);
       
   378 
       
   379         // bottom right
       
   380         glTexCoord2f(1, 1);
       
   381         glVertex2f(1, 1);
       
   382 
       
   383         // bottom left
       
   384         glTexCoord2f(0, 1);
       
   385         glVertex2f(0, 1);
       
   386 
       
   387         glEnd();
       
   388 //DrawFromRect(X, Y, @r, LandSurface, Surface)
   364 end;
   389 end;
   365 
   390 
   366 procedure DrawCentered(X, Top: LongInt; Source, Surface: PSDL_Surface);
   391 procedure DrawCentered(X, Top: LongInt; Source, Surface: PSDL_Surface);
   367 var r: TSDL_Rect;
   392 var r: TSDL_Rect;
   368 begin
   393 begin
   414 Hedgehog.HealthTag:= RenderString(s, Hedgehog.Team^.Clan^.Color, fnt16)
   439 Hedgehog.HealthTag:= RenderString(s, Hedgehog.Team^.Clan^.Color, fnt16)
   415 end;
   440 end;
   416 
   441 
   417 function  LoadImage(const filename: string; hasAlpha: boolean; critical, setTransparent: boolean): PSDL_Surface;
   442 function  LoadImage(const filename: string; hasAlpha: boolean; critical, setTransparent: boolean): PSDL_Surface;
   418 var tmpsurf: PSDL_Surface;
   443 var tmpsurf: PSDL_Surface;
   419     Result: PSDL_Surface;
   444     //Result: PSDL_Surface;
   420     s: shortstring;
   445     s: shortstring;
   421 begin
   446 begin
   422 WriteToConsole(msgLoading + filename + '... ');
   447 WriteToConsole(msgLoading + filename + '... ');
   423 s:= filename + '.' + cBitsStr + '.png';
   448 s:= filename + '.' + cBitsStr + '.png';
   424 tmpsurf:= IMG_Load(Str2PChar(s));
   449 tmpsurf:= IMG_Load(Str2PChar(s));
   435       WriteLnToConsole(msgFailed);
   460       WriteLnToConsole(msgFailed);
   436       exit(nil)
   461       exit(nil)
   437       end;
   462       end;
   438 
   463 
   439 if setTransparent then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
   464 if setTransparent then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
   440 if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf)
   465 //if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf)
   441             else Result:= SDL_DisplayFormat(tmpsurf);
   466 //            else Result:= SDL_DisplayFormat(tmpsurf);
   442 {$IFDEF DEBUGFILE}WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') ');{$ENDIF}
   467 {$IFDEF DEBUGFILE}WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') ');{$ENDIF}
   443 WriteLnToConsole(msgOK);
   468 WriteLnToConsole(msgOK);
   444 LoadImage:= Result
   469 LoadImage:= tmpsurf//Result
       
   470 end;
       
   471 
       
   472 procedure SetupOpenGL;
       
   473 var aspect: real;
       
   474 begin
       
   475 aspect:= cScreenWidth / cScreenHeight;
       
   476 
       
   477 glViewport(0, 0, cScreenWidth, cScreenHeight);
       
   478 
       
   479 //glMatrixMode(GL_PROJECTION);
       
   480 //glLoadIdentity();
       
   481 
       
   482 //gluPerspective(60.0, aspect, 0.1, 100.0);
       
   483 
       
   484 glMatrixMode(GL_MODELVIEW)
   445 end;
   485 end;
   446 
   486 
   447 ////////////////////////////////////////////////////////////////////////////////
   487 ////////////////////////////////////////////////////////////////////////////////
   448 var ProgrSurf: PSDL_Surface = nil;
   488 var ProgrSurf: PSDL_Surface = nil;
   449     Step: integer = 0;
   489     Step: integer = 0;