|
The current version of the Dot contains only a single image loader, for use with Targa (.TGA) files. As for the 3D model loaders included with the Dot, the TGA loader offers little more than a structured representation of the raw data found in the file, so some knowledge of the TGA file format is needed. The TGA loader can be found in TGA2.pas (the "2" suffix is a legacy thing). To load a TGA file, instantiate a TTGAImage object and call its LoadFromFile() or LoadFromStream() method. The loader supports 8-bit, 24-bit and 32-bit images. Images may also be compressed or paletted. To facilitate the use of TGA images as textures in OpenGL, a few methods are provided to convert the image data to something the GL can understand. procedure ExpandToTrueColor; procedure BGRtoRGB; ExpandToTrueColor() will convert 8-bit images to 24-bit ones. If the image is already 24-bit or higher, nothing happens. This works for both grayscale and paletted images. After you've done this, you can use BGRtoRGB() to invert the ordering of the color components in the image. Note that you don't need to do this if your video card supports GL_EXT_bgra. Finally, note that the image will automatically be flipped (if necessary) such that the origin is at the lower-left pixel, i.e. so that texture coordinates (0, 0) match the bottom left corner of the image. |
|||
|
The Delphi OpenGL Toolkit was written
by Tom Nuydens.
See main page for disclaimer. For updates, visit
Delphi3D.