51 procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL |
51 procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL |
52 procedure copyToXY(src, dest: PSDL_Surface; destX, destY: Integer); |
52 procedure copyToXY(src, dest: PSDL_Surface; destX, destY: Integer); |
53 procedure RenderHealth(var Hedgehog: THedgehog); |
53 procedure RenderHealth(var Hedgehog: THedgehog); |
54 procedure AddProgress; |
54 procedure AddProgress; |
55 procedure FinishProgress; |
55 procedure FinishProgress; |
56 function LoadImage(const filename: string; hasAlpha, critical, setTransparent: boolean): PSDL_Surface; |
56 function LoadImage(const filename: string; imageFlags: Integer): PSDL_Surface; |
57 procedure SetupOpenGL; |
57 procedure SetupOpenGL; |
58 procedure SetScale(f: GLfloat); |
58 procedure SetScale(f: GLfloat); |
59 |
59 |
60 |
60 |
61 var PixelFormat: PSDL_PixelFormat = nil; |
61 var PixelFormat: PSDL_PixelFormat = nil; |
172 if Gear <> nil then |
172 if Gear <> nil then |
173 begin |
173 begin |
174 NameTagTex:= RenderStringTex(Name, Clan^.Color, fnt16); |
174 NameTagTex:= RenderStringTex(Name, Clan^.Color, fnt16); |
175 if Hat <> 'NoHat' then |
175 if Hat <> 'NoHat' then |
176 begin |
176 begin |
177 texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, false, false, false); |
177 texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, ifNone); |
178 if texsurf <> nil then |
178 if texsurf <> nil then |
179 begin |
179 begin |
180 HatTex:= Surface2Tex(texsurf); |
180 HatTex:= Surface2Tex(texsurf); |
181 SDL_FreeSurface(texsurf) |
181 SDL_FreeSurface(texsurf) |
182 end |
182 end |
189 var t: LongInt; |
189 var t: LongInt; |
190 tmpsurf, texsurf: PSDL_Surface; |
190 tmpsurf, texsurf: PSDL_Surface; |
191 Color, i: Longword; |
191 Color, i: Longword; |
192 begin |
192 begin |
193 s:= Pathz[ptGraphics] + '/' + cCHFileName; |
193 s:= Pathz[ptGraphics] + '/' + cCHFileName; |
194 tmpsurf:= LoadImage(s, true, true, false); |
194 tmpsurf:= LoadImage(s, ifAlpha or ifCritical); |
195 |
195 |
196 for t:= 0 to Pred(TeamsCount) do |
196 for t:= 0 to Pred(TeamsCount) do |
197 with TeamsArray[t]^ do |
197 with TeamsArray[t]^ do |
198 begin |
198 begin |
199 texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, tmpsurf^.w, tmpsurf^.h, 32, RMask, GMask, BMask, AMask); |
199 texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, tmpsurf^.w, tmpsurf^.h, 32, RMask, GMask, BMask, AMask); |
244 for t:= 0 to Pred(TeamsCount) do |
244 for t:= 0 to Pred(TeamsCount) do |
245 if TeamsArray[t] <> nil then |
245 if TeamsArray[t] <> nil then |
246 with TeamsArray[t]^ do |
246 with TeamsArray[t]^ do |
247 begin |
247 begin |
248 if GraveName = '' then GraveName:= 'Simple'; |
248 if GraveName = '' then GraveName:= 'Simple'; |
249 texsurf:= LoadImage(Pathz[ptGraves] + '/' + GraveName, false, true, true); |
249 texsurf:= LoadImage(Pathz[ptGraves] + '/' + GraveName, ifCritical or ifTransparent); |
250 GraveTex:= Surface2Tex(texsurf); |
250 GraveTex:= Surface2Tex(texsurf); |
251 SDL_FreeSurface(texsurf) |
251 SDL_FreeSurface(texsurf) |
252 end |
252 end |
253 end; |
253 end; |
254 |
254 |
280 // FIXME - add a sprite attribute |
280 // FIXME - add a sprite attribute |
281 if (not cReducedQuality) or |
281 if (not cReducedQuality) or |
282 ((ii <> sprSky) and (ii <> sprHorizont) and (ii <> sprFlake)) then |
282 ((ii <> sprSky) and (ii <> sprHorizont) and (ii <> sprFlake)) then |
283 begin |
283 begin |
284 if AltPath = ptNone then |
284 if AltPath = ptNone then |
285 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, true, true, true) |
285 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifCritical or ifTransparent) |
286 else begin |
286 else begin |
287 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, true, false, true); |
287 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent); |
288 if tmpsurf = nil then |
288 if tmpsurf = nil then |
289 tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, true, true, true) |
289 tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifALpha or ifCritical or ifTransparent) |
290 end; |
290 end; |
291 if Width = 0 then Width:= tmpsurf^.w; |
291 if Width = 0 then Width:= tmpsurf^.w; |
292 if Height = 0 then Height:= tmpsurf^.h; |
292 if Height = 0 then Height:= tmpsurf^.h; |
293 Texture:= Surface2Tex(tmpsurf); |
293 Texture:= Surface2Tex(tmpsurf); |
294 if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf) |
294 if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf) |
295 end; |
295 end; |
296 |
296 |
297 AddProgress; |
297 AddProgress; |
298 |
298 |
299 tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, true, true, true); |
299 tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifCritical or ifTransparent); |
300 HHTexture:= Surface2Tex(tmpsurf); |
300 HHTexture:= Surface2Tex(tmpsurf); |
301 SDL_FreeSurface(tmpsurf); |
301 SDL_FreeSurface(tmpsurf); |
302 |
302 |
303 InitHealth; |
303 InitHealth; |
304 |
304 |
872 str(Hedgehog.Gear^.Health, s); |
872 str(Hedgehog.Gear^.Health, s); |
873 if Hedgehog.HealthTagTex <> nil then FreeTexture(Hedgehog.HealthTagTex); |
873 if Hedgehog.HealthTagTex <> nil then FreeTexture(Hedgehog.HealthTagTex); |
874 Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16) |
874 Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16) |
875 end; |
875 end; |
876 |
876 |
877 function LoadImage(const filename: string; hasAlpha: boolean; critical, setTransparent: boolean): PSDL_Surface; |
877 // hasAlpha: boolean; critical, setTransparent: boolean |
|
878 function LoadImage(const filename: string; imageFlags: Integer): PSDL_Surface; |
878 var tmpsurf: PSDL_Surface; |
879 var tmpsurf: PSDL_Surface; |
879 //Result: PSDL_Surface; |
880 //Result: PSDL_Surface; |
880 s: shortstring; |
881 s: shortstring; |
881 begin |
882 begin |
882 WriteToConsole(msgLoading + filename + '... '); |
883 WriteToConsole(msgLoading + filename + '... '); |
889 tmpsurf:= IMG_Load(Str2PChar(s)); |
890 tmpsurf:= IMG_Load(Str2PChar(s)); |
890 end; |
891 end; |
891 |
892 |
892 if tmpsurf = nil then |
893 if tmpsurf = nil then |
893 begin |
894 begin |
894 OutError(msgFailed, critical); |
895 OutError(msgFailed, (imageFlags and ifCritical) <> 0); |
895 exit(nil) |
896 exit(nil) |
896 end; |
897 end; |
897 |
898 |
898 if (tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize) then |
899 if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then |
899 begin |
900 begin |
900 SDL_FreeSurface(tmpsurf); |
901 SDL_FreeSurface(tmpsurf); |
901 OutError(msgFailedSize, critical); |
902 OutError(msgFailedSize, (imageFlags and ifCritical) <> 0); |
902 exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask)) |
903 exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask)) |
903 end; |
904 end; |
904 |
905 |
905 if setTransparent then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
906 if (imageFlags and ifTransparent) <> 0 then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
906 //if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf) |
907 //if (imageFlags and ifAlpha) <> 0 then Result:= SDL_DisplayFormatAlpha(tmpsurf) |
907 // else Result:= SDL_DisplayFormat(tmpsurf); |
908 // else Result:= SDL_DisplayFormat(tmpsurf); |
908 WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') '); |
909 WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') '); |
909 WriteLnToConsole(msgOK); |
910 WriteLnToConsole(msgOK); |
910 |
911 |
911 LoadImage:= tmpsurf //Result |
912 LoadImage:= tmpsurf //Result |
944 texsurf: PSDL_Surface; |
945 texsurf: PSDL_Surface; |
945 begin |
946 begin |
946 if Step = 0 then |
947 if Step = 0 then |
947 begin |
948 begin |
948 WriteToConsole(msgLoading + 'progress sprite: '); |
949 WriteToConsole(msgLoading + 'progress sprite: '); |
949 texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', false, true, true); |
950 texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent); |
950 ProgrTex:= Surface2Tex(texsurf); |
951 ProgrTex:= Surface2Tex(texsurf); |
951 SDL_FreeSurface(texsurf) |
952 SDL_FreeSurface(texsurf) |
952 end; |
953 end; |
953 |
954 |
954 glClear(GL_COLOR_BUFFER_BIT); |
955 glClear(GL_COLOR_BUFFER_BIT); |