glBitmap by Steffen Xonna aka Lossy eX (2003-2008)
http://www.opengl24.de/index.php?cat=header&file=glbitmap

modified by Delphi OpenGL Community (http://delphigl.com/) (2013)

------------------------------------------------------------
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
------------------------------------------------------------
The glBitmap is a Delphi/FPC unit that contains several wrapper classes
to manage OpenGL texture objects. Below you can find a list of the main
functionality of this classes:
- load texture data from file (e.g. BMP, TGA, DDS, PNG, JPEG, ...)
- load texture data from several other image objects (e.g. TBitmap, TLazIntfImage, SDL Surface)
- save texture data to file (e.g. BMP, TGA, DDS, PNG, JPEG, ...)
- save texture data to several other image objects (e.g. TBitmap, TLazIntfImage, SDL Surface)
- support for many texture formats (e.g. RGB8, BGR8, RGBA8, BGRA8, ...)
- manage texture properties (e.g. Filter, Clamp, Mipmap, ...)
- upload texture data to video card
- download texture data from video card
- manipulate texture data (e.g. add alpha, remove alpha, convert to other format, switch RGB, ...)
------------------------------------------------------------
History
20-11-2013
- refactoring of the complete library
- glBitmap is managed by git, so this history is not maintenanced any longer
21-03-2010
- The define GLB_DELPHI dosn't check versions anymore. If you say you are using delphi
  then it's your problem if that isn't true. This prevents the unit for incompatibility
  with newer versions of Delphi.
- Problems with D2009+ resolved (Thanks noeska and all i forgot)
- GetPixel isn't set if you are loading textures inside the constructor (Thanks Wilson)
10-08-2008
- AddAlphaFromglBitmap used the custom pointer instead the imagedatapointer (Thanks Wilson)
- Additional Datapointer for functioninterface now has the name CustomData
24-07-2008
- AssigneAlphaToBitmap overwrites his own palette (Thanks Wilson)
- If you load an texture from an file the property Filename will be set to the name of the file
- Three new properties to attach custom data to the Texture objects
  - CustomName  (free for use string)
  - CustomNameW (free for use widestring)
  - CustomDataPointer (free for use pointer to attach other objects or complex structures)
27-05-2008
- RLE TGAs loaded much faster
26-05-2008
- fixed some problem with reading RLE TGAs.
21-05-2008
- function clone now only copys data if it's assigned and now it also copies the ID
- it seems that lazarus dont like comments in comments.
01-05-2008
- It's possible to set the id of the texture
- define GLB_NO_NATIVE_GL deactivated by default
27-04-2008
- Now supports the following libraries
  - SDL and SDL_image
  - libPNG
  - libJPEG
- Linux compatibillity via free pascal compatibility (delphi sources optional)
- BMPs now loaded manuel
- Large restructuring
- Property DataPtr now has the name Data
- Functions are more flexible between RGB(A) and BGR(A). RGB can be saved as Bitmap and will be saved as BGR
- Unused Depth removed
- Function FreeData to freeing image data added
24-10-2007
- ImageID flag of TGAs was ignored. (Thanks Zwoetzen)
15-11-2006
- Function SetBorderColor implemented (only used by opengl if wrap is set to GL_CLAMP_TO_BORDER)
- Function AddAlphaFromValue implemented to use an fixed Value as Alphachannel
- Function ReadOpenGLExtension is now only intern
29-06-2006
- pngimage now disabled by default like all other versions.
26-06-2006
- Setting up an anisotropic filter of 0 isnt allowed by nvidia (Thanks Ogridi)
22-06-2006
- Fixed some Problem with Delphi 5
- Now uses the newest version of pngimage. Makes saving pngs much easier.
22-03-2006
- Property IsCompressed and Size removed. Not really supported by Spec (Thanks Ogridi)
09-03-2006
- Internal Format ifDepth8 added
- function GrabScreen now supports all uncompressed formats
31-01-2006
- AddAlphaFromglBitmap implemented
29-12-2005
- LoadFromResource and LoadFromResourceId now needs an Instance and an ResourceType (for ID)
28-12-2005
- Width, Height and Depth internal changed to TglBitmapPixelPosition.
  property Width, Height, Depth are still existing and new property Dimension are avail
11-12-2005
- Added native OpenGL Support. Breaking the dglOpenGL "barrier".
19-10-2005
- Added function GrabScreen to class TglBitmap2D
18-10-2005
- Added support to Save images
- Added function Clone to Clone Instance
11-10-2005
- Functions now works with Cardinals for each channel. Up to 32 Bits per channel.
  Usefull for Future
- Several speed optimizations
09-10-2005
- Internal structure change. Loading of TGA, PNG and DDS improved.
  Data, format and size will now set directly with SetDataPtr.
- AddFunc now works with all Types of Images and Formats
- Some Funtions moved to Baseclass TglBitmap
06-10-2005
- Added Support to decompress DXT3 and DXT5 compressed Images.
- Added Mapping to convert data from one format into an other.
05-10-2005
- Added method ConvertTo in Class TglBitmap2D. Method allows to convert every
  supported Input format (supported by GetPixel) into any uncompresed Format
- Added Support to decompress DXT1 compressed Images.
- SwapColors replaced by ConvertTo
04-10-2005
- Added Support for compressed DDSs
- Added new internal formats (DXT1, DXT3, DXT5)
29-09-2005
- Parameter Components renamed to InternalFormat
23-09-2005
- Some AllocMem replaced with GetMem (little speed change)
- better exception handling. Better protection from memory leaks.
22-09-2005
- Added support for Direct Draw Surfaces (.DDS) (uncompressed images only)
- Added new internal formats (RGB8, RGBA8, RGBA4, RGB5A1, RGB10A2, R5G6B5)
07-09-2005
- Added support for Grayscale textures
- Added internal formats (Alpha, Luminance, LuminanceAlpha, BGR8, BGRA8)
10-07-2005
- Added support for GL_VERSION_2_0
- Added support for GL_EXT_texture_filter_anisotropic
04-07-2005
- Function FillWithColor fills the Image with one Color
- Function LoadNormalMap added
30-06-2005
- ToNormalMap allows to Create an NormalMap from the Alphachannel
- ToNormalMap now supports Sobel (nmSobel) function.
29-06-2005
- support for RLE Compressed RGB TGAs added
28-06-2005
- Class TglBitmapNormalMap added to support Normalmap generation
- Added function ToNormalMap in class TglBitmap2D to genereate normal maps from textures.
  3 Filters are supported. (4 Samples, 3x3 and 5x5)
16-06-2005
- Method LoadCubeMapClass removed
- LoadCubeMap returnvalue is now the Texture paramter. Such as LoadTextures
- virtual abstract method GenTexture in class TglBitmap now is protected
12-06-2005
- now support DescriptionFlag in LoadTga. Allows vertical flipped images to be loaded as normal
10-06-2005
- little enhancement for IsPowerOfTwo
- TglBitmap1D.GenTexture now tests NPOT Textures
06-06-2005
- some little name changes. All properties or function with Texture in name are
  now without texture in name. We have allways texture so we dosn't name it.
03-06-2005
- GenTexture now tests if texture is NPOT and NPOT-Texture are supported or
  TextureTarget is GL_TEXTURE_RECTANGLE. Else it raised an exception.
02-06-2005
- added support for GL_ARB_texture_rectangle, GL_EXT_texture_rectangle and GL_NV_texture_rectangle
25-04-2005
- Function Unbind added
- call of SetFilter or SetTextureWrap if TextureID exists results in setting properties to opengl texture.
21-04-2005
- class TglBitmapCubeMap added (allows to Create Cubemaps)
29-03-2005
- Added Support for PNG Images. (http://pngdelphi.sourceforge.net/)
  To Enable png's use the define pngimage
22-03-2005
- New Functioninterface added
- Function GetPixel added
27-11-2004
- Property BuildMipMaps renamed to MipMap
21-11-2004
- property Name removed.
- BuildMipMaps is now a set of 3 values. None, GluBuildMipmaps and SGIS_generate_mipmap
22-05-2004
- property name added. Only used in glForms!
26-11-2003
- property FreeDataAfterGenTexture is now available as default (default = true)
- BuildMipmaps now implemented in TglBitmap1D (i've forgotten it)
- function MoveMemory replaced with function Move (little speed change)
- several calculations stored in variables (little speed change)
29-09-2003
- property BuildMipsMaps added (default = true)
  if BuildMipMaps isn't set GenTextures uses glTexImage[12]D else it use gluBuild[12]dMipmaps
- property FreeDataAfterGenTexture added (default = true)
  if FreeDataAfterGenTexture is set the texturedata were deleted after the texture was generated.
- parameter DisableOtherTextureUnits of Bind removed
- parameter FreeDataAfterGeneration of GenTextures removed
12-09-2003
- TglBitmap dosn't delete data if class was destroyed (fixed)
09-09-2003
- Bind now enables TextureUnits (by params)
- GenTextures can leave data (by param)
- LoadTextures now optimal
03-09-2003
- Performance optimization in AddFunc
- procedure Bind moved to subclasses
- Added new Class TglBitmap1D to support real OpenGL 1D Textures
19-08-2003
- Texturefilter and texturewrap now also as defaults
  Minfilter = GL_LINEAR_MIPMAP_LINEAR
  Magfilter = GL_LINEAR
  Wrap(str) = GL_CLAMP_TO_EDGE
- Added new format tfCompressed to create a compressed texture.
- propertys IsCompressed, TextureSize and IsResident added
  IsCompressed and TextureSize only contains data from level 0
18-08-2003
- Added function AddFunc to add PerPixelEffects to Image
- LoadFromFunc now based on AddFunc
- Invert now based on AddFunc
- SwapColors now based on AddFunc
16-08-2003
- Added function FlipHorz
15-08-2003
- Added function LaodFromFunc to create images with function
- Added function FlipVert
- Added internal format RGB(A) if GL_EXT_bgra or OpenGL 1.2 isn't supported
29-07-2003
- Added Alphafunctions to calculate alpha per function
- Added Alpha from ColorKey using alphafunctions
28-07-2003
- First full functionally Version of glBitmap
- Support for 24Bit and 32Bit TGA Pictures added
25-07-2003
- begin of programming
