From d52e74ca500daaa05e33e05b53d16317a2990e88 Mon Sep 17 00:00:00 2001 From: Bergmann89 Date: Sat, 16 Nov 2013 18:53:48 +0100 Subject: [PATCH] * fixed Compiler Warnings and Hints --- glBitmap.pas | 297 +++++++++++++++++++++++++++-------------------------------- 1 file changed, 137 insertions(+), 160 deletions(-) diff --git a/glBitmap.pas b/glBitmap.pas index 1a547ac..d39e7c5 100644 --- a/glBitmap.pas +++ b/glBitmap.pas @@ -223,7 +223,7 @@ unit glBitmap; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // activate to enable build-in OpenGL support with statically linked methods // use dglOpenGL.pas if not enabled -{$DEFINE GLB_NATIVE_OGL_STATIC} +{.$DEFINE GLB_NATIVE_OGL_STATIC} // activate to enable build-in OpenGL support with dynamically linked methods // use dglOpenGL.pas if not enabled @@ -794,7 +794,7 @@ type Position: TglBitmapPixelPosition; Source: TglBitmapPixelData; Dest: TglBitmapPixelData; - Args: PtrInt; + Args: Pointer; end; TglBitmapFunction = procedure(var FuncRec: TglBitmapFunctionRec); @@ -853,7 +853,7 @@ type procedure SetAnisotropic(const aValue: Integer); procedure CreateID; - procedure SetupParameters(var aBuildWithGlu: Boolean); + procedure SetupParameters(out aBuildWithGlu: Boolean); procedure SetDataPointer(const aData: PByte; const aFormat: TglBitmapFormat; const aWidth: Integer = -1; const aHeight: Integer = -1); virtual; procedure GenTexture(const aTestTextureSize: Boolean = true); virtual; abstract; @@ -893,7 +893,7 @@ type procedure LoadFromFile(const aFilename: String); procedure LoadFromStream(const aStream: TStream); virtual; procedure LoadFromFunc(const aSize: TglBitmapPixelPosition; const aFunc: TglBitmapFunction; - const aFormat: TglBitmapFormat; const aArgs: PtrInt = 0); + const aFormat: TglBitmapFormat; const aArgs: Pointer = nil); {$IFDEF GLB_DELPHI} procedure LoadFromResource(const aInstance: Cardinal; const aResource: String; const aResType: PChar = nil); procedure LoadFromResourceID(const sInstance: Cardinal; const aResourceID: Integer; const aResType: PChar); @@ -904,9 +904,9 @@ type procedure SaveToStream(const aStream: TStream; const aFileType: TglBitmapFileType); virtual; //Convert - function AddFunc(const aFunc: TglBitmapFunction; const aCreateTemp: Boolean; const aArgs: PtrInt = 0): Boolean; overload; + function AddFunc(const aFunc: TglBitmapFunction; const aCreateTemp: Boolean; const aArgs: Pointer = nil): Boolean; overload; function AddFunc(const aSource: TglBitmap; const aFunc: TglBitmapFunction; aCreateTemp: Boolean; - const aFormat: TglBitmapFormat; const aArgs: PtrInt = 0): Boolean; overload; + const aFormat: TglBitmapFormat; const aArgs: Pointer = nil): Boolean; overload; public //Alpha & Co {$IFDEF GLB_SDL} @@ -914,7 +914,7 @@ type function AssignFromSurface(const aSurface: PSDL_Surface): Boolean; function AssignAlphaToSurface(out aSurface: PSDL_Surface): Boolean; function AddAlphaFromSurface(const aSurface: PSDL_Surface; const aFunc: TglBitmapFunction = nil; - const aArgs: PtrInt = 0): Boolean; + const aArgs: Pointer = nil): Boolean; {$ENDIF} {$IFDEF GLB_DELPHI} @@ -922,17 +922,17 @@ type function AssignFromBitmap(const aBitmap: TBitmap): Boolean; function AssignAlphaToBitmap(const aBitmap: TBitmap): Boolean; function AddAlphaFromBitmap(const aBitmap: TBitmap; const aFunc: TglBitmapFunction = nil; - const aArgs: PtrInt = 0): Boolean; + const aArgs: Pointer = nil): Boolean; function AddAlphaFromResource(const aInstance: Cardinal; const aResource: String; const aResType: PChar = nil; - const aFunc: TglBitmapFunction = nil; const aArgs: PtrInt = 0): Boolean; + const aFunc: TglBitmapFunction = nil; const aArgs: Pointer = nil): Boolean; function AddAlphaFromResourceID(const aInstance: Cardinal; const aResourceID: Integer; const aResType: PChar; - const aFunc: TglBitmapFunction = nil; const aArgs: PtrInt = 0): Boolean; + const aFunc: TglBitmapFunction = nil; const aArgs: Pointer = nil): Boolean; {$ENDIF} - function AddAlphaFromFunc(const aFunc: TglBitmapFunction; const aArgs: PtrInt = 0): Boolean; virtual; - function AddAlphaFromFile(const aFileName: String; const aFunc: TglBitmapFunction = nil; const aArgs: PtrInt = 0): Boolean; - function AddAlphaFromStream(const aStream: TStream; const aFunc: TglBitmapFunction = nil; const aArgs: PtrInt = 0): Boolean; - function AddAlphaFromGlBitmap(const aBitmap: TglBitmap; aFunc: TglBitmapFunction = nil; const aArgs: PtrInt = 0): Boolean; + function AddAlphaFromFunc(const aFunc: TglBitmapFunction; const aArgs: Pointer = nil): Boolean; virtual; + function AddAlphaFromFile(const aFileName: String; const aFunc: TglBitmapFunction = nil; const aArgs: Pointer = nil): Boolean; + function AddAlphaFromStream(const aStream: TStream; const aFunc: TglBitmapFunction = nil; const aArgs: Pointer = nil): Boolean; + function AddAlphaFromGlBitmap(const aBitmap: TglBitmap; aFunc: TglBitmapFunction = nil; const aArgs: Pointer = nil): Boolean; function AddAlphaFromColorKey(const aRed, aGreen, aBlue: Byte; const aDeviation: Byte = 0): Boolean; function AddAlphaFromColorKeyRange(const aRed, aGreen, aBlue: Cardinal; const aDeviation: Cardinal = 0): Boolean; @@ -963,9 +963,6 @@ type const T: Cardinal = GL_CLAMP_TO_EDGE; const R: Cardinal = GL_CLAMP_TO_EDGE); - procedure GetPixel(const aPos: TglBitmapPixelPosition; var aPixel: TglBitmapPixelData); virtual; - procedure SetPixel(const aPos: TglBitmapPixelPosition; const aPixel: TglBitmapPixelData); virtual; - procedure Bind(const aEnableTextureUnit: Boolean = true); virtual; procedure Unbind(const aDisableTextureUnit: Boolean = true); virtual; @@ -974,7 +971,7 @@ type constructor Create(const aFileName: String); overload; constructor Create(const aStream: TStream); overload; constructor Create(const aSize: TglBitmapPixelPosition; const aFormat: TglBitmapFormat); overload; - constructor Create(const aSize: TglBitmapPixelPosition; const aFormat: TglBitmapFormat; const aFunc: TglBitmapFunction; const aArgs: PtrInt = 0); overload; + constructor Create(const aSize: TglBitmapPixelPosition; const aFormat: TglBitmapFormat; const aFunc: TglBitmapFunction; const aArgs: Pointer = nil); overload; {$IFDEF GLB_DELPHI} constructor Create(const aInstance: Cardinal; const aResource: String; const aResType: PChar = nil); overload; constructor Create(const aInstance: Cardinal; const aResourceID: Integer; const aResType: PChar); overload; @@ -1186,7 +1183,7 @@ type property AlphaMask: UInt64 read GetAlphaMask; procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); virtual; abstract; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); virtual; abstract; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); virtual; abstract; function GetSize(const aSize: TglBitmapPixelPosition): Integer; virtual; overload; function GetSize(const aWidth, aHeight: Integer): Integer; virtual; overload; @@ -1215,117 +1212,117 @@ type ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TfdAlpha_UB1 = class(TFormatDescriptor) //1* unsigned byte procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdLuminance_UB1 = class(TFormatDescriptor) //1* unsigned byte procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdUniversal_UB1 = class(TFormatDescriptor) //1* unsigned byte procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdLuminanceAlpha_UB2 = class(TfdLuminance_UB1) //2* unsigned byte procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdRGB_UB3 = class(TFormatDescriptor) //3* unsigned byte procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdBGR_UB3 = class(TFormatDescriptor) //3* unsigned byte (inverse) procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdRGBA_UB4 = class(TfdRGB_UB3) //4* unsigned byte procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdBGRA_UB4 = class(TfdBGR_UB3) //4* unsigned byte (inverse) procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TfdAlpha_US1 = class(TFormatDescriptor) //1* unsigned short procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdLuminance_US1 = class(TFormatDescriptor) //1* unsigned short procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdUniversal_US1 = class(TFormatDescriptor) //1* unsigned short procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdDepth_US1 = class(TFormatDescriptor) //1* unsigned short procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdLuminanceAlpha_US2 = class(TfdLuminance_US1) //2* unsigned short procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdRGB_US3 = class(TFormatDescriptor) //3* unsigned short procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdBGR_US3 = class(TFormatDescriptor) //3* unsigned short (inverse) procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdRGBA_US4 = class(TfdRGB_US3) //4* unsigned short procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdBGRA_US4 = class(TfdBGR_US3) //4* unsigned short (inverse) procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TfdUniversal_UI1 = class(TFormatDescriptor) //1* unsigned int procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdDepth_UI1 = class(TFormatDescriptor) //1* unsigned int procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; @@ -1516,19 +1513,19 @@ type TfdS3tcDtx1RGBA = class(TFormatDescriptor) procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdS3tcDtx3RGBA = class(TFormatDescriptor) procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; TfdS3tcDtx5RGBA = class(TFormatDescriptor) procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; constructor Create; override; end; @@ -1550,7 +1547,7 @@ type property PixelSize: Single read fPixelSize write fPixelSize; procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1571,7 +1568,7 @@ type procedure CreateColorTable; procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; - procedure Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); override; + procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; destructor Destroy; override; end; @@ -1859,7 +1856,7 @@ begin aLibHandle := GL_LibHandle; {$IF DEFINED(GLB_WIN)} - result := GetProcAddress(HMODULE(aLibHandle), aProcName); + result := GetProcAddress({%H-}HMODULE(aLibHandle), aProcName); if Assigned(result) then exit; @@ -1897,7 +1894,7 @@ procedure glbInitOpenGL; function glbLoadLibrary(const aName: PChar): Pointer; begin {$IF DEFINED(GLB_WIN)} - result := Pointer(LoadLibrary(aName)); + result := {%H-}Pointer(LoadLibrary(aName)); {$ELSEIF DEFINED(GLB_LINUX)} result := dlopen(Name, RTLD_LAZY); {$ELSE} @@ -1913,14 +1910,12 @@ procedure glbInitOpenGL; exit; {$IF DEFINED(GLB_WIN)} - Result := FreeLibrary(HINST(aLibHandle)); + Result := FreeLibrary({%H-}HINST(aLibHandle)); {$ELSEIF DEFINED(GLB_LINUX)} Result := dlclose(aLibHandle) = 0; {$ENDIF} end; -var - p: Pointer; begin if Assigned(GL_LibHandle) then glbFreeLibrary(GL_LibHandle); @@ -1983,33 +1978,33 @@ var MajorVersion, MinorVersion: Integer; /////////////////////////////////////////////////////////////////////////////////////////// - procedure TrimVersionString(Buffer: AnsiString; var Major, Minor: Integer); + procedure TrimVersionString(aBuffer: AnsiString; out aMajor, aMinor: Integer); var Separator: Integer; begin - Minor := 0; - Major := 0; + aMinor := 0; + aMajor := 0; - Separator := Pos(AnsiString('.'), Buffer); - if (Separator > 1) and (Separator < Length(Buffer)) and - (Buffer[Separator - 1] in ['0'..'9']) and - (Buffer[Separator + 1] in ['0'..'9']) then begin + Separator := Pos(AnsiString('.'), aBuffer); + if (Separator > 1) and (Separator < Length(aBuffer)) and + (aBuffer[Separator - 1] in ['0'..'9']) and + (aBuffer[Separator + 1] in ['0'..'9']) then begin Dec(Separator); - while (Separator > 0) and (Buffer[Separator] in ['0'..'9']) do + while (Separator > 0) and (aBuffer[Separator] in ['0'..'9']) do Dec(Separator); - Delete(Buffer, 1, Separator); - Separator := Pos(AnsiString('.'), Buffer) + 1; + Delete(aBuffer, 1, Separator); + Separator := Pos(AnsiString('.'), aBuffer) + 1; - while (Separator <= Length(Buffer)) and (AnsiChar(Buffer[Separator]) in ['0'..'9']) do + while (Separator <= Length(aBuffer)) and (AnsiChar(aBuffer[Separator]) in ['0'..'9']) do Inc(Separator); - Delete(Buffer, Separator, 255); - Separator := Pos(AnsiString('.'), Buffer); + Delete(aBuffer, Separator, 255); + Separator := Pos(AnsiString('.'), aBuffer); - Major := StrToInt(Copy(String(Buffer), 1, Separator - 1)); - Minor := StrToInt(Copy(String(Buffer), Separator + 1, 1)); + aMajor := StrToInt(Copy(String(aBuffer), 1, Separator - 1)); + aMinor := StrToInt(Copy(String(aBuffer), Separator + 1, 1)); end; end; @@ -2473,7 +2468,7 @@ end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TFormatDescriptor.PreparePixel(out aPixel: TglBitmapPixelData); begin - FillChar(aPixel, SizeOf(aPixel), 0); + FillChar(aPixel{%H-}, SizeOf(aPixel), 0); aPixel.Data := fRange; aPixel.Range := fRange; aPixel.Format := fFormat; @@ -2509,7 +2504,7 @@ begin inc(aData); end; -procedure TfdAlpha_UB1.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdAlpha_UB1.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin aPixel.Data.r := 0; aPixel.Data.g := 0; @@ -2536,7 +2531,7 @@ begin inc(aData); end; -procedure TfdLuminance_UB1.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdLuminance_UB1.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin aPixel.Data.r := aData^; aPixel.Data.g := aData^; @@ -2570,7 +2565,7 @@ begin inc(aData); end; -procedure TfdUniversal_UB1.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdUniversal_UB1.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); var i: Integer; begin @@ -2595,7 +2590,7 @@ begin inc(aData); end; -procedure TfdLuminanceAlpha_UB2.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdLuminanceAlpha_UB2.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin inherited Unmap(aData, aPixel, aMapData); aPixel.Data.a := aData^; @@ -2625,7 +2620,7 @@ begin inc(aData); end; -procedure TfdRGB_UB3.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdRGB_UB3.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin aPixel.Data.r := aData^; inc(aData); @@ -2663,7 +2658,7 @@ begin inc(aData); end; -procedure TfdBGR_UB3.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdBGR_UB3.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin aPixel.Data.b := aData^; inc(aData); @@ -2697,7 +2692,7 @@ begin inc(aData); end; -procedure TfdRGBA_UB4.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdRGBA_UB4.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin inherited Unmap(aData, aPixel, aMapData); aPixel.Data.a := aData^; @@ -2724,7 +2719,7 @@ begin inc(aData); end; -procedure TfdBGRA_UB4.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdBGRA_UB4.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin inherited Unmap(aData, aPixel, aMapData); aPixel.Data.a := aData^; @@ -2750,7 +2745,7 @@ begin inc(aData, 2); end; -procedure TfdAlpha_US1.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdAlpha_US1.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin aPixel.Data.r := 0; aPixel.Data.g := 0; @@ -2777,7 +2772,7 @@ begin inc(aData, 2); end; -procedure TfdLuminance_US1.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdLuminance_US1.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin aPixel.Data.r := PWord(aData)^; aPixel.Data.g := PWord(aData)^; @@ -2811,7 +2806,7 @@ begin inc(aData, 2); end; -procedure TfdUniversal_US1.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdUniversal_US1.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); var i: Integer; begin @@ -2835,7 +2830,7 @@ begin inc(aData, 2); end; -procedure TfdDepth_US1.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdDepth_US1.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin aPixel.Data.r := PWord(aData)^; aPixel.Data.g := PWord(aData)^; @@ -2865,7 +2860,7 @@ begin inc(aData, 2); end; -procedure TfdLuminanceAlpha_US2.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdLuminanceAlpha_US2.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin inherited Unmap(aData, aPixel, aMapData); aPixel.Data.a := PWord(aData)^; @@ -2895,7 +2890,7 @@ begin inc(aData, 2); end; -procedure TfdRGB_US3.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdRGB_US3.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin aPixel.Data.r := PWord(aData)^; inc(aData, 2); @@ -2933,7 +2928,7 @@ begin inc(aData, 2); end; -procedure TfdBGR_US3.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdBGR_US3.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin aPixel.Data.b := PWord(aData)^; inc(aData, 2); @@ -2968,7 +2963,7 @@ begin inc(aData, 2); end; -procedure TfdRGBA_US4.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdRGBA_US4.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin inherited Unmap(aData, aPixel, aMapData); aPixel.Data.a := PWord(aData)^; @@ -2995,7 +2990,7 @@ begin inc(aData, 2); end; -procedure TfdBGRA_US4.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdBGRA_US4.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin inherited Unmap(aData, aPixel, aMapData); aPixel.Data.a := PWord(aData)^; @@ -3026,7 +3021,7 @@ begin inc(aData, 4); end; -procedure TfdUniversal_UI1.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdUniversal_UI1.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); var i: Integer; begin @@ -3050,7 +3045,7 @@ begin inc(aData, 4); end; -procedure TfdDepth_UI1.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdDepth_UI1.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin aPixel.Data.r := PCardinal(aData)^; aPixel.Data.g := PCardinal(aData)^; @@ -3662,7 +3657,7 @@ begin raise EglBitmapException.Create('mapping for compressed formats is not supported'); end; -procedure TfdS3tcDtx1RGBA.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdS3tcDtx1RGBA.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin raise EglBitmapException.Create('mapping for compressed formats is not supported'); end; @@ -3688,7 +3683,7 @@ begin raise EglBitmapException.Create('mapping for compressed formats is not supported'); end; -procedure TfdS3tcDtx3RGBA.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdS3tcDtx3RGBA.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin raise EglBitmapException.Create('mapping for compressed formats is not supported'); end; @@ -3714,7 +3709,7 @@ begin raise EglBitmapException.Create('mapping for compressed formats is not supported'); end; -procedure TfdS3tcDtx5RGBA.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TfdS3tcDtx5RGBA.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); begin raise EglBitmapException.Create('mapping for compressed formats is not supported'); end; @@ -3857,7 +3852,7 @@ begin end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TbmpBitfieldFormat.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TbmpBitfieldFormat.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); var data: UInt64; s, i: Integer; @@ -3883,8 +3878,6 @@ end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TbmpColorTableFormat.CreateColorTable; var - bits: Byte; - len: Integer; i: Integer; begin if not (Format in [tfLuminance4, tfLuminance8, tfR3G3B2]) then @@ -3938,9 +3931,9 @@ begin if (aMapData = nil) then aData^ := 0; d := LuminanceWeight(aPixel) and Range.r; - aData^ := aData^ or (d shl (4 - PtrInt(aMapData))); + aData^ := aData^ or (d shl (4 - {%H-}PtrUInt(aMapData))); inc(aMapData, 4); - if (PtrInt(aMapData) >= 8) then begin + if ({%H-}PtrUInt(aMapData) >= 8) then begin inc(aData); aMapData := nil; end; @@ -3962,7 +3955,7 @@ begin end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TbmpColorTableFormat.Unmap(var aData: PByte; var aPixel: TglBitmapPixelData; var aMapData: Pointer); +procedure TbmpColorTableFormat.Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); type PUInt64 = ^UInt64; var @@ -3975,7 +3968,7 @@ begin f := fPixelSize - s; bits := Round(8 * f); case s of - 0: idx := (aData^ shr (8 - bits - PtrInt(aMapData))) and ((1 shl bits) - 1); + 0: idx := (aData^ shr (8 - bits - {%H-}PtrUInt(aMapData))) and ((1 shl bits) - 1); 1: idx := aData^; 2: idx := PWord(aData)^; 4: idx := PCardinal(aData)^; @@ -3992,7 +3985,7 @@ begin aPixel.Data.a := a; end; inc(aMapData, bits); - if (PtrInt(aMapData) >= 8) then begin + if ({%H-}PtrUInt(aMapData) >= 8) then begin inc(aData, 1); dec(aMapData, 8); end; @@ -4073,12 +4066,12 @@ procedure glBitmapInvertFunc(var aFuncRec: TglBitmapFunctionRec); begin with aFuncRec do begin Dest.Data := Source.Data; - if (Args and $1 > 0) then begin + if ({%H-}PtrUInt(Args) and $1 > 0) then begin Dest.Data.r := Dest.Data.r xor Dest.Range.r; Dest.Data.g := Dest.Data.g xor Dest.Range.g; Dest.Data.b := Dest.Data.b xor Dest.Range.b; end; - if (Args and $2 > 0) then begin + if ({%H-}PtrUInt(Args) and $2 > 0) then begin Dest.Data.a := Dest.Data.a xor Dest.Range.a; end; end; @@ -4101,7 +4094,7 @@ var Temp: Single; begin with FuncRec do begin - if (FuncRec.Args = 0) then begin //source has no alpha + if (FuncRec.Args = nil) then begin //source has no alpha Temp := Source.Data.r / Source.Range.r * ALPHA_WEIGHT_R + Source.Data.g / Source.Range.g * ALPHA_WEIGHT_G + @@ -4134,8 +4127,6 @@ end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure glBitmapValueAlphaFunc(var FuncRec: TglBitmapFunctionRec); -type - PglBitmapPixelData = ^TglBitmapPixelData; begin with FuncRec do begin Dest.Data.r := Source.Data.r; @@ -4303,7 +4294,7 @@ begin end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TglBitmap.SetupParameters(var aBuildWithGlu: Boolean); +procedure TglBitmap.SetupParameters(out aBuildWithGlu: Boolean); begin // Set Up Parameters SetWrap(fWrapS, fWrapT, fWrapR); @@ -4432,7 +4423,7 @@ end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TglBitmap.LoadFromFunc(const aSize: TglBitmapPixelPosition; const aFunc: TglBitmapFunction; - const aFormat: TglBitmapFormat; const aArgs: PtrInt); + const aFormat: TglBitmapFormat; const aArgs: Pointer); var tmpData: PByte; size: Integer; @@ -4519,14 +4510,14 @@ begin end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TglBitmap.AddFunc(const aFunc: TglBitmapFunction; const aCreateTemp: Boolean; const aArgs: PtrInt): Boolean; +function TglBitmap.AddFunc(const aFunc: TglBitmapFunction; const aCreateTemp: Boolean; const aArgs: Pointer): Boolean; begin result := AddFunc(Self, aFunc, aCreateTemp, Format, aArgs); end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function TglBitmap.AddFunc(const aSource: TglBitmap; const aFunc: TglBitmapFunction; aCreateTemp: Boolean; - const aFormat: TglBitmapFormat; const aArgs: PtrInt): Boolean; + const aFormat: TglBitmapFormat; const aArgs: Pointer): Boolean; var DestData, TmpData, SourceData: pByte; TempHeight, TempWidth: Integer; @@ -4974,7 +4965,7 @@ end; {$ENDIF} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TglBitmap.AddAlphaFromFunc(const aFunc: TglBitmapFunction; const aArgs: PtrInt): Boolean; +function TglBitmap.AddAlphaFromFunc(const aFunc: TglBitmapFunction; const aArgs: Pointer): Boolean; begin (* TODO if not FormatIsUncompressed(InternalFormat) then @@ -4984,7 +4975,7 @@ begin end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TglBitmap.AddAlphaFromFile(const aFileName: String; const aFunc: TglBitmapFunction; const aArgs: PtrInt): Boolean; +function TglBitmap.AddAlphaFromFile(const aFileName: String; const aFunc: TglBitmapFunction; const aArgs: Pointer): Boolean; var FS: TFileStream; begin @@ -4997,7 +4988,7 @@ begin end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TglBitmap.AddAlphaFromStream(const aStream: TStream; const aFunc: TglBitmapFunction; const aArgs: PtrInt): Boolean; +function TglBitmap.AddAlphaFromStream(const aStream: TStream; const aFunc: TglBitmapFunction; const aArgs: Pointer): Boolean; var tex: TglBitmap2D; begin @@ -5010,7 +5001,7 @@ begin end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -function TglBitmap.AddAlphaFromGlBitmap(const aBitmap: TglBitmap; aFunc: TglBitmapFunction; const aArgs: PtrInt): Boolean; +function TglBitmap.AddAlphaFromGlBitmap(const aBitmap: TglBitmap; aFunc: TglBitmapFunction; const aArgs: Pointer): Boolean; var DestData, DestData2, SourceData: pByte; TempHeight, TempWidth: Integer; @@ -5027,21 +5018,23 @@ begin if ((aBitmap.Width = Width) and (aBitmap.Height = Height)) then begin result := ConvertTo(TFormatDescriptor.Get(Format).WithAlpha); - if not Assigned(aFunc) then - aFunc := glBitmapAlphaFunc; SourceFD := TFormatDescriptor.Get(aBitmap.Format); DestFD := TFormatDescriptor.Get(Format); + if not Assigned(aFunc) then begin + aFunc := glBitmapAlphaFunc; + FuncRec.Args := {%H-}Pointer(SourceFD.HasAlpha); + end else + FuncRec.Args := aArgs; + // Values TempHeight := aBitmap.FileHeight; TempWidth := aBitmap.FileWidth; FuncRec.Sender := Self; - FuncRec.Args := aArgs; FuncRec.Size := Dimension; FuncRec.Position.Fields := FuncRec.Size.Fields; - FuncRec.Args := PtrInt(SourceFD.HasAlpha) and 1; DestData := Data; DestData2 := Data; @@ -5116,7 +5109,7 @@ begin Data.a := 0; Range.a := 0; end; - result := AddAlphaFromFunc(glBitmapColorKeyAlphaFunc, PtrInt(@PixelData)); + result := AddAlphaFromFunc(glBitmapColorKeyAlphaFunc, @PixelData); end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -5142,7 +5135,7 @@ begin TFormatDescriptor.GetWithAlpha(Format).PreparePixel(PixelData); with PixelData do Data.a := Min(Range.a, Max(0, Round(Range.a * aAlpha))); - result := AddAlphaFromFunc(glBitmapValueAlphaFunc, PtrInt(@PixelData.Data.a)); + result := AddAlphaFromFunc(glBitmapValueAlphaFunc, @PixelData.Data.a); end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -5258,7 +5251,7 @@ begin ShiftData.g := GetShift(SourcePD.Range.g, DestPD.Range.g); ShiftData.b := GetShift(SourcePD.Range.b, DestPD.Range.b); ShiftData.a := GetShift(SourcePD.Range.a, DestPD.Range.a); - result := AddFunc(Self, glBitmapConvertShiftRGBAFunc, false, aFormat, PtrInt(@ShiftData)); + result := AddFunc(Self, glBitmapConvertShiftRGBAFunc, false, aFormat, @ShiftData); end else result := AddFunc(Self, glBitmapConvertCalculateRGBAFunc, false, aFormat); end else @@ -5269,7 +5262,9 @@ end; procedure TglBitmap.Invert(const aUseRGB: Boolean; const aUseAlpha: Boolean); begin if aUseRGB or aUseAlpha then - AddFunc(glBitmapInvertFunc, false, ((PtrInt(aUseAlpha) and 1) shl 1) or (PtrInt(aUseRGB) and 1)); + AddFunc(glBitmapInvertFunc, false, {%H-}Pointer( + ((PtrInt(aUseAlpha) and 1) shl 1) or + (PtrInt(aUseRGB) and 1) )); end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -5323,7 +5318,7 @@ begin Data.b := Max(0, Min(Range.b, Trunc(Range.b * aBlue))); Data.a := Max(0, Min(Range.a, Trunc(Range.a * aAlpha))); end; - AddFunc(glBitmapFillWithColorFunc, false, PtrInt(@PixelData)); + AddFunc(glBitmapFillWithColorFunc, false, @PixelData); end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -5427,24 +5422,6 @@ begin end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TglBitmap.GetPixel(const aPos: TglBitmapPixelPosition; var aPixel: TglBitmapPixelData); -begin - { TODO delete? - if Assigned (fGetPixelFunc) then - fGetPixelFunc(aPos, aPixel); - } -end; - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TglBitmap.SetPixel(const aPos: TglBitmapPixelPosition; const aPixel: TglBitmapPixelData); -begin - {TODO delete? - if Assigned (fSetPixelFunc) then - fSetPixelFuc(aPos, aPixel); - } -end; - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TglBitmap.Bind(const aEnableTextureUnit: Boolean); begin if aEnableTextureUnit then @@ -5493,7 +5470,7 @@ var ImageSize: Integer; begin Create; - TFormatDescriptor.Get(aFormat).GetSize(aSize); + ImageSize := TFormatDescriptor.Get(aFormat).GetSize(aSize); GetMem(Image, ImageSize); try FillChar(Image^, ImageSize, #$FF); @@ -5506,7 +5483,7 @@ end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// constructor TglBitmap.Create(const aSize: TglBitmapPixelPosition; const aFormat: TglBitmapFormat; - const aFunc: TglBitmapFunction; const aArgs: PtrInt); + const aFunc: TglBitmapFunction; const aArgs: Pointer); begin Create; LoadFromFunc(aSize, aFunc, aFormat, aArgs); @@ -6423,11 +6400,11 @@ type function TglBitmap.LoadBMP(const aStream: TStream): Boolean; ////////////////////////////////////////////////////////////////////////////////////////////////// - function ReadInfo(var aInfo: TBMPInfo; var aMask: TglBitmapColorRec): TglBitmapFormat; + function ReadInfo(out aInfo: TBMPInfo; out aMask: TglBitmapColorRec): TglBitmapFormat; begin result := tfEmpty; - aStream.Read(aInfo, SizeOf(aInfo)); - FillChar(aMask, SizeOf(aMask), 0); + aStream.Read(aInfo{%H-}, SizeOf(aInfo)); + FillChar(aMask{%H-}, SizeOf(aMask), 0); //Read Compression case aInfo.biCompression of @@ -6519,7 +6496,6 @@ var LineBuf, ImageData, TmpData: PByte; SourceMD, DestMD: Pointer; BmpFormat: TglBitmapFormat; - ColorTable: TbmpColorTable; //records Mask: TglBitmapColorRec; @@ -6533,7 +6509,7 @@ var ////////////////////////////////////////////////////////////////////////////////////////////////// procedure SpecialFormatReadLine(aData: PByte; aLineBuf: PByte); var - i, j: Integer; + i: Integer; Pixel: TglBitmapPixelData; begin aStream.Read(aLineBuf^, rbLineSize); @@ -6555,7 +6531,7 @@ begin // Header StartPos := aStream.Position; - aStream.Read(Header, SizeOf(Header)); + aStream.Read(Header{%H-}, SizeOf(Header)); if Header.bfType = BMP_MAGIC then begin try try @@ -6595,7 +6571,7 @@ begin dec(TmpData, wbLineSize) else inc(TmpData, wbLineSize); - aStream.Read(PaddingBuff, Padding); + aStream.Read(PaddingBuff{%H-}, Padding); end; SetDataPointer(ImageData, BmpFormat, Info.biWidth, abs(Info.biHeight)); result := true; @@ -6634,8 +6610,7 @@ var pData, srcData, dstData, ConvertBuffer: pByte; Pixel: TglBitmapPixelData; - PixelFormat: TglBitmapPixelData; - ImageSize, wbLineSize, rbLineSize, Padding, LineIdx, PixelIdx, i: Integer; + ImageSize, wbLineSize, rbLineSize, Padding, LineIdx, PixelIdx: Integer; RedMask, GreenMask, BlueMask, AlphaMask: Cardinal; PaddingBuff: Cardinal; @@ -6653,14 +6628,14 @@ begin FormatDesc := TFormatDescriptor.Get(Format); ImageSize := FormatDesc.GetSize(Dimension); - FillChar(Header, SizeOf(Header), 0); + FillChar(Header{%H-}, SizeOf(Header), 0); Header.bfType := BMP_MAGIC; Header.bfSize := SizeOf(Header) + SizeOf(Info) + ImageSize; Header.bfReserved1 := 0; Header.bfReserved2 := 0; Header.bfOffBits := SizeOf(Header) + SizeOf(Info); - FillChar(Info, SizeOf(Info), 0); + FillChar(Info{%H-}, SizeOf(Info), 0); Info.biSize := SizeOf(Info); Info.biWidth := Width; Info.biHeight := Height; @@ -6907,7 +6882,7 @@ const BytesRead := 0; if (CacheSize - CachePos > 0) then begin BytesRead := CacheSize - CachePos; - Move(PByteArray(Cache)^[CachePos], Buffer, BytesRead); + Move(PByteArray(Cache)^[CachePos], Buffer{%H-}, BytesRead); inc(CachePos, BytesRead); end; @@ -7009,7 +6984,7 @@ begin // reading header to test file and set cursor back to begin StartPosition := aStream.Position; - aStream.Read(Header, SizeOf(Header)); + aStream.Read(Header{%H-}, SizeOf(Header)); // no colormapped files if (Header.ColorMapType = TGA_NONE_COLOR_TABLE) and (Header.ImageType in [ @@ -7111,7 +7086,7 @@ begin raise EglBitmapUnsupportedFormatFormat.Create('SaveTGA - ' + UNSUPPORTED_FORMAT); //prepare header - FillChar(Header, SizeOf(Header), 0); + FillChar(Header{%H-}, SizeOf(Header), 0); //set ImageType if (Format in [tfLuminance8, tfLuminance6Alpha2, tfLuminance4Alpha4, tfAlpha8, @@ -7320,7 +7295,7 @@ var var StreamPos: Int64; - x, y, j, LineSize, RowSize, Magic: Cardinal; + x, y, LineSize, RowSize, Magic: Cardinal; NewImage, TmpData, RowData, SrcData: PByte; SourceMD, DestMD: Pointer; Pixel: TglBitmapPixelData; @@ -7333,14 +7308,14 @@ begin StreamPos := aStream.Position; // Magic - aStream.Read(Magic, sizeof(Magic)); + aStream.Read(Magic{%H-}, sizeof(Magic)); if (Magic <> DDS_MAGIC) then begin aStream.Position := StreamPos; exit; end; //Header - aStream.Read(Header, sizeof(Header)); + aStream.Read(Header{%H-}, sizeof(Header)); if (Header.dwSize <> SizeOf(Header)) or ((Header.dwFlags and (DDSD_PIXELFORMAT or DDSD_CAPS or DDSD_WIDTH or DDSD_HEIGHT)) <> (DDSD_PIXELFORMAT or DDSD_CAPS or DDSD_WIDTH or DDSD_HEIGHT)) then @@ -7429,7 +7404,7 @@ begin FormatDesc := TFormatDescriptor.Get(Format); // Generell - FillChar(Header, SizeOf(Header), 0); + FillChar(Header{%H-}, SizeOf(Header), 0); Header.dwSize := SizeOf(Header); Header.dwFlags := DDSD_WIDTH or DDSD_HEIGHT or DDSD_CAPS or DDSD_PIXELFORMAT; @@ -7589,7 +7564,7 @@ procedure TglBitmap2D.GetDataFromTexture; var Temp: PByte; TempWidth, TempHeight: Integer; - TempType, TempIntFormat: Cardinal; + TempIntFormat: Cardinal; IntFormat, f: TglBitmapFormat; FormatDesc: TFormatDescriptor; begin @@ -7601,11 +7576,13 @@ begin glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_INTERNAL_FORMAT, @TempIntFormat); IntFormat := tfEmpty; - for f := Low(TglBitmapFormat) to High(TglBitmapFormat) do - if (TFormatDescriptor.Get(f).glInternalFormat = TempIntFormat) then begin + for f := Low(TglBitmapFormat) to High(TglBitmapFormat) do begin + FormatDesc := TFormatDescriptor.Get(f); + if (FormatDesc.glInternalFormat = TempIntFormat) then begin IntFormat := FormatDesc.Format; break; end; + end; // Getting data from OpenGL FormatDesc := TFormatDescriptor.Get(IntFormat); @@ -7925,10 +7902,10 @@ begin // Daten Sammeln if aUseAlpha and TFormatDescriptor.Get(Format).HasAlpha then - AddFunc(glBitmapToNormalMapPrepareAlphaFunc, false, PtrInt(@Rec)) + AddFunc(glBitmapToNormalMapPrepareAlphaFunc, false, @Rec) else - AddFunc(glBitmapToNormalMapPrepareFunc, false, PtrInt(@Rec)); - AddFunc(glBitmapToNormalMapFunc, false, PtrInt(@Rec)); + AddFunc(glBitmapToNormalMapPrepareFunc, false, @Rec); + AddFunc(glBitmapToNormalMapFunc, false, @Rec); finally SetLength(Rec.Heights, 0); end; -- 2.1.4