* fixed some compiler hints in delphi 7
[LazOpenGLCore.git] / glBitmap.pas
index fdeaae1..b1b4c65 100644 (file)
@@ -11,7 +11,7 @@ not use this file except in compliance with the License. You may
 obtain a copy of the License at
 http://www.mozilla.org/MPL/MPL-1.1.html
 ------------------------------------------------------------
-Version 3.0.0 unstable
+Version 3.0.1
 ------------------------------------------------------------
 History
 20-11-2013
@@ -24,7 +24,7 @@ History
 - GetPixel isn't set if you are loading textures inside the constructor (Thanks Wilson)
 10-08-2008
 - AddAlphaFromglBitmap used the custom pointer instead the imagedatapointer (Thanks Wilson)
-- Additional Datapointer for functioninterface now has the name CustomData  
+- Additional Datapointer for functioninterface now has the name CustomData
 24-07-2008
 - AssigneAlphaToBitmap overwrites his own palette (Thanks Wilson)
 - If you load an texture from an file the property Filename will be set to the name of the file
@@ -53,7 +53,7 @@ History
 - Property DataPtr now has the name Data
 - Functions are more flexible between RGB(A) and BGR(A). RGB can be saved as Bitmap and will be saved as BGR
 - Unused Depth removed
-- Function FreeData to freeing image data added 
+- Function FreeData to freeing image data added
 24-10-2007
 - ImageID flag of TGAs was ignored. (Thanks Zwoetzen)
 15-11-2006
@@ -221,7 +221,7 @@ unit glBitmap;
 
 // Please uncomment the defines below to configure the glBitmap to your preferences.
 // If you have configured the unit you can uncomment the warning above.
-{$MESSAGE warn 'Hey. I''m the glBitmap.pas and i need to be configured. My master tell me your preferences! ;)'}
+{$MESSAGE error 'Hey. I''m the glBitmap.pas and i need to be configured. My master tell me your preferences! ;)'}
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Preferences ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -238,7 +238,7 @@ unit glBitmap;
 // activate to enable the support for SDL_surfaces
 {.$DEFINE GLB_SDL}
 
-// activate  to enable the support for TBitmap from Delphi (not lazarus)
+// activate  to enable the support for Delphi (including support for Delphi's (not Lazarus') TBitmap)
 {.$DEFINE GLB_DELPHI}
 
 // activate to enable the support for TLazIntfImage from Lazarus
@@ -889,6 +889,9 @@ type
   TglBitmapFormatDescriptor = class(TObject)
   protected
     function GetIsCompressed: Boolean; virtual; abstract;
+    function GetHasRed:       Boolean; virtual; abstract;
+    function GetHasGreen:     Boolean; virtual; abstract;
+    function GetHasBlue:      Boolean; virtual; abstract;
     function GetHasAlpha:     Boolean; virtual; abstract;
 
     function GetglDataFormat:     GLenum;  virtual; abstract;
@@ -896,6 +899,9 @@ type
     function GetglInternalFormat: GLenum;  virtual; abstract;
   public
     property IsCompressed: Boolean read GetIsCompressed;
+    property HasRed:       Boolean read GetHasRed;
+    property HasGreen:     Boolean read GetHasGreen;
+    property HasBlue:      Boolean read GetHasBlue;
     property HasAlpha:     Boolean read GetHasAlpha;
 
     property glFormat:         GLenum  read GetglFormat;
@@ -927,7 +933,7 @@ type
     fFreeDataOnDestroy: Boolean;
     fFreeDataAfterGenTexture: Boolean;
     fData: PByte;
-    fIsResident: Boolean;
+    fIsResident: GLboolean;
     fBorderColor: array[0..3] of Single;
 
     fDimension: TglBitmapPixelPosition;
@@ -1011,7 +1017,7 @@ type
 
     property Dimension:  TglBitmapPixelPosition  read fDimension;
     property Data:       PByte                   read fData;
