296 else |
296 else |
297 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical or ifLowRes) |
297 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical or ifLowRes) |
298 else begin |
298 else begin |
299 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent); |
299 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent); |
300 if tmpsurf = nil then |
300 if tmpsurf = nil then |
301 tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent); |
301 tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent); |
302 end; |
302 end; |
303 |
303 |
304 if tmpsurf <> nil then |
304 if tmpsurf <> nil then |
305 begin |
305 begin |
306 {$IFDEF DARWIN} |
306 {$IFDEF DARWIN} |
307 {* this is a workaround for http://bugzilla.libsdl.org/show_bug.cgi?id=868 |
307 {* this is a workaround for http://bugzilla.libsdl.org/show_bug.cgi?id=868 |
308 remove this when it's fixed in upstream; it causes problems on ppc *} |
308 remove this when it's fixed in upstream *} |
309 tmpP := tmpsurf^.pixels; |
309 tmpP := tmpsurf^.pixels; |
310 for i:= 0 to (tmpsurf^.pitch shr 2) * tmpsurf^.h - 1 do |
310 for i:= 0 to (tmpsurf^.pitch shr 2) * tmpsurf^.h - 1 do |
|
311 begin |
|
312 {$IFDEF ENDIAN_LITTLE} |
|
313 tmpA:= tmpP^[i] shr 24 and $FF; |
|
314 tmpR:= tmpP^[i] shr 16 and $FF; |
|
315 tmpG:= tmpP^[i] shr 8 and $FF; |
|
316 tmpB:= tmpP^[i] and $FF; |
|
317 {$ELSE} |
|
318 tmpA:= tmpP^[i] and $FF; |
|
319 tmpR:= tmpP^[i] shr 8 and $FF; |
|
320 tmpG:= tmpP^[i] shr 16 and $FF; |
|
321 tmpB:= tmpP^[i] shr 24 and $FF; |
|
322 {$ENDIF} |
|
323 if tmpA <> 0 then |
311 begin |
324 begin |
312 tmpA:= tmpP^[i] shr 24 and $FF; |
325 tmpR:= round(tmpR * 255 / tmpA); |
313 tmpR:= tmpP^[i] shr 16 and $FF; |
326 tmpG:= round(tmpG * 255 / tmpA); |
314 tmpG:= tmpP^[i] shr 8 and $FF; |
327 tmpB:= round(tmpB * 255 / tmpA); |
315 tmpB:= tmpP^[i] and $FF; |
328 end; |
316 |
329 |
317 if tmpA <> 0 then |
330 if tmpR > 255 then tmpR:= 255; |
318 begin |
331 if tmpG > 255 then tmpG:= 255; |
319 tmpR:= round(tmpR * 255/tmpA); |
332 if tmpB > 255 then tmpB:= 255; |
320 tmpG:= round(tmpG * 255/tmpA); |
333 |
321 tmpB:= round(tmpB * 255/tmpA); |
334 {$IFDEF ENDIAN_LITTLE} |
322 end; |
335 tmpP^[i]:= (tmpA shl 24) or (tmpR shl 16) or (tmpG shl 8) or tmpB; |
323 |
336 {$ELSE} |
324 if tmpR > 255 then tmpR:= 255; |
337 tmpP^[i]:= (tmpA) or (tmpR shl 8) or (tmpG shl 16) or (tmpB shl 24); |
325 if tmpG > 255 then tmpG:= 255; |
338 {$ENDIF} |
326 if tmpB > 255 then tmpB:= 255; |
339 end; |
327 |
|
328 tmpP^[i]:= (tmpA shl 24) or (tmpR shl 16) or (tmpG shl 8) or tmpB; |
|
329 |
|
330 //AddFileLog(inttostr(tmpP^[i*128] shr 24) + ' | ' + inttostr(tmpP^[i*128] shr 16 and $FF) + ' | ' + inttostr(tmpP^[i*128] shr 8 and $FF)+ ' | ' + inttostr(tmpP^[i*128] and $FF)); |
|
331 end; |
|
332 {$ENDIF} |
340 {$ENDIF} |
333 |
341 |
334 if imageWidth = 0 then imageWidth := tmpsurf^.w; |
342 if imageWidth = 0 then imageWidth:= tmpsurf^.w; |
335 if imageHeight = 0 then imageHeight := tmpsurf^.h; |
343 if imageHeight = 0 then imageHeight:= tmpsurf^.h; |
336 if Width = 0 then Width:= tmpsurf^.w; |
344 if Width = 0 then Width:= tmpsurf^.w; |
337 if Height = 0 then Height:= tmpsurf^.h; |
345 if Height = 0 then Height:= tmpsurf^.h; |
338 if (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]) then |
346 if (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]) then |
339 Texture:= Surface2Tex(tmpsurf, true) |
347 Texture:= Surface2Tex(tmpsurf, true) |
340 else |
348 else |
341 begin |
349 begin |
342 Texture:= Surface2Tex(tmpsurf, false); |
350 Texture:= Surface2Tex(tmpsurf, false); |
343 if (ii = sprWater) and not cReducedQuality then // HACK: We should include some sprite attribute to define the texture wrap directions |
351 if (ii = sprWater) and not cReducedQuality then // HACK: We should include some sprite attribute to define the texture wrap directions |
|
352 begin |
|
353 tmpP := tmpsurf^.pixels; |
|
354 (* REMOVE ME WHEN BUG ABOVE IS FIXED |
|
355 for i:= 0 to (tmpsurf^.pitch shr 2) * tmpsurf^.h - 1 do |
|
356 begin |
|
357 tmpA:= tmpP^[i] shr 24 and $FF; |
|
358 tmpR:= tmpP^[i] shr 16 and $FF; |
|
359 tmpG:= tmpP^[i] shr 8 and $FF; |
|
360 tmpB:= tmpP^[i] and $FF; |
|
361 |
|
362 writeln(stdout, inttostr(tmpA) + ' | ' + inttostr(tmpR) + ' | ' + inttostr(tmpG)+ ' | ' + inttostr(tmpB)); |
|
363 end; |
|
364 *) |
344 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
365 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
|
366 end; |
345 end; |
367 end; |
346 if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf) |
368 if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf) |
347 end |
369 end |
348 else |
370 else |
349 Surface:= nil |
371 Surface:= nil |