Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers
|
Class TGLImage
Unit
CastleGLImages
Declaration
type TGLImage = class(TGLImageCore)
Description
Image ready to be drawn on 2D screen, with automatically managed OpenGL resources.
This is a descendant of TGLImageCore that is easier to use: it can be created and destroyed at any moment (no need to worry about whether OpenGL context is created), and an instance can survive OpenGL context close + open.
The catch is that this keeps the image pixels in normal memory all the time. So it uses a little more memory than TGLImageCore.
Hierarchy
Overview
Methods
 |
constructor Create(const AImage: TEncodedImage; const ASmoothScaling: boolean; const AOwnsImage: boolean); overload; |
 |
constructor Create(const AImage: TEncodedImage; const ASmoothScaling: boolean); overload; deprecated 'this constructor overload is provided only for compatibility, better keep the image instance lifetime guaranteed and use the constructor with AOwnsImage parameter'; |
 |
constructor Create(const URL: string; const ASmoothScaling: boolean = true); overload; |
 |
constructor Create(const URL: string; const LoadAsClass: array of TEncodedImageClass; const ResizeToX: Cardinal = 0; const ResizeToY: Cardinal = 0; const Interpolation: TResizeInterpolation = riBilinear); overload; |
 |
constructor Create(const URL: string; const LoadAsClass: array of TEncodedImageClass; const ASmoothScaling: boolean); overload; |
 |
destructor Destroy; override; |
 |
procedure Load(const AImage: TEncodedImage); override; |
 |
procedure PrepareResources; override; |
 |
procedure Draw(ScreenRects, ImageRects: PFloatRectangleArray; const Count: Integer); override; |
Properties
Description
Methods
 |
constructor Create(const AImage: TEncodedImage; const ASmoothScaling: boolean; const AOwnsImage: boolean); overload; |
Prepare image for drawing.
Parameters
- Image
- Initial image contents. The
Image instance passed here must exist throughout the whole lifetime of this TGLImage instance (so don't free it earlier). It can be automatically freed by us, if OwnsImage = True .
Exceptions raised
- EImageClassNotSupportedForOpenGL
- When Image class is not supported by OpenGL.
|
 |
constructor Create(const AImage: TEncodedImage; const ASmoothScaling: boolean); overload; deprecated 'this constructor overload is provided only for compatibility, better keep the image instance lifetime guaranteed and use the constructor with AOwnsImage parameter'; |
Warning: this symbol is deprecated: this constructor overload is provided only for compatibility, better keep the image instance lifetime guaranteed and use the constructor with AOwnsImage parameter
Prepare image for drawing.
This constructor is provided only for compatibility with previous TGLImage in CGE <= 5.2.0. It assumes that AImage instance passed here is owned by the caller (we cannot free it), and moreover it may become freed at any point (so we actually have to make a copy of it to be safe).
It is advised to use one of the other constructors, for example use the constructor with additional parameter "AOwnsImage". The Image instance passed there must exist throughout the lifetime of this instance, regardless of "AOwnsImage".
Or use TGLImageCore class.
|
 |
constructor Create(const URL: string; const ASmoothScaling: boolean = true); overload; |
Load image from disk, and prepare for drawing.
Parameters
- URL
- URL (or filename) from which to load the image. Often you want to pass here the result ot ApplicationData function, like:
Image := TGLImage.Create(ApplicationData('textures/my_image.png'), ...);
- ASmoothScaling
- The initial value of SmoothScaling, determines whether the image scaling is smooth (bilinear filtering) or not (nearest-pixel filtering). You can always change it later through the SmoothScaling property. But each change has a small cost, so it's more efficient to just set the initial value correctly.
|
 |
constructor Create(const URL: string; const LoadAsClass: array of TEncodedImageClass; const ResizeToX: Cardinal = 0; const ResizeToY: Cardinal = 0; const Interpolation: TResizeInterpolation = riBilinear); overload; |
Load image from disk, and prepare for drawing.
Parameters
- URL
- URL (or filename) from which to load the image. Often you want to pass here the result ot ApplicationData function, like:
Image := TGLImage.Create(ApplicationData('textures/my_image.png'), ...);
- LoadAsClass
- Constrain the possible image classes to load into. This can force removing (or adding) an alpha channel, or converting contents to grayscale or RGB, regardless of the preferred image file format. Must be a subset of PixelsImageClasses, as other classes cannot be loaded into OpenGL 2D images, otherwise you may get EImageClassNotSupportedForOpenGL exception. Pass empty set [] to load into any allowed class (it's equivalent to passing LoadAsClass = PixelsImageClasses).
You can pass e.g. [TRGBImage] to force loading into an RGB image without an alpha channel (it will be stripped from the image if necessary).
- ResizeToX
- After loading, resize to given width. Pass 0 to not resize width.
- ResizeToY
- After loading, resize to given height. Pass 0 to not resize height.
- Interpolation
- If any resizing will be needed (if ResizeToX / ResizeToY parameters request some specific size, and it is different than loaded image size) then the resize operation will use given interpolation.
Exceptions raised
- EImageClassNotSupportedForOpenGL
- When image class is not supported by OpenGL.
|
 |
constructor Create(const URL: string; const LoadAsClass: array of TEncodedImageClass; const ASmoothScaling: boolean); overload; |
Load image from disk, and prepare for drawing.
Parameters
- URL
- URL (or filename) from which to load the image. Often you want to pass here the result ot ApplicationData function, like:
Image := TGLImage.Create(ApplicationData('textures/my_image.png'), ...);
- LoadAsClass
- Constrain the possible image classes to load into. This can force removing (or adding) an alpha channel, or converting contents to grayscale or RGB, regardless of the preferred image file format. Must be a subset of PixelsImageClasses, as other classes cannot be loaded into OpenGL 2D images, otherwise you may get EImageClassNotSupportedForOpenGL exception. Pass empty set [] to load into any allowed class (it's equivalent to passing LoadAsClass = PixelsImageClasses).
You can pass e.g. [TRGBImage] to force loading into an RGB image without an alpha channel (it will be stripped from the image if necessary).
- ASmoothScaling
- The initial value of SmoothScaling, determines whether the image scaling is smooth (bilinear filtering) or not (nearest-pixel filtering). You can always change it later through the SmoothScaling property. But each change has a small cost, so it's more efficient to just set the initial value correctly.
|
 |
destructor Destroy; override; |
|
 |
procedure PrepareResources; override; |
|
Properties
 |
property OwnsImage: boolean read FOwnsImage write FOwnsImage; |
|
Generated by PasDoc 0.15.0.
|