1 glBitmap by Steffen Xonna aka Lossy eX (2003-2008)
2 http://www.opengl24.de/index.php?cat=header&file=glbitmap
4 modified by Delphi OpenGL Community (http://delphigl.com/) (2013)
6 ------------------------------------------------------------
7 The contents of this file are used with permission, subject to
8 the Mozilla Public License Version 1.1 (the "License"); you may
9 not use this file except in compliance with the License. You may
10 obtain a copy of the License at
11 http://www.mozilla.org/MPL/MPL-1.1.html
12 ------------------------------------------------------------
13 The glBitmap is a Delphi/FPC unit that contains several wrapper classes
14 to manage OpenGL texture objects. Below you can find a list of the main
15 functionality of this classes:
16 - load texture data from file (e.g. BMP, TGA, DDS, PNG, JPEG, ...)
17 - load texture data from several other image objects (e.g. TBitmap, TLazIntfImage, SDL Surface)
18 - save texture data to file (e.g. BMP, TGA, DDS, PNG, JPEG, ...)
19 - save texture data to several other image objects (e.g. TBitmap, TLazIntfImage, SDL Surface)
20 - support for many texture formats (e.g. RGB8, BGR8, RGBA8, BGRA8, ...)
21 - manage texture properties (e.g. Filter, Clamp, Mipmap, ...)
22 - upload texture data to video card
23 - download texture data from video card
24 - manipulate texture data (e.g. add alpha, remove alpha, convert to other format, switch RGB, ...)
25 ------------------------------------------------------------
28 - refactoring of the complete library
29 - glBitmap is managed by git, so this history is not maintenanced any longer
31 - The define GLB_DELPHI dosn't check versions anymore. If you say you are using delphi
32 then it's your problem if that isn't true. This prevents the unit for incompatibility
33 with newer versions of Delphi.
34 - Problems with D2009+ resolved (Thanks noeska and all i forgot)
35 - GetPixel isn't set if you are loading textures inside the constructor (Thanks Wilson)
37 - AddAlphaFromglBitmap used the custom pointer instead the imagedatapointer (Thanks Wilson)
38 - Additional Datapointer for functioninterface now has the name CustomData
40 - AssigneAlphaToBitmap overwrites his own palette (Thanks Wilson)
41 - If you load an texture from an file the property Filename will be set to the name of the file
42 - Three new properties to attach custom data to the Texture objects
43 - CustomName (free for use string)
44 - CustomNameW (free for use widestring)
45 - CustomDataPointer (free for use pointer to attach other objects or complex structures)
47 - RLE TGAs loaded much faster
49 - fixed some problem with reading RLE TGAs.
51 - function clone now only copys data if it's assigned and now it also copies the ID
52 - it seems that lazarus dont like comments in comments.
54 - It's possible to set the id of the texture
55 - define GLB_NO_NATIVE_GL deactivated by default
57 - Now supports the following libraries
61 - Linux compatibillity via free pascal compatibility (delphi sources optional)
62 - BMPs now loaded manuel
64 - Property DataPtr now has the name Data
65 - Functions are more flexible between RGB(A) and BGR(A). RGB can be saved as Bitmap and will be saved as BGR
66 - Unused Depth removed
67 - Function FreeData to freeing image data added
69 - ImageID flag of TGAs was ignored. (Thanks Zwoetzen)
71 - Function SetBorderColor implemented (only used by opengl if wrap is set to GL_CLAMP_TO_BORDER)
72 - Function AddAlphaFromValue implemented to use an fixed Value as Alphachannel
73 - Function ReadOpenGLExtension is now only intern
75 - pngimage now disabled by default like all other versions.
77 - Setting up an anisotropic filter of 0 isnt allowed by nvidia (Thanks Ogridi)
79 - Fixed some Problem with Delphi 5
80 - Now uses the newest version of pngimage. Makes saving pngs much easier.
82 - Property IsCompressed and Size removed. Not really supported by Spec (Thanks Ogridi)
84 - Internal Format ifDepth8 added
85 - function GrabScreen now supports all uncompressed formats
87 - AddAlphaFromglBitmap implemented
89 - LoadFromResource and LoadFromResourceId now needs an Instance and an ResourceType (for ID)
91 - Width, Height and Depth internal changed to TglBitmapPixelPosition.
92 property Width, Height, Depth are still existing and new property Dimension are avail
94 - Added native OpenGL Support. Breaking the dglOpenGL "barrier".
96 - Added function GrabScreen to class TglBitmap2D
98 - Added support to Save images
99 - Added function Clone to Clone Instance
101 - Functions now works with Cardinals for each channel. Up to 32 Bits per channel.
103 - Several speed optimizations
105 - Internal structure change. Loading of TGA, PNG and DDS improved.
106 Data, format and size will now set directly with SetDataPtr.
107 - AddFunc now works with all Types of Images and Formats
108 - Some Funtions moved to Baseclass TglBitmap
110 - Added Support to decompress DXT3 and DXT5 compressed Images.
111 - Added Mapping to convert data from one format into an other.
113 - Added method ConvertTo in Class TglBitmap2D. Method allows to convert every
114 supported Input format (supported by GetPixel) into any uncompresed Format
115 - Added Support to decompress DXT1 compressed Images.
116 - SwapColors replaced by ConvertTo
118 - Added Support for compressed DDSs
119 - Added new internal formats (DXT1, DXT3, DXT5)
121 - Parameter Components renamed to InternalFormat
123 - Some AllocMem replaced with GetMem (little speed change)
124 - better exception handling. Better protection from memory leaks.
126 - Added support for Direct Draw Surfaces (.DDS) (uncompressed images only)
127 - Added new internal formats (RGB8, RGBA8, RGBA4, RGB5A1, RGB10A2, R5G6B5)
129 - Added support for Grayscale textures
130 - Added internal formats (Alpha, Luminance, LuminanceAlpha, BGR8, BGRA8)
132 - Added support for GL_VERSION_2_0
133 - Added support for GL_EXT_texture_filter_anisotropic
135 - Function FillWithColor fills the Image with one Color
136 - Function LoadNormalMap added
138 - ToNormalMap allows to Create an NormalMap from the Alphachannel
139 - ToNormalMap now supports Sobel (nmSobel) function.
141 - support for RLE Compressed RGB TGAs added
143 - Class TglBitmapNormalMap added to support Normalmap generation
144 - Added function ToNormalMap in class TglBitmap2D to genereate normal maps from textures.
145 3 Filters are supported. (4 Samples, 3x3 and 5x5)
147 - Method LoadCubeMapClass removed
148 - LoadCubeMap returnvalue is now the Texture paramter. Such as LoadTextures
149 - virtual abstract method GenTexture in class TglBitmap now is protected
151 - now support DescriptionFlag in LoadTga. Allows vertical flipped images to be loaded as normal
153 - little enhancement for IsPowerOfTwo
154 - TglBitmap1D.GenTexture now tests NPOT Textures
156 - some little name changes. All properties or function with Texture in name are
157 now without texture in name. We have allways texture so we dosn't name it.
159 - GenTexture now tests if texture is NPOT and NPOT-Texture are supported or
160 TextureTarget is GL_TEXTURE_RECTANGLE. Else it raised an exception.
162 - added support for GL_ARB_texture_rectangle, GL_EXT_texture_rectangle and GL_NV_texture_rectangle
164 - Function Unbind added
165 - call of SetFilter or SetTextureWrap if TextureID exists results in setting properties to opengl texture.
167 - class TglBitmapCubeMap added (allows to Create Cubemaps)
169 - Added Support for PNG Images. (http://pngdelphi.sourceforge.net/)
170 To Enable png's use the define pngimage
172 - New Functioninterface added
173 - Function GetPixel added
175 - Property BuildMipMaps renamed to MipMap
177 - property Name removed.
178 - BuildMipMaps is now a set of 3 values. None, GluBuildMipmaps and SGIS_generate_mipmap
180 - property name added. Only used in glForms!
182 - property FreeDataAfterGenTexture is now available as default (default = true)
183 - BuildMipmaps now implemented in TglBitmap1D (i've forgotten it)
184 - function MoveMemory replaced with function Move (little speed change)
185 - several calculations stored in variables (little speed change)
187 - property BuildMipsMaps added (default = true)
188 if BuildMipMaps isn't set GenTextures uses glTexImage[12]D else it use gluBuild[12]dMipmaps
189 - property FreeDataAfterGenTexture added (default = true)
190 if FreeDataAfterGenTexture is set the texturedata were deleted after the texture was generated.
191 - parameter DisableOtherTextureUnits of Bind removed
192 - parameter FreeDataAfterGeneration of GenTextures removed
194 - TglBitmap dosn't delete data if class was destroyed (fixed)
196 - Bind now enables TextureUnits (by params)
197 - GenTextures can leave data (by param)
198 - LoadTextures now optimal
200 - Performance optimization in AddFunc
201 - procedure Bind moved to subclasses
202 - Added new Class TglBitmap1D to support real OpenGL 1D Textures
204 - Texturefilter and texturewrap now also as defaults
205 Minfilter = GL_LINEAR_MIPMAP_LINEAR
206 Magfilter = GL_LINEAR
207 Wrap(str) = GL_CLAMP_TO_EDGE
208 - Added new format tfCompressed to create a compressed texture.
209 - propertys IsCompressed, TextureSize and IsResident added
210 IsCompressed and TextureSize only contains data from level 0
212 - Added function AddFunc to add PerPixelEffects to Image
213 - LoadFromFunc now based on AddFunc
214 - Invert now based on AddFunc
215 - SwapColors now based on AddFunc
217 - Added function FlipHorz
219 - Added function LaodFromFunc to create images with function
220 - Added function FlipVert
221 - Added internal format RGB(A) if GL_EXT_bgra or OpenGL 1.2 isn't supported
223 - Added Alphafunctions to calculate alpha per function
224 - Added Alpha from ColorKey using alphafunctions
226 - First full functionally Version of glBitmap
227 - Support for 24Bit and 32Bit TGA Pictures added
229 - begin of programming