# HG changeset patch # User unc0rr # Date 1201454833 0 # Node ID cdc8f75ab7bc6897b9db51c8926d89d1a4aed6e7 # Parent a45111da760ec3d9d9f86f7cf413f82b66ed411d - Update land texture after explosions - Restore loading progress diff -r a45111da760e -r cdc8f75ab7bc hedgewars/hwengine.dpr --- a/hedgewars/hwengine.dpr Sun Jan 27 17:04:54 2008 +0000 +++ b/hedgewars/hwengine.dpr Sun Jan 27 17:27:13 2008 +0000 @@ -111,7 +111,6 @@ end; end; -//SDL_Flip(SDLPrimSurface); SDL_GL_SwapBuffers(); if flagMakeCapture then begin diff -r a45111da760e -r cdc8f75ab7bc hedgewars/uLand.pas --- a/hedgewars/uLand.pas Sun Jan 27 17:04:54 2008 +0000 +++ b/hedgewars/uLand.pas Sun Jan 27 17:27:13 2008 +0000 @@ -25,11 +25,12 @@ var Land: TLandArray; LandSurface: PSDL_Surface; - LandTexture: PTexture; + LandTexture: PTexture = nil; procedure GenMap; -function GenPreview: TPreview; +function GenPreview: TPreview; procedure CheckLandDigest(s: shortstring); +procedure UpdateLandTexture; implementation uses uConsole, uStore, uMisc, uRandom, uTeams, uLandObjects, uSHA, uIO; @@ -532,7 +533,7 @@ AddObjects(tmpsurf, LandSurface); SDL_FreeSurface(tmpsurf); -LandTexture:= Surface2Tex(LandSurface); +UpdateLandTexture; AddProgress end; @@ -554,7 +555,7 @@ BlitImageAndGenerateCollisionInfo(1024, 0, tmpsurf, LandSurface); SDL_FreeSurface(tmpsurf); -LandTexture:= Surface2Tex(LandSurface) +UpdateLandTexture end; procedure LoadMap; @@ -592,7 +593,7 @@ if SDL_MustLock(LandSurface) then SDL_UnlockSurface(LandSurface); -LandTexture:= Surface2Tex(LandSurface) +UpdateLandTexture end; procedure GenMap; @@ -628,6 +629,12 @@ GenPreview:= Preview end; +procedure UpdateLandTexture; +begin +if LandTexture <> nil then FreeTexture(LandTexture); +LandTexture:= Surface2Tex(LandSurface) +end; + initialization end. diff -r a45111da760e -r cdc8f75ab7bc hedgewars/uLandGraphics.pas --- a/hedgewars/uLandGraphics.pas Sun Jan 27 17:04:54 2008 +0000 +++ b/hedgewars/uLandGraphics.pas Sun Jan 27 17:27:13 2008 +0000 @@ -222,6 +222,8 @@ if SDL_MustLock(LandSurface) then SDL_UnlockSurface(LandSurface); + +UpdateLandTexture end; procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); @@ -252,6 +254,8 @@ if SDL_MustLock(LandSurface) then SDL_UnlockSurface(LandSurface); + +UpdateLandTexture end; // @@ -317,7 +321,9 @@ end; if SDL_MustLock(LandSurface) then - SDL_UnlockSurface(LandSurface) + SDL_UnlockSurface(LandSurface); + +UpdateLandTexture end; function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean; diff -r a45111da760e -r cdc8f75ab7bc hedgewars/uStore.pas --- a/hedgewars/uStore.pas Sun Jan 27 17:04:54 2008 +0000 +++ b/hedgewars/uStore.pas Sun Jan 27 17:27:13 2008 +0000 @@ -249,7 +249,10 @@ WriteLnToConsole(msgOK); val(s, cExplosionBorderColor, c); TryDo(c = 0, 'Theme data corrupted', true); - AdjustColor(cExplosionBorderColor); + cExplosionBorderColor:= SDL_MapRGB(LandSurface^.format, + cExplosionBorderColor shr 16, + cExplosionBorderColor shr 8, + cExplosionBorderColor and $FF); end; begin @@ -545,10 +548,7 @@ end; procedure SetupOpenGL; -//var aspect: real; begin -//aspect:= cScreenWidth / cScreenHeight; - glLoadIdentity; glViewport(0, 0, cScreenWidth, cScreenHeight); glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); @@ -558,32 +558,35 @@ end; //////////////////////////////////////////////////////////////////////////////// -var ProgrSurf: PSDL_Surface = nil; +var ProgrTex: PTexture = nil; Step: integer = 0; procedure AddProgress; var r: TSDL_Rect; + texsurf: PSDL_Surface; begin if Step = 0 then begin WriteToConsole(msgLoading + 'progress sprite: '); - ProgrSurf:= LoadImage(Pathz[ptGraphics] + '/Progress', false, true, true); + texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', false, true, true); + ProgrTex:= Surface2Tex(texsurf); + SDL_FreeSurface(texsurf) end; -SDL_FillRect(SDLPrimSurface, nil, 0); +glClear(GL_COLOR_BUFFER_BIT); r.x:= 0; -r.w:= ProgrSurf^.w; -r.h:= ProgrSurf^.w; -r.y:= (Step mod (ProgrSurf^.h div ProgrSurf^.w)) * ProgrSurf^.w; -//DrawFromRect((cScreenWidth - ProgrSurf^.w) div 2, -// (cScreenHeight - ProgrSurf^.w) div 2, @r, ProgrSurf, SDLPrimSurface); -SDL_Flip(SDLPrimSurface); +r.w:= ProgrTex^.w; +r.h:= ProgrTex^.w; +r.y:= (Step mod (ProgrTex^.h div ProgrTex^.w)) * ProgrTex^.w; +DrawFromRect((cScreenWidth - ProgrTex^.w) div 2, + (cScreenHeight - ProgrTex^.w) div 2, @r, ProgrTex, SDLPrimSurface); +SDL_GL_SwapBuffers(); inc(Step); end; procedure FinishProgress; begin WriteLnToConsole('Freeing progress surface... '); -SDL_FreeSurface(ProgrSurf) +FreeTexture(ProgrTex) end; end.