hedgewars/uStore.pas
changeset 2615 b86abe068708
parent 2612 60c7691c348f
child 2619 bc2786a00fb8
equal deleted inserted replaced
2614:6385b6dac259 2615:b86abe068708
   261 var ii: TSprite;
   261 var ii: TSprite;
   262     fi: THWFont;
   262     fi: THWFont;
   263     ai: TAmmoType;
   263     ai: TAmmoType;
   264     tmpsurf: PSDL_Surface;
   264     tmpsurf: PSDL_Surface;
   265     i: LongInt;
   265     i: LongInt;
   266 (* this is a workaround for http://bugzilla.libsdl.org/show_bug.cgi?id=868 remove this when it's fixed in upstream *)
   266 {$IFDEF IPHONEOS}
   267 {$IFDEF DARWIN}
       
   268 tmpP: PLongWordArray;
   267 tmpP: PLongWordArray;
   269 tmpA, tmpR, tmpG, tmpB: LongWord;
   268 tmpA, tmpR, tmpG, tmpB: LongWord;
   270 {$ENDIF}
   269 {$ENDIF}
   271 begin
   270 begin
   272 
   271 
   302 					tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent);
   301 					tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent);
   303 				end;
   302 				end;
   304 
   303 
   305 			if tmpsurf <> nil then
   304 			if tmpsurf <> nil then
   306 				begin
   305 				begin
   307 {$IFDEF DARWIN}   
   306 {$IFDEF IPHONEOS}   
   308 {* this is a workaround for http://bugzilla.libsdl.org/show_bug.cgi?id=868
   307 {* http://bugzilla.libsdl.org/show_bug.cgi?id=868 but patched library doesn't work on ipod, so implementing workaround here *}
   309    remove this when it's fixed in upstream *}
   308 				if (ifAlpha or ifTransparent) > 0 then
   310 				tmpP := tmpsurf^.pixels;
       
   311 				for i:= 0 to (tmpsurf^.pitch shr 2) * tmpsurf^.h - 1 do 
       
   312 				begin
   309 				begin
       
   310 					tmpP := tmpsurf^.pixels;
       
   311 					for i:= 0 to (tmpsurf^.pitch shr 2) * tmpsurf^.h - 1 do 
       
   312 					begin
   313 {$IFDEF ENDIAN_LITTLE}
   313 {$IFDEF ENDIAN_LITTLE}
   314 					tmpA:= tmpP^[i] shr 24 and $FF;
   314 						tmpA:= tmpP^[i] shr 24 and $FF;
   315 					tmpR:= tmpP^[i] shr 16 and $FF;
   315 						tmpR:= tmpP^[i] shr 16 and $FF;
   316 					tmpG:= tmpP^[i] shr 8 and $FF;
   316 						tmpG:= tmpP^[i] shr 8 and $FF;
   317 					tmpB:= tmpP^[i] and $FF;
   317 						tmpB:= tmpP^[i] and $FF;
   318 {$ELSE}
   318 {$ELSE}
   319 					tmpA:= tmpP^[i] and $FF;
   319 						tmpA:= tmpP^[i] and $FF;
   320 					tmpR:= tmpP^[i] shr 8 and $FF;
   320 						tmpR:= tmpP^[i] shr 8 and $FF;
   321 					tmpG:= tmpP^[i] shr 16 and $FF;
   321 						tmpG:= tmpP^[i] shr 16 and $FF;
   322 					tmpB:= tmpP^[i] shr 24 and $FF;
   322 						tmpB:= tmpP^[i] shr 24 and $FF;
   323 {$ENDIF}
   323 {$ENDIF}
   324 					if tmpA <> 0 then
   324 						if tmpA <> 0 then
   325 					begin
   325 						begin
   326 						tmpR:= round(tmpR * 255 / tmpA);
   326 							tmpR:= round(tmpR * 255 / tmpA);
   327 						tmpG:= round(tmpG * 255 / tmpA);
   327 							tmpG:= round(tmpG * 255 / tmpA);
   328 						tmpB:= round(tmpB * 255 / tmpA);
   328 							tmpB:= round(tmpB * 255 / tmpA);
       
   329 						end;
       
   330 
       
   331 						if tmpR > 255 then tmpR:= 255;
       
   332 						if tmpG > 255 then tmpG:= 255;
       
   333 						if tmpB > 255 then tmpB:= 255;
       
   334 
       
   335 {$IFDEF ENDIAN_LITTLE}
       
   336 						tmpP^[i]:= (tmpA shl 24) or (tmpR shl 16) or (tmpG shl 8) or tmpB;
       
   337 {$ELSE}
       
   338 						tmpP^[i]:= (tmpA) or (tmpR shl 8) or (tmpG shl 16) or (tmpB shl 24);
       
   339 {$ENDIF}
   329 					end;
   340 					end;
   330 
       
   331 					if tmpR > 255 then tmpR:= 255;
       
   332 					if tmpG > 255 then tmpG:= 255;
       
   333 					if tmpB > 255 then tmpB:= 255;
       
   334 
       
   335 {$IFDEF ENDIAN_LITTLE}
       
   336 					tmpP^[i]:= (tmpA shl 24) or (tmpR shl 16) or (tmpG shl 8) or tmpB;
       
   337 {$ELSE}
       
   338 					tmpP^[i]:= (tmpA) or (tmpR shl 8) or (tmpG shl 16) or (tmpB shl 24);
       
   339 {$ENDIF}
       
   340 				end;
   341 				end;
   341 {$ENDIF}
   342 {$ENDIF}
   342 				
   343 				
   343 				if imageWidth = 0 then imageWidth:= tmpsurf^.w;
   344 				if imageWidth = 0 then imageWidth:= tmpsurf^.w;
   344 				if imageHeight = 0 then imageHeight:= tmpsurf^.h;
   345 				if imageHeight = 0 then imageHeight:= tmpsurf^.h;
  1101 AddFileLog('OpenGL - GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize));
  1102 AddFileLog('OpenGL - GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize));
  1102 {$ENDIF}
  1103 {$ENDIF}
  1103 
  1104 
  1104 if MaxTextureSize = 0 then
  1105 if MaxTextureSize = 0 then
  1105 	begin
  1106 	begin
  1106 {$IFDEF DARWIN}
       
  1107 	MaxTextureSize:= 2048;
       
  1108 {$ELSE}
       
  1109 	MaxTextureSize:= 1024;
  1107 	MaxTextureSize:= 1024;
  1110 {$ENDIF}
       
  1111 {$IFDEF DEBUGFILE}
  1108 {$IFDEF DEBUGFILE}
  1112 	AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024');
  1109 	AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024');
  1113 {$ENDIF}
  1110 {$ENDIF}
  1114 	end;
  1111 	end;
  1115 
  1112