diff options
author | mogguh <mogguh@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-02-13 19:58:44 +0000 |
---|---|---|
committer | mogguh <mogguh@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-02-13 19:58:44 +0000 |
commit | 949fea202f6c963ad6c8a40040e1e9e6f909161b (patch) | |
tree | 9f6f683d203d55e41e5b7483b4038103d471ce76 /Game/Code/lib | |
parent | 1a7da68ae6e1368dae25821b15318bd1d2d9f88e (diff) | |
parent | efe5b06fd5715f550334692d28c2218896b62ce1 (diff) | |
download | usdx-949fea202f6c963ad6c8a40040e1e9e6f909161b.tar.gz usdx-949fea202f6c963ad6c8a40040e1e9e6f909161b.tar.xz usdx-949fea202f6c963ad6c8a40040e1e9e6f909161b.zip |
First multi platform version, works on Linux and Windows
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.1@855 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
124 files changed, 79529 insertions, 0 deletions
diff --git a/Game/Code/lib/FreeImage/FreeBitmap.pas b/Game/Code/lib/FreeImage/FreeBitmap.pas new file mode 100755 index 00000000..47be822e --- /dev/null +++ b/Game/Code/lib/FreeImage/FreeBitmap.pas @@ -0,0 +1,1740 @@ +unit FreeBitmap;
+
+{$I switches.inc}
+
+
+// ==========================================================
+//
+// Delphi wrapper for FreeImage 3
+//
+// Design and implementation by
+// - Anatoliy Pulyaevskiy (xvel84@rambler.ru)
+//
+// Contributors:
+// - Enzo Costantini (enzocostantini@libero.it)
+//
+// This file is part of FreeImage 3
+//
+// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
+// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
+// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
+// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
+// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
+// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
+// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
+// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
+// THIS DISCLAIMER.
+//
+// Use at your own risk!
+//
+// ==========================================================
+//
+// From begining all code of this file is based on C++ wrapper to
+// FreeImage - FreeImagePlus.
+//
+// ==========================================================
+
+interface
+
+uses
+ SysUtils, Classes, Windows, FreeImage;
+
+type
+ { TFreeObject }
+
+ TFreeObject = class(TObject)
+ public
+ function IsValid: Boolean; virtual;
+ end;
+
+ { TFreeTag }
+
+ TFreeTag = class(TFreeObject)
+ private
+ // fields
+ FTag: PFITAG;
+
+ // getters & setters
+ function GetCount: Cardinal;
+ function GetDescription: string;
+ function GetID: Word;
+ function GetKey: string;
+ function GetLength: Cardinal;
+ function GetTagType: FREE_IMAGE_MDTYPE;
+ function GetValue: Pointer;
+ procedure SetCount(const Value: Cardinal);
+ procedure SetDescription(const Value: string);
+ procedure SetID(const Value: Word);
+ procedure SetKey(const Value: string);
+ procedure SetLength(const Value: Cardinal);
+ procedure SetTagType(const Value: FREE_IMAGE_MDTYPE);
+ procedure SetValue(const Value: Pointer);
+ public
+ // construction & destruction
+ constructor Create(ATag: PFITAG = nil); virtual;
+ destructor Destroy; override;
+
+ // methods
+ function Clone: TFreeTag;
+ function IsValid: Boolean; override;
+ function ToString(Model: FREE_IMAGE_MDMODEL; Make: PChar = nil): string;
+
+ // properties
+ property Key: string read GetKey write SetKey;
+ property Description: string read GetDescription write SetDescription;
+ property ID: Word read GetID write SetID;
+ property TagType: FREE_IMAGE_MDTYPE read GetTagType write SetTagType;
+ property Count: Cardinal read GetCount write SetCount;
+ property Length: Cardinal read GetLength write SetLength;
+ property Value: Pointer read GetValue write SetValue;
+ property Tag: PFITAG read FTag;
+ end;
+
+ { forward declarations }
+
+ TFreeBitmap = class;
+ TFreeMemoryIO = class;
+
+ { TFreeBitmap }
+
+ TFreeBitmapChangingEvent = procedure(Sender: TFreeBitmap; var OldDib, NewDib: PFIBITMAP; var Handled: Boolean) of object;
+
+ TFreeBitmap = class(TFreeObject)
+ private
+ // fields
+ FDib: PFIBITMAP;
+ FOnChange: TNotifyEvent;
+ FOnChanging: TFreeBitmapChangingEvent;
+
+ procedure SetDib(Value: PFIBITMAP);
+ protected
+ function DoChanging(var OldDib, NewDib: PFIBITMAP): Boolean; dynamic;
+ function Replace(NewDib: PFIBITMAP): Boolean; dynamic;
+ public
+ constructor Create(ImageType: FREE_IMAGE_TYPE = FIT_BITMAP; Width: Integer = 0; Height: Integer = 0; Bpp: Integer = 0);
+ destructor Destroy; override;
+ function SetSize(ImageType: FREE_IMAGE_TYPE; Width, Height, Bpp: Integer; RedMask: Cardinal = 0; GreenMask: Cardinal = 0; BlueMask: Cardinal = 0): Boolean;
+ procedure Change; dynamic;
+ procedure Assign(Source: TFreeBitmap);
+ function CopySubImage(Left, Top, Right, Bottom: Integer; Dest: TFreeBitmap): Boolean;
+ function PasteSubImage(Src: TFreeBitmap; Left, Top: Integer; Alpha: Integer = 256): Boolean;
+ procedure Clear; virtual;
+ function Load(const FileName: string; Flag: Integer = 0): Boolean;
+ function LoadU(const FileName: WideString; Flag: Integer = 0): Boolean;
+ function LoadFromHandle(IO: PFreeImageIO; Handle: fi_handle; Flag: Integer = 0): Boolean;
+ function LoadFromMemory(MemIO: TFreeMemoryIO; Flag: Integer = 0): Boolean;
+ function LoadFromStream(Stream: TStream; Flag: Integer = 0): Boolean;
+ // save functions
+ function CanSave(fif: FREE_IMAGE_FORMAT): Boolean;
+ function Save(const FileName: string; Flag: Integer = 0): Boolean;
+ function SaveU(const FileName: WideString; Flag: Integer = 0): Boolean;
+ function SaveToHandle(fif: FREE_IMAGE_FORMAT; IO: PFreeImageIO; Handle: fi_handle; Flag: Integer = 0): Boolean;
+ function SaveToMemory(fif: FREE_IMAGE_FORMAT; MemIO: TFreeMemoryIO; Flag: Integer = 0): Boolean;
+ function SaveToStream(fif: FREE_IMAGE_FORMAT; Stream: TStream; Flag: Integer = 0): Boolean;
+ // image information
+ function GetImageType: FREE_IMAGE_TYPE;
+ function GetWidth: Integer;
+ function GetHeight: Integer;
+ function GetScanWidth: Integer;
+ function IsValid: Boolean; override;
+ function GetInfo: PBitmapInfo;
+ function GetInfoHeader: PBitmapInfoHeader;
+ function GetImageSize: Cardinal;
+ function GetBitsPerPixel: Integer;
+ function GetLine: Integer;
+ function GetHorizontalResolution: Double;
+ function GetVerticalResolution: Double;
+ procedure SetHorizontalResolution(Value: Double);
+ procedure SetVerticalResolution(Value: Double);
+ // palette operations
+ function GetPalette: PRGBQUAD;
+ function GetPaletteSize: Integer;
+ function GetColorsUsed: Integer;
+ function GetColorType: FREE_IMAGE_COLOR_TYPE;
+ function IsGrayScale: Boolean;
+ // pixels access
+ function AccessPixels: PByte;
+ function GetScanLine(ScanLine: Integer): PByte;
+ function GetPixelIndex(X, Y: Cardinal; var Value: PByte): Boolean;
+ function GetPixelColor(X, Y: Cardinal; Value: PRGBQUAD): Boolean;
+ function SetPixelIndex(X, Y: Cardinal; Value: PByte): Boolean;
+ function SetPixelColor(X, Y: Cardinal; Value: PRGBQUAD): Boolean;
+ // convertion
+ function ConvertToStandardType(ScaleLinear: Boolean): Boolean;
+ function ConvertToType(ImageType: FREE_IMAGE_TYPE; ScaleLinear: Boolean): Boolean;
+ function Threshold(T: Byte): Boolean;
+ function ConvertTo4Bits: Boolean;
+ function ConvertTo8Bits: Boolean;
+ function ConvertTo16Bits555: Boolean;
+ function ConvertTo16Bits565: Boolean;
+ function ConvertTo24Bits: Boolean;
+ function ConvertTo32Bits: Boolean;
+ function ConvertToGrayscale: Boolean;
+ function ColorQuantize(Algorithm: FREE_IMAGE_QUANTIZE): Boolean;
+ function Dither(Algorithm: FREE_IMAGE_DITHER): Boolean;
+ function ConvertToRGBF: Boolean;
+ function ToneMapping(TMO: FREE_IMAGE_TMO; FirstParam, SecondParam: Double): Boolean;
+ // transparency
+ function IsTransparent: Boolean;
+ function GetTransparencyCount: Cardinal;
+ function GetTransparencyTable: PByte;
+ procedure SetTransparencyTable(Table: PByte; Count: Integer);
+ function HasFileBkColor: Boolean;
+ function GetFileBkColor(var BkColor: PRGBQuad): Boolean;
+ function SetFileBkColor(BkColor: PRGBQuad): Boolean;
+ // channel processing routines
+ function GetChannel(Bitmap: TFreeBitmap; Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean;
+ function SetChannel(Bitmap: TFreeBitmap; Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean;
+ function SplitChannels(RedChannel, GreenChannel, BlueChannel: TFreeBitmap): Boolean;
+ function CombineChannels(Red, Green, Blue: TFreeBitmap): Boolean;
+ // rotation and flipping
+ function RotateEx(Angle, XShift, YShift, XOrigin, YOrigin: Double; UseMask: Boolean): Boolean;
+ function Rotate(Angle: Double): Boolean;
+ function FlipHorizontal: Boolean;
+ function FlipVertical: Boolean;
+ // color manipulation routines
+ function Invert: Boolean;
+ function AdjustCurve(Lut: PByte; Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean;
+ function AdjustGamma(Gamma: Double): Boolean;
+ function AdjustBrightness(Percentage: Double): Boolean;
+ function AdjustContrast(Percentage: Double): Boolean;
+ function GetHistogram(Histo: PDWORD; Channel: FREE_IMAGE_COLOR_CHANNEL = FICC_BLACK): Boolean;
+ // upsampling / downsampling
+ procedure MakeThumbnail(const Width, Height: Integer; DestBitmap: TFreeBitmap);
+ function Rescale(NewWidth, NewHeight: Integer; Filter: FREE_IMAGE_FILTER; Dest: TFreeBitmap = nil): Boolean;
+ // metadata routines
+ function FindFirstMetadata(Model: FREE_IMAGE_MDMODEL; var Tag: TFreeTag): PFIMETADATA;
+ function FindNextMetadata(MDHandle: PFIMETADATA; var Tag: TFreeTag): Boolean;
+ procedure FindCloseMetadata(MDHandle: PFIMETADATA);
+ function SetMetadata(Model: FREE_IMAGE_MDMODEL; const Key: string; Tag: TFreeTag): Boolean;
+ function GetMetadata(Model: FREE_IMAGE_MDMODEL; const Key: string; var Tag: TFreeTag): Boolean;
+ function GetMetadataCount(Model: FREE_IMAGE_MDMODEL): Cardinal;
+
+ // properties
+ property Dib: PFIBITMAP read FDib write SetDib;
+ property OnChange: TNotifyEvent read FOnChange write FOnChange;
+ property OnChanging: TFreeBitmapChangingEvent read FOnChanging write FOnChanging;
+ end;
+
+ { TFreeWinBitmap }
+
+
+ { TFreeMemoryIO }
+
+ TFreeMemoryIO = class(TFreeObject)
+ private
+ FHMem: PFIMEMORY;
+ public
+ // construction and destruction
+ constructor Create(Data: PByte = nil; SizeInBytes: DWORD = 0);
+ destructor Destroy; override;
+
+ function GetFileType: FREE_IMAGE_FORMAT;
+ function Read(fif: FREE_IMAGE_FORMAT; Flag: Integer = 0): PFIBITMAP;
+ function Write(fif: FREE_IMAGE_FORMAT; dib: PFIBITMAP; Flag: Integer = 0): Boolean;
+ function Tell: Longint;
+ function Seek(Offset: Longint; Origin: Word): Boolean;
+ function Acquire(var Data: PByte; var SizeInBytes: DWORD): Boolean;
+ // overriden methods
+ function IsValid: Boolean; override;
+ end;
+
+ { TFreeMultiBitmap }
+
+ TFreeMultiBitmap = class(TFreeObject)
+ private
+ FMPage: PFIMULTIBITMAP;
+ FMemoryCache: Boolean;
+ public
+ // constructor and destructor
+ constructor Create(KeepCacheInMemory: Boolean = False);
+ destructor Destroy; override;
+
+ // methods
+ function Open(const FileName: string; CreateNew, ReadOnly: Boolean; Flags: Integer = 0): Boolean;
+ function Close(Flags: Integer = 0): Boolean;
+ function GetPageCount: Integer;
+ procedure AppendPage(Bitmap: TFreeBitmap);
+ procedure InsertPage(Page: Integer; Bitmap: TFreeBitmap);
+ procedure DeletePage(Page: Integer);
+ function MovePage(Target, Source: Integer): Boolean;
+ procedure LockPage(Page: Integer; DestBitmap: TFreeBitmap);
+ procedure UnlockPage(Bitmap: TFreeBitmap; Changed: Boolean);
+ function GetLockedPageNumbers(var Pages: Integer; var Count: Integer): Boolean;
+ // overriden methods
+ function IsValid: Boolean; override;
+
+ // properties
+ // change of this property influences only on the next opening of a file
+ property MemoryCache: Boolean read FMemoryCache write FMemoryCache;
+ end;
+
+implementation
+
+const
+ ThumbSize = 150;
+
+// marker used for clipboard copy / paste
+
+procedure SetFreeImageMarker(bmih: PBitmapInfoHeader; dib: PFIBITMAP);
+begin
+ // Windows constants goes from 0L to 5L
+ // Add $FF to avoid conflicts
+ bmih.biCompression := $FF + FreeImage_GetImageType(dib);
+end;
+
+function GetFreeImageMarker(bmih: PBitmapInfoHeader): FREE_IMAGE_TYPE;
+begin
+ Result := FREE_IMAGE_TYPE(bmih.biCompression - $FF);
+end;
+
+{ TFreePersistent }
+
+function TFreeObject.IsValid: Boolean;
+begin
+ Result := False
+end;
+
+{ TFreeBitmap }
+
+function TFreeBitmap.AccessPixels: PByte;
+begin
+ Result := FreeImage_GetBits(FDib)
+end;
+
+function TFreeBitmap.AdjustBrightness(Percentage: Double): Boolean;
+begin
+ if FDib <> nil then
+ begin
+ Result := FreeImage_AdjustBrightness(FDib, Percentage);
+ Change;
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.AdjustContrast(Percentage: Double): Boolean;
+begin
+ if FDib <> nil then
+ begin
+ Result := FreeImage_AdjustContrast(FDib, Percentage);
+ Change;
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.AdjustCurve(Lut: PByte;
+ Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean;
+begin
+ if FDib <> nil then
+ begin
+ Result := FreeImage_AdjustCurve(FDib, Lut, Channel);
+ Change;
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.AdjustGamma(Gamma: Double): Boolean;
+begin
+ if FDib <> nil then
+ begin
+ Result := FreeImage_AdjustGamma(FDib, Gamma);
+ Change;
+ end
+ else
+ Result := False
+end;
+
+procedure TFreeBitmap.Assign(Source: TFreeBitmap);
+var
+ SourceBmp: TFreeBitmap;
+ Clone: PFIBITMAP;
+begin
+ if Source = nil then
+ begin
+ Clear;
+ Exit;
+ end;
+
+ if Source is TFreeBitmap then
+ begin
+ SourceBmp := TFreeBitmap(Source);
+ if SourceBmp <> Self then
+ begin
+ if SourceBmp.IsValid then
+ begin
+ Clone := FreeImage_Clone(SourceBmp.FDib);
+ Replace(Clone);
+ end
+ else
+ Clear;
+ end;
+ end;
+end;
+
+function TFreeBitmap.CanSave(fif: FREE_IMAGE_FORMAT): Boolean;
+var
+ ImageType: FREE_IMAGE_TYPE;
+ Bpp: Word;
+begin
+ Result := False;
+ if not IsValid then Exit;
+
+ if fif <> FIF_UNKNOWN then
+ begin
+ // check that the dib can be saved in this format
+ ImageType := FreeImage_GetImageType(FDib);
+ if ImageType = FIT_BITMAP then
+ begin
+ // standard bitmap type
+ Bpp := FreeImage_GetBPP(FDib);
+ Result := FreeImage_FIFSupportsWriting(fif)
+ and FreeImage_FIFSupportsExportBPP(fif, Bpp);
+ end
+ else // special bitmap type
+ Result := FreeImage_FIFSupportsExportType(fif, ImageType);
+ end;
+end;
+
+procedure TFreeBitmap.Change;
+begin
+ if Assigned(FOnChange) then FOnChange(Self)
+end;
+
+procedure TFreeBitmap.Clear;
+begin
+ if FDib <> nil then
+ begin
+ FreeImage_Unload(FDib);
+ FDib := nil;
+ Change;
+ end;
+end;
+
+function TFreeBitmap.ColorQuantize(
+ Algorithm: FREE_IMAGE_QUANTIZE): Boolean;
+var
+ dib8: PFIBITMAP;
+begin
+ if FDib <> nil then
+ begin
+ dib8 := FreeImage_ColorQuantize(FDib, Algorithm);
+ Result := Replace(dib8);
+ end
+ else
+ Result := False;
+end;
+
+function TFreeBitmap.CombineChannels(Red, Green,
+ Blue: TFreeBitmap): Boolean;
+var
+ Width, Height: Integer;
+begin
+ if FDib = nil then
+ begin
+ Width := Red.GetWidth;
+ Height := Red.GetHeight;
+ FDib := FreeImage_Allocate(Width, Height, 24, FI_RGBA_RED_MASK,
+ FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);
+ end;
+
+ if FDib <> nil then
+ begin
+ Result := FreeImage_SetChannel(FDib, Red.FDib, FICC_RED) and
+ FreeImage_SetChannel(FDib, Green.FDib, FICC_GREEN) and
+ FreeImage_SetChannel(FDib, Blue.FDib, FICC_BLUE);
+
+ Change
+ end
+ else
+ Result := False;
+end;
+
+function TFreeBitmap.ConvertTo16Bits555: Boolean;
+var
+ dib16_555: PFIBITMAP;
+begin
+ if FDib <> nil then
+ begin
+ dib16_555 := FreeImage_ConvertTo16Bits555(FDib);
+ Result := Replace(dib16_555);
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.ConvertTo16Bits565: Boolean;
+var
+ dib16_565: PFIBITMAP;
+begin
+ if FDib <> nil then
+ begin
+ dib16_565 := FreeImage_ConvertTo16Bits565(FDib);
+ Result := Replace(dib16_565);
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.ConvertTo24Bits: Boolean;
+var
+ dibRGB: PFIBITMAP;
+begin
+ if FDib <> nil then
+ begin
+ dibRGB := FreeImage_ConvertTo24Bits(FDib);
+ Result := Replace(dibRGB);
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.ConvertTo32Bits: Boolean;
+var
+ dib32: PFIBITMAP;
+begin
+ if FDib <> nil then
+ begin
+ dib32 := FreeImage_ConvertTo32Bits(FDib);
+ Result := Replace(dib32);
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.ConvertTo4Bits: Boolean;
+var
+ dib4: PFIBITMAP;
+begin
+ Result := False;
+ if IsValid then
+ begin
+ dib4 := FreeImage_ConvertTo4Bits(FDib);
+ Result := Replace(dib4);
+ end;
+end;
+
+function TFreeBitmap.ConvertTo8Bits: Boolean;
+var
+ dib8: PFIBITMAP;
+begin
+ if FDib <> nil then
+ begin
+ dib8 := FreeImage_ConvertTo8Bits(FDib);
+ Result := Replace(dib8);
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.ConvertToGrayscale: Boolean;
+var
+ dib8: PFIBITMAP;
+begin
+ Result := False;
+
+ if IsValid then
+ begin
+ dib8 := FreeImage_ConvertToGreyscale(FDib);
+ Result := Replace(dib8);
+ end
+end;
+
+function TFreeBitmap.ConvertToRGBF: Boolean;
+var
+ ImageType: FREE_IMAGE_TYPE;
+ NewDib: PFIBITMAP;
+begin
+ Result := False;
+ if not IsValid then Exit;
+
+ ImageType := GetImageType;
+
+ if (ImageType = FIT_BITMAP) then
+ begin
+ if GetBitsPerPixel < 24 then
+ if not ConvertTo24Bits then
+ Exit
+ end;
+ NewDib := FreeImage_ConvertToRGBF(FDib);
+ Result := Replace(NewDib);
+end;
+
+function TFreeBitmap.ConvertToStandardType(ScaleLinear: Boolean): Boolean;
+var
+ dibStandard: PFIBITMAP;
+begin
+ if IsValid then
+ begin
+ dibStandard := FreeImage_ConvertToStandardType(FDib, ScaleLinear);
+ Result := Replace(dibStandard);
+ end
+ else
+ Result := False;
+end;
+
+function TFreeBitmap.ConvertToType(ImageType: FREE_IMAGE_TYPE;
+ ScaleLinear: Boolean): Boolean;
+var
+ dib: PFIBITMAP;
+begin
+ if FDib <> nil then
+ begin
+ dib := FreeImage_ConvertToType(FDib, ImageType, ScaleLinear);
+ Result := Replace(dib)
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.CopySubImage(Left, Top, Right, Bottom: Integer;
+ Dest: TFreeBitmap): Boolean;
+begin
+ if FDib <> nil then
+ begin
+ Dest.FDib := FreeImage_Copy(FDib, Left, Top, Right, Bottom);
+ Result := Dest.IsValid;
+ end else
+ Result := False;
+end;
+
+constructor TFreeBitmap.Create(ImageType: FREE_IMAGE_TYPE; Width, Height,
+ Bpp: Integer);
+begin
+ inherited Create;
+
+ FDib := nil;
+ if (Width > 0) and (Height > 0) and (Bpp > 0) then
+ SetSize(ImageType, Width, Height, Bpp);
+end;
+
+destructor TFreeBitmap.Destroy;
+begin
+ if FDib <> nil then
+ FreeImage_Unload(FDib);
+ inherited;
+end;
+
+function TFreeBitmap.Dither(Algorithm: FREE_IMAGE_DITHER): Boolean;
+var
+ dib: PFIBITMAP;
+begin
+ if FDib <> nil then
+ begin
+ dib := FreeImage_Dither(FDib, Algorithm);
+ Result := Replace(dib);
+ end
+ else
+ Result := False;
+end;
+
+function TFreeBitmap.DoChanging(var OldDib, NewDib: PFIBITMAP): Boolean;
+begin
+ Result := False;
+ if (OldDib <> NewDib) and Assigned(FOnChanging) then
+ FOnChanging(Self, OldDib, NewDib, Result);
+end;
+
+procedure TFreeBitmap.FindCloseMetadata(MDHandle: PFIMETADATA);
+begin
+ FreeImage_FindCloseMetadata(MDHandle);
+end;
+
+function TFreeBitmap.FindFirstMetadata(Model: FREE_IMAGE_MDMODEL;
+ var Tag: TFreeTag): PFIMETADATA;
+begin
+ Result := FreeImage_FindFirstMetadata(Model, FDib, Tag.FTag);
+end;
+
+function TFreeBitmap.FindNextMetadata(MDHandle: PFIMETADATA;
+ var Tag: TFreeTag): Boolean;
+begin
+ Result := FreeImage_FindNextMetadata(MDHandle, Tag.FTag);
+end;
+
+function TFreeBitmap.FlipHorizontal: Boolean;
+begin
+ if FDib <> nil then
+ begin
+ Result := FreeImage_FlipHorizontal(FDib);
+ Change;
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.FlipVertical: Boolean;
+begin
+ if FDib <> nil then
+ begin
+ Result := FreeImage_FlipVertical(FDib);
+ Change;
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.GetBitsPerPixel: Integer;
+begin
+ Result := FreeImage_GetBPP(FDib)
+end;
+
+function TFreeBitmap.GetChannel(Bitmap: TFreeBitmap;
+ Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean;
+begin
+ if FDib <> nil then
+ begin
+ Bitmap.Dib := FreeImage_GetChannel(FDib, Channel);
+ Result := Bitmap.IsValid;
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.GetColorsUsed: Integer;
+begin
+ Result := FreeImage_GetColorsUsed(FDib)
+end;
+
+function TFreeBitmap.GetColorType: FREE_IMAGE_COLOR_TYPE;
+begin
+ Result := FreeImage_GetColorType(FDib);
+end;
+
+function TFreeBitmap.GetFileBkColor(var BkColor: PRGBQuad): Boolean;
+begin
+ Result := FreeImage_GetBackgroundColor(FDib, BkColor)
+end;
+
+function TFreeBitmap.GetHeight: Integer;
+begin
+ Result := FreeImage_GetHeight(FDib)
+end;
+
+function TFreeBitmap.GetHistogram(Histo: PDWORD;
+ Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean;
+begin
+ if FDib <> nil then
+ Result := FreeImage_GetHistogram(FDib, Histo, Channel)
+ else
+ Result := False
+end;
+
+function TFreeBitmap.GetHorizontalResolution: Double;
+begin
+ Result := FreeImage_GetDotsPerMeterX(FDib) / 100
+end;
+
+function TFreeBitmap.GetImageSize: Cardinal;
+begin
+ Result := FreeImage_GetDIBSize(FDib);
+end;
+
+function TFreeBitmap.GetImageType: FREE_IMAGE_TYPE;
+begin
+ Result := FreeImage_GetImageType(FDib);
+end;
+
+function TFreeBitmap.GetInfo: PBitmapInfo;
+begin
+ Result := FreeImage_GetInfo(FDib^)
+end;
+
+function TFreeBitmap.GetInfoHeader: PBITMAPINFOHEADER;
+begin
+ Result := FreeImage_GetInfoHeader(FDib)
+end;
+
+function TFreeBitmap.GetLine: Integer;
+begin
+ Result := FreeImage_GetLine(FDib)
+end;
+
+function TFreeBitmap.GetMetadata(Model: FREE_IMAGE_MDMODEL;
+ const Key: string; var Tag: TFreeTag): Boolean;
+begin
+ Result := FreeImage_GetMetaData(Model, FDib, PChar(Key), Tag.FTag);
+end;
+
+function TFreeBitmap.GetMetadataCount(Model: FREE_IMAGE_MDMODEL): Cardinal;
+begin
+ Result := FreeImage_GetMetadataCount(Model, FDib);
+end;
+
+function TFreeBitmap.GetPalette: PRGBQUAD;
+begin
+ Result := FreeImage_GetPalette(FDib)
+end;
+
+function TFreeBitmap.GetPaletteSize: Integer;
+begin
+ Result := FreeImage_GetColorsUsed(FDib) * SizeOf(RGBQUAD)
+end;
+
+function TFreeBitmap.GetPixelColor(X, Y: Cardinal; Value: PRGBQUAD): Boolean;
+begin
+ Result := FreeImage_GetPixelColor(FDib, X, Y, Value)
+end;
+
+function TFreeBitmap.GetPixelIndex(X, Y: Cardinal;
+ var Value: PByte): Boolean;
+begin
+ Result := FreeImage_GetPixelIndex(FDib, X, Y, Value)
+end;
+
+function TFreeBitmap.GetScanLine(ScanLine: Integer): PByte;
+var
+ H: Integer;
+begin
+ H := FreeImage_GetHeight(FDib);
+ if ScanLine < H then
+ Result := FreeImage_GetScanLine(FDib, ScanLine)
+ else
+ Result := nil;
+end;
+
+function TFreeBitmap.GetScanWidth: Integer;
+begin
+ Result := FreeImage_GetPitch(FDib)
+end;
+
+function TFreeBitmap.GetTransparencyCount: Cardinal;
+begin
+ Result := FreeImage_GetTransparencyCount(FDib)
+end;
+
+function TFreeBitmap.GetTransparencyTable: PByte;
+begin
+ Result := FreeImage_GetTransparencyTable(FDib)
+end;
+
+function TFreeBitmap.GetVerticalResolution: Double;
+begin
+ Result := FreeImage_GetDotsPerMeterY(Fdib) / 100
+end;
+
+function TFreeBitmap.GetWidth: Integer;
+begin
+ Result := FreeImage_GetWidth(FDib)
+end;
+
+function TFreeBitmap.HasFileBkColor: Boolean;
+begin
+ Result := FreeImage_HasBackgroundColor(FDib)
+end;
+
+function TFreeBitmap.Invert: Boolean;
+begin
+ if FDib <> nil then
+ begin
+ Result := FreeImage_Invert(FDib);
+ Change;
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.IsGrayScale: Boolean;
+begin
+ Result := (FreeImage_GetBPP(FDib) = 8)
+ and (FreeImage_GetColorType(FDib) = FIC_PALETTE);
+end;
+
+function TFreeBitmap.IsTransparent: Boolean;
+begin
+ Result := FreeImage_IsTransparent(FDib);
+end;
+
+function TFreeBitmap.IsValid: Boolean;
+begin
+ Result := FDib <> nil
+end;
+
+function TFreeBitmap.Load(const FileName: string; Flag: Integer): Boolean;
+var
+ fif: FREE_IMAGE_FORMAT;
+begin
+
+ // check the file signature and get its format
+ fif := FreeImage_GetFileType(PChar(Filename), 0);
+ if fif = FIF_UNKNOWN then
+ // no signature?
+ // try to guess the file format from the file extention
+ fif := FreeImage_GetFIFFromFilename(PChar(FileName));
+
+ // check that the plugin has reading capabilities ...
+ if (fif <> FIF_UNKNOWN) and FreeImage_FIFSupportsReading(FIF) then
+ begin
+ // free the previous dib
+ if FDib <> nil then
+ FreeImage_Unload(dib);
+
+ // load the file
+ FDib := FreeImage_Load(fif, PChar(FileName), Flag);
+
+ Change;
+ Result := IsValid;
+ end else
+ Result := False;
+end;
+
+function TFreeBitmap.LoadFromHandle(IO: PFreeImageIO; Handle: fi_handle;
+ Flag: Integer): Boolean;
+var
+ fif: FREE_IMAGE_FORMAT;
+begin
+ // check the file signature and get its format
+ fif := FreeImage_GetFileTypeFromHandle(IO, Handle, 16);
+ if (fif <> FIF_UNKNOWN) and FreeImage_FIFSupportsReading(fif) then
+ begin
+ // free the previous dib
+ if FDib <> nil then
+ FreeImage_Unload(FDib);
+
+ // load the file
+ FDib := FreeImage_LoadFromHandle(fif, IO, Handle, Flag);
+
+ Change;
+ Result := IsValid;
+ end else
+ Result := False;
+end;
+
+function TFreeBitmap.LoadFromMemory(MemIO: TFreeMemoryIO;
+ Flag: Integer): Boolean;
+var
+ fif: FREE_IMAGE_FORMAT;
+begin
+
+ // check the file signature and get its format
+ fif := MemIO.GetFileType;
+ if (fif <> FIF_UNKNOWN) and FreeImage_FIFSupportsReading(fif) then
+ begin
+ // free the previous dib
+ if FDib <> nil then
+ FreeImage_Unload(FDib);
+
+ // load the file
+ FDib := MemIO.Read(fif, Flag);
+
+ Result := IsValid;
+ Change;
+ end else
+ Result := False;
+end;
+
+function TFreeBitmap.LoadFromStream(Stream: TStream;
+ Flag: Integer): Boolean;
+var
+ MemIO: TFreeMemoryIO;
+ Data: PByte;
+ MemStream: TMemoryStream;
+ Size: Cardinal;
+begin
+ Size := Stream.Size;
+
+ MemStream := TMemoryStream.Create;
+ try
+ MemStream.CopyFrom(Stream, Size);
+ Data := MemStream.Memory;
+
+ MemIO := TFreeMemoryIO.Create(Data, Size);
+ try
+ Result := LoadFromMemory(MemIO);
+ finally
+ MemIO.Free;
+ end;
+ finally
+ MemStream.Free;
+ end;
+end;
+
+function TFreeBitmap.LoadU(const FileName: WideString;
+ Flag: Integer): Boolean;
+var
+ fif: FREE_IMAGE_FORMAT;
+begin
+
+ // check the file signature and get its format
+ fif := FreeImage_GetFileTypeU(PWideChar(Filename), 0);
+ if fif = FIF_UNKNOWN then
+ // no signature?
+ // try to guess the file format from the file extention
+ fif := FreeImage_GetFIFFromFilenameU(PWideChar(FileName));
+
+ // check that the plugin has reading capabilities ...
+ if (fif <> FIF_UNKNOWN) and FreeImage_FIFSupportsReading(FIF) then
+ begin
+ // free the previous dib
+ if FDib <> nil then
+ FreeImage_Unload(dib);
+
+ // load the file
+ FDib := FreeImage_LoadU(fif, PWideChar(FileName), Flag);
+
+ Change;
+ Result := IsValid;
+ end else
+ Result := False;
+end;
+
+procedure TFreeBitmap.MakeThumbnail(const Width, Height: Integer;
+ DestBitmap: TFreeBitmap);
+type
+ PRGB24 = ^TRGB24;
+ TRGB24 = packed record
+ B: Byte;
+ G: Byte;
+ R: Byte;
+ end;
+var
+ x, y, ix, iy: integer;
+ x1, x2, x3: integer;
+
+ xscale, yscale: single;
+ iRed, iGrn, iBlu, iRatio: Longword;
+ p, c1, c2, c3, c4, c5: TRGB24;
+ pt, pt1: PRGB24;
+ iSrc, iDst, s1: integer;
+ i, j, r, g, b, tmpY: integer;
+
+ RowDest, RowSource, RowSourceStart: integer;
+ w, h: Integer;
+ dxmin, dymin: integer;
+ ny1, ny2, ny3: integer;
+ dx, dy: integer;
+ lutX, lutY: array of integer;
+
+ SrcBmp, DestBmp: PFIBITMAP;
+begin
+ if not IsValid then Exit;
+
+ if (GetWidth <= ThumbSize) and (GetHeight <= ThumbSize) then
+ begin
+ DestBitmap.Assign(Self);
+ Exit;
+ end;
+
+ w := Width;
+ h := Height;
+
+ // prepare bitmaps
+ if GetBitsPerPixel <> 24 then
+ SrcBmp := FreeImage_ConvertTo24Bits(FDib)
+ else
+ SrcBmp := FDib;
+ DestBmp := FreeImage_Allocate(w, h, 24);
+ Assert(DestBmp <> nil, 'TFreeBitmap.MakeThumbnail error');
+
+{ iDst := (w * 24 + 31) and not 31;
+ iDst := iDst div 8; //BytesPerScanline
+ iSrc := (GetWidth * 24 + 31) and not 31;
+ iSrc := iSrc div 8;
+}
+ // BytesPerScanline
+ iDst := FreeImage_GetPitch(DestBmp);
+ iSrc := FreeImage_GetPitch(SrcBmp);
+
+ xscale := 1 / (w / FreeImage_GetWidth(SrcBmp));
+ yscale := 1 / (h / FreeImage_GetHeight(SrcBmp));
+
+ // X lookup table
+ SetLength(lutX, w);
+ x1 := 0;
+ x2 := trunc(xscale);
+ for x := 0 to w - 1 do
+ begin
+ lutX[x] := x2 - x1;
+ x1 := x2;
+ x2 := trunc((x + 2) * xscale);
+ end;
+
+ // Y lookup table
+ SetLength(lutY, h);
+ x1 := 0;
+ x2 := trunc(yscale);
+ for x := 0 to h - 1 do
+ begin
+ lutY[x] := x2 - x1;
+ x1 := x2;
+ x2 := trunc((x + 2) * yscale);
+ end;
+
+ Dec(w);
+ Dec(h);
+ RowDest := integer(FreeImage_GetScanLine(DestBmp, 0));
+ RowSourceStart := integer(FreeImage_GetScanLine(SrcBmp, 0));
+ RowSource := RowSourceStart;
+
+ for y := 0 to h do
+ // resampling
+ begin
+ dy := lutY[y];
+ x1 := 0;
+ x3 := 0;
+ for x := 0 to w do // loop through row
+ begin
+ dx:= lutX[x];
+ iRed:= 0;
+ iGrn:= 0;
+ iBlu:= 0;
+ RowSource := RowSourceStart;
+ for iy := 1 to dy do
+ begin
+ pt := PRGB24(RowSource + x1);
+ for ix := 1 to dx do
+ begin
+ iRed := iRed + pt.R;
+ iGrn := iGrn + pt.G;
+ iBlu := iBlu + pt.B;
+ inc(pt);
+ end;
+ RowSource := RowSource + iSrc;
+ end;
+ iRatio := 65535 div (dx * dy);
+ pt1 := PRGB24(RowDest + x3);
+ pt1.R := (iRed * iRatio) shr 16;
+ pt1.G := (iGrn * iRatio) shr 16;
+ pt1.B := (iBlu * iRatio) shr 16;
+ x1 := x1 + 3 * dx;
+ inc(x3,3);
+ end;
+ RowDest := RowDest + iDst;
+ RowSourceStart := RowSource;
+ end; // resampling
+
+ if FreeImage_GetHeight(DestBmp) >= 3 then
+ // Sharpening...
+ begin
+ s1 := integer(FreeImage_GetScanLine(DestBmp, 0));
+ iDst := integer(FreeImage_GetScanLine(DestBmp, 1)) - s1;
+ ny1 := Integer(s1);
+ ny2 := ny1 + iDst;
+ ny3 := ny2 + iDst;
+ for y := 1 to FreeImage_GetHeight(DestBmp) - 2 do
+ begin
+ for x := 0 to FreeImage_GetWidth(DestBmp) - 3 do
+ begin
+ x1 := x * 3;
+ x2 := x1 + 3;
+ x3 := x1 + 6;
+
+ c1 := pRGB24(ny1 + x1)^;
+ c2 := pRGB24(ny1 + x3)^;
+ c3 := pRGB24(ny2 + x2)^;
+ c4 := pRGB24(ny3 + x1)^;
+ c5 := pRGB24(ny3 + x3)^;
+
+ r := (c1.R + c2.R + (c3.R * -12) + c4.R + c5.R) div -8;
+ g := (c1.G + c2.G + (c3.G * -12) + c4.G + c5.G) div -8;
+ b := (c1.B + c2.B + (c3.B * -12) + c4.B + c5.B) div -8;
+
+ if r < 0 then r := 0 else if r > 255 then r := 255;
+ if g < 0 then g := 0 else if g > 255 then g := 255;
+ if b < 0 then b := 0 else if b > 255 then b := 255;
+
+ pt1 := pRGB24(ny2 + x2);
+ pt1.R := r;
+ pt1.G := g;
+ pt1.B := b;
+ end;
+ inc(ny1, iDst);
+ inc(ny2, iDst);
+ inc(ny3, iDst);
+ end;
+ end; // sharpening
+
+ if SrcBmp <> FDib then
+ FreeImage_Unload(SrcBmp);
+ DestBitmap.Replace(DestBmp);
+end;
+
+function TFreeBitmap.PasteSubImage(Src: TFreeBitmap; Left, Top,
+ Alpha: Integer): Boolean;
+begin
+ if FDib <> nil then
+ begin
+ Result := FreeImage_Paste(FDib, Src.Dib, Left, Top, Alpha);
+ Change;
+ end else
+ Result := False;
+end;
+
+function TFreeBitmap.Replace(NewDib: PFIBITMAP): Boolean;
+begin
+ Result := False;
+ if NewDib = nil then Exit;
+
+ if not DoChanging(FDib, NewDib) and IsValid then
+ FreeImage_Unload(FDib);
+
+ FDib := NewDib;
+ Result := True;
+ Change;
+end;
+
+function TFreeBitmap.Rescale(NewWidth, NewHeight: Integer;
+ Filter: FREE_IMAGE_FILTER; Dest: TFreeBitmap): Boolean;
+var
+ Bpp: Integer;
+ DstDib: PFIBITMAP;
+begin
+ Result := False;
+
+ if FDib <> nil then
+ begin
+ Bpp := FreeImage_GetBPP(FDib);
+
+ if Bpp < 8 then
+ if not ConvertToGrayscale then Exit
+ else
+ if Bpp = 16 then
+ // convert to 24-bit
+ if not ConvertTo24Bits then Exit;
+
+ // perform upsampling / downsampling
+ DstDib := FreeImage_Rescale(FDib, NewWidth, NewHeight, Filter);
+ if Dest = nil then
+ Result := Replace(DstDib)
+ else
+ Result := Dest.Replace(DstDib)
+ end
+end;
+
+function TFreeBitmap.Rotate(Angle: Double): Boolean;
+var
+ Bpp: Integer;
+ Rotated: PFIBITMAP;
+begin
+ Result := False;
+ if IsValid then
+ begin
+ Bpp := FreeImage_GetBPP(FDib);
+ if Bpp in [1, 8, 24, 32] then
+ begin
+ Rotated := FreeImage_RotateClassic(FDib, Angle);
+ Result := Replace(Rotated);
+ end
+ end;
+end;
+
+function TFreeBitmap.RotateEx(Angle, XShift, YShift, XOrigin,
+ YOrigin: Double; UseMask: Boolean): Boolean;
+var
+ Rotated: PFIBITMAP;
+begin
+ Result := False;
+ if FDib <> nil then
+ begin
+ if FreeImage_GetBPP(FDib) >= 8 then
+ begin
+ Rotated := FreeImage_RotateEx(FDib, Angle, XShift, YShift, XOrigin, YOrigin, UseMask);
+ Result := Replace(Rotated);
+ end
+ end;
+end;
+
+function TFreeBitmap.Save(const FileName: string; Flag: Integer): Boolean;
+var
+ fif: FREE_IMAGE_FORMAT;
+begin
+ Result := False;
+
+ // try to guess the file format from the file extension
+ fif := FreeImage_GetFIFFromFilename(PChar(Filename));
+ if CanSave(fif) then
+ Result := FreeImage_Save(fif, FDib, PChar(FileName), Flag);
+end;
+
+function TFreeBitmap.SaveToHandle(fif: FREE_IMAGE_FORMAT; IO: PFreeImageIO;
+ Handle: fi_handle; Flag: Integer): Boolean;
+begin
+ Result := False;
+ if CanSave(fif) then
+ Result := FreeImage_SaveToHandle(fif, FDib, IO, Handle, Flag)
+end;
+
+function TFreeBitmap.SaveToMemory(fif: FREE_IMAGE_FORMAT;
+ MemIO: TFreeMemoryIO; Flag: Integer): Boolean;
+begin
+ Result := False;
+
+ if CanSave(fif) then
+ Result := MemIO.Write(fif, FDib, Flag)
+end;
+
+function TFreeBitmap.SaveToStream(fif: FREE_IMAGE_FORMAT; Stream: TStream;
+ Flag: Integer): Boolean;
+var
+ MemIO: TFreeMemoryIO;
+ Data: PByte;
+ Size: Cardinal;
+begin
+ MemIO := TFreeMemoryIO.Create;
+ try
+ Result := SaveToMemory(fif, MemIO, Flag);
+ if Result then
+ begin
+ MemIO.Acquire(Data, Size);
+ Stream.WriteBuffer(Data^, Size);
+ end;
+ finally
+ MemIO.Free;
+ end;
+end;
+
+function TFreeBitmap.SaveU(const FileName: WideString;
+ Flag: Integer): Boolean;
+var
+ fif: FREE_IMAGE_FORMAT;
+begin
+ Result := False;
+
+ // try to guess the file format from the file extension
+ fif := FreeImage_GetFIFFromFilenameU(PWideChar(Filename));
+ if CanSave(fif) then
+ Result := FreeImage_SaveU(fif, FDib, PWideChar(FileName), Flag);
+end;
+
+function TFreeBitmap.SetChannel(Bitmap: TFreeBitmap;
+ Channel: FREE_IMAGE_COLOR_CHANNEL): Boolean;
+begin
+ if FDib <> nil then
+ begin
+ Result := FreeImage_SetChannel(FDib, Bitmap.FDib, Channel);
+ Change;
+ end
+ else
+ Result := False
+end;
+
+procedure TFreeBitmap.SetDib(Value: PFIBITMAP);
+begin
+ Replace(Value);
+end;
+
+function TFreeBitmap.SetFileBkColor(BkColor: PRGBQuad): Boolean;
+begin
+ Result := FreeImage_SetBackgroundColor(FDib, BkColor);
+ Change;
+end;
+
+procedure TFreeBitmap.SetHorizontalResolution(Value: Double);
+begin
+ if IsValid then
+ begin
+ FreeImage_SetDotsPerMeterX(FDib, Trunc(Value * 100 + 0.5));
+ Change;
+ end;
+end;
+
+function TFreeBitmap.SetMetadata(Model: FREE_IMAGE_MDMODEL;
+ const Key: string; Tag: TFreeTag): Boolean;
+begin
+ Result := FreeImage_SetMetadata(Model, FDib, PChar(Key), Tag.Tag);
+end;
+
+function TFreeBitmap.SetPixelColor(X, Y: Cardinal;
+ Value: PRGBQUAD): Boolean;
+begin
+ Result := FreeImage_SetPixelColor(FDib, X, Y, Value);
+ Change;
+end;
+
+function TFreeBitmap.SetPixelIndex(X, Y: Cardinal; Value: PByte): Boolean;
+begin
+ Result := FreeImage_SetPixelIndex(FDib, X, Y, Value);
+ Change;
+end;
+
+function TFreeBitmap.SetSize(ImageType: FREE_IMAGE_TYPE; Width, Height,
+ Bpp: Integer; RedMask, GreenMask, BlueMask: Cardinal): Boolean;
+var
+ Pal: PRGBQuad;
+ I: Cardinal;
+begin
+ Result := False;
+
+ if FDib <> nil then
+ FreeImage_Unload(FDib);
+
+ FDib := FreeImage_Allocate(Width, Height, Bpp, RedMask, GreenMask, BlueMask);
+ if FDib = nil then Exit;
+
+ if ImageType = FIT_BITMAP then
+ case Bpp of
+ 1, 4, 8:
+ begin
+ Pal := FreeImage_GetPalette(FDib);
+ for I := 0 to FreeImage_GetColorsUsed(FDib) - 1 do
+ begin
+ Pal.rgbBlue := I;
+ Pal.rgbGreen := I;
+ Pal.rgbRed := I;
+ Inc(Pal, SizeOf(RGBQUAD));
+ end;
+ end;
+ end;
+
+ Result := True;
+ Change;
+end;
+
+procedure TFreeBitmap.SetTransparencyTable(Table: PByte; Count: Integer);
+begin
+ FreeImage_SetTransparencyTable(FDib, Table, Count);
+ Change;
+end;
+
+procedure TFreeBitmap.SetVerticalResolution(Value: Double);
+begin
+ if IsValid then
+ begin
+ FreeImage_SetDotsPerMeterY(FDib, Trunc(Value * 100 + 0.5));
+ Change;
+ end;
+end;
+
+function TFreeBitmap.SplitChannels(RedChannel, GreenChannel,
+ BlueChannel: TFreeBitmap): Boolean;
+begin
+ if FDib <> nil then
+ begin
+ RedChannel.FDib := FreeImage_GetChannel(FDib, FICC_RED);
+ GreenChannel.FDib := FreeImage_GetChannel(FDib, FICC_GREEN);
+ BlueChannel.FDib := FreeImage_GetChannel(FDib, FICC_BLUE);
+ Result := RedChannel.IsValid and GreenChannel.IsValid and BlueChannel.IsValid;
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.Threshold(T: Byte): Boolean;
+var
+ dib1: PFIBITMAP;
+begin
+ if FDib <> nil then
+ begin
+ dib1 := FreeImage_Threshold(FDib, T);
+ Result := Replace(dib1);
+ end
+ else
+ Result := False
+end;
+
+function TFreeBitmap.ToneMapping(TMO: FREE_IMAGE_TMO; FirstParam,
+ SecondParam: Double): Boolean;
+var
+ NewDib: PFIBITMAP;
+begin
+ Result := False;
+ if not IsValid then Exit;
+
+ NewDib := FreeImage_ToneMapping(Fdib, TMO, FirstParam, SecondParam);
+ Result := Replace(NewDib);
+end;
+
+
+{ TFreeMultiBitmap }
+
+procedure TFreeMultiBitmap.AppendPage(Bitmap: TFreeBitmap);
+begin
+ if IsValid then
+ FreeImage_AppendPage(FMPage, Bitmap.FDib);
+end;
+
+function TFreeMultiBitmap.Close(Flags: Integer): Boolean;
+begin
+ Result := FreeImage_CloseMultiBitmap(FMPage, Flags);
+ FMPage := nil;
+end;
+
+constructor TFreeMultiBitmap.Create(KeepCacheInMemory: Boolean);
+begin
+ inherited Create;
+ FMemoryCache := KeepCacheInMemory;
+end;
+
+procedure TFreeMultiBitmap.DeletePage(Page: Integer);
+begin
+ if IsValid then
+ FreeImage_DeletePage(FMPage, Page);
+end;
+
+destructor TFreeMultiBitmap.Destroy;
+begin
+ if FMPage <> nil then Close;
+ inherited;
+end;
+
+function TFreeMultiBitmap.GetLockedPageNumbers(var Pages,
+ Count: Integer): Boolean;
+begin
+ Result := False;
+ if not IsValid then Exit;
+ Result := FreeImage_GetLockedPageNumbers(FMPage, Pages, Count)
+end;
+
+function TFreeMultiBitmap.GetPageCount: Integer;
+begin
+ Result := 0;
+ if IsValid then
+ Result := FreeImage_GetPageCount(FMPage)
+end;
+
+procedure TFreeMultiBitmap.InsertPage(Page: Integer; Bitmap: TFreeBitmap);
+begin
+ if IsValid then
+ FreeImage_InsertPage(FMPage, Page, Bitmap.FDib);
+end;
+
+function TFreeMultiBitmap.IsValid: Boolean;
+begin
+ Result := FMPage <> nil
+end;
+
+procedure TFreeMultiBitmap.LockPage(Page: Integer; DestBitmap: TFreeBitmap);
+begin
+ if not IsValid then Exit;
+
+ if Assigned(DestBitmap) then
+ begin
+ DestBitmap.Replace(FreeImage_LockPage(FMPage, Page));
+ end;
+end;
+
+function TFreeMultiBitmap.MovePage(Target, Source: Integer): Boolean;
+begin
+ Result := False;
+ if not IsValid then Exit;
+ Result := FreeImage_MovePage(FMPage, Target, Source);
+end;
+
+function TFreeMultiBitmap.Open(const FileName: string; CreateNew,
+ ReadOnly: Boolean; Flags: Integer): Boolean;
+var
+ fif: FREE_IMAGE_FORMAT;
+begin
+ Result := False;
+
+ // try to guess the file format from the filename
+ fif := FreeImage_GetFIFFromFilename(PChar(FileName));
+
+ // check for supported file types
+ if (fif <> FIF_UNKNOWN) and (not fif in [FIF_TIFF, FIF_ICO, FIF_GIF]) then
+ Exit;
+
+ // open the stream
+ FMPage := FreeImage_OpenMultiBitmap(fif, PChar(FileName), CreateNew, ReadOnly, FMemoryCache, Flags);
+
+ Result := FMPage <> nil;
+end;
+
+procedure TFreeMultiBitmap.UnlockPage(Bitmap: TFreeBitmap;
+ Changed: Boolean);
+begin
+ if IsValid then
+ begin
+ FreeImage_UnlockPage(FMPage, Bitmap.FDib, Changed);
+ // clear the image so that it becomes invalid.
+ // don't use Bitmap.Clear method because it calls FreeImage_Unload
+ // just clear the pointer
+ Bitmap.FDib := nil;
+ Bitmap.Change;
+ end;
+end;
+
+{ TFreeMemoryIO }
+
+function TFreeMemoryIO.Acquire(var Data: PByte;
+ var SizeInBytes: DWORD): Boolean;
+begin
+ Result := FreeImage_AcquireMemory(FHMem, Data, SizeInBytes);
+end;
+
+constructor TFreeMemoryIO.Create(Data: PByte; SizeInBytes: DWORD);
+begin
+ inherited Create;
+ FHMem := FreeImage_OpenMemory(Data, SizeInBytes);
+end;
+
+destructor TFreeMemoryIO.Destroy;
+begin
+ FreeImage_CloseMemory(FHMem);
+ inherited;
+end;
+
+function TFreeMemoryIO.GetFileType: FREE_IMAGE_FORMAT;
+begin
+ Result := FreeImage_GetFileTypeFromMemory(FHMem);
+end;
+
+function TFreeMemoryIO.IsValid: Boolean;
+begin
+ Result := FHMem <> nil
+end;
+
+function TFreeMemoryIO.Read(fif: FREE_IMAGE_FORMAT;
+ Flag: Integer): PFIBITMAP;
+begin
+ Result := FreeImage_LoadFromMemory(fif, FHMem, Flag)
+end;
+
+function TFreeMemoryIO.Seek(Offset: Longint; Origin: Word): Boolean;
+begin
+ Result := FreeImage_SeekMemory(FHMem, Offset, Origin)
+end;
+
+function TFreeMemoryIO.Tell: Longint;
+begin
+ Result := FreeImage_TellMemory(FHMem)
+end;
+
+function TFreeMemoryIO.Write(fif: FREE_IMAGE_FORMAT; dib: PFIBITMAP;
+ Flag: Integer): Boolean;
+begin
+ Result := FreeImage_SaveToMemory(fif, dib, FHMem, Flag)
+end;
+
+{ TFreeTag }
+
+function TFreeTag.Clone: TFreeTag;
+var
+ CloneTag: PFITAG;
+begin
+ Result := nil;
+ if not IsValid then Exit;
+
+ CloneTag := FreeImage_CloneTag(FTag);
+ Result := TFreeTag.Create(CloneTag);
+end;
+
+constructor TFreeTag.Create(ATag: PFITAG);
+begin
+ inherited Create;
+
+ if ATag <> nil then
+ FTag := ATag
+ else
+ FTag := FreeImage_CreateTag;
+end;
+
+destructor TFreeTag.Destroy;
+begin
+ if IsValid then
+ FreeImage_DeleteTag(FTag);
+
+ inherited;
+end;
+
+function TFreeTag.GetCount: Cardinal;
+begin
+ Result := 0;
+ if not IsValid then Exit;
+
+ Result := FreeImage_GetTagCount(FTag);
+end;
+
+function TFreeTag.GetDescription: string;
+begin
+ Result := '';
+ if not IsValid then Exit;
+
+ Result := FreeImage_GetTagDescription(FTag);
+end;
+
+function TFreeTag.GetID: Word;
+begin
+ Result := 0;
+ if not IsValid then Exit;
+
+ Result := FreeImage_GetTagID(FTag);
+end;
+
+function TFreeTag.GetKey: string;
+begin
+ Result := '';
+ if not IsValid then Exit;
+
+ Result := FreeImage_GetTagKey(FTag);
+end;
+
+function TFreeTag.GetLength: Cardinal;
+begin
+ Result := 0;
+ if not IsValid then Exit;
+
+ Result := FreeImage_GetTagLength(FTag);
+end;
+
+function TFreeTag.GetTagType: FREE_IMAGE_MDTYPE;
+begin
+ Result := FIDT_NOTYPE;
+ if not IsValid then Exit;
+
+ Result := FreeImage_GetTagType(FTag);
+end;
+
+function TFreeTag.GetValue: Pointer;
+begin
+ Result := nil;
+ if not IsValid then Exit;
+
+ Result := FreeImage_GetTagValue(FTag);
+end;
+
+function TFreeTag.IsValid: Boolean;
+begin
+ Result := FTag <> nil;
+end;
+
+procedure TFreeTag.SetCount(const Value: Cardinal);
+begin
+ if IsValid then
+ FreeImage_SetTagCount(FTag, Value);
+end;
+
+procedure TFreeTag.SetDescription(const Value: string);
+begin
+ if IsValid then
+ FreeImage_SetTagDescription(FTag, PChar(Value));
+end;
+
+procedure TFreeTag.SetID(const Value: Word);
+begin
+ if IsValid then
+ FreeImage_SetTagID(FTag, Value);
+end;
+
+procedure TFreeTag.SetKey(const Value: string);
+begin
+ if IsValid then
+ FreeImage_SetTagKey(FTag, PChar(Value));
+end;
+
+procedure TFreeTag.SetLength(const Value: Cardinal);
+begin
+ if IsValid then
+ FreeImage_SetTagLength(FTag, Value);
+end;
+
+procedure TFreeTag.SetTagType(const Value: FREE_IMAGE_MDTYPE);
+begin
+ if IsValid then
+ FreeImage_SetTagType(FTag, Value);
+end;
+
+procedure TFreeTag.SetValue(const Value: Pointer);
+begin
+ if IsValid then
+ FreeImage_SetTagValue(FTag, Value);
+end;
+
+function TFreeTag.ToString(Model: FREE_IMAGE_MDMODEL; Make: PChar): string;
+begin
+ Result := FreeImage_TagToString(Model, FTag, Make);
+end;
+
+end.
diff --git a/Game/Code/lib/FreeImage/FreeImage.pas b/Game/Code/lib/FreeImage/FreeImage.pas new file mode 100755 index 00000000..a1c0e7de --- /dev/null +++ b/Game/Code/lib/FreeImage/FreeImage.pas @@ -0,0 +1,743 @@ +unit FreeImage; + +{$I switches.inc} + + + + +// ========================================================== +// Delphi wrapper for FreeImage 3 +// +// Design and implementation by +// - Simon Beavis +// - Peter Byström +// - Anatoliy Pulyaevskiy (xvel84@rambler.ru) +// +// This file is part of FreeImage 3 +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY +// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES +// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE +// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED +// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT +// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY +// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL +// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER +// THIS DISCLAIMER. +// +// Use at your own risk! +// ========================================================== + +interface + +uses Windows; + +{$MINENUMSIZE 4} // Make sure enums are stored as an integer to be compatible with C/C++ + +const + FIDLL = 'libfreeimage.dylib'; + +// -------------------------------------------------------------------------- +// Bitmap types ------------------------------------------------------------- +// -------------------------------------------------------------------------- + +type + FIBITMAP = record + data : Pointer; + end; + PFIBITMAP = ^FIBITMAP; + + FIMULTIBITMAP = record + data : Pointer; + end; + PFIMULTIBITMAP = ^FIMULTIBITMAP; + +// -------------------------------------------------------------------------- +// Indexes for byte arrays, masks and shifts for treating pixels as words --- +// These coincide with the order of RGBQUAD and RGBTRIPLE ------------------- +// Little Endian (x86 / MS Windows, Linux) : BGR(A) order ------------------- +// -------------------------------------------------------------------------- + +const + FI_RGBA_RED = 2; + FI_RGBA_GREEN = 1; + FI_RGBA_BLUE = 0; + FI_RGBA_ALPHA = 3; + FI_RGBA_RED_MASK = $00FF0000; + FI_RGBA_GREEN_MASK = $0000FF00; + FI_RGBA_BLUE_MASK = $000000FF; + FI_RGBA_ALPHA_MASK = $FF000000; + FI_RGBA_RED_SHIFT = 16; + FI_RGBA_GREEN_SHIFT = 8; + FI_RGBA_BLUE_SHIFT = 0; + FI_RGBA_ALPHA_SHIFT = 24; + +// -------------------------------------------------------------------------- +// The 16bit macros only include masks and shifts, -------------------------- +// since each color element is not byte aligned ----------------------------- +// -------------------------------------------------------------------------- + +const + FI16_555_RED_MASK = $7C00; + FI16_555_GREEN_MASK = $03E0; + FI16_555_BLUE_MASK = $001F; + FI16_555_RED_SHIFT = 10; + FI16_555_GREEN_SHIFT = 5; + FI16_555_BLUE_SHIFT = 0; + FI16_565_RED_MASK = $F800; + FI16_565_GREEN_MASK = $07E0; + FI16_565_BLUE_MASK = $001F; + FI16_565_RED_SHIFT = 11; + FI16_565_GREEN_SHIFT = 5; + FI16_565_BLUE_SHIFT = 0; + +// -------------------------------------------------------------------------- +// ICC profile support ------------------------------------------------------ +// -------------------------------------------------------------------------- + +const + FIICC_DEFAULT = $0; + FIICC_COLOR_IS_CMYK = $1; + +type + FIICCPROFILE = record + flags : WORD; // info flag + size : DWORD; // profile's size measured in bytes + data : Pointer; // points to a block of contiguous memory containing the profile + end; + PFIICCPROFILE = ^FIICCPROFILE; + +// -------------------------------------------------------------------------- +// Important enums ---------------------------------------------------------- +// -------------------------------------------------------------------------- + +type + FREE_IMAGE_FORMAT = type Integer; + FREE_IMAGE_TYPE = type Integer; + FREE_IMAGE_COLOR_TYPE = type Integer; + FREE_IMAGE_QUANTIZE = type Integer; + FREE_IMAGE_DITHER = type Integer; + FREE_IMAGE_FILTER = type Integer; + FREE_IMAGE_COLOR_CHANNEL = type Integer; + FREE_IMAGE_MDTYPE = type Integer; + FREE_IMAGE_MDMODEL = type Integer; + FREE_IMAGE_JPEG_OPERATION = type Integer; + FREE_IMAGE_TMO = type Integer; + +const + // I/O image format identifiers. + FIF_UNKNOWN = FREE_IMAGE_FORMAT(-1); + FIF_BMP = FREE_IMAGE_FORMAT(0); + FIF_ICO = FREE_IMAGE_FORMAT(1); + FIF_JPEG = FREE_IMAGE_FORMAT(2); + FIF_JNG = FREE_IMAGE_FORMAT(3); + FIF_KOALA = FREE_IMAGE_FORMAT(4); + FIF_LBM = FREE_IMAGE_FORMAT(5); + FIF_IFF = FIF_LBM; + FIF_MNG = FREE_IMAGE_FORMAT(6); + FIF_PBM = FREE_IMAGE_FORMAT(7); + FIF_PBMRAW = FREE_IMAGE_FORMAT(8); + FIF_PCD = FREE_IMAGE_FORMAT(9); + FIF_PCX = FREE_IMAGE_FORMAT(10); + FIF_PGM = FREE_IMAGE_FORMAT(11); + FIF_PGMRAW = FREE_IMAGE_FORMAT(12); + FIF_PNG = FREE_IMAGE_FORMAT(13); + FIF_PPM = FREE_IMAGE_FORMAT(14); + FIF_PPMRAW = FREE_IMAGE_FORMAT(15); + FIF_RAS = FREE_IMAGE_FORMAT(16); + FIF_TARGA = FREE_IMAGE_FORMAT(17); + FIF_TIFF = FREE_IMAGE_FORMAT(18); + FIF_WBMP = FREE_IMAGE_FORMAT(19); + FIF_PSD = FREE_IMAGE_FORMAT(20); + FIF_CUT = FREE_IMAGE_FORMAT(21); + FIF_XBM = FREE_IMAGE_FORMAT(22); + FIF_XPM = FREE_IMAGE_FORMAT(23); + FIF_DDS = FREE_IMAGE_FORMAT(24); + FIF_GIF = FREE_IMAGE_FORMAT(25); + FIF_HDR = FREE_IMAGE_FORMAT(26); + FIF_FAXG3 = FREE_IMAGE_FORMAT(27); + FIF_SGI = FREE_IMAGE_FORMAT(28); + + // Image type used in FreeImage. + FIT_UNKNOWN = FREE_IMAGE_TYPE(0); // unknown type + FIT_BITMAP = FREE_IMAGE_TYPE(1); // standard image: 1-, 4-, 8-, 16-, 24-, 32-bit + FIT_UINT16 = FREE_IMAGE_TYPE(2); // array of unsigned short: unsigned 16-bit + FIT_INT16 = FREE_IMAGE_TYPE(3); // array of short: signed 16-bit + FIT_UINT32 = FREE_IMAGE_TYPE(4); // array of unsigned long: unsigned 32-bit + FIT_INT32 = FREE_IMAGE_TYPE(5); // array of long: signed 32-bit + FIT_FLOAT = FREE_IMAGE_TYPE(6); // array of float: 32-bit IEEE floating point + FIT_DOUBLE = FREE_IMAGE_TYPE(7); // array of double: 64-bit IEEE floating point + FIT_COMPLEX = FREE_IMAGE_TYPE(8); // array of FICOMPLEX: 2 x 64-bit IEEE floating point + FIT_RGB16 = FREE_IMAGE_TYPE(9); // 48-bit RGB image: 3 x 16-bit + FIT_RGBA16 = FREE_IMAGE_TYPE(10); // 64-bit RGBA image: 4 x 16-bit + FIT_RGBF = FREE_IMAGE_TYPE(11); // 96-bit RGB float image: 3 x 32-bit IEEE floating point + FIT_RGBAF = FREE_IMAGE_TYPE(12); // 128-bit RGBA float image: 4 x 32-bit IEEE floating point + + // Image color type used in FreeImage. + FIC_MINISWHITE = FREE_IMAGE_COLOR_TYPE(0); // min value is white + FIC_MINISBLACK = FREE_IMAGE_COLOR_TYPE(1); // min value is black + FIC_RGB = FREE_IMAGE_COLOR_TYPE(2); // RGB color model + FIC_PALETTE = FREE_IMAGE_COLOR_TYPE(3); // color map indexed + FIC_RGBALPHA = FREE_IMAGE_COLOR_TYPE(4); // RGB color model with alpha channel + FIC_CMYK = FREE_IMAGE_COLOR_TYPE(5); // CMYK color model + + // Color quantization algorithms. Constants used in FreeImage_ColorQuantize. + FIQ_WUQUANT = FREE_IMAGE_QUANTIZE(0); // Xiaolin Wu color quantization algorithm + FIQ_NNQUANT = FREE_IMAGE_QUANTIZE(1); // NeuQuant neural-net quantization algorithm by Anthony Dekker + + // Dithering algorithms. Constants used FreeImage_Dither. + FID_FS = FREE_IMAGE_DITHER(0); // Floyd & Steinberg error diffusion + FID_BAYER4x4 = FREE_IMAGE_DITHER(1); // Bayer ordered dispersed dot dithering (order 2 dithering matrix) + FID_BAYER8x8 = FREE_IMAGE_DITHER(2); // Bayer ordered dispersed dot dithering (order 3 dithering matrix) + FID_CLUSTER6x6 = FREE_IMAGE_DITHER(3); // Ordered clustered dot dithering (order 3 - 6x6 matrix) + FID_CLUSTER8x8 = FREE_IMAGE_DITHER(4); // Ordered clustered dot dithering (order 4 - 8x8 matrix) + FID_CLUSTER16x16 = FREE_IMAGE_DITHER(5); // Ordered clustered dot dithering (order 8 - 16x16 matrix) + + // Lossless JPEG transformations Constants used in FreeImage_JPEGTransform + FIJPEG_OP_NONE = FREE_IMAGE_JPEG_OPERATION(0); // no transformation + FIJPEG_OP_FLIP_H = FREE_IMAGE_JPEG_OPERATION(1); // horizontal flip + FIJPEG_OP_FLIP_V = FREE_IMAGE_JPEG_OPERATION(2); // vertical flip + FIJPEG_OP_TRANSPOSE = FREE_IMAGE_JPEG_OPERATION(3); // transpose across UL-to-LR axis + FIJPEG_OP_TRANSVERSE = FREE_IMAGE_JPEG_OPERATION(4); // transpose across UR-to-LL axis + FIJPEG_OP_ROTATE_90 = FREE_IMAGE_JPEG_OPERATION(5); // 90-degree clockwise rotation + FIJPEG_OP_ROTATE_180 = FREE_IMAGE_JPEG_OPERATION(6); // 180-degree rotation + FIJPEG_OP_ROTATE_270 = FREE_IMAGE_JPEG_OPERATION(7); // 270-degree clockwise (or 90 ccw) + + // Tone mapping operators. Constants used in FreeImage_ToneMapping. + FITMO_DRAGO03 = FREE_IMAGE_TMO(0); // Adaptive logarithmic mapping (F. Drago, 2003) + FITMO_REINHARD05 = FREE_IMAGE_TMO(1); // Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005) + + // Upsampling / downsampling filters. Constants used in FreeImage_Rescale. + FILTER_BOX = FREE_IMAGE_FILTER(0); // Box, pulse, Fourier window, 1st order (constant) b-spline + FILTER_BICUBIC = FREE_IMAGE_FILTER(1); // Mitchell & Netravali's two-param cubic filter + FILTER_BILINEAR = FREE_IMAGE_FILTER(2); // Bilinear filter + FILTER_BSPLINE = FREE_IMAGE_FILTER(3); // 4th order (cubic) b-spline + FILTER_CATMULLROM = FREE_IMAGE_FILTER(4); // Catmull-Rom spline, Overhauser spline + FILTER_LANCZOS3 = FREE_IMAGE_FILTER(5); // Lanczos3 filter + + // Color channels. Constants used in color manipulation routines. + FICC_RGB = FREE_IMAGE_COLOR_CHANNEL(0); // Use red, green and blue channels + FICC_RED = FREE_IMAGE_COLOR_CHANNEL(1); // Use red channel + FICC_GREEN = FREE_IMAGE_COLOR_CHANNEL(2); // Use green channel + FICC_BLUE = FREE_IMAGE_COLOR_CHANNEL(3); // Use blue channel + FICC_ALPHA = FREE_IMAGE_COLOR_CHANNEL(4); // Use alpha channel + FICC_BLACK = FREE_IMAGE_COLOR_CHANNEL(5); // Use black channel + FICC_REAL = FREE_IMAGE_COLOR_CHANNEL(6); // Complex images: use real part + FICC_IMAG = FREE_IMAGE_COLOR_CHANNEL(7); // Complex images: use imaginary part + FICC_MAG = FREE_IMAGE_COLOR_CHANNEL(8); // Complex images: use magnitude + FICC_PHASE = FREE_IMAGE_COLOR_CHANNEL(9); // Complex images: use phase + + // Tag data type information (based on TIFF specifications) + FIDT_NOTYPE = FREE_IMAGE_MDTYPE(0); // placeholder + FIDT_BYTE = FREE_IMAGE_MDTYPE(1); // 8-bit unsigned integer + FIDT_ASCII = FREE_IMAGE_MDTYPE(2); // 8-bit bytes w/ last byte null + FIDT_SHORT = FREE_IMAGE_MDTYPE(3); // 16-bit unsigned integer + FIDT_LONG = FREE_IMAGE_MDTYPE(4); // 32-bit unsigned integer + FIDT_RATIONAL = FREE_IMAGE_MDTYPE(5); // 64-bit unsigned fraction + FIDT_SBYTE = FREE_IMAGE_MDTYPE(6); // 8-bit signed integer + FIDT_UNDEFINED = FREE_IMAGE_MDTYPE(7); // 8-bit untyped data + FIDT_SSHORT = FREE_IMAGE_MDTYPE(8); // 16-bit signed integer + FIDT_SLONG = FREE_IMAGE_MDTYPE(9); // 32-bit signed integer + FIDT_SRATIONAL = FREE_IMAGE_MDTYPE(10); // 64-bit signed fraction + FIDT_FLOAT = FREE_IMAGE_MDTYPE(11); // 32-bit IEEE floating point + FIDT_DOUBLE = FREE_IMAGE_MDTYPE(12); // 64-bit IEEE floating point + FIDT_IFD = FREE_IMAGE_MDTYPE(13); // 32-bit unsigned integer (offset) + FIDT_PALETTE = FREE_IMAGE_MDTYPE(14); // 32-bit RGBQUAD + + // Metadata models supported by FreeImage + FIMD_NODATA = FREE_IMAGE_MDMODEL(-1); + FIMD_COMMENTS = FREE_IMAGE_MDMODEL(0); // single comment or keywords + FIMD_EXIF_MAIN = FREE_IMAGE_MDMODEL(1); // Exif-TIFF metadata + FIMD_EXIF_EXIF = FREE_IMAGE_MDMODEL(2); // Exif-specific metadata + FIMD_EXIF_GPS = FREE_IMAGE_MDMODEL(3); // Exif GPS metadata + FIMD_EXIF_MAKERNOTE = FREE_IMAGE_MDMODEL(4); // Exif maker note metadata + FIMD_EXIF_INTEROP = FREE_IMAGE_MDMODEL(5); // Exif interoperability metadata + FIMD_IPTC = FREE_IMAGE_MDMODEL(6); // IPTC/NAA metadata + FIMD_XMP = FREE_IMAGE_MDMODEL(7); // Abobe XMP metadata + FIMD_GEOTIFF = FREE_IMAGE_MDMODEL(8); // GeoTIFF metadata (to be implemented) + FIMD_ANIMATION = FREE_IMAGE_MDMODEL(9); // Animation metadata + FIMD_CUSTOM = FREE_IMAGE_MDMODEL(10); // Used to attach other metadata types to a dib + +//{$endif} + +type + // Handle to a metadata model + FIMETADATA = record + data: Pointer; + end; + PFIMETADATA = ^FIMETADATA; + + // Handle to a metadata tag + FITAG = record + data: Pointer; + end; + PFITAG = ^FITAG; + +// -------------------------------------------------------------------------- +// File IO routines --------------------------------------------------------- +// -------------------------------------------------------------------------- + +type + FI_Handle = Pointer; + PCardinal = ^Cardinal; + PInt = ^Integer; + + FI_ReadProc = function(buffer : pointer; size : Cardinal; count : Cardinal; handle : fi_handle) : PCardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_WriteProc = function(buffer : pointer; size, count : Cardinal; handle : FI_Handle) : PCardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_SeekProc = function(handle : fi_handle; offset : longint; origin : integer) : pint; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_TellProc = function(handle : fi_handle) : PCardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + + FreeImageIO = packed record + read_proc : FI_ReadProc; // pointer to the function used to read data + write_proc: FI_WriteProc; // pointer to the function used to write data + seek_proc : FI_SeekProc; // pointer to the function used to seek + tell_proc : FI_TellProc; // pointer to the function used to aquire the current position + end; + PFreeImageIO = ^FreeImageIO; + + // Handle to a memory I/O stream + FIMEMORY = record + data: Pointer; + end; + PFIMEMORY = ^FIMEMORY; + +const + // constants used in FreeImage_Seek for Origin parameter + SEEK_SET = 0; + SEEK_CUR = 1; + SEEK_END = 2; + +// -------------------------------------------------------------------------- +// Plugin routines ---------------------------------------------------------- +// -------------------------------------------------------------------------- + +type + PPluginStruct = ^PluginStruct; + + FI_InitProc = procedure(Plugin: PPluginStruct; Format_ID: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_FormatProc = function: PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_DescriptionProc = function: PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_ExtensionListProc = function: PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_RegExprProc = function: PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_OpenProc = function(IO: PFreeImageIO; Handle: FI_Handle; Read: Boolean): Pointer; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_CloseProc = procedure(IO: PFreeImageIO; Handle: FI_Handle; Data: Pointer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_PageCountProc = function(IO: PFreeImageIO; Handle: FI_Handle; Data: Pointer): Integer; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_PageCapabilityProc = function(IO: PFreeImageIO; Handle: FI_Handle; Data: Pointer): integer; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_LoadProc = function(IO: PFreeImageIO; Handle: FI_Handle; Page, Flags: Integer; data: pointer): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_SaveProc = function(IO: PFreeImageIO; Dib: PFIBITMAP; Handle: FI_Handle; Page, Flags: Integer; Data: Pointer): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_ValidateProc = function(IO: PFreeImageIO; Handle: FI_Handle): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_MimeProc = function: PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_SupportsExportBPPProc = function(Bpp: integer): boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_SupportsExportTypeProc = function(AType: FREE_IMAGE_TYPE): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + FI_SupportsICCProfilesProc = function: Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + + PluginStruct = record + format_proc: FI_FormatProc; + description_proc: FI_DescriptionProc; + extension_proc: FI_ExtensionListProc; + regexpr_proc: FI_RegExprProc; + open_proc: FI_OpenProc; + close_proc: FI_CloseProc; + pagecount_proc: FI_PageCountProc; + pagecapability_proc: FI_PageCapabilityProc; + load_proc: FI_LoadProc; + save_proc: FI_SaveProc; + validate_proc: FI_ValidateProc; + mime_proc: FI_MimeProc; + supports_export_bpp_proc: FI_SupportsExportBPPProc; + supports_export_type_proc: FI_SupportsExportTypeProc; + supports_icc_profiles_proc: FI_SupportsICCProfilesProc; + end; + +// -------------------------------------------------------------------------- +// Load/Save flag constants ------------------------------------------------- +// -------------------------------------------------------------------------- + +const + BMP_DEFAULT = 0; + BMP_SAVE_RLE = 1; + CUT_DEFAULT = 0; + DDS_DEFAULT = 0; + FAXG3_DEFAULT = 0; + GIF_DEFAULT = 0; + ICO_DEFAULT = 0; + ICO_MAKEALPHA = 0; // convert to 32bpp and create an alpha channel from the AND-mask when loading + IFF_DEFAULT = 0; + JPEG_DEFAULT = 0; + JPEG_FAST = 1; + JPEG_ACCURATE = 2; + JPEG_QUALITYSUPERB = $0080; + JPEG_QUALITYGOOD = $0100; + JPEG_QUALITYNORMAL = $0200; + JPEG_QUALITYAVERAGE = $0400; + JPEG_QUALITYBAD = $0800; + JPEG_CMYK = $1000; // load separated CMYK "as is" (use | to combine with other flags) + KOALA_DEFAULT = 0; + LBM_DEFAULT = 0; + MNG_DEFAULT = 0; + PCD_DEFAULT = 0; + PCD_BASE = 1; // load the bitmap sized 768 x 512 + PCD_BASEDIV4 = 2; // load the bitmap sized 384 x 256 + PCD_BASEDIV16 = 3; // load the bitmap sized 192 x 128 + PCX_DEFAULT = 0; + PNG_DEFAULT = 0; + PNG_IGNOREGAMMA = 1; // avoid gamma correction + PNM_DEFAULT = 0; + PNM_SAVE_RAW = 0; // If set the writer saves in RAW format (i.e. P4, P5 or P6) + PNM_SAVE_ASCII = 1; // If set the writer saves in ASCII format (i.e. P1, P2 or P3) + PSD_DEFAULT = 0; + RAS_DEFAULT = 0; + SGI_DEFAULT = 0; + TARGA_DEFAULT = 0; + TARGA_LOAD_RGB888 = 1; // If set the loader converts RGB555 and ARGB8888 -> RGB888. + TIFF_DEFAULT = 0; + TIFF_CMYK = $0001; // reads/stores tags for separated CMYK (use | to combine with compression flags) + TIFF_PACKBITS = $0100; // save using PACKBITS compression + TIFF_DEFLATE = $0200; // save using DEFLATE compression + TIFF_ADOBE_DEFLATE = $0400; // save using ADOBE DEFLATE compression + TIFF_NONE = $0800; // save without any compression + TIFF_CCITTFAX3 = $1000; // save using CCITT Group 3 fax encoding + TIFF_CCITTFAX4 = $2000; // save using CCITT Group 4 fax encoding + TIFF_LZW = $4000; // save using LZW compression + TIFF_JPEG = $8000; // save using JPEG compression + WBMP_DEFAULT = 0; + XBM_DEFAULT = 0; + XPM_DEFAULT = 0; + +// -------------------------------------------------------------------------- +// Init/Error routines ------------------------------------------------------ +// -------------------------------------------------------------------------- + +procedure FreeImage_Initialise(load_local_plugins_only : boolean = False); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_DeInitialise; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Version routines --------------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_GetVersion : PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetCopyrightMessage : PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Message output functions ------------------------------------------------- +// -------------------------------------------------------------------------- + +procedure FreeImage_OutPutMessageProc(fif: Integer; fmt: PChar); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +type FreeImage_OutputMessageFunction = function(fif: FREE_IMAGE_FORMAT; msg: PChar): pointer; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} +procedure FreeImage_SetOutputMessage(omf: FreeImage_OutputMessageFunction); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Allocate/Unload routines ------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_Allocate(width, height, bpp: integer; red_mask: Cardinal = 0; green_mask: Cardinal = 0; blue_mask: Cardinal = 0): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_AllocateT(Atype: FREE_IMAGE_TYPE; Width, Height: Integer; bpp: Integer = 8; red_mask: Cardinal = 0; green_mask: Cardinal = 0; blue_mask: Cardinal = 0): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_Clone(dib: PFIBITMAP): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_Unload(dib: PFIBITMAP); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Load / Save routines ----------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_Load(fif: FREE_IMAGE_FORMAT; const filename: PChar; flags: integer = 0): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_LoadU(fif: FREE_IMAGE_FORMAT; const filename: PWideChar; flags: Integer = 0): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_LoadFromHandle(fif: FREE_IMAGE_FORMAT; io: PFreeImageIO; handle: fi_handle; flags: integer = 0): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_Save(fif: FREE_IMAGE_FORMAT; dib: PFIBITMAP; filename: PChar; flags: integer = 0): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SaveU(fif: FREE_IMAGE_FORMAT; dib: PFIBITMAP; const filename: PWideChar; flags: Integer = 0): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SaveToHandle(fif: FREE_IMAGE_FORMAT; dib: PFIBITMAP; io : PFreeImageIO; handle : fi_handle; flags : integer = 0) : Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Memory I/O stream routines ----------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_OpenMemory(data: PByte = nil; size_in_bytes: DWORD = 0): PFIMEMORY; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_CloseMemory(stream: PFIMEMORY); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_LoadFromMemory(fif: FREE_IMAGE_FORMAT; stream: PFIMEMORY; flags: Integer = 0): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SaveToMemory(fif: FREE_IMAGE_FORMAT; dib: PFIBITMAP; stream: PFIMEMORY; flags: Integer = 0): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_TellMemory(stream: PFIMEMORY): Longint; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SeekMemory(stream: PFIMEMORY; offset: Longint; origin: Integer): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_AcquireMemory(stream: PFIMEMORY; var data: PByte; var size_in_bytes: DWORD): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Plugin Interface --------------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_RegisterLocalPlugin(proc_address: FI_InitProc; format, description, extension, regexpr: PChar): FREE_IMAGE_FORMAT; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_RegisterExternalPlugin(path, format, description, extension, regexpr: PChar): FREE_IMAGE_FORMAT; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetFIFCount: Integer; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_SetPluginEnabled(fif: FREE_IMAGE_FORMAT; enable: Boolean); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_IsPluginEnabled(fif: FREE_IMAGE_FORMAT): Integer; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetFIFFromFormat(const format: PChar): FREE_IMAGE_FORMAT; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetFIFFromMime(const format: PChar): FREE_IMAGE_FORMAT; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetFormatFromFIF(fif: FREE_IMAGE_FORMAT): PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetFIFExtensionList(fif: FREE_IMAGE_FORMAT): PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetFIFDescription(fif: FREE_IMAGE_FORMAT): PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetFIFRegExpr(fif: FREE_IMAGE_FORMAT): PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetFIFFromFilename(const fname: PChar): FREE_IMAGE_FORMAT; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetFIFFromFilenameU(const fname:PWideChar): FREE_IMAGE_FORMAT; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_FIFSupportsReading(fif: FREE_IMAGE_FORMAT): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_FIFSupportsWriting(fif: FREE_IMAGE_FORMAT): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_FIFSupportsExportBPP(fif: FREE_IMAGE_FORMAT; bpp: Integer): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_FIFSupportsICCProfiles(fif: FREE_IMAGE_FORMAT): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_FIFSupportsExportType(fif: FREE_IMAGE_FORMAT; image_type: FREE_IMAGE_TYPE): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Multipaging interface ---------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_OpenMultiBitmap(fif: FREE_IMAGE_FORMAT; filename: PChar; create_new, read_only, keep_cache_in_memory: Boolean; flags: integer = 0): PFIMULTIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_CloseMultiBitmap(bitmap: PFIMULTIBITMAP; flags: Integer = 0): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetPageCount(bitmap: PFIMULTIBITMAP): Integer; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_AppendPage(bitmap: PFIMULTIBITMAP; data: PFIBITMAP); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_InsertPage(bitmap: PFIMULTIBITMAP; page: Integer; data: PFIBITMAP); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_DeletePage(bitmap: PFIMULTIBITMAP; page: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_LockPage(bitmap: PFIMULTIBITMAP; page: Integer): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_UnlockPage(bitmap: PFIMULTIBITMAP; page: PFIBITMAP; changed: boolean); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_MovePage(bitmap: PFIMULTIBITMAP; target, source: Integer): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetLockedPageNumbers(bitmap: PFIMULTIBITMAP; var pages: Integer; var count : integer): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Filetype request routines ------------------------------------------------ +// -------------------------------------------------------------------------- + +function FreeImage_GetFileType(const filename: PChar; size: Integer): FREE_IMAGE_FORMAT; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetFileTypeU(const filename: PWideChar; size: Integer): FREE_IMAGE_FORMAT; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetFileTypeFromHandle(io: PFreeImageIO; handle: FI_Handle; size: Integer = 0): FREE_IMAGE_FORMAT; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetFileTypeFromMemory(stream: PFIMEMORY; size: Integer = 0): FREE_IMAGE_FORMAT; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// ImageType request routine ------------------------------------------------ +// -------------------------------------------------------------------------- + +function FreeImage_GetImageType(dib: PFIBITMAP): FREE_IMAGE_TYPE; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// FreeImage helper routines ------------------------------------------------ +// -------------------------------------------------------------------------- + +function FreeImage_IsLittleEndian: Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_LookupX11Color(const szColor: PChar; var nRed, nGreen, nBlue: PByte): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_LookupSVGColor(const szColor: PChar; var nRed, nGreen, nBlue: PByte): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Pixels access routines --------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_GetBits(dib: PFIBITMAP): PByte; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetScanLine(dib: PFIBITMAP; scanline: Integer): PByte; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +function FreeImage_GetPixelIndex(dib: PFIBITMAP; X, Y: Longint; Value: PByte): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetPixelColor(dib: PFIBITMAP; X, Y: Longint; Value: PRGBQuad): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SetPixelIndex(dib: PFIBITMAP; X, Y: Longint; Value: PByte): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SetPixelColor(dib: PFIBITMAP; X, Y: Longint; Value: PRGBQuad): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// DIB info routines -------------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_GetColorsUsed(dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetBPP(dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetWidth(dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetHeight(dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetLine(dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetPitch(dib : PFIBITMAP) : Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetDIBSize(dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetPalette(dib: PFIBITMAP): PRGBQUAD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +function FreeImage_GetDotsPerMeterX(dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetDotsPerMeterY(dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_SetDotsPerMeterX(dib: PFIBITMAP; res: Cardinal); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_SetDotsPerMeterY(dib: PFIBITMAP; res: Cardinal); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +function FreeImage_GetInfoHeader(dib: PFIBITMAP): PBITMAPINFOHEADER; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetInfo(var dib: FIBITMAP): PBITMAPINFO; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetColorType(dib: PFIBITMAP): FREE_IMAGE_COLOR_TYPE; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +function FreeImage_GetRedMask(dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetGreenMask(dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetBlueMask(dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +function FreeImage_GetTransparencyCount(dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetTransparencyTable(dib: PFIBITMAP): PByte; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_SetTransparent(dib: PFIBITMAP; enabled: boolean); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_SetTransparencyTable(dib: PFIBITMAP; table: PByte; count: integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_IsTransparent(dib: PFIBITMAP): boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +function FreeImage_HasBackgroundColor(dib: PFIBITMAP): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetBackgroundColor(dib: PFIBITMAP; var bkcolor: PRGBQUAD): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SetBackgroundColor(dib: PFIBITMAP; bkcolor: PRGBQUAD): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// ICC profile routines ----------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_GetICCProfile(var dib: FIBITMAP): PFIICCPROFILE; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_CreateICCProfile(var dib: FIBITMAP; data: Pointer; size: Longint): PFIICCPROFILE; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_DestroyICCProfile(var dib : FIBITMAP); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Line conversion routines ------------------------------------------------- +// -------------------------------------------------------------------------- + +procedure FreeImage_ConvertLine1To4(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine8To4(target, source: PBYTE; width_in_pixels: Integer; palette: PRGBQuad); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine16To4_555(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine16To4_565(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine24To4(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine32To4(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +procedure FreeImage_ConvertLine1To8(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine4To8(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine16To8_555(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine16To8_565(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine24To8(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine32To8(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +procedure FreeImage_ConvertLine1To16_555(target, source: PBYTE; width_in_pixels: Integer; palette: PRGBQUAD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine4To16_555(target, source: PBYTE; width_in_pixels: Integer; palette: PRGBQUAD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine8To16_555(target, source: PBYTE; width_in_pixels: Integer; palette: PRGBQUAD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine16_565_To16_555(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine24To16_555(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine32To16_555(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +procedure FreeImage_ConvertLine1To16_565(target, source : PBYTE; width_in_pixels: Integer; palette: PRGBQUAD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine4To16_565(target, source : PBYTE; width_in_pixels : Integer; palette : PRGBQUAD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine8To16_565(target, source: PBYTE; width_in_pixels: Integer; palette: PRGBQUAD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine16_555_To16_565(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine24To16_565(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine32To16_565(target, source : PBYTE; width_in_pixels : Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +procedure FreeImage_ConvertLine1To24(target, source: PBYTE; width_in_pixels: Integer; palette: PRGBQUAD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine4To24(target, source : PBYTE; width_in_pixels: Integer; palette: PRGBQUAD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine8To24(target, source: PBYTE; width_in_pixels: Integer; palette: PRGBQUAD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine16To24_555(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine16To24_565(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine32To24(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +procedure FreeImage_ConvertLine1To32(target, source: PBYTE; width_in_pixels: Integer; palette: PRGBQUAD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine4To32(target, source: PBYTE; width_in_pixels: Integer; palette: PRGBQUAD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine8To32(target, source: PBYTE; width_in_pixels: Integer; palette: PRGBQUAD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine16To32_555(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine16To32_565(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertLine24To32(target, source: PBYTE; width_in_pixels: Integer); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Smart conversion routines ------------------------------------------------ +// -------------------------------------------------------------------------- + +function FreeImage_ConvertTo4Bits(dib: PFIBITMAP): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_ConvertTo8Bits(dib: PFIBITMAP): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_ConvertToGreyscale(dib: PFIBITMAP): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_ConvertTo16Bits555(dib: PFIBITMAP): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_ConvertTo16Bits565(dib: PFIBITMAP): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_ConvertTo24Bits(dib: PFIBITMAP): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_ConvertTo32Bits(dib: PFIBITMAP): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_ColorQuantize(dib: PFIBITMAP; quantize: FREE_IMAGE_QUANTIZE): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_ColorQuantizeEx(dib: PFIBITMAP; quantize: FREE_IMAGE_QUANTIZE = FIQ_WUQUANT; PaletteSize: Integer = 256; ReserveSize: Integer = 0; ReservePalette: PRGBQuad = nil): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_Threshold(dib: PFIBITMAP; T: Byte): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_Dither(dib: PFIBITMAP; algorithm: FREE_IMAGE_DITHER): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +function FreeImage_ConvertFromRawBits(bits: PBYTE; width, height, pitch: Integer; bpp, red_mask, green_mask, blue_mask: LongWord; topdown: Boolean): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_ConvertToRawBits(bits: PBYTE; dib: PFIBITMAP; pitch: Integer; bpp, red_mask, green_mask, blue_mask: LongWord; topdown: Boolean); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +function FreeImage_ConvertToRGBF(dib: PFIBITMAP): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +function FreeImage_ConvertToStandardType(src: PFIBITMAP; scale_linear: Boolean = True): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_ConvertToType(src: PFIBITMAP; dst_type: FREE_IMAGE_TYPE; scale_linear: Boolean = True): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// tone mapping operators +function FreeImage_ToneMapping(dib: PFIBITMAP; tmo: FREE_IMAGE_TMO; first_param: Double = 0; second_param: Double = 0): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_TmoDrago03(src: PFIBITMAP; gamma: Double = 2.2; exposure: Double = 0): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_TmoReinhard05(src: PFIBITMAP; intensity: Double = 0; contrast: Double = 0): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// ZLib interface ----------------------------------------------------------- +// -------------------------------------------------------------------------- + +function FreeImage_ZLibCompress(target: PBYTE; target_size: DWORD; source: PBYTE; source_size: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_ZLibUncompress(target: PBYTE; target_size: DWORD; source: PBYTE; source_size: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +function FreeImage_ZLibGZip(target: PBYTE; target_size: DWORD; source: PBYTE; source_size: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_ZLibGUnzip(target: PBYTE; target_size: DWORD; source: PBYTE; source_size: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_ZLibCRC32(crc: DWORD; source: PByte; source_size: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Metadata routines -------------------------------------------------------- +// -------------------------------------------------------------------------- + +// tag creation / destruction +function FreeImage_CreateTag: PFITAG; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_DeleteTag(tag: PFITAG); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_CloneTag(tag: PFITAG): PFITAG; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// tag getters and setters +function FreeImage_GetTagKey(tag: PFITAG): PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetTagDescription(tag: PFITAG): PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetTagID(tag: PFITAG): Word; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetTagType(tag: PFITAG): FREE_IMAGE_MDTYPE; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetTagCount(tag: PFITAG): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetTagLength(tag: PFITAG): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetTagValue(tag: PFITAG): Pointer; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +function FreeImage_SetTagKey(tag: PFITAG; const key: PChar): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SetTagDescription(tag: PFITAG; const description: PChar): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SetTagID(tag: PFITAG; id: Word): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SetTagType(tag: PFITAG; atype: FREE_IMAGE_MDTYPE): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SetTagCount(tag: PFITAG; count: DWORD): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SetTagLength(tag: PFITAG; length: DWORD): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SetTagValue(tag: PFITAG; const value: Pointer): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// iterator +function FreeImage_FindFirstMetadata(model: FREE_IMAGE_MDMODEL; dib: PFIBITMAP; var tag: PFITAG): PFIMETADATA; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_FindNextMetadata(mdhandle: PFIMETADATA; var tag: PFITAG): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +procedure FreeImage_FindCloseMetadata(mdhandle: PFIMETADATA); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// metadata setter and getter +function FreeImage_SetMetadata(model: FREE_IMAGE_MDMODEL; dib: PFIBITMAP; const key: PChar; tag: PFITAG): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetMetadata(model: FREE_IMAGE_MDMODEL; dib: PFIBITMAP; const key: PChar; var tag: PFITAG): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// helpers +function FreeImage_GetMetadataCount(model: FREE_IMAGE_MDMODEL; dib: PFIBITMAP): Cardinal; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// tag to C string conversion +function FreeImage_TagToString(model: FREE_IMAGE_MDMODEL; tag: PFITAG; Make: PChar = nil): PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// -------------------------------------------------------------------------- +// Image manipulation toolkit ----------------------------------------------- +// -------------------------------------------------------------------------- + +// rotation and flipping +function FreeImage_RotateClassic(dib: PFIBITMAP; angle: Double): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_RotateEx(dib: PFIBITMAP; angle, x_shift, y_shift, x_origin, y_origin: Double; use_mask: Boolean): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_FlipHorizontal(dib: PFIBITMAP): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_FlipVertical(dib: PFIBITMAP): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_JPEGTransform(const src_file: PChar; const dst_file: PChar; operation: FREE_IMAGE_JPEG_OPERATION; perfect: Boolean = False): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// upsampling / downsampling +function FreeImage_Rescale(dib: PFIBITMAP; dst_width, dst_height: Integer; filter: FREE_IMAGE_FILTER): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_MakeThumbnail(dib: PFIBITMAP; max_pixel_size: Integer; convert:boolean = TRUE): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// color manipulation routines (point operations) +function FreeImage_AdjustCurve(dib: PFIBITMAP; LUT: PBYTE; channel: FREE_IMAGE_COLOR_CHANNEL): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_AdjustGamma(dib: PFIBITMAP; gamma: Double): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_AdjustBrightness(dib: PFIBITMAP; percentage: Double): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_AdjustContrast(dib: PFIBITMAP; percentage: Double): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_Invert(dib: PFIBITMAP): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetHistogram(dib: PFIBITMAP; histo: PDWORD; channel: FREE_IMAGE_COLOR_CHANNEL = FICC_BLACK): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// channel processing routines +function FreeImage_GetChannel(dib: PFIBITMAP; channel: FREE_IMAGE_COLOR_CHANNEL): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SetChannel(dib, dib8: PFIBITMAP; channel: FREE_IMAGE_COLOR_CHANNEL): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_GetComplexChannel(src: PFIBITMAP; channel: FREE_IMAGE_COLOR_CHANNEL): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_SetComplexChannel(src: PFIBITMAP; channel: FREE_IMAGE_COLOR_CHANNEL): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +// copy / paste / composite routines + +function FreeImage_Copy(dib: PFIBITMAP; left, top, right, bottom: Integer): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_Paste(dst, src: PFIBITMAP; left, top, alpha: Integer): Boolean; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; +function FreeImage_Composite(fg: PFIBITMAP; useFileBkg: Boolean = False; appBkColor: PRGBQUAD = nil; bg: PFIBITMAP = nil): PFIBITMAP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external FIDLL; + +{$MINENUMSIZE 1} +implementation + +end. diff --git a/Game/Code/lib/FreeImage/libfreeimage.dylib b/Game/Code/lib/FreeImage/libfreeimage.dylib Binary files differnew file mode 100755 index 00000000..5f9aecce --- /dev/null +++ b/Game/Code/lib/FreeImage/libfreeimage.dylib diff --git a/Game/Code/lib/JEDI-SDL/JEDI-SDL-README.txt b/Game/Code/lib/JEDI-SDL/JEDI-SDL-README.txt new file mode 100644 index 00000000..a068e943 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/JEDI-SDL-README.txt @@ -0,0 +1,244 @@ +This is the based on the SDL ( http://www.libsdl.org ) headers, and has been converted, comments and all, to the Pascal unit called sdl.pas.
+Other conversions that have also been done are SDL_Mixer.h, SDL_Net.h, SDL_Image.h, SDL_ttf, SMPEG.h, SDL_sound and the SFont library,
+which are all included in this distribution.
+
+It allows you to access all the functions within the SDL libraries under Windows, Linux and FreeBSD, so you can write cross-platform games or multimedia applications.
+
+Installation Instructions
+-------------------------
+Windows - We now have a semi-automated setup under Windows ( thanks to David House and the Jedi JCL team ).
+ Once you have extracted the zip file, simply double click on the "JEDISDLWin32Installer.exe" to have the correct paths added to your respective
+ IDEs. All IDEs from Delphi 4 - 7 are supported and it also adds a link to the .CHM help file under the Tools menu.
+
+Linux - Alternatively if you use Linux or want to to manually install the paths, then make sure you read the "Getting Started.html" file ( ideal for those who are new to JEDI-SDL ) and is now included as a guide to help getting everything setup for smooth compilation.
+
+Also included is a guide of how to use Sourceforge using TortoiseCVS under Windows ( Linux guide is under development ).
+Both documents can be found in the "documentation" directory.
+
+
+Release History
+---------------
+1.0 : Yeah!! The Official v1.0 Release of JEDI-SDL!!
+ JEDI-SDL now updated to SDL v1.2.11, SDL_Image v1.2.5, SDL_Mixer v1.2.7, SDL_Net v1.2.6 & SDL_ttf v2.0.8
+ Added Improved FreePascal, TMT Pascal and GnuPascal support as well as maintaining Delphi/Kylix support.
+ Fixed Various bugs as pointed out on the JEDI-SDL mailing list.
+ Added SDL_GL_STEREO, SDL_GL_MULTISAMPLEBUFFERS, SDL_GL_MULTISAMPLESAMPLES
+
+Now works on MacOS X and a MacOS X disk image is available for download.
+
+// DLL/Shared object functions
+function SDL_LoadObject( const sofile : PChar ) : Pointer;
+
+function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer;
+
+procedure SDL_UnloadObject( handle : Pointer );
+
+//Added function to create RWops from const memory: SDL_RWFromConstMem()
+function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops;
+
+//Added support for environment variables SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
+
+ New Units :
+ -----------
+ sdl_cpuinfo.pas - ported SDL_cpuinfo.h so Now you can test for Specific CPU types.
+ sdlinput.pas - Input wrapper class
+ sdlwindow.pas - Window wrapper class
+ sdltruetypefont.pas - True Type Font wrapper class
+ tcputils.pas - SDL_Net utility functions
+ sdlweb.pas - SDL_Net Web class
+ sdlwebhttp.pas - SDL_Net http protocol wrapper class
+ sdlwebftp.pas - SDL_Net ftp protocol wrapper class
+
+ New 2D Demos :
+ --------------
+
+
+ New 3D Demos :
+ --------------
+
+
+ Other New Stuff :
+ -----------------
+
+
+
+0.5 : The JEDI-SDL project is now also set up on Sourceforge ( http://sf.net/projects/jedi-sdl/ ) so the latest code is available from there.
+ Improved FreePascal support has been added.
+ Various bug fixes as pointed out on the JEDI-SDL mailing list.
+ SDL_Mixer has been updated to version 1.2.1 and includes an Effects API.
+ Demo directories are now split into 2D and 3D related sub-directories.
+ There are now both Kylix ( K prefix ) and Delphi ( D prefix ) project groups for all the demos.
+ They can be found in Demos and the 2D and 3D directories.
+
+ New Units
+ ---------
+ SDLStreams.pas - Chris Bruner has created a wrapper that uses Streams to load BMPs
+ SDLUtils.pas - Pascal only version of some Utility functions
+ SDLi386Utils.pas - Intel Assembler versions of the SDLUtils.pas functions.
+ SDL_ttf.pas - Port of the SDL True Type font support unit.
+ SDL_Sound.pas - Port of the SDL Sound library ( untested ).
+
+ New 2D Demos :
+ --------------
+ Pan and Zoom Demo - How to Pan and Zoom an SDL surface.
+ Isometric Demo - I ported my old DelphiX isometric demo over to SDL.
+ TestTimer demo - Shows hows how to use AddTimer and RemoveTimer.
+ MpegPlayer - I have updated and improved Anders Ohlsson's CLX MPegPlayer and component and it now works
+ and installs into D4, D5, D6, D7, K1, K2 & K3.
+ Showfont - Demo to show how to us SDL_ttf.dll
+ SmpegPlayer - is a console MPEG player that use smpeg and SDL_Mixer
+
+ New 3D Demos :
+ --------------
+ DeathTruckTion 1.1 - A slightly updated version of this fully functional 3D network game.
+ TerrainDemo - Terrain demo ported from the book "OpenGL Game programming" by Hawkins and Astle.
+ TestGL - the standard SDL/OpenGL Test demo. Shows how to mix 2D and 3D rendering using OpenGL.
+ glfont - Demo to show how to us SDL_ttf with OpenGL.
+ Particle Engine - Ariel's OpenGL Particle Engine.
+ Picking - Phil Freeman's Picking Demo
+ Motion Blur - Phil Freeman's Motion Blur Demo
+ Dynamic Light - Phil Freeman's Dynamic Light Demo
+ Environment Map - Phil Freeman's Environment Map Demo
+ GLMovie - is an MPEG Player that uses OpenGL to render the movie.
+ NeHe - Quite a few more NeHe demos are now included.
+
+ New Network Demos :
+ -------------------
+ There are now 3 SDL_Net Server demos and 4 SDL_Client demos as submitted by Dean Ellis.
+
+
+Beta 4 : The JEDI-SDL home page is now located @ http://www.delphi-jedi.org/Jedi:TEAM_SDL_HOME
+ All Demos ( including OpenGL Demos ) now compile under both Kylix and Delphi.
+ I have added quite a few more OpenGL examples, we are now up to Nehe tutorial 12.
+ All OpenGL demos also show how to handle Window resizing.
+ Included an OpenGL demo called Puntos by Gustavo Maximo.
+ Ported Jan Horn's OpenGL MetaBalls and also SkyBox demo to SDL.
+ Ported Ilkka Tuomioja's OpenGL Quake 2 Model Viewer/Animator to SDL.
+ NOTE : All OpenGL demos require OpenGL12.pas which can be found at...
+ http://www.lischke-online.de/Graphics.html#OpenGL12
+ I also fixed a conversion bug to do with SDL_MustLock and also a conversion omission to do with various events.
+ Fixed a conversion bug with SDL_CDOpen ( as suggested on the mailing list ).
+ Added the GetPixel and PuxPixel functions to the SDLUtils.pas file.
+ Jason Farmer has donated SFont, a simple, yet effective Font library he converted for JEDI-SDL.
+ It contains 4 Demos show how to best use it.
+ Added TUInt8Array and PUIntArray to SDL.pas after suggestions from Matthias Thoma and Eric Grange.
+ In the file area of the JEDI-SDL mailing list ( http://groups.yahoo.com/group/JEDI-SDL/files/DTTSrc/ there
+ is a fully functional 3D network game called DeathTruckTion v1.0 written by the TNTeam that makes use of
+ JEDI-SDL and is just too big to include with this distribution but is well worth looking at as it works under Windows and Linux!
+ Gustavo Maxima is working on translating the JEDI-SDL Documentation to Spanish and Portugese.
+ The Mouse Demo has now been speeded up considerably and it is very responsive now.
+ Dean Ellis will provide steps on how to compile the demos using the Free Pascal compiler.
+ Jason Farmer and I are working on a series of Tutorials that should hopefully be out soon.
+ David Aclan has donated a SMpeg component that should work under Kylix.
+ Róbert Kisnémeth, has been hard at work, and has donated some new demos he has created with a SpriteEngine ( which he also donated ).
+ He has also donated a couple of games called BlitzBomber and Oxygene ( which uses the SpriteEngine ) and added a couple of useful
+ functions to SDLUtils.pas.
+ The Functions added are SDL_FlipV, SDL_FlipH, SDL_NewPutPixel ( assembler version ), SDL_AddPixel, SDL_SubPixel, SDL_DrawLine, SDL_AddLine,
+ SDL_SubLine, SDL_AddSurface, SDL_SubSurface, SDL_MonoSurface & SDL_TexturedSurface.
+ He has also donated a Font Blitting class and demo called SDL_MonoFonts which supports alignment like Left, Right and Center.
+ He and Thomas are also working on a GUI library.
+ Jason Farmer has donated a set of Image Filtering functions which add quite a few interesting effects. Check the SDL_Filter sub-directory for more
+ info.
+ Christian Hackbart also donated an OpenGL BlockOut clone.
+
+
+Beta 3 : I have added conversions for SDL_env.h, SDL_Mixer.h and SDL_Net.h while Matthias Thoma has added conversions for SDL_Image.h and SMPEG.h.
+ This version is also SDL version 1.2.0 compliant.
+ This release also adds demos for the SDL_Image, SDL_Mixer and SDL_Net libraries.
+ There are now also some OpenGL demos that make some use of SDL as well as a demo on how to use the Mouse with Clickable regions.
+ A conversion bug, that was pointed out by Clem Vasseur, has also been fixed.
+ There is now a mailing list that has been set up at http://groups.yahoo.com/group/JEDI-SDL/join/ so we can all learn from each other how to use
+ these libraries.
+ Demos have not been unified into single .dpr files for each demo, thus showing how you would write a crossplatform game using only 1 .dpr file.
+ There is also a documentation directory that is currently in HTML format. All code examples in the documentation have been converted to Object
+ Pascal but are untested.
+ I Also fixed a few conversion bugs which I came across while converting the documentation.
+
+Beta 2 : I have added conversions for SDL_active.h, SDL_thread.h, SDL_mutex.h and
+ SDL_error.h, Matthias Thoma has added Linux Support and JEDI compliancy so these
+ units and examples are now x-platform and x-compiler compilable.
+ I also added Tom Jones' SDLUtils.pas file;
+ Matthias also cleaned up the 2 new demos and made them work on both Linux and
+ Windows.
+
+Beta 1 : Initial Release;
+
+
+There are now 5 examples included with this JEDI-SDL distribution.
+1. Is the TestWin application, which is based on the testwin application that comes with the SDL SDK, only my version has a gui front end to the options available and has been compiled under Delphi 4.03. It should be compatible with Delphi 3.0 onwards ( though Delphi 2 compatibility has not been tested ).
+
+2. A Plasma example which was converted from one found on the Demos page of the SDL site.
+
+3. A Voxel terrain following demo, which was converted from one found on the Demos page of the SDL site. This one should be of interest to others as it shows how to handle keyboard events when using SDL.
+
+4. A Mouse handling demo that shows how to use transparency and clickable regions.
+
+5. A Space Invaders style game called Aliens which shows the use of SDL, SDL_Image and SDL_Mixer. This game shows how to handle sound, keyboards and some basic collision detection. It is a conversion of one found on the SDL Demos page.
+
+There are also 14 OpenGL demos that are based on the NeHe tutorials <nehe.gamedev.net>. The other 3 OpenGL demos are Jan Horns' OpenGL demo, A Quake 2 Model viewer that I ported and a Demo by Gustavo Maxima called Puntos.
+
+If writing your own, just make sure that the SDL.pas file is in your projects path for compiling and that the SDL.dll file is in your path when running the compiled app.
+
+Please test these units and report problems to the JEDI-SDL mailing list @ http://groups.yahoo.com/group/JEDI-SDL/ outlining steps under which the error occurred. If you convert any more demos please send them to me so that I can
+include them in the ditribution for others to learn from.
+
+Also if you are using these Units to write any games
+please let me know about it so that I can post the information to the http://www.DelphiGamer.com site.
+
+The plan is to have this unit JEDI certified at some point so that it can be included on the Delphi and Kylix CDs, so all feedback is greatly welcomed.
+
+Compilers supported Tested
+------------------- ------
+Delphi Yes
+Kylix Yes
+FreePascal Yes
+TMT Pascal compiler Not Yet.
+Virtual Pascal No
+Gnu Pascal No
+
+
+
+Credits
+-------
+Matthias Thoma <ma.thoma@gmx.de> for is endless help with my conversion bugs.
+Jason Farmer <jason@cerebral-bicycle.co.uk> for donating the SFont Font Library.
+Gustavo Maximo <gmaximo@secretariaplus.com> for the Puntos OpenGL Demo and work he is doing on the documentation
+Róbert Kisnémeth <mikrobi@freemail.hu> for his numerous contributions
+Chris Bruner <cryst@golden.net> for testing under Kylix
+August Logan Bear Jr.<augustjr@columbus.rr.com> for testing under Kylix
+Dean Ellis<dean_ellis@yahoo.com> for FreePascal Compiler compatability testing and SDL_Net demos and testing
+David House<david@dahsoftware.com> for Windows Insaller and testing.
+Romi Kuntsman<romik12345@lycos.co.uk> for helping out on some OpenGL issues.
+Everyone on the JEDI-SDL <http://groups.yahoo.com/group/JEDI-SDL/join/> mailing list for their feedback and support.
+Everyone on the Delphi-JEDI <http://groups.yahoo.com/group/Delphi-JEDI/join/> mailing for answering my conversion questions.
+Tom Jones for inspiring this conversion.
+
+The JEDI-SDL Home page can be found @ http://www.delphi-jedi.org/Jedi:TEAM_SDL_HOME
+
+The JEDI-SDL source code archive can be found @ http://www.sf.net/projects/jedi-sdl/
+
+The JEDI-SDL mailing list can be found @ http://groups.yahoo.com/group/JEDI-SDL/join/
+
+The Latest Stable Release version of the JEDI-SDL.zip file can always be found on the Delphi-JEDI site <http://www.delphi-jedi.org/Jedi:TEAM_SDL_HOME>
+
+The Latest Alpha/Unstable version can always be grabbed from the SourceForge CVS http://sourceforge.net/cvs/?group_id=43805
+
+
+Sincerely,
+
+
+
+Dominique Louis
+Delphi Game Developer.
+*********************************************************
+** To Do Nothing is to Collaborate with the oppressor **
+** -------------------------------------------------- **
+*********************************************************
+=========================================================
+From . . . . . . . : Dominique Louis
+Email. . . . . . . : Dominique@SavageSoftware.com.au
+Company. . . . . . : Savage Software Solutions
+Delphi Games Site. : http://www.DelphiGamer.com
+Delphi JEDI Site . : http://www.delphi-jedi.org
+=========================================================
+
diff --git a/Game/Code/lib/JEDI-SDL/OpenGL/Pas/geometry.pas b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/geometry.pas new file mode 100644 index 00000000..15783515 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/geometry.pas @@ -0,0 +1,1994 @@ +unit geometry;
+{
+ $Id: geometry.pas,v 1.1 2004/03/30 21:53:54 savage Exp $
+
+}
+
+// This unit contains many needed types, functions and procedures for
+// quaternion, vector and matrix arithmetics. It is specifically designed
+// for geometric calculations within R3 (affine vector space)
+// and R4 (homogeneous vector space).
+//
+// Note: The terms 'affine' or 'affine coordinates' are not really correct here
+// because an 'affine transformation' describes generally a transformation which leads
+// to a uniquely solvable system of equations and has nothing to do with the dimensionality
+// of a vector. One could use 'projective coordinates' but this is also not really correct
+// and since I haven't found a better name (or even any correct one), 'affine' is as good
+// as any other one.
+//
+// Identifiers containing no dimensionality (like affine or homogeneous)
+// and no datatype (integer..extended) are supposed as R4 representation
+// with 'single' floating point type (examples are TVector, TMatrix,
+// and TQuaternion). The default data type is 'single' ('GLFloat' for OpenGL)
+// and used in all routines (except conversions and trigonometric functions).
+//
+// Routines with an open array as argument can either take Func([1,2,3,4,..]) or Func(Vect).
+// The latter is prefered, since no extra stack operations is required.
+// Note: Be careful while passing open array elements! If you pass more elements
+// than there's room in the result the behaviour will be unpredictable.
+//
+// If not otherwise stated, all angles are given in radians
+// (instead of degrees). Use RadToDeg or DegToRad to convert between them.
+//
+// Geometry.pas was assembled from different sources (like GraphicGems)
+// and relevant books or based on self written code, respectivly.
+//
+// Note: Some aspects need to be considered when using Delphi and pure
+// assembler code. Delphi ensures that the direction flag is always
+// cleared while entering a function and expects it cleared on return.
+// This is in particular important in routines with (CPU) string commands (MOVSD etc.)
+// The registers EDI, ESI and EBX (as well as the stack management
+// registers EBP and ESP) must not be changed! EAX, ECX and EDX are
+// freely available and mostly used for parameter.
+//
+// Version 2.5
+// last change : 04. January 2000
+//
+// (c) Copyright 1999, Dipl. Ing. Mike Lischke (public@lischke-online.de)
+{
+ $Log: geometry.pas,v $
+ Revision 1.1 2004/03/30 21:53:54 savage
+ Moved to it's own folder.
+
+ Revision 1.1 2004/02/05 00:08:19 savage
+ Module 1.0 release
+
+
+}
+
+interface
+
+{$I jedi-sdl.inc}
+
+type
+ // data types needed for 3D graphics calculation,
+ // included are 'C like' aliases for each type (to be
+ // conformal with OpenGL types)
+
+ PByte = ^Byte;
+ PWord = ^Word;
+ PInteger = ^Integer;
+ PFloat = ^Single;
+ PDouble = ^Double;
+ PExtended = ^Extended;
+ PPointer = ^Pointer;
+
+ // types to specify continous streams of a specific type
+ // switch off range checking to access values beyond the limits
+ PByteVector = ^TByteVector;
+ PByteArray = PByteVector;
+ TByteVector = array[0..0] of Byte;
+
+ PWordVector = ^TWordVector;
+ PWordArray = PWordVector; // note: there's a same named type in SysUtils
+ TWordVector = array[0..0] of Word;
+
+ PIntegerVector = ^TIntegerVector;
+ PIntegerArray = PIntegerVector;
+ TIntegerVector = array[0..0] of Integer;
+
+ PFloatVector = ^TFloatVector;
+ PFloatArray = PFloatVector;
+ TFloatVector = array[0..0] of Single;
+
+ PDoubleVector = ^TDoubleVector;
+ PDoubleArray = PDoubleVector;
+ TDoubleVector = array[0..0] of Double;
+
+ PExtendedVector = ^TExtendedVector;
+ PExtendedArray = PExtendedVector;
+ TExtendedVector = array[0..0] of Extended;
+
+ PPointerVector = ^TPointerVector;
+ PPointerArray = PPointerVector;
+ TPointerVector = array[0..0] of Pointer;
+
+ PCardinalVector = ^TCardinalVector;
+ PCardinalArray = PCardinalVector;
+ TCardinalVector = array[0..0] of Cardinal;
+
+ // common vector and matrix types with predefined limits
+ // indices correspond like: x -> 0
+ // y -> 1
+ // z -> 2
+ // w -> 3
+
+ PHomogeneousByteVector = ^THomogeneousByteVector;
+ THomogeneousByteVector = array[0..3] of Byte;
+ TVector4b = THomogeneousByteVector;
+
+ PHomogeneousWordVector = ^THomogeneousWordVector;
+ THomogeneousWordVector = array[0..3] of Word;
+ TVector4w = THomogeneousWordVector;
+
+ PHomogeneousIntVector = ^THomogeneousIntVector;
+ THomogeneousIntVector = array[0..3] of Integer;
+ TVector4i = THomogeneousIntVector;
+
+ PHomogeneousFltVector = ^THomogeneousFltVector;
+ THomogeneousFltVector = array[0..3] of Single;
+ TVector4f = THomogeneousFltVector;
+
+ PHomogeneousDblVector = ^THomogeneousDblVector;
+ THomogeneousDblVector = array[0..3] of Double;
+ TVector4d = THomogeneousDblVector;
+
+ PHomogeneousExtVector = ^THomogeneousExtVector;
+ THomogeneousExtVector = array[0..3] of Extended;
+ TVector4e = THomogeneousExtVector;
+
+ PHomogeneousPtrVector = ^THomogeneousPtrVector;
+ THomogeneousPtrVector = array[0..3] of Pointer;
+ TVector4p = THomogeneousPtrVector;
+
+ PAffineByteVector = ^TAffineByteVector;
+ TAffineByteVector = array[0..2] of Byte;
+ TVector3b = TAffineByteVector;
+
+ PAffineWordVector = ^TAffineWordVector;
+ TAffineWordVector = array[0..2] of Word;
+ TVector3w = TAffineWordVector;
+
+ PAffineIntVector = ^TAffineIntVector;
+ TAffineIntVector = array[0..2] of Integer;
+ TVector3i = TAffineIntVector;
+
+ PAffineFltVector = ^TAffineFltVector;
+ TAffineFltVector = array[0..2] of Single;
+ TVector3f = TAffineFltVector;
+
+ PAffineDblVector = ^TAffineDblVector;
+ TAffineDblVector = array[0..2] of Double;
+ TVector3d = TAffineDblVector;
+
+ PAffineExtVector = ^TAffineExtVector;
+ TAffineExtVector = array[0..2] of Extended;
+ TVector3e = TAffineExtVector;
+
+ PAffinePtrVector = ^TAffinePtrVector;
+ TAffinePtrVector = array[0..2] of Pointer;
+ TVector3p = TAffinePtrVector;
+
+ // some simplified names
+ PVector = ^TVector;
+ TVector = THomogeneousFltVector;
+
+ PHomogeneousVector = ^THomogeneousVector;
+ THomogeneousVector = THomogeneousFltVector;
+
+ PAffineVector = ^TAffineVector;
+ TAffineVector = TAffineFltVector;
+
+ // arrays of vectors
+ PVectorArray = ^TVectorArray;
+ TVectorArray = array[0..0] of TAffineVector;
+
+ // matrices
+ THomogeneousByteMatrix = array[0..3] of THomogeneousByteVector;
+ TMatrix4b = THomogeneousByteMatrix;
+
+ THomogeneousWordMatrix = array[0..3] of THomogeneousWordVector;
+ TMatrix4w = THomogeneousWordMatrix;
+
+ THomogeneousIntMatrix = array[0..3] of THomogeneousIntVector;
+ TMatrix4i = THomogeneousIntMatrix;
+
+ THomogeneousFltMatrix = array[0..3] of THomogeneousFltVector;
+ TMatrix4f = THomogeneousFltMatrix;
+
+ THomogeneousDblMatrix = array[0..3] of THomogeneousDblVector;
+ TMatrix4d = THomogeneousDblMatrix;
+
+ THomogeneousExtMatrix = array[0..3] of THomogeneousExtVector;
+ TMatrix4e = THomogeneousExtMatrix;
+
+ TAffineByteMatrix = array[0..2] of TAffineByteVector;
+ TMatrix3b = TAffineByteMatrix;
+
+ TAffineWordMatrix = array[0..2] of TAffineWordVector;
+ TMatrix3w = TAffineWordMatrix;
+
+ TAffineIntMatrix = array[0..2] of TAffineIntVector;
+ TMatrix3i = TAffineIntMatrix;
+
+ TAffineFltMatrix = array[0..2] of TAffineFltVector;
+ TMatrix3f = TAffineFltMatrix;
+
+ TAffineDblMatrix = array[0..2] of TAffineDblVector;
+ TMatrix3d = TAffineDblMatrix;
+
+ TAffineExtMatrix = array[0..2] of TAffineExtVector;
+ TMatrix3e = TAffineExtMatrix;
+
+ // some simplified names
+ PMatrix = ^TMatrix;
+ TMatrix = THomogeneousFltMatrix;
+
+ PHomogeneousMatrix = ^THomogeneousMatrix;
+ THomogeneousMatrix = THomogeneousFltMatrix;
+
+ PAffineMatrix = ^TAffineMatrix;
+ TAffineMatrix = TAffineFltMatrix;
+
+ // q = ([x, y, z], w)
+ TQuaternion = record
+ case Integer of
+ 0:
+ (ImagPart: TAffineVector;
+ RealPart: Single);
+ 1:
+ (Vector: TVector4f);
+ end;
+
+ TRectangle = record
+ Left,
+ Top,
+ Width,
+ Height: Integer;
+ end;
+
+ TTransType = (ttScaleX, ttScaleY, ttScaleZ,
+ ttShearXY, ttShearXZ, ttShearYZ,
+ ttRotateX, ttRotateY, ttRotateZ,
+ ttTranslateX, ttTranslateY, ttTranslateZ,
+ ttPerspectiveX, ttPerspectiveY, ttPerspectiveZ, ttPerspectiveW);
+
+ // used to describe a sequence of transformations in following order:
+ // [Sx][Sy][Sz][ShearXY][ShearXZ][ShearZY][Rx][Ry][Rz][Tx][Ty][Tz][P(x,y,z,w)]
+ // constants are declared for easier access (see MatrixDecompose below)
+ TTransformations = array[TTransType] of Single;
+
+
+const
+ // useful constants
+
+ // standard vectors
+ XVector: TAffineVector = (1, 0, 0);
+ YVector: TAffineVector = (0, 1, 0);
+ ZVector: TAffineVector = (0, 0, 1);
+ NullVector: TAffineVector = (0, 0, 0);
+
+ IdentityMatrix: TMatrix = ((1, 0, 0, 0),
+ (0, 1, 0, 0),
+ (0, 0, 1, 0),
+ (0, 0, 0, 1));
+ EmptyMatrix: TMatrix = ((0, 0, 0, 0),
+ (0, 0, 0, 0),
+ (0, 0, 0, 0),
+ (0, 0, 0, 0));
+ // some very small numbers
+ EPSILON = 1e-100;
+ EPSILON2 = 1e-50;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+// vector functions
+function VectorAdd(V1, V2: TVector): TVector;
+function VectorAffineAdd(V1, V2: TAffineVector): TAffineVector;
+function VectorAffineCombine(V1, V2: TAffineVector; F1, F2: Single): TAffineVector;
+function VectorAffineDotProduct(V1, V2: TAffineVector): Single;
+function VectorAffineLerp(V1, V2: TAffineVector; t: Single): TAffineVector;
+function VectorAffineSubtract(V1, V2: TAffineVector): TAffineVector;
+function VectorAngle(V1, V2: TAffineVector): Single;
+function VectorCombine(V1, V2: TVector; F1, F2: Single): TVector;
+function VectorCrossProduct(V1, V2: TAffineVector): TAffineVector;
+function VectorDotProduct(V1, V2: TVector): Single;
+function VectorLength(V: array of Single): Single;
+function VectorLerp(V1, V2: TVector; t: Single): TVector;
+procedure VectorNegate(V: array of Single);
+function VectorNorm(V: array of Single): Single;
+function VectorNormalize(V: array of Single): Single;
+function VectorPerpendicular(V, N: TAffineVector): TAffineVector;
+function VectorReflect(V, N: TAffineVector): TAffineVector;
+procedure VectorRotate(var Vector: TVector4f; Axis: TVector3f; Angle: Single);
+procedure VectorScale(V: array of Single; Factor: Single);
+function VectorSubtract(V1, V2: TVector): TVector;
+
+// matrix functions
+function CreateRotationMatrixX(Sine, Cosine: Single): TMatrix;
+function CreateRotationMatrixY(Sine, Cosine: Single): TMatrix;
+function CreateRotationMatrixZ(Sine, Cosine: Single): TMatrix;
+function CreateScaleMatrix(V: TAffineVector): TMatrix;
+function CreateTranslationMatrix(V: TVector): TMatrix;
+procedure MatrixAdjoint(var M: TMatrix);
+function MatrixAffineDeterminant(M: TAffineMatrix): Single;
+procedure MatrixAffineTranspose(var M: TAffineMatrix);
+function MatrixDeterminant(M: TMatrix): Single;
+procedure MatrixInvert(var M: TMatrix);
+function MatrixMultiply(M1, M2: TMatrix): TMatrix;
+procedure MatrixScale(var M: TMatrix; Factor: Single);
+procedure MatrixTranspose(var M: TMatrix);
+
+// quaternion functions
+function QuaternionConjugate(Q: TQuaternion): TQuaternion;
+function QuaternionFromPoints(V1, V2: TAffineVector): TQuaternion;
+function QuaternionMultiply(qL, qR: TQuaternion): TQuaternion;
+function QuaternionSlerp(QStart, QEnd: TQuaternion; Spin: Integer; t: Single): TQuaternion;
+function QuaternionToMatrix(Q: TQuaternion): TMatrix;
+procedure QuaternionToPoints(Q: TQuaternion; var ArcFrom, ArcTo: TAffineVector);
+
+// mixed functions
+function ConvertRotation(Angles: TAffineVector): TVector;
+function CreateRotationMatrix(Axis: TVector3f; Angle: Single): TMatrix;
+function MatrixDecompose(M: TMatrix; var Tran: TTransformations): Boolean;
+function VectorAffineTransform(V: TAffineVector; M: TAffineMatrix): TAffineVector;
+function VectorTransform(V: TVector4f; M: TMatrix): TVector4f; overload;
+function VectorTransform(V: TVector3f; M: TMatrix): TVector3f; overload;
+
+// miscellaneous functions
+function MakeAffineDblVector(V: array of Double): TAffineDblVector;
+function MakeDblVector(V: array of Double): THomogeneousDblVector;
+function MakeAffineVector(V: array of Single): TAffineVector;
+function MakeQuaternion(Imag: array of Single; Real: Single): TQuaternion;
+function MakeVector(V: array of Single): TVector;
+function PointInPolygon(xp, yp : array of Single; x, y: Single): Boolean;
+function VectorAffineDblToFlt(V: TAffineDblVector): TAffineVector;
+function VectorDblToFlt(V: THomogeneousDblVector): THomogeneousVector;
+function VectorAffineFltToDbl(V: TAffineVector): TAffineDblVector;
+function VectorFltToDbl(V: TVector): THomogeneousDblVector;
+
+// trigonometric functions
+function ArcCos(X: Extended): Extended;
+function ArcSin(X: Extended): Extended;
+function ArcTan2(Y, X: Extended): Extended;
+function CoTan(X: Extended): Extended;
+function DegToRad(Degrees: Extended): Extended;
+function RadToDeg(Radians: Extended): Extended;
+procedure SinCos(Theta: Extended; var Sin, Cos: Extended);
+function Tan(X: Extended): Extended;
+
+// coordinate system manipulation functions
+function Turn(Matrix: TMatrix; Angle: Single): TMatrix; overload;
+function Turn(Matrix: TMatrix; MasterUp: TAffineVector; Angle: Single): TMatrix; overload;
+function Pitch(Matrix: TMatrix; Angle: Single): TMatrix; overload;
+function Pitch(Matrix: TMatrix; MasterRight: TAffineVector; Angle: Single): TMatrix; overload;
+function Roll(Matrix: TMatrix; Angle: Single): TMatrix; overload;
+function Roll(Matrix: TMatrix; MasterDirection: TAffineVector; Angle: Single): TMatrix; overload;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+implementation
+
+const
+ // FPU status flags (high order byte)
+ C0 = 1;
+ C1 = 2;
+ C2 = 4;
+ C3 = $40;
+
+ // to be used as descriptive indices
+ X = 0;
+ Y = 1;
+ Z = 2;
+ W = 3;
+
+//----------------- trigonometric helper functions ---------------------------------------------------------------------
+
+function DegToRad(Degrees: Extended): Extended;
+
+begin
+ Result := Degrees * (PI / 180);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function RadToDeg(Radians: Extended): Extended;
+
+begin
+ Result := Radians * (180 / PI);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure SinCos(Theta: Extended; var Sin, Cos: Extended); assembler; register;
+
+// calculates sine and cosine from the given angle Theta
+// EAX contains address of Sin
+// EDX contains address of Cos
+// Theta is passed over the stack
+
+asm
+ FLD Theta
+ FSINCOS
+ FSTP TBYTE PTR [EDX] // cosine
+ FSTP TBYTE PTR [EAX] // sine
+ FWAIT
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function ArcCos(X: Extended): Extended;
+
+begin
+ Result := ArcTan2(Sqrt(1 - X * X), X);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function ArcSin(X: Extended): Extended;
+
+begin
+ Result := ArcTan2(X, Sqrt(1 - X * X))
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function ArcTan2(Y, X: Extended): Extended;
+
+asm
+ FLD Y
+ FLD X
+ FPATAN
+ FWAIT
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function Tan(X: Extended): Extended;
+
+asm
+ FLD X
+ FPTAN
+ FSTP ST(0) // FPTAN pushes 1.0 after result
+ FWAIT
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function CoTan(X: Extended): Extended;
+
+asm
+ FLD X
+ FPTAN
+ FDIVRP
+ FWAIT
+end;
+
+//----------------- miscellaneous vector functions ---------------------------------------------------------------------
+
+function MakeAffineDblVector(V: array of Double): TAffineDblVector; assembler;
+
+// creates a vector from given values
+// EAX contains address of V
+// ECX contains address to result vector
+// EDX contains highest index of V
+
+asm
+ PUSH EDI
+ PUSH ESI
+ MOV EDI, ECX
+ MOV ESI, EAX
+ MOV ECX, EDX
+ ADD ECX, 2
+ REP MOVSD
+ POP ESI
+ POP EDI
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function MakeDblVector(V: array of Double): THomogeneousDblVector; assembler;
+
+// creates a vector from given values
+// EAX contains address of V
+// ECX contains address to result vector
+// EDX contains highest index of V
+
+asm
+ PUSH EDI
+ PUSH ESI
+ MOV EDI, ECX
+ MOV ESI, EAX
+ MOV ECX, EDX
+ ADD ECX, 2
+ REP MOVSD
+ POP ESI
+ POP EDI
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function MakeAffineVector(V: array of Single): TAffineVector; assembler;
+
+// creates a vector from given values
+// EAX contains address of V
+// ECX contains address to result vector
+// EDX contains highest index of V
+
+asm
+ PUSH EDI
+ PUSH ESI
+ MOV EDI, ECX
+ MOV ESI, EAX
+ MOV ECX, EDX
+ INC ECX
+ CMP ECX, 3
+ JB @@1
+ MOV ECX, 3
+@@1: REP MOVSD // copy given values
+ MOV ECX, 2
+ SUB ECX, EDX // determine missing entries
+ JS @@Finish
+ XOR EAX, EAX
+ REP STOSD // set remaining fields to 0
+@@Finish: POP ESI
+ POP EDI
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function MakeQuaternion(Imag: array of Single; Real: Single): TQuaternion; assembler;
+
+// creates a quaternion from the given values
+// EAX contains address of Imag
+// ECX contains address to result vector
+// EDX contains highest index of Imag
+// Real part is passed on the stack
+
+asm
+ PUSH EDI
+ PUSH ESI
+ MOV EDI, ECX
+ MOV ESI, EAX
+ MOV ECX, EDX
+ INC ECX
+ REP MOVSD
+ MOV EAX, [Real]
+ MOV [EDI], EAX
+ POP ESI
+ POP EDI
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function MakeVector(V: array of Single): TVector; assembler;
+
+// creates a vector from given values
+// EAX contains address of V
+// ECX contains address to result vector
+// EDX contains highest index of V
+
+asm
+ PUSH EDI
+ PUSH ESI
+ MOV EDI, ECX
+ MOV ESI, EAX
+ MOV ECX, EDX
+ INC ECX
+ CMP ECX, 4
+ JB @@1
+ MOV ECX, 4
+@@1: REP MOVSD // copy given values
+ MOV ECX, 3
+ SUB ECX, EDX // determine missing entries
+ JS @@Finish
+ XOR EAX, EAX
+ REP STOSD // set remaining fields to 0
+@@Finish: POP ESI
+ POP EDI
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorLength(V: array of Single): Single; assembler;
+
+// calculates the length of a vector following the equation: sqrt(x * x + y * y + ...)
+// Note: The parameter of this function is declared as open array. Thus
+// there's no restriction about the number of the components of the vector.
+//
+// EAX contains address of V
+// EDX contains the highest index of V
+// the result is returned in ST(0)
+
+asm
+ FLDZ // initialize sum
+@@Loop: FLD DWORD PTR [EAX + 4 * EDX] // load a component
+ FMUL ST, ST
+ FADDP
+ SUB EDX, 1
+ JNL @@Loop
+ FSQRT
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorAngle(V1, V2: TAffineVector): Single; assembler;
+
+// calculates the cosine of the angle between Vector1 and Vector2
+// Result = DotProduct(V1, V2) / (Length(V1) * Length(V2))
+//
+// EAX contains address of Vector1
+// EDX contains address of Vector2
+
+asm
+ FLD DWORD PTR [EAX] // V1[0]
+ FLD ST // double V1[0]
+ FMUL ST, ST // V1[0]^2 (prep. for divisor)
+ FLD DWORD PTR [EDX] // V2[0]
+ FMUL ST(2), ST // ST(2) := V1[0] * V2[0]
+ FMUL ST, ST // V2[0]^2 (prep. for divisor)
+ FLD DWORD PTR [EAX + 4] // V1[1]
+ FLD ST // double V1[1]
+ FMUL ST, ST // ST(0) := V1[1]^2
+ FADDP ST(3), ST // ST(2) := V1[0]^2 + V1[1] * * 2
+ FLD DWORD PTR [EDX + 4] // V2[1]
+ FMUL ST(1), ST // ST(1) := V1[1] * V2[1]
+ FMUL ST, ST // ST(0) := V2[1]^2
+ FADDP ST(2), ST // ST(1) := V2[0]^2 + V2[1]^2
+ FADDP ST(3), ST // ST(2) := V1[0] * V2[0] + V1[1] * V2[1]
+ FLD DWORD PTR [EAX + 8] // load V2[1]
+ FLD ST // same calcs go here
+ FMUL ST, ST // (compare above)
+ FADDP ST(3), ST
+ FLD DWORD PTR [EDX + 8]
+ FMUL ST(1), ST
+ FMUL ST, ST
+ FADDP ST(2), ST
+ FADDP ST(3), ST
+ FMULP // ST(0) := (V1[0]^2 + V1[1]^2 + V1[2]) *
+ // (V2[0]^2 + V2[1]^2 + V2[2])
+ FSQRT // sqrt(ST(0))
+ FDIVP // ST(0) := Result := ST(1) / ST(0)
+ // the result is expected in ST(0), if it's invalid, an error is raised
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorNorm(V: array of Single): Single; assembler; register;
+
+// calculates norm of a vector which is defined as norm = x * x + y * y + ...
+// EAX contains address of V
+// EDX contains highest index in V
+// result is passed in ST(0)
+
+asm
+ FLDZ // initialize sum
+@@Loop: FLD DWORD PTR [EAX + 4 * EDX] // load a component
+ FMUL ST, ST // make square
+ FADDP // add previous calculated sum
+ SUB EDX, 1
+ JNL @@Loop
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorNormalize(V: array of Single): Single; assembler; register;
+
+// transforms a vector to unit length and return length
+// EAX contains address of V
+// EDX contains the highest index in V
+// return former length of V in ST
+
+asm
+ PUSH EBX
+ MOV ECX, EDX // save size of V
+ CALL VectorLength // calculate length of vector
+ FTST // test if length = 0
+ MOV EBX, EAX // save parameter address
+ FSTSW AX // get test result
+ TEST AH, C3 // check the test result
+ JNZ @@Finish
+ SUB EBX, 4 // simplyfied address calculation
+ INC ECX
+ FLD1 // calculate reciprocal of length
+ FDIV ST, ST(1)
+@@1: FLD ST // double reciprocal
+ FMUL DWORD PTR [EBX + 4 * ECX] // scale component
+ WAIT
+ FSTP DWORD PTR [EBX + 4 * ECX] // store result
+ LOOP @@1
+ FSTP ST // remove reciprocal from FPU stack
+@@Finish: POP EBX
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorAffineSubtract(V1, V2: TAffineVector): TAffineVector; assembler; register;
+
+// returns v1 minus v2
+// EAX contains address of V1
+// EDX contains address of V2
+// ECX contains address of the result
+
+asm
+ {Result[X] := V1[X]-V2[X];
+ Result[Y] := V1[Y]-V2[Y];
+ Result[Z] := V1[Z]-V2[Z];}
+
+ FLD DWORD PTR [EAX]
+ FSUB DWORD PTR [EDX]
+ FSTP DWORD PTR [ECX]
+ FLD DWORD PTR [EAX + 4]
+ FSUB DWORD PTR [EDX + 4]
+ FSTP DWORD PTR [ECX + 4]
+ FLD DWORD PTR [EAX + 8]
+ FSUB DWORD PTR [EDX + 8]
+ FSTP DWORD PTR [ECX + 8]
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorReflect(V, N: TAffineVector): TAffineVector; assembler; register;
+
+// reflects vector V against N (assumes N is normalized)
+// EAX contains address of V
+// EDX contains address of N
+// ECX contains address of the result
+
+//var Dot : Single;
+
+asm
+ {Dot := VectorAffineDotProduct(V, N);
+ Result[X] := V[X]-2 * Dot * N[X];
+ Result[Y] := V[Y]-2 * Dot * N[Y];
+ Result[Z] := V[Z]-2 * Dot * N[Z];}
+
+ CALL VectorAffineDotProduct // dot is now in ST(0)
+ FCHS // -dot
+ FADD ST, ST // -dot * 2
+ FLD DWORD PTR [EDX] // ST := N[X]
+ FMUL ST, ST(1) // ST := -2 * dot * N[X]
+ FADD DWORD PTR[EAX] // ST := V[X] - 2 * dot * N[X]
+ FSTP DWORD PTR [ECX] // store result
+ FLD DWORD PTR [EDX + 4] // etc.
+ FMUL ST, ST(1)
+ FADD DWORD PTR[EAX + 4]
+ FSTP DWORD PTR [ECX + 4]
+ FLD DWORD PTR [EDX + 8]
+ FMUL ST, ST(1)
+ FADD DWORD PTR[EAX + 8]
+ FSTP DWORD PTR [ECX + 8]
+ FSTP ST // clean FPU stack
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure VectorRotate(var Vector: TVector4f; Axis: TVector3f; Angle: Single);
+
+// rotates Vector about Axis with Angle radiants
+
+var RotMatrix : TMatrix4f;
+
+begin
+ RotMatrix := CreateRotationMatrix(Axis, Angle);
+ Vector := VectorTransform(Vector, RotMatrix);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure VectorScale(V: array of Single; Factor: Single); assembler; register;
+
+// returns a vector scaled by a factor
+// EAX contains address of V
+// EDX contains highest index in V
+// Factor is located on the stack
+
+asm
+ {for I := Low(V) to High(V) do V[I] := V[I] * Factor;}
+
+ FLD DWORD PTR [Factor] // load factor
+@@Loop: FLD DWORD PTR [EAX + 4 * EDX] // load a component
+ FMUL ST, ST(1) // multiply it with the factor
+ WAIT
+ FSTP DWORD PTR [EAX + 4 * EDX] // store the result
+ DEC EDX // do the entire array
+ JNS @@Loop
+ FSTP ST(0) // clean the FPU stack
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure VectorNegate(V: array of Single); assembler; register;
+
+// returns a negated vector
+// EAX contains address of V
+// EDX contains highest index in V
+
+asm
+ {V[X] := -V[X];
+ V[Y] := -V[Y];
+ V[Z] := -V[Z];}
+
+@@Loop: FLD DWORD PTR [EAX + 4 * EDX]
+ FCHS
+ WAIT
+ FSTP DWORD PTR [EAX + 4 * EDX]
+ DEC EDX
+ JNS @@Loop
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorAdd(V1, V2: TVector): TVector; register;
+
+// returns the sum of two vectors
+
+begin
+ Result[X] := V1[X] + V2[X];
+ Result[Y] := V1[Y] + V2[Y];
+ Result[Z] := V1[Z] + V2[Z];
+ Result[W] := V1[W] + V2[W];
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorAffineAdd(V1, V2: TAffineVector): TAffineVector; register;
+
+// returns the sum of two vectors
+
+begin
+ Result[X] := V1[X] + V2[X];
+ Result[Y] := V1[Y] + V2[Y];
+ Result[Z] := V1[Z] + V2[Z];
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorSubtract(V1, V2: TVector): TVector; register;
+
+// returns the difference of two vectors
+
+begin
+ Result[X] := V1[X] - V2[X];
+ Result[Y] := V1[Y] - V2[Y];
+ Result[Z] := V1[Z] - V2[Z];
+ Result[W] := V1[W] - V2[W];
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorDotProduct(V1, V2: TVector): Single; register;
+
+begin
+ Result := V1[X] * V2[X] + V1[Y] * V2[Y] + V1[Z] * V2[Z] + V1[W] * V2[W];
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorAffineDotProduct(V1, V2: TAffineVector): Single; assembler; register;
+
+// calculates the dot product between V1 and V2
+// EAX contains address of V1
+// EDX contains address of V2
+// result is stored in ST(0)
+
+asm
+ //Result := V1[X] * V2[X] + V1[Y] * V2[Y] + V1[Z] * V2[Z];
+
+ FLD DWORD PTR [EAX]
+ FMUL DWORD PTR [EDX]
+ FLD DWORD PTR [EAX + 4]
+ FMUL DWORD PTR [EDX + 4]
+ FADDP
+ FLD DWORD PTR [EAX + 8]
+ FMUL DWORD PTR [EDX + 8]
+ FADDP
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorCrossProduct(V1, V2: TAffineVector): TAffineVector;
+
+// calculates the cross product between vector 1 and 2, Temp is necessary because
+// either V1 or V2 could also be the result vector
+//
+// EAX contains address of V1
+// EDX contains address of V2
+// ECX contains address of result
+
+var Temp: TAffineVector;
+
+asm
+ {Temp[X] := V1[Y] * V2[Z]-V1[Z] * V2[Y];
+ Temp[Y] := V1[Z] * V2[X]-V1[X] * V2[Z];
+ Temp[Z] := V1[X] * V2[Y]-V1[Y] * V2[X];
+ Result := Temp;}
+
+ PUSH EBX // save EBX, must be restored to original value
+ LEA EBX, [Temp]
+ FLD DWORD PTR [EDX + 8] // first load both vectors onto FPU register stack
+ FLD DWORD PTR [EDX + 4]
+ FLD DWORD PTR [EDX + 0]
+ FLD DWORD PTR [EAX + 8]
+ FLD DWORD PTR [EAX + 4]
+ FLD DWORD PTR [EAX + 0]
+
+ FLD ST(1) // ST(0) := V1[Y]
+ FMUL ST, ST(6) // ST(0) := V1[Y] * V2[Z]
+ FLD ST(3) // ST(0) := V1[Z]
+ FMUL ST, ST(6) // ST(0) := V1[Z] * V2[Y]
+ FSUBP ST(1), ST // ST(0) := ST(1)-ST(0)
+ FSTP DWORD [EBX] // Temp[X] := ST(0)
+ FLD ST(2) // ST(0) := V1[Z]
+ FMUL ST, ST(4) // ST(0) := V1[Z] * V2[X]
+ FLD ST(1) // ST(0) := V1[X]
+ FMUL ST, ST(7) // ST(0) := V1[X] * V2[Z]
+ FSUBP ST(1), ST // ST(0) := ST(1)-ST(0)
+ FSTP DWORD [EBX + 4] // Temp[Y] := ST(0)
+ FLD ST // ST(0) := V1[X]
+ FMUL ST, ST(5) // ST(0) := V1[X] * V2[Y]
+ FLD ST(2) // ST(0) := V1[Y]
+ FMUL ST, ST(5) // ST(0) := V1[Y] * V2[X]
+ FSUBP ST(1), ST // ST(0) := ST(1)-ST(0)
+ FSTP DWORD [EBX + 8] // Temp[Z] := ST(0)
+ FSTP ST(0) // clear FPU register stack
+ FSTP ST(0)
+ FSTP ST(0)
+ FSTP ST(0)
+ FSTP ST(0)
+ FSTP ST(0)
+ MOV EAX, [EBX] // copy Temp to Result
+ MOV [ECX], EAX
+ MOV EAX, [EBX + 4]
+ MOV [ECX + 4], EAX
+ MOV EAX, [EBX + 8]
+ MOV [ECX + 8], EAX
+ POP EBX
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorPerpendicular(V, N: TAffineVector): TAffineVector;
+
+// calculates a vector perpendicular to N (N is assumed to be of unit length)
+// subtract out any component parallel to N
+
+var Dot: Single;
+
+begin
+ Dot := VectorAffineDotProduct(V, N);
+ Result[X] := V[X]-Dot * N[X];
+ Result[Y] := V[Y]-Dot * N[Y];
+ Result[Z] := V[Z]-Dot * N[Z];
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorTransform(V: TVector4f; M: TMatrix): TVector4f; register;
+
+// transforms a homogeneous vector by multiplying it with a matrix
+
+var TV: TVector4f;
+
+begin
+ TV[X] := V[X] * M[X, X] + V[Y] * M[Y, X] + V[Z] * M[Z, X] + V[W] * M[W, X];
+ TV[Y] := V[X] * M[X, Y] + V[Y] * M[Y, Y] + V[Z] * M[Z, Y] + V[W] * M[W, Y];
+ TV[Z] := V[X] * M[X, Z] + V[Y] * M[Y, Z] + V[Z] * M[Z, Z] + V[W] * M[W, Z];
+ TV[W] := V[X] * M[X, W] + V[Y] * M[Y, W] + V[Z] * M[Z, W] + V[W] * M[W, W];
+ Result := TV
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorTransform(V: TVector3f; M: TMatrix): TVector3f;
+
+// transforms an affine vector by multiplying it with a (homogeneous) matrix
+
+var TV: TVector3f;
+
+begin
+ TV[X] := V[X] * M[X, X] + V[Y] * M[Y, X] + V[Z] * M[Z, X] + M[W, X];
+ TV[Y] := V[X] * M[X, Y] + V[Y] * M[Y, Y] + V[Z] * M[Z, Y] + M[W, Y];
+ TV[Z] := V[X] * M[X, Z] + V[Y] * M[Y, Z] + V[Z] * M[Z, Z] + M[W, Z];
+ Result := TV;
+end;
+
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorAffineTransform(V: TAffineVector; M: TAffineMatrix): TAffineVector; register;
+
+// transforms an affine vector by multiplying it with a matrix
+
+var TV: TAffineVector;
+
+begin
+ TV[X] := V[X] * M[X, X] + V[Y] * M[Y, X] + V[Z] * M[Z, X];
+ TV[Y] := V[X] * M[X, Y] + V[Y] * M[Y, Y] + V[Z] * M[Z, Y];
+ TV[Z] := V[X] * M[X, Z] + V[Y] * M[Y, Z] + V[Z] * M[Z, Z];
+ Result := TV;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function PointInPolygon(xp, yp : array of Single; x, y: Single): Boolean;
+
+// The code below is from Wm. Randolph Franklin <wrf@ecse.rpi.edu>
+// with some minor modifications for speed. It returns 1 for strictly
+// interior points, 0 for strictly exterior, and 0 or 1 for points on
+// the boundary.
+// This code is not yet tested!
+
+var I, J: Integer;
+
+begin
+ Result := False;
+ if High(XP) <> High(YP) then Exit;
+ J := High(XP);
+ for I := 0 to High(XP) do
+ begin
+ if ((((yp[I] <= y) and (y < yp[J])) or ((yp[J] <= y) and (y < yp[I]))) and
+ (x < (xp[J] - xp[I]) * (y - yp[I]) / (yp[J] - yp[I]) + xp[I]))
+ then Result := not Result;
+ J := I + 1;
+ end;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function QuaternionConjugate(Q: TQuaternion): TQuaternion; assembler;
+
+// returns the conjugate of a quaternion
+// EAX contains address of Q
+// EDX contains address of result
+
+asm
+ FLD DWORD PTR [EAX]
+ FCHS
+ WAIT
+ FSTP DWORD PTR [EDX]
+ FLD DWORD PTR [EAX + 4]
+ FCHS
+ WAIT
+ FSTP DWORD PTR [EDX + 4]
+ FLD DWORD PTR [EAX + 8]
+ FCHS
+ WAIT
+ FSTP DWORD PTR [EDX + 8]
+ MOV EAX, [EAX + 12]
+ MOV [EDX + 12], EAX
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function QuaternionFromPoints(V1, V2: TAffineVector): TQuaternion; assembler;
+
+// constructs a unit quaternion from two points on unit sphere
+// EAX contains address of V1
+// ECX contains address to result
+// EDX contains address of V2
+
+asm
+ {Result.ImagPart := VectorCrossProduct(V1, V2);
+ Result.RealPart := Sqrt((VectorAffineDotProduct(V1, V2) + 1)/2);}
+
+ PUSH EAX
+ CALL VectorCrossProduct // determine axis to rotate about
+ POP EAX
+ FLD1 // prepare next calculation
+ Call VectorAffineDotProduct // calculate cos(angle between V1 and V2)
+ FADD ST, ST(1) // transform angle to angle/2 by: cos(a/2)=sqrt((1 + cos(a))/2)
+ FXCH ST(1)
+ FADD ST, ST
+ FDIVP ST(1), ST
+ FSQRT
+ FSTP DWORD PTR [ECX + 12] // Result.RealPart := ST(0)
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function QuaternionMultiply(qL, qR: TQuaternion): TQuaternion;
+
+// Returns quaternion product qL * qR. Note: order is important!
+// To combine rotations, use the product QuaternionMuliply(qSecond, qFirst),
+// which gives the effect of rotating by qFirst then qSecond.
+
+var Temp : TQuaternion;
+
+begin
+ Temp.RealPart := qL.RealPart * qR.RealPart - qL.ImagPart[X] * qR.ImagPart[X] -
+ qL.ImagPart[Y] * qR.ImagPart[Y] - qL.ImagPart[Z] * qR.ImagPart[Z];
+ Temp.ImagPart[X] := qL.RealPart * qR.ImagPart[X] + qL.ImagPart[X] * qR.RealPart +
+ qL.ImagPart[Y] * qR.ImagPart[Z] - qL.ImagPart[Z] * qR.ImagPart[Y];
+ Temp.ImagPart[Y] := qL.RealPart * qR.ImagPart[Y] + qL.ImagPart[Y] * qR.RealPart +
+ qL.ImagPart[Z] * qR.ImagPart[X] - qL.ImagPart[X] * qR.ImagPart[Z];
+ Temp.ImagPart[Z] := qL.RealPart * qR.ImagPart[Z] + qL.ImagPart[Z] * qR.RealPart +
+ qL.ImagPart[X] * qR.ImagPart[Y] - qL.ImagPart[Y] * qR.ImagPart[X];
+ Result := Temp;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function QuaternionToMatrix(Q: TQuaternion): TMatrix;
+
+// Constructs rotation matrix from (possibly non-unit) quaternion.
+// Assumes matrix is used to multiply column vector on the left:
+// vnew = mat vold. Works correctly for right-handed coordinate system
+// and right-handed rotations.
+
+// Essentially, this function is the same as CreateRotationMatrix and you can consider it as
+// being for reference here.
+
+{var Norm, S,
+ XS, YS, ZS,
+ WX, WY, WZ,
+ XX, XY, XZ,
+ YY, YZ, ZZ : Single;
+
+begin
+ Norm := Q.Vector[X] * Q.Vector[X] + Q.Vector[Y] * Q.Vector[Y] + Q.Vector[Z] * Q.Vector[Z] + Q.RealPart * Q.RealPart;
+ if Norm > 0 then S := 2 / Norm
+ else S := 0;
+
+ XS := Q.Vector[X] * S; YS := Q.Vector[Y] * S; ZS := Q.Vector[Z] * S;
+ WX := Q.RealPart * XS; WY := Q.RealPart * YS; WZ := Q.RealPart * ZS;
+ XX := Q.Vector[X] * XS; XY := Q.Vector[X] * YS; XZ := Q.Vector[X] * ZS;
+ YY := Q.Vector[Y] * YS; YZ := Q.Vector[Y] * ZS; ZZ := Q.Vector[Z] * ZS;
+
+ Result[X, X] := 1 - (YY + ZZ); Result[Y, X] := XY + WZ; Result[Z, X] := XZ - WY; Result[W, X] := 0;
+ Result[X, Y] := XY - WZ; Result[Y, Y] := 1 - (XX + ZZ); Result[Z, Y] := YZ + WX; Result[W, Y] := 0;
+ Result[X, Z] := XZ + WY; Result[Y, Z] := YZ - WX; Result[Z, Z] := 1 - (XX + YY); Result[W, Z] := 0;
+ Result[X, W] := 0; Result[Y, W] := 0; Result[Z, W] := 0; Result[W, W] := 1;}
+
+var
+ V: TAffineVector;
+ SinA, CosA,
+ A, B, C: Extended;
+
+begin
+ V := Q.ImagPart;
+ VectorNormalize(V);
+ SinCos(Q.RealPart / 2, SinA, CosA);
+ A := V[X] * SinA;
+ B := V[Y] * SinA;
+ C := V[Z] * SinA;
+
+ Result := IdentityMatrix;
+ Result[X, X] := 1 - 2 * B * B - 2 * C * C;
+ Result[X, Y] := 2 * A * B - 2 * CosA * C;
+ Result[X, Z] := 2 * A * C + 2 * CosA * B;
+
+ Result[Y, X] := 2 * A * B + 2 * CosA * C;
+ Result[Y, Y] := 1 - 2 * A * A - 2 * C * C;
+ Result[Y, Z] := 2 * B * C - 2 * CosA * A;
+
+ Result[Z, X] := 2 * A * C - 2 * CosA * B;
+ Result[Z, Y] := 2 * B * C + 2 * CosA * A;
+ Result[Z, Z] := 1 - 2 * A * A - 2 * B * B;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure QuaternionToPoints(Q: TQuaternion; var ArcFrom, ArcTo: TAffineVector); register;
+
+// converts a unit quaternion into two points on a unit sphere
+
+var S: Single;
+
+begin
+ S := Sqrt(Q.ImagPart[X] * Q.ImagPart[X] + Q.ImagPart[Y] * Q.ImagPart[Y]);
+ if S = 0 then ArcFrom := MakeAffineVector([0, 1, 0])
+ else ArcFrom := MakeAffineVector([-Q.ImagPart[Y] / S, Q.ImagPart[X] / S, 0]);
+ ArcTo[X] := Q.RealPart * ArcFrom[X] - Q.ImagPart[Z] * ArcFrom[Y];
+ ArcTo[Y] := Q.RealPart * ArcFrom[Y] + Q.ImagPart[Z] * ArcFrom[X];
+ ArcTo[Z] := Q.ImagPart[X] * ArcFrom[Y] - Q.ImagPart[Y] * ArcFrom[X];
+ if Q.RealPart < 0 then ArcFrom := MakeAffineVector([-ArcFrom[X], -ArcFrom[Y], 0]);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function MatrixAffineDeterminant(M: TAffineMatrix): Single; register;
+
+// determinant of a 3x3 matrix
+
+begin
+ Result := M[X, X] * (M[Y, Y] * M[Z, Z] - M[Z, Y] * M[Y, Z]) -
+ M[X, Y] * (M[Y, X] * M[Z, Z] - M[Z, X] * M[Y, Z]) +
+ M[X, Z] * (M[Y, X] * M[Z, Y] - M[Z, X] * M[Y, Y]);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function MatrixDetInternal(a1, a2, a3, b1, b2, b3, c1, c2, c3: Single): Single;
+
+// internal version for the determinant of a 3x3 matrix
+
+begin
+ Result := a1 * (b2 * c3 - b3 * c2) -
+ b1 * (a2 * c3 - a3 * c2) +
+ c1 * (a2 * b3 - a3 * b2);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure MatrixAdjoint(var M: TMatrix); register;
+
+// Adjoint of a 4x4 matrix - used in the computation of the inverse
+// of a 4x4 matrix
+
+var a1, a2, a3, a4,
+ b1, b2, b3, b4,
+ c1, c2, c3, c4,
+ d1, d2, d3, d4: Single;
+
+
+begin
+ a1 := M[X, X]; b1 := M[X, Y];
+ c1 := M[X, Z]; d1 := M[X, W];
+ a2 := M[Y, X]; b2 := M[Y, Y];
+ c2 := M[Y, Z]; d2 := M[Y, W];
+ a3 := M[Z, X]; b3 := M[Z, Y];
+ c3 := M[Z, Z]; d3 := M[Z, W];
+ a4 := M[W, X]; b4 := M[W, Y];
+ c4 := M[W, Z]; d4 := M[W, W];
+
+ // row column labeling reversed since we transpose rows & columns
+ M[X, X] := MatrixDetInternal(b2, b3, b4, c2, c3, c4, d2, d3, d4);
+ M[Y, X] := -MatrixDetInternal(a2, a3, a4, c2, c3, c4, d2, d3, d4);
+ M[Z, X] := MatrixDetInternal(a2, a3, a4, b2, b3, b4, d2, d3, d4);
+ M[W, X] := -MatrixDetInternal(a2, a3, a4, b2, b3, b4, c2, c3, c4);
+
+ M[X, Y] := -MatrixDetInternal(b1, b3, b4, c1, c3, c4, d1, d3, d4);
+ M[Y, Y] := MatrixDetInternal(a1, a3, a4, c1, c3, c4, d1, d3, d4);
+ M[Z, Y] := -MatrixDetInternal(a1, a3, a4, b1, b3, b4, d1, d3, d4);
+ M[W, Y] := MatrixDetInternal(a1, a3, a4, b1, b3, b4, c1, c3, c4);
+
+ M[X, Z] := MatrixDetInternal(b1, b2, b4, c1, c2, c4, d1, d2, d4);
+ M[Y, Z] := -MatrixDetInternal(a1, a2, a4, c1, c2, c4, d1, d2, d4);
+ M[Z, Z] := MatrixDetInternal(a1, a2, a4, b1, b2, b4, d1, d2, d4);
+ M[W, Z] := -MatrixDetInternal(a1, a2, a4, b1, b2, b4, c1, c2, c4);
+
+ M[X, W] := -MatrixDetInternal(b1, b2, b3, c1, c2, c3, d1, d2, d3);
+ M[Y, W] := MatrixDetInternal(a1, a2, a3, c1, c2, c3, d1, d2, d3);
+ M[Z, W] := -MatrixDetInternal(a1, a2, a3, b1, b2, b3, d1, d2, d3);
+ M[W, W] := MatrixDetInternal(a1, a2, a3, b1, b2, b3, c1, c2, c3);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function MatrixDeterminant(M: TMatrix): Single; register;
+
+// Determinant of a 4x4 matrix
+
+var a1, a2, a3, a4,
+ b1, b2, b3, b4,
+ c1, c2, c3, c4,
+ d1, d2, d3, d4 : Single;
+
+begin
+ a1 := M[X, X]; b1 := M[X, Y]; c1 := M[X, Z]; d1 := M[X, W];
+ a2 := M[Y, X]; b2 := M[Y, Y]; c2 := M[Y, Z]; d2 := M[Y, W];
+ a3 := M[Z, X]; b3 := M[Z, Y]; c3 := M[Z, Z]; d3 := M[Z, W];
+ a4 := M[W, X]; b4 := M[W, Y]; c4 := M[W, Z]; d4 := M[W, W];
+
+ Result := a1 * MatrixDetInternal(b2, b3, b4, c2, c3, c4, d2, d3, d4) -
+ b1 * MatrixDetInternal(a2, a3, a4, c2, c3, c4, d2, d3, d4) +
+ c1 * MatrixDetInternal(a2, a3, a4, b2, b3, b4, d2, d3, d4) -
+ d1 * MatrixDetInternal(a2, a3, a4, b2, b3, b4, c2, c3, c4);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure MatrixScale(var M: TMatrix; Factor: Single); register;
+
+// multiplies all elements of a 4x4 matrix with a factor
+
+var I, J: Integer;
+
+begin
+ for I := 0 to 3 do
+ for J := 0 to 3 do M[I, J] := M[I, J] * Factor;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure MatrixInvert(var M: TMatrix); register;
+
+// finds the inverse of a 4x4 matrix
+
+var Det: Single;
+
+begin
+ Det := MatrixDeterminant(M);
+ if Abs(Det) < EPSILON then M := IdentityMatrix
+ else
+ begin
+ MatrixAdjoint(M);
+ MatrixScale(M, 1 / Det);
+ end;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure MatrixTranspose(var M: TMatrix); register;
+
+// computes transpose of 4x4 matrix
+
+var I, J: Integer;
+ TM: TMatrix;
+
+begin
+ for I := 0 to 3 do
+ for J := 0 to 3 do TM[J, I] := M[I, J];
+ M := TM;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure MatrixAffineTranspose(var M: TAffineMatrix); register;
+
+// computes transpose of 3x3 matrix
+
+var I, J: Integer;
+ TM: TAffineMatrix;
+
+begin
+ for I := 0 to 2 do
+ for J := 0 to 2 do TM[J, I] := M[I, J];
+ M := TM;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function MatrixMultiply(M1, M2: TMatrix): TMatrix; register;
+
+// multiplies two 4x4 matrices
+
+var I, J: Integer;
+ TM: TMatrix;
+
+begin
+ for I := 0 to 3 do
+ for J := 0 to 3 do
+ TM[I, J] := M1[I, X] * M2[X, J] +
+ M1[I, Y] * M2[Y, J] +
+ M1[I, Z] * M2[Z, J] +
+ M1[I, W] * M2[W, J];
+ Result := TM;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function CreateRotationMatrix(Axis: TVector3f; Angle: Single): TMatrix; register;
+
+// Creates a rotation matrix along the given Axis by the given Angle in radians.
+
+var cosine,
+ sine,
+ Len,
+ one_minus_cosine: Extended;
+
+begin
+ SinCos(Angle, Sine, Cosine);
+ one_minus_cosine := 1 - cosine;
+ Len := VectorNormalize(Axis);
+
+ if Len = 0 then Result := IdentityMatrix
+ else
+ begin
+ Result[X, X] := (one_minus_cosine * Sqr(Axis[0])) + Cosine;
+ Result[X, Y] := (one_minus_cosine * Axis[0] * Axis[1]) - (Axis[2] * Sine);
+ Result[X, Z] := (one_minus_cosine * Axis[2] * Axis[0]) + (Axis[1] * Sine);
+ Result[X, W] := 0;
+
+ Result[Y, X] := (one_minus_cosine * Axis[0] * Axis[1]) + (Axis[2] * Sine);
+ Result[Y, Y] := (one_minus_cosine * Sqr(Axis[1])) + Cosine;
+ Result[Y, Z] := (one_minus_cosine * Axis[1] * Axis[2]) - (Axis[0] * Sine);
+ Result[Y, W] := 0;
+
+ Result[Z, X] := (one_minus_cosine * Axis[2] * Axis[0]) - (Axis[1] * Sine);
+ Result[Z, Y] := (one_minus_cosine * Axis[1] * Axis[2]) + (Axis[0] * Sine);
+ Result[Z, Z] := (one_minus_cosine * Sqr(Axis[2])) + Cosine;
+ Result[Z, W] := 0;
+
+ Result[W, X] := 0;
+ Result[W, Y] := 0;
+ Result[W, Z] := 0;
+ Result[W, W] := 1;
+ end;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function ConvertRotation(Angles: TAffineVector): TVector; register;
+
+{ Turn a triplet of rotations about x, y, and z (in that order) into an
+ equivalent rotation around a single axis (all in radians).
+
+ Rotation of the Angle t about the axis (X, Y, Z) is given by:
+
+ | X^2 + (1-X^2) Cos(t), XY(1-Cos(t)) + Z Sin(t), XZ(1-Cos(t))-Y Sin(t) |
+ M = | XY(1-Cos(t))-Z Sin(t), Y^2 + (1-Y^2) Cos(t), YZ(1-Cos(t)) + X Sin(t) |
+ | XZ(1-Cos(t)) + Y Sin(t), YZ(1-Cos(t))-X Sin(t), Z^2 + (1-Z^2) Cos(t) |
+
+ Rotation about the three axes (Angles a1, a2, a3) can be represented as
+ the product of the individual rotation matrices:
+
+ | 1 0 0 | | Cos(a2) 0 -Sin(a2) | | Cos(a3) Sin(a3) 0 |
+ | 0 Cos(a1) Sin(a1) | * | 0 1 0 | * | -Sin(a3) Cos(a3) 0 |
+ | 0 -Sin(a1) Cos(a1) | | Sin(a2) 0 Cos(a2) | | 0 0 1 |
+ Mx My Mz
+
+ We now want to solve for X, Y, Z, and t given 9 equations in 4 unknowns.
+ Using the diagonal elements of the two matrices, we get:
+
+ X^2 + (1-X^2) Cos(t) = M[0][0]
+ Y^2 + (1-Y^2) Cos(t) = M[1][1]
+ Z^2 + (1-Z^2) Cos(t) = M[2][2]
+
+ Adding the three equations, we get:
+
+ X^2 + Y^2 + Z^2 - (M[0][0] + M[1][1] + M[2][2]) =
+ - (3 - X^2 - Y^2 - Z^2) Cos(t)
+
+ Since (X^2 + Y^2 + Z^2) = 1, we can rewrite as:
+
+ Cos(t) = (1 - (M[0][0] + M[1][1] + M[2][2])) / 2
+
+ Solving for t, we get:
+
+ t = Acos(((M[0][0] + M[1][1] + M[2][2]) - 1) / 2)
+
+ We can substitute t into the equations for X^2, Y^2, and Z^2 above
+ to get the values for X, Y, and Z. To find the proper signs we note
+ that:
+
+ 2 X Sin(t) = M[1][2] - M[2][1]
+ 2 Y Sin(t) = M[2][0] - M[0][2]
+ 2 Z Sin(t) = M[0][1] - M[1][0]
+}
+
+var Axis1, Axis2: TVector3f;
+ M, M1, M2: TMatrix;
+ cost, cost1,
+ sint,
+ s1, s2, s3: Single;
+ I: Integer;
+
+
+begin
+ // see if we are only rotating about a single Axis
+ if Abs(Angles[X]) < EPSILON then
+ begin
+ if Abs(Angles[Y]) < EPSILON then
+ begin
+ Result := MakeVector([0, 0, 1, Angles[Z]]);
+ Exit;
+ end
+ else
+ if Abs(Angles[Z]) < EPSILON then
+ begin
+ Result := MakeVector([0, 1, 0, Angles[Y]]);
+ Exit;
+ end
+ end
+ else
+ if (Abs(Angles[Y]) < EPSILON) and
+ (Abs(Angles[Z]) < EPSILON) then
+ begin
+ Result := MakeVector([1, 0, 0, Angles[X]]);
+ Exit;
+ end;
+
+ // make the rotation matrix
+ Axis1 := MakeAffineVector([1, 0, 0]);
+ M := CreateRotationMatrix(Axis1, Angles[X]);
+
+ Axis2 := MakeAffineVector([0, 1, 0]);
+ M2 := CreateRotationMatrix(Axis2, Angles[Y]);
+ M1 := MatrixMultiply(M, M2);
+
+ Axis2 := MakeAffineVector([0, 0, 1]);
+ M2 := CreateRotationMatrix(Axis2, Angles[Z]);
+ M := MatrixMultiply(M1, M2);
+
+ cost := ((M[X, X] + M[Y, Y] + M[Z, Z])-1) / 2;
+ if cost < -1 then cost := -1
+ else
+ if cost > 1 - EPSILON then
+ begin
+ // Bad Angle - this would cause a crash
+ Result := MakeVector([1, 0, 0, 0]);
+ Exit;
+ end;
+
+ cost1 := 1 - cost;
+ Result := Makevector([Sqrt((M[X, X]-cost) / cost1),
+ Sqrt((M[Y, Y]-cost) / cost1),
+ sqrt((M[Z, Z]-cost) / cost1),
+ arccos(cost)]);
+
+ sint := 2 * Sqrt(1 - cost * cost); // This is actually 2 Sin(t)
+
+ // Determine the proper signs
+ for I := 0 to 7 do
+ begin
+ if (I and 1) > 1 then s1 := -1 else s1 := 1;
+ if (I and 2) > 1 then s2 := -1 else s2 := 1;
+ if (I and 4) > 1 then s3 := -1 else s3 := 1;
+ if (Abs(s1 * Result[X] * sint-M[Y, Z] + M[Z, Y]) < EPSILON2) and
+ (Abs(s2 * Result[Y] * sint-M[Z, X] + M[X, Z]) < EPSILON2) and
+ (Abs(s3 * Result[Z] * sint-M[X, Y] + M[Y, X]) < EPSILON2) then
+ begin
+ // We found the right combination of signs
+ Result[X] := Result[X] * s1;
+ Result[Y] := Result[Y] * s2;
+ Result[Z] := Result[Z] * s3;
+ Exit;
+ end;
+ end;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function CreateRotationMatrixX(Sine, Cosine: Single): TMatrix; register;
+
+// creates matrix for rotation about x-axis
+
+begin
+ Result := EmptyMatrix;
+ Result[X, X] := 1;
+ Result[Y, Y] := Cosine;
+ Result[Y, Z] := Sine;
+ Result[Z, Y] := -Sine;
+ Result[Z, Z] := Cosine;
+ Result[W, W] := 1;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function CreateRotationMatrixY(Sine, Cosine: Single): TMatrix; register;
+
+// creates matrix for rotation about y-axis
+
+begin
+ Result := EmptyMatrix;
+ Result[X, X] := Cosine;
+ Result[X, Z] := -Sine;
+ Result[Y, Y] := 1;
+ Result[Z, X] := Sine;
+ Result[Z, Z] := Cosine;
+ Result[W, W] := 1;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function CreateRotationMatrixZ(Sine, Cosine: Single): TMatrix; register;
+
+// creates matrix for rotation about z-axis
+
+begin
+ Result := EmptyMatrix;
+ Result[X, X] := Cosine;
+ Result[X, Y] := Sine;
+ Result[Y, X] := -Sine;
+ Result[Y, Y] := Cosine;
+ Result[Z, Z] := 1;
+ Result[W, W] := 1;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function CreateScaleMatrix(V: TAffineVector): TMatrix; register;
+
+// creates scaling matrix
+
+begin
+ Result := IdentityMatrix;
+ Result[X, X] := V[X];
+ Result[Y, Y] := V[Y];
+ Result[Z, Z] := V[Z];
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function CreateTranslationMatrix(V: TVector): TMatrix; register;
+
+// creates translation matrix
+
+begin
+ Result := IdentityMatrix;
+ Result[W, X] := V[X];
+ Result[W, Y] := V[Y];
+ Result[W, Z] := V[Z];
+ Result[W, W] := V[W];
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function Lerp(Start, Stop, t: Single): Single;
+
+// calculates linear interpolation between start and stop at point t
+
+begin
+ Result := Start + (Stop - Start) * t;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorAffineLerp(V1, V2: TAffineVector; t: Single): TAffineVector;
+
+// calculates linear interpolation between vector1 and vector2 at point t
+
+begin
+ Result[X] := Lerp(V1[X], V2[X], t);
+ Result[Y] := Lerp(V1[Y], V2[Y], t);
+ Result[Z] := Lerp(V1[Z], V2[Z], t);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorLerp(V1, V2: TVector; t: Single): TVector;
+
+// calculates linear interpolation between vector1 and vector2 at point t
+
+begin
+ Result[X] := Lerp(V1[X], V2[X], t);
+ Result[Y] := Lerp(V1[Y], V2[Y], t);
+ Result[Z] := Lerp(V1[Z], V2[Z], t);
+ Result[W] := Lerp(V1[W], V2[W], t);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function QuaternionSlerp(QStart, QEnd: TQuaternion; Spin: Integer; t: Single): TQuaternion;
+
+// spherical linear interpolation of unit quaternions with spins
+// QStart, QEnd - start and end unit quaternions
+// t - interpolation parameter (0 to 1)
+// Spin - number of extra spin rotations to involve
+
+var beta, // complementary interp parameter
+ theta, // Angle between A and B
+ sint, cost, // sine, cosine of theta
+ phi: Single; // theta plus spins
+ bflip: Boolean; // use negativ t?
+
+
+begin
+ // cosine theta
+ cost := VectorAngle(QStart.ImagPart, QEnd.ImagPart);
+
+ // if QEnd is on opposite hemisphere from QStart, use -QEnd instead
+ if cost < 0 then
+ begin
+ cost := -cost;
+ bflip := True;
+ end
+ else bflip := False;
+
+ // if QEnd is (within precision limits) the same as QStart,
+ // just linear interpolate between QStart and QEnd.
+ // Can't do spins, since we don't know what direction to spin.
+
+ if (1 - cost) < EPSILON then beta := 1 - t
+ else
+ begin
+ // normal case
+ theta := arccos(cost);
+ phi := theta + Spin * Pi;
+ sint := sin(theta);
+ beta := sin(theta - t * phi) / sint;
+ t := sin(t * phi) / sint;
+ end;
+
+ if bflip then t := -t;
+
+ // interpolate
+ Result.ImagPart[X] := beta * QStart.ImagPart[X] + t * QEnd.ImagPart[X];
+ Result.ImagPart[Y] := beta * QStart.ImagPart[Y] + t * QEnd.ImagPart[Y];
+ Result.ImagPart[Z] := beta * QStart.ImagPart[Z] + t * QEnd.ImagPart[Z];
+ Result.RealPart := beta * QStart.RealPart + t * QEnd.RealPart;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorAffineCombine(V1, V2: TAffineVector; F1, F2: Single): TAffineVector;
+
+// makes a linear combination of two vectors and return the result
+
+begin
+ Result[X] := (F1 * V1[X]) + (F2 * V2[X]);
+ Result[Y] := (F1 * V1[Y]) + (F2 * V2[Y]);
+ Result[Z] := (F1 * V1[Z]) + (F2 * V2[Z]);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorCombine(V1, V2: TVector; F1, F2: Single): TVector;
+
+// makes a linear combination of two vectors and return the result
+
+begin
+ Result[X] := (F1 * V1[X]) + (F2 * V2[X]);
+ Result[Y] := (F1 * V1[Y]) + (F2 * V2[Y]);
+ Result[Z] := (F1 * V1[Z]) + (F2 * V2[Z]);
+ Result[W] := (F1 * V1[W]) + (F2 * V2[W]);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function MatrixDecompose(M: TMatrix; var Tran: TTransformations): Boolean; register;
+
+// Author: Spencer W. Thomas, University of Michigan
+//
+// MatrixDecompose - Decompose a non-degenerated 4x4 transformation matrix into
+// the sequence of transformations that produced it.
+//
+// The coefficient of each transformation is returned in the corresponding
+// element of the vector Tran.
+//
+// Returns true upon success, false if the matrix is singular.
+
+var I, J: Integer;
+ LocMat,
+ pmat,
+ invpmat,
+ tinvpmat: TMatrix;
+ prhs,
+ psol: TVector;
+ Row: array[0..2] of TAffineVector;
+
+begin
+ Result := False;
+ locmat := M;
+ // normalize the matrix
+ if locmat[W, W] = 0 then Exit;
+ for I := 0 to 3 do
+ for J := 0 to 3 do
+ locmat[I, J] := locmat[I, J] / locmat[W, W];
+
+ // pmat is used to solve for perspective, but it also provides
+ // an easy way to test for singularity of the upper 3x3 component.
+
+ pmat := locmat;
+ for I := 0 to 2 do pmat[I, W] := 0;
+ pmat[W, W] := 1;
+
+ if MatrixDeterminant(pmat) = 0 then Exit;
+
+ // First, isolate perspective. This is the messiest.
+ if (locmat[X, W] <> 0) or
+ (locmat[Y, W] <> 0) or
+ (locmat[Z, W] <> 0) then
+ begin
+ // prhs is the right hand side of the equation.
+ prhs[X] := locmat[X, W];
+ prhs[Y] := locmat[Y, W];
+ prhs[Z] := locmat[Z, W];
+ prhs[W] := locmat[W, W];
+
+ // Solve the equation by inverting pmat and multiplying
+ // prhs by the inverse. (This is the easiest way, not
+ // necessarily the best.)
+
+ invpmat := pmat;
+ MatrixInvert(invpmat);
+ MatrixTranspose(invpmat);
+ psol := VectorTransform(prhs, tinvpmat);
+
+ // stuff the answer away
+ Tran[ttPerspectiveX] := psol[X];
+ Tran[ttPerspectiveY] := psol[Y];
+ Tran[ttPerspectiveZ] := psol[Z];
+ Tran[ttPerspectiveW] := psol[W];
+
+ // clear the perspective partition
+ locmat[X, W] := 0;
+ locmat[Y, W] := 0;
+ locmat[Z, W] := 0;
+ locmat[W, W] := 1;
+ end
+ else
+ begin
+ // no perspective
+ Tran[ttPerspectiveX] := 0;
+ Tran[ttPerspectiveY] := 0;
+ Tran[ttPerspectiveZ] := 0;
+ Tran[ttPerspectiveW] := 0;
+ end;
+
+ // next take care of translation (easy)
+ for I := 0 to 2 do
+ begin
+ Tran[TTransType(Ord(ttTranslateX) + I)] := locmat[W, I];
+ locmat[W, I] := 0;
+ end;
+
+ // now get scale and shear
+ for I := 0 to 2 do
+ begin
+ row[I, X] := locmat[I, X];
+ row[I, Y] := locmat[I, Y];
+ row[I, Z] := locmat[I, Z];
+ end;
+
+ // compute X scale factor and normalize first row
+ Tran[ttScaleX] := Sqr(VectorNormalize(row[0])); // ml: calculation optimized
+
+ // compute XY shear factor and make 2nd row orthogonal to 1st
+ Tran[ttShearXY] := VectorAffineDotProduct(row[0], row[1]);
+ row[1] := VectorAffineCombine(row[1], row[0], 1, -Tran[ttShearXY]);
+
+ // now, compute Y scale and normalize 2nd row
+ Tran[ttScaleY] := Sqr(VectorNormalize(row[1])); // ml: calculation optimized
+ Tran[ttShearXY] := Tran[ttShearXY]/Tran[ttScaleY];
+
+ // compute XZ and YZ shears, orthogonalize 3rd row
+ Tran[ttShearXZ] := VectorAffineDotProduct(row[0], row[2]);
+ row[2] := VectorAffineCombine(row[2], row[0], 1, -Tran[ttShearXZ]);
+ Tran[ttShearYZ] := VectorAffineDotProduct(row[1], row[2]);
+ row[2] := VectorAffineCombine(row[2], row[1], 1, -Tran[ttShearYZ]);
+
+ // next, get Z scale and normalize 3rd row
+ Tran[ttScaleZ] := Sqr(VectorNormalize(row[1])); // (ML) calc. optimized
+ Tran[ttShearXZ] := Tran[ttShearXZ] / tran[ttScaleZ];
+ Tran[ttShearYZ] := Tran[ttShearYZ] / Tran[ttScaleZ];
+
+ // At this point, the matrix (in rows[]) is orthonormal.
+ // Check for a coordinate system flip. If the determinant
+ // is -1, then negate the matrix and the scaling factors.
+ if VectorAffineDotProduct(row[0], VectorCrossProduct(row[1], row[2])) < 0 then
+ for I := 0 to 2 do
+ begin
+ Tran[TTransType(Ord(ttScaleX) + I)] := -Tran[TTransType(Ord(ttScaleX) + I)];
+ row[I, X] := -row[I, X];
+ row[I, Y] := -row[I, Y];
+ row[I, Z] := -row[I, Z];
+ end;
+
+ // now, get the rotations out, as described in the gem
+ Tran[ttRotateY] := arcsin(-row[0, Z]);
+ if cos(Tran[ttRotateY]) <> 0 then
+ begin
+ Tran[ttRotateX] := arctan2(row[1, Z], row[2, Z]);
+ Tran[ttRotateZ] := arctan2(row[0, Y], row[0, X]);
+ end
+ else
+ begin
+ tran[ttRotateX] := arctan2(row[1, X], row[1, Y]);
+ tran[ttRotateZ] := 0;
+ end;
+ // All done!
+ Result := True;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorDblToFlt(V: THomogeneousDblVector): THomogeneousVector; assembler;
+
+// converts a vector containing double sized values into a vector with single sized values
+
+asm
+ FLD QWORD PTR [EAX]
+ FSTP DWORD PTR [EDX]
+ FLD QWORD PTR [EAX + 8]
+ FSTP DWORD PTR [EDX + 4]
+ FLD QWORD PTR [EAX + 16]
+ FSTP DWORD PTR [EDX + 8]
+ FLD QWORD PTR [EAX + 24]
+ FSTP DWORD PTR [EDX + 12]
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorAffineDblToFlt(V: TAffineDblVector): TAffineVector; assembler;
+
+// converts a vector containing double sized values into a vector with single sized values
+
+asm
+ FLD QWORD PTR [EAX]
+ FSTP DWORD PTR [EDX]
+ FLD QWORD PTR [EAX + 8]
+ FSTP DWORD PTR [EDX + 4]
+ FLD QWORD PTR [EAX + 16]
+ FSTP DWORD PTR [EDX + 8]
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorAffineFltToDbl(V: TAffineVector): TAffineDblVector; assembler;
+
+// converts a vector containing single sized values into a vector with double sized values
+
+asm
+ FLD DWORD PTR [EAX]
+ FSTP QWORD PTR [EDX]
+ FLD DWORD PTR [EAX + 8]
+ FSTP QWORD PTR [EDX + 4]
+ FLD DWORD PTR [EAX + 16]
+ FSTP QWORD PTR [EDX + 8]
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function VectorFltToDbl(V: TVector): THomogeneousDblVector; assembler;
+
+// converts a vector containing single sized values into a vector with double sized values
+
+asm
+ FLD DWORD PTR [EAX]
+ FSTP QWORD PTR [EDX]
+ FLD DWORD PTR [EAX + 8]
+ FSTP QWORD PTR [EDX + 4]
+ FLD DWORD PTR [EAX + 16]
+ FSTP QWORD PTR [EDX + 8]
+ FLD DWORD PTR [EAX + 24]
+ FSTP QWORD PTR [EDX + 12]
+end;
+
+//----------------- coordinate system manipulation functions -----------------------------------------------------------
+
+function Turn(Matrix: TMatrix; Angle: Single): TMatrix;
+
+// rotates the given coordinate system (represented by the matrix) around its Y-axis
+
+begin
+ Result := MatrixMultiply(Matrix, CreateRotationMatrix(MakeAffineVector(Matrix[1]), Angle));
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function Turn(Matrix: TMatrix; MasterUp: TAffineVector; Angle: Single): TMatrix;
+
+// rotates the given coordinate system (represented by the matrix) around MasterUp
+
+begin
+ Result := MatrixMultiply(Matrix, CreateRotationMatrix(MasterUp, Angle));
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function Pitch(Matrix: TMatrix; Angle: Single): TMatrix;
+
+// rotates the given coordinate system (represented by the matrix) around its X-axis
+
+begin
+ Result := MatrixMultiply(Matrix, CreateRotationMatrix(MakeAffineVector(Matrix[0]), Angle));
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function Pitch(Matrix: TMatrix; MasterRight: TAffineVector; Angle: Single): TMatrix; overload;
+
+// rotates the given coordinate system (represented by the matrix) around MasterRight
+
+begin
+ Result := MatrixMultiply(Matrix, CreateRotationMatrix(MasterRight, Angle));
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function Roll(Matrix: TMatrix; Angle: Single): TMatrix;
+
+// rotates the given coordinate system (represented by the matrix) around its Z-axis
+
+begin
+ Result := MatrixMultiply(Matrix, CreateRotationMatrix(MakeAffineVector(Matrix[2]), Angle));
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function Roll(Matrix: TMatrix; MasterDirection: TAffineVector; Angle: Single): TMatrix; overload;
+
+// rotates the given coordinate system (represented by the matrix) around MasterDirection
+
+begin
+ Result := MatrixMultiply(Matrix, CreateRotationMatrix(MasterDirection, Angle));
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+end.
+
+
diff --git a/Game/Code/lib/JEDI-SDL/OpenGL/Pas/gl.pas b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/gl.pas new file mode 100644 index 00000000..d2bdcf8b --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/gl.pas @@ -0,0 +1,2301 @@ +unit gl;
+{
+ $Id: gl.pas,v 1.5 2007/05/20 20:28:31 savage Exp $
+
+ Adaption of the delphi3d.net OpenGL units to FreePascal
+ Sebastian Guenther (sg@freepascal.org) in 2002
+ These units are free to use
+}
+
+(*++ BUILD Version: 0004 // Increment this if a change has global effects
+
+Copyright (c) 1985-96, Microsoft Corporation
+
+Module Name:
+
+ gl.h
+
+Abstract:
+
+ Procedure declarations, constant definitions and macros for the OpenGL
+ component.
+
+--*)
+
+(*
+** Copyright 1996 Silicon Graphics, Inc.
+** All Rights Reserved.
+**
+** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
+** the contents of this file may not be disclosed to third parties, copied or
+** duplicated in any form, in whole or in part, without the prior written
+** permission of Silicon Graphics, Inc.
+**
+** RESTRICTED RIGHTS LEGEND:
+** Use, duplication or disclosure by the Government is subject to restrictions
+** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
+** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
+** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
+** rights reserved under the Copyright Laws of the United States.
+*)
+
+{******************************************************************************}
+{ }
+{ Converted to Delphi by Tom Nuydens (tom@delphi3d.net) }
+{ For the latest updates, visit Delphi3D: http://www.delphi3d.net }
+{ }
+{ Modified for Delphi/Kylix and FreePascal }
+{ by Dominique Louis ( Dominique@Savagesoftware.com.au) }
+{ For the latest updates, visit JEDI-SDL : http://www.sf.net/projects/jedi-sdl }
+{ }
+{******************************************************************************}
+
+{
+ $Log: gl.pas,v $
+ Revision 1.5 2007/05/20 20:28:31 savage
+ Initial Changes to Handle 64 Bits
+
+ Revision 1.4 2006/11/20 21:20:59 savage
+ Updated to work in MacOS X
+
+ Revision 1.3 2005/05/22 18:52:09 savage
+ Changes as suggested by Michalis Kamburelis. Thanks again.
+
+ Revision 1.2 2004/08/14 22:54:30 savage
+ Updated so that Library name defines are correctly defined for MacOS X.
+
+ Revision 1.1 2004/03/30 21:53:54 savage
+ Moved to it's own folder.
+
+ Revision 1.4 2004/02/20 17:09:55 savage
+ Code tidied up in gl, glu and glut, while extensions in glext.pas are now loaded using SDL_GL_GetProcAddress, thus making it more cross-platform compatible, but now more tied to SDL.
+
+ Revision 1.3 2004/02/14 00:23:39 savage
+ As UNIX is defined in jedi-sdl.inc this will be used to check linux compatability as well. Units have been changed to reflect this change.
+
+ Revision 1.2 2004/02/14 00:09:18 savage
+ Changed uses to now make use of moduleloader.pas rather than dllfuncs.pas
+
+ Revision 1.1 2004/02/05 00:08:19 savage
+ Module 1.0 release
+
+ Revision 1.6 2003/06/02 12:32:12 savage
+ Modified Sources to avoid warnings with Delphi by moving CVS Logging to the top of the header files. Hopefully CVS Logging still works.
+
+}
+
+interface
+
+{$I jedi-sdl.inc}
+
+uses
+{$IFDEF __GPC__}
+ system,
+ gpc,
+{$ENDIF}
+
+{$IFDEF WINDOWS}
+ Windows,
+{$ENDIF}
+ moduleloader;
+
+
+var
+ LibGL: TModuleHandle;
+
+type
+ GLenum = Cardinal; PGLenum = ^GLenum;
+ GLboolean = Byte; PGLboolean = ^GLboolean;
+ GLbitfield = Cardinal; PGLbitfield = ^GLbitfield;
+ GLbyte = ShortInt; PGLbyte = ^GLbyte;
+ GLshort = SmallInt; PGLshort = ^GLshort;
+ GLint = Integer; PGLint = ^GLint;
+ GLsizei = Integer; PGLsizei = ^GLsizei;
+ GLubyte = Byte; PGLubyte = ^GLubyte;
+ GLushort = Word; PGLushort = ^GLushort;
+ GLuint = Cardinal; PGLuint = ^GLuint;
+ GLfloat = Single; PGLfloat = ^GLfloat;
+ GLclampf = Single; PGLclampf = ^GLclampf;
+ GLdouble = Double; PGLdouble = ^GLdouble;
+ GLclampd = Double; PGLclampd = ^GLclampd;
+{ GLvoid = void; } PGLvoid = Pointer;
+
+{******************************************************************************}
+
+const
+{$IFDEF WINDOWS}
+ GLLibName = 'OpenGL32.dll';
+{$ENDIF}
+
+{$IFDEF UNIX}
+{$IFDEF DARWIN}
+ GLLibName = '/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib';
+{$ELSE}
+ GLLibName = 'libGL.so';
+{$ENDIF}
+{$ENDIF}
+
+ // Version
+ GL_VERSION_1_1 = 1;
+
+ // AccumOp
+ GL_ACCUM = $0100;
+ GL_LOAD = $0101;
+ GL_RETURN = $0102;
+ GL_MULT = $0103;
+ GL_ADD = $0104;
+
+ // AlphaFunction
+ GL_NEVER = $0200;
+ GL_LESS = $0201;
+ GL_EQUAL = $0202;
+ GL_LEQUAL = $0203;
+ GL_GREATER = $0204;
+ GL_NOTEQUAL = $0205;
+ GL_GEQUAL = $0206;
+ GL_ALWAYS = $0207;
+
+ // AttribMask
+ GL_CURRENT_BIT = $00000001;
+ GL_POINT_BIT = $00000002;
+ GL_LINE_BIT = $00000004;
+ GL_POLYGON_BIT = $00000008;
+ GL_POLYGON_STIPPLE_BIT = $00000010;
+ GL_PIXEL_MODE_BIT = $00000020;
+ GL_LIGHTING_BIT = $00000040;
+ GL_FOG_BIT = $00000080;
+ GL_DEPTH_BUFFER_BIT = $00000100;
+ GL_ACCUM_BUFFER_BIT = $00000200;
+ GL_STENCIL_BUFFER_BIT = $00000400;
+ GL_VIEWPORT_BIT = $00000800;
+ GL_TRANSFORM_BIT = $00001000;
+ GL_ENABLE_BIT = $00002000;
+ GL_COLOR_BUFFER_BIT = $00004000;
+ GL_HINT_BIT = $00008000;
+ GL_EVAL_BIT = $00010000;
+ GL_LIST_BIT = $00020000;
+ GL_TEXTURE_BIT = $00040000;
+ GL_SCISSOR_BIT = $00080000;
+ GL_ALL_ATTRIB_BITS = $000FFFFF;
+
+ // BeginMode
+ GL_POINTS = $0000;
+ GL_LINES = $0001;
+ GL_LINE_LOOP = $0002;
+ GL_LINE_STRIP = $0003;
+ GL_TRIANGLES = $0004;
+ GL_TRIANGLE_STRIP = $0005;
+ GL_TRIANGLE_FAN = $0006;
+ GL_QUADS = $0007;
+ GL_QUAD_STRIP = $0008;
+ GL_POLYGON = $0009;
+
+ // BlendingFactorDest
+ GL_ZERO = 0;
+ GL_ONE = 1;
+ GL_SRC_COLOR = $0300;
+ GL_ONE_MINUS_SRC_COLOR = $0301;
+ GL_SRC_ALPHA = $0302;
+ GL_ONE_MINUS_SRC_ALPHA = $0303;
+ GL_DST_ALPHA = $0304;
+ GL_ONE_MINUS_DST_ALPHA = $0305;
+
+ // BlendingFactorSrc
+ // GL_ZERO
+ // GL_ONE
+ GL_DST_COLOR = $0306;
+ GL_ONE_MINUS_DST_COLOR = $0307;
+ GL_SRC_ALPHA_SATURATE = $0308;
+ // GL_SRC_ALPHA
+ // GL_ONE_MINUS_SRC_ALPHA
+ // GL_DST_ALPHA
+ // GL_ONE_MINUS_DST_ALPHA
+
+ // Boolean
+ GL_TRUE = 1;
+ GL_FALSE = 0;
+
+ // ClearBufferMask
+ // GL_COLOR_BUFFER_BIT
+ // GL_ACCUM_BUFFER_BIT
+ // GL_STENCIL_BUFFER_BIT
+ // GL_DEPTH_BUFFER_BIT
+
+ // ClientArrayType
+ // GL_VERTEX_ARRAY
+ // GL_NORMAL_ARRAY
+ // GL_COLOR_ARRAY
+ // GL_INDEX_ARRAY
+ // GL_TEXTURE_COORD_ARRAY
+ // GL_EDGE_FLAG_ARRAY
+
+ // ClipPlaneName
+ GL_CLIP_PLANE0 = $3000;
+ GL_CLIP_PLANE1 = $3001;
+ GL_CLIP_PLANE2 = $3002;
+ GL_CLIP_PLANE3 = $3003;
+ GL_CLIP_PLANE4 = $3004;
+ GL_CLIP_PLANE5 = $3005;
+
+ // ColorMaterialFace
+ // GL_FRONT
+ // GL_BACK
+ // GL_FRONT_AND_BACK
+
+ // ColorMaterialParameter
+ // GL_AMBIENT
+ // GL_DIFFUSE
+ // GL_SPECULAR
+ // GL_EMISSION
+ // GL_AMBIENT_AND_DIFFUSE
+
+ // ColorPointerType
+ // GL_BYTE
+ // GL_UNSIGNED_BYTE
+ // GL_SHORT
+ // GL_UNSIGNED_SHORT
+ // GL_INT
+ // GL_UNSIGNED_INT
+ // GL_FLOAT
+ // GL_DOUBLE
+
+ // CullFaceMode
+ // GL_FRONT
+ // GL_BACK
+ // GL_FRONT_AND_BACK
+
+ // DataType
+ GL_BYTE = $1400;
+ GL_UNSIGNED_BYTE = $1401;
+ GL_SHORT = $1402;
+ GL_UNSIGNED_SHORT = $1403;
+ GL_INT = $1404;
+ GL_UNSIGNED_INT = $1405;
+ GL_FLOAT = $1406;
+ GL_2_BYTES = $1407;
+ GL_3_BYTES = $1408;
+ GL_4_BYTES = $1409;
+ GL_DOUBLE = $140A;
+
+ // DepthFunction
+ // GL_NEVER
+ // GL_LESS
+ // GL_EQUAL
+ // GL_LEQUAL
+ // GL_GREATER
+ // GL_NOTEQUAL
+ // GL_GEQUAL
+ // GL_ALWAYS
+
+ // DrawBufferMode
+ GL_NONE = 0;
+ GL_FRONT_LEFT = $0400;
+ GL_FRONT_RIGHT = $0401;
+ GL_BACK_LEFT = $0402;
+ GL_BACK_RIGHT = $0403;
+ GL_FRONT = $0404;
+ GL_BACK = $0405;
+ GL_LEFT = $0406;
+ GL_RIGHT = $0407;
+ GL_FRONT_AND_BACK = $0408;
+ GL_AUX0 = $0409;
+ GL_AUX1 = $040A;
+ GL_AUX2 = $040B;
+ GL_AUX3 = $040C;
+
+ // Enable
+ // GL_FOG
+ // GL_LIGHTING
+ // GL_TEXTURE_1D
+ // GL_TEXTURE_2D
+ // GL_LINE_STIPPLE
+ // GL_POLYGON_STIPPLE
+ // GL_CULL_FACE
+ // GL_ALPHA_TEST
+ // GL_BLEND
+ // GL_INDEX_LOGIC_OP
+ // GL_COLOR_LOGIC_OP
+ // GL_DITHER
+ // GL_STENCIL_TEST
+ // GL_DEPTH_TEST
+ // GL_CLIP_PLANE0
+ // GL_CLIP_PLANE1
+ // GL_CLIP_PLANE2
+ // GL_CLIP_PLANE3
+ // GL_CLIP_PLANE4
+ // GL_CLIP_PLANE5
+ // GL_LIGHT0
+ // GL_LIGHT1
+ // GL_LIGHT2
+ // GL_LIGHT3
+ // GL_LIGHT4
+ // GL_LIGHT5
+ // GL_LIGHT6
+ // GL_LIGHT7
+ // GL_TEXTURE_GEN_S
+ // GL_TEXTURE_GEN_T
+ // GL_TEXTURE_GEN_R
+ // GL_TEXTURE_GEN_Q
+ // GL_MAP1_VERTEX_3
+ // GL_MAP1_VERTEX_4
+ // GL_MAP1_COLOR_4
+ // GL_MAP1_INDEX
+ // GL_MAP1_NORMAL
+ // GL_MAP1_TEXTURE_COORD_1
+ // GL_MAP1_TEXTURE_COORD_2
+ // GL_MAP1_TEXTURE_COORD_3
+ // GL_MAP1_TEXTURE_COORD_4
+ // GL_MAP2_VERTEX_3
+ // GL_MAP2_VERTEX_4
+ // GL_MAP2_COLOR_4
+ // GL_MAP2_INDEX
+ // GL_MAP2_NORMAL
+ // GL_MAP2_TEXTURE_COORD_1
+ // GL_MAP2_TEXTURE_COORD_2
+ // GL_MAP2_TEXTURE_COORD_3
+ // GL_MAP2_TEXTURE_COORD_4
+ // GL_POINT_SMOOTH
+ // GL_LINE_SMOOTH
+ // GL_POLYGON_SMOOTH
+ // GL_SCISSOR_TEST
+ // GL_COLOR_MATERIAL
+ // GL_NORMALIZE
+ // GL_AUTO_NORMAL
+ // GL_VERTEX_ARRAY
+ // GL_NORMAL_ARRAY
+ // GL_COLOR_ARRAY
+ // GL_INDEX_ARRAY
+ // GL_TEXTURE_COORD_ARRAY
+ // GL_EDGE_FLAG_ARRAY
+ // GL_POLYGON_OFFSET_POINT
+ // GL_POLYGON_OFFSET_LINE
+ // GL_POLYGON_OFFSET_FILL
+
+ // ErrorCode
+ GL_NO_ERROR = 0;
+ GL_INVALID_ENUM = $0500;
+ GL_INVALID_VALUE = $0501;
+ GL_INVALID_OPERATION = $0502;
+ GL_STACK_OVERFLOW = $0503;
+ GL_STACK_UNDERFLOW = $0504;
+ GL_OUT_OF_MEMORY = $0505;
+
+ // FeedBackMode
+ GL_2D = $0600;
+ GL_3D = $0601;
+ GL_3D_COLOR = $0602;
+ GL_3D_COLOR_TEXTURE = $0603;
+ GL_4D_COLOR_TEXTURE = $0604;
+
+ // FeedBackToken
+ GL_PASS_THROUGH_TOKEN = $0700;
+ GL_POINT_TOKEN = $0701;
+ GL_LINE_TOKEN = $0702;
+ GL_POLYGON_TOKEN = $0703;
+ GL_BITMAP_TOKEN = $0704;
+ GL_DRAW_PIXEL_TOKEN = $0705;
+ GL_COPY_PIXEL_TOKEN = $0706;
+ GL_LINE_RESET_TOKEN = $0707;
+
+ // FogMode
+ // GL_LINEAR
+ GL_EXP = $0800;
+ GL_EXP2 = $0801;
+
+ // FogParameter
+ // GL_FOG_COLOR
+ // GL_FOG_DENSITY
+ // GL_FOG_END
+ // GL_FOG_INDEX
+ // GL_FOG_MODE
+ // GL_FOG_START
+
+ // FrontFaceDirection
+ GL_CW = $0900;
+ GL_CCW = $0901;
+
+ // GetMapTarget
+ GL_COEFF = $0A00;
+ GL_ORDER = $0A01;
+ GL_DOMAIN = $0A02;
+
+ // GetPixelMap
+ // GL_PIXEL_MAP_I_TO_I
+ // GL_PIXEL_MAP_S_TO_S
+ // GL_PIXEL_MAP_I_TO_R
+ // GL_PIXEL_MAP_I_TO_G
+ // GL_PIXEL_MAP_I_TO_B
+ // GL_PIXEL_MAP_I_TO_A
+ // GL_PIXEL_MAP_R_TO_R
+ // GL_PIXEL_MAP_G_TO_G
+ // GL_PIXEL_MAP_B_TO_B
+ // GL_PIXEL_MAP_A_TO_A
+
+ // GetPointerTarget
+ // GL_VERTEX_ARRAY_POINTER
+ // GL_NORMAL_ARRAY_POINTER
+ // GL_COLOR_ARRAY_POINTER
+ // GL_INDEX_ARRAY_POINTER
+ // GL_TEXTURE_COORD_ARRAY_POINTER
+ // GL_EDGE_FLAG_ARRAY_POINTER
+
+ // GetTarget
+ GL_CURRENT_COLOR = $0B00;
+ GL_CURRENT_INDEX = $0B01;
+ GL_CURRENT_NORMAL = $0B02;
+ GL_CURRENT_TEXTURE_COORDS = $0B03;
+ GL_CURRENT_RASTER_COLOR = $0B04;
+ GL_CURRENT_RASTER_INDEX = $0B05;
+ GL_CURRENT_RASTER_TEXTURE_COORDS = $0B06;
+ GL_CURRENT_RASTER_POSITION = $0B07;
+ GL_CURRENT_RASTER_POSITION_VALID = $0B08;
+ GL_CURRENT_RASTER_DISTANCE = $0B09;
+ GL_POINT_SMOOTH = $0B10;
+ GL_POINT_SIZE = $0B11;
+ GL_POINT_SIZE_RANGE = $0B12;
+ GL_POINT_SIZE_GRANULARITY = $0B13;
+ GL_LINE_SMOOTH = $0B20;
+ GL_LINE_WIDTH = $0B21;
+ GL_LINE_WIDTH_RANGE = $0B22;
+ GL_LINE_WIDTH_GRANULARITY = $0B23;
+ GL_LINE_STIPPLE = $0B24;
+ GL_LINE_STIPPLE_PATTERN = $0B25;
+ GL_LINE_STIPPLE_REPEAT = $0B26;
+ GL_LIST_MODE = $0B30;
+ GL_MAX_LIST_NESTING = $0B31;
+ GL_LIST_BASE = $0B32;
+ GL_LIST_INDEX = $0B33;
+ GL_POLYGON_MODE = $0B40;
+ GL_POLYGON_SMOOTH = $0B41;
+ GL_POLYGON_STIPPLE = $0B42;
+ GL_EDGE_FLAG = $0B43;
+ GL_CULL_FACE = $0B44;
+ GL_CULL_FACE_MODE = $0B45;
+ GL_FRONT_FACE = $0B46;
+ GL_LIGHTING = $0B50;
+ GL_LIGHT_MODEL_LOCAL_VIEWER = $0B51;
+ GL_LIGHT_MODEL_TWO_SIDE = $0B52;
+ GL_LIGHT_MODEL_AMBIENT = $0B53;
+ GL_SHADE_MODEL = $0B54;
+ GL_COLOR_MATERIAL_FACE = $0B55;
+ GL_COLOR_MATERIAL_PARAMETER = $0B56;
+ GL_COLOR_MATERIAL = $0B57;
+ GL_FOG = $0B60;
+ GL_FOG_INDEX = $0B61;
+ GL_FOG_DENSITY = $0B62;
+ GL_FOG_START = $0B63;
+ GL_FOG_END = $0B64;
+ GL_FOG_MODE = $0B65;
+ GL_FOG_COLOR = $0B66;
+ GL_DEPTH_RANGE = $0B70;
+ GL_DEPTH_TEST = $0B71;
+ GL_DEPTH_WRITEMASK = $0B72;
+ GL_DEPTH_CLEAR_VALUE = $0B73;
+ GL_DEPTH_FUNC = $0B74;
+ GL_ACCUM_CLEAR_VALUE = $0B80;
+ GL_STENCIL_TEST = $0B90;
+ GL_STENCIL_CLEAR_VALUE = $0B91;
+ GL_STENCIL_FUNC = $0B92;
+ GL_STENCIL_VALUE_MASK = $0B93;
+ GL_STENCIL_FAIL = $0B94;
+ GL_STENCIL_PASS_DEPTH_FAIL = $0B95;
+ GL_STENCIL_PASS_DEPTH_PASS = $0B96;
+ GL_STENCIL_REF = $0B97;
+ GL_STENCIL_WRITEMASK = $0B98;
+ GL_MATRIX_MODE = $0BA0;
+ GL_NORMALIZE = $0BA1;
+ GL_VIEWPORT = $0BA2;
+ GL_MODELVIEW_STACK_DEPTH = $0BA3;
+ GL_PROJECTION_STACK_DEPTH = $0BA4;
+ GL_TEXTURE_STACK_DEPTH = $0BA5;
+ GL_MODELVIEW_MATRIX = $0BA6;
+ GL_PROJECTION_MATRIX = $0BA7;
+ GL_TEXTURE_MATRIX = $0BA8;
+ GL_ATTRIB_STACK_DEPTH = $0BB0;
+ GL_CLIENT_ATTRIB_STACK_DEPTH = $0BB1;
+ GL_ALPHA_TEST = $0BC0;
+ GL_ALPHA_TEST_FUNC = $0BC1;
+ GL_ALPHA_TEST_REF = $0BC2;
+ GL_DITHER = $0BD0;
+ GL_BLEND_DST = $0BE0;
+ GL_BLEND_SRC = $0BE1;
+ GL_BLEND = $0BE2;
+ GL_LOGIC_OP_MODE = $0BF0;
+ GL_INDEX_LOGIC_OP = $0BF1;
+ GL_COLOR_LOGIC_OP = $0BF2;
+ GL_AUX_BUFFERS = $0C00;
+ GL_DRAW_BUFFER = $0C01;
+ GL_READ_BUFFER = $0C02;
+ GL_SCISSOR_BOX = $0C10;
+ GL_SCISSOR_TEST = $0C11;
+ GL_INDEX_CLEAR_VALUE = $0C20;
+ GL_INDEX_WRITEMASK = $0C21;
+ GL_COLOR_CLEAR_VALUE = $0C22;
+ GL_COLOR_WRITEMASK = $0C23;
+ GL_INDEX_MODE = $0C30;
+ GL_RGBA_MODE = $0C31;
+ GL_DOUBLEBUFFER = $0C32;
+ GL_STEREO = $0C33;
+ GL_RENDER_MODE = $0C40;
+ GL_PERSPECTIVE_CORRECTION_HINT = $0C50;
+ GL_POINT_SMOOTH_HINT = $0C51;
+ GL_LINE_SMOOTH_HINT = $0C52;
+ GL_POLYGON_SMOOTH_HINT = $0C53;
+ GL_FOG_HINT = $0C54;
+ GL_TEXTURE_GEN_S = $0C60;
+ GL_TEXTURE_GEN_T = $0C61;
+ GL_TEXTURE_GEN_R = $0C62;
+ GL_TEXTURE_GEN_Q = $0C63;
+ GL_PIXEL_MAP_I_TO_I = $0C70;
+ GL_PIXEL_MAP_S_TO_S = $0C71;
+ GL_PIXEL_MAP_I_TO_R = $0C72;
+ GL_PIXEL_MAP_I_TO_G = $0C73;
+ GL_PIXEL_MAP_I_TO_B = $0C74;
+ GL_PIXEL_MAP_I_TO_A = $0C75;
+ GL_PIXEL_MAP_R_TO_R = $0C76;
+ GL_PIXEL_MAP_G_TO_G = $0C77;
+ GL_PIXEL_MAP_B_TO_B = $0C78;
+ GL_PIXEL_MAP_A_TO_A = $0C79;
+ GL_PIXEL_MAP_I_TO_I_SIZE = $0CB0;
+ GL_PIXEL_MAP_S_TO_S_SIZE = $0CB1;
+ GL_PIXEL_MAP_I_TO_R_SIZE = $0CB2;
+ GL_PIXEL_MAP_I_TO_G_SIZE = $0CB3;
+ GL_PIXEL_MAP_I_TO_B_SIZE = $0CB4;
+ GL_PIXEL_MAP_I_TO_A_SIZE = $0CB5;
+ GL_PIXEL_MAP_R_TO_R_SIZE = $0CB6;
+ GL_PIXEL_MAP_G_TO_G_SIZE = $0CB7;
+ GL_PIXEL_MAP_B_TO_B_SIZE = $0CB8;
+ GL_PIXEL_MAP_A_TO_A_SIZE = $0CB9;
+ GL_UNPACK_SWAP_BYTES = $0CF0;
+ GL_UNPACK_LSB_FIRST = $0CF1;
+ GL_UNPACK_ROW_LENGTH = $0CF2;
+ GL_UNPACK_SKIP_ROWS = $0CF3;
+ GL_UNPACK_SKIP_PIXELS = $0CF4;
+ GL_UNPACK_ALIGNMENT = $0CF5;
+ GL_PACK_SWAP_BYTES = $0D00;
+ GL_PACK_LSB_FIRST = $0D01;
+ GL_PACK_ROW_LENGTH = $0D02;
+ GL_PACK_SKIP_ROWS = $0D03;
+ GL_PACK_SKIP_PIXELS = $0D04;
+ GL_PACK_ALIGNMENT = $0D05;
+ GL_MAP_COLOR = $0D10;
+ GL_MAP_STENCIL = $0D11;
+ GL_INDEX_SHIFT = $0D12;
+ GL_INDEX_OFFSET = $0D13;
+ GL_RED_SCALE = $0D14;
+ GL_RED_BIAS = $0D15;
+ GL_ZOOM_X = $0D16;
+ GL_ZOOM_Y = $0D17;
+ GL_GREEN_SCALE = $0D18;
+ GL_GREEN_BIAS = $0D19;
+ GL_BLUE_SCALE = $0D1A;
+ GL_BLUE_BIAS = $0D1B;
+ GL_ALPHA_SCALE = $0D1C;
+ GL_ALPHA_BIAS = $0D1D;
+ GL_DEPTH_SCALE = $0D1E;
+ GL_DEPTH_BIAS = $0D1F;
+ GL_MAX_EVAL_ORDER = $0D30;
+ GL_MAX_LIGHTS = $0D31;
+ GL_MAX_CLIP_PLANES = $0D32;
+ GL_MAX_TEXTURE_SIZE = $0D33;
+ GL_MAX_PIXEL_MAP_TABLE = $0D34;
+ GL_MAX_ATTRIB_STACK_DEPTH = $0D35;
+ GL_MAX_MODELVIEW_STACK_DEPTH = $0D36;
+ GL_MAX_NAME_STACK_DEPTH = $0D37;
+ GL_MAX_PROJECTION_STACK_DEPTH = $0D38;
+ GL_MAX_TEXTURE_STACK_DEPTH = $0D39;
+ GL_MAX_VIEWPORT_DIMS = $0D3A;
+ GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = $0D3B;
+ GL_SUBPIXEL_BITS = $0D50;
+ GL_INDEX_BITS = $0D51;
+ GL_RED_BITS = $0D52;
+ GL_GREEN_BITS = $0D53;
+ GL_BLUE_BITS = $0D54;
+ GL_ALPHA_BITS = $0D55;
+ GL_DEPTH_BITS = $0D56;
+ GL_STENCIL_BITS = $0D57;
+ GL_ACCUM_RED_BITS = $0D58;
+ GL_ACCUM_GREEN_BITS = $0D59;
+ GL_ACCUM_BLUE_BITS = $0D5A;
+ GL_ACCUM_ALPHA_BITS = $0D5B;
+ GL_NAME_STACK_DEPTH = $0D70;
+ GL_AUTO_NORMAL = $0D80;
+ GL_MAP1_COLOR_4 = $0D90;
+ GL_MAP1_INDEX = $0D91;
+ GL_MAP1_NORMAL = $0D92;
+ GL_MAP1_TEXTURE_COORD_1 = $0D93;
+ GL_MAP1_TEXTURE_COORD_2 = $0D94;
+ GL_MAP1_TEXTURE_COORD_3 = $0D95;
+ GL_MAP1_TEXTURE_COORD_4 = $0D96;
+ GL_MAP1_VERTEX_3 = $0D97;
+ GL_MAP1_VERTEX_4 = $0D98;
+ GL_MAP2_COLOR_4 = $0DB0;
+ GL_MAP2_INDEX = $0DB1;
+ GL_MAP2_NORMAL = $0DB2;
+ GL_MAP2_TEXTURE_COORD_1 = $0DB3;
+ GL_MAP2_TEXTURE_COORD_2 = $0DB4;
+ GL_MAP2_TEXTURE_COORD_3 = $0DB5;
+ GL_MAP2_TEXTURE_COORD_4 = $0DB6;
+ GL_MAP2_VERTEX_3 = $0DB7;
+ GL_MAP2_VERTEX_4 = $0DB8;
+ GL_MAP1_GRID_DOMAIN = $0DD0;
+ GL_MAP1_GRID_SEGMENTS = $0DD1;
+ GL_MAP2_GRID_DOMAIN = $0DD2;
+ GL_MAP2_GRID_SEGMENTS = $0DD3;
+ GL_TEXTURE_1D = $0DE0;
+ GL_TEXTURE_2D = $0DE1;
+ GL_FEEDBACK_BUFFER_POINTER = $0DF0;
+ GL_FEEDBACK_BUFFER_SIZE = $0DF1;
+ GL_FEEDBACK_BUFFER_TYPE = $0DF2;
+ GL_SELECTION_BUFFER_POINTER = $0DF3;
+ GL_SELECTION_BUFFER_SIZE = $0DF4;
+ // GL_TEXTURE_BINDING_1D
+ // GL_TEXTURE_BINDING_2D
+ // GL_VERTEX_ARRAY
+ // GL_NORMAL_ARRAY
+ // GL_COLOR_ARRAY
+ // GL_INDEX_ARRAY
+ // GL_TEXTURE_COORD_ARRAY
+ // GL_EDGE_FLAG_ARRAY
+ // GL_VERTEX_ARRAY_SIZE
+ // GL_VERTEX_ARRAY_TYPE
+ // GL_VERTEX_ARRAY_STRIDE
+ // GL_NORMAL_ARRAY_TYPE
+ // GL_NORMAL_ARRAY_STRIDE
+ // GL_COLOR_ARRAY_SIZE
+ // GL_COLOR_ARRAY_TYPE
+ // GL_COLOR_ARRAY_STRIDE
+ // GL_INDEX_ARRAY_TYPE
+ // GL_INDEX_ARRAY_STRIDE
+ // GL_TEXTURE_COORD_ARRAY_SIZE
+ // GL_TEXTURE_COORD_ARRAY_TYPE
+ // GL_TEXTURE_COORD_ARRAY_STRIDE
+ // GL_EDGE_FLAG_ARRAY_STRIDE
+ // GL_POLYGON_OFFSET_FACTOR
+ // GL_POLYGON_OFFSET_UNITS
+
+ // GetTextureParameter
+ // GL_TEXTURE_MAG_FILTER
+ // GL_TEXTURE_MIN_FILTER
+ // GL_TEXTURE_WRAP_S
+ // GL_TEXTURE_WRAP_T
+ GL_TEXTURE_WIDTH = $1000;
+ GL_TEXTURE_HEIGHT = $1001;
+ GL_TEXTURE_INTERNAL_FORMAT = $1003;
+ GL_TEXTURE_BORDER_COLOR = $1004;
+ GL_TEXTURE_BORDER = $1005;
+ // GL_TEXTURE_RED_SIZE
+ // GL_TEXTURE_GREEN_SIZE
+ // GL_TEXTURE_BLUE_SIZE
+ // GL_TEXTURE_ALPHA_SIZE
+ // GL_TEXTURE_LUMINANCE_SIZE
+ // GL_TEXTURE_INTENSITY_SIZE
+ // GL_TEXTURE_PRIORITY
+ // GL_TEXTURE_RESIDENT
+
+ // HintMode
+ GL_DONT_CARE = $1100;
+ GL_FASTEST = $1101;
+ GL_NICEST = $1102;
+
+ // HintTarget
+ // GL_PERSPECTIVE_CORRECTION_HINT
+ // GL_POINT_SMOOTH_HINT
+ // GL_LINE_SMOOTH_HINT
+ // GL_POLYGON_SMOOTH_HINT
+ // GL_FOG_HINT
+
+ // IndexPointerType
+ // GL_SHORT
+ // GL_INT
+ // GL_FLOAT
+ // GL_DOUBLE
+
+ // LightModelParameter
+ // GL_LIGHT_MODEL_AMBIENT
+ // GL_LIGHT_MODEL_LOCAL_VIEWER
+ // GL_LIGHT_MODEL_TWO_SIDE
+
+ // LightName
+ GL_LIGHT0 = $4000;
+ GL_LIGHT1 = $4001;
+ GL_LIGHT2 = $4002;
+ GL_LIGHT3 = $4003;
+ GL_LIGHT4 = $4004;
+ GL_LIGHT5 = $4005;
+ GL_LIGHT6 = $4006;
+ GL_LIGHT7 = $4007;
+
+ // LightParameter
+ GL_AMBIENT = $1200;
+ GL_DIFFUSE = $1201;
+ GL_SPECULAR = $1202;
+ GL_POSITION = $1203;
+ GL_SPOT_DIRECTION = $1204;
+ GL_SPOT_EXPONENT = $1205;
+ GL_SPOT_CUTOFF = $1206;
+ GL_CONSTANT_ATTENUATION = $1207;
+ GL_LINEAR_ATTENUATION = $1208;
+ GL_QUADRATIC_ATTENUATION = $1209;
+
+ // InterleavedArrays
+ // GL_V2F
+ // GL_V3F
+ // GL_C4UB_V2F
+ // GL_C4UB_V3F
+ // GL_C3F_V3F
+ // GL_N3F_V3F
+ // GL_C4F_N3F_V3F
+ // GL_T2F_V3F
+ // GL_T4F_V4F
+ // GL_T2F_C4UB_V3F
+ // GL_T2F_C3F_V3F
+ // GL_T2F_N3F_V3F
+ // GL_T2F_C4F_N3F_V3F
+ // GL_T4F_C4F_N3F_V4F
+
+ // ListMode
+ GL_COMPILE = $1300;
+ GL_COMPILE_AND_EXECUTE = $1301;
+
+ // ListNameType
+ // GL_BYTE
+ // GL_UNSIGNED_BYTE
+ // GL_SHORT
+ // GL_UNSIGNED_SHORT
+ // GL_INT
+ // GL_UNSIGNED_INT
+ // GL_FLOAT
+ // GL_2_BYTES
+ // GL_3_BYTES
+ // GL_4_BYTES
+
+ // LogicOp
+ GL_CLEAR = $1500;
+ GL_AND = $1501;
+ GL_AND_REVERSE = $1502;
+ GL_COPY = $1503;
+ GL_AND_INVERTED = $1504;
+ GL_NOOP = $1505;
+ GL_XOR = $1506;
+ GL_OR = $1507;
+ GL_NOR = $1508;
+ GL_EQUIV = $1509;
+ GL_INVERT = $150A;
+ GL_OR_REVERSE = $150B;
+ GL_COPY_INVERTED = $150C;
+ GL_OR_INVERTED = $150D;
+ GL_NAND = $150E;
+ GL_SET = $150F;
+
+ // MapTarget
+ // GL_MAP1_COLOR_4
+ // GL_MAP1_INDEX
+ // GL_MAP1_NORMAL
+ // GL_MAP1_TEXTURE_COORD_1
+ // GL_MAP1_TEXTURE_COORD_2
+ // GL_MAP1_TEXTURE_COORD_3
+ // GL_MAP1_TEXTURE_COORD_4
+ // GL_MAP1_VERTEX_3
+ // GL_MAP1_VERTEX_4
+ // GL_MAP2_COLOR_4
+ // GL_MAP2_INDEX
+ // GL_MAP2_NORMAL
+ // GL_MAP2_TEXTURE_COORD_1
+ // GL_MAP2_TEXTURE_COORD_2
+ // GL_MAP2_TEXTURE_COORD_3
+ // GL_MAP2_TEXTURE_COORD_4
+ // GL_MAP2_VERTEX_3
+ // GL_MAP2_VERTEX_4
+
+ // MaterialFace
+ // GL_FRONT
+ // GL_BACK
+ // GL_FRONT_AND_BACK
+
+ // MaterialParameter
+ GL_EMISSION = $1600;
+ GL_SHININESS = $1601;
+ GL_AMBIENT_AND_DIFFUSE = $1602;
+ GL_COLOR_INDEXES = $1603;
+ // GL_AMBIENT
+ // GL_DIFFUSE
+ // GL_SPECULAR
+
+ // MatrixMode
+ GL_MODELVIEW = $1700;
+ GL_PROJECTION = $1701;
+ GL_TEXTURE = $1702;
+
+ // MeshMode1
+ // GL_POINT
+ // GL_LINE
+
+ // MeshMode2
+ // GL_POINT
+ // GL_LINE
+ // GL_FILL
+
+ // NormalPointerType
+ // GL_BYTE
+ // GL_SHORT
+ // GL_INT
+ // GL_FLOAT
+ // GL_DOUBLE
+
+ // PixelCopyType
+ GL_COLOR = $1800;
+ GL_DEPTH = $1801;
+ GL_STENCIL = $1802;
+
+ // PixelFormat
+ GL_COLOR_INDEX = $1900;
+ GL_STENCIL_INDEX = $1901;
+ GL_DEPTH_COMPONENT = $1902;
+ GL_RED = $1903;
+ GL_GREEN = $1904;
+ GL_BLUE = $1905;
+ GL_ALPHA = $1906;
+ GL_RGB = $1907;
+ GL_RGBA = $1908;
+ GL_LUMINANCE = $1909;
+ GL_LUMINANCE_ALPHA = $190A;
+
+ // PixelMap
+ // GL_PIXEL_MAP_I_TO_I
+ // GL_PIXEL_MAP_S_TO_S
+ // GL_PIXEL_MAP_I_TO_R
+ // GL_PIXEL_MAP_I_TO_G
+ // GL_PIXEL_MAP_I_TO_B
+ // GL_PIXEL_MAP_I_TO_A
+ // GL_PIXEL_MAP_R_TO_R
+ // GL_PIXEL_MAP_G_TO_G
+ // GL_PIXEL_MAP_B_TO_B
+ // GL_PIXEL_MAP_A_TO_A
+
+ // PixelStore
+ // GL_UNPACK_SWAP_BYTES
+ // GL_UNPACK_LSB_FIRST
+ // GL_UNPACK_ROW_LENGTH
+ // GL_UNPACK_SKIP_ROWS
+ // GL_UNPACK_SKIP_PIXELS
+ // GL_UNPACK_ALIGNMENT
+ // GL_PACK_SWAP_BYTES
+ // GL_PACK_LSB_FIRST
+ // GL_PACK_ROW_LENGTH
+ // GL_PACK_SKIP_ROWS
+ // GL_PACK_SKIP_PIXELS
+ // GL_PACK_ALIGNMENT
+
+ // PixelTransfer
+ // GL_MAP_COLOR
+ // GL_MAP_STENCIL
+ // GL_INDEX_SHIFT
+ // GL_INDEX_OFFSET
+ // GL_RED_SCALE
+ // GL_RED_BIAS
+ // GL_GREEN_SCALE
+ // GL_GREEN_BIAS
+ // GL_BLUE_SCALE
+ // GL_BLUE_BIAS
+ // GL_ALPHA_SCALE
+ // GL_ALPHA_BIAS
+ // GL_DEPTH_SCALE
+ // GL_DEPTH_BIAS
+
+ // PixelType
+ GL_BITMAP = $1A00;
+ // GL_BYTE
+ // GL_UNSIGNED_BYTE
+ // GL_SHORT
+ // GL_UNSIGNED_SHORT
+ // GL_INT
+ // GL_UNSIGNED_INT
+ // GL_FLOAT
+
+ // PolygonMode
+ GL_POINT = $1B00;
+ GL_LINE = $1B01;
+ GL_FILL = $1B02;
+
+ // ReadBufferMode
+ // GL_FRONT_LEFT
+ // GL_FRONT_RIGHT
+ // GL_BACK_LEFT
+ // GL_BACK_RIGHT
+ // GL_FRONT
+ // GL_BACK
+ // GL_LEFT
+ // GL_RIGHT
+ // GL_AUX0
+ // GL_AUX1
+ // GL_AUX2
+ // GL_AUX3
+
+ // RenderingMode
+ GL_RENDER = $1C00;
+ GL_FEEDBACK = $1C01;
+ GL_SELECT = $1C02;
+
+ // ShadingModel
+ GL_FLAT = $1D00;
+ GL_SMOOTH = $1D01;
+
+ // StencilFunction
+ // GL_NEVER
+ // GL_LESS
+ // GL_EQUAL
+ // GL_LEQUAL
+ // GL_GREATER
+ // GL_NOTEQUAL
+ // GL_GEQUAL
+ // GL_ALWAYS
+
+ // StencilOp
+ // GL_ZERO
+ GL_KEEP = $1E00;
+ GL_REPLACE = $1E01;
+ GL_INCR = $1E02;
+ GL_DECR = $1E03;
+ // GL_INVERT
+
+ // StringName
+ GL_VENDOR = $1F00;
+ GL_RENDERER = $1F01;
+ GL_VERSION = $1F02;
+ GL_EXTENSIONS = $1F03;
+
+ // TextureCoordName
+ GL_S = $2000;
+ GL_T = $2001;
+ GL_R = $2002;
+ GL_Q = $2003;
+
+ // TexCoordPointerType
+ // GL_SHORT
+ // GL_INT
+ // GL_FLOAT
+ // GL_DOUBLE
+
+ // TextureEnvMode
+ GL_MODULATE = $2100;
+ GL_DECAL = $2101;
+ // GL_BLEND
+ // GL_REPLACE
+
+ // TextureEnvParameter
+ GL_TEXTURE_ENV_MODE = $2200;
+ GL_TEXTURE_ENV_COLOR = $2201;
+
+ // TextureEnvTarget
+ GL_TEXTURE_ENV = $2300;
+
+ // TextureGenMode
+ GL_EYE_LINEAR = $2400;
+ GL_OBJECT_LINEAR = $2401;
+ GL_SPHERE_MAP = $2402;
+
+ // TextureGenParameter
+ GL_TEXTURE_GEN_MODE = $2500;
+ GL_OBJECT_PLANE = $2501;
+ GL_EYE_PLANE = $2502;
+
+ // TextureMagFilter
+ GL_NEAREST = $2600;
+ GL_LINEAR = $2601;
+
+ // TextureMinFilter
+ // GL_NEAREST
+ // GL_LINEAR
+ GL_NEAREST_MIPMAP_NEAREST = $2700;
+ GL_LINEAR_MIPMAP_NEAREST = $2701;
+ GL_NEAREST_MIPMAP_LINEAR = $2702;
+ GL_LINEAR_MIPMAP_LINEAR = $2703;
+
+ // TextureParameterName
+ GL_TEXTURE_MAG_FILTER = $2800;
+ GL_TEXTURE_MIN_FILTER = $2801;
+ GL_TEXTURE_WRAP_S = $2802;
+ GL_TEXTURE_WRAP_T = $2803;
+ // GL_TEXTURE_BORDER_COLOR
+ // GL_TEXTURE_PRIORITY
+
+ // TextureTarget
+ // GL_TEXTURE_1D
+ // GL_TEXTURE_2D
+ // GL_PROXY_TEXTURE_1D
+ // GL_PROXY_TEXTURE_2D
+
+ // TextureWrapMode
+ GL_CLAMP = $2900;
+ GL_REPEAT = $2901;
+
+ // VertexPointerType
+ // GL_SHORT
+ // GL_INT
+ // GL_FLOAT
+ // GL_DOUBLE
+
+ // ClientAttribMask
+ GL_CLIENT_PIXEL_STORE_BIT = $00000001;
+ GL_CLIENT_VERTEX_ARRAY_BIT = $00000002;
+ GL_CLIENT_ALL_ATTRIB_BITS = $FFFFFFFF;
+
+ // polygon_offset
+ GL_POLYGON_OFFSET_FACTOR = $8038;
+ GL_POLYGON_OFFSET_UNITS = $2A00;
+ GL_POLYGON_OFFSET_POINT = $2A01;
+ GL_POLYGON_OFFSET_LINE = $2A02;
+ GL_POLYGON_OFFSET_FILL = $8037;
+
+ // texture
+ GL_ALPHA4 = $803B;
+ GL_ALPHA8 = $803C;
+ GL_ALPHA12 = $803D;
+ GL_ALPHA16 = $803E;
+ GL_LUMINANCE4 = $803F;
+ GL_LUMINANCE8 = $8040;
+ GL_LUMINANCE12 = $8041;
+ GL_LUMINANCE16 = $8042;
+ GL_LUMINANCE4_ALPHA4 = $8043;
+ GL_LUMINANCE6_ALPHA2 = $8044;
+ GL_LUMINANCE8_ALPHA8 = $8045;
+ GL_LUMINANCE12_ALPHA4 = $8046;
+ GL_LUMINANCE12_ALPHA12 = $8047;
+ GL_LUMINANCE16_ALPHA16 = $8048;
+ GL_INTENSITY = $8049;
+ GL_INTENSITY4 = $804A;
+ GL_INTENSITY8 = $804B;
+ GL_INTENSITY12 = $804C;
+ GL_INTENSITY16 = $804D;
+ GL_R3_G3_B2 = $2A10;
+ GL_RGB4 = $804F;
+ GL_RGB5 = $8050;
+ GL_RGB8 = $8051;
+ GL_RGB10 = $8052;
+ GL_RGB12 = $8053;
+ GL_RGB16 = $8054;
+ GL_RGBA2 = $8055;
+ GL_RGBA4 = $8056;
+ GL_RGB5_A1 = $8057;
+ GL_RGBA8 = $8058;
+ GL_RGB10_A2 = $8059;
+ GL_RGBA12 = $805A;
+ GL_RGBA16 = $805B;
+ GL_TEXTURE_RED_SIZE = $805C;
+ GL_TEXTURE_GREEN_SIZE = $805D;
+ GL_TEXTURE_BLUE_SIZE = $805E;
+ GL_TEXTURE_ALPHA_SIZE = $805F;
+ GL_TEXTURE_LUMINANCE_SIZE = $8060;
+ GL_TEXTURE_INTENSITY_SIZE = $8061;
+ GL_PROXY_TEXTURE_1D = $8063;
+ GL_PROXY_TEXTURE_2D = $8064;
+
+ // texture_object
+ GL_TEXTURE_PRIORITY = $8066;
+ GL_TEXTURE_RESIDENT = $8067;
+ GL_TEXTURE_BINDING_1D = $8068;
+ GL_TEXTURE_BINDING_2D = $8069;
+
+ // vertex_array
+ GL_VERTEX_ARRAY = $8074;
+ GL_NORMAL_ARRAY = $8075;
+ GL_COLOR_ARRAY = $8076;
+ GL_INDEX_ARRAY = $8077;
+ GL_TEXTURE_COORD_ARRAY = $8078;
+ GL_EDGE_FLAG_ARRAY = $8079;
+ GL_VERTEX_ARRAY_SIZE = $807A;
+ GL_VERTEX_ARRAY_TYPE = $807B;
+ GL_VERTEX_ARRAY_STRIDE = $807C;
+ GL_NORMAL_ARRAY_TYPE = $807E;
+ GL_NORMAL_ARRAY_STRIDE = $807F;
+ GL_COLOR_ARRAY_SIZE = $8081;
+ GL_COLOR_ARRAY_TYPE = $8082;
+ GL_COLOR_ARRAY_STRIDE = $8083;
+ GL_INDEX_ARRAY_TYPE = $8085;
+ GL_INDEX_ARRAY_STRIDE = $8086;
+ GL_TEXTURE_COORD_ARRAY_SIZE = $8088;
+ GL_TEXTURE_COORD_ARRAY_TYPE = $8089;
+ GL_TEXTURE_COORD_ARRAY_STRIDE = $808A;
+ GL_EDGE_FLAG_ARRAY_STRIDE = $808C;
+ GL_VERTEX_ARRAY_POINTER = $808E;
+ GL_NORMAL_ARRAY_POINTER = $808F;
+ GL_COLOR_ARRAY_POINTER = $8090;
+ GL_INDEX_ARRAY_POINTER = $8091;
+ GL_TEXTURE_COORD_ARRAY_POINTER = $8092;
+ GL_EDGE_FLAG_ARRAY_POINTER = $8093;
+ GL_V2F = $2A20;
+ GL_V3F = $2A21;
+ GL_C4UB_V2F = $2A22;
+ GL_C4UB_V3F = $2A23;
+ GL_C3F_V3F = $2A24;
+ GL_N3F_V3F = $2A25;
+ GL_C4F_N3F_V3F = $2A26;
+ GL_T2F_V3F = $2A27;
+ GL_T4F_V4F = $2A28;
+ GL_T2F_C4UB_V3F = $2A29;
+ GL_T2F_C3F_V3F = $2A2A;
+ GL_T2F_N3F_V3F = $2A2B;
+ GL_T2F_C4F_N3F_V3F = $2A2C;
+ GL_T4F_C4F_N3F_V4F = $2A2D;
+
+ // Extensions
+ GL_EXT_vertex_array = 1;
+ GL_WIN_swap_hint = 1;
+ GL_EXT_bgra = 1;
+ GL_EXT_paletted_texture = 1;
+
+ // EXT_vertex_array
+ GL_VERTEX_ARRAY_EXT = $8074;
+ GL_NORMAL_ARRAY_EXT = $8075;
+ GL_COLOR_ARRAY_EXT = $8076;
+ GL_INDEX_ARRAY_EXT = $8077;
+ GL_TEXTURE_COORD_ARRAY_EXT = $8078;
+ GL_EDGE_FLAG_ARRAY_EXT = $8079;
+ GL_VERTEX_ARRAY_SIZE_EXT = $807A;
+ GL_VERTEX_ARRAY_TYPE_EXT = $807B;
+ GL_VERTEX_ARRAY_STRIDE_EXT = $807C;
+ GL_VERTEX_ARRAY_COUNT_EXT = $807D;
+ GL_NORMAL_ARRAY_TYPE_EXT = $807E;
+ GL_NORMAL_ARRAY_STRIDE_EXT = $807F;
+ GL_NORMAL_ARRAY_COUNT_EXT = $8080;
+ GL_COLOR_ARRAY_SIZE_EXT = $8081;
+ GL_COLOR_ARRAY_TYPE_EXT = $8082;
+ GL_COLOR_ARRAY_STRIDE_EXT = $8083;
+ GL_COLOR_ARRAY_COUNT_EXT = $8084;
+ GL_INDEX_ARRAY_TYPE_EXT = $8085;
+ GL_INDEX_ARRAY_STRIDE_EXT = $8086;
+ GL_INDEX_ARRAY_COUNT_EXT = $8087;
+ GL_TEXTURE_COORD_ARRAY_SIZE_EXT = $8088;
+ GL_TEXTURE_COORD_ARRAY_TYPE_EXT = $8089;
+ GL_TEXTURE_COORD_ARRAY_STRIDE_EXT = $808A;
+ GL_TEXTURE_COORD_ARRAY_COUNT_EXT = $808B;
+ GL_EDGE_FLAG_ARRAY_STRIDE_EXT = $808C;
+ GL_EDGE_FLAG_ARRAY_COUNT_EXT = $808D;
+ GL_VERTEX_ARRAY_POINTER_EXT = $808E;
+ GL_NORMAL_ARRAY_POINTER_EXT = $808F;
+ GL_COLOR_ARRAY_POINTER_EXT = $8090;
+ GL_INDEX_ARRAY_POINTER_EXT = $8091;
+ GL_TEXTURE_COORD_ARRAY_POINTER_EXT = $8092;
+ GL_EDGE_FLAG_ARRAY_POINTER_EXT = $8093;
+ GL_DOUBLE_EXT = GL_DOUBLE;
+
+ // EXT_bgra
+ GL_BGR_EXT = $80E0;
+ GL_BGRA_EXT = $80E1;
+
+ // EXT_paletted_texture
+
+ // These must match the GL_COLOR_TABLE_*_SGI enumerants
+ GL_COLOR_TABLE_FORMAT_EXT = $80D8;
+ GL_COLOR_TABLE_WIDTH_EXT = $80D9;
+ GL_COLOR_TABLE_RED_SIZE_EXT = $80DA;
+ GL_COLOR_TABLE_GREEN_SIZE_EXT = $80DB;
+ GL_COLOR_TABLE_BLUE_SIZE_EXT = $80DC;
+ GL_COLOR_TABLE_ALPHA_SIZE_EXT = $80DD;
+ GL_COLOR_TABLE_LUMINANCE_SIZE_EXT = $80DE;
+ GL_COLOR_TABLE_INTENSITY_SIZE_EXT = $80DF;
+
+ GL_COLOR_INDEX1_EXT = $80E2;
+ GL_COLOR_INDEX2_EXT = $80E3;
+ GL_COLOR_INDEX4_EXT = $80E4;
+ GL_COLOR_INDEX8_EXT = $80E5;
+ GL_COLOR_INDEX12_EXT = $80E6;
+ GL_COLOR_INDEX16_EXT = $80E7;
+
+ // For compatibility with OpenGL v1.0
+ GL_LOGIC_OP = GL_INDEX_LOGIC_OP;
+ GL_TEXTURE_COMPONENTS = GL_TEXTURE_INTERNAL_FORMAT;
+
+{******************************************************************************}
+
+var
+ glAccum: procedure(op: GLenum; value: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glAlphaFunc: procedure(func: GLenum; ref: GLclampf); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glAreTexturesResident: function (n: GLsizei; const textures: PGLuint; residences: PGLboolean): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glArrayElement: procedure(i: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBegin: procedure(mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindTexture: procedure(target: GLenum; texture: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBitmap: procedure (width, height: GLsizei; xorig, yorig: GLfloat; xmove, ymove: GLfloat; const bitmap: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBlendFunc: procedure(sfactor, dfactor: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCallList: procedure(list: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCallLists: procedure(n: GLsizei; atype: GLenum; const lists: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glClear: procedure(mask: GLbitfield); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glClearAccum: procedure(red, green, blue, alpha: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glClearColor: procedure(red, green, blue, alpha: GLclampf); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glClearDepth: procedure(depth: GLclampd); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glClearIndex: procedure(c: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glClearStencil: procedure(s: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glClipPlane: procedure(plane: GLenum; const equation: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3b: procedure(red, green, blue: GLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3bv: procedure(const v: PGLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3d: procedure(red, green, blue: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3f: procedure(red, green, blue: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3i: procedure(red, green, blue: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3s: procedure(red, green, blue: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3ub: procedure(red, green, blue: GLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3ubv: procedure(const v: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3ui: procedure(red, green, blue: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3uiv: procedure(const v: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3us: procedure(red, green, blue: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3usv: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4b: procedure(red, green, blue, alpha: GLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4bv: procedure(const v: PGLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4d: procedure(red, green, blue, alpha: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4f: procedure(red, green, blue, alpha: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4i: procedure(red, green, blue, alpha: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4s: procedure(red, green, blue, alpha: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4ub: procedure(red, green, blue, alpha: GLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4ubv: procedure(const v: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4ui: procedure(red, green, blue, alpha: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4uiv: procedure(const v: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4us: procedure(red, green, blue, alpha: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4usv: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColorMask: procedure(red, green, blue, alpha: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColorMaterial: procedure(face, mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColorPointer: procedure(size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyPixels: procedure(x, y: GLint; width, height: GLsizei; atype: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyTexImage1D: procedure (target: GLenum; level: GLint; internalFormat: GLenum; x, y: GLint; width: GLsizei; border: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyTexImage2D: procedure(target: GLenum; level: GLint; internalFormat: GLenum; x, y: GLint; width, height: GLsizei; border: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyTexSubImage1D: procedure(target: GLenum; level, xoffset, x, y: GLint; width: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyTexSubImage2D: procedure(target: GLenum; level, xoffset, yoffset, x, y: GLint; width, height: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCullFace: procedure(mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteLists: procedure(list: GLuint; range: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteTextures: procedure(n: GLsizei; const textures: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDepthFunc: procedure(func: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDepthMask: procedure(flag: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDepthRange: procedure(zNear, zFar: GLclampd); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDisable: procedure(cap: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDisableClientState: procedure(aarray: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDrawArrays: procedure(mode: GLenum; first: GLint; count: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDrawBuffer: procedure(mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDrawElements: procedure(mode: GLenum; count: GLsizei; atype: GLenum; const indices: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDrawPixels: procedure(width, height: GLsizei; format, atype: GLenum; const pixels: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEdgeFlag: procedure(flag: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEdgeFlagPointer: procedure(stride: GLsizei; const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEdgeFlagv: procedure(const flag: PGLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEnable: procedure(cap: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEnableClientState: procedure(aarray: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEnd: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEndList: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalCoord1d: procedure(u: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalCoord1dv: procedure(const u: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalCoord1f: procedure(u: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalCoord1fv: procedure(const u: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalCoord2d: procedure(u, v: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalCoord2dv: procedure(const u: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalCoord2f: procedure(u, v: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalCoord2fv: procedure(const u: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalMesh1: procedure(mode: GLenum; i1, i2: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalMesh2: procedure(mode: GLenum; i1, i2, j1, j2: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalPoint1: procedure(i: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalPoint2: procedure(i, j: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFeedbackBuffer: procedure(size: GLsizei; atype: GLenum; buffer: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFinish: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFlush: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogf: procedure(pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogfv: procedure(pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogi: procedure(pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogiv: procedure(pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFrontFace: procedure(mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFrustum: procedure(left, right, bottom, top, zNear, zFar: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGenLists: function(range: GLsizei): GLuint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGenTextures: procedure(n: GLsizei; textures: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetBooleanv: procedure(pname: GLenum; params: PGLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetClipPlane: procedure(plane: GLenum; equation: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetDoublev: procedure(pname: GLenum; params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetError: function: GLenum; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetFloatv: procedure(pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetIntegerv: procedure(pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetLightfv: procedure(light, pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetLightiv: procedure(light, pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMapdv: procedure(target, query: GLenum; v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMapfv: procedure(target, query: GLenum; v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMapiv: procedure(target, query: GLenum; v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMaterialfv: procedure(face, pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMaterialiv: procedure(face, pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetPixelMapfv: procedure(map: GLenum; values: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetPixelMapuiv: procedure(map: GLenum; values: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetPixelMapusv: procedure(map: GLenum; values: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetPointerv: procedure(pname: GLenum; params: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetPolygonStipple: procedure(mask: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetString: function(name: GLenum): PChar; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTexEnvfv: procedure(target, pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTexEnviv: procedure(target, pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTexGendv: procedure(coord, pname: GLenum; params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTexGenfv: procedure(coord, pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTexGeniv: procedure(coord, pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTexImage: procedure(target: GLenum; level: GLint; format: GLenum; atype: GLenum; pixels: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTexLevelParameterfv: procedure(target: GLenum; level: GLint; pname: GLenum; params: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTexLevelParameteriv: procedure(target: GLenum; level: GLint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTexParameterfv: procedure(target, pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTexParameteriv: procedure(target, pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glHint: procedure(target, mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexMask: procedure(mask: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexPointer: procedure(atype: GLenum; stride: GLsizei; const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexd: procedure(c: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexdv: procedure(const c: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexf: procedure(c: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexfv: procedure(const c: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexi: procedure(c: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexiv: procedure(const c: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexs: procedure(c: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexsv: procedure(const c: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexub: procedure(c: GLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexubv: procedure(const c: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glInitNames: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glInterleavedArrays: procedure(format: GLenum; stride: GLsizei; const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsEnabled: function(cap: GLenum): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsList: function(list: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsTexture: function(texture: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLightModelf: procedure(pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLightModelfv: procedure(pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLightModeli: procedure(pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLightModeliv: procedure(pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLightf: procedure(light, pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLightfv: procedure(light, pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLighti: procedure(light, pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLightiv: procedure(light, pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLineStipple: procedure(factor: GLint; pattern: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLineWidth: procedure(width: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glListBase: procedure(base: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLoadIdentity: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLoadMatrixd: procedure(const m: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLoadMatrixf: procedure(const m: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLoadName: procedure(name: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLogicOp: procedure(opcode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMap1d: procedure(target: GLenum; u1, u2: GLdouble; stride, order: GLint; const points: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMap1f: procedure(target: GLenum; u1, u2: GLfloat; stride, order: GLint; const points: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMap2d: procedure(target: GLenum; u1, u2: GLdouble; ustride, uorder: GLint; v1, v2: GLdouble; vstride, vorder: GLint; const points: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMap2f: procedure(target: GLenum; u1, u2: GLfloat; ustride, uorder: GLint; v1, v2: GLfloat; vstride, vorder: GLint; const points: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMapGrid1d: procedure(un: GLint; u1, u2: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMapGrid1f: procedure(un: GLint; u1, u2: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMapGrid2d: procedure(un: GLint; u1, u2: GLdouble; vn: GLint; v1, v2: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMapGrid2f: procedure(un: GLint; u1, u2: GLfloat; vn: GLint; v1, v2: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMaterialf: procedure(face, pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMaterialfv: procedure(face, pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMateriali: procedure(face, pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMaterialiv: procedure(face, pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMatrixMode: procedure(mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultMatrixd: procedure(const m: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultMatrixf: procedure(const m: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNewList: procedure(list: GLuint; mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3b: procedure(nx, ny, nz: GLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3bv: procedure(const v: PGLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3d: procedure(nx, ny, nz: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3f: procedure(nx, ny, nz: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3i: procedure(nx, ny, nz: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3s: procedure(nx, ny, nz: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalPointer: procedure(atype: GLenum; stride: GLsizei; const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glOrtho: procedure(left, right, bottom, top, zNear, zFar: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPassThrough: procedure(token: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPixelMapfv: procedure(map: GLenum; mapsize: GLsizei; const values: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPixelMapuiv: procedure(map: GLenum; mapsize: GLsizei; const values: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPixelMapusv: procedure(map: GLenum; mapsize: GLsizei; const values: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPixelStoref: procedure(pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPixelStorei: procedure(pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPixelTransferf: procedure(pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPixelTransferi: procedure(pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPixelZoom: procedure(xfactor, yfactor: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPointSize: procedure(size: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPolygonMode: procedure(face, mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPolygonOffset: procedure(factor, units: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPolygonStipple: procedure(const mask: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPopAttrib: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPopClientAttrib: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPopMatrix: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPopName: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPrioritizeTextures: procedure(n: GLsizei; const textures: PGLuint; const priorities: PGLclampf); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPushAttrib: procedure(mask: GLbitfield); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPushClientAttrib: procedure(mask: GLbitfield); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPushMatrix: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPushName: procedure(name: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos2d: procedure(x, y: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos2dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos2f: procedure(x, y: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos2fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos2i: procedure(x, y: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos2iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos2s: procedure(x, y: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos2sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos3d: procedure(x, y, z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos3dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos3f: procedure(x, y, z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos3fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos3i: procedure(x, y, z: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos3iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos3s: procedure(x, y, z: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos3sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos4d: procedure(x, y, z, w: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos4dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos4f: procedure(x, y, z, w: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos4fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos4i: procedure(x, y, z, w: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos4iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos4s: procedure(x, y, z, w: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRasterPos4sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReadBuffer: procedure(mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReadPixels: procedure(x, y: GLint; width, height: GLsizei; format, atype: GLenum; pixels: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRectd: procedure(x1, y1, x2, y2: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRectdv: procedure(const v1: PGLdouble; const v2: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRectf: procedure(x1, y1, x2, y2: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRectfv: procedure(const v1: PGLfloat; const v2: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRecti: procedure(x1, y1, x2, y2: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRectiv: procedure(const v1: PGLint; const v2: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRects: procedure(x1, y1, x2, y2: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRectsv: procedure(const v1: PGLshort; const v2: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRenderMode: function(mode: GLint): GLint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRotated: procedure(angle, x, y, z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRotatef: procedure(angle, x, y, z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glScaled: procedure(x, y, z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glScalef: procedure(x, y, z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glScissor: procedure(x, y: GLint; width, height: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSelectBuffer: procedure(size: GLsizei; buffer: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glShadeModel: procedure(mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glStencilFunc: procedure(func: GLenum; ref: GLint; mask: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glStencilMask: procedure(mask: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glStencilOp: procedure(fail, zfail, zpass: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord1d: procedure(s: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord1dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord1f: procedure(s: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord1fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord1i: procedure(s: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord1iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord1s: procedure(s: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord1sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2d: procedure(s, t: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2f: procedure(s, t: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2i: procedure(s, t: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2s: procedure(s, t: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord3d: procedure(s, t, r: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord3dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord3f: procedure(s, t, r: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord3fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord3i: procedure(s, t, r: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord3iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord3s: procedure(s, t, r: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord3sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4d: procedure(s, t, r, q: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4f: procedure(s, t, r, q: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4i: procedure(s, t, r, q: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4s: procedure(s, t, r, q: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoordPointer: procedure(size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexEnvf: procedure(target: GLenum; pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexEnvfv: procedure(target: GLenum; pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexEnvi: procedure(target: GLenum; pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexEnviv: procedure(target: GLenum; pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexGend: procedure(coord: GLenum; pname: GLenum; param: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexGendv: procedure(coord: GLenum; pname: GLenum; const params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexGenf: procedure(coord: GLenum; pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexGenfv: procedure(coord: GLenum; pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexGeni: procedure(coord: GLenum; pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexGeniv: procedure(coord: GLenum; pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexImage1D: procedure(target: GLenum; level, internalformat: GLint; width: GLsizei; border: GLint; format, atype: GLenum; const pixels: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexImage2D: procedure(target: GLenum; level, internalformat: GLint; width, height: GLsizei; border: GLint; format, atype: GLenum; const pixels: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexParameterf: procedure(target: GLenum; pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexParameterfv: procedure(target: GLenum; pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexParameteri: procedure(target: GLenum; pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexParameteriv: procedure(target: GLenum; pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexSubImage1D: procedure(target: GLenum; level, xoffset: GLint; width: GLsizei; format, atype: GLenum; const pixels: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexSubImage2D: procedure(target: GLenum; level, xoffset, yoffset: GLint; width, height: GLsizei; format, atype: GLenum; const pixels: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTranslated: procedure(x, y, z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTranslatef: procedure(x, y, z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex2d: procedure(x, y: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex2dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex2f: procedure(x, y: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex2fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex2i: procedure(x, y: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex2iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex2s: procedure(x, y: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex2sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex3d: procedure(x, y, z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex3dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex3f: procedure(x, y, z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex3fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex3i: procedure(x, y, z: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex3iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex3s: procedure(x, y, z: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex3sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex4d: procedure(x, y, z, w: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex4dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex4f: procedure(x, y, z, w: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex4fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex4i: procedure(x, y, z, w: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex4iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex4s: procedure(x, y, z, w: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex4sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexPointer: procedure(size: GLint; atype: GLenum; stride: GLsizei; const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glViewport: procedure(x, y: GLint; width, height: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ {$IFDEF WINDOWS}
+ ChoosePixelFormat: function(DC: HDC; p2: PPixelFormatDescriptor): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ {$ENDIF}
+
+type
+ // EXT_vertex_array
+ PFNGLARRAYELEMENTEXTPROC = procedure(i: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLDRAWARRAYSEXTPROC = procedure(mode: GLenum; first: GLint; count: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLVERTEXPOINTEREXTPROC = procedure(size: GLint; atype: GLenum;
+ stride, count: GLsizei; const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLNORMALPOINTEREXTPROC = procedure(atype: GLenum; stride, count: GLsizei;
+ const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLCOLORPOINTEREXTPROC = procedure(size: GLint; atype: GLenum; stride, count: GLsizei;
+ const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLINDEXPOINTEREXTPROC = procedure(atype: GLenum; stride, count: GLsizei;
+ const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLTEXCOORDPOINTEREXTPROC = procedure(size: GLint; atype: GLenum;
+ stride, count: GLsizei; const pointer: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLEDGEFLAGPOINTEREXTPROC = procedure(stride, count: GLsizei;
+ const pointer: PGLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLGETPOINTERVEXTPROC = procedure(pname: GLenum; params: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLARRAYELEMENTARRAYEXTPROC = procedure(mode: GLenum; count: GLsizei;
+ const pi: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+ // WIN_swap_hint
+ PFNGLADDSWAPHINTRECTWINPROC = procedure(x, y: GLint; width, height: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+ // EXT_paletted_texture
+ PFNGLCOLORTABLEEXTPROC = procedure(target, internalFormat: GLenum; width: GLsizei;
+ format, atype: GLenum; const data: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLCOLORSUBTABLEEXTPROC = procedure(target: GLenum; start, count: GLsizei;
+ format, atype: GLenum; const data: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLGETCOLORTABLEEXTPROC = procedure(target, format, atype: GLenum; data: Pointer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLGETCOLORTABLEPARAMETERIVEXTPROC = procedure(target, pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ PFNGLGETCOLORTABLEPARAMETERFVEXTPROC = procedure(target, pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+procedure LoadOpenGL( const dll: PChar );
+procedure FreeOpenGL;
+
+implementation
+
+procedure FreeOpenGL;
+begin
+
+ @glAccum := nil;
+ @glAlphaFunc := nil;
+ @glAreTexturesResident := nil;
+ @glArrayElement := nil;
+ @glBegin := nil;
+ @glBindTexture := nil;
+ @glBitmap := nil;
+ @glBlendFunc := nil;
+ @glCallList := nil;
+ @glCallLists := nil;
+ @glClear := nil;
+ @glClearAccum := nil;
+ @glClearColor := nil;
+ @glClearDepth := nil;
+ @glClearIndex := nil;
+ @glClearStencil := nil;
+ @glClipPlane := nil;
+ @glColor3b := nil;
+ @glColor3bv := nil;
+ @glColor3d := nil;
+ @glColor3dv := nil;
+ @glColor3f := nil;
+ @glColor3fv := nil;
+ @glColor3i := nil;
+ @glColor3iv := nil;
+ @glColor3s := nil;
+ @glColor3sv := nil;
+ @glColor3ub := nil;
+ @glColor3ubv := nil;
+ @glColor3ui := nil;
+ @glColor3uiv := nil;
+ @glColor3us := nil;
+ @glColor3usv := nil;
+ @glColor4b := nil;
+ @glColor4bv := nil;
+ @glColor4d := nil;
+ @glColor4dv := nil;
+ @glColor4f := nil;
+ @glColor4fv := nil;
+ @glColor4i := nil;
+ @glColor4iv := nil;
+ @glColor4s := nil;
+ @glColor4sv := nil;
+ @glColor4ub := nil;
+ @glColor4ubv := nil;
+ @glColor4ui := nil;
+ @glColor4uiv := nil;
+ @glColor4us := nil;
+ @glColor4usv := nil;
+ @glColorMask := nil;
+ @glColorMaterial := nil;
+ @glColorPointer := nil;
+ @glCopyPixels := nil;
+ @glCopyTexImage1D := nil;
+ @glCopyTexImage2D := nil;
+ @glCopyTexSubImage1D := nil;
+ @glCopyTexSubImage2D := nil;
+ @glCullFace := nil;
+ @glDeleteLists := nil;
+ @glDeleteTextures := nil;
+ @glDepthFunc := nil;
+ @glDepthMask := nil;
+ @glDepthRange := nil;
+ @glDisable := nil;
+ @glDisableClientState := nil;
+ @glDrawArrays := nil;
+ @glDrawBuffer := nil;
+ @glDrawElements := nil;
+ @glDrawPixels := nil;
+ @glEdgeFlag := nil;
+ @glEdgeFlagPointer := nil;
+ @glEdgeFlagv := nil;
+ @glEnable := nil;
+ @glEnableClientState := nil;
+ @glEnd := nil;
+ @glEndList := nil;
+ @glEvalCoord1d := nil;
+ @glEvalCoord1dv := nil;
+ @glEvalCoord1f := nil;
+ @glEvalCoord1fv := nil;
+ @glEvalCoord2d := nil;
+ @glEvalCoord2dv := nil;
+ @glEvalCoord2f := nil;
+ @glEvalCoord2fv := nil;
+ @glEvalMesh1 := nil;
+ @glEvalMesh2 := nil;
+ @glEvalPoint1 := nil;
+ @glEvalPoint2 := nil;
+ @glFeedbackBuffer := nil;
+ @glFinish := nil;
+ @glFlush := nil;
+ @glFogf := nil;
+ @glFogfv := nil;
+ @glFogi := nil;
+ @glFogiv := nil;
+ @glFrontFace := nil;
+ @glFrustum := nil;
+ @glGenLists := nil;
+ @glGenTextures := nil;
+ @glGetBooleanv := nil;
+ @glGetClipPlane := nil;
+ @glGetDoublev := nil;
+ @glGetError := nil;
+ @glGetFloatv := nil;
+ @glGetIntegerv := nil;
+ @glGetLightfv := nil;
+ @glGetLightiv := nil;
+ @glGetMapdv := nil;
+ @glGetMapfv := nil;
+ @glGetMapiv := nil;
+ @glGetMaterialfv := nil;
+ @glGetMaterialiv := nil;
+ @glGetPixelMapfv := nil;
+ @glGetPixelMapuiv := nil;
+ @glGetPixelMapusv := nil;
+ @glGetPointerv := nil;
+ @glGetPolygonStipple := nil;
+ @glGetString := nil;
+ @glGetTexEnvfv := nil;
+ @glGetTexEnviv := nil;
+ @glGetTexGendv := nil;
+ @glGetTexGenfv := nil;
+ @glGetTexGeniv := nil;
+ @glGetTexImage := nil;
+ @glGetTexLevelParameterfv := nil;
+ @glGetTexLevelParameteriv := nil;
+ @glGetTexParameterfv := nil;
+ @glGetTexParameteriv := nil;
+ @glHint := nil;
+ @glIndexMask := nil;
+ @glIndexPointer := nil;
+ @glIndexd := nil;
+ @glIndexdv := nil;
+ @glIndexf := nil;
+ @glIndexfv := nil;
+ @glIndexi := nil;
+ @glIndexiv := nil;
+ @glIndexs := nil;
+ @glIndexsv := nil;
+ @glIndexub := nil;
+ @glIndexubv := nil;
+ @glInitNames := nil;
+ @glInterleavedArrays := nil;
+ @glIsEnabled := nil;
+ @glIsList := nil;
+ @glIsTexture := nil;
+ @glLightModelf := nil;
+ @glLightModelfv := nil;
+ @glLightModeli := nil;
+ @glLightModeliv := nil;
+ @glLightf := nil;
+ @glLightfv := nil;
+ @glLighti := nil;
+ @glLightiv := nil;
+ @glLineStipple := nil;
+ @glLineWidth := nil;
+ @glListBase := nil;
+ @glLoadIdentity := nil;
+ @glLoadMatrixd := nil;
+ @glLoadMatrixf := nil;
+ @glLoadName := nil;
+ @glLogicOp := nil;
+ @glMap1d := nil;
+ @glMap1f := nil;
+ @glMap2d := nil;
+ @glMap2f := nil;
+ @glMapGrid1d := nil;
+ @glMapGrid1f := nil;
+ @glMapGrid2d := nil;
+ @glMapGrid2f := nil;
+ @glMaterialf := nil;
+ @glMaterialfv := nil;
+ @glMateriali := nil;
+ @glMaterialiv := nil;
+ @glMatrixMode := nil;
+ @glMultMatrixd := nil;
+ @glMultMatrixf := nil;
+ @glNewList := nil;
+ @glNormal3b := nil;
+ @glNormal3bv := nil;
+ @glNormal3d := nil;
+ @glNormal3dv := nil;
+ @glNormal3f := nil;
+ @glNormal3fv := nil;
+ @glNormal3i := nil;
+ @glNormal3iv := nil;
+ @glNormal3s := nil;
+ @glNormal3sv := nil;
+ @glNormalPointer := nil;
+ @glOrtho := nil;
+ @glPassThrough := nil;
+ @glPixelMapfv := nil;
+ @glPixelMapuiv := nil;
+ @glPixelMapusv := nil;
+ @glPixelStoref := nil;
+ @glPixelStorei := nil;
+ @glPixelTransferf := nil;
+ @glPixelTransferi := nil;
+ @glPixelZoom := nil;
+ @glPointSize := nil;
+ @glPolygonMode := nil;
+ @glPolygonOffset := nil;
+ @glPolygonStipple := nil;
+ @glPopAttrib := nil;
+ @glPopClientAttrib := nil;
+ @glPopMatrix := nil;
+ @glPopName := nil;
+ @glPrioritizeTextures := nil;
+ @glPushAttrib := nil;
+ @glPushClientAttrib := nil;
+ @glPushMatrix := nil;
+ @glPushName := nil;
+ @glRasterPos2d := nil;
+ @glRasterPos2dv := nil;
+ @glRasterPos2f := nil;
+ @glRasterPos2fv := nil;
+ @glRasterPos2i := nil;
+ @glRasterPos2iv := nil;
+ @glRasterPos2s := nil;
+ @glRasterPos2sv := nil;
+ @glRasterPos3d := nil;
+ @glRasterPos3dv := nil;
+ @glRasterPos3f := nil;
+ @glRasterPos3fv := nil;
+ @glRasterPos3i := nil;
+ @glRasterPos3iv := nil;
+ @glRasterPos3s := nil;
+ @glRasterPos3sv := nil;
+ @glRasterPos4d := nil;
+ @glRasterPos4dv := nil;
+ @glRasterPos4f := nil;
+ @glRasterPos4fv := nil;
+ @glRasterPos4i := nil;
+ @glRasterPos4iv := nil;
+ @glRasterPos4s := nil;
+ @glRasterPos4sv := nil;
+ @glReadBuffer := nil;
+ @glReadPixels := nil;
+ @glRectd := nil;
+ @glRectdv := nil;
+ @glRectf := nil;
+ @glRectfv := nil;
+ @glRecti := nil;
+ @glRectiv := nil;
+ @glRects := nil;
+ @glRectsv := nil;
+ @glRenderMode := nil;
+ @glRotated := nil;
+ @glRotatef := nil;
+ @glScaled := nil;
+ @glScalef := nil;
+ @glScissor := nil;
+ @glSelectBuffer := nil;
+ @glShadeModel := nil;
+ @glStencilFunc := nil;
+ @glStencilMask := nil;
+ @glStencilOp := nil;
+ @glTexCoord1d := nil;
+ @glTexCoord1dv := nil;
+ @glTexCoord1f := nil;
+ @glTexCoord1fv := nil;
+ @glTexCoord1i := nil;
+ @glTexCoord1iv := nil;
+ @glTexCoord1s := nil;
+ @glTexCoord1sv := nil;
+ @glTexCoord2d := nil;
+ @glTexCoord2dv := nil;
+ @glTexCoord2f := nil;
+ @glTexCoord2fv := nil;
+ @glTexCoord2i := nil;
+ @glTexCoord2iv := nil;
+ @glTexCoord2s := nil;
+ @glTexCoord2sv := nil;
+ @glTexCoord3d := nil;
+ @glTexCoord3dv := nil;
+ @glTexCoord3f := nil;
+ @glTexCoord3fv := nil;
+ @glTexCoord3i := nil;
+ @glTexCoord3iv := nil;
+ @glTexCoord3s := nil;
+ @glTexCoord3sv := nil;
+ @glTexCoord4d := nil;
+ @glTexCoord4dv := nil;
+ @glTexCoord4f := nil;
+ @glTexCoord4fv := nil;
+ @glTexCoord4i := nil;
+ @glTexCoord4iv := nil;
+ @glTexCoord4s := nil;
+ @glTexCoord4sv := nil;
+ @glTexCoordPointer := nil;
+ @glTexEnvf := nil;
+ @glTexEnvfv := nil;
+ @glTexEnvi := nil;
+ @glTexEnviv := nil;
+ @glTexGend := nil;
+ @glTexGendv := nil;
+ @glTexGenf := nil;
+ @glTexGenfv := nil;
+ @glTexGeni := nil;
+ @glTexGeniv := nil;
+ @glTexImage1D := nil;
+ @glTexImage2D := nil;
+ @glTexParameterf := nil;
+ @glTexParameterfv := nil;
+ @glTexParameteri := nil;
+ @glTexParameteriv := nil;
+ @glTexSubImage1D := nil;
+ @glTexSubImage2D := nil;
+ @glTranslated := nil;
+ @glTranslatef := nil;
+ @glVertex2d := nil;
+ @glVertex2dv := nil;
+ @glVertex2f := nil;
+ @glVertex2fv := nil;
+ @glVertex2i := nil;
+ @glVertex2iv := nil;
+ @glVertex2s := nil;
+ @glVertex2sv := nil;
+ @glVertex3d := nil;
+ @glVertex3dv := nil;
+ @glVertex3f := nil;
+ @glVertex3fv := nil;
+ @glVertex3i := nil;
+ @glVertex3iv := nil;
+ @glVertex3s := nil;
+ @glVertex3sv := nil;
+ @glVertex4d := nil;
+ @glVertex4dv := nil;
+ @glVertex4f := nil;
+ @glVertex4fv := nil;
+ @glVertex4i := nil;
+ @glVertex4iv := nil;
+ @glVertex4s := nil;
+ @glVertex4sv := nil;
+ @glVertexPointer := nil;
+ @glViewport := nil;
+ {$IFDEF WINDOWS}
+ @ChoosePixelFormat := nil;
+ {$ENDIF}
+
+ UnLoadModule(LibGL);
+
+end;
+
+procedure LoadOpenGL(const dll: PChar);
+begin
+
+ FreeOpenGL;
+
+ if LoadModule( LibGL, dll ) then
+ begin
+ @glAccum := GetModuleSymbol(LibGL, 'glAccum');
+ @glAlphaFunc := GetModuleSymbol(LibGL, 'glAlphaFunc');
+ @glAreTexturesResident := GetModuleSymbol(LibGL, 'glAreTexturesResident');
+ @glArrayElement := GetModuleSymbol(LibGL, 'glArrayElement');
+ @glBegin := GetModuleSymbol(LibGL, 'glBegin');
+ @glBindTexture := GetModuleSymbol(LibGL, 'glBindTexture');
+ @glBitmap := GetModuleSymbol(LibGL, 'glBitmap');
+ @glBlendFunc := GetModuleSymbol(LibGL, 'glBlendFunc');
+ @glCallList := GetModuleSymbol(LibGL, 'glCallList');
+ @glCallLists := GetModuleSymbol(LibGL, 'glCallLists');
+ @glClear := GetModuleSymbol(LibGL, 'glClear');
+ @glClearAccum := GetModuleSymbol(LibGL, 'glClearAccum');
+ @glClearColor := GetModuleSymbol(LibGL, 'glClearColor');
+ @glClearDepth := GetModuleSymbol(LibGL, 'glClearDepth');
+ @glClearIndex := GetModuleSymbol(LibGL, 'glClearIndex');
+ @glClearStencil := GetModuleSymbol(LibGL, 'glClearStencil');
+ @glClipPlane := GetModuleSymbol(LibGL, 'glClipPlane');
+ @glColor3b := GetModuleSymbol(LibGL, 'glColor3b');
+ @glColor3bv := GetModuleSymbol(LibGL, 'glColor3bv');
+ @glColor3d := GetModuleSymbol(LibGL, 'glColor3d');
+ @glColor3dv := GetModuleSymbol(LibGL, 'glColor3dv');
+ @glColor3f := GetModuleSymbol(LibGL, 'glColor3f');
+ @glColor3fv := GetModuleSymbol(LibGL, 'glColor3fv');
+ @glColor3i := GetModuleSymbol(LibGL, 'glColor3i');
+ @glColor3iv := GetModuleSymbol(LibGL, 'glColor3iv');
+ @glColor3s := GetModuleSymbol(LibGL, 'glColor3s');
+ @glColor3sv := GetModuleSymbol(LibGL, 'glColor3sv');
+ @glColor3ub := GetModuleSymbol(LibGL, 'glColor3ub');
+ @glColor3ubv := GetModuleSymbol(LibGL, 'glColor3ubv');
+ @glColor3ui := GetModuleSymbol(LibGL, 'glColor3ui');
+ @glColor3uiv := GetModuleSymbol(LibGL, 'glColor3uiv');
+ @glColor3us := GetModuleSymbol(LibGL, 'glColor3us');
+ @glColor3usv := GetModuleSymbol(LibGL, 'glColor3usv');
+ @glColor4b := GetModuleSymbol(LibGL, 'glColor4b');
+ @glColor4bv := GetModuleSymbol(LibGL, 'glColor4bv');
+ @glColor4d := GetModuleSymbol(LibGL, 'glColor4d');
+ @glColor4dv := GetModuleSymbol(LibGL, 'glColor4dv');
+ @glColor4f := GetModuleSymbol(LibGL, 'glColor4f');
+ @glColor4fv := GetModuleSymbol(LibGL, 'glColor4fv');
+ @glColor4i := GetModuleSymbol(LibGL, 'glColor4i');
+ @glColor4iv := GetModuleSymbol(LibGL, 'glColor4iv');
+ @glColor4s := GetModuleSymbol(LibGL, 'glColor4s');
+ @glColor4sv := GetModuleSymbol(LibGL, 'glColor4sv');
+ @glColor4ub := GetModuleSymbol(LibGL, 'glColor4ub');
+ @glColor4ubv := GetModuleSymbol(LibGL, 'glColor4ubv');
+ @glColor4ui := GetModuleSymbol(LibGL, 'glColor4ui');
+ @glColor4uiv := GetModuleSymbol(LibGL, 'glColor4uiv');
+ @glColor4us := GetModuleSymbol(LibGL, 'glColor4us');
+ @glColor4usv := GetModuleSymbol(LibGL, 'glColor4usv');
+ @glColorMask := GetModuleSymbol(LibGL, 'glColorMask');
+ @glColorMaterial := GetModuleSymbol(LibGL, 'glColorMaterial');
+ @glColorPointer := GetModuleSymbol(LibGL, 'glColorPointer');
+ @glCopyPixels := GetModuleSymbol(LibGL, 'glCopyPixels');
+ @glCopyTexImage1D := GetModuleSymbol(LibGL, 'glCopyTexImage1D');
+ @glCopyTexImage2D := GetModuleSymbol(LibGL, 'glCopyTexImage2D');
+ @glCopyTexSubImage1D := GetModuleSymbol(LibGL, 'glCopyTexSubImage1D');
+ @glCopyTexSubImage2D := GetModuleSymbol(LibGL, 'glCopyTexSubImage2D');
+ @glCullFace := GetModuleSymbol(LibGL, 'glCullFace');
+ @glDeleteLists := GetModuleSymbol(LibGL, 'glDeleteLists');
+ @glDeleteTextures := GetModuleSymbol(LibGL, 'glDeleteTextures');
+ @glDepthFunc := GetModuleSymbol(LibGL, 'glDepthFunc');
+ @glDepthMask := GetModuleSymbol(LibGL, 'glDepthMask');
+ @glDepthRange := GetModuleSymbol(LibGL, 'glDepthRange');
+ @glDisable := GetModuleSymbol(LibGL, 'glDisable');
+ @glDisableClientState := GetModuleSymbol(LibGL, 'glDisableClientState');
+ @glDrawArrays := GetModuleSymbol(LibGL, 'glDrawArrays');
+ @glDrawBuffer := GetModuleSymbol(LibGL, 'glDrawBuffer');
+ @glDrawElements := GetModuleSymbol(LibGL, 'glDrawElements');
+ @glDrawPixels := GetModuleSymbol(LibGL, 'glDrawPixels');
+ @glEdgeFlag := GetModuleSymbol(LibGL, 'glEdgeFlag');
+ @glEdgeFlagPointer := GetModuleSymbol(LibGL, 'glEdgeFlagPointer');
+ @glEdgeFlagv := GetModuleSymbol(LibGL, 'glEdgeFlagv');
+ @glEnable := GetModuleSymbol(LibGL, 'glEnable');
+ @glEnableClientState := GetModuleSymbol(LibGL, 'glEnableClientState');
+ @glEnd := GetModuleSymbol(LibGL, 'glEnd');
+ @glEndList := GetModuleSymbol(LibGL, 'glEndList');
+ @glEvalCoord1d := GetModuleSymbol(LibGL, 'glEvalCoord1d');
+ @glEvalCoord1dv := GetModuleSymbol(LibGL, 'glEvalCoord1dv');
+ @glEvalCoord1f := GetModuleSymbol(LibGL, 'glEvalCoord1f');
+ @glEvalCoord1fv := GetModuleSymbol(LibGL, 'glEvalCoord1fv');
+ @glEvalCoord2d := GetModuleSymbol(LibGL, 'glEvalCoord2d');
+ @glEvalCoord2dv := GetModuleSymbol(LibGL, 'glEvalCoord2dv');
+ @glEvalCoord2f := GetModuleSymbol(LibGL, 'glEvalCoord2f');
+ @glEvalCoord2fv := GetModuleSymbol(LibGL, 'glEvalCoord2fv');
+ @glEvalMesh1 := GetModuleSymbol(LibGL, 'glEvalMesh1');
+ @glEvalMesh2 := GetModuleSymbol(LibGL, 'glEvalMesh2');
+ @glEvalPoint1 := GetModuleSymbol(LibGL, 'glEvalPoint1');
+ @glEvalPoint2 := GetModuleSymbol(LibGL, 'glEvalPoint2');
+ @glFeedbackBuffer := GetModuleSymbol(LibGL, 'glFeedbackBuffer');
+ @glFinish := GetModuleSymbol(LibGL, 'glFinish');
+ @glFlush := GetModuleSymbol(LibGL, 'glFlush');
+ @glFogf := GetModuleSymbol(LibGL, 'glFogf');
+ @glFogfv := GetModuleSymbol(LibGL, 'glFogfv');
+ @glFogi := GetModuleSymbol(LibGL, 'glFogi');
+ @glFogiv := GetModuleSymbol(LibGL, 'glFogiv');
+ @glFrontFace := GetModuleSymbol(LibGL, 'glFrontFace');
+ @glFrustum := GetModuleSymbol(LibGL, 'glFrustum');
+ @glGenLists := GetModuleSymbol(LibGL, 'glGenLists');
+ @glGenTextures := GetModuleSymbol(LibGL, 'glGenTextures');
+ @glGetBooleanv := GetModuleSymbol(LibGL, 'glGetBooleanv');
+ @glGetClipPlane := GetModuleSymbol(LibGL, 'glGetClipPlane');
+ @glGetDoublev := GetModuleSymbol(LibGL, 'glGetDoublev');
+ @glGetError := GetModuleSymbol(LibGL, 'glGetError');
+ @glGetFloatv := GetModuleSymbol(LibGL, 'glGetFloatv');
+ @glGetIntegerv := GetModuleSymbol(LibGL, 'glGetIntegerv');
+ @glGetLightfv := GetModuleSymbol(LibGL, 'glGetLightfv');
+ @glGetLightiv := GetModuleSymbol(LibGL, 'glGetLightiv');
+ @glGetMapdv := GetModuleSymbol(LibGL, 'glGetMapdv');
+ @glGetMapfv := GetModuleSymbol(LibGL, 'glGetMapfv');
+ @glGetMapiv := GetModuleSymbol(LibGL, 'glGetMapiv');
+ @glGetMaterialfv := GetModuleSymbol(LibGL, 'glGetMaterialfv');
+ @glGetMaterialiv := GetModuleSymbol(LibGL, 'glGetMaterialiv');
+ @glGetPixelMapfv := GetModuleSymbol(LibGL, 'glGetPixelMapfv');
+ @glGetPixelMapuiv := GetModuleSymbol(LibGL, 'glGetPixelMapuiv');
+ @glGetPixelMapusv := GetModuleSymbol(LibGL, 'glGetPixelMapusv');
+ @glGetPointerv := GetModuleSymbol(LibGL, 'glGetPointerv');
+ @glGetPolygonStipple := GetModuleSymbol(LibGL, 'glGetPolygonStipple');
+ @glGetString := GetModuleSymbol(LibGL, 'glGetString');
+ @glGetTexEnvfv := GetModuleSymbol(LibGL, 'glGetTexEnvfv');
+ @glGetTexEnviv := GetModuleSymbol(LibGL, 'glGetTexEnviv');
+ @glGetTexGendv := GetModuleSymbol(LibGL, 'glGetTexGendv');
+ @glGetTexGenfv := GetModuleSymbol(LibGL, 'glGetTexGenfv');
+ @glGetTexGeniv := GetModuleSymbol(LibGL, 'glGetTexGeniv');
+ @glGetTexImage := GetModuleSymbol(LibGL, 'glGetTexImage');
+ @glGetTexLevelParameterfv := GetModuleSymbol(LibGL, 'glGetTexLevelParameterfv');
+ @glGetTexLevelParameteriv := GetModuleSymbol(LibGL, 'glGetTexLevelParameteriv');
+ @glGetTexParameterfv := GetModuleSymbol(LibGL, 'glGetTexParameterfv');
+ @glGetTexParameteriv := GetModuleSymbol(LibGL, 'glGetTexParameteriv');
+ @glHint := GetModuleSymbol(LibGL, 'glHint');
+ @glIndexMask := GetModuleSymbol(LibGL, 'glIndexMask');
+ @glIndexPointer := GetModuleSymbol(LibGL, 'glIndexPointer');
+ @glIndexd := GetModuleSymbol(LibGL, 'glIndexd');
+ @glIndexdv := GetModuleSymbol(LibGL, 'glIndexdv');
+ @glIndexf := GetModuleSymbol(LibGL, 'glIndexf');
+ @glIndexfv := GetModuleSymbol(LibGL, 'glIndexfv');
+ @glIndexi := GetModuleSymbol(LibGL, 'glIndexi');
+ @glIndexiv := GetModuleSymbol(LibGL, 'glIndexiv');
+ @glIndexs := GetModuleSymbol(LibGL, 'glIndexs');
+ @glIndexsv := GetModuleSymbol(LibGL, 'glIndexsv');
+ @glIndexub := GetModuleSymbol(LibGL, 'glIndexub');
+ @glIndexubv := GetModuleSymbol(LibGL, 'glIndexubv');
+ @glInitNames := GetModuleSymbol(LibGL, 'glInitNames');
+ @glInterleavedArrays := GetModuleSymbol(LibGL, 'glInterleavedArrays');
+ @glIsEnabled := GetModuleSymbol(LibGL, 'glIsEnabled');
+ @glIsList := GetModuleSymbol(LibGL, 'glIsList');
+ @glIsTexture := GetModuleSymbol(LibGL, 'glIsTexture');
+ @glLightModelf := GetModuleSymbol(LibGL, 'glLightModelf');
+ @glLightModelfv := GetModuleSymbol(LibGL, 'glLightModelfv');
+ @glLightModeli := GetModuleSymbol(LibGL, 'glLightModeli');
+ @glLightModeliv := GetModuleSymbol(LibGL, 'glLightModeliv');
+ @glLightf := GetModuleSymbol(LibGL, 'glLightf');
+ @glLightfv := GetModuleSymbol(LibGL, 'glLightfv');
+ @glLighti := GetModuleSymbol(LibGL, 'glLighti');
+ @glLightiv := GetModuleSymbol(LibGL, 'glLightiv');
+ @glLineStipple := GetModuleSymbol(LibGL, 'glLineStipple');
+ @glLineWidth := GetModuleSymbol(LibGL, 'glLineWidth');
+ @glListBase := GetModuleSymbol(LibGL, 'glListBase');
+ @glLoadIdentity := GetModuleSymbol(LibGL, 'glLoadIdentity');
+ @glLoadMatrixd := GetModuleSymbol(LibGL, 'glLoadMatrixd');
+ @glLoadMatrixf := GetModuleSymbol(LibGL, 'glLoadMatrixf');
+ @glLoadName := GetModuleSymbol(LibGL, 'glLoadName');
+ @glLogicOp := GetModuleSymbol(LibGL, 'glLogicOp');
+ @glMap1d := GetModuleSymbol(LibGL, 'glMap1d');
+ @glMap1f := GetModuleSymbol(LibGL, 'glMap1f');
+ @glMap2d := GetModuleSymbol(LibGL, 'glMap2d');
+ @glMap2f := GetModuleSymbol(LibGL, 'glMap2f');
+ @glMapGrid1d := GetModuleSymbol(LibGL, 'glMapGrid1d');
+ @glMapGrid1f := GetModuleSymbol(LibGL, 'glMapGrid1f');
+ @glMapGrid2d := GetModuleSymbol(LibGL, 'glMapGrid2d');
+ @glMapGrid2f := GetModuleSymbol(LibGL, 'glMapGrid2f');
+ @glMaterialf := GetModuleSymbol(LibGL, 'glMaterialf');
+ @glMaterialfv := GetModuleSymbol(LibGL, 'glMaterialfv');
+ @glMateriali := GetModuleSymbol(LibGL, 'glMateriali');
+ @glMaterialiv := GetModuleSymbol(LibGL, 'glMaterialiv');
+ @glMatrixMode := GetModuleSymbol(LibGL, 'glMatrixMode');
+ @glMultMatrixd := GetModuleSymbol(LibGL, 'glMultMatrixd');
+ @glMultMatrixf := GetModuleSymbol(LibGL, 'glMultMatrixf');
+ @glNewList := GetModuleSymbol(LibGL, 'glNewList');
+ @glNormal3b := GetModuleSymbol(LibGL, 'glNormal3b');
+ @glNormal3bv := GetModuleSymbol(LibGL, 'glNormal3bv');
+ @glNormal3d := GetModuleSymbol(LibGL, 'glNormal3d');
+ @glNormal3dv := GetModuleSymbol(LibGL, 'glNormal3dv');
+ @glNormal3f := GetModuleSymbol(LibGL, 'glNormal3f');
+ @glNormal3fv := GetModuleSymbol(LibGL, 'glNormal3fv');
+ @glNormal3i := GetModuleSymbol(LibGL, 'glNormal3i');
+ @glNormal3iv := GetModuleSymbol(LibGL, 'glNormal3iv');
+ @glNormal3s := GetModuleSymbol(LibGL, 'glNormal3s');
+ @glNormal3sv := GetModuleSymbol(LibGL, 'glNormal3sv');
+ @glNormalPointer := GetModuleSymbol(LibGL, 'glNormalPointer');
+ @glOrtho := GetModuleSymbol(LibGL, 'glOrtho');
+ @glPassThrough := GetModuleSymbol(LibGL, 'glPassThrough');
+ @glPixelMapfv := GetModuleSymbol(LibGL, 'glPixelMapfv');
+ @glPixelMapuiv := GetModuleSymbol(LibGL, 'glPixelMapuiv');
+ @glPixelMapusv := GetModuleSymbol(LibGL, 'glPixelMapusv');
+ @glPixelStoref := GetModuleSymbol(LibGL, 'glPixelStoref');
+ @glPixelStorei := GetModuleSymbol(LibGL, 'glPixelStorei');
+ @glPixelTransferf := GetModuleSymbol(LibGL, 'glPixelTransferf');
+ @glPixelTransferi := GetModuleSymbol(LibGL, 'glPixelTransferi');
+ @glPixelZoom := GetModuleSymbol(LibGL, 'glPixelZoom');
+ @glPointSize := GetModuleSymbol(LibGL, 'glPointSize');
+ @glPolygonMode := GetModuleSymbol(LibGL, 'glPolygonMode');
+ @glPolygonOffset := GetModuleSymbol(LibGL, 'glPolygonOffset');
+ @glPolygonStipple := GetModuleSymbol(LibGL, 'glPolygonStipple');
+ @glPopAttrib := GetModuleSymbol(LibGL, 'glPopAttrib');
+ @glPopClientAttrib := GetModuleSymbol(LibGL, 'glPopClientAttrib');
+ @glPopMatrix := GetModuleSymbol(LibGL, 'glPopMatrix');
+ @glPopName := GetModuleSymbol(LibGL, 'glPopName');
+ @glPrioritizeTextures := GetModuleSymbol(LibGL, 'glPrioritizeTextures');
+ @glPushAttrib := GetModuleSymbol(LibGL, 'glPushAttrib');
+ @glPushClientAttrib := GetModuleSymbol(LibGL, 'glPushClientAttrib');
+ @glPushMatrix := GetModuleSymbol(LibGL, 'glPushMatrix');
+ @glPushName := GetModuleSymbol(LibGL, 'glPushName');
+ @glRasterPos2d := GetModuleSymbol(LibGL, 'glRasterPos2d');
+ @glRasterPos2dv := GetModuleSymbol(LibGL, 'glRasterPos2dv');
+ @glRasterPos2f := GetModuleSymbol(LibGL, 'glRasterPos2f');
+ @glRasterPos2fv := GetModuleSymbol(LibGL, 'glRasterPos2fv');
+ @glRasterPos2i := GetModuleSymbol(LibGL, 'glRasterPos2i');
+ @glRasterPos2iv := GetModuleSymbol(LibGL, 'glRasterPos2iv');
+ @glRasterPos2s := GetModuleSymbol(LibGL, 'glRasterPos2s');
+ @glRasterPos2sv := GetModuleSymbol(LibGL, 'glRasterPos2sv');
+ @glRasterPos3d := GetModuleSymbol(LibGL, 'glRasterPos3d');
+ @glRasterPos3dv := GetModuleSymbol(LibGL, 'glRasterPos3dv');
+ @glRasterPos3f := GetModuleSymbol(LibGL, 'glRasterPos3f');
+ @glRasterPos3fv := GetModuleSymbol(LibGL, 'glRasterPos3fv');
+ @glRasterPos3i := GetModuleSymbol(LibGL, 'glRasterPos3i');
+ @glRasterPos3iv := GetModuleSymbol(LibGL, 'glRasterPos3iv');
+ @glRasterPos3s := GetModuleSymbol(LibGL, 'glRasterPos3s');
+ @glRasterPos3sv := GetModuleSymbol(LibGL, 'glRasterPos3sv');
+ @glRasterPos4d := GetModuleSymbol(LibGL, 'glRasterPos4d');
+ @glRasterPos4dv := GetModuleSymbol(LibGL, 'glRasterPos4dv');
+ @glRasterPos4f := GetModuleSymbol(LibGL, 'glRasterPos4f');
+ @glRasterPos4fv := GetModuleSymbol(LibGL, 'glRasterPos4fv');
+ @glRasterPos4i := GetModuleSymbol(LibGL, 'glRasterPos4i');
+ @glRasterPos4iv := GetModuleSymbol(LibGL, 'glRasterPos4iv');
+ @glRasterPos4s := GetModuleSymbol(LibGL, 'glRasterPos4s');
+ @glRasterPos4sv := GetModuleSymbol(LibGL, 'glRasterPos4sv');
+ @glReadBuffer := GetModuleSymbol(LibGL, 'glReadBuffer');
+ @glReadPixels := GetModuleSymbol(LibGL, 'glReadPixels');
+ @glRectd := GetModuleSymbol(LibGL, 'glRectd');
+ @glRectdv := GetModuleSymbol(LibGL, 'glRectdv');
+ @glRectf := GetModuleSymbol(LibGL, 'glRectf');
+ @glRectfv := GetModuleSymbol(LibGL, 'glRectfv');
+ @glRecti := GetModuleSymbol(LibGL, 'glRecti');
+ @glRectiv := GetModuleSymbol(LibGL, 'glRectiv');
+ @glRects := GetModuleSymbol(LibGL, 'glRects');
+ @glRectsv := GetModuleSymbol(LibGL, 'glRectsv');
+ @glRenderMode := GetModuleSymbol(LibGL, 'glRenderMode');
+ @glRotated := GetModuleSymbol(LibGL, 'glRotated');
+ @glRotatef := GetModuleSymbol(LibGL, 'glRotatef');
+ @glScaled := GetModuleSymbol(LibGL, 'glScaled');
+ @glScalef := GetModuleSymbol(LibGL, 'glScalef');
+ @glScissor := GetModuleSymbol(LibGL, 'glScissor');
+ @glSelectBuffer := GetModuleSymbol(LibGL, 'glSelectBuffer');
+ @glShadeModel := GetModuleSymbol(LibGL, 'glShadeModel');
+ @glStencilFunc := GetModuleSymbol(LibGL, 'glStencilFunc');
+ @glStencilMask := GetModuleSymbol(LibGL, 'glStencilMask');
+ @glStencilOp := GetModuleSymbol(LibGL, 'glStencilOp');
+ @glTexCoord1d := GetModuleSymbol(LibGL, 'glTexCoord1d');
+ @glTexCoord1dv := GetModuleSymbol(LibGL, 'glTexCoord1dv');
+ @glTexCoord1f := GetModuleSymbol(LibGL, 'glTexCoord1f');
+ @glTexCoord1fv := GetModuleSymbol(LibGL, 'glTexCoord1fv');
+ @glTexCoord1i := GetModuleSymbol(LibGL, 'glTexCoord1i');
+ @glTexCoord1iv := GetModuleSymbol(LibGL, 'glTexCoord1iv');
+ @glTexCoord1s := GetModuleSymbol(LibGL, 'glTexCoord1s');
+ @glTexCoord1sv := GetModuleSymbol(LibGL, 'glTexCoord1sv');
+ @glTexCoord2d := GetModuleSymbol(LibGL, 'glTexCoord2d');
+ @glTexCoord2dv := GetModuleSymbol(LibGL, 'glTexCoord2dv');
+ @glTexCoord2f := GetModuleSymbol(LibGL, 'glTexCoord2f');
+ @glTexCoord2fv := GetModuleSymbol(LibGL, 'glTexCoord2fv');
+ @glTexCoord2i := GetModuleSymbol(LibGL, 'glTexCoord2i');
+ @glTexCoord2iv := GetModuleSymbol(LibGL, 'glTexCoord2iv');
+ @glTexCoord2s := GetModuleSymbol(LibGL, 'glTexCoord2s');
+ @glTexCoord2sv := GetModuleSymbol(LibGL, 'glTexCoord2sv');
+ @glTexCoord3d := GetModuleSymbol(LibGL, 'glTexCoord3d');
+ @glTexCoord3dv := GetModuleSymbol(LibGL, 'glTexCoord3dv');
+ @glTexCoord3f := GetModuleSymbol(LibGL, 'glTexCoord3f');
+ @glTexCoord3fv := GetModuleSymbol(LibGL, 'glTexCoord3fv');
+ @glTexCoord3i := GetModuleSymbol(LibGL, 'glTexCoord3i');
+ @glTexCoord3iv := GetModuleSymbol(LibGL, 'glTexCoord3iv');
+ @glTexCoord3s := GetModuleSymbol(LibGL, 'glTexCoord3s');
+ @glTexCoord3sv := GetModuleSymbol(LibGL, 'glTexCoord3sv');
+ @glTexCoord4d := GetModuleSymbol(LibGL, 'glTexCoord4d');
+ @glTexCoord4dv := GetModuleSymbol(LibGL, 'glTexCoord4dv');
+ @glTexCoord4f := GetModuleSymbol(LibGL, 'glTexCoord4f');
+ @glTexCoord4fv := GetModuleSymbol(LibGL, 'glTexCoord4fv');
+ @glTexCoord4i := GetModuleSymbol(LibGL, 'glTexCoord4i');
+ @glTexCoord4iv := GetModuleSymbol(LibGL, 'glTexCoord4iv');
+ @glTexCoord4s := GetModuleSymbol(LibGL, 'glTexCoord4s');
+ @glTexCoord4sv := GetModuleSymbol(LibGL, 'glTexCoord4sv');
+ @glTexCoordPointer := GetModuleSymbol(LibGL, 'glTexCoordPointer');
+ @glTexEnvf := GetModuleSymbol(LibGL, 'glTexEnvf');
+ @glTexEnvfv := GetModuleSymbol(LibGL, 'glTexEnvfv');
+ @glTexEnvi := GetModuleSymbol(LibGL, 'glTexEnvi');
+ @glTexEnviv := GetModuleSymbol(LibGL, 'glTexEnviv');
+ @glTexGend := GetModuleSymbol(LibGL, 'glTexGend');
+ @glTexGendv := GetModuleSymbol(LibGL, 'glTexGendv');
+ @glTexGenf := GetModuleSymbol(LibGL, 'glTexGenf');
+ @glTexGenfv := GetModuleSymbol(LibGL, 'glTexGenfv');
+ @glTexGeni := GetModuleSymbol(LibGL, 'glTexGeni');
+ @glTexGeniv := GetModuleSymbol(LibGL, 'glTexGeniv');
+ @glTexImage1D := GetModuleSymbol(LibGL, 'glTexImage1D');
+ @glTexImage2D := GetModuleSymbol(LibGL, 'glTexImage2D');
+ @glTexParameterf := GetModuleSymbol(LibGL, 'glTexParameterf');
+ @glTexParameterfv := GetModuleSymbol(LibGL, 'glTexParameterfv');
+ @glTexParameteri := GetModuleSymbol(LibGL, 'glTexParameteri');
+ @glTexParameteriv := GetModuleSymbol(LibGL, 'glTexParameteriv');
+ @glTexSubImage1D := GetModuleSymbol(LibGL, 'glTexSubImage1D');
+ @glTexSubImage2D := GetModuleSymbol(LibGL, 'glTexSubImage2D');
+ @glTranslated := GetModuleSymbol(LibGL, 'glTranslated');
+ @glTranslatef := GetModuleSymbol(LibGL, 'glTranslatef');
+ @glVertex2d := GetModuleSymbol(LibGL, 'glVertex2d');
+ @glVertex2dv := GetModuleSymbol(LibGL, 'glVertex2dv');
+ @glVertex2f := GetModuleSymbol(LibGL, 'glVertex2f');
+ @glVertex2fv := GetModuleSymbol(LibGL, 'glVertex2fv');
+ @glVertex2i := GetModuleSymbol(LibGL, 'glVertex2i');
+ @glVertex2iv := GetModuleSymbol(LibGL, 'glVertex2iv');
+ @glVertex2s := GetModuleSymbol(LibGL, 'glVertex2s');
+ @glVertex2sv := GetModuleSymbol(LibGL, 'glVertex2sv');
+ @glVertex3d := GetModuleSymbol(LibGL, 'glVertex3d');
+ @glVertex3dv := GetModuleSymbol(LibGL, 'glVertex3dv');
+ @glVertex3f := GetModuleSymbol(LibGL, 'glVertex3f');
+ @glVertex3fv := GetModuleSymbol(LibGL, 'glVertex3fv');
+ @glVertex3i := GetModuleSymbol(LibGL, 'glVertex3i');
+ @glVertex3iv := GetModuleSymbol(LibGL, 'glVertex3iv');
+ @glVertex3s := GetModuleSymbol(LibGL, 'glVertex3s');
+ @glVertex3sv := GetModuleSymbol(LibGL, 'glVertex3sv');
+ @glVertex4d := GetModuleSymbol(LibGL, 'glVertex4d');
+ @glVertex4dv := GetModuleSymbol(LibGL, 'glVertex4dv');
+ @glVertex4f := GetModuleSymbol(LibGL, 'glVertex4f');
+ @glVertex4fv := GetModuleSymbol(LibGL, 'glVertex4fv');
+ @glVertex4i := GetModuleSymbol(LibGL, 'glVertex4i');
+ @glVertex4iv := GetModuleSymbol(LibGL, 'glVertex4iv');
+ @glVertex4s := GetModuleSymbol(LibGL, 'glVertex4s');
+ @glVertex4sv := GetModuleSymbol(LibGL, 'glVertex4sv');
+ @glVertexPointer := GetModuleSymbol(LibGL, 'glVertexPointer');
+ @glViewport := GetModuleSymbol(LibGL, 'glViewport');
+
+ {$IFDEF WINDOWS}
+ @ChoosePixelFormat := GetModuleSymbol(LibGL, 'ChoosePixelFormat');
+ if not Assigned(ChoosePixelFormat) then
+ {$IFNDEF FPC}@{$ENDIF}ChoosePixelFormat := @Windows.ChoosePixelFormat;
+ {$ENDIF}
+ end;
+end;
+
+initialization
+ {$ifdef x86}
+ Set8087CW($133F);
+ {$endif x86}
+
+ LoadOpenGL( GLLibName );
+
+finalization
+
+ FreeOpenGL;
+
+end.
+
diff --git a/Game/Code/lib/JEDI-SDL/OpenGL/Pas/glext.pas b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/glext.pas new file mode 100644 index 00000000..835c1703 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/glext.pas @@ -0,0 +1,9578 @@ +unit glext;
+{
+ $Id: glext.pas,v 1.6 2007/05/20 20:28:31 savage Exp $
+
+}
+(**************************************************
+ * OpenGL extension loading library *
+ * Generated by MetaGLext, written by Tom Nuydens *
+ * (tom@delphi3d.net -- http://www.delphi3d.net *
+ **************************************************)
+
+{
+ $Log: glext.pas,v $
+ Revision 1.6 2007/05/20 20:28:31 savage
+ Initial Changes to Handle 64 Bits
+
+ Revision 1.5 2006/01/11 22:39:02 drellis
+ Updated to Support Up to OpenGL 2.0
+
+ Revision 1.4 2005/01/05 00:28:40 savage
+ Forgot to wrap a couple of Load_WGL function calls with an IFDEF WIN32. Fixed so now compiles under Linux as well.
+
+ Revision 1.3 2004/08/24 19:33:06 savage
+ Removed declarations of SDL_GL_GetProcAddress as the correct ones are in sdl.pas.
+
+ Revision 1.2 2004/08/09 00:38:01 savage
+ Updated to Tom's latest version. May contains bugs, but I hope not.
+
+ Revision 1.1 2004/03/30 21:53:54 savage
+ Moved to it's own folder.
+
+ Revision 1.6 2004/03/28 00:28:43 savage
+ Fixed some glSecondaryColor definitions...
+
+ Revision 1.5 2004/02/20 17:18:16 savage
+ Forgot to prefix function pointer with @ for FPC and other Pascal compilers.
+
+ Revision 1.4 2004/02/20 17:09:55 savage
+ Code tidied up in gl, glu and glut, while extensions in glext.pas are now loaded using SDL_GL_GetProcAddress, thus making it more cross-platform compatible, but now more tied to SDL.
+
+ Revision 1.3 2004/02/14 22:36:29 savage
+ Fixed inconsistencies of using LoadLibrary and LoadModule.
+ Now all units make use of LoadModule rather than LoadLibrary and other dynamic proc procedures.
+
+ Revision 1.2 2004/02/14 00:09:19 savage
+ Changed uses to now make use of moduleloader.pas rather than dllfuncs.pas
+
+ Revision 1.1 2004/02/05 00:08:19 savage
+ Module 1.0 release
+
+ Revision 1.7 2003/06/02 12:32:13 savage
+ Modified Sources to avoid warnings with Delphi by moving CVS Logging to the top of the header files. Hopefully CVS Logging still works.
+
+}
+
+interface
+
+{$I jedi-sdl.inc}
+
+uses
+ SysUtils,
+{$IFDEF __GPC__}
+ gpc,
+{$ENDIF}
+
+{$IFDEF WINDOWS}
+ Windows,
+{$ENDIF}
+ moduleloader,
+ gl;
+
+// Test if the given extension name is present in the given extension string.
+function glext_ExtensionSupported(const extension: PChar; const searchIn: PChar): Boolean;
+
+// Load a Specific Extension
+function glext_LoadExtension(ext: String): Boolean;
+// Some types that were introduced by extensions:
+type
+ GLintptrARB = Integer;
+ PGLintptrARB = ^GLintptrARB;
+
+ GLsizeiptrARB = Integer;
+ PGLsizeiptrARB = ^GLsizeiptrARB;
+
+ GLcharARB = Char;
+ PGLcharARB = ^GLcharARB;
+
+ GLhandleARB = Cardinal;
+ PGLhandleARB = ^GLhandleARB;
+
+ GLintptr = Integer;
+ PGLintptr = ^GLintptr;
+
+ GLsizeiptr = Integer;
+ PGLsizeiptr = ^GLsizeiptr;
+
+ GLchar = Char;
+ PGLchar = ^GLchar;
+
+//***** GL_version_1_2 *****//
+const
+ GL_UNSIGNED_BYTE_3_3_2 = $8032;
+ GL_UNSIGNED_SHORT_4_4_4_4 = $8033;
+ GL_UNSIGNED_SHORT_5_5_5_1 = $8034;
+ GL_UNSIGNED_INT_8_8_8_8 = $8035;
+ GL_UNSIGNED_INT_10_10_10_2 = $8036;
+ GL_RESCALE_NORMAL = $803A;
+ GL_UNSIGNED_BYTE_2_3_3_REV = $8362;
+ GL_UNSIGNED_SHORT_5_6_5 = $8363;
+ GL_UNSIGNED_SHORT_5_6_5_REV = $8364;
+ GL_UNSIGNED_SHORT_4_4_4_4_REV = $8365;
+ GL_UNSIGNED_SHORT_1_5_5_5_REV = $8366;
+ GL_UNSIGNED_INT_8_8_8_8_REV = $8367;
+ GL_UNSIGNED_INT_2_10_10_10_REV = $8368;
+ GL_BGR = $80E0;
+ GL_BGRA = $80E1;
+ GL_MAX_ELEMENTS_VERTICES = $80E8;
+ GL_MAX_ELEMENTS_INDICES = $80E9;
+ GL_CLAMP_TO_EDGE = $812F;
+ GL_TEXTURE_MIN_LOD = $813A;
+ GL_TEXTURE_MAX_LOD = $813B;
+ GL_TEXTURE_BASE_LEVEL = $813C;
+ GL_TEXTURE_MAX_LEVEL = $813D;
+ GL_LIGHT_MODEL_COLOR_CONTROL = $81F8;
+ GL_SINGLE_COLOR = $81F9;
+ GL_SEPARATE_SPECULAR_COLOR = $81FA;
+ GL_SMOOTH_POINT_SIZE_RANGE = $0B12;
+ GL_SMOOTH_POINT_SIZE_GRANULARITY = $0B13;
+ GL_SMOOTH_LINE_WIDTH_RANGE = $0B22;
+ GL_SMOOTH_LINE_WIDTH_GRANULARITY = $0B23;
+ GL_ALIASED_POINT_SIZE_RANGE = $846D;
+ GL_ALIASED_LINE_WIDTH_RANGE = $846E;
+ GL_PACK_SKIP_IMAGES = $806B;
+ GL_PACK_IMAGE_HEIGHT = $806C;
+ GL_UNPACK_SKIP_IMAGES = $806D;
+ GL_UNPACK_IMAGE_HEIGHT = $806E;
+ GL_TEXTURE_3D = $806F;
+ GL_PROXY_TEXTURE_3D = $8070;
+ GL_TEXTURE_DEPTH = $8071;
+ GL_TEXTURE_WRAP_R = $8072;
+ GL_MAX_3D_TEXTURE_SIZE = $8073;
+var
+ glDrawRangeElements: procedure(mode: GLenum; start: GLuint; _end: GLuint; count: GLsizei; _type: GLenum; const indices: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexImage3D: procedure(target: GLenum; level: GLint; internalformat: GLint; width: GLsizei; height: GLsizei; depth: GLsizei; border: GLint; format: GLenum; _type: GLenum; const pixels: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexSubImage3D: procedure(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; zoffset: GLint; width: GLsizei; height: GLsizei; depth: GLsizei; format: GLenum; _type: GLenum; const pixels: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyTexSubImage3D: procedure(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; zoffset: GLint; x: GLint; y: GLint; width: GLsizei; height: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_version_1_2: Boolean;
+
+//***** GL_ARB_imaging *****//
+const
+ GL_CONSTANT_COLOR = $8001;
+ GL_ONE_MINUS_CONSTANT_COLOR = $8002;
+ GL_CONSTANT_ALPHA = $8003;
+ GL_ONE_MINUS_CONSTANT_ALPHA = $8004;
+ GL_BLEND_COLOR = $8005;
+ GL_FUNC_ADD = $8006;
+ GL_MIN = $8007;
+ GL_MAX = $8008;
+ GL_BLEND_EQUATION = $8009;
+ GL_FUNC_SUBTRACT = $800A;
+ GL_FUNC_REVERSE_SUBTRACT = $800B;
+ GL_CONVOLUTION_1D = $8010;
+ GL_CONVOLUTION_2D = $8011;
+ GL_SEPARABLE_2D = $8012;
+ GL_CONVOLUTION_BORDER_MODE = $8013;
+ GL_CONVOLUTION_FILTER_SCALE = $8014;
+ GL_CONVOLUTION_FILTER_BIAS = $8015;
+ GL_REDUCE = $8016;
+ GL_CONVOLUTION_FORMAT = $8017;
+ GL_CONVOLUTION_WIDTH = $8018;
+ GL_CONVOLUTION_HEIGHT = $8019;
+ GL_MAX_CONVOLUTION_WIDTH = $801A;
+ GL_MAX_CONVOLUTION_HEIGHT = $801B;
+ GL_POST_CONVOLUTION_RED_SCALE = $801C;
+ GL_POST_CONVOLUTION_GREEN_SCALE = $801D;
+ GL_POST_CONVOLUTION_BLUE_SCALE = $801E;
+ GL_POST_CONVOLUTION_ALPHA_SCALE = $801F;
+ GL_POST_CONVOLUTION_RED_BIAS = $8020;
+ GL_POST_CONVOLUTION_GREEN_BIAS = $8021;
+ GL_POST_CONVOLUTION_BLUE_BIAS = $8022;
+ GL_POST_CONVOLUTION_ALPHA_BIAS = $8023;
+ GL_HISTOGRAM = $8024;
+ GL_PROXY_HISTOGRAM = $8025;
+ GL_HISTOGRAM_WIDTH = $8026;
+ GL_HISTOGRAM_FORMAT = $8027;
+ GL_HISTOGRAM_RED_SIZE = $8028;
+ GL_HISTOGRAM_GREEN_SIZE = $8029;
+ GL_HISTOGRAM_BLUE_SIZE = $802A;
+ GL_HISTOGRAM_ALPHA_SIZE = $802B;
+ GL_HISTOGRAM_LUMINANCE_SIZE = $802C;
+ GL_HISTOGRAM_SINK = $802D;
+ GL_MINMAX = $802E;
+ GL_MINMAX_FORMAT = $802F;
+ GL_MINMAX_SINK = $8030;
+ GL_TABLE_TOO_LARGE = $8031;
+ GL_COLOR_MATRIX = $80B1;
+ GL_COLOR_MATRIX_STACK_DEPTH = $80B2;
+ GL_MAX_COLOR_MATRIX_STACK_DEPTH = $80B3;
+ GL_POST_COLOR_MATRIX_RED_SCALE = $80B4;
+ GL_POST_COLOR_MATRIX_GREEN_SCALE = $80B5;
+ GL_POST_COLOR_MATRIX_BLUE_SCALE = $80B6;
+ GL_POST_COLOR_MATRIX_ALPHA_SCALE = $80B7;
+ GL_POST_COLOR_MATRIX_RED_BIAS = $80B8;
+ GL_POST_COLOR_MATRIX_GREEN_BIAS = $80B9;
+ GL_POST_COLOR_MATRIX_BLUE_BIAS = $80BA;
+ GL_POST_COLOR_MATIX_ALPHA_BIAS = $80BB;
+ GL_COLOR_TABLE = $80D0;
+ GL_POST_CONVOLUTION_COLOR_TABLE = $80D1;
+ GL_POST_COLOR_MATRIX_COLOR_TABLE = $80D2;
+ GL_PROXY_COLOR_TABLE = $80D3;
+ GL_PROXY_POST_CONVOLUTION_COLOR_TABLE = $80D4;
+ GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE = $80D5;
+ GL_COLOR_TABLE_SCALE = $80D6;
+ GL_COLOR_TABLE_BIAS = $80D7;
+ GL_COLOR_TABLE_FORMAT = $80D8;
+ GL_COLOR_TABLE_WIDTH = $80D9;
+ GL_COLOR_TABLE_RED_SIZE = $80DA;
+ GL_COLOR_TABLE_GREEN_SIZE = $80DB;
+ GL_COLOR_TABLE_BLUE_SIZE = $80DC;
+ GL_COLOR_TABLE_ALPHA_SIZE = $80DD;
+ GL_COLOR_TABLE_LUMINANCE_SIZE = $80DE;
+ GL_COLOR_TABLE_INTENSITY_SIZE = $80DF;
+ GL_IGNORE_BORDER = $8150;
+ GL_CONSTANT_BORDER = $8151;
+ GL_WRAP_BORDER = $8152;
+ GL_REPLICATE_BORDER = $8153;
+ GL_CONVOLUTION_BORDER_COLOR = $8154;
+var
+ glColorTable: procedure(target: GLenum; internalformat: GLenum; width: GLsizei; format: GLenum; _type: GLenum; const table: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColorTableParameterfv: procedure(target: GLenum; pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColorTableParameteriv: procedure(target: GLenum; pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyColorTable: procedure(target: GLenum; internalformat: GLenum; x: GLint; y: GLint; width: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetColorTable: procedure(target: GLenum; format: GLenum; _type: GLenum; table: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetColorTableParameterfv: procedure(target: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetColorTableParameteriv: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColorSubTable: procedure(target: GLenum; start: GLsizei; count: GLsizei; format: GLenum; _type: GLenum; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyColorSubTable: procedure(target: GLenum; start: GLsizei; x: GLint; y: GLint; width: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glConvolutionFilter1D: procedure(target: GLenum; internalformat: GLenum; width: GLsizei; format: GLenum; _type: GLenum; const image: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glConvolutionFilter2D: procedure(target: GLenum; internalformat: GLenum; width: GLsizei; height: GLsizei; format: GLenum; _type: GLenum; const image: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glConvolutionParameterf: procedure(target: GLenum; pname: GLenum; params: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glConvolutionParameterfv: procedure(target: GLenum; pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glConvolutionParameteri: procedure(target: GLenum; pname: GLenum; params: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glConvolutionParameteriv: procedure(target: GLenum; pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyConvolutionFilter1D: procedure(target: GLenum; internalformat: GLenum; x: GLint; y: GLint; width: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyConvolutionFilter2D: procedure(target: GLenum; internalformat: GLenum; x: GLint; y: GLint; width: GLsizei; height: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetConvolutionFilter: procedure(target: GLenum; format: GLenum; _type: GLenum; image: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetConvolutionParameterfv: procedure(target: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetConvolutionParameteriv: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetSeparableFilter: procedure(target: GLenum; format: GLenum; _type: GLenum; row: PGLvoid; column: PGLvoid; span: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSeparableFilter2D: procedure(target: GLenum; internalformat: GLenum; width: GLsizei; height: GLsizei; format: GLenum; _type: GLenum; const row: PGLvoid; const column: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetHistogram: procedure(target: GLenum; reset: GLboolean; format: GLenum; _type: GLenum; values: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetHistogramParameterfv: procedure(target: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetHistogramParameteriv: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMinmax: procedure(target: GLenum; reset: GLboolean; format: GLenum; _type: GLenum; values: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMinmaxParameterfv: procedure(target: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMinmaxParameteriv: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glHistogram: procedure(target: GLenum; width: GLsizei; internalformat: GLenum; sink: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMinmax: procedure(target: GLenum; internalformat: GLenum; sink: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glResetHistogram: procedure(target: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glResetMinmax: procedure(target: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBlendEquation: procedure(mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBlendColor: procedure(red: GLclampf; green: GLclampf; blue: GLclampf; alpha: GLclampf); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_imaging: Boolean;
+
+//***** GL_version_1_3 *****//
+const
+ GL_TEXTURE0 = $84C0;
+ GL_TEXTURE1 = $84C1;
+ GL_TEXTURE2 = $84C2;
+ GL_TEXTURE3 = $84C3;
+ GL_TEXTURE4 = $84C4;
+ GL_TEXTURE5 = $84C5;
+ GL_TEXTURE6 = $84C6;
+ GL_TEXTURE7 = $84C7;
+ GL_TEXTURE8 = $84C8;
+ GL_TEXTURE9 = $84C9;
+ GL_TEXTURE10 = $84CA;
+ GL_TEXTURE11 = $84CB;
+ GL_TEXTURE12 = $84CC;
+ GL_TEXTURE13 = $84CD;
+ GL_TEXTURE14 = $84CE;
+ GL_TEXTURE15 = $84CF;
+ GL_TEXTURE16 = $84D0;
+ GL_TEXTURE17 = $84D1;
+ GL_TEXTURE18 = $84D2;
+ GL_TEXTURE19 = $84D3;
+ GL_TEXTURE20 = $84D4;
+ GL_TEXTURE21 = $84D5;
+ GL_TEXTURE22 = $84D6;
+ GL_TEXTURE23 = $84D7;
+ GL_TEXTURE24 = $84D8;
+ GL_TEXTURE25 = $84D9;
+ GL_TEXTURE26 = $84DA;
+ GL_TEXTURE27 = $84DB;
+ GL_TEXTURE28 = $84DC;
+ GL_TEXTURE29 = $84DD;
+ GL_TEXTURE30 = $84DE;
+ GL_TEXTURE31 = $84DF;
+ GL_ACTIVE_TEXTURE = $84E0;
+ GL_CLIENT_ACTIVE_TEXTURE = $84E1;
+ GL_MAX_TEXTURE_UNITS = $84E2;
+ GL_TRANSPOSE_MODELVIEW_MATRIX = $84E3;
+ GL_TRANSPOSE_PROJECTION_MATRIX = $84E4;
+ GL_TRANSPOSE_TEXTURE_MATRIX = $84E5;
+ GL_TRANSPOSE_COLOR_MATRIX = $84E6;
+ GL_MULTISAMPLE = $809D;
+ GL_SAMPLE_ALPHA_TO_COVERAGE = $809E;
+ GL_SAMPLE_ALPHA_TO_ONE = $809F;
+ GL_SAMPLE_COVERAGE = $80A0;
+ GL_SAMPLE_BUFFERS = $80A8;
+ GL_SAMPLES = $80A9;
+ GL_SAMPLE_COVERAGE_VALUE = $80AA;
+ GL_SAMPLE_COVERAGE_INVERT = $80AB;
+ GL_MULTISAMPLE_BIT = $20000000;
+ GL_NORMAL_MAP = $8511;
+ GL_REFLECTION_MAP = $8512;
+ GL_TEXTURE_CUBE_MAP = $8513;
+ GL_TEXTURE_BINDING_CUBE_MAP = $8514;
+ GL_TEXTURE_CUBE_MAP_POSITIVE_X = $8515;
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_X = $8516;
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Y = $8517;
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = $8518;
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Z = $8519;
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = $851A;
+ GL_PROXY_TEXTURE_CUBE_MAP = $851B;
+ GL_MAX_CUBE_MAP_TEXTURE_SIZE = $851C;
+ GL_COMPRESSED_ALPHA = $84E9;
+ GL_COMPRESSED_LUMINANCE = $84EA;
+ GL_COMPRESSED_LUMINANCE_ALPHA = $84EB;
+ GL_COMPRESSED_INTENSITY = $84EC;
+ GL_COMPRESSED_RGB = $84ED;
+ GL_COMPRESSED_RGBA = $84EE;
+ GL_TEXTURE_COMPRESSION_HINT = $84EF;
+ GL_TEXTURE_COMPRESSED_IMAGE_SIZE = $86A0;
+ GL_TEXTURE_COMPRESSED = $86A1;
+ GL_NUM_COMPRESSED_TEXTURE_FORMATS = $86A2;
+ GL_COMPRESSED_TEXTURE_FORMATS = $86A3;
+ GL_CLAMP_TO_BORDER = $812D;
+ GL_CLAMP_TO_BORDER_SGIS = $812D;
+ GL_COMBINE = $8570;
+ GL_COMBINE_RGB = $8571;
+ GL_COMBINE_ALPHA = $8572;
+ GL_SOURCE0_RGB = $8580;
+ GL_SOURCE1_RGB = $8581;
+ GL_SOURCE2_RGB = $8582;
+ GL_SOURCE0_ALPHA = $8588;
+ GL_SOURCE1_ALPHA = $8589;
+ GL_SOURCE2_ALPHA = $858A;
+ GL_OPERAND0_RGB = $8590;
+ GL_OPERAND1_RGB = $8591;
+ GL_OPERAND2_RGB = $8592;
+ GL_OPERAND0_ALPHA = $8598;
+ GL_OPERAND1_ALPHA = $8599;
+ GL_OPERAND2_ALPHA = $859A;
+ GL_RGB_SCALE = $8573;
+ GL_ADD_SIGNED = $8574;
+ GL_INTERPOLATE = $8575;
+ GL_SUBTRACT = $84E7;
+ GL_CONSTANT = $8576;
+ GL_PRIMARY_COLOR = $8577;
+ GL_PREVIOUS = $8578;
+ GL_DOT3_RGB = $86AE;
+ GL_DOT3_RGBA = $86AF;
+var
+ glActiveTexture: procedure(texture: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glClientActiveTexture: procedure(texture: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1d: procedure(target: GLenum; s: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1dv: procedure(target: GLenum; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1f: procedure(target: GLenum; s: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1fv: procedure(target: GLenum; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1i: procedure(target: GLenum; s: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1iv: procedure(target: GLenum; const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1s: procedure(target: GLenum; s: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1sv: procedure(target: GLenum; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2d: procedure(target: GLenum; s: GLdouble; t: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2dv: procedure(target: GLenum; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2f: procedure(target: GLenum; s: GLfloat; t: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2fv: procedure(target: GLenum; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2i: procedure(target: GLenum; s: GLint; t: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2iv: procedure(target: GLenum; const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2s: procedure(target: GLenum; s: GLshort; t: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2sv: procedure(target: GLenum; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3d: procedure(target: GLenum; s: GLdouble; t: GLdouble; r: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3dv: procedure(target: GLenum; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3f: procedure(target: GLenum; s: GLfloat; t: GLfloat; r: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3fv: procedure(target: GLenum; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3i: procedure(target: GLenum; s: GLint; t: GLint; r: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3iv: procedure(target: GLenum; const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3s: procedure(target: GLenum; s: GLshort; t: GLshort; r: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3sv: procedure(target: GLenum; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4d: procedure(target: GLenum; s: GLdouble; t: GLdouble; r: GLdouble; q: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4dv: procedure(target: GLenum; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4f: procedure(target: GLenum; s: GLfloat; t: GLfloat; r: GLfloat; q: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4fv: procedure(target: GLenum; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4i: procedure(target: GLenum; s: GLint; t: GLint; r: GLint; q: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4iv: procedure(target: GLenum; const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4s: procedure(target: GLenum; s: GLshort; t: GLshort; r: GLshort; q: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4sv: procedure(target: GLenum; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLoadTransposeMatrixf: procedure(const m: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLoadTransposeMatrixd: procedure(const m: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultTransposeMatrixf: procedure(const m: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultTransposeMatrixd: procedure(const m: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSampleCoverage: procedure(value: GLclampf; invert: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompressedTexImage3D: procedure(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; height: GLsizei; depth: GLsizei; border: GLint; imageSize: GLsizei; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompressedTexImage2D: procedure(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; height: GLsizei; border: GLint; imageSize: GLsizei; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompressedTexImage1D: procedure(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; border: GLint; imageSize: GLsizei; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompressedTexSubImage3D: procedure(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; zoffset: GLint; width: GLsizei; height: GLsizei; depth: GLsizei; format: GLenum; imageSize: GLsizei; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompressedTexSubImage2D: procedure(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; width: GLsizei; height: GLsizei; format: GLenum; imageSize: GLsizei; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompressedTexSubImage1D: procedure(target: GLenum; level: GLint; xoffset: GLint; width: GLsizei; format: GLenum; imageSize: GLsizei; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetCompressedTexImage: procedure(target: GLenum; level: GLint; img: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_version_1_3: Boolean;
+
+//***** GL_ARB_multitexture *****//
+const
+ GL_TEXTURE0_ARB = $84C0;
+ GL_TEXTURE1_ARB = $84C1;
+ GL_TEXTURE2_ARB = $84C2;
+ GL_TEXTURE3_ARB = $84C3;
+ GL_TEXTURE4_ARB = $84C4;
+ GL_TEXTURE5_ARB = $84C5;
+ GL_TEXTURE6_ARB = $84C6;
+ GL_TEXTURE7_ARB = $84C7;
+ GL_TEXTURE8_ARB = $84C8;
+ GL_TEXTURE9_ARB = $84C9;
+ GL_TEXTURE10_ARB = $84CA;
+ GL_TEXTURE11_ARB = $84CB;
+ GL_TEXTURE12_ARB = $84CC;
+ GL_TEXTURE13_ARB = $84CD;
+ GL_TEXTURE14_ARB = $84CE;
+ GL_TEXTURE15_ARB = $84CF;
+ GL_TEXTURE16_ARB = $84D0;
+ GL_TEXTURE17_ARB = $84D1;
+ GL_TEXTURE18_ARB = $84D2;
+ GL_TEXTURE19_ARB = $84D3;
+ GL_TEXTURE20_ARB = $84D4;
+ GL_TEXTURE21_ARB = $84D5;
+ GL_TEXTURE22_ARB = $84D6;
+ GL_TEXTURE23_ARB = $84D7;
+ GL_TEXTURE24_ARB = $84D8;
+ GL_TEXTURE25_ARB = $84D9;
+ GL_TEXTURE26_ARB = $84DA;
+ GL_TEXTURE27_ARB = $84DB;
+ GL_TEXTURE28_ARB = $84DC;
+ GL_TEXTURE29_ARB = $84DD;
+ GL_TEXTURE30_ARB = $84DE;
+ GL_TEXTURE31_ARB = $84DF;
+ GL_ACTIVE_TEXTURE_ARB = $84E0;
+ GL_CLIENT_ACTIVE_TEXTURE_ARB = $84E1;
+ GL_MAX_TEXTURE_UNITS_ARB = $84E2;
+var
+ glActiveTextureARB: procedure(texture: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glClientActiveTextureARB: procedure(texture: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1dARB: procedure(target: GLenum; s: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1dvARB: procedure(target: GLenum; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1fARB: procedure(target: GLenum; s: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1fvARB: procedure(target: GLenum; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1iARB: procedure(target: GLenum; s: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1ivARB: procedure(target: GLenum; const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1sARB: procedure(target: GLenum; s: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1svARB: procedure(target: GLenum; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2dARB: procedure(target: GLenum; s: GLdouble; t: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2dvARB: procedure(target: GLenum; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2fARB: procedure(target: GLenum; s: GLfloat; t: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2fvARB: procedure(target: GLenum; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2iARB: procedure(target: GLenum; s: GLint; t: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2ivARB: procedure(target: GLenum; const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2sARB: procedure(target: GLenum; s: GLshort; t: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2svARB: procedure(target: GLenum; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3dARB: procedure(target: GLenum; s: GLdouble; t: GLdouble; r: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3dvARB: procedure(target: GLenum; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3fARB: procedure(target: GLenum; s: GLfloat; t: GLfloat; r: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3fvARB: procedure(target: GLenum; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3iARB: procedure(target: GLenum; s: GLint; t: GLint; r: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3ivARB: procedure(target: GLenum; const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3sARB: procedure(target: GLenum; s: GLshort; t: GLshort; r: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3svARB: procedure(target: GLenum; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4dARB: procedure(target: GLenum; s: GLdouble; t: GLdouble; r: GLdouble; q: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4dvARB: procedure(target: GLenum; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4fARB: procedure(target: GLenum; s: GLfloat; t: GLfloat; r: GLfloat; q: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4fvARB: procedure(target: GLenum; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4iARB: procedure(target: GLenum; s: GLint; t: GLint; r: GLint; q: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4ivARB: procedure(target: GLenum; const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4sARB: procedure(target: GLenum; s: GLshort; t: GLshort; r: GLshort; q: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4svARB: procedure(target: GLenum; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_multitexture: Boolean;
+
+//***** GL_ARB_transpose_matrix *****//
+const
+ GL_TRANSPOSE_MODELVIEW_MATRIX_ARB = $84E3;
+ GL_TRANSPOSE_PROJECTION_MATRIX_ARB = $84E4;
+ GL_TRANSPOSE_TEXTURE_MATRIX_ARB = $84E5;
+ GL_TRANSPOSE_COLOR_MATRIX_ARB = $84E6;
+var
+ glLoadTransposeMatrixfARB: procedure(m: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLoadTransposeMatrixdARB: procedure(m: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultTransposeMatrixfARB: procedure(m: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultTransposeMatrixdARB: procedure(m: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_transpose_matrix: Boolean;
+
+//***** GL_ARB_multisample *****//
+const
+ WGL_SAMPLE_BUFFERS_ARB = $2041;
+ WGL_SAMPLES_ARB = $2042;
+ GL_MULTISAMPLE_ARB = $809D;
+ GL_SAMPLE_ALPHA_TO_COVERAGE_ARB = $809E;
+ GL_SAMPLE_ALPHA_TO_ONE_ARB = $809F;
+ GL_SAMPLE_COVERAGE_ARB = $80A0;
+ GL_MULTISAMPLE_BIT_ARB = $20000000;
+ GL_SAMPLE_BUFFERS_ARB = $80A8;
+ GL_SAMPLES_ARB = $80A9;
+ GL_SAMPLE_COVERAGE_VALUE_ARB = $80AA;
+ GL_SAMPLE_COVERAGE_INVERT_ARB = $80AB;
+var
+ glSampleCoverageARB: procedure(value: GLclampf; invert: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_multisample: Boolean;
+
+//***** GL_ARB_texture_env_add *****//
+
+function Load_GL_ARB_texture_env_add: Boolean;
+
+{$IFDEF WINDOWS}
+//***** WGL_ARB_extensions_string *****//
+var
+ wglGetExtensionsStringARB: function(hdc: HDC): Pchar; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_ARB_extensions_string: Boolean;
+
+//***** WGL_ARB_buffer_region *****//
+const
+ WGL_FRONT_COLOR_BUFFER_BIT_ARB = $0001;
+ WGL_BACK_COLOR_BUFFER_BIT_ARB = $0002;
+ WGL_DEPTH_BUFFER_BIT_ARB = $0004;
+ WGL_STENCIL_BUFFER_BIT_ARB = $0008;
+var
+ wglCreateBufferRegionARB: function(hDC: HDC; iLayerPlane: GLint; uType: GLuint): THandle; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglDeleteBufferRegionARB: procedure(hRegion: THandle); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglSaveBufferRegionARB: function(hRegion: THandle; x: GLint; y: GLint; width: GLint; height: GLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglRestoreBufferRegionARB: function(hRegion: THandle; x: GLint; y: GLint; width: GLint; height: GLint; xSrc: GLint; ySrc: GLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_ARB_buffer_region: Boolean;
+{$ENDIF}
+
+//***** GL_ARB_texture_cube_map *****//
+const
+ GL_NORMAL_MAP_ARB = $8511;
+ GL_REFLECTION_MAP_ARB = $8512;
+ GL_TEXTURE_CUBE_MAP_ARB = $8513;
+ GL_TEXTURE_BINDING_CUBE_MAP_ARB = $8514;
+ GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB = $8515;
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = $8516;
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = $8517;
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = $8518;
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = $8519;
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = $851A;
+ GL_PROXY_TEXTURE_CUBE_MAP_ARB = $851B;
+ GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB = $851C;
+
+function Load_GL_ARB_texture_cube_map: Boolean;
+
+//***** GL_ARB_depth_texture *****//
+const
+ GL_DEPTH_COMPONENT16_ARB = $81A5;
+ GL_DEPTH_COMPONENT24_ARB = $81A6;
+ GL_DEPTH_COMPONENT32_ARB = $81A7;
+ GL_TEXTURE_DEPTH_SIZE_ARB = $884A;
+ GL_DEPTH_TEXTURE_MODE_ARB = $884B;
+
+function Load_GL_ARB_depth_texture: Boolean;
+
+//***** GL_ARB_point_parameters *****//
+const
+ GL_POINT_SIZE_MIN_ARB = $8126;
+ GL_POINT_SIZE_MAX_ARB = $8127;
+ GL_POINT_FADE_THRESHOLD_SIZE_ARB = $8128;
+ GL_POINT_DISTANCE_ATTENUATION_ARB = $8129;
+var
+ glPointParameterfARB: procedure(pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPointParameterfvARB: procedure(pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_point_parameters: Boolean;
+
+//***** GL_ARB_shadow *****//
+const
+ GL_TEXTURE_COMPARE_MODE_ARB = $884C;
+ GL_TEXTURE_COMPARE_FUNC_ARB = $884D;
+ GL_COMPARE_R_TO_TEXTURE_ARB = $884E;
+
+function Load_GL_ARB_shadow: Boolean;
+
+//***** GL_ARB_shadow_ambient *****//
+const
+ GL_TEXTURE_COMPARE_FAIL_VALUE_ARB = $80BF;
+
+function Load_GL_ARB_shadow_ambient: Boolean;
+
+//***** GL_ARB_texture_border_clamp *****//
+const
+ GL_CLAMP_TO_BORDER_ARB = $812D;
+
+function Load_GL_ARB_texture_border_clamp: Boolean;
+
+//***** GL_ARB_texture_compression *****//
+const
+ GL_COMPRESSED_ALPHA_ARB = $84E9;
+ GL_COMPRESSED_LUMINANCE_ARB = $84EA;
+ GL_COMPRESSED_LUMINANCE_ALPHA_ARB = $84EB;
+ GL_COMPRESSED_INTENSITY_ARB = $84EC;
+ GL_COMPRESSED_RGB_ARB = $84ED;
+ GL_COMPRESSED_RGBA_ARB = $84EE;
+ GL_TEXTURE_COMPRESSION_HINT_ARB = $84EF;
+ GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB = $86A0;
+ GL_TEXTURE_COMPRESSED_ARB = $86A1;
+ GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB = $86A2;
+ GL_COMPRESSED_TEXTURE_FORMATS_ARB = $86A3;
+var
+ glCompressedTexImage3DARB: procedure(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; height: GLsizei; depth: GLsizei; border: GLint; imageSize: GLsizei; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompressedTexImage2DARB: procedure(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; height: GLsizei; border: GLint; imageSize: GLsizei; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompressedTexImage1DARB: procedure(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; border: GLint; imageSize: GLsizei; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompressedTexSubImage3DARB: procedure(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; zoffset: GLint; width: GLsizei; height: GLsizei; depth: GLsizei; format: GLenum; imageSize: GLsizei; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompressedTexSubImage2DARB: procedure(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; width: GLsizei; height: GLsizei; format: GLenum; imageSize: GLsizei; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompressedTexSubImage1DARB: procedure(target: GLenum; level: GLint; xoffset: GLint; width: GLsizei; format: GLenum; imageSize: GLsizei; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetCompressedTexImageARB: procedure(target: GLenum; lod: GLint; img: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_texture_compression: Boolean;
+
+//***** GL_ARB_texture_env_combine *****//
+const
+ GL_COMBINE_ARB = $8570;
+ GL_COMBINE_RGB_ARB = $8571;
+ GL_COMBINE_ALPHA_ARB = $8572;
+ GL_SOURCE0_RGB_ARB = $8580;
+ GL_SOURCE1_RGB_ARB = $8581;
+ GL_SOURCE2_RGB_ARB = $8582;
+ GL_SOURCE0_ALPHA_ARB = $8588;
+ GL_SOURCE1_ALPHA_ARB = $8589;
+ GL_SOURCE2_ALPHA_ARB = $858A;
+ GL_OPERAND0_RGB_ARB = $8590;
+ GL_OPERAND1_RGB_ARB = $8591;
+ GL_OPERAND2_RGB_ARB = $8592;
+ GL_OPERAND0_ALPHA_ARB = $8598;
+ GL_OPERAND1_ALPHA_ARB = $8599;
+ GL_OPERAND2_ALPHA_ARB = $859A;
+ GL_RGB_SCALE_ARB = $8573;
+ GL_ADD_SIGNED_ARB = $8574;
+ GL_INTERPOLATE_ARB = $8575;
+ GL_SUBTRACT_ARB = $84E7;
+ GL_CONSTANT_ARB = $8576;
+ GL_PRIMARY_COLOR_ARB = $8577;
+ GL_PREVIOUS_ARB = $8578;
+
+function Load_GL_ARB_texture_env_combine: Boolean;
+
+//***** GL_ARB_texture_env_crossbar *****//
+
+function Load_GL_ARB_texture_env_crossbar: Boolean;
+
+//***** GL_ARB_texture_env_dot3 *****//
+const
+ GL_DOT3_RGB_ARB = $86AE;
+ GL_DOT3_RGBA_ARB = $86AF;
+
+function Load_GL_ARB_texture_env_dot3: Boolean;
+
+//***** GL_ARB_texture_mirrored_repeat *****//
+const
+ GL_MIRRORED_REPEAT_ARB = $8370;
+
+function Load_GL_ARB_texture_mirrored_repeat: Boolean;
+
+//***** GL_ARB_vertex_blend *****//
+const
+ GL_MAX_VERTEX_UNITS_ARB = $86A4;
+ GL_ACTIVE_VERTEX_UNITS_ARB = $86A5;
+ GL_WEIGHT_SUM_UNITY_ARB = $86A6;
+ GL_VERTEX_BLEND_ARB = $86A7;
+ GL_MODELVIEW0_ARB = $1700;
+ GL_MODELVIEW1_ARB = $850A;
+ GL_MODELVIEW2_ARB = $8722;
+ GL_MODELVIEW3_ARB = $8723;
+ GL_MODELVIEW4_ARB = $8724;
+ GL_MODELVIEW5_ARB = $8725;
+ GL_MODELVIEW6_ARB = $8726;
+ GL_MODELVIEW7_ARB = $8727;
+ GL_MODELVIEW8_ARB = $8728;
+ GL_MODELVIEW9_ARB = $8729;
+ GL_MODELVIEW10_ARB = $872A;
+ GL_MODELVIEW11_ARB = $872B;
+ GL_MODELVIEW12_ARB = $872C;
+ GL_MODELVIEW13_ARB = $872D;
+ GL_MODELVIEW14_ARB = $872E;
+ GL_MODELVIEW15_ARB = $872F;
+ GL_MODELVIEW16_ARB = $8730;
+ GL_MODELVIEW17_ARB = $8731;
+ GL_MODELVIEW18_ARB = $8732;
+ GL_MODELVIEW19_ARB = $8733;
+ GL_MODELVIEW20_ARB = $8734;
+ GL_MODELVIEW21_ARB = $8735;
+ GL_MODELVIEW22_ARB = $8736;
+ GL_MODELVIEW23_ARB = $8737;
+ GL_MODELVIEW24_ARB = $8738;
+ GL_MODELVIEW25_ARB = $8739;
+ GL_MODELVIEW26_ARB = $873A;
+ GL_MODELVIEW27_ARB = $873B;
+ GL_MODELVIEW28_ARB = $873C;
+ GL_MODELVIEW29_ARB = $873D;
+ GL_MODELVIEW30_ARB = $873E;
+ GL_MODELVIEW31_ARB = $873F;
+ GL_CURRENT_WEIGHT_ARB = $86A8;
+ GL_WEIGHT_ARRAY_TYPE_ARB = $86A9;
+ GL_WEIGHT_ARRAY_STRIDE_ARB = $86AA;
+ GL_WEIGHT_ARRAY_SIZE_ARB = $86AB;
+ GL_WEIGHT_ARRAY_POINTER_ARB = $86AC;
+ GL_WEIGHT_ARRAY_ARB = $86AD;
+var
+ glWeightbvARB: procedure(size: GLint; weights: PGLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWeightsvARB: procedure(size: GLint; weights: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWeightivARB: procedure(size: GLint; weights: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWeightfvARB: procedure(size: GLint; weights: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWeightdvARB: procedure(size: GLint; weights: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWeightvARB: procedure(size: GLint; weights: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWeightubvARB: procedure(size: GLint; weights: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWeightusvARB: procedure(size: GLint; weights: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWeightuivARB: procedure(size: GLint; weights: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWeightPointerARB: procedure(size: GLint; _type: GLenum; stride: GLsizei; pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexBlendARB: procedure(count: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_vertex_blend: Boolean;
+
+//***** GL_ARB_vertex_program *****//
+const
+ GL_VERTEX_PROGRAM_ARB = $8620;
+ GL_VERTEX_PROGRAM_POINT_SIZE_ARB = $8642;
+ GL_VERTEX_PROGRAM_TWO_SIDE_ARB = $8643;
+ GL_COLOR_SUM_ARB = $8458;
+ GL_PROGRAM_FORMAT_ASCII_ARB = $8875;
+ GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB = $8622;
+ GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB = $8623;
+ GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB = $8624;
+ GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB = $8625;
+ GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB = $886A;
+ GL_CURRENT_VERTEX_ATTRIB_ARB = $8626;
+ GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB = $8645;
+ GL_PROGRAM_LENGTH_ARB = $8627;
+ GL_PROGRAM_FORMAT_ARB = $8876;
+ GL_PROGRAM_BINDING_ARB = $8677;
+ GL_PROGRAM_INSTRUCTIONS_ARB = $88A0;
+ GL_MAX_PROGRAM_INSTRUCTIONS_ARB = $88A1;
+ GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB = $88A2;
+ GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB = $88A3;
+ GL_PROGRAM_TEMPORARIES_ARB = $88A4;
+ GL_MAX_PROGRAM_TEMPORARIES_ARB = $88A5;
+ GL_PROGRAM_NATIVE_TEMPORARIES_ARB = $88A6;
+ GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB = $88A7;
+ GL_PROGRAM_PARAMETERS_ARB = $88A8;
+ GL_MAX_PROGRAM_PARAMETERS_ARB = $88A9;
+ GL_PROGRAM_NATIVE_PARAMETERS_ARB = $88AA;
+ GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB = $88AB;
+ GL_PROGRAM_ATTRIBS_ARB = $88AC;
+ GL_MAX_PROGRAM_ATTRIBS_ARB = $88AD;
+ GL_PROGRAM_NATIVE_ATTRIBS_ARB = $88AE;
+ GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB = $88AF;
+ GL_PROGRAM_ADDRESS_REGISTERS_ARB = $88B0;
+ GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB = $88B1;
+ GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB = $88B2;
+ GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB = $88B3;
+ GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB = $88B4;
+ GL_MAX_PROGRAM_ENV_PARAMETERS_ARB = $88B5;
+ GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB = $88B6;
+ GL_PROGRAM_STRING_ARB = $8628;
+ GL_PROGRAM_ERROR_POSITION_ARB = $864B;
+ GL_CURRENT_MATRIX_ARB = $8641;
+ GL_TRANSPOSE_CURRENT_MATRIX_ARB = $88B7;
+ GL_CURRENT_MATRIX_STACK_DEPTH_ARB = $8640;
+ GL_MAX_VERTEX_ATTRIBS_ARB = $8869;
+ GL_MAX_PROGRAM_MATRICES_ARB = $862F;
+ GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB = $862E;
+ GL_PROGRAM_ERROR_STRING_ARB = $8874;
+ GL_MATRIX0_ARB = $88C0;
+ GL_MATRIX1_ARB = $88C1;
+ GL_MATRIX2_ARB = $88C2;
+ GL_MATRIX3_ARB = $88C3;
+ GL_MATRIX4_ARB = $88C4;
+ GL_MATRIX5_ARB = $88C5;
+ GL_MATRIX6_ARB = $88C6;
+ GL_MATRIX7_ARB = $88C7;
+ GL_MATRIX8_ARB = $88C8;
+ GL_MATRIX9_ARB = $88C9;
+ GL_MATRIX10_ARB = $88CA;
+ GL_MATRIX11_ARB = $88CB;
+ GL_MATRIX12_ARB = $88CC;
+ GL_MATRIX13_ARB = $88CD;
+ GL_MATRIX14_ARB = $88CE;
+ GL_MATRIX15_ARB = $88CF;
+ GL_MATRIX16_ARB = $88D0;
+ GL_MATRIX17_ARB = $88D1;
+ GL_MATRIX18_ARB = $88D2;
+ GL_MATRIX19_ARB = $88D3;
+ GL_MATRIX20_ARB = $88D4;
+ GL_MATRIX21_ARB = $88D5;
+ GL_MATRIX22_ARB = $88D6;
+ GL_MATRIX23_ARB = $88D7;
+ GL_MATRIX24_ARB = $88D8;
+ GL_MATRIX25_ARB = $88D9;
+ GL_MATRIX26_ARB = $88DA;
+ GL_MATRIX27_ARB = $88DB;
+ GL_MATRIX28_ARB = $88DC;
+ GL_MATRIX29_ARB = $88DD;
+ GL_MATRIX30_ARB = $88DE;
+ GL_MATRIX31_ARB = $88DF;
+var
+ glVertexAttrib1sARB: procedure(index: GLuint; x: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1fARB: procedure(index: GLuint; x: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1dARB: procedure(index: GLuint; x: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2sARB: procedure(index: GLuint; x: GLshort; y: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2fARB: procedure(index: GLuint; x: GLfloat; y: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2dARB: procedure(index: GLuint; x: GLdouble; y: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3sARB: procedure(index: GLuint; x: GLshort; y: GLshort; z: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3fARB: procedure(index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3dARB: procedure(index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4sARB: procedure(index: GLuint; x: GLshort; y: GLshort; z: GLshort; w: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4fARB: procedure(index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4dARB: procedure(index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4NubARB: procedure(index: GLuint; x: GLubyte; y: GLubyte; z: GLubyte; w: GLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1svARB: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1fvARB: procedure(index: GLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1dvARB: procedure(index: GLuint; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2svARB: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2fvARB: procedure(index: GLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2dvARB: procedure(index: GLuint; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3svARB: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3fvARB: procedure(index: GLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3dvARB: procedure(index: GLuint; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4bvARB: procedure(index: GLuint; const v: PGLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4svARB: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4ivARB: procedure(index: GLuint; const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4ubvARB: procedure(index: GLuint; const v: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4usvARB: procedure(index: GLuint; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4uivARB: procedure(index: GLuint; const v: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4fvARB: procedure(index: GLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4dvARB: procedure(index: GLuint; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4NbvARB: procedure(index: GLuint; const v: PGLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4NsvARB: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4NivARB: procedure(index: GLuint; const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4NubvARB: procedure(index: GLuint; const v: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4NusvARB: procedure(index: GLuint; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4NuivARB: procedure(index: GLuint; const v: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribPointerARB: procedure(index: GLuint; size: GLint; _type: GLenum; normalized: GLboolean; stride: GLsizei; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEnableVertexAttribArrayARB: procedure(index: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDisableVertexAttribArrayARB: procedure(index: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramStringARB: procedure(target: GLenum; format: GLenum; len: GLsizei; const _string: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindProgramARB: procedure(target: GLenum; _program: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteProgramsARB: procedure(n: GLsizei; const programs: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGenProgramsARB: procedure(n: GLsizei; programs: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramEnvParameter4dARB: procedure(target: GLenum; index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramEnvParameter4dvARB: procedure(target: GLenum; index: GLuint; const params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramEnvParameter4fARB: procedure(target: GLenum; index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramEnvParameter4fvARB: procedure(target: GLenum; index: GLuint; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramLocalParameter4dARB: procedure(target: GLenum; index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramLocalParameter4dvARB: procedure(target: GLenum; index: GLuint; const params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramLocalParameter4fARB: procedure(target: GLenum; index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramLocalParameter4fvARB: procedure(target: GLenum; index: GLuint; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramEnvParameterdvARB: procedure(target: GLenum; index: GLuint; params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramEnvParameterfvARB: procedure(target: GLenum; index: GLuint; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramLocalParameterdvARB: procedure(target: GLenum; index: GLuint; params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramLocalParameterfvARB: procedure(target: GLenum; index: GLuint; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramivARB: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramStringARB: procedure(target: GLenum; pname: GLenum; _string: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribdvARB: procedure(index: GLuint; pname: GLenum; params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribfvARB: procedure(index: GLuint; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribivARB: procedure(index: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribPointervARB: procedure(index: GLuint; pname: GLenum; pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsProgramARB: function(_program: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_vertex_program: Boolean;
+
+//***** GL_ARB_window_pos *****//
+var
+ glWindowPos2dARB: procedure(x: GLdouble; y: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2fARB: procedure(x: GLfloat; y: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2iARB: procedure(x: GLint; y: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2sARB: procedure(x: GLshort; y: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2dvARB: procedure(const p: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2fvARB: procedure(const p: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2ivARB: procedure(const p: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2svARB: procedure(const p: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3dARB: procedure(x: GLdouble; y: GLdouble; z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3fARB: procedure(x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3iARB: procedure(x: GLint; y: GLint; z: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3sARB: procedure(x: GLshort; y: GLshort; z: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3dvARB: procedure(const p: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3fvARB: procedure(const p: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3ivARB: procedure(const p: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3svARB: procedure(const p: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_window_pos: Boolean;
+
+//***** GL_EXT_422_pixels *****//
+const
+ GL_422_EXT = $80CC;
+ GL_422_REV_EXT = $80CD;
+ GL_422_AVERAGE_EXT = $80CE;
+ GL_422_REV_AVERAGE_EXT = $80CF;
+
+function Load_GL_EXT_422_pixels: Boolean;
+
+//***** GL_EXT_abgr *****//
+const
+ GL_ABGR_EXT = $8000;
+
+function Load_GL_EXT_abgr: Boolean;
+
+//***** GL_EXT_bgra *****//
+const
+ GL_BGR_EXT = $80E0;
+ GL_BGRA_EXT = $80E1;
+
+function Load_GL_EXT_bgra: Boolean;
+
+//***** GL_EXT_blend_color *****//
+const
+ GL_CONSTANT_COLOR_EXT = $8001;
+ GL_ONE_MINUS_CONSTANT_COLOR_EXT = $8002;
+ GL_CONSTANT_ALPHA_EXT = $8003;
+ GL_ONE_MINUS_CONSTANT_ALPHA_EXT = $8004;
+ GL_BLEND_COLOR_EXT = $8005;
+var
+ glBlendColorEXT: procedure(red: GLclampf; green: GLclampf; blue: GLclampf; alpha: GLclampf); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_blend_color: Boolean;
+
+//***** GL_EXT_blend_func_separate *****//
+const
+ GL_BLEND_DST_RGB_EXT = $80C8;
+ GL_BLEND_SRC_RGB_EXT = $80C9;
+ GL_BLEND_DST_ALPHA_EXT = $80CA;
+ GL_BLEND_SRC_ALPHA_EXT = $80CB;
+var
+ glBlendFuncSeparateEXT: procedure(sfactorRGB: GLenum; dfactorRGB: GLenum; sfactorAlpha: GLenum; dfactorAlpha: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_blend_func_separate: Boolean;
+
+//***** GL_EXT_blend_logic_op *****//
+
+function Load_GL_EXT_blend_logic_op: Boolean;
+
+//***** GL_EXT_blend_minmax *****//
+const
+ GL_FUNC_ADD_EXT = $8006;
+ GL_MIN_EXT = $8007;
+ GL_MAX_EXT = $8008;
+ GL_BLEND_EQUATION_EXT = $8009;
+var
+ glBlendEquationEXT: procedure(mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_blend_minmax: Boolean;
+
+//***** GL_EXT_blend_subtract *****//
+const
+ GL_FUNC_SUBTRACT_EXT = $800A;
+ GL_FUNC_REVERSE_SUBTRACT_EXT = $800B;
+
+function Load_GL_EXT_blend_subtract: Boolean;
+
+//***** GL_EXT_clip_volume_hint *****//
+const
+ GL_CLIP_VOLUME_CLIPPING_HINT_EXT = $80F0;
+
+function Load_GL_EXT_clip_volume_hint: Boolean;
+
+//***** GL_EXT_color_subtable *****//
+var
+ glColorSubTableEXT: procedure(target: GLenum; start: GLsizei; count: GLsizei; format: GLenum; _type: GLenum; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyColorSubTableEXT: procedure(target: GLenum; start: GLsizei; x: GLint; y: GLint; width: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_color_subtable: Boolean;
+
+//***** GL_EXT_compiled_vertex_array *****//
+const
+ GL_ARRAY_ELEMENT_LOCK_FIRST_EXT = $81A8;
+ GL_ARRAY_ELEMENT_LOCK_COUNT_EXT = $81A9;
+var
+ glLockArraysEXT: procedure(first: GLint; count: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUnlockArraysEXT: procedure(); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_compiled_vertex_array: Boolean;
+
+//***** GL_EXT_convolution *****//
+const
+ GL_CONVOLUTION_1D_EXT = $8010;
+ GL_CONVOLUTION_2D_EXT = $8011;
+ GL_SEPARABLE_2D_EXT = $8012;
+ GL_CONVOLUTION_BORDER_MODE_EXT = $8013;
+ GL_CONVOLUTION_FILTER_SCALE_EXT = $8014;
+ GL_CONVOLUTION_FILTER_BIAS_EXT = $8015;
+ GL_REDUCE_EXT = $8016;
+ GL_CONVOLUTION_FORMAT_EXT = $8017;
+ GL_CONVOLUTION_WIDTH_EXT = $8018;
+ GL_CONVOLUTION_HEIGHT_EXT = $8019;
+ GL_MAX_CONVOLUTION_WIDTH_EXT = $801A;
+ GL_MAX_CONVOLUTION_HEIGHT_EXT = $801B;
+ GL_POST_CONVOLUTION_RED_SCALE_EXT = $801C;
+ GL_POST_CONVOLUTION_GREEN_SCALE_EXT = $801D;
+ GL_POST_CONVOLUTION_BLUE_SCALE_EXT = $801E;
+ GL_POST_CONVOLUTION_ALPHA_SCALE_EXT = $801F;
+ GL_POST_CONVOLUTION_RED_BIAS_EXT = $8020;
+ GL_POST_CONVOLUTION_GREEN_BIAS_EXT = $8021;
+ GL_POST_CONVOLUTION_BLUE_BIAS_EXT = $8022;
+ GL_POST_CONVOLUTION_ALPHA_BIAS_EXT = $8023;
+var
+ glConvolutionFilter1DEXT: procedure(target: GLenum; internalformat: GLenum; width: GLsizei; format: GLenum; _type: GLenum; const image: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glConvolutionFilter2DEXT: procedure(target: GLenum; internalformat: GLenum; width: GLsizei; height: GLsizei; format: GLenum; _type: GLenum; const image: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyConvolutionFilter1DEXT: procedure(target: GLenum; internalformat: GLenum; x: GLint; y: GLint; width: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyConvolutionFilter2DEXT: procedure(target: GLenum; internalformat: GLenum; x: GLint; y: GLint; width: GLsizei; height: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetConvolutionFilterEXT: procedure(target: GLenum; format: GLenum; _type: GLenum; image: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSeparableFilter2DEXT: procedure(target: GLenum; internalformat: GLenum; width: GLsizei; height: GLsizei; format: GLenum; _type: GLenum; const row: PGLvoid; const column: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetSeparableFilterEXT: procedure(target: GLenum; format: GLenum; _type: GLenum; row: PGLvoid; column: PGLvoid; span: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glConvolutionParameteriEXT: procedure(target: GLenum; pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glConvolutionParameterivEXT: procedure(target: GLenum; pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glConvolutionParameterfEXT: procedure(target: GLenum; pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glConvolutionParameterfvEXT: procedure(target: GLenum; pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetConvolutionParameterivEXT: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetConvolutionParameterfvEXT: procedure(target: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_convolution: Boolean;
+
+//***** GL_EXT_histogram *****//
+const
+ GL_HISTOGRAM_EXT = $8024;
+ GL_PROXY_HISTOGRAM_EXT = $8025;
+ GL_HISTOGRAM_WIDTH_EXT = $8026;
+ GL_HISTOGRAM_FORMAT_EXT = $8027;
+ GL_HISTOGRAM_RED_SIZE_EXT = $8028;
+ GL_HISTOGRAM_GREEN_SIZE_EXT = $8029;
+ GL_HISTOGRAM_BLUE_SIZE_EXT = $802A;
+ GL_HISTOGRAM_ALPHA_SIZE_EXT = $802B;
+ GL_HISTOGRAM_LUMINANCE_SIZE_EXT = $802C;
+ GL_HISTOGRAM_SINK_EXT = $802D;
+ GL_MINMAX_EXT = $802E;
+ GL_MINMAX_FORMAT_EXT = $802F;
+ GL_MINMAX_SINK_EXT = $8030;
+var
+ glHistogramEXT: procedure(target: GLenum; width: GLsizei; internalformat: GLenum; sink: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glResetHistogramEXT: procedure(target: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetHistogramEXT: procedure(target: GLenum; reset: GLboolean; format: GLenum; _type: GLenum; values: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetHistogramParameterivEXT: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetHistogramParameterfvEXT: procedure(target: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMinmaxEXT: procedure(target: GLenum; internalformat: GLenum; sink: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glResetMinmaxEXT: procedure(target: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMinmaxEXT: procedure(target: GLenum; reset: GLboolean; format: GLenum; _type: GLenum; values: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMinmaxParameterivEXT: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMinmaxParameterfvEXT: procedure(target: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_histogram: Boolean;
+
+//***** GL_EXT_multi_draw_arrays *****//
+var
+ glMultiDrawArraysEXT: procedure(mode: GLenum; first: PGLint; count: PGLsizei; primcount: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiDrawElementsEXT: procedure(mode: GLenum; count: PGLsizei; _type: GLenum; const indices: PGLvoid; primcount: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_multi_draw_arrays: Boolean;
+
+//***** GL_EXT_packed_pixels *****//
+const
+ GL_UNSIGNED_BYTE_3_3_2_EXT = $8032;
+ GL_UNSIGNED_SHORT_4_4_4_4_EXT = $8033;
+ GL_UNSIGNED_SHORT_5_5_5_1_EXT = $8034;
+ GL_UNSIGNED_INT_8_8_8_8_EXT = $8035;
+ GL_UNSIGNED_INT_10_10_10_2_EXT = $8036;
+
+function Load_GL_EXT_packed_pixels: Boolean;
+
+//***** GL_EXT_paletted_texture *****//
+const
+ GL_COLOR_INDEX1_EXT = $80E2;
+ GL_COLOR_INDEX2_EXT = $80E3;
+ GL_COLOR_INDEX4_EXT = $80E4;
+ GL_COLOR_INDEX8_EXT = $80E5;
+ GL_COLOR_INDEX12_EXT = $80E6;
+ GL_COLOR_INDEX16_EXT = $80E7;
+ GL_COLOR_TABLE_FORMAT_EXT = $80D8;
+ GL_COLOR_TABLE_WIDTH_EXT = $80D9;
+ GL_COLOR_TABLE_RED_SIZE_EXT = $80DA;
+ GL_COLOR_TABLE_GREEN_SIZE_EXT = $80DB;
+ GL_COLOR_TABLE_BLUE_SIZE_EXT = $80DC;
+ GL_COLOR_TABLE_ALPHA_SIZE_EXT = $80DD;
+ GL_COLOR_TABLE_LUMINANCE_SIZE_EXT = $80DE;
+ GL_COLOR_TABLE_INTENSITY_SIZE_EXT = $80DF;
+ GL_TEXTURE_INDEX_SIZE_EXT = $80ED;
+ GL_TEXTURE_1D = $0DE0;
+ GL_TEXTURE_2D = $0DE1;
+ GL_TEXTURE_3D_EXT = $806F;
+ // GL_TEXTURE_CUBE_MAP_ARB { already defined }
+ GL_PROXY_TEXTURE_1D = $8063;
+ GL_PROXY_TEXTURE_2D = $8064;
+ GL_PROXY_TEXTURE_3D_EXT = $8070;
+ // GL_PROXY_TEXTURE_CUBE_MAP_ARB { already defined }
+ // GL_TEXTURE_1D { already defined }
+ // GL_TEXTURE_2D { already defined }
+ // GL_TEXTURE_3D_EXT { already defined }
+ // GL_TEXTURE_CUBE_MAP_ARB { already defined }
+var
+ glColorTableEXT: procedure(target: GLenum; internalFormat: GLenum; width: GLsizei; format: GLenum; _type: GLenum; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ // glColorSubTableEXT { already defined }
+ glGetColorTableEXT: procedure(target: GLenum; format: GLenum; _type: GLenum; data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetColorTableParameterivEXT: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetColorTableParameterfvEXT: procedure(target: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_paletted_texture: Boolean;
+
+//***** GL_EXT_point_parameters *****//
+const
+ GL_POINT_SIZE_MIN_EXT = $8126;
+ GL_POINT_SIZE_MAX_EXT = $8127;
+ GL_POINT_FADE_THRESHOLD_SIZE_EXT = $8128;
+ GL_DISTANCE_ATTENUATION_EXT = $8129;
+var
+ glPointParameterfEXT: procedure(pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPointParameterfvEXT: procedure(pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_point_parameters: Boolean;
+
+//***** GL_EXT_polygon_offset *****//
+const
+ GL_POLYGON_OFFSET_EXT = $8037;
+ GL_POLYGON_OFFSET_FACTOR_EXT = $8038;
+ GL_POLYGON_OFFSET_BIAS_EXT = $8039;
+var
+ glPolygonOffsetEXT: procedure(factor: GLfloat; bias: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_polygon_offset: Boolean;
+
+//***** GL_EXT_separate_specular_color *****//
+const
+ GL_LIGHT_MODEL_COLOR_CONTROL_EXT = $81F8;
+ GL_SINGLE_COLOR_EXT = $81F9;
+ GL_SEPARATE_SPECULAR_COLOR_EXT = $81FA;
+
+function Load_GL_EXT_separate_specular_color: Boolean;
+
+//***** GL_EXT_shadow_funcs *****//
+
+function Load_GL_EXT_shadow_funcs: Boolean;
+
+//***** GL_EXT_shared_texture_palette *****//
+const
+ GL_SHARED_TEXTURE_PALETTE_EXT = $81FB;
+
+function Load_GL_EXT_shared_texture_palette: Boolean;
+
+//***** GL_EXT_stencil_two_side *****//
+const
+ GL_STENCIL_TEST_TWO_SIDE_EXT = $8910;
+ GL_ACTIVE_STENCIL_FACE_EXT = $8911;
+var
+ glActiveStencilFaceEXT: procedure(face: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_stencil_two_side: Boolean;
+
+//***** GL_EXT_stencil_wrap *****//
+const
+ GL_INCR_WRAP_EXT = $8507;
+ GL_DECR_WRAP_EXT = $8508;
+
+function Load_GL_EXT_stencil_wrap: Boolean;
+
+//***** GL_EXT_subtexture *****//
+var
+ glTexSubImage1DEXT: procedure(target: GLenum; level: GLint; xoffset: GLint; width: GLsizei; format: GLenum; _type: GLenum; const pixels: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexSubImage2DEXT: procedure(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; width: GLsizei; height: GLsizei; format: GLenum; _type: GLenum; const pixels: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexSubImage3DEXT: procedure(target: GLenum; level: GLint; xoffset: GLint; yoffset: GLint; zoffset: GLint; width: GLsizei; height: GLsizei; depth: GLsizei; format: GLenum; _type: GLenum; const pixels: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_subtexture: Boolean;
+
+//***** GL_EXT_texture3D *****//
+const
+ GL_PACK_SKIP_IMAGES_EXT = $806B;
+ GL_PACK_IMAGE_HEIGHT_EXT = $806C;
+ GL_UNPACK_SKIP_IMAGES_EXT = $806D;
+ GL_UNPACK_IMAGE_HEIGHT_EXT = $806E;
+ // GL_TEXTURE_3D_EXT { already defined }
+ // GL_PROXY_TEXTURE_3D_EXT { already defined }
+ GL_TEXTURE_DEPTH_EXT = $8071;
+ GL_TEXTURE_WRAP_R_EXT = $8072;
+ GL_MAX_3D_TEXTURE_SIZE_EXT = $8073;
+var
+ glTexImage3DEXT: procedure(target: GLenum; level: GLint; internalformat: GLenum; width: GLsizei; height: GLsizei; depth: GLsizei; border: GLint; format: GLenum; _type: GLenum; const pixels: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_texture3D: Boolean;
+
+//***** GL_EXT_texture_compression_s3tc *****//
+const
+ GL_COMPRESSED_RGB_S3TC_DXT1_EXT = $83F0;
+ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = $83F1;
+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = $83F2;
+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = $83F3;
+
+function Load_GL_EXT_texture_compression_s3tc: Boolean;
+
+//***** GL_EXT_texture_env_add *****//
+
+function Load_GL_EXT_texture_env_add: Boolean;
+
+//***** GL_EXT_texture_env_combine *****//
+const
+ GL_COMBINE_EXT = $8570;
+ GL_COMBINE_RGB_EXT = $8571;
+ GL_COMBINE_ALPHA_EXT = $8572;
+ GL_SOURCE0_RGB_EXT = $8580;
+ GL_SOURCE1_RGB_EXT = $8581;
+ GL_SOURCE2_RGB_EXT = $8582;
+ GL_SOURCE0_ALPHA_EXT = $8588;
+ GL_SOURCE1_ALPHA_EXT = $8589;
+ GL_SOURCE2_ALPHA_EXT = $858A;
+ GL_OPERAND0_RGB_EXT = $8590;
+ GL_OPERAND1_RGB_EXT = $8591;
+ GL_OPERAND2_RGB_EXT = $8592;
+ GL_OPERAND0_ALPHA_EXT = $8598;
+ GL_OPERAND1_ALPHA_EXT = $8599;
+ GL_OPERAND2_ALPHA_EXT = $859A;
+ GL_RGB_SCALE_EXT = $8573;
+ GL_ADD_SIGNED_EXT = $8574;
+ GL_INTERPOLATE_EXT = $8575;
+ GL_CONSTANT_EXT = $8576;
+ GL_PRIMARY_COLOR_EXT = $8577;
+ GL_PREVIOUS_EXT = $8578;
+
+function Load_GL_EXT_texture_env_combine: Boolean;
+
+//***** GL_EXT_texture_env_dot3 *****//
+const
+ GL_DOT3_RGB_EXT = $8740;
+ GL_DOT3_RGBA_EXT = $8741;
+
+function Load_GL_EXT_texture_env_dot3: Boolean;
+
+//***** GL_EXT_texture_filter_anisotropic *****//
+const
+ GL_TEXTURE_MAX_ANISOTROPY_EXT = $84FE;
+ GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = $84FF;
+
+function Load_GL_EXT_texture_filter_anisotropic: Boolean;
+
+//***** GL_EXT_texture_lod_bias *****//
+const
+ GL_TEXTURE_FILTER_CONTROL_EXT = $8500;
+ GL_TEXTURE_LOD_BIAS_EXT = $8501;
+ GL_MAX_TEXTURE_LOD_BIAS_EXT = $84FD;
+
+function Load_GL_EXT_texture_lod_bias: Boolean;
+
+//***** GL_EXT_texture_object *****//
+const
+ GL_TEXTURE_PRIORITY_EXT = $8066;
+ GL_TEXTURE_RESIDENT_EXT = $8067;
+ GL_TEXTURE_1D_BINDING_EXT = $8068;
+ GL_TEXTURE_2D_BINDING_EXT = $8069;
+ GL_TEXTURE_3D_BINDING_EXT = $806A;
+var
+ glGenTexturesEXT: procedure(n: GLsizei; textures: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteTexturesEXT: procedure(n: GLsizei; const textures: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindTextureEXT: procedure(target: GLenum; texture: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPrioritizeTexturesEXT: procedure(n: GLsizei; const textures: PGLuint; const priorities: PGLclampf); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glAreTexturesResidentEXT: function(n: GLsizei; const textures: PGLuint; residences: PGLboolean): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsTextureEXT: function(texture: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_texture_object: Boolean;
+
+//***** GL_EXT_vertex_array *****//
+const
+ GL_VERTEX_ARRAY_EXT = $8074;
+ GL_NORMAL_ARRAY_EXT = $8075;
+ GL_COLOR_ARRAY_EXT = $8076;
+ GL_INDEX_ARRAY_EXT = $8077;
+ GL_TEXTURE_COORD_ARRAY_EXT = $8078;
+ GL_EDGE_FLAG_ARRAY_EXT = $8079;
+ GL_DOUBLE_EXT = $140A;
+ GL_VERTEX_ARRAY_SIZE_EXT = $807A;
+ GL_VERTEX_ARRAY_TYPE_EXT = $807B;
+ GL_VERTEX_ARRAY_STRIDE_EXT = $807C;
+ GL_VERTEX_ARRAY_COUNT_EXT = $807D;
+ GL_NORMAL_ARRAY_TYPE_EXT = $807E;
+ GL_NORMAL_ARRAY_STRIDE_EXT = $807F;
+ GL_NORMAL_ARRAY_COUNT_EXT = $8080;
+ GL_COLOR_ARRAY_SIZE_EXT = $8081;
+ GL_COLOR_ARRAY_TYPE_EXT = $8082;
+ GL_COLOR_ARRAY_STRIDE_EXT = $8083;
+ GL_COLOR_ARRAY_COUNT_EXT = $8084;
+ GL_INDEX_ARRAY_TYPE_EXT = $8085;
+ GL_INDEX_ARRAY_STRIDE_EXT = $8086;
+ GL_INDEX_ARRAY_COUNT_EXT = $8087;
+ GL_TEXTURE_COORD_ARRAY_SIZE_EXT = $8088;
+ GL_TEXTURE_COORD_ARRAY_TYPE_EXT = $8089;
+ GL_TEXTURE_COORD_ARRAY_STRIDE_EXT = $808A;
+ GL_TEXTURE_COORD_ARRAY_COUNT_EXT = $808B;
+ GL_EDGE_FLAG_ARRAY_STRIDE_EXT = $808C;
+ GL_EDGE_FLAG_ARRAY_COUNT_EXT = $808D;
+ GL_VERTEX_ARRAY_POINTER_EXT = $808E;
+ GL_NORMAL_ARRAY_POINTER_EXT = $808F;
+ GL_COLOR_ARRAY_POINTER_EXT = $8090;
+ GL_INDEX_ARRAY_POINTER_EXT = $8091;
+ GL_TEXTURE_COORD_ARRAY_POINTER_EXT = $8092;
+ GL_EDGE_FLAG_ARRAY_POINTER_EXT = $8093;
+var
+ glArrayElementEXT: procedure(i: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDrawArraysEXT: procedure(mode: GLenum; first: GLint; count: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexPointerEXT: procedure(size: GLint; _type: GLenum; stride: GLsizei; count: GLsizei; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalPointerEXT: procedure(_type: GLenum; stride: GLsizei; count: GLsizei; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColorPointerEXT: procedure(size: GLint; _type: GLenum; stride: GLsizei; count: GLsizei; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIndexPointerEXT: procedure(_type: GLenum; stride: GLsizei; count: GLsizei; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoordPointerEXT: procedure(size: GLint; _type: GLenum; stride: GLsizei; count: GLsizei; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEdgeFlagPointerEXT: procedure(stride: GLsizei; count: GLsizei; const pointer: PGLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetPointervEXT: procedure(pname: GLenum; params: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_vertex_array: Boolean;
+
+//***** GL_EXT_vertex_shader *****//
+const
+ GL_VERTEX_SHADER_EXT = $8780;
+ GL_VARIANT_VALUE_EXT = $87E4;
+ GL_VARIANT_DATATYPE_EXT = $87E5;
+ GL_VARIANT_ARRAY_STRIDE_EXT = $87E6;
+ GL_VARIANT_ARRAY_TYPE_EXT = $87E7;
+ GL_VARIANT_ARRAY_EXT = $87E8;
+ GL_VARIANT_ARRAY_POINTER_EXT = $87E9;
+ GL_INVARIANT_VALUE_EXT = $87EA;
+ GL_INVARIANT_DATATYPE_EXT = $87EB;
+ GL_LOCAL_CONSTANT_VALUE_EXT = $87EC;
+ GL_LOCAL_CONSTANT_DATATYPE_EXT = $87ED;
+ GL_OP_INDEX_EXT = $8782;
+ GL_OP_NEGATE_EXT = $8783;
+ GL_OP_DOT3_EXT = $8784;
+ GL_OP_DOT4_EXT = $8785;
+ GL_OP_MUL_EXT = $8786;
+ GL_OP_ADD_EXT = $8787;
+ GL_OP_MADD_EXT = $8788;
+ GL_OP_FRAC_EXT = $8789;
+ GL_OP_MAX_EXT = $878A;
+ GL_OP_MIN_EXT = $878B;
+ GL_OP_SET_GE_EXT = $878C;
+ GL_OP_SET_LT_EXT = $878D;
+ GL_OP_CLAMP_EXT = $878E;
+ GL_OP_FLOOR_EXT = $878F;
+ GL_OP_ROUND_EXT = $8790;
+ GL_OP_EXP_BASE_2_EXT = $8791;
+ GL_OP_LOG_BASE_2_EXT = $8792;
+ GL_OP_POWER_EXT = $8793;
+ GL_OP_RECIP_EXT = $8794;
+ GL_OP_RECIP_SQRT_EXT = $8795;
+ GL_OP_SUB_EXT = $8796;
+ GL_OP_CROSS_PRODUCT_EXT = $8797;
+ GL_OP_MULTIPLY_MATRIX_EXT = $8798;
+ GL_OP_MOV_EXT = $8799;
+ GL_OUTPUT_VERTEX_EXT = $879A;
+ GL_OUTPUT_COLOR0_EXT = $879B;
+ GL_OUTPUT_COLOR1_EXT = $879C;
+ GL_OUTPUT_TEXTURE_COORD0_EXT = $879D;
+ GL_OUTPUT_TEXTURE_COORD1_EXT = $879E;
+ GL_OUTPUT_TEXTURE_COORD2_EXT = $879F;
+ GL_OUTPUT_TEXTURE_COORD3_EXT = $87A0;
+ GL_OUTPUT_TEXTURE_COORD4_EXT = $87A1;
+ GL_OUTPUT_TEXTURE_COORD5_EXT = $87A2;
+ GL_OUTPUT_TEXTURE_COORD6_EXT = $87A3;
+ GL_OUTPUT_TEXTURE_COORD7_EXT = $87A4;
+ GL_OUTPUT_TEXTURE_COORD8_EXT = $87A5;
+ GL_OUTPUT_TEXTURE_COORD9_EXT = $87A6;
+ GL_OUTPUT_TEXTURE_COORD10_EXT = $87A7;
+ GL_OUTPUT_TEXTURE_COORD11_EXT = $87A8;
+ GL_OUTPUT_TEXTURE_COORD12_EXT = $87A9;
+ GL_OUTPUT_TEXTURE_COORD13_EXT = $87AA;
+ GL_OUTPUT_TEXTURE_COORD14_EXT = $87AB;
+ GL_OUTPUT_TEXTURE_COORD15_EXT = $87AC;
+ GL_OUTPUT_TEXTURE_COORD16_EXT = $87AD;
+ GL_OUTPUT_TEXTURE_COORD17_EXT = $87AE;
+ GL_OUTPUT_TEXTURE_COORD18_EXT = $87AF;
+ GL_OUTPUT_TEXTURE_COORD19_EXT = $87B0;
+ GL_OUTPUT_TEXTURE_COORD20_EXT = $87B1;
+ GL_OUTPUT_TEXTURE_COORD21_EXT = $87B2;
+ GL_OUTPUT_TEXTURE_COORD22_EXT = $87B3;
+ GL_OUTPUT_TEXTURE_COORD23_EXT = $87B4;
+ GL_OUTPUT_TEXTURE_COORD24_EXT = $87B5;
+ GL_OUTPUT_TEXTURE_COORD25_EXT = $87B6;
+ GL_OUTPUT_TEXTURE_COORD26_EXT = $87B7;
+ GL_OUTPUT_TEXTURE_COORD27_EXT = $87B8;
+ GL_OUTPUT_TEXTURE_COORD28_EXT = $87B9;
+ GL_OUTPUT_TEXTURE_COORD29_EXT = $87BA;
+ GL_OUTPUT_TEXTURE_COORD30_EXT = $87BB;
+ GL_OUTPUT_TEXTURE_COORD31_EXT = $87BC;
+ GL_OUTPUT_FOG_EXT = $87BD;
+ GL_SCALAR_EXT = $87BE;
+ GL_VECTOR_EXT = $87BF;
+ GL_MATRIX_EXT = $87C0;
+ GL_VARIANT_EXT = $87C1;
+ GL_INVARIANT_EXT = $87C2;
+ GL_LOCAL_CONSTANT_EXT = $87C3;
+ GL_LOCAL_EXT = $87C4;
+ GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT = $87C5;
+ GL_MAX_VERTEX_SHADER_VARIANTS_EXT = $87C6;
+ GL_MAX_VERTEX_SHADER_INVARIANTS_EXT = $87C7;
+ GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT = $87C8;
+ GL_MAX_VERTEX_SHADER_LOCALS_EXT = $87C9;
+ GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT = $87CA;
+ GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT = $87CB;
+ GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT = $87CC;
+ GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT = $87CD;
+ GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT = $87CE;
+ GL_VERTEX_SHADER_INSTRUCTIONS_EXT = $87CF;
+ GL_VERTEX_SHADER_VARIANTS_EXT = $87D0;
+ GL_VERTEX_SHADER_INVARIANTS_EXT = $87D1;
+ GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT = $87D2;
+ GL_VERTEX_SHADER_LOCALS_EXT = $87D3;
+ GL_VERTEX_SHADER_BINDING_EXT = $8781;
+ GL_VERTEX_SHADER_OPTIMIZED_EXT = $87D4;
+ GL_X_EXT = $87D5;
+ GL_Y_EXT = $87D6;
+ GL_Z_EXT = $87D7;
+ GL_W_EXT = $87D8;
+ GL_NEGATIVE_X_EXT = $87D9;
+ GL_NEGATIVE_Y_EXT = $87DA;
+ GL_NEGATIVE_Z_EXT = $87DB;
+ GL_NEGATIVE_W_EXT = $87DC;
+ GL_ZERO_EXT = $87DD;
+ GL_ONE_EXT = $87DE;
+ GL_NEGATIVE_ONE_EXT = $87DF;
+ GL_NORMALIZED_RANGE_EXT = $87E0;
+ GL_FULL_RANGE_EXT = $87E1;
+ GL_CURRENT_VERTEX_EXT = $87E2;
+ GL_MVP_MATRIX_EXT = $87E3;
+var
+ glBeginVertexShaderEXT: procedure(); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEndVertexShaderEXT: procedure(); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindVertexShaderEXT: procedure(id: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGenVertexShadersEXT: function(range: GLuint): GLuint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteVertexShaderEXT: procedure(id: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glShaderOp1EXT: procedure(op: GLenum; res: GLuint; arg1: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glShaderOp2EXT: procedure(op: GLenum; res: GLuint; arg1: GLuint; arg2: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glShaderOp3EXT: procedure(op: GLenum; res: GLuint; arg1: GLuint; arg2: GLuint; arg3: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSwizzleEXT: procedure(res: GLuint; _in: GLuint; outX: GLenum; outY: GLenum; outZ: GLenum; outW: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWriteMaskEXT: procedure(res: GLuint; _in: GLuint; outX: GLenum; outY: GLenum; outZ: GLenum; outW: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glInsertComponentEXT: procedure(res: GLuint; src: GLuint; num: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glExtractComponentEXT: procedure(res: GLuint; src: GLuint; num: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGenSymbolsEXT: function(datatype: GLenum; storagetype: GLenum; range: GLenum; components: GLuint): GLuint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSetInvariantEXT: procedure(id: GLuint; _type: GLenum; addr: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSetLocalConstantEXT: procedure(id: GLuint; _type: GLenum; addr: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVariantbvEXT: procedure(id: GLuint; addr: PGLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVariantsvEXT: procedure(id: GLuint; addr: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVariantivEXT: procedure(id: GLuint; addr: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVariantfvEXT: procedure(id: GLuint; addr: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVariantdvEXT: procedure(id: GLuint; addr: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVariantubvEXT: procedure(id: GLuint; addr: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVariantusvEXT: procedure(id: GLuint; addr: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVariantuivEXT: procedure(id: GLuint; addr: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVariantPointerEXT: procedure(id: GLuint; _type: GLenum; stride: GLuint; addr: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEnableVariantClientStateEXT: procedure(id: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDisableVariantClientStateEXT: procedure(id: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindLightParameterEXT: function(light: GLenum; value: GLenum): GLuint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindMaterialParameterEXT: function(face: GLenum; value: GLenum): GLuint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindTexGenParameterEXT: function(_unit: GLenum; coord: GLenum; value: GLenum): GLuint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindTextureUnitParameterEXT: function(_unit: GLenum; value: GLenum): GLuint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindParameterEXT: function(value: GLenum): GLuint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsVariantEnabledEXT: function(id: GLuint; cap: GLenum): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVariantBooleanvEXT: procedure(id: GLuint; value: GLenum; data: PGLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVariantIntegervEXT: procedure(id: GLuint; value: GLenum; data: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVariantFloatvEXT: procedure(id: GLuint; value: GLenum; data: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVariantPointervEXT: procedure(id: GLuint; value: GLenum; data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetInvariantBooleanvEXT: procedure(id: GLuint; value: GLenum; data: PGLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetInvariantIntegervEXT: procedure(id: GLuint; value: GLenum; data: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetInvariantFloatvEXT: procedure(id: GLuint; value: GLenum; data: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetLocalConstantBooleanvEXT: procedure(id: GLuint; value: GLenum; data: PGLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetLocalConstantIntegervEXT: procedure(id: GLuint; value: GLenum; data: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetLocalConstantFloatvEXT: procedure(id: GLuint; value: GLenum; data: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_vertex_shader: Boolean;
+
+//***** GL_EXT_vertex_weighting *****//
+const
+ GL_VERTEX_WEIGHTING_EXT = $8509;
+ GL_MODELVIEW0_EXT = $1700;
+ GL_MODELVIEW1_EXT = $850A;
+ GL_MODELVIEW0_MATRIX_EXT = $0BA6;
+ GL_MODELVIEW1_MATRIX_EXT = $8506;
+ GL_CURRENT_VERTEX_WEIGHT_EXT = $850B;
+ GL_VERTEX_WEIGHT_ARRAY_EXT = $850C;
+ GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT = $850D;
+ GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT = $850E;
+ GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT = $850F;
+ GL_MODELVIEW0_STACK_DEPTH_EXT = $0BA3;
+ GL_MODELVIEW1_STACK_DEPTH_EXT = $8502;
+ GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT = $8510;
+var
+ glVertexWeightfEXT: procedure(weight: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexWeightfvEXT: procedure(weight: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexWeightPointerEXT: procedure(size: GLint; _type: GLenum; stride: GLsizei; pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_vertex_weighting: Boolean;
+
+//***** GL_HP_occlusion_test *****//
+const
+ GL_OCCLUSION_TEST_HP = $8165;
+ GL_OCCLUSION_TEST_RESULT_HP = $8166;
+
+function Load_GL_HP_occlusion_test: Boolean;
+
+//***** GL_NV_blend_square *****//
+
+function Load_GL_NV_blend_square: Boolean;
+
+//***** GL_NV_copy_depth_to_color *****//
+const
+ GL_DEPTH_STENCIL_TO_RGBA_NV = $886E;
+ GL_DEPTH_STENCIL_TO_BGRA_NV = $886F;
+
+function Load_GL_NV_copy_depth_to_color: Boolean;
+
+//***** GL_NV_depth_clamp *****//
+const
+ GL_DEPTH_CLAMP_NV = $864F;
+
+function Load_GL_NV_depth_clamp: Boolean;
+
+//***** GL_NV_evaluators *****//
+const
+ GL_EVAL_2D_NV = $86C0;
+ GL_EVAL_TRIANGULAR_2D_NV = $86C1;
+ GL_MAP_TESSELLATION_NV = $86C2;
+ GL_MAP_ATTRIB_U_ORDER_NV = $86C3;
+ GL_MAP_ATTRIB_V_ORDER_NV = $86C4;
+ GL_EVAL_FRACTIONAL_TESSELLATION_NV = $86C5;
+ GL_EVAL_VERTEX_ATTRIB0_NV = $86C6;
+ GL_EVAL_VERTEX_ATTRIB1_NV = $86C7;
+ GL_EVAL_VERTEX_ATTRIB2_NV = $86C8;
+ GL_EVAL_VERTEX_ATTRIB3_NV = $86C9;
+ GL_EVAL_VERTEX_ATTRIB4_NV = $86CA;
+ GL_EVAL_VERTEX_ATTRIB5_NV = $86CB;
+ GL_EVAL_VERTEX_ATTRIB6_NV = $86CC;
+ GL_EVAL_VERTEX_ATTRIB7_NV = $86CD;
+ GL_EVAL_VERTEX_ATTRIB8_NV = $86CE;
+ GL_EVAL_VERTEX_ATTRIB9_NV = $86CF;
+ GL_EVAL_VERTEX_ATTRIB10_NV = $86D0;
+ GL_EVAL_VERTEX_ATTRIB11_NV = $86D1;
+ GL_EVAL_VERTEX_ATTRIB12_NV = $86D2;
+ GL_EVAL_VERTEX_ATTRIB13_NV = $86D3;
+ GL_EVAL_VERTEX_ATTRIB14_NV = $86D4;
+ GL_EVAL_VERTEX_ATTRIB15_NV = $86D5;
+ GL_MAX_MAP_TESSELLATION_NV = $86D6;
+ GL_MAX_RATIONAL_EVAL_ORDER_NV = $86D7;
+var
+ glMapControlPointsNV: procedure(target: GLenum; index: GLuint; _type: GLenum; ustride: GLsizei; vstride: GLsizei; uorder: GLint; vorder: GLint; _packed: GLboolean; const points: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMapParameterivNV: procedure(target: GLenum; pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMapParameterfvNV: procedure(target: GLenum; pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMapControlPointsNV: procedure(target: GLenum; index: GLuint; _type: GLenum; ustride: GLsizei; vstride: GLsizei; _packed: GLboolean; points: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMapParameterivNV: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMapParameterfvNV: procedure(target: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMapAttribParameterivNV: procedure(target: GLenum; index: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetMapAttribParameterfvNV: procedure(target: GLenum; index: GLuint; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEvalMapsNV: procedure(target: GLenum; mode: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_NV_evaluators: Boolean;
+
+//***** GL_NV_fence *****//
+const
+ GL_ALL_COMPLETED_NV = $84F2;
+ GL_FENCE_STATUS_NV = $84F3;
+ GL_FENCE_CONDITION_NV = $84F4;
+var
+ glGenFencesNV: procedure(n: GLsizei; fences: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteFencesNV: procedure(n: GLsizei; const fences: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSetFenceNV: procedure(fence: GLuint; condition: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTestFenceNV: function(fence: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFinishFenceNV: procedure(fence: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsFenceNV: function(fence: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetFenceivNV: procedure(fence: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_NV_fence: Boolean;
+
+//***** GL_NV_fog_distance *****//
+const
+ GL_FOG_DISTANCE_MODE_NV = $855A;
+ GL_EYE_RADIAL_NV = $855B;
+ GL_EYE_PLANE_ABSOLUTE_NV = $855C;
+
+function Load_GL_NV_fog_distance: Boolean;
+
+//***** GL_NV_light_max_exponent *****//
+const
+ GL_MAX_SHININESS_NV = $8504;
+ GL_MAX_SPOT_EXPONENT_NV = $8505;
+
+function Load_GL_NV_light_max_exponent: Boolean;
+
+//***** GL_NV_multisample_filter_hint *****//
+const
+ GL_MULTISAMPLE_FILTER_HINT_NV = $8534;
+
+function Load_GL_NV_multisample_filter_hint: Boolean;
+
+//***** GL_NV_occlusion_query *****//
+ // GL_OCCLUSION_TEST_HP { already defined }
+ // GL_OCCLUSION_TEST_RESULT_HP { already defined }
+const
+ GL_PIXEL_COUNTER_BITS_NV = $8864;
+ GL_CURRENT_OCCLUSION_QUERY_ID_NV = $8865;
+ GL_PIXEL_COUNT_NV = $8866;
+ GL_PIXEL_COUNT_AVAILABLE_NV = $8867;
+var
+ glGenOcclusionQueriesNV: procedure(n: GLsizei; ids: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteOcclusionQueriesNV: procedure(n: GLsizei; const ids: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsOcclusionQueryNV: function(id: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBeginOcclusionQueryNV: procedure(id: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEndOcclusionQueryNV: procedure(); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetOcclusionQueryivNV: procedure(id: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetOcclusionQueryuivNV: procedure(id: GLuint; pname: GLenum; params: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_NV_occlusion_query: Boolean;
+
+//***** GL_NV_packed_depth_stencil *****//
+const
+ GL_DEPTH_STENCIL_NV = $84F9;
+ GL_UNSIGNED_INT_24_8_NV = $84FA;
+
+function Load_GL_NV_packed_depth_stencil: Boolean;
+
+//***** GL_NV_point_sprite *****//
+const
+ GL_POINT_SPRITE_NV = $8861;
+ GL_COORD_REPLACE_NV = $8862;
+ GL_POINT_SPRITE_R_MODE_NV = $8863;
+var
+ glPointParameteriNV: procedure(pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPointParameterivNV: procedure(pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_NV_point_sprite: Boolean;
+
+//***** GL_NV_register_combiners *****//
+const
+ GL_REGISTER_COMBINERS_NV = $8522;
+ GL_COMBINER0_NV = $8550;
+ GL_COMBINER1_NV = $8551;
+ GL_COMBINER2_NV = $8552;
+ GL_COMBINER3_NV = $8553;
+ GL_COMBINER4_NV = $8554;
+ GL_COMBINER5_NV = $8555;
+ GL_COMBINER6_NV = $8556;
+ GL_COMBINER7_NV = $8557;
+ GL_VARIABLE_A_NV = $8523;
+ GL_VARIABLE_B_NV = $8524;
+ GL_VARIABLE_C_NV = $8525;
+ GL_VARIABLE_D_NV = $8526;
+ GL_VARIABLE_E_NV = $8527;
+ GL_VARIABLE_F_NV = $8528;
+ GL_VARIABLE_G_NV = $8529;
+ GL_CONSTANT_COLOR0_NV = $852A;
+ GL_CONSTANT_COLOR1_NV = $852B;
+ GL_PRIMARY_COLOR_NV = $852C;
+ GL_SECONDARY_COLOR_NV = $852D;
+ GL_SPARE0_NV = $852E;
+ GL_SPARE1_NV = $852F;
+ GL_UNSIGNED_IDENTITY_NV = $8536;
+ GL_UNSIGNED_INVERT_NV = $8537;
+ GL_EXPAND_NORMAL_NV = $8538;
+ GL_EXPAND_NEGATE_NV = $8539;
+ GL_HALF_BIAS_NORMAL_NV = $853A;
+ GL_HALF_BIAS_NEGATE_NV = $853B;
+ GL_SIGNED_IDENTITY_NV = $853C;
+ GL_SIGNED_NEGATE_NV = $853D;
+ GL_E_TIMES_F_NV = $8531;
+ GL_SPARE0_PLUS_SECONDARY_COLOR_NV = $8532;
+ GL_SCALE_BY_TWO_NV = $853E;
+ GL_SCALE_BY_FOUR_NV = $853F;
+ GL_SCALE_BY_ONE_HALF_NV = $8540;
+ GL_BIAS_BY_NEGATIVE_ONE_HALF_NV = $8541;
+ GL_DISCARD_NV = $8530;
+ GL_COMBINER_INPUT_NV = $8542;
+ GL_COMBINER_MAPPING_NV = $8543;
+ GL_COMBINER_COMPONENT_USAGE_NV = $8544;
+ GL_COMBINER_AB_DOT_PRODUCT_NV = $8545;
+ GL_COMBINER_CD_DOT_PRODUCT_NV = $8546;
+ GL_COMBINER_MUX_SUM_NV = $8547;
+ GL_COMBINER_SCALE_NV = $8548;
+ GL_COMBINER_BIAS_NV = $8549;
+ GL_COMBINER_AB_OUTPUT_NV = $854A;
+ GL_COMBINER_CD_OUTPUT_NV = $854B;
+ GL_COMBINER_SUM_OUTPUT_NV = $854C;
+ GL_NUM_GENERAL_COMBINERS_NV = $854E;
+ GL_COLOR_SUM_CLAMP_NV = $854F;
+ GL_MAX_GENERAL_COMBINERS_NV = $854D;
+var
+ glCombinerParameterfvNV: procedure(pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCombinerParameterivNV: procedure(pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCombinerParameterfNV: procedure(pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCombinerParameteriNV: procedure(pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCombinerInputNV: procedure(stage: GLenum; portion: GLenum; variable: GLenum; input: GLenum; mapping: GLenum; componentUsage: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCombinerOutputNV: procedure(stage: GLenum; portion: GLenum; abOutput: GLenum; cdOutput: GLenum; sumOutput: GLenum; scale: GLenum; bias: GLenum; abDotProduct: GLboolean; cdDotProduct: GLboolean; muxSum: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFinalCombinerInputNV: procedure(variable: GLenum; input: GLenum; mapping: GLenum; componentUsage: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetCombinerInputParameterfvNV: procedure(stage: GLenum; portion: GLenum; variable: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetCombinerInputParameterivNV: procedure(stage: GLenum; portion: GLenum; variable: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetCombinerOutputParameterfvNV: procedure(stage: GLenum; portion: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetCombinerOutputParameterivNV: procedure(stage: GLenum; portion: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetFinalCombinerInputParameterfvNV: procedure(variable: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetFinalCombinerInputParameterivNV: procedure(variable: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_NV_register_combiners: Boolean;
+
+//***** GL_NV_register_combiners2 *****//
+const
+ GL_PER_STAGE_CONSTANTS_NV = $8535;
+var
+ glCombinerStageParameterfvNV: procedure(stage: GLenum; pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetCombinerStageParameterfvNV: procedure(stage: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_NV_register_combiners2: Boolean;
+
+//***** GL_NV_texgen_emboss *****//
+const
+ GL_EMBOSS_MAP_NV = $855F;
+ GL_EMBOSS_LIGHT_NV = $855D;
+ GL_EMBOSS_CONSTANT_NV = $855E;
+
+function Load_GL_NV_texgen_emboss: Boolean;
+
+//***** GL_NV_texgen_reflection *****//
+const
+ GL_NORMAL_MAP_NV = $8511;
+ GL_REFLECTION_MAP_NV = $8512;
+
+function Load_GL_NV_texgen_reflection: Boolean;
+
+//***** GL_NV_texture_compression_vtc *****//
+ // GL_COMPRESSED_RGB_S3TC_DXT1_EXT { already defined }
+ // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT { already defined }
+ // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT { already defined }
+ // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT { already defined }
+
+function Load_GL_NV_texture_compression_vtc: Boolean;
+
+//***** GL_NV_texture_env_combine4 *****//
+const
+ GL_COMBINE4_NV = $8503;
+ GL_SOURCE3_RGB_NV = $8583;
+ GL_SOURCE3_ALPHA_NV = $858B;
+ GL_OPERAND3_RGB_NV = $8593;
+ GL_OPERAND3_ALPHA_NV = $859B;
+
+function Load_GL_NV_texture_env_combine4: Boolean;
+
+//***** GL_NV_texture_rectangle *****//
+const
+ GL_TEXTURE_RECTANGLE_NV = $84F5;
+ GL_TEXTURE_BINDING_RECTANGLE_NV = $84F6;
+ GL_PROXY_TEXTURE_RECTANGLE_NV = $84F7;
+ GL_MAX_RECTANGLE_TEXTURE_SIZE_NV = $84F8;
+
+function Load_GL_NV_texture_rectangle: Boolean;
+
+//***** GL_NV_texture_shader *****//
+const
+ GL_TEXTURE_SHADER_NV = $86DE;
+ GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV = $86D9;
+ GL_SHADER_OPERATION_NV = $86DF;
+ GL_CULL_MODES_NV = $86E0;
+ GL_OFFSET_TEXTURE_MATRIX_NV = $86E1;
+ GL_OFFSET_TEXTURE_SCALE_NV = $86E2;
+ GL_OFFSET_TEXTURE_BIAS_NV = $86E3;
+ GL_PREVIOUS_TEXTURE_INPUT_NV = $86E4;
+ GL_CONST_EYE_NV = $86E5;
+ GL_SHADER_CONSISTENT_NV = $86DD;
+ GL_PASS_THROUGH_NV = $86E6;
+ GL_CULL_FRAGMENT_NV = $86E7;
+ GL_OFFSET_TEXTURE_2D_NV = $86E8;
+ GL_OFFSET_TEXTURE_RECTANGLE_NV = $864C;
+ GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV = $864D;
+ GL_DEPENDENT_AR_TEXTURE_2D_NV = $86E9;
+ GL_DEPENDENT_GB_TEXTURE_2D_NV = $86EA;
+ GL_DOT_PRODUCT_NV = $86EC;
+ GL_DOT_PRODUCT_DEPTH_REPLACE_NV = $86ED;
+ GL_DOT_PRODUCT_TEXTURE_2D_NV = $86EE;
+ GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV = $864E;
+ GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV = $86F0;
+ GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV = $86F1;
+ GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV = $86F2;
+ GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV = $86F3;
+ GL_HILO_NV = $86F4;
+ GL_DSDT_NV = $86F5;
+ GL_DSDT_MAG_NV = $86F6;
+ GL_DSDT_MAG_VIB_NV = $86F7;
+ GL_UNSIGNED_INT_S8_S8_8_8_NV = $86DA;
+ GL_UNSIGNED_INT_8_8_S8_S8_REV_NV = $86DB;
+ GL_SIGNED_RGBA_NV = $86FB;
+ GL_SIGNED_RGBA8_NV = $86FC;
+ GL_SIGNED_RGB_NV = $86FE;
+ GL_SIGNED_RGB8_NV = $86FF;
+ GL_SIGNED_LUMINANCE_NV = $8701;
+ GL_SIGNED_LUMINANCE8_NV = $8702;
+ GL_SIGNED_LUMINANCE_ALPHA_NV = $8703;
+ GL_SIGNED_LUMINANCE8_ALPHA8_NV = $8704;
+ GL_SIGNED_ALPHA_NV = $8705;
+ GL_SIGNED_ALPHA8_NV = $8706;
+ GL_SIGNED_INTENSITY_NV = $8707;
+ GL_SIGNED_INTENSITY8_NV = $8708;
+ GL_SIGNED_RGB_UNSIGNED_ALPHA_NV = $870C;
+ GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV = $870D;
+ GL_HILO16_NV = $86F8;
+ GL_SIGNED_HILO_NV = $86F9;
+ GL_SIGNED_HILO16_NV = $86FA;
+ GL_DSDT8_NV = $8709;
+ GL_DSDT8_MAG8_NV = $870A;
+ GL_DSDT_MAG_INTENSITY_NV = $86DC;
+ GL_DSDT8_MAG8_INTENSITY8_NV = $870B;
+ GL_HI_SCALE_NV = $870E;
+ GL_LO_SCALE_NV = $870F;
+ GL_DS_SCALE_NV = $8710;
+ GL_DT_SCALE_NV = $8711;
+ GL_MAGNITUDE_SCALE_NV = $8712;
+ GL_VIBRANCE_SCALE_NV = $8713;
+ GL_HI_BIAS_NV = $8714;
+ GL_LO_BIAS_NV = $8715;
+ GL_DS_BIAS_NV = $8716;
+ GL_DT_BIAS_NV = $8717;
+ GL_MAGNITUDE_BIAS_NV = $8718;
+ GL_VIBRANCE_BIAS_NV = $8719;
+ GL_TEXTURE_BORDER_VALUES_NV = $871A;
+ GL_TEXTURE_HI_SIZE_NV = $871B;
+ GL_TEXTURE_LO_SIZE_NV = $871C;
+ GL_TEXTURE_DS_SIZE_NV = $871D;
+ GL_TEXTURE_DT_SIZE_NV = $871E;
+ GL_TEXTURE_MAG_SIZE_NV = $871F;
+
+function Load_GL_NV_texture_shader: Boolean;
+
+//***** GL_NV_texture_shader2 *****//
+const
+ GL_DOT_PRODUCT_TEXTURE_3D_NV = $86EF;
+ // GL_HILO_NV { already defined }
+ // GL_DSDT_NV { already defined }
+ // GL_DSDT_MAG_NV { already defined }
+ // GL_DSDT_MAG_VIB_NV { already defined }
+ // GL_UNSIGNED_INT_S8_S8_8_8_NV { already defined }
+ // GL_UNSIGNED_INT_8_8_S8_S8_REV_NV { already defined }
+ // GL_SIGNED_RGBA_NV { already defined }
+ // GL_SIGNED_RGBA8_NV { already defined }
+ // GL_SIGNED_RGB_NV { already defined }
+ // GL_SIGNED_RGB8_NV { already defined }
+ // GL_SIGNED_LUMINANCE_NV { already defined }
+ // GL_SIGNED_LUMINANCE8_NV { already defined }
+ // GL_SIGNED_LUMINANCE_ALPHA_NV { already defined }
+ // GL_SIGNED_LUMINANCE8_ALPHA8_NV { already defined }
+ // GL_SIGNED_ALPHA_NV { already defined }
+ // GL_SIGNED_ALPHA8_NV { already defined }
+ // GL_SIGNED_INTENSITY_NV { already defined }
+ // GL_SIGNED_INTENSITY8_NV { already defined }
+ // GL_SIGNED_RGB_UNSIGNED_ALPHA_NV { already defined }
+ // GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV { already defined }
+ // GL_HILO16_NV { already defined }
+ // GL_SIGNED_HILO_NV { already defined }
+ // GL_SIGNED_HILO16_NV { already defined }
+ // GL_DSDT8_NV { already defined }
+ // GL_DSDT8_MAG8_NV { already defined }
+ // GL_DSDT_MAG_INTENSITY_NV { already defined }
+ // GL_DSDT8_MAG8_INTENSITY8_NV { already defined }
+
+function Load_GL_NV_texture_shader2: Boolean;
+
+//***** GL_NV_texture_shader3 *****//
+const
+ GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV = $8850;
+ GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV = $8851;
+ GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV = $8852;
+ GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV = $8853;
+ GL_OFFSET_HILO_TEXTURE_2D_NV = $8854;
+ GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV = $8855;
+ GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV = $8856;
+ GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV = $8857;
+ GL_DEPENDENT_HILO_TEXTURE_2D_NV = $8858;
+ GL_DEPENDENT_RGB_TEXTURE_3D_NV = $8859;
+ GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV = $885A;
+ GL_DOT_PRODUCT_PASS_THROUGH_NV = $885B;
+ GL_DOT_PRODUCT_TEXTURE_1D_NV = $885C;
+ GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV = $885D;
+ GL_HILO8_NV = $885E;
+ GL_SIGNED_HILO8_NV = $885F;
+ GL_FORCE_BLUE_TO_ONE_NV = $8860;
+
+function Load_GL_NV_texture_shader3: Boolean;
+
+//***** GL_NV_vertex_array_range *****//
+const
+ GL_VERTEX_ARRAY_RANGE_NV = $851D;
+ GL_VERTEX_ARRAY_RANGE_LENGTH_NV = $851E;
+ GL_VERTEX_ARRAY_RANGE_VALID_NV = $851F;
+ GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV = $8520;
+ GL_VERTEX_ARRAY_RANGE_POINTER_NV = $8521;
+var
+ glVertexArrayRangeNV: procedure(length: GLsizei; pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFlushVertexArrayRangeNV: procedure(); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+{$IFDEF WINDOWS}
+ wglAllocateMemoryNV: function(size: GLsizei; readFrequency: GLfloat; writeFrequency: GLfloat; priority: GLfloat): PGLvoid; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglFreeMemoryNV: procedure(pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+{$ENDIF}
+
+function Load_GL_NV_vertex_array_range: Boolean;
+
+//***** GL_NV_vertex_array_range2 *****//
+const
+ GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV = $8533;
+
+function Load_GL_NV_vertex_array_range2: Boolean;
+
+//***** GL_NV_vertex_program *****//
+const
+ GL_VERTEX_PROGRAM_NV = $8620;
+ GL_VERTEX_PROGRAM_POINT_SIZE_NV = $8642;
+ GL_VERTEX_PROGRAM_TWO_SIDE_NV = $8643;
+ GL_VERTEX_STATE_PROGRAM_NV = $8621;
+ GL_ATTRIB_ARRAY_SIZE_NV = $8623;
+ GL_ATTRIB_ARRAY_STRIDE_NV = $8624;
+ GL_ATTRIB_ARRAY_TYPE_NV = $8625;
+ GL_CURRENT_ATTRIB_NV = $8626;
+ GL_PROGRAM_PARAMETER_NV = $8644;
+ GL_ATTRIB_ARRAY_POINTER_NV = $8645;
+ GL_PROGRAM_TARGET_NV = $8646;
+ GL_PROGRAM_LENGTH_NV = $8627;
+ GL_PROGRAM_RESIDENT_NV = $8647;
+ GL_PROGRAM_STRING_NV = $8628;
+ GL_TRACK_MATRIX_NV = $8648;
+ GL_TRACK_MATRIX_TRANSFORM_NV = $8649;
+ GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV = $862E;
+ GL_MAX_TRACK_MATRICES_NV = $862F;
+ GL_CURRENT_MATRIX_STACK_DEPTH_NV = $8640;
+ GL_CURRENT_MATRIX_NV = $8641;
+ GL_VERTEX_PROGRAM_BINDING_NV = $864A;
+ GL_PROGRAM_ERROR_POSITION_NV = $864B;
+ GL_MODELVIEW_PROJECTION_NV = $8629;
+ GL_MATRIX0_NV = $8630;
+ GL_MATRIX1_NV = $8631;
+ GL_MATRIX2_NV = $8632;
+ GL_MATRIX3_NV = $8633;
+ GL_MATRIX4_NV = $8634;
+ GL_MATRIX5_NV = $8635;
+ GL_MATRIX6_NV = $8636;
+ GL_MATRIX7_NV = $8637;
+ GL_IDENTITY_NV = $862A;
+ GL_INVERSE_NV = $862B;
+ GL_TRANSPOSE_NV = $862C;
+ GL_INVERSE_TRANSPOSE_NV = $862D;
+ GL_VERTEX_ATTRIB_ARRAY0_NV = $8650;
+ GL_VERTEX_ATTRIB_ARRAY1_NV = $8651;
+ GL_VERTEX_ATTRIB_ARRAY2_NV = $8652;
+ GL_VERTEX_ATTRIB_ARRAY3_NV = $8653;
+ GL_VERTEX_ATTRIB_ARRAY4_NV = $8654;
+ GL_VERTEX_ATTRIB_ARRAY5_NV = $8655;
+ GL_VERTEX_ATTRIB_ARRAY6_NV = $8656;
+ GL_VERTEX_ATTRIB_ARRAY7_NV = $8657;
+ GL_VERTEX_ATTRIB_ARRAY8_NV = $8658;
+ GL_VERTEX_ATTRIB_ARRAY9_NV = $8659;
+ GL_VERTEX_ATTRIB_ARRAY10_NV = $865A;
+ GL_VERTEX_ATTRIB_ARRAY11_NV = $865B;
+ GL_VERTEX_ATTRIB_ARRAY12_NV = $865C;
+ GL_VERTEX_ATTRIB_ARRAY13_NV = $865D;
+ GL_VERTEX_ATTRIB_ARRAY14_NV = $865E;
+ GL_VERTEX_ATTRIB_ARRAY15_NV = $865F;
+ GL_MAP1_VERTEX_ATTRIB0_4_NV = $8660;
+ GL_MAP1_VERTEX_ATTRIB1_4_NV = $8661;
+ GL_MAP1_VERTEX_ATTRIB2_4_NV = $8662;
+ GL_MAP1_VERTEX_ATTRIB3_4_NV = $8663;
+ GL_MAP1_VERTEX_ATTRIB4_4_NV = $8664;
+ GL_MAP1_VERTEX_ATTRIB5_4_NV = $8665;
+ GL_MAP1_VERTEX_ATTRIB6_4_NV = $8666;
+ GL_MAP1_VERTEX_ATTRIB7_4_NV = $8667;
+ GL_MAP1_VERTEX_ATTRIB8_4_NV = $8668;
+ GL_MAP1_VERTEX_ATTRIB9_4_NV = $8669;
+ GL_MAP1_VERTEX_ATTRIB10_4_NV = $866A;
+ GL_MAP1_VERTEX_ATTRIB11_4_NV = $866B;
+ GL_MAP1_VERTEX_ATTRIB12_4_NV = $866C;
+ GL_MAP1_VERTEX_ATTRIB13_4_NV = $866D;
+ GL_MAP1_VERTEX_ATTRIB14_4_NV = $866E;
+ GL_MAP1_VERTEX_ATTRIB15_4_NV = $866F;
+ GL_MAP2_VERTEX_ATTRIB0_4_NV = $8670;
+ GL_MAP2_VERTEX_ATTRIB1_4_NV = $8671;
+ GL_MAP2_VERTEX_ATTRIB2_4_NV = $8672;
+ GL_MAP2_VERTEX_ATTRIB3_4_NV = $8673;
+ GL_MAP2_VERTEX_ATTRIB4_4_NV = $8674;
+ GL_MAP2_VERTEX_ATTRIB5_4_NV = $8675;
+ GL_MAP2_VERTEX_ATTRIB6_4_NV = $8676;
+ GL_MAP2_VERTEX_ATTRIB7_4_NV = $8677;
+ GL_MAP2_VERTEX_ATTRIB8_4_NV = $8678;
+ GL_MAP2_VERTEX_ATTRIB9_4_NV = $8679;
+ GL_MAP2_VERTEX_ATTRIB10_4_NV = $867A;
+ GL_MAP2_VERTEX_ATTRIB11_4_NV = $867B;
+ GL_MAP2_VERTEX_ATTRIB12_4_NV = $867C;
+ GL_MAP2_VERTEX_ATTRIB13_4_NV = $867D;
+ GL_MAP2_VERTEX_ATTRIB14_4_NV = $867E;
+ GL_MAP2_VERTEX_ATTRIB15_4_NV = $867F;
+var
+ glBindProgramNV: procedure(target: GLenum; id: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteProgramsNV: procedure(n: GLsizei; const ids: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glExecuteProgramNV: procedure(target: GLenum; id: GLuint; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGenProgramsNV: procedure(n: GLsizei; ids: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glAreProgramsResidentNV: function(n: GLsizei; const ids: PGLuint; residences: PGLboolean): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRequestResidentProgramsNV: procedure(n: GLsizei; ids: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramParameterfvNV: procedure(target: GLenum; index: GLuint; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramParameterdvNV: procedure(target: GLenum; index: GLuint; pname: GLenum; params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramivNV: procedure(id: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramStringNV: procedure(id: GLuint; pname: GLenum; _program: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTrackMatrixivNV: procedure(target: GLenum; address: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribdvNV: procedure(index: GLuint; pname: GLenum; params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribfvNV: procedure(index: GLuint; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribivNV: procedure(index: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribPointervNV: procedure(index: GLuint; pname: GLenum; pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsProgramNV: function(id: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLoadProgramNV: procedure(target: GLenum; id: GLuint; len: GLsizei; const _program: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramParameter4fNV: procedure(target: GLenum; index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramParameter4fvNV: procedure(target: GLenum; index: GLuint; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramParameters4dvNV: procedure(target: GLenum; index: GLuint; num: GLuint; const params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramParameters4fvNV: procedure(target: GLenum; index: GLuint; num: GLuint; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTrackMatrixNV: procedure(target: GLenum; address: GLuint; matrix: GLenum; transform: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribPointerNV: procedure(index: GLuint; size: GLint; _type: GLenum; stride: GLsizei; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1sNV: procedure(index: GLuint; x: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1fNV: procedure(index: GLuint; x: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1dNV: procedure(index: GLuint; x: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2sNV: procedure(index: GLuint; x: GLshort; y: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2fNV: procedure(index: GLuint; x: GLfloat; y: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2dNV: procedure(index: GLuint; x: GLdouble; y: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3sNV: procedure(index: GLuint; x: GLshort; y: GLshort; z: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3fNV: procedure(index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3dNV: procedure(index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4sNV: procedure(index: GLuint; x: GLshort; y: GLshort; z: GLshort; w: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4fNV: procedure(index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4dNV: procedure(index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4ubNV: procedure(index: GLuint; x: GLubyte; y: GLubyte; z: GLubyte; w: GLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1svNV: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1fvNV: procedure(index: GLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1dvNV: procedure(index: GLuint; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2svNV: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2fvNV: procedure(index: GLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2dvNV: procedure(index: GLuint; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3svNV: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3fvNV: procedure(index: GLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3dvNV: procedure(index: GLuint; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4svNV: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4fvNV: procedure(index: GLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4dvNV: procedure(index: GLuint; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4ubvNV: procedure(index: GLuint; const v: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs1svNV: procedure(index: GLuint; n: GLsizei; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs1fvNV: procedure(index: GLuint; n: GLsizei; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs1dvNV: procedure(index: GLuint; n: GLsizei; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs2svNV: procedure(index: GLuint; n: GLsizei; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs2fvNV: procedure(index: GLuint; n: GLsizei; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs2dvNV: procedure(index: GLuint; n: GLsizei; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs3svNV: procedure(index: GLuint; n: GLsizei; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs3fvNV: procedure(index: GLuint; n: GLsizei; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs3dvNV: procedure(index: GLuint; n: GLsizei; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs4svNV: procedure(index: GLuint; n: GLsizei; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs4fvNV: procedure(index: GLuint; n: GLsizei; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs4dvNV: procedure(index: GLuint; n: GLsizei; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs4ubvNV: procedure(index: GLuint; n: GLsizei; const v: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_NV_vertex_program: Boolean;
+
+//***** GL_NV_vertex_program1_1 *****//
+
+function Load_GL_NV_vertex_program1_1: Boolean;
+
+//***** GL_ATI_element_array *****//
+const
+ GL_ELEMENT_ARRAY_ATI = $8768;
+ GL_ELEMENT_ARRAY_TYPE_ATI = $8769;
+ GL_ELEMENT_ARRAY_POINTER_ATI = $876A;
+var
+ glElementPointerATI: procedure(_type: GLenum; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDrawElementArrayATI: procedure(mode: GLenum; count: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDrawRangeElementArrayATI: procedure(mode: GLenum; start: GLuint; _end: GLuint; count: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ATI_element_array: Boolean;
+
+//***** GL_ATI_envmap_bumpmap *****//
+const
+ GL_BUMP_ROT_MATRIX_ATI = $8775;
+ GL_BUMP_ROT_MATRIX_SIZE_ATI = $8776;
+ GL_BUMP_NUM_TEX_UNITS_ATI = $8777;
+ GL_BUMP_TEX_UNITS_ATI = $8778;
+ GL_DUDV_ATI = $8779;
+ GL_DU8DV8_ATI = $877A;
+ GL_BUMP_ENVMAP_ATI = $877B;
+ GL_BUMP_TARGET_ATI = $877C;
+var
+ glTexBumpParameterivATI: procedure(pname: GLenum; param: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexBumpParameterfvATI: procedure(pname: GLenum; param: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTexBumpParameterivATI: procedure(pname: GLenum; param: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetTexBumpParameterfvATI: procedure(pname: GLenum; param: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ATI_envmap_bumpmap: Boolean;
+
+//***** GL_ATI_fragment_shader *****//
+const
+ GL_FRAGMENT_SHADER_ATI = $8920;
+ GL_REG_0_ATI = $8921;
+ GL_REG_1_ATI = $8922;
+ GL_REG_2_ATI = $8923;
+ GL_REG_3_ATI = $8924;
+ GL_REG_4_ATI = $8925;
+ GL_REG_5_ATI = $8926;
+ GL_CON_0_ATI = $8941;
+ GL_CON_1_ATI = $8942;
+ GL_CON_2_ATI = $8943;
+ GL_CON_3_ATI = $8944;
+ GL_CON_4_ATI = $8945;
+ GL_CON_5_ATI = $8946;
+ GL_CON_6_ATI = $8947;
+ GL_CON_7_ATI = $8948;
+ GL_MOV_ATI = $8961;
+ GL_ADD_ATI = $8963;
+ GL_MUL_ATI = $8964;
+ GL_SUB_ATI = $8965;
+ GL_DOT3_ATI = $8966;
+ GL_DOT4_ATI = $8967;
+ GL_MAD_ATI = $8968;
+ GL_LERP_ATI = $8969;
+ GL_CND_ATI = $896A;
+ GL_CND0_ATI = $896B;
+ GL_DOT2_ADD_ATI = $896C;
+ GL_SECONDARY_INTERPOLATOR_ATI = $896D;
+ GL_SWIZZLE_STR_ATI = $8976;
+ GL_SWIZZLE_STQ_ATI = $8977;
+ GL_SWIZZLE_STR_DR_ATI = $8978;
+ GL_SWIZZLE_STQ_DQ_ATI = $8979;
+ GL_RED_BIT_ATI = $0001;
+ GL_GREEN_BIT_ATI = $0002;
+ GL_BLUE_BIT_ATI = $0004;
+ GL_2X_BIT_ATI = $0001;
+ GL_4X_BIT_ATI = $0002;
+ GL_8X_BIT_ATI = $0004;
+ GL_HALF_BIT_ATI = $0008;
+ GL_QUARTER_BIT_ATI = $0010;
+ GL_EIGHTH_BIT_ATI = $0020;
+ GL_SATURATE_BIT_ATI = $0040;
+ // GL_2X_BIT_ATI { already defined }
+ GL_COMP_BIT_ATI = $0002;
+ GL_NEGATE_BIT_ATI = $0004;
+ GL_BIAS_BIT_ATI = $0008;
+var
+ glGenFragmentShadersATI: function(range: GLuint): GLuint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindFragmentShaderATI: procedure(id: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteFragmentShaderATI: procedure(id: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBeginFragmentShaderATI: procedure(); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEndFragmentShaderATI: procedure(); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPassTexCoordATI: procedure(dst: GLuint; coord: GLuint; swizzle: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSampleMapATI: procedure(dst: GLuint; interp: GLuint; swizzle: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColorFragmentOp1ATI: procedure(op: GLenum; dst: GLuint; dstMask: GLuint; dstMod: GLuint; arg1: GLuint; arg1Rep: GLuint; arg1Mod: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColorFragmentOp2ATI: procedure(op: GLenum; dst: GLuint; dstMask: GLuint; dstMod: GLuint; arg1: GLuint; arg1Rep: GLuint; arg1Mod: GLuint; arg2: GLuint; arg2Rep: GLuint; arg2Mod: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColorFragmentOp3ATI: procedure(op: GLenum; dst: GLuint; dstMask: GLuint; dstMod: GLuint; arg1: GLuint; arg1Rep: GLuint; arg1Mod: GLuint; arg2: GLuint; arg2Rep: GLuint; arg2Mod: GLuint; arg3: GLuint; arg3Rep: GLuint; arg3Mod: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glAlphaFragmentOp1ATI: procedure(op: GLenum; dst: GLuint; dstMod: GLuint; arg1: GLuint; arg1Rep: GLuint; arg1Mod: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glAlphaFragmentOp2ATI: procedure(op: GLenum; dst: GLuint; dstMod: GLuint; arg1: GLuint; arg1Rep: GLuint; arg1Mod: GLuint; arg2: GLuint; arg2Rep: GLuint; arg2Mod: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glAlphaFragmentOp3ATI: procedure(op: GLenum; dst: GLuint; dstMod: GLuint; arg1: GLuint; arg1Rep: GLuint; arg1Mod: GLuint; arg2: GLuint; arg2Rep: GLuint; arg2Mod: GLuint; arg3: GLuint; arg3Rep: GLuint; arg3Mod: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSetFragmentShaderConstantATI: procedure(dst: GLuint; const value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ATI_fragment_shader: Boolean;
+
+//***** GL_ATI_pn_triangles *****//
+const
+ GL_PN_TRIANGLES_ATI = $87F0;
+ GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI = $87F1;
+ GL_PN_TRIANGLES_POINT_MODE_ATI = $87F2;
+ GL_PN_TRIANGLES_NORMAL_MODE_ATI = $87F3;
+ GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI = $87F4;
+ GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI = $87F5;
+ GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI = $87F6;
+ GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI = $87F7;
+ GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI = $87F8;
+var
+ glPNTrianglesiATI: procedure(pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPNTrianglesfATI: procedure(pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ATI_pn_triangles: Boolean;
+
+//***** GL_ATI_texture_mirror_once *****//
+const
+ GL_MIRROR_CLAMP_ATI = $8742;
+ GL_MIRROR_CLAMP_TO_EDGE_ATI = $8743;
+
+function Load_GL_ATI_texture_mirror_once: Boolean;
+
+//***** GL_ATI_vertex_array_object *****//
+const
+ GL_STATIC_ATI = $8760;
+ GL_DYNAMIC_ATI = $8761;
+ GL_PRESERVE_ATI = $8762;
+ GL_DISCARD_ATI = $8763;
+ GL_OBJECT_BUFFER_SIZE_ATI = $8764;
+ GL_OBJECT_BUFFER_USAGE_ATI = $8765;
+ GL_ARRAY_OBJECT_BUFFER_ATI = $8766;
+ GL_ARRAY_OBJECT_OFFSET_ATI = $8767;
+var
+ glNewObjectBufferATI: function(size: GLsizei; const pointer: PGLvoid; usage: GLenum): GLuint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsObjectBufferATI: function(buffer: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUpdateObjectBufferATI: procedure(buffer: GLuint; offset: GLuint; size: GLsizei; const pointer: PGLvoid; preserve: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetObjectBufferfvATI: procedure(buffer: GLuint; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetObjectBufferivATI: procedure(buffer: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteObjectBufferATI: procedure(buffer: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glArrayObjectATI: procedure(_array: GLenum; size: GLint; _type: GLenum; stride: GLsizei; buffer: GLuint; offset: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetArrayObjectfvATI: procedure(_array: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetArrayObjectivATI: procedure(_array: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVariantArrayObjectATI: procedure(id: GLuint; _type: GLenum; stride: GLsizei; buffer: GLuint; offset: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVariantArrayObjectfvATI: procedure(id: GLuint; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVariantArrayObjectivATI: procedure(id: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ATI_vertex_array_object: Boolean;
+
+//***** GL_ATI_vertex_streams *****//
+const
+ GL_MAX_VERTEX_STREAMS_ATI = $876B;
+ GL_VERTEX_STREAM0_ATI = $876C;
+ GL_VERTEX_STREAM1_ATI = $876D;
+ GL_VERTEX_STREAM2_ATI = $876E;
+ GL_VERTEX_STREAM3_ATI = $876F;
+ GL_VERTEX_STREAM4_ATI = $8770;
+ GL_VERTEX_STREAM5_ATI = $8771;
+ GL_VERTEX_STREAM6_ATI = $8772;
+ GL_VERTEX_STREAM7_ATI = $8773;
+ GL_VERTEX_SOURCE_ATI = $8774;
+var
+ glVertexStream1s: procedure(stream: GLenum; coords: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream1i: procedure(stream: GLenum; coords: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream1f: procedure(stream: GLenum; coords: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream1d: procedure(stream: GLenum; coords: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream1sv: procedure(stream: GLenum; coords: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream1iv: procedure(stream: GLenum; coords: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream1fv: procedure(stream: GLenum; coords: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream1dv: procedure(stream: GLenum; coords: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream2s: procedure(stream: GLenum; coords: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream2i: procedure(stream: GLenum; coords: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream2f: procedure(stream: GLenum; coords: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream2d: procedure(stream: GLenum; coords: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream2sv: procedure(stream: GLenum; coords: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream2iv: procedure(stream: GLenum; coords: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream2fv: procedure(stream: GLenum; coords: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream2dv: procedure(stream: GLenum; coords: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream3s: procedure(stream: GLenum; coords: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream3i: procedure(stream: GLenum; coords: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream3f: procedure(stream: GLenum; coords: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream3d: procedure(stream: GLenum; coords: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream3sv: procedure(stream: GLenum; coords: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream3iv: procedure(stream: GLenum; coords: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream3fv: procedure(stream: GLenum; coords: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream3dv: procedure(stream: GLenum; coords: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream4s: procedure(stream: GLenum; coords: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream4i: procedure(stream: GLenum; coords: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream4f: procedure(stream: GLenum; coords: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream4d: procedure(stream: GLenum; coords: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream4sv: procedure(stream: GLenum; coords: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream4iv: procedure(stream: GLenum; coords: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream4fv: procedure(stream: GLenum; coords: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexStream4dv: procedure(stream: GLenum; coords: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalStream3b: procedure(stream: GLenum; coords: GLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalStream3s: procedure(stream: GLenum; coords: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalStream3i: procedure(stream: GLenum; coords: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalStream3f: procedure(stream: GLenum; coords: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalStream3d: procedure(stream: GLenum; coords: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalStream3bv: procedure(stream: GLenum; coords: GLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalStream3sv: procedure(stream: GLenum; coords: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalStream3iv: procedure(stream: GLenum; coords: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalStream3fv: procedure(stream: GLenum; coords: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalStream3dv: procedure(stream: GLenum; coords: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glClientActiveVertexStream: procedure(stream: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexBlendEnvi: procedure(pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexBlendEnvf: procedure(pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ATI_vertex_streams: Boolean;
+
+{$IFDEF WINDOWS}
+//***** WGL_I3D_image_buffer *****//
+const
+ WGL_IMAGE_BUFFER_MIN_ACCESS_I3D = $0001;
+ WGL_IMAGE_BUFFER_LOCK_I3D = $0002;
+var
+ wglCreateImageBufferI3D: function(hDC: HDC; dwSize: DWORD; uFlags: UINT): PGLvoid; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglDestroyImageBufferI3D: function(hDC: HDC; pAddress: PGLvoid): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglAssociateImageBufferEventsI3D: function(hdc: HDC; pEvent: PHandle; pAddress: PGLvoid; pSize: PDWORD; count: UINT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglReleaseImageBufferEventsI3D: function(hdc: HDC; pAddress: PGLvoid; count: UINT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_I3D_image_buffer: Boolean;
+
+//***** WGL_I3D_swap_frame_lock *****//
+var
+ wglEnableFrameLockI3D: function(): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglDisableFrameLockI3D: function(): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglIsEnabledFrameLockI3D: function(pFlag: PBOOL): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglQueryFrameLockMasterI3D: function(pFlag: PBOOL): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_I3D_swap_frame_lock: Boolean;
+
+//***** WGL_I3D_swap_frame_usage *****//
+var
+ wglGetFrameUsageI3D: function(pUsage: PGLfloat): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglBeginFrameTrackingI3D: function(): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglEndFrameTrackingI3D: function(): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglQueryFrameTrackingI3D: function(pFrameCount: PDWORD; pMissedFrames: PDWORD; pLastMissedUsage: PGLfloat): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_I3D_swap_frame_usage: Boolean;
+{$ENDIF}
+
+//***** GL_3DFX_texture_compression_FXT1 *****//
+const
+ GL_COMPRESSED_RGB_FXT1_3DFX = $86B0;
+ GL_COMPRESSED_RGBA_FXT1_3DFX = $86B1;
+
+function Load_GL_3DFX_texture_compression_FXT1: Boolean;
+
+//***** GL_IBM_cull_vertex *****//
+const
+ GL_CULL_VERTEX_IBM = $1928A;
+
+function Load_GL_IBM_cull_vertex: Boolean;
+
+//***** GL_IBM_multimode_draw_arrays *****//
+var
+ glMultiModeDrawArraysIBM: procedure(mode: PGLenum; first: PGLint; count: PGLsizei; primcount: GLsizei; modestride: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiModeDrawElementsIBM: procedure(mode: PGLenum; count: PGLsizei; _type: GLenum; const indices: PGLvoid; primcount: GLsizei; modestride: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_IBM_multimode_draw_arrays: Boolean;
+
+//***** GL_IBM_raster_pos_clip *****//
+const
+ GL_RASTER_POSITION_UNCLIPPED_IBM = $19262;
+
+function Load_GL_IBM_raster_pos_clip: Boolean;
+
+//***** GL_IBM_texture_mirrored_repeat *****//
+const
+ GL_MIRRORED_REPEAT_IBM = $8370;
+
+function Load_GL_IBM_texture_mirrored_repeat: Boolean;
+
+//***** GL_IBM_vertex_array_lists *****//
+const
+ GL_VERTEX_ARRAY_LIST_IBM = $1929E;
+ GL_NORMAL_ARRAY_LIST_IBM = $1929F;
+ GL_COLOR_ARRAY_LIST_IBM = $192A0;
+ GL_INDEX_ARRAY_LIST_IBM = $192A1;
+ GL_TEXTURE_COORD_ARRAY_LIST_IBM = $192A2;
+ GL_EDGE_FLAG_ARRAY_LIST_IBM = $192A3;
+ GL_FOG_COORDINATE_ARRAY_LIST_IBM = $192A4;
+ GL_SECONDARY_COLOR_ARRAY_LIST_IBM = $192A5;
+ GL_VERTEX_ARRAY_LIST_STRIDE_IBM = $192A8;
+ GL_NORMAL_ARRAY_LIST_STRIDE_IBM = $192A9;
+ GL_COLOR_ARRAY_LIST_STRIDE_IBM = $192AA;
+ GL_INDEX_ARRAY_LIST_STRIDE_IBM = $192AB;
+ GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM = $192AC;
+ GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM = $192AD;
+ GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM = $192AE;
+ GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM = $192AF;
+var
+ glColorPointerListIBM: procedure(size: GLint; _type: GLenum; stride: GLint; const pointer: PGLvoid; ptrstride: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColorPointerListIBM: procedure(size: GLint; _type: GLenum; stride: GLint; const pointer: PGLvoid; ptrstride: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEdgeFlagPointerListIBM: procedure(stride: GLint; const pointer: PGLboolean; ptrstride: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogCoordPointerListIBM: procedure(_type: GLenum; stride: GLint; const pointer: PGLvoid; ptrstride: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormalPointerListIBM: procedure(_type: GLenum; stride: GLint; const pointer: PGLvoid; ptrstride: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoordPointerListIBM: procedure(size: GLint; _type: GLenum; stride: GLint; const pointer: PGLvoid; ptrstride: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexPointerListIBM: procedure(size: GLint; _type: GLenum; stride: GLint; const pointer: PGLvoid; ptrstride: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_IBM_vertex_array_lists: Boolean;
+
+//***** GL_MESA_resize_buffers *****//
+var
+ glResizeBuffersMESA: procedure(); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_MESA_resize_buffers: Boolean;
+
+//***** GL_MESA_window_pos *****//
+var
+ glWindowPos2dMESA: procedure(x: GLdouble; y: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2fMESA: procedure(x: GLfloat; y: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2iMESA: procedure(x: GLint; y: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2sMESA: procedure(x: GLshort; y: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2ivMESA: procedure(const p: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2svMESA: procedure(const p: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2fvMESA: procedure(const p: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2dvMESA: procedure(const p: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3iMESA: procedure(x: GLint; y: GLint; z: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3sMESA: procedure(x: GLshort; y: GLshort; z: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3fMESA: procedure(x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3dMESA: procedure(x: GLdouble; y: GLdouble; z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3ivMESA: procedure(const p: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3svMESA: procedure(const p: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3fvMESA: procedure(const p: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3dvMESA: procedure(const p: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos4iMESA: procedure(x: GLint; y: GLint; z: GLint; w: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos4sMESA: procedure(x: GLshort; y: GLshort; z: GLshort; w: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos4fMESA: procedure(x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos4dMESA: procedure(x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos4ivMESA: procedure(const p: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos4svMESA: procedure(const p: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos4fvMESA: procedure(const p: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos4dvMESA: procedure(const p: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_MESA_window_pos: Boolean;
+
+//***** GL_OML_interlace *****//
+const
+ GL_INTERLACE_OML = $8980;
+ GL_INTERLACE_READ_OML = $8981;
+
+function Load_GL_OML_interlace: Boolean;
+
+//***** GL_OML_resample *****//
+const
+ GL_PACK_RESAMPLE_OML = $8984;
+ GL_UNPACK_RESAMPLE_OML = $8985;
+ GL_RESAMPLE_REPLICATE_OML = $8986;
+ GL_RESAMPLE_ZERO_FILL_OML = $8987;
+ GL_RESAMPLE_AVERAGE_OML = $8988;
+ GL_RESAMPLE_DECIMATE_OML = $8989;
+ // GL_RESAMPLE_AVERAGE_OML { already defined }
+
+function Load_GL_OML_resample: Boolean;
+
+//***** GL_OML_subsample *****//
+const
+ GL_FORMAT_SUBSAMPLE_24_24_OML = $8982;
+ GL_FORMAT_SUBSAMPLE_244_244_OML = $8983;
+
+function Load_GL_OML_subsample: Boolean;
+
+//***** GL_SGIS_generate_mipmap *****//
+const
+ GL_GENERATE_MIPMAP_SGIS = $8191;
+ GL_GENERATE_MIPMAP_HINT_SGIS = $8192;
+
+function Load_GL_SGIS_generate_mipmap: Boolean;
+
+//***** GL_SGIS_multisample *****//
+const
+ GLX_SAMPLE_BUFFERS_SGIS = $186A0;
+ GLX_SAMPLES_SGIS = $186A1;
+ GL_MULTISAMPLE_SGIS = $809D;
+ GL_SAMPLE_ALPHA_TO_MASK_SGIS = $809E;
+ GL_SAMPLE_ALPHA_TO_ONE_SGIS = $809F;
+ GL_SAMPLE_MASK_SGIS = $80A0;
+ GL_MULTISAMPLE_BIT_EXT = $20000000;
+ GL_1PASS_SGIS = $80A1;
+ GL_2PASS_0_SGIS = $80A2;
+ GL_2PASS_1_SGIS = $80A3;
+ GL_4PASS_0_SGIS = $80A4;
+ GL_4PASS_1_SGIS = $80A5;
+ GL_4PASS_2_SGIS = $80A6;
+ GL_4PASS_3_SGIS = $80A7;
+ GL_SAMPLE_BUFFERS_SGIS = $80A8;
+ GL_SAMPLES_SGIS = $80A9;
+ GL_SAMPLE_MASK_VALUE_SGIS = $80AA;
+ GL_SAMPLE_MASK_INVERT_SGIS = $80AB;
+ GL_SAMPLE_PATTERN_SGIS = $80AC;
+var
+ glSampleMaskSGIS: procedure(value: GLclampf; invert: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSamplePatternSGIS: procedure(pattern: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_SGIS_multisample: Boolean;
+
+//***** GL_SGIS_pixel_texture *****//
+const
+ GL_PIXEL_TEXTURE_SGIS = $8353;
+ GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS = $8354;
+ GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS = $8355;
+ GL_PIXEL_GROUP_COLOR_SGIS = $8356;
+var
+ glPixelTexGenParameteriSGIS: procedure(pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPixelTexGenParameterfSGIS: procedure(pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetPixelTexGenParameterivSGIS: procedure(pname: GLenum; params: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetPixelTexGenParameterfvSGIS: procedure(pname: GLenum; params: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_SGIS_pixel_texture: Boolean;
+
+//***** GL_SGIS_texture_border_clamp *****//
+ // GL_CLAMP_TO_BORDER_SGIS { already defined }
+
+function Load_GL_SGIS_texture_border_clamp: Boolean;
+
+//***** GL_SGIS_texture_color_mask *****//
+const
+ GL_TEXTURE_COLOR_WRITEMASK_SGIS = $81EF;
+var
+ glTextureColorMaskSGIS: procedure(r: GLboolean; g: GLboolean; b: GLboolean; a: GLboolean); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_SGIS_texture_color_mask: Boolean;
+
+//***** GL_SGIS_texture_edge_clamp *****//
+const
+ GL_CLAMP_TO_EDGE_SGIS = $812F;
+
+function Load_GL_SGIS_texture_edge_clamp: Boolean;
+
+//***** GL_SGIS_texture_lod *****//
+const
+ GL_TEXTURE_MIN_LOD_SGIS = $813A;
+ GL_TEXTURE_MAX_LOD_SGIS = $813B;
+ GL_TEXTURE_BASE_LEVEL_SGIS = $813C;
+ GL_TEXTURE_MAX_LEVEL_SGIS = $813D;
+
+function Load_GL_SGIS_texture_lod: Boolean;
+
+//***** GL_SGIS_depth_texture *****//
+const
+ GL_DEPTH_COMPONENT16_SGIX = $81A5;
+ GL_DEPTH_COMPONENT24_SGIX = $81A6;
+ GL_DEPTH_COMPONENT32_SGIX = $81A7;
+
+function Load_GL_SGIS_depth_texture: Boolean;
+
+//***** GL_SGIX_fog_offset *****//
+const
+ GL_FOG_OFFSET_SGIX = $8198;
+ GL_FOG_OFFSET_VALUE_SGIX = $8199;
+
+function Load_GL_SGIX_fog_offset: Boolean;
+
+//***** GL_SGIX_interlace *****//
+const
+ GL_INTERLACE_SGIX = $8094;
+
+function Load_GL_SGIX_interlace: Boolean;
+
+//***** GL_SGIX_shadow_ambient *****//
+const
+ GL_SHADOW_AMBIENT_SGIX = $80BF;
+
+function Load_GL_SGIX_shadow_ambient: Boolean;
+
+//***** GL_SGI_color_matrix *****//
+const
+ GL_COLOR_MATRIX_SGI = $80B1;
+ GL_COLOR_MATRIX_STACK_DEPTH_SGI = $80B2;
+ GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI = $80B3;
+ GL_POST_COLOR_MATRIX_RED_SCALE_SGI = $80B4;
+ GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI = $80B5;
+ GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI = $80B6;
+ GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI = $80B7;
+ GL_POST_COLOR_MATRIX_RED_BIAS_SGI = $80B8;
+ GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI = $80B9;
+ GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI = $80BA;
+ GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI = $80BB;
+
+function Load_GL_SGI_color_matrix: Boolean;
+
+//***** GL_SGI_color_table *****//
+const
+ GL_COLOR_TABLE_SGI = $80D0;
+ GL_POST_CONVOLUTION_COLOR_TABLE_SGI = $80D1;
+ GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI = $80D2;
+ GL_PROXY_COLOR_TABLE_SGI = $80D3;
+ GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI = $80D4;
+ GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI = $80D5;
+ GL_COLOR_TABLE_SCALE_SGI = $80D6;
+ GL_COLOR_TABLE_BIAS_SGI = $80D7;
+ GL_COLOR_TABLE_FORMAT_SGI = $80D8;
+ GL_COLOR_TABLE_WIDTH_SGI = $80D9;
+ GL_COLOR_TABLE_RED_SIZE_SGI = $80DA;
+ GL_COLOR_TABLE_GREEN_SIZE_SGI = $80DB;
+ GL_COLOR_TABLE_BLUE_SIZE_SGI = $80DC;
+ GL_COLOR_TABLE_ALPHA_SIZE_SGI = $80DD;
+ GL_COLOR_TABLE_LUMINANCE_SIZE_SGI = $80DE;
+ GL_COLOR_TABLE_INTENSITY_SIZE_SGI = $80DF;
+var
+ glColorTableSGI: procedure(target: GLenum; internalformat: GLenum; width: GLsizei; format: GLenum; _type: GLenum; const table: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCopyColorTableSGI: procedure(target: GLenum; internalformat: GLenum; x: GLint; y: GLint; width: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColorTableParameterivSGI: procedure(target: GLenum; pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColorTableParameterfvSGI: procedure(target: GLenum; pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetColorTableSGI: procedure(target: GLenum; format: GLenum; _type: GLenum; table: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetColorTableParameterivSGI: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetColorTableParameterfvSGI: procedure(target: GLenum; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_SGI_color_table: Boolean;
+
+//***** GL_SGI_texture_color_table *****//
+const
+ GL_TEXTURE_COLOR_TABLE_SGI = $80BC;
+ GL_PROXY_TEXTURE_COLOR_TABLE_SGI = $80BD;
+
+function Load_GL_SGI_texture_color_table: Boolean;
+
+//***** GL_SUN_vertex *****//
+var
+ glColor4ubVertex2fSUN: procedure(r: GLubyte; g: GLubyte; b: GLubyte; a: GLubyte; x: GLfloat; y: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4ubVertex2fvSUN: procedure(const c: PGLubyte; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4ubVertex3fSUN: procedure(r: GLubyte; g: GLubyte; b: GLubyte; a: GLubyte; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4ubVertex3fvSUN: procedure(const c: PGLubyte; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3fVertex3fSUN: procedure(r: GLfloat; g: GLfloat; b: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3fVertex3fvSUN: procedure(const c: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3fVertex3fSUN: procedure(nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3fVertex3fvSUN: procedure(const n: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4fNormal3fVertex3fSUN: procedure(r: GLfloat; g: GLfloat; b: GLfloat; a: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4fNormal3fVertex3fvSUN: procedure(const c: PGLfloat; const n: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2fVertex3fSUN: procedure(s: GLfloat; t: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2fVertex3fvSUN: procedure(const tc: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4fVertex4fSUN: procedure(s: GLfloat; t: GLfloat; p: GLfloat; q: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4fVertex4fvSUN: procedure(const tc: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2fColor4ubVertex3fSUN: procedure(s: GLfloat; t: GLfloat; r: GLubyte; g: GLubyte; b: GLubyte; a: GLubyte; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2fColor4ubVertex3fvSUN: procedure(const tc: PGLfloat; const c: PGLubyte; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2fColor3fVertex3fSUN: procedure(s: GLfloat; t: GLfloat; r: GLfloat; g: GLfloat; b: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2fColor3fVertex3fvSUN: procedure(const tc: PGLfloat; const c: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2fNormal3fVertex3fSUN: procedure(s: GLfloat; t: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2fNormal3fVertex3fvSUN: procedure(const tc: PGLfloat; const n: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2fColor4fNormal3fVertex3fSUN: procedure(s: GLfloat; t: GLfloat; r: GLfloat; g: GLfloat; b: GLfloat; a: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2fColor4fNormal3fVertex3fvSUN: procedure(const tc: PGLfloat; const c: PGLfloat; const n: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4fColor4fNormal3fVertex4fSUN: procedure(s: GLfloat; t: GLfloat; p: GLfloat; q: GLfloat; r: GLfloat; g: GLfloat; b: GLfloat; a: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4fColor4fNormal3fVertex4fvSUN: procedure(const tc: PGLfloat; const c: PGLfloat; const n: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiVertex3fSUN: procedure(rc: GLuint; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiVertex3fvSUN: procedure(const rc: PGLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiColor4ubVertex3fSUN: procedure(rc: GLuint; r: GLubyte; g: GLubyte; b: GLubyte; a: GLubyte; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiColor4ubVertex3fvSUN: procedure(const rc: PGLuint; const c: PGLubyte; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiColor3fVertex3fSUN: procedure(rc: GLuint; r: GLfloat; g: GLfloat; b: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiColor3fVertex3fvSUN: procedure(const rc: PGLuint; const c: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiNormal3fVertex3fSUN: procedure(rc: GLuint; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiNormal3fVertex3fvSUN: procedure(const rc: PGLuint; const n: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiColor4fNormal3fVertex3fSUN: procedure(rc: GLuint; r: GLfloat; g: GLfloat; b: GLfloat; a: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiColor4fNormal3fVertex3fvSUN: procedure(const rc: PGLuint; const c: PGLfloat; const n: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiTexCoord2fVertex3fSUN: procedure(rc: GLuint; s: GLfloat; t: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiTexCoord2fVertex3fvSUN: procedure(const rc: PGLuint; const tc: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN: procedure(rc: GLuint; s: GLfloat; t: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN: procedure(const rc: PGLuint; const tc: PGLfloat; const n: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN: procedure(rc: GLuint; s: GLfloat; t: GLfloat; r: GLfloat; g: GLfloat; b: GLfloat; a: GLfloat; nx: GLfloat; ny: GLfloat; nz: GLfloat; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN: procedure(const rc: PGLuint; const tc: PGLfloat; const c: PGLfloat; const n: PGLfloat; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_SUN_vertex: Boolean;
+
+//***** GL_ARB_fragment_program *****//
+const
+ GL_FRAGMENT_PROGRAM_ARB = $8804;
+ // GL_PROGRAM_FORMAT_ASCII_ARB { already defined }
+ // GL_PROGRAM_LENGTH_ARB { already defined }
+ // GL_PROGRAM_FORMAT_ARB { already defined }
+ // GL_PROGRAM_BINDING_ARB { already defined }
+ // GL_PROGRAM_INSTRUCTIONS_ARB { already defined }
+ // GL_MAX_PROGRAM_INSTRUCTIONS_ARB { already defined }
+ // GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB { already defined }
+ // GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB { already defined }
+ // GL_PROGRAM_TEMPORARIES_ARB { already defined }
+ // GL_MAX_PROGRAM_TEMPORARIES_ARB { already defined }
+ // GL_PROGRAM_NATIVE_TEMPORARIES_ARB { already defined }
+ // GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB { already defined }
+ // GL_PROGRAM_PARAMETERS_ARB { already defined }
+ // GL_MAX_PROGRAM_PARAMETERS_ARB { already defined }
+ // GL_PROGRAM_NATIVE_PARAMETERS_ARB { already defined }
+ // GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB { already defined }
+ // GL_PROGRAM_ATTRIBS_ARB { already defined }
+ // GL_MAX_PROGRAM_ATTRIBS_ARB { already defined }
+ // GL_PROGRAM_NATIVE_ATTRIBS_ARB { already defined }
+ // GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB { already defined }
+ // GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB { already defined }
+ // GL_MAX_PROGRAM_ENV_PARAMETERS_ARB { already defined }
+ // GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB { already defined }
+ GL_PROGRAM_ALU_INSTRUCTIONS_ARB = $8805;
+ GL_PROGRAM_TEX_INSTRUCTIONS_ARB = $8806;
+ GL_PROGRAM_TEX_INDIRECTIONS_ARB = $8807;
+ GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB = $8808;
+ GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB = $8809;
+ GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB = $880A;
+ GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB = $880B;
+ GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB = $880C;
+ GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB = $880D;
+ GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB = $880E;
+ GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB = $880F;
+ GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB = $8810;
+ // GL_PROGRAM_STRING_ARB { already defined }
+ // GL_PROGRAM_ERROR_POSITION_ARB { already defined }
+ // GL_CURRENT_MATRIX_ARB { already defined }
+ // GL_TRANSPOSE_CURRENT_MATRIX_ARB { already defined }
+ // GL_CURRENT_MATRIX_STACK_DEPTH_ARB { already defined }
+ // GL_MAX_PROGRAM_MATRICES_ARB { already defined }
+ // GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB { already defined }
+ GL_MAX_TEXTURE_COORDS_ARB = $8871;
+ GL_MAX_TEXTURE_IMAGE_UNITS_ARB = $8872;
+ // GL_PROGRAM_ERROR_STRING_ARB { already defined }
+ // GL_MATRIX0_ARB { already defined }
+ // GL_MATRIX1_ARB { already defined }
+ // GL_MATRIX2_ARB { already defined }
+ // GL_MATRIX3_ARB { already defined }
+ // GL_MATRIX4_ARB { already defined }
+ // GL_MATRIX5_ARB { already defined }
+ // GL_MATRIX6_ARB { already defined }
+ // GL_MATRIX7_ARB { already defined }
+ // GL_MATRIX8_ARB { already defined }
+ // GL_MATRIX9_ARB { already defined }
+ // GL_MATRIX10_ARB { already defined }
+ // GL_MATRIX11_ARB { already defined }
+ // GL_MATRIX12_ARB { already defined }
+ // GL_MATRIX13_ARB { already defined }
+ // GL_MATRIX14_ARB { already defined }
+ // GL_MATRIX15_ARB { already defined }
+ // GL_MATRIX16_ARB { already defined }
+ // GL_MATRIX17_ARB { already defined }
+ // GL_MATRIX18_ARB { already defined }
+ // GL_MATRIX19_ARB { already defined }
+ // GL_MATRIX20_ARB { already defined }
+ // GL_MATRIX21_ARB { already defined }
+ // GL_MATRIX22_ARB { already defined }
+ // GL_MATRIX23_ARB { already defined }
+ // GL_MATRIX24_ARB { already defined }
+ // GL_MATRIX25_ARB { already defined }
+ // GL_MATRIX26_ARB { already defined }
+ // GL_MATRIX27_ARB { already defined }
+ // GL_MATRIX28_ARB { already defined }
+ // GL_MATRIX29_ARB { already defined }
+ // GL_MATRIX30_ARB { already defined }
+ // GL_MATRIX31_ARB { already defined }
+ // glProgramStringARB { already defined }
+ // glBindProgramARB { already defined }
+ // glDeleteProgramsARB { already defined }
+ // glGenProgramsARB { already defined }
+ // glProgramEnvParameter4dARB { already defined }
+ // glProgramEnvParameter4dvARB { already defined }
+ // glProgramEnvParameter4fARB { already defined }
+ // glProgramEnvParameter4fvARB { already defined }
+ // glProgramLocalParameter4dARB { already defined }
+ // glProgramLocalParameter4dvARB { already defined }
+ // glProgramLocalParameter4fARB { already defined }
+ // glProgramLocalParameter4fvARB { already defined }
+ // glGetProgramEnvParameterdvARB { already defined }
+ // glGetProgramEnvParameterfvARB { already defined }
+ // glGetProgramLocalParameterdvARB { already defined }
+ // glGetProgramLocalParameterfvARB { already defined }
+ // glGetProgramivARB { already defined }
+ // glGetProgramStringARB { already defined }
+ // glIsProgramARB { already defined }
+
+function Load_GL_ARB_fragment_program: Boolean;
+
+//***** GL_ATI_text_fragment_shader *****//
+const
+ GL_TEXT_FRAGMENT_SHADER_ATI = $8200;
+
+function Load_GL_ATI_text_fragment_shader: Boolean;
+
+//***** GL_APPLE_client_storage *****//
+const
+ GL_UNPACK_CLIENT_STORAGE_APPLE = $85B2;
+
+function Load_GL_APPLE_client_storage: Boolean;
+
+//***** GL_APPLE_element_array *****//
+const
+ GL_ELEMENT_ARRAY_APPLE = $8768;
+ GL_ELEMENT_ARRAY_TYPE_APPLE = $8769;
+ GL_ELEMENT_ARRAY_POINTER_APPLE = $876A;
+var
+ glElementPointerAPPLE: procedure(_type: GLenum; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDrawElementArrayAPPLE: procedure(mode: GLenum; first: GLint; count: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDrawRangeElementArrayAPPLE: procedure(mode: GLenum; start: GLuint; _end: GLuint; first: GLint; count: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiDrawElementArrayAPPLE: procedure(mode: GLenum; const first: PGLint; const count: PGLsizei; primcount: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiDrawRangeElementArrayAPPLE: procedure(mode: GLenum; start: GLuint; _end: GLuint; const first: PGLint; const count: PGLsizei; primcount: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_APPLE_element_array: Boolean;
+
+//***** GL_APPLE_fence *****//
+const
+ GL_DRAW_PIXELS_APPLE = $8A0A;
+ GL_FENCE_APPLE = $8A0B;
+var
+ glGenFencesAPPLE: procedure(n: GLsizei; fences: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteFencesAPPLE: procedure(n: GLsizei; const fences: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSetFenceAPPLE: procedure(fence: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsFenceAPPLE: function(fence: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTestFenceAPPLE: function(fence: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFinishFenceAPPLE: procedure(fence: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTestObjectAPPLE: function(_object: GLenum; name: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFinishObjectAPPLE: procedure(_object: GLenum; name: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_APPLE_fence: Boolean;
+
+//***** GL_APPLE_vertex_array_object *****//
+const
+ GL_VERTEX_ARRAY_BINDING_APPLE = $85B5;
+var
+ glBindVertexArrayAPPLE: procedure(_array: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteVertexArraysAPPLE: procedure(n: GLsizei; const arrays: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGenVertexArraysAPPLE: procedure(n: GLsizei; const arrays: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsVertexArrayAPPLE: function(_array: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_APPLE_vertex_array_object: Boolean;
+
+//***** GL_APPLE_vertex_array_range *****//
+const
+ GL_VERTEX_ARRAY_RANGE_APPLE = $851D;
+ GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE = $851E;
+ GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE = $8520;
+ GL_VERTEX_ARRAY_RANGE_POINTER_APPLE = $8521;
+ GL_VERTEX_ARRAY_STORAGE_HINT_APPLE = $851F;
+ GL_STORAGE_CACHED_APPLE = $85BE;
+ GL_STORAGE_SHARED_APPLE = $85BF;
+var
+ glVertexArrayRangeAPPLE: procedure(length: GLsizei; pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFlushVertexArrayRangeAPPLE: procedure(length: GLsizei; pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexArrayParameteriAPPLE: procedure(pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_APPLE_vertex_array_range: Boolean;
+
+{$IFDEF WINDOWS}
+//***** WGL_ARB_pixel_format *****//
+const
+ WGL_NUMBER_PIXEL_FORMATS_ARB = $2000;
+ WGL_DRAW_TO_WINDOW_ARB = $2001;
+ WGL_DRAW_TO_BITMAP_ARB = $2002;
+ WGL_ACCELERATION_ARB = $2003;
+ WGL_NEED_PALETTE_ARB = $2004;
+ WGL_NEED_SYSTEM_PALETTE_ARB = $2005;
+ WGL_SWAP_LAYER_BUFFERS_ARB = $2006;
+ WGL_SWAP_METHOD_ARB = $2007;
+ WGL_NUMBER_OVERLAYS_ARB = $2008;
+ WGL_NUMBER_UNDERLAYS_ARB = $2009;
+ WGL_TRANSPARENT_ARB = $200A;
+ WGL_TRANSPARENT_RED_VALUE_ARB = $2037;
+ WGL_TRANSPARENT_GREEN_VALUE_ARB = $2038;
+ WGL_TRANSPARENT_BLUE_VALUE_ARB = $2039;
+ WGL_TRANSPARENT_ALPHA_VALUE_ARB = $203A;
+ WGL_TRANSPARENT_INDEX_VALUE_ARB = $203B;
+ WGL_SHARE_DEPTH_ARB = $200C;
+ WGL_SHARE_STENCIL_ARB = $200D;
+ WGL_SHARE_ACCUM_ARB = $200E;
+ WGL_SUPPORT_GDI_ARB = $200F;
+ WGL_SUPPORT_OPENGL_ARB = $2010;
+ WGL_DOUBLE_BUFFER_ARB = $2011;
+ WGL_STEREO_ARB = $2012;
+ WGL_PIXEL_TYPE_ARB = $2013;
+ WGL_COLOR_BITS_ARB = $2014;
+ WGL_RED_BITS_ARB = $2015;
+ WGL_RED_SHIFT_ARB = $2016;
+ WGL_GREEN_BITS_ARB = $2017;
+ WGL_GREEN_SHIFT_ARB = $2018;
+ WGL_BLUE_BITS_ARB = $2019;
+ WGL_BLUE_SHIFT_ARB = $201A;
+ WGL_ALPHA_BITS_ARB = $201B;
+ WGL_ALPHA_SHIFT_ARB = $201C;
+ WGL_ACCUM_BITS_ARB = $201D;
+ WGL_ACCUM_RED_BITS_ARB = $201E;
+ WGL_ACCUM_GREEN_BITS_ARB = $201F;
+ WGL_ACCUM_BLUE_BITS_ARB = $2020;
+ WGL_ACCUM_ALPHA_BITS_ARB = $2021;
+ WGL_DEPTH_BITS_ARB = $2022;
+ WGL_STENCIL_BITS_ARB = $2023;
+ WGL_AUX_BUFFERS_ARB = $2024;
+ WGL_NO_ACCELERATION_ARB = $2025;
+ WGL_GENERIC_ACCELERATION_ARB = $2026;
+ WGL_FULL_ACCELERATION_ARB = $2027;
+ WGL_SWAP_EXCHANGE_ARB = $2028;
+ WGL_SWAP_COPY_ARB = $2029;
+ WGL_SWAP_UNDEFINED_ARB = $202A;
+ WGL_TYPE_RGBA_ARB = $202B;
+ WGL_TYPE_COLORINDEX_ARB = $202C;
+var
+ wglGetPixelFormatAttribivARB: function(hdc: HDC; iPixelFormat: GLint; iLayerPlane: GLint; nAttributes: GLuint; const piAttributes: PGLint; piValues: PGLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGetPixelFormatAttribfvARB: function(hdc: HDC; iPixelFormat: GLint; iLayerPlane: GLint; nAttributes: GLuint; const piAttributes: PGLint; pfValues: PGLfloat): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglChoosePixelFormatARB: function(hdc: HDC; const piAttribIList: PGLint; const pfAttribFList: PGLfloat; nMaxFormats: GLuint; piFormats: PGLint; nNumFormats: PGLuint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_ARB_pixel_format: Boolean;
+
+//***** WGL_ARB_make_current_read *****//
+const
+ WGL_ERROR_INVALID_PIXEL_TYPE_ARB = $2043;
+ WGL_ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB = $2054;
+var
+ wglMakeContextCurrentARB: function(hDrawDC: HDC; hReadDC: HDC; hglrc: HGLRC): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGetCurrentReadDCARB: function(): HDC; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_ARB_make_current_read: Boolean;
+
+//***** WGL_ARB_pbuffer *****//
+const
+ WGL_DRAW_TO_PBUFFER_ARB = $202D;
+ // WGL_DRAW_TO_PBUFFER_ARB { already defined }
+ WGL_MAX_PBUFFER_PIXELS_ARB = $202E;
+ WGL_MAX_PBUFFER_WIDTH_ARB = $202F;
+ WGL_MAX_PBUFFER_HEIGHT_ARB = $2030;
+ WGL_PBUFFER_LARGEST_ARB = $2033;
+ WGL_PBUFFER_WIDTH_ARB = $2034;
+ WGL_PBUFFER_HEIGHT_ARB = $2035;
+ WGL_PBUFFER_LOST_ARB = $2036;
+var
+ wglCreatePbufferARB: function(hDC: HDC; iPixelFormat: GLint; iWidth: GLint; iHeight: GLint; const piAttribList: PGLint): THandle; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGetPbufferDCARB: function(hPbuffer: THandle): HDC; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglReleasePbufferDCARB: function(hPbuffer: THandle; hDC: HDC): GLint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglDestroyPbufferARB: function(hPbuffer: THandle): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglQueryPbufferARB: function(hPbuffer: THandle; iAttribute: GLint; piValue: PGLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_ARB_pbuffer: Boolean;
+
+//***** WGL_EXT_swap_control *****//
+var
+ wglSwapIntervalEXT: function(interval: GLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGetSwapIntervalEXT: function(): GLint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_EXT_swap_control: Boolean;
+
+//***** WGL_ARB_render_texture *****//
+const
+ WGL_BIND_TO_TEXTURE_RGB_ARB = $2070;
+ WGL_BIND_TO_TEXTURE_RGBA_ARB = $2071;
+ WGL_TEXTURE_FORMAT_ARB = $2072;
+ WGL_TEXTURE_TARGET_ARB = $2073;
+ WGL_MIPMAP_TEXTURE_ARB = $2074;
+ WGL_TEXTURE_RGB_ARB = $2075;
+ WGL_TEXTURE_RGBA_ARB = $2076;
+ WGL_NO_TEXTURE_ARB = $2077;
+ WGL_TEXTURE_CUBE_MAP_ARB = $2078;
+ WGL_TEXTURE_1D_ARB = $2079;
+ WGL_TEXTURE_2D_ARB = $207A;
+ // WGL_NO_TEXTURE_ARB { already defined }
+ WGL_MIPMAP_LEVEL_ARB = $207B;
+ WGL_CUBE_MAP_FACE_ARB = $207C;
+ WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB = $207D;
+ WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = $207E;
+ WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = $207F;
+ WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = $2080;
+ WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = $2081;
+ WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = $2082;
+ WGL_FRONT_LEFT_ARB = $2083;
+ WGL_FRONT_RIGHT_ARB = $2084;
+ WGL_BACK_LEFT_ARB = $2085;
+ WGL_BACK_RIGHT_ARB = $2086;
+ WGL_AUX0_ARB = $2087;
+ WGL_AUX1_ARB = $2088;
+ WGL_AUX2_ARB = $2089;
+ WGL_AUX3_ARB = $208A;
+ WGL_AUX4_ARB = $208B;
+ WGL_AUX5_ARB = $208C;
+ WGL_AUX6_ARB = $208D;
+ WGL_AUX7_ARB = $208E;
+ WGL_AUX8_ARB = $208F;
+ WGL_AUX9_ARB = $2090;
+var
+ wglBindTexImageARB: function(hPbuffer: THandle; iBuffer: GLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglReleaseTexImageARB: function(hPbuffer: THandle; iBuffer: GLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglSetPbufferAttribARB: function(hPbuffer: THandle; const piAttribList: PGLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_ARB_render_texture: Boolean;
+
+//***** WGL_EXT_extensions_string *****//
+var
+ wglGetExtensionsStringEXT: function(): Pchar; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_EXT_extensions_string: Boolean;
+
+//***** WGL_EXT_make_current_read *****//
+var
+ wglMakeContextCurrentEXT: function(hDrawDC: HDC; hReadDC: HDC; hglrc: HGLRC): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGetCurrentReadDCEXT: function(): HDC; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_EXT_make_current_read: Boolean;
+
+//***** WGL_EXT_pbuffer *****//
+const
+ WGL_DRAW_TO_PBUFFER_EXT = $202D;
+ WGL_MAX_PBUFFER_PIXELS_EXT = $202E;
+ WGL_MAX_PBUFFER_WIDTH_EXT = $202F;
+ WGL_MAX_PBUFFER_HEIGHT_EXT = $2030;
+ WGL_OPTIMAL_PBUFFER_WIDTH_EXT = $2031;
+ WGL_OPTIMAL_PBUFFER_HEIGHT_EXT = $2032;
+ WGL_PBUFFER_LARGEST_EXT = $2033;
+ WGL_PBUFFER_WIDTH_EXT = $2034;
+ WGL_PBUFFER_HEIGHT_EXT = $2035;
+var
+ wglCreatePbufferEXT: function(hDC: HDC; iPixelFormat: GLint; iWidth: GLint; iHeight: GLint; const piAttribList: PGLint): THandle; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGetPbufferDCEXT: function(hPbuffer: THandle): HDC; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglReleasePbufferDCEXT: function(hPbuffer: THandle; hDC: HDC): GLint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglDestroyPbufferEXT: function(hPbuffer: THandle): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglQueryPbufferEXT: function(hPbuffer: THandle; iAttribute: GLint; piValue: PGLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_EXT_pbuffer: Boolean;
+
+//***** WGL_EXT_pixel_format *****//
+const
+ WGL_NUMBER_PIXEL_FORMATS_EXT = $2000;
+ WGL_DRAW_TO_WINDOW_EXT = $2001;
+ WGL_DRAW_TO_BITMAP_EXT = $2002;
+ WGL_ACCELERATION_EXT = $2003;
+ WGL_NEED_PALETTE_EXT = $2004;
+ WGL_NEED_SYSTEM_PALETTE_EXT = $2005;
+ WGL_SWAP_LAYER_BUFFERS_EXT = $2006;
+ WGL_SWAP_METHOD_EXT = $2007;
+ WGL_NUMBER_OVERLAYS_EXT = $2008;
+ WGL_NUMBER_UNDERLAYS_EXT = $2009;
+ WGL_TRANSPARENT_EXT = $200A;
+ WGL_TRANSPARENT_VALUE_EXT = $200B;
+ WGL_SHARE_DEPTH_EXT = $200C;
+ WGL_SHARE_STENCIL_EXT = $200D;
+ WGL_SHARE_ACCUM_EXT = $200E;
+ WGL_SUPPORT_GDI_EXT = $200F;
+ WGL_SUPPORT_OPENGL_EXT = $2010;
+ WGL_DOUBLE_BUFFER_EXT = $2011;
+ WGL_STEREO_EXT = $2012;
+ WGL_PIXEL_TYPE_EXT = $2013;
+ WGL_COLOR_BITS_EXT = $2014;
+ WGL_RED_BITS_EXT = $2015;
+ WGL_RED_SHIFT_EXT = $2016;
+ WGL_GREEN_BITS_EXT = $2017;
+ WGL_GREEN_SHIFT_EXT = $2018;
+ WGL_BLUE_BITS_EXT = $2019;
+ WGL_BLUE_SHIFT_EXT = $201A;
+ WGL_ALPHA_BITS_EXT = $201B;
+ WGL_ALPHA_SHIFT_EXT = $201C;
+ WGL_ACCUM_BITS_EXT = $201D;
+ WGL_ACCUM_RED_BITS_EXT = $201E;
+ WGL_ACCUM_GREEN_BITS_EXT = $201F;
+ WGL_ACCUM_BLUE_BITS_EXT = $2020;
+ WGL_ACCUM_ALPHA_BITS_EXT = $2021;
+ WGL_DEPTH_BITS_EXT = $2022;
+ WGL_STENCIL_BITS_EXT = $2023;
+ WGL_AUX_BUFFERS_EXT = $2024;
+ WGL_NO_ACCELERATION_EXT = $2025;
+ WGL_GENERIC_ACCELERATION_EXT = $2026;
+ WGL_FULL_ACCELERATION_EXT = $2027;
+ WGL_SWAP_EXCHANGE_EXT = $2028;
+ WGL_SWAP_COPY_EXT = $2029;
+ WGL_SWAP_UNDEFINED_EXT = $202A;
+ WGL_TYPE_RGBA_EXT = $202B;
+ WGL_TYPE_COLORINDEX_EXT = $202C;
+var
+ wglGetPixelFormatAttribivEXT: function(hdc: HDC; iPixelFormat: GLint; iLayerPlane: GLint; nAttributes: GLuint; piAttributes: PGLint; piValues: PGLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGetPixelFormatAttribfvEXT: function(hdc: HDC; iPixelFormat: GLint; iLayerPlane: GLint; nAttributes: GLuint; piAttributes: PGLint; pfValues: PGLfloat): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglChoosePixelFormatEXT: function(hdc: HDC; const piAttribIList: PGLint; const pfAttribFList: PGLfloat; nMaxFormats: GLuint; piFormats: PGLint; nNumFormats: PGLuint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_EXT_pixel_format: Boolean;
+
+//***** WGL_I3D_digital_video_control *****//
+const
+ WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D = $2050;
+ WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D = $2051;
+ WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D = $2052;
+ WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D = $2053;
+var
+ wglGetDigitalVideoParametersI3D: function(hDC: HDC; iAttribute: GLint; piValue: PGLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglSetDigitalVideoParametersI3D: function(hDC: HDC; iAttribute: GLint; const piValue: PGLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_I3D_digital_video_control: Boolean;
+
+//***** WGL_I3D_gamma *****//
+const
+ WGL_GAMMA_TABLE_SIZE_I3D = $204E;
+ WGL_GAMMA_EXCLUDE_DESKTOP_I3D = $204F;
+ // WGL_GAMMA_EXCLUDE_DESKTOP_I3D { already defined }
+var
+ wglGetGammaTableParametersI3D: function(hDC: HDC; iAttribute: GLint; piValue: PGLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglSetGammaTableParametersI3D: function(hDC: HDC; iAttribute: GLint; const piValue: PGLint): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGetGammaTableI3D: function(hDC: HDC; iEntries: GLint; puRed: PGLUSHORT; puGreen: PGLUSHORT; puBlue: PGLUSHORT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglSetGammaTableI3D: function(hDC: HDC; iEntries: GLint; const puRed: PGLUSHORT; const puGreen: PGLUSHORT; const puBlue: PGLUSHORT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_I3D_gamma: Boolean;
+
+//***** WGL_I3D_genlock *****//
+const
+ WGL_GENLOCK_SOURCE_MULTIVIEW_I3D = $2044;
+ WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D = $2045;
+ WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D = $2046;
+ WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D = $2047;
+ WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D = $2048;
+ WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D = $2049;
+ WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D = $204A;
+ WGL_GENLOCK_SOURCE_EDGE_RISING_I3D = $204B;
+ WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D = $204C;
+var
+ wglEnableGenlockI3D: function(hDC: HDC): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglDisableGenlockI3D: function(hDC: HDC): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglIsEnabledGenlockI3D: function(hDC: HDC; pFlag: PBOOL): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGenlockSourceI3D: function(hDC: HDC; uSource: GLUINT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGetGenlockSourceI3D: function(hDC: HDC; uSource: PGLUINT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGenlockSourceEdgeI3D: function(hDC: HDC; uEdge: GLUINT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGetGenlockSourceEdgeI3D: function(hDC: HDC; uEdge: PGLUINT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGenlockSampleRateI3D: function(hDC: HDC; uRate: GLUINT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGetGenlockSampleRateI3D: function(hDC: HDC; uRate: PGLUINT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGenlockSourceDelayI3D: function(hDC: HDC; uDelay: GLUINT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglGetGenlockSourceDelayI3D: function(hDC: HDC; uDelay: PGLUINT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ wglQueryGenlockMaxSourceDelayI3D: function(hDC: HDC; uMaxLineDelay: PGLUINT; uMaxPixelDelay: PGLUINT): BOOL; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_WGL_I3D_genlock: Boolean;
+{$ENDIF}
+
+//***** GL_ARB_matrix_palette *****//
+const
+ GL_MATRIX_PALETTE_ARB = $8840;
+ GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB = $8841;
+ GL_MAX_PALETTE_MATRICES_ARB = $8842;
+ GL_CURRENT_PALETTE_MATRIX_ARB = $8843;
+ GL_MATRIX_INDEX_ARRAY_ARB = $8844;
+ GL_CURRENT_MATRIX_INDEX_ARB = $8845;
+ GL_MATRIX_INDEX_ARRAY_SIZE_ARB = $8846;
+ GL_MATRIX_INDEX_ARRAY_TYPE_ARB = $8847;
+ GL_MATRIX_INDEX_ARRAY_STRIDE_ARB = $8848;
+ GL_MATRIX_INDEX_ARRAY_POINTER_ARB = $8849;
+var
+ glCurrentPaletteMatrixARB: procedure(index: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMatrixIndexubvARB: procedure(size: GLint; indices: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMatrixIndexusvARB: procedure(size: GLint; indices: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMatrixIndexuivARB: procedure(size: GLint; indices: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMatrixIndexPointerARB: procedure(size: GLint; _type: GLenum; stride: GLsizei; pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_matrix_palette: Boolean;
+
+//***** GL_NV_element_array *****//
+const
+ GL_ELEMENT_ARRAY_TYPE_NV = $8769;
+ GL_ELEMENT_ARRAY_POINTER_NV = $876A;
+var
+ glElementPointerNV: procedure(_type: GLenum; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDrawElementArrayNV: procedure(mode: GLenum; first: GLint; count: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDrawRangeElementArrayNV: procedure(mode: GLenum; start: GLuint; _end: GLuint; first: GLint; count: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiDrawElementArrayNV: procedure(mode: GLenum; const first: PGLint; const count: PGLsizei; primcount: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiDrawRangeElementArrayNV: procedure(mode: GLenum; start: GLuint; _end: GLuint; const first: PGLint; const count: PGLsizei; primcount: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_NV_element_array: Boolean;
+
+//***** GL_NV_float_buffer *****//
+const
+ GL_FLOAT_R_NV = $8880;
+ GL_FLOAT_RG_NV = $8881;
+ GL_FLOAT_RGB_NV = $8882;
+ GL_FLOAT_RGBA_NV = $8883;
+ GL_FLOAT_R16_NV = $8884;
+ GL_FLOAT_R32_NV = $8885;
+ GL_FLOAT_RG16_NV = $8886;
+ GL_FLOAT_RG32_NV = $8887;
+ GL_FLOAT_RGB16_NV = $8888;
+ GL_FLOAT_RGB32_NV = $8889;
+ GL_FLOAT_RGBA16_NV = $888A;
+ GL_FLOAT_RGBA32_NV = $888B;
+ GL_TEXTURE_FLOAT_COMPONENTS_NV = $888C;
+ GL_FLOAT_CLEAR_COLOR_VALUE_NV = $888D;
+ GL_FLOAT_RGBA_MODE_NV = $888E;
+{$IFDEF WINDOWS}
+ WGL_FLOAT_COMPONENTS_NV = $20B0;
+ WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV = $20B1;
+ WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV = $20B2;
+ WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV = $20B3;
+ WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV = $20B4;
+ WGL_TEXTURE_FLOAT_R_NV = $20B5;
+ WGL_TEXTURE_FLOAT_RG_NV = $20B6;
+ WGL_TEXTURE_FLOAT_RGB_NV = $20B7;
+ WGL_TEXTURE_FLOAT_RGBA_NV = $20B8;
+{$ENDIF}
+
+function Load_GL_NV_float_buffer: Boolean;
+
+//***** GL_NV_fragment_program *****//
+const
+ GL_FRAGMENT_PROGRAM_NV = $8870;
+ GL_MAX_TEXTURE_COORDS_NV = $8871;
+ GL_MAX_TEXTURE_IMAGE_UNITS_NV = $8872;
+ GL_FRAGMENT_PROGRAM_BINDING_NV = $8873;
+ GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV = $8868;
+ GL_PROGRAM_ERROR_STRING_NV = $8874;
+var
+ glProgramNamedParameter4fNV: procedure(id: GLuint; len: GLsizei; const name: PGLubyte; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glProgramNamedParameter4dNV: procedure(id: GLuint; len: GLsizei; const name: PGLubyte; x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramNamedParameterfvNV: procedure(id: GLuint; len: GLsizei; const name: PGLubyte; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramNamedParameterdvNV: procedure(id: GLuint; len: GLsizei; const name: PGLubyte; params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ // glProgramLocalParameter4dARB { already defined }
+ // glProgramLocalParameter4dvARB { already defined }
+ // glProgramLocalParameter4fARB { already defined }
+ // glProgramLocalParameter4fvARB { already defined }
+ // glGetProgramLocalParameterdvARB { already defined }
+ // glGetProgramLocalParameterfvARB { already defined }
+
+function Load_GL_NV_fragment_program: Boolean;
+
+//***** GL_NV_primitive_restart *****//
+const
+ GL_PRIMITIVE_RESTART_NV = $8558;
+ GL_PRIMITIVE_RESTART_INDEX_NV = $8559;
+var
+ glPrimitiveRestartNV: procedure(); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPrimitiveRestartIndexNV: procedure(index: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_NV_primitive_restart: Boolean;
+
+//***** GL_NV_vertex_program2 *****//
+
+function Load_GL_NV_vertex_program2: Boolean;
+
+{$IFDEF WINDOWS}
+//***** WGL_NV_render_texture_rectangle *****//
+const
+ WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV = $20A0;
+ WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV = $20A1;
+ WGL_TEXTURE_RECTANGLE_NV = $20A2;
+
+function Load_WGL_NV_render_texture_rectangle: Boolean;
+{$ENDIF}
+
+//***** GL_NV_pixel_data_range *****//
+const
+ GL_WRITE_PIXEL_DATA_RANGE_NV = $8878;
+ GL_READ_PIXEL_DATA_RANGE_NV = $8879;
+ GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV = $887A;
+ GL_READ_PIXEL_DATA_RANGE_LENGTH_NV = $887B;
+ GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV = $887C;
+ GL_READ_PIXEL_DATA_RANGE_POINTER_NV = $887D;
+var
+ glPixelDataRangeNV: procedure(target: GLenum; length: GLsizei; pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFlushPixelDataRangeNV: procedure(target: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ // wglAllocateMemoryNV { already defined }
+ // wglFreeMemoryNV { already defined }
+
+function Load_GL_NV_pixel_data_range: Boolean;
+
+//***** GL_EXT_texture_rectangle *****//
+const
+ GL_TEXTURE_RECTANGLE_EXT = $84F5;
+ GL_TEXTURE_BINDING_RECTANGLE_EXT = $84F6;
+ GL_PROXY_TEXTURE_RECTANGLE_EXT = $84F7;
+ GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT = $84F8;
+
+function Load_GL_EXT_texture_rectangle: Boolean;
+
+//***** GL_S3_s3tc *****//
+const
+ GL_RGB_S3TC = $83A0;
+ GL_RGB4_S3TC = $83A1;
+ GL_RGBA_S3TC = $83A2;
+ GL_RGBA4_S3TC = $83A3;
+
+function Load_GL_S3_s3tc: Boolean;
+
+//***** GL_ATI_draw_buffers *****//
+const
+ GL_MAX_DRAW_BUFFERS_ATI = $8824;
+ GL_DRAW_BUFFER0_ATI = $8825;
+ GL_DRAW_BUFFER1_ATI = $8826;
+ GL_DRAW_BUFFER2_ATI = $8827;
+ GL_DRAW_BUFFER3_ATI = $8828;
+ GL_DRAW_BUFFER4_ATI = $8829;
+ GL_DRAW_BUFFER5_ATI = $882A;
+ GL_DRAW_BUFFER6_ATI = $882B;
+ GL_DRAW_BUFFER7_ATI = $882C;
+ GL_DRAW_BUFFER8_ATI = $882D;
+ GL_DRAW_BUFFER9_ATI = $882E;
+ GL_DRAW_BUFFER10_ATI = $882F;
+ GL_DRAW_BUFFER11_ATI = $8830;
+ GL_DRAW_BUFFER12_ATI = $8831;
+ GL_DRAW_BUFFER13_ATI = $8832;
+ GL_DRAW_BUFFER14_ATI = $8833;
+ GL_DRAW_BUFFER15_ATI = $8834;
+var
+ glDrawBuffersATI: procedure(n: GLsizei; const bufs: PGLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ATI_draw_buffers: Boolean;
+
+{$IFDEF WINDOWS}
+//***** WGL_ATI_pixel_format_float *****//
+const
+ WGL_RGBA_FLOAT_MODE_ATI = $8820;
+ WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI = $8835;
+ WGL_TYPE_RGBA_FLOAT_ATI = $21A0;
+
+function Load_WGL_ATI_pixel_format_float: Boolean;
+{$ENDIF}
+
+//***** GL_ATI_texture_env_combine3 *****//
+const
+ GL_MODULATE_ADD_ATI = $8744;
+ GL_MODULATE_SIGNED_ADD_ATI = $8745;
+ GL_MODULATE_SUBTRACT_ATI = $8746;
+
+function Load_GL_ATI_texture_env_combine3: Boolean;
+
+//***** GL_ATI_texture_float *****//
+const
+ GL_RGBA_FLOAT32_ATI = $8814;
+ GL_RGB_FLOAT32_ATI = $8815;
+ GL_ALPHA_FLOAT32_ATI = $8816;
+ GL_INTENSITY_FLOAT32_ATI = $8817;
+ GL_LUMINANCE_FLOAT32_ATI = $8818;
+ GL_LUMINANCE_ALPHA_FLOAT32_ATI = $8819;
+ GL_RGBA_FLOAT16_ATI = $881A;
+ GL_RGB_FLOAT16_ATI = $881B;
+ GL_ALPHA_FLOAT16_ATI = $881C;
+ GL_INTENSITY_FLOAT16_ATI = $881D;
+ GL_LUMINANCE_FLOAT16_ATI = $881E;
+ GL_LUMINANCE_ALPHA_FLOAT16_ATI = $881F;
+
+function Load_GL_ATI_texture_float: Boolean;
+
+//***** GL_NV_texture_expand_normal *****//
+const
+ GL_TEXTURE_UNSIGNED_REMAP_MODE_NV = $888F;
+
+function Load_GL_NV_texture_expand_normal: Boolean;
+
+//***** GL_NV_half_float *****//
+const
+ GL_HALF_FLOAT_NV = $140B;
+var
+ glVertex2hNV: procedure(x: GLushort; y: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex2hvNV: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex3hNV: procedure(x: GLushort; y: GLushort; z: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex3hvNV: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex4hNV: procedure(x: GLushort; y: GLushort; z: GLushort; w: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertex4hvNV: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3hNV: procedure(nx: GLushort; ny: GLushort; nz: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glNormal3hvNV: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3hNV: procedure(red: GLushort; green: GLushort; blue: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor3hvNV: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4hNV: procedure(red: GLushort; green: GLushort; blue: GLushort; alpha: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glColor4hvNV: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord1hNV: procedure(s: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord1hvNV: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2hNV: procedure(s: GLushort; t: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord2hvNV: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord3hNV: procedure(s: GLushort; t: GLushort; r: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord3hvNV: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4hNV: procedure(s: GLushort; t: GLushort; r: GLushort; q: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glTexCoord4hvNV: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1hNV: procedure(target: GLenum; s: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord1hvNV: procedure(target: GLenum; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2hNV: procedure(target: GLenum; s: GLushort; t: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord2hvNV: procedure(target: GLenum; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3hNV: procedure(target: GLenum; s: GLushort; t: GLushort; r: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord3hvNV: procedure(target: GLenum; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4hNV: procedure(target: GLenum; s: GLushort; t: GLushort; r: GLushort; q: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiTexCoord4hvNV: procedure(target: GLenum; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogCoordhNV: procedure(fog: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogCoordhvNV: procedure(const fog: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3hNV: procedure(red: GLushort; green: GLushort; blue: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3hvNV: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexWeighthNV: procedure(weight: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexWeighthvNV: procedure(const weight: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1hNV: procedure(index: GLuint; x: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1hvNV: procedure(index: GLuint; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2hNV: procedure(index: GLuint; x: GLushort; y: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2hvNV: procedure(index: GLuint; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3hNV: procedure(index: GLuint; x: GLushort; y: GLushort; z: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3hvNV: procedure(index: GLuint; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4hNV: procedure(index: GLuint; x: GLushort; y: GLushort; z: GLushort; w: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4hvNV: procedure(index: GLuint; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs1hvNV: procedure(index: GLuint; n: GLsizei; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs2hvNV: procedure(index: GLuint; n: GLsizei; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs3hvNV: procedure(index: GLuint; n: GLsizei; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribs4hvNV: procedure(index: GLuint; n: GLsizei; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_NV_half_float: Boolean;
+
+//***** GL_ATI_map_object_buffer *****//
+var
+ glMapObjectBufferATI: function(buffer: GLuint): PGLvoid; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUnmapObjectBufferATI: procedure(buffer: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ATI_map_object_buffer: Boolean;
+
+//***** GL_ATI_separate_stencil *****//
+const
+ GL_KEEP = $1E00;
+ GL_ZERO = $0000;
+ GL_REPLACE = $1E01;
+ GL_INCR = $1E02;
+ GL_DECR = $1E03;
+ GL_INVERT = $150A;
+ GL_NEVER = $0200;
+ GL_LESS = $0201;
+ GL_LEQUAL = $0203;
+ GL_GREATER = $0204;
+ GL_GEQUAL = $0206;
+ GL_EQUAL = $0202;
+ GL_NOTEQUAL = $0205;
+ GL_ALWAYS = $0207;
+ GL_FRONT = $0404;
+ GL_BACK = $0405;
+ GL_FRONT_AND_BACK = $0408;
+ GL_STENCIL_BACK_FUNC_ATI = $8800;
+ GL_STENCIL_BACK_FAIL_ATI = $8801;
+ GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI = $8802;
+ GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI = $8803;
+var
+ glStencilOpSeparateATI: procedure(face: GLenum; sfail: GLenum; dpfail: GLenum; dppass: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glStencilFuncSeparateATI: procedure(frontfunc: GLenum; backfunc: GLenum; ref: GLint; mask: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ATI_separate_stencil: Boolean;
+
+//***** GL_ATI_vertex_attrib_array_object *****//
+var
+ glVertexAttribArrayObjectATI: procedure(index: GLuint; size: GLint; _type: GLenum; normalized: GLboolean; stride: GLsizei; buffer: GLuint; offset: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribArrayObjectfvATI: procedure(index: GLuint; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribArrayObjectivATI: procedure(index: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ATI_vertex_attrib_array_object: Boolean;
+
+//***** GL_ARB_vertex_buffer_object *****//
+const
+ GL_ARRAY_BUFFER_ARB = $8892;
+ GL_ELEMENT_ARRAY_BUFFER_ARB = $8893;
+ GL_ARRAY_BUFFER_BINDING_ARB = $8894;
+ GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB = $8895;
+ GL_VERTEX_ARRAY_BUFFER_BINDING_ARB = $8896;
+ GL_NORMAL_ARRAY_BUFFER_BINDING_ARB = $8897;
+ GL_COLOR_ARRAY_BUFFER_BINDING_ARB = $8898;
+ GL_INDEX_ARRAY_BUFFER_BINDING_ARB = $8899;
+ GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB = $889A;
+ GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB = $889B;
+ GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB = $889C;
+ GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB = $889D;
+ GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB = $889E;
+ GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB = $889F;
+ GL_STREAM_DRAW_ARB = $88E0;
+ GL_STREAM_READ_ARB = $88E1;
+ GL_STREAM_COPY_ARB = $88E2;
+ GL_STATIC_DRAW_ARB = $88E4;
+ GL_STATIC_READ_ARB = $88E5;
+ GL_STATIC_COPY_ARB = $88E6;
+ GL_DYNAMIC_DRAW_ARB = $88E8;
+ GL_DYNAMIC_READ_ARB = $88E9;
+ GL_DYNAMIC_COPY_ARB = $88EA;
+ GL_READ_ONLY_ARB = $88B8;
+ GL_WRITE_ONLY_ARB = $88B9;
+ GL_READ_WRITE_ARB = $88BA;
+ GL_BUFFER_SIZE_ARB = $8764;
+ GL_BUFFER_USAGE_ARB = $8765;
+ GL_BUFFER_ACCESS_ARB = $88BB;
+ GL_BUFFER_MAPPED_ARB = $88BC;
+ GL_BUFFER_MAP_POINTER_ARB = $88BD;
+var
+ glBindBufferARB: procedure(target: GLenum; buffer: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteBuffersARB: procedure(n: GLsizei; const buffers: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGenBuffersARB: procedure(n: GLsizei; buffers: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsBufferARB: function(buffer: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBufferDataARB: procedure(target: GLenum; size: GLsizeiptrARB; const data: PGLvoid; usage: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBufferSubDataARB: procedure(target: GLenum; offset: GLintptrARB; size: GLsizeiptrARB; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetBufferSubDataARB: procedure(target: GLenum; offset: GLintptrARB; size: GLsizeiptrARB; data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMapBufferARB: function(target: GLenum; access: GLenum): PGLvoid; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUnmapBufferARB: function(target: GLenum): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetBufferParameterivARB: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetBufferPointervARB: procedure(target: GLenum; pname: GLenum; params: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_vertex_buffer_object: Boolean;
+
+//***** GL_ARB_occlusion_query *****//
+const
+ GL_SAMPLES_PASSED_ARB = $8914;
+ GL_QUERY_COUNTER_BITS_ARB = $8864;
+ GL_CURRENT_QUERY_ARB = $8865;
+ GL_QUERY_RESULT_ARB = $8866;
+ GL_QUERY_RESULT_AVAILABLE_ARB = $8867;
+var
+ glGenQueriesARB: procedure(n: GLsizei; ids: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteQueriesARB: procedure(n: GLsizei; const ids: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsQueryARB: function(id: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBeginQueryARB: procedure(target: GLenum; id: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEndQueryARB: procedure(target: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetQueryivARB: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetQueryObjectivARB: procedure(id: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetQueryObjectuivARB: procedure(id: GLuint; pname: GLenum; params: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_occlusion_query: Boolean;
+
+//***** GL_ARB_shader_objects *****//
+const
+ GL_PROGRAM_OBJECT_ARB = $8B40;
+ GL_OBJECT_TYPE_ARB = $8B4E;
+ GL_OBJECT_SUBTYPE_ARB = $8B4F;
+ GL_OBJECT_DELETE_STATUS_ARB = $8B80;
+ GL_OBJECT_COMPILE_STATUS_ARB = $8B81;
+ GL_OBJECT_LINK_STATUS_ARB = $8B82;
+ GL_OBJECT_VALIDATE_STATUS_ARB = $8B83;
+ GL_OBJECT_INFO_LOG_LENGTH_ARB = $8B84;
+ GL_OBJECT_ATTACHED_OBJECTS_ARB = $8B85;
+ GL_OBJECT_ACTIVE_UNIFORMS_ARB = $8B86;
+ GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB = $8B87;
+ GL_OBJECT_SHADER_SOURCE_LENGTH_ARB = $8B88;
+ GL_SHADER_OBJECT_ARB = $8B48;
+ GL_FLOAT = $1406;
+ GL_FLOAT_VEC2_ARB = $8B50;
+ GL_FLOAT_VEC3_ARB = $8B51;
+ GL_FLOAT_VEC4_ARB = $8B52;
+ GL_INT = $1404;
+ GL_INT_VEC2_ARB = $8B53;
+ GL_INT_VEC3_ARB = $8B54;
+ GL_INT_VEC4_ARB = $8B55;
+ GL_BOOL_ARB = $8B56;
+ GL_BOOL_VEC2_ARB = $8B57;
+ GL_BOOL_VEC3_ARB = $8B58;
+ GL_BOOL_VEC4_ARB = $8B59;
+ GL_FLOAT_MAT2_ARB = $8B5A;
+ GL_FLOAT_MAT3_ARB = $8B5B;
+ GL_FLOAT_MAT4_ARB = $8B5C;
+var
+ glDeleteObjectARB: procedure(obj: GLhandleARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetHandleARB: function(pname: GLenum): GLhandleARB; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDetachObjectARB: procedure(containerObj: GLhandleARB; attachedObj: GLhandleARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCreateShaderObjectARB: function(shaderType: GLenum): GLhandleARB; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glShaderSourceARB: procedure(shaderObj: GLhandleARB; count: GLsizei; const _string: PGLvoid; const length: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompileShaderARB: procedure(shaderObj: GLhandleARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCreateProgramObjectARB: function(): GLhandleARB; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glAttachObjectARB: procedure(containerObj: GLhandleARB; obj: GLhandleARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLinkProgramARB: procedure(programObj: GLhandleARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUseProgramObjectARB: procedure(programObj: GLhandleARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glValidateProgramARB: procedure(programObj: GLhandleARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform1fARB: procedure(location: GLint; v0: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform2fARB: procedure(location: GLint; v0: GLfloat; v1: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform3fARB: procedure(location: GLint; v0: GLfloat; v1: GLfloat; v2: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform4fARB: procedure(location: GLint; v0: GLfloat; v1: GLfloat; v2: GLfloat; v3: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform1iARB: procedure(location: GLint; v0: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform2iARB: procedure(location: GLint; v0: GLint; v1: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform3iARB: procedure(location: GLint; v0: GLint; v1: GLint; v2: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform4iARB: procedure(location: GLint; v0: GLint; v1: GLint; v2: GLint; v3: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform1fvARB: procedure(location: GLint; count: GLsizei; value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform2fvARB: procedure(location: GLint; count: GLsizei; value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform3fvARB: procedure(location: GLint; count: GLsizei; value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform4fvARB: procedure(location: GLint; count: GLsizei; value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform1ivARB: procedure(location: GLint; count: GLsizei; value: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform2ivARB: procedure(location: GLint; count: GLsizei; value: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform3ivARB: procedure(location: GLint; count: GLsizei; value: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform4ivARB: procedure(location: GLint; count: GLsizei; value: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniformMatrix2fvARB: procedure(location: GLint; count: GLsizei; transpose: GLboolean; value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniformMatrix3fvARB: procedure(location: GLint; count: GLsizei; transpose: GLboolean; value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniformMatrix4fvARB: procedure(location: GLint; count: GLsizei; transpose: GLboolean; value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetObjectParameterfvARB: procedure(obj: GLhandleARB; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetObjectParameterivARB: procedure(obj: GLhandleARB; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetInfoLogARB: procedure(obj: GLhandleARB; maxLength: GLsizei; length: PGLsizei; infoLog: PGLcharARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetAttachedObjectsARB: procedure(containerObj: GLhandleARB; maxCount: GLsizei; count: PGLsizei; obj: PGLhandleARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetUniformLocationARB: function(programObj: GLhandleARB; const name: PGLcharARB): GLint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetActiveUniformARB: procedure(programObj: GLhandleARB; index: GLuint; maxLength: GLsizei; length: PGLsizei; size: PGLint; _type: PGLenum; name: PGLcharARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetUniformfvARB: procedure(programObj: GLhandleARB; location: GLint; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetUniformivARB: procedure(programObj: GLhandleARB; location: GLint; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetShaderSourceARB: procedure(obj: GLhandleARB; maxLength: GLsizei; length: PGLsizei; source: PGLcharARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_shader_objects: Boolean;
+
+//***** GL_ARB_vertex_shader *****//
+const
+ GL_VERTEX_SHADER_ARB = $8B31;
+ GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB = $8B4A;
+ GL_MAX_VARYING_FLOATS_ARB = $8B4B;
+ // GL_MAX_VERTEX_ATTRIBS_ARB { already defined }
+ // GL_MAX_TEXTURE_IMAGE_UNITS_ARB { already defined }
+ GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB = $8B4C;
+ GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB = $8B4D;
+ // GL_MAX_TEXTURE_COORDS_ARB { already defined }
+ // GL_VERTEX_PROGRAM_POINT_SIZE_ARB { already defined }
+ // GL_VERTEX_PROGRAM_TWO_SIDE_ARB { already defined }
+ // GL_OBJECT_TYPE_ARB { already defined }
+ // GL_OBJECT_SUBTYPE_ARB { already defined }
+ GL_OBJECT_ACTIVE_ATTRIBUTES_ARB = $8B89;
+ GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB = $8B8A;
+ // GL_SHADER_OBJECT_ARB { already defined }
+ // GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB { already defined }
+ // GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB { already defined }
+ // GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB { already defined }
+ // GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB { already defined }
+ // GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB { already defined }
+ // GL_CURRENT_VERTEX_ATTRIB_ARB { already defined }
+ // GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB { already defined }
+ // GL_FLOAT { already defined }
+ // GL_FLOAT_VEC2_ARB { already defined }
+ // GL_FLOAT_VEC3_ARB { already defined }
+ // GL_FLOAT_VEC4_ARB { already defined }
+ // GL_FLOAT_MAT2_ARB { already defined }
+ // GL_FLOAT_MAT3_ARB { already defined }
+ // GL_FLOAT_MAT4_ARB { already defined }
+ // glVertexAttrib1fARB { already defined }
+ // glVertexAttrib1sARB { already defined }
+ // glVertexAttrib1dARB { already defined }
+ // glVertexAttrib2fARB { already defined }
+ // glVertexAttrib2sARB { already defined }
+ // glVertexAttrib2dARB { already defined }
+ // glVertexAttrib3fARB { already defined }
+ // glVertexAttrib3sARB { already defined }
+ // glVertexAttrib3dARB { already defined }
+ // glVertexAttrib4fARB { already defined }
+ // glVertexAttrib4sARB { already defined }
+ // glVertexAttrib4dARB { already defined }
+ // glVertexAttrib4NubARB { already defined }
+ // glVertexAttrib1fvARB { already defined }
+ // glVertexAttrib1svARB { already defined }
+ // glVertexAttrib1dvARB { already defined }
+ // glVertexAttrib2fvARB { already defined }
+ // glVertexAttrib2svARB { already defined }
+ // glVertexAttrib2dvARB { already defined }
+ // glVertexAttrib3fvARB { already defined }
+ // glVertexAttrib3svARB { already defined }
+ // glVertexAttrib3dvARB { already defined }
+ // glVertexAttrib4fvARB { already defined }
+ // glVertexAttrib4svARB { already defined }
+ // glVertexAttrib4dvARB { already defined }
+ // glVertexAttrib4ivARB { already defined }
+ // glVertexAttrib4bvARB { already defined }
+ // glVertexAttrib4ubvARB { already defined }
+ // glVertexAttrib4usvARB { already defined }
+ // glVertexAttrib4uivARB { already defined }
+ // glVertexAttrib4NbvARB { already defined }
+ // glVertexAttrib4NsvARB { already defined }
+ // glVertexAttrib4NivARB { already defined }
+ // glVertexAttrib4NubvARB { already defined }
+ // glVertexAttrib4NusvARB { already defined }
+ // glVertexAttrib4NuivARB { already defined }
+ // glVertexAttribPointerARB { already defined }
+ // glEnableVertexAttribArrayARB { already defined }
+ // glDisableVertexAttribArrayARB { already defined }
+var
+ glBindAttribLocationARB: procedure(programObj: GLhandleARB; index: GLuint; const name: PGLcharARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetActiveAttribARB: procedure(programObj: GLhandleARB; index: GLuint; maxLength: GLsizei; length: PGLsizei; size: PGLint; _type: PGLenum; name: PGLcharARB); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetAttribLocationARB: function(programObj: GLhandleARB; const name: PGLcharARB): GLint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ // glGetVertexAttribdvARB { already defined }
+ // glGetVertexAttribfvARB { already defined }
+ // glGetVertexAttribivARB { already defined }
+ // glGetVertexAttribPointervARB { already defined }
+
+function Load_GL_ARB_vertex_shader: Boolean;
+
+//***** GL_ARB_fragment_shader *****//
+const
+ GL_FRAGMENT_SHADER_ARB = $8B30;
+ GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB = $8B49;
+ // GL_MAX_TEXTURE_COORDS_ARB { already defined }
+ // GL_MAX_TEXTURE_IMAGE_UNITS_ARB { already defined }
+ // GL_OBJECT_TYPE_ARB { already defined }
+ // GL_OBJECT_SUBTYPE_ARB { already defined }
+ // GL_SHADER_OBJECT_ARB { already defined }
+
+function Load_GL_ARB_fragment_shader: Boolean;
+
+//***** GL_ARB_shading_language_100 *****//
+
+function Load_GL_ARB_shading_language_100: Boolean;
+
+//***** GL_ARB_texture_non_power_of_two *****//
+
+function Load_GL_ARB_texture_non_power_of_two: Boolean;
+
+//***** GL_ARB_point_sprite *****//
+const
+ GL_POINT_SPRITE_ARB = $8861;
+ GL_COORD_REPLACE_ARB = $8862;
+
+function Load_GL_ARB_point_sprite: Boolean;
+
+//***** GL_EXT_depth_bounds_test *****//
+const
+ GL_DEPTH_BOUNDS_TEST_EXT = $8890;
+ GL_DEPTH_BOUNDS_EXT = $8891;
+var
+ glDepthBoundsEXT: procedure(zmin: GLclampd; zmax: GLclampd); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_depth_bounds_test: Boolean;
+
+//***** GL_EXT_secondary_color *****//
+const
+ GL_COLOR_SUM_EXT = $8458;
+ GL_CURRENT_SECONDARY_COLOR_EXT = $8459;
+ GL_SECONDARY_COLOR_ARRAY_SIZE_EXT = $845A;
+ GL_SECONDARY_COLOR_ARRAY_TYPE_EXT = $845B;
+ GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT = $845C;
+ GL_SECONDARY_COLOR_ARRAY_POINTER_EXT = $845D;
+ GL_SECONDARY_COLOR_ARRAY_EXT = $845E;
+var
+ glSecondaryColor3bEXT: procedure(r: GLbyte; g: GLbyte; b: GLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3sEXT: procedure(r: GLshort; g: GLshort; b: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3iEXT: procedure(r: GLint; g: GLint; b: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3fEXT: procedure(r: GLfloat; g: GLfloat; b: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3dEXT: procedure(r: GLdouble; g: GLdouble; b: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3ubEXT: procedure(r: GLubyte; g: GLubyte; b: GLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3usEXT: procedure(r: GLushort; g: GLushort; b: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3uiEXT: procedure(r: GLuint; g: GLuint; b: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3bvEXT: procedure(components: PGLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3svEXT: procedure(components: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3ivEXT: procedure(components: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3fvEXT: procedure(components: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3dvEXT: procedure(components: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3ubvEXT: procedure(components: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3usvEXT: procedure(components: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3uivEXT: procedure(components: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColorPointerEXT: procedure(size: GLint; _type: GLenum; stride: GLsizei; pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_secondary_color: Boolean;
+
+//***** GL_EXT_texture_mirror_clamp *****//
+const
+ GL_MIRROR_CLAMP_EXT = $8742;
+ GL_MIRROR_CLAMP_TO_EDGE_EXT = $8743;
+ GL_MIRROR_CLAMP_TO_BORDER_EXT = $8912;
+
+function Load_GL_EXT_texture_mirror_clamp: Boolean;
+
+//***** GL_EXT_blend_equation_separate *****//
+const
+ GL_BLEND_EQUATION_RGB_EXT = $8009;
+ GL_BLEND_EQUATION_ALPHA_EXT = $883D;
+var
+ glBlendEquationSeparateEXT: procedure(modeRGB: GLenum; modeAlpha: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_blend_equation_separate: Boolean;
+
+//***** GL_MESA_pack_invert *****//
+const
+ GL_PACK_INVERT_MESA = $8758;
+
+function Load_GL_MESA_pack_invert: Boolean;
+
+//***** GL_MESA_ycbcr_texture *****//
+const
+ GL_YCBCR_MESA = $8757;
+ GL_UNSIGNED_SHORT_8_8_MESA = $85BA;
+ GL_UNSIGNED_SHORT_8_8_REV_MESA = $85BB;
+
+function Load_GL_MESA_ycbcr_texture: Boolean;
+
+//***** GL_ARB_fragment_program_shadow *****//
+
+function Load_GL_ARB_fragment_program_shadow: Boolean;
+
+//***** GL_EXT_fog_coord *****//
+const
+ GL_FOG_COORDINATE_SOURCE_EXT = $8450;
+ GL_FOG_COORDINATE_EXT = $8451;
+ GL_FRAGMENT_DEPTH_EXT = $8452;
+ GL_CURRENT_FOG_COORDINATE_EXT = $8453;
+ GL_FOG_COORDINATE_ARRAY_TYPE_EXT = $8454;
+ GL_FOG_COORDINATE_ARRAY_STRIDE_EXT = $8455;
+ GL_FOG_COORDINATE_ARRAY_POINTER_EXT = $8456;
+ GL_FOG_COORDINATE_ARRAY_EXT = $8457;
+var
+ glFogCoordfEXT: procedure(coord: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogCoorddEXT: procedure(coord: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogCoordfvEXT: procedure(coord: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogCoorddvEXT: procedure(coord: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogCoordPointerEXT: procedure(_type: GLenum; stride: GLsizei; pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_fog_coord: Boolean;
+
+//***** GL_NV_fragment_program_option *****//
+
+function Load_GL_NV_fragment_program_option: Boolean;
+
+//***** GL_EXT_pixel_buffer_object *****//
+const
+ GL_PIXEL_PACK_BUFFER_EXT = $88EB;
+ GL_PIXEL_UNPACK_BUFFER_EXT = $88EC;
+ GL_PIXEL_PACK_BUFFER_BINDING_EXT = $88ED;
+ GL_PIXEL_UNPACK_BUFFER_BINDING_EXT = $88EF;
+
+function Load_GL_EXT_pixel_buffer_object: Boolean;
+
+//***** GL_NV_fragment_program2 *****//
+const
+ GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV = $88F4;
+ GL_MAX_PROGRAM_CALL_DEPTH_NV = $88F5;
+ GL_MAX_PROGRAM_IF_DEPTH_NV = $88F6;
+ GL_MAX_PROGRAM_LOOP_DEPTH_NV = $88F7;
+ GL_MAX_PROGRAM_LOOP_COUNT_NV = $88F8;
+
+function Load_GL_NV_fragment_program2: Boolean;
+
+//***** GL_NV_vertex_program2_option *****//
+ // GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV { already defined }
+ // GL_MAX_PROGRAM_CALL_DEPTH_NV { already defined }
+
+function Load_GL_NV_vertex_program2_option: Boolean;
+
+//***** GL_NV_vertex_program3 *****//
+ // GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB { already defined }
+
+function Load_GL_NV_vertex_program3: Boolean;
+
+//***** GL_ARB_draw_buffers *****//
+const
+ GL_MAX_DRAW_BUFFERS_ARB = $8824;
+ GL_DRAW_BUFFER0_ARB = $8825;
+ GL_DRAW_BUFFER1_ARB = $8826;
+ GL_DRAW_BUFFER2_ARB = $8827;
+ GL_DRAW_BUFFER3_ARB = $8828;
+ GL_DRAW_BUFFER4_ARB = $8829;
+ GL_DRAW_BUFFER5_ARB = $882A;
+ GL_DRAW_BUFFER6_ARB = $882B;
+ GL_DRAW_BUFFER7_ARB = $882C;
+ GL_DRAW_BUFFER8_ARB = $882D;
+ GL_DRAW_BUFFER9_ARB = $882E;
+ GL_DRAW_BUFFER10_ARB = $882F;
+ GL_DRAW_BUFFER11_ARB = $8830;
+ GL_DRAW_BUFFER12_ARB = $8831;
+ GL_DRAW_BUFFER13_ARB = $8832;
+ GL_DRAW_BUFFER14_ARB = $8833;
+ GL_DRAW_BUFFER15_ARB = $8834;
+var
+ glDrawBuffersARB: procedure(n: GLsizei; const bufs: PGLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_draw_buffers: Boolean;
+
+//***** GL_ARB_texture_rectangle *****//
+const
+ GL_TEXTURE_RECTANGLE_ARB = $84F5;
+ GL_TEXTURE_BINDING_RECTANGLE_ARB = $84F6;
+ GL_PROXY_TEXTURE_RECTANGLE_ARB = $84F7;
+ GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB = $84F8;
+
+function Load_GL_ARB_texture_rectangle: Boolean;
+
+//***** GL_ARB_color_buffer_float *****//
+const
+ GL_RGBA_FLOAT_MODE_ARB = $8820;
+ GL_CLAMP_VERTEX_COLOR_ARB = $891A;
+ GL_CLAMP_FRAGMENT_COLOR_ARB = $891B;
+ GL_CLAMP_READ_COLOR_ARB = $891C;
+ GL_FIXED_ONLY_ARB = $891D;
+ WGL_TYPE_RGBA_FLOAT_ARB = $21A0;
+var
+ glClampColorARB: procedure(target: GLenum; clamp: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_ARB_color_buffer_float: Boolean;
+
+//***** GL_ARB_half_float_pixel *****//
+const
+ GL_HALF_FLOAT_ARB = $140B;
+
+function Load_GL_ARB_half_float_pixel: Boolean;
+
+//***** GL_ARB_texture_float *****//
+const
+ GL_TEXTURE_RED_TYPE_ARB = $8C10;
+ GL_TEXTURE_GREEN_TYPE_ARB = $8C11;
+ GL_TEXTURE_BLUE_TYPE_ARB = $8C12;
+ GL_TEXTURE_ALPHA_TYPE_ARB = $8C13;
+ GL_TEXTURE_LUMINANCE_TYPE_ARB = $8C14;
+ GL_TEXTURE_INTENSITY_TYPE_ARB = $8C15;
+ GL_TEXTURE_DEPTH_TYPE_ARB = $8C16;
+ GL_UNSIGNED_NORMALIZED_ARB = $8C17;
+ GL_RGBA32F_ARB = $8814;
+ GL_RGB32F_ARB = $8815;
+ GL_ALPHA32F_ARB = $8816;
+ GL_INTENSITY32F_ARB = $8817;
+ GL_LUMINANCE32F_ARB = $8818;
+ GL_LUMINANCE_ALPHA32F_ARB = $8819;
+ GL_RGBA16F_ARB = $881A;
+ GL_RGB16F_ARB = $881B;
+ GL_ALPHA16F_ARB = $881C;
+ GL_INTENSITY16F_ARB = $881D;
+ GL_LUMINANCE16F_ARB = $881E;
+ GL_LUMINANCE_ALPHA16F_ARB = $881F;
+
+function Load_GL_ARB_texture_float: Boolean;
+
+//***** GL_EXT_texture_compression_dxt1 *****//
+ // GL_COMPRESSED_RGB_S3TC_DXT1_EXT { already defined }
+ // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT { already defined }
+
+function Load_GL_EXT_texture_compression_dxt1: Boolean;
+
+//***** GL_ARB_pixel_buffer_object *****//
+const
+ GL_PIXEL_PACK_BUFFER_ARB = $88EB;
+ GL_PIXEL_UNPACK_BUFFER_ARB = $88EC;
+ GL_PIXEL_PACK_BUFFER_BINDING_ARB = $88ED;
+ GL_PIXEL_UNPACK_BUFFER_BINDING_ARB = $88EF;
+
+function Load_GL_ARB_pixel_buffer_object: Boolean;
+
+//***** GL_EXT_framebuffer_object *****//
+const
+ GL_FRAMEBUFFER_EXT = $8D40;
+ GL_RENDERBUFFER_EXT = $8D41;
+ GL_STENCIL_INDEX_EXT = $8D45;
+ GL_STENCIL_INDEX1_EXT = $8D46;
+ GL_STENCIL_INDEX4_EXT = $8D47;
+ GL_STENCIL_INDEX8_EXT = $8D48;
+ GL_STENCIL_INDEX16_EXT = $8D49;
+ GL_RENDERBUFFER_WIDTH_EXT = $8D42;
+ GL_RENDERBUFFER_HEIGHT_EXT = $8D43;
+ GL_RENDERBUFFER_INTERNAL_FORMAT_EXT = $8D44;
+ GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT = $8CD0;
+ GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT = $8CD1;
+ GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT = $8CD2;
+ GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT = $8CD3;
+ GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT = $8CD4;
+ GL_COLOR_ATTACHMENT0_EXT = $8CE0;
+ GL_COLOR_ATTACHMENT1_EXT = $8CE1;
+ GL_COLOR_ATTACHMENT2_EXT = $8CE2;
+ GL_COLOR_ATTACHMENT3_EXT = $8CE3;
+ GL_COLOR_ATTACHMENT4_EXT = $8CE4;
+ GL_COLOR_ATTACHMENT5_EXT = $8CE5;
+ GL_COLOR_ATTACHMENT6_EXT = $8CE6;
+ GL_COLOR_ATTACHMENT7_EXT = $8CE7;
+ GL_COLOR_ATTACHMENT8_EXT = $8CE8;
+ GL_COLOR_ATTACHMENT9_EXT = $8CE9;
+ GL_COLOR_ATTACHMENT10_EXT = $8CEA;
+ GL_COLOR_ATTACHMENT11_EXT = $8CEB;
+ GL_COLOR_ATTACHMENT12_EXT = $8CEC;
+ GL_COLOR_ATTACHMENT13_EXT = $8CED;
+ GL_COLOR_ATTACHMENT14_EXT = $8CEE;
+ GL_COLOR_ATTACHMENT15_EXT = $8CEF;
+ GL_DEPTH_ATTACHMENT_EXT = $8D00;
+ GL_STENCIL_ATTACHMENT_EXT = $8D20;
+ GL_FRAMEBUFFER_COMPLETE_EXT = $8CD5;
+ GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT = $8CD6;
+ GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT = $8CD7;
+ GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT = $8CD8;
+ GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT = $8CD9;
+ GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT = $8CDA;
+ GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT = $8CDB;
+ GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT = $8CDC;
+ GL_FRAMEBUFFER_UNSUPPORTED_EXT = $8CDD;
+ GL_FRAMEBUFFER_STATUS_ERROR_EXT = $8CDE;
+ GL_FRAMEBUFFER_BINDING_EXT = $8CA6;
+ GL_RENDERBUFFER_BINDING_EXT = $8CA7;
+ GL_MAX_COLOR_ATTACHMENTS_EXT = $8CDF;
+ GL_MAX_RENDERBUFFER_SIZE_EXT = $84E8;
+ GL_INVALID_FRAMEBUFFER_OPERATION_EXT = $0506;
+var
+ glIsRenderbufferEXT: function(renderbuffer: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindRenderbufferEXT: procedure(target: GLenum; renderbuffer: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteRenderbuffersEXT: procedure(n: GLsizei; const renderbuffers: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGenRenderbuffersEXT: procedure(n: GLsizei; renderbuffers: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glRenderbufferStorageEXT: procedure(target: GLenum; internalformat: GLenum; width: GLsizei; height: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetRenderbufferParameterivEXT: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsFramebufferEXT: function(framebuffer: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindFramebufferEXT: procedure(target: GLenum; framebuffer: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteFramebuffersEXT: procedure(n: GLsizei; const framebuffers: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGenFramebuffersEXT: procedure(n: GLsizei; framebuffers: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCheckFramebufferStatusEXT: function(target: GLenum): GLenum; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFramebufferTexture1DEXT: procedure(target: GLenum; attachment: GLenum; textarget: GLenum; texture: GLuint; level: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFramebufferTexture2DEXT: procedure(target: GLenum; attachment: GLenum; textarget: GLenum; texture: GLuint; level: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFramebufferTexture3DEXT: procedure(target: GLenum; attachment: GLenum; textarget: GLenum; texture: GLuint; level: GLint; zoffset: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFramebufferRenderbufferEXT: procedure(target: GLenum; attachment: GLenum; renderbuffertarget: GLenum; renderbuffer: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetFramebufferAttachmentParameterivEXT: procedure(target: GLenum; attachment: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGenerateMipmapEXT: procedure(target: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_EXT_framebuffer_object: Boolean;
+
+//***** GL_version_1_4 *****//
+const
+ GL_BLEND_DST_RGB = $80C8;
+ GL_BLEND_SRC_RGB = $80C9;
+ GL_BLEND_DST_ALPHA = $80CA;
+ GL_BLEND_SRC_ALPHA = $80CB;
+ GL_POINT_SIZE_MIN = $8126;
+ GL_POINT_SIZE_MAX = $8127;
+ GL_POINT_FADE_THRESHOLD_SIZE = $8128;
+ GL_POINT_DISTANCE_ATTENUATION = $8129;
+ GL_GENERATE_MIPMAP = $8191;
+ GL_GENERATE_MIPMAP_HINT = $8192;
+ GL_DEPTH_COMPONENT16 = $81A5;
+ GL_DEPTH_COMPONENT24 = $81A6;
+ GL_DEPTH_COMPONENT32 = $81A7;
+ GL_MIRRORED_REPEAT = $8370;
+ GL_FOG_COORDINATE_SOURCE = $8450;
+ GL_FOG_COORDINATE = $8451;
+ GL_FRAGMENT_DEPTH = $8452;
+ GL_CURRENT_FOG_COORDINATE = $8453;
+ GL_FOG_COORDINATE_ARRAY_TYPE = $8454;
+ GL_FOG_COORDINATE_ARRAY_STRIDE = $8455;
+ GL_FOG_COORDINATE_ARRAY_POINTER = $8456;
+ GL_FOG_COORDINATE_ARRAY = $8457;
+ GL_COLOR_SUM = $8458;
+ GL_CURRENT_SECONDARY_COLOR = $8459;
+ GL_SECONDARY_COLOR_ARRAY_SIZE = $845A;
+ GL_SECONDARY_COLOR_ARRAY_TYPE = $845B;
+ GL_SECONDARY_COLOR_ARRAY_STRIDE = $845C;
+ GL_SECONDARY_COLOR_ARRAY_POINTER = $845D;
+ GL_SECONDARY_COLOR_ARRAY = $845E;
+ GL_MAX_TEXTURE_LOD_BIAS = $84FD;
+ GL_TEXTURE_FILTER_CONTROL = $8500;
+ GL_TEXTURE_LOD_BIAS = $8501;
+ GL_INCR_WRAP = $8507;
+ GL_DECR_WRAP = $8508;
+ GL_TEXTURE_DEPTH_SIZE = $884A;
+ GL_DEPTH_TEXTURE_MODE = $884B;
+ GL_TEXTURE_COMPARE_MODE = $884C;
+ GL_TEXTURE_COMPARE_FUNC = $884D;
+ GL_COMPARE_R_TO_TEXTURE = $884E;
+var
+ glBlendFuncSeparate: procedure(sfactorRGB: GLenum; dfactorRGB: GLenum; sfactorAlpha: GLenum; dfactorAlpha: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogCoordf: procedure(coord: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogCoordfv: procedure(const coord: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogCoordd: procedure(coord: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogCoorddv: procedure(const coord: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glFogCoordPointer: procedure(_type: GLenum; stride: GLsizei; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiDrawArrays: procedure(mode: GLenum; first: PGLint; count: PGLsizei; primcount: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMultiDrawElements: procedure(mode: GLenum; const count: PGLsizei; _type: GLenum; const indices: PGLvoid; primcount: GLsizei); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPointParameterf: procedure(pname: GLenum; param: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPointParameterfv: procedure(pname: GLenum; const params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPointParameteri: procedure(pname: GLenum; param: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glPointParameteriv: procedure(pname: GLenum; const params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3b: procedure(red: GLbyte; green: GLbyte; blue: GLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3bv: procedure(const v: PGLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3d: procedure(red: GLdouble; green: GLdouble; blue: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3f: procedure(red: GLfloat; green: GLfloat; blue: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3i: procedure(red: GLint; green: GLint; blue: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3s: procedure(red: GLshort; green: GLshort; blue: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3ub: procedure(red: GLubyte; green: GLubyte; blue: GLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3ubv: procedure(const v: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3ui: procedure(red: GLuint; green: GLuint; blue: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3uiv: procedure(const v: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3us: procedure(red: GLushort; green: GLushort; blue: GLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColor3usv: procedure(const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glSecondaryColorPointer: procedure(size: GLint; _type: GLenum; stride: GLsizei; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2d: procedure(x: GLdouble; y: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2f: procedure(x: GLfloat; y: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2i: procedure(x: GLint; y: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2s: procedure(x: GLshort; y: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos2sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3d: procedure(x: GLdouble; y: GLdouble; z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3dv: procedure(const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3f: procedure(x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3fv: procedure(const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3i: procedure(x: GLint; y: GLint; z: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3iv: procedure(const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3s: procedure(x: GLshort; y: GLshort; z: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glWindowPos3sv: procedure(const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_version_1_4: Boolean;
+
+//***** GL_version_1_5 *****//
+const
+ GL_BUFFER_SIZE = $8764;
+ GL_BUFFER_USAGE = $8765;
+ GL_QUERY_COUNTER_BITS = $8864;
+ GL_CURRENT_QUERY = $8865;
+ GL_QUERY_RESULT = $8866;
+ GL_QUERY_RESULT_AVAILABLE = $8867;
+ GL_ARRAY_BUFFER = $8892;
+ GL_ELEMENT_ARRAY_BUFFER = $8893;
+ GL_ARRAY_BUFFER_BINDING = $8894;
+ GL_ELEMENT_ARRAY_BUFFER_BINDING = $8895;
+ GL_VERTEX_ARRAY_BUFFER_BINDING = $8896;
+ GL_NORMAL_ARRAY_BUFFER_BINDING = $8897;
+ GL_COLOR_ARRAY_BUFFER_BINDING = $8898;
+ GL_INDEX_ARRAY_BUFFER_BINDING = $8899;
+ GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING = $889A;
+ GL_EDGE_FLAG_ARRAY_BUFFER_BINDING = $889B;
+ GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING = $889C;
+ GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING = $889D;
+ GL_WEIGHT_ARRAY_BUFFER_BINDING = $889E;
+ GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = $889F;
+ GL_READ_ONLY = $88B8;
+ GL_WRITE_ONLY = $88B9;
+ GL_READ_WRITE = $88BA;
+ GL_BUFFER_ACCESS = $88BB;
+ GL_BUFFER_MAPPED = $88BC;
+ GL_BUFFER_MAP_POINTER = $88BD;
+ GL_STREAM_DRAW = $88E0;
+ GL_STREAM_READ = $88E1;
+ GL_STREAM_COPY = $88E2;
+ GL_STATIC_DRAW = $88E4;
+ GL_STATIC_READ = $88E5;
+ GL_STATIC_COPY = $88E6;
+ GL_DYNAMIC_DRAW = $88E8;
+ GL_DYNAMIC_READ = $88E9;
+ GL_DYNAMIC_COPY = $88EA;
+ GL_SAMPLES_PASSED = $8914;
+ GL_FOG_COORD_SRC = $8450;
+ GL_FOG_COORD = $8451;
+ GL_CURRENT_FOG_COORD = $8453;
+ GL_FOG_COORD_ARRAY_TYPE = $8454;
+ GL_FOG_COORD_ARRAY_STRIDE = $8455;
+ GL_FOG_COORD_ARRAY_POINTER = $8456;
+ GL_FOG_COORD_ARRAY = $8457;
+ GL_FOG_COORD_ARRAY_BUFFER_BINDING = $889D;
+ GL_SRC0_RGB = $8580;
+ GL_SRC1_RGB = $8581;
+ GL_SRC2_RGB = $8582;
+ GL_SRC0_ALPHA = $8588;
+ GL_SRC1_ALPHA = $8589;
+ GL_SRC2_ALPHA = $858A;
+var
+ glGenQueries: procedure(n: GLsizei; ids: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteQueries: procedure(n: GLsizei; const ids: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsQuery: function(id: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBeginQuery: procedure(target: GLenum; id: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEndQuery: procedure(target: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetQueryiv: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetQueryObjectiv: procedure(id: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetQueryObjectuiv: procedure(id: GLuint; pname: GLenum; params: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindBuffer: procedure(target: GLenum; buffer: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteBuffers: procedure(n: GLsizei; const buffers: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGenBuffers: procedure(n: GLsizei; buffers: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsBuffer: function(buffer: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBufferData: procedure(target: GLenum; size: GLsizeiptr; const data: PGLvoid; usage: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBufferSubData: procedure(target: GLenum; offset: GLintptr; size: GLsizeiptr; const data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetBufferSubData: procedure(target: GLenum; offset: GLintptr; size: GLsizeiptr; data: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glMapBuffer: function(target: GLenum; access: GLenum): PGLvoid; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUnmapBuffer: function(target: GLenum): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetBufferParameteriv: procedure(target: GLenum; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetBufferPointerv: procedure(target: GLenum; pname: GLenum; params: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_version_1_5: Boolean;
+
+//***** GL_version_2_0 *****//
+const
+ GL_BLEND_EQUATION_RGB = $8009;
+ GL_VERTEX_ATTRIB_ARRAY_ENABLED = $8622;
+ GL_VERTEX_ATTRIB_ARRAY_SIZE = $8623;
+ GL_VERTEX_ATTRIB_ARRAY_STRIDE = $8624;
+ GL_VERTEX_ATTRIB_ARRAY_TYPE = $8625;
+ GL_CURRENT_VERTEX_ATTRIB = $8626;
+ GL_VERTEX_PROGRAM_POINT_SIZE = $8642;
+ GL_VERTEX_PROGRAM_TWO_SIDE = $8643;
+ GL_VERTEX_ATTRIB_ARRAY_POINTER = $8645;
+ GL_STENCIL_BACK_FUNC = $8800;
+ GL_STENCIL_BACK_FAIL = $8801;
+ GL_STENCIL_BACK_PASS_DEPTH_FAIL = $8802;
+ GL_STENCIL_BACK_PASS_DEPTH_PASS = $8803;
+ GL_MAX_DRAW_BUFFERS = $8824;
+ GL_DRAW_BUFFER0 = $8825;
+ GL_DRAW_BUFFER1 = $8826;
+ GL_DRAW_BUFFER2 = $8827;
+ GL_DRAW_BUFFER3 = $8828;
+ GL_DRAW_BUFFER4 = $8829;
+ GL_DRAW_BUFFER5 = $882A;
+ GL_DRAW_BUFFER6 = $882B;
+ GL_DRAW_BUFFER7 = $882C;
+ GL_DRAW_BUFFER8 = $882D;
+ GL_DRAW_BUFFER9 = $882E;
+ GL_DRAW_BUFFER10 = $882F;
+ GL_DRAW_BUFFER11 = $8830;
+ GL_DRAW_BUFFER12 = $8831;
+ GL_DRAW_BUFFER13 = $8832;
+ GL_DRAW_BUFFER14 = $8833;
+ GL_DRAW_BUFFER15 = $8834;
+ GL_BLEND_EQUATION_ALPHA = $883D;
+ GL_POINT_SPRITE = $8861;
+ GL_COORD_REPLACE = $8862;
+ GL_MAX_VERTEX_ATTRIBS = $8869;
+ GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = $886A;
+ GL_MAX_TEXTURE_COORDS = $8871;
+ GL_MAX_TEXTURE_IMAGE_UNITS = $8872;
+ GL_FRAGMENT_SHADER = $8B30;
+ GL_VERTEX_SHADER = $8B31;
+ GL_MAX_FRAGMENT_UNIFORM_COMPONENTS = $8B49;
+ GL_MAX_VERTEX_UNIFORM_COMPONENTS = $8B4A;
+ GL_MAX_VARYING_FLOATS = $8B4B;
+ GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = $8B4C;
+ GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = $8B4D;
+ GL_SHADER_TYPE = $8B4F;
+ GL_FLOAT_VEC2 = $8B50;
+ GL_FLOAT_VEC3 = $8B51;
+ GL_FLOAT_VEC4 = $8B52;
+ GL_INT_VEC2 = $8B53;
+ GL_INT_VEC3 = $8B54;
+ GL_INT_VEC4 = $8B55;
+ GL_BOOL = $8B56;
+ GL_BOOL_VEC2 = $8B57;
+ GL_BOOL_VEC3 = $8B58;
+ GL_BOOL_VEC4 = $8B59;
+ GL_FLOAT_MAT2 = $8B5A;
+ GL_FLOAT_MAT3 = $8B5B;
+ GL_FLOAT_MAT4 = $8B5C;
+ GL_SAMPLER_1D = $8B5D;
+ GL_SAMPLER_2D = $8B5E;
+ GL_SAMPLER_3D = $8B5F;
+ GL_SAMPLER_CUBE = $8B60;
+ GL_SAMPLER_1D_SHADOW = $8B61;
+ GL_SAMPLER_2D_SHADOW = $8B62;
+ GL_DELETE_STATUS = $8B80;
+ GL_COMPILE_STATUS = $8B81;
+ GL_LINK_STATUS = $8B82;
+ GL_VALIDATE_STATUS = $8B83;
+ GL_INFO_LOG_LENGTH = $8B84;
+ GL_ATTACHED_SHADERS = $8B85;
+ GL_ACTIVE_UNIFORMS = $8B86;
+ GL_ACTIVE_UNIFORM_MAX_LENGTH = $8B87;
+ GL_SHADER_SOURCE_LENGTH = $8B88;
+ GL_ACTIVE_ATTRIBUTES = $8B89;
+ GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = $8B8A;
+ GL_FRAGMENT_SHADER_DERIVATIVE_HINT = $8B8B;
+ GL_SHADING_LANGUAGE_VERSION = $8B8C;
+ GL_CURRENT_PROGRAM = $8B8D;
+ GL_POINT_SPRITE_COORD_ORIGIN = $8CA0;
+ GL_LOWER_LEFT = $8CA1;
+ GL_UPPER_LEFT = $8CA2;
+ GL_STENCIL_BACK_REF = $8CA3;
+ GL_STENCIL_BACK_VALUE_MASK = $8CA4;
+ GL_STENCIL_BACK_WRITEMASK = $8CA5;
+var
+ glBlendEquationSeparate: procedure(modeRGB: GLenum; modeAlpha: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDrawBuffers: procedure(n: GLsizei; const bufs: PGLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glStencilOpSeparate: procedure(face: GLenum; sfail: GLenum; dpfail: GLenum; dppass: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glStencilFuncSeparate: procedure(frontfunc: GLenum; backfunc: GLenum; ref: GLint; mask: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glStencilMaskSeparate: procedure(face: GLenum; mask: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glAttachShader: procedure(_program: GLuint; shader: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glBindAttribLocation: procedure(_program: GLuint; index: GLuint; const name: PGLchar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCompileShader: procedure(shader: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCreateProgram: function(): GLuint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glCreateShader: function(_type: GLenum): GLuint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteProgram: procedure(_program: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDeleteShader: procedure(shader: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDetachShader: procedure(_program: GLuint; shader: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glDisableVertexAttribArray: procedure(index: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glEnableVertexAttribArray: procedure(index: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetActiveAttrib: procedure(_program: GLuint; index: GLuint; bufSize: GLsizei; length: PGLsizei; size: PGLint; _type: PGLenum; name: PGLchar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetActiveUniform: procedure(_program: GLuint; index: GLuint; bufSize: GLsizei; length: PGLsizei; size: PGLint; _type: PGLenum; name: PGLchar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetAttachedShaders: procedure(_program: GLuint; maxCount: GLsizei; count: PGLsizei; obj: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetAttribLocation: function(_program: GLuint; const name: PGLchar): GLint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramiv: procedure(_program: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetProgramInfoLog: procedure(_program: GLuint; bufSize: GLsizei; length: PGLsizei; infoLog: PGLchar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetShaderiv: procedure(shader: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetShaderInfoLog: procedure(shader: GLuint; bufSize: GLsizei; length: PGLsizei; infoLog: PGLchar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetShaderSource: procedure(shader: GLuint; bufSize: GLsizei; length: PGLsizei; source: PGLchar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetUniformLocation: function(_program: GLuint; const name: PGLchar): GLint; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetUniformfv: procedure(_program: GLuint; location: GLint; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetUniformiv: procedure(_program: GLuint; location: GLint; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribdv: procedure(index: GLuint; pname: GLenum; params: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribfv: procedure(index: GLuint; pname: GLenum; params: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribiv: procedure(index: GLuint; pname: GLenum; params: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glGetVertexAttribPointerv: procedure(index: GLuint; pname: GLenum; pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsProgram: function(_program: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glIsShader: function(shader: GLuint): GLboolean; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glLinkProgram: procedure(_program: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glShaderSource: procedure(shader: GLuint; count: GLsizei; const _string: PGLchar; const length: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUseProgram: procedure(_program: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform1f: procedure(location: GLint; v0: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform2f: procedure(location: GLint; v0: GLfloat; v1: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform3f: procedure(location: GLint; v0: GLfloat; v1: GLfloat; v2: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform4f: procedure(location: GLint; v0: GLfloat; v1: GLfloat; v2: GLfloat; v3: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform1i: procedure(location: GLint; v0: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform2i: procedure(location: GLint; v0: GLint; v1: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform3i: procedure(location: GLint; v0: GLint; v1: GLint; v2: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform4i: procedure(location: GLint; v0: GLint; v1: GLint; v2: GLint; v3: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform1fv: procedure(location: GLint; count: GLsizei; const value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform2fv: procedure(location: GLint; count: GLsizei; const value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform3fv: procedure(location: GLint; count: GLsizei; const value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform4fv: procedure(location: GLint; count: GLsizei; const value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform1iv: procedure(location: GLint; count: GLsizei; const value: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform2iv: procedure(location: GLint; count: GLsizei; const value: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform3iv: procedure(location: GLint; count: GLsizei; const value: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniform4iv: procedure(location: GLint; count: GLsizei; const value: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniformMatrix2fv: procedure(location: GLint; count: GLsizei; transpose: GLboolean; const value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniformMatrix3fv: procedure(location: GLint; count: GLsizei; transpose: GLboolean; const value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glUniformMatrix4fv: procedure(location: GLint; count: GLsizei; transpose: GLboolean; const value: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glValidateProgram: procedure(_program: GLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1d: procedure(index: GLuint; x: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1dv: procedure(index: GLuint; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1f: procedure(index: GLuint; x: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1fv: procedure(index: GLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1s: procedure(index: GLuint; x: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib1sv: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2d: procedure(index: GLuint; x: GLdouble; y: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2dv: procedure(index: GLuint; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2f: procedure(index: GLuint; x: GLfloat; y: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2fv: procedure(index: GLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2s: procedure(index: GLuint; x: GLshort; y: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib2sv: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3d: procedure(index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3dv: procedure(index: GLuint; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3f: procedure(index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3fv: procedure(index: GLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3s: procedure(index: GLuint; x: GLshort; y: GLshort; z: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib3sv: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4Nbv: procedure(index: GLuint; const v: PGLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4Niv: procedure(index: GLuint; const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4Nsv: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4Nub: procedure(index: GLuint; x: GLubyte; y: GLubyte; z: GLubyte; w: GLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4Nubv: procedure(index: GLuint; const v: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4Nuiv: procedure(index: GLuint; const v: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4Nusv: procedure(index: GLuint; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4bv: procedure(index: GLuint; const v: PGLbyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4d: procedure(index: GLuint; x: GLdouble; y: GLdouble; z: GLdouble; w: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4dv: procedure(index: GLuint; const v: PGLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4f: procedure(index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4fv: procedure(index: GLuint; const v: PGLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4iv: procedure(index: GLuint; const v: PGLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4s: procedure(index: GLuint; x: GLshort; y: GLshort; z: GLshort; w: GLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4sv: procedure(index: GLuint; const v: PGLshort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4ubv: procedure(index: GLuint; const v: PGLubyte); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4uiv: procedure(index: GLuint; const v: PGLuint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttrib4usv: procedure(index: GLuint; const v: PGLushort); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glVertexAttribPointer: procedure(index: GLuint; size: GLint; _type: GLenum; normalized: GLboolean; stride: GLsizei; const pointer: PGLvoid); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+function Load_GL_version_2_0: Boolean;
+
+implementation
+
+uses
+ sdl;
+
+function glext_ExtensionSupported(const extension: PChar; const searchIn: PChar): Boolean;
+var
+ extensions: PChar;
+ start: PChar;
+ where, terminator: PChar;
+begin
+
+ if (Pos(' ', extension) <> 0) or (extension = '') then
+ begin
+ Result := FALSE;
+ Exit;
+ end;
+
+ if searchIn = '' then
+ extensions := glGetString(GL_EXTENSIONS)
+ else
+ //StrLCopy( extensions, searchIn, StrLen(searchIn)+1 );
+ extensions := searchIn;
+ start := extensions;
+ while TRUE do
+ begin
+ where := StrPos(start, extension );
+ if where = nil then Break;
+ terminator := Pointer(Integer(where) + Integer( strlen( extension ) ) );
+ if (where = start) or (PChar(Integer(where) - 1)^ = ' ') then
+ begin
+ if (terminator^ = ' ') or (terminator^ = #0) then
+ begin
+ Result := TRUE;
+ Exit;
+ end;
+ end;
+ start := terminator;
+ end;
+ Result := FALSE;
+
+end;
+
+function Load_GL_version_1_2: Boolean;
+{var
+ extstring : PChar;}
+begin
+
+ Result := FALSE;
+ //extstring := glGetString( GL_EXTENSIONS );
+
+ @glCopyTexSubImage3D := SDL_GL_GetProcAddress('glCopyTexSubImage3D');
+ if not Assigned(glCopyTexSubImage3D) then Exit;
+ @glDrawRangeElements := SDL_GL_GetProcAddress('glDrawRangeElements');
+ if not Assigned(glDrawRangeElements) then Exit;
+ @glTexImage3D := SDL_GL_GetProcAddress('glTexImage3D');
+ if not Assigned(glTexImage3D) then Exit;
+ @glTexSubImage3D := SDL_GL_GetProcAddress('glTexSubImage3D');
+ if not Assigned(glTexSubImage3D) then Exit;
+
+ Result := TRUE;
+
+end;
+
+function Load_GL_ARB_imaging: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_imaging', extstring) then
+ begin
+ @glColorTable := SDL_GL_GetProcAddress('glColorTable');
+ if not Assigned(glColorTable) then Exit;
+ @glColorTableParameterfv := SDL_GL_GetProcAddress('glColorTableParameterfv');
+ if not Assigned(glColorTableParameterfv) then Exit;
+ @glColorTableParameteriv := SDL_GL_GetProcAddress('glColorTableParameteriv');
+ if not Assigned(glColorTableParameteriv) then Exit;
+ @glCopyColorTable := SDL_GL_GetProcAddress('glCopyColorTable');
+ if not Assigned(glCopyColorTable) then Exit;
+ @glGetColorTable := SDL_GL_GetProcAddress('glGetColorTable');
+ if not Assigned(glGetColorTable) then Exit;
+ @glGetColorTableParameterfv := SDL_GL_GetProcAddress('glGetColorTableParameterfv');
+ if not Assigned(glGetColorTableParameterfv) then Exit;
+ @glGetColorTableParameteriv := SDL_GL_GetProcAddress('glGetColorTableParameteriv');
+ if not Assigned(glGetColorTableParameteriv) then Exit;
+ @glColorSubTable := SDL_GL_GetProcAddress('glColorSubTable');
+ if not Assigned(glColorSubTable) then Exit;
+ @glCopyColorSubTable := SDL_GL_GetProcAddress('glCopyColorSubTable');
+ if not Assigned(glCopyColorSubTable) then Exit;
+ @glConvolutionFilter1D := SDL_GL_GetProcAddress('glConvolutionFilter1D');
+ if not Assigned(glConvolutionFilter1D) then Exit;
+ @glConvolutionFilter2D := SDL_GL_GetProcAddress('glConvolutionFilter2D');
+ if not Assigned(glConvolutionFilter2D) then Exit;
+ @glConvolutionParameterf := SDL_GL_GetProcAddress('glConvolutionParameterf');
+ if not Assigned(glConvolutionParameterf) then Exit;
+ @glConvolutionParameterfv := SDL_GL_GetProcAddress('glConvolutionParameterfv');
+ if not Assigned(glConvolutionParameterfv) then Exit;
+ @glConvolutionParameteri := SDL_GL_GetProcAddress('glConvolutionParameteri');
+ if not Assigned(glConvolutionParameteri) then Exit;
+ @glConvolutionParameteriv := SDL_GL_GetProcAddress('glConvolutionParameteriv');
+ if not Assigned(glConvolutionParameteriv) then Exit;
+ @glCopyConvolutionFilter1D := SDL_GL_GetProcAddress('glCopyConvolutionFilter1D');
+ if not Assigned(glCopyConvolutionFilter1D) then Exit;
+ @glCopyConvolutionFilter2D := SDL_GL_GetProcAddress('glCopyConvolutionFilter2D');
+ if not Assigned(glCopyConvolutionFilter2D) then Exit;
+ @glGetConvolutionFilter := SDL_GL_GetProcAddress('glGetConvolutionFilter');
+ if not Assigned(glGetConvolutionFilter) then Exit;
+ @glGetConvolutionParameterfv := SDL_GL_GetProcAddress('glGetConvolutionParameterfv');
+ if not Assigned(glGetConvolutionParameterfv) then Exit;
+ @glGetConvolutionParameteriv := SDL_GL_GetProcAddress('glGetConvolutionParameteriv');
+ if not Assigned(glGetConvolutionParameteriv) then Exit;
+ @glGetSeparableFilter := SDL_GL_GetProcAddress('glGetSeparableFilter');
+ if not Assigned(glGetSeparableFilter) then Exit;
+ @glSeparableFilter2D := SDL_GL_GetProcAddress('glSeparableFilter2D');
+ if not Assigned(glSeparableFilter2D) then Exit;
+ @glGetHistogram := SDL_GL_GetProcAddress('glGetHistogram');
+ if not Assigned(glGetHistogram) then Exit;
+ @glGetHistogramParameterfv := SDL_GL_GetProcAddress('glGetHistogramParameterfv');
+ if not Assigned(glGetHistogramParameterfv) then Exit;
+ @glGetHistogramParameteriv := SDL_GL_GetProcAddress('glGetHistogramParameteriv');
+ if not Assigned(glGetHistogramParameteriv) then Exit;
+ @glGetMinmax := SDL_GL_GetProcAddress('glGetMinmax');
+ if not Assigned(glGetMinmax) then Exit;
+ @glGetMinmaxParameterfv := SDL_GL_GetProcAddress('glGetMinmaxParameterfv');
+ if not Assigned(glGetMinmaxParameterfv) then Exit;
+ @glGetMinmaxParameteriv := SDL_GL_GetProcAddress('glGetMinmaxParameteriv');
+ if not Assigned(glGetMinmaxParameteriv) then Exit;
+ @glHistogram := SDL_GL_GetProcAddress('glHistogram');
+ if not Assigned(glHistogram) then Exit;
+ @glMinmax := SDL_GL_GetProcAddress('glMinmax');
+ if not Assigned(glMinmax) then Exit;
+ @glResetHistogram := SDL_GL_GetProcAddress('glResetHistogram');
+ if not Assigned(glResetHistogram) then Exit;
+ @glResetMinmax := SDL_GL_GetProcAddress('glResetMinmax');
+ if not Assigned(glResetMinmax) then Exit;
+ @glBlendEquation := SDL_GL_GetProcAddress('glBlendEquation');
+ if not Assigned(glBlendEquation) then Exit;
+ @glBlendColor := SDL_GL_GetProcAddress('glBlendColor');
+ if not Assigned(glBlendColor) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_version_1_3: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ @glActiveTexture := SDL_GL_GetProcAddress('glActiveTexture');
+ if not Assigned(glActiveTexture) then Exit;
+ @glClientActiveTexture := SDL_GL_GetProcAddress('glClientActiveTexture');
+ if not Assigned(glClientActiveTexture) then Exit;
+ @glMultiTexCoord1d := SDL_GL_GetProcAddress('glMultiTexCoord1d');
+ if not Assigned(glMultiTexCoord1d) then Exit;
+ @glMultiTexCoord1dv := SDL_GL_GetProcAddress('glMultiTexCoord1dv');
+ if not Assigned(glMultiTexCoord1dv) then Exit;
+ @glMultiTexCoord1f := SDL_GL_GetProcAddress('glMultiTexCoord1f');
+ if not Assigned(glMultiTexCoord1f) then Exit;
+ @glMultiTexCoord1fv := SDL_GL_GetProcAddress('glMultiTexCoord1fv');
+ if not Assigned(glMultiTexCoord1fv) then Exit;
+ @glMultiTexCoord1i := SDL_GL_GetProcAddress('glMultiTexCoord1i');
+ if not Assigned(glMultiTexCoord1i) then Exit;
+ @glMultiTexCoord1iv := SDL_GL_GetProcAddress('glMultiTexCoord1iv');
+ if not Assigned(glMultiTexCoord1iv) then Exit;
+ @glMultiTexCoord1s := SDL_GL_GetProcAddress('glMultiTexCoord1s');
+ if not Assigned(glMultiTexCoord1s) then Exit;
+ @glMultiTexCoord1sv := SDL_GL_GetProcAddress('glMultiTexCoord1sv');
+ if not Assigned(glMultiTexCoord1sv) then Exit;
+ @glMultiTexCoord2d := SDL_GL_GetProcAddress('glMultiTexCoord2d');
+ if not Assigned(glMultiTexCoord2d) then Exit;
+ @glMultiTexCoord2dv := SDL_GL_GetProcAddress('glMultiTexCoord2dv');
+ if not Assigned(glMultiTexCoord2dv) then Exit;
+ @glMultiTexCoord2f := SDL_GL_GetProcAddress('glMultiTexCoord2f');
+ if not Assigned(glMultiTexCoord2f) then Exit;
+ @glMultiTexCoord2fv := SDL_GL_GetProcAddress('glMultiTexCoord2fv');
+ if not Assigned(glMultiTexCoord2fv) then Exit;
+ @glMultiTexCoord2i := SDL_GL_GetProcAddress('glMultiTexCoord2i');
+ if not Assigned(glMultiTexCoord2i) then Exit;
+ @glMultiTexCoord2iv := SDL_GL_GetProcAddress('glMultiTexCoord2iv');
+ if not Assigned(glMultiTexCoord2iv) then Exit;
+ @glMultiTexCoord2s := SDL_GL_GetProcAddress('glMultiTexCoord2s');
+ if not Assigned(glMultiTexCoord2s) then Exit;
+ @glMultiTexCoord2sv := SDL_GL_GetProcAddress('glMultiTexCoord2sv');
+ if not Assigned(glMultiTexCoord2sv) then Exit;
+ @glMultiTexCoord3d := SDL_GL_GetProcAddress('glMultiTexCoord3d');
+ if not Assigned(glMultiTexCoord3d) then Exit;
+ @glMultiTexCoord3dv := SDL_GL_GetProcAddress('glMultiTexCoord3dv');
+ if not Assigned(glMultiTexCoord3dv) then Exit;
+ @glMultiTexCoord3f := SDL_GL_GetProcAddress('glMultiTexCoord3f');
+ if not Assigned(glMultiTexCoord3f) then Exit;
+ @glMultiTexCoord3fv := SDL_GL_GetProcAddress('glMultiTexCoord3fv');
+ if not Assigned(glMultiTexCoord3fv) then Exit;
+ @glMultiTexCoord3i := SDL_GL_GetProcAddress('glMultiTexCoord3i');
+ if not Assigned(glMultiTexCoord3i) then Exit;
+ @glMultiTexCoord3iv := SDL_GL_GetProcAddress('glMultiTexCoord3iv');
+ if not Assigned(glMultiTexCoord3iv) then Exit;
+ @glMultiTexCoord3s := SDL_GL_GetProcAddress('glMultiTexCoord3s');
+ if not Assigned(glMultiTexCoord3s) then Exit;
+ @glMultiTexCoord3sv := SDL_GL_GetProcAddress('glMultiTexCoord3sv');
+ if not Assigned(glMultiTexCoord3sv) then Exit;
+ @glMultiTexCoord4d := SDL_GL_GetProcAddress('glMultiTexCoord4d');
+ if not Assigned(glMultiTexCoord4d) then Exit;
+ @glMultiTexCoord4dv := SDL_GL_GetProcAddress('glMultiTexCoord4dv');
+ if not Assigned(glMultiTexCoord4dv) then Exit;
+ @glMultiTexCoord4f := SDL_GL_GetProcAddress('glMultiTexCoord4f');
+ if not Assigned(glMultiTexCoord4f) then Exit;
+ @glMultiTexCoord4fv := SDL_GL_GetProcAddress('glMultiTexCoord4fv');
+ if not Assigned(glMultiTexCoord4fv) then Exit;
+ @glMultiTexCoord4i := SDL_GL_GetProcAddress('glMultiTexCoord4i');
+ if not Assigned(glMultiTexCoord4i) then Exit;
+ @glMultiTexCoord4iv := SDL_GL_GetProcAddress('glMultiTexCoord4iv');
+ if not Assigned(glMultiTexCoord4iv) then Exit;
+ @glMultiTexCoord4s := SDL_GL_GetProcAddress('glMultiTexCoord4s');
+ if not Assigned(glMultiTexCoord4s) then Exit;
+ @glMultiTexCoord4sv := SDL_GL_GetProcAddress('glMultiTexCoord4sv');
+ if not Assigned(glMultiTexCoord4sv) then Exit;
+ @glLoadTransposeMatrixf := SDL_GL_GetProcAddress('glLoadTransposeMatrixf');
+ if not Assigned(glLoadTransposeMatrixf) then Exit;
+ @glLoadTransposeMatrixd := SDL_GL_GetProcAddress('glLoadTransposeMatrixd');
+ if not Assigned(glLoadTransposeMatrixd) then Exit;
+ @glMultTransposeMatrixf := SDL_GL_GetProcAddress('glMultTransposeMatrixf');
+ if not Assigned(glMultTransposeMatrixf) then Exit;
+ @glMultTransposeMatrixd := SDL_GL_GetProcAddress('glMultTransposeMatrixd');
+ if not Assigned(glMultTransposeMatrixd) then Exit;
+ @glSampleCoverage := SDL_GL_GetProcAddress('glSampleCoverage');
+ if not Assigned(glSampleCoverage) then Exit;
+ @glCompressedTexImage3D := SDL_GL_GetProcAddress('glCompressedTexImage3D');
+ if not Assigned(glCompressedTexImage3D) then Exit;
+ @glCompressedTexImage2D := SDL_GL_GetProcAddress('glCompressedTexImage2D');
+ if not Assigned(glCompressedTexImage2D) then Exit;
+ @glCompressedTexImage1D := SDL_GL_GetProcAddress('glCompressedTexImage1D');
+ if not Assigned(glCompressedTexImage1D) then Exit;
+ @glCompressedTexSubImage3D := SDL_GL_GetProcAddress('glCompressedTexSubImage3D');
+ if not Assigned(glCompressedTexSubImage3D) then Exit;
+ @glCompressedTexSubImage2D := SDL_GL_GetProcAddress('glCompressedTexSubImage2D');
+ if not Assigned(glCompressedTexSubImage2D) then Exit;
+ @glCompressedTexSubImage1D := SDL_GL_GetProcAddress('glCompressedTexSubImage1D');
+ if not Assigned(glCompressedTexSubImage1D) then Exit;
+ @glGetCompressedTexImage := SDL_GL_GetProcAddress('glGetCompressedTexImage');
+ if not Assigned(glGetCompressedTexImage) then Exit;
+ Result := TRUE;
+
+end;
+
+function Load_GL_ARB_multitexture: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_multitexture', extstring) then
+ begin
+ @glActiveTextureARB := SDL_GL_GetProcAddress('glActiveTextureARB');
+ if not Assigned(glActiveTextureARB) then Exit;
+ @glClientActiveTextureARB := SDL_GL_GetProcAddress('glClientActiveTextureARB');
+ if not Assigned(glClientActiveTextureARB) then Exit;
+ @glMultiTexCoord1dARB := SDL_GL_GetProcAddress('glMultiTexCoord1dARB');
+ if not Assigned(glMultiTexCoord1dARB) then Exit;
+ @glMultiTexCoord1dvARB := SDL_GL_GetProcAddress('glMultiTexCoord1dvARB');
+ if not Assigned(glMultiTexCoord1dvARB) then Exit;
+ @glMultiTexCoord1fARB := SDL_GL_GetProcAddress('glMultiTexCoord1fARB');
+ if not Assigned(glMultiTexCoord1fARB) then Exit;
+ @glMultiTexCoord1fvARB := SDL_GL_GetProcAddress('glMultiTexCoord1fvARB');
+ if not Assigned(glMultiTexCoord1fvARB) then Exit;
+ @glMultiTexCoord1iARB := SDL_GL_GetProcAddress('glMultiTexCoord1iARB');
+ if not Assigned(glMultiTexCoord1iARB) then Exit;
+ @glMultiTexCoord1ivARB := SDL_GL_GetProcAddress('glMultiTexCoord1ivARB');
+ if not Assigned(glMultiTexCoord1ivARB) then Exit;
+ @glMultiTexCoord1sARB := SDL_GL_GetProcAddress('glMultiTexCoord1sARB');
+ if not Assigned(glMultiTexCoord1sARB) then Exit;
+ @glMultiTexCoord1svARB := SDL_GL_GetProcAddress('glMultiTexCoord1svARB');
+ if not Assigned(glMultiTexCoord1svARB) then Exit;
+ @glMultiTexCoord2dARB := SDL_GL_GetProcAddress('glMultiTexCoord2dARB');
+ if not Assigned(glMultiTexCoord2dARB) then Exit;
+ @glMultiTexCoord2dvARB := SDL_GL_GetProcAddress('glMultiTexCoord2dvARB');
+ if not Assigned(glMultiTexCoord2dvARB) then Exit;
+ @glMultiTexCoord2fARB := SDL_GL_GetProcAddress('glMultiTexCoord2fARB');
+ if not Assigned(glMultiTexCoord2fARB) then Exit;
+ @glMultiTexCoord2fvARB := SDL_GL_GetProcAddress('glMultiTexCoord2fvARB');
+ if not Assigned(glMultiTexCoord2fvARB) then Exit;
+ @glMultiTexCoord2iARB := SDL_GL_GetProcAddress('glMultiTexCoord2iARB');
+ if not Assigned(glMultiTexCoord2iARB) then Exit;
+ @glMultiTexCoord2ivARB := SDL_GL_GetProcAddress('glMultiTexCoord2ivARB');
+ if not Assigned(glMultiTexCoord2ivARB) then Exit;
+ @glMultiTexCoord2sARB := SDL_GL_GetProcAddress('glMultiTexCoord2sARB');
+ if not Assigned(glMultiTexCoord2sARB) then Exit;
+ @glMultiTexCoord2svARB := SDL_GL_GetProcAddress('glMultiTexCoord2svARB');
+ if not Assigned(glMultiTexCoord2svARB) then Exit;
+ @glMultiTexCoord3dARB := SDL_GL_GetProcAddress('glMultiTexCoord3dARB');
+ if not Assigned(glMultiTexCoord3dARB) then Exit;
+ @glMultiTexCoord3dvARB := SDL_GL_GetProcAddress('glMultiTexCoord3dvARB');
+ if not Assigned(glMultiTexCoord3dvARB) then Exit;
+ @glMultiTexCoord3fARB := SDL_GL_GetProcAddress('glMultiTexCoord3fARB');
+ if not Assigned(glMultiTexCoord3fARB) then Exit;
+ @glMultiTexCoord3fvARB := SDL_GL_GetProcAddress('glMultiTexCoord3fvARB');
+ if not Assigned(glMultiTexCoord3fvARB) then Exit;
+ @glMultiTexCoord3iARB := SDL_GL_GetProcAddress('glMultiTexCoord3iARB');
+ if not Assigned(glMultiTexCoord3iARB) then Exit;
+ @glMultiTexCoord3ivARB := SDL_GL_GetProcAddress('glMultiTexCoord3ivARB');
+ if not Assigned(glMultiTexCoord3ivARB) then Exit;
+ @glMultiTexCoord3sARB := SDL_GL_GetProcAddress('glMultiTexCoord3sARB');
+ if not Assigned(glMultiTexCoord3sARB) then Exit;
+ @glMultiTexCoord3svARB := SDL_GL_GetProcAddress('glMultiTexCoord3svARB');
+ if not Assigned(glMultiTexCoord3svARB) then Exit;
+ @glMultiTexCoord4dARB := SDL_GL_GetProcAddress('glMultiTexCoord4dARB');
+ if not Assigned(glMultiTexCoord4dARB) then Exit;
+ @glMultiTexCoord4dvARB := SDL_GL_GetProcAddress('glMultiTexCoord4dvARB');
+ if not Assigned(glMultiTexCoord4dvARB) then Exit;
+ @glMultiTexCoord4fARB := SDL_GL_GetProcAddress('glMultiTexCoord4fARB');
+ if not Assigned(glMultiTexCoord4fARB) then Exit;
+ @glMultiTexCoord4fvARB := SDL_GL_GetProcAddress('glMultiTexCoord4fvARB');
+ if not Assigned(glMultiTexCoord4fvARB) then Exit;
+ @glMultiTexCoord4iARB := SDL_GL_GetProcAddress('glMultiTexCoord4iARB');
+ if not Assigned(glMultiTexCoord4iARB) then Exit;
+ @glMultiTexCoord4ivARB := SDL_GL_GetProcAddress('glMultiTexCoord4ivARB');
+ if not Assigned(glMultiTexCoord4ivARB) then Exit;
+ @glMultiTexCoord4sARB := SDL_GL_GetProcAddress('glMultiTexCoord4sARB');
+ if not Assigned(glMultiTexCoord4sARB) then Exit;
+ @glMultiTexCoord4svARB := SDL_GL_GetProcAddress('glMultiTexCoord4svARB');
+ if not Assigned(glMultiTexCoord4svARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_transpose_matrix: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_transpose_matrix', extstring) then
+ begin
+ @glLoadTransposeMatrixfARB := SDL_GL_GetProcAddress('glLoadTransposeMatrixfARB');
+ if not Assigned(glLoadTransposeMatrixfARB) then Exit;
+ @glLoadTransposeMatrixdARB := SDL_GL_GetProcAddress('glLoadTransposeMatrixdARB');
+ if not Assigned(glLoadTransposeMatrixdARB) then Exit;
+ @glMultTransposeMatrixfARB := SDL_GL_GetProcAddress('glMultTransposeMatrixfARB');
+ if not Assigned(glMultTransposeMatrixfARB) then Exit;
+ @glMultTransposeMatrixdARB := SDL_GL_GetProcAddress('glMultTransposeMatrixdARB');
+ if not Assigned(glMultTransposeMatrixdARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_multisample: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_multisample', extstring) then
+ begin
+ @glSampleCoverageARB := SDL_GL_GetProcAddress('glSampleCoverageARB');
+ if not Assigned(glSampleCoverageARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_texture_env_add: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_texture_env_add', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+{$IFDEF WINDOWS}
+function Load_WGL_ARB_extensions_string: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_ARB_extensions_string', extstring) then
+ begin
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_ARB_buffer_region: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_ARB_buffer_region', extstring) then
+ begin
+ @wglCreateBufferRegionARB := SDL_GL_GetProcAddress('wglCreateBufferRegionARB');
+ if not Assigned(wglCreateBufferRegionARB) then Exit;
+ @wglDeleteBufferRegionARB := SDL_GL_GetProcAddress('wglDeleteBufferRegionARB');
+ if not Assigned(wglDeleteBufferRegionARB) then Exit;
+ @wglSaveBufferRegionARB := SDL_GL_GetProcAddress('wglSaveBufferRegionARB');
+ if not Assigned(wglSaveBufferRegionARB) then Exit;
+ @wglRestoreBufferRegionARB := SDL_GL_GetProcAddress('wglRestoreBufferRegionARB');
+ if not Assigned(wglRestoreBufferRegionARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+{$ENDIF}
+
+function Load_GL_ARB_texture_cube_map: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_texture_cube_map', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_depth_texture: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_depth_texture', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_point_parameters: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_point_parameters', extstring) then
+ begin
+ @glPointParameterfARB := SDL_GL_GetProcAddress('glPointParameterfARB');
+ if not Assigned(glPointParameterfARB) then Exit;
+ @glPointParameterfvARB := SDL_GL_GetProcAddress('glPointParameterfvARB');
+ if not Assigned(glPointParameterfvARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_shadow: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_shadow', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_shadow_ambient: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_shadow_ambient', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_texture_border_clamp: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_texture_border_clamp', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_texture_compression: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_texture_compression', extstring) then
+ begin
+ @glCompressedTexImage3DARB := SDL_GL_GetProcAddress('glCompressedTexImage3DARB');
+ if not Assigned(glCompressedTexImage3DARB) then Exit;
+ @glCompressedTexImage2DARB := SDL_GL_GetProcAddress('glCompressedTexImage2DARB');
+ if not Assigned(glCompressedTexImage2DARB) then Exit;
+ @glCompressedTexImage1DARB := SDL_GL_GetProcAddress('glCompressedTexImage1DARB');
+ if not Assigned(glCompressedTexImage1DARB) then Exit;
+ @glCompressedTexSubImage3DARB := SDL_GL_GetProcAddress('glCompressedTexSubImage3DARB');
+ if not Assigned(glCompressedTexSubImage3DARB) then Exit;
+ @glCompressedTexSubImage2DARB := SDL_GL_GetProcAddress('glCompressedTexSubImage2DARB');
+ if not Assigned(glCompressedTexSubImage2DARB) then Exit;
+ @glCompressedTexSubImage1DARB := SDL_GL_GetProcAddress('glCompressedTexSubImage1DARB');
+ if not Assigned(glCompressedTexSubImage1DARB) then Exit;
+ @glGetCompressedTexImageARB := SDL_GL_GetProcAddress('glGetCompressedTexImageARB');
+ if not Assigned(glGetCompressedTexImageARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_texture_env_combine: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_texture_env_combine', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_texture_env_crossbar: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_texture_env_crossbar', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_texture_env_dot3: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_texture_env_dot3', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_texture_mirrored_repeat: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_texture_mirrored_repeat', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_vertex_blend: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_vertex_blend', extstring) then
+ begin
+ @glWeightbvARB := SDL_GL_GetProcAddress('glWeightbvARB');
+ if not Assigned(glWeightbvARB) then Exit;
+ @glWeightsvARB := SDL_GL_GetProcAddress('glWeightsvARB');
+ if not Assigned(glWeightsvARB) then Exit;
+ @glWeightivARB := SDL_GL_GetProcAddress('glWeightivARB');
+ if not Assigned(glWeightivARB) then Exit;
+ @glWeightfvARB := SDL_GL_GetProcAddress('glWeightfvARB');
+ if not Assigned(glWeightfvARB) then Exit;
+ @glWeightdvARB := SDL_GL_GetProcAddress('glWeightdvARB');
+ if not Assigned(glWeightdvARB) then Exit;
+ @glWeightvARB := SDL_GL_GetProcAddress('glWeightvARB');
+ if not Assigned(glWeightvARB) then Exit;
+ @glWeightubvARB := SDL_GL_GetProcAddress('glWeightubvARB');
+ if not Assigned(glWeightubvARB) then Exit;
+ @glWeightusvARB := SDL_GL_GetProcAddress('glWeightusvARB');
+ if not Assigned(glWeightusvARB) then Exit;
+ @glWeightuivARB := SDL_GL_GetProcAddress('glWeightuivARB');
+ if not Assigned(glWeightuivARB) then Exit;
+ @glWeightPointerARB := SDL_GL_GetProcAddress('glWeightPointerARB');
+ if not Assigned(glWeightPointerARB) then Exit;
+ @glVertexBlendARB := SDL_GL_GetProcAddress('glVertexBlendARB');
+ if not Assigned(glVertexBlendARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_vertex_program: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_vertex_program', extstring) then
+ begin
+ @glVertexAttrib1sARB := SDL_GL_GetProcAddress('glVertexAttrib1sARB');
+ if not Assigned(glVertexAttrib1sARB) then Exit;
+ @glVertexAttrib1fARB := SDL_GL_GetProcAddress('glVertexAttrib1fARB');
+ if not Assigned(glVertexAttrib1fARB) then Exit;
+ @glVertexAttrib1dARB := SDL_GL_GetProcAddress('glVertexAttrib1dARB');
+ if not Assigned(glVertexAttrib1dARB) then Exit;
+ @glVertexAttrib2sARB := SDL_GL_GetProcAddress('glVertexAttrib2sARB');
+ if not Assigned(glVertexAttrib2sARB) then Exit;
+ @glVertexAttrib2fARB := SDL_GL_GetProcAddress('glVertexAttrib2fARB');
+ if not Assigned(glVertexAttrib2fARB) then Exit;
+ @glVertexAttrib2dARB := SDL_GL_GetProcAddress('glVertexAttrib2dARB');
+ if not Assigned(glVertexAttrib2dARB) then Exit;
+ @glVertexAttrib3sARB := SDL_GL_GetProcAddress('glVertexAttrib3sARB');
+ if not Assigned(glVertexAttrib3sARB) then Exit;
+ @glVertexAttrib3fARB := SDL_GL_GetProcAddress('glVertexAttrib3fARB');
+ if not Assigned(glVertexAttrib3fARB) then Exit;
+ @glVertexAttrib3dARB := SDL_GL_GetProcAddress('glVertexAttrib3dARB');
+ if not Assigned(glVertexAttrib3dARB) then Exit;
+ @glVertexAttrib4sARB := SDL_GL_GetProcAddress('glVertexAttrib4sARB');
+ if not Assigned(glVertexAttrib4sARB) then Exit;
+ @glVertexAttrib4fARB := SDL_GL_GetProcAddress('glVertexAttrib4fARB');
+ if not Assigned(glVertexAttrib4fARB) then Exit;
+ @glVertexAttrib4dARB := SDL_GL_GetProcAddress('glVertexAttrib4dARB');
+ if not Assigned(glVertexAttrib4dARB) then Exit;
+ @glVertexAttrib4NubARB := SDL_GL_GetProcAddress('glVertexAttrib4NubARB');
+ if not Assigned(glVertexAttrib4NubARB) then Exit;
+ @glVertexAttrib1svARB := SDL_GL_GetProcAddress('glVertexAttrib1svARB');
+ if not Assigned(glVertexAttrib1svARB) then Exit;
+ @glVertexAttrib1fvARB := SDL_GL_GetProcAddress('glVertexAttrib1fvARB');
+ if not Assigned(glVertexAttrib1fvARB) then Exit;
+ @glVertexAttrib1dvARB := SDL_GL_GetProcAddress('glVertexAttrib1dvARB');
+ if not Assigned(glVertexAttrib1dvARB) then Exit;
+ @glVertexAttrib2svARB := SDL_GL_GetProcAddress('glVertexAttrib2svARB');
+ if not Assigned(glVertexAttrib2svARB) then Exit;
+ @glVertexAttrib2fvARB := SDL_GL_GetProcAddress('glVertexAttrib2fvARB');
+ if not Assigned(glVertexAttrib2fvARB) then Exit;
+ @glVertexAttrib2dvARB := SDL_GL_GetProcAddress('glVertexAttrib2dvARB');
+ if not Assigned(glVertexAttrib2dvARB) then Exit;
+ @glVertexAttrib3svARB := SDL_GL_GetProcAddress('glVertexAttrib3svARB');
+ if not Assigned(glVertexAttrib3svARB) then Exit;
+ @glVertexAttrib3fvARB := SDL_GL_GetProcAddress('glVertexAttrib3fvARB');
+ if not Assigned(glVertexAttrib3fvARB) then Exit;
+ @glVertexAttrib3dvARB := SDL_GL_GetProcAddress('glVertexAttrib3dvARB');
+ if not Assigned(glVertexAttrib3dvARB) then Exit;
+ @glVertexAttrib4bvARB := SDL_GL_GetProcAddress('glVertexAttrib4bvARB');
+ if not Assigned(glVertexAttrib4bvARB) then Exit;
+ @glVertexAttrib4svARB := SDL_GL_GetProcAddress('glVertexAttrib4svARB');
+ if not Assigned(glVertexAttrib4svARB) then Exit;
+ @glVertexAttrib4ivARB := SDL_GL_GetProcAddress('glVertexAttrib4ivARB');
+ if not Assigned(glVertexAttrib4ivARB) then Exit;
+ @glVertexAttrib4ubvARB := SDL_GL_GetProcAddress('glVertexAttrib4ubvARB');
+ if not Assigned(glVertexAttrib4ubvARB) then Exit;
+ @glVertexAttrib4usvARB := SDL_GL_GetProcAddress('glVertexAttrib4usvARB');
+ if not Assigned(glVertexAttrib4usvARB) then Exit;
+ @glVertexAttrib4uivARB := SDL_GL_GetProcAddress('glVertexAttrib4uivARB');
+ if not Assigned(glVertexAttrib4uivARB) then Exit;
+ @glVertexAttrib4fvARB := SDL_GL_GetProcAddress('glVertexAttrib4fvARB');
+ if not Assigned(glVertexAttrib4fvARB) then Exit;
+ @glVertexAttrib4dvARB := SDL_GL_GetProcAddress('glVertexAttrib4dvARB');
+ if not Assigned(glVertexAttrib4dvARB) then Exit;
+ @glVertexAttrib4NbvARB := SDL_GL_GetProcAddress('glVertexAttrib4NbvARB');
+ if not Assigned(glVertexAttrib4NbvARB) then Exit;
+ @glVertexAttrib4NsvARB := SDL_GL_GetProcAddress('glVertexAttrib4NsvARB');
+ if not Assigned(glVertexAttrib4NsvARB) then Exit;
+ @glVertexAttrib4NivARB := SDL_GL_GetProcAddress('glVertexAttrib4NivARB');
+ if not Assigned(glVertexAttrib4NivARB) then Exit;
+ @glVertexAttrib4NubvARB := SDL_GL_GetProcAddress('glVertexAttrib4NubvARB');
+ if not Assigned(glVertexAttrib4NubvARB) then Exit;
+ @glVertexAttrib4NusvARB := SDL_GL_GetProcAddress('glVertexAttrib4NusvARB');
+ if not Assigned(glVertexAttrib4NusvARB) then Exit;
+ @glVertexAttrib4NuivARB := SDL_GL_GetProcAddress('glVertexAttrib4NuivARB');
+ if not Assigned(glVertexAttrib4NuivARB) then Exit;
+ @glVertexAttribPointerARB := SDL_GL_GetProcAddress('glVertexAttribPointerARB');
+ if not Assigned(glVertexAttribPointerARB) then Exit;
+ @glEnableVertexAttribArrayARB := SDL_GL_GetProcAddress('glEnableVertexAttribArrayARB');
+ if not Assigned(glEnableVertexAttribArrayARB) then Exit;
+ @glDisableVertexAttribArrayARB := SDL_GL_GetProcAddress('glDisableVertexAttribArrayARB');
+ if not Assigned(glDisableVertexAttribArrayARB) then Exit;
+ @glProgramStringARB := SDL_GL_GetProcAddress('glProgramStringARB');
+ if not Assigned(glProgramStringARB) then Exit;
+ @glBindProgramARB := SDL_GL_GetProcAddress('glBindProgramARB');
+ if not Assigned(glBindProgramARB) then Exit;
+ @glDeleteProgramsARB := SDL_GL_GetProcAddress('glDeleteProgramsARB');
+ if not Assigned(glDeleteProgramsARB) then Exit;
+ @glGenProgramsARB := SDL_GL_GetProcAddress('glGenProgramsARB');
+ if not Assigned(glGenProgramsARB) then Exit;
+ @glProgramEnvParameter4dARB := SDL_GL_GetProcAddress('glProgramEnvParameter4dARB');
+ if not Assigned(glProgramEnvParameter4dARB) then Exit;
+ @glProgramEnvParameter4dvARB := SDL_GL_GetProcAddress('glProgramEnvParameter4dvARB');
+ if not Assigned(glProgramEnvParameter4dvARB) then Exit;
+ @glProgramEnvParameter4fARB := SDL_GL_GetProcAddress('glProgramEnvParameter4fARB');
+ if not Assigned(glProgramEnvParameter4fARB) then Exit;
+ @glProgramEnvParameter4fvARB := SDL_GL_GetProcAddress('glProgramEnvParameter4fvARB');
+ if not Assigned(glProgramEnvParameter4fvARB) then Exit;
+ @glProgramLocalParameter4dARB := SDL_GL_GetProcAddress('glProgramLocalParameter4dARB');
+ if not Assigned(glProgramLocalParameter4dARB) then Exit;
+ @glProgramLocalParameter4dvARB := SDL_GL_GetProcAddress('glProgramLocalParameter4dvARB');
+ if not Assigned(glProgramLocalParameter4dvARB) then Exit;
+ @glProgramLocalParameter4fARB := SDL_GL_GetProcAddress('glProgramLocalParameter4fARB');
+ if not Assigned(glProgramLocalParameter4fARB) then Exit;
+ @glProgramLocalParameter4fvARB := SDL_GL_GetProcAddress('glProgramLocalParameter4fvARB');
+ if not Assigned(glProgramLocalParameter4fvARB) then Exit;
+ @glGetProgramEnvParameterdvARB := SDL_GL_GetProcAddress('glGetProgramEnvParameterdvARB');
+ if not Assigned(glGetProgramEnvParameterdvARB) then Exit;
+ @glGetProgramEnvParameterfvARB := SDL_GL_GetProcAddress('glGetProgramEnvParameterfvARB');
+ if not Assigned(glGetProgramEnvParameterfvARB) then Exit;
+ @glGetProgramLocalParameterdvARB := SDL_GL_GetProcAddress('glGetProgramLocalParameterdvARB');
+ if not Assigned(glGetProgramLocalParameterdvARB) then Exit;
+ @glGetProgramLocalParameterfvARB := SDL_GL_GetProcAddress('glGetProgramLocalParameterfvARB');
+ if not Assigned(glGetProgramLocalParameterfvARB) then Exit;
+ @glGetProgramivARB := SDL_GL_GetProcAddress('glGetProgramivARB');
+ if not Assigned(glGetProgramivARB) then Exit;
+ @glGetProgramStringARB := SDL_GL_GetProcAddress('glGetProgramStringARB');
+ if not Assigned(glGetProgramStringARB) then Exit;
+ @glGetVertexAttribdvARB := SDL_GL_GetProcAddress('glGetVertexAttribdvARB');
+ if not Assigned(glGetVertexAttribdvARB) then Exit;
+ @glGetVertexAttribfvARB := SDL_GL_GetProcAddress('glGetVertexAttribfvARB');
+ if not Assigned(glGetVertexAttribfvARB) then Exit;
+ @glGetVertexAttribivARB := SDL_GL_GetProcAddress('glGetVertexAttribivARB');
+ if not Assigned(glGetVertexAttribivARB) then Exit;
+ @glGetVertexAttribPointervARB := SDL_GL_GetProcAddress('glGetVertexAttribPointervARB');
+ if not Assigned(glGetVertexAttribPointervARB) then Exit;
+ @glIsProgramARB := SDL_GL_GetProcAddress('glIsProgramARB');
+ if not Assigned(glIsProgramARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_window_pos: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_window_pos', extstring) then
+ begin
+ @glWindowPos2dARB := SDL_GL_GetProcAddress('glWindowPos2dARB');
+ if not Assigned(glWindowPos2dARB) then Exit;
+ @glWindowPos2fARB := SDL_GL_GetProcAddress('glWindowPos2fARB');
+ if not Assigned(glWindowPos2fARB) then Exit;
+ @glWindowPos2iARB := SDL_GL_GetProcAddress('glWindowPos2iARB');
+ if not Assigned(glWindowPos2iARB) then Exit;
+ @glWindowPos2sARB := SDL_GL_GetProcAddress('glWindowPos2sARB');
+ if not Assigned(glWindowPos2sARB) then Exit;
+ @glWindowPos2dvARB := SDL_GL_GetProcAddress('glWindowPos2dvARB');
+ if not Assigned(glWindowPos2dvARB) then Exit;
+ @glWindowPos2fvARB := SDL_GL_GetProcAddress('glWindowPos2fvARB');
+ if not Assigned(glWindowPos2fvARB) then Exit;
+ @glWindowPos2ivARB := SDL_GL_GetProcAddress('glWindowPos2ivARB');
+ if not Assigned(glWindowPos2ivARB) then Exit;
+ @glWindowPos2svARB := SDL_GL_GetProcAddress('glWindowPos2svARB');
+ if not Assigned(glWindowPos2svARB) then Exit;
+ @glWindowPos3dARB := SDL_GL_GetProcAddress('glWindowPos3dARB');
+ if not Assigned(glWindowPos3dARB) then Exit;
+ @glWindowPos3fARB := SDL_GL_GetProcAddress('glWindowPos3fARB');
+ if not Assigned(glWindowPos3fARB) then Exit;
+ @glWindowPos3iARB := SDL_GL_GetProcAddress('glWindowPos3iARB');
+ if not Assigned(glWindowPos3iARB) then Exit;
+ @glWindowPos3sARB := SDL_GL_GetProcAddress('glWindowPos3sARB');
+ if not Assigned(glWindowPos3sARB) then Exit;
+ @glWindowPos3dvARB := SDL_GL_GetProcAddress('glWindowPos3dvARB');
+ if not Assigned(glWindowPos3dvARB) then Exit;
+ @glWindowPos3fvARB := SDL_GL_GetProcAddress('glWindowPos3fvARB');
+ if not Assigned(glWindowPos3fvARB) then Exit;
+ @glWindowPos3ivARB := SDL_GL_GetProcAddress('glWindowPos3ivARB');
+ if not Assigned(glWindowPos3ivARB) then Exit;
+ @glWindowPos3svARB := SDL_GL_GetProcAddress('glWindowPos3svARB');
+ if not Assigned(glWindowPos3svARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_422_pixels: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_422_pixels', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_abgr: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_abgr', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_bgra: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_bgra', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_blend_color: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_blend_color', extstring) then
+ begin
+ @glBlendColorEXT := SDL_GL_GetProcAddress('glBlendColorEXT');
+ if not Assigned(glBlendColorEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_blend_func_separate: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_blend_func_separate', extstring) then
+ begin
+ @glBlendFuncSeparateEXT := SDL_GL_GetProcAddress('glBlendFuncSeparateEXT');
+ if not Assigned(glBlendFuncSeparateEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_blend_logic_op: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_blend_logic_op', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_blend_minmax: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_blend_minmax', extstring) then
+ begin
+ @glBlendEquationEXT := SDL_GL_GetProcAddress('glBlendEquationEXT');
+ if not Assigned(glBlendEquationEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_blend_subtract: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_blend_subtract', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_clip_volume_hint: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_clip_volume_hint', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_color_subtable: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_color_subtable', extstring) then
+ begin
+ @glColorSubTableEXT := SDL_GL_GetProcAddress('glColorSubTableEXT');
+ if not Assigned(glColorSubTableEXT) then Exit;
+ @glCopyColorSubTableEXT := SDL_GL_GetProcAddress('glCopyColorSubTableEXT');
+ if not Assigned(glCopyColorSubTableEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_compiled_vertex_array: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_compiled_vertex_array', extstring) then
+ begin
+ @glLockArraysEXT := SDL_GL_GetProcAddress('glLockArraysEXT');
+ if not Assigned(glLockArraysEXT) then Exit;
+ @glUnlockArraysEXT := SDL_GL_GetProcAddress('glUnlockArraysEXT');
+ if not Assigned(glUnlockArraysEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_convolution: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_convolution', extstring) then
+ begin
+ @glConvolutionFilter1DEXT := SDL_GL_GetProcAddress('glConvolutionFilter1DEXT');
+ if not Assigned(glConvolutionFilter1DEXT) then Exit;
+ @glConvolutionFilter2DEXT := SDL_GL_GetProcAddress('glConvolutionFilter2DEXT');
+ if not Assigned(glConvolutionFilter2DEXT) then Exit;
+ @glCopyConvolutionFilter1DEXT := SDL_GL_GetProcAddress('glCopyConvolutionFilter1DEXT');
+ if not Assigned(glCopyConvolutionFilter1DEXT) then Exit;
+ @glCopyConvolutionFilter2DEXT := SDL_GL_GetProcAddress('glCopyConvolutionFilter2DEXT');
+ if not Assigned(glCopyConvolutionFilter2DEXT) then Exit;
+ @glGetConvolutionFilterEXT := SDL_GL_GetProcAddress('glGetConvolutionFilterEXT');
+ if not Assigned(glGetConvolutionFilterEXT) then Exit;
+ @glSeparableFilter2DEXT := SDL_GL_GetProcAddress('glSeparableFilter2DEXT');
+ if not Assigned(glSeparableFilter2DEXT) then Exit;
+ @glGetSeparableFilterEXT := SDL_GL_GetProcAddress('glGetSeparableFilterEXT');
+ if not Assigned(glGetSeparableFilterEXT) then Exit;
+ @glConvolutionParameteriEXT := SDL_GL_GetProcAddress('glConvolutionParameteriEXT');
+ if not Assigned(glConvolutionParameteriEXT) then Exit;
+ @glConvolutionParameterivEXT := SDL_GL_GetProcAddress('glConvolutionParameterivEXT');
+ if not Assigned(glConvolutionParameterivEXT) then Exit;
+ @glConvolutionParameterfEXT := SDL_GL_GetProcAddress('glConvolutionParameterfEXT');
+ if not Assigned(glConvolutionParameterfEXT) then Exit;
+ @glConvolutionParameterfvEXT := SDL_GL_GetProcAddress('glConvolutionParameterfvEXT');
+ if not Assigned(glConvolutionParameterfvEXT) then Exit;
+ @glGetConvolutionParameterivEXT := SDL_GL_GetProcAddress('glGetConvolutionParameterivEXT');
+ if not Assigned(glGetConvolutionParameterivEXT) then Exit;
+ @glGetConvolutionParameterfvEXT := SDL_GL_GetProcAddress('glGetConvolutionParameterfvEXT');
+ if not Assigned(glGetConvolutionParameterfvEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_histogram: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_histogram', extstring) then
+ begin
+ @glHistogramEXT := SDL_GL_GetProcAddress('glHistogramEXT');
+ if not Assigned(glHistogramEXT) then Exit;
+ @glResetHistogramEXT := SDL_GL_GetProcAddress('glResetHistogramEXT');
+ if not Assigned(glResetHistogramEXT) then Exit;
+ @glGetHistogramEXT := SDL_GL_GetProcAddress('glGetHistogramEXT');
+ if not Assigned(glGetHistogramEXT) then Exit;
+ @glGetHistogramParameterivEXT := SDL_GL_GetProcAddress('glGetHistogramParameterivEXT');
+ if not Assigned(glGetHistogramParameterivEXT) then Exit;
+ @glGetHistogramParameterfvEXT := SDL_GL_GetProcAddress('glGetHistogramParameterfvEXT');
+ if not Assigned(glGetHistogramParameterfvEXT) then Exit;
+ @glMinmaxEXT := SDL_GL_GetProcAddress('glMinmaxEXT');
+ if not Assigned(glMinmaxEXT) then Exit;
+ @glResetMinmaxEXT := SDL_GL_GetProcAddress('glResetMinmaxEXT');
+ if not Assigned(glResetMinmaxEXT) then Exit;
+ @glGetMinmaxEXT := SDL_GL_GetProcAddress('glGetMinmaxEXT');
+ if not Assigned(glGetMinmaxEXT) then Exit;
+ @glGetMinmaxParameterivEXT := SDL_GL_GetProcAddress('glGetMinmaxParameterivEXT');
+ if not Assigned(glGetMinmaxParameterivEXT) then Exit;
+ @glGetMinmaxParameterfvEXT := SDL_GL_GetProcAddress('glGetMinmaxParameterfvEXT');
+ if not Assigned(glGetMinmaxParameterfvEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_multi_draw_arrays: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_multi_draw_arrays', extstring) then
+ begin
+ @glMultiDrawArraysEXT := SDL_GL_GetProcAddress('glMultiDrawArraysEXT');
+ if not Assigned(glMultiDrawArraysEXT) then Exit;
+ @glMultiDrawElementsEXT := SDL_GL_GetProcAddress('glMultiDrawElementsEXT');
+ if not Assigned(glMultiDrawElementsEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_packed_pixels: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_packed_pixels', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_paletted_texture: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_paletted_texture', extstring) then
+ begin
+ @glColorTableEXT := SDL_GL_GetProcAddress('glColorTableEXT');
+ if not Assigned(glColorTableEXT) then Exit;
+ @glColorSubTableEXT := SDL_GL_GetProcAddress('glColorSubTableEXT');
+ if not Assigned(glColorSubTableEXT) then Exit;
+ @glGetColorTableEXT := SDL_GL_GetProcAddress('glGetColorTableEXT');
+ if not Assigned(glGetColorTableEXT) then Exit;
+ @glGetColorTableParameterivEXT := SDL_GL_GetProcAddress('glGetColorTableParameterivEXT');
+ if not Assigned(glGetColorTableParameterivEXT) then Exit;
+ @glGetColorTableParameterfvEXT := SDL_GL_GetProcAddress('glGetColorTableParameterfvEXT');
+ if not Assigned(glGetColorTableParameterfvEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_point_parameters: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_point_parameters', extstring) then
+ begin
+ @glPointParameterfEXT := SDL_GL_GetProcAddress('glPointParameterfEXT');
+ if not Assigned(glPointParameterfEXT) then Exit;
+ @glPointParameterfvEXT := SDL_GL_GetProcAddress('glPointParameterfvEXT');
+ if not Assigned(glPointParameterfvEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_polygon_offset: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_polygon_offset', extstring) then
+ begin
+ @glPolygonOffsetEXT := SDL_GL_GetProcAddress('glPolygonOffsetEXT');
+ if not Assigned(glPolygonOffsetEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_separate_specular_color: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_separate_specular_color', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_shadow_funcs: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_shadow_funcs', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_shared_texture_palette: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_shared_texture_palette', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_stencil_two_side: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_stencil_two_side', extstring) then
+ begin
+ @glActiveStencilFaceEXT := SDL_GL_GetProcAddress('glActiveStencilFaceEXT');
+ if not Assigned(glActiveStencilFaceEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_stencil_wrap: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_stencil_wrap', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_subtexture: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_subtexture', extstring) then
+ begin
+ @glTexSubImage1DEXT := SDL_GL_GetProcAddress('glTexSubImage1DEXT');
+ if not Assigned(glTexSubImage1DEXT) then Exit;
+ @glTexSubImage2DEXT := SDL_GL_GetProcAddress('glTexSubImage2DEXT');
+ if not Assigned(glTexSubImage2DEXT) then Exit;
+ @glTexSubImage3DEXT := SDL_GL_GetProcAddress('glTexSubImage3DEXT');
+ if not Assigned(glTexSubImage3DEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_texture3D: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_texture3D', extstring) then
+ begin
+ glTexImage3DEXT := SDL_GL_GetProcAddress('glTexImage3DEXT');
+ if not Assigned(glTexImage3DEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_texture_compression_s3tc: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_texture_compression_s3tc', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_texture_env_add: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_texture_env_add', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_texture_env_combine: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_texture_env_combine', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_texture_env_dot3: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_texture_env_dot3', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_texture_filter_anisotropic: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_texture_filter_anisotropic', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_texture_lod_bias: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_texture_lod_bias', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_texture_object: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_texture_object', extstring) then
+ begin
+ @glGenTexturesEXT := SDL_GL_GetProcAddress('glGenTexturesEXT');
+ if not Assigned(glGenTexturesEXT) then Exit;
+ @glDeleteTexturesEXT := SDL_GL_GetProcAddress('glDeleteTexturesEXT');
+ if not Assigned(glDeleteTexturesEXT) then Exit;
+ @glBindTextureEXT := SDL_GL_GetProcAddress('glBindTextureEXT');
+ if not Assigned(glBindTextureEXT) then Exit;
+ @glPrioritizeTexturesEXT := SDL_GL_GetProcAddress('glPrioritizeTexturesEXT');
+ if not Assigned(glPrioritizeTexturesEXT) then Exit;
+ @glAreTexturesResidentEXT := SDL_GL_GetProcAddress('glAreTexturesResidentEXT');
+ if not Assigned(glAreTexturesResidentEXT) then Exit;
+ @glIsTextureEXT := SDL_GL_GetProcAddress('glIsTextureEXT');
+ if not Assigned(glIsTextureEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_vertex_array: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_vertex_array', extstring) then
+ begin
+ @glArrayElementEXT := SDL_GL_GetProcAddress('glArrayElementEXT');
+ if not Assigned(glArrayElementEXT) then Exit;
+ @glDrawArraysEXT := SDL_GL_GetProcAddress('glDrawArraysEXT');
+ if not Assigned(glDrawArraysEXT) then Exit;
+ @glVertexPointerEXT := SDL_GL_GetProcAddress('glVertexPointerEXT');
+ if not Assigned(glVertexPointerEXT) then Exit;
+ @glNormalPointerEXT := SDL_GL_GetProcAddress('glNormalPointerEXT');
+ if not Assigned(glNormalPointerEXT) then Exit;
+ @glColorPointerEXT := SDL_GL_GetProcAddress('glColorPointerEXT');
+ if not Assigned(glColorPointerEXT) then Exit;
+ @glIndexPointerEXT := SDL_GL_GetProcAddress('glIndexPointerEXT');
+ if not Assigned(glIndexPointerEXT) then Exit;
+ @glTexCoordPointerEXT := SDL_GL_GetProcAddress('glTexCoordPointerEXT');
+ if not Assigned(glTexCoordPointerEXT) then Exit;
+ @glEdgeFlagPointerEXT := SDL_GL_GetProcAddress('glEdgeFlagPointerEXT');
+ if not Assigned(glEdgeFlagPointerEXT) then Exit;
+ @glGetPointervEXT := SDL_GL_GetProcAddress('glGetPointervEXT');
+ if not Assigned(glGetPointervEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_vertex_shader: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_vertex_shader', extstring) then
+ begin
+ @glBeginVertexShaderEXT := SDL_GL_GetProcAddress('glBeginVertexShaderEXT');
+ if not Assigned(glBeginVertexShaderEXT) then Exit;
+ @glEndVertexShaderEXT := SDL_GL_GetProcAddress('glEndVertexShaderEXT');
+ if not Assigned(glEndVertexShaderEXT) then Exit;
+ @glBindVertexShaderEXT := SDL_GL_GetProcAddress('glBindVertexShaderEXT');
+ if not Assigned(glBindVertexShaderEXT) then Exit;
+ @glGenVertexShadersEXT := SDL_GL_GetProcAddress('glGenVertexShadersEXT');
+ if not Assigned(glGenVertexShadersEXT) then Exit;
+ @glDeleteVertexShaderEXT := SDL_GL_GetProcAddress('glDeleteVertexShaderEXT');
+ if not Assigned(glDeleteVertexShaderEXT) then Exit;
+ @glShaderOp1EXT := SDL_GL_GetProcAddress('glShaderOp1EXT');
+ if not Assigned(glShaderOp1EXT) then Exit;
+ @glShaderOp2EXT := SDL_GL_GetProcAddress('glShaderOp2EXT');
+ if not Assigned(glShaderOp2EXT) then Exit;
+ @glShaderOp3EXT := SDL_GL_GetProcAddress('glShaderOp3EXT');
+ if not Assigned(glShaderOp3EXT) then Exit;
+ @glSwizzleEXT := SDL_GL_GetProcAddress('glSwizzleEXT');
+ if not Assigned(glSwizzleEXT) then Exit;
+ @glWriteMaskEXT := SDL_GL_GetProcAddress('glWriteMaskEXT');
+ if not Assigned(glWriteMaskEXT) then Exit;
+ @glInsertComponentEXT := SDL_GL_GetProcAddress('glInsertComponentEXT');
+ if not Assigned(glInsertComponentEXT) then Exit;
+ @glExtractComponentEXT := SDL_GL_GetProcAddress('glExtractComponentEXT');
+ if not Assigned(glExtractComponentEXT) then Exit;
+ @glGenSymbolsEXT := SDL_GL_GetProcAddress('glGenSymbolsEXT');
+ if not Assigned(glGenSymbolsEXT) then Exit;
+ @glSetInvariantEXT := SDL_GL_GetProcAddress('glSetInvariantEXT');
+ if not Assigned(glSetInvariantEXT) then Exit;
+ @glSetLocalConstantEXT := SDL_GL_GetProcAddress('glSetLocalConstantEXT');
+ if not Assigned(glSetLocalConstantEXT) then Exit;
+ @glVariantbvEXT := SDL_GL_GetProcAddress('glVariantbvEXT');
+ if not Assigned(glVariantbvEXT) then Exit;
+ @glVariantsvEXT := SDL_GL_GetProcAddress('glVariantsvEXT');
+ if not Assigned(glVariantsvEXT) then Exit;
+ @glVariantivEXT := SDL_GL_GetProcAddress('glVariantivEXT');
+ if not Assigned(glVariantivEXT) then Exit;
+ @glVariantfvEXT := SDL_GL_GetProcAddress('glVariantfvEXT');
+ if not Assigned(glVariantfvEXT) then Exit;
+ @glVariantdvEXT := SDL_GL_GetProcAddress('glVariantdvEXT');
+ if not Assigned(glVariantdvEXT) then Exit;
+ @glVariantubvEXT := SDL_GL_GetProcAddress('glVariantubvEXT');
+ if not Assigned(glVariantubvEXT) then Exit;
+ @glVariantusvEXT := SDL_GL_GetProcAddress('glVariantusvEXT');
+ if not Assigned(glVariantusvEXT) then Exit;
+ @glVariantuivEXT := SDL_GL_GetProcAddress('glVariantuivEXT');
+ if not Assigned(glVariantuivEXT) then Exit;
+ @glVariantPointerEXT := SDL_GL_GetProcAddress('glVariantPointerEXT');
+ if not Assigned(glVariantPointerEXT) then Exit;
+ @glEnableVariantClientStateEXT := SDL_GL_GetProcAddress('glEnableVariantClientStateEXT');
+ if not Assigned(glEnableVariantClientStateEXT) then Exit;
+ @glDisableVariantClientStateEXT := SDL_GL_GetProcAddress('glDisableVariantClientStateEXT');
+ if not Assigned(glDisableVariantClientStateEXT) then Exit;
+ @glBindLightParameterEXT := SDL_GL_GetProcAddress('glBindLightParameterEXT');
+ if not Assigned(glBindLightParameterEXT) then Exit;
+ @glBindMaterialParameterEXT := SDL_GL_GetProcAddress('glBindMaterialParameterEXT');
+ if not Assigned(glBindMaterialParameterEXT) then Exit;
+ @glBindTexGenParameterEXT := SDL_GL_GetProcAddress('glBindTexGenParameterEXT');
+ if not Assigned(glBindTexGenParameterEXT) then Exit;
+ @glBindTextureUnitParameterEXT := SDL_GL_GetProcAddress('glBindTextureUnitParameterEXT');
+ if not Assigned(glBindTextureUnitParameterEXT) then Exit;
+ @glBindParameterEXT := SDL_GL_GetProcAddress('glBindParameterEXT');
+ if not Assigned(glBindParameterEXT) then Exit;
+ @glIsVariantEnabledEXT := SDL_GL_GetProcAddress('glIsVariantEnabledEXT');
+ if not Assigned(glIsVariantEnabledEXT) then Exit;
+ @glGetVariantBooleanvEXT := SDL_GL_GetProcAddress('glGetVariantBooleanvEXT');
+ if not Assigned(glGetVariantBooleanvEXT) then Exit;
+ @glGetVariantIntegervEXT := SDL_GL_GetProcAddress('glGetVariantIntegervEXT');
+ if not Assigned(glGetVariantIntegervEXT) then Exit;
+ @glGetVariantFloatvEXT := SDL_GL_GetProcAddress('glGetVariantFloatvEXT');
+ if not Assigned(glGetVariantFloatvEXT) then Exit;
+ @glGetVariantPointervEXT := SDL_GL_GetProcAddress('glGetVariantPointervEXT');
+ if not Assigned(glGetVariantPointervEXT) then Exit;
+ @glGetInvariantBooleanvEXT := SDL_GL_GetProcAddress('glGetInvariantBooleanvEXT');
+ if not Assigned(glGetInvariantBooleanvEXT) then Exit;
+ @glGetInvariantIntegervEXT := SDL_GL_GetProcAddress('glGetInvariantIntegervEXT');
+ if not Assigned(glGetInvariantIntegervEXT) then Exit;
+ @glGetInvariantFloatvEXT := SDL_GL_GetProcAddress('glGetInvariantFloatvEXT');
+ if not Assigned(glGetInvariantFloatvEXT) then Exit;
+ @glGetLocalConstantBooleanvEXT := SDL_GL_GetProcAddress('glGetLocalConstantBooleanvEXT');
+ if not Assigned(glGetLocalConstantBooleanvEXT) then Exit;
+ @glGetLocalConstantIntegervEXT := SDL_GL_GetProcAddress('glGetLocalConstantIntegervEXT');
+ if not Assigned(glGetLocalConstantIntegervEXT) then Exit;
+ @glGetLocalConstantFloatvEXT := SDL_GL_GetProcAddress('glGetLocalConstantFloatvEXT');
+ if not Assigned(glGetLocalConstantFloatvEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_vertex_weighting: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_vertex_weighting', extstring) then
+ begin
+ @glVertexWeightfEXT := SDL_GL_GetProcAddress('glVertexWeightfEXT');
+ if not Assigned(glVertexWeightfEXT) then Exit;
+ @glVertexWeightfvEXT := SDL_GL_GetProcAddress('glVertexWeightfvEXT');
+ if not Assigned(glVertexWeightfvEXT) then Exit;
+ @glVertexWeightPointerEXT := SDL_GL_GetProcAddress('glVertexWeightPointerEXT');
+ if not Assigned(glVertexWeightPointerEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_HP_occlusion_test: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_HP_occlusion_test', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_blend_square: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_blend_square', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_copy_depth_to_color: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_copy_depth_to_color', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_depth_clamp: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_depth_clamp', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_evaluators: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_evaluators', extstring) then
+ begin
+ @glMapControlPointsNV := SDL_GL_GetProcAddress('glMapControlPointsNV');
+ if not Assigned(glMapControlPointsNV) then Exit;
+ @glMapParameterivNV := SDL_GL_GetProcAddress('glMapParameterivNV');
+ if not Assigned(glMapParameterivNV) then Exit;
+ @glMapParameterfvNV := SDL_GL_GetProcAddress('glMapParameterfvNV');
+ if not Assigned(glMapParameterfvNV) then Exit;
+ @glGetMapControlPointsNV := SDL_GL_GetProcAddress('glGetMapControlPointsNV');
+ if not Assigned(glGetMapControlPointsNV) then Exit;
+ @glGetMapParameterivNV := SDL_GL_GetProcAddress('glGetMapParameterivNV');
+ if not Assigned(glGetMapParameterivNV) then Exit;
+ @glGetMapParameterfvNV := SDL_GL_GetProcAddress('glGetMapParameterfvNV');
+ if not Assigned(glGetMapParameterfvNV) then Exit;
+ @glGetMapAttribParameterivNV := SDL_GL_GetProcAddress('glGetMapAttribParameterivNV');
+ if not Assigned(glGetMapAttribParameterivNV) then Exit;
+ @glGetMapAttribParameterfvNV := SDL_GL_GetProcAddress('glGetMapAttribParameterfvNV');
+ if not Assigned(glGetMapAttribParameterfvNV) then Exit;
+ @glEvalMapsNV := SDL_GL_GetProcAddress('glEvalMapsNV');
+ if not Assigned(glEvalMapsNV) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_fence: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_fence', extstring) then
+ begin
+ @glGenFencesNV := SDL_GL_GetProcAddress('glGenFencesNV');
+ if not Assigned(glGenFencesNV) then Exit;
+ @glDeleteFencesNV := SDL_GL_GetProcAddress('glDeleteFencesNV');
+ if not Assigned(glDeleteFencesNV) then Exit;
+ @glSetFenceNV := SDL_GL_GetProcAddress('glSetFenceNV');
+ if not Assigned(glSetFenceNV) then Exit;
+ @glTestFenceNV := SDL_GL_GetProcAddress('glTestFenceNV');
+ if not Assigned(glTestFenceNV) then Exit;
+ @glFinishFenceNV := SDL_GL_GetProcAddress('glFinishFenceNV');
+ if not Assigned(glFinishFenceNV) then Exit;
+ @glIsFenceNV := SDL_GL_GetProcAddress('glIsFenceNV');
+ if not Assigned(glIsFenceNV) then Exit;
+ @glGetFenceivNV := SDL_GL_GetProcAddress('glGetFenceivNV');
+ if not Assigned(glGetFenceivNV) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_fog_distance: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_fog_distance', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_light_max_exponent: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_light_max_exponent', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_multisample_filter_hint: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_multisample_filter_hint', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_occlusion_query: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_occlusion_query', extstring) then
+ begin
+ @glGenOcclusionQueriesNV := SDL_GL_GetProcAddress('glGenOcclusionQueriesNV');
+ if not Assigned(glGenOcclusionQueriesNV) then Exit;
+ @glDeleteOcclusionQueriesNV := SDL_GL_GetProcAddress('glDeleteOcclusionQueriesNV');
+ if not Assigned(glDeleteOcclusionQueriesNV) then Exit;
+ @glIsOcclusionQueryNV := SDL_GL_GetProcAddress('glIsOcclusionQueryNV');
+ if not Assigned(glIsOcclusionQueryNV) then Exit;
+ @glBeginOcclusionQueryNV := SDL_GL_GetProcAddress('glBeginOcclusionQueryNV');
+ if not Assigned(glBeginOcclusionQueryNV) then Exit;
+ @glEndOcclusionQueryNV := SDL_GL_GetProcAddress('glEndOcclusionQueryNV');
+ if not Assigned(glEndOcclusionQueryNV) then Exit;
+ @glGetOcclusionQueryivNV := SDL_GL_GetProcAddress('glGetOcclusionQueryivNV');
+ if not Assigned(glGetOcclusionQueryivNV) then Exit;
+ @glGetOcclusionQueryuivNV := SDL_GL_GetProcAddress('glGetOcclusionQueryuivNV');
+ if not Assigned(glGetOcclusionQueryuivNV) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_packed_depth_stencil: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_packed_depth_stencil', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_point_sprite: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_point_sprite', extstring) then
+ begin
+ @glPointParameteriNV := SDL_GL_GetProcAddress('glPointParameteriNV');
+ if not Assigned(glPointParameteriNV) then Exit;
+ @glPointParameterivNV := SDL_GL_GetProcAddress('glPointParameterivNV');
+ if not Assigned(glPointParameterivNV) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_register_combiners: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_register_combiners', extstring) then
+ begin
+ @glCombinerParameterfvNV := SDL_GL_GetProcAddress('glCombinerParameterfvNV');
+ if not Assigned(glCombinerParameterfvNV) then Exit;
+ @glCombinerParameterivNV := SDL_GL_GetProcAddress('glCombinerParameterivNV');
+ if not Assigned(glCombinerParameterivNV) then Exit;
+ @glCombinerParameterfNV := SDL_GL_GetProcAddress('glCombinerParameterfNV');
+ if not Assigned(glCombinerParameterfNV) then Exit;
+ @glCombinerParameteriNV := SDL_GL_GetProcAddress('glCombinerParameteriNV');
+ if not Assigned(glCombinerParameteriNV) then Exit;
+ @glCombinerInputNV := SDL_GL_GetProcAddress('glCombinerInputNV');
+ if not Assigned(glCombinerInputNV) then Exit;
+ @glCombinerOutputNV := SDL_GL_GetProcAddress('glCombinerOutputNV');
+ if not Assigned(glCombinerOutputNV) then Exit;
+ @glFinalCombinerInputNV := SDL_GL_GetProcAddress('glFinalCombinerInputNV');
+ if not Assigned(glFinalCombinerInputNV) then Exit;
+ @glGetCombinerInputParameterfvNV := SDL_GL_GetProcAddress('glGetCombinerInputParameterfvNV');
+ if not Assigned(glGetCombinerInputParameterfvNV) then Exit;
+ @glGetCombinerInputParameterivNV := SDL_GL_GetProcAddress('glGetCombinerInputParameterivNV');
+ if not Assigned(glGetCombinerInputParameterivNV) then Exit;
+ @glGetCombinerOutputParameterfvNV := SDL_GL_GetProcAddress('glGetCombinerOutputParameterfvNV');
+ if not Assigned(glGetCombinerOutputParameterfvNV) then Exit;
+ @glGetCombinerOutputParameterivNV := SDL_GL_GetProcAddress('glGetCombinerOutputParameterivNV');
+ if not Assigned(glGetCombinerOutputParameterivNV) then Exit;
+ @glGetFinalCombinerInputParameterfvNV := SDL_GL_GetProcAddress('glGetFinalCombinerInputParameterfvNV');
+ if not Assigned(glGetFinalCombinerInputParameterfvNV) then Exit;
+ @glGetFinalCombinerInputParameterivNV := SDL_GL_GetProcAddress('glGetFinalCombinerInputParameterivNV');
+ if not Assigned(glGetFinalCombinerInputParameterivNV) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_register_combiners2: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_register_combiners2', extstring) then
+ begin
+ @glCombinerStageParameterfvNV := SDL_GL_GetProcAddress('glCombinerStageParameterfvNV');
+ if not Assigned(glCombinerStageParameterfvNV) then Exit;
+ @glGetCombinerStageParameterfvNV := SDL_GL_GetProcAddress('glGetCombinerStageParameterfvNV');
+ if not Assigned(glGetCombinerStageParameterfvNV) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_texgen_emboss: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_texgen_emboss', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_texgen_reflection: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_texgen_reflection', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_texture_compression_vtc: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_texture_compression_vtc', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_texture_env_combine4: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_texture_env_combine4', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_texture_rectangle: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_texture_rectangle', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_texture_shader: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_texture_shader', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_texture_shader2: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_texture_shader2', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_texture_shader3: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_texture_shader3', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_vertex_array_range: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_vertex_array_range', extstring) then
+ begin
+ @glVertexArrayRangeNV := SDL_GL_GetProcAddress('glVertexArrayRangeNV');
+ if not Assigned(glVertexArrayRangeNV) then Exit;
+ @glFlushVertexArrayRangeNV := SDL_GL_GetProcAddress('glFlushVertexArrayRangeNV');
+ if not Assigned(glFlushVertexArrayRangeNV) then Exit;
+ {$IFDEF WINDOWS}
+ @wglAllocateMemoryNV := SDL_GL_GetProcAddress('wglAllocateMemoryNV');
+ if not Assigned(wglAllocateMemoryNV) then Exit;
+ @wglFreeMemoryNV := SDL_GL_GetProcAddress('wglFreeMemoryNV');
+ if not Assigned(wglFreeMemoryNV) then Exit;
+ {$ENDIF}
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_vertex_array_range2: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_vertex_array_range2', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_vertex_program: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_vertex_program', extstring) then
+ begin
+ @glBindProgramNV := SDL_GL_GetProcAddress('glBindProgramNV');
+ if not Assigned(glBindProgramNV) then Exit;
+ @glDeleteProgramsNV := SDL_GL_GetProcAddress('glDeleteProgramsNV');
+ if not Assigned(glDeleteProgramsNV) then Exit;
+ @glExecuteProgramNV := SDL_GL_GetProcAddress('glExecuteProgramNV');
+ if not Assigned(glExecuteProgramNV) then Exit;
+ @glGenProgramsNV := SDL_GL_GetProcAddress('glGenProgramsNV');
+ if not Assigned(glGenProgramsNV) then Exit;
+ @glAreProgramsResidentNV := SDL_GL_GetProcAddress('glAreProgramsResidentNV');
+ if not Assigned(glAreProgramsResidentNV) then Exit;
+ @glRequestResidentProgramsNV := SDL_GL_GetProcAddress('glRequestResidentProgramsNV');
+ if not Assigned(glRequestResidentProgramsNV) then Exit;
+ @glGetProgramParameterfvNV := SDL_GL_GetProcAddress('glGetProgramParameterfvNV');
+ if not Assigned(glGetProgramParameterfvNV) then Exit;
+ @glGetProgramParameterdvNV := SDL_GL_GetProcAddress('glGetProgramParameterdvNV');
+ if not Assigned(glGetProgramParameterdvNV) then Exit;
+ @glGetProgramivNV := SDL_GL_GetProcAddress('glGetProgramivNV');
+ if not Assigned(glGetProgramivNV) then Exit;
+ @glGetProgramStringNV := SDL_GL_GetProcAddress('glGetProgramStringNV');
+ if not Assigned(glGetProgramStringNV) then Exit;
+ @glGetTrackMatrixivNV := SDL_GL_GetProcAddress('glGetTrackMatrixivNV');
+ if not Assigned(glGetTrackMatrixivNV) then Exit;
+ @glGetVertexAttribdvNV := SDL_GL_GetProcAddress('glGetVertexAttribdvNV');
+ if not Assigned(glGetVertexAttribdvNV) then Exit;
+ @glGetVertexAttribfvNV := SDL_GL_GetProcAddress('glGetVertexAttribfvNV');
+ if not Assigned(glGetVertexAttribfvNV) then Exit;
+ @glGetVertexAttribivNV := SDL_GL_GetProcAddress('glGetVertexAttribivNV');
+ if not Assigned(glGetVertexAttribivNV) then Exit;
+ @glGetVertexAttribPointervNV := SDL_GL_GetProcAddress('glGetVertexAttribPointervNV');
+ if not Assigned(glGetVertexAttribPointervNV) then Exit;
+ @glIsProgramNV := SDL_GL_GetProcAddress('glIsProgramNV');
+ if not Assigned(glIsProgramNV) then Exit;
+ @glLoadProgramNV := SDL_GL_GetProcAddress('glLoadProgramNV');
+ if not Assigned(glLoadProgramNV) then Exit;
+ @glProgramParameter4fNV := SDL_GL_GetProcAddress('glProgramParameter4fNV');
+ if not Assigned(glProgramParameter4fNV) then Exit;
+ @glProgramParameter4fvNV := SDL_GL_GetProcAddress('glProgramParameter4fvNV');
+ if not Assigned(glProgramParameter4fvNV) then Exit;
+ @glProgramParameters4dvNV := SDL_GL_GetProcAddress('glProgramParameters4dvNV');
+ if not Assigned(glProgramParameters4dvNV) then Exit;
+ @glProgramParameters4fvNV := SDL_GL_GetProcAddress('glProgramParameters4fvNV');
+ if not Assigned(glProgramParameters4fvNV) then Exit;
+ @glTrackMatrixNV := SDL_GL_GetProcAddress('glTrackMatrixNV');
+ if not Assigned(glTrackMatrixNV) then Exit;
+ @glVertexAttribPointerNV := SDL_GL_GetProcAddress('glVertexAttribPointerNV');
+ if not Assigned(glVertexAttribPointerNV) then Exit;
+ @glVertexAttrib1sNV := SDL_GL_GetProcAddress('glVertexAttrib1sNV');
+ if not Assigned(glVertexAttrib1sNV) then Exit;
+ @glVertexAttrib1fNV := SDL_GL_GetProcAddress('glVertexAttrib1fNV');
+ if not Assigned(glVertexAttrib1fNV) then Exit;
+ @glVertexAttrib1dNV := SDL_GL_GetProcAddress('glVertexAttrib1dNV');
+ if not Assigned(glVertexAttrib1dNV) then Exit;
+ @glVertexAttrib2sNV := SDL_GL_GetProcAddress('glVertexAttrib2sNV');
+ if not Assigned(glVertexAttrib2sNV) then Exit;
+ @glVertexAttrib2fNV := SDL_GL_GetProcAddress('glVertexAttrib2fNV');
+ if not Assigned(glVertexAttrib2fNV) then Exit;
+ @glVertexAttrib2dNV := SDL_GL_GetProcAddress('glVertexAttrib2dNV');
+ if not Assigned(glVertexAttrib2dNV) then Exit;
+ @glVertexAttrib3sNV := SDL_GL_GetProcAddress('glVertexAttrib3sNV');
+ if not Assigned(glVertexAttrib3sNV) then Exit;
+ @glVertexAttrib3fNV := SDL_GL_GetProcAddress('glVertexAttrib3fNV');
+ if not Assigned(glVertexAttrib3fNV) then Exit;
+ @glVertexAttrib3dNV := SDL_GL_GetProcAddress('glVertexAttrib3dNV');
+ if not Assigned(glVertexAttrib3dNV) then Exit;
+ @glVertexAttrib4sNV := SDL_GL_GetProcAddress('glVertexAttrib4sNV');
+ if not Assigned(glVertexAttrib4sNV) then Exit;
+ @glVertexAttrib4fNV := SDL_GL_GetProcAddress('glVertexAttrib4fNV');
+ if not Assigned(glVertexAttrib4fNV) then Exit;
+ @glVertexAttrib4dNV := SDL_GL_GetProcAddress('glVertexAttrib4dNV');
+ if not Assigned(glVertexAttrib4dNV) then Exit;
+ @glVertexAttrib4ubNV := SDL_GL_GetProcAddress('glVertexAttrib4ubNV');
+ if not Assigned(glVertexAttrib4ubNV) then Exit;
+ @glVertexAttrib1svNV := SDL_GL_GetProcAddress('glVertexAttrib1svNV');
+ if not Assigned(glVertexAttrib1svNV) then Exit;
+ @glVertexAttrib1fvNV := SDL_GL_GetProcAddress('glVertexAttrib1fvNV');
+ if not Assigned(glVertexAttrib1fvNV) then Exit;
+ @glVertexAttrib1dvNV := SDL_GL_GetProcAddress('glVertexAttrib1dvNV');
+ if not Assigned(glVertexAttrib1dvNV) then Exit;
+ @glVertexAttrib2svNV := SDL_GL_GetProcAddress('glVertexAttrib2svNV');
+ if not Assigned(glVertexAttrib2svNV) then Exit;
+ @glVertexAttrib2fvNV := SDL_GL_GetProcAddress('glVertexAttrib2fvNV');
+ if not Assigned(glVertexAttrib2fvNV) then Exit;
+ @glVertexAttrib2dvNV := SDL_GL_GetProcAddress('glVertexAttrib2dvNV');
+ if not Assigned(glVertexAttrib2dvNV) then Exit;
+ @glVertexAttrib3svNV := SDL_GL_GetProcAddress('glVertexAttrib3svNV');
+ if not Assigned(glVertexAttrib3svNV) then Exit;
+ @glVertexAttrib3fvNV := SDL_GL_GetProcAddress('glVertexAttrib3fvNV');
+ if not Assigned(glVertexAttrib3fvNV) then Exit;
+ @glVertexAttrib3dvNV := SDL_GL_GetProcAddress('glVertexAttrib3dvNV');
+ if not Assigned(glVertexAttrib3dvNV) then Exit;
+ @glVertexAttrib4svNV := SDL_GL_GetProcAddress('glVertexAttrib4svNV');
+ if not Assigned(glVertexAttrib4svNV) then Exit;
+ @glVertexAttrib4fvNV := SDL_GL_GetProcAddress('glVertexAttrib4fvNV');
+ if not Assigned(glVertexAttrib4fvNV) then Exit;
+ @glVertexAttrib4dvNV := SDL_GL_GetProcAddress('glVertexAttrib4dvNV');
+ if not Assigned(glVertexAttrib4dvNV) then Exit;
+ @glVertexAttrib4ubvNV := SDL_GL_GetProcAddress('glVertexAttrib4ubvNV');
+ if not Assigned(glVertexAttrib4ubvNV) then Exit;
+ @glVertexAttribs1svNV := SDL_GL_GetProcAddress('glVertexAttribs1svNV');
+ if not Assigned(glVertexAttribs1svNV) then Exit;
+ @glVertexAttribs1fvNV := SDL_GL_GetProcAddress('glVertexAttribs1fvNV');
+ if not Assigned(glVertexAttribs1fvNV) then Exit;
+ @glVertexAttribs1dvNV := SDL_GL_GetProcAddress('glVertexAttribs1dvNV');
+ if not Assigned(glVertexAttribs1dvNV) then Exit;
+ @glVertexAttribs2svNV := SDL_GL_GetProcAddress('glVertexAttribs2svNV');
+ if not Assigned(glVertexAttribs2svNV) then Exit;
+ @glVertexAttribs2fvNV := SDL_GL_GetProcAddress('glVertexAttribs2fvNV');
+ if not Assigned(glVertexAttribs2fvNV) then Exit;
+ @glVertexAttribs2dvNV := SDL_GL_GetProcAddress('glVertexAttribs2dvNV');
+ if not Assigned(glVertexAttribs2dvNV) then Exit;
+ @glVertexAttribs3svNV := SDL_GL_GetProcAddress('glVertexAttribs3svNV');
+ if not Assigned(glVertexAttribs3svNV) then Exit;
+ @glVertexAttribs3fvNV := SDL_GL_GetProcAddress('glVertexAttribs3fvNV');
+ if not Assigned(glVertexAttribs3fvNV) then Exit;
+ @glVertexAttribs3dvNV := SDL_GL_GetProcAddress('glVertexAttribs3dvNV');
+ if not Assigned(glVertexAttribs3dvNV) then Exit;
+ @glVertexAttribs4svNV := SDL_GL_GetProcAddress('glVertexAttribs4svNV');
+ if not Assigned(glVertexAttribs4svNV) then Exit;
+ @glVertexAttribs4fvNV := SDL_GL_GetProcAddress('glVertexAttribs4fvNV');
+ if not Assigned(glVertexAttribs4fvNV) then Exit;
+ @glVertexAttribs4dvNV := SDL_GL_GetProcAddress('glVertexAttribs4dvNV');
+ if not Assigned(glVertexAttribs4dvNV) then Exit;
+ @glVertexAttribs4ubvNV := SDL_GL_GetProcAddress('glVertexAttribs4ubvNV');
+ if not Assigned(glVertexAttribs4ubvNV) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_vertex_program1_1: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_vertex_program1_1', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_element_array: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_element_array', extstring) then
+ begin
+ @glElementPointerATI := SDL_GL_GetProcAddress('glElementPointerATI');
+ if not Assigned(glElementPointerATI) then Exit;
+ @glDrawElementArrayATI := SDL_GL_GetProcAddress('glDrawElementArrayATI');
+ if not Assigned(glDrawElementArrayATI) then Exit;
+ @glDrawRangeElementArrayATI := SDL_GL_GetProcAddress('glDrawRangeElementArrayATI');
+ if not Assigned(glDrawRangeElementArrayATI) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_envmap_bumpmap: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_envmap_bumpmap', extstring) then
+ begin
+ @glTexBumpParameterivATI := SDL_GL_GetProcAddress('glTexBumpParameterivATI');
+ if not Assigned(glTexBumpParameterivATI) then Exit;
+ @glTexBumpParameterfvATI := SDL_GL_GetProcAddress('glTexBumpParameterfvATI');
+ if not Assigned(glTexBumpParameterfvATI) then Exit;
+ @glGetTexBumpParameterivATI := SDL_GL_GetProcAddress('glGetTexBumpParameterivATI');
+ if not Assigned(glGetTexBumpParameterivATI) then Exit;
+ @glGetTexBumpParameterfvATI := SDL_GL_GetProcAddress('glGetTexBumpParameterfvATI');
+ if not Assigned(glGetTexBumpParameterfvATI) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_fragment_shader: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_fragment_shader', extstring) then
+ begin
+ @glGenFragmentShadersATI := SDL_GL_GetProcAddress('glGenFragmentShadersATI');
+ if not Assigned(glGenFragmentShadersATI) then Exit;
+ @glBindFragmentShaderATI := SDL_GL_GetProcAddress('glBindFragmentShaderATI');
+ if not Assigned(glBindFragmentShaderATI) then Exit;
+ @glDeleteFragmentShaderATI := SDL_GL_GetProcAddress('glDeleteFragmentShaderATI');
+ if not Assigned(glDeleteFragmentShaderATI) then Exit;
+ @glBeginFragmentShaderATI := SDL_GL_GetProcAddress('glBeginFragmentShaderATI');
+ if not Assigned(glBeginFragmentShaderATI) then Exit;
+ @glEndFragmentShaderATI := SDL_GL_GetProcAddress('glEndFragmentShaderATI');
+ if not Assigned(glEndFragmentShaderATI) then Exit;
+ @glPassTexCoordATI := SDL_GL_GetProcAddress('glPassTexCoordATI');
+ if not Assigned(glPassTexCoordATI) then Exit;
+ @glSampleMapATI := SDL_GL_GetProcAddress('glSampleMapATI');
+ if not Assigned(glSampleMapATI) then Exit;
+ @glColorFragmentOp1ATI := SDL_GL_GetProcAddress('glColorFragmentOp1ATI');
+ if not Assigned(glColorFragmentOp1ATI) then Exit;
+ @glColorFragmentOp2ATI := SDL_GL_GetProcAddress('glColorFragmentOp2ATI');
+ if not Assigned(glColorFragmentOp2ATI) then Exit;
+ @glColorFragmentOp3ATI := SDL_GL_GetProcAddress('glColorFragmentOp3ATI');
+ if not Assigned(glColorFragmentOp3ATI) then Exit;
+ @glAlphaFragmentOp1ATI := SDL_GL_GetProcAddress('glAlphaFragmentOp1ATI');
+ if not Assigned(glAlphaFragmentOp1ATI) then Exit;
+ @glAlphaFragmentOp2ATI := SDL_GL_GetProcAddress('glAlphaFragmentOp2ATI');
+ if not Assigned(glAlphaFragmentOp2ATI) then Exit;
+ @glAlphaFragmentOp3ATI := SDL_GL_GetProcAddress('glAlphaFragmentOp3ATI');
+ if not Assigned(glAlphaFragmentOp3ATI) then Exit;
+ @glSetFragmentShaderConstantATI := SDL_GL_GetProcAddress('glSetFragmentShaderConstantATI');
+ if not Assigned(glSetFragmentShaderConstantATI) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_pn_triangles: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_pn_triangles', extstring) then
+ begin
+ @glPNTrianglesiATI := SDL_GL_GetProcAddress('glPNTrianglesiATI');
+ if not Assigned(glPNTrianglesiATI) then Exit;
+ @glPNTrianglesfATI := SDL_GL_GetProcAddress('glPNTrianglesfATI');
+ if not Assigned(glPNTrianglesfATI) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_texture_mirror_once: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_texture_mirror_once', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_vertex_array_object: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_vertex_array_object', extstring) then
+ begin
+ @glNewObjectBufferATI := SDL_GL_GetProcAddress('glNewObjectBufferATI');
+ if not Assigned(glNewObjectBufferATI) then Exit;
+ @glIsObjectBufferATI := SDL_GL_GetProcAddress('glIsObjectBufferATI');
+ if not Assigned(glIsObjectBufferATI) then Exit;
+ @glUpdateObjectBufferATI := SDL_GL_GetProcAddress('glUpdateObjectBufferATI');
+ if not Assigned(glUpdateObjectBufferATI) then Exit;
+ @glGetObjectBufferfvATI := SDL_GL_GetProcAddress('glGetObjectBufferfvATI');
+ if not Assigned(glGetObjectBufferfvATI) then Exit;
+ @glGetObjectBufferivATI := SDL_GL_GetProcAddress('glGetObjectBufferivATI');
+ if not Assigned(glGetObjectBufferivATI) then Exit;
+ @glDeleteObjectBufferATI := SDL_GL_GetProcAddress('glDeleteObjectBufferATI');
+ if not Assigned(glDeleteObjectBufferATI) then Exit;
+ @glArrayObjectATI := SDL_GL_GetProcAddress('glArrayObjectATI');
+ if not Assigned(glArrayObjectATI) then Exit;
+ @glGetArrayObjectfvATI := SDL_GL_GetProcAddress('glGetArrayObjectfvATI');
+ if not Assigned(glGetArrayObjectfvATI) then Exit;
+ @glGetArrayObjectivATI := SDL_GL_GetProcAddress('glGetArrayObjectivATI');
+ if not Assigned(glGetArrayObjectivATI) then Exit;
+ @glVariantArrayObjectATI := SDL_GL_GetProcAddress('glVariantArrayObjectATI');
+ if not Assigned(glVariantArrayObjectATI) then Exit;
+ @glGetVariantArrayObjectfvATI := SDL_GL_GetProcAddress('glGetVariantArrayObjectfvATI');
+ if not Assigned(glGetVariantArrayObjectfvATI) then Exit;
+ @glGetVariantArrayObjectivATI := SDL_GL_GetProcAddress('glGetVariantArrayObjectivATI');
+ if not Assigned(glGetVariantArrayObjectivATI) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_vertex_streams: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_vertex_streams', extstring) then
+ begin
+ @glVertexStream1s := SDL_GL_GetProcAddress('glVertexStream1s');
+ if not Assigned(glVertexStream1s) then Exit;
+ @glVertexStream1i := SDL_GL_GetProcAddress('glVertexStream1i');
+ if not Assigned(glVertexStream1i) then Exit;
+ @glVertexStream1f := SDL_GL_GetProcAddress('glVertexStream1f');
+ if not Assigned(glVertexStream1f) then Exit;
+ @glVertexStream1d := SDL_GL_GetProcAddress('glVertexStream1d');
+ if not Assigned(glVertexStream1d) then Exit;
+ @glVertexStream1sv := SDL_GL_GetProcAddress('glVertexStream1sv');
+ if not Assigned(glVertexStream1sv) then Exit;
+ @glVertexStream1iv := SDL_GL_GetProcAddress('glVertexStream1iv');
+ if not Assigned(glVertexStream1iv) then Exit;
+ @glVertexStream1fv := SDL_GL_GetProcAddress('glVertexStream1fv');
+ if not Assigned(glVertexStream1fv) then Exit;
+ @glVertexStream1dv := SDL_GL_GetProcAddress('glVertexStream1dv');
+ if not Assigned(glVertexStream1dv) then Exit;
+ @glVertexStream2s := SDL_GL_GetProcAddress('glVertexStream2s');
+ if not Assigned(glVertexStream2s) then Exit;
+ @glVertexStream2i := SDL_GL_GetProcAddress('glVertexStream2i');
+ if not Assigned(glVertexStream2i) then Exit;
+ @glVertexStream2f := SDL_GL_GetProcAddress('glVertexStream2f');
+ if not Assigned(glVertexStream2f) then Exit;
+ @glVertexStream2d := SDL_GL_GetProcAddress('glVertexStream2d');
+ if not Assigned(glVertexStream2d) then Exit;
+ @glVertexStream2sv := SDL_GL_GetProcAddress('glVertexStream2sv');
+ if not Assigned(glVertexStream2sv) then Exit;
+ @glVertexStream2iv := SDL_GL_GetProcAddress('glVertexStream2iv');
+ if not Assigned(glVertexStream2iv) then Exit;
+ @glVertexStream2fv := SDL_GL_GetProcAddress('glVertexStream2fv');
+ if not Assigned(glVertexStream2fv) then Exit;
+ @glVertexStream2dv := SDL_GL_GetProcAddress('glVertexStream2dv');
+ if not Assigned(glVertexStream2dv) then Exit;
+ @glVertexStream3s := SDL_GL_GetProcAddress('glVertexStream3s');
+ if not Assigned(glVertexStream3s) then Exit;
+ @glVertexStream3i := SDL_GL_GetProcAddress('glVertexStream3i');
+ if not Assigned(glVertexStream3i) then Exit;
+ @glVertexStream3f := SDL_GL_GetProcAddress('glVertexStream3f');
+ if not Assigned(glVertexStream3f) then Exit;
+ @glVertexStream3d := SDL_GL_GetProcAddress('glVertexStream3d');
+ if not Assigned(glVertexStream3d) then Exit;
+ @glVertexStream3sv := SDL_GL_GetProcAddress('glVertexStream3sv');
+ if not Assigned(glVertexStream3sv) then Exit;
+ @glVertexStream3iv := SDL_GL_GetProcAddress('glVertexStream3iv');
+ if not Assigned(glVertexStream3iv) then Exit;
+ @glVertexStream3fv := SDL_GL_GetProcAddress('glVertexStream3fv');
+ if not Assigned(glVertexStream3fv) then Exit;
+ @glVertexStream3dv := SDL_GL_GetProcAddress('glVertexStream3dv');
+ if not Assigned(glVertexStream3dv) then Exit;
+ @glVertexStream4s := SDL_GL_GetProcAddress('glVertexStream4s');
+ if not Assigned(glVertexStream4s) then Exit;
+ @glVertexStream4i := SDL_GL_GetProcAddress('glVertexStream4i');
+ if not Assigned(glVertexStream4i) then Exit;
+ @glVertexStream4f := SDL_GL_GetProcAddress('glVertexStream4f');
+ if not Assigned(glVertexStream4f) then Exit;
+ @glVertexStream4d := SDL_GL_GetProcAddress('glVertexStream4d');
+ if not Assigned(glVertexStream4d) then Exit;
+ @glVertexStream4sv := SDL_GL_GetProcAddress('glVertexStream4sv');
+ if not Assigned(glVertexStream4sv) then Exit;
+ @glVertexStream4iv := SDL_GL_GetProcAddress('glVertexStream4iv');
+ if not Assigned(glVertexStream4iv) then Exit;
+ @glVertexStream4fv := SDL_GL_GetProcAddress('glVertexStream4fv');
+ if not Assigned(glVertexStream4fv) then Exit;
+ @glVertexStream4dv := SDL_GL_GetProcAddress('glVertexStream4dv');
+ if not Assigned(glVertexStream4dv) then Exit;
+ @glNormalStream3b := SDL_GL_GetProcAddress('glNormalStream3b');
+ if not Assigned(glNormalStream3b) then Exit;
+ @glNormalStream3s := SDL_GL_GetProcAddress('glNormalStream3s');
+ if not Assigned(glNormalStream3s) then Exit;
+ @glNormalStream3i := SDL_GL_GetProcAddress('glNormalStream3i');
+ if not Assigned(glNormalStream3i) then Exit;
+ @glNormalStream3f := SDL_GL_GetProcAddress('glNormalStream3f');
+ if not Assigned(glNormalStream3f) then Exit;
+ @glNormalStream3d := SDL_GL_GetProcAddress('glNormalStream3d');
+ if not Assigned(glNormalStream3d) then Exit;
+ @glNormalStream3bv := SDL_GL_GetProcAddress('glNormalStream3bv');
+ if not Assigned(glNormalStream3bv) then Exit;
+ @glNormalStream3sv := SDL_GL_GetProcAddress('glNormalStream3sv');
+ if not Assigned(glNormalStream3sv) then Exit;
+ @glNormalStream3iv := SDL_GL_GetProcAddress('glNormalStream3iv');
+ if not Assigned(glNormalStream3iv) then Exit;
+ @glNormalStream3fv := SDL_GL_GetProcAddress('glNormalStream3fv');
+ if not Assigned(glNormalStream3fv) then Exit;
+ @glNormalStream3dv := SDL_GL_GetProcAddress('glNormalStream3dv');
+ if not Assigned(glNormalStream3dv) then Exit;
+ @glClientActiveVertexStream := SDL_GL_GetProcAddress('glClientActiveVertexStream');
+ if not Assigned(glClientActiveVertexStream) then Exit;
+ @glVertexBlendEnvi := SDL_GL_GetProcAddress('glVertexBlendEnvi');
+ if not Assigned(glVertexBlendEnvi) then Exit;
+ @glVertexBlendEnvf := SDL_GL_GetProcAddress('glVertexBlendEnvf');
+ if not Assigned(glVertexBlendEnvf) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+{$IFDEF WINDOWS}
+function Load_WGL_I3D_image_buffer: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_I3D_image_buffer', extstring) then
+ begin
+ @wglCreateImageBufferI3D := SDL_GL_GetProcAddress('wglCreateImageBufferI3D');
+ if not Assigned(wglCreateImageBufferI3D) then Exit;
+ @wglDestroyImageBufferI3D := SDL_GL_GetProcAddress('wglDestroyImageBufferI3D');
+ if not Assigned(wglDestroyImageBufferI3D) then Exit;
+ @wglAssociateImageBufferEventsI3D := SDL_GL_GetProcAddress('wglAssociateImageBufferEventsI3D');
+ if not Assigned(wglAssociateImageBufferEventsI3D) then Exit;
+ @wglReleaseImageBufferEventsI3D := SDL_GL_GetProcAddress('wglReleaseImageBufferEventsI3D');
+ if not Assigned(wglReleaseImageBufferEventsI3D) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_I3D_swap_frame_lock: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_I3D_swap_frame_lock', extstring) then
+ begin
+ @wglEnableFrameLockI3D := SDL_GL_GetProcAddress('wglEnableFrameLockI3D');
+ if not Assigned(wglEnableFrameLockI3D) then Exit;
+ @wglDisableFrameLockI3D := SDL_GL_GetProcAddress('wglDisableFrameLockI3D');
+ if not Assigned(wglDisableFrameLockI3D) then Exit;
+ @wglIsEnabledFrameLockI3D := SDL_GL_GetProcAddress('wglIsEnabledFrameLockI3D');
+ if not Assigned(wglIsEnabledFrameLockI3D) then Exit;
+ @wglQueryFrameLockMasterI3D := SDL_GL_GetProcAddress('wglQueryFrameLockMasterI3D');
+ if not Assigned(wglQueryFrameLockMasterI3D) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_I3D_swap_frame_usage: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_I3D_swap_frame_usage', extstring) then
+ begin
+ @wglGetFrameUsageI3D := SDL_GL_GetProcAddress('wglGetFrameUsageI3D');
+ if not Assigned(wglGetFrameUsageI3D) then Exit;
+ @wglBeginFrameTrackingI3D := SDL_GL_GetProcAddress('wglBeginFrameTrackingI3D');
+ if not Assigned(wglBeginFrameTrackingI3D) then Exit;
+ @wglEndFrameTrackingI3D := SDL_GL_GetProcAddress('wglEndFrameTrackingI3D');
+ if not Assigned(wglEndFrameTrackingI3D) then Exit;
+ @wglQueryFrameTrackingI3D := SDL_GL_GetProcAddress('wglQueryFrameTrackingI3D');
+ if not Assigned(wglQueryFrameTrackingI3D) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+{$ENDIF}
+
+function Load_GL_3DFX_texture_compression_FXT1: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_3DFX_texture_compression_FXT1', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_IBM_cull_vertex: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_IBM_cull_vertex', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_IBM_multimode_draw_arrays: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_IBM_multimode_draw_arrays', extstring) then
+ begin
+ @glMultiModeDrawArraysIBM := SDL_GL_GetProcAddress('glMultiModeDrawArraysIBM');
+ if not Assigned(glMultiModeDrawArraysIBM) then Exit;
+ @glMultiModeDrawElementsIBM := SDL_GL_GetProcAddress('glMultiModeDrawElementsIBM');
+ if not Assigned(glMultiModeDrawElementsIBM) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_IBM_raster_pos_clip: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_IBM_raster_pos_clip', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_IBM_texture_mirrored_repeat: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_IBM_texture_mirrored_repeat', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_IBM_vertex_array_lists: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_IBM_vertex_array_lists', extstring) then
+ begin
+ @glColorPointerListIBM := SDL_GL_GetProcAddress('glColorPointerListIBM');
+ if not Assigned(glColorPointerListIBM) then Exit;
+ @glSecondaryColorPointerListIBM := SDL_GL_GetProcAddress('glSecondaryColorPointerListIBM');
+ if not Assigned(glSecondaryColorPointerListIBM) then Exit;
+ @glEdgeFlagPointerListIBM := SDL_GL_GetProcAddress('glEdgeFlagPointerListIBM');
+ if not Assigned(glEdgeFlagPointerListIBM) then Exit;
+ @glFogCoordPointerListIBM := SDL_GL_GetProcAddress('glFogCoordPointerListIBM');
+ if not Assigned(glFogCoordPointerListIBM) then Exit;
+ @glNormalPointerListIBM := SDL_GL_GetProcAddress('glNormalPointerListIBM');
+ if not Assigned(glNormalPointerListIBM) then Exit;
+ @glTexCoordPointerListIBM := SDL_GL_GetProcAddress('glTexCoordPointerListIBM');
+ if not Assigned(glTexCoordPointerListIBM) then Exit;
+ @glVertexPointerListIBM := SDL_GL_GetProcAddress('glVertexPointerListIBM');
+ if not Assigned(glVertexPointerListIBM) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_MESA_resize_buffers: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_MESA_resize_buffers', extstring) then
+ begin
+ @glResizeBuffersMESA := SDL_GL_GetProcAddress('glResizeBuffersMESA');
+ if not Assigned(glResizeBuffersMESA) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_MESA_window_pos: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_MESA_window_pos', extstring) then
+ begin
+ @glWindowPos2dMESA := SDL_GL_GetProcAddress('glWindowPos2dMESA');
+ if not Assigned(glWindowPos2dMESA) then Exit;
+ @glWindowPos2fMESA := SDL_GL_GetProcAddress('glWindowPos2fMESA');
+ if not Assigned(glWindowPos2fMESA) then Exit;
+ @glWindowPos2iMESA := SDL_GL_GetProcAddress('glWindowPos2iMESA');
+ if not Assigned(glWindowPos2iMESA) then Exit;
+ @glWindowPos2sMESA := SDL_GL_GetProcAddress('glWindowPos2sMESA');
+ if not Assigned(glWindowPos2sMESA) then Exit;
+ @glWindowPos2ivMESA := SDL_GL_GetProcAddress('glWindowPos2ivMESA');
+ if not Assigned(glWindowPos2ivMESA) then Exit;
+ @glWindowPos2svMESA := SDL_GL_GetProcAddress('glWindowPos2svMESA');
+ if not Assigned(glWindowPos2svMESA) then Exit;
+ @glWindowPos2fvMESA := SDL_GL_GetProcAddress('glWindowPos2fvMESA');
+ if not Assigned(glWindowPos2fvMESA) then Exit;
+ @glWindowPos2dvMESA := SDL_GL_GetProcAddress('glWindowPos2dvMESA');
+ if not Assigned(glWindowPos2dvMESA) then Exit;
+ @glWindowPos3iMESA := SDL_GL_GetProcAddress('glWindowPos3iMESA');
+ if not Assigned(glWindowPos3iMESA) then Exit;
+ @glWindowPos3sMESA := SDL_GL_GetProcAddress('glWindowPos3sMESA');
+ if not Assigned(glWindowPos3sMESA) then Exit;
+ @glWindowPos3fMESA := SDL_GL_GetProcAddress('glWindowPos3fMESA');
+ if not Assigned(glWindowPos3fMESA) then Exit;
+ @glWindowPos3dMESA := SDL_GL_GetProcAddress('glWindowPos3dMESA');
+ if not Assigned(glWindowPos3dMESA) then Exit;
+ @glWindowPos3ivMESA := SDL_GL_GetProcAddress('glWindowPos3ivMESA');
+ if not Assigned(glWindowPos3ivMESA) then Exit;
+ @glWindowPos3svMESA := SDL_GL_GetProcAddress('glWindowPos3svMESA');
+ if not Assigned(glWindowPos3svMESA) then Exit;
+ @glWindowPos3fvMESA := SDL_GL_GetProcAddress('glWindowPos3fvMESA');
+ if not Assigned(glWindowPos3fvMESA) then Exit;
+ @glWindowPos3dvMESA := SDL_GL_GetProcAddress('glWindowPos3dvMESA');
+ if not Assigned(glWindowPos3dvMESA) then Exit;
+ @glWindowPos4iMESA := SDL_GL_GetProcAddress('glWindowPos4iMESA');
+ if not Assigned(glWindowPos4iMESA) then Exit;
+ @glWindowPos4sMESA := SDL_GL_GetProcAddress('glWindowPos4sMESA');
+ if not Assigned(glWindowPos4sMESA) then Exit;
+ @glWindowPos4fMESA := SDL_GL_GetProcAddress('glWindowPos4fMESA');
+ if not Assigned(glWindowPos4fMESA) then Exit;
+ @glWindowPos4dMESA := SDL_GL_GetProcAddress('glWindowPos4dMESA');
+ if not Assigned(glWindowPos4dMESA) then Exit;
+ @glWindowPos4ivMESA := SDL_GL_GetProcAddress('glWindowPos4ivMESA');
+ if not Assigned(glWindowPos4ivMESA) then Exit;
+ @glWindowPos4svMESA := SDL_GL_GetProcAddress('glWindowPos4svMESA');
+ if not Assigned(glWindowPos4svMESA) then Exit;
+ @glWindowPos4fvMESA := SDL_GL_GetProcAddress('glWindowPos4fvMESA');
+ if not Assigned(glWindowPos4fvMESA) then Exit;
+ @glWindowPos4dvMESA := SDL_GL_GetProcAddress('glWindowPos4dvMESA');
+ if not Assigned(glWindowPos4dvMESA) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_OML_interlace: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_OML_interlace', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_OML_resample: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_OML_resample', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_OML_subsample: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_OML_subsample', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGIS_generate_mipmap: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGIS_generate_mipmap', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGIS_multisample: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGIS_multisample', extstring) then
+ begin
+ @glSampleMaskSGIS := SDL_GL_GetProcAddress('glSampleMaskSGIS');
+ if not Assigned(glSampleMaskSGIS) then Exit;
+ @glSamplePatternSGIS := SDL_GL_GetProcAddress('glSamplePatternSGIS');
+ if not Assigned(glSamplePatternSGIS) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGIS_pixel_texture: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGIS_pixel_texture', extstring) then
+ begin
+ @glPixelTexGenParameteriSGIS := SDL_GL_GetProcAddress('glPixelTexGenParameteriSGIS');
+ if not Assigned(glPixelTexGenParameteriSGIS) then Exit;
+ @glPixelTexGenParameterfSGIS := SDL_GL_GetProcAddress('glPixelTexGenParameterfSGIS');
+ if not Assigned(glPixelTexGenParameterfSGIS) then Exit;
+ @glGetPixelTexGenParameterivSGIS := SDL_GL_GetProcAddress('glGetPixelTexGenParameterivSGIS');
+ if not Assigned(glGetPixelTexGenParameterivSGIS) then Exit;
+ @glGetPixelTexGenParameterfvSGIS := SDL_GL_GetProcAddress('glGetPixelTexGenParameterfvSGIS');
+ if not Assigned(glGetPixelTexGenParameterfvSGIS) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGIS_texture_border_clamp: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGIS_texture_border_clamp', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGIS_texture_color_mask: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGIS_texture_color_mask', extstring) then
+ begin
+ @glTextureColorMaskSGIS := SDL_GL_GetProcAddress('glTextureColorMaskSGIS');
+ if not Assigned(glTextureColorMaskSGIS) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGIS_texture_edge_clamp: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGIS_texture_edge_clamp', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGIS_texture_lod: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGIS_texture_lod', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGIS_depth_texture: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGIS_depth_texture', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGIX_fog_offset: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGIX_fog_offset', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGIX_interlace: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGIX_interlace', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGIX_shadow_ambient: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGIX_shadow_ambient', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGI_color_matrix: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGI_color_matrix', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGI_color_table: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGI_color_table', extstring) then
+ begin
+ @glColorTableSGI := SDL_GL_GetProcAddress('glColorTableSGI');
+ if not Assigned(glColorTableSGI) then Exit;
+ @glCopyColorTableSGI := SDL_GL_GetProcAddress('glCopyColorTableSGI');
+ if not Assigned(glCopyColorTableSGI) then Exit;
+ @glColorTableParameterivSGI := SDL_GL_GetProcAddress('glColorTableParameterivSGI');
+ if not Assigned(glColorTableParameterivSGI) then Exit;
+ @glColorTableParameterfvSGI := SDL_GL_GetProcAddress('glColorTableParameterfvSGI');
+ if not Assigned(glColorTableParameterfvSGI) then Exit;
+ @glGetColorTableSGI := SDL_GL_GetProcAddress('glGetColorTableSGI');
+ if not Assigned(glGetColorTableSGI) then Exit;
+ @glGetColorTableParameterivSGI := SDL_GL_GetProcAddress('glGetColorTableParameterivSGI');
+ if not Assigned(glGetColorTableParameterivSGI) then Exit;
+ @glGetColorTableParameterfvSGI := SDL_GL_GetProcAddress('glGetColorTableParameterfvSGI');
+ if not Assigned(glGetColorTableParameterfvSGI) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SGI_texture_color_table: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SGI_texture_color_table', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_SUN_vertex: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_SUN_vertex', extstring) then
+ begin
+ @glColor4ubVertex2fSUN := SDL_GL_GetProcAddress('glColor4ubVertex2fSUN');
+ if not Assigned(glColor4ubVertex2fSUN) then Exit;
+ @glColor4ubVertex2fvSUN := SDL_GL_GetProcAddress('glColor4ubVertex2fvSUN');
+ if not Assigned(glColor4ubVertex2fvSUN) then Exit;
+ @glColor4ubVertex3fSUN := SDL_GL_GetProcAddress('glColor4ubVertex3fSUN');
+ if not Assigned(glColor4ubVertex3fSUN) then Exit;
+ @glColor4ubVertex3fvSUN := SDL_GL_GetProcAddress('glColor4ubVertex3fvSUN');
+ if not Assigned(glColor4ubVertex3fvSUN) then Exit;
+ @glColor3fVertex3fSUN := SDL_GL_GetProcAddress('glColor3fVertex3fSUN');
+ if not Assigned(glColor3fVertex3fSUN) then Exit;
+ @glColor3fVertex3fvSUN := SDL_GL_GetProcAddress('glColor3fVertex3fvSUN');
+ if not Assigned(glColor3fVertex3fvSUN) then Exit;
+ @glNormal3fVertex3fSUN := SDL_GL_GetProcAddress('glNormal3fVertex3fSUN');
+ if not Assigned(glNormal3fVertex3fSUN) then Exit;
+ @glNormal3fVertex3fvSUN := SDL_GL_GetProcAddress('glNormal3fVertex3fvSUN');
+ if not Assigned(glNormal3fVertex3fvSUN) then Exit;
+ @glColor4fNormal3fVertex3fSUN := SDL_GL_GetProcAddress('glColor4fNormal3fVertex3fSUN');
+ if not Assigned(glColor4fNormal3fVertex3fSUN) then Exit;
+ @glColor4fNormal3fVertex3fvSUN := SDL_GL_GetProcAddress('glColor4fNormal3fVertex3fvSUN');
+ if not Assigned(glColor4fNormal3fVertex3fvSUN) then Exit;
+ @glTexCoord2fVertex3fSUN := SDL_GL_GetProcAddress('glTexCoord2fVertex3fSUN');
+ if not Assigned(glTexCoord2fVertex3fSUN) then Exit;
+ @glTexCoord2fVertex3fvSUN := SDL_GL_GetProcAddress('glTexCoord2fVertex3fvSUN');
+ if not Assigned(glTexCoord2fVertex3fvSUN) then Exit;
+ @glTexCoord4fVertex4fSUN := SDL_GL_GetProcAddress('glTexCoord4fVertex4fSUN');
+ if not Assigned(glTexCoord4fVertex4fSUN) then Exit;
+ @glTexCoord4fVertex4fvSUN := SDL_GL_GetProcAddress('glTexCoord4fVertex4fvSUN');
+ if not Assigned(glTexCoord4fVertex4fvSUN) then Exit;
+ @glTexCoord2fColor4ubVertex3fSUN := SDL_GL_GetProcAddress('glTexCoord2fColor4ubVertex3fSUN');
+ if not Assigned(glTexCoord2fColor4ubVertex3fSUN) then Exit;
+ @glTexCoord2fColor4ubVertex3fvSUN := SDL_GL_GetProcAddress('glTexCoord2fColor4ubVertex3fvSUN');
+ if not Assigned(glTexCoord2fColor4ubVertex3fvSUN) then Exit;
+ @glTexCoord2fColor3fVertex3fSUN := SDL_GL_GetProcAddress('glTexCoord2fColor3fVertex3fSUN');
+ if not Assigned(glTexCoord2fColor3fVertex3fSUN) then Exit;
+ @glTexCoord2fColor3fVertex3fvSUN := SDL_GL_GetProcAddress('glTexCoord2fColor3fVertex3fvSUN');
+ if not Assigned(glTexCoord2fColor3fVertex3fvSUN) then Exit;
+ @glTexCoord2fNormal3fVertex3fSUN := SDL_GL_GetProcAddress('glTexCoord2fNormal3fVertex3fSUN');
+ if not Assigned(glTexCoord2fNormal3fVertex3fSUN) then Exit;
+ @glTexCoord2fNormal3fVertex3fvSUN := SDL_GL_GetProcAddress('glTexCoord2fNormal3fVertex3fvSUN');
+ if not Assigned(glTexCoord2fNormal3fVertex3fvSUN) then Exit;
+ @glTexCoord2fColor4fNormal3fVertex3fSUN := SDL_GL_GetProcAddress('glTexCoord2fColor4fNormal3fVertex3fSUN');
+ if not Assigned(glTexCoord2fColor4fNormal3fVertex3fSUN) then Exit;
+ @glTexCoord2fColor4fNormal3fVertex3fvSUN := SDL_GL_GetProcAddress('glTexCoord2fColor4fNormal3fVertex3fvSUN');
+ if not Assigned(glTexCoord2fColor4fNormal3fVertex3fvSUN) then Exit;
+ @glTexCoord4fColor4fNormal3fVertex4fSUN := SDL_GL_GetProcAddress('glTexCoord4fColor4fNormal3fVertex4fSUN');
+ if not Assigned(glTexCoord4fColor4fNormal3fVertex4fSUN) then Exit;
+ @glTexCoord4fColor4fNormal3fVertex4fvSUN := SDL_GL_GetProcAddress('glTexCoord4fColor4fNormal3fVertex4fvSUN');
+ if not Assigned(glTexCoord4fColor4fNormal3fVertex4fvSUN) then Exit;
+ @glReplacementCodeuiVertex3fSUN := SDL_GL_GetProcAddress('glReplacementCodeuiVertex3fSUN');
+ if not Assigned(glReplacementCodeuiVertex3fSUN) then Exit;
+ @glReplacementCodeuiVertex3fvSUN := SDL_GL_GetProcAddress('glReplacementCodeuiVertex3fvSUN');
+ if not Assigned(glReplacementCodeuiVertex3fvSUN) then Exit;
+ @glReplacementCodeuiColor4ubVertex3fSUN := SDL_GL_GetProcAddress('glReplacementCodeuiColor4ubVertex3fSUN');
+ if not Assigned(glReplacementCodeuiColor4ubVertex3fSUN) then Exit;
+ @glReplacementCodeuiColor4ubVertex3fvSUN := SDL_GL_GetProcAddress('glReplacementCodeuiColor4ubVertex3fvSUN');
+ if not Assigned(glReplacementCodeuiColor4ubVertex3fvSUN) then Exit;
+ @glReplacementCodeuiColor3fVertex3fSUN := SDL_GL_GetProcAddress('glReplacementCodeuiColor3fVertex3fSUN');
+ if not Assigned(glReplacementCodeuiColor3fVertex3fSUN) then Exit;
+ @glReplacementCodeuiColor3fVertex3fvSUN := SDL_GL_GetProcAddress('glReplacementCodeuiColor3fVertex3fvSUN');
+ if not Assigned(glReplacementCodeuiColor3fVertex3fvSUN) then Exit;
+ @glReplacementCodeuiNormal3fVertex3fSUN := SDL_GL_GetProcAddress('glReplacementCodeuiNormal3fVertex3fSUN');
+ if not Assigned(glReplacementCodeuiNormal3fVertex3fSUN) then Exit;
+ @glReplacementCodeuiNormal3fVertex3fvSUN := SDL_GL_GetProcAddress('glReplacementCodeuiNormal3fVertex3fvSUN');
+ if not Assigned(glReplacementCodeuiNormal3fVertex3fvSUN) then Exit;
+ @glReplacementCodeuiColor4fNormal3fVertex3fSUN := SDL_GL_GetProcAddress('glReplacementCodeuiColor4fNormal3fVertex3fSUN');
+ if not Assigned(glReplacementCodeuiColor4fNormal3fVertex3fSUN) then Exit;
+ @glReplacementCodeuiColor4fNormal3fVertex3fvSUN := SDL_GL_GetProcAddress('glReplacementCodeuiColor4fNormal3fVertex3fvSUN');
+ if not Assigned(glReplacementCodeuiColor4fNormal3fVertex3fvSUN) then Exit;
+ @glReplacementCodeuiTexCoord2fVertex3fSUN := SDL_GL_GetProcAddress('glReplacementCodeuiTexCoord2fVertex3fSUN');
+ if not Assigned(glReplacementCodeuiTexCoord2fVertex3fSUN) then Exit;
+ @glReplacementCodeuiTexCoord2fVertex3fvSUN := SDL_GL_GetProcAddress('glReplacementCodeuiTexCoord2fVertex3fvSUN');
+ if not Assigned(glReplacementCodeuiTexCoord2fVertex3fvSUN) then Exit;
+ @glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN := SDL_GL_GetProcAddress('glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN');
+ if not Assigned(glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN) then Exit;
+ @glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN := SDL_GL_GetProcAddress('glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN');
+ if not Assigned(glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN) then Exit;
+ @glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN := SDL_GL_GetProcAddress('glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN');
+ if not Assigned(glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN) then Exit;
+ @glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN := SDL_GL_GetProcAddress('glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN');
+ if not Assigned(glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_fragment_program: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_fragment_program', extstring) then
+ begin
+ @glProgramStringARB := SDL_GL_GetProcAddress('glProgramStringARB');
+ if not Assigned(glProgramStringARB) then Exit;
+ @glBindProgramARB := SDL_GL_GetProcAddress('glBindProgramARB');
+ if not Assigned(glBindProgramARB) then Exit;
+ @glDeleteProgramsARB := SDL_GL_GetProcAddress('glDeleteProgramsARB');
+ if not Assigned(glDeleteProgramsARB) then Exit;
+ @glGenProgramsARB := SDL_GL_GetProcAddress('glGenProgramsARB');
+ if not Assigned(glGenProgramsARB) then Exit;
+ @glProgramEnvParameter4dARB := SDL_GL_GetProcAddress('glProgramEnvParameter4dARB');
+ if not Assigned(glProgramEnvParameter4dARB) then Exit;
+ @glProgramEnvParameter4dvARB := SDL_GL_GetProcAddress('glProgramEnvParameter4dvARB');
+ if not Assigned(glProgramEnvParameter4dvARB) then Exit;
+ @glProgramEnvParameter4fARB := SDL_GL_GetProcAddress('glProgramEnvParameter4fARB');
+ if not Assigned(glProgramEnvParameter4fARB) then Exit;
+ @glProgramEnvParameter4fvARB := SDL_GL_GetProcAddress('glProgramEnvParameter4fvARB');
+ if not Assigned(glProgramEnvParameter4fvARB) then Exit;
+ @glProgramLocalParameter4dARB := SDL_GL_GetProcAddress('glProgramLocalParameter4dARB');
+ if not Assigned(glProgramLocalParameter4dARB) then Exit;
+ @glProgramLocalParameter4dvARB := SDL_GL_GetProcAddress('glProgramLocalParameter4dvARB');
+ if not Assigned(glProgramLocalParameter4dvARB) then Exit;
+ @glProgramLocalParameter4fARB := SDL_GL_GetProcAddress('glProgramLocalParameter4fARB');
+ if not Assigned(glProgramLocalParameter4fARB) then Exit;
+ @glProgramLocalParameter4fvARB := SDL_GL_GetProcAddress('glProgramLocalParameter4fvARB');
+ if not Assigned(glProgramLocalParameter4fvARB) then Exit;
+ @glGetProgramEnvParameterdvARB := SDL_GL_GetProcAddress('glGetProgramEnvParameterdvARB');
+ if not Assigned(glGetProgramEnvParameterdvARB) then Exit;
+ @glGetProgramEnvParameterfvARB := SDL_GL_GetProcAddress('glGetProgramEnvParameterfvARB');
+ if not Assigned(glGetProgramEnvParameterfvARB) then Exit;
+ @glGetProgramLocalParameterdvARB := SDL_GL_GetProcAddress('glGetProgramLocalParameterdvARB');
+ if not Assigned(glGetProgramLocalParameterdvARB) then Exit;
+ @glGetProgramLocalParameterfvARB := SDL_GL_GetProcAddress('glGetProgramLocalParameterfvARB');
+ if not Assigned(glGetProgramLocalParameterfvARB) then Exit;
+ @glGetProgramivARB := SDL_GL_GetProcAddress('glGetProgramivARB');
+ if not Assigned(glGetProgramivARB) then Exit;
+ @glGetProgramStringARB := SDL_GL_GetProcAddress('glGetProgramStringARB');
+ if not Assigned(glGetProgramStringARB) then Exit;
+ @glIsProgramARB := SDL_GL_GetProcAddress('glIsProgramARB');
+ if not Assigned(glIsProgramARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_text_fragment_shader: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_text_fragment_shader', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_APPLE_client_storage: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_APPLE_client_storage', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_APPLE_element_array: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_APPLE_element_array', extstring) then
+ begin
+ @glElementPointerAPPLE := SDL_GL_GetProcAddress('glElementPointerAPPLE');
+ if not Assigned(glElementPointerAPPLE) then Exit;
+ @glDrawElementArrayAPPLE := SDL_GL_GetProcAddress('glDrawElementArrayAPPLE');
+ if not Assigned(glDrawElementArrayAPPLE) then Exit;
+ @glDrawRangeElementArrayAPPLE := SDL_GL_GetProcAddress('glDrawRangeElementArrayAPPLE');
+ if not Assigned(glDrawRangeElementArrayAPPLE) then Exit;
+ @glMultiDrawElementArrayAPPLE := SDL_GL_GetProcAddress('glMultiDrawElementArrayAPPLE');
+ if not Assigned(glMultiDrawElementArrayAPPLE) then Exit;
+ @glMultiDrawRangeElementArrayAPPLE := SDL_GL_GetProcAddress('glMultiDrawRangeElementArrayAPPLE');
+ if not Assigned(glMultiDrawRangeElementArrayAPPLE) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_APPLE_fence: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_APPLE_fence', extstring) then
+ begin
+ @glGenFencesAPPLE := SDL_GL_GetProcAddress('glGenFencesAPPLE');
+ if not Assigned(glGenFencesAPPLE) then Exit;
+ @glDeleteFencesAPPLE := SDL_GL_GetProcAddress('glDeleteFencesAPPLE');
+ if not Assigned(glDeleteFencesAPPLE) then Exit;
+ @glSetFenceAPPLE := SDL_GL_GetProcAddress('glSetFenceAPPLE');
+ if not Assigned(glSetFenceAPPLE) then Exit;
+ @glIsFenceAPPLE := SDL_GL_GetProcAddress('glIsFenceAPPLE');
+ if not Assigned(glIsFenceAPPLE) then Exit;
+ @glTestFenceAPPLE := SDL_GL_GetProcAddress('glTestFenceAPPLE');
+ if not Assigned(glTestFenceAPPLE) then Exit;
+ @glFinishFenceAPPLE := SDL_GL_GetProcAddress('glFinishFenceAPPLE');
+ if not Assigned(glFinishFenceAPPLE) then Exit;
+ @glTestObjectAPPLE := SDL_GL_GetProcAddress('glTestObjectAPPLE');
+ if not Assigned(glTestObjectAPPLE) then Exit;
+ @glFinishObjectAPPLE := SDL_GL_GetProcAddress('glFinishObjectAPPLE');
+ if not Assigned(glFinishObjectAPPLE) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_APPLE_vertex_array_object: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_APPLE_vertex_array_object', extstring) then
+ begin
+ @glBindVertexArrayAPPLE := SDL_GL_GetProcAddress('glBindVertexArrayAPPLE');
+ if not Assigned(glBindVertexArrayAPPLE) then Exit;
+ @glDeleteVertexArraysAPPLE := SDL_GL_GetProcAddress('glDeleteVertexArraysAPPLE');
+ if not Assigned(glDeleteVertexArraysAPPLE) then Exit;
+ @glGenVertexArraysAPPLE := SDL_GL_GetProcAddress('glGenVertexArraysAPPLE');
+ if not Assigned(glGenVertexArraysAPPLE) then Exit;
+ @glIsVertexArrayAPPLE := SDL_GL_GetProcAddress('glIsVertexArrayAPPLE');
+ if not Assigned(glIsVertexArrayAPPLE) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_APPLE_vertex_array_range: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_APPLE_vertex_array_range', extstring) then
+ begin
+ @glVertexArrayRangeAPPLE := SDL_GL_GetProcAddress('glVertexArrayRangeAPPLE');
+ if not Assigned(glVertexArrayRangeAPPLE) then Exit;
+ @glFlushVertexArrayRangeAPPLE := SDL_GL_GetProcAddress('glFlushVertexArrayRangeAPPLE');
+ if not Assigned(glFlushVertexArrayRangeAPPLE) then Exit;
+ @glVertexArrayParameteriAPPLE := SDL_GL_GetProcAddress('glVertexArrayParameteriAPPLE');
+ if not Assigned(glVertexArrayParameteriAPPLE) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+{$IFDEF WINDOWS}
+function Load_WGL_ARB_pixel_format: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_ARB_pixel_format', extstring) then
+ begin
+ @wglGetPixelFormatAttribivARB := SDL_GL_GetProcAddress('wglGetPixelFormatAttribivARB');
+ if not Assigned(wglGetPixelFormatAttribivARB) then Exit;
+ @wglGetPixelFormatAttribfvARB := SDL_GL_GetProcAddress('wglGetPixelFormatAttribfvARB');
+ if not Assigned(wglGetPixelFormatAttribfvARB) then Exit;
+ @wglChoosePixelFormatARB := SDL_GL_GetProcAddress('wglChoosePixelFormatARB');
+ if not Assigned(wglChoosePixelFormatARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_ARB_make_current_read: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_ARB_make_current_read', extstring) then
+ begin
+ @wglMakeContextCurrentARB := SDL_GL_GetProcAddress('wglMakeContextCurrentARB');
+ if not Assigned(wglMakeContextCurrentARB) then Exit;
+ @wglGetCurrentReadDCARB := SDL_GL_GetProcAddress('wglGetCurrentReadDCARB');
+ if not Assigned(wglGetCurrentReadDCARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_ARB_pbuffer: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_ARB_pbuffer', extstring) then
+ begin
+ @wglCreatePbufferARB := SDL_GL_GetProcAddress('wglCreatePbufferARB');
+ if not Assigned(wglCreatePbufferARB) then Exit;
+ @wglGetPbufferDCARB := SDL_GL_GetProcAddress('wglGetPbufferDCARB');
+ if not Assigned(wglGetPbufferDCARB) then Exit;
+ @wglReleasePbufferDCARB := SDL_GL_GetProcAddress('wglReleasePbufferDCARB');
+ if not Assigned(wglReleasePbufferDCARB) then Exit;
+ @wglDestroyPbufferARB := SDL_GL_GetProcAddress('wglDestroyPbufferARB');
+ if not Assigned(wglDestroyPbufferARB) then Exit;
+ @wglQueryPbufferARB := SDL_GL_GetProcAddress('wglQueryPbufferARB');
+ if not Assigned(wglQueryPbufferARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_EXT_swap_control: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_EXT_swap_control', extstring) then
+ begin
+ @wglSwapIntervalEXT := SDL_GL_GetProcAddress('wglSwapIntervalEXT');
+ if not Assigned(wglSwapIntervalEXT) then Exit;
+ @wglGetSwapIntervalEXT := SDL_GL_GetProcAddress('wglGetSwapIntervalEXT');
+ if not Assigned(wglGetSwapIntervalEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_ARB_render_texture: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_ARB_render_texture', extstring) then
+ begin
+ @wglBindTexImageARB := SDL_GL_GetProcAddress('wglBindTexImageARB');
+ if not Assigned(wglBindTexImageARB) then Exit;
+ @wglReleaseTexImageARB := SDL_GL_GetProcAddress('wglReleaseTexImageARB');
+ if not Assigned(wglReleaseTexImageARB) then Exit;
+ @wglSetPbufferAttribARB := SDL_GL_GetProcAddress('wglSetPbufferAttribARB');
+ if not Assigned(wglSetPbufferAttribARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_EXT_extensions_string: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_EXT_extensions_string', extstring) then
+ begin
+ @wglGetExtensionsStringEXT := SDL_GL_GetProcAddress('wglGetExtensionsStringEXT');
+ if not Assigned(wglGetExtensionsStringEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_EXT_make_current_read: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_EXT_make_current_read', extstring) then
+ begin
+ @wglMakeContextCurrentEXT := SDL_GL_GetProcAddress('wglMakeContextCurrentEXT');
+ if not Assigned(wglMakeContextCurrentEXT) then Exit;
+ @wglGetCurrentReadDCEXT := SDL_GL_GetProcAddress('wglGetCurrentReadDCEXT');
+ if not Assigned(wglGetCurrentReadDCEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_EXT_pbuffer: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_EXT_pbuffer', extstring) then
+ begin
+ @wglCreatePbufferEXT := SDL_GL_GetProcAddress('wglCreatePbufferEXT');
+ if not Assigned(wglCreatePbufferEXT) then Exit;
+ @wglGetPbufferDCEXT := SDL_GL_GetProcAddress('wglGetPbufferDCEXT');
+ if not Assigned(wglGetPbufferDCEXT) then Exit;
+ @wglReleasePbufferDCEXT := SDL_GL_GetProcAddress('wglReleasePbufferDCEXT');
+ if not Assigned(wglReleasePbufferDCEXT) then Exit;
+ @wglDestroyPbufferEXT := SDL_GL_GetProcAddress('wglDestroyPbufferEXT');
+ if not Assigned(wglDestroyPbufferEXT) then Exit;
+ @wglQueryPbufferEXT := SDL_GL_GetProcAddress('wglQueryPbufferEXT');
+ if not Assigned(wglQueryPbufferEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_EXT_pixel_format: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_EXT_pixel_format', extstring) then
+ begin
+ @wglGetPixelFormatAttribivEXT := SDL_GL_GetProcAddress('wglGetPixelFormatAttribivEXT');
+ if not Assigned(wglGetPixelFormatAttribivEXT) then Exit;
+ @wglGetPixelFormatAttribfvEXT := SDL_GL_GetProcAddress('wglGetPixelFormatAttribfvEXT');
+ if not Assigned(wglGetPixelFormatAttribfvEXT) then Exit;
+ @wglChoosePixelFormatEXT := SDL_GL_GetProcAddress('wglChoosePixelFormatEXT');
+ if not Assigned(wglChoosePixelFormatEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_I3D_digital_video_control: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_I3D_digital_video_control', extstring) then
+ begin
+ @wglGetDigitalVideoParametersI3D := SDL_GL_GetProcAddress('wglGetDigitalVideoParametersI3D');
+ if not Assigned(wglGetDigitalVideoParametersI3D) then Exit;
+ @wglSetDigitalVideoParametersI3D := SDL_GL_GetProcAddress('wglSetDigitalVideoParametersI3D');
+ if not Assigned(wglSetDigitalVideoParametersI3D) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_I3D_gamma: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_I3D_gamma', extstring) then
+ begin
+ @wglGetGammaTableParametersI3D := SDL_GL_GetProcAddress('wglGetGammaTableParametersI3D');
+ if not Assigned(wglGetGammaTableParametersI3D) then Exit;
+ @wglSetGammaTableParametersI3D := SDL_GL_GetProcAddress('wglSetGammaTableParametersI3D');
+ if not Assigned(wglSetGammaTableParametersI3D) then Exit;
+ @wglGetGammaTableI3D := SDL_GL_GetProcAddress('wglGetGammaTableI3D');
+ if not Assigned(wglGetGammaTableI3D) then Exit;
+ @wglSetGammaTableI3D := SDL_GL_GetProcAddress('wglSetGammaTableI3D');
+ if not Assigned(wglSetGammaTableI3D) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_WGL_I3D_genlock: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_I3D_genlock', extstring) then
+ begin
+ @wglEnableGenlockI3D := SDL_GL_GetProcAddress('wglEnableGenlockI3D');
+ if not Assigned(wglEnableGenlockI3D) then Exit;
+ @wglDisableGenlockI3D := SDL_GL_GetProcAddress('wglDisableGenlockI3D');
+ if not Assigned(wglDisableGenlockI3D) then Exit;
+ @wglIsEnabledGenlockI3D := SDL_GL_GetProcAddress('wglIsEnabledGenlockI3D');
+ if not Assigned(wglIsEnabledGenlockI3D) then Exit;
+ @wglGenlockSourceI3D := SDL_GL_GetProcAddress('wglGenlockSourceI3D');
+ if not Assigned(wglGenlockSourceI3D) then Exit;
+ @wglGetGenlockSourceI3D := SDL_GL_GetProcAddress('wglGetGenlockSourceI3D');
+ if not Assigned(wglGetGenlockSourceI3D) then Exit;
+ @wglGenlockSourceEdgeI3D := SDL_GL_GetProcAddress('wglGenlockSourceEdgeI3D');
+ if not Assigned(wglGenlockSourceEdgeI3D) then Exit;
+ @wglGetGenlockSourceEdgeI3D := SDL_GL_GetProcAddress('wglGetGenlockSourceEdgeI3D');
+ if not Assigned(wglGetGenlockSourceEdgeI3D) then Exit;
+ @wglGenlockSampleRateI3D := SDL_GL_GetProcAddress('wglGenlockSampleRateI3D');
+ if not Assigned(wglGenlockSampleRateI3D) then Exit;
+ @wglGetGenlockSampleRateI3D := SDL_GL_GetProcAddress('wglGetGenlockSampleRateI3D');
+ if not Assigned(wglGetGenlockSampleRateI3D) then Exit;
+ @wglGenlockSourceDelayI3D := SDL_GL_GetProcAddress('wglGenlockSourceDelayI3D');
+ if not Assigned(wglGenlockSourceDelayI3D) then Exit;
+ @wglGetGenlockSourceDelayI3D := SDL_GL_GetProcAddress('wglGetGenlockSourceDelayI3D');
+ if not Assigned(wglGetGenlockSourceDelayI3D) then Exit;
+ @wglQueryGenlockMaxSourceDelayI3D := SDL_GL_GetProcAddress('wglQueryGenlockMaxSourceDelayI3D');
+ if not Assigned(wglQueryGenlockMaxSourceDelayI3D) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+{$ENDIF}
+
+function Load_GL_ARB_matrix_palette: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_matrix_palette', extstring) then
+ begin
+ @glCurrentPaletteMatrixARB := SDL_GL_GetProcAddress('glCurrentPaletteMatrixARB');
+ if not Assigned(glCurrentPaletteMatrixARB) then Exit;
+ @glMatrixIndexubvARB := SDL_GL_GetProcAddress('glMatrixIndexubvARB');
+ if not Assigned(glMatrixIndexubvARB) then Exit;
+ @glMatrixIndexusvARB := SDL_GL_GetProcAddress('glMatrixIndexusvARB');
+ if not Assigned(glMatrixIndexusvARB) then Exit;
+ @glMatrixIndexuivARB := SDL_GL_GetProcAddress('glMatrixIndexuivARB');
+ if not Assigned(glMatrixIndexuivARB) then Exit;
+ @glMatrixIndexPointerARB := SDL_GL_GetProcAddress('glMatrixIndexPointerARB');
+ if not Assigned(glMatrixIndexPointerARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_element_array: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_element_array', extstring) then
+ begin
+ @glElementPointerNV := SDL_GL_GetProcAddress('glElementPointerNV');
+ if not Assigned(glElementPointerNV) then Exit;
+ @glDrawElementArrayNV := SDL_GL_GetProcAddress('glDrawElementArrayNV');
+ if not Assigned(glDrawElementArrayNV) then Exit;
+ @glDrawRangeElementArrayNV := SDL_GL_GetProcAddress('glDrawRangeElementArrayNV');
+ if not Assigned(glDrawRangeElementArrayNV) then Exit;
+ @glMultiDrawElementArrayNV := SDL_GL_GetProcAddress('glMultiDrawElementArrayNV');
+ if not Assigned(glMultiDrawElementArrayNV) then Exit;
+ @glMultiDrawRangeElementArrayNV := SDL_GL_GetProcAddress('glMultiDrawRangeElementArrayNV');
+ if not Assigned(glMultiDrawRangeElementArrayNV) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_float_buffer: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_float_buffer', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_fragment_program: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_fragment_program', extstring) then
+ begin
+ @glProgramNamedParameter4fNV := SDL_GL_GetProcAddress('glProgramNamedParameter4fNV');
+ if not Assigned(glProgramNamedParameter4fNV) then Exit;
+ @glProgramNamedParameter4dNV := SDL_GL_GetProcAddress('glProgramNamedParameter4dNV');
+ if not Assigned(glProgramNamedParameter4dNV) then Exit;
+ @glGetProgramNamedParameterfvNV := SDL_GL_GetProcAddress('glGetProgramNamedParameterfvNV');
+ if not Assigned(glGetProgramNamedParameterfvNV) then Exit;
+ @glGetProgramNamedParameterdvNV := SDL_GL_GetProcAddress('glGetProgramNamedParameterdvNV');
+ if not Assigned(glGetProgramNamedParameterdvNV) then Exit;
+ @glProgramLocalParameter4dARB := SDL_GL_GetProcAddress('glProgramLocalParameter4dARB');
+ if not Assigned(glProgramLocalParameter4dARB) then Exit;
+ @glProgramLocalParameter4dvARB := SDL_GL_GetProcAddress('glProgramLocalParameter4dvARB');
+ if not Assigned(glProgramLocalParameter4dvARB) then Exit;
+ @glProgramLocalParameter4fARB := SDL_GL_GetProcAddress('glProgramLocalParameter4fARB');
+ if not Assigned(glProgramLocalParameter4fARB) then Exit;
+ @glProgramLocalParameter4fvARB := SDL_GL_GetProcAddress('glProgramLocalParameter4fvARB');
+ if not Assigned(glProgramLocalParameter4fvARB) then Exit;
+ @glGetProgramLocalParameterdvARB := SDL_GL_GetProcAddress('glGetProgramLocalParameterdvARB');
+ if not Assigned(glGetProgramLocalParameterdvARB) then Exit;
+ @glGetProgramLocalParameterfvARB := SDL_GL_GetProcAddress('glGetProgramLocalParameterfvARB');
+ if not Assigned(glGetProgramLocalParameterfvARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_primitive_restart: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_primitive_restart', extstring) then
+ begin
+ @glPrimitiveRestartNV := SDL_GL_GetProcAddress('glPrimitiveRestartNV');
+ if not Assigned(glPrimitiveRestartNV) then Exit;
+ @glPrimitiveRestartIndexNV := SDL_GL_GetProcAddress('glPrimitiveRestartIndexNV');
+ if not Assigned(glPrimitiveRestartIndexNV) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_vertex_program2: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_vertex_program2', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+{$IFDEF WINDOWS}
+function Load_WGL_NV_render_texture_rectangle: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_NV_render_texture_rectangle', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+{$ENDIF}
+
+function Load_GL_NV_pixel_data_range: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_pixel_data_range', extstring) then
+ begin
+ @glPixelDataRangeNV := SDL_GL_GetProcAddress('glPixelDataRangeNV');
+ if not Assigned(glPixelDataRangeNV) then Exit;
+ @glFlushPixelDataRangeNV := SDL_GL_GetProcAddress('glFlushPixelDataRangeNV');
+ if not Assigned(glFlushPixelDataRangeNV) then Exit;
+ {$IFDEF WINDOWS}
+ @wglAllocateMemoryNV := SDL_GL_GetProcAddress('wglAllocateMemoryNV');
+ if not Assigned(wglAllocateMemoryNV) then Exit;
+ @wglFreeMemoryNV := SDL_GL_GetProcAddress('wglFreeMemoryNV');
+ if not Assigned(wglFreeMemoryNV) then Exit;
+ {$ENDIF}
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_texture_rectangle: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_texture_rectangle', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_S3_s3tc: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_S3_s3tc', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_draw_buffers: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_draw_buffers', extstring) then
+ begin
+ @glDrawBuffersATI := SDL_GL_GetProcAddress('glDrawBuffersATI');
+ if not Assigned(glDrawBuffersATI) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+{$IFDEF WINDOWS}
+function Load_WGL_ATI_pixel_format_float: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ @wglGetExtensionsStringARB := SDL_GL_GetProcAddress('wglGetExtensionsStringARB');
+ if not Assigned(wglGetExtensionsStringARB) then Exit;
+ extstring := wglGetExtensionsStringARB(wglGetCurrentDC);
+
+ if glext_ExtensionSupported('WGL_ATI_pixel_format_float', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+{$ENDIF}
+
+function Load_GL_ATI_texture_env_combine3: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_texture_env_combine3', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_texture_float: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_texture_float', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_texture_expand_normal: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_texture_expand_normal', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_half_float: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_half_float', extstring) then
+ begin
+ @glVertex2hNV := SDL_GL_GetProcAddress('glVertex2hNV');
+ if not Assigned(glVertex2hNV) then Exit;
+ @glVertex2hvNV := SDL_GL_GetProcAddress('glVertex2hvNV');
+ if not Assigned(glVertex2hvNV) then Exit;
+ @glVertex3hNV := SDL_GL_GetProcAddress('glVertex3hNV');
+ if not Assigned(glVertex3hNV) then Exit;
+ @glVertex3hvNV := SDL_GL_GetProcAddress('glVertex3hvNV');
+ if not Assigned(glVertex3hvNV) then Exit;
+ @glVertex4hNV := SDL_GL_GetProcAddress('glVertex4hNV');
+ if not Assigned(glVertex4hNV) then Exit;
+ @glVertex4hvNV := SDL_GL_GetProcAddress('glVertex4hvNV');
+ if not Assigned(glVertex4hvNV) then Exit;
+ @glNormal3hNV := SDL_GL_GetProcAddress('glNormal3hNV');
+ if not Assigned(glNormal3hNV) then Exit;
+ @glNormal3hvNV := SDL_GL_GetProcAddress('glNormal3hvNV');
+ if not Assigned(glNormal3hvNV) then Exit;
+ @glColor3hNV := SDL_GL_GetProcAddress('glColor3hNV');
+ if not Assigned(glColor3hNV) then Exit;
+ @glColor3hvNV := SDL_GL_GetProcAddress('glColor3hvNV');
+ if not Assigned(glColor3hvNV) then Exit;
+ @glColor4hNV := SDL_GL_GetProcAddress('glColor4hNV');
+ if not Assigned(glColor4hNV) then Exit;
+ @glColor4hvNV := SDL_GL_GetProcAddress('glColor4hvNV');
+ if not Assigned(glColor4hvNV) then Exit;
+ @glTexCoord1hNV := SDL_GL_GetProcAddress('glTexCoord1hNV');
+ if not Assigned(glTexCoord1hNV) then Exit;
+ @glTexCoord1hvNV := SDL_GL_GetProcAddress('glTexCoord1hvNV');
+ if not Assigned(glTexCoord1hvNV) then Exit;
+ @glTexCoord2hNV := SDL_GL_GetProcAddress('glTexCoord2hNV');
+ if not Assigned(glTexCoord2hNV) then Exit;
+ @glTexCoord2hvNV := SDL_GL_GetProcAddress('glTexCoord2hvNV');
+ if not Assigned(glTexCoord2hvNV) then Exit;
+ @glTexCoord3hNV := SDL_GL_GetProcAddress('glTexCoord3hNV');
+ if not Assigned(glTexCoord3hNV) then Exit;
+ @glTexCoord3hvNV := SDL_GL_GetProcAddress('glTexCoord3hvNV');
+ if not Assigned(glTexCoord3hvNV) then Exit;
+ @glTexCoord4hNV := SDL_GL_GetProcAddress('glTexCoord4hNV');
+ if not Assigned(glTexCoord4hNV) then Exit;
+ @glTexCoord4hvNV := SDL_GL_GetProcAddress('glTexCoord4hvNV');
+ if not Assigned(glTexCoord4hvNV) then Exit;
+ @glMultiTexCoord1hNV := SDL_GL_GetProcAddress('glMultiTexCoord1hNV');
+ if not Assigned(glMultiTexCoord1hNV) then Exit;
+ @glMultiTexCoord1hvNV := SDL_GL_GetProcAddress('glMultiTexCoord1hvNV');
+ if not Assigned(glMultiTexCoord1hvNV) then Exit;
+ @glMultiTexCoord2hNV := SDL_GL_GetProcAddress('glMultiTexCoord2hNV');
+ if not Assigned(glMultiTexCoord2hNV) then Exit;
+ @glMultiTexCoord2hvNV := SDL_GL_GetProcAddress('glMultiTexCoord2hvNV');
+ if not Assigned(glMultiTexCoord2hvNV) then Exit;
+ @glMultiTexCoord3hNV := SDL_GL_GetProcAddress('glMultiTexCoord3hNV');
+ if not Assigned(glMultiTexCoord3hNV) then Exit;
+ @glMultiTexCoord3hvNV := SDL_GL_GetProcAddress('glMultiTexCoord3hvNV');
+ if not Assigned(glMultiTexCoord3hvNV) then Exit;
+ @glMultiTexCoord4hNV := SDL_GL_GetProcAddress('glMultiTexCoord4hNV');
+ if not Assigned(glMultiTexCoord4hNV) then Exit;
+ @glMultiTexCoord4hvNV := SDL_GL_GetProcAddress('glMultiTexCoord4hvNV');
+ if not Assigned(glMultiTexCoord4hvNV) then Exit;
+ @glFogCoordhNV := SDL_GL_GetProcAddress('glFogCoordhNV');
+ if not Assigned(glFogCoordhNV) then Exit;
+ @glFogCoordhvNV := SDL_GL_GetProcAddress('glFogCoordhvNV');
+ if not Assigned(glFogCoordhvNV) then Exit;
+ @glSecondaryColor3hNV := SDL_GL_GetProcAddress('glSecondaryColor3hNV');
+ if not Assigned(glSecondaryColor3hNV) then Exit;
+ @glSecondaryColor3hvNV := SDL_GL_GetProcAddress('glSecondaryColor3hvNV');
+ if not Assigned(glSecondaryColor3hvNV) then Exit;
+ @glVertexWeighthNV := SDL_GL_GetProcAddress('glVertexWeighthNV');
+ if not Assigned(glVertexWeighthNV) then Exit;
+ @glVertexWeighthvNV := SDL_GL_GetProcAddress('glVertexWeighthvNV');
+ if not Assigned(glVertexWeighthvNV) then Exit;
+ @glVertexAttrib1hNV := SDL_GL_GetProcAddress('glVertexAttrib1hNV');
+ if not Assigned(glVertexAttrib1hNV) then Exit;
+ @glVertexAttrib1hvNV := SDL_GL_GetProcAddress('glVertexAttrib1hvNV');
+ if not Assigned(glVertexAttrib1hvNV) then Exit;
+ @glVertexAttrib2hNV := SDL_GL_GetProcAddress('glVertexAttrib2hNV');
+ if not Assigned(glVertexAttrib2hNV) then Exit;
+ @glVertexAttrib2hvNV := SDL_GL_GetProcAddress('glVertexAttrib2hvNV');
+ if not Assigned(glVertexAttrib2hvNV) then Exit;
+ @glVertexAttrib3hNV := SDL_GL_GetProcAddress('glVertexAttrib3hNV');
+ if not Assigned(glVertexAttrib3hNV) then Exit;
+ @glVertexAttrib3hvNV := SDL_GL_GetProcAddress('glVertexAttrib3hvNV');
+ if not Assigned(glVertexAttrib3hvNV) then Exit;
+ @glVertexAttrib4hNV := SDL_GL_GetProcAddress('glVertexAttrib4hNV');
+ if not Assigned(glVertexAttrib4hNV) then Exit;
+ @glVertexAttrib4hvNV := SDL_GL_GetProcAddress('glVertexAttrib4hvNV');
+ if not Assigned(glVertexAttrib4hvNV) then Exit;
+ @glVertexAttribs1hvNV := SDL_GL_GetProcAddress('glVertexAttribs1hvNV');
+ if not Assigned(glVertexAttribs1hvNV) then Exit;
+ @glVertexAttribs2hvNV := SDL_GL_GetProcAddress('glVertexAttribs2hvNV');
+ if not Assigned(glVertexAttribs2hvNV) then Exit;
+ @glVertexAttribs3hvNV := SDL_GL_GetProcAddress('glVertexAttribs3hvNV');
+ if not Assigned(glVertexAttribs3hvNV) then Exit;
+ @glVertexAttribs4hvNV := SDL_GL_GetProcAddress('glVertexAttribs4hvNV');
+ if not Assigned(glVertexAttribs4hvNV) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_map_object_buffer: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_map_object_buffer', extstring) then
+ begin
+ @glMapObjectBufferATI := SDL_GL_GetProcAddress('glMapObjectBufferATI');
+ if not Assigned(glMapObjectBufferATI) then Exit;
+ @glUnmapObjectBufferATI := SDL_GL_GetProcAddress('glUnmapObjectBufferATI');
+ if not Assigned(glUnmapObjectBufferATI) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_separate_stencil: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_separate_stencil', extstring) then
+ begin
+ @glStencilOpSeparateATI := SDL_GL_GetProcAddress('glStencilOpSeparateATI');
+ if not Assigned(glStencilOpSeparateATI) then Exit;
+ @glStencilFuncSeparateATI := SDL_GL_GetProcAddress('glStencilFuncSeparateATI');
+ if not Assigned(glStencilFuncSeparateATI) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ATI_vertex_attrib_array_object: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ATI_vertex_attrib_array_object', extstring) then
+ begin
+ @glVertexAttribArrayObjectATI := SDL_GL_GetProcAddress('glVertexAttribArrayObjectATI');
+ if not Assigned(glVertexAttribArrayObjectATI) then Exit;
+ @glGetVertexAttribArrayObjectfvATI := SDL_GL_GetProcAddress('glGetVertexAttribArrayObjectfvATI');
+ if not Assigned(glGetVertexAttribArrayObjectfvATI) then Exit;
+ @glGetVertexAttribArrayObjectivATI := SDL_GL_GetProcAddress('glGetVertexAttribArrayObjectivATI');
+ if not Assigned(glGetVertexAttribArrayObjectivATI) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_vertex_buffer_object: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_vertex_buffer_object', extstring) then
+ begin
+ @glBindBufferARB := SDL_GL_GetProcAddress('glBindBufferARB');
+ if not Assigned(glBindBufferARB) then Exit;
+ @glDeleteBuffersARB := SDL_GL_GetProcAddress('glDeleteBuffersARB');
+ if not Assigned(glDeleteBuffersARB) then Exit;
+ @glGenBuffersARB := SDL_GL_GetProcAddress('glGenBuffersARB');
+ if not Assigned(glGenBuffersARB) then Exit;
+ @glIsBufferARB := SDL_GL_GetProcAddress('glIsBufferARB');
+ if not Assigned(glIsBufferARB) then Exit;
+ @glBufferDataARB := SDL_GL_GetProcAddress('glBufferDataARB');
+ if not Assigned(glBufferDataARB) then Exit;
+ @glBufferSubDataARB := SDL_GL_GetProcAddress('glBufferSubDataARB');
+ if not Assigned(glBufferSubDataARB) then Exit;
+ @glGetBufferSubDataARB := SDL_GL_GetProcAddress('glGetBufferSubDataARB');
+ if not Assigned(glGetBufferSubDataARB) then Exit;
+ @glMapBufferARB := SDL_GL_GetProcAddress('glMapBufferARB');
+ if not Assigned(glMapBufferARB) then Exit;
+ @glUnmapBufferARB := SDL_GL_GetProcAddress('glUnmapBufferARB');
+ if not Assigned(glUnmapBufferARB) then Exit;
+ @glGetBufferParameterivARB := SDL_GL_GetProcAddress('glGetBufferParameterivARB');
+ if not Assigned(glGetBufferParameterivARB) then Exit;
+ @glGetBufferPointervARB := SDL_GL_GetProcAddress('glGetBufferPointervARB');
+ if not Assigned(glGetBufferPointervARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_occlusion_query: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_occlusion_query', extstring) then
+ begin
+ @glGenQueriesARB := SDL_GL_GetProcAddress('glGenQueriesARB');
+ if not Assigned(glGenQueriesARB) then Exit;
+ @glDeleteQueriesARB := SDL_GL_GetProcAddress('glDeleteQueriesARB');
+ if not Assigned(glDeleteQueriesARB) then Exit;
+ @glIsQueryARB := SDL_GL_GetProcAddress('glIsQueryARB');
+ if not Assigned(glIsQueryARB) then Exit;
+ @glBeginQueryARB := SDL_GL_GetProcAddress('glBeginQueryARB');
+ if not Assigned(glBeginQueryARB) then Exit;
+ @glEndQueryARB := SDL_GL_GetProcAddress('glEndQueryARB');
+ if not Assigned(glEndQueryARB) then Exit;
+ @glGetQueryivARB := SDL_GL_GetProcAddress('glGetQueryivARB');
+ if not Assigned(glGetQueryivARB) then Exit;
+ @glGetQueryObjectivARB := SDL_GL_GetProcAddress('glGetQueryObjectivARB');
+ if not Assigned(glGetQueryObjectivARB) then Exit;
+ @glGetQueryObjectuivARB := SDL_GL_GetProcAddress('glGetQueryObjectuivARB');
+ if not Assigned(glGetQueryObjectuivARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_shader_objects: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_shader_objects', extstring) then
+ begin
+ @glDeleteObjectARB := SDL_GL_GetProcAddress('glDeleteObjectARB');
+ if not Assigned(glDeleteObjectARB) then Exit;
+ @glGetHandleARB := SDL_GL_GetProcAddress('glGetHandleARB');
+ if not Assigned(glGetHandleARB) then Exit;
+ @glDetachObjectARB := SDL_GL_GetProcAddress('glDetachObjectARB');
+ if not Assigned(glDetachObjectARB) then Exit;
+ @glCreateShaderObjectARB := SDL_GL_GetProcAddress('glCreateShaderObjectARB');
+ if not Assigned(glCreateShaderObjectARB) then Exit;
+ @glShaderSourceARB := SDL_GL_GetProcAddress('glShaderSourceARB');
+ if not Assigned(glShaderSourceARB) then Exit;
+ @glCompileShaderARB := SDL_GL_GetProcAddress('glCompileShaderARB');
+ if not Assigned(glCompileShaderARB) then Exit;
+ @glCreateProgramObjectARB := SDL_GL_GetProcAddress('glCreateProgramObjectARB');
+ if not Assigned(glCreateProgramObjectARB) then Exit;
+ @glAttachObjectARB := SDL_GL_GetProcAddress('glAttachObjectARB');
+ if not Assigned(glAttachObjectARB) then Exit;
+ @glLinkProgramARB := SDL_GL_GetProcAddress('glLinkProgramARB');
+ if not Assigned(glLinkProgramARB) then Exit;
+ @glUseProgramObjectARB := SDL_GL_GetProcAddress('glUseProgramObjectARB');
+ if not Assigned(glUseProgramObjectARB) then Exit;
+ @glValidateProgramARB := SDL_GL_GetProcAddress('glValidateProgramARB');
+ if not Assigned(glValidateProgramARB) then Exit;
+ @glUniform1fARB := SDL_GL_GetProcAddress('glUniform1fARB');
+ if not Assigned(glUniform1fARB) then Exit;
+ @glUniform2fARB := SDL_GL_GetProcAddress('glUniform2fARB');
+ if not Assigned(glUniform2fARB) then Exit;
+ @glUniform3fARB := SDL_GL_GetProcAddress('glUniform3fARB');
+ if not Assigned(glUniform3fARB) then Exit;
+ @glUniform4fARB := SDL_GL_GetProcAddress('glUniform4fARB');
+ if not Assigned(glUniform4fARB) then Exit;
+ @glUniform1iARB := SDL_GL_GetProcAddress('glUniform1iARB');
+ if not Assigned(glUniform1iARB) then Exit;
+ @glUniform2iARB := SDL_GL_GetProcAddress('glUniform2iARB');
+ if not Assigned(glUniform2iARB) then Exit;
+ @glUniform3iARB := SDL_GL_GetProcAddress('glUniform3iARB');
+ if not Assigned(glUniform3iARB) then Exit;
+ @glUniform4iARB := SDL_GL_GetProcAddress('glUniform4iARB');
+ if not Assigned(glUniform4iARB) then Exit;
+ @glUniform1fvARB := SDL_GL_GetProcAddress('glUniform1fvARB');
+ if not Assigned(glUniform1fvARB) then Exit;
+ @glUniform2fvARB := SDL_GL_GetProcAddress('glUniform2fvARB');
+ if not Assigned(glUniform2fvARB) then Exit;
+ @glUniform3fvARB := SDL_GL_GetProcAddress('glUniform3fvARB');
+ if not Assigned(glUniform3fvARB) then Exit;
+ @glUniform4fvARB := SDL_GL_GetProcAddress('glUniform4fvARB');
+ if not Assigned(glUniform4fvARB) then Exit;
+ @glUniform1ivARB := SDL_GL_GetProcAddress('glUniform1ivARB');
+ if not Assigned(glUniform1ivARB) then Exit;
+ @glUniform2ivARB := SDL_GL_GetProcAddress('glUniform2ivARB');
+ if not Assigned(glUniform2ivARB) then Exit;
+ @glUniform3ivARB := SDL_GL_GetProcAddress('glUniform3ivARB');
+ if not Assigned(glUniform3ivARB) then Exit;
+ @glUniform4ivARB := SDL_GL_GetProcAddress('glUniform4ivARB');
+ if not Assigned(glUniform4ivARB) then Exit;
+ @glUniformMatrix2fvARB := SDL_GL_GetProcAddress('glUniformMatrix2fvARB');
+ if not Assigned(glUniformMatrix2fvARB) then Exit;
+ @glUniformMatrix3fvARB := SDL_GL_GetProcAddress('glUniformMatrix3fvARB');
+ if not Assigned(glUniformMatrix3fvARB) then Exit;
+ @glUniformMatrix4fvARB := SDL_GL_GetProcAddress('glUniformMatrix4fvARB');
+ if not Assigned(glUniformMatrix4fvARB) then Exit;
+ @glGetObjectParameterfvARB := SDL_GL_GetProcAddress('glGetObjectParameterfvARB');
+ if not Assigned(glGetObjectParameterfvARB) then Exit;
+ @glGetObjectParameterivARB := SDL_GL_GetProcAddress('glGetObjectParameterivARB');
+ if not Assigned(glGetObjectParameterivARB) then Exit;
+ @glGetInfoLogARB := SDL_GL_GetProcAddress('glGetInfoLogARB');
+ if not Assigned(glGetInfoLogARB) then Exit;
+ @glGetAttachedObjectsARB := SDL_GL_GetProcAddress('glGetAttachedObjectsARB');
+ if not Assigned(glGetAttachedObjectsARB) then Exit;
+ @glGetUniformLocationARB := SDL_GL_GetProcAddress('glGetUniformLocationARB');
+ if not Assigned(glGetUniformLocationARB) then Exit;
+ @glGetActiveUniformARB := SDL_GL_GetProcAddress('glGetActiveUniformARB');
+ if not Assigned(glGetActiveUniformARB) then Exit;
+ @glGetUniformfvARB := SDL_GL_GetProcAddress('glGetUniformfvARB');
+ if not Assigned(glGetUniformfvARB) then Exit;
+ @glGetUniformivARB := SDL_GL_GetProcAddress('glGetUniformivARB');
+ if not Assigned(glGetUniformivARB) then Exit;
+ @glGetShaderSourceARB := SDL_GL_GetProcAddress('glGetShaderSourceARB');
+ if not Assigned(glGetShaderSourceARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_vertex_shader: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_vertex_shader', extstring) then
+ begin
+ @glVertexAttrib1fARB := SDL_GL_GetProcAddress('glVertexAttrib1fARB');
+ if not Assigned(glVertexAttrib1fARB) then Exit;
+ @glVertexAttrib1sARB := SDL_GL_GetProcAddress('glVertexAttrib1sARB');
+ if not Assigned(glVertexAttrib1sARB) then Exit;
+ @glVertexAttrib1dARB := SDL_GL_GetProcAddress('glVertexAttrib1dARB');
+ if not Assigned(glVertexAttrib1dARB) then Exit;
+ @glVertexAttrib2fARB := SDL_GL_GetProcAddress('glVertexAttrib2fARB');
+ if not Assigned(glVertexAttrib2fARB) then Exit;
+ @glVertexAttrib2sARB := SDL_GL_GetProcAddress('glVertexAttrib2sARB');
+ if not Assigned(glVertexAttrib2sARB) then Exit;
+ @glVertexAttrib2dARB := SDL_GL_GetProcAddress('glVertexAttrib2dARB');
+ if not Assigned(glVertexAttrib2dARB) then Exit;
+ @glVertexAttrib3fARB := SDL_GL_GetProcAddress('glVertexAttrib3fARB');
+ if not Assigned(glVertexAttrib3fARB) then Exit;
+ @glVertexAttrib3sARB := SDL_GL_GetProcAddress('glVertexAttrib3sARB');
+ if not Assigned(glVertexAttrib3sARB) then Exit;
+ @glVertexAttrib3dARB := SDL_GL_GetProcAddress('glVertexAttrib3dARB');
+ if not Assigned(glVertexAttrib3dARB) then Exit;
+ @glVertexAttrib4fARB := SDL_GL_GetProcAddress('glVertexAttrib4fARB');
+ if not Assigned(glVertexAttrib4fARB) then Exit;
+ @glVertexAttrib4sARB := SDL_GL_GetProcAddress('glVertexAttrib4sARB');
+ if not Assigned(glVertexAttrib4sARB) then Exit;
+ @glVertexAttrib4dARB := SDL_GL_GetProcAddress('glVertexAttrib4dARB');
+ if not Assigned(glVertexAttrib4dARB) then Exit;
+ @glVertexAttrib4NubARB := SDL_GL_GetProcAddress('glVertexAttrib4NubARB');
+ if not Assigned(glVertexAttrib4NubARB) then Exit;
+ @glVertexAttrib1fvARB := SDL_GL_GetProcAddress('glVertexAttrib1fvARB');
+ if not Assigned(glVertexAttrib1fvARB) then Exit;
+ @glVertexAttrib1svARB := SDL_GL_GetProcAddress('glVertexAttrib1svARB');
+ if not Assigned(glVertexAttrib1svARB) then Exit;
+ @glVertexAttrib1dvARB := SDL_GL_GetProcAddress('glVertexAttrib1dvARB');
+ if not Assigned(glVertexAttrib1dvARB) then Exit;
+ @glVertexAttrib2fvARB := SDL_GL_GetProcAddress('glVertexAttrib2fvARB');
+ if not Assigned(glVertexAttrib2fvARB) then Exit;
+ @glVertexAttrib2svARB := SDL_GL_GetProcAddress('glVertexAttrib2svARB');
+ if not Assigned(glVertexAttrib2svARB) then Exit;
+ @glVertexAttrib2dvARB := SDL_GL_GetProcAddress('glVertexAttrib2dvARB');
+ if not Assigned(glVertexAttrib2dvARB) then Exit;
+ @glVertexAttrib3fvARB := SDL_GL_GetProcAddress('glVertexAttrib3fvARB');
+ if not Assigned(glVertexAttrib3fvARB) then Exit;
+ @glVertexAttrib3svARB := SDL_GL_GetProcAddress('glVertexAttrib3svARB');
+ if not Assigned(glVertexAttrib3svARB) then Exit;
+ @glVertexAttrib3dvARB := SDL_GL_GetProcAddress('glVertexAttrib3dvARB');
+ if not Assigned(glVertexAttrib3dvARB) then Exit;
+ @glVertexAttrib4fvARB := SDL_GL_GetProcAddress('glVertexAttrib4fvARB');
+ if not Assigned(glVertexAttrib4fvARB) then Exit;
+ @glVertexAttrib4svARB := SDL_GL_GetProcAddress('glVertexAttrib4svARB');
+ if not Assigned(glVertexAttrib4svARB) then Exit;
+ @glVertexAttrib4dvARB := SDL_GL_GetProcAddress('glVertexAttrib4dvARB');
+ if not Assigned(glVertexAttrib4dvARB) then Exit;
+ @glVertexAttrib4ivARB := SDL_GL_GetProcAddress('glVertexAttrib4ivARB');
+ if not Assigned(glVertexAttrib4ivARB) then Exit;
+ @glVertexAttrib4bvARB := SDL_GL_GetProcAddress('glVertexAttrib4bvARB');
+ if not Assigned(glVertexAttrib4bvARB) then Exit;
+ @glVertexAttrib4ubvARB := SDL_GL_GetProcAddress('glVertexAttrib4ubvARB');
+ if not Assigned(glVertexAttrib4ubvARB) then Exit;
+ @glVertexAttrib4usvARB := SDL_GL_GetProcAddress('glVertexAttrib4usvARB');
+ if not Assigned(glVertexAttrib4usvARB) then Exit;
+ @glVertexAttrib4uivARB := SDL_GL_GetProcAddress('glVertexAttrib4uivARB');
+ if not Assigned(glVertexAttrib4uivARB) then Exit;
+ @glVertexAttrib4NbvARB := SDL_GL_GetProcAddress('glVertexAttrib4NbvARB');
+ if not Assigned(glVertexAttrib4NbvARB) then Exit;
+ @glVertexAttrib4NsvARB := SDL_GL_GetProcAddress('glVertexAttrib4NsvARB');
+ if not Assigned(glVertexAttrib4NsvARB) then Exit;
+ @glVertexAttrib4NivARB := SDL_GL_GetProcAddress('glVertexAttrib4NivARB');
+ if not Assigned(glVertexAttrib4NivARB) then Exit;
+ @glVertexAttrib4NubvARB := SDL_GL_GetProcAddress('glVertexAttrib4NubvARB');
+ if not Assigned(glVertexAttrib4NubvARB) then Exit;
+ @glVertexAttrib4NusvARB := SDL_GL_GetProcAddress('glVertexAttrib4NusvARB');
+ if not Assigned(glVertexAttrib4NusvARB) then Exit;
+ @glVertexAttrib4NuivARB := SDL_GL_GetProcAddress('glVertexAttrib4NuivARB');
+ if not Assigned(glVertexAttrib4NuivARB) then Exit;
+ @glVertexAttribPointerARB := SDL_GL_GetProcAddress('glVertexAttribPointerARB');
+ if not Assigned(glVertexAttribPointerARB) then Exit;
+ @glEnableVertexAttribArrayARB := SDL_GL_GetProcAddress('glEnableVertexAttribArrayARB');
+ if not Assigned(glEnableVertexAttribArrayARB) then Exit;
+ @glDisableVertexAttribArrayARB := SDL_GL_GetProcAddress('glDisableVertexAttribArrayARB');
+ if not Assigned(glDisableVertexAttribArrayARB) then Exit;
+ @glBindAttribLocationARB := SDL_GL_GetProcAddress('glBindAttribLocationARB');
+ if not Assigned(glBindAttribLocationARB) then Exit;
+ @glGetActiveAttribARB := SDL_GL_GetProcAddress('glGetActiveAttribARB');
+ if not Assigned(glGetActiveAttribARB) then Exit;
+ @glGetAttribLocationARB := SDL_GL_GetProcAddress('glGetAttribLocationARB');
+ if not Assigned(glGetAttribLocationARB) then Exit;
+ @glGetVertexAttribdvARB := SDL_GL_GetProcAddress('glGetVertexAttribdvARB');
+ if not Assigned(glGetVertexAttribdvARB) then Exit;
+ @glGetVertexAttribfvARB := SDL_GL_GetProcAddress('glGetVertexAttribfvARB');
+ if not Assigned(glGetVertexAttribfvARB) then Exit;
+ @glGetVertexAttribivARB := SDL_GL_GetProcAddress('glGetVertexAttribivARB');
+ if not Assigned(glGetVertexAttribivARB) then Exit;
+ @glGetVertexAttribPointervARB := SDL_GL_GetProcAddress('glGetVertexAttribPointervARB');
+ if not Assigned(glGetVertexAttribPointervARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_fragment_shader: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_fragment_shader', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_shading_language_100: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_shading_language_100', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_texture_non_power_of_two: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_texture_non_power_of_two', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_point_sprite: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_point_sprite', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_depth_bounds_test: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_depth_bounds_test', extstring) then
+ begin
+ @glDepthBoundsEXT := SDL_GL_GetProcAddress('glDepthBoundsEXT');
+ if not Assigned(glDepthBoundsEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_secondary_color: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_secondary_color', extstring) then
+ begin
+ @glSecondaryColor3bEXT := SDL_GL_GetProcAddress('glSecondaryColor3bEXT');
+ if not Assigned(glSecondaryColor3bEXT) then Exit;
+ @glSecondaryColor3sEXT := SDL_GL_GetProcAddress('glSecondaryColor3sEXT');
+ if not Assigned(glSecondaryColor3sEXT) then Exit;
+ @glSecondaryColor3iEXT := SDL_GL_GetProcAddress('glSecondaryColor3iEXT');
+ if not Assigned(glSecondaryColor3iEXT) then Exit;
+ @glSecondaryColor3fEXT := SDL_GL_GetProcAddress('glSecondaryColor3fEXT');
+ if not Assigned(glSecondaryColor3fEXT) then Exit;
+ @glSecondaryColor3dEXT := SDL_GL_GetProcAddress('glSecondaryColor3dEXT');
+ if not Assigned(glSecondaryColor3dEXT) then Exit;
+ @glSecondaryColor3ubEXT := SDL_GL_GetProcAddress('glSecondaryColor3ubEXT');
+ if not Assigned(glSecondaryColor3ubEXT) then Exit;
+ @glSecondaryColor3usEXT := SDL_GL_GetProcAddress('glSecondaryColor3usEXT');
+ if not Assigned(glSecondaryColor3usEXT) then Exit;
+ @glSecondaryColor3uiEXT := SDL_GL_GetProcAddress('glSecondaryColor3uiEXT');
+ if not Assigned(glSecondaryColor3uiEXT) then Exit;
+ @glSecondaryColor3bvEXT := SDL_GL_GetProcAddress('glSecondaryColor3bvEXT');
+ if not Assigned(glSecondaryColor3bvEXT) then Exit;
+ @glSecondaryColor3svEXT := SDL_GL_GetProcAddress('glSecondaryColor3svEXT');
+ if not Assigned(glSecondaryColor3svEXT) then Exit;
+ @glSecondaryColor3ivEXT := SDL_GL_GetProcAddress('glSecondaryColor3ivEXT');
+ if not Assigned(glSecondaryColor3ivEXT) then Exit;
+ @glSecondaryColor3fvEXT := SDL_GL_GetProcAddress('glSecondaryColor3fvEXT');
+ if not Assigned(glSecondaryColor3fvEXT) then Exit;
+ @glSecondaryColor3dvEXT := SDL_GL_GetProcAddress('glSecondaryColor3dvEXT');
+ if not Assigned(glSecondaryColor3dvEXT) then Exit;
+ @glSecondaryColor3ubvEXT := SDL_GL_GetProcAddress('glSecondaryColor3ubvEXT');
+ if not Assigned(glSecondaryColor3ubvEXT) then Exit;
+ @glSecondaryColor3usvEXT := SDL_GL_GetProcAddress('glSecondaryColor3usvEXT');
+ if not Assigned(glSecondaryColor3usvEXT) then Exit;
+ @glSecondaryColor3uivEXT := SDL_GL_GetProcAddress('glSecondaryColor3uivEXT');
+ if not Assigned(glSecondaryColor3uivEXT) then Exit;
+ @glSecondaryColorPointerEXT := SDL_GL_GetProcAddress('glSecondaryColorPointerEXT');
+ if not Assigned(glSecondaryColorPointerEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_texture_mirror_clamp: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_texture_mirror_clamp', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_blend_equation_separate: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_blend_equation_separate', extstring) then
+ begin
+ @glBlendEquationSeparateEXT := SDL_GL_GetProcAddress('glBlendEquationSeparateEXT');
+ if not Assigned(glBlendEquationSeparateEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_MESA_pack_invert: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_MESA_pack_invert', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_MESA_ycbcr_texture: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_MESA_ycbcr_texture', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_fragment_program_shadow: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_ARB_fragment_program_shadow', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_fog_coord: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_fog_coord', extstring) then
+ begin
+ @glFogCoordfEXT := SDL_GL_GetProcAddress('glFogCoordfEXT');
+ if not Assigned(glFogCoordfEXT) then Exit;
+ @glFogCoorddEXT := SDL_GL_GetProcAddress('glFogCoorddEXT');
+ if not Assigned(glFogCoorddEXT) then Exit;
+ @glFogCoordfvEXT := SDL_GL_GetProcAddress('glFogCoordfvEXT');
+ if not Assigned(glFogCoordfvEXT) then Exit;
+ @glFogCoorddvEXT := SDL_GL_GetProcAddress('glFogCoorddvEXT');
+ if not Assigned(glFogCoorddvEXT) then Exit;
+ @glFogCoordPointerEXT := SDL_GL_GetProcAddress('glFogCoordPointerEXT');
+ if not Assigned(glFogCoordPointerEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_fragment_program_option: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_fragment_program_option', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_pixel_buffer_object: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_EXT_pixel_buffer_object', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_fragment_program2: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_fragment_program2', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_vertex_program2_option: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_vertex_program2_option', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_NV_vertex_program3: Boolean;
+var
+ extstring : PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString( GL_EXTENSIONS );
+
+ if glext_ExtensionSupported('GL_NV_vertex_program3', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_draw_buffers: Boolean;
+var
+ extstring: PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString(GL_EXTENSIONS);
+
+ if glext_ExtensionSupported('GL_ARB_draw_buffers', extstring) then
+ begin
+ glDrawBuffersARB := SDL_GL_GetProcAddress('glDrawBuffersARB');
+ if not Assigned(glDrawBuffersARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_texture_rectangle: Boolean;
+var
+ extstring: PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString(GL_EXTENSIONS);
+
+ if glext_ExtensionSupported('GL_ARB_texture_rectangle', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_color_buffer_float: Boolean;
+var
+ extstring: PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString(GL_EXTENSIONS);
+
+ if glext_ExtensionSupported('GL_ARB_color_buffer_float', extstring) then
+ begin
+ glClampColorARB := SDL_GL_GetProcAddress('glClampColorARB');
+ if not Assigned(glClampColorARB) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_half_float_pixel: Boolean;
+var
+ extstring: PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString(GL_EXTENSIONS);
+
+ if glext_ExtensionSupported('GL_ARB_half_float_pixel', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_texture_float: Boolean;
+var
+ extstring: PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString(GL_EXTENSIONS);
+
+ if glext_ExtensionSupported('GL_ARB_texture_float', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_texture_compression_dxt1: Boolean;
+var
+ extstring: PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString(GL_EXTENSIONS);
+
+ if glext_ExtensionSupported('GL_EXT_texture_compression_dxt1', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_ARB_pixel_buffer_object: Boolean;
+var
+ extstring: PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString(GL_EXTENSIONS);
+
+ if glext_ExtensionSupported('GL_ARB_pixel_buffer_object', extstring) then
+ begin
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_EXT_framebuffer_object: Boolean;
+var
+ extstring: PChar;
+begin
+
+ Result := FALSE;
+ extstring := glGetString(GL_EXTENSIONS);
+
+ if glext_ExtensionSupported('GL_EXT_framebuffer_object', extstring) then
+ begin
+ glIsRenderbufferEXT := SDL_GL_GetProcAddress('glIsRenderbufferEXT');
+ if not Assigned(glIsRenderbufferEXT) then Exit;
+ glBindRenderbufferEXT := SDL_GL_GetProcAddress('glBindRenderbufferEXT');
+ if not Assigned(glBindRenderbufferEXT) then Exit;
+ glDeleteRenderbuffersEXT := SDL_GL_GetProcAddress('glDeleteRenderbuffersEXT');
+ if not Assigned(glDeleteRenderbuffersEXT) then Exit;
+ glGenRenderbuffersEXT := SDL_GL_GetProcAddress('glGenRenderbuffersEXT');
+ if not Assigned(glGenRenderbuffersEXT) then Exit;
+ glRenderbufferStorageEXT := SDL_GL_GetProcAddress('glRenderbufferStorageEXT');
+ if not Assigned(glRenderbufferStorageEXT) then Exit;
+ glGetRenderbufferParameterivEXT := SDL_GL_GetProcAddress('glGetRenderbufferParameterivEXT');
+ if not Assigned(glGetRenderbufferParameterivEXT) then Exit;
+ glIsFramebufferEXT := SDL_GL_GetProcAddress('glIsFramebufferEXT');
+ if not Assigned(glIsFramebufferEXT) then Exit;
+ glBindFramebufferEXT := SDL_GL_GetProcAddress('glBindFramebufferEXT');
+ if not Assigned(glBindFramebufferEXT) then Exit;
+ glDeleteFramebuffersEXT := SDL_GL_GetProcAddress('glDeleteFramebuffersEXT');
+ if not Assigned(glDeleteFramebuffersEXT) then Exit;
+ glGenFramebuffersEXT := SDL_GL_GetProcAddress('glGenFramebuffersEXT');
+ if not Assigned(glGenFramebuffersEXT) then Exit;
+ glCheckFramebufferStatusEXT := SDL_GL_GetProcAddress('glCheckFramebufferStatusEXT');
+ if not Assigned(glCheckFramebufferStatusEXT) then Exit;
+ glFramebufferTexture1DEXT := SDL_GL_GetProcAddress('glFramebufferTexture1DEXT');
+ if not Assigned(glFramebufferTexture1DEXT) then Exit;
+ glFramebufferTexture2DEXT := SDL_GL_GetProcAddress('glFramebufferTexture2DEXT');
+ if not Assigned(glFramebufferTexture2DEXT) then Exit;
+ glFramebufferTexture3DEXT := SDL_GL_GetProcAddress('glFramebufferTexture3DEXT');
+ if not Assigned(glFramebufferTexture3DEXT) then Exit;
+ glFramebufferRenderbufferEXT := SDL_GL_GetProcAddress('glFramebufferRenderbufferEXT');
+ if not Assigned(glFramebufferRenderbufferEXT) then Exit;
+ glGetFramebufferAttachmentParameterivEXT := SDL_GL_GetProcAddress('glGetFramebufferAttachmentParameterivEXT');
+ if not Assigned(glGetFramebufferAttachmentParameterivEXT) then Exit;
+ glGenerateMipmapEXT := SDL_GL_GetProcAddress('glGenerateMipmapEXT');
+ if not Assigned(glGenerateMipmapEXT) then Exit;
+ Result := TRUE;
+ end;
+
+end;
+
+function Load_GL_version_1_4: Boolean;
+var
+ extstring: String;
+begin
+
+ Result := FALSE;
+ extstring := String(PChar(glGetString(GL_EXTENSIONS)));
+
+ glBlendFuncSeparate := SDL_GL_GetProcAddress('glBlendFuncSeparate');
+ if not Assigned(glBlendFuncSeparate) then Exit;
+ glFogCoordf := SDL_GL_GetProcAddress('glFogCoordf');
+ if not Assigned(glFogCoordf) then Exit;
+ glFogCoordfv := SDL_GL_GetProcAddress('glFogCoordfv');
+ if not Assigned(glFogCoordfv) then Exit;
+ glFogCoordd := SDL_GL_GetProcAddress('glFogCoordd');
+ if not Assigned(glFogCoordd) then Exit;
+ glFogCoorddv := SDL_GL_GetProcAddress('glFogCoorddv');
+ if not Assigned(glFogCoorddv) then Exit;
+ glFogCoordPointer := SDL_GL_GetProcAddress('glFogCoordPointer');
+ if not Assigned(glFogCoordPointer) then Exit;
+ glMultiDrawArrays := SDL_GL_GetProcAddress('glMultiDrawArrays');
+ if not Assigned(glMultiDrawArrays) then Exit;
+ glMultiDrawElements := SDL_GL_GetProcAddress('glMultiDrawElements');
+ if not Assigned(glMultiDrawElements) then Exit;
+ glPointParameterf := SDL_GL_GetProcAddress('glPointParameterf');
+ if not Assigned(glPointParameterf) then Exit;
+ glPointParameterfv := SDL_GL_GetProcAddress('glPointParameterfv');
+ if not Assigned(glPointParameterfv) then Exit;
+ glPointParameteri := SDL_GL_GetProcAddress('glPointParameteri');
+ if not Assigned(glPointParameteri) then Exit;
+ glPointParameteriv := SDL_GL_GetProcAddress('glPointParameteriv');
+ if not Assigned(glPointParameteriv) then Exit;
+ glSecondaryColor3b := SDL_GL_GetProcAddress('glSecondaryColor3b');
+ if not Assigned(glSecondaryColor3b) then Exit;
+ glSecondaryColor3bv := SDL_GL_GetProcAddress('glSecondaryColor3bv');
+ if not Assigned(glSecondaryColor3bv) then Exit;
+ glSecondaryColor3d := SDL_GL_GetProcAddress('glSecondaryColor3d');
+ if not Assigned(glSecondaryColor3d) then Exit;
+ glSecondaryColor3dv := SDL_GL_GetProcAddress('glSecondaryColor3dv');
+ if not Assigned(glSecondaryColor3dv) then Exit;
+ glSecondaryColor3f := SDL_GL_GetProcAddress('glSecondaryColor3f');
+ if not Assigned(glSecondaryColor3f) then Exit;
+ glSecondaryColor3fv := SDL_GL_GetProcAddress('glSecondaryColor3fv');
+ if not Assigned(glSecondaryColor3fv) then Exit;
+ glSecondaryColor3i := SDL_GL_GetProcAddress('glSecondaryColor3i');
+ if not Assigned(glSecondaryColor3i) then Exit;
+ glSecondaryColor3iv := SDL_GL_GetProcAddress('glSecondaryColor3iv');
+ if not Assigned(glSecondaryColor3iv) then Exit;
+ glSecondaryColor3s := SDL_GL_GetProcAddress('glSecondaryColor3s');
+ if not Assigned(glSecondaryColor3s) then Exit;
+ glSecondaryColor3sv := SDL_GL_GetProcAddress('glSecondaryColor3sv');
+ if not Assigned(glSecondaryColor3sv) then Exit;
+ glSecondaryColor3ub := SDL_GL_GetProcAddress('glSecondaryColor3ub');
+ if not Assigned(glSecondaryColor3ub) then Exit;
+ glSecondaryColor3ubv := SDL_GL_GetProcAddress('glSecondaryColor3ubv');
+ if not Assigned(glSecondaryColor3ubv) then Exit;
+ glSecondaryColor3ui := SDL_GL_GetProcAddress('glSecondaryColor3ui');
+ if not Assigned(glSecondaryColor3ui) then Exit;
+ glSecondaryColor3uiv := SDL_GL_GetProcAddress('glSecondaryColor3uiv');
+ if not Assigned(glSecondaryColor3uiv) then Exit;
+ glSecondaryColor3us := SDL_GL_GetProcAddress('glSecondaryColor3us');
+ if not Assigned(glSecondaryColor3us) then Exit;
+ glSecondaryColor3usv := SDL_GL_GetProcAddress('glSecondaryColor3usv');
+ if not Assigned(glSecondaryColor3usv) then Exit;
+ glSecondaryColorPointer := SDL_GL_GetProcAddress('glSecondaryColorPointer');
+ if not Assigned(glSecondaryColorPointer) then Exit;
+ glWindowPos2d := SDL_GL_GetProcAddress('glWindowPos2d');
+ if not Assigned(glWindowPos2d) then Exit;
+ glWindowPos2dv := SDL_GL_GetProcAddress('glWindowPos2dv');
+ if not Assigned(glWindowPos2dv) then Exit;
+ glWindowPos2f := SDL_GL_GetProcAddress('glWindowPos2f');
+ if not Assigned(glWindowPos2f) then Exit;
+ glWindowPos2fv := SDL_GL_GetProcAddress('glWindowPos2fv');
+ if not Assigned(glWindowPos2fv) then Exit;
+ glWindowPos2i := SDL_GL_GetProcAddress('glWindowPos2i');
+ if not Assigned(glWindowPos2i) then Exit;
+ glWindowPos2iv := SDL_GL_GetProcAddress('glWindowPos2iv');
+ if not Assigned(glWindowPos2iv) then Exit;
+ glWindowPos2s := SDL_GL_GetProcAddress('glWindowPos2s');
+ if not Assigned(glWindowPos2s) then Exit;
+ glWindowPos2sv := SDL_GL_GetProcAddress('glWindowPos2sv');
+ if not Assigned(glWindowPos2sv) then Exit;
+ glWindowPos3d := SDL_GL_GetProcAddress('glWindowPos3d');
+ if not Assigned(glWindowPos3d) then Exit;
+ glWindowPos3dv := SDL_GL_GetProcAddress('glWindowPos3dv');
+ if not Assigned(glWindowPos3dv) then Exit;
+ glWindowPos3f := SDL_GL_GetProcAddress('glWindowPos3f');
+ if not Assigned(glWindowPos3f) then Exit;
+ glWindowPos3fv := SDL_GL_GetProcAddress('glWindowPos3fv');
+ if not Assigned(glWindowPos3fv) then Exit;
+ glWindowPos3i := SDL_GL_GetProcAddress('glWindowPos3i');
+ if not Assigned(glWindowPos3i) then Exit;
+ glWindowPos3iv := SDL_GL_GetProcAddress('glWindowPos3iv');
+ if not Assigned(glWindowPos3iv) then Exit;
+ glWindowPos3s := SDL_GL_GetProcAddress('glWindowPos3s');
+ if not Assigned(glWindowPos3s) then Exit;
+ glWindowPos3sv := SDL_GL_GetProcAddress('glWindowPos3sv');
+ if not Assigned(glWindowPos3sv) then Exit;
+ Result := TRUE;
+
+end;
+
+function Load_GL_version_1_5: Boolean;
+var
+ extstring: String;
+begin
+
+ Result := FALSE;
+ extstring := String(PChar(glGetString(GL_EXTENSIONS)));
+
+ glGenQueries := SDL_GL_GetProcAddress('glGenQueries');
+ if not Assigned(glGenQueries) then Exit;
+ glDeleteQueries := SDL_GL_GetProcAddress('glDeleteQueries');
+ if not Assigned(glDeleteQueries) then Exit;
+ glIsQuery := SDL_GL_GetProcAddress('glIsQuery');
+ if not Assigned(glIsQuery) then Exit;
+ glBeginQuery := SDL_GL_GetProcAddress('glBeginQuery');
+ if not Assigned(glBeginQuery) then Exit;
+ glEndQuery := SDL_GL_GetProcAddress('glEndQuery');
+ if not Assigned(glEndQuery) then Exit;
+ glGetQueryiv := SDL_GL_GetProcAddress('glGetQueryiv');
+ if not Assigned(glGetQueryiv) then Exit;
+ glGetQueryObjectiv := SDL_GL_GetProcAddress('glGetQueryObjectiv');
+ if not Assigned(glGetQueryObjectiv) then Exit;
+ glGetQueryObjectuiv := SDL_GL_GetProcAddress('glGetQueryObjectuiv');
+ if not Assigned(glGetQueryObjectuiv) then Exit;
+ glBindBuffer := SDL_GL_GetProcAddress('glBindBuffer');
+ if not Assigned(glBindBuffer) then Exit;
+ glDeleteBuffers := SDL_GL_GetProcAddress('glDeleteBuffers');
+ if not Assigned(glDeleteBuffers) then Exit;
+ glGenBuffers := SDL_GL_GetProcAddress('glGenBuffers');
+ if not Assigned(glGenBuffers) then Exit;
+ glIsBuffer := SDL_GL_GetProcAddress('glIsBuffer');
+ if not Assigned(glIsBuffer) then Exit;
+ glBufferData := SDL_GL_GetProcAddress('glBufferData');
+ if not Assigned(glBufferData) then Exit;
+ glBufferSubData := SDL_GL_GetProcAddress('glBufferSubData');
+ if not Assigned(glBufferSubData) then Exit;
+ glGetBufferSubData := SDL_GL_GetProcAddress('glGetBufferSubData');
+ if not Assigned(glGetBufferSubData) then Exit;
+ glMapBuffer := SDL_GL_GetProcAddress('glMapBuffer');
+ if not Assigned(glMapBuffer) then Exit;
+ glUnmapBuffer := SDL_GL_GetProcAddress('glUnmapBuffer');
+ if not Assigned(glUnmapBuffer) then Exit;
+ glGetBufferParameteriv := SDL_GL_GetProcAddress('glGetBufferParameteriv');
+ if not Assigned(glGetBufferParameteriv) then Exit;
+ glGetBufferPointerv := SDL_GL_GetProcAddress('glGetBufferPointerv');
+ if not Assigned(glGetBufferPointerv) then Exit;
+ Result := TRUE;
+
+end;
+
+function Load_GL_version_2_0: Boolean;
+var
+ extstring: String;
+begin
+
+ Result := FALSE;
+ extstring := String(PChar(glGetString(GL_EXTENSIONS)));
+
+ glBlendEquationSeparate := SDL_GL_GetProcAddress('glBlendEquationSeparate');
+ if not Assigned(glBlendEquationSeparate) then Exit;
+ glDrawBuffers := SDL_GL_GetProcAddress('glDrawBuffers');
+ if not Assigned(glDrawBuffers) then Exit;
+ glStencilOpSeparate := SDL_GL_GetProcAddress('glStencilOpSeparate');
+ if not Assigned(glStencilOpSeparate) then Exit;
+ glStencilFuncSeparate := SDL_GL_GetProcAddress('glStencilFuncSeparate');
+ if not Assigned(glStencilFuncSeparate) then Exit;
+ glStencilMaskSeparate := SDL_GL_GetProcAddress('glStencilMaskSeparate');
+ if not Assigned(glStencilMaskSeparate) then Exit;
+ glAttachShader := SDL_GL_GetProcAddress('glAttachShader');
+ if not Assigned(glAttachShader) then Exit;
+ glBindAttribLocation := SDL_GL_GetProcAddress('glBindAttribLocation');
+ if not Assigned(glBindAttribLocation) then Exit;
+ glCompileShader := SDL_GL_GetProcAddress('glCompileShader');
+ if not Assigned(glCompileShader) then Exit;
+ glCreateProgram := SDL_GL_GetProcAddress('glCreateProgram');
+ if not Assigned(glCreateProgram) then Exit;
+ glCreateShader := SDL_GL_GetProcAddress('glCreateShader');
+ if not Assigned(glCreateShader) then Exit;
+ glDeleteProgram := SDL_GL_GetProcAddress('glDeleteProgram');
+ if not Assigned(glDeleteProgram) then Exit;
+ glDeleteShader := SDL_GL_GetProcAddress('glDeleteShader');
+ if not Assigned(glDeleteShader) then Exit;
+ glDetachShader := SDL_GL_GetProcAddress('glDetachShader');
+ if not Assigned(glDetachShader) then Exit;
+ glDisableVertexAttribArray := SDL_GL_GetProcAddress('glDisableVertexAttribArray');
+ if not Assigned(glDisableVertexAttribArray) then Exit;
+ glEnableVertexAttribArray := SDL_GL_GetProcAddress('glEnableVertexAttribArray');
+ if not Assigned(glEnableVertexAttribArray) then Exit;
+ glGetActiveAttrib := SDL_GL_GetProcAddress('glGetActiveAttrib');
+ if not Assigned(glGetActiveAttrib) then Exit;
+ glGetActiveUniform := SDL_GL_GetProcAddress('glGetActiveUniform');
+ if not Assigned(glGetActiveUniform) then Exit;
+ glGetAttachedShaders := SDL_GL_GetProcAddress('glGetAttachedShaders');
+ if not Assigned(glGetAttachedShaders) then Exit;
+ glGetAttribLocation := SDL_GL_GetProcAddress('glGetAttribLocation');
+ if not Assigned(glGetAttribLocation) then Exit;
+ glGetProgramiv := SDL_GL_GetProcAddress('glGetProgramiv');
+ if not Assigned(glGetProgramiv) then Exit;
+ glGetProgramInfoLog := SDL_GL_GetProcAddress('glGetProgramInfoLog');
+ if not Assigned(glGetProgramInfoLog) then Exit;
+ glGetShaderiv := SDL_GL_GetProcAddress('glGetShaderiv');
+ if not Assigned(glGetShaderiv) then Exit;
+ glGetShaderInfoLog := SDL_GL_GetProcAddress('glGetShaderInfoLog');
+ if not Assigned(glGetShaderInfoLog) then Exit;
+ glGetShaderSource := SDL_GL_GetProcAddress('glGetShaderSource');
+ if not Assigned(glGetShaderSource) then Exit;
+ glGetUniformLocation := SDL_GL_GetProcAddress('glGetUniformLocation');
+ if not Assigned(glGetUniformLocation) then Exit;
+ glGetUniformfv := SDL_GL_GetProcAddress('glGetUniformfv');
+ if not Assigned(glGetUniformfv) then Exit;
+ glGetUniformiv := SDL_GL_GetProcAddress('glGetUniformiv');
+ if not Assigned(glGetUniformiv) then Exit;
+ glGetVertexAttribdv := SDL_GL_GetProcAddress('glGetVertexAttribdv');
+ if not Assigned(glGetVertexAttribdv) then Exit;
+ glGetVertexAttribfv := SDL_GL_GetProcAddress('glGetVertexAttribfv');
+ if not Assigned(glGetVertexAttribfv) then Exit;
+ glGetVertexAttribiv := SDL_GL_GetProcAddress('glGetVertexAttribiv');
+ if not Assigned(glGetVertexAttribiv) then Exit;
+ glGetVertexAttribPointerv := SDL_GL_GetProcAddress('glGetVertexAttribPointerv');
+ if not Assigned(glGetVertexAttribPointerv) then Exit;
+ glIsProgram := SDL_GL_GetProcAddress('glIsProgram');
+ if not Assigned(glIsProgram) then Exit;
+ glIsShader := SDL_GL_GetProcAddress('glIsShader');
+ if not Assigned(glIsShader) then Exit;
+ glLinkProgram := SDL_GL_GetProcAddress('glLinkProgram');
+ if not Assigned(glLinkProgram) then Exit;
+ glShaderSource := SDL_GL_GetProcAddress('glShaderSource');
+ if not Assigned(glShaderSource) then Exit;
+ glUseProgram := SDL_GL_GetProcAddress('glUseProgram');
+ if not Assigned(glUseProgram) then Exit;
+ glUniform1f := SDL_GL_GetProcAddress('glUniform1f');
+ if not Assigned(glUniform1f) then Exit;
+ glUniform2f := SDL_GL_GetProcAddress('glUniform2f');
+ if not Assigned(glUniform2f) then Exit;
+ glUniform3f := SDL_GL_GetProcAddress('glUniform3f');
+ if not Assigned(glUniform3f) then Exit;
+ glUniform4f := SDL_GL_GetProcAddress('glUniform4f');
+ if not Assigned(glUniform4f) then Exit;
+ glUniform1i := SDL_GL_GetProcAddress('glUniform1i');
+ if not Assigned(glUniform1i) then Exit;
+ glUniform2i := SDL_GL_GetProcAddress('glUniform2i');
+ if not Assigned(glUniform2i) then Exit;
+ glUniform3i := SDL_GL_GetProcAddress('glUniform3i');
+ if not Assigned(glUniform3i) then Exit;
+ glUniform4i := SDL_GL_GetProcAddress('glUniform4i');
+ if not Assigned(glUniform4i) then Exit;
+ glUniform1fv := SDL_GL_GetProcAddress('glUniform1fv');
+ if not Assigned(glUniform1fv) then Exit;
+ glUniform2fv := SDL_GL_GetProcAddress('glUniform2fv');
+ if not Assigned(glUniform2fv) then Exit;
+ glUniform3fv := SDL_GL_GetProcAddress('glUniform3fv');
+ if not Assigned(glUniform3fv) then Exit;
+ glUniform4fv := SDL_GL_GetProcAddress('glUniform4fv');
+ if not Assigned(glUniform4fv) then Exit;
+ glUniform1iv := SDL_GL_GetProcAddress('glUniform1iv');
+ if not Assigned(glUniform1iv) then Exit;
+ glUniform2iv := SDL_GL_GetProcAddress('glUniform2iv');
+ if not Assigned(glUniform2iv) then Exit;
+ glUniform3iv := SDL_GL_GetProcAddress('glUniform3iv');
+ if not Assigned(glUniform3iv) then Exit;
+ glUniform4iv := SDL_GL_GetProcAddress('glUniform4iv');
+ if not Assigned(glUniform4iv) then Exit;
+ glUniformMatrix2fv := SDL_GL_GetProcAddress('glUniformMatrix2fv');
+ if not Assigned(glUniformMatrix2fv) then Exit;
+ glUniformMatrix3fv := SDL_GL_GetProcAddress('glUniformMatrix3fv');
+ if not Assigned(glUniformMatrix3fv) then Exit;
+ glUniformMatrix4fv := SDL_GL_GetProcAddress('glUniformMatrix4fv');
+ if not Assigned(glUniformMatrix4fv) then Exit;
+ glValidateProgram := SDL_GL_GetProcAddress('glValidateProgram');
+ if not Assigned(glValidateProgram) then Exit;
+ glVertexAttrib1d := SDL_GL_GetProcAddress('glVertexAttrib1d');
+ if not Assigned(glVertexAttrib1d) then Exit;
+ glVertexAttrib1dv := SDL_GL_GetProcAddress('glVertexAttrib1dv');
+ if not Assigned(glVertexAttrib1dv) then Exit;
+ glVertexAttrib1f := SDL_GL_GetProcAddress('glVertexAttrib1f');
+ if not Assigned(glVertexAttrib1f) then Exit;
+ glVertexAttrib1fv := SDL_GL_GetProcAddress('glVertexAttrib1fv');
+ if not Assigned(glVertexAttrib1fv) then Exit;
+ glVertexAttrib1s := SDL_GL_GetProcAddress('glVertexAttrib1s');
+ if not Assigned(glVertexAttrib1s) then Exit;
+ glVertexAttrib1sv := SDL_GL_GetProcAddress('glVertexAttrib1sv');
+ if not Assigned(glVertexAttrib1sv) then Exit;
+ glVertexAttrib2d := SDL_GL_GetProcAddress('glVertexAttrib2d');
+ if not Assigned(glVertexAttrib2d) then Exit;
+ glVertexAttrib2dv := SDL_GL_GetProcAddress('glVertexAttrib2dv');
+ if not Assigned(glVertexAttrib2dv) then Exit;
+ glVertexAttrib2f := SDL_GL_GetProcAddress('glVertexAttrib2f');
+ if not Assigned(glVertexAttrib2f) then Exit;
+ glVertexAttrib2fv := SDL_GL_GetProcAddress('glVertexAttrib2fv');
+ if not Assigned(glVertexAttrib2fv) then Exit;
+ glVertexAttrib2s := SDL_GL_GetProcAddress('glVertexAttrib2s');
+ if not Assigned(glVertexAttrib2s) then Exit;
+ glVertexAttrib2sv := SDL_GL_GetProcAddress('glVertexAttrib2sv');
+ if not Assigned(glVertexAttrib2sv) then Exit;
+ glVertexAttrib3d := SDL_GL_GetProcAddress('glVertexAttrib3d');
+ if not Assigned(glVertexAttrib3d) then Exit;
+ glVertexAttrib3dv := SDL_GL_GetProcAddress('glVertexAttrib3dv');
+ if not Assigned(glVertexAttrib3dv) then Exit;
+ glVertexAttrib3f := SDL_GL_GetProcAddress('glVertexAttrib3f');
+ if not Assigned(glVertexAttrib3f) then Exit;
+ glVertexAttrib3fv := SDL_GL_GetProcAddress('glVertexAttrib3fv');
+ if not Assigned(glVertexAttrib3fv) then Exit;
+ glVertexAttrib3s := SDL_GL_GetProcAddress('glVertexAttrib3s');
+ if not Assigned(glVertexAttrib3s) then Exit;
+ glVertexAttrib3sv := SDL_GL_GetProcAddress('glVertexAttrib3sv');
+ if not Assigned(glVertexAttrib3sv) then Exit;
+ glVertexAttrib4Nbv := SDL_GL_GetProcAddress('glVertexAttrib4Nbv');
+ if not Assigned(glVertexAttrib4Nbv) then Exit;
+ glVertexAttrib4Niv := SDL_GL_GetProcAddress('glVertexAttrib4Niv');
+ if not Assigned(glVertexAttrib4Niv) then Exit;
+ glVertexAttrib4Nsv := SDL_GL_GetProcAddress('glVertexAttrib4Nsv');
+ if not Assigned(glVertexAttrib4Nsv) then Exit;
+ glVertexAttrib4Nub := SDL_GL_GetProcAddress('glVertexAttrib4Nub');
+ if not Assigned(glVertexAttrib4Nub) then Exit;
+ glVertexAttrib4Nubv := SDL_GL_GetProcAddress('glVertexAttrib4Nubv');
+ if not Assigned(glVertexAttrib4Nubv) then Exit;
+ glVertexAttrib4Nuiv := SDL_GL_GetProcAddress('glVertexAttrib4Nuiv');
+ if not Assigned(glVertexAttrib4Nuiv) then Exit;
+ glVertexAttrib4Nusv := SDL_GL_GetProcAddress('glVertexAttrib4Nusv');
+ if not Assigned(glVertexAttrib4Nusv) then Exit;
+ glVertexAttrib4bv := SDL_GL_GetProcAddress('glVertexAttrib4bv');
+ if not Assigned(glVertexAttrib4bv) then Exit;
+ glVertexAttrib4d := SDL_GL_GetProcAddress('glVertexAttrib4d');
+ if not Assigned(glVertexAttrib4d) then Exit;
+ glVertexAttrib4dv := SDL_GL_GetProcAddress('glVertexAttrib4dv');
+ if not Assigned(glVertexAttrib4dv) then Exit;
+ glVertexAttrib4f := SDL_GL_GetProcAddress('glVertexAttrib4f');
+ if not Assigned(glVertexAttrib4f) then Exit;
+ glVertexAttrib4fv := SDL_GL_GetProcAddress('glVertexAttrib4fv');
+ if not Assigned(glVertexAttrib4fv) then Exit;
+ glVertexAttrib4iv := SDL_GL_GetProcAddress('glVertexAttrib4iv');
+ if not Assigned(glVertexAttrib4iv) then Exit;
+ glVertexAttrib4s := SDL_GL_GetProcAddress('glVertexAttrib4s');
+ if not Assigned(glVertexAttrib4s) then Exit;
+ glVertexAttrib4sv := SDL_GL_GetProcAddress('glVertexAttrib4sv');
+ if not Assigned(glVertexAttrib4sv) then Exit;
+ glVertexAttrib4ubv := SDL_GL_GetProcAddress('glVertexAttrib4ubv');
+ if not Assigned(glVertexAttrib4ubv) then Exit;
+ glVertexAttrib4uiv := SDL_GL_GetProcAddress('glVertexAttrib4uiv');
+ if not Assigned(glVertexAttrib4uiv) then Exit;
+ glVertexAttrib4usv := SDL_GL_GetProcAddress('glVertexAttrib4usv');
+ if not Assigned(glVertexAttrib4usv) then Exit;
+ glVertexAttribPointer := SDL_GL_GetProcAddress('glVertexAttribPointer');
+ if not Assigned(glVertexAttribPointer) then Exit;
+ Result := TRUE;
+
+end;
+
+function glext_LoadExtension(ext: String): Boolean;
+begin
+
+ Result := FALSE;
+
+ if ext = 'GL_version_1_2' then Result := Load_GL_version_1_2
+ else if ext = 'GL_ARB_imaging' then Result := Load_GL_ARB_imaging
+ else if ext = 'GL_version_1_3' then Result := Load_GL_version_1_3
+ else if ext = 'GL_ARB_multitexture' then Result := Load_GL_ARB_multitexture
+ else if ext = 'GL_ARB_transpose_matrix' then Result := Load_GL_ARB_transpose_matrix
+ else if ext = 'GL_ARB_multisample' then Result := Load_GL_ARB_multisample
+ else if ext = 'GL_ARB_texture_env_add' then Result := Load_GL_ARB_texture_env_add
+ {$IFDEF WINDOWS}
+ else if ext = 'WGL_ARB_extensions_string' then Result := Load_WGL_ARB_extensions_string
+ else if ext = 'WGL_ARB_buffer_region' then Result := Load_WGL_ARB_buffer_region
+ {$ENDIF}
+ else if ext = 'GL_ARB_texture_cube_map' then Result := Load_GL_ARB_texture_cube_map
+ else if ext = 'GL_ARB_depth_texture' then Result := Load_GL_ARB_depth_texture
+ else if ext = 'GL_ARB_point_parameters' then Result := Load_GL_ARB_point_parameters
+ else if ext = 'GL_ARB_shadow' then Result := Load_GL_ARB_shadow
+ else if ext = 'GL_ARB_shadow_ambient' then Result := Load_GL_ARB_shadow_ambient
+ else if ext = 'GL_ARB_texture_border_clamp' then Result := Load_GL_ARB_texture_border_clamp
+ else if ext = 'GL_ARB_texture_compression' then Result := Load_GL_ARB_texture_compression
+ else if ext = 'GL_ARB_texture_env_combine' then Result := Load_GL_ARB_texture_env_combine
+ else if ext = 'GL_ARB_texture_env_crossbar' then Result := Load_GL_ARB_texture_env_crossbar
+ else if ext = 'GL_ARB_texture_env_dot3' then Result := Load_GL_ARB_texture_env_dot3
+ else if ext = 'GL_ARB_texture_mirrored_repeat' then Result := Load_GL_ARB_texture_mirrored_repeat
+ else if ext = 'GL_ARB_vertex_blend' then Result := Load_GL_ARB_vertex_blend
+ else if ext = 'GL_ARB_vertex_program' then Result := Load_GL_ARB_vertex_program
+ else if ext = 'GL_ARB_window_pos' then Result := Load_GL_ARB_window_pos
+ else if ext = 'GL_EXT_422_pixels' then Result := Load_GL_EXT_422_pixels
+ else if ext = 'GL_EXT_abgr' then Result := Load_GL_EXT_abgr
+ else if ext = 'GL_EXT_bgra' then Result := Load_GL_EXT_bgra
+ else if ext = 'GL_EXT_blend_color' then Result := Load_GL_EXT_blend_color
+ else if ext = 'GL_EXT_blend_func_separate' then Result := Load_GL_EXT_blend_func_separate
+ else if ext = 'GL_EXT_blend_logic_op' then Result := Load_GL_EXT_blend_logic_op
+ else if ext = 'GL_EXT_blend_minmax' then Result := Load_GL_EXT_blend_minmax
+ else if ext = 'GL_EXT_blend_subtract' then Result := Load_GL_EXT_blend_subtract
+ else if ext = 'GL_EXT_clip_volume_hint' then Result := Load_GL_EXT_clip_volume_hint
+ else if ext = 'GL_EXT_color_subtable' then Result := Load_GL_EXT_color_subtable
+ else if ext = 'GL_EXT_compiled_vertex_array' then Result := Load_GL_EXT_compiled_vertex_array
+ else if ext = 'GL_EXT_convolution' then Result := Load_GL_EXT_convolution
+ else if ext = 'GL_EXT_histogram' then Result := Load_GL_EXT_histogram
+ else if ext = 'GL_EXT_multi_draw_arrays' then Result := Load_GL_EXT_multi_draw_arrays
+ else if ext = 'GL_EXT_packed_pixels' then Result := Load_GL_EXT_packed_pixels
+ else if ext = 'GL_EXT_paletted_texture' then Result := Load_GL_EXT_paletted_texture
+ else if ext = 'GL_EXT_point_parameters' then Result := Load_GL_EXT_point_parameters
+ else if ext = 'GL_EXT_polygon_offset' then Result := Load_GL_EXT_polygon_offset
+ else if ext = 'GL_EXT_separate_specular_color' then Result := Load_GL_EXT_separate_specular_color
+ else if ext = 'GL_EXT_shadow_funcs' then Result := Load_GL_EXT_shadow_funcs
+ else if ext = 'GL_EXT_shared_texture_palette' then Result := Load_GL_EXT_shared_texture_palette
+ else if ext = 'GL_EXT_stencil_two_side' then Result := Load_GL_EXT_stencil_two_side
+ else if ext = 'GL_EXT_stencil_wrap' then Result := Load_GL_EXT_stencil_wrap
+ else if ext = 'GL_EXT_subtexture' then Result := Load_GL_EXT_subtexture
+ else if ext = 'GL_EXT_texture3D' then Result := Load_GL_EXT_texture3D
+ else if ext = 'GL_EXT_texture_compression_s3tc' then Result := Load_GL_EXT_texture_compression_s3tc
+ else if ext = 'GL_EXT_texture_env_add' then Result := Load_GL_EXT_texture_env_add
+ else if ext = 'GL_EXT_texture_env_combine' then Result := Load_GL_EXT_texture_env_combine
+ else if ext = 'GL_EXT_texture_env_dot3' then Result := Load_GL_EXT_texture_env_dot3
+ else if ext = 'GL_EXT_texture_filter_anisotropic' then Result := Load_GL_EXT_texture_filter_anisotropic
+ else if ext = 'GL_EXT_texture_lod_bias' then Result := Load_GL_EXT_texture_lod_bias
+ else if ext = 'GL_EXT_texture_object' then Result := Load_GL_EXT_texture_object
+ else if ext = 'GL_EXT_vertex_array' then Result := Load_GL_EXT_vertex_array
+ else if ext = 'GL_EXT_vertex_shader' then Result := Load_GL_EXT_vertex_shader
+ else if ext = 'GL_EXT_vertex_weighting' then Result := Load_GL_EXT_vertex_weighting
+ else if ext = 'GL_HP_occlusion_test' then Result := Load_GL_HP_occlusion_test
+ else if ext = 'GL_NV_blend_square' then Result := Load_GL_NV_blend_square
+ else if ext = 'GL_NV_copy_depth_to_color' then Result := Load_GL_NV_copy_depth_to_color
+ else if ext = 'GL_NV_depth_clamp' then Result := Load_GL_NV_depth_clamp
+ else if ext = 'GL_NV_evaluators' then Result := Load_GL_NV_evaluators
+ else if ext = 'GL_NV_fence' then Result := Load_GL_NV_fence
+ else if ext = 'GL_NV_fog_distance' then Result := Load_GL_NV_fog_distance
+ else if ext = 'GL_NV_light_max_exponent' then Result := Load_GL_NV_light_max_exponent
+ else if ext = 'GL_NV_multisample_filter_hint' then Result := Load_GL_NV_multisample_filter_hint
+ else if ext = 'GL_NV_occlusion_query' then Result := Load_GL_NV_occlusion_query
+ else if ext = 'GL_NV_packed_depth_stencil' then Result := Load_GL_NV_packed_depth_stencil
+ else if ext = 'GL_NV_point_sprite' then Result := Load_GL_NV_point_sprite
+ else if ext = 'GL_NV_register_combiners' then Result := Load_GL_NV_register_combiners
+ else if ext = 'GL_NV_register_combiners2' then Result := Load_GL_NV_register_combiners2
+ else if ext = 'GL_NV_texgen_emboss' then Result := Load_GL_NV_texgen_emboss
+ else if ext = 'GL_NV_texgen_reflection' then Result := Load_GL_NV_texgen_reflection
+ else if ext = 'GL_NV_texture_compression_vtc' then Result := Load_GL_NV_texture_compression_vtc
+ else if ext = 'GL_NV_texture_env_combine4' then Result := Load_GL_NV_texture_env_combine4
+ else if ext = 'GL_NV_texture_rectangle' then Result := Load_GL_NV_texture_rectangle
+ else if ext = 'GL_NV_texture_shader' then Result := Load_GL_NV_texture_shader
+ else if ext = 'GL_NV_texture_shader2' then Result := Load_GL_NV_texture_shader2
+ else if ext = 'GL_NV_texture_shader3' then Result := Load_GL_NV_texture_shader3
+ else if ext = 'GL_NV_vertex_array_range' then Result := Load_GL_NV_vertex_array_range
+ else if ext = 'GL_NV_vertex_array_range2' then Result := Load_GL_NV_vertex_array_range2
+ else if ext = 'GL_NV_vertex_program' then Result := Load_GL_NV_vertex_program
+ else if ext = 'GL_NV_vertex_program1_1' then Result := Load_GL_NV_vertex_program1_1
+ else if ext = 'GL_ATI_element_array' then Result := Load_GL_ATI_element_array
+ else if ext = 'GL_ATI_envmap_bumpmap' then Result := Load_GL_ATI_envmap_bumpmap
+ else if ext = 'GL_ATI_fragment_shader' then Result := Load_GL_ATI_fragment_shader
+ else if ext = 'GL_ATI_pn_triangles' then Result := Load_GL_ATI_pn_triangles
+ else if ext = 'GL_ATI_texture_mirror_once' then Result := Load_GL_ATI_texture_mirror_once
+ else if ext = 'GL_ATI_vertex_array_object' then Result := Load_GL_ATI_vertex_array_object
+ else if ext = 'GL_ATI_vertex_streams' then Result := Load_GL_ATI_vertex_streams
+ {$IFDEF WINDOWS}
+ else if ext = 'WGL_I3D_image_buffer' then Result := Load_WGL_I3D_image_buffer
+ else if ext = 'WGL_I3D_swap_frame_lock' then Result := Load_WGL_I3D_swap_frame_lock
+ else if ext = 'WGL_I3D_swap_frame_usage' then Result := Load_WGL_I3D_swap_frame_usage
+ {$ENDIF}
+ else if ext = 'GL_3DFX_texture_compression_FXT1' then Result := Load_GL_3DFX_texture_compression_FXT1
+ else if ext = 'GL_IBM_cull_vertex' then Result := Load_GL_IBM_cull_vertex
+ else if ext = 'GL_IBM_multimode_draw_arrays' then Result := Load_GL_IBM_multimode_draw_arrays
+ else if ext = 'GL_IBM_raster_pos_clip' then Result := Load_GL_IBM_raster_pos_clip
+ else if ext = 'GL_IBM_texture_mirrored_repeat' then Result := Load_GL_IBM_texture_mirrored_repeat
+ else if ext = 'GL_IBM_vertex_array_lists' then Result := Load_GL_IBM_vertex_array_lists
+ else if ext = 'GL_MESA_resize_buffers' then Result := Load_GL_MESA_resize_buffers
+ else if ext = 'GL_MESA_window_pos' then Result := Load_GL_MESA_window_pos
+ else if ext = 'GL_OML_interlace' then Result := Load_GL_OML_interlace
+ else if ext = 'GL_OML_resample' then Result := Load_GL_OML_resample
+ else if ext = 'GL_OML_subsample' then Result := Load_GL_OML_subsample
+ else if ext = 'GL_SGIS_generate_mipmap' then Result := Load_GL_SGIS_generate_mipmap
+ else if ext = 'GL_SGIS_multisample' then Result := Load_GL_SGIS_multisample
+ else if ext = 'GL_SGIS_pixel_texture' then Result := Load_GL_SGIS_pixel_texture
+ else if ext = 'GL_SGIS_texture_border_clamp' then Result := Load_GL_SGIS_texture_border_clamp
+ else if ext = 'GL_SGIS_texture_color_mask' then Result := Load_GL_SGIS_texture_color_mask
+ else if ext = 'GL_SGIS_texture_edge_clamp' then Result := Load_GL_SGIS_texture_edge_clamp
+ else if ext = 'GL_SGIS_texture_lod' then Result := Load_GL_SGIS_texture_lod
+ else if ext = 'GL_SGIS_depth_texture' then Result := Load_GL_SGIS_depth_texture
+ else if ext = 'GL_SGIX_fog_offset' then Result := Load_GL_SGIX_fog_offset
+ else if ext = 'GL_SGIX_interlace' then Result := Load_GL_SGIX_interlace
+ else if ext = 'GL_SGIX_shadow_ambient' then Result := Load_GL_SGIX_shadow_ambient
+ else if ext = 'GL_SGI_color_matrix' then Result := Load_GL_SGI_color_matrix
+ else if ext = 'GL_SGI_color_table' then Result := Load_GL_SGI_color_table
+ else if ext = 'GL_SGI_texture_color_table' then Result := Load_GL_SGI_texture_color_table
+ else if ext = 'GL_SUN_vertex' then Result := Load_GL_SUN_vertex
+ else if ext = 'GL_ARB_fragment_program' then Result := Load_GL_ARB_fragment_program
+ else if ext = 'GL_ATI_text_fragment_shader' then Result := Load_GL_ATI_text_fragment_shader
+ else if ext = 'GL_APPLE_client_storage' then Result := Load_GL_APPLE_client_storage
+ else if ext = 'GL_APPLE_element_array' then Result := Load_GL_APPLE_element_array
+ else if ext = 'GL_APPLE_fence' then Result := Load_GL_APPLE_fence
+ else if ext = 'GL_APPLE_vertex_array_object' then Result := Load_GL_APPLE_vertex_array_object
+ else if ext = 'GL_APPLE_vertex_array_range' then Result := Load_GL_APPLE_vertex_array_range
+ {$IFDEF WINDOWS}
+ else if ext = 'WGL_ARB_pixel_format' then Result := Load_WGL_ARB_pixel_format
+ else if ext = 'WGL_ARB_make_current_read' then Result := Load_WGL_ARB_make_current_read
+ else if ext = 'WGL_ARB_pbuffer' then Result := Load_WGL_ARB_pbuffer
+ else if ext = 'WGL_EXT_swap_control' then Result := Load_WGL_EXT_swap_control
+ else if ext = 'WGL_ARB_render_texture' then Result := Load_WGL_ARB_render_texture
+ else if ext = 'WGL_EXT_extensions_string' then Result := Load_WGL_EXT_extensions_string
+ else if ext = 'WGL_EXT_make_current_read' then Result := Load_WGL_EXT_make_current_read
+ else if ext = 'WGL_EXT_pbuffer' then Result := Load_WGL_EXT_pbuffer
+ else if ext = 'WGL_EXT_pixel_format' then Result := Load_WGL_EXT_pixel_format
+ else if ext = 'WGL_I3D_digital_video_control' then Result := Load_WGL_I3D_digital_video_control
+ else if ext = 'WGL_I3D_gamma' then Result := Load_WGL_I3D_gamma
+ else if ext = 'WGL_I3D_genlock' then Result := Load_WGL_I3D_genlock
+ {$ENDIF}
+ else if ext = 'GL_ARB_matrix_palette' then Result := Load_GL_ARB_matrix_palette
+ else if ext = 'GL_NV_element_array' then Result := Load_GL_NV_element_array
+ else if ext = 'GL_NV_float_buffer' then Result := Load_GL_NV_float_buffer
+ else if ext = 'GL_NV_fragment_program' then Result := Load_GL_NV_fragment_program
+ else if ext = 'GL_NV_primitive_restart' then Result := Load_GL_NV_primitive_restart
+ else if ext = 'GL_NV_vertex_program2' then Result := Load_GL_NV_vertex_program2
+ {$IFDEF WINDOWS}
+ else if ext = 'WGL_NV_render_texture_rectangle' then Result := Load_WGL_NV_render_texture_rectangle
+ {$ENDIF}
+ else if ext = 'GL_NV_pixel_data_range' then Result := Load_GL_NV_pixel_data_range
+ else if ext = 'GL_EXT_texture_rectangle' then Result := Load_GL_EXT_texture_rectangle
+ else if ext = 'GL_S3_s3tc' then Result := Load_GL_S3_s3tc
+ else if ext = 'GL_ATI_draw_buffers' then Result := Load_GL_ATI_draw_buffers
+ {$IFDEF WINDOWS}
+ else if ext = 'WGL_ATI_pixel_format_float' then Result := Load_WGL_ATI_pixel_format_float
+ {$ENDIF}
+ else if ext = 'GL_ATI_texture_env_combine3' then Result := Load_GL_ATI_texture_env_combine3
+ else if ext = 'GL_ATI_texture_float' then Result := Load_GL_ATI_texture_float
+ else if ext = 'GL_NV_texture_expand_normal' then Result := Load_GL_NV_texture_expand_normal
+ else if ext = 'GL_NV_half_float' then Result := Load_GL_NV_half_float
+ else if ext = 'GL_ATI_map_object_buffer' then Result := Load_GL_ATI_map_object_buffer
+ else if ext = 'GL_ATI_separate_stencil' then Result := Load_GL_ATI_separate_stencil
+ else if ext = 'GL_ATI_vertex_attrib_array_object' then Result := Load_GL_ATI_vertex_attrib_array_object
+ else if ext = 'GL_ARB_vertex_buffer_object' then Result := Load_GL_ARB_vertex_buffer_object
+ else if ext = 'GL_ARB_occlusion_query' then Result := Load_GL_ARB_occlusion_query
+ else if ext = 'GL_ARB_shader_objects' then Result := Load_GL_ARB_shader_objects
+ else if ext = 'GL_ARB_vertex_shader' then Result := Load_GL_ARB_vertex_shader
+ else if ext = 'GL_ARB_fragment_shader' then Result := Load_GL_ARB_fragment_shader
+ else if ext = 'GL_ARB_shading_language_100' then Result := Load_GL_ARB_shading_language_100
+ else if ext = 'GL_ARB_texture_non_power_of_two' then Result := Load_GL_ARB_texture_non_power_of_two
+ else if ext = 'GL_ARB_point_sprite' then Result := Load_GL_ARB_point_sprite
+ else if ext = 'GL_EXT_depth_bounds_test' then Result := Load_GL_EXT_depth_bounds_test
+ else if ext = 'GL_EXT_secondary_color' then Result := Load_GL_EXT_secondary_color
+ else if ext = 'GL_EXT_texture_mirror_clamp' then Result := Load_GL_EXT_texture_mirror_clamp
+ else if ext = 'GL_EXT_blend_equation_separate' then Result := Load_GL_EXT_blend_equation_separate
+ else if ext = 'GL_MESA_pack_invert' then Result := Load_GL_MESA_pack_invert
+ else if ext = 'GL_MESA_ycbcr_texture' then Result := Load_GL_MESA_ycbcr_texture
+ else if ext = 'GL_ARB_fragment_program_shadow' then Result := Load_GL_ARB_fragment_program_shadow
+ else if ext = 'GL_EXT_fog_coord' then Result := Load_GL_EXT_fog_coord
+ else if ext = 'GL_NV_fragment_program_option' then Result := Load_GL_NV_fragment_program_option
+ else if ext = 'GL_EXT_pixel_buffer_object' then Result := Load_GL_EXT_pixel_buffer_object
+ else if ext = 'GL_NV_fragment_program2' then Result := Load_GL_NV_fragment_program2
+ else if ext = 'GL_NV_vertex_program2_option' then Result := Load_GL_NV_vertex_program2_option
+ else if ext = 'GL_NV_vertex_program3' then Result := Load_GL_NV_vertex_program3
+ else if ext = 'GL_ARB_draw_buffers' then Result := Load_GL_ARB_draw_buffers
+ else if ext = 'GL_ARB_texture_rectangle' then Result := Load_GL_ARB_texture_rectangle
+ else if ext = 'GL_ARB_color_buffer_float' then Result := Load_GL_ARB_color_buffer_float
+ else if ext = 'GL_ARB_half_float_pixel' then Result := Load_GL_ARB_half_float_pixel
+ else if ext = 'GL_ARB_texture_float' then Result := Load_GL_ARB_texture_float
+ else if ext = 'GL_EXT_texture_compression_dxt1' then Result := Load_GL_EXT_texture_compression_dxt1
+ else if ext = 'GL_ARB_pixel_buffer_object' then Result := Load_GL_ARB_pixel_buffer_object
+ else if ext = 'GL_EXT_framebuffer_object' then Result := Load_GL_EXT_framebuffer_object
+ else if ext = 'GL_version_1_4' then Result := Load_GL_version_1_4
+ else if ext = 'GL_version_1_5' then Result := Load_GL_version_1_5
+ else if ext = 'GL_version_2_0' then Result := Load_GL_version_2_0
+
+end;
+
+end.
diff --git a/Game/Code/lib/JEDI-SDL/OpenGL/Pas/glu.pas b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/glu.pas new file mode 100644 index 00000000..371ccdda --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/glu.pas @@ -0,0 +1,582 @@ +unit glu;
+{
+ $Id: glu.pas,v 1.8 2007/05/20 20:28:31 savage Exp $
+
+ Adaption of the delphi3d.net OpenGL units to FreePascal
+ Sebastian Guenther (sg@freepascal.org) in 2002
+ These units are free to use
+}
+
+(*++ BUILD Version: 0004 // Increment this if a change has global effects
+
+Copyright (c) 1985-95, Microsoft Corporation
+
+Module Name:
+
+ glu.h
+
+Abstract:
+
+ Procedure declarations, constant definitions and macros for the OpenGL
+ Utility Library.
+
+--*)
+
+(*
+** Copyright 1991-1993, Silicon Graphics, Inc.
+** All Rights Reserved.
+**
+** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
+** the contents of this file may not be disclosed to third parties, copied or
+** duplicated in any form, in whole or in part, without the prior written
+** permission of Silicon Graphics, Inc.
+**
+** RESTRICTED RIGHTS LEGEND:
+** Use, duplication or disclosure by the Government is subject to restrictions
+** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
+** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
+** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
+** rights reserved under the Copyright Laws of the United States.
+*)
+
+(*
+** Return the error string associated with a particular error code.
+** This will return 0 for an invalid error code.
+**
+** The generic function prototype that can be compiled for ANSI or Unicode
+** is defined as follows:
+**
+** LPCTSTR APIENTRY gluErrorStringWIN (GLenum errCode);
+*)
+
+{******************************************************************************}
+{ }
+{ Converted to Delphi by Tom Nuydens (tom@delphi3d.net) }
+{ For the latest updates, visit Delphi3D: http://www.delphi3d.net }
+{ }
+{ Modified for Delphi/Kylix and FreePascal }
+{ by Dominique Louis ( Dominique@Savagesoftware.com.au) }
+{ For the latest updates, visit JEDI-SDL : http://www.sf.net/projects/jedi-sdl }
+{ }
+{******************************************************************************}
+
+{
+ $Log: glu.pas,v $
+ Revision 1.8 2007/05/20 20:28:31 savage
+ Initial Changes to Handle 64 Bits
+
+ Revision 1.7 2006/11/26 16:35:49 savage
+ Messed up the last change to GLUtessCombineDataProc, had to reapply it. Thanks Michalis.
+
+ Revision 1.6 2006/11/25 23:38:02 savage
+ Changes as proposed by Michalis Kamburelis for better FPC support
+
+ Revision 1.5 2006/11/20 21:20:59 savage
+ Updated to work in MacOS X
+
+ Revision 1.4 2005/05/22 18:52:09 savage
+ Changes as suggested by Michalis Kamburelis. Thanks again.
+
+ Revision 1.3 2004/10/07 21:01:29 savage
+ Fix for FPC
+
+ Revision 1.2 2004/08/14 22:54:30 savage
+ Updated so that Library name defines are correctly defined for MacOS X.
+
+ Revision 1.1 2004/03/30 21:53:54 savage
+ Moved to it's own folder.
+
+ Revision 1.4 2004/02/20 17:09:55 savage
+ Code tidied up in gl, glu and glut, while extensions in glext.pas are now loaded using SDL_GL_GetProcAddress, thus making it more cross-platform compatible, but now more tied to SDL.
+
+ Revision 1.3 2004/02/14 00:23:39 savage
+ As UNIX is defined in jedi-sdl.inc this will be used to check linux compatability as well. Units have been changed to reflect this change.
+
+ Revision 1.2 2004/02/14 00:09:19 savage
+ Changed uses to now make use of moduleloader.pas rather than dllfuncs.pas
+
+ Revision 1.1 2004/02/05 00:08:19 savage
+ Module 1.0 release
+
+ Revision 1.4 2003/06/02 12:32:13 savage
+ Modified Sources to avoid warnings with Delphi by moving CVS Logging to the top of the header files. Hopefully CVS Logging still works.
+
+ Revision 1.3 2003/05/29 22:55:00 savage
+ Make use of new DLLFunctions
+
+ Revision 1.2 2003/05/27 09:39:53 savage
+ Added better Gnu Pascal support.
+
+ Revision 1.1 2003/05/11 13:18:03 savage
+ Newest OpenGL Headers For Delphi, Kylix and FPC
+
+ Revision 1.2 2002/10/13 14:36:47 sg
+ * Win32 fix: The OS symbol is called "Win32", not "Windows"
+
+ Revision 1.1 2002/10/13 13:57:31 sg
+ * Finally, the new units are available: Match the C headers more closely;
+ support for OpenGL extensions, and much more. Based on the Delphi units
+ by Tom Nuydens of delphi3d.net
+
+}
+
+interface
+
+{$I jedi-sdl.inc}
+
+uses
+{$IFDEF __GPC__}
+ gpc,
+{$ENDIF}
+ moduleloader,
+ gl;
+
+const
+{$IFDEF WINDOWS}
+ GLuLibName = 'glu32.dll';
+{$ENDIF}
+
+{$IFDEF UNIX}
+{$IFDEF DARWIN}
+ GLuLibName = '/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib';
+{$ELSE}
+ GLuLibName = 'libGLU.so';
+{$ENDIF}
+{$ENDIF}
+
+type
+ TViewPortArray = array[ 0..3 ] of GLint;
+ T16dArray = array[ 0..15 ] of GLdouble;
+ TCallBack = procedure;
+ T3dArray = array[ 0..2 ] of GLdouble;
+ T4pArray = array[ 0..3 ] of Pointer;
+ T4fArray = array[ 0..3 ] of GLfloat;
+{$IFNDEF __GPC__}
+ PPointer = ^Pointer;
+{$ENDIF}
+
+var
+ gluErrorString : function( errCode : GLenum ) : PChar; {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluErrorUnicodeStringEXT : function( errCode : GLenum ) : PWideChar; {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluGetString : function( name : GLenum ) : PChar; {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluOrtho2D : procedure( left, right, bottom, top : GLdouble ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluPerspective : procedure( fovy, aspect, zNear, zFar : GLdouble ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluPickMatrix : procedure( x, y, width, height : GLdouble; var viewport : TViewPortArray ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluLookAt : procedure( eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz : GLdouble ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluProject : function( objx, objy, objz : GLdouble; var modelMatrix, projMatrix : T16dArray; var viewport : TViewPortArray; winx, winy, winz : PGLdouble ) : Integer; {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluUnProject : function( winx, winy, winz : GLdouble; var modelMatrix, projMatrix : T16dArray; var viewport : TViewPortArray; objx, objy, objz : PGLdouble ) : Integer; {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluScaleImage : function( format : GLenum; widthin, heightin : GLint; typein : GLenum; const datain : Pointer; widthout, heightout : GLint; typeout : GLenum; dataout : Pointer ) : Integer; {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluBuild1DMipmaps : function( target : GLenum; components, width : GLint; format, atype : GLenum; const data : Pointer ) : Integer; {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluBuild2DMipmaps : function( target : GLenum; components, width, height : GLint; format, atype : GLenum; const data : Pointer ) : Integer; {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+
+type
+ GLUnurbs = record
+ end; PGLUnurbs = ^GLUnurbs;
+ GLUquadric = record
+ end; PGLUquadric = ^GLUquadric;
+ GLUtesselator = record
+ end; PGLUtesselator = ^GLUtesselator;
+
+ // backwards compatibility:
+ GLUnurbsObj = GLUnurbs; PGLUnurbsObj = PGLUnurbs;
+ GLUquadricObj = GLUquadric; PGLUquadricObj = PGLUquadric;
+ GLUtesselatorObj = GLUtesselator; PGLUtesselatorObj = PGLUtesselator;
+ GLUtriangulatorObj = GLUtesselator; PGLUtriangulatorObj = PGLUtesselator;
+
+var
+ gluNewQuadric : function : PGLUquadric; {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluDeleteQuadric : procedure( state : PGLUquadric ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluQuadricNormals : procedure( quadObject : PGLUquadric; normals : GLenum ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluQuadricTexture : procedure( quadObject : PGLUquadric; textureCoords : GLboolean ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluQuadricOrientation : procedure( quadObject : PGLUquadric; orientation : GLenum ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluQuadricDrawStyle : procedure( quadObject : PGLUquadric; drawStyle : GLenum ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluCylinder : procedure( qobj : PGLUquadric; baseRadius, topRadius, height : GLdouble; slices, stacks : GLint ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluDisk : procedure( qobj : PGLUquadric; innerRadius, outerRadius : GLdouble; slices, loops : GLint ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluPartialDisk : procedure( qobj : PGLUquadric; innerRadius, outerRadius : GLdouble; slices, loops : GLint; startAngle, sweepAngle : GLdouble ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluSphere : procedure( qobj : PGLuquadric; radius : GLdouble; slices, stacks : GLint ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluQuadricCallback : procedure( qobj : PGLUquadric; which : GLenum; fn : TCallBack ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluNewTess : function : PGLUtesselator; {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluDeleteTess : procedure( tess : PGLUtesselator ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluTessBeginPolygon : procedure( tess : PGLUtesselator; polygon_data : Pointer ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluTessBeginContour : procedure( tess : PGLUtesselator ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluTessVertex : procedure( tess : PGLUtesselator; var coords : T3dArray; data : Pointer ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluTessEndContour : procedure( tess : PGLUtesselator ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluTessEndPolygon : procedure( tess : PGLUtesselator ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluTessProperty : procedure( tess : PGLUtesselator; which : GLenum; value : GLdouble ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluTessNormal : procedure( tess : PGLUtesselator; x, y, z : GLdouble ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluTessCallback : procedure( tess : PGLUtesselator; which : GLenum; fn : TCallBack ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluGetTessProperty : procedure( tess : PGLUtesselator; which : GLenum; value : PGLdouble ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluNewNurbsRenderer : function : PGLUnurbs; {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluDeleteNurbsRenderer : procedure( nobj : PGLUnurbs ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluBeginSurface : procedure( nobj : PGLUnurbs ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluBeginCurve : procedure( nobj : PGLUnurbs ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluEndCurve : procedure( nobj : PGLUnurbs ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluEndSurface : procedure( nobj : PGLUnurbs ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluBeginTrim : procedure( nobj : PGLUnurbs ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluEndTrim : procedure( nobj : PGLUnurbs ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluPwlCurve : procedure( nobj : PGLUnurbs; count : GLint; aarray : PGLfloat; stride : GLint; atype : GLenum ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluNurbsCurve : procedure( nobj : PGLUnurbs; nknots : GLint; knot : PGLfloat; stride : GLint; ctlarray : PGLfloat; order : GLint; atype : GLenum ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluNurbsSurface : procedure( nobj : PGLUnurbs; sknot_count : GLint; sknot : PGLfloat; tknot_count : GLint; tknot : PGLfloat; s_stride, t_stride : GLint; ctlarray : PGLfloat; sorder, torder : GLint; atype : GLenum ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluLoadSamplingMatrices : procedure( nobj : PGLUnurbs; var modelMatrix, projMatrix : T16dArray; var viewport : TViewPortArray ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluNurbsProperty : procedure( nobj : PGLUnurbs; aproperty : GLenum; value : GLfloat ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluGetNurbsProperty : procedure( nobj : PGLUnurbs; aproperty : GLenum; value : PGLfloat ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluNurbsCallback : procedure( nobj : PGLUnurbs; which : GLenum; fn : TCallBack ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+
+(**** Callback function prototypes ****)
+
+type
+ // gluQuadricCallback
+ GLUquadricErrorProc = procedure( p : GLenum ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+
+ // gluTessCallback
+ GLUtessBeginProc = procedure( p : GLenum ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ GLUtessEdgeFlagProc = procedure( p : GLboolean ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ GLUtessVertexProc = procedure( p : Pointer ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ GLUtessEndProc = procedure; {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ GLUtessErrorProc = procedure( p : GLenum ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ GLUtessCombineProc = procedure( var p1 : T3dArray; p2 : T4pArray; p3 : T4fArray; p4 : PPointer ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ GLUtessBeginDataProc = procedure( p1 : GLenum; p2 : Pointer ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ GLUtessEdgeFlagDataProc = procedure( p1 : GLboolean; p2 : Pointer ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ GLUtessVertexDataProc = procedure( p1, p2 : Pointer ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ GLUtessEndDataProc = procedure( p : Pointer ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ GLUtessErrorDataProc = procedure( p1 : GLenum; p2 : Pointer ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ GLUtessCombineDataProc = procedure( var p1 : T3dArray; var p2 : T4pArray; var p3 : T4fArray;
+ p4 : PPointer; p5 : Pointer ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+
+ // gluNurbsCallback
+ GLUnurbsErrorProc = procedure( p : GLenum ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+
+
+//*** Generic constants ****/
+
+const
+ // Version
+ GLU_VERSION_1_1 = 1;
+ GLU_VERSION_1_2 = 1;
+
+ // Errors: (return value 0 = no error)
+ GLU_INVALID_ENUM = 100900;
+ GLU_INVALID_VALUE = 100901;
+ GLU_OUT_OF_MEMORY = 100902;
+ GLU_INCOMPATIBLE_GL_VERSION = 100903;
+
+ // StringName
+ GLU_VERSION = 100800;
+ GLU_EXTENSIONS = 100801;
+
+ // Boolean
+ GLU_TRUE = GL_TRUE;
+ GLU_FALSE = GL_FALSE;
+
+
+ //*** Quadric constants ****/
+
+ // QuadricNormal
+ GLU_SMOOTH = 100000;
+ GLU_FLAT = 100001;
+ GLU_NONE = 100002;
+
+ // QuadricDrawStyle
+ GLU_POINT = 100010;
+ GLU_LINE = 100011;
+ GLU_FILL = 100012;
+ GLU_SILHOUETTE = 100013;
+
+ // QuadricOrientation
+ GLU_OUTSIDE = 100020;
+ GLU_INSIDE = 100021;
+
+ // Callback types:
+ // GLU_ERROR = 100103;
+
+
+ //*** Tesselation constants ****/
+
+ GLU_TESS_MAX_COORD = 1.0E150;
+
+ // TessProperty
+ GLU_TESS_WINDING_RULE = 100140;
+ GLU_TESS_BOUNDARY_ONLY = 100141;
+ GLU_TESS_TOLERANCE = 100142;
+
+ // TessWinding
+ GLU_TESS_WINDING_ODD = 100130;
+ GLU_TESS_WINDING_NONZERO = 100131;
+ GLU_TESS_WINDING_POSITIVE = 100132;
+ GLU_TESS_WINDING_NEGATIVE = 100133;
+ GLU_TESS_WINDING_ABS_GEQ_TWO = 100134;
+
+ // TessCallback
+ GLU_TESS_BEGIN = 100100; // void (CALLBACK*)(GLenum type)
+ GLU_TESS_VERTEX = 100101; // void (CALLBACK*)(void *data)
+ GLU_TESS_END = 100102; // void (CALLBACK*)(void)
+ GLU_TESS_ERROR = 100103; // void (CALLBACK*)(GLenum errno)
+ GLU_TESS_EDGE_FLAG = 100104; // void (CALLBACK*)(GLboolean boundaryEdge)
+ GLU_TESS_COMBINE = 100105; { void (CALLBACK*)(GLdouble coords[3],
+ void *data[4],
+ GLfloat weight[4],
+ void **dataOut) }
+ GLU_TESS_BEGIN_DATA = 100106; { void (CALLBACK*)(GLenum type,
+ void *polygon_data) }
+ GLU_TESS_VERTEX_DATA = 100107; { void (CALLBACK*)(void *data,
+ void *polygon_data) }
+ GLU_TESS_END_DATA = 100108; // void (CALLBACK*)(void *polygon_data)
+ GLU_TESS_ERROR_DATA = 100109; { void (CALLBACK*)(GLenum errno,
+ void *polygon_data) }
+ GLU_TESS_EDGE_FLAG_DATA = 100110; { void (CALLBACK*)(GLboolean boundaryEdge,
+ void *polygon_data) }
+ GLU_TESS_COMBINE_DATA = 100111; { void (CALLBACK*)(GLdouble coords[3],
+ void *data[4],
+ GLfloat weight[4],
+ void **dataOut,
+ void *polygon_data) }
+
+ // TessError
+ GLU_TESS_ERROR1 = 100151;
+ GLU_TESS_ERROR2 = 100152;
+ GLU_TESS_ERROR3 = 100153;
+ GLU_TESS_ERROR4 = 100154;
+ GLU_TESS_ERROR5 = 100155;
+ GLU_TESS_ERROR6 = 100156;
+ GLU_TESS_ERROR7 = 100157;
+ GLU_TESS_ERROR8 = 100158;
+
+ GLU_TESS_MISSING_BEGIN_POLYGON = GLU_TESS_ERROR1;
+ GLU_TESS_MISSING_BEGIN_CONTOUR = GLU_TESS_ERROR2;
+ GLU_TESS_MISSING_END_POLYGON = GLU_TESS_ERROR3;
+ GLU_TESS_MISSING_END_CONTOUR = GLU_TESS_ERROR4;
+ GLU_TESS_COORD_TOO_LARGE = GLU_TESS_ERROR5;
+ GLU_TESS_NEED_COMBINE_CALLBACK = GLU_TESS_ERROR6;
+
+ //*** NURBS constants ****/
+
+ // NurbsProperty
+ GLU_AUTO_LOAD_MATRIX = 100200;
+ GLU_CULLING = 100201;
+ GLU_SAMPLING_TOLERANCE = 100203;
+ GLU_DISPLAY_MODE = 100204;
+ GLU_PARAMETRIC_TOLERANCE = 100202;
+ GLU_SAMPLING_METHOD = 100205;
+ GLU_U_STEP = 100206;
+ GLU_V_STEP = 100207;
+
+ // NurbsSampling
+ GLU_PATH_LENGTH = 100215;
+ GLU_PARAMETRIC_ERROR = 100216;
+ GLU_DOMAIN_DISTANCE = 100217;
+
+
+ // NurbsTrim
+ GLU_MAP1_TRIM_2 = 100210;
+ GLU_MAP1_TRIM_3 = 100211;
+
+ // NurbsDisplay
+ // GLU_FILL = 100012;
+ GLU_OUTLINE_POLYGON = 100240;
+ GLU_OUTLINE_PATCH = 100241;
+
+ // NurbsCallback
+ // GLU_ERROR = 100103;
+
+ // NurbsErrors
+ GLU_NURBS_ERROR1 = 100251;
+ GLU_NURBS_ERROR2 = 100252;
+ GLU_NURBS_ERROR3 = 100253;
+ GLU_NURBS_ERROR4 = 100254;
+ GLU_NURBS_ERROR5 = 100255;
+ GLU_NURBS_ERROR6 = 100256;
+ GLU_NURBS_ERROR7 = 100257;
+ GLU_NURBS_ERROR8 = 100258;
+ GLU_NURBS_ERROR9 = 100259;
+ GLU_NURBS_ERROR10 = 100260;
+ GLU_NURBS_ERROR11 = 100261;
+ GLU_NURBS_ERROR12 = 100262;
+ GLU_NURBS_ERROR13 = 100263;
+ GLU_NURBS_ERROR14 = 100264;
+ GLU_NURBS_ERROR15 = 100265;
+ GLU_NURBS_ERROR16 = 100266;
+ GLU_NURBS_ERROR17 = 100267;
+ GLU_NURBS_ERROR18 = 100268;
+ GLU_NURBS_ERROR19 = 100269;
+ GLU_NURBS_ERROR20 = 100270;
+ GLU_NURBS_ERROR21 = 100271;
+ GLU_NURBS_ERROR22 = 100272;
+ GLU_NURBS_ERROR23 = 100273;
+ GLU_NURBS_ERROR24 = 100274;
+ GLU_NURBS_ERROR25 = 100275;
+ GLU_NURBS_ERROR26 = 100276;
+ GLU_NURBS_ERROR27 = 100277;
+ GLU_NURBS_ERROR28 = 100278;
+ GLU_NURBS_ERROR29 = 100279;
+ GLU_NURBS_ERROR30 = 100280;
+ GLU_NURBS_ERROR31 = 100281;
+ GLU_NURBS_ERROR32 = 100282;
+ GLU_NURBS_ERROR33 = 100283;
+ GLU_NURBS_ERROR34 = 100284;
+ GLU_NURBS_ERROR35 = 100285;
+ GLU_NURBS_ERROR36 = 100286;
+ GLU_NURBS_ERROR37 = 100287;
+
+//*** Backwards compatibility for old tesselator ****/
+
+var
+ gluBeginPolygon : procedure( tess : PGLUtesselator ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluNextContour : procedure( tess : PGLUtesselator; atype : GLenum ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+ gluEndPolygon : procedure( tess : PGLUtesselator ); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF}
+
+const
+ // Contours types -- obsolete!
+ GLU_CW = 100120;
+ GLU_CCW = 100121;
+ GLU_INTERIOR = 100122;
+ GLU_EXTERIOR = 100123;
+ GLU_UNKNOWN = 100124;
+
+ // Names without "TESS_" prefix
+ GLU_BEGIN = GLU_TESS_BEGIN;
+ GLU_VERTEX = GLU_TESS_VERTEX;
+ GLU_END = GLU_TESS_END;
+ GLU_ERROR = GLU_TESS_ERROR;
+ GLU_EDGE_FLAG = GLU_TESS_EDGE_FLAG;
+
+procedure LoadGLu( const dll : PChar );
+procedure FreeGLu;
+
+implementation
+
+var
+ LibGlu : TModuleHandle;
+
+procedure FreeGLu;
+begin
+
+ @gluErrorString := nil;
+ @gluErrorUnicodeStringEXT := nil;
+ @gluGetString := nil;
+ @gluOrtho2D := nil;
+ @gluPerspective := nil;
+ @gluPickMatrix := nil;
+ @gluLookAt := nil;
+ @gluProject := nil;
+ @gluUnProject := nil;
+ @gluScaleImage := nil;
+ @gluBuild1DMipmaps := nil;
+ @gluBuild2DMipmaps := nil;
+ @gluNewQuadric := nil;
+ @gluDeleteQuadric := nil;
+ @gluQuadricNormals := nil;
+ @gluQuadricTexture := nil;
+ @gluQuadricOrientation := nil;
+ @gluQuadricDrawStyle := nil;
+ @gluCylinder := nil;
+ @gluDisk := nil;
+ @gluPartialDisk := nil;
+ @gluSphere := nil;
+ @gluQuadricCallback := nil;
+ @gluNewTess := nil;
+ @gluDeleteTess := nil;
+ @gluTessBeginPolygon := nil;
+ @gluTessBeginContour := nil;
+ @gluTessVertex := nil;
+ @gluTessEndContour := nil;
+ @gluTessEndPolygon := nil;
+ @gluTessProperty := nil;
+ @gluTessNormal := nil;
+ @gluTessCallback := nil;
+ @gluGetTessProperty := nil;
+ @gluNewNurbsRenderer := nil;
+ @gluDeleteNurbsRenderer := nil;
+ @gluBeginSurface := nil;
+ @gluBeginCurve := nil;
+ @gluEndCurve := nil;
+ @gluEndSurface := nil;
+ @gluBeginTrim := nil;
+ @gluEndTrim := nil;
+ @gluPwlCurve := nil;
+ @gluNurbsCurve := nil;
+ @gluNurbsSurface := nil;
+ @gluLoadSamplingMatrices := nil;
+ @gluNurbsProperty := nil;
+ @gluGetNurbsProperty := nil;
+ @gluNurbsCallback := nil;
+ @gluBeginPolygon := nil;
+ @gluNextContour := nil;
+ @gluEndPolygon := nil;
+
+ UnLoadModule( LibGlu );
+
+end;
+
+procedure LoadGLu( const dll : PChar );
+begin
+
+ FreeGLu;
+
+ if LoadModule( LibGlu, dll ) then
+ begin
+ @gluErrorString := GetModuleSymbol( LibGlu, 'gluErrorString' );
+ @gluErrorUnicodeStringEXT := GetModuleSymbol( LibGlu, 'gluErrorUnicodeStringEXT' );
+ @gluGetString := GetModuleSymbol( LibGlu, 'gluGetString' );
+ @gluOrtho2D := GetModuleSymbol( LibGlu, 'gluOrtho2D' );
+ @gluPerspective := GetModuleSymbol( LibGlu, 'gluPerspective' );
+ @gluPickMatrix := GetModuleSymbol( LibGlu, 'gluPickMatrix' );
+ @gluLookAt := GetModuleSymbol( LibGlu, 'gluLookAt' );
+ @gluProject := GetModuleSymbol( LibGlu, 'gluProject' );
+ @gluUnProject := GetModuleSymbol( LibGlu, 'gluUnProject' );
+ @gluScaleImage := GetModuleSymbol( LibGlu, 'gluScaleImage' );
+ @gluBuild1DMipmaps := GetModuleSymbol( LibGlu, 'gluBuild1DMipmaps' );
+ @gluBuild2DMipmaps := GetModuleSymbol( LibGlu, 'gluBuild2DMipmaps' );
+ @gluNewQuadric := GetModuleSymbol( LibGlu, 'gluNewQuadric' );
+ @gluDeleteQuadric := GetModuleSymbol( LibGlu, 'gluDeleteQuadric' );
+ @gluQuadricNormals := GetModuleSymbol( LibGlu, 'gluQuadricNormals' );
+ @gluQuadricTexture := GetModuleSymbol( LibGlu, 'gluQuadricTexture' );
+ @gluQuadricOrientation := GetModuleSymbol( LibGlu, 'gluQuadricOrientation' );
+ @gluQuadricDrawStyle := GetModuleSymbol( LibGlu, 'gluQuadricDrawStyle' );
+ @gluCylinder := GetModuleSymbol( LibGlu, 'gluCylinder' );
+ @gluDisk := GetModuleSymbol( LibGlu, 'gluDisk' );
+ @gluPartialDisk := GetModuleSymbol( LibGlu, 'gluPartialDisk' );
+ @gluSphere := GetModuleSymbol( LibGlu, 'gluSphere' );
+ @gluQuadricCallback := GetModuleSymbol( LibGlu, 'gluQuadricCallback' );
+ @gluNewTess := GetModuleSymbol( LibGlu, 'gluNewTess' );
+ @gluDeleteTess := GetModuleSymbol( LibGlu, 'gluDeleteTess' );
+ @gluTessBeginPolygon := GetModuleSymbol( LibGlu, 'gluTessBeginPolygon' );
+ @gluTessBeginContour := GetModuleSymbol( LibGlu, 'gluTessBeginContour' );
+ @gluTessVertex := GetModuleSymbol( LibGlu, 'gluTessVertex' );
+ @gluTessEndContour := GetModuleSymbol( LibGlu, 'gluTessEndContour' );
+ @gluTessEndPolygon := GetModuleSymbol( LibGlu, 'gluTessEndPolygon' );
+ @gluTessProperty := GetModuleSymbol( LibGlu, 'gluTessProperty' );
+ @gluTessNormal := GetModuleSymbol( LibGlu, 'gluTessNormal' );
+ @gluTessCallback := GetModuleSymbol( LibGlu, 'gluTessCallback' );
+ @gluGetTessProperty := GetModuleSymbol( LibGlu, 'gluGetTessProperty' );
+ @gluNewNurbsRenderer := GetModuleSymbol( LibGlu, 'gluNewNurbsRenderer' );
+ @gluDeleteNurbsRenderer := GetModuleSymbol( LibGlu, 'gluDeleteNurbsRenderer' );
+ @gluBeginSurface := GetModuleSymbol( LibGlu, 'gluBeginSurface' );
+ @gluBeginCurve := GetModuleSymbol( LibGlu, 'gluBeginCurve' );
+ @gluEndCurve := GetModuleSymbol( LibGlu, 'gluEndCurve' );
+ @gluEndSurface := GetModuleSymbol( LibGlu, 'gluEndSurface' );
+ @gluBeginTrim := GetModuleSymbol( LibGlu, 'gluBeginTrim' );
+ @gluEndTrim := GetModuleSymbol( LibGlu, 'gluEndTrim' );
+ @gluPwlCurve := GetModuleSymbol( LibGlu, 'gluPwlCurve' );
+ @gluNurbsCurve := GetModuleSymbol( LibGlu, 'gluNurbsCurve' );
+ @gluNurbsSurface := GetModuleSymbol( LibGlu, 'gluNurbsSurface' );
+ @gluLoadSamplingMatrices := GetModuleSymbol( LibGlu, 'gluLoadSamplingMatrices' );
+ @gluNurbsProperty := GetModuleSymbol( LibGlu, 'gluNurbsProperty' );
+ @gluGetNurbsProperty := GetModuleSymbol( LibGlu, 'gluGetNurbsProperty' );
+ @gluNurbsCallback := GetModuleSymbol( LibGlu, 'gluNurbsCallback' );
+
+ @gluBeginPolygon := GetModuleSymbol( LibGlu, 'gluBeginPolygon' );
+ @gluNextContour := GetModuleSymbol( LibGlu, 'gluNextContour' );
+ @gluEndPolygon := GetModuleSymbol( LibGlu, 'gluEndPolygon' );
+ end;
+end;
+
+initialization
+
+ LoadGLu( GLuLibName );
+
+finalization
+
+ FreeGLu;
+
+end.
+
diff --git a/Game/Code/lib/JEDI-SDL/OpenGL/Pas/glut.pas b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/glut.pas new file mode 100644 index 00000000..3bea3499 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/glut.pas @@ -0,0 +1,688 @@ +unit glut;
+{
+ $Id: glut.pas,v 1.4 2007/05/20 20:28:31 savage Exp $
+
+ Adaption of the delphi3d.net OpenGL units to FreePascal
+ Sebastian Guenther (sg@freepascal.org) in 2002
+ These units are free to use
+}
+
+// Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. */
+
+(* This program is freely distributable without licensing fees and is
+ provided without guarantee or warrantee expressed or implied. This
+ program is -not- in the public domain. *)
+
+{******************************************************************************}
+{ }
+{ Converted to Delphi by Tom Nuydens (tom@delphi3d.net) }
+{ For the latest updates, visit Delphi3D: http://www.delphi3d.net }
+{ }
+{ Modified for Delphi/Kylix and FreePascal }
+{ by Dominique Louis ( Dominique@Savagesoftware.com.au) }
+{ For the latest updates, visit JEDI-SDL : http://www.sf.net/projects/jedi-sdl }
+{ }
+{******************************************************************************}
+
+{
+ $Log: glut.pas,v $
+ Revision 1.4 2007/05/20 20:28:31 savage
+ Initial Changes to Handle 64 Bits
+
+ Revision 1.3 2006/11/20 21:20:59 savage
+ Updated to work in MacOS X
+
+ Revision 1.2 2004/08/14 22:54:30 savage
+ Updated so that Library name defines are correctly defined for MacOS X.
+
+ Revision 1.1 2004/03/30 21:53:54 savage
+ Moved to it's own folder.
+
+ Revision 1.5 2004/02/20 17:09:55 savage
+ Code tidied up in gl, glu and glut, while extensions in glext.pas are now loaded using SDL_GL_GetProcAddress, thus making it more cross-platform compatible, but now more tied to SDL.
+
+ Revision 1.4 2004/02/14 22:36:29 savage
+ Fixed inconsistencies of using LoadLibrary and LoadModule.
+ Now all units make use of LoadModule rather than LoadLibrary and other dynamic proc procedures.
+
+ Revision 1.3 2004/02/14 00:23:39 savage
+ As UNIX is defined in jedi-sdl.inc this will be used to check linux compatability as well. Units have been changed to reflect this change.
+
+ Revision 1.2 2004/02/14 00:09:19 savage
+ Changed uses to now make use of moduleloader.pas rather than dllfuncs.pas
+
+ Revision 1.1 2004/02/05 00:08:19 savage
+ Module 1.0 release
+
+ Revision 1.4 2003/06/02 12:32:13 savage
+ Modified Sources to avoid warnings with Delphi by moving CVS Logging to the top of the header files. Hopefully CVS Logging still works.
+
+}
+
+interface
+
+{$I jedi-sdl.inc}
+
+uses
+{$IFDEF __GPC__}
+ system,
+ gpc,
+{$ENDIF}
+
+{$IFDEF WINDOWS}
+ Windows,
+{$ENDIF}
+ moduleloader,
+ gl;
+
+type
+ {$IFNDEF __GPC__}
+ PInteger = ^Integer;
+ PPChar = ^PChar;
+ {$ENDIF}
+ TGlutVoidCallback = procedure; {$IFNDEF __GPC__}{$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}{$ENDIF}
+ TGlut1IntCallback = procedure(value: Integer); {$IFNDEF __GPC__}{$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}{$ENDIF}
+ TGlut2IntCallback = procedure(v1, v2: Integer); {$IFNDEF __GPC__}{$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}{$ENDIF}
+ TGlut3IntCallback = procedure(v1, v2, v3: Integer); {$IFNDEF __GPC__}{$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}{$ENDIF}
+ TGlut4IntCallback = procedure(v1, v2, v3, v4: Integer); {$IFNDEF __GPC__}{$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}{$ENDIF}
+ TGlut1Char2IntCallback = procedure(c: Byte; v1, v2: Integer); {$IFNDEF __GPC__}{$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}{$ENDIF}
+
+const
+{$IFDEF WINDOWS}
+ GlutLibName = 'glut32.dll';
+{$ENDIF}
+
+{$IFDEF UNIX}
+{$IFDEF DARWIN}
+ GlutLibName = '/System/Library/Frameworks/GLUT.framework/Libraries/libglut.dylib';
+{$ELSE}
+ GlutLibName = 'libglut.so';
+{$ENDIF}
+{$ENDIF}
+
+ GLUT_API_VERSION = 3;
+ GLUT_XLIB_IMPLEMENTATION = 12;
+ // Display mode bit masks.
+ GLUT_RGB = 0;
+ GLUT_RGBA = GLUT_RGB;
+ GLUT_INDEX = 1;
+ GLUT_SINGLE = 0;
+ GLUT_DOUBLE = 2;
+ GLUT_ACCUM = 4;
+ GLUT_ALPHA = 8;
+ GLUT_DEPTH = 16;
+ GLUT_STENCIL = 32;
+ GLUT_MULTISAMPLE = 128;
+ GLUT_STEREO = 256;
+ GLUT_LUMINANCE = 512;
+
+ // Mouse buttons.
+ GLUT_LEFT_BUTTON = 0;
+ GLUT_MIDDLE_BUTTON = 1;
+ GLUT_RIGHT_BUTTON = 2;
+
+ // Mouse button state.
+ GLUT_DOWN = 0;
+ GLUT_UP = 1;
+
+ // function keys
+ GLUT_KEY_F1 = 1;
+ GLUT_KEY_F2 = 2;
+ GLUT_KEY_F3 = 3;
+ GLUT_KEY_F4 = 4;
+ GLUT_KEY_F5 = 5;
+ GLUT_KEY_F6 = 6;
+ GLUT_KEY_F7 = 7;
+ GLUT_KEY_F8 = 8;
+ GLUT_KEY_F9 = 9;
+ GLUT_KEY_F10 = 10;
+ GLUT_KEY_F11 = 11;
+ GLUT_KEY_F12 = 12;
+ // directional keys
+ GLUT_KEY_LEFT = 100;
+ GLUT_KEY_UP = 101;
+ GLUT_KEY_RIGHT = 102;
+ GLUT_KEY_DOWN = 103;
+ GLUT_KEY_PAGE_UP = 104;
+ GLUT_KEY_PAGE_DOWN = 105;
+ GLUT_KEY_HOME = 106;
+ GLUT_KEY_END = 107;
+ GLUT_KEY_INSERT = 108;
+
+ // Entry/exit state.
+ GLUT_LEFT = 0;
+ GLUT_ENTERED = 1;
+
+ // Menu usage state.
+ GLUT_MENU_NOT_IN_USE = 0;
+ GLUT_MENU_IN_USE = 1;
+
+ // Visibility state.
+ GLUT_NOT_VISIBLE = 0;
+ GLUT_VISIBLE = 1;
+
+ // Window status state.
+ GLUT_HIDDEN = 0;
+ GLUT_FULLY_RETAINED = 1;
+ GLUT_PARTIALLY_RETAINED = 2;
+ GLUT_FULLY_COVERED = 3;
+
+ // Color index component selection values.
+ GLUT_RED = 0;
+ GLUT_GREEN = 1;
+ GLUT_BLUE = 2;
+
+ // Layers for use.
+ GLUT_NORMAL = 0;
+ GLUT_OVERLAY = 1;
+
+ // Stroke font constants (use these in GLUT program).
+ GLUT_STROKE_ROMAN = Pointer(0);
+ GLUT_STROKE_MONO_ROMAN = Pointer(1);
+
+ // Bitmap font constants (use these in GLUT program).
+ GLUT_BITMAP_9_BY_15 = Pointer(2);
+ GLUT_BITMAP_8_BY_13 = Pointer(3);
+ GLUT_BITMAP_TIMES_ROMAN_10 = Pointer(4);
+ GLUT_BITMAP_TIMES_ROMAN_24 = Pointer(5);
+ GLUT_BITMAP_HELVETICA_10 = Pointer(6);
+ GLUT_BITMAP_HELVETICA_12 = Pointer(7);
+ GLUT_BITMAP_HELVETICA_18 = Pointer(8);
+
+ // glutGet parameters.
+ GLUT_WINDOW_X = 100;
+ GLUT_WINDOW_Y = 101;
+ GLUT_WINDOW_WIDTH = 102;
+ GLUT_WINDOW_HEIGHT = 103;
+ GLUT_WINDOW_BUFFER_SIZE = 104;
+ GLUT_WINDOW_STENCIL_SIZE = 105;
+ GLUT_WINDOW_DEPTH_SIZE = 106;
+ GLUT_WINDOW_RED_SIZE = 107;
+ GLUT_WINDOW_GREEN_SIZE = 108;
+ GLUT_WINDOW_BLUE_SIZE = 109;
+ GLUT_WINDOW_ALPHA_SIZE = 110;
+ GLUT_WINDOW_ACCUM_RED_SIZE = 111;
+ GLUT_WINDOW_ACCUM_GREEN_SIZE = 112;
+ GLUT_WINDOW_ACCUM_BLUE_SIZE = 113;
+ GLUT_WINDOW_ACCUM_ALPHA_SIZE = 114;
+ GLUT_WINDOW_DOUBLEBUFFER = 115;
+ GLUT_WINDOW_RGBA = 116;
+ GLUT_WINDOW_PARENT = 117;
+ GLUT_WINDOW_NUM_CHILDREN = 118;
+ GLUT_WINDOW_COLORMAP_SIZE = 119;
+ GLUT_WINDOW_NUM_SAMPLES = 120;
+ GLUT_WINDOW_STEREO = 121;
+ GLUT_WINDOW_CURSOR = 122;
+ GLUT_SCREEN_WIDTH = 200;
+ GLUT_SCREEN_HEIGHT = 201;
+ GLUT_SCREEN_WIDTH_MM = 202;
+ GLUT_SCREEN_HEIGHT_MM = 203;
+ GLUT_MENU_NUM_ITEMS = 300;
+ GLUT_DISPLAY_MODE_POSSIBLE = 400;
+ GLUT_INIT_WINDOW_X = 500;
+ GLUT_INIT_WINDOW_Y = 501;
+ GLUT_INIT_WINDOW_WIDTH = 502;
+ GLUT_INIT_WINDOW_HEIGHT = 503;
+ GLUT_INIT_DISPLAY_MODE = 504;
+ GLUT_ELAPSED_TIME = 700;
+
+ // glutDeviceGet parameters.
+ GLUT_HAS_KEYBOARD = 600;
+ GLUT_HAS_MOUSE = 601;
+ GLUT_HAS_SPACEBALL = 602;
+ GLUT_HAS_DIAL_AND_BUTTON_BOX = 603;
+ GLUT_HAS_TABLET = 604;
+ GLUT_NUM_MOUSE_BUTTONS = 605;
+ GLUT_NUM_SPACEBALL_BUTTONS = 606;
+ GLUT_NUM_BUTTON_BOX_BUTTONS = 607;
+ GLUT_NUM_DIALS = 608;
+ GLUT_NUM_TABLET_BUTTONS = 609;
+
+ // glutLayerGet parameters.
+ GLUT_OVERLAY_POSSIBLE = 800;
+ GLUT_LAYER_IN_USE = 801;
+ GLUT_HAS_OVERLAY = 802;
+ GLUT_TRANSPARENT_INDEX = 803;
+ GLUT_NORMAL_DAMAGED = 804;
+ GLUT_OVERLAY_DAMAGED = 805;
+
+ // glutVideoResizeGet parameters.
+ GLUT_VIDEO_RESIZE_POSSIBLE = 900;
+ GLUT_VIDEO_RESIZE_IN_USE = 901;
+ GLUT_VIDEO_RESIZE_X_DELTA = 902;
+ GLUT_VIDEO_RESIZE_Y_DELTA = 903;
+ GLUT_VIDEO_RESIZE_WIDTH_DELTA = 904;
+ GLUT_VIDEO_RESIZE_HEIGHT_DELTA = 905;
+ GLUT_VIDEO_RESIZE_X = 906;
+ GLUT_VIDEO_RESIZE_Y = 907;
+ GLUT_VIDEO_RESIZE_WIDTH = 908;
+ GLUT_VIDEO_RESIZE_HEIGHT = 909;
+
+ // glutGetModifiers return mask.
+ GLUT_ACTIVE_SHIFT = 1;
+ GLUT_ACTIVE_CTRL = 2;
+ GLUT_ACTIVE_ALT = 4;
+
+ // glutSetCursor parameters.
+ // Basic arrows.
+ GLUT_CURSOR_RIGHT_ARROW = 0;
+ GLUT_CURSOR_LEFT_ARROW = 1;
+ // Symbolic cursor shapes.
+ GLUT_CURSOR_INFO = 2;
+ GLUT_CURSOR_DESTROY = 3;
+ GLUT_CURSOR_HELP = 4;
+ GLUT_CURSOR_CYCLE = 5;
+ GLUT_CURSOR_SPRAY = 6;
+ GLUT_CURSOR_WAIT = 7;
+ GLUT_CURSOR_TEXT = 8;
+ GLUT_CURSOR_CROSSHAIR = 9;
+ // Directional cursors.
+ GLUT_CURSOR_UP_DOWN = 10;
+ GLUT_CURSOR_LEFT_RIGHT = 11;
+ // Sizing cursors.
+ GLUT_CURSOR_TOP_SIDE = 12;
+ GLUT_CURSOR_BOTTOM_SIDE = 13;
+ GLUT_CURSOR_LEFT_SIDE = 14;
+ GLUT_CURSOR_RIGHT_SIDE = 15;
+ GLUT_CURSOR_TOP_LEFT_CORNER = 16;
+ GLUT_CURSOR_TOP_RIGHT_CORNER = 17;
+ GLUT_CURSOR_BOTTOM_RIGHT_CORNER = 18;
+ GLUT_CURSOR_BOTTOM_LEFT_CORNER = 19;
+ // Inherit from parent window.
+ GLUT_CURSOR_INHERIT = 100;
+ // Blank cursor.
+ GLUT_CURSOR_NONE = 101;
+ // Fullscreen crosshair (if available).
+ GLUT_CURSOR_FULL_CROSSHAIR = 102;
+
+ // GLUT game mode sub-API.
+ // glutGameModeGet.
+ GLUT_GAME_MODE_ACTIVE = 0;
+ GLUT_GAME_MODE_POSSIBLE = 1;
+ GLUT_GAME_MODE_WIDTH = 2;
+ GLUT_GAME_MODE_HEIGHT = 3;
+ GLUT_GAME_MODE_PIXEL_DEPTH = 4;
+ GLUT_GAME_MODE_REFRESH_RATE = 5;
+ GLUT_GAME_MODE_DISPLAY_CHANGED = 6;
+
+var
+// GLUT initialization sub-API.
+ glutInit: procedure(argcp: PInteger; argv: PPChar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutInitDisplayMode: procedure(mode: Word); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutInitDisplayString: procedure(const str: PChar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutInitWindowPosition: procedure(x, y: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutInitWindowSize: procedure(width, height: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutMainLoop: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+// GLUT window sub-API.
+ glutCreateWindow: function(const title: PChar): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutCreateSubWindow: function(win, x, y, width, height: Integer): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutDestroyWindow: procedure(win: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutPostRedisplay: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutPostWindowRedisplay: procedure(win: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSwapBuffers: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutGetWindow: function: Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSetWindow: procedure(win: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSetWindowTitle: procedure(const title: PChar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSetIconTitle: procedure(const title: PChar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutPositionWindow: procedure(x, y: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutReshapeWindow: procedure(width, height: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutPopWindow: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutPushWindow: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutIconifyWindow: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutShowWindow: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutHideWindow: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutFullScreen: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSetCursor: procedure(cursor: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutWarpPointer: procedure(x, y: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+// GLUT overlay sub-API.
+ glutEstablishOverlay: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutRemoveOverlay: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutUseLayer: procedure(layer: GLenum); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutPostOverlayRedisplay: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutPostWindowOverlayRedisplay: procedure(win: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutShowOverlay: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutHideOverlay: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+// GLUT menu sub-API.
+ glutCreateMenu: function(callback: TGlut1IntCallback): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutDestroyMenu: procedure(menu: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutGetMenu: function: Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSetMenu: procedure(menu: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutAddMenuEntry: procedure(const caption: PChar; value: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutAddSubMenu: procedure(const caption: PChar; submenu: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutChangeToMenuEntry: procedure(item: Integer; const caption: PChar; value: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutChangeToSubMenu: procedure(item: Integer; const caption: PChar; submenu: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutRemoveMenuItem: procedure(item: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutAttachMenu: procedure(button: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutDetachMenu: procedure(button: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+// GLUTsub-API.
+ glutDisplayFunc: procedure(f: TGlutVoidCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutReshapeFunc: procedure(f: TGlut2IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutKeyboardFunc: procedure(f: TGlut1Char2IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutMouseFunc: procedure(f: TGlut4IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutMotionFunc: procedure(f: TGlut2IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutPassiveMotionFunc: procedure(f: TGlut2IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutEntryFunc: procedure(f: TGlut1IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutVisibilityFunc: procedure(f: TGlut1IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutIdleFunc: procedure(f: TGlutVoidCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutTimerFunc: procedure(millis: Word; f: TGlut1IntCallback; value: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutMenuStateFunc: procedure(f: TGlut1IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSpecialFunc: procedure(f: TGlut3IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSpaceballMotionFunc: procedure(f: TGlut3IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSpaceballRotateFunc: procedure(f: TGlut3IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSpaceballButtonFunc: procedure(f: TGlut2IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutButtonBoxFunc: procedure(f: TGlut2IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutDialsFunc: procedure(f: TGlut2IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutTabletMotionFunc: procedure(f: TGlut2IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutTabletButtonFunc: procedure(f: TGlut4IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutMenuStatusFunc: procedure(f: TGlut3IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutOverlayDisplayFunc: procedure(f:TGlutVoidCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutWindowStatusFunc: procedure(f: TGlut1IntCallback); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+// GLUT color index sub-API.
+ glutSetColor: procedure(cell: Integer; red, green, blue: GLfloat); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutGetColor: function(ndx, component: Integer): GLfloat; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutCopyColormap: procedure(win: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+// GLUT state retrieval sub-API.
+ glutGet: function(t: GLenum): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutDeviceGet: function(t: GLenum): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+// GLUT extension support sub-API
+ glutExtensionSupported: function(const name: PChar): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutGetModifiers: function: Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutLayerGet: function(t: GLenum): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+// GLUT font sub-API
+ glutBitmapCharacter: procedure(font : pointer; character: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutBitmapWidth: function(font : pointer; character: Integer): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutStrokeCharacter: procedure(font : pointer; character: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutStrokeWidth: function(font : pointer; character: Integer): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutBitmapLength: function(font: pointer; const str: PChar): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutStrokeLength: function(font: pointer; const str: PChar): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+// GLUT pre-built models sub-API
+ glutWireSphere: procedure(radius: GLdouble; slices, stacks: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSolidSphere: procedure(radius: GLdouble; slices, stacks: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutWireCone: procedure(base, height: GLdouble; slices, stacks: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSolidCone: procedure(base, height: GLdouble; slices, stacks: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutWireCube: procedure(size: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSolidCube: procedure(size: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutWireTorus: procedure(innerRadius, outerRadius: GLdouble; sides, rings: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSolidTorus: procedure(innerRadius, outerRadius: GLdouble; sides, rings: GLint); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutWireDodecahedron: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSolidDodecahedron: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutWireTeapot: procedure(size: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSolidTeapot: procedure(size: GLdouble); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutWireOctahedron: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSolidOctahedron: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutWireTetrahedron: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSolidTetrahedron: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutWireIcosahedron: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSolidIcosahedron: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+// GLUT video resize sub-API.
+ glutVideoResizeGet: function(param: GLenum): Integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutSetupVideoResizing: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutStopVideoResizing: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutVideoResize: procedure(x, y, width, height: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutVideoPan: procedure(x, y, width, height: Integer); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+// GLUT debugging sub-API.
+ glutReportErrors: procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+var
+ //example glutGameModeString('1280x1024:32@75');
+ glutGameModeString : procedure (const AString : PChar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutEnterGameMode : function : integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutLeaveGameMode : procedure; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+ glutGameModeGet : function (mode : GLenum) : integer; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
+
+procedure LoadGlut(const dll: PChar);
+procedure FreeGlut;
+
+implementation
+
+var
+ LibGLUT : TModuleHandle;
+
+procedure FreeGlut;
+begin
+
+ UnLoadModule( LibGLUT );
+
+ @glutInit := nil;
+ @glutInitDisplayMode := nil;
+ @glutInitDisplayString := nil;
+ @glutInitWindowPosition := nil;
+ @glutInitWindowSize := nil;
+ @glutMainLoop := nil;
+ @glutCreateWindow := nil;
+ @glutCreateSubWindow := nil;
+ @glutDestroyWindow := nil;
+ @glutPostRedisplay := nil;
+ @glutPostWindowRedisplay := nil;
+ @glutSwapBuffers := nil;
+ @glutGetWindow := nil;
+ @glutSetWindow := nil;
+ @glutSetWindowTitle := nil;
+ @glutSetIconTitle := nil;
+ @glutPositionWindow := nil;
+ @glutReshapeWindow := nil;
+ @glutPopWindow := nil;
+ @glutPushWindow := nil;
+ @glutIconifyWindow := nil;
+ @glutShowWindow := nil;
+ @glutHideWindow := nil;
+ @glutFullScreen := nil;
+ @glutSetCursor := nil;
+ @glutWarpPointer := nil;
+ @glutEstablishOverlay := nil;
+ @glutRemoveOverlay := nil;
+ @glutUseLayer := nil;
+ @glutPostOverlayRedisplay := nil;
+ @glutPostWindowOverlayRedisplay := nil;
+ @glutShowOverlay := nil;
+ @glutHideOverlay := nil;
+ @glutCreateMenu := nil;
+ @glutDestroyMenu := nil;
+ @glutGetMenu := nil;
+ @glutSetMenu := nil;
+ @glutAddMenuEntry := nil;
+ @glutAddSubMenu := nil;
+ @glutChangeToMenuEntry := nil;
+ @glutChangeToSubMenu := nil;
+ @glutRemoveMenuItem := nil;
+ @glutAttachMenu := nil;
+ @glutDetachMenu := nil;
+ @glutDisplayFunc := nil;
+ @glutReshapeFunc := nil;
+ @glutKeyboardFunc := nil;
+ @glutMouseFunc := nil;
+ @glutMotionFunc := nil;
+ @glutPassiveMotionFunc := nil;
+ @glutEntryFunc := nil;
+ @glutVisibilityFunc := nil;
+ @glutIdleFunc := nil;
+ @glutTimerFunc := nil;
+ @glutMenuStateFunc := nil;
+ @glutSpecialFunc := nil;
+ @glutSpaceballMotionFunc := nil;
+ @glutSpaceballRotateFunc := nil;
+ @glutSpaceballButtonFunc := nil;
+ @glutButtonBoxFunc := nil;
+ @glutDialsFunc := nil;
+ @glutTabletMotionFunc := nil;
+ @glutTabletButtonFunc := nil;
+ @glutMenuStatusFunc := nil;
+ @glutOverlayDisplayFunc := nil;
+ @glutWindowStatusFunc := nil;
+ @glutSetColor := nil;
+ @glutGetColor := nil;
+ @glutCopyColormap := nil;
+ @glutGet := nil;
+ @glutDeviceGet := nil;
+ @glutExtensionSupported := nil;
+ @glutGetModifiers := nil;
+ @glutLayerGet := nil;
+ @glutBitmapCharacter := nil;
+ @glutBitmapWidth := nil;
+ @glutStrokeCharacter := nil;
+ @glutStrokeWidth := nil;
+ @glutBitmapLength := nil;
+ @glutStrokeLength := nil;
+ @glutWireSphere := nil;
+ @glutSolidSphere := nil;
+ @glutWireCone := nil;
+ @glutSolidCone := nil;
+ @glutWireCube := nil;
+ @glutSolidCube := nil;
+ @glutWireTorus := nil;
+ @glutSolidTorus := nil;
+ @glutWireDodecahedron := nil;
+ @glutSolidDodecahedron := nil;
+ @glutWireTeapot := nil;
+ @glutSolidTeapot := nil;
+ @glutWireOctahedron := nil;
+ @glutSolidOctahedron := nil;
+ @glutWireTetrahedron := nil;
+ @glutSolidTetrahedron := nil;
+ @glutWireIcosahedron := nil;
+ @glutSolidIcosahedron := nil;
+ @glutVideoResizeGet := nil;
+ @glutSetupVideoResizing := nil;
+ @glutStopVideoResizing := nil;
+ @glutVideoResize := nil;
+ @glutVideoPan := nil;
+ @glutReportErrors := nil;
+
+end;
+
+procedure LoadGlut(const dll: PChar);
+begin
+
+ FreeGlut;
+
+ if LoadModule( LibGLUT, dll ) then
+ begin
+ @glutInit := GetModuleSymbol(LibGLUT, 'glutInit');
+ @glutInitDisplayMode := GetModuleSymbol(LibGLUT, 'glutInitDisplayMode');
+ @glutInitDisplayString := GetModuleSymbol(LibGLUT, 'glutInitDisplayString');
+ @glutInitWindowPosition := GetModuleSymbol(LibGLUT, 'glutInitWindowPosition');
+ @glutInitWindowSize := GetModuleSymbol(LibGLUT, 'glutInitWindowSize');
+ @glutMainLoop := GetModuleSymbol(LibGLUT, 'glutMainLoop');
+ @glutCreateWindow := GetModuleSymbol(LibGLUT, 'glutCreateWindow');
+ @glutCreateSubWindow := GetModuleSymbol(LibGLUT, 'glutCreateSubWindow');
+ @glutDestroyWindow := GetModuleSymbol(LibGLUT, 'glutDestroyWindow');
+ @glutPostRedisplay := GetModuleSymbol(LibGLUT, 'glutPostRedisplay');
+ @glutPostWindowRedisplay := GetModuleSymbol(LibGLUT, 'glutPostWindowRedisplay');
+ @glutSwapBuffers := GetModuleSymbol(LibGLUT, 'glutSwapBuffers');
+ @glutGetWindow := GetModuleSymbol(LibGLUT, 'glutGetWindow');
+ @glutSetWindow := GetModuleSymbol(LibGLUT, 'glutSetWindow');
+ @glutSetWindowTitle := GetModuleSymbol(LibGLUT, 'glutSetWindowTitle');
+ @glutSetIconTitle := GetModuleSymbol(LibGLUT, 'glutSetIconTitle');
+ @glutPositionWindow := GetModuleSymbol(LibGLUT, 'glutPositionWindow');
+ @glutReshapeWindow := GetModuleSymbol(LibGLUT, 'glutReshapeWindow');
+ @glutPopWindow := GetModuleSymbol(LibGLUT, 'glutPopWindow');
+ @glutPushWindow := GetModuleSymbol(LibGLUT, 'glutPushWindow');
+ @glutIconifyWindow := GetModuleSymbol(LibGLUT, 'glutIconifyWindow');
+ @glutShowWindow := GetModuleSymbol(LibGLUT, 'glutShowWindow');
+ @glutHideWindow := GetModuleSymbol(LibGLUT, 'glutHideWindow');
+ @glutFullScreen := GetModuleSymbol(LibGLUT, 'glutFullScreen');
+ @glutSetCursor := GetModuleSymbol(LibGLUT, 'glutSetCursor');
+ @glutWarpPointer := GetModuleSymbol(LibGLUT, 'glutWarpPointer');
+ @glutEstablishOverlay := GetModuleSymbol(LibGLUT, 'glutEstablishOverlay');
+ @glutRemoveOverlay := GetModuleSymbol(LibGLUT, 'glutRemoveOverlay');
+ @glutUseLayer := GetModuleSymbol(LibGLUT, 'glutUseLayer');
+ @glutPostOverlayRedisplay := GetModuleSymbol(LibGLUT, 'glutPostOverlayRedisplay');
+ @glutPostWindowOverlayRedisplay := GetModuleSymbol(LibGLUT, 'glutPostWindowOverlayRedisplay');
+ @glutShowOverlay := GetModuleSymbol(LibGLUT, 'glutShowOverlay');
+ @glutHideOverlay := GetModuleSymbol(LibGLUT, 'glutHideOverlay');
+ @glutCreateMenu := GetModuleSymbol(LibGLUT, 'glutCreateMenu');
+ @glutDestroyMenu := GetModuleSymbol(LibGLUT, 'glutDestroyMenu');
+ @glutGetMenu := GetModuleSymbol(LibGLUT, 'glutGetMenu');
+ @glutSetMenu := GetModuleSymbol(LibGLUT, 'glutSetMenu');
+ @glutAddMenuEntry := GetModuleSymbol(LibGLUT, 'glutAddMenuEntry');
+ @glutAddSubMenu := GetModuleSymbol(LibGLUT, 'glutAddSubMenu');
+ @glutChangeToMenuEntry := GetModuleSymbol(LibGLUT, 'glutChangeToMenuEntry');
+ @glutChangeToSubMenu := GetModuleSymbol(LibGLUT, 'glutChangeToSubMenu');
+ @glutRemoveMenuItem := GetModuleSymbol(LibGLUT, 'glutRemoveMenuItem');
+ @glutAttachMenu := GetModuleSymbol(LibGLUT, 'glutAttachMenu');
+ @glutDetachMenu := GetModuleSymbol(LibGLUT, 'glutDetachMenu');
+ @glutDisplayFunc := GetModuleSymbol(LibGLUT, 'glutDisplayFunc');
+ @glutReshapeFunc := GetModuleSymbol(LibGLUT, 'glutReshapeFunc');
+ @glutKeyboardFunc := GetModuleSymbol(LibGLUT, 'glutKeyboardFunc');
+ @glutMouseFunc := GetModuleSymbol(LibGLUT, 'glutMouseFunc');
+ @glutMotionFunc := GetModuleSymbol(LibGLUT, 'glutMotionFunc');
+ @glutPassiveMotionFunc := GetModuleSymbol(LibGLUT, 'glutPassiveMotionFunc');
+ @glutEntryFunc := GetModuleSymbol(LibGLUT, 'glutEntryFunc');
+ @glutVisibilityFunc := GetModuleSymbol(LibGLUT, 'glutVisibilityFunc');
+ @glutIdleFunc := GetModuleSymbol(LibGLUT, 'glutIdleFunc');
+ @glutTimerFunc := GetModuleSymbol(LibGLUT, 'glutTimerFunc');
+ @glutMenuStateFunc := GetModuleSymbol(LibGLUT, 'glutMenuStateFunc');
+ @glutSpecialFunc := GetModuleSymbol(LibGLUT, 'glutSpecialFunc');
+ @glutSpaceballMotionFunc := GetModuleSymbol(LibGLUT, 'glutSpaceballMotionFunc');
+ @glutSpaceballRotateFunc := GetModuleSymbol(LibGLUT, 'glutSpaceballRotateFunc');
+ @glutSpaceballButtonFunc := GetModuleSymbol(LibGLUT, 'glutSpaceballButtonFunc');
+ @glutButtonBoxFunc := GetModuleSymbol(LibGLUT, 'glutButtonBoxFunc');
+ @glutDialsFunc := GetModuleSymbol(LibGLUT, 'glutDialsFunc');
+ @glutTabletMotionFunc := GetModuleSymbol(LibGLUT, 'glutTabletMotionFunc');
+ @glutTabletButtonFunc := GetModuleSymbol(LibGLUT, 'glutTabletButtonFunc');
+ @glutMenuStatusFunc := GetModuleSymbol(LibGLUT, 'glutMenuStatusFunc');
+ @glutOverlayDisplayFunc := GetModuleSymbol(LibGLUT, 'glutOverlayDisplayFunc');
+ @glutWindowStatusFunc := GetModuleSymbol(LibGLUT, 'glutWindowStatusFunc');
+ @glutSetColor := GetModuleSymbol(LibGLUT, 'glutSetColor');
+ @glutGetColor := GetModuleSymbol(LibGLUT, 'glutGetColor');
+ @glutCopyColormap := GetModuleSymbol(LibGLUT, 'glutCopyColormap');
+ @glutGet := GetModuleSymbol(LibGLUT, 'glutGet');
+ @glutDeviceGet := GetModuleSymbol(LibGLUT, 'glutDeviceGet');
+ @glutExtensionSupported := GetModuleSymbol(LibGLUT, 'glutExtensionSupported');
+ @glutGetModifiers := GetModuleSymbol(LibGLUT, 'glutGetModifiers');
+ @glutLayerGet := GetModuleSymbol(LibGLUT, 'glutLayerGet');
+ @glutBitmapCharacter := GetModuleSymbol(LibGLUT, 'glutBitmapCharacter');
+ @glutBitmapWidth := GetModuleSymbol(LibGLUT, 'glutBitmapWidth');
+ @glutStrokeCharacter := GetModuleSymbol(LibGLUT, 'glutStrokeCharacter');
+ @glutStrokeWidth := GetModuleSymbol(LibGLUT, 'glutStrokeWidth');
+ @glutBitmapLength := GetModuleSymbol(LibGLUT, 'glutBitmapLength');
+ @glutStrokeLength := GetModuleSymbol(LibGLUT, 'glutStrokeLength');
+ @glutWireSphere := GetModuleSymbol(LibGLUT, 'glutWireSphere');
+ @glutSolidSphere := GetModuleSymbol(LibGLUT, 'glutSolidSphere');
+ @glutWireCone := GetModuleSymbol(LibGLUT, 'glutWireCone');
+ @glutSolidCone := GetModuleSymbol(LibGLUT, 'glutSolidCone');
+ @glutWireCube := GetModuleSymbol(LibGLUT, 'glutWireCube');
+ @glutSolidCube := GetModuleSymbol(LibGLUT, 'glutSolidCube');
+ @glutWireTorus := GetModuleSymbol(LibGLUT, 'glutWireTorus');
+ @glutSolidTorus := GetModuleSymbol(LibGLUT, 'glutSolidTorus');
+ @glutWireDodecahedron := GetModuleSymbol(LibGLUT, 'glutWireDodecahedron');
+ @glutSolidDodecahedron := GetModuleSymbol(LibGLUT, 'glutSolidDodecahedron');
+ @glutWireTeapot := GetModuleSymbol(LibGLUT, 'glutWireTeapot');
+ @glutSolidTeapot := GetModuleSymbol(LibGLUT, 'glutSolidTeapot');
+ @glutWireOctahedron := GetModuleSymbol(LibGLUT, 'glutWireOctahedron');
+ @glutSolidOctahedron := GetModuleSymbol(LibGLUT, 'glutSolidOctahedron');
+ @glutWireTetrahedron := GetModuleSymbol(LibGLUT, 'glutWireTetrahedron');
+ @glutSolidTetrahedron := GetModuleSymbol(LibGLUT, 'glutSolidTetrahedron');
+ @glutWireIcosahedron := GetModuleSymbol(LibGLUT, 'glutWireIcosahedron');
+ @glutSolidIcosahedron := GetModuleSymbol(LibGLUT, 'glutSolidIcosahedron');
+ @glutVideoResizeGet := GetModuleSymbol(LibGLUT, 'glutVideoResizeGet');
+ @glutSetupVideoResizing := GetModuleSymbol(LibGLUT, 'glutSetupVideoResizing');
+ @glutStopVideoResizing := GetModuleSymbol(LibGLUT, 'glutStopVideoResizing');
+ @glutVideoResize := GetModuleSymbol(LibGLUT, 'glutVideoResize');
+ @glutVideoPan := GetModuleSymbol(LibGLUT, 'glutVideoPan');
+ @glutReportErrors := GetModuleSymbol(LibGLUT, 'glutReportErrors');
+ @glutGameModeString := GetModuleSymbol(LibGLUT, 'glutGameModeString');
+ @glutEnterGameMode := GetModuleSymbol(LibGLUT, 'glutEnterGameMode');
+ @glutLeaveGameMode := GetModuleSymbol(LibGLUT, 'glutLeaveGameMode');
+ @glutGameModeGet := GetModuleSymbol(LibGLUT, 'glutGameModeGet');
+ end;
+end;
+
+initialization
+ LoadGlut( GlutLibName );
+
+finalization
+ FreeGlut;
+
+end.
diff --git a/Game/Code/lib/JEDI-SDL/OpenGL/Pas/glx.pas b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/glx.pas new file mode 100644 index 00000000..125e3e39 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/glx.pas @@ -0,0 +1,280 @@ +unit glx;
+{
+ $Id: glx.pas,v 1.3 2006/11/20 21:20:59 savage Exp $
+
+ Translation of the Mesa GLX headers for FreePascal
+ Copyright (C) 1999 Sebastian Guenther
+
+
+ Mesa 3-D graphics library
+ Version: 3.0
+ Copyright (C) 1995-1998 Brian Paul
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+}
+
+// {$MODE delphi} // objfpc would not work because of direct proc var assignments
+
+{You have to enable Macros (compiler switch "-Sm") for compiling this unit!
+ This is necessary for supporting different platforms with different calling
+ conventions via a single unit.}
+
+{
+ $Log: glx.pas,v $
+ Revision 1.3 2006/11/20 21:20:59 savage
+ Updated to work in MacOS X
+
+ Revision 1.2 2006/04/18 18:38:33 savage
+ fixed boolean test - thanks grudzio
+
+ Revision 1.1 2004/03/30 21:53:55 savage
+ Moved to it's own folder.
+
+ Revision 1.5 2004/02/15 22:48:35 savage
+ More FPC and FreeBSD support changes.
+
+ Revision 1.4 2004/02/14 22:36:29 savage
+ Fixed inconsistencies of using LoadLibrary and LoadModule.
+ Now all units make use of LoadModule rather than LoadLibrary and other dynamic proc procedures.
+
+ Revision 1.3 2004/02/14 00:23:39 savage
+ As UNIX is defined in jedi-sdl.inc this will be used to check linux compatability as well. Units have been changed to reflect this change.
+
+ Revision 1.2 2004/02/14 00:09:19 savage
+ Changed uses to now make use of moduleloader.pas rather than dllfuncs.pas
+
+ Revision 1.1 2004/02/05 00:08:19 savage
+ Module 1.0 release
+
+ Revision 1.1 2003/05/11 13:18:03 savage
+ Newest OpenGL Headers For Delphi, Kylix and FPC
+
+ Revision 1.1 2002/10/13 13:57:31 sg
+ * Finally, the new units are available: Match the C headers more closely;
+ support for OpenGL extensions, and much more. Based on the Delphi units
+ by Tom Nuydens of delphi3d.net
+
+}
+
+interface
+
+{$I jedi-sdl.inc}
+
+{$IFDEF UNIX}
+ uses
+ {$IFDEF FPC}
+ x,
+ xlib,
+ xutil;
+ {$ELSE}
+ xlib;
+ {$ENDIF}
+ {$DEFINE HasGLX} // Activate GLX stuff
+{$ELSE}
+ {$MESSAGE Unsupported platform.}
+{$ENDIF}
+
+{$IFNDEF HasGLX}
+ {$MESSAGE GLX not present on this platform.}
+{$ENDIF}
+
+
+// =======================================================
+// Unit specific extensions
+// =======================================================
+
+// Note: Requires that the GL library has already been initialized
+function InitGLX: Boolean;
+
+var
+ GLXDumpUnresolvedFunctions,
+ GLXInitialized: Boolean;
+
+
+// =======================================================
+// GLX consts, types and functions
+// =======================================================
+
+// Tokens for glXChooseVisual and glXGetConfig:
+const
+ GLX_USE_GL = 1;
+ GLX_BUFFER_SIZE = 2;
+ GLX_LEVEL = 3;
+ GLX_RGBA = 4;
+ GLX_DOUBLEBUFFER = 5;
+ GLX_STEREO = 6;
+ GLX_AUX_BUFFERS = 7;
+ GLX_RED_SIZE = 8;
+ GLX_GREEN_SIZE = 9;
+ GLX_BLUE_SIZE = 10;
+ GLX_ALPHA_SIZE = 11;
+ GLX_DEPTH_SIZE = 12;
+ GLX_STENCIL_SIZE = 13;
+ GLX_ACCUM_RED_SIZE = 14;
+ GLX_ACCUM_GREEN_SIZE = 15;
+ GLX_ACCUM_BLUE_SIZE = 16;
+ GLX_ACCUM_ALPHA_SIZE = 17;
+
+ // GLX_EXT_visual_info extension
+ GLX_X_VISUAL_TYPE_EXT = $22;
+ GLX_TRANSPARENT_TYPE_EXT = $23;
+ GLX_TRANSPARENT_INDEX_VALUE_EXT = $24;
+ GLX_TRANSPARENT_RED_VALUE_EXT = $25;
+ GLX_TRANSPARENT_GREEN_VALUE_EXT = $26;
+ GLX_TRANSPARENT_BLUE_VALUE_EXT = $27;
+ GLX_TRANSPARENT_ALPHA_VALUE_EXT = $28;
+
+
+ // Error codes returned by glXGetConfig:
+ GLX_BAD_SCREEN = 1;
+ GLX_BAD_ATTRIBUTE = 2;
+ GLX_NO_EXTENSION = 3;
+ GLX_BAD_VISUAL = 4;
+ GLX_BAD_CONTEXT = 5;
+ GLX_BAD_VALUE = 6;
+ GLX_BAD_ENUM = 7;
+
+ // GLX 1.1 and later:
+ GLX_VENDOR = 1;
+ GLX_VERSION = 2;
+ GLX_EXTENSIONS = 3;
+
+ // GLX_visual_info extension
+ GLX_TRUE_COLOR_EXT = $8002;
+ GLX_DIRECT_COLOR_EXT = $8003;
+ GLX_PSEUDO_COLOR_EXT = $8004;
+ GLX_STATIC_COLOR_EXT = $8005;
+ GLX_GRAY_SCALE_EXT = $8006;
+ GLX_STATIC_GRAY_EXT = $8007;
+ GLX_NONE_EXT = $8000;
+ GLX_TRANSPARENT_RGB_EXT = $8008;
+ GLX_TRANSPARENT_INDEX_EXT = $8009;
+
+type
+ // From XLib:
+ {$IFNDEF FPC}
+ TXID = XID;
+ {$ENDIF}
+ XPixmap = TXID;
+ XFont = TXID;
+ XColormap = TXID;
+
+ GLXContext = Pointer;
+ GLXPixmap = TXID;
+ GLXDrawable = TXID;
+ GLXContextID = TXID;
+
+var
+ glXChooseVisual: function(dpy: PDisplay; screen: Integer; var attribList: Integer): PXVisualInfo; cdecl;
+ glXCreateContext: function(dpy: PDisplay; vis: PXVisualInfo; shareList: GLXContext; direct: Boolean): GLXContext; cdecl;
+ glXDestroyContext: procedure(dpy: PDisplay; ctx: GLXContext); cdecl;
+ glXMakeCurrent: function(dpy: PDisplay; drawable: GLXDrawable; ctx: GLXContext): Boolean; cdecl;
+ glXCopyContext: procedure(dpy: PDisplay; src, dst: GLXContext; mask: LongWord); cdecl;
+ glXSwapBuffers: procedure(dpy: PDisplay; drawable: GLXDrawable); cdecl;
+ glXCreateGLXPixmap: function(dpy: PDisplay; visual: PXVisualInfo; pixmap: XPixmap): GLXPixmap; cdecl;
+ glXDestroyGLXPixmap: procedure(dpy: PDisplay; pixmap: GLXPixmap); cdecl;
+ glXQueryExtension: function(dpy: PDisplay; var errorb, event: Integer): Boolean; cdecl;
+ glXQueryVersion: function(dpy: PDisplay; var maj, min: Integer): Boolean; cdecl;
+ glXIsDirect: function(dpy: PDisplay; ctx: GLXContext): Boolean; cdecl;
+ glXGetConfig: function(dpy: PDisplay; visual: PXVisualInfo; attrib: Integer; var value: Integer): Integer; cdecl;
+ glXGetCurrentContext: function: GLXContext; cdecl;
+ glXGetCurrentDrawable: function: GLXDrawable; cdecl;
+ glXWaitGL: procedure; cdecl;
+ glXWaitX: procedure; cdecl;
+ glXUseXFont: procedure(font: XFont; first, count, list: Integer); cdecl;
+
+ // GLX 1.1 and later
+ glXQueryExtensionsString: function(dpy: PDisplay; screen: Integer): PChar; cdecl;
+ glXQueryServerString: function(dpy: PDisplay; screen, name: Integer): PChar; cdecl;
+ glXGetClientString: function(dpy: PDisplay; name: Integer): PChar; cdecl;
+
+ // Mesa GLX Extensions
+ glXCreateGLXPixmapMESA: function(dpy: PDisplay; visual: PXVisualInfo; pixmap: XPixmap; cmap: XColormap): GLXPixmap; cdecl;
+ glXReleaseBufferMESA: function(dpy: PDisplay; d: GLXDrawable): Boolean; cdecl;
+ glXCopySubBufferMESA: procedure(dpy: PDisplay; drawbale: GLXDrawable; x, y, width, height: Integer); cdecl;
+ glXGetVideoSyncSGI: function(var counter: LongWord): Integer; cdecl;
+ glXWaitVideoSyncSGI: function(divisor, remainder: Integer; var count: LongWord): Integer; cdecl;
+
+
+// =======================================================
+//
+// =======================================================
+
+implementation
+
+uses
+ {$IFNDEF __GPC__}
+ SysUtils,
+ {$ENDIF}
+ moduleloader;
+
+(* {$LINKLIB m} *)
+
+var
+ libGLX: TModuleHandle;
+
+function InitGLXFromLibrary( dll : PChar ): Boolean;
+begin
+ Result := False;
+
+ if not LoadModule( libGLX, dll ) then
+ exit;
+
+ glXChooseVisual := GetModuleSymbol(libglx, 'glXChooseVisual');
+ glXCreateContext := GetModuleSymbol(libglx, 'glXCreateContext');
+ glXDestroyContext := GetModuleSymbol(libglx, 'glXDestroyContext');
+ glXMakeCurrent := GetModuleSymbol(libglx, 'glXMakeCurrent');
+ glXCopyContext := GetModuleSymbol(libglx, 'glXCopyContext');
+ glXSwapBuffers := GetModuleSymbol(libglx, 'glXSwapBuffers');
+ glXCreateGLXPixmap := GetModuleSymbol(libglx, 'glXCreateGLXPixmap');
+ glXDestroyGLXPixmap := GetModuleSymbol(libglx, 'glXDestroyGLXPixmap');
+ glXQueryExtension := GetModuleSymbol(libglx, 'glXQueryExtension');
+ glXQueryVersion := GetModuleSymbol(libglx, 'glXQueryVersion');
+ glXIsDirect := GetModuleSymbol(libglx, 'glXIsDirect');
+ glXGetConfig := GetModuleSymbol(libglx, 'glXGetConfig');
+ glXGetCurrentContext := GetModuleSymbol(libglx, 'glXGetCurrentContext');
+ glXGetCurrentDrawable := GetModuleSymbol(libglx, 'glXGetCurrentDrawable');
+ glXWaitGL := GetModuleSymbol(libglx, 'glXWaitGL');
+ glXWaitX := GetModuleSymbol(libglx, 'glXWaitX');
+ glXUseXFont := GetModuleSymbol(libglx, 'glXUseXFont');
+ // GLX 1.1 and later
+ glXQueryExtensionsString := GetModuleSymbol(libglx, 'glXQueryExtensionsString');
+ glXQueryServerString := GetModuleSymbol(libglx, 'glXQueryServerString');
+ glXGetClientString := GetModuleSymbol(libglx, 'glXGetClientString');
+ // Mesa GLX Extensions
+ glXCreateGLXPixmapMESA := GetModuleSymbol(libglx, 'glXCreateGLXPixmapMESA');
+ glXReleaseBufferMESA := GetModuleSymbol(libglx, 'glXReleaseBufferMESA');
+ glXCopySubBufferMESA := GetModuleSymbol(libglx, 'glXCopySubBufferMESA');
+ glXGetVideoSyncSGI := GetModuleSymbol(libglx, 'glXGetVideoSyncSGI');
+ glXWaitVideoSyncSGI := GetModuleSymbol(libglx, 'glXWaitVideoSyncSGI');
+
+ GLXInitialized := True;
+ Result := True;
+end;
+
+function InitGLX: Boolean;
+begin
+ Result := InitGLXFromLibrary('libGL.so') or
+ InitGLXFromLibrary('libGL.so.1') or
+ InitGLXFromLibrary('libMesaGL.so') or
+ InitGLXFromLibrary('libMesaGL.so.3');
+end;
+
+
+initialization
+ InitGLX;
+finalization
+ UnloadModule(libGLX);
+end.
diff --git a/Game/Code/lib/JEDI-SDL/OpenGL/Pas/opengl12.pas b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/opengl12.pas new file mode 100644 index 00000000..763edaee --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/opengl12.pas @@ -0,0 +1,9967 @@ +unit opengl12;
+{
+ $Id: opengl12.pas,v 1.2 2004/04/05 09:59:46 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ Borland Delphi Runtime Library }
+{ OpenGL interface unit }
+{ }
+{ }
+{ This is an interface unit for the use of OpenGL from within Delphi and Kylix.}
+{ It contains the translations of gl.h, glu.h, glx.h as well as context }
+{ and extension management functions. }
+{ }
+{ The original Pascal code is: OpenGL12.pas }
+{ The initial developer of the Pascal code is Mike Lischke }
+{ }
+{ }
+{ Portions created by Microsoft are }
+{ Copyright (C) 1995-2001 Microsoft Corporation. }
+{ All Rights Reserved. }
+{ }
+{ Portions created by Silicon Graphics Incorporated are }
+{ Copyright (C) 1995-2001 Silicon Graphics Incorporated }
+{ All Rights Reserved. }
+{ }
+{ Portions created by NVidia are }
+{ Copyright (C) 1995-2001 NVidia }
+{ All Rights Reserved. }
+{ }
+{ Portions created by Brian Paul }
+{ Copyright (C) 1995-2001 Brian Paul }
+{ All Rights Reserved. }
+{ }
+{ }
+{ The original file is: gl.h }
+{ The original file is: glut.h }
+{ The original file is: glx.h }
+{ The original file is: glx.h }
+{ }
+{ Portions created by Mike Lischke are }
+{ Copyright (C) 2001 Mike Lischke. }
+{ }
+{ Portions created by John O'Harrow are }
+{ Copyright (C) 2001 John O'Harrow. }
+{ }
+{ Portions created by Eric Grange are }
+{ Copyright (C) 2001 Eric Grange. }
+{ }
+{ Portions created by Olivier Chatelain }
+{ Copyright (C) 2001 Olivier Chatelain. }
+{ }
+{ Portions created by Tom Nuydens }
+{ Copyright (C) 2001 Tom Nuydens. }
+{ }
+{ Portions created by Matthias Thoma are }
+{ Copyright (C) 2001 Matthias Thoma. }
+{ }
+{ Portions created by Sven Bobrowski are }
+{ Copyright (C) 2001 Sven Bobrowski }
+{ }
+{ }
+{ Obtained through: }
+{ }
+{ Joint Endeavour of Delphi Innovators (Project JEDI) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{******************************************************************************}
+
+//----------------------------------------------------------------------------------------------------------------------
+//
+// This is an interface unit for the use of OpenGL from within Delphi and contains
+// the translations of gl.h, glu.h as well as some support functions.
+// OpenGL12.pas contains bug fixes and enhancements of Delphi's and other translations
+// as well as support for extensions.
+//
+// NOTE: In order to fully support multi thread rendering it is necessary to hold all
+// extension address in threadvars. For single threaded applications this would be an
+// unnecessary time penalty, however. Hence there is a compiler switch to
+// allow single threaded OpenGL application to use vars while multi threaded applications
+// will use threadvars. By default the switch MULTITHREADOPENGL (see compiler switch under der interface keyword)
+// is not active and must explicitly enabled to take effect.
+//
+//----------------------------------------------------------------------------------------------------------------------
+//
+// function InitOpenGL: Boolean;
+// Needed to load the OpenGL DLLs and all addresses of the standard functions.
+// In case OpenGL is already initialized this function does nothing. No error
+// is raised, if something goes wrong, but you need to inspect the result in order
+// to know if all went okay.
+// Result: True if successful or already loaded, False otherwise.
+//
+// function InitOpenGLFromLibrary(GL_Name, GLU_Name: String): Boolean;
+// Same as InitOpenGL, but you can specify specific DLLs. Useful if you want to
+// use different DLLs than the default ones. This function closes previously
+// loaded DLLs before it tries to open the new libraries.
+// Result: True if successful, False otherwise.
+//
+// procedure CloseOpenGL;
+// Unloads the OpenGL DLLs and sets all function addresses to nil, including
+// extensions. You can load and unload the DLLs as often as you like.
+//
+// procedure ClearExtensions;
+// Sets all extension routines to nil. This is needed when you change the Pixelformat
+// of your OpenGL window, since the availability of these routines changes from
+// PixelFormat to Pixelformat (and also between various vendors).
+//
+// function CreateRenderingContext(DC: HDC; Options: TRCOptions; ColorBits, StencilBits, AccumBits, AuxBuffers: Integer;
+// Layer: Integer; var Palette: HPALETTE): HGLRC;
+// Sets up a pixel format and creates a new rendering context depending of the
+// given parameters:
+// DC - the device context for which the rc is to be created
+// Options - options for the context, which the application would like to have
+// (it is not guaranteed they will be available)
+// ColorBits - the color depth of the device context (Note: Because of the internal DC handling of the VCL you
+// should avoid using GetDeviceCaps for memory DCs which are members of a TBitmap class.
+// Translate the Pixelformat member instead!)
+// StencilBits - requested size of the stencil buffer
+// AccumBits - requested size of the accumulation buffer
+// AuxBuffers - requested number of auxiliary buffers
+// Layer - ID for the layer for which the RC will be created (-1..-15 for underlay planes, 0 for main plane,
+// 1..15 for overlay planes)
+// Note: The layer handling is not yet complete as there is very few information
+// available and (until now) no OpenGL implementation with layer support on the low budget market.
+// Hence use 0 (for the main plane) as layer ID.
+// Palette - Palette Handle created within function (need to use DeleteObject(Palette) to free this if <> 0)
+// Result: the newly created context or 0 if setup failed
+//
+// procedure ActivateRenderingContext(DC: HDC; RC: HGLRC);
+// Makes RC in DC 'current' (wglMakeCurrent(..)) and loads all extension addresses
+// and flags if necessary.
+//
+// procedure DeactivateRenderingContext;
+// Counterpart to ActivateRenderingContext.
+//
+// procedure DestroyRenderingContext(RC: HGLRC);
+// RC will be destroyed and must be recreated if you want to use it again.
+//
+// procedure ReadExtensions;
+// Determines which extensions for the current rendering context are available and
+// loads their addresses. This procedure is called from ActivateRenderingContext
+// if a new pixel format is used, but you can safely call it from where you want
+// to actualize those values (under the condition that a rendering context MUST be
+// active).
+//
+// procedure ReadImplementationProperties;
+// Determines other properties of the OpenGL DLL (version, availability of extensions).
+// Again, a valid rendering context must be active.
+//
+// function HasActiveContext: Boolean;
+// Determines whether the calling thread has currently an active rendering context.
+//----------------------------------------------------------------------------------------------------------------------
+//
+// This translation is based on different sources:
+//
+// - first translation from Artemis Alliance Inc.
+// - previous versions from Mike Lischke
+// - Alexander Staubo
+// - Borland OpenGL.pas (from Delphi 3)
+// - Microsoft and SGI OpenGL header files
+// - www.opengl.org, www.sgi.com/OpenGL
+// - nVidia extension reference as of December 1999
+// - nVidia extension reference as of January 2001
+// - vertex_array_range sample by Tom Nuydens at Delphi3D
+// - minor bug fixes and greatly extended by John O'Harrow (john@elmcrest.demon.co.uk)
+// - initial context activation balancing by Eric Grange (egrange@infonie.fr)
+// - additional nVidia extensions by Olivier Chatelain (Olivier.Chatelain@xitact.com)
+//
+// Contact: public@lischke-online.de, www.lischke-online.de
+//
+// Version: 1.2.11
+//----------------------------------------------------------------------------------------------------------------------
+//
+// 12-Feb-2002 dml :
+// - Further modifications to allow unit to compile under Free Pascal
+// as suggested by "QuePasha Pepe" <mrkroket@hotmail.com>
+//
+// 25-OCT-2001 dre :
+// - Made modifications to allow unit to compile under Free Pascal
+// - added tMaxLogPalette declaration to Free Pascal
+// - included fix to ReadExtensions
+// - Added Set8088CW procedure
+//
+// 13-SEP-2001 ml:
+// - added PWGLSwap etc. declarations for Delphi 3
+// 18-AUG-2001 ml:
+// - multi thread support for function addresses (extensions)
+// 28-JUL-2001 ml:
+// - included original type names (+ $EXTERNALSYM directives)
+// 10-JUL-2001 ml:
+// - TGLubyte changed to UCHAR
+// 05-JUL-2001 ml:
+// - own exception type for OpenGL
+// - TGLboolean is now of type BYTEBOOL
+// 05-MAY-2001 ml:
+// - correct tracking of RC creation and release as well as multithreaded RC activation
+// - compatibility routines for users of other OpenGL unit variants
+// - improved rendering context creation
+// - bug fixes
+// 01-MAY-2001 ml:
+// - added more nVidia extensions
+//----------------------------------------------------------------------------------------------------------------------
+{ April 03 2003 - DL : Added jedi-sdl.inc include file to support more }
+{ Pascal compilers. Initial support is now included }
+{ for GnuPascal, VirtualPascal, TMT and obviously }
+{ continue support for Delphi Kylix and FreePascal. }
+{ }
+{ May 03 2003 - DL : under instruction from David Mears AKA }
+{ Jason Siletto, I have added FPC Linux support. }
+{ }
+{******************************************************************************}
+{
+ $Log: opengl12.pas,v $
+ Revision 1.2 2004/04/05 09:59:46 savage
+ Changes for FreePacal as suggested by Marco
+
+ Revision 1.1 2004/03/30 21:53:55 savage
+ Moved to it's own folder.
+
+ Revision 1.6 2004/02/20 17:26:19 savage
+ Extensions are now loaded using SDL_GL_GetProcAddress, thus making it more cross-platform compatible, but now more tied to SDL.
+
+ Revision 1.5 2004/02/15 22:48:36 savage
+ More FPC and FreeBSD support changes.
+
+ Revision 1.4 2004/02/14 22:36:29 savage
+ Fixed inconsistencies of using LoadLibrary and LoadModule.
+ Now all units make use of LoadModule rather than LoadLibrary and other dynamic proc procedures.
+
+ Revision 1.3 2004/02/14 00:23:39 savage
+ As UNIX is defined in jedi-sdl.inc this will be used to check linux compatability as well. Units have been changed to reflect this change.
+
+ Revision 1.2 2004/02/14 00:09:19 savage
+ Changed uses to now make use of moduleloader.pas rather than dllfuncs.pas
+
+ Revision 1.1 2004/02/05 00:08:20 savage
+ Module 1.0 release
+
+
+}
+
+{$I jedi-sdl.inc}
+
+interface
+
+{.$define MULTITHREADOPENGL}
+
+uses
+{$IFDEF __GPC__}
+ gpc;
+{$ENDIF}
+
+{$IFDEF WIN32}
+ {$IFNDEF __GPC__}
+ Windows;
+ {$ENDIF}
+{$ENDIF}
+
+{$IFDEF Unix}
+ {$IFDEF FPC}
+ {$IFDEF Ver1_0}
+ linux,
+ {$ELSE}
+ baseunix,
+ unix,
+ {$ENDIF}
+ x,
+ xlib,
+ xutil,
+ dl;
+ {$ELSE}
+ Types,
+ Libc,
+ Xlib;
+ {$ENDIF}
+{$ENDIF}
+
+type
+ TRCOptions = set of ( opDoubleBuffered, opGDI, opStereo );
+
+ {$EXTERNALSYM GLenum}
+ GLenum = Cardinal;
+ TGLenum = Cardinal;
+ PGLenum = ^TGLenum;
+
+ {$EXTERNALSYM GLboolean}
+ GLboolean = BYTEBOOL;
+ TGLboolean = BYTEBOOL;
+ PGLboolean = ^TGLboolean;
+
+ {$EXTERNALSYM GLbitfield}
+ GLbitfield = Cardinal;
+ TGLbitfield = Cardinal;
+ PGLbitfield = ^TGLbitfield;
+
+ {$EXTERNALSYM GLbyte}
+ GLbyte = ShortInt;
+ TGLbyte = ShortInt;
+ PGLbyte = ^TGLbyte;
+
+ {$EXTERNALSYM GLshort}
+ GLshort = SmallInt;
+ TGLshort = SmallInt;
+ PGLshort = ^TGLshort;
+
+ {$EXTERNALSYM GLint}
+ GLint = Integer;
+ TGLint = Integer;
+ PGLint = ^TGLint;
+
+ {$EXTERNALSYM GLsizei}
+ GLsizei = Integer;
+ TGLsizei = Integer;
+ PGLsizei = ^TGLsizei;
+
+ {$EXTERNALSYM GLubyte}
+ UCHAR = Byte;
+ GLubyte = UCHAR;
+ TGLubyte = UCHAR;
+ PGLubyte = ^TGLubyte;
+
+ {$EXTERNALSYM GLushort}
+ GLushort = Word;
+ TGLushort = Word;
+ PGLushort = ^TGLushort;
+
+ {$EXTERNALSYM GLuint}
+ GLuint = Cardinal;
+ TGLuint = Cardinal;
+ PGLuint = ^TGLuint;
+
+ {$EXTERNALSYM GLfloat}
+ GLfloat = Single;
+ TGLfloat = Single;
+ PGLfloat = ^TGLfloat;
+
+ {$EXTERNALSYM GLclampf}
+ GLclampf = Single;
+ TGLclampf = Single;
+ PGLclampf = ^TGLclampf;
+
+ {$EXTERNALSYM GLdouble}
+ GLdouble = Double;
+ TGLdouble = Double;
+ PGLdouble = ^TGLdouble;
+
+ {$EXTERNALSYM GLclampd}
+ GLclampd = Double;
+ TGLclampd = Double;
+ PGLclampd = ^TGLclampd;
+
+ TVector3d = array[0..2] of GLdouble;
+
+ TVector4i = array[0..3] of GLint;
+ TVector4f = array[0..3] of GLfloat;
+ TVector4p = array[0..3] of Pointer;
+
+ TMatrix4f = array[0..3, 0..3] of GLfloat;
+ TMatrix4d = array[0..3, 0..3] of GLdouble;
+
+ PPointer = ^Pointer;
+
+{$ifndef FPC}
+ {$ifdef MULTITHREADOPENGL}
+ threadvar
+ {$else}
+ var
+ {$endif}
+{$else}
+var
+{$endif}
+ GL_VERSION_1_0,
+ GL_VERSION_1_1,
+ GL_VERSION_1_2,
+ GLU_VERSION_1_1,
+ GLU_VERSION_1_2,
+ GLU_VERSION_1_3: Boolean;
+
+ // Extensions (gl)
+ GL_3DFX_multisample,
+ GL_3DFX_tbuffer,
+ GL_3DFX_texture_compression_FXT1,
+
+ GL_APPLE_specular_vector,
+ GL_APPLE_transform_hint,
+
+ GL_ARB_imaging,
+ GL_ARB_multisample,
+ GL_ARB_multitexture,
+ GL_ARB_texture_compression,
+ GL_ARB_texture_cube_map,
+ GL_ARB_transpose_matrix,
+ GL_ARB_vertex_blend,
+
+ GL_EXT_422_pixels,
+ GL_EXT_abgr,
+ GL_EXT_bgra,
+ GL_EXT_blend_color,
+ GL_EXT_blend_func_separate,
+ GL_EXT_blend_logic_op,
+ GL_EXT_blend_minmax,
+ GL_EXT_blend_subtract,
+ GL_EXT_clip_volume_hint,
+ GL_EXT_cmyka,
+ GL_EXT_color_subtable,
+ GL_EXT_compiled_vertex_array,
+ GL_EXT_convolution,
+ GL_EXT_coordinate_frame,
+ GL_EXT_copy_texture,
+ GL_EXT_cull_vertex,
+ GL_EXT_draw_range_elements,
+ GL_EXT_fog_coord,
+ GL_EXT_histogram,
+ GL_EXT_index_array_formats,
+ GL_EXT_index_func,
+ GL_EXT_index_material,
+ GL_EXT_index_texture,
+ GL_EXT_light_max_exponent,
+ GL_EXT_light_texture,
+ GL_EXT_misc_attribute,
+ GL_EXT_multi_draw_arrays,
+ GL_EXT_multisample,
+ GL_EXT_packed_pixels,
+ GL_EXT_paletted_texture,
+ GL_EXT_pixel_transform,
+ GL_EXT_point_parameters,
+ GL_EXT_polygon_offset,
+ GL_EXT_rescale_normal,
+ GL_EXT_scene_marker,
+ GL_EXT_secondary_color,
+ GL_EXT_separate_specular_color,
+ GL_EXT_shared_texture_palette,
+ GL_EXT_stencil_wrap,
+ GL_EXT_subtexture,
+ GL_EXT_texture_color_table,
+ GL_EXT_texture_compression_s3tc,
+ GL_EXT_texture_cube_map,
+ GL_EXT_texture_edge_clamp,
+ GL_EXT_texture_env_add,
+ GL_EXT_texture_env_combine,
+ GL_EXT_texture_filter_anisotropic,
+ GL_EXT_texture_lod_bias,
+ GL_EXT_texture_object,
+ GL_EXT_texture_perturb_normal,
+ GL_EXT_texture3D,
+ GL_EXT_vertex_array,
+ GL_EXT_vertex_weighting,
+
+ GL_FfdMaskSGIX,
+ GL_HP_convolution_border_modes,
+ GL_HP_image_transform,
+ GL_HP_occlusion_test,
+ GL_HP_texture_lighting,
+
+ GL_IBM_cull_vertex,
+ GL_IBM_multimode_draw_arrays,
+ GL_IBM_rasterpos_clip,
+ GL_IBM_vertex_array_lists,
+
+ GL_INGR_color_clamp,
+ GL_INGR_interlace_read,
+
+ GL_INTEL_parallel_arrays,
+
+ GL_KTX_buffer_region,
+
+ GL_MESA_resize_buffers,
+ GL_MESA_window_pos,
+
+ GL_NV_blend_square,
+ GL_NV_fog_distance,
+ GL_NV_light_max_exponent,
+ GL_NV_register_combiners,
+ GL_NV_texgen_emboss,
+ GL_NV_texgen_reflection,
+ GL_NV_texture_env_combine4,
+ GL_NV_vertex_array_range,
+ GL_NV_vertex_program,
+
+ GL_PGI_misc_hints,
+ GL_PGI_vertex_hints,
+
+ GL_REND_screen_coordinates,
+
+ GL_SGI_color_matrix,
+ GL_SGI_color_table,
+ GL_SGI_depth_pass_instrument,
+
+ GL_SGIS_detail_texture,
+ GL_SGIS_fog_function,
+ GL_SGIS_generate_mipmap,
+ GL_SGIS_multisample,
+ GL_SGIS_multitexture,
+ GL_SGIS_pixel_texture,
+ GL_SGIS_point_line_texgen,
+ GL_SGIS_point_parameters,
+ GL_SGIS_sharpen_texture,
+ GL_SGIS_texture_border_clamp,
+ GL_SGIS_texture_color_mask,
+ GL_SGIS_texture_edge_clamp,
+ GL_SGIS_texture_filter4,
+ GL_SGIS_texture_lod,
+ GL_SGIS_texture_select,
+ GL_SGIS_texture4D,
+
+ GL_SGIX_async,
+ GL_SGIX_async_histogram,
+ GL_SGIX_async_pixel,
+ GL_SGIX_blend_alpha_minmax,
+ GL_SGIX_calligraphic_fragment,
+ GL_SGIX_clipmap,
+ GL_SGIX_convolution_accuracy,
+ GL_SGIX_depth_texture,
+ GL_SGIX_flush_raster,
+ GL_SGIX_fog_offset,
+ GL_SGIX_fog_scale,
+ GL_SGIX_fragment_lighting,
+ GL_SGIX_framezoom,
+ GL_SGIX_igloo_interface,
+ GL_SGIX_instruments,
+ GL_SGIX_interlace,
+ GL_SGIX_ir_instrument1,
+ GL_SGIX_list_priority,
+ GL_SGIX_pixel_texture,
+ GL_SGIX_pixel_tiles,
+ GL_SGIX_polynomial_ffd,
+ GL_SGIX_reference_plane,
+ GL_SGIX_resample,
+ GL_SGIX_shadow,
+ GL_SGIX_shadow_ambient,
+ GL_SGIX_sprite,
+ GL_SGIX_subsample,
+ GL_SGIX_tag_sample_buffer,
+ GL_SGIX_texture_add_env,
+ GL_SGIX_texture_lod_bias,
+ GL_SGIX_texture_multi_buffer,
+ GL_SGIX_texture_scale_bias,
+ GL_SGIX_vertex_preclip,
+ GL_SGIX_ycrcb,
+ GL_SGIX_ycrcba,
+
+ GL_SUN_convolution_border_modes,
+ GL_SUN_global_alpha,
+ GL_SUN_triangle_list,
+ GL_SUN_vertex,
+
+ GL_SUNX_constant_data,
+
+ GL_WIN_phong_shading,
+ GL_WIN_specular_fog,
+ GL_WIN_swap_hint,
+
+ WGL_EXT_swap_control,
+ WGL_ARB_extensions_string,
+ WGL_ARB_pixel_format,
+
+ // Extensions (glu)
+ GLU_EXT_Texture,
+ GLU_EXT_object_space_tess,
+ GLU_EXT_nurbs_tessellator: Boolean;
+
+const
+ // ********** GL generic constants **********
+
+ // errors
+ GL_NO_ERROR = 0;
+ {$EXTERNALSYM GL_NO_ERROR}
+ GL_INVALID_ENUM = $0500;
+ {$EXTERNALSYM GL_INVALID_ENUM}
+ GL_INVALID_VALUE = $0501;
+ {$EXTERNALSYM GL_INVALID_VALUE}
+ GL_INVALID_OPERATION = $0502;
+ {$EXTERNALSYM GL_INVALID_OPERATION}
+ GL_STACK_OVERFLOW = $0503;
+ {$EXTERNALSYM GL_STACK_OVERFLOW}
+ GL_STACK_UNDERFLOW = $0504;
+ {$EXTERNALSYM GL_STACK_UNDERFLOW}
+ GL_OUT_OF_MEMORY = $0505;
+ {$EXTERNALSYM GL_STACK_UNDERFLOW}
+
+ // attribute bits
+ GL_CURRENT_BIT = $00000001;
+ {$EXTERNALSYM GL_CURRENT_BIT}
+ GL_POINT_BIT = $00000002;
+ {$EXTERNALSYM GL_POINT_BIT}
+ GL_LINE_BIT = $00000004;
+ {$EXTERNALSYM GL_LINE_BIT}
+ GL_POLYGON_BIT = $00000008;
+ {$EXTERNALSYM GL_POLYGON_BIT}
+ GL_POLYGON_STIPPLE_BIT = $00000010;
+ {$EXTERNALSYM GL_POLYGON_STIPPLE_BIT}
+ GL_PIXEL_MODE_BIT = $00000020;
+ {$EXTERNALSYM GL_PIXEL_MODE_BIT}
+ GL_LIGHTING_BIT = $00000040;
+ {$EXTERNALSYM GL_LIGHTING_BIT}
+ GL_FOG_BIT = $00000080;
+ {$EXTERNALSYM GL_FOG_BIT}
+ GL_DEPTH_BUFFER_BIT = $00000100;
+ {$EXTERNALSYM GL_DEPTH_BUFFER_BIT}
+ GL_ACCUM_BUFFER_BIT = $00000200;
+ {$EXTERNALSYM GL_ACCUM_BUFFER_BIT}
+ GL_STENCIL_BUFFER_BIT = $00000400;
+ {$EXTERNALSYM GL_STENCIL_BUFFER_BIT}
+ GL_VIEWPORT_BIT = $00000800;
+ {$EXTERNALSYM GL_VIEWPORT_BIT}
+ GL_TRANSFORM_BIT = $00001000;
+ {$EXTERNALSYM GL_TRANSFORM_BIT}
+ GL_ENABLE_BIT = $00002000;
+ {$EXTERNALSYM GL_ENABLE_BIT}
+ GL_COLOR_BUFFER_BIT = $00004000;
+ {$EXTERNALSYM GL_COLOR_BUFFER_BIT}
+ GL_HINT_BIT = $00008000;
+ {$EXTERNALSYM GL_HINT_BIT}
+ GL_EVAL_BIT = $00010000;
+ {$EXTERNALSYM GL_EVAL_BIT}
+ GL_LIST_BIT = $00020000;
+ {$EXTERNALSYM GL_LIST_BIT}
+ GL_TEXTURE_BIT = $00040000;
+ {$EXTERNALSYM GL_TEXTURE_BIT}
+ GL_SCISSOR_BIT = $00080000;
+ {$EXTERNALSYM GL_SCISSOR_BIT}
+ GL_ALL_ATTRIB_BITS = $000FFFFF;
+ {$EXTERNALSYM GL_ALL_ATTRIB_BITS}
+
+ // client attribute bits
+ GL_CLIENT_PIXEL_STORE_BIT = $00000001;
+ {$EXTERNALSYM GL_CLIENT_PIXEL_STORE_BIT}
+ GL_CLIENT_VERTEX_ARRAY_BIT = $00000002;
+ {$EXTERNALSYM GL_CLIENT_VERTEX_ARRAY_BIT}
+ GL_CLIENT_ALL_ATTRIB_BITS = $FFFFFFFF;
+ {$EXTERNALSYM GL_CLIENT_ALL_ATTRIB_BITS}
+
+ // boolean values
+ GL_FALSE = Boolean( 0 );
+ {$EXTERNALSYM GL_FALSE}
+ GL_TRUE = Boolean( 1 );
+ {$EXTERNALSYM GL_TRUE}
+
+ // primitives
+ GL_POINTS = $0000;
+ {$EXTERNALSYM GL_POINTS}
+ GL_LINES = $0001;
+ {$EXTERNALSYM GL_LINES}
+ GL_LINE_LOOP = $0002;
+ {$EXTERNALSYM GL_LINE_LOOP}
+ GL_LINE_STRIP = $0003;
+ {$EXTERNALSYM GL_LINE_STRIP}
+ GL_TRIANGLES = $0004;
+ {$EXTERNALSYM GL_TRIANGLES}
+ GL_TRIANGLE_STRIP = $0005;
+ {$EXTERNALSYM GL_TRIANGLE_STRIP}
+ GL_TRIANGLE_FAN = $0006;
+ {$EXTERNALSYM GL_TRIANGLE_FAN}
+ GL_QUADS = $0007;
+ {$EXTERNALSYM GL_QUADS}
+ GL_QUAD_STRIP = $0008;
+ {$EXTERNALSYM GL_QUAD_STRIP}
+ GL_POLYGON = $0009;
+ {$EXTERNALSYM GL_POLYGON}
+
+ // blending
+ GL_ZERO = 0;
+ {$EXTERNALSYM GL_ZERO}
+ GL_ONE = 1;
+ {$EXTERNALSYM GL_ONE}
+ GL_SRC_COLOR = $0300;
+ {$EXTERNALSYM GL_SRC_COLOR}
+ GL_ONE_MINUS_SRC_COLOR = $0301;
+ {$EXTERNALSYM GL_ONE_MINUS_SRC_COLOR}
+ GL_SRC_ALPHA = $0302;
+ {$EXTERNALSYM GL_SRC_ALPHA}
+ GL_ONE_MINUS_SRC_ALPHA = $0303;
+ {$EXTERNALSYM GL_ONE_MINUS_SRC_ALPHA}
+ GL_DST_ALPHA = $0304;
+ {$EXTERNALSYM GL_DST_ALPHA}
+ GL_ONE_MINUS_DST_ALPHA = $0305;
+ {$EXTERNALSYM GL_ONE_MINUS_DST_ALPHA}
+ GL_DST_COLOR = $0306;
+ {$EXTERNALSYM GL_DST_COLOR}
+ GL_ONE_MINUS_DST_COLOR = $0307;
+ {$EXTERNALSYM GL_ONE_MINUS_DST_COLOR}
+ GL_SRC_ALPHA_SATURATE = $0308;
+ {$EXTERNALSYM GL_SRC_ALPHA_SATURATE}
+ GL_BLEND_DST = $0BE0;
+ {$EXTERNALSYM GL_BLEND_DST}
+ GL_BLEND_SRC = $0BE1;
+ {$EXTERNALSYM GL_BLEND_SRC}
+ GL_BLEND = $0BE2;
+ {$EXTERNALSYM GL_BLEND}
+
+ // blending (GL 1.2 ARB imaging)
+ GL_BLEND_COLOR = $8005;
+ {$EXTERNALSYM GL_BLEND_COLOR}
+ GL_CONSTANT_COLOR = $8001;
+ {$EXTERNALSYM GL_CONSTANT_COLOR}
+ GL_ONE_MINUS_CONSTANT_COLOR = $8002;
+ {$EXTERNALSYM GL_ONE_MINUS_CONSTANT_COLOR}
+ GL_CONSTANT_ALPHA = $8003;
+ {$EXTERNALSYM GL_CONSTANT_ALPHA}
+ GL_ONE_MINUS_CONSTANT_ALPHA = $8004;
+ {$EXTERNALSYM GL_ONE_MINUS_CONSTANT_ALPHA}
+ GL_FUNC_ADD = $8006;
+ {$EXTERNALSYM GL_FUNC_ADD}
+ GL_MIN = $8007;
+ {$EXTERNALSYM GL_MIN}
+ GL_MAX = $8008;
+ {$EXTERNALSYM GL_MAX}
+ GL_FUNC_SUBTRACT = $800A;
+ {$EXTERNALSYM GL_FUNC_SUBTRACT}
+ GL_FUNC_REVERSE_SUBTRACT = $800B;
+ {$EXTERNALSYM GL_FUNC_REVERSE_SUBTRACT}
+
+ // color table GL 1.2 ARB imaging
+ GL_COLOR_TABLE = $80D0;
+ {$EXTERNALSYM GL_COLOR_TABLE}
+ GL_POST_CONVOLUTION_COLOR_TABLE = $80D1;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_COLOR_TABLE}
+ GL_POST_COLOR_MATRIX_COLOR_TABLE = $80D2;
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_COLOR_TABLE}
+ GL_PROXY_COLOR_TABLE = $80D3;
+ {$EXTERNALSYM GL_PROXY_COLOR_TABLE}
+ GL_PROXY_POST_CONVOLUTION_COLOR_TABLE = $80D4;
+ {$EXTERNALSYM GL_PROXY_POST_CONVOLUTION_COLOR_TABLE}
+ GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE = $80D5;
+ {$EXTERNALSYM GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE}
+ GL_COLOR_TABLE_SCALE = $80D6;
+ {$EXTERNALSYM GL_COLOR_TABLE_SCALE}
+ GL_COLOR_TABLE_BIAS = $80D7;
+ {$EXTERNALSYM GL_COLOR_TABLE_BIAS}
+ GL_COLOR_TABLE_FORMAT = $80D8;
+ {$EXTERNALSYM GL_COLOR_TABLE_FORMAT}
+ GL_COLOR_TABLE_WIDTH = $80D9;
+ {$EXTERNALSYM GL_COLOR_TABLE_WIDTH}
+ GL_COLOR_TABLE_RED_SIZE = $80DA;
+ {$EXTERNALSYM GL_COLOR_TABLE_RED_SIZE}
+ GL_COLOR_TABLE_GREEN_SIZE = $80DB;
+ {$EXTERNALSYM GL_COLOR_TABLE_GREEN_SIZE}
+ GL_COLOR_TABLE_BLUE_SIZE = $80DC;
+ {$EXTERNALSYM GL_COLOR_TABLE_BLUE_SIZE}
+ GL_COLOR_TABLE_ALPHA_SIZE = $80DD;
+ {$EXTERNALSYM GL_COLOR_TABLE_ALPHA_SIZE}
+ GL_COLOR_TABLE_LUMINANCE_SIZE = $80DE;
+ {$EXTERNALSYM GL_COLOR_TABLE_LUMINANCE_SIZE}
+ GL_COLOR_TABLE_INTENSITY_SIZE = $80DF;
+ {$EXTERNALSYM GL_COLOR_TABLE_INTENSITY_SIZE}
+
+ // convolutions GL 1.2 ARB imaging
+ GL_CONVOLUTION_1D = $8010;
+ {$EXTERNALSYM GL_CONVOLUTION_1D}
+ GL_CONVOLUTION_2D = $8011;
+ {$EXTERNALSYM GL_CONVOLUTION_2D}
+ GL_SEPARABLE_2D = $8012;
+ {$EXTERNALSYM GL_SEPARABLE_2D}
+ GL_CONVOLUTION_BORDER_MODE = $8013;
+ {$EXTERNALSYM GL_CONVOLUTION_BORDER_MODE}
+ GL_CONVOLUTION_FILTER_SCALE = $8014;
+ {$EXTERNALSYM GL_CONVOLUTION_FILTER_SCALE}
+ GL_CONVOLUTION_FILTER_BIAS = $8015;
+ {$EXTERNALSYM GL_CONVOLUTION_FILTER_BIAS}
+ GL_REDUCE = $8016;
+ {$EXTERNALSYM GL_REDUCE}
+ GL_CONVOLUTION_FORMAT = $8017;
+ {$EXTERNALSYM GL_CONVOLUTION_FORMAT}
+ GL_CONVOLUTION_WIDTH = $8018;
+ {$EXTERNALSYM GL_CONVOLUTION_WIDTH}
+ GL_CONVOLUTION_HEIGHT = $8019;
+ {$EXTERNALSYM GL_CONVOLUTION_HEIGHT}
+ GL_MAX_CONVOLUTION_WIDTH = $801A;
+ {$EXTERNALSYM GL_MAX_CONVOLUTION_WIDTH}
+ GL_MAX_CONVOLUTION_HEIGHT = $801B;
+ {$EXTERNALSYM GL_MAX_CONVOLUTION_HEIGHT}
+ GL_POST_CONVOLUTION_RED_SCALE = $801C;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_RED_SCALE}
+ GL_POST_CONVOLUTION_GREEN_SCALE = $801D;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_GREEN_SCALE}
+ GL_POST_CONVOLUTION_BLUE_SCALE = $801E;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_BLUE_SCALE}
+ GL_POST_CONVOLUTION_ALPHA_SCALE = $801F;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_ALPHA_SCALE}
+ GL_POST_CONVOLUTION_RED_BIAS = $8020;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_RED_BIAS}
+ GL_POST_CONVOLUTION_GREEN_BIAS = $8021;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_GREEN_BIAS}
+ GL_POST_CONVOLUTION_BLUE_BIAS = $8022;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_BLUE_BIAS}
+ GL_POST_CONVOLUTION_ALPHA_BIAS = $8023;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_ALPHA_BIAS}
+
+ // histogram GL 1.2 ARB imaging
+ GL_HISTOGRAM = $8024;
+ {$EXTERNALSYM GL_HISTOGRAM}
+ GL_PROXY_HISTOGRAM = $8025;
+ {$EXTERNALSYM GL_PROXY_HISTOGRAM}
+ GL_HISTOGRAM_WIDTH = $8026;
+ {$EXTERNALSYM GL_HISTOGRAM_WIDTH}
+ GL_HISTOGRAM_FORMAT = $8027;
+ {$EXTERNALSYM GL_HISTOGRAM_FORMAT}
+ GL_HISTOGRAM_RED_SIZE = $8028;
+ {$EXTERNALSYM GL_HISTOGRAM_RED_SIZE}
+ GL_HISTOGRAM_GREEN_SIZE = $8029;
+ {$EXTERNALSYM GL_HISTOGRAM_GREEN_SIZE}
+ GL_HISTOGRAM_BLUE_SIZE = $802A;
+ {$EXTERNALSYM GL_HISTOGRAM_BLUE_SIZE}
+ GL_HISTOGRAM_ALPHA_SIZE = $802B;
+ {$EXTERNALSYM GL_HISTOGRAM_ALPHA_SIZE}
+ GL_HISTOGRAM_LUMINANCE_SIZE = $802C;
+ {$EXTERNALSYM GL_HISTOGRAM_LUMINANCE_SIZE}
+ GL_HISTOGRAM_SINK = $802D;
+ {$EXTERNALSYM GL_HISTOGRAM_SINK}
+ GL_MINMAX = $802E;
+ {$EXTERNALSYM GL_MINMAX}
+ GL_MINMAX_FORMAT = $802F;
+ {$EXTERNALSYM GL_MINMAX_FORMAT}
+ GL_MINMAX_SINK = $8030;
+ {$EXTERNALSYM GL_MINMAX_SINK}
+
+ // buffers
+ GL_NONE = 0;
+ {$EXTERNALSYM GL_NONE}
+ GL_FRONT_LEFT = $0400;
+ {$EXTERNALSYM GL_FRONT_LEFT}
+ GL_FRONT_RIGHT = $0401;
+ {$EXTERNALSYM GL_FRONT_RIGHT}
+ GL_BACK_LEFT = $0402;
+ {$EXTERNALSYM GL_BACK_LEFT}
+ GL_BACK_RIGHT = $0403;
+ {$EXTERNALSYM GL_BACK_RIGHT}
+ GL_FRONT = $0404;
+ {$EXTERNALSYM GL_FRONT}
+ GL_BACK = $0405;
+ {$EXTERNALSYM GL_BACK}
+ GL_LEFT = $0406;
+ {$EXTERNALSYM GL_LEFT}
+ GL_RIGHT = $0407;
+ {$EXTERNALSYM GL_RIGHT}
+ GL_FRONT_AND_BACK = $0408;
+ {$EXTERNALSYM GL_FRONT_AND_BACK}
+ GL_AUX0 = $0409;
+ {$EXTERNALSYM GL_AUX0}
+ GL_AUX1 = $040A;
+ {$EXTERNALSYM GL_AUX1}
+ GL_AUX2 = $040B;
+ {$EXTERNALSYM GL_AUX2}
+ GL_AUX3 = $040C;
+ {$EXTERNALSYM GL_AUX3}
+ GL_AUX_BUFFERS = $0C00;
+ {$EXTERNALSYM GL_AUX_BUFFERS}
+ GL_DRAW_BUFFER = $0C01;
+ {$EXTERNALSYM GL_DRAW_BUFFER}
+ GL_READ_BUFFER = $0C02;
+ {$EXTERNALSYM GL_READ_BUFFER}
+ GL_DOUBLEBUFFER = $0C32;
+ {$EXTERNALSYM GL_DOUBLEBUFFER}
+ GL_STEREO = $0C33;
+ {$EXTERNALSYM GL_STEREO}
+
+ // depth buffer
+ GL_DEPTH_RANGE = $0B70;
+ {$EXTERNALSYM GL_DEPTH_RANGE}
+ GL_DEPTH_TEST = $0B71;
+ {$EXTERNALSYM GL_DEPTH_TEST}
+ GL_DEPTH_WRITEMASK = $0B72;
+ {$EXTERNALSYM GL_DEPTH_WRITEMASK}
+ GL_DEPTH_CLEAR_VALUE = $0B73;
+ {$EXTERNALSYM GL_DEPTH_CLEAR_VALUE}
+ GL_DEPTH_FUNC = $0B74;
+ {$EXTERNALSYM GL_DEPTH_FUNC}
+ GL_NEVER = $0200;
+ {$EXTERNALSYM GL_NEVER}
+ GL_LESS = $0201;
+ {$EXTERNALSYM GL_LESS}
+ GL_EQUAL = $0202;
+ {$EXTERNALSYM GL_EQUAL}
+ GL_LEQUAL = $0203;
+ {$EXTERNALSYM GL_LEQUAL}
+ GL_GREATER = $0204;
+ {$EXTERNALSYM GL_GREATER}
+ GL_NOTEQUAL = $0205;
+ {$EXTERNALSYM GL_NOTEQUAL}
+ GL_GEQUAL = $0206;
+ {$EXTERNALSYM GL_GEQUAL}
+ GL_ALWAYS = $0207;
+ {$EXTERNALSYM GL_ALWAYS}
+
+ // accumulation buffer
+ GL_ACCUM = $0100;
+ {$EXTERNALSYM GL_ACCUM}
+ GL_LOAD = $0101;
+ {$EXTERNALSYM GL_LOAD}
+ GL_RETURN = $0102;
+ {$EXTERNALSYM GL_RETURN}
+ GL_MULT = $0103;
+ {$EXTERNALSYM GL_MULT}
+ GL_ADD = $0104;
+ {$EXTERNALSYM GL_ADD}
+ GL_ACCUM_CLEAR_VALUE = $0B80;
+ {$EXTERNALSYM GL_ACCUM_CLEAR_VALUE}
+
+ // feedback buffer
+ GL_FEEDBACK_BUFFER_POINTER = $0DF0;
+ {$EXTERNALSYM GL_FEEDBACK_BUFFER_POINTER}
+ GL_FEEDBACK_BUFFER_SIZE = $0DF1;
+ {$EXTERNALSYM GL_FEEDBACK_BUFFER_SIZE}
+ GL_FEEDBACK_BUFFER_TYPE = $0DF2;
+ {$EXTERNALSYM GL_FEEDBACK_BUFFER_TYPE}
+
+ // feedback types
+ GL_2D = $0600;
+ {$EXTERNALSYM GL_2D}
+ GL_3D = $0601;
+ {$EXTERNALSYM GL_3D}
+ GL_3D_COLOR = $0602;
+ {$EXTERNALSYM GL_3D_COLOR}
+ GL_3D_COLOR_TEXTURE = $0603;
+ {$EXTERNALSYM GL_3D_COLOR_TEXTURE}
+ GL_4D_COLOR_TEXTURE = $0604;
+ {$EXTERNALSYM GL_4D_COLOR_TEXTURE}
+
+ // feedback tokens
+ GL_PASS_THROUGH_TOKEN = $0700;
+ {$EXTERNALSYM GL_PASS_THROUGH_TOKEN}
+ GL_POINT_TOKEN = $0701;
+ {$EXTERNALSYM GL_POINT_TOKEN}
+ GL_LINE_TOKEN = $0702;
+ {$EXTERNALSYM GL_LINE_TOKEN}
+ GL_POLYGON_TOKEN = $0703;
+ {$EXTERNALSYM GL_POLYGON_TOKEN}
+ GL_BITMAP_TOKEN = $0704;
+ {$EXTERNALSYM GL_BITMAP_TOKEN}
+ GL_DRAW_PIXEL_TOKEN = $0705;
+ {$EXTERNALSYM GL_DRAW_PIXEL_TOKEN}
+ GL_COPY_PIXEL_TOKEN = $0706;
+ {$EXTERNALSYM GL_COPY_PIXEL_TOKEN}
+ GL_LINE_RESET_TOKEN = $0707;
+ {$EXTERNALSYM GL_LINE_RESET_TOKEN}
+
+ // fog
+ GL_EXP = $0800;
+ {$EXTERNALSYM GL_EXP}
+ GL_EXP2 = $0801;
+ {$EXTERNALSYM GL_EXP2}
+ GL_FOG = $0B60;
+ {$EXTERNALSYM GL_FOG}
+ GL_FOG_INDEX = $0B61;
+ {$EXTERNALSYM GL_FOG_INDEX}
+ GL_FOG_DENSITY = $0B62;
+ {$EXTERNALSYM GL_FOG_DENSITY}
+ GL_FOG_START = $0B63;
+ {$EXTERNALSYM GL_FOG_START}
+ GL_FOG_END = $0B64;
+ {$EXTERNALSYM GL_FOG_END}
+ GL_FOG_MODE = $0B65;
+ {$EXTERNALSYM GL_FOG_MODE}
+ GL_FOG_COLOR = $0B66;
+ {$EXTERNALSYM GL_FOG_COLOR}
+
+ // pixel mode, transfer
+ GL_PIXEL_MAP_I_TO_I = $0C70;
+ {$EXTERNALSYM GL_PIXEL_MAP_I_TO_I}
+ GL_PIXEL_MAP_S_TO_S = $0C71;
+ {$EXTERNALSYM GL_PIXEL_MAP_S_TO_S}
+ GL_PIXEL_MAP_I_TO_R = $0C72;
+ {$EXTERNALSYM GL_PIXEL_MAP_I_TO_R}
+ GL_PIXEL_MAP_I_TO_G = $0C73;
+ {$EXTERNALSYM GL_PIXEL_MAP_I_TO_G}
+ GL_PIXEL_MAP_I_TO_B = $0C74;
+ {$EXTERNALSYM GL_PIXEL_MAP_I_TO_B}
+ GL_PIXEL_MAP_I_TO_A = $0C75;
+ {$EXTERNALSYM GL_PIXEL_MAP_I_TO_A}
+ GL_PIXEL_MAP_R_TO_R = $0C76;
+ {$EXTERNALSYM GL_PIXEL_MAP_R_TO_R}
+ GL_PIXEL_MAP_G_TO_G = $0C77;
+ {$EXTERNALSYM GL_PIXEL_MAP_G_TO_G}
+ GL_PIXEL_MAP_B_TO_B = $0C78;
+ {$EXTERNALSYM GL_PIXEL_MAP_B_TO_B}
+ GL_PIXEL_MAP_A_TO_A = $0C79;
+ {$EXTERNALSYM GL_PIXEL_MAP_A_TO_A}
+
+ // vertex arrays
+ GL_VERTEX_ARRAY_POINTER = $808E;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_POINTER}
+ GL_NORMAL_ARRAY_POINTER = $808F;
+ {$EXTERNALSYM GL_NORMAL_ARRAY_POINTER}
+ GL_COLOR_ARRAY_POINTER = $8090;
+ {$EXTERNALSYM GL_COLOR_ARRAY_POINTER}
+ GL_INDEX_ARRAY_POINTER = $8091;
+ {$EXTERNALSYM GL_INDEX_ARRAY_POINTER}
+ GL_TEXTURE_COORD_ARRAY_POINTER = $8092;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_POINTER}
+ GL_EDGE_FLAG_ARRAY_POINTER = $8093;
+ {$EXTERNALSYM GL_EDGE_FLAG_ARRAY_POINTER}
+
+ // stenciling
+ GL_STENCIL_TEST = $0B90;
+ {$EXTERNALSYM GL_STENCIL_TEST}
+ GL_STENCIL_CLEAR_VALUE = $0B91;
+ {$EXTERNALSYM GL_STENCIL_CLEAR_VALUE}
+ GL_STENCIL_FUNC = $0B92;
+ {$EXTERNALSYM GL_STENCIL_FUNC}
+ GL_STENCIL_VALUE_MASK = $0B93;
+ {$EXTERNALSYM GL_STENCIL_VALUE_MASK}
+ GL_STENCIL_FAIL = $0B94;
+ {$EXTERNALSYM GL_STENCIL_FAIL}
+ GL_STENCIL_PASS_DEPTH_FAIL = $0B95;
+ {$EXTERNALSYM GL_STENCIL_PASS_DEPTH_FAIL}
+ GL_STENCIL_PASS_DEPTH_PASS = $0B96;
+ {$EXTERNALSYM GL_STENCIL_PASS_DEPTH_PASS}
+ GL_STENCIL_REF = $0B97;
+ {$EXTERNALSYM GL_STENCIL_REF}
+ GL_STENCIL_WRITEMASK = $0B98;
+ {$EXTERNALSYM GL_STENCIL_WRITEMASK}
+ GL_KEEP = $1E00;
+ {$EXTERNALSYM GL_KEEP}
+ GL_REPLACE = $1E01;
+ {$EXTERNALSYM GL_REPLACE}
+ GL_INCR = $1E02;
+ {$EXTERNALSYM GL_INCR}
+ GL_DECR = $1E03;
+ {$EXTERNALSYM GL_DECR}
+
+ // color material
+ GL_COLOR_MATERIAL_FACE = $0B55;
+ {$EXTERNALSYM GL_COLOR_MATERIAL_FACE}
+ GL_COLOR_MATERIAL_PARAMETER = $0B56;
+ {$EXTERNALSYM GL_COLOR_MATERIAL_PARAMETER}
+ GL_COLOR_MATERIAL = $0B57;
+ {$EXTERNALSYM GL_COLOR_MATERIAL}
+
+ // points
+ GL_POINT_SMOOTH = $0B10;
+ {$EXTERNALSYM GL_POINT_SMOOTH}
+ GL_POINT_SIZE = $0B11;
+ {$EXTERNALSYM GL_POINT_SIZE}
+ GL_POINT_SIZE_RANGE = $0B12;
+ {$EXTERNALSYM GL_POINT_SIZE_RANGE}
+ GL_POINT_SIZE_GRANULARITY = $0B13;
+ {$EXTERNALSYM GL_POINT_SIZE_GRANULARITY}
+
+ // lines
+ GL_LINE_SMOOTH = $0B20;
+ {$EXTERNALSYM GL_LINE_SMOOTH}
+ GL_LINE_WIDTH = $0B21;
+ {$EXTERNALSYM GL_LINE_WIDTH}
+ GL_LINE_WIDTH_RANGE = $0B22;
+ {$EXTERNALSYM GL_LINE_WIDTH_RANGE}
+ GL_LINE_WIDTH_GRANULARITY = $0B23;
+ {$EXTERNALSYM GL_LINE_WIDTH_GRANULARITY}
+ GL_LINE_STIPPLE = $0B24;
+ {$EXTERNALSYM GL_LINE_STIPPLE}
+ GL_LINE_STIPPLE_PATTERN = $0B25;
+ {$EXTERNALSYM GL_LINE_STIPPLE_PATTERN}
+ GL_LINE_STIPPLE_REPEAT = $0B26;
+ {$EXTERNALSYM GL_LINE_STIPPLE_REPEAT}
+
+ // polygons
+ GL_POLYGON_MODE = $0B40;
+ {$EXTERNALSYM GL_POLYGON_MODE}
+ GL_POLYGON_SMOOTH = $0B41;
+ {$EXTERNALSYM GL_POLYGON_SMOOTH}
+ GL_POLYGON_STIPPLE = $0B42;
+ {$EXTERNALSYM GL_POLYGON_STIPPLE}
+ GL_EDGE_FLAG = $0B43;
+ {$EXTERNALSYM GL_EDGE_FLAG}
+ GL_CULL_FACE = $0B44;
+ {$EXTERNALSYM GL_CULL_FACE}
+ GL_CULL_FACE_MODE = $0B45;
+ {$EXTERNALSYM GL_CULL_FACE_MODE}
+ GL_FRONT_FACE = $0B46;
+ {$EXTERNALSYM GL_FRONT_FACE}
+ GL_CW = $0900;
+ {$EXTERNALSYM GL_CW}
+ GL_CCW = $0901;
+ {$EXTERNALSYM GL_CCW}
+ GL_POINT = $1B00;
+ {$EXTERNALSYM GL_POINT}
+ GL_LINE = $1B01;
+ {$EXTERNALSYM GL_LINE}
+ GL_FILL = $1B02;
+ {$EXTERNALSYM GL_FILL}
+
+ // display lists
+ GL_LIST_MODE = $0B30;
+ {$EXTERNALSYM GL_LIST_MODE}
+ GL_LIST_BASE = $0B32;
+ {$EXTERNALSYM GL_LIST_BASE}
+ GL_LIST_INDEX = $0B33;
+ {$EXTERNALSYM GL_LIST_INDEX}
+ GL_COMPILE = $1300;
+ {$EXTERNALSYM GL_COMPILE}
+ GL_COMPILE_AND_EXECUTE = $1301;
+ {$EXTERNALSYM GL_COMPILE_AND_EXECUTE}
+
+ // lighting
+ GL_LIGHTING = $0B50;
+ {$EXTERNALSYM GL_LIGHTING}
+ GL_LIGHT_MODEL_LOCAL_VIEWER = $0B51;
+ {$EXTERNALSYM GL_LIGHT_MODEL_LOCAL_VIEWER}
+ GL_LIGHT_MODEL_TWO_SIDE = $0B52;
+ {$EXTERNALSYM GL_LIGHT_MODEL_TWO_SIDE}
+ GL_LIGHT_MODEL_AMBIENT = $0B53;
+ {$EXTERNALSYM GL_LIGHT_MODEL_AMBIENT}
+ GL_LIGHT_MODEL_COLOR_CONTROL = $81F8; // GL 1.2
+ {$EXTERNALSYM GL_LIGHT_MODEL_COLOR_CONTROL}
+ GL_SHADE_MODEL = $0B54;
+ {$EXTERNALSYM GL_SHADE_MODEL}
+ GL_NORMALIZE = $0BA1;
+ {$EXTERNALSYM GL_NORMALIZE}
+ GL_AMBIENT = $1200;
+ {$EXTERNALSYM GL_AMBIENT}
+ GL_DIFFUSE = $1201;
+ {$EXTERNALSYM GL_DIFFUSE}
+ GL_SPECULAR = $1202;
+ {$EXTERNALSYM GL_SPECULAR}
+ GL_POSITION = $1203;
+ {$EXTERNALSYM GL_POSITION}
+ GL_SPOT_DIRECTION = $1204;
+ {$EXTERNALSYM GL_SPOT_DIRECTION}
+ GL_SPOT_EXPONENT = $1205;
+ {$EXTERNALSYM GL_SPOT_EXPONENT}
+ GL_SPOT_CUTOFF = $1206;
+ {$EXTERNALSYM GL_SPOT_CUTOFF}
+ GL_CONSTANT_ATTENUATION = $1207;
+ {$EXTERNALSYM GL_CONSTANT_ATTENUATION}
+ GL_LINEAR_ATTENUATION = $1208;
+ {$EXTERNALSYM GL_LINEAR_ATTENUATION}
+ GL_QUADRATIC_ATTENUATION = $1209;
+ {$EXTERNALSYM GL_QUADRATIC_ATTENUATION}
+ GL_EMISSION = $1600;
+ {$EXTERNALSYM GL_EMISSION}
+ GL_SHININESS = $1601;
+ {$EXTERNALSYM GL_SHININESS}
+ GL_AMBIENT_AND_DIFFUSE = $1602;
+ {$EXTERNALSYM GL_AMBIENT_AND_DIFFUSE}
+ GL_COLOR_INDEXES = $1603;
+ {$EXTERNALSYM GL_COLOR_INDEXES}
+ GL_FLAT = $1D00;
+ {$EXTERNALSYM GL_FLAT}
+ GL_SMOOTH = $1D01;
+ {$EXTERNALSYM GL_SMOOTH}
+ GL_LIGHT0 = $4000;
+ {$EXTERNALSYM GL_LIGHT0}
+ GL_LIGHT1 = $4001;
+ {$EXTERNALSYM GL_LIGHT1}
+ GL_LIGHT2 = $4002;
+ {$EXTERNALSYM GL_LIGHT2}
+ GL_LIGHT3 = $4003;
+ {$EXTERNALSYM GL_LIGHT3}
+ GL_LIGHT4 = $4004;
+ {$EXTERNALSYM GL_LIGHT4}
+ GL_LIGHT5 = $4005;
+ {$EXTERNALSYM GL_LIGHT5}
+ GL_LIGHT6 = $4006;
+ {$EXTERNALSYM GL_LIGHT6}
+ GL_LIGHT7 = $4007;
+ {$EXTERNALSYM GL_LIGHT7}
+
+ // matrix modes
+ GL_MATRIX_MODE = $0BA0;
+ {$EXTERNALSYM GL_MATRIX_MODE}
+ GL_MODELVIEW = $1700;
+ {$EXTERNALSYM GL_MODELVIEW}
+ GL_PROJECTION = $1701;
+ {$EXTERNALSYM GL_PROJECTION}
+ GL_TEXTURE = $1702;
+ {$EXTERNALSYM GL_TEXTURE}
+
+ // gets
+ GL_CURRENT_COLOR = $0B00;
+ {$EXTERNALSYM GL_CURRENT_COLOR}
+ GL_CURRENT_INDEX = $0B01;
+ {$EXTERNALSYM GL_CURRENT_INDEX}
+ GL_CURRENT_NORMAL = $0B02;
+ {$EXTERNALSYM GL_CURRENT_NORMAL}
+ GL_CURRENT_TEXTURE_COORDS = $0B03;
+ {$EXTERNALSYM GL_CURRENT_TEXTURE_COORDS}
+ GL_CURRENT_RASTER_COLOR = $0B04;
+ {$EXTERNALSYM GL_CURRENT_RASTER_COLOR}
+ GL_CURRENT_RASTER_INDEX = $0B05;
+ {$EXTERNALSYM GL_CURRENT_RASTER_INDEX}
+ GL_CURRENT_RASTER_TEXTURE_COORDS = $0B06;
+ {$EXTERNALSYM GL_CURRENT_RASTER_TEXTURE_COORDS}
+ GL_CURRENT_RASTER_POSITION = $0B07;
+ {$EXTERNALSYM GL_CURRENT_RASTER_POSITION}
+ GL_CURRENT_RASTER_POSITION_VALID = $0B08;
+ {$EXTERNALSYM GL_CURRENT_RASTER_POSITION_VALID}
+ GL_CURRENT_RASTER_DISTANCE = $0B09;
+ {$EXTERNALSYM GL_CURRENT_RASTER_DISTANCE}
+ GL_MAX_LIST_NESTING = $0B31;
+ {$EXTERNALSYM GL_MAX_LIST_NESTING}
+ GL_VIEWPORT = $0BA2;
+ {$EXTERNALSYM GL_VIEWPORT}
+ GL_MODELVIEW_STACK_DEPTH = $0BA3;
+ {$EXTERNALSYM GL_MODELVIEW_STACK_DEPTH}
+ GL_PROJECTION_STACK_DEPTH = $0BA4;
+ {$EXTERNALSYM GL_PROJECTION_STACK_DEPTH}
+ GL_TEXTURE_STACK_DEPTH = $0BA5;
+ {$EXTERNALSYM GL_TEXTURE_STACK_DEPTH}
+ GL_MODELVIEW_MATRIX = $0BA6;
+ {$EXTERNALSYM GL_MODELVIEW_MATRIX}
+ GL_PROJECTION_MATRIX = $0BA7;
+ {$EXTERNALSYM GL_PROJECTION_MATRIX}
+ GL_TEXTURE_MATRIX = $0BA8;
+ {$EXTERNALSYM GL_TEXTURE_MATRIX}
+ GL_ATTRIB_STACK_DEPTH = $0BB0;
+ {$EXTERNALSYM GL_ATTRIB_STACK_DEPTH}
+ GL_CLIENT_ATTRIB_STACK_DEPTH = $0BB1;
+ {$EXTERNALSYM GL_CLIENT_ATTRIB_STACK_DEPTH}
+
+ GL_SINGLE_COLOR = $81F9; // GL 1.2
+ {$EXTERNALSYM GL_SINGLE_COLOR}
+ GL_SEPARATE_SPECULAR_COLOR = $81FA; // GL 1.2
+ {$EXTERNALSYM GL_SEPARATE_SPECULAR_COLOR}
+
+ // alpha testing
+ GL_ALPHA_TEST = $0BC0;
+ {$EXTERNALSYM GL_ALPHA_TEST}
+ GL_ALPHA_TEST_FUNC = $0BC1;
+ {$EXTERNALSYM GL_ALPHA_TEST_FUNC}
+ GL_ALPHA_TEST_REF = $0BC2;
+ {$EXTERNALSYM GL_ALPHA_TEST_REF}
+
+ GL_LOGIC_OP_MODE = $0BF0;
+ {$EXTERNALSYM GL_LOGIC_OP_MODE}
+ GL_INDEX_LOGIC_OP = $0BF1;
+ {$EXTERNALSYM GL_INDEX_LOGIC_OP}
+ GL_LOGIC_OP = $0BF1;
+ {$EXTERNALSYM GL_LOGIC_OP}
+ GL_COLOR_LOGIC_OP = $0BF2;
+ {$EXTERNALSYM GL_COLOR_LOGIC_OP}
+ GL_SCISSOR_BOX = $0C10;
+ {$EXTERNALSYM GL_SCISSOR_BOX}
+ GL_SCISSOR_TEST = $0C11;
+ {$EXTERNALSYM GL_SCISSOR_TEST}
+ GL_INDEX_CLEAR_VALUE = $0C20;
+ {$EXTERNALSYM GL_INDEX_CLEAR_VALUE}
+ GL_INDEX_WRITEMASK = $0C21;
+ {$EXTERNALSYM GL_INDEX_WRITEMASK}
+ GL_COLOR_CLEAR_VALUE = $0C22;
+ {$EXTERNALSYM GL_COLOR_CLEAR_VALUE}
+ GL_COLOR_WRITEMASK = $0C23;
+ {$EXTERNALSYM GL_COLOR_WRITEMASK}
+ GL_INDEX_MODE = $0C30;
+ {$EXTERNALSYM GL_INDEX_MODE}
+ GL_RGBA_MODE = $0C31;
+ {$EXTERNALSYM GL_RGBA_MODE}
+ GL_RENDER_MODE = $0C40;
+ {$EXTERNALSYM GL_RENDER_MODE}
+ GL_PERSPECTIVE_CORRECTION_HINT = $0C50;
+ {$EXTERNALSYM GL_PERSPECTIVE_CORRECTION_HINT}
+ GL_POINT_SMOOTH_HINT = $0C51;
+ {$EXTERNALSYM GL_POINT_SMOOTH_HINT}
+ GL_LINE_SMOOTH_HINT = $0C52;
+ {$EXTERNALSYM GL_LINE_SMOOTH_HINT}
+ GL_POLYGON_SMOOTH_HINT = $0C53;
+ {$EXTERNALSYM GL_POLYGON_SMOOTH_HINT}
+ GL_FOG_HINT = $0C54;
+ {$EXTERNALSYM GL_FOG_HINT}
+ GL_TEXTURE_GEN_S = $0C60;
+ {$EXTERNALSYM GL_TEXTURE_GEN_S}
+ GL_TEXTURE_GEN_T = $0C61;
+ {$EXTERNALSYM GL_TEXTURE_GEN_T}
+ GL_TEXTURE_GEN_R = $0C62;
+ {$EXTERNALSYM GL_TEXTURE_GEN_R}
+ GL_TEXTURE_GEN_Q = $0C63;
+ {$EXTERNALSYM GL_TEXTURE_GEN_Q}
+ GL_PIXEL_MAP_I_TO_I_SIZE = $0CB0;
+ {$EXTERNALSYM GL_PIXEL_MAP_I_TO_I_SIZE}
+ GL_PIXEL_MAP_S_TO_S_SIZE = $0CB1;
+ {$EXTERNALSYM GL_PIXEL_MAP_S_TO_S_SIZE}
+ GL_PIXEL_MAP_I_TO_R_SIZE = $0CB2;
+ {$EXTERNALSYM GL_PIXEL_MAP_I_TO_R_SIZE}
+ GL_PIXEL_MAP_I_TO_G_SIZE = $0CB3;
+ {$EXTERNALSYM GL_PIXEL_MAP_I_TO_G_SIZE}
+ GL_PIXEL_MAP_I_TO_B_SIZE = $0CB4;
+ {$EXTERNALSYM GL_PIXEL_MAP_I_TO_B_SIZE}
+ GL_PIXEL_MAP_I_TO_A_SIZE = $0CB5;
+ {$EXTERNALSYM GL_PIXEL_MAP_I_TO_A_SIZE}
+ GL_PIXEL_MAP_R_TO_R_SIZE = $0CB6;
+ {$EXTERNALSYM GL_PIXEL_MAP_R_TO_R_SIZE}
+ GL_PIXEL_MAP_G_TO_G_SIZE = $0CB7;
+ {$EXTERNALSYM GL_PIXEL_MAP_G_TO_G_SIZE}
+ GL_PIXEL_MAP_B_TO_B_SIZE = $0CB8;
+ {$EXTERNALSYM GL_PIXEL_MAP_B_TO_B_SIZE}
+ GL_PIXEL_MAP_A_TO_A_SIZE = $0CB9;
+ {$EXTERNALSYM GL_PIXEL_MAP_A_TO_A_SIZE}
+ GL_UNPACK_SWAP_BYTES = $0CF0;
+ {$EXTERNALSYM GL_UNPACK_SWAP_BYTES}
+ GL_UNPACK_LSB_FIRST = $0CF1;
+ {$EXTERNALSYM GL_UNPACK_LSB_FIRST}
+ GL_UNPACK_ROW_LENGTH = $0CF2;
+ {$EXTERNALSYM GL_UNPACK_ROW_LENGTH}
+ GL_UNPACK_SKIP_ROWS = $0CF3;
+ {$EXTERNALSYM GL_UNPACK_SKIP_ROWS}
+ GL_UNPACK_SKIP_PIXELS = $0CF4;
+ {$EXTERNALSYM GL_UNPACK_SKIP_PIXELS}
+ GL_UNPACK_ALIGNMENT = $0CF5;
+ {$EXTERNALSYM GL_UNPACK_ALIGNMENT}
+ GL_PACK_SWAP_BYTES = $0D00;
+ {$EXTERNALSYM GL_PACK_SWAP_BYTES}
+ GL_PACK_LSB_FIRST = $0D01;
+ {$EXTERNALSYM GL_PACK_LSB_FIRST}
+ GL_PACK_ROW_LENGTH = $0D02;
+ {$EXTERNALSYM GL_PACK_ROW_LENGTH}
+ GL_PACK_SKIP_ROWS = $0D03;
+ {$EXTERNALSYM GL_PACK_SKIP_ROWS}
+ GL_PACK_SKIP_PIXELS = $0D04;
+ {$EXTERNALSYM GL_PACK_SKIP_PIXELS}
+ GL_PACK_ALIGNMENT = $0D05;
+ {$EXTERNALSYM GL_PACK_ALIGNMENT}
+ GL_PACK_SKIP_IMAGES = $806B; // GL 1.2
+ {$EXTERNALSYM GL_PACK_SKIP_IMAGES}
+ GL_PACK_IMAGE_HEIGHT = $806C; // GL 1.2
+ {$EXTERNALSYM GL_PACK_IMAGE_HEIGHT}
+ GL_UNPACK_SKIP_IMAGES = $806D; // GL 1.2
+ {$EXTERNALSYM GL_UNPACK_SKIP_IMAGES}
+ GL_UNPACK_IMAGE_HEIGHT = $806E; // GL 1.2
+ {$EXTERNALSYM GL_UNPACK_IMAGE_HEIGHT}
+ GL_MAP_COLOR = $0D10;
+ {$EXTERNALSYM GL_MAP_COLOR}
+ GL_MAP_STENCIL = $0D11;
+ {$EXTERNALSYM GL_MAP_STENCIL}
+ GL_INDEX_SHIFT = $0D12;
+ {$EXTERNALSYM GL_INDEX_SHIFT}
+ GL_INDEX_OFFSET = $0D13;
+ {$EXTERNALSYM GL_INDEX_OFFSET}
+ GL_RED_SCALE = $0D14;
+ {$EXTERNALSYM GL_RED_SCALE}
+ GL_RED_BIAS = $0D15;
+ {$EXTERNALSYM GL_RED_BIAS}
+ GL_ZOOM_X = $0D16;
+ {$EXTERNALSYM GL_ZOOM_X}
+ GL_ZOOM_Y = $0D17;
+ {$EXTERNALSYM GL_ZOOM_Y}
+ GL_GREEN_SCALE = $0D18;
+ {$EXTERNALSYM GL_GREEN_SCALE}
+ GL_GREEN_BIAS = $0D19;
+ {$EXTERNALSYM GL_GREEN_BIAS}
+ GL_BLUE_SCALE = $0D1A;
+ {$EXTERNALSYM GL_BLUE_SCALE}
+ GL_BLUE_BIAS = $0D1B;
+ {$EXTERNALSYM GL_BLUE_BIAS}
+ GL_ALPHA_SCALE = $0D1C;
+ {$EXTERNALSYM GL_ALPHA_SCALE}
+ GL_ALPHA_BIAS = $0D1D;
+ {$EXTERNALSYM GL_ALPHA_BIAS}
+ GL_DEPTH_SCALE = $0D1E;
+ {$EXTERNALSYM GL_DEPTH_SCALE}
+ GL_DEPTH_BIAS = $0D1F;
+ {$EXTERNALSYM GL_DEPTH_BIAS}
+ GL_MAX_EVAL_ORDER = $0D30;
+ {$EXTERNALSYM GL_MAX_EVAL_ORDER}
+ GL_MAX_LIGHTS = $0D31;
+ {$EXTERNALSYM GL_MAX_LIGHTS}
+ GL_MAX_CLIP_PLANES = $0D32;
+ {$EXTERNALSYM GL_MAX_CLIP_PLANES}
+ GL_MAX_TEXTURE_SIZE = $0D33;
+ {$EXTERNALSYM GL_MAX_TEXTURE_SIZE}
+ GL_MAX_3D_TEXTURE_SIZE = $8073; // GL 1.2
+ {$EXTERNALSYM GL_MAX_3D_TEXTURE_SIZE}
+ GL_MAX_PIXEL_MAP_TABLE = $0D34;
+ {$EXTERNALSYM GL_MAX_PIXEL_MAP_TABLE}
+ GL_MAX_ATTRIB_STACK_DEPTH = $0D35;
+ {$EXTERNALSYM GL_MAX_ATTRIB_STACK_DEPTH}
+ GL_MAX_MODELVIEW_STACK_DEPTH = $0D36;
+ {$EXTERNALSYM GL_MAX_MODELVIEW_STACK_DEPTH}
+ GL_MAX_NAME_STACK_DEPTH = $0D37;
+ {$EXTERNALSYM GL_MAX_NAME_STACK_DEPTH}
+ GL_MAX_PROJECTION_STACK_DEPTH = $0D38;
+ {$EXTERNALSYM GL_MAX_PROJECTION_STACK_DEPTH}
+ GL_MAX_TEXTURE_STACK_DEPTH = $0D39;
+ {$EXTERNALSYM GL_MAX_TEXTURE_STACK_DEPTH}
+ GL_MAX_VIEWPORT_DIMS = $0D3A;
+ {$EXTERNALSYM GL_MAX_VIEWPORT_DIMS}
+ GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = $0D3B;
+ {$EXTERNALSYM GL_MAX_CLIENT_ATTRIB_STACK_DEPTH}
+ GL_MAX_ELEMENTS_VERTICES = $80E8; // GL 1.2
+ {$EXTERNALSYM GL_MAX_ELEMENTS_VERTICES}
+ GL_MAX_ELEMENTS_INDICES = $80E9; // GL 1.2
+ {$EXTERNALSYM GL_MAX_ELEMENTS_INDICES}
+ GL_RESCALE_NORMAL = $803A; // GL 1.2
+ {$EXTERNALSYM GL_RESCALE_NORMAL}
+ GL_SUBPIXEL_BITS = $0D50;
+ {$EXTERNALSYM GL_SUBPIXEL_BITS}
+ GL_INDEX_BITS = $0D51;
+ {$EXTERNALSYM GL_INDEX_BITS}
+ GL_RED_BITS = $0D52;
+ {$EXTERNALSYM GL_RED_BITS}
+ GL_GREEN_BITS = $0D53;
+ {$EXTERNALSYM GL_GREEN_BITS}
+ GL_BLUE_BITS = $0D54;
+ {$EXTERNALSYM GL_BLUE_BITS}
+ GL_ALPHA_BITS = $0D55;
+ {$EXTERNALSYM GL_ALPHA_BITS}
+ GL_DEPTH_BITS = $0D56;
+ {$EXTERNALSYM GL_DEPTH_BITS}
+ GL_STENCIL_BITS = $0D57;
+ {$EXTERNALSYM GL_STENCIL_BITS}
+ GL_ACCUM_RED_BITS = $0D58;
+ {$EXTERNALSYM GL_ACCUM_RED_BITS}
+ GL_ACCUM_GREEN_BITS = $0D59;
+ {$EXTERNALSYM GL_ACCUM_GREEN_BITS}
+ GL_ACCUM_BLUE_BITS = $0D5A;
+ {$EXTERNALSYM GL_ACCUM_BLUE_BITS}
+ GL_ACCUM_ALPHA_BITS = $0D5B;
+ {$EXTERNALSYM GL_ACCUM_ALPHA_BITS}
+ GL_NAME_STACK_DEPTH = $0D70;
+ {$EXTERNALSYM GL_NAME_STACK_DEPTH}
+ GL_AUTO_NORMAL = $0D80;
+ {$EXTERNALSYM GL_AUTO_NORMAL}
+ GL_MAP1_COLOR_4 = $0D90;
+ {$EXTERNALSYM GL_MAP1_COLOR_4}
+ GL_MAP1_INDEX = $0D91;
+ {$EXTERNALSYM GL_MAP1_INDEX}
+ GL_MAP1_NORMAL = $0D92;
+ {$EXTERNALSYM GL_MAP1_NORMAL}
+ GL_MAP1_TEXTURE_COORD_1 = $0D93;
+ {$EXTERNALSYM GL_MAP1_TEXTURE_COORD_1}
+ GL_MAP1_TEXTURE_COORD_2 = $0D94;
+ {$EXTERNALSYM GL_MAP1_TEXTURE_COORD_2}
+ GL_MAP1_TEXTURE_COORD_3 = $0D95;
+ {$EXTERNALSYM GL_MAP1_TEXTURE_COORD_3}
+ GL_MAP1_TEXTURE_COORD_4 = $0D96;
+ {$EXTERNALSYM GL_MAP1_TEXTURE_COORD_4}
+ GL_MAP1_VERTEX_3 = $0D97;
+ {$EXTERNALSYM GL_MAP1_VERTEX_3}
+ GL_MAP1_VERTEX_4 = $0D98;
+ {$EXTERNALSYM GL_MAP1_VERTEX_4}
+ GL_MAP2_COLOR_4 = $0DB0;
+ {$EXTERNALSYM GL_MAP2_COLOR_4}
+ GL_MAP2_INDEX = $0DB1;
+ {$EXTERNALSYM GL_MAP2_INDEX}
+ GL_MAP2_NORMAL = $0DB2;
+ {$EXTERNALSYM GL_MAP2_NORMAL}
+ GL_MAP2_TEXTURE_COORD_1 = $0DB3;
+ {$EXTERNALSYM GL_MAP2_TEXTURE_COORD_1}
+ GL_MAP2_TEXTURE_COORD_2 = $0DB4;
+ {$EXTERNALSYM GL_MAP2_TEXTURE_COORD_2}
+ GL_MAP2_TEXTURE_COORD_3 = $0DB5;
+ {$EXTERNALSYM GL_MAP2_TEXTURE_COORD_3}
+ GL_MAP2_TEXTURE_COORD_4 = $0DB6;
+ {$EXTERNALSYM GL_MAP2_TEXTURE_COORD_4}
+ GL_MAP2_VERTEX_3 = $0DB7;
+ {$EXTERNALSYM GL_MAP2_VERTEX_3}
+ GL_MAP2_VERTEX_4 = $0DB8;
+ {$EXTERNALSYM GL_MAP2_VERTEX_4}
+ GL_MAP1_GRID_DOMAIN = $0DD0;
+ {$EXTERNALSYM GL_MAP1_GRID_DOMAIN}
+ GL_MAP1_GRID_SEGMENTS = $0DD1;
+ {$EXTERNALSYM GL_MAP1_GRID_SEGMENTS}
+ GL_MAP2_GRID_DOMAIN = $0DD2;
+ {$EXTERNALSYM GL_MAP2_GRID_DOMAIN}
+ GL_MAP2_GRID_SEGMENTS = $0DD3;
+ {$EXTERNALSYM GL_MAP2_GRID_SEGMENTS}
+ GL_TEXTURE_1D = $0DE0;
+ {$EXTERNALSYM GL_TEXTURE_1D}
+ GL_TEXTURE_2D = $0DE1;
+ {$EXTERNALSYM GL_TEXTURE_2D}
+ GL_TEXTURE_3D = $806F; // GL 1.2
+ {$EXTERNALSYM GL_TEXTURE_3D}
+ GL_SELECTION_BUFFER_POINTER = $0DF3;
+ {$EXTERNALSYM GL_SELECTION_BUFFER_POINTER}
+ GL_SELECTION_BUFFER_SIZE = $0DF4;
+ {$EXTERNALSYM GL_SELECTION_BUFFER_SIZE}
+ GL_POLYGON_OFFSET_UNITS = $2A00;
+ {$EXTERNALSYM GL_POLYGON_OFFSET_UNITS}
+ GL_POLYGON_OFFSET_POINT = $2A01;
+ {$EXTERNALSYM GL_POLYGON_OFFSET_POINT}
+ GL_POLYGON_OFFSET_LINE = $2A02;
+ {$EXTERNALSYM GL_POLYGON_OFFSET_LINE}
+ GL_POLYGON_OFFSET_FILL = $8037;
+ {$EXTERNALSYM GL_POLYGON_OFFSET_FILL}
+ GL_POLYGON_OFFSET_FACTOR = $8038;
+ {$EXTERNALSYM GL_POLYGON_OFFSET_FACTOR}
+ GL_TEXTURE_BINDING_1D = $8068;
+ {$EXTERNALSYM GL_TEXTURE_BINDING_1D}
+ GL_TEXTURE_BINDING_2D = $8069;
+ {$EXTERNALSYM GL_TEXTURE_BINDING_2D}
+ GL_VERTEX_ARRAY = $8074;
+ {$EXTERNALSYM GL_VERTEX_ARRAY}
+ GL_NORMAL_ARRAY = $8075;
+ {$EXTERNALSYM GL_NORMAL_ARRAY}
+ GL_COLOR_ARRAY = $8076;
+ {$EXTERNALSYM GL_COLOR_ARRAY}
+ GL_INDEX_ARRAY = $8077;
+ {$EXTERNALSYM GL_INDEX_ARRAY}
+ GL_TEXTURE_COORD_ARRAY = $8078;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY}
+ GL_EDGE_FLAG_ARRAY = $8079;
+ {$EXTERNALSYM GL_EDGE_FLAG_ARRAY}
+ GL_VERTEX_ARRAY_SIZE = $807A;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_SIZE}
+ GL_VERTEX_ARRAY_TYPE = $807B;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_TYPE}
+ GL_VERTEX_ARRAY_STRIDE = $807C;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_STRIDE}
+ GL_NORMAL_ARRAY_TYPE = $807E;
+ {$EXTERNALSYM GL_NORMAL_ARRAY_TYPE}
+ GL_NORMAL_ARRAY_STRIDE = $807F;
+ {$EXTERNALSYM GL_NORMAL_ARRAY_STRIDE}
+ GL_COLOR_ARRAY_SIZE = $8081;
+ {$EXTERNALSYM GL_COLOR_ARRAY_SIZE}
+ GL_COLOR_ARRAY_TYPE = $8082;
+ {$EXTERNALSYM GL_COLOR_ARRAY_TYPE}
+ GL_COLOR_ARRAY_STRIDE = $8083;
+ {$EXTERNALSYM GL_COLOR_ARRAY_STRIDE}
+ GL_INDEX_ARRAY_TYPE = $8085;
+ {$EXTERNALSYM GL_INDEX_ARRAY_TYPE}
+ GL_INDEX_ARRAY_STRIDE = $8086;
+ {$EXTERNALSYM GL_INDEX_ARRAY_STRIDE}
+ GL_TEXTURE_COORD_ARRAY_SIZE = $8088;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_SIZE}
+ GL_TEXTURE_COORD_ARRAY_TYPE = $8089;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_TYPE}
+ GL_TEXTURE_COORD_ARRAY_STRIDE = $808A;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_STRIDE}
+ GL_EDGE_FLAG_ARRAY_STRIDE = $808C;
+ {$EXTERNALSYM GL_EDGE_FLAG_ARRAY_STRIDE}
+ GL_COLOR_MATRIX = $80B1; // GL 1.2 ARB imaging
+ {$EXTERNALSYM GL_COLOR_MATRIX}
+ GL_COLOR_MATRIX_STACK_DEPTH = $80B2; // GL 1.2 ARB imaging
+ {$EXTERNALSYM GL_COLOR_MATRIX_STACK_DEPTH}
+ GL_MAX_COLOR_MATRIX_STACK_DEPTH = $80B3; // GL 1.2 ARB imaging
+ {$EXTERNALSYM GL_MAX_COLOR_MATRIX_STACK_DEPTH}
+ GL_POST_COLOR_MATRIX_RED_SCALE = $80B4; // GL 1.2 ARB imaging
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_RED_SCALE}
+ GL_POST_COLOR_MATRIX_GREEN_SCALE = $80B5; // GL 1.2 ARB imaging
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_GREEN_SCALE}
+ GL_POST_COLOR_MATRIX_BLUE_SCALE = $80B6; // GL 1.2 ARB imaging
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_BLUE_SCALE}
+ GL_POST_COLOR_MATRIX_ALPHA_SCALE = $80B7; // GL 1.2 ARB imaging
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_ALPHA_SCALE}
+ GL_POST_COLOR_MATRIX_RED_BIAS = $80B8; // GL 1.2 ARB imaging
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_RED_BIAS}
+ GL_POST_COLOR_MATRIX_GREEN_BIAS = $80B9; // GL 1.2 ARB imaging
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_GREEN_BIAS}
+ GL_POST_COLOR_MATRIX_BLUE_BIAS = $80BA; // GL 1.2 ARB imaging
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_BLUE_BIAS}
+ GL_POST_COLOR_MATRIX_ALPHA_BIAS = $80BB; // GL 1.2 ARB imaging
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_ALPHA_BIAS}
+
+ // evaluators
+ GL_COEFF = $0A00;
+ {$EXTERNALSYM GL_COEFF}
+ GL_ORDER = $0A01;
+ {$EXTERNALSYM GL_ORDER}
+ GL_DOMAIN = $0A02;
+ {$EXTERNALSYM GL_DOMAIN}
+
+ // texture mapping
+ GL_TEXTURE_WIDTH = $1000;
+ {$EXTERNALSYM GL_TEXTURE_WIDTH}
+ GL_TEXTURE_HEIGHT = $1001;
+ {$EXTERNALSYM GL_TEXTURE_HEIGHT}
+ GL_TEXTURE_INTERNAL_FORMAT = $1003;
+ {$EXTERNALSYM GL_TEXTURE_INTERNAL_FORMAT}
+ GL_TEXTURE_COMPONENTS = $1003;
+ {$EXTERNALSYM GL_TEXTURE_COMPONENTS}
+ GL_TEXTURE_BORDER_COLOR = $1004;
+ {$EXTERNALSYM GL_TEXTURE_BORDER_COLOR}
+ GL_TEXTURE_BORDER = $1005;
+ {$EXTERNALSYM GL_TEXTURE_BORDER}
+ GL_TEXTURE_RED_SIZE = $805C;
+ {$EXTERNALSYM GL_TEXTURE_RED_SIZE}
+ GL_TEXTURE_GREEN_SIZE = $805D;
+ {$EXTERNALSYM GL_TEXTURE_GREEN_SIZE}
+ GL_TEXTURE_BLUE_SIZE = $805E;
+ {$EXTERNALSYM GL_TEXTURE_BLUE_SIZE}
+ GL_TEXTURE_ALPHA_SIZE = $805F;
+ {$EXTERNALSYM GL_TEXTURE_ALPHA_SIZE}
+ GL_TEXTURE_LUMINANCE_SIZE = $8060;
+ {$EXTERNALSYM GL_TEXTURE_LUMINANCE_SIZE}
+ GL_TEXTURE_INTENSITY_SIZE = $8061;
+ {$EXTERNALSYM GL_TEXTURE_INTENSITY_SIZE}
+ GL_TEXTURE_PRIORITY = $8066;
+ {$EXTERNALSYM GL_TEXTURE_PRIORITY}
+ GL_TEXTURE_RESIDENT = $8067;
+ {$EXTERNALSYM GL_TEXTURE_RESIDENT}
+ GL_BGR = $80E0; // v 1.2
+ {$EXTERNALSYM GL_BGR}
+ GL_BGRA = $80E1; // v 1.2
+ {$EXTERNALSYM GL_BGRA}
+ GL_S = $2000;
+ {$EXTERNALSYM GL_S}
+ GL_T = $2001;
+ {$EXTERNALSYM GL_T}
+ GL_R = $2002;
+ {$EXTERNALSYM GL_R}
+ GL_Q = $2003;
+ {$EXTERNALSYM GL_Q}
+ GL_MODULATE = $2100;
+ {$EXTERNALSYM GL_MODULATE}
+ GL_DECAL = $2101;
+ {$EXTERNALSYM GL_DECAL}
+ GL_TEXTURE_ENV_MODE = $2200;
+ {$EXTERNALSYM GL_TEXTURE_ENV_MODE}
+ GL_TEXTURE_ENV_COLOR = $2201;
+ {$EXTERNALSYM GL_TEXTURE_ENV_COLOR}
+ GL_TEXTURE_ENV = $2300;
+ {$EXTERNALSYM GL_TEXTURE_ENV}
+ GL_EYE_LINEAR = $2400;
+ {$EXTERNALSYM GL_EYE_LINEAR}
+ GL_OBJECT_LINEAR = $2401;
+ {$EXTERNALSYM GL_OBJECT_LINEAR}
+ GL_SPHERE_MAP = $2402;
+ {$EXTERNALSYM GL_SPHERE_MAP}
+ GL_TEXTURE_GEN_MODE = $2500;
+ {$EXTERNALSYM GL_TEXTURE_GEN_MODE}
+ GL_OBJECT_PLANE = $2501;
+ {$EXTERNALSYM GL_OBJECT_PLANE}
+ GL_EYE_PLANE = $2502;
+ {$EXTERNALSYM GL_EYE_PLANE}
+ GL_NEAREST = $2600;
+ {$EXTERNALSYM GL_NEAREST}
+ GL_LINEAR = $2601;
+ {$EXTERNALSYM GL_LINEAR}
+ GL_NEAREST_MIPMAP_NEAREST = $2700;
+ {$EXTERNALSYM GL_NEAREST_MIPMAP_NEAREST}
+ GL_LINEAR_MIPMAP_NEAREST = $2701;
+ {$EXTERNALSYM GL_LINEAR_MIPMAP_NEAREST}
+ GL_NEAREST_MIPMAP_LINEAR = $2702;
+ {$EXTERNALSYM GL_NEAREST_MIPMAP_LINEAR}
+ GL_LINEAR_MIPMAP_LINEAR = $2703;
+ {$EXTERNALSYM GL_LINEAR_MIPMAP_LINEAR}
+ GL_TEXTURE_MAG_FILTER = $2800;
+ {$EXTERNALSYM GL_TEXTURE_MAG_FILTER}
+ GL_TEXTURE_MIN_FILTER = $2801;
+ {$EXTERNALSYM GL_TEXTURE_MIN_FILTER}
+ GL_TEXTURE_WRAP_R = $8072; // GL 1.2
+ {$EXTERNALSYM GL_TEXTURE_WRAP_R}
+ GL_TEXTURE_WRAP_S = $2802;
+ {$EXTERNALSYM GL_TEXTURE_WRAP_S}
+ GL_TEXTURE_WRAP_T = $2803;
+ {$EXTERNALSYM GL_TEXTURE_WRAP_T}
+ GL_CLAMP_TO_EDGE = $812F; // GL 1.2
+ {$EXTERNALSYM GL_CLAMP_TO_EDGE}
+ GL_TEXTURE_MIN_LOD = $813A; // GL 1.2
+ {$EXTERNALSYM GL_TEXTURE_MIN_LOD}
+ GL_TEXTURE_MAX_LOD = $813B; // GL 1.2
+ {$EXTERNALSYM GL_TEXTURE_MAX_LOD}
+ GL_TEXTURE_BASE_LEVEL = $813C; // GL 1.2
+ {$EXTERNALSYM GL_TEXTURE_BASE_LEVEL}
+ GL_TEXTURE_MAX_LEVEL = $813D; // GL 1.2
+ {$EXTERNALSYM GL_TEXTURE_MAX_LEVEL}
+ GL_TEXTURE_DEPTH = $8071; // GL 1.2
+ {$EXTERNALSYM GL_TEXTURE_DEPTH}
+ GL_PROXY_TEXTURE_1D = $8063;
+ {$EXTERNALSYM GL_PROXY_TEXTURE_1D}
+ GL_PROXY_TEXTURE_2D = $8064;
+ {$EXTERNALSYM GL_PROXY_TEXTURE_2D}
+ GL_PROXY_TEXTURE_3D = $8070; // GL 1.2
+ {$EXTERNALSYM GL_PROXY_TEXTURE_3D}
+ GL_CLAMP = $2900;
+ {$EXTERNALSYM GL_CLAMP}
+ GL_REPEAT = $2901;
+ {$EXTERNALSYM GL_REPEAT}
+
+ // hints
+ GL_DONT_CARE = $1100;
+ {$EXTERNALSYM GL_DONT_CARE}
+ GL_FASTEST = $1101;
+ {$EXTERNALSYM GL_FASTEST}
+ GL_NICEST = $1102;
+ {$EXTERNALSYM GL_NICEST}
+
+ // data types
+ GL_BYTE = $1400;
+ {$EXTERNALSYM GL_BYTE}
+ GL_UNSIGNED_BYTE = $1401;
+ {$EXTERNALSYM GL_UNSIGNED_BYTE}
+ GL_SHORT = $1402;
+ {$EXTERNALSYM GL_SHORT}
+ GL_UNSIGNED_SHORT = $1403;
+ {$EXTERNALSYM GL_UNSIGNED_SHORT}
+ GL_INT = $1404;
+ {$EXTERNALSYM GL_INT}
+ GL_UNSIGNED_INT = $1405;
+ {$EXTERNALSYM GL_UNSIGNED_INT}
+ GL_FLOAT = $1406;
+ {$EXTERNALSYM GL_FLOAT}
+ GL_2_BYTES = $1407;
+ {$EXTERNALSYM GL_2_BYTES}
+ GL_3_BYTES = $1408;
+ {$EXTERNALSYM GL_3_BYTES}
+ GL_4_BYTES = $1409;
+ {$EXTERNALSYM GL_4_BYTES}
+ GL_DOUBLE = $140A;
+ {$EXTERNALSYM GL_DOUBLE}
+ GL_DOUBLE_EXT = $140A;
+ {$EXTERNALSYM GL_DOUBLE_EXT}
+
+ // logic operations
+ GL_CLEAR = $1500;
+ {$EXTERNALSYM GL_CLEAR}
+ GL_AND = $1501;
+ {$EXTERNALSYM GL_AND}
+ GL_AND_REVERSE = $1502;
+ {$EXTERNALSYM GL_AND_REVERSE}
+ GL_COPY = $1503;
+ {$EXTERNALSYM GL_COPY}
+ GL_AND_INVERTED = $1504;
+ {$EXTERNALSYM GL_AND_INVERTED}
+ GL_NOOP = $1505;
+ {$EXTERNALSYM GL_NOOP}
+ GL_XOR = $1506;
+ {$EXTERNALSYM GL_XOR}
+ GL_OR = $1507;
+ {$EXTERNALSYM GL_OR}
+ GL_NOR = $1508;
+ {$EXTERNALSYM GL_NOR}
+ GL_EQUIV = $1509;
+ {$EXTERNALSYM GL_EQUIV}
+ GL_INVERT = $150A;
+ {$EXTERNALSYM GL_INVERT}
+ GL_OR_REVERSE = $150B;
+ {$EXTERNALSYM GL_OR_REVERSE}
+ GL_COPY_INVERTED = $150C;
+ {$EXTERNALSYM GL_COPY_INVERTED}
+ GL_OR_INVERTED = $150D;
+ {$EXTERNALSYM GL_OR_INVERTED}
+ GL_NAND = $150E;
+ {$EXTERNALSYM GL_NAND}
+ GL_SET = $150F;
+ {$EXTERNALSYM GL_SET}
+
+ // PixelCopyType
+ GL_COLOR = $1800;
+ {$EXTERNALSYM GL_COLOR}
+ GL_DEPTH = $1801;
+ {$EXTERNALSYM GL_DEPTH}
+ GL_STENCIL = $1802;
+ {$EXTERNALSYM GL_STENCIL}
+
+ // pixel formats
+ GL_COLOR_INDEX = $1900;
+ {$EXTERNALSYM GL_COLOR_INDEX}
+ GL_STENCIL_INDEX = $1901;
+ {$EXTERNALSYM GL_STENCIL_INDEX}
+ GL_DEPTH_COMPONENT = $1902;
+ {$EXTERNALSYM GL_DEPTH_COMPONENT}
+ GL_RED = $1903;
+ {$EXTERNALSYM GL_RED}
+ GL_GREEN = $1904;
+ {$EXTERNALSYM GL_GREEN}
+ GL_BLUE = $1905;
+ {$EXTERNALSYM GL_BLUE}
+ GL_ALPHA = $1906;
+ {$EXTERNALSYM GL_ALPHA}
+ GL_RGB = $1907;
+ {$EXTERNALSYM GL_RGB}
+ GL_RGBA = $1908;
+ {$EXTERNALSYM GL_RGBA}
+ GL_LUMINANCE = $1909;
+ {$EXTERNALSYM GL_LUMINANCE}
+ GL_LUMINANCE_ALPHA = $190A;
+ {$EXTERNALSYM GL_LUMINANCE_ALPHA}
+
+ // pixel type
+ GL_BITMAP = $1A00;
+ {$EXTERNALSYM GL_BITMAP}
+
+ // rendering modes
+ GL_RENDER = $1C00;
+ {$EXTERNALSYM GL_RENDER}
+ GL_FEEDBACK = $1C01;
+ {$EXTERNALSYM GL_FEEDBACK}
+ GL_SELECT = $1C02;
+ {$EXTERNALSYM GL_SELECT}
+
+ // implementation strings
+ GL_VENDOR = $1F00;
+ {$EXTERNALSYM GL_VENDOR}
+ GL_RENDERER = $1F01;
+ {$EXTERNALSYM GL_RENDERER}
+ GL_VERSION = $1F02;
+ {$EXTERNALSYM GL_VERSION}
+ GL_EXTENSIONS = $1F03;
+ {$EXTERNALSYM GL_EXTENSIONS}
+
+ // pixel formats
+ GL_R3_G3_B2 = $2A10;
+ {$EXTERNALSYM GL_R3_G3_B2}
+ GL_ALPHA4 = $803B;
+ {$EXTERNALSYM GL_ALPHA4}
+ GL_ALPHA8 = $803C;
+ {$EXTERNALSYM GL_ALPHA8}
+ GL_ALPHA12 = $803D;
+ {$EXTERNALSYM GL_ALPHA12}
+ GL_ALPHA16 = $803E;
+ {$EXTERNALSYM GL_ALPHA16}
+ GL_LUMINANCE4 = $803F;
+ {$EXTERNALSYM GL_LUMINANCE4}
+ GL_LUMINANCE8 = $8040;
+ {$EXTERNALSYM GL_LUMINANCE8}
+ GL_LUMINANCE12 = $8041;
+ {$EXTERNALSYM GL_LUMINANCE12}
+ GL_LUMINANCE16 = $8042;
+ {$EXTERNALSYM GL_LUMINANCE16}
+ GL_LUMINANCE4_ALPHA4 = $8043;
+ {$EXTERNALSYM GL_LUMINANCE4_ALPHA4}
+ GL_LUMINANCE6_ALPHA2 = $8044;
+ {$EXTERNALSYM GL_LUMINANCE6_ALPHA2}
+ GL_LUMINANCE8_ALPHA8 = $8045;
+ {$EXTERNALSYM GL_LUMINANCE8_ALPHA8}
+ GL_LUMINANCE12_ALPHA4 = $8046;
+ {$EXTERNALSYM GL_LUMINANCE12_ALPHA4}
+ GL_LUMINANCE12_ALPHA12 = $8047;
+ {$EXTERNALSYM GL_LUMINANCE12_ALPHA12}
+ GL_LUMINANCE16_ALPHA16 = $8048;
+ {$EXTERNALSYM GL_LUMINANCE16_ALPHA16}
+ GL_INTENSITY = $8049;
+ {$EXTERNALSYM GL_INTENSITY}
+ GL_INTENSITY4 = $804A;
+ {$EXTERNALSYM GL_INTENSITY4}
+ GL_INTENSITY8 = $804B;
+ {$EXTERNALSYM GL_INTENSITY8}
+ GL_INTENSITY12 = $804C;
+ {$EXTERNALSYM GL_INTENSITY12}
+ GL_INTENSITY16 = $804D;
+ {$EXTERNALSYM GL_INTENSITY16}
+ GL_RGB4 = $804F;
+ {$EXTERNALSYM GL_RGB4}
+ GL_RGB5 = $8050;
+ {$EXTERNALSYM GL_RGB5}
+ GL_RGB8 = $8051;
+ {$EXTERNALSYM GL_RGB8}
+ GL_RGB10 = $8052;
+ {$EXTERNALSYM GL_RGB10}
+ GL_RGB12 = $8053;
+ {$EXTERNALSYM GL_RGB12}
+ GL_RGB16 = $8054;
+ {$EXTERNALSYM GL_RGB16}
+ GL_RGBA2 = $8055;
+ {$EXTERNALSYM GL_RGBA2}
+ GL_RGBA4 = $8056;
+ {$EXTERNALSYM GL_RGBA4}
+ GL_RGB5_A1 = $8057;
+ {$EXTERNALSYM GL_RGB5_A1}
+ GL_RGBA8 = $8058;
+ {$EXTERNALSYM GL_RGBA8}
+ GL_RGB10_A2 = $8059;
+ {$EXTERNALSYM GL_RGB10_A2}
+ GL_RGBA12 = $805A;
+ {$EXTERNALSYM GL_RGBA12}
+ GL_RGBA16 = $805B;
+ {$EXTERNALSYM GL_RGBA16}
+ UNSIGNED_BYTE_3_3_2 = $8032; // GL 1.2
+ {$EXTERNALSYM UNSIGNED_BYTE_3_3_2}
+ UNSIGNED_BYTE_2_3_3_REV = $8362; // GL 1.2
+ {$EXTERNALSYM UNSIGNED_BYTE_2_3_3_REV}
+ UNSIGNED_SHORT_5_6_5 = $8363; // GL 1.2
+ {$EXTERNALSYM UNSIGNED_SHORT_5_6_5}
+ UNSIGNED_SHORT_5_6_5_REV = $8364; // GL 1.2
+ {$EXTERNALSYM UNSIGNED_SHORT_5_6_5_REV}
+ UNSIGNED_SHORT_4_4_4_4 = $8033; // GL 1.2
+ {$EXTERNALSYM UNSIGNED_SHORT_4_4_4_4}
+ UNSIGNED_SHORT_4_4_4_4_REV = $8365; // GL 1.2
+ {$EXTERNALSYM UNSIGNED_SHORT_4_4_4_4_REV}
+ UNSIGNED_SHORT_5_5_5_1 = $8034; // GL 1.2
+ {$EXTERNALSYM UNSIGNED_SHORT_5_5_5_1}
+ UNSIGNED_SHORT_1_5_5_5_REV = $8366; // GL 1.2
+ {$EXTERNALSYM UNSIGNED_SHORT_1_5_5_5_REV}
+ UNSIGNED_INT_8_8_8_8 = $8035; // GL 1.2
+ {$EXTERNALSYM UNSIGNED_INT_8_8_8_8}
+ UNSIGNED_INT_8_8_8_8_REV = $8367; // GL 1.2
+ {$EXTERNALSYM UNSIGNED_INT_8_8_8_8_REV}
+ UNSIGNED_INT_10_10_10_2 = $8036; // GL 1.2
+ {$EXTERNALSYM UNSIGNED_INT_10_10_10_2}
+ UNSIGNED_INT_2_10_10_10_REV = $8368; // GL 1.2
+ {$EXTERNALSYM UNSIGNED_INT_2_10_10_10_REV}
+
+ // interleaved arrays formats
+ GL_V2F = $2A20;
+ {$EXTERNALSYM GL_V2F}
+ GL_V3F = $2A21;
+ {$EXTERNALSYM GL_V3F}
+ GL_C4UB_V2F = $2A22;
+ {$EXTERNALSYM GL_C4UB_V2F}
+ GL_C4UB_V3F = $2A23;
+ {$EXTERNALSYM GL_C4UB_V3F}
+ GL_C3F_V3F = $2A24;
+ {$EXTERNALSYM GL_C3F_V3F}
+ GL_N3F_V3F = $2A25;
+ {$EXTERNALSYM GL_N3F_V3F}
+ GL_C4F_N3F_V3F = $2A26;
+ {$EXTERNALSYM GL_C4F_N3F_V3F}
+ GL_T2F_V3F = $2A27;
+ {$EXTERNALSYM GL_T2F_V3F}
+ GL_T4F_V4F = $2A28;
+ {$EXTERNALSYM GL_T4F_V4F}
+ GL_T2F_C4UB_V3F = $2A29;
+ {$EXTERNALSYM GL_T2F_C4UB_V3F}
+ GL_T2F_C3F_V3F = $2A2A;
+ {$EXTERNALSYM GL_T2F_C3F_V3F}
+ GL_T2F_N3F_V3F = $2A2B;
+ {$EXTERNALSYM GL_T2F_N3F_V3F}
+ GL_T2F_C4F_N3F_V3F = $2A2C;
+ {$EXTERNALSYM GL_T2F_C4F_N3F_V3F}
+ GL_T4F_C4F_N3F_V4F = $2A2D;
+ {$EXTERNALSYM GL_T4F_C4F_N3F_V4F}
+
+ // clip planes
+ GL_CLIP_PLANE0 = $3000;
+ {$EXTERNALSYM GL_CLIP_PLANE0}
+ GL_CLIP_PLANE1 = $3001;
+ {$EXTERNALSYM GL_CLIP_PLANE1}
+ GL_CLIP_PLANE2 = $3002;
+ {$EXTERNALSYM GL_CLIP_PLANE2}
+ GL_CLIP_PLANE3 = $3003;
+ {$EXTERNALSYM GL_CLIP_PLANE3}
+ GL_CLIP_PLANE4 = $3004;
+ {$EXTERNALSYM GL_CLIP_PLANE4}
+ GL_CLIP_PLANE5 = $3005;
+ {$EXTERNALSYM GL_CLIP_PLANE5}
+
+ // miscellaneous
+ GL_DITHER = $0BD0;
+ {$EXTERNALSYM GL_DITHER}
+
+ // ----- extensions enumerants -----
+ // EXT_abgr
+ GL_ABGR_EXT = $8000;
+ {$EXTERNALSYM GL_ABGR_EXT}
+
+ // EXT_packed_pixels
+ GL_UNSIGNED_BYTE_3_3_2_EXT = $8032;
+ {$EXTERNALSYM GL_UNSIGNED_BYTE_3_3_2_EXT}
+ GL_UNSIGNED_SHORT_4_4_4_4_EXT = $8033;
+ {$EXTERNALSYM GL_UNSIGNED_SHORT_4_4_4_4_EXT}
+ GL_UNSIGNED_SHORT_5_5_5_1_EXT = $8034;
+ {$EXTERNALSYM GL_UNSIGNED_SHORT_5_5_5_1_EXT}
+ GL_UNSIGNED_INT_8_8_8_8_EXT = $8035;
+ {$EXTERNALSYM GL_UNSIGNED_INT_8_8_8_8_EXT}
+ GL_UNSIGNED_INT_10_10_10_2_EXT = $8036;
+ {$EXTERNALSYM GL_UNSIGNED_INT_10_10_10_2_EXT}
+
+ // EXT_vertex_array
+ GL_VERTEX_ARRAY_EXT = $8074;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_EXT}
+ GL_NORMAL_ARRAY_EXT = $8075;
+ {$EXTERNALSYM GL_NORMAL_ARRAY_EXT}
+ GL_COLOR_ARRAY_EXT = $8076;
+ {$EXTERNALSYM GL_COLOR_ARRAY_EXT}
+ GL_INDEX_ARRAY_EXT = $8077;
+ {$EXTERNALSYM GL_INDEX_ARRAY_EXT}
+ GL_TEXTURE_COORD_ARRAY_EXT = $8078;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_EXT}
+ GL_EDGE_FLAG_ARRAY_EXT = $8079;
+ {$EXTERNALSYM GL_EDGE_FLAG_ARRAY_EXT}
+ GL_VERTEX_ARRAY_SIZE_EXT = $807A;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_SIZE_EXT}
+ GL_VERTEX_ARRAY_TYPE_EXT = $807B;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_TYPE_EXT}
+ GL_VERTEX_ARRAY_STRIDE_EXT = $807C;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_STRIDE_EXT}
+ GL_VERTEX_ARRAY_COUNT_EXT = $807D;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_COUNT_EXT}
+ GL_NORMAL_ARRAY_TYPE_EXT = $807E;
+ {$EXTERNALSYM GL_NORMAL_ARRAY_TYPE_EXT}
+ GL_NORMAL_ARRAY_STRIDE_EXT = $807F;
+ {$EXTERNALSYM GL_NORMAL_ARRAY_STRIDE_EXT}
+ GL_NORMAL_ARRAY_COUNT_EXT = $8080;
+ {$EXTERNALSYM GL_NORMAL_ARRAY_COUNT_EXT}
+ GL_COLOR_ARRAY_SIZE_EXT = $8081;
+ {$EXTERNALSYM GL_COLOR_ARRAY_SIZE_EXT}
+ GL_COLOR_ARRAY_TYPE_EXT = $8082;
+ {$EXTERNALSYM GL_COLOR_ARRAY_TYPE_EXT}
+ GL_COLOR_ARRAY_STRIDE_EXT = $8083;
+ {$EXTERNALSYM GL_COLOR_ARRAY_STRIDE_EXT}
+ GL_COLOR_ARRAY_COUNT_EXT = $8084;
+ {$EXTERNALSYM GL_COLOR_ARRAY_COUNT_EXT}
+ GL_INDEX_ARRAY_TYPE_EXT = $8085;
+ {$EXTERNALSYM GL_INDEX_ARRAY_TYPE_EXT}
+ GL_INDEX_ARRAY_STRIDE_EXT = $8086;
+ {$EXTERNALSYM GL_INDEX_ARRAY_STRIDE_EXT}
+ GL_INDEX_ARRAY_COUNT_EXT = $8087;
+ {$EXTERNALSYM GL_INDEX_ARRAY_COUNT_EXT}
+ GL_TEXTURE_COORD_ARRAY_SIZE_EXT = $8088;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_SIZE_EXT}
+ GL_TEXTURE_COORD_ARRAY_TYPE_EXT = $8089;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_TYPE_EXT}
+ GL_TEXTURE_COORD_ARRAY_STRIDE_EXT = $808A;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_STRIDE_EXT}
+ GL_TEXTURE_COORD_ARRAY_COUNT_EXT = $808B;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_COUNT_EXT}
+ GL_EDGE_FLAG_ARRAY_STRIDE_EXT = $808C;
+ {$EXTERNALSYM GL_EDGE_FLAG_ARRAY_STRIDE_EXT}
+ GL_EDGE_FLAG_ARRAY_COUNT_EXT = $808D;
+ {$EXTERNALSYM GL_EDGE_FLAG_ARRAY_COUNT_EXT}
+ GL_VERTEX_ARRAY_POINTER_EXT = $808E;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_POINTER_EXT}
+ GL_NORMAL_ARRAY_POINTER_EXT = $808F;
+ {$EXTERNALSYM GL_NORMAL_ARRAY_POINTER_EXT}
+ GL_COLOR_ARRAY_POINTER_EXT = $8090;
+ {$EXTERNALSYM GL_COLOR_ARRAY_POINTER_EXT}
+ GL_INDEX_ARRAY_POINTER_EXT = $8091;
+ {$EXTERNALSYM GL_INDEX_ARRAY_POINTER_EXT}
+ GL_TEXTURE_COORD_ARRAY_POINTER_EXT = $8092;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_POINTER_EXT}
+ GL_EDGE_FLAG_ARRAY_POINTER_EXT = $8093;
+ {$EXTERNALSYM GL_EDGE_FLAG_ARRAY_POINTER_EXT}
+
+ // EXT_color_table
+ GL_TABLE_TOO_LARGE_EXT = $8031;
+ {$EXTERNALSYM GL_TABLE_TOO_LARGE_EXT}
+ GL_COLOR_TABLE_EXT = $80D0;
+ {$EXTERNALSYM GL_COLOR_TABLE_EXT}
+ GL_POST_CONVOLUTION_COLOR_TABLE_EXT = $80D1;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_COLOR_TABLE_EXT}
+ GL_POST_COLOR_MATRIX_COLOR_TABLE_EXT = $80D2;
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_COLOR_TABLE_EXT}
+ GL_PROXY_COLOR_TABLE_EXT = $80D3;
+ {$EXTERNALSYM GL_PROXY_COLOR_TABLE_EXT}
+ GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_EXT = $80D4;
+ {$EXTERNALSYM GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_EXT}
+ GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_EXT = $80D5;
+ {$EXTERNALSYM GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_EXT}
+ GL_COLOR_TABLE_SCALE_EXT = $80D6;
+ {$EXTERNALSYM GL_COLOR_TABLE_SCALE_EXT}
+ GL_COLOR_TABLE_BIAS_EXT = $80D7;
+ {$EXTERNALSYM GL_COLOR_TABLE_BIAS_EXT}
+ GL_COLOR_TABLE_FORMAT_EXT = $80D8;
+ {$EXTERNALSYM GL_COLOR_TABLE_FORMAT_EXT}
+ GL_COLOR_TABLE_WIDTH_EXT = $80D9;
+ {$EXTERNALSYM GL_COLOR_TABLE_WIDTH_EXT}
+ GL_COLOR_TABLE_RED_SIZE_EXT = $80DA;
+ {$EXTERNALSYM GL_COLOR_TABLE_RED_SIZE_EXT}
+ GL_COLOR_TABLE_GREEN_SIZE_EXT = $80DB;
+ {$EXTERNALSYM GL_COLOR_TABLE_GREEN_SIZE_EXT}
+ GL_COLOR_TABLE_BLUE_SIZE_EXT = $80DC;
+ {$EXTERNALSYM GL_COLOR_TABLE_BLUE_SIZE_EXT}
+ GL_COLOR_TABLE_ALPHA_SIZE_EXT = $80DD;
+ {$EXTERNALSYM GL_COLOR_TABLE_ALPHA_SIZE_EXT}
+ GL_COLOR_TABLE_LUMINANCE_SIZE_EXT = $80DE;
+ {$EXTERNALSYM GL_COLOR_TABLE_LUMINANCE_SIZE_EXT}
+ GL_COLOR_TABLE_INTENSITY_SIZE_EXT = $80DF;
+ {$EXTERNALSYM GL_COLOR_TABLE_INTENSITY_SIZE_EXT}
+
+ // EXT_bgra
+ GL_BGR_EXT = $80E0;
+ {$EXTERNALSYM GL_BGR_EXT}
+ GL_BGRA_EXT = $80E1;
+ {$EXTERNALSYM GL_BGRA_EXT}
+
+ // EXT_paletted_texture
+ GL_COLOR_INDEX1_EXT = $80E2;
+ {$EXTERNALSYM GL_COLOR_INDEX1_EXT}
+ GL_COLOR_INDEX2_EXT = $80E3;
+ {$EXTERNALSYM GL_COLOR_INDEX2_EXT}
+ GL_COLOR_INDEX4_EXT = $80E4;
+ {$EXTERNALSYM GL_COLOR_INDEX4_EXT}
+ GL_COLOR_INDEX8_EXT = $80E5;
+ {$EXTERNALSYM GL_COLOR_INDEX8_EXT}
+ GL_COLOR_INDEX12_EXT = $80E6;
+ {$EXTERNALSYM GL_COLOR_INDEX12_EXT}
+ GL_COLOR_INDEX16_EXT = $80E7;
+ {$EXTERNALSYM GL_COLOR_INDEX16_EXT}
+
+ // EXT_blend_color
+ GL_CONSTANT_COLOR_EXT = $8001;
+ {$EXTERNALSYM GL_CONSTANT_COLOR_EXT}
+ GL_ONE_MINUS_CONSTANT_COLOR_EXT = $8002;
+ {$EXTERNALSYM GL_ONE_MINUS_CONSTANT_COLOR_EXT}
+ GL_CONSTANT_ALPHA_EXT = $8003;
+ {$EXTERNALSYM GL_CONSTANT_ALPHA_EXT}
+ GL_ONE_MINUS_CONSTANT_ALPHA_EXT = $8004;
+ {$EXTERNALSYM GL_ONE_MINUS_CONSTANT_ALPHA_EXT}
+ GL_BLEND_COLOR_EXT = $8005;
+ {$EXTERNALSYM GL_BLEND_COLOR_EXT}
+
+ // EXT_blend_minmax
+ GL_FUNC_ADD_EXT = $8006;
+ {$EXTERNALSYM GL_FUNC_ADD_EXT}
+ GL_MIN_EXT = $8007;
+ {$EXTERNALSYM GL_MIN_EXT}
+ GL_MAX_EXT = $8008;
+ {$EXTERNALSYM GL_MAX_EXT}
+ GL_BLEND_EQUATION_EXT = $8009;
+ {$EXTERNALSYM GL_BLEND_EQUATION_EXT}
+
+ // EXT_blend_subtract
+ GL_FUNC_SUBTRACT_EXT = $800A;
+ {$EXTERNALSYM GL_FUNC_SUBTRACT_EXT}
+ GL_FUNC_REVERSE_SUBTRACT_EXT = $800B;
+ {$EXTERNALSYM GL_FUNC_REVERSE_SUBTRACT_EXT}
+
+ // EXT_convolution
+ GL_CONVOLUTION_1D_EXT = $8010;
+ {$EXTERNALSYM GL_CONVOLUTION_1D_EXT}
+ GL_CONVOLUTION_2D_EXT = $8011;
+ {$EXTERNALSYM GL_CONVOLUTION_2D_EXT}
+ GL_SEPARABLE_2D_EXT = $8012;
+ {$EXTERNALSYM GL_SEPARABLE_2D_EXT}
+ GL_CONVOLUTION_BORDER_MODE_EXT = $8013;
+ {$EXTERNALSYM GL_CONVOLUTION_BORDER_MODE_EXT}
+ GL_CONVOLUTION_FILTER_SCALE_EXT = $8014;
+ {$EXTERNALSYM GL_CONVOLUTION_FILTER_SCALE_EXT}
+ GL_CONVOLUTION_FILTER_BIAS_EXT = $8015;
+ {$EXTERNALSYM GL_CONVOLUTION_FILTER_BIAS_EXT}
+ GL_REDUCE_EXT = $8016;
+ {$EXTERNALSYM GL_REDUCE_EXT}
+ GL_CONVOLUTION_FORMAT_EXT = $8017;
+ {$EXTERNALSYM GL_CONVOLUTION_FORMAT_EXT}
+ GL_CONVOLUTION_WIDTH_EXT = $8018;
+ {$EXTERNALSYM GL_CONVOLUTION_WIDTH_EXT}
+ GL_CONVOLUTION_HEIGHT_EXT = $8019;
+ {$EXTERNALSYM GL_CONVOLUTION_HEIGHT_EXT}
+ GL_MAX_CONVOLUTION_WIDTH_EXT = $801A;
+ {$EXTERNALSYM GL_MAX_CONVOLUTION_WIDTH_EXT}
+ GL_MAX_CONVOLUTION_HEIGHT_EXT = $801B;
+ {$EXTERNALSYM GL_MAX_CONVOLUTION_HEIGHT_EXT}
+ GL_POST_CONVOLUTION_RED_SCALE_EXT = $801C;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_RED_SCALE_EXT}
+ GL_POST_CONVOLUTION_GREEN_SCALE_EXT = $801D;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_GREEN_SCALE_EXT}
+ GL_POST_CONVOLUTION_BLUE_SCALE_EXT = $801E;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_BLUE_SCALE_EXT}
+ GL_POST_CONVOLUTION_ALPHA_SCALE_EXT = $801F;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_ALPHA_SCALE_EXT}
+ GL_POST_CONVOLUTION_RED_BIAS_EXT = $8020;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_RED_BIAS_EXT}
+ GL_POST_CONVOLUTION_GREEN_BIAS_EXT = $8021;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_GREEN_BIAS_EXT}
+ GL_POST_CONVOLUTION_BLUE_BIAS_EXT = $8022;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_BLUE_BIAS_EXT}
+ GL_POST_CONVOLUTION_ALPHA_BIAS_EXT = $8023;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_ALPHA_BIAS_EXT}
+
+ // EXT_histogram
+ GL_HISTOGRAM_EXT = $8024;
+ {$EXTERNALSYM GL_HISTOGRAM_EXT}
+ GL_PROXY_HISTOGRAM_EXT = $8025;
+ {$EXTERNALSYM GL_PROXY_HISTOGRAM_EXT}
+ GL_HISTOGRAM_WIDTH_EXT = $8026;
+ {$EXTERNALSYM GL_HISTOGRAM_WIDTH_EXT}
+ GL_HISTOGRAM_FORMAT_EXT = $8027;
+ {$EXTERNALSYM GL_HISTOGRAM_FORMAT_EXT}
+ GL_HISTOGRAM_RED_SIZE_EXT = $8028;
+ {$EXTERNALSYM GL_HISTOGRAM_RED_SIZE_EXT}
+ GL_HISTOGRAM_GREEN_SIZE_EXT = $8029;
+ {$EXTERNALSYM GL_HISTOGRAM_GREEN_SIZE_EXT}
+ GL_HISTOGRAM_BLUE_SIZE_EXT = $802A;
+ {$EXTERNALSYM GL_HISTOGRAM_BLUE_SIZE_EXT}
+ GL_HISTOGRAM_ALPHA_SIZE_EXT = $802B;
+ {$EXTERNALSYM GL_HISTOGRAM_ALPHA_SIZE_EXT}
+ GL_HISTOGRAM_LUMINANCE_SIZE_EXT = $802C;
+ {$EXTERNALSYM GL_HISTOGRAM_LUMINANCE_SIZE_EXT}
+ GL_HISTOGRAM_SINK_EXT = $802D;
+ {$EXTERNALSYM GL_HISTOGRAM_SINK_EXT}
+ GL_MINMAX_EXT = $802E;
+ {$EXTERNALSYM GL_MINMAX_EXT}
+ GL_MINMAX_FORMAT_EXT = $802F;
+ {$EXTERNALSYM GL_MINMAX_FORMAT_EXT}
+ GL_MINMAX_SINK_EXT = $8030;
+ {$EXTERNALSYM GL_MINMAX_SINK_EXT}
+
+ // EXT_polygon_offset
+ GL_POLYGON_OFFSET_EXT = $8037;
+ {$EXTERNALSYM GL_POLYGON_OFFSET_EXT}
+ GL_POLYGON_OFFSET_FACTOR_EXT = $8038;
+ {$EXTERNALSYM GL_POLYGON_OFFSET_FACTOR_EXT}
+ GL_POLYGON_OFFSET_BIAS_EXT = $8039;
+ {$EXTERNALSYM GL_POLYGON_OFFSET_BIAS_EXT}
+
+ // EXT_texture
+ GL_ALPHA4_EXT = $803B;
+ {$EXTERNALSYM GL_ALPHA4_EXT}
+ GL_ALPHA8_EXT = $803C;
+ {$EXTERNALSYM GL_ALPHA8_EXT}
+ GL_ALPHA12_EXT = $803D;
+ {$EXTERNALSYM GL_ALPHA12_EXT}
+ GL_ALPHA16_EXT = $803E;
+ {$EXTERNALSYM GL_ALPHA16_EXT}
+ GL_LUMINANCE4_EXT = $803F;
+ {$EXTERNALSYM GL_LUMINANCE4_EXT}
+ GL_LUMINANCE8_EXT = $8040;
+ {$EXTERNALSYM GL_LUMINANCE8_EXT}
+ GL_LUMINANCE12_EXT = $8041;
+ {$EXTERNALSYM GL_LUMINANCE12_EXT}
+ GL_LUMINANCE16_EXT = $8042;
+ {$EXTERNALSYM GL_LUMINANCE16_EXT}
+ GL_LUMINANCE4_ALPHA4_EXT = $8043;
+ {$EXTERNALSYM GL_LUMINANCE4_ALPHA4_EXT}
+ GL_LUMINANCE6_ALPHA2_EXT = $8044;
+ {$EXTERNALSYM GL_LUMINANCE6_ALPHA2_EXT}
+ GL_LUMINANCE8_ALPHA8_EXT = $8045;
+ {$EXTERNALSYM GL_LUMINANCE8_ALPHA8_EXT}
+ GL_LUMINANCE12_ALPHA4_EXT = $8046;
+ {$EXTERNALSYM GL_LUMINANCE12_ALPHA4_EXT}
+ GL_LUMINANCE12_ALPHA12_EXT = $8047;
+ {$EXTERNALSYM GL_LUMINANCE12_ALPHA12_EXT}
+ GL_LUMINANCE16_ALPHA16_EXT = $8048;
+ {$EXTERNALSYM GL_LUMINANCE16_ALPHA16_EXT}
+ GL_INTENSITY_EXT = $8049;
+ {$EXTERNALSYM GL_INTENSITY_EXT}
+ GL_INTENSITY4_EXT = $804A;
+ {$EXTERNALSYM GL_INTENSITY4_EXT}
+ GL_INTENSITY8_EXT = $804B;
+ {$EXTERNALSYM GL_INTENSITY8_EXT}
+ GL_INTENSITY12_EXT = $804C;
+ {$EXTERNALSYM GL_INTENSITY12_EXT}
+ GL_INTENSITY16_EXT = $804D;
+ {$EXTERNALSYM GL_INTENSITY16_EXT}
+ GL_RGB2_EXT = $804E;
+ {$EXTERNALSYM GL_RGB2_EXT}
+ GL_RGB4_EXT = $804F;
+ {$EXTERNALSYM GL_RGB4_EXT}
+ GL_RGB5_EXT = $8050;
+ {$EXTERNALSYM GL_RGB5_EXT}
+ GL_RGB8_EXT = $8051;
+ {$EXTERNALSYM GL_RGB8_EXT}
+ GL_RGB10_EXT = $8052;
+ {$EXTERNALSYM GL_RGB10_EXT}
+ GL_RGB12_EXT = $8053;
+ {$EXTERNALSYM GL_RGB12_EXT}
+ GL_RGB16_EXT = $8054;
+ {$EXTERNALSYM GL_RGB16_EXT}
+ GL_RGBA2_EXT = $8055;
+ {$EXTERNALSYM GL_RGBA2_EXT}
+ GL_RGBA4_EXT = $8056;
+ {$EXTERNALSYM GL_RGBA4_EXT}
+ GL_RGB5_A1_EXT = $8057;
+ {$EXTERNALSYM GL_RGB5_A1_EXT}
+ GL_RGBA8_EXT = $8058;
+ {$EXTERNALSYM GL_RGBA8_EXT}
+ GL_RGB10_A2_EXT = $8059;
+ {$EXTERNALSYM GL_RGB10_A2_EXT}
+ GL_RGBA12_EXT = $805A;
+ {$EXTERNALSYM GL_RGBA12_EXT}
+ GL_RGBA16_EXT = $805B;
+ {$EXTERNALSYM GL_RGBA16_EXT}
+ GL_TEXTURE_RED_SIZE_EXT = $805C;
+ {$EXTERNALSYM GL_TEXTURE_RED_SIZE_EXT}
+ GL_TEXTURE_GREEN_SIZE_EXT = $805D;
+ {$EXTERNALSYM GL_TEXTURE_GREEN_SIZE_EXT}
+ GL_TEXTURE_BLUE_SIZE_EXT = $805E;
+ {$EXTERNALSYM GL_TEXTURE_BLUE_SIZE_EXT}
+ GL_TEXTURE_ALPHA_SIZE_EXT = $805F;
+ {$EXTERNALSYM GL_TEXTURE_ALPHA_SIZE_EXT}
+ GL_TEXTURE_LUMINANCE_SIZE_EXT = $8060;
+ {$EXTERNALSYM GL_TEXTURE_LUMINANCE_SIZE_EXT}
+ GL_TEXTURE_INTENSITY_SIZE_EXT = $8061;
+ {$EXTERNALSYM GL_TEXTURE_INTENSITY_SIZE_EXT}
+ GL_REPLACE_EXT = $8062;
+ {$EXTERNALSYM GL_REPLACE_EXT}
+ GL_PROXY_TEXTURE_1D_EXT = $8063;
+ {$EXTERNALSYM GL_PROXY_TEXTURE_1D_EXT}
+ GL_PROXY_TEXTURE_2D_EXT = $8064;
+ {$EXTERNALSYM GL_PROXY_TEXTURE_2D_EXT}
+ GL_TEXTURE_TOO_LARGE_EXT = $8065;
+ {$EXTERNALSYM GL_TEXTURE_TOO_LARGE_EXT}
+
+ // EXT_texture_object
+ GL_TEXTURE_PRIORITY_EXT = $8066;
+ {$EXTERNALSYM GL_TEXTURE_PRIORITY_EXT}
+ GL_TEXTURE_RESIDENT_EXT = $8067;
+ {$EXTERNALSYM GL_TEXTURE_RESIDENT_EXT}
+ GL_TEXTURE_1D_BINDING_EXT = $8068;
+ {$EXTERNALSYM GL_TEXTURE_1D_BINDING_EXT}
+ GL_TEXTURE_2D_BINDING_EXT = $8069;
+ {$EXTERNALSYM GL_TEXTURE_2D_BINDING_EXT}
+ GL_TEXTURE_3D_BINDING_EXT = $806A;
+ {$EXTERNALSYM GL_TEXTURE_3D_BINDING_EXT}
+
+ // EXT_texture3D
+ GL_PACK_SKIP_IMAGES_EXT = $806B;
+ {$EXTERNALSYM GL_PACK_SKIP_IMAGES_EXT}
+ GL_PACK_IMAGE_HEIGHT_EXT = $806C;
+ {$EXTERNALSYM GL_PACK_IMAGE_HEIGHT_EXT}
+ GL_UNPACK_SKIP_IMAGES_EXT = $806D;
+ {$EXTERNALSYM GL_UNPACK_SKIP_IMAGES_EXT}
+ GL_UNPACK_IMAGE_HEIGHT_EXT = $806E;
+ {$EXTERNALSYM GL_UNPACK_IMAGE_HEIGHT_EXT}
+ GL_TEXTURE_3D_EXT = $806F;
+ {$EXTERNALSYM GL_TEXTURE_3D_EXT}
+ GL_PROXY_TEXTURE_3D_EXT = $8070;
+ {$EXTERNALSYM GL_PROXY_TEXTURE_3D_EXT}
+ GL_TEXTURE_DEPTH_EXT = $8071;
+ {$EXTERNALSYM GL_TEXTURE_DEPTH_EXT}
+ GL_TEXTURE_WRAP_R_EXT = $8072;
+ {$EXTERNALSYM GL_TEXTURE_WRAP_R_EXT}
+ GL_MAX_3D_TEXTURE_SIZE_EXT = $8073;
+ {$EXTERNALSYM GL_MAX_3D_TEXTURE_SIZE_EXT}
+
+ // SGI_color_matrix
+ GL_COLOR_MATRIX_SGI = $80B1;
+ {$EXTERNALSYM GL_COLOR_MATRIX_SGI}
+ GL_COLOR_MATRIX_STACK_DEPTH_SGI = $80B2;
+ {$EXTERNALSYM GL_COLOR_MATRIX_STACK_DEPTH_SGI}
+ GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI = $80B3;
+ {$EXTERNALSYM GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI}
+ GL_POST_COLOR_MATRIX_RED_SCALE_SGI = $80B4;
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_RED_SCALE_SGI}
+ GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI = $80B5;
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI}
+ GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI = $80B6;
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI}
+ GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI = $80B7;
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI}
+ GL_POST_COLOR_MATRIX_RED_BIAS_SGI = $80B8;
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_RED_BIAS_SGI}
+ GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI = $80B9;
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI}
+ GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI = $80BA;
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI}
+ GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI = $80BB;
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI}
+
+ // SGI_texture_color_table
+ GL_TEXTURE_COLOR_TABLE_SGI = $80BC;
+ {$EXTERNALSYM GL_TEXTURE_COLOR_TABLE_SGI}
+ GL_PROXY_TEXTURE_COLOR_TABLE_SGI = $80BD;
+ {$EXTERNALSYM GL_PROXY_TEXTURE_COLOR_TABLE_SGI}
+ GL_TEXTURE_COLOR_TABLE_BIAS_SGI = $80BE;
+ {$EXTERNALSYM GL_TEXTURE_COLOR_TABLE_BIAS_SGI}
+ GL_TEXTURE_COLOR_TABLE_SCALE_SGI = $80BF;
+ {$EXTERNALSYM GL_TEXTURE_COLOR_TABLE_SCALE_SGI}
+
+ // SGI_color_table
+ GL_COLOR_TABLE_SGI = $80D0;
+ {$EXTERNALSYM GL_COLOR_TABLE_SGI}
+ GL_POST_CONVOLUTION_COLOR_TABLE_SGI = $80D1;
+ {$EXTERNALSYM GL_POST_CONVOLUTION_COLOR_TABLE_SGI}
+ GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI = $80D2;
+ {$EXTERNALSYM GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI}
+ GL_PROXY_COLOR_TABLE_SGI = $80D3;
+ {$EXTERNALSYM GL_PROXY_COLOR_TABLE_SGI}
+ GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI = $80D4;
+ {$EXTERNALSYM GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI}
+ GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI = $80D5;
+ {$EXTERNALSYM GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI}
+ GL_COLOR_TABLE_SCALE_SGI = $80D6;
+ {$EXTERNALSYM GL_COLOR_TABLE_SCALE_SGI}
+ GL_COLOR_TABLE_BIAS_SGI = $80D7;
+ {$EXTERNALSYM GL_COLOR_TABLE_BIAS_SGI}
+ GL_COLOR_TABLE_FORMAT_SGI = $80D8;
+ {$EXTERNALSYM GL_COLOR_TABLE_FORMAT_SGI}
+ GL_COLOR_TABLE_WIDTH_SGI = $80D9;
+ {$EXTERNALSYM GL_COLOR_TABLE_WIDTH_SGI}
+ GL_COLOR_TABLE_RED_SIZE_SGI = $80DA;
+ {$EXTERNALSYM GL_COLOR_TABLE_RED_SIZE_SGI}
+ GL_COLOR_TABLE_GREEN_SIZE_SGI = $80DB;
+ {$EXTERNALSYM GL_COLOR_TABLE_GREEN_SIZE_SGI}
+ GL_COLOR_TABLE_BLUE_SIZE_SGI = $80DC;
+ {$EXTERNALSYM GL_COLOR_TABLE_BLUE_SIZE_SGI}
+ GL_COLOR_TABLE_ALPHA_SIZE_SGI = $80DD;
+ {$EXTERNALSYM GL_COLOR_TABLE_ALPHA_SIZE_SGI}
+ GL_COLOR_TABLE_LUMINANCE_SIZE_SGI = $80DE;
+ {$EXTERNALSYM GL_COLOR_TABLE_LUMINANCE_SIZE_SGI}
+ GL_COLOR_TABLE_INTENSITY_SIZE_SGI = $80DF;
+ {$EXTERNALSYM GL_COLOR_TABLE_INTENSITY_SIZE_SGI}
+
+ // EXT_cmyka
+ GL_CMYK_EXT = $800C;
+ {$EXTERNALSYM GL_CMYK_EXT}
+ GL_CMYKA_EXT = $800D;
+ {$EXTERNALSYM GL_CMYKA_EXT}
+ GL_PACK_CMYK_HINT_EXT = $800E;
+ {$EXTERNALSYM GL_PACK_CMYK_HINT_EXT}
+ GL_UNPACK_CMYK_HINT_EXT = $800F;
+ {$EXTERNALSYM GL_UNPACK_CMYK_HINT_EXT}
+
+ // EXT_rescale_normal
+ GL_RESCALE_NORMAL_EXT = $803A;
+ {$EXTERNALSYM GL_RESCALE_NORMAL_EXT}
+
+ // EXT_clip_volume_hint
+ GL_CLIP_VOLUME_CLIPPING_HINT_EXT = $80F0;
+ {$EXTERNALSYM GL_CLIP_VOLUME_CLIPPING_HINT_EXT}
+
+ // EXT_cull_vertex
+ GL_CULL_VERTEX_EXT = $81AA;
+ {$EXTERNALSYM GL_CULL_VERTEX_EXT}
+ GL_CULL_VERTEX_EYE_POSITION_EXT = $81AB;
+ {$EXTERNALSYM GL_CULL_VERTEX_EYE_POSITION_EXT}
+ GL_CULL_VERTEX_OBJECT_POSITION_EXT = $81AC;
+ {$EXTERNALSYM GL_CULL_VERTEX_OBJECT_POSITION_EXT}
+
+ // EXT_index_array_formats
+ GL_IUI_V2F_EXT = $81AD;
+ {$EXTERNALSYM GL_IUI_V2F_EXT}
+ GL_IUI_V3F_EXT = $81AE;
+ {$EXTERNALSYM GL_IUI_V3F_EXT}
+ GL_IUI_N3F_V2F_EXT = $81AF;
+ {$EXTERNALSYM GL_IUI_N3F_V2F_EXT}
+ GL_IUI_N3F_V3F_EXT = $81B0;
+ {$EXTERNALSYM GL_IUI_N3F_V3F_EXT}
+ GL_T2F_IUI_V2F_EXT = $81B1;
+ {$EXTERNALSYM GL_T2F_IUI_V2F_EXT}
+ GL_T2F_IUI_V3F_EXT = $81B2;
+ {$EXTERNALSYM GL_T2F_IUI_V3F_EXT}
+ GL_T2F_IUI_N3F_V2F_EXT = $81B3;
+ {$EXTERNALSYM GL_T2F_IUI_N3F_V2F_EXT}
+ GL_T2F_IUI_N3F_V3F_EXT = $81B4;
+ {$EXTERNALSYM GL_T2F_IUI_N3F_V3F_EXT}
+
+ // EXT_index_func
+ GL_INDEX_TEST_EXT = $81B5;
+ {$EXTERNALSYM GL_INDEX_TEST_EXT}
+ GL_INDEX_TEST_FUNC_EXT = $81B6;
+ {$EXTERNALSYM GL_INDEX_TEST_FUNC_EXT}
+ GL_INDEX_TEST_REF_EXT = $81B7;
+ {$EXTERNALSYM GL_INDEX_TEST_REF_EXT}
+
+ // EXT_index_material
+ GL_INDEX_MATERIAL_EXT = $81B8;
+ {$EXTERNALSYM GL_INDEX_MATERIAL_EXT}
+ GL_INDEX_MATERIAL_PARAMETER_EXT = $81B9;
+ {$EXTERNALSYM GL_INDEX_MATERIAL_PARAMETER_EXT}
+ GL_INDEX_MATERIAL_FACE_EXT = $81BA;
+ {$EXTERNALSYM GL_INDEX_MATERIAL_FACE_EXT}
+
+ // EXT_misc_attribute
+ GL_MISC_BIT_EXT = 0; // not yet defined
+ {$EXTERNALSYM GL_MISC_BIT_EXT}
+
+ // EXT_scene_marker
+ GL_SCENE_REQUIRED_EXT = 0; // not yet defined
+ {$EXTERNALSYM GL_SCENE_REQUIRED_EXT}
+
+ // EXT_shared_texture_palette
+ GL_SHARED_TEXTURE_PALETTE_EXT = $81FB;
+ {$EXTERNALSYM GL_SHARED_TEXTURE_PALETTE_EXT}
+
+ // EXT_nurbs_tessellator
+ GLU_NURBS_MODE_EXT = 100160;
+ {$EXTERNALSYM GLU_NURBS_MODE_EXT}
+ GLU_NURBS_TESSELLATOR_EXT = 100161;
+ {$EXTERNALSYM GLU_NURBS_TESSELLATOR_EXT}
+ GLU_NURBS_RENDERER_EXT = 100162;
+ {$EXTERNALSYM GLU_NURBS_RENDERER_EXT}
+ GLU_NURBS_BEGIN_EXT = 100164;
+ {$EXTERNALSYM GLU_NURBS_BEGIN_EXT}
+ GLU_NURBS_VERTEX_EXT = 100165;
+ {$EXTERNALSYM GLU_NURBS_VERTEX_EXT}
+ GLU_NURBS_NORMAL_EXT = 100166;
+ {$EXTERNALSYM GLU_NURBS_NORMAL_EXT}
+ GLU_NURBS_COLOR_EXT = 100167;
+ {$EXTERNALSYM GLU_NURBS_COLOR_EXT}
+ GLU_NURBS_TEX_COORD_EXT = 100168;
+ {$EXTERNALSYM GLU_NURBS_TEX_COORD_EXT}
+ GLU_NURBS_END_EXT = 100169;
+ {$EXTERNALSYM GLU_NURBS_END_EXT}
+ GLU_NURBS_BEGIN_DATA_EXT = 100170;
+ {$EXTERNALSYM GLU_NURBS_BEGIN_DATA_EXT}
+ GLU_NURBS_VERTEX_DATA_EXT = 100171;
+ {$EXTERNALSYM GLU_NURBS_VERTEX_DATA_EXT}
+ GLU_NURBS_NORMAL_DATA_EXT = 100172;
+ {$EXTERNALSYM GLU_NURBS_NORMAL_DATA_EXT}
+ GLU_NURBS_COLOR_DATA_EXT = 100173;
+ {$EXTERNALSYM GLU_NURBS_COLOR_DATA_EXT}
+ GLU_NURBS_TEX_COORD_DATA_EXT = 100174;
+ {$EXTERNALSYM GLU_NURBS_TEX_COORD_DATA_EXT}
+ GLU_NURBS_END_DATA_EXT = 100175;
+ {$EXTERNALSYM GLU_NURBS_END_DATA_EXT}
+
+ // EXT_object_space_tess
+ GLU_OBJECT_PARAMETRIC_ERROR_EXT = 100208;
+ {$EXTERNALSYM GLU_OBJECT_PARAMETRIC_ERROR_EXT}
+ GLU_OBJECT_PATH_LENGTH_EXT = 100209;
+ {$EXTERNALSYM GLU_OBJECT_PATH_LENGTH_EXT}
+
+ // EXT_point_parameters
+ GL_POINT_SIZE_MIN_EXT = $8126;
+ {$EXTERNALSYM GL_POINT_SIZE_MIN_EXT}
+ GL_POINT_SIZE_MAX_EXT = $8127;
+ {$EXTERNALSYM GL_POINT_SIZE_MAX_EXT}
+ GL_POINT_FADE_THRESHOLD_SIZE_EXT = $8128;
+ {$EXTERNALSYM GL_POINT_FADE_THRESHOLD_SIZE_EXT}
+ GL_DISTANCE_ATTENUATION_EXT = $8129;
+ {$EXTERNALSYM GL_DISTANCE_ATTENUATION_EXT}
+
+ // EXT_compiled_vertex_array
+ GL_ARRAY_ELEMENT_LOCK_FIRST_EXT = $81A8;
+ {$EXTERNALSYM GL_ARRAY_ELEMENT_LOCK_FIRST_EXT}
+ GL_ARRAY_ELEMENT_LOCK_COUNT_EXT = $81A9;
+ {$EXTERNALSYM GL_ARRAY_ELEMENT_LOCK_COUNT_EXT}
+
+ // ARB_multitexture
+ GL_ACTIVE_TEXTURE_ARB = $84E0;
+ {$EXTERNALSYM GL_ACTIVE_TEXTURE_ARB}
+ GL_CLIENT_ACTIVE_TEXTURE_ARB = $84E1;
+ {$EXTERNALSYM GL_CLIENT_ACTIVE_TEXTURE_ARB}
+ GL_MAX_TEXTURE_UNITS_ARB = $84E2;
+ {$EXTERNALSYM GL_MAX_TEXTURE_UNITS_ARB}
+ GL_TEXTURE0_ARB = $84C0;
+ {$EXTERNALSYM GL_TEXTURE0_ARB}
+ GL_TEXTURE1_ARB = $84C1;
+ {$EXTERNALSYM GL_TEXTURE1_ARB}
+ GL_TEXTURE2_ARB = $84C2;
+ {$EXTERNALSYM GL_TEXTURE2_ARB}
+ GL_TEXTURE3_ARB = $84C3;
+ {$EXTERNALSYM GL_TEXTURE3_ARB}
+ GL_TEXTURE4_ARB = $84C4;
+ {$EXTERNALSYM GL_TEXTURE4_ARB}
+ GL_TEXTURE5_ARB = $84C5;
+ {$EXTERNALSYM GL_TEXTURE5_ARB}
+ GL_TEXTURE6_ARB = $84C6;
+ {$EXTERNALSYM GL_TEXTURE6_ARB}
+ GL_TEXTURE7_ARB = $84C7;
+ {$EXTERNALSYM GL_TEXTURE7_ARB}
+ GL_TEXTURE8_ARB = $84C8;
+ {$EXTERNALSYM GL_TEXTURE8_ARB}
+ GL_TEXTURE9_ARB = $84C9;
+ {$EXTERNALSYM GL_TEXTURE9_ARB}
+ GL_TEXTURE10_ARB = $84CA;
+ {$EXTERNALSYM GL_TEXTURE10_ARB}
+ GL_TEXTURE11_ARB = $84CB;
+ {$EXTERNALSYM GL_TEXTURE11_ARB}
+ GL_TEXTURE12_ARB = $84CC;
+ {$EXTERNALSYM GL_TEXTURE12_ARB}
+ GL_TEXTURE13_ARB = $84CD;
+ {$EXTERNALSYM GL_TEXTURE13_ARB}
+ GL_TEXTURE14_ARB = $84CE;
+ {$EXTERNALSYM GL_TEXTURE14_ARB}
+ GL_TEXTURE15_ARB = $84CF;
+ {$EXTERNALSYM GL_TEXTURE15_ARB}
+ GL_TEXTURE16_ARB = $84D0;
+ {$EXTERNALSYM GL_TEXTURE16_ARB}
+ GL_TEXTURE17_ARB = $84D1;
+ {$EXTERNALSYM GL_TEXTURE17_ARB}
+ GL_TEXTURE18_ARB = $84D2;
+ {$EXTERNALSYM GL_TEXTURE18_ARB}
+ GL_TEXTURE19_ARB = $84D3;
+ {$EXTERNALSYM GL_TEXTURE19_ARB}
+ GL_TEXTURE20_ARB = $84D4;
+ {$EXTERNALSYM GL_TEXTURE20_ARB}
+ GL_TEXTURE21_ARB = $84D5;
+ {$EXTERNALSYM GL_TEXTURE21_ARB}
+ GL_TEXTURE22_ARB = $84D6;
+ {$EXTERNALSYM GL_TEXTURE22_ARB}
+ GL_TEXTURE23_ARB = $84D7;
+ {$EXTERNALSYM GL_TEXTURE23_ARB}
+ GL_TEXTURE24_ARB = $84D8;
+ {$EXTERNALSYM GL_TEXTURE24_ARB}
+ GL_TEXTURE25_ARB = $84D9;
+ {$EXTERNALSYM GL_TEXTURE25_ARB}
+ GL_TEXTURE26_ARB = $84DA;
+ {$EXTERNALSYM GL_TEXTURE26_ARB}
+ GL_TEXTURE27_ARB = $84DB;
+ {$EXTERNALSYM GL_TEXTURE27_ARB}
+ GL_TEXTURE28_ARB = $84DC;
+ {$EXTERNALSYM GL_TEXTURE28_ARB}
+ GL_TEXTURE29_ARB = $84DD;
+ {$EXTERNALSYM GL_TEXTURE29_ARB}
+ GL_TEXTURE30_ARB = $84DE;
+ {$EXTERNALSYM GL_TEXTURE30_ARB}
+ GL_TEXTURE31_ARB = $84DF;
+ {$EXTERNALSYM GL_TEXTURE31_ARB}
+
+ // EXT_stencil_wrap
+ GL_INCR_WRAP_EXT = $8507;
+ {$EXTERNALSYM GL_INCR_WRAP_EXT}
+ GL_DECR_WRAP_EXT = $8508;
+ {$EXTERNALSYM GL_DECR_WRAP_EXT}
+
+ // NV_texgen_reflection
+ GL_NORMAL_MAP_NV = $8511;
+ {$EXTERNALSYM GL_NORMAL_MAP_NV}
+ GL_REFLECTION_MAP_NV = $8512;
+ {$EXTERNALSYM GL_REFLECTION_MAP_NV}
+
+ // EXT_texture_env_combine
+ GL_COMBINE_EXT = $8570;
+ {$EXTERNALSYM GL_COMBINE_EXT}
+ GL_COMBINE_RGB_EXT = $8571;
+ {$EXTERNALSYM GL_COMBINE_RGB_EXT}
+ GL_COMBINE_ALPHA_EXT = $8572;
+ {$EXTERNALSYM GL_COMBINE_ALPHA_EXT}
+ GL_RGB_SCALE_EXT = $8573;
+ {$EXTERNALSYM GL_RGB_SCALE_EXT}
+ GL_ADD_SIGNED_EXT = $8574;
+ {$EXTERNALSYM GL_ADD_SIGNED_EXT}
+ GL_INTERPOLATE_EXT = $8575;
+ {$EXTERNALSYM GL_INTERPOLATE_EXT}
+ GL_CONSTANT_EXT = $8576;
+ {$EXTERNALSYM GL_CONSTANT_EXT}
+ GL_PRIMARY_COLOR_EXT = $8577;
+ {$EXTERNALSYM GL_PRIMARY_COLOR_EXT}
+ GL_PREVIOUS_EXT = $8578;
+ {$EXTERNALSYM GL_PREVIOUS_EXT}
+ GL_SOURCE0_RGB_EXT = $8580;
+ {$EXTERNALSYM GL_SOURCE0_RGB_EXT}
+ GL_SOURCE1_RGB_EXT = $8581;
+ {$EXTERNALSYM GL_SOURCE1_RGB_EXT}
+ GL_SOURCE2_RGB_EXT = $8582;
+ {$EXTERNALSYM GL_SOURCE2_RGB_EXT}
+ GL_SOURCE0_ALPHA_EXT = $8588;
+ {$EXTERNALSYM GL_SOURCE0_ALPHA_EXT}
+ GL_SOURCE1_ALPHA_EXT = $8589;
+ {$EXTERNALSYM GL_SOURCE1_ALPHA_EXT}
+ GL_SOURCE2_ALPHA_EXT = $858A;
+ {$EXTERNALSYM GL_SOURCE2_ALPHA_EXT}
+ GL_OPERAND0_RGB_EXT = $8590;
+ {$EXTERNALSYM GL_OPERAND0_RGB_EXT}
+ GL_OPERAND1_RGB_EXT = $8591;
+ {$EXTERNALSYM GL_OPERAND1_RGB_EXT}
+ GL_OPERAND2_RGB_EXT = $8592;
+ {$EXTERNALSYM GL_OPERAND2_RGB_EXT}
+ GL_OPERAND0_ALPHA_EXT = $8598;
+ {$EXTERNALSYM GL_OPERAND0_ALPHA_EXT}
+ GL_OPERAND1_ALPHA_EXT = $8599;
+ {$EXTERNALSYM GL_OPERAND1_ALPHA_EXT}
+ GL_OPERAND2_ALPHA_EXT = $859A;
+ {$EXTERNALSYM GL_OPERAND2_ALPHA_EXT}
+
+ // NV_texture_env_combine4
+ GL_COMBINE4_NV = $8503;
+ {$EXTERNALSYM GL_COMBINE4_NV}
+ GL_SOURCE3_RGB_NV = $8583;
+ {$EXTERNALSYM GL_SOURCE3_RGB_NV}
+ GL_SOURCE3_ALPHA_NV = $858B;
+ {$EXTERNALSYM GL_SOURCE3_ALPHA_NV}
+ GL_OPERAND3_RGB_NV = $8593;
+ {$EXTERNALSYM GL_OPERAND3_RGB_NV}
+ GL_OPERAND3_ALPHA_NV = $859B;
+ {$EXTERNALSYM GL_OPERAND3_ALPHA_NV}
+
+ GL_BLEND_EQUATION = $8009;
+ {$EXTERNALSYM GL_BLEND_EQUATION}
+ GL_TABLE_TOO_LARGE = $8031;
+ {$EXTERNALSYM GL_TABLE_TOO_LARGE}
+ GL_UNSIGNED_BYTE_3_3_2 = $8032;
+ {$EXTERNALSYM GL_UNSIGNED_BYTE_3_3_2}
+ GL_UNSIGNED_SHORT_4_4_4_4 = $8033;
+ {$EXTERNALSYM GL_UNSIGNED_SHORT_4_4_4_4}
+ GL_UNSIGNED_SHORT_5_5_5_1 = $8034;
+ {$EXTERNALSYM GL_UNSIGNED_SHORT_5_5_5_1}
+ GL_UNSIGNED_INT_8_8_8_8 = $8035;
+ {$EXTERNALSYM GL_UNSIGNED_INT_8_8_8_8}
+ GL_UNSIGNED_INT_10_10_10_2 = $8036;
+ {$EXTERNALSYM GL_UNSIGNED_INT_10_10_10_2}
+ GL_UNSIGNED_BYTE_2_3_3_REV = $8362;
+ {$EXTERNALSYM GL_UNSIGNED_BYTE_2_3_3_REV}
+ GL_UNSIGNED_SHORT_5_6_5 = $8363;
+ {$EXTERNALSYM GL_UNSIGNED_SHORT_5_6_5}
+ GL_UNSIGNED_SHORT_5_6_5_REV = $8364;
+ {$EXTERNALSYM GL_UNSIGNED_SHORT_5_6_5_REV}
+ GL_UNSIGNED_SHORT_4_4_4_4_REV = $8365;
+ {$EXTERNALSYM GL_UNSIGNED_SHORT_4_4_4_4_REV}
+ GL_UNSIGNED_SHORT_1_5_5_5_REV = $8366;
+ {$EXTERNALSYM GL_UNSIGNED_SHORT_1_5_5_5_REV}
+ GL_UNSIGNED_INT_8_8_8_8_REV = $8367;
+ {$EXTERNALSYM GL_UNSIGNED_INT_8_8_8_8_REV}
+ GL_UNSIGNED_INT_2_10_10_10_REV = $8368;
+ {$EXTERNALSYM GL_UNSIGNED_INT_2_10_10_10_REV}
+
+ // GL_ARB_transpose_matrix
+ GL_TRANSPOSE_MODELVIEW_MATRIX_ARB = $84E3;
+ {$EXTERNALSYM GL_TRANSPOSE_MODELVIEW_MATRIX_ARB}
+ GL_TRANSPOSE_PROJECTION_MATRIX_ARB = $84E4;
+ {$EXTERNALSYM GL_TRANSPOSE_PROJECTION_MATRIX_ARB}
+ GL_TRANSPOSE_TEXTURE_MATRIX_ARB = $84E5;
+ {$EXTERNALSYM GL_TRANSPOSE_TEXTURE_MATRIX_ARB}
+ GL_TRANSPOSE_COLOR_MATRIX_ARB = $84E6;
+ {$EXTERNALSYM GL_TRANSPOSE_COLOR_MATRIX_ARB}
+
+ // GL_ARB_multisample
+ GL_MULTISAMPLE_ARB = $809D;
+ {$EXTERNALSYM GL_MULTISAMPLE_ARB}
+ GL_SAMPLE_ALPHA_TO_COVERAGE_ARB = $809E;
+ {$EXTERNALSYM GL_SAMPLE_ALPHA_TO_COVERAGE_ARB}
+ GL_SAMPLE_ALPHA_TO_ONE_ARB = $809F;
+ {$EXTERNALSYM GL_SAMPLE_ALPHA_TO_ONE_ARB}
+ GL_SAMPLE_COVERAGE_ARB = $80A0;
+ {$EXTERNALSYM GL_SAMPLE_COVERAGE_ARB}
+ GL_SAMPLE_BUFFERS_ARB = $80A8;
+ {$EXTERNALSYM GL_SAMPLE_BUFFERS_ARB}
+ GL_SAMPLES_ARB = $80A9;
+ {$EXTERNALSYM GL_SAMPLES_ARB}
+ GL_SAMPLE_COVERAGE_VALUE_ARB = $80AA;
+ {$EXTERNALSYM GL_SAMPLE_COVERAGE_VALUE_ARB}
+ GL_SAMPLE_COVERAGE_INVERT_ARB = $80AB;
+ {$EXTERNALSYM GL_SAMPLE_COVERAGE_INVERT_ARB}
+ GL_MULTISAMPLE_BIT_ARB = $20000000;
+ {$EXTERNALSYM GL_MULTISAMPLE_BIT_ARB}
+ GLX_SAMPLE_BUFFERS_ARB = 100000;
+ {$EXTERNALSYM GLX_SAMPLE_BUFFERS_ARB}
+ GLX_SAMPLES_ARB = 100001;
+ {$EXTERNALSYM GLX_SAMPLES_ARB}
+ WGL_SAMPLE_BUFFERS_ARB = $2041;
+ {$EXTERNALSYM WGL_SAMPLE_BUFFERS_ARB}
+ WGL_SAMPLES_ARB = $2042;
+ {$EXTERNALSYM WGL_SAMPLES_ARB}
+
+ // GL_ARB_texture_cube_map
+ GL_NORMAL_MAP_ARB = $8511;
+ {$EXTERNALSYM GL_NORMAL_MAP_ARB}
+ GL_REFLECTION_MAP_ARB = $8512;
+ {$EXTERNALSYM GL_REFLECTION_MAP_ARB}
+ GL_TEXTURE_CUBE_MAP_ARB = $8513;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_ARB}
+ GL_TEXTURE_BINDING_CUBE_MAP_ARB = $8514;
+ {$EXTERNALSYM GL_TEXTURE_BINDING_CUBE_MAP_ARB}
+ GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB = $8515;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB}
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB = $8516;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB}
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB = $8517;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB}
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB = $8518;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB}
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB = $8519;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB}
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB = $851A;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB}
+ GL_PROXY_TEXTURE_CUBE_MAP_ARB = $851B;
+ {$EXTERNALSYM GL_PROXY_TEXTURE_CUBE_MAP_ARB}
+ GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB = $851C;
+ {$EXTERNALSYM GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB}
+
+ // GL_ARB_texture_compression
+ GL_COMPRESSED_ALPHA_ARB = $84E9;
+ {$EXTERNALSYM GL_COMPRESSED_ALPHA_ARB}
+ GL_COMPRESSED_LUMINANCE_ARB = $84EA;
+ {$EXTERNALSYM GL_COMPRESSED_LUMINANCE_ARB}
+ GL_COMPRESSED_LUMINANCE_ALPHA_ARB = $84EB;
+ {$EXTERNALSYM GL_COMPRESSED_LUMINANCE_ALPHA_ARB}
+ GL_COMPRESSED_INTENSITY_ARB = $84EC;
+ {$EXTERNALSYM GL_COMPRESSED_INTENSITY_ARB}
+ GL_COMPRESSED_RGB_ARB = $84ED;
+ {$EXTERNALSYM GL_COMPRESSED_RGB_ARB}
+ GL_COMPRESSED_RGBA_ARB = $84EE;
+ {$EXTERNALSYM GL_COMPRESSED_RGBA_ARB}
+ GL_TEXTURE_COMPRESSION_HINT_ARB = $84EF;
+ {$EXTERNALSYM GL_TEXTURE_COMPRESSION_HINT_ARB}
+ GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB = $86A0;
+ {$EXTERNALSYM GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB}
+ GL_TEXTURE_COMPRESSED_ARB = $86A1;
+ {$EXTERNALSYM GL_TEXTURE_COMPRESSED_ARB}
+ GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB = $86A2;
+ {$EXTERNALSYM GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB}
+ GL_COMPRESSED_TEXTURE_FORMATS_ARB = $86A3;
+ {$EXTERNALSYM GL_COMPRESSED_TEXTURE_FORMATS_ARB}
+
+ // GL_ARB_vertex_blend
+ GL_MAX_VERTEX_UNITS_ARB = $86A4;
+ {$EXTERNALSYM GL_MAX_VERTEX_UNITS_ARB}
+ GL_ACTIVE_VERTEX_UNITS_ARB = $86A5;
+ {$EXTERNALSYM GL_ACTIVE_VERTEX_UNITS_ARB}
+ GL_WEIGHT_SUM_UNITY_ARB = $86A6;
+ {$EXTERNALSYM GL_WEIGHT_SUM_UNITY_ARB}
+ GL_VERTEX_BLEND_ARB = $86A7;
+ {$EXTERNALSYM GL_VERTEX_BLEND_ARB}
+ GL_CURRENT_WEIGHT_ARB = $86A8;
+ {$EXTERNALSYM GL_CURRENT_WEIGHT_ARB}
+ GL_WEIGHT_ARRAY_TYPE_ARB = $86A9;
+ {$EXTERNALSYM GL_WEIGHT_ARRAY_TYPE_ARB}
+ GL_WEIGHT_ARRAY_STRIDE_ARB = $86AA;
+ {$EXTERNALSYM GL_WEIGHT_ARRAY_STRIDE_ARB}
+ GL_WEIGHT_ARRAY_SIZE_ARB = $86AB;
+ {$EXTERNALSYM GL_WEIGHT_ARRAY_SIZE_ARB}
+ GL_WEIGHT_ARRAY_POINTER_ARB = $86AC;
+ {$EXTERNALSYM GL_WEIGHT_ARRAY_POINTER_ARB}
+ GL_WEIGHT_ARRAY_ARB = $86AD;
+ {$EXTERNALSYM GL_WEIGHT_ARRAY_ARB}
+ GL_MODELVIEW0_ARB = $1700;
+ {$EXTERNALSYM GL_MODELVIEW0_ARB}
+ GL_MODELVIEW1_ARB = $850A;
+ {$EXTERNALSYM GL_MODELVIEW1_ARB}
+ GL_MODELVIEW2_ARB = $8722;
+ {$EXTERNALSYM GL_MODELVIEW2_ARB}
+ GL_MODELVIEW3_ARB = $8723;
+ {$EXTERNALSYM GL_MODELVIEW3_ARB}
+ GL_MODELVIEW4_ARB = $8724;
+ {$EXTERNALSYM GL_MODELVIEW4_ARB}
+ GL_MODELVIEW5_ARB = $8725;
+ {$EXTERNALSYM GL_MODELVIEW5_ARB}
+ GL_MODELVIEW6_ARB = $8726;
+ {$EXTERNALSYM GL_MODELVIEW6_ARB}
+ GL_MODELVIEW7_ARB = $8727;
+ {$EXTERNALSYM GL_MODELVIEW7_ARB}
+ GL_MODELVIEW8_ARB = $8728;
+ {$EXTERNALSYM GL_MODELVIEW8_ARB}
+ GL_MODELVIEW9_ARB = $8729;
+ {$EXTERNALSYM GL_MODELVIEW9_ARB}
+ GL_MODELVIEW10_ARB = $872A;
+ {$EXTERNALSYM GL_MODELVIEW10_ARB}
+ GL_MODELVIEW11_ARB = $872B;
+ {$EXTERNALSYM GL_MODELVIEW11_ARB}
+ GL_MODELVIEW12_ARB = $872C;
+ {$EXTERNALSYM GL_MODELVIEW12_ARB}
+ GL_MODELVIEW13_ARB = $872D;
+ {$EXTERNALSYM GL_MODELVIEW13_ARB}
+ GL_MODELVIEW14_ARB = $872E;
+ {$EXTERNALSYM GL_MODELVIEW14_ARB}
+ GL_MODELVIEW15_ARB = $872F;
+ {$EXTERNALSYM GL_MODELVIEW15_ARB}
+ GL_MODELVIEW16_ARB = $8730;
+ {$EXTERNALSYM GL_MODELVIEW16_ARB}
+ GL_MODELVIEW17_ARB = $8731;
+ {$EXTERNALSYM GL_MODELVIEW17_ARB}
+ GL_MODELVIEW18_ARB = $8732;
+ {$EXTERNALSYM GL_MODELVIEW18_ARB}
+ GL_MODELVIEW19_ARB = $8733;
+ {$EXTERNALSYM GL_MODELVIEW19_ARB}
+ GL_MODELVIEW20_ARB = $8734;
+ {$EXTERNALSYM GL_MODELVIEW20_ARB}
+ GL_MODELVIEW21_ARB = $8735;
+ {$EXTERNALSYM GL_MODELVIEW21_ARB}
+ GL_MODELVIEW22_ARB = $8736;
+ {$EXTERNALSYM GL_MODELVIEW22_ARB}
+ GL_MODELVIEW23_ARB = $8737;
+ {$EXTERNALSYM GL_MODELVIEW23_ARB}
+ GL_MODELVIEW24_ARB = $8738;
+ {$EXTERNALSYM GL_MODELVIEW24_ARB}
+ GL_MODELVIEW25_ARB = $8739;
+ {$EXTERNALSYM GL_MODELVIEW25_ARB}
+ GL_MODELVIEW26_ARB = $873A;
+ {$EXTERNALSYM GL_MODELVIEW26_ARB}
+ GL_MODELVIEW27_ARB = $873B;
+ {$EXTERNALSYM GL_MODELVIEW27_ARB}
+ GL_MODELVIEW28_ARB = $873C;
+ {$EXTERNALSYM GL_MODELVIEW28_ARB}
+ GL_MODELVIEW29_ARB = $873D;
+ {$EXTERNALSYM GL_MODELVIEW29_ARB}
+ GL_MODELVIEW30_ARB = $873E;
+ {$EXTERNALSYM GL_MODELVIEW30_ARB}
+ GL_MODELVIEW31_ARB = $873F;
+ {$EXTERNALSYM GL_MODELVIEW31_ARB}
+
+ // GL_SGIS_texture_filter4
+ GL_FILTER4_SGIS = $8146;
+ {$EXTERNALSYM GL_FILTER4_SGIS}
+ GL_TEXTURE_FILTER4_SIZE_SGIS = $8147;
+ {$EXTERNALSYM GL_TEXTURE_FILTER4_SIZE_SGIS}
+
+ // GL_SGIS_pixel_texture
+ GL_PIXEL_TEXTURE_SGIS = $8353;
+ {$EXTERNALSYM GL_PIXEL_TEXTURE_SGIS}
+ GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS = $8354;
+ {$EXTERNALSYM GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS}
+ GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS = $8355;
+ {$EXTERNALSYM GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS}
+ GL_PIXEL_GROUP_COLOR_SGIS = $8356;
+ {$EXTERNALSYM GL_PIXEL_GROUP_COLOR_SGIS}
+
+ // GL_SGIX_pixel_texture
+ GL_PIXEL_TEX_GEN_SGIX = $8139;
+ {$EXTERNALSYM GL_PIXEL_TEX_GEN_SGIX}
+ GL_PIXEL_TEX_GEN_MODE_SGIX = $832B;
+ {$EXTERNALSYM GL_PIXEL_TEX_GEN_MODE_SGIX}
+
+ // GL_SGIS_texture4D
+ GL_PACK_SKIP_VOLUMES_SGIS = $8130;
+ {$EXTERNALSYM GL_PACK_SKIP_VOLUMES_SGIS}
+ GL_PACK_IMAGE_DEPTH_SGIS = $8131;
+ {$EXTERNALSYM GL_PACK_IMAGE_DEPTH_SGIS}
+ GL_UNPACK_SKIP_VOLUMES_SGIS = $8132;
+ {$EXTERNALSYM GL_UNPACK_SKIP_VOLUMES_SGIS}
+ GL_UNPACK_IMAGE_DEPTH_SGIS = $8133;
+ {$EXTERNALSYM GL_UNPACK_IMAGE_DEPTH_SGIS}
+ GL_TEXTURE_4D_SGIS = $8134;
+ {$EXTERNALSYM GL_TEXTURE_4D_SGIS}
+ GL_PROXY_TEXTURE_4D_SGIS = $8135;
+ {$EXTERNALSYM GL_PROXY_TEXTURE_4D_SGIS}
+ GL_TEXTURE_4DSIZE_SGIS = $8136;
+ {$EXTERNALSYM GL_TEXTURE_4DSIZE_SGIS}
+ GL_TEXTURE_WRAP_Q_SGIS = $8137;
+ {$EXTERNALSYM GL_TEXTURE_WRAP_Q_SGIS}
+ GL_MAX_4D_TEXTURE_SIZE_SGIS = $8138;
+ {$EXTERNALSYM GL_MAX_4D_TEXTURE_SIZE_SGIS}
+ GL_TEXTURE_4D_BINDING_SGIS = $814F;
+ {$EXTERNALSYM GL_TEXTURE_4D_BINDING_SGIS}
+
+ // GL_SGIS_detail_texture
+ GL_DETAIL_TEXTURE_2D_SGIS = $8095;
+ {$EXTERNALSYM GL_DETAIL_TEXTURE_2D_SGIS}
+ GL_DETAIL_TEXTURE_2D_BINDING_SGIS = $8096;
+ {$EXTERNALSYM GL_DETAIL_TEXTURE_2D_BINDING_SGIS}
+ GL_LINEAR_DETAIL_SGIS = $8097;
+ {$EXTERNALSYM GL_LINEAR_DETAIL_SGIS}
+ GL_LINEAR_DETAIL_ALPHA_SGIS = $8098;
+ {$EXTERNALSYM GL_LINEAR_DETAIL_ALPHA_SGIS}
+ GL_LINEAR_DETAIL_COLOR_SGIS = $8099;
+ {$EXTERNALSYM GL_LINEAR_DETAIL_COLOR_SGIS}
+ GL_DETAIL_TEXTURE_LEVEL_SGIS = $809A;
+ {$EXTERNALSYM GL_DETAIL_TEXTURE_LEVEL_SGIS}
+ GL_DETAIL_TEXTURE_MODE_SGIS = $809B;
+ {$EXTERNALSYM GL_DETAIL_TEXTURE_MODE_SGIS}
+ GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS = $809C;
+ {$EXTERNALSYM GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS}
+
+ // GL_SGIS_sharpen_texture
+ GL_LINEAR_SHARPEN_SGIS = $80AD;
+ {$EXTERNALSYM GL_LINEAR_SHARPEN_SGIS}
+ GL_LINEAR_SHARPEN_ALPHA_SGIS = $80AE;
+ {$EXTERNALSYM GL_LINEAR_SHARPEN_ALPHA_SGIS}
+ GL_LINEAR_SHARPEN_COLOR_SGIS = $80AF;
+ {$EXTERNALSYM GL_LINEAR_SHARPEN_COLOR_SGIS}
+ GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS = $80B0;
+ {$EXTERNALSYM GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS}
+
+ // GL_SGIS_texture_lod
+ GL_TEXTURE_MIN_LOD_SGIS = $813A;
+ {$EXTERNALSYM GL_TEXTURE_MIN_LOD_SGIS}
+ GL_TEXTURE_MAX_LOD_SGIS = $813B;
+ {$EXTERNALSYM GL_TEXTURE_MAX_LOD_SGIS}
+ GL_TEXTURE_BASE_LEVEL_SGIS = $813C;
+ {$EXTERNALSYM GL_TEXTURE_BASE_LEVEL_SGIS}
+ GL_TEXTURE_MAX_LEVEL_SGIS = $813D;
+ {$EXTERNALSYM GL_TEXTURE_MAX_LEVEL_SGIS}
+
+ // GL_SGIS_multisample
+ GL_MULTISAMPLE_SGIS = $809D;
+ {$EXTERNALSYM GL_MULTISAMPLE_SGIS}
+ GL_SAMPLE_ALPHA_TO_MASK_SGIS = $809E;
+ {$EXTERNALSYM GL_SAMPLE_ALPHA_TO_MASK_SGIS}
+ GL_SAMPLE_ALPHA_TO_ONE_SGIS = $809F;
+ {$EXTERNALSYM GL_SAMPLE_ALPHA_TO_ONE_SGIS}
+ GL_SAMPLE_MASK_SGIS = $80A0;
+ {$EXTERNALSYM GL_SAMPLE_MASK_SGIS}
+ GL_1PASS_SGIS = $80A1;
+ {$EXTERNALSYM GL_1PASS_SGIS}
+ GL_2PASS_0_SGIS = $80A2;
+ {$EXTERNALSYM GL_2PASS_0_SGIS}
+ GL_2PASS_1_SGIS = $80A3;
+ {$EXTERNALSYM GL_2PASS_1_SGIS}
+ GL_4PASS_0_SGIS = $80A4;
+ {$EXTERNALSYM GL_4PASS_0_SGIS}
+ GL_4PASS_1_SGIS = $80A5;
+ {$EXTERNALSYM GL_4PASS_1_SGIS}
+ GL_4PASS_2_SGIS = $80A6;
+ {$EXTERNALSYM GL_4PASS_2_SGIS}
+ GL_4PASS_3_SGIS = $80A7;
+ {$EXTERNALSYM GL_4PASS_3_SGIS}
+ GL_SAMPLE_BUFFERS_SGIS = $80A8;
+ {$EXTERNALSYM GL_SAMPLE_BUFFERS_SGIS}
+ GL_SAMPLES_SGIS = $80A9;
+ {$EXTERNALSYM GL_SAMPLES_SGIS}
+ GL_SAMPLE_MASK_VALUE_SGIS = $80AA;
+ {$EXTERNALSYM GL_SAMPLE_MASK_VALUE_SGIS}
+ GL_SAMPLE_MASK_INVERT_SGIS = $80AB;
+ {$EXTERNALSYM GL_SAMPLE_MASK_INVERT_SGIS}
+ GL_SAMPLE_PATTERN_SGIS = $80AC;
+ {$EXTERNALSYM GL_SAMPLE_PATTERN_SGIS}
+
+ // GL_SGIS_generate_mipmap
+ GL_GENERATE_MIPMAP_SGIS = $8191;
+ {$EXTERNALSYM GL_GENERATE_MIPMAP_SGIS}
+ GL_GENERATE_MIPMAP_HINT_SGIS = $8192;
+ {$EXTERNALSYM GL_GENERATE_MIPMAP_HINT_SGIS}
+
+ // GL_SGIX_clipmap
+ GL_LINEAR_CLIPMAP_LINEAR_SGIX = $8170;
+ {$EXTERNALSYM GL_LINEAR_CLIPMAP_LINEAR_SGIX}
+ GL_TEXTURE_CLIPMAP_CENTER_SGIX = $8171;
+ {$EXTERNALSYM GL_TEXTURE_CLIPMAP_CENTER_SGIX}
+ GL_TEXTURE_CLIPMAP_FRAME_SGIX = $8172;
+ {$EXTERNALSYM GL_TEXTURE_CLIPMAP_FRAME_SGIX}
+ GL_TEXTURE_CLIPMAP_OFFSET_SGIX = $8173;
+ {$EXTERNALSYM GL_TEXTURE_CLIPMAP_OFFSET_SGIX}
+ GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX = $8174;
+ {$EXTERNALSYM GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX}
+ GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX = $8175;
+ {$EXTERNALSYM GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX}
+ GL_TEXTURE_CLIPMAP_DEPTH_SGIX = $8176;
+ {$EXTERNALSYM GL_TEXTURE_CLIPMAP_DEPTH_SGIX}
+ GL_MAX_CLIPMAP_DEPTH_SGIX = $8177;
+ {$EXTERNALSYM GL_MAX_CLIPMAP_DEPTH_SGIX}
+ GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX = $8178;
+ {$EXTERNALSYM GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX}
+ GL_NEAREST_CLIPMAP_NEAREST_SGIX = $844D;
+ {$EXTERNALSYM GL_NEAREST_CLIPMAP_NEAREST_SGIX}
+ GL_NEAREST_CLIPMAP_LINEAR_SGIX = $844E;
+ {$EXTERNALSYM GL_NEAREST_CLIPMAP_LINEAR_SGIX}
+ GL_LINEAR_CLIPMAP_NEAREST_SGIX = $844F;
+ {$EXTERNALSYM GL_LINEAR_CLIPMAP_NEAREST_SGIX}
+
+ // GL_SGIX_shadow
+ GL_TEXTURE_COMPARE_SGIX = $819A;
+ {$EXTERNALSYM GL_TEXTURE_COMPARE_SGIX}
+ GL_TEXTURE_COMPARE_OPERATOR_SGIX = $819B;
+ {$EXTERNALSYM GL_TEXTURE_COMPARE_OPERATOR_SGIX}
+ GL_TEXTURE_LEQUAL_R_SGIX = $819C;
+ {$EXTERNALSYM GL_TEXTURE_LEQUAL_R_SGIX}
+ GL_TEXTURE_GEQUAL_R_SGIX = $819D;
+ {$EXTERNALSYM GL_TEXTURE_GEQUAL_R_SGIX}
+
+ // GL_SGIS_texture_edge_clamp
+ GL_CLAMP_TO_EDGE_SGIS = $812F;
+ {$EXTERNALSYM GL_CLAMP_TO_EDGE_SGIS}
+
+ // GL_SGIS_texture_border_clamp
+ GL_CLAMP_TO_BORDER_SGIS = $812D;
+ {$EXTERNALSYM GL_CLAMP_TO_BORDER_SGIS}
+
+ // GL_SGIX_interlace
+ GL_INTERLACE_SGIX = $8094;
+ {$EXTERNALSYM GL_INTERLACE_SGIX}
+
+ // GL_SGIX_pixel_tiles
+ GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX = $813E;
+ {$EXTERNALSYM GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX}
+ GL_PIXEL_TILE_CACHE_INCREMENT_SGIX = $813F;
+ {$EXTERNALSYM GL_PIXEL_TILE_CACHE_INCREMENT_SGIX}
+ GL_PIXEL_TILE_WIDTH_SGIX = $8140;
+ {$EXTERNALSYM GL_PIXEL_TILE_WIDTH_SGIX}
+ GL_PIXEL_TILE_HEIGHT_SGIX = $8141;
+ {$EXTERNALSYM GL_PIXEL_TILE_HEIGHT_SGIX}
+ GL_PIXEL_TILE_GRID_WIDTH_SGIX = $8142;
+ {$EXTERNALSYM GL_PIXEL_TILE_GRID_WIDTH_SGIX}
+ GL_PIXEL_TILE_GRID_HEIGHT_SGIX = $8143;
+ {$EXTERNALSYM GL_PIXEL_TILE_GRID_HEIGHT_SGIX}
+ GL_PIXEL_TILE_GRID_DEPTH_SGIX = $8144;
+ {$EXTERNALSYM GL_PIXEL_TILE_GRID_DEPTH_SGIX}
+ GL_PIXEL_TILE_CACHE_SIZE_SGIX = $8145;
+ {$EXTERNALSYM GL_PIXEL_TILE_CACHE_SIZE_SGIX}
+
+ // GL_SGIS_texture_select
+ GL_DUAL_ALPHA4_SGIS = $8110;
+ {$EXTERNALSYM GL_DUAL_ALPHA4_SGIS}
+ GL_DUAL_ALPHA8_SGIS = $8111;
+ {$EXTERNALSYM GL_DUAL_ALPHA8_SGIS}
+ GL_DUAL_ALPHA12_SGIS = $8112;
+ {$EXTERNALSYM GL_DUAL_ALPHA12_SGIS}
+ GL_DUAL_ALPHA16_SGIS = $8113;
+ {$EXTERNALSYM GL_DUAL_ALPHA16_SGIS}
+ GL_DUAL_LUMINANCE4_SGIS = $8114;
+ {$EXTERNALSYM GL_DUAL_LUMINANCE4_SGIS}
+ GL_DUAL_LUMINANCE8_SGIS = $8115;
+ {$EXTERNALSYM GL_DUAL_LUMINANCE8_SGIS}
+ GL_DUAL_LUMINANCE12_SGIS = $8116;
+ {$EXTERNALSYM GL_DUAL_LUMINANCE12_SGIS}
+ GL_DUAL_LUMINANCE16_SGIS = $8117;
+ {$EXTERNALSYM GL_DUAL_LUMINANCE16_SGIS}
+ GL_DUAL_INTENSITY4_SGIS = $8118;
+ {$EXTERNALSYM GL_DUAL_INTENSITY4_SGIS}
+ GL_DUAL_INTENSITY8_SGIS = $8119;
+ {$EXTERNALSYM GL_DUAL_INTENSITY8_SGIS}
+ GL_DUAL_INTENSITY12_SGIS = $811A;
+ {$EXTERNALSYM GL_DUAL_INTENSITY12_SGIS}
+ GL_DUAL_INTENSITY16_SGIS = $811B;
+ {$EXTERNALSYM GL_DUAL_INTENSITY16_SGIS}
+ GL_DUAL_LUMINANCE_ALPHA4_SGIS = $811C;
+ {$EXTERNALSYM GL_DUAL_LUMINANCE_ALPHA4_SGIS}
+ GL_DUAL_LUMINANCE_ALPHA8_SGIS = $811D;
+ {$EXTERNALSYM GL_DUAL_LUMINANCE_ALPHA8_SGIS}
+ GL_QUAD_ALPHA4_SGIS = $811E;
+ {$EXTERNALSYM GL_QUAD_ALPHA4_SGIS}
+ GL_QUAD_ALPHA8_SGIS = $811F;
+ {$EXTERNALSYM GL_QUAD_ALPHA8_SGIS}
+ GL_QUAD_LUMINANCE4_SGIS = $8120;
+ {$EXTERNALSYM GL_QUAD_LUMINANCE4_SGIS}
+ GL_QUAD_LUMINANCE8_SGIS = $8121;
+ {$EXTERNALSYM GL_QUAD_LUMINANCE8_SGIS}
+ GL_QUAD_INTENSITY4_SGIS = $8122;
+ {$EXTERNALSYM GL_QUAD_INTENSITY4_SGIS}
+ GL_QUAD_INTENSITY8_SGIS = $8123;
+ {$EXTERNALSYM GL_QUAD_INTENSITY8_SGIS}
+ GL_DUAL_TEXTURE_SELECT_SGIS = $8124;
+ {$EXTERNALSYM GL_DUAL_TEXTURE_SELECT_SGIS}
+ GL_QUAD_TEXTURE_SELECT_SGIS = $8125;
+ {$EXTERNALSYM GL_QUAD_TEXTURE_SELECT_SGIS}
+
+ // GL_SGIX_sprite
+ GL_SPRITE_SGIX = $8148;
+ {$EXTERNALSYM GL_SPRITE_SGIX}
+ GL_SPRITE_MODE_SGIX = $8149;
+ {$EXTERNALSYM GL_SPRITE_MODE_SGIX}
+ GL_SPRITE_AXIS_SGIX = $814A;
+ {$EXTERNALSYM GL_SPRITE_AXIS_SGIX}
+ GL_SPRITE_TRANSLATION_SGIX = $814B;
+ {$EXTERNALSYM GL_SPRITE_TRANSLATION_SGIX}
+ GL_SPRITE_AXIAL_SGIX = $814C;
+ {$EXTERNALSYM GL_SPRITE_AXIAL_SGIX}
+ GL_SPRITE_OBJECT_ALIGNED_SGIX = $814D;
+ {$EXTERNALSYM GL_SPRITE_OBJECT_ALIGNED_SGIX}
+ GL_SPRITE_EYE_ALIGNED_SGIX = $814E;
+ {$EXTERNALSYM GL_SPRITE_EYE_ALIGNED_SGIX}
+
+ // GL_SGIX_texture_multi_buffer
+ GL_TEXTURE_MULTI_BUFFER_HINT_SGIX = $812E;
+ {$EXTERNALSYM GL_TEXTURE_MULTI_BUFFER_HINT_SGIX}
+
+ // GL_SGIS_point_parameters
+ GL_POINT_SIZE_MIN_SGIS = $8126;
+ {$EXTERNALSYM GL_POINT_SIZE_MIN_SGIS}
+ GL_POINT_SIZE_MAX_SGIS = $8127;
+ {$EXTERNALSYM GL_POINT_SIZE_MAX_SGIS}
+ GL_POINT_FADE_THRESHOLD_SIZE_SGIS = $8128;
+ {$EXTERNALSYM GL_POINT_FADE_THRESHOLD_SIZE_SGIS}
+ GL_DISTANCE_ATTENUATION_SGIS = $8129;
+ {$EXTERNALSYM GL_DISTANCE_ATTENUATION_SGIS}
+
+ // GL_SGIX_instruments
+ GL_INSTRUMENT_BUFFER_POINTER_SGIX = $8180;
+ {$EXTERNALSYM GL_INSTRUMENT_BUFFER_POINTER_SGIX}
+ GL_INSTRUMENT_MEASUREMENTS_SGIX = $8181;
+ {$EXTERNALSYM GL_INSTRUMENT_MEASUREMENTS_SGIX}
+
+ // GL_SGIX_texture_scale_bias
+ GL_POST_TEXTURE_FILTER_BIAS_SGIX = $8179;
+ {$EXTERNALSYM GL_POST_TEXTURE_FILTER_BIAS_SGIX}
+ GL_POST_TEXTURE_FILTER_SCALE_SGIX = $817A;
+ {$EXTERNALSYM GL_POST_TEXTURE_FILTER_SCALE_SGIX}
+ GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX = $817B;
+ {$EXTERNALSYM GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX}
+ GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX = $817C;
+ {$EXTERNALSYM GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX}
+
+ // GL_SGIX_framezoom
+ GL_FRAMEZOOM_SGIX = $818B;
+ {$EXTERNALSYM GL_FRAMEZOOM_SGIX}
+ GL_FRAMEZOOM_FACTOR_SGIX = $818C;
+ {$EXTERNALSYM GL_FRAMEZOOM_FACTOR_SGIX}
+ GL_MAX_FRAMEZOOM_FACTOR_SGIX = $818D;
+ {$EXTERNALSYM GL_MAX_FRAMEZOOM_FACTOR_SGIX}
+
+ // GL_FfdMaskSGIX
+ GL_TEXTURE_DEFORMATION_BIT_SGIX = $00000001;
+ {$EXTERNALSYM GL_TEXTURE_DEFORMATION_BIT_SGIX}
+ GL_GEOMETRY_DEFORMATION_BIT_SGIX = $00000002;
+ {$EXTERNALSYM GL_GEOMETRY_DEFORMATION_BIT_SGIX}
+
+ // GL_SGIX_polynomial_ffd
+ GL_GEOMETRY_DEFORMATION_SGIX = $8194;
+ {$EXTERNALSYM GL_GEOMETRY_DEFORMATION_SGIX}
+ GL_TEXTURE_DEFORMATION_SGIX = $8195;
+ {$EXTERNALSYM GL_TEXTURE_DEFORMATION_SGIX}
+ GL_DEFORMATIONS_MASK_SGIX = $8196;
+ {$EXTERNALSYM GL_DEFORMATIONS_MASK_SGIX}
+ GL_MAX_DEFORMATION_ORDER_SGIX = $8197;
+ {$EXTERNALSYM GL_MAX_DEFORMATION_ORDER_SGIX}
+
+ // GL_SGIX_reference_plane
+ GL_REFERENCE_PLANE_SGIX = $817D;
+ {$EXTERNALSYM GL_REFERENCE_PLANE_SGIX}
+ GL_REFERENCE_PLANE_EQUATION_SGIX = $817E;
+ {$EXTERNALSYM GL_REFERENCE_PLANE_EQUATION_SGIX}
+
+ // GL_SGIX_depth_texture
+ GL_DEPTH_COMPONENT16_SGIX = $81A5;
+ {$EXTERNALSYM GL_DEPTH_COMPONENT16_SGIX}
+ GL_DEPTH_COMPONENT24_SGIX = $81A6;
+ {$EXTERNALSYM GL_DEPTH_COMPONENT24_SGIX}
+ GL_DEPTH_COMPONENT32_SGIX = $81A7;
+ {$EXTERNALSYM GL_DEPTH_COMPONENT32_SGIX}
+
+ // GL_SGIS_fog_function
+ GL_FOG_FUNC_SGIS = $812A;
+ {$EXTERNALSYM GL_FOG_FUNC_SGIS}
+ GL_FOG_FUNC_POINTS_SGIS = $812B;
+ {$EXTERNALSYM GL_FOG_FUNC_POINTS_SGIS}
+ GL_MAX_FOG_FUNC_POINTS_SGIS = $812C;
+ {$EXTERNALSYM GL_MAX_FOG_FUNC_POINTS_SGIS}
+
+ // GL_SGIX_fog_offset
+ GL_FOG_OFFSET_SGIX = $8198;
+ {$EXTERNALSYM GL_FOG_OFFSET_SGIX}
+ GL_FOG_OFFSET_VALUE_SGIX = $8199;
+ {$EXTERNALSYM GL_FOG_OFFSET_VALUE_SGIX}
+
+ // GL_HP_image_transform
+ GL_IMAGE_SCALE_X_HP = $8155;
+ {$EXTERNALSYM GL_IMAGE_SCALE_X_HP}
+ GL_IMAGE_SCALE_Y_HP = $8156;
+ {$EXTERNALSYM GL_IMAGE_SCALE_Y_HP}
+ GL_IMAGE_TRANSLATE_X_HP = $8157;
+ {$EXTERNALSYM GL_IMAGE_TRANSLATE_X_HP}
+ GL_IMAGE_TRANSLATE_Y_HP = $8158;
+ {$EXTERNALSYM GL_IMAGE_TRANSLATE_Y_HP}
+ GL_IMAGE_ROTATE_ANGLE_HP = $8159;
+ {$EXTERNALSYM GL_IMAGE_ROTATE_ANGLE_HP}
+ GL_IMAGE_ROTATE_ORIGIN_X_HP = $815A;
+ {$EXTERNALSYM GL_IMAGE_ROTATE_ORIGIN_X_HP}
+ GL_IMAGE_ROTATE_ORIGIN_Y_HP = $815B;
+ {$EXTERNALSYM GL_IMAGE_ROTATE_ORIGIN_Y_HP}
+ GL_IMAGE_MAG_FILTER_HP = $815C;
+ {$EXTERNALSYM GL_IMAGE_MAG_FILTER_HP}
+ GL_IMAGE_MIN_FILTER_HP = $815D;
+ {$EXTERNALSYM GL_IMAGE_MIN_FILTER_HP}
+ GL_IMAGE_CUBIC_WEIGHT_HP = $815E;
+ {$EXTERNALSYM GL_IMAGE_CUBIC_WEIGHT_HP}
+ GL_CUBIC_HP = $815F;
+ {$EXTERNALSYM GL_CUBIC_HP}
+ GL_AVERAGE_HP = $8160;
+ {$EXTERNALSYM GL_AVERAGE_HP}
+ GL_IMAGE_TRANSFORM_2D_HP = $8161;
+ {$EXTERNALSYM GL_IMAGE_TRANSFORM_2D_HP}
+ GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP = $8162;
+ {$EXTERNALSYM GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP}
+ GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP = $8163;
+ {$EXTERNALSYM GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP}
+
+ // GL_HP_convolution_border_modes
+ GL_IGNORE_BORDER_HP = $8150;
+ {$EXTERNALSYM GL_IGNORE_BORDER_HP}
+ GL_CONSTANT_BORDER_HP = $8151;
+ {$EXTERNALSYM GL_CONSTANT_BORDER_HP}
+ GL_REPLICATE_BORDER_HP = $8153;
+ {$EXTERNALSYM GL_REPLICATE_BORDER_HP}
+ GL_CONVOLUTION_BORDER_COLOR_HP = $8154;
+ {$EXTERNALSYM GL_CONVOLUTION_BORDER_COLOR_HP}
+
+ // GL_SGIX_texture_add_env
+ GL_TEXTURE_ENV_BIAS_SGIX = $80BE;
+ {$EXTERNALSYM GL_TEXTURE_ENV_BIAS_SGIX}
+
+ // GL_PGI_vertex_hints
+ GL_VERTEX_DATA_HINT_PGI = $1A22A;
+ {$EXTERNALSYM GL_VERTEX_DATA_HINT_PGI}
+ GL_VERTEX_CONSISTENT_HINT_PGI = $1A22B;
+ {$EXTERNALSYM GL_VERTEX_CONSISTENT_HINT_PGI}
+ GL_MATERIAL_SIDE_HINT_PGI = $1A22C;
+ {$EXTERNALSYM GL_MATERIAL_SIDE_HINT_PGI}
+ GL_MAX_VERTEX_HINT_PGI = $1A22D;
+ {$EXTERNALSYM GL_MAX_VERTEX_HINT_PGI}
+ GL_COLOR3_BIT_PGI = $00010000;
+ {$EXTERNALSYM GL_COLOR3_BIT_PGI}
+ GL_COLOR4_BIT_PGI = $00020000;
+ {$EXTERNALSYM GL_COLOR4_BIT_PGI}
+ GL_EDGEFLAG_BIT_PGI = $00040000;
+ {$EXTERNALSYM GL_EDGEFLAG_BIT_PGI}
+ GL_INDEX_BIT_PGI = $00080000;
+ {$EXTERNALSYM GL_INDEX_BIT_PGI}
+ GL_MAT_AMBIENT_BIT_PGI = $00100000;
+ {$EXTERNALSYM GL_MAT_AMBIENT_BIT_PGI}
+ GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI = $00200000;
+ {$EXTERNALSYM GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI}
+ GL_MAT_DIFFUSE_BIT_PGI = $00400000;
+ {$EXTERNALSYM GL_MAT_DIFFUSE_BIT_PGI}
+ GL_MAT_EMISSION_BIT_PGI = $00800000;
+ {$EXTERNALSYM GL_MAT_EMISSION_BIT_PGI}
+ GL_MAT_COLOR_INDEXES_BIT_PGI = $01000000;
+ {$EXTERNALSYM GL_MAT_COLOR_INDEXES_BIT_PGI}
+ GL_MAT_SHININESS_BIT_PGI = $02000000;
+ {$EXTERNALSYM GL_MAT_SHININESS_BIT_PGI}
+ GL_MAT_SPECULAR_BIT_PGI = $04000000;
+ {$EXTERNALSYM GL_MAT_SPECULAR_BIT_PGI}
+ GL_NORMAL_BIT_PGI = $08000000;
+ {$EXTERNALSYM GL_NORMAL_BIT_PGI}
+ GL_TEXCOORD1_BIT_PGI = $10000000;
+ {$EXTERNALSYM GL_TEXCOORD1_BIT_PGI}
+ GL_TEXCOORD2_BIT_PGI = $20000000;
+ {$EXTERNALSYM GL_TEXCOORD2_BIT_PGI}
+ GL_TEXCOORD3_BIT_PGI = $40000000;
+ {$EXTERNALSYM GL_TEXCOORD3_BIT_PGI}
+ GL_TEXCOORD4_BIT_PGI = $80000000;
+ {$EXTERNALSYM GL_TEXCOORD4_BIT_PGI}
+ GL_VERTEX23_BIT_PGI = $00000004;
+ {$EXTERNALSYM GL_VERTEX23_BIT_PGI}
+ GL_VERTEX4_BIT_PGI = $00000008;
+ {$EXTERNALSYM GL_VERTEX4_BIT_PGI}
+
+ // GL_PGI_misc_hints
+ GL_PREFER_DOUBLEBUFFER_HINT_PGI = $1A1F8;
+ {$EXTERNALSYM GL_PREFER_DOUBLEBUFFER_HINT_PGI}
+ GL_CONSERVE_MEMORY_HINT_PGI = $1A1FD;
+ {$EXTERNALSYM GL_CONSERVE_MEMORY_HINT_PGI}
+ GL_RECLAIM_MEMORY_HINT_PGI = $1A1FE;
+ {$EXTERNALSYM GL_RECLAIM_MEMORY_HINT_PGI}
+ GL_NATIVE_GRAPHICS_HANDLE_PGI = $1A202;
+ {$EXTERNALSYM GL_NATIVE_GRAPHICS_HANDLE_PGI}
+ GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI = $1A203;
+ {$EXTERNALSYM GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI}
+ GL_NATIVE_GRAPHICS_END_HINT_PGI = $1A204;
+ {$EXTERNALSYM GL_NATIVE_GRAPHICS_END_HINT_PGI}
+ GL_ALWAYS_FAST_HINT_PGI = $1A20C;
+ {$EXTERNALSYM GL_ALWAYS_FAST_HINT_PGI}
+ GL_ALWAYS_SOFT_HINT_PGI = $1A20D;
+ {$EXTERNALSYM GL_ALWAYS_SOFT_HINT_PGI}
+ GL_ALLOW_DRAW_OBJ_HINT_PGI = $1A20E;
+ {$EXTERNALSYM GL_ALLOW_DRAW_OBJ_HINT_PGI}
+ GL_ALLOW_DRAW_WIN_HINT_PGI = $1A20F;
+ {$EXTERNALSYM GL_ALLOW_DRAW_WIN_HINT_PGI}
+ GL_ALLOW_DRAW_FRG_HINT_PGI = $1A210;
+ {$EXTERNALSYM GL_ALLOW_DRAW_FRG_HINT_PGI}
+ GL_ALLOW_DRAW_MEM_HINT_PGI = $1A211;
+ {$EXTERNALSYM GL_ALLOW_DRAW_MEM_HINT_PGI}
+ GL_STRICT_DEPTHFUNC_HINT_PGI = $1A216;
+ {$EXTERNALSYM GL_STRICT_DEPTHFUNC_HINT_PGI}
+ GL_STRICT_LIGHTING_HINT_PGI = $1A217;
+ {$EXTERNALSYM GL_STRICT_LIGHTING_HINT_PGI}
+ GL_STRICT_SCISSOR_HINT_PGI = $1A218;
+ {$EXTERNALSYM GL_STRICT_SCISSOR_HINT_PGI}
+ GL_FULL_STIPPLE_HINT_PGI = $1A219;
+ {$EXTERNALSYM GL_FULL_STIPPLE_HINT_PGI}
+ GL_CLIP_NEAR_HINT_PGI = $1A220;
+ {$EXTERNALSYM GL_CLIP_NEAR_HINT_PGI}
+ GL_CLIP_FAR_HINT_PGI = $1A221;
+ {$EXTERNALSYM GL_CLIP_FAR_HINT_PGI}
+ GL_WIDE_LINE_HINT_PGI = $1A222;
+ {$EXTERNALSYM GL_WIDE_LINE_HINT_PGI}
+ GL_BACK_NORMALS_HINT_PGI = $1A223;
+ {$EXTERNALSYM GL_BACK_NORMALS_HINT_PGI}
+
+ // GL_EXT_paletted_texture
+ GL_TEXTURE_INDEX_SIZE_EXT = $80ED;
+ {$EXTERNALSYM GL_TEXTURE_INDEX_SIZE_EXT}
+
+ // GL_SGIX_list_priority
+ GL_LIST_PRIORITY_SGIX = $8182;
+ {$EXTERNALSYM GL_LIST_PRIORITY_SGIX}
+
+ // GL_SGIX_ir_instrument1
+ GL_IR_INSTRUMENT1_SGIX = $817F;
+ {$EXTERNALSYM GL_IR_INSTRUMENT1_SGIX}
+
+ // GL_SGIX_calligraphic_fragment
+ GL_CALLIGRAPHIC_FRAGMENT_SGIX = $8183;
+ {$EXTERNALSYM GL_CALLIGRAPHIC_FRAGMENT_SGIX}
+
+ // GL_SGIX_texture_lod_bias
+ GL_TEXTURE_LOD_BIAS_S_SGIX = $818E;
+ {$EXTERNALSYM GL_TEXTURE_LOD_BIAS_S_SGIX}
+ GL_TEXTURE_LOD_BIAS_T_SGIX = $818F;
+ {$EXTERNALSYM GL_TEXTURE_LOD_BIAS_T_SGIX}
+ GL_TEXTURE_LOD_BIAS_R_SGIX = $8190;
+ {$EXTERNALSYM GL_TEXTURE_LOD_BIAS_R_SGIX}
+
+ // GL_SGIX_shadow_ambient
+ GL_SHADOW_AMBIENT_SGIX = $80BF;
+ {$EXTERNALSYM GL_SHADOW_AMBIENT_SGIX}
+
+ // GL_SGIX_ycrcb
+ GL_YCRCB_422_SGIX = $81BB;
+ {$EXTERNALSYM GL_YCRCB_422_SGIX}
+ GL_YCRCB_444_SGIX = $81BC;
+ {$EXTERNALSYM GL_YCRCB_444_SGIX}
+
+ // GL_SGIX_fragment_lighting
+ GL_FRAGMENT_LIGHTING_SGIX = $8400;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHTING_SGIX}
+ GL_FRAGMENT_COLOR_MATERIAL_SGIX = $8401;
+ {$EXTERNALSYM GL_FRAGMENT_COLOR_MATERIAL_SGIX}
+ GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX = $8402;
+ {$EXTERNALSYM GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX}
+ GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX = $8403;
+ {$EXTERNALSYM GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX}
+ GL_MAX_FRAGMENT_LIGHTS_SGIX = $8404;
+ {$EXTERNALSYM GL_MAX_FRAGMENT_LIGHTS_SGIX}
+ GL_MAX_ACTIVE_LIGHTS_SGIX = $8405;
+ {$EXTERNALSYM GL_MAX_ACTIVE_LIGHTS_SGIX}
+ GL_CURRENT_RASTER_NORMAL_SGIX = $8406;
+ {$EXTERNALSYM GL_CURRENT_RASTER_NORMAL_SGIX}
+ GL_LIGHT_ENV_MODE_SGIX = $8407;
+ {$EXTERNALSYM GL_LIGHT_ENV_MODE_SGIX}
+ GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX = $8408;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX}
+ GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX = $8409;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX}
+ GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX = $840A;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX}
+ GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX = $840B;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX}
+ GL_FRAGMENT_LIGHT0_SGIX = $840C;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHT0_SGIX}
+ GL_FRAGMENT_LIGHT1_SGIX = $840D;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHT1_SGIX}
+ GL_FRAGMENT_LIGHT2_SGIX = $840E;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHT2_SGIX}
+ GL_FRAGMENT_LIGHT3_SGIX = $840F;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHT3_SGIX}
+ GL_FRAGMENT_LIGHT4_SGIX = $8410;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHT4_SGIX}
+ GL_FRAGMENT_LIGHT5_SGIX = $8411;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHT5_SGIX}
+ GL_FRAGMENT_LIGHT6_SGIX = $8412;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHT6_SGIX}
+ GL_FRAGMENT_LIGHT7_SGIX = $8413;
+ {$EXTERNALSYM GL_FRAGMENT_LIGHT7_SGIX}
+
+ // GL_IBM_rasterpos_clip
+ GL_RASTER_POSITION_UNCLIPPED_IBM = $19262;
+ {$EXTERNALSYM GL_RASTER_POSITION_UNCLIPPED_IBM}
+
+ // GL_HP_texture_lighting
+ GL_TEXTURE_LIGHTING_MODE_HP = $8167;
+ {$EXTERNALSYM GL_TEXTURE_LIGHTING_MODE_HP}
+ GL_TEXTURE_POST_SPECULAR_HP = $8168;
+ {$EXTERNALSYM GL_TEXTURE_POST_SPECULAR_HP}
+ GL_TEXTURE_PRE_SPECULAR_HP = $8169;
+ {$EXTERNALSYM GL_TEXTURE_PRE_SPECULAR_HP}
+
+ // GL_EXT_draw_range_elements
+ GL_MAX_ELEMENTS_VERTICES_EXT = $80E8;
+ {$EXTERNALSYM GL_MAX_ELEMENTS_VERTICES_EXT}
+ GL_MAX_ELEMENTS_INDICES_EXT = $80E9;
+ {$EXTERNALSYM GL_MAX_ELEMENTS_INDICES_EXT}
+
+ // GL_WIN_phong_shading
+ GL_PHONG_WIN = $80EA;
+ {$EXTERNALSYM GL_PHONG_WIN}
+ GL_PHONG_HINT_WIN = $80EB;
+ {$EXTERNALSYM GL_PHONG_HINT_WIN}
+
+ // GL_WIN_specular_fog
+ GL_FOG_SPECULAR_TEXTURE_WIN = $80EC;
+ {$EXTERNALSYM GL_FOG_SPECULAR_TEXTURE_WIN}
+
+ // GL_EXT_light_texture
+ GL_FRAGMENT_MATERIAL_EXT = $8349;
+ {$EXTERNALSYM GL_FRAGMENT_MATERIAL_EXT}
+ GL_FRAGMENT_NORMAL_EXT = $834A;
+ {$EXTERNALSYM GL_FRAGMENT_NORMAL_EXT}
+ GL_FRAGMENT_COLOR_EXT = $834C;
+ {$EXTERNALSYM GL_FRAGMENT_COLOR_EXT}
+ GL_ATTENUATION_EXT = $834D;
+ {$EXTERNALSYM GL_ATTENUATION_EXT}
+ GL_SHADOW_ATTENUATION_EXT = $834E;
+ {$EXTERNALSYM GL_SHADOW_ATTENUATION_EXT}
+ GL_TEXTURE_APPLICATION_MODE_EXT = $834F;
+ {$EXTERNALSYM GL_TEXTURE_APPLICATION_MODE_EXT}
+ GL_TEXTURE_LIGHT_EXT = $8350;
+ {$EXTERNALSYM GL_TEXTURE_LIGHT_EXT}
+ GL_TEXTURE_MATERIAL_FACE_EXT = $8351;
+ {$EXTERNALSYM GL_TEXTURE_MATERIAL_FACE_EXT}
+ GL_TEXTURE_MATERIAL_PARAMETER_EXT = $8352;
+ {$EXTERNALSYM GL_TEXTURE_MATERIAL_PARAMETER_EXT}
+
+ // GL_SGIX_blend_alpha_minmax
+ GL_ALPHA_MIN_SGIX = $8320;
+ {$EXTERNALSYM GL_ALPHA_MIN_SGIX}
+ GL_ALPHA_MAX_SGIX = $8321;
+ {$EXTERNALSYM GL_ALPHA_MAX_SGIX}
+
+ // GL_SGIX_async
+ GL_ASYNC_MARKER_SGIX = $8329;
+ {$EXTERNALSYM GL_ASYNC_MARKER_SGIX}
+
+ // GL_SGIX_async_pixel
+ GL_ASYNC_TEX_IMAGE_SGIX = $835C;
+ {$EXTERNALSYM GL_ASYNC_TEX_IMAGE_SGIX}
+ GL_ASYNC_DRAW_PIXELS_SGIX = $835D;
+ {$EXTERNALSYM GL_ASYNC_DRAW_PIXELS_SGIX}
+ GL_ASYNC_READ_PIXELS_SGIX = $835E;
+ {$EXTERNALSYM GL_ASYNC_READ_PIXELS_SGIX}
+ GL_MAX_ASYNC_TEX_IMAGE_SGIX = $835F;
+ {$EXTERNALSYM GL_MAX_ASYNC_TEX_IMAGE_SGIX}
+ GL_MAX_ASYNC_DRAW_PIXELS_SGIX = $8360;
+ {$EXTERNALSYM GL_MAX_ASYNC_DRAW_PIXELS_SGIX}
+ GL_MAX_ASYNC_READ_PIXELS_SGIX = $8361;
+ {$EXTERNALSYM GL_MAX_ASYNC_READ_PIXELS_SGIX}
+
+ // GL_SGIX_async_histogram
+ GL_ASYNC_HISTOGRAM_SGIX = $832C;
+ {$EXTERNALSYM GL_ASYNC_HISTOGRAM_SGIX}
+ GL_MAX_ASYNC_HISTOGRAM_SGIX = $832D;
+ {$EXTERNALSYM GL_MAX_ASYNC_HISTOGRAM_SGIX}
+
+ // GL_INTEL_parallel_arrays
+ GL_PARALLEL_ARRAYS_INTEL = $83F4;
+ {$EXTERNALSYM GL_PARALLEL_ARRAYS_INTEL}
+ GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL = $83F5;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL}
+ GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL = $83F6;
+ {$EXTERNALSYM GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL}
+ GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL = $83F7;
+ {$EXTERNALSYM GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL}
+ GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL = $83F8;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL}
+
+ // GL_HP_occlusion_test
+ GL_OCCLUSION_TEST_HP = $8165;
+ {$EXTERNALSYM GL_OCCLUSION_TEST_HP}
+ GL_OCCLUSION_TEST_RESULT_HP = $8166;
+ {$EXTERNALSYM GL_OCCLUSION_TEST_RESULT_HP}
+
+ // GL_EXT_pixel_transform
+ GL_PIXEL_TRANSFORM_2D_EXT = $8330;
+ {$EXTERNALSYM GL_PIXEL_TRANSFORM_2D_EXT}
+ GL_PIXEL_MAG_FILTER_EXT = $8331;
+ {$EXTERNALSYM GL_PIXEL_MAG_FILTER_EXT}
+ GL_PIXEL_MIN_FILTER_EXT = $8332;
+ {$EXTERNALSYM GL_PIXEL_MIN_FILTER_EXT}
+ GL_PIXEL_CUBIC_WEIGHT_EXT = $8333;
+ {$EXTERNALSYM GL_PIXEL_CUBIC_WEIGHT_EXT}
+ GL_CUBIC_EXT = $8334;
+ {$EXTERNALSYM GL_CUBIC_EXT}
+ GL_AVERAGE_EXT = $8335;
+ {$EXTERNALSYM GL_AVERAGE_EXT}
+ GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT = $8336;
+ {$EXTERNALSYM GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT}
+ GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT = $8337;
+ {$EXTERNALSYM GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT}
+ GL_PIXEL_TRANSFORM_2D_MATRIX_EXT = $8338;
+ {$EXTERNALSYM GL_PIXEL_TRANSFORM_2D_MATRIX_EXT}
+
+ // GL_EXT_separate_specular_color
+ GL_LIGHT_MODEL_COLOR_CONTROL_EXT = $81F8;
+ {$EXTERNALSYM GL_LIGHT_MODEL_COLOR_CONTROL_EXT}
+ GL_SINGLE_COLOR_EXT = $81F9;
+ {$EXTERNALSYM GL_SINGLE_COLOR_EXT}
+ GL_SEPARATE_SPECULAR_COLOR_EXT = $81FA;
+ {$EXTERNALSYM GL_SEPARATE_SPECULAR_COLOR_EXT}
+
+ // GL_EXT_secondary_color
+ GL_COLOR_SUM_EXT = $8458;
+ {$EXTERNALSYM GL_COLOR_SUM_EXT}
+ GL_CURRENT_SECONDARY_COLOR_EXT = $8459;
+ {$EXTERNALSYM GL_CURRENT_SECONDARY_COLOR_EXT}
+ GL_SECONDARY_COLOR_ARRAY_SIZE_EXT = $845A;
+ {$EXTERNALSYM GL_SECONDARY_COLOR_ARRAY_SIZE_EXT}
+ GL_SECONDARY_COLOR_ARRAY_TYPE_EXT = $845B;
+ {$EXTERNALSYM GL_SECONDARY_COLOR_ARRAY_TYPE_EXT}
+ GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT = $845C;
+ {$EXTERNALSYM GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT}
+ GL_SECONDARY_COLOR_ARRAY_POINTER_EXT = $845D;
+ {$EXTERNALSYM GL_SECONDARY_COLOR_ARRAY_POINTER_EXT}
+ GL_SECONDARY_COLOR_ARRAY_EXT = $845E;
+ {$EXTERNALSYM GL_SECONDARY_COLOR_ARRAY_EXT}
+
+ // GL_EXT_texture_perturb_normal
+ GL_PERTURB_EXT = $85AE;
+ {$EXTERNALSYM GL_PERTURB_EXT}
+ GL_TEXTURE_NORMAL_EXT = $85AF;
+ {$EXTERNALSYM GL_TEXTURE_NORMAL_EXT}
+
+ // GL_EXT_fog_coord
+ GL_FOG_COORDINATE_SOURCE_EXT = $8450;
+ {$EXTERNALSYM GL_FOG_COORDINATE_SOURCE_EXT}
+ GL_FOG_COORDINATE_EXT = $8451;
+ {$EXTERNALSYM GL_FOG_COORDINATE_EXT}
+ GL_FRAGMENT_DEPTH_EXT = $8452;
+ {$EXTERNALSYM GL_FRAGMENT_DEPTH_EXT}
+ GL_CURRENT_FOG_COORDINATE_EXT = $8453;
+ {$EXTERNALSYM GL_CURRENT_FOG_COORDINATE_EXT}
+ GL_FOG_COORDINATE_ARRAY_TYPE_EXT = $8454;
+ {$EXTERNALSYM GL_FOG_COORDINATE_ARRAY_TYPE_EXT}
+ GL_FOG_COORDINATE_ARRAY_STRIDE_EXT = $8455;
+ {$EXTERNALSYM GL_FOG_COORDINATE_ARRAY_STRIDE_EXT}
+ GL_FOG_COORDINATE_ARRAY_POINTER_EXT = $8456;
+ {$EXTERNALSYM GL_FOG_COORDINATE_ARRAY_POINTER_EXT}
+ GL_FOG_COORDINATE_ARRAY_EXT = $8457;
+ {$EXTERNALSYM GL_FOG_COORDINATE_ARRAY_EXT}
+
+ // GL_REND_screen_coordinates
+ GL_SCREEN_COORDINATES_REND = $8490;
+ {$EXTERNALSYM GL_SCREEN_COORDINATES_REND}
+ GL_INVERTED_SCREEN_W_REND = $8491;
+ {$EXTERNALSYM GL_INVERTED_SCREEN_W_REND}
+
+ // GL_EXT_coordinate_frame
+ GL_TANGENT_ARRAY_EXT = $8439;
+ {$EXTERNALSYM GL_TANGENT_ARRAY_EXT}
+ GL_BINORMAL_ARRAY_EXT = $843A;
+ {$EXTERNALSYM GL_BINORMAL_ARRAY_EXT}
+ GL_CURRENT_TANGENT_EXT = $843B;
+ {$EXTERNALSYM GL_CURRENT_TANGENT_EXT}
+ GL_CURRENT_BINORMAL_EXT = $843C;
+ {$EXTERNALSYM GL_CURRENT_BINORMAL_EXT}
+ GL_TANGENT_ARRAY_TYPE_EXT = $843E;
+ {$EXTERNALSYM GL_TANGENT_ARRAY_TYPE_EXT}
+ GL_TANGENT_ARRAY_STRIDE_EXT = $843F;
+ {$EXTERNALSYM GL_TANGENT_ARRAY_STRIDE_EXT}
+ GL_BINORMAL_ARRAY_TYPE_EXT = $8440;
+ {$EXTERNALSYM GL_BINORMAL_ARRAY_TYPE_EXT}
+ GL_BINORMAL_ARRAY_STRIDE_EXT = $8441;
+ {$EXTERNALSYM GL_BINORMAL_ARRAY_STRIDE_EXT}
+ GL_TANGENT_ARRAY_POINTER_EXT = $8442;
+ {$EXTERNALSYM GL_TANGENT_ARRAY_POINTER_EXT}
+ GL_BINORMAL_ARRAY_POINTER_EXT = $8443;
+ {$EXTERNALSYM GL_BINORMAL_ARRAY_POINTER_EXT}
+ GL_MAP1_TANGENT_EXT = $8444;
+ {$EXTERNALSYM GL_MAP1_TANGENT_EXT}
+ GL_MAP2_TANGENT_EXT = $8445;
+ {$EXTERNALSYM GL_MAP2_TANGENT_EXT}
+ GL_MAP1_BINORMAL_EXT = $8446;
+ {$EXTERNALSYM GL_MAP1_BINORMAL_EXT}
+ GL_MAP2_BINORMAL_EXT = $8447;
+ {$EXTERNALSYM GL_MAP2_BINORMAL_EXT}
+
+ // GL_EXT_texture_env_combine
+ GL_SOURCE3_RGB_EXT = $8583;
+ {$EXTERNALSYM GL_SOURCE3_RGB_EXT}
+ GL_SOURCE4_RGB_EXT = $8584;
+ {$EXTERNALSYM GL_SOURCE4_RGB_EXT}
+ GL_SOURCE5_RGB_EXT = $8585;
+ {$EXTERNALSYM GL_SOURCE5_RGB_EXT}
+ GL_SOURCE6_RGB_EXT = $8586;
+ {$EXTERNALSYM GL_SOURCE6_RGB_EXT}
+ GL_SOURCE7_RGB_EXT = $8587;
+ {$EXTERNALSYM GL_SOURCE7_RGB_EXT}
+ GL_SOURCE3_ALPHA_EXT = $858B;
+ {$EXTERNALSYM GL_SOURCE3_ALPHA_EXT}
+ GL_SOURCE4_ALPHA_EXT = $858C;
+ {$EXTERNALSYM GL_SOURCE4_ALPHA_EXT}
+ GL_SOURCE5_ALPHA_EXT = $858D;
+ {$EXTERNALSYM GL_SOURCE5_ALPHA_EXT}
+ GL_SOURCE6_ALPHA_EXT = $858E;
+ {$EXTERNALSYM GL_SOURCE6_ALPHA_EXT}
+ GL_SOURCE7_ALPHA_EXT = $858F;
+ {$EXTERNALSYM GL_SOURCE7_ALPHA_EXT}
+ GL_OPERAND3_RGB_EXT = $8593;
+ {$EXTERNALSYM GL_OPERAND3_RGB_EXT}
+ GL_OPERAND4_RGB_EXT = $8594;
+ {$EXTERNALSYM GL_OPERAND4_RGB_EXT}
+ GL_OPERAND5_RGB_EXT = $8595;
+ {$EXTERNALSYM GL_OPERAND5_RGB_EXT}
+ GL_OPERAND6_RGB_EXT = $8596;
+ {$EXTERNALSYM GL_OPERAND6_RGB_EXT}
+ GL_OPERAND7_RGB_EXT = $8597;
+ {$EXTERNALSYM GL_OPERAND7_RGB_EXT}
+ GL_OPERAND3_ALPHA_EXT = $859B;
+ {$EXTERNALSYM GL_OPERAND3_ALPHA_EXT}
+ GL_OPERAND4_ALPHA_EXT = $859C;
+ {$EXTERNALSYM GL_OPERAND4_ALPHA_EXT}
+ GL_OPERAND5_ALPHA_EXT = $859D;
+ {$EXTERNALSYM GL_OPERAND5_ALPHA_EXT}
+ GL_OPERAND6_ALPHA_EXT = $859E;
+ {$EXTERNALSYM GL_OPERAND6_ALPHA_EXT}
+ GL_OPERAND7_ALPHA_EXT = $859F;
+ {$EXTERNALSYM GL_OPERAND7_ALPHA_EXT}
+
+ // GL_APPLE_specular_vector
+ GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE = $85B0;
+ {$EXTERNALSYM GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE}
+
+ // GL_APPLE_transform_hint
+ GL_TRANSFORM_HINT_APPLE = $85B1;
+ {$EXTERNALSYM GL_TRANSFORM_HINT_APPLE}
+
+ // GL_SGIX_fog_scale
+ GL_FOG_SCALE_SGIX = $81FC;
+ {$EXTERNALSYM GL_FOG_SCALE_SGIX}
+ GL_FOG_SCALE_VALUE_SGIX = $81FD;
+ {$EXTERNALSYM GL_FOG_SCALE_VALUE_SGIX}
+
+ // GL_SUNX_constant_data
+ GL_UNPACK_CONSTANT_DATA_SUNX = $81D5;
+ {$EXTERNALSYM GL_UNPACK_CONSTANT_DATA_SUNX}
+ GL_TEXTURE_CONSTANT_DATA_SUNX = $81D6;
+ {$EXTERNALSYM GL_TEXTURE_CONSTANT_DATA_SUNX}
+
+ // GL_SUN_global_alpha
+ GL_GLOBAL_ALPHA_SUN = $81D9;
+ {$EXTERNALSYM GL_GLOBAL_ALPHA_SUN}
+ GL_GLOBAL_ALPHA_FACTOR_SUN = $81DA;
+ {$EXTERNALSYM GL_GLOBAL_ALPHA_FACTOR_SUN}
+
+ // GL_SUN_triangle_list
+ GL_RESTART_SUN = $01;
+ {$EXTERNALSYM GL_RESTART_SUN}
+ GL_REPLACE_MIDDLE_SUN = $02;
+ {$EXTERNALSYM GL_REPLACE_MIDDLE_SUN}
+ GL_REPLACE_OLDEST_SUN = $03;
+ {$EXTERNALSYM GL_REPLACE_OLDEST_SUN}
+ GL_TRIANGLE_LIST_SUN = $81D7;
+ {$EXTERNALSYM GL_TRIANGLE_LIST_SUN}
+ GL_REPLACEMENT_CODE_SUN = $81D8;
+ {$EXTERNALSYM GL_REPLACEMENT_CODE_SUN}
+ GL_REPLACEMENT_CODE_ARRAY_SUN = $85C0;
+ {$EXTERNALSYM GL_REPLACEMENT_CODE_ARRAY_SUN}
+ GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN = $85C1;
+ {$EXTERNALSYM GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN}
+ GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN = $85C2;
+ {$EXTERNALSYM GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN}
+ GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN = $85C3;
+ {$EXTERNALSYM GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN}
+ GL_R1UI_V3F_SUN = $85C4;
+ {$EXTERNALSYM GL_R1UI_V3F_SUN}
+ GL_R1UI_C4UB_V3F_SUN = $85C5;
+ {$EXTERNALSYM GL_R1UI_C4UB_V3F_SUN}
+ GL_R1UI_C3F_V3F_SUN = $85C6;
+ {$EXTERNALSYM GL_R1UI_C3F_V3F_SUN}
+ GL_R1UI_N3F_V3F_SUN = $85C7;
+ {$EXTERNALSYM GL_R1UI_N3F_V3F_SUN}
+ GL_R1UI_C4F_N3F_V3F_SUN = $85C8;
+ {$EXTERNALSYM GL_R1UI_C4F_N3F_V3F_SUN}
+ GL_R1UI_T2F_V3F_SUN = $85C9;
+ {$EXTERNALSYM GL_R1UI_T2F_V3F_SUN}
+ GL_R1UI_T2F_N3F_V3F_SUN = $85CA;
+ {$EXTERNALSYM GL_R1UI_T2F_N3F_V3F_SUN}
+ GL_R1UI_T2F_C4F_N3F_V3F_SUN = $85CB;
+ {$EXTERNALSYM GL_R1UI_T2F_C4F_N3F_V3F_SUN}
+
+ // GL_EXT_blend_func_separate
+ GL_BLEND_DST_RGB_EXT = $80C8;
+ {$EXTERNALSYM GL_BLEND_DST_RGB_EXT}
+ GL_BLEND_SRC_RGB_EXT = $80C9;
+ {$EXTERNALSYM GL_BLEND_SRC_RGB_EXT}
+ GL_BLEND_DST_ALPHA_EXT = $80CA;
+ {$EXTERNALSYM GL_BLEND_DST_ALPHA_EXT}
+ GL_BLEND_SRC_ALPHA_EXT = $80CB;
+ {$EXTERNALSYM GL_BLEND_SRC_ALPHA_EXT}
+
+ // GL_INGR_color_clamp
+ GL_RED_MIN_CLAMP_INGR = $8560;
+ {$EXTERNALSYM GL_RED_MIN_CLAMP_INGR}
+ GL_GREEN_MIN_CLAMP_INGR = $8561;
+ {$EXTERNALSYM GL_GREEN_MIN_CLAMP_INGR}
+ GL_BLUE_MIN_CLAMP_INGR = $8562;
+ {$EXTERNALSYM GL_BLUE_MIN_CLAMP_INGR}
+ GL_ALPHA_MIN_CLAMP_INGR = $8563;
+ {$EXTERNALSYM GL_ALPHA_MIN_CLAMP_INGR}
+ GL_RED_MAX_CLAMP_INGR = $8564;
+ {$EXTERNALSYM GL_RED_MAX_CLAMP_INGR}
+ GL_GREEN_MAX_CLAMP_INGR = $8565;
+ {$EXTERNALSYM GL_GREEN_MAX_CLAMP_INGR}
+ GL_BLUE_MAX_CLAMP_INGR = $8566;
+ {$EXTERNALSYM GL_BLUE_MAX_CLAMP_INGR}
+ GL_ALPHA_MAX_CLAMP_INGR = $8567;
+ {$EXTERNALSYM GL_ALPHA_MAX_CLAMP_INGR}
+
+ // GL_INGR_interlace_read
+ GL_INTERLACE_READ_INGR = $8568;
+ {$EXTERNALSYM GL_INTERLACE_READ_INGR}
+
+ // GL_EXT_422_pixels
+ GL_422_EXT = $80CC;
+ {$EXTERNALSYM GL_422_EXT}
+ GL_422_REV_EXT = $80CD;
+ {$EXTERNALSYM GL_422_REV_EXT}
+ GL_422_AVERAGE_EXT = $80CE;
+ {$EXTERNALSYM GL_422_AVERAGE_EXT}
+ GL_422_REV_AVERAGE_EXT = $80CF;
+ {$EXTERNALSYM GL_422_REV_AVERAGE_EXT}
+
+ // GL_EXT_texture_cube_map
+ GL_NORMAL_MAP_EXT = $8511;
+ {$EXTERNALSYM GL_NORMAL_MAP_EXT}
+ GL_REFLECTION_MAP_EXT = $8512;
+ {$EXTERNALSYM GL_REFLECTION_MAP_EXT}
+ GL_TEXTURE_CUBE_MAP_EXT = $8513;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_EXT}
+ GL_TEXTURE_BINDING_CUBE_MAP_EXT = $8514;
+ {$EXTERNALSYM GL_TEXTURE_BINDING_CUBE_MAP_EXT}
+ GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT = $8515;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT}
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT = $8516;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT}
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT = $8517;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT}
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT = $8518;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT}
+ GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT = $8519;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT}
+ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT = $851A;
+ {$EXTERNALSYM GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT}
+ GL_PROXY_TEXTURE_CUBE_MAP_EXT = $851B;
+ {$EXTERNALSYM GL_PROXY_TEXTURE_CUBE_MAP_EXT}
+ GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT = $851C;
+ {$EXTERNALSYM GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT}
+
+ // GL_SUN_convolution_border_modes
+ GL_WRAP_BORDER_SUN = $81D4;
+ {$EXTERNALSYM GL_WRAP_BORDER_SUN}
+
+ // GL_EXT_texture_lod_bias
+ GL_MAX_TEXTURE_LOD_BIAS_EXT = $84FD;
+ {$EXTERNALSYM GL_MAX_TEXTURE_LOD_BIAS_EXT}
+ GL_TEXTURE_FILTER_CONTROL_EXT = $8500;
+ {$EXTERNALSYM GL_TEXTURE_FILTER_CONTROL_EXT}
+ GL_TEXTURE_LOD_BIAS_EXT = $8501;
+ {$EXTERNALSYM GL_TEXTURE_LOD_BIAS_EXT}
+
+ // GL_EXT_texture_filter_anisotropic
+ GL_TEXTURE_MAX_ANISOTROPY_EXT = $84FE;
+ {$EXTERNALSYM GL_TEXTURE_MAX_ANISOTROPY_EXT}
+ GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = $84FF;
+ {$EXTERNALSYM GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT}
+
+ // GL_EXT_vertex_weighting
+ GL_MODELVIEW0_STACK_DEPTH_EXT = GL_MODELVIEW_STACK_DEPTH;
+ {$EXTERNALSYM GL_MODELVIEW0_STACK_DEPTH_EXT}
+ GL_MODELVIEW1_STACK_DEPTH_EXT = $8502;
+ {$EXTERNALSYM GL_MODELVIEW1_STACK_DEPTH_EXT}
+ GL_MODELVIEW0_MATRIX_EXT = GL_MODELVIEW_MATRIX;
+ {$EXTERNALSYM GL_MODELVIEW0_MATRIX_EXT}
+ GL_MODELVIEW_MATRIX1_EXT = $8506;
+ {$EXTERNALSYM GL_MODELVIEW_MATRIX1_EXT}
+ GL_VERTEX_WEIGHTING_EXT = $8509;
+ {$EXTERNALSYM GL_VERTEX_WEIGHTING_EXT}
+ GL_MODELVIEW0_EXT = GL_MODELVIEW;
+ {$EXTERNALSYM GL_MODELVIEW0_EXT}
+ GL_MODELVIEW1_EXT = $850A;
+ {$EXTERNALSYM GL_MODELVIEW1_EXT}
+ GL_CURRENT_VERTEX_WEIGHT_EXT = $850B;
+ {$EXTERNALSYM GL_CURRENT_VERTEX_WEIGHT_EXT}
+ GL_VERTEX_WEIGHT_ARRAY_EXT = $850C;
+ {$EXTERNALSYM GL_VERTEX_WEIGHT_ARRAY_EXT}
+ GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT = $850D;
+ {$EXTERNALSYM GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT}
+ GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT = $850E;
+ {$EXTERNALSYM GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT}
+ GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT = $850F;
+ {$EXTERNALSYM GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT}
+ GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT = $8510;
+ {$EXTERNALSYM GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT}
+
+ // GL_NV_light_max_exponent
+ GL_MAX_SHININESS_NV = $8504;
+ {$EXTERNALSYM GL_MAX_SHININESS_NV}
+ GL_MAX_SPOT_EXPONENT_NV = $8505;
+ {$EXTERNALSYM GL_MAX_SPOT_EXPONENT_NV}
+
+ // GL_NV_vertex_array_range
+ GL_VERTEX_ARRAY_RANGE_NV = $851D;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_RANGE_NV}
+ GL_VERTEX_ARRAY_RANGE_LENGTH_NV = $851E;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_RANGE_LENGTH_NV}
+ GL_VERTEX_ARRAY_RANGE_VALID_NV = $851F;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_RANGE_VALID_NV}
+ GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV = $8520;
+ {$EXTERNALSYM GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV}
+ GL_VERTEX_ARRAY_RANGE_POINTER_NV = $8521;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_RANGE_POINTER_NV}
+
+ // GL_NV_register_combiners
+ GL_REGISTER_COMBINERS_NV = $8522;
+ {$EXTERNALSYM GL_REGISTER_COMBINERS_NV}
+ GL_VARIABLE_A_NV = $8523;
+ {$EXTERNALSYM GL_VARIABLE_A_NV}
+ GL_VARIABLE_B_NV = $8524;
+ {$EXTERNALSYM GL_VARIABLE_B_NV}
+ GL_VARIABLE_C_NV = $8525;
+ {$EXTERNALSYM GL_VARIABLE_C_NV}
+ GL_VARIABLE_D_NV = $8526;
+ {$EXTERNALSYM GL_VARIABLE_D_NV}
+ GL_VARIABLE_E_NV = $8527;
+ {$EXTERNALSYM GL_VARIABLE_E_NV}
+ GL_VARIABLE_F_NV = $8528;
+ {$EXTERNALSYM GL_VARIABLE_F_NV}
+ GL_VARIABLE_G_NV = $8529;
+ {$EXTERNALSYM GL_VARIABLE_G_NV}
+ GL_CONSTANT_COLOR0_NV = $852A;
+ {$EXTERNALSYM GL_CONSTANT_COLOR0_NV}
+ GL_CONSTANT_COLOR1_NV = $852B;
+ {$EXTERNALSYM GL_CONSTANT_COLOR1_NV}
+ GL_PRIMARY_COLOR_NV = $852C;
+ {$EXTERNALSYM GL_PRIMARY_COLOR_NV}
+ GL_SECONDARY_COLOR_NV = $852D;
+ {$EXTERNALSYM GL_SECONDARY_COLOR_NV}
+ GL_SPARE0_NV = $852E;
+ {$EXTERNALSYM GL_SPARE0_NV}
+ GL_SPARE1_NV = $852F;
+ {$EXTERNALSYM GL_SPARE1_NV}
+ GL_DISCARD_NV = $8530;
+ {$EXTERNALSYM GL_DISCARD_NV}
+ GL_E_TIMES_F_NV = $8531;
+ {$EXTERNALSYM GL_E_TIMES_F_NV}
+ GL_SPARE0_PLUS_SECONDARY_COLOR_NV = $8532;
+ {$EXTERNALSYM GL_SPARE0_PLUS_SECONDARY_COLOR_NV}
+ GL_UNSIGNED_IDENTITY_NV = $8536;
+ {$EXTERNALSYM GL_UNSIGNED_IDENTITY_NV}
+ GL_UNSIGNED_INVERT_NV = $8537;
+ {$EXTERNALSYM GL_UNSIGNED_INVERT_NV}
+ GL_EXPAND_NORMAL_NV = $8538;
+ {$EXTERNALSYM GL_EXPAND_NORMAL_NV}
+ GL_EXPAND_NEGATE_NV = $8539;
+ {$EXTERNALSYM GL_EXPAND_NEGATE_NV}
+ GL_HALF_BIAS_NORMAL_NV = $853A;
+ {$EXTERNALSYM GL_HALF_BIAS_NORMAL_NV}
+ GL_HALF_BIAS_NEGATE_NV = $853B;
+ {$EXTERNALSYM GL_HALF_BIAS_NEGATE_NV}
+ GL_SIGNED_IDENTITY_NV = $853C;
+ {$EXTERNALSYM GL_SIGNED_IDENTITY_NV}
+ GL_SIGNED_NEGATE_NV = $853D;
+ {$EXTERNALSYM GL_SIGNED_NEGATE_NV}
+ GL_SCALE_BY_TWO_NV = $853E;
+ {$EXTERNALSYM GL_SCALE_BY_TWO_NV}
+ GL_SCALE_BY_FOUR_NV = $853F;
+ {$EXTERNALSYM GL_SCALE_BY_FOUR_NV}
+ GL_SCALE_BY_ONE_HALF_NV = $8540;
+ {$EXTERNALSYM GL_SCALE_BY_ONE_HALF_NV}
+ GL_BIAS_BY_NEGATIVE_ONE_HALF_NV = $8541;
+ {$EXTERNALSYM GL_BIAS_BY_NEGATIVE_ONE_HALF_NV}
+ GL_COMBINER_INPUT_NV = $8542;
+ {$EXTERNALSYM GL_COMBINER_INPUT_NV}
+ GL_COMBINER_MAPPING_NV = $8543;
+ {$EXTERNALSYM GL_COMBINER_MAPPING_NV}
+ GL_COMBINER_COMPONENT_USAGE_NV = $8544;
+ {$EXTERNALSYM GL_COMBINER_COMPONENT_USAGE_NV}
+ GL_COMBINER_AB_DOT_PRODUCT_NV = $8545;
+ {$EXTERNALSYM GL_COMBINER_AB_DOT_PRODUCT_NV}
+ GL_COMBINER_CD_DOT_PRODUCT_NV = $8546;
+ {$EXTERNALSYM GL_COMBINER_CD_DOT_PRODUCT_NV}
+ GL_COMBINER_MUX_SUM_NV = $8547;
+ {$EXTERNALSYM GL_COMBINER_MUX_SUM_NV}
+ GL_COMBINER_SCALE_NV = $8548;
+ {$EXTERNALSYM GL_COMBINER_SCALE_NV}
+ GL_COMBINER_BIAS_NV = $8549;
+ {$EXTERNALSYM GL_COMBINER_BIAS_NV}
+ GL_COMBINER_AB_OUTPUT_NV = $854A;
+ {$EXTERNALSYM GL_COMBINER_AB_OUTPUT_NV}
+ GL_COMBINER_CD_OUTPUT_NV = $854B;
+ {$EXTERNALSYM GL_COMBINER_CD_OUTPUT_NV}
+ GL_COMBINER_SUM_OUTPUT_NV = $854C;
+ {$EXTERNALSYM GL_COMBINER_SUM_OUTPUT_NV}
+ GL_MAX_GENERAL_COMBINERS_NV = $854D;
+ {$EXTERNALSYM GL_MAX_GENERAL_COMBINERS_NV}
+ GL_NUM_GENERAL_COMBINERS_NV = $854E;
+ {$EXTERNALSYM GL_NUM_GENERAL_COMBINERS_NV}
+ GL_COLOR_SUM_CLAMP_NV = $854F;
+ {$EXTERNALSYM GL_COLOR_SUM_CLAMP_NV}
+ GL_COMBINER0_NV = $8550;
+ {$EXTERNALSYM GL_COMBINER0_NV}
+ GL_COMBINER1_NV = $8551;
+ {$EXTERNALSYM GL_COMBINER1_NV}
+ GL_COMBINER2_NV = $8552;
+ {$EXTERNALSYM GL_COMBINER2_NV}
+ GL_COMBINER3_NV = $8553;
+ {$EXTERNALSYM GL_COMBINER3_NV}
+ GL_COMBINER4_NV = $8554;
+ {$EXTERNALSYM GL_COMBINER4_NV}
+ GL_COMBINER5_NV = $8555;
+ {$EXTERNALSYM GL_COMBINER5_NV}
+ GL_COMBINER6_NV = $8556;
+ {$EXTERNALSYM GL_COMBINER6_NV}
+ GL_COMBINER7_NV = $8557;
+ {$EXTERNALSYM GL_COMBINER7_NV}
+
+ // GL_NV_fog_distance
+ GL_FOG_DISTANCE_MODE_NV = $855A;
+ {$EXTERNALSYM GL_FOG_DISTANCE_MODE_NV}
+ GL_EYE_RADIAL_NV = $855B;
+ {$EXTERNALSYM GL_EYE_RADIAL_NV}
+ GL_EYE_PLANE_ABSOLUTE_NV = $855C;
+ {$EXTERNALSYM GL_EYE_PLANE_ABSOLUTE_NV}
+
+ // GL_NV_texgen_emboss
+ GL_EMBOSS_LIGHT_NV = $855D;
+ {$EXTERNALSYM GL_EMBOSS_LIGHT_NV}
+ GL_EMBOSS_CONSTANT_NV = $855E;
+ {$EXTERNALSYM GL_EMBOSS_CONSTANT_NV}
+ GL_EMBOSS_MAP_NV = $855F;
+ {$EXTERNALSYM GL_EMBOSS_MAP_NV}
+
+ // GL_EXT_texture_compression_s3tc
+ GL_COMPRESSED_RGB_S3TC_DXT1_EXT = $83F0;
+ {$EXTERNALSYM GL_COMPRESSED_RGB_S3TC_DXT1_EXT}
+ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = $83F1;
+ {$EXTERNALSYM GL_COMPRESSED_RGBA_S3TC_DXT1_EXT}
+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = $83F2;
+ {$EXTERNALSYM GL_COMPRESSED_RGBA_S3TC_DXT3_EXT}
+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = $83F3;
+ {$EXTERNALSYM GL_COMPRESSED_RGBA_S3TC_DXT5_EXT}
+
+ // GL_IBM_cull_vertex
+ GL_CULL_VERTEX_IBM = 103050;
+ {$EXTERNALSYM GL_CULL_VERTEX_IBM}
+
+ // GL_IBM_vertex_array_lists
+ GL_VERTEX_ARRAY_LIST_IBM = 103070;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_LIST_IBM}
+ GL_NORMAL_ARRAY_LIST_IBM = 103071;
+ {$EXTERNALSYM GL_NORMAL_ARRAY_LIST_IBM}
+ GL_COLOR_ARRAY_LIST_IBM = 103072;
+ {$EXTERNALSYM GL_COLOR_ARRAY_LIST_IBM}
+ GL_INDEX_ARRAY_LIST_IBM = 103073;
+ {$EXTERNALSYM GL_INDEX_ARRAY_LIST_IBM}
+ GL_TEXTURE_COORD_ARRAY_LIST_IBM = 103074;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_LIST_IBM}
+ GL_EDGE_FLAG_ARRAY_LIST_IBM = 103075;
+ {$EXTERNALSYM GL_EDGE_FLAG_ARRAY_LIST_IBM}
+ GL_FOG_COORDINATE_ARRAY_LIST_IBM = 103076;
+ {$EXTERNALSYM GL_FOG_COORDINATE_ARRAY_LIST_IBM}
+ GL_SECONDARY_COLOR_ARRAY_LIST_IBM = 103077;
+ {$EXTERNALSYM GL_SECONDARY_COLOR_ARRAY_LIST_IBM}
+ GL_VERTEX_ARRAY_LIST_STRIDE_IBM = 103080;
+ {$EXTERNALSYM GL_VERTEX_ARRAY_LIST_STRIDE_IBM}
+ GL_NORMAL_ARRAY_LIST_STRIDE_IBM = 103081;
+ {$EXTERNALSYM GL_NORMAL_ARRAY_LIST_STRIDE_IBM}
+ GL_COLOR_ARRAY_LIST_STRIDE_IBM = 103082;
+ {$EXTERNALSYM GL_COLOR_ARRAY_LIST_STRIDE_IBM}
+ GL_INDEX_ARRAY_LIST_STRIDE_IBM = 103083;
+ {$EXTERNALSYM GL_INDEX_ARRAY_LIST_STRIDE_IBM}
+ GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM = 103084;
+ {$EXTERNALSYM GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM}
+ GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM = 103085;
+ {$EXTERNALSYM GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM}
+ GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM = 103086;
+ {$EXTERNALSYM GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM}
+ GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM = 103087;
+ {$EXTERNALSYM GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM}
+
+ // GL_SGIX_subsample
+ GL_PACK_SUBSAMPLE_RATE_SGIX = $85A0;
+ {$EXTERNALSYM GL_PACK_SUBSAMPLE_RATE_SGIX}
+ GL_UNPACK_SUBSAMPLE_RATE_SGIX = $85A1;
+ {$EXTERNALSYM GL_UNPACK_SUBSAMPLE_RATE_SGIX}
+ GL_PIXEL_SUBSAMPLE_4444_SGIX = $85A2;
+ {$EXTERNALSYM GL_PIXEL_SUBSAMPLE_4444_SGIX}
+ GL_PIXEL_SUBSAMPLE_2424_SGIX = $85A3;
+ {$EXTERNALSYM GL_PIXEL_SUBSAMPLE_2424_SGIX}
+ GL_PIXEL_SUBSAMPLE_4242_SGIX = $85A4;
+ {$EXTERNALSYM GL_PIXEL_SUBSAMPLE_4242_SGIX}
+
+ // GL_SGIX_ycrcba
+ GL_YCRCB_SGIX = $8318;
+ {$EXTERNALSYM GL_YCRCB_SGIX}
+ GL_YCRCBA_SGIX = $8319;
+ {$EXTERNALSYM GL_YCRCBA_SGIX}
+
+ // GL_SGI_depth_pass_instrument
+ GL_DEPTH_PASS_INSTRUMENT_SGIX = $8310;
+ {$EXTERNALSYM GL_DEPTH_PASS_INSTRUMENT_SGIX}
+ GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX = $8311;
+ {$EXTERNALSYM GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX}
+ GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX = $8312;
+ {$EXTERNALSYM GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX}
+
+ // GL_3DFX_texture_compression_FXT1
+ GL_COMPRESSED_RGB_FXT1_3DFX = $86B0;
+ {$EXTERNALSYM GL_COMPRESSED_RGB_FXT1_3DFX}
+ GL_COMPRESSED_RGBA_FXT1_3DFX = $86B1;
+ {$EXTERNALSYM GL_COMPRESSED_RGBA_FXT1_3DFX}
+
+ // GL_3DFX_multisample
+ GL_MULTISAMPLE_3DFX = $86B2;
+ {$EXTERNALSYM GL_MULTISAMPLE_3DFX}
+ GL_SAMPLE_BUFFERS_3DFX = $86B3;
+ {$EXTERNALSYM GL_SAMPLE_BUFFERS_3DFX}
+ GL_SAMPLES_3DFX = $86B4;
+ {$EXTERNALSYM GL_SAMPLES_3DFX}
+ GL_MULTISAMPLE_BIT_3DFX = $20000000;
+ {$EXTERNALSYM GL_MULTISAMPLE_BIT_3DFX}
+
+ // GL_EXT_multisample
+ GL_MULTISAMPLE_EXT = $809D;
+ {$EXTERNALSYM GL_MULTISAMPLE_EXT}
+ GL_SAMPLE_ALPHA_TO_MASK_EXT = $809E;
+ {$EXTERNALSYM GL_SAMPLE_ALPHA_TO_MASK_EXT}
+ GL_SAMPLE_ALPHA_TO_ONE_EXT = $809F;
+ {$EXTERNALSYM GL_SAMPLE_ALPHA_TO_ONE_EXT}
+ GL_SAMPLE_MASK_EXT = $80A0;
+ {$EXTERNALSYM GL_SAMPLE_MASK_EXT}
+ GL_1PASS_EXT = $80A1;
+ {$EXTERNALSYM GL_1PASS_EXT}
+ GL_2PASS_0_EXT = $80A2;
+ {$EXTERNALSYM GL_2PASS_0_EXT}
+ GL_2PASS_1_EXT = $80A3;
+ {$EXTERNALSYM GL_2PASS_1_EXT}
+ GL_4PASS_0_EXT = $80A4;
+ {$EXTERNALSYM GL_4PASS_0_EXT}
+ GL_4PASS_1_EXT = $80A5;
+ {$EXTERNALSYM GL_4PASS_1_EXT}
+ GL_4PASS_2_EXT = $80A6;
+ {$EXTERNALSYM GL_4PASS_2_EXT}
+ GL_4PASS_3_EXT = $80A7;
+ {$EXTERNALSYM GL_4PASS_3_EXT}
+ GL_SAMPLE_BUFFERS_EXT = $80A8;
+ {$EXTERNALSYM GL_SAMPLE_BUFFERS_EXT}
+ GL_SAMPLES_EXT = $80A9;
+ {$EXTERNALSYM GL_SAMPLES_EXT}
+ GL_SAMPLE_MASK_VALUE_EXT = $80AA;
+ {$EXTERNALSYM GL_SAMPLE_MASK_VALUE_EXT}
+ GL_SAMPLE_MASK_INVERT_EXT = $80AB;
+ {$EXTERNALSYM GL_SAMPLE_MASK_INVERT_EXT}
+ GL_SAMPLE_PATTERN_EXT = $80AC;
+ {$EXTERNALSYM GL_SAMPLE_PATTERN_EXT}
+
+ // GL_SGIX_vertex_preclip
+ GL_VERTEX_PRECLIP_SGIX = $83EE;
+ {$EXTERNALSYM GL_VERTEX_PRECLIP_SGIX}
+ GL_VERTEX_PRECLIP_HINT_SGIX = $83EF;
+ {$EXTERNALSYM GL_VERTEX_PRECLIP_HINT_SGIX}
+
+ // GL_SGIX_convolution_accuracy
+ GL_CONVOLUTION_HINT_SGIX = $8316;
+ {$EXTERNALSYM GL_CONVOLUTION_HINT_SGIX}
+
+ // GL_SGIX_resample
+ GL_PACK_RESAMPLE_SGIX = $842C;
+ {$EXTERNALSYM GL_PACK_RESAMPLE_SGIX}
+ GL_UNPACK_RESAMPLE_SGIX = $842D;
+ {$EXTERNALSYM GL_UNPACK_RESAMPLE_SGIX}
+ GL_RESAMPLE_REPLICATE_SGIX = $842E;
+ {$EXTERNALSYM GL_RESAMPLE_REPLICATE_SGIX}
+ GL_RESAMPLE_ZERO_FILL_SGIX = $842F;
+ {$EXTERNALSYM GL_RESAMPLE_ZERO_FILL_SGIX}
+ GL_RESAMPLE_DECIMATE_SGIX = $8430;
+ {$EXTERNALSYM GL_RESAMPLE_DECIMATE_SGIX}
+
+ // GL_SGIS_point_line_texgen
+ GL_EYE_DISTANCE_TO_POINT_SGIS = $81F0;
+ {$EXTERNALSYM GL_EYE_DISTANCE_TO_POINT_SGIS}
+ GL_OBJECT_DISTANCE_TO_POINT_SGIS = $81F1;
+ {$EXTERNALSYM GL_OBJECT_DISTANCE_TO_POINT_SGIS}
+ GL_EYE_DISTANCE_TO_LINE_SGIS = $81F2;
+ {$EXTERNALSYM GL_EYE_DISTANCE_TO_LINE_SGIS}
+ GL_OBJECT_DISTANCE_TO_LINE_SGIS = $81F3;
+ {$EXTERNALSYM GL_OBJECT_DISTANCE_TO_LINE_SGIS}
+ GL_EYE_POINT_SGIS = $81F4;
+ {$EXTERNALSYM GL_EYE_POINT_SGIS}
+ GL_OBJECT_POINT_SGIS = $81F5;
+ {$EXTERNALSYM GL_OBJECT_POINT_SGIS}
+ GL_EYE_LINE_SGIS = $81F6;
+ {$EXTERNALSYM GL_EYE_LINE_SGIS}
+ GL_OBJECT_LINE_SGIS = $81F7;
+ {$EXTERNALSYM GL_OBJECT_LINE_SGIS}
+
+ // GL_SGIS_texture_color_mask
+ GL_TEXTURE_COLOR_WRITEMASK_SGIS = $81EF;
+ {$EXTERNALSYM GL_TEXTURE_COLOR_WRITEMASK_SGIS}
+
+ // GL_NV_vertex_program
+ GL_VERTEX_PROGRAM_NV = $8620;
+ {$EXTERNALSYM GL_VERTEX_PROGRAM_NV}
+ GL_VERTEX_STATE_PROGRAM_NV = $8621;
+ {$EXTERNALSYM GL_VERTEX_STATE_PROGRAM_NV}
+ GL_ATTRIB_ARRAY_SIZE_NV = $8623;
+ {$EXTERNALSYM GL_ATTRIB_ARRAY_SIZE_NV}
+ GL_ATTRIB_ARRAY_STRIDE_NV = $8624;
+ {$EXTERNALSYM GL_ATTRIB_ARRAY_STRIDE_NV}
+ GL_ATTRIB_ARRAY_TYPE_NV = $8625;
+ {$EXTERNALSYM GL_ATTRIB_ARRAY_TYPE_NV}
+ GL_CURRENT_ATTRIB_NV = $8626;
+ {$EXTERNALSYM GL_CURRENT_ATTRIB_NV}
+ GL_PROGRAM_LENGTH_NV = $8627;
+ {$EXTERNALSYM GL_PROGRAM_LENGTH_NV}
+ GL_PROGRAM_STRING_NV = $8628;
+ {$EXTERNALSYM GL_PROGRAM_STRING_NV}
+ GL_MODELVIEW_PROJECTION_NV = $8629;
+ {$EXTERNALSYM GL_MODELVIEW_PROJECTION_NV}
+ GL_IDENTITY_NV = $862A;
+ {$EXTERNALSYM GL_IDENTITY_NV}
+ GL_INVERSE_NV = $862B;
+ {$EXTERNALSYM GL_INVERSE_NV}
+ GL_TRANSPOSE_NV = $862C;
+ {$EXTERNALSYM GL_TRANSPOSE_NV}
+ GL_INVERSE_TRANSPOSE_NV = $862D;
+ {$EXTERNALSYM GL_INVERSE_TRANSPOSE_NV}
+ GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV = $862E;
+ {$EXTERNALSYM GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV}
+ GL_MAX_TRACK_MATRICES_NV = $862F;
+ {$EXTERNALSYM GL_MAX_TRACK_MATRICES_NV}
+ GL_MATRIX0_NV = $8630;
+ {$EXTERNALSYM GL_MATRIX0_NV}
+ GL_MATRIX1_NV = $8631;
+ {$EXTERNALSYM GL_MATRIX1_NV}
+ GL_MATRIX2_NV = $8632;
+ {$EXTERNALSYM GL_MATRIX2_NV}
+ GL_MATRIX3_NV = $8633;
+ {$EXTERNALSYM GL_MATRIX3_NV}
+ GL_MATRIX4_NV = $8634;
+ {$EXTERNALSYM GL_MATRIX4_NV}
+ GL_MATRIX5_NV = $8635;
+ {$EXTERNALSYM GL_MATRIX5_NV}
+ GL_MATRIX6_NV = $8636;
+ {$EXTERNALSYM GL_MATRIX6_NV}
+ GL_MATRIX7_NV = $8637;
+ {$EXTERNALSYM GL_MATRIX7_NV}
+ GL_CURRENT_MATRIX_STACK_DEPTH_NV = $8640;
+ {$EXTERNALSYM GL_CURRENT_MATRIX_STACK_DEPTH_NV}
+ GL_CURRENT_MATRIX_NV = $8641;
+ {$EXTERNALSYM GL_CURRENT_MATRIX_NV}
+ GL_VERTEX_PROGRAM_POINT_SIZE_NV = $8642;
+ {$EXTERNALSYM GL_VERTEX_PROGRAM_POINT_SIZE_NV}
+ GL_VERTEX_PROGRAM_TWO_SIDE_NV = $8643;
+ {$EXTERNALSYM GL_VERTEX_PROGRAM_TWO_SIDE_NV}
+ GL_PROGRAM_PARAMETER_NV = $8644;
+ {$EXTERNALSYM GL_PROGRAM_PARAMETER_NV}
+ GL_ATTRIB_ARRAY_POINTER_NV = $8645;
+ {$EXTERNALSYM GL_ATTRIB_ARRAY_POINTER_NV}
+ GL_PROGRAM_TARGET_NV = $8646;
+ {$EXTERNALSYM GL_PROGRAM_TARGET_NV}
+ GL_PROGRAM_RESIDENT_NV = $8647;
+ {$EXTERNALSYM GL_PROGRAM_RESIDENT_NV}
+ GL_TRACK_MATRIX_NV = $8648;
+ {$EXTERNALSYM GL_TRACK_MATRIX_NV}
+ GL_TRACK_MATRIX_TRANSFORM_NV = $8649;
+ {$EXTERNALSYM GL_TRACK_MATRIX_TRANSFORM_NV}
+ GL_VERTEX_PROGRAM_BINDING_NV = $864A;
+ {$EXTERNALSYM GL_VERTEX_PROGRAM_BINDING_NV}
+ GL_PROGRAM_ERROR_POSITION_NV = $864B;
+ {$EXTERNALSYM GL_PROGRAM_ERROR_POSITION_NV}
+ GL_VERTEX_ATTRIB_ARRAY0_NV = $8650;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY0_NV}
+ GL_VERTEX_ATTRIB_ARRAY1_NV = $8651;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY1_NV}
+ GL_VERTEX_ATTRIB_ARRAY2_NV = $8652;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY2_NV}
+ GL_VERTEX_ATTRIB_ARRAY3_NV = $8653;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY3_NV}
+ GL_VERTEX_ATTRIB_ARRAY4_NV = $8654;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY4_NV}
+ GL_VERTEX_ATTRIB_ARRAY5_NV = $8655;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY5_NV}
+ GL_VERTEX_ATTRIB_ARRAY6_NV = $8656;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY6_NV}
+ GL_VERTEX_ATTRIB_ARRAY7_NV = $8657;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY7_NV}
+ GL_VERTEX_ATTRIB_ARRAY8_NV = $8658;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY8_NV}
+ GL_VERTEX_ATTRIB_ARRAY9_NV = $8659;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY9_NV}
+ GL_VERTEX_ATTRIB_ARRAY10_NV = $865A;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY10_NV}
+ GL_VERTEX_ATTRIB_ARRAY11_NV = $865B;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY11_NV}
+ GL_VERTEX_ATTRIB_ARRAY12_NV = $865C;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY12_NV}
+ GL_VERTEX_ATTRIB_ARRAY13_NV = $865D;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY13_NV}
+ GL_VERTEX_ATTRIB_ARRAY14_NV = $865E;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY14_NV}
+ GL_VERTEX_ATTRIB_ARRAY15_NV = $865F;
+ {$EXTERNALSYM GL_VERTEX_ATTRIB_ARRAY15_NV}
+ GL_MAP1_VERTEX_ATTRIB0_4_NV = $8660;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB0_4_NV}
+ GL_MAP1_VERTEX_ATTRIB1_4_NV = $8661;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB1_4_NV}
+ GL_MAP1_VERTEX_ATTRIB2_4_NV = $8662;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB2_4_NV}
+ GL_MAP1_VERTEX_ATTRIB3_4_NV = $8663;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB3_4_NV}
+ GL_MAP1_VERTEX_ATTRIB4_4_NV = $8664;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB4_4_NV}
+ GL_MAP1_VERTEX_ATTRIB5_4_NV = $8665;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB5_4_NV}
+ GL_MAP1_VERTEX_ATTRIB6_4_NV = $8666;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB6_4_NV}
+ GL_MAP1_VERTEX_ATTRIB7_4_NV = $8667;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB7_4_NV}
+ GL_MAP1_VERTEX_ATTRIB8_4_NV = $8668;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB8_4_NV}
+ GL_MAP1_VERTEX_ATTRIB9_4_NV = $8669;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB9_4_NV}
+ GL_MAP1_VERTEX_ATTRIB10_4_NV = $866A;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB10_4_NV}
+ GL_MAP1_VERTEX_ATTRIB11_4_NV = $866B;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB11_4_NV}
+ GL_MAP1_VERTEX_ATTRIB12_4_NV = $866C;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB12_4_NV}
+ GL_MAP1_VERTEX_ATTRIB13_4_NV = $866D;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB13_4_NV}
+ GL_MAP1_VERTEX_ATTRIB14_4_NV = $866E;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB14_4_NV}
+ GL_MAP1_VERTEX_ATTRIB15_4_NV = $866F;
+ {$EXTERNALSYM GL_MAP1_VERTEX_ATTRIB15_4_NV}
+ GL_MAP2_VERTEX_ATTRIB0_4_NV = $8670;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB0_4_NV}
+ GL_MAP2_VERTEX_ATTRIB1_4_NV = $8671;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB1_4_NV}
+ GL_MAP2_VERTEX_ATTRIB2_4_NV = $8672;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB2_4_NV}
+ GL_MAP2_VERTEX_ATTRIB3_4_NV = $8673;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB3_4_NV}
+ GL_MAP2_VERTEX_ATTRIB4_4_NV = $8674;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB4_4_NV}
+ GL_MAP2_VERTEX_ATTRIB5_4_NV = $8675;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB5_4_NV}
+ GL_MAP2_VERTEX_ATTRIB6_4_NV = $8676;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB6_4_NV}
+ GL_MAP2_VERTEX_ATTRIB7_4_NV = $8677;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB7_4_NV}
+ GL_MAP2_VERTEX_ATTRIB8_4_NV = $8678;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB8_4_NV}
+ GL_MAP2_VERTEX_ATTRIB9_4_NV = $8679;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB9_4_NV}
+ GL_MAP2_VERTEX_ATTRIB10_4_NV = $867A;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB10_4_NV}
+ GL_MAP2_VERTEX_ATTRIB11_4_NV = $867B;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB11_4_NV}
+ GL_MAP2_VERTEX_ATTRIB12_4_NV = $867C;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB12_4_NV}
+ GL_MAP2_VERTEX_ATTRIB13_4_NV = $867D;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB13_4_NV}
+ GL_MAP2_VERTEX_ATTRIB14_4_NV = $867E;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB14_4_NV}
+ GL_MAP2_VERTEX_ATTRIB15_4_NV = $867F;
+ {$EXTERNALSYM GL_MAP2_VERTEX_ATTRIB15_4_NV}
+
+ // WGL_ARB_pixel_format
+ WGL_NUMBER_PIXEL_FORMATS_ARB = $2000;
+ {$EXTERNALSYM WGL_NUMBER_PIXEL_FORMATS_ARB}
+ WGL_DRAW_TO_WINDOW_ARB = $2001;
+ {$EXTERNALSYM WGL_DRAW_TO_WINDOW_ARB}
+ WGL_DRAW_TO_BITMAP_ARB = $2002;
+ {$EXTERNALSYM WGL_DRAW_TO_BITMAP_ARB}
+ WGL_ACCELERATION_ARB = $2003;
+ {$EXTERNALSYM WGL_ACCELERATION_ARB}
+ WGL_NEED_PALETTE_ARB = $2004;
+ {$EXTERNALSYM WGL_NEED_PALETTE_ARB}
+ WGL_NEED_SYSTEM_PALETTE_ARB = $2005;
+ {$EXTERNALSYM WGL_NEED_SYSTEM_PALETTE_ARB}
+ WGL_SWAP_LAYER_BUFFERS_ARB = $2006;
+ {$EXTERNALSYM WGL_SWAP_LAYER_BUFFERS_ARB}
+ WGL_SWAP_METHOD_ARB = $2007;
+ {$EXTERNALSYM WGL_SWAP_METHOD_ARB}
+ WGL_NUMBER_OVERLAYS_ARB = $2008;
+ {$EXTERNALSYM WGL_NUMBER_OVERLAYS_ARB}
+ WGL_NUMBER_UNDERLAYS_ARB = $2009;
+ {$EXTERNALSYM WGL_NUMBER_UNDERLAYS_ARB}
+ WGL_TRANSPARENT_ARB = $200A;
+ {$EXTERNALSYM WGL_TRANSPARENT_ARB}
+ WGL_TRANSPARENT_RED_VALUE_ARB = $2037;
+ {$EXTERNALSYM WGL_TRANSPARENT_RED_VALUE_ARB}
+ WGL_TRANSPARENT_GREEN_VALUE_ARB = $2038;
+ {$EXTERNALSYM WGL_TRANSPARENT_GREEN_VALUE_ARB}
+ WGL_TRANSPARENT_BLUE_VALUE_ARB = $2039;
+ {$EXTERNALSYM WGL_TRANSPARENT_BLUE_VALUE_ARB}
+ WGL_TRANSPARENT_ALPHA_VALUE_ARB = $203A;
+ {$EXTERNALSYM WGL_TRANSPARENT_ALPHA_VALUE_ARB}
+ WGL_TRANSPARENT_INDEX_VALUE_ARB = $203B;
+ {$EXTERNALSYM WGL_TRANSPARENT_INDEX_VALUE_ARB}
+ WGL_SHARE_DEPTH_ARB = $200C;
+ {$EXTERNALSYM WGL_SHARE_DEPTH_ARB}
+ WGL_SHARE_STENCIL_ARB = $200D;
+ {$EXTERNALSYM WGL_SHARE_STENCIL_ARB}
+ WGL_SHARE_ACCUM_ARB = $200E;
+ {$EXTERNALSYM WGL_SHARE_ACCUM_ARB}
+ WGL_SUPPORT_GDI_ARB = $200F;
+ {$EXTERNALSYM WGL_SUPPORT_GDI_ARB}
+ WGL_SUPPORT_OPENGL_ARB = $2010;
+ {$EXTERNALSYM WGL_SUPPORT_OPENGL_ARB}
+ WGL_DOUBLE_BUFFER_ARB = $2011;
+ {$EXTERNALSYM WGL_DOUBLE_BUFFER_ARB}
+ WGL_STEREO_ARB = $2012;
+ {$EXTERNALSYM WGL_STEREO_ARB}
+ WGL_PIXEL_TYPE_ARB = $2013;
+ {$EXTERNALSYM WGL_PIXEL_TYPE_ARB}
+ WGL_COLOR_BITS_ARB = $2014;
+ {$EXTERNALSYM WGL_COLOR_BITS_ARB}
+ WGL_RED_BITS_ARB = $2015;
+ {$EXTERNALSYM WGL_RED_BITS_ARB}
+ WGL_RED_SHIFT_ARB = $2016;
+ {$EXTERNALSYM WGL_RED_SHIFT_ARB}
+ WGL_GREEN_BITS_ARB = $2017;
+ {$EXTERNALSYM WGL_GREEN_BITS_ARB}
+ WGL_GREEN_SHIFT_ARB = $2018;
+ {$EXTERNALSYM WGL_GREEN_SHIFT_ARB}
+ WGL_BLUE_BITS_ARB = $2019;
+ {$EXTERNALSYM WGL_BLUE_BITS_ARB}
+ WGL_BLUE_SHIFT_ARB = $201A;
+ {$EXTERNALSYM WGL_BLUE_SHIFT_ARB}
+ WGL_ALPHA_BITS_ARB = $201B;
+ {$EXTERNALSYM WGL_ALPHA_BITS_ARB}
+ WGL_ALPHA_SHIFT_ARB = $201C;
+ {$EXTERNALSYM WGL_ALPHA_SHIFT_ARB}
+ WGL_ACCUM_BITS_ARB = $201D;
+ {$EXTERNALSYM WGL_ACCUM_BITS_ARB}
+ WGL_ACCUM_RED_BITS_ARB = $201E;
+ {$EXTERNALSYM WGL_ACCUM_RED_BITS_ARB}
+ WGL_ACCUM_GREEN_BITS_ARB = $201F;
+ {$EXTERNALSYM WGL_ACCUM_GREEN_BITS_ARB}
+ WGL_ACCUM_BLUE_BITS_ARB = $2020;
+ {$EXTERNALSYM WGL_ACCUM_BLUE_BITS_ARB}
+ WGL_ACCUM_ALPHA_BITS_ARB = $2021;
+ {$EXTERNALSYM WGL_ACCUM_ALPHA_BITS_ARB}
+ WGL_DEPTH_BITS_ARB = $2022;
+ {$EXTERNALSYM WGL_DEPTH_BITS_ARB}
+ WGL_STENCIL_BITS_ARB = $2023;
+ {$EXTERNALSYM WGL_STENCIL_BITS_ARB}
+ WGL_AUX_BUFFERS_ARB = $2024;
+ {$EXTERNALSYM WGL_AUX_BUFFERS_ARB}
+ WGL_NO_ACCELERATION_ARB = $2025;
+ {$EXTERNALSYM WGL_NO_ACCELERATION_ARB}
+ WGL_GENERIC_ACCELERATION_ARB = $2026;
+ {$EXTERNALSYM WGL_GENERIC_ACCELERATION_ARB}
+ WGL_FULL_ACCELERATION_ARB = $2027;
+ {$EXTERNALSYM WGL_FULL_ACCELERATION_ARB}
+ WGL_SWAP_EXCHANGE_ARB = $2028;
+ {$EXTERNALSYM WGL_SWAP_EXCHANGE_ARB}
+ WGL_SWAP_COPY_ARB = $2029;
+ {$EXTERNALSYM WGL_SWAP_COPY_ARB}
+ WGL_SWAP_UNDEFINED_ARB = $202A;
+ {$EXTERNALSYM WGL_SWAP_UNDEFINED_ARB}
+ WGL_TYPE_RGBA_ARB = $202B;
+ {$EXTERNALSYM WGL_TYPE_RGBA_ARB}
+ WGL_TYPE_COLORINDEX_ARB = $202C;
+ {$EXTERNALSYM WGL_TYPE_COLORINDEX_ARB}
+
+
+ // ********** GLU generic constants **********
+
+ // Errors: (return value 0 = no error)
+ GLU_INVALID_ENUM = 100900;
+ {$EXTERNALSYM GLU_INVALID_ENUM}
+ GLU_INVALID_VALUE = 100901;
+ {$EXTERNALSYM GLU_INVALID_VALUE}
+ GLU_OUT_OF_MEMORY = 100902;
+ {$EXTERNALSYM GLU_OUT_OF_MEMORY}
+ GLU_INCOMPATIBLE_GL_VERSION = 100903;
+ {$EXTERNALSYM GLU_INCOMPATIBLE_GL_VERSION}
+
+ // StringName
+ GLU_VERSION = 100800;
+ {$EXTERNALSYM GLU_VERSION}
+ GLU_EXTENSIONS = 100801;
+ {$EXTERNALSYM GLU_EXTENSIONS}
+
+ // Boolean
+ GLU_TRUE = GL_TRUE;
+ {$EXTERNALSYM GLU_TRUE}
+ GLU_FALSE = GL_FALSE;
+ {$EXTERNALSYM GLU_FALSE}
+
+ // Quadric constants
+ // QuadricNormal
+ GLU_SMOOTH = 100000;
+ {$EXTERNALSYM GLU_SMOOTH}
+ GLU_FLAT = 100001;
+ {$EXTERNALSYM GLU_FLAT}
+ GLU_NONE = 100002;
+ {$EXTERNALSYM GLU_NONE}
+
+ // QuadricDrawStyle
+ GLU_POINT = 100010;
+ {$EXTERNALSYM GLU_POINT}
+ GLU_LINE = 100011;
+ {$EXTERNALSYM GLU_LINE}
+ GLU_FILL = 100012;
+ {$EXTERNALSYM GLU_FILL}
+ GLU_SILHOUETTE = 100013;
+ {$EXTERNALSYM GLU_SILHOUETTE}
+
+ // QuadricOrientation
+ GLU_OUTSIDE = 100020;
+ {$EXTERNALSYM GLU_OUTSIDE}
+ GLU_INSIDE = 100021;
+ {$EXTERNALSYM GLU_INSIDE}
+
+ // Tesselation constants
+ GLU_TESS_MAX_COORD = 1.0e150;
+ {$EXTERNALSYM GLU_TESS_MAX_COORD}
+
+ // TessProperty
+ GLU_TESS_WINDING_RULE = 100140;
+ {$EXTERNALSYM GLU_TESS_WINDING_RULE}
+ GLU_TESS_BOUNDARY_ONLY = 100141;
+ {$EXTERNALSYM GLU_TESS_BOUNDARY_ONLY}
+ GLU_TESS_TOLERANCE = 100142;
+ {$EXTERNALSYM GLU_TESS_TOLERANCE}
+
+ // TessWinding
+ GLU_TESS_WINDING_ODD = 100130;
+ {$EXTERNALSYM GLU_TESS_WINDING_ODD}
+ GLU_TESS_WINDING_NONZERO = 100131;
+ {$EXTERNALSYM GLU_TESS_WINDING_NONZERO}
+ GLU_TESS_WINDING_POSITIVE = 100132;
+ {$EXTERNALSYM GLU_TESS_WINDING_POSITIVE}
+ GLU_TESS_WINDING_NEGATIVE = 100133;
+ {$EXTERNALSYM GLU_TESS_WINDING_NEGATIVE}
+ GLU_TESS_WINDING_ABS_GEQ_TWO = 100134;
+ {$EXTERNALSYM GLU_TESS_WINDING_ABS_GEQ_TWO}
+
+ // TessCallback
+ GLU_TESS_BEGIN = 100100; // TGLUTessBeginProc
+ {$EXTERNALSYM GLU_TESS_BEGIN}
+ GLU_TESS_VERTEX = 100101; // TGLUTessVertexProc
+ {$EXTERNALSYM GLU_TESS_VERTEX}
+ GLU_TESS_END = 100102; // TGLUTessEndProc
+ {$EXTERNALSYM GLU_TESS_END}
+ GLU_TESS_ERROR = 100103; // TGLUTessErrorProc
+ {$EXTERNALSYM GLU_TESS_ERROR}
+ GLU_TESS_EDGE_FLAG = 100104; // TGLUTessEdgeFlagProc
+ {$EXTERNALSYM GLU_TESS_EDGE_FLAG}
+ GLU_TESS_COMBINE = 100105; // TGLUTessCombineProc
+ {$EXTERNALSYM GLU_TESS_COMBINE}
+ GLU_TESS_BEGIN_DATA = 100106; // TGLUTessBeginDataProc
+ {$EXTERNALSYM GLU_TESS_BEGIN_DATA}
+ GLU_TESS_VERTEX_DATA = 100107; // TGLUTessVertexDataProc
+ {$EXTERNALSYM GLU_TESS_VERTEX_DATA}
+ GLU_TESS_END_DATA = 100108; // TGLUTessEndDataProc
+ {$EXTERNALSYM GLU_TESS_END_DATA}
+ GLU_TESS_ERROR_DATA = 100109; // TGLUTessErrorDataProc
+ {$EXTERNALSYM GLU_TESS_ERROR_DATA}
+ GLU_TESS_EDGE_FLAG_DATA = 100110; // TGLUTessEdgeFlagDataProc
+ {$EXTERNALSYM GLU_TESS_EDGE_FLAG_DATA}
+ GLU_TESS_COMBINE_DATA = 100111; // TGLUTessCombineDataProc
+ {$EXTERNALSYM GLU_TESS_COMBINE_DATA}
+
+ // TessError
+ GLU_TESS_ERROR1 = 100151;
+ {$EXTERNALSYM GLU_TESS_ERROR1}
+ GLU_TESS_ERROR2 = 100152;
+ {$EXTERNALSYM GLU_TESS_ERROR2}
+ GLU_TESS_ERROR3 = 100153;
+ {$EXTERNALSYM GLU_TESS_ERROR3}
+ GLU_TESS_ERROR4 = 100154;
+ {$EXTERNALSYM GLU_TESS_ERROR4}
+ GLU_TESS_ERROR5 = 100155;
+ {$EXTERNALSYM GLU_TESS_ERROR5}
+ GLU_TESS_ERROR6 = 100156;
+ {$EXTERNALSYM GLU_TESS_ERROR6}
+ GLU_TESS_ERROR7 = 100157;
+ {$EXTERNALSYM GLU_TESS_ERROR7}
+ GLU_TESS_ERROR8 = 100158;
+ {$EXTERNALSYM GLU_TESS_ERROR8}
+
+ GLU_TESS_MISSING_BEGIN_POLYGON = GLU_TESS_ERROR1;
+ {$EXTERNALSYM GLU_TESS_MISSING_BEGIN_POLYGON}
+ GLU_TESS_MISSING_BEGIN_CONTOUR = GLU_TESS_ERROR2;
+ {$EXTERNALSYM GLU_TESS_MISSING_BEGIN_CONTOUR}
+ GLU_TESS_MISSING_END_POLYGON = GLU_TESS_ERROR3;
+ {$EXTERNALSYM GLU_TESS_MISSING_END_POLYGON}
+ GLU_TESS_MISSING_END_CONTOUR = GLU_TESS_ERROR4;
+ {$EXTERNALSYM GLU_TESS_MISSING_END_CONTOUR}
+ GLU_TESS_COORD_TOO_LARGE = GLU_TESS_ERROR5;
+ {$EXTERNALSYM GLU_TESS_COORD_TOO_LARGE}
+ GLU_TESS_NEED_COMBINE_CALLBACK = GLU_TESS_ERROR6;
+ {$EXTERNALSYM GLU_TESS_NEED_COMBINE_CALLBACK}
+
+ // NURBS constants
+
+ // NurbsProperty
+ GLU_AUTO_LOAD_MATRIX = 100200;
+ {$EXTERNALSYM GLU_AUTO_LOAD_MATRIX}
+ GLU_CULLING = 100201;
+ {$EXTERNALSYM GLU_CULLING}
+ GLU_SAMPLING_TOLERANCE = 100203;
+ {$EXTERNALSYM GLU_SAMPLING_TOLERANCE}
+ GLU_DISPLAY_MODE = 100204;
+ {$EXTERNALSYM GLU_DISPLAY_MODE}
+ GLU_PARAMETRIC_TOLERANCE = 100202;
+ {$EXTERNALSYM GLU_PARAMETRIC_TOLERANCE}
+ GLU_SAMPLING_METHOD = 100205;
+ {$EXTERNALSYM GLU_SAMPLING_METHOD}
+ GLU_U_STEP = 100206;
+ {$EXTERNALSYM GLU_U_STEP}
+ GLU_V_STEP = 100207;
+ {$EXTERNALSYM GLU_V_STEP}
+
+ // NurbsSampling
+ GLU_PATH_LENGTH = 100215;
+ {$EXTERNALSYM GLU_PATH_LENGTH}
+ GLU_PARAMETRIC_ERROR = 100216;
+ {$EXTERNALSYM GLU_PARAMETRIC_ERROR}
+ GLU_DOMAIN_DISTANCE = 100217;
+ {$EXTERNALSYM GLU_DOMAIN_DISTANCE}
+
+ // NurbsTrim
+ GLU_MAP1_TRIM_2 = 100210;
+ {$EXTERNALSYM GLU_MAP1_TRIM_2}
+ GLU_MAP1_TRIM_3 = 100211;
+ {$EXTERNALSYM GLU_MAP1_TRIM_3}
+
+ // NurbsDisplay
+ GLU_OUTLINE_POLYGON = 100240;
+ {$EXTERNALSYM GLU_OUTLINE_POLYGON}
+ GLU_OUTLINE_PATCH = 100241;
+ {$EXTERNALSYM GLU_OUTLINE_PATCH}
+
+ // NurbsErrors
+ GLU_NURBS_ERROR1 = 100251;
+ {$EXTERNALSYM GLU_NURBS_ERROR1}
+ GLU_NURBS_ERROR2 = 100252;
+ {$EXTERNALSYM GLU_NURBS_ERROR2}
+ GLU_NURBS_ERROR3 = 100253;
+ {$EXTERNALSYM GLU_NURBS_ERROR3}
+ GLU_NURBS_ERROR4 = 100254;
+ {$EXTERNALSYM GLU_NURBS_ERROR4}
+ GLU_NURBS_ERROR5 = 100255;
+ {$EXTERNALSYM GLU_NURBS_ERROR5}
+ GLU_NURBS_ERROR6 = 100256;
+ {$EXTERNALSYM GLU_NURBS_ERROR6}
+ GLU_NURBS_ERROR7 = 100257;
+ {$EXTERNALSYM GLU_NURBS_ERROR7}
+ GLU_NURBS_ERROR8 = 100258;
+ {$EXTERNALSYM GLU_NURBS_ERROR8}
+ GLU_NURBS_ERROR9 = 100259;
+ {$EXTERNALSYM GLU_NURBS_ERROR9}
+ GLU_NURBS_ERROR10 = 100260;
+ {$EXTERNALSYM GLU_NURBS_ERROR10}
+ GLU_NURBS_ERROR11 = 100261;
+ {$EXTERNALSYM GLU_NURBS_ERROR11}
+ GLU_NURBS_ERROR12 = 100262;
+ {$EXTERNALSYM GLU_NURBS_ERROR12}
+ GLU_NURBS_ERROR13 = 100263;
+ {$EXTERNALSYM GLU_NURBS_ERROR13}
+ GLU_NURBS_ERROR14 = 100264;
+ {$EXTERNALSYM GLU_NURBS_ERROR14}
+ GLU_NURBS_ERROR15 = 100265;
+ {$EXTERNALSYM GLU_NURBS_ERROR15}
+ GLU_NURBS_ERROR16 = 100266;
+ {$EXTERNALSYM GLU_NURBS_ERROR16}
+ GLU_NURBS_ERROR17 = 100267;
+ {$EXTERNALSYM GLU_NURBS_ERROR17}
+ GLU_NURBS_ERROR18 = 100268;
+ {$EXTERNALSYM GLU_NURBS_ERROR18}
+ GLU_NURBS_ERROR19 = 100269;
+ {$EXTERNALSYM GLU_NURBS_ERROR19}
+ GLU_NURBS_ERROR20 = 100270;
+ {$EXTERNALSYM GLU_NURBS_ERROR20}
+ GLU_NURBS_ERROR21 = 100271;
+ {$EXTERNALSYM GLU_NURBS_ERROR21}
+ GLU_NURBS_ERROR22 = 100272;
+ {$EXTERNALSYM GLU_NURBS_ERROR22}
+ GLU_NURBS_ERROR23 = 100273;
+ {$EXTERNALSYM GLU_NURBS_ERROR23}
+ GLU_NURBS_ERROR24 = 100274;
+ {$EXTERNALSYM GLU_NURBS_ERROR24}
+ GLU_NURBS_ERROR25 = 100275;
+ {$EXTERNALSYM GLU_NURBS_ERROR25}
+ GLU_NURBS_ERROR26 = 100276;
+ {$EXTERNALSYM GLU_NURBS_ERROR26}
+ GLU_NURBS_ERROR27 = 100277;
+ {$EXTERNALSYM GLU_NURBS_ERROR27}
+ GLU_NURBS_ERROR28 = 100278;
+ {$EXTERNALSYM GLU_NURBS_ERROR28}
+ GLU_NURBS_ERROR29 = 100279;
+ {$EXTERNALSYM GLU_NURBS_ERROR29}
+ GLU_NURBS_ERROR30 = 100280;
+ {$EXTERNALSYM GLU_NURBS_ERROR30}
+ GLU_NURBS_ERROR31 = 100281;
+ {$EXTERNALSYM GLU_NURBS_ERROR31}
+ GLU_NURBS_ERROR32 = 100282;
+ {$EXTERNALSYM GLU_NURBS_ERROR32}
+ GLU_NURBS_ERROR33 = 100283;
+ {$EXTERNALSYM GLU_NURBS_ERROR33}
+ GLU_NURBS_ERROR34 = 100284;
+ {$EXTERNALSYM GLU_NURBS_ERROR34}
+ GLU_NURBS_ERROR35 = 100285;
+ {$EXTERNALSYM GLU_NURBS_ERROR35}
+ GLU_NURBS_ERROR36 = 100286;
+ {$EXTERNALSYM GLU_NURBS_ERROR36}
+ GLU_NURBS_ERROR37 = 100287;
+ {$EXTERNALSYM GLU_NURBS_ERROR37}
+
+ // Contours types -- obsolete!
+ GLU_CW = 100120;
+ {$EXTERNALSYM GLU_CW}
+ GLU_CCW = 100121;
+ {$EXTERNALSYM GLU_CCW}
+ GLU_INTERIOR = 100122;
+ {$EXTERNALSYM GLU_INTERIOR}
+ GLU_EXTERIOR = 100123;
+ {$EXTERNALSYM GLU_EXTERIOR}
+ GLU_UNKNOWN = 100124;
+ {$EXTERNALSYM GLU_UNKNOWN}
+
+ // Names without "TESS_" prefix
+ GLU_BEGIN = GLU_TESS_BEGIN;
+ {$EXTERNALSYM GLU_BEGIN}
+ GLU_VERTEX = GLU_TESS_VERTEX;
+ {$EXTERNALSYM GLU_VERTEX}
+ GLU_END = GLU_TESS_END;
+ {$EXTERNALSYM GLU_END}
+ GLU_ERROR = GLU_TESS_ERROR;
+ {$EXTERNALSYM GLU_ERROR}
+ GLU_EDGE_FLAG = GLU_TESS_EDGE_FLAG;
+ {$EXTERNALSYM GLU_EDGE_FLAG}
+
+ GLX_VERSION_1_1 = 1;
+ GLX_VERSION_1_2 = 1;
+ GLX_VERSION_1_3 = 1;
+ GLX_EXTENSION_NAME = 'GLX';
+ {$EXTERNALSYM GLX_EXTENSION_NAME}
+ GLX_USE_GL = 1;
+ {$EXTERNALSYM GLX_USE_GL}
+ GLX_BUFFER_SIZE = 2;
+ {$EXTERNALSYM GLX_BUFFER_SIZE}
+ GLX_LEVEL = 3;
+ {$EXTERNALSYM GLX_LEVEL}
+ GLX_RGBA = 4;
+ {$EXTERNALSYM GLX_RGBA}
+ GLX_DOUBLEBUFFER = 5;
+ {$EXTERNALSYM GLX_DOUBLEBUFFER}
+ GLX_STEREO = 6;
+ {$EXTERNALSYM GLX_STEREO}
+ GLX_AUX_BUFFERS = 7;
+ {$EXTERNALSYM GLX_AUX_BUFFERS}
+ GLX_RED_SIZE = 8;
+ {$EXTERNALSYM GLX_RED_SIZE}
+ GLX_GREEN_SIZE = 9;
+ {$EXTERNALSYM GLX_GREEN_SIZE}
+ GLX_BLUE_SIZE = 10;
+ {$EXTERNALSYM GLX_BLUE_SIZE}
+ GLX_ALPHA_SIZE = 11;
+ {$EXTERNALSYM GLX_ALPHA_SIZE}
+ GLX_DEPTH_SIZE = 12;
+ {$EXTERNALSYM GLX_DEPTH_SIZE}
+ GLX_STENCIL_SIZE = 13;
+ {$EXTERNALSYM GLX_STENCIL_SIZE}
+ GLX_ACCUM_RED_SIZE = 14;
+ {$EXTERNALSYM GLX_ACCUM_RED_SIZE}
+ GLX_ACCUM_GREEN_SIZE = 15;
+ {$EXTERNALSYM GLX_ACCUM_GREEN_SIZE}
+ GLX_ACCUM_BLUE_SIZE = 16;
+ {$EXTERNALSYM GLX_ACCUM_BLUE_SIZE}
+ GLX_ACCUM_ALPHA_SIZE = 17;
+ {$EXTERNALSYM GLX_ACCUM_ALPHA_SIZE}
+
+ // Error codes returned by glXGetConfig:
+ GLX_BAD_SCREEN = 1;
+ {$EXTERNALSYM GLX_BAD_SCREEN}
+ GLX_BAD_ATTRIBUTE = 2;
+ {$EXTERNALSYM GLX_BAD_ATTRIBUTE}
+ GLX_NO_EXTENSION = 3;
+ {$EXTERNALSYM GLX_NO_EXTENSION}
+ GLX_BAD_VISUAL = 4;
+ {$EXTERNALSYM GLX_BAD_VISUAL}
+ GLX_BAD_CONTEXT = 5;
+ {$EXTERNALSYM GLX_BAD_CONTEXT}
+ GLX_BAD_VALUE = 6;
+ {$EXTERNALSYM GLX_BAD_VALUE}
+ GLX_BAD_ENUM = 7;
+ {$EXTERNALSYM GLX_BAD_ENUM}
+
+ // GLX 1.1 and later:
+ GLX_VENDOR = 1;
+ {$EXTERNALSYM GLX_VENDOR}
+ GLX_VERSION = 2;
+ {$EXTERNALSYM GLX_VERSION}
+ GLX_EXTENSIONS = 3;
+ {$EXTERNALSYM GLX_EXTENSIONS}
+
+ // GLX 1.3 and later:
+ GLX_CONFIG_CAVEAT = $20;
+ {$EXTERNALSYM GLX_CONFIG_CAVEAT}
+ GLX_DONT_CARE = $FFFFFFFF;
+ {$EXTERNALSYM GLX_DONT_CARE}
+ GLX_SLOW_CONFIG = $8001;
+ {$EXTERNALSYM GLX_SLOW_CONFIG}
+ GLX_NON_CONFORMANT_CONFIG = $800D;
+ {$EXTERNALSYM GLX_NON_CONFORMANT_CONFIG}
+ GLX_X_VISUAL_TYPE = $22;
+ {$EXTERNALSYM GLX_X_VISUAL_TYPE}
+ GLX_TRANSPARENT_TYPE = $23;
+ {$EXTERNALSYM GLX_TRANSPARENT_TYPE}
+ GLX_TRANSPARENT_INDEX_VALUE = $24;
+ {$EXTERNALSYM GLX_TRANSPARENT_INDEX_VALUE}
+ GLX_TRANSPARENT_RED_VALUE = $25;
+ {$EXTERNALSYM GLX_TRANSPARENT_RED_VALUE}
+ GLX_TRANSPARENT_GREEN_VALUE = $26;
+ {$EXTERNALSYM GLX_TRANSPARENT_GREEN_VALUE}
+ GLX_TRANSPARENT_BLUE_VALUE = $27;
+ {$EXTERNALSYM GLX_TRANSPARENT_BLUE_VALUE}
+ GLX_TRANSPARENT_ALPHA_VALUE = $28;
+ {$EXTERNALSYM GLX_TRANSPARENT_ALPHA_VALUE}
+ GLX_MAX_PBUFFER_WIDTH = $8016;
+ {$EXTERNALSYM GLX_MAX_PBUFFER_WIDTH}
+ GLX_MAX_PBUFFER_HEIGHT = $8017;
+ {$EXTERNALSYM GLX_MAX_PBUFFER_HEIGHT}
+ GLX_MAX_PBUFFER_PIXELS = $8018;
+ {$EXTERNALSYM GLX_MAX_PBUFFER_PIXELS}
+ GLX_PRESERVED_CONTENTS = $801B;
+ {$EXTERNALSYM GLX_PRESERVED_CONTENTS}
+ GLX_LARGEST_BUFFER = $801C;
+ {$EXTERNALSYM GLX_LARGEST_BUFFER}
+ GLX_DRAWABLE_TYPE = $8010;
+ {$EXTERNALSYM GLX_DRAWABLE_TYPE}
+ GLX_FBCONFIG_ID = $8013;
+ {$EXTERNALSYM GLX_FBCONFIG_ID}
+ GLX_VISUAL_ID = $800B;
+ {$EXTERNALSYM GLX_VISUAL_ID}
+ GLX_WINDOW_BIT = $00000001;
+ {$EXTERNALSYM GLX_WINDOW_BIT}
+ GLX_PIXMAP_BIT = $00000002;
+ {$EXTERNALSYM GLX_PIXMAP_BIT}
+ GLX_PBUFFER_BIT = $00000004;
+ {$EXTERNALSYM GLX_PBUFFER_BIT}
+ GLX_AUX_BUFFERS_BIT = $00000010;
+ {$EXTERNALSYM GLX_AUX_BUFFERS_BIT}
+ GLX_FRONT_LEFT_BUFFER_BIT = $00000001;
+ {$EXTERNALSYM GLX_FRONT_LEFT_BUFFER_BIT}
+ GLX_FRONT_RIGHT_BUFFER_BIT = $00000002;
+ {$EXTERNALSYM GLX_FRONT_RIGHT_BUFFER_BIT}
+ GLX_BACK_LEFT_BUFFER_BIT = $00000004;
+ {$EXTERNALSYM GLX_BACK_LEFT_BUFFER_BIT}
+ GLX_BACK_RIGHT_BUFFER_BIT = $00000008;
+ {$EXTERNALSYM GLX_BACK_RIGHT_BUFFER_BIT}
+ GLX_DEPTH_BUFFER_BIT = $00000020;
+ {$EXTERNALSYM GLX_DEPTH_BUFFER_BIT}
+ GLX_STENCIL_BUFFER_BIT = $00000040;
+ {$EXTERNALSYM GLX_STENCIL_BUFFER_BIT}
+ GLX_ACCUM_BUFFER_BIT = $00000080;
+ {$EXTERNALSYM GLX_ACCUM_BUFFER_BIT}
+ GLX_RENDER_TYPE = $8011;
+ {$EXTERNALSYM GLX_RENDER_TYPE}
+ GLX_X_RENDERABLE = $8012;
+ {$EXTERNALSYM GLX_X_RENDERABLE}
+ GLX_NONE = $8000;
+ {$EXTERNALSYM GLX_NONE}
+ GLX_TRUE_COLOR = $8002;
+ {$EXTERNALSYM GLX_TRUE_COLOR}
+ GLX_DIRECT_COLOR = $8003;
+ {$EXTERNALSYM GLX_DIRECT_COLOR}
+ GLX_PSEUDO_COLOR = $8004;
+ {$EXTERNALSYM GLX_PSEUDO_COLOR}
+ GLX_STATIC_COLOR = $8005;
+ {$EXTERNALSYM GLX_STATIC_COLOR}
+ GLX_GRAY_SCALE = $8006;
+ {$EXTERNALSYM GLX_GRAY_SCALE}
+ GLX_STATIC_GRAY = $8007;
+ {$EXTERNALSYM GLX_STATIC_GRAY}
+ GLX_TRANSPARENT_INDEX = $8009;
+ {$EXTERNALSYM GLX_TRANSPARENT_INDEX}
+ GLX_COLOR_INDEX_TYPE = $8015;
+ {$EXTERNALSYM GLX_COLOR_INDEX_TYPE}
+ GLX_COLOR_INDEX_BIT = $00000002;
+ {$EXTERNALSYM GLX_COLOR_INDEX_BIT}
+ GLX_SCREEN = $800C;
+ {$EXTERNALSYM GLX_SCREEN}
+ GLX_PBUFFER_CLOBBER_MASK = $08000000;
+ {$EXTERNALSYM GLX_PBUFFER_CLOBBER_MASK}
+ GLX_DAMAGED = $8020;
+ {$EXTERNALSYM GLX_DAMAGED}
+ GLX_SAVED = $8021;
+ {$EXTERNALSYM GLX_SAVED}
+ GLX_WINDOW = $8022;
+ {$EXTERNALSYM GLX_WINDOW}
+ GLX_PBUFFER = $8023;
+ {$EXTERNALSYM GLX_PBUFFER}
+ GLX_EXT_visual_info = 1;
+ {$EXTERNALSYM GLX_EXT_visual_info}
+ GLX_X_VISUAL_TYPE_EXT = $22;
+ {$EXTERNALSYM GLX_X_VISUAL_TYPE_EXT}
+ GLX_TRANSPARENT_TYPE_EXT = $23;
+ {$EXTERNALSYM GLX_TRANSPARENT_TYPE_EXT}
+ GLX_TRANSPARENT_INDEX_VALUE_EXT = $24;
+ {$EXTERNALSYM GLX_TRANSPARENT_INDEX_VALUE_EXT}
+ GLX_TRANSPARENT_RED_VALUE_EXT = $25;
+ {$EXTERNALSYM GLX_TRANSPARENT_RED_VALUE_EXT}
+ GLX_TRANSPARENT_GREEN_VALUE_EXT = $26;
+ {$EXTERNALSYM GLX_TRANSPARENT_GREEN_VALUE_EXT}
+ GLX_TRANSPARENT_BLUE_VALUE_EXT = $27;
+ {$EXTERNALSYM GLX_TRANSPARENT_BLUE_VALUE_EXT}
+ GLX_TRANSPARENT_ALPHA_VALUE_EXT = $28;
+ {$EXTERNALSYM GLX_TRANSPARENT_ALPHA_VALUE_EXT}
+ GLX_TRUE_COLOR_EXT = $8002;
+ {$EXTERNALSYM GLX_TRUE_COLOR_EXT}
+ GLX_DIRECT_COLOR_EXT = $8003;
+ {$EXTERNALSYM GLX_DIRECT_COLOR_EXT}
+ GLX_PSEUDO_COLOR_EXT = $8004;
+ {$EXTERNALSYM GLX_PSEUDO_COLOR_EXT}
+ GLX_STATIC_COLOR_EXT = $8005;
+ {$EXTERNALSYM GLX_STATIC_COLOR_EXT}
+ GLX_GRAY_SCALE_EXT = $8006;
+ {$EXTERNALSYM GLX_GRAY_SCALE_EXT}
+ GLX_STATIC_GRAY_EXT = $8007;
+ {$EXTERNALSYM GLX_STATIC_GRAY_EXT}
+ GLX_NONE_EXT = $8000;
+ {$EXTERNALSYM GLX_NONE_EXT}
+ GLX_TRANSPARENT_RGB_EXT = $8008;
+ {$EXTERNALSYM GLX_TRANSPARENT_RGB_EXT}
+ GLX_TRANSPARENT_INDEX_EXT = $8009;
+ {$EXTERNALSYM GLX_TRANSPARENT_INDEX_EXT}
+ GLX_VISUAL_CAVEAT_EXT = $20;
+ {$EXTERNALSYM GLX_VISUAL_CAVEAT_EXT}
+ GLX_SLOW_VISUAL_EXT = $8001;
+ {$EXTERNALSYM GLX_SLOW_VISUAL_EXT}
+ GLX_NON_CONFORMANT_VISUAL_EXT = $800D;
+ {$EXTERNALSYM GLX_NON_CONFORMANT_VISUAL_EXT}
+ GLX_SHARE_CONTEXT_EXT = $800A;
+ {$EXTERNALSYM GLX_SHARE_CONTEXT_EXT}
+ GLX_VISUAL_ID_EXT = $800B;
+ {$EXTERNALSYM GLX_VISUAL_ID_EXT}
+ GLX_SCREEN_EXT = $800C;
+ {$EXTERNALSYM GLX_SCREEN_EXT}
+ GLX_3DFX_WINDOW_MODE_MESA = $1;
+ {$EXTERNALSYM GLX_3DFX_WINDOW_MODE_MESA}
+ GLX_3DFX_FULLSCREEN_MODE_MESA = $2;
+ {$EXTERNALSYM GLX_3DFX_FULLSCREEN_MODE_MESA}
+
+
+type
+ // GLU types
+ TGLUNurbs = record end;
+ TGLUQuadric = record end;
+ TGLUTesselator = record end;
+
+ PGLUNurbs = ^TGLUNurbs;
+ PGLUQuadric = ^TGLUQuadric;
+ PGLUTesselator = ^TGLUTesselator;
+
+ // backwards compatibility
+ TGLUNurbsObj = TGLUNurbs;
+ TGLUQuadricObj = TGLUQuadric;
+ TGLUTesselatorObj = TGLUTesselator;
+ TGLUTriangulatorObj = TGLUTesselator;
+
+ PGLUNurbsObj = PGLUNurbs;
+ PGLUQuadricObj = PGLUQuadric;
+ PGLUTesselatorObj = PGLUTesselator;
+ PGLUTriangulatorObj = PGLUTesselator;
+
+ {$IFDEF FPC}
+ {$IFDEF UNIX}
+ PALETTEENTRY = record
+ peRed : BYTE;
+ peGreen : BYTE;
+ peBlue : BYTE;
+ peFlags : BYTE;
+ end;
+ LPPALETTEENTRY = ^PALETTEENTRY;
+ tagPALETTEENTRY = PALETTEENTRY;
+ TPaletteEntry = PALETTEENTRY;
+ PPALETTEENTRY = ^PALETTEENTRY;
+ xid = txid;
+ pixmap = tpixmap;
+ font = tfont;
+ window = twindow;
+ colormap = tcolormap;
+ {$ENDIF}
+
+ PMaxLogPalette = ^TMaxLogPalette;
+ TMaxLogPalette = packed record
+ palversion : word;
+ palnumentries : word;
+ palpalentry : array[byte] of TPaletteEntry;
+ end;
+
+ {$ifdef WIN32} // If Windows
+ PWGLSwap = ^TWGLSwap;
+ {$EXTERNALSYM _WGLSWAP}
+ _WGLSWAP = packed record
+ hdc: HDC;
+ uiFlags: Cardinal;
+ end;
+ TWGLSwap = _WGLSWAP;
+ {$EXTERNALSYM WGLSWAP}
+ WGLSWAP = _WGLSWAP;
+ {$endif WIN32}
+
+ {$ENDIF}
+
+ {$ifdef VER100} // Delphi 3
+ PWGLSwap = ^TWGLSwap;
+ {$EXTERNALSYM _WGLSWAP}
+ _WGLSWAP = packed record
+ hdc: HDC;
+ uiFlags: Cardinal;
+ end;
+ TWGLSwap = _WGLSWAP;
+ {$EXTERNALSYM WGLSWAP}
+ WGLSWAP = _WGLSWAP;
+ {$endif VER100}
+
+ // Callback function prototypes
+ // GLUQuadricCallback
+ TGLUQuadricErrorProc = procedure(errorCode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+
+ // GLUTessCallback
+ TGLUTessBeginProc = procedure(AType: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ TGLUTessEdgeFlagProc = procedure(Flag: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ TGLUTessVertexProc = procedure(VertexData: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ TGLUTessEndProc = procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ TGLUTessErrorProc = procedure(ErrNo: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ TGLUTessCombineProc = procedure(Coords: TVector3d; VertexData: TVector4p; Weight: TVector4f; OutData: PPointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ TGLUTessBeginDataProc = procedure(AType: TGLEnum; UserData: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ TGLUTessEdgeFlagDataProc = procedure(Flag: TGLboolean; UserData: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ TGLUTessVertexDataProc = procedure(VertexData: Pointer; UserData: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ TGLUTessEndDataProc = procedure(UserData: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ TGLUTessErrorDataProc = procedure(ErrNo: TGLEnum; UserData: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ TGLUTessCombineDataProc = procedure(Coords: TVector3d; VertexData: TVector4p; Weight: TVector4f; OutData: PPointer; UserData: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+
+ // GLUNurbsCallback
+ TGLUNurbsErrorProc = procedure(ErrorCode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+
+var
+ // GL functions and procedures
+ glAccum: procedure(op: TGLuint; value: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glAccum}
+ glAlphaFunc: procedure(func: TGLEnum; ref: TGLclampf); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glAlphaFunc}
+ glAreTexturesResident: function(n: TGLsizei; Textures: PGLuint; residences: PGLboolean): TGLboolean; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glAreTexturesResident}
+ glArrayElement: procedure(i: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glArrayElement}
+ glBegin: procedure(mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBegin}
+ glBindTexture: procedure(target: TGLEnum; texture: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBindTexture}
+ glBitmap: procedure(width: TGLsizei; height: TGLsizei; xorig, yorig: TGLfloat; xmove: TGLfloat; ymove: TGLfloat; bitmap: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBitmap}
+ glBlendFunc: procedure(sfactor: TGLEnum; dfactor: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBlendFunc}
+ glCallList: procedure(list: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCallList}
+ glCallLists: procedure(n: TGLsizei; atype: TGLEnum; lists: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCallLists}
+ glClear: procedure(mask: TGLbitfield); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glClear}
+ glClearAccum: procedure(red, green, blue, alpha: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glClearAccum}
+ glClearColor: procedure(red, green, blue, alpha: TGLclampf); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glClearColor}
+ glClearDepth: procedure(depth: TGLclampd); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glClearDepth}
+ glClearIndex: procedure(c: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glClearIndex}
+ glClearStencil: procedure(s: TGLint ); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glClearStencil}
+ glClipPlane: procedure(plane: TGLEnum; equation: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glClipPlane}
+ glColor3b: procedure(red, green, blue: TGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3b}
+ glColor3bv: procedure(v: PGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3bv}
+ glColor3d: procedure(red, green, blue: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3d}
+ glColor3dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3dv}
+ glColor3f: procedure(red, green, blue: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3f}
+ glColor3fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3fv}
+ glColor3i: procedure(red, green, blue: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3i}
+ glColor3iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3iv}
+ glColor3s: procedure(red, green, blue: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3s}
+ glColor3sv: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3sv}
+ glColor3ub: procedure(red, green, blue: TGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3ub}
+ glColor3ubv: procedure(v: PGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3ubv}
+ glColor3ui: procedure(red, green, blue: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3ui}
+ glColor3uiv: procedure(v: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3uiv}
+ glColor3us: procedure(red, green, blue: TGLushort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3us}
+ glColor3usv: procedure(v: PGLushort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3usv}
+ glColor4b: procedure(red, green, blue, alpha: TGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4b}
+ glColor4bv: procedure(v: PGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4bv}
+ glColor4d: procedure(red, green, blue, alpha: TGLdouble ); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4d}
+ glColor4dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4dv}
+ glColor4f: procedure(red, green, blue, alpha: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4f}
+ glColor4fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4fv}
+ glColor4i: procedure(red, green, blue, alpha: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4i}
+ glColor4iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4iv}
+ glColor4s: procedure(red, green, blue, alpha: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4s}
+ glColor4sv: procedure(v: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4sv}
+ glColor4ub: procedure(red, green, blue, alpha: TGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4ub}
+ glColor4ubv: procedure(v: PGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4ubv}
+ glColor4ui: procedure(red, green, blue, alpha: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4ui}
+ glColor4uiv: procedure(v: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4uiv}
+ glColor4us: procedure(red, green, blue, alpha: TGLushort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4us}
+ glColor4usv: procedure(v: PGLushort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4usv}
+ glColorMask: procedure(red, green, blue, alpha: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorMask}
+ glColorMaterial: procedure(face: TGLEnum; mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorMaterial}
+ glColorPointer: procedure(size: TGLint; atype: TGLEnum; stride: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorPointer}
+ glCopyPixels: procedure(x, y: TGLint; width, height: TGLsizei; atype: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyPixels}
+ glCopyTexImage1D: procedure(target: TGLEnum; level: TGLint; internalFormat: TGLEnum; x, y: TGLint; width: TGLsizei; border: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyTexImage1D}
+ glCopyTexImage2D: procedure(target: TGLEnum; level: TGLint; internalFormat: TGLEnum; x, y: TGLint; width, height: TGLsizei; border: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyTexImage2D}
+ glCopyTexSubImage1D: procedure(target: TGLEnum; level, xoffset, x, y: TGLint; width: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyTexSubImage1D}
+ glCopyTexSubImage2D: procedure(target: TGLEnum; level, xoffset, yoffset, x, y: TGLint; width, height: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyTexSubImage2D}
+ glCullFace: procedure(mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCullFace}
+ glDeleteLists: procedure(list: TGLuint; range: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDeleteLists}
+ glDeleteTextures: procedure(n: TGLsizei; textures: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDeleteTextures}
+ glDepthFunc: procedure(func: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDepthFunc}
+ glDepthMask: procedure(flag: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDepthMask}
+ glDepthRange: procedure(zNear, zFar: TGLclampd); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDepthRange}
+ glDisable: procedure(cap: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDisable}
+ glDisableClientState: procedure(aarray: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDisableClientState}
+ glDrawArrays: procedure(mode: TGLEnum; first: TGLint; count: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDrawArrays}
+ glDrawBuffer: procedure(mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDrawBuffer}
+ glDrawElements: procedure(mode: TGLEnum; count: TGLsizei; atype: TGLEnum; indices: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDrawElements}
+ glDrawPixels: procedure(width, height: TGLsizei; format, atype: TGLEnum; pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDrawPixels}
+ glEdgeFlag: procedure(flag: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEdgeFlag}
+ glEdgeFlagPointer: procedure(stride: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEdgeFlagPointer}
+ glEdgeFlagv: procedure(flag: PGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEdgeFlagv}
+ glEnable: procedure(cap: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEnable}
+ glEnableClientState: procedure(aarray: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEnableClientState}
+ glEnd: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEnd}
+ glEndList: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEndList}
+ glEvalCoord1d: procedure(u: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEvalCoord1d}
+ glEvalCoord1dv: procedure(u: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEvalCoord1dv}
+ glEvalCoord1f: procedure(u: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEvalCoord1f}
+ glEvalCoord1fv: procedure(u: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEvalCoord1fv}
+ glEvalCoord2d: procedure(u: TGLdouble; v: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEvalCoord2d}
+ glEvalCoord2dv: procedure(u: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEvalCoord2dv}
+ glEvalCoord2f: procedure(u, v: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEvalCoord2f}
+ glEvalCoord2fv: procedure(u: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEvalCoord2fv}
+ glEvalMesh1: procedure(mode: TGLEnum; i1, i2: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEvalMesh1}
+ glEvalMesh2: procedure(mode: TGLEnum; i1, i2, j1, j2: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEvalMesh2}
+ glEvalPoint1: procedure(i: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEvalPoint1}
+ glEvalPoint2: procedure(i, j: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEvalPoint2}
+ glFeedbackBuffer: procedure(size: TGLsizei; atype: TGLEnum; buffer: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFeedbackBuffer}
+ glFinish: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFinish}
+ glFlush: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFlush}
+ glFogf: procedure(pname: TGLEnum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFogf}
+ glFogfv: procedure(pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFogfv}
+ glFogi: procedure(pname: TGLEnum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFogi}
+ glFogiv: procedure(pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFogiv}
+ glFrontFace: procedure(mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFrontFace}
+ glFrustum: procedure(left, right, bottom, top, zNear, zFar: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFrustum}
+ glGenLists: function(range: TGLsizei): TGLuint; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGenLists}
+ glGenTextures: procedure(n: TGLsizei; textures: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGenTextures}
+ glGetBooleanv: procedure(pname: TGLEnum; params: PGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetBooleanv}
+ glGetClipPlane: procedure(plane: TGLEnum; equation: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetClipPlane}
+ glGetDoublev: procedure(pname: TGLEnum; params: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetDoublev}
+ glGetError: function: TGLuint; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetError}
+ glGetFloatv: procedure(pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetFloatv}
+ glGetIntegerv: procedure(pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetIntegerv}
+ glGetLightfv: procedure(light, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetLightfv}
+ glGetLightiv: procedure(light, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetLightiv}
+ glGetMapdv: procedure(target, query: TGLEnum; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetMapdv}
+ glGetMapfv: procedure(target, query: TGLEnum; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetMapfv}
+ glGetMapiv: procedure(target, query: TGLEnum; v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetMapiv}
+ glGetMaterialfv: procedure(face, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetMaterialfv}
+ glGetMaterialiv: procedure(face, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetMaterialiv}
+ glGetPixelMapfv: procedure(map: TGLEnum; values: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetPixelMapfv}
+ glGetPixelMapuiv: procedure(map: TGLEnum; values: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetPixelMapuiv}
+ glGetPixelMapusv: procedure(map: TGLEnum; values: PGLushort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetPixelMapusv}
+ glGetPointerv: procedure(pname: TGLEnum; var params); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetPointerv}
+ glGetPolygonStipple: procedure(mask: PGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetPolygonStipple}
+ glGetString: function(name: TGLEnum): PChar; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetString}
+ glGetTexEnvfv: procedure(target, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetTexEnvfv}
+ glGetTexEnviv: procedure(target, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetTexEnviv}
+ glGetTexGendv: procedure(coord, pname: TGLEnum; params: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetTexGendv}
+ glGetTexGenfv: procedure(coord, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetTexGenfv}
+ glGetTexGeniv: procedure(coord, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetTexGeniv}
+ glGetTexImage: procedure(target: TGLEnum; level: TGLint; format, atype: TGLEnum; pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetTexImage}
+ glGetTexLevelParameterfv: procedure(target: TGLEnum; level: TGLint; pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetTexLevelParameterfv}
+ glGetTexLevelParameteriv: procedure(target: TGLEnum; level: TGLint; pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetTexLevelParameteriv}
+ glGetTexParameterfv: procedure(target, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetTexParameterfv}
+ glGetTexParameteriv: procedure(target, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetTexParameteriv}
+ glHint: procedure(target, mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glHint}
+ glIndexMask: procedure(mask: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexMask}
+ glIndexPointer: procedure(atype: TGLEnum; stride: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexPointer}
+ glIndexd: procedure(c: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexd}
+ glIndexdv: procedure(c: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexdv}
+ glIndexf: procedure(c: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexf}
+ glIndexfv: procedure(c: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexfv}
+ glIndexi: procedure(c: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexi}
+ glIndexiv: procedure(c: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexiv}
+ glIndexs: procedure(c: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexs}
+ glIndexsv: procedure(c: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexsv}
+ glIndexub: procedure(c: TGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexub}
+ glIndexubv: procedure(c: PGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexubv}
+ glInitNames: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glInitNames}
+ glInterleavedArrays: procedure(format: TGLEnum; stride: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glInterleavedArrays}
+ glIsEnabled: function(cap: TGLEnum): TGLboolean; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIsEnabled}
+ glIsList: function(list: TGLuint): TGLboolean; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIsList}
+ glIsTexture: function(texture: TGLuint): TGLboolean; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIsTexture}
+ glLightModelf: procedure(pname: TGLEnum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLightModelf}
+ glLightModelfv: procedure(pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLightModelfv}
+ glLightModeli: procedure(pname: TGLEnum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLightModeli}
+ glLightModeliv: procedure(pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLightModeliv}
+ glLightf: procedure(light, pname: TGLEnum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLightf}
+ glLightfv: procedure(light, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLightfv}
+ glLighti: procedure(light, pname: TGLEnum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLighti}
+ glLightiv: procedure(light, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLightiv}
+ glLineStipple: procedure(factor: TGLint; pattern: TGLushort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLineStipple}
+ glLineWidth: procedure(width: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLineWidth}
+ glListBase: procedure(base: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glListBase}
+ glLoadIdentity: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLoadIdentity}
+ glLoadMatrixd: procedure(m: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLoadMatrixd}
+ glLoadMatrixf: procedure(m: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLoadMatrixf}
+ glLoadName: procedure(name: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLoadName}
+ glLogicOp: procedure(opcode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLogicOp}
+ glMap1d: procedure(target: TGLEnum; u1, u2: TGLdouble; stride, order: TGLint; points: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMap1d}
+ glMap1f: procedure(target: TGLEnum; u1, u2: TGLfloat; stride, order: TGLint; points: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMap1f}
+ glMap2d: procedure(target: TGLEnum; u1, u2: TGLdouble; ustride, uorder: TGLint; v1, v2: TGLdouble; vstride,
+ vorder: TGLint; points: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMap2d}
+ glMap2f: procedure(target: TGLEnum; u1, u2: TGLfloat; ustride, uorder: TGLint; v1, v2: TGLfloat; vstride,
+ vorder: TGLint; points: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMap2f}
+ glMapGrid1d: procedure(un: TGLint; u1, u2: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMapGrid1d}
+ glMapGrid1f: procedure(un: TGLint; u1, u2: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMapGrid1f}
+ glMapGrid2d: procedure(un: TGLint; u1, u2: TGLdouble; vn: TGLint; v1, v2: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMapGrid2d}
+ glMapGrid2f: procedure(un: TGLint; u1, u2: TGLfloat; vn: TGLint; v1, v2: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMapGrid2f}
+ glMaterialf: procedure(face, pname: TGLEnum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMaterialf}
+ glMaterialfv: procedure(face, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMaterialfv}
+ glMateriali: procedure(face, pname: TGLEnum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMateriali}
+ glMaterialiv: procedure(face, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMaterialiv}
+ glMatrixMode: procedure(mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMatrixMode}
+ glMultMatrixd: procedure(m: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultMatrixd}
+ glMultMatrixf: procedure(m: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultMatrixf}
+ glNewList: procedure(list: TGLuint; mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNewList}
+ glNormal3b: procedure(nx, ny, nz: TGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormal3b}
+ glNormal3bv: procedure(v: PGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormal3bv}
+ glNormal3d: procedure(nx, ny, nz: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormal3d}
+ glNormal3dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormal3dv}
+ glNormal3f: procedure(nx, ny, nz: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormal3f}
+ glNormal3fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormal3fv}
+ glNormal3i: procedure(nx, ny, nz: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormal3i}
+ glNormal3iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormal3iv}
+ glNormal3s: procedure(nx, ny, nz: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormal3s}
+ glNormal3sv: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormal3sv}
+ glNormalPointer: procedure(atype: TGLEnum; stride: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormalPointer}
+ glOrtho: procedure(left, right, bottom, top, zNear, zFar: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glOrtho}
+ glPassThrough: procedure(token: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPassThrough}
+ glPixelMapfv: procedure(map: TGLEnum; mapsize: TGLsizei; values: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelMapfv}
+ glPixelMapuiv: procedure(map: TGLEnum; mapsize: TGLsizei; values: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelMapuiv}
+ glPixelMapusv: procedure(map: TGLEnum; mapsize: TGLsizei; values: PGLushort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelMapusv}
+ glPixelStoref: procedure(pname: TGLEnum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelStoref}
+ glPixelStorei: procedure(pname: TGLEnum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelStorei}
+ glPixelTransferf: procedure(pname: TGLEnum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelTransferf}
+ glPixelTransferi: procedure(pname: TGLEnum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelTransferi}
+ glPixelZoom: procedure(xfactor, yfactor: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelZoom}
+ glPointSize: procedure(size: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPointSize}
+ glPolygonMode: procedure(face, mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPolygonMode}
+ glPolygonOffset: procedure(factor, units: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPolygonOffset}
+ glPolygonStipple: procedure(mask: PGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPolygonStipple}
+ glPopAttrib: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPopAttrib}
+ glPopClientAttrib: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPopClientAttrib}
+ glPopMatrix: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPopMatrix}
+ glPopName: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPopName}
+ glPrioritizeTextures: procedure(n: TGLsizei; textures: PGLuint; priorities: PGLclampf); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPrioritizeTextures}
+ glPushAttrib: procedure(mask: TGLbitfield); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPushAttrib}
+ glPushClientAttrib: procedure(mask: TGLbitfield); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPushClientAttrib}
+ glPushMatrix: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPushMatrix}
+ glPushName: procedure(name: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPushName}
+ glRasterPos2d: procedure(x, y: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos2d}
+ glRasterPos2dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos2dv}
+ glRasterPos2f: procedure(x, y: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos2f}
+ glRasterPos2fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos2fv}
+ glRasterPos2i: procedure(x, y: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos2i}
+ glRasterPos2iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos2iv}
+ glRasterPos2s: procedure(x, y: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos2s}
+ glRasterPos2sv: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos2sv}
+ glRasterPos3d: procedure(x, y, z: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos3d}
+ glRasterPos3dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos3dv}
+ glRasterPos3f: procedure(x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos3f}
+ glRasterPos3fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos3fv}
+ glRasterPos3i: procedure(x, y, z: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos3i}
+ glRasterPos3iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos3iv}
+ glRasterPos3s: procedure(x, y, z: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos3s}
+ glRasterPos3sv: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos3sv}
+ glRasterPos4d: procedure(x, y, z, w: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos4d}
+ glRasterPos4dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos4dv}
+ glRasterPos4f: procedure(x, y, z, w: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos4f}
+ glRasterPos4fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos4fv}
+ glRasterPos4i: procedure(x, y, z, w: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos4i}
+ glRasterPos4iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos4iv}
+ glRasterPos4s: procedure(x, y, z, w: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos4s}
+ glRasterPos4sv: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRasterPos4sv}
+ glReadBuffer: procedure(mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReadBuffer}
+ glReadPixels: procedure(x, y: TGLint; width, height: TGLsizei; format, atype: TGLEnum; pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReadPixels}
+ glRectd: procedure(x1, y1, x2, y2: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRectd}
+ glRectdv: procedure(v1, v2: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRectdv}
+ glRectf: procedure(x1, y1, x2, y2: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRectf}
+ glRectfv: procedure(v1, v2: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRectfv}
+ glRecti: procedure(x1, y1, x2, y2: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRecti}
+ glRectiv: procedure(v1, v2: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRectiv}
+ glRects: procedure(x1, y1, x2, y2: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRects}
+ glRectsv: procedure(v1, v2: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRectsv}
+ glRenderMode: function(mode: TGLEnum): TGLint; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRenderMode}
+ glRotated: procedure(angle, x, y, z: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRotated}
+ glRotatef: procedure(angle, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRotatef}
+ glScaled: procedure(x, y, z: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glScaled}
+ glScalef: procedure(x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glScalef}
+ glScissor: procedure(x, y: TGLint; width, height: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glScissor}
+ glSelectBuffer: procedure(size: TGLsizei; buffer: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSelectBuffer}
+ glShadeModel: procedure(mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glShadeModel}
+ glStencilFunc: procedure(func: TGLEnum; ref: TGLint; mask: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glStencilFunc}
+ glStencilMask: procedure(mask: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glStencilMask}
+ glStencilOp: procedure(fail, zfail, zpass: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glStencilOp}
+ glTexCoord1d: procedure(s: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord1d}
+ glTexCoord1dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord1dv}
+ glTexCoord1f: procedure(s: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord1f}
+ glTexCoord1fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord1fv}
+ glTexCoord1i: procedure(s: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord1i}
+ glTexCoord1iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord1iv}
+ glTexCoord1s: procedure(s: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord1s}
+ glTexCoord1sv: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord1sv}
+ glTexCoord2d: procedure(s, t: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2d}
+ glTexCoord2dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2dv}
+ glTexCoord2f: procedure(s, t: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2f}
+ glTexCoord2fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2fv}
+ glTexCoord2i: procedure(s, t: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2i}
+ glTexCoord2iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2iv}
+ glTexCoord2s: procedure(s, t: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2s}
+ glTexCoord2sv: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2sv}
+ glTexCoord3d: procedure(s, t, r: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord3d}
+ glTexCoord3dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord3dv}
+ glTexCoord3f: procedure(s, t, r: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord3f}
+ glTexCoord3fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord3fv}
+ glTexCoord3i: procedure(s, t, r: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord3i}
+ glTexCoord3iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord3iv}
+ glTexCoord3s: procedure(s, t, r: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord3s}
+ glTexCoord3sv: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord3sv}
+ glTexCoord4d: procedure(s, t, r, q: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord4d}
+ glTexCoord4dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord4dv}
+ glTexCoord4f: procedure(s, t, r, q: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord4f}
+ glTexCoord4fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord4fv}
+ glTexCoord4i: procedure(s, t, r, q: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord4i}
+ glTexCoord4iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord4iv}
+ glTexCoord4s: procedure(s, t, r, q: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord4s}
+ glTexCoord4sv: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord4sv}
+ glTexCoordPointer: procedure(size: TGLint; atype: TGLEnum; stride: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoordPointer}
+ glTexEnvf: procedure(target, pname: TGLEnum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexEnvf}
+ glTexEnvfv: procedure(target, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexEnvfv}
+ glTexEnvi: procedure(target, pname: TGLEnum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexEnvi}
+ glTexEnviv: procedure(target, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexEnviv}
+ glTexGend: procedure(coord, pname: TGLEnum; param: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexGend}
+ glTexGendv: procedure(coord, pname: TGLEnum; params: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexGendv}
+ glTexGenf: procedure(coord, pname: TGLEnum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexGenf}
+ glTexGenfv: procedure(coord, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexGenfv}
+ glTexGeni: procedure(coord, pname: TGLEnum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexGeni}
+ glTexGeniv: procedure(coord, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexGeniv}
+ glTexImage1D: procedure(target: TGLEnum; level, internalformat: TGLint; width: TGLsizei; border: TGLint; format,
+ atype: TGLEnum; pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexImage1D}
+ glTexImage2D: procedure(target: TGLEnum; level, internalformat: TGLint; width, height: TGLsizei; border: TGLint;
+ format, atype: TGLEnum; Pixels:Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexImage2D}
+ glTexParameterf: procedure(target, pname: TGLEnum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexParameterf}
+ glTexParameterfv: procedure(target, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexParameterfv}
+ glTexParameteri: procedure(target, pname: TGLEnum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexParameteri}
+ glTexParameteriv: procedure(target, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexParameteriv}
+ glTexSubImage1D: procedure(target: TGLEnum; level, xoffset: TGLint; width: TGLsizei; format, atype: TGLEnum;
+ pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexSubImage1D}
+ glTexSubImage2D: procedure(target: TGLEnum; level, xoffset, yoffset: TGLint; width, height: TGLsizei; format,
+ atype: TGLEnum; pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexSubImage2D}
+ glTranslated: procedure(x, y, z: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTranslated}
+ glTranslatef: procedure(x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTranslatef}
+ glVertex2d: procedure(x, y: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex2d}
+ glVertex2dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex2dv}
+ glVertex2f: procedure(x, y: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex2f}
+ glVertex2fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex2fv}
+ glVertex2i: procedure(x, y: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex2i}
+ glVertex2iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex2iv}
+ glVertex2s: procedure(x, y: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex2s}
+ glVertex2sv: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex2sv}
+ glVertex3d: procedure(x, y, z: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex3d}
+ glVertex3dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex3dv}
+ glVertex3f: procedure(x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex3f}
+ glVertex3fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex3fv}
+ glVertex3i: procedure(x, y, z: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex3i}
+ glVertex3iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex3iv}
+ glVertex3s: procedure(x, y, z: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex3s}
+ glVertex3sv: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex3sv}
+ glVertex4d: procedure(x, y, z, w: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex4d}
+ glVertex4dv: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex4dv}
+ glVertex4f: procedure(x, y, z, w: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex4f}
+ glVertex4fv: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex4fv}
+ glVertex4i: procedure(x, y, z, w: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex4i}
+ glVertex4iv: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex4iv}
+ glVertex4s: procedure(x, y, z, w: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex4s}
+ glVertex4sv: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertex4sv}
+ glVertexPointer: procedure(size: TGLint; atype: TGLEnum; stride: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexPointer}
+ glViewport: procedure(x, y: TGLint; width, height: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glViewport}
+
+ // GL 1.2
+ glDrawRangeElements: procedure(mode: TGLEnum; Astart, Aend: TGLuint; count: TGLsizei; Atype: TGLEnum;
+ indices: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDrawRangeElements}
+ glTexImage3D: procedure(target: TGLEnum; level: TGLint; internalformat: TGLEnum; width, height, depth: TGLsizei;
+ border: TGLint; format: TGLEnum; Atype: TGLEnum; pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexImage3D}
+
+ // GL 1.2 ARB imaging
+ glBlendColor: procedure(red, green, blue, alpha: TGLclampf); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBlendColor}
+ glBlendEquation: procedure(mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBlendEquation}
+ glColorSubTable: procedure(target: TGLEnum; start, count: TGLsizei; format, Atype: TGLEnum; data: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorSubTable}
+ glCopyColorSubTable: procedure(target: TGLEnum; start: TGLsizei; x, y: TGLint; width: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyColorSubTable}
+ glColorTable: procedure(target, internalformat: TGLEnum; width: TGLsizei; format, Atype: TGLEnum;
+ table: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorTable}
+ glCopyColorTable: procedure(target, internalformat: TGLEnum; x, y: TGLint; width: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyColorTable}
+ glColorTableParameteriv: procedure(target, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorTableParameteriv}
+ glColorTableParameterfv: procedure(target, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorTableParameterfv}
+ glGetColorTable: procedure(target, format, Atype: TGLEnum; table: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetColorTable}
+ glGetColorTableParameteriv: procedure(target, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetColorTableParameteriv}
+ glGetColorTableParameterfv: procedure(target, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetColorTableParameterfv}
+ glConvolutionFilter1D: procedure(target, internalformat: TGLEnum; width: TGLsizei; format, Atype: TGLEnum;
+ image: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glConvolutionFilter1D}
+ glConvolutionFilter2D: procedure(target, internalformat: TGLEnum; width, height: TGLsizei; format, Atype: TGLEnum;
+ image: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glConvolutionFilter2D}
+ glCopyConvolutionFilter1D: procedure(target, internalformat: TGLEnum; x, y: TGLint; width: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyConvolutionFilter1D}
+ glCopyConvolutionFilter2D: procedure(target, internalformat: TGLEnum; x, y: TGLint; width, height: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyConvolutionFilter2D}
+ glGetConvolutionFilter: procedure(target, internalformat, Atype: TGLEnum; image: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetConvolutionFilter}
+ glSeparableFilter2D: procedure(target, internalformat: TGLEnum; width, height: TGLsizei; format, Atype: TGLEnum; row,
+ column: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSeparableFilter2D}
+ glGetSeparableFilter: procedure(target, format, Atype: TGLEnum; row, column, span: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetSeparableFilter}
+ glConvolutionParameteri: procedure(target, pname: TGLEnum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glConvolutionParameteri}
+ glConvolutionParameteriv: procedure(target, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glConvolutionParameteriv}
+ glConvolutionParameterf: procedure(target, pname: TGLEnum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glConvolutionParameterf}
+ glConvolutionParameterfv: procedure(target, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glConvolutionParameterfv}
+ glGetConvolutionParameteriv: procedure(target, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetConvolutionParameteriv}
+ glGetConvolutionParameterfv: procedure(target, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetConvolutionParameterfv}
+ glHistogram: procedure(target: TGLEnum; width: TGLsizei; internalformat: TGLEnum; sink: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glHistogram}
+ glResetHistogram: procedure(target: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glResetHistogram}
+ glGetHistogram: procedure(target: TGLEnum; reset: TGLboolean; format, Atype: TGLEnum; values: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetHistogram}
+ glGetHistogramParameteriv: procedure(target, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetHistogramParameteriv}
+ glGetHistogramParameterfv: procedure(target, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetHistogramParameterfv}
+ glMinmax: procedure(target, internalformat: TGLEnum; sink: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMinmax}
+ glResetMinmax: procedure(target: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glResetMinmax}
+ glGetMinmax: procedure(target: TGLEnum; reset: TGLboolean; format, Atype: TGLEnum; values: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetMinmax}
+ glGetMinmaxParameteriv: procedure(target, pname: TGLEnum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetMinmaxParameteriv}
+ glGetMinmaxParameterfv: procedure(target, pname: TGLEnum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetMinmaxParameterfv}
+
+ // GL utility functions and procedures
+ gluErrorString: function(errCode: TGLEnum): PChar; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluErrorString}
+ gluGetString: function(name: TGLEnum): PChar; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluGetString}
+ gluOrtho2D: procedure(left, right, bottom, top: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluOrtho2D}
+ gluPerspective: procedure(fovy, aspect, zNear, zFar: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluPerspective}
+ gluPickMatrix: procedure(x, y, width, height: TGLdouble; viewport: TVector4i); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluPickMatrix}
+ gluLookAt: procedure(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluLookAt}
+ gluProject: function(objx, objy, objz: TGLdouble; modelMatrix: TMatrix4d; projMatrix: TMatrix4d; viewport: TVector4i;
+ winx, winy, winz: PGLdouble): TGLint; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluProject}
+ gluUnProject: function(winx, winy, winz: TGLdouble; modelMatrix: TMatrix4d; projMatrix: TMatrix4d; viewport: TVector4i;
+ objx, objy, objz: PGLdouble): TGLint; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluUnProject}
+ gluScaleImage: function(format: TGLEnum; widthin, heightin: TGLint; typein: TGLEnum; datain: Pointer; widthout,
+ heightout: TGLint; typeout: TGLEnum; dataout: Pointer): TGLint; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluScaleImage}
+ gluBuild1DMipmaps: function(target: TGLEnum; components, width: TGLint; format, atype: TGLEnum;
+ data: Pointer): TGLint; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluBuild1DMipmaps}
+ gluBuild2DMipmaps: function(target: TGLEnum; components, width, height: TGLint; format, atype: TGLEnum;
+ Data: Pointer): TGLint; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluBuild2DMipmaps}
+ gluNewQuadric: function: PGLUquadric; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluNewQuadric}
+ gluDeleteQuadric: procedure(state: PGLUquadric); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluDeleteQuadric}
+ gluQuadricNormals: procedure(quadObject: PGLUquadric; normals: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluQuadricNormals}
+ gluQuadricTexture: procedure(quadObject: PGLUquadric; textureCoords: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluQuadricTexture}
+ gluQuadricOrientation: procedure(quadObject: PGLUquadric; orientation: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluQuadricOrientation}
+ gluQuadricDrawStyle: procedure(quadObject: PGLUquadric; drawStyle: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluQuadricDrawStyle}
+ gluCylinder: procedure(quadObject: PGLUquadric; baseRadius, topRadius, height: TGLdouble; slices,
+ stacks: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluCylinder}
+ gluDisk: procedure(quadObject: PGLUquadric; innerRadius, outerRadius: TGLdouble; slices, loops: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluDisk}
+ gluPartialDisk: procedure(quadObject: PGLUquadric; innerRadius, outerRadius: TGLdouble; slices, loops: TGLint;
+ startAngle, sweepAngle: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluPartialDisk}
+ gluSphere: procedure(quadObject: PGLUquadric; radius: TGLdouble; slices, stacks: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluSphere}
+ gluQuadricCallback: procedure(quadObject: PGLUquadric; which: TGLEnum; fn: TGLUQuadricErrorProc); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluQuadricCallback}
+ gluNewTess: function: PGLUtesselator; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluNewTess}
+ gluDeleteTess: procedure(tess: PGLUtesselator); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluDeleteTess}
+ gluTessBeginPolygon: procedure(tess: PGLUtesselator; polygon_data: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluTessBeginPolygon}
+ gluTessBeginContour: procedure(tess: PGLUtesselator); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluTessBeginContour}
+ gluTessVertex: procedure(tess: PGLUtesselator; coords: TVector3d; data: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluTessVertex}
+ gluTessEndContour: procedure(tess: PGLUtesselator); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluTessEndContour}
+ gluTessEndPolygon: procedure(tess: PGLUtesselator); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluTessEndPolygon}
+ gluTessProperty: procedure(tess: PGLUtesselator; which: TGLEnum; value: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluTessProperty}
+ gluTessNormal: procedure(tess: PGLUtesselator; x, y, z: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluTessNormal}
+ gluTessCallback: procedure(tess: PGLUtesselator; which: TGLEnum; fn: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluTessCallback}
+ gluGetTessProperty: procedure(tess: PGLUtesselator; which: TGLEnum; value: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluGetTessProperty}
+ gluNewNurbsRenderer: function: PGLUnurbs; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluNewNurbsRenderer}
+ gluDeleteNurbsRenderer: procedure(nobj: PGLUnurbs); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluDeleteNurbsRenderer}
+ gluBeginSurface: procedure(nobj: PGLUnurbs); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluBeginSurface}
+ gluBeginCurve: procedure(nobj: PGLUnurbs); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluBeginCurve}
+ gluEndCurve: procedure(nobj: PGLUnurbs); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluEndCurve}
+ gluEndSurface: procedure(nobj: PGLUnurbs); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluEndSurface}
+ gluBeginTrim: procedure(nobj: PGLUnurbs); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluBeginTrim}
+ gluEndTrim: procedure(nobj: PGLUnurbs); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluEndTrim}
+ gluPwlCurve: procedure(nobj: PGLUnurbs; count: TGLint; points: PGLfloat; stride: TGLint; atype: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluPwlCurve}
+ gluNurbsCurve: procedure(nobj: PGLUnurbs; nknots: TGLint; knot: PGLfloat; stride: TGLint; ctlarray: PGLfloat; order: TGLint; atype: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluNurbsCurve}
+ gluNurbsSurface: procedure(nobj: PGLUnurbs; sknot_count: TGLint; sknot: PGLfloat; tknot_count: TGLint; tknot: PGLfloat; s_stride, t_stride: TGLint; ctlarray: PGLfloat; sorder, torder: TGLint; atype: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluNurbsSurface}
+ gluLoadSamplingMatrices: procedure(nobj: PGLUnurbs; modelMatrix, projMatrix: TMatrix4f; viewport: TVector4i); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluLoadSamplingMatrices}
+ gluNurbsProperty: procedure(nobj: PGLUnurbs; aproperty: TGLEnum; value: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluNurbsProperty}
+ gluGetNurbsProperty: procedure(nobj: PGLUnurbs; aproperty: TGLEnum; value: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluGetNurbsProperty}
+ gluNurbsCallback: procedure(nobj: PGLUnurbs; which: TGLEnum; fn: TGLUNurbsErrorProc); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluNurbsCallback}
+ gluBeginPolygon: procedure(tess: PGLUtesselator); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluBeginPolygon}
+ gluNextContour: procedure(tess: PGLUtesselator; atype: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluNextContour}
+ gluEndPolygon: procedure(tess: PGLUtesselator); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluEndPolygon}
+
+ // window support functions
+ {$ifdef Win32}
+ wglGetProcAddress: function(ProcName: PChar): Pointer; stdcall;
+ {$EXTERNALSYM wglGetProcAddress}
+ wglCopyContext: function(p1: HGLRC; p2: HGLRC; p3: Cardinal): BOOL; stdcall;
+ {$EXTERNALSYM wglCopyContext}
+ wglCreateContext: function(DC: HDC): HGLRC; stdcall;
+ {$EXTERNALSYM wglCreateContext}
+ wglCreateLayerContext: function(p1: HDC; p2: Integer): HGLRC; stdcall;
+ {$EXTERNALSYM wglCreateLayerContext}
+ wglDeleteContext: function(p1: HGLRC): BOOL; stdcall;
+ {$EXTERNALSYM wglDeleteContext}
+ wglDescribeLayerPlane:function(p1: HDC; p2, p3: Integer; p4: Cardinal; var p5: TLayerPlaneDescriptor): BOOL; stdcall;
+ {$EXTERNALSYM wglDescribeLayerPlane}
+ wglGetCurrentContext: function: HGLRC; stdcall;
+ {$EXTERNALSYM wglGetCurrentContext}
+ wglGetCurrentDC: function: HDC; stdcall;
+ {$EXTERNALSYM wglGetCurrentDC}
+ wglGetLayerPaletteEntries: function(p1: HDC; p2, p3, p4: Integer; var pcr): Integer; stdcall;
+ {$EXTERNALSYM wglGetLayerPaletteEntries}
+ wglMakeCurrent: function(DC: HDC; p2: HGLRC): BOOL; stdcall;
+ {$EXTERNALSYM wglMakeCurrent}
+ wglRealizeLayerPalette: function(p1: HDC; p2: Integer; p3: BOOL): BOOL; stdcall;
+ {$EXTERNALSYM wglRealizeLayerPalette}
+ wglSetLayerPaletteEntries: function(p1: HDC; p2, p3, p4: Integer; var pcr): Integer; stdcall;
+ {$EXTERNALSYM wglSetLayerPaletteEntries}
+ wglShareLists: function(p1, p2: HGLRC): BOOL; stdcall;
+ {$EXTERNALSYM wglShareLists}
+ wglSwapLayerBuffers: function(p1: HDC; p2: Cardinal): BOOL; stdcall;
+ {$EXTERNALSYM wglSwapLayerBuffers}
+ wglSwapMultipleBuffers: function(p1: Cardinal; const p2: PWGLSwap): DWORD; stdcall;
+ {$EXTERNALSYM wglSwapMultipleBuffers}
+ wglUseFontBitmapsA: function(DC: HDC; p2, p3, p4: DWORD): BOOL; stdcall;
+ {$EXTERNALSYM wglUseFontBitmapsA}
+ wglUseFontOutlinesA: function (p1: HDC; p2, p3, p4: DWORD; p5, p6: Single; p7: Integer; p8: PGlyphMetricsFloat): BOOL; stdcall;
+ {$EXTERNALSYM wglUseFontOutlinesA}
+ wglUseFontBitmapsW: function(DC: HDC; p2, p3, p4: DWORD): BOOL; stdcall;
+ {$EXTERNALSYM wglUseFontBitmapsW}
+ wglUseFontOutlinesW: function (p1: HDC; p2, p3, p4: DWORD; p5, p6: Single; p7: Integer; p8: PGlyphMetricsFloat): BOOL; stdcall;
+ {$EXTERNALSYM wglUseFontOutlinesW}
+ wglUseFontBitmaps: function(DC: HDC; p2, p3, p4: DWORD): BOOL; stdcall;
+ {$EXTERNALSYM wglUseFontBitmaps}
+ wglUseFontOutlines: function(p1: HDC; p2, p3, p4: DWORD; p5, p6: Single; p7: Integer; p8: PGlyphMetricsFloat): BOOL; stdcall;
+ {$EXTERNALSYM wglUseFontOutlines}
+
+ // ARB wgl extensions
+ wglGetExtensionsStringARB: function(DC: HDC): PChar; stdcall;
+ {$EXTERNALSYM wglGetExtensionsStringARB}
+ wglGetPixelFormatAttribivARB: function(DC: HDC; iPixelFormat, iLayerPlane: Integer; nAttributes: Cardinal;
+ const piAttributes: PInteger; piValues : PInteger) : BOOL; stdcall;
+ {$EXTERNALSYM wglGetPixelFormatAttribivARB}
+ wglGetPixelFormatAttribfvARB: function(DC: HDC; iPixelFormat, iLayerPlane: Integer; nAttributes: Cardinal;
+ const piAttributes: PInteger; piValues: PGLFloat) : BOOL; stdcall;
+ {$EXTERNALSYM wglGetPixelFormatAttribfvARB}
+ wglChoosePixelFormatARB: function(DC: HDC; const piAttribIList: PInteger; const pfAttribFList: PGLFloat;
+ nMaxFormats: Cardinal; piFormats: PInteger; nNumFormats: PCardinal) : BOOL; stdcall;
+ {$EXTERNALSYM wglChoosePixelFormatARB}
+ {$endif}
+
+ // ARB_multitexture
+ glMultiTexCoord1dARB: procedure(target: TGLenum; s: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord1dARB}
+ glMultiTexCoord1dVARB: procedure(target: TGLenum; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord1dVARB}
+ glMultiTexCoord1fARBP: procedure(target: TGLenum; s: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord1fARBP}
+ glMultiTexCoord1fVARB: procedure(target: TGLenum; v: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord1fVARB}
+ glMultiTexCoord1iARB: procedure(target: TGLenum; s: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord1iARB}
+ glMultiTexCoord1iVARB: procedure(target: TGLenum; v: PGLInt); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord1iVARB}
+ glMultiTexCoord1sARBP: procedure(target: TGLenum; s: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord1sARBP}
+ glMultiTexCoord1sVARB: procedure(target: TGLenum; v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord1sVARB}
+ glMultiTexCoord2dARB: procedure(target: TGLenum; s, t: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord2dARB}
+ glMultiTexCoord2dvARB: procedure(target: TGLenum; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord2dvARB}
+ glMultiTexCoord2fARB: procedure(target: TGLenum; s, t: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord2fARB}
+ glMultiTexCoord2fvARB: procedure(target: TGLenum; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord2fvARB}
+ glMultiTexCoord2iARB: procedure(target: TGLenum; s, t: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord2iARB}
+ glMultiTexCoord2ivARB: procedure(target: TGLenum; v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord2ivARB}
+ glMultiTexCoord2sARB: procedure(target: TGLenum; s, t: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord2sARB}
+ glMultiTexCoord2svARB: procedure(target: TGLenum; v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord2svARB}
+ glMultiTexCoord3dARB: procedure(target: TGLenum; s, t, r: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord3dARB}
+ glMultiTexCoord3dvARB: procedure(target: TGLenum; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord3dvARB}
+ glMultiTexCoord3fARB: procedure(target: TGLenum; s, t, r: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord3fARB}
+ glMultiTexCoord3fvARB: procedure(target: TGLenum; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord3fvARB}
+ glMultiTexCoord3iARB: procedure(target: TGLenum; s, t, r: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord3iARB}
+ glMultiTexCoord3ivARB: procedure(target: TGLenum; v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord3ivARB}
+ glMultiTexCoord3sARB: procedure(target: TGLenum; s, t, r: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord3sARB}
+ glMultiTexCoord3svARB: procedure(target: TGLenum; v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord3svARB}
+ glMultiTexCoord4dARB: procedure(target: TGLenum; s, t, r, q: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord4dARB}
+ glMultiTexCoord4dvARB: procedure(target: TGLenum; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord4dvARB}
+ glMultiTexCoord4fARB: procedure(target: TGLenum; s, t, r, q: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord4fARB}
+ glMultiTexCoord4fvARB: procedure(target: TGLenum; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord4fvARB}
+ glMultiTexCoord4iARB: procedure(target: TGLenum; s, t, r, q: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord4iARB}
+ glMultiTexCoord4ivARB: procedure(target: TGLenum; v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord4ivARB}
+ glMultiTexCoord4sARB: procedure(target: TGLenum; s, t, r, q: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord4sARB}
+ glMultiTexCoord4svARB: procedure(target: TGLenum; v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiTexCoord4svARB}
+ glActiveTextureARB: procedure(target: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glActiveTextureARB}
+ glClientActiveTextureARB: procedure(target: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glClientActiveTextureARB}
+
+ // GLU extensions
+ gluNurbsCallbackDataEXT: procedure(nurb: PGLUnurbs; userData: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluNurbsCallbackDataEXT}
+ gluNewNurbsTessellatorEXT: function: PGLUnurbs; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluNewNurbsTessellatorEXT}
+ gluDeleteNurbsTessellatorEXT: procedure(nurb: PGLUnurbs); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM gluDeleteNurbsTessellatorEXT}
+
+{$ifndef FPC}
+ {$ifdef MULTITHREADOPENGL}
+ threadvar
+ {$else}
+ var
+ {$endif}
+{$else}
+var
+{$endif}
+ // Extension functions
+ glAreTexturesResidentEXT: function(n: TGLsizei; textures: PGLuint; residences: PGLBoolean): TGLboolean; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glAreTexturesResidentEXT}
+ glArrayElementArrayEXT: procedure(mode: TGLEnum; count: TGLsizei; pi: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glArrayElementArrayEXT}
+ glBeginSceneEXT: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBeginSceneEXT}
+ glBindTextureEXT: procedure(target: TGLEnum; texture: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBindTextureEXT}
+ glColorTableEXT: procedure(target, internalFormat: TGLEnum; width: TGLsizei; format, atype: TGLEnum; data: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorTableEXT}
+ glColorSubTableExt: procedure(target: TGLEnum; start, count: TGLsizei; format, atype: TGLEnum; data: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorSubTableExt}
+ glCopyTexImage1DEXT: procedure(target: TGLEnum; level: TGLint; internalFormat: TGLEnum; x, y: TGLint; width: TGLsizei; border: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyTexImage1DEXT}
+ glCopyTexSubImage1DEXT: procedure(target: TGLEnum; level, xoffset, x, y: TGLint; width: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyTexSubImage1DEXT}
+ glCopyTexImage2DEXT: procedure(target: TGLEnum; level: TGLint; internalFormat: TGLEnum; x, y: TGLint; width, height: TGLsizei; border: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyTexImage2DEXT}
+ glCopyTexSubImage2DEXT: procedure(target: TGLEnum; level, xoffset, yoffset, x, y: TGLint; width, height: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyTexSubImage2DEXT}
+ glCopyTexSubImage3DEXT: procedure(target: TGLEnum; level, xoffset, yoffset, zoffset, x, y: TGLint; width, height: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyTexSubImage3DEXT}
+ glDeleteTexturesEXT: procedure(n: TGLsizei; textures: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDeleteTexturesEXT}
+ glEndSceneEXT: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEndSceneEXT}
+ glGenTexturesEXT: procedure(n: TGLsizei; textures: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGenTexturesEXT}
+ glGetColorTableEXT: procedure(target, format, atype: TGLEnum; data: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetColorTableEXT}
+ glGetColorTablePameterfvEXT: procedure(target, pname: TGLEnum; params: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetColorTablePameterfvEXT}
+ glGetColorTablePameterivEXT: procedure(target, pname: TGLEnum; params: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetColorTablePameterivEXT}
+ glIndexFuncEXT: procedure(func: TGLEnum; ref: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexFuncEXT}
+ glIndexMaterialEXT: procedure(face: TGLEnum; mode: TGLEnum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexMaterialEXT}
+ glIsTextureEXT: function(texture: TGLuint): TGLboolean; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIsTextureEXT}
+ glLockArraysEXT: procedure(first: TGLint; count: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLockArraysEXT}
+ glPolygonOffsetEXT: procedure(factor, bias: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPolygonOffsetEXT}
+ glPrioritizeTexturesEXT: procedure(n: TGLsizei; textures: PGLuint; priorities: PGLclampf); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPrioritizeTexturesEXT}
+ glTexSubImage1DEXT: procedure(target: TGLEnum; level, xoffset: TGLint; width: TGLsizei; format, Atype: TGLEnum; pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexSubImage1DEXT}
+ glTexSubImage2DEXT: procedure(target: TGLEnum; level, xoffset, yoffset: TGLint; width, height: TGLsizei; format, Atype: TGLEnum; pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexSubImage2DEXT}
+ glTexSubImage3DEXT: procedure(target: TGLEnum; level, xoffset, yoffset, zoffset: TGLint; width, height, depth: TGLsizei; format, Atype: TGLEnum; pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexSubImage3DEXT}
+ glUnlockArraysEXT: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glUnlockArraysEXT}
+
+ // EXT_vertex_array
+ glArrayElementEXT: procedure(I: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glArrayElementEXT}
+ glColorPointerEXT: procedure(size: TGLInt; atype: TGLenum; stride, count: TGLsizei; data: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorPointerEXT}
+ glDrawArraysEXT: procedure(mode: TGLenum; first: TGLInt; count: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDrawArraysEXT}
+ glEdgeFlagPointerEXT: procedure(stride, count: TGLsizei; data: PGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEdgeFlagPointerEXT}
+ glGetPointervEXT: procedure(pname: TGLEnum; var params); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetPointervEXT}
+ glIndexPointerEXT: procedure(AType: TGLEnum; stride, count: TGLsizei; P: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexPointerEXT}
+ glNormalPointerEXT: procedure(AType: TGLsizei; stride, count: TGLsizei; P: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormalPointerEXT}
+ glTexCoordPointerEXT: procedure(size: TGLint; AType: TGLenum; stride, count: TGLsizei; P: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoordPointerEXT}
+ glVertexPointerEXT: procedure(size: TGLint; AType: TGLenum; stride, count: TGLsizei; P: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexPointerEXT}
+
+ // EXT_compiled_vertex_array
+ glLockArrayEXT: procedure(first: TGLint; count: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLockArrayEXT}
+ glUnlockArrayEXT: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glUnlockArrayEXT}
+
+ // EXT_cull_vertex
+ glCullParameterdvEXT: procedure(pname: TGLenum; params: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCullParameterdvEXT}
+ glCullParameterfvEXT: procedure(pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCullParameterfvEXT}
+
+ // WIN_swap_hint
+ glAddSwapHintRectWIN: procedure(x, y: TGLint; width, height: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glAddSwapHintRectWIN}
+
+ // EXT_point_parameter
+ glPointParameterfEXT: procedure(pname: TGLenum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPointParameterfEXT}
+ glPointParameterfvEXT: procedure(pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPointParameterfvEXT}
+
+ // GL_ARB_transpose_matrix
+ glLoadTransposeMatrixfARB: procedure(m: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLoadTransposeMatrixfARB}
+ glLoadTransposeMatrixdARB: procedure(m: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLoadTransposeMatrixdARB}
+ glMultTransposeMatrixfARB: procedure(m: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultTransposeMatrixfARB}
+ glMultTransposeMatrixdARB: procedure(m: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultTransposeMatrixdARB}
+
+ // GL_ARB_multisample
+ glSampleCoverageARB: procedure(Value: TGLclampf; invert: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSampleCoverageARB}
+ glSamplePassARB: procedure(pass: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSamplePassARB}
+
+ // GL_ARB_texture_compression
+ glCompressedTexImage3DARB: procedure(target: TGLenum; level: TGLint; internalformat: TGLenum; Width, Height, depth: TGLsizei; border: TGLint; imageSize: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCompressedTexImage3DARB}
+ glCompressedTexImage2DARB: procedure(target: TGLenum; level: TGLint; internalformat: TGLenum; Width, Height: TGLsizei; border: TGLint; imageSize: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCompressedTexImage2DARB}
+ glCompressedTexImage1DARB: procedure(target: TGLenum; level: TGLint; internalformat: TGLenum; Width: TGLsizei; border: TGLint; imageSize: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCompressedTexImage1DARB}
+ glCompressedTexSubImage3DARB: procedure(target: TGLenum; level: TGLint; xoffset, yoffset, zoffset: TGLint; width, height, depth: TGLsizei; Format: TGLenum; imageSize: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCompressedTexSubImage3DARB}
+ glCompressedTexSubImage2DARB: procedure(target: TGLenum; level: TGLint; xoffset, yoffset: TGLint; width, height: TGLsizei; Format: TGLenum; imageSize: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCompressedTexSubImage2DARB}
+ glCompressedTexSubImage1DARB: procedure(target: TGLenum; level: TGLint; xoffset: TGLint; width: TGLsizei; Format: TGLenum; imageSize: TGLsizei; data: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCompressedTexSubImage1DARB}
+ glGetCompressedTexImageARB: procedure(target: TGLenum; level: TGLint; img: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetCompressedTexImageARB}
+
+ // GL_EXT_blend_color
+ glBlendColorEXT: procedure(red, green, blue: TGLclampf; alpha: TGLclampf); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBlendColorEXT}
+
+ // GL_EXT_texture3D
+ glTexImage3DEXT: procedure(target: TGLenum; level: TGLint; internalformat: TGLenum; width, height, depth: TGLsizei; border: TGLint; Format, AType: TGLenum; pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexImage3DEXT}
+
+ // GL_SGIS_texture_filter4
+ glGetTexFilterFuncSGIS: procedure(target, Filter: TGLenum; weights: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetTexFilterFuncSGIS}
+ glTexFilterFuncSGIS: procedure(target, Filter: TGLenum; n: TGLsizei; weights: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexFilterFuncSGIS}
+
+ // GL_EXT_histogram
+ glGetHistogramEXT: procedure(target: TGLenum; reset: TGLboolean; Format, AType: TGLenum; values: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetHistogramEXT}
+ glGetHistogramParameterfvEXT: procedure(target, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetHistogramParameterfvEXT}
+ glGetHistogramParameterivEXT: procedure(target, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetHistogramParameterivEXT}
+ glGetMinmaxEXT: procedure(target: TGLenum; reset: TGLboolean; Format, AType: TGLenum; values: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetMinmaxEXT}
+ glGetMinmaxParameterfvEXT: procedure(target, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetMinmaxParameterfvEXT}
+ glGetMinmaxParameterivEXT: procedure(target, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetMinmaxParameterivEXT}
+ glHistogramEXT: procedure(target: TGLenum; Width: TGLsizei; internalformat: TGLenum; sink: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glHistogramEXT}
+ glMinmaxEXT: procedure(target, internalformat: TGLenum; sink: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMinmaxEXT}
+ glResetHistogramEXT: procedure(target: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glResetHistogramEXT}
+ glResetMinmaxEXT: procedure(target: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glResetMinmaxEXT}
+
+ // GL_EXT_convolution
+ glConvolutionFilter1DEXT: procedure(target, internalformat: TGLenum; Width: TGLsizei; Format, AType: TGLenum; image: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glConvolutionFilter1DEXT}
+ glConvolutionFilter2DEXT: procedure(target, internalformat: TGLenum; Width, Height: TGLsizei; Format, AType: TGLenum; image: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glConvolutionFilter2DEXT}
+ glConvolutionParameterfEXT: procedure(target, pname: TGLenum; params: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glConvolutionParameterfEXT}
+ glConvolutionParameterfvEXT: procedure(target, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glConvolutionParameterfvEXT}
+ glConvolutionParameteriEXT: procedure(target, pname: TGLenum; params: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glConvolutionParameteriEXT}
+ glConvolutionParameterivEXT: procedure(target, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glConvolutionParameterivEXT}
+ glCopyConvolutionFilter1DEXT: procedure(target, internalformat: TGLenum; x, y: TGLint; Width: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyConvolutionFilter1DEXT}
+ glCopyConvolutionFilter2DEXT: procedure(target, internalformat: TGLenum; x, y: TGLint; Width, Height: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyConvolutionFilter2DEXT}
+ glGetConvolutionFilterEXT: procedure(target, Format, AType: TGLenum; image: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetConvolutionFilterEXT}
+ glGetConvolutionParameterfvEXT: procedure(target, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetConvolutionParameterfvEXT}
+ glGetConvolutionParameterivEXT: procedure(target, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetConvolutionParameterivEXT}
+ glGetSeparableFilterEXT: procedure(target, Format, AType: TGLenum; row, column, span: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetSeparableFilterEXT}
+ glSeparableFilter2DEXT: procedure(target, internalformat: TGLenum; Width, Height: TGLsizei; Format, AType: TGLenum; row, column: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSeparableFilter2DEXT}
+
+ // GL_SGI_color_table
+ glColorTableSGI: procedure(target, internalformat: TGLenum; Width: TGLsizei; Format, AType: TGLenum; Table: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorTableSGI}
+ glColorTableParameterfvSGI: procedure(target, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorTableParameterfvSGI}
+ glColorTableParameterivSGI: procedure(target, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorTableParameterivSGI}
+ glCopyColorTableSGI: procedure(target, internalformat: TGLenum; x, y: TGLint; Width: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyColorTableSGI}
+ glGetColorTableSGI: procedure(target, Format, AType: TGLenum; Table: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetColorTableSGI}
+ glGetColorTableParameterfvSGI: procedure(target, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetColorTableParameterfvSGI}
+ glGetColorTableParameterivSGI: procedure(target, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetColorTableParameterivSGI}
+
+ // GL_SGIX_pixel_texture
+ glPixelTexGenSGIX: procedure(mode: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelTexGenSGIX}
+
+ // GL_SGIS_pixel_texture
+ glPixelTexGenParameteriSGIS: procedure(pname: TGLenum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelTexGenParameteriSGIS}
+ glPixelTexGenParameterivSGIS: procedure(pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelTexGenParameterivSGIS}
+ glPixelTexGenParameterfSGIS: procedure(pname: TGLenum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelTexGenParameterfSGIS}
+ glPixelTexGenParameterfvSGIS: procedure(pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelTexGenParameterfvSGIS}
+ glGetPixelTexGenParameterivSGIS: procedure(pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetPixelTexGenParameterivSGIS}
+ glGetPixelTexGenParameterfvSGIS: procedure(pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetPixelTexGenParameterfvSGIS}
+
+ // GL_SGIS_texture4D
+ glTexImage4DSGIS: procedure(target: TGLenum; level: TGLint; internalformat: TGLenum; Width, Height, depth, size4d: TGLsizei; border: TGLint; Format, AType: TGLenum; pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexImage4DSGIS}
+ glTexSubImage4DSGIS: procedure(target: TGLenum; level, xoffset, yoffset, zoffset, woffset: TGLint; Width, Height, depth, size4d: TGLsizei; Format, AType: TGLenum; pixels: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexSubImage4DSGIS}
+
+ // GL_SGIS_detail_texture
+ glDetailTexFuncSGIS: procedure(target: TGLenum; n: TGLsizei; points: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDetailTexFuncSGIS}
+ glGetDetailTexFuncSGIS: procedure(target: TGLenum; points: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetDetailTexFuncSGIS}
+
+ // GL_SGIS_sharpen_texture
+ glSharpenTexFuncSGIS: procedure(target: TGLenum; n: TGLsizei; points: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSharpenTexFuncSGIS}
+ glGetSharpenTexFuncSGIS: procedure(target: TGLenum; points: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetSharpenTexFuncSGIS}
+
+ // GL_SGIS_multisample
+ glSampleMaskSGIS: procedure(Value: TGLclampf; invert: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSampleMaskSGIS}
+ glSamplePatternSGIS: procedure(pattern: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSamplePatternSGIS}
+
+ // GL_EXT_blend_minmax
+ glBlendEquationEXT: procedure(mode: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBlendEquationEXT}
+
+ // GL_SGIX_sprite
+ glSpriteParameterfSGIX: procedure(pname: TGLenum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSpriteParameterfSGIX}
+ glSpriteParameterfvSGIX: procedure(pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSpriteParameterfvSGIX}
+ glSpriteParameteriSGIX: procedure(pname: TGLenum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSpriteParameteriSGIX}
+ glSpriteParameterivSGIX: procedure(pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSpriteParameterivSGIX}
+
+ // GL_EXT_point_parameters
+ glPointParameterfSGIS: procedure(pname: TGLenum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPointParameterfSGIS}
+ glPointParameterfvSGIS: procedure(pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPointParameterfvSGIS}
+
+ // GL_SGIX_instruments
+ glGetInstrumentsSGIX: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetInstrumentsSGIX}
+ glInstrumentsBufferSGIX: procedure(Size: TGLsizei; buffer: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glInstrumentsBufferSGIX}
+ glPollInstrumentsSGIX: procedure(marker_p: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPollInstrumentsSGIX}
+ glReadInstrumentsSGIX: procedure(marker: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReadInstrumentsSGIX}
+ glStartInstrumentsSGIX: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glStartInstrumentsSGIX}
+ glStopInstrumentsSGIX: procedure(marker: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glStopInstrumentsSGIX}
+
+ // GL_SGIX_framezoom
+ glFrameZoomSGIX: procedure(factor: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFrameZoomSGIX}
+
+ // GL_SGIX_tag_sample_buffer
+ glTagSampleBufferSGIX: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTagSampleBufferSGIX}
+
+ // GL_SGIX_polynomial_ffd
+ glDeformationMap3dSGIX: procedure(target: TGLenum; u1, u2: TGLdouble; ustride, uorder: TGLint; v1, v2: TGLdouble; vstride, vorder: TGLint; w1, w2: TGLdouble; wstride, worder: TGLint; points: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDeformationMap3dSGIX}
+ glDeformationMap3fSGIX: procedure(target: TGLenum; u1, u2: TGLfloat; ustride, uorder: TGLint; v1, v2: TGLfloat; vstride, vorder: TGLint; w1, w2: TGLfloat; wstride, worder: TGLint; points: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDeformationMap3fSGIX}
+ glDeformSGIX: procedure(mask: TGLbitfield); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDeformSGIX}
+ glLoadIdentityDeformationMapSGIX: procedure(mask: TGLbitfield); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLoadIdentityDeformationMapSGIX}
+
+ // GL_SGIX_reference_plane
+ glReferencePlaneSGIX: procedure(equation: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReferencePlaneSGIX}
+
+ // GL_SGIX_flush_raster
+ glFlushRasterSGIX: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFlushRasterSGIX}
+
+ // GL_SGIS_fog_function
+ glFogFuncSGIS: procedure(n: TGLsizei; points: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFogFuncSGIS}
+ glGetFogFuncSGIS: procedure(points: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetFogFuncSGIS}
+
+ // GL_HP_image_transform
+ glImageTransformParameteriHP: procedure(target, pname: TGLenum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glImageTransformParameteriHP}
+ glImageTransformParameterfHP: procedure(target, pname: TGLenum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glImageTransformParameterfHP}
+ glImageTransformParameterivHP: procedure(target, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glImageTransformParameterivHP}
+ glImageTransformParameterfvHP: procedure(target, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glImageTransformParameterfvHP}
+ glGetImageTransformParameterivHP: procedure(target, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetImageTransformParameterivHP}
+ glGetImageTransformParameterfvHP: procedure(target, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetImageTransformParameterfvHP}
+
+ // GL_EXT_color_subtable
+ glCopyColorSubTableEXT: procedure(target: TGLenum; start: TGLsizei; x, y: TGLint; Width: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCopyColorSubTableEXT}
+
+ // GL_PGI_misc_hints
+ glHintPGI: procedure(target: TGLenum; mode: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glHintPGI}
+
+ // GL_EXT_paletted_texture
+ glGetColorTableParameterivEXT: procedure(target, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetColorTableParameterivEXT}
+ glGetColorTableParameterfvEXT: procedure(target, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetColorTableParameterfvEXT}
+
+ // GL_SGIX_list_priority
+ glGetListParameterfvSGIX: procedure(list: TGLuint; pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetListParameterfvSGIX}
+ glGetListParameterivSGIX: procedure(list: TGLuint; pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetListParameterivSGIX}
+ glListParameterfSGIX: procedure(list: TGLuint; pname: TGLenum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glListParameterfSGIX}
+ glListParameterfvSGIX: procedure(list: TGLuint; pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glListParameterfvSGIX}
+ glListParameteriSGIX: procedure(list: TGLuint; pname: TGLenum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glListParameteriSGIX}
+ glListParameterivSGIX: procedure(list: TGLuint; pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glListParameterivSGIX}
+
+ // GL_SGIX_fragment_lighting
+ glFragmentColorMaterialSGIX: procedure(face, mode: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentColorMaterialSGIX}
+ glFragmentLightfSGIX: procedure(light, pname: TGLenum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentLightfSGIX}
+ glFragmentLightfvSGIX: procedure(light, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentLightfvSGIX}
+ glFragmentLightiSGIX: procedure(light, pname: TGLenum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentLightiSGIX}
+ glFragmentLightivSGIX: procedure(light, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentLightivSGIX}
+ glFragmentLightModelfSGIX: procedure(pname: TGLenum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentLightModelfSGIX}
+ glFragmentLightModelfvSGIX: procedure(pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentLightModelfvSGIX}
+ glFragmentLightModeliSGIX: procedure(pname: TGLenum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentLightModeliSGIX}
+ glFragmentLightModelivSGIX: procedure(pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentLightModelivSGIX}
+ glFragmentMaterialfSGIX: procedure(face, pname: TGLenum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentMaterialfSGIX}
+ glFragmentMaterialfvSGIX: procedure(face, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentMaterialfvSGIX}
+ glFragmentMaterialiSGIX: procedure(face, pname: TGLenum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentMaterialiSGIX}
+ glFragmentMaterialivSGIX: procedure(face, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFragmentMaterialivSGIX}
+ glGetFragmentLightfvSGIX: procedure(light, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetFragmentLightfvSGIX}
+ glGetFragmentLightivSGIX: procedure(light, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetFragmentLightivSGIX}
+ glGetFragmentMaterialfvSGIX: procedure(face, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetFragmentMaterialfvSGIX}
+ glGetFragmentMaterialivSGIX: procedure(face, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetFragmentMaterialivSGIX}
+ glLightEnviSGIX: procedure(pname: TGLenum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLightEnviSGIX}
+
+ // GL_EXT_draw_range_elements
+ glDrawRangeElementsEXT: procedure(mode: TGLenum; start, Aend: TGLuint; Count: TGLsizei; Atype: TGLenum; indices: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDrawRangeElementsEXT}
+
+ // GL_EXT_light_texture
+ glApplyTextureEXT: procedure(mode: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glApplyTextureEXT}
+ glTextureLightEXT: procedure(pname: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTextureLightEXT}
+ glTextureMaterialEXT: procedure(face, mode: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTextureMaterialEXT}
+
+ // GL_SGIX_async
+ glAsyncMarkerSGIX: procedure(marker: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glAsyncMarkerSGIX}
+ glFinishAsyncSGIX: procedure(markerp: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFinishAsyncSGIX}
+ glPollAsyncSGIX: procedure(markerp: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPollAsyncSGIX}
+ glGenAsyncMarkersSGIX: procedure(range: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGenAsyncMarkersSGIX}
+ glDeleteAsyncMarkersSGIX: procedure(marker: TGLuint; range: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDeleteAsyncMarkersSGIX}
+ glIsAsyncMarkerSGIX: procedure(marker: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIsAsyncMarkerSGIX}
+
+ // GL_INTEL_parallel_arrays
+ glVertexPointervINTEL: procedure(size: TGLint; Atype: TGLenum; var P); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexPointervINTEL}
+ glNormalPointervINTEL: procedure(Atype: TGLenum; var P); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormalPointervINTEL}
+ glColorPointervINTEL: procedure(size: TGLint; Atype: TGLenum; var P); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorPointervINTEL}
+ glTexCoordPointervINTEL: procedure(size: TGLint; Atype: TGLenum; var P); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoordPointervINTEL}
+
+ // GL_EXT_pixel_transform
+ glPixelTransformParameteriEXT: procedure(target, pname: TGLenum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelTransformParameteriEXT}
+ glPixelTransformParameterfEXT: procedure(target, pname: TGLenum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelTransformParameterfEXT}
+ glPixelTransformParameterivEXT: procedure(target, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelTransformParameterivEXT}
+ glPixelTransformParameterfvEXT: procedure(target, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glPixelTransformParameterfvEXT}
+
+ // GL_EXT_secondary_color
+ glSecondaryColor3bEXT: procedure(red, green, blue: TGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3bEXT}
+ glSecondaryColor3bvEXT: procedure(v: PGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3bvEXT}
+ glSecondaryColor3dEXT: procedure(red, green, blue: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3dEXT}
+ glSecondaryColor3dvEXT: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3dvEXT}
+ glSecondaryColor3fEXT: procedure(red, green, blue: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3fEXT}
+ glSecondaryColor3fvEXT: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3fvEXT}
+ glSecondaryColor3iEXT: procedure(red, green, blue: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3iEXT}
+ glSecondaryColor3ivEXT: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3ivEXT}
+
+ glSecondaryColor3sEXT: procedure(red, green, blue: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3sEXT}
+ glSecondaryColor3svEXT: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3svEXT}
+ glSecondaryColor3ubEXT: procedure(red, green, blue: TGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3ubEXT}
+ glSecondaryColor3ubvEXT: procedure(v: PGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3ubvEXT}
+ glSecondaryColor3uiEXT: procedure(red, green, blue: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3uiEXT}
+ glSecondaryColor3uivEXT: procedure(v: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3uivEXT}
+ glSecondaryColor3usEXT: procedure(red, green, blue: TGLushort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3usEXT}
+ glSecondaryColor3usvEXT: procedure(v: PGLushort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColor3usvEXT}
+ glSecondaryColorPointerEXT: procedure(Size: TGLint; Atype: TGLenum; stride: TGLsizei; p: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColorPointerEXT}
+
+ // GL_EXT_texture_perturb_normal
+ glTextureNormalEXT: procedure(mode: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTextureNormalEXT}
+
+ // GL_EXT_multi_draw_arrays
+ glMultiDrawArraysEXT: procedure(mode: TGLenum; First: PGLint; Count: PGLsizei; primcount: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiDrawArraysEXT}
+ glMultiDrawElementsEXT: procedure(mode: TGLenum; Count: PGLsizei; AType: TGLenum; var indices; primcount: TGLsizei); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiDrawElementsEXT}
+
+ // GL_EXT_fog_coord
+ glFogCoordfEXT: procedure(coord: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFogCoordfEXT}
+ glFogCoordfvEXT: procedure(coord: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFogCoordfvEXT}
+ glFogCoorddEXT: procedure(coord: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFogCoorddEXT}
+ glFogCoorddvEXT: procedure(coord: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFogCoorddvEXT}
+ glFogCoordPointerEXT: procedure(AType: TGLenum; stride: TGLsizei; p: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFogCoordPointerEXT}
+
+ // GL_EXT_coordinate_frame
+ glTangent3bEXT: procedure(tx, ty, tz: TGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTangent3bEXT}
+ glTangent3bvEXT: procedure(v: PGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTangent3bvEXT}
+ glTangent3dEXT: procedure(tx, ty, tz: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTangent3dEXT}
+ glTangent3dvEXT: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTangent3dvEXT}
+ glTangent3fEXT: procedure(tx, ty, tz: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTangent3fEXT}
+ glTangent3fvEXT: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTangent3fvEXT}
+ glTangent3iEXT: procedure(tx, ty, tz: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTangent3iEXT}
+ glTangent3ivEXT: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTangent3ivEXT}
+ glTangent3sEXT: procedure(tx, ty, tz: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTangent3sEXT}
+ glTangent3svEXT: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTangent3svEXT}
+
+ glBinormal3bEXT: procedure(bx, by, bz: TGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBinormal3bEXT}
+ glBinormal3bvEXT: procedure(v: PGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBinormal3bvEXT}
+ glBinormal3dEXT: procedure(bx, by, bz: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBinormal3dEXT}
+ glBinormal3dvEXT: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBinormal3dvEXT}
+ glBinormal3fEXT: procedure(bx, by, bz: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBinormal3fEXT}
+ glBinormal3fvEXT: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBinormal3fvEXT}
+ glBinormal3iEXT: procedure(bx, by, bz: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBinormal3iEXT}
+ glBinormal3ivEXT: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBinormal3ivEXT}
+ glBinormal3sEXT: procedure(bx, by, bz: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBinormal3sEXT}
+ glBinormal3svEXT: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBinormal3svEXT}
+ glTangentPointerEXT: procedure(Atype: TGLenum; stride: TGLsizei; p: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTangentPointerEXT}
+ glBinormalPointerEXT: procedure(Atype: TGLenum; stride: TGLsizei; p: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBinormalPointerEXT}
+
+ // GL_SUNX_constant_data
+ glFinishTextureSUNX: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFinishTextureSUNX}
+
+ // GL_SUN_global_alpha
+ glGlobalAlphaFactorbSUN: procedure(factor: TGLbyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGlobalAlphaFactorbSUN}
+ glGlobalAlphaFactorsSUN: procedure(factor: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGlobalAlphaFactorsSUN}
+ glGlobalAlphaFactoriSUN: procedure(factor: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGlobalAlphaFactoriSUN}
+ glGlobalAlphaFactorfSUN: procedure(factor: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGlobalAlphaFactorfSUN}
+ glGlobalAlphaFactordSUN: procedure(factor: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGlobalAlphaFactordSUN}
+ glGlobalAlphaFactorubSUN: procedure(factor: TGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGlobalAlphaFactorubSUN}
+ glGlobalAlphaFactorusSUN: procedure(factor: TGLushort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGlobalAlphaFactorusSUN}
+ glGlobalAlphaFactoruiSUN: procedure(factor: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGlobalAlphaFactoruiSUN}
+
+ // GL_SUN_triangle_list
+ glReplacementCodeuiSUN: procedure(code: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiSUN}
+ glReplacementCodeusSUN: procedure(code: TGLushort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeusSUN}
+ glReplacementCodeubSUN: procedure(code: TGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeubSUN}
+ glReplacementCodeuivSUN: procedure(code: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuivSUN}
+ glReplacementCodeusvSUN: procedure(code: PGLushort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeusvSUN}
+ glReplacementCodeubvSUN: procedure(code: PGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeubvSUN}
+ glReplacementCodePointerSUN: procedure(Atype: TGLenum; stride: TGLsizei; var p); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodePointerSUN}
+
+ // GL_SUN_vertex
+ glColor4ubVertex2fSUN: procedure(r, g, b, a: TGLubyte; x, y: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4ubVertex2fSUN}
+ glColor4ubVertex2fvSUN: procedure(c: PGLubyte; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4ubVertex2fvSUN}
+ glColor4ubVertex3fSUN: procedure(r, g, b, a: TGLubyte; x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4ubVertex3fSUN}
+ glColor4ubVertex3fvSUN: procedure(c: PGLubyte; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4ubVertex3fvSUN}
+ glColor3fVertex3fSUN: procedure(r, g, b, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3fVertex3fSUN}
+ glColor3fVertex3fvSUN: procedure(c, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor3fVertex3fvSUN}
+ glNormal3fVertex3fSUN: procedure(nx, ny, nz: TGLfloat; x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormal3fVertex3fSUN}
+ glNormal3fVertex3fvSUN: procedure(n, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormal3fVertex3fvSUN}
+ glColor4fNormal3fVertex3fSUN: procedure(r, g, b, a, nx, ny, nz, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4fNormal3fVertex3fSUN}
+ glColor4fNormal3fVertex3fvSUN: procedure(c, n, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColor4fNormal3fVertex3fvSUN}
+ glTexCoord2fVertex3fSUN: procedure(s, t, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2fVertex3fSUN}
+ glTexCoord2fVertex3fvSUN: procedure(tc, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2fVertex3fvSUN}
+ glTexCoord4fVertex4fSUN: procedure(s, t, p, q, x, y, z, w: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord4fVertex4fSUN}
+ glTexCoord4fVertex4fvSUN: procedure(tc, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord4fVertex4fvSUN}
+ glTexCoord2fColor4ubVertex3fSUN: procedure(s, t, r, g, b, a, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2fColor4ubVertex3fSUN}
+ glTexCoord2fColor4ubVertex3fvSUN: procedure(tc: PGLfloat; c: PGLubyte; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2fColor4ubVertex3fvSUN}
+ glTexCoord2fColor3fVertex3fSUN: procedure(s, t, r, g, b, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2fColor3fVertex3fSUN}
+ glTexCoord2fColor3fVertex3fvSUN: procedure(tc, c, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2fColor3fVertex3fvSUN}
+ glTexCoord2fNormal3fVertex3fSUN: procedure(s, t, nx, ny, nz, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2fNormal3fVertex3fSUN}
+ glTexCoord2fNormal3fVertex3fvSUN: procedure(tc, n, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2fNormal3fVertex3fvSUN}
+ glTexCoord2fColor4fNormal3fVertex3fSUN: procedure(s, t, r, g, b, a, nx, ny, nz, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2fColor4fNormal3fVertex3fSUN}
+ glTexCoord2fColor4fNormal3fVertex3fvSUN: procedure(tc, c, n, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord2fColor4fNormal3fVertex3fvSUN}
+ glTexCoord4fColor4fNormal3fVertex4fSUN: procedure(s, t, p, q, r, g, b, a, nx, ny, nz, x, y, z, w: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord4fColor4fNormal3fVertex4fSUN}
+ glTexCoord4fColor4fNormal3fVertex4fvSUN: procedure(tc, c, n, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoord4fColor4fNormal3fVertex4fvSUN}
+ glReplacementCodeuiVertex3fSUN: procedure(rc: TGLenum; x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiVertex3fSUN}
+ glReplacementCodeuiVertex3fvSUN: procedure(rc: PGLenum; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiVertex3fvSUN}
+ glReplacementCodeuiColor4ubVertex3fSUN: procedure(rc: TGLenum; r, g, b, a: TGLubyte; x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiColor4ubVertex3fSUN}
+ glReplacementCodeuiColor4ubVertex3fvSUN: procedure(rc: PGLenum; c: PGLubyte; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiColor4ubVertex3fvSUN}
+ glReplacementCodeuiColor3fVertex3fSUN: procedure(rc: TGLenum; r, g, b, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiColor3fVertex3fSUN}
+ glReplacementCodeuiColor3fVertex3fvSUN: procedure(rc: PGLenum; c, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiColor3fVertex3fvSUN}
+ glReplacementCodeuiNormal3fVertex3fSUN: procedure(rc: TGLenum; nx, ny, nz, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiNormal3fVertex3fSUN}
+ glReplacementCodeuiNormal3fVertex3fvSUN: procedure(rc: PGLenum; n, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiNormal3fVertex3fvSUN}
+ glReplacementCodeuiColor4fNormal3fVertex3fSUN: procedure(rc: TGLenum; r, g, b, a, nx, ny, nz, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiColor4fNormal3fVertex3fSUN}
+ glReplacementCodeuiColor4fNormal3fVertex3fvSUN: procedure(rc: PGLenum; c, n, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiColor4fNormal3fVertex3fvSUN}
+ glReplacementCodeuiTexCoord2fVertex3fSUN: procedure(rc: TGLenum; s, t, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiTexCoord2fVertex3fSUN}
+ glReplacementCodeuiTexCoord2fVertex3fvSUN: procedure(rc: PGLenum; tc, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiTexCoord2fVertex3fvSUN}
+ glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN: procedure(rc: TGLenum; s, t, nx, ny, nz, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN}
+ glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN: procedure(rc: PGLenum; tc, n, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN}
+ glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN: procedure(rc: TGLenum; s, t, r, g, b, a, nx, ny, nz, x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN}
+ glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN: procedure(rc: PGLenum; tc, c, n, v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN}
+
+ // GL_EXT_blend_func_separate
+ glBlendFuncSeparateEXT: procedure(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBlendFuncSeparateEXT}
+
+ // GL_EXT_vertex_weighting
+ glVertexWeightfEXT: procedure(weight: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexWeightfEXT}
+ glVertexWeightfvEXT: procedure(weight: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexWeightfvEXT}
+ glVertexWeightPointerEXT: procedure(Size: TGLsizei; Atype: TGLenum; stride: TGLsizei; p: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexWeightPointerEXT}
+
+ // GL_NV_vertex_array_range
+ glFlushVertexArrayRangeNV: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFlushVertexArrayRangeNV}
+ glVertexArrayRangeNV: procedure(Size: TGLsizei; p: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexArrayRangeNV}
+ wglAllocateMemoryNV: function(size: TGLsizei; readFrequency, writeFrequency, priority: Single): Pointer; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM wglAllocateMemoryNV}
+ wglFreeMemoryNV: procedure(ptr: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM wglFreeMemoryNV}
+
+ // GL_NV_register_combiners
+ glCombinerParameterfvNV: procedure(pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCombinerParameterfvNV}
+ glCombinerParameterfNV: procedure(pname: TGLenum; param: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCombinerParameterfNV}
+ glCombinerParameterivNV: procedure(pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCombinerParameterivNV}
+ glCombinerParameteriNV: procedure(pname: TGLenum; param: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCombinerParameteriNV}
+ glCombinerInputNV: procedure(stage, portion, variable, input, mapping, componentUsage: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCombinerInputNV}
+ glCombinerOutputNV: procedure(stage, portion, abOutput, cdOutput, sumOutput, scale, bias: TGLenum; abDotProduct, cdDotProduct, muxSum: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glCombinerOutputNV}
+ glFinalCombinerInputNV: procedure(variable, input, mapping, componentUsage: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFinalCombinerInputNV}
+ glGetCombinerInputParameterfvNV: procedure(stage, portion, variable, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetCombinerInputParameterfvNV}
+ glGetCombinerInputParameterivNV: procedure(stage, portion, variable, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetCombinerInputParameterivNV}
+ glGetCombinerOutputParameterfvNV: procedure(stage, portion, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetCombinerOutputParameterfvNV}
+ glGetCombinerOutputParameterivNV: procedure(stage, portion, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetCombinerOutputParameterivNV}
+ glGetFinalCombinerInputParameterfvNV: procedure(variable, pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetFinalCombinerInputParameterfvNV}
+ glGetFinalCombinerInputParameterivNV: procedure(variable, pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetFinalCombinerInputParameterivNV}
+
+ // GL_MESA_resize_buffers
+ glResizeBuffersMESA: procedure; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glResizeBuffersMESA}
+
+ // GL_MESA_window_pos
+ glWindowPos2dMESA: procedure(x, y: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos2dMESA}
+ glWindowPos2dvMESA: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos2dvMESA}
+ glWindowPos2fMESA: procedure(x, y: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos2fMESA}
+ glWindowPos2fvMESA: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos2fvMESA}
+ glWindowPos2iMESA: procedure(x, y: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos2iMESA}
+ glWindowPos2ivMESA: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos2ivMESA}
+ glWindowPos2sMESA: procedure(x, y: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos2sMESA}
+ glWindowPos2svMESA: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos2svMESA}
+ glWindowPos3dMESA: procedure(x, y, z: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos3dMESA}
+ glWindowPos3dvMESA: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos3dvMESA}
+ glWindowPos3fMESA: procedure(x, y, z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos3fMESA}
+ glWindowPos3fvMESA: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos3fvMESA}
+ glWindowPos3iMESA: procedure(x, y, z: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos3iMESA}
+ glWindowPos3ivMESA: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos3ivMESA}
+ glWindowPos3sMESA: procedure(x, y, z: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos3sMESA}
+ glWindowPos3svMESA: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos3svMESA}
+ glWindowPos4dMESA: procedure(x, y, z, w: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos4dMESA}
+ glWindowPos4dvMESA: procedure(v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos4dvMESA}
+ glWindowPos4fMESA: procedure(x, y, z, w: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos4fMESA}
+ glWindowPos4fvMESA: procedure(v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos4fvMESA}
+ glWindowPos4iMESA: procedure(x, y, z, w: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos4iMESA}
+ glWindowPos4ivMESA: procedure(v: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos4ivMESA}
+ glWindowPos4sMESA: procedure(x, y, z, w: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos4sMESA}
+ glWindowPos4svMESA: procedure(v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glWindowPos4svMESA}
+
+ // GL_IBM_multimode_draw_arrays
+ glMultiModeDrawArraysIBM: procedure(mode: TGLenum; First: PGLint; Count: PGLsizei; primcount: TGLsizei; modestride: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiModeDrawArraysIBM}
+ glMultiModeDrawElementsIBM: procedure(mode: PGLenum; Count: PGLsizei; Atype: TGLenum; var indices; primcount: TGLsizei; modestride: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glMultiModeDrawElementsIBM}
+
+ // GL_IBM_vertex_array_lists
+ glColorPointerListIBM: procedure(Size: TGLint; Atype: TGLenum; stride: TGLint; var p; ptrstride: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glColorPointerListIBM}
+ glSecondaryColorPointerListIBM: procedure(Size: TGLint; Atype: TGLenum; stride: TGLint; var p; ptrstride: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSecondaryColorPointerListIBM}
+ glEdgeFlagPointerListIBM: procedure(stride: TGLint; var p: PGLboolean; ptrstride: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glEdgeFlagPointerListIBM}
+ glFogCoordPointerListIBM: procedure(Atype: TGLenum; stride: TGLint; var p; ptrstride: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glFogCoordPointerListIBM}
+ glIndexPointerListIBM: procedure(Atype: TGLenum; stride: TGLint; var p; ptrstride: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIndexPointerListIBM}
+ glNormalPointerListIBM: procedure(Atype: TGLenum; stride: TGLint; var p; ptrstride: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glNormalPointerListIBM}
+ glTexCoordPointerListIBM: procedure(Size: TGLint; Atype: TGLenum; stride: TGLint; var p; ptrstride: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTexCoordPointerListIBM}
+ glVertexPointerListIBM: procedure(Size: TGLint; Atype: TGLenum; stride: TGLint; var p; ptrstride: TGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexPointerListIBM}
+
+ // GL_3DFX_tbuffer
+ glTbufferMask3DFX: procedure(mask: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTbufferMask3DFX}
+
+ // GL_EXT_multisample
+ glSampleMaskEXT: procedure(Value: TGLclampf; invert: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSampleMaskEXT}
+ glSamplePatternEXT: procedure(pattern: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glSamplePatternEXT}
+
+ // GL_SGIS_texture_color_mask
+ glTextureColorMaskSGIS: procedure(red, green, blue, alpha: TGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTextureColorMaskSGIS}
+
+ // GL_SGIX_igloo_interface
+ glIglooInterfaceSGIX: procedure(pname: TGLenum; params: pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIglooInterfaceSGIX}
+
+ // GL_NV_vertex_program
+ glAreProgramsResidentNV: procedure(n: TGLSizei; programs: PGLuint; residences: PGLboolean); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glAreProgramsResidentNV}
+ glBindProgramNV: procedure(target: TGLenum; id: TGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glBindProgramNV}
+ glDeleteProgramsNV: procedure(n: TGLSizei; programs: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glDeleteProgramsNV}
+ glExecuteProgramNV: procedure(target: TGLenum; id: TGLuint; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glExecuteProgramNV}
+ glGenProgramsNV: procedure(n: TGLSizei; programs: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGenProgramsNV}
+ glGetProgramParameterdvNV: procedure (target: TGLenum; index: TGLuint; pname: TGLenum; params: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetProgramParameterdvNV}
+ glGetProgramParameterfvNV: procedure (target: TGLenum; index: TGLuint; pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetProgramParameterfvNV}
+ glGetProgramivNV: procedure (id: TGLuint; pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetProgramivNV}
+ glGetProgramStringNV: procedure (id: TGLuint; pname: TGLenum; programIdx: PGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetProgramStringNV}
+ glGetTrackMatrixivNV: procedure (target: TGLenum; address: TGLuint; pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetTrackMatrixivNV}
+ glGetVertexAttribdvNV: procedure (index: TGLuint; pname: TGLenum; params: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetVertexAttribdvNV}
+ glGetVertexAttribfvNV: procedure (index: TGLuint; pname: TGLenum; params: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetVertexAttribfvNV}
+ glGetVertexAttribivNV: procedure (index: TGLuint; pname: TGLenum; params: PGLint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetVertexAttribivNV}
+ glGetVertexAttribPointervNV: procedure (index: TGLuint; pname: TGLenum; pointer: PPointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glGetVertexAttribPointervNV}
+ glIsProgramNV: function (id: TGLuint): TGLboolean; {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glIsProgramNV}
+ glLoadProgramNV: procedure (target: TGLenum; id: TGLuint; len: TGLSizei; programIdx: PGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glLoadProgramNV}
+ glProgramParameter4dNV: procedure (target: TGLenum; index: TGLuint; x, y, z, w: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glProgramParameter4dNV}
+ glProgramParameter4dvNV: procedure (target: TGLenum; index: TGLuint; v: PGLdouble ); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glProgramParameter4dvNV}
+ glProgramParameter4fNV: procedure (target: TGLenum; index: TGLuint; x, y, z, w: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glProgramParameter4fNV}
+ glProgramParameter4fvNV: procedure (target: TGLenum; index: TGLuint; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glProgramParameter4fvNV}
+ glProgramParameters4dvNV: procedure (target: TGLenum; index: TGLuint; count: TGLSizei; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glProgramParameters4dvNV}
+ glProgramParameters4fvNV: procedure (target: TGLenum; index: TGLuint; count: TGLSizei; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glProgramParameters4fvNV}
+ glRequestResidentProgramsNV: procedure (n: TGLSizei; programs: PGLuint); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glRequestResidentProgramsNV}
+ glTrackMatrixNV: procedure (target: TGLenum; address: TGLuint; matrix: TGLenum; transform: TGLenum); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glTrackMatrixNV}
+ glVertexAttribPointerNV: procedure (index: TGLuint; fsize: TGLint; vertextype: TGLenum; stride: TGLSizei; pointer: Pointer); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribPointerNV}
+ glVertexAttrib1dNV: procedure (index: TGLuint; x: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib1dNV}
+ glVertexAttrib1dvNV: procedure (index: TGLuint; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib1dvNV}
+ glVertexAttrib1fNV: procedure (index: TGLuint; x: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib1fNV}
+ glVertexAttrib1fvNV: procedure (index: TGLuint; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib1fvNV}
+ glVertexAttrib1sNV: procedure (index: TGLuint; x: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib1sNV}
+ glVertexAttrib1svNV: procedure (index: TGLuint; v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib1svNV}
+ glVertexAttrib2dNV: procedure (index: TGLuint; x: TGLdouble; y: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib2dNV}
+ glVertexAttrib2dvNV: procedure (index: TGLuint; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib2dvNV}
+ glVertexAttrib2fNV: procedure (index: TGLuint; x: TGLfloat; y: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib2fNV}
+ glVertexAttrib2fvNV: procedure (index: TGLuint; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib2fvNV}
+ glVertexAttrib2sNV: procedure (index: TGLuint; x: TGLshort; y: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib2sNV}
+ glVertexAttrib2svNV: procedure (index: TGLuint; v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib2svNV}
+ glVertexAttrib3dNV: procedure (index: TGLuint; x: TGLdouble; y: TGLdouble; z: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib3dNV}
+ glVertexAttrib3dvNV: procedure (index: TGLuint; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib3dvNV}
+ glVertexAttrib3fNV: procedure (index: TGLuint; x: TGLfloat; y: TGLfloat; z: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib3fNV}
+ glVertexAttrib3fvNV: procedure (index: TGLuint; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib3fvNV}
+ glVertexAttrib3sNV: procedure (index: TGLuint; x: TGLshort; y: TGLshort; z: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib3sNV}
+ glVertexAttrib3svNV: procedure (index: TGLuint; v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib3svNV}
+ glVertexAttrib4dNV: procedure (index: TGLuint; x: TGLdouble; y: TGLdouble; z: TGLdouble; w: TGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib4dNV}
+ glVertexAttrib4dvNV: procedure (index: TGLuint; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib4dvNV}
+ glVertexAttrib4fNV: procedure(index: TGLuint; x: TGLfloat; y: TGLfloat; z: TGLfloat; w: TGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib4fNV}
+ glVertexAttrib4fvNV: procedure(index: TGLuint; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib4fvNV}
+ glVertexAttrib4sNV: procedure (index: TGLuint; x: TGLshort; y: TGLshort; z: TGLdouble; w: TGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib4sNV}
+ glVertexAttrib4svNV: procedure (index: TGLuint; v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib4svNV}
+ glVertexAttrib4ubvNV: procedure (index: TGLuint; v: PGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttrib4ubvNV}
+ glVertexAttribs1dvNV: procedure (index: TGLuint; count: TGLSizei; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs1dvNV}
+ glVertexAttribs1fvNV: procedure (index: TGLuint; count: TGLSizei; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs1fvNV}
+ glVertexAttribs1svNV: procedure (index: TGLuint; count: TGLSizei; v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs1svNV}
+ glVertexAttribs2dvNV: procedure (index: TGLuint; count: TGLSizei; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs2dvNV}
+ glVertexAttribs2fvNV: procedure (index: TGLuint; count: TGLSizei; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs2fvNV}
+ glVertexAttribs2svNV: procedure (index: TGLuint; count: TGLSizei; v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs2svNV}
+ glVertexAttribs3dvNV: procedure (index: TGLuint; count: TGLSizei; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs3dvNV}
+ glVertexAttribs3fvNV: procedure (index: TGLuint; count: TGLSizei; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs3fvNV}
+ glVertexAttribs3svNV: procedure (index: TGLuint; count: TGLSizei; v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs3svNV}
+ glVertexAttribs4dvNV: procedure (index: TGLuint; count: TGLSizei; v: PGLdouble); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs4dvNV}
+ glVertexAttribs4fvNV: procedure (index: TGLuint; count: TGLSizei; v: PGLfloat); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs4fvNV}
+ glVertexAttribs4svNV: procedure (index: TGLuint; count: TGLSizei; v: PGLshort); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs4svNV}
+ glVertexAttribs4ubvNV: procedure (index: TGLuint; count: TGLSizei; v: PGLubyte); {$ifdef Win32} stdcall; {$endif} {$ifdef UNIX} cdecl; {$endif}
+ {$EXTERNALSYM glVertexAttribs4ubvNV}
+
+{$ifdef UNIX}
+type
+ GLXContext = Pointer;
+ GLXPixmap = XID;
+ GLXDrawable = XID;
+
+ // GLX 1.3 and later
+ GLXFBConfig = Pointer;
+ GLXFBConfigID = XID;
+ GLXContextID = XID;
+ GLXWindow = XID;
+ GLXPbuffer = XID;
+
+var
+ glXChooseVisual: function(dpy: PDisplay; screen: TGLint; attribList: PGLint): PXVisualInfo; cdecl;
+ {$EXTERNALSYM glXChooseVisual}
+ glXCreateContext: function(dpy: PDisplay; vis: PXVisualInfo; shareList: GLXContext; direct: TGLboolean): GLXContext; cdecl;
+ {$EXTERNALSYM glXCreateContext}
+ glXDestroyContext: procedure(dpy: PDisplay; ctx: GLXContext); cdecl;
+ {$EXTERNALSYM glXDestroyContext}
+ glXMakeCurrent: function(dpy: PDisplay; drawable: GLXDrawable; ctx: GLXContext): TGLboolean; cdecl;
+ {$EXTERNALSYM glXMakeCurrent}
+ glXCopyContext: procedure(dpy: PDisplay; src: GLXContext; dst: GLXContext; mask: TGLuint); cdecl;
+ {$EXTERNALSYM glXCopyContext}
+ glXSwapBuffers: procedure(dpy: PDisplay; drawable: GLXDrawable); cdecl;
+ {$EXTERNALSYM glXSwapBuffers}
+ glXCreateGLXPixmap: function(dpy: PDisplay; visual: PXVisualInfo; pixmap: Pixmap): GLXPixmap; cdecl;
+ {$EXTERNALSYM glXCreateGLXPixmap}
+ glXDestroyGLXPixmap: procedure(dpy: PDisplay; pixmap: GLXPixmap); cdecl;
+ {$EXTERNALSYM glXDestroyGLXPixmap}
+ glXQueryExtension: function(dpy: PDisplay; errorb: PGLInt; event: PGLInt): TGLboolean; cdecl;
+ {$EXTERNALSYM glXQueryExtension}
+ glXQueryVersion: function(dpy: PDisplay; maj: PGLInt; min: PGLINT): TGLboolean; cdecl;
+ {$EXTERNALSYM glXQueryVersion}
+ glXIsDirect: function(dpy: PDisplay; ctx: GLXContext): TGLboolean; cdecl;
+ {$EXTERNALSYM glXIsDirect}
+ glXGetConfig: function(dpy: PDisplay; visual: PXVisualInfo; attrib: TGLInt; value: PGLInt): TGLInt; cdecl;
+ {$EXTERNALSYM glXGetConfig}
+ glXGetCurrentContext: function: GLXContext; cdecl;
+ {$EXTERNALSYM glXGetCurrentContext}
+ glXGetCurrentDrawable: function: GLXDrawable; cdecl;
+ {$EXTERNALSYM glXGetCurrentDrawable}
+ glXWaitGL: procedure; cdecl;
+ {$EXTERNALSYM glXWaitGL}
+ glXWaitX: procedure; cdecl;
+ {$EXTERNALSYM glXWaitX}
+ glXUseXFont: procedure(font: Font; first: TGLInt; count: TGLInt; list: TGLint); cdecl;
+ {$EXTERNALSYM glXUseXFont}
+
+ // GLX 1.1 and later
+ glXQueryExtensionsString: function(dpy: PDisplay; screen: TGLInt): PChar; cdecl;
+ {$EXTERNALSYM glXQueryExtensionsString}
+ glXQueryServerString: function(dpy: PDisplay; screen: TGLInt; name: TGLInt): PChar; cdecl;
+ {$EXTERNALSYM glXQueryServerString}
+ glXGetClientString: function(dpy: PDisplay; name: TGLInt): PChar; cdecl;
+ {$EXTERNALSYM glXGetClientString}
+
+ // GLX 1.2 and later
+ glXGetCurrentDisplay: function: PDisplay; cdecl;
+ {$EXTERNALSYM glXGetCurrentDisplay}
+
+ // GLX 1.3 and later
+ glXChooseFBConfig: function(dpy: PDisplay; screen: TGLInt; attribList: PGLInt; nitems: PGLInt): GLXFBConfig; cdecl;
+ {$EXTERNALSYM glXChooseFBConfig}
+ glXGetFBConfigAttrib: function(dpy: PDisplay; config: GLXFBConfig; attribute: TGLInt; value: PGLInt): TGLInt; cdecl;
+ {$EXTERNALSYM glXGetFBConfigAttrib}
+ glXGetFBConfigs: function(dpy: PDisplay; screen: TGLInt; nelements: PGLInt): GLXFBConfig; cdecl;
+ {$EXTERNALSYM glXGetFBConfigs}
+ glXGetVisualFromFBConfig: function(dpy: PDisplay; config: GLXFBConfig): PXVisualInfo; cdecl;
+ {$EXTERNALSYM glXGetVisualFromFBConfig}
+ glXCreateWindow: function(dpy: PDisplay; config: GLXFBConfig; win: Window; const attribList: PGLInt): GLXWindow; cdecl;
+ {$EXTERNALSYM glXCreateWindow}
+ glXDestroyWindow: procedure(dpy: PDisplay; window: GLXWindow); cdecl;
+ {$EXTERNALSYM glXDestroyWindow}
+ glXCreatePixmap: function(dpy: PDisplay; config: GLXFBConfig; pixmap: Pixmap; attribList: PGLInt): GLXPixmap; cdecl;
+ {$EXTERNALSYM glXCreatePixmap}
+ glXDestroyPixmap: procedure(dpy: PDisplay; pixmap: GLXPixmap); cdecl;
+ {$EXTERNALSYM glXDestroyPixmap}
+ glXCreatePbuffer: function(dpy: PDisplay; config: GLXFBConfig; attribList: PGLInt): GLXPBuffer; cdecl;
+ {$EXTERNALSYM glXCreatePbuffer}
+ glXDestroyPbuffer: procedure(dpy: PDisplay; pbuf: GLXPBuffer); cdecl;
+ {$EXTERNALSYM glXDestroyPbuffer}
+ glXQueryDrawable: procedure(dpy: PDisplay; draw: GLXDrawable; attribute: TGLInt; value: PGLuint); cdecl;
+ {$EXTERNALSYM glXQueryDrawable}
+ glXCreateNewContext: function(dpy: PDisplay; config: GLXFBConfig; renderType: TGLInt; shareList: GLXContext; direct: TGLboolean): GLXContext; cdecl;
+ {$EXTERNALSYM glXCreateNewContext}
+ glXMakeContextCurrent: function(dpy: PDisplay; draw: GLXDrawable; read: GLXDrawable; ctx: GLXContext): TGLboolean; cdecl;
+ {$EXTERNALSYM glXMakeContextCurrent}
+ glXGetCurrentReadDrawable: function: GLXDrawable; cdecl;
+ {$EXTERNALSYM glXGetCurrentReadDrawable}
+ glXQueryContext: function(dpy: PDisplay; ctx: GLXContext; attribute: TGLInt; value: PGLInt): TGLInt; cdecl;
+ {$EXTERNALSYM glXQueryContext}
+ glXSelectEvent: procedure(dpy: PDisplay; drawable: GLXDrawable; mask: TGLsizei); cdecl;
+ {$EXTERNALSYM glXSelectEvent}
+ glXGetSelectedEvent: procedure(dpy: PDisplay; drawable: GLXDrawable; mask: TGLsizei); cdecl;
+ {$EXTERNALSYM glXGetSelectedEvent}
+ glXGetVideoSyncSGI: function(count: PGLuint): TGLInt; cdecl;
+ {$EXTERNALSYM glXGetVideoSyncSGI}
+ glXWaitVideoSyncSGI: function(divisor: TGLInt; remainder: TGLInt; count: PGLuint): TGLInt; cdecl;
+ {$EXTERNALSYM glXWaitVideoSyncSGI}
+ glXFreeContextEXT: procedure(dpy: PDisplay; context: GLXContext); cdecl;
+ {$EXTERNALSYM glXFreeContextEXT}
+ glXGetContextIDEXT: function(const context: GLXContext): GLXContextID; cdecl;
+ {$EXTERNALSYM glXGetContextIDEXT}
+ glXGetCurrentDisplayEXT: function: PDisplay; cdecl;
+ {$EXTERNALSYM glXGetCurrentDisplayEXT}
+ glXImportContextEXT: function(dpy: PDisplay; contextID: GLXContextID): GLXContext; cdecl;
+ {$EXTERNALSYM glXImportContextEXT}
+ glXQueryContextInfoEXT: function(dpy: PDisplay; context: GLXContext; attribute: TGLInt; value: PGLInt): TGLInt; cdecl;
+ {$EXTERNALSYM glXQueryContextInfoEXT}
+ glXCopySubBufferMESA: procedure(dpy: PDisplay; drawable: GLXDrawable; x: TGLInt; y: TGLInt; width: TGLInt; height: TGLInt); cdecl;
+ {$EXTERNALSYM glXCopySubBufferMESA}
+ glXCreateGLXPixmapMESA: function(dpy: PDisplay; visual: PXVisualInfo; pixmap: Pixmap; cmap: Colormap): GLXPixmap; cdecl;
+ {$EXTERNALSYM glXCreateGLXPixmapMESA}
+ glXReleaseBuffersMESA: function(dpy: PDisplay; d: GLXDrawable): TGLboolean; cdecl;
+ {$EXTERNALSYM glXReleaseBuffersMESA}
+ glXSet3DfxModeMESA: function(mode: TGLint): TGLboolean; cdecl;
+ {$EXTERNALSYM glXSet3DfxModeMESA}
+{$endif}
+
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure CloseOpenGL;
+function InitOpenGL: Boolean;
+function InitOpenGLFromLibrary(GLName, GLUName: PChar): Boolean;
+function IsOpenGLInitialized: Boolean;
+
+// Compatibility routines
+procedure UnloadOpenGL;
+function LoadOpenGL: Boolean;
+function LoadOpenGLFromLibrary(GLName, GLUName: PChar): Boolean;
+function IsOpenGLLoaded: Boolean;
+
+{$ifdef Win32}
+procedure ActivateRenderingContext(DC: HDC; RC: HGLRC);
+function CreateRenderingContext(DC: HDC; Options: TRCOptions; ColorBits, StencilBits, AccumBits, AuxBuffers: Integer; Layer: Integer; var Palette: HPALETTE): HGLRC;
+function CurrentDC: HDC;
+procedure DeactivateRenderingContext;
+procedure DestroyRenderingContext(RC: HGLRC);
+procedure ClearExtensions;
+function HasActiveContext: Boolean;
+procedure ReadExtensions;
+procedure ReadImplementationProperties;
+{$endif}
+
+//----------------------------------------------------------------------------------------------------------------------
+
+implementation
+
+uses
+ SysUtils,
+ Classes,
+ sdl,
+ moduleloader;
+
+type
+ EOpenGLException = class(Exception);
+
+{$ifndef FPC}
+threadvar
+{$else}
+var
+{$endif}
+ LastPixelFormat: Integer;
+ ActivationRefCount: Integer;
+
+{$ifdef Win32}
+const
+ INVALID_MODULEHANDLE = 0;
+
+var
+ GLHandle: TModuleHandle;
+ GLUHandle: TModuleHandle;
+{$endif}
+
+{$ifdef UNIX}
+const
+ INVALID_MODULEHANDLE = nil;
+
+var
+ GLHandle: TModuleHandle;
+ GLUHandle: TModuleHandle;
+{$endif}
+
+ // The context list is used to determine if a context is active already in any thread.
+ ContextList: TThreadList;
+
+resourcestring
+ SRCAlreadyActive = 'Rendering context already active in another thread.';
+ SMakeCurrentFailed = 'wglMakeCurrent failed';
+ SDeleteContextFailed = 'wglDeleteContext failed';
+ SContextInUse = 'Cannot delete rendering context. It is still in use by another thread.';
+
+{$ifdef Win32}
+ SDefaultGLLibrary = 'OpenGL32.dll';
+ SDefaultGLULibrary = 'GLU32.dll';
+{$endif}
+
+{$ifdef UNIX}
+ SDefaultGLLibrary = 'libGL.so';
+ SDefaultGLULibrary = 'libGLU.so';
+{$endif}
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure ShowError(const Message: string);
+
+begin
+ raise EOpenGLException.Create(Message);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+{$ifndef VER140}
+
+procedure RaiseLastOSError;
+begin
+ {$ifndef FPC}
+ RaiseLastWin32Error;
+ {$endif}
+end;
+
+{$endif VER140}
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure ClearProcAddresses;
+
+begin
+ glAccum := nil;
+ glAlphaFunc := nil;
+ glAreTexturesResident := nil;
+ glArrayElement := nil;
+ glBegin := nil;
+ glBindTexture := nil;
+ glBitmap := nil;
+ glBlendFunc := nil;
+ glCallList := nil;
+ glCallLists := nil;
+ glClear := nil;
+ glClearAccum := nil;
+ glClearColor := nil;
+ glClearDepth := nil;
+ glClearIndex := nil;
+ glClearStencil := nil;
+ glClipPlane := nil;
+ glColor3b := nil;
+ glColor3bv := nil;
+ glColor3d := nil;
+ glColor3dv := nil;
+ glColor3f := nil;
+ glColor3fv := nil;
+ glColor3i := nil;
+ glColor3iv := nil;
+ glColor3s := nil;
+ glColor3sv := nil;
+ glColor3ub := nil;
+ glColor3ubv := nil;
+ glColor3ui := nil;
+ glColor3uiv := nil;
+ glColor3us := nil;
+ glColor3usv := nil;
+ glColor4b := nil;
+ glColor4bv := nil;
+ glColor4d := nil;
+ glColor4dv := nil;
+ glColor4f := nil;
+ glColor4fv := nil;
+ glColor4i := nil;
+ glColor4iv := nil;
+ glColor4s := nil;
+ glColor4sv := nil;
+ glColor4ub := nil;
+ glColor4ubv := nil;
+ glColor4ui := nil;
+ glColor4uiv := nil;
+ glColor4us := nil;
+ glColor4usv := nil;
+ glColorMask := nil;
+ glColorMaterial := nil;
+ glColorPointer := nil;
+ glCopyPixels := nil;
+ glCopyTexImage1D := nil;
+ glCopyTexImage2D := nil;
+ glCopyTexSubImage1D := nil;
+ glCopyTexSubImage2D := nil;
+ glCullFace := nil;
+ glDeleteLists := nil;
+ glDeleteTextures := nil;
+ glDepthFunc := nil;
+ glDepthMask := nil;
+ glDepthRange := nil;
+ glDisable := nil;
+ glDisableClientState := nil;
+ glDrawArrays := nil;
+ glDrawBuffer := nil;
+ glDrawElements := nil;
+ glDrawPixels := nil;
+ glEdgeFlag := nil;
+ glEdgeFlagPointer := nil;
+ glEdgeFlagv := nil;
+ glEnable := nil;
+ glEnableClientState := nil;
+ glEnd := nil;
+ glEndList := nil;
+ glEvalCoord1d := nil;
+ glEvalCoord1dv := nil;
+ glEvalCoord1f := nil;
+ glEvalCoord1fv := nil;
+ glEvalCoord2d := nil;
+ glEvalCoord2dv := nil;
+ glEvalCoord2f := nil;
+ glEvalCoord2fv := nil;
+ glEvalMesh1 := nil;
+ glEvalMesh2 := nil;
+ glEvalPoint1 := nil;
+ glEvalPoint2 := nil;
+ glFeedbackBuffer := nil;
+ glFinish := nil;
+ glFlush := nil;
+ glFogf := nil;
+ glFogfv := nil;
+ glFogi := nil;
+ glFogiv := nil;
+ glFrontFace := nil;
+ glFrustum := nil;
+ glGenLists := nil;
+ glGenTextures := nil;
+ glGetBooleanv := nil;
+ glGetClipPlane := nil;
+ glGetDoublev := nil;
+ glGetError := nil;
+ glGetFloatv := nil;
+ glGetIntegerv := nil;
+ glGetLightfv := nil;
+ glGetLightiv := nil;
+ glGetMapdv := nil;
+ glGetMapfv := nil;
+ glGetMapiv := nil;
+ glGetMaterialfv := nil;
+ glGetMaterialiv := nil;
+ glGetPixelMapfv := nil;
+ glGetPixelMapuiv := nil;
+ glGetPixelMapusv := nil;
+ glGetPointerv := nil;
+ glGetPolygonStipple := nil;
+ glGetString := nil;
+ glGetTexEnvfv := nil;
+ glGetTexEnviv := nil;
+ glGetTexGendv := nil;
+ glGetTexGenfv := nil;
+ glGetTexGeniv := nil;
+ glGetTexImage := nil;
+ glGetTexLevelParameterfv := nil;
+ glGetTexLevelParameteriv := nil;
+ glGetTexParameterfv := nil;
+ glGetTexParameteriv := nil;
+ glHint := nil;
+ glIndexMask := nil;
+ glIndexPointer := nil;
+ glIndexd := nil;
+ glIndexdv := nil;
+ glIndexf := nil;
+ glIndexfv := nil;
+ glIndexi := nil;
+ glIndexiv := nil;
+ glIndexs := nil;
+ glIndexsv := nil;
+ glIndexub := nil;
+ glIndexubv := nil;
+ glInitNames := nil;
+ glInterleavedArrays := nil;
+ glIsEnabled := nil;
+ glIsList := nil;
+ glIsTexture := nil;
+ glLightModelf := nil;
+ glLightModelfv := nil;
+ glLightModeli := nil;
+ glLightModeliv := nil;
+ glLightf := nil;
+ glLightfv := nil;
+ glLighti := nil;
+ glLightiv := nil;
+ glLineStipple := nil;
+ glLineWidth := nil;
+ glListBase := nil;
+ glLoadIdentity := nil;
+ glLoadMatrixd := nil;
+ glLoadMatrixf := nil;
+ glLoadName := nil;
+ glLogicOp := nil;
+ glMap1d := nil;
+ glMap1f := nil;
+ glMap2d := nil;
+ glMap2f := nil;
+ glMapGrid1d := nil;
+ glMapGrid1f := nil;
+ glMapGrid2d := nil;
+ glMapGrid2f := nil;
+ glMaterialf := nil;
+ glMaterialfv := nil;
+ glMateriali := nil;
+ glMaterialiv := nil;
+ glMatrixMode := nil;
+ glMultMatrixd := nil;
+ glMultMatrixf := nil;
+ glNewList := nil;
+ glNormal3b := nil;
+ glNormal3bv := nil;
+ glNormal3d := nil;
+ glNormal3dv := nil;
+ glNormal3f := nil;
+ glNormal3fv := nil;
+ glNormal3i := nil;
+ glNormal3iv := nil;
+ glNormal3s := nil;
+ glNormal3sv := nil;
+ glNormalPointer := nil;
+ glOrtho := nil;
+ glPassThrough := nil;
+ glPixelMapfv := nil;
+ glPixelMapuiv := nil;
+ glPixelMapusv := nil;
+ glPixelStoref := nil;
+ glPixelStorei := nil;
+ glPixelTransferf := nil;
+ glPixelTransferi := nil;
+ glPixelZoom := nil;
+ glPointSize := nil;
+ glPolygonMode := nil;
+ glPolygonOffset := nil;
+ glPolygonStipple := nil;
+ glPopAttrib := nil;
+ glPopClientAttrib := nil;
+ glPopMatrix := nil;
+ glPopName := nil;
+ glPrioritizeTextures := nil;
+ glPushAttrib := nil;
+ glPushClientAttrib := nil;
+ glPushMatrix := nil;
+ glPushName := nil;
+ glRasterPos2d := nil;
+ glRasterPos2dv := nil;
+ glRasterPos2f := nil;
+ glRasterPos2fv := nil;
+ glRasterPos2i := nil;
+ glRasterPos2iv := nil;
+ glRasterPos2s := nil;
+ glRasterPos2sv := nil;
+ glRasterPos3d := nil;
+ glRasterPos3dv := nil;
+ glRasterPos3f := nil;
+ glRasterPos3fv := nil;
+ glRasterPos3i := nil;
+ glRasterPos3iv := nil;
+ glRasterPos3s := nil;
+ glRasterPos3sv := nil;
+ glRasterPos4d := nil;
+ glRasterPos4dv := nil;
+ glRasterPos4f := nil;
+ glRasterPos4fv := nil;
+ glRasterPos4i := nil;
+ glRasterPos4iv := nil;
+ glRasterPos4s := nil;
+ glRasterPos4sv := nil;
+ glReadBuffer := nil;
+ glReadPixels := nil;
+ glRectd := nil;
+ glRectdv := nil;
+ glRectf := nil;
+ glRectfv := nil;
+ glRecti := nil;
+ glRectiv := nil;
+ glRects := nil;
+ glRectsv := nil;
+ glRenderMode := nil;
+ glRotated := nil;
+ glRotatef := nil;
+ glScaled := nil;
+ glScalef := nil;
+ glScissor := nil;
+ glSelectBuffer := nil;
+ glShadeModel := nil;
+ glStencilFunc := nil;
+ glStencilMask := nil;
+ glStencilOp := nil;
+ glTexCoord1d := nil;
+ glTexCoord1dv := nil;
+ glTexCoord1f := nil;
+ glTexCoord1fv := nil;
+ glTexCoord1i := nil;
+ glTexCoord1iv := nil;
+ glTexCoord1s := nil;
+ glTexCoord1sv := nil;
+ glTexCoord2d := nil;
+ glTexCoord2dv := nil;
+ glTexCoord2f := nil;
+ glTexCoord2fv := nil;
+ glTexCoord2i := nil;
+ glTexCoord2iv := nil;
+ glTexCoord2s := nil;
+ glTexCoord2sv := nil;
+ glTexCoord3d := nil;
+ glTexCoord3dv := nil;
+ glTexCoord3f := nil;
+ glTexCoord3fv := nil;
+ glTexCoord3i := nil;
+ glTexCoord3iv := nil;
+ glTexCoord3s := nil;
+ glTexCoord3sv := nil;
+ glTexCoord4d := nil;
+ glTexCoord4dv := nil;
+ glTexCoord4f := nil;
+ glTexCoord4fv := nil;
+ glTexCoord4i := nil;
+ glTexCoord4iv := nil;
+ glTexCoord4s := nil;
+ glTexCoord4sv := nil;
+ glTexCoordPointer := nil;
+ glTexEnvf := nil;
+ glTexEnvfv := nil;
+ glTexEnvi := nil;
+ glTexEnviv := nil;
+ glTexGend := nil;
+ glTexGendv := nil;
+ glTexGenf := nil;
+ glTexGenfv := nil;
+ glTexGeni := nil;
+ glTexGeniv := nil;
+ glTexImage1D := nil;
+ glTexImage2D := nil;
+ glTexParameterf := nil;
+ glTexParameterfv := nil;
+ glTexParameteri := nil;
+ glTexParameteriv := nil;
+ glTexSubImage1D := nil;
+ glTexSubImage2D := nil;
+ glTranslated := nil;
+ glTranslatef := nil;
+ glVertex2d := nil;
+ glVertex2dv := nil;
+ glVertex2f := nil;
+ glVertex2fv := nil;
+ glVertex2i := nil;
+ glVertex2iv := nil;
+ glVertex2s := nil;
+ glVertex2sv := nil;
+ glVertex3d := nil;
+ glVertex3dv := nil;
+ glVertex3f := nil;
+ glVertex3fv := nil;
+ glVertex3i := nil;
+ glVertex3iv := nil;
+ glVertex3s := nil;
+ glVertex3sv := nil;
+ glVertex4d := nil;
+ glVertex4dv := nil;
+ glVertex4f := nil;
+ glVertex4fv := nil;
+ glVertex4i := nil;
+ glVertex4iv := nil;
+ glVertex4s := nil;
+ glVertex4sv := nil;
+ glVertexPointer := nil;
+ glViewport := nil;
+
+ {$ifdef Win32}
+ wglGetProcAddress := nil;
+ wglCopyContext := nil;
+ wglCreateContext := nil;
+ wglCreateLayerContext := nil;
+ wglDeleteContext := nil;
+ wglDescribeLayerPlane := nil;
+ wglGetCurrentContext := nil;
+ wglGetCurrentDC := nil;
+ wglGetLayerPaletteEntries := nil;
+ wglMakeCurrent := nil;
+ wglRealizeLayerPalette := nil;
+ wglSetLayerPaletteEntries := nil;
+ wglShareLists := nil;
+ wglSwapLayerBuffers := nil;
+ wglSwapMultipleBuffers := nil;
+ wglUseFontBitmapsA := nil;
+ wglUseFontOutlinesA := nil;
+ wglUseFontBitmapsW := nil;
+ wglUseFontOutlinesW := nil;
+ wglUseFontBitmaps := nil;
+ wglUseFontOutlines := nil;
+ {$endif}
+
+ // GL 1.2
+ glDrawRangeElements := nil;
+ glTexImage3D := nil;
+
+ // GL 1.2 ARB imaging
+ glBlendColor := nil;
+ glBlendEquation := nil;
+ glColorSubTable := nil;
+ glCopyColorSubTable := nil;
+ glColorTable := nil;
+ glCopyColorTable := nil;
+ glColorTableParameteriv := nil;
+ glColorTableParameterfv := nil;
+ glGetColorTable := nil;
+ glGetColorTableParameteriv := nil;
+ glGetColorTableParameterfv := nil;
+ glConvolutionFilter1D := nil;
+ glConvolutionFilter2D := nil;
+ glCopyConvolutionFilter1D := nil;
+ glCopyConvolutionFilter2D := nil;
+ glGetConvolutionFilter := nil;
+ glSeparableFilter2D := nil;
+ glGetSeparableFilter := nil;
+ glConvolutionParameteri := nil;
+ glConvolutionParameteriv := nil;
+ glConvolutionParameterf := nil;
+ glConvolutionParameterfv := nil;
+ glGetConvolutionParameteriv := nil;
+ glGetConvolutionParameterfv := nil;
+ glHistogram := nil;
+ glResetHistogram := nil;
+ glGetHistogram := nil;
+ glGetHistogramParameteriv := nil;
+ glGetHistogramParameterfv := nil;
+ glMinmax := nil;
+ glResetMinmax := nil;
+ glGetMinmax := nil;
+ glGetMinmaxParameteriv := nil;
+ glGetMinmaxParameterfv := nil;
+
+ // GLX
+ {$ifdef UNIX}
+ glXChooseVisual := nil;
+ glXCreateContext := nil;
+ glXDestroyContext := nil;
+ glXMakeCurrent := nil;
+ glXCopyContext := nil;
+ glXSwapBuffers := nil;
+ glXCreateGLXPixmap := nil;
+ glXDestroyGLXPixmap := nil;
+ glXQueryExtension := nil;
+ glXQueryVersion := nil;
+ glXIsDirect := nil;
+ glXGetConfig := nil;
+ glXGetCurrentContext := nil;
+ glXGetCurrentDrawable := nil;
+ glXWaitGL := nil;
+ glXWaitX := nil;
+ glXUseXFont := nil;
+
+ // GLX 1.1 and later
+ glXQueryExtensionsString := nil;
+ glXQueryServerString := nil;
+ glXGetClientString := nil;
+
+ // GLX 1.2 and later
+ glXGetCurrentDisplay := nil;
+
+ // GLX 1.3 and later
+ glXChooseFBConfig := nil;
+ glXGetFBConfigAttrib := nil;
+ glXGetFBConfigs := nil;
+ glXGetVisualFromFBConfig := nil;
+ glXCreateWindow := nil;
+ glXDestroyWindow := nil;
+ glXCreatePixmap := nil;
+ glXDestroyPixmap := nil;
+ glXCreatePbuffer := nil;
+ glXDestroyPbuffer := nil;
+ glXQueryDrawable := nil;
+ glXCreateNewContext := nil;
+ glXMakeContextCurrent := nil;
+ glXGetCurrentReadDrawable := nil;
+ glXQueryContext := nil;
+ glXSelectEvent := nil;
+ glXGetSelectedEvent := nil;
+ glXGetVideoSyncSGI := nil;
+ glXWaitVideoSyncSGI := nil;
+ glXFreeContextEXT := nil;
+ glXGetContextIDEXT := nil;
+ glXGetCurrentDisplayEXT := nil;
+ glXImportContextEXT := nil;
+ glXQueryContextInfoEXT := nil;
+ glXCopySubBufferMESA := nil;
+ glXCreateGLXPixmapMESA := nil;
+ glXReleaseBuffersMESA := nil;
+ glXSet3DfxModeMESA := nil;
+ {$endif}
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure LoadProcAddresses;
+begin
+ if GLHandle <> INVALID_MODULEHANDLE then
+ begin
+ glAccum := GetModuleSymbol( GLHandle, 'glAccum');
+ glAlphaFunc := GetModuleSymbol( GLHandle, 'glAlphaFunc');
+ glAreTexturesResident := GetModuleSymbol( GLHandle, 'glAreTexturesResident');
+ glArrayElement := GetModuleSymbol( GLHandle, 'glArrayElement');
+ glBegin := GetModuleSymbol( GLHandle, 'glBegin');
+ glBindTexture := GetModuleSymbol( GLHandle, 'glBindTexture');
+ glBitmap := GetModuleSymbol( GLHandle, 'glBitmap');
+ glBlendFunc := GetModuleSymbol( GLHandle, 'glBlendFunc');
+ glCallList := GetModuleSymbol( GLHandle, 'glCallList');
+ glCallLists := GetModuleSymbol( GLHandle, 'glCallLists');
+ glClear := GetModuleSymbol( GLHandle, 'glClear');
+ glClearAccum := GetModuleSymbol( GLHandle, 'glClearAccum');
+ glClearColor := GetModuleSymbol( GLHandle, 'glClearColor');
+ glClearDepth := GetModuleSymbol( GLHandle, 'glClearDepth');
+ glClearIndex := GetModuleSymbol( GLHandle, 'glClearIndex');
+ glClearStencil := GetModuleSymbol( GLHandle, 'glClearStencil');
+ glClipPlane := GetModuleSymbol( GLHandle, 'glClipPlane');
+ glColor3b := GetModuleSymbol( GLHandle, 'glColor3b');
+ glColor3bv := GetModuleSymbol( GLHandle, 'glColor3bv');
+ glColor3d := GetModuleSymbol( GLHandle, 'glColor3d');
+ glColor3dv := GetModuleSymbol( GLHandle, 'glColor3dv');
+ glColor3f := GetModuleSymbol( GLHandle, 'glColor3f');
+ glColor3fv := GetModuleSymbol( GLHandle, 'glColor3fv');
+ glColor3i := GetModuleSymbol( GLHandle, 'glColor3i');
+ glColor3iv := GetModuleSymbol( GLHandle, 'glColor3iv');
+ glColor3s := GetModuleSymbol( GLHandle, 'glColor3s');
+ glColor3sv := GetModuleSymbol( GLHandle, 'glColor3sv');
+ glColor3ub := GetModuleSymbol( GLHandle, 'glColor3ub');
+ glColor3ubv := GetModuleSymbol( GLHandle, 'glColor3ubv');
+ glColor3ui := GetModuleSymbol( GLHandle, 'glColor3ui');
+ glColor3uiv := GetModuleSymbol( GLHandle, 'glColor3uiv');
+ glColor3us := GetModuleSymbol( GLHandle, 'glColor3us');
+ glColor3usv := GetModuleSymbol( GLHandle, 'glColor3usv');
+ glColor4b := GetModuleSymbol( GLHandle, 'glColor4b');
+ glColor4bv := GetModuleSymbol( GLHandle, 'glColor4bv');
+ glColor4d := GetModuleSymbol( GLHandle, 'glColor4d');
+ glColor4dv := GetModuleSymbol( GLHandle, 'glColor4dv');
+ glColor4f := GetModuleSymbol( GLHandle, 'glColor4f');
+ glColor4fv := GetModuleSymbol( GLHandle, 'glColor4fv');
+ glColor4i := GetModuleSymbol( GLHandle, 'glColor4i');
+ glColor4iv := GetModuleSymbol( GLHandle, 'glColor4iv');
+ glColor4s := GetModuleSymbol( GLHandle, 'glColor4s');
+ glColor4sv := GetModuleSymbol( GLHandle, 'glColor4sv');
+ glColor4ub := GetModuleSymbol( GLHandle, 'glColor4ub');
+ glColor4ubv := GetModuleSymbol( GLHandle, 'glColor4ubv');
+ glColor4ui := GetModuleSymbol( GLHandle, 'glColor4ui');
+ glColor4uiv := GetModuleSymbol( GLHandle, 'glColor4uiv');
+ glColor4us := GetModuleSymbol( GLHandle, 'glColor4us');
+ glColor4usv := GetModuleSymbol( GLHandle, 'glColor4usv');
+ glColorMask := GetModuleSymbol( GLHandle, 'glColorMask');
+ glColorMaterial := GetModuleSymbol( GLHandle, 'glColorMaterial');
+ glColorPointer := GetModuleSymbol( GLHandle, 'glColorPointer');
+ glCopyPixels := GetModuleSymbol( GLHandle, 'glCopyPixels');
+ glCopyTexImage1D := GetModuleSymbol( GLHandle, 'glCopyTexImage1D');
+ glCopyTexImage2D := GetModuleSymbol( GLHandle, 'glCopyTexImage2D');
+ glCopyTexSubImage1D := GetModuleSymbol( GLHandle, 'glCopyTexSubImage1D');
+ glCopyTexSubImage2D := GetModuleSymbol( GLHandle, 'glCopyTexSubImage2D');
+ glCullFace := GetModuleSymbol( GLHandle, 'glCullFace');
+ glDeleteLists := GetModuleSymbol( GLHandle, 'glDeleteLists');
+ glDeleteTextures := GetModuleSymbol( GLHandle, 'glDeleteTextures');
+ glDepthFunc := GetModuleSymbol( GLHandle, 'glDepthFunc');
+ glDepthMask := GetModuleSymbol( GLHandle, 'glDepthMask');
+ glDepthRange := GetModuleSymbol( GLHandle, 'glDepthRange');
+ glDisable := GetModuleSymbol( GLHandle, 'glDisable');
+ glDisableClientState := GetModuleSymbol( GLHandle, 'glDisableClientState');
+ glDrawArrays := GetModuleSymbol( GLHandle, 'glDrawArrays');
+ glDrawBuffer := GetModuleSymbol( GLHandle, 'glDrawBuffer');
+ glDrawElements := GetModuleSymbol( GLHandle, 'glDrawElements');
+ glDrawPixels := GetModuleSymbol( GLHandle, 'glDrawPixels');
+ glEdgeFlag := GetModuleSymbol( GLHandle, 'glEdgeFlag');
+ glEdgeFlagPointer := GetModuleSymbol( GLHandle, 'glEdgeFlagPointer');
+ glEdgeFlagv := GetModuleSymbol( GLHandle, 'glEdgeFlagv');
+ glEnable := GetModuleSymbol( GLHandle, 'glEnable');
+ glEnableClientState := GetModuleSymbol( GLHandle, 'glEnableClientState');
+ glEnd := GetModuleSymbol( GLHandle, 'glEnd');
+ glEndList := GetModuleSymbol( GLHandle, 'glEndList');
+ glEvalCoord1d := GetModuleSymbol( GLHandle, 'glEvalCoord1d');
+ glEvalCoord1dv := GetModuleSymbol( GLHandle, 'glEvalCoord1dv');
+ glEvalCoord1f := GetModuleSymbol( GLHandle, 'glEvalCoord1f');
+ glEvalCoord1fv := GetModuleSymbol( GLHandle, 'glEvalCoord1fv');
+ glEvalCoord2d := GetModuleSymbol( GLHandle, 'glEvalCoord2d');
+ glEvalCoord2dv := GetModuleSymbol( GLHandle, 'glEvalCoord2dv');
+ glEvalCoord2f := GetModuleSymbol( GLHandle, 'glEvalCoord2f');
+ glEvalCoord2fv := GetModuleSymbol( GLHandle, 'glEvalCoord2fv');
+ glEvalMesh1 := GetModuleSymbol( GLHandle, 'glEvalMesh1');
+ glEvalMesh2 := GetModuleSymbol( GLHandle, 'glEvalMesh2');
+ glEvalPoint1 := GetModuleSymbol( GLHandle, 'glEvalPoint1');
+ glEvalPoint2 := GetModuleSymbol( GLHandle, 'glEvalPoint2');
+ glFeedbackBuffer := GetModuleSymbol( GLHandle, 'glFeedbackBuffer');
+ glFinish := GetModuleSymbol( GLHandle, 'glFinish');
+ glFlush := GetModuleSymbol( GLHandle, 'glFlush');
+ glFogf := GetModuleSymbol( GLHandle, 'glFogf');
+ glFogfv := GetModuleSymbol( GLHandle, 'glFogfv');
+ glFogi := GetModuleSymbol( GLHandle, 'glFogi');
+ glFogiv := GetModuleSymbol( GLHandle, 'glFogiv');
+ glFrontFace := GetModuleSymbol( GLHandle, 'glFrontFace');
+ glFrustum := GetModuleSymbol( GLHandle, 'glFrustum');
+ glGenLists := GetModuleSymbol( GLHandle, 'glGenLists');
+ glGenTextures := GetModuleSymbol( GLHandle, 'glGenTextures');
+ glGetBooleanv := GetModuleSymbol( GLHandle, 'glGetBooleanv');
+ glGetClipPlane := GetModuleSymbol( GLHandle, 'glGetClipPlane');
+ glGetDoublev := GetModuleSymbol( GLHandle, 'glGetDoublev');
+ glGetError := GetModuleSymbol( GLHandle, 'glGetError');
+ glGetFloatv := GetModuleSymbol( GLHandle, 'glGetFloatv');
+ glGetIntegerv := GetModuleSymbol( GLHandle, 'glGetIntegerv');
+ glGetLightfv := GetModuleSymbol( GLHandle, 'glGetLightfv');
+ glGetLightiv := GetModuleSymbol( GLHandle, 'glGetLightiv');
+ glGetMapdv := GetModuleSymbol( GLHandle, 'glGetMapdv');
+ glGetMapfv := GetModuleSymbol( GLHandle, 'glGetMapfv');
+ glGetMapiv := GetModuleSymbol( GLHandle, 'glGetMapiv');
+ glGetMaterialfv := GetModuleSymbol( GLHandle, 'glGetMaterialfv');
+ glGetMaterialiv := GetModuleSymbol( GLHandle, 'glGetMaterialiv');
+ glGetPixelMapfv := GetModuleSymbol( GLHandle, 'glGetPixelMapfv');
+ glGetPixelMapuiv := GetModuleSymbol( GLHandle, 'glGetPixelMapuiv');
+ glGetPixelMapusv := GetModuleSymbol( GLHandle, 'glGetPixelMapusv');
+ glGetPointerv := GetModuleSymbol( GLHandle, 'glGetPointerv');
+ glGetPolygonStipple := GetModuleSymbol( GLHandle, 'glGetPolygonStipple');
+ glGetString := GetModuleSymbol( GLHandle, 'glGetString');
+ glGetTexEnvfv := GetModuleSymbol( GLHandle, 'glGetTexEnvfv');
+ glGetTexEnviv := GetModuleSymbol( GLHandle, 'glGetTexEnviv');
+ glGetTexGendv := GetModuleSymbol( GLHandle, 'glGetTexGendv');
+ glGetTexGenfv := GetModuleSymbol( GLHandle, 'glGetTexGenfv');
+ glGetTexGeniv := GetModuleSymbol( GLHandle, 'glGetTexGeniv');
+ glGetTexImage := GetModuleSymbol( GLHandle, 'glGetTexImage');
+ glGetTexLevelParameterfv := GetModuleSymbol( GLHandle, 'glGetTexLevelParameterfv');
+ glGetTexLevelParameteriv := GetModuleSymbol( GLHandle, 'glGetTexLevelParameteriv');
+ glGetTexParameterfv := GetModuleSymbol( GLHandle, 'glGetTexParameterfv');
+ glGetTexParameteriv := GetModuleSymbol( GLHandle, 'glGetTexParameteriv');
+ glHint := GetModuleSymbol( GLHandle, 'glHint');
+ glIndexMask := GetModuleSymbol( GLHandle, 'glIndexMask');
+ glIndexPointer := GetModuleSymbol( GLHandle, 'glIndexPointer');
+ glIndexd := GetModuleSymbol( GLHandle, 'glIndexd');
+ glIndexdv := GetModuleSymbol( GLHandle, 'glIndexdv');
+ glIndexf := GetModuleSymbol( GLHandle, 'glIndexf');
+ glIndexfv := GetModuleSymbol( GLHandle, 'glIndexfv');
+ glIndexi := GetModuleSymbol( GLHandle, 'glIndexi');
+ glIndexiv := GetModuleSymbol( GLHandle, 'glIndexiv');
+ glIndexs := GetModuleSymbol( GLHandle, 'glIndexs');
+ glIndexsv := GetModuleSymbol( GLHandle, 'glIndexsv');
+ glIndexub := GetModuleSymbol( GLHandle, 'glIndexub');
+ glIndexubv := GetModuleSymbol( GLHandle, 'glIndexubv');
+ glInitNames := GetModuleSymbol( GLHandle, 'glInitNames');
+ glInterleavedArrays := GetModuleSymbol( GLHandle, 'glInterleavedArrays');
+ glIsEnabled := GetModuleSymbol( GLHandle, 'glIsEnabled');
+ glIsList := GetModuleSymbol( GLHandle, 'glIsList');
+ glIsTexture := GetModuleSymbol( GLHandle, 'glIsTexture');
+ glLightModelf := GetModuleSymbol( GLHandle, 'glLightModelf');
+ glLightModelfv := GetModuleSymbol( GLHandle, 'glLightModelfv');
+ glLightModeli := GetModuleSymbol( GLHandle, 'glLightModeli');
+ glLightModeliv := GetModuleSymbol( GLHandle, 'glLightModeliv');
+ glLightf := GetModuleSymbol( GLHandle, 'glLightf');
+ glLightfv := GetModuleSymbol( GLHandle, 'glLightfv');
+ glLighti := GetModuleSymbol( GLHandle, 'glLighti');
+ glLightiv := GetModuleSymbol( GLHandle, 'glLightiv');
+ glLineStipple := GetModuleSymbol( GLHandle, 'glLineStipple');
+ glLineWidth := GetModuleSymbol( GLHandle, 'glLineWidth');
+ glListBase := GetModuleSymbol( GLHandle, 'glListBase');
+ glLoadIdentity := GetModuleSymbol( GLHandle, 'glLoadIdentity');
+ glLoadMatrixd := GetModuleSymbol( GLHandle, 'glLoadMatrixd');
+ glLoadMatrixf := GetModuleSymbol( GLHandle, 'glLoadMatrixf');
+ glLoadName := GetModuleSymbol( GLHandle, 'glLoadName');
+ glLogicOp := GetModuleSymbol( GLHandle, 'glLogicOp');
+ glMap1d := GetModuleSymbol( GLHandle, 'glMap1d');
+ glMap1f := GetModuleSymbol( GLHandle, 'glMap1f');
+ glMap2d := GetModuleSymbol( GLHandle, 'glMap2d');
+ glMap2f := GetModuleSymbol( GLHandle, 'glMap2f');
+ glMapGrid1d := GetModuleSymbol( GLHandle, 'glMapGrid1d');
+ glMapGrid1f := GetModuleSymbol( GLHandle, 'glMapGrid1f');
+ glMapGrid2d := GetModuleSymbol( GLHandle, 'glMapGrid2d');
+ glMapGrid2f := GetModuleSymbol( GLHandle, 'glMapGrid2f');
+ glMaterialf := GetModuleSymbol( GLHandle, 'glMaterialf');
+ glMaterialfv := GetModuleSymbol( GLHandle, 'glMaterialfv');
+ glMateriali := GetModuleSymbol( GLHandle, 'glMateriali');
+ glMaterialiv := GetModuleSymbol( GLHandle, 'glMaterialiv');
+ glMatrixMode := GetModuleSymbol( GLHandle, 'glMatrixMode');
+ glMultMatrixd := GetModuleSymbol( GLHandle, 'glMultMatrixd');
+ glMultMatrixf := GetModuleSymbol( GLHandle, 'glMultMatrixf');
+ glNewList := GetModuleSymbol( GLHandle, 'glNewList');
+ glNormal3b := GetModuleSymbol( GLHandle, 'glNormal3b');
+ glNormal3bv := GetModuleSymbol( GLHandle, 'glNormal3bv');
+ glNormal3d := GetModuleSymbol( GLHandle, 'glNormal3d');
+ glNormal3dv := GetModuleSymbol( GLHandle, 'glNormal3dv');
+ glNormal3f := GetModuleSymbol( GLHandle, 'glNormal3f');
+ glNormal3fv := GetModuleSymbol( GLHandle, 'glNormal3fv');
+ glNormal3i := GetModuleSymbol( GLHandle, 'glNormal3i');
+ glNormal3iv := GetModuleSymbol( GLHandle, 'glNormal3iv');
+ glNormal3s := GetModuleSymbol( GLHandle, 'glNormal3s');
+ glNormal3sv := GetModuleSymbol( GLHandle, 'glNormal3sv');
+ glNormalPointer := GetModuleSymbol( GLHandle, 'glNormalPointer');
+ glOrtho := GetModuleSymbol( GLHandle, 'glOrtho');
+ glPassThrough := GetModuleSymbol( GLHandle, 'glPassThrough');
+ glPixelMapfv := GetModuleSymbol( GLHandle, 'glPixelMapfv');
+ glPixelMapuiv := GetModuleSymbol( GLHandle, 'glPixelMapuiv');
+ glPixelMapusv := GetModuleSymbol( GLHandle, 'glPixelMapusv');
+ glPixelStoref := GetModuleSymbol( GLHandle, 'glPixelStoref');
+ glPixelStorei := GetModuleSymbol( GLHandle, 'glPixelStorei');
+ glPixelTransferf := GetModuleSymbol( GLHandle, 'glPixelTransferf');
+ glPixelTransferi := GetModuleSymbol( GLHandle, 'glPixelTransferi');
+ glPixelZoom := GetModuleSymbol( GLHandle, 'glPixelZoom');
+ glPointSize := GetModuleSymbol( GLHandle, 'glPointSize');
+ glPolygonMode := GetModuleSymbol( GLHandle, 'glPolygonMode');
+ glPolygonOffset := GetModuleSymbol( GLHandle, 'glPolygonOffset');
+ glPolygonStipple := GetModuleSymbol( GLHandle, 'glPolygonStipple');
+ glPopAttrib := GetModuleSymbol( GLHandle, 'glPopAttrib');
+ glPopClientAttrib := GetModuleSymbol( GLHandle, 'glPopClientAttrib');
+ glPopMatrix := GetModuleSymbol( GLHandle, 'glPopMatrix');
+ glPopName := GetModuleSymbol( GLHandle, 'glPopName');
+ glPrioritizeTextures := GetModuleSymbol( GLHandle, 'glPrioritizeTextures');
+ glPushAttrib := GetModuleSymbol( GLHandle, 'glPushAttrib');
+ glPushClientAttrib := GetModuleSymbol( GLHandle, 'glPushClientAttrib');
+ glPushMatrix := GetModuleSymbol( GLHandle, 'glPushMatrix');
+ glPushName := GetModuleSymbol( GLHandle, 'glPushName');
+ glRasterPos2d := GetModuleSymbol( GLHandle, 'glRasterPos2d');
+ glRasterPos2dv := GetModuleSymbol( GLHandle, 'glRasterPos2dv');
+ glRasterPos2f := GetModuleSymbol( GLHandle, 'glRasterPos2f');
+ glRasterPos2fv := GetModuleSymbol( GLHandle, 'glRasterPos2fv');
+ glRasterPos2i := GetModuleSymbol( GLHandle, 'glRasterPos2i');
+ glRasterPos2iv := GetModuleSymbol( GLHandle, 'glRasterPos2iv');
+ glRasterPos2s := GetModuleSymbol( GLHandle, 'glRasterPos2s');
+ glRasterPos2sv := GetModuleSymbol( GLHandle, 'glRasterPos2sv');
+ glRasterPos3d := GetModuleSymbol( GLHandle, 'glRasterPos3d');
+ glRasterPos3dv := GetModuleSymbol( GLHandle, 'glRasterPos3dv');
+ glRasterPos3f := GetModuleSymbol( GLHandle, 'glRasterPos3f');
+ glRasterPos3fv := GetModuleSymbol( GLHandle, 'glRasterPos3fv');
+ glRasterPos3i := GetModuleSymbol( GLHandle, 'glRasterPos3i');
+ glRasterPos3iv := GetModuleSymbol( GLHandle, 'glRasterPos3iv');
+ glRasterPos3s := GetModuleSymbol( GLHandle, 'glRasterPos3s');
+ glRasterPos3sv := GetModuleSymbol( GLHandle, 'glRasterPos3sv');
+ glRasterPos4d := GetModuleSymbol( GLHandle, 'glRasterPos4d');
+ glRasterPos4dv := GetModuleSymbol( GLHandle, 'glRasterPos4dv');
+ glRasterPos4f := GetModuleSymbol( GLHandle, 'glRasterPos4f');
+ glRasterPos4fv := GetModuleSymbol( GLHandle, 'glRasterPos4fv');
+ glRasterPos4i := GetModuleSymbol( GLHandle, 'glRasterPos4i');
+ glRasterPos4iv := GetModuleSymbol( GLHandle, 'glRasterPos4iv');
+ glRasterPos4s := GetModuleSymbol( GLHandle, 'glRasterPos4s');
+ glRasterPos4sv := GetModuleSymbol( GLHandle, 'glRasterPos4sv');
+ glReadBuffer := GetModuleSymbol( GLHandle, 'glReadBuffer');
+ glReadPixels := GetModuleSymbol( GLHandle, 'glReadPixels');
+ glRectd := GetModuleSymbol( GLHandle, 'glRectd');
+ glRectdv := GetModuleSymbol( GLHandle, 'glRectdv');
+ glRectf := GetModuleSymbol( GLHandle, 'glRectf');
+ glRectfv := GetModuleSymbol( GLHandle, 'glRectfv');
+ glRecti := GetModuleSymbol( GLHandle, 'glRecti');
+ glRectiv := GetModuleSymbol( GLHandle, 'glRectiv');
+ glRects := GetModuleSymbol( GLHandle, 'glRects');
+ glRectsv := GetModuleSymbol( GLHandle, 'glRectsv');
+ glRenderMode := GetModuleSymbol( GLHandle, 'glRenderMode');
+ glRotated := GetModuleSymbol( GLHandle, 'glRotated');
+ glRotatef := GetModuleSymbol( GLHandle, 'glRotatef');
+ glScaled := GetModuleSymbol( GLHandle, 'glScaled');
+ glScalef := GetModuleSymbol( GLHandle, 'glScalef');
+ glScissor := GetModuleSymbol( GLHandle, 'glScissor');
+ glSelectBuffer := GetModuleSymbol( GLHandle, 'glSelectBuffer');
+ glShadeModel := GetModuleSymbol( GLHandle, 'glShadeModel');
+ glStencilFunc := GetModuleSymbol( GLHandle, 'glStencilFunc');
+ glStencilMask := GetModuleSymbol( GLHandle, 'glStencilMask');
+ glStencilOp := GetModuleSymbol( GLHandle, 'glStencilOp');
+ glTexCoord1d := GetModuleSymbol( GLHandle, 'glTexCoord1d');
+ glTexCoord1dv := GetModuleSymbol( GLHandle, 'glTexCoord1dv');
+ glTexCoord1f := GetModuleSymbol( GLHandle, 'glTexCoord1f');
+ glTexCoord1fv := GetModuleSymbol( GLHandle, 'glTexCoord1fv');
+ glTexCoord1i := GetModuleSymbol( GLHandle, 'glTexCoord1i');
+ glTexCoord1iv := GetModuleSymbol( GLHandle, 'glTexCoord1iv');
+ glTexCoord1s := GetModuleSymbol( GLHandle, 'glTexCoord1s');
+ glTexCoord1sv := GetModuleSymbol( GLHandle, 'glTexCoord1sv');
+ glTexCoord2d := GetModuleSymbol( GLHandle, 'glTexCoord2d');
+ glTexCoord2dv := GetModuleSymbol( GLHandle, 'glTexCoord2dv');
+ glTexCoord2f := GetModuleSymbol( GLHandle, 'glTexCoord2f');
+ glTexCoord2fv := GetModuleSymbol( GLHandle, 'glTexCoord2fv');
+ glTexCoord2i := GetModuleSymbol( GLHandle, 'glTexCoord2i');
+ glTexCoord2iv := GetModuleSymbol( GLHandle, 'glTexCoord2iv');
+ glTexCoord2s := GetModuleSymbol( GLHandle, 'glTexCoord2s');
+ glTexCoord2sv := GetModuleSymbol( GLHandle, 'glTexCoord2sv');
+ glTexCoord3d := GetModuleSymbol( GLHandle, 'glTexCoord3d');
+ glTexCoord3dv := GetModuleSymbol( GLHandle, 'glTexCoord3dv');
+ glTexCoord3f := GetModuleSymbol( GLHandle, 'glTexCoord3f');
+ glTexCoord3fv := GetModuleSymbol( GLHandle, 'glTexCoord3fv');
+ glTexCoord3i := GetModuleSymbol( GLHandle, 'glTexCoord3i');
+ glTexCoord3iv := GetModuleSymbol( GLHandle, 'glTexCoord3iv');
+ glTexCoord3s := GetModuleSymbol( GLHandle, 'glTexCoord3s');
+ glTexCoord3sv := GetModuleSymbol( GLHandle, 'glTexCoord3sv');
+ glTexCoord4d := GetModuleSymbol( GLHandle, 'glTexCoord4d');
+ glTexCoord4dv := GetModuleSymbol( GLHandle, 'glTexCoord4dv');
+ glTexCoord4f := GetModuleSymbol( GLHandle, 'glTexCoord4f');
+ glTexCoord4fv := GetModuleSymbol( GLHandle, 'glTexCoord4fv');
+ glTexCoord4i := GetModuleSymbol( GLHandle, 'glTexCoord4i');
+ glTexCoord4iv := GetModuleSymbol( GLHandle, 'glTexCoord4iv');
+ glTexCoord4s := GetModuleSymbol( GLHandle, 'glTexCoord4s');
+ glTexCoord4sv := GetModuleSymbol( GLHandle, 'glTexCoord4sv');
+ glTexCoordPointer := GetModuleSymbol( GLHandle, 'glTexCoordPointer');
+ glTexEnvf := GetModuleSymbol( GLHandle, 'glTexEnvf');
+ glTexEnvfv := GetModuleSymbol( GLHandle, 'glTexEnvfv');
+ glTexEnvi := GetModuleSymbol( GLHandle, 'glTexEnvi');
+ glTexEnviv := GetModuleSymbol( GLHandle, 'glTexEnviv');
+ glTexGend := GetModuleSymbol( GLHandle, 'glTexGend');
+ glTexGendv := GetModuleSymbol( GLHandle, 'glTexGendv');
+ glTexGenf := GetModuleSymbol( GLHandle, 'glTexGenf');
+ glTexGenfv := GetModuleSymbol( GLHandle, 'glTexGenfv');
+ glTexGeni := GetModuleSymbol( GLHandle, 'glTexGeni');
+ glTexGeniv := GetModuleSymbol( GLHandle, 'glTexGeniv');
+ glTexImage1D := GetModuleSymbol( GLHandle, 'glTexImage1D');
+ glTexImage2D := GetModuleSymbol( GLHandle, 'glTexImage2D');
+ glTexParameterf := GetModuleSymbol( GLHandle, 'glTexParameterf');
+ glTexParameterfv := GetModuleSymbol( GLHandle, 'glTexParameterfv');
+ glTexParameteri := GetModuleSymbol( GLHandle, 'glTexParameteri');
+ glTexParameteriv := GetModuleSymbol( GLHandle, 'glTexParameteriv');
+ glTexSubImage1D := GetModuleSymbol( GLHandle, 'glTexSubImage1D');
+ glTexSubImage2D := GetModuleSymbol( GLHandle, 'glTexSubImage2D');
+ glTranslated := GetModuleSymbol( GLHandle, 'glTranslated');
+ glTranslatef := GetModuleSymbol( GLHandle, 'glTranslatef');
+ glVertex2d := GetModuleSymbol( GLHandle, 'glVertex2d');
+ glVertex2dv := GetModuleSymbol( GLHandle, 'glVertex2dv');
+ glVertex2f := GetModuleSymbol( GLHandle, 'glVertex2f');
+ glVertex2fv := GetModuleSymbol( GLHandle, 'glVertex2fv');
+ glVertex2i := GetModuleSymbol( GLHandle, 'glVertex2i');
+ glVertex2iv := GetModuleSymbol( GLHandle, 'glVertex2iv');
+ glVertex2s := GetModuleSymbol( GLHandle, 'glVertex2s');
+ glVertex2sv := GetModuleSymbol( GLHandle, 'glVertex2sv');
+ glVertex3d := GetModuleSymbol( GLHandle, 'glVertex3d');
+ glVertex3dv := GetModuleSymbol( GLHandle, 'glVertex3dv');
+ glVertex3f := GetModuleSymbol( GLHandle, 'glVertex3f');
+ glVertex3fv := GetModuleSymbol( GLHandle, 'glVertex3fv');
+ glVertex3i := GetModuleSymbol( GLHandle, 'glVertex3i');
+ glVertex3iv := GetModuleSymbol( GLHandle, 'glVertex3iv');
+ glVertex3s := GetModuleSymbol( GLHandle, 'glVertex3s');
+ glVertex3sv := GetModuleSymbol( GLHandle, 'glVertex3sv');
+ glVertex4d := GetModuleSymbol( GLHandle, 'glVertex4d');
+ glVertex4dv := GetModuleSymbol( GLHandle, 'glVertex4dv');
+ glVertex4f := GetModuleSymbol( GLHandle, 'glVertex4f');
+ glVertex4fv := GetModuleSymbol( GLHandle, 'glVertex4fv');
+ glVertex4i := GetModuleSymbol( GLHandle, 'glVertex4i');
+ glVertex4iv := GetModuleSymbol( GLHandle, 'glVertex4iv');
+ glVertex4s := GetModuleSymbol( GLHandle, 'glVertex4s');
+ glVertex4sv := GetModuleSymbol( GLHandle, 'glVertex4sv');
+ glVertexPointer := GetModuleSymbol( GLHandle, 'glVertexPointer');
+ glViewport := GetModuleSymbol( GLHandle, 'glViewport');
+
+ // window support routines
+ {$ifdef Win32}
+ wglGetProcAddress := GetModuleSymbol( GLHandle, 'wglGetProcAddress');
+ wglCopyContext := GetModuleSymbol( GLHandle, 'wglCopyContext');
+ wglCreateContext := GetModuleSymbol( GLHandle, 'wglCreateContext');
+ wglCreateLayerContext := GetModuleSymbol( GLHandle, 'wglCreateLayerContext');
+ wglDeleteContext := GetModuleSymbol( GLHandle, 'wglDeleteContext');
+ wglDescribeLayerPlane := GetModuleSymbol( GLHandle, 'wglDescribeLayerPlane');
+ wglGetCurrentContext := GetModuleSymbol( GLHandle, 'wglGetCurrentContext');
+ wglGetCurrentDC := GetModuleSymbol( GLHandle, 'wglGetCurrentDC');
+ wglGetLayerPaletteEntries := GetModuleSymbol( GLHandle, 'wglGetLayerPaletteEntries');
+ wglMakeCurrent := GetModuleSymbol( GLHandle, 'wglMakeCurrent');
+ wglRealizeLayerPalette := GetModuleSymbol( GLHandle, 'wglRealizeLayerPalette');
+ wglSetLayerPaletteEntries := GetModuleSymbol( GLHandle, 'wglSetLayerPaletteEntries');
+ wglShareLists := GetModuleSymbol( GLHandle, 'wglShareLists');
+ wglSwapLayerBuffers := GetModuleSymbol( GLHandle, 'wglSwapLayerBuffers');
+ wglSwapMultipleBuffers := GetModuleSymbol( GLHandle, 'wglSwapMultipleBuffers');
+ wglUseFontBitmapsA := GetModuleSymbol( GLHandle, 'wglUseFontBitmapsA');
+ wglUseFontOutlinesA := GetModuleSymbol( GLHandle, 'wglUseFontOutlinesA');
+ wglUseFontBitmapsW := GetModuleSymbol( GLHandle, 'wglUseFontBitmapsW');
+ wglUseFontOutlinesW := GetModuleSymbol( GLHandle, 'wglUseFontOutlinesW');
+ wglUseFontBitmaps := GetModuleSymbol( GLHandle, 'wglUseFontBitmapsA');
+ wglUseFontOutlines := GetModuleSymbol( GLHandle, 'wglUseFontOutlinesA');
+ {$endif}
+
+ // GL 1.2
+ glDrawRangeElements := GetModuleSymbol( GLHandle, 'glDrawRangeElements');
+ glTexImage3D := GetModuleSymbol( GLHandle, 'glTexImage3D');
+
+ // GL 1.2 ARB imaging
+ glBlendColor := GetModuleSymbol( GLHandle, 'glBlendColor');
+ glBlendEquation := GetModuleSymbol( GLHandle, 'glBlendEquation');
+ glColorSubTable := GetModuleSymbol( GLHandle, 'glColorSubTable');
+ glCopyColorSubTable := GetModuleSymbol( GLHandle, 'glCopyColorSubTable');
+ glColorTable := GetModuleSymbol( GLHandle, 'glCopyColorSubTable');
+ glCopyColorTable := GetModuleSymbol( GLHandle, 'glCopyColorTable');
+ glColorTableParameteriv := GetModuleSymbol( GLHandle, 'glColorTableParameteriv');
+ glColorTableParameterfv := GetModuleSymbol( GLHandle, 'glColorTableParameterfv');
+ glGetColorTable := GetModuleSymbol( GLHandle, 'glGetColorTable');
+ glGetColorTableParameteriv := GetModuleSymbol( GLHandle, 'glGetColorTableParameteriv');
+ glGetColorTableParameterfv := GetModuleSymbol( GLHandle, 'glGetColorTableParameterfv');
+ glConvolutionFilter1D := GetModuleSymbol( GLHandle, 'glConvolutionFilter1D');
+ glConvolutionFilter2D := GetModuleSymbol( GLHandle, 'glConvolutionFilter2D');
+ glCopyConvolutionFilter1D := GetModuleSymbol( GLHandle, 'glCopyConvolutionFilter1D');
+ glCopyConvolutionFilter2D := GetModuleSymbol( GLHandle, 'glCopyConvolutionFilter2D');
+ glGetConvolutionFilter := GetModuleSymbol( GLHandle, 'glGetConvolutionFilter');
+ glSeparableFilter2D := GetModuleSymbol( GLHandle, 'glSeparableFilter2D');
+ glGetSeparableFilter := GetModuleSymbol( GLHandle, 'glGetSeparableFilter');
+ glConvolutionParameteri := GetModuleSymbol( GLHandle, 'glConvolutionParameteri');
+ glConvolutionParameteriv := GetModuleSymbol( GLHandle, 'glConvolutionParameteriv');
+ glConvolutionParameterf := GetModuleSymbol( GLHandle, 'glConvolutionParameterf');
+ glConvolutionParameterfv := GetModuleSymbol( GLHandle, 'glConvolutionParameterfv');
+ glGetConvolutionParameteriv := GetModuleSymbol( GLHandle, 'glGetConvolutionParameteriv');
+ glGetConvolutionParameterfv := GetModuleSymbol( GLHandle, 'glGetConvolutionParameterfv');
+ glHistogram := GetModuleSymbol( GLHandle, 'glHistogram');
+ glResetHistogram := GetModuleSymbol( GLHandle, 'glResetHistogram');
+ glGetHistogram := GetModuleSymbol( GLHandle, 'glGetHistogram');
+ glGetHistogramParameteriv := GetModuleSymbol( GLHandle, 'glGetHistogramParameteriv');
+ glGetHistogramParameterfv := GetModuleSymbol( GLHandle, 'glGetHistogramParameterfv');
+ glMinmax := GetModuleSymbol( GLHandle, 'glMinmax');
+ glResetMinmax := GetModuleSymbol( GLHandle, 'glResetMinmax');
+ glGetMinmax := GetModuleSymbol( GLHandle, 'glGetMinmax');
+ glGetMinmaxParameteriv := GetModuleSymbol( GLHandle, 'glGetMinmaxParameteriv');
+ glGetMinmaxParameterfv := GetModuleSymbol( GLHandle, 'glGetMinmaxParameterfv');
+
+ {$ifdef UNIX}
+ glXChooseVisual := GetModuleSymbol( GLHandle, 'glXChooseVisual');
+ glXCreateContext := GetModuleSymbol( GLHandle, 'glXCreateContext');
+ glXDestroyContext := GetModuleSymbol( GLHandle, 'glXDestroyContext');
+ glXMakeCurrent := GetModuleSymbol( GLHandle, 'glXMakeCurrent');
+ glXCopyContext := GetModuleSymbol( GLHandle, 'glXCopyContext');
+ glXSwapBuffers := GetModuleSymbol( GLHandle, 'glXSwapBuffers');
+ glXCreateGLXPixmap := GetModuleSymbol( GLHandle, 'glXCreateGLXPixmap');
+ glXDestroyGLXPixmap := GetModuleSymbol( GLHandle, 'glXDestroyGLXPixmap');
+ glXQueryExtension := GetModuleSymbol( GLHandle, 'glXQueryExtension');
+ glXQueryVersion := GetModuleSymbol( GLHandle, 'glXQueryVersion');
+ glXIsDirect := GetModuleSymbol( GLHandle, 'glXIsDirect');
+ glXGetConfig := GetModuleSymbol( GLHandle, 'glXGetConfig');
+ glXGetCurrentContext := GetModuleSymbol( GLHandle, 'glXGetCurrentContext');
+ glXGetCurrentDrawable := GetModuleSymbol( GLHandle, 'glXGetCurrentDrawable');
+ glXWaitGL := GetModuleSymbol( GLHandle, 'glXWaitGL');
+ glXWaitX := GetModuleSymbol( GLHandle, 'glXWaitX');
+ glXUseXFont := GetModuleSymbol( GLHandle, 'glXUseXFont');
+ glXQueryExtensionsString := GetModuleSymbol( GLHandle, 'glXQueryExtensionsString');
+ glXQueryServerString := GetModuleSymbol( GLHandle, 'glXQueryServerString');
+ glXGetClientString := GetModuleSymbol( GLHandle, 'glXGetClientString');
+ glXGetCurrentDisplay := GetModuleSymbol( GLHandle, 'glXGetCurrentDisplay');
+ glXChooseFBConfig := GetModuleSymbol( GLHandle, 'glXChooseFBConfig');
+ glXGetFBConfigAttrib := GetModuleSymbol( GLHandle, 'glXGetFBConfigAttrib');
+ glXGetFBConfigs := GetModuleSymbol( GLHandle, 'glXGetFBConfigs');
+ glXGetVisualFromFBConfig := GetModuleSymbol( GLHandle, 'glXGetVisualFromFBConfig');
+ glXCreateWindow := GetModuleSymbol( GLHandle, 'glXCreateWindow');
+ glXDestroyWindow := GetModuleSymbol( GLHandle, 'glXDestroyWindow');
+ glXCreatePixmap := GetModuleSymbol( GLHandle, 'glXCreatePixmap');
+ glXDestroyPixmap := GetModuleSymbol( GLHandle, 'glXDestroyPixmap');
+ glXCreatePbuffer := GetModuleSymbol( GLHandle, 'glXCreatePbuffer');
+ glXDestroyPbuffer := GetModuleSymbol( GLHandle, 'glXDestroyPbuffer');
+ glXQueryDrawable := GetModuleSymbol( GLHandle, 'glXQueryDrawable');
+ glXCreateNewContext := GetModuleSymbol( GLHandle, 'glXCreateNewContext');
+ glXMakeContextCurrent := GetModuleSymbol( GLHandle, 'glXMakeContextCurrent');
+ glXGetCurrentReadDrawable := GetModuleSymbol( GLHandle, 'glXGetCurrentReadDrawable');
+ glXQueryContext := GetModuleSymbol( GLHandle, 'glXQueryContext');
+ glXSelectEvent := GetModuleSymbol( GLHandle, 'glXSelectEvent');
+ glXGetSelectedEvent := GetModuleSymbol( GLHandle, 'glXGetSelectedEvent');
+ glXGetVideoSyncSGI := GetModuleSymbol( GLHandle, 'glXGetVideoSyncSGI');
+ glXWaitVideoSyncSGI := GetModuleSymbol( GLHandle, 'glXWaitVideoSyncSGI');
+ glXFreeContextEXT := GetModuleSymbol( GLHandle, 'glXFreeContextEXT');
+ glXGetContextIDEXT := GetModuleSymbol( GLHandle, 'glXGetContextIDEXT');
+ glXGetCurrentDisplayEXT := GetModuleSymbol( GLHandle, 'glXGetCurrentDisplayEXT');
+ glXImportContextEXT := GetModuleSymbol( GLHandle, 'glXImportContextEXT');
+ glXQueryContextInfoEXT := GetModuleSymbol( GLHandle, 'glXQueryContextInfoEXT');
+ glXCopySubBufferMESA := GetModuleSymbol( GLHandle, 'glXCopySubBufferMESA');
+ glXCreateGLXPixmapMESA := GetModuleSymbol( GLHandle, 'glXCreateGLXPixmapMESA');
+ glXReleaseBuffersMESA := GetModuleSymbol( GLHandle, 'glXReleaseBuffersMESA');
+ glXSet3DfxModeMESA := GetModuleSymbol( GLHandle, 'glXSet3DfxModeMESA');
+ {$endif}
+ end;
+
+ if GLUHandle <> INVALID_MODULEHANDLE then
+ begin
+ GLHandle := TModuleHandle(GLUHandle); // Kylix compatiblilty trick
+
+ gluBeginCurve := GetModuleSymbol( GLUHandle, 'gluBeginCurve');
+ gluBeginPolygon := GetModuleSymbol( GLUHandle, 'gluBeginPolygon');
+ gluBeginSurface := GetModuleSymbol( GLUHandle, 'gluBeginSurface');
+ gluBeginTrim := GetModuleSymbol( GLUHandle, 'gluBeginTrim');
+ gluBuild1DMipmaps := GetModuleSymbol( GLUHandle, 'gluBuild1DMipmaps');
+ gluBuild2DMipmaps := GetModuleSymbol( GLUHandle, 'gluBuild2DMipmaps');
+ gluCylinder := GetModuleSymbol( GLUHandle, 'gluCylinder');
+ gluDeleteNurbsRenderer := GetModuleSymbol( GLUHandle, 'gluDeleteNurbsRenderer');
+ gluDeleteQuadric := GetModuleSymbol( GLUHandle, 'gluDeleteQuadric');
+ gluDeleteTess := GetModuleSymbol( GLUHandle, 'gluDeleteTess');
+ gluDisk := GetModuleSymbol( GLUHandle, 'gluDisk');
+ gluEndCurve := GetModuleSymbol( GLUHandle, 'gluEndCurve');
+ gluEndPolygon := GetModuleSymbol( GLUHandle, 'gluEndPolygon');
+ gluEndSurface := GetModuleSymbol( GLUHandle, 'gluEndSurface');
+ gluEndTrim := GetModuleSymbol( GLUHandle, 'gluEndTrim');
+ gluErrorString := GetModuleSymbol( GLUHandle, 'gluErrorString');
+ gluGetNurbsProperty := GetModuleSymbol( GLUHandle, 'gluGetNurbsProperty');
+ gluGetString := GetModuleSymbol( GLUHandle, 'gluGetString');
+ gluGetTessProperty := GetModuleSymbol( GLUHandle, 'gluGetTessProperty');
+ gluLoadSamplingMatrices := GetModuleSymbol( GLUHandle, 'gluLoadSamplingMatrices');
+ gluLookAt := GetModuleSymbol( GLUHandle, 'gluLookAt');
+ gluNewNurbsRenderer := GetModuleSymbol( GLUHandle, 'gluNewNurbsRenderer');
+ gluNewQuadric := GetModuleSymbol( GLUHandle, 'gluNewQuadric');
+ gluNewTess := GetModuleSymbol( GLUHandle, 'gluNewTess');
+ gluNextContour := GetModuleSymbol( GLUHandle, 'gluNextContour');
+ gluNurbsCallback := GetModuleSymbol( GLUHandle, 'gluNurbsCallback');
+ gluNurbsCurve := GetModuleSymbol( GLUHandle, 'gluNurbsCurve');
+ gluNurbsProperty := GetModuleSymbol( GLUHandle, 'gluNurbsProperty');
+ gluNurbsSurface := GetModuleSymbol( GLUHandle, 'gluNurbsSurface');
+ gluOrtho2D := GetModuleSymbol( GLUHandle, 'gluOrtho2D');
+ gluPartialDisk := GetModuleSymbol( GLUHandle, 'gluPartialDisk');
+ gluPerspective := GetModuleSymbol( GLUHandle, 'gluPerspective');
+ gluPickMatrix := GetModuleSymbol( GLUHandle, 'gluPickMatrix');
+ gluProject := GetModuleSymbol( GLUHandle, 'gluProject');
+ gluPwlCurve := GetModuleSymbol( GLUHandle, 'gluPwlCurve');
+ gluQuadricCallback := GetModuleSymbol( GLUHandle, 'gluQuadricCallback');
+ gluQuadricDrawStyle := GetModuleSymbol( GLUHandle, 'gluQuadricDrawStyle');
+ gluQuadricNormals := GetModuleSymbol( GLUHandle, 'gluQuadricNormals');
+ gluQuadricOrientation := GetModuleSymbol( GLUHandle, 'gluQuadricOrientation');
+ gluQuadricTexture := GetModuleSymbol( GLUHandle, 'gluQuadricTexture');
+ gluScaleImage := GetModuleSymbol( GLUHandle, 'gluScaleImage');
+ gluSphere := GetModuleSymbol( GLUHandle, 'gluSphere');
+ gluTessBeginContour := GetModuleSymbol( GLUHandle, 'gluTessBeginContour');
+ gluTessBeginPolygon := GetModuleSymbol( GLUHandle, 'gluTessBeginPolygon');
+ gluTessCallback := GetModuleSymbol( GLUHandle, 'gluTessCallback');
+ gluTessEndContour := GetModuleSymbol( GLUHandle, 'gluTessEndContour');
+ gluTessEndPolygon := GetModuleSymbol( GLUHandle, 'gluTessEndPolygon');
+ gluTessNormal := GetModuleSymbol( GLUHandle, 'gluTessNormal');
+ gluTessProperty := GetModuleSymbol( GLUHandle, 'gluTessProperty');
+ gluTessVertex := GetModuleSymbol( GLUHandle, 'gluTessVertex');
+ gluUnProject := GetModuleSymbol( GLUHandle, 'gluUnProject');
+ end;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure ClearExtensions;
+
+begin
+ glArrayElementEXT := nil;
+ glDrawArraysEXT := nil;
+ glVertexPointerEXT := nil;
+ glNormalPointerEXT := nil;
+ glColorPointerEXT := nil;
+ glIndexPointerEXT := nil;
+ glTexCoordPointerEXT := nil;
+ glEdgeFlagPointerEXT := nil;
+ glGetPointervEXT := nil;
+ glArrayElementArrayEXT := nil;
+ glAddSwapHintRectWIN := nil;
+ glColorTableEXT := nil;
+ glColorSubTableEXT := nil;
+ glGetColorTableEXT := nil;
+ glGetColorTablePameterivEXT := nil;
+ glGetColorTablePameterfvEXT := nil;
+ gluNurbsCallbackDataEXT := nil;
+ gluNewNurbsTessellatorEXT := nil;
+ gluDeleteNurbsTessellatorEXT := nil;
+ glLockArraysEXT := nil;
+ glUnlockArraysEXT := nil;
+ glCopyTexImage1DEXT := nil;
+ glCopyTexSubImage1DEXT := nil;
+ glCopyTexImage2DEXT := nil;
+ glCopyTexSubImage2DEXT := nil;
+ glCopyTexSubImage3DEXT := nil;
+ glCullParameterfvEXT := nil;
+ glCullParameterdvEXT := nil;
+ glIndexFuncEXT := nil;
+ glIndexMaterialEXT := nil;
+ glPolygonOffsetEXT := nil;
+ glTexSubImage1DEXT := nil;
+ glTexSubImage2DEXT := nil;
+ glTexSubImage3DEXT := nil;
+ glGenTexturesEXT := nil;
+ glDeleteTexturesEXT := nil;
+ glBindTextureEXT := nil;
+ glPrioritizeTexturesEXT := nil;
+ glAreTexturesResidentEXT := nil;
+ glIsTextureEXT := nil;
+
+ glMultiTexCoord1dARB := nil;
+ glMultiTexCoord1dVARB := nil;
+ glMultiTexCoord1fARBP := nil;
+ glMultiTexCoord1fVARB := nil;
+ glMultiTexCoord1iARB := nil;
+ glMultiTexCoord1iVARB := nil;
+ glMultiTexCoord1sARBP := nil;
+ glMultiTexCoord1sVARB := nil;
+ glMultiTexCoord2dARB := nil;
+ glMultiTexCoord2dvARB := nil;
+ glMultiTexCoord2fARB := nil;
+ glMultiTexCoord2fvARB := nil;
+ glMultiTexCoord2iARB := nil;
+ glMultiTexCoord2ivARB := nil;
+ glMultiTexCoord2sARB := nil;
+ glMultiTexCoord2svARB := nil;
+ glMultiTexCoord3dARB := nil;
+ glMultiTexCoord3dvARB := nil;
+ glMultiTexCoord3fARB := nil;
+ glMultiTexCoord3fvARB := nil;
+ glMultiTexCoord3iARB := nil;
+ glMultiTexCoord3ivARB := nil;
+ glMultiTexCoord3sARB := nil;
+ glMultiTexCoord3svARB := nil;
+ glMultiTexCoord4dARB := nil;
+ glMultiTexCoord4dvARB := nil;
+ glMultiTexCoord4fARB := nil;
+ glMultiTexCoord4fvARB := nil;
+ glMultiTexCoord4iARB := nil;
+ glMultiTexCoord4ivARB := nil;
+ glMultiTexCoord4sARB := nil;
+ glMultiTexCoord4svARB := nil;
+ glActiveTextureARB := nil;
+ glClientActiveTextureARB := nil;
+
+ // EXT_compiled_vertex_array
+ glLockArrayEXT := nil;
+ glUnlockArrayEXT := nil;
+
+ // EXT_cull_vertex
+ glCullParameterdvEXT := nil;
+ glCullParameterfvEXT := nil;
+
+ // WIN_swap_hint
+ glAddSwapHintRectWIN := nil;
+
+ // EXT_point_parameter
+ glPointParameterfEXT := nil;
+ glPointParameterfvEXT := nil;
+
+ // GL_ARB_transpose_matrix
+ glLoadTransposeMatrixfARB := nil;
+ glLoadTransposeMatrixdARB := nil;
+ glMultTransposeMatrixfARB := nil;
+ glMultTransposeMatrixdARB := nil;
+
+ glSampleCoverageARB := nil;
+ glSamplePassARB := nil;
+
+ // GL_ARB_multisample
+ glCompressedTexImage3DARB := nil;
+ glCompressedTexImage2DARB := nil;
+ glCompressedTexImage1DARB := nil;
+ glCompressedTexSubImage3DARB := nil;
+ glCompressedTexSubImage2DARB := nil;
+ glCompressedTexSubImage1DARB := nil;
+ glGetCompressedTexImageARB := nil;
+
+ // GL_EXT_blend_color
+ glBlendColorEXT := nil;
+
+ // GL_EXT_texture3D
+ glTexImage3DEXT := nil;
+
+ // GL_SGIS_texture_filter4
+ glGetTexFilterFuncSGIS := nil;
+ glTexFilterFuncSGIS := nil;
+
+ // GL_EXT_histogram
+ glGetHistogramEXT := nil;
+ glGetHistogramParameterfvEXT := nil;
+ glGetHistogramParameterivEXT := nil;
+ glGetMinmaxEXT := nil;
+ glGetMinmaxParameterfvEXT := nil;
+ glGetMinmaxParameterivEXT := nil;
+ glHistogramEXT := nil;
+ glMinmaxEXT := nil;
+ glResetHistogramEXT := nil;
+ glResetMinmaxEXT := nil;
+
+ // GL_EXT_convolution
+ glConvolutionFilter1DEXT := nil;
+ glConvolutionFilter2DEXT := nil;
+ glConvolutionParameterfEXT := nil;
+ glConvolutionParameterfvEXT := nil;
+ glConvolutionParameteriEXT := nil;
+ glConvolutionParameterivEXT := nil;
+ glCopyConvolutionFilter1DEXT := nil;
+ glCopyConvolutionFilter2DEXT := nil;
+ glGetConvolutionFilterEXT := nil;
+ glGetConvolutionParameterfvEXT := nil;
+ glGetConvolutionParameterivEXT := nil;
+ glGetSeparableFilterEXT := nil;
+ glSeparableFilter2DEXT := nil;
+
+ // GL_SGI_color_table
+ glColorTableSGI := nil;
+ glColorTableParameterfvSGI := nil;
+ glColorTableParameterivSGI := nil;
+ glCopyColorTableSGI := nil;
+ glGetColorTableSGI := nil;
+ glGetColorTableParameterfvSGI := nil;
+ glGetColorTableParameterivSGI := nil;
+
+ // GL_SGIX_pixel_texture
+ glPixelTexGenSGIX := nil;
+
+ // GL_SGIS_pixel_texture
+ glPixelTexGenParameteriSGIS := nil;
+ glPixelTexGenParameterivSGIS := nil;
+ glPixelTexGenParameterfSGIS := nil;
+ glPixelTexGenParameterfvSGIS := nil;
+ glGetPixelTexGenParameterivSGIS := nil;
+ glGetPixelTexGenParameterfvSGIS := nil;
+
+ // GL_SGIS_texture4D
+ glTexImage4DSGIS := nil;
+ glTexSubImage4DSGIS := nil;
+
+ // GL_SGIS_detail_texture
+ glDetailTexFuncSGIS := nil;
+ glGetDetailTexFuncSGIS := nil;
+
+ // GL_SGIS_sharpen_texture
+ glSharpenTexFuncSGIS := nil;
+ glGetSharpenTexFuncSGIS := nil;
+
+ // GL_SGIS_multisample
+ glSampleMaskSGIS := nil;
+ glSamplePatternSGIS := nil;
+
+ // GL_EXT_blend_minmax
+ glBlendEquationEXT := nil;
+
+ // GL_SGIX_sprite
+ glSpriteParameterfSGIX := nil;
+ glSpriteParameterfvSGIX := nil;
+ glSpriteParameteriSGIX := nil;
+ glSpriteParameterivSGIX := nil;
+
+ // GL_EXT_point_parameters
+ glPointParameterfSGIS := nil;
+ glPointParameterfvSGIS := nil;
+
+ // GL_SGIX_instruments
+ glGetInstrumentsSGIX := nil;
+ glInstrumentsBufferSGIX := nil;
+ glPollInstrumentsSGIX := nil;
+ glReadInstrumentsSGIX := nil;
+ glStartInstrumentsSGIX := nil;
+ glStopInstrumentsSGIX := nil;
+
+ // GL_SGIX_framezoom
+ glFrameZoomSGIX := nil;
+
+ // GL_SGIX_tag_sample_buffer
+ glTagSampleBufferSGIX := nil;
+
+ // GL_SGIX_polynomial_ffd
+ glDeformationMap3dSGIX := nil;
+ glDeformationMap3fSGIX := nil;
+ glDeformSGIX := nil;
+ glLoadIdentityDeformationMapSGIX := nil;
+
+ // GL_SGIX_reference_plane
+ glReferencePlaneSGIX := nil;
+
+ // GL_SGIX_flush_raster
+ glFlushRasterSGIX := nil;
+
+ // GL_SGIS_fog_function
+ glFogFuncSGIS := nil;
+ glGetFogFuncSGIS := nil;
+
+ // GL_HP_image_transform
+ glImageTransformParameteriHP := nil;
+ glImageTransformParameterfHP := nil;
+ glImageTransformParameterivHP := nil;
+ glImageTransformParameterfvHP := nil;
+ glGetImageTransformParameterivHP := nil;
+ glGetImageTransformParameterfvHP := nil;
+
+ // GL_EXT_color_subtable
+ glCopyColorSubTableEXT := nil;
+
+ // GL_PGI_misc_hints
+ glHintPGI := nil;
+
+ // GL_EXT_paletted_texture
+ glGetColorTableParameterivEXT := nil;
+ glGetColorTableParameterfvEXT := nil;
+
+ // GL_SGIX_list_priority
+ glGetListParameterfvSGIX := nil;
+ glGetListParameterivSGIX := nil;
+ glListParameterfSGIX := nil;
+ glListParameterfvSGIX := nil;
+ glListParameteriSGIX := nil;
+ glListParameterivSGIX := nil;
+
+ // GL_SGIX_fragment_lighting
+ glFragmentColorMaterialSGIX := nil;
+ glFragmentLightfSGIX := nil;
+ glFragmentLightfvSGIX := nil;
+ glFragmentLightiSGIX := nil;
+ glFragmentLightivSGIX := nil;
+ glFragmentLightModelfSGIX := nil;
+ glFragmentLightModelfvSGIX := nil;
+ glFragmentLightModeliSGIX := nil;
+ glFragmentLightModelivSGIX := nil;
+ glFragmentMaterialfSGIX := nil;
+ glFragmentMaterialfvSGIX := nil;
+ glFragmentMaterialiSGIX := nil;
+ glFragmentMaterialivSGIX := nil;
+ glGetFragmentLightfvSGIX := nil;
+ glGetFragmentLightivSGIX := nil;
+ glGetFragmentMaterialfvSGIX := nil;
+ glGetFragmentMaterialivSGIX := nil;
+ glLightEnviSGIX := nil;
+
+ // GL_EXT_draw_range_elements
+ glDrawRangeElementsEXT := nil;
+
+ // GL_EXT_light_texture
+ glApplyTextureEXT := nil;
+ glTextureLightEXT := nil;
+ glTextureMaterialEXT := nil;
+
+ // GL_SGIX_async
+ glAsyncMarkerSGIX := nil;
+ glFinishAsyncSGIX := nil;
+ glPollAsyncSGIX := nil;
+ glGenAsyncMarkersSGIX := nil;
+ glDeleteAsyncMarkersSGIX := nil;
+ glIsAsyncMarkerSGIX := nil;
+
+ // GL_INTEL_parallel_arrays
+ glVertexPointervINTEL := nil;
+ glNormalPointervINTEL := nil;
+ glColorPointervINTEL := nil;
+ glTexCoordPointervINTEL := nil;
+
+ // GL_EXT_pixel_transform
+ glPixelTransformParameteriEXT := nil;
+ glPixelTransformParameterfEXT := nil;
+ glPixelTransformParameterivEXT := nil;
+ glPixelTransformParameterfvEXT := nil;
+
+ // GL_EXT_secondary_color
+ glSecondaryColor3bEXT := nil;
+ glSecondaryColor3bvEXT := nil;
+ glSecondaryColor3dEXT := nil;
+ glSecondaryColor3dvEXT := nil;
+ glSecondaryColor3fEXT := nil;
+ glSecondaryColor3fvEXT := nil;
+ glSecondaryColor3iEXT := nil;
+ glSecondaryColor3ivEXT := nil;
+ glSecondaryColor3sEXT := nil;
+ glSecondaryColor3svEXT := nil;
+ glSecondaryColor3ubEXT := nil;
+ glSecondaryColor3ubvEXT := nil;
+ glSecondaryColor3uiEXT := nil;
+ glSecondaryColor3uivEXT := nil;
+ glSecondaryColor3usEXT := nil;
+ glSecondaryColor3usvEXT := nil;
+ glSecondaryColorPointerEXT := nil;
+
+ // GL_EXT_texture_perturb_normal
+ glTextureNormalEXT := nil;
+
+ // GL_EXT_multi_draw_arrays
+ glMultiDrawArraysEXT := nil;
+ glMultiDrawElementsEXT := nil;
+
+ // GL_EXT_fog_coord
+ glFogCoordfEXT := nil;
+ glFogCoordfvEXT := nil;
+ glFogCoorddEXT := nil;
+ glFogCoorddvEXT := nil;
+ glFogCoordPointerEXT := nil;
+
+ // GL_EXT_coordinate_frame
+ glTangent3bEXT := nil;
+ glTangent3bvEXT := nil;
+ glTangent3dEXT := nil;
+ glTangent3dvEXT := nil;
+ glTangent3fEXT := nil;
+ glTangent3fvEXT := nil;
+ glTangent3iEXT := nil;
+ glTangent3ivEXT := nil;
+ glTangent3sEXT := nil;
+ glTangent3svEXT := nil;
+ glBinormal3bEXT := nil;
+ glBinormal3bvEXT := nil;
+ glBinormal3dEXT := nil;
+ glBinormal3dvEXT := nil;
+ glBinormal3fEXT := nil;
+ glBinormal3fvEXT := nil;
+ glBinormal3iEXT := nil;
+ glBinormal3ivEXT := nil;
+ glBinormal3sEXT := nil;
+ glBinormal3svEXT := nil;
+ glTangentPointerEXT := nil;
+ glBinormalPointerEXT := nil;
+
+ // GL_SUNX_constant_data
+ glFinishTextureSUNX := nil;
+
+ // GL_SUN_global_alpha
+ glGlobalAlphaFactorbSUN := nil;
+ glGlobalAlphaFactorsSUN := nil;
+ glGlobalAlphaFactoriSUN := nil;
+ glGlobalAlphaFactorfSUN := nil;
+ glGlobalAlphaFactordSUN := nil;
+ glGlobalAlphaFactorubSUN := nil;
+ glGlobalAlphaFactorusSUN := nil;
+ glGlobalAlphaFactoruiSUN := nil;
+
+ // GL_SUN_triangle_list
+ glReplacementCodeuiSUN := nil;
+ glReplacementCodeusSUN := nil;
+ glReplacementCodeubSUN := nil;
+ glReplacementCodeuivSUN := nil;
+ glReplacementCodeusvSUN := nil;
+ glReplacementCodeubvSUN := nil;
+ glReplacementCodePointerSUN := nil;
+
+ // GL_SUN_vertex
+ glColor4ubVertex2fSUN := nil;
+ glColor4ubVertex2fvSUN := nil;
+ glColor4ubVertex3fSUN := nil;
+ glColor4ubVertex3fvSUN := nil;
+ glColor3fVertex3fSUN := nil;
+ glColor3fVertex3fvSUN := nil;
+ glNormal3fVertex3fSUN := nil;
+ glNormal3fVertex3fvSUN := nil;
+ glColor4fNormal3fVertex3fSUN := nil;
+ glColor4fNormal3fVertex3fvSUN := nil;
+ glTexCoord2fVertex3fSUN := nil;
+ glTexCoord2fVertex3fvSUN := nil;
+ glTexCoord4fVertex4fSUN := nil;
+ glTexCoord4fVertex4fvSUN := nil;
+ glTexCoord2fColor4ubVertex3fSUN := nil;
+ glTexCoord2fColor4ubVertex3fvSUN := nil;
+ glTexCoord2fColor3fVertex3fSUN := nil;
+ glTexCoord2fColor3fVertex3fvSUN := nil;
+ glTexCoord2fNormal3fVertex3fSUN := nil;
+ glTexCoord2fNormal3fVertex3fvSUN := nil;
+ glTexCoord2fColor4fNormal3fVertex3fSUN := nil;
+ glTexCoord2fColor4fNormal3fVertex3fvSUN := nil;
+ glTexCoord4fColor4fNormal3fVertex4fSUN := nil;
+ glTexCoord4fColor4fNormal3fVertex4fvSUN := nil;
+ glReplacementCodeuiVertex3fSUN := nil;
+ glReplacementCodeuiVertex3fvSUN := nil;
+ glReplacementCodeuiColor4ubVertex3fSUN := nil;
+ glReplacementCodeuiColor4ubVertex3fvSUN := nil;
+ glReplacementCodeuiColor3fVertex3fSUN := nil;
+ glReplacementCodeuiColor3fVertex3fvSUN := nil;
+ glReplacementCodeuiNormal3fVertex3fSUN := nil;
+ glReplacementCodeuiNormal3fVertex3fvSUN := nil;
+ glReplacementCodeuiColor4fNormal3fVertex3fSUN := nil;
+ glReplacementCodeuiColor4fNormal3fVertex3fvSUN := nil;
+ glReplacementCodeuiTexCoord2fVertex3fSUN := nil;
+ glReplacementCodeuiTexCoord2fVertex3fvSUN := nil;
+ glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN := nil;
+ glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN := nil;
+ glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN := nil;
+ glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN := nil;
+
+ // GL_EXT_blend_func_separate
+ glBlendFuncSeparateEXT := nil;
+
+ // GL_EXT_vertex_weighting
+ glVertexWeightfEXT := nil;
+ glVertexWeightfvEXT := nil;
+ glVertexWeightPointerEXT := nil;
+
+ // GL_NV_vertex_array_range
+ glFlushVertexArrayRangeNV := nil;
+ glVertexArrayRangeNV := nil;
+ wglAllocateMemoryNV := nil;
+ wglFreeMemoryNV := nil;
+
+ // GL_NV_register_combiners
+ glCombinerParameterfvNV := nil;
+ glCombinerParameterfNV := nil;
+ glCombinerParameterivNV := nil;
+ glCombinerParameteriNV := nil;
+ glCombinerInputNV := nil;
+ glCombinerOutputNV := nil;
+ glFinalCombinerInputNV := nil;
+ glGetCombinerInputParameterfvNV := nil;
+ glGetCombinerInputParameterivNV := nil;
+ glGetCombinerOutputParameterfvNV := nil;
+ glGetCombinerOutputParameterivNV := nil;
+ glGetFinalCombinerInputParameterfvNV := nil;
+ glGetFinalCombinerInputParameterivNV := nil;
+
+ // GL_MESA_resize_buffers
+ glResizeBuffersMESA := nil;
+
+ // GL_MESA_window_pos
+ glWindowPos2dMESA := nil;
+ glWindowPos2dvMESA := nil;
+ glWindowPos2fMESA := nil;
+ glWindowPos2fvMESA := nil;
+ glWindowPos2iMESA := nil;
+ glWindowPos2ivMESA := nil;
+ glWindowPos2sMESA := nil;
+ glWindowPos2svMESA := nil;
+ glWindowPos3dMESA := nil;
+ glWindowPos3dvMESA := nil;
+ glWindowPos3fMESA := nil;
+ glWindowPos3fvMESA := nil;
+ glWindowPos3iMESA := nil;
+ glWindowPos3ivMESA := nil;
+ glWindowPos3sMESA := nil;
+ glWindowPos3svMESA := nil;
+ glWindowPos4dMESA := nil;
+ glWindowPos4dvMESA := nil;
+ glWindowPos4fMESA := nil;
+ glWindowPos4fvMESA := nil;
+ glWindowPos4iMESA := nil;
+ glWindowPos4ivMESA := nil;
+ glWindowPos4sMESA := nil;
+ glWindowPos4svMESA := nil;
+
+ // GL_IBM_multimode_draw_arrays
+ glMultiModeDrawArraysIBM := nil;
+ glMultiModeDrawElementsIBM := nil;
+
+ // GL_IBM_vertex_array_lists
+ glColorPointerListIBM := nil;
+ glSecondaryColorPointerListIBM := nil;
+ glEdgeFlagPointerListIBM := nil;
+ glFogCoordPointerListIBM := nil;
+ glIndexPointerListIBM := nil;
+ glNormalPointerListIBM := nil;
+ glTexCoordPointerListIBM := nil;
+ glVertexPointerListIBM := nil;
+
+ // GL_3DFX_tbuffer
+ glTbufferMask3DFX := nil;
+
+ // GL_EXT_multisample
+ glSampleMaskEXT := nil;
+ glSamplePatternEXT := nil;
+
+ // GL_SGIS_texture_color_mask
+ glTextureColorMaskSGIS := nil;
+
+ // GL_SGIX_igloo_interface
+ glIglooInterfaceSGIX := nil;
+
+ // GLU extensions
+ gluNurbsCallbackDataEXT := nil;
+ gluNewNurbsTessellatorEXT := nil;
+ gluDeleteNurbsTessellatorEXT := nil;
+
+ // GL_NV_vertex_program
+ glAreProgramsResidentNV := nil;
+ glBindProgramNV := nil;
+ glDeleteProgramsNV := nil;
+ glExecuteProgramNV := nil;
+ glGenProgramsNV := nil;
+ glGetProgramParameterdvNV := nil;
+ glGetProgramParameterfvNV := nil;
+ glGetProgramivNV := nil;
+ glGetProgramStringNV := nil;
+ glGetTrackMatrixivNV := nil;
+ glGetVertexAttribdvNV:= nil;
+ glGetVertexAttribfvNV:= nil;
+ glGetVertexAttribivNV:= nil;
+ glGetVertexAttribPointervNV := nil;
+ glIsProgramNV := nil;
+ glLoadProgramNV := nil;
+ glProgramParameter4dNV := nil;
+ glProgramParameter4dvNV := nil;
+ glProgramParameter4fNV := nil;
+ glProgramParameter4fvNV := nil;
+ glProgramParameters4dvNV := nil;
+ glProgramParameters4fvNV := nil;
+ glRequestResidentProgramsNV := nil;
+ glTrackMatrixNV := nil;
+ glVertexAttribPointerNV := nil;
+ glVertexAttrib1dNV := nil;
+ glVertexAttrib1dvNV := nil;
+ glVertexAttrib1fNV := nil;
+ glVertexAttrib1fvNV := nil;
+ glVertexAttrib1sNV := nil;
+ glVertexAttrib1svNV := nil;
+ glVertexAttrib2dNV := nil;
+ glVertexAttrib2dvNV := nil;
+ glVertexAttrib2fNV := nil;
+ glVertexAttrib2fvNV := nil;
+ glVertexAttrib2sNV := nil;
+ glVertexAttrib2svNV := nil;
+ glVertexAttrib3dNV := nil;
+ glVertexAttrib3dvNV := nil;
+ glVertexAttrib3fNV := nil;
+ glVertexAttrib3fvNV := nil;
+ glVertexAttrib3sNV := nil;
+ glVertexAttrib3svNV := nil;
+ glVertexAttrib4dNV := nil;
+ glVertexAttrib4dvNV := nil;
+ glVertexAttrib4fNV := nil;
+ glVertexAttrib4fvNV := nil;
+ glVertexAttrib4sNV := nil;
+ glVertexAttrib4svNV := nil;
+ glVertexAttrib4ubvNV := nil;
+ glVertexAttribs1dvNV := nil;
+ glVertexAttribs1fvNV := nil;
+ glVertexAttribs1svNV := nil;
+ glVertexAttribs2dvNV := nil;
+ glVertexAttribs2fvNV := nil;
+ glVertexAttribs2svNV := nil;
+ glVertexAttribs3dvNV := nil;
+ glVertexAttribs3fvNV := nil;
+ glVertexAttribs3svNV := nil;
+ glVertexAttribs4dvNV := nil;
+ glVertexAttribs4fvNV := nil;
+ glVertexAttribs4svNV := nil;
+ glVertexAttribs4ubvNV := nil;
+
+ LastPixelFormat := 0; // to get synchronized again, if this proc was called from outside
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+{$ifdef Win32}
+
+function HasActiveContext: Boolean;
+
+// Returns True if the caller thread has an active (current) rendering context.
+
+begin
+ Result := ActivationRefCount > 0;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure ReadExtensions;
+begin
+ if GLHandle <> INVALID_MODULEHANDLE then
+ begin
+ // GL extensions
+ glArrayElementArrayEXT := SDL_GL_GetProcAddress( 'glArrayElementArrayEXT');
+ glColorTableEXT := SDL_GL_GetProcAddress( 'glColorTableEXT');
+ glColorSubTableEXT := SDL_GL_GetProcAddress( 'glColorSubTableEXT');
+ glGetColorTableEXT := SDL_GL_GetProcAddress( 'glGetColorTableEXT');
+ glGetColorTablePameterivEXT := SDL_GL_GetProcAddress( 'glGetColorTablePameterivEXT');
+ glGetColorTablePameterfvEXT := SDL_GL_GetProcAddress( 'glGetColorTablePameterfvEXT');
+ glLockArraysEXT := SDL_GL_GetProcAddress( 'glLockArraysEXT');
+ glUnlockArraysEXT := SDL_GL_GetProcAddress( 'glUnlockArraysEXT');
+ glCopyTexImage1DEXT := SDL_GL_GetProcAddress( 'glCopyTexImage1DEXT');
+ glCopyTexSubImage1DEXT := SDL_GL_GetProcAddress( 'glCopyTexSubImage1DEXT');
+ glCopyTexImage2DEXT := SDL_GL_GetProcAddress( 'glCopyTexImage2DEXT');
+ glCopyTexSubImage2DEXT := SDL_GL_GetProcAddress( 'glCopyTexSubImage2DEXT');
+ glCopyTexSubImage3DEXT := SDL_GL_GetProcAddress( 'glCopyTexSubImage3DEXT');
+ glIndexFuncEXT := GetModuleSymbol( GLHandle, 'glIndexFuncEXT');
+ glIndexMaterialEXT := SDL_GL_GetProcAddress( 'glIndexMaterialEXT');
+ glPolygonOffsetEXT := SDL_GL_GetProcAddress( 'glPolygonOffsetEXT');
+ glTexSubImage1dEXT := SDL_GL_GetProcAddress( 'glTexSubImage1DEXT');
+ glTexSubImage2dEXT := SDL_GL_GetProcAddress( 'glTexSubImage2DEXT');
+ glTexSubImage3dEXT := SDL_GL_GetProcAddress( 'glTexSubImage3DEXT');
+ glGenTexturesEXT := SDL_GL_GetProcAddress( 'glGenTexturesEXT');
+ glDeleteTexturesEXT := SDL_GL_GetProcAddress( 'glDeleteTexturesEXT');
+ glBindTextureEXT := SDL_GL_GetProcAddress( 'glBindTextureEXT');
+ glPrioritizeTexturesEXT := SDL_GL_GetProcAddress( 'glPrioritizeTexturesEXT');
+ glAreTexturesResidentEXT := SDL_GL_GetProcAddress( 'glAreTexturesResidentEXT');
+ glIsTextureEXT := GetModuleSymbol( GLHandle, 'glIsTextureEXT');
+
+ // EXT_vertex_array
+ glArrayElementEXT := SDL_GL_GetProcAddress( 'glArrayElementEXT');
+ glColorPointerEXT := SDL_GL_GetProcAddress( 'glColorPointerEXT');
+ glDrawArraysEXT := SDL_GL_GetProcAddress( 'glDrawArraysEXT');
+ glEdgeFlagPointerEXT := SDL_GL_GetProcAddress( 'glEdgeFlagPointerEXT');
+ glGetPointervEXT := SDL_GL_GetProcAddress( 'glGetPointervEXT');
+ glIndexPointerEXT := SDL_GL_GetProcAddress( 'glIndexPointerEXT');
+ glNormalPointerEXT := SDL_GL_GetProcAddress( 'glNormalPointerEXT');
+ glTexCoordPointerEXT := SDL_GL_GetProcAddress( 'glTexCoordPointerEXT');
+ glVertexPointerEXT := SDL_GL_GetProcAddress( 'glVertexPointerEXT');
+
+ // ARB_multitexture
+ glMultiTexCoord1dARB := SDL_GL_GetProcAddress( 'glMultiTexCoord1dARB');
+ glMultiTexCoord1dVARB := SDL_GL_GetProcAddress( 'glMultiTexCoord1dVARB');
+ glMultiTexCoord1fARBP := SDL_GL_GetProcAddress( 'glMultiTexCoord1fARBP');
+ glMultiTexCoord1fVARB := SDL_GL_GetProcAddress( 'glMultiTexCoord1fVARB');
+ glMultiTexCoord1iARB := SDL_GL_GetProcAddress( 'glMultiTexCoord1iARB');
+ glMultiTexCoord1iVARB := SDL_GL_GetProcAddress( 'glMultiTexCoord1iVARB');
+ glMultiTexCoord1sARBP := SDL_GL_GetProcAddress( 'glMultiTexCoord1sARBP');
+ glMultiTexCoord1sVARB := SDL_GL_GetProcAddress( 'glMultiTexCoord1sVARB');
+ glMultiTexCoord2dARB := SDL_GL_GetProcAddress( 'glMultiTexCoord2dARB');
+ glMultiTexCoord2dvARB := SDL_GL_GetProcAddress( 'glMultiTexCoord2dvARB');
+ glMultiTexCoord2fARB := SDL_GL_GetProcAddress( 'glMultiTexCoord2fARB');
+ glMultiTexCoord2fvARB := SDL_GL_GetProcAddress( 'glMultiTexCoord2fvARB');
+ glMultiTexCoord2iARB := SDL_GL_GetProcAddress( 'glMultiTexCoord2iARB');
+ glMultiTexCoord2ivARB := SDL_GL_GetProcAddress( 'glMultiTexCoord2ivARB');
+ glMultiTexCoord2sARB := SDL_GL_GetProcAddress( 'glMultiTexCoord2sARB');
+ glMultiTexCoord2svARB := SDL_GL_GetProcAddress( 'glMultiTexCoord2svARB');
+ glMultiTexCoord3dARB := SDL_GL_GetProcAddress( 'glMultiTexCoord3dARB');
+ glMultiTexCoord3dvARB := SDL_GL_GetProcAddress( 'glMultiTexCoord3dvARB');
+ glMultiTexCoord3fARB := SDL_GL_GetProcAddress( 'glMultiTexCoord3fARB');
+ glMultiTexCoord3fvARB := SDL_GL_GetProcAddress( 'glMultiTexCoord3fvARB');
+ glMultiTexCoord3iARB := SDL_GL_GetProcAddress( 'glMultiTexCoord3iARB');
+ glMultiTexCoord3ivARB := SDL_GL_GetProcAddress( 'glMultiTexCoord3ivARB');
+ glMultiTexCoord3sARB := SDL_GL_GetProcAddress( 'glMultiTexCoord3sARB');
+ glMultiTexCoord3svARB := SDL_GL_GetProcAddress( 'glMultiTexCoord3svARB');
+ glMultiTexCoord4dARB := SDL_GL_GetProcAddress( 'glMultiTexCoord4dARB');
+ glMultiTexCoord4dvARB := SDL_GL_GetProcAddress( 'glMultiTexCoord4dvARB');
+ glMultiTexCoord4fARB := SDL_GL_GetProcAddress( 'glMultiTexCoord4fARB');
+ glMultiTexCoord4fvARB := SDL_GL_GetProcAddress( 'glMultiTexCoord4fvARB');
+ glMultiTexCoord4iARB := SDL_GL_GetProcAddress( 'glMultiTexCoord4iARB');
+ glMultiTexCoord4ivARB := SDL_GL_GetProcAddress( 'glMultiTexCoord4ivARB');
+ glMultiTexCoord4sARB := SDL_GL_GetProcAddress( 'glMultiTexCoord4sARB');
+ glMultiTexCoord4svARB := SDL_GL_GetProcAddress( 'glMultiTexCoord4svARB');
+ glActiveTextureARB := SDL_GL_GetProcAddress( 'glActiveTextureARB');
+ glClientActiveTextureARB := SDL_GL_GetProcAddress( 'glClientActiveTextureARB');
+
+ // EXT_compiled_vertex_array
+ glLockArrayEXT := SDL_GL_GetProcAddress( 'glLockArrayEXT');
+ glUnlockArrayEXT := SDL_GL_GetProcAddress( 'glUnlockArrayEXT');
+
+ // EXT_cull_vertex
+ glCullParameterdvEXT := SDL_GL_GetProcAddress( 'glCullParameterdvEXT');
+ glCullParameterfvEXT := SDL_GL_GetProcAddress( 'glCullParameterfvEXT');
+
+ // WIN_swap_hint
+ glAddSwapHintRectWIN := SDL_GL_GetProcAddress( 'glAddSwapHintRectWIN');
+
+ // EXT_point_parameter
+ glPointParameterfEXT := SDL_GL_GetProcAddress( 'glPointParameterfEXT');
+ glPointParameterfvEXT := SDL_GL_GetProcAddress( 'glPointParameterfvEXT');
+
+ // GL_ARB_transpose_matrix
+ glLoadTransposeMatrixfARB := SDL_GL_GetProcAddress( 'glLoadTransposeMatrixfARB');
+ glLoadTransposeMatrixdARB := SDL_GL_GetProcAddress( 'glLoadTransposeMatrixdARB');
+ glMultTransposeMatrixfARB := SDL_GL_GetProcAddress( 'glMultTransposeMatrixfARB');
+ glMultTransposeMatrixdARB := SDL_GL_GetProcAddress( 'glMultTransposeMatrixdARB');
+
+ glSampleCoverageARB := SDL_GL_GetProcAddress( 'glSampleCoverageARB');
+ glSamplePassARB := SDL_GL_GetProcAddress( 'glSamplePassARB');
+
+ // GL_ARB_multisample
+ glCompressedTexImage3DARB := SDL_GL_GetProcAddress( 'glCompressedTexImage3DARB');
+ glCompressedTexImage2DARB := SDL_GL_GetProcAddress( 'glCompressedTexImage2DARB');
+ glCompressedTexImage1DARB := SDL_GL_GetProcAddress( 'glCompressedTexImage1DARB');
+ glCompressedTexSubImage3DARB := SDL_GL_GetProcAddress( 'glCompressedTexSubImage3DARB');
+ glCompressedTexSubImage2DARB := SDL_GL_GetProcAddress( 'glCompressedTexSubImage2DARB');
+ glCompressedTexSubImage1DARB := SDL_GL_GetProcAddress( 'glCompressedTexSubImage1DARB');
+ glGetCompressedTexImageARB := SDL_GL_GetProcAddress( 'glGetCompressedTexImageARB');
+
+ // GL_EXT_blend_color
+ glBlendColorEXT := SDL_GL_GetProcAddress( 'glBlendColorEXT');
+
+ // GL_EXT_texture3D
+ glTexImage3DEXT := SDL_GL_GetProcAddress( 'glTexImage3DEXT');
+
+ // GL_SGIS_texture_filter4
+ glGetTexFilterFuncSGIS := SDL_GL_GetProcAddress( 'glGetTexFilterFuncSGIS');
+ glTexFilterFuncSGIS := SDL_GL_GetProcAddress( 'glTexFilterFuncSGIS');
+
+ // GL_EXT_histogram
+ glGetHistogramEXT := SDL_GL_GetProcAddress( 'glGetHistogramEXT');
+ glGetHistogramParameterfvEXT := SDL_GL_GetProcAddress( 'glGetHistogramParameterfvEXT');
+ glGetHistogramParameterivEXT := SDL_GL_GetProcAddress( 'glGetHistogramParameterivEXT');
+ glGetMinmaxEXT := SDL_GL_GetProcAddress( 'glGetMinmaxEXT');
+ glGetMinmaxParameterfvEXT := SDL_GL_GetProcAddress( 'glGetMinmaxParameterfvEXT');
+ glGetMinmaxParameterivEXT := SDL_GL_GetProcAddress( 'glGetMinmaxParameterivEXT');
+ glHistogramEXT := SDL_GL_GetProcAddress( 'glHistogramEXT');
+ glMinmaxEXT := SDL_GL_GetProcAddress( 'glMinmaxEXT');
+ glResetHistogramEXT := SDL_GL_GetProcAddress( 'glResetHistogramEXT');
+ glResetMinmaxEXT := SDL_GL_GetProcAddress( 'glResetMinmaxEXT');
+
+ // GL_EXT_convolution
+ glConvolutionFilter1DEXT := SDL_GL_GetProcAddress( 'glConvolutionFilter1DEXT');
+ glConvolutionFilter2DEXT := SDL_GL_GetProcAddress( 'glConvolutionFilter2DEXT');
+ glConvolutionParameterfEXT := SDL_GL_GetProcAddress( 'glConvolutionParameterfEXT');
+ glConvolutionParameterfvEXT := SDL_GL_GetProcAddress( 'glConvolutionParameterfvEXT');
+ glConvolutionParameteriEXT := SDL_GL_GetProcAddress( 'glConvolutionParameteriEXT');
+ glConvolutionParameterivEXT := SDL_GL_GetProcAddress( 'glConvolutionParameterivEXT');
+ glCopyConvolutionFilter1DEXT := SDL_GL_GetProcAddress( 'glCopyConvolutionFilter1DEXT');
+ glCopyConvolutionFilter2DEXT := SDL_GL_GetProcAddress( 'glCopyConvolutionFilter2DEXT');
+ glGetConvolutionFilterEXT := SDL_GL_GetProcAddress( 'glGetConvolutionFilterEXT');
+ glGetConvolutionParameterfvEXT := SDL_GL_GetProcAddress( 'glGetConvolutionParameterfvEXT');
+ glGetConvolutionParameterivEXT := SDL_GL_GetProcAddress( 'glGetConvolutionParameterivEXT');
+ glGetSeparableFilterEXT := SDL_GL_GetProcAddress( 'glGetSeparableFilterEXT');
+ glSeparableFilter2DEXT := SDL_GL_GetProcAddress( 'glSeparableFilter2DEXT');
+
+ // GL_SGI_color_table
+ glColorTableSGI := SDL_GL_GetProcAddress( 'glColorTableSGI');
+ glColorTableParameterfvSGI := SDL_GL_GetProcAddress( 'glColorTableParameterfvSGI');
+ glColorTableParameterivSGI := SDL_GL_GetProcAddress( 'glColorTableParameterivSGI');
+ glCopyColorTableSGI := SDL_GL_GetProcAddress( 'glCopyColorTableSGI');
+ glGetColorTableSGI := SDL_GL_GetProcAddress( 'glGetColorTableSGI');
+ glGetColorTableParameterfvSGI := SDL_GL_GetProcAddress( 'glGetColorTableParameterfvSGI');
+ glGetColorTableParameterivSGI := SDL_GL_GetProcAddress( 'glGetColorTableParameterivSGI');
+
+ // GL_SGIX_pixel_texture
+ glPixelTexGenSGIX := SDL_GL_GetProcAddress( 'glPixelTexGenSGIX');
+
+ // GL_SGIS_pixel_texture
+ glPixelTexGenParameteriSGIS := SDL_GL_GetProcAddress( 'glPixelTexGenParameteriSGIS');
+ glPixelTexGenParameterivSGIS := SDL_GL_GetProcAddress( 'glPixelTexGenParameterivSGIS');
+ glPixelTexGenParameterfSGIS := SDL_GL_GetProcAddress( 'glPixelTexGenParameterfSGIS');
+ glPixelTexGenParameterfvSGIS := SDL_GL_GetProcAddress( 'glPixelTexGenParameterfvSGIS');
+ glGetPixelTexGenParameterivSGIS := SDL_GL_GetProcAddress( 'glGetPixelTexGenParameterivSGIS');
+ glGetPixelTexGenParameterfvSGIS := SDL_GL_GetProcAddress( 'glGetPixelTexGenParameterfvSGIS');
+
+ // GL_SGIS_texture4D
+ glTexImage4DSGIS := SDL_GL_GetProcAddress( 'glTexImage4DSGIS');
+ glTexSubImage4DSGIS := SDL_GL_GetProcAddress( 'glTexSubImage4DSGIS');
+
+ // GL_SGIS_detail_texture
+ glDetailTexFuncSGIS := SDL_GL_GetProcAddress( 'glDetailTexFuncSGIS');
+ glGetDetailTexFuncSGIS := SDL_GL_GetProcAddress( 'glGetDetailTexFuncSGIS');
+
+ // GL_SGIS_sharpen_texture
+ glSharpenTexFuncSGIS := SDL_GL_GetProcAddress( 'glSharpenTexFuncSGIS');
+ glGetSharpenTexFuncSGIS := SDL_GL_GetProcAddress( 'glGetSharpenTexFuncSGIS');
+
+ // GL_SGIS_multisample
+ glSampleMaskSGIS := SDL_GL_GetProcAddress( 'glSampleMaskSGIS');
+ glSamplePatternSGIS := SDL_GL_GetProcAddress( 'glSamplePatternSGIS');
+
+ // GL_EXT_blend_minmax
+ glBlendEquationEXT := SDL_GL_GetProcAddress( 'glBlendEquationEXT');
+
+ // GL_SGIX_sprite
+ glSpriteParameterfSGIX := SDL_GL_GetProcAddress( 'glSpriteParameterfSGIX');
+ glSpriteParameterfvSGIX := SDL_GL_GetProcAddress( 'glSpriteParameterfvSGIX');
+ glSpriteParameteriSGIX := SDL_GL_GetProcAddress( 'glSpriteParameteriSGIX');
+ glSpriteParameterivSGIX := SDL_GL_GetProcAddress( 'glSpriteParameterivSGIX');
+
+ // GL_EXT_point_parameters
+ glPointParameterfSGIS := SDL_GL_GetProcAddress( 'glPointParameterfSGIS');
+ glPointParameterfvSGIS := SDL_GL_GetProcAddress( 'glPointParameterfvSGIS');
+
+ // GL_SGIX_instruments
+ glGetInstrumentsSGIX := SDL_GL_GetProcAddress( 'glGetInstrumentsSGIX');
+ glInstrumentsBufferSGIX := SDL_GL_GetProcAddress( 'glInstrumentsBufferSGIX');
+ glPollInstrumentsSGIX := SDL_GL_GetProcAddress( 'glPollInstrumentsSGIX');
+ glReadInstrumentsSGIX := SDL_GL_GetProcAddress( 'glReadInstrumentsSGIX');
+ glStartInstrumentsSGIX := SDL_GL_GetProcAddress( 'glStartInstrumentsSGIX');
+ glStopInstrumentsSGIX := SDL_GL_GetProcAddress( 'glStopInstrumentsSGIX');
+
+ // GL_SGIX_framezoom
+ glFrameZoomSGIX := SDL_GL_GetProcAddress( 'glFrameZoomSGIX');
+
+ // GL_SGIX_tag_sample_buffer
+ glTagSampleBufferSGIX := SDL_GL_GetProcAddress( 'glTagSampleBufferSGIX');
+
+ // GL_SGIX_polynomial_ffd
+ glDeformationMap3dSGIX := SDL_GL_GetProcAddress( 'glDeformationMap3dSGIX');
+ glDeformationMap3fSGIX := SDL_GL_GetProcAddress( 'glDeformationMap3fSGIX');
+ glDeformSGIX := SDL_GL_GetProcAddress( 'glDeformSGIX');
+ glLoadIdentityDeformationMapSGIX := SDL_GL_GetProcAddress( 'glLoadIdentityDeformationMapSGIX');
+
+ // GL_SGIX_reference_plane
+ glReferencePlaneSGIX := SDL_GL_GetProcAddress( 'glReferencePlaneSGIX');
+
+ // GL_SGIX_flush_raster
+ glFlushRasterSGIX := SDL_GL_GetProcAddress( 'glFlushRasterSGIX');
+
+ // GL_SGIS_fog_function
+ glFogFuncSGIS := SDL_GL_GetProcAddress( 'glFogFuncSGIS');
+ glGetFogFuncSGIS := SDL_GL_GetProcAddress( 'glGetFogFuncSGIS');
+
+ // GL_HP_image_transform
+ glImageTransformParameteriHP := SDL_GL_GetProcAddress( 'glImageTransformParameteriHP');
+ glImageTransformParameterfHP := SDL_GL_GetProcAddress( 'glImageTransformParameterfHP');
+ glImageTransformParameterivHP := SDL_GL_GetProcAddress( 'glImageTransformParameterivHP');
+ glImageTransformParameterfvHP := SDL_GL_GetProcAddress( 'glImageTransformParameterfvHP');
+ glGetImageTransformParameterivHP := SDL_GL_GetProcAddress( 'glGetImageTransformParameterivHP');
+ glGetImageTransformParameterfvHP := SDL_GL_GetProcAddress( 'glGetImageTransformParameterfvHP');
+
+ // GL_EXT_color_subtable
+ glCopyColorSubTableEXT := SDL_GL_GetProcAddress( 'glCopyColorSubTableEXT');
+
+ // GL_PGI_misc_hints
+ glHintPGI := SDL_GL_GetProcAddress( 'glHintPGI');
+
+ // GL_EXT_paletted_texture
+ glGetColorTableParameterivEXT := SDL_GL_GetProcAddress( 'glGetColorTableParameterivEXT');
+ glGetColorTableParameterfvEXT := SDL_GL_GetProcAddress( 'glGetColorTableParameterfvEXT');
+
+ // GL_SGIX_list_priority
+ glGetListParameterfvSGIX := SDL_GL_GetProcAddress( 'glGetListParameterfvSGIX');
+ glGetListParameterivSGIX := SDL_GL_GetProcAddress( 'glGetListParameterivSGIX');
+ glListParameterfSGIX := SDL_GL_GetProcAddress( 'glListParameterfSGIX');
+ glListParameterfvSGIX := SDL_GL_GetProcAddress( 'glListParameterfvSGIX');
+ glListParameteriSGIX := SDL_GL_GetProcAddress( 'glListParameteriSGIX');
+ glListParameterivSGIX := SDL_GL_GetProcAddress( 'glListParameterivSGIX');
+
+ // GL_SGIX_fragment_lighting
+ glFragmentColorMaterialSGIX := SDL_GL_GetProcAddress( 'glFragmentColorMaterialSGIX');
+ glFragmentLightfSGIX := SDL_GL_GetProcAddress( 'glFragmentLightfSGIX');
+ glFragmentLightfvSGIX := SDL_GL_GetProcAddress( 'glFragmentLightfvSGIX');
+ glFragmentLightiSGIX := SDL_GL_GetProcAddress( 'glFragmentLightiSGIX');
+ glFragmentLightivSGIX := SDL_GL_GetProcAddress( 'glFragmentLightivSGIX');
+ glFragmentLightModelfSGIX := SDL_GL_GetProcAddress( 'glFragmentLightModelfSGIX');
+ glFragmentLightModelfvSGIX := SDL_GL_GetProcAddress( 'glFragmentLightModelfvSGIX');
+ glFragmentLightModeliSGIX := SDL_GL_GetProcAddress( 'glFragmentLightModeliSGIX');
+ glFragmentLightModelivSGIX := SDL_GL_GetProcAddress( 'glFragmentLightModelivSGIX');
+ glFragmentMaterialfSGIX := SDL_GL_GetProcAddress( 'glFragmentMaterialfSGIX');
+ glFragmentMaterialfvSGIX := SDL_GL_GetProcAddress( 'glFragmentMaterialfvSGIX');
+ glFragmentMaterialiSGIX := SDL_GL_GetProcAddress( 'glFragmentMaterialiSGIX');
+ glFragmentMaterialivSGIX := SDL_GL_GetProcAddress( 'glFragmentMaterialivSGIX');
+ glGetFragmentLightfvSGIX := SDL_GL_GetProcAddress( 'glGetFragmentLightfvSGIX');
+ glGetFragmentLightivSGIX := SDL_GL_GetProcAddress( 'glGetFragmentLightivSGIX');
+ glGetFragmentMaterialfvSGIX := SDL_GL_GetProcAddress( 'glGetFragmentMaterialfvSGIX');
+ glGetFragmentMaterialivSGIX := SDL_GL_GetProcAddress( 'glGetFragmentMaterialivSGIX');
+ glLightEnviSGIX := SDL_GL_GetProcAddress( 'glLightEnviSGIX');
+
+ // GL_EXT_draw_range_elements
+ glDrawRangeElementsEXT := SDL_GL_GetProcAddress( 'glDrawRangeElementsEXT');
+
+ // GL_EXT_light_texture
+ glApplyTextureEXT := SDL_GL_GetProcAddress( 'glApplyTextureEXT');
+ glTextureLightEXT := SDL_GL_GetProcAddress( 'glTextureLightEXT');
+ glTextureMaterialEXT := SDL_GL_GetProcAddress( 'glTextureMaterialEXT');
+
+ // GL_SGIX_async
+ glAsyncMarkerSGIX := SDL_GL_GetProcAddress( 'glAsyncMarkerSGIX');
+ glFinishAsyncSGIX := SDL_GL_GetProcAddress( 'glFinishAsyncSGIX');
+ glPollAsyncSGIX := SDL_GL_GetProcAddress( 'glPollAsyncSGIX');
+ glGenAsyncMarkersSGIX := SDL_GL_GetProcAddress( 'glGenAsyncMarkersSGIX');
+ glDeleteAsyncMarkersSGIX := SDL_GL_GetProcAddress( 'glDeleteAsyncMarkersSGIX');
+ glIsAsyncMarkerSGIX := SDL_GL_GetProcAddress( 'glIsAsyncMarkerSGIX');
+
+ // GL_INTEL_parallel_arrays
+ glVertexPointervINTEL := SDL_GL_GetProcAddress( 'glVertexPointervINTEL');
+ glNormalPointervINTEL := SDL_GL_GetProcAddress( 'glNormalPointervINTEL');
+ glColorPointervINTEL := SDL_GL_GetProcAddress( 'glColorPointervINTEL');
+ glTexCoordPointervINTEL := SDL_GL_GetProcAddress( 'glTexCoordPointervINTEL');
+
+ // GL_EXT_pixel_transform
+ glPixelTransformParameteriEXT := SDL_GL_GetProcAddress( 'glPixelTransformParameteriEXT');
+ glPixelTransformParameterfEXT := SDL_GL_GetProcAddress( 'glPixelTransformParameterfEXT');
+ glPixelTransformParameterivEXT := SDL_GL_GetProcAddress( 'glPixelTransformParameterivEXT');
+ glPixelTransformParameterfvEXT := SDL_GL_GetProcAddress( 'glPixelTransformParameterfvEXT');
+
+ // GL_EXT_secondary_color
+ glSecondaryColor3bEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3bEXT');
+ glSecondaryColor3bvEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3bvEXT');
+ glSecondaryColor3dEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3dEXT');
+ glSecondaryColor3dvEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3dvEXT');
+ glSecondaryColor3fEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3fEXT');
+ glSecondaryColor3fvEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3fvEXT');
+ glSecondaryColor3iEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3iEXT');
+ glSecondaryColor3ivEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3ivEXT');
+ glSecondaryColor3sEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3sEXT');
+ glSecondaryColor3svEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3svEXT');
+ glSecondaryColor3ubEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3ubEXT');
+ glSecondaryColor3ubvEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3ubvEXT');
+ glSecondaryColor3uiEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3uiEXT');
+ glSecondaryColor3uivEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3uivEXT');
+ glSecondaryColor3usEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3usEXT');
+ glSecondaryColor3usvEXT := SDL_GL_GetProcAddress( 'glSecondaryColor3usvEXT');
+ glSecondaryColorPointerEXT := SDL_GL_GetProcAddress( 'glSecondaryColorPointerEXT');
+
+ // GL_EXT_texture_perturb_normal
+ glTextureNormalEXT := SDL_GL_GetProcAddress( 'glTextureNormalEXT');
+
+ // GL_EXT_multi_draw_arrays
+ glMultiDrawArraysEXT := SDL_GL_GetProcAddress( 'glMultiDrawArraysEXT');
+ glMultiDrawElementsEXT := SDL_GL_GetProcAddress( 'glMultiDrawElementsEXT');
+
+ // GL_EXT_fog_coord
+ glFogCoordfEXT := SDL_GL_GetProcAddress( 'glFogCoordfEXT');
+ glFogCoordfvEXT := SDL_GL_GetProcAddress( 'glFogCoordfvEXT');
+ glFogCoorddEXT := SDL_GL_GetProcAddress( 'glFogCoorddEXT');
+ glFogCoorddvEXT := SDL_GL_GetProcAddress( 'glFogCoorddvEXT');
+ glFogCoordPointerEXT := SDL_GL_GetProcAddress( 'glFogCoordPointerEXT');
+
+ // GL_EXT_coordinate_frame
+ glTangent3bEXT := SDL_GL_GetProcAddress( 'glTangent3bEXT');
+ glTangent3bvEXT := SDL_GL_GetProcAddress( 'glTangent3bvEXT');
+ glTangent3dEXT := SDL_GL_GetProcAddress( 'glTangent3dEXT');
+ glTangent3dvEXT := SDL_GL_GetProcAddress( 'glTangent3dvEXT');
+ glTangent3fEXT := SDL_GL_GetProcAddress( 'glTangent3fEXT');
+ glTangent3fvEXT := SDL_GL_GetProcAddress( 'glTangent3fvEXT');
+ glTangent3iEXT := SDL_GL_GetProcAddress( 'glTangent3iEXT');
+ glTangent3ivEXT := SDL_GL_GetProcAddress( 'glTangent3ivEXT');
+ glTangent3sEXT := SDL_GL_GetProcAddress( 'glTangent3sEXT');
+ glTangent3svEXT := SDL_GL_GetProcAddress( 'glTangent3svEXT');
+ glBinormal3bEXT := SDL_GL_GetProcAddress( 'glBinormal3bEXT');
+ glBinormal3bvEXT := SDL_GL_GetProcAddress( 'glBinormal3bvEXT');
+ glBinormal3dEXT := SDL_GL_GetProcAddress( 'glBinormal3dEXT');
+ glBinormal3dvEXT := SDL_GL_GetProcAddress( 'glBinormal3dvEXT');
+ glBinormal3fEXT := SDL_GL_GetProcAddress( 'glBinormal3fEXT');
+ glBinormal3fvEXT := SDL_GL_GetProcAddress( 'glBinormal3fvEXT');
+ glBinormal3iEXT := SDL_GL_GetProcAddress( 'glBinormal3iEXT');
+ glBinormal3ivEXT := SDL_GL_GetProcAddress( 'glBinormal3ivEXT');
+ glBinormal3sEXT := SDL_GL_GetProcAddress( 'glBinormal3sEXT');
+ glBinormal3svEXT := SDL_GL_GetProcAddress( 'glBinormal3svEXT');
+ glTangentPointerEXT := SDL_GL_GetProcAddress( 'glTangentPointerEXT');
+ glBinormalPointerEXT := SDL_GL_GetProcAddress( 'glBinormalPointerEXT');
+
+ // GL_SUNX_constant_data
+ glFinishTextureSUNX := SDL_GL_GetProcAddress( 'glFinishTextureSUNX');
+
+ // GL_SUN_global_alpha
+ glGlobalAlphaFactorbSUN := SDL_GL_GetProcAddress( 'glGlobalAlphaFactorbSUN');
+ glGlobalAlphaFactorsSUN := SDL_GL_GetProcAddress( 'glGlobalAlphaFactorsSUN');
+ glGlobalAlphaFactoriSUN := SDL_GL_GetProcAddress( 'glGlobalAlphaFactoriSUN');
+ glGlobalAlphaFactorfSUN := SDL_GL_GetProcAddress( 'glGlobalAlphaFactorfSUN');
+ glGlobalAlphaFactordSUN := SDL_GL_GetProcAddress( 'glGlobalAlphaFactordSUN');
+ glGlobalAlphaFactorubSUN := SDL_GL_GetProcAddress( 'glGlobalAlphaFactorubSUN');
+ glGlobalAlphaFactorusSUN := SDL_GL_GetProcAddress( 'glGlobalAlphaFactorusSUN');
+ glGlobalAlphaFactoruiSUN := SDL_GL_GetProcAddress( 'glGlobalAlphaFactoruiSUN');
+
+ // GL_SUN_triangle_list
+ glReplacementCodeuiSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiSUN');
+ glReplacementCodeusSUN := SDL_GL_GetProcAddress( 'glReplacementCodeusSUN');
+ glReplacementCodeubSUN := SDL_GL_GetProcAddress( 'glReplacementCodeubSUN');
+ glReplacementCodeuivSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuivSUN');
+ glReplacementCodeusvSUN := SDL_GL_GetProcAddress( 'glReplacementCodeusvSUN');
+ glReplacementCodeubvSUN := SDL_GL_GetProcAddress( 'glReplacementCodeubvSUN');
+ glReplacementCodePointerSUN := SDL_GL_GetProcAddress( 'glReplacementCodePointerSUN');
+
+ // GL_SUN_vertex
+ glColor4ubVertex2fSUN := SDL_GL_GetProcAddress( 'glColor4ubVertex2fSUN');
+ glColor4ubVertex2fvSUN := SDL_GL_GetProcAddress( 'glColor4ubVertex2fvSUN');
+ glColor4ubVertex3fSUN := SDL_GL_GetProcAddress( 'glColor4ubVertex3fSUN');
+ glColor4ubVertex3fvSUN := SDL_GL_GetProcAddress( 'glColor4ubVertex3fvSUN');
+ glColor3fVertex3fSUN := SDL_GL_GetProcAddress( 'glColor3fVertex3fSUN');
+ glColor3fVertex3fvSUN := SDL_GL_GetProcAddress( 'glColor3fVertex3fvSUN');
+ glNormal3fVertex3fSUN := SDL_GL_GetProcAddress( 'glNormal3fVertex3fSUN');
+ glNormal3fVertex3fvSUN := SDL_GL_GetProcAddress( 'glNormal3fVertex3fvSUN');
+ glColor4fNormal3fVertex3fSUN := SDL_GL_GetProcAddress( 'glColor4fNormal3fVertex3fSUN');
+ glColor4fNormal3fVertex3fvSUN := SDL_GL_GetProcAddress( 'glColor4fNormal3fVertex3fvSUN');
+ glTexCoord2fVertex3fSUN := SDL_GL_GetProcAddress( 'glTexCoord2fVertex3fSUN');
+ glTexCoord2fVertex3fvSUN := SDL_GL_GetProcAddress( 'glTexCoord2fVertex3fvSUN');
+ glTexCoord4fVertex4fSUN := SDL_GL_GetProcAddress( 'glTexCoord4fVertex4fSUN');
+ glTexCoord4fVertex4fvSUN := SDL_GL_GetProcAddress( 'glTexCoord4fVertex4fvSUN');
+ glTexCoord2fColor4ubVertex3fSUN := SDL_GL_GetProcAddress( 'glTexCoord2fColor4ubVertex3fSUN');
+ glTexCoord2fColor4ubVertex3fvSUN := SDL_GL_GetProcAddress( 'glTexCoord2fColor4ubVertex3fvSUN');
+ glTexCoord2fColor3fVertex3fSUN := SDL_GL_GetProcAddress( 'glTexCoord2fColor3fVertex3fSUN');
+ glTexCoord2fColor3fVertex3fvSUN := SDL_GL_GetProcAddress( 'glTexCoord2fColor3fVertex3fvSUN');
+ glTexCoord2fNormal3fVertex3fSUN := SDL_GL_GetProcAddress( 'glTexCoord2fNormal3fVertex3fSUN');
+ glTexCoord2fNormal3fVertex3fvSUN := SDL_GL_GetProcAddress( 'glTexCoord2fNormal3fVertex3fvSUN');
+ glTexCoord2fColor4fNormal3fVertex3fSUN := SDL_GL_GetProcAddress( 'glTexCoord2fColor4fNormal3fVertex3fSUN');
+ glTexCoord2fColor4fNormal3fVertex3fvSUN := SDL_GL_GetProcAddress( 'glTexCoord2fColor4fNormal3fVertex3fvSUN');
+ glTexCoord4fColor4fNormal3fVertex4fSUN := SDL_GL_GetProcAddress( 'glTexCoord4fColor4fNormal3fVertex4fSUN');
+ glTexCoord4fColor4fNormal3fVertex4fvSUN := SDL_GL_GetProcAddress( 'glTexCoord4fColor4fNormal3fVertex4fvSUN');
+ glReplacementCodeuiVertex3fSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiVertex3fSUN');
+ glReplacementCodeuiVertex3fvSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiVertex3fvSUN');
+ glReplacementCodeuiColor4ubVertex3fSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiColor4ubVertex3fSUN');
+ glReplacementCodeuiColor4ubVertex3fvSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiColor4ubVertex3fvSUN');
+ glReplacementCodeuiColor3fVertex3fSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiColor3fVertex3fSUN');
+ glReplacementCodeuiColor3fVertex3fvSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiColor3fVertex3fvSUN');
+ glReplacementCodeuiNormal3fVertex3fSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiNormal3fVertex3fSUN');
+ glReplacementCodeuiNormal3fVertex3fvSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiNormal3fVertex3fvSUN');
+ glReplacementCodeuiColor4fNormal3fVertex3fSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiColor4fNormal3fVertex3fSUN');
+ glReplacementCodeuiColor4fNormal3fVertex3fvSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiColor4fNormal3fVertex3fvSUN');
+ glReplacementCodeuiTexCoord2fVertex3fSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiTexCoord2fVertex3fSUN');
+ glReplacementCodeuiTexCoord2fVertex3fvSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiTexCoord2fVertex3fvSUN');
+ glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN');
+ glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN');
+ glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN');
+ glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN := SDL_GL_GetProcAddress( 'glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN');
+
+ // GL_EXT_blend_func_separate
+ glBlendFuncSeparateEXT := SDL_GL_GetProcAddress( 'glBlendFuncSeparateEXT');
+
+ // GL_EXT_vertex_weighting
+ glVertexWeightfEXT := SDL_GL_GetProcAddress( 'glVertexWeightfEXT');
+ glVertexWeightfvEXT := SDL_GL_GetProcAddress( 'glVertexWeightfvEXT');
+ glVertexWeightPointerEXT := SDL_GL_GetProcAddress( 'glVertexWeightPointerEXT');
+
+ // GL_NV_vertex_array_range
+ glFlushVertexArrayRangeNV := SDL_GL_GetProcAddress( 'glFlushVertexArrayRangeNV');
+ glVertexArrayRangeNV := SDL_GL_GetProcAddress( 'glVertexArrayRangeNV');
+ wglAllocateMemoryNV := SDL_GL_GetProcAddress( 'wglAllocateMemoryNV');
+ wglFreeMemoryNV := SDL_GL_GetProcAddress( 'wglFreeMemoryNV');
+
+ // GL_NV_register_combiners
+ glCombinerParameterfvNV := SDL_GL_GetProcAddress( 'glCombinerParameterfvNV');
+ glCombinerParameterfNV := SDL_GL_GetProcAddress( 'glCombinerParameterfNV');
+ glCombinerParameterivNV := SDL_GL_GetProcAddress( 'glCombinerParameterivNV');
+ glCombinerParameteriNV := SDL_GL_GetProcAddress( 'glCombinerParameteriNV');
+ glCombinerInputNV := SDL_GL_GetProcAddress( 'glCombinerInputNV');
+ glCombinerOutputNV := SDL_GL_GetProcAddress( 'glCombinerOutputNV');
+ glFinalCombinerInputNV := SDL_GL_GetProcAddress( 'glFinalCombinerInputNV');
+ glGetCombinerInputParameterfvNV := SDL_GL_GetProcAddress( 'glGetCombinerInputParameterfvNV');
+ glGetCombinerInputParameterivNV := SDL_GL_GetProcAddress( 'glGetCombinerInputParameterivNV');
+ glGetCombinerOutputParameterfvNV := SDL_GL_GetProcAddress( 'glGetCombinerOutputParameterfvNV');
+ glGetCombinerOutputParameterivNV := SDL_GL_GetProcAddress( 'glGetCombinerOutputParameterivNV');
+ glGetFinalCombinerInputParameterfvNV := SDL_GL_GetProcAddress( 'glGetFinalCombinerInputParameterfvNV');
+ glGetFinalCombinerInputParameterivNV := SDL_GL_GetProcAddress( 'glGetFinalCombinerInputParameterivNV');
+
+ // GL_MESA_resize_buffers
+ glResizeBuffersMESA := SDL_GL_GetProcAddress( 'glResizeBuffersMESA');
+
+ // GL_MESA_window_pos
+ glWindowPos2dMESA := SDL_GL_GetProcAddress( 'glWindowPos2dMESA');
+ glWindowPos2dvMESA := SDL_GL_GetProcAddress( 'glWindowPos2dvMESA');
+ glWindowPos2fMESA := SDL_GL_GetProcAddress( 'glWindowPos2fMESA');
+ glWindowPos2fvMESA := SDL_GL_GetProcAddress( 'glWindowPos2fvMESA');
+ glWindowPos2iMESA := SDL_GL_GetProcAddress( 'glWindowPos2iMESA');
+ glWindowPos2ivMESA := SDL_GL_GetProcAddress( 'glWindowPos2ivMESA');
+ glWindowPos2sMESA := SDL_GL_GetProcAddress( 'glWindowPos2sMESA');
+ glWindowPos2svMESA := SDL_GL_GetProcAddress( 'glWindowPos2svMESA');
+ glWindowPos3dMESA := SDL_GL_GetProcAddress( 'glWindowPos3dMESA');
+ glWindowPos3dvMESA := SDL_GL_GetProcAddress( 'glWindowPos3dvMESA');
+ glWindowPos3fMESA := SDL_GL_GetProcAddress( 'glWindowPos3fMESA');
+ glWindowPos3fvMESA := SDL_GL_GetProcAddress( 'glWindowPos3fvMESA');
+ glWindowPos3iMESA := SDL_GL_GetProcAddress( 'glWindowPos3iMESA');
+ glWindowPos3ivMESA := SDL_GL_GetProcAddress( 'glWindowPos3ivMESA');
+ glWindowPos3sMESA := SDL_GL_GetProcAddress( 'glWindowPos3sMESA');
+ glWindowPos3svMESA := SDL_GL_GetProcAddress( 'glWindowPos3svMESA');
+ glWindowPos4dMESA := SDL_GL_GetProcAddress( 'glWindowPos4dMESA');
+ glWindowPos4dvMESA := SDL_GL_GetProcAddress( 'glWindowPos4dvMESA');
+ glWindowPos4fMESA := SDL_GL_GetProcAddress( 'glWindowPos4fMESA');
+ glWindowPos4fvMESA := SDL_GL_GetProcAddress( 'glWindowPos4fvMESA');
+ glWindowPos4iMESA := SDL_GL_GetProcAddress( 'glWindowPos4iMESA');
+ glWindowPos4ivMESA := SDL_GL_GetProcAddress( 'glWindowPos4ivMESA');
+ glWindowPos4sMESA := SDL_GL_GetProcAddress( 'glWindowPos4sMESA');
+ glWindowPos4svMESA := SDL_GL_GetProcAddress( 'glWindowPos4svMESA');
+
+ // GL_IBM_multimode_draw_arrays
+ glMultiModeDrawArraysIBM := SDL_GL_GetProcAddress( 'glMultiModeDrawArraysIBM');
+ glMultiModeDrawElementsIBM := SDL_GL_GetProcAddress( 'glMultiModeDrawElementsIBM');
+
+ // GL_IBM_vertex_array_lists
+ glColorPointerListIBM := SDL_GL_GetProcAddress( 'glColorPointerListIBM');
+ glSecondaryColorPointerListIBM := SDL_GL_GetProcAddress( 'glSecondaryColorPointerListIBM');
+ glEdgeFlagPointerListIBM := SDL_GL_GetProcAddress( 'glEdgeFlagPointerListIBM');
+ glFogCoordPointerListIBM := SDL_GL_GetProcAddress( 'glFogCoordPointerListIBM');
+ glIndexPointerListIBM := SDL_GL_GetProcAddress( 'glIndexPointerListIBM');
+ glNormalPointerListIBM := SDL_GL_GetProcAddress( 'glNormalPointerListIBM');
+ glTexCoordPointerListIBM := SDL_GL_GetProcAddress( 'glTexCoordPointerListIBM');
+ glVertexPointerListIBM := SDL_GL_GetProcAddress( 'glVertexPointerListIBM');
+
+ // GL_3DFX_tbuffer
+ glTbufferMask3DFX := SDL_GL_GetProcAddress( 'glTbufferMask3DFX');
+
+ // GL_EXT_multisample
+ glSampleMaskEXT := SDL_GL_GetProcAddress( 'glSampleMaskEXT');
+ glSamplePatternEXT := SDL_GL_GetProcAddress( 'glSamplePatternEXT');
+
+ // GL_SGIS_texture_color_mask
+ glTextureColorMaskSGIS := SDL_GL_GetProcAddress( 'glTextureColorMaskSGIS');
+
+ // GL_SGIX_igloo_interface
+ glIglooInterfaceSGIX := SDL_GL_GetProcAddress( 'glIglooInterfaceSGIX');
+
+ // GLU extensions
+ gluNurbsCallbackDataEXT := SDL_GL_GetProcAddress( 'gluNurbsCallbackDataEXT');
+ gluNewNurbsTessellatorEXT := SDL_GL_GetProcAddress( 'gluNewNurbsTessellatorEXT');
+ gluDeleteNurbsTessellatorEXT := SDL_GL_GetProcAddress( 'gluDeleteNurbsTessellatorEXT');
+
+ // GL_NV_vertex_program
+ glAreProgramsResidentNV := SDL_GL_GetProcAddress( 'glAreProgramsResidentNV');
+ glBindProgramNV := SDL_GL_GetProcAddress( 'glBindProgramNV');
+ glDeleteProgramsNV := SDL_GL_GetProcAddress( 'glDeleteProgramsNV');
+ glExecuteProgramNV := SDL_GL_GetProcAddress( 'glExecuteProgramNV');
+ glGenProgramsNV := SDL_GL_GetProcAddress( 'glGenProgramsNV');
+ glGetProgramParameterdvNV := SDL_GL_GetProcAddress( 'glGetProgramParameterdvNV');
+ glGetProgramParameterfvNV := SDL_GL_GetProcAddress( 'glGetProgramParameterfvNV');
+ glGetProgramivNV := SDL_GL_GetProcAddress( 'glGetProgramivNV');
+ glGetProgramStringNV := SDL_GL_GetProcAddress( 'glGetProgramStringNV');
+ glGetTrackMatrixivNV := SDL_GL_GetProcAddress( 'glGetTrackMatrixivNV');
+ glGetVertexAttribdvNV:= SDL_GL_GetProcAddress( 'glGetVertexAttribdvNV');
+ glGetVertexAttribfvNV:= SDL_GL_GetProcAddress( 'glGetVertexAttribfvNV');
+ glGetVertexAttribivNV:= SDL_GL_GetProcAddress( 'glGetVertexAttribivNV');
+ glGetVertexAttribPointervNV := wglGetProcAddress ('glGetVertexAttribPointervNV');
+ glIsProgramNV := SDL_GL_GetProcAddress( 'glIsProgramNV');
+ glLoadProgramNV := SDL_GL_GetProcAddress( 'glLoadProgramNV');
+ glProgramParameter4dNV := SDL_GL_GetProcAddress( 'glProgramParameter4dNV');
+ glProgramParameter4dvNV := SDL_GL_GetProcAddress( 'glProgramParameter4dvNV');
+ glProgramParameter4fNV := SDL_GL_GetProcAddress( 'glProgramParameter4fNV');
+ glProgramParameter4fvNV := SDL_GL_GetProcAddress( 'glProgramParameter4fvNV');
+ glProgramParameters4dvNV := wglGetProcAddress ('glProgramParameters4dvNV');
+ glProgramParameters4fvNV := wglGetProcAddress ('glProgramParameters4fvNV');
+ glRequestResidentProgramsNV := wglGetProcAddress ('glRequestResidentProgramsNV');
+ glTrackMatrixNV := SDL_GL_GetProcAddress( 'glTrackMatrixNV');
+ glVertexAttribPointerNV := SDL_GL_GetProcAddress( 'glVertexAttribPointerNV');
+ glVertexAttrib1dNV := SDL_GL_GetProcAddress( 'glVertexAttrib1dNV');
+ glVertexAttrib1dvNV := SDL_GL_GetProcAddress( 'glVertexAttrib1dvNV');
+ glVertexAttrib1fNV := SDL_GL_GetProcAddress( 'glVertexAttrib1fNV');
+ glVertexAttrib1fvNV := SDL_GL_GetProcAddress( 'glVertexAttrib1fvNV');
+ glVertexAttrib1sNV := SDL_GL_GetProcAddress( 'glVertexAttrib1sNV');
+ glVertexAttrib1svNV := SDL_GL_GetProcAddress( 'glVertexAttrib1svNV');
+ glVertexAttrib2dNV := SDL_GL_GetProcAddress( 'glVertexAttrib2dNV');
+ glVertexAttrib2dvNV := SDL_GL_GetProcAddress( 'glVertexAttrib2dvNV');
+ glVertexAttrib2fNV := SDL_GL_GetProcAddress( 'glVertexAttrib2fNV');
+ glVertexAttrib2fvNV := SDL_GL_GetProcAddress( 'glVertexAttrib2fvNV');
+ glVertexAttrib2sNV := SDL_GL_GetProcAddress( 'glVertexAttrib2sNV');
+ glVertexAttrib2svNV := SDL_GL_GetProcAddress( 'glVertexAttrib2svNV');
+ glVertexAttrib3dNV := SDL_GL_GetProcAddress( 'glVertexAttrib3dNV');
+ glVertexAttrib3dvNV := SDL_GL_GetProcAddress( 'glVertexAttrib3dvNV');
+ glVertexAttrib3fNV := SDL_GL_GetProcAddress( 'glVertexAttrib3fNV');
+ glVertexAttrib3fvNV := SDL_GL_GetProcAddress( 'glVertexAttrib3fvNV');
+ glVertexAttrib3sNV := SDL_GL_GetProcAddress( 'glVertexAttrib3sNV');
+ glVertexAttrib3svNV := SDL_GL_GetProcAddress( 'glVertexAttrib3svNV');
+ glVertexAttrib4dNV := SDL_GL_GetProcAddress( 'glVertexAttrib4dNV');
+ glVertexAttrib4dvNV := SDL_GL_GetProcAddress( 'glVertexAttrib4dvNV');
+ glVertexAttrib4fNV := SDL_GL_GetProcAddress( 'glVertexAttrib4fNV');
+ glVertexAttrib4fvNV := SDL_GL_GetProcAddress( 'glVertexAttrib4fvNV');
+ glVertexAttrib4sNV := SDL_GL_GetProcAddress( 'glVertexAttrib4sNV');
+ glVertexAttrib4svNV := SDL_GL_GetProcAddress( 'glVertexAttrib4svNV');
+ glVertexAttrib4ubvNV := SDL_GL_GetProcAddress( 'glVertexAttrib4ubvNV');
+ glVertexAttribs1dvNV := SDL_GL_GetProcAddress( 'glVertexAttribs1dvNV');
+ glVertexAttribs1fvNV := SDL_GL_GetProcAddress( 'glVertexAttribs1fvNV');
+ glVertexAttribs1svNV := SDL_GL_GetProcAddress( 'glVertexAttribs1svNV');
+ glVertexAttribs2dvNV := SDL_GL_GetProcAddress( 'glVertexAttribs2dvNV');
+ glVertexAttribs2fvNV := SDL_GL_GetProcAddress( 'glVertexAttribs2fvNV');
+ glVertexAttribs2svNV := SDL_GL_GetProcAddress( 'glVertexAttribs2svNV');
+ glVertexAttribs3dvNV := SDL_GL_GetProcAddress( 'glVertexAttribs3dvNV');
+ glVertexAttribs3fvNV := SDL_GL_GetProcAddress( 'glVertexAttribs3fvNV');
+ glVertexAttribs3svNV := SDL_GL_GetProcAddress( 'glVertexAttribs3svNV');
+ glVertexAttribs4dvNV := SDL_GL_GetProcAddress( 'glVertexAttribs4dvNV');
+ glVertexAttribs4fvNV := SDL_GL_GetProcAddress( 'glVertexAttribs4fvNV');
+ glVertexAttribs4svNV := SDL_GL_GetProcAddress( 'glVertexAttribs4svNV');
+ glVertexAttribs4ubvNV := SDL_GL_GetProcAddress( 'glVertexAttribs4ubvN');
+
+ // ARB wgl extensions
+ wglGetExtensionsStringARB := SDL_GL_GetProcAddress( 'wglGetExtensionsStringARB');
+ wglGetPixelFormatAttribivARB := SDL_GL_GetProcAddress( 'wglGetPixelFormatAttribivARB');
+ wglGetPixelFormatAttribfvARB := SDL_GL_GetProcAddress( 'wglGetPixelFormatAttribfvARB');
+ wglChoosePixelFormatARB := SDL_GL_GetProcAddress( 'wglChoosePixelFormatARB');
+
+ // To get synchronized again, if this proc was called externally.
+ LastPixelFormat := 0;
+ end;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure TrimAndSplitVersionString(Buffer: String; var Max, Min: Integer);
+
+// Peels out the X.Y form from the given Buffer which must contain a version string like "text Minor.Major.Build text"
+// at least however "Major.Minor".
+
+var
+ Separator: Integer;
+
+begin
+ try
+ // There must be at least one dot to separate major and minor version number.
+ Separator := Pos('.', Buffer);
+ // At least one number must be before and one after the dot.
+ if (Separator > 1) and (Separator < Length(Buffer)) and (Buffer[Separator - 1] in ['0'..'9']) and
+ (Buffer[Separator + 1] in ['0'..'9']) then
+ begin
+ // OK, it's a valid version string. Now remove unnecessary parts.
+ Dec(Separator);
+ // Find last non-numeric character before version number.
+ while (Separator > 0) and (Buffer[Separator] in ['0'..'9']) do
+ Dec(Separator);
+ // Delete leading characters which do not belong to the version string.
+ Delete(Buffer, 1, Separator);
+ Separator := Pos('.', Buffer) + 1;
+ // Find first non-numeric character after version number
+ while (Separator <= Length(Buffer)) and (Buffer[Separator] in ['0'..'9']) do
+ Inc(Separator);
+ // delete trailing characters not belonging to the version string
+ Delete(Buffer, Separator, 255);
+ // Now translate the numbers.
+ Separator := Pos('.', Buffer); // This is necessary because the buffer length might have changed.
+ Max := StrToInt(Copy(Buffer, 1, Separator - 1));
+ Min := StrToInt(Copy(Buffer, Separator + 1, 255));
+ end
+ else
+ Abort;
+ except
+ Min := 0;
+ Max := 0;
+ end;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure ReadImplementationProperties;
+
+var
+ Buffer: string;
+ MajorVersion,
+ MinorVersion: Integer;
+
+ //--------------- local function --------------------------------------------
+
+ function CheckExtension(const Extension: string): Boolean;
+
+ // Checks if the given Extension string is in Buffer.
+
+ var
+ ExtPos: Integer;
+
+ begin
+ // First find the position of the extension string as substring in Buffer.
+ ExtPos := Pos(Extension, Buffer);
+ Result := ExtPos > 0;
+ // Now check that it isn't only a substring of another extension.
+ if Result then
+ Result := ((ExtPos + Length(Extension) - 1) = Length(Buffer)) or
+ not (Buffer[ExtPos + Length(Extension)] in ['_', 'A'..'Z', 'a'..'z']);
+ end;
+
+ //--------------- end local function ----------------------------------------
+
+begin
+ // determine version of implementation
+ // GL
+ Buffer := glGetString(GL_VERSION);
+ TrimAndSplitVersionString(Buffer, Majorversion, MinorVersion);
+ GL_VERSION_1_0 := True;
+ GL_VERSION_1_1 := False;
+ GL_VERSION_1_2 := False;
+ if MajorVersion > 0 then
+ begin
+ if MinorVersion > 0 then
+ begin
+ GL_VERSION_1_1 := True;
+ if MinorVersion > 1 then
+ GL_VERSION_1_2 := True;
+ end;
+ end;
+
+ // GLU
+ GLU_VERSION_1_1 := False;
+ GLU_VERSION_1_2 := False;
+ GLU_VERSION_1_3 := False;
+ // gluGetString is valid for version 1.1 or later
+ if Assigned(gluGetString) then
+ begin
+ Buffer := gluGetString(GLU_VERSION);
+ TrimAndSplitVersionString(Buffer, Majorversion, MinorVersion);
+ GLU_VERSION_1_1 := True;
+ if MinorVersion > 1 then
+ begin
+ GLU_VERSION_1_2 := True;
+ if MinorVersion > 2 then
+ GLU_VERSION_1_3 := True;
+ end;
+ end;
+
+ // check supported extensions
+ // GL
+ Buffer := glGetString(GL_EXTENSIONS);
+ GL_3DFX_multisample :=CheckExtension('GL_3DFX_multisample');
+ GL_3DFX_tbuffer := CheckExtension('GL_3DFX_tbuffer');
+ GL_3DFX_texture_compression_FXT1 := CheckExtension('GL_3DFX_texture_compression_FXT1');
+
+ GL_APPLE_specular_vector := CheckExtension('GL_APPLE_specular_vector');
+ GL_APPLE_transform_hint := CheckExtension('GL_APPLE_transform_hint');
+
+ GL_ARB_imaging := CheckExtension('GL_ARB_imaging');
+ GL_ARB_multisample := CheckExtension('GL_ARB_multisample');
+ GL_ARB_multitexture := CheckExtension('GL_ARB_multitexture');
+ GL_ARB_texture_compression := CheckExtension('GL_ARB_texture_compression');
+ GL_ARB_texture_cube_map := CheckExtension('GL_ARB_texture_cube_map');
+ GL_ARB_transpose_matrix := CheckExtension('GL_ARB_transpose_matrix');
+ GL_ARB_vertex_blend := CheckExtension('GL_ARB_vertex_blend');
+
+ GL_EXT_422_pixels := CheckExtension('GL_EXT_422_pixels');
+ GL_EXT_abgr := CheckExtension('GL_EXT_abgr');
+ GL_EXT_bgra := CheckExtension('GL_EXT_bgra');
+ GL_EXT_blend_color := CheckExtension('GL_EXT_blend_color');
+ GL_EXT_blend_func_separate := CheckExtension('GL_EXT_blend_func_separate');
+ GL_EXT_blend_logic_op := CheckExtension('GL_EXT_blend_logic_op');
+ GL_EXT_blend_minmax := CheckExtension('GL_EXT_blend_minmax');
+ GL_EXT_blend_subtract := CheckExtension('GL_EXT_blend_subtract');
+ GL_EXT_clip_volume_hint := CheckExtension('GL_EXT_clip_volume_hint');
+ GL_EXT_cmyka := CheckExtension('GL_EXT_cmyka');
+ GL_EXT_color_subtable := CheckExtension('GL_EXT_color_subtable');
+ GL_EXT_compiled_vertex_array := CheckExtension('GL_EXT_compiled_vertex_array');
+ GL_EXT_convolution := CheckExtension('GL_EXT_convolution');
+ GL_EXT_coordinate_frame := CheckExtension('GL_EXT_coordinate_frame');
+ GL_EXT_copy_texture := CheckExtension('GL_EXT_copy_texture');
+ GL_EXT_cull_vertex := CheckExtension('GL_EXT_cull_vertex');
+ GL_EXT_draw_range_elements := CheckExtension('GL_EXT_draw_range_elements');
+ GL_EXT_fog_coord := CheckExtension('GL_EXT_fog_coord');
+ GL_EXT_histogram := CheckExtension('GL_EXT_histogram');
+ GL_EXT_index_array_formats := CheckExtension('GL_EXT_index_array_formats');
+ GL_EXT_index_func := CheckExtension('GL_EXT_index_func');
+ GL_EXT_index_material := CheckExtension('GL_EXT_index_material');
+ GL_EXT_index_texture := CheckExtension('GL_EXT_index_texture');
+ GL_EXT_light_max_exponent := CheckExtension('GL_EXT_light_max_exponent');
+ GL_EXT_light_texture := CheckExtension('GL_EXT_light_texture');
+ GL_EXT_misc_attribute := CheckExtension('GL_EXT_misc_attribute');
+ GL_EXT_multi_draw_arrays := CheckExtension('GL_EXT_multi_draw_arrays');
+ GL_EXT_multisample := CheckExtension('GL_EXT_multisample');
+ GL_EXT_packed_pixels := CheckExtension('GL_EXT_packed_pixels');
+ GL_EXT_paletted_texture := CheckExtension('GL_EXT_paletted_texture');
+ GL_EXT_pixel_transform := CheckExtension('GL_EXT_pixel_transform');
+ GL_EXT_point_parameters := CheckExtension('GL_EXT_point_parameters');
+ GL_EXT_polygon_offset := CheckExtension('GL_EXT_polygon_offset');
+ GL_EXT_rescale_normal := CheckExtension('GL_EXT_rescale_normal');
+ GL_EXT_scene_marker := CheckExtension('GL_EXT_scene_marker');
+ GL_EXT_secondary_color := CheckExtension('GL_EXT_secondary_color');
+ GL_EXT_separate_specular_color := CheckExtension('GL_EXT_separate_specular_color');
+ GL_EXT_shared_texture_palette := CheckExtension('GL_EXT_shared_texture_palette');
+ GL_EXT_stencil_wrap := CheckExtension('GL_EXT_stencil_wrap');
+ GL_EXT_subtexture := CheckExtension('GL_EXT_subtexture');
+ GL_EXT_texture_color_table := CheckExtension('GL_EXT_texture_color_table');
+ GL_EXT_texture_compression_s3tc := CheckExtension('GL_EXT_texture_compression_s3tc');
+ GL_EXT_texture_cube_map := CheckExtension('GL_EXT_texture_cube_map');
+ GL_EXT_texture_edge_clamp := CheckExtension('GL_EXT_texture_edge_clamp');
+ GL_EXT_texture_env_add := CheckExtension('GL_EXT_texture_env_add');
+ GL_EXT_texture_env_combine := CheckExtension('GL_EXT_texture_env_combine');
+ GL_EXT_texture_filter_anisotropic := CheckExtension('GL_EXT_texture_filter_anisotropic');
+ GL_EXT_texture_lod_bias := CheckExtension('GL_EXT_texture_lod_bias');
+ GL_EXT_texture_object := CheckExtension('GL_EXT_texture_object');
+ GL_EXT_texture_perturb_normal := CheckExtension('GL_EXT_texture_perturb_normal');
+ GL_EXT_texture3D := CheckExtension('GL_EXT_texture3D');
+ GL_EXT_vertex_array := CheckExtension('GL_EXT_vertex_array');
+ GL_EXT_vertex_weighting := CheckExtension('GL_EXT_vertex_weighting');
+
+ GL_FfdMaskSGIX := CheckExtension('GL_FfdMaskSGIX');
+ GL_HP_convolution_border_modes := CheckExtension('GL_HP_convolution_border_modes');
+ GL_HP_image_transform := CheckExtension('GL_HP_image_transform');
+ GL_HP_occlusion_test := CheckExtension('GL_HP_occlusion_test');
+ GL_HP_texture_lighting := CheckExtension('GL_HP_texture_lighting');
+
+ GL_IBM_cull_vertex := CheckExtension('GL_IBM_cull_vertex');
+ GL_IBM_multimode_draw_arrays := CheckExtension('GL_IBM_multimode_draw_arrays');
+ GL_IBM_rasterpos_clip := CheckExtension('GL_IBM_rasterpos_clip');
+ GL_IBM_vertex_array_lists := CheckExtension('GL_IBM_vertex_array_lists');
+
+ GL_INGR_color_clamp := CheckExtension('GL_INGR_color_clamp');
+ GL_INGR_interlace_read := CheckExtension('GL_INGR_interlace_read');
+
+ GL_INTEL_parallel_arrays := CheckExtension('GL_INTEL_parallel_arrays');
+
+ GL_KTX_buffer_region := CheckExtension('GL_KTX_buffer_region');
+
+ GL_MESA_resize_buffers := CheckExtension('GL_MESA_resize_buffers');
+ GL_MESA_window_pos := CheckExtension('GL_MESA_window_pos');
+
+ GL_NV_blend_square := CheckExtension('GL_NV_blend_square');
+ GL_NV_fog_distance := CheckExtension('GL_NV_fog_distance');
+ GL_NV_light_max_exponent := CheckExtension('GL_NV_light_max_exponent');
+ GL_NV_register_combiners := CheckExtension('GL_NV_register_combiners');
+ GL_NV_texgen_emboss := CheckExtension('GL_NV_texgen_emboss');
+ GL_NV_texgen_reflection := CheckExtension('GL_NV_texgen_reflection');
+ GL_NV_texture_env_combine4 := CheckExtension('GL_NV_texture_env_combine4');
+ GL_NV_vertex_array_range := CheckExtension('GL_NV_vertex_array_range');
+ GL_NV_vertex_program := CheckExtension('GL_NV_vertex_program');
+
+ GL_PGI_misc_hints := CheckExtension('GL_PGI_misc_hints');
+ GL_PGI_vertex_hints := CheckExtension('GL_PGI_vertex_hints');
+
+ GL_REND_screen_coordinates := CheckExtension('GL_REND_screen_coordinates');
+
+ GL_SGI_color_matrix := CheckExtension('GL_SGI_color_matrix');
+ GL_SGI_color_table := CheckExtension('GL_SGI_color_table');
+ GL_SGI_depth_pass_instrument := CheckExtension('GL_SGI_depth_pass_instrument');
+
+ GL_SGIS_detail_texture := CheckExtension('GL_SGIS_detail_texture');
+ GL_SGIS_fog_function := CheckExtension('GL_SGIS_fog_function');
+ GL_SGIS_generate_mipmap := CheckExtension('GL_SGIS_generate_mipmap');
+ GL_SGIS_multisample := CheckExtension('GL_SGIS_multisample');
+ GL_SGIS_multitexture := CheckExtension('GL_SGIS_multitexture');
+ GL_SGIS_pixel_texture := CheckExtension('GL_SGIS_pixel_texture');
+ GL_SGIS_point_line_texgen := CheckExtension('GL_SGIS_point_line_texgen');
+ GL_SGIS_point_parameters := CheckExtension('GL_SGIS_point_parameters');
+ GL_SGIS_sharpen_texture := CheckExtension('GL_SGIS_sharpen_texture');
+ GL_SGIS_texture_border_clamp := CheckExtension('GL_SGIS_texture_border_clamp');
+ GL_SGIS_texture_color_mask := CheckExtension('GL_SGIS_texture_color_mask');
+ GL_SGIS_texture_edge_clamp := CheckExtension('GL_SGIS_texture_edge_clamp');
+ GL_SGIS_texture_filter4 := CheckExtension('GL_SGIS_texture_filter4');
+ GL_SGIS_texture_lod := CheckExtension('GL_SGIS_texture_lod');
+ GL_SGIS_texture_select := CheckExtension('GL_SGIS_texture_select');
+ GL_SGIS_texture4D := CheckExtension('GL_SGIS_texture4D');
+
+ GL_SGIX_async := CheckExtension('GL_SGIX_async');
+ GL_SGIX_async_histogram := CheckExtension('GL_SGIX_async_histogram');
+ GL_SGIX_async_pixel := CheckExtension('GL_SGIX_async_pixel');
+ GL_SGIX_blend_alpha_minmax := CheckExtension('GL_SGIX_blend_alpha_minmax');
+ GL_SGIX_calligraphic_fragment := CheckExtension('GL_SGIX_calligraphic_fragment');
+ GL_SGIX_clipmap := CheckExtension('GL_SGIX_clipmap');
+ GL_SGIX_convolution_accuracy := CheckExtension('GL_SGIX_convolution_accuracy');
+ GL_SGIX_depth_texture := CheckExtension('GL_SGIX_depth_texture');
+ GL_SGIX_flush_raster := CheckExtension('GL_SGIX_flush_raster');
+ GL_SGIX_fog_offset := CheckExtension('GL_SGIX_fog_offset');
+ GL_SGIX_fog_scale := CheckExtension('GL_SGIX_fog_scale');
+ GL_SGIX_fragment_lighting := CheckExtension('GL_SGIX_fragment_lighting');
+ GL_SGIX_framezoom := CheckExtension('GL_SGIX_framezoom');
+ GL_SGIX_igloo_interface := CheckExtension('GL_SGIX_igloo_interface');
+ GL_SGIX_instruments := CheckExtension('GL_SGIX_instruments');
+ GL_SGIX_interlace := CheckExtension('GL_SGIX_interlace');
+ GL_SGIX_ir_instrument1 := CheckExtension('GL_SGIX_ir_instrument1');
+ GL_SGIX_list_priority := CheckExtension('GL_SGIX_list_priority');
+ GL_SGIX_pixel_texture := CheckExtension('GL_SGIX_pixel_texture');
+ GL_SGIX_pixel_tiles := CheckExtension('GL_SGIX_pixel_tiles');
+ GL_SGIX_polynomial_ffd := CheckExtension('GL_SGIX_polynomial_ffd');
+ GL_SGIX_reference_plane := CheckExtension('GL_SGIX_reference_plane');
+ GL_SGIX_resample := CheckExtension('GL_SGIX_resample');
+ GL_SGIX_shadow := CheckExtension('GL_SGIX_shadow');
+ GL_SGIX_shadow_ambient := CheckExtension('GL_SGIX_shadow_ambient');
+ GL_SGIX_sprite := CheckExtension('GL_SGIX_sprite');
+ GL_SGIX_subsample := CheckExtension('GL_SGIX_subsample');
+ GL_SGIX_tag_sample_buffer := CheckExtension('GL_SGIX_tag_sample_buffer');
+ GL_SGIX_texture_add_env := CheckExtension('GL_SGIX_texture_add_env');
+ GL_SGIX_texture_lod_bias := CheckExtension('GL_SGIX_texture_lod_bias');
+ GL_SGIX_texture_multi_buffer := CheckExtension('GL_SGIX_texture_multi_buffer');
+ GL_SGIX_texture_scale_bias := CheckExtension('GL_SGIX_texture_scale_bias');
+ GL_SGIX_vertex_preclip := CheckExtension('GL_SGIX_vertex_preclip');
+ GL_SGIX_ycrcb := CheckExtension('GL_SGIX_ycrcb');
+ GL_SGIX_ycrcba := CheckExtension('GL_SGIX_ycrcba');
+
+ GL_SUN_convolution_border_modes := CheckExtension('GL_SUN_convolution_border_modes');
+ GL_SUN_global_alpha := CheckExtension('GL_SUN_global_alpha');
+ GL_SUN_triangle_list := CheckExtension('GL_SUN_triangle_list');
+ GL_SUN_vertex := CheckExtension('GL_SUN_vertex');
+
+ GL_SUNX_constant_data := CheckExtension('GL_SUNX_constant_data');
+
+ GL_WIN_phong_shading := CheckExtension('GL_WIN_phong_shading');
+ GL_WIN_specular_fog := CheckExtension('GL_WIN_specular_fog');
+ GL_WIN_swap_hint := CheckExtension('GL_WIN_swap_hint');
+
+ WGL_EXT_swap_control := CheckExtension('WGL_EXT_swap_control');
+ WGL_ARB_extensions_string := CheckExtension('WGL_ARB_extensions_string');
+ WGL_ARB_pixel_format := CheckExtension('WGL_ARB_pixel_format');
+
+ // GLU
+ Buffer := gluGetString(GLU_EXTENSIONS);
+ GLU_EXT_TEXTURE := CheckExtension('GLU_EXT_TEXTURE');
+ GLU_EXT_object_space_tess := CheckExtension('GLU_EXT_object_space_tess');
+ GLU_EXT_nurbs_tessellator := CheckExtension('GLU_EXT_nurbs_tessellator');
+
+ // ARB wgl extensions
+ if Assigned(wglGetExtensionsStringARB) then
+ begin
+ Buffer := wglGetExtensionsStringARB(wglGetCurrentDC);
+ WGL_ARB_extensions_string := CheckExtension('WGL_ARB_extensions_string');
+ WGL_ARB_pixel_format := CheckExtension('WGL_ARB_pixel_format');
+ end
+ else
+ begin
+ WGL_ARB_extensions_string := False;
+ WGL_ARB_pixel_format := False;
+ end;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function SetupPalette(DC: HDC; PFD: TPixelFormatDescriptor): HPalette;
+
+var
+ nColors,
+ I: Integer;
+ LogPalette: TMaxLogPalette;
+ RedMask,
+ GreenMask,
+ BlueMask: Byte;
+
+begin
+ nColors := 1 shl Pfd.cColorBits;
+ LogPalette.palVersion := $300;
+ LogPalette.palNumEntries := nColors;
+ RedMask := (1 shl Pfd.cRedBits ) - 1;
+ GreenMask := (1 shl Pfd.cGreenBits) - 1;
+ BlueMask := (1 shl Pfd.cBlueBits ) - 1;
+ with LogPalette, PFD do
+ for I := 0 to nColors - 1 do
+ begin
+ palPalEntry[I].peRed := (((I shr cRedShift ) and RedMask ) * 255) div RedMask;
+ palPalEntry[I].peGreen := (((I shr cGreenShift) and GreenMask) * 255) div GreenMask;
+ palPalEntry[I].peBlue := (((I shr cBlueShift ) and BlueMask ) * 255) div BlueMask;
+ palPalEntry[I].peFlags := 0;
+ end;
+
+ Result := CreatePalette(PLogPalette(@LogPalette)^);
+ if Result <> 0 then
+ begin
+ SelectPalette(DC, Result, False);
+ RealizePalette(DC);
+ end
+ else
+ RaiseLastOSError;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function CreateRenderingContext(DC: HDC; Options: TRCOptions; ColorBits, StencilBits, AccumBits, AuxBuffers: Integer;
+ Layer: Integer; var Palette: HPALETTE): HGLRC;
+
+// Set the OpenGL properties required to draw to the given canvas and create a rendering context for it.
+
+const
+ MemoryDCs = [OBJ_MEMDC, OBJ_METADC, OBJ_ENHMETADC];
+
+var
+ PFDescriptor: TPixelFormatDescriptor;
+ PixelFormat: Integer;
+ AType: DWORD;
+
+begin
+ FillChar(PFDescriptor, SizeOf(PFDescriptor), 0);
+ with PFDescriptor do
+ begin
+ nSize := SizeOf(PFDescriptor);
+ nVersion := 1;
+ dwFlags := PFD_SUPPORT_OPENGL;
+ AType := GetObjectType(DC);
+ if AType = 0 then
+ RaiseLastOSError;
+
+ if AType in MemoryDCs then
+ dwFlags := dwFlags or PFD_DRAW_TO_BITMAP
+ else
+ dwFlags := dwFlags or PFD_DRAW_TO_WINDOW;
+ if opDoubleBuffered in Options then
+ dwFlags := dwFlags or PFD_DOUBLEBUFFER;
+ if opGDI in Options then
+ dwFlags := dwFlags or PFD_SUPPORT_GDI;
+ if opStereo in Options then
+ dwFlags := dwFlags or PFD_STEREO;
+ iPixelType := PFD_TYPE_RGBA;
+ cColorBits := ColorBits;
+ cDepthBits := 32;
+ cStencilBits := StencilBits;
+ cAccumBits := AccumBits;
+ cAuxBuffers := AuxBuffers;
+ if Layer = 0 then
+ iLayerType := PFD_MAIN_PLANE
+ else
+ if Layer > 0 then
+ iLayerType := PFD_OVERLAY_PLANE
+ else
+ iLayerType := Byte(PFD_UNDERLAY_PLANE);
+ end;
+
+ // Just in case it didn't happen already.
+ if not InitOpenGL then
+ RaiseLastOSError;
+ PixelFormat := ChoosePixelFormat(DC, {$ifndef FPC}@{$endif}PFDescriptor);
+ if PixelFormat = 0 then
+ RaiseLastOSError;
+
+ // NOTE: It is not allowed to change a pixel format of a device context once it has been set.
+ // Hence you may create more than one rendering context for one single device only if it
+ // uses the same pixel format as the first created RC.
+ if GetPixelFormat(DC) <> PixelFormat then
+ begin
+ if not SetPixelFormat(DC, PixelFormat, @PFDescriptor) then
+ RaiseLastOSError;
+ end;
+
+ // Check the properties we just set.
+ DescribePixelFormat(DC, PixelFormat, SizeOf(PFDescriptor), PFDescriptor);
+ with PFDescriptor do
+ if (dwFlags and PFD_NEED_PALETTE) <> 0 then
+ Palette := SetupPalette(DC, PFDescriptor)
+ else
+ Palette := 0;
+
+ Result := wglCreateLayerContext(DC, Layer);
+ if Result = 0 then
+ RaiseLastOSError
+ else
+ LastPixelFormat := 0;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure ActivateRenderingContext(DC: HDC; RC: HGLRC);
+
+var
+ PixelFormat: Integer;
+
+begin
+ Assert((DC <> 0), 'DC must not be 0');
+ Assert((RC <> 0), 'RC must not be 0');
+
+ if ActivationRefCount = 0 then
+ begin
+ // Before activating the rendering context check if it is not already used by another thread.
+ with ContextList.LockList do
+ try
+ if IndexOf(Pointer(RC)) = -1 then
+ begin
+ if wglMakeCurrent(DC, RC) then
+ Add(Pointer(RC))
+ else
+ ShowError(SMakeCurrentFailed);
+ end
+ else
+ ShowError(SRCAlreadyActive)
+ finally
+ ContextList.UnlockList;
+ end;
+
+ Inc(ActivationRefCount);
+
+ // The extension function addresses are unique for each pixel format. All rendering
+ // contexts of a given pixel format share the same extension function addresses.
+ PixelFormat := GetPixelFormat(DC);
+ if PixelFormat <> LastPixelFormat then
+ begin
+ ReadExtensions;
+ ReadImplementationProperties;
+ LastPixelFormat := PixelFormat;
+ end;
+ end
+ else
+ begin
+ Assert((wglGetCurrentDC = DC) and (wglGetCurrentContext = RC), 'Incoherent DC/RC pair.');
+ Inc(ActivationRefCount);
+ end;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure DeactivateRenderingContext;
+
+begin
+ Assert(ActivationRefCount > 0, 'Unbalanced deactivation.');
+ if ActivationRefCount > 0 then
+ begin
+ Dec(ActivationRefCount);
+
+ if ActivationRefCount = 0 then
+ begin
+ // If the rendering context is no longer used then remove it from the context list to indicate
+ // it can now be used in any thread.
+ with ContextList.LockList do
+ try
+ Remove(Pointer(wglGetCurrentContext));
+ if not wglMakeCurrent(0, 0) then
+ ShowError(SMakeCurrentFailed);
+ finally
+ ContextList.UnlockList;
+ end;
+ end;
+ end;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure DestroyRenderingContext(RC: HGLRC);
+
+// Used to destroy the given rendering context. Only contexts which are no longer in use by any thread can be deleted.
+
+begin
+ Assert((ActivationRefCount = 0), 'Active contexts cannot be deleted.');
+
+ with ContextList.LockList do
+ try
+ if not wglDeleteContext(RC) then
+ ShowError(SDeleteContextFailed);
+ if IndexOf(Pointer(RC)) > -1 then
+ ShowError(SContextInUse);
+ finally
+ ContextList.UnlockList;
+ end;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function CurrentDC: HDC;
+
+// Returns the device context which is used for the current rendering context of the caller thread.
+
+begin
+ Result := wglGetCurrentDC;
+end;
+
+{$endif}
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure CloseOpenGL;
+begin
+ if GLHandle <> INVALID_MODULEHANDLE then
+ begin
+ UnloadModule( GLHandle );
+ GLHandle := INVALID_MODULEHANDLE;
+ end;
+
+ if GLUHandle <> INVALID_MODULEHANDLE then
+ begin
+ UnloadModule( GLUHandle );
+ GLUHandle := INVALID_MODULEHANDLE;
+ end;
+
+ ClearProcAddresses;
+ ClearExtensions;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function InitOpenGL: Boolean;
+
+begin
+ if (GLHandle = INVALID_MODULEHANDLE) or (GLUHandle = INVALID_MODULEHANDLE) then
+ Result := InitOpenGLFromLibrary(PChar( SDefaultGLLibrary ), PChar( SDefaultGLULibrary ) )
+ else
+ Result := True;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function InitOpenGLFromLibrary(GLName, GLUName: PChar): Boolean;
+
+begin
+ Result := False;
+ CloseOpenGL;
+
+ LoadModule( GLHandle, GLName );
+ LoadModule( GLUHandle, GLUName );
+
+ if (GLHandle <> INVALID_MODULEHANDLE) and (GLUHandle <> INVALID_MODULEHANDLE) then
+ begin
+ LoadProcAddresses;
+ Result := True;
+ end
+ else
+ begin
+ if GLHandle <> INVALID_MODULEHANDLE then
+ UnloadModule( GLHandle );
+
+ if GLUHandle <> INVALID_MODULEHANDLE then
+ UnloadModule( GLUHandle );
+ end;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function IsOpenGLInitialized: Boolean;
+
+begin
+ Result := GLHandle <> INVALID_MODULEHANDLE;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+procedure UnloadOpenGL;
+
+// compatibility routine
+
+begin
+ CloseOpenGL;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function LoadOpenGL: Boolean;
+
+// compatibility routine
+
+begin
+ Result := InitOpenGL;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function LoadOpenGLFromLibrary(GLName, GLUName: PChar): Boolean;
+
+// compatibility routine
+
+begin
+ Result := InitOpenGLFromLibrary(GLName, GLUName);
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+
+function IsOpenGLLoaded: Boolean;
+
+// compatibility routine
+
+begin
+ Result := GLHandle <> INVALID_MODULEHANDLE;
+end;
+
+//----------------------------------------------------------------------------------------------------------------------
+{$ifdef FPC}
+const Default8087CW: Word = $1332;
+
+{$ASMMODE INTEL}
+procedure Set8087CW(NewCW: Word); Assembler;
+asm
+ MOV Default8087CW, AX
+end;
+{$endif}
+
+//----------------------------------------------------------------------------------------------------------------------
+
+initialization
+ ContextList := TThreadList.Create;
+ Set8087CW($133F);
+finalization
+ CloseOpenGL;
+ ContextList.Free;
+ // We don't need to reset the FPU control word as the previous set call is process specific.
+end.
diff --git a/Game/Code/lib/JEDI-SDL/OpenGL/Pas/opengl12.rst b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/opengl12.rst new file mode 100644 index 00000000..857993e7 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/OpenGL/Pas/opengl12.rst @@ -0,0 +1,26 @@ +
+# hash value = 79191886
+opengl12.srcalreadyactive='Rendering context already active in another th'+
+'read.'
+
+
+# hash value = 191308692
+opengl12.smakecurrentfailed='wglMakeCurrent failed'
+
+
+# hash value = 214729876
+opengl12.sdeletecontextfailed='wglDeleteContext failed'
+
+
+# hash value = 230190814
+opengl12.scontextinuse='Cannot delete rendering context. It is still in u'+
+'se by another thread.'
+
+
+# hash value = 168003996
+opengl12.sdefaultgllibrary='OpenGL32.dll'
+
+
+# hash value = 140838716
+opengl12.sdefaultglulibrary='GLU32.dll'
+
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/Readme.txt b/Game/Code/lib/JEDI-SDL/SDL/Pas/Readme.txt new file mode 100644 index 00000000..76d63a9d --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/Readme.txt @@ -0,0 +1,27 @@ +Delphi interface unit for OpenGL version 1.2 compilable with Delphi 3-6 and Kylix.
+
+This unit is open source under the Mozilla Public License and
+the original author is Dipl. Ing. Mike Lischke (public@lischke-online.de).
+
+You can obtain this unit also from the JEDI (Joint Endeavor of Delphi Innovators)
+API page at www.delphi-jedi.org.
+
+Note for GLScene users: Eric Grange has provided a general vector types unit which
+resolves conflicts for types which are defined in OpenGL12.pas as well as Geometry.pas.
+This unit is located in the sub folder "GLScene AddOn".
+Please add this unit to the uses clause of OpenGL12.pas and remove the few types which
+are already declared in VectorTypes.pas.
+
+For tests and as starting point three demos are included into the package. Two of them (GLDiag and GLTest)
+need the (also provided) simple OpenGL control GLControl (see "GLControl\Package").
+
+- Basic is a very simple test program which only uses an empty form.
+- GLTest (in GLControl) uses GLControl to show four rendering contexts simultanously.
+- GLDiag is a diagnosis tool similar to DXDiag which shows some properties of the current
+ OpenGL driver implementation.
+
+Have fun and
+
+Ciao, Mike
+www.lischke-online.de
+www.delphi-unicode.net
\ No newline at end of file diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/jedi-sdl.inc b/Game/Code/lib/JEDI-SDL/SDL/Pas/jedi-sdl.inc new file mode 100644 index 00000000..31283d40 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/jedi-sdl.inc @@ -0,0 +1,438 @@ +{
+ $Id: jedi-sdl.inc,v 1.15 2007/05/29 21:30:48 savage Exp $
+}
+{******************************************************************************}
+{ }
+{ Borland Delphi SDL - Simple DirectMedia Layer }
+{ Global Conditional Definitions for JEDI-SDL cross-compilation }
+{ }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Prof. Abimbola Olowofoyeku <http://www.bigfoot.com/~African_Chief/> }
+{ }
+{ Portions created by Prof. Abimbola Olowofoyeku are }
+{ Copyright (C) 2000 - 2100 Prof. Abimbola Olowofoyeku. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ Prof. Abimbola Olowofoyeku <http://www.bigfoot.com/~African_Chief/> }
+{ Dominqiue Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ This code has been copied from... }
+{ Global Conditional Definitions for Chief's UNZIP package }
+{ By Prof. Abimbola Olowofoyeku (The African Chief) }
+{ http://www.bigfoot.com/~African_Chief/ }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so }
+{ They are available from... }
+{ http://www.libsdl.org . }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ 2003-04-03 DL - Initial addition }
+{ }
+{ 2003-04-07 DL - Added Macro ON derective for FPC and OpenGL and removed }
+{ WEAKPACKAGE derective. WEAKPACKAGE should be set when }
+{ appropriate. }
+{ }
+{ 2003-04-23 - DL : under instruction from Alexey Barkovoy I have added }
+{ better TMT Pascal support and under instruction }
+{ from Prof. Abimbola Olowofoyeku (The African Chief) }
+{ I have added better Gnu Pascal support }
+{ }
+{ 2004-01-19 - DL : Under instruction from Marco van de Voort, I have added }
+{ Better FPC support for FreeBSD. }
+{ }
+(*
+ $Log: jedi-sdl.inc,v $
+ Revision 1.15 2007/05/29 21:30:48 savage
+ Changes as suggested by Almindor for 64bit compatibility.
+
+ Revision 1.14 2007/05/20 20:29:11 savage
+ Initial Changes to Handle 64 Bits
+
+ Revision 1.13 2007/01/21 15:51:45 savage
+ Added Delphi 2006 support
+
+ Revision 1.12 2006/11/19 18:41:01 savage
+ removed THREADING ON flag as it is no longer needed in latest versions of FPC.
+
+ Revision 1.11 2006/01/04 00:52:41 drellis
+ Updated to include defined for ENDIAN values, SDL_BYTEORDER should now be correctly defined depending onthe platform. Code taken from sdl_mixer
+
+ Revision 1.10 2005/05/22 18:42:31 savage
+ Changes as suggested by Michalis Kamburelis. Thanks again.
+
+ Revision 1.9 2004/12/23 23:42:17 savage
+ Applied Patches supplied by Michalis Kamburelis ( THANKS! ), for greater FreePascal compatability.
+
+ Revision 1.8 2004/10/20 22:43:04 savage
+ Ensure that UNSAFE type warning are off in D9 as well
+
+ Revision 1.7 2004/04/05 09:59:51 savage
+ Changes for FreePacal as suggested by Marco
+
+ Revision 1.6 2004/03/31 22:18:15 savage
+ Small comment for turning off warning under GnuPascal
+
+ Revision 1.5 2004/03/30 22:41:02 savage
+ Added extra commenting due to previous compiler directive
+
+ Revision 1.4 2004/03/30 22:08:33 savage
+ Added Kylix Define
+
+ Revision 1.3 2004/03/30 21:34:40 savage
+ {$H+} needed for FPC compatiblity
+
+ Revision 1.2 2004/02/14 00:23:39 savage
+ As UNIX is defined in jedi-sdl.inc this will be used to check linux compatability as well. Units have been changed to reflect this change.
+
+*)
+{******************************************************************************}
+
+{.$define Debug} { uncomment for debugging }
+
+{$IFNDEF FPC}
+ {$IFDEF __GPC__}
+ {$I-}
+ {$W-} // turn off GPC warnings
+ {$X+}
+ {$ELSE} {__GPC__}
+ {$IFDEF Debug}
+ {$F+,D+,Q-,L+,R+,I-,S+,Y+,A+}
+ {$ELSE}
+ {$F+,Q-,R-,S-,I-,A+}
+ {$ENDIF}
+ {$ENDIF} {__GPC__}
+{$ELSE} {FPC}
+ //{$M+}
+{$ENDIF} {FPC}
+
+{$IFDEF LINUX}
+{$DEFINE UNIX}
+{$ENDIF}
+
+{$IFDEF ver70}
+ {$IFDEF Windows}
+ {$DEFINE Win16}
+ {$ENDIF Windows}
+ {$IFDEF MSDOS}
+ {$DEFINE NO_EXPORTS}
+ {$ENDIF MSDOS}
+ {$IFDEF DPMI}
+ {$DEFINE BP_DPMI}
+ {$ENDIF}
+ {$DEFINE OS_16_BIT}
+ {$DEFINE __OS_DOS__}
+{$ENDIF ver70}
+
+{$IFDEF ver80}
+ {$DEFINE Delphi} {Delphi 1.x}
+ {$DEFINE Delphi16}
+ {$DEFINE Win16}
+ {$DEFINE OS_16_BIT}
+ {$DEFINE __OS_DOS__}
+{$ENDIF ver80}
+
+{$IFDEF ver90}
+ {$DEFINE Delphi} {Delphi 2.x}
+ {$DEFINE Delphi32}
+ {$DEFINE WIN32}
+ {$DEFINE WINDOWS}
+{$ENDIF ver90}
+
+{$IFDEF ver100}
+ {$DEFINE Delphi} {Delphi 3.x}
+ {$DEFINE Delphi32}
+ {$DEFINE WIN32}
+ {$DEFINE WINDOWS}
+{$ENDIF ver100}
+
+{$IFDEF ver93}
+ {$DEFINE Delphi} {C++ Builder 1.x}
+ {$DEFINE Delphi32}
+ {$DEFINE WINDOWS}
+{$ENDIF ver93}
+
+{$IFDEF ver110}
+ {$DEFINE Delphi} {C++ Builder 3.x}
+ {$DEFINE Delphi32}
+ {$DEFINE WINDOWS}
+{$ENDIF ver110}
+
+{$IFDEF ver120}
+ {$DEFINE Delphi} {Delphi 4.x}
+ {$DEFINE Delphi32}
+ {$DEFINE Delphi4UP}
+ {$DEFINE Has_Int64}
+ {$DEFINE WINDOWS}
+{$ENDIF ver120}
+
+{$IFDEF ver130}
+ {$DEFINE Delphi} {Delphi 5.x}
+ {$DEFINE Delphi32}
+ {$DEFINE Delphi4UP}
+ {$DEFINE Delphi5UP}
+ {$DEFINE Has_Int64}
+ {$DEFINE WINDOWS}
+{$ENDIF ver130}
+
+{$IFDEF ver140}
+ {$DEFINE Delphi} {Delphi 6.x}
+ {$DEFINE Delphi32}
+ {$DEFINE Delphi4UP}
+ {$DEFINE Delphi5UP}
+ {$DEFINE Delphi6UP}
+ {$DEFINE Has_Int64}
+ {$DEFINE HAS_TYPES}
+{$ENDIF ver140}
+
+{$IFDEF ver150}
+ {$DEFINE Delphi} {Delphi 7.x}
+ {$DEFINE Delphi32}
+ {$DEFINE Delphi4UP}
+ {$DEFINE Delphi5UP}
+ {$DEFINE Delphi6UP}
+ {$DEFINE Delphi7UP}
+ {$WARN UNSAFE_TYPE OFF} {Disable warning for unsafe types in Delphi 7}
+ {$DEFINE Has_Int64}
+ {$DEFINE HAS_TYPES}
+{$ENDIF ver150}
+
+{$IFDEF ver160}
+ {$DEFINE Delphi} {Delphi 8}
+ {$DEFINE Delphi32}
+ {$DEFINE Delphi4UP}
+ {$DEFINE Delphi5UP}
+ {$DEFINE Delphi6UP}
+ {$DEFINE Delphi7UP}
+ {$DEFINE Delphi8UP}
+ {$DEFINE Has_Int64}
+ {$DEFINE HAS_TYPES}
+{$ENDIF ver160}
+
+{$IFDEF ver170}
+ {$DEFINE Delphi} {Delphi 2005}
+ {$DEFINE Delphi32}
+ {$DEFINE Delphi4UP}
+ {$DEFINE Delphi5UP}
+ {$DEFINE Delphi6UP}
+ {$DEFINE Delphi7UP}
+ {$DEFINE Delphi8UP}
+ {$DEFINE Delphi9UP}
+ {$WARN UNSAFE_TYPE OFF} {Disable warning for unsafe types in Delphi 7}
+ {$DEFINE Has_Int64}
+ {$DEFINE HAS_TYPES}
+{$ENDIF ver170}
+
+{$IFDEF ver180}
+ {$DEFINE Delphi} {Delphi 2006}
+ {$DEFINE Delphi32}
+ {$DEFINE Delphi4UP}
+ {$DEFINE Delphi5UP}
+ {$DEFINE Delphi6UP}
+ {$DEFINE Delphi7UP}
+ {$DEFINE Delphi8UP}
+ {$DEFINE Delphi9UP}
+ {$DEFINE Delphi10UP}
+ {$WARN UNSAFE_TYPE OFF} {Disable warning for unsafe types in Delphi 7}
+ {$DEFINE Has_Int64}
+ {$DEFINE HAS_TYPES}
+{$ENDIF ver180}
+
+{$IFDEF ver185}
+ {$DEFINE Delphi} {Delphi 2007}
+ {$DEFINE Delphi32}
+ {$DEFINE Delphi4UP}
+ {$DEFINE Delphi5UP}
+ {$DEFINE Delphi6UP}
+ {$DEFINE Delphi7UP}
+ {$DEFINE Delphi8UP}
+ {$DEFINE Delphi9UP}
+ {$DEFINE Delphi10UP}
+ {$WARN UNSAFE_TYPE OFF} {Disable warning for unsafe types in Delphi 7}
+ {$DEFINE Has_Int64}
+ {$DEFINE HAS_TYPES}
+{$ENDIF ver180}
+
+{$IFDEF UNIX}
+ {$ifdef VER140} // Kylix 1 & 2
+ {$DEFINE KYLIX}
+ {$DEFINE KYLIX1UP}
+ {$DEFINE KYLIX2UP}
+ {$DEFINE HAS_TYPES}
+ {$endif}
+
+ {$ifdef VER150} // Kylix 3
+ {$DEFINE KYLIX}
+ {$DEFINE KYLIX1UP}
+ {$DEFINE KYLIX2UP}
+ {$DEFINE KYLIX3UP}
+ {$DEFINE HAS_TYPES}
+ {$endif}
+{$ENDIF UNIX}
+
+{$IFDEF VirtualPascal} { Virtual Pascal 2.x }
+ {$DEFINE Delphi} { Use Delphi Syntax }
+ {$DEFINE VP2}
+ {&Delphi+}
+{$ENDIF VirtualPascal}
+
+{$IFDEF Delphi}
+ {$DEFINE Windows}
+ {$DEFINE USE_STDCALL}
+ //{$ALIGN ON}
+{$ENDIF Delphi}
+
+{$IFDEF FPC}
+ {$MODE Delphi} { use Delphi compatibility mode }
+ {$H+}
+ {$PACKRECORDS C} // Added for record
+ {$MACRO ON} // Added For OpenGL
+ {$DEFINE Delphi}
+ {$DEFINE UseAT}
+ {$UNDEF USE_STDCALL}
+ {$DEFINE OS_BigMem}
+ {$DEFINE NO_EXPORTS}
+ {$DEFINE Has_Int64}
+ {$DEFINE NOCRT}
+ {$IFDEF UNIX}
+ {$DEFINE fpc_unix}
+ {$ELSE}
+ {$DEFINE __OS_DOS__}
+ {$ENDIF}
+ {$IFDEF WIN32}
+ {$DEFINE UseWin}
+ {$ENDIF}
+ {$DEFINE HAS_TYPES}
+{$ENDIF FPC}
+
+{$IFDEF Win16}
+ {$K+} {smart callbacks}
+{$ENDIF Win16}
+
+ {$IFDEF OS2}
+ {$UNDEF Windows}
+ {$DEFINE UseWin}
+ {$DEFINE OS_BigMem}
+ {$ENDIF OS2}
+
+{$IFDEF __GPC__}
+ {$UNDEF UseWin}
+ {$UNDEF USE_STDCALL}
+ {$DEFINE OS_BigMem}
+ {$DEFINE NO_EXPORTS}
+ {$DEFINE NOCRT}
+ {$DEFINE cdecl attribute(cdecl)}
+{$ENDIF}
+
+{$IFDEF __TMT__}
+ {$DEFINE OS_BigMem}
+ {$DEFINE NO_EXPORTS}
+ {$DEFINE __OS_DOS__}
+ {$DEFINE UseAT}
+ {$IFNDEF MSDOS}
+ {$DEFINE USE_STDCALL}
+ {$ENDIF}
+
+ {$IFDEF __WIN32__}
+ {$DEFINE Win32}
+ {$DEFINE UseWin}
+ {$DEFINE NOCRT}
+ {$DEFINE Win32}
+ {$IFNDEF __CON__}
+ {$DEFINE Windows}
+ {$ENDIF}
+ {$ENDIF}
+
+ {$A+} // Word alignment data
+ {$OA+} // Objects and structures align
+{$ENDIF}
+
+{$IFDEF Win32}
+ {$DEFINE OS_BigMem}
+{$ELSE Win32}
+ {$IFDEF ver70}
+ {$DEFINE assembler}
+ {$ENDIF} { use 16-bit assembler! }
+{$ENDIF Win32}
+
+{ ************************** dos/dos-like platforms **************}
+{$IFDEF Windows}
+ {$DEFINE __OS_DOS__}
+ {$DEFINE UseWin}
+ {$DEFINE MSWINDOWS}
+{$ENDIF Delphi}
+
+{$IFDEF OS2}
+ {$DEFINE __OS_DOS__}
+ {$DEFINE Can_Use_DLL}
+{$ENDIF Delphi}
+
+{$IFDEF UseWin}
+ {$DEFINE Can_Use_DLL}
+{$ENDIF}
+
+{$IFDEF Win16}
+ {$DEFINE Can_Use_DLL}
+{$ENDIF}
+
+{$IFDEF BP_DPMI}
+ {$DEFINE Can_Use_DLL}
+{$ENDIF}
+
+{$IFDEF USE_STDCALL}
+ {$IFNDEF __TMT__}
+ {$DEFINE BY_NAME}
+ {$ENDIF}
+{$ENDIF}
+
+{$IFNDEF ver70}
+ {$UNDEF assembler}
+{$ENDIF}
+
+{*************** define LITTLE ENDIAN platforms ********************}
+
+
+{$IFDEF Delphi}
+{$DEFINE IA32}
+{$ENDIF}
+
+{$IFDEF KYLIX}
+{$DEFINE IA32}
+{$ENDIF}
+
+{$IFDEF FPC}
+{$IFDEF FPC_LITTLE_ENDIAN}
+{$DEFINE IA32}
+{$ENDIF}
+{$ENDIF}
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/libxmlparser.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/libxmlparser.pas new file mode 100644 index 00000000..0cdf44c7 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/libxmlparser.pas @@ -0,0 +1,2688 @@ +(**
+===============================================================================================
+Name : LibXmlParser
+===============================================================================================
+Project : All Projects
+===============================================================================================
+Subject : Progressive XML Parser for all types of XML Files
+===============================================================================================
+Author : Stefan Heymann
+ Eschenweg 3
+ 72076 Tübingen
+ GERMANY
+
+E-Mail: stefan@destructor.de
+URL: www.destructor.de
+===============================================================================================
+Source, Legals ("Licence")
+--------------------------
+The official site to get this parser is http://www.destructor.de/
+
+Usage and Distribution of this Source Code is ruled by the
+"Destructor.de Source code Licence" (DSL) which comes with this file or
+can be downloaded at http://www.destructor.de/
+
+IN SHORT: Usage and distribution of this source code is free.
+ You use it completely on your own risk.
+
+Postcardware
+------------
+If you like this code, please send a postcard of your city to my above address.
+===============================================================================================
+!!! All parts of this code which are not finished or not conforming exactly to
+ the XmlSpec are marked with three exclamation marks
+
+-!- Parts where the parser may be able to detect errors in the document's syntax are
+ marked with the dash-exlamation mark-dash sequence.
+===============================================================================================
+Terminology:
+------------
+- Start: Start of a buffer part
+- Final: End (last character) of a buffer part
+- DTD: Document Type Definition
+- DTDc: Document Type Declaration
+- XMLSpec: The current W3C XML Recommendation (version 1.0 as of 1998-02-10), Chapter No.
+- Cur*: Fields concerning the "Current" part passed back by the "Scan" method
+===============================================================================================
+Scanning the XML document
+-------------------------
+- Create TXmlParser Instance MyXml := TXmlParser.Create;
+- Load XML Document MyXml.LoadFromFile (Filename);
+- Start Scanning MyXml.StartScan;
+- Scan Loop WHILE MyXml.Scan DO
+- Test for Part Type CASE MyXml.CurPartType OF
+- Handle Parts ... : ;;;
+- Handle Parts ... : ;;;
+- Handle Parts ... : ;;;
+ END;
+- Destroy MyXml.Free;
+===============================================================================================
+Loading the XML document
+------------------------
+You can load the XML document from a file with the "LoadFromFile" method.
+It is beyond the scope of this parser to perform HTTP or FTP accesses. If you want your
+application to handle such requests (URLs), you can load the XML via HTTP or FTP or whatever
+protocol and hand over the data buffer using the "LoadFromBuffer" or "SetBuffer" method.
+"LoadFromBuffer" loads the internal buffer of TXmlParser with the given null-terminated
+string, thereby creating a copy of that buffer.
+"SetBuffer" just takes the pointer to another buffer, which means that the given
+buffer pointer must be valid while the document is accessed via TXmlParser.
+===============================================================================================
+Encodings:
+----------
+This XML parser kind of "understands" the following encodings:
+- UTF-8
+- ISO-8859-1
+- Windows-1252
+
+Any flavor of multi-byte characters (and this includes UTF-16) is not supported. Sorry.
+
+Every string which has to be passed to the application passes the virtual method
+"TranslateEncoding" which translates the string from the current encoding (stored in
+"CurEncoding") into the encoding the application wishes to receive.
+The "TranslateEncoding" method that is built into TXmlParser assumes that the application
+wants to receive Windows ANSI (Windows-1252, about the same as ISO-8859-1) and is able
+to convert UTF-8 and ISO-8859-1 encodings.
+For other source and target encodings, you will have to override "TranslateEncoding".
+===============================================================================================
+Buffer Handling
+---------------
+- The document must be loaded completely into a piece of RAM
+- All character positions are referenced by PChar pointers
+- The TXmlParser instance can either "own" the buffer itself (then, FBufferSize is > 0)
+ or reference the buffer of another instance or object (then, FBuffersize is 0 and
+ FBuffer is not NIL)
+- The Property DocBuffer passes back a pointer to the first byte of the document. If there
+ is no document stored (FBuffer is NIL), the DocBuffer returns a pointer to a NULL character.
+===============================================================================================
+Whitespace Handling
+-------------------
+The TXmlParser property "PackSpaces" determines how Whitespace is returned in Text Content:
+While PackSpaces is true, all leading and trailing whitespace characters are trimmed of, all
+Whitespace is converted to Space #x20 characters and contiguous Whitespace characters are
+compressed to one.
+If the "Scan" method reports a ptContent part, the application can get the original text
+with all whitespace characters by extracting the characters from "CurStart" to "CurFinal".
+If the application detects an xml:space attribute, it can set "PackSpaces" accordingly or
+use CurStart/CurFinal.
+Please note that TXmlParser does _not_ normalize Line Breaks to single LineFeed characters
+as the XmlSpec requires (XmlSpec 2.11).
+The xml:space attribute is not handled by TXmlParser. This is on behalf of the application.
+===============================================================================================
+Non-XML-Conforming
+------------------
+TXmlParser does not conform 100 % exactly to the XmlSpec:
+- UTF-16 is not supported (XmlSpec 2.2)
+ (Workaround: Convert UTF-16 to UTF-8 and hand the buffer over to TXmlParser)
+- As the parser only works with single byte strings, all Unicode characters > 255
+ can currently not be handled correctly.
+- Line breaks are not normalized to single Linefeed #x0A characters (XmlSpec 2.11)
+ (Workaround: The Application can access the text contents on its own [CurStart, CurFinal],
+ thereby applying every normalization it wishes to)
+- The attribute value normalization does not work exactly as defined in the
+ Second Edition of the XML 1.0 specification.
+- See also the code parts marked with three consecutive exclamation marks. These are
+ parts which are not finished in the current code release.
+
+This list may be incomplete, so it may grow if I get to know any other points.
+As work on the parser proceeds, this list may also shrink.
+===============================================================================================
+Things Todo
+-----------
+- Introduce a new event/callback which is called when there is an unresolvable
+ entity or character reference
+- Support Unicode
+- Use Streams instead of reading the whole XML into memory
+===============================================================================================
+Change History, Version numbers
+-------------------------------
+The Date is given in ISO Year-Month-Day (YYYY-MM-DD) order.
+Versions are counted from 1.0.0 beginning with the version from 2000-03-16.
+Unreleased versions don't get a version number.
+
+Date Author Version Changes
+-----------------------------------------------------------------------------------------------
+2000-03-16 HeySt 1.0.0 Start
+2000-03-28 HeySt 1.0.1 Initial Publishing of TXmlParser on the destructor.de Web Site
+2000-03-30 HeySt 1.0.2 TXmlParser.AnalyzeCData: Call "TranslateEncoding" for CurContent
+2000-03-31 HeySt 1.0.3 Deleted the StrPosE function (was not needed anyway)
+2000-04-04 HeySt 1.0.4 TDtdElementRec modified: Start/Final for all Elements;
+ Should be backwards compatible.
+ AnalyzeDtdc: Set CurPartType to ptDtdc
+2000-04-23 HeySt 1.0.5 New class TObjectList. Eliminated reference to the Delphi 5
+ "Contnrs" unit so LibXmlParser is Delphi 4 compatible.
+2000-07-03 HeySt 1.0.6 TNvpNode: Added Constructor
+2000-07-11 HeySt 1.0.7 Removed "Windows" from USES clause
+ Added three-exclamation-mark comments for Utf8ToAnsi/AnsiToUtf8
+ Added three-exclamation-mark comments for CHR function calls
+2000-07-23 HeySt 1.0.8 TXmlParser.Clear: CurAttr.Clear; EntityStack.Clear;
+ (This was not a bug; just defensive programming)
+2000-07-29 HeySt 1.0.9 TNvpList: Added methods: Node(Index), Value(Index), Name(Index);
+2000-10-07 HeySt Introduced Conditional Defines
+ Uses Contnrs unit and its TObjectList class again for
+ Delphi 5 and newer versions
+2001-01-30 HeySt Introduced Version Numbering
+ Made LoadFromFile and LoadFromBuffer BOOLEAN functions
+ Introduced FileMode parameter for LoadFromFile
+ BugFix: TAttrList.Analyze: Must add CWhitespace to ExtractName call
+ Comments worked over
+2001-02-28 HeySt 1.0.10 Completely worked over and tested the UTF-8 functions
+ Fixed a bug in TXmlParser.Scan which caused it to start over when it
+ was called after the end of scanning, resulting in an endless loop
+ TEntityStack is now a TObjectList instead of TList
+2001-07-03 HeySt 1.0.11 Updated Compiler Version IFDEFs for Kylix
+2001-07-11 HeySt 1.0.12 New TCustomXmlScanner component (taken over from LibXmlComps.pas)
+2001-07-14 HeySt 1.0.13 Bugfix TCustomXmlScanner.FOnTranslateEncoding
+2001-10-22 HeySt Don't clear CurName anymore when the parser finds a CDATA section.
+2001-12-03 HeySt 1.0.14 TObjectList.Clear: Make call to INHERITED method (fixes a memory leak)
+2001-12-05 HeySt 1.0.15 TObjectList.Clear: removed call to INHERITED method
+ TObjectList.Destroy: Inserted SetCapacity call.
+ Reduces need for frequent re-allocation of pointer buffer
+ Dedicated to my father, Theodor Heymann
+2002-06-26 HeySt 1.0.16 TXmlParser.Scan: Fixed a bug with PIs whose name is beginning
+ with 'xml'. Thanks to Uwe Kamm for submitting this bug.
+ The CurEncoding property is now always in uppercase letters (the XML
+ spec wants it to be treated case independently so when it's uppercase
+ comparisons are faster)
+2002-03-04 HeySt 1.0.17 Included an IFDEF for Delphi 7 (VER150) and Kylix
+ There is a new symbol HAS_CONTNRS_UNIT which is used now to
+ distinguish between IDEs which come with the Contnrs unit and
+ those that don't.
+*)
+
+UNIT libxmlparser;
+
+{$I jedi-sdl.inc}
+
+INTERFACE
+
+USES
+ SysUtils, Classes,
+ (*$IFDEF HAS_CONTNRS_UNIT *) // The Contnrs Unit was introduced in Delphi 5
+ Contnrs,
+ (*$ENDIF*)
+ Math;
+
+CONST
+ CVersion = '1.0.17'; // This variable will be updated for every release
+ // (I hope, I won't forget to do it everytime ...)
+
+TYPE
+ TPartType = // --- Document Part Types
+ (ptNone, // Nothing
+ ptXmlProlog, // XML Prolog XmlSpec 2.8 / 4.3.1
+ ptComment, // Comment XmlSpec 2.5
+ ptPI, // Processing Instruction XmlSpec 2.6
+ ptDtdc, // Document Type Declaration XmlSpec 2.8
+ ptStartTag, // Start Tag XmlSpec 3.1
+ ptEmptyTag, // Empty-Element Tag XmlSpec 3.1
+ ptEndTag, // End Tag XmlSpec 3.1
+ ptContent, // Text Content between Tags
+ ptCData); // CDATA Section XmlSpec 2.7
+
+ TDtdElemType = // --- DTD Elements
+ (deElement, // !ELEMENT declaration
+ deAttList, // !ATTLIST declaration
+ deEntity, // !ENTITY declaration
+ deNotation, // !NOTATION declaration
+ dePI, // PI in DTD
+ deComment, // Comment in DTD
+ deError); // Error found in the DTD
+
+TYPE
+ TAttrList = CLASS;
+ TEntityStack = CLASS;
+ TNvpList = CLASS;
+ TElemDef = CLASS;
+ TElemList = CLASS;
+ TEntityDef = CLASS;
+ TNotationDef = CLASS;
+
+ TDtdElementRec = RECORD // --- This Record is returned by the DTD parser callback function
+ Start, Final : PChar; // Start/End of the Element's Declaration
+ CASE ElementType : TDtdElemType OF // Type of the Element
+ deElement, // <!ELEMENT>
+ deAttList : (ElemDef : TElemDef); // <!ATTLIST>
+ deEntity : (EntityDef : TEntityDef); // <!ENTITY>
+ deNotation : (NotationDef : TNotationDef); // <!NOTATION>
+ dePI : (Target : PChar; // <?PI ?>
+ Content : PChar;
+ AttrList : TAttrList);
+ deError : (Pos : PChar); // Error
+ // deComment : ((No additional fields here)); // <!-- Comment -->
+ END;
+
+ TXmlParser = CLASS // --- Internal Properties and Methods
+ PROTECTED
+ FBuffer : PChar; // NIL if there is no buffer available
+ FBufferSize : INTEGER; // 0 if the buffer is not owned by the Document instance
+ FSource : STRING; // Name of Source of document. Filename for Documents loaded with LoadFromFile
+
+ FXmlVersion : STRING; // XML version from Document header. Default is '1.0'
+ FEncoding : STRING; // Encoding from Document header. Default is 'UTF-8'
+ FStandalone : BOOLEAN; // Standalone declaration from Document header. Default is 'yes'
+ FRootName : STRING; // Name of the Root Element (= DTD name)
+ FDtdcFinal : PChar; // Pointer to the '>' character terminating the DTD declaration
+
+ FNormalize : BOOLEAN; // If true: Pack Whitespace and don't return empty contents
+ EntityStack : TEntityStack; // Entity Stack for Parameter and General Entities
+ FCurEncoding : STRING; // Current Encoding during parsing (always uppercase)
+
+ PROCEDURE AnalyzeProlog; // Analyze XML Prolog or Text Declaration
+ PROCEDURE AnalyzeComment (Start : PChar; VAR Final : PChar); // Analyze Comments
+ PROCEDURE AnalyzePI (Start : PChar; VAR Final : PChar); // Analyze Processing Instructions (PI)
+ PROCEDURE AnalyzeDtdc; // Analyze Document Type Declaration
+ PROCEDURE AnalyzeDtdElements (Start : PChar; VAR Final : PChar); // Analyze DTD declarations
+ PROCEDURE AnalyzeTag; // Analyze Start/End/Empty-Element Tags
+ PROCEDURE AnalyzeCData; // Analyze CDATA Sections
+ PROCEDURE AnalyzeText (VAR IsDone : BOOLEAN); // Analyze Text Content between Tags
+ PROCEDURE AnalyzeElementDecl (Start : PChar; VAR Final : PChar);
+ PROCEDURE AnalyzeAttListDecl (Start : PChar; VAR Final : PChar);
+ PROCEDURE AnalyzeEntityDecl (Start : PChar; VAR Final : PChar);
+ PROCEDURE AnalyzeNotationDecl (Start : PChar; VAR Final : PChar);
+
+ PROCEDURE PushPE (VAR Start : PChar);
+ PROCEDURE ReplaceCharacterEntities (VAR Str : STRING);
+ PROCEDURE ReplaceParameterEntities (VAR Str : STRING);
+ PROCEDURE ReplaceGeneralEntities (VAR Str : STRING);
+
+ FUNCTION GetDocBuffer : PChar; // Returns FBuffer or a pointer to a NUL char if Buffer is empty
+
+ PUBLIC // --- Document Properties
+ PROPERTY XmlVersion : STRING READ FXmlVersion; // XML version from the Document Prolog
+ PROPERTY Encoding : STRING READ FEncoding; // Document Encoding from Prolog
+ PROPERTY Standalone : BOOLEAN READ FStandalone; // Standalone Declaration from Prolog
+ PROPERTY RootName : STRING READ FRootName; // Name of the Root Element
+ PROPERTY Normalize : BOOLEAN READ FNormalize WRITE FNormalize; // True if Content is to be normalized
+ PROPERTY Source : STRING READ FSource; // Name of Document Source (Filename)
+ PROPERTY DocBuffer : PChar READ GetDocBuffer; // Returns document buffer
+ PUBLIC // --- DTD Objects
+ Elements : TElemList; // Elements: List of TElemDef (contains Attribute Definitions)
+ Entities : TNvpList; // General Entities: List of TEntityDef
+ ParEntities : TNvpList; // Parameter Entities: List of TEntityDef
+ Notations : TNvpList; // Notations: List of TNotationDef
+ PUBLIC
+ CONSTRUCTOR Create;
+ DESTRUCTOR Destroy; OVERRIDE;
+
+ // --- Document Handling
+ FUNCTION LoadFromFile (Filename : STRING;
+ FileMode : INTEGER = fmOpenRead OR fmShareDenyNone) : BOOLEAN;
+ // Loads Document from given file
+ FUNCTION LoadFromBuffer (Buffer : PChar) : BOOLEAN; // Loads Document from another buffer
+ PROCEDURE SetBuffer (Buffer : PChar); // References another buffer
+ PROCEDURE Clear; // Clear Document
+
+ PUBLIC
+ // --- Scanning through the document
+ CurPartType : TPartType; // Current Type
+ CurName : STRING; // Current Name
+ CurContent : STRING; // Current Normalized Content
+ CurStart : PChar; // Current First character
+ CurFinal : PChar; // Current Last character
+ CurAttr : TAttrList; // Current Attribute List
+ PROPERTY CurEncoding : STRING READ FCurEncoding; // Current Encoding
+ PROCEDURE StartScan;
+ FUNCTION Scan : BOOLEAN;
+
+ // --- Events / Callbacks
+ FUNCTION LoadExternalEntity (SystemId, PublicId,
+ Notation : STRING) : TXmlParser; VIRTUAL;
+ FUNCTION TranslateEncoding (CONST Source : STRING) : STRING; VIRTUAL;
+ PROCEDURE DtdElementFound (DtdElementRec : TDtdElementRec); VIRTUAL;
+ END;
+
+ TValueType = // --- Attribute Value Type
+ (vtNormal, // Normal specified Attribute
+ vtImplied, // #IMPLIED attribute value
+ vtFixed, // #FIXED attribute value
+ vtDefault); // Attribute value from default value in !ATTLIST declaration
+
+ TAttrDefault = // --- Attribute Default Type
+ (adDefault, // Normal default value
+ adRequired, // #REQUIRED attribute
+ adImplied, // #IMPLIED attribute
+ adFixed); // #FIXED attribute
+
+ TAttrType = // --- Type of attribute
+ (atUnknown, // Unknown type
+ atCData, // Character data only
+ atID, // ID
+ atIdRef, // ID Reference
+ atIdRefs, // Several ID References, separated by Whitespace
+ atEntity, // Name of an unparsed Entity
+ atEntities, // Several unparsed Entity names, separated by Whitespace
+ atNmToken, // Name Token
+ atNmTokens, // Several Name Tokens, separated by Whitespace
+ atNotation, // A selection of Notation names (Unparsed Entity)
+ atEnumeration); // Enumeration
+
+ TElemType = // --- Element content type
+ (etEmpty, // Element is always empty
+ etAny, // Element can have any mixture of PCDATA and any elements
+ etChildren, // Element must contain only elements
+ etMixed); // Mixed PCDATA and elements
+
+ (*$IFDEF HAS_CONTNRS_UNIT *)
+ TObjectList = Contnrs.TObjectList; // Re-Export this identifier
+ (*$ELSE *)
+ TObjectList = CLASS (TList)
+ DESTRUCTOR Destroy; OVERRIDE;
+ PROCEDURE Delete (Index : INTEGER);
+ PROCEDURE Clear; OVERRIDE;
+ END;
+ (*$ENDIF *)
+
+ TNvpNode = CLASS // Name-Value Pair Node
+ Name : STRING;
+ Value : STRING;
+ CONSTRUCTOR Create (TheName : STRING = ''; TheValue : STRING = '');
+ END;
+
+ TNvpList = CLASS (TObjectList) // Name-Value Pair List
+ PROCEDURE Add (Node : TNvpNode);
+ FUNCTION Node (Name : STRING) : TNvpNode; OVERLOAD;
+ FUNCTION Node (Index : INTEGER) : TNvpNode; OVERLOAD;
+ FUNCTION Value (Name : STRING) : STRING; OVERLOAD;
+ FUNCTION Value (Index : INTEGER) : STRING; OVERLOAD;
+ FUNCTION Name (Index : INTEGER) : STRING;
+ END;
+
+ TAttr = CLASS (TNvpNode) // Attribute of a Start-Tag or Empty-Element-Tag
+ ValueType : TValueType;
+ AttrType : TAttrType;
+ END;
+
+ TAttrList = CLASS (TNvpList) // List of Attributes
+ PROCEDURE Analyze (Start : PChar; VAR Final : PChar);
+ END;
+
+ TEntityStack = CLASS (TObjectList) // Stack where current position is stored before parsing entities
+ PROTECTED
+ Owner : TXmlParser;
+ PUBLIC
+ CONSTRUCTOR Create (TheOwner : TXmlParser);
+ PROCEDURE Push (LastPos : PChar); OVERLOAD;
+ PROCEDURE Push (Instance : TObject; LastPos : PChar); OVERLOAD;
+ FUNCTION Pop : PChar; // Returns next char or NIL if EOF is reached. Frees Instance.
+ END;
+
+ TAttrDef = CLASS (TNvpNode) // Represents a <!ATTLIST Definition. "Value" is the default value
+ TypeDef : STRING; // Type definition from the DTD
+ Notations : STRING; // Notation List, separated by pipe symbols '|'
+ AttrType : TAttrType; // Attribute Type
+ DefaultType : TAttrDefault; // Default Type
+ END;
+
+ TElemDef = CLASS (TNvpList) // Represents a <!ELEMENT Definition. Is a list of TAttrDef-Nodes
+ Name : STRING; // Element name
+ ElemType : TElemType; // Element type
+ Definition : STRING; // Element definition from DTD
+ END;
+
+ TElemList = CLASS (TObjectList) // List of TElemDef nodes
+ FUNCTION Node (Name : STRING) : TElemDef;
+ PROCEDURE Add (Node : TElemDef);
+ END;
+
+ TEntityDef = CLASS (TNvpNode) // Represents a <!ENTITY Definition.
+ SystemId : STRING;
+ PublicId : STRING;
+ NotationName : STRING;
+ END;
+
+ TNotationDef = CLASS (TNvpNode) // Represents a <!NOTATION Definition. Value is the System ID
+ PublicId : STRING;
+ END;
+
+ TCharset = SET OF CHAR;
+
+
+CONST
+ CWhitespace = [#32, #9, #13, #10]; // Whitespace characters (XmlSpec 2.3)
+ CLetter = [#$41..#$5A, #$61..#$7A, #$C0..#$D6, #$D8..#$F6, #$F8..#$FF];
+ CDigit = [#$30..#$39];
+ CNameChar = CLetter + CDigit + ['.', '-', '_', ':', #$B7];
+ CNameStart = CLetter + ['_', ':'];
+ CQuoteChar = ['"', ''''];
+ CPubidChar = [#32, ^M, ^J, #9, 'a'..'z', 'A'..'Z', '0'..'9',
+ '-', '''', '(', ')', '+', ',', '.', '/', ':',
+ '=', '?', ';', '!', '*', '#', '@', '$', '_', '%'];
+
+ CDStart = '<![CDATA[';
+ CDEnd = ']]>';
+
+ // --- Name Constants for the above enumeration types
+ CPartType_Name : ARRAY [TPartType] OF STRING =
+ ('', 'XML Prolog', 'Comment', 'PI',
+ 'DTD Declaration', 'Start Tag', 'Empty Tag', 'End Tag',
+ 'Text', 'CDATA');
+ CValueType_Name : ARRAY [TValueType] OF STRING = ('Normal', 'Implied', 'Fixed', 'Default');
+ CAttrDefault_Name : ARRAY [TAttrDefault] OF STRING = ('Default', 'Required', 'Implied', 'Fixed');
+ CElemType_Name : ARRAY [TElemType] OF STRING = ('Empty', 'Any', 'Childs only', 'Mixed');
+ CAttrType_Name : ARRAY [TAttrType] OF STRING = ('Unknown', 'CDATA',
+ 'ID', 'IDREF', 'IDREFS',
+ 'ENTITY', 'ENTITIES',
+ 'NMTOKEN', 'NMTOKENS',
+ 'Notation', 'Enumeration');
+
+FUNCTION ConvertWs (Source: STRING; PackWs: BOOLEAN) : STRING; // Convert WS to spaces #x20
+PROCEDURE SetStringSF (VAR S : STRING; BufferStart, BufferFinal : PChar); // SetString by Start/Final of buffer
+FUNCTION StrSFPas (Start, Finish : PChar) : STRING; // Convert buffer part to Pascal string
+FUNCTION TrimWs (Source : STRING) : STRING; // Trim Whitespace
+
+FUNCTION AnsiToUtf8 (Source : ANSISTRING) : STRING; // Convert Win-1252 to UTF-8
+FUNCTION Utf8ToAnsi (Source : STRING; UnknownChar : CHAR = 'ż') : ANSISTRING; // Convert UTF-8 to Win-1252
+
+
+(*
+===============================================================================================
+TCustomXmlScanner event based component wrapper for TXmlParser
+===============================================================================================
+*)
+
+TYPE
+ TCustomXmlScanner = CLASS;
+ TXmlPrologEvent = PROCEDURE (Sender : TObject; XmlVersion, Encoding: STRING; Standalone : BOOLEAN) OF OBJECT;
+ TCommentEvent = PROCEDURE (Sender : TObject; Comment : STRING) OF OBJECT;
+ TPIEvent = PROCEDURE (Sender : TObject; Target, Content: STRING; Attributes : TAttrList) OF OBJECT;
+ TDtdEvent = PROCEDURE (Sender : TObject; RootElementName : STRING) OF OBJECT;
+ TStartTagEvent = PROCEDURE (Sender : TObject; TagName : STRING; Attributes : TAttrList) OF OBJECT;
+ TEndTagEvent = PROCEDURE (Sender : TObject; TagName : STRING) OF OBJECT;
+ TContentEvent = PROCEDURE (Sender : TObject; Content : STRING) OF OBJECT;
+ TElementEvent = PROCEDURE (Sender : TObject; ElemDef : TElemDef) OF OBJECT;
+ TEntityEvent = PROCEDURE (Sender : TObject; EntityDef : TEntityDef) OF OBJECT;
+ TNotationEvent = PROCEDURE (Sender : TObject; NotationDef : TNotationDef) OF OBJECT;
+ TErrorEvent = PROCEDURE (Sender : TObject; ErrorPos : PChar) OF OBJECT;
+ TExternalEvent = PROCEDURE (Sender : TObject; SystemId, PublicId, NotationId : STRING;
+ VAR Result : TXmlParser) OF OBJECT;
+ TEncodingEvent = FUNCTION (Sender : TObject; CurrentEncoding, Source : STRING) : STRING OF OBJECT;
+
+
+ TCustomXmlScanner = CLASS (TComponent)
+ PROTECTED
+ FXmlParser : TXmlParser;
+ FOnXmlProlog : TXmlPrologEvent;
+ FOnComment : TCommentEvent;
+ FOnPI : TPIEvent;
+ FOnDtdRead : TDtdEvent;
+ FOnStartTag : TStartTagEvent;
+ FOnEmptyTag : TStartTagEvent;
+ FOnEndTag : TEndTagEvent;
+ FOnContent : TContentEvent;
+ FOnCData : TContentEvent;
+ FOnElement : TElementEvent;
+ FOnAttList : TElementEvent;
+ FOnEntity : TEntityEvent;
+ FOnNotation : TNotationEvent;
+ FOnDtdError : TErrorEvent;
+ FOnLoadExternal : TExternalEvent;
+ FOnTranslateEncoding : TEncodingEvent;
+ FStopParser : BOOLEAN;
+ FUNCTION GetNormalize : BOOLEAN;
+ PROCEDURE SetNormalize (Value : BOOLEAN);
+
+ PROCEDURE WhenXmlProlog(XmlVersion, Encoding: STRING; Standalone : BOOLEAN); VIRTUAL;
+ PROCEDURE WhenComment (Comment : STRING); VIRTUAL;
+ PROCEDURE WhenPI (Target, Content: STRING; Attributes : TAttrList); VIRTUAL;
+ PROCEDURE WhenDtdRead (RootElementName : STRING); VIRTUAL;
+ PROCEDURE WhenStartTag (TagName : STRING; Attributes : TAttrList); VIRTUAL;
+ PROCEDURE WhenEmptyTag (TagName : STRING; Attributes : TAttrList); VIRTUAL;
+ PROCEDURE WhenEndTag (TagName : STRING); VIRTUAL;
+ PROCEDURE WhenContent (Content : STRING); VIRTUAL;
+ PROCEDURE WhenCData (Content : STRING); VIRTUAL;
+ PROCEDURE WhenElement (ElemDef : TElemDef); VIRTUAL;
+ PROCEDURE WhenAttList (ElemDef : TElemDef); VIRTUAL;
+ PROCEDURE WhenEntity (EntityDef : TEntityDef); VIRTUAL;
+ PROCEDURE WhenNotation (NotationDef : TNotationDef); VIRTUAL;
+ PROCEDURE WhenDtdError (ErrorPos : PChar); VIRTUAL;
+
+ PUBLIC
+ CONSTRUCTOR Create (AOwner: TComponent); OVERRIDE;
+ DESTRUCTOR Destroy; OVERRIDE;
+
+ PROCEDURE LoadFromFile (Filename : TFilename); // Load XML Document from file
+ PROCEDURE LoadFromBuffer (Buffer : PChar); // Load XML Document from buffer
+ PROCEDURE SetBuffer (Buffer : PChar); // Refer to Buffer
+ FUNCTION GetFilename : TFilename;
+
+ PROCEDURE Execute; // Perform scanning
+
+ PROTECTED
+ PROPERTY XmlParser : TXmlParser READ FXmlParser;
+ PROPERTY StopParser : BOOLEAN READ FStopParser WRITE FStopParser;
+ PROPERTY Filename : TFilename READ GetFilename WRITE LoadFromFile;
+ PROPERTY Normalize : BOOLEAN READ GetNormalize WRITE SetNormalize;
+ PROPERTY OnXmlProlog : TXmlPrologEvent READ FOnXmlProlog WRITE FOnXmlProlog;
+ PROPERTY OnComment : TCommentEvent READ FOnComment WRITE FOnComment;
+ PROPERTY OnPI : TPIEvent READ FOnPI WRITE FOnPI;
+ PROPERTY OnDtdRead : TDtdEvent READ FOnDtdRead WRITE FOnDtdRead;
+ PROPERTY OnStartTag : TStartTagEvent READ FOnStartTag WRITE FOnStartTag;
+ PROPERTY OnEmptyTag : TStartTagEvent READ FOnEmptyTag WRITE FOnEmptyTag;
+ PROPERTY OnEndTag : TEndTagEvent READ FOnEndTag WRITE FOnEndTag;
+ PROPERTY OnContent : TContentEvent READ FOnContent WRITE FOnContent;
+ PROPERTY OnCData : TContentEvent READ FOnCData WRITE FOnCData;
+ PROPERTY OnElement : TElementEvent READ FOnElement WRITE FOnElement;
+ PROPERTY OnAttList : TElementEvent READ FOnAttList WRITE FOnAttList;
+ PROPERTY OnEntity : TEntityEvent READ FOnEntity WRITE FOnEntity;
+ PROPERTY OnNotation : TNotationEvent READ FOnNotation WRITE FOnNotation;
+ PROPERTY OnDtdError : TErrorEvent READ FOnDtdError WRITE FOnDtdError;
+ PROPERTY OnLoadExternal : TExternalEvent READ FOnLoadExternal WRITE FOnLoadExternal;
+ PROPERTY OnTranslateEncoding : TEncodingEvent READ FOnTranslateEncoding WRITE FOnTranslateEncoding;
+ END;
+
+(*
+===============================================================================================
+IMPLEMENTATION
+===============================================================================================
+*)
+
+IMPLEMENTATION
+
+
+(*
+===============================================================================================
+Unicode and UTF-8 stuff
+===============================================================================================
+*)
+
+CONST
+ // --- Character Translation Table for Unicode <-> Win-1252
+ WIN1252_UNICODE : ARRAY [$00..$FF] OF WORD = (
+ $0000, $0001, $0002, $0003, $0004, $0005, $0006, $0007, $0008, $0009,
+ $000A, $000B, $000C, $000D, $000E, $000F, $0010, $0011, $0012, $0013,
+ $0014, $0015, $0016, $0017, $0018, $0019, $001A, $001B, $001C, $001D,
+ $001E, $001F, $0020, $0021, $0022, $0023, $0024, $0025, $0026, $0027,
+ $0028, $0029, $002A, $002B, $002C, $002D, $002E, $002F, $0030, $0031,
+ $0032, $0033, $0034, $0035, $0036, $0037, $0038, $0039, $003A, $003B,
+ $003C, $003D, $003E, $003F, $0040, $0041, $0042, $0043, $0044, $0045,
+ $0046, $0047, $0048, $0049, $004A, $004B, $004C, $004D, $004E, $004F,
+ $0050, $0051, $0052, $0053, $0054, $0055, $0056, $0057, $0058, $0059,
+ $005A, $005B, $005C, $005D, $005E, $005F, $0060, $0061, $0062, $0063,
+ $0064, $0065, $0066, $0067, $0068, $0069, $006A, $006B, $006C, $006D,
+ $006E, $006F, $0070, $0071, $0072, $0073, $0074, $0075, $0076, $0077,
+ $0078, $0079, $007A, $007B, $007C, $007D, $007E, $007F,
+
+ $20AC, $0081, $201A, $0192, $201E, $2026, $2020, $2021, $02C6, $2030,
+ $0160, $2039, $0152, $008D, $017D, $008F, $0090, $2018, $2019, $201C,
+ $201D, $2022, $2013, $2014, $02DC, $2122, $0161, $203A, $0153, $009D,
+ $017E, $0178, $00A0, $00A1, $00A2, $00A3, $00A4, $00A5, $00A6, $00A7,
+ $00A8, $00A9, $00AA, $00AB, $00AC, $00AD, $00AE, $00AF, $00B0, $00B1,
+ $00B2, $00B3, $00B4, $00B5, $00B6, $00B7, $00B8, $00B9, $00BA, $00BB,
+ $00BC, $00BD, $00BE, $00BF, $00C0, $00C1, $00C2, $00C3, $00C4, $00C5,
+ $00C6, $00C7, $00C8, $00C9, $00CA, $00CB, $00CC, $00CD, $00CE, $00CF,
+ $00D0, $00D1, $00D2, $00D3, $00D4, $00D5, $00D6, $00D7, $00D8, $00D9,
+ $00DA, $00DB, $00DC, $00DD, $00DE, $00DF, $00E0, $00E1, $00E2, $00E3,
+ $00E4, $00E5, $00E6, $00E7, $00E8, $00E9, $00EA, $00EB, $00EC, $00ED,
+ $00EE, $00EF, $00F0, $00F1, $00F2, $00F3, $00F4, $00F5, $00F6, $00F7,
+ $00F8, $00F9, $00FA, $00FB, $00FC, $00FD, $00FE, $00FF);
+
+(* UTF-8 (somewhat simplified)
+ -----
+ Character Range Byte sequence
+ --------------- -------------------------- (x=Bits from original character)
+ $0000..$007F 0xxxxxxx
+ $0080..$07FF 110xxxxx 10xxxxxx
+ $8000..$FFFF 1110xxxx 10xxxxxx 10xxxxxx
+
+ Example
+ --------
+ Transforming the Unicode character U+00E4 LATIN SMALL LETTER A WITH DIAERESIS ("ä"):
+
+ ISO-8859-1, Decimal 228
+ Win1252, Hex $E4
+ ANSI Bin 1110 0100
+ abcd efgh
+
+ UTF-8 Binary 1100xxab 10cdefgh
+ Binary 11000011 10100100
+ Hex $C3 $A4
+ Decimal 195 164
+ ANSI Ă ¤ *)
+
+
+FUNCTION AnsiToUtf8 (Source : ANSISTRING) : STRING;
+ (* Converts the given Windows ANSI (Win1252) String to UTF-8. *)
+VAR
+ I : INTEGER; // Loop counter
+ U : WORD; // Current Unicode value
+ Len : INTEGER; // Current real length of "Result" string
+BEGIN
+ SetLength (Result, Length (Source) * 3); // Worst case
+ Len := 0;
+ FOR I := 1 TO Length (Source) DO BEGIN
+ U := WIN1252_UNICODE [ORD (Source [I])];
+ CASE U OF
+ $0000..$007F : BEGIN
+ INC (Len);
+ Result [Len] := CHR (U);
+ END;
+ $0080..$07FF : BEGIN
+ INC (Len);
+ Result [Len] := CHR ($C0 OR (U SHR 6));
+ INC (Len);
+ Result [Len] := CHR ($80 OR (U AND $3F));
+ END;
+ $0800..$FFFF : BEGIN
+ INC (Len);
+ Result [Len] := CHR ($E0 OR (U SHR 12));
+ INC (Len);
+ Result [Len] := CHR ($80 OR ((U SHR 6) AND $3F));
+ INC (Len);
+ Result [Len] := CHR ($80 OR (U AND $3F));
+ END;
+ END;
+ END;
+ SetLength (Result, Len);
+END;
+
+
+FUNCTION Utf8ToAnsi (Source : STRING; UnknownChar : CHAR = 'ż') : ANSISTRING;
+ (* Converts the given UTF-8 String to Windows ANSI (Win-1252).
+ If a character can not be converted, the "UnknownChar" is inserted. *)
+VAR
+ SourceLen : INTEGER; // Length of Source string
+ I, K : INTEGER;
+ A : BYTE; // Current ANSI character value
+ U : WORD;
+ Ch : CHAR; // Dest char
+ Len : INTEGER; // Current real length of "Result" string
+BEGIN
+ SourceLen := Length (Source);
+ SetLength (Result, SourceLen); // Enough room to live
+ Len := 0;
+ I := 1;
+ WHILE I <= SourceLen DO BEGIN
+ A := ORD (Source [I]);
+ IF A < $80 THEN BEGIN // Range $0000..$007F
+ INC (Len);
+ Result [Len] := Source [I];
+ INC (I);
+ END
+ ELSE BEGIN // Determine U, Inc I
+ IF (A AND $E0 = $C0) AND (I < SourceLen) THEN BEGIN // Range $0080..$07FF
+ U := (WORD (A AND $1F) SHL 6) OR (ORD (Source [I+1]) AND $3F);
+ INC (I, 2);
+ END
+ ELSE IF (A AND $F0 = $E0) AND (I < SourceLen-1) THEN BEGIN // Range $0800..$FFFF
+ U := (WORD (A AND $0F) SHL 12) OR
+ (WORD (ORD (Source [I+1]) AND $3F) SHL 6) OR
+ ( ORD (Source [I+2]) AND $3F);
+ INC (I, 3);
+ END
+ ELSE BEGIN // Unknown/unsupported
+ INC (I);
+ FOR K := 7 DOWNTO 0 DO
+ IF A AND (1 SHL K) = 0 THEN BEGIN
+ INC (I, (A SHR (K+1))-1);
+ BREAK;
+ END;
+ U := WIN1252_UNICODE [ORD (UnknownChar)];
+ END;
+ Ch := UnknownChar; // Retrieve ANSI char
+ FOR A := $00 TO $FF DO
+ IF WIN1252_UNICODE [A] = U THEN BEGIN
+ Ch := CHR (A);
+ BREAK;
+ END;
+ INC (Len);
+ Result [Len] := Ch;
+ END;
+ END;
+ SetLength (Result, Len);
+END;
+
+
+(*
+===============================================================================================
+"Special" Helper Functions
+
+Don't ask me why. But including these functions makes the parser *DRAMATICALLY* faster
+on my K6-233 machine. You can test it yourself just by commenting them out.
+They do exactly the same as the Assembler routines defined in SysUtils.
+(This is where you can see how great the Delphi compiler really is. The compiled code is
+faster than hand-coded assembler!)
+===============================================================================================
+--> Just move this line below the StrScan function --> *)
+
+
+FUNCTION StrPos (CONST Str, SearchStr : PChar) : PChar;
+ // Same functionality as SysUtils.StrPos
+VAR
+ First : CHAR;
+ Len : INTEGER;
+BEGIN
+ First := SearchStr^;
+ Len := StrLen (SearchStr);
+ Result := Str;
+ REPEAT
+ IF Result^ = First THEN
+ IF StrLComp (Result, SearchStr, Len) = 0 THEN BREAK;
+ IF Result^ = #0 THEN BEGIN
+ Result := NIL;
+ BREAK;
+ END;
+ INC (Result);
+ UNTIL FALSE;
+END;
+
+
+FUNCTION StrScan (CONST Start : PChar; CONST Ch : CHAR) : PChar;
+ // Same functionality as SysUtils.StrScan
+BEGIN
+ Result := Start;
+ WHILE Result^ <> Ch DO BEGIN
+ IF Result^ = #0 THEN BEGIN
+ Result := NIL;
+ EXIT;
+ END;
+ INC (Result);
+ END;
+END;
+
+
+(*
+===============================================================================================
+Helper Functions
+===============================================================================================
+*)
+
+FUNCTION DelChars (Source : STRING; CharsToDelete : TCharset) : STRING;
+ // Delete all "CharsToDelete" from the string
+VAR
+ I : INTEGER;
+BEGIN
+ Result := Source;
+ FOR I := Length (Result) DOWNTO 1 DO
+ IF Result [I] IN CharsToDelete THEN
+ Delete (Result, I, 1);
+END;
+
+
+FUNCTION TrimWs (Source : STRING) : STRING;
+ // Trimms off Whitespace characters from both ends of the string
+VAR
+ I : INTEGER;
+BEGIN
+ // --- Trim Left
+ I := 1;
+ WHILE (I <= Length (Source)) AND (Source [I] IN CWhitespace) DO
+ INC (I);
+ Result := Copy (Source, I, MaxInt);
+
+ // --- Trim Right
+ I := Length (Result);
+ WHILE (I > 1) AND (Result [I] IN CWhitespace) DO
+ DEC (I);
+ Delete (Result, I+1, Length (Result)-I);
+END;
+
+
+FUNCTION ConvertWs (Source: STRING; PackWs: BOOLEAN) : STRING;
+ // Converts all Whitespace characters to the Space #x20 character
+ // If "PackWs" is true, contiguous Whitespace characters are packed to one
+VAR
+ I : INTEGER;
+BEGIN
+ Result := Source;
+ FOR I := Length (Result) DOWNTO 1 DO
+ IF (Result [I] IN CWhitespace) THEN
+ IF PackWs AND (I > 1) AND (Result [I-1] IN CWhitespace)
+ THEN Delete (Result, I, 1)
+ ELSE Result [I] := #32;
+END;
+
+
+PROCEDURE SetStringSF (VAR S : STRING; BufferStart, BufferFinal : PChar);
+BEGIN
+ SetString (S, BufferStart, BufferFinal-BufferStart+1);
+END;
+
+
+FUNCTION StrLPas (Start : PChar; Len : INTEGER) : STRING;
+BEGIN
+ SetString (Result, Start, Len);
+END;
+
+
+FUNCTION StrSFPas (Start, Finish : PChar) : STRING;
+BEGIN
+ SetString (Result, Start, Finish-Start+1);
+END;
+
+
+FUNCTION StrScanE (CONST Source : PChar; CONST CharToScanFor : CHAR) : PChar;
+ // If "CharToScanFor" is not found, StrScanE returns the last char of the
+ // buffer instead of NIL
+BEGIN
+ Result := StrScan (Source, CharToScanFor);
+ IF Result = NIL THEN
+ Result := StrEnd (Source)-1;
+END;
+
+
+PROCEDURE ExtractName (Start : PChar; Terminators : TCharset; VAR Final : PChar);
+ (* Extracts the complete Name beginning at "Start".
+ It is assumed that the name is contained in Markup, so the '>' character is
+ always a Termination.
+ Start: IN Pointer to first char of name. Is always considered to be valid
+ Terminators: IN Characters which terminate the name
+ Final: OUT Pointer to last char of name *)
+BEGIN
+ Final := Start+1;
+ Include (Terminators, #0);
+ Include (Terminators, '>');
+ WHILE NOT (Final^ IN Terminators) DO
+ INC (Final);
+ DEC (Final);
+END;
+
+
+PROCEDURE ExtractQuote (Start : PChar; VAR Content : STRING; VAR Final : PChar);
+ (* Extract a string which is contained in single or double Quotes.
+ Start: IN Pointer to opening quote
+ Content: OUT The quoted string
+ Final: OUT Pointer to closing quote *)
+BEGIN
+ Final := StrScan (Start+1, Start^);
+ IF Final = NIL THEN BEGIN
+ Final := StrEnd (Start+1)-1;
+ SetString (Content, Start+1, Final-Start);
+ END
+ ELSE
+ SetString (Content, Start+1, Final-1-Start);
+END;
+
+
+(*
+===============================================================================================
+TEntityStackNode
+This Node is pushed to the "Entity Stack" whenever the parser parses entity replacement text.
+The "Instance" field holds the Instance pointer of an External Entity buffer. When it is
+popped, the Instance is freed.
+The "Encoding" field holds the name of the Encoding. External Parsed Entities may have
+another encoding as the document entity (XmlSpec 4.3.3). So when there is an "<?xml" PI
+found in the stream (= Text Declaration at the beginning of external parsed entities), the
+Encoding found there is used for the External Entity (is assigned to TXmlParser.CurEncoding)
+Default Encoding is for the Document Entity is UTF-8. It is assumed that External Entities
+have the same Encoding as the Document Entity, unless they carry a Text Declaration.
+===============================================================================================
+*)
+
+TYPE
+ TEntityStackNode = CLASS
+ Instance : TObject;
+ Encoding : STRING;
+ LastPos : PChar;
+ END;
+
+(*
+===============================================================================================
+TEntityStack
+For nesting of Entities.
+When there is an entity reference found in the data stream, the corresponding entity
+definition is searched and the current position is pushed to this stack.
+From then on, the program scans the entitiy replacement text as if it were normal content.
+When the parser reaches the end of an entity, the current position is popped off the
+stack again.
+===============================================================================================
+*)
+
+CONSTRUCTOR TEntityStack.Create (TheOwner : TXmlParser);
+BEGIN
+ INHERITED Create;
+ Owner := TheOwner;
+END;
+
+
+PROCEDURE TEntityStack.Push (LastPos : PChar);
+BEGIN
+ Push (NIL, LastPos);
+END;
+
+
+PROCEDURE TEntityStack.Push (Instance : TObject; LastPos : PChar);
+VAR
+ ESN : TEntityStackNode;
+BEGIN
+ ESN := TEntityStackNode.Create;
+ ESN.Instance := Instance;
+ ESN.Encoding := Owner.FCurEncoding; // Save current Encoding
+ ESN.LastPos := LastPos;
+ Add (ESN);
+END;
+
+
+FUNCTION TEntityStack.Pop : PChar;
+VAR
+ ESN : TEntityStackNode;
+BEGIN
+ IF Count > 0 THEN BEGIN
+ ESN := TEntityStackNode (Items [Count-1]);
+ Result := ESN.LastPos;
+ IF ESN.Instance <> NIL THEN
+ ESN.Instance.Free;
+ IF ESN.Encoding <> '' THEN
+ Owner.FCurEncoding := ESN.Encoding; // Restore current Encoding
+ Delete (Count-1);
+ END
+ ELSE
+ Result := NIL;
+END;
+
+
+(*
+===============================================================================================
+TExternalID
+-----------
+XmlSpec 4.2.2: ExternalID ::= 'SYSTEM' S SystemLiteral |
+ 'PUBLIC' S PubidLiteral S SystemLiteral
+XmlSpec 4.7: PublicID ::= 'PUBLIC' S PubidLiteral
+SystemLiteral and PubidLiteral are quoted
+===============================================================================================
+*)
+
+TYPE
+ TExternalID = CLASS
+ PublicId : STRING;
+ SystemId : STRING;
+ Final : PChar;
+ CONSTRUCTOR Create (Start : PChar);
+ END;
+
+CONSTRUCTOR TExternalID.Create (Start : PChar);
+BEGIN
+ INHERITED Create;
+ Final := Start;
+ IF StrLComp (Start, 'SYSTEM', 6) = 0 THEN BEGIN
+ WHILE NOT (Final^ IN (CQuoteChar + [#0, '>', '['])) DO INC (Final);
+ IF NOT (Final^ IN CQuoteChar) THEN EXIT;
+ ExtractQuote (Final, SystemID, Final);
+ END
+ ELSE IF StrLComp (Start, 'PUBLIC', 6) = 0 THEN BEGIN
+ WHILE NOT (Final^ IN (CQuoteChar + [#0, '>', '['])) DO INC (Final);
+ IF NOT (Final^ IN CQuoteChar) THEN EXIT;
+ ExtractQuote (Final, PublicID, Final);
+ INC (Final);
+ WHILE NOT (Final^ IN (CQuoteChar + [#0, '>', '['])) DO INC (Final);
+ IF NOT (Final^ IN CQuoteChar) THEN EXIT;
+ ExtractQuote (Final, SystemID, Final);
+ END;
+END;
+
+
+(*
+===============================================================================================
+TXmlParser
+===============================================================================================
+*)
+
+CONSTRUCTOR TXmlParser.Create;
+BEGIN
+ INHERITED Create;
+ FBuffer := NIL;
+ FBufferSize := 0;
+ Elements := TElemList.Create;
+ Entities := TNvpList.Create;
+ ParEntities := TNvpList.Create;
+ Notations := TNvpList.Create;
+ CurAttr := TAttrList.Create;
+ EntityStack := TEntityStack.Create (Self);
+ Clear;
+END;
+
+
+DESTRUCTOR TXmlParser.Destroy;
+BEGIN
+ Clear;
+ Elements.Free;
+ Entities.Free;
+ ParEntities.Free;
+ Notations.Free;
+ CurAttr.Free;
+ EntityStack.Free;
+ INHERITED Destroy;
+END;
+
+
+PROCEDURE TXmlParser.Clear;
+ // Free Buffer and clear all object attributes
+BEGIN
+ IF (FBufferSize > 0) AND (FBuffer <> NIL) THEN
+ FreeMem (FBuffer);
+ FBuffer := NIL;
+ FBufferSize := 0;
+ FSource := '';
+ FXmlVersion := '';
+ FEncoding := '';
+ FStandalone := FALSE;
+ FRootName := '';
+ FDtdcFinal := NIL;
+ FNormalize := TRUE;
+ Elements.Clear;
+ Entities.Clear;
+ ParEntities.Clear;
+ Notations.Clear;
+ CurAttr.Clear;
+ EntityStack.Clear;
+END;
+
+
+FUNCTION TXmlParser.LoadFromFile (Filename : STRING; FileMode : INTEGER = fmOpenRead OR fmShareDenyNone) : BOOLEAN;
+ // Loads Document from given file
+ // Returns TRUE if successful
+VAR
+ f : FILE;
+ ReadIn : INTEGER;
+ OldFileMode : INTEGER;
+BEGIN
+ Result := FALSE;
+ Clear;
+
+ // --- Open File
+ OldFileMode := SYSTEM.FileMode;
+ TRY
+ SYSTEM.FileMode := FileMode;
+ TRY
+ AssignFile (f, Filename);
+ Reset (f, 1);
+ EXCEPT
+ EXIT;
+ END;
+
+ TRY
+ // --- Allocate Memory
+ TRY
+ FBufferSize := Filesize (f) + 1;
+ GetMem (FBuffer, FBufferSize);
+ EXCEPT
+ Clear;
+ EXIT;
+ END;
+
+ // --- Read File
+ TRY
+ BlockRead (f, FBuffer^, FBufferSize, ReadIn);
+ (FBuffer+ReadIn)^ := #0; // NULL termination
+ EXCEPT
+ Clear;
+ EXIT;
+ END;
+ FINALLY
+ CloseFile (f);
+ END;
+
+ FSource := Filename;
+ Result := TRUE;
+
+ FINALLY
+ SYSTEM.FileMode := OldFileMode;
+ END;
+END;
+
+
+FUNCTION TXmlParser.LoadFromBuffer (Buffer : PChar) : BOOLEAN;
+ // Loads Document from another buffer
+ // Returns TRUE if successful
+ // The "Source" property becomes '<MEM>' if successful
+BEGIN
+ Result := FALSE;
+ Clear;
+ FBufferSize := StrLen (Buffer) + 1;
+ TRY
+ GetMem (FBuffer, FBufferSize);
+ EXCEPT
+ Clear;
+ EXIT;
+ END;
+ StrCopy (FBuffer, Buffer);
+ FSource := '<MEM>';
+ Result := TRUE;
+END;
+
+
+PROCEDURE TXmlParser.SetBuffer (Buffer : PChar); // References another buffer
+BEGIN
+ Clear;
+ FBuffer := Buffer;
+ FBufferSize := 0;
+ FSource := '<REFERENCE>';
+END;
+
+
+//-----------------------------------------------------------------------------------------------
+// Scanning through the document
+//-----------------------------------------------------------------------------------------------
+
+PROCEDURE TXmlParser.StartScan;
+BEGIN
+ CurPartType := ptNone;
+ CurName := '';
+ CurContent := '';
+ CurStart := NIL;
+ CurFinal := NIL;
+ CurAttr.Clear;
+ EntityStack.Clear;
+END;
+
+
+FUNCTION TXmlParser.Scan : BOOLEAN;
+ // Scans the next Part
+ // Returns TRUE if a part could be found, FALSE if there is no part any more
+ //
+ // "IsDone" can be set to FALSE by AnalyzeText in order to go to the next part
+ // if there is no Content due to normalization
+VAR
+ IsDone : BOOLEAN;
+BEGIN
+ REPEAT
+ IsDone := TRUE;
+
+ // --- Start of next Part
+ IF CurStart = NIL
+ THEN CurStart := DocBuffer
+ ELSE CurStart := CurFinal+1;
+ CurFinal := CurStart;
+
+ // --- End of Document of Pop off a new part from the Entity stack?
+ IF CurStart^ = #0 THEN
+ CurStart := EntityStack.Pop;
+
+ // --- No Document or End Of Document: Terminate Scan
+ IF (CurStart = NIL) OR (CurStart^ = #0) THEN BEGIN
+ CurStart := StrEnd (DocBuffer);
+ CurFinal := CurStart-1;
+ EntityStack.Clear;
+ Result := FALSE;
+ EXIT;
+ END;
+
+ IF (StrLComp (CurStart, '<?xml', 5) = 0) AND
+ ((CurStart+5)^ IN CWhitespace) THEN AnalyzeProlog // XML Declaration, Text Declaration
+ ELSE IF StrLComp (CurStart, '<?', 2) = 0 THEN AnalyzePI (CurStart, CurFinal) // PI
+ ELSE IF StrLComp (CurStart, '<!--', 4) = 0 THEN AnalyzeComment (CurStart, CurFinal) // Comment
+ ELSE IF StrLComp (CurStart, '<!DOCTYPE', 9) = 0 THEN AnalyzeDtdc // DTDc
+ ELSE IF StrLComp (CurStart, CDStart, Length (CDStart)) = 0 THEN AnalyzeCdata // CDATA Section
+ ELSE IF StrLComp (CurStart, '<', 1) = 0 THEN AnalyzeTag // Start-Tag, End-Tag, Empty-Element-Tag
+ ELSE AnalyzeText (IsDone); // Text Content
+ UNTIL IsDone;
+ Result := TRUE;
+END;
+
+
+PROCEDURE TXmlParser.AnalyzeProlog;
+ // Analyze XML Prolog or Text Declaration
+VAR
+ F : PChar;
+BEGIN
+ CurAttr.Analyze (CurStart+5, F);
+ IF EntityStack.Count = 0 THEN BEGIN
+ FXmlVersion := CurAttr.Value ('version');
+ FEncoding := CurAttr.Value ('encoding');
+ FStandalone := CurAttr.Value ('standalone') = 'yes';
+ END;
+ CurFinal := StrPos (F, '?>');
+ IF CurFinal <> NIL
+ THEN INC (CurFinal)
+ ELSE CurFinal := StrEnd (CurStart)-1;
+ FCurEncoding := AnsiUpperCase (CurAttr.Value ('encoding'));
+ IF FCurEncoding = '' THEN
+ FCurEncoding := 'UTF-8'; // Default XML Encoding is UTF-8
+ CurPartType := ptXmlProlog;
+ CurName := '';
+ CurContent := '';
+END;
+
+
+PROCEDURE TXmlParser.AnalyzeComment (Start : PChar; VAR Final : PChar);
+ // Analyze Comments
+BEGIN
+ Final := StrPos (Start+4, '-->');
+ IF Final = NIL
+ THEN Final := StrEnd (Start)-1
+ ELSE INC (Final, 2);
+ CurPartType := ptComment;
+END;
+
+
+PROCEDURE TXmlParser.AnalyzePI (Start : PChar; VAR Final : PChar);
+ // Analyze Processing Instructions (PI)
+ // This is also called for Character
+VAR
+ F : PChar;
+BEGIN
+ CurPartType := ptPI;
+ Final := StrPos (Start+2, '?>');
+ IF Final = NIL
+ THEN Final := StrEnd (Start)-1
+ ELSE INC (Final);
+ ExtractName (Start+2, CWhitespace + ['?', '>'], F);
+ SetStringSF (CurName, Start+2, F);
+ SetStringSF (CurContent, F+1, Final-2);
+ CurAttr.Analyze (F+1, F);
+END;
+
+
+PROCEDURE TXmlParser.AnalyzeDtdc;
+ (* Analyze Document Type Declaration
+ doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
+ markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment
+ PEReference ::= '%' Name ';'
+
+ elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>'
+ AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>'
+ EntityDecl ::= '<!ENTITY' S Name S EntityDef S? '>' |
+ '<!ENTITY' S '%' S Name S PEDef S? '>'
+ NotationDecl ::= '<!NOTATION' S Name S (ExternalID | PublicID) S? '>'
+ PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char* )))? '?>'
+ Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->' *)
+TYPE
+ TPhase = (phName, phDtd, phInternal, phFinishing);
+VAR
+ Phase : TPhase;
+ F : PChar;
+ ExternalID : TExternalID;
+ ExternalDTD : TXmlParser;
+ DER : TDtdElementRec;
+BEGIN
+ DER.Start := CurStart;
+ EntityStack.Clear; // Clear stack for Parameter Entities
+ CurPartType := ptDtdc;
+
+ // --- Don't read DTDc twice
+ IF FDtdcFinal <> NIL THEN BEGIN
+ CurFinal := FDtdcFinal;
+ EXIT;
+ END;
+
+ // --- Scan DTDc
+ CurFinal := CurStart + 9; // First char after '<!DOCTYPE'
+ Phase := phName;
+ REPEAT
+ CASE CurFinal^ OF
+ '%' : BEGIN
+ PushPE (CurFinal);
+ CONTINUE;
+ END;
+ #0 : IF EntityStack.Count = 0 THEN
+ BREAK
+ ELSE BEGIN
+ CurFinal := EntityStack.Pop;
+ CONTINUE;
+ END;
+ '[' : BEGIN
+ Phase := phInternal;
+ AnalyzeDtdElements (CurFinal+1, CurFinal);
+ CONTINUE;
+ END;
+ ']' : Phase := phFinishing;
+ '>' : BREAK;
+ ELSE IF NOT (CurFinal^ IN CWhitespace) THEN BEGIN
+ CASE Phase OF
+ phName : IF (CurFinal^ IN CNameStart) THEN BEGIN
+ ExtractName (CurFinal, CWhitespace + ['[', '>'], F);
+ SetStringSF (FRootName, CurFinal, F);
+ CurFinal := F;
+ Phase := phDtd;
+ END;
+ phDtd : IF (StrLComp (CurFinal, 'SYSTEM', 6) = 0) OR
+ (StrLComp (CurFinal, 'PUBLIC', 6) = 0) THEN BEGIN
+ ExternalID := TExternalID.Create (CurFinal);
+ ExternalDTD := LoadExternalEntity (ExternalId.SystemId, ExternalID.PublicId, '');
+ F := StrPos (ExternalDtd.DocBuffer, '<!');
+ IF F <> NIL THEN
+ AnalyzeDtdElements (F, F);
+ ExternalDTD.Free;
+ CurFinal := ExternalID.Final;
+ ExternalID.Free;
+ END;
+ ELSE BEGIN
+ DER.ElementType := deError;
+ DER.Pos := CurFinal;
+ DER.Final := CurFinal;
+ DtdElementFound (DER);
+ END;
+ END;
+
+ END;
+ END;
+ INC (CurFinal);
+ UNTIL FALSE;
+
+ CurPartType := ptDtdc;
+ CurName := '';
+ CurContent := '';
+
+ // It is an error in the document if "EntityStack" is not empty now
+ IF EntityStack.Count > 0 THEN BEGIN
+ DER.ElementType := deError;
+ DER.Final := CurFinal;
+ DER.Pos := CurFinal;
+ DtdElementFound (DER);
+ END;
+
+ EntityStack.Clear; // Clear stack for General Entities
+ FDtdcFinal := CurFinal;
+END;
+
+
+PROCEDURE TXmlParser.AnalyzeDtdElements (Start : PChar; VAR Final : PChar);
+ // Analyze the "Elements" of a DTD contained in the external or
+ // internal DTD subset.
+VAR
+ DER : TDtdElementRec;
+BEGIN
+ Final := Start;
+ REPEAT
+ CASE Final^ OF
+ '%' : BEGIN
+ PushPE (Final);
+ CONTINUE;
+ END;
+ #0 : IF EntityStack.Count = 0 THEN
+ BREAK
+ ELSE BEGIN
+ CurFinal := EntityStack.Pop;
+ CONTINUE;
+ END;
+ ']',
+ '>' : BREAK;
+ '<' : IF StrLComp (Final, '<!ELEMENT', 9) = 0 THEN AnalyzeElementDecl (Final, Final)
+ ELSE IF StrLComp (Final, '<!ATTLIST', 9) = 0 THEN AnalyzeAttListDecl (Final, Final)
+ ELSE IF StrLComp (Final, '<!ENTITY', 8) = 0 THEN AnalyzeEntityDecl (Final, Final)
+ ELSE IF StrLComp (Final, '<!NOTATION', 10) = 0 THEN AnalyzeNotationDecl (Final, Final)
+ ELSE IF StrLComp (Final, '<?', 2) = 0 THEN BEGIN // PI in DTD
+ DER.ElementType := dePI;
+ DER.Start := Final;
+ AnalyzePI (Final, Final);
+ DER.Target := PChar (CurName);
+ DER.Content := PChar (CurContent);
+ DER.AttrList := CurAttr;
+ DER.Final := Final;
+ DtdElementFound (DER);
+ END
+ ELSE IF StrLComp (Final, '<!--', 4) = 0 THEN BEGIN // Comment in DTD
+ DER.ElementType := deComment;
+ DER.Start := Final;
+ AnalyzeComment (Final, Final);
+ DER.Final := Final;
+ DtdElementFound (DER);
+ END
+ ELSE BEGIN
+ DER.ElementType := deError;
+ DER.Start := Final;
+ DER.Pos := Final;
+ DER.Final := Final;
+ DtdElementFound (DER);
+ END;
+
+ END;
+ INC (Final);
+ UNTIL FALSE;
+END;
+
+
+PROCEDURE TXmlParser.AnalyzeTag;
+ // Analyze Tags
+VAR
+ S, F : PChar;
+ Attr : TAttr;
+ ElemDef : TElemDef;
+ AttrDef : TAttrDef;
+ I : INTEGER;
+BEGIN
+ CurPartType := ptStartTag;
+ S := CurStart+1;
+ IF S^ = '/' THEN BEGIN
+ CurPartType := ptEndTag;
+ INC (S);
+ END;
+ ExtractName (S, CWhitespace + ['/'], F);
+ SetStringSF (CurName, S, F);
+ CurAttr.Analyze (F+1, CurFinal);
+ IF CurFinal^ = '/' THEN BEGIN
+ CurPartType := ptEmptyTag;
+ END;
+ CurFinal := StrScanE (CurFinal, '>');
+
+ // --- Set Default Attribute values for nonexistent attributes
+ IF (CurPartType = ptStartTag) OR (CurPartType = ptEmptyTag) THEN BEGIN
+ ElemDef := Elements.Node (CurName);
+ IF ElemDef <> NIL THEN BEGIN
+ FOR I := 0 TO ElemDef.Count-1 DO BEGIN
+ AttrDef := TAttrDef (ElemDef [I]);
+ Attr := TAttr (CurAttr.Node (AttrDef.Name));
+ IF (Attr = NIL) AND (AttrDef.Value <> '') THEN BEGIN
+ Attr := TAttr.Create (AttrDef.Name, AttrDef.Value);
+ Attr.ValueType := vtDefault;
+ CurAttr.Add (Attr);
+ END;
+ IF Attr <> NIL THEN BEGIN
+ CASE AttrDef.DefaultType OF
+ adDefault : ;
+ adRequired : ; // -!- It is an error in the document if "Attr.Value" is an empty string
+ adImplied : Attr.ValueType := vtImplied;
+ adFixed : BEGIN
+ Attr.ValueType := vtFixed;
+ Attr.Value := AttrDef.Value;
+ END;
+ END;
+ Attr.AttrType := AttrDef.AttrType;
+ END;
+ END;
+ END;
+
+ // --- Normalize Attribute Values. XmlSpec:
+ // - a character reference is processed by appending the referenced character to the attribute value
+ // - an entity reference is processed by recursively processing the replacement text of the entity
+ // - a whitespace character (#x20, #xD, #xA, #x9) is processed by appending #x20 to the normalized value,
+ // except that only a single #x20 is appended for a "#xD#xA" sequence that is part of an external
+ // parsed entity or the literal entity value of an internal parsed entity
+ // - other characters are processed by appending them to the normalized value
+ // If the declared value is not CDATA, then the XML processor must further process the
+ // normalized attribute value by discarding any leading and trailing space (#x20) characters,
+ // and by replacing sequences of space (#x20) characters by a single space (#x20) character.
+ // All attributes for which no declaration has been read should be treated by a
+ // non-validating parser as if declared CDATA.
+ // !!! The XML 1.0 SE specification is somewhat different here
+ // This code does not conform exactly to this specification
+ FOR I := 0 TO CurAttr.Count-1 DO
+ WITH TAttr (CurAttr [I]) DO BEGIN
+ ReplaceGeneralEntities (Value);
+ ReplaceCharacterEntities (Value);
+ IF (AttrType <> atCData) AND (AttrType <> atUnknown)
+ THEN Value := TranslateEncoding (TrimWs (ConvertWs (Value, TRUE)))
+ ELSE Value := TranslateEncoding (ConvertWs (Value, FALSE));
+ END;
+ END;
+END;
+
+
+PROCEDURE TXmlParser.AnalyzeCData;
+ // Analyze CDATA Sections
+BEGIN
+ CurPartType := ptCData;
+ CurFinal := StrPos (CurStart, CDEnd);
+ IF CurFinal = NIL THEN BEGIN
+ CurFinal := StrEnd (CurStart)-1;
+ CurContent := TranslateEncoding (StrPas (CurStart+Length (CDStart)));
+ END
+ ELSE BEGIN
+ SetStringSF (CurContent, CurStart+Length (CDStart), CurFinal-1);
+ INC (CurFinal, Length (CDEnd)-1);
+ CurContent := TranslateEncoding (CurContent);
+ END;
+END;
+
+
+PROCEDURE TXmlParser.AnalyzeText (VAR IsDone : BOOLEAN);
+ (* Analyzes Text Content between Tags. CurFinal will point to the last content character.
+ Content ends at a '<' character or at the end of the document.
+ Entity References and Character Entity references are resolved.
+ If PackSpaces is TRUE, contiguous Whitespace Characters will be compressed to
+ one Space #x20 character, Whitespace at the beginning and end of content will
+ be trimmed off and content which is or becomes empty is not returned to
+ the application (in this case, "IsDone" is set to FALSE which causes the
+ Scan method to proceed directly to the next part. *)
+
+ PROCEDURE ProcessEntity;
+ (* Is called if there is an ampsersand '&' character found in the document.
+ IN "CurFinal" points to the ampersand
+ OUT "CurFinal" points to the first character after the semi-colon ';' *)
+ VAR
+ P : PChar;
+ Name : STRING;
+ EntityDef : TEntityDef;
+ ExternalEntity : TXmlParser;
+ BEGIN
+ P := StrScan (CurFinal , ';');
+ IF P <> NIL THEN BEGIN
+ SetStringSF (Name, CurFinal+1, P-1);
+
+ // Is it a Character Entity?
+ IF (CurFinal+1)^ = '#' THEN BEGIN
+ IF UpCase ((CurFinal+2)^) = 'X' // !!! Can't use "CHR" for Unicode characters > 255:
+ THEN CurContent := CurContent + CHR (StrToIntDef ('$'+Copy (Name, 3, MaxInt), 32))
+ ELSE CurContent := CurContent + CHR (StrToIntDef (Copy (Name, 2, MaxInt), 32));
+ CurFinal := P+1;
+ EXIT;
+ END
+
+ // Is it a Predefined Entity?
+ ELSE IF Name = 'lt' THEN BEGIN CurContent := CurContent + '<'; CurFinal := P+1; EXIT; END
+ ELSE IF Name = 'gt' THEN BEGIN CurContent := CurContent + '>'; CurFinal := P+1; EXIT; END
+ ELSE IF Name = 'amp' THEN BEGIN CurContent := CurContent + '&'; CurFinal := P+1; EXIT; END
+ ELSE IF Name = 'apos' THEN BEGIN CurContent := CurContent + ''''; CurFinal := P+1; EXIT; END
+ ELSE IF Name = 'quot' THEN BEGIN CurContent := CurContent + '"'; CurFinal := P+1; EXIT; END;
+
+ // Replace with Entity from DTD
+ EntityDef := TEntityDef (Entities.Node (Name));
+ IF EntityDef <> NIL THEN BEGIN
+ IF EntityDef.Value <> '' THEN BEGIN
+ EntityStack.Push (P+1);
+ CurFinal := PChar (EntityDef.Value);
+ END
+ ELSE BEGIN
+ ExternalEntity := LoadExternalEntity (EntityDef.SystemId, EntityDef.PublicId, EntityDef.NotationName);
+ EntityStack.Push (ExternalEntity, P+1);
+ CurFinal := ExternalEntity.DocBuffer;
+ END;
+ END
+ ELSE BEGIN
+ CurContent := CurContent + Name;
+ CurFinal := P+1;
+ END;
+ END
+ ELSE BEGIN
+ INC (CurFinal);
+ END;
+ END;
+
+VAR
+ C : INTEGER;
+BEGIN
+ CurFinal := CurStart;
+ CurPartType := ptContent;
+ CurContent := '';
+ C := 0;
+ REPEAT
+ CASE CurFinal^ OF
+ '&' : BEGIN
+ CurContent := CurContent + TranslateEncoding (StrLPas (CurFinal-C, C));
+ C := 0;
+ ProcessEntity;
+ CONTINUE;
+ END;
+ #0 : BEGIN
+ IF EntityStack.Count = 0 THEN
+ BREAK
+ ELSE BEGIN
+ CurContent := CurContent + TranslateEncoding (StrLPas (CurFinal-C, C));
+ C := 0;
+ CurFinal := EntityStack.Pop;
+ CONTINUE;
+ END;
+ END;
+ '<' : BREAK;
+ ELSE INC (C);
+ END;
+ INC (CurFinal);
+ UNTIL FALSE;
+ CurContent := CurContent + TranslateEncoding (StrLPas (CurFinal-C, C));
+ DEC (CurFinal);
+
+ IF FNormalize THEN BEGIN
+ CurContent := ConvertWs (TrimWs (CurContent), TRUE);
+ IsDone := CurContent <> ''; // IsDone will only get FALSE if PackSpaces is TRUE
+ END;
+END;
+
+
+PROCEDURE TXmlParser.AnalyzeElementDecl (Start : PChar; VAR Final : PChar);
+ (* Parse <!ELEMENT declaration starting at "Start"
+ Final must point to the terminating '>' character
+ XmlSpec 3.2:
+ elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>'
+ contentspec ::= 'EMPTY' | 'ANY' | Mixed | children
+ Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' |
+ '(' S? '#PCDATA' S? ')'
+ children ::= (choice | seq) ('?' | '*' | '+')?
+ choice ::= '(' S? cp ( S? '|' S? cp )* S? ')'
+ cp ::= (Name | choice | seq) ('?' | '*' | '+')?
+ seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'
+
+ More simply:
+ contentspec ::= EMPTY
+ ANY
+ '(#PCDATA)'
+ '(#PCDATA | A | B)*'
+ '(A, B, C)'
+ '(A | B | C)'
+ '(A?, B*, C+),
+ '(A, (B | C | D)* )' *)
+VAR
+ Element : TElemDef;
+ Elem2 : TElemDef;
+ F : PChar;
+ DER : TDtdElementRec;
+BEGIN
+ Element := TElemDef.Create;
+ Final := Start + 9;
+ DER.Start := Start;
+ REPEAT
+ IF Final^ = '>' THEN BREAK;
+ IF (Final^ IN CNameStart) AND (Element.Name = '') THEN BEGIN
+ ExtractName (Final, CWhitespace, F);
+ SetStringSF (Element.Name, Final, F);
+ Final := F;
+ F := StrScan (Final+1, '>');
+ IF F = NIL THEN BEGIN
+ Element.Definition := STRING (Final);
+ Final := StrEnd (Final);
+ BREAK;
+ END
+ ELSE BEGIN
+ SetStringSF (Element.Definition, Final+1, F-1);
+ Final := F;
+ BREAK;
+ END;
+ END;
+ INC (Final);
+ UNTIL FALSE;
+ Element.Definition := DelChars (Element.Definition, CWhitespace);
+ ReplaceParameterEntities (Element.Definition);
+ IF Element.Definition = 'EMPTY' THEN Element.ElemType := etEmpty
+ ELSE IF Element.Definition = 'ANY' THEN Element.ElemType := etAny
+ ELSE IF Copy (Element.Definition, 1, 8) = '(#PCDATA' THEN Element.ElemType := etMixed
+ ELSE IF Copy (Element.Definition, 1, 1) = '(' THEN Element.ElemType := etChildren
+ ELSE Element.ElemType := etAny;
+
+ Elem2 := Elements.Node (Element.Name);
+ IF Elem2 <> NIL THEN
+ Elements.Delete (Elements.IndexOf (Elem2));
+ Elements.Add (Element);
+ Final := StrScanE (Final, '>');
+ DER.ElementType := deElement;
+ DER.ElemDef := Element;
+ DER.Final := Final;
+ DtdElementFound (DER);
+END;
+
+
+PROCEDURE TXmlParser.AnalyzeAttListDecl (Start : PChar; VAR Final : PChar);
+ (* Parse <!ATTLIST declaration starting at "Start"
+ Final must point to the terminating '>' character
+ XmlSpec 3.3:
+ AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>'
+ AttDef ::= S Name S AttType S DefaultDecl
+ AttType ::= StringType | TokenizedType | EnumeratedType
+ StringType ::= 'CDATA'
+ TokenizedType ::= 'ID' | 'IDREF' | 'IDREFS' | 'ENTITY' | 'ENTITIES' | 'NMTOKEN' | 'NMTOKENS'
+ EnumeratedType ::= NotationType | Enumeration
+ NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'
+ Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'
+ DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)
+ AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'"
+ Examples:
+ <!ATTLIST address
+ A1 CDATA "Default"
+ A2 ID #REQUIRED
+ A3 IDREF #IMPLIED
+ A4 IDREFS #IMPLIED
+ A5 ENTITY #FIXED "&at;ü"
+ A6 ENTITIES #REQUIRED
+ A7 NOTATION (WMF | DXF) "WMF"
+ A8 (A | B | C) #REQUIRED> *)
+TYPE
+ TPhase = (phElementName, phName, phType, phNotationContent, phDefault);
+VAR
+ Phase : TPhase;
+ F : PChar;
+ ElementName : STRING;
+ ElemDef : TElemDef;
+ AttrDef : TAttrDef;
+ AttrDef2 : TAttrDef;
+ Strg : STRING;
+ DER : TDtdElementRec;
+BEGIN
+ Final := Start + 9; // The character after <!ATTLIST
+ Phase := phElementName;
+ DER.Start := Start;
+ AttrDef := NIL;
+ ElemDef := NIL;
+ REPEAT
+ IF NOT (Final^ IN CWhitespace) THEN
+ CASE Final^ OF
+ '%' : BEGIN
+ PushPE (Final);
+ CONTINUE;
+ END;
+ #0 : IF EntityStack.Count = 0 THEN
+ BREAK
+ ELSE BEGIN
+ Final := EntityStack.Pop;
+ CONTINUE;
+ END;
+ '>' : BREAK;
+ ELSE CASE Phase OF
+ phElementName : BEGIN
+ ExtractName (Final, CWhitespace + CQuoteChar + ['#'], F);
+ SetStringSF (ElementName, Final, F);
+ Final := F;
+ ElemDef := Elements.Node (ElementName);
+ IF ElemDef = NIL THEN BEGIN
+ ElemDef := TElemDef.Create;
+ ElemDef.Name := ElementName;
+ ElemDef.Definition := 'ANY';
+ ElemDef.ElemType := etAny;
+ Elements.Add (ElemDef);
+ END;
+ Phase := phName;
+ END;
+ phName : BEGIN
+ AttrDef := TAttrDef.Create;
+ ExtractName (Final, CWhitespace + CQuoteChar + ['#'], F);
+ SetStringSF (AttrDef.Name, Final, F);
+ Final := F;
+ AttrDef2 := TAttrDef (ElemDef.Node (AttrDef.Name));
+ IF AttrDef2 <> NIL THEN
+ ElemDef.Delete (ElemDef.IndexOf (AttrDef2));
+ ElemDef.Add (AttrDef);
+ Phase := phType;
+ END;
+ phType : BEGIN
+ IF Final^ = '(' THEN BEGIN
+ F := StrScan (Final+1, ')');
+ IF F <> NIL
+ THEN SetStringSF (AttrDef.TypeDef, Final+1, F-1)
+ ELSE AttrDef.TypeDef := STRING (Final+1);
+ AttrDef.TypeDef := DelChars (AttrDef.TypeDef, CWhitespace);
+ AttrDef.AttrType := atEnumeration;
+ ReplaceParameterEntities (AttrDef.TypeDef);
+ ReplaceCharacterEntities (AttrDef.TypeDef);
+ Phase := phDefault;
+ END
+ ELSE IF StrLComp (Final, 'NOTATION', 8) = 0 THEN BEGIN
+ INC (Final, 8);
+ AttrDef.AttrType := atNotation;
+ Phase := phNotationContent;
+ END
+ ELSE BEGIN
+ ExtractName (Final, CWhitespace+CQuoteChar+['#'], F);
+ SetStringSF (AttrDef.TypeDef, Final, F);
+ IF AttrDef.TypeDef = 'CDATA' THEN AttrDef.AttrType := atCData
+ ELSE IF AttrDef.TypeDef = 'ID' THEN AttrDef.AttrType := atId
+ ELSE IF AttrDef.TypeDef = 'IDREF' THEN AttrDef.AttrType := atIdRef
+ ELSE IF AttrDef.TypeDef = 'IDREFS' THEN AttrDef.AttrType := atIdRefs
+ ELSE IF AttrDef.TypeDef = 'ENTITY' THEN AttrDef.AttrType := atEntity
+ ELSE IF AttrDef.TypeDef = 'ENTITIES' THEN AttrDef.AttrType := atEntities
+ ELSE IF AttrDef.TypeDef = 'NMTOKEN' THEN AttrDef.AttrType := atNmToken
+ ELSE IF AttrDef.TypeDef = 'NMTOKENS' THEN AttrDef.AttrType := atNmTokens;
+ Phase := phDefault;
+ END
+ END;
+ phNotationContent : BEGIN
+ F := StrScan (Final, ')');
+ IF F <> NIL THEN
+ SetStringSF (AttrDef.Notations, Final+1, F-1)
+ ELSE BEGIN
+ AttrDef.Notations := STRING (Final+1);
+ Final := StrEnd (Final);
+ END;
+ ReplaceParameterEntities (AttrDef.Notations);
+ AttrDef.Notations := DelChars (AttrDef.Notations, CWhitespace);
+ Phase := phDefault;
+ END;
+ phDefault : BEGIN
+ IF Final^ = '#' THEN BEGIN
+ ExtractName (Final, CWhiteSpace + CQuoteChar, F);
+ SetStringSF (Strg, Final, F);
+ Final := F;
+ ReplaceParameterEntities (Strg);
+ IF Strg = '#REQUIRED' THEN BEGIN AttrDef.DefaultType := adRequired; Phase := phName; END
+ ELSE IF Strg = '#IMPLIED' THEN BEGIN AttrDef.DefaultType := adImplied; Phase := phName; END
+ ELSE IF Strg = '#FIXED' THEN AttrDef.DefaultType := adFixed;
+ END
+ ELSE IF (Final^ IN CQuoteChar) THEN BEGIN
+ ExtractQuote (Final, AttrDef.Value, Final);
+ ReplaceParameterEntities (AttrDef.Value);
+ ReplaceCharacterEntities (AttrDef.Value);
+ Phase := phName;
+ END;
+ IF Phase = phName THEN BEGIN
+ AttrDef := NIL;
+ END;
+ END;
+
+ END;
+ END;
+ INC (Final);
+ UNTIL FALSE;
+
+ Final := StrScan (Final, '>');
+
+ DER.ElementType := deAttList;
+ DER.ElemDef := ElemDef;
+ DER.Final := Final;
+ DtdElementFound (DER);
+END;
+
+
+PROCEDURE TXmlParser.AnalyzeEntityDecl (Start : PChar; VAR Final : PChar);
+ (* Parse <!ENTITY declaration starting at "Start"
+ Final must point to the terminating '>' character
+ XmlSpec 4.2:
+ EntityDecl ::= '<!ENTITY' S Name S EntityDef S? '>' |
+ '<!ENTITY' S '%' S Name S PEDef S? '>'
+ EntityDef ::= EntityValue | (ExternalID NDataDecl?)
+ PEDef ::= EntityValue | ExternalID
+ NDataDecl ::= S 'NDATA' S Name
+ EntityValue ::= '"' ([^%&"] | PEReference | EntityRef | CharRef)* '"' |
+ "'" ([^%&'] | PEReference | EntityRef | CharRef)* "'"
+ PEReference ::= '%' Name ';'
+
+ Examples
+ <!ENTITY test1 "Stefan Heymann"> <!-- Internal, general, parsed -->
+ <!ENTITY test2 SYSTEM "ent2.xml"> <!-- External, general, parsed -->
+ <!ENTITY test2 SYSTEM "ent3.gif" NDATA gif> <!-- External, general, unparsed -->
+ <!ENTITY % test3 "<!ELEMENT q ANY>"> <!-- Internal, parameter -->
+ <!ENTITY % test6 SYSTEM "ent6.xml"> <!-- External, parameter -->
+ <!ENTITY test4 "&test1; ist lieb"> <!-- IGP, Replacement text <> literal value -->
+ <!ENTITY test5 "<p>Dies ist ein Test-Absatz</p>"> <!-- IGP, See XmlSpec 2.4 -->
+ *)
+TYPE
+ TPhase = (phName, phContent, phNData, phNotationName, phFinalGT);
+VAR
+ Phase : TPhase;
+ IsParamEntity : BOOLEAN;
+ F : PChar;
+ ExternalID : TExternalID;
+ EntityDef : TEntityDef;
+ EntityDef2 : TEntityDef;
+ DER : TDtdElementRec;
+BEGIN
+ Final := Start + 8; // First char after <!ENTITY
+ DER.Start := Start;
+ Phase := phName;
+ IsParamEntity := FALSE;
+ EntityDef := TEntityDef.Create;
+ REPEAT
+ IF NOT (Final^ IN CWhitespace) THEN
+ CASE Final^ OF
+ '%' : IsParamEntity := TRUE;
+ '>' : BREAK;
+ ELSE CASE Phase OF
+ phName : IF Final^ IN CNameStart THEN BEGIN
+ ExtractName (Final, CWhitespace + CQuoteChar, F);
+ SetStringSF (EntityDef.Name, Final, F);
+ Final := F;
+ Phase := phContent;
+ END;
+ phContent : IF Final^ IN CQuoteChar THEN BEGIN
+ ExtractQuote (Final, EntityDef.Value, Final);
+ Phase := phFinalGT;
+ END
+ ELSE IF (StrLComp (Final, 'SYSTEM', 6) = 0) OR
+ (StrLComp (Final, 'PUBLIC', 6) = 0) THEN BEGIN
+ ExternalID := TExternalID.Create (Final);
+ EntityDef.SystemId := ExternalID.SystemId;
+ EntityDef.PublicId := ExternalID.PublicId;
+ Final := ExternalID.Final;
+ Phase := phNData;
+ ExternalID.Free;
+ END;
+ phNData : IF StrLComp (Final, 'NDATA', 5) = 0 THEN BEGIN
+ INC (Final, 4);
+ Phase := phNotationName;
+ END;
+ phNotationName : IF Final^ IN CNameStart THEN BEGIN
+ ExtractName (Final, CWhitespace + ['>'], F);
+ SetStringSF (EntityDef.NotationName, Final, F);
+ Final := F;
+ Phase := phFinalGT;
+ END;
+ phFinalGT : ; // -!- There is an error in the document if this branch is called
+ END;
+ END;
+ INC (Final);
+ UNTIL FALSE;
+ IF IsParamEntity THEN BEGIN
+ EntityDef2 := TEntityDef (ParEntities.Node (EntityDef.Name));
+ IF EntityDef2 <> NIL THEN
+ ParEntities.Delete (ParEntities.IndexOf (EntityDef2));
+ ParEntities.Add (EntityDef);
+ ReplaceCharacterEntities (EntityDef.Value);
+ END
+ ELSE BEGIN
+ EntityDef2 := TEntityDef (Entities.Node (EntityDef.Name));
+ IF EntityDef2 <> NIL THEN
+ Entities.Delete (Entities.IndexOf (EntityDef2));
+ Entities.Add (EntityDef);
+ ReplaceParameterEntities (EntityDef.Value); // Create replacement texts (see XmlSpec 4.5)
+ ReplaceCharacterEntities (EntityDef.Value);
+ END;
+ Final := StrScanE (Final, '>');
+
+ DER.ElementType := deEntity;
+ DER.EntityDef := EntityDef;
+ DER.Final := Final;
+ DtdElementFound (DER);
+END;
+
+
+PROCEDURE TXmlParser.AnalyzeNotationDecl (Start : PChar; VAR Final : PChar);
+ // Parse <!NOTATION declaration starting at "Start"
+ // Final must point to the terminating '>' character
+ // XmlSpec 4.7: NotationDecl ::= '<!NOTATION' S Name S (ExternalID | PublicID) S? '>'
+TYPE
+ TPhase = (phName, phExtId, phEnd);
+VAR
+ ExternalID : TExternalID;
+ Phase : TPhase;
+ F : PChar;
+ NotationDef : TNotationDef;
+ DER : TDtdElementRec;
+BEGIN
+ Final := Start + 10; // Character after <!NOTATION
+ DER.Start := Start;
+ Phase := phName;
+ NotationDef := TNotationDef.Create;
+ REPEAT
+ IF NOT (Final^ IN CWhitespace) THEN
+ CASE Final^ OF
+ '>',
+ #0 : BREAK;
+ ELSE CASE Phase OF
+ phName : BEGIN
+ ExtractName (Final, CWhitespace + ['>'], F);
+ SetStringSF (NotationDef.Name, Final, F);
+ Final := F;
+ Phase := phExtId;
+ END;
+ phExtId : BEGIN
+ ExternalID := TExternalID.Create (Final);
+ NotationDef.Value := ExternalID.SystemId;
+ NotationDef.PublicId := ExternalID.PublicId;
+ Final := ExternalId.Final;
+ ExternalId.Free;
+ Phase := phEnd;
+ END;
+ phEnd : ; // -!- There is an error in the document if this branch is called
+ END;
+ END;
+ INC (Final);
+ UNTIL FALSE;
+ Notations.Add (NotationDef);
+ Final := StrScanE (Final, '>');
+
+ DER.ElementType := deNotation;
+ DER.NotationDef := NotationDef;
+ DER.Final := Final;
+ DtdElementFound (DER);
+END;
+
+
+PROCEDURE TXmlParser.PushPE (VAR Start : PChar);
+ (* If there is a parameter entity reference found in the data stream,
+ the current position will be pushed to the entity stack.
+ Start: IN Pointer to the '%' character starting the PE reference
+ OUT Pointer to first character of PE replacement text *)
+VAR
+ P : PChar;
+ EntityDef : TEntityDef;
+BEGIN
+ P := StrScan (Start, ';');
+ IF P <> NIL THEN BEGIN
+ EntityDef := TEntityDef (ParEntities.Node (StrSFPas (Start+1, P-1)));
+ IF EntityDef <> NIL THEN BEGIN
+ EntityStack.Push (P+1);
+ Start := PChar (EntityDef.Value);
+ END
+ ELSE
+ Start := P+1;
+ END;
+END;
+
+
+PROCEDURE TXmlParser.ReplaceCharacterEntities (VAR Str : STRING);
+ // Replaces all Character Entity References in the String
+VAR
+ Start : INTEGER;
+ PAmp : PChar;
+ PSemi : PChar;
+ PosAmp : INTEGER;
+ Len : INTEGER; // Length of Entity Reference
+BEGIN
+ IF Str = '' THEN EXIT;
+ Start := 1;
+ REPEAT
+ PAmp := StrPos (PChar (Str) + Start-1, '&#');
+ IF PAmp = NIL THEN BREAK;
+ PSemi := StrScan (PAmp+2, ';');
+ IF PSemi = NIL THEN BREAK;
+ PosAmp := PAmp - PChar (Str) + 1;
+ Len := PSemi-PAmp+1;
+ IF CompareText (Str [PosAmp+2], 'x') = 0 // !!! Can't use "CHR" for Unicode characters > 255
+ THEN Str [PosAmp] := CHR (StrToIntDef ('$'+Copy (Str, PosAmp+3, Len-4), 0))
+ ELSE Str [PosAmp] := CHR (StrToIntDef (Copy (Str, PosAmp+2, Len-3), 32));
+ Delete (Str, PosAmp+1, Len-1);
+ Start := PosAmp + 1;
+ UNTIL FALSE;
+END;
+
+
+PROCEDURE TXmlParser.ReplaceParameterEntities (VAR Str : STRING);
+ // Recursively replaces all Parameter Entity References in the String
+ PROCEDURE ReplaceEntities (VAR Str : STRING);
+ VAR
+ Start : INTEGER;
+ PAmp : PChar;
+ PSemi : PChar;
+ PosAmp : INTEGER;
+ Len : INTEGER;
+ Entity : TEntityDef;
+ Repl : STRING; // Replacement
+ BEGIN
+ IF Str = '' THEN EXIT;
+ Start := 1;
+ REPEAT
+ PAmp := StrPos (PChar (Str)+Start-1, '%');
+ IF PAmp = NIL THEN BREAK;
+ PSemi := StrScan (PAmp+2, ';');
+ IF PSemi = NIL THEN BREAK;
+ PosAmp := PAmp - PChar (Str) + 1;
+ Len := PSemi-PAmp+1;
+ Entity := TEntityDef (ParEntities.Node (Copy (Str, PosAmp+1, Len-2)));
+ IF Entity <> NIL THEN BEGIN
+ Repl := Entity.Value;
+ ReplaceEntities (Repl); // Recursion
+ END
+ ELSE
+ Repl := Copy (Str, PosAmp, Len);
+ Delete (Str, PosAmp, Len);
+ Insert (Repl, Str, PosAmp);
+ Start := PosAmp + Length (Repl);
+ UNTIL FALSE;
+ END;
+BEGIN
+ ReplaceEntities (Str);
+END;
+
+
+PROCEDURE TXmlParser.ReplaceGeneralEntities (VAR Str : STRING);
+ // Recursively replaces General Entity References in the String
+ PROCEDURE ReplaceEntities (VAR Str : STRING);
+ VAR
+ Start : INTEGER;
+ PAmp : PChar;
+ PSemi : PChar;
+ PosAmp : INTEGER;
+ Len : INTEGER;
+ EntityDef : TEntityDef;
+ EntName : STRING;
+ Repl : STRING; // Replacement
+ ExternalEntity : TXmlParser;
+ BEGIN
+ IF Str = '' THEN EXIT;
+ Start := 1;
+ REPEAT
+ PAmp := StrPos (PChar (Str)+Start-1, '&');
+ IF PAmp = NIL THEN BREAK;
+ PSemi := StrScan (PAmp+2, ';');
+ IF PSemi = NIL THEN BREAK;
+ PosAmp := PAmp - PChar (Str) + 1;
+ Len := PSemi-PAmp+1;
+ EntName := Copy (Str, PosAmp+1, Len-2);
+ IF EntName = 'lt' THEN Repl := '<'
+ ELSE IF EntName = 'gt' THEN Repl := '>'
+ ELSE IF EntName = 'amp' THEN Repl := '&'
+ ELSE IF EntName = 'apos' THEN Repl := ''''
+ ELSE IF EntName = 'quot' THEN Repl := '"'
+ ELSE BEGIN
+ EntityDef := TEntityDef (Entities.Node (EntName));
+ IF EntityDef <> NIL THEN BEGIN
+ IF EntityDef.Value <> '' THEN // Internal Entity
+ Repl := EntityDef.Value
+ ELSE BEGIN // External Entity
+ ExternalEntity := LoadExternalEntity (EntityDef.SystemId, EntityDef.PublicId, EntityDef.NotationName);
+ Repl := StrPas (ExternalEntity.DocBuffer); // !!! What if it contains a Text Declaration?
+ ExternalEntity.Free;
+ END;
+ ReplaceEntities (Repl); // Recursion
+ END
+ ELSE
+ Repl := Copy (Str, PosAmp, Len);
+ END;
+ Delete (Str, PosAmp, Len);
+ Insert (Repl, Str, PosAmp);
+ Start := PosAmp + Length (Repl);
+ UNTIL FALSE;
+ END;
+BEGIN
+ ReplaceEntities (Str);
+END;
+
+
+FUNCTION TXmlParser.LoadExternalEntity (SystemId, PublicId, Notation : STRING) : TXmlParser;
+ // This will be called whenever there is a Parsed External Entity or
+ // the DTD External Subset to be parsed.
+ // It has to create a TXmlParser instance and load the desired Entity.
+ // This instance of LoadExternalEntity assumes that "SystemId" is a valid
+ // file name (relative to the Document source) and loads this file using
+ // the LoadFromFile method.
+VAR
+ Filename : STRING;
+BEGIN
+ // --- Convert System ID to complete filename
+ Filename := StringReplace (SystemId, '/', '\', [rfReplaceAll]);
+ IF Copy (FSource, 1, 1) <> '<' THEN
+ IF (Copy (Filename, 1, 2) = '\\') OR (Copy (Filename, 2, 1) = ':') THEN
+ // Already has an absolute Path
+ ELSE BEGIN
+ Filename := ExtractFilePath (FSource) + Filename;
+ END;
+
+ // --- Load the File
+ Result := TXmlParser.Create;
+ Result.LoadFromFile (Filename);
+END;
+
+
+FUNCTION TXmlParser.TranslateEncoding (CONST Source : STRING) : STRING;
+ // The member variable "CurEncoding" always holds the name of the current
+ // encoding, e.g. 'UTF-8' or 'ISO-8859-1'.
+ // This virtual method "TranslateEncoding" is responsible for translating
+ // the content passed in the "Source" parameter to the Encoding which
+ // is expected by the application.
+ // This instance of "TranlateEncoding" assumes that the Application expects
+ // Windows ANSI (Win1252) strings. It is able to transform UTF-8 or ISO-8859-1
+ // encodings.
+ // If you want your application to understand or create other encodings, you
+ // override this function.
+BEGIN
+ IF CurEncoding = 'UTF-8'
+ THEN Result := Utf8ToAnsi (Source)
+ ELSE Result := Source;
+END;
+
+
+PROCEDURE TXmlParser.DtdElementFound (DtdElementRec : TDtdElementRec);
+ // This method is called for every element which is found in the DTD
+ // declaration. The variant record TDtdElementRec is passed which
+ // holds informations about the element.
+ // You can override this function to handle DTD declarations.
+ // Note that when you parse the same Document instance a second time,
+ // the DTD will not get parsed again.
+BEGIN
+END;
+
+
+FUNCTION TXmlParser.GetDocBuffer: PChar;
+ // Returns FBuffer or a pointer to a NUL char if Buffer is empty
+BEGIN
+ IF FBuffer = NIL
+ THEN Result := #0
+ ELSE Result := FBuffer;
+END;
+
+
+(*$IFNDEF HAS_CONTNRS_UNIT
+===============================================================================================
+TObjectList
+===============================================================================================
+*)
+
+DESTRUCTOR TObjectList.Destroy;
+BEGIN
+ Clear;
+ SetCapacity(0);
+ INHERITED Destroy;
+END;
+
+
+PROCEDURE TObjectList.Delete (Index : INTEGER);
+BEGIN
+ IF (Index < 0) OR (Index >= Count) THEN EXIT;
+ TObject (Items [Index]).Free;
+ INHERITED Delete (Index);
+END;
+
+
+PROCEDURE TObjectList.Clear;
+BEGIN
+ WHILE Count > 0 DO
+ Delete (Count-1);
+END;
+
+(*$ENDIF *)
+
+(*
+===============================================================================================
+TNvpNode
+--------
+Node base class for the TNvpList
+===============================================================================================
+*)
+
+CONSTRUCTOR TNvpNode.Create (TheName, TheValue : STRING);
+BEGIN
+ INHERITED Create;
+ Name := TheName;
+ Value := TheValue;
+END;
+
+
+(*
+===============================================================================================
+TNvpList
+--------
+A generic List of Name-Value Pairs, based on the TObjectList introduced in Delphi 5
+===============================================================================================
+*)
+
+PROCEDURE TNvpList.Add (Node : TNvpNode);
+VAR
+ I : INTEGER;
+BEGIN
+ FOR I := Count-1 DOWNTO 0 DO
+ IF Node.Name > TNvpNode (Items [I]).Name THEN BEGIN
+ Insert (I+1, Node);
+ EXIT;
+ END;
+ Insert (0, Node);
+END;
+
+
+
+FUNCTION TNvpList.Node (Name : STRING) : TNvpNode;
+ // Binary search for Node
+VAR
+ L, H : INTEGER; // Low, High Limit
+ T, C : INTEGER; // Test Index, Comparison result
+ Last : INTEGER; // Last Test Index
+BEGIN
+ IF Count=0 THEN BEGIN
+ Result := NIL;
+ EXIT;
+ END;
+
+ L := 0;
+ H := Count;
+ Last := -1;
+ REPEAT
+ T := (L+H) DIV 2;
+ IF T=Last THEN BREAK;
+ Result := TNvpNode (Items [T]);
+ C := CompareStr (Result.Name, Name);
+ IF C = 0 THEN EXIT
+ ELSE IF C < 0 THEN L := T
+ ELSE H := T;
+ Last := T;
+ UNTIL FALSE;
+ Result := NIL;
+END;
+
+
+FUNCTION TNvpList.Node (Index : INTEGER) : TNvpNode;
+BEGIN
+ IF (Index < 0) OR (Index >= Count)
+ THEN Result := NIL
+ ELSE Result := TNvpNode (Items [Index]);
+END;
+
+
+FUNCTION TNvpList.Value (Name : STRING) : STRING;
+VAR
+ Nvp : TNvpNode;
+BEGIN
+ Nvp := TNvpNode (Node (Name));
+ IF Nvp <> NIL
+ THEN Result := Nvp.Value
+ ELSE Result := '';
+END;
+
+
+FUNCTION TNvpList.Value (Index : INTEGER) : STRING;
+BEGIN
+ IF (Index < 0) OR (Index >= Count)
+ THEN Result := ''
+ ELSE Result := TNvpNode (Items [Index]).Value;
+END;
+
+
+FUNCTION TNvpList.Name (Index : INTEGER) : STRING;
+BEGIN
+ IF (Index < 0) OR (Index >= Count)
+ THEN Result := ''
+ ELSE Result := TNvpNode (Items [Index]).Name;
+END;
+
+
+(*
+===============================================================================================
+TAttrList
+List of Attributes. The "Analyze" method extracts the Attributes from the given Buffer.
+Is used for extraction of Attributes in Start-Tags, Empty-Element Tags and the "pseudo"
+attributes in XML Prologs, Text Declarations and PIs.
+===============================================================================================
+*)
+
+PROCEDURE TAttrList.Analyze (Start : PChar; VAR Final : PChar);
+ // Analyze the Buffer for Attribute=Name pairs.
+ // Terminates when there is a character which is not IN CNameStart
+ // (e.g. '?>' or '>' or '/>')
+TYPE
+ TPhase = (phName, phEq, phValue);
+VAR
+ Phase : TPhase;
+ F : PChar;
+ Name : STRING;
+ Value : STRING;
+ Attr : TAttr;
+BEGIN
+ Clear;
+ Phase := phName;
+ Final := Start;
+ REPEAT
+ IF (Final^ = #0) OR (Final^ = '>') THEN BREAK;
+ IF NOT (Final^ IN CWhitespace) THEN
+ CASE Phase OF
+ phName : BEGIN
+ IF NOT (Final^ IN CNameStart) THEN EXIT;
+ ExtractName (Final, CWhitespace + ['=', '/'], F);
+ SetStringSF (Name, Final, F);
+ Final := F;
+ Phase := phEq;
+ END;
+ phEq : BEGIN
+ IF Final^ = '=' THEN
+ Phase := phValue
+ END;
+ phValue : BEGIN
+ IF Final^ IN CQuoteChar THEN BEGIN
+ ExtractQuote (Final, Value, F);
+ Attr := TAttr.Create;
+ Attr.Name := Name;
+ Attr.Value := Value;
+ Attr.ValueType := vtNormal;
+ Add (Attr);
+ Final := F;
+ Phase := phName;
+ END;
+ END;
+ END;
+ INC (Final);
+ UNTIL FALSE;
+END;
+
+
+(*
+===============================================================================================
+TElemList
+List of TElemDef nodes.
+===============================================================================================
+*)
+
+FUNCTION TElemList.Node (Name : STRING) : TElemDef;
+ // Binary search for the Node with the given Name
+VAR
+ L, H : INTEGER; // Low, High Limit
+ T, C : INTEGER; // Test Index, Comparison result
+ Last : INTEGER; // Last Test Index
+BEGIN
+ IF Count=0 THEN BEGIN
+ Result := NIL;
+ EXIT;
+ END;
+
+ L := 0;
+ H := Count;
+ Last := -1;
+ REPEAT
+ T := (L+H) DIV 2;
+ IF T=Last THEN BREAK;
+ Result := TElemDef (Items [T]);
+ C := CompareStr (Result.Name, Name);
+ IF C = 0 THEN EXIT
+ ELSE IF C < 0 THEN L := T
+ ELSE H := T;
+ Last := T;
+ UNTIL FALSE;
+ Result := NIL;
+END;
+
+
+PROCEDURE TElemList.Add (Node : TElemDef);
+VAR
+ I : INTEGER;
+BEGIN
+ FOR I := Count-1 DOWNTO 0 DO
+ IF Node.Name > TElemDef (Items [I]).Name THEN BEGIN
+ Insert (I+1, Node);
+ EXIT;
+ END;
+ Insert (0, Node);
+END;
+
+
+(*
+===============================================================================================
+TScannerXmlParser
+A TXmlParser descendant for the TCustomXmlScanner component
+===============================================================================================
+*)
+
+TYPE
+ TScannerXmlParser = CLASS (TXmlParser)
+ Scanner : TCustomXmlScanner;
+ CONSTRUCTOR Create (TheScanner : TCustomXmlScanner);
+ FUNCTION LoadExternalEntity (SystemId, PublicId,
+ Notation : STRING) : TXmlParser; OVERRIDE;
+ FUNCTION TranslateEncoding (CONST Source : STRING) : STRING; OVERRIDE;
+ PROCEDURE DtdElementFound (DtdElementRec : TDtdElementRec); OVERRIDE;
+ END;
+
+CONSTRUCTOR TScannerXmlParser.Create (TheScanner : TCustomXmlScanner);
+BEGIN
+ INHERITED Create;
+ Scanner := TheScanner;
+END;
+
+
+FUNCTION TScannerXmlParser.LoadExternalEntity (SystemId, PublicId, Notation : STRING) : TXmlParser;
+BEGIN
+ IF Assigned (Scanner.FOnLoadExternal)
+ THEN Scanner.FOnLoadExternal (Scanner, SystemId, PublicId, Notation, Result)
+ ELSE Result := INHERITED LoadExternalEntity (SystemId, PublicId, Notation);
+END;
+
+
+FUNCTION TScannerXmlParser.TranslateEncoding (CONST Source : STRING) : STRING;
+BEGIN
+ IF Assigned (Scanner.FOnTranslateEncoding)
+ THEN Result := Scanner.FOnTranslateEncoding (Scanner, CurEncoding, Source)
+ ELSE Result := INHERITED TranslateEncoding (Source);
+END;
+
+
+PROCEDURE TScannerXmlParser.DtdElementFound (DtdElementRec : TDtdElementRec);
+BEGIN
+ WITH DtdElementRec DO
+ CASE ElementType OF
+ deElement : Scanner.WhenElement (ElemDef);
+ deAttList : Scanner.WhenAttList (ElemDef);
+ deEntity : Scanner.WhenEntity (EntityDef);
+ deNotation : Scanner.WhenNotation (NotationDef);
+ dePI : Scanner.WhenPI (STRING (Target), STRING (Content), AttrList);
+ deComment : Scanner.WhenComment (StrSFPas (Start, Final));
+ deError : Scanner.WhenDtdError (Pos);
+ END;
+END;
+
+
+(*
+===============================================================================================
+TCustomXmlScanner
+===============================================================================================
+*)
+
+CONSTRUCTOR TCustomXmlScanner.Create (AOwner: TComponent);
+BEGIN
+ INHERITED;
+ FXmlParser := TScannerXmlParser.Create (Self);
+END;
+
+
+DESTRUCTOR TCustomXmlScanner.Destroy;
+BEGIN
+ FXmlParser.Free;
+ INHERITED;
+END;
+
+
+PROCEDURE TCustomXmlScanner.LoadFromFile (Filename : TFilename);
+ // Load XML Document from file
+BEGIN
+ FXmlParser.LoadFromFile (Filename);
+END;
+
+
+PROCEDURE TCustomXmlScanner.LoadFromBuffer (Buffer : PChar);
+ // Load XML Document from buffer
+BEGIN
+ FXmlParser.LoadFromBuffer (Buffer);
+END;
+
+
+PROCEDURE TCustomXmlScanner.SetBuffer (Buffer : PChar);
+ // Refer to Buffer
+BEGIN
+ FXmlParser.SetBuffer (Buffer);
+END;
+
+
+FUNCTION TCustomXmlScanner.GetFilename : TFilename;
+BEGIN
+ Result := FXmlParser.Source;
+END;
+
+
+FUNCTION TCustomXmlScanner.GetNormalize : BOOLEAN;
+BEGIN
+ Result := FXmlParser.Normalize;
+END;
+
+
+PROCEDURE TCustomXmlScanner.SetNormalize (Value : BOOLEAN);
+BEGIN
+ FXmlParser.Normalize := Value;
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenXmlProlog(XmlVersion, Encoding: STRING; Standalone : BOOLEAN);
+ // Is called when the parser has parsed the <? xml ?> declaration of the prolog
+BEGIN
+ IF Assigned (FOnXmlProlog) THEN FOnXmlProlog (Self, XmlVersion, Encoding, Standalone);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenComment (Comment : STRING);
+ // Is called when the parser has parsed a <!-- comment -->
+BEGIN
+ IF Assigned (FOnComment) THEN FOnComment (Self, Comment);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenPI (Target, Content: STRING; Attributes : TAttrList);
+ // Is called when the parser has parsed a <?processing instruction ?>
+BEGIN
+ IF Assigned (FOnPI) THEN FOnPI (Self, Target, Content, Attributes);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenDtdRead (RootElementName : STRING);
+ // Is called when the parser has completely parsed the DTD
+BEGIN
+ IF Assigned (FOnDtdRead) THEN FOnDtdRead (Self, RootElementName);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenStartTag (TagName : STRING; Attributes : TAttrList);
+ // Is called when the parser has parsed a start tag like <p>
+BEGIN
+ IF Assigned (FOnStartTag) THEN FOnStartTag (Self, TagName, Attributes);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenEmptyTag (TagName : STRING; Attributes : TAttrList);
+ // Is called when the parser has parsed an Empty Element Tag like <br/>
+BEGIN
+ IF Assigned (FOnEmptyTag) THEN FOnEmptyTag (Self, TagName, Attributes);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenEndTag (TagName : STRING);
+ // Is called when the parser has parsed an End Tag like </p>
+BEGIN
+ IF Assigned (FOnEndTag) THEN FOnEndTag (Self, TagName);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenContent (Content : STRING);
+ // Is called when the parser has parsed an element's text content
+BEGIN
+ IF Assigned (FOnContent) THEN FOnContent (Self, Content);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenCData (Content : STRING);
+ // Is called when the parser has parsed a CDATA section
+BEGIN
+ IF Assigned (FOnCData) THEN FOnCData (Self, Content);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenElement (ElemDef : TElemDef);
+ // Is called when the parser has parsed an <!ELEMENT> definition
+ // inside the DTD
+BEGIN
+ IF Assigned (FOnElement) THEN FOnElement (Self, ElemDef);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenAttList (ElemDef : TElemDef);
+ // Is called when the parser has parsed an <!ATTLIST> definition
+ // inside the DTD
+BEGIN
+ IF Assigned (FOnAttList) THEN FOnAttList (Self, ElemDef);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenEntity (EntityDef : TEntityDef);
+ // Is called when the parser has parsed an <!ENTITY> definition
+ // inside the DTD
+BEGIN
+ IF Assigned (FOnEntity) THEN FOnEntity (Self, EntityDef);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenNotation (NotationDef : TNotationDef);
+ // Is called when the parser has parsed a <!NOTATION> definition
+ // inside the DTD
+BEGIN
+ IF Assigned (FOnNotation) THEN FOnNotation (Self, NotationDef);
+END;
+
+
+PROCEDURE TCustomXmlScanner.WhenDtdError (ErrorPos : PChar);
+ // Is called when the parser has found an Error in the DTD
+BEGIN
+ IF Assigned (FOnDtdError) THEN FOnDtdError (Self, ErrorPos);
+END;
+
+
+PROCEDURE TCustomXmlScanner.Execute;
+ // Perform scanning
+ // Scanning is done synchronously, i.e. you can expect events to be triggered
+ // in the order of the XML data stream. Execute will finish when the whole XML
+ // document has been scanned or when the StopParser property has been set to TRUE.
+BEGIN
+ FStopParser := FALSE;
+ FXmlParser.StartScan;
+ WHILE FXmlParser.Scan AND (NOT FStopParser) DO
+ CASE FXmlParser.CurPartType OF
+ ptNone : ;
+ ptXmlProlog : WhenXmlProlog (FXmlParser.XmlVersion, FXmlParser.Encoding, FXmlParser.Standalone);
+ ptComment : WhenComment (StrSFPas (FXmlParser.CurStart, FXmlParser.CurFinal));
+ ptPI : WhenPI (FXmlParser.CurName, FXmlParser.CurContent, FXmlParser.CurAttr);
+ ptDtdc : WhenDtdRead (FXmlParser.RootName);
+ ptStartTag : WhenStartTag (FXmlParser.CurName, FXmlParser.CurAttr);
+ ptEmptyTag : WhenEmptyTag (FXmlParser.CurName, FXmlParser.CurAttr);
+ ptEndTag : WhenEndTag (FXmlParser.CurName);
+ ptContent : WhenContent (FXmlParser.CurContent);
+ ptCData : WhenCData (FXmlParser.CurContent);
+ END;
+END;
+
+
+END.
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/logger.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/logger.pas new file mode 100644 index 00000000..461fa261 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/logger.pas @@ -0,0 +1,189 @@ +unit logger;
+{
+ $Id: logger.pas,v 1.2 2006/11/26 16:58:04 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ Error Logging Unit }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Dominique Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Portions created by Dominique Louis are }
+{ Copyright (C) 2000 - 2001 Dominique Louis. }
+{ }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ Logging functions... }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ SDL.dll on Windows platforms }
+{ libSDL-1.1.so.0 on Linux platform }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ 2001 - DL : Initial creation }
+{ 25/10/2001 - DRE : Added $M+ directive to allow published }
+{ in classes. Added a compile directive }
+{ around fmShareExclusive as this does not }
+{ exist in Free Pascal }
+{ }
+{******************************************************************************}
+{
+ $Log: logger.pas,v $
+ Revision 1.2 2006/11/26 16:58:04 savage
+ Modifed to create separate log files. Therefore each instance running from the same directory will have their own individual log file, prepended with a number.
+
+ Revision 1.1 2004/02/05 00:08:20 savage
+ Module 1.0 release
+
+
+}
+
+{$I jedi-sdl.inc}
+
+{$WEAKPACKAGEUNIT OFF}
+
+interface
+
+uses
+ Classes,
+ SysUtils;
+
+type
+ TLogger = class
+ private
+ FFileHandle : TextFile;
+ FApplicationName : string;
+ FApplicationPath : string;
+ protected
+
+ public
+ constructor Create;
+ destructor Destroy; override;
+ function GetApplicationName: string;
+ function GetApplicationPath: string;
+ procedure LogError( ErrorMessage : string; Location : string );
+ procedure LogWarning( WarningMessage : string; Location : string );
+ procedure LogStatus( StatusMessage : string; Location : string );
+ published
+ property ApplicationName : string read GetApplicationName;
+ property ApplicationPath : string read GetApplicationPath;
+ end;
+
+var
+ Log : TLogger;
+
+implementation
+
+{ TLogger }
+constructor TLogger.Create;
+var
+ FileName : string;
+ FileNo : integer;
+begin
+ FApplicationName := ExtractFileName( ParamStr(0) );
+ FApplicationPath := ExtractFilePath( ParamStr(0) );
+ FileName := FApplicationPath + ChangeFileExt( FApplicationName, '.log' );
+ FileNo := 0;
+ while FileExists( FileName ) do
+ begin
+ inc( FileNo );
+ FileName := FApplicationPath + IntToStr( FileNo ) + ChangeFileExt( FApplicationName, '.log' )
+ end;
+ AssignFile( FFileHandle, FileName );
+ ReWrite( FFileHandle );
+ (*inherited Create( FApplicationPath + ChangeFileExt( FApplicationName, '.log' ),
+ fmCreate {$IFNDEF FPC}or fmShareExclusive{$ENDIF} );*)
+end;
+
+destructor TLogger.Destroy;
+begin
+ CloseFile( FFileHandle );
+ inherited;
+end;
+
+function TLogger.GetApplicationName: string;
+begin
+ result := FApplicationName;
+end;
+
+function TLogger.GetApplicationPath: string;
+begin
+ result := FApplicationPath;
+end;
+
+procedure TLogger.LogError(ErrorMessage, Location: string);
+var
+ S : string;
+begin
+ S := '*** ERROR *** : @ ' + TimeToStr(Time) + ' MSG : ' + ErrorMessage + ' IN : ' + Location + #13#10;
+ WriteLn( FFileHandle, S );
+ Flush( FFileHandle );
+end;
+
+procedure TLogger.LogStatus(StatusMessage, Location: string);
+var
+ S : string;
+begin
+ S := 'STATUS INFO : @ ' + TimeToStr(Time) + ' MSG : ' + StatusMessage + ' IN : ' + Location + #13#10;
+ WriteLn( FFileHandle, S );
+ Flush( FFileHandle );
+end;
+
+procedure TLogger.LogWarning(WarningMessage, Location: string);
+var
+ S : string;
+begin
+ S := '=== WARNING === : @ ' + TimeToStr(Time) + ' MSG : ' + WarningMessage + ' IN : ' + Location + #13#10;
+ WriteLn( FFileHandle, S );
+ Flush( FFileHandle );
+end;
+
+initialization
+begin
+ Log := TLogger.Create;
+ Log.LogStatus( 'Starting Application', 'Initialization' );
+end;
+
+finalization
+begin
+ Log.LogStatus( 'Terminating Application', 'Finalization' );
+ Log.Free;
+ Log := nil;
+end;
+
+end.
+
\ No newline at end of file diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/moduleloader.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/moduleloader.pas new file mode 100644 index 00000000..146e4b30 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/moduleloader.pas @@ -0,0 +1,319 @@ +unit moduleloader;
+{
+ $Id: moduleloader.pas,v 1.4 2004/02/20 17:19:10 savage Exp $
+
+}
+{******************************************************************}
+{ }
+{ Project JEDI }
+{ OS independent Dynamic Loading Helpers }
+{ }
+{ The initial developer of the this code is }
+{ Robert Marquardt <robert_marquardt@gmx.de) }
+{ }
+{ Copyright (C) 2000, 2001 Robert Marquardt. }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators (Project JEDI) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ not use this file except in compliance with the License. You may }
+{ obtain a copy of the License at }
+{ http://www.mozilla.org/NPL/NPL-1_1Final.html }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{******************************************************************}
+{
+ $Log: moduleloader.pas,v $
+ Revision 1.4 2004/02/20 17:19:10 savage
+ Added Calling convention to Win32 functions just in case.
+
+ Revision 1.3 2004/02/14 22:36:29 savage
+ Fixed inconsistencies of using LoadLibrary and LoadModule.
+ Now all units make use of LoadModule rather than LoadLibrary and other dynamic proc procedures.
+
+ Revision 1.2 2004/02/14 00:23:39 savage
+ As UNIX is defined in jedi-sdl.inc this will be used to check linux compatability as well. Units have been changed to reflect this change.
+
+ Revision 1.1 2004/02/14 00:04:50 savage
+ dllfuncs conflicts with FreePascal so it has been renamed back to the moduleloader.pas
+
+ Revision 1.1 2004/02/05 00:08:19 savage
+ Module 1.0 release
+
+
+}
+
+interface
+
+{$i jedi-sdl.inc}
+{$WEAKPACKAGEUNIT ON}
+
+// each OS gets its own IFDEFed complete code block to make reading easier
+
+{$IFDEF WIN32}
+uses
+ Windows;
+
+type
+ // Handle to a loaded DLL
+ TModuleHandle = HINST;
+
+const
+ // Value designating an unassigned TModuleHandle od a failed loading
+ INVALID_MODULEHANDLE_VALUE = TModuleHandle(0);
+
+function LoadModule(var Module: TModuleHandle; FileName: PChar): Boolean; stdcall;
+function LoadModuleEx(var Module: TModuleHandle; FileName: PChar; Flags: Cardinal): Boolean; stdcall;
+procedure UnloadModule(var Module: TModuleHandle); stdcall;
+function GetModuleSymbol(Module: TModuleHandle; SymbolName: PChar): Pointer; stdcall;
+function GetModuleSymbolEx(Module: TModuleHandle; SymbolName: PChar; var Accu: Boolean): Pointer; stdcall;
+function ReadModuleData(Module: TModuleHandle; SymbolName: PChar; var Buffer; Size: Cardinal): Boolean; stdcall;
+function WriteModuleData(Module: TModuleHandle; SymbolName: PChar; var Buffer; Size: Cardinal): Boolean; stdcall;
+
+implementation
+
+// load the DLL file FileName
+// the rules for FileName are those of LoadLibrary
+// Returns: True = success, False = failure to load
+// Assigns: the handle of the loaded DLL to Module
+// Warning: if Module has any other value than INVALID_MODULEHANDLE_VALUE
+// on entry the function will do nothing but returning success.
+
+function LoadModule(var Module: TModuleHandle; FileName: PChar): Boolean;
+begin
+ if Module = INVALID_MODULEHANDLE_VALUE then
+ Module := LoadLibrary( FileName );
+ Result := Module <> INVALID_MODULEHANDLE_VALUE;
+end;
+
+// load the DLL file FileName
+// LoadLibraryEx is used to get better control of the loading
+// for the allowed values for flags see LoadLibraryEx documentation.
+
+function LoadModuleEx(var Module: TModuleHandle; FileName: PChar; Flags: Cardinal): Boolean;
+begin
+ if Module = INVALID_MODULEHANDLE_VALUE then
+ Module := LoadLibraryEx( FileName, 0, Flags);
+ Result := Module <> INVALID_MODULEHANDLE_VALUE;
+end;
+
+// unload a DLL loaded with LoadModule or LoadModuleEx
+// The procedure will not try to unload a handle with
+// value INVALID_MODULEHANDLE_VALUE and assigns this value
+// to Module after unload.
+
+procedure UnloadModule(var Module: TModuleHandle);
+begin
+ if Module <> INVALID_MODULEHANDLE_VALUE then
+ FreeLibrary(Module);
+ Module := INVALID_MODULEHANDLE_VALUE;
+end;
+
+// returns the pointer to the symbol named SymbolName
+// if it is exported from the DLL Module
+// nil is returned if the symbol is not available
+
+function GetModuleSymbol(Module: TModuleHandle; SymbolName: PChar): Pointer;
+begin
+ Result := nil;
+ if Module <> INVALID_MODULEHANDLE_VALUE then
+ Result := GetProcAddress(Module, SymbolName );
+end;
+
+// returns the pointer to the symbol named SymbolName
+// if it is exported from the DLL Module
+// nil is returned if the symbol is not available.
+// as an extra the boolean variable Accu is updated
+// by anding in the success of the function.
+// This is very handy for rendering a global result
+// when accessing a long list of symbols.
+
+function GetModuleSymbolEx(Module: TModuleHandle; SymbolName: PChar; var Accu: Boolean): Pointer;
+begin
+ Result := nil;
+ if Module <> INVALID_MODULEHANDLE_VALUE then
+ Result := GetProcAddress(Module, SymbolName );
+ Accu := Accu and (Result <> nil);
+end;
+
+// get the value of variables exported from a DLL Module
+// Delphi cannot access variables in a DLL directly, so
+// this function allows to copy the data from the DLL.
+// Beware! You are accessing the DLL memory image directly.
+// Be sure to access a variable not a function and be sure
+// to read the correct amount of data.
+
+function ReadModuleData(Module: TModuleHandle; SymbolName: PChar; var Buffer; Size: Cardinal): Boolean;
+var
+ Sym: Pointer;
+begin
+ Result := True;
+ Sym := GetModuleSymbolEx(Module, SymbolName, Result);
+ if Result then
+ Move(Sym^, Buffer, Size);
+end;
+
+// set the value of variables exported from a DLL Module
+// Delphi cannot access variables in a DLL directly, so
+// this function allows to copy the data to the DLL!
+// BEWARE! You are accessing the DLL memory image directly.
+// Be sure to access a variable not a function and be sure
+// to write the correct amount of data.
+// The changes are not persistent. They get lost when the
+// DLL is unloaded.
+
+function WriteModuleData(Module: TModuleHandle; SymbolName: PChar; var Buffer; Size: Cardinal): Boolean;
+var
+ Sym: Pointer;
+begin
+ Result := True;
+ Sym := GetModuleSymbolEx(Module, SymbolName, Result);
+ if Result then
+ Move(Buffer, Sym^, Size);
+end;
+
+{$ENDIF}
+
+{$IFDEF Unix}
+uses
+{$ifdef Linux}
+ Types,
+ Libc;
+{$else}
+ dl,
+ Types,
+ Baseunix,
+ Unix;
+{$endif}
+type
+ // Handle to a loaded .so
+ TModuleHandle = Pointer;
+
+const
+ // Value designating an unassigned TModuleHandle od a failed loading
+ INVALID_MODULEHANDLE_VALUE = TModuleHandle(nil);
+
+function LoadModule(var Module: TModuleHandle; FileName: PChar): Boolean;
+function LoadModuleEx(var Module: TModuleHandle; FileName: PChar; Flags: Cardinal): Boolean;
+procedure UnloadModule(var Module: TModuleHandle);
+function GetModuleSymbol(Module: TModuleHandle; SymbolName: PChar): Pointer;
+function GetModuleSymbolEx(Module: TModuleHandle; SymbolName: PChar; var Accu: Boolean): Pointer;
+function ReadModuleData(Module: TModuleHandle; SymbolName: PChar; var Buffer; Size: Cardinal): Boolean;
+function WriteModuleData(Module: TModuleHandle; SymbolName: PChar; var Buffer; Size: Cardinal): Boolean;
+
+implementation
+
+// load the .so file FileName
+// the rules for FileName are those of dlopen()
+// Returns: True = success, False = failure to load
+// Assigns: the handle of the loaded .so to Module
+// Warning: if Module has any other value than INVALID_MODULEHANDLE_VALUE
+// on entry the function will do nothing but returning success.
+
+function LoadModule(var Module: TModuleHandle; FileName: PChar): Boolean;
+begin
+ if Module = INVALID_MODULEHANDLE_VALUE then
+ Module := dlopen( FileName, RTLD_NOW);
+ Result := Module <> INVALID_MODULEHANDLE_VALUE;
+end;
+
+// load the .so file FileName
+// dlopen() with flags is used to get better control of the loading
+// for the allowed values for flags see "man dlopen".
+
+function LoadModuleEx(var Module: TModuleHandle; FileName: PChar; Flags: Cardinal): Boolean;
+begin
+ if Module = INVALID_MODULEHANDLE_VALUE then
+ Module := dlopen( FileName, Flags);
+ Result := Module <> INVALID_MODULEHANDLE_VALUE;
+end;
+
+// unload a .so loaded with LoadModule or LoadModuleEx
+// The procedure will not try to unload a handle with
+// value INVALID_MODULEHANDLE_VALUE and assigns this value
+// to Module after unload.
+
+procedure UnloadModule(var Module: TModuleHandle);
+begin
+ if Module <> INVALID_MODULEHANDLE_VALUE then
+ dlclose(Module);
+ Module := INVALID_MODULEHANDLE_VALUE;
+end;
+
+// returns the pointer to the symbol named SymbolName
+// if it is exported from the .so Module
+// nil is returned if the symbol is not available
+
+function GetModuleSymbol(Module: TModuleHandle; SymbolName: PChar): Pointer;
+begin
+ Result := nil;
+ if Module <> INVALID_MODULEHANDLE_VALUE then
+ Result := dlsym(Module, SymbolName );
+end;
+
+// returns the pointer to the symbol named SymbolName
+// if it is exported from the .so Module
+// nil is returned if the symbol is not available.
+// as an extra the boolean variable Accu is updated
+// by anding in the success of the function.
+// This is very handy for rendering a global result
+// when accessing a long list of symbols.
+
+function GetModuleSymbolEx(Module: TModuleHandle; SymbolName: PChar; var Accu: Boolean): Pointer;
+begin
+ Result := nil;
+ if Module <> INVALID_MODULEHANDLE_VALUE then
+ Result := dlsym(Module, SymbolName );
+ Accu := Accu and (Result <> nil);
+end;
+
+// get the value of variables exported from a .so Module
+// Delphi cannot access variables in a .so directly, so
+// this function allows to copy the data from the .so.
+// Beware! You are accessing the .so memory image directly.
+// Be sure to access a variable not a function and be sure
+// to read the correct amount of data.
+
+function ReadModuleData(Module: TModuleHandle; SymbolName: PChar; var Buffer; Size: Cardinal): Boolean;
+var
+ Sym: Pointer;
+begin
+ Result := True;
+ Sym := GetModuleSymbolEx(Module, SymbolName, Result);
+ if Result then
+ Move(Sym^, Buffer, Size);
+end;
+
+// set the value of variables exported from a .so Module
+// Delphi cannot access variables in a .so directly, so
+// this function allows to copy the data to the .so!
+// BEWARE! You are accessing the .so memory image directly.
+// Be sure to access a variable not a function and be sure
+// to write the correct amount of data.
+// The changes are not persistent. They get lost when the
+// .so is unloaded.
+
+function WriteModuleData(Module: TModuleHandle; SymbolName: PChar; var Buffer; Size: Cardinal): Boolean;
+var
+ Sym: Pointer;
+begin
+ Result := True;
+ Sym := GetModuleSymbolEx(Module, SymbolName, Result);
+ if Result then
+ Move(Buffer, Sym^, Size);
+end;
+{$ENDIF}
+
+{$IFDEF __MACH__} // Mach definitions go here
+{$ENDIF}
+
+end.
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/registryuserpreferences.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/registryuserpreferences.pas new file mode 100644 index 00000000..2d28a222 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/registryuserpreferences.pas @@ -0,0 +1,229 @@ +unit registryuserpreferences;
+{
+ $Id: registryuserpreferences.pas,v 1.1 2004/09/30 22:35:47 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer }
+{ Wrapper class for Windows Register and INI Files }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Dominqiue Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Portions created by Dominqiue Louis are }
+{ Copyright (C) 2000 - 2001 Dominqiue Louis. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so }
+{ They are available from... }
+{ http://www.libsdl.org . }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ September 23 2004 - DL : Initial Creation }
+{
+ $Log: registryuserpreferences.pas,v $
+ Revision 1.1 2004/09/30 22:35:47 savage
+ Changes, enhancements and additions as required to get SoAoS working.
+
+
+}
+{******************************************************************************}
+
+interface
+
+uses
+ {$IFDEF REG}
+ Registry,
+ {$ELSE}
+ IniFiles,
+ {$ENDIF}
+ Classes,
+ userpreferences;
+
+type
+ TRegistryUserPreferences = class( TUserPreferences )
+ private
+
+ protected
+ function GetSection( const Index : Integer ) : string; virtual; abstract;
+ function GetIdentifier( const Index : Integer ) : string; virtual; abstract;
+ function GetDefaultBoolean( const Index : Integer ) : Boolean; override;
+ function GetBoolean( const Index : Integer ) : Boolean; override;
+ procedure SetBoolean( const Index : Integer; const Value : Boolean ); override;
+ function GetDefaultDateTime( const Index : Integer ) : TDateTime; override;
+ function GetDateTime( const Index : Integer ) : TDateTime; override;
+ procedure SetDateTime( const Index : Integer; const Value : TDateTime ); override;
+ function GetDefaultInteger( const Index : Integer ) : Integer; override;
+ function GetInteger( const Index : Integer ) : Integer; override;
+ procedure SetInteger( const Index : Integer; const Value : Integer ); override;
+ function GetDefaultFloat( const Index : Integer ) : single; override;
+ function GetFloat( const Index : Integer ) : single; override;
+ procedure SetFloat( const Index : Integer; const Value : single ); override;
+ function GetDefaultString( const Index : Integer ) : string; override;
+ function GetString( const Index : Integer ) : string; override;
+ procedure SetString( const Index : Integer; const Value : string ); override;
+ public
+ Registry : {$IFDEF REG}TRegIniFile{$ELSE}TIniFile{$ENDIF};
+ constructor Create( const FileName : string = '' ); reintroduce;
+ destructor Destroy; override;
+ procedure Update; override;
+ end;
+
+implementation
+
+uses
+ SysUtils;
+
+{ TRegistryUserPreferences }
+constructor TRegistryUserPreferences.Create( const FileName : string );
+var
+ defFileName : string;
+begin
+ inherited Create;
+
+ if FileName <> '' then
+ defFileName := FileName
+ else
+ defFileName := ChangeFileExt( ParamStr( 0 ), '.ini' );
+
+ Registry := {$IFDEF REG}TRegIniFile{$ELSE}TIniFile{$ENDIF}.Create( defFileName );
+end;
+
+destructor TRegistryUserPreferences.Destroy;
+begin
+ Update;
+ Registry.Free;
+ Registry := nil;
+ inherited;
+end;
+
+function TRegistryUserPreferences.GetBoolean( const Index : Integer ) : Boolean;
+begin
+ Result := Registry.ReadBool( GetSection( Index ), GetIdentifier( Index ), GetDefaultBoolean( Index ) );
+end;
+
+function TRegistryUserPreferences.GetDateTime( const Index : Integer ): TDateTime;
+begin
+ Result := Registry.ReadDateTime( GetSection( Index ){$IFNDEF REG}, GetIdentifier( Index ), GetDefaultDateTime( Index ){$ENDIF} );
+end;
+
+function TRegistryUserPreferences.GetDefaultBoolean( const Index : Integer ) : Boolean;
+begin
+ result := false;
+end;
+
+function TRegistryUserPreferences.GetDefaultDateTime( const Index: Integer ) : TDateTime;
+begin
+ result := Now;
+end;
+
+function TRegistryUserPreferences.GetDefaultFloat( const Index: Integer ) : single;
+begin
+ result := 0.0;
+end;
+
+function TRegistryUserPreferences.GetDefaultInteger(const Index : Integer ) : Integer;
+begin
+ result := 0;
+end;
+
+function TRegistryUserPreferences.GetDefaultString( const Index : Integer ) : string;
+begin
+ result := '';
+end;
+
+function TRegistryUserPreferences.GetFloat( const Index : Integer ): single;
+begin
+ Result := Registry.ReadFloat( GetSection( Index ){$IFNDEF REG}, GetIdentifier( Index ), GetDefaultFloat( Index ){$ENDIF} );
+end;
+
+function TRegistryUserPreferences.GetInteger( const Index : Integer ) : Integer;
+begin
+ Result := Registry.ReadInteger( GetSection( Index ), GetIdentifier( Index ), GetDefaultInteger( Index ) );
+end;
+
+function TRegistryUserPreferences.GetString( const Index : Integer ): string;
+begin
+ Result := Registry.ReadString( GetSection( Index ), GetIdentifier( Index ), GetDefaultString( Index ) );
+end;
+
+procedure TRegistryUserPreferences.SetBoolean( const Index : Integer; const Value : Boolean );
+begin
+ Registry.WriteBool( GetSection( Index ), GetIdentifier( Index ), Value );
+ inherited;
+end;
+
+procedure TRegistryUserPreferences.SetDateTime( const Index: Integer; const Value: TDateTime );
+begin
+ Registry.WriteDateTime( GetSection( Index ){$IFNDEF REG}, GetIdentifier( Index ){$ENDIF}, Value );
+ inherited;
+end;
+
+procedure TRegistryUserPreferences.SetFloat(const Index: Integer; const Value: single);
+begin
+ Registry.WriteFloat( GetSection( Index ){$IFNDEF REG}, GetIdentifier( Index ){$ENDIF}, Value );
+ inherited;
+end;
+
+procedure TRegistryUserPreferences.SetInteger( const Index, Value : Integer );
+begin
+ Registry.WriteInteger( GetSection( Index ), GetIdentifier( Index ), Value );
+ inherited;
+end;
+
+procedure TRegistryUserPreferences.SetString( const Index : Integer; const Value : string );
+begin
+ Registry.WriteString( GetSection( Index ), GetIdentifier( Index ), Value );
+ inherited;
+end;
+
+procedure TRegistryUserPreferences.Update;
+begin
+ {$IFDEF REG}
+ Registry.CloseKey;
+ {$ELSE}
+ Registry.UpdateFile;
+ {$ENDIF}
+end;
+
+end.
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/sdl.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdl.pas new file mode 100644 index 00000000..29bc7123 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdl.pas @@ -0,0 +1,4321 @@ +unit sdl;
+{
+ $Id: sdl.pas,v 1.38 2008/01/26 10:09:32 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer }
+{ Conversion of the Simple DirectMedia Layer Headers }
+{ }
+{ Portions created by Sam Lantinga <slouken@devolution.com> are }
+{ Copyright (C) 1997-2004 Sam Lantinga }
+{ 5635-34 Springhouse Dr. }
+{ Pleasanton, CA 94588 (USA) }
+{ }
+{ All Rights Reserved. }
+{ }
+{ The original files are : SDL.h }
+{ SDL_main.h }
+{ SDL_types.h }
+{ SDL_rwops.h }
+{ SDL_timer.h }
+{ SDL_audio.h }
+{ SDL_cdrom.h }
+{ SDL_joystick.h }
+{ SDL_mouse.h }
+{ SDL_keyboard.h }
+{ SDL_events.h }
+{ SDL_video.h }
+{ SDL_byteorder.h }
+{ SDL_version.h }
+{ SDL_active.h }
+{ SDL_thread.h }
+{ SDL_mutex .h }
+{ SDL_getenv.h }
+{ SDL_loadso.h }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Dominique Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Portions created by Dominique Louis are }
+{ Copyright (C) 2000 - 2004 Dominique Louis. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion }
+{ Matthias Thoma <ma.thoma@gmx.de> }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so }
+{ They are available from... }
+{ http://www.libsdl.org . }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ May 08 2001 - DL : Added Keyboard State Array ( See demos for how to }
+{ use ) }
+{ PKeyStateArr = ^TKeyStateArr; }
+{ TKeyStateArr = array[0..65000] of UInt8; }
+{ As most games will need it. }
+{ }
+{ April 02 2001 - DL : Added SDL_getenv.h definitions and tested version }
+{ 1.2.0 compatability. }
+{ }
+{ March 13 2001 - MT : Added Linux compatibility. }
+{ }
+{ March 10 2001 - MT : Added externalsyms for DEFINES }
+{ Changed the license header }
+{ }
+{ March 09 2001 - MT : Added Kylix Ifdefs/Deleted the uses mmsystem }
+{ }
+{ March 01 2001 - DL : Update conversion of version 1.1.8 }
+{ }
+{ July 22 2001 - DL : Added TUInt8Array and PUIntArray after suggestions }
+{ from Matthias Thoma and Eric Grange. }
+{ }
+{ October 12 2001 - DL : Various changes as suggested by Matthias Thoma and }
+{ David Acklam }
+{ }
+{ October 24 2001 - DL : Added FreePascal support as per suggestions from }
+{ Dean Ellis. }
+{ }
+{ October 27 2001 - DL : Added SDL_BUTTON macro }
+{ }
+{ November 08 2001 - DL : Bug fix as pointed out by Puthoon. }
+{ }
+{ November 29 2001 - DL : Bug fix of SDL_SetGammaRamp as pointed out by Simon}
+{ Rushton. }
+{ }
+{ November 30 2001 - DL : SDL_NOFRAME added as pointed out by Simon Rushton. }
+{ }
+{ December 11 2001 - DL : Added $WEAKPACKAGEUNIT ON to facilitate useage in }
+{ Components }
+{ }
+{ January 05 2002 - DL : Added SDL_Swap32 function as suggested by Matthias }
+{ Thoma and also made sure the _getenv from }
+{ MSVCRT.DLL uses the right calling convention }
+{ }
+{ January 25 2002 - DL : Updated conversion of SDL_AddTimer & }
+{ SDL_RemoveTimer as per suggestions from Matthias }
+{ Thoma. }
+{ }
+{ January 27 2002 - DL : Commented out exported function putenv and getenv }
+{ So that developers get used to using SDL_putenv }
+{ SDL_getenv, as they are more portable }
+{ }
+{ March 05 2002 - DL : Added FreeAnNil procedure for Delphi 4 users. }
+{ }
+{ October 23 2002 - DL : Added Delphi 3 Define of Win32. }
+{ If you intend to you Delphi 3... }
+{ ( which is officially unsupported ) make sure you }
+{ remove references to $EXTERNALSYM in this and other}
+{ SDL files. }
+{ }
+{ November 29 2002 - DL : Fixed bug in Declaration of SDL_GetRGBA that was }
+{ pointed out by Todd Lang }
+{ }
+{ April 03 2003 - DL : Added jedi-sdl.inc include file to support more }
+{ Pascal compilers. Initial support is now included }
+{ for GnuPascal, VirtualPascal, TMT and obviously }
+{ continue support for Delphi Kylix and FreePascal. }
+{ }
+{ April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support }
+{ }
+{ April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added}
+{ better TMT Pascal support and under instruction }
+{ from Prof. Abimbola Olowofoyeku (The African Chief),}
+{ I have added better Gnu Pascal support }
+{ }
+{ April 30 2003 - DL : under instruction from David Mears AKA }
+{ Jason Siletto, I have added FPC Linux support. }
+{ This was compiled with fpc 1.1, so remember to set }
+{ include file path. ie. -Fi/usr/share/fpcsrc/rtl/* }
+{ }
+{
+ $Log: sdl.pas,v $
+ Revision 1.38 2008/01/26 10:09:32 savage
+ Added SDL_BUTTON_X1 and SDL_BUTTON_X2 constants for extended mouse buttons. Now makes SDL v1.2.13 compliant.
+
+ Revision 1.37 2007/12/20 22:36:56 savage
+ Added SKYOS support, thanks to Sebastian-Torsten Tillmann
+
+ Revision 1.36 2007/12/05 22:52:04 savage
+ Better Mac OS X support for Frameworks.
+
+ Revision 1.35 2007/12/02 22:41:13 savage
+ Change for Mac OS X to link to SDL Framework
+
+ Revision 1.34 2007/08/26 23:50:53 savage
+ Jonas supplied another fix.
+
+ Revision 1.33 2007/08/26 15:59:46 savage
+ Mac OS changes as suggested by Jonas Maebe
+
+ Revision 1.32 2007/08/22 21:18:43 savage
+ Thanks to Dean for his MouseDelta patch.
+
+ Revision 1.31 2007/05/29 21:30:48 savage
+ Changes as suggested by Almindor for 64bit compatibility.
+
+ Revision 1.30 2007/05/29 19:31:03 savage
+ Fix to TSDL_Overlay structure - thanks David Pethes (aka imcold)
+
+ Revision 1.29 2007/05/20 20:29:11 savage
+ Initial Changes to Handle 64 Bits
+
+ Revision 1.26 2007/02/11 13:38:04 savage
+ Added Nintendo DS support - Thanks Dean.
+
+ Revision 1.25 2006/12/02 00:12:52 savage
+ Updated to latest version
+
+ Revision 1.24 2006/05/18 21:10:04 savage
+ Added 1.2.10 Changes
+
+ Revision 1.23 2005/12/04 23:17:52 drellis
+ Added declaration of SInt8 and PSInt8
+
+ Revision 1.22 2005/05/24 21:59:03 savage
+ Re-arranged uses clause to work on Win32 and Linux, Thanks again Michalis.
+
+ Revision 1.21 2005/05/22 18:42:31 savage
+ Changes as suggested by Michalis Kamburelis. Thanks again.
+
+ Revision 1.20 2005/04/10 11:48:33 savage
+ Changes as suggested by Michalis, thanks.
+
+ Revision 1.19 2005/01/05 01:47:06 savage
+ Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
+
+ Revision 1.18 2005/01/04 23:14:41 savage
+ Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
+
+ Revision 1.17 2005/01/03 18:40:59 savage
+ Updated Version number to reflect latest one
+
+ Revision 1.16 2005/01/01 02:02:06 savage
+ Updated to v1.2.8
+
+ Revision 1.15 2004/12/24 18:57:11 savage
+ forgot to apply Michalis Kamburelis' patch to the implementation section. now fixed
+
+ Revision 1.14 2004/12/23 23:42:18 savage
+ Applied Patches supplied by Michalis Kamburelis ( THANKS! ), for greater FreePascal compatability.
+
+ Revision 1.13 2004/09/30 22:31:59 savage
+ Updated with slightly different header comments
+
+ Revision 1.12 2004/09/12 21:52:58 savage
+ Slight changes to fix some issues with the sdl classes.
+
+ Revision 1.11 2004/08/14 22:54:30 savage
+ Updated so that Library name defines are correctly defined for MacOS X.
+
+ Revision 1.10 2004/07/20 23:57:33 savage
+ Thanks to Paul Toth for spotting an error in the SDL Audio Convertion structures.
+ In TSDL_AudioCVT the filters variable should point to and array of pointers and not what I had there previously.
+
+ Revision 1.9 2004/07/03 22:07:22 savage
+ Added Bitwise Manipulation Functions for TSDL_VideoInfo struct.
+
+ Revision 1.8 2004/05/10 14:10:03 savage
+ Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
+
+ Revision 1.7 2004/04/13 09:32:08 savage
+ Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
+
+ Revision 1.6 2004/04/01 20:53:23 savage
+ Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
+
+ Revision 1.5 2004/02/22 15:32:10 savage
+ SDL_GetEnv Fix so it also works on FPC/Linux. Thanks to Rodrigo for pointing this out.
+
+ Revision 1.4 2004/02/21 23:24:29 savage
+ SDL_GetEnv Fix so that it is not define twice for FPC. Thanks to Rene Hugentobler for pointing out this bug,
+
+ Revision 1.3 2004/02/18 22:35:51 savage
+ Brought sdl.pas up to 1.2.7 compatability
+ Thus...
+ Added SDL_GL_STEREO,
+ SDL_GL_MULTISAMPLEBUFFERS,
+ SDL_GL_MULTISAMPLESAMPLES
+
+ Add DLL/Shared object functions
+ function SDL_LoadObject( const sofile : PChar ) : Pointer;
+
+ function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer;
+
+ procedure SDL_UnloadObject( handle : Pointer );
+
+ Added function to create RWops from const memory: SDL_RWFromConstMem()
+ function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops;
+
+ Ported SDL_cpuinfo.h so Now you can test for Specific CPU types.
+
+ Revision 1.2 2004/02/17 21:37:12 savage
+ Tidying up of units
+
+ Revision 1.1 2004/02/05 00:08:20 savage
+ Module 1.0 release
+
+}
+{******************************************************************************}
+
+{$I jedi-sdl.inc}
+
+interface
+
+uses
+{$IFDEF __GPC__}
+ system,
+ {$IFDEF WINDOWS}
+ wintypes,
+ {$ELSE}
+ {$ENDIF}
+ gpc;
+{$ENDIF}
+
+{$IFDEF HAS_TYPES}
+ Types{$IFNDEF NDS},{$ELSE};{$ENDIF}
+{$ENDIF}
+
+{$IFDEF WINDOWS}
+ Windows;
+{$ENDIF}
+
+{$IFDEF UNIX}
+ {$IFDEF FPC}
+ {$IFNDEF SKYOS}
+ pthreads,
+ {$ENDIF}
+ baseunix,
+ {$IFNDEF GP2X}
+ {$IFNDEF DARWIN}
+ {$IFNDEF SKYOS}
+ unix,
+ {$ELSE}
+ unix;
+ {$ENDIF}
+ {$ELSE}
+ unix;
+ {$ENDIF}
+ {$ELSE}
+ unix;
+ {$ENDIF}
+ {$IFNDEF GP2X}
+ {$IFNDEF DARWIN}
+ {$IFNDEF SKYOS}
+ x,
+ xlib;
+ {$ENDIF}
+ {$ENDIF}
+ {$ENDIF}
+ {$ELSE}
+ Libc,
+ Xlib;
+ {$ENDIF}
+{$ENDIF}
+
+{$IFDEF __MACH__}
+ GPCMacOSAll;
+{$ENDIF}
+
+const
+{$IFDEF WINDOWS}
+ SDLLibName = 'SDL.dll';
+{$ENDIF}
+
+{$IFDEF UNIX}
+{$IFDEF DARWIN}
+ SDLLibName = 'libSDL-1.2.0.dylib';
+{$ELSE}
+ {$IFDEF FPC}
+ SDLLibName = 'libSDL.so';
+ {$ELSE}
+ SDLLibName = 'libSDL-1.2.so.0';
+ {$ENDIF}
+{$ENDIF}
+{$ENDIF}
+
+{$IFDEF MACOS}
+ SDLLibName = 'SDL';
+ {$linklib libSDL}
+{$ENDIF}
+
+{$IFDEF NDS}
+ SDLLibName = 'libSDL.a';
+ {$linklib libSDL.a}
+ {$linklib libnds9.a}
+ {$linklib libc.a}
+ {$linklib libgcc.a}
+ {$linklib libsysbase.a}
+{$ENDIF}
+
+ // SDL_verion.h constants
+ // Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
+ SDL_MAJOR_VERSION = 1;
+{$EXTERNALSYM SDL_MAJOR_VERSION}
+ SDL_MINOR_VERSION = 2;
+{$EXTERNALSYM SDL_MINOR_VERSION}
+ SDL_PATCHLEVEL = 13;
+{$EXTERNALSYM SDL_PATCHLEVEL}
+
+ // SDL.h constants
+ SDL_INIT_TIMER = $00000001;
+{$EXTERNALSYM SDL_INIT_TIMER}
+ SDL_INIT_AUDIO = $00000010;
+{$EXTERNALSYM SDL_INIT_AUDIO}
+ SDL_INIT_VIDEO = $00000020;
+{$EXTERNALSYM SDL_INIT_VIDEO}
+ SDL_INIT_CDROM = $00000100;
+{$EXTERNALSYM SDL_INIT_CDROM}
+ SDL_INIT_JOYSTICK = $00000200;
+{$EXTERNALSYM SDL_INIT_JOYSTICK}
+ SDL_INIT_NOPARACHUTE = $00100000; // Don't catch fatal signals
+{$EXTERNALSYM SDL_INIT_NOPARACHUTE}
+ SDL_INIT_EVENTTHREAD = $01000000; // Not supported on all OS's
+{$EXTERNALSYM SDL_INIT_EVENTTHREAD}
+ SDL_INIT_EVERYTHING = $0000FFFF;
+{$EXTERNALSYM SDL_INIT_EVERYTHING}
+
+ // SDL_error.h constants
+ ERR_MAX_STRLEN = 128;
+{$EXTERNALSYM ERR_MAX_STRLEN}
+ ERR_MAX_ARGS = 5;
+{$EXTERNALSYM ERR_MAX_ARGS}
+
+ // SDL_types.h constants
+ SDL_PRESSED = $01;
+{$EXTERNALSYM SDL_PRESSED}
+ SDL_RELEASED = $00;
+{$EXTERNALSYM SDL_RELEASED}
+
+ // SDL_timer.h constants
+ // This is the OS scheduler timeslice, in milliseconds
+ SDL_TIMESLICE = 10;
+{$EXTERNALSYM SDL_TIMESLICE}
+ // This is the maximum resolution of the SDL timer on all platforms
+ TIMER_RESOLUTION = 10; // Experimentally determined
+{$EXTERNALSYM TIMER_RESOLUTION}
+
+ // SDL_audio.h constants
+ AUDIO_U8 = $0008; // Unsigned 8-bit samples
+{$EXTERNALSYM AUDIO_U8}
+ AUDIO_S8 = $8008; // Signed 8-bit samples
+{$EXTERNALSYM AUDIO_S8}
+ AUDIO_U16LSB = $0010; // Unsigned 16-bit samples
+{$EXTERNALSYM AUDIO_U16LSB}
+ AUDIO_S16LSB = $8010; // Signed 16-bit samples
+{$EXTERNALSYM AUDIO_S16LSB}
+ AUDIO_U16MSB = $1010; // As above, but big-endian byte order
+{$EXTERNALSYM AUDIO_U16MSB}
+ AUDIO_S16MSB = $9010; // As above, but big-endian byte order
+{$EXTERNALSYM AUDIO_S16MSB}
+ AUDIO_U16 = AUDIO_U16LSB;
+{$EXTERNALSYM AUDIO_U16}
+ AUDIO_S16 = AUDIO_S16LSB;
+{$EXTERNALSYM AUDIO_S16}
+
+
+ // SDL_cdrom.h constants
+ // The maximum number of CD-ROM tracks on a disk
+ SDL_MAX_TRACKS = 99;
+{$EXTERNALSYM SDL_MAX_TRACKS}
+ // The types of CD-ROM track possible
+ SDL_AUDIO_TRACK = $00;
+{$EXTERNALSYM SDL_AUDIO_TRACK}
+ SDL_DATA_TRACK = $04;
+{$EXTERNALSYM SDL_DATA_TRACK}
+
+ // Conversion functions from frames to Minute/Second/Frames and vice versa
+ CD_FPS = 75;
+{$EXTERNALSYM CD_FPS}
+ // SDL_byteorder.h constants
+ // The two types of endianness
+ SDL_LIL_ENDIAN = 1234;
+{$EXTERNALSYM SDL_LIL_ENDIAN}
+ SDL_BIG_ENDIAN = 4321;
+{$EXTERNALSYM SDL_BIG_ENDIAN}
+
+{$IFDEF IA32}
+
+ SDL_BYTEORDER = SDL_LIL_ENDIAN;
+{$EXTERNALSYM SDL_BYTEORDER}
+ // Native audio byte ordering
+ AUDIO_U16SYS = AUDIO_U16LSB;
+{$EXTERNALSYM AUDIO_U16SYS}
+ AUDIO_S16SYS = AUDIO_S16LSB;
+{$EXTERNALSYM AUDIO_S16SYS}
+
+{$ELSE}
+
+ SDL_BYTEORDER = SDL_BIG_ENDIAN;
+{$EXTERNALSYM SDL_BYTEORDER}
+ // Native audio byte ordering
+ AUDIO_U16SYS = AUDIO_U16MSB;
+{$EXTERNALSYM AUDIO_U16SYS}
+ AUDIO_S16SYS = AUDIO_S16MSB;
+{$EXTERNALSYM AUDIO_S16SYS}
+
+{$ENDIF}
+
+
+ SDL_MIX_MAXVOLUME = 128;
+{$EXTERNALSYM SDL_MIX_MAXVOLUME}
+
+ // SDL_joystick.h constants
+ MAX_JOYSTICKS = 2; // only 2 are supported in the multimedia API
+{$EXTERNALSYM MAX_JOYSTICKS}
+ MAX_AXES = 6; // each joystick can have up to 6 axes
+{$EXTERNALSYM MAX_AXES}
+ MAX_BUTTONS = 32; // and 32 buttons
+{$EXTERNALSYM MAX_BUTTONS}
+ AXIS_MIN = -32768; // minimum value for axis coordinate
+{$EXTERNALSYM AXIS_MIN}
+ AXIS_MAX = 32767; // maximum value for axis coordinate
+{$EXTERNALSYM AXIS_MAX}
+ JOY_AXIS_THRESHOLD = (((AXIS_MAX) - (AXIS_MIN)) / 100); // 1% motion
+{$EXTERNALSYM JOY_AXIS_THRESHOLD}
+ //JOY_BUTTON_FLAG(n) (1<<n)
+ // array to hold joystick ID values
+ //static UInt SYS_JoystickID[MAX_JOYSTICKS];
+ //static JOYCAPS SYS_Joystick[MAX_JOYSTICKS];
+
+ { Get the current state of a POV hat on a joystick
+ The return value is one of the following positions: }
+ SDL_HAT_CENTERED = $00;
+{$EXTERNALSYM SDL_HAT_CENTERED}
+ SDL_HAT_UP = $01;
+{$EXTERNALSYM SDL_HAT_UP}
+ SDL_HAT_RIGHT = $02;
+{$EXTERNALSYM SDL_HAT_RIGHT}
+ SDL_HAT_DOWN = $04;
+{$EXTERNALSYM SDL_HAT_DOWN}
+ SDL_HAT_LEFT = $08;
+{$EXTERNALSYM SDL_HAT_LEFT}
+ SDL_HAT_RIGHTUP = SDL_HAT_RIGHT or SDL_HAT_UP;
+{$EXTERNALSYM SDL_HAT_RIGHTUP}
+ SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN;
+{$EXTERNALSYM SDL_HAT_RIGHTDOWN}
+ SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP;
+{$EXTERNALSYM SDL_HAT_LEFTUP}
+ SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN;
+{$EXTERNALSYM SDL_HAT_LEFTDOWN}
+
+ // SDL_events.h constants
+ SDL_NOEVENT = 0; // Unused (do not remove)
+{$EXTERNALSYM SDL_NOEVENT}
+ SDL_ACTIVEEVENT = 1; // Application loses/gains visibility
+{$EXTERNALSYM SDL_ACTIVEEVENT}
+ SDL_KEYDOWN = 2; // Keys pressed
+{$EXTERNALSYM SDL_KEYDOWN}
+ SDL_KEYUP = 3; // Keys released
+{$EXTERNALSYM SDL_KEYUP}
+ SDL_MOUSEMOTION = 4; // Mouse moved
+{$EXTERNALSYM SDL_MOUSEMOTION}
+ SDL_MOUSEBUTTONDOWN = 5; // Mouse button pressed
+{$EXTERNALSYM SDL_MOUSEBUTTONDOWN}
+ SDL_MOUSEBUTTONUP = 6; // Mouse button released
+{$EXTERNALSYM SDL_MOUSEBUTTONUP}
+ SDL_JOYAXISMOTION = 7; // Joystick axis motion
+{$EXTERNALSYM SDL_JOYAXISMOTION}
+ SDL_JOYBALLMOTION = 8; // Joystick trackball motion
+{$EXTERNALSYM SDL_JOYBALLMOTION}
+ SDL_JOYHATMOTION = 9; // Joystick hat position change
+{$EXTERNALSYM SDL_JOYHATMOTION}
+ SDL_JOYBUTTONDOWN = 10; // Joystick button pressed
+{$EXTERNALSYM SDL_JOYBUTTONDOWN}
+ SDL_JOYBUTTONUP = 11; // Joystick button released
+{$EXTERNALSYM SDL_JOYBUTTONUP}
+ SDL_QUITEV = 12; // User-requested quit ( Changed due to procedure conflict )
+{$EXTERNALSYM SDL_QUIT}
+ SDL_SYSWMEVENT = 13; // System specific event
+{$EXTERNALSYM SDL_SYSWMEVENT}
+ SDL_EVENT_RESERVEDA = 14; // Reserved for future use..
+{$EXTERNALSYM SDL_EVENT_RESERVEDA}
+ SDL_EVENT_RESERVED = 15; // Reserved for future use..
+{$EXTERNALSYM SDL_EVENT_RESERVED}
+ SDL_VIDEORESIZE = 16; // User resized video mode
+{$EXTERNALSYM SDL_VIDEORESIZE}
+ SDL_VIDEOEXPOSE = 17; // Screen needs to be redrawn
+{$EXTERNALSYM SDL_VIDEOEXPOSE}
+ SDL_EVENT_RESERVED2 = 18; // Reserved for future use..
+{$EXTERNALSYM SDL_EVENT_RESERVED2}
+ SDL_EVENT_RESERVED3 = 19; // Reserved for future use..
+{$EXTERNALSYM SDL_EVENT_RESERVED3}
+ SDL_EVENT_RESERVED4 = 20; // Reserved for future use..
+{$EXTERNALSYM SDL_EVENT_RESERVED4}
+ SDL_EVENT_RESERVED5 = 21; // Reserved for future use..
+{$EXTERNALSYM SDL_EVENT_RESERVED5}
+ SDL_EVENT_RESERVED6 = 22; // Reserved for future use..
+{$EXTERNALSYM SDL_EVENT_RESERVED6}
+ SDL_EVENT_RESERVED7 = 23; // Reserved for future use..
+{$EXTERNALSYM SDL_EVENT_RESERVED7}
+ // Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use
+ SDL_USEREVENT = 24;
+{$EXTERNALSYM SDL_USEREVENT}
+ // This last event is only for bounding internal arrays
+ // It is the number of bits in the event mask datatype -- UInt32
+ SDL_NUMEVENTS = 32;
+{$EXTERNALSYM SDL_NUMEVENTS}
+
+ SDL_ALLEVENTS = $FFFFFFFF;
+{$EXTERNALSYM SDL_ALLEVENTS}
+
+ SDL_ACTIVEEVENTMASK = 1 shl SDL_ACTIVEEVENT;
+{$EXTERNALSYM SDL_ACTIVEEVENTMASK}
+ SDL_KEYDOWNMASK = 1 shl SDL_KEYDOWN;
+{$EXTERNALSYM SDL_KEYDOWNMASK}
+ SDL_KEYUPMASK = 1 shl SDL_KEYUP;
+{$EXTERNALSYM SDL_KEYUPMASK}
+ SDL_MOUSEMOTIONMASK = 1 shl SDL_MOUSEMOTION;
+{$EXTERNALSYM SDL_MOUSEMOTIONMASK}
+ SDL_MOUSEBUTTONDOWNMASK = 1 shl SDL_MOUSEBUTTONDOWN;
+{$EXTERNALSYM SDL_MOUSEBUTTONDOWNMASK}
+ SDL_MOUSEBUTTONUPMASK = 1 shl SDL_MOUSEBUTTONUP;
+{$EXTERNALSYM SDL_MOUSEBUTTONUPMASK}
+ SDL_MOUSEEVENTMASK = 1 shl SDL_MOUSEMOTION or
+ 1 shl SDL_MOUSEBUTTONDOWN or
+ 1 shl SDL_MOUSEBUTTONUP;
+{$EXTERNALSYM SDL_MOUSEEVENTMASK}
+ SDL_JOYAXISMOTIONMASK = 1 shl SDL_JOYAXISMOTION;
+{$EXTERNALSYM SDL_JOYAXISMOTIONMASK}
+ SDL_JOYBALLMOTIONMASK = 1 shl SDL_JOYBALLMOTION;
+{$EXTERNALSYM SDL_JOYBALLMOTIONMASK}
+ SDL_JOYHATMOTIONMASK = 1 shl SDL_JOYHATMOTION;
+{$EXTERNALSYM SDL_JOYHATMOTIONMASK}
+ SDL_JOYBUTTONDOWNMASK = 1 shl SDL_JOYBUTTONDOWN;
+{$EXTERNALSYM SDL_JOYBUTTONDOWNMASK}
+ SDL_JOYBUTTONUPMASK = 1 shl SDL_JOYBUTTONUP;
+{$EXTERNALSYM SDL_JOYBUTTONUPMASK}
+ SDL_JOYEVENTMASK = 1 shl SDL_JOYAXISMOTION or
+ 1 shl SDL_JOYBALLMOTION or
+ 1 shl SDL_JOYHATMOTION or
+ 1 shl SDL_JOYBUTTONDOWN or
+ 1 shl SDL_JOYBUTTONUP;
+{$EXTERNALSYM SDL_JOYEVENTMASK}
+ SDL_VIDEORESIZEMASK = 1 shl SDL_VIDEORESIZE;
+{$EXTERNALSYM SDL_VIDEORESIZEMASK}
+ SDL_QUITMASK = 1 shl SDL_QUITEV;
+{$EXTERNALSYM SDL_QUITMASK}
+ SDL_SYSWMEVENTMASK = 1 shl SDL_SYSWMEVENT;
+{$EXTERNALSYM SDL_SYSWMEVENTMASK}
+
+ { This function allows you to set the state of processing certain events.
+ If 'state' is set to SDL_IGNORE, that event will be automatically dropped
+ from the event queue and will not event be filtered.
+ If 'state' is set to SDL_ENABLE, that event will be processed normally.
+ If 'state' is set to SDL_QUERY, SDL_EventState() will return the
+ current processing state of the specified event. }
+
+ SDL_QUERY = -1;
+{$EXTERNALSYM SDL_QUERY}
+ SDL_IGNORE = 0;
+{$EXTERNALSYM SDL_IGNORE}
+ SDL_DISABLE = 0;
+{$EXTERNALSYM SDL_DISABLE}
+ SDL_ENABLE = 1;
+{$EXTERNALSYM SDL_ENABLE}
+
+ //SDL_keyboard.h constants
+ // This is the mask which refers to all hotkey bindings
+ SDL_ALL_HOTKEYS = $FFFFFFFF;
+{$EXTERNALSYM SDL_ALL_HOTKEYS}
+
+{ Enable/Disable keyboard repeat. Keyboard repeat defaults to off.
+ 'delay' is the initial delay in ms between the time when a key is
+ pressed, and keyboard repeat begins.
+ 'interval' is the time in ms between keyboard repeat events. }
+
+ SDL_DEFAULT_REPEAT_DELAY = 500;
+{$EXTERNALSYM SDL_DEFAULT_REPEAT_DELAY}
+ SDL_DEFAULT_REPEAT_INTERVAL = 30;
+{$EXTERNALSYM SDL_DEFAULT_REPEAT_INTERVAL}
+
+ // The keyboard syms have been cleverly chosen to map to ASCII
+ SDLK_UNKNOWN = 0;
+{$EXTERNALSYM SDLK_UNKNOWN}
+ SDLK_FIRST = 0;
+{$EXTERNALSYM SDLK_FIRST}
+ SDLK_BACKSPACE = 8;
+{$EXTERNALSYM SDLK_BACKSPACE}
+ SDLK_TAB = 9;
+{$EXTERNALSYM SDLK_TAB}
+ SDLK_CLEAR = 12;
+{$EXTERNALSYM SDLK_CLEAR}
+ SDLK_RETURN = 13;
+{$EXTERNALSYM SDLK_RETURN}
+ SDLK_PAUSE = 19;
+{$EXTERNALSYM SDLK_PAUSE}
+ SDLK_ESCAPE = 27;
+{$EXTERNALSYM SDLK_ESCAPE}
+ SDLK_SPACE = 32;
+{$EXTERNALSYM SDLK_SPACE}
+ SDLK_EXCLAIM = 33;
+{$EXTERNALSYM SDLK_EXCLAIM}
+ SDLK_QUOTEDBL = 34;
+{$EXTERNALSYM SDLK_QUOTEDBL}
+ SDLK_HASH = 35;
+{$EXTERNALSYM SDLK_HASH}
+ SDLK_DOLLAR = 36;
+{$EXTERNALSYM SDLK_DOLLAR}
+ SDLK_AMPERSAND = 38;
+{$EXTERNALSYM SDLK_AMPERSAND}
+ SDLK_QUOTE = 39;
+{$EXTERNALSYM SDLK_QUOTE}
+ SDLK_LEFTPAREN = 40;
+{$EXTERNALSYM SDLK_LEFTPAREN}
+ SDLK_RIGHTPAREN = 41;
+{$EXTERNALSYM SDLK_RIGHTPAREN}
+ SDLK_ASTERISK = 42;
+{$EXTERNALSYM SDLK_ASTERISK}
+ SDLK_PLUS = 43;
+{$EXTERNALSYM SDLK_PLUS}
+ SDLK_COMMA = 44;
+{$EXTERNALSYM SDLK_COMMA}
+ SDLK_MINUS = 45;
+{$EXTERNALSYM SDLK_MINUS}
+ SDLK_PERIOD = 46;
+{$EXTERNALSYM SDLK_PERIOD}
+ SDLK_SLASH = 47;
+{$EXTERNALSYM SDLK_SLASH}
+ SDLK_0 = 48;
+{$EXTERNALSYM SDLK_0}
+ SDLK_1 = 49;
+{$EXTERNALSYM SDLK_1}
+ SDLK_2 = 50;
+{$EXTERNALSYM SDLK_2}
+ SDLK_3 = 51;
+{$EXTERNALSYM SDLK_3}
+ SDLK_4 = 52;
+{$EXTERNALSYM SDLK_4}
+ SDLK_5 = 53;
+{$EXTERNALSYM SDLK_5}
+ SDLK_6 = 54;
+{$EXTERNALSYM SDLK_6}
+ SDLK_7 = 55;
+{$EXTERNALSYM SDLK_7}
+ SDLK_8 = 56;
+{$EXTERNALSYM SDLK_8}
+ SDLK_9 = 57;
+{$EXTERNALSYM SDLK_9}
+ SDLK_COLON = 58;
+{$EXTERNALSYM SDLK_COLON}
+ SDLK_SEMICOLON = 59;
+{$EXTERNALSYM SDLK_SEMICOLON}
+ SDLK_LESS = 60;
+{$EXTERNALSYM SDLK_LESS}
+ SDLK_EQUALS = 61;
+{$EXTERNALSYM SDLK_EQUALS}
+ SDLK_GREATER = 62;
+{$EXTERNALSYM SDLK_GREATER}
+ SDLK_QUESTION = 63;
+{$EXTERNALSYM SDLK_QUESTION}
+ SDLK_AT = 64;
+{$EXTERNALSYM SDLK_AT}
+
+ { Skip uppercase letters }
+
+ SDLK_LEFTBRACKET = 91;
+{$EXTERNALSYM SDLK_LEFTBRACKET}
+ SDLK_BACKSLASH = 92;
+{$EXTERNALSYM SDLK_BACKSLASH}
+ SDLK_RIGHTBRACKET = 93;
+{$EXTERNALSYM SDLK_RIGHTBRACKET}
+ SDLK_CARET = 94;
+{$EXTERNALSYM SDLK_CARET}
+ SDLK_UNDERSCORE = 95;
+{$EXTERNALSYM SDLK_UNDERSCORE}
+ SDLK_BACKQUOTE = 96;
+{$EXTERNALSYM SDLK_BACKQUOTE}
+ SDLK_a = 97;
+{$EXTERNALSYM SDLK_a}
+ SDLK_b = 98;
+{$EXTERNALSYM SDLK_b}
+ SDLK_c = 99;
+{$EXTERNALSYM SDLK_c}
+ SDLK_d = 100;
+{$EXTERNALSYM SDLK_d}
+ SDLK_e = 101;
+{$EXTERNALSYM SDLK_e}
+ SDLK_f = 102;
+{$EXTERNALSYM SDLK_f}
+ SDLK_g = 103;
+{$EXTERNALSYM SDLK_g}
+ SDLK_h = 104;
+{$EXTERNALSYM SDLK_h}
+ SDLK_i = 105;
+{$EXTERNALSYM SDLK_i}
+ SDLK_j = 106;
+{$EXTERNALSYM SDLK_j}
+ SDLK_k = 107;
+{$EXTERNALSYM SDLK_k}
+ SDLK_l = 108;
+{$EXTERNALSYM SDLK_l}
+ SDLK_m = 109;
+{$EXTERNALSYM SDLK_m}
+ SDLK_n = 110;
+{$EXTERNALSYM SDLK_n}
+ SDLK_o = 111;
+{$EXTERNALSYM SDLK_o}
+ SDLK_p = 112;
+{$EXTERNALSYM SDLK_p}
+ SDLK_q = 113;
+{$EXTERNALSYM SDLK_q}
+ SDLK_r = 114;
+{$EXTERNALSYM SDLK_r}
+ SDLK_s = 115;
+{$EXTERNALSYM SDLK_s}
+ SDLK_t = 116;
+{$EXTERNALSYM SDLK_t}
+ SDLK_u = 117;
+{$EXTERNALSYM SDLK_u}
+ SDLK_v = 118;
+{$EXTERNALSYM SDLK_v}
+ SDLK_w = 119;
+{$EXTERNALSYM SDLK_w}
+ SDLK_x = 120;
+{$EXTERNALSYM SDLK_x}
+ SDLK_y = 121;
+{$EXTERNALSYM SDLK_y}
+ SDLK_z = 122;
+{$EXTERNALSYM SDLK_z}
+ SDLK_DELETE = 127;
+{$EXTERNALSYM SDLK_DELETE}
+ // End of ASCII mapped keysyms
+
+ // International keyboard syms
+ SDLK_WORLD_0 = 160; // 0xA0
+{$EXTERNALSYM SDLK_WORLD_0}
+ SDLK_WORLD_1 = 161;
+{$EXTERNALSYM SDLK_WORLD_1}
+ SDLK_WORLD_2 = 162;
+{$EXTERNALSYM SDLK_WORLD_2}
+ SDLK_WORLD_3 = 163;
+{$EXTERNALSYM SDLK_WORLD_3}
+ SDLK_WORLD_4 = 164;
+{$EXTERNALSYM SDLK_WORLD_4}
+ SDLK_WORLD_5 = 165;
+{$EXTERNALSYM SDLK_WORLD_5}
+ SDLK_WORLD_6 = 166;
+{$EXTERNALSYM SDLK_WORLD_6}
+ SDLK_WORLD_7 = 167;
+{$EXTERNALSYM SDLK_WORLD_7}
+ SDLK_WORLD_8 = 168;
+{$EXTERNALSYM SDLK_WORLD_8}
+ SDLK_WORLD_9 = 169;
+{$EXTERNALSYM SDLK_WORLD_9}
+ SDLK_WORLD_10 = 170;
+{$EXTERNALSYM SDLK_WORLD_10}
+ SDLK_WORLD_11 = 171;
+{$EXTERNALSYM SDLK_WORLD_11}
+ SDLK_WORLD_12 = 172;
+{$EXTERNALSYM SDLK_WORLD_12}
+ SDLK_WORLD_13 = 173;
+{$EXTERNALSYM SDLK_WORLD_13}
+ SDLK_WORLD_14 = 174;
+{$EXTERNALSYM SDLK_WORLD_14}
+ SDLK_WORLD_15 = 175;
+{$EXTERNALSYM SDLK_WORLD_15}
+ SDLK_WORLD_16 = 176;
+{$EXTERNALSYM SDLK_WORLD_16}
+ SDLK_WORLD_17 = 177;
+{$EXTERNALSYM SDLK_WORLD_17}
+ SDLK_WORLD_18 = 178;
+{$EXTERNALSYM SDLK_WORLD_18}
+ SDLK_WORLD_19 = 179;
+{$EXTERNALSYM SDLK_WORLD_19}
+ SDLK_WORLD_20 = 180;
+{$EXTERNALSYM SDLK_WORLD_20}
+ SDLK_WORLD_21 = 181;
+{$EXTERNALSYM SDLK_WORLD_21}
+ SDLK_WORLD_22 = 182;
+{$EXTERNALSYM SDLK_WORLD_22}
+ SDLK_WORLD_23 = 183;
+{$EXTERNALSYM SDLK_WORLD_23}
+ SDLK_WORLD_24 = 184;
+{$EXTERNALSYM SDLK_WORLD_24}
+ SDLK_WORLD_25 = 185;
+{$EXTERNALSYM SDLK_WORLD_25}
+ SDLK_WORLD_26 = 186;
+{$EXTERNALSYM SDLK_WORLD_26}
+ SDLK_WORLD_27 = 187;
+{$EXTERNALSYM SDLK_WORLD_27}
+ SDLK_WORLD_28 = 188;
+{$EXTERNALSYM SDLK_WORLD_28}
+ SDLK_WORLD_29 = 189;
+{$EXTERNALSYM SDLK_WORLD_29}
+ SDLK_WORLD_30 = 190;
+{$EXTERNALSYM SDLK_WORLD_30}
+ SDLK_WORLD_31 = 191;
+{$EXTERNALSYM SDLK_WORLD_31}
+ SDLK_WORLD_32 = 192;
+{$EXTERNALSYM SDLK_WORLD_32}
+ SDLK_WORLD_33 = 193;
+{$EXTERNALSYM SDLK_WORLD_33}
+ SDLK_WORLD_34 = 194;
+{$EXTERNALSYM SDLK_WORLD_34}
+ SDLK_WORLD_35 = 195;
+{$EXTERNALSYM SDLK_WORLD_35}
+ SDLK_WORLD_36 = 196;
+{$EXTERNALSYM SDLK_WORLD_36}
+ SDLK_WORLD_37 = 197;
+{$EXTERNALSYM SDLK_WORLD_37}
+ SDLK_WORLD_38 = 198;
+{$EXTERNALSYM SDLK_WORLD_38}
+ SDLK_WORLD_39 = 199;
+{$EXTERNALSYM SDLK_WORLD_39}
+ SDLK_WORLD_40 = 200;
+{$EXTERNALSYM SDLK_WORLD_40}
+ SDLK_WORLD_41 = 201;
+{$EXTERNALSYM SDLK_WORLD_41}
+ SDLK_WORLD_42 = 202;
+{$EXTERNALSYM SDLK_WORLD_42}
+ SDLK_WORLD_43 = 203;
+{$EXTERNALSYM SDLK_WORLD_43}
+ SDLK_WORLD_44 = 204;
+{$EXTERNALSYM SDLK_WORLD_44}
+ SDLK_WORLD_45 = 205;
+{$EXTERNALSYM SDLK_WORLD_45}
+ SDLK_WORLD_46 = 206;
+{$EXTERNALSYM SDLK_WORLD_46}
+ SDLK_WORLD_47 = 207;
+{$EXTERNALSYM SDLK_WORLD_47}
+ SDLK_WORLD_48 = 208;
+{$EXTERNALSYM SDLK_WORLD_48}
+ SDLK_WORLD_49 = 209;
+{$EXTERNALSYM SDLK_WORLD_49}
+ SDLK_WORLD_50 = 210;
+{$EXTERNALSYM SDLK_WORLD_50}
+ SDLK_WORLD_51 = 211;
+{$EXTERNALSYM SDLK_WORLD_51}
+ SDLK_WORLD_52 = 212;
+{$EXTERNALSYM SDLK_WORLD_52}
+ SDLK_WORLD_53 = 213;
+{$EXTERNALSYM SDLK_WORLD_53}
+ SDLK_WORLD_54 = 214;
+{$EXTERNALSYM SDLK_WORLD_54}
+ SDLK_WORLD_55 = 215;
+{$EXTERNALSYM SDLK_WORLD_55}
+ SDLK_WORLD_56 = 216;
+{$EXTERNALSYM SDLK_WORLD_56}
+ SDLK_WORLD_57 = 217;
+{$EXTERNALSYM SDLK_WORLD_57}
+ SDLK_WORLD_58 = 218;
+{$EXTERNALSYM SDLK_WORLD_58}
+ SDLK_WORLD_59 = 219;
+{$EXTERNALSYM SDLK_WORLD_59}
+ SDLK_WORLD_60 = 220;
+{$EXTERNALSYM SDLK_WORLD_60}
+ SDLK_WORLD_61 = 221;
+{$EXTERNALSYM SDLK_WORLD_61}
+ SDLK_WORLD_62 = 222;
+{$EXTERNALSYM SDLK_WORLD_62}
+ SDLK_WORLD_63 = 223;
+{$EXTERNALSYM SDLK_WORLD_63}
+ SDLK_WORLD_64 = 224;
+{$EXTERNALSYM SDLK_WORLD_64}
+ SDLK_WORLD_65 = 225;
+{$EXTERNALSYM SDLK_WORLD_65}
+ SDLK_WORLD_66 = 226;
+{$EXTERNALSYM SDLK_WORLD_66}
+ SDLK_WORLD_67 = 227;
+{$EXTERNALSYM SDLK_WORLD_67}
+ SDLK_WORLD_68 = 228;
+{$EXTERNALSYM SDLK_WORLD_68}
+ SDLK_WORLD_69 = 229;
+{$EXTERNALSYM SDLK_WORLD_69}
+ SDLK_WORLD_70 = 230;
+{$EXTERNALSYM SDLK_WORLD_70}
+ SDLK_WORLD_71 = 231;
+{$EXTERNALSYM SDLK_WORLD_71}
+ SDLK_WORLD_72 = 232;
+{$EXTERNALSYM SDLK_WORLD_72}
+ SDLK_WORLD_73 = 233;
+{$EXTERNALSYM SDLK_WORLD_73}
+ SDLK_WORLD_74 = 234;
+{$EXTERNALSYM SDLK_WORLD_74}
+ SDLK_WORLD_75 = 235;
+{$EXTERNALSYM SDLK_WORLD_75}
+ SDLK_WORLD_76 = 236;
+{$EXTERNALSYM SDLK_WORLD_76}
+ SDLK_WORLD_77 = 237;
+{$EXTERNALSYM SDLK_WORLD_77}
+ SDLK_WORLD_78 = 238;
+{$EXTERNALSYM SDLK_WORLD_78}
+ SDLK_WORLD_79 = 239;
+{$EXTERNALSYM SDLK_WORLD_79}
+ SDLK_WORLD_80 = 240;
+{$EXTERNALSYM SDLK_WORLD_80}
+ SDLK_WORLD_81 = 241;
+{$EXTERNALSYM SDLK_WORLD_81}
+ SDLK_WORLD_82 = 242;
+{$EXTERNALSYM SDLK_WORLD_82}
+ SDLK_WORLD_83 = 243;
+{$EXTERNALSYM SDLK_WORLD_83}
+ SDLK_WORLD_84 = 244;
+{$EXTERNALSYM SDLK_WORLD_84}
+ SDLK_WORLD_85 = 245;
+{$EXTERNALSYM SDLK_WORLD_85}
+ SDLK_WORLD_86 = 246;
+{$EXTERNALSYM SDLK_WORLD_86}
+ SDLK_WORLD_87 = 247;
+{$EXTERNALSYM SDLK_WORLD_87}
+ SDLK_WORLD_88 = 248;
+{$EXTERNALSYM SDLK_WORLD_88}
+ SDLK_WORLD_89 = 249;
+{$EXTERNALSYM SDLK_WORLD_89}
+ SDLK_WORLD_90 = 250;
+{$EXTERNALSYM SDLK_WORLD_90}
+ SDLK_WORLD_91 = 251;
+{$EXTERNALSYM SDLK_WORLD_91}
+ SDLK_WORLD_92 = 252;
+{$EXTERNALSYM SDLK_WORLD_92}
+ SDLK_WORLD_93 = 253;
+{$EXTERNALSYM SDLK_WORLD_93}
+ SDLK_WORLD_94 = 254;
+{$EXTERNALSYM SDLK_WORLD_94}
+ SDLK_WORLD_95 = 255; // 0xFF
+{$EXTERNALSYM SDLK_WORLD_95}
+
+ // Numeric keypad
+ SDLK_KP0 = 256;
+{$EXTERNALSYM SDLK_KP0}
+ SDLK_KP1 = 257;
+{$EXTERNALSYM SDLK_KP1}
+ SDLK_KP2 = 258;
+{$EXTERNALSYM SDLK_KP2}
+ SDLK_KP3 = 259;
+{$EXTERNALSYM SDLK_KP3}
+ SDLK_KP4 = 260;
+{$EXTERNALSYM SDLK_KP4}
+ SDLK_KP5 = 261;
+{$EXTERNALSYM SDLK_KP5}
+ SDLK_KP6 = 262;
+{$EXTERNALSYM SDLK_KP6}
+ SDLK_KP7 = 263;
+{$EXTERNALSYM SDLK_KP7}
+ SDLK_KP8 = 264;
+{$EXTERNALSYM SDLK_KP8}
+ SDLK_KP9 = 265;
+{$EXTERNALSYM SDLK_KP9}
+ SDLK_KP_PERIOD = 266;
+{$EXTERNALSYM SDLK_KP_PERIOD}
+ SDLK_KP_DIVIDE = 267;
+{$EXTERNALSYM SDLK_KP_DIVIDE}
+ SDLK_KP_MULTIPLY = 268;
+{$EXTERNALSYM SDLK_KP_MULTIPLY}
+ SDLK_KP_MINUS = 269;
+{$EXTERNALSYM SDLK_KP_MINUS}
+ SDLK_KP_PLUS = 270;
+{$EXTERNALSYM SDLK_KP_PLUS}
+ SDLK_KP_ENTER = 271;
+{$EXTERNALSYM SDLK_KP_ENTER}
+ SDLK_KP_EQUALS = 272;
+{$EXTERNALSYM SDLK_KP_EQUALS}
+
+ // Arrows + Home/End pad
+ SDLK_UP = 273;
+{$EXTERNALSYM SDLK_UP}
+ SDLK_DOWN = 274;
+{$EXTERNALSYM SDLK_DOWN}
+ SDLK_RIGHT = 275;
+{$EXTERNALSYM SDLK_RIGHT}
+ SDLK_LEFT = 276;
+{$EXTERNALSYM SDLK_LEFT}
+ SDLK_INSERT = 277;
+{$EXTERNALSYM SDLK_INSERT}
+ SDLK_HOME = 278;
+{$EXTERNALSYM SDLK_HOME}
+ SDLK_END = 279;
+{$EXTERNALSYM SDLK_END}
+ SDLK_PAGEUP = 280;
+{$EXTERNALSYM SDLK_PAGEUP}
+ SDLK_PAGEDOWN = 281;
+{$EXTERNALSYM SDLK_PAGEDOWN}
+
+ // Function keys
+ SDLK_F1 = 282;
+{$EXTERNALSYM SDLK_F1}
+ SDLK_F2 = 283;
+{$EXTERNALSYM SDLK_F2}
+ SDLK_F3 = 284;
+{$EXTERNALSYM SDLK_F3}
+ SDLK_F4 = 285;
+{$EXTERNALSYM SDLK_F4}
+ SDLK_F5 = 286;
+{$EXTERNALSYM SDLK_F5}
+ SDLK_F6 = 287;
+{$EXTERNALSYM SDLK_F6}
+ SDLK_F7 = 288;
+{$EXTERNALSYM SDLK_F7}
+ SDLK_F8 = 289;
+{$EXTERNALSYM SDLK_F8}
+ SDLK_F9 = 290;
+{$EXTERNALSYM SDLK_F9}
+ SDLK_F10 = 291;
+{$EXTERNALSYM SDLK_F10}
+ SDLK_F11 = 292;
+{$EXTERNALSYM SDLK_F11}
+ SDLK_F12 = 293;
+{$EXTERNALSYM SDLK_F12}
+ SDLK_F13 = 294;
+{$EXTERNALSYM SDLK_F13}
+ SDLK_F14 = 295;
+{$EXTERNALSYM SDLK_F14}
+ SDLK_F15 = 296;
+{$EXTERNALSYM SDLK_F15}
+
+ // Key state modifier keys
+ SDLK_NUMLOCK = 300;
+{$EXTERNALSYM SDLK_NUMLOCK}
+ SDLK_CAPSLOCK = 301;
+{$EXTERNALSYM SDLK_CAPSLOCK}
+ SDLK_SCROLLOCK = 302;
+{$EXTERNALSYM SDLK_SCROLLOCK}
+ SDLK_RSHIFT = 303;
+{$EXTERNALSYM SDLK_RSHIFT}
+ SDLK_LSHIFT = 304;
+{$EXTERNALSYM SDLK_LSHIFT}
+ SDLK_RCTRL = 305;
+{$EXTERNALSYM SDLK_RCTRL}
+ SDLK_LCTRL = 306;
+{$EXTERNALSYM SDLK_LCTRL}
+ SDLK_RALT = 307;
+{$EXTERNALSYM SDLK_RALT}
+ SDLK_LALT = 308;
+{$EXTERNALSYM SDLK_LALT}
+ SDLK_RMETA = 309;
+{$EXTERNALSYM SDLK_RMETA}
+ SDLK_LMETA = 310;
+{$EXTERNALSYM SDLK_LMETA}
+ SDLK_LSUPER = 311; // Left "Windows" key
+{$EXTERNALSYM SDLK_LSUPER}
+ SDLK_RSUPER = 312; // Right "Windows" key
+{$EXTERNALSYM SDLK_RSUPER}
+ SDLK_MODE = 313; // "Alt Gr" key
+{$EXTERNALSYM SDLK_MODE}
+ SDLK_COMPOSE = 314; // Multi-key compose key
+{$EXTERNALSYM SDLK_COMPOSE}
+
+ // Miscellaneous function keys
+ SDLK_HELP = 315;
+{$EXTERNALSYM SDLK_HELP}
+ SDLK_PRINT = 316;
+{$EXTERNALSYM SDLK_PRINT}
+ SDLK_SYSREQ = 317;
+{$EXTERNALSYM SDLK_SYSREQ}
+ SDLK_BREAK = 318;
+{$EXTERNALSYM SDLK_BREAK}
+ SDLK_MENU = 319;
+{$EXTERNALSYM SDLK_MENU}
+ SDLK_POWER = 320; // Power Macintosh power key
+{$EXTERNALSYM SDLK_POWER}
+ SDLK_EURO = 321; // Some european keyboards
+{$EXTERNALSYM SDLK_EURO}
+
+{$IFDEF GP2X}
+SDLK_GP2X_UP = 0;
+{$EXTERNALSYM SDLK_GP2X_UP}
+SDLK_GP2X_UPLEFT = 1;
+{$EXTERNALSYM SDLK_GP2X_UPLEFT}
+SDLK_GP2X_LEFT = 2;
+{$EXTERNALSYM SDLK_GP2X_LEFT}
+SDLK_GP2X_DOWNLEFT = 3;
+{$EXTERNALSYM SDLK_GP2X_DOWNLEFT}
+SDLK_GP2X_DOWN = 4;
+{$EXTERNALSYM SDLK_GP2X_DOWN}
+SDLK_GP2X_DOWNRIGHT = 5;
+{$EXTERNALSYM SDLK_GP2X_DOWNRIGHT}
+SDLK_GP2X_RIGHT = 6;
+{$EXTERNALSYM SDLK_GP2X_RIGHT}
+SDLK_GP2X_UPRIGHT = 7;
+{$EXTERNALSYM SDLK_GP2X_UPRIGHT}
+SDLK_GP2X_START = 8;
+{$EXTERNALSYM SDLK_GP2X_START}
+SDLK_GP2X_SELECT = 9;
+{$EXTERNALSYM SDLK_GP2X_SELECT}
+SDLK_GP2X_L = 10;
+{$EXTERNALSYM SDLK_GP2X_L}
+SDLK_GP2X_R = 11;
+{$EXTERNALSYM SDLK_GP2X_R}
+SDLK_GP2X_A = 12;
+{$EXTERNALSYM SDLK_GP2X_A}
+SDLK_GP2X_B = 13;
+{$EXTERNALSYM SDLK_GP2X_B}
+SDLK_GP2X_Y = 14;
+{$EXTERNALSYM SDLK_GP2X_Y}
+SDLK_GP2X_X = 15;
+{$EXTERNALSYM SDLK_GP2X_X}
+SDLK_GP2X_VOLUP = 16;
+{$EXTERNALSYM SDLK_GP2X_VOLUP}
+SDLK_GP2X_VOLDOWN = 17;
+{$EXTERNALSYM SDLK_GP2X_VOLDOWN}
+SDLK_GP2X_CLICK = 18;
+{$EXTERNALSYM SDLK_GP2X_CLICK}
+{$ENDIF}
+
+ // Enumeration of valid key mods (possibly OR'd together)
+ KMOD_NONE = $0000;
+{$EXTERNALSYM KMOD_NONE}
+ KMOD_LSHIFT = $0001;
+{$EXTERNALSYM KMOD_LSHIFT}
+ KMOD_RSHIFT = $0002;
+{$EXTERNALSYM KMOD_RSHIFT}
+ KMOD_LCTRL = $0040;
+{$EXTERNALSYM KMOD_LCTRL}
+ KMOD_RCTRL = $0080;
+{$EXTERNALSYM KMOD_RCTRL}
+ KMOD_LALT = $0100;
+{$EXTERNALSYM KMOD_LALT}
+ KMOD_RALT = $0200;
+{$EXTERNALSYM KMOD_RALT}
+ KMOD_LMETA = $0400;
+{$EXTERNALSYM KMOD_LMETA}
+ KMOD_RMETA = $0800;
+{$EXTERNALSYM KMOD_RMETA}
+ KMOD_NUM = $1000;
+{$EXTERNALSYM KMOD_NUM}
+ KMOD_CAPS = $2000;
+{$EXTERNALSYM KMOD_CAPS}
+ KMOD_MODE = 44000;
+{$EXTERNALSYM KMOD_MODE}
+ KMOD_RESERVED = $8000;
+{$EXTERNALSYM KMOD_RESERVED}
+
+ KMOD_CTRL = (KMOD_LCTRL or KMOD_RCTRL);
+{$EXTERNALSYM KMOD_CTRL}
+ KMOD_SHIFT = (KMOD_LSHIFT or KMOD_RSHIFT);
+{$EXTERNALSYM KMOD_SHIFT}
+ KMOD_ALT = (KMOD_LALT or KMOD_RALT);
+{$EXTERNALSYM KMOD_ALT}
+ KMOD_META = (KMOD_LMETA or KMOD_RMETA);
+{$EXTERNALSYM KMOD_META}
+
+ //SDL_video.h constants
+ // Transparency definitions: These define alpha as the opacity of a surface */
+ SDL_ALPHA_OPAQUE = 255;
+{$EXTERNALSYM SDL_ALPHA_OPAQUE}
+ SDL_ALPHA_TRANSPARENT = 0;
+{$EXTERNALSYM SDL_ALPHA_TRANSPARENT}
+
+ // These are the currently supported flags for the SDL_surface
+ // Available for SDL_CreateRGBSurface() or SDL_SetVideoMode()
+ SDL_SWSURFACE = $00000000; // Surface is in system memory
+{$EXTERNALSYM SDL_SWSURFACE}
+ SDL_HWSURFACE = $00000001; // Surface is in video memory
+{$EXTERNALSYM SDL_HWSURFACE}
+ SDL_ASYNCBLIT = $00000004; // Use asynchronous blits if possible
+{$EXTERNALSYM SDL_ASYNCBLIT}
+ // Available for SDL_SetVideoMode()
+ SDL_ANYFORMAT = $10000000; // Allow any video depth/pixel-format
+{$EXTERNALSYM SDL_ANYFORMAT}
+ SDL_HWPALETTE = $20000000; // Surface has exclusive palette
+{$EXTERNALSYM SDL_HWPALETTE}
+ SDL_DOUBLEBUF = $40000000; // Set up double-buffered video mode
+{$EXTERNALSYM SDL_DOUBLEBUF}
+ SDL_FULLSCREEN = $80000000; // Surface is a full screen display
+{$EXTERNALSYM SDL_FULLSCREEN}
+ SDL_OPENGL = $00000002; // Create an OpenGL rendering context
+{$EXTERNALSYM SDL_OPENGL}
+ SDL_OPENGLBLIT = $00000002; // Create an OpenGL rendering context
+{$EXTERNALSYM SDL_OPENGLBLIT}
+ SDL_RESIZABLE = $00000010; // This video mode may be resized
+{$EXTERNALSYM SDL_RESIZABLE}
+ SDL_NOFRAME = $00000020; // No window caption or edge frame
+{$EXTERNALSYM SDL_NOFRAME}
+ // Used internally (read-only)
+ SDL_HWACCEL = $00000100; // Blit uses hardware acceleration
+{$EXTERNALSYM SDL_HWACCEL}
+ SDL_SRCCOLORKEY = $00001000; // Blit uses a source color key
+{$EXTERNALSYM SDL_SRCCOLORKEY}
+ SDL_RLEACCELOK = $00002000; // Private flag
+{$EXTERNALSYM SDL_RLEACCELOK}
+ SDL_RLEACCEL = $00004000; // Colorkey blit is RLE accelerated
+{$EXTERNALSYM SDL_RLEACCEL}
+ SDL_SRCALPHA = $00010000; // Blit uses source alpha blending
+{$EXTERNALSYM SDL_SRCALPHA}
+ SDL_SRCCLIPPING = $00100000; // Blit uses source clipping
+{$EXTERNALSYM SDL_SRCCLIPPING}
+ SDL_PREALLOC = $01000000; // Surface uses preallocated memory
+{$EXTERNALSYM SDL_PREALLOC}
+
+ { The most common video overlay formats.
+ For an explanation of these pixel formats, see:
+ http://www.webartz.com/fourcc/indexyuv.htm
+
+ For information on the relationship between color spaces, see:
+ http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html }
+
+ SDL_YV12_OVERLAY = $32315659; // Planar mode: Y + V + U (3 planes)
+{$EXTERNALSYM SDL_YV12_OVERLAY}
+ SDL_IYUV_OVERLAY = $56555949; // Planar mode: Y + U + V (3 planes)
+{$EXTERNALSYM SDL_IYUV_OVERLAY}
+ SDL_YUY2_OVERLAY = $32595559; // Packed mode: Y0+U0+Y1+V0 (1 plane)
+{$EXTERNALSYM SDL_YUY2_OVERLAY}
+ SDL_UYVY_OVERLAY = $59565955; // Packed mode: U0+Y0+V0+Y1 (1 plane)
+{$EXTERNALSYM SDL_UYVY_OVERLAY}
+ SDL_YVYU_OVERLAY = $55595659; // Packed mode: Y0+V0+Y1+U0 (1 plane)
+{$EXTERNALSYM SDL_YVYU_OVERLAY}
+
+ // flags for SDL_SetPalette()
+ SDL_LOGPAL = $01;
+{$EXTERNALSYM SDL_LOGPAL}
+ SDL_PHYSPAL = $02;
+{$EXTERNALSYM SDL_PHYSPAL}
+
+ //SDL_mouse.h constants
+ { Used as a mask when testing buttons in buttonstate
+ Button 1: Left mouse button
+ Button 2: Middle mouse button
+ Button 3: Right mouse button
+ Button 4: Mouse Wheel Up (may also be a real button)
+ Button 5: Mouse Wheel Down (may also be a real button)
+ Button 6: Mouse X1 (may also be a real button)
+ Button 7: Mouse X2 (may also be a real button)
+ }
+ SDL_BUTTON_LEFT = 1;
+{$EXTERNALSYM SDL_BUTTON_LEFT}
+ SDL_BUTTON_MIDDLE = 2;
+{$EXTERNALSYM SDL_BUTTON_MIDDLE}
+ SDL_BUTTON_RIGHT = 3;
+{$EXTERNALSYM SDL_BUTTON_RIGHT}
+ SDL_BUTTON_WHEELUP = 4;
+{$EXTERNALSYM SDL_BUTTON_WHEELUP}
+ SDL_BUTTON_WHEELDOWN = 5;
+{$EXTERNALSYM SDL_BUTTON_WHEELDOWN}
+ SDL_BUTTON_X1 = 6;
+{$EXTERNALSYM SDL_BUTTON_X1}
+ SDL_BUTTON_X2 = 7;
+{$EXTERNALSYM SDL_BUTTON_X2}
+
+ SDL_BUTTON_LMASK = SDL_PRESSED shl (SDL_BUTTON_LEFT - 1);
+{$EXTERNALSYM SDL_BUTTON_LMASK}
+ SDL_BUTTON_MMASK = SDL_PRESSED shl (SDL_BUTTON_MIDDLE - 1);
+{$EXTERNALSYM SDL_BUTTON_MMASK}
+ SDL_BUTTON_RMASK = SDL_PRESSED shl (SDL_BUTTON_RIGHT - 1);
+{$EXTERNALSYM SDL_BUTTON_RMASK}
+ SDL_BUTTON_X1MASK = SDL_PRESSED shl (SDL_BUTTON_X1 - 1);
+{$EXTERNALSYM SDL_BUTTON_X1MASK}
+ SDL_BUTTON_X2MASK = SDL_PRESSED shl (SDL_BUTTON_X2 - 1);
+{$EXTERNALSYM SDL_BUTTON_X2MASK}
+
+ // SDL_active.h constants
+ // The available application states
+ SDL_APPMOUSEFOCUS = $01; // The app has mouse coverage
+{$EXTERNALSYM SDL_APPMOUSEFOCUS}
+ SDL_APPINPUTFOCUS = $02; // The app has input focus
+{$EXTERNALSYM SDL_APPINPUTFOCUS}
+ SDL_APPACTIVE = $04; // The application is active
+{$EXTERNALSYM SDL_APPACTIVE}
+
+ // SDL_mutex.h constants
+ // Synchronization functions which can time out return this value
+ // they time out.
+
+ SDL_MUTEX_TIMEDOUT = 1;
+{$EXTERNALSYM SDL_MUTEX_TIMEDOUT}
+
+ // This is the timeout value which corresponds to never time out
+ SDL_MUTEX_MAXWAIT = not Cardinal(0);
+{$EXTERNALSYM SDL_MUTEX_MAXWAIT}
+
+ {TSDL_GrabMode = (
+ SDL_GRAB_QUERY,
+ SDL_GRAB_OFF,
+ SDL_GRAB_ON,
+ SDL_GRAB_FULLSCREEN ); // Used internally}
+ SDL_GRAB_QUERY = -1;
+ SDL_GRAB_OFF = 0;
+ SDL_GRAB_ON = 1;
+ //SDL_GRAB_FULLSCREEN // Used internally
+
+type
+ THandle = Cardinal;
+ //SDL_types.h types
+ // Basic data types
+
+ SDL_Bool = (SDL_FALSE, SDL_TRUE);
+ TSDL_Bool = SDL_Bool;
+
+ PUInt8Array = ^TUInt8Array;
+ PUInt8 = ^UInt8;
+ PPUInt8 = ^PUInt8;
+ UInt8 = Byte;
+{$EXTERNALSYM UInt8}
+ TUInt8Array = array [0..MAXINT shr 1] of UInt8;
+
+ PUInt16 = ^UInt16;
+ UInt16 = word;
+{$EXTERNALSYM UInt16}
+
+ PSInt8 = ^SInt8;
+ SInt8 = Shortint;
+{$EXTERNALSYM SInt8}
+
+ PSInt16 = ^SInt16;
+ SInt16 = smallint;
+{$EXTERNALSYM SInt16}
+
+ PUInt32 = ^UInt32;
+ UInt32 = Cardinal;
+{$EXTERNALSYM UInt32}
+
+ SInt32 = Integer;
+{$EXTERNALSYM SInt32}
+
+ PInt = ^Integer;
+
+ PShortInt = ^ShortInt;
+
+ PUInt64 = ^UInt64;
+ UInt64 = record
+ hi: UInt32;
+ lo: UInt32;
+ end;
+{$EXTERNALSYM UInt64}
+
+ PSInt64 = ^SInt64;
+ SInt64 = record
+ hi: UInt32;
+ lo: UInt32;
+ end;
+{$EXTERNALSYM SInt64}
+
+ TSDL_GrabMode = Integer;
+
+ // SDL_error.h types
+ TSDL_errorcode = (
+ SDL_ENOMEM,
+ SDL_EFREAD,
+ SDL_EFWRITE,
+ SDL_EFSEEK,
+ SDL_LASTERROR);
+
+ SDL_errorcode = TSDL_errorcode;
+{$EXTERNALSYM SDL_errorcode}
+
+ TArg = record
+ case Byte of
+ 0: (value_ptr: Pointer);
+ (* #if 0 means: never
+ 1 : ( value_c : Byte );
+ *)
+ 2: (value_i: Integer);
+ 3: (value_f: double);
+ 4: (buf: array[0..ERR_MAX_STRLEN - 1] of Byte);
+ end;
+
+ PSDL_error = ^TSDL_error;
+ TSDL_error = record
+ { This is a numeric value corresponding to the current error }
+ error: Integer;
+
+ { This is a key used to index into a language hashtable containing
+ internationalized versions of the SDL error messages. If the key
+ is not in the hashtable, or no hashtable is available, the key is
+ used directly as an error message format string. }
+ key: array[0..ERR_MAX_STRLEN - 1] of Byte;
+
+ { These are the arguments for the error functions }
+ argc: Integer;
+ args: array[0..ERR_MAX_ARGS - 1] of TArg;
+ end;
+
+ // SDL_rwops.h types
+ // This is the read/write operation structure -- very basic
+ // some helper types to handle the unions
+ // "packed" is only guessed
+
+ TStdio = record
+ autoclose: Integer;
+ // FILE * is only defined in Kylix so we use a simple Pointer
+ fp: Pointer;
+ end;
+
+ TMem = record
+ base: PUInt8;
+ here: PUInt8;
+ stop: PUInt8;
+ end;
+
+ TUnknown = record
+ data1: Pointer;
+ end;
+
+ // first declare the pointer type
+ PSDL_RWops = ^TSDL_RWops;
+ // now the pointer to function types
+ {$IFNDEF __GPC__}
+ TSeek = function( context: PSDL_RWops; offset: Integer; whence: Integer ): Integer; cdecl;
+ TRead = function( context: PSDL_RWops; Ptr: Pointer; size: Integer; maxnum : Integer ): Integer; cdecl;
+ TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: Integer; num: Integer ): Integer; cdecl;
+ TClose = function( context: PSDL_RWops ): Integer; cdecl;
+ {$ELSE}
+ TSeek = function( context: PSDL_RWops; offset: Integer; whence: Integer ): Integer;
+ TRead = function( context: PSDL_RWops; Ptr: Pointer; size: Integer; maxnum : Integer ): Integer;
+ TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: Integer; num: Integer ): Integer;
+ TClose = function( context: PSDL_RWops ): Integer;
+ {$ENDIF}
+ // the variant record itself
+ TSDL_RWops = record
+ seek: TSeek;
+ read: TRead;
+ write: TWrite;
+ close: TClose;
+ // a keyword as name is not allowed
+ type_: UInt32;
+ // be warned! structure alignment may arise at this point
+ case Integer of
+ 0: (stdio: TStdio);
+ 1: (mem: TMem);
+ 2: (unknown: TUnknown);
+ end;
+
+ SDL_RWops = TSDL_RWops;
+{$EXTERNALSYM SDL_RWops}
+
+
+ // SDL_timer.h types
+ // Function prototype for the timer callback function
+ {$IFNDEF __GPC__}
+ TSDL_TimerCallback = function( interval: UInt32 ): UInt32; cdecl;
+ {$ELSE}
+ TSDL_TimerCallback = function( interval: UInt32 ): UInt32;
+ {$ENDIF}
+
+ { New timer API, supports multiple timers
+ Written by Stephane Peter <megastep@lokigames.com> }
+
+ { Function prototype for the new timer callback function.
+ The callback function is passed the current timer interval and returns
+ the next timer interval. If the returned value is the same as the one
+ passed in, the periodic alarm continues, otherwise a new alarm is
+ scheduled. If the callback returns 0, the periodic alarm is cancelled. }
+ {$IFNDEF __GPC__}
+ TSDL_NewTimerCallback = function( interval: UInt32; param: Pointer ): UInt32; cdecl;
+ {$ELSE}
+ TSDL_NewTimerCallback = function( interval: UInt32; param: Pointer ): UInt32;
+ {$ENDIF}
+
+ // Definition of the timer ID type
+ PSDL_TimerID = ^TSDL_TimerID;
+ TSDL_TimerID = record
+ interval: UInt32;
+ callback: TSDL_NewTimerCallback;
+ param: Pointer;
+ last_alarm: UInt32;
+ next: PSDL_TimerID;
+ end;
+
+ {$IFNDEF __GPC__}
+ TSDL_AudioSpecCallback = procedure( userdata: Pointer; stream: PUInt8; len: Integer ); cdecl;
+ {$ELSE}
+ TSDL_AudioSpecCallback = procedure( userdata: Pointer; stream: PUInt8; len: Integer );
+ {$ENDIF}
+
+ // SDL_audio.h types
+ // The calculated values in this structure are calculated by SDL_OpenAudio()
+ PSDL_AudioSpec = ^TSDL_AudioSpec;
+ TSDL_AudioSpec = record
+ freq: Integer; // DSP frequency -- samples per second
+ format: UInt16; // Audio data format
+ channels: UInt8; // Number of channels: 1 mono, 2 stereo
+ silence: UInt8; // Audio buffer silence value (calculated)
+ samples: UInt16; // Audio buffer size in samples
+ padding: UInt16; // Necessary for some compile environments
+ size: UInt32; // Audio buffer size in bytes (calculated)
+ { This function is called when the audio device needs more data.
+ 'stream' is a pointer to the audio data buffer
+ 'len' is the length of that buffer in bytes.
+ Once the callback returns, the buffer will no longer be valid.
+ Stereo samples are stored in a LRLRLR ordering.}
+ callback: TSDL_AudioSpecCallback;
+ userdata: Pointer;
+ end;
+
+ // A structure to hold a set of audio conversion filters and buffers
+ PSDL_AudioCVT = ^TSDL_AudioCVT;
+
+ PSDL_AudioCVTFilter = ^TSDL_AudioCVTFilter;
+ TSDL_AudioCVTFilter = record
+ cvt: PSDL_AudioCVT;
+ format: UInt16;
+ end;
+
+ PSDL_AudioCVTFilterArray = ^TSDL_AudioCVTFilterArray;
+ TSDL_AudioCVTFilterArray = array[0..9] of PSDL_AudioCVTFilter;
+
+ TSDL_AudioCVT = record
+ needed: Integer; // Set to 1 if conversion possible
+ src_format: UInt16; // Source audio format
+ dst_format: UInt16; // Target audio format
+ rate_incr: double; // Rate conversion increment
+ buf: PUInt8; // Buffer to hold entire audio data
+ len: Integer; // Length of original audio buffer
+ len_cvt: Integer; // Length of converted audio buffer
+ len_mult: Integer; // buffer must be len*len_mult big
+ len_ratio: double; // Given len, final size is len*len_ratio
+ filters: TSDL_AudioCVTFilterArray;
+ filter_index: Integer; // Current audio conversion function
+ end;
+
+ TSDL_Audiostatus = (
+ SDL_AUDIO_STOPPED,
+ SDL_AUDIO_PLAYING,
+ SDL_AUDIO_PAUSED
+ );
+
+ // SDL_cdrom.h types
+ TSDL_CDStatus = (
+ CD_ERROR,
+ CD_TRAYEMPTY,
+ CD_STOPPED,
+ CD_PLAYING,
+ CD_PAUSED );
+
+ PSDL_CDTrack = ^TSDL_CDTrack;
+ TSDL_CDTrack = record
+ id: UInt8; // Track number
+ type_: UInt8; // Data or audio track
+ unused: UInt16;
+ length: UInt32; // Length, in frames, of this track
+ offset: UInt32; // Offset, in frames, from start of disk
+ end;
+
+ // This structure is only current as of the last call to SDL_CDStatus()
+ PSDL_CD = ^TSDL_CD;
+ TSDL_CD = record
+ id: Integer; // Private drive identifier
+ status: TSDL_CDStatus; // Current drive status
+
+ // The rest of this structure is only valid if there's a CD in drive
+ numtracks: Integer; // Number of tracks on disk
+ cur_track: Integer; // Current track position
+ cur_frame: Integer; // Current frame offset within current track
+ track: array[0..SDL_MAX_TRACKS] of TSDL_CDTrack;
+ end;
+
+ //SDL_joystick.h types
+ PTransAxis = ^TTransAxis;
+ TTransAxis = record
+ offset: Integer;
+ scale: single;
+ end;
+
+ // The private structure used to keep track of a joystick
+ PJoystick_hwdata = ^TJoystick_hwdata;
+ TJoystick_hwdata = record
+ // joystick ID
+ id: Integer;
+ // values used to translate device-specific coordinates into SDL-standard ranges
+ transaxis: array[0..5] of TTransAxis;
+ end;
+
+ PBallDelta = ^TBallDelta;
+ TBallDelta = record
+ dx: Integer;
+ dy: Integer;
+ end; // Current ball motion deltas
+
+ // The SDL joystick structure
+ PSDL_Joystick = ^TSDL_Joystick;
+ TSDL_Joystick = record
+ index: UInt8; // Device index
+ name: PChar; // Joystick name - system dependent
+
+ naxes: Integer; // Number of axis controls on the joystick
+ axes: PUInt16; // Current axis states
+
+ nhats: Integer; // Number of hats on the joystick
+ hats: PUInt8; // Current hat states
+
+ nballs: Integer; // Number of trackballs on the joystick
+ balls: PBallDelta; // Current ball motion deltas
+
+ nbuttons: Integer; // Number of buttons on the joystick
+ buttons: PUInt8; // Current button states
+
+ hwdata: PJoystick_hwdata; // Driver dependent information
+
+ ref_count: Integer; // Reference count for multiple opens
+ end;
+
+ // SDL_verion.h types
+ PSDL_version = ^TSDL_version;
+ TSDL_version = record
+ major: UInt8;
+ minor: UInt8;
+ patch: UInt8;
+ end;
+
+ // SDL_keyboard.h types
+ TSDLKey = LongWord;
+
+ TSDLMod = LongWord;
+
+ PSDL_KeySym = ^TSDL_KeySym;
+ TSDL_KeySym = record
+ scancode: UInt8; // hardware specific scancode
+ sym: TSDLKey; // SDL virtual keysym
+ modifier: TSDLMod; // current key modifiers
+ unicode: UInt16; // translated character
+ end;
+
+ // SDL_events.h types
+ {Checks the event queue for messages and optionally returns them.
+ If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
+ the back of the event queue.
+ If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
+ of the event queue, matching 'mask', will be returned and will not
+ be removed from the queue.
+ If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
+ of the event queue, matching 'mask', will be returned and will be
+ removed from the queue.
+ This function returns the number of events actually stored, or -1
+ if there was an error. This function is thread-safe. }
+
+ TSDL_EventAction = (SDL_ADDEVENT, SDL_PEEKEVENT, SDL_GETEVENT);
+
+ // Application visibility event structure
+ TSDL_ActiveEvent = record
+ type_: UInt8; // SDL_ACTIVEEVENT
+ gain: UInt8; // Whether given states were gained or lost (1/0)
+ state: UInt8; // A mask of the focus states
+ end;
+
+ // Keyboard event structure
+ TSDL_KeyboardEvent = record
+ type_: UInt8; // SDL_KEYDOWN or SDL_KEYUP
+ which: UInt8; // The keyboard device index
+ state: UInt8; // SDL_PRESSED or SDL_RELEASED
+ keysym: TSDL_KeySym;
+ end;
+
+ // Mouse motion event structure
+ TSDL_MouseMotionEvent = record
+ type_: UInt8; // SDL_MOUSEMOTION
+ which: UInt8; // The mouse device index
+ state: UInt8; // The current button state
+ x, y: UInt16; // The X/Y coordinates of the mouse
+ xrel: SInt16; // The relative motion in the X direction
+ yrel: SInt16; // The relative motion in the Y direction
+ end;
+
+ // Mouse button event structure
+ TSDL_MouseButtonEvent = record
+ type_: UInt8; // SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
+ which: UInt8; // The mouse device index
+ button: UInt8; // The mouse button index
+ state: UInt8; // SDL_PRESSED or SDL_RELEASED
+ x: UInt16; // The X coordinates of the mouse at press time
+ y: UInt16; // The Y coordinates of the mouse at press time
+ end;
+
+ // Joystick axis motion event structure
+ TSDL_JoyAxisEvent = record
+ type_: UInt8; // SDL_JOYAXISMOTION
+ which: UInt8; // The joystick device index
+ axis: UInt8; // The joystick axis index
+ value: SInt16; // The axis value (range: -32768 to 32767)
+ end;
+
+ // Joystick trackball motion event structure
+ TSDL_JoyBallEvent = record
+ type_: UInt8; // SDL_JOYAVBALLMOTION
+ which: UInt8; // The joystick device index
+ ball: UInt8; // The joystick trackball index
+ xrel: SInt16; // The relative motion in the X direction
+ yrel: SInt16; // The relative motion in the Y direction
+ end;
+
+ // Joystick hat position change event structure
+ TSDL_JoyHatEvent = record
+ type_: UInt8; // SDL_JOYHATMOTION */
+ which: UInt8; // The joystick device index */
+ hat: UInt8; // The joystick hat index */
+ value: UInt8; { The hat position value:
+ 8 1 2
+ 7 0 3
+ 6 5 4
+
+ Note that zero means the POV is centered. }
+
+ end;
+
+ // Joystick button event structure
+ TSDL_JoyButtonEvent = record
+ type_: UInt8; // SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
+ which: UInt8; // The joystick device index
+ button: UInt8; // The joystick button index
+ state: UInt8; // SDL_PRESSED or SDL_RELEASED
+ end;
+
+ { The "window resized" event
+ When you get this event, you are responsible for setting a new video
+ mode with the new width and height. }
+ TSDL_ResizeEvent = record
+ type_: UInt8; // SDL_VIDEORESIZE
+ w: Integer; // New width
+ h: Integer; // New height
+ end;
+
+ // The "quit requested" event
+ PSDL_QuitEvent = ^TSDL_QuitEvent;
+ TSDL_QuitEvent = record
+ type_: UInt8;
+ end;
+
+ // A user-defined event type
+ PSDL_UserEvent = ^TSDL_UserEvent;
+ TSDL_UserEvent = record
+ type_: UInt8; // SDL_USEREVENT through SDL_NUMEVENTS-1
+ code: Integer; // User defined event code */
+ data1: Pointer; // User defined data pointer */
+ data2: Pointer; // User defined data pointer */
+ end;
+
+ // The "screen redraw" event
+ PSDL_ExposeEvent = ^TSDL_ExposeEvent;
+ TSDL_ExposeEvent = record
+ type_ : Uint8; // SDL_VIDEOEXPOSE
+ end;
+
+ {$IFDEF Unix}
+ //These are the various supported subsystems under UNIX
+ TSDL_SysWm = ( SDL_SYSWM_X11 ) ;
+ {$ENDIF}
+
+// The windows custom event structure
+{$IFDEF WINDOWS}
+ PSDL_SysWMmsg = ^TSDL_SysWMmsg;
+ TSDL_SysWMmsg = record
+ version: TSDL_version;
+ h_wnd: HWND; // The window for the message
+ msg: UInt; // The type of message
+ w_Param: WPARAM; // WORD message parameter
+ lParam: LPARAM; // LONG message parameter
+ end;
+{$ELSE}
+
+{$IFDEF Unix}
+{ The Linux custom event structure }
+ PSDL_SysWMmsg = ^TSDL_SysWMmsg;
+ TSDL_SysWMmsg = record
+ version : TSDL_version;
+ subsystem : TSDL_SysWm;
+ {$IFDEF FPC}
+ {$IFNDEF GP2X}
+ {$IFNDEF DARWIN}
+ {$IFNDEF SKYOS}
+ event : TXEvent;
+ {$ENDIF}
+ {$ENDIF}
+ {$ENDIF}
+ {$ELSE}
+ event : XEvent;
+ {$ENDIF}
+ end;
+{$ELSE}
+{ The generic custom event structure }
+ PSDL_SysWMmsg = ^TSDL_SysWMmsg;
+ TSDL_SysWMmsg = record
+ version: TSDL_version;
+ data: Integer;
+ end;
+{$ENDIF}
+
+{$ENDIF}
+
+// The Windows custom window manager information structure
+{$IFDEF WINDOWS}
+ PSDL_SysWMinfo = ^TSDL_SysWMinfo;
+ TSDL_SysWMinfo = record
+ version : TSDL_version;
+ window : HWnd; // The display window
+ end;
+{$ELSE}
+
+// The Linux custom window manager information structure
+{$IFDEF Unix}
+ {$IFNDEF GP2X}
+ {$IFNDEF DARWIN}
+ {$IFNDEF SKYOS}
+ TX11 = record
+ display : PDisplay; // The X11 display
+ window : TWindow ; // The X11 display window */
+ {* These locking functions should be called around
+ any X11 functions using the display variable.
+ They lock the event thread, so should not be
+ called around event functions or from event filters.
+ *}
+ lock_func : Pointer;
+ unlock_func : Pointer;
+
+ // Introduced in SDL 1.0.2
+ fswindow : TWindow ; // The X11 fullscreen window */
+ wmwindow : TWindow ; // The X11 managed input window */
+ end;
+ {$ENDIF}
+ {$ENDIF}
+ {$ENDIF}
+
+ PSDL_SysWMinfo = ^TSDL_SysWMinfo;
+ TSDL_SysWMinfo = record
+ version : TSDL_version ;
+ subsystem : TSDL_SysWm;
+ {$IFNDEF GP2X}
+ {$IFNDEF DARWIN}
+ {$IFNDEF SKYOS}
+ X11 : TX11;
+ {$ENDIF}
+ {$ENDIF}
+ {$ENDIF}
+ end;
+{$ELSE}
+ // The generic custom window manager information structure
+ PSDL_SysWMinfo = ^TSDL_SysWMinfo;
+ TSDL_SysWMinfo = record
+ version : TSDL_version ;
+ data : integer;
+ end;
+{$ENDIF}
+
+{$ENDIF}
+
+ PSDL_SysWMEvent = ^TSDL_SysWMEvent;
+ TSDL_SysWMEvent = record
+ type_: UInt8;
+ msg: PSDL_SysWMmsg;
+ end;
+
+ PSDL_Event = ^TSDL_Event;
+ TSDL_Event = record
+ case UInt8 of
+ SDL_NOEVENT: (type_: byte);
+ SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
+ SDL_KEYDOWN, SDL_KEYUP: (key: TSDL_KeyboardEvent);
+ SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
+ SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent );
+ SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent );
+ SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent );
+ SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent );
+ SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent );
+ SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent );
+ SDL_QUITEV: (quit: TSDL_QuitEvent );
+ SDL_USEREVENT : ( user : TSDL_UserEvent );
+ SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent );
+ end;
+
+
+{ This function sets up a filter to process all events before they
+ change internal state and are posted to the internal event queue.
+
+ The filter is protypted as: }
+ {$IFNDEF __GPC__}
+ TSDL_EventFilter = function( event : PSDL_Event ): Integer; cdecl;
+ {$ELSE}
+ TSDL_EventFilter = function( event : PSDL_Event ): Integer;
+ {$ENDIF}
+
+ // SDL_video.h types
+ // Useful data types
+ PPSDL_Rect = ^PSDL_Rect;
+ PSDL_Rect = ^TSDL_Rect;
+ TSDL_Rect = record
+ x, y: SInt16;
+ w, h: UInt16;
+ end;
+
+ SDL_Rect = TSDL_Rect;
+{$EXTERNALSYM SDL_Rect}
+
+ PSDL_Color = ^TSDL_Color;
+ TSDL_Color = record
+ r: UInt8;
+ g: UInt8;
+ b: UInt8;
+ unused: UInt8;
+ end;
+
+ PSDL_ColorArray = ^TSDL_ColorArray;
+ TSDL_ColorArray = array[0..65000] of TSDL_Color;
+
+ PSDL_Palette = ^TSDL_Palette;
+ TSDL_Palette = record
+ ncolors: Integer;
+ colors: PSDL_ColorArray;
+ end;
+
+ // Everything in the pixel format structure is read-only
+ PSDL_PixelFormat = ^TSDL_PixelFormat;
+ TSDL_PixelFormat = record
+ palette: PSDL_Palette;
+ BitsPerPixel: UInt8;
+ BytesPerPixel: UInt8;
+ Rloss: UInt8;
+ Gloss: UInt8;
+ Bloss: UInt8;
+ Aloss: UInt8;
+ Rshift: UInt8;
+ Gshift: UInt8;
+ Bshift: UInt8;
+ Ashift: UInt8;
+ RMask: UInt32;
+ GMask: UInt32;
+ BMask: UInt32;
+ AMask: UInt32;
+ colorkey: UInt32; // RGB color key information
+ alpha: UInt8; // Alpha value information (per-surface alpha)
+ end;
+
+{$IFDEF WINDOWS}
+ {PPrivate_hwdata = ^TPrivate_hwdata;
+ TPrivate_hwdata = record
+ dd_surface : IDIRECTDRAWSURFACE3;
+ dd_writebuf : IDIRECTDRAWSURFACE3;
+ end;}
+ {ELSE}
+{$ENDIF}
+
+ // The structure passed to the low level blit functions
+ PSDL_BlitInfo = ^TSDL_BlitInfo;
+ TSDL_BlitInfo = record
+ s_pixels: PUInt8;
+ s_width: Integer;
+ s_height: Integer;
+ s_skip: Integer;
+ d_pixels: PUInt8;
+ d_width: Integer;
+ d_height: Integer;
+ d_skip: Integer;
+ aux_data: Pointer;
+ src: PSDL_PixelFormat;
+ table: PUInt8;
+ dst: PSDL_PixelFormat;
+ end;
+
+ // typedef for private surface blitting functions
+ PSDL_Surface = ^TSDL_Surface;
+
+ {$IFNDEF __GPC__}
+ TSDL_Blit = function( src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect ): Integer; cdecl;
+ {$ELSE}
+ TSDL_Blit = function( src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect ): Integer;
+ {$ENDIF}
+
+ // The type definition for the low level blit functions
+ //TSDL_LoBlit = procedure( info : PSDL_BlitInfo ); cdecl;
+
+ // This is the private info structure for software accelerated blits
+ {PPrivate_swaccel = ^TPrivate_swaccel;
+ TPrivate_swaccel = record
+ blit : TSDL_LoBlit;
+ aux_data : Pointer;
+ end;}
+
+ // Blit mapping definition
+ {PSDL_BlitMap = ^TSDL_BlitMap;
+ TSDL_BlitMap = record
+ dst : PSDL_Surface;
+ identity : Integer;
+ table : PUInt8;
+ hw_blit : TSDL_Blit;
+ sw_blit : TSDL_Blit;
+ hw_data : PPrivate_hwaccel;
+ sw_data : PPrivate_swaccel;
+
+ // the version count matches the destination; mismatch indicates an invalid mapping
+ format_version : Cardinal;
+ end;}
+
+ TSDL_Surface = record
+ flags: UInt32; // Read-only
+ format: PSDL_PixelFormat; // Read-only
+ w, h: Integer; // Read-only
+ pitch: UInt16; // Read-only
+ pixels: Pointer; // Read-write
+ offset: Integer; // Private
+ hwdata: Pointer; //TPrivate_hwdata; Hardware-specific surface info
+
+ // clipping information:
+ clip_rect: TSDL_Rect; // Read-only
+ unused1: UInt32; // for binary compatibility
+ // Allow recursive locks
+ locked: UInt32; // Private
+ // info for fast blit mapping to other surfaces
+ Blitmap: Pointer; // PSDL_BlitMap; // Private
+ // format version, bumped at every change to invalidate blit maps
+ format_version: Cardinal; // Private
+ refcount: Integer;
+ end;
+
+ // Useful for determining the video hardware capabilities
+ PSDL_VideoInfo = ^TSDL_VideoInfo;
+ TSDL_VideoInfo = record
+ hw_available: UInt8; // Hardware and WindowManager flags in first 2 bits ( see below )
+ {hw_available: 1; // Can you create hardware surfaces
+ wm_available: 1; // Can you talk to a window manager?
+ UnusedBits1: 6;}
+ blit_hw: UInt8; // Blit Hardware flags. See below for which bits do what
+ {UnusedBits2: 1;
+ blit_hw: 1; // Flag:UInt32 Accelerated blits HW --> HW
+ blit_hw_CC: 1; // Flag:UInt32 Accelerated blits with Colorkey
+ blit_hw_A: 1; // Flag:UInt32 Accelerated blits with Alpha
+ blit_sw: 1; // Flag:UInt32 Accelerated blits SW --> HW
+ blit_sw_CC: 1; // Flag:UInt32 Accelerated blits with Colorkey
+ blit_sw_A: 1; // Flag:UInt32 Accelerated blits with Alpha
+ blit_fill: 1; // Flag:UInt32 Accelerated color fill}
+ UnusedBits3: UInt8; // Unused at this point
+ video_mem: UInt32; // The total amount of video memory (in K)
+ vfmt: PSDL_PixelFormat; // Value: The format of the video surface
+ current_w : SInt32; // Value: The current video mode width
+ current_h : SInt32; // Value: The current video mode height
+ end;
+
+ // The YUV hardware video overlay
+ PSDL_Overlay = ^TSDL_Overlay;
+ TSDL_Overlay = record
+ format: UInt32; // Overlay format
+ w, h: Integer; // Width and height of overlay
+ planes: Integer; // Number of planes in the overlay. Usually either 1 or 3
+ pitches: PUInt16;
+ // An array of pitches, one for each plane. Pitch is the length of a row in bytes.
+ pixels: PPUInt8;
+ // An array of pointers to the data of each plane. The overlay should be locked before these pointers are used.
+ hw_overlay: UInt32;
+ // This will be set to 1 if the overlay is hardware accelerated.
+ end;
+
+ // Public enumeration for setting the OpenGL window attributes.
+ TSDL_GLAttr = (
+ SDL_GL_RED_SIZE,
+ SDL_GL_GREEN_SIZE,
+ SDL_GL_BLUE_SIZE,
+ SDL_GL_ALPHA_SIZE,
+ SDL_GL_BUFFER_SIZE,
+ SDL_GL_DOUBLEBUFFER,
+ SDL_GL_DEPTH_SIZE,
+ SDL_GL_STENCIL_SIZE,
+ SDL_GL_ACCUM_RED_SIZE,
+ SDL_GL_ACCUM_GREEN_SIZE,
+ SDL_GL_ACCUM_BLUE_SIZE,
+ SDL_GL_ACCUM_ALPHA_SIZE,
+ SDL_GL_STEREO,
+ SDL_GL_MULTISAMPLEBUFFERS,
+ SDL_GL_MULTISAMPLESAMPLES,
+ SDL_GL_ACCELERATED_VISUAL,
+ SDL_GL_SWAP_CONTROL);
+
+
+
+ PSDL_Cursor = ^TSDL_Cursor;
+ TSDL_Cursor = record
+ area: TSDL_Rect; // The area of the mouse cursor
+ hot_x, hot_y: SInt16; // The "tip" of the cursor
+ data: PUInt8; // B/W cursor data
+ mask: PUInt8; // B/W cursor mask
+ save: array[1..2] of PUInt8; // Place to save cursor area
+ wm_cursor: Pointer; // Window-manager cursor
+ end;
+
+// SDL_mutex.h types
+
+{$IFDEF WINDOWS}
+ PSDL_Mutex = ^TSDL_Mutex;
+ TSDL_Mutex = record
+ id: THANDLE;
+ end;
+{$ENDIF}
+
+{$IFDEF Unix}
+ PSDL_Mutex = ^TSDL_Mutex;
+ TSDL_mutex = record
+ id: pthread_mutex_t;
+{$IFDEF PTHREAD_NO_RECURSIVE_MUTEX}
+ recursive: Integer;
+ owner: pthread_t;
+{$ENDIF}
+ end;
+{$ENDIF}
+
+{$IFDEF NDS}
+ PSDL_mutex = ^TSDL_Mutex;
+ TSDL_Mutex = record
+ recursive: Integer;
+ Owner: UInt32;
+ sem: PSDL_sem;
+ end;
+{$ENDIF}
+
+{$IFDEF __MACH__}
+ {$define USE_NAMED_SEMAPHORES}
+ // Broken sem_getvalue() in MacOS X Public Beta */
+ {$define BROKEN_SEMGETVALUE}
+{$ENDIF}
+
+PSDL_semaphore = ^TSDL_semaphore;
+{$IFDEF WINDOWS}
+ // WINDOWS or Machintosh
+ TSDL_semaphore = record
+ id: THANDLE;
+ count: UInt32;
+ end;
+{$ELSE}
+ {$IFDEF FPC}
+ // This should be semaphore.h
+ __sem_lock_t = {packed} record { Not in header file - anonymous }
+ status: Longint;
+ spinlock: Integer;
+ end;
+
+ sem_t = {packed} record
+ __sem_lock: __sem_lock_t;
+ __sem_value: Integer;
+ __sem_waiting: longint ; {_pthread_queue;}
+ end;
+ {$ENDIF}
+
+ TSDL_semaphore = record
+ sem: Pointer; //PSem_t;
+ {$IFNDEF USE_NAMED_SEMAPHORES}
+ sem_data: Sem_t;
+ {$ENDIF}
+
+ {$IFDEF BROKEN_SEMGETVALUE}
+ { This is a little hack for MacOS X -
+ It's not thread-safe, but it's better than nothing }
+ sem_value: Integer;
+ {$ENDIF}
+ end;
+{$ENDIF}
+
+ PSDL_Sem = ^TSDL_Sem;
+ TSDL_Sem = TSDL_Semaphore;
+
+ PSDL_Cond = ^TSDL_Cond;
+ TSDL_Cond = record
+{$IFDEF Unix}
+ cond: pthread_cond_t;
+{$ELSE}
+ // Generic Cond structure
+ lock: PSDL_mutex;
+ waiting: Integer;
+ signals: Integer;
+ wait_sem: PSDL_Sem;
+ wait_done: PSDL_Sem;
+{$ENDIF}
+ end;
+
+ // SDL_thread.h types
+{$IFDEF WINDOWS}
+ TSYS_ThreadHandle = THandle;
+{$ENDIF}
+
+{$IFDEF Unix}
+ TSYS_ThreadHandle = pthread_t;
+{$ENDIF}
+
+{$IFDEF NDS}
+ TSYS_ThreadHandle = Integer;
+{$ENDIF}
+
+ { This is the system-independent thread info structure }
+ PSDL_Thread = ^TSDL_Thread;
+ TSDL_Thread = record
+ threadid: UInt32;
+ handle: TSYS_ThreadHandle;
+ status: Integer;
+ errbuf: TSDL_Error;
+ data: Pointer;
+ end;
+
+ // Helper Types
+
+ // Keyboard State Array ( See demos for how to use )
+ PKeyStateArr = ^TKeyStateArr;
+ TKeyStateArr = array[0..65000] of UInt8;
+
+ // Types required so we don't need to use Windows.pas
+ PInteger = ^Integer;
+ PByte = ^Byte;
+ PWord = ^Word;
+ PLongWord = ^Longword;
+
+ // General arrays
+ PByteArray = ^TByteArray;
+ TByteArray = array[0..32767] of Byte;
+
+ PWordArray = ^TWordArray;
+ TWordArray = array[0..16383] of Word;
+
+ PPoint = ^TPoint;
+ {$IFDEF HAS_TYPES}
+ TPoint = Types.TPoint;
+ {$ELSE}
+ {$IFDEF WINDOWS}
+ {$IFDEF __GPC__}
+ TPoint = wintypes.TPoint;
+ {$ELSE}
+ TPoint = Windows.TPoint;
+ {$ENDIF}
+ {$ELSE}
+ //Can't define TPoint : neither Types nor Windows unit available.
+ {$ENDIF}
+ {$ENDIF}
+
+ PRect = ^TRect;
+ {$IFDEF HAS_TYPES}
+ TRect = Types.TRect;
+ {$ELSE}
+ {$IFDEF WINDOWS}
+ {$IFDEF __GPC__}
+ TRect = wintypes.TRect;
+ {$ELSE}
+ TRect = Windows.TRect;
+ {$ENDIF}
+ {$ELSE}
+ //Can't define TRect: neither Types nor Windows unit available.
+ {$ENDIF}
+ {$ENDIF}
+
+ { Generic procedure pointer }
+ TProcedure = procedure;
+
+{------------------------------------------------------------------------------}
+{ initialization }
+{------------------------------------------------------------------------------}
+
+{ This function loads the SDL dynamically linked library and initializes
+ the subsystems specified by 'flags' (and those satisfying dependencies)
+ Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
+ signal handlers for some commonly ignored fatal signals (like SIGSEGV) }
+
+function SDL_Init( flags : UInt32 ) : Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_Init}
+
+// This function initializes specific SDL subsystems
+function SDL_InitSubSystem( flags : UInt32 ) : Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_InitSubSystem'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_InitSubSystem}
+
+// This function cleans up specific SDL subsystems
+procedure SDL_QuitSubSystem( flags : UInt32 );
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_QuitSubSystem'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_QuitSubSystem}
+
+{ This function returns mask of the specified subsystems which have
+ been initialized.
+ If 'flags' is 0, it returns a mask of all initialized subsystems. }
+
+function SDL_WasInit( flags : UInt32 ): UInt32;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WasInit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_WasInit}
+
+{ This function cleans up all initialized subsystems and unloads the
+ dynamically linked library. You should call it upon all exit conditions. }
+procedure SDL_Quit;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Quit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_Quit}
+
+{$IFDEF WINDOWS}
+// This should be called from your WinMain() function, if any
+function SDL_RegisterApp(name: PChar; style: UInt32; h_Inst: Pointer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RegisterApp'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_RegisterApp}
+{$ENDIF}
+
+{$IFDEF __MACH__}
+// This should be called from your main() function, if any
+procedure SDL_InitQuickDraw( the_qd: QDGlobals );
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_InitQuickDraw'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_InitQuickDraw}
+{$ENDIF}
+
+
+{------------------------------------------------------------------------------}
+{ types }
+{------------------------------------------------------------------------------}
+// The number of elements in a table
+function SDL_TableSize( table: PChar ): Integer;
+{$EXTERNALSYM SDL_TABLESIZE}
+
+
+{------------------------------------------------------------------------------}
+{ error-handling }
+{------------------------------------------------------------------------------}
+// Public functions
+function SDL_GetError: PChar;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetError'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetError}
+procedure SDL_SetError(fmt: PChar);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetError'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetError}
+procedure SDL_ClearError;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ClearError'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_ClearError}
+
+{$IFNDEF WINDOWS}
+procedure SDL_Error(Code: TSDL_errorcode);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Error'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_Error}
+{$ENDIF}
+
+// Private error message function - used internally
+procedure SDL_OutOfMemory;
+
+{------------------------------------------------------------------------------}
+{ io handling }
+{------------------------------------------------------------------------------}
+// Functions to create SDL_RWops structures from various data sources
+
+function SDL_RWFromFile(filename, mode: PChar): PSDL_RWops;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RWFromFile'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_RWFromFile}
+procedure SDL_FreeRW(area: PSDL_RWops);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeRW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_FreeRW}
+
+//fp is FILE *fp ???
+function SDL_RWFromFP(fp: Pointer; autoclose: Integer): PSDL_RWops;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RWFromFP'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_RWFromFP}
+function SDL_RWFromMem(mem: Pointer; size: Integer): PSDL_RWops;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RWFromMem'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_RWFromMem}
+function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RWFromConstMem'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_RWFromConstMem}
+function SDL_AllocRW: PSDL_RWops;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AllocRW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_AllocRW}
+
+function SDL_RWSeek(context: PSDL_RWops; offset: Integer; whence: Integer) : Integer;
+{$EXTERNALSYM SDL_RWSeek}
+function SDL_RWTell(context: PSDL_RWops): Integer;
+{$EXTERNALSYM SDL_RWTell}
+function SDL_RWRead(context: PSDL_RWops; ptr: Pointer; size: Integer; n : Integer): Integer;
+{$EXTERNALSYM SDL_RWRead}
+function SDL_RWWrite(context: PSDL_RWops; ptr: Pointer; size: Integer; n : Integer): Integer;
+{$EXTERNALSYM SDL_RWWrite}
+function SDL_RWClose(context: PSDL_RWops): Integer;
+{$EXTERNALSYM SDL_RWClose}
+
+{------------------------------------------------------------------------------}
+{ time-handling }
+{------------------------------------------------------------------------------}
+
+{ Get the number of milliseconds since the SDL library initialization. }
+{ Note that this value wraps if the program runs for more than ~49 days. }
+function SDL_GetTicks: UInt32;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetTicks'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetTicks}
+
+// Wait a specified number of milliseconds before returning
+procedure SDL_Delay(msec: UInt32);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Delay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_Delay}
+
+{ Add a new timer to the pool of timers already running. }
+{ Returns a timer ID, or NULL when an error occurs. }
+function SDL_AddTimer(interval: UInt32; callback: TSDL_NewTimerCallback; param : Pointer): PSDL_TimerID;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AddTimer'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_AddTimer}
+
+{ Remove one of the multiple timers knowing its ID. }
+{ Returns a boolean value indicating success. }
+function SDL_RemoveTimer(t: PSDL_TimerID): TSDL_Bool;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RemoveTimer'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_RemoveTimer}
+
+function SDL_SetTimer(interval: UInt32; callback: TSDL_TimerCallback): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetTimer'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetTimer}
+
+{------------------------------------------------------------------------------}
+{ audio-routines }
+{------------------------------------------------------------------------------}
+
+{ These functions are used internally, and should not be used unless you
+ have a specific need to specify the audio driver you want to use.
+ You should normally use SDL_Init() or SDL_InitSubSystem(). }
+
+function SDL_AudioInit(driver_name: PChar): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AudioInit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_AudioInit}
+procedure SDL_AudioQuit;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AudioQuit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_AudioQuit}
+
+{ This function fills the given character buffer with the name of the
+ current audio driver, and returns a Pointer to it if the audio driver has
+ been initialized. It returns NULL if no driver has been initialized. }
+
+function SDL_AudioDriverName(namebuf: PChar; maxlen: Integer): PChar;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AudioDriverName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_AudioDriverName}
+
+{ This function opens the audio device with the desired parameters, and
+ returns 0 if successful, placing the actual hardware parameters in the
+ structure pointed to by 'obtained'. If 'obtained' is NULL, the audio
+ data passed to the callback function will be guaranteed to be in the
+ requested format, and will be automatically converted to the hardware
+ audio format if necessary. This function returns -1 if it failed
+ to open the audio device, or couldn't set up the audio thread.
+
+ When filling in the desired audio spec structure,
+ 'desired->freq' should be the desired audio frequency in samples-per-second.
+ 'desired->format' should be the desired audio format.
+ 'desired->samples' is the desired size of the audio buffer, in samples.
+ This number should be a power of two, and may be adjusted by the audio
+ driver to a value more suitable for the hardware. Good values seem to
+ range between 512 and 8096 inclusive, depending on the application and
+ CPU speed. Smaller values yield faster response time, but can lead
+ to underflow if the application is doing heavy processing and cannot
+ fill the audio buffer in time. A stereo sample consists of both right
+ and left channels in LR ordering.
+ Note that the number of samples is directly related to time by the
+ following formula: ms = (samples*1000)/freq
+ 'desired->size' is the size in bytes of the audio buffer, and is
+ calculated by SDL_OpenAudio().
+ 'desired->silence' is the value used to set the buffer to silence,
+ and is calculated by SDL_OpenAudio().
+ 'desired->callback' should be set to a function that will be called
+ when the audio device is ready for more data. It is passed a pointer
+ to the audio buffer, and the length in bytes of the audio buffer.
+ This function usually runs in a separate thread, and so you should
+ protect data structures that it accesses by calling SDL_LockAudio()
+ and SDL_UnlockAudio() in your code.
+ 'desired->userdata' is passed as the first parameter to your callback
+ function.
+
+ The audio device starts out playing silence when it's opened, and should
+ be enabled for playing by calling SDL_PauseAudio(0) when you are ready
+ for your audio callback function to be called. Since the audio driver
+ may modify the requested size of the audio buffer, you should allocate
+ any local mixing buffers after you open the audio device. }
+
+function SDL_OpenAudio(desired, obtained: PSDL_AudioSpec): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_OpenAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_OpenAudio}
+
+{ Get the current audio state: }
+function SDL_GetAudioStatus: TSDL_Audiostatus;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetAudioStatus'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetAudioStatus}
+
+{ This function pauses and unpauses the audio callback processing.
+ It should be called with a parameter of 0 after opening the audio
+ device to start playing sound. This is so you can safely initialize
+ data for your callback function after opening the audio device.
+ Silence will be written to the audio device during the pause. }
+
+procedure SDL_PauseAudio(pause_on: Integer);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PauseAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_PauseAudio}
+
+{ This function loads a WAVE from the data source, automatically freeing
+ that source if 'freesrc' is non-zero. For example, to load a WAVE file,
+ you could do:
+ SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
+
+ If this function succeeds, it returns the given SDL_AudioSpec,
+ filled with the audio data format of the wave data, and sets
+ 'audio_buf' to a malloc()'d buffer containing the audio data,
+ and sets 'audio_len' to the length of that audio buffer, in bytes.
+ You need to free the audio buffer with SDL_FreeWAV() when you are
+ done with it.
+
+ This function returns NULL and sets the SDL error message if the
+ wave file cannot be opened, uses an unknown data format, or is
+ corrupt. Currently raw and MS-ADPCM WAVE files are supported. }
+
+function SDL_LoadWAV_RW(src: PSDL_RWops; freesrc: Integer; spec:
+ PSDL_AudioSpec; audio_buf: PUInt8; audiolen: PUInt32): PSDL_AudioSpec;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LoadWAV_RW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_LoadWAV_RW}
+
+// Compatibility convenience function -- loads a WAV from a file
+function SDL_LoadWAV(filename: PChar; spec: PSDL_AudioSpec; audio_buf:
+ PUInt8; audiolen: PUInt32): PSDL_AudioSpec;
+{$EXTERNALSYM SDL_LoadWAV}
+
+{ This function frees data previously allocated with SDL_LoadWAV_RW() }
+
+procedure SDL_FreeWAV(audio_buf: PUInt8);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeWAV'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_FreeWAV}
+
+{ This function takes a source format and rate and a destination format
+ and rate, and initializes the 'cvt' structure with information needed
+ by SDL_ConvertAudio() to convert a buffer of audio data from one format
+ to the other.
+ This function returns 0, or -1 if there was an error. }
+function SDL_BuildAudioCVT(cvt: PSDL_AudioCVT; src_format: UInt16;
+ src_channels: UInt8; src_rate: Integer; dst_format: UInt16; dst_channels: UInt8;
+ dst_rate: Integer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_BuildAudioCVT'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_BuildAudioCVT}
+
+{ Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
+ created an audio buffer cvt->buf, and filled it with cvt->len bytes of
+ audio data in the source format, this function will convert it in-place
+ to the desired format.
+ The data conversion may expand the size of the audio data, so the buffer
+ cvt->buf should be allocated after the cvt structure is initialized by
+ SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. }
+function SDL_ConvertAudio(cvt: PSDL_AudioCVT): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ConvertAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_ConvertAudio}
+
+{ This takes two audio buffers of the playing audio format and mixes
+ them, performing addition, volume adjustment, and overflow clipping.
+ The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
+ for full audio volume. Note this does not change hardware volume.
+ This is provided for convenience -- you can mix your own audio data. }
+
+procedure SDL_MixAudio(dst, src: PUInt8; len: UInt32; volume: Integer);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_MixAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_MixAudio}
+
+{ The lock manipulated by these functions protects the callback function.
+ During a LockAudio/UnlockAudio pair, you can be guaranteed that the
+ callback function is not running. Do not call these from the callback
+ function or you will cause deadlock. }
+procedure SDL_LockAudio;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LockAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_LockAudio}
+procedure SDL_UnlockAudio;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UnlockAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_UnlockAudio}
+
+{ This function shuts down audio processing and closes the audio device. }
+
+procedure SDL_CloseAudio;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CloseAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CloseAudio}
+
+{------------------------------------------------------------------------------}
+{ CD-routines }
+{------------------------------------------------------------------------------}
+
+{ Returns the number of CD-ROM drives on the system, or -1 if
+ SDL_Init() has not been called with the SDL_INIT_CDROM flag. }
+
+function SDL_CDNumDrives: Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDNumDrives'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CDNumDrives}
+
+{ Returns a human-readable, system-dependent identifier for the CD-ROM.
+ Example:
+ "/dev/cdrom"
+ "E:"
+ "/dev/disk/ide/1/master" }
+
+function SDL_CDName(drive: Integer): PChar;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CDName}
+
+{ Opens a CD-ROM drive for access. It returns a drive handle on success,
+ or NULL if the drive was invalid or busy. This newly opened CD-ROM
+ becomes the default CD used when other CD functions are passed a NULL
+ CD-ROM handle.
+ Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. }
+
+function SDL_CDOpen(drive: Integer): PSDL_CD;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDOpen'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CDOpen}
+
+{ This function returns the current status of the given drive.
+ If the drive has a CD in it, the table of contents of the CD and current
+ play position of the CD will be stored in the SDL_CD structure. }
+
+function SDL_CDStatus(cdrom: PSDL_CD): TSDL_CDStatus;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDStatus'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CDStatus}
+
+{ Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
+ tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play
+ until the end of the CD. This function will skip data tracks.
+ This function should only be called after calling SDL_CDStatus() to
+ get track information about the CD.
+
+ For example:
+ // Play entire CD:
+ if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then
+ SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
+ // Play last track:
+ if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then
+ begin
+ SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
+ end;
+
+ // Play first and second track and 10 seconds of third track:
+ if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
+ SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
+
+ This function returns 0, or -1 if there was an error. }
+
+function SDL_CDPlayTracks(cdrom: PSDL_CD; start_track: Integer; start_frame:
+ Integer; ntracks: Integer; nframes: Integer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDPlayTracks'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CDPlayTracks}
+
+
+{ Play the given CD starting at 'start' frame for 'length' frames.
+ It returns 0, or -1 if there was an error. }
+
+function SDL_CDPlay(cdrom: PSDL_CD; start: Integer; length: Integer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDPlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CDPlay}
+
+// Pause play -- returns 0, or -1 on error
+function SDL_CDPause(cdrom: PSDL_CD): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDPause'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CDPause}
+
+// Resume play -- returns 0, or -1 on error
+function SDL_CDResume(cdrom: PSDL_CD): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDResume'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CDResume}
+
+// Stop play -- returns 0, or -1 on error
+function SDL_CDStop(cdrom: PSDL_CD): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDStop'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CDStop}
+
+// Eject CD-ROM -- returns 0, or -1 on error
+function SDL_CDEject(cdrom: PSDL_CD): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDEject'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CDEject}
+
+// Closes the handle for the CD-ROM drive
+procedure SDL_CDClose(cdrom: PSDL_CD);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDClose'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CDClose}
+
+// Given a status, returns true if there's a disk in the drive
+function SDL_CDInDrive( status : TSDL_CDStatus ) : LongBool;
+{$EXTERNALSYM SDL_CDInDrive}
+
+// Conversion functions from frames to Minute/Second/Frames and vice versa
+procedure FRAMES_TO_MSF(frames: Integer; var M: Integer; var S: Integer; var
+ F: Integer);
+{$EXTERNALSYM FRAMES_TO_MSF}
+function MSF_TO_FRAMES(M: Integer; S: Integer; F: Integer): Integer;
+{$EXTERNALSYM MSF_TO_FRAMES}
+
+{------------------------------------------------------------------------------}
+{ JoyStick-routines }
+{------------------------------------------------------------------------------}
+
+{ Count the number of joysticks attached to the system }
+function SDL_NumJoysticks: Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_NumJoysticks'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_NumJoysticks}
+
+{ Get the implementation dependent name of a joystick.
+ This can be called before any joysticks are opened.
+ If no name can be found, this function returns NULL. }
+function SDL_JoystickName(index: Integer): PChar;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickName}
+
+{ Open a joystick for use - the index passed as an argument refers to
+ the N'th joystick on the system. This index is the value which will
+ identify this joystick in future joystick events.
+
+ This function returns a joystick identifier, or NULL if an error occurred. }
+function SDL_JoystickOpen(index: Integer): PSDL_Joystick;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickOpen'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickOpen}
+
+{ Returns 1 if the joystick has been opened, or 0 if it has not. }
+function SDL_JoystickOpened(index: Integer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickOpened'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickOpened}
+
+{ Get the device index of an opened joystick. }
+function SDL_JoystickIndex(joystick: PSDL_Joystick): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickIndex'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickIndex}
+
+{ Get the number of general axis controls on a joystick }
+function SDL_JoystickNumAxes(joystick: PSDL_Joystick): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickNumAxes'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickNumAxes}
+
+{ Get the number of trackballs on a joystick
+ Joystick trackballs have only relative motion events associated
+ with them and their state cannot be polled. }
+function SDL_JoystickNumBalls(joystick: PSDL_Joystick): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickNumBalls'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickNumBalls}
+
+
+{ Get the number of POV hats on a joystick }
+function SDL_JoystickNumHats(joystick: PSDL_Joystick): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickNumHats'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickNumHats}
+
+{ Get the number of buttons on a joystick }
+function SDL_JoystickNumButtons(joystick: PSDL_Joystick): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickNumButtons'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickNumButtons}
+
+{ Update the current state of the open joysticks.
+ This is called automatically by the event loop if any joystick
+ events are enabled. }
+
+procedure SDL_JoystickUpdate;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickUpdate'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickUpdate;}
+
+{ Enable/disable joystick event polling.
+ If joystick events are disabled, you must call SDL_JoystickUpdate()
+ yourself and check the state of the joystick when you want joystick
+ information.
+ The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. }
+
+function SDL_JoystickEventState(state: Integer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickEventState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickEventState}
+
+{ Get the current state of an axis control on a joystick
+ The state is a value ranging from -32768 to 32767.
+ The axis indices start at index 0. }
+
+function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: Integer) : SInt16;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickGetAxis'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickGetAxis}
+
+{ The hat indices start at index 0. }
+
+function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: Integer): UInt8;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickGetHat'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickGetHat}
+
+{ Get the ball axis change since the last poll
+ This returns 0, or -1 if you passed it invalid parameters.
+ The ball indices start at index 0. }
+
+function SDL_JoystickGetBall(joystick: PSDL_Joystick; ball: Integer; var dx: Integer; var dy: Integer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickGetBall'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickGetBall}
+
+{ Get the current state of a button on a joystick
+ The button indices start at index 0. }
+function SDL_JoystickGetButton( joystick: PSDL_Joystick; Button: Integer): UInt8;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickGetButton'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickGetButton}
+
+{ Close a joystick previously opened with SDL_JoystickOpen() }
+procedure SDL_JoystickClose(joystick: PSDL_Joystick);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickClose'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_JoystickClose}
+
+{------------------------------------------------------------------------------}
+{ event-handling }
+{------------------------------------------------------------------------------}
+
+{ Pumps the event loop, gathering events from the input devices.
+ This function updates the event queue and internal input device state.
+ This should only be run in the thread that sets the video mode. }
+
+procedure SDL_PumpEvents;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PumpEvents'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_PumpEvents;}
+
+{ Checks the event queue for messages and optionally returns them.
+ If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
+ the back of the event queue.
+ If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
+ of the event queue, matching 'mask', will be returned and will not
+ be removed from the queue.
+ If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
+ of the event queue, matching 'mask', will be returned and will be
+ removed from the queue.
+ This function returns the number of events actually stored, or -1
+ if there was an error. This function is thread-safe. }
+
+function SDL_PeepEvents(events: PSDL_Event; numevents: Integer; action: TSDL_eventaction; mask: UInt32): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PeepEvents'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_PeepEvents}
+
+{ Polls for currently pending events, and returns 1 if there are any pending
+ events, or 0 if there are none available. If 'event' is not NULL, the next
+ event is removed from the queue and stored in that area. }
+
+function SDL_PollEvent(event: PSDL_Event): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PollEvent'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_PollEvent}
+
+{ Waits indefinitely for the next available event, returning 1, or 0 if there
+ was an error while waiting for events. If 'event' is not NULL, the next
+ event is removed from the queue and stored in that area. }
+
+function SDL_WaitEvent(event: PSDL_Event): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WaitEvent'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_WaitEvent}
+
+function SDL_PushEvent( event : PSDL_Event ) : Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PushEvent'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_PushEvent}
+
+{ If the filter returns 1, then the event will be added to the internal queue.
+ If it returns 0, then the event will be dropped from the queue, but the
+ internal state will still be updated. This allows selective filtering of
+ dynamically arriving events.
+
+ WARNING: Be very careful of what you do in the event filter function, as
+ it may run in a different thread!
+
+ There is one caveat when dealing with the SDL_QUITEVENT event type. The
+ event filter is only called when the window manager desires to close the
+ application window. If the event filter returns 1, then the window will
+ be closed, otherwise the window will remain open if possible.
+ If the quit event is generated by an interrupt signal, it will bypass the
+ internal queue and be delivered to the application at the next event poll. }
+procedure SDL_SetEventFilter( filter : TSDL_EventFilter );
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetEventFilter'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetEventFilter}
+
+{ Return the current event filter - can be used to "chain" filters.
+ If there is no event filter set, this function returns NULL. }
+
+function SDL_GetEventFilter: TSDL_EventFilter;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetEventFilter'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetEventFilter}
+
+{ This function allows you to set the state of processing certain events.
+ If 'state' is set to SDL_IGNORE, that event will be automatically dropped
+ from the event queue and will not event be filtered.
+ If 'state' is set to SDL_ENABLE, that event will be processed normally.
+ If 'state' is set to SDL_QUERY, SDL_EventState() will return the
+ current processing state of the specified event. }
+
+function SDL_EventState(type_: UInt8; state: Integer): UInt8;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_EventState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_EventState}
+
+{------------------------------------------------------------------------------}
+{ Version Routines }
+{------------------------------------------------------------------------------}
+
+{ This macro can be used to fill a version structure with the compile-time
+ version of the SDL library. }
+procedure SDL_VERSION(var X: TSDL_Version);
+{$EXTERNALSYM SDL_VERSION}
+
+{ This macro turns the version numbers into a numeric value:
+ (1,2,3) -> (1203)
+ This assumes that there will never be more than 100 patchlevels }
+
+function SDL_VERSIONNUM(X, Y, Z: Integer): Integer;
+{$EXTERNALSYM SDL_VERSIONNUM}
+
+// This is the version number macro for the current SDL version
+function SDL_COMPILEDVERSION: Integer;
+{$EXTERNALSYM SDL_COMPILEDVERSION}
+
+// This macro will evaluate to true if compiled with SDL at least X.Y.Z
+function SDL_VERSION_ATLEAST(X: Integer; Y: Integer; Z: Integer) : LongBool;
+{$EXTERNALSYM SDL_VERSION_ATLEAST}
+
+{ This function gets the version of the dynamically linked SDL library.
+ it should NOT be used to fill a version structure, instead you should
+ use the SDL_Version() macro. }
+
+function SDL_Linked_Version: PSDL_version;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Linked_Version'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_Linked_Version}
+
+{------------------------------------------------------------------------------}
+{ video }
+{------------------------------------------------------------------------------}
+
+{ These functions are used internally, and should not be used unless you
+ have a specific need to specify the video driver you want to use.
+ You should normally use SDL_Init() or SDL_InitSubSystem().
+
+ SDL_VideoInit() initializes the video subsystem -- sets up a connection
+ to the window manager, etc, and determines the current video mode and
+ pixel format, but does not initialize a window or graphics mode.
+ Note that event handling is activated by this routine.
+
+ If you use both sound and video in your application, you need to call
+ SDL_Init() before opening the sound device, otherwise under Win32 DirectX,
+ you won't be able to set full-screen display modes. }
+
+function SDL_VideoInit(driver_name: PChar; flags: UInt32): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_VideoInit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_VideoInit}
+procedure SDL_VideoQuit;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_VideoQuit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_VideoQuit}
+
+{ This function fills the given character buffer with the name of the
+ video driver, and returns a pointer to it if the video driver has
+ been initialized. It returns NULL if no driver has been initialized. }
+
+function SDL_VideoDriverName(namebuf: PChar; maxlen: Integer): PChar;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_VideoDriverName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_VideoDriverName}
+
+{ This function returns a pointer to the current display surface.
+ If SDL is doing format conversion on the display surface, this
+ function returns the publicly visible surface, not the real video
+ surface. }
+
+function SDL_GetVideoSurface: PSDL_Surface;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetVideoSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetVideoSurface}
+
+{ This function returns a read-only pointer to information about the
+ video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt'
+ member of the returned structure will contain the pixel format of the
+ "best" video mode. }
+function SDL_GetVideoInfo: PSDL_VideoInfo;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetVideoInfo'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetVideoInfo}
+
+{ Check to see if a particular video mode is supported.
+ It returns 0 if the requested mode is not supported under any bit depth,
+ or returns the bits-per-pixel of the closest available mode with the
+ given width and height. If this bits-per-pixel is different from the
+ one used when setting the video mode, SDL_SetVideoMode() will succeed,
+ but will emulate the requested bits-per-pixel with a shadow surface.
+
+ The arguments to SDL_VideoModeOK() are the same ones you would pass to
+ SDL_SetVideoMode() }
+
+function SDL_VideoModeOK(width, height, bpp: Integer; flags: UInt32): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_VideoModeOK'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_VideoModeOK}
+
+{ Return a pointer to an array of available screen dimensions for the
+ given format and video flags, sorted largest to smallest. Returns
+ NULL if there are no dimensions available for a particular format,
+ or (SDL_Rect **)-1 if any dimension is okay for the given format.
+
+ if 'format' is NULL, the mode list will be for the format given
+ by SDL_GetVideoInfo( ) - > vfmt }
+
+function SDL_ListModes(format: PSDL_PixelFormat; flags: UInt32): PPSDL_Rect;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ListModes'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_ListModes}
+
+
+{ Set up a video mode with the specified width, height and bits-per-pixel.
+
+ If 'bpp' is 0, it is treated as the current display bits per pixel.
+
+ If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the
+ requested bits-per-pixel, but will return whatever video pixel format is
+ available. The default is to emulate the requested pixel format if it
+ is not natively available.
+
+ If SDL_HWSURFACE is set in 'flags', the video surface will be placed in
+ video memory, if possible, and you may have to call SDL_LockSurface()
+ in order to access the raw framebuffer. Otherwise, the video surface
+ will be created in system memory.
+
+ If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle
+ updates asynchronously, but you must always lock before accessing pixels.
+ SDL will wait for updates to complete before returning from the lock.
+
+ If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee
+ that the colors set by SDL_SetColors() will be the colors you get.
+ Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all
+ of the colors exactly the way they are requested, and you should look
+ at the video surface structure to determine the actual palette.
+ If SDL cannot guarantee that the colors you request can be set,
+ i.e. if the colormap is shared, then the video surface may be created
+ under emulation in system memory, overriding the SDL_HWSURFACE flag.
+
+ If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set
+ a fullscreen video mode. The default is to create a windowed mode
+ if the current graphics system has a window manager.
+ If the SDL library is able to set a fullscreen video mode, this flag
+ will be set in the surface that is returned.
+
+ If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up
+ two surfaces in video memory and swap between them when you call
+ SDL_Flip(). This is usually slower than the normal single-buffering
+ scheme, but prevents "tearing" artifacts caused by modifying video
+ memory while the monitor is refreshing. It should only be used by
+ applications that redraw the entire screen on every update.
+
+ This function returns the video framebuffer surface, or NULL if it fails. }
+
+function SDL_SetVideoMode(width, height, bpp: Integer; flags: UInt32): PSDL_Surface;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetVideoMode'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetVideoMode}
+
+
+{ Makes sure the given list of rectangles is updated on the given screen.
+ If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
+ screen.
+ These functions should not be called while 'screen' is locked. }
+
+procedure SDL_UpdateRects(screen: PSDL_Surface; numrects: Integer; rects: PSDL_Rect);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UpdateRects'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_UpdateRects}
+procedure SDL_UpdateRect(screen: PSDL_Surface; x, y: SInt32; w, h: UInt32);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UpdateRect'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_UpdateRect}
+
+
+{ On hardware that supports double-buffering, this function sets up a flip
+ and returns. The hardware will wait for vertical retrace, and then swap
+ video buffers before the next video surface blit or lock will return.
+ On hardware that doesn not support double-buffering, this is equivalent
+ to calling SDL_UpdateRect(screen, 0, 0, 0, 0);
+ The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when
+ setting the video mode for this function to perform hardware flipping.
+ This function returns 0 if successful, or -1 if there was an error.}
+
+function SDL_Flip(screen: PSDL_Surface): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Flip'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_Flip}
+
+{ Set the gamma correction for each of the color channels.
+ The gamma values range (approximately) between 0.1 and 10.0
+
+ If this function isn't supported directly by the hardware, it will
+ be emulated using gamma ramps, if available. If successful, this
+ function returns 0, otherwise it returns -1. }
+
+function SDL_SetGamma(redgamma: single; greengamma: single; bluegamma: single ): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetGamma'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetGamma}
+
+{ Set the gamma translation table for the red, green, and blue channels
+ of the video hardware. Each table is an array of 256 16-bit quantities,
+ representing a mapping between the input and output for that channel.
+ The input is the index into the array, and the output is the 16-bit
+ gamma value at that index, scaled to the output color precision.
+
+ You may pass NULL for any of the channels to leave it unchanged.
+ If the call succeeds, it will return 0. If the display driver or
+ hardware does not support gamma translation, or otherwise fails,
+ this function will return -1. }
+
+function SDL_SetGammaRamp( redtable: PUInt16; greentable: PUInt16; bluetable: PUInt16): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetGammaRamp'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetGammaRamp}
+
+{ Retrieve the current values of the gamma translation tables.
+
+ You must pass in valid pointers to arrays of 256 16-bit quantities.
+ Any of the pointers may be NULL to ignore that channel.
+ If the call succeeds, it will return 0. If the display driver or
+ hardware does not support gamma translation, or otherwise fails,
+ this function will return -1. }
+
+function SDL_GetGammaRamp( redtable: PUInt16; greentable: PUInt16; bluetable: PUInt16): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetGammaRamp'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetGammaRamp}
+
+{ Sets a portion of the colormap for the given 8-bit surface. If 'surface'
+ is not a palettized surface, this function does nothing, returning 0.
+ If all of the colors were set as passed to SDL_SetColors(), it will
+ return 1. If not all the color entries were set exactly as given,
+ it will return 0, and you should look at the surface palette to
+ determine the actual color palette.
+
+ When 'surface' is the surface associated with the current display, the
+ display colormap will be updated with the requested colors. If
+ SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors()
+ will always return 1, and the palette is guaranteed to be set the way
+ you desire, even if the window colormap has to be warped or run under
+ emulation. }
+
+
+function SDL_SetColors(surface: PSDL_Surface; colors: PSDL_Color; firstcolor : Integer; ncolors: Integer) : Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetColors'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetColors}
+
+{ Sets a portion of the colormap for a given 8-bit surface.
+ 'flags' is one or both of:
+ SDL_LOGPAL -- set logical palette, which controls how blits are mapped
+ to/from the surface,
+ SDL_PHYSPAL -- set physical palette, which controls how pixels look on
+ the screen
+ Only screens have physical palettes. Separate change of physical/logical
+ palettes is only possible if the screen has SDL_HWPALETTE set.
+
+ The return value is 1 if all colours could be set as requested, and 0
+ otherwise.
+
+ SDL_SetColors() is equivalent to calling this function with
+ flags = (SDL_LOGPAL or SDL_PHYSPAL). }
+
+function SDL_SetPalette(surface: PSDL_Surface; flags: Integer; colors: PSDL_Color; firstcolor: Integer; ncolors: Integer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetPalette'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetPalette}
+
+{ Maps an RGB triple to an opaque pixel value for a given pixel format }
+function SDL_MapRGB(format: PSDL_PixelFormat; r: UInt8; g: UInt8; b: UInt8) : UInt32;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_MapRGB'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_MapRGB}
+
+{ Maps an RGBA quadruple to a pixel value for a given pixel format }
+function SDL_MapRGBA(format: PSDL_PixelFormat; r: UInt8; g: UInt8; b: UInt8; a: UInt8): UInt32;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_MapRGBA'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_MapRGBA}
+
+{ Maps a pixel value into the RGB components for a given pixel format }
+procedure SDL_GetRGB(pixel: UInt32; fmt: PSDL_PixelFormat; r: PUInt8; g: PUInt8; b: PUInt8);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetRGB'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetRGB}
+
+{ Maps a pixel value into the RGBA components for a given pixel format }
+procedure SDL_GetRGBA(pixel: UInt32; fmt: PSDL_PixelFormat; r: PUInt8; g: PUInt8; b: PUInt8; a: PUInt8);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetRGBA'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetRGBA}
+
+{ Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
+ If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
+ If the depth is greater than 8 bits, the pixel format is set using the
+ flags '[RGB]mask'.
+ If the function runs out of memory, it will return NULL.
+
+ The 'flags' tell what kind of surface to create.
+ SDL_SWSURFACE means that the surface should be created in system memory.
+ SDL_HWSURFACE means that the surface should be created in video memory,
+ with the same format as the display surface. This is useful for surfaces
+ that will not change much, to take advantage of hardware acceleration
+ when being blitted to the display surface.
+ SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with
+ this surface, but you must always lock it before accessing the pixels.
+ SDL will wait for current blits to finish before returning from the lock.
+ SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
+ If the hardware supports acceleration of colorkey blits between
+ two surfaces in video memory, SDL will try to place the surface in
+ video memory. If this isn't possible or if there is no hardware
+ acceleration available, the surface will be placed in system memory.
+ SDL_SRCALPHA means that the surface will be used for alpha blits and
+ if the hardware supports hardware acceleration of alpha blits between
+ two surfaces in video memory, to place the surface in video memory
+ if possible, otherwise it will be placed in system memory.
+ If the surface is created in video memory, blits will be _much_ faster,
+ but the surface format must be identical to the video surface format,
+ and the only way to access the pixels member of the surface is to use
+ the SDL_LockSurface() and SDL_UnlockSurface() calls.
+ If the requested surface actually resides in video memory, SDL_HWSURFACE
+ will be set in the flags member of the returned surface. If for some
+ reason the surface could not be placed in video memory, it will not have
+ the SDL_HWSURFACE flag set, and will be created in system memory instead. }
+
+function SDL_AllocSurface(flags: UInt32; width, height, depth: Integer;
+ RMask, GMask, BMask, AMask: UInt32): PSDL_Surface;
+{$EXTERNALSYM SDL_AllocSurface}
+
+function SDL_CreateRGBSurface(flags: UInt32; width, height, depth: Integer; RMask, GMask, BMask, AMask: UInt32): PSDL_Surface;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateRGBSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CreateRGBSurface}
+
+function SDL_CreateRGBSurfaceFrom(pixels: Pointer; width, height, depth, pitch
+ : Integer; RMask, GMask, BMask, AMask: UInt32): PSDL_Surface;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateRGBSurfaceFrom'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CreateRGBSurfaceFrom}
+
+procedure SDL_FreeSurface(surface: PSDL_Surface);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_FreeSurface}
+
+function SDL_MustLock(Surface: PSDL_Surface): Boolean;
+{$EXTERNALSYM SDL_MustLock}
+{ SDL_LockSurface() sets up a surface for directly accessing the pixels.
+ Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
+ to and read from 'surface->pixels', using the pixel format stored in
+ 'surface->format'. Once you are done accessing the surface, you should
+ use SDL_UnlockSurface() to release it.
+
+ Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
+ to 0, then you can read and write to the surface at any time, and the
+ pixel format of the surface will not change. In particular, if the
+ SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you
+ will not need to lock the display surface before accessing it.
+
+ No operating system or library calls should be made between lock/unlock
+ pairs, as critical system locks may be held during this time.
+
+ SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. }
+function SDL_LockSurface(surface: PSDL_Surface): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LockSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_LockSurface}
+
+procedure SDL_UnlockSurface(surface: PSDL_Surface);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UnlockSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_UnlockSurface}
+
+{ Load a surface from a seekable SDL data source (memory or file.)
+ If 'freesrc' is non-zero, the source will be closed after being read.
+ Returns the new surface, or NULL if there was an error.
+ The new surface should be freed with SDL_FreeSurface(). }
+function SDL_LoadBMP_RW(src: PSDL_RWops; freesrc: Integer): PSDL_Surface;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LoadBMP_RW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_LoadBMP_RW}
+
+// Convenience macro -- load a surface from a file
+function SDL_LoadBMP(filename: PChar): PSDL_Surface;
+{$EXTERNALSYM SDL_LoadBMP}
+
+{ Save a surface to a seekable SDL data source (memory or file.)
+ If 'freedst' is non-zero, the source will be closed after being written.
+ Returns 0 if successful or -1 if there was an error. }
+
+function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: Integer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SaveBMP_RW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SaveBMP_RW}
+
+// Convenience macro -- save a surface to a file
+function SDL_SaveBMP(surface: PSDL_Surface; filename: PChar): Integer;
+{$EXTERNALSYM SDL_SaveBMP}
+
+{ Sets the color key (transparent pixel) in a blittable surface.
+ If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
+ 'key' will be the transparent pixel in the source image of a blit.
+ SDL_RLEACCEL requests RLE acceleration for the surface if present,
+ and removes RLE acceleration if absent.
+ If 'flag' is 0, this function clears any current color key.
+ This function returns 0, or -1 if there was an error. }
+
+function SDL_SetColorKey(surface: PSDL_Surface; flag, key: UInt32) : Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetColorKey'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetColorKey}
+
+{ This function sets the alpha value for the entire surface, as opposed to
+ using the alpha component of each pixel. This value measures the range
+ of transparency of the surface, 0 being completely transparent to 255
+ being completely opaque. An 'alpha' value of 255 causes blits to be
+ opaque, the source pixels copied to the destination (the default). Note
+ that per-surface alpha can be combined with colorkey transparency.
+
+ If 'flag' is 0, alpha blending is disabled for the surface.
+ If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface.
+ OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the
+ surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed. }
+
+
+function SDL_SetAlpha(surface: PSDL_Surface; flag: UInt32; alpha: UInt8): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetAlpha'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetAlpha}
+
+{ Sets the clipping rectangle for the destination surface in a blit.
+
+ If the clip rectangle is NULL, clipping will be disabled.
+ If the clip rectangle doesn't intersect the surface, the function will
+ return SDL_FALSE and blits will be completely clipped. Otherwise the
+ function returns SDL_TRUE and blits to the surface will be clipped to
+ the intersection of the surface area and the clipping rectangle.
+
+ Note that blits are automatically clipped to the edges of the source
+ and destination surfaces. }
+procedure SDL_SetClipRect(surface: PSDL_Surface; rect: PSDL_Rect); cdecl;
+external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetClipRect'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetClipRect}
+
+{ Gets the clipping rectangle for the destination surface in a blit.
+ 'rect' must be a pointer to a valid rectangle which will be filled
+ with the correct values. }
+procedure SDL_GetClipRect(surface: PSDL_Surface; rect: PSDL_Rect); cdecl;
+external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetClipRect'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetClipRect}
+
+{ Creates a new surface of the specified format, and then copies and maps
+ the given surface to it so the blit of the converted surface will be as
+ fast as possible. If this function fails, it returns NULL.
+
+ The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those
+ semantics. You can also pass SDL_RLEACCEL in the flags parameter and
+ SDL will try to RLE accelerate colorkey and alpha blits in the resulting
+ surface.
+
+ This function is used internally by SDL_DisplayFormat(). }
+
+function SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: UInt32): PSDL_Surface;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ConvertSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_ConvertSurface}
+
+{
+ This performs a fast blit from the source surface to the destination
+ surface. It assumes that the source and destination rectangles are
+ the same size. If either 'srcrect' or 'dstrect' are NULL, the entire
+ surface (src or dst) is copied. The final blit rectangles are saved
+ in 'srcrect' and 'dstrect' after all clipping is performed.
+ If the blit is successful, it returns 0, otherwise it returns -1.
+
+ The blit function should not be called on a locked surface.
+
+ The blit semantics for surfaces with and without alpha and colorkey
+ are defined as follows:
+
+ RGBA->RGB:
+ SDL_SRCALPHA set:
+ alpha-blend (using alpha-channel).
+ SDL_SRCCOLORKEY ignored.
+ SDL_SRCALPHA not set:
+ copy RGB.
+ if SDL_SRCCOLORKEY set, only copy the pixels matching the
+ RGB values of the source colour key, ignoring alpha in the
+ comparison.
+
+ RGB->RGBA:
+ SDL_SRCALPHA set:
+ alpha-blend (using the source per-surface alpha value);
+ set destination alpha to opaque.
+ SDL_SRCALPHA not set:
+ copy RGB, set destination alpha to opaque.
+ both:
+ if SDL_SRCCOLORKEY set, only copy the pixels matching the
+ source colour key.
+
+ RGBA->RGBA:
+ SDL_SRCALPHA set:
+ alpha-blend (using the source alpha channel) the RGB values;
+ leave destination alpha untouched. [Note: is this correct?]
+ SDL_SRCCOLORKEY ignored.
+ SDL_SRCALPHA not set:
+ copy all of RGBA to the destination.
+ if SDL_SRCCOLORKEY set, only copy the pixels matching the
+ RGB values of the source colour key, ignoring alpha in the
+ comparison.
+
+ RGB->RGB:
+ SDL_SRCALPHA set:
+ alpha-blend (using the source per-surface alpha value).
+ SDL_SRCALPHA not set:
+ copy RGB.
+ both:
+ if SDL_SRCCOLORKEY set, only copy the pixels matching the
+ source colour key.
+
+ If either of the surfaces were in video memory, and the blit returns -2,
+ the video memory was lost, so it should be reloaded with artwork and
+ re-blitted:
+ while ( SDL_BlitSurface(image, imgrect, screen, dstrect) = -2 ) do
+ begin
+ while ( SDL_LockSurface(image) < 0 ) do
+ Sleep(10);
+ -- Write image pixels to image->pixels --
+ SDL_UnlockSurface(image);
+ end;
+
+ This happens under DirectX 5.0 when the system switches away from your
+ fullscreen application. The lock will also fail until you have access
+ to the video memory again. }
+
+{ You should call SDL_BlitSurface() unless you know exactly how SDL
+ blitting works internally and how to use the other blit functions. }
+
+function SDL_BlitSurface(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): Integer;
+{$EXTERNALSYM SDL_BlitSurface}
+
+{ This is the public blit function, SDL_BlitSurface(), and it performs
+ rectangle validation and clipping before passing it to SDL_LowerBlit() }
+function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UpperBlit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_UpperBlit}
+
+{ This is a semi-private blit function and it performs low-level surface
+ blitting only. }
+function SDL_LowerBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LowerBlit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_LowerBlit}
+
+{ This function performs a fast fill of the given rectangle with 'color'
+ The given rectangle is clipped to the destination surface clip area
+ and the final fill rectangle is saved in the passed in pointer.
+ If 'dstrect' is NULL, the whole surface will be filled with 'color'
+ The color should be a pixel of the format used by the surface, and
+ can be generated by the SDL_MapRGB() function.
+ This function returns 0 on success, or -1 on error. }
+
+function SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: UInt32) : Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FillRect'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_FillRect}
+
+{ This function takes a surface and copies it to a new surface of the
+ pixel format and colors of the video framebuffer, suitable for fast
+ blitting onto the display surface. It calls SDL_ConvertSurface()
+
+ If you want to take advantage of hardware colorkey or alpha blit
+ acceleration, you should set the colorkey and alpha value before
+ calling this function.
+
+ If the conversion fails or runs out of memory, it returns NULL }
+
+function SDL_DisplayFormat(surface: PSDL_Surface): PSDL_Surface; cdecl;
+external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DisplayFormat'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_DisplayFormat}
+
+{ This function takes a surface and copies it to a new surface of the
+ pixel format and colors of the video framebuffer (if possible),
+ suitable for fast alpha blitting onto the display surface.
+ The new surface will always have an alpha channel.
+
+ If you want to take advantage of hardware colorkey or alpha blit
+ acceleration, you should set the colorkey and alpha value before
+ calling this function.
+
+ If the conversion fails or runs out of memory, it returns NULL }
+
+
+function SDL_DisplayFormatAlpha(surface: PSDL_Surface): PSDL_Surface; cdecl;
+external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DisplayFormatAlpha'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_DisplayFormatAlpha}
+
+//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+//* YUV video surface overlay functions */
+//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+{ This function creates a video output overlay
+ Calling the returned surface an overlay is something of a misnomer because
+ the contents of the display surface underneath the area where the overlay
+ is shown is undefined - it may be overwritten with the converted YUV data. }
+
+function SDL_CreateYUVOverlay(width: Integer; height: Integer; format: UInt32; display: PSDL_Surface): PSDL_Overlay;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CreateYUVOverlay}
+
+// Lock an overlay for direct access, and unlock it when you are done
+function SDL_LockYUVOverlay(Overlay: PSDL_Overlay): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LockYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_LockYUVOverlay}
+
+procedure SDL_UnlockYUVOverlay(Overlay: PSDL_Overlay); cdecl;
+external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UnlockYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_UnlockYUVOverlay}
+
+
+{ Blit a video overlay to the display surface.
+ The contents of the video surface underneath the blit destination are
+ not defined.
+ The width and height of the destination rectangle may be different from
+ that of the overlay, but currently only 2x scaling is supported. }
+
+function SDL_DisplayYUVOverlay(Overlay: PSDL_Overlay; dstrect: PSDL_Rect) : Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DisplayYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_DisplayYUVOverlay}
+
+// Free a video overlay
+procedure SDL_FreeYUVOverlay(Overlay: PSDL_Overlay);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_FreeYUVOverlay}
+
+{------------------------------------------------------------------------------}
+{ OpenGL Routines }
+{------------------------------------------------------------------------------}
+
+{ Dynamically load a GL driver, if SDL is built with dynamic GL.
+
+ SDL links normally with the OpenGL library on your system by default,
+ but you can compile it to dynamically load the GL driver at runtime.
+ If you do this, you need to retrieve all of the GL functions used in
+ your program from the dynamic library using SDL_GL_GetProcAddress().
+
+ This is disabled in default builds of SDL. }
+
+
+function SDL_GL_LoadLibrary(filename: PChar): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_LoadLibrary'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GL_LoadLibrary}
+
+{ Get the address of a GL function (for extension functions) }
+function SDL_GL_GetProcAddress(procname: PChar) : Pointer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_GetProcAddress'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GL_GetProcAddress}
+
+{ Set an attribute of the OpenGL subsystem before intialization. }
+function SDL_GL_SetAttribute(attr: TSDL_GLAttr; value: Integer) : Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_SetAttribute'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GL_SetAttribute}
+
+{ Get an attribute of the OpenGL subsystem from the windowing
+ interface, such as glX. This is of course different from getting
+ the values from SDL's internal OpenGL subsystem, which only
+ stores the values you request before initialization.
+
+ Developers should track the values they pass into SDL_GL_SetAttribute
+ themselves if they want to retrieve these values. }
+
+function SDL_GL_GetAttribute(attr: TSDL_GLAttr; var value: Integer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_GetAttribute'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GL_GetAttribute}
+
+{ Swap the OpenGL buffers, if double-buffering is supported. }
+
+procedure SDL_GL_SwapBuffers;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_SwapBuffers'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GL_SwapBuffers;}
+
+{ Internal functions that should not be called unless you have read
+ and understood the source code for these functions. }
+
+procedure SDL_GL_UpdateRects(numrects: Integer; rects: PSDL_Rect);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_UpdateRects'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GL_UpdateRects}
+procedure SDL_GL_Lock;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_Lock'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GL_Lock;}
+procedure SDL_GL_Unlock;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_Unlock'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GL_Unlock;}
+
+{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
+{* These functions allow interaction with the window manager, if any. *}
+{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
+
+{ Sets/Gets the title and icon text of the display window }
+procedure SDL_WM_GetCaption(var title : PChar; var icon : PChar);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_GetCaption'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_WM_GetCaption}
+procedure SDL_WM_SetCaption( const title : PChar; const icon : PChar);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_SetCaption'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_WM_SetCaption}
+
+{ Sets the icon for the display window.
+ This function must be called before the first call to SDL_SetVideoMode().
+ It takes an icon surface, and a mask in MSB format.
+ If 'mask' is NULL, the entire icon surface will be used as the icon. }
+procedure SDL_WM_SetIcon(icon: PSDL_Surface; mask: UInt8);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_SetIcon'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_WM_SetIcon}
+
+{ This function iconifies the window, and returns 1 if it succeeded.
+ If the function succeeds, it generates an SDL_APPACTIVE loss event.
+ This function is a noop and returns 0 in non-windowed environments. }
+
+function SDL_WM_IconifyWindow: Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_IconifyWindow'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_WM_IconifyWindow}
+
+{ Toggle fullscreen mode without changing the contents of the screen.
+ If the display surface does not require locking before accessing
+ the pixel information, then the memory pointers will not change.
+
+ If this function was able to toggle fullscreen mode (change from
+ running in a window to fullscreen, or vice-versa), it will return 1.
+ If it is not implemented, or fails, it returns 0.
+
+ The next call to SDL_SetVideoMode() will set the mode fullscreen
+ attribute based on the flags parameter - if SDL_FULLSCREEN is not
+ set, then the display will be windowed by default where supported.
+
+ This is currently only implemented in the X11 video driver. }
+
+function SDL_WM_ToggleFullScreen(surface: PSDL_Surface): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_ToggleFullScreen'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_WM_ToggleFullScreen}
+
+{ Grabbing means that the mouse is confined to the application window,
+ and nearly all keyboard input is passed directly to the application,
+ and not interpreted by a window manager, if any. }
+
+function SDL_WM_GrabInput(mode: TSDL_GrabMode): TSDL_GrabMode;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_GrabInput'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_WM_GrabInput}
+
+{------------------------------------------------------------------------------}
+{ mouse-routines }
+{------------------------------------------------------------------------------}
+
+{ Retrieve the current state of the mouse.
+ The current button state is returned as a button bitmask, which can
+ be tested using the SDL_BUTTON(X) macros, and x and y are set to the
+ current mouse cursor position. You can pass NULL for either x or y. }
+
+function SDL_GetMouseState(var x: Integer; var y: Integer): UInt8;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetMouseState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetMouseState}
+
+{ Retrieve the current state of the mouse.
+ The current button state is returned as a button bitmask, which can
+ be tested using the SDL_BUTTON(X) macros, and x and y are set to the
+ mouse deltas since the last call to SDL_GetRelativeMouseState(). }
+function SDL_GetRelativeMouseState(var x: Integer; var y: Integer): UInt8;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetRelativeMouseState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetRelativeMouseState}
+
+{ Set the position of the mouse cursor (generates a mouse motion event) }
+procedure SDL_WarpMouse(x, y: UInt16);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WarpMouse'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_WarpMouse}
+
+{ Create a cursor using the specified data and mask (in MSB format).
+ The cursor width must be a multiple of 8 bits.
+
+ The cursor is created in black and white according to the following:
+ data mask resulting pixel on screen
+ 0 1 White
+ 1 1 Black
+ 0 0 Transparent
+ 1 0 Inverted color if possible, black if not.
+
+ Cursors created with this function must be freed with SDL_FreeCursor(). }
+function SDL_CreateCursor(data, mask: PUInt8; w, h, hot_x, hot_y: Integer): PSDL_Cursor;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CreateCursor}
+
+{ Set the currently active cursor to the specified one.
+ If the cursor is currently visible, the change will be immediately
+ represented on the display. }
+procedure SDL_SetCursor(cursor: PSDL_Cursor);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetCursor}
+
+{ Returns the currently active cursor. }
+function SDL_GetCursor: PSDL_Cursor;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetCursor}
+
+{ Deallocates a cursor created with SDL_CreateCursor(). }
+procedure SDL_FreeCursor(cursor: PSDL_Cursor);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_FreeCursor}
+
+{ Toggle whether or not the cursor is shown on the screen.
+ The cursor start off displayed, but can be turned off.
+ SDL_ShowCursor() returns 1 if the cursor was being displayed
+ before the call, or 0 if it was not. You can query the current
+ state by passing a 'toggle' value of -1. }
+function SDL_ShowCursor(toggle: Integer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ShowCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_ShowCursor}
+
+function SDL_BUTTON( Button : Integer ) : Integer;
+
+{------------------------------------------------------------------------------}
+{ Keyboard-routines }
+{------------------------------------------------------------------------------}
+
+{ Enable/Disable UNICODE translation of keyboard input.
+ This translation has some overhead, so translation defaults off.
+ If 'enable' is 1, translation is enabled.
+ If 'enable' is 0, translation is disabled.
+ If 'enable' is -1, the translation state is not changed.
+ It returns the previous state of keyboard translation. }
+function SDL_EnableUNICODE(enable: Integer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_EnableUNICODE'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_EnableUNICODE}
+
+{ If 'delay' is set to 0, keyboard repeat is disabled. }
+function SDL_EnableKeyRepeat(delay: Integer; interval: Integer): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_EnableKeyRepeat'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_EnableKeyRepeat}
+
+procedure SDL_GetKeyRepeat(delay : PInteger; interval: PInteger);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetKeyRepeat'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetKeyRepeat}
+
+{ Get a snapshot of the current state of the keyboard.
+ Returns an array of keystates, indexed by the SDLK_* syms.
+ Used:
+
+ UInt8 *keystate = SDL_GetKeyState(NULL);
+ if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed }
+
+function SDL_GetKeyState(numkeys: PInt): PUInt8;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetKeyState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetKeyState}
+
+{ Get the current key modifier state }
+function SDL_GetModState: TSDLMod;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetModState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetModState}
+
+{ Set the current key modifier state
+ This does not change the keyboard state, only the key modifier flags. }
+procedure SDL_SetModState(modstate: TSDLMod);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetModState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SetModState}
+
+{ Get the name of an SDL virtual keysym }
+function SDL_GetKeyName(key: TSDLKey): PChar;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetKeyName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetKeyName}
+
+{------------------------------------------------------------------------------}
+{ Active Routines }
+{------------------------------------------------------------------------------}
+
+{ This function returns the current state of the application, which is a
+ bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and
+ SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to
+ see your application, otherwise it has been iconified or disabled. }
+
+function SDL_GetAppState: UInt8;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetAppState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetAppState}
+
+
+{ Mutex functions }
+
+{ Create a mutex, initialized unlocked }
+
+function SDL_CreateMutex: PSDL_Mutex;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateMutex'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CreateMutex}
+
+{ Lock the mutex (Returns 0, or -1 on error) }
+
+ function SDL_mutexP(mutex: PSDL_mutex): Integer;
+ cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_mutexP'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{ $ EXTERNALSYM SDL_mutexP}
+
+function SDL_LockMutex(mutex: PSDL_mutex): Integer;
+{$EXTERNALSYM SDL_LockMutex}
+
+{ Unlock the mutex (Returns 0, or -1 on error) }
+function SDL_mutexV(mutex: PSDL_mutex): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_mutexV'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_mutexV}
+
+function SDL_UnlockMutex(mutex: PSDL_mutex): Integer;
+{$EXTERNALSYM SDL_UnlockMutex}
+
+{ Destroy a mutex }
+procedure SDL_DestroyMutex(mutex: PSDL_mutex);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DestroyMutex'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_DestroyMutex}
+
+{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
+{ Semaphore functions }
+{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
+{ Create a semaphore, initialized with value, returns NULL on failure. }
+function SDL_CreateSemaphore(initial_value: UInt32): PSDL_Sem;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateSemaphore'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CreateSemaphore}
+
+
+{ Destroy a semaphore }
+procedure SDL_DestroySemaphore(sem: PSDL_sem);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DestroySemaphore'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_DestroySemaphore}
+
+{ This function suspends the calling thread until the semaphore pointed
+ to by sem has a positive count. It then atomically decreases the semaphore
+ count. }
+
+function SDL_SemWait(sem: PSDL_sem): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemWait'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SemWait}
+
+{ Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds,
+ SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. }
+
+function SDL_SemTryWait(sem: PSDL_sem): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemTryWait'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SemTryWait}
+
+{ Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if
+ the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in
+ the allotted time, and -1 on error.
+ On some platforms this function is implemented by looping with a delay
+ of 1 ms, and so should be avoided if possible. }
+
+function SDL_SemWaitTimeout(sem: PSDL_sem; ms: UInt32): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemWaitTimeout'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SemTryWait}
+
+{ Atomically increases the semaphore's count (not blocking), returns 0,
+ or -1 on error. }
+
+function SDL_SemPost(sem: PSDL_sem): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemPost'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SemTryWait}
+
+{ Returns the current count of the semaphore }
+
+function SDL_SemValue(sem: PSDL_sem): UInt32;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemValue'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_SemValue}
+
+{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
+{ Condition variable functions }
+{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
+{ Create a condition variable }
+function SDL_CreateCond: PSDL_Cond;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateCond'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CreateCond}
+
+{ Destroy a condition variable }
+procedure SDL_DestroyCond(cond: PSDL_Cond);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DestroyCond'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_DestroyCond}
+
+{ Restart one of the threads that are waiting on the condition variable,
+ returns 0 or -1 on error. }
+
+function SDL_CondSignal(cond: PSDL_cond): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CondSignal'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CondSignal}
+
+{ Restart all threads that are waiting on the condition variable,
+ returns 0 or -1 on error. }
+
+function SDL_CondBroadcast(cond: PSDL_cond): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CondBroadcast'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CondBroadcast}
+
+
+{ Wait on the condition variable, unlocking the provided mutex.
+ The mutex must be locked before entering this function!
+ Returns 0 when it is signaled, or -1 on error. }
+
+function SDL_CondWait(cond: PSDL_cond; mut: PSDL_mutex): Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CondWait'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CondWait}
+
+{ Waits for at most 'ms' milliseconds, and returns 0 if the condition
+ variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not
+ signaled in the allotted time, and -1 on error.
+ On some platforms this function is implemented by looping with a delay
+ of 1 ms, and so should be avoided if possible. }
+
+function SDL_CondWaitTimeout(cond: PSDL_cond; mut: PSDL_mutex; ms: UInt32) : Integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CondWaitTimeout'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CondWaitTimeout}
+
+{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
+{ Condition variable functions }
+{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
+
+{ Create a thread }
+function SDL_CreateThread(fn: PInt; data: Pointer): PSDL_Thread;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateThread'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_CreateThread}
+
+{ Get the 32-bit thread identifier for the current thread }
+function SDL_ThreadID: UInt32;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ThreadID'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_ThreadID}
+
+{ Get the 32-bit thread identifier for the specified thread,
+ equivalent to SDL_ThreadID() if the specified thread is NULL. }
+function SDL_GetThreadID(thread: PSDL_Thread): UInt32;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetThreadID'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetThreadID}
+
+{ Wait for a thread to finish.
+ The return code for the thread function is placed in the area
+ pointed to by 'status', if 'status' is not NULL. }
+
+procedure SDL_WaitThread(thread: PSDL_Thread; var status: Integer);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WaitThread'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_WaitThread}
+
+{ Forcefully kill a thread without worrying about its state }
+procedure SDL_KillThread(thread: PSDL_Thread);
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_KillThread'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_KillThread}
+
+{------------------------------------------------------------------------------}
+{ Get Environment Routines }
+{------------------------------------------------------------------------------}
+{$IFDEF WINDOWS}
+function _putenv( const variable : Pchar ): integer;
+cdecl;
+{$ENDIF}
+
+{$IFDEF Unix}
+{$IFDEF FPC}
+function _putenv( const variable : Pchar ): integer;
+cdecl; external 'libc.so' name 'putenv';
+{$ENDIF}
+{$ENDIF}
+
+{ Put a variable of the form "name=value" into the environment }
+//function SDL_putenv(const variable: PChar): integer; cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}SDLLibName name '';
+function SDL_putenv(const variable: PChar): integer;
+{$EXTERNALSYM SDL_putenv}
+
+// The following function has been commented out to encourage developers to use
+// SDL_putenv as it it more portable
+//function putenv(const variable: PChar): integer;
+//{$EXTERNALSYM putenv}
+
+{$IFDEF WINDOWS}
+{$IFNDEF __GPC__}
+function getenv( const name : Pchar ): PChar; cdecl;
+{$ENDIF}
+{$ENDIF}
+
+{* Retrieve a variable named "name" from the environment }
+//function SDL_getenv(const name: PChar): PChar; cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}SDLLibName name '';
+function SDL_getenv(const name: PChar): PChar;
+{$EXTERNALSYM SDL_getenv}
+
+// The following function has been commented out to encourage developers to use
+// SDL_getenv as it it more portable
+//function getenv(const name: PChar): PChar;
+//{$EXTERNALSYM getenv}
+
+{*
+ * This function gives you custom hooks into the window manager information.
+ * It fills the structure pointed to by 'info' with custom information and
+ * returns 1 if the function is implemented. If it's not implemented, or
+ * the version member of the 'info' structure is invalid, it returns 0.
+ *}
+function SDL_GetWMInfo(info : PSDL_SysWMinfo) : integer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetWMInfo'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_GetWMInfo}
+
+{------------------------------------------------------------------------------}
+
+//SDL_loadso.h
+{* This function dynamically loads a shared object and returns a pointer
+ * to the object handle (or NULL if there was an error).
+ * The 'sofile' parameter is a system dependent name of the object file.
+ *}
+function SDL_LoadObject( const sofile : PChar ) : Pointer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LoadObject'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_LoadObject}
+
+{* Given an object handle, this function looks up the address of the
+ * named function in the shared object and returns it. This address
+ * is no longer valid after calling SDL_UnloadObject().
+ *}
+function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer;
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LoadFunction'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_LoadFunction}
+
+{* Unload a shared object from memory *}
+procedure SDL_UnloadObject( handle : Pointer );
+cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UnloadObject'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
+{$EXTERNALSYM SDL_UnloadObject}
+
+
+
+{------------------------------------------------------------------------------}
+
+function SDL_Swap32(D: Uint32): Uint32;
+{$EXTERNALSYM SDL_Swap32}
+
+{ FreeAndNil frees the given TObject instance and sets the variable reference
+ to nil. Be careful to only pass TObjects to this routine. }
+procedure FreeAndNil(var Obj);
+
+{ Exit procedure handling }
+
+{ AddExitProc adds the given procedure to the run-time library's exit
+ procedure list. When an application terminates, its exit procedures are
+ executed in reverse order of definition, i.e. the last procedure passed
+ to AddExitProc is the first one to get executed upon termination. }
+procedure AddExitProc(Proc: TProcedure);
+
+// Bitwise Checking functions
+function IsBitOn( value : integer; bit : Byte ) : boolean;
+
+function TurnBitOn( value : integer; bit : Byte ) : integer;
+
+function TurnBitOff( value : integer; bit : Byte ) : integer;
+
+implementation
+
+{$IFDEF __GPC__}
+ {$L 'sdl'} { link sdl.dll.a or libsdl.so or libsdl.a }
+{$ENDIF}
+
+function SDL_TABLESIZE(table: PChar): Integer;
+begin
+ Result := SizeOf(table) div SizeOf(table[0]);
+end;
+
+procedure SDL_OutOfMemory;
+begin
+ {$IFNDEF WINDOWS}
+ SDL_Error(SDL_ENOMEM);
+ {$ENDIF}
+end;
+
+function SDL_RWSeek(context: PSDL_RWops; offset: Integer; whence: Integer) : Integer;
+begin
+ Result := context^.seek(context, offset, whence);
+end;
+
+function SDL_RWTell(context: PSDL_RWops): Integer;
+begin
+ Result := context^.seek(context, 0, 1);
+end;
+
+function SDL_RWRead(context: PSDL_RWops; ptr: Pointer; size: Integer; n: Integer): Integer;
+begin
+ Result := context^.read(context, ptr, size, n);
+end;
+
+function SDL_RWWrite(context: PSDL_RWops; ptr: Pointer; size: Integer; n: Integer): Integer;
+begin
+ Result := context^.write(context, ptr, size, n);
+end;
+
+function SDL_RWClose(context: PSDL_RWops): Integer;
+begin
+ Result := context^.close(context);
+end;
+
+function SDL_LoadWAV(filename: PChar; spec: PSDL_AudioSpec; audio_buf: PUInt8; audiolen: PUInt32): PSDL_AudioSpec;
+begin
+ Result := SDL_LoadWAV_RW(SDL_RWFromFile(filename, 'rb'), 1, spec, audio_buf, audiolen);
+end;
+
+function SDL_CDInDrive( status : TSDL_CDStatus ): LongBool;
+begin
+ Result := ord( status ) > ord( CD_ERROR );
+end;
+
+procedure FRAMES_TO_MSF(frames: Integer; var M: Integer; var S: Integer; var
+ F: Integer);
+var
+ value: Integer;
+begin
+ value := frames;
+ F := value mod CD_FPS;
+ value := value div CD_FPS;
+ S := value mod 60;
+ value := value div 60;
+ M := value;
+end;
+
+function MSF_TO_FRAMES(M: Integer; S: Integer; F: Integer): Integer;
+begin
+ Result := M * 60 * CD_FPS + S * CD_FPS + F;
+end;
+
+procedure SDL_VERSION(var X: TSDL_Version);
+begin
+ X.major := SDL_MAJOR_VERSION;
+ X.minor := SDL_MINOR_VERSION;
+ X.patch := SDL_PATCHLEVEL;
+end;
+
+function SDL_VERSIONNUM(X, Y, Z: Integer): Integer;
+begin
+ Result := X * 1000 + Y * 100 + Z;
+end;
+
+function SDL_COMPILEDVERSION: Integer;
+begin
+ Result := SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL
+ );
+end;
+
+function SDL_VERSION_ATLEAST(X, Y, Z: Integer): LongBool;
+begin
+ Result := (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z));
+end;
+
+function SDL_LoadBMP(filename: PChar): PSDL_Surface;
+begin
+ Result := SDL_LoadBMP_RW(SDL_RWFromFile(filename, 'rb'), 1);
+end;
+
+function SDL_SaveBMP(surface: PSDL_Surface; filename: PChar): Integer;
+begin
+ Result := SDL_SaveBMP_RW(surface, SDL_RWFromFile(filename, 'wb'), 1);
+end;
+
+function SDL_BlitSurface(src: PSDL_Surface; srcrect: PSDL_Rect; dst:
+ PSDL_Surface;
+ dstrect: PSDL_Rect): Integer;
+begin
+ Result := SDL_UpperBlit(src, srcrect, dst, dstrect);
+end;
+
+function SDL_AllocSurface(flags: UInt32; width, height, depth: Integer;
+ RMask, GMask, BMask, AMask: UInt32): PSDL_Surface;
+begin
+ Result := SDL_CreateRGBSurface(flags, width, height, depth, RMask, GMask,
+ BMask, AMask);
+end;
+
+function SDL_MustLock(Surface: PSDL_Surface): Boolean;
+begin
+ Result := ( ( surface^.offset <> 0 ) or
+ ( ( surface^.flags and ( SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL ) ) <> 0 ) );
+end;
+
+function SDL_LockMutex(mutex: PSDL_mutex): Integer;
+begin
+ Result := SDL_mutexP(mutex);
+end;
+
+function SDL_UnlockMutex(mutex: PSDL_mutex): Integer;
+begin
+ Result := SDL_mutexV(mutex);
+end;
+
+{$IFDEF WINDOWS}
+function _putenv( const variable : Pchar ): Integer;
+cdecl; external {$IFDEF __GPC__}name '_putenv'{$ELSE} 'MSVCRT.DLL'{$ENDIF __GPC__};
+{$ENDIF}
+
+
+function SDL_putenv(const variable: PChar): Integer;
+begin
+ {$IFDEF WINDOWS}
+ Result := _putenv(variable);
+ {$ENDIF}
+
+ {$IFDEF UNIX}
+ {$IFDEF FPC}
+ Result := _putenv(variable);
+ {$ELSE}
+ Result := libc.putenv(variable);
+ {$ENDIF}
+ {$ENDIF}
+end;
+
+{$IFDEF WINDOWS}
+{$IFNDEF __GPC__}
+function getenv( const name : Pchar ): PChar;
+cdecl; external {$IFDEF __GPC__}name 'getenv'{$ELSE} 'MSVCRT.DLL'{$ENDIF};
+{$ENDIF}
+{$ENDIF}
+
+function SDL_getenv(const name: PChar): PChar;
+begin
+ {$IFDEF WINDOWS}
+
+ {$IFDEF __GPC__}
+ Result := getenv( string( name ) );
+ {$ELSE}
+ Result := getenv( name );
+ {$ENDIF}
+
+ {$ELSE}
+
+ {$IFDEF UNIX}
+
+ {$IFDEF FPC}
+ Result := fpgetenv(name);
+ {$ELSE}
+ Result := libc.getenv(name);
+ {$ENDIF}
+
+ {$ENDIF}
+
+ {$ENDIF}
+end;
+
+function SDL_BUTTON( Button : Integer ) : Integer;
+begin
+ Result := SDL_PRESSED shl ( Button - 1 );
+end;
+
+function SDL_Swap32(D: Uint32): Uint32;
+begin
+ Result := ((D shl 24) or ((D shl 8) and $00FF0000) or ((D shr 8) and $0000FF00) or (D shr 24));
+end;
+
+procedure FreeAndNil(var Obj);
+{$IFNDEF __GPC__}
+{$IFNDEF __TMT__}
+var
+ Temp: TObject;
+{$ENDIF}
+{$ENDIF}
+begin
+{$IFNDEF __GPC__}
+{$IFNDEF __TMT__}
+ Temp := TObject(Obj);
+ Pointer(Obj) := nil;
+ Temp.Free;
+{$ENDIF}
+{$ENDIF}
+end;
+
+{ Exit procedure handling }
+type
+ PExitProcInfo = ^TExitProcInfo;
+ TExitProcInfo = record
+ Next: PExitProcInfo;
+ SaveExit: Pointer;
+ Proc: TProcedure;
+ end;
+
+var
+ ExitProcList: PExitProcInfo = nil;
+
+procedure DoExitProc;
+var
+ P: PExitProcInfo;
+ Proc: TProcedure;
+begin
+ P := ExitProcList;
+ ExitProcList := P^.Next;
+ ExitProc := P^.SaveExit;
+ Proc := P^.Proc;
+ Dispose(P);
+ Proc;
+end;
+
+procedure AddExitProc(Proc: TProcedure);
+var
+ P: PExitProcInfo;
+begin
+ New(P);
+ P^.Next := ExitProcList;
+ P^.SaveExit := ExitProc;
+ P^.Proc := Proc;
+ ExitProcList := P;
+ ExitProc := @DoExitProc;
+end;
+
+function IsBitOn( value : integer; bit : Byte ) : boolean;
+begin
+ result := ( ( value and ( 1 shl bit ) ) <> 0 );
+end;
+
+function TurnBitOn( value : integer; bit : Byte ) : integer;
+begin
+ result := ( value or ( 1 shl bit ) );
+end;
+
+function TurnBitOff( value : integer; bit : Byte ) : integer;
+begin
+ result := ( value and not ( 1 shl bit ) );
+end;
+
+end.
+
+
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/sdl_cpuinfo.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdl_cpuinfo.pas new file mode 100644 index 00000000..bd371c55 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdl_cpuinfo.pas @@ -0,0 +1,155 @@ +unit sdl_cpuinfo;
+{
+ $Id: sdl_cpuinfo.pas,v 1.2 2004/02/18 22:52:53 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ Borland Delphi SDL - Simple DirectMedia Layer }
+{ Conversion of the Simple DirectMedia Layer Headers }
+{ }
+{ Portions created by Sam Lantinga <slouken@devolution.com> are }
+{ Copyright (C) 1997-2004 Sam Lantinga }
+{ 5635-34 Springhouse Dr. }
+{ Pleasanton, CA 94588 (USA) }
+{ }
+{ All Rights Reserved. }
+{ }
+{ The original files are : SDL_cpuinfo.h }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Dominqiue Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Portions created by Dominqiue Louis are }
+{ Copyright (C) 2000 - 2004 Dominqiue Louis. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so }
+{ They are available from... }
+{ http://www.libsdl.org . }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{
+ $Log: sdl_cpuinfo.pas,v $
+ Revision 1.2 2004/02/18 22:52:53 savage
+ Forgot to add jedi-sdl.inc file. It's there now.
+
+ Revision 1.1 2004/02/18 22:35:54 savage
+ Brought sdl.pas up to 1.2.7 compatability
+ Thus...
+ Added SDL_GL_STEREO,
+ SDL_GL_MULTISAMPLEBUFFERS,
+ SDL_GL_MULTISAMPLESAMPLES
+
+ Add DLL/Shared object functions
+ function SDL_LoadObject( const sofile : PChar ) : Pointer;
+
+ function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer;
+
+ procedure SDL_UnloadObject( handle : Pointer );
+
+ Added function to create RWops from const memory: SDL_RWFromConstMem()
+ function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops;
+
+ Ported SDL_cpuinfo.h so Now you can test for Specific CPU types.
+
+
+}
+{******************************************************************************}
+
+interface
+
+{$I jedi-sdl.inc}
+
+uses
+ sdl;
+
+{* This function returns true if the CPU has the RDTSC instruction
+ *}
+function SDL_HasRDTSC : SDL_Bool;
+cdecl; external {$IFDEF __GPC__}name 'SDL_HasRDTSC'{$ELSE} SDLLibName{$ENDIF __GPC__};
+{$EXTERNALSYM SDL_HasRDTSC}
+
+{* This function returns true if the CPU has MMX features
+ *}
+function SDL_HasMMX : SDL_Bool;
+cdecl; external {$IFDEF __GPC__}name 'SDL_HasMMX'{$ELSE} SDLLibName{$ENDIF __GPC__};
+{$EXTERNALSYM SDL_HasMMX}
+
+{* This function returns true if the CPU has MMX Ext. features
+ *}
+function SDL_HasMMXExt : SDL_Bool;
+cdecl; external {$IFDEF __GPC__}name 'SDL_HasMMXExt'{$ELSE} SDLLibName{$ENDIF __GPC__};
+{$EXTERNALSYM SDL_HasMMXExt}
+
+{* This function returns true if the CPU has 3DNow features
+ *}
+function SDL_Has3DNow : SDL_Bool;
+cdecl; external {$IFDEF __GPC__}name 'SDL_Has3DNow'{$ELSE} SDLLibName{$ENDIF __GPC__};
+{$EXTERNALSYM SDL_Has3DNow}
+
+{* This function returns true if the CPU has 3DNow! Ext. features
+ *}
+function SDL_Has3DNowExt : SDL_Bool;
+cdecl; external {$IFDEF __GPC__}name 'SDL_Has3DNowExt'{$ELSE} SDLLibName{$ENDIF __GPC__};
+{$EXTERNALSYM SDL_Has3DNowExt}
+
+{* This function returns true if the CPU has SSE features
+ *}
+function SDL_HasSSE : SDL_Bool;
+cdecl; external {$IFDEF __GPC__}name 'SDL_HasSSE'{$ELSE} SDLLibName{$ENDIF __GPC__};
+{$EXTERNALSYM SDL_HasSSE}
+
+{* This function returns true if the CPU has SSE2 features
+ *}
+function SDL_HasSSE2 : SDL_Bool;
+cdecl; external {$IFDEF __GPC__}name 'SDL_HasSSE2'{$ELSE} SDLLibName{$ENDIF __GPC__};
+{$EXTERNALSYM SDL_HasSSE2}
+
+{* This function returns true if the CPU has AltiVec features
+ *}
+function SDL_HasAltiVec : SDL_Bool;
+cdecl; external {$IFDEF __GPC__}name 'SDL_HasAltiVec'{$ELSE} SDLLibName{$ENDIF __GPC__};
+{$EXTERNALSYM SDL_HasAltiVec}
+
+implementation
+
+end.
+
\ No newline at end of file diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlgameinterface.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlgameinterface.pas new file mode 100644 index 00000000..cc95751d --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlgameinterface.pas @@ -0,0 +1,202 @@ +unit sdlgameinterface;
+{
+ $Id: sdlgameinterface.pas,v 1.4 2005/08/03 18:57:31 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer }
+{ Game Interface Base class }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Dominqiue Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Portions created by Dominqiue Louis are }
+{ Copyright (C) 2000 - 2001 Dominqiue Louis. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so }
+{ They are available from... }
+{ http://www.libsdl.org . }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ September 23 2004 - DL : Initial Creation }
+{
+ $Log: sdlgameinterface.pas,v $
+ Revision 1.4 2005/08/03 18:57:31 savage
+ Various updates and additions. Mainly to handle OpenGL 3D Window support and better cursor support for the mouse class
+
+ Revision 1.3 2004/10/17 18:41:49 savage
+ Slight Change to allow Reseting of Input Event handlers
+
+ Revision 1.2 2004/09/30 22:35:47 savage
+ Changes, enhancements and additions as required to get SoAoS working.
+
+
+}
+{******************************************************************************}
+
+interface
+
+uses
+ sdl,
+ sdlwindow;
+
+type
+ TGameInterfaceClass = class of TGameInterface;
+
+ TGameInterface = class( TObject )
+ private
+ FNextGameInterface : TGameInterfaceClass;
+ protected
+ Dragging : Boolean;
+ Loaded : Boolean;
+ procedure FreeSurfaces; virtual;
+ procedure Render; virtual; abstract;
+ procedure Close; virtual;
+ procedure Update( aElapsedTime : single ); virtual;
+ procedure MouseDown( Button : Integer; Shift: TSDLMod; MousePos : TPoint ); virtual;
+ procedure MouseMove( Shift: TSDLMod; CurrentPos : TPoint; RelativePos : TPoint ); virtual;
+ procedure MouseUp( Button : Integer; Shift: TSDLMod; MousePos : TPoint ); virtual;
+ procedure MouseWheelScroll( WheelDelta : Integer; Shift: TSDLMod; MousePos : TPoint ); virtual;
+ procedure KeyDown( var Key: TSDLKey; Shift: TSDLMod; unicode : UInt16 ); virtual;
+ public
+ MainWindow : TSDLCustomWindow;
+ procedure ResetInputManager;
+ procedure LoadSurfaces; virtual;
+ function PointIsInRect( Point : TPoint; x, y, x1, y1 : integer ) : Boolean;
+ constructor Create( const aMainWindow : TSDLCustomWindow );
+ destructor Destroy; override;
+ property NextGameInterface : TGameInterfaceClass read FNextGameInterface write FNextGameInterface;
+ end;
+
+implementation
+
+{ TGameInterface }
+procedure TGameInterface.Close;
+begin
+ FNextGameInterface := nil;
+end;
+
+constructor TGameInterface.Create( const aMainWindow : TSDLCustomWindow );
+begin
+ inherited Create;
+ MainWindow := aMainWindow;
+ FNextGameInterface := TGameInterface;
+ ResetInputManager;
+end;
+
+destructor TGameInterface.Destroy;
+begin
+ if Loaded then
+ FreeSurfaces;
+ inherited;
+end;
+
+procedure TGameInterface.FreeSurfaces;
+begin
+ Loaded := False;
+end;
+
+procedure TGameInterface.KeyDown(var Key: TSDLKey; Shift: TSDLMod; unicode: UInt16);
+begin
+
+end;
+
+procedure TGameInterface.LoadSurfaces;
+begin
+ Loaded := True;
+end;
+
+procedure TGameInterface.MouseDown(Button: Integer; Shift: TSDLMod; MousePos: TPoint);
+begin
+ Dragging := True;
+end;
+
+procedure TGameInterface.MouseMove(Shift: TSDLMod; CurrentPos, RelativePos: TPoint);
+begin
+
+end;
+
+procedure TGameInterface.MouseUp(Button: Integer; Shift: TSDLMod; MousePos: TPoint);
+begin
+ Dragging := True;
+end;
+
+procedure TGameInterface.MouseWheelScroll(WheelDelta: Integer; Shift: TSDLMod; MousePos: TPoint);
+begin
+
+end;
+
+function TGameInterface.PointIsInRect( Point : TPoint; x, y, x1, y1: integer ): Boolean;
+begin
+ if ( Point.x >= x )
+ and ( Point.y >= y )
+ and ( Point.x <= x1 )
+ and ( Point.y <= y1 ) then
+ result := true
+ else
+ result := false;
+end;
+
+procedure TGameInterface.ResetInputManager;
+var
+ temp : TSDLNotifyEvent;
+begin
+ MainWindow.InputManager.Mouse.OnMouseDown := MouseDown;
+ MainWindow.InputManager.Mouse.OnMouseMove := MouseMove;
+ MainWindow.InputManager.Mouse.OnMouseUp := MouseUp;
+ MainWindow.InputManager.Mouse.OnMouseWheel := MouseWheelScroll;
+ MainWindow.InputManager.KeyBoard.OnKeyDown := KeyDown;
+ temp := Render;
+ MainWindow.OnRender := temp;
+ temp := Close;
+ MainWindow.OnClose := temp;
+ MainWindow.OnUpdate := Update;
+end;
+
+procedure TGameInterface.Update(aElapsedTime: single);
+begin
+
+end;
+
+end.
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/sdli386utils.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdli386utils.pas new file mode 100644 index 00000000..9151168a --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdli386utils.pas @@ -0,0 +1,5236 @@ +unit sdli386utils;
+{
+ $Id: sdli386utils.pas,v 1.5 2004/06/02 19:38:53 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ Borland Delphi SDL - Simple DirectMedia Layer }
+{ SDL Utility functions }
+{ }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Tom Jones <tigertomjones@gmx.de> }
+{ }
+{ Portions created by Tom Jones are }
+{ Copyright (C) 2000 - 2001 Tom Jones. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ Dominique Louis <Dominique@SavageSoftware.com.au> }
+{ Róbert Kisnémeth <mikrobi@freemail.hu> }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ Helper functions... }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ SDL.dll on Windows platforms }
+{ libSDL-1.1.so.0 on Linux platform }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ 2000 - TJ : Initial creation }
+{ }
+{ July 13 2001 - DL : Added PutPixel and GetPixel routines. }
+{ }
+{ Sept 14 2001 - RK : Added flipping routines. }
+{ }
+{ Sept 19 2001 - RK : Added PutPixel & line drawing & blitting with ADD }
+{ effect. Fixed a bug in SDL_PutPixel & SDL_GetPixel }
+{ Added PSDLRect() }
+{ Sept 22 2001 - DL : Removed need for Windows.pas by defining types here}
+{ Also removed by poor attempt or a dialog box }
+{ }
+{ Sept 25 2001 - RK : Added PixelTest, NewPutPixel, SubPixel, SubLine, }
+{ SubSurface, MonoSurface & TexturedSurface }
+{ }
+{ Sept 26 2001 - DL : Made change so that it refers to native Pascal }
+{ types rather that Windows types. This makes it more}
+{ portable to Linix. }
+{ }
+{ Sept 27 2001 - RK : SDLUtils now can be compiled with FreePascal }
+{ }
+{ Oct 27 2001 - JF : Added ScrollY function }
+{ }
+{ Jan 21 2002 - RK : Added SDL_ZoomSurface and SDL_WarpSurface }
+{ }
+{ Mar 28 2002 - JF : Added SDL_RotateSurface }
+{ }
+{ May 13 2002 - RK : Improved SDL_FillRectAdd & SDL_FillRectSub }
+{ }
+{ May 27 2002 - YS : GradientFillRect function }
+{ }
+{ May 30 2002 - RK : Added SDL_2xBlit, SDL_Scanline2xBlit }
+{ & SDL_50Scanline2xBlit }
+{ }
+{ June 12 2002 - RK : Added SDL_PixelTestSurfaceVsRect }
+{ }
+{ June 12 2002 - JF : Updated SDL_PixelTestSurfaceVsRect }
+{ }
+{ November 9 2002 - JF : Added Jason's boolean Surface functions }
+{ }
+{ December 10 2002 - DE : Added Dean's SDL_ClipLine function }
+{ }
+{******************************************************************************}
+{
+ $Log: sdli386utils.pas,v $
+ Revision 1.5 2004/06/02 19:38:53 savage
+ Changes to SDL_GradientFillRect as suggested by
+ Ángel Eduardo García Hernández. Many thanks.
+
+ Revision 1.4 2004/05/29 23:11:53 savage
+ Changes to SDL_ScaleSurfaceRect as suggested by
+ Ángel Eduardo García Hernández to fix a colour issue with the function. Many thanks.
+
+ Revision 1.3 2004/02/20 22:04:11 savage
+ Added Changes as mentioned by Rodrigo "Rui" R. (1/2 RRC2Soft) to facilitate FPC compilation and it also works in Delphi. Also syncronized the funcitons so that they are identical to sdlutils.pas, when no assembly version is available.
+
+ Revision 1.2 2004/02/14 00:23:39 savage
+ As UNIX is defined in jedi-sdl.inc this will be used to check linux compatability as well. Units have been changed to reflect this change.
+
+ Revision 1.1 2004/02/05 00:08:20 savage
+ Module 1.0 release
+
+
+}
+
+interface
+
+{$i jedi-sdl.inc}
+
+uses
+{$IFDEF UNIX}
+ Types,
+ Xlib,
+{$ENDIF}
+ SysUtils,
+ sdl;
+
+type
+ TGradientStyle = ( gsHorizontal, gsVertical );
+
+ // Pixel procedures
+function SDL_PixelTest( SrcSurface1 : PSDL_Surface; SrcRect1 : PSDL_Rect; SrcSurface2 :
+ PSDL_Surface; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) : Boolean;
+
+function SDL_GetPixel( SrcSurface : PSDL_Surface; x : cardinal; y : cardinal ) : Uint32;
+
+procedure SDL_PutPixel( SrcSurface : PSDL_Surface; x : integer; y : integer; Color :
+ cardinal );
+
+procedure SDL_AddPixel( SrcSurface : PSDL_Surface; x : integer; y : integer; Color :
+ cardinal );
+
+procedure SDL_SubPixel( SrcSurface : PSDL_Surface; x : integer; y : integer; Color :
+ cardinal );
+
+// Line procedures
+procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal );overload;
+
+procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal ; DashLength, DashSpace : byte ); overload;
+
+procedure SDL_AddLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal );
+
+procedure SDL_SubLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal );
+
+// Surface procedures
+procedure SDL_AddSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DstSurface : PSDL_Surface; DestRect : PSDL_Rect );
+
+procedure SDL_SubSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DstSurface : PSDL_Surface; DestRect : PSDL_Rect );
+
+procedure SDL_MonoSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DstSurface : PSDL_Surface; DestRect : PSDL_Rect; Color : cardinal );
+
+procedure SDL_TexturedSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DstSurface : PSDL_Surface; DestRect : PSDL_Rect; Texture : PSDL_Surface;
+ TextureRect : PSDL_Rect );
+
+procedure SDL_ZoomSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; DstRect : PSDL_Rect );
+
+procedure SDL_WarpSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; UL, UR, LR, LL : PPoint );
+
+// Flip procedures
+procedure SDL_FlipRectH( DstSurface : PSDL_Surface; Rect : PSDL_Rect );
+
+procedure SDL_FlipRectV( DstSurface : PSDL_Surface; Rect : PSDL_Rect );
+
+function PSDLRect( aLeft, aTop, aWidth, aHeight : integer ) : PSDL_Rect;
+
+function SDLRect( aLeft, aTop, aWidth, aHeight : integer ) : TSDL_Rect; overload;
+
+function SDLRect( aRect : TRect ) : TSDL_Rect; overload;
+
+function SDL_ScaleSurfaceRect( SrcSurface : PSDL_Surface; SrcX1, SrcY1, SrcW, SrcH,
+ Width, Height : integer ) : PSDL_Surface;
+
+procedure SDL_ScrollY( DstSurface : PSDL_Surface; DifY : integer );
+
+procedure SDL_ScrollX( DstSurface : PSDL_Surface; DifX : integer );
+
+procedure SDL_RotateDeg( DstSurface, SrcSurface : PSDL_Surface; SrcRect :
+ PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Integer );
+
+procedure SDL_RotateRad( DstSurface, SrcSurface : PSDL_Surface; SrcRect :
+ PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Single );
+
+function ValidateSurfaceRect( DstSurface : PSDL_Surface; dstrect : PSDL_Rect ) : TSDL_Rect;
+
+// Fill Rect routine
+procedure SDL_FillRectAdd( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 );
+
+procedure SDL_FillRectSub( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 );
+
+procedure SDL_GradientFillRect( DstSurface : PSDL_Surface; const Rect : PSDL_Rect; const StartColor, EndColor : TSDL_Color; const Style : TGradientStyle );
+
+// NOTE for All SDL_2xblit... function : the dest surface must be 2x of the source surface!
+procedure SDL_2xBlit( Src, Dest : PSDL_Surface );
+
+procedure SDL_Scanline2xBlit( Src, Dest : PSDL_Surface );
+
+procedure SDL_50Scanline2xBlit( Src, Dest : PSDL_Surface );
+
+function SDL_PixelTestSurfaceVsRect( SrcSurface1 : PSDL_Surface; SrcRect1 :
+PSDL_Rect; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) :
+boolean;
+
+// Jason's boolean Surface functions
+procedure SDL_ORSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+
+procedure SDL_ANDSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+
+procedure SDL_GTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+
+procedure SDL_LTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+
+function SDL_ClipLine(var x1,y1,x2,y2: Integer; ClipRect: PSDL_Rect) : boolean;
+
+implementation
+
+uses
+ Math;
+
+function SDL_PixelTest( SrcSurface1 : PSDL_Surface; SrcRect1 : PSDL_Rect; SrcSurface2 :
+ PSDL_Surface; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) : boolean;
+var
+ Src_Rect1, Src_Rect2 : TSDL_Rect;
+ right1, bottom1 : integer;
+ right2, bottom2 : integer;
+ Scan1Start, Scan2Start, ScanWidth, ScanHeight : cardinal;
+ Mod1, Mod2 : cardinal;
+ Addr1, Addr2 : cardinal;
+ BPP : cardinal;
+ Pitch1, Pitch2 : cardinal;
+ TransparentColor1, TransparentColor2 : cardinal;
+ tx, ty : cardinal;
+ StartTick : cardinal;
+ Color1, Color2 : cardinal;
+begin
+ Result := false;
+ if SrcRect1 = nil then
+ begin
+ with Src_Rect1 do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface1.w;
+ h := SrcSurface1.h;
+ end;
+ end
+ else
+ Src_Rect1 := SrcRect1^;
+ if SrcRect2 = nil then
+ begin
+ with Src_Rect2 do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface2.w;
+ h := SrcSurface2.h;
+ end;
+ end
+ else
+ Src_Rect2 := SrcRect2^;
+ with Src_Rect1 do
+ begin
+ Right1 := Left1 + w;
+ Bottom1 := Top1 + h;
+ end;
+ with Src_Rect2 do
+ begin
+ Right2 := Left2 + w;
+ Bottom2 := Top2 + h;
+ end;
+ if ( Left1 >= Right2 ) or ( Right1 <= Left2 ) or ( Top1 >= Bottom2 ) or ( Bottom1 <=
+ Top2 ) then
+ exit;
+ if Left1 <= Left2 then
+ begin
+ // 1. left, 2. right
+ Scan1Start := Src_Rect1.x + Left2 - Left1;
+ Scan2Start := Src_Rect2.x;
+ ScanWidth := Right1 - Left2;
+ with Src_Rect2 do
+ if ScanWidth > w then
+ ScanWidth := w;
+ end
+ else
+ begin
+ // 1. right, 2. left
+ Scan1Start := Src_Rect1.x;
+ Scan2Start := Src_Rect2.x + Left1 - Left2;
+ ScanWidth := Right2 - Left1;
+ with Src_Rect1 do
+ if ScanWidth > w then
+ ScanWidth := w;
+ end;
+ with SrcSurface1^ do
+ begin
+ Pitch1 := Pitch;
+ Addr1 := cardinal( Pixels );
+ inc( Addr1, Pitch1 * UInt32( Src_Rect1.y ) );
+ with format^ do
+ begin
+ BPP := BytesPerPixel;
+ TransparentColor1 := colorkey;
+ end;
+ end;
+ with SrcSurface2^ do
+ begin
+ TransparentColor2 := format.colorkey;
+ Pitch2 := Pitch;
+ Addr2 := cardinal( Pixels );
+ inc( Addr2, Pitch2 * UInt32( Src_Rect2.y ) );
+ end;
+ Mod1 := Pitch1 - ( ScanWidth * BPP );
+ Mod2 := Pitch2 - ( ScanWidth * BPP );
+ inc( Addr1, BPP * Scan1Start );
+ inc( Addr2, BPP * Scan2Start );
+ if Top1 <= Top2 then
+ begin
+ // 1. up, 2. down
+ ScanHeight := Bottom1 - Top2;
+ if ScanHeight > Src_Rect2.h then
+ ScanHeight := Src_Rect2.h;
+ inc( Addr1, Pitch1 * UInt32( Top2 - Top1 ) );
+ end
+ else
+ begin
+ // 1. down, 2. up
+ ScanHeight := Bottom2 - Top1;
+ if ScanHeight > Src_Rect1.h then
+ ScanHeight := Src_Rect1.h;
+ inc( Addr2, Pitch2 * UInt32( Top1 - Top2 ) );
+ end;
+ case BPP of
+ 1 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ if ( PByte( Addr1 )^ <> TransparentColor1 ) and ( PByte( Addr2 )^ <>
+ TransparentColor2 ) then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1 );
+ inc( Addr2 );
+ end;
+ inc( Addr1, Mod1 );
+ inc( Addr2, Mod2 );
+ end;
+ 2 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ if ( PWord( Addr1 )^ <> TransparentColor1 ) and ( PWord( Addr2 )^ <>
+ TransparentColor2 ) then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1, 2 );
+ inc( Addr2, 2 );
+ end;
+ inc( Addr1, Mod1 );
+ inc( Addr2, Mod2 );
+ end;
+ 3 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ Color1 := PLongWord( Addr1 )^ and $00FFFFFF;
+ Color2 := PLongWord( Addr2 )^ and $00FFFFFF;
+ if ( Color1 <> TransparentColor1 ) and ( Color2 <> TransparentColor2 )
+ then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1, 3 );
+ inc( Addr2, 3 );
+ end;
+ inc( Addr1, Mod1 );
+ inc( Addr2, Mod2 );
+ end;
+ 4 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ if ( PLongWord( Addr1 )^ <> TransparentColor1 ) and ( PLongWord( Addr2 )^ <>
+ TransparentColor2 ) then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1, 4 );
+ inc( Addr2, 4 );
+ end;
+ inc( Addr1, Mod1 );
+ inc( Addr2, Mod2 );
+ end;
+ end;
+end;
+
+function SDL_GetPixel( SrcSurface : PSDL_Surface; x : cardinal; y : cardinal ) : Uint32;
+var
+ bpp : UInt32;
+ p : PInteger;
+begin
+ bpp := SrcSurface.format.BytesPerPixel;
+ // Here p is the address to the pixel we want to retrieve
+ p := Pointer( Uint32( SrcSurface.pixels ) + UInt32( y ) * SrcSurface.pitch + UInt32( x ) *
+ bpp );
+ case bpp of
+ 1 : result := PUint8( p )^;
+ 2 : result := PUint16( p )^;
+ 3 :
+ if ( SDL_BYTEORDER = SDL_BIG_ENDIAN ) then
+ result := PUInt8Array( p )[ 0 ] shl 16 or PUInt8Array( p )[ 1 ] shl 8 or
+ PUInt8Array( p )[ 2 ]
+ else
+ result := PUInt8Array( p )[ 0 ] or PUInt8Array( p )[ 1 ] shl 8 or
+ PUInt8Array( p )[ 2 ] shl 16;
+ 4 : result := PUint32( p )^;
+ else
+ result := 0; // shouldn't happen, but avoids warnings
+ end;
+end;
+
+procedure SDL_PutPixel( SrcSurface : PSDL_Surface; x : integer; y : integer; Color :
+ cardinal );
+var
+ Addr, Pitch, BPP : cardinal;
+begin
+ Addr := cardinal( SrcSurface.Pixels );
+ Pitch := SrcSurface.Pitch;
+ BPP := SrcSurface.format.BytesPerPixel;
+ asm
+ mov eax, y
+ mul Pitch // EAX := y * Pitch
+ add Addr, eax // Addr:= Addr + (y * Pitch)
+ mov eax, x
+ mov ecx, Color
+ cmp BPP, 1
+ jne @Not1BPP
+ add eax, Addr // Now: EAX:= Addr + (y * Pitch) + x
+ mov [eax], cl
+ jmp @Quit
+ @Not1BPP:
+ cmp BPP, 2
+ jne @Not2BPP
+ mul BPP // EAX := x * BPP
+ add eax, Addr // Now: EAX:= Addr + (y * Pitch) + x * BPP
+ mov [eax], cx
+ jmp @Quit
+ @Not2BPP:
+ cmp BPP, 3
+ jne @Not3BPP
+ mul BPP // EAX := x * BPP
+ add eax, Addr // Now: EAX:= Addr + (y * Pitch) + x * BPP
+ mov edx, [eax]
+ and edx, $ff000000
+ or edx, ecx
+ mov [eax], edx
+ jmp @Quit
+ @Not3BPP:
+ mul BPP // EAX := x * BPP
+ add eax, Addr // Now: EAX:= Addr + (y * Pitch) + x * BPP
+ mov [eax], ecx
+ @Quit:
+ end;
+end;
+
+procedure SDL_AddPixel( SrcSurface : PSDL_Surface; x : integer; y : integer; Color :
+ cardinal );
+var
+ SrcColor, FinalColor : cardinal;
+ Addr, Pitch, Bits : cardinal;
+begin
+ if Color = 0 then
+ exit;
+ Addr := cardinal( SrcSurface.Pixels );
+ Pitch := SrcSurface.Pitch;
+ Bits := SrcSurface.format.BitsPerPixel;
+ asm
+ mov eax, y
+ mul Pitch // EAX := y * Pitch
+ add Addr, eax // Addr:= Addr + (y * Pitch)
+ mov eax, x
+ cmp Bits, 8
+ jne @Not8bit
+ add eax, Addr // Now: EAX:= Addr + (y * Pitch) + x
+ mov cl, [eax]
+ movzx ecx, cl
+ mov SrcColor, ecx
+ mov edx, Color
+ and ecx, 3
+ and edx, 3
+ add ecx, edx
+ cmp ecx, 3
+ jbe @Skip1_8bit
+ mov ecx, 3
+ @Skip1_8bit:
+ mov FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $1c
+ and edx, $1c
+ add ecx, edx
+ cmp ecx, $1c
+ jbe @Skip2_8bit
+ mov ecx, $1c
+ @Skip2_8bit:
+ or FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $e0
+ and edx, $e0
+ add ecx, edx
+ cmp ecx, $e0
+ jbe @Skip3_8bit
+ mov ecx, $e0
+ @Skip3_8bit:
+ or ecx, FinalColor
+ mov [eax], cl
+ jmp @Quit
+ @Not8bit:
+ cmp Bits, 15
+ jne @Not15bit
+ shl eax, 1
+ add eax, Addr // Now: EAX:= Addr + (y * Pitch) + x * 2
+ mov ecx, [eax]
+ and ecx, $00007fff
+ mov SrcColor, ecx
+ mov edx, Color
+ and ecx, $1f
+ and edx, $1f
+ add ecx, edx
+ cmp ecx, $1f
+ jbe @Skip1_15bit
+ mov ecx, $1f
+ @Skip1_15bit:
+ mov FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $03e0
+ and edx, $03e0
+ add ecx, edx
+ cmp ecx, $03e0
+ jbe @Skip2_15bit
+ mov ecx, $03e0
+ @Skip2_15bit:
+ or FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $7c00
+ and edx, $7c00
+ add ecx, edx
+ cmp ecx, $7c00
+ jbe @Skip3_15bit
+ mov ecx, $7c00
+ @Skip3_15bit:
+ or ecx, FinalColor
+ mov [eax], cx
+ jmp @Quit
+ @Not15Bit:
+ cmp Bits, 16
+ jne @Not16bit
+ shl eax, 1
+ add eax, Addr // Now: EAX:= Addr + (y * Pitch) + x * 2
+ mov ecx, [eax]
+ and ecx, $0000ffff
+ mov SrcColor, ecx
+ mov edx, Color
+ and ecx, $1f
+ and edx, $1f
+ add ecx, edx
+ cmp ecx, $1f
+ jbe @Skip1_16bit
+ mov ecx, $1f
+ @Skip1_16bit:
+ mov FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $07e0
+ and edx, $07e0
+ add ecx, edx
+ cmp ecx, $07e0
+ jbe @Skip2_16bit
+ mov ecx, $07e0
+ @Skip2_16bit:
+ or FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $f800
+ and edx, $f800
+ add ecx, edx
+ cmp ecx, $f800
+ jbe @Skip3_16bit
+ mov ecx, $f800
+ @Skip3_16bit:
+ or ecx, FinalColor
+ mov [eax], cx
+ jmp @Quit
+ @Not16Bit:
+ cmp Bits, 24
+ jne @Not24bit
+ mov ecx, 0
+ add ecx, eax
+ shl ecx, 1
+ add ecx, eax
+ mov eax, ecx
+ jmp @32bit
+ @Not24bit:
+ shl eax, 2
+ @32bit:
+ add eax, Addr // Now: EAX:= Addr + (y * Pitch) + x * 2
+ mov ecx, [eax]
+ mov FinalColor, ecx
+ and FinalColor, $ff000000
+ and ecx, $00ffffff
+ mov SrcColor, ecx
+ mov edx, Color
+ and ecx, $000000ff
+ and edx, $000000ff
+ add ecx, edx
+ cmp ecx, $000000ff
+ jbe @Skip1_32bit
+ mov ecx, $000000ff
+ @Skip1_32bit:
+ or FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $0000ff00
+ and edx, $0000ff00
+ add ecx, edx
+ cmp ecx, $0000ff00
+ jbe @Skip2_32bit
+ mov ecx, $0000ff00
+ @Skip2_32bit:
+ or FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $00ff0000
+ and edx, $00ff0000
+ add ecx, edx
+ cmp ecx, $00ff0000
+ jbe @Skip3_32bit
+ mov ecx, $00ff0000
+ @Skip3_32bit:
+ or ecx, FinalColor
+ mov [eax], ecx
+ @Quit:
+ end;
+end;
+
+procedure SDL_SubPixel( SrcSurface : PSDL_Surface; x : integer; y : integer; Color :
+ cardinal );
+var
+ SrcColor, FinalColor : cardinal;
+ Addr, Pitch, Bits : cardinal;
+begin
+ if Color = 0 then
+ exit;
+ Addr := cardinal( SrcSurface.Pixels );
+ Pitch := SrcSurface.Pitch;
+ Bits := SrcSurface.format.BitsPerPixel;
+ asm
+ mov eax, y
+ mul Pitch // EAX := y * Pitch
+ add Addr, eax // Addr:= Addr + (y * Pitch)
+ mov eax, x
+ cmp Bits, 8
+ jne @Not8bit
+ add eax, Addr // Now: EAX:= Addr + (y * Pitch) + x
+ mov cl, [eax]
+ movzx ecx, cl
+ mov SrcColor, ecx
+ mov edx, Color
+ and ecx, 3
+ and edx, 3
+ sub ecx, edx
+ jns @Skip1_8bit
+ mov ecx, 0
+ @Skip1_8bit:
+ mov FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $1c
+ and edx, $1c
+ sub ecx, edx
+ jns @Skip2_8bit
+ mov ecx, 0
+ @Skip2_8bit:
+ or FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $e0
+ and edx, $e0
+ sub ecx, edx
+ jns @Skip3_8bit
+ mov ecx, 0
+ @Skip3_8bit:
+ or ecx, FinalColor
+ mov [eax], cl
+ jmp @Quit
+ @Not8bit:
+ cmp Bits, 15
+ jne @Not15bit
+ shl eax, 1
+ add eax, Addr
+ mov ecx, [eax]
+ and ecx, $00007fff
+ mov SrcColor, ecx
+ mov edx, Color
+ and ecx, $1f
+ and edx, $1f
+ sub ecx, edx
+ jns @Skip1_15bit
+ mov ecx, 0
+ @Skip1_15bit:
+ mov FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $03e0
+ and edx, $03e0
+ sub ecx, edx
+ jns @Skip2_15bit
+ mov ecx, 0
+ @Skip2_15bit:
+ or FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $7c00
+ and edx, $7c00
+ sub ecx, edx
+ jns @Skip3_15bit
+ mov ecx, 0
+ @Skip3_15bit:
+ or ecx, FinalColor
+ mov [eax], cx
+ jmp @Quit
+ @Not15Bit:
+ cmp Bits, 16
+ jne @Not16bit
+ shl eax, 1
+ add eax, Addr
+ mov ecx, [eax]
+ and ecx, $0000ffff
+ mov SrcColor, ecx
+ mov edx, Color
+ and ecx, $1f
+ and edx, $1f
+ sub ecx, edx
+ jns @Skip1_16bit
+ mov ecx, 0
+ @Skip1_16bit:
+ mov FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $07e0
+ and edx, $07e0
+ sub ecx, edx
+ jns @Skip2_16bit
+ mov ecx, 0
+ @Skip2_16bit:
+ or FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $f800
+ and edx, $f800
+ sub ecx, edx
+ jns @Skip3_16bit
+ mov ecx, 0
+ @Skip3_16bit:
+ or ecx, FinalColor
+ mov [eax], cx
+ jmp @Quit
+ @Not16Bit:
+ cmp Bits, 24
+ jne @Not24bit
+ mov ecx, 0
+ add ecx, eax
+ shl ecx, 1
+ add ecx, eax
+ mov eax, ecx
+ jmp @32bit
+ @Not24bit:
+ shl eax, 2
+ @32bit:
+ add eax, Addr
+ mov ecx, [eax]
+ mov FinalColor, ecx
+ and FinalColor, $ff000000
+ and ecx, $00ffffff
+ mov SrcColor, ecx
+ mov edx, Color
+ and ecx, $000000ff
+ and edx, $000000ff
+ sub ecx, edx
+ jns @Skip1_32bit
+ mov ecx, 0
+ @Skip1_32bit:
+ or FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $0000ff00
+ and edx, $0000ff00
+ sub ecx, edx
+ jns @Skip2_32bit
+ mov ecx, 0
+ @Skip2_32bit:
+ or FinalColor, ecx
+ mov ecx, SrcColor
+ mov edx, Color
+ and ecx, $00ff0000
+ and edx, $00ff0000
+ sub ecx, edx
+ jns @Skip3_32bit
+ mov ecx, 0
+ @Skip3_32bit:
+ or ecx, FinalColor
+ mov [eax], ecx
+ @Quit:
+ end;
+end;
+
+// Draw a line between x1,y1 and x2,y2 to the given surface
+// NOTE: The surface must be locked before calling this!
+procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal );
+var
+ dx, dy, sdx, sdy, x, y, px, py : integer;
+begin
+ dx := x2 - x1;
+ dy := y2 - y1;
+ if dx < 0 then
+ sdx := -1
+ else
+ sdx := 1;
+ if dy < 0 then
+ sdy := -1
+ else
+ sdy := 1;
+ dx := sdx * dx + 1;
+ dy := sdy * dy + 1;
+ x := 0;
+ y := 0;
+ px := x1;
+ py := y1;
+ if dx >= dy then
+ begin
+ for x := 0 to dx - 1 do
+ begin
+ SDL_PutPixel( DstSurface, px, py, Color );
+ y := y + dy;
+ if y >= dx then
+ begin
+ y := y - dx;
+ py := py + sdy;
+ end;
+ px := px + sdx;
+ end;
+ end
+ else
+ begin
+ for y := 0 to dy - 1 do
+ begin
+ SDL_PutPixel( DstSurface, px, py, Color );
+ x := x + dx;
+ if x >= dy then
+ begin
+ x := x - dy;
+ px := px + sdx;
+ end;
+ py := py + sdy;
+ end;
+ end;
+end;
+
+// Draw a dashed line between x1,y1 and x2,y2 to the given surface
+// NOTE: The surface must be locked before calling this!
+procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal ; DashLength, DashSpace : byte ); overload;
+var
+ dx, dy, sdx, sdy, x, y, px, py, counter : integer; drawdash : boolean;
+begin
+ counter := 0;
+ drawdash := true; //begin line drawing with dash
+
+ //Avoid invalid user-passed dash parameters
+ if (DashLength < 1)
+ then DashLength := 1;
+ if (DashSpace < 1)
+ then DashSpace := 0;
+
+ dx := x2 - x1;
+ dy := y2 - y1;
+ if dx < 0 then
+ sdx := -1
+ else
+ sdx := 1;
+ if dy < 0 then
+ sdy := -1
+ else
+ sdy := 1;
+ dx := sdx * dx + 1;
+ dy := sdy * dy + 1;
+ x := 0;
+ y := 0;
+ px := x1;
+ py := y1;
+ if dx >= dy then
+ begin
+ for x := 0 to dx - 1 do
+ begin
+
+ //Alternate drawing dashes, or leaving spaces
+ if drawdash then
+ begin
+ SDL_PutPixel( DstSurface, px, py, Color );
+ inc(counter);
+ if (counter > DashLength-1) and (DashSpace > 0) then
+ begin
+ drawdash := false;
+ counter := 0;
+ end;
+ end
+ else //space
+ begin
+ inc(counter);
+ if counter > DashSpace-1 then
+ begin
+ drawdash := true;
+ counter := 0;
+ end;
+ end;
+
+ y := y + dy;
+ if y >= dx then
+ begin
+ y := y - dx;
+ py := py + sdy;
+ end;
+ px := px + sdx;
+ end;
+ end
+ else
+ begin
+ for y := 0 to dy - 1 do
+ begin
+
+ //Alternate drawing dashes, or leaving spaces
+ if drawdash then
+ begin
+ SDL_PutPixel( DstSurface, px, py, Color );
+ inc(counter);
+ if (counter > DashLength-1) and (DashSpace > 0) then
+ begin
+ drawdash := false;
+ counter := 0;
+ end;
+ end
+ else //space
+ begin
+ inc(counter);
+ if counter > DashSpace-1 then
+ begin
+ drawdash := true;
+ counter := 0;
+ end;
+ end;
+
+ x := x + dx;
+ if x >= dy then
+ begin
+ x := x - dy;
+ px := px + sdx;
+ end;
+ py := py + sdy;
+ end;
+ end;
+end;
+
+procedure SDL_AddLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal );
+var
+ dx, dy, sdx, sdy, x, y, px, py : integer;
+begin
+ dx := x2 - x1;
+ dy := y2 - y1;
+ if dx < 0 then
+ sdx := -1
+ else
+ sdx := 1;
+ if dy < 0 then
+ sdy := -1
+ else
+ sdy := 1;
+ dx := sdx * dx + 1;
+ dy := sdy * dy + 1;
+ x := 0;
+ y := 0;
+ px := x1;
+ py := y1;
+ if dx >= dy then
+ begin
+ for x := 0 to dx - 1 do
+ begin
+ SDL_AddPixel( DstSurface, px, py, Color );
+ y := y + dy;
+ if y >= dx then
+ begin
+ y := y - dx;
+ py := py + sdy;
+ end;
+ px := px + sdx;
+ end;
+ end
+ else
+ begin
+ for y := 0 to dy - 1 do
+ begin
+ SDL_AddPixel( DstSurface, px, py, Color );
+ x := x + dx;
+ if x >= dy then
+ begin
+ x := x - dy;
+ px := px + sdx;
+ end;
+ py := py + sdy;
+ end;
+ end;
+end;
+
+procedure SDL_SubLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal );
+var
+ dx, dy, sdx, sdy, x, y, px, py : integer;
+begin
+ dx := x2 - x1;
+ dy := y2 - y1;
+ if dx < 0 then
+ sdx := -1
+ else
+ sdx := 1;
+ if dy < 0 then
+ sdy := -1
+ else
+ sdy := 1;
+ dx := sdx * dx + 1;
+ dy := sdy * dy + 1;
+ x := 0;
+ y := 0;
+ px := x1;
+ py := y1;
+ if dx >= dy then
+ begin
+ for x := 0 to dx - 1 do
+ begin
+ SDL_SubPixel( DstSurface, px, py, Color );
+ y := y + dy;
+ if y >= dx then
+ begin
+ y := y - dx;
+ py := py + sdy;
+ end;
+ px := px + sdx;
+ end;
+ end
+ else
+ begin
+ for y := 0 to dy - 1 do
+ begin
+ SDL_SubPixel( DstSurface, px, py, Color );
+ x := x + dx;
+ if x >= dy then
+ begin
+ x := x - dy;
+ px := px + sdx;
+ end;
+ py := py + sdy;
+ end;
+ end;
+end;
+
+// This procedure works on 8, 15, 16, 24 and 32 bits color depth surfaces.
+// In 8 bit color depth mode the procedure works with the default packed
+// palette (RRRGGGBB). It handles all clipping.
+procedure SDL_AddSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DstSurface : PSDL_Surface; DestRect : PSDL_Rect );
+var
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr : cardinal;
+ // TransparentColor: cardinal;
+ _ebx, _esi, _edi, _esp : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DstSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DstSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DstSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ // TransparentColor := format.ColorKey;
+ end;
+ with DstSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DstSurface );
+ case bits of
+ 8 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov al, [esi] // AL := source color
+ cmp al, 0
+ je @SkipColor // if AL=0 or AL=transparent color then skip everything
+ mov esp, eax // ESP - source color
+ mov bl, [edi] // BL := destination color
+ mov dl, bl // DL := destination color
+ and ax, $03 // Adding BLUE
+ and bl, $03
+ add al, bl
+ cmp al, $03
+ jbe @Skip1
+ mov al, $03
+ @Skip1:
+ mov cl, al
+ mov eax, esp // Adding GREEN
+ mov bl, dl
+ and al, $1c
+ and bl, $1c
+ add al, bl
+ cmp al, $1c
+ jbe @Skip2
+ mov al, $1c
+ @Skip2:
+ or cl, al
+ mov eax, esp // Adding RED
+ mov bl, dl
+ and ax, $e0
+ and bx, $e0
+ add ax, bx
+ cmp ax, $e0
+ jbe @Skip3
+ mov al, $e0
+ @Skip3:
+ or cl, al
+ mov [edi], cl
+ @SkipColor:
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 15 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov ax, [esi] // AX := source color
+ cmp ax, 0
+ je @SkipColor // if AX=0 then skip everything
+ mov esp, eax // ESP - source color
+ mov bx, [edi] // BX := destination color
+ mov dx, bx // DX := destination color
+ and ax, $001F // Adding BLUE
+ and bx, $001F
+ add ax, bx
+ cmp ax, $001F
+ jbe @Skip1
+ mov ax, $001F
+ @Skip1:
+ mov cx, ax
+ mov eax, esp // Adding GREEN
+ mov bx, dx
+ and ax, $3E0
+ and bx, $3E0
+ add ax, bx
+ cmp ax, $3E0
+ jbe @Skip2
+ mov ax, $3E0
+ @Skip2:
+ or cx, ax
+ mov eax, esp // Adding RED
+ mov bx, dx
+ and ax, $7C00
+ and bx, $7C00
+ add ax, bx
+ cmp ax, $7C00
+ jbe @Skip3
+ mov ax, $7C00
+ @Skip3:
+ or cx, ax
+ mov [edi], cx
+ @SkipColor:
+ add esi, 2
+ add edi, 2
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 16 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov ax, [esi] // AX := source color
+ cmp ax, 0
+ je @SkipColor // if AX=0 then skip everything
+ mov esp, eax // ESP - source color
+ mov bx, [edi] // BX := destination color
+ mov dx, bx // DX := destination color
+ and ax, $1F // Adding BLUE
+ and bx, $1F
+ add ax, bx
+ cmp ax, $1F
+ jbe @Skip1
+ mov ax, $1F
+ @Skip1:
+ mov cx, ax
+ mov eax, esp // Adding GREEN
+ mov bx, dx
+ and ax, $7E0
+ and bx, $7E0
+ add ax, bx
+ cmp ax, $7E0
+ jbe @Skip2
+ mov ax, $7E0
+ @Skip2:
+ or cx, ax
+ mov eax, esp // Adding RED
+ mov bx, dx
+ and eax, $F800
+ and ebx, $F800
+ add eax, ebx
+ cmp eax, $F800
+ jbe @Skip3
+ mov ax, $F800
+ @Skip3:
+ or cx, ax
+ mov [edi], cx
+ @SkipColor:
+ add esi, 2
+ add edi, 2
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 24 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ add WorkX, ax // WorkX := Src.w * 2
+ add WorkX, ax // WorkX := Src.w * 3
+ @Loopx:
+ mov bl, [edi] // BX := destination color
+ mov al, [esi] // AX := source color
+ cmp al, 0
+ je @Skip // if AL=0 then skip COMPONENT
+ mov ah, 0 // AX := COLOR COMPONENT
+ mov bh, 0
+ add bx, ax
+ cmp bx, $00ff
+ jb @Skip
+ mov bl, $ff
+ @Skip:
+ mov [edi], bl
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 32 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ shl ax, 2
+ mov WorkX, ax // WorkX := Src.w * 4
+ @Loopx:
+ mov bl, [edi] // BX := destination color
+ mov al, [esi] // AX := source color
+ cmp al, 0
+ je @Skip // if AL=0 then skip COMPONENT
+ mov ah, 0 // AX := COLOR COMPONENT
+ mov bh, 0
+ add bx, ax
+ cmp bx, $00ff
+ jb @Skip
+ mov bl, $ff
+ @Skip:
+ mov [edi], bl
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DstSurface );
+end;
+
+procedure SDL_SubSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DstSurface : PSDL_Surface; DestRect : PSDL_Rect );
+var
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr : cardinal;
+ _ebx, _esi, _edi, _esp : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DstSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DstSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DstSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ end;
+ with DstSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := DstSurface.Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DstSurface );
+ case bits of
+ 8 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov al, [esi] // AL := source color
+ cmp al, 0
+ je @SkipColor // if AL=0 then skip everything
+ mov esp, eax // ESP - source color
+ mov bl, [edi] // BL := destination color
+ mov dl, bl // DL := destination color
+ and al, $03 // Subtract BLUE
+ and bl, $03
+ sub bl, al
+ jns @Skip1
+ mov bl, 0
+ @Skip1:
+ mov cl, bl
+ mov eax, esp // Subtract GREEN
+ mov bl, dl
+ and al, $1c
+ and bl, $1c
+ sub bl, al
+ jns @Skip2
+ mov bl, 0
+ @Skip2:
+ or cl, bl
+ mov eax, esp // Subtract RED
+ mov bl, dl
+ and ax, $e0
+ and bx, $e0
+ sub bx, ax
+ jns @Skip3
+ mov bl, 0
+ @Skip3:
+ or cl, bl
+ mov [edi], cl
+ @SkipColor:
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 15 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov ax, [esi] // AX := source color
+ cmp ax, 0
+ je @SkipColor // if AX=0 then skip everything
+ mov esp, eax // ESP - source color
+ mov bx, [edi] // BX := destination color
+ mov dx, bx // DX := destination color
+ and ax, $001F // Subtract BLUE
+ and bx, $001F
+ sub bx, ax
+ jns @Skip1
+ mov bx, 0
+ @Skip1:
+ mov cx, bx
+ mov eax, esp // Subtract GREEN
+ mov bx, dx
+ and ax, $3E0
+ and bx, $3E0
+ sub bx, ax
+ jns @Skip2
+ mov bx, 0
+ @Skip2:
+ or cx, bx
+ mov eax, esp // Subtract RED
+ mov bx, dx
+ and ax, $7C00
+ and bx, $7C00
+ sub bx, ax
+ jns @Skip3
+ mov bx, 0
+ @Skip3:
+ or cx, bx
+ mov [edi], cx
+ @SkipColor:
+ add esi, 2
+ add edi, 2
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 16 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov ax, [esi] // AX := source color
+ cmp ax, 0
+ je @SkipColor // if AX=0 then skip everything
+ mov esp, eax // ESP - source color
+ mov bx, [edi] // BX := destination color
+ mov dx, bx // DX := destination color
+ and ax, $1F // Subtracting BLUE
+ and bx, $1F
+ sub bx, ax
+ jns @Skip1
+ mov bx, 0
+ @Skip1:
+ mov cx, bx
+ mov eax, esp // Adding GREEN
+ mov bx, dx
+ and ax, $7E0
+ and bx, $7E0
+ sub bx, ax
+ jns @Skip2
+ mov bx, 0
+ @Skip2:
+ or cx, bx
+ mov eax, esp // Adding RED
+ mov bx, dx
+ and eax, $F800
+ and ebx, $F800
+ sub ebx, eax
+ jns @Skip3
+ mov bx, 0
+ @Skip3:
+ or cx, bx
+ mov [edi], cx
+ @SkipColor:
+ add esi, 2
+ add edi, 2
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 24 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ add WorkX, ax // WorkX := Src.w * 2
+ add WorkX, ax // WorkX := Src.w * 3
+ @Loopx:
+ mov bl, [edi] // BX := destination color
+ mov al, [esi] // AX := source color
+ cmp al, 0
+ je @Skip // if AL=0 then skip COMPONENT
+ mov ah, 0 // AX := COLOR COMPONENT
+ mov bh, 0
+ sub bx, ax
+ jns @Skip
+ mov bl, 0
+ @Skip:
+ mov [edi], bl
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 32 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ shl ax, 2
+ mov WorkX, ax // WorkX := Src.w * 4
+ @Loopx:
+ mov bl, [edi] // BX := destination color
+ mov al, [esi] // AX := source color
+ cmp al, 0
+ je @Skip // if AL=0 then skip COMPONENT
+ mov ah, 0 // AX := COLOR COMPONENT
+ mov bh, 0
+ sub bx, ax
+ jns @Skip
+ mov bl, 0
+ @Skip:
+ mov [edi], bl
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DstSurface );
+end;
+
+procedure SDL_MonoSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DstSurface : PSDL_Surface; DestRect : PSDL_Rect; Color : cardinal );
+var
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr : cardinal;
+ _ebx, _esi, _edi, _esp : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ SrcTransparentColor : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DstSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DstSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DstSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ SrcTransparentColor := format.colorkey;
+ end;
+ with DstSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := DstSurface.Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DstSurface );
+ case bits of
+ 8 :
+ asm
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ mov ecx, Color
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov al, [esi] // AL := source color
+ movzx eax, al
+ cmp eax, SrcTransparentColor
+ je @SkipColor // if AL=Transparent color then skip everything
+ mov [edi], cl
+ @SkipColor:
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ end;
+ 15, 16 :
+ asm
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ mov ecx, Color
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov ax, [esi] // AX := source color
+ movzx eax, ax
+ cmp eax, SrcTransparentColor
+ je @SkipColor // if AX=Transparent color then skip everything
+ mov [edi], cx
+ @SkipColor:
+ inc esi
+ inc esi
+ inc edi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ end;
+ 24 :
+ asm
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov _ebx, ebx
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ mov ecx, Color
+ and ecx, $00ffffff
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov eax, [esi] // EAX := source color
+ and eax, $00ffffff
+ cmp eax, SrcTransparentColor
+ je @SkipColor // if EAX=Transparent color then skip everything
+ mov ebx, [edi]
+ and ebx, $ff000000
+ or ebx, ecx
+ mov [edi], ecx
+ @SkipColor:
+ add esi, 3
+ add edi, 3
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp, _esp
+ mov edi, _edi
+ mov esi, _esi
+ mov ebx, _ebx
+ end;
+ 32 :
+ asm
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ mov ecx, Color
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov eax, [esi] // EAX := source color
+ cmp eax, SrcTransparentColor
+ je @SkipColor // if EAX=Transparent color then skip everything
+ mov [edi], ecx
+ @SkipColor:
+ add esi, 4
+ add edi, 4
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp, _esp
+ mov edi, _edi
+ mov esi, _esi
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DstSurface );
+end;
+// TextureRect.w and TextureRect.h are not used.
+// The TextureSurface's size MUST larger than the drawing rectangle!!!
+
+procedure SDL_TexturedSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DstSurface : PSDL_Surface; DestRect : PSDL_Rect; Texture : PSDL_Surface;
+ TextureRect : PSDL_Rect );
+var
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr, TextAddr : cardinal;
+ _ebx, _esi, _edi, _esp : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod, TextMod : cardinal;
+ SrcTransparentColor : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DstSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DstSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DstSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ SrcTransparentColor := format.colorkey;
+ end;
+ with DstSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := DstSurface.Format.BitsPerPixel;
+ end;
+ with Texture^ do
+ begin
+ TextAddr := cardinal( Pixels ) + UInt32( TextureRect.y ) * Pitch +
+ UInt32( TextureRect.x ) * Format.BytesPerPixel;
+ TextMod := Pitch - Src.w * Format.BytesPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DstSurface );
+ SDL_LockSurface( Texture );
+ case bits of
+ 8 :
+ asm
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov _ebx, ebx
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ebx, TextAddr
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov al, [esi] // AL := source color
+ movzx eax, al
+ cmp eax, SrcTransparentColor
+ je @SkipColor // if AL=Transparent color then skip everything
+ mov al, [ebx]
+ mov [edi], al
+ @SkipColor:
+ inc esi
+ inc edi
+ inc ebx
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ add ebx, TextMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx, _ebx
+ end;
+ 15, 16 :
+ asm
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ecx, TextAddr
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov ax, [esi] // AL := source color
+ movzx eax, ax
+ cmp eax, SrcTransparentColor
+ je @SkipColor // if AL=Transparent color then skip everything
+ mov ax, [ecx]
+ mov [edi], ax
+ @SkipColor:
+ inc esi
+ inc esi
+ inc edi
+ inc edi
+ inc ecx
+ inc ecx
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ add ecx, TextMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ end;
+ 24 :
+ asm
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov _ebx, ebx
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ebx, TextAddr
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov eax, [esi] // AL := source color
+ and eax, $00ffffff
+ cmp eax, SrcTransparentColor
+ je @SkipColor // if AL=Transparent color then skip everything
+ mov eax, [ebx]
+ and eax, $00ffffff
+ mov ecx, [edi]
+ and ecx, $ff000000
+ or ecx, eax
+ mov [edi], eax
+ @SkipColor:
+ add esi, 3
+ add edi, 3
+ add ebx, 3
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ add ebx, TextMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx, _ebx
+ end;
+ 32 :
+ asm
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ecx, TextAddr
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov eax, [esi] // AL := source color
+ cmp eax, SrcTransparentColor
+ je @SkipColor // if AL=Transparent color then skip everything
+ mov eax, [ecx]
+ mov [edi], eax
+ @SkipColor:
+ add esi, 4
+ add edi, 4
+ add ecx, 4
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ add ecx, TextMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DstSurface );
+ SDL_UnlockSurface( Texture );
+end;
+
+procedure SDL_ZoomSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; DstRect : PSDL_Rect );
+var
+ xc, yc : cardinal;
+ rx, wx, ry, wy, ry16 : cardinal;
+ color : cardinal;
+ modx, mody : cardinal;
+begin
+ // Warning! No checks for surface pointers!!!
+ if srcrect = nil then
+ srcrect := @SrcSurface.clip_rect;
+ if dstrect = nil then
+ dstrect := @DstSurface.clip_rect;
+ if SDL_MustLock( SrcSurface ) then
+ SDL_LockSurface( SrcSurface );
+ if SDL_MustLock( DstSurface ) then
+ SDL_LockSurface( DstSurface );
+ modx := trunc( ( srcrect.w / dstrect.w ) * 65536 );
+ mody := trunc( ( srcrect.h / dstrect.h ) * 65536 );
+ //rx := srcrect.x * 65536;
+ ry := srcrect.y * 65536;
+ wy := dstrect.y;
+ for yc := 0 to dstrect.h - 1 do
+ begin
+ rx := srcrect.x * 65536;
+ wx := dstrect.x;
+ ry16 := ry shr 16;
+ for xc := 0 to dstrect.w - 1 do
+ begin
+ color := SDL_GetPixel( SrcSurface, rx shr 16, ry16 );
+ SDL_PutPixel( DstSurface, wx, wy, color );
+ rx := rx + modx;
+ inc( wx );
+ end;
+ ry := ry + mody;
+ inc( wy );
+ end;
+ if SDL_MustLock( SrcSurface ) then
+ SDL_UnlockSurface( SrcSurface );
+ if SDL_MustLock( DstSurface ) then
+ SDL_UnlockSurface( DstSurface );
+end;
+// Re-map a rectangular area into an area defined by four vertices
+// Converted from C to Pascal by KiCHY
+
+procedure SDL_WarpSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; UL, UR, LR, LL : PPoint );
+const
+ SHIFTS = 15; // Extend ints to limit round-off error (try 2 - 20)
+ THRESH = 1 shl SHIFTS; // Threshold for pixel size value
+ procedure CopySourceToDest( UL, UR, LR, LL : TPoint; x1, y1, x2, y2 : cardinal );
+ var
+ tm, lm, rm, bm, m : TPoint;
+ mx, my : cardinal;
+ cr : cardinal;
+ begin
+ // Does the destination area specify a single pixel?
+ if ( ( abs( ul.x - ur.x ) < THRESH ) and
+ ( abs( ul.x - lr.x ) < THRESH ) and
+ ( abs( ul.x - ll.x ) < THRESH ) and
+ ( abs( ul.y - ur.y ) < THRESH ) and
+ ( abs( ul.y - lr.y ) < THRESH ) and
+ ( abs( ul.y - ll.y ) < THRESH ) ) then
+ begin // Yes
+ cr := SDL_GetPixel( SrcSurface, ( x1 shr SHIFTS ), ( y1 shr SHIFTS ) );
+ SDL_PutPixel( DstSurface, ( ul.x shr SHIFTS ), ( ul.y shr SHIFTS ), cr );
+ end
+ else
+ begin // No
+ // Quarter the source and the destination, and then recurse
+ tm.x := ( ul.x + ur.x ) shr 1;
+ tm.y := ( ul.y + ur.y ) shr 1;
+ bm.x := ( ll.x + lr.x ) shr 1;
+ bm.y := ( ll.y + lr.y ) shr 1;
+ lm.x := ( ul.x + ll.x ) shr 1;
+ lm.y := ( ul.y + ll.y ) shr 1;
+ rm.x := ( ur.x + lr.x ) shr 1;
+ rm.y := ( ur.y + lr.y ) shr 1;
+ m.x := ( tm.x + bm.x ) shr 1;
+ m.y := ( tm.y + bm.y ) shr 1;
+ mx := ( x1 + x2 ) shr 1;
+ my := ( y1 + y2 ) shr 1;
+ CopySourceToDest( ul, tm, m, lm, x1, y1, mx, my );
+ CopySourceToDest( tm, ur, rm, m, mx, y1, x2, my );
+ CopySourceToDest( m, rm, lr, bm, mx, my, x2, y2 );
+ CopySourceToDest( lm, m, bm, ll, x1, my, mx, y2 );
+ end;
+ end;
+var
+ _UL, _UR, _LR, _LL : TPoint;
+ Rect_x, Rect_y, Rect_w, Rect_h : integer;
+begin
+ if SDL_MustLock( SrcSurface ) then
+ SDL_LockSurface( SrcSurface );
+ if SDL_MustLock( DstSurface ) then
+ SDL_LockSurface( DstSurface );
+ if SrcRect = nil then
+ begin
+ Rect_x := 0;
+ Rect_y := 0;
+ Rect_w := ( SrcSurface.w - 1 ) shl SHIFTS;
+ Rect_h := ( SrcSurface.h - 1 ) shl SHIFTS;
+ end
+ else
+ begin
+ Rect_x := SrcRect.x;
+ Rect_y := SrcRect.y;
+ Rect_w := ( SrcRect.w - 1 ) shl SHIFTS;
+ Rect_h := ( SrcRect.h - 1 ) shl SHIFTS;
+ end;
+ // Shift all values to help reduce round-off error.
+ _ul.x := ul.x shl SHIFTS;
+ _ul.y := ul.y shl SHIFTS;
+ _ur.x := ur.x shl SHIFTS;
+ _ur.y := ur.y shl SHIFTS;
+ _lr.x := lr.x shl SHIFTS;
+ _lr.y := lr.y shl SHIFTS;
+ _ll.x := ll.x shl SHIFTS;
+ _ll.y := ll.y shl SHIFTS;
+ CopySourceToDest( _ul, _ur, _lr, _ll, Rect_x, Rect_y, Rect_w, Rect_h );
+ if SDL_MustLock( SrcSurface ) then
+ SDL_UnlockSurface( SrcSurface );
+ if SDL_MustLock( DstSurface ) then
+ SDL_UnlockSurface( DstSurface );
+end;
+
+// flips a rectangle vertically on given surface
+procedure SDL_FlipRectV( DstSurface : PSDL_Surface; Rect : PSDL_Rect );
+var
+ TmpRect : TSDL_Rect;
+ Locked : boolean;
+ y, FlipLength, RowLength : integer;
+ Row1, Row2 : Pointer;
+ OneRow : TByteArray; // Optimize it if you wish
+begin
+ if DstSurface <> nil then
+ begin
+ if Rect = nil then
+ begin // if Rect=nil then we flip the whole surface
+ TmpRect := SDLRect( 0, 0, DstSurface.w, DstSurface.h );
+ Rect := @TmpRect;
+ end;
+ FlipLength := Rect^.h shr 1 - 1;
+ RowLength := Rect^.w * DstSurface^.format.BytesPerPixel;
+ if SDL_MustLock( DstSurface ) then
+ begin
+ Locked := true;
+ SDL_LockSurface( DstSurface );
+ end
+ else
+ Locked := false;
+ Row1 := pointer( cardinal( DstSurface^.Pixels ) + UInt32( Rect^.y ) *
+ DstSurface^.Pitch );
+ Row2 := pointer( cardinal( DstSurface^.Pixels ) + ( UInt32( Rect^.y ) + Rect^.h - 1 )
+ * DstSurface^.Pitch );
+ for y := 0 to FlipLength do
+ begin
+ Move( Row1^, OneRow, RowLength );
+ Move( Row2^, Row1^, RowLength );
+ Move( OneRow, Row2^, RowLength );
+ inc( cardinal( Row1 ), DstSurface^.Pitch );
+ dec( cardinal( Row2 ), DstSurface^.Pitch );
+ end;
+ if Locked then
+ SDL_UnlockSurface( DstSurface );
+ end;
+end;
+
+// flips a rectangle horizontally on given surface
+procedure SDL_FlipRectH( DstSurface : PSDL_Surface; Rect : PSDL_Rect );
+type
+ T24bit = packed array[ 0..2 ] of byte;
+ T24bitArray = packed array[ 0..8191 ] of T24bit;
+ P24bitArray = ^T24bitArray;
+ TLongWordArray = array[ 0..8191 ] of LongWord;
+ PLongWordArray = ^TLongWordArray;
+var
+ TmpRect : TSDL_Rect;
+ Row8bit : PByteArray;
+ Row16bit : PWordArray;
+ Row24bit : P24bitArray;
+ Row32bit : PLongWordArray;
+ y, x, RightSide, FlipLength : integer;
+ Pixel : cardinal;
+ Pixel24 : T24bit;
+ Locked : boolean;
+begin
+ if DstSurface <> nil then
+ begin
+ if Rect = nil then
+ begin
+ TmpRect := SDLRect( 0, 0, DstSurface.w, DstSurface.h );
+ Rect := @TmpRect;
+ end;
+ FlipLength := Rect^.w shr 1 - 1;
+ if SDL_MustLock( DstSurface ) then
+ begin
+ Locked := true;
+ SDL_LockSurface( DstSurface );
+ end
+ else
+ Locked := false;
+ case DstSurface^.format.BytesPerPixel of
+ 1 :
+ begin
+ Row8Bit := pointer( cardinal( DstSurface^.pixels ) + UInt32( Rect^.y ) *
+ DstSurface^.pitch );
+ for y := 1 to Rect^.h do
+ begin
+ RightSide := Rect^.w - 1;
+ for x := 0 to FlipLength do
+ begin
+ Pixel := Row8Bit^[ x ];
+ Row8Bit^[ x ] := Row8Bit^[ RightSide ];
+ Row8Bit^[ RightSide ] := Pixel;
+ dec( RightSide );
+ end;
+ inc( cardinal( Row8Bit ), DstSurface^.pitch );
+ end;
+ end;
+ 2 :
+ begin
+ Row16Bit := pointer( cardinal( DstSurface^.pixels ) + UInt32( Rect^.y ) *
+ DstSurface^.pitch );
+ for y := 1 to Rect^.h do
+ begin
+ RightSide := Rect^.w - 1;
+ for x := 0 to FlipLength do
+ begin
+ Pixel := Row16Bit^[ x ];
+ Row16Bit^[ x ] := Row16Bit^[ RightSide ];
+ Row16Bit^[ RightSide ] := Pixel;
+ dec( RightSide );
+ end;
+ inc( cardinal( Row16Bit ), DstSurface^.pitch );
+ end;
+ end;
+ 3 :
+ begin
+ Row24Bit := pointer( cardinal( DstSurface^.pixels ) + UInt32( Rect^.y ) *
+ DstSurface^.pitch );
+ for y := 1 to Rect^.h do
+ begin
+ RightSide := Rect^.w - 1;
+ for x := 0 to FlipLength do
+ begin
+ Pixel24 := Row24Bit^[ x ];
+ Row24Bit^[ x ] := Row24Bit^[ RightSide ];
+ Row24Bit^[ RightSide ] := Pixel24;
+ dec( RightSide );
+ end;
+ inc( cardinal( Row24Bit ), DstSurface^.pitch );
+ end;
+ end;
+ 4 :
+ begin
+ Row32Bit := pointer( cardinal( DstSurface^.pixels ) + UInt32( Rect^.y ) *
+ DstSurface^.pitch );
+ for y := 1 to Rect^.h do
+ begin
+ RightSide := Rect^.w - 1;
+ for x := 0 to FlipLength do
+ begin
+ Pixel := Row32Bit^[ x ];
+ Row32Bit^[ x ] := Row32Bit^[ RightSide ];
+ Row32Bit^[ RightSide ] := Pixel;
+ dec( RightSide );
+ end;
+ inc( cardinal( Row32Bit ), DstSurface^.pitch );
+ end;
+ end;
+ end;
+ if Locked then
+ SDL_UnlockSurface( DstSurface );
+ end;
+end;
+
+// Use with caution! The procedure allocates memory for TSDL_Rect and return with its pointer.
+// But you MUST free it after you don't need it anymore!!!
+function PSDLRect( aLeft, aTop, aWidth, aHeight : integer ) : PSDL_Rect;
+var
+ Rect : PSDL_Rect;
+begin
+ New( Rect );
+ with Rect^ do
+ begin
+ x := aLeft;
+ y := aTop;
+ w := aWidth;
+ h := aHeight;
+ end;
+ Result := Rect;
+end;
+
+function SDLRect( aLeft, aTop, aWidth, aHeight : integer ) : TSDL_Rect;
+begin
+ with result do
+ begin
+ x := aLeft;
+ y := aTop;
+ w := aWidth;
+ h := aHeight;
+ end;
+end;
+
+function SDLRect( aRect : TRect ) : TSDL_Rect;
+begin
+ with aRect do
+ result := SDLRect( Left, Top, Right - Left, Bottom - Top );
+end;
+
+procedure SDL_Stretch8( Surface, Dst_Surface : PSDL_Surface; x1, x2, y1, y2, yr, yw,
+ depth : integer );
+var
+ dx, dy, e, d, dx2 : integer;
+ src_pitch, dst_pitch : uint16;
+ src_pixels, dst_pixels : PUint8;
+begin
+ if ( yw >= dst_surface^.h ) then
+ exit;
+ dx := ( x2 - x1 );
+ dy := ( y2 - y1 );
+ dy := dy shl 1;
+ e := dy - dx;
+ dx2 := dx shl 1;
+ src_pitch := Surface^.pitch;
+ dst_pitch := dst_surface^.pitch;
+ src_pixels := PUint8( integer( Surface^.pixels ) + yr * src_pitch + y1 * depth );
+ dst_pixels := PUint8( integer( dst_surface^.pixels ) + yw * dst_pitch + x1 *
+ depth );
+ for d := 0 to dx - 1 do
+ begin
+ move( src_pixels^, dst_pixels^, depth );
+ while ( e >= 0 ) do
+ begin
+ inc( src_pixels, depth );
+ e := e - dx2;
+ end;
+ inc( dst_pixels, depth );
+ e := e + dy;
+ end;
+end;
+
+function sign( x : integer ) : integer;
+begin
+ if x > 0 then
+ result := 1
+ else
+ result := -1;
+end;
+
+// Stretches a part of a surface
+function SDL_ScaleSurfaceRect( SrcSurface : PSDL_Surface; SrcX1, SrcY1, SrcW, SrcH,
+ Width, Height : integer ) : PSDL_Surface;
+var
+ dst_surface : PSDL_Surface;
+ dx, dy, e, d, dx2, srcx2, srcy2 : integer;
+ destx1, desty1 : integer;
+begin
+ srcx2 := srcx1 + SrcW;
+ srcy2 := srcy1 + SrcH;
+ result := nil;
+ destx1 := 0;
+ desty1 := 0;
+ dx := abs( integer( Height - desty1 ) );
+ dy := abs( integer( SrcY2 - SrcY1 ) );
+ e := ( dy shl 1 ) - dx;
+ dx2 := dx shl 1;
+ dy := dy shl 1;
+ dst_surface := SDL_CreateRGBSurface( SDL_HWPALETTE, width - destx1, Height -
+ desty1,
+ SrcSurface^.Format^.BitsPerPixel,
+ SrcSurface^.Format^.RMask,
+ SrcSurface^.Format^.GMask,
+ SrcSurface^.Format^.BMask,
+ SrcSurface^.Format^.AMask );
+ if ( dst_surface^.format^.BytesPerPixel = 1 ) then
+ SDL_SetColors( dst_surface, @SrcSurface^.format^.palette^.colors^[ 0 ], 0, 256 );
+ SDL_SetColorKey( dst_surface, sdl_srccolorkey, SrcSurface^.format^.colorkey );
+ if ( SDL_MustLock( dst_surface ) ) then
+ if ( SDL_LockSurface( dst_surface ) < 0 ) then
+ exit;
+ for d := 0 to dx - 1 do
+ begin
+ SDL_Stretch8( SrcSurface, dst_surface, destx1, Width, SrcX1, SrcX2, SrcY1, desty1,
+ SrcSurface^.format^.BytesPerPixel );
+ while e >= 0 do
+ begin
+ inc( SrcY1 );
+ e := e - dx2;
+ end;
+ inc( desty1 );
+ e := e + dy;
+ end;
+ if SDL_MUSTLOCK( dst_surface ) then
+ SDL_UnlockSurface( dst_surface );
+ result := dst_surface;
+end;
+
+procedure SDL_ScrollY( DstSurface : PSDL_Surface; DifY : integer );
+var
+ r1, r2 : TSDL_Rect;
+ //buffer: PSDL_Surface;
+ YPos : Integer;
+begin
+ if ( DstSurface <> nil ) and ( DifY <> 0 ) then
+ begin
+ //if DifY > 0 then // going up
+ //begin
+ ypos := 0;
+ r1.x := 0;
+ r2.x := 0;
+ r1.w := DstSurface.w;
+ r2.w := DstSurface.w;
+ r1.h := DifY;
+ r2.h := DifY;
+ while ypos < DstSurface.h do
+ begin
+ r1.y := ypos;
+ r2.y := ypos + DifY;
+ SDL_BlitSurface( DstSurface, @r2, DstSurface, @r1 );
+ ypos := ypos + DifY;
+ end;
+ //end
+ //else
+ //begin // Going Down
+ //end;
+ end;
+end;
+
+procedure SDL_ScrollX( DstSurface : PSDL_Surface; DifX : integer );
+var
+ r1, r2 : TSDL_Rect;
+ buffer : PSDL_Surface;
+begin
+ if ( DstSurface <> nil ) and ( DifX <> 0 ) then
+ begin
+ buffer := SDL_CreateRGBSurface( SDL_HWSURFACE, ( DstSurface^.w - DifX ) * 2,
+ DstSurface^.h * 2,
+ DstSurface^.Format^.BitsPerPixel,
+ DstSurface^.Format^.RMask,
+ DstSurface^.Format^.GMask,
+ DstSurface^.Format^.BMask,
+ DstSurface^.Format^.AMask );
+ if buffer <> nil then
+ begin
+ if ( buffer^.format^.BytesPerPixel = 1 ) then
+ SDL_SetColors( buffer, @DstSurface^.format^.palette^.colors^[ 0 ], 0, 256 );
+ r1 := SDLRect( DifX, 0, buffer^.w, buffer^.h );
+ r2 := SDLRect( 0, 0, buffer^.w, buffer^.h );
+ SDL_BlitSurface( DstSurface, @r1, buffer, @r2 );
+ SDL_BlitSurface( buffer, @r2, DstSurface, @r2 );
+ SDL_FreeSurface( buffer );
+ end;
+ end;
+end;
+
+procedure SDL_RotateRad( DstSurface, SrcSurface : PSDL_Surface; SrcRect :
+ PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Single );
+var
+ aSin, aCos : Single;
+ MX, MY, DX, DY, NX, NY, SX, SY, OX, OY, Width, Height, TX, TY, RX, RY, ROX, ROY : Integer;
+ Colour, TempTransparentColour : UInt32;
+ MAXX, MAXY : Integer;
+begin
+ // Rotate the surface to the target surface.
+ TempTransparentColour := SrcSurface.format.colorkey;
+ if srcRect.w > srcRect.h then
+ begin
+ Width := srcRect.w;
+ Height := srcRect.w;
+ end
+ else
+ begin
+ Width := srcRect.h;
+ Height := srcRect.h;
+ end;
+
+ maxx := DstSurface.w;
+ maxy := DstSurface.h;
+ aCos := cos( Angle );
+ aSin := sin( Angle );
+
+ Width := round( abs( srcrect.h * acos ) + abs( srcrect.w * asin ) );
+ Height := round( abs( srcrect.h * asin ) + abs( srcrect.w * acos ) );
+
+ OX := Width div 2;
+ OY := Height div 2; ;
+ MX := ( srcRect.x + ( srcRect.x + srcRect.w ) ) div 2;
+ MY := ( srcRect.y + ( srcRect.y + srcRect.h ) ) div 2;
+ ROX := ( -( srcRect.w div 2 ) ) + Offsetx;
+ ROY := ( -( srcRect.h div 2 ) ) + OffsetY;
+ Tx := ox + round( ROX * aSin - ROY * aCos );
+ Ty := oy + round( ROY * aSin + ROX * aCos );
+ SX := 0;
+ for DX := DestX - TX to DestX - TX + ( width ) do
+ begin
+ Inc( SX );
+ SY := 0;
+ for DY := DestY - TY to DestY - TY + ( Height ) do
+ begin
+ RX := SX - OX;
+ RY := SY - OY;
+ NX := round( mx + RX * aSin + RY * aCos ); //
+ NY := round( my + RY * aSin - RX * aCos ); //
+ // Used for testing only
+ //SDL_PutPixel(DstSurface.SDLSurfacePointer,DX,DY,0);
+ if ( ( DX > 0 ) and ( DX < MAXX ) ) and ( ( DY > 0 ) and ( DY < MAXY ) ) then
+ begin
+ if ( NX >= srcRect.x ) and ( NX <= srcRect.x + srcRect.w ) then
+ begin
+ if ( NY >= srcRect.y ) and ( NY <= srcRect.y + srcRect.h ) then
+ begin
+ Colour := SDL_GetPixel( SrcSurface, NX, NY );
+ if Colour <> TempTransparentColour then
+ begin
+ SDL_PutPixel( DstSurface, DX, DY, Colour );
+ end;
+ end;
+ end;
+ end;
+ inc( SY );
+ end;
+ end;
+end;
+
+procedure SDL_RotateDeg( DstSurface, SrcSurface : PSDL_Surface; SrcRect :
+ PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Integer );
+begin
+ SDL_RotateRad( DstSurface, SrcSurface, SrcRect, DestX, DestY, OffsetX, OffsetY, DegToRad( Angle ) );
+end;
+
+function ValidateSurfaceRect( DstSurface : PSDL_Surface; dstrect : PSDL_Rect ) : TSDL_Rect;
+var
+ RealRect : TSDL_Rect;
+ OutOfRange : Boolean;
+begin
+ OutOfRange := false;
+ if dstrect = nil then
+ begin
+ RealRect.x := 0;
+ RealRect.y := 0;
+ RealRect.w := DstSurface.w;
+ RealRect.h := DstSurface.h;
+ end
+ else
+ begin
+ if dstrect.x < DstSurface.w then
+ begin
+ RealRect.x := dstrect.x;
+ end
+ else if dstrect.x < 0 then
+ begin
+ realrect.x := 0;
+ end
+ else
+ begin
+ OutOfRange := True;
+ end;
+ if dstrect.y < DstSurface.h then
+ begin
+ RealRect.y := dstrect.y;
+ end
+ else if dstrect.y < 0 then
+ begin
+ realrect.y := 0;
+ end
+ else
+ begin
+ OutOfRange := True;
+ end;
+ if OutOfRange = False then
+ begin
+ if realrect.x + dstrect.w <= DstSurface.w then
+ begin
+ RealRect.w := dstrect.w;
+ end
+ else
+ begin
+ RealRect.w := dstrect.w - realrect.x;
+ end;
+ if realrect.y + dstrect.h <= DstSurface.h then
+ begin
+ RealRect.h := dstrect.h;
+ end
+ else
+ begin
+ RealRect.h := dstrect.h - realrect.y;
+ end;
+ end;
+ end;
+ if OutOfRange = False then
+ begin
+ result := realrect;
+ end
+ else
+ begin
+ realrect.w := 0;
+ realrect.h := 0;
+ realrect.x := 0;
+ realrect.y := 0;
+ result := realrect;
+ end;
+end;
+
+procedure SDL_FillRectAdd( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 );
+var
+ RealRect : TSDL_Rect;
+ Addr : pointer;
+ ModX, BPP : cardinal;
+ x, y, R, G, B, SrcColor : cardinal;
+begin
+ RealRect := ValidateSurfaceRect( DstSurface, DstRect );
+ if ( RealRect.w > 0 ) and ( RealRect.h > 0 ) then
+ begin
+ SDL_LockSurface( DstSurface );
+ BPP := DstSurface.format.BytesPerPixel;
+ with DstSurface^ do
+ begin
+ Addr := pointer( UInt32( pixels ) + UInt32( RealRect.y ) * pitch + UInt32( RealRect.x ) * BPP );
+ ModX := Pitch - UInt32( RealRect.w ) * BPP;
+ end;
+ case DstSurface.format.BitsPerPixel of
+ 8 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $E0 + Color and $E0;
+ G := SrcColor and $1C + Color and $1C;
+ B := SrcColor and $03 + Color and $03;
+ if R > $E0 then
+ R := $E0;
+ if G > $1C then
+ G := $1C;
+ if B > $03 then
+ B := $03;
+ PUInt8( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 15 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $7C00 + Color and $7C00;
+ G := SrcColor and $03E0 + Color and $03E0;
+ B := SrcColor and $001F + Color and $001F;
+ if R > $7C00 then
+ R := $7C00;
+ if G > $03E0 then
+ G := $03E0;
+ if B > $001F then
+ B := $001F;
+ PUInt16( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 16 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $F800 + Color and $F800;
+ G := SrcColor and $07C0 + Color and $07C0;
+ B := SrcColor and $001F + Color and $001F;
+ if R > $F800 then
+ R := $F800;
+ if G > $07C0 then
+ G := $07C0;
+ if B > $001F then
+ B := $001F;
+ PUInt16( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 24 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $00FF0000 + Color and $00FF0000;
+ G := SrcColor and $0000FF00 + Color and $0000FF00;
+ B := SrcColor and $000000FF + Color and $000000FF;
+ if R > $FF0000 then
+ R := $FF0000;
+ if G > $00FF00 then
+ G := $00FF00;
+ if B > $0000FF then
+ B := $0000FF;
+ PUInt32( Addr )^ := SrcColor and $FF000000 or R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 32 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $00FF0000 + Color and $00FF0000;
+ G := SrcColor and $0000FF00 + Color and $0000FF00;
+ B := SrcColor and $000000FF + Color and $000000FF;
+ if R > $FF0000 then
+ R := $FF0000;
+ if G > $00FF00 then
+ G := $00FF00;
+ if B > $0000FF then
+ B := $0000FF;
+ PUInt32( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ end;
+ SDL_UnlockSurface( DstSurface );
+ end;
+end;
+
+procedure SDL_FillRectSub( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 );
+var
+ RealRect : TSDL_Rect;
+ Addr : pointer;
+ ModX, BPP : cardinal;
+ x, y, R, G, B, SrcColor : cardinal;
+begin
+ RealRect := ValidateSurfaceRect( DstSurface, DstRect );
+ if ( RealRect.w > 0 ) and ( RealRect.h > 0 ) then
+ begin
+ SDL_LockSurface( DstSurface );
+ BPP := DstSurface.format.BytesPerPixel;
+ with DstSurface^ do
+ begin
+ Addr := pointer( UInt32( pixels ) + UInt32( RealRect.y ) * pitch + UInt32( RealRect.x ) * BPP );
+ ModX := Pitch - UInt32( RealRect.w ) * BPP;
+ end;
+ case DstSurface.format.BitsPerPixel of
+ 8 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $E0 - Color and $E0;
+ G := SrcColor and $1C - Color and $1C;
+ B := SrcColor and $03 - Color and $03;
+ if R > $E0 then
+ R := 0;
+ if G > $1C then
+ G := 0;
+ if B > $03 then
+ B := 0;
+ PUInt8( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 15 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $7C00 - Color and $7C00;
+ G := SrcColor and $03E0 - Color and $03E0;
+ B := SrcColor and $001F - Color and $001F;
+ if R > $7C00 then
+ R := 0;
+ if G > $03E0 then
+ G := 0;
+ if B > $001F then
+ B := 0;
+ PUInt16( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 16 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $F800 - Color and $F800;
+ G := SrcColor and $07C0 - Color and $07C0;
+ B := SrcColor and $001F - Color and $001F;
+ if R > $F800 then
+ R := 0;
+ if G > $07C0 then
+ G := 0;
+ if B > $001F then
+ B := 0;
+ PUInt16( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 24 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $00FF0000 - Color and $00FF0000;
+ G := SrcColor and $0000FF00 - Color and $0000FF00;
+ B := SrcColor and $000000FF - Color and $000000FF;
+ if R > $FF0000 then
+ R := 0;
+ if G > $00FF00 then
+ G := 0;
+ if B > $0000FF then
+ B := 0;
+ PUInt32( Addr )^ := SrcColor and $FF000000 or R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 32 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $00FF0000 - Color and $00FF0000;
+ G := SrcColor and $0000FF00 - Color and $0000FF00;
+ B := SrcColor and $000000FF - Color and $000000FF;
+ if R > $FF0000 then
+ R := 0;
+ if G > $00FF00 then
+ G := 0;
+ if B > $0000FF then
+ B := 0;
+ PUInt32( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ end;
+ SDL_UnlockSurface( DstSurface );
+ end;
+end;
+
+procedure SDL_GradientFillRect( DstSurface : PSDL_Surface; const Rect : PSDL_Rect; const StartColor, EndColor : TSDL_Color; const Style : TGradientStyle );
+var
+ FBC : array[ 0..255 ] of Cardinal;
+ // temp vars
+ i, YR, YG, YB, SR, SG, SB, DR, DG, DB : Integer;
+
+ TempStepV, TempStepH : Single;
+ TempLeft, TempTop, TempHeight, TempWidth : integer;
+ TempRect : TSDL_Rect;
+
+begin
+ // calc FBC
+ YR := StartColor.r;
+ YG := StartColor.g;
+ YB := StartColor.b;
+ SR := YR;
+ SG := YG;
+ SB := YB;
+ DR := EndColor.r - SR;
+ DG := EndColor.g - SG;
+ DB := EndColor.b - SB;
+
+ for i := 0 to 255 do
+ begin
+ FBC[ i ] := SDL_MapRGB( DstSurface.format, YR, YG, YB );
+ YR := SR + round( DR / 255 * i );
+ YG := SG + round( DG / 255 * i );
+ YB := SB + round( DB / 255 * i );
+ end;
+
+ // if aStyle = 1 then begin
+ TempStepH := Rect.w / 255;
+ TempStepV := Rect.h / 255;
+ TempHeight := Trunc( TempStepV + 1 );
+ TempWidth := Trunc( TempStepH + 1 );
+ TempTop := 0;
+ TempLeft := 0;
+ TempRect.x := Rect.x;
+ TempRect.y := Rect.y;
+ TempRect.h := Rect.h;
+ TempRect.w := Rect.w;
+
+ case Style of
+ gsHorizontal :
+ begin
+ TempRect.h := TempHeight;
+ for i := 0 to 255 do
+ begin
+ TempRect.y := Rect.y + TempTop;
+ SDL_FillRect( DstSurface, @TempRect, FBC[ i ] );
+ TempTop := Trunc( TempStepV * i );
+ end;
+ end;
+ gsVertical :
+ begin
+ TempRect.w := TempWidth;
+ for i := 0 to 255 do
+ begin
+ TempRect.x := Rect.x + TempLeft;
+ SDL_FillRect( DstSurface, @TempRect, FBC[ i ] );
+ TempLeft := Trunc( TempStepH * i );
+ end;
+ end;
+ end;
+end;
+
+procedure SDL_2xBlit( Src, Dest : PSDL_Surface );
+var
+ ReadAddr, WriteAddr, ReadRow, WriteRow : UInt32;
+ SrcPitch, DestPitch, x, y, w, h : UInt32;
+begin
+ if ( Src = nil ) or ( Dest = nil ) then
+ exit;
+ if ( Src.w shl 1 ) < Dest.w then
+ exit;
+ if ( Src.h shl 1 ) < Dest.h then
+ exit;
+
+ if SDL_MustLock( Src ) then
+ SDL_LockSurface( Src );
+ if SDL_MustLock( Dest ) then
+ SDL_LockSurface( Dest );
+
+ ReadRow := UInt32( Src.Pixels );
+ WriteRow := UInt32( Dest.Pixels );
+
+ SrcPitch := Src.pitch;
+ DestPitch := Dest.pitch;
+
+ w := Src.w;
+ h := Src.h;
+
+ case Src.format.BytesPerPixel of
+ 1 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+ mov ebx, DestPitch
+
+ @LoopX:
+ mov al, [ecx] // PUInt8(WriteAddr)^ := PUInt8(ReadAddr)^;
+ mov [edx], al
+ mov [edx + 1], al // PUInt8(WriteAddr + 1)^ := PUInt8(ReadAddr)^;
+ mov [edx + ebx], al // PUInt8(WriteAddr + DestPitch)^ := PUInt8(ReadAddr)^;
+ mov [edx + ebx + 1], al // PUInt8(WriteAddr + DestPitch + 1)^ := PUInt8(ReadAddr)^;
+
+ inc ecx // inc(ReadAddr);
+ add edx, 2 // inc(WriteAddr, 2);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ 2 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+ mov ebx, DestPitch
+
+ @LoopX:
+ mov ax, [ecx] // PUInt16(WriteAddr)^ := PUInt16(ReadAddr)^;
+ mov [edx], ax
+ mov [edx + 2], ax // PUInt16(WriteAddr + 2)^ := PUInt16(ReadAddr)^;
+ mov [edx + ebx], ax // PUInt16(WriteAddr + DestPitch)^ := PUInt16(ReadAddr)^;
+ mov [edx + ebx + 2], ax // PUInt16(WriteAddr + DestPitch + 2)^ := PUInt16(ReadAddr)^;
+
+ add ecx, 2 // inc(ReadAddr, 2);
+ add edx, 4 // inc(WriteAddr, 4);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ 3 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+ mov ebx, DestPitch
+
+ @LoopX:
+ mov eax, [ecx] // (PUInt32(WriteAddr)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff);
+ and eax, $00ffffff
+ and dword ptr [edx], $ff000000
+ or [edx], eax
+ and dword ptr [edx + 3], $00ffffff // (PUInt32(WriteAddr + 3)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff);
+ or [edx + 3], eax
+ and dword ptr [edx + ebx], $00ffffff // (PUInt32(WriteAddr + DestPitch)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff);
+ or [edx + ebx], eax
+ and dword ptr [edx + ebx + 3], $00ffffff // (PUInt32(WriteAddr + DestPitch + 3)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff);
+ or [edx + ebx + 3], eax
+
+ add ecx, 3 // inc(ReadAddr, 3);
+ add edx, 6 // inc(WriteAddr, 6);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ 4 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+ mov ebx, DestPitch
+
+ @LoopX:
+ mov eax, [ecx] // PUInt32(WriteAddr)^ := PUInt32(ReadAddr)^;
+ mov [edx], eax
+ mov [edx + 4], eax // PUInt32(WriteAddr + 4)^ := PUInt32(ReadAddr)^;
+ mov [edx + ebx], eax // PUInt32(WriteAddr + DestPitch)^ := PUInt32(ReadAddr)^;
+ mov [edx + ebx + 4], eax // PUInt32(WriteAddr + DestPitch + 4)^ := PUInt32(ReadAddr)^;
+
+ add ecx, 4 // inc(ReadAddr, 4);
+ add edx, 8 // inc(WriteAddr, 8);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ end;
+
+ if SDL_MustLock( Src ) then
+ SDL_UnlockSurface( Src );
+ if SDL_MustLock( Dest ) then
+ SDL_UnlockSurface( Dest );
+end;
+
+procedure SDL_Scanline2xBlit( Src, Dest : PSDL_Surface );
+var
+ ReadAddr, WriteAddr, ReadRow, WriteRow : UInt32;
+ SrcPitch, DestPitch, x, y, w, h : UInt32;
+begin
+ if ( Src = nil ) or ( Dest = nil ) then
+ exit;
+ if ( Src.w shl 1 ) < Dest.w then
+ exit;
+ if ( Src.h shl 1 ) < Dest.h then
+ exit;
+
+ if SDL_MustLock( Src ) then
+ SDL_LockSurface( Src );
+ if SDL_MustLock( Dest ) then
+ SDL_LockSurface( Dest );
+
+ ReadRow := UInt32( Src.Pixels );
+ WriteRow := UInt32( Dest.Pixels );
+
+ SrcPitch := Src.pitch;
+ DestPitch := Dest.pitch;
+
+ w := Src.w;
+ h := Src.h;
+
+ case Src.format.BytesPerPixel of
+ 1 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+
+ @LoopX:
+ mov al, [ecx] // PUInt8(WriteAddr)^ := PUInt8(ReadAddr)^;
+ mov [edx], al
+ mov [edx + 1], al // PUInt8(WriteAddr + 1)^ := PUInt8(ReadAddr)^;
+
+ inc ecx // inc(ReadAddr);
+ add edx, 2 // inc(WriteAddr, 2);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ 2 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+
+ @LoopX:
+ mov ax, [ecx] // PUInt16(WriteAddr)^ := PUInt16(ReadAddr)^;
+ mov [edx], ax
+ mov [edx + 2], eax // PUInt16(WriteAddr + 2)^ := PUInt16(ReadAddr)^;
+
+ add ecx, 2 // inc(ReadAddr, 2);
+ add edx, 4 // inc(WriteAddr, 4);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ 3 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+
+ @LoopX:
+ mov eax, [ecx] // (PUInt32(WriteAddr)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff);
+ and eax, $00ffffff
+ and dword ptr [edx], $ff000000
+ or [edx], eax
+ and dword ptr [edx + 3], $00ffffff // (PUInt32(WriteAddr + 3)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff);
+ or [edx + 3], eax
+
+ add ecx, 3 // inc(ReadAddr, 3);
+ add edx, 6 // inc(WriteAddr, 6);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ 4 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+
+ @LoopX:
+ mov eax, [ecx] // PUInt32(WriteAddr)^ := PUInt32(ReadAddr)^;
+ mov [edx], eax
+ mov [edx + 4], eax // PUInt32(WriteAddr + 4)^ := PUInt32(ReadAddr)^;
+
+ add ecx, 4 // inc(ReadAddr, 4);
+ add edx, 8 // inc(WriteAddr, 8);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ end;
+
+ if SDL_MustLock( Src ) then
+ SDL_UnlockSurface( Src );
+ if SDL_MustLock( Dest ) then
+ SDL_UnlockSurface( Dest );
+end;
+
+procedure SDL_50Scanline2xBlit( Src, Dest : PSDL_Surface );
+var
+ ReadAddr, WriteAddr, ReadRow, WriteRow : UInt32;
+ SrcPitch, DestPitch, x, y, w, h : UInt32;
+begin
+ if ( Src = nil ) or ( Dest = nil ) then
+ exit;
+ if ( Src.w shl 1 ) < Dest.w then
+ exit;
+ if ( Src.h shl 1 ) < Dest.h then
+ exit;
+
+ if SDL_MustLock( Src ) then
+ SDL_LockSurface( Src );
+ if SDL_MustLock( Dest ) then
+ SDL_LockSurface( Dest );
+
+ ReadRow := UInt32( Src.Pixels );
+ WriteRow := UInt32( Dest.Pixels );
+
+ SrcPitch := Src.pitch;
+ DestPitch := Dest.pitch;
+
+ w := Src.w;
+ h := Src.h;
+
+ case Src.format.BitsPerPixel of
+ 8 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+ mov ebx, DestPitch
+
+ @LoopX:
+ mov al, [ecx] // PUInt8(WriteAddr)^ := PUInt8(ReadAddr)^;
+ mov [edx], al
+ mov [edx + 1], al // PUInt8(WriteAddr + 1)^ := PUInt8(ReadAddr)^;
+ shr al, 1
+ and al, $6d
+ mov [edx + ebx], al // PUInt8(WriteAddr + DestPitch)^ := PUInt8(ReadAddr)^;
+ mov [edx + ebx + 1], al // PUInt8(WriteAddr + DestPitch + 1)^ := PUInt8(ReadAddr)^;
+
+ inc ecx // inc(ReadAddr);
+ add edx, 2 // inc(WriteAddr, 2);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ 15 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+ mov ebx, DestPitch
+
+ @LoopX:
+ mov ax, [ecx] // PUInt16(WriteAddr)^ := PUInt16(ReadAddr)^;
+ mov [edx], ax
+ mov [edx + 2], ax // PUInt16(WriteAddr + 2)^ := PUInt16(ReadAddr)^;
+ shr ax, 1
+ and ax, $3def
+ mov [edx + ebx], ax // PUInt16(WriteAddr + DestPitch)^ := PUInt16(ReadAddr)^;
+ mov [edx + ebx + 2], ax // PUInt16(WriteAddr + DestPitch + 2)^ := PUInt16(ReadAddr)^;
+
+ add ecx, 2 // inc(ReadAddr, 2);
+ add edx, 4 // inc(WriteAddr, 4);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ 16 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+ mov ebx, DestPitch
+
+ @LoopX:
+ mov ax, [ecx] // PUInt16(WriteAddr)^ := PUInt16(ReadAddr)^;
+ mov [edx], ax
+ mov [edx + 2], ax // PUInt16(WriteAddr + 2)^ := PUInt16(ReadAddr)^;
+ shr ax, 1
+ and ax, $7bef
+ mov [edx + ebx], ax // PUInt16(WriteAddr + DestPitch)^ := PUInt16(ReadAddr)^;
+ mov [edx + ebx + 2], ax // PUInt16(WriteAddr + DestPitch + 2)^ := PUInt16(ReadAddr)^;
+
+ add ecx, 2 // inc(ReadAddr, 2);
+ add edx, 4 // inc(WriteAddr, 4);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ 24 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+ mov ebx, DestPitch
+
+ @LoopX:
+ mov eax, [ecx] // (PUInt32(WriteAddr)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff);
+ and eax, $00ffffff
+ and dword ptr [edx], $ff000000
+ or [edx], eax
+ and dword ptr [edx + 3], $00ffffff // (PUInt32(WriteAddr + 3)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff);
+ or [edx + 3], eax
+ shr eax, 1
+ and eax, $007f7f7f
+ and dword ptr [edx + ebx], $00ffffff // (PUInt32(WriteAddr + DestPitch)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff);
+ or [edx + ebx], eax
+ and dword ptr [edx + ebx + 3], $00ffffff // (PUInt32(WriteAddr + DestPitch + 3)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff);
+ or [edx + ebx + 3], eax
+
+ add ecx, 3 // inc(ReadAddr, 3);
+ add edx, 6 // inc(WriteAddr, 6);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ 32 :
+ asm
+ push ebx
+ mov eax, h // for y := 1 to Src.h do
+ mov y, eax
+ @LoopY:
+ mov eax, ReadRow // ReadAddr := ReadRow;
+ mov ReadAddr, eax
+
+ mov eax, WriteRow // WriteAddr := WriteRow;
+ mov WriteAddr, eax
+
+ mov eax, w // for x := 1 to Src.w do
+ mov x, eax
+
+ mov ecx, ReadAddr
+ mov edx, WriteAddr
+ mov ebx, DestPitch
+
+ @LoopX:
+ mov eax, [ecx] // PUInt32(WriteAddr)^ := PUInt32(ReadAddr)^;
+ mov [edx], eax
+ mov [edx + 4], eax // PUInt32(WriteAddr + 4)^ := PUInt32(ReadAddr)^;
+ shr eax, 1
+ and eax, $7f7f7f7f
+ mov [edx + ebx], eax // PUInt32(WriteAddr + DestPitch)^ := PUInt32(ReadAddr)^;
+ mov [edx + ebx + 4], eax // PUInt32(WriteAddr + DestPitch + 4)^ := PUInt32(ReadAddr)^;
+
+ add ecx, 4 // inc(ReadAddr, 4);
+ add edx, 8 // inc(WriteAddr, 8);
+
+ dec x
+ jnz @LoopX
+
+ mov eax, SrcPitch // inc(UInt32(ReadRow), SrcPitch);
+ add ReadRow, eax
+
+ mov eax, DestPitch // inc(UInt32(WriteRow), DestPitch * 2);
+ add WriteRow, eax
+ add WriteRow, eax
+
+ dec y
+ jnz @LoopY
+ pop ebx
+ end;
+ end;
+
+ if SDL_MustLock( Src ) then
+ SDL_UnlockSurface( Src );
+ if SDL_MustLock( Dest ) then
+ SDL_UnlockSurface( Dest );
+end;
+
+function SDL_PixelTestSurfaceVsRect( SrcSurface1 : PSDL_Surface; SrcRect1 : PSDL_Rect; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) :
+boolean;
+var
+ Src_Rect1, Src_Rect2 : TSDL_Rect;
+ right1, bottom1 : integer;
+ right2, bottom2 : integer;
+ Scan1Start, Scan2Start, ScanWidth, ScanHeight : cardinal;
+ Mod1: cardinal;
+ Addr1 : cardinal;
+ BPP : cardinal;
+ Pitch1 : cardinal;
+ TransparentColor1 : cardinal;
+ tx, ty : cardinal;
+ StartTick : cardinal;
+ Color1 : cardinal;
+begin
+ Result := false;
+ if SrcRect1 = nil then
+ begin
+ with Src_Rect1 do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface1.w;
+ h := SrcSurface1.h;
+ end;
+ end
+ else
+ Src_Rect1 := SrcRect1^;
+
+ Src_Rect2 := SrcRect2^;
+ with Src_Rect1 do
+ begin
+ Right1 := Left1 + w;
+ Bottom1 := Top1 + h;
+ end;
+ with Src_Rect2 do
+ begin
+ Right2 := Left2 + w;
+ Bottom2 := Top2 + h;
+ end;
+ if ( Left1 >= Right2 ) or ( Right1 <= Left2 ) or ( Top1 >= Bottom2 ) or (
+Bottom1 <=
+ Top2 ) then
+ exit;
+ if Left1 <= Left2 then
+ begin
+ // 1. left, 2. right
+ Scan1Start := Src_Rect1.x + Left2 - Left1;
+ Scan2Start := Src_Rect2.x;
+ ScanWidth := Right1 - Left2;
+ with Src_Rect2 do
+ if ScanWidth > w then
+ ScanWidth := w;
+ end
+ else
+ begin
+ // 1. right, 2. left
+ Scan1Start := Src_Rect1.x;
+ Scan2Start := Src_Rect2.x + Left1 - Left2;
+ ScanWidth := Right2 - Left1;
+ with Src_Rect1 do
+ if ScanWidth > w then
+ ScanWidth := w;
+ end;
+ with SrcSurface1^ do
+ begin
+ Pitch1 := Pitch;
+ Addr1 := cardinal( Pixels );
+ inc( Addr1, Pitch1 * UInt32( Src_Rect1.y ) );
+ with format^ do
+ begin
+ BPP := BytesPerPixel;
+ TransparentColor1 := colorkey;
+ end;
+ end;
+
+ Mod1 := Pitch1 - ( ScanWidth * BPP );
+
+ inc( Addr1, BPP * Scan1Start );
+
+ if Top1 <= Top2 then
+ begin
+ // 1. up, 2. down
+ ScanHeight := Bottom1 - Top2;
+ if ScanHeight > Src_Rect2.h then
+ ScanHeight := Src_Rect2.h;
+ inc( Addr1, Pitch1 * UInt32( Top2 - Top1 ) );
+ end
+ else
+ begin
+ // 1. down, 2. up
+ ScanHeight := Bottom2 - Top1;
+ if ScanHeight > Src_Rect1.h then
+ ScanHeight := Src_Rect1.h;
+
+ end;
+ case BPP of
+ 1 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ if ( PByte( Addr1 )^ <> TransparentColor1 ) then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1 );
+
+ end;
+ inc( Addr1, Mod1 );
+
+ end;
+ 2 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ if ( PWord( Addr1 )^ <> TransparentColor1 ) then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1, 2 );
+
+ end;
+ inc( Addr1, Mod1 );
+
+ end;
+ 3 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ Color1 := PLongWord( Addr1 )^ and $00FFFFFF;
+
+ if ( Color1 <> TransparentColor1 )
+ then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1, 3 );
+
+ end;
+ inc( Addr1, Mod1 );
+
+ end;
+ 4 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ if ( PLongWord( Addr1 )^ <> TransparentColor1 ) then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1, 4 );
+
+ end;
+ inc( Addr1, Mod1 );
+
+ end;
+ end;
+end;
+
+procedure SDL_ORSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+var
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr, TransparentColor : cardinal;
+ // TransparentColor: cardinal;
+ _ebx, _esi, _edi, _esp : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DestSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DestSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ TransparentColor := Format.colorkey;
+ end;
+ with DestSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DestSurface );
+ WorkY := Src.h;
+ case bits of
+ 8 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov al, [esi] // AL := source color
+ cmp al, 0
+ je @SkipColor // if AL=0 or AL=transparent color then skip everything
+ cmp al, byte ptr TransparentColor
+ je @SkipColor
+ or al, [edi]
+ mov [edi], al
+ @SkipColor:
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 15 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov ax, [esi] // AX := source color
+ cmp ax, 0
+ je @SkipColor // if AX=0 then skip everything
+ cmp ax, word ptr TransparentColor
+ je @SkipColor
+ or ax, [edi]
+ mov [edi], ax
+ @SkipColor:
+ add esi, 2
+ add edi, 2
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 16 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov ax, [esi] // AX := source color
+ cmp ax, 0
+ je @SkipColor // if AX=0 then skip everything
+ cmp ax, word ptr TransparentColor
+ je @SkipColor
+ or ax, [edi]
+ mov [edi], ax
+ @SkipColor:
+ add esi, 2
+ add edi, 2
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 24 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ add WorkX, ax // WorkX := Src.w * 2
+ add WorkX, ax // WorkX := Src.w * 3
+ @Loopx:
+ mov al, [esi] // AL := source color
+ or al, [edi]
+ mov [edi], al
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 32 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ shl ax, 2
+ mov WorkX, ax // WorkX := Src.w * 4
+ @Loopx:
+ mov al, [esi] // AL := source color
+ or al, [edi]
+ mov [edi], al
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DestSurface );
+end;
+
+procedure SDL_ANDSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+var
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr, TransparentColor : cardinal;
+ // TransparentColor: cardinal;
+ _ebx, _esi, _edi, _esp : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DestSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DestSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ TransparentColor := Format.colorkey;
+ end;
+ with DestSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DestSurface );
+ WorkY := Src.h;
+ case bits of
+ 8 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov al, [esi] // AL := source color
+ cmp al, 0
+ je @SkipColor // if AL=0 or AL=transparent color then skip everything
+ cmp al, byte ptr TransparentColor
+ je @SkipColor
+ and al, [edi]
+ mov [edi], al
+ @SkipColor:
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 15 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov ax, [esi] // AX := source color
+ cmp ax, 0
+ je @SkipColor // if AX=0 then skip everything
+ cmp ax, word ptr TransparentColor
+ je @SkipColor
+ and ax, [edi]
+ mov [edi], ax
+ @SkipColor:
+ add esi, 2
+ add edi, 2
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 16 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ @Loopx:
+ mov ax, [esi] // AX := source color
+ cmp ax, 0
+ je @SkipColor // if AX=0 then skip everything
+ cmp ax, word ptr TransparentColor
+ je @SkipColor
+ and ax, [edi]
+ mov [edi], ax
+ @SkipColor:
+ add esi, 2
+ add edi, 2
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 24 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ mov WorkX, ax // WorkX := Src.w
+ add WorkX, ax // WorkX := Src.w * 2
+ add WorkX, ax // WorkX := Src.w * 3
+ @Loopx:
+ mov al, [esi] // AL := source color
+ and al, [edi]
+ mov [edi], al
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ 32 :
+ asm
+ mov _ebx, ebx
+ mov _esi, esi
+ mov _edi, edi
+ mov _esp, esp
+ mov esi, SrcAddr // ESI - Source Offset
+ mov edi, DestAddr // EDI - Destination Offset
+ mov ax, Src.h // WorkY := Src.h
+ mov WorkY, ax
+ @LoopY:
+ mov ax, Src.w
+ shl ax, 2
+ mov WorkX, ax // WorkX := Src.w * 4
+ @Loopx:
+ mov al, [esi] // AL := source color
+ and al, [edi]
+ mov [edi], al
+ inc esi
+ inc edi
+ dec WorkX
+ jnz @LoopX
+ add esi, SrcMod
+ add edi, DestMod
+ dec WorkY
+ jnz @LoopY
+ mov esp,_esp
+ mov edi,_edi
+ mov esi,_esi
+ mov ebx,_ebx
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DestSurface );
+end;
+
+
+procedure SDL_GTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+var
+ R, G, B, Pixel1, Pixel2, TransparentColor : cardinal;
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DestSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DestSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ TransparentColor := Format.colorkey;
+ end;
+ with DestSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DestSurface );
+ WorkY := Src.h;
+ case bits of
+ 8 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt8( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt8( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+ if Pixel2 and $E0 > Pixel1 and $E0 then R := Pixel2 and $E0 else R := Pixel1 and $E0;
+ if Pixel2 and $1C > Pixel1 and $1C then G := Pixel2 and $1C else G := Pixel1 and $1C;
+ if Pixel2 and $03 > Pixel1 and $03 then B := Pixel2 and $03 else B := Pixel1 and $03;
+
+ if R > $E0 then
+ R := $E0;
+ if G > $1C then
+ G := $1C;
+ if B > $03 then
+ B := $03;
+ PUInt8( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt8( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr );
+ inc( DestAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 15 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $7C00 > Pixel1 and $7C00 then R := Pixel2 and $7C00 else R := Pixel1 and $7C00;
+ if Pixel2 and $03E0 > Pixel1 and $03E0 then G := Pixel2 and $03E0 else G := Pixel1 and $03E0;
+ if Pixel2 and $001F > Pixel1 and $001F then B := Pixel2 and $001F else B := Pixel1 and $001F;
+
+ PUInt16( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt16( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 16 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $F800 > Pixel1 and $F800 then R := Pixel2 and $F800 else R := Pixel1 and $F800;
+ if Pixel2 and $07E0 > Pixel1 and $07E0 then G := Pixel2 and $07E0 else G := Pixel1 and $07E0;
+ if Pixel2 and $001F > Pixel1 and $001F then B := Pixel2 and $001F else B := Pixel1 and $001F;
+
+ PUInt16( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt16( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 24 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $FF0000 > Pixel1 and $FF0000 then R := Pixel2 and $FF0000 else R := Pixel1 and $FF0000;
+ if Pixel2 and $00FF00 > Pixel1 and $00FF00 then G := Pixel2 and $00FF00 else G := Pixel1 and $00FF00;
+ if Pixel2 and $0000FF > Pixel1 and $0000FF then B := Pixel2 and $0000FF else B := Pixel1 and $0000FF;
+
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or ( R or G or B );
+ end
+ else
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or Pixel1;
+ end;
+ inc( SrcAddr, 3 );
+ inc( DestAddr, 3 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 32 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $FF0000 > Pixel1 and $FF0000 then R := Pixel2 and $FF0000 else R := Pixel1 and $FF0000;
+ if Pixel2 and $00FF00 > Pixel1 and $00FF00 then G := Pixel2 and $00FF00 else G := Pixel1 and $00FF00;
+ if Pixel2 and $0000FF > Pixel1 and $0000FF then B := Pixel2 and $0000FF else B := Pixel1 and $0000FF;
+
+ PUInt32( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt32( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 4 );
+ inc( DestAddr, 4 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DestSurface );
+end;
+
+
+procedure SDL_LTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+var
+ R, G, B, Pixel1, Pixel2, TransparentColor : cardinal;
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DestSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DestSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ TransparentColor := Format.colorkey;
+ end;
+ with DestSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DestSurface );
+ WorkY := Src.h;
+ case bits of
+ 8 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt8( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt8( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+ if Pixel2 and $E0 < Pixel1 and $E0 then R := Pixel2 and $E0 else R := Pixel1 and $E0;
+ if Pixel2 and $1C < Pixel1 and $1C then G := Pixel2 and $1C else G := Pixel1 and $1C;
+ if Pixel2 and $03 < Pixel1 and $03 then B := Pixel2 and $03 else B := Pixel1 and $03;
+
+ if R > $E0 then
+ R := $E0;
+ if G > $1C then
+ G := $1C;
+ if B > $03 then
+ B := $03;
+ PUInt8( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt8( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr );
+ inc( DestAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 15 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $7C00 < Pixel1 and $7C00 then R := Pixel2 and $7C00 else R := Pixel1 and $7C00;
+ if Pixel2 and $03E0 < Pixel1 and $03E0 then G := Pixel2 and $03E0 else G := Pixel1 and $03E0;
+ if Pixel2 and $001F < Pixel1 and $001F then B := Pixel2 and $001F else B := Pixel1 and $001F;
+
+ PUInt16( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt16( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 16 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $F800 < Pixel1 and $F800 then R := Pixel2 and $F800 else R := Pixel1 and $F800;
+ if Pixel2 and $07E0 < Pixel1 and $07E0 then G := Pixel2 and $07E0 else G := Pixel1 and $07E0;
+ if Pixel2 and $001F < Pixel1 and $001F then B := Pixel2 and $001F else B := Pixel1 and $001F;
+
+ PUInt16( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt16( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 24 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $FF0000 < Pixel1 and $FF0000 then R := Pixel2 and $FF0000 else R := Pixel1 and $FF0000;
+ if Pixel2 and $00FF00 < Pixel1 and $00FF00 then G := Pixel2 and $00FF00 else G := Pixel1 and $00FF00;
+ if Pixel2 and $0000FF < Pixel1 and $0000FF then B := Pixel2 and $0000FF else B := Pixel1 and $0000FF;
+
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or ( R or G or B );
+ end
+ else
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or Pixel1;
+ end;
+ inc( SrcAddr, 3 );
+ inc( DestAddr, 3 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 32 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $FF0000 < Pixel1 and $FF0000 then R := Pixel2 and $FF0000 else R := Pixel1 and $FF0000;
+ if Pixel2 and $00FF00 < Pixel1 and $00FF00 then G := Pixel2 and $00FF00 else G := Pixel1 and $00FF00;
+ if Pixel2 and $0000FF < Pixel1 and $0000FF then B := Pixel2 and $0000FF else B := Pixel1 and $0000FF;
+
+ PUInt32( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt32( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 4 );
+ inc( DestAddr, 4 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DestSurface );
+end;
+
+function SDL_ClipLine(var x1,y1,x2,y2: Integer; ClipRect: PSDL_Rect) : boolean;
+var tflag, flag1, flag2: word;
+ txy, xedge, yedge: Integer;
+ slope: single;
+
+ function ClipCode(x,y: Integer): word;
+ begin
+ Result := 0;
+ if x < ClipRect.x then Result := 1;
+ if x >= ClipRect.w + ClipRect.x then Result := Result or 2;
+ if y < ClipRect.y then Result := Result or 4;
+ if y >= ClipRect.h + ClipRect.y then Result := Result or 8;
+ end;
+
+begin
+ flag1 := ClipCode(x1,y1);
+ flag2 := ClipCode(x2,y2);
+ result := true;
+
+ while true do
+ begin
+ if (flag1 or flag2) = 0 then Exit; // all in
+
+ if (flag1 and flag2) <> 0 then
+ begin
+ result := false;
+ Exit; // all out
+ end;
+
+ if flag2 = 0 then
+ begin
+ txy := x1; x1 := x2; x2 := txy;
+ txy := y1; y1 := y2; y2 := txy;
+ tflag := flag1; flag1 := flag2; flag2 := tflag;
+ end;
+
+ if (flag2 and 3) <> 0 then
+ begin
+ if (flag2 and 1) <> 0 then
+ xedge := ClipRect.x
+ else
+ xedge := ClipRect.w + ClipRect.x -1; // back 1 pixel otherwise we end up in a loop
+
+ slope := (y2 - y1) / (x2 - x1);
+ y2 := y1 + Round(slope * (xedge - x1));
+ x2 := xedge;
+ end
+ else
+ begin
+ if (flag2 and 4) <> 0 then
+ yedge := ClipRect.y
+ else
+ yedge := ClipRect.h + ClipRect.y -1; // up 1 pixel otherwise we end up in a loop
+
+ slope := (x2 - x1) / (y2 - y1);
+ x2 := x1 + Round(slope * (yedge - y1));
+ y2 := yedge;
+ end;
+
+ flag2 := ClipCode(x2, y2);
+ end;
+end;
+
+end.
+
+
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlinput.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlinput.pas new file mode 100644 index 00000000..2955d17a --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlinput.pas @@ -0,0 +1,692 @@ +unit sdlinput;
+{
+ $Id: sdlinput.pas,v 1.7 2004/09/30 22:32:04 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer }
+{ SDL Input Wrapper }
+{ }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Dominique Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Portions created by Dominique Louis are }
+{ Copyright (C) 2003 - 2100 Dominique Louis. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ Dominique Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ SDL Mouse, Keyboard and Joystick wrapper }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ SDL.dll on Windows platforms }
+{ libSDL-1.1.so.0 on Linux platform }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ March 12 2003 - DL : Initial creation }
+{ }
+{ February 02 2004 - DL : Added Custom Cursor Support to the Mouse class }
+{
+ $Log: sdlinput.pas,v $
+ Revision 1.7 2004/09/30 22:32:04 savage
+ Updated with slightly different header comments
+
+ Revision 1.6 2004/09/12 21:52:58 savage
+ Slight changes to fix some issues with the sdl classes.
+
+ Revision 1.5 2004/05/10 21:11:49 savage
+ changes required to help get SoAoS off the ground.
+
+ Revision 1.4 2004/05/03 22:38:40 savage
+ Added the ability to enable or disable certain inputs @ runtime. Basically it just does not call UpdateInput if Enabled = false.
+ Can also disable and enable input devices via the InputManager.
+
+ Revision 1.3 2004/04/28 21:27:01 savage
+ Updated Joystick code and event handlers. Needs testing...
+
+ Revision 1.2 2004/02/14 22:36:29 savage
+ Fixed inconsistencies of using LoadLibrary and LoadModule.
+ Now all units make use of LoadModule rather than LoadLibrary and other dynamic proc procedures.
+
+ Revision 1.1 2004/02/05 00:08:20 savage
+ Module 1.0 release
+
+
+}
+{******************************************************************************}
+
+interface
+
+{$i jedi-sdl.inc}
+
+uses
+ Classes,
+ sdl;
+
+type
+ TSDLInputType = ( itJoystick , itKeyBoard, itMouse );
+ TSDLInputTypes = set of TSDLInputType;
+
+ TSDLCustomInput = class( TObject )
+ private
+ FEnabled: Boolean;
+ public
+ constructor Create;
+ function UpdateInput( event: TSDL_EVENT ) : Boolean; virtual; abstract;
+ property Enabled : Boolean read FEnabled write FEnabled;
+ end;
+
+ TSDLJoyAxisMoveEvent = procedure ( Which: UInt8; Axis: UInt8; Value: SInt16 ) {$IFNDEF NOT_OO}of object{$ENDIF};
+ TSDLJoyBallMoveEvent = procedure ( Which: UInt8; Ball: UInt8; RelativePos: TPoint ) {$IFNDEF NOT_OO}of object{$ENDIF};
+ TSDLJoyHatMoveEvent = procedure ( Which: UInt8; Hat: UInt8; Value: SInt16 ) {$IFNDEF NOT_OO}of object{$ENDIF};
+ TSDLJoyButtonEvent = procedure ( Which: UInt8; Button: UInt8; State: SInt16 ) {$IFNDEF NOT_OO}of object{$ENDIF};
+
+
+ TSDLJoyStick = class( TSDLCustomInput )
+ private
+ FJoystick : PSDL_Joystick;
+ FJoystickIndex : Integer;
+ FJoyAxisMoveEvent : TSDLJoyAxisMoveEvent;
+ FJoyBallMoveEvent : TSDLJoyBallMoveEvent;
+ FJoyHatMoveEvent : TSDLJoyHatMoveEvent;
+ FJoyButtonDownEvent : TSDLJoyButtonEvent;
+ FJoyButtonUpEvent : TSDLJoyButtonEvent;
+ procedure DoAxisMove( Event : TSDL_Event );
+ procedure DoBallMove( Event : TSDL_Event );
+ procedure DoHatMove( Event : TSDL_Event );
+ procedure DoButtonDown( Event : TSDL_Event );
+ procedure DoButtonUp( Event : TSDL_Event );
+ function GetName: PChar;
+ function GetNumAxes: integer;
+ function GetNumBalls: integer;
+ function GetNumButtons: integer;
+ function GetNumHats: integer;
+ public
+ constructor Create( Index : Integer );
+ destructor Destroy; override;
+ procedure Open;
+ procedure Close;
+ function UpdateInput( Event: TSDL_EVENT ) : Boolean; override;
+ property Name : PChar read GetName;
+ property NumAxes : integer read GetNumAxes;
+ property NumBalls : integer read GetNumBalls;
+ property NumButtons : integer read GetNumButtons;
+ property NumHats : integer read GetNumHats;
+ property OnAxisMove : TSDLJoyAxisMoveEvent read FJoyAxisMoveEvent write FJoyAxisMoveEvent;
+ property OnBallMove : TSDLJoyBallMoveEvent read FJoyBallMoveEvent write FJoyBallMoveEvent;
+ property OnHatMove : TSDLJoyHatMoveEvent read FJoyHatMoveEvent write FJoyHatMoveEvent;
+ property OnButtonDown : TSDLJoyButtonEvent read FJoyButtonDownEvent write FJoyButtonDownEvent;
+ property OnButtonUp : TSDLJoyButtonEvent read FJoyButtonUpEvent write FJoyButtonUpEvent;
+ end;
+
+ TSDLJoySticks = class( TObject )
+ private
+ FNumOfJoySticks: Integer;
+ FJoyStickList : TList;
+ function GetJoyStick(Index: integer): TSDLJoyStick;
+ procedure SetJoyStick(Index: integer; const Value: TSDLJoyStick);
+ public
+ constructor Create;
+ destructor Destroy; override;
+ function UpdateInput( event: TSDL_EVENT ) : Boolean;
+ property NumOfJoySticks : Integer read FNumOfJoySticks write FNumOfJoySticks;
+ property JoySticks[ Index : integer ] : TSDLJoyStick read GetJoyStick write SetJoyStick;
+ end;
+
+ TSDLKeyBoardEvent = procedure ( var Key: TSDLKey; Shift: TSDLMod; unicode : UInt16 ) {$IFNDEF NOT_OO}of object{$ENDIF};
+
+ TSDLKeyBoard = class( TSDLCustomInput )
+ private
+ FKeys : PKeyStateArr;
+ FOnKeyUp: TSDLKeyBoardEvent;
+ FOnKeyDown: TSDLKeyBoardEvent;
+ procedure DoKeyDown( keysym : PSDL_keysym );
+ procedure DoKeyUp( keysym : PSDL_keysym );
+ public
+ function IsKeyDown( Key : TSDLKey ) : Boolean;
+ function IsKeyUp( Key : TSDLKey ) : Boolean;
+ function UpdateInput( event: TSDL_EVENT ) : Boolean; override;
+ property Keys : PKeyStateArr read FKeys write FKeys;
+ property OnKeyDown : TSDLKeyBoardEvent read FOnKeyDown write FOnKeyDown;
+ property OnKeyUp : TSDLKeyBoardEvent read FOnKeyUp write FOnKeyUp;
+ end;
+
+ TSDLMouseButtonEvent = procedure ( Button : Integer; Shift: TSDLMod; MousePos : TPoint ) {$IFNDEF NOT_OO}of object{$ENDIF};
+ TSDLMouseMoveEvent = procedure ( Shift: TSDLMod; CurrentPos : TPoint; RelativePos : TPoint ) {$IFNDEF NOT_OO}of object{$ENDIF};
+ TSDLMouseWheelEvent = procedure ( WheelDelta : Integer; Shift: TSDLMod; MousePos : TPoint ) {$IFNDEF NOT_OO}of object{$ENDIF};
+
+ TSDLMouse = class( TSDLCustomInput )
+ private
+ FDragging : Boolean;
+ FMousePos : TPoint;
+ FOnMouseUp: TSDLMouseButtonEvent;
+ FOnMouseDown: TSDLMouseButtonEvent;
+ FOnMouseMove: TSDLMouseMoveEvent;
+ FOnMouseWheel: TSDLMouseWheelEvent;
+ FCursor : PSDL_Cursor; // Cursor Pointer
+ procedure DoMouseMove( Event: TSDL_Event );
+ procedure DoMouseDown( Event: TSDL_Event );
+ procedure DoMouseUp( Event: TSDL_Event );
+ procedure DoMouseWheelScroll( Event: TSDL_Event );
+ function GetMousePosition: TPoint;
+ procedure SetMousePosition(const Value: TPoint);
+ public
+ destructor Destroy; override;
+ function UpdateInput( event: TSDL_EVENT ) : Boolean; override;
+ function MouseIsDown( Button : Integer ) : Boolean;
+ function MouseIsUp( Button : Integer ) : Boolean;
+ procedure SetCursor(data, mask: PUInt8; w, h, hot_x, hot_y: Integer);
+ procedure ShowCursor;
+ procedure HideCursor;
+ property OnMouseDown : TSDLMouseButtonEvent read FOnMouseDown write FOnMouseDown;
+ property OnMouseUp : TSDLMouseButtonEvent read FOnMouseUp write FOnMouseUp;
+ property OnMouseMove : TSDLMouseMoveEvent read FOnMouseMove write FOnMouseMove;
+ property OnMouseWheel : TSDLMouseWheelEvent read FOnMouseWheel write FOnMouseWheel;
+ property MousePosition : TPoint read GetMousePosition write SetMousePosition;
+ end;
+
+ TSDLInputManager = class( TObject )
+ private
+ FKeyBoard : TSDLKeyBoard;
+ FMouse : TSDLMouse;
+ FJoystick : TSDLJoysticks;
+ public
+ constructor Create( InitInputs : TSDLInputTypes );
+ destructor Destroy; override;
+ procedure Disable( InitInputs : TSDLInputTypes; JoyStickNumber : Integer = 0 );
+ procedure Enable( InitInputs : TSDLInputTypes; JoyStickNumber : Integer = 0 );
+ function UpdateInputs( event: TSDL_EVENT ) : Boolean;
+ property KeyBoard : TSDLKeyBoard read FKeyBoard write FKeyBoard;
+ property Mouse : TSDLMouse read FMouse write FMouse;
+ property JoyStick : TSDLJoysticks read FJoyStick write FJoyStick;
+ end;
+
+implementation
+
+{ TSDLCustomInput }
+constructor TSDLCustomInput.Create;
+begin
+ inherited;
+ FEnabled := true;
+end;
+
+{ TSDLJoysticks }
+constructor TSDLJoysticks.Create;
+var
+ i : integer;
+begin
+ inherited;
+ if ( SDL_WasInit( SDL_INIT_JOYSTICK ) = 0 ) then
+ SDL_InitSubSystem( SDL_INIT_JOYSTICK );
+ FNumOfJoySticks := SDL_NumJoysticks;
+ FJoyStickList := TList.Create;
+ for i := 0 to FNumOfJoySticks - 1 do
+ begin
+ FJoyStickList.Add( TSDLJoyStick.Create( i ) );
+ end;
+end;
+
+destructor TSDLJoysticks.Destroy;
+var
+ i : integer;
+begin
+ if FJoyStickList.Count > 0 then
+ begin
+ for i := 0 to FJoyStickList.Count - 1 do
+ begin
+ TSDLJoyStick( FJoyStickList.Items[i] ).Free;
+ end;
+ end;
+ SDL_QuitSubSystem( SDL_INIT_JOYSTICK );
+ inherited;
+end;
+
+function TSDLJoySticks.GetJoyStick(Index: integer): TSDLJoyStick;
+begin
+ Result := TSDLJoyStick( FJoyStickList[ Index ] );
+end;
+
+procedure TSDLJoySticks.SetJoyStick(Index: integer;
+ const Value: TSDLJoyStick);
+begin
+ FJoyStickList[ Index ] := @Value;
+end;
+
+function TSDLJoysticks.UpdateInput(event: TSDL_EVENT): Boolean;
+var
+ i : integer;
+begin
+ result := false;
+ if FJoyStickList.Count > 0 then
+ begin
+ for i := 0 to FJoyStickList.Count - 1 do
+ begin
+ TSDLJoyStick( FJoyStickList.Items[i] ).UpdateInput( event );
+ end;
+ end;
+end;
+
+{ TSDLKeyBoard }
+procedure TSDLKeyBoard.DoKeyDown(keysym: PSDL_keysym);
+begin
+ if Assigned( FOnKeyDown ) then
+ FOnKeyDown( keysym.sym , keysym.modifier, keysym.unicode );
+end;
+
+procedure TSDLKeyBoard.DoKeyUp(keysym: PSDL_keysym);
+begin
+ if Assigned( FOnKeyUp ) then
+ FOnKeyUp( keysym.sym , keysym.modifier, keysym.unicode );
+end;
+
+function TSDLKeyBoard.IsKeyDown( Key: TSDLKey ): Boolean;
+begin
+ SDL_PumpEvents;
+
+ // Populate Keys array
+ FKeys := PKeyStateArr( SDL_GetKeyState( nil ) );
+ Result := ( FKeys[Key] = SDL_PRESSED );
+end;
+
+function TSDLKeyBoard.IsKeyUp( Key: TSDLKey ): Boolean;
+begin
+ SDL_PumpEvents;
+
+ // Populate Keys array
+ FKeys := PKeyStateArr( SDL_GetKeyState( nil ) );
+ Result := ( FKeys[Key] = SDL_RELEASED );
+end;
+
+function TSDLKeyBoard.UpdateInput(event: TSDL_EVENT): Boolean;
+begin
+ result := false;
+ if ( FEnabled ) then
+ begin
+ case event.type_ of
+ SDL_KEYDOWN :
+ begin
+ // handle key presses
+ DoKeyDown( @event.key.keysym );
+ result := true;
+ end;
+
+ SDL_KEYUP :
+ begin
+ // handle key releases
+ DoKeyUp( @event.key.keysym );
+ result := true;
+ end;
+ end;
+ end;
+end;
+
+{ TSDLMouse }
+destructor TSDLMouse.Destroy;
+begin
+ if FCursor <> nil then
+ SDL_FreeCursor( FCursor );
+ inherited;
+end;
+
+procedure TSDLMouse.DoMouseDown( Event: TSDL_Event );
+var
+ CurrentPos : TPoint;
+begin
+ FDragging := true;
+ if Assigned( FOnMouseDown ) then
+ begin
+ CurrentPos.x := event.button.x;
+ CurrentPos.y := event.button.y;
+ FOnMouseDown( event.button.button, SDL_GetModState, CurrentPos );
+ end;
+end;
+
+procedure TSDLMouse.DoMouseMove( Event: TSDL_Event );
+var
+ CurrentPos, RelativePos : TPoint;
+begin
+ if Assigned( FOnMouseMove ) then
+ begin
+ CurrentPos.x := event.motion.x;
+ CurrentPos.y := event.motion.y;
+ RelativePos.x := event.motion.xrel;
+ RelativePos.y := event.motion.yrel;
+ FOnMouseMove( SDL_GetModState, CurrentPos, RelativePos );
+ end;
+end;
+
+procedure TSDLMouse.DoMouseUp( event: TSDL_EVENT );
+var
+ Point : TPoint;
+begin
+ FDragging := false;
+ if Assigned( FOnMouseUp ) then
+ begin
+ Point.x := event.button.x;
+ Point.y := event.button.y;
+ FOnMouseUp( event.button.button, SDL_GetModState, Point );
+ end;
+end;
+
+procedure TSDLMouse.DoMouseWheelScroll( event: TSDL_EVENT );
+var
+ Point : TPoint;
+begin
+ if Assigned( FOnMouseWheel ) then
+ begin
+ Point.x := event.button.x;
+ Point.y := event.button.y;
+ if ( event.button.button = SDL_BUTTON_WHEELUP ) then
+ FOnMouseWheel( SDL_BUTTON_WHEELUP, SDL_GetModState, Point )
+ else
+ FOnMouseWheel( SDL_BUTTON_WHEELDOWN, SDL_GetModState, Point );
+ end;
+end;
+
+function TSDLMouse.GetMousePosition: TPoint;
+begin
+ SDL_PumpEvents;
+
+ SDL_GetMouseState( FMousePos.X, FMousePos.Y );
+ Result := FMousePos;
+end;
+
+procedure TSDLMouse.HideCursor;
+begin
+ SDL_ShowCursor( SDL_DISABLE );
+end;
+
+function TSDLMouse.MouseIsDown(Button: Integer): Boolean;
+begin
+ SDL_PumpEvents;
+
+ Result := ( SDL_GetMouseState( FMousePos.X, FMousePos.Y ) and SDL_BUTTON( Button ) = 0 );
+end;
+
+function TSDLMouse.MouseIsUp(Button: Integer): Boolean;
+begin
+ SDL_PumpEvents;
+
+ Result := not ( SDL_GetMouseState( FMousePos.X, FMousePos.Y ) and SDL_BUTTON( Button ) = 0 );
+end;
+
+procedure TSDLMouse.SetCursor(data, mask: PUInt8; w, h, hot_x, hot_y: Integer);
+begin
+ if FCursor <> nil then
+ SDL_FreeCursor( FCursor );
+ // create the cursor
+ FCursor := SDL_CreateCursor( data, mask, w, h, hot_x, hot_y );
+
+ // set the cursor
+ SDL_SetCursor( FCursor );
+end;
+
+procedure TSDLMouse.SetMousePosition(const Value: TPoint);
+begin
+ SDL_WarpMouse( Value.x, Value.y );
+end;
+
+procedure TSDLMouse.ShowCursor;
+begin
+ SDL_ShowCursor( SDL_ENABLE );
+end;
+
+function TSDLMouse.UpdateInput(event: TSDL_EVENT): Boolean;
+begin
+ result := false;
+ if ( FEnabled ) then
+ begin
+ case event.type_ of
+ SDL_MOUSEMOTION :
+ begin
+ // handle Mouse Move
+ DoMouseMove( event );
+ end;
+
+ SDL_MOUSEBUTTONDOWN :
+ begin
+ // handle Mouse Down
+ if ( event.button.button = SDL_BUTTON_WHEELUP )
+ or ( event.button.button = SDL_BUTTON_WHEELDOWN ) then
+ DoMouseWheelScroll( event )
+ else
+ DoMouseDown( event );
+ end;
+
+ SDL_MOUSEBUTTONUP :
+ begin
+ // handle Mouse Up
+ if ( event.button.button = SDL_BUTTON_WHEELUP )
+ or ( event.button.button = SDL_BUTTON_WHEELDOWN ) then
+ DoMouseWheelScroll( event )
+ else
+ DoMouseUp( event );
+ end;
+ end;
+ end;
+end;
+
+{ TSDLInputManager }
+constructor TSDLInputManager.Create(InitInputs: TSDLInputTypes);
+begin
+ inherited Create;
+ if itJoystick in InitInputs then
+ FJoystick := TSDLJoysticks.Create;
+
+ if itKeyBoard in InitInputs then
+ FKeyBoard := TSDLKeyBoard.Create;
+
+ if itMouse in InitInputs then
+ FMouse := TSDLMouse.Create;
+end;
+
+destructor TSDLInputManager.Destroy;
+begin
+ if FJoystick <> nil then
+ FreeAndNil( FJoystick );
+ if FKeyBoard <> nil then
+ FreeAndNil( FKeyBoard );
+ if FMouse <> nil then
+ FreeAndNil( FMouse );
+ inherited;
+end;
+
+procedure TSDLInputManager.Disable( InitInputs : TSDLInputTypes; JoyStickNumber : Integer );
+begin
+ if itJoystick in InitInputs then
+ FJoystick.JoySticks[ JoyStickNumber ].Enabled := false;
+
+ if itKeyBoard in InitInputs then
+ FKeyBoard.Enabled := false;
+
+ if itMouse in InitInputs then
+ FMouse.Enabled := false;
+end;
+
+procedure TSDLInputManager.Enable( InitInputs: TSDLInputTypes; JoyStickNumber: Integer );
+begin
+ if itJoystick in InitInputs then
+ FJoystick.JoySticks[ JoyStickNumber ].Enabled := true;
+
+ if itKeyBoard in InitInputs then
+ FKeyBoard.Enabled := true;
+
+ if itMouse in InitInputs then
+ FMouse.Enabled := true;
+end;
+
+function TSDLInputManager.UpdateInputs( event: TSDL_EVENT ): Boolean;
+begin
+ Result := false;
+ if ( FJoystick <> nil ) then
+ Result := FJoystick.UpdateInput( event );
+ if ( FKeyBoard <> nil ) then
+ Result := FKeyBoard.UpdateInput( event );
+ if ( FMouse <> nil ) then
+ Result := FMouse.UpdateInput( event );
+end;
+
+{ TSDLJoyStick }
+procedure TSDLJoyStick.Close;
+begin
+ SDL_JoystickClose( @FJoystick );
+end;
+
+constructor TSDLJoyStick.Create( Index : Integer );
+begin
+ inherited Create;
+ FJoystick := nil;
+ FJoystickIndex := Index;
+end;
+
+destructor TSDLJoyStick.Destroy;
+begin
+ if FJoystick <> nil then
+ Close;
+ inherited;
+end;
+
+procedure TSDLJoyStick.DoAxisMove(Event: TSDL_Event);
+begin
+ if Assigned( FJoyAxisMoveEvent ) then
+ begin
+ FJoyAxisMoveEvent( Event.jaxis.which, Event.jaxis.axis, Event.jaxis.value );
+ end
+end;
+
+procedure TSDLJoyStick.DoBallMove(Event: TSDL_Event);
+var
+ BallPoint : TPoint;
+begin
+ if Assigned( FJoyBallMoveEvent ) then
+ begin
+ BallPoint.x := Event.jball.xrel;
+ BallPoint.y := Event.jball.yrel;
+ FJoyBallMoveEvent( Event.jball.which, Event.jball.ball, BallPoint );
+ end;
+end;
+
+procedure TSDLJoyStick.DoButtonDown(Event: TSDL_Event);
+begin
+ if Assigned( FJoyButtonDownEvent ) then
+ begin
+ if ( Event.jbutton.state = SDL_PRESSED ) then
+ FJoyButtonDownEvent( Event.jbutton.which, Event.jbutton.button, Event.jbutton.state );
+ end;
+end;
+
+procedure TSDLJoyStick.DoButtonUp(Event: TSDL_Event);
+begin
+ if Assigned( FJoyButtonUpEvent ) then
+ begin
+ if ( Event.jbutton.state = SDL_RELEASED ) then
+ FJoyButtonUpEvent( Event.jbutton.which, Event.jbutton.button, Event.jbutton.state );
+ end
+end;
+
+procedure TSDLJoyStick.DoHatMove(Event: TSDL_Event);
+begin
+ if Assigned( FJoyHatMoveEvent ) then
+ begin
+ FJoyHatMoveEvent( Event.jhat.which, Event.jhat.hat, Event.jhat.value );
+ end;
+end;
+
+function TSDLJoyStick.GetName: PChar;
+begin
+ result := FJoystick.name;
+end;
+
+function TSDLJoyStick.GetNumAxes: integer;
+begin
+ result := FJoystick.naxes;
+end;
+
+function TSDLJoyStick.GetNumBalls: integer;
+begin
+ result := FJoystick.nballs;
+end;
+
+function TSDLJoyStick.GetNumButtons: integer;
+begin
+ result := FJoystick.nbuttons;
+end;
+
+function TSDLJoyStick.GetNumHats: integer;
+begin
+ result := FJoystick.nhats;
+end;
+
+procedure TSDLJoyStick.Open;
+begin
+ FJoystick := SDL_JoyStickOpen( FJoystickIndex );
+end;
+
+function TSDLJoyStick.UpdateInput(Event: TSDL_EVENT): Boolean;
+begin
+ Result := false;
+
+ if ( FEnabled ) then
+ begin
+ case event.type_ of
+ SDL_JOYAXISMOTION :
+ begin
+ DoAxisMove( Event );
+ end;
+
+ SDL_JOYBALLMOTION :
+ begin
+ DoBallMove( Event );
+ end;
+
+ SDL_JOYHATMOTION :
+ begin
+ DoHatMove( Event );
+ end;
+
+ SDL_JOYBUTTONDOWN :
+ begin
+ DoButtonDown( Event );
+ end;
+
+ SDL_JOYBUTTONUP :
+ begin
+ DoButtonUp( Event );
+ end;
+ end;
+ end;
+end;
+
+end.
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlstreams.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlstreams.pas new file mode 100644 index 00000000..64009176 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlstreams.pas @@ -0,0 +1,216 @@ +unit sdlstreams;
+{
+ $Id: sdlstreams.pas,v 1.1 2004/02/05 00:08:20 savage Exp $
+
+}
+{******************************************************************}
+{ }
+{ SDL - Simple DirectMedia Layer }
+{ Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga }
+{ }
+{ Portions created by Chris Bruner are }
+{ Copyright (C) 2002 Chris Bruner. }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ not use this file except in compliance with the License. You may }
+{ obtain a copy of the License at }
+{ http://www.mozilla.org/NPL/NPL-1_1Final.html }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ Shows how to use OpenGL to do 2D and 3D with the SDL libraries }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ SDL runtime libary somewhere in your path }
+{ The Latest SDL runtime can be found on http://www.libsdl.org }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ January 11 2002 - CB : Software embraced and extended by }
+{ Chris Bruner of Crystal Software }
+{ (Canada) Inc. }
+{ }
+{ February 11 2002 - DL : Added FreePascal support as suggested }
+{ by "QuePasha Pepe" <mrkroket@hotmail.com> }
+{ }
+{******************************************************************}
+{
+ $Log: sdlstreams.pas,v $
+ Revision 1.1 2004/02/05 00:08:20 savage
+ Module 1.0 release
+
+
+}
+
+{$i jedi-sdl.inc}
+
+interface
+
+uses
+ Classes,
+ SysUtils,
+ sdl,
+ sdlutils;
+
+{$IFDEF FPC}
+type
+ EinvalidContainer=class(Exception);
+ {$ENDIF}
+
+function LoadSDLBMPFromStream( Stream : TStream ) : PSDL_Surface;
+procedure SaveSDLBMPToStream( SDL_Surface : PSDL_Surface; stream : TStream );
+function SDL_Swap16( D : UInt16 ) : Uint16;
+function SDL_Swap32( D : UInt32 ) : Uint32;
+function SDLStreamSetup( stream : TStream ) : PSDL_RWops;
+// this only closes the SDL_RWops part of the stream, not the stream itself
+procedure SDLStreamCloseRWops( SDL_RWops : PSDL_RWops );
+
+implementation
+
+function SDL_Swap16( D : UInt16 ) : Uint16;
+begin
+ Result := ( D shl 8 ) or ( D shr 8 );
+end;
+
+function SDL_Swap32( D : UInt32 ) : Uint32;
+begin
+ Result := ( ( D shl 24 ) or ( ( D shl 8 ) and $00FF0000 ) or ( ( D shr 8 ) and $0000FF00 ) or ( D shr 24 ) );
+end;
+
+(*function SDL_Swap64(D : UInt64) : Uint64;
+var hi,lo : Uint32;
+begin
+ // Separate into high and low 32-bit resultues and swap them
+ lo := Uint32(D and $0FFFFFFFF); // bloody pascal is too tight in it's type checking!
+ D := D shr 32;
+ hi = Uint32((D and $FFFFFFFF));
+ result = SDL_Swap32(lo);
+ result := result shl 32;
+ result := result or SDL_Swap32(hi);
+end;
+*)
+
+function SdlStreamSeek( context : PSDL_RWops; offset : Integer; whence : Integer ) : integer; cdecl;
+var
+ stream : TStream;
+ origin : Word;
+begin
+ stream := TStream( context.unknown );
+ if ( stream = nil ) then
+ raise EInvalidContainer.Create( 'SDLStreamSeek on nil' );
+ case whence of
+ 0 : origin := soFromBeginning; // Offset is from the beginning of the resource. Seek moves to the position Offset. Offset must be >= 0.
+ 1 : origin := soFromCurrent; // Offset is from the current position in the resource. Seek moves to Position + Offset.
+ 2 : origin := soFromEnd;
+ else
+ origin := soFromBeginning; // just in case
+ end;
+ Result := stream.Seek( offset, origin );
+end;
+
+function SDLStreamWrite( context : PSDL_RWops; Ptr : Pointer;
+ size : Integer; num : Integer ) : Integer; cdecl;
+var
+ stream : TStream;
+begin
+ stream := TStream( context.unknown );
+ if ( stream = nil ) then
+ raise EInvalidContainer.Create( 'SDLStreamWrite on nil' );
+ try
+ Result := stream.Write( Ptr^, Size * num ) div size;
+ except
+ Result := -1;
+ end;
+end;
+
+function SdlStreamRead( context : PSDL_RWops; Ptr : Pointer; size : Integer; maxnum
+ : Integer ) : Integer; cdecl;
+var
+ stream : TStream;
+begin
+ stream := TStream( context.unknown );
+ if ( stream = nil ) then
+ raise EInvalidContainer.Create( 'SDLStreamRead on nil' );
+ try
+ Result := stream.read( Ptr^, Size * maxnum ) div size;
+ except
+ Result := -1;
+ end;
+end;
+
+function SDLStreamClose( context : PSDL_RWops ) : Integer; cdecl;
+var
+ stream : TStream;
+begin
+ stream := TStream( context.unknown );
+ if ( stream = nil ) then
+ raise EInvalidContainer.Create( 'SDLStreamClose on nil' );
+ stream.Free;
+ Result := 1;
+end;
+
+function SDLStreamSetup( stream : TStream ) : PSDL_RWops;
+begin
+ result := SDL_AllocRW;
+ if ( result = nil ) then
+ raise EInvalidContainer.Create( 'could not create SDLStream on nil' );
+ result.unknown := TUnknown( stream );
+ result.seek := SDLStreamSeek;
+ result.read := SDLStreamRead;
+ result.write := SDLStreamWrite;
+ result.close := SDLStreamClose;
+ Result.type_ := 2; // TUnknown
+end;
+
+// this only closes the SDL part of the stream, not the context
+
+procedure SDLStreamCloseRWops( SDL_RWops : PSDL_RWops );
+begin
+ SDL_FreeRW( SDL_RWops );
+end;
+
+function LoadSDLBMPFromStream( stream : TStream ) : PSDL_Surface;
+var
+ SDL_RWops : PSDL_RWops;
+begin
+ SDL_RWops := SDLStreamSetup( stream );
+ result := SDL_LoadBMP_RW( SDL_RWops, 0 );
+ SDLStreamCloseRWops( SDL_RWops );
+end;
+
+procedure SaveSDLBMPToStream( SDL_Surface : PSDL_Surface; stream : TStream );
+var
+ SDL_RWops : PSDL_RWops;
+begin
+ SDL_RWops := SDLStreamSetup( stream );
+ SDL_SaveBMP_RW( SDL_Surface, SDL_RWops, 0 );
+ SDLStreamCloseRWops( SDL_RWops );
+end;
+
+end.
+
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlticks.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlticks.pas new file mode 100644 index 00000000..8e00dd6f --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlticks.pas @@ -0,0 +1,197 @@ +unit sdlticks;
+{
+ $Id: sdlticks.pas,v 1.2 2006/11/08 08:22:48 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer }
+{ SDL GetTicks Class Wrapper }
+{ }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Dominique Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Portions created by Dominique Louis are }
+{ Copyright (C) 2004 - 2100 Dominique Louis. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ Dominique Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ SDL Window Wrapper }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ SDL.dll on Windows platforms }
+{ libSDL-1.1.so.0 on Linux platform }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ }
+{ September 23 2004 - DL : Initial Creation }
+{
+ $Log: sdlticks.pas,v $
+ Revision 1.2 2006/11/08 08:22:48 savage
+ updates tp sdlgameinterface and sdlticks functions.
+
+ Revision 1.1 2004/09/30 22:35:47 savage
+ Changes, enhancements and additions as required to get SoAoS working.
+
+}
+{******************************************************************************}
+
+interface
+
+uses
+ sdl;
+
+type
+ TSDLTicks = class
+ private
+ FStartTime : UInt32;
+ FTicksPerSecond : UInt32;
+ FElapsedLastTime : UInt32;
+ FFPSLastTime : UInt32;
+ FLockFPSLastTime : UInt32;
+ public
+ constructor Create;
+ destructor Destroy; override; // destructor
+
+ {*****************************************************************************
+ Init
+ If the hi-res timer is present, the tick rate is stored and the function
+ returns true. Otherwise, the function returns false, and the timer should
+ not be used.
+ *****************************************************************************}
+ function Init : boolean;
+
+ {***************************************************************************
+ GetGetElapsedSeconds
+ Returns the Elapsed time, since the function was last called.
+ ***************************************************************************}
+ function GetElapsedSeconds : Single;
+
+ {***************************************************************************
+ GetFPS
+ Returns the average frames per second.
+ If this is not called every frame, the client should track the number
+ of frames itself, and reset the value after this is called.
+ ***************************************************************************}
+ function GetFPS : single;
+
+ {***************************************************************************
+ LockFPS
+ Used to lock the frame rate to a set amount. This will block until enough
+ time has passed to ensure that the fps won't go over the requested amount.
+ Note that this can only keep the fps from going above the specified level;
+ it can still drop below it. It is assumed that if used, this function will
+ be called every frame. The value returned is the instantaneous fps, which
+ will be less than or equal to the targetFPS.
+ ***************************************************************************}
+ procedure LockFPS( targetFPS : Byte );
+ end;
+
+implementation
+
+{ TSDLTicks }
+constructor TSDLTicks.Create;
+begin
+ inherited;
+ FTicksPerSecond := 1000;
+end;
+
+destructor TSDLTicks.Destroy;
+begin
+ inherited;
+end;
+
+function TSDLTicks.GetElapsedSeconds : Single;
+var
+ currentTime : Cardinal;
+begin
+ currentTime := SDL_GetTicks;
+
+ result := ( currentTime - FElapsedLastTime ) / FTicksPerSecond;
+
+ // reset the timer
+ FElapsedLastTime := currentTime;
+end;
+
+function TSDLTicks.GetFPS : Single;
+var
+ currentTime, FrameTime : UInt32;
+ fps : single;
+begin
+ currentTime := SDL_GetTicks;
+
+ FrameTime := ( currentTime - FFPSLastTime );
+
+ if FrameTime = 0 then
+ FrameTime := 1;
+
+ fps := FTicksPerSecond / FrameTime;
+
+ // reset the timer
+ FFPSLastTime := currentTime;
+ result := fps;
+end;
+
+function TSDLTicks.Init : boolean;
+begin
+ FStartTime := SDL_GetTicks;
+ FElapsedLastTime := FStartTime;
+ FFPSLastTime := FStartTime;
+ FLockFPSLastTime := FStartTime;
+ result := true;
+end;
+
+procedure TSDLTicks.LockFPS( targetFPS : Byte );
+var
+ currentTime : UInt32;
+ targetTime : single;
+begin
+ if ( targetFPS = 0 ) then
+ targetFPS := 1;
+
+ targetTime := FTicksPerSecond / targetFPS;
+
+ // delay to maintain a constant frame rate
+ repeat
+ currentTime := SDL_GetTicks;
+ until ( ( currentTime - FLockFPSLastTime ) > targetTime );
+
+ // reset the timer
+ FLockFPSLastTime := currentTime;
+end;
+
+end.
+
+
\ No newline at end of file diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlutils.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlutils.pas new file mode 100644 index 00000000..b15fa9ba --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlutils.pas @@ -0,0 +1,4361 @@ +unit sdlutils;
+{
+ $Id: sdlutils.pas,v 1.5 2006/11/19 18:56:44 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ Borland Delphi SDL - Simple DirectMedia Layer }
+{ SDL Utility functions }
+{ }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Tom Jones <tigertomjones@gmx.de> }
+{ }
+{ Portions created by Tom Jones are }
+{ Copyright (C) 2000 - 2001 Tom Jones. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ Dominique Louis <Dominique@SavageSoftware.com.au> }
+{ Róbert Kisnémeth <mikrobi@freemail.hu> }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ Helper functions... }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ SDL.dll on Windows platforms }
+{ libSDL-1.1.so.0 on Linux platform }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ 2000 - TJ : Initial creation }
+{ }
+{ July 13 2001 - DL : Added PutPixel and GetPixel routines. }
+{ }
+{ Sept 14 2001 - RK : Added flipping routines. }
+{ }
+{ Sept 19 2001 - RK : Added PutPixel & line drawing & blitting with ADD }
+{ effect. Fixed a bug in SDL_PutPixel & SDL_GetPixel }
+{ Added PSDLRect() }
+{ Sept 22 2001 - DL : Removed need for Windows.pas by defining types here}
+{ Also removed by poor attempt or a dialog box }
+{ }
+{ Sept 25 2001 - RK : Added PixelTest, NewPutPixel, SubPixel, SubLine, }
+{ SubSurface, MonoSurface & TexturedSurface }
+{ }
+{ Sept 26 2001 - DL : Made change so that it refers to native Pascal }
+{ types rather that Windows types. This makes it more}
+{ portable to Linix. }
+{ }
+{ Sept 27 2001 - RK : SDLUtils now can be compiled with FreePascal }
+{ }
+{ Oct 27 2001 - JF : Added ScrollY function }
+{ }
+{ Jan 21 2002 - RK : Added SDL_ZoomSurface and SDL_WarpSurface }
+{ }
+{ Mar 28 2002 - JF : Added SDL_RotateSurface }
+{ }
+{ May 13 2002 - RK : Improved SDL_FillRectAdd & SDL_FillRectSub }
+{ }
+{ May 27 2002 - YS : GradientFillRect function }
+{ }
+{ May 30 2002 - RK : Added SDL_2xBlit, SDL_Scanline2xBlit }
+{ & SDL_50Scanline2xBlit }
+{ }
+{ June 12 2002 - RK : Added SDL_PixelTestSurfaceVsRect }
+{ }
+{ June 12 2002 - JF : Updated SDL_PixelTestSurfaceVsRect }
+{ }
+{ November 9 2002 - JF : Added Jason's boolean Surface functions }
+{ }
+{ December 10 2002 - DE : Added Dean's SDL_ClipLine function }
+{ }
+{ April 26 2003 - SS : Incorporated JF's changes to SDL_ClipLine }
+{ Fixed SDL_ClipLine bug for non-zero cliprect x, y }
+{ Added overloaded SDL_DrawLine for dashed lines }
+{ }
+{******************************************************************************}
+{
+ $Log: sdlutils.pas,v $
+ Revision 1.5 2006/11/19 18:56:44 savage
+ Removed Hints and Warnings.
+
+ Revision 1.4 2004/06/02 19:38:53 savage
+ Changes to SDL_GradientFillRect as suggested by
+ Ángel Eduardo García Hernández. Many thanks.
+
+ Revision 1.3 2004/05/29 23:11:54 savage
+ Changes to SDL_ScaleSurfaceRect as suggested by
+ Ángel Eduardo García Hernández to fix a colour issue with the function. Many thanks.
+
+ Revision 1.2 2004/02/14 00:23:39 savage
+ As UNIX is defined in jedi-sdl.inc this will be used to check linux compatability as well. Units have been changed to reflect this change.
+
+ Revision 1.1 2004/02/05 00:08:20 savage
+ Module 1.0 release
+
+
+}
+
+interface
+
+{$I jedi-sdl.inc}
+
+uses
+{$IFDEF UNIX}
+ Types,
+ Xlib,
+{$ENDIF}
+ SysUtils,
+ sdl;
+
+type
+ TGradientStyle = ( gsHorizontal, gsVertical );
+
+// Pixel procedures
+function SDL_PixelTest( SrcSurface1 : PSDL_Surface; SrcRect1 : PSDL_Rect; SrcSurface2 :
+ PSDL_Surface; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) : Boolean;
+
+function SDL_GetPixel( SrcSurface : PSDL_Surface; x : integer; y : integer ) : Uint32;
+
+procedure SDL_PutPixel( DstSurface : PSDL_Surface; x : integer; y : integer; pixel :
+ Uint32 );
+
+procedure SDL_AddPixel( DstSurface : PSDL_Surface; x : cardinal; y : cardinal; Color :
+ cardinal );
+
+procedure SDL_SubPixel( DstSurface : PSDL_Surface; x : cardinal; y : cardinal; Color :
+ cardinal );
+
+// Line procedures
+procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal ); overload;
+
+procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal; DashLength, DashSpace : byte ); overload;
+
+procedure SDL_AddLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal );
+
+procedure SDL_SubLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal );
+
+// Surface procedures
+procedure SDL_AddSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+
+procedure SDL_SubSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+
+procedure SDL_MonoSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect; Color : cardinal );
+
+procedure SDL_TexturedSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect; Texture : PSDL_Surface;
+ TextureRect : PSDL_Rect );
+
+procedure SDL_ZoomSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; DstRect : PSDL_Rect );
+
+procedure SDL_WarpSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; UL, UR, LR, LL : PPoint );
+
+// Flip procedures
+procedure SDL_FlipRectH( DstSurface : PSDL_Surface; Rect : PSDL_Rect );
+
+procedure SDL_FlipRectV( DstSurface : PSDL_Surface; Rect : PSDL_Rect );
+
+function PSDLRect( aLeft, aTop, aWidth, aHeight : integer ) : PSDL_Rect;
+
+function SDLRect( aLeft, aTop, aWidth, aHeight : integer ) : TSDL_Rect; overload;
+
+function SDLRect( aRect : TRect ) : TSDL_Rect; overload;
+
+function SDL_ScaleSurfaceRect( SrcSurface : PSDL_Surface; SrcX1, SrcY1, SrcW, SrcH,
+ Width, Height : integer ) : PSDL_Surface;
+
+procedure SDL_ScrollY( DstSurface : PSDL_Surface; DifY : integer );
+
+procedure SDL_ScrollX( DstSurface : PSDL_Surface; DifX : integer );
+
+procedure SDL_RotateDeg( DstSurface, SrcSurface : PSDL_Surface; SrcRect :
+ PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Integer );
+
+procedure SDL_RotateRad( DstSurface, SrcSurface : PSDL_Surface; SrcRect :
+ PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Single );
+
+function ValidateSurfaceRect( DstSurface : PSDL_Surface; dstrect : PSDL_Rect ) : TSDL_Rect;
+
+// Fill Rect routine
+procedure SDL_FillRectAdd( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 );
+
+procedure SDL_FillRectSub( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 );
+
+procedure SDL_GradientFillRect( DstSurface : PSDL_Surface; const Rect : PSDL_Rect; const StartColor, EndColor : TSDL_Color; const Style : TGradientStyle );
+
+// NOTE for All SDL_2xblit... function : the dest surface must be 2x of the source surface!
+procedure SDL_2xBlit( Src, Dest : PSDL_Surface );
+
+procedure SDL_Scanline2xBlit( Src, Dest : PSDL_Surface );
+
+procedure SDL_50Scanline2xBlit( Src, Dest : PSDL_Surface );
+
+//
+function SDL_PixelTestSurfaceVsRect( SrcSurface1 : PSDL_Surface; SrcRect1 :
+ PSDL_Rect; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) :
+ boolean;
+
+// Jason's boolean Surface functions
+procedure SDL_ORSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+
+procedure SDL_ANDSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+
+
+procedure SDL_GTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+
+procedure SDL_LTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+
+function SDL_ClipLine( var x1, y1, x2, y2 : Integer; ClipRect : PSDL_Rect ) : boolean;
+
+implementation
+
+uses
+ Math;
+
+function SDL_PixelTest( SrcSurface1 : PSDL_Surface; SrcRect1 : PSDL_Rect; SrcSurface2 :
+ PSDL_Surface; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) : boolean;
+var
+ Src_Rect1, Src_Rect2 : TSDL_Rect;
+ right1, bottom1 : integer;
+ right2, bottom2 : integer;
+ Scan1Start, Scan2Start, ScanWidth, ScanHeight : cardinal;
+ Mod1, Mod2 : cardinal;
+ Addr1, Addr2 : cardinal;
+ BPP : cardinal;
+ Pitch1, Pitch2 : cardinal;
+ TransparentColor1, TransparentColor2 : cardinal;
+ tx, ty : cardinal;
+ StartTick : cardinal;
+ Color1, Color2 : cardinal;
+begin
+ Result := false;
+ if SrcRect1 = nil then
+ begin
+ with Src_Rect1 do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface1.w;
+ h := SrcSurface1.h;
+ end;
+ end
+ else
+ Src_Rect1 := SrcRect1^;
+ if SrcRect2 = nil then
+ begin
+ with Src_Rect2 do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface2.w;
+ h := SrcSurface2.h;
+ end;
+ end
+ else
+ Src_Rect2 := SrcRect2^;
+ with Src_Rect1 do
+ begin
+ Right1 := Left1 + w;
+ Bottom1 := Top1 + h;
+ end;
+ with Src_Rect2 do
+ begin
+ Right2 := Left2 + w;
+ Bottom2 := Top2 + h;
+ end;
+ if ( Left1 >= Right2 ) or ( Right1 <= Left2 ) or ( Top1 >= Bottom2 ) or ( Bottom1 <=
+ Top2 ) then
+ exit;
+ if Left1 <= Left2 then
+ begin
+ // 1. left, 2. right
+ Scan1Start := Src_Rect1.x + Left2 - Left1;
+ Scan2Start := Src_Rect2.x;
+ ScanWidth := Right1 - Left2;
+ with Src_Rect2 do
+ if ScanWidth > w then
+ ScanWidth := w;
+ end
+ else
+ begin
+ // 1. right, 2. left
+ Scan1Start := Src_Rect1.x;
+ Scan2Start := Src_Rect2.x + Left1 - Left2;
+ ScanWidth := Right2 - Left1;
+ with Src_Rect1 do
+ if ScanWidth > w then
+ ScanWidth := w;
+ end;
+ with SrcSurface1^ do
+ begin
+ Pitch1 := Pitch;
+ Addr1 := cardinal( Pixels );
+ inc( Addr1, Pitch1 * UInt32( Src_Rect1.y ) );
+ with format^ do
+ begin
+ BPP := BytesPerPixel;
+ TransparentColor1 := colorkey;
+ end;
+ end;
+ with SrcSurface2^ do
+ begin
+ TransparentColor2 := format.colorkey;
+ Pitch2 := Pitch;
+ Addr2 := cardinal( Pixels );
+ inc( Addr2, Pitch2 * UInt32( Src_Rect2.y ) );
+ end;
+ Mod1 := Pitch1 - ( ScanWidth * BPP );
+ Mod2 := Pitch2 - ( ScanWidth * BPP );
+ inc( Addr1, BPP * Scan1Start );
+ inc( Addr2, BPP * Scan2Start );
+ if Top1 <= Top2 then
+ begin
+ // 1. up, 2. down
+ ScanHeight := Bottom1 - Top2;
+ if ScanHeight > Src_Rect2.h then
+ ScanHeight := Src_Rect2.h;
+ inc( Addr1, Pitch1 * UInt32( Top2 - Top1 ) );
+ end
+ else
+ begin
+ // 1. down, 2. up
+ ScanHeight := Bottom2 - Top1;
+ if ScanHeight > Src_Rect1.h then
+ ScanHeight := Src_Rect1.h;
+ inc( Addr2, Pitch2 * UInt32( Top1 - Top2 ) );
+ end;
+ case BPP of
+ 1 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ if ( PByte( Addr1 )^ <> TransparentColor1 ) and ( PByte( Addr2 )^ <>
+ TransparentColor2 ) then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1 );
+ inc( Addr2 );
+ end;
+ inc( Addr1, Mod1 );
+ inc( Addr2, Mod2 );
+ end;
+ 2 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ if ( PWord( Addr1 )^ <> TransparentColor1 ) and ( PWord( Addr2 )^ <>
+ TransparentColor2 ) then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1, 2 );
+ inc( Addr2, 2 );
+ end;
+ inc( Addr1, Mod1 );
+ inc( Addr2, Mod2 );
+ end;
+ 3 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ Color1 := PLongWord( Addr1 )^ and $00FFFFFF;
+ Color2 := PLongWord( Addr2 )^ and $00FFFFFF;
+ if ( Color1 <> TransparentColor1 ) and ( Color2 <> TransparentColor2 )
+ then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1, 3 );
+ inc( Addr2, 3 );
+ end;
+ inc( Addr1, Mod1 );
+ inc( Addr2, Mod2 );
+ end;
+ 4 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ if ( PLongWord( Addr1 )^ <> TransparentColor1 ) and ( PLongWord( Addr2 )^ <>
+ TransparentColor2 ) then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1, 4 );
+ inc( Addr2, 4 );
+ end;
+ inc( Addr1, Mod1 );
+ inc( Addr2, Mod2 );
+ end;
+ end;
+end;
+
+procedure SDL_AddPixel( DstSurface : PSDL_Surface; x : cardinal; y : cardinal; Color :
+ cardinal );
+var
+ SrcColor : cardinal;
+ Addr : cardinal;
+ R, G, B : cardinal;
+begin
+ if Color = 0 then
+ exit;
+ with DstSurface^ do
+ begin
+ Addr := cardinal( Pixels ) + y * Pitch + x * format.BytesPerPixel;
+ SrcColor := PUInt32( Addr )^;
+ case format.BitsPerPixel of
+ 8 :
+ begin
+ R := SrcColor and $E0 + Color and $E0;
+ G := SrcColor and $1C + Color and $1C;
+ B := SrcColor and $03 + Color and $03;
+ if R > $E0 then
+ R := $E0;
+ if G > $1C then
+ G := $1C;
+ if B > $03 then
+ B := $03;
+ PUInt8( Addr )^ := R or G or B;
+ end;
+ 15 :
+ begin
+ R := SrcColor and $7C00 + Color and $7C00;
+ G := SrcColor and $03E0 + Color and $03E0;
+ B := SrcColor and $001F + Color and $001F;
+ if R > $7C00 then
+ R := $7C00;
+ if G > $03E0 then
+ G := $03E0;
+ if B > $001F then
+ B := $001F;
+ PUInt16( Addr )^ := R or G or B;
+ end;
+ 16 :
+ begin
+ R := SrcColor and $F800 + Color and $F800;
+ G := SrcColor and $07C0 + Color and $07C0;
+ B := SrcColor and $001F + Color and $001F;
+ if R > $F800 then
+ R := $F800;
+ if G > $07C0 then
+ G := $07C0;
+ if B > $001F then
+ B := $001F;
+ PUInt16( Addr )^ := R or G or B;
+ end;
+ 24 :
+ begin
+ R := SrcColor and $00FF0000 + Color and $00FF0000;
+ G := SrcColor and $0000FF00 + Color and $0000FF00;
+ B := SrcColor and $000000FF + Color and $000000FF;
+ if R > $FF0000 then
+ R := $FF0000;
+ if G > $00FF00 then
+ G := $00FF00;
+ if B > $0000FF then
+ B := $0000FF;
+ PUInt32( Addr )^ := SrcColor and $FF000000 or R or G or B;
+ end;
+ 32 :
+ begin
+ R := SrcColor and $00FF0000 + Color and $00FF0000;
+ G := SrcColor and $0000FF00 + Color and $0000FF00;
+ B := SrcColor and $000000FF + Color and $000000FF;
+ if R > $FF0000 then
+ R := $FF0000;
+ if G > $00FF00 then
+ G := $00FF00;
+ if B > $0000FF then
+ B := $0000FF;
+ PUInt32( Addr )^ := R or G or B;
+ end;
+ end;
+ end;
+end;
+
+procedure SDL_SubPixel( DstSurface : PSDL_Surface; x : cardinal; y : cardinal; Color :
+ cardinal );
+var
+ SrcColor : cardinal;
+ Addr : cardinal;
+ R, G, B : cardinal;
+begin
+ if Color = 0 then
+ exit;
+ with DstSurface^ do
+ begin
+ Addr := cardinal( Pixels ) + y * Pitch + x * format.BytesPerPixel;
+ SrcColor := PUInt32( Addr )^;
+ case format.BitsPerPixel of
+ 8 :
+ begin
+ R := SrcColor and $E0 - Color and $E0;
+ G := SrcColor and $1C - Color and $1C;
+ B := SrcColor and $03 - Color and $03;
+ if R > $E0 then
+ R := 0;
+ if G > $1C then
+ G := 0;
+ if B > $03 then
+ B := 0;
+ PUInt8( Addr )^ := R or G or B;
+ end;
+ 15 :
+ begin
+ R := SrcColor and $7C00 - Color and $7C00;
+ G := SrcColor and $03E0 - Color and $03E0;
+ B := SrcColor and $001F - Color and $001F;
+ if R > $7C00 then
+ R := 0;
+ if G > $03E0 then
+ G := 0;
+ if B > $001F then
+ B := 0;
+ PUInt16( Addr )^ := R or G or B;
+ end;
+ 16 :
+ begin
+ R := SrcColor and $F800 - Color and $F800;
+ G := SrcColor and $07C0 - Color and $07C0;
+ B := SrcColor and $001F - Color and $001F;
+ if R > $F800 then
+ R := 0;
+ if G > $07C0 then
+ G := 0;
+ if B > $001F then
+ B := 0;
+ PUInt16( Addr )^ := R or G or B;
+ end;
+ 24 :
+ begin
+ R := SrcColor and $00FF0000 - Color and $00FF0000;
+ G := SrcColor and $0000FF00 - Color and $0000FF00;
+ B := SrcColor and $000000FF - Color and $000000FF;
+ if R > $FF0000 then
+ R := 0;
+ if G > $00FF00 then
+ G := 0;
+ if B > $0000FF then
+ B := 0;
+ PUInt32( Addr )^ := SrcColor and $FF000000 or R or G or B;
+ end;
+ 32 :
+ begin
+ R := SrcColor and $00FF0000 - Color and $00FF0000;
+ G := SrcColor and $0000FF00 - Color and $0000FF00;
+ B := SrcColor and $000000FF - Color and $000000FF;
+ if R > $FF0000 then
+ R := 0;
+ if G > $00FF00 then
+ G := 0;
+ if B > $0000FF then
+ B := 0;
+ PUInt32( Addr )^ := R or G or B;
+ end;
+ end;
+ end;
+end;
+// This procedure works on 8, 15, 16, 24 and 32 bits color depth surfaces.
+// In 8 bit color depth mode the procedure works with the default packed
+// palette (RRRGGGBB). It handles all clipping.
+
+procedure SDL_AddSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+var
+ R, G, B, Pixel1, Pixel2, TransparentColor : cardinal;
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DestSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DestSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ TransparentColor := Format.colorkey;
+ end;
+ with DestSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DestSurface );
+ WorkY := Src.h;
+ case bits of
+ 8 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt8( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt8( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+ R := Pixel1 and $E0 + Pixel2 and $E0;
+ G := Pixel1 and $1C + Pixel2 and $1C;
+ B := Pixel1 and $03 + Pixel2 and $03;
+ if R > $E0 then
+ R := $E0;
+ if G > $1C then
+ G := $1C;
+ if B > $03 then
+ B := $03;
+ PUInt8( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt8( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr );
+ inc( DestAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 15 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+ R := Pixel1 and $7C00 + Pixel2 and $7C00;
+ G := Pixel1 and $03E0 + Pixel2 and $03E0;
+ B := Pixel1 and $001F + Pixel2 and $001F;
+ if R > $7C00 then
+ R := $7C00;
+ if G > $03E0 then
+ G := $03E0;
+ if B > $001F then
+ B := $001F;
+ PUInt16( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt16( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 16 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+ R := Pixel1 and $F800 + Pixel2 and $F800;
+ G := Pixel1 and $07E0 + Pixel2 and $07E0;
+ B := Pixel1 and $001F + Pixel2 and $001F;
+ if R > $F800 then
+ R := $F800;
+ if G > $07E0 then
+ G := $07E0;
+ if B > $001F then
+ B := $001F;
+ PUInt16( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt16( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 24 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF;
+ if Pixel2 > 0 then
+ begin
+ R := Pixel1 and $FF0000 + Pixel2 and $FF0000;
+ G := Pixel1 and $00FF00 + Pixel2 and $00FF00;
+ B := Pixel1 and $0000FF + Pixel2 and $0000FF;
+ if R > $FF0000 then
+ R := $FF0000;
+ if G > $00FF00 then
+ G := $00FF00;
+ if B > $0000FF then
+ B := $0000FF;
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or ( R or G or B );
+ end
+ else
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or Pixel1;
+ end;
+ inc( SrcAddr, 3 );
+ inc( DestAddr, 3 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 32 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+ R := Pixel1 and $FF0000 + Pixel2 and $FF0000;
+ G := Pixel1 and $00FF00 + Pixel2 and $00FF00;
+ B := Pixel1 and $0000FF + Pixel2 and $0000FF;
+ if R > $FF0000 then
+ R := $FF0000;
+ if G > $00FF00 then
+ G := $00FF00;
+ if B > $0000FF then
+ B := $0000FF;
+ PUInt32( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt32( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 4 );
+ inc( DestAddr, 4 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DestSurface );
+end;
+
+procedure SDL_SubSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+var
+ R, G, B, Pixel1, Pixel2, TransparentColor : cardinal;
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr : cardinal;
+ _ebx, _esi, _edi, _esp : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DestSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DestSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ TransparentColor := Format.colorkey;
+ end;
+ with DestSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := DestSurface.Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DestSurface );
+ WorkY := Src.h;
+ case bits of
+ 8 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt8( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt8( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+ R := Pixel2 and $E0 - Pixel1 and $E0;
+ G := Pixel2 and $1C - Pixel1 and $1C;
+ B := Pixel2 and $03 - Pixel1 and $03;
+ if R > $E0 then
+ R := 0;
+ if G > $1C then
+ G := 0;
+ if B > $03 then
+ B := 0;
+ PUInt8( DestAddr )^ := R or G or B;
+ end;
+ end;
+ inc( SrcAddr );
+ inc( DestAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 15 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+ R := Pixel2 and $7C00 - Pixel1 and $7C00;
+ G := Pixel2 and $03E0 - Pixel1 and $03E0;
+ B := Pixel2 and $001F - Pixel1 and $001F;
+ if R > $7C00 then
+ R := 0;
+ if G > $03E0 then
+ G := 0;
+ if B > $001F then
+ B := 0;
+ PUInt16( DestAddr )^ := R or G or B;
+ end;
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 16 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+ R := Pixel2 and $F800 - Pixel1 and $F800;
+ G := Pixel2 and $07E0 - Pixel1 and $07E0;
+ B := Pixel2 and $001F - Pixel1 and $001F;
+ if R > $F800 then
+ R := 0;
+ if G > $07E0 then
+ G := 0;
+ if B > $001F then
+ B := 0;
+ PUInt16( DestAddr )^ := R or G or B;
+ end;
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 24 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF;
+ if Pixel2 > 0 then
+ begin
+ R := Pixel2 and $FF0000 - Pixel1 and $FF0000;
+ G := Pixel2 and $00FF00 - Pixel1 and $00FF00;
+ B := Pixel2 and $0000FF - Pixel1 and $0000FF;
+ if R > $FF0000 then
+ R := 0;
+ if G > $00FF00 then
+ G := 0;
+ if B > $0000FF then
+ B := 0;
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or ( R or G or B );
+ end;
+ end;
+ inc( SrcAddr, 3 );
+ inc( DestAddr, 3 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 32 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+ R := Pixel2 and $FF0000 - Pixel1 and $FF0000;
+ G := Pixel2 and $00FF00 - Pixel1 and $00FF00;
+ B := Pixel2 and $0000FF - Pixel1 and $0000FF;
+ if R > $FF0000 then
+ R := 0;
+ if G > $00FF00 then
+ G := 0;
+ if B > $0000FF then
+ B := 0;
+ PUInt32( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt32( DestAddr )^ := Pixel2;
+ end;
+ inc( SrcAddr, 4 );
+ inc( DestAddr, 4 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DestSurface );
+end;
+
+procedure SDL_MonoSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect; Color : cardinal );
+var
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr : cardinal;
+ _ebx, _esi, _edi, _esp : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ TransparentColor, SrcColor : cardinal;
+ BPP : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DestSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DestSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ TransparentColor := Format.colorkey;
+ end;
+ with DestSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ BPP := DestSurface.Format.BytesPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DestSurface );
+ WorkY := Src.h;
+ case BPP of
+ 1 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ SrcColor := PUInt8( SrcAddr )^;
+ if SrcColor <> TransparentColor then
+ PUInt8( DestAddr )^ := SrcColor;
+ inc( SrcAddr );
+ inc( DestAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 2 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ SrcColor := PUInt16( SrcAddr )^;
+ if SrcColor <> TransparentColor then
+ PUInt16( DestAddr )^ := SrcColor;
+ inc( SrcAddr );
+ inc( DestAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 3 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ SrcColor := PUInt32( SrcAddr )^ and $FFFFFF;
+ if SrcColor <> TransparentColor then
+ PUInt32( DestAddr )^ := ( PUInt32( DestAddr )^ and $FFFFFF ) or SrcColor;
+ inc( SrcAddr );
+ inc( DestAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 4 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ SrcColor := PUInt32( SrcAddr )^;
+ if SrcColor <> TransparentColor then
+ PUInt32( DestAddr )^ := SrcColor;
+ inc( SrcAddr );
+ inc( DestAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DestSurface );
+end;
+// TextureRect.w and TextureRect.h are not used.
+// The TextureSurface's size MUST larger than the drawing rectangle!!!
+
+procedure SDL_TexturedSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect; Texture : PSDL_Surface;
+ TextureRect : PSDL_Rect );
+var
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr, TextAddr : cardinal;
+ _ebx, _esi, _edi, _esp : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod, TextMod : cardinal;
+ SrcColor, TransparentColor, TextureColor : cardinal;
+ BPP : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DestSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DestSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ TransparentColor := format.colorkey;
+ end;
+ with DestSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ BPP := DestSurface.Format.BitsPerPixel;
+ end;
+ with Texture^ do
+ begin
+ TextAddr := cardinal( Pixels ) + UInt32( TextureRect.y ) * Pitch +
+ UInt32( TextureRect.x ) * Format.BytesPerPixel;
+ TextMod := Pitch - Src.w * Format.BytesPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DestSurface );
+ SDL_LockSurface( Texture );
+ WorkY := Src.h;
+ case BPP of
+ 1 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ SrcColor := PUInt8( SrcAddr )^;
+ if SrcColor <> TransparentColor then
+ PUInt8( DestAddr )^ := PUint8( TextAddr )^;
+ inc( SrcAddr );
+ inc( DestAddr );
+ inc( TextAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ inc( TextAddr, TextMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 2 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ SrcColor := PUInt16( SrcAddr )^;
+ if SrcColor <> TransparentColor then
+ PUInt16( DestAddr )^ := PUInt16( TextAddr )^;
+ inc( SrcAddr );
+ inc( DestAddr );
+ inc( TextAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ inc( TextAddr, TextMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 3 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ SrcColor := PUInt32( SrcAddr )^ and $FFFFFF;
+ if SrcColor <> TransparentColor then
+ PUInt32( DestAddr )^ := ( PUInt32( DestAddr )^ and $FFFFFF ) or ( PUInt32( TextAddr )^ and $FFFFFF );
+ inc( SrcAddr );
+ inc( DestAddr );
+ inc( TextAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ inc( TextAddr, TextMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 4 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ SrcColor := PUInt32( SrcAddr )^;
+ if SrcColor <> TransparentColor then
+ PUInt32( DestAddr )^ := PUInt32( TextAddr )^;
+ inc( SrcAddr );
+ inc( DestAddr );
+ inc( TextAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ inc( TextAddr, TextMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DestSurface );
+ SDL_UnlockSurface( Texture );
+end;
+
+procedure SDL_ZoomSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; DstRect : PSDL_Rect );
+var
+ xc, yc : cardinal;
+ rx, wx, ry, wy, ry16 : cardinal;
+ color : cardinal;
+ modx, mody : cardinal;
+begin
+ // Warning! No checks for surface pointers!!!
+ if srcrect = nil then
+ srcrect := @SrcSurface.clip_rect;
+ if dstrect = nil then
+ dstrect := @DstSurface.clip_rect;
+ if SDL_MustLock( SrcSurface ) then
+ SDL_LockSurface( SrcSurface );
+ if SDL_MustLock( DstSurface ) then
+ SDL_LockSurface( DstSurface );
+ modx := trunc( ( srcrect.w / dstrect.w ) * 65536 );
+ mody := trunc( ( srcrect.h / dstrect.h ) * 65536 );
+ //rx := srcrect.x * 65536;
+ ry := srcrect.y * 65536;
+ wy := dstrect.y;
+ for yc := 0 to dstrect.h - 1 do
+ begin
+ rx := srcrect.x * 65536;
+ wx := dstrect.x;
+ ry16 := ry shr 16;
+ for xc := 0 to dstrect.w - 1 do
+ begin
+ color := SDL_GetPixel( SrcSurface, rx shr 16, ry16 );
+ SDL_PutPixel( DstSurface, wx, wy, color );
+ rx := rx + modx;
+ inc( wx );
+ end;
+ ry := ry + mody;
+ inc( wy );
+ end;
+ if SDL_MustLock( SrcSurface ) then
+ SDL_UnlockSurface( SrcSurface );
+ if SDL_MustLock( DstSurface ) then
+ SDL_UnlockSurface( DstSurface );
+end;
+// Re-map a rectangular area into an area defined by four vertices
+// Converted from C to Pascal by KiCHY
+
+procedure SDL_WarpSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; UL, UR, LR, LL : PPoint );
+const
+ SHIFTS = 15; // Extend ints to limit round-off error (try 2 - 20)
+ THRESH = 1 shl SHIFTS; // Threshold for pixel size value
+ procedure CopySourceToDest( UL, UR, LR, LL : TPoint; x1, y1, x2, y2 : cardinal );
+ var
+ tm, lm, rm, bm, m : TPoint;
+ mx, my : cardinal;
+ cr : cardinal;
+ begin
+ // Does the destination area specify a single pixel?
+ if ( ( abs( ul.x - ur.x ) < THRESH ) and
+ ( abs( ul.x - lr.x ) < THRESH ) and
+ ( abs( ul.x - ll.x ) < THRESH ) and
+ ( abs( ul.y - ur.y ) < THRESH ) and
+ ( abs( ul.y - lr.y ) < THRESH ) and
+ ( abs( ul.y - ll.y ) < THRESH ) ) then
+ begin // Yes
+ cr := SDL_GetPixel( SrcSurface, ( x1 shr SHIFTS ), ( y1 shr SHIFTS ) );
+ SDL_PutPixel( DstSurface, ( ul.x shr SHIFTS ), ( ul.y shr SHIFTS ), cr );
+ end
+ else
+ begin // No
+ // Quarter the source and the destination, and then recurse
+ tm.x := ( ul.x + ur.x ) shr 1;
+ tm.y := ( ul.y + ur.y ) shr 1;
+ bm.x := ( ll.x + lr.x ) shr 1;
+ bm.y := ( ll.y + lr.y ) shr 1;
+ lm.x := ( ul.x + ll.x ) shr 1;
+ lm.y := ( ul.y + ll.y ) shr 1;
+ rm.x := ( ur.x + lr.x ) shr 1;
+ rm.y := ( ur.y + lr.y ) shr 1;
+ m.x := ( tm.x + bm.x ) shr 1;
+ m.y := ( tm.y + bm.y ) shr 1;
+ mx := ( x1 + x2 ) shr 1;
+ my := ( y1 + y2 ) shr 1;
+ CopySourceToDest( ul, tm, m, lm, x1, y1, mx, my );
+ CopySourceToDest( tm, ur, rm, m, mx, y1, x2, my );
+ CopySourceToDest( m, rm, lr, bm, mx, my, x2, y2 );
+ CopySourceToDest( lm, m, bm, ll, x1, my, mx, y2 );
+ end;
+ end;
+var
+ _UL, _UR, _LR, _LL : TPoint;
+ Rect_x, Rect_y, Rect_w, Rect_h : integer;
+begin
+ if SDL_MustLock( SrcSurface ) then
+ SDL_LockSurface( SrcSurface );
+ if SDL_MustLock( DstSurface ) then
+ SDL_LockSurface( DstSurface );
+ if SrcRect = nil then
+ begin
+ Rect_x := 0;
+ Rect_y := 0;
+ Rect_w := ( SrcSurface.w - 1 ) shl SHIFTS;
+ Rect_h := ( SrcSurface.h - 1 ) shl SHIFTS;
+ end
+ else
+ begin
+ Rect_x := SrcRect.x;
+ Rect_y := SrcRect.y;
+ Rect_w := ( SrcRect.w - 1 ) shl SHIFTS;
+ Rect_h := ( SrcRect.h - 1 ) shl SHIFTS;
+ end;
+ // Shift all values to help reduce round-off error.
+ _ul.x := ul.x shl SHIFTS;
+ _ul.y := ul.y shl SHIFTS;
+ _ur.x := ur.x shl SHIFTS;
+ _ur.y := ur.y shl SHIFTS;
+ _lr.x := lr.x shl SHIFTS;
+ _lr.y := lr.y shl SHIFTS;
+ _ll.x := ll.x shl SHIFTS;
+ _ll.y := ll.y shl SHIFTS;
+ CopySourceToDest( _ul, _ur, _lr, _ll, Rect_x, Rect_y, Rect_w, Rect_h );
+ if SDL_MustLock( SrcSurface ) then
+ SDL_UnlockSurface( SrcSurface );
+ if SDL_MustLock( DstSurface ) then
+ SDL_UnlockSurface( DstSurface );
+end;
+
+// Draw a line between x1,y1 and x2,y2 to the given surface
+// NOTE: The surface must be locked before calling this!
+
+procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal );
+var
+ dx, dy, sdx, sdy, x, y, px, py : integer;
+begin
+ dx := x2 - x1;
+ dy := y2 - y1;
+ if dx < 0 then
+ sdx := -1
+ else
+ sdx := 1;
+ if dy < 0 then
+ sdy := -1
+ else
+ sdy := 1;
+ dx := sdx * dx + 1;
+ dy := sdy * dy + 1;
+ x := 0;
+ y := 0;
+ px := x1;
+ py := y1;
+ if dx >= dy then
+ begin
+ for x := 0 to dx - 1 do
+ begin
+ SDL_PutPixel( DstSurface, px, py, Color );
+ y := y + dy;
+ if y >= dx then
+ begin
+ y := y - dx;
+ py := py + sdy;
+ end;
+ px := px + sdx;
+ end;
+ end
+ else
+ begin
+ for y := 0 to dy - 1 do
+ begin
+ SDL_PutPixel( DstSurface, px, py, Color );
+ x := x + dx;
+ if x >= dy then
+ begin
+ x := x - dy;
+ px := px + sdx;
+ end;
+ py := py + sdy;
+ end;
+ end;
+end;
+
+// Draw a dashed line between x1,y1 and x2,y2 to the given surface
+// NOTE: The surface must be locked before calling this!
+
+procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal; DashLength, DashSpace : byte ); overload;
+var
+ dx, dy, sdx, sdy, x, y, px, py, counter : integer; drawdash : boolean;
+begin
+ counter := 0;
+ drawdash := true; //begin line drawing with dash
+
+ //Avoid invalid user-passed dash parameters
+ if ( DashLength < 1 )
+ then
+ DashLength := 1;
+ if ( DashSpace < 1 )
+ then
+ DashSpace := 0;
+
+ dx := x2 - x1;
+ dy := y2 - y1;
+ if dx < 0 then
+ sdx := -1
+ else
+ sdx := 1;
+ if dy < 0 then
+ sdy := -1
+ else
+ sdy := 1;
+ dx := sdx * dx + 1;
+ dy := sdy * dy + 1;
+ x := 0;
+ y := 0;
+ px := x1;
+ py := y1;
+ if dx >= dy then
+ begin
+ for x := 0 to dx - 1 do
+ begin
+
+ //Alternate drawing dashes, or leaving spaces
+ if drawdash then
+ begin
+ SDL_PutPixel( DstSurface, px, py, Color );
+ inc( counter );
+ if ( counter > DashLength - 1 ) and ( DashSpace > 0 ) then
+ begin
+ drawdash := false;
+ counter := 0;
+ end;
+ end
+ else //space
+ begin
+ inc( counter );
+ if counter > DashSpace - 1 then
+ begin
+ drawdash := true;
+ counter := 0;
+ end;
+ end;
+
+ y := y + dy;
+ if y >= dx then
+ begin
+ y := y - dx;
+ py := py + sdy;
+ end;
+ px := px + sdx;
+ end;
+ end
+ else
+ begin
+ for y := 0 to dy - 1 do
+ begin
+
+ //Alternate drawing dashes, or leaving spaces
+ if drawdash then
+ begin
+ SDL_PutPixel( DstSurface, px, py, Color );
+ inc( counter );
+ if ( counter > DashLength - 1 ) and ( DashSpace > 0 ) then
+ begin
+ drawdash := false;
+ counter := 0;
+ end;
+ end
+ else //space
+ begin
+ inc( counter );
+ if counter > DashSpace - 1 then
+ begin
+ drawdash := true;
+ counter := 0;
+ end;
+ end;
+
+ x := x + dx;
+ if x >= dy then
+ begin
+ x := x - dy;
+ px := px + sdx;
+ end;
+ py := py + sdy;
+ end;
+ end;
+end;
+
+procedure SDL_AddLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal );
+var
+ dx, dy, sdx, sdy, x, y, px, py : integer;
+begin
+ dx := x2 - x1;
+ dy := y2 - y1;
+ if dx < 0 then
+ sdx := -1
+ else
+ sdx := 1;
+ if dy < 0 then
+ sdy := -1
+ else
+ sdy := 1;
+ dx := sdx * dx + 1;
+ dy := sdy * dy + 1;
+ x := 0;
+ y := 0;
+ px := x1;
+ py := y1;
+ if dx >= dy then
+ begin
+ for x := 0 to dx - 1 do
+ begin
+ SDL_AddPixel( DstSurface, px, py, Color );
+ y := y + dy;
+ if y >= dx then
+ begin
+ y := y - dx;
+ py := py + sdy;
+ end;
+ px := px + sdx;
+ end;
+ end
+ else
+ begin
+ for y := 0 to dy - 1 do
+ begin
+ SDL_AddPixel( DstSurface, px, py, Color );
+ x := x + dx;
+ if x >= dy then
+ begin
+ x := x - dy;
+ px := px + sdx;
+ end;
+ py := py + sdy;
+ end;
+ end;
+end;
+
+procedure SDL_SubLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color :
+ cardinal );
+var
+ dx, dy, sdx, sdy, x, y, px, py : integer;
+begin
+ dx := x2 - x1;
+ dy := y2 - y1;
+ if dx < 0 then
+ sdx := -1
+ else
+ sdx := 1;
+ if dy < 0 then
+ sdy := -1
+ else
+ sdy := 1;
+ dx := sdx * dx + 1;
+ dy := sdy * dy + 1;
+ x := 0;
+ y := 0;
+ px := x1;
+ py := y1;
+ if dx >= dy then
+ begin
+ for x := 0 to dx - 1 do
+ begin
+ SDL_SubPixel( DstSurface, px, py, Color );
+ y := y + dy;
+ if y >= dx then
+ begin
+ y := y - dx;
+ py := py + sdy;
+ end;
+ px := px + sdx;
+ end;
+ end
+ else
+ begin
+ for y := 0 to dy - 1 do
+ begin
+ SDL_SubPixel( DstSurface, px, py, Color );
+ x := x + dx;
+ if x >= dy then
+ begin
+ x := x - dy;
+ px := px + sdx;
+ end;
+ py := py + sdy;
+ end;
+ end;
+end;
+
+// flips a rectangle vertically on given surface
+
+procedure SDL_FlipRectV( DstSurface : PSDL_Surface; Rect : PSDL_Rect );
+var
+ TmpRect : TSDL_Rect;
+ Locked : boolean;
+ y, FlipLength, RowLength : integer;
+ Row1, Row2 : Pointer;
+ OneRow : TByteArray; // Optimize it if you wish
+begin
+ if DstSurface <> nil then
+ begin
+ if Rect = nil then
+ begin // if Rect=nil then we flip the whole surface
+ TmpRect := SDLRect( 0, 0, DstSurface.w, DstSurface.h );
+ Rect := @TmpRect;
+ end;
+ FlipLength := Rect^.h shr 1 - 1;
+ RowLength := Rect^.w * DstSurface^.format.BytesPerPixel;
+ if SDL_MustLock( DstSurface ) then
+ begin
+ Locked := true;
+ SDL_LockSurface( DstSurface );
+ end
+ else
+ Locked := false;
+ Row1 := pointer( cardinal( DstSurface^.Pixels ) + UInt32( Rect^.y ) *
+ DstSurface^.Pitch );
+ Row2 := pointer( cardinal( DstSurface^.Pixels ) + ( UInt32( Rect^.y ) + Rect^.h - 1 )
+ * DstSurface^.Pitch );
+ for y := 0 to FlipLength do
+ begin
+ Move( Row1^, OneRow, RowLength );
+ Move( Row2^, Row1^, RowLength );
+ Move( OneRow, Row2^, RowLength );
+ inc( cardinal( Row1 ), DstSurface^.Pitch );
+ dec( cardinal( Row2 ), DstSurface^.Pitch );
+ end;
+ if Locked then
+ SDL_UnlockSurface( DstSurface );
+ end;
+end;
+
+// flips a rectangle horizontally on given surface
+
+procedure SDL_FlipRectH( DstSurface : PSDL_Surface; Rect : PSDL_Rect );
+type
+ T24bit = packed array[ 0..2 ] of byte;
+ T24bitArray = packed array[ 0..8191 ] of T24bit;
+ P24bitArray = ^T24bitArray;
+ TLongWordArray = array[ 0..8191 ] of LongWord;
+ PLongWordArray = ^TLongWordArray;
+var
+ TmpRect : TSDL_Rect;
+ Row8bit : PByteArray;
+ Row16bit : PWordArray;
+ Row24bit : P24bitArray;
+ Row32bit : PLongWordArray;
+ y, x, RightSide, FlipLength : integer;
+ Pixel : cardinal;
+ Pixel24 : T24bit;
+ Locked : boolean;
+begin
+ if DstSurface <> nil then
+ begin
+ if Rect = nil then
+ begin
+ TmpRect := SDLRect( 0, 0, DstSurface.w, DstSurface.h );
+ Rect := @TmpRect;
+ end;
+ FlipLength := Rect^.w shr 1 - 1;
+ if SDL_MustLock( DstSurface ) then
+ begin
+ Locked := true;
+ SDL_LockSurface( DstSurface );
+ end
+ else
+ Locked := false;
+ case DstSurface^.format.BytesPerPixel of
+ 1 :
+ begin
+ Row8Bit := pointer( cardinal( DstSurface^.pixels ) + UInt32( Rect^.y ) *
+ DstSurface^.pitch );
+ for y := 1 to Rect^.h do
+ begin
+ RightSide := Rect^.w - 1;
+ for x := 0 to FlipLength do
+ begin
+ Pixel := Row8Bit^[ x ];
+ Row8Bit^[ x ] := Row8Bit^[ RightSide ];
+ Row8Bit^[ RightSide ] := Pixel;
+ dec( RightSide );
+ end;
+ inc( cardinal( Row8Bit ), DstSurface^.pitch );
+ end;
+ end;
+ 2 :
+ begin
+ Row16Bit := pointer( cardinal( DstSurface^.pixels ) + UInt32( Rect^.y ) *
+ DstSurface^.pitch );
+ for y := 1 to Rect^.h do
+ begin
+ RightSide := Rect^.w - 1;
+ for x := 0 to FlipLength do
+ begin
+ Pixel := Row16Bit^[ x ];
+ Row16Bit^[ x ] := Row16Bit^[ RightSide ];
+ Row16Bit^[ RightSide ] := Pixel;
+ dec( RightSide );
+ end;
+ inc( cardinal( Row16Bit ), DstSurface^.pitch );
+ end;
+ end;
+ 3 :
+ begin
+ Row24Bit := pointer( cardinal( DstSurface^.pixels ) + UInt32( Rect^.y ) *
+ DstSurface^.pitch );
+ for y := 1 to Rect^.h do
+ begin
+ RightSide := Rect^.w - 1;
+ for x := 0 to FlipLength do
+ begin
+ Pixel24 := Row24Bit^[ x ];
+ Row24Bit^[ x ] := Row24Bit^[ RightSide ];
+ Row24Bit^[ RightSide ] := Pixel24;
+ dec( RightSide );
+ end;
+ inc( cardinal( Row24Bit ), DstSurface^.pitch );
+ end;
+ end;
+ 4 :
+ begin
+ Row32Bit := pointer( cardinal( DstSurface^.pixels ) + UInt32( Rect^.y ) *
+ DstSurface^.pitch );
+ for y := 1 to Rect^.h do
+ begin
+ RightSide := Rect^.w - 1;
+ for x := 0 to FlipLength do
+ begin
+ Pixel := Row32Bit^[ x ];
+ Row32Bit^[ x ] := Row32Bit^[ RightSide ];
+ Row32Bit^[ RightSide ] := Pixel;
+ dec( RightSide );
+ end;
+ inc( cardinal( Row32Bit ), DstSurface^.pitch );
+ end;
+ end;
+ end;
+ if Locked then
+ SDL_UnlockSurface( DstSurface );
+ end;
+end;
+
+// Use with caution! The procedure allocates memory for TSDL_Rect and return with its pointer.
+// But you MUST free it after you don't need it anymore!!!
+
+function PSDLRect( aLeft, aTop, aWidth, aHeight : integer ) : PSDL_Rect;
+var
+ Rect : PSDL_Rect;
+begin
+ New( Rect );
+ with Rect^ do
+ begin
+ x := aLeft;
+ y := aTop;
+ w := aWidth;
+ h := aHeight;
+ end;
+ Result := Rect;
+end;
+
+function SDLRect( aLeft, aTop, aWidth, aHeight : integer ) : TSDL_Rect;
+begin
+ with result do
+ begin
+ x := aLeft;
+ y := aTop;
+ w := aWidth;
+ h := aHeight;
+ end;
+end;
+
+function SDLRect( aRect : TRect ) : TSDL_Rect;
+begin
+ with aRect do
+ result := SDLRect( Left, Top, Right - Left, Bottom - Top );
+end;
+
+procedure SDL_Stretch8( Surface, Dst_Surface : PSDL_Surface; x1, x2, y1, y2, yr, yw,
+ depth : integer );
+var
+ dx, dy, e, d, dx2 : integer;
+ src_pitch, dst_pitch : uint16;
+ src_pixels, dst_pixels : PUint8;
+begin
+ if ( yw >= dst_surface^.h ) then
+ exit;
+ dx := ( x2 - x1 );
+ dy := ( y2 - y1 );
+ dy := dy shl 1;
+ e := dy - dx;
+ dx2 := dx shl 1;
+ src_pitch := Surface^.pitch;
+ dst_pitch := dst_surface^.pitch;
+ src_pixels := PUint8( integer( Surface^.pixels ) + yr * src_pitch + y1 * depth );
+ dst_pixels := PUint8( integer( dst_surface^.pixels ) + yw * dst_pitch + x1 *
+ depth );
+ for d := 0 to dx - 1 do
+ begin
+ move( src_pixels^, dst_pixels^, depth );
+ while ( e >= 0 ) do
+ begin
+ inc( src_pixels, depth );
+ e := e - dx2;
+ end;
+ inc( dst_pixels, depth );
+ e := e + dy;
+ end;
+end;
+
+function sign( x : integer ) : integer;
+begin
+ if x > 0 then
+ result := 1
+ else
+ result := -1;
+end;
+
+// Stretches a part of a surface
+
+function SDL_ScaleSurfaceRect( SrcSurface : PSDL_Surface; SrcX1, SrcY1, SrcW, SrcH,
+ Width, Height : integer ) : PSDL_Surface;
+var
+ dst_surface : PSDL_Surface;
+ dx, dy, e, d, dx2, srcx2, srcy2 : integer;
+ destx1, desty1 : integer;
+begin
+ srcx2 := srcx1 + SrcW;
+ srcy2 := srcy1 + SrcH;
+ result := nil;
+ destx1 := 0;
+ desty1 := 0;
+ dx := abs( integer( Height - desty1 ) );
+ dy := abs( integer( SrcY2 - SrcY1 ) );
+ e := ( dy shl 1 ) - dx;
+ dx2 := dx shl 1;
+ dy := dy shl 1;
+ dst_surface := SDL_CreateRGBSurface( SDL_HWPALETTE, width - destx1, Height -
+ desty1,
+ SrcSurface^.Format^.BitsPerPixel,
+ SrcSurface^.Format^.RMask,
+ SrcSurface^.Format^.GMask,
+ SrcSurface^.Format^.BMask,
+ SrcSurface^.Format^.AMask );
+ if ( dst_surface^.format^.BytesPerPixel = 1 ) then
+ SDL_SetColors( dst_surface, @SrcSurface^.format^.palette^.colors^[ 0 ], 0, 256 );
+ SDL_SetColorKey( dst_surface, sdl_srccolorkey, SrcSurface^.format^.colorkey );
+ if ( SDL_MustLock( dst_surface ) ) then
+ if ( SDL_LockSurface( dst_surface ) < 0 ) then
+ exit;
+ for d := 0 to dx - 1 do
+ begin
+ SDL_Stretch8( SrcSurface, dst_surface, destx1, Width, SrcX1, SrcX2, SrcY1, desty1,
+ SrcSurface^.format^.BytesPerPixel );
+ while e >= 0 do
+ begin
+ inc( SrcY1 );
+ e := e - dx2;
+ end;
+ inc( desty1 );
+ e := e + dy;
+ end;
+ if SDL_MUSTLOCK( dst_surface ) then
+ SDL_UnlockSurface( dst_surface );
+ result := dst_surface;
+end;
+
+procedure SDL_MoveLine( Surface : PSDL_Surface; x1, x2, y1, xofs, depth : integer );
+var
+ src_pixels, dst_pixels : PUint8;
+ i : integer;
+begin
+ src_pixels := PUint8( integer( Surface^.pixels ) + Surface^.w * y1 * depth + x2 *
+ depth );
+ dst_pixels := PUint8( integer( Surface^.pixels ) + Surface^.w * y1 * depth + ( x2
+ + xofs ) * depth );
+ for i := x2 downto x1 do
+ begin
+ move( src_pixels^, dst_pixels^, depth );
+ dec( src_pixels );
+ dec( dst_pixels );
+ end;
+end;
+{ Return the pixel value at (x, y)
+NOTE: The surface must be locked before calling this! }
+
+function SDL_GetPixel( SrcSurface : PSDL_Surface; x : integer; y : integer ) : Uint32;
+var
+ bpp : UInt32;
+ p : PInteger;
+begin
+ bpp := SrcSurface.format.BytesPerPixel;
+ // Here p is the address to the pixel we want to retrieve
+ p := Pointer( Uint32( SrcSurface.pixels ) + UInt32( y ) * SrcSurface.pitch + UInt32( x ) *
+ bpp );
+ case bpp of
+ 1 : result := PUint8( p )^;
+ 2 : result := PUint16( p )^;
+ 3 :
+ if ( SDL_BYTEORDER = SDL_BIG_ENDIAN ) then
+ result := PUInt8Array( p )[ 0 ] shl 16 or PUInt8Array( p )[ 1 ] shl 8 or
+ PUInt8Array( p )[ 2 ]
+ else
+ result := PUInt8Array( p )[ 0 ] or PUInt8Array( p )[ 1 ] shl 8 or
+ PUInt8Array( p )[ 2 ] shl 16;
+ 4 : result := PUint32( p )^;
+ else
+ result := 0; // shouldn't happen, but avoids warnings
+ end;
+end;
+{ Set the pixel at (x, y) to the given value
+ NOTE: The surface must be locked before calling this! }
+
+procedure SDL_PutPixel( DstSurface : PSDL_Surface; x : integer; y : integer; pixel :
+ Uint32 );
+var
+ bpp : UInt32;
+ p : PInteger;
+begin
+ bpp := DstSurface.format.BytesPerPixel;
+ p := Pointer( Uint32( DstSurface.pixels ) + UInt32( y ) * DstSurface.pitch + UInt32( x )
+ * bpp );
+ case bpp of
+ 1 : PUint8( p )^ := pixel;
+ 2 : PUint16( p )^ := pixel;
+ 3 :
+ if ( SDL_BYTEORDER = SDL_BIG_ENDIAN ) then
+ begin
+ PUInt8Array( p )[ 0 ] := ( pixel shr 16 ) and $FF;
+ PUInt8Array( p )[ 1 ] := ( pixel shr 8 ) and $FF;
+ PUInt8Array( p )[ 2 ] := pixel and $FF;
+ end
+ else
+ begin
+ PUInt8Array( p )[ 0 ] := pixel and $FF;
+ PUInt8Array( p )[ 1 ] := ( pixel shr 8 ) and $FF;
+ PUInt8Array( p )[ 2 ] := ( pixel shr 16 ) and $FF;
+ end;
+ 4 :
+ PUint32( p )^ := pixel;
+ end;
+end;
+
+procedure SDL_ScrollY( DstSurface : PSDL_Surface; DifY : integer );
+var
+ r1, r2 : TSDL_Rect;
+ //buffer: PSDL_Surface;
+ YPos : Integer;
+begin
+ if ( DstSurface <> nil ) and ( DifY <> 0 ) then
+ begin
+ //if DifY > 0 then // going up
+ //begin
+ ypos := 0;
+ r1.x := 0;
+ r2.x := 0;
+ r1.w := DstSurface.w;
+ r2.w := DstSurface.w;
+ r1.h := DifY;
+ r2.h := DifY;
+ while ypos < DstSurface.h do
+ begin
+ r1.y := ypos;
+ r2.y := ypos + DifY;
+ SDL_BlitSurface( DstSurface, @r2, DstSurface, @r1 );
+ ypos := ypos + DifY;
+ end;
+ //end
+ //else
+ //begin // Going Down
+ //end;
+ end;
+end;
+
+{procedure SDL_ScrollY(Surface: PSDL_Surface; DifY: integer);
+var
+ r1, r2: TSDL_Rect;
+ buffer: PSDL_Surface;
+begin
+ if (Surface <> nil) and (Dify <> 0) then
+ begin
+ buffer := SDL_CreateRGBSurface(SDL_HWSURFACE, (Surface^.w - DifY) * 2,
+ Surface^.h * 2,
+ Surface^.Format^.BitsPerPixel, 0, 0, 0, 0);
+ if buffer <> nil then
+ begin
+ if (buffer^.format^.BytesPerPixel = 1) then
+ SDL_SetColors(buffer, @Surface^.format^.palette^.colors^[0], 0, 256);
+ r1 := SDLRect(0, DifY, buffer^.w, buffer^.h);
+ r2 := SDLRect(0, 0, buffer^.w, buffer^.h);
+ SDL_BlitSurface(Surface, @r1, buffer, @r2);
+ SDL_BlitSurface(buffer, @r2, Surface, @r2);
+ SDL_FreeSurface(buffer);
+ end;
+ end;
+end;}
+
+procedure SDL_ScrollX( DstSurface : PSDL_Surface; DifX : integer );
+var
+ r1, r2 : TSDL_Rect;
+ buffer : PSDL_Surface;
+begin
+ if ( DstSurface <> nil ) and ( DifX <> 0 ) then
+ begin
+ buffer := SDL_CreateRGBSurface( SDL_HWSURFACE, ( DstSurface^.w - DifX ) * 2,
+ DstSurface^.h * 2,
+ DstSurface^.Format^.BitsPerPixel,
+ DstSurface^.Format^.RMask,
+ DstSurface^.Format^.GMask,
+ DstSurface^.Format^.BMask,
+ DstSurface^.Format^.AMask );
+ if buffer <> nil then
+ begin
+ if ( buffer^.format^.BytesPerPixel = 1 ) then
+ SDL_SetColors( buffer, @DstSurface^.format^.palette^.colors^[ 0 ], 0, 256 );
+ r1 := SDLRect( DifX, 0, buffer^.w, buffer^.h );
+ r2 := SDLRect( 0, 0, buffer^.w, buffer^.h );
+ SDL_BlitSurface( DstSurface, @r1, buffer, @r2 );
+ SDL_BlitSurface( buffer, @r2, DstSurface, @r2 );
+ SDL_FreeSurface( buffer );
+ end;
+ end;
+end;
+
+procedure SDL_RotateRad( DstSurface, SrcSurface : PSDL_Surface; SrcRect :
+ PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Single );
+var
+ aSin, aCos : Single;
+ MX, MY, DX, DY, NX, NY, SX, SY, OX, OY, Width, Height, TX, TY, RX, RY, ROX, ROY : Integer;
+ Colour, TempTransparentColour : UInt32;
+ MAXX, MAXY : Integer;
+begin
+ // Rotate the surface to the target surface.
+ TempTransparentColour := SrcSurface.format.colorkey;
+ {if srcRect.w > srcRect.h then
+ begin
+ Width := srcRect.w;
+ Height := srcRect.w;
+ end
+ else
+ begin
+ Width := srcRect.h;
+ Height := srcRect.h;
+ end; }
+
+ maxx := DstSurface.w;
+ maxy := DstSurface.h;
+ aCos := cos( Angle );
+ aSin := sin( Angle );
+
+ Width := round( abs( srcrect.h * acos ) + abs( srcrect.w * asin ) );
+ Height := round( abs( srcrect.h * asin ) + abs( srcrect.w * acos ) );
+
+ OX := Width div 2;
+ OY := Height div 2; ;
+ MX := ( srcRect.x + ( srcRect.x + srcRect.w ) ) div 2;
+ MY := ( srcRect.y + ( srcRect.y + srcRect.h ) ) div 2;
+ ROX := ( -( srcRect.w div 2 ) ) + Offsetx;
+ ROY := ( -( srcRect.h div 2 ) ) + OffsetY;
+ Tx := ox + round( ROX * aSin - ROY * aCos );
+ Ty := oy + round( ROY * aSin + ROX * aCos );
+ SX := 0;
+ for DX := DestX - TX to DestX - TX + ( width ) do
+ begin
+ Inc( SX );
+ SY := 0;
+ for DY := DestY - TY to DestY - TY + ( Height ) do
+ begin
+ RX := SX - OX;
+ RY := SY - OY;
+ NX := round( mx + RX * aSin + RY * aCos ); //
+ NY := round( my + RY * aSin - RX * aCos ); //
+ // Used for testing only
+ //SDL_PutPixel(DestSurface.SDLSurfacePointer,DX,DY,0);
+ if ( ( DX > 0 ) and ( DX < MAXX ) ) and ( ( DY > 0 ) and ( DY < MAXY ) ) then
+ begin
+ if ( NX >= srcRect.x ) and ( NX <= srcRect.x + srcRect.w ) then
+ begin
+ if ( NY >= srcRect.y ) and ( NY <= srcRect.y + srcRect.h ) then
+ begin
+ Colour := SDL_GetPixel( SrcSurface, NX, NY );
+ if Colour <> TempTransparentColour then
+ begin
+ SDL_PutPixel( DstSurface, DX, DY, Colour );
+ end;
+ end;
+ end;
+ end;
+ inc( SY );
+ end;
+ end;
+end;
+
+procedure SDL_RotateDeg( DstSurface, SrcSurface : PSDL_Surface; SrcRect :
+ PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Integer );
+begin
+ SDL_RotateRad( DstSurface, SrcSurface, SrcRect, DestX, DestY, OffsetX, OffsetY, DegToRad( Angle ) );
+end;
+
+function ValidateSurfaceRect( DstSurface : PSDL_Surface; dstrect : PSDL_Rect ) : TSDL_Rect;
+var
+ RealRect : TSDL_Rect;
+ OutOfRange : Boolean;
+begin
+ OutOfRange := false;
+ if dstrect = nil then
+ begin
+ RealRect.x := 0;
+ RealRect.y := 0;
+ RealRect.w := DstSurface.w;
+ RealRect.h := DstSurface.h;
+ end
+ else
+ begin
+ if dstrect.x < DstSurface.w then
+ begin
+ RealRect.x := dstrect.x;
+ end
+ else if dstrect.x < 0 then
+ begin
+ realrect.x := 0;
+ end
+ else
+ begin
+ OutOfRange := True;
+ end;
+ if dstrect.y < DstSurface.h then
+ begin
+ RealRect.y := dstrect.y;
+ end
+ else if dstrect.y < 0 then
+ begin
+ realrect.y := 0;
+ end
+ else
+ begin
+ OutOfRange := True;
+ end;
+ if OutOfRange = False then
+ begin
+ if realrect.x + dstrect.w <= DstSurface.w then
+ begin
+ RealRect.w := dstrect.w;
+ end
+ else
+ begin
+ RealRect.w := dstrect.w - realrect.x;
+ end;
+ if realrect.y + dstrect.h <= DstSurface.h then
+ begin
+ RealRect.h := dstrect.h;
+ end
+ else
+ begin
+ RealRect.h := dstrect.h - realrect.y;
+ end;
+ end;
+ end;
+ if OutOfRange = False then
+ begin
+ result := realrect;
+ end
+ else
+ begin
+ realrect.w := 0;
+ realrect.h := 0;
+ realrect.x := 0;
+ realrect.y := 0;
+ result := realrect;
+ end;
+end;
+
+procedure SDL_FillRectAdd( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 );
+var
+ RealRect : TSDL_Rect;
+ Addr : pointer;
+ ModX, BPP : cardinal;
+ x, y, R, G, B, SrcColor : cardinal;
+begin
+ RealRect := ValidateSurfaceRect( DstSurface, DstRect );
+ if ( RealRect.w > 0 ) and ( RealRect.h > 0 ) then
+ begin
+ SDL_LockSurface( DstSurface );
+ BPP := DstSurface.format.BytesPerPixel;
+ with DstSurface^ do
+ begin
+ Addr := pointer( UInt32( pixels ) + UInt32( RealRect.y ) * pitch + UInt32( RealRect.x ) * BPP );
+ ModX := Pitch - UInt32( RealRect.w ) * BPP;
+ end;
+ case DstSurface.format.BitsPerPixel of
+ 8 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $E0 + Color and $E0;
+ G := SrcColor and $1C + Color and $1C;
+ B := SrcColor and $03 + Color and $03;
+ if R > $E0 then
+ R := $E0;
+ if G > $1C then
+ G := $1C;
+ if B > $03 then
+ B := $03;
+ PUInt8( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 15 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $7C00 + Color and $7C00;
+ G := SrcColor and $03E0 + Color and $03E0;
+ B := SrcColor and $001F + Color and $001F;
+ if R > $7C00 then
+ R := $7C00;
+ if G > $03E0 then
+ G := $03E0;
+ if B > $001F then
+ B := $001F;
+ PUInt16( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 16 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $F800 + Color and $F800;
+ G := SrcColor and $07C0 + Color and $07C0;
+ B := SrcColor and $001F + Color and $001F;
+ if R > $F800 then
+ R := $F800;
+ if G > $07C0 then
+ G := $07C0;
+ if B > $001F then
+ B := $001F;
+ PUInt16( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 24 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $00FF0000 + Color and $00FF0000;
+ G := SrcColor and $0000FF00 + Color and $0000FF00;
+ B := SrcColor and $000000FF + Color and $000000FF;
+ if R > $FF0000 then
+ R := $FF0000;
+ if G > $00FF00 then
+ G := $00FF00;
+ if B > $0000FF then
+ B := $0000FF;
+ PUInt32( Addr )^ := SrcColor and $FF000000 or R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 32 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $00FF0000 + Color and $00FF0000;
+ G := SrcColor and $0000FF00 + Color and $0000FF00;
+ B := SrcColor and $000000FF + Color and $000000FF;
+ if R > $FF0000 then
+ R := $FF0000;
+ if G > $00FF00 then
+ G := $00FF00;
+ if B > $0000FF then
+ B := $0000FF;
+ PUInt32( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ end;
+ SDL_UnlockSurface( DstSurface );
+ end;
+end;
+
+procedure SDL_FillRectSub( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 );
+var
+ RealRect : TSDL_Rect;
+ Addr : pointer;
+ ModX, BPP : cardinal;
+ x, y, R, G, B, SrcColor : cardinal;
+begin
+ RealRect := ValidateSurfaceRect( DstSurface, DstRect );
+ if ( RealRect.w > 0 ) and ( RealRect.h > 0 ) then
+ begin
+ SDL_LockSurface( DstSurface );
+ BPP := DstSurface.format.BytesPerPixel;
+ with DstSurface^ do
+ begin
+ Addr := pointer( UInt32( pixels ) + UInt32( RealRect.y ) * pitch + UInt32( RealRect.x ) * BPP );
+ ModX := Pitch - UInt32( RealRect.w ) * BPP;
+ end;
+ case DstSurface.format.BitsPerPixel of
+ 8 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $E0 - Color and $E0;
+ G := SrcColor and $1C - Color and $1C;
+ B := SrcColor and $03 - Color and $03;
+ if R > $E0 then
+ R := 0;
+ if G > $1C then
+ G := 0;
+ if B > $03 then
+ B := 0;
+ PUInt8( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 15 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $7C00 - Color and $7C00;
+ G := SrcColor and $03E0 - Color and $03E0;
+ B := SrcColor and $001F - Color and $001F;
+ if R > $7C00 then
+ R := 0;
+ if G > $03E0 then
+ G := 0;
+ if B > $001F then
+ B := 0;
+ PUInt16( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 16 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $F800 - Color and $F800;
+ G := SrcColor and $07C0 - Color and $07C0;
+ B := SrcColor and $001F - Color and $001F;
+ if R > $F800 then
+ R := 0;
+ if G > $07C0 then
+ G := 0;
+ if B > $001F then
+ B := 0;
+ PUInt16( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 24 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $00FF0000 - Color and $00FF0000;
+ G := SrcColor and $0000FF00 - Color and $0000FF00;
+ B := SrcColor and $000000FF - Color and $000000FF;
+ if R > $FF0000 then
+ R := 0;
+ if G > $00FF00 then
+ G := 0;
+ if B > $0000FF then
+ B := 0;
+ PUInt32( Addr )^ := SrcColor and $FF000000 or R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ 32 :
+ begin
+ for y := 0 to RealRect.h - 1 do
+ begin
+ for x := 0 to RealRect.w - 1 do
+ begin
+ SrcColor := PUInt32( Addr )^;
+ R := SrcColor and $00FF0000 - Color and $00FF0000;
+ G := SrcColor and $0000FF00 - Color and $0000FF00;
+ B := SrcColor and $000000FF - Color and $000000FF;
+ if R > $FF0000 then
+ R := 0;
+ if G > $00FF00 then
+ G := 0;
+ if B > $0000FF then
+ B := 0;
+ PUInt32( Addr )^ := R or G or B;
+ inc( UInt32( Addr ), BPP );
+ end;
+ inc( UInt32( Addr ), ModX );
+ end;
+ end;
+ end;
+ SDL_UnlockSurface( DstSurface );
+ end;
+end;
+
+procedure SDL_GradientFillRect( DstSurface : PSDL_Surface; const Rect : PSDL_Rect; const StartColor, EndColor : TSDL_Color; const Style : TGradientStyle );
+var
+ FBC : array[ 0..255 ] of Cardinal;
+ // temp vars
+ i, YR, YG, YB, SR, SG, SB, DR, DG, DB : Integer;
+
+ TempStepV, TempStepH : Single;
+ TempLeft, TempTop, TempHeight, TempWidth : integer;
+ TempRect : TSDL_Rect;
+
+begin
+ // calc FBC
+ YR := StartColor.r;
+ YG := StartColor.g;
+ YB := StartColor.b;
+ SR := YR;
+ SG := YG;
+ SB := YB;
+ DR := EndColor.r - SR;
+ DG := EndColor.g - SG;
+ DB := EndColor.b - SB;
+
+ for i := 0 to 255 do
+ begin
+ FBC[ i ] := SDL_MapRGB( DstSurface.format, YR, YG, YB );
+ YR := SR + round( DR / 255 * i );
+ YG := SG + round( DG / 255 * i );
+ YB := SB + round( DB / 255 * i );
+ end;
+
+ // if aStyle = 1 then begin
+ TempStepH := Rect.w / 255;
+ TempStepV := Rect.h / 255;
+ TempHeight := Trunc( TempStepV + 1 );
+ TempWidth := Trunc( TempStepH + 1 );
+ TempTop := 0;
+ TempLeft := 0;
+ TempRect.x := Rect.x;
+ TempRect.y := Rect.y;
+ TempRect.h := Rect.h;
+ TempRect.w := Rect.w;
+
+ case Style of
+ gsHorizontal :
+ begin
+ TempRect.h := TempHeight;
+ for i := 0 to 255 do
+ begin
+ TempRect.y := Rect.y + TempTop;
+ SDL_FillRect( DstSurface, @TempRect, FBC[ i ] );
+ TempTop := Trunc( TempStepV * i );
+ end;
+ end;
+ gsVertical :
+ begin
+ TempRect.w := TempWidth;
+ for i := 0 to 255 do
+ begin
+ TempRect.x := Rect.x + TempLeft;
+ SDL_FillRect( DstSurface, @TempRect, FBC[ i ] );
+ TempLeft := Trunc( TempStepH * i );
+ end;
+ end;
+ end;
+end;
+
+procedure SDL_2xBlit( Src, Dest : PSDL_Surface );
+var
+ ReadAddr, WriteAddr, ReadRow, WriteRow : UInt32;
+ SrcPitch, DestPitch, x, y : UInt32;
+begin
+ if ( Src = nil ) or ( Dest = nil ) then
+ exit;
+ if ( Src.w shl 1 ) < Dest.w then
+ exit;
+ if ( Src.h shl 1 ) < Dest.h then
+ exit;
+
+ if SDL_MustLock( Src ) then
+ SDL_LockSurface( Src );
+ if SDL_MustLock( Dest ) then
+ SDL_LockSurface( Dest );
+
+ ReadRow := UInt32( Src.Pixels );
+ WriteRow := UInt32( Dest.Pixels );
+
+ SrcPitch := Src.pitch;
+ DestPitch := Dest.pitch;
+
+ case Src.format.BytesPerPixel of
+ 1 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ PUInt8( WriteAddr )^ := PUInt8( ReadAddr )^;
+ PUInt8( WriteAddr + 1 )^ := PUInt8( ReadAddr )^;
+ PUInt8( WriteAddr + DestPitch )^ := PUInt8( ReadAddr )^;
+ PUInt8( WriteAddr + DestPitch + 1 )^ := PUInt8( ReadAddr )^;
+ inc( ReadAddr );
+ inc( WriteAddr, 2 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ 2 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ PUInt16( WriteAddr )^ := PUInt16( ReadAddr )^;
+ PUInt16( WriteAddr + 2 )^ := PUInt16( ReadAddr )^;
+ PUInt16( WriteAddr + DestPitch )^ := PUInt16( ReadAddr )^;
+ PUInt16( WriteAddr + DestPitch + 2 )^ := PUInt16( ReadAddr )^;
+ inc( ReadAddr, 2 );
+ inc( WriteAddr, 4 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ 3 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ PUInt32( WriteAddr )^ := ( PUInt32( WriteAddr )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF );
+ PUInt32( WriteAddr + 3 )^ := ( PUInt32( WriteAddr + 3 )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF );
+ PUInt32( WriteAddr + DestPitch )^ := ( PUInt32( WriteAddr + DestPitch )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF );
+ PUInt32( WriteAddr + DestPitch + 3 )^ := ( PUInt32( WriteAddr + DestPitch + 3 )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF );
+ inc( ReadAddr, 3 );
+ inc( WriteAddr, 6 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ 4 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ PUInt32( WriteAddr )^ := PUInt32( ReadAddr )^;
+ PUInt32( WriteAddr + 4 )^ := PUInt32( ReadAddr )^;
+ PUInt32( WriteAddr + DestPitch )^ := PUInt32( ReadAddr )^;
+ PUInt32( WriteAddr + DestPitch + 4 )^ := PUInt32( ReadAddr )^;
+ inc( ReadAddr, 4 );
+ inc( WriteAddr, 8 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ end;
+
+ if SDL_MustLock( Src ) then
+ SDL_UnlockSurface( Src );
+ if SDL_MustLock( Dest ) then
+ SDL_UnlockSurface( Dest );
+end;
+
+procedure SDL_Scanline2xBlit( Src, Dest : PSDL_Surface );
+var
+ ReadAddr, WriteAddr, ReadRow, WriteRow : UInt32;
+ SrcPitch, DestPitch, x, y : UInt32;
+begin
+ if ( Src = nil ) or ( Dest = nil ) then
+ exit;
+ if ( Src.w shl 1 ) < Dest.w then
+ exit;
+ if ( Src.h shl 1 ) < Dest.h then
+ exit;
+
+ if SDL_MustLock( Src ) then
+ SDL_LockSurface( Src );
+ if SDL_MustLock( Dest ) then
+ SDL_LockSurface( Dest );
+
+ ReadRow := UInt32( Src.Pixels );
+ WriteRow := UInt32( Dest.Pixels );
+
+ SrcPitch := Src.pitch;
+ DestPitch := Dest.pitch;
+
+ case Src.format.BytesPerPixel of
+ 1 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ PUInt8( WriteAddr )^ := PUInt8( ReadAddr )^;
+ PUInt8( WriteAddr + 1 )^ := PUInt8( ReadAddr )^;
+ inc( ReadAddr );
+ inc( WriteAddr, 2 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ 2 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ PUInt16( WriteAddr )^ := PUInt16( ReadAddr )^;
+ PUInt16( WriteAddr + 2 )^ := PUInt16( ReadAddr )^;
+ inc( ReadAddr, 2 );
+ inc( WriteAddr, 4 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ 3 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ PUInt32( WriteAddr )^ := ( PUInt32( WriteAddr )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF );
+ PUInt32( WriteAddr + 3 )^ := ( PUInt32( WriteAddr + 3 )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF );
+ inc( ReadAddr, 3 );
+ inc( WriteAddr, 6 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ 4 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ PUInt32( WriteAddr )^ := PUInt32( ReadAddr )^;
+ PUInt32( WriteAddr + 4 )^ := PUInt32( ReadAddr )^;
+ inc( ReadAddr, 4 );
+ inc( WriteAddr, 8 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ end;
+
+ if SDL_MustLock( Src ) then
+ SDL_UnlockSurface( Src );
+ if SDL_MustLock( Dest ) then
+ SDL_UnlockSurface( Dest );
+end;
+
+procedure SDL_50Scanline2xBlit( Src, Dest : PSDL_Surface );
+var
+ ReadAddr, WriteAddr, ReadRow, WriteRow : UInt32;
+ SrcPitch, DestPitch, x, y, Color : UInt32;
+begin
+ if ( Src = nil ) or ( Dest = nil ) then
+ exit;
+ if ( Src.w shl 1 ) < Dest.w then
+ exit;
+ if ( Src.h shl 1 ) < Dest.h then
+ exit;
+
+ if SDL_MustLock( Src ) then
+ SDL_LockSurface( Src );
+ if SDL_MustLock( Dest ) then
+ SDL_LockSurface( Dest );
+
+ ReadRow := UInt32( Src.Pixels );
+ WriteRow := UInt32( Dest.Pixels );
+
+ SrcPitch := Src.pitch;
+ DestPitch := Dest.pitch;
+
+ case Src.format.BitsPerPixel of
+ 8 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ Color := PUInt8( ReadAddr )^;
+ PUInt8( WriteAddr )^ := Color;
+ PUInt8( WriteAddr + 1 )^ := Color;
+ Color := ( Color shr 1 ) and $6D; {%01101101}
+ PUInt8( WriteAddr + DestPitch )^ := Color;
+ PUInt8( WriteAddr + DestPitch + 1 )^ := Color;
+ inc( ReadAddr );
+ inc( WriteAddr, 2 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ 15 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ Color := PUInt16( ReadAddr )^;
+ PUInt16( WriteAddr )^ := Color;
+ PUInt16( WriteAddr + 2 )^ := Color;
+ Color := ( Color shr 1 ) and $3DEF; {%0011110111101111}
+ PUInt16( WriteAddr + DestPitch )^ := Color;
+ PUInt16( WriteAddr + DestPitch + 2 )^ := Color;
+ inc( ReadAddr, 2 );
+ inc( WriteAddr, 4 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ 16 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ Color := PUInt16( ReadAddr )^;
+ PUInt16( WriteAddr )^ := Color;
+ PUInt16( WriteAddr + 2 )^ := Color;
+ Color := ( Color shr 1 ) and $7BEF; {%0111101111101111}
+ PUInt16( WriteAddr + DestPitch )^ := Color;
+ PUInt16( WriteAddr + DestPitch + 2 )^ := Color;
+ inc( ReadAddr, 2 );
+ inc( WriteAddr, 4 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ 24 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ Color := ( PUInt32( WriteAddr )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF );
+ PUInt32( WriteAddr )^ := Color;
+ PUInt32( WriteAddr + 3 )^ := Color;
+ Color := ( Color shr 1 ) and $007F7F7F; {%011111110111111101111111}
+ PUInt32( WriteAddr + DestPitch )^ := Color;
+ PUInt32( WriteAddr + DestPitch + 3 )^ := Color;
+ inc( ReadAddr, 3 );
+ inc( WriteAddr, 6 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ 32 : for y := 1 to Src.h do
+ begin
+ ReadAddr := ReadRow;
+ WriteAddr := WriteRow;
+ for x := 1 to Src.w do
+ begin
+ Color := PUInt32( ReadAddr )^;
+ PUInt32( WriteAddr )^ := Color;
+ PUInt32( WriteAddr + 4 )^ := Color;
+ Color := ( Color shr 1 ) and $7F7F7F7F;
+ PUInt32( WriteAddr + DestPitch )^ := Color;
+ PUInt32( WriteAddr + DestPitch + 4 )^ := Color;
+ inc( ReadAddr, 4 );
+ inc( WriteAddr, 8 );
+ end;
+ inc( UInt32( ReadRow ), SrcPitch );
+ inc( UInt32( WriteRow ), DestPitch * 2 );
+ end;
+ end;
+
+ if SDL_MustLock( Src ) then
+ SDL_UnlockSurface( Src );
+ if SDL_MustLock( Dest ) then
+ SDL_UnlockSurface( Dest );
+end;
+
+function SDL_PixelTestSurfaceVsRect( SrcSurface1 : PSDL_Surface; SrcRect1 :
+ PSDL_Rect; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) :
+ boolean;
+var
+ Src_Rect1, Src_Rect2 : TSDL_Rect;
+ right1, bottom1 : integer;
+ right2, bottom2 : integer;
+ Scan1Start, {Scan2Start,} ScanWidth, ScanHeight : cardinal;
+ Mod1 : cardinal;
+ Addr1 : cardinal;
+ BPP : cardinal;
+ Pitch1 : cardinal;
+ TransparentColor1 : cardinal;
+ tx, ty : cardinal;
+ StartTick : cardinal;
+ Color1 : cardinal;
+begin
+ Result := false;
+ if SrcRect1 = nil then
+ begin
+ with Src_Rect1 do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface1.w;
+ h := SrcSurface1.h;
+ end;
+ end
+ else
+ Src_Rect1 := SrcRect1^;
+
+ Src_Rect2 := SrcRect2^;
+ with Src_Rect1 do
+ begin
+ Right1 := Left1 + w;
+ Bottom1 := Top1 + h;
+ end;
+ with Src_Rect2 do
+ begin
+ Right2 := Left2 + w;
+ Bottom2 := Top2 + h;
+ end;
+ if ( Left1 >= Right2 ) or ( Right1 <= Left2 ) or ( Top1 >= Bottom2 ) or ( Bottom1 <= Top2 ) then
+ exit;
+ if Left1 <= Left2 then
+ begin
+ // 1. left, 2. right
+ Scan1Start := Src_Rect1.x + Left2 - Left1;
+ //Scan2Start := Src_Rect2.x;
+ ScanWidth := Right1 - Left2;
+ with Src_Rect2 do
+ if ScanWidth > w then
+ ScanWidth := w;
+ end
+ else
+ begin
+ // 1. right, 2. left
+ Scan1Start := Src_Rect1.x;
+ //Scan2Start := Src_Rect2.x + Left1 - Left2;
+ ScanWidth := Right2 - Left1;
+ with Src_Rect1 do
+ if ScanWidth > w then
+ ScanWidth := w;
+ end;
+ with SrcSurface1^ do
+ begin
+ Pitch1 := Pitch;
+ Addr1 := cardinal( Pixels );
+ inc( Addr1, Pitch1 * UInt32( Src_Rect1.y ) );
+ with format^ do
+ begin
+ BPP := BytesPerPixel;
+ TransparentColor1 := colorkey;
+ end;
+ end;
+
+ Mod1 := Pitch1 - ( ScanWidth * BPP );
+
+ inc( Addr1, BPP * Scan1Start );
+
+ if Top1 <= Top2 then
+ begin
+ // 1. up, 2. down
+ ScanHeight := Bottom1 - Top2;
+ if ScanHeight > Src_Rect2.h then
+ ScanHeight := Src_Rect2.h;
+ inc( Addr1, Pitch1 * UInt32( Top2 - Top1 ) );
+ end
+ else
+ begin
+ // 1. down, 2. up
+ ScanHeight := Bottom2 - Top1;
+ if ScanHeight > Src_Rect1.h then
+ ScanHeight := Src_Rect1.h;
+
+ end;
+ case BPP of
+ 1 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ if ( PByte( Addr1 )^ <> TransparentColor1 ) then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1 );
+
+ end;
+ inc( Addr1, Mod1 );
+
+ end;
+ 2 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ if ( PWord( Addr1 )^ <> TransparentColor1 ) then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1, 2 );
+
+ end;
+ inc( Addr1, Mod1 );
+
+ end;
+ 3 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ Color1 := PLongWord( Addr1 )^ and $00FFFFFF;
+
+ if ( Color1 <> TransparentColor1 )
+ then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1, 3 );
+
+ end;
+ inc( Addr1, Mod1 );
+
+ end;
+ 4 :
+ for ty := 1 to ScanHeight do
+ begin
+ for tx := 1 to ScanWidth do
+ begin
+ if ( PLongWord( Addr1 )^ <> TransparentColor1 ) then
+ begin
+ Result := true;
+ exit;
+ end;
+ inc( Addr1, 4 );
+
+ end;
+ inc( Addr1, Mod1 );
+
+ end;
+ end;
+end;
+
+procedure SDL_ORSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+var
+ R, G, B, Pixel1, Pixel2, TransparentColor : cardinal;
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DestSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DestSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ TransparentColor := Format.colorkey;
+ end;
+ with DestSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DestSurface );
+ WorkY := Src.h;
+ case bits of
+ 8 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt8( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt8( DestAddr )^;
+ PUInt8( DestAddr )^ := Pixel2 or Pixel1;
+ end;
+ inc( SrcAddr );
+ inc( DestAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 15 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+
+ PUInt16( DestAddr )^ := Pixel2 or Pixel1;
+
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 16 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+
+ PUInt16( DestAddr )^ := Pixel2 or Pixel1;
+
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 24 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF;
+
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or Pixel2 or Pixel1;
+ end;
+ inc( SrcAddr, 3 );
+ inc( DestAddr, 3 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 32 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^;
+
+ PUInt32( DestAddr )^ := Pixel2 or Pixel1;
+ end;
+ inc( SrcAddr, 4 );
+ inc( DestAddr, 4 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DestSurface );
+end;
+
+procedure SDL_ANDSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+var
+ R, G, B, Pixel1, Pixel2, TransparentColor : cardinal;
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DestSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DestSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ TransparentColor := Format.colorkey;
+ end;
+ with DestSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DestSurface );
+ WorkY := Src.h;
+ case bits of
+ 8 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt8( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt8( DestAddr )^;
+ PUInt8( DestAddr )^ := Pixel2 and Pixel1;
+ end;
+ inc( SrcAddr );
+ inc( DestAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 15 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+
+ PUInt16( DestAddr )^ := Pixel2 and Pixel1;
+
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 16 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+
+ PUInt16( DestAddr )^ := Pixel2 and Pixel1;
+
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 24 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF;
+
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or Pixel2 and Pixel1;
+ end;
+ inc( SrcAddr, 3 );
+ inc( DestAddr, 3 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 32 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^;
+
+ PUInt32( DestAddr )^ := Pixel2 and Pixel1;
+ end;
+ inc( SrcAddr, 4 );
+ inc( DestAddr, 4 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DestSurface );
+end;
+
+
+
+procedure SDL_GTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+var
+ R, G, B, Pixel1, Pixel2, TransparentColor : cardinal;
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DestSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DestSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ TransparentColor := Format.colorkey;
+ end;
+ with DestSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DestSurface );
+ WorkY := Src.h;
+ case bits of
+ 8 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt8( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt8( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+ if Pixel2 and $E0 > Pixel1 and $E0 then
+ R := Pixel2 and $E0
+ else
+ R := Pixel1 and $E0;
+ if Pixel2 and $1C > Pixel1 and $1C then
+ G := Pixel2 and $1C
+ else
+ G := Pixel1 and $1C;
+ if Pixel2 and $03 > Pixel1 and $03 then
+ B := Pixel2 and $03
+ else
+ B := Pixel1 and $03;
+
+ if R > $E0 then
+ R := $E0;
+ if G > $1C then
+ G := $1C;
+ if B > $03 then
+ B := $03;
+ PUInt8( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt8( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr );
+ inc( DestAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 15 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $7C00 > Pixel1 and $7C00 then
+ R := Pixel2 and $7C00
+ else
+ R := Pixel1 and $7C00;
+ if Pixel2 and $03E0 > Pixel1 and $03E0 then
+ G := Pixel2 and $03E0
+ else
+ G := Pixel1 and $03E0;
+ if Pixel2 and $001F > Pixel1 and $001F then
+ B := Pixel2 and $001F
+ else
+ B := Pixel1 and $001F;
+
+ PUInt16( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt16( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 16 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $F800 > Pixel1 and $F800 then
+ R := Pixel2 and $F800
+ else
+ R := Pixel1 and $F800;
+ if Pixel2 and $07E0 > Pixel1 and $07E0 then
+ G := Pixel2 and $07E0
+ else
+ G := Pixel1 and $07E0;
+ if Pixel2 and $001F > Pixel1 and $001F then
+ B := Pixel2 and $001F
+ else
+ B := Pixel1 and $001F;
+
+ PUInt16( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt16( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 24 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $FF0000 > Pixel1 and $FF0000 then
+ R := Pixel2 and $FF0000
+ else
+ R := Pixel1 and $FF0000;
+ if Pixel2 and $00FF00 > Pixel1 and $00FF00 then
+ G := Pixel2 and $00FF00
+ else
+ G := Pixel1 and $00FF00;
+ if Pixel2 and $0000FF > Pixel1 and $0000FF then
+ B := Pixel2 and $0000FF
+ else
+ B := Pixel1 and $0000FF;
+
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or ( R or G or B );
+ end
+ else
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or Pixel1;
+ end;
+ inc( SrcAddr, 3 );
+ inc( DestAddr, 3 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 32 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $FF0000 > Pixel1 and $FF0000 then
+ R := Pixel2 and $FF0000
+ else
+ R := Pixel1 and $FF0000;
+ if Pixel2 and $00FF00 > Pixel1 and $00FF00 then
+ G := Pixel2 and $00FF00
+ else
+ G := Pixel1 and $00FF00;
+ if Pixel2 and $0000FF > Pixel1 and $0000FF then
+ B := Pixel2 and $0000FF
+ else
+ B := Pixel1 and $0000FF;
+
+ PUInt32( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt32( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 4 );
+ inc( DestAddr, 4 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DestSurface );
+end;
+
+
+procedure SDL_LTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect;
+ DestSurface : PSDL_Surface; DestRect : PSDL_Rect );
+var
+ R, G, B, Pixel1, Pixel2, TransparentColor : cardinal;
+ Src, Dest : TSDL_Rect;
+ Diff : integer;
+ SrcAddr, DestAddr : cardinal;
+ WorkX, WorkY : word;
+ SrcMod, DestMod : cardinal;
+ Bits : cardinal;
+begin
+ if ( SrcSurface = nil ) or ( DestSurface = nil ) then
+ exit; // Remove this to make it faster
+ if ( SrcSurface.Format.BitsPerPixel <> DestSurface.Format.BitsPerPixel ) then
+ exit; // Remove this to make it faster
+ if SrcRect = nil then
+ begin
+ with Src do
+ begin
+ x := 0;
+ y := 0;
+ w := SrcSurface.w;
+ h := SrcSurface.h;
+ end;
+ end
+ else
+ Src := SrcRect^;
+ if DestRect = nil then
+ begin
+ Dest.x := 0;
+ Dest.y := 0;
+ end
+ else
+ Dest := DestRect^;
+ Dest.w := Src.w;
+ Dest.h := Src.h;
+ with DestSurface.Clip_Rect do
+ begin
+ // Source's right side is greater than the dest.cliprect
+ if Dest.x + Src.w > x + w then
+ begin
+ smallint( Src.w ) := x + w - Dest.x;
+ smallint( Dest.w ) := x + w - Dest.x;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's bottom side is greater than the dest.clip
+ if Dest.y + Src.h > y + h then
+ begin
+ smallint( Src.h ) := y + h - Dest.y;
+ smallint( Dest.h ) := y + h - Dest.y;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ // Source's left side is less than the dest.clip
+ if Dest.x < x then
+ begin
+ Diff := x - Dest.x;
+ Src.x := Src.x + Diff;
+ smallint( Src.w ) := smallint( Src.w ) - Diff;
+ Dest.x := x;
+ smallint( Dest.w ) := smallint( Dest.w ) - Diff;
+ if smallint( Dest.w ) < 1 then
+ exit;
+ end;
+ // Source's Top side is less than the dest.clip
+ if Dest.y < y then
+ begin
+ Diff := y - Dest.y;
+ Src.y := Src.y + Diff;
+ smallint( Src.h ) := smallint( Src.h ) - Diff;
+ Dest.y := y;
+ smallint( Dest.h ) := smallint( Dest.h ) - Diff;
+ if smallint( Dest.h ) < 1 then
+ exit;
+ end;
+ end;
+ with SrcSurface^ do
+ begin
+ SrcAddr := cardinal( Pixels ) + UInt32( Src.y ) * Pitch + UInt32( Src.x ) *
+ Format.BytesPerPixel;
+ SrcMod := Pitch - Src.w * Format.BytesPerPixel;
+ TransparentColor := Format.colorkey;
+ end;
+ with DestSurface^ do
+ begin
+ DestAddr := cardinal( Pixels ) + UInt32( Dest.y ) * Pitch + UInt32( Dest.x ) *
+ Format.BytesPerPixel;
+ DestMod := Pitch - Dest.w * Format.BytesPerPixel;
+ Bits := Format.BitsPerPixel;
+ end;
+ SDL_LockSurface( SrcSurface );
+ SDL_LockSurface( DestSurface );
+ WorkY := Src.h;
+ case bits of
+ 8 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt8( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt8( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+ if Pixel2 and $E0 < Pixel1 and $E0 then
+ R := Pixel2 and $E0
+ else
+ R := Pixel1 and $E0;
+ if Pixel2 and $1C < Pixel1 and $1C then
+ G := Pixel2 and $1C
+ else
+ G := Pixel1 and $1C;
+ if Pixel2 and $03 < Pixel1 and $03 then
+ B := Pixel2 and $03
+ else
+ B := Pixel1 and $03;
+
+ if R > $E0 then
+ R := $E0;
+ if G > $1C then
+ G := $1C;
+ if B > $03 then
+ B := $03;
+ PUInt8( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt8( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr );
+ inc( DestAddr );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 15 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $7C00 < Pixel1 and $7C00 then
+ R := Pixel2 and $7C00
+ else
+ R := Pixel1 and $7C00;
+ if Pixel2 and $03E0 < Pixel1 and $03E0 then
+ G := Pixel2 and $03E0
+ else
+ G := Pixel1 and $03E0;
+ if Pixel2 and $001F < Pixel1 and $001F then
+ B := Pixel2 and $001F
+ else
+ B := Pixel1 and $001F;
+
+ PUInt16( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt16( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 16 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt16( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt16( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $F800 < Pixel1 and $F800 then
+ R := Pixel2 and $F800
+ else
+ R := Pixel1 and $F800;
+ if Pixel2 and $07E0 < Pixel1 and $07E0 then
+ G := Pixel2 and $07E0
+ else
+ G := Pixel1 and $07E0;
+ if Pixel2 and $001F < Pixel1 and $001F then
+ B := Pixel2 and $001F
+ else
+ B := Pixel1 and $001F;
+
+ PUInt16( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt16( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 2 );
+ inc( DestAddr, 2 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 24 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^ and $00FFFFFF;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^ and $00FFFFFF;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $FF0000 < Pixel1 and $FF0000 then
+ R := Pixel2 and $FF0000
+ else
+ R := Pixel1 and $FF0000;
+ if Pixel2 and $00FF00 < Pixel1 and $00FF00 then
+ G := Pixel2 and $00FF00
+ else
+ G := Pixel1 and $00FF00;
+ if Pixel2 and $0000FF < Pixel1 and $0000FF then
+ B := Pixel2 and $0000FF
+ else
+ B := Pixel1 and $0000FF;
+
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or ( R or G or B );
+ end
+ else
+ PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or Pixel1;
+ end;
+ inc( SrcAddr, 3 );
+ inc( DestAddr, 3 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ 32 :
+ begin
+ repeat
+ WorkX := Src.w;
+ repeat
+ Pixel1 := PUInt32( SrcAddr )^;
+ if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then
+ begin
+ Pixel2 := PUInt32( DestAddr )^;
+ if Pixel2 > 0 then
+ begin
+
+ if Pixel2 and $FF0000 < Pixel1 and $FF0000 then
+ R := Pixel2 and $FF0000
+ else
+ R := Pixel1 and $FF0000;
+ if Pixel2 and $00FF00 < Pixel1 and $00FF00 then
+ G := Pixel2 and $00FF00
+ else
+ G := Pixel1 and $00FF00;
+ if Pixel2 and $0000FF < Pixel1 and $0000FF then
+ B := Pixel2 and $0000FF
+ else
+ B := Pixel1 and $0000FF;
+
+ PUInt32( DestAddr )^ := R or G or B;
+ end
+ else
+ PUInt32( DestAddr )^ := Pixel1;
+ end;
+ inc( SrcAddr, 4 );
+ inc( DestAddr, 4 );
+ dec( WorkX );
+ until WorkX = 0;
+ inc( SrcAddr, SrcMod );
+ inc( DestAddr, DestMod );
+ dec( WorkY );
+ until WorkY = 0;
+ end;
+ end;
+ SDL_UnlockSurface( SrcSurface );
+ SDL_UnlockSurface( DestSurface );
+end;
+
+// Will clip the x1,x2,y1,x2 params to the ClipRect provided
+
+function SDL_ClipLine( var x1, y1, x2, y2 : Integer; ClipRect : PSDL_Rect ) : boolean;
+var
+ tflag, flag1, flag2 : word;
+ txy, xedge, yedge : Integer;
+ slope : single;
+
+ function ClipCode( x, y : Integer ) : word;
+ begin
+ Result := 0;
+ if x < ClipRect.x then
+ Result := 1;
+ if x >= ClipRect.w + ClipRect.x then
+ Result := Result or 2;
+ if y < ClipRect.y then
+ Result := Result or 4;
+ if y >= ClipRect.h + ClipRect.y then
+ Result := Result or 8;
+ end;
+
+begin
+ flag1 := ClipCode( x1, y1 );
+ flag2 := ClipCode( x2, y2 );
+ result := true;
+
+ while true do
+ begin
+ if ( flag1 or flag2 ) = 0 then
+ Exit; // all in
+
+ if ( flag1 and flag2 ) <> 0 then
+ begin
+ result := false;
+ Exit; // all out
+ end;
+
+ if flag2 = 0 then
+ begin
+ txy := x1; x1 := x2; x2 := txy;
+ txy := y1; y1 := y2; y2 := txy;
+ tflag := flag1; flag1 := flag2; flag2 := tflag;
+ end;
+
+ if ( flag2 and 3 ) <> 0 then
+ begin
+ if ( flag2 and 1 ) <> 0 then
+ xedge := ClipRect.x
+ else
+ xedge := ClipRect.w + ClipRect.x - 1; // back 1 pixel otherwise we end up in a loop
+
+ slope := ( y2 - y1 ) / ( x2 - x1 );
+ y2 := y1 + Round( slope * ( xedge - x1 ) );
+ x2 := xedge;
+ end
+ else
+ begin
+ if ( flag2 and 4 ) <> 0 then
+ yedge := ClipRect.y
+ else
+ yedge := ClipRect.h + ClipRect.y - 1; // up 1 pixel otherwise we end up in a loop
+
+ slope := ( x2 - x1 ) / ( y2 - y1 );
+ x2 := x1 + Round( slope * ( yedge - y1 ) );
+ y2 := yedge;
+ end;
+
+ flag2 := ClipCode( x2, y2 );
+ end;
+end;
+
+end.
+
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlwindow.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlwindow.pas new file mode 100644 index 00000000..ba60714b --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/sdlwindow.pas @@ -0,0 +1,566 @@ +unit sdlwindow;
+{
+ $Id: sdlwindow.pas,v 1.9 2006/10/22 18:55:25 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer }
+{ SDL Window Wrapper }
+{ }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Dominique Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Portions created by Dominique Louis are }
+{ Copyright (C) 2004 - 2100 Dominique Louis. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ Dominique Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ SDL Window Wrapper }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ SDL.dll on Windows platforms }
+{ libSDL-1.1.so.0 on Linux platform }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ January 31 2003 - DL : Initial creation }
+{ }
+{
+ $Log: sdlwindow.pas,v $
+ Revision 1.9 2006/10/22 18:55:25 savage
+ Slight Change to handle OpenGL context
+
+ Revision 1.8 2005/08/03 18:57:32 savage
+ Various updates and additions. Mainly to handle OpenGL 3D Window support and better cursor support for the mouse class
+
+ Revision 1.7 2004/09/30 22:35:47 savage
+ Changes, enhancements and additions as required to get SoAoS working.
+
+ Revision 1.6 2004/09/12 21:52:58 savage
+ Slight changes to fix some issues with the sdl classes.
+
+ Revision 1.5 2004/05/10 21:11:49 savage
+ changes required to help get SoAoS off the ground.
+
+ Revision 1.4 2004/05/01 14:59:27 savage
+ Updated code
+
+ Revision 1.3 2004/04/23 10:45:28 savage
+ Changes made by Dean Ellis to work more modularly.
+
+ Revision 1.2 2004/03/31 10:06:41 savage
+ Changed so that it now compiles, but is untested.
+
+ Revision 1.1 2004/02/05 00:08:20 savage
+ Module 1.0 release
+
+}
+{******************************************************************************}
+
+interface
+
+{$i jedi-sdl.inc}
+
+uses
+ Classes,
+ sdl,
+ sdlinput,
+ sdlticks;
+
+type
+ TSDLNotifyEvent = procedure {$IFNDEF NOT_OO}of object{$ENDIF};
+ TSDLUpdateEvent = procedure( aElapsedTime : single ) {$IFNDEF NOT_OO}of object{$ENDIF};
+ TSDLResizeEvent = procedure( aWidth : integer; aHeight : integer; aBitDepth : integer; aVideoFlags : Uint32 ) {$IFNDEF NOT_OO}of object{$ENDIF};
+ TSDLUserEvent = procedure( aType : UInt8; aCode : integer; aData1 : Pointer; aData2 : Pointer ) {$IFNDEF NOT_OO}of object{$ENDIF};
+ TSDLActiveEvent = procedure( aGain: UInt8; aState: UInt8 ) {$IFNDEF NOT_OO}of object{$ENDIF};
+
+ TSDLBaseWindow = class( TObject )
+ private
+ FDisplaySurface : PSDL_Surface;
+ FVideoFlags : Uint32;
+ FOnDestroy: TSDLNotifyEvent;
+ FOnCreate: TSDLNotifyEvent;
+ FOnShow: TSDLNotifyEvent;
+ FOnResize: TSDLResizeEvent;
+ FOnUpdate: TSDLUpdateEvent;
+ FOnRender: TSDLNotifyEvent;
+ FOnClose: TSDLNotifyEvent;
+ FLoaded: Boolean;
+ FRendering: Boolean;
+ FHeight: integer;
+ FBitDepth: integer;
+ FWidth: integer;
+ FInputManager: TSDLInputManager;
+ FCaptionText : PChar;
+ FIconName : PChar;
+ FOnActive: TSDLActiveEvent;
+ FOnQuit: TSDLNotifyEvent;
+ FOnExpose: TSDLNotifyEvent;
+ FOnUser: TSDLUserEvent;
+ FTimer : TSDLTicks;
+ protected
+ procedure DoActive( aGain: UInt8; aState: UInt8 );
+ procedure DoCreate;
+ procedure DoClose;
+ procedure DoDestroy;
+ procedure DoUpdate( aElapsedTime : single );
+ procedure DoQuit;
+ procedure DoRender;
+ procedure DoResize( aWidth : integer; aHeight : integer; aBitDepth : integer; aVideoFlags : Uint32 );
+ procedure DoShow;
+ procedure DoUser( aType : UInt8; aCode : integer; aData1 : Pointer; aData2 : Pointer );
+ procedure DoExpose;
+ procedure Render; virtual;
+ procedure Update( aElapsedTime : single ); virtual;
+ procedure InitialiseObjects; virtual;
+ procedure RestoreObjects; virtual;
+ procedure DeleteObjects; virtual;
+ function Flip : integer; virtual;
+ property OnActive : TSDLActiveEvent read FOnActive write FOnActive;
+ property OnClose: TSDLNotifyEvent read FOnClose write FOnClose;
+ property OnDestroy : TSDLNotifyEvent read FOnDestroy write FOnDestroy;
+ property OnCreate : TSDLNotifyEvent read FOnCreate write FOnCreate;
+ property OnUpdate: TSDLUpdateEvent read FOnUpdate write FOnUpdate;
+ property OnQuit : TSDLNotifyEvent read FOnQuit write FOnQuit;
+ property OnResize : TSDLResizeEvent read FOnResize write FOnResize;
+ property OnRender: TSDLNotifyEvent read FOnRender write FOnRender;
+ property OnShow : TSDLNotifyEvent read FOnShow write FOnShow;
+ property OnUser : TSDLUserEvent read FOnUser write FOnUser;
+ property OnExpose : TSDLNotifyEvent read FOnExpose write FOnExpose;
+ property DisplaySurface: PSDL_Surface read FDisplaySurface;
+ public
+ property InputManager : TSDLInputManager read FInputManager;
+ property Loaded : Boolean read FLoaded;
+ property Width : integer read FWidth;
+ property Height : integer read FHeight;
+ property BitDepth : integer read FBitDepth;
+ property Rendering : Boolean read FRendering write FRendering;
+ procedure SetCaption( const aCaptionText : string; const aIconName : string );
+ procedure GetCaption( var aCaptionText : string; var aIconName : string );
+ procedure SetIcon( aIcon : PSDL_Surface; aMask: UInt8 );
+ procedure ActivateVideoMode;
+ constructor Create( aWidth : integer; aHeight : integer; aBitDepth : integer; aVideoFlags : Uint32 ); virtual;
+ destructor Destroy; override;
+ procedure InitialiseEnvironment;
+ function Show : Boolean; virtual;
+ end;
+
+ TSDLCustomWindow = class( TSDLBaseWindow )
+ public
+ property OnCreate;
+ property OnDestroy;
+ property OnClose;
+ property OnShow;
+ property OnResize;
+ property OnRender;
+ property OnUpdate;
+ property DisplaySurface;
+ end;
+
+ TSDL2DWindow = class( TSDLCustomWindow )
+ public
+ constructor Create( aWidth : integer; aHeight : integer; aBitDepth : integer; aVideoFlags : Uint32 = SDL_DOUBLEBUF or SDL_SWSURFACE); override;
+ procedure Render; override;
+ procedure Update( aElapsedTime : single ); override;
+ procedure InitialiseObjects; override;
+ procedure RestoreObjects; override;
+ procedure DeleteObjects; override;
+ function Flip : integer; override;
+ end;
+
+ TSDL3DWindow = class( TSDLCustomWindow )
+ public
+ constructor Create( aWidth : integer; aHeight : integer; aBitDepth : integer; aVideoFlags : Uint32 = SDL_OPENGL or SDL_DOUBLEBUF); override;
+ function Flip : integer; override;
+ procedure Render; override;
+ procedure Update( aElapsedTime : single ); override;
+ procedure InitialiseObjects; override;
+ procedure RestoreObjects; override;
+ procedure DeleteObjects; override;
+ end;
+
+
+
+implementation
+
+uses
+ logger,
+ SysUtils;
+
+{ TSDLBaseWindow }
+procedure TSDLBaseWindow.ActivateVideoMode;
+begin
+ FDisplaySurface := SDL_SetVideoMode( FWidth, FHeight, FBitDepth, FVideoFlags);
+ if (FDisplaySurface = nil) then
+ begin
+ Log.LogError( Format('Could not set video mode: %s', [SDL_GetError]), 'Main');
+ exit;
+ end;
+
+ SetCaption( 'Made with JEDI-SDL', 'JEDI-SDL Icon' );
+end;
+
+constructor TSDLBaseWindow.Create( aWidth : integer; aHeight : integer; aBitDepth : integer; aVideoFlags : Uint32 );
+begin
+ inherited Create;
+ SDL_Init(SDL_INIT_EVERYTHING);
+ FInputManager := TSDLInputManager.Create( [ itJoystick, itKeyBoard, itMouse ]);
+ FTimer := TSDLTicks.Create;
+
+ FWidth := aWidth;
+ FHeight := aHeight;
+ FBitDepth := aBitDepth;
+ FVideoFlags := aVideoFlags;
+
+ DoCreate;
+end;
+
+procedure TSDLBaseWindow.DeleteObjects;
+begin
+ FLoaded := False;
+end;
+
+destructor TSDLBaseWindow.Destroy;
+begin
+ DoDestroy;
+ if FLoaded then
+ DeleteObjects;
+ if FInputManager <> nil then
+ FreeAndNil( FInputManager );
+ if FTimer <> nil then
+ FreeAndNil( FTimer );
+ if FDisplaySurface <> nil then
+ SDL_FreeSurface( FDisplaySurface );
+ inherited Destroy;
+ SDL_Quit;
+end;
+
+procedure TSDLBaseWindow.DoActive(aGain, aState: UInt8);
+begin
+ if Assigned( FOnActive ) then
+ begin
+ FOnActive( aGain, aState );
+ end;
+end;
+
+procedure TSDLBaseWindow.DoClose;
+begin
+ if Assigned( FOnClose ) then
+ begin
+ FOnClose;
+ end;
+end;
+
+procedure TSDLBaseWindow.DoCreate;
+begin
+ if Assigned( FOnCreate ) then
+ begin
+ FOnCreate;
+ end;
+end;
+
+procedure TSDLBaseWindow.DoDestroy;
+begin
+ if Assigned( FOnDestroy ) then
+ begin
+ FOnDestroy;
+ end;
+end;
+
+procedure TSDLBaseWindow.DoExpose;
+begin
+ if Assigned( FOnExpose ) then
+ begin
+ FOnExpose;
+ end;
+end;
+
+procedure TSDLBaseWindow.DoUpdate( aElapsedTime : single );
+begin
+ if Assigned( FOnUpdate ) then
+ begin
+ FOnUpdate( aElapsedTime );
+ end;
+end;
+
+procedure TSDLBaseWindow.DoQuit;
+begin
+ FRendering := false;
+ if Assigned( FOnQuit ) then
+ begin
+ FOnQuit;
+ end;
+end;
+
+procedure TSDLBaseWindow.DoRender;
+begin
+ if Assigned( FOnRender ) then
+ begin
+ FOnRender;
+ end;
+end;
+
+procedure TSDLBaseWindow.DoResize( aWidth : integer; aHeight : integer; aBitDepth : integer; aVideoFlags : Uint32 );
+begin
+ // resize to the new size
+ SDL_FreeSurface(FDisplaySurface);
+ FWidth := aWidth;
+ FHeight := aHeight;
+ FBitDepth := aBitDepth;
+ FVideoFlags := aVideoFlags;
+ FDisplaySurface := SDL_SetVideoMode(aWidth, aHeight, aBitDepth, aVideoFlags);
+ if Assigned( FOnResize ) then
+ begin
+ FOnResize( aWidth, aHeight, aBitDepth, aVideoFlags );
+ end;
+end;
+
+procedure TSDLBaseWindow.DoShow;
+begin
+ if Assigned( FOnShow ) then
+ begin
+ FOnShow;
+ end;
+end;
+
+procedure TSDLBaseWindow.DoUser(aType: UInt8; aCode: integer; aData1, aData2: Pointer);
+begin
+ if Assigned( FOnUser ) then
+ begin
+ FOnUser( aType, aCode, aData1, aData2 );
+ end;
+end;
+
+function TSDLBaseWindow.Flip : integer;
+begin
+ result := 0;
+end;
+
+procedure TSDLBaseWindow.GetCaption( var aCaptionText : string; var aIconName : string );
+begin
+ aCaptionText := string( FCaptionText );
+ aIconName := string( FIconName );
+end;
+
+procedure TSDLBaseWindow.InitialiseEnvironment;
+begin
+ InitialiseObjects;
+ RestoreObjects;
+end;
+
+procedure TSDLBaseWindow.InitialiseObjects;
+begin
+ FLoaded := True;
+end;
+
+procedure TSDLBaseWindow.Update( aElapsedTime : single );
+begin
+ DoUpdate( aElapsedTime );
+end;
+
+procedure TSDLBaseWindow.Render;
+begin
+ DoRender;
+end;
+
+procedure TSDLBaseWindow.RestoreObjects;
+begin
+ FLoaded := false;
+end;
+
+procedure TSDLBaseWindow.SetCaption( const aCaptionText : string; const aIconName : string );
+begin
+ if FCaptionText <> aCaptionText then
+ begin
+ FCaptionText := PChar( aCaptionText );
+ FIconName := PChar( aIconName );
+ SDL_WM_SetCaption( FCaptionText, FIconName );
+ end;
+end;
+
+procedure TSDLBaseWindow.SetIcon(aIcon: PSDL_Surface; aMask: UInt8);
+begin
+ SDL_WM_SetIcon( aIcon, aMask );
+end;
+
+function TSDLBaseWindow.Show : Boolean;
+var
+ eBaseWindowEvent : TSDL_Event;
+begin
+ DoShow;
+
+ FTimer.Init;
+
+ FRendering := true;
+ // repeat until we are told not to render
+ while FRendering do
+ begin
+ // wait for an event
+ while SDL_PollEvent( @eBaseWindowEvent ) > 0 do
+ begin
+
+ // check for a quit event
+ case eBaseWindowEvent.type_ of
+ SDL_ACTIVEEVENT :
+ begin
+ DoActive( eBaseWindowEvent.active.gain, eBaseWindowEvent.active.state );
+ end;
+
+ SDL_QUITEV :
+ begin
+ DoQuit;
+ DoClose;
+ end;
+
+ SDL_USEREVENT :
+ begin
+ DoUser( eBaseWindowEvent.user.type_, eBaseWindowEvent.user.code, eBaseWindowEvent.user.data1, eBaseWindowEvent.user.data2 );
+ end;
+
+ SDL_VIDEOEXPOSE :
+ begin
+ DoExpose;
+ end;
+
+ SDL_VIDEORESIZE :
+ begin
+ DoResize( eBaseWindowEvent.resize.w, eBaseWindowEvent.resize.h, FDisplaySurface.format.BitsPerPixel, FVideoflags );
+ end;
+
+
+ end;
+ InputManager.UpdateInputs( eBaseWindowEvent );
+ end;
+ // Prepare the Next Frame
+ Update( FTimer.GetElapsedSeconds );
+ // Display the Next Frame
+ Render;
+ // Flip the surfaces
+ Flip;
+ end;
+
+ Result := FRendering;
+end;
+
+{ TSDL2DWindow }
+
+constructor TSDL2DWindow.Create(aWidth, aHeight, aBitDepth: integer; aVideoFlags: Uint32);
+begin
+ // make sure double buffer is always included in the video flags
+ inherited Create(aWidth,aHeight, aBitDepth, aVideoFlags or SDL_DOUBLEBUF);
+end;
+
+procedure TSDL2DWindow.DeleteObjects;
+begin
+ inherited;
+
+end;
+
+function TSDL2DWindow.Flip: integer;
+begin
+ // let's show the back buffer
+ result := SDL_Flip( FDisplaySurface );
+end;
+
+procedure TSDL2DWindow.InitialiseObjects;
+begin
+ inherited;
+
+end;
+
+procedure TSDL2DWindow.Update( aElapsedTime : single );
+begin
+ inherited;
+
+end;
+
+procedure TSDL2DWindow.Render;
+begin
+ inherited;
+
+end;
+
+procedure TSDL2DWindow.RestoreObjects;
+begin
+ inherited;
+
+end;
+
+{ TSDL3DWindow }
+
+constructor TSDL3DWindow.Create(aWidth,
+ aHeight, aBitDepth: integer; aVideoFlags: Uint32);
+begin
+ // make sure opengl is always included in the video flags
+ inherited Create(aWidth,aHeight, aBitDepth, aVideoFlags or SDL_OPENGL or SDL_DOUBLEBUF);
+end;
+
+procedure TSDL3DWindow.DeleteObjects;
+begin
+ inherited;
+
+end;
+
+function TSDL3DWindow.Flip : integer;
+begin
+ SDL_GL_SwapBuffers;
+ result := 0;
+end;
+
+procedure TSDL3DWindow.InitialiseObjects;
+begin
+ inherited;
+
+end;
+
+procedure TSDL3DWindow.Update( aElapsedTime : single );
+begin
+ inherited;
+
+end;
+
+procedure TSDL3DWindow.Render;
+begin
+ inherited;
+
+end;
+
+procedure TSDL3DWindow.RestoreObjects;
+begin
+ inherited;
+
+end;
+
+end.
diff --git a/Game/Code/lib/JEDI-SDL/SDL/Pas/userpreferences.pas b/Game/Code/lib/JEDI-SDL/SDL/Pas/userpreferences.pas new file mode 100644 index 00000000..97e26520 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL/Pas/userpreferences.pas @@ -0,0 +1,159 @@ +unit userpreferences;
+{
+ $Id: userpreferences.pas,v 1.1 2004/09/30 22:35:47 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer }
+{ Base Class for User Preferences }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Dominqiue Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Portions created by Dominqiue Louis are }
+{ Copyright (C) 2000 - 2001 Dominqiue Louis. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so }
+{ They are available from... }
+{ http://www.libsdl.org . }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ September 23 2004 - DL : Initial Creation }
+{
+ $Log: userpreferences.pas,v $
+ Revision 1.1 2004/09/30 22:35:47 savage
+ Changes, enhancements and additions as required to get SoAoS working.
+
+
+}
+{******************************************************************************}
+
+interface
+
+uses
+ Classes;
+
+type
+ TUserPreferences = class
+ private
+ FAutoSave: Boolean;
+ procedure CheckAutoSave;
+ protected
+ function GetDefaultBoolean( const Index : Integer ) : Boolean; virtual; abstract;
+ function GetBoolean( const Index : Integer ) : Boolean; virtual; abstract;
+ procedure SetBoolean( const Index : Integer; const Value : Boolean ); virtual;
+ function GetDefaultDateTime( const Index : Integer ) : TDateTime; virtual; abstract;
+ function GetDateTime( const Index : Integer ) : TDateTime; virtual; abstract;
+ procedure SetDateTime( const Index : Integer; const Value : TDateTime ); virtual;
+ function GetDefaultInteger( const Index : Integer ) : Integer; virtual; abstract;
+ function GetInteger( const Index : Integer ) : Integer; virtual; abstract;
+ procedure SetInteger( const Index : Integer; const Value : Integer ); virtual;
+ function GetDefaultFloat( const Index : Integer ) : single; virtual; abstract;
+ function GetFloat( const Index : Integer ) : single; virtual; abstract;
+ procedure SetFloat( const Index : Integer; const Value : single ); virtual;
+ function GetDefaultString( const Index : Integer ) : string; virtual; abstract;
+ function GetString( const Index : Integer ) : string; virtual; abstract;
+ procedure SetString( const Index : Integer; const Value : string ); virtual;
+ function GetDefaultBinaryStream( const Index : Integer ) : TStream; virtual; abstract;
+ function GetBinaryStream( const Index : Integer ) : TStream; virtual; abstract;
+ procedure SetBinaryStream( const Index : Integer; const Value : TStream ); virtual;
+ public
+ procedure Update; virtual; abstract;
+ constructor Create; virtual;
+ destructor Destroy; override;
+ property AutoSave : Boolean read FAutoSave write FAutoSave;
+ end;
+
+implementation
+
+{ TUserPreferences }
+procedure TUserPreferences.CheckAutoSave;
+begin
+ if FAutoSave then
+ Update;
+end;
+
+constructor TUserPreferences.Create;
+begin
+ inherited;
+ FAutoSave := false;
+end;
+
+destructor TUserPreferences.Destroy;
+begin
+
+ inherited;
+end;
+
+procedure TUserPreferences.SetBinaryStream( const Index : Integer; const Value : TStream );
+begin
+ CheckAutoSave;
+end;
+
+procedure TUserPreferences.SetBoolean(const Index: Integer; const Value: Boolean);
+begin
+ CheckAutoSave;
+end;
+
+procedure TUserPreferences.SetDateTime(const Index: Integer; const Value: TDateTime);
+begin
+ CheckAutoSave;
+end;
+
+procedure TUserPreferences.SetFloat(const Index: Integer; const Value: single);
+begin
+ CheckAutoSave;
+end;
+
+procedure TUserPreferences.SetInteger(const Index, Value: Integer);
+begin
+ CheckAutoSave;
+end;
+
+procedure TUserPreferences.SetString(const Index: Integer; const Value: string);
+begin
+ CheckAutoSave;
+end;
+
+end.
diff --git a/Game/Code/lib/JEDI-SDL/SDL_Image/Pas/sdl_image.pas b/Game/Code/lib/JEDI-SDL/SDL_Image/Pas/sdl_image.pas new file mode 100644 index 00000000..d0699761 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL_Image/Pas/sdl_image.pas @@ -0,0 +1,349 @@ +unit sdl_image;
+{
+ $Id: sdl_image.pas,v 1.15 2007/12/05 22:52:23 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ Borland Delphi SDL_Image - An example image loading library for use }
+{ with SDL }
+{ Conversion of the Simple DirectMedia Layer Image Headers }
+{ }
+{ Portions created by Sam Lantinga <slouken@devolution.com> are }
+{ Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga }
+{ 5635-34 Springhouse Dr. }
+{ Pleasanton, CA 94588 (USA) }
+{ }
+{ All Rights Reserved. }
+{ }
+{ The original files are : SDL_image.h }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Matthias Thoma <ma.thoma@gmx.de> }
+{ }
+{ Portions created by Matthias Thoma are }
+{ Copyright (C) 2000 - 2001 Matthias Thoma. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ Dominique Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ A simple library to load images of various formats as SDL surfaces }
+{ }
+{ Requires }
+{ -------- }
+{ SDL.pas in your search path. }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ See the Aliens Demo on how to make use of this libaray }
+{ }
+{ Revision History }
+{ ---------------- }
+{ April 02 2001 - MT : Initial Translation }
+{ }
+{ May 08 2001 - DL : Added ExternalSym derectives and copyright header }
+{ }
+{ April 03 2003 - DL : Added jedi-sdl.inc include file to support more }
+{ Pascal compilers. Initial support is now included }
+{ for GnuPascal, VirtualPascal, TMT and obviously }
+{ continue support for Delphi Kylix and FreePascal. }
+{ }
+{ April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support }
+{ }
+{ April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added}
+{ better TMT Pascal support and under instruction }
+{ from Prof. Abimbola Olowofoyeku (The African Chief),}
+{ I have added better Gnu Pascal support }
+{ }
+{ April 30 2003 - DL : under instruction from David Mears AKA }
+{ Jason Siletto, I have added FPC Linux support. }
+{ This was compiled with fpc 1.1, so remember to set }
+{ include file path. ie. -Fi/usr/share/fpcsrc/rtl/* }
+{ }
+{
+ $Log: sdl_image.pas,v $
+ Revision 1.15 2007/12/05 22:52:23 savage
+ Better Mac OS X support for Frameworks.
+
+ Revision 1.14 2007/05/29 21:31:13 savage
+ Changes as suggested by Almindor for 64bit compatibility.
+
+ Revision 1.13 2007/05/20 20:30:54 savage
+ Initial Changes to Handle 64 Bits
+
+ Revision 1.12 2006/12/02 00:14:40 savage
+ Updated to latest version
+
+ Revision 1.11 2005/04/10 18:22:59 savage
+ Changes as suggested by Michalis, thanks.
+
+ Revision 1.10 2005/04/10 11:48:33 savage
+ Changes as suggested by Michalis, thanks.
+
+ Revision 1.9 2005/01/05 01:47:07 savage
+ Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
+
+ Revision 1.8 2005/01/04 23:14:44 savage
+ Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
+
+ Revision 1.7 2005/01/01 02:03:12 savage
+ Updated to v1.2.4
+
+ Revision 1.6 2004/08/14 22:54:30 savage
+ Updated so that Library name defines are correctly defined for MacOS X.
+
+ Revision 1.5 2004/05/10 14:10:04 savage
+ Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
+
+ Revision 1.4 2004/04/13 09:32:08 savage
+ Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
+
+ Revision 1.3 2004/04/01 20:53:23 savage
+ Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
+
+ Revision 1.2 2004/03/30 20:23:28 savage
+ Tidied up use of UNIX compiler directive.
+
+ Revision 1.1 2004/02/14 23:35:42 savage
+ version 1 of sdl_image, sdl_mixer and smpeg.
+
+
+}
+{******************************************************************************}
+
+{$I jedi-sdl.inc}
+
+interface
+
+uses
+{$IFDEF __GPC__}
+ gpc,
+{$ENDIF}
+ sdl;
+
+const
+{$IFDEF WINDOWS}
+ SDL_ImageLibName = 'SDL_Image.dll';
+{$ENDIF}
+
+{$IFDEF UNIX}
+{$IFDEF DARWIN}
+ SDL_ImageLibName = 'libSDL_image-1.2.0.dylib';
+{$ELSE}
+ {$IFDEF FPC}
+ SDL_ImageLibName = 'libSDL_image.so';
+ {$ELSE}
+ SDL_ImageLibName = 'libSDL_image-1.2.so.0';
+ {$ENDIF}
+{$ENDIF}
+{$ENDIF}
+
+{$IFDEF MACOS}
+ SDL_ImageLibName = 'SDL_image';
+ {$linklib libSDL_image}
+{$ENDIF}
+
+ // Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
+ SDL_IMAGE_MAJOR_VERSION = 1;
+{$EXTERNALSYM SDL_IMAGE_MAJOR_VERSION}
+ SDL_IMAGE_MINOR_VERSION = 2;
+{$EXTERNALSYM SDL_IMAGE_MINOR_VERSION}
+ SDL_IMAGE_PATCHLEVEL = 6;
+{$EXTERNALSYM SDL_IMAGE_PATCHLEVEL}
+
+{ This macro can be used to fill a version structure with the compile-time
+ version of the SDL_image library. }
+procedure SDL_IMAGE_VERSION( var X : TSDL_Version );
+{$EXTERNALSYM SDL_IMAGE_VERSION}
+
+{ This function gets the version of the dynamically linked SDL_image library.
+ it should NOT be used to fill a version structure, instead you should
+ use the SDL_IMAGE_VERSION() macro.
+ }
+function IMG_Linked_Version : PSDL_version;
+external {$IFDEF __GPC__}name 'IMG_Linked_Version'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_Linked_Version}
+
+{ Load an image from an SDL data source.
+ The 'type' may be one of: "BMP", "GIF", "PNG", etc.
+
+ If the image format supports a transparent pixel, SDL will set the
+ colorkey for the surface. You can enable RLE acceleration on the
+ surface afterwards by calling:
+ SDL_SetColorKey(image, SDL_RLEACCEL, image.format.colorkey);
+}
+function IMG_LoadTyped_RW(src: PSDL_RWops; freesrc: Integer; _type: PChar): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadTyped_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadTyped_RW}
+{ Convenience functions }
+function IMG_Load(const _file: PChar): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_Load'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_Load}
+function IMG_Load_RW(src: PSDL_RWops; freesrc: Integer): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_Load_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_Load_RW}
+
+{ Invert the alpha of a surface for use with OpenGL
+ This function is now a no-op, and only provided for backwards compatibility. }
+function IMG_InvertAlpha(_on: Integer): Integer;
+cdecl; external {$IFDEF __GPC__}name 'IMG_InvertAlpha'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_InvertAlpha}
+
+{ Functions to detect a file type, given a seekable source }
+function IMG_isBMP(src: PSDL_RWops): Integer;
+cdecl; external {$IFDEF __GPC__}name 'IMG_isBMP'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_isBMP}
+
+function IMG_isGIF(src: PSDL_RWops): Integer;
+cdecl; external {$IFDEF __GPC__}name 'IMG_isGIF'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_isGIF}
+
+function IMG_isJPG(src: PSDL_RWops): Integer;
+cdecl; external {$IFDEF __GPC__}name 'IMG_isJPG'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_isJPG}
+
+function IMG_isLBM(src: PSDL_RWops): Integer;
+cdecl; external {$IFDEF __GPC__}name 'IMG_isLBM'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_isLBM}
+
+function IMG_isPCX(src: PSDL_RWops): Integer;
+cdecl; external {$IFDEF __GPC__}name 'IMG_isPCX'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_isPCX}
+
+function IMG_isPNG(src: PSDL_RWops): Integer;
+cdecl; external {$IFDEF __GPC__}name 'IMG_isPNG'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_isPNG}
+
+function IMG_isPNM(src: PSDL_RWops): Integer;
+cdecl; external {$IFDEF __GPC__}name 'IMG_isPNM'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_isPNM}
+
+function IMG_isTIF(src: PSDL_RWops): Integer;
+cdecl; external {$IFDEF __GPC__}name 'IMG_isTIF'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_isTIF}
+
+function IMG_isXCF(src: PSDL_RWops): Integer;
+cdecl; external {$IFDEF __GPC__}name 'IMG_isXCF'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_isXCF}
+
+function IMG_isXPM(src: PSDL_RWops): Integer;
+cdecl; external {$IFDEF __GPC__}name 'IMG_isXPM'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_isXPM}
+
+function IMG_isXV(src: PSDL_RWops): Integer;
+cdecl; external {$IFDEF __GPC__}name 'IMG_isXV'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_isXV}
+
+
+{ Individual loading functions }
+function IMG_LoadBMP_RW(src: PSDL_RWops): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadBMP_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadBMP_RW}
+
+function IMG_LoadGIF_RW(src: PSDL_RWops): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadGIF_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadGIF_RW}
+
+function IMG_LoadJPG_RW(src: PSDL_RWops): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadJPG_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadJPG_RW}
+
+function IMG_LoadLBM_RW(src: PSDL_RWops): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadLBM_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadLBM_RW}
+
+function IMG_LoadPCX_RW(src: PSDL_RWops): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadPCX_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadPCX_RW}
+
+function IMG_LoadPNM_RW(src: PSDL_RWops): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadPNM_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadPNM_RW}
+
+function IMG_LoadPNG_RW(src: PSDL_RWops): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadPNG_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadPNG_RW}
+
+function IMG_LoadTGA_RW(src: PSDL_RWops): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadTGA_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadTGA_RW}
+
+function IMG_LoadTIF_RW(src: PSDL_RWops): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadTIF_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadTIF_RW}
+
+function IMG_LoadXCF_RW(src: PSDL_RWops): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadXCF_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadXCF_RW}
+
+function IMG_LoadXPM_RW(src: PSDL_RWops): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadXPM_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadXPM_RW}
+
+function IMG_LoadXV_RW(src: PSDL_RWops): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_LoadXV_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_LoadXV_RW}
+
+function IMG_ReadXPMFromArray( xpm : PPChar ): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'IMG_ReadXPMFromArray'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+{$EXTERNALSYM IMG_ReadXPMFromArray}
+
+
+
+
+{ used internally, NOT an exported function }
+//function IMG_string_equals( const str1 : PChar; const str2 : PChar ) : integer;
+//cdecl; external {$IFDEF __GPC__}name 'IMG_string_equals'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__};
+//{ $ EXTERNALSYM IMG_string_equals}
+
+{ Error Macros }
+{ We'll use SDL for reporting errors }
+procedure IMG_SetError( fmt : PChar );
+
+function IMG_GetError : PChar;
+
+implementation
+
+{$IFDEF __GPC__}
+ {$L 'sdl_image'} { link sdl_image.dll.a or libsdl_image.so or libsdl_image.a }
+{$ENDIF}
+
+procedure SDL_IMAGE_VERSION( var X : TSDL_Version );
+begin
+ X.major := SDL_IMAGE_MAJOR_VERSION;
+ X.minor := SDL_IMAGE_MINOR_VERSION;
+ X.patch := SDL_IMAGE_PATCHLEVEL;
+end;
+
+procedure IMG_SetError( fmt : PChar );
+begin
+ SDL_SetError( fmt );
+end;
+
+function IMG_GetError : PChar;
+begin
+ result := SDL_GetError;
+end;
+
+end.
diff --git a/Game/Code/lib/JEDI-SDL/SDL_ttf/Pas/sdl_ttf.pas b/Game/Code/lib/JEDI-SDL/SDL_ttf/Pas/sdl_ttf.pas new file mode 100644 index 00000000..88966f82 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL_ttf/Pas/sdl_ttf.pas @@ -0,0 +1,505 @@ +unit sdl_ttf;
+{
+ $Id: sdl_ttf.pas,v 1.19 2007/12/05 22:54:20 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer }
+{ Conversion of the Simple DirectMedia Layer Headers }
+{ }
+{ Portions created by Sam Lantinga <slouken@devolution.com> are }
+{ Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga }
+{ 5635-34 Springhouse Dr. }
+{ Pleasanton, CA 94588 (USA) }
+{ }
+{ All Rights Reserved. }
+{ }
+{ The original files are : SDL_ttf.h }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Dominqiue Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Portions created by Dominqiue Louis are }
+{ Copyright (C) 2000 - 2001 Dominqiue Louis. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so }
+{ They are available from... }
+{ http://www.libsdl.org . }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ December 08 2002 - DL : Fixed definition of TTF_RenderUnicode_Solid }
+{ }
+{ April 03 2003 - DL : Added jedi-sdl.inc include file to support more }
+{ Pascal compilers. Initial support is now included }
+{ for GnuPascal, VirtualPascal, TMT and obviously }
+{ continue support for Delphi Kylix and FreePascal. }
+{ }
+{ April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added}
+{ better TMT Pascal support and under instruction }
+{ from Prof. Abimbola Olowofoyeku (The African Chief),}
+{ I have added better Gnu Pascal support }
+{ }
+{ April 30 2003 - DL : under instruction from David Mears AKA }
+{ Jason Siletto, I have added FPC Linux support. }
+{ This was compiled with fpc 1.1, so remember to set }
+{ include file path. ie. -Fi/usr/share/fpcsrc/rtl/* }
+{ }
+{
+ $Log: sdl_ttf.pas,v $
+ Revision 1.19 2007/12/05 22:54:20 savage
+ Better Mac OS X support for Frameworks.
+
+ Revision 1.18 2007/06/01 11:16:33 savage
+ Added IFDEF UNIX for Workaround.
+
+ Revision 1.17 2007/06/01 08:38:21 savage
+ Added TTF_RenderText_Solid workaround as suggested by Michalis Kamburelis
+
+ Revision 1.16 2007/05/29 21:32:14 savage
+ Changes as suggested by Almindor for 64bit compatibility.
+
+ Revision 1.15 2007/05/20 20:32:45 savage
+ Initial Changes to Handle 64 Bits
+
+ Revision 1.14 2006/12/02 00:19:01 savage
+ Updated to latest version
+
+ Revision 1.13 2005/04/10 11:48:33 savage
+ Changes as suggested by Michalis, thanks.
+
+ Revision 1.12 2005/01/05 01:47:14 savage
+ Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
+
+ Revision 1.11 2005/01/04 23:14:57 savage
+ Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
+
+ Revision 1.10 2005/01/02 19:07:32 savage
+ Slight bug fix to use LongInt instead of Long ( Thanks Michalis Kamburelis )
+
+ Revision 1.9 2005/01/01 02:15:20 savage
+ Updated to v2.0.7
+
+ Revision 1.8 2004/10/07 21:02:32 savage
+ Fix for FPC
+
+ Revision 1.7 2004/09/30 22:39:50 savage
+ Added a true type font class which contains a wrap text function.
+ Changed the sdl_ttf.pas header to reflect the future of jedi-sdl.
+
+ Revision 1.6 2004/08/14 22:54:30 savage
+ Updated so that Library name defines are correctly defined for MacOS X.
+
+ Revision 1.5 2004/05/10 14:10:04 savage
+ Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
+
+ Revision 1.4 2004/04/13 09:32:08 savage
+ Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
+
+ Revision 1.3 2004/04/01 20:53:24 savage
+ Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
+
+ Revision 1.2 2004/03/30 20:23:28 savage
+ Tidied up use of UNIX compiler directive.
+
+ Revision 1.1 2004/02/16 22:16:40 savage
+ v1.0 changes
+
+
+}
+{******************************************************************************}
+
+{$I jedi-sdl.inc}
+
+{
+ Define this to workaround a known bug in some freetype versions.
+ The error manifests as TTF_RenderGlyph_Solid returning nil (error)
+ and error message (in SDL_Error) is
+ "Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable"
+ See [http://lists.libsdl.org/pipermail/sdl-libsdl.org/2007-March/060459.html]
+}
+{$IFDEF UNIX}
+{$DEFINE Workaround_TTF_RenderText_Solid}
+{$ENDIF}
+
+
+interface
+
+uses
+{$IFDEF __GPC__}
+ gpc,
+{$ENDIF}
+
+{$IFDEF WINDOWS}
+ {$IFNDEF __GPC__}
+ Windows,
+ {$ENDIF}
+{$ENDIF}
+ sdl;
+
+const
+{$IFDEF WINDOWS}
+ SDLttfLibName = 'SDL_ttf.dll';
+{$ENDIF}
+
+{$IFDEF UNIX}
+{$IFDEF DARWIN}
+ SDLttfLibName = 'libSDL_ttf-2.0.0.dylib';
+{$ELSE}
+ {$IFDEF FPC}
+ SDLttfLibName = 'libSDL_ttf.so';
+ {$ELSE}
+ SDLttfLibName = 'libSDL_ttf-2.0.so.0';
+ {$ENDIF}
+{$ENDIF}
+{$ENDIF}
+
+{$IFDEF MACOS}
+ SDLttfLibName = 'SDL_ttf';
+ {$linklib libSDL_ttf}
+{$ENDIF}
+
+ {* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *}
+ SDL_TTF_MAJOR_VERSION = 2;
+{$EXTERNALSYM SDL_TTF_MAJOR_VERSION}
+ SDL_TTF_MINOR_VERSION = 0;
+{$EXTERNALSYM SDL_TTF_MINOR_VERSION}
+ SDL_TTF_PATCHLEVEL = 9;
+{$EXTERNALSYM SDL_TTF_PATCHLEVEL}
+
+ // Backwards compatibility
+ TTF_MAJOR_VERSION = SDL_TTF_MAJOR_VERSION;
+ TTF_MINOR_VERSION = SDL_TTF_MINOR_VERSION;
+ TTF_PATCHLEVEL = SDL_TTF_PATCHLEVEL;
+
+{*
+ Set and retrieve the font style
+ This font style is implemented by modifying the font glyphs, and
+ doesn't reflect any inherent properties of the truetype font file.
+*}
+ TTF_STYLE_NORMAL = $00;
+ TTF_STYLE_BOLD = $01;
+ TTF_STYLE_ITALIC = $02;
+ TTF_STYLE_UNDERLINE = $04;
+
+// ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark)
+ UNICODE_BOM_NATIVE = $FEFF;
+ UNICODE_BOM_SWAPPED = $FFFE;
+
+type
+ PTTF_Font = ^TTTF_font;
+ TTTF_Font = record
+ end;
+
+{ This macro can be used to fill a version structure with the compile-time
+ version of the SDL_ttf library. }
+procedure SDL_TTF_VERSION( var X : TSDL_version );
+{$EXTERNALSYM SDL_TTF_VERSION}
+
+{ This function gets the version of the dynamically linked SDL_ttf library.
+ It should NOT be used to fill a version structure, instead you should use the
+ SDL_TTF_VERSION() macro. }
+function TTF_Linked_Version : PSDL_version;
+cdecl; external {$IFDEF __GPC__}name 'TTF_Linked_Version'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_Linked_Version}
+
+{ This function tells the library whether UNICODE text is generally
+ byteswapped. A UNICODE BOM character in a string will override
+ this setting for the remainder of that string.
+}
+procedure TTF_ByteSwappedUNICODE( swapped : integer );
+cdecl; external {$IFDEF __GPC__}name 'TTF_ByteSwappedUNICODE'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_ByteSwappedUNICODE}
+
+//returns 0 on succes, -1 if error occurs
+function TTF_Init : integer;
+cdecl; external {$IFDEF __GPC__}name 'TTF_Init'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_Init}
+
+{
+ Open a font file and create a font of the specified point size.
+ Some .fon fonts will have several sizes embedded in the file, so the
+ point size becomes the index of choosing which size. If the value
+ is too high, the last indexed size will be the default.
+}
+function TTF_OpenFont( const filename : Pchar; ptsize : integer ) : PTTF_Font;
+cdecl; external {$IFDEF __GPC__}name 'TTF_OpenFont'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_OpenFont}
+
+function TTF_OpenFontIndex( const filename : Pchar; ptsize : integer; index : Longint ): PTTF_Font;
+cdecl; external {$IFDEF __GPC__}name 'TTF_OpenFontIndex'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_OpenFontIndex}
+
+function TTF_OpenFontRW( src : PSDL_RWops; freesrc : integer; ptsize : integer ): PTTF_Font;
+cdecl; external {$IFDEF __GPC__}name 'TTF_OpenFontRW'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_OpenFontRW}
+
+function TTF_OpenFontIndexRW( src : PSDL_RWops; freesrc : integer; ptsize : integer; index : Longint ): PTTF_Font;
+cdecl; external {$IFDEF __GPC__}name 'TTF_OpenFontIndexRW'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_OpenFontIndexRW}
+
+function TTF_GetFontStyle( font : PTTF_Font) : integer;
+cdecl; external {$IFDEF __GPC__}name 'TTF_GetFontStyle'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_GetFontStyle}
+
+procedure TTF_SetFontStyle( font : PTTF_Font; style : integer );
+cdecl; external {$IFDEF __GPC__}name 'TTF_SetFontStyle'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_SetFontStyle}
+
+{ Get the total height of the font - usually equal to point size }
+function TTF_FontHeight( font : PTTF_Font ) : Integer;
+cdecl; external {$IFDEF __GPC__}name 'TTF_FontHeight'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_FontHeight}
+
+{ Get the offset from the baseline to the top of the font
+ This is a positive value, relative to the baseline.
+}
+function TTF_FontAscent( font : PTTF_Font ) : Integer;
+cdecl; external {$IFDEF __GPC__}name 'TTF_FontAscent'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_FontAscent}
+{ Get the offset from the baseline to the bottom of the font
+ This is a negative value, relative to the baseline.
+}
+function TTF_FontDescent( font : PTTF_Font ) : Integer;
+cdecl; external {$IFDEF __GPC__}name 'TTF_FontDescent'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_FontDescent}
+
+{ Get the recommended spacing between lines of text for this font }
+function TTF_FontLineSkip( font : PTTF_Font ): Integer;
+cdecl; external {$IFDEF __GPC__}name 'TTF_FontLineSkip'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_FontLineSkip}
+
+{ Get the number of faces of the font }
+function TTF_FontFaces( font : PTTF_Font ) : Longint;
+cdecl; external {$IFDEF __GPC__}name 'TTF_FontFaces'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_FontFaces}
+
+{ Get the font face attributes, if any }
+function TTF_FontFaceIsFixedWidth( font : PTTF_Font ): Integer;
+cdecl; external {$IFDEF __GPC__}name 'TTF_FontFaceIsFixedWidth'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_FontFaceIsFixedWidth}
+
+function TTF_FontFaceFamilyName( font : PTTF_Font ): PChar;
+cdecl; external {$IFDEF __GPC__}name 'TTF_FontFaceFamilyName'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_FontFaceFamilyName}
+
+function TTF_FontFaceStyleName( font : PTTF_Font ): PChar;
+cdecl; external {$IFDEF __GPC__}name 'TTF_FontFaceStyleName'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_FontFaceStyleName}
+
+{ Get the metrics (dimensions) of a glyph }
+function TTF_GlyphMetrics( font : PTTF_Font; ch : Uint16;
+ var minx : integer; var maxx : integer;
+ var miny : integer; var maxy : integer;
+ var advance : integer ): Integer;
+cdecl; external {$IFDEF __GPC__}name 'TTF_GlyphMetrics'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_GlyphMetrics}
+
+{ Get the dimensions of a rendered string of text }
+function TTF_SizeText( font : PTTF_Font; const text : PChar; var w : integer; var y : integer ): Integer;
+cdecl; external {$IFDEF __GPC__}name 'TTF_SizeText'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_SizeText}
+
+function TTF_SizeUTF8( font : PTTF_Font; const text : PChar; var w : integer; var y : integer): Integer;
+cdecl; external {$IFDEF __GPC__}name 'TTF_SizeUTF8'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_SizeUTF8}
+
+function TTF_SizeUNICODE( font : PTTF_Font; const text : PUint16; var w : integer; var y : integer): Integer;
+cdecl; external {$IFDEF __GPC__}name 'TTF_SizeUNICODE'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_SizeUNICODE}
+
+{ Create an 8-bit palettized surface and render the given text at
+ fast quality with the given font and color. The 0 pixel is the
+ colorkey, giving a transparent background, and the 1 pixel is set
+ to the text color.
+ This function returns the new surface, or NULL if there was an error.
+}
+function TTF_RenderText_Solid( font : PTTF_Font;
+ const text : PChar; fg : TSDL_Color ): PSDL_Surface;
+{$IFNDEF Workaround_TTF_RenderText_Solid}
+cdecl; external {$IFDEF __GPC__}name 'TTF_RenderText_Solid'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_RenderText_Solid}
+{$ENDIF}
+
+function TTF_RenderUTF8_Solid( font : PTTF_Font;
+ const text : PChar; fg : TSDL_Color ): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'TTF_RenderUTF8_Solid'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_RenderUTF8_Solid}
+
+function TTF_RenderUNICODE_Solid( font : PTTF_Font;
+ const text :PUint16; fg : TSDL_Color ): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'TTF_RenderUNICODE_Solid'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_RenderUNICODE_Solid}
+
+{
+Create an 8-bit palettized surface and render the given glyph at
+ fast quality with the given font and color. The 0 pixel is the
+ colorkey, giving a transparent background, and the 1 pixel is set
+ to the text color. The glyph is rendered without any padding or
+ centering in the X direction, and aligned normally in the Y direction.
+ This function returns the new surface, or NULL if there was an error.
+}
+function TTF_RenderGlyph_Solid( font : PTTF_Font;
+ ch : Uint16; fg : TSDL_Color ): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'TTF_RenderGlyph_Solid'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_RenderGlyph_Solid}
+
+{ Create an 8-bit palettized surface and render the given text at
+ high quality with the given font and colors. The 0 pixel is background,
+ while other pixels have varying degrees of the foreground color.
+ This function returns the new surface, or NULL if there was an error.
+}
+function TTF_RenderText_Shaded( font : PTTF_Font;
+ const text : PChar; fg : TSDL_Color; bg : TSDL_Color ): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'TTF_RenderText_Shaded'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_RenderText_Shaded}
+function TTF_RenderUTF8_Shaded( font : PTTF_Font;
+ const text : PChar; fg : TSDL_Color; bg : TSDL_Color ): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'TTF_RenderUTF8_Shaded'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_RenderUTF8_Shaded}
+function TTF_RenderUNICODE_Shaded( font : PTTF_Font;
+ const text : PUint16; fg : TSDL_Color; bg : TSDL_Color ): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'TTF_RenderUNICODE_Shaded'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_RenderUNICODE_Shaded}
+
+{ Create an 8-bit palettized surface and render the given glyph at
+ high quality with the given font and colors. The 0 pixel is background,
+ while other pixels have varying degrees of the foreground color.
+ The glyph is rendered without any padding or centering in the X
+ direction, and aligned normally in the Y direction.
+ This function returns the new surface, or NULL if there was an error.
+}
+function TTF_RenderGlyph_Shaded( font : PTTF_Font; ch : Uint16; fg : TSDL_Color;
+ bg : TSDL_Color ): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'TTF_RenderGlyph_Shaded'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_RenderGlyph_Shaded}
+
+{ Create a 32-bit ARGB surface and render the given text at high quality,
+ using alpha blending to dither the font with the given color.
+ This function returns the new surface, or NULL if there was an error.
+}
+function TTF_RenderText_Blended( font : PTTF_Font;
+ const text : PChar; fg : TSDL_Color ): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'TTF_RenderText_Blended'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_RenderText_Blended}
+function TTF_RenderUTF8_Blended( font : PTTF_Font;
+ const text : PChar; fg : TSDL_Color ): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'TTF_RenderUTF8_Blended'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_RenderUTF8_Blended}
+function TTF_RenderUNICODE_Blended( font : PTTF_Font;
+ const text: PUint16; fg : TSDL_Color ): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'TTF_RenderUNICODE_Blended'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_RenderUNICODE_Blended}
+
+{ Create a 32-bit ARGB surface and render the given glyph at high quality,
+ using alpha blending to dither the font with the given color.
+ The glyph is rendered without any padding or centering in the X
+ direction, and aligned normally in the Y direction.
+ This function returns the new surface, or NULL if there was an error.
+}
+function TTF_RenderGlyph_Blended( font : PTTF_Font; ch : Uint16; fg : TSDL_Color ): PSDL_Surface;
+cdecl; external {$IFDEF __GPC__}name 'TTF_RenderGlyph_Blended'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_RenderGlyph_Blended}
+
+{ For compatibility with previous versions, here are the old functions }
+{#define TTF_RenderText(font, text, fg, bg)
+ TTF_RenderText_Shaded(font, text, fg, bg)
+#define TTF_RenderUTF8(font, text, fg, bg)
+ TTF_RenderUTF8_Shaded(font, text, fg, bg)
+#define TTF_RenderUNICODE(font, text, fg, bg)
+ TTF_RenderUNICODE_Shaded(font, text, fg, bg)}
+
+{ Close an opened font file }
+procedure TTF_CloseFont( font : PTTF_Font );
+cdecl; external {$IFDEF __GPC__}name 'TTF_CloseFont'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_CloseFont}
+
+//De-initialize TTF engine
+procedure TTF_Quit;
+cdecl; external {$IFDEF __GPC__}name 'TTF_Quit'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_Quit}
+
+// Check if the TTF engine is initialized
+function TTF_WasInit : integer;
+cdecl; external {$IFDEF __GPC__}name 'TTF_WasInit'{$ELSE} SDLttfLibName{$ENDIF __GPC__};
+{$EXTERNALSYM TTF_WasInit}
+
+// We'll use SDL for reporting errors
+procedure TTF_SetError( fmt : PChar );
+
+function TTF_GetError : PChar;
+
+implementation
+
+{$IFDEF __GPC__}
+ {$L 'sdl_ttf'} { link sdl_ttf.dll.a or libsdl_ttf.so or libsdl_ttf.a }
+{$ENDIF}
+
+procedure SDL_TTF_VERSION( var X : TSDL_version );
+begin
+ X.major := SDL_TTF_MAJOR_VERSION;
+ X.minor := SDL_TTF_MINOR_VERSION;
+ X.patch := SDL_TTF_PATCHLEVEL;
+end;
+
+procedure TTF_SetError( fmt : PChar );
+begin
+ SDL_SetError( fmt );
+end;
+
+function TTF_GetError : PChar;
+begin
+ result := SDL_GetError;
+end;
+
+{$IFDEF Workaround_TTF_RenderText_Solid}
+function TTF_RenderText_Solid( font : PTTF_Font;
+ const text : PChar; fg : TSDL_Color ): PSDL_Surface;
+const
+ Black: TSDL_Color = (r: 0; g: 0; b: 0; unused: 0);
+begin
+ Result := TTF_RenderText_Shaded(font, text, fg, Black);
+end;
+{$ENDIF Workaround_TTF_RenderText_Solid}
+
+end.
diff --git a/Game/Code/lib/JEDI-SDL/SDL_ttf/Pas/sdltruetypefont.pas b/Game/Code/lib/JEDI-SDL/SDL_ttf/Pas/sdltruetypefont.pas new file mode 100644 index 00000000..a0f25e12 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/SDL_ttf/Pas/sdltruetypefont.pas @@ -0,0 +1,565 @@ +unit sdltruetypefont;
+{
+ $Id: sdltruetypefont.pas,v 1.5 2005/05/26 21:22:28 savage Exp $
+
+}
+{******************************************************************************}
+{ }
+{ JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer }
+{ Wrapper class for SDL_ttf }
+{ }
+{ The initial developer of this Pascal code was : }
+{ Dominqiue Louis <Dominique@SavageSoftware.com.au> }
+{ }
+{ Portions created by Dominqiue Louis are }
+{ Copyright (C) 2000 - 2001 Dominqiue Louis. }
+{ }
+{ }
+{ Contributor(s) }
+{ -------------- }
+{ }
+{ }
+{ Obtained through: }
+{ Joint Endeavour of Delphi Innovators ( Project JEDI ) }
+{ }
+{ You may retrieve the latest version of this file at the Project }
+{ JEDI home page, located at http://delphi-jedi.org }
+{ }
+{ The contents of this file are used with permission, subject to }
+{ the Mozilla Public License Version 1.1 (the "License"); you may }
+{ 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 }
+{ }
+{ Software distributed under the License is distributed on an }
+{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
+{ implied. See the License for the specific language governing }
+{ rights and limitations under the License. }
+{ }
+{ Description }
+{ ----------- }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ }
+{ Requires }
+{ -------- }
+{ The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so }
+{ They are available from... }
+{ http://www.libsdl.org . }
+{ }
+{ Programming Notes }
+{ ----------------- }
+{ }
+{ }
+{ }
+{ }
+{ Revision History }
+{ ---------------- }
+{ September 23 2004 - DL : Initial Creation }
+{
+ $Log: sdltruetypefont.pas,v $
+ Revision 1.5 2005/05/26 21:22:28 savage
+ Update to Input code.
+
+ Revision 1.1 2005/05/25 23:15:42 savage
+ Latest Changes
+
+ Revision 1.4 2005/05/25 22:55:01 savage
+ Added InputRect support.
+
+ Revision 1.3 2005/05/13 14:02:49 savage
+ Made it use UniCode rendering by default.
+
+ Revision 1.2 2005/05/13 11:37:52 savage
+ Improved wordwrapping algorithm
+
+ Revision 1.1 2004/09/30 22:39:50 savage
+ Added a true type font class which contains a wrap text function.
+ Changed the sdl_ttf.pas header to reflect the future of jedi-sdl.
+
+
+}
+{******************************************************************************}
+
+interface
+
+uses
+ sdl,
+ sdl_ttf;
+
+type
+ TRenderType = ( rtLatin1, rtUTF8, rtUnicode );
+ TSDLFontStyle = ( fsBold, fsItalic, fsUnderline, fsStrikeOut );
+
+ TSDLFontStyles = set of TSDLFontStyle;
+
+ TTrueTypeFont = class( TObject )
+ private
+ FFont : PTTF_Font;
+ FSolid : Boolean;
+ FBackGroundColour : TSDL_Color;
+ FForeGroundColour : TSDL_Color;
+ FRenderType : TRenderType;
+ FStyle : TSDLFontStyles;
+ FFontFile : string;
+ FFontSize : integer;
+ procedure PrepareFont;
+
+ protected
+
+ public
+ constructor Create( aFontFile : string; aRenderStyle : TSDLFontStyles = [ ]; aFontSize : integer = 14 );
+ destructor Destroy; override;
+ function DrawText( aText : WideString ) : PSDL_Surface; overload;
+ function DrawText( aText : WideString; aWidth, aHeight : Integer ) : PSDL_Surface; overload;
+ function Input(aDestination: PSDL_Surface; aX, aY, aWidth, aHeight: integer; var aText: string; aMaxChars: integer = 10 ): PSDL_Surface;
+ property BackGroundColour : TSDL_Color read FBackGroundColour write FBackGroundColour;
+ property ForeGroundColour : TSDL_Color read FForeGroundColour write FForeGroundColour;
+ property FontFile : string read FFontFile write FFontFile;
+ property RenderType : TRenderType read FRenderType write FRenderType;
+ property Solid : Boolean read FSolid write FSolid;
+ property Style : TSDLFontStyles read FStyle write FStyle;
+ property FontSize : integer read FFontSize write FFontSize;
+ end;
+
+
+implementation
+
+uses
+ SysUtils;
+
+{ TTrueTypeFont }
+
+constructor TTrueTypeFont.Create( aFontFile : string; aRenderStyle : TSDLFontStyles; aFontSize : integer );
+begin
+ inherited Create;
+ if FileExists( aFontFile ) then
+ begin
+ FStyle := aRenderStyle;
+ FFontSize := aFontSize;
+ FSolid := false;
+ FBackGroundColour.r := 255;
+ FBackGroundColour.g := 255;
+ FBackGroundColour.b := 255;
+ FForeGroundColour.r := 0;
+ FForeGroundColour.g := 0;
+ FForeGroundColour.b := 0;
+ FRenderType := rtUnicode;
+ if ( TTF_Init >= 0 ) then
+ begin
+ FFontFile := aFontFile;
+ end
+ else
+ raise Exception.Create( 'Failed to Initialiase SDL_TTF' );
+ end
+ else
+ raise Exception.Create( 'Font File does not exist' );
+end;
+
+destructor TTrueTypeFont.Destroy;
+begin
+ if FFont <> nil then
+ TTF_CloseFont( FFont );
+ TTF_Quit;
+ inherited;
+end;
+
+function TTrueTypeFont.DrawText( aText : WideString ) : PSDL_Surface;
+begin
+ PrepareFont;
+
+ result := nil;
+
+ case FRenderType of
+ rtLatin1 :
+ begin
+ if ( FSolid ) then
+ begin
+ result := TTF_RenderText_Solid( FFont, PChar( string( aText ) ), FForeGroundColour );
+ end
+ else
+ begin
+ result := TTF_RenderText_Shaded( FFont, PChar( string( aText ) ), FForeGroundColour, FBackGroundColour );
+ end;
+ end;
+
+ rtUTF8 :
+ begin
+ if ( FSolid ) then
+ begin
+ result := TTF_RenderUTF8_Solid( FFont, PChar( string( aText ) ), FForeGroundColour );
+ end
+ else
+ begin
+ result := TTF_RenderUTF8_Shaded( FFont, PChar( string( aText ) ), FForeGroundColour, FBackGroundColour );
+ end;
+ end;
+
+ rtUnicode :
+ begin
+ if ( FSolid ) then
+ begin
+ result := TTF_RenderUNICODE_Solid( FFont, PUInt16( aText ), FForeGroundColour );
+ end
+ else
+ begin
+ result := TTF_RenderUNICODE_Shaded( FFont, PUInt16( aText ), FForeGroundColour, FBackGroundColour );
+ end;
+ end;
+ end;
+end;
+
+function TTrueTypeFont.DrawText( aText : WideString; aWidth, aHeight : Integer ) : PSDL_Surface;
+var
+ textw, texth, i, yPos : integer;
+ strChopped : WideString;
+ SurfaceList : array of PSDL_Surface;
+ strlist : array of WideString;
+ ReturnedSurface : PSDL_Surface;
+ BltRect : TSDL_Rect;
+begin
+ PrepareFont;
+
+ // Do an initial check to see if it already fits
+ case FRenderType of
+ rtLatin1 :
+ begin
+ if TTF_SizeText( FFont, PChar( string( aText ) ), textw, texth ) = 0 then
+ begin
+ if ( textw < aWidth )
+ and ( texth < aHeight ) then
+ begin
+ result := DrawText( aText );
+ exit;
+ end
+ end;
+ end;
+
+ rtUTF8 :
+ begin
+ if TTF_SizeUTF8( FFont, PChar( string( aText ) ), textw, texth ) = 0 then
+ begin
+ if ( textw < aWidth )
+ and ( texth < aHeight ) then
+ begin
+ result := DrawText( aText );
+ exit;
+ end
+ end;
+ end;
+
+ rtUnicode :
+ begin
+ if TTF_SizeUNICODE( FFont, PUInt16( aText ), textw, texth ) = 0 then
+ begin
+ if ( textw < aWidth )
+ and ( texth < aHeight ) then
+ begin
+ result := DrawText( aText );
+ exit;
+ end
+ end;
+ end;
+ end;
+
+ // Create the Surface we will be returning
+ ReturnedSurface := SDL_DisplayFormat( SDL_CreateRGBSurface( SDL_SRCCOLORKEY or SDL_RLEACCEL or SDL_HWACCEL, aWidth, aHeight, 16, 0, 0, 0, 0 ) );
+
+ // If we are still here there is some serious parsing to do
+ case FRenderType of
+ rtLatin1 :
+ begin
+ strChopped := aText;
+ i := Length( strChopped );
+ while ( i <> 0 ) do
+ begin
+ if ( string( strChopped[ i ] ) <> ' ' ) and ( Integer( string( strChopped[ i ] ) ) <> 13 ) then
+ dec( i )
+ else
+ begin
+ dec( i );
+ if TTF_SizeText( FFont, PChar( string( Copy( strChopped, 0, i ) ) ), textw, texth ) = 0 then
+ begin
+ if ( textw < aWidth )
+ and ( texth < aHeight ) then
+ begin
+ SetLength( strlist, Length( strlist ) + 1 );
+ strlist[ Length( strlist ) - 1 ] := Copy( strChopped, 0, i );
+ strChopped := Copy( strChopped, i + 2, Length( strChopped ) - ( i - 1 ) );
+ i := Length( strChopped );
+ if TTF_SizeText( FFont, PChar( string( strChopped ) ), textw, texth ) = 0 then
+ begin
+ if ( textw < aWidth )
+ and ( texth < aHeight ) then
+ begin
+ SetLength( strlist, Length( strlist ) + 1 );
+ strlist[ Length( strlist ) - 1 ] := Copy( strChopped, 0, i );
+ strChopped := Copy( strChopped, i + 2, Length( strChopped ) - ( i - 1 ) );
+ i := Length( strChopped );
+ end;
+ end;
+ end;
+ end;
+ end;
+ end;
+
+ SetLength( SurfaceList, Length( strlist ) );
+ for i := Low( strlist ) to High( strlist ) do
+ begin
+ if ( FSolid ) then
+ begin
+ SurfaceList[ i ] := TTF_RenderText_Solid( FFont, PChar( string( strlist[ i ] ) ), FForeGroundColour );
+ end
+ else
+ begin
+ SurfaceList[ i ] := TTF_RenderText_Shaded( FFont, PChar( string( strlist[ i ] ) ), FForeGroundColour, FBackGroundColour );
+ end;
+ end;
+ end;
+
+ rtUTF8 :
+ begin
+ strChopped := aText;
+ i := Length( strChopped );
+ while ( i <> 0 ) do
+ begin
+ if ( string( strChopped[ i ] ) <> ' ' ) and ( Integer( string( strChopped[ i ] ) ) <> 13 ) then
+ dec( i )
+ else
+ begin
+ dec( i );
+ if TTF_SizeUTF8( FFont, PChar( string( Copy( strChopped, 0, i ) ) ), textw, texth ) = 0 then
+ begin
+ if ( textw < aWidth )
+ and ( texth < aHeight ) then
+ begin
+ SetLength( strlist, Length( strlist ) + 1 );
+ strlist[ Length( strlist ) - 1 ] := Copy( strChopped, 0, i );
+ strChopped := Copy( strChopped, i + 2, Length( strChopped ) - ( i - 1 ) );
+ i := Length( strChopped );
+ if TTF_SizeUTF8( FFont, PChar( string( strChopped ) ), textw, texth ) = 0 then
+ begin
+ if ( textw < aWidth )
+ and ( texth < aHeight ) then
+ begin
+ SetLength( strlist, Length( strlist ) + 1 );
+ strlist[ Length( strlist ) - 1 ] := Copy( strChopped, 0, i );
+ strChopped := Copy( strChopped, i + 2, Length( strChopped ) - ( i - 1 ) );
+ i := Length( strChopped );
+ end;
+ end;
+ end;
+ end;
+ end;
+ end;
+
+ SetLength( SurfaceList, Length( strlist ) );
+ for i := Low( strlist ) to High( strlist ) do
+ begin
+ if ( FSolid ) then
+ begin
+ SurfaceList[ i ] := TTF_RenderUTF8_Solid( FFont, PChar( string( strlist[ i ] ) ), FForeGroundColour );
+ end
+ else
+ begin
+ SurfaceList[ i ] := TTF_RenderUTF8_Shaded( FFont, PChar( string( strlist[ i ] ) ), FForeGroundColour, FBackGroundColour );
+ end;
+ end;
+ end;
+
+ rtUnicode :
+ begin
+ strChopped := aText;
+ i := Length( strChopped );
+ while ( i <> 0 ) do
+ begin
+ if ( string( strChopped[ i ] ) <> ' ' ) and ( Integer( string( strChopped[ i ] ) ) <> 13 ) then
+ dec( i )
+ else
+ begin
+ dec( i );
+ if TTF_SizeUNICODE( FFont, PUInt16( Copy( strChopped, 0, i ) ), textw, texth ) = 0 then
+ begin
+ if ( textw < aWidth )
+ and ( texth < aHeight ) then
+ begin
+ SetLength( strlist, Length( strlist ) + 1 );
+ strlist[ Length( strlist ) - 1 ] := Copy( strChopped, 0, i );
+ strChopped := Copy( strChopped, i + 2, Length( strChopped ) - ( i - 1 ) );
+ i := Length( strChopped );
+ if TTF_SizeUNICODE( FFont, PUInt16( strChopped ), textw, texth ) = 0 then
+ begin
+ if ( textw < aWidth )
+ and ( texth < aHeight ) then
+ begin
+ SetLength( strlist, Length( strlist ) + 1 );
+ strlist[ Length( strlist ) - 1 ] := Copy( strChopped, 0, i );
+ strChopped := Copy( strChopped, i + 2, Length( strChopped ) - ( i - 1 ) );
+ i := Length( strChopped );
+ end;
+ end;
+ end;
+ end;
+ end;
+ end;
+ SetLength( SurfaceList, Length( strlist ) );
+ for i := Low( strlist ) to High( strlist ) do
+ begin
+ if ( FSolid ) then
+ begin
+ SurfaceList[ i ] := TTF_RenderUNICODE_Solid( FFont, PUInt16( strlist[ i ] ), FForeGroundColour );
+ end
+ else
+ begin
+ SurfaceList[ i ] := TTF_RenderUNICODE_Shaded( FFont, PUInt16( strlist[ i ] ), FForeGroundColour, FBackGroundColour );
+ end;
+ end;
+ end;
+ end;
+
+ // Now Draw the SurfaceList onto the resulting Surface
+ yPos := 6;
+ for i := Low( SurfaceList ) to High( SurfaceList ) do
+ begin
+ BltRect.x := 6;
+ BltRect.y := yPos;
+ BltRect.w := SurfaceList[ i ].w;
+ BltRect.h := SurfaceList[ i ].h;
+ SDL_BlitSurface( SurfaceList[ i ], nil, ReturnedSurface, @BltRect );
+ yPos := yPos + TTF_FontHeight( FFont );
+ end;
+ result := ReturnedSurface;
+
+ for i := Low( SurfaceList ) to High( SurfaceList ) do
+ begin
+ SDL_FreeSurface( SurfaceList[ i ] );
+ end;
+ SetLength( SurfaceList, 0 );
+ SetLength( strlist, 0 );
+end;
+
+function TTrueTypeFont.Input(aDestination: PSDL_Surface; aX, aY, aWidth: integer; aHeight : integer; var aText : string; aMaxChars: integer): PSDL_Surface;
+var
+ event : TSDL_Event;
+ ch : integer;
+
+ BackSurface, TextSurface : PSDL_Surface;
+ rect : SDL_Rect;
+ textw, texth : integer;
+ Done : boolean;
+ PassedInText : string;
+begin
+ PassedInText := aText;
+
+ BackSurface := SDL_AllocSurface( aDestination.flags,
+ aDestination.w,
+ aDestination.h,
+ aDestination.format.BitsPerPixel,
+ aDestination.format.Rmask,
+ aDestination.format.Gmask,
+ aDestination.format.Bmask, 0 );
+
+ rect.x := aX;
+ rect.y := aY;
+ rect.w := aWidth;
+ rect.h := aHeight;
+
+ SDL_BlitSurface( aDestination, nil, BackSurface, nil );
+ SDL_FillRect( BackSurface, @rect, SDL_MapRGB( aDestination.format, 0, 0, 0 ) );
+
+ TextSurface := DrawText( aText + '|' );
+
+ // start input
+ SDL_EnableUNICODE( 1 );
+ Done := false;
+ while ( not Done ) and ( SDL_WaitEvent( @event ) > 0 ) do
+ begin
+ if event.type_ = SDL_KEYDOWN then
+ begin
+ ch := event.key.keysym.unicode;
+ case ch of
+ SDLK_RETURN :
+ begin
+ Done := true;
+ end;
+
+ SDLK_ESCAPE :
+ begin
+ aText := PassedInText;
+ Done := true;
+ end;
+
+ SDLK_BACKSPACE :
+ begin
+ if ( Length( aText ) > 0 ) then
+ begin
+ aText := Copy( aText, 0, Length( aText ) - 1 );
+ if TextSurface <> nil then
+ SDL_FreeSurface( TextSurface );
+ TextSurface := DrawText( aText + '|' );
+ end;
+ end;
+ else
+ begin
+ if Length( aText ) < aMaxChars then
+ begin
+ if ( chr( ch ) <> '' ) then
+ begin
+ aText := aText + chr( ch );
+
+ if ( aText <> '' )
+ and ( TTF_SizeUNICODE( FFont, PUInt16( aText ), textw, texth ) = 0 ) then
+ begin
+ if ( textw > aWidth ) then
+ aText := Copy( aText, 0, Length( aText ) - 1 );
+ end;
+
+ if TextSurface <> nil then
+ SDL_FreeSurface( TextSurface );
+ TextSurface := DrawText( aText + '|' );
+ end;
+ end;
+ end;
+ end;
+ end;
+ SDL_BlitSurface( BackSurface, nil, aDestination, nil );
+ SDL_BlitSurface( TextSurface, nil, aDestination, @rect );
+ SDL_Flip( aDestination );
+ end;
+
+ if TextSurface <> nil then
+ SDL_FreeSurface( TextSurface );
+ if aText <> '' then
+ TextSurface := DrawText( aText );
+ SDL_FreeSurface( BackSurface );
+ result := TextSurface;
+end;
+
+procedure TTrueTypeFont.PrepareFont;
+var
+ renderstyle : integer;
+begin
+ if FFont <> nil then
+ TTF_CloseFont( FFont );
+
+ FFont := TTF_OpenFont( PChar( FFontFile ), FFontSize );
+
+ renderstyle := TTF_STYLE_NORMAL;
+ if ( fsBold in FStyle ) then
+ renderstyle := renderstyle or TTF_STYLE_BOLD;
+
+ if ( fsItalic in FStyle ) then
+ renderstyle := renderstyle or TTF_STYLE_ITALIC;
+
+ if ( fsUnderline in FStyle ) then
+ renderstyle := renderstyle or TTF_STYLE_UNDERLINE;
+
+ TTF_SetFontStyle( FFont, renderstyle );
+end;
+
+end.
+
diff --git a/Game/Code/lib/JEDI-SDL/fpc-install.sh b/Game/Code/lib/JEDI-SDL/fpc-install.sh new file mode 100644 index 00000000..ea6c4928 --- /dev/null +++ b/Game/Code/lib/JEDI-SDL/fpc-install.sh @@ -0,0 +1,252 @@ +#!/bin/sh
+#
+# FreePascal & Delphi Installation script for JEDI-SDL
+# portions of which are based on the FreePascal install script
+# Copyright 1996-2002 Michael Van Canneyt and Peter Vreman
+#
+# Copyright (c)2004-2100, JEDI-SDL Team
+# All Rights Reserved
+#
+# Don NOT edit this file.
+# Everything should be configuration while the script is running.
+#
+############################################################################
+
+# Release Version
+VERSION=1.0
+
+# some useful functions
+# ask displays 1st parameter, and ask new value for variable, whose name is
+# in the second parameter.
+ask ()
+{
+askvar=$2
+eval old=\$$askvar
+eval echo -n \""$1 [$old] : "\"
+read $askvar
+eval test -z \"\$$askvar\" && eval $askvar=\'$old\'
+}
+# yesno gives 1 on no, 0 on yes $1 gives text to display.
+yesno ()
+{
+ while true; do
+ echo -n "$1 (Y/n) ? "
+ read ans
+ case X$ans in
+ X|Xy|XY) return 0;;
+ Xn|XN) return 1;;
+ esac
+ done
+}
+
+# Untar files ($3,optional) from file ($1) to the given directory ($2)
+unztar ()
+{
+ tar -xzf $HERE/$1 --directory $2 $3
+}
+
+# Untar tar.gz file ($2) from file ($1) and untar result to the given directory ($3)
+unztarfromtar ()
+{
+ tar -xOf $HERE/$1 $2 | tar --directory $3 -xzf -
+}
+# Get file list from tar archive ($1) in variable ($2)
+# optionally filter result through sed ($3)
+listtarfiles ()
+{
+ askvar=$2
+ if [ ! -z $3 ]; then
+ list=`tar tvf $1 | awk '{ print $(NF) }' | sed -n /$3/p`
+ else
+ list=`tar tvf $1 | awk '{ print $(NF) }'`
+ fi
+ eval $askvar='$list'
+}
+# Make all the necessary directories to get $1
+makedirhierarch ()
+{
+ OLDDIR=`pwd`
+ case $1 in
+ /*) cd /;;
+ esac
+ OLDIFS=$IFS;IFS=/;eval set $1; IFS=$OLDIFS
+ for i
+ do
+ test -d $i || mkdir $i || break
+ cd $i ||break
+ done
+ cd $OLDDIR
+}
+
+# check to see if something is in the path
+checkpath ()
+{
+ ARG=$1
+ OLDIFS=$IFS; IFS=":";eval set $PATH;IFS=$OLDIFS
+ for i
+ do
+ if [ $i = $ARG ]; then
+ return 0
+ fi
+ done
+ return 1
+}
+
+# --------------------------------------------------------------------------
+# welcome message.
+#
+
+clear
+echo "This shell script will attempt to install the Free Pascal Compiler"
+echo "version $VERSION with the items you select"
+echo
+
+# Here we start the thing.
+HERE=`pwd`
+
+# Install in /usr/local or /usr ?
+if checkpath /usr/local/bin; then
+ PREFIX=/usr/local
+else
+ PREFIX=/usr
+fi
+# If we can't write on prefix, select subdir of home dir
+if [ ! -w $PREFIX ]; then
+ PREFIX=$HOME/JEDI-SDLv$VERSION
+fi
+ask "Install prefix (/usr or /usr/local) " PREFIX
+makedirhierarch $PREFIX
+
+# Set some defaults.
+LIBDIR=$PREFIX/lib/JEDI-SDL/$VERSION
+SRCDIR=$PREFIX/src/JEDI-SDLv$VERSION
+EXECDIR=$PREFIX/bin
+OSNAME=`uname -s | tr A-Z a-z`
+
+BSDHIER=0
+case $OSNAME in
+*bsd)
+ BSDHIER=1;;
+esac
+
+
+if [ "${BSDHIER}" = "1" ]; then
+DOCDIR=$PREFIX/share/doc/JEDI-SDLv$VERSION
+else
+DOCDIR=$PREFIX/doc/JEDI-SDLv$VERSION
+fi
+
+echo $DOCDIR
+
+DEMODIR=$PREFIX/demos
+
+# Install SDL headers
+if yesno "Install SDL headers"; then
+
+fi
+
+# Install SDL_image headers
+if yesno "Install SDL_image headers"; then
+
+fi
+
+# Install compiler/RTL. Mandatory.
+echo Installing compiler and RTL ...
+unztarfromtar binary.tar base${OSNAME}.tar.gz $PREFIX
+rm -f $EXECDIR/ppc386
+ln -sf $LIBDIR/ppc386 $EXECDIR/ppc386
+echo Installing utilities...
+unztarfromtar binary.tar util${OSNAME}.tar.gz $PREFIX
+if yesno "Install FCL"; then
+ unztarfromtar binary.tar unitsfcl${OSNAME}.tar.gz $PREFIX
+fi
+if yesno "Install packages"; then
+ listtarfiles binary.tar packages units
+ for f in $packages
+ do
+ if [ $f != unitsfcl${OSNAME}.tar.gz ]; then
+ basename $f .tar.gz |\
+ sed -e s/units// -e s/${OSNAME}// |\
+ xargs echo Installing
+ unztarfromtar binary.tar $f $PREFIX
+ fi
+ done
+fi
+rm -f *${OSNAME}.tar.gz
+echo Done.
+echo
+
+# Install the sources. Optional.
+if yesno "Install sources"; then
+ echo Installing sources in $SRCDIR ...
+ unztarfromtar sources.tar basesrc.tar.gz $PREFIX
+ if yesno "Install compiler source"; then
+ unztarfromtar sources.tar compilersrc.tar.gz $PREFIX
+ fi
+ if yesno "Install RTL source"; then
+ unztarfromtar sources.tar rtlsrc.tar.gz $PREFIX
+ fi
+ if yesno "Install FCL source"; then
+ unztarfromtar sources.tar fclsrc.tar.gz $PREFIX
+ fi
+ if yesno "Install IDE source"; then
+ unztarfromtar sources.tar idesrc.tar.gz $PREFIX
+ fi
+ if yesno "Install installer source"; then
+ unztarfromtar sources.tar installersrc.tar.gz $PREFIX
+ fi
+ if yesno "Install Packages source"; then
+ listtarfiles sources.tar packages units
+ for f in $packages
+ do
+ basename $f .tar.gz |\
+ sed -e s/units// -e s/src// |\
+ xargs echo Installing sources for
+ unztarfromtar sources.tar $f $PREFIX
+ done
+ fi
+ # rm -f *src.tar.gz
+ echo Done.
+fi
+echo
+
+# Install the documentation. Optional.
+if yesno "Install documentation"; then
+ echo Installing documentation in $DOCDIR ...
+ unztar docs.tar.gz $DOCDIR
+ echo Done.
+fi
+echo
+
+# Install the demos. Optional.
+if yesno "Install demos"; then
+ ask "Install demos in" DEMODIR
+ echo Installing demos in $DEMODIR ...
+ makedirhierarch $DEMODIR
+ unztar demo.tar.gz $DEMODIR
+ echo Done.
+fi
+echo
+
+# update fpc.cfg file
+if yesno "Update fpc.cfg file automagically"; then
+ echo Updating fpc.cfg in $DOCDIR ...
+ echo
+ echo Done.
+fi
+
+# update Borland IDE file
+if yesno "Update the Kylix IDE automagically"; then
+ echo Updating the Kylix IDE in $DOCDIR ...
+ echo
+ echo Done.
+fi
+
+$LIBDIR/samplecfg $LIBDIR
+
+# The End
+echo
+echo End of installation.
+echo
+echo Refer to the documentation for more information.
+echo
\ No newline at end of file diff --git a/Game/Code/lib/PngImage/Tpngimage.DPK b/Game/Code/lib/PngImage/Tpngimage.DPK new file mode 100644 index 00000000..b9c395f4 --- /dev/null +++ b/Game/Code/lib/PngImage/Tpngimage.DPK @@ -0,0 +1,34 @@ +package Tpngimage;
+
+{$R *.res}
+{$ALIGN 8}
+{$ASSERTIONS ON}
+{$BOOLEVAL OFF}
+{$DEBUGINFO ON}
+{$EXTENDEDSYNTAX ON}
+{$IMPORTEDDATA ON}
+{$IOCHECKS ON}
+{$LOCALSYMBOLS ON}
+{$LONGSTRINGS ON}
+{$OPENSTRINGS ON}
+{$OPTIMIZATION ON}
+{$OVERFLOWCHECKS OFF}
+{$RANGECHECKS OFF}
+{$REFERENCEINFO ON}
+{$SAFEDIVIDE OFF}
+{$STACKFRAMES OFF}
+{$TYPEDADDRESS OFF}
+{$VARSTRINGCHECKS ON}
+{$WRITEABLECONST OFF}
+{$MINENUMSIZE 1}
+{$IMAGEBASE $400000}
+{$IMPLICITBUILD OFF}
+
+requires
+ rtl,
+ vcl;
+
+contains
+ pngimage in 'pngimage.pas';
+
+end.
diff --git a/Game/Code/lib/PngImage/Tpngimage.bdsproj b/Game/Code/lib/PngImage/Tpngimage.bdsproj new file mode 100644 index 00000000..b7a30970 --- /dev/null +++ b/Game/Code/lib/PngImage/Tpngimage.bdsproj @@ -0,0 +1,177 @@ +<?xml version="1.0" encoding="utf-8"?>
+<BorlandProject>
+ <PersonalityInfo>
+ <Option>
+ <Option Name="Personality">Delphi.Personality</Option>
+ <Option Name="ProjectType"></Option>
+ <Option Name="Version">1.0</Option>
+ <Option Name="GUID">{2C0AD708-246C-40AA-902E-B3901926A7DC}</Option>
+ </Option>
+ </PersonalityInfo>
+ <Delphi.Personality>
+ <Source>
+ <Source Name="MainSource">Tpngimage.DPK</Source>
+ </Source>
+ <FileVersion>
+ <FileVersion Name="Version">7.0</FileVersion>
+ </FileVersion>
+ <Compiler>
+ <Compiler Name="A">8</Compiler>
+ <Compiler Name="B">0</Compiler>
+ <Compiler Name="C">1</Compiler>
+ <Compiler Name="D">1</Compiler>
+ <Compiler Name="E">0</Compiler>
+ <Compiler Name="F">0</Compiler>
+ <Compiler Name="G">1</Compiler>
+ <Compiler Name="H">1</Compiler>
+ <Compiler Name="I">1</Compiler>
+ <Compiler Name="J">0</Compiler>
+ <Compiler Name="K">0</Compiler>
+ <Compiler Name="L">1</Compiler>
+ <Compiler Name="M">0</Compiler>
+ <Compiler Name="N">1</Compiler>
+ <Compiler Name="O">1</Compiler>
+ <Compiler Name="P">1</Compiler>
+ <Compiler Name="Q">0</Compiler>
+ <Compiler Name="R">0</Compiler>
+ <Compiler Name="S">0</Compiler>
+ <Compiler Name="T">0</Compiler>
+ <Compiler Name="U">0</Compiler>
+ <Compiler Name="V">1</Compiler>
+ <Compiler Name="W">0</Compiler>
+ <Compiler Name="X">1</Compiler>
+ <Compiler Name="Y">1</Compiler>
+ <Compiler Name="Z">1</Compiler>
+ <Compiler Name="ShowHints">True</Compiler>
+ <Compiler Name="ShowWarnings">True</Compiler>
+ <Compiler Name="UnitAliases">WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;</Compiler>
+ <Compiler Name="NamespacePrefix"></Compiler>
+ <Compiler Name="GenerateDocumentation">False</Compiler>
+ <Compiler Name="DefaultNamespace"></Compiler>
+ <Compiler Name="SymbolDeprecated">True</Compiler>
+ <Compiler Name="SymbolLibrary">True</Compiler>
+ <Compiler Name="SymbolPlatform">True</Compiler>
+ <Compiler Name="SymbolExperimental">True</Compiler>
+ <Compiler Name="UnitLibrary">True</Compiler>
+ <Compiler Name="UnitPlatform">True</Compiler>
+ <Compiler Name="UnitDeprecated">True</Compiler>
+ <Compiler Name="UnitExperimental">True</Compiler>
+ <Compiler Name="HResultCompat">True</Compiler>
+ <Compiler Name="HidingMember">True</Compiler>
+ <Compiler Name="HiddenVirtual">True</Compiler>
+ <Compiler Name="Garbage">True</Compiler>
+ <Compiler Name="BoundsError">True</Compiler>
+ <Compiler Name="ZeroNilCompat">True</Compiler>
+ <Compiler Name="StringConstTruncated">True</Compiler>
+ <Compiler Name="ForLoopVarVarPar">True</Compiler>
+ <Compiler Name="TypedConstVarPar">True</Compiler>
+ <Compiler Name="AsgToTypedConst">True</Compiler>
+ <Compiler Name="CaseLabelRange">True</Compiler>
+ <Compiler Name="ForVariable">True</Compiler>
+ <Compiler Name="ConstructingAbstract">True</Compiler>
+ <Compiler Name="ComparisonFalse">True</Compiler>
+ <Compiler Name="ComparisonTrue">True</Compiler>
+ <Compiler Name="ComparingSignedUnsigned">True</Compiler>
+ <Compiler Name="CombiningSignedUnsigned">True</Compiler>
+ <Compiler Name="UnsupportedConstruct">True</Compiler>
+ <Compiler Name="FileOpen">True</Compiler>
+ <Compiler Name="FileOpenUnitSrc">True</Compiler>
+ <Compiler Name="BadGlobalSymbol">True</Compiler>
+ <Compiler Name="DuplicateConstructorDestructor">True</Compiler>
+ <Compiler Name="InvalidDirective">True</Compiler>
+ <Compiler Name="PackageNoLink">True</Compiler>
+ <Compiler Name="PackageThreadVar">True</Compiler>
+ <Compiler Name="ImplicitImport">True</Compiler>
+ <Compiler Name="HPPEMITIgnored">True</Compiler>
+ <Compiler Name="NoRetVal">True</Compiler>
+ <Compiler Name="UseBeforeDef">True</Compiler>
+ <Compiler Name="ForLoopVarUndef">True</Compiler>
+ <Compiler Name="UnitNameMismatch">True</Compiler>
+ <Compiler Name="NoCFGFileFound">True</Compiler>
+ <Compiler Name="MessageDirective">True</Compiler>
+ <Compiler Name="ImplicitVariants">True</Compiler>
+ <Compiler Name="UnicodeToLocale">True</Compiler>
+ <Compiler Name="LocaleToUnicode">True</Compiler>
+ <Compiler Name="ImagebaseMultiple">True</Compiler>
+ <Compiler Name="SuspiciousTypecast">True</Compiler>
+ <Compiler Name="PrivatePropAccessor">True</Compiler>
+ <Compiler Name="UnsafeType">False</Compiler>
+ <Compiler Name="UnsafeCode">False</Compiler>
+ <Compiler Name="UnsafeCast">False</Compiler>
+ <Compiler Name="OptionTruncated">True</Compiler>
+ <Compiler Name="WideCharReduced">True</Compiler>
+ <Compiler Name="DuplicatesIgnored">True</Compiler> <Compiler Name="UnitInitSeq">True</Compiler>
+ <Compiler Name="LocalPInvoke">True</Compiler>
+ <Compiler Name="CodePage"></Compiler>
+ </Compiler>
+ <Linker>
+ <Linker Name="MapFile">3</Linker>
+ <Linker Name="OutputObjs">0</Linker>
+ <Linker Name="ConsoleApp">1</Linker>
+ <Linker Name="DebugInfo">False</Linker>
+ <Linker Name="RemoteSymbols">False</Linker>
+ <Linker Name="GenerateDRC">False</Linker>
+ <Linker Name="MinStackSize">16384</Linker>
+ <Linker Name="MaxStackSize">1048576</Linker>
+ <Linker Name="ImageBase">4194304</Linker>
+ <Linker Name="ExeDescription"></Linker> <Linker Name="GenerateHpps">False</Linker>
+ </Linker>
+ <Directories>
+ <Directories Name="OutputDir"></Directories>
+ <Directories Name="UnitOutputDir"></Directories>
+ <Directories Name="PackageDLLOutputDir"></Directories>
+ <Directories Name="PackageDCPOutputDir"></Directories>
+ <Directories Name="SearchPath"></Directories>
+ <Directories Name="Packages"></Directories>
+ <Directories Name="Conditionals"></Directories>
+ <Directories Name="DebugSourceDirs"></Directories>
+ <Directories Name="UsePackages">False</Directories>
+ </Directories>
+ <Parameters>
+ <Parameters Name="RunParams"></Parameters>
+ <Parameters Name="HostApplication"></Parameters>
+ <Parameters Name="Launcher"></Parameters>
+ <Parameters Name="UseLauncher">False</Parameters>
+ <Parameters Name="DebugCWD"></Parameters>
+ <Parameters Name="RemoteHost"></Parameters>
+ <Parameters Name="RemotePath"></Parameters>
+ <Parameters Name="RemoteLauncher"></Parameters>
+ <Parameters Name="RemoteCWD"></Parameters>
+ <Parameters Name="RemoteDebug">False</Parameters> <Parameters Name="Debug Symbols Search Path"></Parameters>
+ <Parameters Name="LoadAllSymbols">True</Parameters>
+ <Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
+ </Parameters>
+ <Language>
+ <Language Name="ActiveLang"></Language>
+ <Language Name="ProjectLang">$00000000</Language>
+ <Language Name="RootDir">C:\Program Files\Borland\Delphi7\Bin\</Language>
+ </Language>
+ <VersionInfo>
+ <VersionInfo Name="IncludeVerInfo">True</VersionInfo>
+ <VersionInfo Name="AutoIncBuild">False</VersionInfo>
+ <VersionInfo Name="MajorVer">1</VersionInfo>
+ <VersionInfo Name="MinorVer">0</VersionInfo>
+ <VersionInfo Name="Release">0</VersionInfo>
+ <VersionInfo Name="Build">0</VersionInfo>
+ <VersionInfo Name="Debug">False</VersionInfo>
+ <VersionInfo Name="PreRelease">False</VersionInfo>
+ <VersionInfo Name="Special">False</VersionInfo>
+ <VersionInfo Name="Private">False</VersionInfo>
+ <VersionInfo Name="DLL">False</VersionInfo>
+ <VersionInfo Name="Locale">1033</VersionInfo>
+ <VersionInfo Name="CodePage">1252</VersionInfo>
+ </VersionInfo>
+ <VersionInfoKeys>
+ <VersionInfoKeys Name="CompanyName"></VersionInfoKeys>
+ <VersionInfoKeys Name="FileDescription"></VersionInfoKeys>
+ <VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
+ <VersionInfoKeys Name="InternalName"></VersionInfoKeys>
+ <VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys>
+ <VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys>
+ <VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys>
+ <VersionInfoKeys Name="ProductName"></VersionInfoKeys>
+ <VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
+ <VersionInfoKeys Name="Comments"></VersionInfoKeys>
+ </VersionInfoKeys>
+ </Delphi.Personality>
+</BorlandProject>
diff --git a/Game/Code/lib/PngImage/Tpngimage.bdsproj.local b/Game/Code/lib/PngImage/Tpngimage.bdsproj.local new file mode 100644 index 00000000..d576f039 --- /dev/null +++ b/Game/Code/lib/PngImage/Tpngimage.bdsproj.local @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8"?>
+<BorlandProject/>
diff --git a/Game/Code/lib/PngImage/Tpngimage.cfg b/Game/Code/lib/PngImage/Tpngimage.cfg new file mode 100644 index 00000000..4a78a005 --- /dev/null +++ b/Game/Code/lib/PngImage/Tpngimage.cfg @@ -0,0 +1,40 @@ +-$A8
+-$B-
+-$C+
+-$D+
+-$E-
+-$F-
+-$G+
+-$H+
+-$I+
+-$J-
+-$K-
+-$L+
+-$M-
+-$N+
+-$O+
+-$P+
+-$Q-
+-$R-
+-$S-
+-$T-
+-$U-
+-$V+
+-$W-
+-$X+
+-$YD
+-$Z1
+-GD
+-cg
+-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+-H+
+-W+
+-M
+-$M16384,1048576
+-K$00400000
+-LE"C:\Documents and Settings\Jay Binks\My Documents\Borland Studio Projects\Bpl"
+-LN"C:\Documents and Settings\Jay Binks\My Documents\Borland Studio Projects\Bpl"
+-Z
+-w-UNSAFE_TYPE
+-w-UNSAFE_CODE
+-w-UNSAFE_CAST
diff --git a/Game/Code/lib/PngImage/Tpngimage.dof b/Game/Code/lib/PngImage/Tpngimage.dof new file mode 100644 index 00000000..45e43c01 --- /dev/null +++ b/Game/Code/lib/PngImage/Tpngimage.dof @@ -0,0 +1,136 @@ +[FileVersion]
+Version=7.0
+[Compiler]
+A=8
+B=0
+C=1
+D=1
+E=0
+F=0
+G=1
+H=1
+I=1
+J=0
+K=0
+L=1
+M=0
+N=1
+O=1
+P=1
+Q=0
+R=0
+S=0
+T=0
+U=0
+V=1
+W=0
+X=1
+Y=1
+Z=1
+ShowHints=1
+ShowWarnings=1
+UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+NamespacePrefix=
+SymbolDeprecated=1
+SymbolLibrary=1
+SymbolPlatform=1
+UnitLibrary=1
+UnitPlatform=1
+UnitDeprecated=1
+HResultCompat=1
+HidingMember=1
+HiddenVirtual=1
+Garbage=1
+BoundsError=1
+ZeroNilCompat=1
+StringConstTruncated=1
+ForLoopVarVarPar=1
+TypedConstVarPar=1
+AsgToTypedConst=1
+CaseLabelRange=1
+ForVariable=1
+ConstructingAbstract=1
+ComparisonFalse=1
+ComparisonTrue=1
+ComparingSignedUnsigned=1
+CombiningSignedUnsigned=1
+UnsupportedConstruct=1
+FileOpen=1
+FileOpenUnitSrc=1
+BadGlobalSymbol=1
+DuplicateConstructorDestructor=1
+InvalidDirective=1
+PackageNoLink=1
+PackageThreadVar=1
+ImplicitImport=1
+HPPEMITIgnored=1
+NoRetVal=1
+UseBeforeDef=1
+ForLoopVarUndef=1
+UnitNameMismatch=1
+NoCFGFileFound=1
+MessageDirective=1
+ImplicitVariants=1
+UnicodeToLocale=1
+LocaleToUnicode=1
+ImagebaseMultiple=1
+SuspiciousTypecast=1
+PrivatePropAccessor=1
+UnsafeType=0
+UnsafeCode=0
+UnsafeCast=0
+[Linker]
+MapFile=0
+OutputObjs=0
+ConsoleApp=1
+DebugInfo=0
+RemoteSymbols=0
+MinStackSize=16384
+MaxStackSize=1048576
+ImageBase=4194304
+ExeDescription=
+[Directories]
+OutputDir=
+UnitOutputDir=
+PackageDLLOutputDir=
+PackageDCPOutputDir=
+SearchPath=
+Packages=vcl;rtl;vclx;VclSmp;vclshlctrls;VirtualTreesD7;Tpngimage;THTTPGet;XmlComponents_D6;EmbWb;TINetDetector;FolderDialog;Indy70;madBasic_;madHelp_;madDisAsm_;madExcept_;madRemote_;madKernel_;madCodeHook_;madSecurity_;madShell_;TRegs32;Progress;TTRAYICON;TXPPanel;DelphiX_for5
+Conditionals=
+DebugSourceDirs=
+UsePackages=0
+[Parameters]
+RunParams=
+HostApplication=
+Launcher=
+UseLauncher=0
+DebugCWD=
+[Language]
+ActiveLang=
+ProjectLang=
+RootDir=C:\Program Files\Borland\Delphi7\Bin\
+[Version Info]
+IncludeVerInfo=1
+AutoIncBuild=0
+MajorVer=1
+MinorVer=0
+Release=0
+Build=0
+Debug=0
+PreRelease=0
+Special=0
+Private=0
+DLL=0
+Locale=1033
+CodePage=1252
+[Version Info Keys]
+CompanyName=
+FileDescription=
+FileVersion=1.0.0.0
+InternalName=
+LegalCopyright=
+LegalTrademarks=
+OriginalFilename=
+ProductName=
+ProductVersion=1.0.0.0
+Comments=
diff --git a/Game/Code/lib/PngImage/Tpngimage.drc b/Game/Code/lib/PngImage/Tpngimage.drc new file mode 100644 index 00000000..52d3a522 --- /dev/null +++ b/Game/Code/lib/PngImage/Tpngimage.drc @@ -0,0 +1,62 @@ +/* VER180
+ Generated by the Borland Delphi Pascal Compiler
+ because -GD or --drc was supplied to the compiler.
+
+ This file contains compiler-generated resources that
+ were bound to the executable.
+ If this file is empty, then no compiler-generated
+ resources were bound to the produced executable.
+*/
+
+#define pnglang_EPNGNoImageDataText 65504
+#define pnglang_EPNGCannotChangeSizeText 65505
+#define pnglang_EPNGCannotAddChunkText 65506
+#define pnglang_EPNGCannotAddInvalidImageText 65507
+#define pnglang_EPNGCouldNotLoadResourceText 65508
+#define pnglang_EPNGOutMemoryText 65509
+#define pnglang_EPNGCannotChangeTransparentText 65510
+#define pnglang_EPNGHeaderNotPresentText 65511
+#define pnglang_EPngInvalidCRCText 65520
+#define pnglang_EPNGInvalidIHDRText 65521
+#define pnglang_EPNGMissingMultipleIDATText 65522
+#define pnglang_EPNGZLIBErrorText 65523
+#define pnglang_EPNGInvalidPaletteText 65524
+#define pnglang_EPNGInvalidFileHeaderText 65525
+#define pnglang_EPNGIHDRNotFirstText 65526
+#define pnglang_EPNGNotExistsText 65527
+#define pnglang_EPNGSizeExceedsText 65528
+#define pnglang_EPNGUnknownPalEntryText 65529
+#define pnglang_EPNGMissingPaletteText 65530
+#define pnglang_EPNGUnknownCriticalChunkText 65531
+#define pnglang_EPNGUnknownCompressionText 65532
+#define pnglang_EPNGUnknownInterlaceText 65533
+#define pnglang_EPNGCannotAssignChunkText 65534
+#define pnglang_EPNGUnexpectedEndText 65535
+STRINGTABLE
+BEGIN
+ pnglang_EPNGNoImageDataText, "This \"Portable Network Graphics\" image contains no data."
+ pnglang_EPNGCannotChangeSizeText, "The \"Portable Network Graphics\" image can not be resize by changing width and height properties. Try assigning the image from a bitmap."
+ pnglang_EPNGCannotAddChunkText, "The program tried to add a existent critical chunk to the current image which is not allowed."
+ pnglang_EPNGCannotAddInvalidImageText, "It's not allowed to add a new chunk because the current image is invalid."
+ pnglang_EPNGCouldNotLoadResourceText, "The png image could not be loaded from the resource ID."
+ pnglang_EPNGOutMemoryText, "Some operation could not be performed because the system is out of resources. Close some windows and try again."
+ pnglang_EPNGCannotChangeTransparentText, "Setting bit transparency color is not allowed for png images containing alpha value for each pixel (COLOR_RGBALPHA and COLOR_GRAYSCALEALPHA)"
+ pnglang_EPNGHeaderNotPresentText, "This operation is not valid because the current image contains no valid header."
+ pnglang_EPngInvalidCRCText, "This \"Portable Network Graphics\" image is not valid because it contains invalid pieces of data (crc error)"
+ pnglang_EPNGInvalidIHDRText, "The \"Portable Network Graphics\" image could not be loaded because one of its main piece of data (ihdr) might be corrupted"
+ pnglang_EPNGMissingMultipleIDATText, "This \"Portable Network Graphics\" image is invalid because it has missing image parts."
+ pnglang_EPNGZLIBErrorText, "Could not decompress the image because it contains invalid compressed data.\r\n Description: "
+ pnglang_EPNGInvalidPaletteText, "The \"Portable Network Graphics\" image contains an invalid palette."
+ pnglang_EPNGInvalidFileHeaderText, "The file being readed is not a valid \"Portable Network Graphics\" image because it contains an invalid header. This file may be corruped, try obtaining it again."
+ pnglang_EPNGIHDRNotFirstText, "This \"Portable Network Graphics\" image is not supported or it might be invalid.\r\n(IHDR chunk is not the first)"
+ pnglang_EPNGNotExistsText, "The png file could not be loaded because it does not exists."
+ pnglang_EPNGSizeExceedsText, "This \"Portable Network Graphics\" image is not supported because either it's width or height exceeds the maximum size, which is 65535 pixels length."
+ pnglang_EPNGUnknownPalEntryText, "There is no such palette entry."
+ pnglang_EPNGMissingPaletteText, "This \"Portable Network Graphics\" could not be loaded because it uses a color table which is missing."
+ pnglang_EPNGUnknownCriticalChunkText, "This \"Portable Network Graphics\" image contains an unknown critical part which could not be decoded."
+ pnglang_EPNGUnknownCompressionText, "This \"Portable Network Graphics\" image is encoded with an unknown compression scheme which could not be decoded."
+ pnglang_EPNGUnknownInterlaceText, "This \"Portable Network Graphics\" image uses an unknown interlace scheme which could not be decoded."
+ pnglang_EPNGCannotAssignChunkText, "The chunks must be compatible to be assigned."
+ pnglang_EPNGUnexpectedEndText, "This \"Portable Network Graphics\" image is invalid because the decoder found an unexpected end of the file."
+END
+
diff --git a/Game/Code/lib/PngImage/Tpngimage.res b/Game/Code/lib/PngImage/Tpngimage.res Binary files differnew file mode 100644 index 00000000..aac9aa64 --- /dev/null +++ b/Game/Code/lib/PngImage/Tpngimage.res diff --git a/Game/Code/lib/PngImage/Tpngimage.stat b/Game/Code/lib/PngImage/Tpngimage.stat new file mode 100644 index 00000000..57f32789 --- /dev/null +++ b/Game/Code/lib/PngImage/Tpngimage.stat @@ -0,0 +1,10 @@ +[Stats]
+EditorSecs=3
+DesignerSecs=1
+InspectorSecs=1
+CompileSecs=1542
+OtherSecs=11
+StartTime=5/6/2004 7:36:05 PM
+RealKeys=0
+EffectiveKeys=0
+DebugSecs=1
diff --git a/Game/Code/lib/PngImage/lazarustest.lpi b/Game/Code/lib/PngImage/lazarustest.lpi new file mode 100644 index 00000000..4dec8a9e --- /dev/null +++ b/Game/Code/lib/PngImage/lazarustest.lpi @@ -0,0 +1,239 @@ +<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="\"/>
+ <Version Value="5"/>
+ <General>
+ <MainUnit Value="0"/>
+ <IconPath Value="./"/>
+ <TargetFileExt Value=".exe"/>
+ <ActiveEditorIndexAtStart Value="0"/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ <Language Value=""/>
+ <CharSet Value=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <IgnoreBinaries Value="False"/>
+ <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
+ <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ </local>
+ </RunParams>
+ <Units Count="8">
+ <Unit0>
+ <Filename Value="lazarustest.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="lazarustest"/>
+ <CursorPos X="49" Y="11"/>
+ <TopLine Value="1"/>
+ <EditorIndex Value="0"/>
+ <UsageCount Value="23"/>
+ <Loaded Value="True"/>
+ </Unit0>
+ <Unit1>
+ <Filename Value="delphi\bass.pas"/>
+ <UnitName Value="Bass"/>
+ <CursorPos X="12" Y="539"/>
+ <TopLine Value="589"/>
+ <UsageCount Value="10"/>
+ </Unit1>
+ <Unit2>
+ <Filename Value="avformat.pas"/>
+ <UnitName Value="avformat"/>
+ <CursorPos X="38" Y="594"/>
+ <TopLine Value="567"/>
+ <UsageCount Value="10"/>
+ </Unit2>
+ <Unit3>
+ <Filename Value="avcodec.pas"/>
+ <UnitName Value="avcodec"/>
+ <CursorPos X="3" Y="1796"/>
+ <TopLine Value="1775"/>
+ <UsageCount Value="11"/>
+ </Unit3>
+ <Unit4>
+ <Filename Value="avio.pas"/>
+ <UnitName Value="avio"/>
+ <CursorPos X="1" Y="1"/>
+ <TopLine Value="1"/>
+ <UsageCount Value="11"/>
+ </Unit4>
+ <Unit5>
+ <Filename Value="pngimage.pas"/>
+ <UnitName Value="pngimage"/>
+ <CursorPos X="20" Y="133"/>
+ <TopLine Value="121"/>
+ <EditorIndex Value="1"/>
+ <UsageCount Value="10"/>
+ <Loaded Value="True"/>
+ </Unit5>
+ <Unit6>
+ <Filename Value="pngzlib.pas"/>
+ <UnitName Value="pngzlib"/>
+ <CursorPos X="6" Y="111"/>
+ <TopLine Value="91"/>
+ <EditorIndex Value="3"/>
+ <UsageCount Value="10"/>
+ <Loaded Value="True"/>
+ </Unit6>
+ <Unit7>
+ <Filename Value="pnglang.pas"/>
+ <UnitName Value="pnglang"/>
+ <CursorPos X="1" Y="1"/>
+ <TopLine Value="1"/>
+ <EditorIndex Value="2"/>
+ <UsageCount Value="10"/>
+ <Loaded Value="True"/>
+ </Unit7>
+ </Units>
+ <JumpHistory Count="30" HistoryIndex="29">
+ <Position1>
+ <Filename Value="pngimage.pas"/>
+ <Caret Line="4037" Column="16" TopLine="4017"/>
+ </Position1>
+ <Position2>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="19" Column="1" TopLine="1"/>
+ </Position2>
+ <Position3>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="6" Column="1" TopLine="1"/>
+ </Position3>
+ <Position4>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="4" Column="1" TopLine="1"/>
+ </Position4>
+ <Position5>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="8" Column="30" TopLine="1"/>
+ </Position5>
+ <Position6>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="38" Column="37" TopLine="18"/>
+ </Position6>
+ <Position7>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="52" Column="16" TopLine="31"/>
+ </Position7>
+ <Position8>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="6" Column="1" TopLine="1"/>
+ </Position8>
+ <Position9>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="124" Column="82" TopLine="86"/>
+ </Position9>
+ <Position10>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="1" Column="1" TopLine="1"/>
+ </Position10>
+ <Position11>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="103" Column="6" TopLine="83"/>
+ </Position11>
+ <Position12>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="104" Column="6" TopLine="84"/>
+ </Position12>
+ <Position13>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="105" Column="6" TopLine="85"/>
+ </Position13>
+ <Position14>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="106" Column="6" TopLine="86"/>
+ </Position14>
+ <Position15>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="107" Column="6" TopLine="87"/>
+ </Position15>
+ <Position16>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="108" Column="6" TopLine="88"/>
+ </Position16>
+ <Position17>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="109" Column="6" TopLine="89"/>
+ </Position17>
+ <Position18>
+ <Filename Value="pngzlib.pas"/>
+ <Caret Line="110" Column="6" TopLine="90"/>
+ </Position18>
+ <Position19>
+ <Filename Value="pngimage.pas"/>
+ <Caret Line="4037" Column="62" TopLine="4017"/>
+ </Position19>
+ <Position20>
+ <Filename Value="pnglang.pas"/>
+ <Caret Line="275" Column="31" TopLine="255"/>
+ </Position20>
+ <Position21>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="19" Column="1" TopLine="1"/>
+ </Position21>
+ <Position22>
+ <Filename Value="pngimage.pas"/>
+ <Caret Line="1" Column="1" TopLine="1"/>
+ </Position22>
+ <Position23>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="19" Column="1" TopLine="1"/>
+ </Position23>
+ <Position24>
+ <Filename Value="pngimage.pas"/>
+ <Caret Line="1" Column="1" TopLine="1"/>
+ </Position24>
+ <Position25>
+ <Filename Value="pngimage.pas"/>
+ <Caret Line="139" Column="10" TopLine="119"/>
+ </Position25>
+ <Position26>
+ <Filename Value="pngimage.pas"/>
+ <Caret Line="138" Column="1" TopLine="119"/>
+ </Position26>
+ <Position27>
+ <Filename Value="pngimage.pas"/>
+ <Caret Line="146" Column="38" TopLine="121"/>
+ </Position27>
+ <Position28>
+ <Filename Value="pngimage.pas"/>
+ <Caret Line="141" Column="2" TopLine="121"/>
+ </Position28>
+ <Position29>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="11" Column="20" TopLine="1"/>
+ </Position29>
+ <Position30>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="14" Column="1" TopLine="1"/>
+ </Position30>
+ </JumpHistory>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <PathDelim Value="\"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+ <Debugging>
+ <Exceptions Count="2">
+ <Item1>
+ <Name Value="ECodetoolError"/>
+ </Item1>
+ <Item2>
+ <Name Value="EFOpenError"/>
+ </Item2>
+ </Exceptions>
+ </Debugging>
+</CONFIG>
diff --git a/Game/Code/lib/PngImage/lazarustest.lpr b/Game/Code/lib/PngImage/lazarustest.lpr new file mode 100644 index 00000000..f567b6cb --- /dev/null +++ b/Game/Code/lib/PngImage/lazarustest.lpr @@ -0,0 +1,15 @@ +program lazarustest;
+
+uses
+ pngimage in 'pngimage.pas',
+ pnglang in 'pnglang.pas',
+ pngzlib in 'pngzlib.pas',
+ sysutils;
+
+begin
+ writeln( 'pngimage is NOT lazarus compatible' );
+ writeln( 'It might compile ( not link though ), however the object files are in borland obj format' );
+ writeln( 'to use this, it will need to be in GCC object file format format' );
+ writeln( 'Or we can use the lazarus / freepascal png unit' );
+end.
+
diff --git a/Game/Code/lib/PngImage/obj/adler32.obj b/Game/Code/lib/PngImage/obj/adler32.obj Binary files differnew file mode 100644 index 00000000..7da9fd19 --- /dev/null +++ b/Game/Code/lib/PngImage/obj/adler32.obj diff --git a/Game/Code/lib/PngImage/obj/deflate.obj b/Game/Code/lib/PngImage/obj/deflate.obj Binary files differnew file mode 100644 index 00000000..804e9334 --- /dev/null +++ b/Game/Code/lib/PngImage/obj/deflate.obj diff --git a/Game/Code/lib/PngImage/obj/infblock.obj b/Game/Code/lib/PngImage/obj/infblock.obj Binary files differnew file mode 100644 index 00000000..3bc38e41 --- /dev/null +++ b/Game/Code/lib/PngImage/obj/infblock.obj diff --git a/Game/Code/lib/PngImage/obj/infcodes.obj b/Game/Code/lib/PngImage/obj/infcodes.obj Binary files differnew file mode 100644 index 00000000..faec2222 --- /dev/null +++ b/Game/Code/lib/PngImage/obj/infcodes.obj diff --git a/Game/Code/lib/PngImage/obj/inffast.obj b/Game/Code/lib/PngImage/obj/inffast.obj Binary files differnew file mode 100644 index 00000000..62e18ceb --- /dev/null +++ b/Game/Code/lib/PngImage/obj/inffast.obj diff --git a/Game/Code/lib/PngImage/obj/inflate.obj b/Game/Code/lib/PngImage/obj/inflate.obj Binary files differnew file mode 100644 index 00000000..7dc522e0 --- /dev/null +++ b/Game/Code/lib/PngImage/obj/inflate.obj diff --git a/Game/Code/lib/PngImage/obj/inftrees.obj b/Game/Code/lib/PngImage/obj/inftrees.obj Binary files differnew file mode 100644 index 00000000..5755233f --- /dev/null +++ b/Game/Code/lib/PngImage/obj/inftrees.obj diff --git a/Game/Code/lib/PngImage/obj/infutil.obj b/Game/Code/lib/PngImage/obj/infutil.obj Binary files differnew file mode 100644 index 00000000..7e175a83 --- /dev/null +++ b/Game/Code/lib/PngImage/obj/infutil.obj diff --git a/Game/Code/lib/PngImage/obj/trees.obj b/Game/Code/lib/PngImage/obj/trees.obj Binary files differnew file mode 100644 index 00000000..81f05568 --- /dev/null +++ b/Game/Code/lib/PngImage/obj/trees.obj diff --git a/Game/Code/lib/PngImage/pngimage.chm b/Game/Code/lib/PngImage/pngimage.chm Binary files differnew file mode 100644 index 00000000..c7e51b2e --- /dev/null +++ b/Game/Code/lib/PngImage/pngimage.chm diff --git a/Game/Code/lib/PngImage/pngimage.pas b/Game/Code/lib/PngImage/pngimage.pas new file mode 100644 index 00000000..ecd52c5b --- /dev/null +++ b/Game/Code/lib/PngImage/pngimage.pas @@ -0,0 +1,5213 @@ +{Portable Network Graphics Delphi 1.4361 (8 March 2003) }
+
+{This is the latest implementation for TPngImage component }
+{It's meant to be a full replacement for the previous one. }
+{There are lots of new improvements, including cleaner code, }
+{full partial transparency support, speed improvements, }
+{saving using ADAM 7 interlacing, better error handling, also }
+{the best compression for the final image ever. And now it's }
+{truly able to read about any png image. }
+
+{
+ Version 1.4361
+ 2003-03-04 - Fixed important bug for simple transparency when using
+ RGB, Grayscale color modes
+
+ Version 1.436
+ 2003-03-04 - * NEW * Property Pixels for direct access to pixels
+ * IMPROVED * Palette property (TPngObject) (read only)
+ Slovenian traslation for the component (Miha Petelin)
+ Help file update (scanline article/png->jpg example)
+
+ Version 1.435
+ 2003-11-03 - * NEW * New chunk implementation zTXt (method AddzTXt)
+ * NEW * New compiler flags to store the extra 8 bits
+ from 16 bits samples (when saving it is ignored), the
+ extra data may be acessed using ExtraScanline property
+ * Fixed * a bug on tIMe chunk
+ French translation included (Thanks to IBE Software)
+ Bugs fixed
+
+ Version 1.432
+ 2002-08-24 - * NEW * A new method, CreateAlpha will transform the
+ current image into partial transparency.
+ Help file updated with a new article on how to handle
+ partial transparency.
+
+ Version 1.431
+ 2002-08-14 - Fixed and tested to work on:
+ C++ Builder 3
+ C++ Builder 5
+ Delphi 3
+ There was an error when setting TransparentColor, fixed
+ New method, RemoveTransparency to remove image
+ BIT TRANSPARENCY
+
+ Version 1.43
+ 2002-08-01 - * NEW * Support for Delphi 3 and C++ Builder 3
+ Implements mostly some things that were missing,
+ a few tweaks and fixes.
+
+ Version 1.428
+ 2002-07-24 - More minor fixes (thanks to Ian Boyd)
+ Bit transparency fixes
+ * NEW * Finally support to bit transparency
+ (palette / rgb / grayscale -> all)
+
+ Version 1.427
+ 2002-07-19 - Lots of bugs and leaks fixed
+ * NEW * method to easy adding text comments, AddtEXt
+ * NEW * property for setting bit transparency,
+ TransparentColor
+
+ Version 1.426
+ 2002-07-18 - Clipboard finally fixed (hope)
+ Changed UseDelphi trigger to UseDelphi
+ * NEW * Support for bit transparency bitmaps
+ when assigning from/to TBitmap objects
+ Altough it does not support drawing transparent
+ parts of bit transparency pngs (only partial)
+ it is closer than ever
+
+ Version 1.425
+ 2002-07-01 - Clipboard methods implemented
+ Lots of bugs fixed
+
+ Version 1.424
+ 2002-05-16 - Scanline and AlphaScanline are now working correctly.
+ New methods for handling the clipboard
+
+ Version 1.423
+ 2002-05-16 - * NEW * Partial transparency for 1, 2, 4 and 8 bits is
+ also supported using the tRNS chunk (for palette and
+ grayscaling).
+ New bug fixes (Peter Haas).
+
+ Version 1.422
+ 2002-05-14 - Fixed some critical leaks, thanks to Peter Haas tips.
+ New translation for German (Peter Haas).
+
+ Version 1.421
+ 2002-05-06 - Now uses new ZLIB version, 1.1.4 with some security
+ fixes.
+ LoadFromResourceID and LoadFromResourceName added and
+ help file updated for that.
+ The resources strings are now located in pnglang.pas.
+ New translation for Brazilian Portuguese.
+ Bugs fixed.
+
+ IMPORTANT: I'm currently looking for bugs on the library. If
+ anyone has found one, please send me an email and
+ I will fix right away. Thanks for all the help and
+ ideias I'm receiving so far.}
+
+{My new email is: gubadaud@terra.com.br}
+{Website link : pngdelphi.sourceforge.net}
+{Gustavo Huffenbacher Daud}
+
+unit pngimage;
+
+interface
+
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
+{Triggers avaliable (edit the fields bellow)}
+{$IFNDef FPC}
+{$DEFINE UseDelphi} //Disable fat vcl units (perfect to small apps)
+{$ENDIF}
+
+{$DEFINE ErrorOnUnknownCritical} //Error when finds an unknown critical chunk
+{$DEFINE CheckCRC} //Enables CRC checking
+{$DEFINE RegisterGraphic} //Registers TPNGObject to use with TPicture
+{$DEFINE PartialTransparentDraw} //Draws partial transparent images
+{.$DEFINE Store16bits} //Stores the extra 8 bits from 16bits/sample
+{.$DEFINE Debug} //For programming purposes
+{$RANGECHECKS OFF} {$J+}
+
+
+
+uses
+ Windows,
+ {$IFDEF UseDelphi}
+ Classes,
+ Graphics,
+ SysUtils,
+ {$ENDIF}
+ {$IFDEF Debug}
+ dialogs,
+ {$ENDIF}
+ pngzlib,
+ pnglang;
+
+{$IFNDEF UseDelphi}
+ const
+ soFromBeginning = 0;
+ soFromCurrent = 1;
+ soFromEnd = 2;
+{$ENDIF}
+
+const
+ {ZLIB constants}
+ ZLIBErrors: Array[-6..2] of string = ('incompatible version (-6)',
+ 'buffer error (-5)', 'insufficient memory (-4)', 'data error (-3)',
+ 'stream error (-2)', 'file error (-1)', '(0)', 'stream end (1)',
+ 'need dictionary (2)');
+ Z_NO_FLUSH = 0;
+ Z_FINISH = 4;
+ Z_STREAM_END = 1;
+
+ {Avaliable PNG filters for mode 0}
+ FILTER_NONE = 0;
+ FILTER_SUB = 1;
+ FILTER_UP = 2;
+ FILTER_AVERAGE = 3;
+ FILTER_PAETH = 4;
+
+ {Avaliable color modes for PNG}
+ COLOR_GRAYSCALE = 0;
+ COLOR_RGB = 2;
+ COLOR_PALETTE = 3;
+ COLOR_GRAYSCALEALPHA = 4;
+ COLOR_RGBALPHA = 6;
+
+
+type
+ {$IFNDEF UseDelphi}
+ {Custom exception handler}
+ Exception = class(TObject)
+ constructor Create(Msg: String);
+ end;
+ ExceptClass = class of Exception;
+ TColor = ColorRef;
+ {$ENDIF}
+
+ {Error types}
+ EPNGOutMemory = class(Exception);
+ EPngError = class(Exception);
+ EPngUnexpectedEnd = class(Exception);
+ EPngInvalidCRC = class(Exception);
+ EPngInvalidIHDR = class(Exception);
+ EPNGMissingMultipleIDAT = class(Exception);
+ EPNGZLIBError = class(Exception);
+ EPNGInvalidPalette = class(Exception);
+ EPNGInvalidFileHeader = class(Exception);
+ EPNGIHDRNotFirst = class(Exception);
+ EPNGNotExists = class(Exception);
+ EPNGSizeExceeds = class(Exception);
+ EPNGMissingPalette = class(Exception);
+ EPNGUnknownCriticalChunk = class(Exception);
+ EPNGUnknownCompression = class(Exception);
+ EPNGUnknownInterlace = class(Exception);
+ EPNGNoImageData = class(Exception);
+ EPNGCouldNotLoadResource = class(Exception);
+ EPNGCannotChangeTransparent = class(Exception);
+ EPNGHeaderNotPresent = class(Exception);
+
+type
+ {Direct access to pixels using R,G,B}
+ TRGBLine = array[word] of TRGBTriple;
+ pRGBLine = ^TRGBLine;
+
+ {Same as TBitmapInfo but with allocated space for}
+ {palette entries}
+ TMAXBITMAPINFO = packed record
+ bmiHeader: TBitmapInfoHeader;
+ bmiColors: packed array[0..255] of TRGBQuad;
+ end;
+
+ {Transparency mode for pngs}
+ TPNGTransparencyMode = (ptmNone, ptmBit, ptmPartial);
+ {Pointer to a cardinal type}
+ pCardinal = ^Cardinal;
+ {Access to a rgb pixel}
+ pRGBPixel = ^TRGBPixel;
+ TRGBPixel = packed record
+ B, G, R: Byte;
+ end;
+
+ {Pointer to an array of bytes type}
+ TByteArray = Array[Word] of Byte;
+ pByteArray = ^TByteArray;
+
+ {Forward}
+ TPNGObject = class;
+ pPointerArray = ^TPointerArray;
+ TPointerArray = Array[Word] of Pointer;
+
+ {Contains a list of objects}
+ TPNGPointerList = class
+ private
+ fOwner: TPNGObject;
+ fCount : Cardinal;
+ fMemory: pPointerArray;
+ function GetItem(Index: Cardinal): Pointer;
+ procedure SetItem(Index: Cardinal; const Value: Pointer);
+ protected
+ {Removes an item}
+ function Remove(Value: Pointer): Pointer; virtual;
+ {Inserts an item}
+ procedure Insert(Value: Pointer; Position: Cardinal);
+ {Add a new item}
+ procedure Add(Value: Pointer);
+ {Returns an item}
+ property Item[Index: Cardinal]: Pointer read GetItem write SetItem;
+ {Set the size of the list}
+ procedure SetSize(const Size: Cardinal);
+ {Returns owner}
+ property Owner: TPNGObject read fOwner;
+ public
+ {Returns number of items}
+ property Count: Cardinal read fCount write SetSize;
+ {Object being either created or destroyed}
+ constructor Create(AOwner: TPNGObject);
+ destructor Destroy; override;
+ end;
+
+ {Forward declaration}
+ TChunk = class;
+ TChunkClass = class of TChunk;
+
+ {Same as TPNGPointerList but providing typecasted values}
+ TPNGList = class(TPNGPointerList)
+ private
+ {Used with property Item}
+ function GetItem(Index: Cardinal): TChunk;
+ public
+ {Removes an item}
+ procedure RemoveChunk(Chunk: TChunk); overload;
+ {Add a new chunk using the class from the parameter}
+ function Add(ChunkClass: TChunkClass): TChunk;
+ {Returns pointer to the first chunk of class}
+ function ItemFromClass(ChunkClass: TChunkClass): TChunk;
+ {Returns a chunk item from the list}
+ property Item[Index: Cardinal]: TChunk read GetItem;
+ end;
+
+ {$IFNDEF UseDelphi}
+ {The STREAMs bellow are only needed in case delphi provided ones is not}
+ {avaliable (UseDelphi trigger not set)}
+ {Object becomes handles}
+ TCanvas = THandle;
+ TBitmap = HBitmap;
+ {Trick to work}
+ TPersistent = TObject;
+
+ {Base class for all streams}
+ TStream = class
+ protected
+ {Returning/setting size}
+ function GetSize: Longint; virtual;
+ procedure SetSize(const Value: Longint); virtual; abstract;
+ {Returns/set position}
+ function GetPosition: Longint; virtual;
+ procedure SetPosition(const Value: Longint); virtual;
+ public
+ {Returns/sets current position}
+ property Position: Longint read GetPosition write SetPosition;
+ {Property returns/sets size}
+ property Size: Longint read GetSize write SetSize;
+ {Allows reading/writing data}
+ function Read(var Buffer; Count: Longint): Cardinal; virtual; abstract;
+ function Write(const Buffer; Count: Longint): Cardinal; virtual; abstract;
+ {Copies from another Stream}
+ function CopyFrom(Source: TStream;
+ Count: Cardinal): Cardinal; virtual;
+ {Seeks a stream position}
+ function Seek(Offset: Longint; Origin: Word): Longint; virtual; abstract;
+ end;
+
+ {File stream modes}
+ TFileStreamMode = (fsmRead, fsmWrite, fsmCreate);
+ TFileStreamModeSet = set of TFileStreamMode;
+
+ {File stream for reading from files}
+ TFileStream = class(TStream)
+ private
+ {Opened mode}
+ Filemode: TFileStreamModeSet;
+ {Handle}
+ fHandle: THandle;
+ protected
+ {Set the size of the file}
+ procedure SetSize(const Value: Longint); override;
+ public
+ {Seeks a file position}
+ function Seek(Offset: Longint; Origin: Word): Longint; override;
+ {Reads/writes data from/to the file}
+ function Read(var Buffer; Count: Longint): Cardinal; override;
+ function Write(const Buffer; Count: Longint): Cardinal; override;
+ {Stream being created and destroy}
+ constructor Create(Filename: String; Mode: TFileStreamModeSet);
+ destructor Destroy; override;
+ end;
+
+ {Stream for reading from resources}
+ TResourceStream = class(TStream)
+ constructor Create(Instance: HInst; const ResName: String; ResType:PChar);
+ private
+ {Variables for reading}
+ Size: Integer;
+ Memory: Pointer;
+ Position: Integer;
+ protected
+ {Set the size of the file}
+ procedure SetSize(const Value: Longint); override;
+ public
+ {Stream processing}
+ function Read(var Buffer; Count: Integer): Cardinal; override;
+ function Seek(Offset: Integer; Origin: Word): Longint; override;
+ function Write(const Buffer; Count: Longint): Cardinal; override;
+ end;
+ {$ENDIF}
+
+ {Forward}
+ TChunkIHDR = class;
+ {Interlace method}
+ TInterlaceMethod = (imNone, imAdam7);
+ {Compression level type}
+ TCompressionLevel = 0..9;
+ {Filters type}
+ TFilter = (pfNone, pfSub, pfUp, pfAverage, pfPaeth);
+ TFilters = set of TFilter;
+
+ {Png implementation object}
+ TPngObject = class{$IFDEF UseDelphi}(TGraphic){$ENDIF}
+ protected
+ {Gamma table values}
+ GammaTable, InverseGamma: Array[Byte] of Byte;
+ procedure InitializeGamma;
+ private
+ {Temporary palette}
+ TempPalette: HPalette;
+ {Filters to test to encode}
+ fFilters: TFilters;
+ {Compression level for ZLIB}
+ fCompressionLevel: TCompressionLevel;
+ {Maximum size for IDAT chunks}
+ fMaxIdatSize: Cardinal;
+ {Returns if image is interlaced}
+ fInterlaceMethod: TInterlaceMethod;
+ {Chunks object}
+ fChunkList: TPngList;
+ {Clear all chunks in the list}
+ procedure ClearChunks;
+ {Returns if header is present}
+ function HeaderPresent: Boolean;
+ {Returns linesize and byte offset for pixels}
+ procedure GetPixelInfo(var LineSize, Offset: Cardinal);
+ procedure SetMaxIdatSize(const Value: Cardinal);
+ function GetAlphaScanline(const LineIndex: Integer): pByteArray;
+ function GetScanline(const LineIndex: Integer): Pointer;
+ {$IFDEF Store16bits}
+ function GetExtraScanline(const LineIndex: Integer): Pointer;
+ {$ENDIF}
+ function GetTransparencyMode: TPNGTransparencyMode;
+ function GetTransparentColor: TColor;
+ procedure SetTransparentColor(const Value: TColor);
+ protected
+ {Returns the image palette}
+ function GetPalette: HPALETTE; {$IFDEF UseDelphi}override;{$ENDIF}
+ {Returns/sets image width and height}
+ function GetWidth: Integer; {$IFDEF UseDelphi}override;{$ENDIF}
+ function GetHeight: Integer; {$IFDEF UseDelphi}override; {$ENDIF}
+ procedure SetWidth(Value: Integer); {$IFDEF UseDelphi}override; {$ENDIF}
+ procedure SetHeight(Value: Integer); {$IFDEF UseDelphi}override;{$ENDIF}
+ {Assigns from another TPNGObject}
+ procedure AssignPNG(Source: TPNGObject);
+ {Returns if the image is empty}
+ function GetEmpty: Boolean; {$IFDEF UseDelphi}override; {$ENDIF}
+ {Used with property Header}
+ function GetHeader: TChunkIHDR;
+ {Draws using partial transparency}
+ procedure DrawPartialTrans(DC: HDC; Rect: TRect);
+ {$IFDEF UseDelphi}
+ {Returns if the image is transparent}
+ function GetTransparent: Boolean; override;
+ {$ENDIF}
+ {Returns a pixel}
+ function GetPixels(const X, Y: Integer): TColor; virtual;
+ procedure SetPixels(const X, Y: Integer; const Value: TColor); virtual;
+ public
+ {Generates alpha information}
+ procedure CreateAlpha;
+ {Removes the image transparency}
+ procedure RemoveTransparency;
+ {Transparent color}
+ property TransparentColor: TColor read GetTransparentColor write
+ SetTransparentColor;
+ {Add text chunk, TChunkTEXT, TChunkzTXT}
+ procedure AddtEXt(const Keyword, Text: String);
+ procedure AddzTXt(const Keyword, Text: String);
+ {$IFDEF UseDelphi}
+ {Saves to clipboard format (thanks to Antoine Pottern)}
+ procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle;
+ var APalette: HPalette); override;
+ procedure LoadFromClipboardFormat(AFormat: Word; AData: THandle;
+ APalette: HPalette); override;
+ {$ENDIF}
+ {Calling errors}
+ procedure RaiseError(ExceptionClass: ExceptClass; Text: String);
+ {Returns a scanline from png}
+ property Scanline[const Index: Integer]: Pointer read GetScanline;
+ {$IFDEF Store16bits}
+ property ExtraScanline[const Index: Integer]: Pointer read GetExtraScanline;
+ {$ENDIF}
+ property AlphaScanline[const Index: Integer]: pByteArray read GetAlphaScanline;
+ {Returns pointer to the header}
+ property Header: TChunkIHDR read GetHeader;
+ {Returns the transparency mode used by this png}
+ property TransparencyMode: TPNGTransparencyMode read GetTransparencyMode;
+ {Assigns from another object}
+ procedure Assign(Source: TPersistent);{$IFDEF UseDelphi}override;{$ENDIF}
+ {Assigns to another object}
+ procedure AssignTo(Dest: TPersistent);{$IFDEF UseDelphi}override;{$ENDIF}
+ {Assigns from a windows bitmap handle}
+ procedure AssignHandle(Handle: HBitmap; Transparent: Boolean;
+ TransparentColor: ColorRef);
+ {Draws the image into a canvas}
+ procedure Draw(ACanvas: TCanvas; const Rect: TRect);
+ {$IFDEF UseDelphi}override;{$ENDIF}
+ {Width and height properties}
+ property Width: Integer read GetWidth;
+ property Height: Integer read GetHeight;
+ {Returns if the image is interlaced}
+ property InterlaceMethod: TInterlaceMethod read fInterlaceMethod
+ write fInterlaceMethod;
+ {Filters to test to encode}
+ property Filters: TFilters read fFilters write fFilters;
+ {Maximum size for IDAT chunks, default and minimum is 65536}
+ property MaxIdatSize: Cardinal read fMaxIdatSize write SetMaxIdatSize;
+ {Property to return if the image is empty or not}
+ property Empty: Boolean read GetEmpty;
+ {Compression level}
+ property CompressionLevel: TCompressionLevel read fCompressionLevel
+ write fCompressionLevel;
+ {Access to the chunk list}
+ property Chunks: TPngList read fChunkList;
+ {Object being created and destroyed}
+ constructor Create; {$IFDEF UseDelphi}override;{$ENDIF}
+ destructor Destroy; override;
+ {$IFNDEF UseDelphi}procedure LoadFromFile(const Filename: String);{$ENDIF}
+ {$IFNDEF UseDelphi}procedure SaveToFile(const Filename: String);{$ENDIF}
+ procedure LoadFromStream(Stream: TStream); {$IFDEF UseDelphi}override;{$ENDIF}
+ procedure SaveToStream(Stream: TStream); {$IFDEF UseDelphi}override;{$ENDIF}
+ {Loading the image from resources}
+ procedure LoadFromResourceName(Instance: HInst; const Name: String);
+ procedure LoadFromResourceID(Instance: HInst; ResID: Integer);
+ {Access to the png pixels}
+ property Pixels[const X, Y: Integer]: TColor read GetPixels write SetPixels;
+ {Palette property}
+ {$IFNDEF UseDelphi}property Palette: HPalette read GetPalette;{$ENDIF}
+ end;
+
+ {Chunk name object}
+ TChunkName = Array[0..3] of Char;
+
+ {Global chunk object}
+ TChunk = class
+ private
+ {Contains data}
+ fData: Pointer;
+ fDataSize: Cardinal;
+ {Stores owner}
+ fOwner: TPngObject;
+ {Stores the chunk name}
+ fName: TChunkName;
+ {Returns pointer to the TChunkIHDR}
+ function GetHeader: TChunkIHDR;
+ {Used with property index}
+ function GetIndex: Integer;
+ {Should return chunk class/name}
+ class function GetName: String; virtual;
+ {Returns the chunk name}
+ function GetChunkName: String;
+ public
+ {Returns index from list}
+ property Index: Integer read GetIndex;
+ {Returns pointer to the TChunkIHDR}
+ property Header: TChunkIHDR read GetHeader;
+ {Resize the data}
+ procedure ResizeData(const NewSize: Cardinal);
+ {Returns data and size}
+ property Data: Pointer read fData;
+ property DataSize: Cardinal read fDataSize;
+ {Assigns from another TChunk}
+ procedure Assign(Source: TChunk); virtual;
+ {Returns owner}
+ property Owner: TPngObject read fOwner;
+ {Being destroyed/created}
+ constructor Create(Owner: TPngObject); virtual;
+ destructor Destroy; override;
+ {Returns chunk class/name}
+ property Name: String read GetChunkName;
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; virtual;
+ {Saves the chunk to a stream}
+ function SaveData(Stream: TStream): Boolean;
+ function SaveToStream(Stream: TStream): Boolean; virtual;
+ end;
+
+ {Chunk classes}
+ TChunkIEND = class(TChunk); {End chunk}
+
+ {IHDR data}
+ pIHDRData = ^TIHDRData;
+ TIHDRData = packed record
+ Width, Height: Cardinal;
+ BitDepth,
+ ColorType,
+ CompressionMethod,
+ FilterMethod,
+ InterlaceMethod: Byte;
+ end;
+
+ {Information header chunk}
+ TChunkIHDR = class(TChunk)
+ private
+ {Current image}
+ ImageHandle: HBitmap;
+ ImageDC: HDC;
+
+ {Output windows bitmap}
+ HasPalette: Boolean;
+ BitmapInfo: TMaxBitmapInfo;
+ BytesPerRow: Integer;
+ {Stores the image bytes}
+ {$IFDEF Store16bits}ExtraImageData: Pointer;{$ENDIF}
+ ImageData: pointer;
+ ImageAlpha: Pointer;
+
+ {Contains all the ihdr data}
+ IHDRData: TIHDRData;
+ protected
+ {Resizes the image data to fill the color type, bit depth, }
+ {width and height parameters}
+ procedure PrepareImageData;
+ {Release allocated ImageData memory}
+ procedure FreeImageData;
+ public
+ {Properties}
+ property Width: Cardinal read IHDRData.Width write IHDRData.Width;
+ property Height: Cardinal read IHDRData.Height write IHDRData.Height;
+ property BitDepth: Byte read IHDRData.BitDepth write IHDRData.BitDepth;
+ property ColorType: Byte read IHDRData.ColorType write IHDRData.ColorType;
+ property CompressionMethod: Byte read IHDRData.CompressionMethod
+ write IHDRData.CompressionMethod;
+ property FilterMethod: Byte read IHDRData.FilterMethod
+ write IHDRData.FilterMethod;
+ property InterlaceMethod: Byte read IHDRData.InterlaceMethod
+ write IHDRData.InterlaceMethod;
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Saves the chunk to a stream}
+ function SaveToStream(Stream: TStream): Boolean; override;
+ {Destructor/constructor}
+ constructor Create(Owner: TPngObject); override;
+ destructor Destroy; override;
+ {Assigns from another TChunk}
+ procedure Assign(Source: TChunk); override;
+ end;
+
+ {Gamma chunk}
+ TChunkgAMA = class(TChunk)
+ private
+ {Returns/sets the value for the gamma chunk}
+ function GetValue: Cardinal;
+ procedure SetValue(const Value: Cardinal);
+ public
+ {Returns/sets gamma value}
+ property Gamma: Cardinal read GetValue write SetValue;
+ {Loading the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Being created}
+ constructor Create(Owner: TPngObject); override;
+ {Assigns from another TChunk}
+ procedure Assign(Source: TChunk); override;
+ end;
+
+ {ZLIB Decompression extra information}
+ TZStreamRec2 = packed record
+ {From ZLIB}
+ ZLIB: TZStreamRec;
+ {Additional info}
+ Data: Pointer;
+ fStream : TStream;
+ end;
+
+ {Palette chunk}
+ TChunkPLTE = class(TChunk)
+ private
+ {Number of items in the palette}
+ fCount: Integer;
+ {Contains the palette handle}
+ function GetPaletteItem(Index: Byte): TRGBQuad;
+ public
+ {Returns the color for each item in the palette}
+ property Item[Index: Byte]: TRGBQuad read GetPaletteItem;
+ {Returns the number of items in the palette}
+ property Count: Integer read fCount;
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Saves the chunk to a stream}
+ function SaveToStream(Stream: TStream): Boolean; override;
+ {Assigns from another TChunk}
+ procedure Assign(Source: TChunk); override;
+ end;
+
+ {Transparency information}
+ TChunktRNS = class(TChunk)
+ private
+ fBitTransparency: Boolean;
+ function GetTransparentColor: ColorRef;
+ {Returns the transparent color}
+ procedure SetTransparentColor(const Value: ColorRef);
+ public
+ {Palette values for transparency}
+ PaletteValues: Array[Byte] of Byte;
+ {Returns if it uses bit transparency}
+ property BitTransparency: Boolean read fBitTransparency;
+ {Returns the transparent color}
+ property TransparentColor: ColorRef read GetTransparentColor write
+ SetTransparentColor;
+ {Loads/saves the chunk from/to a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ function SaveToStream(Stream: TStream): Boolean; override;
+ {Assigns from another TChunk}
+ procedure Assign(Source: TChunk); override;
+ end;
+
+ {Actual image information}
+ TChunkIDAT = class(TChunk)
+ private
+ {Holds another pointer to the TChunkIHDR}
+ Header: TChunkIHDR;
+ {Stores temporary image width and height}
+ ImageWidth, ImageHeight: Integer;
+ {Size in bytes of each line and offset}
+ Row_Bytes, Offset : Cardinal;
+ {Contains data for the lines}
+ Encode_Buffer: Array[0..5] of pByteArray;
+ Row_Buffer: Array[Boolean] of pByteArray;
+ {Variable to invert the Row_Buffer used}
+ RowUsed: Boolean;
+ {Ending position for the current IDAT chunk}
+ EndPos: Integer;
+ {Filter the current line}
+ procedure FilterRow;
+ {Filter to encode and returns the best filter}
+ function FilterToEncode: Byte;
+ {Reads ZLIB compressed data}
+ function IDATZlibRead(var ZLIBStream: TZStreamRec2; Buffer: Pointer;
+ Count: Integer; var EndPos: Integer; var crcfile: Cardinal): Integer;
+ {Compress and writes IDAT data}
+ procedure IDATZlibWrite(var ZLIBStream: TZStreamRec2; Buffer: Pointer;
+ const Length: Cardinal);
+ procedure FinishIDATZlib(var ZLIBStream: TZStreamRec2);
+ {Prepares the palette}
+ procedure PreparePalette;
+ protected
+ {Decode interlaced image}
+ procedure DecodeInterlacedAdam7(Stream: TStream;
+ var ZLIBStream: TZStreamRec2; const Size: Integer; var crcfile: Cardinal);
+ {Decode non interlaced imaged}
+ procedure DecodeNonInterlaced(Stream: TStream;
+ var ZLIBStream: TZStreamRec2; const Size: Integer;
+ var crcfile: Cardinal);
+ protected
+ {Encode non interlaced images}
+ procedure EncodeNonInterlaced(Stream: TStream;
+ var ZLIBStream: TZStreamRec2);
+ {Encode interlaced images}
+ procedure EncodeInterlacedAdam7(Stream: TStream;
+ var ZLIBStream: TZStreamRec2);
+ protected
+ {Memory copy methods to decode}
+ procedure CopyNonInterlacedRGB8(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedRGB16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedPalette148(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedPalette2(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedGray2(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedGrayscale16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedRGBAlpha8(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedRGBAlpha16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedGrayscaleAlpha8(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedGrayscaleAlpha16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedRGB8(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedRGB16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedPalette148(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedPalette2(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedGray2(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedGrayscale16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedRGBAlpha8(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedRGBAlpha16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedGrayscaleAlpha8(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedGrayscaleAlpha16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ protected
+ {Memory copy methods to encode}
+ procedure EncodeNonInterlacedRGB8(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedRGB16(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedGrayscale16(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedPalette148(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedRGBAlpha8(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedRGBAlpha16(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedGrayscaleAlpha8(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedGrayscaleAlpha16(Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedRGB8(const Pass: Byte; Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedRGB16(const Pass: Byte; Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedPalette148(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedGrayscale16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedRGBAlpha8(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedRGBAlpha16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedGrayscaleAlpha8(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedGrayscaleAlpha16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+ public
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Saves the chunk to a stream}
+ function SaveToStream(Stream: TStream): Boolean; override;
+ end;
+
+ {Image last modification chunk}
+ TChunktIME = class(TChunk)
+ private
+ {Holds the variables}
+ fYear: Word;
+ fMonth, fDay, fHour, fMinute, fSecond: Byte;
+ public
+ {Returns/sets variables}
+ property Year: Word read fYear write fYear;
+ property Month: Byte read fMonth write fMonth;
+ property Day: Byte read fDay write fDay;
+ property Hour: Byte read fHour write fHour;
+ property Minute: Byte read fMinute write fMinute;
+ property Second: Byte read fSecond write fSecond;
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Saves the chunk to a stream}
+ function SaveToStream(Stream: TStream): Boolean; override;
+ end;
+
+ {Textual data}
+ TChunktEXt = class(TChunk)
+ private
+ fKeyword, fText: String;
+ public
+ {Keyword and text}
+ property Keyword: String read fKeyword write fKeyword;
+ property Text: String read fText write fText;
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Saves the chunk to a stream}
+ function SaveToStream(Stream: TStream): Boolean; override;
+ {Assigns from another TChunk}
+ procedure Assign(Source: TChunk); override;
+ end;
+
+ {zTXT chunk}
+ TChunkzTXt = class(TChunktEXt)
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Saves the chunk to a stream}
+ function SaveToStream(Stream: TStream): Boolean; override;
+ end;
+
+{Here we test if it's c++ builder or delphi version 3 or less}
+{$IFDEF VER110}{$DEFINE DelphiBuilder3Less}{$ENDIF}
+{$IFDEF VER100}{$DEFINE DelphiBuilder3Less}{$ENDIF}
+{$IFDEF VER93}{$DEFINE DelphiBuilder3Less}{$ENDIF}
+{$IFDEF VER90}{$DEFINE DelphiBuilder3Less}{$ENDIF}
+{$IFDEF VER80}{$DEFINE DelphiBuilder3Less}{$ENDIF}
+
+
+{Registers a new chunk class}
+procedure RegisterChunk(ChunkClass: TChunkClass);
+{Calculates crc}
+function update_crc(crc: {$IFNDEF DelphiBuilder3Less}Cardinal{$ELSE}Integer
+ {$ENDIF}; buf: pByteArray; len: Integer): Cardinal;
+{Invert bytes using assembly}
+function ByteSwap(const a: integer): integer;
+
+implementation
+
+var
+ ChunkClasses: TPngPointerList;
+ {Table of CRCs of all 8-bit messages}
+ crc_table: Array[0..255] of Cardinal;
+ {Flag: has the table been computed? Initially false}
+ crc_table_computed: Boolean;
+
+{Draw transparent image using transparent color}
+procedure DrawTransparentBitmap(dc: HDC; srcBits: Pointer;
+ var srcHeader: TBitmapInfoHeader;
+ srcBitmapInfo: pBitmapInfo; Rect: TRect; cTransparentColor: COLORREF);
+var
+ cColor: COLORREF;
+ bmAndBack, bmAndObject, bmAndMem: HBITMAP;
+ bmBackOld, bmObjectOld, bmMemOld: HBITMAP;
+ hdcMem, hdcBack, hdcObject, hdcTemp: HDC;
+ ptSize, orgSize: TPOINT;
+ OldBitmap, DrawBitmap: HBITMAP;
+begin
+ hdcTemp := CreateCompatibleDC(dc);
+ // Select the bitmap
+ DrawBitmap := CreateDIBitmap(dc, srcHeader, CBM_INIT, srcBits, srcBitmapInfo^,
+ DIB_RGB_COLORS);
+ OldBitmap := SelectObject(hdcTemp, DrawBitmap);
+
+ // Sizes
+ OrgSize.x := abs(srcHeader.biWidth);
+ OrgSize.y := abs(srcHeader.biHeight);
+ ptSize.x := Rect.Right - Rect.Left; // Get width of bitmap
+ ptSize.y := Rect.Bottom - Rect.Top; // Get height of bitmap
+
+ // Create some DCs to hold temporary data.
+ hdcBack := CreateCompatibleDC(dc);
+ hdcObject := CreateCompatibleDC(dc);
+ hdcMem := CreateCompatibleDC(dc);
+
+ // Create a bitmap for each DC. DCs are required for a number of
+ // GDI functions.
+
+ // Monochrome DCs
+ bmAndBack := CreateBitmap(ptSize.x, ptSize.y, 1, 1, nil);
+ bmAndObject := CreateBitmap(ptSize.x, ptSize.y, 1, 1, nil);
+
+ bmAndMem := CreateCompatibleBitmap(dc, ptSize.x, ptSize.y);
+
+ // Each DC must select a bitmap object to store pixel data.
+ bmBackOld := SelectObject(hdcBack, bmAndBack);
+ bmObjectOld := SelectObject(hdcObject, bmAndObject);
+ bmMemOld := SelectObject(hdcMem, bmAndMem);
+
+ // Set the background color of the source DC to the color.
+ // contained in the parts of the bitmap that should be transparent
+ cColor := SetBkColor(hdcTemp, cTransparentColor);
+
+ // Create the object mask for the bitmap by performing a BitBlt
+ // from the source bitmap to a monochrome bitmap.
+ StretchBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0,
+ orgSize.x, orgSize.y, SRCCOPY);
+
+ // Set the background color of the source DC back to the original
+ // color.
+ SetBkColor(hdcTemp, cColor);
+
+ // Create the inverse of the object mask.
+ BitBlt(hdcBack, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0,
+ NOTSRCCOPY);
+
+ // Copy the background of the main DC to the destination.
+ BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, dc, Rect.Left, Rect.Top,
+ SRCCOPY);
+
+ // Mask out the places where the bitmap will be placed.
+ BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, SRCAND);
+
+ // Mask out the transparent colored pixels on the bitmap.
+// BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcBack, 0, 0, SRCAND);
+ StretchBlt(hdcTemp, 0, 0, OrgSize.x, OrgSize.y, hdcBack, 0, 0,
+ PtSize.x, PtSize.y, SRCAND);
+
+ // XOR the bitmap with the background on the destination DC.
+ StretchBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0,
+ OrgSize.x, OrgSize.y, SRCPAINT);
+
+ // Copy the destination to the screen.
+ BitBlt(dc, Rect.Left, Rect.Top, ptSize.x, ptSize.y, hdcMem, 0, 0,
+ SRCCOPY);
+
+ // Delete the memory bitmaps.
+ DeleteObject(SelectObject(hdcBack, bmBackOld));
+ DeleteObject(SelectObject(hdcObject, bmObjectOld));
+ DeleteObject(SelectObject(hdcMem, bmMemOld));
+ DeleteObject(SelectObject(hdcTemp, OldBitmap));
+
+ // Delete the memory DCs.
+ DeleteDC(hdcMem);
+ DeleteDC(hdcBack);
+ DeleteDC(hdcObject);
+ DeleteDC(hdcTemp);
+end;
+
+{Make the table for a fast CRC.}
+procedure make_crc_table;
+var
+ c: Cardinal;
+ n, k: Integer;
+begin
+
+ {fill the crc table}
+ for n := 0 to 255 do
+ begin
+ c := Cardinal(n);
+ for k := 0 to 7 do
+ begin
+ if Boolean(c and 1) then
+ c := $edb88320 xor (c shr 1)
+ else
+ c := c shr 1;
+ end;
+ crc_table[n] := c;
+ end;
+
+ {The table has already being computated}
+ crc_table_computed := true;
+end;
+
+{Update a running CRC with the bytes buf[0..len-1]--the CRC
+ should be initialized to all 1's, and the transmitted value
+ is the 1's complement of the final running CRC (see the
+ crc() routine below)).}
+function update_crc(crc: {$IFNDEF DelphiBuilder3Less}Cardinal{$ELSE}Integer
+ {$ENDIF}; buf: pByteArray; len: Integer): Cardinal;
+var
+ c: Cardinal;
+ n: Integer;
+begin
+ c := crc;
+
+ {Create the crc table in case it has not being computed yet}
+ if not crc_table_computed then make_crc_table;
+
+ {Update}
+ for n := 0 to len - 1 do
+ c := crc_table[(c XOR buf^[n]) and $FF] XOR (c shr 8);
+
+ {Returns}
+ Result := c;
+end;
+
+{$IFNDEF UseDelphi}
+ function FileExists(Filename: String): Boolean;
+ var
+ FindFile: THandle;
+ FindData: TWin32FindData;
+ begin
+ FindFile := FindFirstFile(PChar(Filename), FindData);
+ Result := FindFile <> INVALID_HANDLE_VALUE;
+ if Result then Windows.FindClose(FindFile);
+ end;
+
+
+{$ENDIF}
+
+{$IFNDEF UseDelphi}
+ {Exception implementation}
+ constructor Exception.Create(Msg: String);
+ begin
+ end;
+{$ENDIF}
+
+{Calculates the paeth predictor}
+function PaethPredictor(a, b, c: Byte): Byte;
+var
+ pa, pb, pc: Integer;
+begin
+ { a = left, b = above, c = upper left }
+ pa := abs(b - c); { distances to a, b, c }
+ pb := abs(a - c);
+ pc := abs(a + b - c * 2);
+
+ { return nearest of a, b, c, breaking ties in order a, b, c }
+ if (pa <= pb) and (pa <= pc) then
+ Result := a
+ else
+ if pb <= pc then
+ Result := b
+ else
+ Result := c;
+end;
+
+{Invert bytes using assembly}
+function ByteSwap(const a: integer): integer;
+asm
+ bswap eax
+end;
+function ByteSwap16(inp:word): word;
+asm
+ bswap eax
+ shr eax, 16
+end;
+
+{Calculates number of bytes for the number of pixels using the}
+{color mode in the paramenter}
+function BytesForPixels(const Pixels: Integer; const ColorType,
+ BitDepth: Byte): Integer;
+begin
+ case ColorType of
+ {Palette and grayscale contains a single value, for palette}
+ {an value of size 2^bitdepth pointing to the palette index}
+ {and grayscale the value from 0 to 2^bitdepth with color intesity}
+ COLOR_GRAYSCALE, COLOR_PALETTE:
+ Result := (Pixels * BitDepth + 7) div 8;
+ {RGB contains 3 values R, G, B with size 2^bitdepth each}
+ COLOR_RGB:
+ Result := (Pixels * BitDepth * 3) div 8;
+ {Contains one value followed by alpha value booth size 2^bitdepth}
+ COLOR_GRAYSCALEALPHA:
+ Result := (Pixels * BitDepth * 2) div 8;
+ {Contains four values size 2^bitdepth, Red, Green, Blue and alpha}
+ COLOR_RGBALPHA:
+ Result := (Pixels * BitDepth * 4) div 8;
+ else
+ Result := 0;
+ end {case ColorType}
+end;
+
+type
+ pChunkClassInfo = ^TChunkClassInfo;
+ TChunkClassInfo = record
+ ClassName: TChunkClass;
+ end;
+
+{Register a chunk type}
+procedure RegisterChunk(ChunkClass: TChunkClass);
+var
+ NewClass: pChunkClassInfo;
+begin
+ {In case the list object has not being created yet}
+ if ChunkClasses = nil then ChunkClasses := TPngPointerList.Create(nil);
+
+ {Add this new class}
+ new(NewClass);
+ NewClass^.ClassName := ChunkClass;
+ ChunkClasses.Add(NewClass);
+end;
+
+{Free chunk class list}
+procedure FreeChunkClassList;
+var
+ i: Integer;
+begin
+ if (ChunkClasses <> nil) then
+ begin
+ FOR i := 0 TO ChunkClasses.Count - 1 do
+ Dispose(pChunkClassInfo(ChunkClasses.Item[i]));
+ ChunkClasses.Free;
+ end;
+end;
+
+{Registering of common chunk classes}
+procedure RegisterCommonChunks;
+begin
+ {Important chunks}
+ RegisterChunk(TChunkIEND);
+ RegisterChunk(TChunkIHDR);
+ RegisterChunk(TChunkIDAT);
+ RegisterChunk(TChunkPLTE);
+ RegisterChunk(TChunkgAMA);
+ RegisterChunk(TChunktRNS);
+
+ {Not so important chunks}
+ RegisterChunk(TChunktIME);
+ RegisterChunk(TChunktEXt);
+ RegisterChunk(TChunkzTXt);
+end;
+
+{Creates a new chunk of this class}
+function CreateClassChunk(Owner: TPngObject; Name: TChunkName): TChunk;
+var
+ i : Integer;
+ NewChunk: TChunkClass;
+begin
+ {Looks for this chunk}
+ NewChunk := TChunk; {In case there is no registered class for this}
+
+ {Looks for this class in all registered chunks}
+ if Assigned(ChunkClasses) then
+ FOR i := 0 TO ChunkClasses.Count - 1 DO
+ begin
+ if pChunkClassInfo(ChunkClasses.Item[i])^.ClassName.GetName = Name then
+ begin
+ NewChunk := pChunkClassInfo(ChunkClasses.Item[i])^.ClassName;
+ break;
+ end;
+ end;
+
+ {Returns chunk class}
+ Result := NewChunk.Create(Owner);
+ Result.fName := Name;
+end;
+
+{ZLIB support}
+
+const
+ ZLIBAllocate = High(Word);
+
+{Initializes ZLIB for decompression}
+function ZLIBInitInflate(Stream: TStream): TZStreamRec2;
+begin
+ {Fill record}
+ Fillchar(Result, SIZEOF(TZStreamRec2), #0);
+
+ {Set internal record information}
+ with Result do
+ begin
+ GetMem(Data, ZLIBAllocate);
+ fStream := Stream;
+ end;
+
+ {Init decompression}
+ InflateInit_(Result.zlib, zlib_version, SIZEOF(TZStreamRec));
+end;
+
+{Initializes ZLIB for compression}
+function ZLIBInitDeflate(Stream: TStream;
+ Level: TCompressionlevel; Size: Cardinal): TZStreamRec2;
+begin
+ {Fill record}
+ Fillchar(Result, SIZEOF(TZStreamRec2), #0);
+
+ {Set internal record information}
+ with Result, ZLIB do
+ begin
+ GetMem(Data, Size);
+ fStream := Stream;
+ next_out := Data;
+ avail_out := Size;
+ end;
+
+ {Inits compression}
+ deflateInit_(Result.zlib, Level, zlib_version, sizeof(TZStreamRec));
+end;
+
+{Terminates ZLIB for compression}
+procedure ZLIBTerminateDeflate(var ZLIBStream: TZStreamRec2);
+begin
+ {Terminates decompression}
+ DeflateEnd(ZLIBStream.zlib);
+ {Free internal record}
+ FreeMem(ZLIBStream.Data, ZLIBAllocate);
+end;
+
+{Terminates ZLIB for decompression}
+procedure ZLIBTerminateInflate(var ZLIBStream: TZStreamRec2);
+begin
+ {Terminates decompression}
+ InflateEnd(ZLIBStream.zlib);
+ {Free internal record}
+ FreeMem(ZLIBStream.Data, ZLIBAllocate);
+end;
+
+{Decompresses ZLIB into a memory address}
+function DecompressZLIB(const Input: Pointer; InputSize: Integer;
+ var Output: Pointer; var OutputSize: Integer;
+ var ErrorOutput: String): Boolean;
+var
+ StreamRec : TZStreamRec;
+ Buffer : Array[Byte] of Byte;
+ InflateRet: Integer;
+begin
+ with StreamRec do
+ begin
+ {Initializes}
+ Result := True;
+ OutputSize := 0;
+
+ {Prepares the data to decompress}
+ FillChar(StreamRec, SizeOf(TZStreamRec), #0);
+ InflateInit_(StreamRec, zlib_version, SIZEOF(TZStreamRec));
+ next_in := Input;
+ avail_in := InputSize;
+
+ {Decodes data}
+ repeat
+ {In case it needs an output buffer}
+ if (avail_out = 0) then
+ begin
+ next_out := @Buffer;
+ avail_out := SizeOf(Buffer);
+ end {if (avail_out = 0)};
+
+ {Decompress and put in output}
+ InflateRet := inflate(StreamRec, 0);
+ if (InflateRet = Z_STREAM_END) or (InflateRet = 0) then
+ begin
+ {Reallocates output buffer}
+ inc(OutputSize, total_out);
+ if Output = nil then
+ GetMem(Output, OutputSize) else ReallocMem(Output, OutputSize);
+ {Copies the new data}
+ CopyMemory(pointer(Longint(Output) + OutputSize - total_out), @Buffer, total_out);
+ end {if (InflateRet = Z_STREAM_END) or (InflateRet = 0)}
+ {Now tests for errors}
+ else if InflateRet < 0 then
+ begin
+ Result := False;
+ ErrorOutput := StreamRec.msg;
+ InflateEnd(StreamRec);
+ Exit;
+ end {if InflateRet < 0}
+ until InflateRet = Z_STREAM_END;
+
+ {Terminates decompression}
+ InflateEnd(StreamRec);
+ end {with StreamRec}
+
+end;
+
+{Compresses ZLIB into a memory address}
+function CompressZLIB(Input: Pointer; InputSize, CompressionLevel: Integer;
+ var Output: Pointer; var OutputSize: Integer;
+ var ErrorOutput: String): Boolean;
+var
+ StreamRec : TZStreamRec;
+ Buffer : Array[Byte] of Byte;
+ DeflateRet: Integer;
+begin
+ with StreamRec do
+ begin
+ Result := True; {By default returns TRUE as everything might have gone ok}
+ OutputSize := 0; {Initialize}
+ {Prepares the data to compress}
+ FillChar(StreamRec, SizeOf(TZStreamRec), #0);
+ DeflateInit_(StreamRec, CompressionLevel,zlib_version, SIZEOF(TZStreamRec));
+
+ next_in := Input;
+ avail_in := InputSize;
+
+ while avail_in > 0 do
+ begin
+ {When it needs new buffer to stores the compressed data}
+ if avail_out = 0 then
+ begin
+ {Restore buffer}
+ next_out := @Buffer;
+ avail_out := SizeOf(Buffer);
+ end {if avail_out = 0};
+
+ {Compresses}
+ DeflateRet := deflate(StreamRec, Z_FINISH);
+
+ if (DeflateRet = Z_STREAM_END) or (DeflateRet = 0) then
+ begin
+ {Updates the output memory}
+ inc(OutputSize, total_out);
+ if Output = nil then
+ GetMem(Output, OutputSize) else ReallocMem(Output, OutputSize);
+
+ {Copies the new data}
+ CopyMemory(Pointer(Longint(Output) + OutputSize - total_out), @Buffer, total_out);
+ end {if (InflateRet = Z_STREAM_END) or (InflateRet = 0)}
+ {Now tests for errors}
+ else if DeflateRet < 0 then
+ begin
+ Result := False;
+ ErrorOutput := StreamRec.msg;
+ DeflateEnd(StreamRec);
+ Exit;
+ end {if InflateRet < 0}
+
+ end {while avail_in > 0};
+
+ {Finishes compressing}
+ DeflateEnd(StreamRec);
+ end {with StreamRec}
+
+end;
+
+{TPngPointerList implementation}
+
+{Object being created}
+constructor TPngPointerList.Create(AOwner: TPNGObject);
+begin
+ inherited Create; {Let ancestor work}
+ {Holds owner}
+ fOwner := AOwner;
+ {Memory pointer not being used yet}
+ fMemory := nil;
+ {No items yet}
+ fCount := 0;
+end;
+
+{Removes value from the list}
+function TPngPointerList.Remove(Value: Pointer): Pointer;
+var
+ I, Position: Integer;
+begin
+ {Gets item position}
+ Position := -1;
+ FOR I := 0 TO Count - 1 DO
+ if Value = Item[I] then Position := I;
+ {In case a match was found}
+ if Position >= 0 then
+ begin
+ Result := Item[Position]; {Returns pointer}
+ {Remove item and move memory}
+ Dec(fCount);
+ if Position < Integer(FCount) then
+ System.Move(fMemory^[Position + 1], fMemory^[Position],
+ (Integer(fCount) - Position) * SizeOf(Pointer));
+ end {if Position >= 0} else Result := nil
+end;
+
+{Add a new value in the list}
+procedure TPngPointerList.Add(Value: Pointer);
+begin
+ Count := Count + 1;
+ Item[Count - 1] := Value;
+end;
+
+
+{Object being destroyed}
+destructor TPngPointerList.Destroy;
+begin
+ {Release memory if needed}
+ if fMemory <> nil then
+ FreeMem(fMemory, fCount * sizeof(Pointer));
+
+ {Free things}
+ inherited Destroy;
+end;
+
+{Returns one item from the list}
+function TPngPointerList.GetItem(Index: Cardinal): Pointer;
+begin
+ if (Index <= Count - 1) then
+ Result := fMemory[Index]
+ else
+ {In case it's out of bounds}
+ Result := nil;
+end;
+
+{Inserts a new item in the list}
+procedure TPngPointerList.Insert(Value: Pointer; Position: Cardinal);
+begin
+ if (Position < Count) then
+ begin
+ {Increase item count}
+ SetSize(Count + 1);
+ {Move other pointers}
+ if Position < Count then
+ System.Move(fMemory^[Position], fMemory^[Position + 1],
+ (Count - Position - 1) * SizeOf(Pointer));
+ {Sets item}
+ Item[Position] := Value;
+ end;
+end;
+
+{Sets one item from the list}
+procedure TPngPointerList.SetItem(Index: Cardinal; const Value: Pointer);
+begin
+ {If index is in bounds, set value}
+ if (Index <= Count - 1) then
+ fMemory[Index] := Value
+end;
+
+{This method resizes the list}
+procedure TPngPointerList.SetSize(const Size: Cardinal);
+begin
+ {Sets the size}
+ if (fMemory = nil) and (Size > 0) then
+ GetMem(fMemory, Size * SIZEOF(Pointer))
+ else
+ if Size > 0 then {Only realloc if the new size is greater than 0}
+ ReallocMem(fMemory, Size * SIZEOF(Pointer))
+ else
+ {In case user is resize to 0 items}
+ begin
+ FreeMem(fMemory);
+ fMemory := nil;
+ end;
+ {Update count}
+ fCount := Size;
+end;
+
+{TPNGList implementation}
+
+{Removes an item}
+procedure TPNGList.RemoveChunk(Chunk: TChunk);
+begin
+ Remove(Chunk);
+ Chunk.Free
+end;
+
+{Add a new item}
+function TPNGList.Add(ChunkClass: TChunkClass): TChunk;
+var
+ IHDR: TChunkIHDR;
+ IEND: TChunkIEND;
+
+ IDAT: TChunkIDAT;
+ PLTE: TChunkPLTE;
+begin
+ Result := nil; {Default result}
+ {Adding these is not allowed}
+ if (ChunkClass = TChunkIHDR) or (ChunkClass = TChunkIDAT) or
+ (ChunkClass = TChunkPLTE) or (ChunkClass = TChunkIEND) then
+ fOwner.RaiseError(EPngError, EPNGCannotAddChunkText)
+ {Two of these is not allowed}
+ else if ((ChunkClass = TChunkgAMA) and (ItemFromClass(TChunkgAMA) <> nil)) or
+ ((ChunkClass = TChunktRNS) and (ItemFromClass(TChunktRNS) <> nil)) then
+ fOwner.RaiseError(EPngError, EPNGCannotAddChunkText)
+ {There must have an IEND and IHDR chunk}
+ else if (ItemFromClass(TChunkIEND) = nil) or
+ (ItemFromClass(TChunkIHDR) = nil) then
+ fOwner.RaiseError(EPngError, EPNGCannotAddInvalidImageText)
+ else
+ begin
+ {Get common chunks}
+ IHDR := ItemFromClass(TChunkIHDR) as TChunkIHDR;
+ IEND := ItemFromClass(TChunkIEND) as TChunkIEND;
+ {Create new chunk}
+ Result := ChunkClass.Create(Owner);
+ {Add to the list}
+ if (ChunkClass = TChunkgAMA) then
+ Insert(Result, IHDR.Index + 1)
+ {Transparency chunk (fix by Ian Boyd)}
+ else if (ChunkClass = TChunktRNS) then
+ begin
+ {Transparecy chunk must be after PLTE; before IDAT}
+ IDAT := ItemFromClass(TChunkIDAT) as TChunkIDAT;
+ PLTE := ItemFromClass(TChunkPLTE) as TChunkPLTE;
+
+ if Assigned(PLTE) then
+ Insert(Result, PLTE.Index + 1)
+ else if Assigned(IDAT) then
+ Insert(Result, IDAT.Index)
+ else
+ Insert(Result, IHDR.Index + 1)
+ end
+ else {All other chunks}
+ Insert(Result, IEND.Index);
+ end {if}
+end;
+
+{Returns item from the list}
+function TPNGList.GetItem(Index: Cardinal): TChunk;
+begin
+ Result := inherited GetItem(Index);
+end;
+
+{Returns first item from the list using the class from parameter}
+function TPNGList.ItemFromClass(ChunkClass: TChunkClass): TChunk;
+var
+ i: Integer;
+begin
+ Result := nil; {Initial result}
+ FOR i := 0 TO Count - 1 DO
+ {Test if this item has the same class}
+ if Item[i] is ChunkClass then
+ begin
+ {Returns this item and exit}
+ Result := Item[i];
+ break;
+ end {if}
+end;
+
+{$IFNDEF UseDelphi}
+
+ {TStream implementation}
+
+ {Copies all from another stream}
+ function TStream.CopyFrom(Source: TStream; Count: Cardinal): Cardinal;
+ const
+ MaxBytes = $f000;
+ var
+ Buffer: PChar;
+ BufSize, N: Cardinal;
+ begin
+ {If count is zero, copy everything from Source}
+ if Count = 0 then
+ begin
+ Source.Seek(0, soFromBeginning);
+ Count := Source.Size;
+ end;
+
+ Result := Count; {Returns the number of bytes readed}
+ {Allocates memory}
+ if Count > MaxBytes then BufSize := MaxBytes else BufSize := Count;
+ GetMem(Buffer, BufSize);
+
+ {Copy memory}
+ while Count > 0 do
+ begin
+ if Count > BufSize then N := BufSize else N := Count;
+ Source.Read(Buffer^, N);
+ Write(Buffer^, N);
+ dec(Count, N);
+ end;
+
+ {Deallocates memory}
+ FreeMem(Buffer, BufSize);
+ end;
+
+{Set current stream position}
+procedure TStream.SetPosition(const Value: Longint);
+begin
+ Seek(Value, soFromBeginning);
+end;
+
+{Returns position}
+function TStream.GetPosition: Longint;
+begin
+ Result := Seek(0, soFromCurrent);
+end;
+
+ {Returns stream size}
+function TStream.GetSize: Longint;
+ var
+ Pos: Cardinal;
+ begin
+ Pos := Seek(0, soFromCurrent);
+ Result := Seek(0, soFromEnd);
+ Seek(Pos, soFromCurrent);
+ end;
+
+ {TFileStream implementation}
+
+ {Filestream object being created}
+ constructor TFileStream.Create(Filename: String; Mode: TFileStreamModeSet);
+ {Makes file mode}
+ function OpenMode: DWORD;
+ begin
+ Result := 0;
+ if fsmRead in Mode then Result := GENERIC_READ;
+ if (fsmWrite in Mode) or (fsmCreate in Mode) then
+ Result := Result OR GENERIC_WRITE;
+ end;
+ const
+ IsCreate: Array[Boolean] of Integer = (OPEN_ALWAYS, CREATE_ALWAYS);
+ begin
+ {Call ancestor}
+ inherited Create;
+
+ {Create handle}
+ fHandle := CreateFile(PChar(Filename), OpenMode, FILE_SHARE_READ or
+ FILE_SHARE_WRITE, nil, IsCreate[fsmCreate in Mode], 0, 0);
+ {Store mode}
+ FileMode := Mode;
+ end;
+
+ {Filestream object being destroyed}
+ destructor TFileStream.Destroy;
+ begin
+ {Terminates file and close}
+ if FileMode = [fsmWrite] then
+ SetEndOfFile(fHandle);
+ CloseHandle(fHandle);
+
+ {Call ancestor}
+ inherited Destroy;
+ end;
+
+ {Writes data to the file}
+ function TFileStream.Write(const Buffer; Count: Longint): Cardinal;
+ begin
+ if not WriteFile(fHandle, Buffer, Count, Result, nil) then
+ Result := 0;
+ end;
+
+ {Reads data from the file}
+ function TFileStream.Read(var Buffer; Count: Longint): Cardinal;
+ begin
+ if not ReadFile(fHandle, Buffer, Count, Result, nil) then
+ Result := 0;
+ end;
+
+ {Seeks the file position}
+ function TFileStream.Seek(Offset: Integer; Origin: Word): Longint;
+ begin
+ Result := SetFilePointer(fHandle, Offset, nil, Origin);
+ end;
+
+ {Sets the size of the file}
+ procedure TFileStream.SetSize(const Value: Longint);
+ begin
+ Seek(Value, soFromBeginning);
+ SetEndOfFile(fHandle);
+ end;
+
+ {TResourceStream implementation}
+
+ {Creates the resource stream}
+ constructor TResourceStream.Create(Instance: HInst; const ResName: String;
+ ResType: PChar);
+ var
+ ResID: HRSRC;
+ ResGlobal: HGlobal;
+ begin
+ {Obtains the resource ID}
+ ResID := FindResource(hInstance, PChar(ResName), RT_RCDATA);
+ if ResID = 0 then raise EPNGError.Create('');
+ {Obtains memory and size}
+ ResGlobal := LoadResource(hInstance, ResID);
+ Size := SizeOfResource(hInstance, ResID);
+ Memory := LockResource(ResGlobal);
+ if (ResGlobal = 0) or (Memory = nil) then EPNGError.Create('');
+ end;
+
+
+ {Setting resource stream size is not supported}
+ procedure TResourceStream.SetSize(const Value: Integer);
+ begin
+ end;
+
+ {Writing into a resource stream is not supported}
+ function TResourceStream.Write(const Buffer; Count: Integer): Cardinal;
+ begin
+ Result := 0;
+ end;
+
+ {Reads data from the stream}
+ function TResourceStream.Read(var Buffer; Count: Integer): Cardinal;
+ begin
+ //Returns data
+ CopyMemory(@Buffer, pointer(Longint(Memory) + Position), Count);
+ //Update position
+ inc(Position, Count);
+ //Returns
+ Result := Count;
+ end;
+
+ {Seeks data}
+ function TResourceStream.Seek(Offset: Integer; Origin: Word): Longint;
+ begin
+ {Move depending on the origin}
+ case Origin of
+ soFromBeginning: Position := Offset;
+ soFromCurrent: inc(Position, Offset);
+ soFromEnd: Position := Size + Offset;
+ end;
+
+ {Returns the current position}
+ Result := Position;
+ end;
+
+{$ENDIF}
+
+{TChunk implementation}
+
+{Resizes the data}
+procedure TChunk.ResizeData(const NewSize: Cardinal);
+begin
+ fDataSize := NewSize;
+ ReallocMem(fData, NewSize + 1);
+end;
+
+{Returns index from list}
+function TChunk.GetIndex: Integer;
+var
+ i: Integer;
+begin
+ Result := -1; {Avoiding warnings}
+ {Searches in the list}
+ FOR i := 0 TO Owner.Chunks.Count - 1 DO
+ if Owner.Chunks.Item[i] = Self then
+ begin
+ {Found match}
+ Result := i;
+ exit;
+ end {for i}
+end;
+
+{Returns pointer to the TChunkIHDR}
+function TChunk.GetHeader: TChunkIHDR;
+begin
+ Result := Owner.Chunks.Item[0] as TChunkIHDR;
+end;
+
+{Assigns from another TChunk}
+procedure TChunk.Assign(Source: TChunk);
+begin
+ {Copy properties}
+ fName := Source.fName;
+ {Set data size and realloc}
+ ResizeData(Source.fDataSize);
+
+ {Copy data (if there's any)}
+ if fDataSize > 0 then CopyMemory(fData, Source.fData, fDataSize);
+end;
+
+{Chunk being created}
+constructor TChunk.Create(Owner: TPngObject);
+var
+ ChunkName: String;
+begin
+ {Ancestor create}
+ inherited Create;
+
+ {If it's a registered class, set the chunk name based on the class}
+ {name. For instance, if the class name is TChunkgAMA, the GAMA part}
+ {will become the chunk name}
+ ChunkName := Copy(ClassName, Length('TChunk') + 1, Length(ClassName));
+ if Length(ChunkName) = 4 then CopyMemory(@fName[0], @ChunkName[1], 4);
+
+ {Initialize data holder}
+ GetMem(fData, 1);
+ fDataSize := 0;
+ {Record owner}
+ fOwner := Owner;
+end;
+
+{Chunk being destroyed}
+destructor TChunk.Destroy;
+begin
+ {Free data holder}
+ FreeMem(fData, fDataSize + 1);
+ {Let ancestor destroy}
+ inherited Destroy;
+end;
+
+{Returns the chunk name 1}
+function TChunk.GetChunkName: String;
+begin
+ Result := fName
+end;
+
+{Returns the chunk name 2}
+class function TChunk.GetName: String;
+begin
+ {For avoid writing GetName for each TChunk descendent, by default for}
+ {classes which don't declare GetName, it will look for the class name}
+ {to extract the chunk kind. Example, if the class name is TChunkIEND }
+ {this method extracts and returns IEND}
+ Result := Copy(ClassName, Length('TChunk') + 1, Length(ClassName));
+end;
+
+{Saves the data to the stream}
+function TChunk.SaveData(Stream: TStream): Boolean;
+var
+ ChunkSize, ChunkCRC: Cardinal;
+begin
+ {First, write the size for the following data in the chunk}
+ ChunkSize := ByteSwap(DataSize);
+ Stream.Write(ChunkSize, 4);
+ {The chunk name}
+ Stream.Write(fName, 4);
+ {If there is data for the chunk, write it}
+ if DataSize > 0 then Stream.Write(Data^, DataSize);
+ {Calculates and write CRC}
+ ChunkCRC := update_crc($ffffffff, @fName[0], 4);
+ ChunkCRC := Byteswap(update_crc(ChunkCRC, Data, DataSize) xor $ffffffff);
+ Stream.Write(ChunkCRC, 4);
+
+ {Returns that everything went ok}
+ Result := TRUE;
+end;
+
+{Saves the chunk to the stream}
+function TChunk.SaveToStream(Stream: TStream): Boolean;
+begin
+ Result := SaveData(Stream)
+end;
+
+
+{Loads the chunk from a stream}
+function TChunk.LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean;
+var
+ CheckCRC: Cardinal;
+ {$IFDEF CheckCRC}RightCRC: Cardinal;{$ENDIF}
+begin
+ {Copies data from source}
+ ResizeData(Size);
+ if Size > 0 then Stream.Read(fData^, Size);
+ {Reads CRC}
+ Stream.Read(CheckCRC, 4);
+ CheckCrc := ByteSwap(CheckCRC);
+
+ {Check if crc readed is valid}
+ {$IFDEF CheckCRC}
+ RightCRC := update_crc($ffffffff, @ChunkName[0], 4);
+ RightCRC := update_crc(RightCRC, fData, Size) xor $ffffffff;
+ Result := RightCRC = CheckCrc;
+
+ {Handle CRC error}
+ if not Result then
+ begin
+ {In case it coult not load chunk}
+ Owner.RaiseError(EPngInvalidCRC, EPngInvalidCRCText);
+ exit;
+ end
+ {$ELSE}Result := TRUE; {$ENDIF}
+
+end;
+
+{TChunktIME implementation}
+
+{Chunk being loaded from a stream}
+function TChunktIME.LoadFromStream(Stream: TStream;
+ const ChunkName: TChunkName; Size: Integer): Boolean;
+begin
+ {Let ancestor load the data}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+ if not Result or (Size <> 7) then exit; {Size must be 7}
+
+ {Reads data}
+ fYear := ((pByte(Longint(Data) )^) * 256)+ (pByte(Longint(Data) + 1)^);
+ fMonth := pByte(Longint(Data) + 2)^;
+ fDay := pByte(Longint(Data) + 3)^;
+ fHour := pByte(Longint(Data) + 4)^;
+ fMinute := pByte(Longint(Data) + 5)^;
+ fSecond := pByte(Longint(Data) + 6)^;
+end;
+
+{Saving the chunk to a stream}
+function TChunktIME.SaveToStream(Stream: TStream): Boolean;
+begin
+ {Update data}
+ ResizeData(7); {Make sure the size is 7}
+ pWord(Data)^ := Year;
+ pByte(Longint(Data) + 2)^ := Month;
+ pByte(Longint(Data) + 3)^ := Day;
+ pByte(Longint(Data) + 4)^ := Hour;
+ pByte(Longint(Data) + 5)^ := Minute;
+ pByte(Longint(Data) + 6)^ := Second;
+
+ {Let inherited save data}
+ Result := inherited SaveToStream(Stream);
+end;
+
+{TChunkztXt implementation}
+
+{Loading the chunk from a stream}
+function TChunkzTXt.LoadFromStream(Stream: TStream;
+ const ChunkName: TChunkName; Size: Integer): Boolean;
+var
+ ErrorOutput: String;
+ CompressionMethod: Byte;
+ Output: Pointer;
+ OutputSize: Integer;
+begin
+ {Load data from stream and validate}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+ if not Result or (Size < 4) then exit;
+ fKeyword := PChar(Data); {Get keyword and compression method bellow}
+ CompressionMethod := pByte(Longint(fKeyword) + Length(fKeyword))^;
+ fText := '';
+
+ {In case the compression is 0 (only one accepted by specs), reads it}
+ if CompressionMethod = 0 then
+ begin
+ Output := nil;
+ if DecompressZLIB(PChar(Longint(Data) + Length(fKeyword) + 2),
+ Size - Length(fKeyword) - 2, Output, OutputSize, ErrorOutput) then
+ begin
+ SetLength(fText, OutputSize);
+ CopyMemory(@fText[1], Output, OutputSize);
+ end {if DecompressZLIB(...};
+ FreeMem(Output);
+ end {if CompressionMethod = 0}
+
+end;
+
+{Saving the chunk to a stream}
+function TChunkztXt.SaveToStream(Stream: TStream): Boolean;
+var
+ Output: Pointer;
+ OutputSize: Integer;
+ ErrorOutput: String;
+begin
+ Output := nil; {Initializes output}
+ if fText = '' then fText := ' ';
+
+ {Compresses the data}
+ if CompressZLIB(@fText[1], Length(fText), Owner.CompressionLevel, Output,
+ OutputSize, ErrorOutput) then
+ begin
+ {Size is length from keyword, plus a null character to divide}
+ {plus the compression method, plus the length of the text (zlib compressed)}
+ ResizeData(Length(fKeyword) + 2 + OutputSize);
+
+ Fillchar(Data^, DataSize, #0);
+ {Copies the keyword data}
+ if Keyword <> '' then
+ CopyMemory(Data, @fKeyword[1], Length(Keyword));
+ {Compression method 0 (inflate/deflate)}
+ pByte(pointer(Longint(Data) + Length(Keyword) + 1))^ := 0;
+ if OutputSize > 0 then
+ CopyMemory(pointer(Longint(Data) + Length(Keyword) + 2), Output, OutputSize);
+
+ {Let ancestor calculate crc and save}
+ Result := SaveData(Stream);
+ end {if CompressZLIB(...} else Result := False;
+
+ {Frees output}
+ if Output <> nil then FreeMem(Output)
+end;
+
+{TChunktEXt implementation}
+
+{Assigns from another text chunk}
+procedure TChunktEXt.Assign(Source: TChunk);
+begin
+ fKeyword := TChunktEXt(Source).fKeyword;
+ fText := TChunktEXt(Source).fText;
+end;
+
+{Loading the chunk from a stream}
+function TChunktEXt.LoadFromStream(Stream: TStream;
+ const ChunkName: TChunkName; Size: Integer): Boolean;
+begin
+ {Load data from stream and validate}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+ if not Result or (Size < 3) then exit;
+ {Get text}
+ fKeyword := PChar(Data);
+ SetLength(fText, Size - Length(fKeyword) - 1);
+ CopyMemory(@fText[1], pointer(Longint(Data) + Length(fKeyword) + 1), Length(fText));
+end;
+
+{Saving the chunk to a stream}
+function TChunktEXt.SaveToStream(Stream: TStream): Boolean;
+begin
+ {Size is length from keyword, plus a null character to divide}
+ {plus the length of the text}
+ ResizeData(Length(fKeyword) + 1 + Length(fText));
+ Fillchar(Data^, DataSize, #0);
+ {Copy data}
+ if Keyword <> '' then
+ CopyMemory(Data, @fKeyword[1], Length(Keyword));
+ if Text <> '' then
+ CopyMemory(pointer(Longint(Data) + Length(Keyword) + 1), @fText[1], Length(Text));
+ {Let ancestor calculate crc and save}
+ Result := inherited SaveToStream(Stream);
+end;
+
+
+{TChunkIHDR implementation}
+
+{Chunk being created}
+constructor TChunkIHDR.Create(Owner: TPngObject);
+begin
+ {Call inherited}
+ inherited Create(Owner);
+ {Prepare pointers}
+ ImageHandle := 0;
+ ImageDC := 0;
+end;
+
+{Chunk being destroyed}
+destructor TChunkIHDR.Destroy;
+begin
+ {Free memory}
+ FreeImageData();
+
+ {Calls TChunk destroy}
+ inherited Destroy;
+end;
+
+{Assigns from another IHDR chunk}
+procedure TChunkIHDR.Assign(Source: TChunk);
+begin
+ {Copy the IHDR data}
+ if Source is TChunkIHDR then
+ begin
+ {Copy IHDR values}
+ IHDRData := TChunkIHDR(Source).IHDRData;
+
+ {Prepare to hold data by filling BitmapInfo structure and}
+ {resizing ImageData and ImageAlpha memory allocations}
+ PrepareImageData();
+
+ {Copy image data}
+ CopyMemory(ImageData, TChunkIHDR(Source).ImageData,
+ BytesPerRow * Integer(Height));
+ CopyMemory(ImageAlpha, TChunkIHDR(Source).ImageAlpha,
+ Integer(Width) * Integer(Height));
+
+ {Copy palette colors}
+ BitmapInfo.bmiColors := TChunkIHDR(Source).BitmapInfo.bmiColors;
+ end
+ else
+ Owner.RaiseError(EPNGError, EPNGCannotAssignChunkText);
+end;
+
+{Release allocated image data}
+procedure TChunkIHDR.FreeImageData;
+begin
+ {Free old image data}
+ if ImageHandle <> 0 then DeleteObject(ImageHandle);
+ if ImageDC <> 0 then DeleteDC(ImageDC);
+ if ImageAlpha <> nil then FreeMem(ImageAlpha);
+ {$IFDEF Store16bits}
+ if ExtraImageData <> nil then FreeMem(ExtraImageData);
+ {$ENDIF}
+ ImageHandle := 0; ImageDC := 0; ImageAlpha := nil; ImageData := nil;
+end;
+
+{Chunk being loaded from a stream}
+function TChunkIHDR.LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean;
+begin
+ {Let TChunk load it}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+ if not Result then Exit;
+
+ {Now check values}
+ {Note: It's recommended by png specification to make sure that the size}
+ {must be 13 bytes to be valid, but some images with 14 bytes were found}
+ {which could be loaded by internet explorer and other tools}
+ if (fDataSize < SIZEOF(TIHdrData)) then
+ begin
+ {Ihdr must always have at least 13 bytes}
+ Result := False;
+ Owner.RaiseError(EPNGInvalidIHDR, EPNGInvalidIHDRText);
+ exit;
+ end;
+
+ {Everything ok, reads IHDR}
+ IHDRData := pIHDRData(fData)^;
+ IHDRData.Width := ByteSwap(IHDRData.Width);
+ IHDRData.Height := ByteSwap(IHDRData.Height);
+
+ {The width and height must not be larger than 65535 pixels}
+ if (IHDRData.Width > High(Word)) or (IHDRData.Height > High(Word)) then
+ begin
+ Result := False;
+ Owner.RaiseError(EPNGSizeExceeds, EPNGSizeExceedsText);
+ exit;
+ end {if IHDRData.Width > High(Word)};
+ {Compression method must be 0 (inflate/deflate)}
+ if (IHDRData.CompressionMethod <> 0) then
+ begin
+ Result := False;
+ Owner.RaiseError(EPNGUnknownCompression, EPNGUnknownCompressionText);
+ exit;
+ end;
+ {Interlace must be either 0 (none) or 7 (adam7)}
+ if (IHDRData.InterlaceMethod <> 0) and (IHDRData.InterlaceMethod <> 1) then
+ begin
+ Result := False;
+ Owner.RaiseError(EPNGUnknownInterlace, EPNGUnknownInterlaceText);
+ exit;
+ end;
+
+ {Updates owner properties}
+ Owner.InterlaceMethod := TInterlaceMethod(IHDRData.InterlaceMethod);
+
+ {Prepares data to hold image}
+ PrepareImageData();
+end;
+
+{Saving the IHDR chunk to a stream}
+function TChunkIHDR.SaveToStream(Stream: TStream): Boolean;
+begin
+ {Ignore 2 bits images}
+ if BitDepth = 2 then BitDepth := 4;
+
+ {It needs to do is update the data with the IHDR data}
+ {structure containing the write values}
+ ResizeData(SizeOf(TIHDRData));
+ pIHDRData(fData)^ := IHDRData;
+ {..byteswap 4 byte types}
+ pIHDRData(fData)^.Width := ByteSwap(pIHDRData(fData)^.Width);
+ pIHDRData(fData)^.Height := ByteSwap(pIHDRData(fData)^.Height);
+ {..update interlace method}
+ pIHDRData(fData)^.InterlaceMethod := Byte(Owner.InterlaceMethod);
+ {..and then let the ancestor SaveToStream do the hard work}
+ Result := inherited SaveToStream(Stream);
+end;
+
+{Resizes the image data to fill the color type, bit depth, }
+{width and height parameters}
+procedure TChunkIHDR.PrepareImageData();
+
+ {Set the bitmap info}
+ procedure SetInfo(const Bitdepth: Integer; const Palette: Boolean);
+ begin
+
+ {Copy if the bitmap contain palette entries}
+ HasPalette := Palette;
+ {Initialize the structure with zeros}
+ fillchar(BitmapInfo, sizeof(BitmapInfo), #0);
+ {Fill the strucutre}
+ with BitmapInfo.bmiHeader do
+ begin
+ biSize := sizeof(TBitmapInfoHeader);
+ biHeight := Height;
+ biWidth := Width;
+ biPlanes := 1;
+ biBitCount := BitDepth;
+ biCompression := BI_RGB;
+ end {with BitmapInfo.bmiHeader}
+ end;
+begin
+ {Prepare bitmap info header}
+ Fillchar(BitmapInfo, sizeof(TMaxBitmapInfo), #0);
+ {Release old image data}
+ FreeImageData();
+
+ {Obtain number of bits for each pixel}
+ case ColorType of
+ COLOR_GRAYSCALE, COLOR_PALETTE, COLOR_GRAYSCALEALPHA:
+ case BitDepth of
+ {These are supported by windows}
+ 1, 4, 8: SetInfo(BitDepth, TRUE);
+ {2 bits for each pixel is not supported by windows bitmap}
+ 2 : SetInfo(4, TRUE);
+ {Also 16 bits (2 bytes) for each pixel is not supported}
+ {and should be transormed into a 8 bit grayscale}
+ 16 : SetInfo(8, TRUE);
+ end;
+ {Only 1 byte (8 bits) is supported}
+ COLOR_RGB, COLOR_RGBALPHA: SetInfo(24, FALSE);
+ end {case ColorType};
+ {Number of bytes for each scanline}
+ BytesPerRow := (((BitmapInfo.bmiHeader.biBitCount * Width) + 31)
+ and not 31) div 8;
+
+ {Build array for alpha information, if necessary}
+ if (ColorType = COLOR_RGBALPHA) or (ColorType = COLOR_GRAYSCALEALPHA) then
+ begin
+ GetMem(ImageAlpha, Integer(Width) * Integer(Height));
+ FillChar(ImageAlpha^, Integer(Width) * Integer(Height), #0);
+ end;
+
+ {Build array for extra byte information}
+ {$IFDEF Store16bits}
+ if (BitDepth = 16) then
+ begin
+ GetMem(ExtraImageData, BytesPerRow * Integer(Height));
+ FillChar(ExtraImageData^, BytesPerRow * Integer(Height), #0);
+ end;
+ {$ENDIF}
+
+ {Creates the image to hold the data, CreateDIBSection does a better}
+ {work in allocating necessary memory}
+ ImageDC := CreateCompatibleDC(0);
+ ImageHandle := CreateDIBSection(ImageDC, pBitmapInfo(@BitmapInfo)^,
+ DIB_RGB_COLORS, ImageData, 0, 0);
+
+ {Clears the old palette (if any)}
+ with Owner do
+ if TempPalette <> 0 then
+ begin
+ DeleteObject(TempPalette);
+ TempPalette := 0;
+ end {with Owner, if TempPalette <> 0};
+
+ {Build array and allocate bytes for each row}
+ zeromemory(ImageData, BytesPerRow * Integer(Height));
+end;
+
+{TChunktRNS implementation}
+
+{$IFNDEF UseDelphi}
+function CompareMem(P1, P2: pByte; const Size: Integer): Boolean;
+var i: Integer;
+begin
+ Result := True;
+ for i := 1 to Size do
+ begin
+ if P1^ <> P2^ then Result := False;
+ inc(P1); inc(P2);
+ end {for i}
+end;
+{$ENDIF}
+
+{Sets the transpararent color}
+procedure TChunktRNS.SetTransparentColor(const Value: ColorRef);
+var
+ i: Byte;
+ LookColor: TRGBQuad;
+begin
+ {Clears the palette values}
+ Fillchar(PaletteValues, SizeOf(PaletteValues), #0);
+ {Sets that it uses bit transparency}
+ fBitTransparency := True;
+
+
+ {Depends on the color type}
+ with Header do
+ case ColorType of
+ COLOR_GRAYSCALE:
+ begin
+ Self.ResizeData(2);
+ pWord(@PaletteValues[0])^ := ByteSwap16(GetRValue(Value));
+ end;
+ COLOR_RGB:
+ begin
+ Self.ResizeData(6);
+ pWord(@PaletteValues[0])^ := ByteSwap16(GetRValue(Value));
+ pWord(@PaletteValues[2])^ := ByteSwap16(GetGValue(Value));
+ pWord(@PaletteValues[4])^ := ByteSwap16(GetBValue(Value));
+ end;
+ COLOR_PALETTE:
+ begin
+ {Creates a RGBQuad to search for the color}
+ LookColor.rgbRed := GetRValue(Value);
+ LookColor.rgbGreen := GetGValue(Value);
+ LookColor.rgbBlue := GetBValue(Value);
+ {Look in the table for the entry}
+ for i := 0 to 255 do
+ if CompareMem(@BitmapInfo.bmiColors[i], @LookColor, 3) then
+ Break;
+ {Fill the transparency table}
+ Fillchar(PaletteValues, i, 255);
+ Self.ResizeData(i + 1)
+
+ end
+ end {case / with};
+
+end;
+
+{Returns the transparent color for the image}
+function TChunktRNS.GetTransparentColor: ColorRef;
+var
+ PaletteChunk: TChunkPLTE;
+ i: Integer;
+begin
+ Result := 0; {Default: Unknown transparent color}
+
+ {Depends on the color type}
+ with Header do
+ case ColorType of
+ COLOR_GRAYSCALE:
+ Result := RGB(PaletteValues[0], PaletteValues[0],
+ PaletteValues[0]);
+ COLOR_RGB:
+ Result := RGB(PaletteValues[1], PaletteValues[3], PaletteValues[5]);
+ COLOR_PALETTE:
+ begin
+ {Obtains the palette chunk}
+ PaletteChunk := Owner.Chunks.ItemFromClass(TChunkPLTE) as TChunkPLTE;
+
+ {Looks for an entry with 0 transparency meaning that it is the}
+ {full transparent entry}
+ for i := 0 to Self.DataSize - 1 do
+ if PaletteValues[i] = 0 then
+ with PaletteChunk.GetPaletteItem(i) do
+ begin
+ Result := RGB(rgbRed, rgbGreen, rgbBlue);
+ break
+ end
+ end {COLOR_PALETTE}
+ end {case Header.ColorType};
+end;
+
+{Saving the chunk to a stream}
+function TChunktRNS.SaveToStream(Stream: TStream): Boolean;
+begin
+ {Copy palette into data buffer}
+ if DataSize <= 256 then
+ CopyMemory(fData, @PaletteValues[0], DataSize);
+
+ Result := inherited SaveToStream(Stream);
+end;
+
+{Assigns from another chunk}
+procedure TChunktRNS.Assign(Source: TChunk);
+begin
+ CopyMemory(@PaletteValues[0], @TChunkTrns(Source).PaletteValues[0], 256);
+ fBitTransparency := TChunkTrns(Source).fBitTransparency;
+ inherited Assign(Source);
+end;
+
+{Loads the chunk from a stream}
+function TChunktRNS.LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean;
+var
+ i, Differ255: Integer;
+begin
+ {Let inherited load}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+
+ if not Result then Exit;
+
+ {Make sure size is correct}
+ if Size > 256 then Owner.RaiseError(EPNGInvalidPalette,
+ EPNGInvalidPaletteText);
+
+ {The unset items should have value 255}
+ Fillchar(PaletteValues[0], 256, 255);
+ {Copy the other values}
+ CopyMemory(@PaletteValues[0], fData, Size);
+
+ {Create the mask if needed}
+ case Header.ColorType of
+ {Mask for grayscale and RGB}
+ COLOR_RGB, COLOR_GRAYSCALE: fBitTransparency := True;
+ COLOR_PALETTE:
+ begin
+ Differ255 := 0; {Count the entries with a value different from 255}
+ {Tests if it uses bit transparency}
+ for i := 0 to Size - 1 do
+ if PaletteValues[i] <> 255 then inc(Differ255);
+
+ {If it has one value different from 255 it is a bit transparency}
+ fBitTransparency := (Differ255 = 1);
+ end {COLOR_PALETTE}
+ end {case Header.ColorType};
+
+end;
+
+{Prepares the image palette}
+procedure TChunkIDAT.PreparePalette;
+var
+ Entries: Word;
+ j : Integer;
+begin
+ {In case the image uses grayscale, build a grayscale palette}
+ with Header do
+ if (ColorType = COLOR_GRAYSCALE) or (ColorType = COLOR_GRAYSCALEALPHA) then
+ begin
+ {Calculate total number of palette entries}
+ Entries := (1 shl Byte(BitmapInfo.bmiHeader.biBitCount));
+
+ FOR j := 0 TO Entries - 1 DO
+ with BitmapInfo.bmiColors[j] do
+ begin
+
+ {Calculate each palette entry}
+ rgbRed := fOwner.GammaTable[MulDiv(j, 255, Entries - 1)];
+ rgbGreen := rgbRed;
+ rgbBlue := rgbRed;
+ end {with BitmapInfo.bmiColors[j]}
+ end {if ColorType = COLOR_GRAYSCALE..., with Header}
+end;
+
+{Reads from ZLIB}
+function TChunkIDAT.IDATZlibRead(var ZLIBStream: TZStreamRec2;
+ Buffer: Pointer; Count: Integer; var EndPos: Integer;
+ var crcfile: Cardinal): Integer;
+var
+ ProcResult : Integer;
+ IDATHeader : Array[0..3] of char;
+ IDATCRC : Cardinal;
+begin
+ {Uses internal record pointed by ZLIBStream to gather information}
+ with ZLIBStream, ZLIBStream.zlib do
+ begin
+ {Set the buffer the zlib will read into}
+ next_out := Buffer;
+ avail_out := Count;
+
+ {Decode until it reach the Count variable}
+ while avail_out > 0 do
+ begin
+ {In case it needs more data and it's in the end of a IDAT chunk,}
+ {it means that there are more IDAT chunks}
+ if (fStream.Position = EndPos) and (avail_out > 0) and
+ (avail_in = 0) then
+ begin
+ {End this chunk by reading and testing the crc value}
+ fStream.Read(IDATCRC, 4);
+
+ {$IFDEF CheckCRC}
+ if crcfile xor $ffffffff <> Cardinal(ByteSwap(IDATCRC)) then
+ begin
+ Result := -1;
+ Owner.RaiseError(EPNGInvalidCRC, EPNGInvalidCRCText);
+ exit;
+ end;
+ {$ENDIF}
+
+ {Start reading the next chunk}
+ fStream.Read(EndPos, 4); {Reads next chunk size}
+ fStream.Read(IDATHeader[0], 4); {Next chunk header}
+ {It must be a IDAT chunk since image data is required and PNG}
+ {specification says that multiple IDAT chunks must be consecutive}
+ if IDATHeader <> 'IDAT' then
+ begin
+ Owner.RaiseError(EPNGMissingMultipleIDAT, EPNGMissingMultipleIDATText);
+ result := -1;
+ exit;
+ end;
+
+ {Calculate chunk name part of the crc}
+ {$IFDEF CheckCRC}
+ crcfile := update_crc($ffffffff, @IDATHeader[0], 4);
+ {$ENDIF}
+ EndPos := fStream.Position + ByteSwap(EndPos);
+ end;
+
+
+ {In case it needs compressed data to read from}
+ if avail_in = 0 then
+ begin
+ {In case it's trying to read more than it is avaliable}
+ if fStream.Position + ZLIBAllocate > EndPos then
+ avail_in := fStream.Read(Data^, EndPos - fStream.Position)
+ else
+ avail_in := fStream.Read(Data^, ZLIBAllocate);
+ {Update crc}
+ {$IFDEF CheckCRC}
+ crcfile := update_crc(crcfile, Data, avail_in);
+ {$ENDIF}
+
+ {In case there is no more compressed data to read from}
+ if avail_in = 0 then
+ begin
+ Result := Count - avail_out;
+ Exit;
+ end;
+
+ {Set next buffer to read and record current position}
+ next_in := Data;
+
+ end {if avail_in = 0};
+
+ ProcResult := inflate(zlib, 0);
+
+ {In case the result was not sucessfull}
+ if (ProcResult < 0) then
+ begin
+ Result := -1;
+ Owner.RaiseError(EPNGZLIBError,
+ EPNGZLIBErrorText + zliberrors[procresult]);
+ exit;
+ end;
+
+ end {while avail_out > 0};
+
+ end {with};
+
+ {If everything gone ok, it returns the count bytes}
+ Result := Count;
+end;
+
+{TChunkIDAT implementation}
+
+const
+ {Adam 7 interlacing values}
+ RowStart: array[0..6] of Integer = (0, 0, 4, 0, 2, 0, 1);
+ ColumnStart: array[0..6] of Integer = (0, 4, 0, 2, 0, 1, 0);
+ RowIncrement: array[0..6] of Integer = (8, 8, 8, 4, 4, 2, 2);
+ ColumnIncrement: array[0..6] of Integer = (8, 8, 4, 4, 2, 2, 1);
+
+{Copy interlaced images with 1 byte for R, G, B}
+procedure TChunkIDAT.CopyInterlacedRGB8(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col * 3);
+ repeat
+ {Copy this row}
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+
+ {Move to next column}
+ inc(Src, 3);
+ inc(Dest, ColumnIncrement[Pass] * 3 - 3);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy interlaced images with 2 bytes for R, G, B}
+procedure TChunkIDAT.CopyInterlacedRGB16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col * 3);
+ repeat
+ {Copy this row}
+ Byte(Dest^) := Owner.GammaTable[pByte(Longint(Src) + 4)^]; inc(Dest);
+ Byte(Dest^) := Owner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := Owner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+ {$IFDEF Store16bits}
+ {Copy extra pixel values}
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 5)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 3)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Extra);
+ {$ENDIF}
+
+ {Move to next column}
+ inc(Src, 6);
+ inc(Dest, ColumnIncrement[Pass] * 3 - 3);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy ímages with palette using bit depths 1, 4 or 8}
+procedure TChunkIDAT.CopyInterlacedPalette148(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+const
+ BitTable: Array[1..8] of Integer = ($1, $3, 0, $F, 0, 0, 0, $FF);
+ StartBit: Array[1..8] of Integer = (7 , 0 , 0, 4, 0, 0, 0, 0);
+var
+ CurBit, Col: Integer;
+ Dest2: PChar;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ repeat
+ {Copy data}
+ CurBit := StartBit[Header.BitDepth];
+ repeat
+ {Adjust pointer to pixel byte bounds}
+ Dest2 := pChar(Longint(Dest) + (Header.BitDepth * Col) div 8);
+ {Copy data}
+ Byte(Dest2^) := Byte(Dest2^) or
+ ( ((Byte(Src^) shr CurBit) and BitTable[Header.BitDepth])
+ shl (StartBit[Header.BitDepth] - (Col * Header.BitDepth mod 8)));
+
+ {Move to next column}
+ inc(Col, ColumnIncrement[Pass]);
+ {Will read next bits}
+ dec(CurBit, Header.BitDepth);
+ until CurBit < 0;
+
+ {Move to next byte in source}
+ inc(Src);
+ until Col >= ImageWidth;
+end;
+
+{Copy ímages with palette using bit depth 2}
+procedure TChunkIDAT.CopyInterlacedPalette2(const Pass: Byte; Src, Dest,
+ Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ CurBit, Col: Integer;
+ Dest2: PChar;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ repeat
+ {Copy data}
+ CurBit := 6;
+ repeat
+ {Adjust pointer to pixel byte bounds}
+ Dest2 := pChar(Longint(Dest) + Col div 2);
+ {Copy data}
+ Byte(Dest2^) := Byte(Dest2^) or (((Byte(Src^) shr CurBit) and $3)
+ shl (4 - (4 * Col) mod 8));
+ {Move to next column}
+ inc(Col, ColumnIncrement[Pass]);
+ {Will read next bits}
+ dec(CurBit, 2);
+ until CurBit < 0;
+
+ {Move to next byte in source}
+ inc(Src);
+ until Col >= ImageWidth;
+end;
+
+{Copy ímages with grayscale using bit depth 2}
+procedure TChunkIDAT.CopyInterlacedGray2(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ CurBit, Col: Integer;
+ Dest2: PChar;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ repeat
+ {Copy data}
+ CurBit := 6;
+ repeat
+ {Adjust pointer to pixel byte bounds}
+ Dest2 := pChar(Longint(Dest) + Col div 2);
+ {Copy data}
+ Byte(Dest2^) := Byte(Dest2^) or ((((Byte(Src^) shr CurBit) shl 2) and $F)
+ shl (4 - (Col*4) mod 8));
+ {Move to next column}
+ inc(Col, ColumnIncrement[Pass]);
+ {Will read next bits}
+ dec(CurBit, 2);
+ until CurBit < 0;
+
+ {Move to next byte in source}
+ inc(Src);
+ until Col >= ImageWidth;
+end;
+
+{Copy ímages with palette using 2 bytes for each pixel}
+procedure TChunkIDAT.CopyInterlacedGrayscale16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col);
+ repeat
+ {Copy this row}
+ Dest^ := Src^; inc(Dest);
+ {$IFDEF Store16bits}
+ Extra^ := pChar(Longint(Src) + 1)^; inc(Extra);
+ {$ENDIF}
+
+ {Move to next column}
+ inc(Src, 2);
+ inc(Dest, ColumnIncrement[Pass] - 1);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Decodes interlaced RGB alpha with 1 byte for each sample}
+procedure TChunkIDAT.CopyInterlacedRGBAlpha8(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col * 3);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this row and alpha value}
+ Trans^ := pChar(Longint(Src) + 3)^;
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+
+ {Move to next column}
+ inc(Src, 4);
+ inc(Dest, ColumnIncrement[Pass] * 3 - 3);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Decodes interlaced RGB alpha with 2 bytes for each sample}
+procedure TChunkIDAT.CopyInterlacedRGBAlpha16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col * 3);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this row and alpha value}
+ Trans^ := pChar(Longint(Src) + 6)^;
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 4)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+ {$IFDEF Store16bits}
+ {Copy extra pixel values}
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 5)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 3)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Extra);
+ {$ENDIF}
+
+ {Move to next column}
+ inc(Src, 8);
+ inc(Dest, ColumnIncrement[Pass] * 3 - 3);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Decodes 8 bit grayscale image followed by an alpha sample}
+procedure TChunkIDAT.CopyInterlacedGrayscaleAlpha8(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column, pointers to the data and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this grayscale value and alpha}
+ Dest^ := Src^; inc(Src);
+ Trans^ := Src^; inc(Src);
+
+ {Move to next column}
+ inc(Dest, ColumnIncrement[Pass]);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Decodes 16 bit grayscale image followed by an alpha sample}
+procedure TChunkIDAT.CopyInterlacedGrayscaleAlpha16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column, pointers to the data and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {$IFDEF Store16bits}
+ Extra^ := pChar(Longint(Src) + 1)^; inc(Extra);
+ {$ENDIF}
+ {Copy this grayscale value and alpha, transforming 16 bits into 8}
+ Dest^ := Src^; inc(Src, 2);
+ Trans^ := Src^; inc(Src, 2);
+
+ {Move to next column}
+ inc(Dest, ColumnIncrement[Pass]);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Decodes an interlaced image}
+procedure TChunkIDAT.DecodeInterlacedAdam7(Stream: TStream;
+ var ZLIBStream: TZStreamRec2; const Size: Integer; var crcfile: Cardinal);
+var
+ CurrentPass: Byte;
+ PixelsThisRow: Integer;
+ CurrentRow: Integer;
+ Trans, Data{$IFDEF Store16bits}, Extra{$ENDIF}: pChar;
+ CopyProc: procedure(const Pass: Byte; Src, Dest,
+ Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar) of object;
+begin
+
+ CopyProc := nil; {Initialize}
+ {Determine method to copy the image data}
+ case Header.ColorType of
+ {R, G, B values for each pixel}
+ COLOR_RGB:
+ case Header.BitDepth of
+ 8: CopyProc := CopyInterlacedRGB8;
+ 16: CopyProc := CopyInterlacedRGB16;
+ end {case Header.BitDepth};
+ {Palette}
+ COLOR_PALETTE, COLOR_GRAYSCALE:
+ case Header.BitDepth of
+ 1, 4, 8: CopyProc := CopyInterlacedPalette148;
+ 2 : if Header.ColorType = COLOR_PALETTE then
+ CopyProc := CopyInterlacedPalette2
+ else
+ CopyProc := CopyInterlacedGray2;
+ 16 : CopyProc := CopyInterlacedGrayscale16;
+ end;
+ {RGB followed by alpha}
+ COLOR_RGBALPHA:
+ case Header.BitDepth of
+ 8: CopyProc := CopyInterlacedRGBAlpha8;
+ 16: CopyProc := CopyInterlacedRGBAlpha16;
+ end;
+ {Grayscale followed by alpha}
+ COLOR_GRAYSCALEALPHA:
+ case Header.BitDepth of
+ 8: CopyProc := CopyInterlacedGrayscaleAlpha8;
+ 16: CopyProc := CopyInterlacedGrayscaleAlpha16;
+ end;
+ end {case Header.ColorType};
+
+ {Adam7 method has 7 passes to make the final image}
+ FOR CurrentPass := 0 TO 6 DO
+ begin
+ {Calculates the number of pixels and bytes for this pass row}
+ PixelsThisRow := (ImageWidth - ColumnStart[CurrentPass] +
+ ColumnIncrement[CurrentPass] - 1) div ColumnIncrement[CurrentPass];
+ Row_Bytes := BytesForPixels(PixelsThisRow, Header.ColorType,
+ Header.BitDepth);
+ {Clear buffer for this pass}
+ ZeroMemory(Row_Buffer[not RowUsed], Row_Bytes);
+
+ {Get current row index}
+ CurrentRow := RowStart[CurrentPass];
+ {Get a pointer to the current row image data}
+ Data := pointer(Longint(Header.ImageData) + Header.BytesPerRow * (ImageHeight - 1 - CurrentRow));
+ Trans := pointer(Longint(Header.ImageAlpha) + ImageWidth * CurrentRow);
+ {$IFDEF Store16bits}
+ Extra := pointer(Longint(Header.ExtraImageData) + Header.BytesPerRow * (ImageHeight - 1 - CurrentRow));
+ {$ENDIF}
+
+ if Row_Bytes > 0 then {There must have bytes for this interlaced pass}
+ while CurrentRow < ImageHeight do
+ begin
+ {Reads this line and filter}
+ if IDATZlibRead(ZLIBStream, @Row_Buffer[RowUsed][0], Row_Bytes + 1,
+ EndPos, CRCFile) = 0 then break;
+
+ FilterRow;
+ {Copy image data}
+
+ CopyProc(CurrentPass, @Row_Buffer[RowUsed][1], Data, Trans
+ {$IFDEF Store16bits}, Extra{$ENDIF});
+
+ {Use the other RowBuffer item}
+ RowUsed := not RowUsed;
+
+ {Move to the next row}
+ inc(CurrentRow, RowIncrement[CurrentPass]);
+ {Move pointer to the next line}
+ dec(Data, RowIncrement[CurrentPass] * Header.BytesPerRow);
+ inc(Trans, RowIncrement[CurrentPass] * ImageWidth);
+ {$IFDEF Store16bits}
+ dec(Extra, RowIncrement[CurrentPass] * Header.BytesPerRow);
+ {$ENDIF}
+ end {while CurrentRow < ImageHeight};
+
+ end {FOR CurrentPass};
+
+end;
+
+{Copy 8 bits RGB image}
+procedure TChunkIDAT.CopyNonInterlacedRGB8(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ {Copy pixel values}
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+ {Move to next pixel}
+ inc(Src, 3);
+ end {for I}
+end;
+
+{Copy 16 bits RGB image}
+procedure TChunkIDAT.CopyNonInterlacedRGB16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ //Since windows does not supports 2 bytes for
+ //each R, G, B value, the method will read only 1 byte from it
+ {Copy pixel values}
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 4)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+ {$IFDEF Store16bits}
+ {Copy extra pixel values}
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 5)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 3)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Extra);
+ {$ENDIF}
+
+ {Move to next pixel}
+ inc(Src, 6);
+ end {for I}
+end;
+
+{Copy types using palettes (1, 4 or 8 bits per pixel)}
+procedure TChunkIDAT.CopyNonInterlacedPalette148(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+begin
+ {It's simple as copying the data}
+ CopyMemory(Dest, Src, Row_Bytes);
+end;
+
+{Copy grayscale types using 2 bits for each pixel}
+procedure TChunkIDAT.CopyNonInterlacedGray2(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ i: Integer;
+begin
+ {2 bits is not supported, this routine will converted into 4 bits}
+ FOR i := 1 TO Row_Bytes do
+ begin
+ Byte(Dest^) := ((Byte(Src^) shr 2) and $F) or ((Byte(Src^)) and $F0); inc(Dest);
+ Byte(Dest^) := ((Byte(Src^) shl 2) and $F) or ((Byte(Src^) shl 4) and $F0); inc(Dest);
+ inc(Src);
+ end {FOR i}
+end;
+
+{Copy types using palette with 2 bits for each pixel}
+procedure TChunkIDAT.CopyNonInterlacedPalette2(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ i: Integer;
+begin
+ {2 bits is not supported, this routine will converted into 4 bits}
+ FOR i := 1 TO Row_Bytes do
+ begin
+ Byte(Dest^) := ((Byte(Src^) shr 4) and $3) or ((Byte(Src^) shr 2) and $30); inc(Dest);
+ Byte(Dest^) := (Byte(Src^) and $3) or ((Byte(Src^) shl 2) and $30); inc(Dest);
+ inc(Src);
+ end {FOR i}
+end;
+
+{Copy grayscale images with 16 bits}
+procedure TChunkIDAT.CopyNonInterlacedGrayscale16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ {Windows does not supports 16 bits for each pixel in grayscale}
+ {mode, so reduce to 8}
+ Dest^ := Src^; inc(Dest);
+ {$IFDEF Store16bits}
+ Extra^ := pChar(Longint(Src) + 1)^; inc(Extra);
+ {$ENDIF}
+
+ {Move to next pixel}
+ inc(Src, 2);
+ end {for I}
+end;
+
+{Copy 8 bits per sample RGB images followed by an alpha byte}
+procedure TChunkIDAT.CopyNonInterlacedRGBAlpha8(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ i: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ {Copy pixel values and transparency}
+ Trans^ := pChar(Longint(Src) + 3)^;
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+ {Move to next pixel}
+ inc(Src, 4); inc(Trans);
+ end {for I}
+end;
+
+{Copy 16 bits RGB image with alpha using 2 bytes for each sample}
+procedure TChunkIDAT.CopyNonInterlacedRGBAlpha16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ //Copy rgb and alpha values (transforming from 16 bits to 8 bits)
+ {Copy pixel values}
+ Trans^ := pChar(Longint(Src) + 6)^;
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 4)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+ {$IFDEF Store16bits}
+ {Copy extra pixel values}
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 5)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 3)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Extra);
+ {$ENDIF}
+ {Move to next pixel}
+ inc(Src, 8); inc(Trans);
+ end {for I}
+end;
+
+{Copy 8 bits per sample grayscale followed by alpha}
+procedure TChunkIDAT.CopyNonInterlacedGrayscaleAlpha8(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ {Copy alpha value and then gray value}
+ Dest^ := Src^; inc(Src);
+ Trans^ := Src^; inc(Src);
+ inc(Dest); inc(Trans);
+ end;
+end;
+
+{Copy 16 bits per sample grayscale followed by alpha}
+procedure TChunkIDAT.CopyNonInterlacedGrayscaleAlpha16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ {Copy alpha value and then gray value}
+ {$IFDEF Store16bits}
+ Extra^ := pChar(Longint(Src) + 1)^; inc(Extra);
+ {$ENDIF}
+ Dest^ := Src^; inc(Src, 2);
+ Trans^ := Src^; inc(Src, 2);
+ inc(Dest); inc(Trans);
+ end;
+end;
+
+{Decode non interlaced image}
+procedure TChunkIDAT.DecodeNonInterlaced(Stream: TStream;
+ var ZLIBStream: TZStreamRec2; const Size: Integer; var crcfile: Cardinal);
+var
+ j: Cardinal;
+ Trans, Data{$IFDEF Store16bits}, Extra{$ENDIF}: pChar;
+ CopyProc: procedure(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar) of object;
+begin
+ CopyProc := nil; {Initialize}
+ {Determines the method to copy the image data}
+ case Header.ColorType of
+ {R, G, B values}
+ COLOR_RGB:
+ case Header.BitDepth of
+ 8: CopyProc := CopyNonInterlacedRGB8;
+ 16: CopyProc := CopyNonInterlacedRGB16;
+ end;
+ {Types using palettes}
+ COLOR_PALETTE, COLOR_GRAYSCALE:
+ case Header.BitDepth of
+ 1, 4, 8: CopyProc := CopyNonInterlacedPalette148;
+ 2 : if Header.ColorType = COLOR_PALETTE then
+ CopyProc := CopyNonInterlacedPalette2
+ else
+ CopyProc := CopyNonInterlacedGray2;
+ 16 : CopyProc := CopyNonInterlacedGrayscale16;
+ end;
+ {R, G, B followed by alpha}
+ COLOR_RGBALPHA:
+ case Header.BitDepth of
+ 8 : CopyProc := CopyNonInterlacedRGBAlpha8;
+ 16 : CopyProc := CopyNonInterlacedRGBAlpha16;
+ end;
+ {Grayscale followed by alpha}
+ COLOR_GRAYSCALEALPHA:
+ case Header.BitDepth of
+ 8 : CopyProc := CopyNonInterlacedGrayscaleAlpha8;
+ 16 : CopyProc := CopyNonInterlacedGrayscaleAlpha16;
+ end;
+ end;
+
+ {Get the image data pointer}
+ Longint(Data) := Longint(Header.ImageData) +
+ Header.BytesPerRow * (ImageHeight - 1);
+ Trans := Header.ImageAlpha;
+ {$IFDEF Store16bits}
+ Longint(Extra) := Longint(Header.ExtraImageData) +
+ Header.BytesPerRow * (ImageHeight - 1);
+ {$ENDIF}
+ {Reads each line}
+ FOR j := 0 to ImageHeight - 1 do
+ begin
+ {Read this line Row_Buffer[RowUsed][0] if the filter type for this line}
+ if IDATZlibRead(ZLIBStream, @Row_Buffer[RowUsed][0], Row_Bytes + 1, EndPos,
+ CRCFile) = 0 then break;
+
+ {Filter the current row}
+ FilterRow;
+ {Copies non interlaced row to image}
+ CopyProc(@Row_Buffer[RowUsed][1], Data, Trans{$IFDEF Store16bits}, Extra
+ {$ENDIF});
+
+ {Invert line used}
+ RowUsed := not RowUsed;
+ dec(Data, Header.BytesPerRow);
+ {$IFDEF Store16bits}dec(Extra, Header.BytesPerRow);{$ENDIF}
+ inc(Trans, ImageWidth);
+ end {for I};
+
+
+end;
+
+{Filter the current line}
+procedure TChunkIDAT.FilterRow;
+var
+ pp: Byte;
+ vv, left, above, aboveleft: Integer;
+ Col: Cardinal;
+begin
+ {Test the filter}
+ case Row_Buffer[RowUsed]^[0] of
+ {No filtering for this line}
+ FILTER_NONE: begin end;
+ {AND 255 serves only to never let the result be larger than one byte}
+ {Sub filter}
+ FILTER_SUB:
+ FOR Col := Offset + 1 to Row_Bytes DO
+ Row_Buffer[RowUsed][Col] := (Row_Buffer[RowUsed][Col] +
+ Row_Buffer[RowUsed][Col - Offset]) and 255;
+ {Up filter}
+ FILTER_UP:
+ FOR Col := 1 to Row_Bytes DO
+ Row_Buffer[RowUsed][Col] := (Row_Buffer[RowUsed][Col] +
+ Row_Buffer[not RowUsed][Col]) and 255;
+ {Average filter}
+ FILTER_AVERAGE:
+ FOR Col := 1 to Row_Bytes DO
+ begin
+ {Obtains up and left pixels}
+ above := Row_Buffer[not RowUsed][Col];
+ if col - 1 < Offset then
+ left := 0
+ else
+ Left := Row_Buffer[RowUsed][Col - Offset];
+
+ {Calculates}
+ Row_Buffer[RowUsed][Col] := (Row_Buffer[RowUsed][Col] +
+ (left + above) div 2) and 255;
+ end;
+ {Paeth filter}
+ FILTER_PAETH:
+ begin
+ {Initialize}
+ left := 0;
+ aboveleft := 0;
+ {Test each byte}
+ FOR Col := 1 to Row_Bytes DO
+ begin
+ {Obtains above pixel}
+ above := Row_Buffer[not RowUsed][Col];
+ {Obtains left and top-left pixels}
+ if (col - 1 >= offset) Then
+ begin
+ left := row_buffer[RowUsed][col - offset];
+ aboveleft := row_buffer[not RowUsed][col - offset];
+ end;
+
+ {Obtains current pixel and paeth predictor}
+ vv := row_buffer[RowUsed][Col];
+ pp := PaethPredictor(left, above, aboveleft);
+
+ {Calculates}
+ Row_Buffer[RowUsed][Col] := (pp + vv) and $FF;
+ end {for};
+ end;
+
+ end {case};
+end;
+
+{Reads the image data from the stream}
+function TChunkIDAT.LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean;
+var
+ ZLIBStream: TZStreamRec2;
+ CRCCheck,
+ CRCFile : Cardinal;
+begin
+ {Get pointer to the header chunk}
+ Header := Owner.Chunks.Item[0] as TChunkIHDR;
+ {Build palette if necessary}
+ if Header.HasPalette then PreparePalette();
+
+ {Copy image width and height}
+ ImageWidth := Header.Width;
+ ImageHeight := Header.Height;
+
+ {Initialize to calculate CRC}
+ {$IFDEF CheckCRC}
+ CRCFile := update_crc($ffffffff, @ChunkName[0], 4);
+ {$ENDIF}
+
+ Owner.GetPixelInfo(Row_Bytes, Offset); {Obtain line information}
+ ZLIBStream := ZLIBInitInflate(Stream); {Initializes decompression}
+
+ {Calculate ending position for the current IDAT chunk}
+ EndPos := Stream.Position + Size;
+
+ {Allocate memory}
+ GetMem(Row_Buffer[false], Row_Bytes + 1);
+ GetMem(Row_Buffer[true], Row_Bytes + 1);
+ ZeroMemory(Row_Buffer[false], Row_bytes + 1);
+ {Set the variable to alternate the Row_Buffer item to use}
+ RowUsed := TRUE;
+
+ {Call special methods for the different interlace methods}
+ case Owner.InterlaceMethod of
+ imNone: DecodeNonInterlaced(stream, ZLIBStream, Size, crcfile);
+ imAdam7: DecodeInterlacedAdam7(stream, ZLIBStream, size, crcfile);
+ end;
+
+ {Free memory}
+ ZLIBTerminateInflate(ZLIBStream); {Terminates decompression}
+ FreeMem(Row_Buffer[False], Row_Bytes + 1);
+ FreeMem(Row_Buffer[True], Row_Bytes + 1);
+
+ {Now checks CRC}
+ Stream.Read(CRCCheck, 4);
+ {$IFDEF CheckCRC}
+ CRCFile := CRCFile xor $ffffffff;
+ CRCCheck := ByteSwap(CRCCheck);
+ Result := CRCCheck = CRCFile;
+
+ {Handle CRC error}
+ if not Result then
+ begin
+ {In case it coult not load chunk}
+ Owner.RaiseError(EPngInvalidCRC, EPngInvalidCRCText);
+ exit;
+ end;
+ {$ELSE}Result := TRUE; {$ENDIF}
+end;
+
+const
+ IDATHeader: Array[0..3] of char = ('I', 'D', 'A', 'T');
+ BUFFER = 5;
+
+{Saves the IDAT chunk to a stream}
+function TChunkIDAT.SaveToStream(Stream: TStream): Boolean;
+var
+ ZLIBStream : TZStreamRec2;
+begin
+ {Get pointer to the header chunk}
+ Header := Owner.Chunks.Item[0] as TChunkIHDR;
+ {Copy image width and height}
+ ImageWidth := Header.Width;
+ ImageHeight := Header.Height;
+ Owner.GetPixelInfo(Row_Bytes, Offset); {Obtain line information}
+
+ {Allocate memory}
+ GetMem(Encode_Buffer[BUFFER], Row_Bytes);
+ ZeroMemory(Encode_Buffer[BUFFER], Row_Bytes);
+ {Allocate buffers for the filters selected}
+ {Filter none will always be calculated to the other filters to work}
+ GetMem(Encode_Buffer[FILTER_NONE], Row_Bytes);
+ ZeroMemory(Encode_Buffer[FILTER_NONE], Row_Bytes);
+ if pfSub in Owner.Filters then
+ GetMem(Encode_Buffer[FILTER_SUB], Row_Bytes);
+ if pfUp in Owner.Filters then
+ GetMem(Encode_Buffer[FILTER_UP], Row_Bytes);
+ if pfAverage in Owner.Filters then
+ GetMem(Encode_Buffer[FILTER_AVERAGE], Row_Bytes);
+ if pfPaeth in Owner.Filters then
+ GetMem(Encode_Buffer[FILTER_PAETH], Row_Bytes);
+
+ {Initialize ZLIB}
+ ZLIBStream := ZLIBInitDeflate(Stream, Owner.fCompressionLevel,
+ Owner.MaxIdatSize);
+ {Write data depending on the interlace method}
+ case Owner.InterlaceMethod of
+ imNone: EncodeNonInterlaced(stream, ZLIBStream);
+ imAdam7: EncodeInterlacedAdam7(stream, ZLIBStream);
+ end;
+ {Terminates ZLIB}
+ ZLIBTerminateDeflate(ZLIBStream);
+
+ {Release allocated memory}
+ FreeMem(Encode_Buffer[BUFFER], Row_Bytes);
+ FreeMem(Encode_Buffer[FILTER_NONE], Row_Bytes);
+ if pfSub in Owner.Filters then
+ FreeMem(Encode_Buffer[FILTER_SUB], Row_Bytes);
+ if pfUp in Owner.Filters then
+ FreeMem(Encode_Buffer[FILTER_UP], Row_Bytes);
+ if pfAverage in Owner.Filters then
+ FreeMem(Encode_Buffer[FILTER_AVERAGE], Row_Bytes);
+ if pfPaeth in Owner.Filters then
+ FreeMem(Encode_Buffer[FILTER_PAETH], Row_Bytes);
+
+ {Everything went ok}
+ Result := True;
+end;
+
+{Writes the IDAT using the settings}
+procedure WriteIDAT(Stream: TStream; Data: Pointer; const Length: Cardinal);
+var
+ ChunkLen, CRC: Cardinal;
+begin
+ {Writes IDAT header}
+ ChunkLen := ByteSwap(Length);
+ Stream.Write(ChunkLen, 4); {Chunk length}
+ Stream.Write(IDATHeader[0], 4); {Idat header}
+ CRC := update_crc($ffffffff, @IDATHeader[0], 4); {Crc part for header}
+
+ {Writes IDAT data and calculates CRC for data}
+ Stream.Write(Data^, Length);
+ CRC := Byteswap(update_crc(CRC, Data, Length) xor $ffffffff);
+ {Writes final CRC}
+ Stream.Write(CRC, 4);
+end;
+
+{Compress and writes IDAT chunk data}
+procedure TChunkIDAT.IDATZlibWrite(var ZLIBStream: TZStreamRec2;
+ Buffer: Pointer; const Length: Cardinal);
+begin
+ with ZLIBStream, ZLIBStream.ZLIB do
+ begin
+ {Set data to be compressed}
+ next_in := Buffer;
+ avail_in := Length;
+
+ {Compress all the data avaliable to compress}
+ while avail_in > 0 do
+ begin
+ deflate(ZLIB, Z_NO_FLUSH);
+
+ {The whole buffer was used, save data to stream and restore buffer}
+ if avail_out = 0 then
+ begin
+ {Writes this IDAT chunk}
+ WriteIDAT(fStream, Data, ZLIBAllocate);
+
+ {Restore buffer}
+ next_out := Data;
+ avail_out := ZLIBAllocate;
+ end {if avail_out = 0};
+
+ end {while avail_in};
+
+ end {with ZLIBStream, ZLIBStream.ZLIB}
+end;
+
+{Finishes compressing data to write IDAT chunk}
+procedure TChunkIDAT.FinishIDATZlib(var ZLIBStream: TZStreamRec2);
+begin
+ with ZLIBStream, ZLIBStream.ZLIB do
+ begin
+ {Set data to be compressed}
+ next_in := nil;
+ avail_in := 0;
+
+ while deflate(ZLIB,Z_FINISH) <> Z_STREAM_END do
+ begin
+ {Writes this IDAT chunk}
+ WriteIDAT(fStream, Data, ZLIBAllocate - avail_out);
+ {Re-update buffer}
+ next_out := Data;
+ avail_out := ZLIBAllocate;
+ end;
+
+ if avail_out < ZLIBAllocate then
+ {Writes final IDAT}
+ WriteIDAT(fStream, Data, ZLIBAllocate - avail_out);
+
+ end {with ZLIBStream, ZLIBStream.ZLIB};
+end;
+
+{Copy memory to encode RGB image with 1 byte for each color sample}
+procedure TChunkIDAT.EncodeNonInterlacedRGB8(Src, Dest, Trans: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ {Copy pixel values}
+ Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest);
+ {Move to next pixel}
+ inc(Src, 3);
+ end {for I}
+end;
+
+{Copy memory to encode RGB images with 16 bits for each color sample}
+procedure TChunkIDAT.EncodeNonInterlacedRGB16(Src, Dest, Trans: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ //Now we copy from 1 byte for each sample stored to a 2 bytes (or 1 word)
+ //for sample
+ {Copy pixel values}
+ pWORD(Dest)^ := fOwner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest, 2);
+ pWORD(Dest)^ := fOwner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest, 2);
+ pWORD(Dest)^ := fOwner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest, 2);
+ {Move to next pixel}
+ inc(Src, 3);
+ end {for I}
+
+end;
+
+{Copy memory to encode types using palettes (1, 4 or 8 bits per pixel)}
+procedure TChunkIDAT.EncodeNonInterlacedPalette148(Src, Dest, Trans: pChar);
+begin
+ {It's simple as copying the data}
+ CopyMemory(Dest, Src, Row_Bytes);
+end;
+
+{Copy memory to encode grayscale images with 2 bytes for each sample}
+procedure TChunkIDAT.EncodeNonInterlacedGrayscale16(Src, Dest, Trans: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ //Now we copy from 1 byte for each sample stored to a 2 bytes (or 1 word)
+ //for sample
+ pWORD(Dest)^ := pByte(Longint(Src))^; inc(Dest, 2);
+ {Move to next pixel}
+ inc(Src);
+ end {for I}
+end;
+
+{Encode images using RGB followed by an alpha value using 1 byte for each}
+procedure TChunkIDAT.EncodeNonInterlacedRGBAlpha8(Src, Dest, Trans: pChar);
+var
+ i: Integer;
+begin
+ {Copy the data to the destination, including data from Trans pointer}
+ FOR i := 1 TO ImageWidth do
+ begin
+ Byte(Dest^) := Owner.InverseGamma[PByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := Owner.InverseGamma[PByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := Owner.InverseGamma[PByte(Longint(Src) )^]; inc(Dest);
+ Dest^ := Trans^; inc(Dest);
+ inc(Src, 3); inc(Trans);
+ end {for i};
+end;
+
+{Encode images using RGB followed by an alpha value using 2 byte for each}
+procedure TChunkIDAT.EncodeNonInterlacedRGBAlpha16(Src, Dest, Trans: pChar);
+var
+ i: Integer;
+begin
+ {Copy the data to the destination, including data from Trans pointer}
+ FOR i := 1 TO ImageWidth do
+ begin
+ pWord(Dest)^ := Owner.InverseGamma[PByte(Longint(Src) + 2)^]; inc(Dest, 2);
+ pWord(Dest)^ := Owner.InverseGamma[PByte(Longint(Src) + 1)^]; inc(Dest, 2);
+ pWord(Dest)^ := Owner.InverseGamma[PByte(Longint(Src) )^]; inc(Dest, 2);
+ pWord(Dest)^ := PByte(Longint(Trans) )^; inc(Dest, 2);
+ inc(Src, 3); inc(Trans);
+ end {for i};
+end;
+
+{Encode grayscale images followed by an alpha value using 1 byte for each}
+procedure TChunkIDAT.EncodeNonInterlacedGrayscaleAlpha8(
+ Src, Dest, Trans: pChar);
+var
+ i: Integer;
+begin
+ {Copy the data to the destination, including data from Trans pointer}
+ FOR i := 1 TO ImageWidth do
+ begin
+ Dest^ := Src^; inc(Dest);
+ Dest^ := Trans^; inc(Dest);
+ inc(Src); inc(Trans);
+ end {for i};
+end;
+
+{Encode grayscale images followed by an alpha value using 2 byte for each}
+procedure TChunkIDAT.EncodeNonInterlacedGrayscaleAlpha16(
+ Src, Dest, Trans: pChar);
+var
+ i: Integer;
+begin
+ {Copy the data to the destination, including data from Trans pointer}
+ FOR i := 1 TO ImageWidth do
+ begin
+ pWord(Dest)^ := pByte(Src)^; inc(Dest, 2);
+ pWord(Dest)^ := pByte(Trans)^; inc(Dest, 2);
+ inc(Src); inc(Trans);
+ end {for i};
+end;
+
+{Encode non interlaced images}
+procedure TChunkIDAT.EncodeNonInterlaced(Stream: TStream;
+ var ZLIBStream: TZStreamRec2);
+var
+ {Current line}
+ j: Cardinal;
+ {Pointers to image data}
+ Data, Trans: PChar;
+ {Filter used for this line}
+ Filter: Byte;
+ {Method which will copy the data into the buffer}
+ CopyProc: procedure(Src, Dest, Trans: pChar) of object;
+begin
+ CopyProc := nil; {Initialize to avoid warnings}
+ {Defines the method to copy the data to the buffer depending on}
+ {the image parameters}
+ case Header.ColorType of
+ {R, G, B values}
+ COLOR_RGB:
+ case Header.BitDepth of
+ 8: CopyProc := EncodeNonInterlacedRGB8;
+ 16: CopyProc := EncodeNonInterlacedRGB16;
+ end;
+ {Palette and grayscale values}
+ COLOR_GRAYSCALE, COLOR_PALETTE:
+ case Header.BitDepth of
+ 1, 4, 8: CopyProc := EncodeNonInterlacedPalette148;
+ 16: CopyProc := EncodeNonInterlacedGrayscale16;
+ end;
+ {RGB with a following alpha value}
+ COLOR_RGBALPHA:
+ case Header.BitDepth of
+ 8: CopyProc := EncodeNonInterlacedRGBAlpha8;
+ 16: CopyProc := EncodeNonInterlacedRGBAlpha16;
+ end;
+ {Grayscale images followed by an alpha}
+ COLOR_GRAYSCALEALPHA:
+ case Header.BitDepth of
+ 8: CopyProc := EncodeNonInterlacedGrayscaleAlpha8;
+ 16: CopyProc := EncodeNonInterlacedGrayscaleAlpha16;
+ end;
+ end {case Header.ColorType};
+
+ {Get the image data pointer}
+ Longint(Data) := Longint(Header.ImageData) +
+ Header.BytesPerRow * (ImageHeight - 1);
+ Trans := Header.ImageAlpha;
+
+ {Writes each line}
+ FOR j := 0 to ImageHeight - 1 do
+ begin
+ {Copy data into buffer}
+ CopyProc(Data, @Encode_Buffer[BUFFER][0], Trans);
+ {Filter data}
+ Filter := FilterToEncode;
+
+ {Compress data}
+ IDATZlibWrite(ZLIBStream, @Filter, 1);
+ IDATZlibWrite(ZLIBStream, @Encode_Buffer[Filter][0], Row_Bytes);
+
+ {Adjust pointers to the actual image data}
+ dec(Data, Header.BytesPerRow);
+ inc(Trans, ImageWidth);
+ end;
+
+ {Compress and finishes copying the remaining data}
+ FinishIDATZlib(ZLIBStream);
+end;
+
+{Copy memory to encode interlaced images using RGB value with 1 byte for}
+{each color sample}
+procedure TChunkIDAT.EncodeInterlacedRGB8(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col * 3);
+ repeat
+ {Copy this row}
+ Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass] * 3);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy memory to encode interlaced RGB images with 2 bytes each color sample}
+procedure TChunkIDAT.EncodeInterlacedRGB16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col * 3);
+ repeat
+ {Copy this row}
+ pWord(Dest)^ := Owner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest, 2);
+ pWord(Dest)^ := Owner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest, 2);
+ pWord(Dest)^ := Owner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest, 2);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass] * 3);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy memory to encode interlaced images using palettes using bit depths}
+{1, 4, 8 (each pixel in the image)}
+procedure TChunkIDAT.EncodeInterlacedPalette148(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+const
+ BitTable: Array[1..8] of Integer = ($1, $3, 0, $F, 0, 0, 0, $FF);
+ StartBit: Array[1..8] of Integer = (7 , 0 , 0, 4, 0, 0, 0, 0);
+var
+ CurBit, Col: Integer;
+ Src2: PChar;
+begin
+ {Clean the line}
+ fillchar(Dest^, Row_Bytes, #0);
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ with Header.BitmapInfo.bmiHeader do
+ repeat
+ {Copy data}
+ CurBit := StartBit[biBitCount];
+ repeat
+ {Adjust pointer to pixel byte bounds}
+ Src2 := pChar(Longint(Src) + (biBitCount * Col) div 8);
+ {Copy data}
+ Byte(Dest^) := Byte(Dest^) or
+ (((Byte(Src2^) shr (StartBit[Header.BitDepth] - (biBitCount * Col)
+ mod 8))) and (BitTable[biBitCount])) shl CurBit;
+
+ {Move to next column}
+ inc(Col, ColumnIncrement[Pass]);
+ {Will read next bits}
+ dec(CurBit, biBitCount);
+ until CurBit < 0;
+
+ {Move to next byte in source}
+ inc(Dest);
+ until Col >= ImageWidth;
+end;
+
+{Copy to encode interlaced grayscale images using 16 bits for each sample}
+procedure TChunkIDAT.EncodeInterlacedGrayscale16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col);
+ repeat
+ {Copy this row}
+ pWord(Dest)^ := Byte(Src^); inc(Dest, 2);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy to encode interlaced rgb images followed by an alpha value, all using}
+{one byte for each sample}
+procedure TChunkIDAT.EncodeInterlacedRGBAlpha8(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col * 3);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this row}
+ Byte(Dest^) := Owner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := Owner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := Owner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest);
+ Dest^ := Trans^; inc(Dest);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass] * 3);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy to encode interlaced rgb images followed by an alpha value, all using}
+{two byte for each sample}
+procedure TChunkIDAT.EncodeInterlacedRGBAlpha16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col * 3);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this row}
+ pWord(Dest)^ := pByte(Longint(Src) + 2)^; inc(Dest, 2);
+ pWord(Dest)^ := pByte(Longint(Src) + 1)^; inc(Dest, 2);
+ pWord(Dest)^ := pByte(Longint(Src) )^; inc(Dest, 2);
+ pWord(Dest)^ := pByte(Trans)^; inc(Dest, 2);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass] * 3);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy to encode grayscale interlaced images followed by an alpha value, all}
+{using 1 byte for each sample}
+procedure TChunkIDAT.EncodeInterlacedGrayscaleAlpha8(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this row}
+ Dest^ := Src^; inc(Dest);
+ Dest^ := Trans^; inc(Dest);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass]);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy to encode grayscale interlaced images followed by an alpha value, all}
+{using 2 bytes for each sample}
+procedure TChunkIDAT.EncodeInterlacedGrayscaleAlpha16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this row}
+ pWord(Dest)^ := pByte(Src)^; inc(Dest, 2);
+ pWord(Dest)^ := pByte(Trans)^; inc(Dest, 2);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass]);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Encode interlaced images}
+procedure TChunkIDAT.EncodeInterlacedAdam7(Stream: TStream;
+ var ZLIBStream: TZStreamRec2);
+var
+ CurrentPass, Filter: Byte;
+ PixelsThisRow: Integer;
+ CurrentRow : Integer;
+ Trans, Data: pChar;
+ CopyProc: procedure(const Pass: Byte;
+ Src, Dest, Trans: pChar) of object;
+begin
+ CopyProc := nil; {Initialize to avoid warnings}
+ {Defines the method to copy the data to the buffer depending on}
+ {the image parameters}
+ case Header.ColorType of
+ {R, G, B values}
+ COLOR_RGB:
+ case Header.BitDepth of
+ 8: CopyProc := EncodeInterlacedRGB8;
+ 16: CopyProc := EncodeInterlacedRGB16;
+ end;
+ {Grayscale and palette}
+ COLOR_PALETTE, COLOR_GRAYSCALE:
+ case Header.BitDepth of
+ 1, 4, 8: CopyProc := EncodeInterlacedPalette148;
+ 16: CopyProc := EncodeInterlacedGrayscale16;
+ end;
+ {RGB followed by alpha}
+ COLOR_RGBALPHA:
+ case Header.BitDepth of
+ 8: CopyProc := EncodeInterlacedRGBAlpha8;
+ 16: CopyProc := EncodeInterlacedRGBAlpha16;
+ end;
+ COLOR_GRAYSCALEALPHA:
+ {Grayscale followed by alpha}
+ case Header.BitDepth of
+ 8: CopyProc := EncodeInterlacedGrayscaleAlpha8;
+ 16: CopyProc := EncodeInterlacedGrayscaleAlpha16;
+ end;
+ end {case Header.ColorType};
+
+ {Compress the image using the seven passes for ADAM 7}
+ FOR CurrentPass := 0 TO 6 DO
+ begin
+ {Calculates the number of pixels and bytes for this pass row}
+ PixelsThisRow := (ImageWidth - ColumnStart[CurrentPass] +
+ ColumnIncrement[CurrentPass] - 1) div ColumnIncrement[CurrentPass];
+ Row_Bytes := BytesForPixels(PixelsThisRow, Header.ColorType,
+ Header.BitDepth);
+ ZeroMemory(Encode_Buffer[FILTER_NONE], Row_Bytes);
+
+ {Get current row index}
+ CurrentRow := RowStart[CurrentPass];
+ {Get a pointer to the current row image data}
+ Data := pointer(Longint(Header.ImageData) + Header.BytesPerRow * (ImageHeight - 1 - CurrentRow));
+ Trans := pointer(Longint(Header.ImageAlpha) + ImageWidth * CurrentRow);
+
+ {Process all the image rows}
+ if Row_Bytes > 0 then
+ while CurrentRow < ImageHeight do
+ begin
+ {Copy data into buffer}
+ CopyProc(CurrentPass, Data, @Encode_Buffer[BUFFER][0], Trans);
+ {Filter data}
+ Filter := FilterToEncode;
+
+ {Compress data}
+ IDATZlibWrite(ZLIBStream, @Filter, 1);
+ IDATZlibWrite(ZLIBStream, @Encode_Buffer[Filter][0], Row_Bytes);
+
+ {Move to the next row}
+ inc(CurrentRow, RowIncrement[CurrentPass]);
+ {Move pointer to the next line}
+ dec(Data, RowIncrement[CurrentPass] * Header.BytesPerRow);
+ inc(Trans, RowIncrement[CurrentPass] * ImageWidth);
+ end {while CurrentRow < ImageHeight}
+
+ end {CurrentPass};
+
+ {Compress and finishes copying the remaining data}
+ FinishIDATZlib(ZLIBStream);
+end;
+
+{Filters the row to be encoded and returns the best filter}
+function TChunkIDAT.FilterToEncode: Byte;
+var
+ Run, LongestRun, ii, jj: Cardinal;
+ Last, Above, LastAbove: Byte;
+begin
+ {Selecting more filters using the Filters property from TPngObject}
+ {increases the chances to the file be much smaller, but decreases}
+ {the performace}
+
+ {This method will creates the same line data using the different}
+ {filter methods and select the best}
+
+ {Sub-filter}
+ if pfSub in Owner.Filters then
+ for ii := 0 to Row_Bytes - 1 do
+ begin
+ {There is no previous pixel when it's on the first pixel, so}
+ {set last as zero when in the first}
+ if (ii >= Offset) then
+ last := Encode_Buffer[BUFFER]^[ii - Offset]
+ else
+ last := 0;
+ Encode_Buffer[FILTER_SUB]^[ii] := Encode_Buffer[BUFFER]^[ii] - last;
+ end;
+
+ {Up filter}
+ if pfUp in Owner.Filters then
+ for ii := 0 to Row_Bytes - 1 do
+ Encode_Buffer[FILTER_UP]^[ii] := Encode_Buffer[BUFFER]^[ii] -
+ Encode_Buffer[FILTER_NONE]^[ii];
+
+ {Average filter}
+ if pfAverage in Owner.Filters then
+ for ii := 0 to Row_Bytes - 1 do
+ begin
+ {Get the previous pixel, if the current pixel is the first, the}
+ {previous is considered to be 0}
+ if (ii >= Offset) then
+ last := Encode_Buffer[BUFFER]^[ii - Offset]
+ else
+ last := 0;
+ {Get the pixel above}
+ above := Encode_Buffer[FILTER_NONE]^[ii];
+
+ {Calculates formula to the average pixel}
+ Encode_Buffer[FILTER_AVERAGE]^[ii] := Encode_Buffer[BUFFER]^[ii] -
+ (above + last) div 2 ;
+ end;
+
+ {Paeth filter (the slower)}
+ if pfPaeth in Owner.Filters then
+ begin
+ {Initialize}
+ last := 0;
+ lastabove := 0;
+ for ii := 0 to Row_Bytes - 1 do
+ begin
+ {In case this pixel is not the first in the line obtains the}
+ {previous one and the one above the previous}
+ if (ii >= Offset) then
+ begin
+ last := Encode_Buffer[BUFFER]^[ii - Offset];
+ lastabove := Encode_Buffer[FILTER_NONE]^[ii - Offset];
+ end;
+ {Obtains the pixel above}
+ above := Encode_Buffer[FILTER_NONE]^[ii];
+ {Calculate paeth filter for this byte}
+ Encode_Buffer[FILTER_PAETH]^[ii] := Encode_Buffer[BUFFER]^[ii] -
+ PaethPredictor(last, above, lastabove);
+ end;
+ end;
+
+ {Now calculates the same line using no filter, which is necessary}
+ {in order to have data to the filters when the next line comes}
+ CopyMemory(@Encode_Buffer[FILTER_NONE]^[0],
+ @Encode_Buffer[BUFFER]^[0], Row_Bytes);
+
+ {If only filter none is selected in the filter list, we don't need}
+ {to proceed and further}
+ if (Owner.Filters = [pfNone]) or (Owner.Filters = []) then
+ begin
+ Result := FILTER_NONE;
+ exit;
+ end {if (Owner.Filters = [pfNone...};
+
+ {Check which filter is the best by checking which has the larger}
+ {sequence of the same byte, since they are best compressed}
+ LongestRun := 0; Result := FILTER_NONE;
+ for ii := FILTER_NONE TO FILTER_PAETH do
+ {Check if this filter was selected}
+ if TFilter(ii) in Owner.Filters then
+ begin
+ Run := 0;
+ {Check if it's the only filter}
+ if Owner.Filters = [TFilter(ii)] then
+ begin
+ Result := ii;
+ exit;
+ end;
+
+ {Check using a sequence of four bytes}
+ for jj := 2 to Row_Bytes - 1 do
+ if (Encode_Buffer[ii]^[jj] = Encode_Buffer [ii]^[jj-1]) or
+ (Encode_Buffer[ii]^[jj] = Encode_Buffer [ii]^[jj-2]) then
+ inc(Run); {Count the number of sequences}
+
+ {Check if this one is the best so far}
+ if (Run > LongestRun) then
+ begin
+ Result := ii;
+ LongestRun := Run;
+ end {if (Run > LongestRun)};
+
+ end {if TFilter(ii) in Owner.Filters};
+end;
+
+{TChunkPLTE implementation}
+
+{Returns an item in the palette}
+function TChunkPLTE.GetPaletteItem(Index: Byte): TRGBQuad;
+begin
+ {Test if item is valid, if not raise error}
+ if Index > Count - 1 then
+ Owner.RaiseError(EPNGError, EPNGUnknownPalEntryText)
+ else
+ {Returns the item}
+ Result := Header.BitmapInfo.bmiColors[Index];
+end;
+
+{Loads the palette chunk from a stream}
+function TChunkPLTE.LoadFromStream(Stream: TStream;
+ const ChunkName: TChunkName; Size: Integer): Boolean;
+type
+ pPalEntry = ^PalEntry;
+ PalEntry = record r, g, b: Byte end;
+var
+ j : Integer; {For the FOR}
+ PalColor : pPalEntry;
+begin
+ {Let ancestor load data and check CRC}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+ if not Result then exit;
+
+ {This chunk must be divisible by 3 in order to be valid}
+ if (Size mod 3 <> 0) or (Size div 3 > 256) then
+ begin
+ {Raise error}
+ Result := FALSE;
+ Owner.RaiseError(EPNGInvalidPalette, EPNGInvalidPaletteText);
+ exit;
+ end {if Size mod 3 <> 0};
+
+ {Fill array with the palette entries}
+ fCount := Size div 3;
+ PalColor := Data;
+ FOR j := 0 TO fCount - 1 DO
+ with Header.BitmapInfo.bmiColors[j] do
+ begin
+ rgbRed := Owner.GammaTable[PalColor.r];
+ rgbGreen := Owner.GammaTable[PalColor.g];
+ rgbBlue := Owner.GammaTable[PalColor.b];
+ rgbReserved := 0;
+ inc(PalColor); {Move to next palette entry}
+ end;
+end;
+
+{Saves the PLTE chunk to a stream}
+function TChunkPLTE.SaveToStream(Stream: TStream): Boolean;
+var
+ J: Integer;
+ DataPtr: pByte;
+begin
+ {Adjust size to hold all the palette items}
+ ResizeData(fCount * 3);
+ {Copy pointer to data}
+ DataPtr := fData;
+
+ {Copy palette items}
+ with Header do
+ FOR j := 0 TO fCount - 1 DO
+ with BitmapInfo.bmiColors[j] do
+ begin
+ DataPtr^ := Owner.InverseGamma[rgbRed] ; inc(DataPtr);
+ DataPtr^ := Owner.InverseGamma[rgbGreen]; inc(DataPtr);
+ DataPtr^ := Owner.InverseGamma[rgbBlue] ; inc(DataPtr);
+ end {with BitmapInfo};
+
+ {Let ancestor do the rest of the work}
+ Result := inherited SaveToStream(Stream);
+end;
+
+{Assigns from another PLTE chunk}
+procedure TChunkPLTE.Assign(Source: TChunk);
+begin
+ {Copy the number of palette items}
+ if Source is TChunkPLTE then
+ fCount := TChunkPLTE(Source).fCount
+ else
+ Owner.RaiseError(EPNGError, EPNGCannotAssignChunkText);
+end;
+
+{TChunkgAMA implementation}
+
+{Assigns from another chunk}
+procedure TChunkgAMA.Assign(Source: TChunk);
+begin
+ {Copy the gamma value}
+ if Source is TChunkgAMA then
+ Gamma := TChunkgAMA(Source).Gamma
+ else
+ Owner.RaiseError(EPNGError, EPNGCannotAssignChunkText);
+end;
+
+{Gamma chunk being created}
+constructor TChunkgAMA.Create(Owner: TPngObject);
+begin
+ {Call ancestor}
+ inherited Create(Owner);
+ Gamma := 1; {Initial value}
+end;
+
+{Returns gamma value}
+function TChunkgAMA.GetValue: Cardinal;
+begin
+ {Make sure that the size is four bytes}
+ if DataSize <> 4 then
+ begin
+ {Adjust size and returns 1}
+ ResizeData(4);
+ Result := 1;
+ end
+ {If it's right, read the value}
+ else Result := Cardinal(ByteSwap(pCardinal(Data)^))
+end;
+
+function Power(Base, Exponent: Extended): Extended;
+begin
+ if Exponent = 0.0 then
+ Result := 1.0 {Math rule}
+ else if (Base = 0) or (Exponent = 0) then Result := 0
+ else
+ Result := Exp(Exponent * Ln(Base));
+end;
+
+
+{Loading the chunk from a stream}
+function TChunkgAMA.LoadFromStream(Stream: TStream;
+ const ChunkName: TChunkName; Size: Integer): Boolean;
+var
+ i: Integer;
+ Value: Cardinal;
+begin
+ {Call ancestor and test if it went ok}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+ if not Result then exit;
+ Value := Gamma;
+ {Build gamma table and inverse table for saving}
+ if Value <> 0 then
+ with Owner do
+ FOR i := 0 TO 255 DO
+ begin
+ GammaTable[I] := Round(Power((I / 255), 1 /
+ (Value / 100000 * 2.2)) * 255);
+ InverseGamma[Round(Power((I / 255), 1 /
+ (Value / 100000 * 2.2)) * 255)] := I;
+ end
+end;
+
+{Sets the gamma value}
+procedure TChunkgAMA.SetValue(const Value: Cardinal);
+begin
+ {Make sure that the size is four bytes}
+ if DataSize <> 4 then ResizeData(4);
+ {If it's right, set the value}
+ pCardinal(Data)^ := ByteSwap(Value);
+end;
+
+{TPngObject implementation}
+
+{Assigns from another object}
+procedure TPngObject.Assign(Source: TPersistent);
+begin
+ {Assigns contents from another TPNGObject}
+ if Source is TPNGObject then
+ AssignPNG(Source as TPNGObject)
+ {Copy contents from a TBitmap}
+ {$IFDEF UseDelphi}else if Source is TBitmap then
+ with Source as TBitmap do
+ AssignHandle(Handle, Transparent,
+ ColorToRGB(TransparentColor)){$ENDIF}
+ {Unknown source, let ancestor deal with it}
+ else
+ inherited;
+end;
+
+{Clear all the chunks in the list}
+procedure TPngObject.ClearChunks;
+var
+ i: Integer;
+begin
+ {Initialize gamma}
+ InitializeGamma();
+ {Free all the objects and memory (0 chunks Bug fixed by Noel Sharpe)}
+ for i := 0 TO Integer(Chunks.Count) - 1 do
+ TChunk(Chunks.Item[i]).Free;
+ Chunks.Count := 0;
+end;
+
+{Portable Network Graphics object being created}
+constructor TPngObject.Create;
+begin
+ {Let it be created}
+ inherited Create;
+
+ {Initial properties}
+ TempPalette := 0;
+ fFilters := [pfSub];
+ fCompressionLevel := 7;
+ fInterlaceMethod := imNone;
+ fMaxIdatSize := High(Word);
+ {Create chunklist object}
+ fChunkList := TPngList.Create(Self);
+end;
+
+{Portable Network Graphics object being destroyed}
+destructor TPngObject.Destroy;
+begin
+ {Free object list}
+ ClearChunks;
+ fChunkList.Free;
+ {Free the temporary palette}
+ if TempPalette <> 0 then DeleteObject(TempPalette);
+
+ {Call ancestor destroy}
+ inherited Destroy;
+end;
+
+{Returns linesize and byte offset for pixels}
+procedure TPngObject.GetPixelInfo(var LineSize, Offset: Cardinal);
+begin
+ {There must be an Header chunk to calculate size}
+ if HeaderPresent then
+ begin
+ {Calculate number of bytes for each line}
+ LineSize := BytesForPixels(Header.Width, Header.ColorType, Header.BitDepth);
+
+ {Calculates byte offset}
+ Case Header.ColorType of
+ {Grayscale}
+ COLOR_GRAYSCALE:
+ If Header.BitDepth = 16 Then
+ Offset := 2
+ Else
+ Offset := 1 ;
+ {It always smaller or equal one byte, so it occupes one byte}
+ COLOR_PALETTE:
+ offset := 1;
+ {It might be 3 or 6 bytes}
+ COLOR_RGB:
+ offset := 3 * Header.BitDepth Div 8;
+ {It might be 2 or 4 bytes}
+ COLOR_GRAYSCALEALPHA:
+ offset := 2 * Header.BitDepth Div 8;
+ {4 or 8 bytes}
+ COLOR_RGBALPHA:
+ offset := 4 * Header.BitDepth Div 8;
+ else
+ Offset := 0;
+ End ;
+
+ end
+ else
+ begin
+ {In case if there isn't any Header chunk}
+ Offset := 0;
+ LineSize := 0;
+ end;
+
+end;
+
+{Returns image height}
+function TPngObject.GetHeight: Integer;
+begin
+ {There must be a Header chunk to get the size, otherwise returns 0}
+ if HeaderPresent then
+ Result := TChunkIHDR(Chunks.Item[0]).Height
+ else Result := 0;
+end;
+
+{Returns image width}
+function TPngObject.GetWidth: Integer;
+begin
+ {There must be a Header chunk to get the size, otherwise returns 0}
+ if HeaderPresent then
+ Result := Header.Width
+ else Result := 0;
+end;
+
+{Returns if the image is empty}
+function TPngObject.GetEmpty: Boolean;
+begin
+ Result := (Chunks.Count = 0);
+end;
+
+{Raises an error}
+procedure TPngObject.RaiseError(ExceptionClass: ExceptClass; Text: String);
+begin
+ raise ExceptionClass.Create(Text);
+end;
+
+{Set the maximum size for IDAT chunk}
+procedure TPngObject.SetMaxIdatSize(const Value: Cardinal);
+begin
+ {Make sure the size is at least 65535}
+ if Value < High(Word) then
+ fMaxIdatSize := High(Word) else fMaxIdatSize := Value;
+end;
+
+{$IFNDEF UseDelphi}
+ {Creates a file stream reading from the filename in the parameter and load}
+ procedure TPngObject.LoadFromFile(const Filename: String);
+ var
+ FileStream: TFileStream;
+ begin
+ {Test if the file exists}
+ if not FileExists(Filename) then
+ begin
+ {In case it does not exists, raise error}
+ RaiseError(EPNGNotExists, EPNGNotExistsText);
+ exit;
+ end;
+
+ {Creates the file stream to read}
+ FileStream := TFileStream.Create(Filename, [fsmRead]);
+ LoadFromStream(FileStream); {Loads the data}
+ FileStream.Free; {Free file stream}
+ end;
+
+ {Saves the current png image to a file}
+ procedure TPngObject.SaveToFile(const Filename: String);
+ var
+ FileStream: TFileStream;
+ begin
+ {Creates the file stream to write}
+ FileStream := TFileStream.Create(Filename, [fsmWrite]);
+ SaveToStream(FileStream); {Saves the data}
+ FileStream.Free; {Free file stream}
+ end;
+
+{$ENDIF}
+
+{Returns pointer to the chunk TChunkIHDR which should be the first}
+function TPngObject.GetHeader: TChunkIHDR;
+begin
+ {If there is a TChunkIHDR returns it, otherwise returns nil}
+ if (Chunks.Count <> 0) and (Chunks.Item[0] is TChunkIHDR) then
+ Result := Chunks.Item[0] as TChunkIHDR
+ else
+ begin
+ {No header, throw error message}
+ RaiseError(EPNGHeaderNotPresent, EPNGHeaderNotPresentText);
+ Result := nil
+ end
+end;
+
+{Draws using partial transparency}
+procedure TPngObject.DrawPartialTrans(DC: HDC; Rect: TRect);
+type
+ {Access to pixels}
+ TPixelLine = Array[Word] of TRGBQuad;
+ pPixelLine = ^TPixelLine;
+const
+ {Structure used to create the bitmap}
+ BitmapInfoHeader: TBitmapInfoHeader =
+ (biSize: sizeof(TBitmapInfoHeader);
+ biWidth: 100;
+ biHeight: 100;
+ biPlanes: 1;
+ biBitCount: 32;
+ biCompression: BI_RGB;
+ biSizeImage: 0;
+ biXPelsPerMeter: 0;
+ biYPelsPerMeter: 0;
+ biClrUsed: 0;
+ biClrImportant: 0);
+var
+ {Buffer bitmap creation}
+ BitmapInfo : TBitmapInfo;
+ BufferDC : HDC;
+ BufferBits : Pointer;
+ OldBitmap,
+ BufferBitmap: HBitmap;
+
+ {Transparency/palette chunks}
+ TransparencyChunk: TChunktRNS;
+ PaletteChunk: TChunkPLTE;
+ TransValue, PaletteIndex: Byte;
+ CurBit: Integer;
+ Data: PByte;
+
+ {Buffer bitmap modification}
+ BytesPerRowDest,
+ BytesPerRowSrc,
+ BytesPerRowAlpha: Integer;
+ ImageSource,
+ AlphaSource : pByteArray;
+ ImageData : pPixelLine;
+ i, j : Integer;
+begin
+ {Prepare to create the bitmap}
+ Fillchar(BitmapInfo, sizeof(BitmapInfo), #0);
+ BitmapInfoHeader.biWidth := Header.Width;
+ BitmapInfoHeader.biHeight := -1 * Header.Height;
+ BitmapInfo.bmiHeader := BitmapInfoHeader;
+
+ {Create the bitmap which will receive the background, the applied}
+ {alpha blending and then will be painted on the background}
+ BufferDC := CreateCompatibleDC(0);
+ {In case BufferDC could not be created}
+ if (BufferDC = 0) then RaiseError(EPNGOutMemory, EPNGOutMemoryText);
+ BufferBitmap := CreateDIBSection(BufferDC, BitmapInfo, DIB_RGB_COLORS,
+ BufferBits, 0, 0);
+ {In case buffer bitmap could not be created}
+ if (BufferBitmap = 0) or (BufferBits = Nil) then
+ begin
+ if BufferBitmap <> 0 then DeleteObject(BufferBitmap);
+ DeleteDC(BufferDC);
+ RaiseError(EPNGOutMemory, EPNGOutMemoryText);
+ end;
+
+ {Selects new bitmap and release old bitmap}
+ OldBitmap := SelectObject(BufferDC, BufferBitmap);
+
+ {Draws the background on the buffer image}
+ StretchBlt(BufferDC, 0, 0, Header.Width, Header.height, DC, Rect.Left,
+ Rect.Top, Header.Width, Header.Height, SRCCOPY);
+
+ {Obtain number of bytes for each row}
+ BytesPerRowAlpha := Header.Width;
+ BytesPerRowDest := (((BitmapInfo.bmiHeader.biBitCount * Width) + 31)
+ and not 31) div 8; {Number of bytes for each image row in destination}
+ BytesPerRowSrc := (((Header.BitmapInfo.bmiHeader.biBitCount * Header.Width) +
+ 31) and not 31) div 8; {Number of bytes for each image row in source}
+
+ {Obtains image pointers}
+ ImageData := BufferBits;
+ AlphaSource := Header.ImageAlpha;
+ Longint(ImageSource) := Longint(Header.ImageData) +
+ Header.BytesPerRow * Longint(Header.Height - 1);
+
+ case Header.BitmapInfo.bmiHeader.biBitCount of
+ {R, G, B images}
+ 24:
+ FOR j := 1 TO Header.Height DO
+ begin
+ {Process all the pixels in this line}
+ FOR i := 0 TO Header.Width - 1 DO
+ with ImageData[i] do
+ begin
+ rgbRed := (255+ImageSource[2+i*3] * AlphaSource[i] + rgbRed * (255 -
+ AlphaSource[i])) shr 8;
+ rgbGreen := (255+ImageSource[1+i*3] * AlphaSource[i] + rgbGreen *
+ (255 - AlphaSource[i])) shr 8;
+ rgbBlue := (255+ImageSource[i*3] * AlphaSource[i] + rgbBlue *
+ (255 - AlphaSource[i])) shr 8;
+ end;
+
+ {Move pointers}
+ Longint(ImageData) := Longint(ImageData) + BytesPerRowDest;
+ Longint(ImageSource) := Longint(ImageSource) - BytesPerRowSrc;
+ Longint(AlphaSource) := Longint(AlphaSource) + BytesPerRowAlpha;
+ end;
+ {Palette images with 1 byte for each pixel}
+ 1,4,8: if Header.ColorType = COLOR_GRAYSCALEALPHA then
+ FOR j := 1 TO Header.Height DO
+ begin
+ {Process all the pixels in this line}
+ FOR i := 0 TO Header.Width - 1 DO
+ with ImageData[i], Header.BitmapInfo do begin
+ rgbRed := (255 + ImageSource[i] * AlphaSource[i] +
+ rgbRed * (255 - AlphaSource[i])) shr 8;
+ rgbGreen := (255 + ImageSource[i] * AlphaSource[i] +
+ rgbGreen * (255 - AlphaSource[i])) shr 8;
+ rgbBlue := (255 + ImageSource[i] * AlphaSource[i] +
+ rgbBlue * (255 - AlphaSource[i])) shr 8;
+ end;
+
+ {Move pointers}
+ Longint(ImageData) := Longint(ImageData) + BytesPerRowDest;
+ Longint(ImageSource) := Longint(ImageSource) - BytesPerRowSrc;
+ Longint(AlphaSource) := Longint(AlphaSource) + BytesPerRowAlpha;
+ end
+ else {Palette images}
+ begin
+ {Obtain pointer to the transparency chunk}
+ TransparencyChunk := TChunktRNS(Chunks.ItemFromClass(TChunktRNS));
+ PaletteChunk := TChunkPLTE(Chunks.ItemFromClass(TChunkPLTE));
+
+ FOR j := 1 TO Header.Height DO
+ begin
+ {Process all the pixels in this line}
+ i := 0; Data := @ImageSource[0];
+ repeat
+ CurBit := 0;
+
+ repeat
+ {Obtains the palette index}
+ case Header.BitDepth of
+ 1: PaletteIndex := (Data^ shr (7-(I Mod 8))) and 1;
+ 2,4: PaletteIndex := (Data^ shr ((1-(I Mod 2))*4)) and $0F;
+ else PaletteIndex := Data^;
+ end;
+
+ {Updates the image with the new pixel}
+ with ImageData[i] do
+ begin
+ TransValue := TransparencyChunk.PaletteValues[PaletteIndex];
+ rgbRed := (255 + PaletteChunk.Item[PaletteIndex].rgbRed *
+ TransValue + rgbRed * (255 - TransValue)) shr 8;
+ rgbGreen := (255 + PaletteChunk.Item[PaletteIndex].rgbGreen *
+ TransValue + rgbGreen * (255 - TransValue)) shr 8;
+ rgbBlue := (255 + PaletteChunk.Item[PaletteIndex].rgbBlue *
+ TransValue + rgbBlue * (255 - TransValue)) shr 8;
+ end;
+
+ {Move to next data}
+ inc(i); inc(CurBit, Header.BitmapInfo.bmiHeader.biBitCount);
+ until CurBit >= 8;
+ {Move to next source data}
+ inc(Data);
+ until i >= Integer(Header.Width);
+
+ {Move pointers}
+ Longint(ImageData) := Longint(ImageData) + BytesPerRowDest;
+ Longint(ImageSource) := Longint(ImageSource) - BytesPerRowSrc;
+ end
+ end {Palette images}
+ end {case Header.BitmapInfo.bmiHeader.biBitCount};
+
+ {Draws the new bitmap on the foreground}
+ StretchBlt(DC, Rect.Left, Rect.Top, Header.Width, Header.Height, BufferDC,
+ 0, 0, Header.Width, Header.Height, SRCCOPY);
+
+ {Free bitmap}
+ SelectObject(BufferDC, OldBitmap);
+ DeleteObject(BufferBitmap);
+ DeleteDC(BufferDC);
+end;
+
+{Draws the image into a canvas}
+procedure TPngObject.Draw(ACanvas: TCanvas; const Rect: TRect);
+var
+ Header: TChunkIHDR;
+begin
+ {Quit in case there is no header, otherwise obtain it}
+ if (Chunks.Count = 0) or not (Chunks.GetItem(0) is TChunkIHDR) then Exit;
+ Header := Chunks.GetItem(0) as TChunkIHDR;
+
+ {Copy the data to the canvas}
+ case Self.TransparencyMode of
+ {$IFDEF PartialTransparentDraw}
+ ptmPartial:
+ DrawPartialTrans(ACanvas{$IFDEF UseDelphi}.Handle{$ENDIF}, Rect);
+ {$ENDIF}
+ ptmBit: DrawTransparentBitmap(ACanvas{$IFDEF UseDelphi}.Handle{$ENDIF},
+ Header.ImageData, Header.BitmapInfo.bmiHeader,
+ pBitmapInfo(@Header.BitmapInfo), Rect,
+ {$IFDEF UseDelphi}ColorToRGB({$ENDIF}TransparentColor)
+ {$IFDEF UseDelphi}){$ENDIF}
+ else
+ StretchDiBits(ACanvas{$IFDEF UseDelphi}.Handle{$ENDIF}, Rect.Left,
+ Rect.Top, Rect.Right - Rect.Left, Rect.Bottom - Rect.Top, 0, 0,
+ Header.Width, Header.Height, Header.ImageData,
+ pBitmapInfo(@Header.BitmapInfo)^, DIB_RGB_COLORS, SRCCOPY)
+ end {case}
+end;
+
+{Characters for the header}
+const
+ PngHeader: Array[0..7] of Char = (#137, #80, #78, #71, #13, #10, #26, #10);
+
+{Loads the image from a stream of data}
+procedure TPngObject.LoadFromStream(Stream: TStream);
+var
+ Header : Array[0..7] of Char;
+ HasIDAT : Boolean;
+
+ {Chunks reading}
+ ChunkCount : Cardinal;
+ ChunkLength: Cardinal;
+ ChunkName : TChunkName;
+begin
+ {Initialize before start loading chunks}
+ ChunkCount := 0;
+ ClearChunks();
+ {Reads the header}
+ Stream.Read(Header[0], 8);
+
+ {Test if the header matches}
+ if Header <> PngHeader then
+ begin
+ RaiseError(EPNGInvalidFileHeader, EPNGInvalidFileHeaderText);
+ Exit;
+ end;
+
+
+ HasIDAT := FALSE;
+ Chunks.Count := 10;
+
+ {Load chunks}
+ repeat
+ inc(ChunkCount); {Increment number of chunks}
+ if Chunks.Count < ChunkCount then {Resize the chunks list if needed}
+ Chunks.Count := Chunks.Count + 10;
+
+ {Reads chunk length and invert since it is in network order}
+ {also checks the Read method return, if it returns 0, it}
+ {means that no bytes was readed, probably because it reached}
+ {the end of the file}
+ if Stream.Read(ChunkLength, 4) = 0 then
+ begin
+ {In case it found the end of the file here}
+ Chunks.Count := ChunkCount - 1;
+ RaiseError(EPNGUnexpectedEnd, EPNGUnexpectedEndText);
+ end;
+
+ ChunkLength := ByteSwap(ChunkLength);
+ {Reads chunk name}
+ Stream.Read(Chunkname, 4);
+
+ {Here we check if the first chunk is the Header which is necessary}
+ {to the file in order to be a valid Portable Network Graphics image}
+ if (ChunkCount = 1) and (ChunkName <> 'IHDR') then
+ begin
+ Chunks.Count := ChunkCount - 1;
+ RaiseError(EPNGIHDRNotFirst, EPNGIHDRNotFirstText);
+ exit;
+ end;
+
+ {Has a previous IDAT}
+ if (HasIDAT and (ChunkName = 'IDAT')) or (ChunkName = 'cHRM') then
+ begin
+ dec(ChunkCount);
+ Stream.Seek(ChunkLength + 4, soFromCurrent);
+ Continue;
+ end;
+ {Tell it has an IDAT chunk}
+ if ChunkName = 'IDAT' then HasIDAT := TRUE;
+
+ {Creates object for this chunk}
+ Chunks.SetItem(ChunkCount - 1, CreateClassChunk(Self, ChunkName));
+
+ {Check if the chunk is critical and unknown}
+ {$IFDEF ErrorOnUnknownCritical}
+ if (TChunk(Chunks.Item[ChunkCount - 1]).ClassType = TChunk) and
+ ((Byte(ChunkName[0]) AND $20) = 0) and (ChunkName <> '') then
+ begin
+ Chunks.Count := ChunkCount;
+ RaiseError(EPNGUnknownCriticalChunk, EPNGUnknownCriticalChunkText);
+ end;
+ {$ENDIF}
+
+ {Loads it}
+ try if not TChunk(Chunks.Item[ChunkCount - 1]).LoadFromStream(Stream,
+ ChunkName, ChunkLength) then break;
+ except
+ Chunks.Count := ChunkCount;
+ raise;
+ end;
+
+ {Terminates when it reaches the IEND chunk}
+ until (ChunkName = 'IEND');
+
+ {Resize the list to the appropriate size}
+ Chunks.Count := ChunkCount;
+
+ {Check if there is data}
+ if not HasIDAT then
+ RaiseError(EPNGNoImageData, EPNGNoImageDataText);
+end;
+
+{Changing height is not supported}
+procedure TPngObject.SetHeight(Value: Integer);
+begin
+ RaiseError(EPNGError, EPNGCannotChangeSizeText);
+end;
+
+{Changing width is not supported}
+procedure TPngObject.SetWidth(Value: Integer);
+begin
+ RaiseError(EPNGError, EPNGCannotChangeSizeText);
+end;
+
+{$IFDEF UseDelphi}
+{Saves to clipboard format (thanks to Antoine Pottern)}
+procedure TPNGObject.SaveToClipboardFormat(var AFormat: Word;
+ var AData: THandle; var APalette: HPalette);
+begin
+ with TBitmap.Create do
+ try
+ Width := Self.Width;
+ Height := Self.Height;
+ Self.Draw(Canvas, Rect(0, 0, Width, Height));
+ SaveToClipboardFormat(AFormat, AData, APalette);
+ finally
+ Free;
+ end {try}
+end;
+
+{Loads data from clipboard}
+procedure TPngObject.LoadFromClipboardFormat(AFormat: Word;
+ AData: THandle; APalette: HPalette);
+begin
+ with TBitmap.Create do
+ try
+ LoadFromClipboardFormat(AFormat, AData, APalette);
+ Self.AssignHandle(Handle, False, 0);
+ finally
+ Free;
+ end {try}
+end;
+
+{Returns if the image is transparent}
+function TPngObject.GetTransparent: Boolean;
+begin
+ Result := (TransparencyMode <> ptmNone);
+end;
+
+{$ENDIF}
+
+{Saving the PNG image to a stream of data}
+procedure TPngObject.SaveToStream(Stream: TStream);
+var
+ j: Integer;
+begin
+ {Reads the header}
+ Stream.Write(PNGHeader[0], 8);
+ {Write each chunk}
+ FOR j := 0 TO Chunks.Count - 1 DO
+ Chunks.Item[j].SaveToStream(Stream)
+end;
+
+{Prepares the Header chunk}
+procedure BuildHeader(Header: TChunkIHDR; Handle: HBitmap; Info: pBitmap;
+ HasPalette: Boolean);
+var
+ DC: HDC;
+begin
+ {Set width and height}
+ Header.Width := Info.bmWidth;
+ Header.Height := abs(Info.bmHeight);
+ {Set bit depth}
+ if Info.bmBitsPixel >= 16 then
+ Header.BitDepth := 8 else Header.BitDepth := Info.bmBitsPixel;
+ {Set color type}
+ if Info.bmBitsPixel >= 16 then
+ Header.ColorType := COLOR_RGB else Header.ColorType := COLOR_PALETTE;
+ {Set other info}
+ Header.CompressionMethod := 0; {deflate/inflate}
+ Header.InterlaceMethod := 0; {no interlace}
+
+ {Prepares bitmap headers to hold data}
+ Header.PrepareImageData();
+ {Copy image data}
+ DC := CreateCompatibleDC(0);
+ GetDIBits(DC, Handle, 0, Header.Height, Header.ImageData,
+ pBitmapInfo(@Header.BitmapInfo)^, DIB_RGB_COLORS);
+ DeleteDC(DC);
+end;
+
+{Loads the image from a resource}
+procedure TPngObject.LoadFromResourceName(Instance: HInst;
+ const Name: String);
+var
+ ResStream: TResourceStream;
+begin
+ {Creates an especial stream to load from the resource}
+ try ResStream := TResourceStream.Create(Instance, Name, RT_RCDATA);
+ except RaiseError(EPNGCouldNotLoadResource, EPNGCouldNotLoadResourceText);
+ exit; end;
+
+ {Loads the png image from the resource}
+ try
+ LoadFromStream(ResStream);
+ finally
+ ResStream.Free;
+ end;
+end;
+
+{Loads the png from a resource ID}
+procedure TPngObject.LoadFromResourceID(Instance: HInst; ResID: Integer);
+begin
+ LoadFromResourceName(Instance, String(ResID));
+end;
+
+{Assigns this tpngobject to another object}
+procedure TPngObject.AssignTo(Dest: TPersistent);
+{$IFDEF UseDelphi}
+var
+ DeskDC: HDC;
+ TRNS: TChunkTRNS;
+{$ENDIF}
+begin
+ {If the destination is also a TPNGObject make it assign}
+ {this one}
+ if Dest is TPNGObject then
+ TPNGObject(Dest).AssignPNG(Self)
+ {$IFDEF UseDelphi}
+ {In case the destination is a bitmap}
+ else if (Dest is TBitmap) and HeaderPresent then
+ begin
+ {Device context}
+ DeskDC := GetDC(0);
+ {Copy the data}
+ TBitmap(Dest).Handle := CreateDIBitmap(DeskDC,
+ Header.BitmapInfo.bmiHeader, CBM_INIT, Header.ImageData,
+ pBitmapInfo(@Header.BitmapInfo)^, DIB_RGB_COLORS);
+ ReleaseDC(0, DeskDC);
+ {Tests for the best pixelformat}
+ case Header.BitmapInfo.bmiHeader.biBitCount of
+ 1: TBitmap(Dest).PixelFormat := pf1Bit;
+ 4: TBitmap(Dest).PixelFormat := pf4Bit;
+ 8: TBitmap(Dest).PixelFormat := pf8Bit;
+ 24: TBitmap(Dest).PixelFormat := pf24Bit;
+ 32: TBitmap(Dest).PixelFormat := pf32Bit;
+ end {case Header.BitmapInfo.bmiHeader.biBitCount};
+
+ {Copy transparency mode}
+ if (TransparencyMode = ptmBit) then
+ begin
+ TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS;
+ TBitmap(Dest).TransparentColor := TRNS.TransparentColor;
+ TBitmap(Dest).Transparent := True
+ end {if (TransparencyMode = ptmBit)}
+
+ end
+ else
+ {Unknown destination kind, }
+ inherited AssignTo(Dest);
+ {$ENDIF}
+end;
+
+{Assigns from a bitmap object}
+procedure TPngObject.AssignHandle(Handle: HBitmap; Transparent: Boolean;
+ TransparentColor: ColorRef);
+var
+ BitmapInfo: Windows.TBitmap;
+ HasPalette: Boolean;
+
+ {Chunks}
+ Header: TChunkIHDR;
+ PLTE: TChunkPLTE;
+ IDAT: TChunkIDAT;
+ IEND: TChunkIEND;
+ TRNS: TChunkTRNS;
+begin
+ {Obtain bitmap info}
+ GetObject(Handle, SizeOf(BitmapInfo), @BitmapInfo);
+
+ {Only bit depths 1, 4 and 8 needs a palette}
+ HasPalette := (BitmapInfo.bmBitsPixel < 16);
+
+ {Clear old chunks and prepare}
+ ClearChunks();
+
+ {Create the chunks}
+ Header := TChunkIHDR.Create(Self);
+ if HasPalette then PLTE := TChunkPLTE.Create(Self) else PLTE := nil;
+ if Transparent then TRNS := TChunkTRNS.Create(Self) else TRNS := nil;
+ IDAT := TChunkIDAT.Create(Self);
+ IEND := TChunkIEND.Create(Self);
+
+ {Add chunks}
+ TPNGPointerList(Chunks).Add(Header);
+ if HasPalette then TPNGPointerList(Chunks).Add(PLTE);
+ if Transparent then TPNGPointerList(Chunks).Add(TRNS);
+ TPNGPointerList(Chunks).Add(IDAT);
+ TPNGPointerList(Chunks).Add(IEND);
+
+ {This method will fill the Header chunk with bitmap information}
+ {and copy the image data}
+ BuildHeader(Header, Handle, @BitmapInfo, HasPalette);
+ {In case there is a image data, set the PLTE chunk fCount variable}
+ {to the actual number of palette colors which is 2^(Bits for each pixel)}
+ if HasPalette then PLTE.fCount := 1 shl BitmapInfo.bmBitsPixel;
+
+ {In case it is a transparent bitmap, prepares it}
+ if Transparent then TRNS.TransparentColor := TransparentColor;
+
+end;
+
+{Assigns from another PNG}
+procedure TPngObject.AssignPNG(Source: TPNGObject);
+var
+ J: Integer;
+begin
+ {Copy properties}
+ InterlaceMethod := Source.InterlaceMethod;
+ MaxIdatSize := Source.MaxIdatSize;
+ CompressionLevel := Source.CompressionLevel;
+ Filters := Source.Filters;
+
+ {Clear old chunks and prepare}
+ ClearChunks();
+ Chunks.Count := Source.Chunks.Count;
+ {Create chunks and makes a copy from the source}
+ FOR J := 0 TO Chunks.Count - 1 DO
+ with Source.Chunks do
+ begin
+ Chunks.SetItem(J, TChunkClass(TChunk(Item[J]).ClassType).Create(Self));
+ TChunk(Chunks.Item[J]).Assign(TChunk(Item[J]));
+ end {with};
+end;
+
+{Returns a alpha data scanline}
+function TPngObject.GetAlphaScanline(const LineIndex: Integer): pByteArray;
+begin
+ with Header do
+ if (ColorType = COLOR_RGBALPHA) or (ColorType = COLOR_GRAYSCALEALPHA) then
+ Longint(Result) := Longint(ImageAlpha) + (LineIndex * Longint(Width))
+ else Result := nil; {In case the image does not use alpha information}
+end;
+
+{$IFDEF Store16bits}
+{Returns a png data extra scanline}
+function TPngObject.GetExtraScanline(const LineIndex: Integer): Pointer;
+begin
+ with Header do
+ Longint(Result) := (Longint(ExtraImageData) + ((Longint(Height) - 1) *
+ BytesPerRow)) - (LineIndex * BytesPerRow);
+end;
+{$ENDIF}
+
+{Returns a png data scanline}
+function TPngObject.GetScanline(const LineIndex: Integer): Pointer;
+begin
+ with Header do
+ Longint(Result) := (Longint(ImageData) + ((Longint(Height) - 1) *
+ BytesPerRow)) - (LineIndex * BytesPerRow);
+end;
+
+{Initialize gamma table}
+procedure TPngObject.InitializeGamma;
+var
+ i: Integer;
+begin
+ {Build gamma table as if there was no gamma}
+ FOR i := 0 to 255 do
+ begin
+ GammaTable[i] := i;
+ InverseGamma[i] := i;
+ end {for i}
+end;
+
+{Returns the transparency mode used by this png}
+function TPngObject.GetTransparencyMode: TPNGTransparencyMode;
+var
+ TRNS: TChunkTRNS;
+begin
+ with Header do
+ begin
+ Result := ptmNone; {Default result}
+ {Gets the TRNS chunk pointer}
+ TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS;
+
+ {Test depending on the color type}
+ case ColorType of
+ {This modes are always partial}
+ COLOR_RGBALPHA, COLOR_GRAYSCALEALPHA: Result := ptmPartial;
+ {This modes support bit transparency}
+ COLOR_RGB, COLOR_GRAYSCALE: if TRNS <> nil then Result := ptmBit;
+ {Supports booth translucid and bit}
+ COLOR_PALETTE:
+ {A TRNS chunk must be present, otherwise it won't support transparency}
+ if TRNS <> nil then
+ if TRNS.BitTransparency then
+ Result := ptmBit else Result := ptmPartial
+ end {case}
+
+ end {with Header}
+end;
+
+{Add a text chunk}
+procedure TPngObject.AddtEXt(const Keyword, Text: String);
+var
+ TextChunk: TChunkTEXT;
+begin
+ TextChunk := Chunks.Add(TChunkText) as TChunkTEXT;
+ TextChunk.Keyword := Keyword;
+ TextChunk.Text := Text;
+end;
+
+{Add a text chunk}
+procedure TPngObject.AddzTXt(const Keyword, Text: String);
+var
+ TextChunk: TChunkzTXt;
+begin
+ TextChunk := Chunks.Add(TChunkText) as TChunkzTXt;
+ TextChunk.Keyword := Keyword;
+ TextChunk.Text := Text;
+end;
+
+{Removes the image transparency}
+procedure TPngObject.RemoveTransparency;
+var
+ TRNS: TChunkTRNS;
+begin
+ TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS;
+ if TRNS <> nil then Chunks.RemoveChunk(TRNS)
+end;
+
+{Generates alpha information}
+procedure TPngObject.CreateAlpha;
+var
+ TRNS: TChunkTRNS;
+begin
+ {Generates depending on the color type}
+ with Header do
+ case ColorType of
+ {Png allocates different memory space to hold alpha information}
+ {for these types}
+ COLOR_GRAYSCALE, COLOR_RGB:
+ begin
+ {Transform into the appropriate color type}
+ if ColorType = COLOR_GRAYSCALE then
+ ColorType := COLOR_GRAYSCALEALPHA
+ else ColorType := COLOR_RGBALPHA;
+ {Allocates memory to hold alpha information}
+ GetMem(ImageAlpha, Integer(Width) * Integer(Height));
+ FillChar(ImageAlpha^, Integer(Width) * Integer(Height), #255);
+ end;
+ {Palette uses the TChunktRNS to store alpha}
+ COLOR_PALETTE:
+ begin
+ {Gets/creates TRNS chunk}
+ if Chunks.ItemFromClass(TChunkTRNS) = nil then
+ TRNS := Chunks.Add(TChunkTRNS) as TChunkTRNS
+ else
+ TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS;
+
+ {Prepares the TRNS chunk}
+ with TRNS do
+ begin
+ Fillchar(PaletteValues[0], 256, 255);
+ fDataSize := 1 shl Header.BitDepth;
+ fBitTransparency := False
+ end {with Chunks.Add};
+ end;
+ end {case Header.ColorType}
+
+end;
+
+{Returns transparent color}
+function TPngObject.GetTransparentColor: TColor;
+var
+ TRNS: TChunkTRNS;
+begin
+ TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS;
+ {Reads the transparency chunk to get this info}
+ if Assigned(TRNS) then Result := TRNS.TransparentColor
+ else Result := 0
+end;
+
+{$OPTIMIZATION OFF}
+procedure TPngObject.SetTransparentColor(const Value: TColor);
+var
+ TRNS: TChunkTRNS;
+begin
+ if HeaderPresent then
+ {Tests the ColorType}
+ case Header.ColorType of
+ {Not allowed for this modes}
+ COLOR_RGBALPHA, COLOR_GRAYSCALEALPHA: Self.RaiseError(
+ EPNGCannotChangeTransparent, EPNGCannotChangeTransparentText);
+ {Allowed}
+ COLOR_PALETTE, COLOR_RGB, COLOR_GRAYSCALE:
+ begin
+ TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS;
+ if not Assigned(TRNS) then TRNS := Chunks.Add(TChunkTRNS) as TChunkTRNS;
+
+ {Sets the transparency value from TRNS chunk}
+ TRNS.TransparentColor := {$IFDEF UseDelphi}ColorToRGB({$ENDIF}Value{$IFDEF UseDelphi}){$ENDIF}
+ end {COLOR_PALETTE, COLOR_RGB, COLOR_GRAYSCALE)}
+ end {case}
+end;
+
+{Returns if header is present}
+function TPngObject.HeaderPresent: Boolean;
+begin
+ Result := ((Chunks.Count <> 0) and (Chunks.Item[0] is TChunkIHDR))
+end;
+
+{Returns pixel for png using palette and grayscale}
+function GetByteArrayPixel(const png: TPngObject; const X, Y: Integer): TColor;
+var
+ ByteData: Byte;
+ DataDepth: Byte;
+begin
+ with png, Header do
+ begin
+ {Make sure the bitdepth is not greater than 8}
+ DataDepth := BitDepth;
+ if DataDepth > 8 then DataDepth := 8;
+ {Obtains the byte containing this pixel}
+ ByteData := pByteArray(png.Scanline[Y])^[X div (8 div DataDepth)];
+ {Moves the bits we need to the right}
+ ByteData := (ByteData shr ((8 - DataDepth) -
+ (X mod (8 div DataDepth)) * DataDepth));
+ {Discard the unwanted pixels}
+ ByteData:= ByteData and ($FF shr (8 - DataDepth));
+
+ {For palette mode map the palette entry and for grayscale convert and
+ returns the intensity}
+ case ColorType of
+ COLOR_PALETTE:
+ with TChunkPLTE(png.Chunks.ItemFromClass(TChunkPLTE)).Item[ByteData] do
+ Result := rgb(GammaTable[rgbRed], GammaTable[rgbGreen],
+ GammaTable[rgbBlue]);
+ COLOR_GRAYSCALE:
+ begin
+ ByteData := GammaTable[ByteData * ((1 shl DataDepth) + 1)];
+ Result := rgb(ByteData, ByteData, ByteData);
+ end;
+ else Result := 0;
+ end {case};
+ end {with}
+end;
+
+{In case vcl units are not being used}
+{$IFNDEF UseDelphi}
+function ColorToRGB(const Color: TColor): COLORREF;
+begin
+ Result := Color
+end;
+{$ENDIF}
+
+{Sets a pixel for grayscale and palette pngs}
+procedure SetByteArrayPixel(const png: TPngObject; const X, Y: Integer;
+ const Value: TColor);
+const
+ ClearFlag: Array[1..8] of Integer = (1, 3, 0, 15, 0, 0, 0, $FF);
+var
+ ByteData: pByte;
+ DataDepth: Byte;
+ ValEntry: Byte;
+begin
+ with png.Header do
+ begin
+ {Map into a palette entry}
+ ValEntry := GetNearestPaletteIndex(Png.Palette, ColorToRGB(Value));
+
+ {16 bits grayscale extra bits are discarted}
+ DataDepth := BitDepth;
+ if DataDepth > 8 then DataDepth := 8;
+ {Gets a pointer to the byte we intend to change}
+ ByteData := @pByteArray(png.Scanline[Y])^[X div (8 div DataDepth)];
+ {Clears the old pixel data}
+ ByteData^ := ByteData^ and not (ClearFlag[DataDepth] shl ((8 - DataDepth) -
+ (X mod (8 div DataDepth)) * DataDepth));
+
+ {Setting the new pixel}
+ ByteData^ := ByteData^ or (ValEntry shl ((8 - DataDepth) - (X mod (8 div DataDepth)) * DataDepth));
+ end {with png.Header}
+end;
+
+{Returns pixel when png uses RGB}
+function GetRGBLinePixel(const png: TPngObject;
+ const X, Y: Integer): TColor;
+begin
+ with pRGBLine(png.Scanline[Y])^[X] do
+ Result := RGB(rgbtRed, rgbtGreen, rgbtBlue)
+end;
+
+{Sets pixel when png uses RGB}
+procedure SetRGBLinePixel(const png: TPngObject;
+ const X, Y: Integer; Value: TColor);
+begin
+ with pRGBLine(png.Scanline[Y])^[X] do
+ begin
+ rgbtRed := GetRValue(Value);
+ rgbtGreen := GetGValue(Value);
+ rgbtBlue := GetBValue(Value)
+ end
+end;
+
+{Sets a pixel}
+procedure TPngObject.SetPixels(const X, Y: Integer; const Value: TColor);
+begin
+ if (X in [0..Width - 1]) and (Y in [0..Height - 1]) then
+ with Header do
+ begin
+ if ColorType in [COLOR_GRAYSCALE, COLOR_PALETTE] then
+ SetByteArrayPixel(Self, X, Y, Value)
+ else
+ SetRGBLinePixel(Self, X, Y, Value)
+ end {with}
+end;
+
+{Returns a pixel}
+function TPngObject.GetPixels(const X, Y: Integer): TColor;
+begin
+ if (X in [0..Width - 1]) and (Y in [0..Height - 1]) then
+ with Header do
+ begin
+ if ColorType in [COLOR_GRAYSCALE, COLOR_PALETTE] then
+ Result := GetByteArrayPixel(Self, X, Y)
+ else
+ Result := GetRGBLinePixel(Self, X, Y)
+ end {with}
+ else Result := 0
+end;
+
+{Returns the image palette}
+function TPngObject.GetPalette: HPALETTE;
+var
+ LogPalette: TMaxLogPalette;
+ i: Integer;
+begin
+ {Palette is avaliable for COLOR_PALETTE and COLOR_GRAYSCALE modes}
+ if (Header.ColorType in [COLOR_PALETTE, COLOR_GRAYSCALE]) then
+ begin
+ {In case the pal}
+ if TempPalette = 0 then
+ with LogPalette do
+ begin
+ {Prepares the new palette}
+ palVersion := $300;
+ palNumEntries := 256;
+ {Copy entries}
+ for i := 0 to LogPalette.palNumEntries - 1 do
+ begin
+ palPalEntry[i].peRed := Header.BitmapInfo.bmiColors[i].rgbRed;
+ palPalEntry[i].peGreen := Header.BitmapInfo.bmiColors[i].rgbGreen;
+ palPalEntry[i].peBlue := Header.BitmapInfo.bmiColors[i].rgbBlue;
+ palPalEntry[i].peFlags := 0;
+ end {for i};
+ {Creates the palette}
+ TempPalette := CreatePalette(pLogPalette(@LogPalette)^);
+ end {with LogPalette, if Temppalette = 0}
+ end {if Header.ColorType in ...};
+ Result := TempPalette;
+end;
+
+initialization
+ {Initialize}
+ ChunkClasses := nil;
+ {crc table has not being computed yet}
+ crc_table_computed := FALSE;
+ {Register the necessary chunks for png}
+ RegisterCommonChunks;
+ {Registers TPNGObject to use with TPicture}
+ {$IFDEF UseDelphi}{$IFDEF RegisterGraphic}
+ TPicture.RegisterFileFormat('PNG', 'Portable Network Graphics', TPNGObject);
+ {$ENDIF}{$ENDIF}
+finalization
+ {$IFDEF UseDelphi}{$IFDEF RegisterGraphic}
+ TPicture.UnregisterGraphicClass(TPNGObject);
+ {$ENDIF}{$ENDIF}
+ {Free chunk classes}
+ FreeChunkClassList;
+end.
+
+
diff --git a/Game/Code/lib/PngImage/pngimage.~pas b/Game/Code/lib/PngImage/pngimage.~pas new file mode 100644 index 00000000..ec712737 --- /dev/null +++ b/Game/Code/lib/PngImage/pngimage.~pas @@ -0,0 +1,5205 @@ +{Portable Network Graphics Delphi 1.4361 (8 March 2003) }
+
+{This is the latest implementation for TPngImage component }
+{It's meant to be a full replacement for the previous one. }
+{There are lots of new improvements, including cleaner code, }
+{full partial transparency support, speed improvements, }
+{saving using ADAM 7 interlacing, better error handling, also }
+{the best compression for the final image ever. And now it's }
+{truly able to read about any png image. }
+
+{
+ Version 1.4361
+ 2003-03-04 - Fixed important bug for simple transparency when using
+ RGB, Grayscale color modes
+
+ Version 1.436
+ 2003-03-04 - * NEW * Property Pixels for direct access to pixels
+ * IMPROVED * Palette property (TPngObject) (read only)
+ Slovenian traslation for the component (Miha Petelin)
+ Help file update (scanline article/png->jpg example)
+
+ Version 1.435
+ 2003-11-03 - * NEW * New chunk implementation zTXt (method AddzTXt)
+ * NEW * New compiler flags to store the extra 8 bits
+ from 16 bits samples (when saving it is ignored), the
+ extra data may be acessed using ExtraScanline property
+ * Fixed * a bug on tIMe chunk
+ French translation included (Thanks to IBE Software)
+ Bugs fixed
+
+ Version 1.432
+ 2002-08-24 - * NEW * A new method, CreateAlpha will transform the
+ current image into partial transparency.
+ Help file updated with a new article on how to handle
+ partial transparency.
+
+ Version 1.431
+ 2002-08-14 - Fixed and tested to work on:
+ C++ Builder 3
+ C++ Builder 5
+ Delphi 3
+ There was an error when setting TransparentColor, fixed
+ New method, RemoveTransparency to remove image
+ BIT TRANSPARENCY
+
+ Version 1.43
+ 2002-08-01 - * NEW * Support for Delphi 3 and C++ Builder 3
+ Implements mostly some things that were missing,
+ a few tweaks and fixes.
+
+ Version 1.428
+ 2002-07-24 - More minor fixes (thanks to Ian Boyd)
+ Bit transparency fixes
+ * NEW * Finally support to bit transparency
+ (palette / rgb / grayscale -> all)
+
+ Version 1.427
+ 2002-07-19 - Lots of bugs and leaks fixed
+ * NEW * method to easy adding text comments, AddtEXt
+ * NEW * property for setting bit transparency,
+ TransparentColor
+
+ Version 1.426
+ 2002-07-18 - Clipboard finally fixed (hope)
+ Changed UseDelphi trigger to UseDelphi
+ * NEW * Support for bit transparency bitmaps
+ when assigning from/to TBitmap objects
+ Altough it does not support drawing transparent
+ parts of bit transparency pngs (only partial)
+ it is closer than ever
+
+ Version 1.425
+ 2002-07-01 - Clipboard methods implemented
+ Lots of bugs fixed
+
+ Version 1.424
+ 2002-05-16 - Scanline and AlphaScanline are now working correctly.
+ New methods for handling the clipboard
+
+ Version 1.423
+ 2002-05-16 - * NEW * Partial transparency for 1, 2, 4 and 8 bits is
+ also supported using the tRNS chunk (for palette and
+ grayscaling).
+ New bug fixes (Peter Haas).
+
+ Version 1.422
+ 2002-05-14 - Fixed some critical leaks, thanks to Peter Haas tips.
+ New translation for German (Peter Haas).
+
+ Version 1.421
+ 2002-05-06 - Now uses new ZLIB version, 1.1.4 with some security
+ fixes.
+ LoadFromResourceID and LoadFromResourceName added and
+ help file updated for that.
+ The resources strings are now located in pnglang.pas.
+ New translation for Brazilian Portuguese.
+ Bugs fixed.
+
+ IMPORTANT: I'm currently looking for bugs on the library. If
+ anyone has found one, please send me an email and
+ I will fix right away. Thanks for all the help and
+ ideias I'm receiving so far.}
+
+{My new email is: gubadaud@terra.com.br}
+{Website link : pngdelphi.sourceforge.net}
+{Gustavo Huffenbacher Daud}
+
+unit pngimage;
+
+interface
+
+{Triggers avaliable (edit the fields bellow)}
+{$DEFINE UseDelphi} //Disable fat vcl units (perfect to small apps)
+{$DEFINE ErrorOnUnknownCritical} //Error when finds an unknown critical chunk
+{$DEFINE CheckCRC} //Enables CRC checking
+{$DEFINE RegisterGraphic} //Registers TPNGObject to use with TPicture
+{$DEFINE PartialTransparentDraw} //Draws partial transparent images
+{.$DEFINE Store16bits} //Stores the extra 8 bits from 16bits/sample
+{.$DEFINE Debug} //For programming purposes
+{$RANGECHECKS OFF} {$J+}
+
+
+
+uses
+ Windows {$IFDEF UseDelphi}, Classes, Graphics, SysUtils{$ENDIF} {$IFDEF Debug},
+ dialogs{$ENDIF}, pngzlib, pnglang;
+
+{$IFNDEF UseDelphi}
+ const
+ soFromBeginning = 0;
+ soFromCurrent = 1;
+ soFromEnd = 2;
+{$ENDIF}
+
+const
+ {ZLIB constants}
+ ZLIBErrors: Array[-6..2] of string = ('incompatible version (-6)',
+ 'buffer error (-5)', 'insufficient memory (-4)', 'data error (-3)',
+ 'stream error (-2)', 'file error (-1)', '(0)', 'stream end (1)',
+ 'need dictionary (2)');
+ Z_NO_FLUSH = 0;
+ Z_FINISH = 4;
+ Z_STREAM_END = 1;
+
+ {Avaliable PNG filters for mode 0}
+ FILTER_NONE = 0;
+ FILTER_SUB = 1;
+ FILTER_UP = 2;
+ FILTER_AVERAGE = 3;
+ FILTER_PAETH = 4;
+
+ {Avaliable color modes for PNG}
+ COLOR_GRAYSCALE = 0;
+ COLOR_RGB = 2;
+ COLOR_PALETTE = 3;
+ COLOR_GRAYSCALEALPHA = 4;
+ COLOR_RGBALPHA = 6;
+
+
+type
+ {$IFNDEF UseDelphi}
+ {Custom exception handler}
+ Exception = class(TObject)
+ constructor Create(Msg: String);
+ end;
+ ExceptClass = class of Exception;
+ TColor = ColorRef;
+ {$ENDIF}
+
+ {Error types}
+ EPNGOutMemory = class(Exception);
+ EPngError = class(Exception);
+ EPngUnexpectedEnd = class(Exception);
+ EPngInvalidCRC = class(Exception);
+ EPngInvalidIHDR = class(Exception);
+ EPNGMissingMultipleIDAT = class(Exception);
+ EPNGZLIBError = class(Exception);
+ EPNGInvalidPalette = class(Exception);
+ EPNGInvalidFileHeader = class(Exception);
+ EPNGIHDRNotFirst = class(Exception);
+ EPNGNotExists = class(Exception);
+ EPNGSizeExceeds = class(Exception);
+ EPNGMissingPalette = class(Exception);
+ EPNGUnknownCriticalChunk = class(Exception);
+ EPNGUnknownCompression = class(Exception);
+ EPNGUnknownInterlace = class(Exception);
+ EPNGNoImageData = class(Exception);
+ EPNGCouldNotLoadResource = class(Exception);
+ EPNGCannotChangeTransparent = class(Exception);
+ EPNGHeaderNotPresent = class(Exception);
+
+type
+ {Direct access to pixels using R,G,B}
+ TRGBLine = array[word] of TRGBTriple;
+ pRGBLine = ^TRGBLine;
+
+ {Same as TBitmapInfo but with allocated space for}
+ {palette entries}
+ TMAXBITMAPINFO = packed record
+ bmiHeader: TBitmapInfoHeader;
+ bmiColors: packed array[0..255] of TRGBQuad;
+ end;
+
+ {Transparency mode for pngs}
+ TPNGTransparencyMode = (ptmNone, ptmBit, ptmPartial);
+ {Pointer to a cardinal type}
+ pCardinal = ^Cardinal;
+ {Access to a rgb pixel}
+ pRGBPixel = ^TRGBPixel;
+ TRGBPixel = packed record
+ B, G, R: Byte;
+ end;
+
+ {Pointer to an array of bytes type}
+ TByteArray = Array[Word] of Byte;
+ pByteArray = ^TByteArray;
+
+ {Forward}
+ TPNGObject = class;
+ pPointerArray = ^TPointerArray;
+ TPointerArray = Array[Word] of Pointer;
+
+ {Contains a list of objects}
+ TPNGPointerList = class
+ private
+ fOwner: TPNGObject;
+ fCount : Cardinal;
+ fMemory: pPointerArray;
+ function GetItem(Index: Cardinal): Pointer;
+ procedure SetItem(Index: Cardinal; const Value: Pointer);
+ protected
+ {Removes an item}
+ function Remove(Value: Pointer): Pointer; virtual;
+ {Inserts an item}
+ procedure Insert(Value: Pointer; Position: Cardinal);
+ {Add a new item}
+ procedure Add(Value: Pointer);
+ {Returns an item}
+ property Item[Index: Cardinal]: Pointer read GetItem write SetItem;
+ {Set the size of the list}
+ procedure SetSize(const Size: Cardinal);
+ {Returns owner}
+ property Owner: TPNGObject read fOwner;
+ public
+ {Returns number of items}
+ property Count: Cardinal read fCount write SetSize;
+ {Object being either created or destroyed}
+ constructor Create(AOwner: TPNGObject);
+ destructor Destroy; override;
+ end;
+
+ {Forward declaration}
+ TChunk = class;
+ TChunkClass = class of TChunk;
+
+ {Same as TPNGPointerList but providing typecasted values}
+ TPNGList = class(TPNGPointerList)
+ private
+ {Used with property Item}
+ function GetItem(Index: Cardinal): TChunk;
+ public
+ {Removes an item}
+ procedure RemoveChunk(Chunk: TChunk); overload;
+ {Add a new chunk using the class from the parameter}
+ function Add(ChunkClass: TChunkClass): TChunk;
+ {Returns pointer to the first chunk of class}
+ function ItemFromClass(ChunkClass: TChunkClass): TChunk;
+ {Returns a chunk item from the list}
+ property Item[Index: Cardinal]: TChunk read GetItem;
+ end;
+
+ {$IFNDEF UseDelphi}
+ {The STREAMs bellow are only needed in case delphi provided ones is not}
+ {avaliable (UseDelphi trigger not set)}
+ {Object becomes handles}
+ TCanvas = THandle;
+ TBitmap = HBitmap;
+ {Trick to work}
+ TPersistent = TObject;
+
+ {Base class for all streams}
+ TStream = class
+ protected
+ {Returning/setting size}
+ function GetSize: Longint; virtual;
+ procedure SetSize(const Value: Longint); virtual; abstract;
+ {Returns/set position}
+ function GetPosition: Longint; virtual;
+ procedure SetPosition(const Value: Longint); virtual;
+ public
+ {Returns/sets current position}
+ property Position: Longint read GetPosition write SetPosition;
+ {Property returns/sets size}
+ property Size: Longint read GetSize write SetSize;
+ {Allows reading/writing data}
+ function Read(var Buffer; Count: Longint): Cardinal; virtual; abstract;
+ function Write(const Buffer; Count: Longint): Cardinal; virtual; abstract;
+ {Copies from another Stream}
+ function CopyFrom(Source: TStream;
+ Count: Cardinal): Cardinal; virtual;
+ {Seeks a stream position}
+ function Seek(Offset: Longint; Origin: Word): Longint; virtual; abstract;
+ end;
+
+ {File stream modes}
+ TFileStreamMode = (fsmRead, fsmWrite, fsmCreate);
+ TFileStreamModeSet = set of TFileStreamMode;
+
+ {File stream for reading from files}
+ TFileStream = class(TStream)
+ private
+ {Opened mode}
+ Filemode: TFileStreamModeSet;
+ {Handle}
+ fHandle: THandle;
+ protected
+ {Set the size of the file}
+ procedure SetSize(const Value: Longint); override;
+ public
+ {Seeks a file position}
+ function Seek(Offset: Longint; Origin: Word): Longint; override;
+ {Reads/writes data from/to the file}
+ function Read(var Buffer; Count: Longint): Cardinal; override;
+ function Write(const Buffer; Count: Longint): Cardinal; override;
+ {Stream being created and destroy}
+ constructor Create(Filename: String; Mode: TFileStreamModeSet);
+ destructor Destroy; override;
+ end;
+
+ {Stream for reading from resources}
+ TResourceStream = class(TStream)
+ constructor Create(Instance: HInst; const ResName: String; ResType:PChar);
+ private
+ {Variables for reading}
+ Size: Integer;
+ Memory: Pointer;
+ Position: Integer;
+ protected
+ {Set the size of the file}
+ procedure SetSize(const Value: Longint); override;
+ public
+ {Stream processing}
+ function Read(var Buffer; Count: Integer): Cardinal; override;
+ function Seek(Offset: Integer; Origin: Word): Longint; override;
+ function Write(const Buffer; Count: Longint): Cardinal; override;
+ end;
+ {$ENDIF}
+
+ {Forward}
+ TChunkIHDR = class;
+ {Interlace method}
+ TInterlaceMethod = (imNone, imAdam7);
+ {Compression level type}
+ TCompressionLevel = 0..9;
+ {Filters type}
+ TFilter = (pfNone, pfSub, pfUp, pfAverage, pfPaeth);
+ TFilters = set of TFilter;
+
+ {Png implementation object}
+ TPngObject = class{$IFDEF UseDelphi}(TGraphic){$ENDIF}
+ protected
+ {Gamma table values}
+ GammaTable, InverseGamma: Array[Byte] of Byte;
+ procedure InitializeGamma;
+ private
+ {Temporary palette}
+ TempPalette: HPalette;
+ {Filters to test to encode}
+ fFilters: TFilters;
+ {Compression level for ZLIB}
+ fCompressionLevel: TCompressionLevel;
+ {Maximum size for IDAT chunks}
+ fMaxIdatSize: Cardinal;
+ {Returns if image is interlaced}
+ fInterlaceMethod: TInterlaceMethod;
+ {Chunks object}
+ fChunkList: TPngList;
+ {Clear all chunks in the list}
+ procedure ClearChunks;
+ {Returns if header is present}
+ function HeaderPresent: Boolean;
+ {Returns linesize and byte offset for pixels}
+ procedure GetPixelInfo(var LineSize, Offset: Cardinal);
+ procedure SetMaxIdatSize(const Value: Cardinal);
+ function GetAlphaScanline(const LineIndex: Integer): pByteArray;
+ function GetScanline(const LineIndex: Integer): Pointer;
+ {$IFDEF Store16bits}
+ function GetExtraScanline(const LineIndex: Integer): Pointer;
+ {$ENDIF}
+ function GetTransparencyMode: TPNGTransparencyMode;
+ function GetTransparentColor: TColor;
+ procedure SetTransparentColor(const Value: TColor);
+ protected
+ {Returns the image palette}
+ function GetPalette: HPALETTE; {$IFDEF UseDelphi}override;{$ENDIF}
+ {Returns/sets image width and height}
+ function GetWidth: Integer; {$IFDEF UseDelphi}override;{$ENDIF}
+ function GetHeight: Integer; {$IFDEF UseDelphi}override; {$ENDIF}
+ procedure SetWidth(Value: Integer); {$IFDEF UseDelphi}override; {$ENDIF}
+ procedure SetHeight(Value: Integer); {$IFDEF UseDelphi}override;{$ENDIF}
+ {Assigns from another TPNGObject}
+ procedure AssignPNG(Source: TPNGObject);
+ {Returns if the image is empty}
+ function GetEmpty: Boolean; {$IFDEF UseDelphi}override; {$ENDIF}
+ {Used with property Header}
+ function GetHeader: TChunkIHDR;
+ {Draws using partial transparency}
+ procedure DrawPartialTrans(DC: HDC; Rect: TRect);
+ {$IFDEF UseDelphi}
+ {Returns if the image is transparent}
+ function GetTransparent: Boolean; override;
+ {$ENDIF}
+ {Returns a pixel}
+ function GetPixels(const X, Y: Integer): TColor; virtual;
+ procedure SetPixels(const X, Y: Integer; const Value: TColor); virtual;
+ public
+ {Generates alpha information}
+ procedure CreateAlpha;
+ {Removes the image transparency}
+ procedure RemoveTransparency;
+ {Transparent color}
+ property TransparentColor: TColor read GetTransparentColor write
+ SetTransparentColor;
+ {Add text chunk, TChunkTEXT, TChunkzTXT}
+ procedure AddtEXt(const Keyword, Text: String);
+ procedure AddzTXt(const Keyword, Text: String);
+ {$IFDEF UseDelphi}
+ {Saves to clipboard format (thanks to Antoine Pottern)}
+ procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle;
+ var APalette: HPalette); override;
+ procedure LoadFromClipboardFormat(AFormat: Word; AData: THandle;
+ APalette: HPalette); override;
+ {$ENDIF}
+ {Calling errors}
+ procedure RaiseError(ExceptionClass: ExceptClass; Text: String);
+ {Returns a scanline from png}
+ property Scanline[const Index: Integer]: Pointer read GetScanline;
+ {$IFDEF Store16bits}
+ property ExtraScanline[const Index: Integer]: Pointer read GetExtraScanline;
+ {$ENDIF}
+ property AlphaScanline[const Index: Integer]: pByteArray read GetAlphaScanline;
+ {Returns pointer to the header}
+ property Header: TChunkIHDR read GetHeader;
+ {Returns the transparency mode used by this png}
+ property TransparencyMode: TPNGTransparencyMode read GetTransparencyMode;
+ {Assigns from another object}
+ procedure Assign(Source: TPersistent);{$IFDEF UseDelphi}override;{$ENDIF}
+ {Assigns to another object}
+ procedure AssignTo(Dest: TPersistent);{$IFDEF UseDelphi}override;{$ENDIF}
+ {Assigns from a windows bitmap handle}
+ procedure AssignHandle(Handle: HBitmap; Transparent: Boolean;
+ TransparentColor: ColorRef);
+ {Draws the image into a canvas}
+ procedure Draw(ACanvas: TCanvas; const Rect: TRect);
+ {$IFDEF UseDelphi}override;{$ENDIF}
+ {Width and height properties}
+ property Width: Integer read GetWidth;
+ property Height: Integer read GetHeight;
+ {Returns if the image is interlaced}
+ property InterlaceMethod: TInterlaceMethod read fInterlaceMethod
+ write fInterlaceMethod;
+ {Filters to test to encode}
+ property Filters: TFilters read fFilters write fFilters;
+ {Maximum size for IDAT chunks, default and minimum is 65536}
+ property MaxIdatSize: Cardinal read fMaxIdatSize write SetMaxIdatSize;
+ {Property to return if the image is empty or not}
+ property Empty: Boolean read GetEmpty;
+ {Compression level}
+ property CompressionLevel: TCompressionLevel read fCompressionLevel
+ write fCompressionLevel;
+ {Access to the chunk list}
+ property Chunks: TPngList read fChunkList;
+ {Object being created and destroyed}
+ constructor Create; {$IFDEF UseDelphi}override;{$ENDIF}
+ destructor Destroy; override;
+ {$IFNDEF UseDelphi}procedure LoadFromFile(const Filename: String);{$ENDIF}
+ {$IFNDEF UseDelphi}procedure SaveToFile(const Filename: String);{$ENDIF}
+ procedure LoadFromStream(Stream: TStream); {$IFDEF UseDelphi}override;{$ENDIF}
+ procedure SaveToStream(Stream: TStream); {$IFDEF UseDelphi}override;{$ENDIF}
+ {Loading the image from resources}
+ procedure LoadFromResourceName(Instance: HInst; const Name: String);
+ procedure LoadFromResourceID(Instance: HInst; ResID: Integer);
+ {Access to the png pixels}
+ property Pixels[const X, Y: Integer]: TColor read GetPixels write SetPixels;
+ {Palette property}
+ {$IFNDEF UseDelphi}property Palette: HPalette read GetPalette;{$ENDIF}
+ end;
+
+ {Chunk name object}
+ TChunkName = Array[0..3] of Char;
+
+ {Global chunk object}
+ TChunk = class
+ private
+ {Contains data}
+ fData: Pointer;
+ fDataSize: Cardinal;
+ {Stores owner}
+ fOwner: TPngObject;
+ {Stores the chunk name}
+ fName: TChunkName;
+ {Returns pointer to the TChunkIHDR}
+ function GetHeader: TChunkIHDR;
+ {Used with property index}
+ function GetIndex: Integer;
+ {Should return chunk class/name}
+ class function GetName: String; virtual;
+ {Returns the chunk name}
+ function GetChunkName: String;
+ public
+ {Returns index from list}
+ property Index: Integer read GetIndex;
+ {Returns pointer to the TChunkIHDR}
+ property Header: TChunkIHDR read GetHeader;
+ {Resize the data}
+ procedure ResizeData(const NewSize: Cardinal);
+ {Returns data and size}
+ property Data: Pointer read fData;
+ property DataSize: Cardinal read fDataSize;
+ {Assigns from another TChunk}
+ procedure Assign(Source: TChunk); virtual;
+ {Returns owner}
+ property Owner: TPngObject read fOwner;
+ {Being destroyed/created}
+ constructor Create(Owner: TPngObject); virtual;
+ destructor Destroy; override;
+ {Returns chunk class/name}
+ property Name: String read GetChunkName;
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; virtual;
+ {Saves the chunk to a stream}
+ function SaveData(Stream: TStream): Boolean;
+ function SaveToStream(Stream: TStream): Boolean; virtual;
+ end;
+
+ {Chunk classes}
+ TChunkIEND = class(TChunk); {End chunk}
+
+ {IHDR data}
+ pIHDRData = ^TIHDRData;
+ TIHDRData = packed record
+ Width, Height: Cardinal;
+ BitDepth,
+ ColorType,
+ CompressionMethod,
+ FilterMethod,
+ InterlaceMethod: Byte;
+ end;
+
+ {Information header chunk}
+ TChunkIHDR = class(TChunk)
+ private
+ {Current image}
+ ImageHandle: HBitmap;
+ ImageDC: HDC;
+
+ {Output windows bitmap}
+ HasPalette: Boolean;
+ BitmapInfo: TMaxBitmapInfo;
+ BytesPerRow: Integer;
+ {Stores the image bytes}
+ {$IFDEF Store16bits}ExtraImageData: Pointer;{$ENDIF}
+ ImageData: pointer;
+ ImageAlpha: Pointer;
+
+ {Contains all the ihdr data}
+ IHDRData: TIHDRData;
+ protected
+ {Resizes the image data to fill the color type, bit depth, }
+ {width and height parameters}
+ procedure PrepareImageData;
+ {Release allocated ImageData memory}
+ procedure FreeImageData;
+ public
+ {Properties}
+ property Width: Cardinal read IHDRData.Width write IHDRData.Width;
+ property Height: Cardinal read IHDRData.Height write IHDRData.Height;
+ property BitDepth: Byte read IHDRData.BitDepth write IHDRData.BitDepth;
+ property ColorType: Byte read IHDRData.ColorType write IHDRData.ColorType;
+ property CompressionMethod: Byte read IHDRData.CompressionMethod
+ write IHDRData.CompressionMethod;
+ property FilterMethod: Byte read IHDRData.FilterMethod
+ write IHDRData.FilterMethod;
+ property InterlaceMethod: Byte read IHDRData.InterlaceMethod
+ write IHDRData.InterlaceMethod;
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Saves the chunk to a stream}
+ function SaveToStream(Stream: TStream): Boolean; override;
+ {Destructor/constructor}
+ constructor Create(Owner: TPngObject); override;
+ destructor Destroy; override;
+ {Assigns from another TChunk}
+ procedure Assign(Source: TChunk); override;
+ end;
+
+ {Gamma chunk}
+ TChunkgAMA = class(TChunk)
+ private
+ {Returns/sets the value for the gamma chunk}
+ function GetValue: Cardinal;
+ procedure SetValue(const Value: Cardinal);
+ public
+ {Returns/sets gamma value}
+ property Gamma: Cardinal read GetValue write SetValue;
+ {Loading the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Being created}
+ constructor Create(Owner: TPngObject); override;
+ {Assigns from another TChunk}
+ procedure Assign(Source: TChunk); override;
+ end;
+
+ {ZLIB Decompression extra information}
+ TZStreamRec2 = packed record
+ {From ZLIB}
+ ZLIB: TZStreamRec;
+ {Additional info}
+ Data: Pointer;
+ fStream : TStream;
+ end;
+
+ {Palette chunk}
+ TChunkPLTE = class(TChunk)
+ private
+ {Number of items in the palette}
+ fCount: Integer;
+ {Contains the palette handle}
+ function GetPaletteItem(Index: Byte): TRGBQuad;
+ public
+ {Returns the color for each item in the palette}
+ property Item[Index: Byte]: TRGBQuad read GetPaletteItem;
+ {Returns the number of items in the palette}
+ property Count: Integer read fCount;
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Saves the chunk to a stream}
+ function SaveToStream(Stream: TStream): Boolean; override;
+ {Assigns from another TChunk}
+ procedure Assign(Source: TChunk); override;
+ end;
+
+ {Transparency information}
+ TChunktRNS = class(TChunk)
+ private
+ fBitTransparency: Boolean;
+ function GetTransparentColor: ColorRef;
+ {Returns the transparent color}
+ procedure SetTransparentColor(const Value: ColorRef);
+ public
+ {Palette values for transparency}
+ PaletteValues: Array[Byte] of Byte;
+ {Returns if it uses bit transparency}
+ property BitTransparency: Boolean read fBitTransparency;
+ {Returns the transparent color}
+ property TransparentColor: ColorRef read GetTransparentColor write
+ SetTransparentColor;
+ {Loads/saves the chunk from/to a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ function SaveToStream(Stream: TStream): Boolean; override;
+ {Assigns from another TChunk}
+ procedure Assign(Source: TChunk); override;
+ end;
+
+ {Actual image information}
+ TChunkIDAT = class(TChunk)
+ private
+ {Holds another pointer to the TChunkIHDR}
+ Header: TChunkIHDR;
+ {Stores temporary image width and height}
+ ImageWidth, ImageHeight: Integer;
+ {Size in bytes of each line and offset}
+ Row_Bytes, Offset : Cardinal;
+ {Contains data for the lines}
+ Encode_Buffer: Array[0..5] of pByteArray;
+ Row_Buffer: Array[Boolean] of pByteArray;
+ {Variable to invert the Row_Buffer used}
+ RowUsed: Boolean;
+ {Ending position for the current IDAT chunk}
+ EndPos: Integer;
+ {Filter the current line}
+ procedure FilterRow;
+ {Filter to encode and returns the best filter}
+ function FilterToEncode: Byte;
+ {Reads ZLIB compressed data}
+ function IDATZlibRead(var ZLIBStream: TZStreamRec2; Buffer: Pointer;
+ Count: Integer; var EndPos: Integer; var crcfile: Cardinal): Integer;
+ {Compress and writes IDAT data}
+ procedure IDATZlibWrite(var ZLIBStream: TZStreamRec2; Buffer: Pointer;
+ const Length: Cardinal);
+ procedure FinishIDATZlib(var ZLIBStream: TZStreamRec2);
+ {Prepares the palette}
+ procedure PreparePalette;
+ protected
+ {Decode interlaced image}
+ procedure DecodeInterlacedAdam7(Stream: TStream;
+ var ZLIBStream: TZStreamRec2; const Size: Integer; var crcfile: Cardinal);
+ {Decode non interlaced imaged}
+ procedure DecodeNonInterlaced(Stream: TStream;
+ var ZLIBStream: TZStreamRec2; const Size: Integer;
+ var crcfile: Cardinal);
+ protected
+ {Encode non interlaced images}
+ procedure EncodeNonInterlaced(Stream: TStream;
+ var ZLIBStream: TZStreamRec2);
+ {Encode interlaced images}
+ procedure EncodeInterlacedAdam7(Stream: TStream;
+ var ZLIBStream: TZStreamRec2);
+ protected
+ {Memory copy methods to decode}
+ procedure CopyNonInterlacedRGB8(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedRGB16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedPalette148(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedPalette2(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedGray2(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedGrayscale16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedRGBAlpha8(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedRGBAlpha16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedGrayscaleAlpha8(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyNonInterlacedGrayscaleAlpha16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedRGB8(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedRGB16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedPalette148(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedPalette2(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedGray2(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedGrayscale16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedRGBAlpha8(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedRGBAlpha16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedGrayscaleAlpha8(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ procedure CopyInterlacedGrayscaleAlpha16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+ protected
+ {Memory copy methods to encode}
+ procedure EncodeNonInterlacedRGB8(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedRGB16(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedGrayscale16(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedPalette148(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedRGBAlpha8(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedRGBAlpha16(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedGrayscaleAlpha8(Src, Dest, Trans: pChar);
+ procedure EncodeNonInterlacedGrayscaleAlpha16(Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedRGB8(const Pass: Byte; Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedRGB16(const Pass: Byte; Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedPalette148(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedGrayscale16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedRGBAlpha8(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedRGBAlpha16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedGrayscaleAlpha8(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+ procedure EncodeInterlacedGrayscaleAlpha16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+ public
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Saves the chunk to a stream}
+ function SaveToStream(Stream: TStream): Boolean; override;
+ end;
+
+ {Image last modification chunk}
+ TChunktIME = class(TChunk)
+ private
+ {Holds the variables}
+ fYear: Word;
+ fMonth, fDay, fHour, fMinute, fSecond: Byte;
+ public
+ {Returns/sets variables}
+ property Year: Word read fYear write fYear;
+ property Month: Byte read fMonth write fMonth;
+ property Day: Byte read fDay write fDay;
+ property Hour: Byte read fHour write fHour;
+ property Minute: Byte read fMinute write fMinute;
+ property Second: Byte read fSecond write fSecond;
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Saves the chunk to a stream}
+ function SaveToStream(Stream: TStream): Boolean; override;
+ end;
+
+ {Textual data}
+ TChunktEXt = class(TChunk)
+ private
+ fKeyword, fText: String;
+ public
+ {Keyword and text}
+ property Keyword: String read fKeyword write fKeyword;
+ property Text: String read fText write fText;
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Saves the chunk to a stream}
+ function SaveToStream(Stream: TStream): Boolean; override;
+ {Assigns from another TChunk}
+ procedure Assign(Source: TChunk); override;
+ end;
+
+ {zTXT chunk}
+ TChunkzTXt = class(TChunktEXt)
+ {Loads the chunk from a stream}
+ function LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean; override;
+ {Saves the chunk to a stream}
+ function SaveToStream(Stream: TStream): Boolean; override;
+ end;
+
+{Here we test if it's c++ builder or delphi version 3 or less}
+{$IFDEF VER110}{$DEFINE DelphiBuilder3Less}{$ENDIF}
+{$IFDEF VER100}{$DEFINE DelphiBuilder3Less}{$ENDIF}
+{$IFDEF VER93}{$DEFINE DelphiBuilder3Less}{$ENDIF}
+{$IFDEF VER90}{$DEFINE DelphiBuilder3Less}{$ENDIF}
+{$IFDEF VER80}{$DEFINE DelphiBuilder3Less}{$ENDIF}
+
+
+{Registers a new chunk class}
+procedure RegisterChunk(ChunkClass: TChunkClass);
+{Calculates crc}
+function update_crc(crc: {$IFNDEF DelphiBuilder3Less}Cardinal{$ELSE}Integer
+ {$ENDIF}; buf: pByteArray; len: Integer): Cardinal;
+{Invert bytes using assembly}
+function ByteSwap(const a: integer): integer;
+
+implementation
+
+var
+ ChunkClasses: TPngPointerList;
+ {Table of CRCs of all 8-bit messages}
+ crc_table: Array[0..255] of Cardinal;
+ {Flag: has the table been computed? Initially false}
+ crc_table_computed: Boolean;
+
+{Draw transparent image using transparent color}
+procedure DrawTransparentBitmap(dc: HDC; srcBits: Pointer;
+ var srcHeader: TBitmapInfoHeader;
+ srcBitmapInfo: pBitmapInfo; Rect: TRect; cTransparentColor: COLORREF);
+var
+ cColor: COLORREF;
+ bmAndBack, bmAndObject, bmAndMem: HBITMAP;
+ bmBackOld, bmObjectOld, bmMemOld: HBITMAP;
+ hdcMem, hdcBack, hdcObject, hdcTemp: HDC;
+ ptSize, orgSize: TPOINT;
+ OldBitmap, DrawBitmap: HBITMAP;
+begin
+ hdcTemp := CreateCompatibleDC(dc);
+ // Select the bitmap
+ DrawBitmap := CreateDIBitmap(dc, srcHeader, CBM_INIT, srcBits, srcBitmapInfo^,
+ DIB_RGB_COLORS);
+ OldBitmap := SelectObject(hdcTemp, DrawBitmap);
+
+ // Sizes
+ OrgSize.x := abs(srcHeader.biWidth);
+ OrgSize.y := abs(srcHeader.biHeight);
+ ptSize.x := Rect.Right - Rect.Left; // Get width of bitmap
+ ptSize.y := Rect.Bottom - Rect.Top; // Get height of bitmap
+
+ // Create some DCs to hold temporary data.
+ hdcBack := CreateCompatibleDC(dc);
+ hdcObject := CreateCompatibleDC(dc);
+ hdcMem := CreateCompatibleDC(dc);
+
+ // Create a bitmap for each DC. DCs are required for a number of
+ // GDI functions.
+
+ // Monochrome DCs
+ bmAndBack := CreateBitmap(ptSize.x, ptSize.y, 1, 1, nil);
+ bmAndObject := CreateBitmap(ptSize.x, ptSize.y, 1, 1, nil);
+
+ bmAndMem := CreateCompatibleBitmap(dc, ptSize.x, ptSize.y);
+
+ // Each DC must select a bitmap object to store pixel data.
+ bmBackOld := SelectObject(hdcBack, bmAndBack);
+ bmObjectOld := SelectObject(hdcObject, bmAndObject);
+ bmMemOld := SelectObject(hdcMem, bmAndMem);
+
+ // Set the background color of the source DC to the color.
+ // contained in the parts of the bitmap that should be transparent
+ cColor := SetBkColor(hdcTemp, cTransparentColor);
+
+ // Create the object mask for the bitmap by performing a BitBlt
+ // from the source bitmap to a monochrome bitmap.
+ StretchBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0,
+ orgSize.x, orgSize.y, SRCCOPY);
+
+ // Set the background color of the source DC back to the original
+ // color.
+ SetBkColor(hdcTemp, cColor);
+
+ // Create the inverse of the object mask.
+ BitBlt(hdcBack, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0,
+ NOTSRCCOPY);
+
+ // Copy the background of the main DC to the destination.
+ BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, dc, Rect.Left, Rect.Top,
+ SRCCOPY);
+
+ // Mask out the places where the bitmap will be placed.
+ BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, SRCAND);
+
+ // Mask out the transparent colored pixels on the bitmap.
+// BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcBack, 0, 0, SRCAND);
+ StretchBlt(hdcTemp, 0, 0, OrgSize.x, OrgSize.y, hdcBack, 0, 0,
+ PtSize.x, PtSize.y, SRCAND);
+
+ // XOR the bitmap with the background on the destination DC.
+ StretchBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0,
+ OrgSize.x, OrgSize.y, SRCPAINT);
+
+ // Copy the destination to the screen.
+ BitBlt(dc, Rect.Left, Rect.Top, ptSize.x, ptSize.y, hdcMem, 0, 0,
+ SRCCOPY);
+
+ // Delete the memory bitmaps.
+ DeleteObject(SelectObject(hdcBack, bmBackOld));
+ DeleteObject(SelectObject(hdcObject, bmObjectOld));
+ DeleteObject(SelectObject(hdcMem, bmMemOld));
+ DeleteObject(SelectObject(hdcTemp, OldBitmap));
+
+ // Delete the memory DCs.
+ DeleteDC(hdcMem);
+ DeleteDC(hdcBack);
+ DeleteDC(hdcObject);
+ DeleteDC(hdcTemp);
+end;
+
+{Make the table for a fast CRC.}
+procedure make_crc_table;
+var
+ c: Cardinal;
+ n, k: Integer;
+begin
+
+ {fill the crc table}
+ for n := 0 to 255 do
+ begin
+ c := Cardinal(n);
+ for k := 0 to 7 do
+ begin
+ if Boolean(c and 1) then
+ c := $edb88320 xor (c shr 1)
+ else
+ c := c shr 1;
+ end;
+ crc_table[n] := c;
+ end;
+
+ {The table has already being computated}
+ crc_table_computed := true;
+end;
+
+{Update a running CRC with the bytes buf[0..len-1]--the CRC
+ should be initialized to all 1's, and the transmitted value
+ is the 1's complement of the final running CRC (see the
+ crc() routine below)).}
+function update_crc(crc: {$IFNDEF DelphiBuilder3Less}Cardinal{$ELSE}Integer
+ {$ENDIF}; buf: pByteArray; len: Integer): Cardinal;
+var
+ c: Cardinal;
+ n: Integer;
+begin
+ c := crc;
+
+ {Create the crc table in case it has not being computed yet}
+ if not crc_table_computed then make_crc_table;
+
+ {Update}
+ for n := 0 to len - 1 do
+ c := crc_table[(c XOR buf^[n]) and $FF] XOR (c shr 8);
+
+ {Returns}
+ Result := c;
+end;
+
+{$IFNDEF UseDelphi}
+ function FileExists(Filename: String): Boolean;
+ var
+ FindFile: THandle;
+ FindData: TWin32FindData;
+ begin
+ FindFile := FindFirstFile(PChar(Filename), FindData);
+ Result := FindFile <> INVALID_HANDLE_VALUE;
+ if Result then Windows.FindClose(FindFile);
+ end;
+
+
+{$ENDIF}
+
+{$IFNDEF UseDelphi}
+ {Exception implementation}
+ constructor Exception.Create(Msg: String);
+ begin
+ end;
+{$ENDIF}
+
+{Calculates the paeth predictor}
+function PaethPredictor(a, b, c: Byte): Byte;
+var
+ pa, pb, pc: Integer;
+begin
+ { a = left, b = above, c = upper left }
+ pa := abs(b - c); { distances to a, b, c }
+ pb := abs(a - c);
+ pc := abs(a + b - c * 2);
+
+ { return nearest of a, b, c, breaking ties in order a, b, c }
+ if (pa <= pb) and (pa <= pc) then
+ Result := a
+ else
+ if pb <= pc then
+ Result := b
+ else
+ Result := c;
+end;
+
+{Invert bytes using assembly}
+function ByteSwap(const a: integer): integer;
+asm
+ bswap eax
+end;
+function ByteSwap16(inp:word): word;
+asm
+ bswap eax
+ shr eax, 16
+end;
+
+{Calculates number of bytes for the number of pixels using the}
+{color mode in the paramenter}
+function BytesForPixels(const Pixels: Integer; const ColorType,
+ BitDepth: Byte): Integer;
+begin
+ case ColorType of
+ {Palette and grayscale contains a single value, for palette}
+ {an value of size 2^bitdepth pointing to the palette index}
+ {and grayscale the value from 0 to 2^bitdepth with color intesity}
+ COLOR_GRAYSCALE, COLOR_PALETTE:
+ Result := (Pixels * BitDepth + 7) div 8;
+ {RGB contains 3 values R, G, B with size 2^bitdepth each}
+ COLOR_RGB:
+ Result := (Pixels * BitDepth * 3) div 8;
+ {Contains one value followed by alpha value booth size 2^bitdepth}
+ COLOR_GRAYSCALEALPHA:
+ Result := (Pixels * BitDepth * 2) div 8;
+ {Contains four values size 2^bitdepth, Red, Green, Blue and alpha}
+ COLOR_RGBALPHA:
+ Result := (Pixels * BitDepth * 4) div 8;
+ else
+ Result := 0;
+ end {case ColorType}
+end;
+
+type
+ pChunkClassInfo = ^TChunkClassInfo;
+ TChunkClassInfo = record
+ ClassName: TChunkClass;
+ end;
+
+{Register a chunk type}
+procedure RegisterChunk(ChunkClass: TChunkClass);
+var
+ NewClass: pChunkClassInfo;
+begin
+ {In case the list object has not being created yet}
+ if ChunkClasses = nil then ChunkClasses := TPngPointerList.Create(nil);
+
+ {Add this new class}
+ new(NewClass);
+ NewClass^.ClassName := ChunkClass;
+ ChunkClasses.Add(NewClass);
+end;
+
+{Free chunk class list}
+procedure FreeChunkClassList;
+var
+ i: Integer;
+begin
+ if (ChunkClasses <> nil) then
+ begin
+ FOR i := 0 TO ChunkClasses.Count - 1 do
+ Dispose(pChunkClassInfo(ChunkClasses.Item[i]));
+ ChunkClasses.Free;
+ end;
+end;
+
+{Registering of common chunk classes}
+procedure RegisterCommonChunks;
+begin
+ {Important chunks}
+ RegisterChunk(TChunkIEND);
+ RegisterChunk(TChunkIHDR);
+ RegisterChunk(TChunkIDAT);
+ RegisterChunk(TChunkPLTE);
+ RegisterChunk(TChunkgAMA);
+ RegisterChunk(TChunktRNS);
+
+ {Not so important chunks}
+ RegisterChunk(TChunktIME);
+ RegisterChunk(TChunktEXt);
+ RegisterChunk(TChunkzTXt);
+end;
+
+{Creates a new chunk of this class}
+function CreateClassChunk(Owner: TPngObject; Name: TChunkName): TChunk;
+var
+ i : Integer;
+ NewChunk: TChunkClass;
+begin
+ {Looks for this chunk}
+ NewChunk := TChunk; {In case there is no registered class for this}
+
+ {Looks for this class in all registered chunks}
+ if Assigned(ChunkClasses) then
+ FOR i := 0 TO ChunkClasses.Count - 1 DO
+ begin
+ if pChunkClassInfo(ChunkClasses.Item[i])^.ClassName.GetName = Name then
+ begin
+ NewChunk := pChunkClassInfo(ChunkClasses.Item[i])^.ClassName;
+ break;
+ end;
+ end;
+
+ {Returns chunk class}
+ Result := NewChunk.Create(Owner);
+ Result.fName := Name;
+end;
+
+{ZLIB support}
+
+const
+ ZLIBAllocate = High(Word);
+
+{Initializes ZLIB for decompression}
+function ZLIBInitInflate(Stream: TStream): TZStreamRec2;
+begin
+ {Fill record}
+ Fillchar(Result, SIZEOF(TZStreamRec2), #0);
+
+ {Set internal record information}
+ with Result do
+ begin
+ GetMem(Data, ZLIBAllocate);
+ fStream := Stream;
+ end;
+
+ {Init decompression}
+ InflateInit_(Result.zlib, zlib_version, SIZEOF(TZStreamRec));
+end;
+
+{Initializes ZLIB for compression}
+function ZLIBInitDeflate(Stream: TStream;
+ Level: TCompressionlevel; Size: Cardinal): TZStreamRec2;
+begin
+ {Fill record}
+ Fillchar(Result, SIZEOF(TZStreamRec2), #0);
+
+ {Set internal record information}
+ with Result, ZLIB do
+ begin
+ GetMem(Data, Size);
+ fStream := Stream;
+ next_out := Data;
+ avail_out := Size;
+ end;
+
+ {Inits compression}
+ deflateInit_(Result.zlib, Level, zlib_version, sizeof(TZStreamRec));
+end;
+
+{Terminates ZLIB for compression}
+procedure ZLIBTerminateDeflate(var ZLIBStream: TZStreamRec2);
+begin
+ {Terminates decompression}
+ DeflateEnd(ZLIBStream.zlib);
+ {Free internal record}
+ FreeMem(ZLIBStream.Data, ZLIBAllocate);
+end;
+
+{Terminates ZLIB for decompression}
+procedure ZLIBTerminateInflate(var ZLIBStream: TZStreamRec2);
+begin
+ {Terminates decompression}
+ InflateEnd(ZLIBStream.zlib);
+ {Free internal record}
+ FreeMem(ZLIBStream.Data, ZLIBAllocate);
+end;
+
+{Decompresses ZLIB into a memory address}
+function DecompressZLIB(const Input: Pointer; InputSize: Integer;
+ var Output: Pointer; var OutputSize: Integer;
+ var ErrorOutput: String): Boolean;
+var
+ StreamRec : TZStreamRec;
+ Buffer : Array[Byte] of Byte;
+ InflateRet: Integer;
+begin
+ with StreamRec do
+ begin
+ {Initializes}
+ Result := True;
+ OutputSize := 0;
+
+ {Prepares the data to decompress}
+ FillChar(StreamRec, SizeOf(TZStreamRec), #0);
+ InflateInit_(StreamRec, zlib_version, SIZEOF(TZStreamRec));
+ next_in := Input;
+ avail_in := InputSize;
+
+ {Decodes data}
+ repeat
+ {In case it needs an output buffer}
+ if (avail_out = 0) then
+ begin
+ next_out := @Buffer;
+ avail_out := SizeOf(Buffer);
+ end {if (avail_out = 0)};
+
+ {Decompress and put in output}
+ InflateRet := inflate(StreamRec, 0);
+ if (InflateRet = Z_STREAM_END) or (InflateRet = 0) then
+ begin
+ {Reallocates output buffer}
+ inc(OutputSize, total_out);
+ if Output = nil then
+ GetMem(Output, OutputSize) else ReallocMem(Output, OutputSize);
+ {Copies the new data}
+ CopyMemory(Ptr(Longint(Output) + OutputSize - total_out),
+ @Buffer, total_out);
+ end {if (InflateRet = Z_STREAM_END) or (InflateRet = 0)}
+ {Now tests for errors}
+ else if InflateRet < 0 then
+ begin
+ Result := False;
+ ErrorOutput := StreamRec.msg;
+ InflateEnd(StreamRec);
+ Exit;
+ end {if InflateRet < 0}
+ until InflateRet = Z_STREAM_END;
+
+ {Terminates decompression}
+ InflateEnd(StreamRec);
+ end {with StreamRec}
+
+end;
+
+{Compresses ZLIB into a memory address}
+function CompressZLIB(Input: Pointer; InputSize, CompressionLevel: Integer;
+ var Output: Pointer; var OutputSize: Integer;
+ var ErrorOutput: String): Boolean;
+var
+ StreamRec : TZStreamRec;
+ Buffer : Array[Byte] of Byte;
+ DeflateRet: Integer;
+begin
+ with StreamRec do
+ begin
+ Result := True; {By default returns TRUE as everything might have gone ok}
+ OutputSize := 0; {Initialize}
+ {Prepares the data to compress}
+ FillChar(StreamRec, SizeOf(TZStreamRec), #0);
+ DeflateInit_(StreamRec, CompressionLevel,zlib_version, SIZEOF(TZStreamRec));
+
+ next_in := Input;
+ avail_in := InputSize;
+
+ while avail_in > 0 do
+ begin
+ {When it needs new buffer to stores the compressed data}
+ if avail_out = 0 then
+ begin
+ {Restore buffer}
+ next_out := @Buffer;
+ avail_out := SizeOf(Buffer);
+ end {if avail_out = 0};
+
+ {Compresses}
+ DeflateRet := deflate(StreamRec, Z_FINISH);
+
+ if (DeflateRet = Z_STREAM_END) or (DeflateRet = 0) then
+ begin
+ {Updates the output memory}
+ inc(OutputSize, total_out);
+ if Output = nil then
+ GetMem(Output, OutputSize) else ReallocMem(Output, OutputSize);
+
+ {Copies the new data}
+ CopyMemory(Ptr(Longint(Output) + OutputSize - total_out),
+ @Buffer, total_out);
+ end {if (InflateRet = Z_STREAM_END) or (InflateRet = 0)}
+ {Now tests for errors}
+ else if DeflateRet < 0 then
+ begin
+ Result := False;
+ ErrorOutput := StreamRec.msg;
+ DeflateEnd(StreamRec);
+ Exit;
+ end {if InflateRet < 0}
+
+ end {while avail_in > 0};
+
+ {Finishes compressing}
+ DeflateEnd(StreamRec);
+ end {with StreamRec}
+
+end;
+
+{TPngPointerList implementation}
+
+{Object being created}
+constructor TPngPointerList.Create(AOwner: TPNGObject);
+begin
+ inherited Create; {Let ancestor work}
+ {Holds owner}
+ fOwner := AOwner;
+ {Memory pointer not being used yet}
+ fMemory := nil;
+ {No items yet}
+ fCount := 0;
+end;
+
+{Removes value from the list}
+function TPngPointerList.Remove(Value: Pointer): Pointer;
+var
+ I, Position: Integer;
+begin
+ {Gets item position}
+ Position := -1;
+ FOR I := 0 TO Count - 1 DO
+ if Value = Item[I] then Position := I;
+ {In case a match was found}
+ if Position >= 0 then
+ begin
+ Result := Item[Position]; {Returns pointer}
+ {Remove item and move memory}
+ Dec(fCount);
+ if Position < Integer(FCount) then
+ System.Move(fMemory^[Position + 1], fMemory^[Position],
+ (Integer(fCount) - Position) * SizeOf(Pointer));
+ end {if Position >= 0} else Result := nil
+end;
+
+{Add a new value in the list}
+procedure TPngPointerList.Add(Value: Pointer);
+begin
+ Count := Count + 1;
+ Item[Count - 1] := Value;
+end;
+
+
+{Object being destroyed}
+destructor TPngPointerList.Destroy;
+begin
+ {Release memory if needed}
+ if fMemory <> nil then
+ FreeMem(fMemory, fCount * sizeof(Pointer));
+
+ {Free things}
+ inherited Destroy;
+end;
+
+{Returns one item from the list}
+function TPngPointerList.GetItem(Index: Cardinal): Pointer;
+begin
+ if (Index <= Count - 1) then
+ Result := fMemory[Index]
+ else
+ {In case it's out of bounds}
+ Result := nil;
+end;
+
+{Inserts a new item in the list}
+procedure TPngPointerList.Insert(Value: Pointer; Position: Cardinal);
+begin
+ if (Position < Count) then
+ begin
+ {Increase item count}
+ SetSize(Count + 1);
+ {Move other pointers}
+ if Position < Count then
+ System.Move(fMemory^[Position], fMemory^[Position + 1],
+ (Count - Position - 1) * SizeOf(Pointer));
+ {Sets item}
+ Item[Position] := Value;
+ end;
+end;
+
+{Sets one item from the list}
+procedure TPngPointerList.SetItem(Index: Cardinal; const Value: Pointer);
+begin
+ {If index is in bounds, set value}
+ if (Index <= Count - 1) then
+ fMemory[Index] := Value
+end;
+
+{This method resizes the list}
+procedure TPngPointerList.SetSize(const Size: Cardinal);
+begin
+ {Sets the size}
+ if (fMemory = nil) and (Size > 0) then
+ GetMem(fMemory, Size * SIZEOF(Pointer))
+ else
+ if Size > 0 then {Only realloc if the new size is greater than 0}
+ ReallocMem(fMemory, Size * SIZEOF(Pointer))
+ else
+ {In case user is resize to 0 items}
+ begin
+ FreeMem(fMemory);
+ fMemory := nil;
+ end;
+ {Update count}
+ fCount := Size;
+end;
+
+{TPNGList implementation}
+
+{Removes an item}
+procedure TPNGList.RemoveChunk(Chunk: TChunk);
+begin
+ Remove(Chunk);
+ Chunk.Free
+end;
+
+{Add a new item}
+function TPNGList.Add(ChunkClass: TChunkClass): TChunk;
+var
+ IHDR: TChunkIHDR;
+ IEND: TChunkIEND;
+
+ IDAT: TChunkIDAT;
+ PLTE: TChunkPLTE;
+begin
+ Result := nil; {Default result}
+ {Adding these is not allowed}
+ if (ChunkClass = TChunkIHDR) or (ChunkClass = TChunkIDAT) or
+ (ChunkClass = TChunkPLTE) or (ChunkClass = TChunkIEND) then
+ fOwner.RaiseError(EPngError, EPNGCannotAddChunkText)
+ {Two of these is not allowed}
+ else if ((ChunkClass = TChunkgAMA) and (ItemFromClass(TChunkgAMA) <> nil)) or
+ ((ChunkClass = TChunktRNS) and (ItemFromClass(TChunktRNS) <> nil)) then
+ fOwner.RaiseError(EPngError, EPNGCannotAddChunkText)
+ {There must have an IEND and IHDR chunk}
+ else if (ItemFromClass(TChunkIEND) = nil) or
+ (ItemFromClass(TChunkIHDR) = nil) then
+ fOwner.RaiseError(EPngError, EPNGCannotAddInvalidImageText)
+ else
+ begin
+ {Get common chunks}
+ IHDR := ItemFromClass(TChunkIHDR) as TChunkIHDR;
+ IEND := ItemFromClass(TChunkIEND) as TChunkIEND;
+ {Create new chunk}
+ Result := ChunkClass.Create(Owner);
+ {Add to the list}
+ if (ChunkClass = TChunkgAMA) then
+ Insert(Result, IHDR.Index + 1)
+ {Transparency chunk (fix by Ian Boyd)}
+ else if (ChunkClass = TChunktRNS) then
+ begin
+ {Transparecy chunk must be after PLTE; before IDAT}
+ IDAT := ItemFromClass(TChunkIDAT) as TChunkIDAT;
+ PLTE := ItemFromClass(TChunkPLTE) as TChunkPLTE;
+
+ if Assigned(PLTE) then
+ Insert(Result, PLTE.Index + 1)
+ else if Assigned(IDAT) then
+ Insert(Result, IDAT.Index)
+ else
+ Insert(Result, IHDR.Index + 1)
+ end
+ else {All other chunks}
+ Insert(Result, IEND.Index);
+ end {if}
+end;
+
+{Returns item from the list}
+function TPNGList.GetItem(Index: Cardinal): TChunk;
+begin
+ Result := inherited GetItem(Index);
+end;
+
+{Returns first item from the list using the class from parameter}
+function TPNGList.ItemFromClass(ChunkClass: TChunkClass): TChunk;
+var
+ i: Integer;
+begin
+ Result := nil; {Initial result}
+ FOR i := 0 TO Count - 1 DO
+ {Test if this item has the same class}
+ if Item[i] is ChunkClass then
+ begin
+ {Returns this item and exit}
+ Result := Item[i];
+ break;
+ end {if}
+end;
+
+{$IFNDEF UseDelphi}
+
+ {TStream implementation}
+
+ {Copies all from another stream}
+ function TStream.CopyFrom(Source: TStream; Count: Cardinal): Cardinal;
+ const
+ MaxBytes = $f000;
+ var
+ Buffer: PChar;
+ BufSize, N: Cardinal;
+ begin
+ {If count is zero, copy everything from Source}
+ if Count = 0 then
+ begin
+ Source.Seek(0, soFromBeginning);
+ Count := Source.Size;
+ end;
+
+ Result := Count; {Returns the number of bytes readed}
+ {Allocates memory}
+ if Count > MaxBytes then BufSize := MaxBytes else BufSize := Count;
+ GetMem(Buffer, BufSize);
+
+ {Copy memory}
+ while Count > 0 do
+ begin
+ if Count > BufSize then N := BufSize else N := Count;
+ Source.Read(Buffer^, N);
+ Write(Buffer^, N);
+ dec(Count, N);
+ end;
+
+ {Deallocates memory}
+ FreeMem(Buffer, BufSize);
+ end;
+
+{Set current stream position}
+procedure TStream.SetPosition(const Value: Longint);
+begin
+ Seek(Value, soFromBeginning);
+end;
+
+{Returns position}
+function TStream.GetPosition: Longint;
+begin
+ Result := Seek(0, soFromCurrent);
+end;
+
+ {Returns stream size}
+function TStream.GetSize: Longint;
+ var
+ Pos: Cardinal;
+ begin
+ Pos := Seek(0, soFromCurrent);
+ Result := Seek(0, soFromEnd);
+ Seek(Pos, soFromCurrent);
+ end;
+
+ {TFileStream implementation}
+
+ {Filestream object being created}
+ constructor TFileStream.Create(Filename: String; Mode: TFileStreamModeSet);
+ {Makes file mode}
+ function OpenMode: DWORD;
+ begin
+ Result := 0;
+ if fsmRead in Mode then Result := GENERIC_READ;
+ if (fsmWrite in Mode) or (fsmCreate in Mode) then
+ Result := Result OR GENERIC_WRITE;
+ end;
+ const
+ IsCreate: Array[Boolean] of Integer = (OPEN_ALWAYS, CREATE_ALWAYS);
+ begin
+ {Call ancestor}
+ inherited Create;
+
+ {Create handle}
+ fHandle := CreateFile(PChar(Filename), OpenMode, FILE_SHARE_READ or
+ FILE_SHARE_WRITE, nil, IsCreate[fsmCreate in Mode], 0, 0);
+ {Store mode}
+ FileMode := Mode;
+ end;
+
+ {Filestream object being destroyed}
+ destructor TFileStream.Destroy;
+ begin
+ {Terminates file and close}
+ if FileMode = [fsmWrite] then
+ SetEndOfFile(fHandle);
+ CloseHandle(fHandle);
+
+ {Call ancestor}
+ inherited Destroy;
+ end;
+
+ {Writes data to the file}
+ function TFileStream.Write(const Buffer; Count: Longint): Cardinal;
+ begin
+ if not WriteFile(fHandle, Buffer, Count, Result, nil) then
+ Result := 0;
+ end;
+
+ {Reads data from the file}
+ function TFileStream.Read(var Buffer; Count: Longint): Cardinal;
+ begin
+ if not ReadFile(fHandle, Buffer, Count, Result, nil) then
+ Result := 0;
+ end;
+
+ {Seeks the file position}
+ function TFileStream.Seek(Offset: Integer; Origin: Word): Longint;
+ begin
+ Result := SetFilePointer(fHandle, Offset, nil, Origin);
+ end;
+
+ {Sets the size of the file}
+ procedure TFileStream.SetSize(const Value: Longint);
+ begin
+ Seek(Value, soFromBeginning);
+ SetEndOfFile(fHandle);
+ end;
+
+ {TResourceStream implementation}
+
+ {Creates the resource stream}
+ constructor TResourceStream.Create(Instance: HInst; const ResName: String;
+ ResType: PChar);
+ var
+ ResID: HRSRC;
+ ResGlobal: HGlobal;
+ begin
+ {Obtains the resource ID}
+ ResID := FindResource(hInstance, PChar(ResName), RT_RCDATA);
+ if ResID = 0 then raise EPNGError.Create('');
+ {Obtains memory and size}
+ ResGlobal := LoadResource(hInstance, ResID);
+ Size := SizeOfResource(hInstance, ResID);
+ Memory := LockResource(ResGlobal);
+ if (ResGlobal = 0) or (Memory = nil) then EPNGError.Create('');
+ end;
+
+
+ {Setting resource stream size is not supported}
+ procedure TResourceStream.SetSize(const Value: Integer);
+ begin
+ end;
+
+ {Writing into a resource stream is not supported}
+ function TResourceStream.Write(const Buffer; Count: Integer): Cardinal;
+ begin
+ Result := 0;
+ end;
+
+ {Reads data from the stream}
+ function TResourceStream.Read(var Buffer; Count: Integer): Cardinal;
+ begin
+ //Returns data
+ CopyMemory(@Buffer, Ptr(Longint(Memory) + Position), Count);
+ //Update position
+ inc(Position, Count);
+ //Returns
+ Result := Count;
+ end;
+
+ {Seeks data}
+ function TResourceStream.Seek(Offset: Integer; Origin: Word): Longint;
+ begin
+ {Move depending on the origin}
+ case Origin of
+ soFromBeginning: Position := Offset;
+ soFromCurrent: inc(Position, Offset);
+ soFromEnd: Position := Size + Offset;
+ end;
+
+ {Returns the current position}
+ Result := Position;
+ end;
+
+{$ENDIF}
+
+{TChunk implementation}
+
+{Resizes the data}
+procedure TChunk.ResizeData(const NewSize: Cardinal);
+begin
+ fDataSize := NewSize;
+ ReallocMem(fData, NewSize + 1);
+end;
+
+{Returns index from list}
+function TChunk.GetIndex: Integer;
+var
+ i: Integer;
+begin
+ Result := -1; {Avoiding warnings}
+ {Searches in the list}
+ FOR i := 0 TO Owner.Chunks.Count - 1 DO
+ if Owner.Chunks.Item[i] = Self then
+ begin
+ {Found match}
+ Result := i;
+ exit;
+ end {for i}
+end;
+
+{Returns pointer to the TChunkIHDR}
+function TChunk.GetHeader: TChunkIHDR;
+begin
+ Result := Owner.Chunks.Item[0] as TChunkIHDR;
+end;
+
+{Assigns from another TChunk}
+procedure TChunk.Assign(Source: TChunk);
+begin
+ {Copy properties}
+ fName := Source.fName;
+ {Set data size and realloc}
+ ResizeData(Source.fDataSize);
+
+ {Copy data (if there's any)}
+ if fDataSize > 0 then CopyMemory(fData, Source.fData, fDataSize);
+end;
+
+{Chunk being created}
+constructor TChunk.Create(Owner: TPngObject);
+var
+ ChunkName: String;
+begin
+ {Ancestor create}
+ inherited Create;
+
+ {If it's a registered class, set the chunk name based on the class}
+ {name. For instance, if the class name is TChunkgAMA, the GAMA part}
+ {will become the chunk name}
+ ChunkName := Copy(ClassName, Length('TChunk') + 1, Length(ClassName));
+ if Length(ChunkName) = 4 then CopyMemory(@fName[0], @ChunkName[1], 4);
+
+ {Initialize data holder}
+ GetMem(fData, 1);
+ fDataSize := 0;
+ {Record owner}
+ fOwner := Owner;
+end;
+
+{Chunk being destroyed}
+destructor TChunk.Destroy;
+begin
+ {Free data holder}
+ FreeMem(fData, fDataSize + 1);
+ {Let ancestor destroy}
+ inherited Destroy;
+end;
+
+{Returns the chunk name 1}
+function TChunk.GetChunkName: String;
+begin
+ Result := fName
+end;
+
+{Returns the chunk name 2}
+class function TChunk.GetName: String;
+begin
+ {For avoid writing GetName for each TChunk descendent, by default for}
+ {classes which don't declare GetName, it will look for the class name}
+ {to extract the chunk kind. Example, if the class name is TChunkIEND }
+ {this method extracts and returns IEND}
+ Result := Copy(ClassName, Length('TChunk') + 1, Length(ClassName));
+end;
+
+{Saves the data to the stream}
+function TChunk.SaveData(Stream: TStream): Boolean;
+var
+ ChunkSize, ChunkCRC: Cardinal;
+begin
+ {First, write the size for the following data in the chunk}
+ ChunkSize := ByteSwap(DataSize);
+ Stream.Write(ChunkSize, 4);
+ {The chunk name}
+ Stream.Write(fName, 4);
+ {If there is data for the chunk, write it}
+ if DataSize > 0 then Stream.Write(Data^, DataSize);
+ {Calculates and write CRC}
+ ChunkCRC := update_crc($ffffffff, @fName[0], 4);
+ ChunkCRC := Byteswap(update_crc(ChunkCRC, Data, DataSize) xor $ffffffff);
+ Stream.Write(ChunkCRC, 4);
+
+ {Returns that everything went ok}
+ Result := TRUE;
+end;
+
+{Saves the chunk to the stream}
+function TChunk.SaveToStream(Stream: TStream): Boolean;
+begin
+ Result := SaveData(Stream)
+end;
+
+
+{Loads the chunk from a stream}
+function TChunk.LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean;
+var
+ CheckCRC: Cardinal;
+ {$IFDEF CheckCRC}RightCRC: Cardinal;{$ENDIF}
+begin
+ {Copies data from source}
+ ResizeData(Size);
+ if Size > 0 then Stream.Read(fData^, Size);
+ {Reads CRC}
+ Stream.Read(CheckCRC, 4);
+ CheckCrc := ByteSwap(CheckCRC);
+
+ {Check if crc readed is valid}
+ {$IFDEF CheckCRC}
+ RightCRC := update_crc($ffffffff, @ChunkName[0], 4);
+ RightCRC := update_crc(RightCRC, fData, Size) xor $ffffffff;
+ Result := RightCRC = CheckCrc;
+
+ {Handle CRC error}
+ if not Result then
+ begin
+ {In case it coult not load chunk}
+ Owner.RaiseError(EPngInvalidCRC, EPngInvalidCRCText);
+ exit;
+ end
+ {$ELSE}Result := TRUE; {$ENDIF}
+
+end;
+
+{TChunktIME implementation}
+
+{Chunk being loaded from a stream}
+function TChunktIME.LoadFromStream(Stream: TStream;
+ const ChunkName: TChunkName; Size: Integer): Boolean;
+begin
+ {Let ancestor load the data}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+ if not Result or (Size <> 7) then exit; {Size must be 7}
+
+ {Reads data}
+ fYear := ((pByte(Longint(Data) )^) * 256)+ (pByte(Longint(Data) + 1)^);
+ fMonth := pByte(Longint(Data) + 2)^;
+ fDay := pByte(Longint(Data) + 3)^;
+ fHour := pByte(Longint(Data) + 4)^;
+ fMinute := pByte(Longint(Data) + 5)^;
+ fSecond := pByte(Longint(Data) + 6)^;
+end;
+
+{Saving the chunk to a stream}
+function TChunktIME.SaveToStream(Stream: TStream): Boolean;
+begin
+ {Update data}
+ ResizeData(7); {Make sure the size is 7}
+ pWord(Data)^ := Year;
+ pByte(Longint(Data) + 2)^ := Month;
+ pByte(Longint(Data) + 3)^ := Day;
+ pByte(Longint(Data) + 4)^ := Hour;
+ pByte(Longint(Data) + 5)^ := Minute;
+ pByte(Longint(Data) + 6)^ := Second;
+
+ {Let inherited save data}
+ Result := inherited SaveToStream(Stream);
+end;
+
+{TChunkztXt implementation}
+
+{Loading the chunk from a stream}
+function TChunkzTXt.LoadFromStream(Stream: TStream;
+ const ChunkName: TChunkName; Size: Integer): Boolean;
+var
+ ErrorOutput: String;
+ CompressionMethod: Byte;
+ Output: Pointer;
+ OutputSize: Integer;
+begin
+ {Load data from stream and validate}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+ if not Result or (Size < 4) then exit;
+ fKeyword := PChar(Data); {Get keyword and compression method bellow}
+ CompressionMethod := pByte(Longint(fKeyword) + Length(fKeyword))^;
+ fText := '';
+
+ {In case the compression is 0 (only one accepted by specs), reads it}
+ if CompressionMethod = 0 then
+ begin
+ Output := nil;
+ if DecompressZLIB(PChar(Longint(Data) + Length(fKeyword) + 2),
+ Size - Length(fKeyword) - 2, Output, OutputSize, ErrorOutput) then
+ begin
+ SetLength(fText, OutputSize);
+ CopyMemory(@fText[1], Output, OutputSize);
+ end {if DecompressZLIB(...};
+ FreeMem(Output);
+ end {if CompressionMethod = 0}
+
+end;
+
+{Saving the chunk to a stream}
+function TChunkztXt.SaveToStream(Stream: TStream): Boolean;
+var
+ Output: Pointer;
+ OutputSize: Integer;
+ ErrorOutput: String;
+begin
+ Output := nil; {Initializes output}
+ if fText = '' then fText := ' ';
+
+ {Compresses the data}
+ if CompressZLIB(@fText[1], Length(fText), Owner.CompressionLevel, Output,
+ OutputSize, ErrorOutput) then
+ begin
+ {Size is length from keyword, plus a null character to divide}
+ {plus the compression method, plus the length of the text (zlib compressed)}
+ ResizeData(Length(fKeyword) + 2 + OutputSize);
+
+ Fillchar(Data^, DataSize, #0);
+ {Copies the keyword data}
+ if Keyword <> '' then
+ CopyMemory(Data, @fKeyword[1], Length(Keyword));
+ {Compression method 0 (inflate/deflate)}
+ pByte(Ptr(Longint(Data) + Length(Keyword) + 1))^ := 0;
+ if OutputSize > 0 then
+ CopyMemory(Ptr(Longint(Data) + Length(Keyword) + 2), Output, OutputSize);
+
+ {Let ancestor calculate crc and save}
+ Result := SaveData(Stream);
+ end {if CompressZLIB(...} else Result := False;
+
+ {Frees output}
+ if Output <> nil then FreeMem(Output)
+end;
+
+{TChunktEXt implementation}
+
+{Assigns from another text chunk}
+procedure TChunktEXt.Assign(Source: TChunk);
+begin
+ fKeyword := TChunktEXt(Source).fKeyword;
+ fText := TChunktEXt(Source).fText;
+end;
+
+{Loading the chunk from a stream}
+function TChunktEXt.LoadFromStream(Stream: TStream;
+ const ChunkName: TChunkName; Size: Integer): Boolean;
+begin
+ {Load data from stream and validate}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+ if not Result or (Size < 3) then exit;
+ {Get text}
+ fKeyword := PChar(Data);
+ SetLength(fText, Size - Length(fKeyword) - 1);
+ CopyMemory(@fText[1], Ptr(Longint(Data) + Length(fKeyword) + 1),
+ Length(fText));
+end;
+
+{Saving the chunk to a stream}
+function TChunktEXt.SaveToStream(Stream: TStream): Boolean;
+begin
+ {Size is length from keyword, plus a null character to divide}
+ {plus the length of the text}
+ ResizeData(Length(fKeyword) + 1 + Length(fText));
+ Fillchar(Data^, DataSize, #0);
+ {Copy data}
+ if Keyword <> '' then
+ CopyMemory(Data, @fKeyword[1], Length(Keyword));
+ if Text <> '' then
+ CopyMemory(Ptr(Longint(Data) + Length(Keyword) + 1), @fText[1],
+ Length(Text));
+ {Let ancestor calculate crc and save}
+ Result := inherited SaveToStream(Stream);
+end;
+
+
+{TChunkIHDR implementation}
+
+{Chunk being created}
+constructor TChunkIHDR.Create(Owner: TPngObject);
+begin
+ {Call inherited}
+ inherited Create(Owner);
+ {Prepare pointers}
+ ImageHandle := 0;
+ ImageDC := 0;
+end;
+
+{Chunk being destroyed}
+destructor TChunkIHDR.Destroy;
+begin
+ {Free memory}
+ FreeImageData();
+
+ {Calls TChunk destroy}
+ inherited Destroy;
+end;
+
+{Assigns from another IHDR chunk}
+procedure TChunkIHDR.Assign(Source: TChunk);
+begin
+ {Copy the IHDR data}
+ if Source is TChunkIHDR then
+ begin
+ {Copy IHDR values}
+ IHDRData := TChunkIHDR(Source).IHDRData;
+
+ {Prepare to hold data by filling BitmapInfo structure and}
+ {resizing ImageData and ImageAlpha memory allocations}
+ PrepareImageData();
+
+ {Copy image data}
+ CopyMemory(ImageData, TChunkIHDR(Source).ImageData,
+ BytesPerRow * Integer(Height));
+ CopyMemory(ImageAlpha, TChunkIHDR(Source).ImageAlpha,
+ Integer(Width) * Integer(Height));
+
+ {Copy palette colors}
+ BitmapInfo.bmiColors := TChunkIHDR(Source).BitmapInfo.bmiColors;
+ end
+ else
+ Owner.RaiseError(EPNGError, EPNGCannotAssignChunkText);
+end;
+
+{Release allocated image data}
+procedure TChunkIHDR.FreeImageData;
+begin
+ {Free old image data}
+ if ImageHandle <> 0 then DeleteObject(ImageHandle);
+ if ImageDC <> 0 then DeleteDC(ImageDC);
+ if ImageAlpha <> nil then FreeMem(ImageAlpha);
+ {$IFDEF Store16bits}
+ if ExtraImageData <> nil then FreeMem(ExtraImageData);
+ {$ENDIF}
+ ImageHandle := 0; ImageDC := 0; ImageAlpha := nil; ImageData := nil;
+end;
+
+{Chunk being loaded from a stream}
+function TChunkIHDR.LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean;
+begin
+ {Let TChunk load it}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+ if not Result then Exit;
+
+ {Now check values}
+ {Note: It's recommended by png specification to make sure that the size}
+ {must be 13 bytes to be valid, but some images with 14 bytes were found}
+ {which could be loaded by internet explorer and other tools}
+ if (fDataSize < SIZEOF(TIHdrData)) then
+ begin
+ {Ihdr must always have at least 13 bytes}
+ Result := False;
+ Owner.RaiseError(EPNGInvalidIHDR, EPNGInvalidIHDRText);
+ exit;
+ end;
+
+ {Everything ok, reads IHDR}
+ IHDRData := pIHDRData(fData)^;
+ IHDRData.Width := ByteSwap(IHDRData.Width);
+ IHDRData.Height := ByteSwap(IHDRData.Height);
+
+ {The width and height must not be larger than 65535 pixels}
+ if (IHDRData.Width > High(Word)) or (IHDRData.Height > High(Word)) then
+ begin
+ Result := False;
+ Owner.RaiseError(EPNGSizeExceeds, EPNGSizeExceedsText);
+ exit;
+ end {if IHDRData.Width > High(Word)};
+ {Compression method must be 0 (inflate/deflate)}
+ if (IHDRData.CompressionMethod <> 0) then
+ begin
+ Result := False;
+ Owner.RaiseError(EPNGUnknownCompression, EPNGUnknownCompressionText);
+ exit;
+ end;
+ {Interlace must be either 0 (none) or 7 (adam7)}
+ if (IHDRData.InterlaceMethod <> 0) and (IHDRData.InterlaceMethod <> 1) then
+ begin
+ Result := False;
+ Owner.RaiseError(EPNGUnknownInterlace, EPNGUnknownInterlaceText);
+ exit;
+ end;
+
+ {Updates owner properties}
+ Owner.InterlaceMethod := TInterlaceMethod(IHDRData.InterlaceMethod);
+
+ {Prepares data to hold image}
+ PrepareImageData();
+end;
+
+{Saving the IHDR chunk to a stream}
+function TChunkIHDR.SaveToStream(Stream: TStream): Boolean;
+begin
+ {Ignore 2 bits images}
+ if BitDepth = 2 then BitDepth := 4;
+
+ {It needs to do is update the data with the IHDR data}
+ {structure containing the write values}
+ ResizeData(SizeOf(TIHDRData));
+ pIHDRData(fData)^ := IHDRData;
+ {..byteswap 4 byte types}
+ pIHDRData(fData)^.Width := ByteSwap(pIHDRData(fData)^.Width);
+ pIHDRData(fData)^.Height := ByteSwap(pIHDRData(fData)^.Height);
+ {..update interlace method}
+ pIHDRData(fData)^.InterlaceMethod := Byte(Owner.InterlaceMethod);
+ {..and then let the ancestor SaveToStream do the hard work}
+ Result := inherited SaveToStream(Stream);
+end;
+
+{Resizes the image data to fill the color type, bit depth, }
+{width and height parameters}
+procedure TChunkIHDR.PrepareImageData();
+
+ {Set the bitmap info}
+ procedure SetInfo(const Bitdepth: Integer; const Palette: Boolean);
+ begin
+
+ {Copy if the bitmap contain palette entries}
+ HasPalette := Palette;
+ {Initialize the structure with zeros}
+ fillchar(BitmapInfo, sizeof(BitmapInfo), #0);
+ {Fill the strucutre}
+ with BitmapInfo.bmiHeader do
+ begin
+ biSize := sizeof(TBitmapInfoHeader);
+ biHeight := Height;
+ biWidth := Width;
+ biPlanes := 1;
+ biBitCount := BitDepth;
+ biCompression := BI_RGB;
+ end {with BitmapInfo.bmiHeader}
+ end;
+begin
+ {Prepare bitmap info header}
+ Fillchar(BitmapInfo, sizeof(TMaxBitmapInfo), #0);
+ {Release old image data}
+ FreeImageData();
+
+ {Obtain number of bits for each pixel}
+ case ColorType of
+ COLOR_GRAYSCALE, COLOR_PALETTE, COLOR_GRAYSCALEALPHA:
+ case BitDepth of
+ {These are supported by windows}
+ 1, 4, 8: SetInfo(BitDepth, TRUE);
+ {2 bits for each pixel is not supported by windows bitmap}
+ 2 : SetInfo(4, TRUE);
+ {Also 16 bits (2 bytes) for each pixel is not supported}
+ {and should be transormed into a 8 bit grayscale}
+ 16 : SetInfo(8, TRUE);
+ end;
+ {Only 1 byte (8 bits) is supported}
+ COLOR_RGB, COLOR_RGBALPHA: SetInfo(24, FALSE);
+ end {case ColorType};
+ {Number of bytes for each scanline}
+ BytesPerRow := (((BitmapInfo.bmiHeader.biBitCount * Width) + 31)
+ and not 31) div 8;
+
+ {Build array for alpha information, if necessary}
+ if (ColorType = COLOR_RGBALPHA) or (ColorType = COLOR_GRAYSCALEALPHA) then
+ begin
+ GetMem(ImageAlpha, Integer(Width) * Integer(Height));
+ FillChar(ImageAlpha^, Integer(Width) * Integer(Height), #0);
+ end;
+
+ {Build array for extra byte information}
+ {$IFDEF Store16bits}
+ if (BitDepth = 16) then
+ begin
+ GetMem(ExtraImageData, BytesPerRow * Integer(Height));
+ FillChar(ExtraImageData^, BytesPerRow * Integer(Height), #0);
+ end;
+ {$ENDIF}
+
+ {Creates the image to hold the data, CreateDIBSection does a better}
+ {work in allocating necessary memory}
+ ImageDC := CreateCompatibleDC(0);
+ ImageHandle := CreateDIBSection(ImageDC, pBitmapInfo(@BitmapInfo)^,
+ DIB_RGB_COLORS, ImageData, 0, 0);
+
+ {Clears the old palette (if any)}
+ with Owner do
+ if TempPalette <> 0 then
+ begin
+ DeleteObject(TempPalette);
+ TempPalette := 0;
+ end {with Owner, if TempPalette <> 0};
+
+ {Build array and allocate bytes for each row}
+ zeromemory(ImageData, BytesPerRow * Integer(Height));
+end;
+
+{TChunktRNS implementation}
+
+{$IFNDEF UseDelphi}
+function CompareMem(P1, P2: pByte; const Size: Integer): Boolean;
+var i: Integer;
+begin
+ Result := True;
+ for i := 1 to Size do
+ begin
+ if P1^ <> P2^ then Result := False;
+ inc(P1); inc(P2);
+ end {for i}
+end;
+{$ENDIF}
+
+{Sets the transpararent color}
+procedure TChunktRNS.SetTransparentColor(const Value: ColorRef);
+var
+ i: Byte;
+ LookColor: TRGBQuad;
+begin
+ {Clears the palette values}
+ Fillchar(PaletteValues, SizeOf(PaletteValues), #0);
+ {Sets that it uses bit transparency}
+ fBitTransparency := True;
+
+
+ {Depends on the color type}
+ with Header do
+ case ColorType of
+ COLOR_GRAYSCALE:
+ begin
+ Self.ResizeData(2);
+ pWord(@PaletteValues[0])^ := ByteSwap16(GetRValue(Value));
+ end;
+ COLOR_RGB:
+ begin
+ Self.ResizeData(6);
+ pWord(@PaletteValues[0])^ := ByteSwap16(GetRValue(Value));
+ pWord(@PaletteValues[2])^ := ByteSwap16(GetGValue(Value));
+ pWord(@PaletteValues[4])^ := ByteSwap16(GetBValue(Value));
+ end;
+ COLOR_PALETTE:
+ begin
+ {Creates a RGBQuad to search for the color}
+ LookColor.rgbRed := GetRValue(Value);
+ LookColor.rgbGreen := GetGValue(Value);
+ LookColor.rgbBlue := GetBValue(Value);
+ {Look in the table for the entry}
+ for i := 0 to 255 do
+ if CompareMem(@BitmapInfo.bmiColors[i], @LookColor, 3) then
+ Break;
+ {Fill the transparency table}
+ Fillchar(PaletteValues, i, 255);
+ Self.ResizeData(i + 1)
+
+ end
+ end {case / with};
+
+end;
+
+{Returns the transparent color for the image}
+function TChunktRNS.GetTransparentColor: ColorRef;
+var
+ PaletteChunk: TChunkPLTE;
+ i: Integer;
+begin
+ Result := 0; {Default: Unknown transparent color}
+
+ {Depends on the color type}
+ with Header do
+ case ColorType of
+ COLOR_GRAYSCALE:
+ Result := RGB(PaletteValues[0], PaletteValues[0],
+ PaletteValues[0]);
+ COLOR_RGB:
+ Result := RGB(PaletteValues[1], PaletteValues[3], PaletteValues[5]);
+ COLOR_PALETTE:
+ begin
+ {Obtains the palette chunk}
+ PaletteChunk := Owner.Chunks.ItemFromClass(TChunkPLTE) as TChunkPLTE;
+
+ {Looks for an entry with 0 transparency meaning that it is the}
+ {full transparent entry}
+ for i := 0 to Self.DataSize - 1 do
+ if PaletteValues[i] = 0 then
+ with PaletteChunk.GetPaletteItem(i) do
+ begin
+ Result := RGB(rgbRed, rgbGreen, rgbBlue);
+ break
+ end
+ end {COLOR_PALETTE}
+ end {case Header.ColorType};
+end;
+
+{Saving the chunk to a stream}
+function TChunktRNS.SaveToStream(Stream: TStream): Boolean;
+begin
+ {Copy palette into data buffer}
+ if DataSize <= 256 then
+ CopyMemory(fData, @PaletteValues[0], DataSize);
+
+ Result := inherited SaveToStream(Stream);
+end;
+
+{Assigns from another chunk}
+procedure TChunktRNS.Assign(Source: TChunk);
+begin
+ CopyMemory(@PaletteValues[0], @TChunkTrns(Source).PaletteValues[0], 256);
+ fBitTransparency := TChunkTrns(Source).fBitTransparency;
+ inherited Assign(Source);
+end;
+
+{Loads the chunk from a stream}
+function TChunktRNS.LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean;
+var
+ i, Differ255: Integer;
+begin
+ {Let inherited load}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+
+ if not Result then Exit;
+
+ {Make sure size is correct}
+ if Size > 256 then Owner.RaiseError(EPNGInvalidPalette,
+ EPNGInvalidPaletteText);
+
+ {The unset items should have value 255}
+ Fillchar(PaletteValues[0], 256, 255);
+ {Copy the other values}
+ CopyMemory(@PaletteValues[0], fData, Size);
+
+ {Create the mask if needed}
+ case Header.ColorType of
+ {Mask for grayscale and RGB}
+ COLOR_RGB, COLOR_GRAYSCALE: fBitTransparency := True;
+ COLOR_PALETTE:
+ begin
+ Differ255 := 0; {Count the entries with a value different from 255}
+ {Tests if it uses bit transparency}
+ for i := 0 to Size - 1 do
+ if PaletteValues[i] <> 255 then inc(Differ255);
+
+ {If it has one value different from 255 it is a bit transparency}
+ fBitTransparency := (Differ255 = 1);
+ end {COLOR_PALETTE}
+ end {case Header.ColorType};
+
+end;
+
+{Prepares the image palette}
+procedure TChunkIDAT.PreparePalette;
+var
+ Entries: Word;
+ j : Integer;
+begin
+ {In case the image uses grayscale, build a grayscale palette}
+ with Header do
+ if (ColorType = COLOR_GRAYSCALE) or (ColorType = COLOR_GRAYSCALEALPHA) then
+ begin
+ {Calculate total number of palette entries}
+ Entries := (1 shl Byte(BitmapInfo.bmiHeader.biBitCount));
+
+ FOR j := 0 TO Entries - 1 DO
+ with BitmapInfo.bmiColors[j] do
+ begin
+
+ {Calculate each palette entry}
+ rgbRed := fOwner.GammaTable[MulDiv(j, 255, Entries - 1)];
+ rgbGreen := rgbRed;
+ rgbBlue := rgbRed;
+ end {with BitmapInfo.bmiColors[j]}
+ end {if ColorType = COLOR_GRAYSCALE..., with Header}
+end;
+
+{Reads from ZLIB}
+function TChunkIDAT.IDATZlibRead(var ZLIBStream: TZStreamRec2;
+ Buffer: Pointer; Count: Integer; var EndPos: Integer;
+ var crcfile: Cardinal): Integer;
+var
+ ProcResult : Integer;
+ IDATHeader : Array[0..3] of char;
+ IDATCRC : Cardinal;
+begin
+ {Uses internal record pointed by ZLIBStream to gather information}
+ with ZLIBStream, ZLIBStream.zlib do
+ begin
+ {Set the buffer the zlib will read into}
+ next_out := Buffer;
+ avail_out := Count;
+
+ {Decode until it reach the Count variable}
+ while avail_out > 0 do
+ begin
+ {In case it needs more data and it's in the end of a IDAT chunk,}
+ {it means that there are more IDAT chunks}
+ if (fStream.Position = EndPos) and (avail_out > 0) and
+ (avail_in = 0) then
+ begin
+ {End this chunk by reading and testing the crc value}
+ fStream.Read(IDATCRC, 4);
+
+ {$IFDEF CheckCRC}
+ if crcfile xor $ffffffff <> Cardinal(ByteSwap(IDATCRC)) then
+ begin
+ Result := -1;
+ Owner.RaiseError(EPNGInvalidCRC, EPNGInvalidCRCText);
+ exit;
+ end;
+ {$ENDIF}
+
+ {Start reading the next chunk}
+ fStream.Read(EndPos, 4); {Reads next chunk size}
+ fStream.Read(IDATHeader[0], 4); {Next chunk header}
+ {It must be a IDAT chunk since image data is required and PNG}
+ {specification says that multiple IDAT chunks must be consecutive}
+ if IDATHeader <> 'IDAT' then
+ begin
+ Owner.RaiseError(EPNGMissingMultipleIDAT, EPNGMissingMultipleIDATText);
+ result := -1;
+ exit;
+ end;
+
+ {Calculate chunk name part of the crc}
+ {$IFDEF CheckCRC}
+ crcfile := update_crc($ffffffff, @IDATHeader[0], 4);
+ {$ENDIF}
+ EndPos := fStream.Position + ByteSwap(EndPos);
+ end;
+
+
+ {In case it needs compressed data to read from}
+ if avail_in = 0 then
+ begin
+ {In case it's trying to read more than it is avaliable}
+ if fStream.Position + ZLIBAllocate > EndPos then
+ avail_in := fStream.Read(Data^, EndPos - fStream.Position)
+ else
+ avail_in := fStream.Read(Data^, ZLIBAllocate);
+ {Update crc}
+ {$IFDEF CheckCRC}
+ crcfile := update_crc(crcfile, Data, avail_in);
+ {$ENDIF}
+
+ {In case there is no more compressed data to read from}
+ if avail_in = 0 then
+ begin
+ Result := Count - avail_out;
+ Exit;
+ end;
+
+ {Set next buffer to read and record current position}
+ next_in := Data;
+
+ end {if avail_in = 0};
+
+ ProcResult := inflate(zlib, 0);
+
+ {In case the result was not sucessfull}
+ if (ProcResult < 0) then
+ begin
+ Result := -1;
+ Owner.RaiseError(EPNGZLIBError,
+ EPNGZLIBErrorText + zliberrors[procresult]);
+ exit;
+ end;
+
+ end {while avail_out > 0};
+
+ end {with};
+
+ {If everything gone ok, it returns the count bytes}
+ Result := Count;
+end;
+
+{TChunkIDAT implementation}
+
+const
+ {Adam 7 interlacing values}
+ RowStart: array[0..6] of Integer = (0, 0, 4, 0, 2, 0, 1);
+ ColumnStart: array[0..6] of Integer = (0, 4, 0, 2, 0, 1, 0);
+ RowIncrement: array[0..6] of Integer = (8, 8, 8, 4, 4, 2, 2);
+ ColumnIncrement: array[0..6] of Integer = (8, 8, 4, 4, 2, 2, 1);
+
+{Copy interlaced images with 1 byte for R, G, B}
+procedure TChunkIDAT.CopyInterlacedRGB8(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col * 3);
+ repeat
+ {Copy this row}
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+
+ {Move to next column}
+ inc(Src, 3);
+ inc(Dest, ColumnIncrement[Pass] * 3 - 3);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy interlaced images with 2 bytes for R, G, B}
+procedure TChunkIDAT.CopyInterlacedRGB16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col * 3);
+ repeat
+ {Copy this row}
+ Byte(Dest^) := Owner.GammaTable[pByte(Longint(Src) + 4)^]; inc(Dest);
+ Byte(Dest^) := Owner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := Owner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+ {$IFDEF Store16bits}
+ {Copy extra pixel values}
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 5)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 3)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Extra);
+ {$ENDIF}
+
+ {Move to next column}
+ inc(Src, 6);
+ inc(Dest, ColumnIncrement[Pass] * 3 - 3);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy ímages with palette using bit depths 1, 4 or 8}
+procedure TChunkIDAT.CopyInterlacedPalette148(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+const
+ BitTable: Array[1..8] of Integer = ($1, $3, 0, $F, 0, 0, 0, $FF);
+ StartBit: Array[1..8] of Integer = (7 , 0 , 0, 4, 0, 0, 0, 0);
+var
+ CurBit, Col: Integer;
+ Dest2: PChar;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ repeat
+ {Copy data}
+ CurBit := StartBit[Header.BitDepth];
+ repeat
+ {Adjust pointer to pixel byte bounds}
+ Dest2 := pChar(Longint(Dest) + (Header.BitDepth * Col) div 8);
+ {Copy data}
+ Byte(Dest2^) := Byte(Dest2^) or
+ ( ((Byte(Src^) shr CurBit) and BitTable[Header.BitDepth])
+ shl (StartBit[Header.BitDepth] - (Col * Header.BitDepth mod 8)));
+
+ {Move to next column}
+ inc(Col, ColumnIncrement[Pass]);
+ {Will read next bits}
+ dec(CurBit, Header.BitDepth);
+ until CurBit < 0;
+
+ {Move to next byte in source}
+ inc(Src);
+ until Col >= ImageWidth;
+end;
+
+{Copy ímages with palette using bit depth 2}
+procedure TChunkIDAT.CopyInterlacedPalette2(const Pass: Byte; Src, Dest,
+ Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ CurBit, Col: Integer;
+ Dest2: PChar;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ repeat
+ {Copy data}
+ CurBit := 6;
+ repeat
+ {Adjust pointer to pixel byte bounds}
+ Dest2 := pChar(Longint(Dest) + Col div 2);
+ {Copy data}
+ Byte(Dest2^) := Byte(Dest2^) or (((Byte(Src^) shr CurBit) and $3)
+ shl (4 - (4 * Col) mod 8));
+ {Move to next column}
+ inc(Col, ColumnIncrement[Pass]);
+ {Will read next bits}
+ dec(CurBit, 2);
+ until CurBit < 0;
+
+ {Move to next byte in source}
+ inc(Src);
+ until Col >= ImageWidth;
+end;
+
+{Copy ímages with grayscale using bit depth 2}
+procedure TChunkIDAT.CopyInterlacedGray2(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ CurBit, Col: Integer;
+ Dest2: PChar;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ repeat
+ {Copy data}
+ CurBit := 6;
+ repeat
+ {Adjust pointer to pixel byte bounds}
+ Dest2 := pChar(Longint(Dest) + Col div 2);
+ {Copy data}
+ Byte(Dest2^) := Byte(Dest2^) or ((((Byte(Src^) shr CurBit) shl 2) and $F)
+ shl (4 - (Col*4) mod 8));
+ {Move to next column}
+ inc(Col, ColumnIncrement[Pass]);
+ {Will read next bits}
+ dec(CurBit, 2);
+ until CurBit < 0;
+
+ {Move to next byte in source}
+ inc(Src);
+ until Col >= ImageWidth;
+end;
+
+{Copy ímages with palette using 2 bytes for each pixel}
+procedure TChunkIDAT.CopyInterlacedGrayscale16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col);
+ repeat
+ {Copy this row}
+ Dest^ := Src^; inc(Dest);
+ {$IFDEF Store16bits}
+ Extra^ := pChar(Longint(Src) + 1)^; inc(Extra);
+ {$ENDIF}
+
+ {Move to next column}
+ inc(Src, 2);
+ inc(Dest, ColumnIncrement[Pass] - 1);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Decodes interlaced RGB alpha with 1 byte for each sample}
+procedure TChunkIDAT.CopyInterlacedRGBAlpha8(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col * 3);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this row and alpha value}
+ Trans^ := pChar(Longint(Src) + 3)^;
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+
+ {Move to next column}
+ inc(Src, 4);
+ inc(Dest, ColumnIncrement[Pass] * 3 - 3);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Decodes interlaced RGB alpha with 2 bytes for each sample}
+procedure TChunkIDAT.CopyInterlacedRGBAlpha16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col * 3);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this row and alpha value}
+ Trans^ := pChar(Longint(Src) + 6)^;
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 4)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+ {$IFDEF Store16bits}
+ {Copy extra pixel values}
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 5)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 3)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Extra);
+ {$ENDIF}
+
+ {Move to next column}
+ inc(Src, 8);
+ inc(Dest, ColumnIncrement[Pass] * 3 - 3);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Decodes 8 bit grayscale image followed by an alpha sample}
+procedure TChunkIDAT.CopyInterlacedGrayscaleAlpha8(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column, pointers to the data and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this grayscale value and alpha}
+ Dest^ := Src^; inc(Src);
+ Trans^ := Src^; inc(Src);
+
+ {Move to next column}
+ inc(Dest, ColumnIncrement[Pass]);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Decodes 16 bit grayscale image followed by an alpha sample}
+procedure TChunkIDAT.CopyInterlacedGrayscaleAlpha16(const Pass: Byte;
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column, pointers to the data and enter in loop}
+ Col := ColumnStart[Pass];
+ Dest := pChar(Longint(Dest) + Col);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {$IFDEF Store16bits}
+ Extra^ := pChar(Longint(Src) + 1)^; inc(Extra);
+ {$ENDIF}
+ {Copy this grayscale value and alpha, transforming 16 bits into 8}
+ Dest^ := Src^; inc(Src, 2);
+ Trans^ := Src^; inc(Src, 2);
+
+ {Move to next column}
+ inc(Dest, ColumnIncrement[Pass]);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Decodes an interlaced image}
+procedure TChunkIDAT.DecodeInterlacedAdam7(Stream: TStream;
+ var ZLIBStream: TZStreamRec2; const Size: Integer; var crcfile: Cardinal);
+var
+ CurrentPass: Byte;
+ PixelsThisRow: Integer;
+ CurrentRow: Integer;
+ Trans, Data{$IFDEF Store16bits}, Extra{$ENDIF}: pChar;
+ CopyProc: procedure(const Pass: Byte; Src, Dest,
+ Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar) of object;
+begin
+
+ CopyProc := nil; {Initialize}
+ {Determine method to copy the image data}
+ case Header.ColorType of
+ {R, G, B values for each pixel}
+ COLOR_RGB:
+ case Header.BitDepth of
+ 8: CopyProc := CopyInterlacedRGB8;
+ 16: CopyProc := CopyInterlacedRGB16;
+ end {case Header.BitDepth};
+ {Palette}
+ COLOR_PALETTE, COLOR_GRAYSCALE:
+ case Header.BitDepth of
+ 1, 4, 8: CopyProc := CopyInterlacedPalette148;
+ 2 : if Header.ColorType = COLOR_PALETTE then
+ CopyProc := CopyInterlacedPalette2
+ else
+ CopyProc := CopyInterlacedGray2;
+ 16 : CopyProc := CopyInterlacedGrayscale16;
+ end;
+ {RGB followed by alpha}
+ COLOR_RGBALPHA:
+ case Header.BitDepth of
+ 8: CopyProc := CopyInterlacedRGBAlpha8;
+ 16: CopyProc := CopyInterlacedRGBAlpha16;
+ end;
+ {Grayscale followed by alpha}
+ COLOR_GRAYSCALEALPHA:
+ case Header.BitDepth of
+ 8: CopyProc := CopyInterlacedGrayscaleAlpha8;
+ 16: CopyProc := CopyInterlacedGrayscaleAlpha16;
+ end;
+ end {case Header.ColorType};
+
+ {Adam7 method has 7 passes to make the final image}
+ FOR CurrentPass := 0 TO 6 DO
+ begin
+ {Calculates the number of pixels and bytes for this pass row}
+ PixelsThisRow := (ImageWidth - ColumnStart[CurrentPass] +
+ ColumnIncrement[CurrentPass] - 1) div ColumnIncrement[CurrentPass];
+ Row_Bytes := BytesForPixels(PixelsThisRow, Header.ColorType,
+ Header.BitDepth);
+ {Clear buffer for this pass}
+ ZeroMemory(Row_Buffer[not RowUsed], Row_Bytes);
+
+ {Get current row index}
+ CurrentRow := RowStart[CurrentPass];
+ {Get a pointer to the current row image data}
+ Data := Ptr(Longint(Header.ImageData) + Header.BytesPerRow *
+ (ImageHeight - 1 - CurrentRow));
+ Trans := Ptr(Longint(Header.ImageAlpha) + ImageWidth * CurrentRow);
+ {$IFDEF Store16bits}
+ Extra := Ptr(Longint(Header.ExtraImageData) + Header.BytesPerRow *
+ (ImageHeight - 1 - CurrentRow));
+ {$ENDIF}
+
+ if Row_Bytes > 0 then {There must have bytes for this interlaced pass}
+ while CurrentRow < ImageHeight do
+ begin
+ {Reads this line and filter}
+ if IDATZlibRead(ZLIBStream, @Row_Buffer[RowUsed][0], Row_Bytes + 1,
+ EndPos, CRCFile) = 0 then break;
+
+ FilterRow;
+ {Copy image data}
+
+ CopyProc(CurrentPass, @Row_Buffer[RowUsed][1], Data, Trans
+ {$IFDEF Store16bits}, Extra{$ENDIF});
+
+ {Use the other RowBuffer item}
+ RowUsed := not RowUsed;
+
+ {Move to the next row}
+ inc(CurrentRow, RowIncrement[CurrentPass]);
+ {Move pointer to the next line}
+ dec(Data, RowIncrement[CurrentPass] * Header.BytesPerRow);
+ inc(Trans, RowIncrement[CurrentPass] * ImageWidth);
+ {$IFDEF Store16bits}
+ dec(Extra, RowIncrement[CurrentPass] * Header.BytesPerRow);
+ {$ENDIF}
+ end {while CurrentRow < ImageHeight};
+
+ end {FOR CurrentPass};
+
+end;
+
+{Copy 8 bits RGB image}
+procedure TChunkIDAT.CopyNonInterlacedRGB8(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ {Copy pixel values}
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+ {Move to next pixel}
+ inc(Src, 3);
+ end {for I}
+end;
+
+{Copy 16 bits RGB image}
+procedure TChunkIDAT.CopyNonInterlacedRGB16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ //Since windows does not supports 2 bytes for
+ //each R, G, B value, the method will read only 1 byte from it
+ {Copy pixel values}
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 4)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+ {$IFDEF Store16bits}
+ {Copy extra pixel values}
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 5)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 3)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Extra);
+ {$ENDIF}
+
+ {Move to next pixel}
+ inc(Src, 6);
+ end {for I}
+end;
+
+{Copy types using palettes (1, 4 or 8 bits per pixel)}
+procedure TChunkIDAT.CopyNonInterlacedPalette148(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+begin
+ {It's simple as copying the data}
+ CopyMemory(Dest, Src, Row_Bytes);
+end;
+
+{Copy grayscale types using 2 bits for each pixel}
+procedure TChunkIDAT.CopyNonInterlacedGray2(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ i: Integer;
+begin
+ {2 bits is not supported, this routine will converted into 4 bits}
+ FOR i := 1 TO Row_Bytes do
+ begin
+ Byte(Dest^) := ((Byte(Src^) shr 2) and $F) or ((Byte(Src^)) and $F0); inc(Dest);
+ Byte(Dest^) := ((Byte(Src^) shl 2) and $F) or ((Byte(Src^) shl 4) and $F0); inc(Dest);
+ inc(Src);
+ end {FOR i}
+end;
+
+{Copy types using palette with 2 bits for each pixel}
+procedure TChunkIDAT.CopyNonInterlacedPalette2(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ i: Integer;
+begin
+ {2 bits is not supported, this routine will converted into 4 bits}
+ FOR i := 1 TO Row_Bytes do
+ begin
+ Byte(Dest^) := ((Byte(Src^) shr 4) and $3) or ((Byte(Src^) shr 2) and $30); inc(Dest);
+ Byte(Dest^) := (Byte(Src^) and $3) or ((Byte(Src^) shl 2) and $30); inc(Dest);
+ inc(Src);
+ end {FOR i}
+end;
+
+{Copy grayscale images with 16 bits}
+procedure TChunkIDAT.CopyNonInterlacedGrayscale16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ {Windows does not supports 16 bits for each pixel in grayscale}
+ {mode, so reduce to 8}
+ Dest^ := Src^; inc(Dest);
+ {$IFDEF Store16bits}
+ Extra^ := pChar(Longint(Src) + 1)^; inc(Extra);
+ {$ENDIF}
+
+ {Move to next pixel}
+ inc(Src, 2);
+ end {for I}
+end;
+
+{Copy 8 bits per sample RGB images followed by an alpha byte}
+procedure TChunkIDAT.CopyNonInterlacedRGBAlpha8(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ i: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ {Copy pixel values and transparency}
+ Trans^ := pChar(Longint(Src) + 3)^;
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+ {Move to next pixel}
+ inc(Src, 4); inc(Trans);
+ end {for I}
+end;
+
+{Copy 16 bits RGB image with alpha using 2 bytes for each sample}
+procedure TChunkIDAT.CopyNonInterlacedRGBAlpha16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ //Copy rgb and alpha values (transforming from 16 bits to 8 bits)
+ {Copy pixel values}
+ Trans^ := pChar(Longint(Src) + 6)^;
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 4)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest);
+ {$IFDEF Store16bits}
+ {Copy extra pixel values}
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 5)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 3)^]; inc(Extra);
+ Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Extra);
+ {$ENDIF}
+ {Move to next pixel}
+ inc(Src, 8); inc(Trans);
+ end {for I}
+end;
+
+{Copy 8 bits per sample grayscale followed by alpha}
+procedure TChunkIDAT.CopyNonInterlacedGrayscaleAlpha8(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ {Copy alpha value and then gray value}
+ Dest^ := Src^; inc(Src);
+ Trans^ := Src^; inc(Src);
+ inc(Dest); inc(Trans);
+ end;
+end;
+
+{Copy 16 bits per sample grayscale followed by alpha}
+procedure TChunkIDAT.CopyNonInterlacedGrayscaleAlpha16(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ {Copy alpha value and then gray value}
+ {$IFDEF Store16bits}
+ Extra^ := pChar(Longint(Src) + 1)^; inc(Extra);
+ {$ENDIF}
+ Dest^ := Src^; inc(Src, 2);
+ Trans^ := Src^; inc(Src, 2);
+ inc(Dest); inc(Trans);
+ end;
+end;
+
+{Decode non interlaced image}
+procedure TChunkIDAT.DecodeNonInterlaced(Stream: TStream;
+ var ZLIBStream: TZStreamRec2; const Size: Integer; var crcfile: Cardinal);
+var
+ j: Cardinal;
+ Trans, Data{$IFDEF Store16bits}, Extra{$ENDIF}: pChar;
+ CopyProc: procedure(
+ Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar) of object;
+begin
+ CopyProc := nil; {Initialize}
+ {Determines the method to copy the image data}
+ case Header.ColorType of
+ {R, G, B values}
+ COLOR_RGB:
+ case Header.BitDepth of
+ 8: CopyProc := CopyNonInterlacedRGB8;
+ 16: CopyProc := CopyNonInterlacedRGB16;
+ end;
+ {Types using palettes}
+ COLOR_PALETTE, COLOR_GRAYSCALE:
+ case Header.BitDepth of
+ 1, 4, 8: CopyProc := CopyNonInterlacedPalette148;
+ 2 : if Header.ColorType = COLOR_PALETTE then
+ CopyProc := CopyNonInterlacedPalette2
+ else
+ CopyProc := CopyNonInterlacedGray2;
+ 16 : CopyProc := CopyNonInterlacedGrayscale16;
+ end;
+ {R, G, B followed by alpha}
+ COLOR_RGBALPHA:
+ case Header.BitDepth of
+ 8 : CopyProc := CopyNonInterlacedRGBAlpha8;
+ 16 : CopyProc := CopyNonInterlacedRGBAlpha16;
+ end;
+ {Grayscale followed by alpha}
+ COLOR_GRAYSCALEALPHA:
+ case Header.BitDepth of
+ 8 : CopyProc := CopyNonInterlacedGrayscaleAlpha8;
+ 16 : CopyProc := CopyNonInterlacedGrayscaleAlpha16;
+ end;
+ end;
+
+ {Get the image data pointer}
+ Longint(Data) := Longint(Header.ImageData) +
+ Header.BytesPerRow * (ImageHeight - 1);
+ Trans := Header.ImageAlpha;
+ {$IFDEF Store16bits}
+ Longint(Extra) := Longint(Header.ExtraImageData) +
+ Header.BytesPerRow * (ImageHeight - 1);
+ {$ENDIF}
+ {Reads each line}
+ FOR j := 0 to ImageHeight - 1 do
+ begin
+ {Read this line Row_Buffer[RowUsed][0] if the filter type for this line}
+ if IDATZlibRead(ZLIBStream, @Row_Buffer[RowUsed][0], Row_Bytes + 1, EndPos,
+ CRCFile) = 0 then break;
+
+ {Filter the current row}
+ FilterRow;
+ {Copies non interlaced row to image}
+ CopyProc(@Row_Buffer[RowUsed][1], Data, Trans{$IFDEF Store16bits}, Extra
+ {$ENDIF});
+
+ {Invert line used}
+ RowUsed := not RowUsed;
+ dec(Data, Header.BytesPerRow);
+ {$IFDEF Store16bits}dec(Extra, Header.BytesPerRow);{$ENDIF}
+ inc(Trans, ImageWidth);
+ end {for I};
+
+
+end;
+
+{Filter the current line}
+procedure TChunkIDAT.FilterRow;
+var
+ pp: Byte;
+ vv, left, above, aboveleft: Integer;
+ Col: Cardinal;
+begin
+ {Test the filter}
+ case Row_Buffer[RowUsed]^[0] of
+ {No filtering for this line}
+ FILTER_NONE: begin end;
+ {AND 255 serves only to never let the result be larger than one byte}
+ {Sub filter}
+ FILTER_SUB:
+ FOR Col := Offset + 1 to Row_Bytes DO
+ Row_Buffer[RowUsed][Col] := (Row_Buffer[RowUsed][Col] +
+ Row_Buffer[RowUsed][Col - Offset]) and 255;
+ {Up filter}
+ FILTER_UP:
+ FOR Col := 1 to Row_Bytes DO
+ Row_Buffer[RowUsed][Col] := (Row_Buffer[RowUsed][Col] +
+ Row_Buffer[not RowUsed][Col]) and 255;
+ {Average filter}
+ FILTER_AVERAGE:
+ FOR Col := 1 to Row_Bytes DO
+ begin
+ {Obtains up and left pixels}
+ above := Row_Buffer[not RowUsed][Col];
+ if col - 1 < Offset then
+ left := 0
+ else
+ Left := Row_Buffer[RowUsed][Col - Offset];
+
+ {Calculates}
+ Row_Buffer[RowUsed][Col] := (Row_Buffer[RowUsed][Col] +
+ (left + above) div 2) and 255;
+ end;
+ {Paeth filter}
+ FILTER_PAETH:
+ begin
+ {Initialize}
+ left := 0;
+ aboveleft := 0;
+ {Test each byte}
+ FOR Col := 1 to Row_Bytes DO
+ begin
+ {Obtains above pixel}
+ above := Row_Buffer[not RowUsed][Col];
+ {Obtains left and top-left pixels}
+ if (col - 1 >= offset) Then
+ begin
+ left := row_buffer[RowUsed][col - offset];
+ aboveleft := row_buffer[not RowUsed][col - offset];
+ end;
+
+ {Obtains current pixel and paeth predictor}
+ vv := row_buffer[RowUsed][Col];
+ pp := PaethPredictor(left, above, aboveleft);
+
+ {Calculates}
+ Row_Buffer[RowUsed][Col] := (pp + vv) and $FF;
+ end {for};
+ end;
+
+ end {case};
+end;
+
+{Reads the image data from the stream}
+function TChunkIDAT.LoadFromStream(Stream: TStream; const ChunkName: TChunkName;
+ Size: Integer): Boolean;
+var
+ ZLIBStream: TZStreamRec2;
+ CRCCheck,
+ CRCFile : Cardinal;
+begin
+ {Get pointer to the header chunk}
+ Header := Owner.Chunks.Item[0] as TChunkIHDR;
+ {Build palette if necessary}
+ if Header.HasPalette then PreparePalette();
+
+ {Copy image width and height}
+ ImageWidth := Header.Width;
+ ImageHeight := Header.Height;
+
+ {Initialize to calculate CRC}
+ {$IFDEF CheckCRC}
+ CRCFile := update_crc($ffffffff, @ChunkName[0], 4);
+ {$ENDIF}
+
+ Owner.GetPixelInfo(Row_Bytes, Offset); {Obtain line information}
+ ZLIBStream := ZLIBInitInflate(Stream); {Initializes decompression}
+
+ {Calculate ending position for the current IDAT chunk}
+ EndPos := Stream.Position + Size;
+
+ {Allocate memory}
+ GetMem(Row_Buffer[false], Row_Bytes + 1);
+ GetMem(Row_Buffer[true], Row_Bytes + 1);
+ ZeroMemory(Row_Buffer[false], Row_bytes + 1);
+ {Set the variable to alternate the Row_Buffer item to use}
+ RowUsed := TRUE;
+
+ {Call special methods for the different interlace methods}
+ case Owner.InterlaceMethod of
+ imNone: DecodeNonInterlaced(stream, ZLIBStream, Size, crcfile);
+ imAdam7: DecodeInterlacedAdam7(stream, ZLIBStream, size, crcfile);
+ end;
+
+ {Free memory}
+ ZLIBTerminateInflate(ZLIBStream); {Terminates decompression}
+ FreeMem(Row_Buffer[False], Row_Bytes + 1);
+ FreeMem(Row_Buffer[True], Row_Bytes + 1);
+
+ {Now checks CRC}
+ Stream.Read(CRCCheck, 4);
+ {$IFDEF CheckCRC}
+ CRCFile := CRCFile xor $ffffffff;
+ CRCCheck := ByteSwap(CRCCheck);
+ Result := CRCCheck = CRCFile;
+
+ {Handle CRC error}
+ if not Result then
+ begin
+ {In case it coult not load chunk}
+ Owner.RaiseError(EPngInvalidCRC, EPngInvalidCRCText);
+ exit;
+ end;
+ {$ELSE}Result := TRUE; {$ENDIF}
+end;
+
+const
+ IDATHeader: Array[0..3] of char = ('I', 'D', 'A', 'T');
+ BUFFER = 5;
+
+{Saves the IDAT chunk to a stream}
+function TChunkIDAT.SaveToStream(Stream: TStream): Boolean;
+var
+ ZLIBStream : TZStreamRec2;
+begin
+ {Get pointer to the header chunk}
+ Header := Owner.Chunks.Item[0] as TChunkIHDR;
+ {Copy image width and height}
+ ImageWidth := Header.Width;
+ ImageHeight := Header.Height;
+ Owner.GetPixelInfo(Row_Bytes, Offset); {Obtain line information}
+
+ {Allocate memory}
+ GetMem(Encode_Buffer[BUFFER], Row_Bytes);
+ ZeroMemory(Encode_Buffer[BUFFER], Row_Bytes);
+ {Allocate buffers for the filters selected}
+ {Filter none will always be calculated to the other filters to work}
+ GetMem(Encode_Buffer[FILTER_NONE], Row_Bytes);
+ ZeroMemory(Encode_Buffer[FILTER_NONE], Row_Bytes);
+ if pfSub in Owner.Filters then
+ GetMem(Encode_Buffer[FILTER_SUB], Row_Bytes);
+ if pfUp in Owner.Filters then
+ GetMem(Encode_Buffer[FILTER_UP], Row_Bytes);
+ if pfAverage in Owner.Filters then
+ GetMem(Encode_Buffer[FILTER_AVERAGE], Row_Bytes);
+ if pfPaeth in Owner.Filters then
+ GetMem(Encode_Buffer[FILTER_PAETH], Row_Bytes);
+
+ {Initialize ZLIB}
+ ZLIBStream := ZLIBInitDeflate(Stream, Owner.fCompressionLevel,
+ Owner.MaxIdatSize);
+ {Write data depending on the interlace method}
+ case Owner.InterlaceMethod of
+ imNone: EncodeNonInterlaced(stream, ZLIBStream);
+ imAdam7: EncodeInterlacedAdam7(stream, ZLIBStream);
+ end;
+ {Terminates ZLIB}
+ ZLIBTerminateDeflate(ZLIBStream);
+
+ {Release allocated memory}
+ FreeMem(Encode_Buffer[BUFFER], Row_Bytes);
+ FreeMem(Encode_Buffer[FILTER_NONE], Row_Bytes);
+ if pfSub in Owner.Filters then
+ FreeMem(Encode_Buffer[FILTER_SUB], Row_Bytes);
+ if pfUp in Owner.Filters then
+ FreeMem(Encode_Buffer[FILTER_UP], Row_Bytes);
+ if pfAverage in Owner.Filters then
+ FreeMem(Encode_Buffer[FILTER_AVERAGE], Row_Bytes);
+ if pfPaeth in Owner.Filters then
+ FreeMem(Encode_Buffer[FILTER_PAETH], Row_Bytes);
+
+ {Everything went ok}
+ Result := True;
+end;
+
+{Writes the IDAT using the settings}
+procedure WriteIDAT(Stream: TStream; Data: Pointer; const Length: Cardinal);
+var
+ ChunkLen, CRC: Cardinal;
+begin
+ {Writes IDAT header}
+ ChunkLen := ByteSwap(Length);
+ Stream.Write(ChunkLen, 4); {Chunk length}
+ Stream.Write(IDATHeader[0], 4); {Idat header}
+ CRC := update_crc($ffffffff, @IDATHeader[0], 4); {Crc part for header}
+
+ {Writes IDAT data and calculates CRC for data}
+ Stream.Write(Data^, Length);
+ CRC := Byteswap(update_crc(CRC, Data, Length) xor $ffffffff);
+ {Writes final CRC}
+ Stream.Write(CRC, 4);
+end;
+
+{Compress and writes IDAT chunk data}
+procedure TChunkIDAT.IDATZlibWrite(var ZLIBStream: TZStreamRec2;
+ Buffer: Pointer; const Length: Cardinal);
+begin
+ with ZLIBStream, ZLIBStream.ZLIB do
+ begin
+ {Set data to be compressed}
+ next_in := Buffer;
+ avail_in := Length;
+
+ {Compress all the data avaliable to compress}
+ while avail_in > 0 do
+ begin
+ deflate(ZLIB, Z_NO_FLUSH);
+
+ {The whole buffer was used, save data to stream and restore buffer}
+ if avail_out = 0 then
+ begin
+ {Writes this IDAT chunk}
+ WriteIDAT(fStream, Data, ZLIBAllocate);
+
+ {Restore buffer}
+ next_out := Data;
+ avail_out := ZLIBAllocate;
+ end {if avail_out = 0};
+
+ end {while avail_in};
+
+ end {with ZLIBStream, ZLIBStream.ZLIB}
+end;
+
+{Finishes compressing data to write IDAT chunk}
+procedure TChunkIDAT.FinishIDATZlib(var ZLIBStream: TZStreamRec2);
+begin
+ with ZLIBStream, ZLIBStream.ZLIB do
+ begin
+ {Set data to be compressed}
+ next_in := nil;
+ avail_in := 0;
+
+ while deflate(ZLIB,Z_FINISH) <> Z_STREAM_END do
+ begin
+ {Writes this IDAT chunk}
+ WriteIDAT(fStream, Data, ZLIBAllocate - avail_out);
+ {Re-update buffer}
+ next_out := Data;
+ avail_out := ZLIBAllocate;
+ end;
+
+ if avail_out < ZLIBAllocate then
+ {Writes final IDAT}
+ WriteIDAT(fStream, Data, ZLIBAllocate - avail_out);
+
+ end {with ZLIBStream, ZLIBStream.ZLIB};
+end;
+
+{Copy memory to encode RGB image with 1 byte for each color sample}
+procedure TChunkIDAT.EncodeNonInterlacedRGB8(Src, Dest, Trans: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ {Copy pixel values}
+ Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest);
+ {Move to next pixel}
+ inc(Src, 3);
+ end {for I}
+end;
+
+{Copy memory to encode RGB images with 16 bits for each color sample}
+procedure TChunkIDAT.EncodeNonInterlacedRGB16(Src, Dest, Trans: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ //Now we copy from 1 byte for each sample stored to a 2 bytes (or 1 word)
+ //for sample
+ {Copy pixel values}
+ pWORD(Dest)^ := fOwner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest, 2);
+ pWORD(Dest)^ := fOwner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest, 2);
+ pWORD(Dest)^ := fOwner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest, 2);
+ {Move to next pixel}
+ inc(Src, 3);
+ end {for I}
+
+end;
+
+{Copy memory to encode types using palettes (1, 4 or 8 bits per pixel)}
+procedure TChunkIDAT.EncodeNonInterlacedPalette148(Src, Dest, Trans: pChar);
+begin
+ {It's simple as copying the data}
+ CopyMemory(Dest, Src, Row_Bytes);
+end;
+
+{Copy memory to encode grayscale images with 2 bytes for each sample}
+procedure TChunkIDAT.EncodeNonInterlacedGrayscale16(Src, Dest, Trans: pChar);
+var
+ I: Integer;
+begin
+ FOR I := 1 TO ImageWidth DO
+ begin
+ //Now we copy from 1 byte for each sample stored to a 2 bytes (or 1 word)
+ //for sample
+ pWORD(Dest)^ := pByte(Longint(Src))^; inc(Dest, 2);
+ {Move to next pixel}
+ inc(Src);
+ end {for I}
+end;
+
+{Encode images using RGB followed by an alpha value using 1 byte for each}
+procedure TChunkIDAT.EncodeNonInterlacedRGBAlpha8(Src, Dest, Trans: pChar);
+var
+ i: Integer;
+begin
+ {Copy the data to the destination, including data from Trans pointer}
+ FOR i := 1 TO ImageWidth do
+ begin
+ Byte(Dest^) := Owner.InverseGamma[PByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := Owner.InverseGamma[PByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := Owner.InverseGamma[PByte(Longint(Src) )^]; inc(Dest);
+ Dest^ := Trans^; inc(Dest);
+ inc(Src, 3); inc(Trans);
+ end {for i};
+end;
+
+{Encode images using RGB followed by an alpha value using 2 byte for each}
+procedure TChunkIDAT.EncodeNonInterlacedRGBAlpha16(Src, Dest, Trans: pChar);
+var
+ i: Integer;
+begin
+ {Copy the data to the destination, including data from Trans pointer}
+ FOR i := 1 TO ImageWidth do
+ begin
+ pWord(Dest)^ := Owner.InverseGamma[PByte(Longint(Src) + 2)^]; inc(Dest, 2);
+ pWord(Dest)^ := Owner.InverseGamma[PByte(Longint(Src) + 1)^]; inc(Dest, 2);
+ pWord(Dest)^ := Owner.InverseGamma[PByte(Longint(Src) )^]; inc(Dest, 2);
+ pWord(Dest)^ := PByte(Longint(Trans) )^; inc(Dest, 2);
+ inc(Src, 3); inc(Trans);
+ end {for i};
+end;
+
+{Encode grayscale images followed by an alpha value using 1 byte for each}
+procedure TChunkIDAT.EncodeNonInterlacedGrayscaleAlpha8(
+ Src, Dest, Trans: pChar);
+var
+ i: Integer;
+begin
+ {Copy the data to the destination, including data from Trans pointer}
+ FOR i := 1 TO ImageWidth do
+ begin
+ Dest^ := Src^; inc(Dest);
+ Dest^ := Trans^; inc(Dest);
+ inc(Src); inc(Trans);
+ end {for i};
+end;
+
+{Encode grayscale images followed by an alpha value using 2 byte for each}
+procedure TChunkIDAT.EncodeNonInterlacedGrayscaleAlpha16(
+ Src, Dest, Trans: pChar);
+var
+ i: Integer;
+begin
+ {Copy the data to the destination, including data from Trans pointer}
+ FOR i := 1 TO ImageWidth do
+ begin
+ pWord(Dest)^ := pByte(Src)^; inc(Dest, 2);
+ pWord(Dest)^ := pByte(Trans)^; inc(Dest, 2);
+ inc(Src); inc(Trans);
+ end {for i};
+end;
+
+{Encode non interlaced images}
+procedure TChunkIDAT.EncodeNonInterlaced(Stream: TStream;
+ var ZLIBStream: TZStreamRec2);
+var
+ {Current line}
+ j: Cardinal;
+ {Pointers to image data}
+ Data, Trans: PChar;
+ {Filter used for this line}
+ Filter: Byte;
+ {Method which will copy the data into the buffer}
+ CopyProc: procedure(Src, Dest, Trans: pChar) of object;
+begin
+ CopyProc := nil; {Initialize to avoid warnings}
+ {Defines the method to copy the data to the buffer depending on}
+ {the image parameters}
+ case Header.ColorType of
+ {R, G, B values}
+ COLOR_RGB:
+ case Header.BitDepth of
+ 8: CopyProc := EncodeNonInterlacedRGB8;
+ 16: CopyProc := EncodeNonInterlacedRGB16;
+ end;
+ {Palette and grayscale values}
+ COLOR_GRAYSCALE, COLOR_PALETTE:
+ case Header.BitDepth of
+ 1, 4, 8: CopyProc := EncodeNonInterlacedPalette148;
+ 16: CopyProc := EncodeNonInterlacedGrayscale16;
+ end;
+ {RGB with a following alpha value}
+ COLOR_RGBALPHA:
+ case Header.BitDepth of
+ 8: CopyProc := EncodeNonInterlacedRGBAlpha8;
+ 16: CopyProc := EncodeNonInterlacedRGBAlpha16;
+ end;
+ {Grayscale images followed by an alpha}
+ COLOR_GRAYSCALEALPHA:
+ case Header.BitDepth of
+ 8: CopyProc := EncodeNonInterlacedGrayscaleAlpha8;
+ 16: CopyProc := EncodeNonInterlacedGrayscaleAlpha16;
+ end;
+ end {case Header.ColorType};
+
+ {Get the image data pointer}
+ Longint(Data) := Longint(Header.ImageData) +
+ Header.BytesPerRow * (ImageHeight - 1);
+ Trans := Header.ImageAlpha;
+
+ {Writes each line}
+ FOR j := 0 to ImageHeight - 1 do
+ begin
+ {Copy data into buffer}
+ CopyProc(Data, @Encode_Buffer[BUFFER][0], Trans);
+ {Filter data}
+ Filter := FilterToEncode;
+
+ {Compress data}
+ IDATZlibWrite(ZLIBStream, @Filter, 1);
+ IDATZlibWrite(ZLIBStream, @Encode_Buffer[Filter][0], Row_Bytes);
+
+ {Adjust pointers to the actual image data}
+ dec(Data, Header.BytesPerRow);
+ inc(Trans, ImageWidth);
+ end;
+
+ {Compress and finishes copying the remaining data}
+ FinishIDATZlib(ZLIBStream);
+end;
+
+{Copy memory to encode interlaced images using RGB value with 1 byte for}
+{each color sample}
+procedure TChunkIDAT.EncodeInterlacedRGB8(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col * 3);
+ repeat
+ {Copy this row}
+ Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass] * 3);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy memory to encode interlaced RGB images with 2 bytes each color sample}
+procedure TChunkIDAT.EncodeInterlacedRGB16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col * 3);
+ repeat
+ {Copy this row}
+ pWord(Dest)^ := Owner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest, 2);
+ pWord(Dest)^ := Owner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest, 2);
+ pWord(Dest)^ := Owner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest, 2);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass] * 3);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy memory to encode interlaced images using palettes using bit depths}
+{1, 4, 8 (each pixel in the image)}
+procedure TChunkIDAT.EncodeInterlacedPalette148(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+const
+ BitTable: Array[1..8] of Integer = ($1, $3, 0, $F, 0, 0, 0, $FF);
+ StartBit: Array[1..8] of Integer = (7 , 0 , 0, 4, 0, 0, 0, 0);
+var
+ CurBit, Col: Integer;
+ Src2: PChar;
+begin
+ {Clean the line}
+ fillchar(Dest^, Row_Bytes, #0);
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ with Header.BitmapInfo.bmiHeader do
+ repeat
+ {Copy data}
+ CurBit := StartBit[biBitCount];
+ repeat
+ {Adjust pointer to pixel byte bounds}
+ Src2 := pChar(Longint(Src) + (biBitCount * Col) div 8);
+ {Copy data}
+ Byte(Dest^) := Byte(Dest^) or
+ (((Byte(Src2^) shr (StartBit[Header.BitDepth] - (biBitCount * Col)
+ mod 8))) and (BitTable[biBitCount])) shl CurBit;
+
+ {Move to next column}
+ inc(Col, ColumnIncrement[Pass]);
+ {Will read next bits}
+ dec(CurBit, biBitCount);
+ until CurBit < 0;
+
+ {Move to next byte in source}
+ inc(Dest);
+ until Col >= ImageWidth;
+end;
+
+{Copy to encode interlaced grayscale images using 16 bits for each sample}
+procedure TChunkIDAT.EncodeInterlacedGrayscale16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col);
+ repeat
+ {Copy this row}
+ pWord(Dest)^ := Byte(Src^); inc(Dest, 2);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy to encode interlaced rgb images followed by an alpha value, all using}
+{one byte for each sample}
+procedure TChunkIDAT.EncodeInterlacedRGBAlpha8(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col * 3);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this row}
+ Byte(Dest^) := Owner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest);
+ Byte(Dest^) := Owner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest);
+ Byte(Dest^) := Owner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest);
+ Dest^ := Trans^; inc(Dest);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass] * 3);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy to encode interlaced rgb images followed by an alpha value, all using}
+{two byte for each sample}
+procedure TChunkIDAT.EncodeInterlacedRGBAlpha16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col * 3);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this row}
+ pWord(Dest)^ := pByte(Longint(Src) + 2)^; inc(Dest, 2);
+ pWord(Dest)^ := pByte(Longint(Src) + 1)^; inc(Dest, 2);
+ pWord(Dest)^ := pByte(Longint(Src) )^; inc(Dest, 2);
+ pWord(Dest)^ := pByte(Trans)^; inc(Dest, 2);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass] * 3);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy to encode grayscale interlaced images followed by an alpha value, all}
+{using 1 byte for each sample}
+procedure TChunkIDAT.EncodeInterlacedGrayscaleAlpha8(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this row}
+ Dest^ := Src^; inc(Dest);
+ Dest^ := Trans^; inc(Dest);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass]);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Copy to encode grayscale interlaced images followed by an alpha value, all}
+{using 2 bytes for each sample}
+procedure TChunkIDAT.EncodeInterlacedGrayscaleAlpha16(const Pass: Byte;
+ Src, Dest, Trans: pChar);
+var
+ Col: Integer;
+begin
+ {Get first column and enter in loop}
+ Col := ColumnStart[Pass];
+ Src := pChar(Longint(Src) + Col);
+ Trans := pChar(Longint(Trans) + Col);
+ repeat
+ {Copy this row}
+ pWord(Dest)^ := pByte(Src)^; inc(Dest, 2);
+ pWord(Dest)^ := pByte(Trans)^; inc(Dest, 2);
+
+ {Move to next column}
+ inc(Src, ColumnIncrement[Pass]);
+ inc(Trans, ColumnIncrement[Pass]);
+ inc(Col, ColumnIncrement[Pass]);
+ until Col >= ImageWidth;
+end;
+
+{Encode interlaced images}
+procedure TChunkIDAT.EncodeInterlacedAdam7(Stream: TStream;
+ var ZLIBStream: TZStreamRec2);
+var
+ CurrentPass, Filter: Byte;
+ PixelsThisRow: Integer;
+ CurrentRow : Integer;
+ Trans, Data: pChar;
+ CopyProc: procedure(const Pass: Byte;
+ Src, Dest, Trans: pChar) of object;
+begin
+ CopyProc := nil; {Initialize to avoid warnings}
+ {Defines the method to copy the data to the buffer depending on}
+ {the image parameters}
+ case Header.ColorType of
+ {R, G, B values}
+ COLOR_RGB:
+ case Header.BitDepth of
+ 8: CopyProc := EncodeInterlacedRGB8;
+ 16: CopyProc := EncodeInterlacedRGB16;
+ end;
+ {Grayscale and palette}
+ COLOR_PALETTE, COLOR_GRAYSCALE:
+ case Header.BitDepth of
+ 1, 4, 8: CopyProc := EncodeInterlacedPalette148;
+ 16: CopyProc := EncodeInterlacedGrayscale16;
+ end;
+ {RGB followed by alpha}
+ COLOR_RGBALPHA:
+ case Header.BitDepth of
+ 8: CopyProc := EncodeInterlacedRGBAlpha8;
+ 16: CopyProc := EncodeInterlacedRGBAlpha16;
+ end;
+ COLOR_GRAYSCALEALPHA:
+ {Grayscale followed by alpha}
+ case Header.BitDepth of
+ 8: CopyProc := EncodeInterlacedGrayscaleAlpha8;
+ 16: CopyProc := EncodeInterlacedGrayscaleAlpha16;
+ end;
+ end {case Header.ColorType};
+
+ {Compress the image using the seven passes for ADAM 7}
+ FOR CurrentPass := 0 TO 6 DO
+ begin
+ {Calculates the number of pixels and bytes for this pass row}
+ PixelsThisRow := (ImageWidth - ColumnStart[CurrentPass] +
+ ColumnIncrement[CurrentPass] - 1) div ColumnIncrement[CurrentPass];
+ Row_Bytes := BytesForPixels(PixelsThisRow, Header.ColorType,
+ Header.BitDepth);
+ ZeroMemory(Encode_Buffer[FILTER_NONE], Row_Bytes);
+
+ {Get current row index}
+ CurrentRow := RowStart[CurrentPass];
+ {Get a pointer to the current row image data}
+ Data := Ptr(Longint(Header.ImageData) + Header.BytesPerRow *
+ (ImageHeight - 1 - CurrentRow));
+ Trans := Ptr(Longint(Header.ImageAlpha) + ImageWidth * CurrentRow);
+
+ {Process all the image rows}
+ if Row_Bytes > 0 then
+ while CurrentRow < ImageHeight do
+ begin
+ {Copy data into buffer}
+ CopyProc(CurrentPass, Data, @Encode_Buffer[BUFFER][0], Trans);
+ {Filter data}
+ Filter := FilterToEncode;
+
+ {Compress data}
+ IDATZlibWrite(ZLIBStream, @Filter, 1);
+ IDATZlibWrite(ZLIBStream, @Encode_Buffer[Filter][0], Row_Bytes);
+
+ {Move to the next row}
+ inc(CurrentRow, RowIncrement[CurrentPass]);
+ {Move pointer to the next line}
+ dec(Data, RowIncrement[CurrentPass] * Header.BytesPerRow);
+ inc(Trans, RowIncrement[CurrentPass] * ImageWidth);
+ end {while CurrentRow < ImageHeight}
+
+ end {CurrentPass};
+
+ {Compress and finishes copying the remaining data}
+ FinishIDATZlib(ZLIBStream);
+end;
+
+{Filters the row to be encoded and returns the best filter}
+function TChunkIDAT.FilterToEncode: Byte;
+var
+ Run, LongestRun, ii, jj: Cardinal;
+ Last, Above, LastAbove: Byte;
+begin
+ {Selecting more filters using the Filters property from TPngObject}
+ {increases the chances to the file be much smaller, but decreases}
+ {the performace}
+
+ {This method will creates the same line data using the different}
+ {filter methods and select the best}
+
+ {Sub-filter}
+ if pfSub in Owner.Filters then
+ for ii := 0 to Row_Bytes - 1 do
+ begin
+ {There is no previous pixel when it's on the first pixel, so}
+ {set last as zero when in the first}
+ if (ii >= Offset) then
+ last := Encode_Buffer[BUFFER]^[ii - Offset]
+ else
+ last := 0;
+ Encode_Buffer[FILTER_SUB]^[ii] := Encode_Buffer[BUFFER]^[ii] - last;
+ end;
+
+ {Up filter}
+ if pfUp in Owner.Filters then
+ for ii := 0 to Row_Bytes - 1 do
+ Encode_Buffer[FILTER_UP]^[ii] := Encode_Buffer[BUFFER]^[ii] -
+ Encode_Buffer[FILTER_NONE]^[ii];
+
+ {Average filter}
+ if pfAverage in Owner.Filters then
+ for ii := 0 to Row_Bytes - 1 do
+ begin
+ {Get the previous pixel, if the current pixel is the first, the}
+ {previous is considered to be 0}
+ if (ii >= Offset) then
+ last := Encode_Buffer[BUFFER]^[ii - Offset]
+ else
+ last := 0;
+ {Get the pixel above}
+ above := Encode_Buffer[FILTER_NONE]^[ii];
+
+ {Calculates formula to the average pixel}
+ Encode_Buffer[FILTER_AVERAGE]^[ii] := Encode_Buffer[BUFFER]^[ii] -
+ (above + last) div 2 ;
+ end;
+
+ {Paeth filter (the slower)}
+ if pfPaeth in Owner.Filters then
+ begin
+ {Initialize}
+ last := 0;
+ lastabove := 0;
+ for ii := 0 to Row_Bytes - 1 do
+ begin
+ {In case this pixel is not the first in the line obtains the}
+ {previous one and the one above the previous}
+ if (ii >= Offset) then
+ begin
+ last := Encode_Buffer[BUFFER]^[ii - Offset];
+ lastabove := Encode_Buffer[FILTER_NONE]^[ii - Offset];
+ end;
+ {Obtains the pixel above}
+ above := Encode_Buffer[FILTER_NONE]^[ii];
+ {Calculate paeth filter for this byte}
+ Encode_Buffer[FILTER_PAETH]^[ii] := Encode_Buffer[BUFFER]^[ii] -
+ PaethPredictor(last, above, lastabove);
+ end;
+ end;
+
+ {Now calculates the same line using no filter, which is necessary}
+ {in order to have data to the filters when the next line comes}
+ CopyMemory(@Encode_Buffer[FILTER_NONE]^[0],
+ @Encode_Buffer[BUFFER]^[0], Row_Bytes);
+
+ {If only filter none is selected in the filter list, we don't need}
+ {to proceed and further}
+ if (Owner.Filters = [pfNone]) or (Owner.Filters = []) then
+ begin
+ Result := FILTER_NONE;
+ exit;
+ end {if (Owner.Filters = [pfNone...};
+
+ {Check which filter is the best by checking which has the larger}
+ {sequence of the same byte, since they are best compressed}
+ LongestRun := 0; Result := FILTER_NONE;
+ for ii := FILTER_NONE TO FILTER_PAETH do
+ {Check if this filter was selected}
+ if TFilter(ii) in Owner.Filters then
+ begin
+ Run := 0;
+ {Check if it's the only filter}
+ if Owner.Filters = [TFilter(ii)] then
+ begin
+ Result := ii;
+ exit;
+ end;
+
+ {Check using a sequence of four bytes}
+ for jj := 2 to Row_Bytes - 1 do
+ if (Encode_Buffer[ii]^[jj] = Encode_Buffer [ii]^[jj-1]) or
+ (Encode_Buffer[ii]^[jj] = Encode_Buffer [ii]^[jj-2]) then
+ inc(Run); {Count the number of sequences}
+
+ {Check if this one is the best so far}
+ if (Run > LongestRun) then
+ begin
+ Result := ii;
+ LongestRun := Run;
+ end {if (Run > LongestRun)};
+
+ end {if TFilter(ii) in Owner.Filters};
+end;
+
+{TChunkPLTE implementation}
+
+{Returns an item in the palette}
+function TChunkPLTE.GetPaletteItem(Index: Byte): TRGBQuad;
+begin
+ {Test if item is valid, if not raise error}
+ if Index > Count - 1 then
+ Owner.RaiseError(EPNGError, EPNGUnknownPalEntryText)
+ else
+ {Returns the item}
+ Result := Header.BitmapInfo.bmiColors[Index];
+end;
+
+{Loads the palette chunk from a stream}
+function TChunkPLTE.LoadFromStream(Stream: TStream;
+ const ChunkName: TChunkName; Size: Integer): Boolean;
+type
+ pPalEntry = ^PalEntry;
+ PalEntry = record r, g, b: Byte end;
+var
+ j : Integer; {For the FOR}
+ PalColor : pPalEntry;
+begin
+ {Let ancestor load data and check CRC}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+ if not Result then exit;
+
+ {This chunk must be divisible by 3 in order to be valid}
+ if (Size mod 3 <> 0) or (Size div 3 > 256) then
+ begin
+ {Raise error}
+ Result := FALSE;
+ Owner.RaiseError(EPNGInvalidPalette, EPNGInvalidPaletteText);
+ exit;
+ end {if Size mod 3 <> 0};
+
+ {Fill array with the palette entries}
+ fCount := Size div 3;
+ PalColor := Data;
+ FOR j := 0 TO fCount - 1 DO
+ with Header.BitmapInfo.bmiColors[j] do
+ begin
+ rgbRed := Owner.GammaTable[PalColor.r];
+ rgbGreen := Owner.GammaTable[PalColor.g];
+ rgbBlue := Owner.GammaTable[PalColor.b];
+ rgbReserved := 0;
+ inc(PalColor); {Move to next palette entry}
+ end;
+end;
+
+{Saves the PLTE chunk to a stream}
+function TChunkPLTE.SaveToStream(Stream: TStream): Boolean;
+var
+ J: Integer;
+ DataPtr: pByte;
+begin
+ {Adjust size to hold all the palette items}
+ ResizeData(fCount * 3);
+ {Copy pointer to data}
+ DataPtr := fData;
+
+ {Copy palette items}
+ with Header do
+ FOR j := 0 TO fCount - 1 DO
+ with BitmapInfo.bmiColors[j] do
+ begin
+ DataPtr^ := Owner.InverseGamma[rgbRed]; inc(DataPtr);
+ DataPtr^ := Owner.InverseGamma[rgbGreen]; inc(DataPtr);
+ DataPtr^ := Owner.InverseGamma[rgbBlue]; inc(DataPtr);
+ end {with BitmapInfo};
+
+ {Let ancestor do the rest of the work}
+ Result := inherited SaveToStream(Stream);
+end;
+
+{Assigns from another PLTE chunk}
+procedure TChunkPLTE.Assign(Source: TChunk);
+begin
+ {Copy the number of palette items}
+ if Source is TChunkPLTE then
+ fCount := TChunkPLTE(Source).fCount
+ else
+ Owner.RaiseError(EPNGError, EPNGCannotAssignChunkText);
+end;
+
+{TChunkgAMA implementation}
+
+{Assigns from another chunk}
+procedure TChunkgAMA.Assign(Source: TChunk);
+begin
+ {Copy the gamma value}
+ if Source is TChunkgAMA then
+ Gamma := TChunkgAMA(Source).Gamma
+ else
+ Owner.RaiseError(EPNGError, EPNGCannotAssignChunkText);
+end;
+
+{Gamma chunk being created}
+constructor TChunkgAMA.Create(Owner: TPngObject);
+begin
+ {Call ancestor}
+ inherited Create(Owner);
+ Gamma := 1; {Initial value}
+end;
+
+{Returns gamma value}
+function TChunkgAMA.GetValue: Cardinal;
+begin
+ {Make sure that the size is four bytes}
+ if DataSize <> 4 then
+ begin
+ {Adjust size and returns 1}
+ ResizeData(4);
+ Result := 1;
+ end
+ {If it's right, read the value}
+ else Result := Cardinal(ByteSwap(pCardinal(Data)^))
+end;
+
+function Power(Base, Exponent: Extended): Extended;
+begin
+ if Exponent = 0.0 then
+ Result := 1.0 {Math rule}
+ else if (Base = 0) or (Exponent = 0) then Result := 0
+ else
+ Result := Exp(Exponent * Ln(Base));
+end;
+
+
+{Loading the chunk from a stream}
+function TChunkgAMA.LoadFromStream(Stream: TStream;
+ const ChunkName: TChunkName; Size: Integer): Boolean;
+var
+ i: Integer;
+ Value: Cardinal;
+begin
+ {Call ancestor and test if it went ok}
+ Result := inherited LoadFromStream(Stream, ChunkName, Size);
+ if not Result then exit;
+ Value := Gamma;
+ {Build gamma table and inverse table for saving}
+ if Value <> 0 then
+ with Owner do
+ FOR i := 0 TO 255 DO
+ begin
+ GammaTable[I] := Round(Power((I / 255), 1 /
+ (Value / 100000 * 2.2)) * 255);
+ InverseGamma[Round(Power((I / 255), 1 /
+ (Value / 100000 * 2.2)) * 255)] := I;
+ end
+end;
+
+{Sets the gamma value}
+procedure TChunkgAMA.SetValue(const Value: Cardinal);
+begin
+ {Make sure that the size is four bytes}
+ if DataSize <> 4 then ResizeData(4);
+ {If it's right, set the value}
+ pCardinal(Data)^ := ByteSwap(Value);
+end;
+
+{TPngObject implementation}
+
+{Assigns from another object}
+procedure TPngObject.Assign(Source: TPersistent);
+begin
+ {Assigns contents from another TPNGObject}
+ if Source is TPNGObject then
+ AssignPNG(Source as TPNGObject)
+ {Copy contents from a TBitmap}
+ {$IFDEF UseDelphi}else if Source is TBitmap then
+ with Source as TBitmap do
+ AssignHandle(Handle, Transparent,
+ ColorToRGB(TransparentColor)){$ENDIF}
+ {Unknown source, let ancestor deal with it}
+ else
+ inherited;
+end;
+
+{Clear all the chunks in the list}
+procedure TPngObject.ClearChunks;
+var
+ i: Integer;
+begin
+ {Initialize gamma}
+ InitializeGamma();
+ {Free all the objects and memory (0 chunks Bug fixed by Noel Sharpe)}
+ for i := 0 TO Integer(Chunks.Count) - 1 do
+ TChunk(Chunks.Item[i]).Free;
+ Chunks.Count := 0;
+end;
+
+{Portable Network Graphics object being created}
+constructor TPngObject.Create;
+begin
+ {Let it be created}
+ inherited Create;
+
+ {Initial properties}
+ TempPalette := 0;
+ fFilters := [pfSub];
+ fCompressionLevel := 7;
+ fInterlaceMethod := imNone;
+ fMaxIdatSize := High(Word);
+ {Create chunklist object}
+ fChunkList := TPngList.Create(Self);
+end;
+
+{Portable Network Graphics object being destroyed}
+destructor TPngObject.Destroy;
+begin
+ {Free object list}
+ ClearChunks;
+ fChunkList.Free;
+ {Free the temporary palette}
+ if TempPalette <> 0 then DeleteObject(TempPalette);
+
+ {Call ancestor destroy}
+ inherited Destroy;
+end;
+
+{Returns linesize and byte offset for pixels}
+procedure TPngObject.GetPixelInfo(var LineSize, Offset: Cardinal);
+begin
+ {There must be an Header chunk to calculate size}
+ if HeaderPresent then
+ begin
+ {Calculate number of bytes for each line}
+ LineSize := BytesForPixels(Header.Width, Header.ColorType, Header.BitDepth);
+
+ {Calculates byte offset}
+ Case Header.ColorType of
+ {Grayscale}
+ COLOR_GRAYSCALE:
+ If Header.BitDepth = 16 Then
+ Offset := 2
+ Else
+ Offset := 1 ;
+ {It always smaller or equal one byte, so it occupes one byte}
+ COLOR_PALETTE:
+ offset := 1;
+ {It might be 3 or 6 bytes}
+ COLOR_RGB:
+ offset := 3 * Header.BitDepth Div 8;
+ {It might be 2 or 4 bytes}
+ COLOR_GRAYSCALEALPHA:
+ offset := 2 * Header.BitDepth Div 8;
+ {4 or 8 bytes}
+ COLOR_RGBALPHA:
+ offset := 4 * Header.BitDepth Div 8;
+ else
+ Offset := 0;
+ End ;
+
+ end
+ else
+ begin
+ {In case if there isn't any Header chunk}
+ Offset := 0;
+ LineSize := 0;
+ end;
+
+end;
+
+{Returns image height}
+function TPngObject.GetHeight: Integer;
+begin
+ {There must be a Header chunk to get the size, otherwise returns 0}
+ if HeaderPresent then
+ Result := TChunkIHDR(Chunks.Item[0]).Height
+ else Result := 0;
+end;
+
+{Returns image width}
+function TPngObject.GetWidth: Integer;
+begin
+ {There must be a Header chunk to get the size, otherwise returns 0}
+ if HeaderPresent then
+ Result := Header.Width
+ else Result := 0;
+end;
+
+{Returns if the image is empty}
+function TPngObject.GetEmpty: Boolean;
+begin
+ Result := (Chunks.Count = 0);
+end;
+
+{Raises an error}
+procedure TPngObject.RaiseError(ExceptionClass: ExceptClass; Text: String);
+begin
+ raise ExceptionClass.Create(Text);
+end;
+
+{Set the maximum size for IDAT chunk}
+procedure TPngObject.SetMaxIdatSize(const Value: Cardinal);
+begin
+ {Make sure the size is at least 65535}
+ if Value < High(Word) then
+ fMaxIdatSize := High(Word) else fMaxIdatSize := Value;
+end;
+
+{$IFNDEF UseDelphi}
+ {Creates a file stream reading from the filename in the parameter and load}
+ procedure TPngObject.LoadFromFile(const Filename: String);
+ var
+ FileStream: TFileStream;
+ begin
+ {Test if the file exists}
+ if not FileExists(Filename) then
+ begin
+ {In case it does not exists, raise error}
+ RaiseError(EPNGNotExists, EPNGNotExistsText);
+ exit;
+ end;
+
+ {Creates the file stream to read}
+ FileStream := TFileStream.Create(Filename, [fsmRead]);
+ LoadFromStream(FileStream); {Loads the data}
+ FileStream.Free; {Free file stream}
+ end;
+
+ {Saves the current png image to a file}
+ procedure TPngObject.SaveToFile(const Filename: String);
+ var
+ FileStream: TFileStream;
+ begin
+ {Creates the file stream to write}
+ FileStream := TFileStream.Create(Filename, [fsmWrite]);
+ SaveToStream(FileStream); {Saves the data}
+ FileStream.Free; {Free file stream}
+ end;
+
+{$ENDIF}
+
+{Returns pointer to the chunk TChunkIHDR which should be the first}
+function TPngObject.GetHeader: TChunkIHDR;
+begin
+ {If there is a TChunkIHDR returns it, otherwise returns nil}
+ if (Chunks.Count <> 0) and (Chunks.Item[0] is TChunkIHDR) then
+ Result := Chunks.Item[0] as TChunkIHDR
+ else
+ begin
+ {No header, throw error message}
+ RaiseError(EPNGHeaderNotPresent, EPNGHeaderNotPresentText);
+ Result := nil
+ end
+end;
+
+{Draws using partial transparency}
+procedure TPngObject.DrawPartialTrans(DC: HDC; Rect: TRect);
+type
+ {Access to pixels}
+ TPixelLine = Array[Word] of TRGBQuad;
+ pPixelLine = ^TPixelLine;
+const
+ {Structure used to create the bitmap}
+ BitmapInfoHeader: TBitmapInfoHeader =
+ (biSize: sizeof(TBitmapInfoHeader);
+ biWidth: 100;
+ biHeight: 100;
+ biPlanes: 1;
+ biBitCount: 32;
+ biCompression: BI_RGB;
+ biSizeImage: 0;
+ biXPelsPerMeter: 0;
+ biYPelsPerMeter: 0;
+ biClrUsed: 0;
+ biClrImportant: 0);
+var
+ {Buffer bitmap creation}
+ BitmapInfo : TBitmapInfo;
+ BufferDC : HDC;
+ BufferBits : Pointer;
+ OldBitmap,
+ BufferBitmap: HBitmap;
+
+ {Transparency/palette chunks}
+ TransparencyChunk: TChunktRNS;
+ PaletteChunk: TChunkPLTE;
+ TransValue, PaletteIndex: Byte;
+ CurBit: Integer;
+ Data: PByte;
+
+ {Buffer bitmap modification}
+ BytesPerRowDest,
+ BytesPerRowSrc,
+ BytesPerRowAlpha: Integer;
+ ImageSource,
+ AlphaSource : pByteArray;
+ ImageData : pPixelLine;
+ i, j : Integer;
+begin
+ {Prepare to create the bitmap}
+ Fillchar(BitmapInfo, sizeof(BitmapInfo), #0);
+ BitmapInfoHeader.biWidth := Header.Width;
+ BitmapInfoHeader.biHeight := -1 * Header.Height;
+ BitmapInfo.bmiHeader := BitmapInfoHeader;
+
+ {Create the bitmap which will receive the background, the applied}
+ {alpha blending and then will be painted on the background}
+ BufferDC := CreateCompatibleDC(0);
+ {In case BufferDC could not be created}
+ if (BufferDC = 0) then RaiseError(EPNGOutMemory, EPNGOutMemoryText);
+ BufferBitmap := CreateDIBSection(BufferDC, BitmapInfo, DIB_RGB_COLORS,
+ BufferBits, 0, 0);
+ {In case buffer bitmap could not be created}
+ if (BufferBitmap = 0) or (BufferBits = Nil) then
+ begin
+ if BufferBitmap <> 0 then DeleteObject(BufferBitmap);
+ DeleteDC(BufferDC);
+ RaiseError(EPNGOutMemory, EPNGOutMemoryText);
+ end;
+
+ {Selects new bitmap and release old bitmap}
+ OldBitmap := SelectObject(BufferDC, BufferBitmap);
+
+ {Draws the background on the buffer image}
+ StretchBlt(BufferDC, 0, 0, Header.Width, Header.height, DC, Rect.Left,
+ Rect.Top, Header.Width, Header.Height, SRCCOPY);
+
+ {Obtain number of bytes for each row}
+ BytesPerRowAlpha := Header.Width;
+ BytesPerRowDest := (((BitmapInfo.bmiHeader.biBitCount * Width) + 31)
+ and not 31) div 8; {Number of bytes for each image row in destination}
+ BytesPerRowSrc := (((Header.BitmapInfo.bmiHeader.biBitCount * Header.Width) +
+ 31) and not 31) div 8; {Number of bytes for each image row in source}
+
+ {Obtains image pointers}
+ ImageData := BufferBits;
+ AlphaSource := Header.ImageAlpha;
+ Longint(ImageSource) := Longint(Header.ImageData) +
+ Header.BytesPerRow * Longint(Header.Height - 1);
+
+ case Header.BitmapInfo.bmiHeader.biBitCount of
+ {R, G, B images}
+ 24:
+ FOR j := 1 TO Header.Height DO
+ begin
+ {Process all the pixels in this line}
+ FOR i := 0 TO Header.Width - 1 DO
+ with ImageData[i] do
+ begin
+ rgbRed := (255+ImageSource[2+i*3] * AlphaSource[i] + rgbRed * (255 -
+ AlphaSource[i])) shr 8;
+ rgbGreen := (255+ImageSource[1+i*3] * AlphaSource[i] + rgbGreen *
+ (255 - AlphaSource[i])) shr 8;
+ rgbBlue := (255+ImageSource[i*3] * AlphaSource[i] + rgbBlue *
+ (255 - AlphaSource[i])) shr 8;
+ end;
+
+ {Move pointers}
+ Longint(ImageData) := Longint(ImageData) + BytesPerRowDest;
+ Longint(ImageSource) := Longint(ImageSource) - BytesPerRowSrc;
+ Longint(AlphaSource) := Longint(AlphaSource) + BytesPerRowAlpha;
+ end;
+ {Palette images with 1 byte for each pixel}
+ 1,4,8: if Header.ColorType = COLOR_GRAYSCALEALPHA then
+ FOR j := 1 TO Header.Height DO
+ begin
+ {Process all the pixels in this line}
+ FOR i := 0 TO Header.Width - 1 DO
+ with ImageData[i], Header.BitmapInfo do begin
+ rgbRed := (255 + ImageSource[i] * AlphaSource[i] +
+ rgbRed * (255 - AlphaSource[i])) shr 8;
+ rgbGreen := (255 + ImageSource[i] * AlphaSource[i] +
+ rgbGreen * (255 - AlphaSource[i])) shr 8;
+ rgbBlue := (255 + ImageSource[i] * AlphaSource[i] +
+ rgbBlue * (255 - AlphaSource[i])) shr 8;
+ end;
+
+ {Move pointers}
+ Longint(ImageData) := Longint(ImageData) + BytesPerRowDest;
+ Longint(ImageSource) := Longint(ImageSource) - BytesPerRowSrc;
+ Longint(AlphaSource) := Longint(AlphaSource) + BytesPerRowAlpha;
+ end
+ else {Palette images}
+ begin
+ {Obtain pointer to the transparency chunk}
+ TransparencyChunk := TChunktRNS(Chunks.ItemFromClass(TChunktRNS));
+ PaletteChunk := TChunkPLTE(Chunks.ItemFromClass(TChunkPLTE));
+
+ FOR j := 1 TO Header.Height DO
+ begin
+ {Process all the pixels in this line}
+ i := 0; Data := @ImageSource[0];
+ repeat
+ CurBit := 0;
+
+ repeat
+ {Obtains the palette index}
+ case Header.BitDepth of
+ 1: PaletteIndex := (Data^ shr (7-(I Mod 8))) and 1;
+ 2,4: PaletteIndex := (Data^ shr ((1-(I Mod 2))*4)) and $0F;
+ else PaletteIndex := Data^;
+ end;
+
+ {Updates the image with the new pixel}
+ with ImageData[i] do
+ begin
+ TransValue := TransparencyChunk.PaletteValues[PaletteIndex];
+ rgbRed := (255 + PaletteChunk.Item[PaletteIndex].rgbRed *
+ TransValue + rgbRed * (255 - TransValue)) shr 8;
+ rgbGreen := (255 + PaletteChunk.Item[PaletteIndex].rgbGreen *
+ TransValue + rgbGreen * (255 - TransValue)) shr 8;
+ rgbBlue := (255 + PaletteChunk.Item[PaletteIndex].rgbBlue *
+ TransValue + rgbBlue * (255 - TransValue)) shr 8;
+ end;
+
+ {Move to next data}
+ inc(i); inc(CurBit, Header.BitmapInfo.bmiHeader.biBitCount);
+ until CurBit >= 8;
+ {Move to next source data}
+ inc(Data);
+ until i >= Integer(Header.Width);
+
+ {Move pointers}
+ Longint(ImageData) := Longint(ImageData) + BytesPerRowDest;
+ Longint(ImageSource) := Longint(ImageSource) - BytesPerRowSrc;
+ end
+ end {Palette images}
+ end {case Header.BitmapInfo.bmiHeader.biBitCount};
+
+ {Draws the new bitmap on the foreground}
+ StretchBlt(DC, Rect.Left, Rect.Top, Header.Width, Header.Height, BufferDC,
+ 0, 0, Header.Width, Header.Height, SRCCOPY);
+
+ {Free bitmap}
+ SelectObject(BufferDC, OldBitmap);
+ DeleteObject(BufferBitmap);
+ DeleteDC(BufferDC);
+end;
+
+{Draws the image into a canvas}
+procedure TPngObject.Draw(ACanvas: TCanvas; const Rect: TRect);
+var
+ Header: TChunkIHDR;
+begin
+ {Quit in case there is no header, otherwise obtain it}
+ if (Chunks.Count = 0) or not (Chunks.GetItem(0) is TChunkIHDR) then Exit;
+ Header := Chunks.GetItem(0) as TChunkIHDR;
+
+ {Copy the data to the canvas}
+ case Self.TransparencyMode of
+ {$IFDEF PartialTransparentDraw}
+ ptmPartial:
+ DrawPartialTrans(ACanvas{$IFDEF UseDelphi}.Handle{$ENDIF}, Rect);
+ {$ENDIF}
+ ptmBit: DrawTransparentBitmap(ACanvas{$IFDEF UseDelphi}.Handle{$ENDIF},
+ Header.ImageData, Header.BitmapInfo.bmiHeader,
+ pBitmapInfo(@Header.BitmapInfo), Rect,
+ {$IFDEF UseDelphi}ColorToRGB({$ENDIF}TransparentColor)
+ {$IFDEF UseDelphi}){$ENDIF}
+ else
+ StretchDiBits(ACanvas{$IFDEF UseDelphi}.Handle{$ENDIF}, Rect.Left,
+ Rect.Top, Rect.Right - Rect.Left, Rect.Bottom - Rect.Top, 0, 0,
+ Header.Width, Header.Height, Header.ImageData,
+ pBitmapInfo(@Header.BitmapInfo)^, DIB_RGB_COLORS, SRCCOPY)
+ end {case}
+end;
+
+{Characters for the header}
+const
+ PngHeader: Array[0..7] of Char = (#137, #80, #78, #71, #13, #10, #26, #10);
+
+{Loads the image from a stream of data}
+procedure TPngObject.LoadFromStream(Stream: TStream);
+var
+ Header : Array[0..7] of Char;
+ HasIDAT : Boolean;
+
+ {Chunks reading}
+ ChunkCount : Cardinal;
+ ChunkLength: Cardinal;
+ ChunkName : TChunkName;
+begin
+ {Initialize before start loading chunks}
+ ChunkCount := 0;
+ ClearChunks();
+ {Reads the header}
+ Stream.Read(Header[0], 8);
+
+ {Test if the header matches}
+ if Header <> PngHeader then
+ begin
+ RaiseError(EPNGInvalidFileHeader, EPNGInvalidFileHeaderText);
+ Exit;
+ end;
+
+
+ HasIDAT := FALSE;
+ Chunks.Count := 10;
+
+ {Load chunks}
+ repeat
+ inc(ChunkCount); {Increment number of chunks}
+ if Chunks.Count < ChunkCount then {Resize the chunks list if needed}
+ Chunks.Count := Chunks.Count + 10;
+
+ {Reads chunk length and invert since it is in network order}
+ {also checks the Read method return, if it returns 0, it}
+ {means that no bytes was readed, probably because it reached}
+ {the end of the file}
+ if Stream.Read(ChunkLength, 4) = 0 then
+ begin
+ {In case it found the end of the file here}
+ Chunks.Count := ChunkCount - 1;
+ RaiseError(EPNGUnexpectedEnd, EPNGUnexpectedEndText);
+ end;
+
+ ChunkLength := ByteSwap(ChunkLength);
+ {Reads chunk name}
+ Stream.Read(Chunkname, 4);
+
+ {Here we check if the first chunk is the Header which is necessary}
+ {to the file in order to be a valid Portable Network Graphics image}
+ if (ChunkCount = 1) and (ChunkName <> 'IHDR') then
+ begin
+ Chunks.Count := ChunkCount - 1;
+ RaiseError(EPNGIHDRNotFirst, EPNGIHDRNotFirstText);
+ exit;
+ end;
+
+ {Has a previous IDAT}
+ if (HasIDAT and (ChunkName = 'IDAT')) or (ChunkName = 'cHRM') then
+ begin
+ dec(ChunkCount);
+ Stream.Seek(ChunkLength + 4, soFromCurrent);
+ Continue;
+ end;
+ {Tell it has an IDAT chunk}
+ if ChunkName = 'IDAT' then HasIDAT := TRUE;
+
+ {Creates object for this chunk}
+ Chunks.SetItem(ChunkCount - 1, CreateClassChunk(Self, ChunkName));
+
+ {Check if the chunk is critical and unknown}
+ {$IFDEF ErrorOnUnknownCritical}
+ if (TChunk(Chunks.Item[ChunkCount - 1]).ClassType = TChunk) and
+ ((Byte(ChunkName[0]) AND $20) = 0) and (ChunkName <> '') then
+ begin
+ Chunks.Count := ChunkCount;
+ RaiseError(EPNGUnknownCriticalChunk, EPNGUnknownCriticalChunkText);
+ end;
+ {$ENDIF}
+
+ {Loads it}
+ try if not TChunk(Chunks.Item[ChunkCount - 1]).LoadFromStream(Stream,
+ ChunkName, ChunkLength) then break;
+ except
+ Chunks.Count := ChunkCount;
+ raise;
+ end;
+
+ {Terminates when it reaches the IEND chunk}
+ until (ChunkName = 'IEND');
+
+ {Resize the list to the appropriate size}
+ Chunks.Count := ChunkCount;
+
+ {Check if there is data}
+ if not HasIDAT then
+ RaiseError(EPNGNoImageData, EPNGNoImageDataText);
+end;
+
+{Changing height is not supported}
+procedure TPngObject.SetHeight(Value: Integer);
+begin
+ RaiseError(EPNGError, EPNGCannotChangeSizeText);
+end;
+
+{Changing width is not supported}
+procedure TPngObject.SetWidth(Value: Integer);
+begin
+ RaiseError(EPNGError, EPNGCannotChangeSizeText);
+end;
+
+{$IFDEF UseDelphi}
+{Saves to clipboard format (thanks to Antoine Pottern)}
+procedure TPNGObject.SaveToClipboardFormat(var AFormat: Word;
+ var AData: THandle; var APalette: HPalette);
+begin
+ with TBitmap.Create do
+ try
+ Width := Self.Width;
+ Height := Self.Height;
+ Self.Draw(Canvas, Rect(0, 0, Width, Height));
+ SaveToClipboardFormat(AFormat, AData, APalette);
+ finally
+ Free;
+ end {try}
+end;
+
+{Loads data from clipboard}
+procedure TPngObject.LoadFromClipboardFormat(AFormat: Word;
+ AData: THandle; APalette: HPalette);
+begin
+ with TBitmap.Create do
+ try
+ LoadFromClipboardFormat(AFormat, AData, APalette);
+ Self.AssignHandle(Handle, False, 0);
+ finally
+ Free;
+ end {try}
+end;
+
+{Returns if the image is transparent}
+function TPngObject.GetTransparent: Boolean;
+begin
+ Result := (TransparencyMode <> ptmNone);
+end;
+
+{$ENDIF}
+
+{Saving the PNG image to a stream of data}
+procedure TPngObject.SaveToStream(Stream: TStream);
+var
+ j: Integer;
+begin
+ {Reads the header}
+ Stream.Write(PNGHeader[0], 8);
+ {Write each chunk}
+ FOR j := 0 TO Chunks.Count - 1 DO
+ Chunks.Item[j].SaveToStream(Stream)
+end;
+
+{Prepares the Header chunk}
+procedure BuildHeader(Header: TChunkIHDR; Handle: HBitmap; Info: pBitmap;
+ HasPalette: Boolean);
+var
+ DC: HDC;
+begin
+ {Set width and height}
+ Header.Width := Info.bmWidth;
+ Header.Height := abs(Info.bmHeight);
+ {Set bit depth}
+ if Info.bmBitsPixel >= 16 then
+ Header.BitDepth := 8 else Header.BitDepth := Info.bmBitsPixel;
+ {Set color type}
+ if Info.bmBitsPixel >= 16 then
+ Header.ColorType := COLOR_RGB else Header.ColorType := COLOR_PALETTE;
+ {Set other info}
+ Header.CompressionMethod := 0; {deflate/inflate}
+ Header.InterlaceMethod := 0; {no interlace}
+
+ {Prepares bitmap headers to hold data}
+ Header.PrepareImageData();
+ {Copy image data}
+ DC := CreateCompatibleDC(0);
+ GetDIBits(DC, Handle, 0, Header.Height, Header.ImageData,
+ pBitmapInfo(@Header.BitmapInfo)^, DIB_RGB_COLORS);
+ DeleteDC(DC);
+end;
+
+{Loads the image from a resource}
+procedure TPngObject.LoadFromResourceName(Instance: HInst;
+ const Name: String);
+var
+ ResStream: TResourceStream;
+begin
+ {Creates an especial stream to load from the resource}
+ try ResStream := TResourceStream.Create(Instance, Name, RT_RCDATA);
+ except RaiseError(EPNGCouldNotLoadResource, EPNGCouldNotLoadResourceText);
+ exit; end;
+
+ {Loads the png image from the resource}
+ try
+ LoadFromStream(ResStream);
+ finally
+ ResStream.Free;
+ end;
+end;
+
+{Loads the png from a resource ID}
+procedure TPngObject.LoadFromResourceID(Instance: HInst; ResID: Integer);
+begin
+ LoadFromResourceName(Instance, String(ResID));
+end;
+
+{Assigns this tpngobject to another object}
+procedure TPngObject.AssignTo(Dest: TPersistent);
+{$IFDEF UseDelphi}
+var
+ DeskDC: HDC;
+ TRNS: TChunkTRNS;
+{$ENDIF}
+begin
+ {If the destination is also a TPNGObject make it assign}
+ {this one}
+ if Dest is TPNGObject then
+ TPNGObject(Dest).AssignPNG(Self)
+ {$IFDEF UseDelphi}
+ {In case the destination is a bitmap}
+ else if (Dest is TBitmap) and HeaderPresent then
+ begin
+ {Device context}
+ DeskDC := GetDC(0);
+ {Copy the data}
+ TBitmap(Dest).Handle := CreateDIBitmap(DeskDC,
+ Header.BitmapInfo.bmiHeader, CBM_INIT, Header.ImageData,
+ pBitmapInfo(@Header.BitmapInfo)^, DIB_RGB_COLORS);
+ ReleaseDC(0, DeskDC);
+ {Tests for the best pixelformat}
+ case Header.BitmapInfo.bmiHeader.biBitCount of
+ 1: TBitmap(Dest).PixelFormat := pf1Bit;
+ 4: TBitmap(Dest).PixelFormat := pf4Bit;
+ 8: TBitmap(Dest).PixelFormat := pf8Bit;
+ 24: TBitmap(Dest).PixelFormat := pf24Bit;
+ 32: TBitmap(Dest).PixelFormat := pf32Bit;
+ end {case Header.BitmapInfo.bmiHeader.biBitCount};
+
+ {Copy transparency mode}
+ if (TransparencyMode = ptmBit) then
+ begin
+ TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS;
+ TBitmap(Dest).TransparentColor := TRNS.TransparentColor;
+ TBitmap(Dest).Transparent := True
+ end {if (TransparencyMode = ptmBit)}
+
+ end
+ else
+ {Unknown destination kind, }
+ inherited AssignTo(Dest);
+ {$ENDIF}
+end;
+
+{Assigns from a bitmap object}
+procedure TPngObject.AssignHandle(Handle: HBitmap; Transparent: Boolean;
+ TransparentColor: ColorRef);
+var
+ BitmapInfo: Windows.TBitmap;
+ HasPalette: Boolean;
+
+ {Chunks}
+ Header: TChunkIHDR;
+ PLTE: TChunkPLTE;
+ IDAT: TChunkIDAT;
+ IEND: TChunkIEND;
+ TRNS: TChunkTRNS;
+begin
+ {Obtain bitmap info}
+ GetObject(Handle, SizeOf(BitmapInfo), @BitmapInfo);
+
+ {Only bit depths 1, 4 and 8 needs a palette}
+ HasPalette := (BitmapInfo.bmBitsPixel < 16);
+
+ {Clear old chunks and prepare}
+ ClearChunks();
+
+ {Create the chunks}
+ Header := TChunkIHDR.Create(Self);
+ if HasPalette then PLTE := TChunkPLTE.Create(Self) else PLTE := nil;
+ if Transparent then TRNS := TChunkTRNS.Create(Self) else TRNS := nil;
+ IDAT := TChunkIDAT.Create(Self);
+ IEND := TChunkIEND.Create(Self);
+
+ {Add chunks}
+ TPNGPointerList(Chunks).Add(Header);
+ if HasPalette then TPNGPointerList(Chunks).Add(PLTE);
+ if Transparent then TPNGPointerList(Chunks).Add(TRNS);
+ TPNGPointerList(Chunks).Add(IDAT);
+ TPNGPointerList(Chunks).Add(IEND);
+
+ {This method will fill the Header chunk with bitmap information}
+ {and copy the image data}
+ BuildHeader(Header, Handle, @BitmapInfo, HasPalette);
+ {In case there is a image data, set the PLTE chunk fCount variable}
+ {to the actual number of palette colors which is 2^(Bits for each pixel)}
+ if HasPalette then PLTE.fCount := 1 shl BitmapInfo.bmBitsPixel;
+
+ {In case it is a transparent bitmap, prepares it}
+ if Transparent then TRNS.TransparentColor := TransparentColor;
+
+end;
+
+{Assigns from another PNG}
+procedure TPngObject.AssignPNG(Source: TPNGObject);
+var
+ J: Integer;
+begin
+ {Copy properties}
+ InterlaceMethod := Source.InterlaceMethod;
+ MaxIdatSize := Source.MaxIdatSize;
+ CompressionLevel := Source.CompressionLevel;
+ Filters := Source.Filters;
+
+ {Clear old chunks and prepare}
+ ClearChunks();
+ Chunks.Count := Source.Chunks.Count;
+ {Create chunks and makes a copy from the source}
+ FOR J := 0 TO Chunks.Count - 1 DO
+ with Source.Chunks do
+ begin
+ Chunks.SetItem(J, TChunkClass(TChunk(Item[J]).ClassType).Create(Self));
+ TChunk(Chunks.Item[J]).Assign(TChunk(Item[J]));
+ end {with};
+end;
+
+{Returns a alpha data scanline}
+function TPngObject.GetAlphaScanline(const LineIndex: Integer): pByteArray;
+begin
+ with Header do
+ if (ColorType = COLOR_RGBALPHA) or (ColorType = COLOR_GRAYSCALEALPHA) then
+ Longint(Result) := Longint(ImageAlpha) + (LineIndex * Longint(Width))
+ else Result := nil; {In case the image does not use alpha information}
+end;
+
+{$IFDEF Store16bits}
+{Returns a png data extra scanline}
+function TPngObject.GetExtraScanline(const LineIndex: Integer): Pointer;
+begin
+ with Header do
+ Longint(Result) := (Longint(ExtraImageData) + ((Longint(Height) - 1) *
+ BytesPerRow)) - (LineIndex * BytesPerRow);
+end;
+{$ENDIF}
+
+{Returns a png data scanline}
+function TPngObject.GetScanline(const LineIndex: Integer): Pointer;
+begin
+ with Header do
+ Longint(Result) := (Longint(ImageData) + ((Longint(Height) - 1) *
+ BytesPerRow)) - (LineIndex * BytesPerRow);
+end;
+
+{Initialize gamma table}
+procedure TPngObject.InitializeGamma;
+var
+ i: Integer;
+begin
+ {Build gamma table as if there was no gamma}
+ FOR i := 0 to 255 do
+ begin
+ GammaTable[i] := i;
+ InverseGamma[i] := i;
+ end {for i}
+end;
+
+{Returns the transparency mode used by this png}
+function TPngObject.GetTransparencyMode: TPNGTransparencyMode;
+var
+ TRNS: TChunkTRNS;
+begin
+ with Header do
+ begin
+ Result := ptmNone; {Default result}
+ {Gets the TRNS chunk pointer}
+ TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS;
+
+ {Test depending on the color type}
+ case ColorType of
+ {This modes are always partial}
+ COLOR_RGBALPHA, COLOR_GRAYSCALEALPHA: Result := ptmPartial;
+ {This modes support bit transparency}
+ COLOR_RGB, COLOR_GRAYSCALE: if TRNS <> nil then Result := ptmBit;
+ {Supports booth translucid and bit}
+ COLOR_PALETTE:
+ {A TRNS chunk must be present, otherwise it won't support transparency}
+ if TRNS <> nil then
+ if TRNS.BitTransparency then
+ Result := ptmBit else Result := ptmPartial
+ end {case}
+
+ end {with Header}
+end;
+
+{Add a text chunk}
+procedure TPngObject.AddtEXt(const Keyword, Text: String);
+var
+ TextChunk: TChunkTEXT;
+begin
+ TextChunk := Chunks.Add(TChunkText) as TChunkTEXT;
+ TextChunk.Keyword := Keyword;
+ TextChunk.Text := Text;
+end;
+
+{Add a text chunk}
+procedure TPngObject.AddzTXt(const Keyword, Text: String);
+var
+ TextChunk: TChunkzTXt;
+begin
+ TextChunk := Chunks.Add(TChunkText) as TChunkzTXt;
+ TextChunk.Keyword := Keyword;
+ TextChunk.Text := Text;
+end;
+
+{Removes the image transparency}
+procedure TPngObject.RemoveTransparency;
+var
+ TRNS: TChunkTRNS;
+begin
+ TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS;
+ if TRNS <> nil then Chunks.RemoveChunk(TRNS)
+end;
+
+{Generates alpha information}
+procedure TPngObject.CreateAlpha;
+var
+ TRNS: TChunkTRNS;
+begin
+ {Generates depending on the color type}
+ with Header do
+ case ColorType of
+ {Png allocates different memory space to hold alpha information}
+ {for these types}
+ COLOR_GRAYSCALE, COLOR_RGB:
+ begin
+ {Transform into the appropriate color type}
+ if ColorType = COLOR_GRAYSCALE then
+ ColorType := COLOR_GRAYSCALEALPHA
+ else ColorType := COLOR_RGBALPHA;
+ {Allocates memory to hold alpha information}
+ GetMem(ImageAlpha, Integer(Width) * Integer(Height));
+ FillChar(ImageAlpha^, Integer(Width) * Integer(Height), #255);
+ end;
+ {Palette uses the TChunktRNS to store alpha}
+ COLOR_PALETTE:
+ begin
+ {Gets/creates TRNS chunk}
+ if Chunks.ItemFromClass(TChunkTRNS) = nil then
+ TRNS := Chunks.Add(TChunkTRNS) as TChunkTRNS
+ else
+ TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS;
+
+ {Prepares the TRNS chunk}
+ with TRNS do
+ begin
+ Fillchar(PaletteValues[0], 256, 255);
+ fDataSize := 1 shl Header.BitDepth;
+ fBitTransparency := False
+ end {with Chunks.Add};
+ end;
+ end {case Header.ColorType}
+
+end;
+
+{Returns transparent color}
+function TPngObject.GetTransparentColor: TColor;
+var
+ TRNS: TChunkTRNS;
+begin
+ TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS;
+ {Reads the transparency chunk to get this info}
+ if Assigned(TRNS) then Result := TRNS.TransparentColor
+ else Result := 0
+end;
+
+{$OPTIMIZATION OFF}
+procedure TPngObject.SetTransparentColor(const Value: TColor);
+var
+ TRNS: TChunkTRNS;
+begin
+ if HeaderPresent then
+ {Tests the ColorType}
+ case Header.ColorType of
+ {Not allowed for this modes}
+ COLOR_RGBALPHA, COLOR_GRAYSCALEALPHA: Self.RaiseError(
+ EPNGCannotChangeTransparent, EPNGCannotChangeTransparentText);
+ {Allowed}
+ COLOR_PALETTE, COLOR_RGB, COLOR_GRAYSCALE:
+ begin
+ TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS;
+ if not Assigned(TRNS) then TRNS := Chunks.Add(TChunkTRNS) as TChunkTRNS;
+
+ {Sets the transparency value from TRNS chunk}
+ TRNS.TransparentColor := {$IFDEF UseDelphi}ColorToRGB({$ENDIF}Value{$IFDEF UseDelphi}){$ENDIF}
+ end {COLOR_PALETTE, COLOR_RGB, COLOR_GRAYSCALE)}
+ end {case}
+end;
+
+{Returns if header is present}
+function TPngObject.HeaderPresent: Boolean;
+begin
+ Result := ((Chunks.Count <> 0) and (Chunks.Item[0] is TChunkIHDR))
+end;
+
+{Returns pixel for png using palette and grayscale}
+function GetByteArrayPixel(const png: TPngObject; const X, Y: Integer): TColor;
+var
+ ByteData: Byte;
+ DataDepth: Byte;
+begin
+ with png, Header do
+ begin
+ {Make sure the bitdepth is not greater than 8}
+ DataDepth := BitDepth;
+ if DataDepth > 8 then DataDepth := 8;
+ {Obtains the byte containing this pixel}
+ ByteData := pByteArray(png.Scanline[Y])^[X div (8 div DataDepth)];
+ {Moves the bits we need to the right}
+ ByteData := (ByteData shr ((8 - DataDepth) -
+ (X mod (8 div DataDepth)) * DataDepth));
+ {Discard the unwanted pixels}
+ ByteData:= ByteData and ($FF shr (8 - DataDepth));
+
+ {For palette mode map the palette entry and for grayscale convert and
+ returns the intensity}
+ case ColorType of
+ COLOR_PALETTE:
+ with TChunkPLTE(png.Chunks.ItemFromClass(TChunkPLTE)).Item[ByteData] do
+ Result := rgb(GammaTable[rgbRed], GammaTable[rgbGreen],
+ GammaTable[rgbBlue]);
+ COLOR_GRAYSCALE:
+ begin
+ ByteData := GammaTable[ByteData * ((1 shl DataDepth) + 1)];
+ Result := rgb(ByteData, ByteData, ByteData);
+ end;
+ else Result := 0;
+ end {case};
+ end {with}
+end;
+
+{In case vcl units are not being used}
+{$IFNDEF UseDelphi}
+function ColorToRGB(const Color: TColor): COLORREF;
+begin
+ Result := Color
+end;
+{$ENDIF}
+
+{Sets a pixel for grayscale and palette pngs}
+procedure SetByteArrayPixel(const png: TPngObject; const X, Y: Integer;
+ const Value: TColor);
+const
+ ClearFlag: Array[1..8] of Integer = (1, 3, 0, 15, 0, 0, 0, $FF);
+var
+ ByteData: pByte;
+ DataDepth: Byte;
+ ValEntry: Byte;
+begin
+ with png.Header do
+ begin
+ {Map into a palette entry}
+ ValEntry := GetNearestPaletteIndex(Png.Palette, ColorToRGB(Value));
+
+ {16 bits grayscale extra bits are discarted}
+ DataDepth := BitDepth;
+ if DataDepth > 8 then DataDepth := 8;
+ {Gets a pointer to the byte we intend to change}
+ ByteData := @pByteArray(png.Scanline[Y])^[X div (8 div DataDepth)];
+ {Clears the old pixel data}
+ ByteData^ := ByteData^ and not (ClearFlag[DataDepth] shl ((8 - DataDepth) -
+ (X mod (8 div DataDepth)) * DataDepth));
+
+ {Setting the new pixel}
+ ByteData^ := ByteData^ or (ValEntry shl ((8 - DataDepth) -
+ (X mod (8 div DataDepth)) * DataDepth));
+ end {with png.Header}
+end;
+
+{Returns pixel when png uses RGB}
+function GetRGBLinePixel(const png: TPngObject;
+ const X, Y: Integer): TColor;
+begin
+ with pRGBLine(png.Scanline[Y])^[X] do
+ Result := RGB(rgbtRed, rgbtGreen, rgbtBlue)
+end;
+
+{Sets pixel when png uses RGB}
+procedure SetRGBLinePixel(const png: TPngObject;
+ const X, Y: Integer; Value: TColor);
+begin
+ with pRGBLine(png.Scanline[Y])^[X] do
+ begin
+ rgbtRed := GetRValue(Value);
+ rgbtGreen := GetGValue(Value);
+ rgbtBlue := GetBValue(Value)
+ end
+end;
+
+{Sets a pixel}
+procedure TPngObject.SetPixels(const X, Y: Integer; const Value: TColor);
+begin
+ if (X in [0..Width - 1]) and (Y in [0..Height - 1]) then
+ with Header do
+ begin
+ if ColorType in [COLOR_GRAYSCALE, COLOR_PALETTE] then
+ SetByteArrayPixel(Self, X, Y, Value)
+ else
+ SetRGBLinePixel(Self, X, Y, Value)
+ end {with}
+end;
+
+{Returns a pixel}
+function TPngObject.GetPixels(const X, Y: Integer): TColor;
+begin
+ if (X in [0..Width - 1]) and (Y in [0..Height - 1]) then
+ with Header do
+ begin
+ if ColorType in [COLOR_GRAYSCALE, COLOR_PALETTE] then
+ Result := GetByteArrayPixel(Self, X, Y)
+ else
+ Result := GetRGBLinePixel(Self, X, Y)
+ end {with}
+ else Result := 0
+end;
+
+{Returns the image palette}
+function TPngObject.GetPalette: HPALETTE;
+var
+ LogPalette: TMaxLogPalette;
+ i: Integer;
+begin
+ {Palette is avaliable for COLOR_PALETTE and COLOR_GRAYSCALE modes}
+ if (Header.ColorType in [COLOR_PALETTE, COLOR_GRAYSCALE]) then
+ begin
+ {In case the pal}
+ if TempPalette = 0 then
+ with LogPalette do
+ begin
+ {Prepares the new palette}
+ palVersion := $300;
+ palNumEntries := 256;
+ {Copy entries}
+ for i := 0 to LogPalette.palNumEntries - 1 do
+ begin
+ palPalEntry[i].peRed := Header.BitmapInfo.bmiColors[i].rgbRed;
+ palPalEntry[i].peGreen := Header.BitmapInfo.bmiColors[i].rgbGreen;
+ palPalEntry[i].peBlue := Header.BitmapInfo.bmiColors[i].rgbBlue;
+ palPalEntry[i].peFlags := 0;
+ end {for i};
+ {Creates the palette}
+ TempPalette := CreatePalette(pLogPalette(@LogPalette)^);
+ end {with LogPalette, if Temppalette = 0}
+ end {if Header.ColorType in ...};
+ Result := TempPalette;
+end;
+
+initialization
+ {Initialize}
+ ChunkClasses := nil;
+ {crc table has not being computed yet}
+ crc_table_computed := FALSE;
+ {Register the necessary chunks for png}
+ RegisterCommonChunks;
+ {Registers TPNGObject to use with TPicture}
+ {$IFDEF UseDelphi}{$IFDEF RegisterGraphic}
+ TPicture.RegisterFileFormat('PNG', 'Portable Network Graphics', TPNGObject);
+ {$ENDIF}{$ENDIF}
+finalization
+ {$IFDEF UseDelphi}{$IFDEF RegisterGraphic}
+ TPicture.UnregisterGraphicClass(TPNGObject);
+ {$ENDIF}{$ENDIF}
+ {Free chunk classes}
+ FreeChunkClassList;
+end.
+
+
diff --git a/Game/Code/lib/PngImage/pnglang.pas b/Game/Code/lib/PngImage/pnglang.pas new file mode 100644 index 00000000..7a9c5078 --- /dev/null +++ b/Game/Code/lib/PngImage/pnglang.pas @@ -0,0 +1,301 @@ +{Portable Network Graphics Delphi Language Info (24 July 2002)}
+
+{Feel free to change the text bellow to adapt to your language}
+{Also if you have a translation to other languages and want to}
+{share it, send me: gubadaud@terra.com.br }
+unit pnglang;
+
+interface
+
+{$DEFINE English}
+{.$DEFINE Portuguese}
+{.$DEFINE German}
+{.$DEFINE French}
+{.$DEFINE Slovenian}
+
+{Language strings for english}
+resourcestring
+ {$IFDEF English}
+ EPngInvalidCRCText = 'This "Portable Network Graphics" image is not valid ' +
+ 'because it contains invalid pieces of data (crc error)';
+ EPNGInvalidIHDRText = 'The "Portable Network Graphics" image could not be ' +
+ 'loaded because one of its main piece of data (ihdr) might be corrupted';
+ EPNGMissingMultipleIDATText = 'This "Portable Network Graphics" image is ' +
+ 'invalid because it has missing image parts.';
+ EPNGZLIBErrorText = 'Could not decompress the image because it contains ' +
+ 'invalid compressed data.'#13#10 + ' Description: ';
+ EPNGInvalidPaletteText = 'The "Portable Network Graphics" image contains ' +
+ 'an invalid palette.';
+ EPNGInvalidFileHeaderText = 'The file being readed is not a valid '+
+ '"Portable Network Graphics" image because it contains an invalid header.' +
+ ' This file may be corruped, try obtaining it again.';
+ EPNGIHDRNotFirstText = 'This "Portable Network Graphics" image is not ' +
+ 'supported or it might be invalid.'#13#10 + '(IHDR chunk is not the first)';
+ EPNGNotExistsText = 'The png file could not be loaded because it does not ' +
+ 'exists.';
+ EPNGSizeExceedsText = 'This "Portable Network Graphics" image is not ' +
+ 'supported because either it''s width or height exceeds the maximum ' +
+ 'size, which is 65535 pixels length.';
+ EPNGUnknownPalEntryText = 'There is no such palette entry.';
+ EPNGMissingPaletteText = 'This "Portable Network Graphics" could not be ' +
+ 'loaded because it uses a color table which is missing.';
+ EPNGUnknownCriticalChunkText = 'This "Portable Network Graphics" image ' +
+ 'contains an unknown critical part which could not be decoded.';
+ EPNGUnknownCompressionText = 'This "Portable Network Graphics" image is ' +
+ 'encoded with an unknown compression scheme which could not be decoded.';
+ EPNGUnknownInterlaceText = 'This "Portable Network Graphics" image uses ' +
+ 'an unknown interlace scheme which could not be decoded.';
+ EPNGCannotAssignChunkText = 'The chunks must be compatible to be assigned.';
+ EPNGUnexpectedEndText = 'This "Portable Network Graphics" image is invalid ' +
+ 'because the decoder found an unexpected end of the file.';
+ EPNGNoImageDataText = 'This "Portable Network Graphics" image contains no ' +
+ 'data.';
+ EPNGCannotChangeSizeText = 'The "Portable Network Graphics" image can not ' +
+ 'be resize by changing width and height properties. Try assigning the ' +
+ 'image from a bitmap.';
+ EPNGCannotAddChunkText = 'The program tried to add a existent critical ' +
+ 'chunk to the current image which is not allowed.';
+ EPNGCannotAddInvalidImageText = 'It''s not allowed to add a new chunk ' +
+ 'because the current image is invalid.';
+ EPNGCouldNotLoadResourceText = 'The png image could not be loaded from the ' +
+ 'resource ID.';
+ EPNGOutMemoryText = 'Some operation could not be performed because the ' +
+ 'system is out of resources. Close some windows and try again.';
+ EPNGCannotChangeTransparentText = 'Setting bit transparency color is not ' +
+ 'allowed for png images containing alpha value for each pixel ' +
+ '(COLOR_RGBALPHA and COLOR_GRAYSCALEALPHA)';
+ EPNGHeaderNotPresentText = 'This operation is not valid because the ' +
+ 'current image contains no valid header.';
+ {$ENDIF}
+ {$IFDEF Portuguese}
+ EPngInvalidCRCText = 'Essa imagem "Portable Network Graphics" năo é válida ' +
+ 'porque contém chunks inválidos de dados (erro crc)';
+ EPNGInvalidIHDRText = 'A imagem "Portable Network Graphics" năo pode ser ' +
+ 'carregada porque um dos seus chunks importantes (ihdr) pode estar '+
+ 'inválido';
+ EPNGMissingMultipleIDATText = 'Essa imagem "Portable Network Graphics" é ' +
+ 'inválida porque tem chunks de dados faltando.';
+ EPNGZLIBErrorText = 'Năo foi possível descomprimir os dados da imagem ' +
+ 'porque ela contém dados inválidos.'#13#10 + ' Descriçăo: ';
+ EPNGInvalidPaletteText = 'A imagem "Portable Network Graphics" contém ' +
+ 'uma paleta inválida.';
+ EPNGInvalidFileHeaderText = 'O arquivo sendo lido năo é uma imagem '+
+ '"Portable Network Graphics" válida porque contém um cabeçalho inválido.' +
+ ' O arquivo pode estar corrompida, tente obter ela novamente.';
+ EPNGIHDRNotFirstText = 'Essa imagem "Portable Network Graphics" năo é ' +
+ 'suportada ou pode ser inválida.'#13#10 + '(O chunk IHDR năo é o ' +
+ 'primeiro)';
+ EPNGNotExistsText = 'A imagem png năo pode ser carregada porque ela năo ' +
+ 'existe.';
+ EPNGSizeExceedsText = 'Essa imagem "Portable Network Graphics" năo é ' +
+ 'suportada porque a largura ou a altura ultrapassam o tamanho máximo, ' +
+ 'que é de 65535 pixels de diâmetro.';
+ EPNGUnknownPalEntryText = 'Năo existe essa entrada de paleta.';
+ EPNGMissingPaletteText = 'Essa imagem "Portable Network Graphics" năo pode ' +
+ 'ser carregada porque usa uma paleta que está faltando.';
+ EPNGUnknownCriticalChunkText = 'Essa imagem "Portable Network Graphics" ' +
+ 'contém um chunk crítico desconheçido que năo pode ser decodificado.';
+ EPNGUnknownCompressionText = 'Essa imagem "Portable Network Graphics" está ' +
+ 'codificada com um esquema de compressăo desconheçido e năo pode ser ' +
+ 'decodificada.';
+ EPNGUnknownInterlaceText = 'Essa imagem "Portable Network Graphics" usa um ' +
+ 'um esquema de interlace que năo pode ser decodificado.';
+ EPNGCannotAssignChunkText = 'Os chunk devem ser compatíveis para serem ' +
+ 'copiados.';
+ EPNGUnexpectedEndText = 'Essa imagem "Portable Network Graphics" é ' +
+ 'inválida porque o decodificador encontrou um fim inesperado.';
+ EPNGNoImageDataText = 'Essa imagem "Portable Network Graphics" năo contém ' +
+ 'dados.';
+ EPNGCannotChangeSizeText = 'A imagem "Portable Network Graphics" năo pode ' +
+ 'ser redimensionada mudando as propriedades width e height. Tente ' +
+ 'copiar a imagem de um bitmap usando a funçăo assign.';
+ EPNGCannotAddChunkText = 'O programa tentou adicionar um chunk crítico ' +
+ 'já existente para a imagem atual, oque năo é permitido.';
+ EPNGCannotAddInvalidImageText = 'Năo é permitido adicionar um chunk novo ' +
+ 'porque a imagem atual é inválida.';
+ EPNGCouldNotLoadResourceText = 'A imagem png năo pode ser carregada apartir' +
+ ' do resource.';
+ EPNGOutMemoryText = 'Uma operaçăo năo pode ser completada porque o sistema ' +
+ 'está sem recursos. Fecha algumas janelas e tente novamente.';
+ EPNGCannotChangeTransparentText = 'Definir transparęncia booleana năo é ' +
+ 'permitido para imagens png contendo informaçăo alpha para cada pixel ' +
+ '(COLOR_RGBALPHA e COLOR_GRAYSCALEALPHA)';
+ EPNGHeaderNotPresentText = 'Essa operaçăo năo é válida porque a ' +
+ 'imagem atual năo contém um cabeçalho válido.';
+ {$ENDIF}
+ {Language strings for German}
+ {$IFDEF German}
+ EPngInvalidCRCText = 'Dieses "Portable Network Graphics" Image ist ' +
+ 'ungültig, weil Teile der Daten ungültig sind (CRC-Fehler).';
+ EPNGInvalidIHDRText = 'Dieses "Portable Network Graphics" Image konnte ' +
+ 'nicht geladen werden, weil eine der Hauptdaten (IHDR) beschädigt ' +
+ 'sein könnte.';
+ EPNGMissingMultipleIDATText = 'Dieses "Portable Network Graphics" Image ' +
+ 'ist ungültig, weil Grafikdaten fehlen.';
+ EPNGZLIBErrorText = 'Die Grafik konnte nicht entpackt werden, weil sie ' +
+ 'fehlerhafte komprimierte Daten enthält.'#13#10 + ' Beschreibung: ';
+ EPNGInvalidPaletteText = 'Das "Portable Network Graphics" Image enthält ' +
+ 'eine ungültige Palette.';
+ EPNGInvalidFileHeaderText = 'Die Datei, die gelesen wird, ist kein ' +
+ 'gültiges "Portable Network Graphics" Image, da es keinen gültigen ' +
+ 'Header enthält. Die Datei könnte beschädigt sein, versuchen Sie, ' +
+ 'eine neue Kopie zu bekommen.';
+ EPNGIHDRNotFirstText = 'Dieses "Portable Network Graphics" Image wird ' +
+ 'nicht unterstützt bzw. es könnte ungültig sein.'#13#10 +
+ '(Der IHDR-Chunk ist nicht der erste Chunk in der Datei).';
+ EPNGNotExistsText = 'Die PNG Datei konnte nicht geladen werden, da sie ' +
+ 'nicht existiert.';
+ EPNGSizeExceedsText = 'Dieses "Portable Network Graphics" Image wird nicht ' +
+ 'unterstützt, weil entweder seine Breite oder seine Höhe das Maximum von ' +
+ '65535 Pixeln überschreitet.';
+ EPNGUnknownPalEntryText = 'Es gibt keinen solchen Palettenwert.';
+ EPNGMissingPaletteText = 'Dieses "Portable Network Graphics" Image konnte ' +
+ 'nicht geladen werden, weil die benötigte Farbtabelle fehlt.';
+ EPNGUnknownCriticalChunkText = 'Dieses "Portable Network Graphics" Image ' +
+ 'enhält einen unbekannten kritischen Teil, welcher nicht entschlüsselt ' +
+ 'werden kann.';
+ EPNGUnknownCompressionText = 'Dieses "Portable Network Graphics" Image ' +
+ 'wurde mit einem unbekannten Komprimierungsalgorithmus kodiert, welcher ' +
+ 'nicht entschlüsselt werden kann.';
+ EPNGUnknownInterlaceText = 'Dieses "Portable Network Graphics" Image ' +
+ 'benutzt ein unbekanntes Interlace-Schema, welcher nicht entschlüsselt ' +
+ 'werden kann.';
+ EPNGCannotAssignChunkText = 'Die Chunks müssen kompatibel sein, um ' +
+ 'zugewiesen werden zu können.';
+ EPNGUnexpectedEndText = 'Dieses "Portable Network Graphics" Image ist ' +
+ 'ungültig, der Dekoder stieß unerwarteterweise auf das Ende der Datei.';
+ EPNGNoImageDataText = 'Dieses "Portable Network Graphics" Image enthält ' +
+ 'keine Daten.';
+ EPNGCannotChangeSizeText = 'Das "Portable Network Graphics" Image kann ' +
+ 'nicht durch Ändern der Eigenschaften Width und Height in seinen ' +
+ 'Abmessungen geändert werden. Versuchen Sie das Image von einer Bitmap ' +
+ 'aus zuzuweisen.';
+ EPNGCannotAddChunkText = 'Das Programm versucht einen existierenden ' +
+ 'kritischen Chunk zum aktuellen Image hinzuzufügen. Dies ist nicht ' +
+ 'zulässig.';
+ EPNGCannotAddInvalidImageText = 'Es ist nicht zulässig, dem aktuellen ' +
+ 'Image einen neuen Chunk hinzuzufügen, da es ungültig ist.';
+ EPNGCouldNotLoadResourceText = 'Das PNG Image konnte nicht von den ' +
+ 'Resourcendaten geladen werden.';
+ EPNGOutMemoryText = 'Es stehen nicht genügend Resourcen im System zur ' +
+ 'Verfügung, um die Operation auszuführen. Schließen Sie einige Fenster '+
+ 'und versuchen Sie es erneut.';
+ EPNGCannotChangeTransparentText = 'Das Setzen der Bit-' +
+ 'Transparent-Farbe ist fuer PNG-Images die Alpha-Werte fuer jedes ' +
+ 'Pixel enthalten (COLOR_RGBALPHA und COLOR_GRAYSCALEALPHA) nicht ' +
+ 'zulaessig';
+ EPNGHeaderNotPresentText = 'Die Datei, die gelesen wird, ist kein ' +
+ 'gültiges "Portable Network Graphics" Image, da es keinen gültigen ' +
+ 'Header enthält.';
+ {$ENDIF}
+ {Language strings for French}
+ {$IFDEF French}
+ EPngInvalidCRCText = 'Cette image "Portable Network Graphics" n''est pas valide ' +
+ 'car elle contient des données invalides (erreur crc)';
+ EPNGInvalidIHDRText = 'Cette image "Portable Network Graphics" n''a pu ętre ' +
+ 'chargée car l''une de ses principale donnée (ihdr) doit ętre corrompue';
+ EPNGMissingMultipleIDATText = 'Cette image "Portable Network Graphics" est ' +
+ 'invalide car elle contient des parties d''image manquantes.';
+ EPNGZLIBErrorText = 'Impossible de décompresser l''image car elle contient ' +
+ 'des données compressées invalides.'#13#10 + ' Description: ';
+ EPNGInvalidPaletteText = 'L''image "Portable Network Graphics" contient ' +
+ 'une palette invalide.';
+ EPNGInvalidFileHeaderText = 'Le fichier actuellement lu est une image '+
+ '"Portable Network Graphics" invalide car elle contient un en-tęte invalide.' +
+ ' Ce fichier doit ętre corrompu, essayer de l''obtenir ŕ nouveau.';
+ EPNGIHDRNotFirstText = 'Cette image "Portable Network Graphics" n''est pas ' +
+ 'supportée ou doit ętre invalide.'#13#10 + '(la partie IHDR n''est pas la premičre)';
+ EPNGNotExistsText = 'Le fichier png n''a pu ętre chargé car il n''éxiste pas.';
+ EPNGSizeExceedsText = 'Cette image "Portable Network Graphics" n''est pas supportée ' +
+ 'car sa longueur ou sa largeur excčde la taille maximale, qui est de 65535 pixels.';
+ EPNGUnknownPalEntryText = 'Il n''y a aucune entrée pour cette palette.';
+ EPNGMissingPaletteText = 'Cette image "Portable Network Graphics" n''a pu ętre ' +
+ 'chargée car elle utilise une table de couleur manquante.';
+ EPNGUnknownCriticalChunkText = 'Cette image "Portable Network Graphics" ' +
+ 'contient une partie critique inconnue qui n'' pu ętre décodée.';
+ EPNGUnknownCompressionText = 'Cette image "Portable Network Graphics" est ' +
+ 'encodée ŕ l''aide d''un schémas de compression inconnu qui ne peut ętre décodé.';
+ EPNGUnknownInterlaceText = 'Cette image "Portable Network Graphics" utilise ' +
+ 'un schémas d''entrelacement inconnu qui ne peut ętre décodé.';
+ EPNGCannotAssignChunkText = 'Ce morceau doit ętre compatible pour ętre assigné.';
+ EPNGUnexpectedEndText = 'Cette image "Portable Network Graphics" est invalide ' +
+ 'car le decodeur est arrivé ŕ une fin de fichier non attendue.';
+ EPNGNoImageDataText = 'Cette image "Portable Network Graphics" ne contient pas de ' +
+ 'données.';
+ EPNGCannotChangeSizeText = 'Cette image "Portable Network Graphics" ne peut pas ' +
+ 'ętre retaillée en changeant ses propriétés width et height. Essayer d''assigner l''image depuis ' +
+ 'un bitmap.';
+ EPNGCannotAddChunkText = 'Le programme a essayé d''ajouter un morceau critique existant ' +
+ 'ŕ l''image actuelle, ce qui n''est pas autorisé.';
+ EPNGCannotAddInvalidImageText = 'Il n''est pas permis d''ajouter un nouveau morceau ' +
+ 'car l''image actuelle est invalide.';
+ EPNGCouldNotLoadResourceText = 'L''image png n''a pu ętre chargée depuis ' +
+ 'l''ID ressource.';
+ EPNGOutMemoryText = 'Certaines opérations n''ont pu ętre effectuée car le ' +
+ 'systčme n''a plus de ressources. Fermez quelques fenętres et essayez ŕ nouveau.';
+ EPNGCannotChangeTransparentText = 'Définir le bit de transparence n''est pas ' +
+ 'permis pour des images png qui contiennent une valeur alpha pour chaque pixel ' +
+ '(COLOR_RGBALPHA et COLOR_GRAYSCALEALPHA)';
+ EPNGHeaderNotPresentText = 'Cette opération n''est pas valide car l''image ' +
+ 'actuelle ne contient pas de header valide.';
+ EPNGAlphaNotSupportedText = 'Le type de couleur de l''image "Portable Network Graphics" actuelle ' +
+ 'contient déjŕ des informations alpha ou il ne peut ętre converti.';
+ {$ENDIF}
+ {Language strings for slovenian}
+ {$IFDEF Slovenian}
+ EPngInvalidCRCText = 'Ta "Portable Network Graphics" slika je neveljavna, ' +
+ 'ker vsebuje neveljavne dele podatkov (CRC napaka).';
+ EPNGInvalidIHDRText = 'Slike "Portable Network Graphics" ni bilo možno ' +
+ 'naložiti, ker je eden od glavnih delov podatkov (IHDR) verjetno pokvarjen.';
+ EPNGMissingMultipleIDATText = 'Ta "Portable Network Graphics" slika je ' +
+ 'naveljavna, ker manjkajo deli slike.';
+ EPNGZLIBErrorText = 'Ne morem raztegniti slike, ker vsebuje ' +
+ 'neveljavne stisnjene podatke.'#13#10 + ' Opis: ';
+ EPNGInvalidPaletteText = 'Slika "Portable Network Graphics" vsebuje ' +
+ 'neveljavno barvno paleto.';
+ EPNGInvalidFileHeaderText = 'Datoteka za branje ni veljavna '+
+ '"Portable Network Graphics" slika, ker vsebuje neveljavno glavo.' +
+ ' Datoteka je verjetno pokvarjena, poskusite jo ponovno naložiti.';
+ EPNGIHDRNotFirstText = 'Ta "Portable Network Graphics" slika ni ' +
+ 'podprta ali pa je neveljavna.'#13#10 + '(IHDR del datoteke ni prvi).';
+ EPNGNotExistsText = 'Ne morem naložiti png datoteke, ker ta ne ' +
+ 'obstaja.';
+ EPNGSizeExceedsText = 'Ta "Portable Network Graphics" slika ni ' +
+ 'podprta, ker ali njena širina ali višina presega najvecjo možno vrednost ' +
+ '65535 pik.';
+ EPNGUnknownPalEntryText = 'Slika nima vnešene take barvne palete.';
+ EPNGMissingPaletteText = 'Te "Portable Network Graphics" ne morem ' +
+ 'naložiti, ker uporablja manjkajoco barvno paleto.';
+ EPNGUnknownCriticalChunkText = 'Ta "Portable Network Graphics" slika ' +
+ 'vsebuje neznan kriticni del podatkov, ki ga ne morem prebrati.';
+ EPNGUnknownCompressionText = 'Ta "Portable Network Graphics" slika je ' +
+ 'kodirana z neznano kompresijsko shemo, ki je ne morem prebrati.';
+ EPNGUnknownInterlaceText = 'Ta "Portable Network Graphics" slika uporablja ' +
+ 'neznano shemo za preliv, ki je ne morem prebrati.';
+ EPNGCannotAssignChunkText = Košcki morajo biti med seboj kompatibilni za prireditev vrednosti.';
+ EPNGUnexpectedEndText = 'Ta "Portable Network Graphics" slika je neveljavna, ' +
+ 'ker je bralnik prišel do nepricakovanega konca datoteke.';
+ EPNGNoImageDataText = 'Ta "Portable Network Graphics" ne vsebuje nobenih ' +
+ 'podatkov.';
+ EPNGCannotChangeSizeText = 'Te "Portable Network Graphics" sliki ne morem ' +
+ 'spremeniti velikosti s spremembo lastnosti višine in širine. Poskusite ' +
+ 'sliko prirediti v bitno sliko.';
+ EPNGCannotAddChunkText = 'Program je poskusil dodati obstojeci kriticni ' +
+ 'kos podatkov k trenutni sliki, kar ni dovoljeno.';
+ EPNGCannotAddInvalidImageText = 'Ni dovoljeno dodati nov kos podatkov, ' +
+ 'ker trenutna slika ni veljavna.';
+ EPNGCouldNotLoadResourceText = 'Ne morem naložiti png slike iz ' +
+ 'skladišca.';
+ EPNGOutMemoryText = 'Ne morem izvesti operacije, ker je ' +
+ 'sistem ostal brez resorjev. Zaprite nekaj oken in poskusite znova.';
+ EPNGCannotChangeTransparentText = 'Ni dovoljeno nastaviti prosojnosti posamezne barve ' +
+ 'za png slike, ki vsebujejo alfa prosojno vrednost za vsako piko ' +
+ '(COLOR_RGBALPHA and COLOR_GRAYSCALEALPHA)';
+ EPNGHeaderNotPresentText = 'Ta operacija ni veljavna, ker ' +
+ 'izbrana slika ne vsebuje veljavne glave.';
+ {$ENDIF}
+
+
+implementation
+
+end.
diff --git a/Game/Code/lib/PngImage/pngzlib.pas b/Game/Code/lib/PngImage/pngzlib.pas new file mode 100644 index 00000000..3155946a --- /dev/null +++ b/Game/Code/lib/PngImage/pngzlib.pas @@ -0,0 +1,172 @@ +{Portable Network Graphics Delphi ZLIB linking (16 May 2002) }
+
+{This unit links ZLIB to pngimage unit in order to implement }
+{the library. It's now using the new ZLIB version, 1.1.4 }
+{Note: The .obj files must be located in the subdirectory \obj}
+
+unit pngzlib;
+
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
+interface
+
+type
+
+ TAlloc = function (AppData: Pointer; Items, Size: Integer): Pointer;
+ TFree = procedure (AppData, Block: Pointer);
+
+ // Internal structure. Ignore.
+ TZStreamRec = packed record
+ next_in: PChar; // next input byte
+ avail_in: Integer; // number of bytes available at next_in
+ total_in: Integer; // total nb of input bytes read so far
+
+ next_out: PChar; // next output byte should be put here
+ avail_out: Integer; // remaining free space at next_out
+ total_out: Integer; // total nb of bytes output so far
+
+ msg: PChar; // last error message, NULL if no error
+ internal: Pointer; // not visible by applications
+
+ zalloc: TAlloc; // used to allocate the internal state
+ zfree: TFree; // used to free the internal state
+ AppData: Pointer; // private data object passed to zalloc and zfree
+
+ data_type: Integer; // best guess about the data type: ascii or binary
+ adler: Integer; // adler32 value of the uncompressed data
+ reserved: Integer; // reserved for future use
+ end;
+
+function inflateInit_(var strm: TZStreamRec; version: PChar; recsize: Integer): Integer; // forward;
+function inflate(var strm: TZStreamRec; flush: Integer): Integer; //forward;
+function inflateEnd(var strm: TZStreamRec): Integer; //forward;
+function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar; recsize: Integer): Integer; //forward;
+function deflate(var strm: TZStreamRec; flush: Integer): Integer; //forward;
+function deflateEnd(var strm: TZStreamRec): Integer; //forward;
+
+const
+ zlib_version = '1.1.4';
+
+function adler32(adler: Integer; buf: PChar; len: Integer): Integer;
+
+
+const
+ Z_NO_FLUSH = 0;
+ Z_PARTIAL_FLUSH = 1;
+ Z_SYNC_FLUSH = 2;
+ Z_FULL_FLUSH = 3;
+ Z_FINISH = 4;
+
+ Z_OK = 0;
+ Z_STREAM_END = 1;
+ Z_NEED_DICT = 2;
+ Z_ERRNO = (-1);
+ Z_STREAM_ERROR = (-2);
+ Z_DATA_ERROR = (-3);
+ Z_MEM_ERROR = (-4);
+ Z_BUF_ERROR = (-5);
+ Z_VERSION_ERROR = (-6);
+
+ Z_NO_COMPRESSION = 0;
+ Z_BEST_SPEED = 1;
+ Z_BEST_COMPRESSION = 9;
+ Z_DEFAULT_COMPRESSION = (-1);
+
+ Z_FILTERED = 1;
+ Z_HUFFMAN_ONLY = 2;
+ Z_DEFAULT_STRATEGY = 0;
+
+ Z_BINARY = 0;
+ Z_ASCII = 1;
+ Z_UNKNOWN = 2;
+
+ Z_DEFLATED = 8;
+
+ _z_errmsg: array[0..9] of PChar = (
+ 'need dictionary', // Z_NEED_DICT (2)
+ 'stream end', // Z_STREAM_END (1)
+ '', // Z_OK (0)
+ 'file error', // Z_ERRNO (-1)
+ 'stream error', // Z_STREAM_ERROR (-2)
+ 'data error', // Z_DATA_ERROR (-3)
+ 'insufficient memory', // Z_MEM_ERROR (-4)
+ 'buffer error', // Z_BUF_ERROR (-5)
+ 'incompatible version', // Z_VERSION_ERROR (-6)
+ ''
+ );
+
+implementation
+
+{$IFNDef FPC}
+ {$L obj\deflate.obj}
+ {$L obj\trees.obj}
+ {$L obj\inflate.obj}
+ {$L obj\inftrees.obj}
+ {$L obj\adler32.obj}
+ {$L obj\infblock.obj}
+ {$L obj\infcodes.obj}
+ {$L obj\infutil.obj}
+ {$L obj\inffast.obj}
+{$ENDIF}
+
+procedure _tr_init; external;
+procedure _tr_tally; external;
+procedure _tr_flush_block; external;
+procedure _tr_align; external;
+procedure _tr_stored_block; external;
+function adler32; external;
+procedure inflate_blocks_new; external;
+procedure inflate_blocks; external;
+procedure inflate_blocks_reset; external;
+procedure inflate_blocks_free; external;
+procedure inflate_set_dictionary; external;
+procedure inflate_trees_bits; external;
+procedure inflate_trees_dynamic; external;
+procedure inflate_trees_fixed; external;
+procedure inflate_codes_new; external;
+procedure inflate_codes; external;
+procedure inflate_codes_free; external;
+procedure _inflate_mask; external;
+procedure inflate_flush; external;
+procedure inflate_fast; external;
+
+procedure _memset(P: Pointer; B: Byte; count: Integer);cdecl;
+begin
+ FillChar(P^, count, B);
+end;
+
+procedure _memcpy(dest, source: Pointer; count: Integer);cdecl;
+begin
+ Move(source^, dest^, count);
+end;
+
+
+// deflate compresses data
+function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar;
+ recsize: Integer): Integer; external;
+function deflate(var strm: TZStreamRec; flush: Integer): Integer; external;
+function deflateEnd(var strm: TZStreamRec): Integer; external;
+
+// inflate decompresses data
+function inflateInit_(var strm: TZStreamRec; version: PChar; recsize: Integer): Integer; external;
+function inflate(var strm: TZStreamRec; flush: Integer): Integer; external;
+function inflateEnd(var strm: TZStreamRec): Integer; external;
+function inflateReset(var strm: TZStreamRec): Integer; external;
+
+
+function zcalloc(AppData: Pointer; Items, Size: Integer): Pointer;
+begin
+ GetMem(Result, Items*Size);
+end;
+
+procedure zcfree(AppData, Block: Pointer);
+begin
+ FreeMem(Block);
+end;
+
+end.
+
+
+
diff --git a/Game/Code/lib/SQLite/SQLite3.pas b/Game/Code/lib/SQLite/SQLite3.pas new file mode 100644 index 00000000..f1b03e08 --- /dev/null +++ b/Game/Code/lib/SQLite/SQLite3.pas @@ -0,0 +1,199 @@ +unit SQLite3; + +{ + Simplified interface for SQLite. + Updated for Sqlite 3 by Tim Anderson (tim@itwriting.com) + Note: NOT COMPLETE for version 3, just minimal functionality + Adapted from file created by Pablo Pissanetzky (pablo@myhtpc.net) + which was based on SQLite.pas by Ben Hochstrasser (bhoc@surfeu.ch) +} + +interface + +{$I switches.inc} + +const + +{$IFDEF MSWINDOWS} + SQLiteDLL = 'sqlite3.dll'; +{$ENDIF} +{$IFDEF LINUX} + SQLiteDLL = 'sqlite3.so'; +{$ENDIF} +{$IFDEF DARWIN} + SQLiteDLL = 'libsqlite3.dylib'; +{$ENDIF} + +// Return values for sqlite3_exec() and sqlite3_step() + + SQLITE_OK = 0; // Successful result + SQLITE_ERROR = 1; // SQL error or missing database + SQLITE_INTERNAL = 2; // An internal logic error in SQLite + SQLITE_PERM = 3; // Access permission denied + SQLITE_ABORT = 4; // Callback routine requested an abort + SQLITE_BUSY = 5; // The database file is locked + SQLITE_LOCKED = 6; // A table in the database is locked + SQLITE_NOMEM = 7; // A malloc() failed + SQLITE_READONLY = 8; // Attempt to write a readonly database + SQLITE_INTERRUPT = 9; // Operation terminated by sqlite3_interrupt() + SQLITE_IOERR = 10; // Some kind of disk I/O error occurred + SQLITE_CORRUPT = 11; // The database disk image is malformed + SQLITE_NOTFOUND = 12; // (Internal Only) Table or record not found + SQLITE_FULL = 13; // Insertion failed because database is full + SQLITE_CANTOPEN = 14; // Unable to open the database file + SQLITE_PROTOCOL = 15; // Database lock protocol error + SQLITE_EMPTY = 16; // Database is empty + SQLITE_SCHEMA = 17; // The database schema changed + SQLITE_TOOBIG = 18; // Too much data for one row of a table + SQLITE_CONSTRAINT = 19; // Abort due to contraint violation + SQLITE_MISMATCH = 20; // Data type mismatch + SQLITE_MISUSE = 21; // Library used incorrectly + SQLITE_NOLFS = 22; // Uses OS features not supported on host + SQLITE_AUTH = 23; // Authorization denied + SQLITE_FORMAT = 24; // Auxiliary database format error + SQLITE_RANGE = 25; // 2nd parameter to sqlite3_bind out of range + SQLITE_NOTADB = 26; // File opened that is not a database file + SQLITE_ROW = 100; // sqlite3_step() has another row ready + SQLITE_DONE = 101; // sqlite3_step() has finished executing + + SQLITE_INTEGER = 1; + SQLITE_FLOAT = 2; + SQLITE_TEXT = 3; + SQLITE_BLOB = 4; + SQLITE_NULL = 5; + +type + TSQLiteDB = Pointer; + TSQLiteResult = ^PChar; + TSQLiteStmt = Pointer; + +function SQLite3_Open(dbname: PChar; var db: TSqliteDB): integer; cdecl; external SQLiteDLL name 'sqlite3_open'; +function SQLite3_Close(db: TSQLiteDB): integer; cdecl; external SQLiteDLL name 'sqlite3_close'; +function SQLite3_Exec(db: TSQLiteDB; SQLStatement: PChar; CallbackPtr: Pointer; Sender: TObject; var ErrMsg: PChar): integer; cdecl; external SQLiteDLL name 'sqlite3_exec'; +function SQLite3_Version(): PChar; cdecl; external SQLiteDLL name 'sqlite3_libversion'; +function SQLite3_ErrMsg(db: TSQLiteDB): PChar; cdecl; external SQLiteDLL name 'sqlite3_errmsg'; +function SQLite3_ErrCode(db: TSQLiteDB): integer; cdecl; external SQLiteDLL name 'sqlite3_errcode'; +procedure SQlite3_Free(P: PChar); cdecl; external SQLiteDLL name 'sqlite3_free'; +function SQLite3_GetTable(db: TSQLiteDB; SQLStatement: PChar; var ResultPtr: TSQLiteResult; var RowCount: Cardinal; var ColCount: Cardinal; var ErrMsg: PChar): integer; cdecl; external SQLiteDLL name 'sqlite3_get_table'; +procedure SQLite3_FreeTable(Table: TSQLiteResult); cdecl; external SQLiteDLL name 'sqlite3_free_table'; +function SQLite3_Complete(P: PChar): boolean; cdecl; external SQLiteDLL name 'sqlite3_complete'; +function SQLite3_LastInsertRowID(db: TSQLiteDB): int64; cdecl; external SQLiteDLL name 'sqlite3_last_insert_rowid'; +procedure SQLite3_Interrupt(db: TSQLiteDB); cdecl; external SQLiteDLL name 'sqlite3_interrupt'; +procedure SQLite3_BusyHandler(db: TSQLiteDB; CallbackPtr: Pointer; Sender: TObject); cdecl; external SQLiteDLL name 'sqlite3_busy_handler'; +procedure SQLite3_BusyTimeout(db: TSQLiteDB; TimeOut: integer); cdecl; external SQLiteDLL name 'sqlite3_busy_timeout'; +function SQLite3_Changes(db: TSQLiteDB): integer; cdecl; external SQLiteDLL name 'sqlite3_changes'; +function SQLite3_TotalChanges(db: TSQLiteDB): integer; cdecl; external SQLiteDLL name 'sqlite3_total_changes'; +function SQLite3_Prepare(db: TSQLiteDB; SQLStatement: PChar; nBytes: integer; var hStmt: TSqliteStmt; var pzTail: PChar): integer; cdecl; external SQLiteDLL name 'sqlite3_prepare'; +function SQLite3_ColumnCount(hStmt: TSqliteStmt): integer; cdecl; external SQLiteDLL name 'sqlite3_column_count'; +function Sqlite3_ColumnName(hStmt: TSqliteStmt; ColNum: integer): pchar; cdecl; external SQLiteDLL name 'sqlite3_column_name'; +function Sqlite3_ColumnDeclType(hStmt: TSqliteStmt; ColNum: integer): pchar; cdecl; external SQLiteDLL name 'sqlite3_column_decltype'; +function Sqlite3_Step(hStmt: TSqliteStmt): integer; cdecl; external SQLiteDLL name 'sqlite3_step'; +function SQLite3_DataCount(hStmt: TSqliteStmt): integer; cdecl; external SQLiteDLL name 'sqlite3_data_count'; + +function Sqlite3_ColumnBlob(hStmt: TSqliteStmt; ColNum: integer): pointer; cdecl; external SQLiteDLL name 'sqlite3_column_blob'; +function Sqlite3_ColumnBytes(hStmt: TSqliteStmt; ColNum: integer): integer; cdecl; external SQLiteDLL name 'sqlite3_column_bytes'; +function Sqlite3_ColumnDouble(hStmt: TSqliteStmt; ColNum: integer): double; cdecl; external SQLiteDLL name 'sqlite3_column_double'; +function Sqlite3_ColumnInt(hStmt: TSqliteStmt; ColNum: integer): integer; cdecl; external SQLiteDLL name 'sqlite3_column_int'; +function Sqlite3_ColumnText(hStmt: TSqliteStmt; ColNum: integer): pchar; cdecl; external SQLiteDLL name 'sqlite3_column_text'; +function Sqlite3_ColumnType(hStmt: TSqliteStmt; ColNum: integer): integer; cdecl; external SQLiteDLL name 'sqlite3_column_type'; +function Sqlite3_ColumnInt64(hStmt: TSqliteStmt; ColNum: integer): Int64; cdecl; external SQLiteDLL name 'sqlite3_column_int64'; +function SQLite3_Finalize(hStmt: TSqliteStmt): integer; cdecl; external SQLiteDLL name 'sqlite3_finalize'; +function SQLite3_Reset(hStmt: TSqliteStmt): integer; cdecl; external SQLiteDLL name 'sqlite3_reset'; + +// +// In the SQL strings input to sqlite3_prepare() and sqlite3_prepare16(), +// one or more literals can be replace by a wildcard "?" or ":N:" where +// N is an integer. These value of these wildcard literals can be set +// using the routines listed below. +// +// In every case, the first parameter is a pointer to the sqlite3_stmt +// structure returned from sqlite3_prepare(). The second parameter is the +// index of the wildcard. The first "?" has an index of 1. ":N:" wildcards +// use the index N. +// + // The fifth parameter to sqlite3_bind_blob(), sqlite3_bind_text(), and + //sqlite3_bind_text16() is a destructor used to dispose of the BLOB or +//text after SQLite has finished with it. If the fifth argument is the +// special value SQLITE_STATIC, then the library assumes that the information +// is in static, unmanaged space and does not need to be freed. If the +// fifth argument has the value SQLITE_TRANSIENT, then SQLite makes its +// own private copy of the data. +// +// The sqlite3_bind_* routine must be called before sqlite3_step() after +// an sqlite3_prepare() or sqlite3_reset(). Unbound wildcards are interpreted +// as NULL. +// + +function SQLite3_BindBlob(hStmt: TSqliteStmt; ParamNum: integer; + ptrData: pointer; numBytes: integer; ptrDestructor: pointer): integer; +cdecl; external SQLiteDLL name 'sqlite3_bind_blob'; + +function SQLiteFieldType(SQLiteFieldTypeCode: Integer): AnsiString; +function SQLiteErrorStr(SQLiteErrorCode: Integer): AnsiString; + +implementation + +uses + SysUtils; + +function SQLiteFieldType(SQLiteFieldTypeCode: Integer): AnsiString; +begin + case SQLiteFieldTypeCode of + SQLITE_INTEGER: Result := 'Integer'; + SQLITE_FLOAT: Result := 'Float'; + SQLITE_TEXT: Result := 'Text'; + SQLITE_BLOB: Result := 'Blob'; + SQLITE_NULL: Result := 'Null'; + else + Result := 'Unknown SQLite Field Type Code "' + IntToStr(SQLiteFieldTypeCode) + '"'; + end; +end; + +function SQLiteErrorStr(SQLiteErrorCode: Integer): AnsiString; +begin + case SQLiteErrorCode of + SQLITE_OK: Result := 'Successful result'; + SQLITE_ERROR: Result := 'SQL error or missing database'; + SQLITE_INTERNAL: Result := 'An internal logic error in SQLite'; + SQLITE_PERM: Result := 'Access permission denied'; + SQLITE_ABORT: Result := 'Callback routine requested an abort'; + SQLITE_BUSY: Result := 'The database file is locked'; + SQLITE_LOCKED: Result := 'A table in the database is locked'; + SQLITE_NOMEM: Result := 'A malloc() failed'; + SQLITE_READONLY: Result := 'Attempt to write a readonly database'; + SQLITE_INTERRUPT: Result := 'Operation terminated by sqlite3_interrupt()'; + SQLITE_IOERR: Result := 'Some kind of disk I/O error occurred'; + SQLITE_CORRUPT: Result := 'The database disk image is malformed'; + SQLITE_NOTFOUND: Result := '(Internal Only) Table or record not found'; + SQLITE_FULL: Result := 'Insertion failed because database is full'; + SQLITE_CANTOPEN: Result := 'Unable to open the database file'; + SQLITE_PROTOCOL: Result := 'Database lock protocol error'; + SQLITE_EMPTY: Result := 'Database is empty'; + SQLITE_SCHEMA: Result := 'The database schema changed'; + SQLITE_TOOBIG: Result := 'Too much data for one row of a table'; + SQLITE_CONSTRAINT: Result := 'Abort due to contraint violation'; + SQLITE_MISMATCH: Result := 'Data type mismatch'; + SQLITE_MISUSE: Result := 'Library used incorrectly'; + SQLITE_NOLFS: Result := 'Uses OS features not supported on host'; + SQLITE_AUTH: Result := 'Authorization denied'; + SQLITE_FORMAT: Result := 'Auxiliary database format error'; + SQLITE_RANGE: Result := '2nd parameter to sqlite3_bind out of range'; + SQLITE_NOTADB: Result := 'File opened that is not a database file'; + SQLITE_ROW: Result := 'sqlite3_step() has another row ready'; + SQLITE_DONE: Result := 'sqlite3_step() has finished executing'; + else + Result := 'Unknown SQLite Error Code "' + IntToStr(SQLiteErrorCode) + '"'; + end; +end; + +function ColValueToStr(Value: PChar): AnsiString; +begin + if (Value = nil) then + Result := 'NULL' + else + Result := Value; +end; + + +end. + diff --git a/Game/Code/lib/SQLite/SQLiteTable3.pas b/Game/Code/lib/SQLite/SQLiteTable3.pas new file mode 100644 index 00000000..fc958d23 --- /dev/null +++ b/Game/Code/lib/SQLite/SQLiteTable3.pas @@ -0,0 +1,772 @@ +unit SQLiteTable3; + +{ + Simple classes for using SQLite's exec and get_table. + + TSQLiteDatabase wraps the calls to open and close an SQLite database. + It also wraps SQLite_exec for queries that do not return a result set + + TSQLiteTable wraps sqlite_get_table. + It allows accessing fields by name as well as index and can step through a + result set with the Next procedure. + + Adapted by Tim Anderson (tim@itwriting.com) + Originally created by Pablo Pissanetzky (pablo@myhtpc.net) + Modified and enhanced by Lukas Gebauer +} + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + +uses + {$ifdef win32} + Windows, + {$endif} + SQLite3, + Classes, + SysUtils; + +const + + dtInt = 1; + dtNumeric = 2; + dtStr = 3; + dtBlob = 4; + dtNull = 5; + +type + + ESQLiteException = class(Exception) + end; + + TSQLiteTable = class; + + TSQLiteDatabase = class + private + fDB: TSQLiteDB; + fInTrans: boolean; + procedure RaiseError(s: string; SQL: string); + public + constructor Create(const FileName: string); + destructor Destroy; override; + function GetTable(const SQL: string): TSQLiteTable; + procedure ExecSQL(const SQL: string); + function GetTableValue(const SQL: string): int64; + function GetTableString(const SQL: string): string; + procedure UpdateBlob(const SQL: string; BlobData: TStream); + procedure BeginTransaction; + procedure Commit; + procedure Rollback; + function TableExists(TableName: string): boolean; + function GetLastInsertRowID: int64; + procedure SetTimeout(Value: integer); + function version: string; + published + property isTransactionOpen: boolean read fInTrans; + end; + + TSQLiteTable = class + private + fResults: TList; + fRowCount: cardinal; + fColCount: cardinal; + fCols: TStringList; + fColTypes: TList; + fRow: cardinal; + function GetFields(I: cardinal): string; + function GetEOF: boolean; + function GetBOF: boolean; + function GetColumns(I: integer): string; + function GetFieldByName(FieldName: string): string; + function GetFieldIndex(FieldName: string): integer; + function GetCount: integer; + function GetCountResult: integer; + public + constructor Create(DB: TSQLiteDatabase; const SQL: string); + destructor Destroy; override; + function FieldAsInteger(I: cardinal): int64; + function FieldAsBlob(I: cardinal): TMemoryStream; + function FieldAsBlobText(I: cardinal): string; + function FieldIsNull(I: cardinal): boolean; + function FieldAsString(I: cardinal): string; + function FieldAsDouble(I: cardinal): double; + function Next: boolean; + function Previous: boolean; + property EOF: boolean read GetEOF; + property BOF: boolean read GetBOF; + property Fields[I: cardinal]: string read GetFields; + property FieldByName[FieldName: string]: string read GetFieldByName; + property FieldIndex[FieldName: string]: integer read GetFieldIndex; + property Columns[I: integer]: string read GetColumns; + property ColCount: cardinal read fColCount; + property RowCount: cardinal read fRowCount; + property Row: cardinal read fRow; + function MoveFirst: boolean; + function MoveLast: boolean; + property Count: integer read GetCount; + // The property CountResult is used when you execute count(*) queries. + // It returns 0 if the result set is empty or the value of the + // first field as an integer. + property CountResult: integer read GetCountResult; + end; + +procedure DisposePointer(ptr: pointer); cdecl; + + +implementation + +procedure DisposePointer(ptr: pointer); cdecl; +begin + if assigned(ptr) then + freemem(ptr); +end; + +//------------------------------------------------------------------------------ +// TSQLiteDatabase +//------------------------------------------------------------------------------ + +constructor TSQLiteDatabase.Create(const FileName: string); +var + Msg: pchar; + iResult: integer; +begin + inherited Create; + + self.fInTrans := False; + + Msg := nil; + try + iResult := SQLite3_Open(PChar(FileName), Fdb); + + if iResult <> SQLITE_OK then + if Assigned(Fdb) then + begin + Msg := Sqlite3_ErrMsg(Fdb); + raise ESqliteException.CreateFmt('Failed to open database "%s" : %s', + [FileName, Msg]); + end + else + raise ESqliteException.CreateFmt('Failed to open database "%s" : unknown error', + [FileName]); + + //set a few configs + self.ExecSQL('PRAGMA SYNCHRONOUS=NORMAL;'); +// self.ExecSQL('PRAGMA full_column_names = 1;'); + self.ExecSQL('PRAGMA temp_store = MEMORY;'); + + finally + if Assigned(Msg) then + SQLite3_Free(Msg); + end; + +end; + + +//.............................................................................. + +destructor TSQLiteDatabase.Destroy; +begin + + if self.fInTrans then + self.ExecSQL('ROLLBACK;'); //assume rollback + + if Assigned(fDB) then + SQLite3_Close(fDB); + + inherited; +end; + +function TSQLiteDatabase.GetLastInsertRowID: int64; +begin + Result := Sqlite3_LastInsertRowID(self.fDB); +end; + +//.............................................................................. + +procedure TSQLiteDatabase.RaiseError(s: string; SQL: string); +//look up last error and raise an exception with an appropriate message +var + Msg: PChar; +begin + + Msg := nil; + + if sqlite3_errcode(self.fDB) <> SQLITE_OK then + Msg := sqlite3_errmsg(self.fDB); + + if Msg <> nil then + raise ESqliteException.CreateFmt(s + ' "%s" : %s', [SQL, Msg]) + else + raise ESqliteException.CreateFmt(s, [SQL, 'No message']); + +end; + +procedure TSQLiteDatabase.ExecSQL(const SQL: string); +var + Stmt: TSQLiteStmt; + NextSQLStatement: Pchar; + iStepResult: integer; +begin + try + + if Sqlite3_Prepare(self.fDB, PChar(SQL), -1, Stmt, NextSQLStatement) <> + SQLITE_OK then + RaiseError('Error executing SQL', SQL); + + if (Stmt = nil) then + RaiseError('Could not prepare SQL statement', SQL); + + iStepResult := Sqlite3_step(Stmt); + + if (iStepResult <> SQLITE_DONE) then + RaiseError('Error executing SQL statement', SQL); + + finally + + if Assigned(Stmt) then + Sqlite3_Finalize(stmt); + + end; +end; + +procedure TSQLiteDatabase.UpdateBlob(const SQL: string; BlobData: TStream); +var + iSize: integer; + ptr: pointer; + Stmt: TSQLiteStmt; + Msg: Pchar; + NextSQLStatement: Pchar; + iStepResult: integer; + iBindResult: integer; +begin + //expects SQL of the form 'UPDATE MYTABLE SET MYFIELD = ? WHERE MYKEY = 1' + + if pos('?', SQL) = 0 then + RaiseError('SQL must include a ? parameter', SQL); + + Msg := nil; + try + + if Sqlite3_Prepare(self.fDB, PChar(SQL), -1, Stmt, NextSQLStatement) <> + SQLITE_OK then + RaiseError('Could not prepare SQL statement', SQL); + + if (Stmt = nil) then + RaiseError('Could not prepare SQL statement', SQL); + + //now bind the blob data + iSize := BlobData.size; + + GetMem(ptr, iSize); + + if (ptr = nil) then + raise ESqliteException.CreateFmt('Error getting memory to save blob', + [SQL, 'Error']); + + BlobData.position := 0; + BlobData.Read(ptr^, iSize); + + iBindResult := SQLite3_BindBlob(stmt, 1, ptr, iSize, @DisposePointer); + + if iBindResult <> SQLITE_OK then + RaiseError('Error binding blob to database', SQL); + + iStepResult := Sqlite3_step(Stmt); + + if (iStepResult <> SQLITE_DONE) then + RaiseError('Error executing SQL statement', SQL); + + finally + + if Assigned(Stmt) then + Sqlite3_Finalize(stmt); + + if Assigned(Msg) then + SQLite3_Free(Msg); + end; + +end; + +//.............................................................................. + +function TSQLiteDatabase.GetTable(const SQL: string): TSQLiteTable; +begin + Result := TSQLiteTable.Create(Self, SQL); +end; + +function TSQLiteDatabase.GetTableValue(const SQL: string): int64; +var + Table: TSQLiteTable; +begin + Table := self.GetTable(SQL); + try + Result := Table.FieldAsInteger(0); + finally + Table.Free; + end; +end; + +function TSQLiteDatabase.GetTableString(const SQL: string): string; +var + Table: TSQLiteTable; +begin + Table := self.GetTable(SQL); + try + Result := Table.FieldAsString(0); + finally + Table.Free; + end; +end; + + +procedure TSQLiteDatabase.BeginTransaction; +begin + if not self.fInTrans then + begin + self.ExecSQL('BEGIN TRANSACTION;'); + self.fInTrans := True; + end + else + raise ESqliteException.Create('Transaction already open'); +end; + +procedure TSQLiteDatabase.Commit; +begin + self.ExecSQL('COMMIT;'); + self.fInTrans := False; +end; + +procedure TSQLiteDatabase.Rollback; +begin + self.ExecSQL('ROLLBACK;'); + self.fInTrans := False; +end; + +function TSQLiteDatabase.TableExists(TableName: string): boolean; +var + sql: string; + ds: TSqliteTable; +begin + //returns true if table exists in the database + sql := 'select [sql] from sqlite_master where [type] = ''table'' and lower(name) = ''' + + lowercase(TableName) + ''' '; + ds := self.GetTable(sql); + try + Result := (ds.Count > 0); + finally + ds.Free; + end; +end; + +procedure TSQLiteDatabase.SetTimeout(Value: integer); +begin + SQLite3_BusyTimeout(self.fDB, Value); +end; + +function TSQLiteDatabase.version: string; +begin + Result := SQLite3_Version; +end; + + +//------------------------------------------------------------------------------ +// TSQLiteTable +//------------------------------------------------------------------------------ + +constructor TSQLiteTable.Create(DB: TSQLiteDatabase; const SQL: string); +var + Stmt: TSQLiteStmt; + NextSQLStatement: Pchar; + iStepResult: integer; + ptr: pointer; + iNumBytes: integer; + thisBlobValue: TMemoryStream; + thisStringValue: pstring; + thisDoubleValue: pDouble; + thisIntValue: pInt64; + thisColType: pInteger; + i: integer; + DeclaredColType: Pchar; + ActualColType: integer; + ptrValue: Pchar; +begin + try + self.fRowCount := 0; + self.fColCount := 0; + //if there are several SQL statements in SQL, NextSQLStatment points to the + //beginning of the next one. Prepare only prepares the first SQL statement. + if Sqlite3_Prepare(DB.fDB, PChar(SQL), -1, Stmt, NextSQLStatement) <> SQLITE_OK then + DB.RaiseError('Error executing SQL', SQL); + if (Stmt = nil) then + DB.RaiseError('Could not prepare SQL statement', SQL); + iStepResult := Sqlite3_step(Stmt); + while (iStepResult <> SQLITE_DONE) do + begin + case iStepResult of + SQLITE_ROW: + begin + Inc(fRowCount); + if (fRowCount = 1) then + begin + //get data types + fCols := TStringList.Create; + fColTypes := TList.Create; + fColCount := SQLite3_ColumnCount(stmt); + for i := 0 to Pred(fColCount) do + fCols.Add(AnsiUpperCase(Sqlite3_ColumnName(stmt, i))); + for i := 0 to Pred(fColCount) do + begin + new(thisColType); + DeclaredColType := Sqlite3_ColumnDeclType(stmt, i); + if DeclaredColType = nil then + thisColType^ := Sqlite3_ColumnType(stmt, i) //use the actual column type instead + //seems to be needed for last_insert_rowid + else + if (DeclaredColType = 'INTEGER') or (DeclaredColType = 'BOOLEAN') then + thisColType^ := dtInt + else + if (DeclaredColType = 'NUMERIC') or + (DeclaredColType = 'FLOAT') or + (DeclaredColType = 'DOUBLE') or + (DeclaredColType = 'REAL') then + thisColType^ := dtNumeric + else + if DeclaredColType = 'BLOB' then + thisColType^ := dtBlob + else + thisColType^ := dtStr; + fColTypes.Add(thiscoltype); + end; + fResults := TList.Create; + end; + + //get column values + for i := 0 to Pred(ColCount) do + begin + ActualColType := Sqlite3_ColumnType(stmt, i); + if (ActualColType = SQLITE_NULL) then + fResults.Add(nil) + else + if pInteger(fColTypes[i])^ = dtInt then + begin + new(thisintvalue); + thisintvalue^ := Sqlite3_ColumnInt64(stmt, i); + fResults.Add(thisintvalue); + end + else + if pInteger(fColTypes[i])^ = dtNumeric then + begin + new(thisdoublevalue); + thisdoublevalue^ := Sqlite3_ColumnDouble(stmt, i); + fResults.Add(thisdoublevalue); + end + else + if pInteger(fColTypes[i])^ = dtBlob then + begin + iNumBytes := Sqlite3_ColumnBytes(stmt, i); + if iNumBytes = 0 then + thisblobvalue := nil + else + begin + thisblobvalue := TMemoryStream.Create; + thisblobvalue.position := 0; + ptr := Sqlite3_ColumnBlob(stmt, i); + thisblobvalue.writebuffer(ptr^, iNumBytes); + end; + fResults.Add(thisblobvalue); + end + else + begin + new(thisstringvalue); + ptrValue := Sqlite3_ColumnText(stmt, i); + setstring(thisstringvalue^, ptrvalue, strlen(ptrvalue)); + fResults.Add(thisstringvalue); + end; + end; + end; + SQLITE_BUSY: + raise ESqliteException.CreateFmt('Could not prepare SQL statement', + [SQL, 'SQLite is Busy']); + else + DB.RaiseError('Could not retrieve data', SQL); + end; + iStepResult := Sqlite3_step(Stmt); + end; + fRow := 0; + finally + if Assigned(Stmt) then + Sqlite3_Finalize(stmt); + end; +end; + +//.............................................................................. + +destructor TSQLiteTable.Destroy; +var + i: cardinal; + iColNo: integer; +begin + if Assigned(fResults) then + begin + for i := 0 to fResults.Count - 1 do + begin + //check for blob type + iColNo := (i mod fColCount); + case pInteger(self.fColTypes[iColNo])^ of + dtBlob: + TMemoryStream(fResults[i]).Free; + dtStr: + if fResults[i] <> nil then + begin + setstring(string(fResults[i]^), nil, 0); + dispose(fResults[i]); + end; + else + dispose(fResults[i]); + end; + end; + fResults.Free; + end; + if Assigned(fCols) then + fCols.Free; + if Assigned(fColTypes) then + for i := 0 to fColTypes.Count - 1 do + dispose(fColTypes[i]); + fColTypes.Free; + inherited; +end; + +//.............................................................................. + +function TSQLiteTable.GetColumns(I: integer): string; +begin + Result := fCols[I]; +end; + +//.............................................................................. + +function TSQLiteTable.GetCountResult: integer; +begin + if not EOF then + Result := StrToInt(Fields[0]) + else + Result := 0; +end; + +function TSQLiteTable.GetCount: integer; +begin + Result := FRowCount; +end; + +//.............................................................................. + +function TSQLiteTable.GetEOF: boolean; +begin + Result := fRow >= fRowCount; +end; + +function TSQLiteTable.GetBOF: boolean; +begin + Result := fRow <= 0; +end; + +//.............................................................................. + +function TSQLiteTable.GetFieldByName(FieldName: string): string; +begin + Result := GetFields(self.GetFieldIndex(FieldName)); +end; + +function TSQLiteTable.GetFieldIndex(FieldName: string): integer; +begin + + if (fCols = nil) then + begin + raise ESqliteException.Create('Field ' + fieldname + ' Not found. Empty dataset'); + exit; + end; + + if (fCols.count = 0) then + begin + raise ESqliteException.Create('Field ' + fieldname + ' Not found. Empty dataset'); + exit; + end; + + Result := fCols.IndexOf(AnsiUpperCase(FieldName)); + + if (result < 0) then + begin raise ESqliteException.Create('Field not found in dataset: ' + fieldname) end; + +end; + +//.............................................................................. + +function TSQLiteTable.GetFields(I: cardinal): string; +var + thisvalue: pstring; + thistype: integer; +begin + Result := ''; + if EOF then + raise ESqliteException.Create('Table is at End of File'); + //integer types are not stored in the resultset + //as strings, so they should be retrieved using the type-specific + //methods + thistype := pInteger(self.fColTypes[I])^; + + case thistype of + dtStr: + begin + thisvalue := self.fResults[(self.frow * self.fColCount) + I]; + if (thisvalue <> nil) then + Result := thisvalue^ + else + Result := ''; + end; + dtInt: + Result := IntToStr(self.FieldAsInteger(I)); + dtNumeric: + Result := FloatToStr(self.FieldAsDouble(I)); + dtBlob: + Result := self.FieldAsBlobText(I); + else + Result := ''; + end; +end; + +function TSqliteTable.FieldAsBlob(I: cardinal): TMemoryStream; +begin + if EOF then + raise ESqliteException.Create('Table is at End of File'); + if (self.fResults[(self.frow * self.fColCount) + I] = nil) then + Result := nil + else + if pInteger(self.fColTypes[I])^ = dtBlob then + Result := TMemoryStream(self.fResults[(self.frow * self.fColCount) + I]) + else + raise ESqliteException.Create('Not a Blob field'); +end; + +function TSqliteTable.FieldAsBlobText(I: cardinal): string; +var + MemStream: TMemoryStream; + Buffer: PChar; +begin + Result := ''; + MemStream := self.FieldAsBlob(I); + if MemStream <> nil then + if MemStream.Size > 0 then + begin + MemStream.position := 0; + Buffer := stralloc(MemStream.Size + 1); + MemStream.readbuffer(Buffer[0], MemStream.Size); + (Buffer + MemStream.Size)^ := chr(0); + SetString(Result, Buffer, MemStream.size); + strdispose(Buffer); + end; +end; + + +function TSqliteTable.FieldAsInteger(I: cardinal): int64; +begin + if EOF then + //raise ESqliteException.Create('Table is at End of File'); + Result := 0 + else if (self.fResults[(self.frow * self.fColCount) + I] = nil) then + Result := 0 + else + if pInteger(self.fColTypes[I])^ = dtInt then + Result := pInt64(self.fResults[(self.frow * self.fColCount) + I])^ + else + if pInteger(self.fColTypes[I])^ = dtNumeric then + Result := trunc(strtofloat(pString(self.fResults[(self.frow * self.fColCount) + I])^)) + else + raise ESqliteException.Create('Not an integer or numeric field'); +end; + +function TSqliteTable.FieldAsDouble(I: cardinal): double; +begin + if EOF then + raise ESqliteException.Create('Table is at End of File'); + if (self.fResults[(self.frow * self.fColCount) + I] = nil) then + Result := 0 + else + if pInteger(self.fColTypes[I])^ = dtInt then + Result := pInt64(self.fResults[(self.frow * self.fColCount) + I])^ + else + if pInteger(self.fColTypes[I])^ = dtNumeric then + Result := pDouble(self.fResults[(self.frow * self.fColCount) + I])^ + else + raise ESqliteException.Create('Not an integer or numeric field'); +end; + +function TSqliteTable.FieldAsString(I: cardinal): string; +begin + if EOF then + raise ESqliteException.Create('Table is at End of File'); + if (self.fResults[(self.frow * self.fColCount) + I] = nil) then + Result := '' + else + Result := self.GetFields(I); +end; + +function TSqliteTable.FieldIsNull(I: cardinal): boolean; +var + thisvalue: pointer; +begin + if EOF then + raise ESqliteException.Create('Table is at End of File'); + thisvalue := self.fResults[(self.frow * self.fColCount) + I]; + Result := (thisvalue = nil); +end; + +//.............................................................................. + +function TSQLiteTable.Next: boolean; +begin + Result := False; + if not EOF then + begin + Inc(fRow); + Result := True; + end; +end; + +function TSQLiteTable.Previous: boolean; +begin + Result := False; + if not BOF then + begin + Dec(fRow); + Result := True; + end; +end; + +function TSQLiteTable.MoveFirst: boolean; +begin + Result := False; + if self.fRowCount > 0 then + begin + fRow := 0; + Result := True; + end; +end; + +function TSQLiteTable.MoveLast: boolean; +begin + Result := False; + if self.fRowCount > 0 then + begin + fRow := fRowCount - 1; + Result := True; + end; +end; + + +end. + diff --git a/Game/Code/lib/SQLite/example/Sunset.jpg b/Game/Code/lib/SQLite/example/Sunset.jpg Binary files differnew file mode 100644 index 00000000..860f6eec --- /dev/null +++ b/Game/Code/lib/SQLite/example/Sunset.jpg diff --git a/Game/Code/lib/SQLite/example/TestSqlite.dpr b/Game/Code/lib/SQLite/example/TestSqlite.dpr new file mode 100644 index 00000000..82f2a468 --- /dev/null +++ b/Game/Code/lib/SQLite/example/TestSqlite.dpr @@ -0,0 +1,15 @@ +program TestSqlite;
+
+uses
+ Forms,
+ uTestSqlite in 'uTestSqlite.pas' {Form1},
+ SQLiteTable3 in 'SQLiteTable3.pas',
+ SQLite3 in 'SQLite3.pas';
+
+{$R *.res}
+
+begin
+ Application.Initialize;
+ Application.CreateForm(TForm1, Form1);
+ Application.Run;
+end.
diff --git a/Game/Code/lib/SQLite/example/TestSqlite.exe b/Game/Code/lib/SQLite/example/TestSqlite.exe Binary files differnew file mode 100644 index 00000000..12f77a3d --- /dev/null +++ b/Game/Code/lib/SQLite/example/TestSqlite.exe diff --git a/Game/Code/lib/SQLite/example/TestSqlite.res b/Game/Code/lib/SQLite/example/TestSqlite.res Binary files differnew file mode 100644 index 00000000..4bdd5e2e --- /dev/null +++ b/Game/Code/lib/SQLite/example/TestSqlite.res diff --git a/Game/Code/lib/SQLite/example/uTestSqlite.dfm b/Game/Code/lib/SQLite/example/uTestSqlite.dfm new file mode 100644 index 00000000..b77ec2c7 --- /dev/null +++ b/Game/Code/lib/SQLite/example/uTestSqlite.dfm @@ -0,0 +1,110 @@ +object Form1: TForm1
+ Left = 242
+ Top = 242
+ Width = 541
+ Height = 308
+ Caption = 'Test SQLite 3'
+ Color = clBtnFace
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -11
+ Font.Name = 'MS Sans Serif'
+ Font.Style = []
+ OldCreateOrder = False
+ PixelsPerInch = 96
+ TextHeight = 13
+ object Label1: TLabel
+ Left = 24
+ Top = 104
+ Width = 28
+ Height = 13
+ Caption = 'Notes'
+ end
+ object Label2: TLabel
+ Left = 24
+ Top = 44
+ Width = 28
+ Height = 13
+ Caption = 'Name'
+ end
+ object Label3: TLabel
+ Left = 24
+ Top = 72
+ Width = 40
+ Height = 13
+ Caption = 'Number:'
+ end
+ object Label4: TLabel
+ Left = 24
+ Top = 12
+ Width = 11
+ Height = 13
+ Caption = 'ID'
+ end
+ object Image1: TImage
+ Left = 272
+ Top = 12
+ Width = 241
+ Height = 165
+ Proportional = True
+ Stretch = True
+ end
+ object btnTest: TButton
+ Left = 24
+ Top = 224
+ Width = 161
+ Height = 37
+ Caption = 'Test SQLite 3'
+ TabOrder = 0
+ OnClick = btnTestClick
+ end
+ object memNotes: TMemo
+ Left = 24
+ Top = 124
+ Width = 185
+ Height = 89
+ Lines.Strings = (
+ '')
+ ScrollBars = ssVertical
+ TabOrder = 1
+ end
+ object ebName: TEdit
+ Left = 72
+ Top = 40
+ Width = 173
+ Height = 21
+ TabOrder = 2
+ end
+ object ebNumber: TEdit
+ Left = 72
+ Top = 68
+ Width = 173
+ Height = 21
+ TabOrder = 3
+ end
+ object ebID: TEdit
+ Left = 72
+ Top = 12
+ Width = 173
+ Height = 21
+ TabOrder = 4
+ end
+ object btnLoadImage: TButton
+ Left = 192
+ Top = 224
+ Width = 157
+ Height = 37
+ Caption = 'Load image'
+ TabOrder = 5
+ OnClick = btnLoadImageClick
+ end
+ object btnDisplayImage: TButton
+ Left = 360
+ Top = 224
+ Width = 157
+ Height = 37
+ Caption = 'Display image'
+ TabOrder = 6
+ OnClick = btnDisplayImageClick
+ end
+end
diff --git a/Game/Code/lib/SQLite/example/uTestSqlite.pas b/Game/Code/lib/SQLite/example/uTestSqlite.pas new file mode 100644 index 00000000..6691fece --- /dev/null +++ b/Game/Code/lib/SQLite/example/uTestSqlite.pas @@ -0,0 +1,233 @@ +unit uTestSqlite;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+ Dialogs, StdCtrls,SQLiteTable3, ExtCtrls, jpeg;
+
+type
+ TForm1 = class(TForm)
+ btnTest: TButton;
+ memNotes: TMemo;
+ Label1: TLabel;
+ Label2: TLabel;
+ ebName: TEdit;
+ Label3: TLabel;
+ ebNumber: TEdit;
+ Label4: TLabel;
+ ebID: TEdit;
+ Image1: TImage;
+ btnLoadImage: TButton;
+ btnDisplayImage: TButton;
+ procedure btnTestClick(Sender: TObject);
+ procedure btnLoadImageClick(Sender: TObject);
+ procedure btnDisplayImageClick(Sender: TObject);
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+var
+ Form1: TForm1;
+
+implementation
+
+{$R *.dfm}
+
+procedure TForm1.btnTestClick(Sender: TObject);
+var
+slDBpath: string;
+sldb: TSQLiteDatabase;
+sltb: TSQLIteTable;
+sSQL: String;
+Notes: String;
+
+begin
+
+slDBPath := ExtractFilepath(application.exename)
++ 'test.db';
+
+sldb := TSQLiteDatabase.Create(slDBPath);
+try
+
+if sldb.TableExists('testTable') then begin
+sSQL := 'DROP TABLE testtable';
+sldb.execsql(sSQL);
+end;
+
+sSQL := 'CREATE TABLE testtable ([ID] INTEGER PRIMARY KEY,[OtherID] INTEGER NULL,';
+sSQL := sSQL + '[Name] VARCHAR (255),[Number] FLOAT, [notes] BLOB, [picture] BLOB COLLATE NOCASE);';
+
+sldb.execsql(sSQL);
+
+sldb.execsql('CREATE INDEX TestTableName ON [testtable]([Name]);');
+
+//begin a transaction
+sldb.BeginTransaction;
+
+sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("Some Name",4,587.6594,"Here are some notes");';
+//do the insert
+sldb.ExecSQL(sSQL);
+
+sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("Another Name",12,4758.3265,"More notes");';
+//do the insert
+sldb.ExecSQL(sSQL);
+
+//end the transaction
+sldb.Commit;
+
+//query the data
+sltb := slDb.GetTable('SELECT * FROM testtable');
+try
+
+if sltb.Count > 0 then
+begin
+//display first row
+
+ebName.Text := sltb.FieldAsString(sltb.FieldIndex['Name']);
+ebID.Text := inttostr(sltb.FieldAsInteger(sltb.FieldIndex['ID']));
+ebNumber.Text := floattostr( sltb.FieldAsDouble(sltb.FieldIndex['Number']));
+Notes := sltb.FieldAsBlobText(sltb.FieldIndex['Notes']);
+memNotes.Text := notes;
+
+end;
+
+finally
+sltb.Free;
+end;
+
+finally
+sldb.Free;
+
+end;
+
+end;
+
+procedure TForm1.btnLoadImageClick(Sender: TObject);
+var
+slDBpath: string;
+sldb: TSQLiteDatabase;
+sltb: TSQLIteTable;
+iID: integer;
+fs: TFileStream;
+
+begin
+
+slDBPath := ExtractFilepath(application.exename)
++ 'test.db';
+
+if not FileExists(slDBPath) then begin
+MessageDLg('Test.db does not exist. Click Test Sqlite 3 to create it.',mtInformation,[mbOK],0);
+exit;
+end;
+
+sldb := TSQLiteDatabase.Create(slDBPath);
+try
+
+//get an ID
+//query the data
+sltb := slDb.GetTable('SELECT ID FROM testtable');
+try
+
+if sltb.Count = 0 then begin
+MessageDLg('There are no rows in the database. Click Test Sqlite 3 to insert a row.',mtInformation,[mbOK],0);
+exit;
+end;
+
+iID := sltb.FieldAsInteger(sltb.FieldIndex['ID']);
+
+finally
+sltb.Free;
+end;
+
+//load an image
+fs := TFileStream.Create(ExtractFileDir(application.ExeName) + '\sunset.jpg',fmOpenRead);
+try
+
+//insert the image into the db
+sldb.UpdateBlob('UPDATE testtable set picture = ? WHERE ID = ' + inttostr(iID),fs);
+
+finally
+fs.Free;
+end;
+
+finally
+sldb.Free;
+
+end;
+
+end;
+
+procedure TForm1.btnDisplayImageClick(Sender: TObject);
+var
+slDBpath: string;
+sldb: TSQLiteDatabase;
+sltb: TSQLIteTable;
+iID: integer;
+ms: TMemoryStream;
+pic: TJPegImage;
+
+begin
+
+slDBPath := ExtractFilepath(application.exename)
++ 'test.db';
+
+if not FileExists(slDBPath) then begin
+MessageDLg('Test.db does not exist. Click Test Sqlite 3 to create it, then Load image to load an image.',mtInformation,[mbOK],0);
+exit;
+end;
+
+sldb := TSQLiteDatabase.Create(slDBPath);
+try
+
+//get an ID
+//query the data
+sltb := slDb.GetTable('SELECT ID FROM testtable');
+try
+
+if not sltb.Count = 0 then begin
+MessageDLg('No rows in the test database. Click Test Sqlite 3 to insert a row, then Load image to load an image.',mtInformation,[mbOK],0);
+exit;
+end;
+
+iID := sltb.FieldAsInteger(sltb.FieldIndex['ID']);
+
+finally
+sltb.Free;
+end;
+
+sltb := sldb.GetTable('SELECT picture FROM testtable where ID = ' + inttostr(iID));
+try
+
+ms := sltb.FieldAsBlob(sltb.FieldIndex['picture']);
+//note that the memory stream is freed when the TSqliteTable is destroyed.
+
+if (ms = nil) then begin
+MessageDLg('No image in the test database. Click Load image to load an image.',mtInformation,[mbOK],0);
+exit;
+end;
+
+ms.Position := 0;
+
+pic := TJPEGImage.Create;
+pic.LoadFromStream(ms);
+
+self.Image1.Picture.Graphic := pic;
+
+pic.Free;
+
+finally
+sltb.Free;
+end;
+
+finally
+sldb.Free;
+
+end;
+
+
+end;
+
+end.
diff --git a/Game/Code/lib/SQLite/lazarustest.lpi b/Game/Code/lib/SQLite/lazarustest.lpi new file mode 100644 index 00000000..0e65a1e2 --- /dev/null +++ b/Game/Code/lib/SQLite/lazarustest.lpi @@ -0,0 +1,123 @@ +<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="/"/> + <Version Value="5"/> + <General> + <MainUnit Value="0"/> + <IconPath Value="./"/> + <TargetFileExt Value=".exe"/> + <ActiveEditorIndexAtStart Value="0"/> + </General> + <VersionInfo> + <ProjectVersion Value=""/> + <Language Value=""/> + <CharSet Value=""/> + </VersionInfo> + <PublishOptions> + <Version Value="2"/> + <IgnoreBinaries Value="False"/> + <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> + <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> + </PublishOptions> + <RunParams> + <local> + <FormatVersion Value="1"/> + <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> + </local> + </RunParams> + <Units Count="9"> + <Unit0> + <Filename Value="lazarustest.lpr"/> + <IsPartOfProject Value="True"/> + <UnitName Value="lazarustest"/> + <CursorPos X="29" Y="18"/> + <TopLine Value="1"/> + <EditorIndex Value="0"/> + <UsageCount Value="23"/> + <Loaded Value="True"/> + </Unit0> + <Unit1> + <Filename Value="delphi/bass.pas"/> + <UnitName Value="Bass"/> + <CursorPos X="12" Y="539"/> + <TopLine Value="589"/> + <UsageCount Value="10"/> + </Unit1> + <Unit2> + <Filename Value="avformat.pas"/> + <UnitName Value="avformat"/> + <CursorPos X="38" Y="594"/> + <TopLine Value="567"/> + <UsageCount Value="10"/> + </Unit2> + <Unit3> + <Filename Value="avcodec.pas"/> + <UnitName Value="avcodec"/> + <CursorPos X="3" Y="1796"/> + <TopLine Value="1775"/> + <UsageCount Value="11"/> + </Unit3> + <Unit4> + <Filename Value="avio.pas"/> + <UnitName Value="avio"/> + <CursorPos X="1" Y="1"/> + <TopLine Value="1"/> + <UsageCount Value="11"/> + </Unit4> + <Unit5> + <Filename Value="pngimage.pas"/> + <UnitName Value="pngimage"/> + <CursorPos X="20" Y="133"/> + <TopLine Value="121"/> + <UsageCount Value="10"/> + </Unit5> + <Unit6> + <Filename Value="pngzlib.pas"/> + <UnitName Value="pngzlib"/> + <CursorPos X="6" Y="111"/> + <TopLine Value="91"/> + <UsageCount Value="10"/> + </Unit6> + <Unit7> + <Filename Value="pnglang.pas"/> + <UnitName Value="pnglang"/> + <CursorPos X="1" Y="1"/> + <TopLine Value="1"/> + <UsageCount Value="10"/> + </Unit7> + <Unit8> + <Filename Value="SQLiteTable3.pas"/> + <UnitName Value="SQLiteTable3"/> + <CursorPos X="28" Y="16"/> + <TopLine Value="1"/> + <UsageCount Value="10"/> + </Unit8> + </Units> + <JumpHistory Count="1" HistoryIndex="0"> + <Position1> + <Filename Value="lazarustest.lpr"/> + <Caret Line="47" Column="41" TopLine="1"/> + </Position1> + </JumpHistory> + </ProjectOptions> + <CompilerOptions> + <Version Value="5"/> + <CodeGeneration> + <Generate Value="Faster"/> + </CodeGeneration> + <Other> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> + <Debugging> + <Exceptions Count="2"> + <Item1> + <Name Value="ECodetoolError"/> + </Item1> + <Item2> + <Name Value="EFOpenError"/> + </Item2> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/Game/Code/lib/SQLite/lazarustest.lpr b/Game/Code/lib/SQLite/lazarustest.lpr new file mode 100644 index 00000000..bc005bec --- /dev/null +++ b/Game/Code/lib/SQLite/lazarustest.lpr @@ -0,0 +1,81 @@ +program lazarustest; + +uses + SQLiteTable3 in 'SQLiteTable3.pas', + SQLite3 in 'SQLite3.pas', + sysutils; + + +procedure DoTest(); +var + slDBpath : string; + sldb : TSQLiteDatabase; + sltb : TSQLIteTable; + sSQL : String; + Notes : String; + +begin + // needed for linux build. + + slDBPath := ExtractFilepath( paramstr(0) ) + 'test.db'; + sldb := TSQLiteDatabase.Create(slDBPath); + + try + + if sldb.TableExists('testTable') then + begin + sSQL := 'DROP TABLE testtable'; + sldb.execsql(sSQL); + end; + + sSQL := 'CREATE TABLE testtable ([ID] INTEGER PRIMARY KEY,[OtherID] INTEGER NULL,'; + sSQL := sSQL + '[Name] VARCHAR (255),[Number] FLOAT, [notes] BLOB, [picture] BLOB COLLATE NOCASE);'; + sldb.execsql(sSQL); + + sldb.execsql('CREATE INDEX TestTableName ON [testtable]([Name]);'); + + //begin a transaction + sldb.BeginTransaction; + + sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("Some Name",4,587.6594,"Here are some notes");'; + //do the insert + sldb.ExecSQL(sSQL); + + sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("Another Name",12,4758.3265,"More notes");'; + //do the insert + sldb.ExecSQL(sSQL); + + //end the transaction + sldb.Commit; + + //query the data + sltb := slDb.GetTable('SELECT * FROM testtable'); + try + + if sltb.Count > 0 then + begin + //display first row + writeln( sltb.FieldAsString(sltb.FieldIndex['Name']) ); + writeln( inttostr(sltb.FieldAsInteger(sltb.FieldIndex['ID'])) ); + writeln( floattostr( sltb.FieldAsDouble(sltb.FieldIndex['Number'])) ); + end; + + finally + sltb.Free; + end; + + finally + sldb.Free; + end; + +end; + +begin + try + DoTest(); + writeln( 'SqlLite3 unit IS lazarus compatible' ); + except + writeln( 'ERROR : SqlLite3 unit is NOT lazarus compatible' ); + end; +end. + diff --git a/Game/Code/lib/SQLite/libsqlite3.dylib b/Game/Code/lib/SQLite/libsqlite3.dylib Binary files differnew file mode 100755 index 00000000..303dcb05 --- /dev/null +++ b/Game/Code/lib/SQLite/libsqlite3.dylib diff --git a/Game/Code/lib/SQLite/readme.txt b/Game/Code/lib/SQLite/readme.txt new file mode 100644 index 00000000..80e5b3a1 --- /dev/null +++ b/Game/Code/lib/SQLite/readme.txt @@ -0,0 +1,82 @@ +14 Aug 2005
+
+The following changes were made by Lukas Gebauer (geby@volny.cz). In addition, some changes from a previous D5-compatible version were merged, and the supplied sqlite3.dll is updated to version 3.2.2
+
+Notes from Lukas:
+
+- added support for delphi 4+
+
+- datatype constants matches SQlite datatypes contants. (otherwise in some situations you got bad column datatype!)
+
+- removed dependency on strutils
+
+- code is reformated to better look (official borland formationg
+rules)
+
+- added some pragma's after database is open (temp is in memory)
+
+- TSQLiteDatabase.GetTableValue(const SQL: string): int64 for easy call of SQL commands what returning one number only. (like select
+count(*)...)
+
+- TSQLiteDatabase.GetTableString(const SQL: string): String for easy call of SQL commands what returning one string only. (like PRAGMA
+integrity_check)
+
+- TSQLiteDatabase.SetTimeout(Value: integer); you can set timeout for accessing to some table. Good for database sharing!
+
+- TSQLiteDatabase.version: string; returns SQLITE version string
+
+- removed bool fieldtype (it is not natural SQLite3 type)
+
+- fild type detection by Sqite3_columnType knows REAL too.
+
+- integer filedtype is based on Int64
+
+- GetFields can get data from any supported fieldtype
+
+- changed some integers to cardinal for avoid signed and unsigned mismatch
+
+- TSqliteTable.FieldAsInteger(I: cardinal): int64; returns int64
+
+
+3 May 2005 Fixed bug where strupper called on column type before checking for nil
+
+2 May 2005 Add extra check for nil in TSqliteTable.Destroy, thanks to Tim Maddrell
+
+22 Apr 2005 Revise TSqliteTable.Destroy to fix memory leak with dtStr type (thanks to
+Jose Brito)
+
+21 Apr 2005 Quick revision to fix case sensitivity in detecting column type,
+and remove PRAGMA full_column_names = 1 which is deprecated. Warning: may break code. Fix your SQL code so that all column names in a result set are unique.
+
+21 Feb 2005 Sqlite DLL now 3.1.3
+
+19 Feb 2005 Revised for Sqlite 3.1.2
+
+21 Dec 2004 First public release
+
+The following notice appears in the Sqlite source code:
+
+* +** 2001 September 15 +** +**
+** The author disclaims copyright to this source code. In place of +
+** a legal notice, here is a blessing:
+ +** + May you do good and not evil.
+ +** May you find forgiveness for yourself and forgive others.
+ +** May you share freely, never taking more than you give. +
+
+For more information about SQLite, see http://www.sqlite.org
+
+For more information about this simple wrapper, see http://www.itwriting.com/sqlitesimple.php
+
+
+
+ +
diff --git a/Game/Code/lib/bass/MacOSX/Bass.pas b/Game/Code/lib/bass/MacOSX/Bass.pas new file mode 100755 index 00000000..d065f027 --- /dev/null +++ b/Game/Code/lib/bass/MacOSX/Bass.pas @@ -0,0 +1,984 @@ +{ + BASS 2.3 Audio Library, (c) 1999-2007 Ian Luck. + Please report bugs/suggestions/etc... to bass@un4seen.com + + See the BASS.CHM file for more complete documentation + + + How to install + ---------------- + Copy BASS.PAS to the \LIB subdirectory of your Delphi path or your project dir +} +unit Bass; + +{$I switches.inc} + +interface + +uses + Windows; + +const + BASSVERSION = $203; // API version + + // Use these to test for error from functions that return a DWORD or QWORD + DW_ERROR = Cardinal(-1); // -1 (DWORD) + QW_ERROR = Int64(-1); // -1 (QWORD) + + // Error codes returned by BASS_GetErrorCode() + BASS_OK = 0; // all is OK + BASS_ERROR_MEM = 1; // memory error + BASS_ERROR_FILEOPEN = 2; // can't open the file + BASS_ERROR_DRIVER = 3; // can't find a free sound driver + BASS_ERROR_BUFLOST = 4; // the sample buffer was lost - please report this! + BASS_ERROR_HANDLE = 5; // invalid handle + BASS_ERROR_FORMAT = 6; // unsupported sample format + BASS_ERROR_POSITION = 7; // invalid playback position + BASS_ERROR_INIT = 8; // BASS_Init has not been successfully called + BASS_ERROR_START = 9; // BASS_Start has not been successfully called + BASS_ERROR_ALREADY = 14; // already initialized/paused/whatever + BASS_ERROR_NOPAUSE = 16; // not paused + BASS_ERROR_NOCHAN = 18; // can't get a free channel + BASS_ERROR_ILLTYPE = 19; // an illegal type was specified + BASS_ERROR_ILLPARAM = 20; // an illegal parameter was specified + BASS_ERROR_NO3D = 21; // no 3D support + BASS_ERROR_NOEAX = 22; // no EAX support + BASS_ERROR_DEVICE = 23; // illegal device number + BASS_ERROR_NOPLAY = 24; // not playing + BASS_ERROR_FREQ = 25; // illegal sample rate + BASS_ERROR_NOTFILE = 27; // the stream is not a file stream + BASS_ERROR_NOHW = 29; // no hardware voices available + BASS_ERROR_EMPTY = 31; // the MOD music has no sequence data + BASS_ERROR_NONET = 32; // no internet connection could be opened + BASS_ERROR_CREATE = 33; // couldn't create the file + BASS_ERROR_NOFX = 34; // effects are not enabled + BASS_ERROR_PLAYING = 35; // the channel is playing + BASS_ERROR_NOTAVAIL = 37; // requested data is not available + BASS_ERROR_DECODE = 38; // the channel is a "decoding channel" + BASS_ERROR_DX = 39; // a sufficient DirectX version is not installed + BASS_ERROR_TIMEOUT = 40; // connection timedout + BASS_ERROR_FILEFORM = 41; // unsupported file format + BASS_ERROR_SPEAKER = 42; // unavailable speaker + BASS_ERROR_VERSION = 43; // invalid BASS version (used by add-ons) + BASS_ERROR_CODEC = 44; // codec is not available/supported + BASS_ERROR_UNKNOWN = -1; // some other mystery error + + // Initialization flags + BASS_DEVICE_8BITS = 1; // use 8 bit resolution, else 16 bit + BASS_DEVICE_MONO = 2; // use mono, else stereo + BASS_DEVICE_3D = 4; // enable 3D functionality + { + If the BASS_DEVICE_3D flag is not specified when + initilizing BASS, then the 3D flags (BASS_SAMPLE_3D + and BASS_MUSIC_3D) are ignored when loading/creating + a sample/stream/music. + } + BASS_DEVICE_LATENCY = 256; // calculate device latency (BASS_INFO struct) + BASS_DEVICE_SPEAKERS = 2048; // force enabling of speaker assignment + BASS_DEVICE_NOSPEAKER = 4096; // ignore speaker arrangement + + // DirectSound interfaces (for use with BASS_GetDSoundObject) + BASS_OBJECT_DS = 1; // IDirectSound + BASS_OBJECT_DS3DL = 2; // IDirectSound3DListener + + // BASS_INFO flags (from DSOUND.H) + DSCAPS_CONTINUOUSRATE = $00000010; + { supports all sample rates between min/maxrate } + DSCAPS_EMULDRIVER = $00000020; + { device does NOT have hardware DirectSound support } + DSCAPS_CERTIFIED = $00000040; + { device driver has been certified by Microsoft } + { + The following flags tell what type of samples are + supported by HARDWARE mixing, all these formats are + supported by SOFTWARE mixing + } + DSCAPS_SECONDARYMONO = $00000100; // mono + DSCAPS_SECONDARYSTEREO = $00000200; // stereo + DSCAPS_SECONDARY8BIT = $00000400; // 8 bit + DSCAPS_SECONDARY16BIT = $00000800; // 16 bit + + // BASS_RECORDINFO flags (from DSOUND.H) + DSCCAPS_EMULDRIVER = DSCAPS_EMULDRIVER; + { device does NOT have hardware DirectSound recording support } + DSCCAPS_CERTIFIED = DSCAPS_CERTIFIED; + { device driver has been certified by Microsoft } + + // defines for formats field of BASS_RECORDINFO (from MMSYSTEM.H) + WAVE_FORMAT_1M08 = $00000001; // 11.025 kHz, Mono, 8-bit + WAVE_FORMAT_1S08 = $00000002; // 11.025 kHz, Stereo, 8-bit + WAVE_FORMAT_1M16 = $00000004; // 11.025 kHz, Mono, 16-bit + WAVE_FORMAT_1S16 = $00000008; // 11.025 kHz, Stereo, 16-bit + WAVE_FORMAT_2M08 = $00000010; // 22.05 kHz, Mono, 8-bit + WAVE_FORMAT_2S08 = $00000020; // 22.05 kHz, Stereo, 8-bit + WAVE_FORMAT_2M16 = $00000040; // 22.05 kHz, Mono, 16-bit + WAVE_FORMAT_2S16 = $00000080; // 22.05 kHz, Stereo, 16-bit + WAVE_FORMAT_4M08 = $00000100; // 44.1 kHz, Mono, 8-bit + WAVE_FORMAT_4S08 = $00000200; // 44.1 kHz, Stereo, 8-bit + WAVE_FORMAT_4M16 = $00000400; // 44.1 kHz, Mono, 16-bit + WAVE_FORMAT_4S16 = $00000800; // 44.1 kHz, Stereo, 16-bit + + // Sample info flags + BASS_SAMPLE_8BITS = 1; // 8 bit + BASS_SAMPLE_FLOAT = 256; // 32-bit floating-point + BASS_SAMPLE_MONO = 2; // mono, else stereo + BASS_SAMPLE_LOOP = 4; // looped + BASS_SAMPLE_3D = 8; // 3D functionality enabled + BASS_SAMPLE_SOFTWARE = 16; // it's NOT using hardware mixing + BASS_SAMPLE_MUTEMAX = 32; // muted at max distance (3D only) + BASS_SAMPLE_VAM = 64; // uses the DX7 voice allocation & management + BASS_SAMPLE_FX = 128; // old implementation of DX8 effects are enabled + BASS_SAMPLE_OVER_VOL = $10000; // override lowest volume + BASS_SAMPLE_OVER_POS = $20000; // override longest playing + BASS_SAMPLE_OVER_DIST = $30000; // override furthest from listener (3D only) + + BASS_STREAM_PRESCAN = $20000; // enable pin-point seeking (MP3/MP2/MP1) + BASS_MP3_SETPOS = BASS_STREAM_PRESCAN; + BASS_STREAM_AUTOFREE = $40000; // automatically free the stream when it stop/ends + BASS_STREAM_RESTRATE = $80000; // restrict the download rate of internet file streams + BASS_STREAM_BLOCK = $100000;// download/play internet file stream in small blocks + BASS_STREAM_DECODE = $200000;// don't play the stream, only decode (BASS_ChannelGetData) + BASS_STREAM_STATUS = $800000;// give server status info (HTTP/ICY tags) in DOWNLOADPROC + + BASS_MUSIC_FLOAT = BASS_SAMPLE_FLOAT; // 32-bit floating-point + BASS_MUSIC_MONO = BASS_SAMPLE_MONO; // force mono mixing (less CPU usage) + BASS_MUSIC_LOOP = BASS_SAMPLE_LOOP; // loop music + BASS_MUSIC_3D = BASS_SAMPLE_3D; // enable 3D functionality + BASS_MUSIC_FX = BASS_SAMPLE_FX; // enable old implementation of DX8 effects + BASS_MUSIC_AUTOFREE = BASS_STREAM_AUTOFREE; // automatically free the music when it stop/ends + BASS_MUSIC_DECODE = BASS_STREAM_DECODE; // don't play the music, only decode (BASS_ChannelGetData) + BASS_MUSIC_PRESCAN = BASS_STREAM_PRESCAN; // calculate playback length + BASS_MUSIC_CALCLEN = BASS_MUSIC_PRESCAN; + BASS_MUSIC_RAMP = $200; // normal ramping + BASS_MUSIC_RAMPS = $400; // sensitive ramping + BASS_MUSIC_SURROUND = $800; // surround sound + BASS_MUSIC_SURROUND2 = $1000; // surround sound (mode 2) + BASS_MUSIC_FT2MOD = $2000; // play .MOD as FastTracker 2 does + BASS_MUSIC_PT1MOD = $4000; // play .MOD as ProTracker 1 does + BASS_MUSIC_NONINTER = $10000; // non-interpolated mixing + BASS_MUSIC_POSRESET = $8000; // stop all notes when moving position + BASS_MUSIC_POSRESETEX = $400000; // stop all notes and reset bmp/etc when moving position + BASS_MUSIC_STOPBACK = $80000; // stop the music on a backwards jump effect + BASS_MUSIC_NOSAMPLE = $100000; // don't load the samples + + // Speaker assignment flags + BASS_SPEAKER_FRONT = $1000000; // front speakers + BASS_SPEAKER_REAR = $2000000; // rear/side speakers + BASS_SPEAKER_CENLFE = $3000000; // center & LFE speakers (5.1) + BASS_SPEAKER_REAR2 = $4000000; // rear center speakers (7.1) + BASS_SPEAKER_LEFT = $10000000; // modifier: left + BASS_SPEAKER_RIGHT = $20000000; // modifier: right + BASS_SPEAKER_FRONTLEFT = BASS_SPEAKER_FRONT or BASS_SPEAKER_LEFT; + BASS_SPEAKER_FRONTRIGHT = BASS_SPEAKER_FRONT or BASS_SPEAKER_RIGHT; + BASS_SPEAKER_REARLEFT = BASS_SPEAKER_REAR or BASS_SPEAKER_LEFT; + BASS_SPEAKER_REARRIGHT = BASS_SPEAKER_REAR or BASS_SPEAKER_RIGHT; + BASS_SPEAKER_CENTER = BASS_SPEAKER_CENLFE or BASS_SPEAKER_LEFT; + BASS_SPEAKER_LFE = BASS_SPEAKER_CENLFE or BASS_SPEAKER_RIGHT; + BASS_SPEAKER_REAR2LEFT = BASS_SPEAKER_REAR2 or BASS_SPEAKER_LEFT; + BASS_SPEAKER_REAR2RIGHT = BASS_SPEAKER_REAR2 or BASS_SPEAKER_RIGHT; + + BASS_UNICODE = $80000000; + + BASS_RECORD_PAUSE = $8000; // start recording paused + + // DX7 voice allocation flags + BASS_VAM_HARDWARE = 1; + { + Play the sample in hardware. If no hardware voices are available then + the "play" call will fail + } + BASS_VAM_SOFTWARE = 2; + { + Play the sample in software (ie. non-accelerated). No other VAM flags + may be used together with this flag. + } + + // DX7 voice management flags + { + These flags enable hardware resource stealing... if the hardware has no + available voices, a currently playing buffer will be stopped to make room + for the new buffer. NOTE: only samples loaded/created with the + BASS_SAMPLE_VAM flag are considered for termination by the DX7 voice + management. + } + BASS_VAM_TERM_TIME = 4; + { + If there are no free hardware voices, the buffer to be terminated will be + the one with the least time left to play. + } + BASS_VAM_TERM_DIST = 8; + { + If there are no free hardware voices, the buffer to be terminated will be + one that was loaded/created with the BASS_SAMPLE_MUTEMAX flag and is + beyond + it's max distance. If there are no buffers that match this criteria, then + the "play" call will fail. + } + BASS_VAM_TERM_PRIO = 16; + { + If there are no free hardware voices, the buffer to be terminated will be + the one with the lowest priority. + } + + // BASS_CHANNELINFO types + BASS_CTYPE_SAMPLE = 1; + BASS_CTYPE_RECORD = 2; + BASS_CTYPE_STREAM = $10000; + BASS_CTYPE_STREAM_OGG = $10002; + BASS_CTYPE_STREAM_MP1 = $10003; + BASS_CTYPE_STREAM_MP2 = $10004; + BASS_CTYPE_STREAM_MP3 = $10005; + BASS_CTYPE_STREAM_AIFF = $10006; + BASS_CTYPE_STREAM_WAV = $40000; // WAVE flag, LOWORD=codec + BASS_CTYPE_STREAM_WAV_PCM = $50001; + BASS_CTYPE_STREAM_WAV_FLOAT = $50003; + BASS_CTYPE_MUSIC_MOD = $20000; + BASS_CTYPE_MUSIC_MTM = $20001; + BASS_CTYPE_MUSIC_S3M = $20002; + BASS_CTYPE_MUSIC_XM = $20003; + BASS_CTYPE_MUSIC_IT = $20004; + BASS_CTYPE_MUSIC_MO3 = $00100; // MO3 flag + + // 3D channel modes + BASS_3DMODE_NORMAL = 0; + { normal 3D processing } + BASS_3DMODE_RELATIVE = 1; + { + The channel's 3D position (position/velocity/ + orientation) are relative to the listener. When the + listener's position/velocity/orientation is changed + with BASS_Set3DPosition, the channel's position + relative to the listener does not change. + } + BASS_3DMODE_OFF = 2; + { + Turn off 3D processing on the channel, the sound will + be played in the center. + } + + // EAX environments, use with BASS_SetEAXParameters + EAX_ENVIRONMENT_GENERIC = 0; + EAX_ENVIRONMENT_PADDEDCELL = 1; + EAX_ENVIRONMENT_ROOM = 2; + EAX_ENVIRONMENT_BATHROOM = 3; + EAX_ENVIRONMENT_LIVINGROOM = 4; + EAX_ENVIRONMENT_STONEROOM = 5; + EAX_ENVIRONMENT_AUDITORIUM = 6; + EAX_ENVIRONMENT_CONCERTHALL = 7; + EAX_ENVIRONMENT_CAVE = 8; + EAX_ENVIRONMENT_ARENA = 9; + EAX_ENVIRONMENT_HANGAR = 10; + EAX_ENVIRONMENT_CARPETEDHALLWAY = 11; + EAX_ENVIRONMENT_HALLWAY = 12; + EAX_ENVIRONMENT_STONECORRIDOR = 13; + EAX_ENVIRONMENT_ALLEY = 14; + EAX_ENVIRONMENT_FOREST = 15; + EAX_ENVIRONMENT_CITY = 16; + EAX_ENVIRONMENT_MOUNTAINS = 17; + EAX_ENVIRONMENT_QUARRY = 18; + EAX_ENVIRONMENT_PLAIN = 19; + EAX_ENVIRONMENT_PARKINGLOT = 20; + EAX_ENVIRONMENT_SEWERPIPE = 21; + EAX_ENVIRONMENT_UNDERWATER = 22; + EAX_ENVIRONMENT_DRUGGED = 23; + EAX_ENVIRONMENT_DIZZY = 24; + EAX_ENVIRONMENT_PSYCHOTIC = 25; + // total number of environments + EAX_ENVIRONMENT_COUNT = 26; + + // software 3D mixing algorithm modes (used with BASS_Set3DAlgorithm) + BASS_3DALG_DEFAULT = 0; + { + default algorithm (currently translates to BASS_3DALG_OFF) + } + BASS_3DALG_OFF = 1; + { + Uses normal left and right panning. The vertical axis is ignored except + for scaling of volume due to distance. Doppler shift and volume scaling + are still applied, but the 3D filtering is not performed. This is the + most CPU efficient software implementation, but provides no virtual 3D + audio effect. Head Related Transfer Function processing will not be done. + Since only normal stereo panning is used, a channel using this algorithm + may be accelerated by a 2D hardware voice if no free 3D hardware voices + are available. + } + BASS_3DALG_FULL = 2; + { + This algorithm gives the highest quality 3D audio effect, but uses more + CPU. Requires Windows 98 2nd Edition or Windows 2000 that uses WDM + drivers, if this mode is not available then BASS_3DALG_OFF will be used + instead. + } + BASS_3DALG_LIGHT = 3; + { + This algorithm gives a good 3D audio effect, and uses less CPU than the + FULL mode. Requires Windows 98 2nd Edition or Windows 2000 that uses WDM + drivers, if this mode is not available then BASS_3DALG_OFF will be used + instead. + } + + { + Sync types (with BASS_ChannelSetSync() "param" and + SYNCPROC "data" definitions) & flags. + } + BASS_SYNC_POS = 0; + { + Sync when a channel reaches a position. + param: position in bytes + data : not used + } + BASS_SYNC_END = 2; + { + Sync when a channel reaches the end. + param: not used + data : not used + } + BASS_SYNC_META = 4; + { + Sync when metadata is received in a stream. + param: not used + data : pointer to the metadata + } + BASS_SYNC_SLIDE = 5; + { + Sync when an attribute slide is completed. + param: not used + data : the type of slide completed (one of the BASS_SLIDE_xxx values) + } + BASS_SYNC_STALL = 6; + { + Sync when playback has stalled. + param: not used + data : 0=stalled, 1=resumed + } + BASS_SYNC_DOWNLOAD = 7; + { + Sync when downloading of an internet (or "buffered" user file) stream has ended. + param: not used + data : not used + } + BASS_SYNC_FREE = 8; + { + Sync when a channel is freed. + param: not used + data : not used + } + BASS_SYNC_SETPOS = 11; + { + Sync when a channel's position is set. + param: not used + data : 0 = playback buffer not flushed, 1 = playback buffer flushed + } + BASS_SYNC_MUSICPOS = 10; + { + Sync when a MOD music reaches an order:row position. + param: LOWORD=order (0=first, -1=all) HIWORD=row (0=first, -1=all) + data : LOWORD=order HIWORD=row + } + BASS_SYNC_MUSICINST = 1; + { + Sync when an instrument (sample for the non-instrument based formats) + is played in a MOD music (not including retrigs). + param: LOWORD=instrument (1=first) HIWORD=note (0=c0...119=b9, -1=all) + data : LOWORD=note HIWORD=volume (0-64) + } + BASS_SYNC_MUSICFX = 3; + { + Sync when the "sync" effect (XM/MTM/MOD: E8x/Wxx, IT/S3M: S2x) is used. + param: 0:data=pos, 1:data="x" value + data : param=0: LOWORD=order HIWORD=row, param=1: "x" value + } + BASS_SYNC_MESSAGE = $20000000; + { FLAG: post a Windows message (instead of callback) + When using a window message "callback", the message to post is given in the "proc" + parameter of BASS_ChannelSetSync, and is posted to the window specified in the BASS_Init + call. The message parameters are: WPARAM = data, LPARAM = user. + } + BASS_SYNC_MIXTIME = $40000000; + { FLAG: sync at mixtime, else at playtime } + BASS_SYNC_ONETIME = $80000000; + { FLAG: sync only once, else continuously } + + // BASS_ChannelIsActive return values + BASS_ACTIVE_STOPPED = 0; + BASS_ACTIVE_PLAYING = 1; + BASS_ACTIVE_STALLED = 2; + BASS_ACTIVE_PAUSED = 3; + + // BASS_ChannelIsSliding return flags + BASS_SLIDE_FREQ = 1; + BASS_SLIDE_VOL = 2; + BASS_SLIDE_PAN = 4; + + // BASS_ChannelGetData flags + BASS_DATA_AVAILABLE = 0; // query how much data is buffered + BASS_DATA_FLOAT = $40000000; // flag: return floating-point sample data + BASS_DATA_FFT512 = $80000000; // 512 sample FFT + BASS_DATA_FFT1024 = $80000001; // 1024 FFT + BASS_DATA_FFT2048 = $80000002; // 2048 FFT + BASS_DATA_FFT4096 = $80000003; // 4096 FFT + BASS_DATA_FFT8192 = $80000004; // 8192 FFT + BASS_DATA_FFT_INDIVIDUAL = $10; // FFT flag: FFT for each channel, else all combined + BASS_DATA_FFT_NOWINDOW = $20; // FFT flag: no Hanning window + + // BASS_ChannelGetTags types : what's returned + BASS_TAG_ID3 = 0; // ID3v1 tags : 128 byte block + BASS_TAG_ID3V2 = 1; // ID3v2 tags : variable length block + BASS_TAG_OGG = 2; // OGG comments : array of null-terminated strings + BASS_TAG_HTTP = 3; // HTTP headers : array of null-terminated strings + BASS_TAG_ICY = 4; // ICY headers : array of null-terminated strings + BASS_TAG_META = 5; // ICY metadata : null-terminated string + BASS_TAG_VENDOR = 9; // OGG encoder : null-terminated string + BASS_TAG_LYRICS3 = 10; // Lyric3v2 tag : ASCII string + BASS_TAG_RIFF_INFO = $100; // RIFF/WAVE tags : array of null-terminated ANSI strings + BASS_TAG_MUSIC_NAME = $10000; // MOD music name : ANSI string + BASS_TAG_MUSIC_MESSAGE = $10001; // MOD message : ANSI string + BASS_TAG_MUSIC_INST = $10100; // + instrument #, MOD instrument name : ANSI string + BASS_TAG_MUSIC_SAMPLE = $10300; // + sample #, MOD sample name : ANSI string + + BASS_FX_CHORUS = 0; // GUID_DSFX_STANDARD_CHORUS + BASS_FX_COMPRESSOR = 1; // GUID_DSFX_STANDARD_COMPRESSOR + BASS_FX_DISTORTION = 2; // GUID_DSFX_STANDARD_DISTORTION + BASS_FX_ECHO = 3; // GUID_DSFX_STANDARD_ECHO + BASS_FX_FLANGER = 4; // GUID_DSFX_STANDARD_FLANGER + BASS_FX_GARGLE = 5; // GUID_DSFX_STANDARD_GARGLE + BASS_FX_I3DL2REVERB = 6; // GUID_DSFX_STANDARD_I3DL2REVERB + BASS_FX_PARAMEQ = 7; // GUID_DSFX_STANDARD_PARAMEQ + BASS_FX_REVERB = 8; // GUID_DSFX_WAVES_REVERB + + BASS_FX_PHASE_NEG_180 = 0; + BASS_FX_PHASE_NEG_90 = 1; + BASS_FX_PHASE_ZERO = 2; + BASS_FX_PHASE_90 = 3; + BASS_FX_PHASE_180 = 4; + + // BASS_RecordSetInput flags + BASS_INPUT_OFF = $10000; + BASS_INPUT_ON = $20000; + BASS_INPUT_LEVEL = $40000; + + BASS_INPUT_TYPE_MASK = $ff000000; + BASS_INPUT_TYPE_UNDEF = $00000000; + BASS_INPUT_TYPE_DIGITAL = $01000000; + BASS_INPUT_TYPE_LINE = $02000000; + BASS_INPUT_TYPE_MIC = $03000000; + BASS_INPUT_TYPE_SYNTH = $04000000; + BASS_INPUT_TYPE_CD = $05000000; + BASS_INPUT_TYPE_PHONE = $06000000; + BASS_INPUT_TYPE_SPEAKER = $07000000; + BASS_INPUT_TYPE_WAVE = $08000000; + BASS_INPUT_TYPE_AUX = $09000000; + BASS_INPUT_TYPE_ANALOG = $0a000000; + + // BASS_SetNetConfig flags + BASS_NET_TIMEOUT = 0; + BASS_NET_BUFFER = 1; + + // BASS_StreamGetFilePosition modes + BASS_FILEPOS_CURRENT = 0; + BASS_FILEPOS_DECODE = BASS_FILEPOS_CURRENT; + BASS_FILEPOS_DOWNLOAD = 1; + BASS_FILEPOS_END = 2; + BASS_FILEPOS_START = 3; + BASS_FILEPOS_CONNECTED = 4; + + // STREAMFILEPROC actions + BASS_FILE_CLOSE = 0; + BASS_FILE_READ = 1; + BASS_FILE_LEN = 3; + BASS_FILE_SEEK = 4; + + BASS_STREAMPROC_END = $80000000; // end of user stream flag + + // BASS_MusicSet/GetAttribute options + BASS_MUSIC_ATTRIB_AMPLIFY = 0; + BASS_MUSIC_ATTRIB_PANSEP = 1; + BASS_MUSIC_ATTRIB_PSCALER = 2; + BASS_MUSIC_ATTRIB_BPM = 3; + BASS_MUSIC_ATTRIB_SPEED = 4; + BASS_MUSIC_ATTRIB_VOL_GLOBAL = 5; + BASS_MUSIC_ATTRIB_VOL_CHAN = $100; // + channel # + BASS_MUSIC_ATTRIB_VOL_INST = $200; // + instrument # + + // BASS_Set/GetConfig options + BASS_CONFIG_BUFFER = 0; + BASS_CONFIG_UPDATEPERIOD = 1; + BASS_CONFIG_MAXVOL = 3; + BASS_CONFIG_GVOL_SAMPLE = 4; + BASS_CONFIG_GVOL_STREAM = 5; + BASS_CONFIG_GVOL_MUSIC = 6; + BASS_CONFIG_CURVE_VOL = 7; + BASS_CONFIG_CURVE_PAN = 8; + BASS_CONFIG_FLOATDSP = 9; + BASS_CONFIG_3DALGORITHM = 10; + BASS_CONFIG_NET_TIMEOUT = 11; + BASS_CONFIG_NET_BUFFER = 12; + BASS_CONFIG_PAUSE_NOPLAY = 13; + BASS_CONFIG_NET_PREBUF = 15; + BASS_CONFIG_NET_AGENT = 16; + BASS_CONFIG_NET_PROXY = 17; + BASS_CONFIG_NET_PASSIVE = 18; + BASS_CONFIG_REC_BUFFER = 19; + BASS_CONFIG_NET_PLAYLIST = 21; + BASS_CONFIG_MUSIC_VIRTUAL = 22; + +type + DWORD = cardinal; + BOOL = LongBool; + FLOAT = Single; + QWORD = int64; // 64-bit (replace "int64" with "comp" if using Delphi 3) + + HMUSIC = DWORD; // MOD music handle + HSAMPLE = DWORD; // sample handle + HCHANNEL = DWORD; // playing sample's channel handle + HSTREAM = DWORD; // sample stream handle + HRECORD = DWORD; // recording handle + HSYNC = DWORD; // synchronizer handle + HDSP = DWORD; // DSP handle + HFX = DWORD; // DX8 effect handle + HPLUGIN = DWORD; // Plugin handle + + BASS_INFO = record + flags: DWORD; // device capabilities (DSCAPS_xxx flags) + hwsize: DWORD; // size of total device hardware memory + hwfree: DWORD; // size of free device hardware memory + freesam: DWORD; // number of free sample slots in the hardware + free3d: DWORD; // number of free 3D sample slots in the hardware + minrate: DWORD; // min sample rate supported by the hardware + maxrate: DWORD; // max sample rate supported by the hardware + eax: BOOL; // device supports EAX? (always FALSE if BASS_DEVICE_3D was not used) + minbuf: DWORD; // recommended minimum buffer length in ms (requires BASS_DEVICE_LATENCY) + dsver: DWORD; // DirectSound version + latency: DWORD; // delay (in ms) before start of playback (requires BASS_DEVICE_LATENCY) + initflags: DWORD; // "flags" parameter of BASS_Init call + speakers: DWORD; // number of speakers available + driver: PChar; // driver + freq: DWORD; // current output rate (OSX only) + end; + + BASS_RECORDINFO = record + flags: DWORD; // device capabilities (DSCCAPS_xxx flags) + formats: DWORD; // supported standard formats (WAVE_FORMAT_xxx flags) + inputs: DWORD; // number of inputs + singlein: BOOL; // only 1 input can be set at a time + driver: PChar; // driver + freq: DWORD; // current input rate (OSX only) + end; + + BASS_CHANNELINFO = record + freq: DWORD; // default playback rate + chans: DWORD; // channels + flags: DWORD; // BASS_SAMPLE/STREAM/MUSIC/SPEAKER flags + ctype: DWORD; // type of channel + origres: DWORD; // original resolution + plugin: HPLUGIN; // plugin + end; + + BASS_PLUGINFORM = record + ctype: DWORD; // channel type + name: PChar; // format description + exts: PChar; // file extension filter ( *.ext1;*.ext2;etc...) + end; + PBASS_PLUGINFORMS = ^TBASS_PLUGINFORMS; + TBASS_PLUGINFORMS = array[0..maxInt div sizeOf(BASS_PLUGINFORM) - 1] of BASS_PLUGINFORM; + + BASS_PLUGININFO = record + version: DWORD; // version (same form as BASS_GetVersion) + formatc: DWORD; // number of formats + formats: PBASS_PLUGINFORMS; // the array of formats + end; + PBASS_PLUGININFO = ^BASS_PLUGININFO; + + // Sample info structure + BASS_SAMPLE = record + freq: DWORD; // default playback rate + volume: DWORD; // default volume (0-100) + pan: Integer; // default pan (-100=left, 0=middle, 100=right) + flags: DWORD; // BASS_SAMPLE_xxx flags + length: DWORD; // length (in samples, not bytes) + max: DWORD; // maximum simultaneous playbacks + origres: DWORD; // original resolution + chans: DWORD; // number of channels + mingap: DWORD; // minimum gap (ms) between creating channels + { + The following are the samples default 3D attributes + (if the sample is 3D, BASS_SAMPLE_3D is in flags) + see BASS_ChannelSet3DAttributes + } + mode3d: DWORD; // BASS_3DMODE_xxx mode + mindist: FLOAT; // minimum distance + maxdist: FLOAT; // maximum distance + iangle: DWORD; // angle of inside projection cone + oangle: DWORD; // angle of outside projection cone + outvol: DWORD; // delta-volume outside the projection cone + { + The following are the defaults used if the sample uses the DirectX 7 + voice allocation/management features. + } + vam: DWORD; // voice allocation/management flags (BASS_VAM_xxx) + priority: DWORD; // priority (0=lowest, $ffffffff=highest) + end; + + // 3D vector (for 3D positions/velocities/orientations) + BASS_3DVECTOR = record + x: FLOAT; // +=right, -=left + y: FLOAT; // +=up, -=down + z: FLOAT; // +=front, -=behind + end; + + BASS_FXCHORUS = record + fWetDryMix: FLOAT; + fDepth: FLOAT; + fFeedback: FLOAT; + fFrequency: FLOAT; + lWaveform: DWORD; // 0=triangle, 1=sine + fDelay: FLOAT; + lPhase: DWORD; // BASS_FX_PHASE_xxx + end; + + BASS_FXCOMPRESSOR = record + fGain: FLOAT; + fAttack: FLOAT; + fRelease: FLOAT; + fThreshold: FLOAT; + fRatio: FLOAT; + fPredelay: FLOAT; + end; + + BASS_FXDISTORTION = record + fGain: FLOAT; + fEdge: FLOAT; + fPostEQCenterFrequency: FLOAT; + fPostEQBandwidth: FLOAT; + fPreLowpassCutoff: FLOAT; + end; + + BASS_FXECHO = record + fWetDryMix: FLOAT; + fFeedback: FLOAT; + fLeftDelay: FLOAT; + fRightDelay: FLOAT; + lPanDelay: BOOL; + end; + + BASS_FXFLANGER = record + fWetDryMix: FLOAT; + fDepth: FLOAT; + fFeedback: FLOAT; + fFrequency: FLOAT; + lWaveform: DWORD; // 0=triangle, 1=sine + fDelay: FLOAT; + lPhase: DWORD; // BASS_FX_PHASE_xxx + end; + + BASS_FXGARGLE = record + dwRateHz: DWORD; // Rate of modulation in hz + dwWaveShape: DWORD; // 0=triangle, 1=square + end; + + BASS_FXI3DL2REVERB = record + lRoom: Longint; // [-10000, 0] default: -1000 mB + lRoomHF: Longint; // [-10000, 0] default: 0 mB + flRoomRolloffFactor: FLOAT; // [0.0, 10.0] default: 0.0 + flDecayTime: FLOAT; // [0.1, 20.0] default: 1.49s + flDecayHFRatio: FLOAT; // [0.1, 2.0] default: 0.83 + lReflections: Longint; // [-10000, 1000] default: -2602 mB + flReflectionsDelay: FLOAT; // [0.0, 0.3] default: 0.007 s + lReverb: Longint; // [-10000, 2000] default: 200 mB + flReverbDelay: FLOAT; // [0.0, 0.1] default: 0.011 s + flDiffusion: FLOAT; // [0.0, 100.0] default: 100.0 % + flDensity: FLOAT; // [0.0, 100.0] default: 100.0 % + flHFReference: FLOAT; // [20.0, 20000.0] default: 5000.0 Hz + end; + + BASS_FXPARAMEQ = record + fCenter: FLOAT; + fBandwidth: FLOAT; + fGain: FLOAT; + end; + + BASS_FXREVERB = record + fInGain: FLOAT; // [-96.0,0.0] default: 0.0 dB + fReverbMix: FLOAT; // [-96.0,0.0] default: 0.0 db + fReverbTime: FLOAT; // [0.001,3000.0] default: 1000.0 ms + fHighFreqRTRatio: FLOAT; // [0.001,0.999] default: 0.001 + end; + + // callback function types + STREAMPROC = function(handle: HSTREAM; buffer: Pointer; length: DWORD; user: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + { + User stream callback function. NOTE: A stream function should obviously be as + quick as possible, other streams (and MOD musics) can't be mixed until + it's finished. + handle : The stream that needs writing + buffer : Buffer to write the samples in + length : Number of bytes to write + user : The 'user' parameter value given when calling BASS_StreamCreate + RETURN : Number of bytes written. Set the BASS_STREAMPROC_END flag to end + the stream. + } + + STREAMFILEPROC = function(action, param1, param2, user: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + { + User file stream callback function. + action : The action to perform, one of BASS_FILE_xxx values. + param1 : Depends on "action" + param2 : Depends on "action" + user : The 'user' parameter value given when calling BASS_StreamCreate + RETURN : Depends on "action" + } + + DOWNLOADPROC = procedure(buffer: Pointer; length: DWORD; user: DWORD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + { + Internet stream download callback function. + buffer : Buffer containing the downloaded data... NULL=end of download + length : Number of bytes in the buffer + user : The 'user' parameter value given when calling BASS_StreamCreateURL + } + + SYNCPROC = procedure(handle: HSYNC; channel, data: DWORD; user: DWORD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + { + Sync callback function. NOTE: a sync callback function should be very + quick as other syncs cannot be processed until it has finished. If the + sync is a "mixtime" sync, then other streams and MOD musics can not be + mixed until it's finished either. + handle : The sync that has occured + channel: Channel that the sync occured in + data : Additional data associated with the sync's occurance + user : The 'user' parameter given when calling BASS_ChannelSetSync + } + + DSPPROC = procedure(handle: HDSP; channel: DWORD; buffer: Pointer; length: DWORD; user: DWORD); {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + { + DSP callback function. NOTE: A DSP function should obviously be as quick + as possible... other DSP functions, streams and MOD musics can not be + processed until it's finished. + handle : The DSP handle + channel: Channel that the DSP is being applied to + buffer : Buffer to apply the DSP to + length : Number of bytes in the buffer + user : The 'user' parameter given when calling BASS_ChannelSetDSP + } + + RECORDPROC = function(handle: HRECORD; const buffer: Pointer; length: DWORD; user: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} + { + Recording callback function. + handle : The recording handle + buffer : Buffer containing the recorded sample data + length : Number of bytes + user : The 'user' parameter value given when calling BASS_RecordStart + RETURN : TRUE = continue recording, FALSE = stop + } + + +// Functions +const + +{$IFDEF MSWINDOWS} + bassdll = 'bass.dll'; +{$ENDIF} +{$IFDEF DARWIN} + bassdll = 'libbass.dylib'; +{$ENDIF} + +function BASS_SetConfig(option, value: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_GetConfig(option: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_GetVersion: DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_GetDeviceDescription(device: DWORD): PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ErrorGetCode: Integer; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_Init(device: Integer; freq, flags: DWORD; win: HWND; clsid: PGUID): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_SetDevice(device: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_GetDevice: DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_Free: BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_GetDSoundObject(obj: DWORD): Pointer; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_GetInfo(var info: BASS_INFO): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_Update: BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_GetCPU: FLOAT; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_Start: BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_Stop: BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_Pause: BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_SetVolume(volume: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_GetVolume: Integer; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; + +function BASS_PluginLoad(filename: PChar; flags: DWORD): HPLUGIN; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_PluginFree(handle: HPLUGIN): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_PluginGetInfo(handle: HPLUGIN): PBASS_PLUGININFO; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; + +function BASS_Set3DFactors(distf, rollf, doppf: FLOAT): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_Get3DFactors(var distf, rollf, doppf: FLOAT): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_Set3DPosition(var pos, vel, front, top: BASS_3DVECTOR): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_Get3DPosition(var pos, vel, front, top: BASS_3DVECTOR): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +procedure BASS_Apply3D; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +{$IFDEF MSWINDOWS} +function BASS_SetEAXParameters(env: Integer; vol, decay, damp: FLOAT): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_GetEAXParameters(var env: DWORD; var vol, decay, damp: FLOAT): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +{$ENDIF} + +function BASS_MusicLoad(mem: BOOL; f: Pointer; offset, length, flags, freq: DWORD): HMUSIC; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_MusicFree(handle: HMUSIC): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_MusicSetAttribute(handle: HMUSIC; attrib,value: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_MusicGetAttribute(handle: HMUSIC; attrib: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_MusicGetOrders(handle: HMUSIC): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_MusicGetOrderPosition(handle: HMUSIC): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; + +function BASS_SampleLoad(mem: BOOL; f: Pointer; offset, length, max, flags: DWORD): HSAMPLE; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_SampleCreate(length, freq, chans, max, flags: DWORD): Pointer; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_SampleCreateDone: HSAMPLE; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_SampleFree(handle: HSAMPLE): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_SampleGetInfo(handle: HSAMPLE; var info: BASS_SAMPLE): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_SampleSetInfo(handle: HSAMPLE; var info: BASS_SAMPLE): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_SampleGetChannel(handle: HSAMPLE; onlynew: BOOL): HCHANNEL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_SampleGetChannels(handle: HSAMPLE; channels: Pointer): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_SampleStop(handle: HSAMPLE): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; + +function BASS_StreamCreate(freq, chans, flags: DWORD; proc: Pointer; user: DWORD): HSTREAM; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_StreamCreateFile(mem: BOOL; f: Pointer; offset, length, flags: DWORD): HSTREAM; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_StreamCreateURL(url: PChar; offset: DWORD; flags: DWORD; proc: DOWNLOADPROC; user: DWORD):HSTREAM; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_StreamCreateFileUser(buffered: BOOL; flags: DWORD; proc: STREAMFILEPROC; user: DWORD): HSTREAM; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_StreamFree(handle: HSTREAM): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_StreamGetFilePosition(handle:HSTREAM; mode:DWORD) : DWORD;{$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_StreamGetLength(handle: DWORD): QWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll name 'BASS_ChannelGetLength'; + +function BASS_RecordGetDeviceDescription(devnum: DWORD):PChar;{$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_RecordInit(device: Integer):BOOL;{$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_RecordSetDevice(device: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_RecordGetDevice: DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_RecordFree:BOOL;{$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_RecordGetInfo(var info:BASS_RECORDINFO):BOOL;{$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_RecordGetInputName(input:Integer):PChar;{$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_RecordSetInput(input:Integer; setting:DWORD):BOOL;{$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_RecordGetInput(input:Integer):DWORD;{$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_RecordStart(freq,chans,flags:DWORD; proc:RECORDPROC; user:DWORD):HRECORD;{$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; + +function BASS_ChannelBytes2Seconds(handle: DWORD; pos: QWORD): FLOAT; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_ChannelSeconds2Bytes(handle: DWORD; pos: FLOAT): QWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_ChannelGetDevice(handle: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelSetDevice(handle, device: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelIsActive(handle: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_ChannelGetInfo(handle: DWORD; var info:BASS_CHANNELINFO):BOOL;{$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_ChannelGetTags(handle: HSTREAM; tags : DWORD): PChar; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelSetFlags(handle, flags: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelPreBuf(handle, length: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelPlay(handle: DWORD; restart: BOOL): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelStop(handle: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelPause(handle: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelSetAttributes(handle: DWORD; freq, volume, pan: Integer): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelGetAttributes(handle: DWORD; var freq, volume: DWORD; var pan: Integer): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelSlideAttributes(handle: DWORD; freq, volume, pan: Integer; time: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelIsSliding(handle: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF}external bassdll; +function BASS_ChannelSet3DAttributes(handle: DWORD; mode: Integer; min, max: FLOAT; iangle, oangle, outvol: Integer): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelGet3DAttributes(handle: DWORD; var mode: DWORD; var min, max: FLOAT; var iangle, oangle, outvol: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelSet3DPosition(handle: DWORD; var pos, orient, vel: BASS_3DVECTOR): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelGet3DPosition(handle: DWORD; var pos, orient, vel: BASS_3DVECTOR): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelGetLength(handle: DWORD): QWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelSetPosition(handle: DWORD; pos: QWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelGetPosition(handle: DWORD): QWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelGetLevel(handle: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelGetData(handle: DWORD; buffer: Pointer; length: DWORD): DWORD; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelSetSync(handle: DWORD; stype: DWORD; param: QWORD; proc: SYNCPROC; user: DWORD): HSYNC; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelRemoveSync(handle: DWORD; sync: HSYNC): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelSetDSP(handle: DWORD; proc: DSPPROC; user: DWORD; priority: Integer): HDSP; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelRemoveDSP(handle: DWORD; dsp: HDSP): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +{$IFDEF MSWINDOWS} +function BASS_ChannelSetEAXMix(handle: DWORD; mix: FLOAT): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelGetEAXMix(handle: DWORD; var mix: FLOAT): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +{$ENDIF} +function BASS_ChannelSetLink(handle, chan: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelRemoveLink(handle, chan: DWORD): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelSetFX(handle, etype: DWORD; priority: Integer): HFX; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_ChannelRemoveFX(handle: DWORD; fx: HFX): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; + +function BASS_FXSetParameters(handle: HFX; par: Pointer): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_FXGetParameters(handle: HFX; par: Pointer): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; +function BASS_FXReset(handle: HFX): BOOL; {$IFDEF DLL_STDCALL} stdcall; {$ENDIF} {$IFDEF DLL_CDECL} cdecl; {$ENDIF} external bassdll; + + +function BASS_SPEAKER_N(n: DWORD): DWORD; +function MAKEMUSICPOS(order,row: DWORD): DWORD; +{$IFDEF MSWINDOWS} +function BASS_SetEAXPreset(env: Integer): BOOL; +{ + This function is defined in the implementation part of this unit. + It is not part of BASS.DLL but an extra function which makes it easier + to set the predefined EAX environments. + env : a EAX_ENVIRONMENT_xxx constant +} +{$ENDIF} + +implementation + +function BASS_SPEAKER_N(n: DWORD): DWORD; +begin + Result := n shl 24; +end; + +function MAKEMUSICPOS(order,row: DWORD): DWORD; +begin + Result := $80000000 or DWORD(MAKELONG(order,row)); +end; + +{$IFDEF MSWINDOWS} +function BASS_SetEAXPreset(env: Integer): BOOL; +begin + case (env) of + EAX_ENVIRONMENT_GENERIC: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_GENERIC, 0.5, 1.493, 0.5); + EAX_ENVIRONMENT_PADDEDCELL: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_PADDEDCELL, 0.25, 0.1, 0); + EAX_ENVIRONMENT_ROOM: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_ROOM, 0.417, 0.4, 0.666); + EAX_ENVIRONMENT_BATHROOM: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_BATHROOM, 0.653, 1.499, 0.166); + EAX_ENVIRONMENT_LIVINGROOM: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_LIVINGROOM, 0.208, 0.478, 0); + EAX_ENVIRONMENT_STONEROOM: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_STONEROOM, 0.5, 2.309, 0.888); + EAX_ENVIRONMENT_AUDITORIUM: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_AUDITORIUM, 0.403, 4.279, 0.5); + EAX_ENVIRONMENT_CONCERTHALL: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_CONCERTHALL, 0.5, 3.961, 0.5); + EAX_ENVIRONMENT_CAVE: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_CAVE, 0.5, 2.886, 1.304); + EAX_ENVIRONMENT_ARENA: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_ARENA, 0.361, 7.284, 0.332); + EAX_ENVIRONMENT_HANGAR: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_HANGAR, 0.5, 10.0, 0.3); + EAX_ENVIRONMENT_CARPETEDHALLWAY: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_CARPETEDHALLWAY, 0.153, 0.259, 2.0); + EAX_ENVIRONMENT_HALLWAY: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_HALLWAY, 0.361, 1.493, 0); + EAX_ENVIRONMENT_STONECORRIDOR: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_STONECORRIDOR, 0.444, 2.697, 0.638); + EAX_ENVIRONMENT_ALLEY: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_ALLEY, 0.25, 1.752, 0.776); + EAX_ENVIRONMENT_FOREST: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_FOREST, 0.111, 3.145, 0.472); + EAX_ENVIRONMENT_CITY: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_CITY, 0.111, 2.767, 0.224); + EAX_ENVIRONMENT_MOUNTAINS: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_MOUNTAINS, 0.194, 7.841, 0.472); + EAX_ENVIRONMENT_QUARRY: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_QUARRY, 1, 1.499, 0.5); + EAX_ENVIRONMENT_PLAIN: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_PLAIN, 0.097, 2.767, 0.224); + EAX_ENVIRONMENT_PARKINGLOT: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_PARKINGLOT, 0.208, 1.652, 1.5); + EAX_ENVIRONMENT_SEWERPIPE: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_SEWERPIPE, 0.652, 2.886, 0.25); + EAX_ENVIRONMENT_UNDERWATER: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_UNDERWATER, 1, 1.499, 0); + EAX_ENVIRONMENT_DRUGGED: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_DRUGGED, 0.875, 8.392, 1.388); + EAX_ENVIRONMENT_DIZZY: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_DIZZY, 0.139, 17.234, 0.666); + EAX_ENVIRONMENT_PSYCHOTIC: + Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_PSYCHOTIC, 0.486, 7.563, 0.806); + else + Result := FALSE; + end; +end; +{$ENDIF} + +end. +// END OF FILE ///////////////////////////////////////////////////////////////// + diff --git a/Game/Code/lib/bass/bass.chm b/Game/Code/lib/bass/bass.chm Binary files differnew file mode 100644 index 00000000..1e8c5076 --- /dev/null +++ b/Game/Code/lib/bass/bass.chm diff --git a/Game/Code/lib/bass/bass.dll b/Game/Code/lib/bass/bass.dll Binary files differnew file mode 100644 index 00000000..964d8996 --- /dev/null +++ b/Game/Code/lib/bass/bass.dll diff --git a/Game/Code/lib/bass/bass.txt b/Game/Code/lib/bass/bass.txt new file mode 100644 index 00000000..c60b6594 --- /dev/null +++ b/Game/Code/lib/bass/bass.txt @@ -0,0 +1,1546 @@ +BASS 2.3 - Copyright (c) 1999-2007 Ian Luck. All rights reserved.
+
+Files that you should have found in the BASS "package"
+======================================================
+Win32 version
+-------------
+BASS.TXT This file
+BASS.DLL The BASS module
+BASS.CHM BASS documentation
+MP3-FREE
+ BASS.DLL BASS module using the Windows MP3 decoder
+C\ C/C++ API and samples...
+ BASS.H BASS C/C++ header file
+ BASS.LIB BASS import library
+ BASS.DSW Visual C++ workspace for examples
+ MAKEFILE Makefile for all examples
+ MAKEFILE.IN Makefile helper macros
+ 3DTEST\ 3D/EAX example
+ 3DTEST.C
+ 3DTEST.RC
+ 3DTEST.DSP
+ MAKEFILE
+ BASSTEST\ Simple playback example
+ BASSTEST.C
+ BASSTEST.RC
+ BASSTEST.H
+ BASSTEST.DSP
+ MAKEFILE
+ CONTEST\ Console example
+ CONTEST.C
+ CONTEST.DSP
+ MAKEFILE
+ CUSTLOOP\ Custom looping example
+ CUSTLOOP.C
+ CUSTLOOP.DSP
+ MAKEFILE
+ DSPTEST\ DSP example
+ DSPTEST.C
+ DSPTEST.RC
+ DSPTEST.DSP
+ MAKEFILE
+ FXTEST\ DX8 effect example
+ FXTEST.C
+ FXTEST.RC
+ FXTEST.DSP
+ MAKEFILE
+ LIVEFX\ Full-duplex example
+ LIVEFX.C
+ LIVEFX.RC
+ LIVEFX.DSP
+ MAKEFILE
+ LIVESPEC\ "Live" version of spectrum analyser example
+ LIVESPEC.C
+ LIVESPEC.DSP
+ MAKEFILE
+ LOADNGET\ LoadLibrary/GetProcAddress example
+ LOADNGET.C
+ LOADNGET.RC
+ LOADNGET.DSP
+ MAKEFILE
+ MULTI\ Multiple device example
+ MULTI.C
+ MULTI.RC
+ MULTI.DSP
+ MAKEFILE
+ NETRADIO\ Internet streaming example
+ NETRADIO.C
+ NETRADIO.RC
+ NETRADIO.DSP
+ MAKEFILE
+ PLUGINS\ Plugins example
+ PLUGINS.C
+ PLUGINS.RC
+ PLUGINS.DSP
+ MAKEFILE
+ RECTEST\ Recording example
+ RECTEST.C
+ RECTEST.RC
+ RECTEST.DSP
+ MAKEFILE
+ SPEAKERS\ Multi-speaker example
+ SPEAKERS.C
+ SPEAKERS.RC
+ SPEAKERS.DSP
+ MAKEFILE
+ SPECTRUM\ Spectrum analyser example
+ SPECTRUM.C
+ SPECTRUM.DSP
+ MAKEFILE
+ SYNTH\ Synth example
+ SYNTH.C
+ SYNTH.DSP
+ MAKEFILE
+ WRITEWAV\ WAVE writer example
+ WRITEWAV.C
+ WRITEWAV.DSP
+ MAKEFILE
+ BIN\ Precompiled examples
+ 3DTEST.EXE
+ BASSTEST.EXE
+ CONTEST.EXE
+ CUSTLOOP.EXE
+ DSPTEST.EXE
+ FXTEST.EXE
+ LIVEFX.EXE
+ LIVESPEC.EXE
+ LOADNGET.EXE
+ MULTI.EXE
+ NETRADIO.EXE
+ RECTEST.EXE
+ SPEAKERS.EXE
+ SPECTRUM.EXE
+ SYNTH.EXE
+ WRITEWAV.EXE
+VB\ Visual Basic API and samples...
+ BASS.BAS BASS Visual Basic module file
+ 3DTEST\ 3D/EAX example
+ PRJ3DTEST.VBP
+ PRJ3DTEST.FRM
+ PRJDEVICE.FRM
+ BASSTEST\ Simple playback example
+ PRJBASSTEST.VBP
+ FRMBASSTEST.FRM
+ CUSTLOOP\ Custom looping example
+ PRJCUSTLOOP.VBP
+ FRMCUSTLOOP.FRM
+ MODCUSTLOOP.BAS
+ DSPTEST\ DSP example
+ PRJDSPTEST.VBP
+ FRMDSPTEST.FRM
+ MODDSPTEST.BAS
+ FXTEST\ DX8 effect example
+ PRJFXTEST.VBP
+ FRMFXTEST.FRM
+ LIVEFX\ Full-duplex example
+ PRJLIVEFX.VBP
+ FRMLIVEFX.FRM
+ MODLIVEFX.BAS
+ LIVESPEC\ "Live" version of spectrum analyser example
+ PRJLIVESPEC.VBP
+ FRMLIVESPEC.FRM
+ MODLIVESPEC.BAS
+ MULTI\ Multiple device example
+ PRJMULTI.VBP
+ PRJMULTI.FRM
+ PRJDEVICE.FRM
+ NETRADIO\ Internet streaming example
+ PRJNETRADIO.VBP
+ FRMNETRADIO.FRM
+ MODNETRADIO.BAS
+ CLSFILEIO.CLS
+ PLUGINS\ Plugins example
+ PRJPLUGINS.VBP
+ FRMPLUGINS.FRM
+ RECTEST\ Recording example
+ PRJRECTEST.VBP
+ FRMRECTEST.FRM
+ MODRECTEST.BAS
+ SPEAKERS\ Multi-speaker example
+ PRJSPEAKERS.VBP
+ FRMSPEAKERS.FRM
+ SPECTRUM\ Spectrum analyser example
+ PRJSPECTRUM.VBP
+ FRMSPECTRUM.FRM
+ MODSPECTRUM.BAS
+ SYNTH\ Synth example
+ PRJSYNTH.VBP
+ FRMSYNTH.FRM
+ MODSYNTH.BAS
+ WRITEWAV\ WAVE writer example
+ PRJWRITEWAVE.VBP
+ PRJWRITEWAVE.FRM
+ MEMORY\ Playing from memory example by Jobnik
+ PRJMEMORY.VBP
+ FRMMEMORY.FRM
+ SYNCTEST.BAS
+ CBASS_TIME.CLS
+DELPHI\ Delphi API and samples...
+ BASS.PAS BASS Delphi unit
+ 3DTEST\ 3D/EAX example
+ D3TEST.DPR
+ DTMAIN.PAS
+ DTMAIN.DFM
+ DTSELECT.PAS
+ DTSELECT.DFM
+ BASSTEST\ Simple playback example
+ BASSTEST.DPR
+ BTMAIN.PAS
+ BTMAIN.DFM
+ CONTEST\ Console example
+ CONTEST.DPR
+ CUSTLOOP\ Custom looping example
+ CUSTLOOP.DPR
+ UNIT1.PAS
+ UNIT1.DFM
+ DSPTEST\ DSP example
+ DSPTEST.DPR
+ DTMAIN.PAS
+ DTMAIN.DFM
+ FXTEST\ DX8 effect example
+ FXTEST.DPR
+ TEST.PAS
+ TEST.DFM
+ LIVEFX\ Full-duplex example
+ LIVEFX.DPR
+ UNIT1.PAS
+ UNIT1.DFM
+ MULTI\ Multiple device example
+ MULTI.DPR
+ UNIT1.PAS
+ UNIT1.DFM
+ UNIT2.PAS
+ UNIT2.DFM
+ NETRADIO\ Internet streaming example
+ NETRADIO.DPR
+ UNIT1.PAS
+ UNIT1.DFM
+ PLUGINS\ Plugins example
+ PLUGINS.DPR
+ UNIT1.PAS
+ UNIT1.DFM
+ RECORDTEST\ Recording example
+ RECORDTEST.DPR
+ UNIT1.PAS
+ UNIT1.DFM
+ SAMPLEVIS\ Visualisation example
+ SAMPLEVIS.DPR
+ MAIN.PAS
+ MAIN.DFM
+ SPECTRUM_VIS.PAS
+ CIRCLE_VIS.PAS
+ OSC_VIS.PAS
+ COMMONTYPES.PAS
+ SPEAKERS\ Multi-speaker example
+ SPEAKERS.DPR
+ UNIT1.PAS
+ UNIT1.DFM
+ STREAMTEST\ User stream example
+ STREAMTEST.DPR
+ STMAIN.PAS
+ STMAIN.DFM
+ WRITEWAV\ WAVE writer example
+ WRITEWAV.DPR
+ UNITMAIN.PAS
+ UNITMAIN.DFM
+ DYNAMIC\ Dynamic-loading Delphi API
+ DYNAMIC_BASS.PAS Dynamic-loading Delphi unit
+MASM\ MASM API and samples...
+ BASS.INC BASS MASM include file
+ PLAYER\ Example MOD player
+ PLAYER.EXE
+ PLAYER.ASM
+ RSRC.RC
+ TOOLBAR.BMP
+ COMPILE.BAT
+
+NOTE: To run the sample EXEs, first you'll have to copy BASS.DLL into the
+ same directory as the EXEs.
+
+NOTE: To avoid unnecessary bloatage, the BASS DLLs are not digitally signed.
+ Signed versions are available on request (email: bass@un4seen.com).
+
+MacOSX version
+--------------
+BASS.TXT This file
+LIBBASS.DYLIB The BASS module
+BASS.CHM BASS documentation
+CHMOX.APP CHM file viewer
+BASS.H BASS C/C++ header file
+MAKEFILE Makefile for all examples
+MAKEFILE.IN Makefile helper macros
+MP3-FREE
+ LIBBASS.DYLIB BASS module using the OSX MP3 decoder
+3DTEST\ 3D example
+ 3DTEST.C
+ MAKEFILE
+ 3DTEST.NIB
+BASSTEST\ Simple playback example
+ BASSTEST.C
+ MAKEFILE
+ BASSTEST.NIB
+CONTEST\ Console example
+ CONTEST.C
+ MAKEFILE
+CUSTLOOP\ Custom looping example
+ CUSTLOOP.C
+ MAKEFILE
+DSPTEST\ DSP example
+ DSPTEST.C
+ DSPTEST.RC
+ MAKEFILE
+ DSPTEST.NIB
+LIVESPEC\ "Live" version of spectrum analyser example
+ LIVESPEC.C
+ MAKEFILE
+MULTI\ Multiple device example
+ MULTI.C
+ MAKEFILE
+ MULTI.NIB
+NETRADIO\ Internet streaming example
+ NETRADIO.C
+ MAKEFILE
+ NETRADIO.NIB
+PLUGINS\ Plugins example
+ PLUGINS.C
+ MAKEFILE
+ PLUGINS.NIB
+RECTEST\ Recording example
+ RECTEST.C
+ MAKEFILE
+ RECTEST.NIB
+SPEAKERS\ Multi-speaker example
+ SPEAKERS.C
+ MAKEFILE
+ SPEAKERS.NIB
+SPECTRUM\ Spectrum analyser example
+ SPECTRUM.C
+ MAKEFILE
+WRITEWAV\ WAVE writer example
+ WRITEWAV.C
+ MAKEFILE
+
+
+What's the point?
+=================
+BASS is an audio library for use in Windows and MacOSX software. Its
+purpose is to provide the most powerful and efficient (yet easy to use),
+sample, stream, MOD music, and recording functions. All in a tiny DLL,
+under 100KB in size.
+
+See the documentation for descriptions of all the BASS functions. You
+should also look at the included example program source-codes for some
+examples of how to use BASS in your own programs.
+
+
+Requirements
+============
+Win32 version
+-------------
+BASS requires DirectX 3 or above for output. BASS does not require that a
+soundcard with DirectSound/DirectSound3D hardware accelerated drivers is
+installed, but it does improve performance if there is one. BASS also takes
+advantage of MMX, which improves the performance of the MOD music playback.
+
+MacOSX version
+--------------
+OSX 10.3 or above is recommended. BASS uses CoreAudio for output, so there
+are no special library/driver requirements. BASS supports both PowerPC and
+Intel Macs.
+
+
+Main Features
+=============
+* Samples
+- supports WAV/AIFF/MP3/MP2/MP1/OGG and custom generated samples
+
+* Sample streams
+- stream any sample data in 8/16/32 bit
+
+* File streams
+- MP3/MP2/MP1/OGG/WAV/AIFF file streaming
+
+* Internet file streaming
+- stream MP3/MP2/MP1/OGG/WAV/AIFF files from the internet (inc. Shout/Icecast)
+
+* User file streaming
+- stream MP3/MP2/MP1/OGG/WAV/AIFF files from anywhere using any delivery method
+
+* Multi-channel streaming
+- support for more than plain stereo, including multi-channel OGG/WAV/AIFF files
+
+* MOD music
+- uses the same engine as XMPlay = best accuracy, speed and quality
+
+* MO3 music
+- MP3/OGG compressed MOD music
+
+* Add-on system
+- support for more formats is available via add-ons (aka plugins)
+
+* Multiple outputs
+- simultaneously use multiple soundcards, and move channels between them
+
+* Recording
+- flexible recording system, with support for multiple devices
+
+* Decode without playback
+- streams and musics can be outputted in any way you want
+
+* Speaker assignment
+- assign streams and musics to specific speakers
+
+* High precision synchronization
+- synchronize events in your software to the music
+
+* DirectX 8 effects
+- chorus/compressor/distortion/echo/flanger/gargle/parameq/reverb
+
+* User defined DSP functions
+- custom effects may be applied to musics and streams
+
+* 32 bit floating-point decoding and processing
+- floating-point stream/music decoding, DSP, FX, and recording
+
+* 3D sound
+- play samples/streams/musics in any 3D position, with EAX support
+
+* Expandable
+- underlying DirectSound object interfaces are accessible
+
+* Small
+- BASS is under 100KB (on Windows), so won't bloat your distribution
+
+
+Using BASS
+==========
+There is no guarantee that all future BASS versions will be compatible
+with all previous versions, so your program should use BASS_GetVersion
+to check the version that is loaded. This also means that you should
+put the BASS module in the same directory as your executable (not just
+somewhere in the path), to avoid the possibility of a wrong version being
+loaded.
+
+If you are updating your software from a previous BASS version, then
+you should check the "History" section (below), to see if any of the
+functions that you are using have been affected by a change.
+
+Win32 version
+-------------
+C/C++, Visual Basic, Delphi and MASM APIs are provided, to use BASS with
+another language you'll first have to convert the header file. Or, as a
+last resort, you could use LoadLibrary and GetProcAddress.
+
+One benefit of the LoadLibrary method is that it allows you to look for
+the correct BASS version, because you can load and unload BASS.DLL at
+any time. This also allows those who'd prefer not to have a separate
+DLL to store it with the program (eg. in a resource), write it to disk,
+load it, use it, free it and delete it.
+
+The downside is that you have to manually import each function that you
+use, with the GetProcAddress function. But it has been made a lot simpler
+to import BASS this way by the use of the BASSDEF #define. Here's a small
+example:
+
+#define BASSDEF(f) (WINAPI *f) // define the functions as pointers
+#include "bass.h"
+...
+HINSTANCE bass=LoadLibrary("BASS.DLL"); // load BASS
+BASS_Init=GetProcAddress(bass,"BASS_Init"); // get BASS_Init
+BASS_Init(-1,44100,0,hWnd,NULL); // call BASS_Init
+
+See the LOADNGET.C file for a more complete example.
+
+To use BASS with Borland C++ Builder, you'll first have to create a
+Borland C++ Builder import library for it. This is done by using the
+IMPLIB tool that comes with Borland C++ Builder. Simply execute this:
+
+ IMPLIB BASSBCB.LIB BASS.DLL
+
+... and then use BASSBCB.LIB in your projects to import BASS.
+
+To use BASS with LCC-Win32, you'll first have to create a compatible
+import library for it. This is done by using the PEDUMP and BUILDLIB
+tools that come with LCC-Win32. Run these 2 commands:
+
+ PEDUMP /EXP BASS.LIB > BASSLCC.EXP
+ BUILDLIB BASSLCC.EXP BASSLCC.LIB
+
+... and then use BASSLCC.LIB in your projects to import BASS.
+
+For the BASS functions that return strings (char*), VB users should use
+the VBStrFromAnsiPtr function to convert the returned pointer into a VB
+string.
+
+MacOSX version
+--------------
+A separate "LIB" file is not required for OSX. Using XCode, you can simply
+add the DYLIB file to the project. Or using a makefile, you can build your
+programs like this, for example:
+
+ gcc yoursource -L. -lbass -o yourprog
+
+The LIBBASS.DYLIB file must be put in the same directory as the executable
+(it can't just be somewhere in the path). See the example makefiles.
+
+LIBBASS.DYLIB is a universal binary, with support for both PowerPC and
+Intel Macs. If you want PowerPC-only or Intel-only versions, the included
+makefile can create them for you, by typing "make ppc" or "make i386". It
+will also process any BASS add-ons placed in the same directory.
+
+
+Latest Version
+==============
+The latest version of BASS can always be found at the BASS website:
+
+ www.un4seen.com
+
+
+Copyright, disclaimer, and all that other jazz
+==============================================
+The BASS library is free for non-commercial use. If you are a non-
+commercial entity (eg. an individual) and are not charging for your
+product, and the product has no other commercial purpose, then you
+can use BASS in it for free. If you wish to use BASS in commercial
+products, then please also see the next section.
+
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, BASS IS PROVIDED
+"AS IS", WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND/OR FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS SHALL NOT BE HELD
+LIABLE FOR ANY DAMAGE THAT MAY RESULT FROM THE USE OF BASS. BASICALLY,
+YOU USE BASS ENTIRELY AT YOUR OWN RISK.
+
+Usage of BASS indicates that you agree to the above conditions.
+
+All trademarks and other registered names contained in the BASS
+package are the property of their respective owners.
+
+
+BASS in commercial products?
+============================
+BASS is available for use in your commercial products. The licence
+types available are as follows:
+
+SHAREWARE: Allows the usage of BASS in an unlimited number of your
+shareware products, which must sell for no more than 40 Euros each.
+If you're an individual making and selling your own software (and
+its price is within the limit), this is the licence for you.
+
+SINGLE COMMERCIAL: Allows the usage of BASS in a single commercial
+product.
+
+UNLIMITED COMMERCIAL: Allows the usage of BASS in an unlimited number
+of your commercial products. This licence is on a per site basis. So
+if your company has two sites that use BASS, then two licences are
+required.
+
+Please note the products must be end-user products, eg. not components
+used by other products.
+
+These licences only cover your own software. not the publishing of
+other's software. If you publish other's software, its developers (or
+the software itself) will need to be licensed to use BASS.
+
+These licences are on a per-platform basis, with reductions available
+when licensing for both platforms. In all cases there are no royalties
+to pay, and you can use future BASS updates without further cost. One
+licence covers one person or entity and is not transferable.
+
+These licences do not allow reselling/sublicensing of BASS. For example,
+if a product is a development system, the users of said product are not
+licensed to use BASS in their productions - they will need their own
+licences.
+
+If the standard licences do not meet your requirements, or if you have
+any questions, please get in touch (email: bass@un4seen.com).
+
+Visit the BASS website for the latest pricing:
+
+ www.un4seen.com
+
+
+MP3
+===
+MP3 technology is patented, and Thomson license the use of their and
+Fraunhofer's patents. The inclusion of an MP3 decoder (eg. BASS) in a
+commercial product requires an MP3 patent licence. Contact Thomson for
+details:
+
+ www.mp3licensing.com
+
+Alternatively, the "MP3-FREE" BASS version doesn't include its own MP3
+decoder but instead makes use of the operating system's already licensed
+decoder.
+
+NOTE: When using the OS's MP3 decoder, BASS still does the file handling
+ so all the usual features are still supported, including streaming,
+ tag reading, pre-scanning, gapless playback, etc...
+
+
+History
+=======
+These are the major (and not so major) changes at each version stage.
+There are of course bug fixes and other little improvements made along
+the way too! To make upgrading simpler, all functions affected by a
+change to the BASS interface are listed.
+
+2.3.0.3 - 30/7/2007
+-------------------
+* FX state resetting
+ BASS_FXReset
+* PLS/M3U playlist URL processing
+ BASS_CONFIG_NET_PLAYLIST
+ NETRADIO example updated
+* Internet stream connection status retrieval
+ BASS_FILEPOS_CONNECTED (BASS_StreamGetFilePosition mode)
+* Lyrics3v2 tags
+ BASS_TAG_LYRICS3 (BASS_ChannelGetTags type)
+* IT virtual channel configuration
+ BASS_CONFIG_MUSIC_VIRTUAL
+* Accurate speaker detection on Vista
+ BASS_INFO (speakers member)
+* Device output/input rate retrieval on Vista
+ BASS_INFO (freq member)
+ BASS_RECORDINFO (freq member)
+* Syncing upon position changes
+ BASS_SYNC_SETPOS (BASS_ChannelSetSync type)
+* Improved stall handling
+ BASS_SYNC_STALL
+* Invalid decoding channel flags produce an error instead of being ignored
+ BASS_StreamCreate/File/User/Url
+ BASS_MusicLoad
+
+2.3.0.2 - 22/1/2007
+-------------------
+* Retrieval of a sample's existing channel handles
+ BASS_SampleGetChannels
+* 8192 sample FFT
+ BASS_DATA_FFT8192 (BASS_ChannelGetData flag)
+* Adjustable recording buffer
+ BASS_CONFIG_REC_BUFFER (BASS_SetConfig option)
+* Stopping decoding channels before the end
+ BASS_ChannelStop
+* Sample channels created paused to prevent overriding before playback
+ BASS_SampleGetChannel
+* Separate "MP3-FREE" version using Windows/OSX MP3 decoder
+ BASS_CONFIG_MP3_CODEC *removed*
+
+2.3.0.1 - 12/6/2006
+-------------------
+* Ability to move a channel to another device
+ BASS_ChannelSetDevice
+ MULTI example updated
+* Support for ID3v2.4 tags at end of file
+ BASS_TAG_ID3V2 (BASS_ChannelGetTags type)
+
+2.3 - 21/5/2006
+---------------
+* MOD message/instrument/sample text retrieval, merged with stream tag retrieval function
+ BASS_ChannelGetTags
+ BASS_TAG_MUSIC_NAME/MESSAGE/INST/SAMPLE (BASS_ChannelGetTags types)
+ BASS_MusicGetName *removed*
+ BASS_StreamGetTags *removed*
+* Plugin information retrieval
+ BASS_PluginGetInfo
+ BASS_PLUGININFO/FORM structures
+ BASS_CHANNELINFO (plugin member)
+ PLUGINS example updated
+* RIFF/WAVE "INFO" tag retrieval
+ BASS_TAG_RIFF_INFO (BASS_StreamGetTags type)
+* More specific WAVE format information
+ BASS_CTYPE_STREAM_WAV_PCM/FLOAT (channel types)
+ BASS_CTYPE_STREAM_WAV (channel type flag)
+* Proxy server configuration
+ BASS_CONFIG_NET_PROXY (BASS_SetConfig option)
+ BASS_CONFIG_NET_NOPROXY *removed*
+ NETRADIO example updated
+* Passive FTP mode
+ BASS_CONFIG_NET_PASSIVE (BASS_SetConfig option)
+* Agent changes take immediate effect
+ BASS_CONFIG_NET_AGENT (BASS_SetConfig option)
+* Minimum time gap between creating new sample channels
+ BASS_SAMPLE (mingap member)
+ BASS_SampleGetChannel
+* Support for Unicode plugin filenames
+ BASS_PluginLoad
+* Device output/input rate retrieval (MacOSX only)
+ BASS_INFO (freq member)
+ BASS_RECORDINFO (freq member)
+* Extended version info (minor revision)
+ BASS_GetVersion
+* Unsupported codec error code
+ BASS_ERROR_CODEC
+* Optional use of the Windows MP3 codec
+ BASS_CONFIG_MP3_CODEC (BASS_SetConfig option)
+* 3D support for MacOSX
+ BASS_Set3DFactors
+ BASS_Get3DFactors
+ BASS_Set3DPosition
+ BASS_Get3DPosition
+ BASS_Apply3D
+ BASS_ChannelSet3DAttributes
+ BASS_ChannelGet3DAttributes
+ BASS_ChannelSet3DPosition
+ BASS_ChannelGet3DPosition
+ 3DTEST example added (Win32 example also updated)
+* VB version of SYNTH example added
+
+2.2 - 2/10/2005
+---------------
+* Add-on plugin system
+ BASS_PluginLoad
+ BASS_PluginFree
+ BASS_StreamCreateFile/User/Url
+ BASS_SampleLoad
+ PLUGINS example added
+* MOD position & syncing in bytes
+ BASS_ChannelSetPosition
+ BASS_ChannelGetPosition
+ BASS_MusicGetOrderPosition added for orders position
+ BASS_SYNC_MUSICPOS added for orders syncing
+ MAKEMUSICPOS macro/define
+ CUSTLOOP example updated
+* Stream/MOD "length" functions combined (also works with samples), new MOD orders length function
+ BASS_ChannelGetLength
+ BASS_MusicGetOrders
+ BASS_StreamGetLength *removed*
+ BASS_MusicGetLength *removed*
+* Support for AIFF files
+ BASS_StreamCreateFile/User/Url
+ BASS_SampleLoad
+* Support for 24 and 32-bit (integer) WAV files
+ BASS_StreamCreateFile/User/Url
+ BASS_SampleLoad
+* WAV files are no longer converted to the "device" resolution
+ BASS_StreamCreateFile/User/Url
+* Recording master control
+ BASS_RecordGetInput
+ BASS_RecordSetInput
+* Adjustable prebuffering
+ BASS_ChannelPreBuf
+* Floating-point data retrieval
+ BASS_DATA_FLOAT (BASS_ChannelGetData flag)
+* Support for floating-point samples
+ BASS_SampleLoad
+ BASS_SampleCreate
+* Multi-channel samples
+ BASS_SampleLoad/Create
+ BASS_SAMPLE (chans member)
+* Sample lengths given in bytes
+ BASS_SampleCreate
+ BASS_SAMPLE (length member)
+* MOD music 8-bit resolution option
+ BASS_MusicLoad
+* OGG vendor tag retrieval
+ BASS_TAG_VENDOR (BASS_StreamGetTags type)
+* Configurable "User-Agent" header for internet streams
+ BASS_CONFIG_NET_AGENT (BASS_SetConfig option)
+* Shoutcast metadata is now requested automatically
+ BASS_STREAM_META flag *removed*
+* Download callbacks receive all data from start of file/stream (including any non-audio data)
+ DOWNLOADPROC
+* Length when streaming in blocks is unavailable (BASS_ERROR_NOTAVAIL, not just 0)
+ BASS_ChannelGetLength
+* Support for growing custom file streams
+ BASS_FILE_LEN (STREAMFILEPROC action)
+* Query file action removed
+ BASS_FILE_QUERY *removed*
+* Recording channel syncing
+ BASS_ChannelSetSync
+* Info structure "size" members removed
+ BASS_INFO structure
+ BASS_RECORDINFO structure
+* Little bit of flag reshuffling
+ BASS_MP3_SETPOS renamed to BASS_STREAM_PRESCAN
+ BASS_MUSIC_CALCLEN value changed and renamed to BASS_MUSIC_PRESCAN
+ BASS_MUSIC_POSRESET value changed
+* Add-on API enhancements
+* MacOSX port introduced
+
+2.1 - 28/11/2004
+----------------
+* Improved "mixtime" sync system, allowing custom looping
+ SYNCPROC
+ CUSTLOOP example added
+* FX can now be in the DSP chain, so can be prioritized and applied in floating-point
+ BASS_ChannelSetFX
+ BASS_CONFIG_FLOATDSP (BASS_SetConfig option)
+* Ability to set channel flags (eg. looping) independent of playback
+ BASS_ChannelSetFlags
+ SPEAKERS example updated
+* Stream/MOD "play" and channel "resume" functions combined
+ BASS_ChannelPlay
+ BASS_StreamPlay *removed*
+ BASS_MusicPlay *removed*
+ BASS_MusicPlayEx *removed*
+ BASS_ChannelResume *removed*
+* Stream/MOD prebuffering functions combined
+ BASS_ChannelPreBuf
+ BASS_StreamPreBuf *removed*
+ BASS_MusicPreBuf *removed*
+* MOD attribute functions combined, with added BPM/speed/globalvolume options
+ BASS_MusicSetAttribute
+ BASS_MusicGetAttribute
+ BASS_MUSIC_ATTRIB_AMPLIFY
+ BASS_MUSIC_ATTRIB_PANSEP
+ BASS_MUSIC_ATTRIB_PSCALER
+ BASS_MUSIC_ATTRIB_BPM
+ BASS_MUSIC_ATTRIB_SPEED
+ BASS_MUSIC_ATTRIB_VOL_GLOBAL
+ BASS_MUSIC_ATTRIB_VOL_CHAN
+ BASS_MUSIC_ATTRIB_VOL_INST
+ BASS_MusicSetAmplify *removed*
+ BASS_MusicSetPanSep *removed*
+ BASS_MusicSetPositionScaler *removed*
+ BASS_MusicSetVolume *removed*
+ BASS_MusicGetVolume *removed*
+* Flag to reset bpm/etc as well as notes when seeking in MOD musics
+ BASS_MUSIC_POSRESETEX (BASS_MusicLoad & BASS_ChannelSetFlags flag)
+* More flexible and concise sample channel creation system
+ BASS_SampleGetChannel
+ BASS_SamplePlay *removed*
+ BASS_SamplePlayEx *removed*
+ BASS_SamplePlay3D *removed*
+ BASS_SamplePlay3DEx *removed*
+* Support for up to 30 speakers
+ BASS_SPEAKER_N macro/define
+* More precise level measurement
+ BASS_ChannelGetLevel
+* Level can now be retrieved from decoding channels
+ BASS_ChannelGetLevel
+* Retrieval of a sample/channel's original sample resolution
+ BASS_SAMPLE (origres member)
+ BASS_CHANNELINFO (origres member)
+* Support for streaming WAV files in "blocks"
+ BASS_StreamCreateURL
+ BASS_StreamCreateFileUser
+* Status info (HTTP/ICY tags) available during connection to server
+ BASS_STREAM_STATUS (BASS_StreamCreateURL flag)
+ DOWNLOADPROC
+ NETRADIO example updated (Delphi version also added)
+* Adjustable internet stream prebuffering
+ BASS_CONFIG_NET_PREBUF (BASS_SetConfig option)
+* Option to bypass proxy server
+ BASS_CONFIG_NET_NOPROXY (BASS_SetConfig option)
+* Option whether to allow channels to be played after BASS_Pause
+ BASS_CONFIG_PAUSE_NOPLAY (BASS_SetConfig option)
+* Recording channel count now a separate parameter
+ BASS_RecordStart (chans parameter)
+* Synchronizer for when a channel is freed
+ BASS_SYNC_FREE (BASS_ChannelSetSync type)
+* Data start file position retrieval
+ BASS_FILEPOS_START (BASS_StreamGetFilePosition mode)
+* Performance improvements
+ MP2 decoding ~20% faster
+ MP3/MP1 decoding & FFT processing all up to 10% faster
+ OGG decoding ~3% faster
+* C/C++ examples reorganised, with makefiles & VC++ projects
+* Add-on API enhancements
+* More DLL shrinkage :)
+
+2.0 - 31/10/2003
+----------------
+* Multiple output device support
+ BASS_Init (device number changes)
+ BASS_SetDevice
+ BASS_GetDevice
+ BASS_ChannelGetDevice
+ MULTI example updated (VB version also added)
+* Multiple recording device support
+ BASS_RecordSetDevice
+ BASS_RecordGetDevice
+ BASS_RecordStart
+ BASS_ChannelGetDevice
+ HRECORD handle
+ RECORDPROC (handle parameter)
+* Recording with DSP/FX
+ BASS_ChannelSetDSP
+ BASS_ChannelSetFX
+* Recording position retrieval
+ BASS_ChannelGetPosition
+* Start recording paused
+ BASS_RECORD_PAUSE (BASS_RecordStart flag)
+* Multi-channel streams, inc. support for multichannel OGG & WAV files
+ BASS_StreamCreate
+ BASS_StreamCreateFile/User/Url
+* FFT for individual channels, inc. multi-channel streams
+ BASS_DATA_FFT_INDIVIDUAL (BASS_ChannelGetData flag)
+ BASS_DATA_FFT512S/1024S/2048S/4096S *removed*
+* DSP prioritizing
+ BASS_ChannelSetDSP
+ DSPTEST example updated
+* Seeking in internet streamed files
+ BASS_ChannelSetPosition
+* Enhanced custom file stream systems
+ BASS_StreamCreateFileUser
+ BASS_FILE_SEEK (STREAMFILEPROC action)
+ BASS_STREAM_FILEPROC flag *removed*
+* Enhanced custom stream system with automatic stalling/resuming
+ STREAMPROC
+ BASS_STREAMPROC_END (STREAMPROC flag)
+* Synchronizer for stalled/resumed playback
+ BASS_SYNC_STALL (BASS_ChannelSetSync type)
+* Synchronizer for completed download
+ BASS_SYNC_DOWNLOAD (BASS_ChannelSetSync type)
+* End sync support for custom streams
+ BASS_SYNC_END (BASS_ChannelSetSync type)
+* Synchronizer support for decoding channels
+ BASS_ChannelSetSync
+* Unified configuration function
+ BASS_SetConfig
+ BASS_GetConfig
+ BASS_SetBufferLength *removed*
+ BASS_SetNetConfig *removed*
+ BASS_SetGlobalVolumes *removed*
+ BASS_GetGlobalVolumes *removed*
+ BASS_SetLogCurves *removed*
+ BASS_Set3DAlgorithm *removed*
+ BASS_DEVICE_FLOATDSP flag *removed*
+* Internet stream saving to disk replaced by more flexible callback
+ BASS_StreamCreateURL
+ DOWNLOADPROC
+ VB NETRADIO example updated
+* Buffer length retrieval when "streaming in blocks"
+ BASS_FILEPOS_END (BASS_StreamGetFilePosition mode)
+* Individual sample rate setting for MOD musics
+ BASS_MusicLoad
+* Channel type and default sample rate retrieval
+ BASS_ChannelGetInfo (replaces BASS_ChannelGetFlags)
+ BASS_CHANNELINFO
+* MOD music flag retrieval
+ BASS_CHANNELINFO (flags member)
+* Adjustable instrument volumes in MOD musics
+ BASS_MusicSetVolume (replaces BASS_MusicSetChannelVol)
+ BASS_MusicGetVolume (replaces BASS_MusicGetChannelVol)
+* Automatically free a MOD music when it stops or ends
+ BASS_MUSIC_AUTOFREE (BASS_MusicLoad flag)
+* Class GUID added to initialization parameters
+ BASS_Init
+ BASS_SetCLSID *removed*
+* Update period adjustable at any time
+ BASS_CONFIG_UPDATEPERIOD (BASS_SetConfig option)
+ BASS_DEVICE_NOTHREAD flag *removed*
+* Customizable maximum volume setting
+ BASS_CONFIG_MAXVOL (BASS_SetConfig option)
+ BASS_DEVICE_VOL1000 flag *removed*
+* Device volume is now always left as it is during init/freeing
+ BASS_DEVICE_LEAVEVOL flag *removed*
+* Device driver name retrieval
+ BASS_INFO (driver member)
+ BASS_RECORDINFO (driver member)
+* Error codes are local to the current thread
+ BASS_ErrorGetCode
+* Performance improvements
+ MP2 decoding 15-20% faster
+ MP3 decoding ~5% faster
+* Built-in CD functions removed (replaced in BASSCD)
+ BASS_CDDoor *removed*
+ BASS_CDFree *removed*
+ BASS_CDGetID *removed*
+ BASS_CDGetTrackLength *removed*
+ BASS_CDGetTracks *removed*
+ BASS_CDInDrive *removed*
+ BASS_CDInit *removed*
+ BASS_CDPlay *removed*
+* Force channels to use software mixing
+ BASS_SAMPLE_SOFTWARE (BASS_StreamCreate/File/User/URL & BASS_MusicLoad flag)
+* Support for high-pass filter and forward/reverse (S9E/F) IT/MPT effects
+* BASS_MUSIC flags rearranged to mirror BASS_SAMPLE/STREAM counterparts
+* Output automatically started during initialization
+* BASS_ChannelGetData once again accepts any "length" param
+* All function comments have been removed from the API headers to avoid
+ outdated/incorrect information - the BASS.CHM documentation should be used.
+* TMT Pascal API removed from main distribution - now available on the website
+* A few more 'K' knocked off the DLL size :)
+
+1.8a - 18/6/2003
+----------------
+* Tweaks 'n' fixes, including...
+ Fixed seeking bug on 32-bit OGG streams
+ Fixed seeking on a decoding channel after it has reached the end
+ Low FPU precision (eg. when using Direct3D) issue addressed
+ Improved speakers (BASS_INFO) detection
+ BASS_ChannelSeconds2Bytes return value is rounded down to nearest sample
+ BASS_ChannelGetData "length" param must equal a whole number of samples
+ Slide syncs are triggered by "-2" volume slides on "autofree" streams
+* Support for UNICODE filenames
+ BASS_UNICODE (BASS_SampleLoad/BASS_StreamCreateFile/BASS_MusicLoad flag)
+* 4096 sample FFT
+ BASS_DATA_FFT4096/S (BASS_ChannelGetData flags)
+* Another 'K' knocked off the DLL size
+
+1.8 - 9/3/2003
+--------------
+* 32-bit floating-point channels
+ BASS_SAMPLE_FLOAT (BASS_StreamCreate/URL/File flag)
+ BASS_MUSIC_FLOAT (BASS_MusicLoad flag)
+ BASS_SAMPLE_FLOAT (BASS_RecordStart flag)
+ BASS_DEVICE_FLOATDSP (BASS_Init flag)
+ DSPTEST example updated
+* Support for 32-bit floating-point (type 3) WAV files
+ BASS_StreamCreateFile/URL
+ BASS_SampleLoad
+* Channel speaker assignment
+ BASS_SPEAKER_FRONT (BASS_MusicLoad/BASS_StreamCreate/File/URL flag)
+ BASS_SPEAKER_REAR "
+ BASS_SPEAKER_CENLFE "
+ BASS_SPEAKER_REAR2 "
+ BASS_SPEAKER_FRONTLEFT "
+ BASS_SPEAKER_FRONTRIGHT "
+ BASS_SPEAKER_REARLEFT "
+ BASS_SPEAKER_REARRIGHT "
+ BASS_SPEAKER_CENTER "
+ BASS_SPEAKER_LFE "
+ BASS_SPEAKER_REAR2LEFT "
+ BASS_SPEAKER_REAR2RIGHT "
+ BASS_INFO (speakers member)
+ BASS_DEVICE_SPEAKERS (BASS_Init flag)
+ 4SPEAKER example replaced by SPEAKERS example
+* Recording input type retrieval
+ BASS_INPUT_TYPE_xxx (BASS_RecordGetInput)
+ RECTEST example updated
+* Non-interpolated MOD mixing
+ BASS_MUSIC_NONINTER (BASS_MusicLoad/PlayEx flag)
+* Performance improvements
+ FFT up to 100% faster!
+ MP3(MPEG2/2.5) decoding up to 60% faster
+ MMX mixers 5-10% faster
+ MP3(MPEG1)/MP2/MP1/OGG decoding all ~5% faster
+* Optional disabling of FFT windowing
+ BASS_DATA_FFT_NOWINDOW (BASS_ChannelGetData flag)
+* BASS_ERROR_FILEFORM - error code to distinguish between file and sample format
+ BASS_MusicLoad
+ BASS_SampleLoad
+ BASS_StreamCreate/File/URL
+* BASS_StreamGetFilePosition mode flags added
+ BASS_FILEPOS_DECODE/DOWNLOAD/END
+* DirectX 9 detection
+ BASS_INFO (dsver member)
+* Initialization flags retrieval
+ BASS_INFO (initflags member)
+* Half-rate MP3 playback option removed
+ BASS_MP3_HALFRATE flag *removed*
+* New internal "plugin" system - BASSWMA is further integrated as a result
+* Improved documentation - integrated with BASSWMA, search option added
+* VB version of DSPTEST example added
+* Delphi RECORDTEST example added
+* Guess what... reduced DLL size again :)
+
+1.7 - 27/10/2002
+----------------
+* New alternative DX8 (DMO) effects implementation
+ BASS_StreamCreate/File/URL
+ BASS_MusicLoad
+ BASS_ChannelSetFX
+ SYNTH example updated
+* User file streaming
+ BASS_STREAM_FILEPROC (BASS_StreamCreate flag)
+ STREAMFILEPROC
+* DSP & FX support for decoding channels
+ BASS_ChannelSetDSP
+ BASS_ChannelSetFX
+* Support for DX8 (DMO) effects in IT/XM/MO3 files
+ BASS_MusicLoad
+* Support for chained OGG streaming (and syncing)
+ BASS_StreamCreateURL
+ BASS_SYNC_META (BASS_ChannelSetSync type)
+* Attribute (volume/frequency/pan) sliding
+ BASS_ChannelSlideAttributes
+ BASS_ChannelIsSliding
+ BASS_SYNC_SLIDE (BASS_ChannelSetSync type)
+* Recording without a callback function
+ BASS_RecordStart
+ LIVEFX example added
+* Query a channel's buffered data
+ BASS_DATA_AVAILABLE (BASS_ChannelGetData flag)
+* Discard data from the recording buffer
+ BASS_ChannelGetData
+* Adjustable internet stream config (timeout/buffer lengths)
+ BASS_SetNetConfig
+* Recommended minimum buffer length
+ BASS_INFO (minbuf member)
+* MOD music flags adjustment without changing playback position
+ BASS_MusicPlayEx
+ PLAYER (MASM) example updated
+* More functions are now useable in MOD music "mixtime" syncs
+ SYNCPROC
+ BASS_ChannelSetPosition
+ BASS_MusicPlayEx
+ BASS_MusicSetAmplify
+ BASS_MusicSetPanSep
+* Maximum buffer length increased to 5 seconds
+ BASS_SetBufferLength
+* Support for extended filter range in IT files
+ BASS_MusicLoad
+* Speedier MOD music file verification
+ BASS_MusicLoad
+* Delphi 3DTEST example fixed
+* Magically reduced DLL size again :)
+
+1.6a - 25/8/2002
+----------------
+* OGG support updated to 1.0
+* Stereo FFT
+ BASS_DATA_FFT512S/1024S/2048S (BASS_ChannelGetData flags)
+* Support for "Invert Loop" (EFx) MOD effect
+* Reduced DLL size
+* New Delphi examples
+ WRITEWAV - WAVE writer example
+ SAMPLEVIS - Visualisation example
+
+1.6 - 13/6/2002
+---------------
+* 64-bit stream lengths and positions
+ BASS_StreamGetLength
+ BASS_ChannelBytes2Seconds
+ BASS_ChannelSeconds2Bytes
+ BASS_ChannelGetPosition
+ BASS_ChannelSetPosition
+ BASS_ChannelSetSync
+* Recording input selection
+ BASS_RECORDINFO (inputs & singlein members)
+ BASS_RecordGetInputName
+ BASS_RecordGetInput
+ BASS_RecordSetInput
+* Adjustable recording update period
+ BASS_RecordStart
+* Load OGG files as samples
+ BASS_SampleLoad
+* CD drive door opening & closing
+ BASS_CDDoor
+* CDDB2 ID retrieval
+ BASS_CDID_CDDB2 (BASS_CDGetID flag)
+* Streaming beyond initial file length
+ BASS_StreamCreateFile
+* Recording position bytes<->seconds translation
+ BASS_ChannelBytes2Seconds
+ BASS_ChannelSeconds2Bytes
+* Improved multi-threaded support (play from any thread)
+ BASS_MusicPlay/Ex
+ BASS_SamplePlay/3D/Ex
+ BASS_StreamPlay
+ BASS_DEVICE_NOSYNC flag *removed*
+* Paused channel status
+ BASS_ACTIVE_PAUSED (BASS_ChannelIsActive)
+* Integrated WMA stream freeing
+ BASS_StreamFree
+ BASS_Free
+* Pin-point accurate OGG seeking without BASS_MP3_SETPOS flag
+* Win2k DS buffer bug fix
+
+1.5a - 14/4/2002
+----------------
+* NT4 fix (also enables "nosound" device without DX installed)
+ BASS_ERROR_DX error code
+* MOD music loading without the samples
+ BASS_MUSIC_NOSAMPLE (BASS_MusicLoad flag)
+* Custom decoding channels
+ BASS_STREAM_DECODE (BASS_StreamCreate flag)
+* 5 second HTTP connection timeout
+ BASS_ERROR_TIMEOUT (BASS_StreamCreateURL error code)
+
+1.5 - 31/3/2002
+---------------
+* Improved performance
+ MMX mixers lot faster (over 50% faster in some cases!)
+ OGG decoding 15-20% faster
+ MP3 decoding 5-10% faster
+* Recording
+ BASS_RecordGetDeviceDescription
+ BASS_RecordInit
+ BASS_RecordFree
+ BASS_RecordGetInfo
+ BASS_RecordStart
+* OGG support built-in (OGG/VORBIS DLLs not required)
+ BASS_DEVICE_OGG flag *removed*
+* MOD music seeking in seconds
+ BASS_MusicPlayEx
+ BASS_ChannelSetPosition
+* Shoutcast metadata retrieval
+ BASS_STREAM_META (BASS_StreamCreateURL flag)
+ BASS_TAG_META (BASS_StreamGetTags type)
+ BASS_SYNC_META (BASS_ChannelSetSync type)
+* 1000 volume levels
+ BASS_DEVICE_VOL1000 (BASS_Init/CDInit flag)
+* CDDB ID retrieval
+ BASS_CDID_CDDB (BASS_CDGetID flag)
+* Leave the CD volume as it is during init/closing
+ BASS_DEVICE_LEAVEVOL (BASS_CDInit flag)
+* FFT enabled on decoding channels
+ BASS_ChannelGetData
+* Left level duplicated on right for mono channels
+ BASS_ChannelGetLevel
+* Improved MPEG length estimation without BASS_MP3_SETPOS flag
+ BASS_StreamGetLength
+* Support for Modplug/ADPCM compressed files
+ BASS_MusicLoad
+* Device description function parameter change
+ BASS_GetDeviceDescription
+* MASM API
+
+1.4 - 30/1/2002
+---------------
+* Channel decoding without playback
+ BASS_MUSIC_DECODE (BASS_MusicLoad flag)
+ BASS_STREAM_DECODE (BASS_StreamCreateFile/URL flag)
+ BASS_ChannelGetData
+* Windows message sync callbacks
+ BASS_SYNC_MESSAGE (BASS_ChannelSetSync flag)
+* Adjustable channel volumes in MOD musics
+ BASS_MusicSetChannelVol
+ BASS_MusicGetChannelVol
+* Customizable DirectSound initialization object
+ BASS_SetCLSID
+* Retrieve HMUSIC/HSTREAM/HCHANNEL IDirectSoundBuffer interfaces
+ BASS_GetDSoundObject
+* A3D functions removed (use BASS_SetCLSID/BASS_GetDSoundObject to access A3D)
+ BASS_DEVICE_A3D (BASS_Init flag)
+ BASS_SetA3DResManager
+ BASS_GetA3DResManager
+ BASS_SetA3DHFAbsorbtion
+ BASS_GetA3DHFAbsorbtion
+* Callback functions now work in VB6
+ DSPPROC
+ STREAMPROC
+ SYNCPROC
+* Improved PCM WAVE streaming performance
+ BASS_StreamCreateFile
+ BASS_StreamCreateURL
+* OGG modules updated to RC3
+* Stereo sample support in MO3 format
+* MO3 encoder now distributed separately from BASS
+
+1.3 - 17/11/2001
+----------------
+* Manual buffer updating
+ BASS_DEVICE_NOTHREAD (BASS_Init flag)
+ BASS_Update
+* Adjustable buffer update period (allows small buffer sizes)
+ BASS_Init
+* Output device latency retrieval
+ BASS_INFO (latency member)
+* MPEG/OGG seeking without BASS_MP3_SETPOS flag
+ BASS_ChannelSetPosition
+* Internet file streaming from offsets
+ BASS_StreamCreateURL
+* File stream tag/comment retrieval (ID3/ID3v2/OGG/HTTP/ICY tags)
+ BASS_StreamGetTags
+* Byte<->time position translation
+ BASS_ChannelBytes2Seconds
+ BASS_ChannelSeconds2Bytes
+* UMX (Unreal/Tournament music package) format support
+ BASS_MusicLoad
+* S3M/IT sync fx changed to S2x (S0x conflicted with S00)
+ BASS_SYNC_MUSICFX
+* Stereo sample support in IT/XM/S3M formats
+* MO3: OGG compression supported
+
+1.2 - 25/9/2001
+---------------
+* OGG (Ogg Vorbis) stream support
+ BASS_DEVICE_OGG (BASS_Init flag)
+ BASS_StreamCreateFile
+ BASS_StreamCreateURL
+* Channel linking (start/stop/pause/resume channels together)
+ BASS_ChannelSetLink
+ BASS_ChannelRemoveLink
+* MOD music playback length calculation
+ BASS_MUSIC_CALCLEN (BASS_MusicLoad flag)
+ BASS_MusicGetLength
+* Pre-buffering
+ BASS_MusicPreBuf
+ BASS_StreamPreBuf
+* Samples with single simultaneous playbacks have same HSAMPLE/HCHANNEL handle
+ BASS_SamplePlay/Ex
+* Stopping a custom stream flushes its buffer contents
+ BASS_ChannelStop
+
+1.1a - 31/8/2001
+----------------
+* NT4 bug fixed
+* XM Wxx effect syncing
+ BASS_SYNC_MUSICFX
+* MP3/2/1 rewinding without BASS_MP3_SETPOS
+ BASS_ChannelSetPosition
+
+1.1 - 11/8/2001
+---------------
+* DX8 (DMO) effects
+ BASS_SAMPLE_FX (BASS_StreamCreate/File/URL flag)
+ BASS_MUSIC_FX (BASS_MusicLoad flag)
+ BASS_ChannelSetFX
+ BASS_ChannelRemoveFX
+ BASS_FXSetParameters
+ BASS_FXGetParameters
+ BASS_FXCHORUS structure
+ BASS_FXCOMPRESSOR structure
+ BASS_FXDISTORTION structure
+ BASS_FXECHO structure
+ BASS_FXFLANGER structure
+ BASS_FXGARGLE structure
+ BASS_FXI3DL2REVERB structure
+ BASS_FXPARAMEQ structure
+ BASS_FXREVERB structure
+* Internet file streaming in blocks (inc. Shoutcast/Icecast stream support)
+ BASS_STREAM_BLOCK (BASS_StreamCreateURL flag)
+* 512/1024/2048 sample FFT
+ BASS_DATA_FFT512/1024/2048 (BASS_ChannelGetData flags)
+* CD identification
+ BASS_CDGetID
+* Improved DX version detection
+ BASS_INFO (dsver member)
+
+1.0 - 20/6/2001
+---------------
+* Load MP3/MP2/MP1 files as samples
+ BASS_SampleLoad
+* Internet file streaming from FTP servers
+ BASS_StreamCreateURL
+* Save a local copy of internet file streams
+ BASS_StreamCreateURL
+* Sample accurate file stream seeking
+ BASS_ChannelSetPosition
+ BASS_StreamGetBlockLength *removed*
+* Stream position synchronizer
+ BASS_SYNC_POS
+* Increased synchronizer precision
+* Improved MPEG file detection and error detection
+* Stop MOD musics on a backwards jump effect
+ BASS_MUSIC_STOPBACK (BASS_MusicLoad/PlayEx flag)
+* Leave the volume as it is during closing (as well as initialization)
+ BASS_DEVICE_LEAVEVOL (BASS_Init flag)
+* Optional automatic use of foreground window handle during initialization
+ BASS_Init
+* Reduced DLL size
+* VB API fixes
+
+0.9 - 18/4/2001
+---------------
+* Internet file streaming
+ BASS_StreamCreateURL
+* MP1 & MP2 (MPEG layer 1 & 2) support
+ BASS_StreamCreateFile/URL
+* MPEG 2.5 support (12000/11025/8000hz sample rates)
+ BASS_StreamCreateFile/URL
+* Decoding/download/end file stream position retrieval
+ BASS_StreamGetFilePosition
+* XMPlay surround sound for MOD musics
+ BASS_MUSIC_SURROUND (BASS_MusicLoad/PlayEx flag)
+ BASS_MUSIC_SURROUND2 (BASS_MusicLoad/PlayEx flag)
+* Restrict the download rate of internet file streams
+ BASS_STREAM_RESTRATE (BASS_StreamCreateURL flag)
+* Check if an internet file stream is stalled
+ BASS_ChannelIsActive
+* Automatically free a stream when it stops or ends
+ BASS_STREAM_AUTOFREE (BASS_StreamCreate/File/URL flag)
+* Leave the volume as it is during initialization
+ BASS_DEVICE_LEAVEVOL (BASS_Init flag)
+* Number of CD tracks retrieval
+ BASS_CDGetTracks
+* CD track length retrieval
+ BASS_CDGetTrackLength
+* Exact stream length set after whole file is streamed
+ BASS_StreamGetLength
+* TMT Pascal API and samples
+* Dynamic-loading Delphi API
+
+0.8a - 28/2/2000
+----------------
+* Updated Delphi API and samples
+
+0.8 - 24/1/2000
+---------------
+* Improved MP3 performance on P2/K6 and above CPUs - fast!
+* User DSP functions on streams and MOD musics
+ BASS_ChannelSetDSP
+ BASS_ChannelRemoveDSP
+* DX7 voice allocation & management
+ BASS_SAMPLE_VAM (BASS_SampleLoad/Create flag)
+ BASS_VAM_xxx flags
+ BASS_SAMPLE (vam & priority members)
+* DX7 software 3D algorithm selection
+ BASS_Set3DAlgorithm
+* DirectSound interface retrieval
+ BASS_GetDSoundObject
+* Log/linear volume & panning curves
+ BASS_SetLogCurves
+* User data passed to callback functions
+ STREAMPROC - BASS_StreamCreate
+ SYNCPROC - BASS_ChannelSetSync
+* New synchronizer
+ BASS_SYNC_MUSICFX
+* New synchronizer flag
+ BASS_SYNC_MIXTIME
+* Disable synchronizers option - saves a little CPU time
+ BASS_DEVICE_NOSYNC (BASS_Init flag)
+* Hi-res floating-point CPU usage monitoring
+ BASS_GetCPU
+* Wait for playback to start when playing a CD
+ BASS_CDPlay
+* DirectSound (dsound.dll) version retrieval
+ BASS_INFO (dsver member)
+* Removed volume sliding functions (they were fairly pointless)
+ BASS_SlideVolume
+ BASS_IsSliding
+* MO3: read/write encoder settings
+* MO3: remove inst/samp/message texts now optional
+* MO3: LAME encoder settings
+
+0.7 - 3/10/1999
+---------------
+* MO3 (MP3 compressed MODs)
+* A3D functions
+ BASS_DEVICE_A3D (BASS_Init flag)
+ BASS_INFO (a3d member)
+ BASS_SetA3DResManager
+ BASS_GetA3DResManager
+ BASS_SetA3DHFAbsorbtion
+ BASS_GetA3DHFAbsorbtion
+* Music/stream immediate sample data retrieval
+ BASS_ChannelGetData
+* File stream (WAV/MP3) length retrieval
+ BASS_StreamGetLength
+ BASS_StreamGetBlockLength
+* File stream seeking
+ BASS_ChannelSetPosition
+* Mono MP3 option (lower CPU usage)
+ BASS_StreamCreateFile
+* Music length retrieval
+ BASS_MusicGetLength
+* Music name retrieval
+ BASS_MusicGetName
+* Stop notes when moving MOD music position
+ BASS_MUSIC_POSRESET (BASS_MusicLoad/BASS_MusicPlayEx flag)
+* BASS_ERROR_FREQ - invalid sample rate error code
+ BASS_SampleCreate
+ BASS_SamplePlayEx
+ BASS_SamplePlay3DEx
+ BASS_StreamCreate
+ BASS_ChannelSetAttributes
+* Delphi and VB APIs
+
+0.6a - 26/7/1999
+----------------
+* Half rate MP3 option (lower CPU usage)
+ BASS_MP3_HALFRATE
+* Loading/streaming from file offsets
+ BASS_MusicLoad
+ BASS_SampleLoad
+ BASS_StreamCreateFile
+* Global music/sample/stream volume levels
+ BASS_SetGlobalVolumes
+ BASS_GetGlobalVolumes
+* Other new function
+ BASS_SampleStop
+* New synchronizer
+ BASS_SYNC_END
+* New sample overrider
+ BASS_SAMPLE_OVER_DIST
+* LoadLibrary/GetProcAddress instructions and example
+
+0.5 - 4/7/1999
+--------------
+* Documentation!
+* File streaming (MP3 and WAV)
+ BASS_StreamCreateFile
+* Custom generated samples
+ BASS_SampleCreate
+ BASS_SampleCreateDone
+* Other new function
+ BASS_MusicSetPositionScaler
+* Renamed function
+ BASS_ChannelClearSync -> BASS_ChannelRemoveSync
+* Alterations made to
+ BASS_ChannelGetPosition
+ BASS_SampleLoad
+ BASS_StreamPlay
+
+0.4 - 30/3/1999
+---------------
+* Compressed WAV samples support (using audio CODECs)
+* Updated CD volume handling - now works with SB Live
+* More linear channel volume/pan scales (were slightly off before)
+* "no sound" device option
+* 3D sound functions
+ BASS_Set3DFactors
+ BASS_Get3DFactors
+ BASS_Set3DPosition
+ BASS_Get3DPosition
+ BASS_Apply3D
+ BASS_SamplePlay3D
+ BASS_SamplePlay3DEx
+ BASS_ChannelSet3DAttributes
+ BASS_ChannelGet3DAttributes
+ BASS_ChannelSet3DPosition
+ BASS_ChannelGet3DPosition
+* EAX functions
+ BASS_SetEAXParameters
+ BASS_GetEAXParameters
+ BASS_ChannelSetEAXMix
+ BASS_ChannelGetEAXMix
+* Other new functions
+ BASS_GetDeviceDescription
+ BASS_SetBufferLen
+ BASS_ChannelGetFlags
+ BASS_ChannelPause
+ BASS_ChannelResume
+ BASS_ChannelSetPosition
+* Replaced function
+ BASS_CDResume -> BASS_ChannelResume
+* Alterations made to
+ BASS_Init
+ BASS_CDInit
+ BASS_SampleLoad
+ BASS_StreamPlay
+ BASS_INFO structure
+ BASS_SAMPLE structure
+ BASS_DEVICE_xxx flags
+ BASS_SAMPLE_xxx flags
+
+0.3 - 8/3/1999
+--------------
+* Synchronization functions
+ BASS_ChannelSetSync
+ BASS_ChannelClearSync
+* Other new functions
+ BASS_GetVersion
+ BASS_ChannelGetPosition
+ BASS_ChannelGetLevel
+ BASS_ChannelGetAttributes
+ BASS_ChannelSetAttributes
+* Replaced functions
+ BASS_MusicStop -> BASS_ChannelStop
+ BASS_MusicSetVolume -> BASS_ChannelSetAttributes
+ BASS_CDStop -> BASS_ChannelStop
+ BASS_CDSetVolume -> BASS_ChannelSetAttributes
+ BASS_CDGetVolume -> BASS_ChannelGetAttributes
+ BASS_ChannelUpdate -> BASS_ChannelSetAttributes
+* Alterations made to
+ BASS_MusicPlayEx
+ BASS_StreamPlay
+ BASS_INFO structure
+
+0.2 - 28/2/1999
+---------------
+* First public release
+
+
+Credits - API/Sample Contributors
+=================================
+Visual Basic - Adam Hoult, Hendrik Knaepen, Arthur Aminov,
+ Peter Hebels
+Delphi - Titus Miloi, Rogier Timmermans, Alessandro Cappellozza,
+ Jesse Naranjo, Chris Troesken
+MASM - Octavian Chis
+
+CHMOX is (c)2004 Stéphane Boisson, http://chmox.sourceforge.net/
+
+
+Bug reports, Suggestions, Comments, Enquiries, etc...
+=====================================================
+If you have any of the aforementioned please see the BASS forum (at
+the website). If you can't find an answer there, you can email:
+
+ bass@un4seen.com
+
diff --git a/Game/Code/lib/bass/delphi/bass.bpg b/Game/Code/lib/bass/delphi/bass.bpg new file mode 100644 index 00000000..55c2e004 --- /dev/null +++ b/Game/Code/lib/bass/delphi/bass.bpg @@ -0,0 +1,64 @@ +#------------------------------------------------------------------------------
+VERSION = BWS.01
+#------------------------------------------------------------------------------
+!ifndef ROOT
+ROOT = $(MAKEDIR)\..
+!endif
+#------------------------------------------------------------------------------
+MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
+DCC = $(ROOT)\bin\dcc32.exe $**
+BRCC = $(ROOT)\bin\brcc32.exe $**
+#------------------------------------------------------------------------------
+PROJECTS = D3Test.exe BassTest.exe ConTest.exe custloop.exe DspTest.exe \
+ FXtest.exe livefx.exe Multi.exe netradio.exe plugins.exe RecordTest.exe \
+ samplevis.exe Speakers.exe StreamTest.exe writewav.exe
+#------------------------------------------------------------------------------
+default: $(PROJECTS)
+#------------------------------------------------------------------------------
+
+D3Test.exe: 3dTest\D3Test.dpr
+ $(DCC)
+
+BassTest.exe: BassTest\BassTest.dpr
+ $(DCC)
+
+ConTest.exe: ConTest\ConTest.dpr
+ $(DCC)
+
+custloop.exe: custloop\custloop.dpr
+ $(DCC)
+
+DspTest.exe: DspTest\DspTest.dpr
+ $(DCC)
+
+FXtest.exe: fxtest\FXtest.dpr
+ $(DCC)
+
+livefx.exe: livefx\livefx.dpr
+ $(DCC)
+
+Multi.exe: multi\Multi.dpr
+ $(DCC)
+
+netradio.exe: netradio\netradio.dpr
+ $(DCC)
+
+plugins.exe: plugins\plugins.dpr
+ $(DCC)
+
+RecordTest.exe: RecordTest\RecordTest.dpr
+ $(DCC)
+
+samplevis.exe: SampleVis\samplevis.dpr
+ $(DCC)
+
+Speakers.exe: Speakers\Speakers.dpr
+ $(DCC)
+
+StreamTest.exe: StreamTest\StreamTest.dpr
+ $(DCC)
+
+writewav.exe: writewav\writewav.dpr
+ $(DCC)
+
+
diff --git a/Game/Code/lib/bass/delphi/bass.pas b/Game/Code/lib/bass/delphi/bass.pas new file mode 100644 index 00000000..ba661699 --- /dev/null +++ b/Game/Code/lib/bass/delphi/bass.pas @@ -0,0 +1,968 @@ +{
+ BASS 2.3 Audio Library, (c) 1999-2007 Ian Luck.
+ Please report bugs/suggestions/etc... to bass@un4seen.com
+
+ See the BASS.CHM file for more complete documentation
+
+
+ How to install
+ ----------------
+ Copy BASS.PAS to the \LIB subdirectory of your Delphi path or your project dir
+}
+unit Bass;
+
+interface
+
+uses
+ Windows;
+
+const
+ BASSVERSION = $203; // API version
+
+ // Use these to test for error from functions that return a DWORD or QWORD
+ DW_ERROR = Cardinal(-1); // -1 (DWORD)
+ QW_ERROR = Int64(-1); // -1 (QWORD)
+
+ // Error codes returned by BASS_GetErrorCode()
+ BASS_OK = 0; // all is OK
+ BASS_ERROR_MEM = 1; // memory error
+ BASS_ERROR_FILEOPEN = 2; // can't open the file
+ BASS_ERROR_DRIVER = 3; // can't find a free sound driver
+ BASS_ERROR_BUFLOST = 4; // the sample buffer was lost - please report this!
+ BASS_ERROR_HANDLE = 5; // invalid handle
+ BASS_ERROR_FORMAT = 6; // unsupported sample format
+ BASS_ERROR_POSITION = 7; // invalid playback position
+ BASS_ERROR_INIT = 8; // BASS_Init has not been successfully called
+ BASS_ERROR_START = 9; // BASS_Start has not been successfully called
+ BASS_ERROR_ALREADY = 14; // already initialized/paused/whatever
+ BASS_ERROR_NOPAUSE = 16; // not paused
+ BASS_ERROR_NOCHAN = 18; // can't get a free channel
+ BASS_ERROR_ILLTYPE = 19; // an illegal type was specified
+ BASS_ERROR_ILLPARAM = 20; // an illegal parameter was specified
+ BASS_ERROR_NO3D = 21; // no 3D support
+ BASS_ERROR_NOEAX = 22; // no EAX support
+ BASS_ERROR_DEVICE = 23; // illegal device number
+ BASS_ERROR_NOPLAY = 24; // not playing
+ BASS_ERROR_FREQ = 25; // illegal sample rate
+ BASS_ERROR_NOTFILE = 27; // the stream is not a file stream
+ BASS_ERROR_NOHW = 29; // no hardware voices available
+ BASS_ERROR_EMPTY = 31; // the MOD music has no sequence data
+ BASS_ERROR_NONET = 32; // no internet connection could be opened
+ BASS_ERROR_CREATE = 33; // couldn't create the file
+ BASS_ERROR_NOFX = 34; // effects are not enabled
+ BASS_ERROR_PLAYING = 35; // the channel is playing
+ BASS_ERROR_NOTAVAIL = 37; // requested data is not available
+ BASS_ERROR_DECODE = 38; // the channel is a "decoding channel"
+ BASS_ERROR_DX = 39; // a sufficient DirectX version is not installed
+ BASS_ERROR_TIMEOUT = 40; // connection timedout
+ BASS_ERROR_FILEFORM = 41; // unsupported file format
+ BASS_ERROR_SPEAKER = 42; // unavailable speaker
+ BASS_ERROR_VERSION = 43; // invalid BASS version (used by add-ons)
+ BASS_ERROR_CODEC = 44; // codec is not available/supported
+ BASS_ERROR_UNKNOWN = -1; // some other mystery error
+
+ // Initialization flags
+ BASS_DEVICE_8BITS = 1; // use 8 bit resolution, else 16 bit
+ BASS_DEVICE_MONO = 2; // use mono, else stereo
+ BASS_DEVICE_3D = 4; // enable 3D functionality
+ {
+ If the BASS_DEVICE_3D flag is not specified when
+ initilizing BASS, then the 3D flags (BASS_SAMPLE_3D
+ and BASS_MUSIC_3D) are ignored when loading/creating
+ a sample/stream/music.
+ }
+ BASS_DEVICE_LATENCY = 256; // calculate device latency (BASS_INFO struct)
+ BASS_DEVICE_SPEAKERS = 2048; // force enabling of speaker assignment
+ BASS_DEVICE_NOSPEAKER = 4096; // ignore speaker arrangement
+
+ // DirectSound interfaces (for use with BASS_GetDSoundObject)
+ BASS_OBJECT_DS = 1; // IDirectSound
+ BASS_OBJECT_DS3DL = 2; // IDirectSound3DListener
+
+ // BASS_INFO flags (from DSOUND.H)
+ DSCAPS_CONTINUOUSRATE = $00000010;
+ { supports all sample rates between min/maxrate }
+ DSCAPS_EMULDRIVER = $00000020;
+ { device does NOT have hardware DirectSound support }
+ DSCAPS_CERTIFIED = $00000040;
+ { device driver has been certified by Microsoft }
+ {
+ The following flags tell what type of samples are
+ supported by HARDWARE mixing, all these formats are
+ supported by SOFTWARE mixing
+ }
+ DSCAPS_SECONDARYMONO = $00000100; // mono
+ DSCAPS_SECONDARYSTEREO = $00000200; // stereo
+ DSCAPS_SECONDARY8BIT = $00000400; // 8 bit
+ DSCAPS_SECONDARY16BIT = $00000800; // 16 bit
+
+ // BASS_RECORDINFO flags (from DSOUND.H)
+ DSCCAPS_EMULDRIVER = DSCAPS_EMULDRIVER;
+ { device does NOT have hardware DirectSound recording support }
+ DSCCAPS_CERTIFIED = DSCAPS_CERTIFIED;
+ { device driver has been certified by Microsoft }
+
+ // defines for formats field of BASS_RECORDINFO (from MMSYSTEM.H)
+ WAVE_FORMAT_1M08 = $00000001; // 11.025 kHz, Mono, 8-bit
+ WAVE_FORMAT_1S08 = $00000002; // 11.025 kHz, Stereo, 8-bit
+ WAVE_FORMAT_1M16 = $00000004; // 11.025 kHz, Mono, 16-bit
+ WAVE_FORMAT_1S16 = $00000008; // 11.025 kHz, Stereo, 16-bit
+ WAVE_FORMAT_2M08 = $00000010; // 22.05 kHz, Mono, 8-bit
+ WAVE_FORMAT_2S08 = $00000020; // 22.05 kHz, Stereo, 8-bit
+ WAVE_FORMAT_2M16 = $00000040; // 22.05 kHz, Mono, 16-bit
+ WAVE_FORMAT_2S16 = $00000080; // 22.05 kHz, Stereo, 16-bit
+ WAVE_FORMAT_4M08 = $00000100; // 44.1 kHz, Mono, 8-bit
+ WAVE_FORMAT_4S08 = $00000200; // 44.1 kHz, Stereo, 8-bit
+ WAVE_FORMAT_4M16 = $00000400; // 44.1 kHz, Mono, 16-bit
+ WAVE_FORMAT_4S16 = $00000800; // 44.1 kHz, Stereo, 16-bit
+
+ // Sample info flags
+ BASS_SAMPLE_8BITS = 1; // 8 bit
+ BASS_SAMPLE_FLOAT = 256; // 32-bit floating-point
+ BASS_SAMPLE_MONO = 2; // mono, else stereo
+ BASS_SAMPLE_LOOP = 4; // looped
+ BASS_SAMPLE_3D = 8; // 3D functionality enabled
+ BASS_SAMPLE_SOFTWARE = 16; // it's NOT using hardware mixing
+ BASS_SAMPLE_MUTEMAX = 32; // muted at max distance (3D only)
+ BASS_SAMPLE_VAM = 64; // uses the DX7 voice allocation & management
+ BASS_SAMPLE_FX = 128; // old implementation of DX8 effects are enabled
+ BASS_SAMPLE_OVER_VOL = $10000; // override lowest volume
+ BASS_SAMPLE_OVER_POS = $20000; // override longest playing
+ BASS_SAMPLE_OVER_DIST = $30000; // override furthest from listener (3D only)
+
+ BASS_STREAM_PRESCAN = $20000; // enable pin-point seeking (MP3/MP2/MP1)
+ BASS_MP3_SETPOS = BASS_STREAM_PRESCAN;
+ BASS_STREAM_AUTOFREE = $40000; // automatically free the stream when it stop/ends
+ BASS_STREAM_RESTRATE = $80000; // restrict the download rate of internet file streams
+ BASS_STREAM_BLOCK = $100000;// download/play internet file stream in small blocks
+ BASS_STREAM_DECODE = $200000;// don't play the stream, only decode (BASS_ChannelGetData)
+ BASS_STREAM_STATUS = $800000;// give server status info (HTTP/ICY tags) in DOWNLOADPROC
+
+ BASS_MUSIC_FLOAT = BASS_SAMPLE_FLOAT; // 32-bit floating-point
+ BASS_MUSIC_MONO = BASS_SAMPLE_MONO; // force mono mixing (less CPU usage)
+ BASS_MUSIC_LOOP = BASS_SAMPLE_LOOP; // loop music
+ BASS_MUSIC_3D = BASS_SAMPLE_3D; // enable 3D functionality
+ BASS_MUSIC_FX = BASS_SAMPLE_FX; // enable old implementation of DX8 effects
+ BASS_MUSIC_AUTOFREE = BASS_STREAM_AUTOFREE; // automatically free the music when it stop/ends
+ BASS_MUSIC_DECODE = BASS_STREAM_DECODE; // don't play the music, only decode (BASS_ChannelGetData)
+ BASS_MUSIC_PRESCAN = BASS_STREAM_PRESCAN; // calculate playback length
+ BASS_MUSIC_CALCLEN = BASS_MUSIC_PRESCAN;
+ BASS_MUSIC_RAMP = $200; // normal ramping
+ BASS_MUSIC_RAMPS = $400; // sensitive ramping
+ BASS_MUSIC_SURROUND = $800; // surround sound
+ BASS_MUSIC_SURROUND2 = $1000; // surround sound (mode 2)
+ BASS_MUSIC_FT2MOD = $2000; // play .MOD as FastTracker 2 does
+ BASS_MUSIC_PT1MOD = $4000; // play .MOD as ProTracker 1 does
+ BASS_MUSIC_NONINTER = $10000; // non-interpolated mixing
+ BASS_MUSIC_POSRESET = $8000; // stop all notes when moving position
+ BASS_MUSIC_POSRESETEX = $400000; // stop all notes and reset bmp/etc when moving position
+ BASS_MUSIC_STOPBACK = $80000; // stop the music on a backwards jump effect
+ BASS_MUSIC_NOSAMPLE = $100000; // don't load the samples
+
+ // Speaker assignment flags
+ BASS_SPEAKER_FRONT = $1000000; // front speakers
+ BASS_SPEAKER_REAR = $2000000; // rear/side speakers
+ BASS_SPEAKER_CENLFE = $3000000; // center & LFE speakers (5.1)
+ BASS_SPEAKER_REAR2 = $4000000; // rear center speakers (7.1)
+ BASS_SPEAKER_LEFT = $10000000; // modifier: left
+ BASS_SPEAKER_RIGHT = $20000000; // modifier: right
+ BASS_SPEAKER_FRONTLEFT = BASS_SPEAKER_FRONT or BASS_SPEAKER_LEFT;
+ BASS_SPEAKER_FRONTRIGHT = BASS_SPEAKER_FRONT or BASS_SPEAKER_RIGHT;
+ BASS_SPEAKER_REARLEFT = BASS_SPEAKER_REAR or BASS_SPEAKER_LEFT;
+ BASS_SPEAKER_REARRIGHT = BASS_SPEAKER_REAR or BASS_SPEAKER_RIGHT;
+ BASS_SPEAKER_CENTER = BASS_SPEAKER_CENLFE or BASS_SPEAKER_LEFT;
+ BASS_SPEAKER_LFE = BASS_SPEAKER_CENLFE or BASS_SPEAKER_RIGHT;
+ BASS_SPEAKER_REAR2LEFT = BASS_SPEAKER_REAR2 or BASS_SPEAKER_LEFT;
+ BASS_SPEAKER_REAR2RIGHT = BASS_SPEAKER_REAR2 or BASS_SPEAKER_RIGHT;
+
+ BASS_UNICODE = $80000000;
+
+ BASS_RECORD_PAUSE = $8000; // start recording paused
+
+ // DX7 voice allocation flags
+ BASS_VAM_HARDWARE = 1;
+ {
+ Play the sample in hardware. If no hardware voices are available then
+ the "play" call will fail
+ }
+ BASS_VAM_SOFTWARE = 2;
+ {
+ Play the sample in software (ie. non-accelerated). No other VAM flags
+ may be used together with this flag.
+ }
+
+ // DX7 voice management flags
+ {
+ These flags enable hardware resource stealing... if the hardware has no
+ available voices, a currently playing buffer will be stopped to make room
+ for the new buffer. NOTE: only samples loaded/created with the
+ BASS_SAMPLE_VAM flag are considered for termination by the DX7 voice
+ management.
+ }
+ BASS_VAM_TERM_TIME = 4;
+ {
+ If there are no free hardware voices, the buffer to be terminated will be
+ the one with the least time left to play.
+ }
+ BASS_VAM_TERM_DIST = 8;
+ {
+ If there are no free hardware voices, the buffer to be terminated will be
+ one that was loaded/created with the BASS_SAMPLE_MUTEMAX flag and is
+ beyond
+ it's max distance. If there are no buffers that match this criteria, then
+ the "play" call will fail.
+ }
+ BASS_VAM_TERM_PRIO = 16;
+ {
+ If there are no free hardware voices, the buffer to be terminated will be
+ the one with the lowest priority.
+ }
+
+ // BASS_CHANNELINFO types
+ BASS_CTYPE_SAMPLE = 1;
+ BASS_CTYPE_RECORD = 2;
+ BASS_CTYPE_STREAM = $10000;
+ BASS_CTYPE_STREAM_OGG = $10002;
+ BASS_CTYPE_STREAM_MP1 = $10003;
+ BASS_CTYPE_STREAM_MP2 = $10004;
+ BASS_CTYPE_STREAM_MP3 = $10005;
+ BASS_CTYPE_STREAM_AIFF = $10006;
+ BASS_CTYPE_STREAM_WAV = $40000; // WAVE flag, LOWORD=codec
+ BASS_CTYPE_STREAM_WAV_PCM = $50001;
+ BASS_CTYPE_STREAM_WAV_FLOAT = $50003;
+ BASS_CTYPE_MUSIC_MOD = $20000;
+ BASS_CTYPE_MUSIC_MTM = $20001;
+ BASS_CTYPE_MUSIC_S3M = $20002;
+ BASS_CTYPE_MUSIC_XM = $20003;
+ BASS_CTYPE_MUSIC_IT = $20004;
+ BASS_CTYPE_MUSIC_MO3 = $00100; // MO3 flag
+
+ // 3D channel modes
+ BASS_3DMODE_NORMAL = 0;
+ { normal 3D processing }
+ BASS_3DMODE_RELATIVE = 1;
+ {
+ The channel's 3D position (position/velocity/
+ orientation) are relative to the listener. When the
+ listener's position/velocity/orientation is changed
+ with BASS_Set3DPosition, the channel's position
+ relative to the listener does not change.
+ }
+ BASS_3DMODE_OFF = 2;
+ {
+ Turn off 3D processing on the channel, the sound will
+ be played in the center.
+ }
+
+ // EAX environments, use with BASS_SetEAXParameters
+ EAX_ENVIRONMENT_GENERIC = 0;
+ EAX_ENVIRONMENT_PADDEDCELL = 1;
+ EAX_ENVIRONMENT_ROOM = 2;
+ EAX_ENVIRONMENT_BATHROOM = 3;
+ EAX_ENVIRONMENT_LIVINGROOM = 4;
+ EAX_ENVIRONMENT_STONEROOM = 5;
+ EAX_ENVIRONMENT_AUDITORIUM = 6;
+ EAX_ENVIRONMENT_CONCERTHALL = 7;
+ EAX_ENVIRONMENT_CAVE = 8;
+ EAX_ENVIRONMENT_ARENA = 9;
+ EAX_ENVIRONMENT_HANGAR = 10;
+ EAX_ENVIRONMENT_CARPETEDHALLWAY = 11;
+ EAX_ENVIRONMENT_HALLWAY = 12;
+ EAX_ENVIRONMENT_STONECORRIDOR = 13;
+ EAX_ENVIRONMENT_ALLEY = 14;
+ EAX_ENVIRONMENT_FOREST = 15;
+ EAX_ENVIRONMENT_CITY = 16;
+ EAX_ENVIRONMENT_MOUNTAINS = 17;
+ EAX_ENVIRONMENT_QUARRY = 18;
+ EAX_ENVIRONMENT_PLAIN = 19;
+ EAX_ENVIRONMENT_PARKINGLOT = 20;
+ EAX_ENVIRONMENT_SEWERPIPE = 21;
+ EAX_ENVIRONMENT_UNDERWATER = 22;
+ EAX_ENVIRONMENT_DRUGGED = 23;
+ EAX_ENVIRONMENT_DIZZY = 24;
+ EAX_ENVIRONMENT_PSYCHOTIC = 25;
+ // total number of environments
+ EAX_ENVIRONMENT_COUNT = 26;
+
+ // software 3D mixing algorithm modes (used with BASS_Set3DAlgorithm)
+ BASS_3DALG_DEFAULT = 0;
+ {
+ default algorithm (currently translates to BASS_3DALG_OFF)
+ }
+ BASS_3DALG_OFF = 1;
+ {
+ Uses normal left and right panning. The vertical axis is ignored except
+ for scaling of volume due to distance. Doppler shift and volume scaling
+ are still applied, but the 3D filtering is not performed. This is the
+ most CPU efficient software implementation, but provides no virtual 3D
+ audio effect. Head Related Transfer Function processing will not be done.
+ Since only normal stereo panning is used, a channel using this algorithm
+ may be accelerated by a 2D hardware voice if no free 3D hardware voices
+ are available.
+ }
+ BASS_3DALG_FULL = 2;
+ {
+ This algorithm gives the highest quality 3D audio effect, but uses more
+ CPU. Requires Windows 98 2nd Edition or Windows 2000 that uses WDM
+ drivers, if this mode is not available then BASS_3DALG_OFF will be used
+ instead.
+ }
+ BASS_3DALG_LIGHT = 3;
+ {
+ This algorithm gives a good 3D audio effect, and uses less CPU than the
+ FULL mode. Requires Windows 98 2nd Edition or Windows 2000 that uses WDM
+ drivers, if this mode is not available then BASS_3DALG_OFF will be used
+ instead.
+ }
+
+ {
+ Sync types (with BASS_ChannelSetSync() "param" and
+ SYNCPROC "data" definitions) & flags.
+ }
+ BASS_SYNC_POS = 0;
+ {
+ Sync when a channel reaches a position.
+ param: position in bytes
+ data : not used
+ }
+ BASS_SYNC_END = 2;
+ {
+ Sync when a channel reaches the end.
+ param: not used
+ data : not used
+ }
+ BASS_SYNC_META = 4;
+ {
+ Sync when metadata is received in a stream.
+ param: not used
+ data : pointer to the metadata
+ }
+ BASS_SYNC_SLIDE = 5;
+ {
+ Sync when an attribute slide is completed.
+ param: not used
+ data : the type of slide completed (one of the BASS_SLIDE_xxx values)
+ }
+ BASS_SYNC_STALL = 6;
+ {
+ Sync when playback has stalled.
+ param: not used
+ data : 0=stalled, 1=resumed
+ }
+ BASS_SYNC_DOWNLOAD = 7;
+ {
+ Sync when downloading of an internet (or "buffered" user file) stream has ended.
+ param: not used
+ data : not used
+ }
+ BASS_SYNC_FREE = 8;
+ {
+ Sync when a channel is freed.
+ param: not used
+ data : not used
+ }
+ BASS_SYNC_SETPOS = 11;
+ {
+ Sync when a channel's position is set.
+ param: not used
+ data : 0 = playback buffer not flushed, 1 = playback buffer flushed
+ }
+ BASS_SYNC_MUSICPOS = 10;
+ {
+ Sync when a MOD music reaches an order:row position.
+ param: LOWORD=order (0=first, -1=all) HIWORD=row (0=first, -1=all)
+ data : LOWORD=order HIWORD=row
+ }
+ BASS_SYNC_MUSICINST = 1;
+ {
+ Sync when an instrument (sample for the non-instrument based formats)
+ is played in a MOD music (not including retrigs).
+ param: LOWORD=instrument (1=first) HIWORD=note (0=c0...119=b9, -1=all)
+ data : LOWORD=note HIWORD=volume (0-64)
+ }
+ BASS_SYNC_MUSICFX = 3;
+ {
+ Sync when the "sync" effect (XM/MTM/MOD: E8x/Wxx, IT/S3M: S2x) is used.
+ param: 0:data=pos, 1:data="x" value
+ data : param=0: LOWORD=order HIWORD=row, param=1: "x" value
+ }
+ BASS_SYNC_MESSAGE = $20000000;
+ { FLAG: post a Windows message (instead of callback)
+ When using a window message "callback", the message to post is given in the "proc"
+ parameter of BASS_ChannelSetSync, and is posted to the window specified in the BASS_Init
+ call. The message parameters are: WPARAM = data, LPARAM = user.
+ }
+ BASS_SYNC_MIXTIME = $40000000;
+ { FLAG: sync at mixtime, else at playtime }
+ BASS_SYNC_ONETIME = $80000000;
+ { FLAG: sync only once, else continuously }
+
+ // BASS_ChannelIsActive return values
+ BASS_ACTIVE_STOPPED = 0;
+ BASS_ACTIVE_PLAYING = 1;
+ BASS_ACTIVE_STALLED = 2;
+ BASS_ACTIVE_PAUSED = 3;
+
+ // BASS_ChannelIsSliding return flags
+ BASS_SLIDE_FREQ = 1;
+ BASS_SLIDE_VOL = 2;
+ BASS_SLIDE_PAN = 4;
+
+ // BASS_ChannelGetData flags
+ BASS_DATA_AVAILABLE = 0; // query how much data is buffered
+ BASS_DATA_FLOAT = $40000000; // flag: return floating-point sample data
+ BASS_DATA_FFT512 = $80000000; // 512 sample FFT
+ BASS_DATA_FFT1024 = $80000001; // 1024 FFT
+ BASS_DATA_FFT2048 = $80000002; // 2048 FFT
+ BASS_DATA_FFT4096 = $80000003; // 4096 FFT
+ BASS_DATA_FFT8192 = $80000004; // 8192 FFT
+ BASS_DATA_FFT_INDIVIDUAL = $10; // FFT flag: FFT for each channel, else all combined
+ BASS_DATA_FFT_NOWINDOW = $20; // FFT flag: no Hanning window
+
+ // BASS_ChannelGetTags types : what's returned
+ BASS_TAG_ID3 = 0; // ID3v1 tags : 128 byte block
+ BASS_TAG_ID3V2 = 1; // ID3v2 tags : variable length block
+ BASS_TAG_OGG = 2; // OGG comments : array of null-terminated strings
+ BASS_TAG_HTTP = 3; // HTTP headers : array of null-terminated strings
+ BASS_TAG_ICY = 4; // ICY headers : array of null-terminated strings
+ BASS_TAG_META = 5; // ICY metadata : null-terminated string
+ BASS_TAG_VENDOR = 9; // OGG encoder : null-terminated string
+ BASS_TAG_LYRICS3 = 10; // Lyric3v2 tag : ASCII string
+ BASS_TAG_RIFF_INFO = $100; // RIFF/WAVE tags : array of null-terminated ANSI strings
+ BASS_TAG_MUSIC_NAME = $10000; // MOD music name : ANSI string
+ BASS_TAG_MUSIC_MESSAGE = $10001; // MOD message : ANSI string
+ BASS_TAG_MUSIC_INST = $10100; // + instrument #, MOD instrument name : ANSI string
+ BASS_TAG_MUSIC_SAMPLE = $10300; // + sample #, MOD sample name : ANSI string
+
+ BASS_FX_CHORUS = 0; // GUID_DSFX_STANDARD_CHORUS
+ BASS_FX_COMPRESSOR = 1; // GUID_DSFX_STANDARD_COMPRESSOR
+ BASS_FX_DISTORTION = 2; // GUID_DSFX_STANDARD_DISTORTION
+ BASS_FX_ECHO = 3; // GUID_DSFX_STANDARD_ECHO
+ BASS_FX_FLANGER = 4; // GUID_DSFX_STANDARD_FLANGER
+ BASS_FX_GARGLE = 5; // GUID_DSFX_STANDARD_GARGLE
+ BASS_FX_I3DL2REVERB = 6; // GUID_DSFX_STANDARD_I3DL2REVERB
+ BASS_FX_PARAMEQ = 7; // GUID_DSFX_STANDARD_PARAMEQ
+ BASS_FX_REVERB = 8; // GUID_DSFX_WAVES_REVERB
+
+ BASS_FX_PHASE_NEG_180 = 0;
+ BASS_FX_PHASE_NEG_90 = 1;
+ BASS_FX_PHASE_ZERO = 2;
+ BASS_FX_PHASE_90 = 3;
+ BASS_FX_PHASE_180 = 4;
+
+ // BASS_RecordSetInput flags
+ BASS_INPUT_OFF = $10000;
+ BASS_INPUT_ON = $20000;
+ BASS_INPUT_LEVEL = $40000;
+
+ BASS_INPUT_TYPE_MASK = $ff000000;
+ BASS_INPUT_TYPE_UNDEF = $00000000;
+ BASS_INPUT_TYPE_DIGITAL = $01000000;
+ BASS_INPUT_TYPE_LINE = $02000000;
+ BASS_INPUT_TYPE_MIC = $03000000;
+ BASS_INPUT_TYPE_SYNTH = $04000000;
+ BASS_INPUT_TYPE_CD = $05000000;
+ BASS_INPUT_TYPE_PHONE = $06000000;
+ BASS_INPUT_TYPE_SPEAKER = $07000000;
+ BASS_INPUT_TYPE_WAVE = $08000000;
+ BASS_INPUT_TYPE_AUX = $09000000;
+ BASS_INPUT_TYPE_ANALOG = $0a000000;
+
+ // BASS_SetNetConfig flags
+ BASS_NET_TIMEOUT = 0;
+ BASS_NET_BUFFER = 1;
+
+ // BASS_StreamGetFilePosition modes
+ BASS_FILEPOS_CURRENT = 0;
+ BASS_FILEPOS_DECODE = BASS_FILEPOS_CURRENT;
+ BASS_FILEPOS_DOWNLOAD = 1;
+ BASS_FILEPOS_END = 2;
+ BASS_FILEPOS_START = 3;
+ BASS_FILEPOS_CONNECTED = 4;
+
+ // STREAMFILEPROC actions
+ BASS_FILE_CLOSE = 0;
+ BASS_FILE_READ = 1;
+ BASS_FILE_LEN = 3;
+ BASS_FILE_SEEK = 4;
+
+ BASS_STREAMPROC_END = $80000000; // end of user stream flag
+
+ // BASS_MusicSet/GetAttribute options
+ BASS_MUSIC_ATTRIB_AMPLIFY = 0;
+ BASS_MUSIC_ATTRIB_PANSEP = 1;
+ BASS_MUSIC_ATTRIB_PSCALER = 2;
+ BASS_MUSIC_ATTRIB_BPM = 3;
+ BASS_MUSIC_ATTRIB_SPEED = 4;
+ BASS_MUSIC_ATTRIB_VOL_GLOBAL = 5;
+ BASS_MUSIC_ATTRIB_VOL_CHAN = $100; // + channel #
+ BASS_MUSIC_ATTRIB_VOL_INST = $200; // + instrument #
+
+ // BASS_Set/GetConfig options
+ BASS_CONFIG_BUFFER = 0;
+ BASS_CONFIG_UPDATEPERIOD = 1;
+ BASS_CONFIG_MAXVOL = 3;
+ BASS_CONFIG_GVOL_SAMPLE = 4;
+ BASS_CONFIG_GVOL_STREAM = 5;
+ BASS_CONFIG_GVOL_MUSIC = 6;
+ BASS_CONFIG_CURVE_VOL = 7;
+ BASS_CONFIG_CURVE_PAN = 8;
+ BASS_CONFIG_FLOATDSP = 9;
+ BASS_CONFIG_3DALGORITHM = 10;
+ BASS_CONFIG_NET_TIMEOUT = 11;
+ BASS_CONFIG_NET_BUFFER = 12;
+ BASS_CONFIG_PAUSE_NOPLAY = 13;
+ BASS_CONFIG_NET_PREBUF = 15;
+ BASS_CONFIG_NET_AGENT = 16;
+ BASS_CONFIG_NET_PROXY = 17;
+ BASS_CONFIG_NET_PASSIVE = 18;
+ BASS_CONFIG_REC_BUFFER = 19;
+ BASS_CONFIG_NET_PLAYLIST = 21;
+ BASS_CONFIG_MUSIC_VIRTUAL = 22;
+
+type
+ DWORD = cardinal;
+ BOOL = LongBool;
+ FLOAT = Single;
+ QWORD = int64; // 64-bit (replace "int64" with "comp" if using Delphi 3)
+
+ HMUSIC = DWORD; // MOD music handle
+ HSAMPLE = DWORD; // sample handle
+ HCHANNEL = DWORD; // playing sample's channel handle
+ HSTREAM = DWORD; // sample stream handle
+ HRECORD = DWORD; // recording handle
+ HSYNC = DWORD; // synchronizer handle
+ HDSP = DWORD; // DSP handle
+ HFX = DWORD; // DX8 effect handle
+ HPLUGIN = DWORD; // Plugin handle
+
+ BASS_INFO = record
+ flags: DWORD; // device capabilities (DSCAPS_xxx flags)
+ hwsize: DWORD; // size of total device hardware memory
+ hwfree: DWORD; // size of free device hardware memory
+ freesam: DWORD; // number of free sample slots in the hardware
+ free3d: DWORD; // number of free 3D sample slots in the hardware
+ minrate: DWORD; // min sample rate supported by the hardware
+ maxrate: DWORD; // max sample rate supported by the hardware
+ eax: BOOL; // device supports EAX? (always FALSE if BASS_DEVICE_3D was not used)
+ minbuf: DWORD; // recommended minimum buffer length in ms (requires BASS_DEVICE_LATENCY)
+ dsver: DWORD; // DirectSound version
+ latency: DWORD; // delay (in ms) before start of playback (requires BASS_DEVICE_LATENCY)
+ initflags: DWORD; // "flags" parameter of BASS_Init call
+ speakers: DWORD; // number of speakers available
+ driver: PChar; // driver
+ freq: DWORD; // current output rate (OSX only)
+ end;
+
+ BASS_RECORDINFO = record
+ flags: DWORD; // device capabilities (DSCCAPS_xxx flags)
+ formats: DWORD; // supported standard formats (WAVE_FORMAT_xxx flags)
+ inputs: DWORD; // number of inputs
+ singlein: BOOL; // only 1 input can be set at a time
+ driver: PChar; // driver
+ freq: DWORD; // current input rate (OSX only)
+ end;
+
+ BASS_CHANNELINFO = record
+ freq: DWORD; // default playback rate
+ chans: DWORD; // channels
+ flags: DWORD; // BASS_SAMPLE/STREAM/MUSIC/SPEAKER flags
+ ctype: DWORD; // type of channel
+ origres: DWORD; // original resolution
+ plugin: HPLUGIN; // plugin
+ end;
+
+ BASS_PLUGINFORM = record
+ ctype: DWORD; // channel type
+ name: PChar; // format description
+ exts: PChar; // file extension filter (*.ext1;*.ext2;etc...)
+ end;
+ PBASS_PLUGINFORMS = ^TBASS_PLUGINFORMS;
+ TBASS_PLUGINFORMS = array[0..maxInt div sizeOf(BASS_PLUGINFORM) - 1] of BASS_PLUGINFORM;
+
+ BASS_PLUGININFO = record
+ version: DWORD; // version (same form as BASS_GetVersion)
+ formatc: DWORD; // number of formats
+ formats: PBASS_PLUGINFORMS; // the array of formats
+ end;
+ PBASS_PLUGININFO = ^BASS_PLUGININFO;
+
+ // Sample info structure
+ BASS_SAMPLE = record
+ freq: DWORD; // default playback rate
+ volume: DWORD; // default volume (0-100)
+ pan: Integer; // default pan (-100=left, 0=middle, 100=right)
+ flags: DWORD; // BASS_SAMPLE_xxx flags
+ length: DWORD; // length (in samples, not bytes)
+ max: DWORD; // maximum simultaneous playbacks
+ origres: DWORD; // original resolution
+ chans: DWORD; // number of channels
+ mingap: DWORD; // minimum gap (ms) between creating channels
+ {
+ The following are the sample's default 3D attributes
+ (if the sample is 3D, BASS_SAMPLE_3D is in flags)
+ see BASS_ChannelSet3DAttributes
+ }
+ mode3d: DWORD; // BASS_3DMODE_xxx mode
+ mindist: FLOAT; // minimum distance
+ maxdist: FLOAT; // maximum distance
+ iangle: DWORD; // angle of inside projection cone
+ oangle: DWORD; // angle of outside projection cone
+ outvol: DWORD; // delta-volume outside the projection cone
+ {
+ The following are the defaults used if the sample uses the DirectX 7
+ voice allocation/management features.
+ }
+ vam: DWORD; // voice allocation/management flags (BASS_VAM_xxx)
+ priority: DWORD; // priority (0=lowest, $ffffffff=highest)
+ end;
+
+ // 3D vector (for 3D positions/velocities/orientations)
+ BASS_3DVECTOR = record
+ x: FLOAT; // +=right, -=left
+ y: FLOAT; // +=up, -=down
+ z: FLOAT; // +=front, -=behind
+ end;
+
+ BASS_FXCHORUS = record
+ fWetDryMix: FLOAT;
+ fDepth: FLOAT;
+ fFeedback: FLOAT;
+ fFrequency: FLOAT;
+ lWaveform: DWORD; // 0=triangle, 1=sine
+ fDelay: FLOAT;
+ lPhase: DWORD; // BASS_FX_PHASE_xxx
+ end;
+
+ BASS_FXCOMPRESSOR = record
+ fGain: FLOAT;
+ fAttack: FLOAT;
+ fRelease: FLOAT;
+ fThreshold: FLOAT;
+ fRatio: FLOAT;
+ fPredelay: FLOAT;
+ end;
+
+ BASS_FXDISTORTION = record
+ fGain: FLOAT;
+ fEdge: FLOAT;
+ fPostEQCenterFrequency: FLOAT;
+ fPostEQBandwidth: FLOAT;
+ fPreLowpassCutoff: FLOAT;
+ end;
+
+ BASS_FXECHO = record
+ fWetDryMix: FLOAT;
+ fFeedback: FLOAT;
+ fLeftDelay: FLOAT;
+ fRightDelay: FLOAT;
+ lPanDelay: BOOL;
+ end;
+
+ BASS_FXFLANGER = record
+ fWetDryMix: FLOAT;
+ fDepth: FLOAT;
+ fFeedback: FLOAT;
+ fFrequency: FLOAT;
+ lWaveform: DWORD; // 0=triangle, 1=sine
+ fDelay: FLOAT;
+ lPhase: DWORD; // BASS_FX_PHASE_xxx
+ end;
+
+ BASS_FXGARGLE = record
+ dwRateHz: DWORD; // Rate of modulation in hz
+ dwWaveShape: DWORD; // 0=triangle, 1=square
+ end;
+
+ BASS_FXI3DL2REVERB = record
+ lRoom: Longint; // [-10000, 0] default: -1000 mB
+ lRoomHF: Longint; // [-10000, 0] default: 0 mB
+ flRoomRolloffFactor: FLOAT; // [0.0, 10.0] default: 0.0
+ flDecayTime: FLOAT; // [0.1, 20.0] default: 1.49s
+ flDecayHFRatio: FLOAT; // [0.1, 2.0] default: 0.83
+ lReflections: Longint; // [-10000, 1000] default: -2602 mB
+ flReflectionsDelay: FLOAT; // [0.0, 0.3] default: 0.007 s
+ lReverb: Longint; // [-10000, 2000] default: 200 mB
+ flReverbDelay: FLOAT; // [0.0, 0.1] default: 0.011 s
+ flDiffusion: FLOAT; // [0.0, 100.0] default: 100.0 %
+ flDensity: FLOAT; // [0.0, 100.0] default: 100.0 %
+ flHFReference: FLOAT; // [20.0, 20000.0] default: 5000.0 Hz
+ end;
+
+ BASS_FXPARAMEQ = record
+ fCenter: FLOAT;
+ fBandwidth: FLOAT;
+ fGain: FLOAT;
+ end;
+
+ BASS_FXREVERB = record
+ fInGain: FLOAT; // [-96.0,0.0] default: 0.0 dB
+ fReverbMix: FLOAT; // [-96.0,0.0] default: 0.0 db
+ fReverbTime: FLOAT; // [0.001,3000.0] default: 1000.0 ms
+ fHighFreqRTRatio: FLOAT; // [0.001,0.999] default: 0.001
+ end;
+
+ // callback function types
+ STREAMPROC = function(handle: HSTREAM; buffer: Pointer; length: DWORD; user: DWORD): DWORD; stdcall;
+ {
+ User stream callback function. NOTE: A stream function should obviously be as
+ quick as possible, other streams (and MOD musics) can't be mixed until
+ it's finished.
+ handle : The stream that needs writing
+ buffer : Buffer to write the samples in
+ length : Number of bytes to write
+ user : The 'user' parameter value given when calling BASS_StreamCreate
+ RETURN : Number of bytes written. Set the BASS_STREAMPROC_END flag to end
+ the stream.
+ }
+
+ STREAMFILEPROC = function(action, param1, param2, user: DWORD): DWORD; stdcall;
+ {
+ User file stream callback function.
+ action : The action to perform, one of BASS_FILE_xxx values.
+ param1 : Depends on "action"
+ param2 : Depends on "action"
+ user : The 'user' parameter value given when calling BASS_StreamCreate
+ RETURN : Depends on "action"
+ }
+
+ DOWNLOADPROC = procedure(buffer: Pointer; length: DWORD; user: DWORD); stdcall;
+ {
+ Internet stream download callback function.
+ buffer : Buffer containing the downloaded data... NULL=end of download
+ length : Number of bytes in the buffer
+ user : The 'user' parameter value given when calling BASS_StreamCreateURL
+ }
+
+ SYNCPROC = procedure(handle: HSYNC; channel, data: DWORD; user: DWORD); stdcall;
+ {
+ Sync callback function. NOTE: a sync callback function should be very
+ quick as other syncs cannot be processed until it has finished. If the
+ sync is a "mixtime" sync, then other streams and MOD musics can not be
+ mixed until it's finished either.
+ handle : The sync that has occured
+ channel: Channel that the sync occured in
+ data : Additional data associated with the sync's occurance
+ user : The 'user' parameter given when calling BASS_ChannelSetSync
+ }
+
+ DSPPROC = procedure(handle: HDSP; channel: DWORD; buffer: Pointer; length: DWORD; user: DWORD); stdcall;
+ {
+ DSP callback function. NOTE: A DSP function should obviously be as quick
+ as possible... other DSP functions, streams and MOD musics can not be
+ processed until it's finished.
+ handle : The DSP handle
+ channel: Channel that the DSP is being applied to
+ buffer : Buffer to apply the DSP to
+ length : Number of bytes in the buffer
+ user : The 'user' parameter given when calling BASS_ChannelSetDSP
+ }
+
+ RECORDPROC = function(handle: HRECORD; buffer: Pointer; length: DWORD; user: DWORD): BOOL; stdcall;
+ {
+ Recording callback function.
+ handle : The recording handle
+ buffer : Buffer containing the recorded sample data
+ length : Number of bytes
+ user : The 'user' parameter value given when calling BASS_RecordStart
+ RETURN : TRUE = continue recording, FALSE = stop
+ }
+
+
+// Functions
+const
+ bassdll = 'bass.dll';
+
+function BASS_SetConfig(option, value: DWORD): DWORD; stdcall; external bassdll;
+function BASS_GetConfig(option: DWORD): DWORD; stdcall; external bassdll;
+function BASS_GetVersion: DWORD; stdcall; external bassdll;
+function BASS_GetDeviceDescription(device: DWORD): PChar; stdcall; external bassdll;
+function BASS_ErrorGetCode: Integer; stdcall; external bassdll;
+function BASS_Init(device: Integer; freq, flags: DWORD; win: HWND; clsid: PGUID): BOOL; stdcall; external bassdll;
+function BASS_SetDevice(device: DWORD): BOOL; stdcall; external bassdll;
+function BASS_GetDevice: DWORD; stdcall; external bassdll;
+function BASS_Free: BOOL; stdcall; external bassdll;
+function BASS_GetDSoundObject(obj: DWORD): Pointer; stdcall; external bassdll;
+function BASS_GetInfo(var info: BASS_INFO): BOOL; stdcall; external bassdll;
+function BASS_Update: BOOL; stdcall; external bassdll;
+function BASS_GetCPU: FLOAT; stdcall; external bassdll;
+function BASS_Start: BOOL; stdcall; external bassdll;
+function BASS_Stop: BOOL; stdcall; external bassdll;
+function BASS_Pause: BOOL; stdcall; external bassdll;
+function BASS_SetVolume(volume: DWORD): BOOL; stdcall; external bassdll;
+function BASS_GetVolume: Integer; stdcall; external bassdll;
+
+function BASS_PluginLoad(filename: PChar; flags: DWORD): HPLUGIN; stdcall; external bassdll;
+function BASS_PluginFree(handle: HPLUGIN): BOOL; stdcall; external bassdll;
+function BASS_PluginGetInfo(handle: HPLUGIN): PBASS_PLUGININFO; stdcall; external bassdll;
+
+function BASS_Set3DFactors(distf, rollf, doppf: FLOAT): BOOL; stdcall; external bassdll;
+function BASS_Get3DFactors(var distf, rollf, doppf: FLOAT): BOOL; stdcall; external bassdll;
+function BASS_Set3DPosition(var pos, vel, front, top: BASS_3DVECTOR): BOOL; stdcall; external bassdll;
+function BASS_Get3DPosition(var pos, vel, front, top: BASS_3DVECTOR): BOOL; stdcall; external bassdll;
+procedure BASS_Apply3D; stdcall; external bassdll;
+function BASS_SetEAXParameters(env: Integer; vol, decay, damp: FLOAT): BOOL; stdcall; external bassdll;
+function BASS_GetEAXParameters(var env: DWORD; var vol, decay, damp: FLOAT): BOOL; stdcall; external bassdll;
+
+function BASS_MusicLoad(mem: BOOL; f: Pointer; offset, length, flags, freq: DWORD): HMUSIC; stdcall; external bassdll;
+function BASS_MusicFree(handle: HMUSIC): BOOL; stdcall; external bassdll;
+function BASS_MusicSetAttribute(handle: HMUSIC; attrib,value: DWORD): DWORD; stdcall; external bassdll;
+function BASS_MusicGetAttribute(handle: HMUSIC; attrib: DWORD): DWORD; stdcall; external bassdll;
+function BASS_MusicGetOrders(handle: HMUSIC): DWORD; stdcall; external bassdll;
+function BASS_MusicGetOrderPosition(handle: HMUSIC): DWORD; stdcall; external bassdll;
+
+function BASS_SampleLoad(mem: BOOL; f: Pointer; offset, length, max, flags: DWORD): HSAMPLE; stdcall; external bassdll;
+function BASS_SampleCreate(length, freq, chans, max, flags: DWORD): Pointer; stdcall; external bassdll;
+function BASS_SampleCreateDone: HSAMPLE; stdcall; external bassdll;
+function BASS_SampleFree(handle: HSAMPLE): BOOL; stdcall; external bassdll;
+function BASS_SampleGetInfo(handle: HSAMPLE; var info: BASS_SAMPLE): BOOL; stdcall; external bassdll;
+function BASS_SampleSetInfo(handle: HSAMPLE; var info: BASS_SAMPLE): BOOL; stdcall; external bassdll;
+function BASS_SampleGetChannel(handle: HSAMPLE; onlynew: BOOL): HCHANNEL; stdcall; external bassdll;
+function BASS_SampleGetChannels(handle: HSAMPLE; channels: Pointer): DWORD; stdcall; external bassdll;
+function BASS_SampleStop(handle: HSAMPLE): BOOL; stdcall; external bassdll;
+
+function BASS_StreamCreate(freq, chans, flags: DWORD; proc: Pointer; user: DWORD): HSTREAM; stdcall; external bassdll;
+function BASS_StreamCreateFile(mem: BOOL; f: Pointer; offset, length, flags: DWORD): HSTREAM; stdcall; external bassdll;
+function BASS_StreamCreateURL(url: PChar; offset: DWORD; flags: DWORD; proc: DOWNLOADPROC; user: DWORD):HSTREAM; stdcall; external bassdll;
+function BASS_StreamCreateFileUser(buffered: BOOL; flags: DWORD; proc: STREAMFILEPROC; user: DWORD): HSTREAM; stdcall; external bassdll;
+function BASS_StreamFree(handle: HSTREAM): BOOL; stdcall; external bassdll;
+function BASS_StreamGetFilePosition(handle:HSTREAM; mode:DWORD) : DWORD;stdcall;external bassdll;
+
+function BASS_RecordGetDeviceDescription(devnum: DWORD):PChar;stdcall;external bassdll;
+function BASS_RecordInit(device: Integer):BOOL;stdcall;external bassdll;
+function BASS_RecordSetDevice(device: DWORD): BOOL; stdcall; external bassdll;
+function BASS_RecordGetDevice: DWORD; stdcall; external bassdll;
+function BASS_RecordFree:BOOL;stdcall;external bassdll;
+function BASS_RecordGetInfo(var info:BASS_RECORDINFO):BOOL;stdcall;external bassdll;
+function BASS_RecordGetInputName(input:Integer):PChar;stdcall;external bassdll;
+function BASS_RecordSetInput(input:Integer; setting:DWORD):BOOL;stdcall;external bassdll;
+function BASS_RecordGetInput(input:Integer):DWORD;stdcall;external bassdll;
+function BASS_RecordStart(freq,chans,flags:DWORD; proc:RECORDPROC; user:DWORD):HRECORD;stdcall;external bassdll;
+
+function BASS_ChannelBytes2Seconds(handle: DWORD; pos: QWORD): FLOAT; stdcall;external bassdll;
+function BASS_ChannelSeconds2Bytes(handle: DWORD; pos: FLOAT): QWORD; stdcall;external bassdll;
+function BASS_ChannelGetDevice(handle: DWORD): DWORD; stdcall; external bassdll;
+function BASS_ChannelSetDevice(handle, device: DWORD): BOOL; stdcall; external bassdll;
+function BASS_ChannelIsActive(handle: DWORD): DWORD; stdcall;external bassdll;
+function BASS_ChannelGetInfo(handle: DWORD; var info:BASS_CHANNELINFO):BOOL;stdcall;external bassdll;
+function BASS_ChannelGetTags(handle: HSTREAM; tags : DWORD): PChar; stdcall; external bassdll;
+function BASS_ChannelSetFlags(handle, flags: DWORD): BOOL; stdcall; external bassdll;
+function BASS_ChannelPreBuf(handle, length: DWORD): BOOL; stdcall; external bassdll;
+function BASS_ChannelPlay(handle: DWORD; restart: BOOL): BOOL; stdcall; external bassdll;
+function BASS_ChannelStop(handle: DWORD): BOOL; stdcall; external bassdll;
+function BASS_ChannelPause(handle: DWORD): BOOL; stdcall; external bassdll;
+function BASS_ChannelSetAttributes(handle: DWORD; freq, volume, pan: Integer): BOOL; stdcall; external bassdll;
+function BASS_ChannelGetAttributes(handle: DWORD; var freq, volume: DWORD; var pan: Integer): BOOL; stdcall; external bassdll;
+function BASS_ChannelSlideAttributes(handle: DWORD; freq, volume, pan: Integer; time: DWORD): BOOL; stdcall; external bassdll;
+function BASS_ChannelIsSliding(handle: DWORD): DWORD; stdcall;external bassdll;
+function BASS_ChannelSet3DAttributes(handle: DWORD; mode: Integer; min, max: FLOAT; iangle, oangle, outvol: Integer): BOOL; stdcall; external bassdll;
+function BASS_ChannelGet3DAttributes(handle: DWORD; var mode: DWORD; var min, max: FLOAT; var iangle, oangle, outvol: DWORD): BOOL; stdcall; external bassdll;
+function BASS_ChannelSet3DPosition(handle: DWORD; var pos, orient, vel: BASS_3DVECTOR): BOOL; stdcall; external bassdll;
+function BASS_ChannelGet3DPosition(handle: DWORD; var pos, orient, vel: BASS_3DVECTOR): BOOL; stdcall; external bassdll;
+function BASS_ChannelGetLength(handle: DWORD): QWORD; stdcall; external bassdll;
+function BASS_ChannelSetPosition(handle: DWORD; pos: QWORD): BOOL; stdcall; external bassdll;
+function BASS_ChannelGetPosition(handle: DWORD): QWORD; stdcall; external bassdll;
+function BASS_ChannelGetLevel(handle: DWORD): DWORD; stdcall; external bassdll;
+function BASS_ChannelGetData(handle: DWORD; buffer: Pointer; length: DWORD): DWORD; stdcall; external bassdll;
+function BASS_ChannelSetSync(handle: DWORD; stype: DWORD; param: QWORD; proc: SYNCPROC; user: DWORD): HSYNC; stdcall; external bassdll;
+function BASS_ChannelRemoveSync(handle: DWORD; sync: HSYNC): BOOL; stdcall; external bassdll;
+function BASS_ChannelSetDSP(handle: DWORD; proc: DSPPROC; user: DWORD; priority: Integer): HDSP; stdcall; external bassdll;
+function BASS_ChannelRemoveDSP(handle: DWORD; dsp: HDSP): BOOL; stdcall; external bassdll;
+function BASS_ChannelSetEAXMix(handle: DWORD; mix: FLOAT): BOOL; stdcall; external bassdll;
+function BASS_ChannelGetEAXMix(handle: DWORD; var mix: FLOAT): BOOL; stdcall; external bassdll;
+function BASS_ChannelSetLink(handle, chan: DWORD): BOOL; stdcall; external bassdll;
+function BASS_ChannelRemoveLink(handle, chan: DWORD): BOOL; stdcall; external bassdll;
+function BASS_ChannelSetFX(handle, etype: DWORD; priority: Integer): HFX; stdcall; external bassdll;
+function BASS_ChannelRemoveFX(handle: DWORD; fx: HFX): BOOL; stdcall; external bassdll;
+
+function BASS_FXSetParameters(handle: HFX; par: Pointer): BOOL; stdcall; external bassdll;
+function BASS_FXGetParameters(handle: HFX; par: Pointer): BOOL; stdcall; external bassdll;
+function BASS_FXReset(handle: HFX): BOOL; stdcall; external bassdll;
+
+
+function BASS_SPEAKER_N(n: DWORD): DWORD;
+function MAKEMUSICPOS(order,row: DWORD): DWORD;
+function BASS_SetEAXPreset(env: Integer): BOOL;
+{
+ This function is defined in the implementation part of this unit.
+ It is not part of BASS.DLL but an extra function which makes it easier
+ to set the predefined EAX environments.
+ env : a EAX_ENVIRONMENT_xxx constant
+}
+
+
+implementation
+
+function BASS_SPEAKER_N(n: DWORD): DWORD;
+begin
+ Result := n shl 24;
+end;
+
+function MAKEMUSICPOS(order,row: DWORD): DWORD;
+begin
+ Result := $80000000 or DWORD(MAKELONG(order,row));
+end;
+
+function BASS_SetEAXPreset(env: Integer): BOOL;
+begin
+ case (env) of
+ EAX_ENVIRONMENT_GENERIC:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_GENERIC, 0.5, 1.493, 0.5);
+ EAX_ENVIRONMENT_PADDEDCELL:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_PADDEDCELL, 0.25, 0.1, 0);
+ EAX_ENVIRONMENT_ROOM:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_ROOM, 0.417, 0.4, 0.666);
+ EAX_ENVIRONMENT_BATHROOM:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_BATHROOM, 0.653, 1.499, 0.166);
+ EAX_ENVIRONMENT_LIVINGROOM:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_LIVINGROOM, 0.208, 0.478, 0);
+ EAX_ENVIRONMENT_STONEROOM:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_STONEROOM, 0.5, 2.309, 0.888);
+ EAX_ENVIRONMENT_AUDITORIUM:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_AUDITORIUM, 0.403, 4.279, 0.5);
+ EAX_ENVIRONMENT_CONCERTHALL:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_CONCERTHALL, 0.5, 3.961, 0.5);
+ EAX_ENVIRONMENT_CAVE:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_CAVE, 0.5, 2.886, 1.304);
+ EAX_ENVIRONMENT_ARENA:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_ARENA, 0.361, 7.284, 0.332);
+ EAX_ENVIRONMENT_HANGAR:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_HANGAR, 0.5, 10.0, 0.3);
+ EAX_ENVIRONMENT_CARPETEDHALLWAY:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_CARPETEDHALLWAY, 0.153, 0.259, 2.0);
+ EAX_ENVIRONMENT_HALLWAY:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_HALLWAY, 0.361, 1.493, 0);
+ EAX_ENVIRONMENT_STONECORRIDOR:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_STONECORRIDOR, 0.444, 2.697, 0.638);
+ EAX_ENVIRONMENT_ALLEY:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_ALLEY, 0.25, 1.752, 0.776);
+ EAX_ENVIRONMENT_FOREST:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_FOREST, 0.111, 3.145, 0.472);
+ EAX_ENVIRONMENT_CITY:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_CITY, 0.111, 2.767, 0.224);
+ EAX_ENVIRONMENT_MOUNTAINS:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_MOUNTAINS, 0.194, 7.841, 0.472);
+ EAX_ENVIRONMENT_QUARRY:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_QUARRY, 1, 1.499, 0.5);
+ EAX_ENVIRONMENT_PLAIN:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_PLAIN, 0.097, 2.767, 0.224);
+ EAX_ENVIRONMENT_PARKINGLOT:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_PARKINGLOT, 0.208, 1.652, 1.5);
+ EAX_ENVIRONMENT_SEWERPIPE:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_SEWERPIPE, 0.652, 2.886, 0.25);
+ EAX_ENVIRONMENT_UNDERWATER:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_UNDERWATER, 1, 1.499, 0);
+ EAX_ENVIRONMENT_DRUGGED:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_DRUGGED, 0.875, 8.392, 1.388);
+ EAX_ENVIRONMENT_DIZZY:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_DIZZY, 0.139, 17.234, 0.666);
+ EAX_ENVIRONMENT_PSYCHOTIC:
+ Result := BASS_SetEAXParameters(EAX_ENVIRONMENT_PSYCHOTIC, 0.486, 7.563, 0.806);
+ else
+ Result := FALSE;
+ end;
+end;
+
+end.
+// END OF FILE /////////////////////////////////////////////////////////////////
+
diff --git a/Game/Code/lib/bass/lazarustest.lpi b/Game/Code/lib/bass/lazarustest.lpi new file mode 100644 index 00000000..fd0f1c9c --- /dev/null +++ b/Game/Code/lib/bass/lazarustest.lpi @@ -0,0 +1,192 @@ +<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="\"/>
+ <Version Value="5"/>
+ <General>
+ <MainUnit Value="0"/>
+ <TargetFileExt Value=".exe"/>
+ <ActiveEditorIndexAtStart Value="0"/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ <Language Value=""/>
+ <CharSet Value=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <IgnoreBinaries Value="False"/>
+ <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
+ <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
+ </local>
+ </RunParams>
+ <Units Count="2">
+ <Unit0>
+ <Filename Value="lazarustest.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="lazarustest"/>
+ <CursorPos X="38" Y="33"/>
+ <TopLine Value="10"/>
+ <EditorIndex Value="0"/>
+ <UsageCount Value="20"/>
+ <Loaded Value="True"/>
+ </Unit0>
+ <Unit1>
+ <Filename Value="delphi\bass.pas"/>
+ <UnitName Value="Bass"/>
+ <CursorPos X="12" Y="539"/>
+ <TopLine Value="589"/>
+ <EditorIndex Value="1"/>
+ <UsageCount Value="10"/>
+ <Loaded Value="True"/>
+ </Unit1>
+ </Units>
+ <JumpHistory Count="30" HistoryIndex="29">
+ <Position1>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="778" Column="59" TopLine="758"/>
+ </Position1>
+ <Position2>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="779" Column="84" TopLine="759"/>
+ </Position2>
+ <Position3>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="780" Column="63" TopLine="760"/>
+ </Position3>
+ <Position4>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="781" Column="114" TopLine="761"/>
+ </Position4>
+ <Position5>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="782" Column="72" TopLine="762"/>
+ </Position5>
+ <Position6>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="783" Column="58" TopLine="763"/>
+ </Position6>
+ <Position7>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="784" Column="52" TopLine="764"/>
+ </Position7>
+ <Position8>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="785" Column="78" TopLine="765"/>
+ </Position8>
+ <Position9>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="786" Column="76" TopLine="766"/>
+ </Position9>
+ <Position10>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="787" Column="54" TopLine="767"/>
+ </Position10>
+ <Position11>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="788" Column="55" TopLine="768"/>
+ </Position11>
+ <Position12>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="789" Column="53" TopLine="769"/>
+ </Position12>
+ <Position13>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="790" Column="52" TopLine="770"/>
+ </Position13>
+ <Position14>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="791" Column="53" TopLine="771"/>
+ </Position14>
+ <Position15>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="792" Column="72" TopLine="772"/>
+ </Position15>
+ <Position16>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="793" Column="60" TopLine="773"/>
+ </Position16>
+ <Position17>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="795" Column="92" TopLine="775"/>
+ </Position17>
+ <Position18>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="796" Column="75" TopLine="776"/>
+ </Position18>
+ <Position19>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="11" Column="42" TopLine="1"/>
+ </Position19>
+ <Position20>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="786" Column="42" TopLine="762"/>
+ </Position20>
+ <Position21>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="1" Column="1" TopLine="1"/>
+ </Position21>
+ <Position22>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="74" Column="73" TopLine="54"/>
+ </Position22>
+ <Position23>
+ <Filename Value="delphi\bass.pas"/>
+ <Caret Line="82" Column="15" TopLine="62"/>
+ </Position23>
+ <Position24>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="43" Column="67" TopLine="6"/>
+ </Position24>
+ <Position25>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="7" Column="9" TopLine="1"/>
+ </Position25>
+ <Position26>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="16" Column="12" TopLine="1"/>
+ </Position26>
+ <Position27>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="7" Column="1" TopLine="1"/>
+ </Position27>
+ <Position28>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="15" Column="9" TopLine="1"/>
+ </Position28>
+ <Position29>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="17" Column="58" TopLine="1"/>
+ </Position29>
+ <Position30>
+ <Filename Value="lazarustest.lpr"/>
+ <Caret Line="22" Column="32" TopLine="2"/>
+ </Position30>
+ </JumpHistory>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <PathDelim Value="\"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+ <Debugging>
+ <Exceptions Count="2">
+ <Item1>
+ <Name Value="ECodetoolError"/>
+ </Item1>
+ <Item2>
+ <Name Value="EFOpenError"/>
+ </Item2>
+ </Exceptions>
+ </Debugging>
+</CONFIG>
diff --git a/Game/Code/lib/bass/lazarustest.lpr b/Game/Code/lib/bass/lazarustest.lpr new file mode 100644 index 00000000..6faee86d --- /dev/null +++ b/Game/Code/lib/bass/lazarustest.lpr @@ -0,0 +1,51 @@ +program lazarustest;
+
+{$mode objfpc}{$H+}
+
+uses
+ sysutils,
+ bass in 'delphi\bass.pas'
+ { add your units here };
+
+var
+ chan : HSTREAM;
+
+begin
+ // check the correct BASS was loaded
+ if (hi(BASS_GetVersion) <> BASSVERSION) then
+ begin
+ writeln('An incorrect version of BASS.DLL was loaded');
+ Halt;
+ end;
+
+ //init BASS
+ if not BASS_Init(0,44100,0,0,nil) then
+ writeln('Can''t initialize device');
+
+ //creating stream
+ if fileexists( 'music.mp3 ') then
+ begin
+ chan := BASS_StreamCreateFile(FALSE,pchar('music.mp3'),0,0,0);
+ if chan = 0 then
+ begin
+ chan := BASS_MusicLoad(False, pchar('music.mp3'), 0, 0, BASS_MUSIC_RAMPS or BASS_MUSIC_POSRESET or BASS_MUSIC_PRESCAN, 0);
+ if (chan = 0) then
+ begin
+ writeln('Can''t play file');
+ Exit;
+ end;
+ end;
+
+ BASS_ChannelPlay(chan,FALSE); // start playing
+ end
+ else
+ begin
+ writeln( 'music.mp3 not found.. could not test mp3 playback');
+ end;
+
+ BASS_Free();
+ writeln( 'Seems BASS is compatible with lazarus :) ');
+
+
+end.
+
diff --git a/Game/Code/lib/bass/libbass.dylib b/Game/Code/lib/bass/libbass.dylib Binary files differnew file mode 100755 index 00000000..1168bd07 --- /dev/null +++ b/Game/Code/lib/bass/libbass.dylib diff --git a/Game/Code/lib/ffmpeg/avcodec.pas b/Game/Code/lib/ffmpeg/avcodec.pas new file mode 100644 index 00000000..cdb9b7d4 --- /dev/null +++ b/Game/Code/lib/ffmpeg/avcodec.pas @@ -0,0 +1,3225 @@ +(* + * copyright (c) 2001 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(* This is a part of Pascal porting of ffmpeg. + * Originally by Victor Zinetz for Delphi and Free Pascal on Windows. + * For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT + * in the source codes *) + +(* + * Min. version: 51.16.0 + * Max. version: 51.50.0, Revision: 11878, Wed Feb 6 12:37:37 2008 UTC + *) + +unit avcodec; + +{$IFDEF FPC} + {$MODE DELPHI } + {$PACKENUM 4} (* use 4-byte enums *) + {$PACKRECORDS C} (* C/C++-compatible record packing *) +{$ELSE} + {$MINENUMSIZE 4} (* use 4-byte enums *) +{$ENDIF} + +interface + +uses + avutil, + rational, + opt, + UConfig; + +const + (* Max. supported version by this header *) + LIBAVCODEC_MAX_VERSION_MAJOR = 51; + LIBAVCODEC_MAX_VERSION_MINOR = 50; + LIBAVCODEC_MAX_VERSION_RELEASE = 0; + LIBAVCODEC_MAX_VERSION = (LIBAVCODEC_MAX_VERSION_MAJOR * VERSION_MAJOR) + + (LIBAVCODEC_MAX_VERSION_MINOR * VERSION_MINOR) + + (LIBAVCODEC_MAX_VERSION_RELEASE * VERSION_RELEASE); + +(* Check if linked version is supported *) +{$IF (LIBAVCODEC_VERSION > LIBAVCODEC_MAX_VERSION)} + {$MESSAGE Warn 'Linked version of libavcodec may be unsupported!'} +{$IFEND} + +const + AV_NOPTS_VALUE: int64 = $8000000000000000; + AV_TIME_BASE = 1000000; + AV_TIME_BASE_Q : TAVRational = (num:1; den:AV_TIME_BASE); (* added by CAT *) + +(** + * Identifies the syntax and semantics of the bitstream. + * The principle is roughly: + * Two decoders with the same ID can decode the same streams. + * Two encoders with the same ID can encode compatible streams. + * There may be slight deviations from the principle due to implementation + * details. + * + * If you add a codec ID to this list, add it so that + * 1. no value of a existing codec ID changes (that would break ABI), + * 2. it is as close as possible to similar codecs. + *) +type + TCodecID = ( + CODEC_ID_NONE, + CODEC_ID_MPEG1VIDEO, + CODEC_ID_MPEG2VIDEO, //* prefered ID for MPEG Video 1/2 decoding */ + CODEC_ID_MPEG2VIDEO_XVMC, + CODEC_ID_H261, + CODEC_ID_H263, + CODEC_ID_RV10, + CODEC_ID_RV20, + CODEC_ID_MJPEG, + CODEC_ID_MJPEGB, + CODEC_ID_LJPEG, + CODEC_ID_SP5X, + CODEC_ID_JPEGLS, + CODEC_ID_MPEG4, + CODEC_ID_RAWVIDEO, + CODEC_ID_MSMPEG4V1, + CODEC_ID_MSMPEG4V2, + CODEC_ID_MSMPEG4V3, + CODEC_ID_WMV1, + CODEC_ID_WMV2, + CODEC_ID_H263P, + CODEC_ID_H263I, + CODEC_ID_FLV1, + CODEC_ID_SVQ1, + CODEC_ID_SVQ3, + CODEC_ID_DVVIDEO, + CODEC_ID_HUFFYUV, + CODEC_ID_CYUV, + CODEC_ID_H264, + CODEC_ID_INDEO3, + CODEC_ID_VP3, + CODEC_ID_THEORA, + CODEC_ID_ASV1, + CODEC_ID_ASV2, + CODEC_ID_FFV1, + CODEC_ID_4XM, + CODEC_ID_VCR1, + CODEC_ID_CLJR, + CODEC_ID_MDEC, + CODEC_ID_ROQ, + CODEC_ID_INTERPLAY_VIDEO, + CODEC_ID_XAN_WC3, + CODEC_ID_XAN_WC4, + CODEC_ID_RPZA, + CODEC_ID_CINEPAK, + CODEC_ID_WS_VQA, + CODEC_ID_MSRLE, + CODEC_ID_MSVIDEO1, + CODEC_ID_IDCIN, + CODEC_ID_8BPS, + CODEC_ID_SMC, + CODEC_ID_FLIC, + CODEC_ID_TRUEMOTION1, + CODEC_ID_VMDVIDEO, + CODEC_ID_MSZH, + CODEC_ID_ZLIB, + CODEC_ID_QTRLE, + CODEC_ID_SNOW, + CODEC_ID_TSCC, + CODEC_ID_ULTI, + CODEC_ID_QDRAW, + CODEC_ID_VIXL, + CODEC_ID_QPEG, + CODEC_ID_XVID, + CODEC_ID_PNG, + CODEC_ID_PPM, + CODEC_ID_PBM, + CODEC_ID_PGM, + CODEC_ID_PGMYUV, + CODEC_ID_PAM, + CODEC_ID_FFVHUFF, + CODEC_ID_RV30, + CODEC_ID_RV40, + CODEC_ID_VC1, + CODEC_ID_WMV3, + CODEC_ID_LOCO, + CODEC_ID_WNV1, + CODEC_ID_AASC, + CODEC_ID_INDEO2, + CODEC_ID_FRAPS, + CODEC_ID_TRUEMOTION2, + CODEC_ID_BMP, + CODEC_ID_CSCD, + CODEC_ID_MMVIDEO, + CODEC_ID_ZMBV, + CODEC_ID_AVS, + CODEC_ID_SMACKVIDEO, + CODEC_ID_NUV, + CODEC_ID_KMVC, + CODEC_ID_FLASHSV, + CODEC_ID_CAVS, + CODEC_ID_JPEG2000, + CODEC_ID_VMNC, + CODEC_ID_VP5, + CODEC_ID_VP6, + CODEC_ID_VP6F, + CODEC_ID_TARGA, + CODEC_ID_DSICINVIDEO, + CODEC_ID_TIERTEXSEQVIDEO, + CODEC_ID_TIFF, + CODEC_ID_GIF, + CODEC_ID_FFH264, + CODEC_ID_DXA, + CODEC_ID_DNXHD, + CODEC_ID_THP, + CODEC_ID_SGI, + CODEC_ID_C93, + CODEC_ID_BETHSOFTVID, + CODEC_ID_PTX, + CODEC_ID_TXD, + CODEC_ID_VP6A, + CODEC_ID_AMV, + CODEC_ID_VB, + CODEC_ID_PCX, + CODEC_ID_SUNRAST, + + //* various PCM "codecs" */ + CODEC_ID_PCM_S16LE= $10000, + CODEC_ID_PCM_S16BE, + CODEC_ID_PCM_U16LE, + CODEC_ID_PCM_U16BE, + CODEC_ID_PCM_S8, + CODEC_ID_PCM_U8, + CODEC_ID_PCM_MULAW, + CODEC_ID_PCM_ALAW, + CODEC_ID_PCM_S32LE, + CODEC_ID_PCM_S32BE, + CODEC_ID_PCM_U32LE, + CODEC_ID_PCM_U32BE, + CODEC_ID_PCM_S24LE, + CODEC_ID_PCM_S24BE, + CODEC_ID_PCM_U24LE, + CODEC_ID_PCM_U24BE, + CODEC_ID_PCM_S24DAUD, + CODEC_ID_PCM_ZORK, + CODEC_ID_PCM_S16LE_PLANAR, + + //* various ADPCM codecs */ + CODEC_ID_ADPCM_IMA_QT= $11000, + CODEC_ID_ADPCM_IMA_WAV, + CODEC_ID_ADPCM_IMA_DK3, + CODEC_ID_ADPCM_IMA_DK4, + CODEC_ID_ADPCM_IMA_WS, + CODEC_ID_ADPCM_IMA_SMJPEG, + CODEC_ID_ADPCM_MS, + CODEC_ID_ADPCM_4XM, + CODEC_ID_ADPCM_XA, + CODEC_ID_ADPCM_ADX, + CODEC_ID_ADPCM_EA, + CODEC_ID_ADPCM_G726, + CODEC_ID_ADPCM_CT, + CODEC_ID_ADPCM_SWF, + CODEC_ID_ADPCM_YAMAHA, + CODEC_ID_ADPCM_SBPRO_4, + CODEC_ID_ADPCM_SBPRO_3, + CODEC_ID_ADPCM_SBPRO_2, + CODEC_ID_ADPCM_THP, + CODEC_ID_ADPCM_IMA_AMV, + CODEC_ID_ADPCM_EA_R1, + CODEC_ID_ADPCM_EA_R3, + CODEC_ID_ADPCM_EA_R2, + CODEC_ID_ADPCM_IMA_EA_SEAD, + CODEC_ID_ADPCM_IMA_EA_EACS, + CODEC_ID_ADPCM_EA_XAS, + + //* AMR */ + CODEC_ID_AMR_NB= $12000, + CODEC_ID_AMR_WB, + + //* RealAudio codecs*/ + CODEC_ID_RA_144= $13000, + CODEC_ID_RA_288, + + //* various DPCM codecs */ + CODEC_ID_ROQ_DPCM= $14000, + CODEC_ID_INTERPLAY_DPCM, + CODEC_ID_XAN_DPCM, + CODEC_ID_SOL_DPCM, + + CODEC_ID_MP2= $15000, + CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 + CODEC_ID_AAC, + {$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 + _CODEC_ID_MPEG4AAC, // will be redefined to CODEC_ID_AAC below + {$IFEND} + CODEC_ID_AC3, + CODEC_ID_DTS, + CODEC_ID_VORBIS, + CODEC_ID_DVAUDIO, + CODEC_ID_WMAV1, + CODEC_ID_WMAV2, + CODEC_ID_MACE3, + CODEC_ID_MACE6, + CODEC_ID_VMDAUDIO, + CODEC_ID_SONIC, + CODEC_ID_SONIC_LS, + CODEC_ID_FLAC, + CODEC_ID_MP3ADU, + CODEC_ID_MP3ON4, + CODEC_ID_SHORTEN, + CODEC_ID_ALAC, + CODEC_ID_WESTWOOD_SND1, + CODEC_ID_GSM, ///< as in Berlin toast format + CODEC_ID_QDM2, + CODEC_ID_COOK, + CODEC_ID_TRUESPEECH, + CODEC_ID_TTA, + CODEC_ID_SMACKAUDIO, + CODEC_ID_QCELP, + CODEC_ID_WAVPACK, + CODEC_ID_DSICINAUDIO, + CODEC_ID_IMC, + CODEC_ID_MUSEPACK7, + CODEC_ID_MLP, + CODEC_ID_GSM_MS, { as found in WAV } + CODEC_ID_ATRAC3, + CODEC_ID_VOXWARE, + CODEC_ID_APE, + CODEC_ID_NELLYMOSER, + CODEC_ID_MUSEPACK8, + CODEC_ID_SPEEX, + + //* subtitle codecs */ + CODEC_ID_DVD_SUBTITLE= $17000, + CODEC_ID_DVB_SUBTITLE, + CODEC_ID_TEXT, ///< raw UTF-8 text + CODEC_ID_XSUB, + CODEC_ID_SSA, + CODEC_ID_MOV_TEXT, + + (* other specific kind of codecs (generaly used for attachments) *) + CODEC_ID_TTF= $18000, + + CODEC_ID_MPEG2TS= $20000, {*< _FAKE_ codec to indicate a raw MPEG-2 TS + * stream (only used by libavformat) *} + __CODEC_ID_4BYTE = $FFFFF // ensure 4-byte enum + ); + +{$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 +{* CODEC_ID_MP3LAME is obsolete *} +const + CODEC_ID_MP3LAME = CODEC_ID_MP3; + CODEC_ID_MPEG4AAC = CODEC_ID_AAC; +{$IFEND} + +type + TCodecType = ( + CODEC_TYPE_UNKNOWN = -1, + CODEC_TYPE_VIDEO, + CODEC_TYPE_AUDIO, + CODEC_TYPE_DATA, + CODEC_TYPE_SUBTITLE, + CODEC_TYPE_ATTACHMENT, + CODEC_TYPE_NB + ); + +{** + * currently unused, may be used if 24/32 bits samples ever supported */ + * all in native endian + *} +type + TSampleFormat = ( + SAMPLE_FMT_NONE = -1, + SAMPLE_FMT_U8, ///< unsigned 8 bits + SAMPLE_FMT_S16, ///< signed 16 bits + SAMPLE_FMT_S24, ///< signed 24 bits + SAMPLE_FMT_S32, ///< signed 32 bits + SAMPLE_FMT_FLT ///< float + ); + +const + {* in bytes *} + AVCODEC_MAX_AUDIO_FRAME_SIZE = 192000; // 1 second of 48khz 32bit audio + +{** + * Required number of additionally allocated bytes at the end of the input bitstream for decoding. + * This is mainly needed because some optimized bitstream readers read + * 32 or 64 bit at once and could read over the end.<br> + * Note: If the first 23 bits of the additional bytes are not 0, then damaged + * MPEG bitstreams could cause overread and segfault. + *} + FF_INPUT_BUFFER_PADDING_SIZE = 8; + +{** + * minimum encoding buffer size. + * Used to avoid some checks during header writing. + *} + FF_MIN_BUFFER_SIZE = 16384; + +type +{* + * motion estimation type. + *} + TMotion_Est_ID = ( + ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed + ME_FULL, + ME_LOG, + ME_PHODS, + ME_EPZS, ///< enhanced predictive zonal search + ME_X1, ///< reserved for experiments + ME_HEX, ///< hexagon based search + ME_UMH, ///< uneven multi-hexagon search + ME_ITER ///< iterative search + ); + + TAVDiscard = ( + {* We leave some space between them for extensions (drop some + * keyframes for intra-only or drop just some bidir frames). *} + AVDISCARD_NONE =-16, ///< discard nothing + AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi + AVDISCARD_NONREF = 8, ///< discard all non reference + AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames + AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes + AVDISCARD_ALL = 48 ///< discard all + ); + + PRcOverride = ^TRcOverride; + TRcOverride = record {16} + start_frame: integer; + end_frame: integer; + qscale: integer; // if this is 0 then quality_factor will be used instead + quality_factor: single; + end; + +const + FF_MAX_B_FRAMES = 16; + +{* encoding support + These flags can be passed in AVCodecContext.flags before initialization. + Note: Not everything is supported yet. +*} + + CODEC_FLAG_QSCALE = $0002; ///< Use fixed qscale. + CODEC_FLAG_4MV = $0004; ///< 4 MV per MB allowed / advanced prediction for H263. + CODEC_FLAG_QPEL = $0010; ///< use qpel MC. + CODEC_FLAG_GMC = $0020; ///< use GMC. + CODEC_FLAG_MV0 = $0040; ///< always try a MB with MV=<0,0>. + CODEC_FLAG_PART = $0080; ///< Use data partitioning. + {** + * The parent program guarantees that the input for B-frames containing + * streams is not written to for at least s->max_b_frames+1 frames, if + * this is not set the input will be copied. + *} + CODEC_FLAG_INPUT_PRESERVED = $0100; + CODEC_FLAG_PASS1 = $0200; ///< use internal 2pass ratecontrol in first pass mode + CODEC_FLAG_PASS2 = $0400; ///< use internal 2pass ratecontrol in second pass mode + CODEC_FLAG_EXTERN_HUFF = $1000; ///< use external huffman table (for mjpeg) + CODEC_FLAG_GRAY = $2000; ///< only decode/encode grayscale + CODEC_FLAG_EMU_EDGE = $4000; ///< don't draw edges + CODEC_FLAG_PSNR = $8000; ///< error[?] variables will be set during encoding + CODEC_FLAG_TRUNCATED = $00010000; //** input bitstream might be truncated at a random location instead + // of only at frame boundaries */ + CODEC_FLAG_NORMALIZE_AQP = $00020000; ///< normalize adaptive quantization + CODEC_FLAG_INTERLACED_DCT = $00040000; ///< use interlaced dct + CODEC_FLAG_LOW_DELAY = $00080000; ///< force low delay + CODEC_FLAG_ALT_SCAN = $00100000; ///< use alternate scan + CODEC_FLAG_TRELLIS_QUANT = $00200000; ///< use trellis quantization + CODEC_FLAG_GLOBAL_HEADER = $00400000; ///< place global headers in extradata instead of every keyframe + CODEC_FLAG_BITEXACT = $00800000; ///< use only bitexact stuff (except (i)dct) + {* Fx : Flag for h263+ extra options *} + {$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 + CODEC_FLAG_H263P_AIC = $01000000; ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this) + {$IFEND} + CODEC_FLAG_AC_PRED = $01000000; ///< H263 Advanced intra coding / MPEG4 AC prediction + CODEC_FLAG_H263P_UMV = $02000000; ///< Unlimited motion vector + CODEC_FLAG_CBP_RD = $04000000; ///< use rate distortion optimization for cbp + CODEC_FLAG_QP_RD = $08000000; ///< use rate distortion optimization for qp selectioon + CODEC_FLAG_H263P_AIV = $00000008; ///< H263 Alternative inter vlc + CODEC_FLAG_OBMC = $00000001; ///< OBMC + CODEC_FLAG_LOOP_FILTER = $00000800; ///< loop filter + CODEC_FLAG_H263P_SLICE_STRUCT = $10000000; + CODEC_FLAG_INTERLACED_ME = $20000000; ///< interlaced motion estimation + CODEC_FLAG_SVCD_SCAN_OFFSET = $40000000; ///< will reserve space for SVCD scan offset user data + CODEC_FLAG_CLOSED_GOP = $80000000; + CODEC_FLAG2_FAST = $00000001; ///< allow non spec compliant speedup tricks + CODEC_FLAG2_STRICT_GOP = $00000002; ///< strictly enforce GOP size + CODEC_FLAG2_NO_OUTPUT = $00000004; ///< skip bitstream encoding + CODEC_FLAG2_LOCAL_HEADER = $00000008; ///< place global headers at every keyframe instead of in extradata + CODEC_FLAG2_BPYRAMID = $00000010; ///< H.264 allow b-frames to be used as references + CODEC_FLAG2_WPRED = $00000020; ///< H.264 weighted biprediction for b-frames + CODEC_FLAG2_MIXED_REFS = $00000040; ///< H.264 multiple references per partition + CODEC_FLAG2_8X8DCT = $00000080; ///< H.264 high profile 8x8 transform + CODEC_FLAG2_FASTPSKIP = $00000100; ///< H.264 fast pskip + CODEC_FLAG2_AUD = $00000200; ///< H.264 access unit delimiters + CODEC_FLAG2_BRDO = $00000400; ///< b-frame rate-distortion optimization + CODEC_FLAG2_INTRA_VLC = $00000800; ///< use MPEG-2 intra VLC table + CODEC_FLAG2_MEMC_ONLY = $00001000; ///< only do ME/MC (I frames -> ref, P frame -> ME+MC) + CODEC_FLAG2_DROP_FRAME_TIMECODE = $00002000; ///< timecode is in drop frame format. + CODEC_FLAG2_SKIP_RD = $00004000; ///< RD optimal MB level residual skipping + CODEC_FLAG2_CHUNKS = $00008000; ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. + CODEC_FLAG2_NON_LINEAR_QUANT = $00010000; ///< Use MPEG-2 nonlinear quantizer. + +(* Unsupported options : + * Syntax Arithmetic coding (SAC) + * Reference Picture Selection + * Independant Segment Decoding *) +(* /Fx *) +(* codec capabilities *) + +const + CODEC_CAP_DRAW_HORIZ_BAND = $0001; ///< decoder can use draw_horiz_band callback + (** + * Codec uses get_buffer() for allocating buffers. + * direct rendering method 1 + *) + CODEC_CAP_DR1 = $0002; + (* if 'parse_only' field is true, then avcodec_parse_frame() can be used *) + CODEC_CAP_PARSE_ONLY = $0004; + CODEC_CAP_TRUNCATED = $0008; + (* codec can export data for HW decoding (XvMC) *) + CODEC_CAP_HWACCEL = $0010; + (** + * codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data. + * if this is not set, the codec is guranteed to never be feeded with NULL data + *) + CODEC_CAP_DELAY = $0020; + (** + * Codec can be fed a final frame with a smaller size. + * This can be used to prevent truncation of the last audio samples. + *) + CODEC_CAP_SMALL_LAST_FRAME = $0040; + + //the following defines may change, don't expect compatibility if you use them + MB_TYPE_INTRA4x4 = $001; + MB_TYPE_INTRA16x16 = $002; //FIXME h264 specific + MB_TYPE_INTRA_PCM = $004; //FIXME h264 specific + MB_TYPE_16x16 = $008; + MB_TYPE_16x8 = $010; + MB_TYPE_8x16 = $020; + MB_TYPE_8x8 = $040; + MB_TYPE_INTERLACED = $080; + MB_TYPE_DIRECT2 = $100; //FIXME + MB_TYPE_ACPRED = $200; + MB_TYPE_GMC = $400; + MB_TYPE_SKIP = $800; + MB_TYPE_P0L0 = $1000; + MB_TYPE_P1L0 = $2000; + MB_TYPE_P0L1 = $4000; + MB_TYPE_P1L1 = $8000; + MB_TYPE_L0 = (MB_TYPE_P0L0 or MB_TYPE_P1L0); + MB_TYPE_L1 = (MB_TYPE_P0L1 or MB_TYPE_P1L1); + MB_TYPE_L0L1 = (MB_TYPE_L0 or MB_TYPE_L1); + MB_TYPE_QUANT = $0010000; + MB_TYPE_CBP = $0020000; + //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...) + +type +(** + * Pan Scan area. + * This specifies the area which should be displayed. + * Note there may be multiple such areas for one frame. + *) + PAVPanScan = ^TAVPanScan; + TAVPanScan = record {24} + (*** id. + * - encoding: set by user. + * - decoding: set by libavcodec. *) + id: integer; + + (*** width and height in 1/16 pel + * - encoding: set by user. + * - decoding: set by libavcodec. *) + width: integer; + height: integer; + + (*** position of the top left corner in 1/16 pel for up to 3 fields/frames. + * - encoding: set by user. + * - decoding: set by libavcodec. *) + position: array [0..2] of array [0..1] of smallint; + end; + +const + FF_QSCALE_TYPE_MPEG1 = 0; + FF_QSCALE_TYPE_MPEG2 = 1; + FF_QSCALE_TYPE_H264 = 2; + + FF_BUFFER_TYPE_INTERNAL = 1; + FF_BUFFER_TYPE_USER = 2; ///< Direct rendering buffers (image is (de)allocated by user) + FF_BUFFER_TYPE_SHARED = 4; ///< buffer from somewhere else, don't dealloc image (data/base), all other tables are not shared + FF_BUFFER_TYPE_COPY = 8; ///< just a (modified) copy of some other buffer, don't dealloc anything. + + + FF_I_TYPE = 1; // Intra + FF_P_TYPE = 2; // Predicted + FF_B_TYPE = 3; // Bi-dir predicted + FF_S_TYPE = 4; // S(GMC)-VOP MPEG4 + FF_SI_TYPE = 5; + FF_SP_TYPE = 6; + + FF_BUFFER_HINTS_VALID = $01; // Buffer hints value is meaningful (if 0 ignore) + FF_BUFFER_HINTS_READABLE = $02; // Codec will read from buffer + FF_BUFFER_HINTS_PRESERVE = $04; // User must not alter buffer content + FF_BUFFER_HINTS_REUSABLE = $08; // Codec will reuse the buffer (update) + +type + {** + * Audio Video Frame. + * New fields can be added to the end of FF_COMMON_FRAME with minor version + * bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. No fields should be added into AVFrame before or after + * FF_COMMON_FRAME! + * sizeof(AVFrame) must not be used outside libav*. + *} + PAVFrame = ^TAVFrame; + TAVFrame = record {200} + (** + * pointer to the picture planes. + * This might be different from the first allocated byte + * - encoding: + * - decoding: + *) + data: array [0..3] of pbyte; + linesize: array [0..3] of integer; + (** + * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer. + * This isn't used by libavcodec unless the default get/release_buffer() is used. + * - encoding: + * - decoding: + *) + base: array [0..3] of pbyte; + (** + * 1 -> keyframe, 0-> not + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + *) + key_frame: integer; + (** + * Picture type of the frame, see ?_TYPE below. + * - encoding: Set by libavcodec. for coded_picture (and set by user for input). + * - decoding: Set by libavcodec. + *) + pict_type: integer; + (** + * presentation timestamp in time_base units (time when frame should be shown to user) + * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed. + * - encoding: MUST be set by user. + * - decoding: Set by libavcodec. + *) + pts: int64; + (**\ + * picture number in bitstream order + * - encoding: set by + * - decoding: Set by libavcodec. + *) + coded_picture_number: integer; + (** + * picture number in display order + * - encoding: set by + * - decoding: Set by libavcodec. + *) + display_picture_number: integer; + (** + * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) + * - encoding: Set by libavcodec. for coded_picture (and set by user for input). + * - decoding: Set by libavcodec. + *) + quality: integer; + (** + * buffer age (1->was last buffer and dint change, 2->..., ...). + * Set to INT_MAX if the buffer has not been used yet. + * - encoding: unused + * - decoding: MUST be set by get_buffer(). + *) + age: integer; + (** + * is this picture used as reference + * - encoding: unused + * - decoding: Set by libavcodec. (before get_buffer() call)). + *) + reference: integer; + (** + * QP table + * - encoding: unused + * - decoding: Set by libavcodec. + *) + qscale_table: PShortint; + (** + * QP store stride + * - encoding: unused + * - decoding: Set by libavcodec. + *) + qstride: integer; + (** + * mbskip_table[mb]>=1 if MB didn't change + * stride= mb_width = (width+15)>>4 + * - encoding: unused + * - decoding: Set by libavcodec. + *) + mbskip_table: pbyte; + (** + * motion vector table + * @code + * example: + * int mv_sample_log2= 4 - motion_subsample_log2; + * int mb_width= (width+15)>>4; + * int mv_stride= (mb_width << mv_sample_log2) + 1; + * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y]; + * @endcode + * - encoding: Set by user. + * - decoding: Set by libavcodec. + *) + //int16_t (*motion_val[2])[2]; + motion_val: array [0..1] of pointer; + (** + * macroblock type table + * mb_type_base + mb_width + 2 + * - encoding: Set by user. + * - decoding: Set by libavcodec. + *) + mb_type: PCardinal; + (** + * log2 of the size of the block which a single vector in motion_val represents: + * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2) + * - encoding: unused + * - decoding: Set by libavcodec. + *) + motion_subsample_log2: byte; + (** + * for some private data of the user + * - encoding: unused + * - decoding: Set by user. + *) + opaque: pointer; + (** + * error + * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR. + * - decoding: unused + *) + error: array [0..3] of uint64; + (** + * type of the buffer (to keep track of who has to deallocate data[*]) + * - encoding: Set by the one who allocates it. + * - decoding: Set by the one who allocates it. + * Note: User allocated (direct rendering) & internal buffers cannot coexist currently. + *) + type_: integer; + (** + * When decoding, this signals how much the picture must be delayed. + * extra_delay = repeat_pict / (2*fps) + * - encoding: unused + * - decoding: Set by libavcodec. + *) + repeat_pict: integer; + (** + * + *) + qscale_type: integer; + (** + * The content of the picture is interlaced. + * - encoding: Set by user. + * - decoding: Set by libavcodec. (default 0) + *) + interlaced_frame: integer; + (** + * If the content is interlaced, is top field displayed first. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + *) + top_field_first: integer; + (** + * Pan scan. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + *) + pan_scan: PAVPanScan; + (** + * Tell user application that palette has changed from previous frame. + * - encoding: ??? (no palette-enabled encoder yet) + * - decoding: Set by libavcodec. (default 0). + *) + palette_has_changed: integer; + (** + * codec suggestion on buffer type if != 0 + * - encoding: unused + * - decoding: Set by libavcodec. (before get_buffer() call)). + *) + buffer_hints: integer; + (** + * DCT coefficients + * - encoding: unused + * - decoding: Set by libavcodec. + *) + dct_coeff: PsmallInt; + (** + * motion referece frame index + * - encoding: Set by user. + * - decoding: Set by libavcodec. + *) + ref_index: array [0..1] of PShortint; + end; + +const + DEFAULT_FRAME_RATE_BASE = 1001000; + + FF_ASPECT_EXTENDED = 15; + + FF_RC_STRATEGY_XVID = 1; + + FF_BUG_AUTODETECT = 1; ///< autodetection + FF_BUG_OLD_MSMPEG4 = 2; + FF_BUG_XVID_ILACE = 4; + FF_BUG_UMP4 = 8; + FF_BUG_NO_PADDING = 16; + FF_BUG_AMV = 32; + FF_BUG_AC_VLC = 0; ///< will be removed, libavcodec can now handle these non compliant files by default + FF_BUG_QPEL_CHROMA = 64; + FF_BUG_STD_QPEL = 128; + FF_BUG_QPEL_CHROMA2 = 256; + FF_BUG_DIRECT_BLOCKSIZE = 512; + FF_BUG_EDGE = 1024; + FF_BUG_HPEL_CHROMA = 2048; + FF_BUG_DC_CLIP = 4096; + FF_BUG_MS = 8192; ///< workaround various bugs in microsofts broken decoders + //FF_BUG_FAKE_SCALABILITY = 16 //Autodetection should work 100%. + + FF_COMPLIANCE_VERY_STRICT = 2; ///< strictly conform to a older more strict version of the spec or reference software + FF_COMPLIANCE_STRICT = 1; ///< strictly conform to all the things in the spec no matter what consequences + FF_COMPLIANCE_NORMAL = 0; + FF_COMPLIANCE_INOFFICIAL = -1; ///< allow inofficial extensions + FF_COMPLIANCE_EXPERIMENTAL = -2; ///< allow non standarized experimental things + + FF_ER_CAREFUL = 1; + FF_ER_COMPLIANT = 2; + FF_ER_AGGRESSIVE = 3; + FF_ER_VERY_AGGRESSIVE = 4; + + FF_DCT_AUTO = 0; + FF_DCT_FASTINT = 1; + FF_DCT_INT = 2; + FF_DCT_MMX = 3; + FF_DCT_MLIB = 4; + FF_DCT_ALTIVEC = 5; + FF_DCT_FAAN = 6; + + FF_IDCT_AUTO = 0; + FF_IDCT_INT = 1; + FF_IDCT_SIMPLE = 2; + FF_IDCT_SIMPLEMMX = 3; + FF_IDCT_LIBMPEG2MMX = 4; + FF_IDCT_PS2 = 5; + FF_IDCT_MLIB = 6; + FF_IDCT_ARM = 7; + FF_IDCT_ALTIVEC = 8; + FF_IDCT_SH4 = 9; + FF_IDCT_SIMPLEARM = 10; + FF_IDCT_H264 = 11; + FF_IDCT_VP3 = 12; + FF_IDCT_IPP = 13; + FF_IDCT_XVIDMMX = 14; + FF_IDCT_CAVS = 15; + FF_IDCT_SIMPLEARMV5TE= 16; + FF_IDCT_SIMPLEARMV6 = 17; + FF_IDCT_SIMPLEVIS = 18; + FF_IDCT_WMV2 = 19; + + FF_EC_GUESS_MVS = 1; + FF_EC_DEBLOCK = 2; + + FF_MM_FORCE = $80000000; (* force usage of selected flags (OR) *) + (* lower 16 bits - CPU features *) + FF_MM_MMX = $0001; ///< standard MMX + FF_MM_3DNOW = $0004; ///< AMD 3DNOW + FF_MM_MMXEXT = $0002; ///< SSE integer functions or AMD MMX ext + FF_MM_SSE = $0008; ///< SSE functions + FF_MM_SSE2 = $0010; ///< PIV SSE2 functions + FF_MM_3DNOWEXT = $0020; ///< AMD 3DNowExt + FF_MM_SSE3 = $0040; ///< Prescott SSE3 functions + FF_MM_SSSE3 = $0080; ///< Conroe SSSE3 functions + FF_MM_IWMMXT = $0100; ///< XScale IWMMXT + + FF_PRED_LEFT = 0; + FF_PRED_PLANE = 1; + FF_PRED_MEDIAN = 2; + + FF_DEBUG_PICT_INFO = 1; + FF_DEBUG_RC = 2; + FF_DEBUG_BITSTREAM = 4; + FF_DEBUG_MB_TYPE = 8; + FF_DEBUG_QP = 16; + FF_DEBUG_MV = 32; + FF_DEBUG_DCT_COEFF = $00000040; + FF_DEBUG_SKIP = $00000080; + FF_DEBUG_STARTCODE = $00000100; + FF_DEBUG_PTS = $00000200; + FF_DEBUG_ER = $00000400; + FF_DEBUG_MMCO = $00000800; + FF_DEBUG_BUGS = $00001000; + FF_DEBUG_VIS_QP = $00002000; + FF_DEBUG_VIS_MB_TYPE = $00004000; + + FF_DEBUG_VIS_MV_P_FOR = $00000001; //visualize forward predicted MVs of P frames + FF_DEBUG_VIS_MV_B_FOR = $00000002; //visualize forward predicted MVs of B frames + FF_DEBUG_VIS_MV_B_BACK = $00000004; //visualize backward predicted MVs of B frames + + FF_CMP_SAD = 0; + FF_CMP_SSE = 1; + FF_CMP_SATD = 2; + FF_CMP_DCT = 3; + FF_CMP_PSNR = 4; + FF_CMP_BIT = 5; + FF_CMP_RD = 6; + FF_CMP_ZERO = 7; + FF_CMP_VSAD = 8; + FF_CMP_VSSE = 9; + FF_CMP_NSSE = 10; + FF_CMP_W53 = 11; + FF_CMP_W97 = 12; + FF_CMP_DCTMAX = 13; + FF_CMP_DCT264 = 14; + FF_CMP_CHROMA = 256; + + FF_DTG_AFD_SAME = 8; + FF_DTG_AFD_4_3 = 9; + FF_DTG_AFD_16_9 = 10; + FF_DTG_AFD_14_9 = 11; + FF_DTG_AFD_4_3_SP_14_9 = 13; + FF_DTG_AFD_16_9_SP_14_9 = 14; + FF_DTG_AFD_SP_4_3 = 15; + + FF_DEFAULT_QUANT_BIAS = 999999; + + FF_LAMBDA_SHIFT = 7; + FF_LAMBDA_SCALE = (1 shl FF_LAMBDA_SHIFT); + FF_QP2LAMBDA = 118; ///< factor to convert from H.263 QP to lambda + FF_LAMBDA_MAX = (256 * 128 - 1); + + FF_QUALITY_SCALE = FF_LAMBDA_SCALE; //FIXME maybe remove + + FF_CODER_TYPE_VLC = 0; + FF_CODER_TYPE_AC = 1; + FF_CODER_TYPE_RAW = 2; + FF_CODER_TYPE_RLE = 3; + FF_CODER_TYPE_DEFLATE = 4; + + SLICE_FLAG_CODED_ORDER = $0001; ///< draw_horiz_band() is called in coded order instead of display + SLICE_FLAG_ALLOW_FIELD = $0002; ///< allow draw_horiz_band() with field slices (MPEG2 field pics) + SLICE_FLAG_ALLOW_PLANE = $0004; ///< allow draw_horiz_band() with 1 component at a time (SVQ1) + + FF_MB_DECISION_SIMPLE = 0; ///< uses mb_cmp + FF_MB_DECISION_BITS = 1; ///< chooses the one which needs the fewest bits + FF_MB_DECISION_RD = 2; ///< rate distoration + + FF_AA_AUTO = 0; + FF_AA_FASTINT = 1; //not implemented yet + FF_AA_INT = 2; + FF_AA_FLOAT = 3; + + FF_PROFILE_UNKNOWN = -99; + FF_PROFILE_AAC_MAIN = 0; + FF_PROFILE_AAC_LOW = 1; + FF_PROFILE_AAC_SSR = 2; + FF_PROFILE_AAC_LTP = 3; + + FF_LEVEL_UNKNOWN = -99; + + X264_PART_I4X4 = $001; (* Analyse i4x4 *) + X264_PART_I8X8 = $002; (* Analyse i8x8 (requires 8x8 transform) *) + X264_PART_P8X8 = $010; (* Analyse p16x8, p8x16 and p8x8 *) + X264_PART_P4X4 = $020; (* Analyse p8x4, p4x8, p4x4 *) + X264_PART_B8X8 = $100; (* Analyse b16x8, b8x16 and b8x8 *) + + FF_COMPRESSION_DEFAULT = -1; + +const + AVPALETTE_SIZE = 1024; + AVPALETTE_COUNT = 256; + +type +(** + * AVPaletteControl + * This structure defines a method for communicating palette changes + * between and demuxer and a decoder. + * + * @deprecated Use AVPacket to send palette changes instead. + * This is totally broken. + *) + PAVPaletteControl = ^TAVPaletteControl; + TAVPaletteControl = record + (* demuxer sets this to 1 to indicate the palette has changed; + * decoder resets to 0 *) + palette_changed: integer; + + (* 4-byte ARGB palette entries, stored in native byte order; note that + * the individual palette components should be on a 8-bit scale; if + * the palette data comes from a IBM VGA native format, the component + * data is probably 6 bits in size and needs to be scaled *) + palette: array [0..AVPALETTE_COUNT - 1] of cardinal; + end; {deprecated;} + +type + PAVClass = ^TAVClass; + PAVCodecContext = ^TAVCodecContext; + + PAVCodec = ^TAVCodec; + + // int[4] + PQuadIntArray = ^TQuadIntArray; + TQuadIntArray = array[0..3] of integer; + // int (*func)(struct AVCodecContext *c2, void *arg) + TExecuteFunc = function(c2: PAVCodecContext; arg: Pointer): integer; cdecl; + + TAVClass = record {12} + class_name: pchar; + (* actually passing a pointer to an AVCodecContext + or AVFormatContext, which begin with an AVClass. + Needed because av_log is in libavcodec and has no visibility + of AVIn/OutputFormat *) + item_name: function (): pchar; cdecl; + option: PAVOption; + end; + + (** + * main external API structure. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVCodecContext) must not be used outside libav*. + *) + TAVCodecContext = record {720} + (** + * information on struct for av_log + * - set by avcodec_alloc_context + *) + av_class: PAVClass; + (** + * the average bitrate + * - encoding: Set by user; unused for constant quantizer encoding. + * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream. + *) + bit_rate: integer; + + (** + * number of bits the bitstream is allowed to diverge from the reference. + * the reference can be CBR (for CBR pass1) or VBR (for pass2) + * - encoding: Set by user; unused for constant quantizer encoding. + * - decoding: unused + *) + bit_rate_tolerance: integer; + + (** + * CODEC_FLAG_*. + * - encoding: Set by user. + * - decoding: Set by user. + *) + flags: integer; + + (** + * Some codecs need additional format info. It is stored here. + * If any muxer uses this then ALL demuxers/parsers AND encoders for the + * specific codec MUST set it correctly otherwise stream copy breaks. + * In general use of this field by muxers is not recommanded. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. (FIXME: Is this OK?) + *) + sub_id: integer; + + (** + * Motion estimation algorithm used for video coding. + * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex), + * 8 (umh), 9 (iter) [7, 8 are x264 specific, 9 is snow specific] + * - encoding: MUST be set by user. + * - decoding: unused + *) + me_method: integer; + + (** + * some codecs need / can use extradata like Huffman tables. + * mjpeg: Huffman tables + * rv10: additional flags + * mpeg4: global headers (they can be in the bitstream or here) + * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger + * than extradata_size to avoid prolems if it is read with the bitstream reader. + * The bytewise contents of extradata must not depend on the architecture or CPU endianness. + * - encoding: Set/allocated/freed by libavcodec. + * - decoding: Set/allocated/freed by user. + *) + extradata: pbyte; + extradata_size: integer; + + (** + * This is the fundamental unit of time (in seconds) in terms + * of which frame timestamps are represented. For fixed-fps content, + * timebase should be 1/framerate and timestamp increments should be + * identically 1. + * - encoding: MUST be set by user. + * - decoding: Set by libavcodec. + *) + time_base: TAVRational; + + (* video only *) + (** + * picture width / height. + * - encoding: MUST be set by user. + * - decoding: Set by libavcodec. + * Note: For compatibility it is possible to set this instead of + * coded_width/height before decoding. + *) + width, height: integer; + + (** + * the number of pictures in a group of pictures, or 0 for intra_only + * - encoding: Set by user. + * - decoding: unused + *) + gop_size: integer; + + (** + * Pixel format, see PIX_FMT_xxx. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + *) + pix_fmt: TAVPixelFormat; + + (** + * Frame rate emulation. If not zero, the lower layer (i.e. format handler) + * has to read frames at native frame rate. + * - encoding: Set by user. + * - decoding: unused + *) + rate_emu: integer; + + (** + * If non NULL, 'draw_horiz_band' is called by the libavcodec + * decoder to draw a horizontal band. It improves cache usage. Not + * all codecs can do that. You must check the codec capabilities + * beforehand. + * - encoding: unused + * - decoding: Set by user. + * @param height the height of the slice + * @param y the y position of the slice + * @param type 1->top field, 2->bottom field, 3->frame + * @param offset offset into the AVFrame.data from which the slice should be read + *) + draw_horiz_band: procedure (s: PAVCodecContext; + {const} src: PAVFrame; offset: PQuadIntArray; + y: integer; type_: integer; height: integer); cdecl; + + (* audio only *) + sample_rate: integer; ///< samples per second + channels: integer; + + (** + * audio sample format + * - encoding: Set by user. + * - decoding: Set by libavcodec. + *) + sample_fmt: TSampleFormat; ///< sample format, currenly unused + + (* The following data should not be initialized. *) + (** + * Samples per packet, initialized when calling 'init'. + *) + frame_size: integer; + frame_number: integer; ///< audio or video frame number + real_pict_num: integer; ///< returns the real picture number of previous encoded frame + + (** + * Number of frames the decoded output will be delayed relative to + * the encoded input. + * - encoding: Set by libavcodec. + * - decoding: unused + *) + delay: integer; + + (* - encoding parameters *) + qcompress: single; ///< amount of qscale change between easy & hard scenes (0.0-1.0) + qblur: single; ///< amount of qscale smoothing over time (0.0-1.0) + + (** + * minimum quantizer + * - encoding: Set by user. + * - decoding: unused + *) + qmin: integer; + + (** + * maximum quantizer + * - encoding: Set by user. + * - decoding: unused + *) + qmax: integer; + + (** + * maximum quantizer difference between frames + * - encoding: Set by user. + * - decoding: unused + *) + max_qdiff: integer; + + (** + * maximum number of B-frames between non-B-frames + * Note: The output will be delayed by max_b_frames+1 relative to the input. + * - encoding: Set by user. + * - decoding: unused + *) + max_b_frames: integer; + + (** + * qscale factor between IP and B-frames + * - encoding: Set by user. + * - decoding: unused + *) + b_quant_factor: single; + + (** obsolete FIXME remove *) + rc_strategy: integer; + + b_frame_strategy: integer; + + (** + * hurry up amount + * - encoding: unused + * - decoding: Set by user. 1-> Skip B-frames, 2-> Skip IDCT/dequant too, 5-> Skip everything except header + * @deprecated Deprecated in favor of skip_idct and skip_frame. + *) + hurry_up: integer; + + codec: PAVCodec; + + priv_data: pointer; + + {$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 + (* unused, FIXME remove*) + rtp_mode: integer; + {$IFEND} + + rtp_payload_size: integer; (* The size of the RTP payload: the coder will *) + (* do it's best to deliver a chunk with size *) + (* below rtp_payload_size, the chunk will start *) + (* with a start code on some codecs like H.263 *) + (* This doesn't take account of any particular *) + (* headers inside the transmited RTP payload *) + + + (* The RTP callback: This function is called *) + (* every time the encoder has a packet to send *) + (* Depends on the encoder if the data starts *) + (* with a Start Code (it should) H.263 does. *) + (* mb_nb contains the number of macroblocks *) + (* encoded in the RTP payload *) + rtp_callback: procedure (avctx: PAVCodecContext; data: pointer; + size: integer; mb_nb: integer); cdecl; + + (* statistics, used for 2-pass encoding *) + mv_bits: integer; + header_bits: integer; + i_tex_bits: integer; + p_tex_bits: integer; + i_count: integer; + p_count: integer; + skip_count: integer; + misc_bits: integer; + + (** + * number of bits used for the previously encoded frame + * - encoding: Set by libavcodec. + * - decoding: unused + *) + frame_bits: integer; + + (** + * Private data of the user, can be used to carry app specific stuff. + * - encoding: Set by user. + * - decoding: Set by user. + *) + opaque: pointer; + + codec_name: array [0..31] of char; + codec_type: TCodecType; (* see CODEC_TYPE_xxx *) + codec_id: TCodecID; (* see CODEC_ID_xxx *) + + (** + * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). + * This is used to work around some encoder bugs. + * A demuxer should set this to what is stored in the field used to identify the codec. + * If there are multiple such fields in a container then the demuxer should choose the one + * which maximizes the information about the used codec. + * If the codec tag field in a container is larger then 32 bits then the demuxer should + * remap the longer ID to 32 bits with a table or other structure. Alternatively a new + * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated + * first. + * - encoding: Set by user, if not then the default based on codec_id will be used. + * - decoding: Set by user, will be converted to uppercase by libavcodec during init. + *) + codec_tag: cardinal; // ěîćíî array [0..3] of char - ňîăäŕ âčäíî FOURCC + + (** + * Work around bugs in encoders which sometimes cannot be detected automatically. + * - encoding: Set by user + * - decoding: Set by user + *) + workaround_bugs: integer; + + (** + * luma single coefficient elimination threshold + * - encoding: Set by user. + * - decoding: unused + *) + luma_elim_threshold: integer; + + (** + * chroma single coeff elimination threshold + * - encoding: Set by user. + * - decoding: unused + *) + chroma_elim_threshold: integer; + + (** + * strictly follow the standard (MPEG4, ...). + * - encoding: Set by user. + * - decoding: unused + *) + strict_std_compliance: integer; + + (** + * qscale offset between IP and B-frames + * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset). + * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). + * - encoding: Set by user. + * - decoding: unused + *) + b_quant_offset: single; + + (** + * Error resilience; higher values will detect more errors but may + * misdetect some more or less valid parts as errors. + * - encoding: unused + * - decoding: Set by user. + *) + error_resilience: integer; + + (** + * Called at the beginning of each frame to get a buffer for it. + * If pic.reference is set then the frame will be read later by libavcodec. + * avcodec_align_dimensions() should be used to find the required width and + * height, as they normally need to be rounded up to the next multiple of 16. + * - encoding: unused + * - decoding: Set by libavcodec., user can override. + *) + get_buffer: function (c: PAVCodecContext; pic: PAVFrame): integer; cdecl; + + (** + * Called to release buffers which where allocated with get_buffer. + * A released buffer can be reused in get_buffer(). + * pic.data[*] must be set to NULL. + * - encoding: unused + * - decoding: Set by libavcodec., user can override. + *) + release_buffer: procedure (c: PAVCodecContext; pic: PAVFrame); cdecl; + + (** + * If 1 the stream has a 1 frame delay during decoding. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + *) + has_b_frames: integer; + + (** + * number of bytes per packet if constant and known or 0 + * Used by some WAV based audio codecs. + *) + block_align: integer; + + parse_only: integer; (* - decoding only: if true, only parsing is done + (function avcodec_parse_frame()). The frame + data is returned. Only MPEG codecs support this now. *) + + (** + * 0-> h263 quant 1-> mpeg quant + * - encoding: Set by user. + * - decoding: unused + *) + mpeg_quant: integer; + + (** + * pass1 encoding statistics output buffer + * - encoding: Set by libavcodec. + * - decoding: unused + *) + stats_out: pchar; + + (** + * pass2 encoding statistics input buffer + * Concatenated stuff from stats_out of pass1 should be placed here. + * - encoding: Allocated/set/freed by user. + * - decoding: unused + *) + stats_in: pchar; + + (** + * ratecontrol qmin qmax limiting method + * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax. + * - encoding: Set by user. + * - decoding: unused + *) + rc_qsquish: single; + + rc_qmod_amp: single; + rc_qmod_freq: integer; + + (** + * ratecontrol override, see RcOverride + * - encoding: Allocated/set/freed by user. + * - decoding: unused + *) + rc_override: PRcOverride; + rc_override_count: integer; + + (** + * rate control equation + * - encoding: Set by user + * - decoding: unused + *) + rc_eq: pchar; + + (** + * maximum bitrate + * - encoding: Set by user. + * - decoding: unused + *) + rc_max_rate: integer; + + (** + * minimum bitrate + * - encoding: Set by user. + * - decoding: unused + *) + rc_min_rate: integer; + + (** + * decoder bitstream buffer size + * - encoding: Set by user. + * - decoding: unused + *) + rc_buffer_size: integer; + rc_buffer_aggressivity: single; + + (** + * qscale factor between P and I-frames + * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset). + * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). + * - encoding: Set by user. + * - decoding: unused + *) + i_quant_factor: single; + + (** + * qscale offset between P and I-frames + * - encoding: Set by user. + * - decoding: unused + *) + i_quant_offset: single; + + (** + * initial complexity for pass1 ratecontrol + * - encoding: Set by user. + * - decoding: unused + *) + rc_initial_cplx: single; + + (** + * DCT algorithm, see FF_DCT_* below + * - encoding: Set by user. + * - decoding: unused + *) + dct_algo: integer; + + (** + * luminance masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + *) + lumi_masking: single; + + (** + * temporary complexity masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + *) + temporal_cplx_masking: single; + + (** + * spatial complexity masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + *) + spatial_cplx_masking: single; + + (** + * p block masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + *) + p_masking: single; + + (** + * darkness masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + *) + dark_masking: single; + + {$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 + (* for binary compatibility *) + unused: integer; + {$IFEND} + + (** + * IDCT algorithm, see FF_IDCT_* below. + * - encoding: Set by user. + * - decoding: Set by user. + *) + idct_algo: integer; + + (** + * slice count + * - encoding: Set by libavcodec. + * - decoding: Set by user (or 0). + *) + slice_count: integer; + + (** + * slice offsets in the frame in bytes + * - encoding: Set/allocated by libavcodec. + * - decoding: Set/allocated by user (or NULL). + *) + slice_offset: Pinteger; + + (** + * error concealment flags + * - encoding: unused + * - decoding: Set by user. + *) + error_concealment: integer; + + (** + * dsp_mask could be add used to disable unwanted CPU features + * CPU features (i.e. MMX, SSE. ...) + * + * With the FORCE flag you may instead enable given CPU features. + * (Dangerous: Usable in case of misdetection, improper usage however will + * result into program crash.) + *) + dsp_mask: cardinal; + + (** + * bits per sample/pixel from the demuxer (needed for huffyuv). + * - encoding: Set by libavcodec. + * - decoding: Set by user. + *) + bits_per_sample: integer; + + (** + * prediction method (needed for huffyuv) + * - encoding: Set by user. + * - decoding: unused + *) + prediction_method: integer; + + (** + * sample aspect ratio (0 if unknown) + * Numerator and denominator must be relatively prime and smaller than 256 for some video standards. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + *) + sample_aspect_ratio: TAVRational; + + (** + * the picture in the bitstream + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + *) + coded_frame: PAVFrame; + + (** + * debug + * - encoding: Set by user. + * - decoding: Set by user. + *) + debug: integer; + + (** + * debug + * - encoding: Set by user. + * - decoding: Set by user. + *) + debug_mv: integer; + + (** + * error + * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR. + * - decoding: unused + *) + error: array [0..3] of uint64; + + (** + * minimum MB quantizer + * - encoding: unused + * - decoding: unused + *) + mb_qmin: integer; + + (** + * maximum MB quantizer + * - encoding: unused + * - decoding: unused + *) + mb_qmax: integer; + + (** + * motion estimation comparison function + * - encoding: Set by user. + * - decoding: unused + *) + me_cmp: integer; + + (** + * subpixel motion estimation comparison function + * - encoding: Set by user. + * - decoding: unused + *) + me_sub_cmp: integer; + (** + * macroblock comparison function (not supported yet) + * - encoding: Set by user. + * - decoding: unused + *) + mb_cmp: integer; + (** + * interlaced DCT comparison function + * - encoding: Set by user. + * - decoding: unused + *) + ildct_cmp: integer; + + (** + * ME diamond size & shape + * - encoding: Set by user. + * - decoding: unused + *) + dia_size: integer; + + (** + * amount of previous MV predictors (2a+1 x 2a+1 square) + * - encoding: Set by user. + * - decoding: unused + *) + last_predictor_count: integer; + + (** + * prepass for motion estimation + * - encoding: Set by user. + * - decoding: unused + *) + pre_me: integer; + + (** + * motion estimation prepass comparison function + * - encoding: Set by user. + * - decoding: unused + *) + me_pre_cmp: integer; + + (** + * ME prepass diamond size & shape + * - encoding: Set by user. + * - decoding: unused + *) + pre_dia_size: integer; + + (** + * subpel ME quality + * - encoding: Set by user. + * - decoding: unused + *) + me_subpel_quality: integer; + + (** + * callback to negotiate the pixelFormat + * @param fmt is the list of formats which are supported by the codec, + * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality. + * The first is always the native one. + * @return the chosen format + * - encoding: unused + * - decoding: Set by user, if not set the native format will be chosen. + *) + get_format: function (s: PAVCodecContext; {const} fmt: PAVPixelFormat): TAVPixelFormat; cdecl; + + (** + * DTG active format information (additional aspect ratio + * information only used in DVB MPEG-2 transport streams) + * 0 if not set. + * + * - encoding: unused + * - decoding: Set by decoder. + *) + dtg_active_format: integer; + + (** + * maximum motion estimation search range in subpel units + * If 0 then no limit. + * + * - encoding: Set by user. + * - decoding: unused + *) + me_range: integer; + + (** + * intra quantizer bias + * - encoding: Set by user. + * - decoding: unused + *) + intra_quant_bias: integer; + + (** + * inter quantizer bias + * - encoding: Set by user. + * - decoding: unused + *) + inter_quant_bias: integer; + + (** + * color table ID + * - encoding: unused + * - decoding: Which clrtable should be used for 8bit RGB images. + * Tables have to be stored somewhere. FIXME + *) + color_table_id: integer; + + (** + * internal_buffer count + * Don't touch, used by libavcodec default_get_buffer(). + *) + internal_buffer_count: integer; + + (** + * internal_buffers + * Don't touch, used by libavcodec default_get_buffer(). + *) + internal_buffer: pointer; + + (** + * Global quality for codecs which cannot change it per frame. + * This should be proportional to MPEG-1/2/4 qscale. + * - encoding: Set by user. + * - decoding: unused + *) + global_quality: integer; + + (** + * coder type + * - encoding: Set by user. + * - decoding: unused + *) + coder_type: integer; + + (** + * context model + * - encoding: Set by user. + * - decoding: unused + *) + context_model: integer; + + { + (** + * + * - encoding: unused + * - decoding: Set by user. + *) + realloc: function (s: PAVCodecContext; buf: Pbyte; buf_size: integer): Pbyte; cdecl; + } + + (** + * slice flags + * - encoding: unused + * - decoding: Set by user. + *) + slice_flags: integer; + + (** + * XVideo Motion Acceleration + * - encoding: forbidden + * - decoding: set by decoder + *) + xvmc_acceleration: integer; + + (** + * macroblock decision mode + * - encoding: Set by user. + * - decoding: unused + *) + mb_decision: integer; + + (** + * custom intra quantization matrix + * - encoding: Set by user, can be NULL. + * - decoding: Set by libavcodec. + *) + intra_matrix: Pword; + + (** + * custom inter quantization matrix + * - encoding: Set by user, can be NULL. + * - decoding: Set by libavcodec. + *) + inter_matrix: Pword; + + (** + * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). + * This is used to work around some encoder bugs. + * - encoding: unused + * - decoding: Set by user, will be converted to uppercase by libavcodec during init. + *) + stream_codec_tag: array [0..3] of char; //cardinal; + + (** + * scene change detection threshold + * 0 is default, larger means fewer detected scene changes. + * - encoding: Set by user. + * - decoding: unused + *) + scenechange_threshold: integer; + + (** + * minimum Lagrange multipler + * - encoding: Set by user. + * - decoding: unused + *) + lmin: integer; + + (** + * maximum Lagrange multipler + * - encoding: Set by user. + * - decoding: unused + *) + lmax: integer; + + (** + * palette control structure + * - encoding: ??? (no palette-enabled encoder yet) + * - decoding: Set by user. + *) + palctrl: PAVPaletteControl; + + (** + * noise reduction strength + * - encoding: Set by user. + * - decoding: unused + *) + noise_reduction: integer; + + (** + * Called at the beginning of a frame to get cr buffer for it. + * Buffer type (size, hints) must be the same. libavcodec won't check it. + * libavcodec will pass previous buffer in pic, function should return + * same buffer or new buffer with old frame "painted" into it. + * If pic.data[0] == NULL must behave like get_buffer(). + * - encoding: unused + * - decoding: Set by libavcodec., user can override + *) + reget_buffer: function (c: PAVCodecContext; pic: PAVFrame): integer; cdecl; + + (** + * Number of bits which should be loaded into the rc buffer before decoding starts. + * - encoding: Set by user. + * - decoding: unused + *) + rc_initial_buffer_occupancy: integer; + + (** + * + * - encoding: Set by user. + * - decoding: unused + *) + inter_threshold: integer; + + (** + * CODEC_FLAG2_* + * - encoding: Set by user. + * - decoding: Set by user. + *) + flags2: integer; + + (** + * Simulates errors in the bitstream to test error concealment. + * - encoding: Set by user. + * - decoding: unused + *) + error_rate: integer; + + (** + * MP3 antialias algorithm, see FF_AA_* below. + * - encoding: unused + * - decoding: Set by user. + *) + antialias_algo: integer; + + (** + * quantizer noise shaping + * - encoding: Set by user. + * - decoding: unused + *) + quantizer_noise_shaping: integer; + + (** + * thread count + * is used to decide how many independent tasks should be passed to execute() + * - encoding: Set by user. + * - decoding: Set by user. + *) + thread_count: integer; + + (** + * The codec may call this to execute several independent things. + * It will return only after finishing all tasks. + * The user may replace this with some multithreaded implementation, + * the default implementation will execute the parts serially. + * @param count the number of things to execute + * - encoding: Set by libavcodec, user can override. + * - decoding: Set by libavcodec, user can override. + *) + execute: function (c: PAVCodecContext; func: TExecuteFunc; arg: PPointer; ret: PInteger; count: integer): integer; cdecl; + + (** + * thread opaque + * Can be used by execute() to store some per AVCodecContext stuff. + * - encoding: set by execute() + * - decoding: set by execute() + *) + thread_opaque: pointer; + + (** + * Motion estimation threshold below which no motion estimation is + * performed, but instead the user specified motion vectors are used. + * + * - encoding: Set by user. + * - decoding: unused + *) + me_threshold: integer; + + (** + * Macroblock threshold below which the user specified macroblock types will be used. + * - encoding: Set by user. + * - decoding: unused + *) + mb_threshold: integer; + + (** + * precision of the intra DC coefficient - 8 + * - encoding: Set by user. + * - decoding: unused + *) + intra_dc_precision: integer; + + (** + * noise vs. sse weight for the nsse comparsion function + * - encoding: Set by user. + * - decoding: unused + *) + nsse_weight: integer; + + (** + * Number of macroblock rows at the top which are skipped. + * - encoding: unused + * - decoding: Set by user. + *) + skip_top: integer; + + (** + * Number of macroblock rows at the bottom which are skipped. + * - encoding: unused + * - decoding: Set by user. + *) + skip_bottom: integer; + + (** + * profile + * - encoding: Set by user. + * - decoding: Set by libavcodec. + *) + profile: integer; + + (** + * level + * - encoding: Set by user. + * - decoding: Set by libavcodec. + *) + level: integer; + + (** + * low resolution decoding, 1-> 1/2 size, 2->1/4 size + * - encoding: unused + * - decoding: Set by user. + *) + lowres: integer; + + (** + * Bitstream width / height, may be different from width/height if lowres + * or other things are used. + * - encoding: unused + * - decoding: Set by user before init if known. Codec should override / dynamically change if needed. + *) + coded_width, coded_height: integer; + + (** + * frame skip threshold + * - encoding: Set by user. + * - decoding: unused + *) + frame_skip_threshold: integer; + + (** + * frame skip factor + * - encoding: Set by user. + * - decoding: unused + *) + frame_skip_factor: integer; + + (** + * frame skip exponent + * - encoding: Set by user. + * - decoding: unused + *) + frame_skip_exp: integer; + + (** + * frame skip comparison function + * - encoding: Set by user. + * - decoding: unused + *) + frame_skip_cmp: integer; + + (** + * Border processing masking, raises the quantizer for mbs on the borders + * of the picture. + * - encoding: Set by user. + * - decoding: unused + *) + border_masking: single; + + (** + * minimum MB lagrange multipler + * - encoding: Set by user. + * - decoding: unused + *) + mb_lmin: integer; + + (** + * maximum MB lagrange multipler + * - encoding: Set by user. + * - decoding: unused + *) + mb_lmax: integer; + + (** + * + * - encoding: Set by user. + * - decoding: unused + *) + me_penalty_compensation: integer; + + (** + * + * - encoding: unused + * - decoding: Set by user. + *) + skip_loop_filter: TAVDiscard; + + (** + * + * - encoding: unused + * - decoding: Set by user. + *) + skip_idct: TAVDiscard; + + (** + * + * - encoding: unused + * - decoding: Set by user. + *) + skip_frame: TAVDiscard; + + (** + * + * - encoding: Set by user. + * - decoding: unused + *) + bidir_refine: integer; + + (** + * + * - encoding: Set by user. + * - decoding: unused + *) + brd_scale: integer; + + (** + * constant rate factor - quality-based VBR - values ~correspond to qps + * - encoding: Set by user. + * - decoding: unused + *) + {$IF LIBAVCODEC_VERSION >= 51021000} // 51.21.0 + crf: single; + {$ELSE} + crf: integer; + {$IFEND} + + (** + * constant quantization parameter rate control method + * - encoding: Set by user. + * - decoding: unused + *) + cqp: integer; + + (** + * minimum GOP size + * - encoding: Set by user. + * - decoding: unused + *) + keyint_min: integer; + + (** + * number of reference frames + * - encoding: Set by user. + * - decoding: unused + *) + refs: integer; + + (** + * chroma qp offset from luma + * - encoding: Set by user. + * - decoding: unused + *) + chromaoffset: integer; + + (** + * Influences how often B-frames are used. + * - encoding: Set by user. + * - decoding: unused + *) + bframebias: integer; + + (** + * trellis RD quantization + * - encoding: Set by user. + * - decoding: unused + *) + trellis: integer; + + (** + * Reduce fluctuations in qp (before curve compression). + * - encoding: Set by user. + * - decoding: unused + *) + complexityblur: single; + + (** + * in-loop deblocking filter alphac0 parameter + * alpha is in the range -6...6 + * - encoding: Set by user. + * - decoding: unused + *) + deblockalpha: integer; + + (** + * in-loop deblocking filter beta parameter + * beta is in the range -6...6 + * - encoding: Set by user. + * - decoding: unused + *) + deblockbeta: integer; + + (** + * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4 + * - encoding: Set by user. + * - decoding: unused + *) + partitions: integer; + + (** + * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal) + * - encoding: Set by user. + * - decoding: unused + *) + directpred: integer; + + (** + * Audio cutoff bandwidth (0 means "automatic") + * - encoding: Set by user. + * - decoding: unused + *) + cutoff: integer; + + (** + * Multiplied by qscale for each frame and added to scene_change_score. + * - encoding: Set by user. + * - decoding: unused + *) + scenechange_factor: integer; + + (** + * + * Note: Value depends upon the compare function used for fullpel ME. + * - encoding: Set by user. + * - decoding: unused + *) + mv0_threshold: integer; + + (** + * Adjusts sensitivity of b_frame_strategy 1. + * - encoding: Set by user. + * - decoding: unused + *) + b_sensitivity: integer; + + (** + * - encoding: Set by user. + * - decoding: unused + *) + compression_level: integer; + + (** + * Sets whether to use LPC mode - used by FLAC encoder. + * - encoding: Set by user. + * - decoding: unused + *) + use_lpc: integer; + + (** + * LPC coefficient precision - used by FLAC encoder + * - encoding: Set by user. + * - decoding: unused + *) + lpc_coeff_precision: integer; + + (** + * - encoding: Set by user. + * - decoding: unused + *) + min_prediction_order: integer; + + (** + * - encoding: Set by user. + * - decoding: unused + *) + max_prediction_order: integer; + + (** + * search method for selecting prediction order + * - encoding: Set by user. + * - decoding: unused + *) + prediction_order_method: integer; + + (** + * - encoding: Set by user. + * - decoding: unused + *) + min_partition_order: integer; + + (** + * - encoding: Set by user. + * - decoding: unused + *) + max_partition_order: integer; + + {$IF LIBAVCODEC_VERSION >= 51026000} // 51.26.0 + (** + * GOP timecode frame start number, in non drop frame format + * - encoding: Set by user. + * - decoding: unused + *) + timecode_frame_start: int64; + {$IFEND} + + {$IF LIBAVCODEC_VERSION >= 51042000} // 51.42.0 + (** + * Decoder should decode to this many channels if it can (0 for default) + * - encoding: unused + * - decoding: Set by user. + *) + request_channels: integer; + {$IFEND} + + {$IF LIBAVCODEC_VERSION > 51049000} // > 51.49.0 + (** + * Percentage of dynamic range compression to be applied by the decoder. + * The default value is 1.0, corresponding to full compression. + * - encoding: unused + * - decoding: Set by user. + *) + drc_scale: Single; + {$IFEND} + end; + +(** + * AVCodec. + *) + TAVCodec = record + name: pchar; + type_: TCodecType; + id: TCodecID; + priv_data_size: integer; + init: function (avctx: PAVCodecContext): integer; cdecl; (* typo corretion by the Creative CAT *) + encode: function (avctx: PAVCodecContext; buf: pchar; buf_size: integer; data: pointer): integer; cdecl; + close: function (avctx: PAVCodecContext): integer; cdecl; + decode: function (avctx: PAVCodecContext; outdata: pointer; outdata_size: PInteger; + {const} buf: pchar; buf_size: integer): integer; cdecl; + capabilities: integer; + next: PAVCodec; + flush: procedure (avctx: PAVCodecContext); cdecl; + {const} supported_framerates: PAVRational; ///array of supported framerates, or NULL if any, array is terminated by {0,0} + {const} pix_fmts: PAVPixelFormat; ///array of supported pixel formats, or NULL if unknown, array is terminanted by -1 + end; + +(** + * four components are given, that's all. + * the last component is alpha + *) + PAVPicture = ^TAVPicture; + TAVPicture = record + data: array [0..3] of pchar; + linesize: array [0..3] of integer; ///< number of bytes per line + end; + +type + PAVSubtitleRect = ^TAVSubtitleRect; + TAVSubtitleRect = record + x: word; + y: word; + w: word; + h: word; + nb_colors: word; + linesize: integer; + rgba_palette: PCardinal; + bitmap: pchar; + end; + + PAVSubtitle = ^TAVSubtitle; + TAVSubtitle = record {20} + format: word; (* 0 = graphics *) + start_display_time: cardinal; (* relative to packet pts, in ms *) + end_display_time: cardinal; (* relative to packet pts, in ms *) + num_rects: cardinal; + rects: PAVSubtitleRect; + end; + + +(* resample.c *) + + PReSampleContext = pointer; + PAVResampleContext = pointer; + PImgReSampleContext = pointer; + +function audio_resample_init (output_channels: integer; input_channels: integer; + output_rate: integer; input_rate: integer): PReSampleContext; + cdecl; external av__codec; + +function audio_resample (s: PReSampleContext; output: PSmallint; input: PSmallint; nb_samples: integer): integer; + cdecl; external av__codec; + +procedure audio_resample_close (s: PReSampleContext); + cdecl; external av__codec; + + +function av_resample_init (out_rate: integer; in_rate: integer; filter_length: integer; + log2_phase_count: integer; linear: integer; cutoff: double): PAVResampleContext; + cdecl; external av__codec; + +function av_resample (c: PAVResampleContext; dst: PSmallint; src: PSmallint; consumed: PInteger; + src_size: integer; dst_size: integer; update_ctx: integer): integer; + cdecl; external av__codec; + +procedure av_resample_compensate (c: PAVResampleContext; sample_delta: integer; + compensation_distance: integer); + cdecl; external av__codec; + +procedure av_resample_close (c: PAVResampleContext); + cdecl; external av__codec; + + +{$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 +(* YUV420 format is assumed ! *) + +(** + * @deprecated Use the software scaler (swscale) instead. + *) +function img_resample_init (output_width: integer; output_height: integer; + input_width: integer; input_height: integer): PImgReSampleContext; + cdecl; external av__codec; deprecated; + +(** + * @deprecated Use the software scaler (swscale) instead. + *) +function img_resample_full_init (owidth: integer; oheight: integer; + iwidth: integer; iheight: integer; + topBand: integer; bottomBand: integer; + leftBand: integer; rightBand: integer; + padtop: integer; padbottom: integer; + padleft: integer; padright: integer): PImgReSampleContext; + cdecl; external av__codec; deprecated; + +(** + * @deprecated Use the software scaler (swscale) instead. + *) +procedure img_resample (s: PImgReSampleContext; output: PAVPicture; {const} input: PAVPicture); + cdecl; external av__codec; deprecated; + +(** + * @deprecated Use the software scaler (swscale) instead. + *) +procedure img_resample_close (s: PImgReSampleContext); + cdecl; external av__codec; deprecated; + +{$IFEND} + +(** + * Allocate memory for a picture. Call avpicture_free to free it. + * + * @param picture the picture to be filled in. + * @param pix_fmt the format of the picture. + * @param width the width of the picture. + * @param height the height of the picture. + * @return Zero if successful, a negative value if not. + *) +function avpicture_alloc (picture: PAVPicture; pix_fmt: TAVPixelFormat; + width: integer; height: integer): integer; + cdecl; external av__codec; + +(** + * Free a picture previously allocated by avpicture_alloc(). + * + * @param picture the AVPicture to be freed + *) +procedure avpicture_free (picture: PAVPicture); + cdecl; external av__codec; + +(** + * Fill in the AVPicture fields. + * The fields of the given AVPicture are filled in by using the 'ptr' address + * which points to the image data buffer. Depending on the specified picture + * format, one or multiple image data pointers and line sizes will be set. + * If a planar format is specified, several pointers will be set pointing to + * the different picture planes and the line sizes of the different planes + * will be stored in the lines_sizes array. + * + * @param picture AVPicture whose fields are to be filled in + * @param ptr Buffer which will contain or contains the actual image data + * @param pix_fmt The format in which the picture data is stored. + * @param width the width of the image in pixels + * @param height the height of the image in pixels + * @return size of the image data in bytes + *) +function avpicture_fill (picture: PAVPicture; ptr: pointer; + pix_fmt: TAVPixelFormat; width: integer; height: integer): integer; + cdecl; external av__codec; + +function avpicture_layout ({const} src: PAVPicture; pix_fmt: TAVPixelFormat; + width: integer; height: integer; + dest: pchar; dest_size: integer): integer; + cdecl; external av__codec; + +(** + * Calculate the size in bytes that a picture of the given width and height + * would occupy if stored in the given picture format. + * + * @param pix_fmt the given picture format + * @param width the width of the image + * @param height the height of the image + * @return Image data size in bytes + *) +function avpicture_get_size (pix_fmt: TAVPixelFormat; width: integer; height: integer): integer; + cdecl; external av__codec; + +procedure avcodec_get_chroma_sub_sample (pix_fmt: TAVPixelFormat; h_shift: Pinteger; v_shift: pinteger); + cdecl; external av__codec; + +function avcodec_get_pix_fmt_name(pix_fmt: TAVPixelFormat): pchar; + cdecl; external av__codec; + +procedure avcodec_set_dimensions(s: PAVCodecContext; width: integer; height: integer); + cdecl; external av__codec; + +function avcodec_get_pix_fmt(const name: pchar): TAVPixelFormat; + cdecl; external av__codec; + +function avcodec_pix_fmt_to_codec_tag(p: TAVPixelFormat): cardinal; + cdecl; external av__codec; + +const + FF_LOSS_RESOLUTION = $0001; {**< loss due to resolution change *} + FF_LOSS_DEPTH = $0002; {**< loss due to color depth change *} + FF_LOSS_COLORSPACE = $0004; {**< loss due to color space conversion *} + FF_LOSS_ALPHA = $0008; {**< loss of alpha bits *} + FF_LOSS_COLORQUANT = $0010; {**< loss due to color quantization *} + FF_LOSS_CHROMA = $0020; {**< loss of chroma (e.g. RGB to gray conversion) *} + +(** + * Computes what kind of losses will occur when converting from one specific + * pixel format to another. + * When converting from one pixel format to another, information loss may occur. + * For example, when converting from RGB24 to GRAY, the color information will + * be lost. Similarly, other losses occur when converting from some formats to + * other formats. These losses can involve loss of chroma, but also loss of + * resolution, loss of color depth, loss due to the color space conversion, loss + * of the alpha bits or loss due to color quantization. + * avcodec_get_fix_fmt_loss() informs you about the various types of losses + * which will occur when converting from one pixel format to another. + * + * @param[in] dst_pix_fmt destination pixel format + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @return Combination of flags informing you what kind of losses will occur. + *) +function avcodec_get_pix_fmt_loss (dst_pix_fmt: TAVPixelFormat; src_pix_fmt: TAVPixelFormat; + has_alpha: integer): integer; + cdecl; external av__codec; + +(** + * Finds the best pixel format to convert to given a certain source pixel + * format. When converting from one pixel format to another, information loss + * may occur. For example, when converting from RGB24 to GRAY, the color + * information will be lost. Similarly, other losses occur when converting from + * some formats to other formats. avcodec_find_best_pix_fmt() searches which of + * the given pixel formats should be used to suffer the least amount of loss. + * The pixel formats from which it chooses one, are determined by the + * \p pix_fmt_mask parameter. + * + * @code + * src_pix_fmt = PIX_FMT_YUV420P; + * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24); + * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss); + * @endcode + * + * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur. + * @return The best pixel format to convert to or -1 if none was found. + *) +function avcodec_find_best_pix_fmt (pix_fmt_mask: integer; src_pix_fmt: TAVPixelFormat; + has_alpha: integer; loss_ptr: pinteger): integer; + cdecl; external av__codec; + +{$IF LIBAVCODEC_VERSION >= 51041000} // 51.41.0 +(** + * Print in buf the string corresponding to the pixel format with + * number pix_fmt, or an header if pix_fmt is negative. + * + * @param[in] buf the buffer where to write the string + * @param[in] buf_size the size of buf + * @param[in] pix_fmt the number of the pixel format to print the corresponding info string, or + * a negative value to print the corresponding header. + * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1. + *) +procedure avcodec_pix_fmt_string (buf: PChar; buf_size: integer; pix_fmt: integer); + cdecl; external av__codec; +{$IFEND} + +const + FF_ALPHA_TRANSP = $0001; {* image has some totally transparent pixels *} + FF_ALPHA_SEMI_TRANSP = $0002; {* image has some transparent pixels *} + +(** + * Tell if an image really has transparent alpha values. + * @return ored mask of FF_ALPHA_xxx constants + *) +function img_get_alpha_info ({const} src: PAVPicture; + pix_fmt: TAVPixelFormat; + width: integer; height: integer): integer; + cdecl; external av__codec; + +{$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 +(** + * convert among pixel formats + * @deprecated Use the software scaler (swscale) instead. + *) +function img_convert (dst: PAVPicture; dst_pix_fmt: TAVPixelFormat; + const src: PAVPicture; pix_fmt: TAVPixelFormat; + width: integer; height: integer): integer; + cdecl; external av__codec; deprecated; +{$IFEND} + +(* deinterlace a picture *) +(* deinterlace - if not supported return -1 *) +function avpicture_deinterlace (dst: PAVPicture; const src: PAVPicture; + pix_fmt: TAVPixelFormat; width: integer; height: integer): integer; + cdecl; external av__codec; + +{* external high level API *} + +{$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 +{ +var + first_avcodec: PAVCodec; external av__codec; +} +{$IFEND} + +{$IF LIBAVCODEC_VERSION >= 51049000} // 51.49.0 +function av_codec_next(c: PAVCodec): PAVCodec; + cdecl; external av__codec; +{$IFEND} + +(* returns LIBAVCODEC_VERSION_INT constant *) +function avcodec_version (): cardinal; + cdecl; external av__codec; + +(* returns LIBAVCODEC_BUILD constant *) +function avcodec_build (): cardinal; + cdecl; external av__codec; + +(** + * Initializes libavcodec. + * + * @warning This function \e must be called before any other libavcodec + * function. + *) +procedure avcodec_init (); + cdecl; external av__codec; + +procedure register_avcodec (format: PAVCodec); + cdecl; external av__codec; + +(** + * Finds a registered encoder with a matching codec ID. + * + * @param id CodecID of the requested encoder + * @return An encoder if one was found, NULL otherwise. + *) +function avcodec_find_encoder (id: TCodecID): PAVCodec; + cdecl; external av__codec; + +(** + * Finds a registered encoder with the specified name. + * + * @param name name of the requested encoder + * @return An encoder if one was found, NULL otherwise. + *) +function avcodec_find_encoder_by_name (name: pchar): PAVCodec; + cdecl; external av__codec; + +(** + * Finds a registered decoder with a matching codec ID. + * + * @param id CodecID of the requested decoder + * @return A decoder if one was found, NULL otherwise. + *) +function avcodec_find_decoder(id: TCodecID): PAVCodec; + cdecl; external av__codec; + +(** + * Finds a registered decoder with the specified name. + * + * @param name name of the requested decoder + * @return A decoder if one was found, NULL otherwise. + *) +function avcodec_find_decoder_by_name (name: pchar): PAVCodec; + cdecl; external av__codec; +procedure avcodec_string(buf: pchar; buf_size: integer; enc: PAVCodecContext; encode: integer); + cdecl; external av__codec; + +(** + * Sets the fields of the given AVCodecContext to default values. + * + * @param s The AVCodecContext of which the fields should be set to default values. + *) +procedure avcodec_get_context_defaults (s: PAVCodecContext); + cdecl; external av__codec; + +{$IF LIBAVCODEC_VERSION >= 51039000} // 51.39.0 +(** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! + * we WILL change its arguments and name a few times! *) +procedure avcodec_get_context_defaults2(s: PAVCodecContext; ctype: TCodecType); + cdecl; external av__codec; +{$IFEND} + +(** + * Allocates an AVCodecContext and sets its fields to default values. The + * resulting struct can be deallocated by simply calling av_free(). + * + * @return An AVCodecContext filled with default values or NULL on failure. + * @see avcodec_get_context_defaults + *) +function avcodec_alloc_context(): PAVCodecContext; + cdecl; external av__codec; + +{$IF LIBAVCODEC_VERSION >= 51039000} // 51.39.0 +(** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! + * we WILL change its arguments and name a few times! *) +function avcodec_alloc_context2(ctype: TCodecType): PAVCodecContext; + cdecl; external av__codec; +{$IFEND} + +(** + * Sets the fields of the given AVFrame to default values. + * + * @param pic The AVFrame of which the fields should be set to default values. + *) +procedure avcodec_get_frame_defaults (pic: PAVFrame); + cdecl; external av__codec; + +(** + * Allocates an AVFrame and sets its fields to default values. The resulting + * struct can be deallocated by simply calling av_free(). + * + * @return An AVFrame filled with default values or NULL on failure. + * @see avcodec_get_frame_defaults + *) +function avcodec_alloc_frame(): PAVFrame; + cdecl; external av__codec; + +function avcodec_default_get_buffer (s: PAVCodecContext; pic: PAVFrame): integer; + cdecl; external av__codec; +procedure avcodec_default_release_buffer (s: PAVCodecContext; pic: PAVFrame); + cdecl; external av__codec; +function avcodec_default_reget_buffer (s: PAVCodecContext; pic: PAVFrame): integer; + cdecl; external av__codec; +procedure avcodec_align_dimensions(s: PAVCodecContext; width: Pinteger; height: PInteger); + cdecl; external av__codec; + +(** + * Checks if the given dimension of a picture is valid, meaning that all + * bytes of the picture can be addressed with a signed int. + * + * @param[in] w Width of the picture. + * @param[in] h Height of the picture. + * @return Zero if valid, a negative value if invalid. + *) +function avcodec_check_dimensions (av_log_ctx: pointer; w: cardinal; h: cardinal): integer; + cdecl; external av__codec; +function avcodec_default_get_format(s: PAVCodecContext; const fmt: PAVPixelFormat): TAVPixelFormat; + cdecl; external av__codec; + +function avcodec_thread_init (s: PAVCodecContext; thread_count: integer): integer; + cdecl; external av__codec; +procedure avcodec_thread_free (s: PAVCodecContext); + cdecl; external av__codec; +function avcodec_thread_execute (s: PAVCodecContext; func: TExecuteFunc; arg: PPointer; ret: Pinteger; count: integer): integer; + cdecl; external av__codec; +function avcodec_default_execute (s: PAVCodecContext; func: TExecuteFunc; arg: PPointer; ret: Pinteger; count: integer): integer; + cdecl; external av__codec; +//FIXME func typedef + +(** + * Initializes the AVCodecContext to use the given AVCodec. Prior to using this + * function the context has to be allocated. + * + * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), + * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for + * retrieving a codec. + * + * @warning This function is not thread safe! + * + * @code + * avcodec_register_all(); + * codec = avcodec_find_decoder(CODEC_ID_H264); + * if (!codec) + * exit(1); + * + * context = avcodec_alloc_context(); + * + * if (avcodec_open(context, codec) < 0) + * exit(1); + * @endcode + * + * @param avctx The context which will be set up to use the given codec. + * @param codec The codec to use within the context. + * @return zero on success, a negative value on error + * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder + *) +function avcodec_open (avctx: PAVCodecContext; codec: PAVCodec): integer; + cdecl; external av__codec; + +(** + * @deprecated Use avcodec_decode_audio2() instead. + *) +function avcodec_decode_audio (avctx: PAVCodecContext; samples: Pword; + var frame_size_ptr: integer; + {const} buf: pchar; buf_size: integer): integer; + cdecl; external av__codec; + +{$IF LIBAVCODEC_VERSION >= 51030000} // 51.30.0 +(** + * Decodes an audio frame from \p buf into \p samples. + * The avcodec_decode_audio2() function decodes an audio frame from the input + * buffer \p buf of size \p buf_size. To decode it, it makes use of the + * audio codec which was coupled with \p avctx using avcodec_open(). The + * resulting decoded frame is stored in output buffer \p samples. If no frame + * could be decompressed, \p frame_size_ptr is zero. Otherwise, it is the + * decompressed frame size in \e bytes. + * + * @warning You \e must set \p frame_size_ptr to the allocated size of the + * output buffer before calling avcodec_decode_audio2(). + * + * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than + * the actual read bytes because some optimized bitstream readers read 32 or 64 + * bits at once and could read over the end. + * + * @warning The end of the input buffer \p buf should be set to 0 to ensure that + * no overreading happens for damaged MPEG streams. + * + * @note You might have to align the input buffer \p buf and output buffer \p + * samples. The alignment requirements depend on the CPU: On some CPUs it isn't + * necessary at all, on others it won't work at all if not aligned and on others + * it will work but it will have an impact on performance. In practice, the + * bitstream should have 4 byte alignment at minimum and all sample data should + * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If + * the linesize is not a multiple of 16 then there's no sense in aligning the + * start of the buffer to 16. + * + * @param avctx the codec context + * @param[out] samples the output buffer + * @param[in,out] frame_size_ptr the output buffer size in bytes + * @param[in] buf the input buffer + * @param[in] buf_size the input buffer size in bytes + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + *) +function avcodec_decode_audio2(avctx : PAVCodecContext; samples : PSmallint; + var frame_size_ptr : integer; + {const} buf: pchar; buf_size: integer): integer; + cdecl; external av__codec; +{$IFEND} + +(** + * Decodes a video frame from \p buf into \p picture. + * The avcodec_decode_video() function decodes a video frame from the input + * buffer \p buf of size \p buf_size. To decode it, it makes use of the + * video codec which was coupled with \p avctx using avcodec_open(). The + * resulting decoded frame is stored in \p picture. + * + * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than + * the actual read bytes because some optimized bitstream readers read 32 or 64 + * bits at once and could read over the end. + * + * @warning The end of the input buffer \p buf should be set to 0 to ensure that + * no overreading happens for damaged MPEG streams. + * + * @note You might have to align the input buffer \p buf and output buffer \p + * samples. The alignment requirements depend on the CPU: on some CPUs it isn't + * necessary at all, on others it won't work at all if not aligned and on others + * it will work but it will have an impact on performance. In practice, the + * bitstream should have 4 byte alignment at minimum and all sample data should + * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If + * the linesize is not a multiple of 16 then there's no sense in aligning the + * start of the buffer to 16. + * + * @param avctx the codec context + * @param[out] picture The AVFrame in which the decoded video frame will be stored. + * @param[in] buf the input buffer + * @param[in] buf_size the size of the input buffer in bytes + * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + *) +function avcodec_decode_video (avctx: PAVCodecContext; picture: PAVFrame; + var got_picture_ptr: integer; + {const} buf: PByte; buf_size: integer): integer; + cdecl; external av__codec; + +(* Decode a subtitle message. Return -1 if error, otherwise return the + * number of bytes used. If no subtitle could be decompressed, + * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. *) +function avcodec_decode_subtitle (avctx: PAVCodecContext; sub: PAVSubtitle; + var got_sub_ptr: integer; + {const} buf: pchar; buf_size: integer): integer; + cdecl; external av__codec; +function avcodec_parse_frame (avctx: PAVCodecContext; pdata: PPointer; + data_size_ptr: pinteger; + buf: pchar; buf_size: integer): integer; + cdecl; external av__codec; + +(** + * Encodes an audio frame from \p samples into \p buf. + * The avcodec_encode_audio() function encodes an audio frame from the input + * buffer \p samples. To encode it, it makes use of the audio codec which was + * coupled with \p avctx using avcodec_open(). The resulting encoded frame is + * stored in output buffer \p buf. + * + * @note The output buffer should be at least \c FF_MIN_BUFFER_SIZE bytes large. + * + * @param avctx the codec context + * @param[out] buf the output buffer + * @param[in] buf_size the output buffer size + * @param[in] samples the input buffer containing the samples + * The number of samples read from this buffer is frame_size*channels, + * both of which are defined in \p avctx. + * @return On error a negative value is returned, on success zero or the number + * of bytes used to encode the data read from the input buffer. + *) +function avcodec_encode_audio (avctx: PAVCodecContext; buf: PByte; + buf_size: integer; {const} samples: PWord): integer; + cdecl; external av__codec; + +(** + * Encodes a video frame from \p pict into \p buf. + * The avcodec_encode_video() function encodes a video frame from the input + * \p pict. To encode it, it makes use of the video codec which was coupled with + * \p avctx using avcodec_open(). The resulting encoded bytes representing the + * frame are stored in the output buffer \p buf. The input picture should be + * stored using a specific format, namely \c avctx.pix_fmt. + * + * @param avctx the codec context + * @param[out] buf the output buffer for the bitstream of encoded frame + * @param[in] buf_size the size of the output buffer in bytes + * @param[in] pict the input picture to encode + * @return On error a negative value is returned, on success zero or the number + * of bytes used from the input buffer. + *) +function avcodec_encode_video (avctx: PAVCodecContext; buf: PByte; + buf_size: integer; pict: PAVFrame): integer; + cdecl; external av__codec; +function avcodec_encode_subtitle (avctx: PAVCodecContext; buf: pchar; + buf_size: integer; {const} sub: PAVSubtitle): integer; + cdecl; external av__codec; + +function avcodec_close (avctx: PAVCodecContext): integer; + cdecl; external av__codec; + +procedure avcodec_register_all (); + cdecl; external av__codec; + +(** + * Flush buffers, should be called when seeking or when switching to a different stream. + *) +procedure avcodec_flush_buffers (avctx: PAVCodecContext); + cdecl; external av__codec; + +procedure avcodec_default_free_buffers (s: PAVCodecContext); + cdecl; external av__codec; + +(* misc useful functions *) + +(** + * Returns a single letter to describe the given picture type \p pict_type. + * + * @param[in] pict_type the picture type + * @return A single character representing the picture type. + *) +function av_get_pict_type_char (pict_type: integer): char; + cdecl; external av__codec; + +(** + * Returns codec bits per sample. + * + * @param[in] codec_id the codec + * @return Number of bits per sample or zero if unknown for the given codec. + *) +function av_get_bits_per_sample (codec_id: TCodecID): integer; + cdecl; external av__codec; + +{$IF LIBAVCODEC_VERSION >= 51041000} // 51.41.0 +(** + * Returns sample format bits per sample. + * + * @param[in] sample_fmt the sample format + * @return Number of bits per sample or zero if unknown for the given sample format. + *) +function av_get_bits_per_sample_format(sample_fmt: TSampleFormat): integer; + cdecl; external av__codec; +{$IFEND} + +const + AV_PARSER_PTS_NB = 4; + PARSER_FLAG_COMPLETE_FRAMES = $0001; + +type + {* frame parsing *} + PAVCodecParserContext = ^TAVCodecParserContext; + PAVCodecParser = ^TAVCodecParser; + + TAVCodecParserContext = record + priv_data: pointer; + parser: PAVCodecParser; + frame_offset: int64; (* offset of the current frame *) + cur_offset: int64; (* current offset (incremented by each av_parser_parse()) *) + last_frame_offset: int64; (* offset of the last frame *) + (* video info *) + pict_type: integer; (* XXX: put it back in AVCodecContext *) + repeat_pict: integer; (* XXX: put it back in AVCodecContext *) + pts: int64; (* pts of the current frame *) + dts: int64; (* dts of the current frame *) + + (* private data *) + last_pts: int64; + last_dts: int64; + fetch_timestamp: integer; + + cur_frame_start_index: integer; + cur_frame_offset: array [0..AV_PARSER_PTS_NB - 1] of int64; + cur_frame_pts: array [0..AV_PARSER_PTS_NB - 1] of int64; + cur_frame_dts: array [0..AV_PARSER_PTS_NB - 1] of int64; + + flags: integer; + + {$IF LIBAVCODEC_VERSION >= 51040003} // 51.40.3 + offset: int64; ///< byte offset from starting packet start + last_offset: int64; + {$IFEND} + end; + + TAVCodecParser = record + codec_ids: array [0..4] of integer; (* several codec IDs are permitted *) + priv_data_size: integer; + parser_init: function (s: PAVCodecParserContext): integer; cdecl; + parser_parse: function (s: PAVCodecParserContext; avctx: PAVCodecContext; + {const} poutbuf: PPointer; poutbuf_size: PInteger; + {const} buf: pchar; buf_size: integer): integer; cdecl; + parser_close: procedure (s: PAVCodecParserContext); cdecl; + split: function (avctx: PAVCodecContext; {const} buf: pchar; + buf_size: integer): integer; cdecl; + next: PAVCodecParser; + end; + + +{$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 +{ +var + av_first_parser: PAVCodecParser; external av__codec; +} +{$IFEND} + +{$IF LIBAVCODEC_VERSION >= 51049000} // 51.49.0 +function av_parser_next(c: PAVCodecParser): PAVCodecParser; + cdecl; external av__codec; +{$IFEND} + +procedure av_register_codec_parser (parser: PAVCodecParser); + cdecl; external av__codec; + +function av_parser_init (codec_id: integer): PAVCodecParserContext; + cdecl; external av__codec; + +function av_parser_parse (s: PAVCodecParserContext; + avctx: PAVCodecContext; + poutbuf: PPointer; poutbuf_size: pinteger; + const buf: pchar; buf_size: integer; + pts: int64; dts: int64): integer; + cdecl; external av__codec; +function av_parser_change (s: PAVCodecParserContext; + avctx: PAVCodecContext; + poutbuf: PPointer; poutbuf_size: PInteger; + const buf: pchar; buf_size: integer; keyframe: integer): integer; + cdecl; external av__codec; +procedure av_parser_close (s: PAVCodecParserContext); + cdecl; external av__codec; + +type + PAVBitStreamFilterContext = ^TAVBitStreamFilterContext; + PAVBitStreamFilter = ^TAVBitStreamFilter; + + TAVBitStreamFilterContext = record + priv_data: pointer; + filter: PAVBitStreamFilter; + parser: PAVCodecParserContext; + next: PAVBitStreamFilterContext; + end; + + TAVBitStreamFilter = record + name: pchar; + priv_data_size: integer; + filter: function (bsfc: PAVBitStreamFilterContext; + avctx: PAVCodecContext; args: pchar; + poutbuf: PPointer; poutbuf_size: PInteger; + buf: PByte; buf_size: integer; keyframe: integer): integer; cdecl; + {$IF LIBAVCODEC_VERSION >= 51043000} // 51.43.0 + close: procedure (bsfc: PAVBitStreamFilterContext); + {$IFEND} + next: PAVBitStreamFilter; + end; + +procedure av_register_bitstream_filter (bsf: PAVBitStreamFilter); + cdecl; external av__codec; + +function av_bitstream_filter_init (name: pchar): PAVBitStreamFilterContext; + cdecl; external av__codec; + +function av_bitstream_filter_filter (bsfc: PAVBitStreamFilterContext; + avctx: PAVCodecContext; args: pchar; + poutbuf: PPointer; poutbuf_size: PInteger; + buf: PByte; buf_size: integer; keyframe: integer): integer; + cdecl; external av__codec; +procedure av_bitstream_filter_close (bsf: PAVBitStreamFilterContext); + cdecl; external av__codec; + +{$IF LIBAVCODEC_VERSION >= 51049000} // 51.49.0 +function av_bitstream_filter_next(f: PAVBitStreamFilter): PAVBitStreamFilter; + cdecl; external av__codec; +{$IFEND} + +(* memory *) + +(** + * Reallocates the given block if it is not large enough, otherwise it + * does nothing. + * + * @see av_realloc + *) +procedure av_fast_realloc (ptr: pointer; size: PCardinal; min_size: Cardinal); + cdecl; external av__codec; + +(* for static data only *) + +(** + * Frees all static arrays and resets their pointers to 0. + * Call this function to release all statically allocated tables. + * + * @deprecated. Code which uses av_free_static is broken/misdesigned + * and should correctly use static arrays + * + *) +procedure av_free_static (); + cdecl; external av__codec; deprecated; + +(** + * Allocation of static arrays. + * + * @warning Do not use for normal allocation. + * + * @param[in] size The amount of memory you need in bytes. + * @return block of memory of the requested size + * @deprecated. Code which uses av_mallocz_static is broken/misdesigned + * and should correctly use static arrays + *) +procedure av_mallocz_static(size: cardinal); + cdecl; external av__codec; deprecated; + +{$IF LIBAVCODEC_VERSION < 51035000} // 51.35.0 +procedure av_realloc_static(ptr: pointer; size: Cardinal); + cdecl; external av__codec; +{$IFEND} + +{$IF LIBAVCODEC_VERSION >= 51039000} // 51.39.0 +(** + * Copy image 'src' to 'dst'. + *) +procedure av_picture_copy(dst: PAVPicture; {const} src: PAVPicture; + pix_fmt: integer; width: integer; height: integer); + cdecl; external av__codec; + +(** + * Crop image top and left side. + *) +function av_picture_crop(dst: PAVPicture; {const} src: PAVPicture; + pix_fmt: integer; top_band: integer; left_band: integer): integer; + cdecl; external av__codec; + +(** + * Pad image. + *) +function av_picture_pad(dst: PAVPicture; {const} src: PAVPicture; height: integer; width: integer; pix_fmt: integer; + padtop: integer; padbottom: integer; padleft: integer; padright: integer; color: PInteger): integer; + cdecl; external av__codec; +{$IFEND} + +{$IF LIBAVCODEC_VERSION < 52000000} // 52.0.0 +(** + * @deprecated Use the software scaler (swscale) instead. + *) +procedure img_copy (dst: PAVPicture; const src: PAVPicture; + pix_fmt: TAVPixelFormat; width: integer; height: integer); + cdecl; external av__codec; deprecated; + +(** + * @deprecated Use the software scaler (swscale) instead. + *) +function img_crop (dst: PAVPicture; const src: PAVPicture; + pix_fmt: TAVPixelFormat; top_band, left_band: integer): integer; + cdecl; external av__codec; deprecated; + +(** + * @deprecated Use the software scaler (swscale) instead. + *) +function img_pad (dst: PAVPicture; const src: PAVPicture; height, width: integer; + pix_fmt: TAVPixelFormat; padtop, padbottom, padleft, padright: integer; + color: PInteger): integer; + cdecl; external av__codec; deprecated; +{$IFEND} + +function av_xiphlacing(s: PByte; v: Cardinal): Cardinal; + cdecl; external av__codec; + +{$IF LIBAVCODEC_VERSION >= 51041000} // 51.41.0 +(** + * Parses \p str and put in \p width_ptr and \p height_ptr the detected values. + * + * @return 0 in case of a successful parsing, a negative value otherwise + * @param[in] str the string to parse: it has to be a string in the format + * <width>x<height> or a valid video frame size abbreviation. + * @param[in,out] width_ptr pointer to the variable which will contain the detected + * frame width value + * @param[in,out] height_ptr pointer to the variable which will contain the detected + * frame height value + *) +function av_parse_video_frame_size(width_ptr: PInteger; height_ptr: PInteger; {const} str: PChar): integer; + cdecl; external av__codec; + +(** + * Parses \p str and put in \p frame_rate the detected values. + * + * @return 0 in case of a successful parsing, a negative value otherwise + * @param[in] str the string to parse: it has to be a string in the format + * <frame_rate_nom>/<frame_rate_den>, a float number or a valid video rate abbreviation + * @param[in,out] frame_rate pointer to the AVRational which will contain the detected + * frame rate + *) +function av_parse_video_frame_rate(frame_rate: PAVRational; {const} str: PChar): integer; + cdecl; external av__codec; +{$IFEND} + +(* +{* error handling *} +#if EINVAL > 0 +#define AVERROR(e) (-(e)) {**< Returns a negative error code from a POSIX error code, to return from library functions. *} +#define AVUNERROR(e) (-(e)) {**< Returns a POSIX error code from a library function error return value. *} +#else +{* Some platforms have E* and errno already negated. *} +#define AVERROR(e) (e) +#define AVUNERROR(e) (e) +#endif + +const + AVERROR_UNKNOWN AVERROR(EINVAL) {**< unknown error *} + AVERROR_IO AVERROR(EIO) {**< I/O error *} + AVERROR_NUMEXPECTED AVERROR(EDOM) {**< Number syntax expected in filename. *} + AVERROR_INVALIDDATA AVERROR(EINVAL) {**< invalid data found *} + AVERROR_NOMEM AVERROR(ENOMEM) {**< not enough memory *} + AVERROR_NOFMT AVERROR(EILSEQ) {**< unknown format *} + AVERROR_NOTSUPP AVERROR(ENOSYS) {**< Operation not supported. *} + AVERROR_NOENT AVERROR(ENOENT) {**< No such file or directory. *} + AVERROR_PATCHWELCOME -MKTAG('P','A','W','E') {**< Not yet implemented in FFmpeg. Patches welcome. *} +*) + +const + AVERROR_UNKNOWN =(-1); (* unknown error *) + AVERROR_IO =(-2); (* i/o error *) + AVERROR_NUMEXPECTED =(-3); (* number syntax expected in filename *) + AVERROR_INVALIDDATA =(-4); (* invalid data found *) + AVERROR_NOMEM =(-5); (* not enough memory *) + AVERROR_NOFMT =(-6); (* unknown format *) + AVERROR_NOTSUPP =(-7); (* operation not supported *) + +implementation + +end. diff --git a/Game/Code/lib/ffmpeg/avformat.pas b/Game/Code/lib/ffmpeg/avformat.pas new file mode 100644 index 00000000..7a5678a5 --- /dev/null +++ b/Game/Code/lib/ffmpeg/avformat.pas @@ -0,0 +1,1235 @@ +(* + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(* This is a part of Pascal porting of ffmpeg. Originally by Victor Zinetz for Delphi and Free Pascal on Windows. + * For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT + * in the source codes *) + +(* + * Min. version: 50.5.0 + * Max. version: 52.7.0, Revision: 11661, Tue Jan 29 09:25:49 2008 UTC + *) + +unit avformat; + +{$IFDEF FPC} + {$MODE DELPHI } + {$PACKENUM 4} (* use 4-byte enums *) + {$PACKRECORDS C} (* C/C++-compatible record packing *) +{$ELSE} + {$MINENUMSIZE 4} (* use 4-byte enums *) +{$ENDIF} + +interface + +uses + avcodec, + avutil, + avio, + rational, + UConfig; + +const + (* Max. supported version by this header *) + LIBAVFORMAT_MAX_VERSION_MAJOR = 52; + LIBAVFORMAT_MAX_VERSION_MINOR = 7; + LIBAVFORMAT_MAX_VERSION_RELEASE = 0; + LIBAVFORMAT_MAX_VERSION = (LIBAVFORMAT_MAX_VERSION_MAJOR * VERSION_MAJOR) + + (LIBAVFORMAT_MAX_VERSION_MINOR * VERSION_MINOR) + + (LIBAVFORMAT_MAX_VERSION_RELEASE * VERSION_RELEASE); + +(* Check if linked versions are supported *) +{$IF (LIBAVFORMAT_VERSION > LIBAVFORMAT_MAX_VERSION)} + {$MESSAGE Warn 'Linked version of libavformat may be unsupported!'} +{$IFEND} + +type + PAVFile = Pointer; + +(* packet functions *) + +type + PAVPacket = ^TAVPacket; + TAVPacket = record + pts: int64; ///< presentation time stamp in time_base units + dts: int64; ///< decompression time stamp in time_base units + data: PByte; + size: integer; + stream_index: integer; + flags: integer; + duration: integer; ///< presentation duration in time_base units (0 if not available) + destruct: procedure (p: PAVPacket); cdecl; + priv: pointer; + pos: int64; ///< byte position in stream, -1 if unknown + end; +const + PKT_FLAG_KEY = $0001; + +procedure av_destruct_packet_nofree (var pkt: TAVPacket); + cdecl; external av__format; + +(** + * Default packet destructor. + *) +procedure av_destruct_packet (var pkt: TAVPacket); + cdecl; external av__format; + +(** + * Initialize optional fields of a packet to default values. + * + * @param pkt packet + *) +procedure av_init_packet (var pkt: TAVPacket); +{$IF LIBAVFORMAT_VERSION >= 51012002} // 51.12.2 + cdecl; external av__format; +{$IFEND} + +(** + * Allocate the payload of a packet and initialize its fields to default values. + * + * @param pkt packet + * @param size wanted payload size + * @return 0 if OK. AVERROR_xxx otherwise. + *) +function av_new_packet(var pkt: TAVPacket; size: integer): integer; + cdecl; external av__format; + +(** + * Allocate and read the payload of a packet and initialize its fields to default values. + * + * @param pkt packet + * @param size wanted payload size + * @return >0 (read size) if OK. AVERROR_xxx otherwise. + *) +function av_get_packet (s: PByteIOContext; var pkt: TAVPacket; size: integer): integer; + cdecl; external av__format; + +(** + * @warning This is a hack - the packet memory allocation stuff is broken. The + * packet is allocated if it was not really allocated + *) +function av_dup_packet (pkt: PAVPacket): integer; + cdecl; external av__format; + +(** + * Free a packet + * + * @param pkt packet to free + *) +procedure av_free_packet (pkt: PAVPacket); inline; + +(*************************************************) +(* fractional numbers for exact pts handling *) + +type + (** + * the exact value of the fractional number is: 'val + num / den'. + * num is assumed to be such as 0 <= num < den + * @deprecated Use AVRational instead + *) + PAVFrac = ^TAVFrac; + TAVFrac = record + val, num, den: int64; + end; {deprecated} + +(*************************************************) +(* input/output formats *) + +type + (* this structure contains the data a format has to probe a file *) + TAVProbeData = record + filename: pchar; + buf: pchar; + buf_size: integer; + end; + +const + AVPROBE_SCORE_MAX = 100; ///< max score, half of that is used for file extension based detection + AVPROBE_PADDING_SIZE = 32; ///< extra allocated bytes at the end of the probe buffer + + //! demuxer will use url_fopen, no opened file should be provided by the caller + AVFMT_NOFILE = $0001; + AVFMT_NEEDNUMBER = $0002; (**< needs '%d' in filename *) + AVFMT_SHOW_IDS = $0008; (**< show format stream IDs numbers *) + AVFMT_RAWPICTURE = $0020; (**< format wants AVPicture structure for + raw picture data *) + AVFMT_GLOBALHEADER = $0040; (**< format wants global header *) + AVFMT_NOTIMESTAMPS = $0080; (**< format does not need / have any timestamps *) + AVFMT_GENERIC_INDEX = $0100; (**< use generic index building code *) + + // used by AVIndexEntry + AVINDEX_KEYFRAME = $0001; + + AVFMTCTX_NOHEADER = $0001; (**< signal that no header is present + (streams are added dynamically) *) + MAX_STREAMS = 20; + + AVFMT_NOOUTPUTLOOP = -1; + AVFMT_INFINITEOUTPUTLOOP = 0; + AVFMT_FLAG_GENPTS = $0001; ///< generate pts if missing even if it requires parsing future frames + AVFMT_FLAG_IGNIDX = $0002; ///< ignore index + AVFMT_FLAG_NONBLOCK = $0004; ///< do not block when reading packets from input + + // used by AVStream + MAX_REORDER_DELAY = 4; + + // used by TAVProgram + AV_PROGRAM_RUNNING = 1; + +type + PPAVCodecTag = ^PAVCodecTag; + PAVCodecTag = Pointer; + + PPAVFormatContext = ^PAVFormatContext; + PAVFormatContext = ^TAVFormatContext; + + PAVFormatParameters = ^TAVFormatParameters; + + PAVOutputFormat = ^TAVOutputFormat; + PAVProbeData = ^TAVProbeData; + + PAVInputFormat = ^TAVInputFormat; + PAVIndexEntry = ^TAVIndexEntry; + + PAVStream = ^TAVStream; + PAVPacketList = ^TAVPacketList; + + PPAVProgram = ^PAVProgram; + PAVProgram = ^TAVProgram; + + {$IF LIBAVFORMAT_VERSION < 51006000} // 51.6.0 + PAVImageFormat = ^TAVImageFormat; + PAVImageInfo = ^TAVImageInfo; + {$IFEND} + + TAVFormatParameters = record + time_base: TAVRational; + sample_rate: integer; + channels: integer; + width: integer; + height: integer; + pix_fmt: TAVPixelFormat; + {$IF LIBAVFORMAT_VERSION < 51006000} // 51.6.0 + image_format: PAVImageFormat; + {$IFEND} + channel: integer; (* used to select dv channel *) + {$IF LIBAVFORMAT_VERSION_MAJOR < 52} + device: pchar; (* video, audio or DV device, if LIBAVFORMAT_VERSION_INT < (52<<16) *) + {$IFEND} + standard: pchar; (* tv standard, NTSC, PAL, SECAM *) + { Delphi does not support bit fields -> use bf_flags instead + int mpeg2ts_raw:1; (* force raw MPEG2 transport stream output, if possible *) + int mpeg2ts_compute_pcr:1; (* compute exact PCR for each transport + stream packet (only meaningful if + mpeg2ts_raw is TRUE *) + int initial_pause:1; (* do not begin to play the stream + immediately (RTSP only) *) + int prealloced_context:1; + } + bf_flags: byte; // 0:mpeg2ts_raw/1:mpeg2ts_compute_pcr/2:initial_pause/3:prealloced_context + {$IF LIBAVFORMAT_VERSION_MAJOR < 53} + video_codec_id: TCodecID; + audio_codec_id: TCodecID; + {$IFEND} + end; + + TAVOutputFormat = record + name: pchar; + long_name: pchar; + mime_type: pchar; + extensions: pchar; (*< comma separated filename extensions *) + (* size of private data so that it can be allocated in the wrapper *) + priv_data_size: integer; + (* output support *) + audio_codec: TCodecID; (* default audio codec *) + video_codec: TCodecID; (* default video codec *) + write_header: function (c: PAVFormatContext): integer; cdecl; + write_packet: function (c: PAVFormatContext; pkt: PAVPacket): integer; cdecl; + write_trailer: function (c: PAVFormatContext): integer; cdecl; + (* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER *) + flags: integer; + (* currently only used to set pixel format if not YUV420P *) + set_parameters: function (c: PAVFormatContext; f: PAVFormatParameters): integer; cdecl; + interleave_packet: function (s: PAVFormatContext; out_: PAVPacket; in_: PAVPacket; flush: integer): integer; cdecl; + + {$IF LIBAVFORMAT_VERSION >= 51008000} // 51.8.0 + (** + * list of supported codec_id-codec_tag pairs, ordered by "better choice first" + * the arrays are all CODEC_ID_NONE terminated + *) + codec_tag: {const} PPAVCodecTag; + {$IFEND} + + {$IF LIBAVFORMAT_VERSION >= 51012002} // 51.12.2 + subtitle_codec: TCodecID; (**< default subtitle codec *) + {$IFEND} + + (* private fields *) + next: PAVOutputFormat; + end; + + TAVInputFormat = record + name: pchar; + long_name: pchar; + (* size of private data so that it can be allocated in the wrapper *) + priv_data_size: integer; + (** + * Tell if a given file has a chance of being parsed by this format. + * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes + * big so you do not have to check for that unless you need more. + *) + read_probe: function (p: PAVProbeData): integer; cdecl; + (* read the format header and initialize the AVFormatContext + structure. Return 0 if OK. 'ap' if non NULL contains + additionnal paramters. Only used in raw format right + now. 'av_new_stream' should be called to create new streams. *) + read_header: function (c: PAVFormatContext; ap: PAVFormatParameters): integer; cdecl; + (* read one packet and put it in 'pkt'. pts and flags are also + set. 'av_new_stream' can be called only if the flag + AVFMTCTX_NOHEADER is used. *) + read_packet: function (c: PAVFormatContext; var pkt: TAVPacket): integer; cdecl; + (* close the stream. The AVFormatContext and AVStreams are not + freed by this function *) + read_close: function (c: PAVFormatContext): integer; cdecl; + (** + * seek to a given timestamp relative to the frames in + * stream component stream_index + * @param stream_index must not be -1 + * @param flags selects which direction should be preferred if no exact + * match is available + * @return >= 0 on success (but not necessarily the new offset) + *) + read_seek: function (c: PAVFormatContext; stream_index: integer; + timestamp: int64; flags: integer): integer; cdecl; + (** + * gets the next timestamp in stream[stream_index].time_base units. + * @return the timestamp or AV_NOPTS_VALUE if an error occured + *) + read_timestamp: function (s: PAVFormatContext; stream_index: integer; + pos: pint64; pos_limit: int64): int64; cdecl; + (* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER *) + flags: integer; + (* if extensions are defined, then no probe is done. You should + usually not use extension format guessing because it is not + reliable enough *) + extensions: pchar; + (* general purpose read only value that the format can use *) + value: integer; + + (* start/resume playing - only meaningful if using a network based format (RTSP) *) + read_play: function (c: PAVFormatContext): integer; cdecl; + + (* pause playing - only meaningful if using a network based format (RTSP) *) + read_pause: function (c: PAVFormatContext): integer; cdecl; + + {$IF LIBAVFORMAT_VERSION >= 51008000} // 51.8.0 + codec_tag: {const} PPAVCodecTag; + {$IFEND} + + (* private fields *) + next: PAVInputFormat; + end; + + TAVStreamParseType = ( + AVSTREAM_PARSE_NONE, + AVSTREAM_PARSE_FULL, (**< full parsing and repack *) + AVSTREAM_PARSE_HEADERS, (**< only parse headers, don't repack *) + AVSTREAM_PARSE_TIMESTAMPS (**< full parsing and interpolation of timestamps for frames not starting on packet boundary *) + ); + + TAVIndexEntry = record + pos: int64; + timestamp: int64; + { Delphi doesn't support bitfields -> use flags_size instead + int flags:2; + int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs 32 byte due to possible 8byte align). + } + flags_size: cardinal; // 0..1: flags, 2..31: size + min_distance: integer; (* min distance between this and the previous keyframe, used to avoid unneeded searching *) + end; + + (** + * Stream structure. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVStream) must not be used outside libav*. + *) + TAVStream = record + index: integer; (* stream index in AVFormatContext *) + id: integer; (* format specific stream id *) + codec: PAVCodecContext; (* codec context *) + (** + * Real base frame rate of the stream. + * This is the lowest frame rate with which all timestamps can be + * represented accurately (it is the least common multiple of all + * frame rates in the stream), Note, this value is just a guess! + * For example if the timebase is 1/90000 and all frames have either + * approximately 3600 or 1800 timer ticks then r_frame_rate will be 50/1. + *) + r_frame_rate: TAVRational; + priv_data: pointer; + + (* internal data used in av_find_stream_info() *) + first_dts: int64; + {$IF LIBAVFORMAT_VERSION_MAJOR < 52} + codec_info_nb_frames: integer; + {$IFEND} + + (** encoding: PTS generation when outputing stream *) + pts: TAVFrac; + (** + * This is the fundamental unit of time (in seconds) in terms + * of which frame timestamps are represented. For fixed-fps content, + * timebase should be 1/frame rate and timestamp increments should be + * identically 1. + *) + time_base: TAVRational; + pts_wrap_bits: integer; (* number of bits in pts (used for wrapping control) *) + (* ffmpeg.c private use *) + stream_copy: integer; (**< if set, just copy stream *) + discard: TAVDiscard; ///< selects which packets can be discarded at will and dont need to be demuxed + //FIXME move stuff to a flags field? + (* quality, as it has been removed from AVCodecContext and put in AVVideoFrame + * MN:dunno if thats the right place, for it *) + quality: single; + (** + * Decoding: pts of the first frame of the stream, in stream time base. + * Only set this if you are absolutely 100% sure that the value you set + * it to really is the pts of the first frame. + * This may be undefined (AV_NOPTS_VALUE). + * @note The ASF header does NOT contain a correct start_time the ASF + * demuxer must NOT set this. + *) + start_time: int64; + (** + * Decoding: duration of the stream, in stream time base. + * If a source file does not specify a duration, but does specify + * a bitrate, this value will be estimates from bit rate and file size. + *) + duration: int64; + + language: array [0..3] of char; (* ISO 639 3-letter language code (empty string if undefined) *) + + (* av_read_frame() support *) + need_parsing: TAVStreamParseType; + parser: PAVCodecParserContext; + + cur_dts: int64; + last_IP_duration: integer; + last_IP_pts: int64; + (* av_seek_frame() support *) + index_entries: PAVIndexEntry; (* only used if the format does not support seeking natively *) + nb_index_entries: integer; + index_entries_allocated_size: cardinal; + + nb_frames: int64; ///< number of frames in this stream if known or 0 + + {$IF LIBAVFORMAT_VERSION >= 50006000} // 50.6.0 + pts_buffer: array [0..MAX_REORDER_DELAY] of int64; + {$IFEND} + + {$IF LIBAVFORMAT_VERSION >= 52006000} // 52.6.0 + filename: PChar; (**< source filename of the stream *) + {$IFEND} + end; + + (** + * format I/O context. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVFormatContext) must not be used outside libav*. + *) + TAVFormatContext = record + av_class: PAVClass; (* set by av_alloc_format_context *) + (* can only be iformat or oformat, not both at the same time *) + iformat: PAVInputFormat; + oformat: PAVOutputFormat; + priv_data: pointer; + + {$IF LIBAVFORMAT_VERSION_MAJOR >= 52} + pb: PByteIOContext; + {$ELSE} + pb: TByteIOContext; + {$IFEND} + + nb_streams: cardinal; + streams: array [0..MAX_STREAMS - 1] of PAVStream; + filename: array [0..1023] of char; (* input or output filename *) + (* stream info *) + timestamp: int64; + title: array [0..511] of char; + author: array [0..511] of char; + copyright: array [0..511] of char; + comment: array [0..511] of char; + album: array [0..511] of char; + year: integer; (* ID3 year, 0 if none *) + track: integer; (* track number, 0 if none *) + genre: array [0..31] of char; (* ID3 genre *) + + ctx_flags: integer; (* format specific flags, see AVFMTCTX_xx *) + (* private data for pts handling (do not modify directly) *) + (* This buffer is only needed when packets were already buffered but + not decoded, for example to get the codec parameters in mpeg + streams *) + packet_buffer: PAVPacketList; + + (* decoding: position of the first frame of the component, in + AV_TIME_BASE fractional seconds. NEVER set this value directly: + it is deduced from the AVStream values. *) + start_time: int64; + (* decoding: duration of the stream, in AV_TIME_BASE fractional + seconds. NEVER set this value directly: it is deduced from the + AVStream values. *) + duration: int64; + (* decoding: total file size. 0 if unknown *) + file_size: int64; + (* decoding: total stream bitrate in bit/s, 0 if not + available. Never set it directly if the file_size and the + duration are known as ffmpeg can compute it automatically. *) + bit_rate: integer; + + (* av_read_frame() support *) + cur_st: PAVStream; + cur_ptr: pbyte; + cur_len: integer; + cur_pkt: TAVPacket; + + (* av_seek_frame() support *) + data_offset: int64; (* offset of the first packet *) + index_built: integer; + + mux_rate: integer; + packet_size: integer; + preload: integer; + max_delay: integer; + + (* number of times to loop output in formats that support it *) + loop_output: integer; + + flags: integer; + loop_input: integer; + + {$IF LIBAVFORMAT_VERSION >= 50006000} // 50.6.0 + (* decoding: size of data to probe; encoding unused *) + probesize: cardinal; + {$IFEND} + + {$IF LIBAVFORMAT_VERSION >= 51009000} // 51.9.0 + (** + * maximum duration in AV_TIME_BASE units over which the input should be analyzed in av_find_stream_info() + *) + max_analyze_duration: integer; + + key: pbyte; + keylen : integer; + {$IFEND} + + {$IF LIBAVFORMAT_VERSION >= 51014000} // 51.14.0 + nb_programs: cardinal; + programs: PPAVProgram; + {$IFEND} + + {$IF LIBAVFORMAT_VERSION >= 52003000} // 52.3.0 + (** + * Forced video codec_id. + * demuxing: set by user + *) + video_codec_id: TCodecID; + (** + * Forced audio codec_id. + * demuxing: set by user + *) + audio_codec_id: TCodecID; + (** + * Forced subtitle codec_id. + * demuxing: set by user + *) + subtitle_codec_id: TCodecID; + {$IFEND} + + {$IF LIBAVFORMAT_VERSION >= 52004000} // 52.4.0 + (** + * Maximum amount of memory in bytes to use per stream for the index. + * If the needed index exceeds this size entries will be discarded as + * needed to maintain a smaller size. This can lead to slower or less + * accurate seeking (depends on demuxer). + * Demuxers for which a full in memory index is mandatory will ignore + * this. + * muxing : unused + * demuxing: set by user + *) + max_index_size: cardinal; + {$IFEND} + end; + + (** + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVProgram) must not be used outside libav*. + *) + TAVProgram = record + id : integer; + provider_name : PChar; ///< Network name for DVB streams + name : PChar; ///< Service name for DVB streams + flags : integer; + discard : TAVDiscard; ///< selects which program to discard and which to feed to the caller + {$IF LIBAVFORMAT_VERSION >= 51016000} // 51.16.0 + stream_index : PCardinal; + nb_stream_indexes : PCardinal; + {$IFEND} + end; + + TAVPacketList = record + pkt: TAVPacket; + next: PAVPacketList; + end; + +{$IF LIBAVFORMAT_VERSION < 51006000} // 51.6.0 + (* still image support *) + PAVInputImageContext = pointer; {deprecated} + + (* still image support *) + TAVImageInfo = record + pix_fmt: TAVPixelFormat; (* requested pixel format *) + width: integer; (* requested width *) + height: integer; (* requested height *) + interleaved: integer; (* image is interleaved (e.g. interleaved GIF) *) + pict: TAVPicture; (* returned allocated image *) + end; {deprecated} + + TAVImageFormat = record + name: pchar; + extensions: pchar; + (* tell if a given file has a chance of being parsing by this format *) + img_probe: function (d: PAVProbeData): integer; cdecl; + (* read a whole image. 'alloc_cb' is called when the image size is + known so that the caller can allocate the image. If 'allo_cb' + returns non zero, then the parsing is aborted. Return '0' if + OK. *) + img_read: function (b: PByteIOContext; alloc_cb: pointer; ptr: pointer): integer; cdecl; + (* write the image *) + supported_pixel_formats: integer; (* mask of supported formats for output *) + img_write: function (b: PByteIOContext; i: PAVImageInfo): integer; cdecl; + flags: integer; + next: PAVImageFormat; + end; {deprecated} + +procedure av_register_image_format (img_fmt: PAVImageFormat); + cdecl; external av__format; deprecated; + +function av_probe_image_format (pd: PAVProbeData): PAVImageFormat; + cdecl; external av__format; deprecated; + +function guess_image_format (filename: pchar): PAVImageFormat; + cdecl; external av__format; deprecated; + +function av_read_image (pb: PByteIOContext; filename: pchar; + fmt: PAVImageFormat; + alloc_cb: pointer; opaque: pointer): integer; + cdecl; external av__format; deprecated; + +function av_write_image(pb: PByteIOContext; fmt: PAVImageFormat; img: PAVImageInfo): integer; + cdecl; external av__format; deprecated; +{$IFEND} + +{$IF LIBAVFORMAT_VERSION_MAJOR < 53} +{ +var + first_iformat: PAVInputFormat; external av__format; + first_oformat: PAVOutputFormat; external av__format; +} +{$IFEND} + +{$IF LIBAVFORMAT_VERSION >= 52003000} // 52.3.0 +function av_iformat_next(f: PAVInputFormat): PAVInputFormat; + cdecl; external av__format; +function av_oformat_next(f: PAVOutputFormat): PAVOutputFormat; + cdecl; external av__format; +{$IFEND} + +function av_guess_image2_codec({const} filename: PChar): TCodecID; + cdecl; external av__format; + +(* XXX: use automatic init with either ELF sections or C file parser *) +(* modules *) + +(* utils.c *) +procedure av_register_input_format (format: PAVInputFormat); + cdecl; external av__format; + +procedure av_register_output_format (format: PAVOutputFormat); + cdecl; external av__format; + +function guess_stream_format (short_name: pchar; filename: pchar; mime_type: pchar): PAVOutputFormat; + cdecl; external av__format; + +function guess_format(short_name: pchar; filename: pchar; mime_type: pchar): PAVOutputFormat; + cdecl; external av__format; + +(** + * Guesses the codec id based upon muxer and filename. + *) +function av_guess_codec(fmt: PAVOutputFormat; short_name: pchar; + filename: pchar; mime_type: pchar; type_: TCodecType): TCodecID; + cdecl; external av__format; + +(** + * Send a nice hexadecimal dump of a buffer to the specified file stream. + * + * @param f The file stream pointer where the dump should be sent to. + * @param buf buffer + * @param size buffer size + * + * @see av_hex_dump_log, av_pkt_dump, av_pkt_dump_log + *) +procedure av_hex_dump (f: PAVFile; buf: pchar; size: integer); + cdecl; external av__format; + +{$IF LIBAVFORMAT_VERSION >= 51011000} // 51.11.0 +(** + * Send a nice hexadecimal dump of a buffer to the log. + * + * @param avcl A pointer to an arbitrary struct of which the first field is a + * pointer to an AVClass struct. + * @param level The importance level of the message, lower values signifying + * higher importance. + * @param buf buffer + * @param size buffer size + * + * @see av_hex_dump, av_pkt_dump, av_pkt_dump_log + *) +procedure av_hex_dump_log(avcl: Pointer; level: integer; buf: PChar; size: integer); + cdecl; external av__format; +{$IFEND} + +(** + * Send a nice dump of a packet to the specified file stream. + * + * @param f The file stream pointer where the dump should be sent to. + * @param pkt packet to dump + * @param dump_payload true if the payload must be displayed too + *) +procedure av_pkt_dump(f: PAVFile; pkt: PAVPacket; dump_payload: integer); + cdecl; external av__format; + +{$IF LIBAVFORMAT_VERSION >= 51011000} // 51.11.0 +(** + * Send a nice dump of a packet to the log. + * + * @param avcl A pointer to an arbitrary struct of which the first field is a + * pointer to an AVClass struct. + * @param level The importance level of the message, lower values signifying + * higher importance. + * @param pkt packet to dump + * @param dump_payload true if the payload must be displayed too + *) +procedure av_pkt_dump_log(avcl: Pointer; level: integer; pkt: PAVPacket; dump_payload: integer); + cdecl; external av__format; +{$IFEND} + +procedure av_register_all (); + cdecl; external av__format; + +{$IF LIBAVFORMAT_VERSION >= 51008000} // 51.8.0 +(** codec tag <-> codec id *) +function av_codec_get_id(var tags: PAVCodecTag; tag: cardinal): TCodecID; + cdecl; external av__format; +function av_codec_get_tag(var tags: PAVCodecTag; id: TCodecID): cardinal; + cdecl; external av__format; +{$IFEND} + +(* media file input *) + +(** + * finds AVInputFormat based on input format's short name. + *) +function av_find_input_format (short_name: pchar): PAVInputFormat; + cdecl; external av__format; + +(** + * Guess file format. + * + * @param is_opened whether the file is already opened, determines whether + * demuxers with or without AVFMT_NOFILE are probed + *) +function av_probe_input_format (pd: PAVProbeData; is_opened: integer): PAVInputFormat; + cdecl; external av__format; + +(** + * Allocates all the structures needed to read an input stream. + * This does not open the needed codecs for decoding the stream[s]. + *) +function av_open_input_stream (ic_ptr: PAVFormatContext; + pb: PByteIOContext; filename: pchar; + fmt: PAVInputFormat; ap: PAVFormatParameters): integer; + cdecl; external av__format; + +(** + * Open a media file as input. The codecs are not opened. Only the file + * header (if present) is read. + * + * @param ic_ptr the opened media file handle is put here + * @param filename filename to open. + * @param fmt if non NULL, force the file format to use + * @param buf_size optional buffer size (zero if default is OK) + * @param ap additional parameters needed when opening the file (NULL if default) + * @return 0 if OK. AVERROR_xxx otherwise. + *) +function av_open_input_file (var ic_ptr: PAVFormatContext; filename: pchar; + fmt: PAVInputFormat; buf_size: integer; + ap: PAVFormatParameters): integer; + cdecl; external av__format; + +(** + * Allocate an AVFormatContext. + * Can be freed with av_free() but do not forget to free everything you + * explicitly allocated as well! + *) +function av_alloc_format_context (): PAVFormatContext; + cdecl; external av__format; + +(** + * Read packets of a media file to get stream information. This + * is useful for file formats with no headers such as MPEG. This + * function also computes the real frame rate in case of mpeg2 repeat + * frame mode. + * The logical file position is not changed by this function; + * examined packets may be buffered for later processing. + * + * @param ic media file handle + * @return >=0 if OK. AVERROR_xxx if error. + * @todo Let user decide somehow what information is needed so we do not waste time getting stuff the user does not need. + *) +function av_find_stream_info (ic: PAVFormatContext): integer; + cdecl; external av__format; + +(** + * Read a transport packet from a media file. + * + * This function is obsolete and should never be used. + * Use av_read_frame() instead. + * + * @param s media file handle + * @param pkt is filled + * @return 0 if OK. AVERROR_xxx if error. + *) +function av_read_packet (s: PAVFormatContext; var pkt: TAVPacket): integer; + cdecl; external av__format; + +(** + * Return the next frame of a stream. + * + * The returned packet is valid + * until the next av_read_frame() or until av_close_input_file() and + * must be freed with av_free_packet. For video, the packet contains + * exactly one frame. For audio, it contains an integer number of + * frames if each frame has a known fixed size (e.g. PCM or ADPCM + * data). If the audio frames have a variable size (e.g. MPEG audio), + * then it contains one frame. + * + * pkt->pts, pkt->dts and pkt->duration are always set to correct + * values in AVStream.timebase units (and guessed if the format cannot + * provided them). pkt->pts can be AV_NOPTS_VALUE if the video format + * has B frames, so it is better to rely on pkt->dts if you do not + * decompress the payload. + * + * @return 0 if OK, < 0 if error or end of file. + *) +function av_read_frame (s: PAVFormatContext; var pkt: TAVPacket): integer; (* CAT#2 *) + cdecl; external av__format; + +(** + * Seek to the key frame at timestamp. + * 'timestamp' in 'stream_index'. + * @param stream_index If stream_index is (-1), a default + * stream is selected, and timestamp is automatically converted + * from AV_TIME_BASE units to the stream specific time_base. + * @param timestamp timestamp in AVStream.time_base units + * or if there is no stream specified then in AV_TIME_BASE units + * @param flags flags which select direction and seeking mode + * @return >= 0 on success + *) +function av_seek_frame (s: PAVFormatContext; stream_index: integer; timestamp: int64; flags: integer): integer; + cdecl; external av__format; + +(** + * start playing a network based stream (e.g. RTSP stream) at the + * current position + *) +function av_read_play (s: PAVFormatContext): integer; + cdecl; external av__format; + +(** + * Pause a network based stream (e.g. RTSP stream). + * + * Use av_read_play() to resume it. + *) +function av_read_pause (s: PAVFormatContext): integer; + cdecl; external av__format; + +{$IF LIBAVFORMAT_VERSION >= 52003000} // 52.3.0 +(** + * Free a AVFormatContext allocated by av_open_input_stream. + * @param s context to free + *) +procedure av_close_input_stream(s: PAVFormatContext); + cdecl; external av__format; +{$IFEND} + +(** + * Close a media file (but not its codecs). + * + * @param s media file handle + *) +procedure av_close_input_file (s: PAVFormatContext); + cdecl; external av__format; + +(** + * Add a new stream to a media file. + * + * Can only be called in the read_header() function. If the flag + * AVFMTCTX_NOHEADER is in the format context, then new streams + * can be added in read_packet too. + * + * @param s media file handle + * @param id file format dependent stream id + *) +function av_new_stream (s: PAVFormatContext; id: integer): PAVStream; + cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION >= 51014000} // 51.14.0 +function av_new_program(s: PAVFormatContext; id: integer): PAVProgram; + cdecl; external av__format; +{$IFEND} + +(** + * Set the pts for a given stream. + * + * @param s stream + * @param pts_wrap_bits number of bits effectively used by the pts + * (used for wrap control, 33 is the value for MPEG) + * @param pts_num numerator to convert to seconds (MPEG: 1) + * @param pts_den denominator to convert to seconds (MPEG: 90000) + *) +procedure av_set_pts_info (s: PAVStream; pts_wrap_bits: integer; + pts_num: integer; pts_den: integer); + cdecl; external av__format; + +const + AVSEEK_FLAG_BACKWARD = 1; ///< seek backward + AVSEEK_FLAG_BYTE = 2; ///< seeking based on position in bytes + AVSEEK_FLAG_ANY = 4; ///< seek to any frame, even non keyframes + +function av_find_default_stream_index (s: PAVFormatContext): integer; + cdecl; external av__format; + +(** + * Gets the index for a specific timestamp. + * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond to + * the timestamp which is <= the requested one, if backward is 0 + * then it will be >= + * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise + * @return < 0 if no such timestamp could be found + *) +function av_index_search_timestamp (st: PAVStream; timestamp: int64; flags: integer): integer; + cdecl; external av__format; + +{$IF LIBAVFORMAT_VERSION >= 52004000} // 52.4.0 +(** + * Ensures the index uses less memory than the maximum specified in + * AVFormatContext.max_index_size, by discarding entries if it grows + * too large. + * This function is not part of the public API and should only be called + * by demuxers. + *) +procedure ff_reduce_index(s: PAVFormatContext; stream_index: integer); + cdecl; external av__format; +{$IFEND} + +(** + * Add a index entry into a sorted list updateing if it is already there. + * + * @param timestamp timestamp in the timebase of the given stream + *) +function av_add_index_entry (st: PAVStream; pos: int64; timestamp: int64; + distance: integer; flags: integer): integer; + cdecl; external av__format; + +(** + * Does a binary search using av_index_search_timestamp() and AVCodec.read_timestamp(). + * This is not supposed to be called directly by a user application, but by demuxers. + * @param target_ts target timestamp in the time base of the given stream + * @param stream_index stream number + *) +function av_seek_frame_binary (s: PAVFormatContext; stream_index: integer; + target_ts: int64; flags: integer): integer; + cdecl; external av__format; + + +(** + * Updates cur_dts of all streams based on given timestamp and AVStream. + * + * Stream ref_st unchanged, others set cur_dts in their native timebase + * only needed for timestamp wrapping or if (dts not set and pts!=dts). + * @param timestamp new dts expressed in time_base of param ref_st + * @param ref_st reference stream giving time_base of param timestamp + *) +procedure av_update_cur_dts (s: PAVFormatContext; ref_st: PAVStream; + timestamp: int64); + cdecl; external av__format; + +{$IF LIBAVFORMAT_VERSION >= 51007000} // 51.7.0 +type + TReadTimestampFunc = function (pavfc: PAVFormatContext; + arg2: integer; arg3: Pint64; arg4: int64): int64; cdecl; + +(** + * Does a binary search using read_timestamp(). + * This is not supposed to be called directly by a user application, but by demuxers. + * @param target_ts target timestamp in the time base of the given stream + * @param stream_index stream number + *) +function av_gen_search(s: PAVFormatContext; stream_index: integer; target_ts: int64; + pos_min: int64; pos_max: int64; pos_limit: int64; ts_min: int64; ts_max: int64; + flags: integer; ts_ret: Pint64; read_timestamp: TReadTimestampFunc): int64; + cdecl; external av__format; +{$IFEND} + +(* media file output *) +function av_set_parameters (s: PAVFormatContext; ap: PAVFormatParameters): integer; + cdecl; external av__format; + +(** + * Allocate the stream private data and write the stream header to an + * output media file. + * + * @param s media file handle + * @return 0 if OK. AVERROR_xxx if error. + *) +function av_write_header (s: PAVFormatContext): integer; + cdecl; external av__format; + +(** + * Write a packet to an output media file. + * + * The packet shall contain one audio or video frame. + * The packet must be correctly interleaved according to the container specification, + * if not then av_interleaved_write_frame must be used + * + * @param s media file handle + * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ... + * @return < 0 if error, = 0 if OK, 1 if end of stream wanted. + *) +function av_write_frame(s: PAVFormatContext; var pkt: TAVPacket): integer; + cdecl; external av__format; (* CAT#2 *) + +(** + * Writes a packet to an output media file ensuring correct interleaving. + * + * The packet must contain one audio or video frame. + * If the packets are already correctly interleaved the application should + * call av_write_frame() instead as it is slightly faster. It is also important + * to keep in mind that completely non-interleaved input will need huge amounts + * of memory to interleave with this, so it is preferable to interleave at the + * demuxer level. + * + * @param s media file handle + * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ... + * @return < 0 if error, = 0 if OK, 1 if end of stream wanted. + *) +function av_interleaved_write_frame (s: PAVFormatContext; var pkt: TAVPacket): integer; + cdecl; external av__format; (* CAT#2 *) + +(** + * Interleave a packet per DTS in an output media file. + * + * Packets with pkt->destruct == av_destruct_packet will be freed inside this function, + * so they cannot be used after it, note calling av_free_packet() on them is still safe. + * + * @param s media file handle + * @param out the interleaved packet will be output here + * @param in the input packet + * @param flush 1 if no further packets are available as input and all + * remaining packets should be output + * @return 1 if a packet was output, 0 if no packet could be output, + * < 0 if an error occured + *) +function av_interleave_packet_per_dts(s: PAVFormatContext; _out: PAVPacket; + pkt: PAVPacket; flush: integer): integer; + cdecl; external av__format; + +(** + * @brief Write the stream trailer to an output media file and + * free the file private data. + * + * @param s media file handle + * @return 0 if OK. AVERROR_xxx if error. + *) +function av_write_trailer(s: pAVFormatContext): integer; + cdecl; external av__format; + +procedure dump_format(ic: PAVFormatContext; index: integer; url: pchar; + is_output: integer); + cdecl; external av__format; + +(** + * parses width and height out of string str. + * @deprecated Use av_parse_video_frame_size instead. + *) +function parse_image_size(width_ptr: PInteger; height_ptr: PInteger; str: pchar): integer; + cdecl; external av__format; deprecated; + +(** + * Converts frame rate from string to a fraction. + * @deprecated Use av_parse_video_frame_rate instead. + *) +function parse_frame_rate (frame_rate: PInteger; frame_rate_base: PInteger; arg: pchar): integer; + cdecl; external av__format; deprecated; + +(** + * Parses \p datestr and returns a corresponding number of microseconds. + * @param datestr String representing a date or a duration. + * - If a date the syntax is: + * @code + * [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]} + * @endcode + * Time is localtime unless Z is appended, in which case it is + * interpreted as UTC. + * If the year-month-day part isn't specified it takes the current + * year-month-day. + * Returns the number of microseconds since 1st of January, 1970 up to + * the time of the parsed date or INT64_MIN if \p datestr cannot be + * successfully parsed. + * - If a duration the syntax is: + * @code + * [-]HH[:MM[:SS[.m...]]] + * [-]S+[.m...] + * @endcode + * Returns the number of microseconds contained in a time interval + * with the specified duration or INT64_MIN if \p datestr cannot be + * successfully parsed. + * @param duration Flag which tells how to interpret \p datestr, if + * not zero \p datestr is interpreted as a duration, otherwise as a + * date. + *) +function parse_date(datestr: pchar; duration: integer): int64; + cdecl; external av__format; + +function av_gettime (): int64; + cdecl; external av__format; + +(* ffm specific for ffserver *) +const + FFM_PACKET_SIZE = 4096; + +function ffm_read_write_index (fd: integer): int64; + cdecl; external av__format; + +procedure ffm_write_write_index(fd: integer; pos: int64); + cdecl; external av__format; + +procedure ffm_set_write_index (s: PAVFormatContext; pos: int64; file_size: int64); + cdecl; external av__format; + +(** + * Attempts to find a specific tag in a URL. + * + * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done. + * Return 1 if found. + *) +function find_info_tag (arg: pchar; arg_size: integer; tag1: pchar; info: pchar): integer; + cdecl; external av__format; + +(** + * Returns in 'buf' the path with '%d' replaced by number. + + * Also handles the '%0nd' format where 'n' is the total number + * of digits and '%%'. + * + * @param buf destination buffer + * @param buf_size destination buffer size + * @param path numbered sequence string + * @param number frame number + * @return 0 if OK, -1 if format error. + *) +function av_get_frame_filename(buf: pchar; buf_size: integer; + path: pchar; number: integer): integer; + cdecl; external av__format + {$IF LIBAVFORMAT_VERSION <= 50006000} // 50.6.0 + name 'get_frame_filename' + {$IFEND}; + +(** + * Check whether filename actually is a numbered sequence generator. + * + * @param filename possible numbered sequence string + * @return 1 if a valid numbered sequence string, 0 otherwise. + *) +function av_filename_number_test(filename: pchar): integer; + cdecl; external av__format + {$IF LIBAVFORMAT_VERSION <= 50006000} // 50.6.0 + name 'filename_number_test' + {$IFEND}; + +{$IF LIBAVFORMAT_VERSION >= 51012002} // 51.12.2 +(** + * Generate an SDP for an RTP session. + * + * @param ac array of AVFormatContexts describing the RTP streams. If the + * array is composed by only one context, such context can contain + * multiple AVStreams (one AVStream per RTP stream). Otherwise, + * all the contexts in the array (an AVCodecContext per RTP stream) + * must contain only one AVStream + * @param n_files number of AVCodecContexts contained in ac + * @param buff buffer where the SDP will be stored (must be allocated by + * the caller + * @param size the size of the buffer + * @return 0 if OK. AVERROR_xxx if error. + *) +function avf_sdp_create(ac: PPAVFormatContext; n_files: integer; buff: PChar; size: integer): integer; + cdecl; external av__format; +{$IFEND} + +implementation + +{$IF LIBAVFORMAT_VERSION < 51012002} // 51.12.2 +procedure av_init_packet (var pkt: TAVPacket); +begin + with pkt do begin + pts := AV_NOPTS_VALUE; + dts := AV_NOPTS_VALUE; + pos := -1; + duration := 0; + flags := 0; + stream_index := 0; + destruct := @av_destruct_packet_nofree + end +end; +{$IFEND} + +procedure av_free_packet (pkt: PAVPacket); +begin + if ((pkt <> nil) and (@pkt^.destruct <> nil)) then + pkt^.destruct(pkt); +end; + +end. diff --git a/Game/Code/lib/ffmpeg/avio.pas b/Game/Code/lib/ffmpeg/avio.pas new file mode 100644 index 00000000..a4d7af12 --- /dev/null +++ b/Game/Code/lib/ffmpeg/avio.pas @@ -0,0 +1,490 @@ +(* + * unbuffered io for ffmpeg system + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(* This is a part of Pascal porting of ffmpeg. Originally by Victor Zinetz for Delphi and Free Pascal on Windows. +For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT +in the source codes *) + +(* + * Revision: 11305, Sat Dec 22 16:18:07 2007 UTC + *) + +unit avio; + +{$IFDEF FPC} + {$MODE DELPHI } + {$PACKENUM 4} (* use 4-byte enums *) + {$PACKRECORDS C} (* C/C++-compatible record packing *) +{$ELSE} + {$MINENUMSIZE 4} (* use 4-byte enums *) +{$ENDIF} + +interface + +uses + UConfig; + +(* output byte stream handling *) + +type + TOffset = int64; + +(* unbuffered I/O *) + +const + URL_RDONLY = 0; + URL_WRONLY = 1; + URL_RDWR = 2; + + (** + * Passing this as the "whence" parameter to a seek function causes it to + * return the filesize without seeking anywhere. Supporting this is optional. + * If it is not supported then the seek function will return <0. + *) + AVSEEK_SIZE = $10000; + +type + TURLInterruptCB = function (): integer; cdecl; + +type + PURLProtocol = ^TURLProtocol; + + (** + * URL Context. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(URLContext) must not be used outside libav*. + *) + PURLContext = ^TURLContext; + TURLContext = record + prot: PURLProtocol; + flags: integer; + is_streamed: integer; (**< true if streamed (no seek possible), default = false *) + max_packet_size: integer; (**< if non zero, the stream is packetized with this max packet size *) + priv_data: pointer; + filename: PChar; (**< specified filename *) + end; + + PURLPollEntry = ^TURLPollEntry; + TURLPollEntry = record + handle: PURLContext; + events: integer; + revents: integer; + end; + + TURLProtocol = record + name: pchar; + url_open: function (h: PURLContext; {const} filename: pchar; flags: integer): integer; cdecl; + url_read: function (h: PURLContext; buf: pchar; size: integer): integer; cdecl; + url_write: function (h: PURLContext; buf: pchar; size: integer): integer; cdecl; + url_seek: function (h: PURLContext; pos: TOffset; whence: integer): TOffset; cdecl; + url_close: function (h: PURLContext): integer; cdecl; + next: PURLProtocol; + {$IF (LIBAVFORMAT_VERSION >= 52001000) and (LIBAVFORMAT_VERSION < 52004000)} // 52.1.0 .. 52.4.0 + url_read_play: function (h: PURLContext): integer; + url_read_pause: function (h: PURLContext): integer; + {$IFEND} + {$IF LIBAVFORMAT_VERSION >= 52004000} // 52.4.0 + url_read_pause: function (h: PURLContext; pause: integer): integer; cdecl; + {$IFEND} + {$IF LIBAVFORMAT_VERSION >= 52001000} // 52.1.0 + url_read_seek: function (h: PURLContext; + stream_index: integer; timestamp: int64; flags: integer): TOffset; cdecl; + {$IFEND} + end; + + (** + * Bytestream IO Context. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(ByteIOContext) must not be used outside libav*. + *) + PByteIOContext = ^TByteIOContext; + TByteIOContext = record + buffer: pchar; + buffer_size: integer; + buf_ptr: pchar; + buf_end: pchar; + opaque: pointer; + read_packet: function (opaque: pointer; buf: pchar; buf_size: integer): integer; cdecl; + write_packet: function (opaque: pointer; buf: pchar; buf_size: integer): integer; cdecl; + seek: function (opaque: pointer; offset: TOffset; whence: integer): TOffset; cdecl; + pos: TOffset; (* position in the file of the current buffer *) + must_flush: integer; (* true if the next seek should flush *) + eof_reached: integer; (* true if eof reached *) + write_flag: integer; (* true if open for writing *) + is_streamed: integer; + max_packet_size: integer; + checksum: longword; + checksum_ptr: pchar; + update_checksum: function (checksum: Longword; {const} buf: pchar; size: cardinal): Longword; cdecl; + error: integer; ///< contains the error code or 0 if no error happened + {$IF (LIBAVFORMAT_VERSION >= 52001000) and (LIBAVFORMAT_VERSION < 52004000)} // 52.1.0 .. 52.4.0 + read_play: function(opaque: Pointer): integer; cdecl; + read_pause: function(opaque: Pointer): integer; cdecl; + {$IFEND} + {$IF LIBAVFORMAT_VERSION >= 52004000} // 52.4.0 + read_pause: function(opaque: Pointer; pause: integer): integer; cdecl; + {$IFEND} + {$IF LIBAVFORMAT_VERSION >= 52001000} // 52.1.0 + read_seek: function(opaque: Pointer; + stream_index: integer; timestamp: int64; flags: integer): TOffset; cdecl; + {$IFEND} + end; + +function url_open(h: PPointer; {const} filename: pchar; flags: integer): integer; + cdecl; external av__format; +function url_read (h: PURLContext; buf: pchar; size: integer): integer; + cdecl; external av__format; +function url_write (h: PURLContext; buf: pchar; size: integer): integer; + cdecl; external av__format; +function url_seek (h: PURLContext; pos: TOffset; whence: integer): TOffset; + cdecl; external av__format; +function url_close (h: PURLContext): integer; + cdecl; external av__format; +function url_exist(const filename: pchar): integer; + cdecl; external av__format; +function url_filesize (h: PURLContext): TOffset; + cdecl; external av__format; + +(** + * Return the maximum packet size associated to packetized file + * handle. If the file is not packetized (stream like HTTP or file on + * disk), then 0 is returned. + * + * @param h file handle + * @return maximum packet size in bytes + *) +function url_get_max_packet_size(h: PURLContext): integer; + cdecl; external av__format; +procedure url_get_filename(h: PURLContext; buf: pchar; buf_size: integer); + cdecl; external av__format; + +(** + * The callback is called in blocking functions to test regulary if + * asynchronous interruption is needed. AVERROR(EINTR) is returned + * in this case by the interrupted function. 'NULL' means no interrupt + * callback is given. + *) +procedure url_set_interrupt_cb (interrupt_cb: TURLInterruptCB); + cdecl; external av__format; + +(* not implemented *) +function url_poll(poll_table: PURLPollEntry; n: integer; timeout: integer): integer; + cdecl; external av__format; + +{$IF LIBAVFORMAT_VERSION >= 52004000} // 52.4.0 +(** + * Pause and resume playing - only meaningful if using a network streaming + * protocol (e.g. MMS). + * @param pause 1 for pause, 0 for resume + *) +function av_url_read_pause(h: PURLContext; pause: integer): integer; + cdecl; external av__format; +{$IFEND} + +{$IF LIBAVFORMAT_VERSION >= 52001000} // 52.1.0 +(** + * Seek to a given timestamp relative to some component stream. + * Only meaningful if using a network streaming protocol (e.g. MMS.). + * @param stream_index The stream index that the timestamp is relative to. + * If stream_index is (-1) the timestamp should be in AV_TIME_BASE + * units from the beginning of the presentation. + * If a stream_index >= 0 is used and the protocol does not support + * seeking based on component streams, the call will fail with ENOTSUP. + * @param timestamp timestamp in AVStream.time_base units + * or if there is no stream specified then in AV_TIME_BASE units. + * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE + * and AVSEEK_FLAG_ANY. The protocol may silently ignore + * AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will + * fail with ENOTSUP if used and not supported. + * @return >= 0 on success + * @see AVInputFormat::read_seek + *) +function av_url_read_seek(h: PURLContext; + stream_index: integer; timestamp: int64; flags: integer): TOffset; + cdecl; external av__format; +{$IFEND} + +{ +var + first_protocol: PURLProtocol; external av__format; + url_interrupt_cb: PURLInterruptCB; external av__format; +} + +{$IF LIBAVFORMAT_VERSION >= 52002000} // 52.2.0 +function av_protocol_next(p: PURLProtocol): PURLProtocol; + cdecl; external av__format; +{$IFEND} + +function register_protocol (protocol: PURLProtocol): integer; + cdecl; external av__format; + +type + TReadWriteFunc = function (opaque: Pointer; buf: PChar; buf_size: integer): integer; cdecl; + TSeekFunc = function (opaque: Pointer; offset: TOffset; whence: integer): TOffset; cdecl; + +function init_put_byte(s: PByteIOContext; + buffer: pchar; + buffer_size: integer; write_flag: integer; + opaque: pointer; + read_packet: TReadWriteFunc; + write_packet: TReadWriteFunc; + seek: TSeekFunc): integer; + cdecl; external av__format; +{$IF LIBAVFORMAT_VERSION >= 52004000} // 52.4.0 +function av_alloc_put_byte( + buffer: PChar; + buffer_size: integer; + write_flag: integer; + opaque: Pointer; + read_packet: TReadWriteFunc; + write_packet: TReadWriteFunc; + seek: TSeekFunc): PByteIOContext; + cdecl; external av__format; +{$IFEND} + +procedure put_byte(s: PByteIOContext; b: integer); + cdecl; external av__format; +procedure put_buffer (s: PByteIOContext; {const} buf: pchar; size: integer); + cdecl; external av__format; +procedure put_le64(s: PByteIOContext; val: int64); + cdecl; external av__format; +procedure put_be64(s: PByteIOContext; val: int64); + cdecl; external av__format; +procedure put_le32(s: PByteIOContext; val: cardinal); + cdecl; external av__format; +procedure put_be32(s: PByteIOContext; val: cardinal); + cdecl; external av__format; +procedure put_le24(s: PByteIOContext; val: cardinal); + cdecl; external av__format; +procedure put_be24(s: PByteIOContext; val: cardinal); + cdecl; external av__format; +procedure put_le16(s: PByteIOContext; val: cardinal); + cdecl; external av__format; +procedure put_be16(s: PByteIOContext; val: cardinal); + cdecl; external av__format; +procedure put_tag(s: PByteIOContext; {const} tag: pchar); + cdecl; external av__format; + +procedure put_strz(s: PByteIOContext; {const} buf: pchar); + cdecl; external av__format; + +function url_fseek(s: PByteIOContext; offset: TOffset; whence: integer): TOffset; + cdecl; external av__format; +procedure url_fskip(s: PByteIOContext; offset: TOffset); + cdecl; external av__format; +function url_ftell(s: PByteIOContext): TOffset; + cdecl; external av__format; +function url_fsize(s: PByteIOContext): TOffset; + cdecl; external av__format; +function url_feof(s: PByteIOContext): integer; + cdecl; external av__format; +function url_ferror(s: PByteIOContext): integer; + cdecl; external av__format; + +{$IF LIBAVFORMAT_VERSION >= 52004000} // 52.4.0 +function av_url_read_fpause(h: PByteIOContext; pause: integer): integer; + cdecl; external av__format; +{$IFEND} +{$IF LIBAVFORMAT_VERSION >= 52001000} // 52.1.0 +function av_url_read_fseek(h: PByteIOContext; + stream_index: integer; timestamp: int64; flags: integer): TOffset; + cdecl; external av__format; +{$IFEND} + +const + URL_EOF = -1; +(** @note return URL_EOF (-1) if EOF *) +function url_fgetc(s: PByteIOContext): integer; + cdecl; external av__format; + +(** @warning currently size is limited *) +function url_fprintf(s: PByteIOContext; {const} fmt: PChar; args: array of const): integer; + cdecl; external av__format; + +(** @note unlike fgets, the EOL character is not returned and a whole + line is parsed. return NULL if first char read was EOF *) +function url_fgets(s: PByteIOContext; buf: PChar; buf_size: integer): PChar; + cdecl; external av__format; + +procedure put_flush_packet (s: PByteIOContext); + cdecl; external av__format; + +function get_buffer(s: PByteIOContext; buf: pchar; size: integer): integer; + cdecl; external av__format; +function get_partial_buffer(s: PByteIOContext; buf: pchar; size: integer): integer; + cdecl; external av__format; + +(** @note return 0 if EOF, so you cannot use it if EOF handling is + necessary *) +function get_byte(s: PByteIOContext): integer; + cdecl; external av__format; +function get_le24(s: PByteIOContext): cardinal; + cdecl; external av__format; +function get_le32(s: PByteIOContext): cardinal; + cdecl; external av__format; +function get_le64(s: PByteIOContext): uint64; + cdecl; external av__format; +function get_le16(s: PByteIOContext): cardinal; + cdecl; external av__format; + +function get_strz(s: PByteIOContext; buf: pchar; maxlen: integer): pchar; + cdecl; external av__format; +function get_be16(s: PByteIOContext): cardinal; + cdecl; external av__format; +function get_be24(s: PByteIOContext): cardinal; + cdecl; external av__format; +function get_be32(s: PByteIOContext): cardinal; + cdecl; external av__format; +function get_be64(s: PByteIOContext): uint64; + cdecl; external av__format; + +{$IF LIBAVFORMAT_VERSION >= 51017001} // 51.17.1 +function ff_get_v(bc: PByteIOContext): uint64; + cdecl; external av__format; +{$IFEND} + +function url_is_streamed(s: PByteIOContext): integer; inline; + +(** @note when opened as read/write, the buffers are only used for + writing *) +{$IF LIBAVFORMAT_VERSION >= 52000000} // 52.0.0 +function url_fdopen (var s: PByteIOContext; h: PURLContext): integer; +{$ELSE} +function url_fdopen (s: PByteIOContext; h: PURLContext): integer; +{$IFEND} + cdecl; external av__format; + +(** @warning must be called before any I/O *) +function url_setbufsize (s: PByteIOContext; buf_size: integer): integer; + cdecl; external av__format; + +{$IF LIBAVFORMAT_VERSION >= 51015000} // 51.15.0 +(** Reset the buffer for reading or writing. + * @note Will drop any data currently in the buffer without transmitting it. + * @param flags URL_RDONLY to set up the buffer for reading, or URL_WRONLY + * to set up the buffer for writing. *) +function url_resetbuf(s: PByteIOContext; flags: integer): integer; + cdecl; external av__format; +{$IFEND} + +(** @note when opened as read/write, the buffers are only used for + writing *) +{$IF LIBAVFORMAT_VERSION >= 52000000} // 52.0.0 +function url_fopen(var s: PByteIOContext; const filename: pchar; flags: integer): integer; +{$ELSE} +function url_fopen(s: PByteIOContext; const filename: pchar; flags: integer): integer; +{$IFEND} + cdecl; external av__format; +function url_fclose(s: PByteIOContext): integer; + cdecl; external av__format; +function url_fileno(s: PByteIOContext): PURLContext; + cdecl; external av__format; + +(** + * Return the maximum packet size associated to packetized buffered file + * handle. If the file is not packetized (stream like http or file on + * disk), then 0 is returned. + * + * @param s buffered file handle + * @return maximum packet size in bytes + *) +function url_fget_max_packet_size (s: PByteIOContext): integer; + cdecl; external av__format; + +{$IF LIBAVFORMAT_VERSION >= 52000000} // 52.0.0 +function url_open_buf(var s: PByteIOContext; buf: pchar; buf_size: integer; flags: integer): integer; +{$ELSE} +function url_open_buf(s: PByteIOContext; buf: pchar; buf_size: integer; flags: integer): integer; +{$IFEND} + cdecl; external av__format; + +(** return the written or read size *) +function url_close_buf(s: PByteIOContext): integer; + cdecl; external av__format; + +(** + * Open a write only memory stream. + * + * @param s new IO context + * @return zero if no error. + *) +{$IF LIBAVFORMAT_VERSION >= 52000000} // 52.0.0 +function url_open_dyn_buf(var s: PByteIOContext): integer; +{$ELSE} +function url_open_dyn_buf(s: PByteIOContext): integer; +{$IFEND} + cdecl; external av__format; + +(** + * Open a write only packetized memory stream with a maximum packet + * size of 'max_packet_size'. The stream is stored in a memory buffer + * with a big endian 4 byte header giving the packet size in bytes. + * + * @param s new IO context + * @param max_packet_size maximum packet size (must be > 0) + * @return zero if no error. + *) +{$IF LIBAVFORMAT_VERSION >= 52000000} // 52.0.0 +function url_open_dyn_packet_buf(var s: PByteIOContext; max_packet_size: integer): integer; +{$ELSE} +function url_open_dyn_packet_buf(s: PByteIOContext; max_packet_size: integer): integer; +{$IFEND} + cdecl; external av__format; + +(** + * Return the written size and a pointer to the buffer. The buffer + * must be freed with av_free(). + * @param s IO context + * @param pbuffer pointer to a byte buffer + * @return the length of the byte buffer + *) +function url_close_dyn_buf(s: PByteIOContext; pbuffer:PPointer): integer; + cdecl; external av__format; + +{$IF LIBAVFORMAT_VERSION >= 51017001} // 51.17.1 +function ff_crc04C11DB7_update(checksum: longword; {const} buf: PChar; len: cardinal): longword; + cdecl; external av__format; +{$IFEND} +function get_checksum(s: PByteIOContext): cardinal; + cdecl; external av__format; +procedure init_checksum (s: PByteIOContext; update_checksum: pointer; checksum: cardinal); + cdecl; external av__format; + +(* udp.c *) +function udp_set_remote_url(h: PURLContext; {const} uri: pchar): integer; + cdecl; external av__format; +function udp_get_local_port(h: PURLContext): integer; + cdecl; external av__format; +function udp_get_file_handle(h: PURLContext): integer; + cdecl; external av__format; + +implementation + +function url_is_streamed(s: PByteIOContext): integer; +begin + Result := s^.is_streamed; +end; + +end. diff --git a/Game/Code/lib/ffmpeg/avutil.pas b/Game/Code/lib/ffmpeg/avutil.pas new file mode 100644 index 00000000..906d9041 --- /dev/null +++ b/Game/Code/lib/ffmpeg/avutil.pas @@ -0,0 +1,225 @@ +(* + * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(* This is a part of Pascal porting of ffmpeg. + * Originally by Victor Zinetz for Delphi and Free Pascal on Windows. + * For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT + * in the source codes *) + +(* + * avutil.h: + * Min. version: ? + * Max. version: 49.6.0, Revision: 11654, Mon Jan 28 17:23:57 2008 UTC + * + * mem.h: + * Revision: 11641, Sun Jan 27 20:50:16 2008 UTC + *) + +unit avutil; + +{$IFDEF FPC} + {$MODE DELPHI} + {$PACKENUM 4} (* use 4-byte enums *) + {$PACKRECORDS C} (* C/C++-compatible record packing *) +{$ELSE} + {$MINENUMSIZE 4} (* use 4-byte enums *) +{$ENDIF} + +interface + +uses + mathematics, + rational, + UConfig; + +const + (* Max. supported version by this header *) + LIBAVUTIL_MAX_VERSION_MAJOR = 49; + LIBAVUTIL_MAX_VERSION_MINOR = 6; + LIBAVUTIL_MAX_VERSION_RELEASE = 0; + LIBAVUTIL_MAX_VERSION = (LIBAVUTIL_MAX_VERSION_MAJOR * VERSION_MAJOR) + + (LIBAVUTIL_MAX_VERSION_MINOR * VERSION_MINOR) + + (LIBAVUTIL_MAX_VERSION_RELEASE * VERSION_RELEASE); + +(* Check if linked versions are supported *) +{$IF (LIBAVUTIL_VERSION > LIBAVUTIL_MAX_VERSION)} + {$MESSAGE Warn 'Linked version of libavutil may be unsupported!'} +{$IFEND} + +type +(** + * Pixel format. Notes: + * + * PIX_FMT_RGB32 is handled in an endian-specific manner. A RGBA + * color is put together as: + * (A << 24) | (R << 16) | (G << 8) | B + * This is stored as BGRA on little endian CPU architectures and ARGB on + * big endian CPUs. + * + * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized + * image data is stored in AVFrame.data[0]. The palette is transported in + * AVFrame.data[1] and, is 1024 bytes long (256 4-byte entries) and is + * formatted the same as in PIX_FMT_RGB32 described above (i.e., it is + * also endian-specific). Note also that the individual RGB palette + * components stored in AVFrame.data[1] should be in the range 0..255. + * This is important as many custom PAL8 video codecs that were designed + * to run on the IBM VGA graphics adapter use 6-bit palette components. + *) + + PAVPixelFormat = ^TAVPixelFormat; + TAVPixelFormat = ( + PIX_FMT_NONE= -1, + PIX_FMT_YUV420P, ///< Planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) + PIX_FMT_YUYV422, ///< Packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr + PIX_FMT_RGB24, ///< Packed RGB 8:8:8, 24bpp, RGBRGB... + PIX_FMT_BGR24, ///< Packed RGB 8:8:8, 24bpp, BGRBGR... + PIX_FMT_YUV422P, ///< Planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) + PIX_FMT_YUV444P, ///< Planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) + PIX_FMT_RGB32, ///< Packed RGB 8:8:8, 32bpp, (msb)8A 8R 8G 8B(lsb), in cpu endianness + PIX_FMT_YUV410P, ///< Planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) + PIX_FMT_YUV411P, ///< Planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) + PIX_FMT_RGB565, ///< Packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), in cpu endianness + PIX_FMT_RGB555, ///< Packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), in cpu endianness most significant bit to 1 + PIX_FMT_GRAY8, ///< Y , 8bpp + PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black + PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white + PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette + PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0, 12bpp, full scale (jpeg) + PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2, 16bpp, full scale (jpeg) + PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4, 24bpp, full scale (jpeg) + PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h) + PIX_FMT_XVMC_MPEG2_IDCT, + PIX_FMT_UYVY422, ///< Packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 + PIX_FMT_UYYVYY411, ///< Packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 + PIX_FMT_BGR32, ///< Packed RGB 8:8:8, 32bpp, (msb)8A 8B 8G 8R(lsb), in cpu endianness + PIX_FMT_BGR565, ///< Packed RGB 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), in cpu endianness + PIX_FMT_BGR555, ///< Packed RGB 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), in cpu endianness most significant bit to 1 + PIX_FMT_BGR8, ///< Packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) + PIX_FMT_BGR4, ///< Packed RGB 1:2:1, 4bpp, (msb)1B 2G 1R(lsb) + PIX_FMT_BGR4_BYTE, ///< Packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) + PIX_FMT_RGB8, ///< Packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb) + PIX_FMT_RGB4, ///< Packed RGB 1:2:1, 4bpp, (msb)2R 3G 3B(lsb) + PIX_FMT_RGB4_BYTE, ///< Packed RGB 1:2:1, 8bpp, (msb)2R 3G 3B(lsb) + PIX_FMT_NV12, ///< Planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 for UV + PIX_FMT_NV21, ///< as above, but U and V bytes are swapped + + PIX_FMT_RGB32_1, ///< Packed RGB 8:8:8, 32bpp, (msb)8R 8G 8B 8A(lsb), in cpu endianness + PIX_FMT_BGR32_1, ///< Packed RGB 8:8:8, 32bpp, (msb)8B 8G 8R 8A(lsb), in cpu endianness + + PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian + PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian + PIX_FMT_YUV440P, ///< Planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) + PIX_FMT_YUVJ440P, ///< Planar YUV 4:4:0 full scale (jpeg) + PIX_FMT_YUVA420P, ///< Planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples) + PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions + ); + +const +{$ifdef WORDS_BIGENDIAN} + PIX_FMT_RGBA = PIX_FMT_RGB32_1; + PIX_FMT_BGRA = PIX_FMT_BGR32_1; + PIX_FMT_ARGB = PIX_FMT_RGB32; + PIX_FMT_ABGR = PIX_FMT_BGR32; + PIX_FMT_GRAY16 = PIX_FMT_GRAY16BE; +{$else} + PIX_FMT_RGBA = PIX_FMT_BGR32; + PIX_FMT_BGRA = PIX_FMT_RGB32; + PIX_FMT_ARGB = PIX_FMT_BGR32_1; + PIX_FMT_ABGR = PIX_FMT_RGB32_1; + PIX_FMT_GRAY16 = PIX_FMT_GRAY16LE; +{$endif} + +{$IF LIBAVUTIL_VERSION_MAJOR < 50} // 50.0.0 + PIX_FMT_UYVY411 = PIX_FMT_UYYVYY411; + PIX_FMT_RGBA32 = PIX_FMT_RGB32; + PIX_FMT_YUV422 = PIX_FMT_YUYV422; +{$IFEND} + +(* mem.h *) + +(** + * Allocate a block of \p size bytes with alignment suitable for all + * memory accesses (including vectors if available on the CPU). + * @param size Size in bytes for the memory block to be allocated. + * @return Pointer to the allocated block, NULL if it cannot allocate + * it. + * @see av_mallocz() + *) +function av_malloc (size: cardinal): pointer; + cdecl; external av__util; + +(** + * Allocate or reallocate a block of memory. + * If \p ptr is NULL and \p size > 0, allocate a new block. If \p + * size is zero, free the memory block pointed by \p ptr. + * @param size Size in bytes for the memory block to be allocated or + * reallocated. + * @param ptr Pointer to a memory block already allocated with + * av_malloc(z)() or av_realloc() or NULL. + * @return Pointer to a newly reallocated block or NULL if it cannot + * reallocate or the function is used to free the memory block. + * @see av_fast_realloc() + *) +function av_realloc (ptr: pointer; size: cardinal): pointer; + cdecl; external av__util; + +(** + * Free a memory block which has been allocated with av_malloc(z)() or + * av_realloc(). + * @param ptr Pointer to the memory block which should be freed. + * @note ptr = NULL is explicitly allowed. + * @note It is recommended that you use av_freep() instead. + * @see av_freep() + *) +procedure av_free (ptr: pointer); + cdecl; external av__util; + +(** + * Allocate a block of \p size bytes with alignment suitable for all + * memory accesses (including vectors if available on the CPU) and + * set to zeroes all the bytes of the block. + * @param size Size in bytes for the memory block to be allocated. + * @return Pointer to the allocated block, NULL if it cannot allocate + * it. + * @see av_malloc() + *) +function av_mallocz (size: cardinal): pointer; + cdecl; external av__util; + +(** + * Duplicate the string \p s. + * @param s String to be duplicated. + * @return Pointer to a newly allocated string containing a + * copy of \p s or NULL if it cannot be allocated. + *) +function av_strdup({const} s: pchar): pchar; + cdecl; external av__util; + +(** + * Free a memory block which has been allocated with av_malloc(z)() or + * av_realloc() and set to NULL the pointer to it. + * @param ptr Pointer to the pointer to the memory block which should + * be freed. + * @see av_free() + *) +procedure av_freep (ptr: pointer); + cdecl; external av__util; + +implementation + +end. diff --git a/Game/Code/lib/ffmpeg/mathematics.pas b/Game/Code/lib/ffmpeg/mathematics.pas new file mode 100644 index 00000000..ae390e9d --- /dev/null +++ b/Game/Code/lib/ffmpeg/mathematics.pas @@ -0,0 +1,75 @@ +(* + * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(* This is a part of Pascal porting of ffmpeg. Originally by Victor Zinetz for Delphi and Free Pascal on Windows. +For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT +in the source codes *) + +(* + * Revision: 10765, Wed Oct 17 09:37:46 2007 UTC + *) + +unit mathematics; + +{$IFDEF FPC} + {$MODE DELPHI } + {$PACKENUM 4} (* use 4-byte enums *) + {$PACKRECORDS C} (* C/C++-compatible record packing *) +{$ELSE} + {$MINENUMSIZE 4} (* use 4-byte enums *) +{$ENDIF} + +interface + +uses + rational, + UConfig; + +type + TAVRounding = ( + AV_ROUND_ZERO = 0, ///< round toward zero + AV_ROUND_INF = 1, ///< round away from zero + AV_ROUND_DOWN = 2, ///< round toward -infinity + AV_ROUND_UP = 3, ///< round toward +infinity + AV_ROUND_NEAR_INF = 5 ///< round to nearest and halfway cases away from zero + ); + +(** + * rescale a 64bit integer with rounding to nearest. + * a simple a*b/c isn't possible as it can overflow + *) +function av_rescale (a, b, c: int64): int64; + cdecl; external av__util; + +(** + * rescale a 64bit integer with specified rounding. + * a simple a*b/c isn't possible as it can overflow + *) +function av_rescale_rnd (a, b, c: int64; enum: TAVRounding): int64; + cdecl; external av__util; + +(** + * rescale a 64bit integer by 2 rational numbers. + *) +function av_rescale_q (a: int64; bq, cq: TAVRational): int64; + cdecl; external av__util; + +implementation + +end. + diff --git a/Game/Code/lib/ffmpeg/opt.pas b/Game/Code/lib/ffmpeg/opt.pas new file mode 100644 index 00000000..6bde3e65 --- /dev/null +++ b/Game/Code/lib/ffmpeg/opt.pas @@ -0,0 +1,136 @@ +(* + * AVOptions + * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(* This is a part of Pascal porting of ffmpeg. + * Originally by Victor Zinetz for Delphi and Free Pascal on Windows. + * For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT + * in the source codes *) + +(* + * Revision: 11250, Mon Dec 17 17:41:24 2007 UTC + *) + +unit opt; + +{$IFDEF FPC} + {$MODE DELPHI} + {$PACKENUM 4} (* use 4-byte enums *) + {$PACKRECORDS C} (* C/C++-compatible record packing *) +{$ELSE} + {$MINENUMSIZE 4} (* use 4-byte enums *) +{$ENDIF} + +interface + +uses + rational, + UConfig; + +type + TAVOptionType = ( + FF_OPT_TYPE_FLAGS, + FF_OPT_TYPE_INT, + FF_OPT_TYPE_INT64, + FF_OPT_TYPE_DOUBLE, + FF_OPT_TYPE_FLOAT, + FF_OPT_TYPE_STRING, + FF_OPT_TYPE_RATIONAL, + FF_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length + FF_OPT_TYPE_CONST = 128 + ); + +const + AV_OPT_FLAG_ENCODING_PARAM = 1; ///< a generic parameter which can be set by the user for muxing or encoding + AV_OPT_FLAG_DECODING_PARAM = 2; ///< a generic parameter which can be set by the user for demuxing or decoding + AV_OPT_FLAG_METADATA = 4; ///< some data extracted or inserted into the file like title, comment, ... + AV_OPT_FLAG_AUDIO_PARAM = 8; + AV_OPT_FLAG_VIDEO_PARAM = 16; + AV_OPT_FLAG_SUBTITLE_PARAM = 32; + +type + (** + * AVOption. + *) + PAVOption = ^TAVOption; + TAVOption = record + name: pchar; + + (** + * short English text help. + * @todo what about other languages + *) + help: pchar; + offset: integer; ///< offset to context structure where the parsed value should be stored + type_: TAVOptionType; + + default_val: double; + min: double; + max: double; + + flags: integer; +//FIXME think about enc-audio, ... style flags + unit_: pchar; + end; + +{$IF LIBAVCODEC_VERSION >= 51039000} // 51.39.0 +function av_find_opt (obj: Pointer; {const} name: PChar; {const} unit_: PChar; mask: integer; flags: integer): {const} PAVOption; + cdecl; external av__codec; +{$IFEND} + +function av_set_string (obj: pointer; name: pchar; val: pchar): PAVOption; + cdecl; external av__codec; + +function av_set_double (obj: pointer; name: pchar; n: double): PAVOption; + cdecl; external av__codec; + +function av_set_q (obj: pointer; name: pchar; n: TAVRational): PAVOption; + cdecl; external av__codec; + +function av_set_int (obj: pointer; name: pchar; n: int64): PAVOption; + cdecl; external av__codec; + +function av_get_double (obj: pointer; name: pchar; o_out: PPointer): double; + cdecl; external av__codec; + +function av_get_q (obj: pointer; name: pchar; o_out: PPointer): TAVRational; + cdecl; external av__codec; + +function av_get_int (obj: pointer; name: pchar; o_out: PPointer): int64; + cdecl; external av__codec; + +function av_get_string (obj: pointer; name: pchar; o_out: PPOinter; buf: pchar; buf_len: integer): pchar; + cdecl; external av__codec; + +function av_next_option (obj: pointer; last: PAVOption): PAVOption; + cdecl; external av__codec; + +function av_opt_show (obj: pointer; av_log_obj: pointer): integer; + cdecl; external av__codec; + +procedure av_opt_set_defaults (s: pointer); + cdecl; external av__codec; + +{$IF LIBAVCODEC_VERSION >= 51039000} // 51.39.0 +procedure av_opt_set_defaults2 (s: Pointer; mask: integer; flags: integer); + cdecl; external av__codec; +{$IFEND} + +implementation + +end. diff --git a/Game/Code/lib/ffmpeg/rational.pas b/Game/Code/lib/ffmpeg/rational.pas new file mode 100644 index 00000000..0d6f76b6 --- /dev/null +++ b/Game/Code/lib/ffmpeg/rational.pas @@ -0,0 +1,146 @@ +(* + * Rational numbers + * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(* This is a part of Pascal porting of ffmpeg. + * Originally by Victor Zinetz for Delphi and Free Pascal on Windows. + * For Mac OS X, some modifications were made by The Creative CAT, denoted as CAT + * in the source codes *) + +(* + * Revision: 10765, Wed Oct 17 09:37:46 2007 UTC + *) + +unit rational; + +{$IFDEF FPC} + {$MODE DELPHI} + {$PACKENUM 4} (* use 4-byte enums *) + {$PACKRECORDS C} (* C/C++-compatible record packing *) +{$ELSE} + {$MINENUMSIZE 4} (* use 4-byte enums *) +{$ENDIF} + +interface + +uses + UConfig; + +type +(* + * Rational number num/den. + *) + PAVRational = ^TAVRational; + TAVRational = record + num: integer; ///< numerator + den: integer; ///< denominator + end; + +(** + * Compare two rationals. + * @param a first rational + * @param b second rational + * @return 0 if a==b, 1 if a>b and -1 if a<b. + *) +function av_cmp_q(a: TAVRational; b: TAVRational): integer; inline; + +(** + * Rational to double conversion. + * @param a rational to convert + * @return (double) a + *) +function av_q2d(a: TAVRational): double; inline; + +(** + * Reduce a fraction. + * This is useful for framerate calculations. + * @param dst_nom destination numerator + * @param dst_den destination denominator + * @param nom source numerator + * @param den source denominator + * @param max the maximum allowed for dst_nom & dst_den + * @return 1 if exact, 0 otherwise + *) +function av_reduce(dst_nom: PInteger; dst_den: PInteger; nom: int64; den: int64; max: int64): integer; + cdecl; external av__util; + +(** + * Multiplies two rationals. + * @param b first rational. + * @param c second rational. + * @return b*c. + *) +function av_mul_q(b: TAVRational; c: TAVRational): TAVRational; + cdecl; external av__util; + +(** + * Divides one rational by another. + * @param b first rational. + * @param c second rational. + * @return b/c. + *) +function av_div_q(b: TAVRational; c: TAVRational): TAVRational; + cdecl; external av__util; + +(** + * Adds two rationals. + * @param b first rational. + * @param c second rational. + * @return b+c. + *) +function av_add_q(b: TAVRational; c: TAVRational): TAVRational; + cdecl; external av__util; + +(** + * Subtracts one rational from another. + * @param b first rational. + * @param c second rational. + * @return b-c. + *) +function av_sub_q(b: TAVRational; c: TAVRational): TAVRational; + cdecl; external av__util; + +(** + * Converts a double precision floating point number to a rational. + * @param d double to convert + * @param max the maximum allowed numerator and denominator + * @return (AVRational) d. + *) +function av_d2q(d: double; max: integer): TAVRational; + cdecl; external av__util; + +implementation + +function av_cmp_q (a: TAVRational; b: TAVRational): integer; +var + tmp: int64; +begin + tmp := a.num * int64(b.den) - b.num * int64(a.den); + + if (tmp <> 0) then + Result := (tmp shr 63) or 1 + else + Result := 0 +end; + +function av_q2d(a: TAVRational): double; +begin + Result := a.num / a.den; +end; + +end. diff --git a/Game/Code/lib/ffmpeg/src/MacOSX/MacOSXReadMe.txt b/Game/Code/lib/ffmpeg/src/MacOSX/MacOSXReadMe.txt new file mode 100644 index 00000000..59e54e04 --- /dev/null +++ b/Game/Code/lib/ffmpeg/src/MacOSX/MacOSXReadMe.txt @@ -0,0 +1,23 @@ + +How to download an build ffmpeg for UltraStar Deluxe on Mac OS X: + +1. Open a terminal. + +2. cd into the Game/Code/lib/ffmpeg/src/MacOSX directory + +3. Run the following command: + +svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg + +4. The compile ffmpeg. I made a script for this: + +./build_ffmpeg.sh + +5. On OS X you have to patch the the dylibs. Run the following + script. It patches the dylibs and copies them to the + lib/ffmpeg dir: + +./copy_and_patch_dylibs.sh + + +You're done. diff --git a/Game/Code/lib/ffmpeg/src/MacOSX/build_ffmpeg.sh b/Game/Code/lib/ffmpeg/src/MacOSX/build_ffmpeg.sh new file mode 100755 index 00000000..bcb3ca1e --- /dev/null +++ b/Game/Code/lib/ffmpeg/src/MacOSX/build_ffmpeg.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +cd ffmpeg +./configure --enable-shared --disable-static --disable-mmx +make + diff --git a/Game/Code/lib/ffmpeg/src/MacOSX/copy_and_patch_dylibs.sh b/Game/Code/lib/ffmpeg/src/MacOSX/copy_and_patch_dylibs.sh new file mode 100755 index 00000000..064d2ecc --- /dev/null +++ b/Game/Code/lib/ffmpeg/src/MacOSX/copy_and_patch_dylibs.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Copy dylibs: +cp ffmpeg/libavcodec/libavcodec.51.dylib ../../libavcodec.dylib +cp ffmpeg/libavformat/libavformat.52.dylib ../../libavformat.dylib +cp ffmpeg/libavutil/libavutil.49.dylib ../../libavutil.dylib + +# Patching libavcodec: +install_name_tool -id @executable_path/libavcodec.dylib ../../libavcodec.dylib +install_name_tool -change /usr/local/lib/libavutil.dylib @executable_path/libavutil.dylib ../../libavcodec.dylib + +# Patching libavformat: +install_name_tool -id @executable_path/libavformat.dylib ../../libavformat.dylib +install_name_tool -change /usr/local/lib/libavutil.dylib @executable_path/libavutil.dylib ../../libavformat.dylib +install_name_tool -change /usr/local/lib/libavcodec.dylib @executable_path/libavcodec.dylib ../../libavformat.dylib + +# Patching libavcodec: +install_name_tool -id @executable_path/libavutil.dylib ../../libavutil.dylib + +# Printing result: +otool -L ../../libavutil.dylib +otool -L ../../libavcodec.dylib +otool -L ../../libavformat.dylib
\ No newline at end of file diff --git a/Game/Code/lib/ffmpeg/swscale.pas b/Game/Code/lib/ffmpeg/swscale.pas new file mode 100644 index 00000000..15b2c38f --- /dev/null +++ b/Game/Code/lib/ffmpeg/swscale.pas @@ -0,0 +1,214 @@ +(* + * Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) +(* + * @file swscale.h + * @brief + * external api for the swscale stuff + *) + +(* + * Revision: 24800, Thu Oct 18 09:30:33 2007 UTC + *) + +unit swscale; + +{$IFDEF FPC} + {$MODE DELPHI } + {$PACKENUM 4} (* use 4-byte enums *) + {$PACKRECORDS C} (* C/C++-compatible record packing *) +{$ELSE} + {$MINENUMSIZE 4} (* use 4-byte enums *) +{$ENDIF} + +interface + +uses + avutil, + UConfig; + +const + (* Max. supported version by this header *) + LIBSWSCALE_MAX_VERSION_MAJOR = 0; + LIBSWSCALE_MAX_VERSION_MINOR = 5; + LIBSWSCALE_MAX_VERSION_RELEASE = 0; + LIBSWSCALE_MAX_VERSION = (LIBSWSCALE_MAX_VERSION_MAJOR * VERSION_MAJOR) + + (LIBSWSCALE_MAX_VERSION_MINOR * VERSION_MINOR) + + (LIBSWSCALE_MAX_VERSION_RELEASE * VERSION_RELEASE); + +(* Check if linked versions are supported *) +{$IF (LIBSWSCALE_VERSION > LIBSWSCALE_MAX_VERSION)} + {$MESSAGE Warn 'Linked version of libswscale may be unsupported!'} +{$IFEND} + +type + TQuadIntArray = array[0..3] of integer; + PQuadIntArray = ^TQuadIntArray; + TIntArray = array[0..0] of integer; + PIntArray = ^TIntArray; + TPByteArray = array[0..0] of Pbyte; + PPByteArray = ^TPByteArray; + +const + LIBSWSCALE_VERSION_INT = ((0 shl 16)+(5 shl 8))+0; + LIBSWSCALE_VERSION = '0.5.0'; + LIBSWSCALE_BUILD = LIBSWSCALE_VERSION_INT; + + LIBSWSCALE_IDENT = 'SwS'+LIBSWSCALE_VERSION; + + {* values for the flags, the stuff on the command line is different *} + SWS_FAST_BILINEAR = 1; + SWS_BILINEAR = 2; + SWS_BICUBIC = 4; + SWS_X = 8; + SWS_POINT = $10; + SWS_AREA = $20; + SWS_BICUBLIN = $40; + SWS_GAUSS = $80; + SWS_SINC = $100; + SWS_LANCZOS = $200; + SWS_SPLINE = $400; + + SWS_SRC_V_CHR_DROP_MASK = $30000; + SWS_SRC_V_CHR_DROP_SHIFT = 16; + + SWS_PARAM_DEFAULT = 123456; + + SWS_PRINT_INFO = $1000; + + //the following 3 flags are not completely implemented + //internal chrominace subsampling info + SWS_FULL_CHR_H_INT = $2000; + //input subsampling info + SWS_FULL_CHR_H_INP = $4000; + SWS_DIRECT_BGR = $8000; + SWS_ACCURATE_RND = $40000; + + SWS_CPU_CAPS_MMX = $80000000; + SWS_CPU_CAPS_MMX2 = $20000000; + SWS_CPU_CAPS_3DNOW = $40000000; + SWS_CPU_CAPS_ALTIVEC = $10000000; + SWS_CPU_CAPS_BFIN = $01000000; + + SWS_MAX_REDUCE_CUTOFF = 0.002; + + SWS_CS_ITU709 = 1; + SWS_CS_FCC = 4; + SWS_CS_ITU601 = 5; + SWS_CS_ITU624 = 5; + SWS_CS_SMPTE170M = 5; + SWS_CS_SMPTE240M = 7; + SWS_CS_DEFAULT = 5; + + +type + + // when used for filters they must have an odd number of elements + // coeffs cannot be shared between vectors + PSwsVector = ^TSwsVector; + TSwsVector = record + coeff: Pdouble; + length: integer; + end; + + // vectors can be shared + PSwsFilter = ^TSwsFilter; + TSwsFilter = record + lumH: PSwsVector; + lumV: PSwsVector; + chrH: PSwsVector; + chrV: PSwsVector; + end; + + PSwsContext = ^TSwsContext; + TSwsContext = record + av_class: Pointer; + swScale: Pointer; + srxW,srcH, dstH: integer; + chrSrcW, chrSrcH, chrDstW, chrDstH: integer; + lumXInc, chrXInc, lumYInc, chrYInc: integer; + dstFormat, srcFormat, origDstFormat, origSrcFormat: integer; + chrSrcHSubSample, chrSrcVSubSample, chrIntHSubSample, chrIntVSubSample: integer; + chrDstHSubSample, chrDstVSubSample: integer; + vChrDrop, sliceDir: integer; + param: array[0..1] of double; + {internal structure} + end; + + +procedure sws_freeContext(swsContext: PSwsContext); + cdecl; external sw__scale; + +function sws_getContext(srcW: integer; srcH: integer; srcFormat: integer; dstW: integer; dstH: integer;dstFormat: integer; flags: integer; + srcFilter: PSwsFilter; dstFilter: PSwsFilter; param: Pdouble): PSwsContext; + cdecl; external sw__scale; +function sws_scale(context: PSwsContext; src: PPByteArray; srcStride: PIntArray; srcSliceY: integer; srcSliceH: integer; + dst: PPByteArray; dstStride: PIntArray): integer; + cdecl; external sw__scale; +function sws_scale_ordered(context: PSwsContext; src: PPByteArray; srcStride: PIntArray; srcSliceY: integer; + srcSliceH: integer; dst: PPByteArray; dstStride: PIntArray): integer; + cdecl; external sw__scale; deprecated; + +function sws_setColorspaceDetails(c: PSwsContext; inv_table: PQuadIntArray; srcRange: integer; table: PQuadIntArray; dstRange: integer; + brightness: integer; contrast: integer; saturation: integer): integer; + cdecl; external sw__scale; +function sws_getColorspaceDetails(c: PSwsContext; var inv_table: PQuadIntArray; var srcRange: integer; var table: PQuadIntArray; var dstRange: integer; + var brightness: integer; var contrast: integer; var saturation: integer): integer; + cdecl; external sw__scale; +function sws_getGaussianVec(variance: double; quality: double): PSwsVector; + cdecl; external sw__scale; +function sws_getConstVec(c: double; length: integer): PSwsVector; + cdecl; external sw__scale; +function sws_getIdentityVec: PSwsVector; + cdecl; external sw__scale; +procedure sws_scaleVec(a: PSwsVector; scalar: double); + cdecl; external sw__scale; +procedure sws_normalizeVec(a: PSwsVector; height: double); + cdecl; external sw__scale; +procedure sws_convVec(a: PSwsVector; b: PSwsVector); + cdecl; external sw__scale; +procedure sws_addVec(a: PSwsVector; b: PSwsVector); + cdecl; external sw__scale; +procedure sws_subVec(a: PSwsVector; b: PSwsVector); + cdecl; external sw__scale; +procedure sws_shiftVec(a: PSwsVector; shift: integer); + cdecl; external sw__scale; +function sws_cloneVec(a: PSwsVector): PSwsVector; + cdecl; external sw__scale; + +procedure sws_printVec(a: PSwsVector); + cdecl; external sw__scale; +procedure sws_freeVec(a: PSwsVector); + cdecl; external sw__scale; + +function sws_getDefaultFilter(lumaGBlur: single; chromaGBlur: single; lumaSarpen: single; chromaSharpen: single; chromaHShift: single; + chromaVShift: single; verbose: integer): PSwsFilter; + cdecl; external sw__scale; +procedure sws_freeFilter(filter: PSwsFilter); + cdecl; external sw__scale; + +function sws_getCachedContext(context: PSwsContext; + srcW: integer; srcH: integer; srcFormat: integer; + dstW: integer; dstH: integer; dstFormat: integer; flags: integer; + srcFilter: PSwsFilter; dstFilter: PSwsFilter; param: Pdouble): PSwsContext; + cdecl; external sw__scale; + +implementation + +end. diff --git a/Game/Code/lib/midi/CIRCBUF.PAS b/Game/Code/lib/midi/CIRCBUF.PAS new file mode 100644 index 00000000..e84fc2c4 --- /dev/null +++ b/Game/Code/lib/midi/CIRCBUF.PAS @@ -0,0 +1,192 @@ +{ $Header: /MidiComp/CIRCBUF.PAS 2 10/06/97 7:33 Davec $ }
+
+{ Written by David Churcher <dchurcher@cix.compulink.co.uk>,
+ released to the public domain. }
+
+
+{ A First-In First-Out circular buffer.
+ Port of circbuf.c from Microsoft's Windows MIDI monitor example.
+ I did do a version of this as an object (see Rev 1.1) but it was getting too
+ complicated and I couldn't see any real benefits to it so I dumped it
+ for an ordinary memory buffer with pointers.
+
+ This unit is a bit C-like, everything is done with pointers and extensive
+ use is made of the undocumented feature of the Inc() function that
+ increments pointers by the size of the object pointed to.
+ All of this could probably be done using Pascal array notation with
+ range-checking turned off, but I'm not sure it's worth it.
+}
+
+Unit Circbuf;
+
+interface
+
+Uses Wintypes, WinProcs, MMSystem;
+
+type
+ {$IFNDEF WIN32}
+ { API types not defined in Delphi 1 }
+ DWORD = Longint;
+ HGLOBAL = THandle;
+ UINT = Word;
+ TFNTimeCallBack = procedure(uTimerID, uMessage: UINT; dwUser, dw1, dw2: DWORD);
+ {$ENDIF}
+
+ { MIDI input event }
+ TMidiBufferItem = record
+ timestamp: DWORD; { Timestamp in milliseconds after midiInStart }
+ data: DWORD; { MIDI message received }
+ sysex: PMidiHdr; { Pointer to sysex MIDIHDR, nil if not sysex }
+ end;
+ PMidiBufferItem = ^TMidiBufferItem;
+
+ { MIDI input buffer }
+ TCircularBuffer = record
+ RecordHandle: HGLOBAL; { Windows memory handle for this record }
+ BufferHandle: HGLOBAL; { Windows memory handle for the buffer }
+ pStart: PMidiBufferItem; { ptr to start of buffer }
+ pEnd: PMidiBufferItem; { ptr to end of buffer }
+ pNextPut: PMidiBufferItem; { next location to fill }
+ pNextGet: PMidiBufferItem; { next location to empty }
+ Error: Word; { error code from MMSYSTEM functions }
+ Capacity: Word; { buffer size (in TMidiBufferItems) }
+ EventCount: Word; { Number of events in buffer }
+ end;
+
+ PCircularBuffer = ^TCircularBuffer;
+
+function GlobalSharedLockedAlloc( Capacity: Word; var hMem: HGLOBAL ): Pointer;
+procedure GlobalSharedLockedFree( hMem: HGLOBAL; ptr: Pointer );
+
+function CircbufAlloc( Capacity: Word ): PCircularBuffer;
+procedure CircbufFree( PBuffer: PCircularBuffer );
+function CircbufRemoveEvent( PBuffer: PCircularBuffer ): Boolean;
+function CircbufReadEvent( PBuffer: PCircularBuffer; PEvent: PMidiBufferItem ): Boolean;
+{ Note: The PutEvent function is in the DLL }
+
+implementation
+
+{ Allocates in global shared memory, returns pointer and handle }
+function GlobalSharedLockedAlloc( Capacity: Word; var hMem: HGLOBAL ): Pointer;
+var
+ ptr: Pointer;
+begin
+ { Allocate the buffer memory }
+ hMem := GlobalAlloc(GMEM_SHARE Or GMEM_MOVEABLE Or GMEM_ZEROINIT, Capacity );
+
+ if (hMem = 0) then
+ ptr := Nil
+ else
+ begin
+ ptr := GlobalLock(hMem);
+ if (ptr = Nil) then
+ GlobalFree(hMem);
+ end;
+
+{$IFNDEF WIN32}
+ if (ptr <> Nil) then
+ GlobalPageLock(HIWORD(DWORD(ptr)));
+{$ENDIF}
+ GlobalSharedLockedAlloc := Ptr;
+end;
+
+procedure GlobalSharedLockedFree( hMem: HGLOBAL; ptr: Pointer );
+begin
+{$IFNDEF WIN32}
+ if (ptr <> Nil) then
+ GlobalPageUnlock(HIWORD(DWORD(ptr)));
+{$ENDIF}
+ if (hMem <> 0) then
+ begin
+ GlobalUnlock(hMem);
+ GlobalFree(hMem);
+ end;
+end;
+
+function CircbufAlloc( Capacity: Word ): PCircularBuffer;
+var
+ NewCircularBuffer: PCircularBuffer;
+ NewMIDIBuffer: PMidiBufferItem;
+ hMem: HGLOBAL;
+begin
+ { TODO: Validate circbuf size, <64K }
+ NewCircularBuffer :=
+ GlobalSharedLockedAlloc( Sizeof(TCircularBuffer), hMem );
+ if (NewCircularBuffer <> Nil) then
+ begin
+ NewCircularBuffer^.RecordHandle := hMem;
+ NewMIDIBuffer :=
+ GlobalSharedLockedAlloc( Capacity * Sizeof(TMidiBufferItem), hMem );
+ if (NewMIDIBuffer = Nil) then
+ begin
+ { TODO: Exception here? }
+ GlobalSharedLockedFree( NewCircularBuffer^.RecordHandle,
+ NewCircularBuffer );
+ NewCircularBuffer := Nil;
+ end
+ else
+ begin
+ NewCircularBuffer^.pStart := NewMidiBuffer;
+ { Point to item at end of buffer }
+ NewCircularBuffer^.pEnd := NewMidiBuffer;
+ Inc(NewCircularBuffer^.pEnd, Capacity);
+ { Start off the get and put pointers in the same position. These
+ will get out of sync as the interrupts start rolling in }
+ NewCircularBuffer^.pNextPut := NewMidiBuffer;
+ NewCircularBuffer^.pNextGet := NewMidiBuffer;
+ NewCircularBuffer^.Error := 0;
+ NewCircularBuffer^.Capacity := Capacity;
+ NewCircularBuffer^.EventCount := 0;
+ end;
+ end;
+ CircbufAlloc := NewCircularBuffer;
+end;
+
+procedure CircbufFree( pBuffer: PCircularBuffer );
+begin
+ if (pBuffer <> Nil) then
+ begin
+ GlobalSharedLockedFree(pBuffer^.BufferHandle, pBuffer^.pStart);
+ GlobalSharedLockedFree(pBuffer^.RecordHandle, pBuffer);
+ end;
+end;
+
+{ Reads first event in queue without removing it.
+ Returns true if successful, False if no events in queue }
+function CircbufReadEvent( PBuffer: PCircularBuffer; PEvent: PMidiBufferItem ): Boolean;
+var
+ PCurrentEvent: PMidiBufferItem;
+begin
+ if (PBuffer^.EventCount <= 0) then
+ CircbufReadEvent := False
+ else
+ begin
+ PCurrentEvent := PBuffer^.PNextget;
+
+ { Copy the object from the "tail" of the buffer to the caller's object }
+ PEvent^.Timestamp := PCurrentEvent^.Timestamp;
+ PEvent^.Data := PCurrentEvent^.Data;
+ PEvent^.Sysex := PCurrentEvent^.Sysex;
+ CircbufReadEvent := True;
+ end;
+end;
+
+{ Remove current event from the queue }
+function CircbufRemoveEvent(PBuffer: PCircularBuffer): Boolean;
+begin
+ if (PBuffer^.EventCount > 0) then
+ begin
+ Dec( Pbuffer^.EventCount);
+
+ { Advance the buffer pointer, with wrap }
+ Inc( Pbuffer^.PNextGet );
+ If (PBuffer^.PNextGet = PBuffer^.PEnd) then
+ PBuffer^.PNextGet := PBuffer^.PStart;
+
+ CircbufRemoveEvent := True;
+ end
+ else
+ CircbufRemoveEvent := False;
+end;
+
+end.
diff --git a/Game/Code/lib/midi/DELPHMCB.PAS b/Game/Code/lib/midi/DELPHMCB.PAS new file mode 100644 index 00000000..23ce0e1a --- /dev/null +++ b/Game/Code/lib/midi/DELPHMCB.PAS @@ -0,0 +1,140 @@ +{ $Header: /MidiComp/DELPHMCB.PAS 2 10/06/97 7:33 Davec $ }
+
+{MIDI callback for Delphi, was DLL for Delphi 1}
+
+unit Delphmcb;
+
+{ These segment options required for the MIDI callback functions }
+{$C PRELOAD FIXED PERMANENT}
+
+interface
+
+uses WinProcs, WinTypes, MMsystem, Circbuf, MidiDefs, MidiCons;
+
+{$IFDEF WIN32}
+procedure midiHandler(
+ hMidiIn: HMidiIn;
+ wMsg: UINT;
+ dwInstance: DWORD;
+ dwParam1: DWORD;
+ dwParam2: DWORD); stdcall export;
+function CircbufPutEvent(PBuffer: PCircularBuffer; PTheEvent: PMidiBufferItem): Boolean; stdcall; export;
+{$ELSE}
+procedure midiHandler(
+ hMidiIn: HMidiIn;
+ wMsg: Word;
+ dwInstance: DWORD;
+ dwParam1: DWORD;
+ dwParam2: DWORD); export;
+function CircbufPutEvent(PBuffer: PCircularBuffer; PTheEvent: PMidiBufferItem): Boolean; export;
+{$ENDIF}
+
+implementation
+
+{ Add an event to the circular input buffer. }
+function CircbufPutEvent(PBuffer: PCircularBuffer; PTheEvent: PMidiBufferItem): Boolean;
+begin
+ If (PBuffer^.EventCount < PBuffer^.Capacity) Then
+ begin
+ Inc(Pbuffer^.EventCount);
+
+ { Todo: better way of copying this record }
+ with PBuffer^.PNextput^ do
+ begin
+ Timestamp := PTheEvent^.Timestamp;
+ Data := PTheEvent^.Data;
+ Sysex := PTheEvent^.Sysex;
+ end;
+
+ { Move to next put location, with wrap }
+ Inc(Pbuffer^.PNextPut);
+ If (PBuffer^.PNextPut = PBuffer^.PEnd) then
+ PBuffer^.PNextPut := PBuffer^.PStart;
+
+ CircbufPutEvent := True;
+ end
+ else
+ CircbufPutEvent := False;
+end;
+
+{ This is the callback function specified when the MIDI device was opened
+ by midiInOpen. It's called at interrupt time when MIDI input is seen
+ by the MIDI device driver(s). See the docs for midiInOpen for restrictions
+ on the Windows functions that can be called in this interrupt. }
+procedure midiHandler(
+ hMidiIn: HMidiIn;
+ wMsg: UINT;
+ dwInstance: DWORD;
+ dwParam1: DWORD;
+ dwParam2: DWORD);
+
+var
+ thisEvent: TMidiBufferItem;
+ thisCtlInfo: PMidiCtlInfo;
+ thisBuffer: PCircularBuffer;
+
+Begin
+ case wMsg of
+
+ mim_Open: {nothing};
+
+ mim_Error: {TODO: handle (message to trigger exception?) };
+
+ mim_Data, mim_Longdata, mim_Longerror:
+ { Note: mim_Longerror included because there's a bug in the Maui
+ input driver that sends MIM_LONGERROR for subsequent buffers when
+ the input buffer is smaller than the sysex block being received }
+
+ begin
+ { TODO: Make filtered messages customisable, I'm sure someone wants to
+ do something with MTC! }
+ if (dwParam1 <> MIDI_ACTIVESENSING) and
+ (dwParam1 <> MIDI_TIMINGCLOCK) then
+ begin
+
+ { The device driver passes us the instance data pointer we
+ specified for midiInOpen. Use this to get the buffer address
+ and window handle for the MIDI control }
+ thisCtlInfo := PMidiCtlInfo(dwInstance);
+ thisBuffer := thisCtlInfo^.PBuffer;
+
+ { Screen out short messages if we've been asked to }
+ if ((wMsg <> mim_Data) or (thisCtlInfo^.SysexOnly = False))
+ and (thisCtlInfo <> Nil) and (thisBuffer <> Nil) then
+ begin
+ with thisEvent do
+ begin
+ timestamp := dwParam2;
+ if (wMsg = mim_Longdata) or
+ (wMsg = mim_Longerror) then
+ begin
+ data := 0;
+ sysex := PMidiHdr(dwParam1);
+ end
+ else
+ begin
+ data := dwParam1;
+ sysex := Nil;
+ end;
+ end;
+ if CircbufPutEvent( thisBuffer, @thisEvent ) then
+ { Send a message to the control to say input's arrived }
+ PostMessage(thisCtlInfo^.hWindow, mim_Data, 0, 0)
+ else
+ { Buffer overflow }
+ PostMessage(thisCtlInfo^.hWindow, mim_Overflow, 0, 0);
+ end;
+ end;
+ end;
+
+ mom_Done: { Sysex output complete, dwParam1 is pointer to MIDIHDR }
+ begin
+ { Notify the control that its sysex output is finished.
+ The control should call midiOutUnprepareHeader before freeing the buffer }
+ PostMessage(PMidiCtlInfo(dwInstance)^.hWindow, mom_Done, 0, dwParam1);
+ end;
+
+ end; { Case }
+end;
+
+end.
diff --git a/Game/Code/lib/midi/MIDIDEFS.PAS b/Game/Code/lib/midi/MIDIDEFS.PAS new file mode 100644 index 00000000..4024c547 --- /dev/null +++ b/Game/Code/lib/midi/MIDIDEFS.PAS @@ -0,0 +1,47 @@ +{ $Header: /MidiComp/MIDIDEFS.PAS 2 10/06/97 7:33 Davec $ }
+
+{ Written by David Churcher <dchurcher@cix.compulink.co.uk>,
+ released to the public domain. }
+
+
+{ Common definitions used by DELPHMID.DPR and the MIDI components.
+ This must be a separate unit to prevent large chunks of the VCL being
+ linked into the DLL. }
+unit Mididefs;
+
+interface
+
+uses WinProcs, WinTypes, MMsystem, Circbuf;
+
+type
+
+ {-------------------------------------------------------------------}
+ { This is the information about the control that must be accessed by
+ the MIDI input callback function in the DLL at interrupt time }
+ PMidiCtlInfo = ^TMidiCtlInfo;
+ TMidiCtlInfo = record
+ hMem: THandle; { Memory handle for this record }
+ PBuffer: PCircularBuffer; { Pointer to the MIDI input data buffer }
+ hWindow: HWnd; { Control's window handle }
+ SysexOnly: Boolean; { Only process System Exclusive input }
+ end;
+
+ { Information for the output timer callback function, also required at
+ interrupt time. }
+ PMidiOutTimerInfo = ^TMidiOutTimerInfo;
+ TMidiOutTimerInfo = record
+ hMem: THandle; { Memory handle for this record }
+ PBuffer: PCircularBuffer; { Pointer to MIDI output data buffer }
+ hWindow: HWnd; { Control's window handle }
+ TimeToNextEvent: DWORD; { Delay to next event after timer set }
+ MIDIHandle: HMidiOut; { MIDI handle to send output to
+ (copy of component's FMidiHandle property) }
+ PeriodMin: Word; { Multimedia timer minimum period supported }
+ PeriodMax: Word; { Multimedia timer maximum period supported }
+ TimerId: Word; { Multimedia timer ID of current event }
+ end;
+
+implementation
+
+
+end.
diff --git a/Game/Code/lib/midi/MIDITYPE.PAS b/Game/Code/lib/midi/MIDITYPE.PAS new file mode 100644 index 00000000..0aa9cec3 --- /dev/null +++ b/Game/Code/lib/midi/MIDITYPE.PAS @@ -0,0 +1,79 @@ +{ $Header: /MidiComp/MIDITYPE.PAS 2 10/06/97 7:33 Davec $ }
+
+{ Written by David Churcher <dchurcher@cix.compulink.co.uk>,
+ released to the public domain. }
+
+
+unit Miditype;
+
+interface
+
+uses Classes, Wintypes, Messages, MMSystem, MidiDefs, Circbuf;
+
+type
+ {-------------------------------------------------------------------}
+ { A MIDI input/output event }
+ TMyMidiEvent = class(TPersistent)
+ public
+ MidiMessage: Byte; { MIDI message status byte }
+ Data1: Byte; { MIDI message data 1 byte }
+ Data2: Byte; { MIDI message data 2 byte }
+ Time: DWORD; { Time in ms since midiInOpen }
+ SysexLength: Word; { Length of sysex data (0 if none) }
+ Sysex: PChar; { Pointer to sysex data buffer }
+ destructor Destroy; override; { Frees sysex data buffer if nec. }
+ end;
+ PMyMidiEvent = ^TMyMidiEvent;
+
+ {-------------------------------------------------------------------}
+ { Encapsulates the MIDIHDR with its memory handle and sysex buffer }
+ PMyMidiHdr = ^TMyMidiHdr;
+ TMyMidiHdr = class(TObject)
+ public
+ hdrHandle: THandle;
+ hdrPointer: PMIDIHDR;
+ sysexHandle: THandle;
+ sysexPointer: Pointer;
+ constructor Create(BufferSize: Word);
+ destructor Destroy; override;
+ end;
+
+implementation
+
+{-------------------------------------------------------------------}
+{ Free any sysex buffer associated with the event }
+destructor TMyMidiEvent.Destroy;
+begin
+ if (Sysex <> Nil) then
+ Freemem(Sysex, SysexLength);
+
+ inherited Destroy;
+end;
+
+{-------------------------------------------------------------------}
+{ Allocate memory for the sysex header and buffer }
+constructor TMyMidiHdr.Create(BufferSize:Word);
+begin
+ inherited Create;
+
+ if BufferSize > 0 then
+ begin
+ hdrPointer := GlobalSharedLockedAlloc(sizeof(TMIDIHDR), hdrHandle);
+ sysexPointer := GlobalSharedLockedAlloc(BufferSize, sysexHandle);
+
+ hdrPointer^.lpData := sysexPointer;
+ hdrPointer^.dwBufferLength := BufferSize;
+ end;
+end;
+
+{-------------------------------------------------------------------}
+destructor TMyMidiHdr.Destroy;
+begin
+ GlobalSharedLockedFree( hdrHandle, hdrPointer );
+ GlobalSharedLockedFree( sysexHandle, sysexPointer );
+ inherited Destroy;
+end;
+
+
+
+end.
diff --git a/Game/Code/lib/midi/MidiFile.pas b/Game/Code/lib/midi/MidiFile.pas new file mode 100644 index 00000000..10b64a80 --- /dev/null +++ b/Game/Code/lib/midi/MidiFile.pas @@ -0,0 +1,956 @@ +{
+ Load a midifile and get access to tracks and events
+ I did build this component to convert midifiles to wave files
+ or play the files on a software synthesizer which I'm currenly
+ building.
+
+ version 1.0 first release
+
+ version 1.1
+ added some function
+ function KeyToStr(key : integer) : string;
+ function MyTimeToStr(val : integer) : string;
+ Bpm can be set to change speed
+
+ version 1.2
+ added some functions
+ function GetTrackLength:integer;
+ function Ready: boolean;
+
+ version 1.3
+ update by Chulwoong,
+ He knows how to use the MM timer, the timing is much better now, thank you
+
+ for comments/bugs
+ F.Bouwmans
+ fbouwmans@spiditel.nl
+
+ if you think this component is nice and you use it, sent me a short email.
+ I've seen that other of my components have been downloaded a lot, but I've
+ got no clue wether they are actually used.
+ Don't worry because you are free to use these components
+
+ Timing has improved, however because the messages are handled by the normal
+ windows message loop (of the main window) it is still influenced by actions
+ done on the window (minimize/maximize ..).
+ Use of a second thread with higher priority which only handles the
+ timer message should increase performance. If somebody knows such a component
+ which is freeware please let me know.
+
+ interface description:
+
+ procedure ReadFile:
+ actually read the file which is set in Filename
+
+ function GetTrack(index: integer) : TMidiTrack;
+
+ property Filename
+ set/read filename of midifile
+
+ property NumberOfTracks
+ read number of tracks in current file
+
+ property TicksPerQuarter: integer
+ ticks per quarter, tells how to interpret the time value in midi events
+
+ property FileFormat: TFileFormat
+ tells the format of the current midifile
+
+ property Bpm:integer
+ tells Beats per minut
+
+ property OnMidiEvent:TOnMidiEvent
+ called while playing for each midi event
+
+ procedure StartPlaying;
+ start playing the current loaded midifile from the beginning
+
+ procedure StopPlaying;
+ stop playing the current midifile
+
+ procedure PlayToTime(time : integer);
+ if playing yourself then events from last time to this time are produced
+
+
+ function KeyToStr(key : integer) : string;
+ give note string on key value: e.g. C4
+
+ function MyTimeToStr(val : integer) : string;
+ give time string from msec time
+
+ function GetTrackLength:integer;
+ gives the track lenght in msec (assuming the bpm at the start oof the file)
+
+ function Ready: boolean;
+ now you can check wether the playback is finished
+
+}
+
+unit MidiFile;
+
+interface
+
+uses
+ Windows,
+ Messages,
+ SysUtils,
+ Classes,
+ Graphics,
+ Controls,
+ Forms,
+ stdctrls,
+ ExtCtrls,
+ WinProcs;
+
+type
+ TChunkType = (illegal, header, track);
+ TFileFormat = (single, multi_synch, multi_asynch);
+ PByte = ^byte;
+
+ TMidiEvent = record
+ event: byte;
+ data1: byte;
+ data2: byte;
+ str: string;
+ dticks: integer;
+ time: integer;
+ mtime: integer;
+ len: integer;
+ end;
+ PMidiEvent = ^TMidiEvent;
+
+ TOnMidiEvent = procedure(event: PMidiEvent) of object;
+ TEvent = procedure of object;
+
+ TMidiTrack = class(TObject)
+ protected
+ events: TList;
+ name: string;
+ instrument: string;
+ currentTime: integer;
+ currentPos: integer;
+ ready: boolean;
+ trackLenght: integer;
+ procedure checkReady;
+ public
+ OnMidiEvent: TOnMidiEvent;
+ OnTrackReady: TEvent;
+ constructor Create;
+ destructor Destroy; override;
+
+ procedure Rewind(pos: integer);
+ procedure PlayUntil(pos: integer);
+ procedure GoUntil(pos: integer);
+
+ procedure putEvent(event: PMidiEvent);
+ function getEvent(index: integer): PMidiEvent;
+ function getName: string;
+ function getInstrument: string;
+ function getEventCount: integer;
+ function getCurrentTime: integer;
+ function getTrackLength: integer;
+ function isReady:boolean;
+ end;
+
+ TMidiFile = class(TComponent)
+ private
+ { Private declarations }
+ procedure MidiTimer(sender : TObject);
+ procedure WndProc(var Msg : TMessage);
+ protected
+ { Protected declarations }
+ midiFile: file of byte;
+ chunkType: TChunkType;
+ chunkLength: integer;
+ chunkData: PByte;
+ chunkIndex: PByte;
+ chunkEnd: PByte;
+ FPriority: DWORD;
+
+ // midi file attributes
+ FFileFormat: TFileFormat;
+ numberTracks: integer;
+ deltaTicks: integer;
+ FBpm: integer;
+ FBeatsPerMeasure: integer;
+ FusPerTick: double;
+ FFilename: string;
+
+ Tracks: TList;
+ currentTrack: TMidiTrack;
+ FOnMidiEvent: TOnMidiEvent;
+ FOnUpdateEvent: TNotifyEvent;
+
+ // playing attributes
+ playing: boolean;
+ PlayStartTime: integer;
+ currentTime: integer; // Current playtime in msec
+ currentPos: Double; // Current Position in ticks
+
+ procedure OnTrackReady;
+ procedure setFilename(val: string);
+ procedure ReadChunkHeader;
+ procedure ReadChunkContent;
+ procedure ReadChunk;
+ procedure ProcessHeaderChunk;
+ procedure ProcessTrackChunk;
+ function ReadVarLength: integer;
+ function ReadString(l: integer): string;
+ procedure SetOnMidiEvent(handler: TOnMidiEvent);
+ procedure SetBpm(val: integer);
+ public
+ { Public declarations }
+ constructor Create(AOwner: TComponent); override;
+ destructor Destroy; override;
+
+ procedure ReadFile;
+ function GetTrack(index: integer): TMidiTrack;
+
+ procedure StartPlaying;
+ procedure StopPlaying;
+ procedure ContinuePlaying;
+
+ procedure PlayToTime(time: integer);
+ procedure GoToTime(time: integer);
+ function GetCurrentTime: integer;
+ function GetFusPerTick : Double;
+ function GetTrackLength:integer;
+ function Ready: boolean;
+ published
+ { Published declarations }
+ property Filename: string read FFilename write setFilename;
+ property NumberOfTracks: integer read numberTracks;
+ property TicksPerQuarter: integer read deltaTicks;
+ property FileFormat: TFileFormat read FFileFormat;
+ property Bpm: integer read FBpm write SetBpm;
+ property OnMidiEvent: TOnMidiEvent read FOnMidiEvent write SetOnMidiEvent;
+ property OnUpdateEvent: TNotifyEvent read FOnUpdateEvent write FOnUpdateEvent;
+ end;
+
+function KeyToStr(key: integer): string;
+function MyTimeToStr(val: integer): string;
+procedure Register;
+
+implementation
+
+uses mmsystem;
+
+type TTimerProc=procedure(uTimerID,uMsg: Integer; dwUser,dwParam1,dwParam2:DWORD);stdcall;
+
+const TIMER_RESOLUTION=10;
+const WM_MULTIMEDIA_TIMER=WM_USER+127;
+
+var MIDIFileHandle : HWND;
+ TimerProc : TTimerProc;
+ MIDITimerID : Integer;
+ TimerPeriod : Integer;
+
+procedure TimerCallBackProc(uTimerID,uMsg: Integer; dwUser,dwParam1,dwParam2:DWORD);stdcall;
+begin
+ PostMessage(HWND(dwUser),WM_MULTIMEDIA_TIMER,0,0);
+end;
+
+procedure SetMIDITimer;
+ var TimeCaps : TTimeCaps ;
+begin
+ timeGetDevCaps(@TimeCaps,SizeOf(TimeCaps));
+ if TIMER_RESOLUTION < TimeCaps.wPeriodMin then
+ TimerPeriod:=TimeCaps.wPeriodMin
+ else if TIMER_RESOLUTION > TimeCaps.wPeriodMax then
+ TimerPeriod:=TimeCaps.wPeriodMax
+ else
+ TimerPeriod:=TIMER_RESOLUTION;
+
+ timeBeginPeriod(TimerPeriod);
+ MIDITimerID:=timeSetEvent(TimerPeriod,TimerPeriod,@TimerProc,
+ DWORD(MIDIFileHandle),TIME_PERIODIC);
+ if MIDITimerID=0 then
+ timeEndPeriod(TimerPeriod);
+end;
+
+procedure KillMIDITimer;
+begin
+ timeKillEvent(MIDITimerID);
+ timeEndPeriod(TimerPeriod);
+end;
+
+constructor TMidiTrack.Create;
+begin
+ inherited Create;
+ events := TList.Create;
+ currentTime := 0;
+ currentPos := 0;
+end;
+
+destructor TMidiTrack.Destroy;
+var
+ i: integer;
+begin
+ for i := 0 to events.count - 1 do
+ Dispose(PMidiEvent(events.items[i]));
+ events.Free;
+ inherited Destroy;
+end;
+
+procedure TMidiTRack.putEvent(event: PMidiEvent);
+var
+ command: integer;
+ i: integer;
+ pevent: PMidiEvent;
+begin
+ if (event.event = $FF) then
+ begin
+ if (event.data1 = 3) then
+ name := event.str;
+ if (event.data1 = 4) then
+ instrument := event.str;
+ end;
+ currentTime := currentTime + event.dticks;
+ event.time := currentTime; // for the moment just add dticks
+ event.len := 0;
+ events.add(TObject(event));
+ command := event.event and $F0;
+
+ if ((command = $80) // note off
+ or ((command = $90) and (event.data2 = 0))) //note on with speed 0
+ then
+ begin
+ // this is a note off, try to find the accompanion note on
+ command := event.event or $90;
+ i := events.count - 2;
+ while i >= 0 do
+ begin
+ pevent := PMidiEvent(events[i]);
+ if (pevent.event = command) and
+ (pevent.data1 = event.data1)
+ then
+ begin
+ pevent.len := currentTIme - pevent.time;
+ i := 0;
+ event.len := -1;
+ end;
+ dec(i);
+ end;
+ end;
+end;
+
+function TMidiTrack.getName: string;
+begin
+ result := name;
+end;
+
+function TMidiTrack.getInstrument: string;
+begin
+ result := instrument;
+end;
+
+function TMiditrack.getEventCount: integer;
+begin
+ result := events.count;
+end;
+
+function TMiditrack.getEvent(index: integer): PMidiEvent;
+begin
+ if ((index < events.count) and (index >= 0)) then
+ result := events[index]
+ else
+ result := nil;
+end;
+
+function TMiditrack.getCurrentTime: integer;
+begin
+ result := currentTime;
+end;
+
+procedure TMiditrack.Rewind(pos: integer);
+begin
+ if currentPos = events.count then
+ dec(currentPos);
+ while ((currentPos > 0) and
+ (PMidiEvent(events[currentPos]).time > pos))
+ do
+ begin
+ dec(currentPos);
+ end;
+ checkReady;
+end;
+
+procedure TMiditrack.PlayUntil(pos: integer);
+begin
+ if assigned(OnMidiEvent) then
+ begin
+ while ((currentPos < events.count) and
+ (PMidiEvent(events[currentPos]).time < pos)) do
+ begin
+ OnMidiEvent(PMidiEvent(events[currentPos]));
+ inc(currentPos);
+ end;
+ end;
+ checkReady;
+end;
+
+procedure TMidiTrack.GoUntil(pos: integer);
+begin
+ while ((currentPos < events.count) and
+ (PMidiEvent(events[currentPos]).time < pos)) do
+ begin
+ inc(currentPos);
+ end;
+ checkReady;
+end;
+
+procedure TMidiTrack.checkReady;
+begin
+ if currentPos >= events.count then
+ begin
+ ready := true;
+ if assigned(OnTrackReady) then
+ OnTrackReady;
+ end
+ else
+ ready := false;
+end;
+
+function TMidiTrack.getTrackLength: integer;
+begin
+ result := PMidiEvent(events[events.count-1]).time
+end;
+
+function TMidiTrack.isReady: boolean;
+begin
+ result := ready;
+end;
+
+constructor TMidifile.Create(AOwner: TComponent);
+begin
+ inherited Create(AOWner);
+ MIDIFileHandle:=AllocateHWnd(WndProc);
+ chunkData := nil;
+ chunkType := illegal;
+ Tracks := TList.Create;
+ TimerProc:=TimerCallBackProc;
+ FPriority:=GetPriorityClass(MIDIFileHandle);
+end;
+
+destructor TMidifile.Destroy;
+var
+ i: integer;
+begin
+ if not (chunkData = nil) then FreeMem(chunkData);
+ for i := 0 to Tracks.Count - 1 do
+ TMidiTrack(Tracks.Items[i]).Free;
+ Tracks.Free;
+ SetPriorityClass(MIDIFileHandle,FPriority);
+
+ if MIDITimerID<>0 then KillMIDITimer;
+
+ DeallocateHWnd(MIDIFileHandle);
+
+ inherited Destroy;
+end;
+
+function TMidiFile.GetTrack(index: integer): TMidiTrack;
+begin
+ result := Tracks.Items[index];
+end;
+
+procedure TMidifile.setFilename(val: string);
+begin
+ FFilename := val;
+// ReadFile;
+end;
+
+procedure TMidifile.SetOnMidiEvent(handler: TOnMidiEvent);
+var
+ i: integer;
+begin
+// if not (FOnMidiEvent = handler) then
+// begin
+ FOnMidiEvent := handler;
+ for i := 0 to tracks.count - 1 do
+ TMidiTrack(tracks.items[i]).OnMidiEvent := handler;
+// end;
+end;
+
+procedure TMidifile.MidiTimer(Sender: TObject);
+begin
+ if playing then
+ begin
+ PlayToTime(GetTickCount - PlayStartTime);
+ if assigned(FOnUpdateEvent) then FOnUpdateEvent(self);
+ end;
+end;
+
+procedure TMidifile.StartPlaying;
+var
+ i: integer;
+begin
+ for i := 0 to tracks.count - 1 do
+ TMidiTrack(tracks[i]).Rewind(0);
+ playStartTime := getTickCount;
+ playing := true;
+
+ SetPriorityClass(MIDIFileHandle,REALTIME_PRIORITY_CLASS);
+
+ SetMIDITimer;
+ currentPos := 0.0;
+ currentTime := 0;
+end;
+
+procedure TMidifile.ContinuePlaying;
+begin
+ PlayStartTime := GetTickCount - currentTime;
+ playing := true;
+
+ SetPriorityClass(MIDIFileHandle,REALTIME_PRIORITY_CLASS);
+
+ SetMIDITimer;
+end;
+
+procedure TMidifile.StopPlaying;
+begin
+ playing := false;
+ KillMIDITimer;
+ SetPriorityClass(MIDIFileHandle,FPriority);
+end;
+
+function TMidiFile.GetCurrentTime: integer;
+begin
+ Result := currentTime;
+end;
+
+procedure TMidifile.PlayToTime(time: integer);
+var
+ i: integer;
+ track: TMidiTrack;
+ pos: integer;
+ deltaTime: integer;
+begin
+ // calculate the pos in the file.
+ // pos is actually tick
+ // Current FusPerTick is uses to determine the actual pos
+
+ deltaTime := time - currentTime;
+ currentPos := currentPos + (deltaTime * 1000) / FusPerTick;
+ pos := round(currentPos);
+
+ for i := 0 to tracks.count - 1 do
+ begin
+ TMidiTrack(tracks.items[i]).PlayUntil(pos);
+ end;
+ currentTime := time;
+end;
+
+procedure TMidifile.GoToTime(time: integer);
+var
+ i: integer;
+ track: TMidiTrack;
+ pos: integer;
+begin
+ // this function should be changed because FusPerTick might not be constant
+ pos := round((time * 1000) / FusPerTick);
+ for i := 0 to tracks.count - 1 do
+ begin
+ TMidiTrack(tracks.items[i]).Rewind(0);
+ TMidiTrack(tracks.items[i]).GoUntil(pos);
+ end;
+end;
+
+procedure TMidifile.SetBpm(val: integer);
+var
+ us_per_quarter: integer;
+begin
+ if not (val = FBpm) then
+ begin
+ us_per_quarter := 60000000 div val;
+
+ FBpm := 60000000 div us_per_quarter;
+ FusPerTick := us_per_quarter / deltaTicks;
+ end;
+end;
+
+procedure TMidifile.ReadChunkHeader;
+var
+ theByte: array[0..7] of byte;
+begin
+ BlockRead(midiFile, theByte, 8);
+ if (theByte[0] = $4D) and (theByte[1] = $54) then
+ begin
+ if (theByte[2] = $68) and (theByte[3] = $64) then
+ chunkType := header
+ else if (theByte[2] = $72) and (theByte[3] = $6B) then
+ chunkType := track
+ else
+ chunkType := illegal;
+ end
+ else
+ begin
+ chunkType := illegal;
+ end;
+ chunkLength := theByte[7] + theByte[6] * $100 + theByte[5] * $10000 + theByte[4] * $1000000;
+end;
+
+procedure TMidifile.ReadChunkContent;
+begin
+ if not (chunkData = nil) then
+ FreeMem(chunkData);
+ GetMem(chunkData, chunkLength + 10);
+ BlockRead(midiFile, chunkData^, chunkLength);
+ chunkIndex := chunkData;
+ chunkEnd := PByte(integer(chunkIndex) + integer(chunkLength) - 1);
+end;
+
+procedure TMidifile.ReadChunk;
+begin
+ ReadChunkHeader;
+ ReadChunkContent;
+ case chunkType of
+ header:
+ ProcessHeaderChunk;
+ track:
+ ProcessTrackCHunk;
+ end;
+end;
+
+procedure TMidifile.ProcessHeaderChunk;
+begin
+ chunkIndex := chunkData;
+ inc(chunkIndex);
+ if chunkType = header then
+ begin
+ case chunkIndex^ of
+ 0: FfileFormat := single;
+ 1: FfileFormat := multi_synch;
+ 2: FfileFormat := multi_asynch;
+ end;
+ inc(chunkIndex);
+ numberTracks := chunkIndex^ * $100;
+ inc(chunkIndex);
+ numberTracks := numberTracks + chunkIndex^;
+ inc(chunkIndex);
+ deltaTicks := chunkIndex^ * $100;
+ inc(chunkIndex);
+ deltaTicks := deltaTicks + chunkIndex^;
+ end;
+end;
+
+procedure TMidifile.ProcessTrackChunk;
+var
+ dTime: integer;
+ event: integer;
+ len: integer;
+ str: string;
+ midiEvent: PMidiEvent;
+ i: integer;
+ us_per_quarter: integer;
+begin
+ chunkIndex := chunkData;
+// inc(chunkIndex);
+ event := 0;
+ if chunkType = track then
+ begin
+ currentTrack := TMidiTrack.Create;
+ currentTrack.OnMidiEvent := FOnMidiEvent;
+ Tracks.add(currentTrack);
+ while integer(chunkIndex) < integer(chunkEnd) do
+ begin
+ // each event starts with var length delta time
+ dTime := ReadVarLength;
+ if chunkIndex^ >= $80 then
+ begin
+ event := chunkIndex^;
+ inc(chunkIndex);
+ end;
+ // else it is a running status event (just the same event as before)
+
+ if event = $FF then
+ begin
+{ case chunkIndex^ of
+ $00: // sequence number, not implemented jet
+ begin
+ inc(chunkIndex); // $02
+ inc(chunkIndex);
+ end;
+ $01 .. $0f: // text events FF ty len text
+ begin
+ New(midiEvent);
+ midiEvent.event := $FF;
+ midiEvent.data1 := chunkIndex^; // type is stored in data1
+ midiEvent.dticks := dtime;
+
+ inc(chunkIndex);
+ len := ReadVarLength;
+ midiEvent.str := ReadString(len);
+
+ currentTrack.putEvent(midiEvent);
+ end;
+ $20: // Midi channel prefix FF 20 01 cc
+ begin
+ inc(chunkIndex); // $01
+ inc(chunkIndex); // channel
+ inc(chunkIndex);
+ end;
+ $2F: // End of track FF 2F 00
+ begin
+ inc(chunkIndex); // $00
+ inc(chunkIndex);
+ end;
+ $51: // Set Tempo FF 51 03 tttttt
+ begin
+ inc(chunkIndex); // $03
+ inc(chunkIndex); // tt
+ inc(chunkIndex); // tt
+ inc(chunkIndex); // tt
+ inc(chunkIndex);
+ end;
+ $54: // SMPTE offset FF 54 05 hr mn se fr ff
+ begin
+ inc(chunkIndex); // $05
+ inc(chunkIndex); // hr
+ inc(chunkIndex); // mn
+ inc(chunkIndex); // se
+ inc(chunkIndex); // fr
+ inc(chunkIndex); // ff
+ inc(chunkIndex);
+ end;
+ $58: // Time signature FF 58 04 nn dd cc bb
+ begin
+ inc(chunkIndex); // $04
+ inc(chunkIndex); // nn
+ inc(chunkIndex); // dd
+ inc(chunkIndex); // cc
+ inc(chunkIndex); // bb
+ inc(chunkIndex);
+ end;
+ $59: // Key signature FF 59 02 df mi
+ begin
+ inc(chunkIndex); // $02
+ inc(chunkIndex); // df
+ inc(chunkIndex); // mi
+ inc(chunkIndex);
+ end;
+ $7F: // Sequence specific Meta-event
+ begin
+ inc(chunkIndex);
+ len := ReadVarLength;
+ str := ReadString(len);
+ end;
+ else // unknown meta event
+ }
+ begin
+ New(midiEvent);
+ midiEvent.event := $FF;
+ midiEvent.data1 := chunkIndex^; // type is stored in data1
+ midiEvent.dticks := dtime;
+
+ inc(chunkIndex);
+ len := ReadVarLength;
+ midiEvent.str := ReadString(len);
+ currentTrack.putEvent(midiEvent);
+
+ case midiEvent.data1 of
+ $51:
+ begin
+ us_per_quarter :=
+ (integer(byte(midiEvent.str[1])) shl 16 +
+ integer(byte(midiEvent.str[2])) shl 8 +
+ integer(byte(midiEvent.str[3])));
+ FBpm := 60000000 div us_per_quarter;
+ FusPerTick := us_per_quarter / deltaTicks;
+ end;
+ end;
+ end;
+// end;
+ end
+ else
+ begin
+ // these are all midi events
+ New(midiEvent);
+ midiEvent.event := event;
+ midiEvent.dticks := dtime;
+// inc(chunkIndex);
+ case event of
+ $80..$8F, // note off
+ $90..$9F, // note on
+ $A0..$AF, // key aftertouch
+ $B0..$BF, // control change
+ $E0..$EF: // pitch wheel change
+ begin
+ midiEvent.data1 := chunkIndex^; inc(chunkIndex);
+ midiEvent.data2 := chunkIndex^; inc(chunkIndex);
+ end;
+ $C0..$CF, // program change
+ $D0..$DF: // channel aftertouch
+ begin
+ midiEvent.data1 := chunkIndex^; inc(chunkIndex);
+ end;
+ else
+ // error
+ end;
+ currentTrack.putEvent(midiEvent);
+ end;
+ end;
+ end;
+end;
+
+
+function TMidifile.ReadVarLength: integer;
+var
+ i: integer;
+ b: byte;
+begin
+ b := 128;
+ i := 0;
+ while b > 127 do
+ begin
+ i := i shl 7;
+ b := chunkIndex^;
+ i := i + b and $7F;
+ inc(chunkIndex);
+ end;
+ result := i;
+end;
+
+function TMidifile.ReadString(l: integer): string;
+var
+ s: PChar;
+ i: integer;
+begin
+ GetMem(s, l + 1); ;
+ s[l] := chr(0);
+ for i := 0 to l - 1 do
+ begin
+ s[i] := Chr(chunkIndex^);
+ inc(chunkIndex);
+ end;
+ result := string(s);
+end;
+
+procedure TMidifile.ReadFile;
+var
+ i: integer;
+begin
+ for i := 0 to Tracks.Count - 1 do
+ TMidiTrack(Tracks.Items[i]).Free;
+ Tracks.Clear;
+ chunkType := illegal;
+
+ AssignFile(midiFile, FFilename);
+ FileMode := 0;
+ Reset(midiFile);
+ while not eof(midiFile) do
+ ReadChunk;
+ CloseFile(midiFile);
+ numberTracks := Tracks.Count;
+end;
+
+function KeyToStr(key: integer): string;
+var
+ n: integer;
+ str: string;
+begin
+ n := key mod 12;
+ case n of
+ 0: str := 'C';
+ 1: str := 'C#';
+ 2: str := 'D';
+ 3: str := 'D#';
+ 4: str := 'E';
+ 5: str := 'F';
+ 6: str := 'F#';
+ 7: str := 'G';
+ 8: str := 'G#';
+ 9: str := 'A';
+ 10: str := 'A#';
+ 11: str := 'B';
+ end;
+ Result := str + IntToStr(key div 12);
+end;
+
+function IntToLenStr(val: integer; len: integer): string;
+var
+ str: string;
+begin
+ str := IntToStr(val);
+ while Length(str) < len do
+ str := '0' + str;
+ Result := str;
+end;
+
+function MyTimeToStr(val: integer): string;
+ var
+ hour: integer;
+ min: integer;
+ sec: integer;
+ msec: integer;
+begin
+ msec := val mod 1000;
+ sec := val div 1000;
+ min := sec div 60;
+ sec := sec mod 60;
+ hour := min div 60;
+ min := min mod 60;
+ Result := IntToStr(hour) + ':' + IntToLenStr(min, 2) + ':' + IntToLenStr(sec, 2) + '.' + IntToLenStr(msec, 3);
+end;
+
+function TMidiFIle.GetFusPerTick : Double;
+begin
+ Result := FusPerTick;
+end;
+
+function TMidiFIle.GetTrackLength:integer;
+var i,length : integer;
+ time : extended;
+begin
+ length := 0;
+ for i := 0 to Tracks.Count - 1 do
+ if TMidiTrack(Tracks.Items[i]).getTrackLength > length then
+ length := TMidiTrack(Tracks.Items[i]).getTrackLength;
+ time := length * FusPerTick;
+ time := time / 1000.0;
+ result := round(time);
+end;
+
+function TMidiFIle.Ready: boolean;
+var i : integer;
+begin
+ result := true;
+ for i := 0 to Tracks.Count - 1 do
+ if not TMidiTrack(Tracks.Items[i]).isready then
+ result := false;
+end;
+
+procedure TMidiFile.OnTrackReady;
+begin
+ if ready then
+ if assigned(FOnUpdateEvent) then FOnUpdateEvent(self);
+end;
+
+procedure TMidiFile.WndProc(var Msg : TMessage);
+begin
+ with MSG do
+ begin
+ case Msg of
+ WM_MULTIMEDIA_TIMER:
+ begin
+ try
+ MidiTimer(self);
+ except
+ Application.HandleException(Self);
+ end;
+ end;
+ else
+ begin
+ Result := DefWindowProc(MIDIFileHandle, Msg, wParam, lParam);
+ end;
+ end;
+ end;
+end;
+
+procedure Register;
+begin
+ RegisterComponents('Synth', [TMidiFile]);
+end;
+
+end.
+
diff --git a/Game/Code/lib/midi/MidiScope.pas b/Game/Code/lib/midi/MidiScope.pas new file mode 100644 index 00000000..0caa430f --- /dev/null +++ b/Game/Code/lib/midi/MidiScope.pas @@ -0,0 +1,193 @@ +{
+ Shows a large black area where midi note/controller events are shown
+ just to monitor midi activity (for the MidiPlayer)
+
+ version 1.0 first release
+
+ for comments/bugs
+ F.Bouwmans
+ fbouwmans@spiditel.nl
+
+ if you think this component is nice and you use it, sent me a short email.
+ I've seen that other of my components have been downloaded a lot, but I've
+ got no clue wether they are actually used.
+ Don't worry because you are free to use these components
+}
+
+unit MidiScope;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
+
+type
+ TMidiScope = class(TGraphicControl)
+ private
+ { Private declarations }
+ protected
+ { Protected declarations }
+ notes : array[0..15,0..127] of integer;
+ controllers : array[0..15,0..17] of integer;
+ aftertouch : array[0..15,0..127] of integer;
+
+ selectedChannel : integer;
+
+ procedure PaintSlide(ch,pos,val: integer);
+
+ procedure NoteOn(channel, note, speed : integer);
+ procedure Controller(channel,number,value : integer);
+ procedure AfterTch(channel, note, value : integer);
+
+ public
+ { Public declarations }
+ constructor Create(AOwner: TComponent); override;
+ procedure MidiEvent(event,data1,data2 : integer);
+ procedure Paint; override;
+ published
+ { Published declarations }
+ end;
+
+
+procedure Register;
+
+const
+ BarHeight = 16;
+ BarHeightInc = BarHeight+2;
+ BarWidth = 3;
+ BarWidthInc = BarWidth+1;
+ HeightDiv = 128 div BarHeight;
+
+implementation
+
+uses Midicons;
+
+procedure Register;
+begin
+ RegisterComponents('Synth', [TMidiScope]);
+end;
+
+constructor TMidiScope.Create(AOwner: TComponent);
+var
+ i,j : integer;
+begin
+ inherited Create(AOwner);
+ Height := BarHeightinc * 16 + 4;
+ Width := 147*BarWidthInc + 4 + 20; // for channel number
+ for i := 0 to 15 do
+ begin
+ for j := 0 to 127 do
+ begin
+ notes[i,j] := 0;
+ aftertouch[i,j] := 0;
+ end;
+ end;
+ for i := 0 to 17 do
+ begin
+ for j := 0 to 15 do
+ controllers[i,j] := 0;
+ end;
+end;
+
+procedure TMidiScope.PaintSlide(ch,pos,val: integer);
+var x,y:integer;
+begin
+ Canvas.Brush.Color := clBlack;
+ Canvas.Pen.color := clBlack;
+ x := pos * BarWidthInc + 2;
+ y := 2 + ch * BarHeightInc;
+ Canvas.Rectangle(x, y, x+BarWidthInc, y+BarHeightInc);
+ Canvas.Brush.Color := clGreen;
+ Canvas.Pen.Color := clGreen;
+ Canvas.Rectangle(x, y + (BarHeight - (val div HeightDiv )), x + BarWidth, y + BarHeight)
+end;
+
+procedure TMidiScope.Paint;
+var i,j : integer;
+x : integer;
+begin
+ Canvas.Brush.color := clBlack;
+ Canvas.Rectangle(0,0,Width,Height);
+ Canvas.Pen.Color := clGreen;
+ x := 128*BarWidthInc+2;
+ Canvas.MoveTo(x,0);
+ Canvas.LineTo(x,Height);
+ x := 148*BarWIdthInc+2;
+ canvas.Font.Color := clGreen;
+ for i := 0 to 15 do
+ Canvas.TextOut(x,((i+1)*BarHeightInc) - Canvas.font.size-3,IntToStr(i+1));
+ canvas.Pen.color := clBlack;
+ begin
+ for j := 0 to 127 do
+ begin
+ PaintSlide(i,j,notes[i,j]);
+ end;
+ for j := 0 to 17 do
+ begin
+ PaintSlide(i,j+129,controllers[i,j]);
+ end;
+ end;
+end;
+procedure TMidiScope.NoteOn(channel, note, speed : integer);
+begin
+ notes[channel,note] := speed;
+ PaintSlide(channel,note,notes[channel,note]);
+end;
+procedure TMidiScope.AfterTch(channel, note, value : integer);
+begin
+ aftertouch[channel,note] := value;
+end;
+
+procedure TMidiScope.Controller(channel,number,value : integer);
+var i : integer;
+begin
+ if number < 18 then
+ begin
+ controllers[channel,number] := value;
+ PaintSlide(channel,number+129,value);
+ end
+ else if number >= $7B then
+ begin
+ // all notes of for channel
+ for i := 0 to 127 do
+ begin
+ if notes[channel,i] > 0 then
+ begin
+ notes[channel,i] := 0;
+ PaintSlide(channel,i,0);
+ end;
+ end;
+ end;
+end;
+
+procedure TMidiScope.MidiEvent(event,data1,data2 : integer);
+begin
+ case (event AND $F0) of
+ MIDI_NOTEON :
+ begin
+ NoteOn((event AND $F),data1,data2);
+ end;
+ MIDI_NOTEOFF:
+ begin
+ NoteOn((event AND $F),data1,0);
+ end;
+ MIDI_CONTROLCHANGE :
+ begin
+ Controller((event AND $F),data1,data2);
+ end;
+ MIDI_CHANAFTERTOUCH:
+ begin
+ Controller((Event AND $F),16,Data1);
+ end;
+ MIDI_PITCHBEND:
+ begin
+ begin
+ Controller((Event AND $F),17,data2);
+ end;
+ end;
+ MIDI_KEYAFTERTOUCH:
+ begin
+ end;
+ end;
+end;
+end.
diff --git a/Game/Code/lib/midi/Midicons.pas b/Game/Code/lib/midi/Midicons.pas new file mode 100644 index 00000000..41dda9e1 --- /dev/null +++ b/Game/Code/lib/midi/Midicons.pas @@ -0,0 +1,42 @@ +{ $Header: /MidiComp/MIDICONS.PAS 2 10/06/97 7:33 Davec $ }
+
+{ Written by David Churcher <dchurcher@cix.compulink.co.uk>,
+ released to the public domain. }
+
+
+{ MIDI Constants }
+unit Midicons;
+
+interface
+
+uses Messages;
+
+const
+ MIDI_ALLNOTESOFF = $7B;
+ MIDI_NOTEON = $90;
+ MIDI_NOTEOFF = $80;
+ MIDI_KEYAFTERTOUCH = $a0;
+ MIDI_CONTROLCHANGE = $b0;
+ MIDI_PROGRAMCHANGE = $c0;
+ MIDI_CHANAFTERTOUCH = $d0;
+ MIDI_PITCHBEND = $e0;
+ MIDI_SYSTEMMESSAGE = $f0;
+ MIDI_BEGINSYSEX = $f0;
+ MIDI_MTCQUARTERFRAME = $f1;
+ MIDI_SONGPOSPTR = $f2;
+ MIDI_SONGSELECT = $f3;
+ MIDI_ENDSYSEX = $F7;
+ MIDI_TIMINGCLOCK = $F8;
+ MIDI_START = $FA;
+ MIDI_CONTINUE = $FB;
+ MIDI_STOP = $FC;
+ MIDI_ACTIVESENSING = $FE;
+ MIDI_SYSTEMRESET = $FF;
+
+ MIM_OVERFLOW = WM_USER; { Input buffer overflow }
+ MOM_PLAYBACK_DONE = WM_USER+1; { Timed playback complete }
+
+
+implementation
+
+end.
diff --git a/Game/Code/lib/midi/Midiin.pas b/Game/Code/lib/midi/Midiin.pas new file mode 100644 index 00000000..32a17c51 --- /dev/null +++ b/Game/Code/lib/midi/Midiin.pas @@ -0,0 +1,712 @@ +{ $Header: /MidiComp/Midiin.pas 2 10/06/97 7:33 Davec $ }
+
+{ Written by David Churcher <dchurcher@cix.compulink.co.uk>,
+ released to the public domain. }
+
+unit MidiIn;
+
+{
+ Properties:
+ DeviceID: Windows numeric device ID for the MIDI input device.
+ Between 0 and NumDevs-1.
+ Read-only while device is open, exception when changed while open
+
+ MIDIHandle: The input handle to the MIDI device.
+ 0 when device is not open
+ Read-only, runtime-only
+
+ MessageCount: Number of input messages waiting in input buffer
+
+ Capacity: Number of messages input buffer can hold
+ Defaults to 1024
+ Limited to (64K/event size)
+ Read-only when device is open (exception when changed while open)
+
+ SysexBufferSize: Size in bytes of each sysex buffer
+ Defaults to 10K
+ Minimum 0K (no buffers), Maximum 64K-1
+
+ SysexBufferCount: Number of sysex buffers
+ Defaults to 16
+ Minimum 0 (no buffers), Maximum (avail mem/SysexBufferSize)
+ Check where these buffers are allocated?
+
+ SysexOnly: True to ignore all non-sysex input events. May be changed while
+ device is open. Handy for patch editors where you have lots of short MIDI
+ events on the wire which you are always going to ignore anyway.
+
+ DriverVersion: Version number of MIDI device driver. High-order byte is
+ major version, low-order byte is minor version.
+
+ ProductName: Name of product (e.g. 'MPU 401 In')
+
+ MID and PID: Manufacturer ID and Product ID, see
+ "Manufacturer and Product IDs" in MMSYSTEM.HLP for list of possible values.
+
+ Methods:
+ GetMidiEvent: Read Midi event at the head of the FIFO input buffer.
+ Returns a TMyMidiEvent object containing MIDI message data, timestamp,
+ and sysex data if applicable.
+ This method automatically removes the event from the input buffer.
+ It makes a copy of the received sysex buffer and puts the buffer back
+ on the input device.
+ The TMyMidiEvent object must be freed by calling MyMidiEvent.Free.
+
+ Open: Opens device. Note no input will appear until you call the Start
+ method.
+
+ Close: Closes device. Any pending system exclusive output will be cancelled.
+
+ Start: Starts receiving MIDI input.
+
+ Stop: Stops receiving MIDI input.
+
+ Events:
+ OnMidiInput: Called when MIDI input data arrives. Use the GetMidiEvent to
+ get the MIDI input data.
+
+ OnOverflow: Called if the MIDI input buffer overflows. The caller must
+ clear the buffer before any more MIDI input can be received.
+
+ Notes:
+ Buffering: Uses a circular buffer, separate pointers for next location
+ to fill and next location to empty because a MIDI input interrupt may
+ be adding data to the buffer while the buffer is being read. Buffer
+ pointers wrap around from end to start of buffer automatically. If
+ buffer overflows then the OnBufferOverflow event is triggered and no
+ further input will be received until the buffer is emptied by calls
+ to GetMidiEvent.
+
+ Sysex buffers: There are (SysexBufferCount) buffers on the input device.
+ When sysex events arrive these buffers are removed from the input device and
+ added to the circular buffer by the interrupt handler in the DLL. When the sysex events
+ are removed from the circular buffer by the GetMidiEvent method the buffers are
+ put back on the input. If all the buffers are used up there will be no
+ more sysex input until at least one sysex event is removed from the input buffer.
+ In other words if you're expecting lots of sysex input you need to set the
+ SysexBufferCount property high enough so that you won't run out of
+ input buffers before you get a chance to read them with GetMidiEvent.
+
+ If the synth sends a block of sysex that's longer than SysexBufferSize it
+ will be received as separate events.
+ TODO: Component derived from this one that handles >64K sysex blocks cleanly
+ and can stream them to disk.
+
+ Midi Time Code (MTC) and Active Sensing: The DLL is currently hardcoded
+ to filter these short events out, so that we don't spend all our time
+ processing them.
+ TODO: implement a filter property to select the events that will be filtered
+ out.
+}
+
+interface
+
+uses
+ Classes, SysUtils, WinTypes, Messages, WinProcs, MMSystem, MidiDefs, MidiType,
+ MidiCons, Circbuf, Delphmcb;
+
+type
+ MidiInputState = (misOpen, misClosed, misCreating, misDestroying);
+ EMidiInputError = class(Exception);
+
+ {-------------------------------------------------------------------}
+ TMidiInput = class(TComponent)
+ private
+ Handle: THandle; { Window handle used for callback notification }
+ FDeviceID: Word; { MIDI device ID }
+ FMIDIHandle: HMIDIIn; { Handle to input device }
+ FState: MidiInputState; { Current device state }
+
+ FError: Word;
+ FSysexOnly: Boolean;
+
+ { Stuff from MIDIINCAPS }
+ FDriverVersion: Version;
+ FProductName: string;
+ FMID: Word; { Manufacturer ID }
+ FPID: Word; { Product ID }
+
+ { Queue }
+ FCapacity: Word; { Buffer capacity }
+ PBuffer: PCircularBuffer; { Low-level MIDI input buffer created by Open method }
+ FNumdevs: Word; { Number of input devices on system }
+
+ { Events }
+ FOnMIDIInput: TNotifyEvent; { MIDI Input arrived }
+ FOnOverflow: TNotifyEvent; { Input buffer overflow }
+ { TODO: Some sort of error handling event for MIM_ERROR }
+
+ { Sysex }
+ FSysexBufferSize: Word;
+ FSysexBufferCount: Word;
+ MidiHdrs: Tlist;
+
+ PCtlInfo: PMidiCtlInfo; { Pointer to control info for DLL }
+
+ protected
+ procedure Prepareheaders;
+ procedure UnprepareHeaders;
+ procedure AddBuffers;
+ procedure SetDeviceID(DeviceID: Word);
+ procedure SetProductName(NewProductName: string);
+ function GetEventCount: Word;
+ procedure SetSysexBufferSize(BufferSize: Word);
+ procedure SetSysexBufferCount(BufferCount: Word);
+ procedure SetSysexOnly(bSysexOnly: Boolean);
+ function MidiInErrorString(WError: Word): string;
+
+ public
+ constructor Create(AOwner: TComponent); override;
+ destructor Destroy; override;
+
+ property MIDIHandle: HMIDIIn read FMIDIHandle;
+
+ property DriverVersion: Version read FDriverVersion;
+ property MID: Word read FMID; { Manufacturer ID }
+ property PID: Word read FPID; { Product ID }
+
+ property Numdevs: Word read FNumdevs;
+
+ property MessageCount: Word read GetEventCount;
+ { TODO: property to select which incoming messages get filtered out }
+
+ procedure Open;
+ procedure Close;
+ procedure Start;
+ procedure Stop;
+ { Get first message in input queue }
+ function GetMidiEvent: TMyMidiEvent;
+ procedure MidiInput(var Message: TMessage);
+
+ { Some functions to decode and classify incoming messages would be good }
+
+ published
+
+ { TODO: Property editor with dropdown list of product names }
+ property ProductName: string read FProductName write SetProductName;
+
+ property DeviceID: Word read FDeviceID write SetDeviceID default 0;
+ property Capacity: Word read FCapacity write FCapacity default 1024;
+ property Error: Word read FError;
+ property SysexBufferSize: Word
+ read FSysexBufferSize
+ write SetSysexBufferSize
+ default 10000;
+ property SysexBufferCount: Word
+ read FSysexBufferCount
+ write SetSysexBufferCount
+ default 16;
+ property SysexOnly: Boolean
+ read FSysexOnly
+ write SetSysexOnly
+ default False;
+
+ { Events }
+ property OnMidiInput: TNotifyEvent read FOnMidiInput write FOnMidiInput;
+ property OnOverflow: TNotifyEvent read FOnOverflow write FOnOverflow;
+
+ end;
+
+procedure Register;
+
+{====================================================================}
+implementation
+
+uses Controls,
+ Forms,
+ Graphics;
+
+(* Not used in Delphi 3
+{ This is the callback procedure in the external DLL.
+ It's used when midiInOpen is called by the Open method.
+ There are special requirements and restrictions for this callback
+ procedure (see midiInOpen in MMSYSTEM.HLP) so it's impractical to
+ make it an object method }
+{$IFDEF WIN32}
+function midiHandler(
+ hMidiIn: HMidiIn;
+ wMsg: UINT;
+ dwInstance: DWORD;
+ dwParam1: DWORD;
+ dwParam2: DWORD): Boolean; stdcall; external 'DELMID32.DLL';
+{$ELSE}
+procedure midiHandler(
+ hMidiIn: HMidiIn;
+ wMsg: Word;
+ dwInstance: DWORD;
+ dwParam1: DWORD;
+ dwParam2: DWORD); far; external 'DELPHMID';
+{$ENDIF}
+*)
+{-------------------------------------------------------------------}
+
+constructor TMidiInput.Create(AOwner: TComponent);
+begin
+ inherited Create(AOwner);
+ FState := misCreating;
+
+ FSysexOnly := False;
+ FNumDevs := midiInGetNumDevs;
+ MidiHdrs := nil;
+
+ { Set defaults }
+ if (FNumDevs > 0) then
+ SetDeviceID(0);
+ FCapacity := 1024;
+ FSysexBufferSize := 4096;
+ FSysexBufferCount := 16;
+
+ { Create the window for callback notification }
+ if not (csDesigning in ComponentState) then
+ begin
+ Handle := AllocateHwnd(MidiInput);
+ end;
+
+ FState := misClosed;
+
+end;
+
+{-------------------------------------------------------------------}
+{ Close the device if it's open }
+
+destructor TMidiInput.Destroy;
+begin
+ if (FMidiHandle <> 0) then
+ begin
+ Close;
+ FMidiHandle := 0;
+ end;
+
+ if (PCtlInfo <> nil) then
+ GlobalSharedLockedFree(PCtlinfo^.hMem, PCtlInfo);
+
+ DeallocateHwnd(Handle);
+ inherited Destroy;
+end;
+
+{-------------------------------------------------------------------}
+{ Convert the numeric return code from an MMSYSTEM function to a string
+ using midiInGetErrorText. TODO: These errors aren't very helpful
+ (e.g. "an invalid parameter was passed to a system function") so
+ sort out some proper error strings. }
+
+function TMidiInput.MidiInErrorString(WError: Word): string;
+var
+ errorDesc: PChar;
+begin
+ errorDesc := nil;
+ try
+ errorDesc := StrAlloc(MAXERRORLENGTH);
+ if midiInGetErrorText(WError, errorDesc, MAXERRORLENGTH) = 0 then
+ result := StrPas(errorDesc)
+ else
+ result := 'Specified error number is out of range';
+ finally
+ if errorDesc <> nil then StrDispose(errorDesc);
+ end;
+end;
+
+{-------------------------------------------------------------------}
+{ Set the sysex buffer size, fail if device is already open }
+
+procedure TMidiInput.SetSysexBufferSize(BufferSize: Word);
+begin
+ if FState = misOpen then
+ raise EMidiInputError.Create('Change to SysexBufferSize while device was open')
+ else
+ { TODO: Validate the sysex buffer size. Is this necessary for WIN32? }
+ FSysexBufferSize := BufferSize;
+end;
+
+{-------------------------------------------------------------------}
+{ Set the sysex buffer count, fail if device is already open }
+
+procedure TMidiInput.SetSysexBuffercount(Buffercount: Word);
+begin
+ if FState = misOpen then
+ raise EMidiInputError.Create('Change to SysexBuffercount while device was open')
+ else
+ { TODO: Validate the sysex buffer count }
+ FSysexBuffercount := Buffercount;
+end;
+
+{-------------------------------------------------------------------}
+{ Set the Sysex Only flag to eliminate unwanted short MIDI input messages }
+
+procedure TMidiInput.SetSysexOnly(bSysexOnly: Boolean);
+begin
+ FSysexOnly := bSysexOnly;
+ { Update the interrupt handler's copy of this property }
+ if PCtlInfo <> nil then
+ PCtlInfo^.SysexOnly := bSysexOnly;
+end;
+
+{-------------------------------------------------------------------}
+{ Set the Device ID to select a new MIDI input device
+ Note: If no MIDI devices are installed, throws an 'Invalid Device ID' exception }
+
+procedure TMidiInput.SetDeviceID(DeviceID: Word);
+var
+ MidiInCaps: TMidiInCaps;
+begin
+ if FState = misOpen then
+ raise EMidiInputError.Create('Change to DeviceID while device was open')
+ else
+ if (DeviceID >= midiInGetNumDevs) then
+ raise EMidiInputError.Create('Invalid device ID')
+ else
+ begin
+ FDeviceID := DeviceID;
+
+ { Set the name and other MIDIINCAPS properties to match the ID }
+ FError :=
+ midiInGetDevCaps(DeviceID, @MidiInCaps, sizeof(TMidiInCaps));
+ if Ferror <> MMSYSERR_NOERROR then
+ raise EMidiInputError.Create(MidiInErrorString(FError));
+
+ FProductName := StrPas(MidiInCaps.szPname);
+ FDriverVersion := MidiInCaps.vDriverVersion;
+ FMID := MidiInCaps.wMID;
+ FPID := MidiInCaps.wPID;
+
+ end;
+end;
+
+{-------------------------------------------------------------------}
+{ Set the product name and put the matching input device number in FDeviceID.
+ This is handy if you want to save a configured input/output device
+ by device name instead of device number, because device numbers may
+ change if users add or remove MIDI devices.
+ Exception if input device with matching name not found,
+ or if input device is open }
+
+procedure TMidiInput.SetProductName(NewProductName: string);
+var
+ MidiInCaps: TMidiInCaps;
+ testDeviceID: Word;
+ testProductName: string;
+begin
+ if FState = misOpen then
+ raise EMidiInputError.Create('Change to ProductName while device was open')
+ else
+ { Don't set the name if the component is reading properties because
+ the saved Productname will be from the machine the application was compiled
+ on, which may not be the same for the corresponding DeviceID on the user's
+ machine. The FProductname property will still be set by SetDeviceID }
+ if not (csLoading in ComponentState) then
+ begin
+ begin
+ for testDeviceID := 0 to (midiInGetNumDevs - 1) do
+ begin
+ FError :=
+ midiInGetDevCaps(testDeviceID, @MidiInCaps, sizeof(TMidiInCaps));
+ if Ferror <> MMSYSERR_NOERROR then
+ raise EMidiInputError.Create(MidiInErrorString(FError));
+ testProductName := StrPas(MidiInCaps.szPname);
+ if testProductName = NewProductName then
+ begin
+ FProductName := NewProductName;
+ Break;
+ end;
+ end;
+ if FProductName <> NewProductName then
+ raise EMidiInputError.Create('MIDI Input Device ' +
+ NewProductName + ' not installed ')
+ else
+ SetDeviceID(testDeviceID);
+ end;
+ end;
+end;
+
+
+{-------------------------------------------------------------------}
+{ Get the sysex buffers ready }
+
+procedure TMidiInput.PrepareHeaders;
+var
+ ctr: Word;
+ MyMidiHdr: TMyMidiHdr;
+begin
+ if (FSysexBufferCount > 0) and (FSysexBufferSize > 0)
+ and (FMidiHandle <> 0) then
+ begin
+ Midihdrs := TList.Create;
+ for ctr := 1 to FSysexBufferCount do
+ begin
+ { Initialize the header and allocate buffer memory }
+ MyMidiHdr := TMyMidiHdr.Create(FSysexBufferSize);
+
+ { Store the address of the MyMidiHdr object in the contained MIDIHDR
+ structure so we can get back to the object when a pointer to the
+ MIDIHDR is received.
+ E.g. see TMidiOutput.Output method }
+ MyMidiHdr.hdrPointer^.dwUser := DWORD(MyMidiHdr);
+
+ { Get MMSYSTEM's blessing for this header }
+ FError := midiInPrepareHeader(FMidiHandle, MyMidiHdr.hdrPointer,
+ sizeof(TMIDIHDR));
+ if Ferror <> MMSYSERR_NOERROR then
+ raise EMidiInputError.Create(MidiInErrorString(FError));
+
+ { Save it in our list }
+ MidiHdrs.Add(MyMidiHdr);
+ end;
+ end;
+
+end;
+
+{-------------------------------------------------------------------}
+{ Clean up from PrepareHeaders }
+
+procedure TMidiInput.UnprepareHeaders;
+var
+ ctr: Word;
+begin
+ if (MidiHdrs <> nil) then { will be Nil if 0 sysex buffers }
+ begin
+ for ctr := 0 to MidiHdrs.Count - 1 do
+ begin
+ FError := midiInUnprepareHeader(FMidiHandle,
+ TMyMidiHdr(MidiHdrs.Items[ctr]).hdrPointer,
+ sizeof(TMIDIHDR));
+ if Ferror <> MMSYSERR_NOERROR then
+ raise EMidiInputError.Create(MidiInErrorString(FError));
+ TMyMidiHdr(MidiHdrs.Items[ctr]).Free;
+ end;
+ MidiHdrs.Free;
+ MidiHdrs := nil;
+ end;
+end;
+
+{-------------------------------------------------------------------}
+{ Add sysex buffers, if required, to input device }
+
+procedure TMidiInput.AddBuffers;
+var
+ ctr: Word;
+begin
+ if MidiHdrs <> nil then { will be Nil if 0 sysex buffers }
+ begin
+ if MidiHdrs.Count > 0 then
+ begin
+ for ctr := 0 to MidiHdrs.Count - 1 do
+ begin
+ FError := midiInAddBuffer(FMidiHandle,
+ TMyMidiHdr(MidiHdrs.Items[ctr]).hdrPointer,
+ sizeof(TMIDIHDR));
+ if FError <> MMSYSERR_NOERROR then
+ raise EMidiInputError.Create(MidiInErrorString(FError));
+ end;
+ end;
+ end;
+end;
+
+{-------------------------------------------------------------------}
+
+procedure TMidiInput.Open;
+var
+ hMem: THandle;
+begin
+ try
+ { Create the buffer for the MIDI input messages }
+ if (PBuffer = nil) then
+ PBuffer := CircBufAlloc(FCapacity);
+
+ { Create the control info for the DLL }
+ if (PCtlInfo = nil) then
+ begin
+ PCtlInfo := GlobalSharedLockedAlloc(Sizeof(TMidiCtlInfo), hMem);
+ PctlInfo^.hMem := hMem;
+ end;
+ PctlInfo^.pBuffer := PBuffer;
+ Pctlinfo^.hWindow := Handle; { Control's window handle }
+ PCtlInfo^.SysexOnly := FSysexOnly;
+ FError := midiInOpen(@FMidiHandle, FDeviceId,
+ DWORD(@midiHandler),
+ DWORD(PCtlInfo),
+ CALLBACK_FUNCTION);
+
+ if (FError <> MMSYSERR_NOERROR) then
+ { TODO: use CreateFmtHelp to add MIDI device name/ID to message }
+ raise EMidiInputError.Create(MidiInErrorString(FError));
+
+ { Get sysex buffers ready }
+ PrepareHeaders;
+
+ { Add them to the input }
+ AddBuffers;
+
+ FState := misOpen;
+
+ except
+ if PBuffer <> nil then
+ begin
+ CircBufFree(PBuffer);
+ PBuffer := nil;
+ end;
+
+ if PCtlInfo <> nil then
+ begin
+ GlobalSharedLockedFree(PCtlInfo^.hMem, PCtlInfo);
+ PCtlInfo := nil;
+ end;
+
+ end;
+
+end;
+
+{-------------------------------------------------------------------}
+
+function TMidiInput.GetMidiEvent: TMyMidiEvent;
+var
+ thisItem: TMidiBufferItem;
+begin
+ if (FState = misOpen) and
+ CircBufReadEvent(PBuffer, @thisItem) then
+ begin
+ Result := TMyMidiEvent.Create;
+ with thisItem do
+ begin
+ Result.Time := Timestamp;
+ if (Sysex = nil) then
+ begin
+ { Short message }
+ Result.MidiMessage := LoByte(LoWord(Data));
+ Result.Data1 := HiByte(LoWord(Data));
+ Result.Data2 := LoByte(HiWord(Data));
+ Result.Sysex := nil;
+ Result.SysexLength := 0;
+ end
+ else
+ { Long Sysex message }
+ begin
+ Result.MidiMessage := MIDI_BEGINSYSEX;
+ Result.Data1 := 0;
+ Result.Data2 := 0;
+ Result.SysexLength := Sysex^.dwBytesRecorded;
+ if Sysex^.dwBytesRecorded <> 0 then
+ begin
+ { Put a copy of the sysex buffer in the object }
+ GetMem(Result.Sysex, Sysex^.dwBytesRecorded);
+ StrMove(Result.Sysex, Sysex^.lpData, Sysex^.dwBytesRecorded);
+ end;
+
+ { Put the header back on the input buffer }
+ FError := midiInPrepareHeader(FMidiHandle, Sysex,
+ sizeof(TMIDIHDR));
+ if Ferror = 0 then
+ FError := midiInAddBuffer(FMidiHandle,
+ Sysex, sizeof(TMIDIHDR));
+ if Ferror <> MMSYSERR_NOERROR then
+ raise EMidiInputError.Create(MidiInErrorString(FError));
+ end;
+ end;
+ CircbufRemoveEvent(PBuffer);
+ end
+ else
+ { Device isn't open, return a nil event }
+ Result := nil;
+end;
+
+{-------------------------------------------------------------------}
+
+function TMidiInput.GetEventCount: Word;
+begin
+ if FState = misOpen then
+ Result := PBuffer^.EventCount
+ else
+ Result := 0;
+end;
+
+{-------------------------------------------------------------------}
+
+procedure TMidiInput.Close;
+begin
+ if FState = misOpen then
+ begin
+ FState := misClosed;
+
+ { MidiInReset cancels any pending output.
+ Note that midiInReset causes an MIM_LONGDATA callback for each sysex
+ buffer on the input, so the callback function and Midi input buffer
+ should still be viable at this stage.
+ All the resulting MIM_LONGDATA callbacks will be completed by the time
+ MidiInReset returns, though. }
+ FError := MidiInReset(FMidiHandle);
+ if Ferror <> MMSYSERR_NOERROR then
+ raise EMidiInputError.Create(MidiInErrorString(FError));
+
+ { Remove sysex buffers from input device and free them }
+ UnPrepareHeaders;
+
+ { Close the device (finally!) }
+ FError := MidiInClose(FMidiHandle);
+ if Ferror <> MMSYSERR_NOERROR then
+ raise EMidiInputError.Create(MidiInErrorString(FError));
+
+ FMidiHandle := 0;
+
+ if (PBuffer <> nil) then
+ begin
+ CircBufFree(PBuffer);
+ PBuffer := nil;
+ end;
+ end;
+end;
+
+{-------------------------------------------------------------------}
+
+procedure TMidiInput.Start;
+begin
+ if FState = misOpen then
+ begin
+ FError := MidiInStart(FMidiHandle);
+ if Ferror <> MMSYSERR_NOERROR then
+ raise EMidiInputError.Create(MidiInErrorString(FError));
+ end;
+end;
+
+{-------------------------------------------------------------------}
+
+procedure TMidiInput.Stop;
+begin
+ if FState = misOpen then
+ begin
+ FError := MidiInStop(FMidiHandle);
+ if Ferror <> MMSYSERR_NOERROR then
+ raise EMidiInputError.Create(MidiInErrorString(FError));
+ end;
+end;
+
+{-------------------------------------------------------------------}
+
+procedure TMidiInput.MidiInput(var Message: TMessage);
+{ Triggered by incoming message from DLL.
+ Note DLL has already put the message in the queue }
+begin
+ case Message.Msg of
+ mim_data:
+ { Trigger the user's MIDI input event, if they've specified one and
+ we're not in the process of closing the device. The check for
+ GetEventCount > 0 prevents unnecessary event calls where the user has
+ already cleared all the events from the input buffer using a GetMidiEvent
+ loop in the OnMidiInput event handler }
+ if Assigned(FOnMIDIInput) and (FState = misOpen)
+ and (GetEventCount > 0) then
+ FOnMIDIInput(Self);
+
+ mim_Overflow: { input circular buffer overflow }
+ if Assigned(FOnOverflow) and (FState = misOpen) then
+ FOnOverflow(Self);
+ end;
+end;
+
+{-------------------------------------------------------------------}
+
+procedure Register;
+begin
+ RegisterComponents('Synth', [TMIDIInput]);
+end;
+
+end.
+
diff --git a/Game/Code/lib/midi/Midiout.pas b/Game/Code/lib/midi/Midiout.pas new file mode 100644 index 00000000..91b75073 --- /dev/null +++ b/Game/Code/lib/midi/Midiout.pas @@ -0,0 +1,600 @@ +{ $Header: /MidiComp/MidiOut.pas 2 10/06/97 7:33 Davec $ }
+
+{ Written by David Churcher <dchurcher@cix.compulink.co.uk>,
+ released to the public domain. }
+
+{ Thanks very much to Fred Kohler for the Technology code. }
+
+unit MidiOut;
+
+{
+ MIDI Output component.
+
+ Properties:
+ DeviceID: Windows numeric device ID for the MIDI output device.
+ Between 0 and (midioutGetNumDevs-1), or MIDI_MAPPER (-1).
+ Special value MIDI_MAPPER specifies output to the Windows MIDI mapper
+ Read-only while device is open, exception if changed while open
+
+ MIDIHandle: The output handle to the MIDI device.
+ 0 when device is not open
+ Read-only, runtime-only
+
+ ProductName: Name of the output device product that corresponds to the
+ DeviceID property (e.g. 'MPU 401 out').
+ You can write to this while the device is closed to select a particular
+ output device by name (the DeviceID property will change to match).
+ Exception if this property is changed while the device is open.
+
+ Numdevs: Number of MIDI output devices installed on the system. This
+ is the value returned by midiOutGetNumDevs. It's included for
+ completeness.
+
+ Technology: Type of technology used by the MIDI device. You can set this
+ property to one of the values listed for OutportTech (below) and the component
+ will find an appropriate MIDI device. For example:
+ MidiOutput.Technology := opt_FMSynth;
+ will set MidiInput.DeviceID to the MIDI device ID of the FM synth, if one
+ is installed. If no such device is available an exception is raised,
+ see MidiOutput.SetTechnology.
+
+ See the MIDIOUTCAPS entry in MMSYSTEM.HLP for descriptions of the
+ following properties:
+ DriverVersion
+ Voices
+ Notes
+ ChannelMask
+ Support
+
+ Error: The error code for the last MMSYSTEM error. See the MMSYSERR_
+ entries in MMSYSTEM.INT for possible values.
+
+ Methods:
+ Open: Open MIDI device specified by DeviceID property for output
+
+ Close: Close device
+
+ PutMidiEvent(Event:TMyMidiEvent): Output a note or sysex message to the
+ device. This method takes a TMyMidiEvent object and transmits it.
+ Notes:
+ 1. If the object contains a sysex event the OnMidiOutput event will
+ be triggered when the sysex transmission is complete.
+ 2. You can queue up multiple blocks of system exclusive data for
+ transmission by chucking them at this method; they will be
+ transmitted as quickly as the device can manage.
+ 3. This method will not free the TMyMidiEvent object, the caller
+ must do that. Any sysex data in the TMyMidiEvent is copied before
+ transmission so you can free the TMyMidiEvent immediately after
+ calling PutMidiEvent, even if output has not yet finished.
+
+ PutShort(MidiMessage: Byte; Data1: Byte; Data2: Byte): Output a short
+ MIDI message. Handy when you can't be bothered to build a TMyMidiEvent.
+ If the message you're sending doesn't use Data1 or Data2, set them to 0.
+
+ PutLong(TheSysex: Pointer; msgLength: Word): Output sysex data.
+ SysexPointer: Pointer to sysex data to send
+ msgLength: Length of sysex data.
+ This is handy when you don't have a TMyMidiEvent.
+
+ SetVolume(Left: Word, Right: Word): Set the volume of the
+ left and right channels on the output device (only on internal devices?).
+ 0xFFFF is maximum volume. If the device doesn't support separate
+ left/right volume control, the value of the Left parameter will be used.
+ Check the Support property to see whether the device supports volume
+ control. See also other notes on volume control under midiOutSetVolume()
+ in MMSYSTEM.HLP.
+
+ Events:
+ OnMidiOutput: Procedure called when output of a system exclusive block
+ is completed.
+
+ Notes:
+ I haven't implemented any methods for midiOutCachePatches and
+ midiOutCacheDrumpatches, mainly 'cause I don't have any way of testing
+ them. Does anyone really use these?
+}
+
+interface
+
+uses
+ SysUtils, WinTypes, WinProcs, Messages, Classes, Controls, Forms,
+ MMSystem, Circbuf, MidiType, MidiDefs, Delphmcb;
+
+type
+ midioutputState = (mosOpen, mosClosed);
+ EmidioutputError = class(Exception);
+
+ { These are the equivalent of constants prefixed with mod_
+ as defined in MMSystem. See SetTechnology }
+ OutPortTech = (
+ opt_None, { none }
+ opt_MidiPort, { output port }
+ opt_Synth, { generic internal synth }
+ opt_SQSynth, { square wave internal synth }
+ opt_FMSynth, { FM internal synth }
+ opt_Mapper); { MIDI mapper }
+ TechNameMap = array[OutPortTech] of string[18];
+
+
+const
+ TechName: TechNameMap = (
+ 'None', 'MIDI Port', 'Generic Synth', 'Square Wave Synth',
+ 'FM Synth', 'MIDI Mapper');
+
+{-------------------------------------------------------------------}
+type
+ TMidiOutput = class(TComponent)
+ protected
+ Handle: THandle; { Window handle used for callback notification }
+ FDeviceID: Integer; { MIDI device ID }
+ FMIDIHandle: Hmidiout; { Handle to output device }
+ FState: midioutputState; { Current device state }
+ PCtlInfo: PMidiCtlInfo; { Pointer to control info for DLL }
+
+ PBuffer: PCircularBuffer; { Output queue for PutTimedEvent, set by Open }
+
+ FError: Word; { Last MMSYSTEM error }
+
+ { Stuff from midioutCAPS }
+ FDriverVersion: Version; { Driver version from midioutGetDevCaps }
+ FProductName: string; { product name }
+ FTechnology: OutPortTech; { Type of MIDI output device }
+ FVoices: Word; { Number of voices (internal synth) }
+ FNotes: Word; { Number of notes (internal synth) }
+ FChannelMask: Word; { Bit set for each MIDI channels that the
+ device responds to (internal synth) }
+ FSupport: DWORD; { Technology supported (volume control,
+ patch caching etc. }
+ FNumdevs: Word; { Number of MIDI output devices on system }
+
+
+ FOnMIDIOutput: TNotifyEvent; { Sysex output finished }
+
+ procedure MidiOutput(var Message: TMessage);
+ procedure SetDeviceID(DeviceID: Integer);
+ procedure SetProductName(NewProductName: string);
+ procedure SetTechnology(NewTechnology: OutPortTech);
+ function midioutErrorString(WError: Word): string;
+
+ public
+ { Properties }
+ property MIDIHandle: Hmidiout read FMIDIHandle;
+ property DriverVersion: Version { Driver version from midioutGetDevCaps }
+ read FDriverVersion;
+ property Technology: OutPortTech { Type of MIDI output device }
+ read FTechnology
+ write SetTechnology
+ default opt_Synth;
+ property Voices: Word { Number of voices (internal synth) }
+ read FVoices;
+ property Notes: Word { Number of notes (internal synth) }
+ read FNotes;
+ property ChannelMask: Word { Bit set for each MIDI channels that the }
+ read FChannelMask; { device responds to (internal synth) }
+ property Support: DWORD { Technology supported (volume control, }
+ read FSupport; { patch caching etc. }
+ property Error: Word read FError;
+ property Numdevs: Word read FNumdevs;
+
+ { Methods }
+ function Open: Boolean; virtual;
+ function Close: Boolean; virtual;
+ procedure PutMidiEvent(theEvent: TMyMidiEvent); virtual;
+ procedure PutShort(MidiMessage: Byte; Data1: Byte; Data2: Byte); virtual;
+ procedure PutLong(TheSysex: Pointer; msgLength: Word); virtual;
+ procedure SetVolume(Left: Word; Right: Word);
+ constructor Create(AOwner: TComponent); override;
+ destructor Destroy; override;
+
+ { Some functions to decode and classify incoming messages would be nice }
+
+ published
+ { TODO: Property editor with dropdown list of product names }
+ property ProductName: string read FProductName write SetProductName;
+
+ property DeviceID: Integer read FDeviceID write SetDeviceID default 0;
+ { TODO: midiOutGetVolume? Or two properties for Left and Right volume?
+ Is it worth it??
+ midiOutMessage?? Does anyone use this? }
+
+ { Events }
+ property Onmidioutput: TNotifyEvent
+ read FOnmidioutput
+ write FOnmidioutput;
+ end;
+
+procedure Register;
+
+{-------------------------------------------------------------------}
+implementation
+
+(* Not used in Delphi 3
+
+{ This is the callback procedure in the external DLL.
+ It's used when midioutOpen is called by the Open method.
+ There are special requirements and restrictions for this callback
+ procedure (see midioutOpen in MMSYSTEM.HLP) so it's impractical to
+ make it an object method }
+{$IFDEF WIN32}
+function midiHandler(
+ hMidiIn: HMidiIn;
+ wMsg: UINT;
+ dwInstance: DWORD;
+ dwParam1: DWORD;
+ dwParam2: DWORD): Boolean; stdcall; external 'DELMID32.DLL';
+{$ELSE}
+function midiHandler(
+ hMidiIn: HMidiIn;
+ wMsg: Word;
+ dwInstance: DWORD;
+ dwParam1: DWORD;
+ dwParam2: DWORD): Boolean; far; external 'DELPHMID.DLL';
+{$ENDIF}
+*)
+
+{-------------------------------------------------------------------}
+
+constructor Tmidioutput.Create(AOwner: TComponent);
+begin
+ inherited Create(AOwner);
+ FState := mosClosed;
+ FNumdevs := midiOutGetNumDevs;
+
+ { Create the window for callback notification }
+ if not (csDesigning in ComponentState) then
+ begin
+ Handle := AllocateHwnd(MidiOutput);
+ end;
+
+end;
+
+{-------------------------------------------------------------------}
+
+destructor Tmidioutput.Destroy;
+begin
+ if FState = mosOpen then
+ Close;
+ if (PCtlInfo <> nil) then
+ GlobalSharedLockedFree(PCtlinfo^.hMem, PCtlInfo);
+ DeallocateHwnd(Handle);
+ inherited Destroy;
+end;
+
+{-------------------------------------------------------------------}
+{ Convert the numeric return code from an MMSYSTEM function to a string
+ using midioutGetErrorText. TODO: These errors aren't very helpful
+ (e.g. "an invalid parameter was passed to a system function") so
+ some proper error strings would be nice. }
+
+
+function Tmidioutput.midioutErrorString(WError: Word): string;
+var
+ errorDesc: PChar;
+begin
+ errorDesc := nil;
+ try
+ errorDesc := StrAlloc(MAXERRORLENGTH);
+ if midioutGetErrorText(WError, errorDesc, MAXERRORLENGTH) = 0 then
+ result := StrPas(errorDesc)
+ else
+ result := 'Specified error number is out of range';
+ finally
+ if errorDesc <> nil then StrDispose(errorDesc);
+ end;
+end;
+
+{-------------------------------------------------------------------}
+{ Set the output device ID and change the other properties to match }
+
+procedure Tmidioutput.SetDeviceID(DeviceID: Integer);
+var
+ midioutCaps: TmidioutCaps;
+begin
+ if FState = mosOpen then
+ raise EmidioutputError.Create('Change to DeviceID while device was open')
+ else
+ if (DeviceID >= midioutGetNumDevs) and (DeviceID <> MIDI_MAPPER) then
+ raise EmidioutputError.Create('Invalid device ID')
+ else
+ begin
+ FDeviceID := DeviceID;
+
+ { Set the name and other midioutCAPS properties to match the ID }
+ FError :=
+ midioutGetDevCaps(DeviceID, @midioutCaps, sizeof(TmidioutCaps));
+ if Ferror > 0 then
+ raise EmidioutputError.Create(midioutErrorString(FError));
+
+ with midiOutCaps do
+ begin
+ FProductName := StrPas(szPname);
+ FDriverVersion := vDriverVersion;
+ FTechnology := OutPortTech(wTechnology);
+ FVoices := wVoices;
+ FNotes := wNotes;
+ FChannelMask := wChannelMask;
+ FSupport := dwSupport;
+ end;
+
+ end;
+end;
+
+{-------------------------------------------------------------------}
+{ Set the product name property and put the matching output device number
+ in FDeviceID.
+ This is handy if you want to save a configured output/output device
+ by device name instead of device number, because device numbers may
+ change if users install or remove MIDI devices.
+ Exception if output device with matching name not found,
+ or if output device is open }
+
+procedure Tmidioutput.SetProductName(NewProductName: string);
+var
+ midioutCaps: TmidioutCaps;
+ testDeviceID: Integer;
+ testProductName: string;
+begin
+ if FState = mosOpen then
+ raise EmidioutputError.Create('Change to ProductName while device was open')
+ else
+ { Don't set the name if the component is reading properties because
+ the saved Productname will be from the machine the application was compiled
+ on, which may not be the same for the corresponding DeviceID on the user's
+ machine. The FProductname property will still be set by SetDeviceID }
+ if not (csLoading in ComponentState) then
+ begin
+ { Loop uses -1 to test for MIDI_MAPPER as well }
+ for testDeviceID := -1 to (midioutGetNumDevs - 1) do
+ begin
+ FError :=
+ midioutGetDevCaps(testDeviceID, @midioutCaps, sizeof(TmidioutCaps));
+ if Ferror > 0 then
+ raise EmidioutputError.Create(midioutErrorString(FError));
+ testProductName := StrPas(midioutCaps.szPname);
+ if testProductName = NewProductName then
+ begin
+ FProductName := NewProductName;
+ Break;
+ end;
+ end;
+ if FProductName <> NewProductName then
+ raise EmidioutputError.Create('MIDI output Device ' +
+ NewProductName + ' not installed')
+ else
+ SetDeviceID(testDeviceID);
+ end;
+end;
+
+{-------------------------------------------------------------------}
+{ Set the output technology property and put the matching output device
+ number in FDeviceID.
+ This is handy, for example, if you want to be able to switch between a
+ sound card and a MIDI port }
+
+procedure TMidiOutput.SetTechnology(NewTechnology: OutPortTech);
+var
+ midiOutCaps: TMidiOutCaps;
+ testDeviceID: Integer;
+ testTechnology: OutPortTech;
+begin
+ if FState = mosOpen then
+ raise EMidiOutputError.Create(
+ 'Change to Product Technology while device was open')
+ else
+ begin
+ { Loop uses -1 to test for MIDI_MAPPER as well }
+ for testDeviceID := -1 to (midiOutGetNumDevs - 1) do
+ begin
+ FError :=
+ midiOutGetDevCaps(testDeviceID,
+ @midiOutCaps, sizeof(TMidiOutCaps));
+ if Ferror > 0 then
+ raise EMidiOutputError.Create(MidiOutErrorString(FError));
+ testTechnology := OutPortTech(midiOutCaps.wTechnology);
+ if testTechnology = NewTechnology then
+ begin
+ FTechnology := NewTechnology;
+ Break;
+ end;
+ end;
+ if FTechnology <> NewTechnology then
+ raise EMidiOutputError.Create('MIDI output technology ' +
+ TechName[NewTechnology] + ' not installed')
+ else
+ SetDeviceID(testDeviceID);
+ end;
+end;
+
+{-------------------------------------------------------------------}
+
+function Tmidioutput.Open: Boolean;
+var
+ hMem: THandle;
+begin
+ Result := False;
+ try
+ { Create the control info for the DLL }
+ if (PCtlInfo = nil) then
+ begin
+ PCtlInfo := GlobalSharedLockedAlloc(Sizeof(TMidiCtlInfo), hMem);
+ PctlInfo^.hMem := hMem;
+ end;
+
+ Pctlinfo^.hWindow := Handle; { Control's window handle }
+
+ FError := midioutOpen(@FMidiHandle, FDeviceId,
+ DWORD(@midiHandler),
+ DWORD(PCtlInfo),
+ CALLBACK_FUNCTION);
+{ FError := midioutOpen(@FMidiHandle, FDeviceId,
+ Handle,
+ DWORD(PCtlInfo),
+ CALLBACK_WINDOW); }
+ if (FError <> 0) then
+ { TODO: use CreateFmtHelp to add MIDI device name/ID to message }
+ raise EmidioutputError.Create(midioutErrorString(FError))
+ else
+ begin
+ Result := True;
+ FState := mosOpen;
+ end;
+
+ except
+ if PCtlInfo <> nil then
+ begin
+ GlobalSharedLockedFree(PCtlInfo^.hMem, PCtlInfo);
+ PCtlInfo := nil;
+ end;
+ end;
+
+end;
+
+{-------------------------------------------------------------------}
+
+procedure TMidiOutput.PutShort(MidiMessage: Byte; Data1: Byte; Data2: Byte);
+var
+ thisMsg: DWORD;
+begin
+ thisMsg := DWORD(MidiMessage) or
+ (DWORD(Data1) shl 8) or
+ (DWORD(Data2) shl 16);
+
+ FError := midiOutShortMsg(FMidiHandle, thisMsg);
+ if Ferror > 0 then
+ raise EmidioutputError.Create(midioutErrorString(FError));
+end;
+
+{-------------------------------------------------------------------}
+
+procedure TMidiOutput.PutLong(TheSysex: Pointer; msgLength: Word);
+{ Notes: This works asynchronously; you send your sysex output by
+calling this function, which returns immediately. When the MIDI device
+driver has finished sending the data the MidiOutPut function in this
+component is called, which will in turn call the OnMidiOutput method
+if the component user has defined one. }
+{ TODO: Combine common functions with PutTimedLong into subroutine }
+
+var
+ MyMidiHdr: TMyMidiHdr;
+begin
+ { Initialize the header and allocate buffer memory }
+ MyMidiHdr := TMyMidiHdr.Create(msgLength);
+
+ { Copy the data over to the MidiHdr buffer
+ We can't just use the caller's PChar because the buffer memory
+ has to be global, shareable, and locked. }
+ StrMove(MyMidiHdr.SysexPointer, TheSysex, msgLength);
+
+ { Store the MyMidiHdr address in the header so we can find it again quickly
+ (see the MidiOutput proc) }
+ MyMidiHdr.hdrPointer^.dwUser := DWORD(MyMidiHdr);
+
+ { Get MMSYSTEM's blessing for this header }
+ FError := midiOutPrepareHeader(FMidiHandle, MyMidiHdr.hdrPointer,
+ sizeof(TMIDIHDR));
+ if Ferror > 0 then
+ raise EMidiOutputError.Create(MidiOutErrorString(FError));
+
+ { Send it }
+ FError := midiOutLongMsg(FMidiHandle, MyMidiHdr.hdrPointer,
+ sizeof(TMIDIHDR));
+ if Ferror > 0 then
+ raise EMidiOutputError.Create(MidiOutErrorString(FError));
+
+end;
+
+{-------------------------------------------------------------------}
+
+procedure Tmidioutput.PutMidiEvent(theEvent: TMyMidiEvent);
+begin
+ if FState <> mosOpen then
+ raise EMidiOutputError.Create('MIDI Output device not open');
+
+ with theEvent do
+ begin
+ if Sysex = nil then
+ begin
+ PutShort(MidiMessage, Data1, Data2)
+ end
+ else
+ PutLong(Sysex, SysexLength);
+ end;
+end;
+
+{-------------------------------------------------------------------}
+
+function Tmidioutput.Close: Boolean;
+begin
+ Result := False;
+ if FState = mosOpen then
+ begin
+
+ { Note this sends a lot of fast control change messages which some synths can't handle.
+ TODO: Make this optional. }
+{ FError := midioutReset(FMidiHandle);
+ if Ferror <> 0 then
+ raise EMidiOutputError.Create(MidiOutErrorString(FError)); }
+
+ FError := midioutClose(FMidiHandle);
+ if Ferror <> 0 then
+ raise EMidiOutputError.Create(MidiOutErrorString(FError))
+ else
+ Result := True;
+ end;
+
+ FMidiHandle := 0;
+ FState := mosClosed;
+
+end;
+
+{-------------------------------------------------------------------}
+
+procedure TMidiOutput.SetVolume(Left: Word; Right: Word);
+var
+ dwVolume: DWORD;
+begin
+ dwVolume := (DWORD(Left) shl 16) or Right;
+ FError := midiOutSetVolume(DeviceID, dwVolume);
+ if Ferror <> 0 then
+ raise EMidiOutputError.Create(MidiOutErrorString(FError));
+end;
+
+{-------------------------------------------------------------------}
+
+procedure Tmidioutput.midioutput(var Message: TMessage);
+{ Triggered when sysex output from PutLong is complete }
+var
+ MyMidiHdr: TMyMidiHdr;
+ thisHdr: PMidiHdr;
+begin
+ if Message.Msg = Mom_Done then
+ begin
+ { Find the MIDIHDR we used for the output. Message.lParam is its address }
+ thisHdr := PMidiHdr(Message.lParam);
+
+ { Remove it from the output device }
+ midiOutUnprepareHeader(FMidiHandle, thisHdr, sizeof(TMIDIHDR));
+
+ { Get the address of the MyMidiHdr object containing this MIDIHDR structure.
+ We stored this address in the PutLong procedure }
+ MyMidiHdr := TMyMidiHdr(thisHdr^.dwUser);
+
+ { Header and copy of sysex data no longer required since output is complete }
+ MyMidiHdr.Free;
+
+ { Call the user's event handler if any }
+ if Assigned(FOnmidioutput) then
+ FOnmidioutput(Self);
+ end;
+ { TODO: Case for MOM_PLAYBACK_DONE }
+end;
+
+{-------------------------------------------------------------------}
+
+procedure Register;
+begin
+ RegisterComponents('Synth', [Tmidioutput]);
+end;
+
+end.
+
diff --git a/Game/Code/lib/midi/demo/MidiTest.dfm b/Game/Code/lib/midi/demo/MidiTest.dfm Binary files differnew file mode 100644 index 00000000..0d0ae182 --- /dev/null +++ b/Game/Code/lib/midi/demo/MidiTest.dfm diff --git a/Game/Code/lib/midi/demo/MidiTest.pas b/Game/Code/lib/midi/demo/MidiTest.pas new file mode 100644 index 00000000..0cf3e302 --- /dev/null +++ b/Game/Code/lib/midi/demo/MidiTest.pas @@ -0,0 +1,249 @@ +// Test application for TMidiFile
+
+unit MidiTest;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
+ StdCtrls, MidiFile, ExtCtrls, MidiOut, MidiType, MidiScope, Grids;
+type
+ TMidiPlayer = class(TForm)
+ OpenDialog1: TOpenDialog;
+ Button1: TButton;
+ Button3: TButton;
+ Button4: TButton;
+ MidiOutput1: TMidiOutput;
+ cmbInput: TComboBox;
+ MidiFile1: TMidiFile;
+ MidiScope1: TMidiScope;
+ Label3: TLabel;
+ edtBpm: TEdit;
+ Memo2: TMemo;
+ edtTime: TEdit;
+ Button2: TButton;
+ TrackGrid: TStringGrid;
+ TracksGrid: TStringGrid;
+ edtLength: TEdit;
+ procedure Button1Click(Sender: TObject);
+ procedure MidiFile1MidiEvent(event: PMidiEvent);
+ procedure Button3Click(Sender: TObject);
+ procedure Button4Click(Sender: TObject);
+ procedure FormCreate(Sender: TObject);
+ procedure cmbInputChange(Sender: TObject);
+ procedure MidiFile1UpdateEvent(Sender: TObject);
+ procedure Button2Click(Sender: TObject);
+ procedure edtBpmKeyPress(Sender: TObject; var Key: Char);
+ procedure TracksGridSelectCell(Sender: TObject; Col, Row: Integer;
+ var CanSelect: Boolean);
+ procedure FormShow(Sender: TObject);
+ private
+ { Private declarations }
+ MidiOpened : boolean;
+ procedure SentAllNotesOff;
+
+ procedure MidiOpen;
+ procedure MidiClose;
+
+ public
+ { Public declarations }
+ end;
+
+var
+ MidiPlayer: TMidiPlayer;
+
+implementation
+
+{$R *.DFM}
+
+procedure TMidiPlayer.Button1Click(Sender: TObject);
+var
+ i,j: integer;
+ track : TMidiTrack;
+ event : PMidiEvent;
+begin
+ if opendialog1.execute then
+ begin
+ midifile1.filename := opendialog1.filename;
+ midifile1.readfile;
+// label1.caption := IntToStr(midifile1.NumberOfTracks);
+ edtBpm.text := IntToStr(midifile1.Bpm);
+// TracksGrid.cells.clear;
+ for i := 0 to midifile1.NumberOfTracks-1 do
+ begin
+ track := midifile1.getTrack(i);
+ TracksGrid.cells[0,i] := 'Tr: '+ track.getName + ' '+ track.getInstrument ;
+ end;
+ edtLength.Text := MyTimeToStr(MidiFile1.GetTrackLength);
+ end;
+end;
+
+procedure TMidiPlayer.MidiFile1MidiEvent(event: PMidiEvent);
+var mEvent : TMyMidiEvent;
+begin
+ mEvent := TMyMidiEvent.Create;
+ if not (event.event = $FF) then
+ begin
+ mEvent.MidiMessage := event.event;
+ mEvent.data1 := event.data1;
+ mEvent.data2 := event.data2;
+ midioutput1.PutMidiEvent(mEvent);
+ end
+ else
+ begin
+ if (event.data1 >= 1) and (event.data1 < 15) then
+ begin
+ memo2.Lines.add(IntToStr(event.data1) + ' '+ event.str);
+ end
+ end;
+ midiScope1.MidiEvent(event.event,event.data1,event.data2);
+ mEvent.Destroy;
+end;
+
+procedure TMidiPlayer.SentAllNotesOff;
+var mEvent : TMyMidiEvent;
+channel : integer;
+begin
+ mEvent := TMyMidiEvent.Create;
+ for channel:= 0 to 15 do
+ begin
+ mEvent.MidiMessage := $B0 + channel;
+ mEvent.data1 := $78;
+ mEvent.data2 := 0;
+ if MidiOpened then
+ midioutput1.PutMidiEvent(mEvent);
+ midiScope1.MidiEvent(mEvent.MidiMessage,mEvent.data1,mEvent.data2);
+ end;
+ mEvent.Destroy;
+end;
+
+procedure TMidiPlayer.Button3Click(Sender: TObject);
+begin
+ midifile1.StartPlaying;
+end;
+
+procedure TMidiPlayer.Button4Click(Sender: TObject);
+begin
+ midifile1.StopPlaying;
+ SentAllNotesOff;
+end;
+
+procedure TMidiPlayer.MidiOpen;
+begin
+ if not (cmbInput.Text = '') then
+ begin
+ MidiOutput1.ProductName := cmbInput.Text;
+ MidiOutput1.OPEN;
+ MidiOpened := true;
+ end;
+end;
+
+procedure TMidiPlayer.MidiClose;
+begin
+ if MidiOpened then
+ begin
+ MidiOutput1.Close;
+ MidiOpened := false;
+ end;
+end;
+
+
+procedure TMidiPlayer.FormCreate(Sender: TObject);
+var thisDevice : integer;
+begin
+ for thisDevice := 0 to MidiOutput1.NumDevs - 1 do
+ begin
+ MidiOutput1.DeviceID := thisDevice;
+ cmbInput.Items.Add(MidiOutput1.ProductName);
+ end;
+ cmbInput.ItemIndex := 0;
+ MidiOpened := false;
+ MidiOpen;
+end;
+
+procedure TMidiPlayer.cmbInputChange(Sender: TObject);
+begin
+ MidiClose;
+ MidiOPen;
+end;
+
+procedure TMidiPlayer.MidiFile1UpdateEvent(Sender: TObject);
+begin
+ edtTime.Text := MyTimeToStr(MidiFile1.GetCurrentTime);
+ edtTime.update;
+ if MidiFile1.ready then
+ begin
+ midifile1.StopPlaying;
+ SentAllNotesOff;
+ end;
+end;
+
+procedure TMidiPlayer.Button2Click(Sender: TObject);
+begin
+ MidiFile1.ContinuePlaying;
+end;
+
+procedure TMidiPlayer.edtBpmKeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key = char(13) then
+ begin
+ MidiFile1.Bpm := StrToInt(edtBpm.Text);
+ edtBpm.text := IntToStr(midifile1.Bpm);
+ abort;
+ end;
+
+end;
+
+procedure TMidiPlayer.TracksGridSelectCell(Sender: TObject; Col,
+ Row: Integer; var CanSelect: Boolean);
+var
+ MidiTrack : TMidiTrack;
+ i : integer;
+ j : integer;
+ event : PMidiEvent;
+begin
+ CanSelect := false;
+ if Row < MidiFile1.NumberOfTracks then
+ begin
+ CanSelect := true;
+ MidiTrack := MidiFile1.GetTrack(Row);
+ TrackGrid.RowCount := 2;
+ TrackGrid.RowCount := MidiTrack.getEventCount;
+ j := 1;
+ for i := 0 to MidiTrack.GetEventCount-1 do
+ begin
+ event := MidiTrack.getEvent(i);
+ if not (event.len = -1) then
+ begin // do not print when
+ TrackGrid.cells[0,j] := IntToStr(i);
+ TrackGrid.cells[1,j] := MyTimeToStr(event.time);
+ TrackGrid.cells[2,j] := IntToHex(event.event,2);
+ if not (event.event = $FF) then
+ begin
+ TrackGrid.cells[3,j] := IntToStr(event.len);
+ TrackGrid.cells[4,j] := KeyToStr(event.data1);
+ TrackGrid.cells[5,j] := IntToStr(event.data2);
+ end
+ else
+ begin
+ TrackGrid.cells[3,j] := IntToStr(event.data1);
+ TrackGrid.cells[4,j] := '';
+ TrackGrid.cells[5,j] := event.str;
+ end;
+ inc(j);
+ end;
+ end;
+ TrackGrid.RowCount := j;
+ end;
+end;
+
+procedure TMidiPlayer.FormShow(Sender: TObject);
+begin
+ TrackGrid.ColWidths[0] := 30;
+ TrackGrid.ColWidths[2] := 30;
+ TrackGrid.ColWidths[3] := 30;
+ TrackGrid.ColWidths[4] := 30;
+ TrackGrid.ColWidths[5] := 100;
+end;
+
+end.
diff --git a/Game/Code/lib/midi/demo/Project1.dpr b/Game/Code/lib/midi/demo/Project1.dpr new file mode 100644 index 00000000..4237e983 --- /dev/null +++ b/Game/Code/lib/midi/demo/Project1.dpr @@ -0,0 +1,13 @@ +program Project1;
+
+uses
+ Forms,
+ MidiTest in 'MidiTest.pas' {MidiPlayer};
+
+{$R *.RES}
+
+begin
+ Application.Initialize;
+ Application.CreateForm(TMidiPlayer, MidiPlayer);
+ Application.Run;
+end.
diff --git a/Game/Code/lib/midi/demo/Project1.res b/Game/Code/lib/midi/demo/Project1.res Binary files differnew file mode 100644 index 00000000..2b020d69 --- /dev/null +++ b/Game/Code/lib/midi/demo/Project1.res diff --git a/Game/Code/lib/midi/midiComp.cfg b/Game/Code/lib/midi/midiComp.cfg new file mode 100644 index 00000000..2ee4ea3a --- /dev/null +++ b/Game/Code/lib/midi/midiComp.cfg @@ -0,0 +1,35 @@ +-$A+
+-$B-
+-$C+
+-$D+
+-$E-
+-$F-
+-$G+
+-$H+
+-$I+
+-$J+
+-$K-
+-$L+
+-$M-
+-$N+
+-$O+
+-$P+
+-$Q-
+-$R-
+-$S-
+-$T-
+-$U-
+-$V+
+-$W-
+-$X+
+-$Y-
+-$Z1
+-cg
+-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+-H+
+-W+
+-M
+-$M16384,1048576
+-K$00400000
+-LE"d:\program files\borland\delphi5\Projects\Bpl"
+-LN"d:\program files\borland\delphi5\Projects\Bpl"
diff --git a/Game/Code/lib/midi/midiComp.dpk b/Game/Code/lib/midi/midiComp.dpk new file mode 100644 index 00000000..7c403eae --- /dev/null +++ b/Game/Code/lib/midi/midiComp.dpk @@ -0,0 +1,45 @@ +package midiComp;
+
+{$R *.RES}
+{$R 'MidiFile.dcr'}
+{$R 'Midiin.dcr'}
+{$R 'Midiout.dcr'}
+{$R 'MidiScope.dcr'}
+{$ALIGN ON}
+{$ASSERTIONS ON}
+{$BOOLEVAL OFF}
+{$DEBUGINFO ON}
+{$EXTENDEDSYNTAX ON}
+{$IMPORTEDDATA ON}
+{$IOCHECKS ON}
+{$LOCALSYMBOLS ON}
+{$LONGSTRINGS ON}
+{$OPENSTRINGS ON}
+{$OPTIMIZATION ON}
+{$OVERFLOWCHECKS OFF}
+{$RANGECHECKS OFF}
+{$REFERENCEINFO OFF}
+{$SAFEDIVIDE OFF}
+{$STACKFRAMES OFF}
+{$TYPEDADDRESS OFF}
+{$VARSTRINGCHECKS ON}
+{$WRITEABLECONST ON}
+{$MINENUMSIZE 1}
+{$IMAGEBASE $400000}
+{$DESCRIPTION 'Midi related components'}
+{$DESIGNONLY}
+{$IMPLICITBUILD ON}
+
+requires
+ vcl50;
+
+contains
+ Miditype in 'Miditype.pas',
+ Mididefs in 'Mididefs.pas',
+ MidiFile in 'MidiFile.pas',
+ Midiin in 'Midiin.pas',
+ Midiout in 'Midiout.pas',
+ MidiScope in 'MidiScope.pas',
+ Midicons in 'Midicons.pas';
+
+end.
diff --git a/Game/Code/lib/midi/midiComp.res b/Game/Code/lib/midi/midiComp.res Binary files differnew file mode 100644 index 00000000..91fb756e --- /dev/null +++ b/Game/Code/lib/midi/midiComp.res diff --git a/Game/Code/lib/midi/readme.txt b/Game/Code/lib/midi/readme.txt new file mode 100644 index 00000000..5e4207f6 --- /dev/null +++ b/Game/Code/lib/midi/readme.txt @@ -0,0 +1,60 @@ +
+Midi components
+ TMidiFile, TMidiScope
+ TMidiIn and TMidiOut of david Churcher are included because they are used in
+ the demo application
+
+Freeware.
+
+100% source code, demo application.
+
+Included Components/Classes
+
+TMidiFile, read a midifile and have the contents available in memory
+ list of Tracks, track is list of events
+
+
+TMidiScope, show all activity on a midi device
+
+TMidiIn and TMidiOut of David Churcher are included because they are used
+in the demo application
+
+Midiplayer is a demo application which plays a midifile on a midi output
+ it is build fairly simple with the included components. The timer is used
+ to time the midievents. The timing is therefor as good as the windows timer.
+
+
+ The header of midifile,midiscope contains help information on the properties/functions
+ The example Midiplayer gives a good idea how to use the components
+
+Installation
+ open midiComp.dpk with file/open
+ compile and install the package
+ make sure that the directory where the files are located is in the library path
+ (tools/environment options/library)
+
+to run the demo
+ open project1.dpr in the demo directory and press run.
+
+
+
+history
+1.0 18-1-1999 first release
+
+1.1 5-3-1999 update
+ added some functions for display purposes
+ improved demo to include event viewer
+ bpm can be changed
+
+1.2 24-2-2000 update
+ added some functions to see the length of a song and ready function to know when playback is ready
+
+for comments/bugs in these components:
+
+Frans Bouwmans
+fbouwmans@spiditel.nl
+
+I'm busy building a software music synthesizer, which will be available in source
+to the public. If you are interrested in helping me with certain soundmodules
+(effects, filters, sound generators) just sent me an email.
+
diff --git a/Game/Code/lib/other/DirWatch.pas b/Game/Code/lib/other/DirWatch.pas new file mode 100644 index 00000000..b14fa791 --- /dev/null +++ b/Game/Code/lib/other/DirWatch.pas @@ -0,0 +1,346 @@ +unit DirWatch;
+
+// -----------------------------------------------------------------------------
+// Component Name: TDirectoryWatch .
+// Module: DirWatch .
+// Description: Implements watching for file changes in a designated .
+// directory (or directories). .
+// Version: 1.4 .
+// Date: 10-MAR-2003 .
+// Target: Win32, Delphi 3 - Delphi 7 .
+// Author: Angus Johnson, angusj-AT-myrealbox-DOT-com .
+// A portion of code has been copied from the Drag & Drop .
+// Component Suite which I co-authored with Anders Melander. .
+// Copyright: © 2003 Angus Johnson .
+// .
+// Usage: 1. Add a TDirectoryWatch component to your form. .
+// 2. Set its Directory property .
+// 3. If you wish to watch its subdirectories too then set .
+// the WatchSubDir property to true .
+// 4. Assign the OnChange event .
+// 5. Set Active to true .
+// -----------------------------------------------------------------------------
+
+interface
+
+{$IFDEF FPC}
+ {$MODE Delphi}
+{$ENDIF}
+
+uses
+ Windows,
+ Messages,
+ SysUtils,
+ {$IFDEF LCL}
+ LCLIntf, // used for AllocateHWnd
+ {$ELSE}
+ Forms,
+ {$ENDIF}
+ Classes;
+
+type
+ TNotifyFilters = set of (nfFilename, nfDirname, nfAttrib,
+ nfSize, nfLastWrite, nfSecurity);
+
+ TWatchThread = class; //forward declaration
+
+ TDirectoryWatch = class(TComponent)
+ private
+ fWindowHandle: THandle;
+ fWatchThread: TWatchThread;
+ fWatchSubDirs: boolean;
+ fDirectory: string;
+ fActive: boolean;
+ fNotifyFilters: TNotifyFilters; //see FindFirstChangeNotification in winAPI
+ fOnChangeEvent: TNotifyEvent;
+ procedure SetActive(aActive: boolean);
+ procedure SetDirectory(aDir: string);
+ procedure SetWatchSubDirs(aWatchSubDirs: boolean);
+ procedure SetNotifyFilters(aNotifyFilters: TNotifyFilters);
+ procedure WndProc(var aMsg: TMessage);
+ public
+ constructor Create(aOwner: TComponent); override;
+ destructor Destroy; override;
+ published
+ property Directory: string read fDirectory write SetDirectory;
+ property NotifyFilters: TNotifyFilters
+ read fNotifyFilters write SetNotifyFilters;
+ property WatchSubDirs: boolean read fWatchSubDirs write SetWatchSubDirs;
+ property Active: boolean read fActive write SetActive;
+ property OnChange: TNotifyEvent read fOnChangeEvent write fOnChangeEvent;
+ end;
+
+ TWatchThread = class(TThread)
+ private
+ fOwnerHdl: Thandle;
+ fChangeNotify : THandle; //Signals whenever Windows detects a change in .
+ //the watched directory .
+ fBreakEvent: THandle; //Signals when either the Directory property .
+ //changes or when the thread terminates .
+ fDirectory: string;
+ fWatchSubDirs: longbool;
+ fNotifyFilters: dword;
+ fFinished: boolean;
+ protected
+ procedure SetDirectory(const Value: string);
+ procedure ProcessFilenameChanges;
+ procedure Execute; override;
+ public
+ constructor Create( OwnerHdl: THandle;
+ const InitialDir: string; WatchSubDirs: boolean; NotifyFilters: dword);
+ destructor Destroy; override;
+ procedure Terminate;
+ property Directory: string write SetDirectory;
+ end;
+
+procedure Register;
+
+implementation
+
+const
+ NOTIFYCHANGE_MESSAGE = WM_USER + 1;
+
+resourcestring
+ sInvalidDir = 'Invalid Directory: ';
+
+//----------------------------------------------------------------------------
+// Miscellaneous functions ...
+//----------------------------------------------------------------------------
+
+procedure Register;
+begin
+ RegisterComponents('Samples', [TDirectoryWatch]);
+end;
+//----------------------------------------------------------------------------
+
+function DirectoryExists(const Name: string): Boolean;
+var
+ Code: Integer;
+begin
+ Code := GetFileAttributes(PChar(Name));
+ Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0);
+end;
+
+//----------------------------------------------------------------------------
+// TDirectoryWatch methods ...
+//----------------------------------------------------------------------------
+
+constructor TDirectoryWatch.Create(aOwner: TComponent);
+begin
+ inherited Create(aOwner);
+ //default Notify values - notify if either a file name or a directory name
+ //changes or if a file is modified ...
+ fNotifyFilters := [nfFilename, nfDirname, nfLastWrite];
+ fDirectory := 'C:\';
+ //this non-visual control needs to handle messages, so ...
+ if not (csDesigning in ComponentState) then
+ fWindowHandle := AllocateHWnd(WndProc);
+end;
+//----------------------------------------------------------------------------
+
+destructor TDirectoryWatch.Destroy;
+begin
+ Active := false;
+ if not (csDesigning in ComponentState) then
+ DeallocateHWnd(fWindowHandle);
+ inherited Destroy;
+end;
+//----------------------------------------------------------------------------
+
+procedure TDirectoryWatch.WndProc(var aMsg: TMessage);
+begin
+ with aMsg do
+ if Msg = NOTIFYCHANGE_MESSAGE then
+ begin
+ if assigned(OnChange) then OnChange(self);
+ end else
+ Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);
+end;
+//------------------------------------------------------------------------------
+
+procedure TDirectoryWatch.SetNotifyFilters(aNotifyFilters: TNotifyFilters);
+begin
+ if aNotifyFilters = fNotifyFilters then exit;
+ fNotifyFilters := aNotifyFilters;
+ if assigned(fWatchThread) then
+ begin
+ Active := false;
+ Active := true;
+ end;
+end;
+//------------------------------------------------------------------------------
+
+procedure TDirectoryWatch.SetWatchSubDirs(aWatchSubDirs: boolean);
+begin
+ if aWatchSubDirs = fWatchSubDirs then exit;
+ fWatchSubDirs := aWatchSubDirs;
+ if assigned(fWatchThread) then
+ begin
+ Active := false;
+ Active := true;
+ end;
+end;
+//------------------------------------------------------------------------------
+
+procedure TDirectoryWatch.SetDirectory(aDir: string);
+begin
+ if aDir = '' then
+ begin
+ Active := false;
+ fDirectory := '';
+ exit;
+ end;
+ if (aDir[length(aDir)] <> '\') then aDir := aDir + '\';
+ if aDir = fDirectory then exit;
+ if not (csDesigning in ComponentState) and not DirectoryExists(aDir) then
+ raise Exception.Create( sInvalidDir + aDir);
+ fDirectory := aDir;
+ if assigned(fWatchThread) then
+ fWatchThread.Directory := fDirectory;
+end;
+//------------------------------------------------------------------------------
+
+procedure TDirectoryWatch.SetActive(aActive: boolean);
+var
+ nf: dword;
+begin
+ if aActive = fActive then exit;
+ fActive := aActive;
+ if csDesigning in ComponentState then exit;
+ if fActive then
+ begin
+ if not DirectoryExists(fDirectory) then
+ begin
+ fActive := false;
+ raise Exception.Create(sInvalidDir + fDirectory);
+ end;
+ nf := 0;
+ if nfFilename in fNotifyFilters then
+ nf := nf or FILE_NOTIFY_CHANGE_FILE_NAME;
+ if nfDirname in fNotifyFilters then
+ nf := nf or FILE_NOTIFY_CHANGE_DIR_NAME;
+ if nfAttrib in fNotifyFilters then
+ nf := nf or FILE_NOTIFY_CHANGE_ATTRIBUTES;
+ if nfSize in fNotifyFilters then
+ nf := nf or FILE_NOTIFY_CHANGE_SIZE;
+ if nfLastWrite in fNotifyFilters then
+ nf := nf or FILE_NOTIFY_CHANGE_LAST_WRITE;
+ if nfSecurity in fNotifyFilters then
+ nf := nf or FILE_NOTIFY_CHANGE_SECURITY;
+ fWatchThread := TWatchThread.Create(
+ fWindowHandle, fDirectory, fWatchSubDirs, nf);
+ end else
+ begin
+ fWatchThread.Terminate;
+ fWatchThread := nil;
+ end;
+end;
+
+//----------------------------------------------------------------------------
+// TWatchThread methods ...
+//----------------------------------------------------------------------------
+
+constructor TWatchThread.Create(OwnerHdl: THandle;
+ const InitialDir: string; WatchSubDirs: boolean; NotifyFilters: dword);
+begin
+ inherited Create(True);
+ fOwnerHdl := OwnerHdl;
+ if WatchSubDirs then
+ cardinal(fWatchSubDirs) := 1 //workaround a Win9x OS issue
+ else
+ fWatchSubDirs := false;
+ FreeOnTerminate := true;
+ Priority := tpLowest;
+ fDirectory := InitialDir;
+ fNotifyFilters := NotifyFilters;
+ fBreakEvent := windows.CreateEvent(nil, False, False, nil);
+ Resume;
+end;
+//------------------------------------------------------------------------------
+
+destructor TWatchThread.Destroy;
+begin
+ CloseHandle(fBreakEvent);
+ inherited Destroy;
+end;
+//------------------------------------------------------------------------------
+
+procedure TWatchThread.SetDirectory(const Value: string);
+begin
+ if (Value = FDirectory) then exit;
+ FDirectory := Value;
+ SetEvent(fBreakEvent);
+end;
+//------------------------------------------------------------------------------
+
+procedure TWatchThread.Terminate;
+begin
+ inherited Terminate;
+ SetEvent(fBreakEvent);
+ while not fFinished do sleep(10); //avoids a reported resource leak
+ //if called while closing the application.
+end;
+//------------------------------------------------------------------------------
+
+procedure TWatchThread.Execute;
+begin
+ //OUTER LOOP - manages Directory property reassignments
+ while (not Terminated) do
+ begin
+ fChangeNotify := FindFirstChangeNotification(pchar(fDirectory),
+ fWatchSubDirs, fNotifyFilters);
+ if (fChangeNotify = INVALID_HANDLE_VALUE) then
+ //Can't monitor the specified directory so we'll just wait for
+ //a new Directory assignment or the thread terminating ...
+ WaitForSingleObject(fBreakEvent, INFINITE)
+ else
+ try
+ //Now do the INNER loop...
+ ProcessFilenameChanges;
+ finally
+ FindCloseChangeNotification(fChangeNotify);
+ end;
+ end;
+ fFinished := true;
+end;
+//------------------------------------------------------------------------------
+
+procedure TWatchThread.ProcessFilenameChanges;
+var
+ WaitResult : DWORD;
+ HandleArray : array[0..1] of THandle;
+const
+ TEN_MSECS = 10;
+ HUNDRED_MSECS = 100;
+begin
+ HandleArray[0] := fBreakEvent;
+ HandleArray[1] := fChangeNotify;
+ //INNER LOOP - exits only when fBreakEvent signaled
+ while (not Terminated) do
+ begin
+ //waits for either fChangeNotify or fBreakEvent ...
+ WaitResult := WaitForMultipleObjects(2, @HandleArray, False, INFINITE);
+ if (WaitResult = WAIT_OBJECT_0 + 1) then //fChangeNotify
+ begin
+ repeat //ie: if a number of files are changing in a block
+ //just post the one notification message ...
+ FindNextChangeNotification(fChangeNotify);
+ until Terminated or
+ (WaitForSingleObject(fChangeNotify, TEN_MSECS) <> WAIT_OBJECT_0);
+ if Terminated then break;
+ //OK, now notify the main thread (before restarting inner loop)...
+ PostMessage(fOwnerHdl, NOTIFYCHANGE_MESSAGE, 0, 0);
+ end else //fBreakEvent ...
+ begin
+ //If the Directory property is undergoing multiple rapid reassignments
+ //wait 'til this stops before restarting monitoring of a new directory ...
+ while (not Terminated) and
+ (WaitForSingleObject(fBreakEvent, HUNDRED_MSECS) = WAIT_OBJECT_0) do;
+ break; //EXIT LOOP HERE
+ end;
+ end;
+end;
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+end.
\ No newline at end of file diff --git a/Game/Code/lib/portaudio/delphi/portaudio.pas b/Game/Code/lib/portaudio/delphi/portaudio.pas new file mode 100644 index 00000000..31f9ee3a --- /dev/null +++ b/Game/Code/lib/portaudio/delphi/portaudio.pas @@ -0,0 +1,1159 @@ +{*
+ * $Id: portaudio.h,v 1.7 2007/08/16 20:45:34 richardash1981 Exp $
+ * PortAudio Portable Real-Time Audio Library
+ * PortAudio API Header File
+ * Latest version available at: http://www.portaudio.com/
+ *
+ * Copyright (c) 1999-2002 Ross Bencina and Phil Burk
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *}
+
+{*
+ * The text above constitutes the entire PortAudio license; however,
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
+ * license above.
+ *}
+
+{** @file
+ @brief The PortAudio API.
+*}
+
+unit portaudio;
+
+{$IFDEF FPC}
+ {$IFNDEF win32}
+ {$LINKLIB libportaudio}
+ {$ENDIF}
+ {$PACKRECORDS C} (* GCC/Visual C/C++ compatible record packing *)
+ {$MODE DELPHI }
+{$ENDIF}
+
+interface
+
+//uses;
+
+const
+{$IFDEF WIN32}
+ LibName = 'portaudio_x86.dll';
+{$ENDIF}
+{$IFDEF LINUX}
+ LibName = 'libportaudio.so';
+{$ENDIF}
+{$IFDEF DARWIN}
+ LibName = 'libportaudio.dylib';
+{$ENDIF}
+
+{** Retrieve the release number of the currently running PortAudio build,
+ eg 1900.
+*}
+function Pa_GetVersion(): Integer; cdecl; external LibName;
+
+
+{** Retrieve a textual description of the current PortAudio build,
+ eg "PortAudio V19-devel 13 October 2002".
+*}
+function Pa_GetVersionText(): PChar; cdecl; external LibName;
+
+
+{** Error codes returned by PortAudio functions.
+ Note that with the exception of paNoError, all PaErrorCodes are negative.
+*}
+
+type TPaError = Integer;
+type TPaErrorCode = {enum}Integer; const
+{enum_begin PaErrorCode}
+ paNoError = 0;
+
+ paNotInitialized = -10000;
+ paUnanticipatedHostError = (paNotInitialized+ 1);
+ paInvalidChannelCount = (paNotInitialized+ 2);
+ paInvalidSampleRate = (paNotInitialized+ 3);
+ paInvalidDevice = (paNotInitialized+ 4);
+ paInvalidFlag = (paNotInitialized+ 5);
+ paSampleFormatNotSupported = (paNotInitialized+ 6);
+ paBadIODeviceCombination = (paNotInitialized+ 7);
+ paInsufficientMemory = (paNotInitialized+ 8);
+ paBufferTooBig = (paNotInitialized+ 9);
+ paBufferTooSmall = (paNotInitialized+10);
+ paNullCallback = (paNotInitialized+11);
+ paBadStreamPtr = (paNotInitialized+12);
+ paTimedOut = (paNotInitialized+13);
+ paInternalError = (paNotInitialized+14);
+ paDeviceUnavailable = (paNotInitialized+15);
+ paIncompatibleHostApiSpecificStreamInfo = (paNotInitialized+16);
+ paStreamIsStopped = (paNotInitialized+17);
+ paStreamIsNotStopped = (paNotInitialized+18);
+ paInputOverflowed = (paNotInitialized+19);
+ paOutputUnderflowed = (paNotInitialized+20);
+ paHostApiNotFound = (paNotInitialized+21);
+ paInvalidHostApi = (paNotInitialized+22);
+ paCanNotReadFromACallbackStream = (paNotInitialized+23); {**< @todo review error code name *}
+ paCanNotWriteToACallbackStream = (paNotInitialized+24); {**< @todo review error code name *}
+ paCanNotReadFromAnOutputOnlyStream = (paNotInitialized+25); {**< @todo review error code name *}
+ paCanNotWriteToAnInputOnlyStream = (paNotInitialized+26); {**< @todo review error code name *}
+ paIncompatibleStreamHostApi = (paNotInitialized+27);
+ paBadBufferPtr = (paNotInitialized+28);
+{enum_end PaErrorCode}
+
+
+{** Translate the supplied PortAudio error code into a human readable
+ message.
+*}
+function Pa_GetErrorText( errorCode: TPaError ): PChar; cdecl; external LibName;
+
+
+{** Library initialization function - call this before using PortAudio.
+ This function initialises internal data structures and prepares underlying
+ host APIs for use. With the exception of Pa_GetVersion(), Pa_GetVersionText(),
+ and Pa_GetErrorText(), this function MUST be called before using any other
+ PortAudio API functions.
+
+ If Pa_Initialize() is called multiple times, each successful
+ call must be matched with a corresponding call to Pa_Terminate().
+ Pairs of calls to Pa_Initialize()/Pa_Terminate() may overlap, and are not
+ required to be fully nested.
+
+ Note that if Pa_Initialize() returns an error code, Pa_Terminate() should
+ NOT be called.
+
+ @return paNoError if successful, otherwise an error code indicating the cause
+ of failure.
+
+ @see Pa_Terminate
+*}
+function Pa_Initialize(): TPaError; cdecl; external LibName;
+
+
+{** Library termination function - call this when finished using PortAudio.
+ This function deallocates all resources allocated by PortAudio since it was
+ initializied by a call to Pa_Initialize(). In cases where Pa_Initialise() has
+ been called multiple times, each call must be matched with a corresponding call
+ to Pa_Terminate(). The final matching call to Pa_Terminate() will automatically
+ close any PortAudio streams that are still open.
+
+ Pa_Terminate() MUST be called before exiting a program which uses PortAudio.
+ Failure to do so may result in serious resource leaks, such as audio devices
+ not being available until the next reboot.
+
+ @return paNoError if successful, otherwise an error code indicating the cause
+ of failure.
+
+ @see Pa_Initialize
+*}
+function Pa_Terminate(): TPaError; cdecl; external LibName;
+
+
+
+{** The type used to refer to audio devices. Values of this type usually
+ range from 0 to (Pa_GetDeviceCount()-1), and may also take on the PaNoDevice
+ and paUseHostApiSpecificDeviceSpecification values.
+
+ @see Pa_GetDeviceCount, paNoDevice, paUseHostApiSpecificDeviceSpecification
+*}
+type TPaDeviceIndex = Integer;
+
+
+{** A special PaDeviceIndex value indicating that no device is available,
+ or should be used.
+
+ @see PaDeviceIndex
+*}
+const paNoDevice = TPaDeviceIndex(-1);
+
+
+{** A special PaDeviceIndex value indicating that the device(s) to be used
+ are specified in the host api specific stream info structure.
+
+ @see PaDeviceIndex
+*}
+const paUseHostApiSpecificDeviceSpecification = TPaDeviceIndex(-2);
+
+
+{* Host API enumeration mechanism *}
+
+{** The type used to enumerate to host APIs at runtime. Values of this type
+ range from 0 to (Pa_GetHostApiCount()-1).
+
+ @see Pa_GetHostApiCount
+*}
+type TPaHostApiIndex = Integer;
+
+{** Retrieve the number of available host APIs. Even if a host API is
+ available it may have no devices available.
+
+ @return A non-negative value indicating the number of available host APIs
+ or, a PaErrorCode (which are always negative) if PortAudio is not initialized
+ or an error is encountered.
+
+ @see PaHostApiIndex
+*}
+function Pa_GetHostApiCount(): TPaHostApiIndex; cdecl; external LibName;
+
+
+{** Retrieve the index of the default host API. The default host API will be
+ the lowest common denominator host API on the current platform and is
+ unlikely to provide the best performance.
+
+ @return A non-negative value ranging from 0 to (Pa_GetHostApiCount()-1)
+ indicating the default host API index or, a PaErrorCode (which are always
+ negative) if PortAudio is not initialized or an error is encountered.
+*}
+function Pa_GetDefaultHostApi(): TPaHostApiIndex; cdecl; external LibName;
+
+
+{** Unchanging unique identifiers for each supported host API. This type
+ is used in the PaHostApiInfo structure. The values are guaranteed to be
+ unique and to never change, thus allowing code to be written that
+ conditionally uses host API specific extensions.
+
+ New type ids will be allocated when support for a host API reaches
+ "public alpha" status, prior to that developers should use the
+ paInDevelopment type id.
+
+ @see PaHostApiInfo
+*}
+type TPaHostApiTypeId = {enum}Integer; const
+{enum_begin PaHostApiTypeId}
+ paInDevelopment=0; {* use while developing support for a new host API *}
+ paDirectSound=1;
+ paMME=2;
+ paASIO=3;
+ paSoundManager=4;
+ paCoreAudio=5;
+ paOSS=7;
+ paALSA=8;
+ paAL=9;
+ paBeOS=10;
+ paWDMKS=11;
+ paJACK=12;
+ paWASAPI=13;
+ paAudioScienceHPI=14;
+{enum_end PaHostApiTypeId}
+
+{** A structure containing information about a particular host API. *}
+
+type
+ PPaHostApiInfo = ^TPaHostApiInfo;
+ TPaHostApiInfo = record
+ {** this is struct version 1 *}
+ structVersion: Integer;
+ {** The well known unique identifier of this host API @see PaHostApiTypeId *}
+ _type: TPaHostApiTypeId;
+ {** A textual description of the host API for display on user interfaces. *}
+ name: PChar;
+
+ {** The number of devices belonging to this host API. This field may be
+ used in conjunction with Pa_HostApiDeviceIndexToDeviceIndex() to enumerate
+ all devices for this host API.
+ @see Pa_HostApiDeviceIndexToDeviceIndex
+ *}
+ deviceCount: Integer;
+
+ {** The default input device for this host API. The value will be a
+ device index ranging from 0 to (Pa_GetDeviceCount()-1), or paNoDevice
+ if no default input device is available.
+ *}
+ defaultInputDevice: TPaDeviceIndex;
+
+ {** The default output device for this host API. The value will be a
+ device index ranging from 0 to (Pa_GetDeviceCount()-1), or paNoDevice
+ if no default output device is available.
+ *}
+ defaultOutputDevice: TPaDeviceIndex;
+ end;
+
+
+{** Retrieve a pointer to a structure containing information about a specific
+ host Api.
+
+ @param hostApi A valid host API index ranging from 0 to (Pa_GetHostApiCount()-1)
+
+ @return A pointer to an immutable PaHostApiInfo structure describing
+ a specific host API. If the hostApi parameter is out of range or an error
+ is encountered, the function returns NULL.
+
+ The returned structure is owned by the PortAudio implementation and must not
+ be manipulated or freed. The pointer is only guaranteed to be valid between
+ calls to Pa_Initialize() and Pa_Terminate().
+*}
+function Pa_GetHostApiInfo( hostApi: TPaHostApiIndex ): PPaHostApiInfo; cdecl; external LibName;
+
+
+{** Convert a static host API unique identifier, into a runtime
+ host API index.
+
+ @param type A unique host API identifier belonging to the PaHostApiTypeId
+ enumeration.
+
+ @return A valid PaHostApiIndex ranging from 0 to (Pa_GetHostApiCount()-1) or,
+ a PaErrorCode (which are always negative) if PortAudio is not initialized
+ or an error is encountered.
+
+ The paHostApiNotFound error code indicates that the host API specified by the
+ type parameter is not available.
+
+ @see PaHostApiTypeId
+*}
+function Pa_HostApiTypeIdToHostApiIndex( _type: TPaHostApiTypeId ): TPaHostApiIndex; cdecl; external LibName;
+
+
+{** Convert a host-API-specific device index to standard PortAudio device index.
+ This function may be used in conjunction with the deviceCount field of
+ PaHostApiInfo to enumerate all devices for the specified host API.
+
+ @param hostApi A valid host API index ranging from 0 to (Pa_GetHostApiCount()-1)
+
+ @param hostApiDeviceIndex A valid per-host device index in the range
+ 0 to (Pa_GetHostApiInfo(hostApi)->deviceCount-1)
+
+ @return A non-negative PaDeviceIndex ranging from 0 to (Pa_GetDeviceCount()-1)
+ or, a PaErrorCode (which are always negative) if PortAudio is not initialized
+ or an error is encountered.
+
+ A paInvalidHostApi error code indicates that the host API index specified by
+ the hostApi parameter is out of range.
+
+ A paInvalidDevice error code indicates that the hostApiDeviceIndex parameter
+ is out of range.
+
+ @see PaHostApiInfo
+*}
+function Pa_HostApiDeviceIndexToDeviceIndex( hostApi: TPaHostApiIndex;
+ hostApiDeviceIndex: Integer ): TPaDeviceIndex; cdecl; external LibName;
+
+
+
+{** Structure used to return information about a host error condition.
+*}
+type
+ PPaHostErrorInfo = ^TPaHostErrorInfo;
+ TPaHostErrorInfo = record
+ hostApiType: TPaHostApiTypeId; {**< the host API which returned the error code *}
+ errorCode: Longint; {**< the error code returned *}
+ errorText: PChar; {**< a textual description of the error if available, otherwise a zero-length string *}
+ end;
+
+
+{** Return information about the last host error encountered. The error
+ information returned by Pa_GetLastHostErrorInfo() will never be modified
+ asyncronously by errors occurring in other PortAudio owned threads
+ (such as the thread that manages the stream callback.)
+
+ This function is provided as a last resort, primarily to enhance debugging
+ by providing clients with access to all available error information.
+
+ @return A pointer to an immutable structure constaining information about
+ the host error. The values in this structure will only be valid if a
+ PortAudio function has previously returned the paUnanticipatedHostError
+ error code.
+*}
+function Pa_GetLastHostErrorInfo(): PPaHostErrorInfo; cdecl; external LibName;
+
+
+
+{* Device enumeration and capabilities *}
+
+{** Retrieve the number of available devices. The number of available devices
+ may be zero.
+
+ @return A non-negative value indicating the number of available devices or,
+ a PaErrorCode (which are always negative) if PortAudio is not initialized
+ or an error is encountered.
+*}
+function Pa_GetDeviceCount(): TPaDeviceIndex; cdecl; external LibName;
+
+
+{** Retrieve the index of the default input device. The result can be
+ used in the inputDevice parameter to Pa_OpenStream().
+
+ @return The default input device index for the default host API, or paNoDevice
+ if no default input device is available or an error was encountered.
+*}
+function Pa_GetDefaultInputDevice(): TPaDeviceIndex; cdecl; external LibName;
+
+
+{** Retrieve the index of the default output device. The result can be
+ used in the outputDevice parameter to Pa_OpenStream().
+
+ @return The default output device index for the defualt host API, or paNoDevice
+ if no default output device is available or an error was encountered.
+
+ @note
+ On the PC, the user can specify a default device by
+ setting an environment variable. For example, to use device #1.
+<pre>
+ set PA_RECOMMENDED_OUTPUT_DEVICE=1
+</pre>
+ The user should first determine the available device ids by using
+ the supplied application "pa_devs".
+*}
+function Pa_GetDefaultOutputDevice(): TPaDeviceIndex; cdecl; external LibName;
+
+
+{** The type used to represent monotonic time in seconds that can be used
+ for syncronisation. The type is used for the outTime argument to the
+ PaStreamCallback and as the result of Pa_GetStreamTime().
+
+ @see PaStreamCallback, Pa_GetStreamTime
+*}
+type TPaTime = Double;
+
+
+{** A type used to specify one or more sample formats. Each value indicates
+ a possible format for sound data passed to and from the stream callback,
+ Pa_ReadStream and Pa_WriteStream.
+
+ The standard formats paFloat32, paInt16, paInt32, paInt24, paInt8
+ and aUInt8 are usually implemented by all implementations.
+
+ The floating point representation (paFloat32) uses +1.0 and -1.0 as the
+ maximum and minimum respectively.
+
+ paUInt8 is an unsigned 8 bit format where 128 is considered "ground"
+
+ The paNonInterleaved flag indicates that a multichannel buffer is passed
+ as a set of non-interleaved pointers.
+
+ @see Pa_OpenStream, Pa_OpenDefaultStream, PaDeviceInfo
+ @see paFloat32, paInt16, paInt32, paInt24, paInt8
+ @see paUInt8, paCustomFormat, paNonInterleaved
+*}
+type TPaSampleFormat = Longword;
+const
+ paFloat32 = TPaSampleFormat($00000001); {**< @see PaSampleFormat *}
+ paInt32 = TPaSampleFormat($00000002); {**< @see PaSampleFormat *}
+ paInt24 = TPaSampleFormat($00000004); {**< Packed 24 bit format. @see PaSampleFormat *}
+ paInt16 = TPaSampleFormat($00000008); {**< @see PaSampleFormat *}
+ paInt8 = TPaSampleFormat($00000010); {**< @see PaSampleFormat *}
+ paUInt8 = TPaSampleFormat($00000020); {**< @see PaSampleFormat *}
+ paCustomFormat = TPaSampleFormat($00010000); {**< @see PaSampleFormat *}
+ paNonInterleaved = TPaSampleFormat($80000000);
+
+{** A structure providing information and capabilities of PortAudio devices.
+ Devices may support input, output or both input and output.
+*}
+type
+ PPaDeviceInfo = ^TPaDeviceInfo;
+ TPaDeviceInfo = record
+ structVersion: Integer; {* this is struct version 2 *}
+ name: PChar;
+ hostApi: TPaHostApiIndex; {* note this is a host API index, not a type id*}
+
+ maxInputChannels: Integer;
+ maxOutputChannels: Integer;
+
+ {* Default latency values for interactive performance. *}
+ defaultLowInputLatency: TPaTime;
+ defaultLowOutputLatency: TPaTime;
+ {* Default latency values for robust non-interactive applications (eg. playing sound files). *}
+ defaultHighInputLatency: TPaTime;
+ defaultHighOutputLatency: TPaTime;
+
+ defaultSampleRate: Double;
+ end;
+
+
+{** Retrieve a pointer to a PaDeviceInfo structure containing information
+ about the specified device.
+ @return A pointer to an immutable PaDeviceInfo structure. If the device
+ parameter is out of range the function returns NULL.
+
+ @param device A valid device index in the range 0 to (Pa_GetDeviceCount()-1)
+
+ @note PortAudio manages the memory referenced by the returned pointer,
+ the client must not manipulate or free the memory. The pointer is only
+ guaranteed to be valid between calls to Pa_Initialize() and Pa_Terminate().
+
+ @see PaDeviceInfo, PaDeviceIndex
+*}
+function Pa_GetDeviceInfo( device: TPaDeviceIndex ): PPaDeviceInfo; cdecl; external LibName;
+
+
+{** Parameters for one direction (input or output) of a stream.
+*}
+type
+ PPaStreamParameters = ^TPaStreamParameters;
+ TPaStreamParameters = record
+ {** A valid device index in the range 0 to (Pa_GetDeviceCount()-1)
+ specifying the device to be used or the special constant
+ paUseHostApiSpecificDeviceSpecification which indicates that the actual
+ device(s) to use are specified in hostApiSpecificStreamInfo.
+ This field must not be set to paNoDevice.
+ *}
+ device: TPaDeviceIndex;
+
+ {** The number of channels of sound to be delivered to the
+ stream callback or accessed by Pa_ReadStream() or Pa_WriteStream().
+ It can range from 1 to the value of maxInputChannels in the
+ PaDeviceInfo record for the device specified by the device parameter.
+ *}
+ channelCount: Integer;
+
+ {** The sample format of the buffer provided to the stream callback,
+ a_ReadStream() or Pa_WriteStream(). It may be any of the formats described
+ by the PaSampleFormat enumeration.
+ *}
+ sampleFormat: TPaSampleFormat;
+
+ {** The desired latency in seconds. Where practical, implementations should
+ configure their latency based on these parameters, otherwise they may
+ choose the closest viable latency instead. Unless the suggested latency
+ is greater than the absolute upper limit for the device implementations
+ should round the suggestedLatency up to the next practial value - ie to
+ provide an equal or higher latency than suggestedLatency wherever possibe.
+ Actual latency values for an open stream may be retrieved using the
+ inputLatency and outputLatency fields of the PaStreamInfo structure
+ returned by Pa_GetStreamInfo().
+ @see default*Latency in PaDeviceInfo, *Latency in PaStreamInfo
+ *}
+ suggestedLatency: TPaTime;
+
+ {** An optional pointer to a host api specific data structure
+ containing additional information for device setup and/or stream processing.
+ hostApiSpecificStreamInfo is never required for correct operation,
+ if not used it should be set to NULL.
+ *}
+ hostApiSpecificStreamInfo: Pointer;
+ end;
+
+
+{** Return code for Pa_IsFormatSupported indicating success. *}
+const paFormatIsSupported = (0);
+
+{** Determine whether it would be possible to open a stream with the specified
+ parameters.
+
+ @param inputParameters A structure that describes the input parameters used to
+ open a stream. The suggestedLatency field is ignored. See PaStreamParameters
+ for a description of these parameters. inputParameters must be NULL for
+ output-only streams.
+
+ @param outputParameters A structure that describes the output parameters used
+ to open a stream. The suggestedLatency field is ignored. See PaStreamParameters
+ for a description of these parameters. outputParameters must be NULL for
+ input-only streams.
+
+ @param sampleRate The required sampleRate. For full-duplex streams it is the
+ sample rate for both input and output
+
+ @return Returns 0 if the format is supported, and an error code indicating why
+ the format is not supported otherwise. The constant paFormatIsSupported is
+ provided to compare with the return value for success.
+
+ @see paFormatIsSupported, PaStreamParameters
+*}
+function Pa_IsFormatSupported( inputParameters: PPaStreamParameters;
+ outputParameters: PPaStreamParameters;
+ sampleRate: Double ): TPaError; cdecl; external LibName;
+
+
+
+{* Streaming types and functions *}
+
+
+{**
+ A single PaStream can provide multiple channels of real-time
+ streaming audio input and output to a client application. A stream
+ provides access to audio hardware represented by one or more
+ PaDevices. Depending on the underlying Host API, it may be possible
+ to open multiple streams using the same device, however this behavior
+ is implementation defined. Portable applications should assume that
+ a PaDevice may be simultaneously used by at most one PaStream.
+
+ Pointers to PaStream objects are passed between PortAudio functions that
+ operate on streams.
+
+ @see Pa_OpenStream, Pa_OpenDefaultStream, Pa_OpenDefaultStream, Pa_CloseStream,
+ Pa_StartStream, Pa_StopStream, Pa_AbortStream, Pa_IsStreamActive,
+ Pa_GetStreamTime, Pa_GetStreamCpuLoad
+
+*}
+type
+ PPaStream = Pointer;
+
+{** Can be passed as the framesPerBuffer parameter to Pa_OpenStream()
+ or Pa_OpenDefaultStream() to indicate that the stream callback will
+ accept buffers of any size.
+*}
+const paFramesPerBufferUnspecified = (0);
+
+
+{** Flags used to control the behavior of a stream. They are passed as
+ parameters to Pa_OpenStream or Pa_OpenDefaultStream. Multiple flags may be
+ ORed together.
+
+ @see Pa_OpenStream, Pa_OpenDefaultStream
+ @see paNoFlag, paClipOff, paDitherOff, paNeverDropInput,
+ paPrimeOutputBuffersUsingStreamCallback, paPlatformSpecificFlags
+*}
+type TPaStreamFlags = Longword;
+
+{** @see PaStreamFlags *}
+const paNoFlag = TPaStreamFlags(0);
+
+{** Disable default clipping of out of range samples.
+ @see PaStreamFlags
+*}
+const paClipOff = TPaStreamFlags($00000001);
+
+{** Disable default dithering.
+ @see PaStreamFlags
+*}
+const paDitherOff = TPaStreamFlags($00000002);
+
+{** Flag requests that where possible a full duplex stream will not discard
+ overflowed input samples without calling the stream callback. This flag is
+ only valid for full duplex callback streams and only when used in combination
+ with the paFramesPerBufferUnspecified (0) framesPerBuffer parameter. Using
+ this flag incorrectly results in a paInvalidFlag error being returned from
+ Pa_OpenStream and Pa_OpenDefaultStream.
+
+ @see PaStreamFlags, paFramesPerBufferUnspecified
+*}
+const paNeverDropInput = TPaStreamFlags($00000004);
+
+{** Call the stream callback to fill initial output buffers, rather than the
+ default behavior of priming the buffers with zeros (silence). This flag has
+ no effect for input-only and blocking read/write streams.
+
+ @see PaStreamFlags
+*}
+const paPrimeOutputBuffersUsingStreamCallback = TPaStreamFlags($00000008);
+
+{** A mask specifying the platform specific bits.
+ @see PaStreamFlags
+*}
+const paPlatformSpecificFlags = TPaStreamFlags($FFFF0000);
+
+{**
+ Timing information for the buffers passed to the stream callback.
+*}
+type
+ PPaStreamCallbackTimeInfo = ^TPaStreamCallbackTimeInfo;
+ TPaStreamCallbackTimeInfo = record
+ inputBufferAdcTime: TPaTime;
+ currentTime: TPaTime;
+ outputBufferDacTime: TPaTime;
+ end;
+
+
+{**
+ Flag bit constants for the statusFlags to PaStreamCallback.
+
+ @see paInputUnderflow, paInputOverflow, paOutputUnderflow, paOutputOverflow,
+ paPrimingOutput
+*}
+type TPaStreamCallbackFlags = Longword;
+
+{** In a stream opened with paFramesPerBufferUnspecified, indicates that
+ input data is all silence (zeros) because no real data is available. In a
+ stream opened without paFramesPerBufferUnspecified, it indicates that one or
+ more zero samples have been inserted into the input buffer to compensate
+ for an input underflow.
+ @see PaStreamCallbackFlags
+*}
+const paInputUnderflow = TPaStreamCallbackFlags($00000001);
+
+{** In a stream opened with paFramesPerBufferUnspecified, indicates that data
+ prior to the first sample of the input buffer was discarded due to an
+ overflow, possibly because the stream callback is using too much CPU time.
+ Otherwise indicates that data prior to one or more samples in the
+ input buffer was discarded.
+ @see PaStreamCallbackFlags
+*}
+const paInputOverflow = TPaStreamCallbackFlags($00000002);
+
+{** Indicates that output data (or a gap) was inserted, possibly because the
+ stream callback is using too much CPU time.
+ @see PaStreamCallbackFlags
+*}
+const paOutputUnderflow = TPaStreamCallbackFlags($00000004);
+
+{** Indicates that output data will be discarded because no room is available.
+ @see PaStreamCallbackFlags
+*}
+const paOutputOverflow = TPaStreamCallbackFlags($00000008);
+
+{** Some of all of the output data will be used to prime the stream, input
+ data may be zero.
+ @see PaStreamCallbackFlags
+*}
+const paPrimingOutput = TPaStreamCallbackFlags($00000010);
+
+{**
+ Allowable return values for the PaStreamCallback.
+ @see PaStreamCallback
+*}
+type TPaStreamCallbackResult = {enum}Integer; const
+{enum_begin PaStreamCallbackResult}
+ paContinue=0;
+ paComplete=1;
+ paAbort=2;
+{enum_end PaStreamCallbackResult}
+
+{**
+ Functions of type PaStreamCallback are implemented by PortAudio clients.
+ They consume, process or generate audio in response to requests from an
+ active PortAudio stream.
+
+ @param input and @param output are arrays of interleaved samples,
+ the format, packing and number of channels used by the buffers are
+ determined by parameters to Pa_OpenStream().
+
+ @param frameCount The number of sample frames to be processed by
+ the stream callback.
+
+ @param timeInfo The time in seconds when the first sample of the input
+ buffer was received at the audio input, the time in seconds when the first
+ sample of the output buffer will begin being played at the audio output, and
+ the time in seconds when the stream callback was called.
+ See also Pa_GetStreamTime()
+
+ @param statusFlags Flags indicating whether input and/or output buffers
+ have been inserted or will be dropped to overcome underflow or overflow
+ conditions.
+
+ @param userData The value of a user supplied pointer passed to
+ Pa_OpenStream() intended for storing synthesis data etc.
+
+ @return
+ The stream callback should return one of the values in the
+ PaStreamCallbackResult enumeration. To ensure that the callback continues
+ to be called, it should return paContinue (0). Either paComplete or paAbort
+ can be returned to finish stream processing, after either of these values is
+ returned the callback will not be called again. If paAbort is returned the
+ stream will finish as soon as possible. If paComplete is returned, the stream
+ will continue until all buffers generated by the callback have been played.
+ This may be useful in applications such as soundfile players where a specific
+ duration of output is required. However, it is not necessary to utilise this
+ mechanism as Pa_StopStream(), Pa_AbortStream() or Pa_CloseStream() can also
+ be used to stop the stream. The callback must always fill the entire output
+ buffer irrespective of its return value.
+
+ @see Pa_OpenStream, Pa_OpenDefaultStream
+
+ @note With the exception of Pa_GetStreamCpuLoad() it is not permissable to call
+ PortAudio API functions from within the stream callback.
+*}
+type
+ PPaStreamCallback = ^TPaStreamCallback;
+ TPaStreamCallback = function(
+ input: Pointer; output: Pointer;
+ frameCount: Longword;
+ timeInfo: PPaStreamCallbackTimeInfo;
+ statusFlags: TPaStreamCallbackFlags;
+ userData: Pointer ): Integer; cdecl;
+
+
+{** Opens a stream for either input, output or both.
+
+ @param stream The address of a PaStream pointer which will receive
+ a pointer to the newly opened stream.
+
+ @param inputParameters A structure that describes the input parameters used by
+ the opened stream. See PaStreamParameters for a description of these parameters.
+ inputParameters must be NULL for output-only streams.
+
+ @param outputParameters A structure that describes the output parameters used by
+ the opened stream. See PaStreamParameters for a description of these parameters.
+ outputParameters must be NULL for input-only streams.
+
+ @param sampleRate The desired sampleRate. For full-duplex streams it is the
+ sample rate for both input and output
+
+ @param framesPerBuffer The number of frames passed to the stream callback
+ function, or the preferred block granularity for a blocking read/write stream.
+ The special value paFramesPerBufferUnspecified (0) may be used to request that
+ the stream callback will recieve an optimal (and possibly varying) number of
+ frames based on host requirements and the requested latency settings.
+ Note: With some host APIs, the use of non-zero framesPerBuffer for a callback
+ stream may introduce an additional layer of buffering which could introduce
+ additional latency. PortAudio guarantees that the additional latency
+ will be kept to the theoretical minimum however, it is strongly recommended
+ that a non-zero framesPerBuffer value only be used when your algorithm
+ requires a fixed number of frames per stream callback.
+
+ @param streamFlags Flags which modify the behaviour of the streaming process.
+ This parameter may contain a combination of flags ORed together. Some flags may
+ only be relevant to certain buffer formats.
+
+ @param streamCallback A pointer to a client supplied function that is responsible
+ for processing and filling input and output buffers. If this parameter is NULL
+ the stream will be opened in 'blocking read/write' mode. In blocking mode,
+ the client can receive sample data using Pa_ReadStream and write sample data
+ using Pa_WriteStream, the number of samples that may be read or written
+ without blocking is returned by Pa_GetStreamReadAvailable and
+ Pa_GetStreamWriteAvailable respectively.
+
+ @param userData A client supplied pointer which is passed to the stream callback
+ function. It could for example, contain a pointer to instance data necessary
+ for processing the audio buffers. This parameter is ignored if streamCallback
+ is NULL.
+
+ @return
+ Upon success Pa_OpenStream() returns paNoError and places a pointer to a
+ valid PaStream in the stream argument. The stream is inactive (stopped).
+ If a call to Pa_OpenStream() fails, a non-zero error code is returned (see
+ PaError for possible error codes) and the value of stream is invalid.
+
+ @see PaStreamParameters, PaStreamCallback, Pa_ReadStream, Pa_WriteStream,
+ Pa_GetStreamReadAvailable, Pa_GetStreamWriteAvailable
+*}
+function Pa_OpenStream( var stream: PPaStream;
+ inputParameters: PPaStreamParameters;
+ outputParameters: PPaStreamParameters;
+ sampleRate: Double;
+ framesPerBuffer: Longword;
+ streamFlags: TPaStreamFlags;
+ streamCallback: PPaStreamCallback;
+ userData: Pointer ): TPaError; cdecl; external LibName;
+
+
+{** A simplified version of Pa_OpenStream() that opens the default input
+ and/or output devices.
+
+ @param stream The address of a PaStream pointer which will receive
+ a pointer to the newly opened stream.
+
+ @param numInputChannels The number of channels of sound that will be supplied
+ to the stream callback or returned by Pa_ReadStream. It can range from 1 to
+ the value of maxInputChannels in the PaDeviceInfo record for the default input
+ device. If 0 the stream is opened as an output-only stream.
+
+ @param numOutputChannels The number of channels of sound to be delivered to the
+ stream callback or passed to Pa_WriteStream. It can range from 1 to the value
+ of maxOutputChannels in the PaDeviceInfo record for the default output dvice.
+ If 0 the stream is opened as an output-only stream.
+
+ @param sampleFormat The sample format of both the input and output buffers
+ provided to the callback or passed to and from Pa_ReadStream and Pa_WriteStream.
+ sampleFormat may be any of the formats described by the PaSampleFormat
+ enumeration.
+
+ @param sampleRate Same as Pa_OpenStream parameter of the same name.
+ @param framesPerBuffer Same as Pa_OpenStream parameter of the same name.
+ @param streamCallback Same as Pa_OpenStream parameter of the same name.
+ @param userData Same as Pa_OpenStream parameter of the same name.
+
+ @return As for Pa_OpenStream
+
+ @see Pa_OpenStream, PaStreamCallback
+*}
+function Pa_OpenDefaultStream( var stream: PPaStream;
+ numInputChannels: Integer;
+ numOutputChannels: Integer;
+ sampleFormat: TPaSampleFormat;
+ sampleRate: Double;
+ framesPerBuffer: Longword;
+ streamCallback: PPaStreamCallback;
+ userData: Pointer ): TPaError; cdecl; external LibName;
+
+
+{** Closes an audio stream. If the audio stream is active it
+ discards any pending buffers as if Pa_AbortStream() had been called.
+*}
+function Pa_CloseStream( stream: PPaStream ): TPaError; cdecl; external LibName;
+
+
+{** Functions of type PaStreamFinishedCallback are implemented by PortAudio
+ clients. They can be registered with a stream using the Pa_SetStreamFinishedCallback
+ function. Once registered they are called when the stream becomes inactive
+ (ie once a call to Pa_StopStream() will not block).
+ A stream will become inactive after the stream callback returns non-zero,
+ or when Pa_StopStream or Pa_AbortStream is called. For a stream providing audio
+ output, if the stream callback returns paComplete, or Pa_StopStream is called,
+ the stream finished callback will not be called until all generated sample data
+ has been played.
+
+ @param userData The userData parameter supplied to Pa_OpenStream()
+
+ @see Pa_SetStreamFinishedCallback
+*}
+type
+ PPaStreamFinishedCallback = ^TPaStreamFinishedCallback;
+ TPaStreamFinishedCallback = procedure( userData: Pointer ); cdecl;
+
+
+{** Register a stream finished callback function which will be called when the
+ stream becomes inactive. See the description of PaStreamFinishedCallback for
+ further details about when the callback will be called.
+
+ @param stream a pointer to a PaStream that is in the stopped state - if the
+ stream is not stopped, the stream's finished callback will remain unchanged
+ and an error code will be returned.
+
+ @param streamFinishedCallback a pointer to a function with the same signature
+ as PaStreamFinishedCallback, that will be called when the stream becomes
+ inactive. Passing NULL for this parameter will un-register a previously
+ registered stream finished callback function.
+
+ @return on success returns paNoError, otherwise an error code indicating the cause
+ of the error.
+
+ @see PaStreamFinishedCallback
+*}
+function Pa_SetStreamFinishedCallback( stream: PPaStream;
+ streamFinishedCallback: PPaStreamFinishedCallback ): TPaError; cdecl; external LibName;
+
+
+{** Commences audio processing.
+*}
+function Pa_StartStream( stream: PPaStream ): TPaError; cdecl; external LibName;
+
+
+{** Terminates audio processing. It waits until all pending
+ audio buffers have been played before it returns.
+*}
+function Pa_StopStream( stream: PPaStream ): TPaError; cdecl; external LibName;
+
+
+{** Terminates audio processing immediately without waiting for pending
+ buffers to complete.
+*}
+function Pa_AbortStream( stream: PPaStream ): TPaError; cdecl; external LibName;
+
+
+{** Determine whether the stream is stopped.
+ A stream is considered to be stopped prior to a successful call to
+ Pa_StartStream and after a successful call to Pa_StopStream or Pa_AbortStream.
+ If a stream callback returns a value other than paContinue the stream is NOT
+ considered to be stopped.
+
+ @return Returns one (1) when the stream is stopped, zero (0) when
+ the stream is running or, a PaErrorCode (which are always negative) if
+ PortAudio is not initialized or an error is encountered.
+
+ @see Pa_StopStream, Pa_AbortStream, Pa_IsStreamActive
+*}
+function Pa_IsStreamStopped( stream: PPaStream ): TPaError; cdecl; external LibName;
+
+
+{** Determine whether the stream is active.
+ A stream is active after a successful call to Pa_StartStream(), until it
+ becomes inactive either as a result of a call to Pa_StopStream() or
+ Pa_AbortStream(), or as a result of a return value other than paContinue from
+ the stream callback. In the latter case, the stream is considered inactive
+ after the last buffer has finished playing.
+
+ @return Returns one (1) when the stream is active (ie playing or recording
+ audio), zero (0) when not playing or, a PaErrorCode (which are always negative)
+ if PortAudio is not initialized or an error is encountered.
+
+ @see Pa_StopStream, Pa_AbortStream, Pa_IsStreamStopped
+*}
+function Pa_IsStreamActive( stream: PPaStream ): TPaError; cdecl; external LibName;
+
+
+
+{** A structure containing unchanging information about an open stream.
+ @see Pa_GetStreamInfo
+*}
+type
+ PPaStreamInfo = ^TPaStreamInfo;
+ TPaStreamInfo = record
+ {** this is struct version 1 *}
+ structVersion: Integer;
+
+ {** The input latency of the stream in seconds. This value provides the most
+ accurate estimate of input latency available to the implementation. It may
+ differ significantly from the suggestedLatency value passed to Pa_OpenStream().
+ The value of this field will be zero (0.) for output-only streams.
+ @see PaTime
+ *}
+ inputLatency: TPaTime;
+
+ {** The output latency of the stream in seconds. This value provides the most
+ accurate estimate of output latency available to the implementation. It may
+ differ significantly from the suggestedLatency value passed to Pa_OpenStream().
+ The value of this field will be zero (0.) for input-only streams.
+ @see PaTime
+ *}
+ outputLatency: TPaTime;
+
+ {** The sample rate of the stream in Hertz (samples per second). In cases
+ where the hardware sample rate is inaccurate and PortAudio is aware of it,
+ the value of this field may be different from the sampleRate parameter
+ passed to Pa_OpenStream(). If information about the actual hardware sample
+ rate is not available, this field will have the same value as the sampleRate
+ parameter passed to Pa_OpenStream().
+ *}
+ sampleRate: Double;
+ end;
+
+
+{** Retrieve a pointer to a PaStreamInfo structure containing information
+ about the specified stream.
+ @return A pointer to an immutable PaStreamInfo structure. If the stream
+ parameter invalid, or an error is encountered, the function returns NULL.
+
+ @param stream A pointer to an open stream previously created with Pa_OpenStream.
+
+ @note PortAudio manages the memory referenced by the returned pointer,
+ the client must not manipulate or free the memory. The pointer is only
+ guaranteed to be valid until the specified stream is closed.
+
+ @see PaStreamInfo
+*}
+function Pa_GetStreamInfo( stream: PPaStream ): PPaStreamInfo; cdecl; external LibName;
+
+
+{** Determine the current time for the stream according to the same clock used
+ to generate buffer timestamps. This time may be used for syncronising other
+ events to the audio stream, for example synchronizing audio to MIDI.
+
+ @return The stream's current time in seconds, or 0 if an error occurred.
+
+ @see PaTime, PaStreamCallback
+*}
+function Pa_GetStreamTime( stream: PPaStream ): TPaTime; cdecl; external LibName;
+
+
+{** Retrieve CPU usage information for the specified stream.
+ The "CPU Load" is a fraction of total CPU time consumed by a callback stream's
+ audio processing routines including, but not limited to the client supplied
+ stream callback. This function does not work with blocking read/write streams.
+
+ This function may be called from the stream callback function or the
+ application.
+
+ @return
+ A floating point value, typically between 0.0 and 1.0, where 1.0 indicates
+ that the stream callback is consuming the maximum number of CPU cycles possible
+ to maintain real-time operation. A value of 0.5 would imply that PortAudio and
+ the stream callback was consuming roughly 50% of the available CPU time. The
+ return value may exceed 1.0. A value of 0.0 will always be returned for a
+ blocking read/write stream, or if an error occurrs.
+*}
+function Pa_GetStreamCpuLoad( stream: PPaStream ): Double; cdecl; external LibName;
+
+
+{** Read samples from an input stream. The function doesn't return until
+ the entire buffer has been filled - this may involve waiting for the operating
+ system to supply the data.
+
+ @param stream A pointer to an open stream previously created with Pa_OpenStream.
+
+ @param buffer A pointer to a buffer of sample frames. The buffer contains
+ samples in the format specified by the inputParameters->sampleFormat field
+ used to open the stream, and the number of channels specified by
+ inputParameters->numChannels. If non-interleaved samples were requested,
+ buffer is a pointer to the first element of an array of non-interleaved
+ buffer pointers, one for each channel.
+
+ @param frames The number of frames to be read into buffer. This parameter
+ is not constrained to a specific range, however high performance applications
+ will want to match this parameter to the framesPerBuffer parameter used
+ when opening the stream.
+
+ @return On success PaNoError will be returned, or PaInputOverflowed if input
+ data was discarded by PortAudio after the previous call and before this call.
+*}
+function Pa_ReadStream( stream: PPaStream;
+ buffer: Pointer;
+ frames: Longword ): TPaError; cdecl; external LibName;
+
+
+{** Write samples to an output stream. This function doesn't return until the
+ entire buffer has been consumed - this may involve waiting for the operating
+ system to consume the data.
+
+ @param stream A pointer to an open stream previously created with Pa_OpenStream.
+
+ @param buffer A pointer to a buffer of sample frames. The buffer contains
+ samples in the format specified by the outputParameters->sampleFormat field
+ used to open the stream, and the number of channels specified by
+ outputParameters->numChannels. If non-interleaved samples were requested,
+ buffer is a pointer to the first element of an array of non-interleaved
+ buffer pointers, one for each channel.
+
+ @param frames The number of frames to be written from buffer. This parameter
+ is not constrained to a specific range, however high performance applications
+ will want to match this parameter to the framesPerBuffer parameter used
+ when opening the stream.
+
+ @return On success PaNoError will be returned, or paOutputUnderflowed if
+ additional output data was inserted after the previous call and before this
+ call.
+*}
+function Pa_WriteStream( stream: PPaStream;
+ buffer: Pointer;
+ frames: Longword ): TPaError; cdecl; external LibName;
+
+
+{** Retrieve the number of frames that can be read from the stream without
+ waiting.
+
+ @return Returns a non-negative value representing the maximum number of frames
+ that can be read from the stream without blocking or busy waiting or, a
+ PaErrorCode (which are always negative) if PortAudio is not initialized or an
+ error is encountered.
+*}
+function Pa_GetStreamReadAvailable( stream: PPaStream ): Longint; cdecl; external LibName;
+
+
+{** Retrieve the number of frames that can be written to the stream without
+ waiting.
+
+ @return Returns a non-negative value representing the maximum number of frames
+ that can be written to the stream without blocking or busy waiting or, a
+ PaErrorCode (which are always negative) if PortAudio is not initialized or an
+ error is encountered.
+*}
+function Pa_GetStreamWriteAvailable( stream: PPaStream ): Longint; cdecl; external LibName;
+
+
+{** Retrieve the host type handling an open stream.
+
+ @return Returns a non-negative value representing the host API type
+ handling an open stream or, a PaErrorCode (which are always negative)
+ if PortAudio is not initialized or an error is encountered.
+*}
+function Pa_GetStreamHostApiType( stream: PPaStream ): TPaHostApiTypeId; cdecl; external LibName;
+
+
+{* Miscellaneous utilities *}
+
+
+{** Retrieve the size of a given sample format in bytes.
+
+ @return The size in bytes of a single sample in the specified format,
+ or paSampleFormatNotSupported if the format is not supported.
+*}
+function Pa_GetSampleSize( format: TPaSampleFormat ): TPaError; cdecl; external LibName;
+
+
+{** Put the caller to sleep for at least 'msec' milliseconds. This function is
+ provided only as a convenience for authors of portable code (such as the tests
+ and examples in the PortAudio distribution.)
+
+ The function may sleep longer than requested so don't rely on this for accurate
+ musical timing.
+*}
+procedure Pa_Sleep( msec: Longint ); cdecl; external LibName;
+
+implementation
+
+end.
diff --git a/Game/Code/lib/portmixer/delphi/portmixer.pas b/Game/Code/lib/portmixer/delphi/portmixer.pas new file mode 100644 index 00000000..a9e27516 --- /dev/null +++ b/Game/Code/lib/portmixer/delphi/portmixer.pas @@ -0,0 +1,152 @@ +{*
+ * PortMixer
+ * PortMixer API Header File
+ *
+ * Copyright (c) 2002, 2006
+ *
+ * Written by Dominic Mazzoni
+ * and Leland Lucius
+ *
+ * PortMixer is intended to work side-by-side with PortAudio,
+ * the Portable Real-Time Audio Library by Ross Bencina and
+ * Phil Burk.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *}
+unit portmixer;
+
+{$IFDEF FPC}
+ {$IFNDEF win32}
+ {$LINKLIB libportaudio}
+ {$ENDIF}
+ {$PACKRECORDS C} (* GCC/Visual C/C++ compatible record packing *)
+ {$MODE DELPHI }
+{$ENDIF}
+
+interface
+
+uses
+ portaudio;
+
+const
+{$IFDEF WIN32}
+ LibName = 'portmixer.dll';
+{$ENDIF}
+{$IFDEF LINUX}
+ LibName = 'libportmixer.so';
+{$ENDIF}
+{$IFDEF MACOS}
+ LibName = 'libportmixer.dylib';
+{$ENDIF}
+
+type
+ PPxMixer = Pointer;
+ TPxVolume = Single; {* 0.0 (min) --> 1.0 (max) *}
+ TPxBalance = Single; {* -1.0 (left) --> 1.0 (right) *}
+
+{*
+ Px_OpenMixer() returns a mixer which will work with the given PortAudio
+ audio device. Pass 0 as the index for the first (default) mixer.
+*}
+
+function Px_OpenMixer( pa_stream: Pointer; i: Integer ): PPxMixer; cdecl; external LibName;
+
+{*
+ Px_CloseMixer() closes a mixer opened using Px_OpenMixer and frees any
+ memory associated with it.
+*}
+
+procedure Px_CloseMixer( mixer: PPxMixer ); cdecl; external LibName;
+
+{*
+ Px_GetNumMixers returns the number of mixers which could be
+ used with the given PortAudio device. On most systems, there
+ will be only one mixer for each device; however there may be
+ multiple mixers for each device, or possibly multiple mixers
+ which are independent of any particular PortAudio device.
+*}
+
+function Px_GetNumMixers( mixer: PPxMixer ): Integer; cdecl; external LibName;
+function Px_GetMixerName( mixer: PPxMixer; i: Integer ): PChar; cdecl; external LibName;
+
+{*
+ Master (output) volume
+*}
+
+function Px_GetMasterVolume( mixer: PPxMixer ): TPxVolume; cdecl; external LibName;
+procedure Px_SetMasterVolume( mixer: PPxMixer; volume: TPxVolume ); cdecl; external LibName;
+
+{*
+ Main output volume
+*}
+
+function Px_GetPCMOutputVolume( mixer: PPxMixer ): TPxVolume; cdecl; external LibName;
+procedure Px_SetPCMOutputVolume( mixer: PPxMixer; volume: TPxVolume ); cdecl; external LibName;
+function Px_SupportsPCMOutputVolume( mixer: PPxMixer ): Integer; cdecl; external LibName;
+
+{*
+ All output volumes
+*}
+
+function Px_GetNumOutputVolumes( mixer: PPxMixer ): Integer; cdecl; external LibName;
+function Px_GetOutputVolumeName( mixer: PPxMixer; i: Integer ): PChar; cdecl; external LibName;
+function Px_GetOutputVolume( mixer: PPxMixer; i: Integer ): TPxVolume; cdecl; external LibName;
+procedure Px_SetOutputVolume( mixer: PPxMixer; i: Integer; volume: TPxVolume ); cdecl; external LibName;
+
+{*
+ Input source
+*}
+
+function Px_GetNumInputSources( mixer: PPxMixer ): Integer; cdecl; external LibName;
+function Px_GetInputSourceName( mixer: PPxMixer; i: Integer): PChar; cdecl; external LibName;
+function Px_GetCurrentInputSource( mixer: PPxMixer ): Integer; cdecl; external LibName; {* may return -1 == none *}
+procedure Px_SetCurrentInputSource( mixer: PPxMixer; i: Integer ); cdecl; external LibName;
+
+{*
+ Input volume
+*}
+
+function Px_GetInputVolume( mixer: PPxMixer ): TPxVolume; cdecl; external LibName;
+procedure Px_SetInputVolume( mixer: PPxMixer; volume: TPxVolume ); cdecl; external LibName;
+
+{*
+ Balance
+*}
+
+function Px_SupportsOutputBalance( mixer: PPxMixer ): Integer; cdecl; external LibName;
+function Px_GetOutputBalance( mixer: PPxMixer ): TPxBalance; cdecl; external LibName;
+procedure Px_SetOutputBalance( mixer: PPxMixer; balance: TPxBalance ); cdecl; external LibName;
+
+{*
+ Playthrough
+*}
+
+function Px_SupportsPlaythrough( mixer: PPxMixer ): Integer; cdecl; external LibName;
+function Px_GetPlaythrough( mixer: PPxMixer ): TPxVolume; cdecl; external LibName;
+procedure Px_SetPlaythrough( mixer: PPxMixer; volume: TPxVolume ); cdecl; external LibName;
+
+implementation
+
+end.
diff --git a/Game/Code/lib/projectM/0.9/projectM.pas b/Game/Code/lib/projectM/0.9/projectM.pas new file mode 100644 index 00000000..b3103b2e --- /dev/null +++ b/Game/Code/lib/projectM/0.9/projectM.pas @@ -0,0 +1,590 @@ +unit projectM; + +{$IFDEF FPC} + {$IFNDEF win32} + {$LINKLIB libprojectM} + {$ENDIF} + {$MODE DELPHI} + {$PACKENUM 4} + {$PACKRECORDS C} +{$ENDIF} + +interface + +uses + SysUtils; + +const +{$IFDEF win32} + libprojectM = 'libprojectM.dll'; +{$ELSE} + libprojectM = 'libprojectM.so'; +{$ENDIF} + +const + PROJECTM_VERSION = '0.99'; + PROJECTM_TITLE = 'projectM 0.99'; + +type + // 16bit non-interleaved data + TPCM16 = array[0..1, 0..511] of Smallint; + PPCM16 = ^TPCM16; + // 8bit non-interleaved data + TPCM8_512 = array[0..1, 0..511] of byte; + PPCM8_512 = ^TPCM8_512; + +{ Event types } +type + TProjectMEvent = integer; +const + PROJECTM_KEYUP = 0; + PROJECTM_KEYDOWN = 1;
+ PROJECTM_VIDEORESIZE = 2;
+ PROJECTM_VIDEOQUIT = 3;
+ PROJECTM_NONE = 4;
+
+{ Keycodes }
+type
+ TProjectMKeycode = integer;
+const
+ PROJECTM_K_RETURN = 0;
+ PROJECTM_K_RIGHT = 1;
+ PROJECTM_K_LEFT = 2;
+ PROJECTM_K_UP = 3;
+ PROJECTM_K_DOWN = 4;
+ PROJECTM_K_PAGEUP = 5;
+ PROJECTM_K_PAGEDOWN = 6;
+ PROJECTM_K_INSERT = 7;
+ PROJECTM_K_DELETE = 8;
+ PROJECTM_K_ESCAPE = 9;
+ PROJECTM_K_LSHIFT = 10;
+ PROJECTM_K_RSHIFT = 11;
+ PROJECTM_K_CAPSLOCK = 12;
+ PROJECTM_K_LCTRL = 13;
+ PROJECTM_K_HOME = 14;
+ PROJECTM_K_END = 15;
+ PROJECTM_K_BACKSPACE = 16;
+
+ PROJECTM_K_F1 = 17;
+ PROJECTM_K_F2 = (PROJECTM_K_F1 + 1);
+ PROJECTM_K_F3 = (PROJECTM_K_F1 + 2);
+ PROJECTM_K_F4 = (PROJECTM_K_F1 + 3);
+ PROJECTM_K_F5 = (PROJECTM_K_F1 + 4);
+ PROJECTM_K_F6 = (PROJECTM_K_F1 + 5);
+ PROJECTM_K_F7 = (PROJECTM_K_F1 + 6);
+ PROJECTM_K_F8 = (PROJECTM_K_F1 + 7);
+ PROJECTM_K_F9 = (PROJECTM_K_F1 + 8);
+ PROJECTM_K_F10 = (PROJECTM_K_F1 + 9);
+ PROJECTM_K_F11 = (PROJECTM_K_F1 + 10);
+ PROJECTM_K_F12 = (PROJECTM_K_F1 + 11);
+
+ PROJECTM_K_0 = 48;
+ PROJECTM_K_1 = (PROJECTM_K_0 + 1);
+ PROJECTM_K_2 = (PROJECTM_K_0 + 2);
+ PROJECTM_K_3 = (PROJECTM_K_0 + 3);
+ PROJECTM_K_4 = (PROJECTM_K_0 + 4);
+ PROJECTM_K_5 = (PROJECTM_K_0 + 5);
+ PROJECTM_K_6 = (PROJECTM_K_0 + 6);
+ PROJECTM_K_7 = (PROJECTM_K_0 + 7);
+ PROJECTM_K_8 = (PROJECTM_K_0 + 8);
+ PROJECTM_K_9 = (PROJECTM_K_0 + 9);
+
+ { Upper case }
+ PROJECTM_K_A_UPPERCASE = 65;
+ PROJECTM_K_B_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 1);
+ PROJECTM_K_C_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 2);
+ PROJECTM_K_D_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 3);
+ PROJECTM_K_E_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 4);
+ PROJECTM_K_F_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 5);
+ PROJECTM_K_G_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 6);
+ PROJECTM_K_H_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 7);
+ PROJECTM_K_I_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 8);
+ PROJECTM_K_J_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 9);
+ PROJECTM_K_K_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 10);
+ PROJECTM_K_L_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 11);
+ PROJECTM_K_M_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 12);
+ PROJECTM_K_N_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 13);
+ PROJECTM_K_O_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 14);
+ PROJECTM_K_P_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 15);
+ PROJECTM_K_Q_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 16);
+ PROJECTM_K_R_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 17);
+ PROJECTM_K_S_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 18);
+ PROJECTM_K_T_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 19);
+ PROJECTM_K_U_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 20);
+ PROJECTM_K_V_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 21);
+ PROJECTM_K_W_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 22);
+ PROJECTM_K_X_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 23);
+ PROJECTM_K_Y_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 24);
+ PROJECTM_K_Z_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 25);
+
+ { Lower case }
+ PROJECTM_K_a_LOWERCASE = 97;
+ PROJECTM_K_b_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 1);
+ PROJECTM_K_c_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 2);
+ PROJECTM_K_d_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 3);
+ PROJECTM_K_e_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 4);
+ PROJECTM_K_f_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 5);
+ PROJECTM_K_g_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 6);
+ PROJECTM_K_h_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 7);
+ PROJECTM_K_i_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 8);
+ PROJECTM_K_j_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 9);
+ PROJECTM_K_k_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 10);
+ PROJECTM_K_l_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 11);
+ PROJECTM_K_m_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 12);
+ PROJECTM_K_n_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 13);
+ PROJECTM_K_o_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 14);
+ PROJECTM_K_p_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 15);
+ PROJECTM_K_q_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 16);
+ PROJECTM_K_r_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 17);
+ PROJECTM_K_s_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 18);
+ PROJECTM_K_t_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 19);
+ PROJECTM_K_u_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 20);
+ PROJECTM_K_v_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 21);
+ PROJECTM_K_w_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 22);
+ PROJECTM_K_x_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 23);
+ PROJECTM_K_y_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 24);
+ PROJECTM_K_z_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 25);
+
+ PROJECTM_K_NONE = (PROJECTM_K_z_LOWERCASE + 1);
+
+{ Modifiers }
+type
+ TProjectMModifier = integer;
+const
+ PROJECTM_KMOD_LSHIFT = 0;
+ PROJECTM_KMOD_RSHIFT = 1;
+ PROJECTM_KMOD_CAPS = 2;
+ PROJECTM_KMOD_LCTRL = 3;
+ PROJECTM_KMOD_RCTRL = 4;
+ +type + PProjectM = ^TProjectM; + TProjectM = class(TObject) + private + _pm: Pointer; + public + constructor Create(gx, gy: integer; fps: integer; + texsize: integer; width, height: integer; + presetsDir, fontsDir: string); + + procedure ResetGL(width, height: Integer); + procedure SetTitle(title: string); + procedure RenderFrame(); + + procedure AddPCMfloat(pcmData: PSingle; samples: integer); + procedure AddPCM16(pcmData: PPCM16); + procedure AddPCM16Data(pcmData: PSmallint; samples: Smallint); + procedure AddPCM8_512(pcmData: PPCM8_512); + + procedure RandomPreset(); + procedure PreviousPreset(); + procedure NextPreset(); + procedure ToggleShowPresetNames(); + + procedure KeyHandler(event: TProjectMEvent; + keycode: TProjectMKeycode; + modifier: TProjectMModifier); + + destructor Destroy(); override; + end; + +implementation + +uses +{$IFNDEF win32} + baseunix, +{$ENDIF} + OpenGL12; + + +{**************** INTERNAL SECTION ****************} + + +type + PPSingle = ^PSingle; + +type + _TContextType = Integer; +const + AGL_CONTEXT = 0; + CGL_CONTEXT = 1; + NSGL_CONTEXT = 2; + GLX_CONTEXT = 3; + WGL_CONTEXT = 4; + +type + _PRenderTarget = ^_TRenderTarget; + _TRenderTarget = record + { Texture size } + texsize: Integer; + + { Application context } + origContextType: _TContextType; + + usePbuffers: Integer; + + {$ifdef LINUX} + lock_func: procedure(); cdecl; + unlock_func: procedure(); cdecl; + {$endif} + + { Opaque pbuffer context and pbuffer } + {$ifdef MACOS} + origContext: Pointer; + pbufferContext: Pointer; + pbuffer: Pointer; + {$endif} + + { Render target texture ID for non-pbuffer systems } + textureID: array[0..2] of TGLuint; + end; + + _PProjectM = ^_TProjectM; + _TProjectM = record + presetURL: PChar; + presetName: PChar; + fontURL: PChar; + + hasInit: Integer; + + noSwitch: Integer; + pcmframes: Integer; + freqframes: Integer; + totalframes: Integer; + + showfps: Integer; + showtitle: Integer; + showpreset: Integer; + showhelp: Integer; + showstats: Integer; + + studio: Integer; + + fbuffer: PGLubyte; + + {$ifndef Win32} + { The first ticks value of the application } + startTime: timeval; + {$else} + startTime: Longint; + {$endif Win32} + Time: Single; + + { Render target texture ID } + renderTarget: _PRenderTarget; + + disp: array[0..79] of Char; + + wave_o: Single; + + //int texsize=1024; //size of texture to do actual graphics + fvw: Integer; //fullscreen dimensions + fvh: Integer; + wvw: Integer; //windowed dimensions + wvh: Integer; + vw: Integer; //runtime dimensions + vh: Integer; + fullscreen: Integer; + + maxsamples: Integer; //size of PCM buffer + numsamples: Integer; //size of new PCM info + pcmdataL: PSingle; //holder for most recent pcm data + pcmdataR: PSingle; //holder for most recent pcm data + + avgtime: Integer; //# frames per preset + + title: PChar; + drawtitle: Integer; + + correction: Integer; + + vol: Single; + + //per pixel equation variables + gridx: PPSingle; //grid containing interpolated mesh + gridy: PPSingle; + origtheta: PPSingle; //grid containing interpolated mesh reference values + origrad: PPSingle; + origx: PPSingle; //original mesh + origy: PPSingle; + origx2: PPSingle; //original mesh + origy2: PPSingle; + + { Timing information } + mspf: Integer; + timed: Integer; + timestart: Integer; + nohard: Integer; + count: Integer; + realfps, + fpsstart: Single; + + { PCM data } + vdataL: array[0..511] of Single; //holders for FFT data (spectrum) + vdataR: array[0..511] of Single; + + { Various toggles } + doPerPixelEffects: Integer; + doIterative: Integer; + + { ENGINE VARIABLES } + { From engine_vars.h } + preset_name: array[0..255] of Char; + + { PER FRAME CONSTANTS BEGIN } + zoom: Single; + zoomexp: Single; + rot: Single; + warp: Single; + + sx: Single; + sy: Single; + dx: Single; + dy: Single; + cx: Single; + cy: Single; + + gy: Integer; + gx: Integer; + + decay: Single; + + wave_r: Single; + wave_g: Single; + wave_b: Single; + wave_x: Single; + wave_y: Single; + wave_mystery: Single; + + ob_size: Single; + ob_r: Single; + ob_g: Single; + ob_b: Single; + ob_a: Single; + + ib_size: Single; + ib_r: Single; + ib_g: Single; + ib_b: Single; + ib_a: Single; + + meshx: Integer; + meshy: Integer; + + mv_a: Single; + mv_r: Single; + mv_g: Single; + mv_b: Single; + mv_l: Single; + mv_x: Single; + mv_y: Single; + mv_dy: Single; + mv_dx: Single; + + treb: Single; + mid: Single; + bass: Single; + bass_old: Single; + beat_sensitivity: Single; + treb_att: Single; + mid_att: Single; + bass_att: Single; + progress: Single; + frame: Integer; + + { PER_FRAME CONSTANTS END } + + { PER_PIXEL CONSTANTS BEGIN } + + x_per_pixel: Single; + y_per_pixel: Single; + rad_per_pixel: Single; + ang_per_pixel: Single; + + { PER_PIXEL CONSTANT END } + + + fRating: Single; + fGammaAdj: Single; + fVideoEchoZoom: Single; + fVideoEchoAlpha: Single; + + nVideoEchoOrientation: Integer; + nWaveMode: Integer; + bAdditiveWaves: Integer; + bWaveDots: Integer; + bWaveThick: Integer; + bModWaveAlphaByVolume: Integer; + bMaximizeWaveColor: Integer; + bTexWrap: Integer; + bDarkenCenter: Integer; + bRedBlueStereo: Integer; + bBrighten: Integer; + bDarken: Integer; + bSolarize: Integer; + bInvert: Integer; + bMotionVectorsOn: Integer; + fps: Integer; + + fWaveAlpha: Single; + fWaveScale: Single; + fWaveSmoothing: Single; + fWaveParam: Single; + fModWaveAlphaStart: Single; + fModWaveAlphaEnd: Single; + fWarpAnimSpeed: Single; + fWarpScale: Single; + fShader: Single; + + + { Q VARIABLES START } + + q1: Single; + q2: Single; + q3: Single; + q4: Single; + q5: Single; + q6: Single; + q7: Single; + q8: Single; + + + { Q VARIABLES END } + + zoom_mesh: PPSingle; + zoomexp_mesh: PPSingle; + rot_mesh: PPSingle; + + sx_mesh: PPSingle; + sy_mesh: PPSingle; + dx_mesh: PPSingle; + dy_mesh: PPSingle; + cx_mesh: PPSingle; + cy_mesh: PPSingle; + + x_mesh: PPSingle; + y_mesh: PPSingle; + rad_mesh: PPSingle; + theta_mesh: PPSingle; + end; + +{ projectM.h declarations } +procedure _projectM_init(pm: _PProjectM); cdecl; external libprojectM name 'projectM_init'; +procedure _projectM_reset(pm: _PProjectM); cdecl; external libprojectM name 'projectM_reset'; +procedure _projectM_resetGL(pm: _PProjectM; width: Integer; height: Integer); cdecl; external libprojectM name 'projectM_resetGL'; +procedure _projectM_setTitle(pm: _PProjectM; title: PChar); cdecl; external libprojectM name 'projectM_setTitle'; +procedure _renderFrame(pm: _PProjectM); cdecl; external libprojectM name 'renderFrame'; + +{ PCM.h declarations } +procedure _addPCMfloat(pcm_data: PSingle; samples: integer); cdecl; external libprojectM name 'addPCMfloat'; +procedure _addPCM16(pcm_data: PPCM16); cdecl; external libprojectM name 'addPCM16'; +procedure _addPCM16Data(pcm_data: PSmallint; samples: Smallint); cdecl; external libprojectM name 'addPCM16Data'; +procedure _addPCM8_512(pcm_data: PPCM8_512); cdecl; external libprojectM name 'addPCM8'; + +{ console_interface.h declarations } +procedure _key_handler(pm: _PProjectM; + event: TProjectMEvent; + keycode: TProjectMKeycode; + modifier: TProjectMModifier); cdecl; external libprojectM name 'key_handler'; + + + + +{**************** EXTERNAL SECTION ****************} + + +constructor TProjectM.Create(gx, gy: integer; fps: integer; + texsize: integer; width, height: integer; + presetsDir, fontsDir: string); +var + pm: _PProjectM; +begin + New(pm); + _pm := pm; + _projectM_reset(pm); + + pm^.fullscreen := 0; + pm^.renderTarget^.texsize := texsize; + pm^.gx := gx; + pm^.gy := gy; + pm^.fps := fps; + pm^.renderTarget^.usePbuffers := 0; + + pm^.fontURL := PChar(fontsDir); + pm^.presetURL := PChar(presetsDir); + + _projectM_init(pm); +end; + +procedure TProjectM.ResetGL(width, height: Integer); +begin + _projectM_resetGL(_pm, width, height); +end; + +procedure TProjectM.SetTitle(title: string); +var pm: _PProjectM; +begin + pm := _pm; + pm^.title := PChar(title); + pm^.showtitle := 1; +end; + +procedure TProjectM.RenderFrame(); +begin + _renderFrame(_pm); +end; + +procedure TProjectM.AddPCMfloat(pcmData: PSingle; samples: integer); +begin + _addPCMfloat(pcmData, samples); +end; + +procedure TProjectM.AddPCM16(pcmData: PPCM16); +begin + _addPCM16(pcmData); +end; + +procedure TProjectM.AddPCM16Data(pcmData: PSmallint; samples: Smallint); +begin + _addPCM16Data(pcmData, samples); +end; + +procedure TProjectM.AddPCM8_512(pcmData: PPCM8_512); +begin + _addPCM8_512(pcmData); +end; + +procedure TProjectM.KeyHandler(event: TProjectMEvent; + keycode: TProjectMKeycode; + modifier: TProjectMModifier); +begin + _key_handler(_pm, event, keycode, modifier); +end; + +procedure TProjectM.RandomPreset(); +begin + KeyHandler(PROJECTM_KEYDOWN, PROJECTM_K_r_LOWERCASE, PROJECTM_KMOD_LSHIFT); +end; + +procedure TProjectM.PreviousPreset(); +begin + KeyHandler(PROJECTM_KEYDOWN, PROJECTM_K_p_LOWERCASE, PROJECTM_KMOD_LSHIFT); +end; + +procedure TProjectM.NextPreset(); +begin + KeyHandler(PROJECTM_KEYDOWN, PROJECTM_K_n_LOWERCASE, PROJECTM_KMOD_LSHIFT); +end; + +procedure TProjectM.ToggleShowPresetNames(); +begin + KeyHandler(PROJECTM_KEYDOWN, PROJECTM_K_F3, PROJECTM_KMOD_LSHIFT); +end; + +destructor TProjectM.Destroy(); +begin + Dispose(_pm); + _pm := nil; +end; + +end. diff --git a/Game/Code/lib/projectM/1.0/projectM.pas b/Game/Code/lib/projectM/1.0/projectM.pas new file mode 100644 index 00000000..47da36cc --- /dev/null +++ b/Game/Code/lib/projectM/1.0/projectM.pas @@ -0,0 +1,336 @@ +unit projectM;
+
+{$IFDEF FPC}
+ {$IFNDEF win32}
+ {$LINKLIB libprojectM}
+ {$ENDIF}
+ {$MODE DELPHI}
+ {$PACKENUM 4}
+ {$PACKRECORDS C}
+{$ENDIF}
+
+interface
+
+uses
+ OpenGL12;
+
+const
+{$IFDEF win32}
+ libprojectM = 'projectM-cwrapper.dll';
+{$ELSE}
+ libprojectM = 'libprojectM-cwrapper.so';
+{$ENDIF}
+
+const
+ PROJECTM_VERSION = '1.00.00';
+ PROJECTM_TITLE = 'projectM 1.00.00';
+
+type
+ // 16bit non-interleaved data
+ TPCM16 = array[0..1, 0..511] of Smallint;
+ PPCM16 = ^TPCM16;
+ // 8bit non-interleaved data (512 samples)
+ TPCM8_512 = array[0..1, 0..511] of byte;
+ PPCM8_512 = ^TPCM8_512;
+ // 8bit non-interleaved data (1024 samples)
+ TPCM8_1024 = array[0..1, 0..1023] of byte;
+ PPCM8_1024 = ^TPCM8_512;
+
+{ Event types }
+type
+ TProjectMEvent = integer;
+const
+ PROJECTM_KEYUP = 0;
+ PROJECTM_KEYDOWN = 1;
+ PROJECTM_VIDEORESIZE = 2;
+ PROJECTM_VIDEOQUIT = 3;
+ PROJECTM_NONE = 4;
+
+{ Keycodes }
+type
+ TProjectMKeycode = integer;
+const
+ PROJECTM_K_RETURN = 0;
+ PROJECTM_K_RIGHT = 1;
+ PROJECTM_K_LEFT = 2;
+ PROJECTM_K_UP = 3;
+ PROJECTM_K_DOWN = 4;
+ PROJECTM_K_PAGEUP = 5;
+ PROJECTM_K_PAGEDOWN = 6;
+ PROJECTM_K_INSERT = 7;
+ PROJECTM_K_DELETE = 8;
+ PROJECTM_K_ESCAPE = 9;
+ PROJECTM_K_LSHIFT = 10;
+ PROJECTM_K_RSHIFT = 11;
+ PROJECTM_K_CAPSLOCK = 12;
+ PROJECTM_K_LCTRL = 13;
+ PROJECTM_K_HOME = 14;
+ PROJECTM_K_END = 15;
+ PROJECTM_K_BACKSPACE = 16;
+
+ PROJECTM_K_F1 = 17;
+ PROJECTM_K_F2 = (PROJECTM_K_F1 + 1);
+ PROJECTM_K_F3 = (PROJECTM_K_F1 + 2);
+ PROJECTM_K_F4 = (PROJECTM_K_F1 + 3);
+ PROJECTM_K_F5 = (PROJECTM_K_F1 + 4);
+ PROJECTM_K_F6 = (PROJECTM_K_F1 + 5);
+ PROJECTM_K_F7 = (PROJECTM_K_F1 + 6);
+ PROJECTM_K_F8 = (PROJECTM_K_F1 + 7);
+ PROJECTM_K_F9 = (PROJECTM_K_F1 + 8);
+ PROJECTM_K_F10 = (PROJECTM_K_F1 + 9);
+ PROJECTM_K_F11 = (PROJECTM_K_F1 + 10);
+ PROJECTM_K_F12 = (PROJECTM_K_F1 + 11);
+
+ PROJECTM_K_0 = 48;
+ PROJECTM_K_1 = (PROJECTM_K_0 + 1);
+ PROJECTM_K_2 = (PROJECTM_K_0 + 2);
+ PROJECTM_K_3 = (PROJECTM_K_0 + 3);
+ PROJECTM_K_4 = (PROJECTM_K_0 + 4);
+ PROJECTM_K_5 = (PROJECTM_K_0 + 5);
+ PROJECTM_K_6 = (PROJECTM_K_0 + 6);
+ PROJECTM_K_7 = (PROJECTM_K_0 + 7);
+ PROJECTM_K_8 = (PROJECTM_K_0 + 8);
+ PROJECTM_K_9 = (PROJECTM_K_0 + 9);
+
+ { Upper case }
+ PROJECTM_K_A_UPPERCASE = 65;
+ PROJECTM_K_B_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 1);
+ PROJECTM_K_C_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 2);
+ PROJECTM_K_D_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 3);
+ PROJECTM_K_E_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 4);
+ PROJECTM_K_F_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 5);
+ PROJECTM_K_G_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 6);
+ PROJECTM_K_H_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 7);
+ PROJECTM_K_I_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 8);
+ PROJECTM_K_J_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 9);
+ PROJECTM_K_K_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 10);
+ PROJECTM_K_L_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 11);
+ PROJECTM_K_M_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 12);
+ PROJECTM_K_N_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 13);
+ PROJECTM_K_O_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 14);
+ PROJECTM_K_P_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 15);
+ PROJECTM_K_Q_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 16);
+ PROJECTM_K_R_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 17);
+ PROJECTM_K_S_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 18);
+ PROJECTM_K_T_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 19);
+ PROJECTM_K_U_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 20);
+ PROJECTM_K_V_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 21);
+ PROJECTM_K_W_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 22);
+ PROJECTM_K_X_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 23);
+ PROJECTM_K_Y_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 24);
+ PROJECTM_K_Z_UPPERCASE = (PROJECTM_K_A_UPPERCASE + 25);
+
+ { Lower case }
+ PROJECTM_K_a_LOWERCASE = 97;
+ PROJECTM_K_b_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 1);
+ PROJECTM_K_c_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 2);
+ PROJECTM_K_d_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 3);
+ PROJECTM_K_e_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 4);
+ PROJECTM_K_f_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 5);
+ PROJECTM_K_g_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 6);
+ PROJECTM_K_h_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 7);
+ PROJECTM_K_i_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 8);
+ PROJECTM_K_j_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 9);
+ PROJECTM_K_k_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 10);
+ PROJECTM_K_l_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 11);
+ PROJECTM_K_m_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 12);
+ PROJECTM_K_n_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 13);
+ PROJECTM_K_o_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 14);
+ PROJECTM_K_p_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 15);
+ PROJECTM_K_q_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 16);
+ PROJECTM_K_r_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 17);
+ PROJECTM_K_s_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 18);
+ PROJECTM_K_t_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 19);
+ PROJECTM_K_u_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 20);
+ PROJECTM_K_v_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 21);
+ PROJECTM_K_w_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 22);
+ PROJECTM_K_x_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 23);
+ PROJECTM_K_y_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 24);
+ PROJECTM_K_z_LOWERCASE = (PROJECTM_K_a_LOWERCASE + 25);
+
+ PROJECTM_K_NONE = (PROJECTM_K_z_LOWERCASE + 1);
+
+{ Modifiers }
+type
+ TProjectMModifier = integer;
+const
+ PROJECTM_KMOD_LSHIFT = 0;
+ PROJECTM_KMOD_RSHIFT = 1;
+ PROJECTM_KMOD_CAPS = 2;
+ PROJECTM_KMOD_LCTRL = 3;
+ PROJECTM_KMOD_RCTRL = 4;
+
+
+type
+ PProjectM = ^TProjectM;
+ TProjectM = class(TObject)
+ private
+ _pm: Pointer;
+ public
+ constructor Create(gx, gy: integer; fps: integer;
+ texsize: integer; width, height: integer;
+ presetsDir, fontsDir: string;
+ titleFont: string = 'Vera.ttf';
+ menuFont: string = 'Vera.ttf'); overload;
+ constructor Create(configFile: string); overload;
+
+ procedure ResetGL(width, height: Integer);
+ procedure SetTitle(title: string);
+ procedure RenderFrame();
+
+ procedure AddPCMfloat(pcmData: PSingle; samples: integer);
+ procedure AddPCM16(pcmData: PPCM16);
+ procedure AddPCM16Data(pcmData: PSmallint; samples: Smallint);
+ procedure AddPCM8_512(pcmData: PPCM8_512);
+ procedure AddPCM8_1024(pcmData: PPCM8_1024);
+
+ procedure RandomPreset();
+ procedure PreviousPreset();
+ procedure NextPreset();
+ procedure ToggleShowPresetNames();
+
+ function InitRenderToTexture(): GLuint;
+
+ procedure KeyHandler(event: TProjectMEvent;
+ keycode: TProjectMKeycode;
+ modifier: TProjectMModifier);
+
+ destructor Destroy(); override;
+ end;
+
+implementation
+
+
+{**************** INTERNAL SECTION ****************}
+
+
+type
+ _PProjectM = Pointer;
+
+{ projectM.hpp declarations }
+function _projectM_create1(config_file: PChar): _PProjectM; cdecl; external libprojectM name 'projectM_create1';
+function _projectM_create2(gx: integer; gy: integer; fps: integer;
+ texsize: integer; width: integer; height: integer;
+ preset_url: PChar; title_fonturl: PChar; title_menuurl: PChar): _PProjectM; cdecl; external libprojectM name 'projectM_create2';
+
+procedure _projectM_resetGL(pm: _PProjectM; width: integer; height: integer); cdecl; external libprojectM name 'projectM_resetGL';
+procedure _projectM_setTitle(pm: _PProjectM; title: PChar); cdecl; external libprojectM name 'projectM_setTitle';
+procedure _projectM_renderFrame(pm: _PProjectM); cdecl; external libprojectM name 'projectM_renderFrame';
+function _projectM_initRenderToTexture(pm: _PProjectM): Cardinal; cdecl; external libprojectM name 'projectM_initRenderToTexture';
+
+procedure _projectM_free(pm: _PProjectM); cdecl; external libprojectM name 'projectM_free';
+
+procedure _projectM_key_handler(pm: _PProjectM; event: TProjectMEvent;
+ keycode: TProjectMKeycode; modifier: TProjectMModifier); cdecl; external libprojectM name 'projectM_key_handler';
+
+{ PCM.hpp declarations }
+procedure _PCM_addPCMfloat(pm: _PProjectM; pcm_data: PSingle; samples: integer); cdecl; external libprojectM name 'PCM_addPCMfloat';
+procedure _PCM_addPCM16(pm: _PProjectM; pcm_data: PPCM16); cdecl; external libprojectM name 'PCM_addPCM16';
+procedure _PCM_addPCM16Data(pm: _PProjectM; pcm_data: PSmallint; samples: Smallint); cdecl; external libprojectM name 'PCM_addPCM16Data';
+procedure _PCM_addPCM8_512(pm: _PProjectM; pcm_data: PPCM8_512); cdecl; external libprojectM name 'PCM_addPCM8_512';
+procedure _PCM_addPCM8_1024(pm: _PProjectM; pcm_data: PPCM8_1024); cdecl; external libprojectM name 'PCM_addPCM8';
+
+
+{**************** EXTERNAL SECTION ****************}
+
+constructor TProjectM.Create(gx, gy: integer; fps: integer;
+ texsize: integer; width, height: integer;
+ presetsDir, fontsDir: string; titleFont, menuFont: string);
+begin
+ _pm := _projectM_create2(gx, gy, fps, texsize, width, height,
+ PChar(presetsDir),
+ PChar(fontsDir + '/' + titleFont),
+ PChar(fontsDir + '/' + menuFont))
+end;
+
+constructor TProjectM.Create(configFile: string);
+begin
+ _pm := _projectM_create1(PChar(configFile));
+end;
+
+procedure TProjectM.ResetGL(width, height: Integer);
+begin
+ _projectM_resetGL(_pm, width, height);
+end;
+
+procedure TProjectM.SetTitle(title: string);
+begin
+ _projectM_setTitle(_pm, PChar(title));
+end;
+
+procedure TProjectM.RenderFrame();
+begin
+ _projectM_renderFrame(_pm);
+end;
+
+procedure TProjectM.AddPCMfloat(pcmData: PSingle; samples: integer);
+begin
+ _PCM_addPCMfloat(_pm, pcmData, samples);
+end;
+
+procedure TProjectM.AddPCM16(pcmData: PPCM16);
+begin
+ _PCM_addPCM16(_pm, pcmData);
+end;
+
+{**
+ * Passes interleaved stereo PCM-samples to projectM.
+ *}
+procedure TProjectM.AddPCM16Data(pcmData: PSmallint; samples: Smallint);
+begin
+ _PCM_addPCM16Data(_pm, pcmData, samples);
+end;
+
+procedure TProjectM.AddPCM8_512(pcmData: PPCM8_512);
+begin
+ _PCM_addPCM8_512(_pm, pcmData);
+end;
+
+procedure TProjectM.AddPCM8_1024(pcmData: PPCM8_1024);
+begin
+ _PCM_addPCM8_1024(_pm, pcmData);
+end;
+
+{**
+ * If the result is > -1 projectM will render to a texture.
+ * The texture-ID is the return-value.
+ *}
+function TProjectM.InitRenderToTexture(): GLuint;
+begin
+ result := _projectM_initRenderToTexture(_pm);
+end;
+
+procedure TProjectM.KeyHandler(event: TProjectMEvent;
+ keycode: TProjectMKeycode;
+ modifier: TProjectMModifier);
+begin
+ _projectM_key_handler(_pm, event, keycode, modifier);
+end;
+
+procedure TProjectM.RandomPreset();
+begin
+ KeyHandler(PROJECTM_KEYDOWN, PROJECTM_K_r_LOWERCASE, PROJECTM_KMOD_LSHIFT);
+end;
+
+procedure TProjectM.PreviousPreset();
+begin
+ KeyHandler(PROJECTM_KEYDOWN, PROJECTM_K_p_LOWERCASE, PROJECTM_KMOD_LSHIFT);
+end;
+
+procedure TProjectM.NextPreset();
+begin
+ KeyHandler(PROJECTM_KEYDOWN, PROJECTM_K_n_LOWERCASE, PROJECTM_KMOD_LSHIFT);
+end;
+
+procedure TProjectM.ToggleShowPresetNames();
+begin
+ KeyHandler(PROJECTM_KEYDOWN, PROJECTM_K_F3, PROJECTM_KMOD_LSHIFT);
+end;
+
+destructor TProjectM.Destroy();
+begin
+ _projectM_free(_pm);
+ _pm := nil;
+end;
+
+end.
diff --git a/Game/Code/lib/requirements.txt b/Game/Code/lib/requirements.txt new file mode 100644 index 00000000..a8cd99eb --- /dev/null +++ b/Game/Code/lib/requirements.txt @@ -0,0 +1,40 @@ +Included in SVN ..
+---------------------------------------------------------------------------
+ +Jedi-sdl
+ http://sourceforge.net/projects/jedi-sdl
+
+pngImage
+ http://pngdelphi.sourceforge.net/
+
+BASS.pas
+ http://www.un4seen.com/download.php?bass23
+
+zlportio
+ http://www.specosoft.com/en/download.html
+
+ffmpeg
+ http://www.iversenit.dk/dev/ffmpeg-headers/
+
+SQLLite Wrapper
+ http://www.itwriting.com/sqlitesimple.php
+
+======================================
+For LINUX build
+======================================
+On top of the above pas files, you will need development libraries for them.
+
+here are the instructions needed to compile on ubunty ( 7.04 )
+
+ sudo apt-get install libavcodec-dev libavformat-dev libsqlite3-dev libsdl-ttf2.0-dev libsdl-image1.2-dev portaudio19-dev + + in order to build the configure file ( with autogen.sh ) + + sudo apt-get install automake autoconf + + +for Fedora 8 ( contributed by kdub ) + + yum install ffmpeg-devel portaudio-devel SDL_ttf-devel SDL_image-devel sqlite-devel
+
+ diff --git a/Game/Code/lib/zlportio/Example/README.TXT b/Game/Code/lib/zlportio/Example/README.TXT new file mode 100644 index 00000000..dd71c689 --- /dev/null +++ b/Game/Code/lib/zlportio/Example/README.TXT @@ -0,0 +1,27 @@ +
+PortIO example
+Copyright (C) 2001 Zloba Alexander
+http://www.specosoft.com
+Description
+-----------
+ This example show how tow to get direct access port input and output under
+ all versions of Microsoft Windows using ZlPortio library,
+
+Terms of Use
+------------
+
+This software is provided "as is", without any guarantee made
+as to its suitability or fitness for any particular use. It may
+contain bugs, so use of this tool is at your own risk. We take
+no responsilbity for any damage that may unintentionally be caused
+through its use.
+
+Reporting Problems
+------------------
+
+If you encounter problems, please visit http://www.specosoft.com
+and download the latest version to see if the issue has been resolved.
+If not, please send a bug report to:
+
+ zal@specosoft.com
+
diff --git a/Game/Code/lib/zlportio/Example/install.txt b/Game/Code/lib/zlportio/Example/install.txt new file mode 100644 index 00000000..8d4f45a6 --- /dev/null +++ b/Game/Code/lib/zlportio/Example/install.txt @@ -0,0 +1,6 @@ +
+Installation:
+
+Copy files: zlportio.pas, ddkint.pas to your project directory
+or common unit directory.
+
diff --git a/Game/Code/lib/zlportio/Example/mainform.dfm b/Game/Code/lib/zlportio/Example/mainform.dfm Binary files differnew file mode 100644 index 00000000..42608286 --- /dev/null +++ b/Game/Code/lib/zlportio/Example/mainform.dfm diff --git a/Game/Code/lib/zlportio/Example/mainform.pas b/Game/Code/lib/zlportio/Example/mainform.pas new file mode 100644 index 00000000..295958c2 --- /dev/null +++ b/Game/Code/lib/zlportio/Example/mainform.pas @@ -0,0 +1,205 @@ +{$A-,H+}
+unit mainform;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
+ StdCtrls,zlportio, ComCtrls, shellapi,rdtsc;
+
+type
+ TMain = class(TForm)
+ lb1: TLabel;
+ ePort: TEdit;
+ lb2: TLabel;
+ eData: TEdit;
+ eRData: TEdit;
+ btnExit: TButton;
+ lb3: TLabel;
+ coDataType: TComboBox;
+ Lb4: TLabel;
+ gb1: TGroupBox;
+ sbBar: TStatusBar;
+ lb5: TLabel;
+ btnWrite: TButton;
+ btnRead: TButton;
+ cbDirect: TCheckBox;
+ llbWWW: TLabel;
+ procedure btnExitClick(Sender: TObject);
+ procedure ePortKeyUp(Sender: TObject; var Key: Word;
+ Shift: TShiftState);
+ procedure ePortKeyPress(Sender: TObject; var Key: Char);
+ procedure FormCreate(Sender: TObject);
+ procedure coDataTypeChange(Sender: TObject);
+ procedure ePortKeyDown(Sender: TObject; var Key: Word;
+ Shift: TShiftState);
+ procedure btnWriteClick(Sender: TObject);
+ procedure eDataKeyDown(Sender: TObject; var Key: Word;
+ Shift: TShiftState);
+ procedure btnReadClick(Sender: TObject);
+ procedure cbDirectClick(Sender: TObject);
+ procedure llbWWWClick(Sender: TObject);
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ procedure setrdata(const Data:dword);
+ function str2int(const value:string;const HEX:boolean):integer;
+ end;
+
+var
+ Main: TMain;
+implementation
+
+{$R *.DFM}
+{$R-}
+
+function TMain.str2int(const value:string;const HEX:boolean):integer;
+begin
+ if HEX then
+ result := strtoint('$' + value)
+ else
+ result := strtoint(value);
+end;
+
+
+procedure TMain.btnExitClick(Sender: TObject);
+begin
+ close;
+end;
+
+procedure TMain.ePortKeyUp(Sender: TObject; var Key: Word;
+ Shift: TShiftState);
+begin
+try
+ Case key of
+ 38: begin
+ key := 0;
+ end;
+ 40: begin
+ key := 0;
+ end
+ end;
+except
+end;
+end;
+
+procedure TMain.ePortKeyPress(Sender: TObject; var Key: Char);
+begin
+ // filter on hex
+ if pos(key,#13#8'0123456789abcdefABCDEF')=0 then
+ key := #0;
+end;
+
+procedure TMain.FormCreate(Sender: TObject);
+begin
+ coDataType.itemindex :=0;
+ coDataType.Tag := 2;
+ if ZLIOStarted then
+ sbBar.SimpleText := 'Driver successfully started !'
+ else
+ sbBar.SimpleText := 'Couldnt start driver. Something wrong !';
+end;
+
+procedure TMain.coDataTypeChange(Sender: TObject);
+var s:string;
+begin
+ coDataType.Tag := 2 shl (coDataType.itemindex);
+ erdata.MaxLength := coDataType.Tag;
+ edata.MaxLength := coDataType.Tag;
+ s := edata.Text;
+ delete(s,1,length(s)-coDataType.Tag);
+ edata.text := s;
+end;
+
+procedure TMain.ePortKeyDown(Sender: TObject; var Key: Word;
+ Shift: TShiftState);
+var Port,data:dword;
+begin
+try
+ try
+ Port := str2int(ePort.Text,true);
+ except
+ Port := 0;
+ end;
+ Case key of
+ 13: begin
+ zlioportwrite(port,coDataType.itemindex,str2int(eData.Text, true));
+ end;
+ 38: begin
+ inc(Port);
+ ePort.Text := inttohex(Port,3);
+ key := 0;
+ end;
+ 40: begin
+ if port > 0 then
+ dec(Port);
+ ePort.Text := inttohex(Port,3);
+ key := 0;
+ end
+ end;
+ setthreadpriority(GetCurrentThread,THREAD_PRIORITY_TIME_CRITICAL);
+ data := zlioportread(Port,coDataType.itemindex);
+ setrdata(data);
+except
+end;
+
+end;
+
+procedure TMain.setrdata(const Data:dword);
+begin
+ erData.Text := inttohex(Data,coDataType.Tag);
+end;
+
+procedure TMain.btnWriteClick(Sender: TObject);
+var i:word;
+begin
+ i := 13;
+ ePortKeyDown( self,i,[])
+end;
+
+
+
+procedure TMain.eDataKeyDown(Sender: TObject; var Key: Word;
+ Shift: TShiftState);
+var data:dword;
+begin
+ try
+ Data := str2int(eData.Text,true);
+ except Data := 0; end;
+ Case key of
+ 13: begin
+ ePortKeyDown( self,key,[])
+ end;
+ 38: begin
+ inc(Data);
+ eData.Text := inttohex(Data,coDataType.Tag);
+ key := 0;
+ end;
+ 40: begin
+ dec(Data);
+ eData.Text := inttohex(Data,coDataType.Tag);
+ key := 0;
+ end
+ end;
+
+end;
+
+procedure TMain.btnReadClick(Sender: TObject);
+var k:word;
+begin
+ k := 0;
+ ePortKeyDown(self, k,[]);
+end;
+
+procedure TMain.cbDirectClick(Sender: TObject);
+begin
+zliosetiopm(cbDirect.Checked);
+end;
+
+procedure TMain.llbWWWClick(Sender: TObject);
+begin
+ shellexecute( 0,'open','http://www.specosoft.com/update/portio_15.htm',nil,nil,SW_SHOW);
+end;
+
+end.
diff --git a/Game/Code/lib/zlportio/Example/portio.dof b/Game/Code/lib/zlportio/Example/portio.dof new file mode 100644 index 00000000..3f5c0f5c --- /dev/null +++ b/Game/Code/lib/zlportio/Example/portio.dof @@ -0,0 +1,85 @@ +[Compiler]
+A=0
+B=0
+C=0
+D=1
+E=0
+F=0
+G=1
+H=1
+I=0
+J=1
+K=0
+L=1
+M=0
+N=1
+O=1
+P=1
+Q=0
+R=0
+S=0
+T=0
+U=0
+V=1
+W=0
+X=1
+Y=2
+Z=1
+ShowHints=1
+ShowWarnings=1
+UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+[Linker]
+MapFile=0
+OutputObjs=9
+ConsoleApp=1
+DebugInfo=0
+RemoteSymbols=0
+MinStackSize=16384
+MaxStackSize=1048576
+ImageBase=4194304
+ExeDescription=
+[Directories]
+OutputDir=
+UnitOutputDir=
+PackageDLLOutputDir=
+PackageDCPOutputDir=
+SearchPath=
+Packages=Vcl50;Vclx50;VclSmp50;dclocx50;Vcldb50;dclaxserver50;zal
+Conditionals=
+DebugSourceDirs=
+UsePackages=0
+[Parameters]
+RunParams=
+HostApplication=
+[Language]
+ActiveLang=
+ProjectLang=$00000419
+RootDir=
+[Version Info]
+IncludeVerInfo=0
+AutoIncBuild=0
+MajorVer=1
+MinorVer=0
+Release=0
+Build=0
+Debug=0
+PreRelease=0
+Special=0
+Private=0
+DLL=0
+Locale=1049
+CodePage=1251
+[Version Info Keys]
+CompanyName=
+FileDescription=
+FileVersion=1.0.0.0
+InternalName=
+LegalCopyright=
+LegalTrademarks=
+OriginalFilename=
+ProductName=
+ProductVersion=1.0.0.0
+Comments=
+[HistoryLists\hlUnitAliases]
+Count=1
+Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
diff --git a/Game/Code/lib/zlportio/Example/portio.dpr b/Game/Code/lib/zlportio/Example/portio.dpr new file mode 100644 index 00000000..5d86ae5d --- /dev/null +++ b/Game/Code/lib/zlportio/Example/portio.dpr @@ -0,0 +1,14 @@ +{$A-,H+}
+program portio;
+
+uses
+ Forms,
+ mainform in 'mainform.pas' {Main};
+
+{$R *.RES}
+
+begin
+ Application.Initialize;
+ Application.CreateForm(TMain, Main);
+ Application.Run;
+end.
diff --git a/Game/Code/lib/zlportio/Example/portio.res b/Game/Code/lib/zlportio/Example/portio.res Binary files differnew file mode 100644 index 00000000..08ba56e9 --- /dev/null +++ b/Game/Code/lib/zlportio/Example/portio.res diff --git a/Game/Code/lib/zlportio/Example/zlportio.sys b/Game/Code/lib/zlportio/Example/zlportio.sys Binary files differnew file mode 100644 index 00000000..19e42319 --- /dev/null +++ b/Game/Code/lib/zlportio/Example/zlportio.sys diff --git a/Game/Code/lib/zlportio/README.TXT b/Game/Code/lib/zlportio/README.TXT new file mode 100644 index 00000000..137f5c07 --- /dev/null +++ b/Game/Code/lib/zlportio/README.TXT @@ -0,0 +1,27 @@ +
+ZLPortIO
+Copyright (C) 2001 Zloba Alexander
+http://www.specosoft.com
+Description
+-----------
+ This unit allow your application direct access port input and output under
+ all versions of Microsoft Windows,
+
+Terms of Use
+------------
+
+This software is provided "as is", without any guarantee made
+as to its suitability or fitness for any particular use. It may
+contain bugs, so use of this tool is at your own risk. We take
+no responsilbity for any damage that may unintentionally be caused
+through its use.
+
+Reporting Problems
+------------------
+
+If you encounter problems, please visit http://www.specosoft.com
+and download the latest version to see if the issue has been resolved.
+If not, please send a bug report to:
+
+ zal@specosoft.com
+
diff --git a/Game/Code/lib/zlportio/Sys/zlportio.sys b/Game/Code/lib/zlportio/Sys/zlportio.sys Binary files differnew file mode 100644 index 00000000..a897a020 --- /dev/null +++ b/Game/Code/lib/zlportio/Sys/zlportio.sys diff --git a/Game/Code/lib/zlportio/ddkint.pas b/Game/Code/lib/zlportio/ddkint.pas new file mode 100644 index 00000000..2b70ee54 --- /dev/null +++ b/Game/Code/lib/zlportio/ddkint.pas @@ -0,0 +1,253 @@ +{ -----------------------------------------------------------------------------}
+{ Copyright 2000-2001, Zloba Alexander. All Rights Reserved. }
+{ This unit can be freely used and distributed in commercial and private }
+{ environments, provided this notice is not modified in any way. }
+{ -----------------------------------------------------------------------------}
+{ Feel free to contact me if you have any questions, comments or suggestions at}
+{ zal@specosoft.com (Zloba Alexander) }
+{ You can always find the latest version of this unit at: }
+{ http://www.specosoft.com }
+
+{ -----------------------------------------------------------------------------}
+{ Date last modified: 08/10/2001 }
+{ -----------------------------------------------------------------------------}
+{ Description: }
+{ This unit include service function to work with NT drivers and some }
+{ constant from ntddk.h }
+{------------------------------------------------------------------------------}
+{ Revision History: }
+{ 1.00: + First public release }
+{ 1.10: + added compiler directives for correct compilation }
+{ 1.20: + optimized code }
+{ 1.30: + added constant for compatibility with delphi 3.0 }
+{------------------------------------------------------------------------------}
+
+{$A-,H-}
+unit ddkint;
+
+interface
+uses
+ windows,
+ winsvc;
+
+function CTL_CODE(const DeviceType,Func,Method,Access:Cardinal):cardinal;
+
+const
+ FILE_DEVICE_BEEP = $00000001;
+ FILE_DEVICE_CD_ROM = $00000002;
+ FILE_DEVICE_CD_ROM_FILE_SYSTEM = $00000003;
+ FILE_DEVICE_CONTROLLER = $00000004;
+ FILE_DEVICE_DATALINK = $00000005;
+ FILE_DEVICE_DFS = $00000006;
+ FILE_DEVICE_DISK = $00000007;
+ FILE_DEVICE_DISK_FILE_SYSTEM = $00000008;
+ FILE_DEVICE_FILE_SYSTEM = $00000009;
+ FILE_DEVICE_INPORT_PORT = $0000000a;
+ FILE_DEVICE_KEYBOARD = $0000000b;
+ FILE_DEVICE_MAILSLOT = $0000000c;
+ FILE_DEVICE_MIDI_IN = $0000000d;
+ FILE_DEVICE_MIDI_OUT = $0000000e;
+ FILE_DEVICE_MOUSE = $0000000f;
+ FILE_DEVICE_MULTI_UNC_PROVIDER = $00000010;
+ FILE_DEVICE_NAMED_PIPE = $00000011;
+ FILE_DEVICE_NETWORK = $00000012;
+ FILE_DEVICE_NETWORK_BROWSER = $00000013;
+ FILE_DEVICE_NETWORK_FILE_SYSTEM= $00000014;
+ FILE_DEVICE_NULL = $00000015;
+ FILE_DEVICE_PARALLEL_PORT = $00000016;
+ FILE_DEVICE_PHYSICAL_NETCARD = $00000017;
+ FILE_DEVICE_PRINTER = $00000018;
+ FILE_DEVICE_SCANNER = $00000019;
+ FILE_DEVICE_SERIAL_MOUSE_PORT = $0000001a;
+ FILE_DEVICE_SERIAL_PORT = $0000001b;
+ FILE_DEVICE_SCREEN = $0000001c;
+ FILE_DEVICE_SOUND = $0000001d;
+ FILE_DEVICE_STREAMS = $0000001e;
+ FILE_DEVICE_TAPE = $0000001f;
+ FILE_DEVICE_TAPE_FILE_SYSTEM = $00000020;
+ FILE_DEVICE_TRANSPORT = $00000021;
+ FILE_DEVICE_UNKNOWN = $00000022;
+ FILE_DEVICE_VIDEO = $00000023;
+ FILE_DEVICE_VIRTUAL_DISK = $00000024;
+ FILE_DEVICE_WAVE_IN = $00000025;
+ FILE_DEVICE_WAVE_OUT = $00000026;
+ FILE_DEVICE_8042_PORT = $00000027;
+ FILE_DEVICE_NETWORK_REDIRECTOR = $00000028;
+ FILE_DEVICE_BATTERY = $00000029;
+ FILE_DEVICE_BUS_EXTENDER = $0000002a;
+ FILE_DEVICE_MODEM = $0000002b;
+ FILE_DEVICE_VDM = $0000002c;
+ FILE_DEVICE_MASS_STORAGE = $0000002d;
+ FILE_DEVICE_SMB = $0000002e;
+ FILE_DEVICE_KS = $0000002f;
+ FILE_DEVICE_CHANGER = $00000030;
+ FILE_DEVICE_SMARTCARD = $00000031;
+ FILE_DEVICE_ACPI = $00000032;
+ FILE_DEVICE_DVD = $00000033;
+ FILE_DEVICE_FULLSCREEN_VIDEO = $00000034;
+ FILE_DEVICE_DFS_FILE_SYSTEM = $00000035;
+ FILE_DEVICE_DFS_VOLUME = $00000036;
+ FILE_DEVICE_SERENUM = $00000037;
+ FILE_DEVICE_TERMSRV = $00000038;
+ FILE_DEVICE_KSEC = $00000039;
+
+ FILE_DEVICE_KRNLDRVR = $80ff;
+
+ METHOD_BUFFERED = 0;
+ METHOD_IN_DIRECT = 1;
+ METHOD_OUT_DIRECT = 2;
+ METHOD_NEITHER = 3;
+
+ FILE_ANY_ACCESS = 0;
+ FILE_SPECIAL_ACCESS = (FILE_ANY_ACCESS);
+ FILE_READ_ACCESS = ( $0001 ); // file & pipe
+ FILE_WRITE_ACCESS = ( $0002 ); // file & pipe
+
+ {$IFDEF VER100 or VER110}
+ // for compatibilty with delphi 3.0
+const
+ SERVICE_KERNEL_DRIVER = $00000001;
+ SERVICE_DEMAND_START = $00000003;
+ SERVICE_ERROR_NORMAL = $00000001;
+
+{$ENDIF}
+
+function driverstart(const name:pchar):integer;
+function driverstop(const name:pchar):integer;
+
+// for this function must have Administrators or Power users rigths
+function driverinstall(const path,name:pchar):integer;
+function driverremove(const name:pchar):integer;
+
+
+// exlpanation function
+function messagestring(const error:integer):string;
+
+implementation
+
+function CTL_CODE(const DeviceType,Func,Method,Access:Cardinal):cardinal;
+begin
+ Result := DeviceType shl 16 or Access shl 14 or Func shl 2 or Method;
+end;
+
+
+function driverinstall(const path,name:pchar):integer;
+var hService: SC_HANDLE;
+ hSCMan : SC_HANDLE;
+begin
+
+ Result := 0;
+
+ hSCMan := OpenSCManager(nil, nil, SC_MANAGER_ALL_ACCESS);
+ if hSCMan = 0 then begin
+ result := getlasterror;
+ exit;
+ end;
+
+ hService := CreateService(hSCMan, name,name,
+ SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START,
+ SERVICE_ERROR_NORMAL, path,
+ nil, nil, nil, nil, nil);
+
+ if (hService = 0) then begin
+ result := getlasterror;
+ CloseServiceHandle(hSCMan);
+ exit;
+ end
+ else
+ CloseServiceHandle(hService);
+ CloseServiceHandle(hSCMan);
+end;
+
+function driverstart(const name:pchar):integer;
+var
+ hService: SC_HANDLE;
+ hSCMan : SC_HANDLE;
+ args:pchar;
+begin
+
+ hSCMan := OpenSCManager(nil, nil, SC_MANAGER_CONNECT);
+ if hSCMan = 0 then begin
+ result := getlasterror;
+ exit;
+ end;
+
+ // get a handle to the service
+ hService := OpenService(hSCMan, name, SERVICE_START);
+ if hService <> 0 then Begin
+ // start the driver
+ args := nil;
+ Result := 0;
+ if integer(StartService(hService, 0, args ))=0 then
+ result := getlasterror;
+ CloseServiceHandle(hService);
+ end
+ else
+ result := getlasterror;
+ CloseServiceHandle(hSCMan);
+end;
+
+function driverstop(const name:pchar):integer;
+Var
+ serviceStatus: TServiceStatus;
+ hService: SC_HANDLE;
+ hSCMan : SC_HANDLE;
+begin
+
+ hSCMan := OpenSCManager(nil, nil, SC_MANAGER_CONNECT);
+ if hSCMan = 0 then begin
+ result := getlasterror;
+ exit;
+ end;
+
+ // get a handle to the service
+ hService := OpenService(hSCMan, Name, SERVICE_STOP);
+ if hService <> 0 then Begin
+ // start the driver
+ Result := 0;
+ if integer(ControlService(hService, SERVICE_CONTROL_STOP, serviceStatus))=0 then
+ result := getlasterror;
+ CloseServiceHandle(hService);
+ end
+ else
+ result := getlasterror;
+ CloseServiceHandle(hSCMan);
+end;
+
+function driverremove(const name:pchar):integer;
+Var
+ hService: SC_HANDLE;
+ hSCMan : SC_HANDLE;
+begin
+
+ hSCMan := OpenSCManager(nil, nil, SC_MANAGER_ALL_ACCESS);
+ if hSCMan = 0 then begin
+ result := getlasterror;
+ exit;
+ end;
+
+ // get a handle to the service
+ hService := OpenService(hSCMan, Name, SERVICE_ALL_ACCESS);
+ if hService <> 0 then Begin
+ // remove driver description from the registry
+ Result := 0;
+ if integer(DeleteService(hService)) = 0 then
+ result := getlasterror;
+ CloseServiceHandle(hService);
+ end
+ else
+ result := getlasterror;
+ CloseServiceHandle(hSCMan);
+end;
+
+function messagestring(const error:integer):string;
+var p:pchar;
+begin
+ GetMem(p, 200);
+ FillChar(p^, 200, 0);
+ formatmessage(FORMAT_MESSAGE_FROM_SYSTEM,nil,error,0,p,199,nil);
+ Result := p;
+ freemem(p,200);
+end;
+
+end.
diff --git a/Game/Code/lib/zlportio/install.txt b/Game/Code/lib/zlportio/install.txt new file mode 100644 index 00000000..7a92b29d --- /dev/null +++ b/Game/Code/lib/zlportio/install.txt @@ -0,0 +1,8 @@ +
+Installation:
+
+Copy files: zlportio.pas, ddkint.pas to your project directory
+or common unit directory.
+
+Copy file zlportio.sys to your project directory.
+It should be in the one directory with you application.
diff --git a/Game/Code/lib/zlportio/zlportio.pas b/Game/Code/lib/zlportio/zlportio.pas new file mode 100644 index 00000000..2cf57334 --- /dev/null +++ b/Game/Code/lib/zlportio/zlportio.pas @@ -0,0 +1,285 @@ +{ -----------------------------------------------------------------------------}
+{ Copyright 2000-2001, Zloba Alexander. All Rights Reserved. }
+{ This unit can be freely used and distributed in commercial and private }
+{ environments, provided this notice is not modified in any way. }
+{ -----------------------------------------------------------------------------}
+{ Feel free to contact me if you have any questions, comments or suggestions at}
+{ zal@specosoft.com (Zloba Alexander) }
+{ You can always find the latest version of this unit at: }
+{ http://www.specosoft.com }
+
+{ -----------------------------------------------------------------------------}
+{ Date last modified: 08/10/2001 }
+{ -----------------------------------------------------------------------------}
+{ ZLPortIO driver interface unit v1.20 }
+{ -----------------------------------------------------------------------------}
+{ Description: }
+{ This unit allow your application direct access port input and output under }
+{ all versions of Microsoft Windows® }
+{ Depends: }
+{ zlportio.sys ddkint.pas }
+{ You must distribute zlportio.sys with your application }
+{ Procedures and functions: }
+{ procedure zlioportread( const Port,DataType:dword ):dword; }
+{ procedure zlioportwrite( const Port,DataType,Data:dword ); }
+{ }
+{ function portreadb( const Port:dword ):byte; }
+{ function portreadw( const Port:dword ):word; }
+{ function portreadl( const Port:dword ):dword; }
+{ }
+{ procedure portwriteb( const Port:Dword;const Data:byte ); }
+{ procedure portwritew( const Port:dword;const Data:word ); }
+{ procedure portwritel( const Port,Data:dword ); }
+{ }
+{ Examples: }
+{ // get data bits from LPT port }
+{ databits := portreadb( $378 ) }
+{ // set data bits from LPT port }
+{ portwriteb( $378, databits ) }
+{ // The second parameter determine the databus length for operation }
+{ -----------------------------------------------------------------------------}
+{ Revision History: }
+{ 1.00: + First public release }
+{ 1.10: + Added new functions (portreadX,portwriteX) for convenience of usage }
+{ 1.20: + Added new function (zliosetiopm) for enabling direct access to ports}
+{ 1.30: + added compiler directives for correct compilation }
+{ 1.40: + added opportunity to run multiply instances client to driver }
+{ 1.50: - fixed bug with work under win98 }
+{------------------------------------------------------------------------------}
+
+{$A-,H-}
+unit zlportio;
+
+interface
+
+uses windows,
+ sysutils,
+ ddkint;
+
+Const
+ ZLIO_BYTE = 0;
+ ZLIO_WORD = 1;
+ ZLIO_DWORD = 2;
+
+var
+
+// if TRUE then driver was started
+// in other case something wrong
+// We start driver in initialization section of unit.
+
+ ZlIOStarted:boolean = false;
+
+// if TRUE then we can use asm IN,OUT under NT/2000
+// see zliosetiopm for more details
+ ZlIODirect:boolean = false;
+
+// handle to opened driver
+
+ HZLIO:THandle;
+
+
+function portreadb( const Port:dword ):byte;
+function portreadw( const Port:dword ):word;
+function portreadl( const Port:dword ):dword;
+
+procedure portwriteb( const Port:Dword;const Data:byte );
+procedure portwritew( const Port:dword;const Data:word );
+procedure portwritel( const Port,Data:dword );
+
+
+procedure zlioportwrite( const Port,DataType,Data:dword );
+function zlioportread( const Port,DataType:dword ):dword;
+
+// if you need the best perfomance for your IO operations
+// call zliosetiopm(TRUE). This allow your application
+// to use asm command IN,OUT directly in your code.
+
+procedure zliosetiopm( const Direct:boolean );
+
+// internal
+
+function zliostart:boolean;
+procedure zliostop;
+
+
+implementation
+
+const
+ ZLIODriverName='zlportio';
+
+var
+ IOCTL_ZLUNI_PORT_READ:cardinal;
+ IOCTL_ZLUNI_PORT_WRITE:cardinal;
+ IOCTL_ZLUNI_IOPM_ON:cardinal;
+ IOCTL_ZLUNI_IOPM_OFF:cardinal;
+
+type
+TzlIOData = record
+ Port,DataType,Data:dword;
+end;
+
+
+procedure zlioportwrite( const Port,DataType,Data:dword );
+var resdata:TZLIOData;
+ cBR:cardinal;
+begin
+ if (not ZLIODirect) then begin
+ resdata.Port := Port;
+ resdata.Data := Data;
+ resdata.DataType := DataType;
+ if ZLIOStarted then
+ DeviceIoControl(HZLIO,IOCTL_ZLUNI_PORT_WRITE,@resdata,sizeof(resdata),nil,0,cBR,nil );
+ end
+ else begin
+ Case DataType of
+ ZLIO_BYTE : asm mov edx,Port;mov eax,data;out dx,al; end;
+ ZLIO_WORD : asm mov edx,Port;mov eax,data;out dx,ax; end;
+ ZLIO_DWORD: asm mov edx,Port;mov eax,data;out dx,eax; end;
+ end;
+ end;
+end;
+
+function zlioportread(const Port,DataType:dword):dword;
+var resdata:TZLIOData;
+ cBR:cardinal;i:dword;
+begin
+ if (not ZLIODirect) then begin
+ resdata.Port := Port;
+ resdata.DataType := DataType;
+ if ZLIOStarted then
+ DeviceIoControl(HZLIO,IOCTL_ZLUNI_PORT_READ,@resdata,sizeof(resdata),@i,sizeof(dword),cBR,nil );
+ end
+ else begin
+ Case DataType of
+ ZLIO_BYTE : asm mov edx,Port;xor eax,eax;in al,dx;mov i,eax; end;
+ ZLIO_WORD : asm mov edx,Port;xor eax,eax;in ax,dx;mov i,eax; end;
+ ZLIO_DWORD: asm mov edx,Port;xor eax,eax;in eax,dx;mov i,eax end;
+ end;
+ end;
+ result := i;
+end;
+
+function portreadb( const Port:dword ):byte;
+begin
+ Result := zlioportread(Port,ZLIO_BYTE);
+end;
+
+function portreadw( const Port:dword ):word;
+begin
+ Result := zlioportread(Port,ZLIO_WORD);
+end;
+
+function portreadl( const Port:dword ):dword;
+begin
+ Result := zlioportread(Port,ZLIO_DWORD);
+end;
+
+procedure portwriteb( const Port:Dword;const Data:byte );
+begin
+ zlioportwrite(Port,ZLIO_BYTE,Data);
+end;
+
+procedure portwritew( const Port:dword;const Data:word );
+begin
+ zlioportwrite(Port,ZLIO_WORD,Data);
+end;
+
+procedure portwritel( const Port,Data:dword );
+begin
+ zlioportwrite(Port,ZLIO_DWORD,Data);
+end;
+
+procedure zliosetiopm( const Direct:boolean );
+var cBR:cardinal;
+begin
+ if Win32Platform=VER_PLATFORM_WIN32_NT then
+ if ZLIOStarted then begin
+ if Direct then
+ DeviceIoControl(HZLIO,IOCTL_ZLUNI_IOPM_ON,nil,0,nil,0,cBR,nil )
+ else
+ DeviceIoControl(HZLIO,IOCTL_ZLUNI_IOPM_OFF,nil,0,nil,0,cBR,nil );
+ ZLIODirect := Direct;
+ end
+end;
+
+
+
+
+function zliostart;
+var dir:shortstring;
+begin
+ if Win32Platform<>VER_PLATFORM_WIN32_NT then begin
+ result := true;
+ exit;
+ end;
+// Result := false;
+ zliostop;
+ dir := ExtractFileDir(ParamStr(0))+'\'+ZLIODriverName+'.sys'#0;
+ driverinstall(pchar(@dir[1]),ZLIODriverName+#0);
+ Result := driverstart(ZLIODriverName) = 0;
+end;
+
+procedure zliostop;
+begin
+ if Win32Platform<>VER_PLATFORM_WIN32_NT then
+ exit;
+ driverstop(ZLIODriverName);
+ driverremove(ZLIODriverName);
+end;
+
+function zlioopen( var Handle:thandle):boolean;
+var cERR:integer;
+ s:string;
+begin
+ if Win32Platform<>VER_PLATFORM_WIN32_NT then begin
+ result := true;
+ exit;
+ end;
+ Result := false;
+ Handle := THandle(-1);
+ Handle := createFile('\\.\ZLPORTIO',
+ GENERIC_READ or GENERIC_WRITE,
+ 0,
+ nil,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ 0 );
+ cERR := getlasterror;
+ s := messagestring( cerr);
+ if (cERR = ERROR_ALREADY_EXISTS)or(cERR = ERROR_SUCCESS) then Result := True;
+end;
+
+procedure zlioclose( const Handle:thandle);
+begin
+ if (Win32Platform=VER_PLATFORM_WIN32_NT) then
+ closehandle(Handle);
+end;
+
+
+initialization
+
+IOCTL_ZLUNI_PORT_READ := CTL_CODE(FILE_DEVICE_KRNLDRVR, 1, METHOD_BUFFERED, FILE_ANY_ACCESS);
+IOCTL_ZLUNI_PORT_WRITE := CTL_CODE(FILE_DEVICE_KRNLDRVR, 2, METHOD_BUFFERED, FILE_ANY_ACCESS);
+IOCTL_ZLUNI_IOPM_ON := CTL_CODE(FILE_DEVICE_KRNLDRVR, 3, METHOD_BUFFERED, FILE_ANY_ACCESS);
+IOCTL_ZLUNI_IOPM_OFF := CTL_CODE(FILE_DEVICE_KRNLDRVR, 4, METHOD_BUFFERED, FILE_ANY_ACCESS);
+
+ if Win32Platform<>VER_PLATFORM_WIN32_NT then begin
+ zliostarted := true;
+ zliodirect := true;
+ end
+ else begin
+ if not zlioopen(HZLIO) then begin
+ if zliostart then
+ ZLIOStarted := zlioopen(HZLIO) or (Win32Platform<>VER_PLATFORM_WIN32_NT);
+ end
+ else
+ ZLIOStarted := true;
+ end;
+finalization
+
+if ZLIOStarted then
+ zliostop;
+
+
+
+end.
|