aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes/UTexture.pas
diff options
context:
space:
mode:
authork-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-05-24 18:55:02 +0000
committerk-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-05-24 18:55:02 +0000
commit83402238f4c9fdc07d633d9748e3a596e01a3174 (patch)
treee931ce67c07a0b252f49d8592bcdb9b0a9c146e3 /Game/Code/Classes/UTexture.pas
parent2690a0ef36afe8983ee82673310739eba16cc21b (diff)
downloadusdx-83402238f4c9fdc07d633d9748e3a596e01a3174.tar.gz
usdx-83402238f4c9fdc07d633d9748e3a596e01a3174.tar.xz
usdx-83402238f4c9fdc07d633d9748e3a596e01a3174.zip
final removal of Macresources, indentation
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1134 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/Classes/UTexture.pas')
-rw-r--r--Game/Code/Classes/UTexture.pas84
1 files changed, 45 insertions, 39 deletions
diff --git a/Game/Code/Classes/UTexture.pas b/Game/Code/Classes/UTexture.pas
index d5926e45..3028fb71 100644
--- a/Game/Code/Classes/UTexture.pas
+++ b/Game/Code/Classes/UTexture.pas
@@ -131,9 +131,6 @@ uses ULog,
DateUtils,
UCovers,
UThemes,
- {$IFDEF DARWIN}
- // MacResources,
- {$ENDIF}
StrUtils;
Constructor TTextureUnit.Create;
@@ -266,9 +263,9 @@ begin
for PixelIndex := 0 to (TexSurface^.W * TexSurface^.H)-1 do
begin
PixelColors := PByteArray(Pixel);
- // inlined colorize per pixel
+ // inlined colorize per pixel
- // uses fixed point math
+ // uses fixed point math
// get color values
clr2[0] := PixelColors[0] shl 10;
clr2[1] := PixelColors[1] shl 10;
@@ -284,29 +281,32 @@ begin
delta2 := max2-delta2;
hsv2[0] := dhue; // shl 8
hsv2[2] := max2; // shl 8
- if (max2 = 0) then hsv2[1] := 0
- else hsv2[1] := (delta2 shl 10) div max2; // shl 8
- h_int := hsv2[0] and $fffffC00;
- f2 := hsv2[0]-h_int; //shl 10
- p2 := (hsv2[2]*(1024-hsv2[1])) shr 10;
- q2 := (hsv2[2]*(1024-(hsv2[1]*f2) shr 10)) shr 10;
- t2 := (hsv2[2]*(1024-(hsv2[1]*(1024-f2)) shr 10)) shr 10;
- h_int := h_int shr 10;
- case h_int of
- 0: begin clr2[0] := hsv2[2]; clr2[1] := t2; clr2[2] := p2; end; // (v,t,p)
- 1: begin clr2[0] := q2; clr2[1] := hsv2[2]; clr2[2] := p2; end; // (q,v,p)
- 2: begin clr2[0] := p2; clr2[1] := hsv2[2]; clr2[2] := t2; end; // (p,v,t)
- 3: begin clr2[0] := p2; clr2[1] := q2; clr2[2] := hsv2[2]; end; // (p,q,v)
- 4: begin clr2[0] := t2; clr2[1] := p2; clr2[2] := hsv2[2]; end; // (t,p,v)
- 5: begin clr2[0] := hsv2[2]; clr2[1] := p2; clr2[2] := q2; end; // (v,p,q)
- end;
+ if (max2 = 0) then
+ hsv2[1] := 0
+ else
+ hsv2[1] := (delta2 shl 10) div max2; // shl 8
+ h_int := hsv2[0] and $fffffC00;
+ f2 := hsv2[0]-h_int; //shl 10
+ p2 := (hsv2[2]*(1024-hsv2[1])) shr 10;
+ q2 := (hsv2[2]*(1024-(hsv2[1]*f2) shr 10)) shr 10;
+ t2 := (hsv2[2]*(1024-(hsv2[1]*(1024-f2)) shr 10)) shr 10;
+ h_int := h_int shr 10;
+ case h_int of
+ 0: begin clr2[0] := hsv2[2]; clr2[1] := t2; clr2[2] := p2; end; // (v,t,p)
+ 1: begin clr2[0] := q2; clr2[1] := hsv2[2]; clr2[2] := p2; end; // (q,v,p)
+ 2: begin clr2[0] := p2; clr2[1] := hsv2[2]; clr2[2] := t2; end; // (p,v,t)
+ 3: begin clr2[0] := p2; clr2[1] := q2; clr2[2] := hsv2[2]; end; // (p,q,v)
+ 4: begin clr2[0] := t2; clr2[1] := p2; clr2[2] := hsv2[2]; end; // (t,p,v)
+ 5: begin clr2[0] := hsv2[2]; clr2[1] := p2; clr2[2] := q2; end; // (v,p,q)
+ end;
PixelColors[0] := clr2[0] shr 10;
PixelColors[1] := clr2[1] shr 10;
PixelColors[2] := clr2[2] shr 10;
// old floating point version
-(* clr[0] := PixelColors[0]/255;
+(*
+ clr[0] := PixelColors[0]/255;
clr[1] := PixelColors[1]/255;
clr[2] := PixelColors[2]/255;
max := maxvalue(clr);
@@ -315,23 +315,25 @@ begin
hsv[0] := DestinationHue; // set H(ue)
hsv[2] := max; // set V(alue)
// calc S(aturation)
- if (max = 0.0) then hsv[1] := 0.0
- else hsv[1] := delta/max;
+ if (max = 0.0) then
+ hsv[1] := 0.0
+ else
+ hsv[1] := delta/max;
// ColorizePixel(PByteArray(Pixel), DestinationHue);
- h_int := trunc(hsv[0]); // h_int = |_h_|
- f := hsv[0]-h_int; // f = h-h_int
- p := hsv[2]*(1.0-hsv[1]); // p = v*(1-s)
- q := hsv[2]*(1.0-(hsv[1]*f)); // q = v*(1-s*f)
- t := hsv[2]*(1.0-(hsv[1]*(1.0-f))); // t = v*(1-s*(1-f))
- case h_int of
- 0: begin clr[0] := hsv[2]; clr[1] := t; clr[2] := p; end; // (v,t,p)
- 1: begin clr[0] := q; clr[1] := hsv[2]; clr[2] := p; end; // (q,v,p)
- 2: begin clr[0] := p; clr[1] := hsv[2]; clr[2] := t; end; // (p,v,t)
- 3: begin clr[0] := p; clr[1] := q; clr[2] := hsv[2]; end; // (p,q,v)
- 4: begin clr[0] := t; clr[1] := p; clr[2] := hsv[2]; end; // (t,p,v)
- 5: begin clr[0] := hsv[2]; clr[1] := p; clr[2] := q; end; // (v,p,q)
- end;
+ h_int := trunc(hsv[0]); // h_int = |_h_|
+ f := hsv[0]-h_int; // f = h-h_int
+ p := hsv[2]*(1.0-hsv[1]); // p = v*(1-s)
+ q := hsv[2]*(1.0-(hsv[1]*f)); // q = v*(1-s*f)
+ t := hsv[2]*(1.0-(hsv[1]*(1.0-f))); // t = v*(1-s*(1-f))
+ case h_int of
+ 0: begin clr[0] := hsv[2]; clr[1] := t; clr[2] := p; end; // (v,t,p)
+ 1: begin clr[0] := q; clr[1] := hsv[2]; clr[2] := p; end; // (q,v,p)
+ 2: begin clr[0] := p; clr[1] := hsv[2]; clr[2] := t; end; // (p,v,t)
+ 3: begin clr[0] := p; clr[1] := q; clr[2] := hsv[2]; end; // (p,q,v)
+ 4: begin clr[0] := t; clr[1] := p; clr[2] := hsv[2]; end; // (t,p,v)
+ 5: begin clr[0] := hsv[2]; clr[1] := p; clr[2] := q; end; // (v,p,q)
+ end;
// and store new rgb back into the image
PixelColors[0] := trunc(255*clr[0]);
@@ -552,7 +554,8 @@ begin
Log.BenchmarkEnd(4);
if Log.BenchmarkTimeLength[4] >= 1 then
Log.LogBenchmark('**********> Texture Load Time Warning - ' + Identifier + '/' + TextureTypeToStr(Typ), 4)
- else Log.LogBenchmark('**********> Texture Load Time ' + ExtractFileName(Identifier) + '/' + TextureTypeToStr(Typ), 4);
+ else
+ Log.LogBenchmark('**********> Texture Load Time ' + ExtractFileName(Identifier) + '/' + TextureTypeToStr(Typ), 4);
{$ifdef blindydebug}
Log.LogStatus('',' JB-8');
{$endif}
@@ -719,6 +722,7 @@ var
begin
Result := -1;
for T := 0 to high(TextureDatabase.Texture) do
+ begin
if (TextureDatabase.Texture[T].Name = Name) and
(TextureDatabase.Texture[T].Typ = Typ) then
begin
@@ -730,6 +734,7 @@ begin
break;
end;
end;
+ end;
end;
function TTextureUnit.LoadTexture(const Identifier: string; Typ: TTextureType; Col: LongWord): TTexture;
@@ -815,7 +820,8 @@ begin
else
begin
TexNum := TextureDatabase.Texture[T].TextureCache.TexNum;
- if TexNum > 0 then begin
+ if TexNum > 0 then
+ begin
glDeleteTextures(1, @TexNum);
TextureDatabase.Texture[T].TextureCache.TexNum := 0;
// Log.LogError('Unload texture cache no '+IntToStr(TexNum));