-    property IsResident: Boolean                 read fIsResident;
+    property IsResident: GLboolean               read fIsResident;
 
     procedure AfterConstruction; override;
     procedure BeforeDestruction; override;
@@ -1230,7 +1236,6 @@ implementation
 
 uses
   Math, syncobjs, typinfo
-  {$IFDEF GLB_DELPHI}, Types{$ENDIF}
   {$IF DEFINED(GLB_SUPPORT_JPEG_READ) AND DEFINED(GLB_LAZ_JPEG)}, FPReadJPEG{$IFEND};
 
 type
@@ -1272,6 +1277,9 @@ type
     fglDataFormat:     GLenum;
 
     function GetIsCompressed: Boolean; override;
+    function GetHasRed: Boolean; override;
+    function GetHasGreen: Boolean; override;
+    function GetHasBlue: Boolean; override;
     function GetHasAlpha: Boolean; override;
 
     function GetglFormat: GLenum; override;
@@ -2308,7 +2316,7 @@ begin
 end;
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-//TglBitmapFormatDescriptor///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//TFormatDescriptor///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 function TFormatDescriptor.GetRedMask: QWord;
 begin
@@ -2340,6 +2348,24 @@ begin
 end;
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TFormatDescriptor.GetHasRed: Boolean;
+begin
+  result := (fRange.r > 0);
+end;
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TFormatDescriptor.GetHasGreen: Boolean;
+begin
+  result := (fRange.g > 0);
+end;
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+function TFormatDescriptor.GetHasBlue: Boolean;
+begin
+  result := (fRange.b > 0);
+end;
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 function TFormatDescriptor.GetHasAlpha: Boolean;
 begin
   result := (fRange.a > 0);
@@ -4976,7 +5002,7 @@ var
     bfFormat: TbmpBitfieldFormat;
     pSourceLine, pDestLine: PByte;
     pSourceMD, pDestMD: Pointer;
-    x, y: Integer;
+    x, y: Cardinal;
     pixel: TglBitmapPixelData;
   begin
     bfFormat  := TbmpBitfieldFormat.Create;
@@ -5360,7 +5386,6 @@ var
   TempPtr: PByte;
   Size: Integer;
 begin
-  result := nil;
   Temp := (ClassType.Create as TglBitmap);
   try
     // copy texture data if assigned
@@ -5650,7 +5675,7 @@ begin
 
   if (ID > 0) then begin
     Bind(false);
-    glTexParameteriv(Target, GL_TEXTURE_SWIZZLE_RGBA, @fSwizzle[0]);
+    glTexParameteriv(Target, GL_TEXTURE_SWIZZLE_RGBA, PGLint(@fSwizzle[0]));
   end;
 end;
 
@@ -6347,7 +6372,6 @@ const
   MAGIC_LEN = 2;
   JPEG_MAGIC: String[MAGIC_LEN] = #$FF#$D8;
 var
-  jpeg: TJPEGImage;
   intf: TLazIntfImage;
   reader: TFPReaderJPEG;
   StreamPos: Int64;
@@ -8027,8 +8051,8 @@ end;
 procedure TglBitmap2D.GetDataFromTexture;
 var
   Temp: PByte;
-  TempWidth, TempHeight: Integer;
-  TempIntFormat: Cardinal;
+  TempWidth, TempHeight: GLint;
+  TempIntFormat: GLenum;
   IntFormat, f: TglBitmapFormat;
   FormatDesc: TFormatDescriptor;
 begin
@@ -8037,7 +8061,7 @@ begin
   // Request Data
   glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_WIDTH,           @TempWidth);
   glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_HEIGHT,          @TempHeight);
-  glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_INTERNAL_FORMAT, @TempIntFormat);
+  glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_INTERNAL_FORMAT, PGLint(@TempIntFormat));
 
   IntFormat := tfEmpty;
   for f := Low(TglBitmapFormat) to High(TglBitmapFormat) do begin