Class TDrawableImage

Unit

Declaration

type TDrawableImage = class(TNoParameterlessContructor)

Description

Image that can be drawn. This image can be drawn in various rendering methods and events, e.g. inside overridden TCastleUserInterface.Render.

See the manual about drawing using TDrawableImage: https://castle-engine.io/manual_2d_ui_custom_drawn.php . See the description how to render 2D stuff using Castle Game Engine: https://castle-engine.io/how_to_render_2d .

We have a few (probably too many) ways to show a 2D image. Alternatives to TDrawableImage are:

  • TCastleImagePersistent: Wraps TEncodedImage and TDrawableImage in a class that has comfortable published properties (so it can be edited in CGE editor, can be saved to CGE design files). Also adds caching.

  • TCastleImageControl: UI control to draw an image, using TCastleImagePersistent. This will perform the drawing by itself.

  • TCastleScene: You can also load an image to TCastleScene.Load to create a rectangle displaying this texture, which can be rendered in 2D and 3D.

Hierarchy

Overview

Fields

Public class var Statistics: TDrawableImageRenderStatistics;
Public nested const DefaultBlendingSourceFactor = bsSrcAlpha;
Public nested const DefaultBlendingDestinationFactor = bdOneMinusSrcAlpha;
Public nested const DefaultBlendingConstantColor: TVector4 = (X: 1; Y: 1; Z: 1; W: 1);

Methods

Public class procedure BatchingBegin;
Public class procedure BatchingEnd;
Public class procedure BatchingFlush;
Public constructor Create(const AImage: TEncodedImage; const ASmoothScaling: boolean; const AOwnsImage: boolean); overload;
Public constructor Create(const AUrl: String; const ASmoothScaling: boolean = true); overload;
Public constructor Create(const AUrl: String; const LoadAsClass: array of TEncodedImageClass; const ResizeToX: Cardinal = 0; const ResizeToY: Cardinal = 0; const Interpolation: TResizeInterpolation = riBilinear); overload;
Public constructor Create(const AUrl: String; const LoadAsClass: array of TEncodedImageClass; const ASmoothScaling: boolean); overload;
Public destructor Destroy; override;
Public function Rect: TRectangle;
Public procedure Draw(const X, Y: Single); overload;
Public procedure Draw(const X, Y, DrawWidth, DrawHeight: Single); overload;
Public procedure Draw(const X, Y, DrawWidth, DrawHeight: Single; const ImageX, ImageY, ImageWidth, ImageHeight: Single); overload;
Public procedure Draw(const Pos: TVector2Integer); overload;
Public procedure Draw(const ScreenRect: TFloatRectangle); overload;
Public procedure Draw(const ScreenRect, ImageRect: TFloatRectangle); overload;
Public procedure Draw(const ScreenRect: TRectangle); overload;
Public procedure Draw(const ScreenRect: TRectangle; const ImageX, ImageY, ImageWidth, ImageHeight: Single); overload;
Public procedure Draw(const ScreenRect, ImageRect: TRectangle); overload;
Public procedure Draw(ScreenRects, ImageRects: PFloatRectangleArray; Count: Integer); overload; virtual;
Public procedure DrawFlipped(const ScreenRect: TRectangle; const FlipHorizontal, FlipVertical: boolean); overload;
Public procedure DrawFlipped(const ScreenRect: TFloatRectangle; const FlipHorizontal, FlipVertical: boolean); overload;
Public procedure DrawFlipped(const ScreenRect: TFloatRectangle; ImageRect: TFloatRectangle; const FlipHorizontal, FlipVertical: boolean); overload;
Public procedure Draw3x3(const X, Y, DrawWidth, DrawHeight: Single; CornerTop, CornerRight, CornerBottom, CornerLeft: Single; ImageLeft: Single = 0; ImageBottom: Single = 0; ImageWidth: Single = -1; ImageHeight: Single = -1); overload;
Public procedure Draw3x3(const X, Y, DrawWidth, DrawHeight: Single; const Corner: TVector4Integer; const ImageRect: TFloatRectangle); overload;
Public procedure Draw3x3(const ScreenRect: TRectangle; const Corner: TVector4Integer; const ImageRect: TFloatRectangle); overload;
Public procedure Draw3x3(const ScreenRect: TFloatRectangle; const Corner: TVector4Integer; const ImageRect: TFloatRectangle); overload;
Public procedure Draw3x3(const ScreenRect: TFloatRectangle; const Corner: TVector4; const ImageRect: TFloatRectangle); overload;
Public procedure Draw3x3(const X, Y, DrawWidth, DrawHeight: Single; const Corner: TVector4Integer); overload;
Public procedure Draw3x3(const ScreenRect: TRectangle; const Corner: TVector4Integer); overload;
Public procedure Draw3x3(const ScreenRect: TFloatRectangle; const Corner: TVector4Integer); overload;
Public procedure Draw3x3(const ScreenRect: TFloatRectangle; const Corner: TVector4); overload;
Public procedure Load(const AImage: TEncodedImage); virtual;
Public procedure PrepareResources;
Public function GetContents(const ImageClass: TCastleImageClass): TCastleImage;
Public procedure RenderToImageBegin(const SetAndRestoreViewport: boolean = true);
Public procedure RenderToImageEnd;
Public procedure RenderToImageFree;
Public procedure DrawFrom(const SourceImage: TDrawableImage; const DestinationRect, SourceRect: TFloatRectangle);

Properties

Public property Width: Cardinal read FWidth;
Public property Height: Cardinal read FHeight;
Public property Alpha: TAutoAlphaChannel read FAlpha write SetAlpha default acAuto;
Public property BlendingSourceFactor: TBlendingSourceFactor read FBlendingSourceFactor write SetBlendingSourceFactor default DefaultBlendingSourceFactor;
Public property BlendingDestinationFactor: TBlendingDestinationFactor read FBlendingDestinationFactor write SetBlendingDestinationFactor default DefaultBlendingDestinationFactor;
Public property BlendingConstantColor: TCastleColor read FBlendingConstantColor write SetBlendingConstantColor;
Public property ScaleCorners: Single read FScaleCorners write FScaleCorners default 1;
Public property Color: TCastleColor read FColor write SetColor;
Public property SmoothScaling: boolean read FSmoothScaling write SetSmoothScaling;
Public property ScalingPossible: boolean read FSmoothScaling write SetSmoothScaling; deprecated 'use SmoothScaling';
Public property CenterX: Single read GetCenterX write SetCenterX default 0.5; deprecated 'use RotationCenter';
Public property CenterY: Single read GetCenterY write SetCenterY default 0.5; deprecated 'use RotationCenter';
Public property RotationCenter: TVector2 read FRotationCenter write SetRotationCenter;
Public property Rotation: Single read FRotation write SetRotation default 0;
Public property Clip: Boolean read FClip write SetClip;
Public property ClipLine: TVector3 read FClipLine write SetClipLine;
Public property Texture: TGLTextureId read FTexture;
Public property CustomShader: TGLSLProgram read FCustomShader write FCustomShader;
Public property Image: TEncodedImage read FImage write SetImage;
Public property OwnsImage: boolean read FOwnsImage write FOwnsImage;
Public property Url: String read FUrl write SetUrl;
Public property RepeatS: Boolean read FRepeatS write SetRepeatS default false;
Public property RepeatT: Boolean read FRepeatT write SetRepeatT default false;

Description

Fields

Public class var Statistics: TDrawableImageRenderStatistics;

This item has no description.

Public nested const DefaultBlendingSourceFactor = bsSrcAlpha;

This item has no description.

Public nested const DefaultBlendingDestinationFactor = bdOneMinusSrcAlpha;

This item has no description.

Public nested const DefaultBlendingConstantColor: TVector4 = (X: 1; Y: 1; Z: 1; W: 1);

This item has no description.

Methods

Public class procedure BatchingBegin;

Start batching that optimizes further TDrawableImage.Draw calls by grouping them.

All subsequent calls to TDrawableImage.Draw are delayed, to be grouped in case you execute TDrawableImage.Draw multiple times on the same image, in which case it is more efficient to draw multiple rectangles in one "draw call" for OpenGL.

The images are actually drawn only when you try to draw a different image, or when you execute BatchingEnd.

Some other operations also flush the last batch to to the screen: rendering using DrawPrimitive2D and friends like DrawRectangle, changing the parameters or last image that affect rendering (like image contents, TDrawableImage.Color or TDrawableImage.Rotation), freeing last image. This fact should be transparent to you, we try to flush as seldom as possible to have as big groups (and thus effective batching) as possible.

Calling BatchingBegin with matching BatchingEnd when the batching is already in progress is gracefully handled, i.e. we assume you just continue larger-scope batching. So the "inner" BatchingBegin + BatchingEnd calls are ignored, but you always must match one BatchingBegin with one BatchingEnd.

Public class procedure BatchingEnd;

This item has no description.

Public class procedure BatchingFlush;

If we are during batching, then flush the pending drawing now.

You should never need to call this, unless you do direct rendering that is not

Public 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 TDrawableImage instance (so don't free it earlier). It can be automatically freed by us, if OwnsImage = True.

It can be Nil.

Exceptions raised
EImageClassNotSupportedForOpenGL
When Image class is not supported by OpenGL.
Public constructor Create(const AUrl: String; const ASmoothScaling: boolean = true); overload;

Load image from disk, and prepare for drawing.

Parameters
AUrl
URL (or filename) from which to load the image. Often you want to use here castle-data:/ protocol to load application data, like:

Image := TDrawableImage.Create('castle-data:/textures/my_image.png', ...);

See https://castle-engine.io/data

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.
Public constructor Create(const AUrl: 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
AUrl
URL (or filename) from which to load the image. Usually you want to use here URL starting with the "castle-data:" protocol, to load an image from application data, like this:

Image := TDrawableImage.Create('castle-data:/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.
Public constructor Create(const AUrl: String; const LoadAsClass: array of TEncodedImageClass; const ASmoothScaling: boolean); overload;

Load image from disk, and prepare for drawing.

Parameters
AUrl
URL (or filename) from which to load the image. Often you want to pass here the result ot ApplicationData function, like:

Image := TDrawableImage.Create('castle-data:/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.
Public destructor Destroy; override;

This item has no description.

Public function Rect: TRectangle;

Rectangle representing the inside of this image. Always (Left,Bottom) are zero, and (Width,Height) correspond to image sizes.

Public procedure Draw(const X, Y: Single); overload;

Draw the image as 2D on screen.

The X, Y parameters determine where the left-bottom corner of the image will be placed (from 0 to size - 1).

You should only use this inside TCastleUserInterface.Render. We require that current projection is 2D and lighting / depth test and such are off, which is the default state there.

The image is drawn in 2D. In normal circumstances 1 pixel of the image is just placed over 1 pixel of the screen, and we draw the whole image. But you can use the overloaded versions where you specify DrawWidth, DrawHeight or ScreenRect, and then the indicated image portion is stretched over the designated screen area. Note: if you plan to use such stretching when drawing the image, then you usually want to create the image with SmoothScaling = True (otherwise the scaling will look pixelated).

Note that the image position (ImageX, ImageY) is specified like a texture coordinate. So (0, 0) is actually the left-bottom corner of the left-bottom pixel, and (Width,Height) is the right-top corner of the right-top pixel. That is why image position and sizes are floats, it makes sense to render partial pixels this way (make sure you have SmoothScaling = True to get nice scaling of image contents).

You can also flip the image horizontally or vertically, e.g. use ImageX = Width and ImageWidth = -Width to mirror image horizontally. Although it's usually more comfortable to flip using DrawFlipped methods.

Public procedure Draw(const X, Y, DrawWidth, DrawHeight: Single); overload;

This item has no description.

Public procedure Draw(const X, Y, DrawWidth, DrawHeight: Single; const ImageX, ImageY, ImageWidth, ImageHeight: Single); overload;

This item has no description.

Public procedure Draw(const Pos: TVector2Integer); overload;

This item has no description.

Public procedure Draw(const ScreenRect: TFloatRectangle); overload;

This item has no description.

Public procedure Draw(const ScreenRect, ImageRect: TFloatRectangle); overload;

This item has no description.

Public procedure Draw(const ScreenRect: TRectangle); overload;

This item has no description.

Public procedure Draw(const ScreenRect: TRectangle; const ImageX, ImageY, ImageWidth, ImageHeight: Single); overload;

This item has no description.

Public procedure Draw(const ScreenRect, ImageRect: TRectangle); overload;

This item has no description.

Public procedure Draw(ScreenRects, ImageRects: PFloatRectangleArray; Count: Integer); overload; virtual;

This item has no description.

Public procedure DrawFlipped(const ScreenRect: TRectangle; const FlipHorizontal, FlipVertical: boolean); overload;

This item has no description.

Public procedure DrawFlipped(const ScreenRect: TFloatRectangle; const FlipHorizontal, FlipVertical: boolean); overload;

This item has no description.

Public procedure DrawFlipped(const ScreenRect: TFloatRectangle; ImageRect: TFloatRectangle; const FlipHorizontal, FlipVertical: boolean); overload;

This item has no description.

Public procedure Draw3x3(const X, Y, DrawWidth, DrawHeight: Single; CornerTop, CornerRight, CornerBottom, CornerLeft: Single; ImageLeft: Single = 0; ImageBottom: Single = 0; ImageWidth: Single = -1; ImageHeight: Single = -1); overload;

Draw the image on the screen, divided into 3x3 parts for corners, sides, and inside.

Just like the regular Draw method, this fills a rectangle on the 2D screen, with bottom-left corner in (X, Y), and size (DrawWidth, DrawHeight). The image is divided into 3 * 3 = 9 parts:

  • 4 corners, used to fill the corners of the screen rectangle. They are not stretched.

  • 4 sides, used to fill the sides of the screen rectangle between the corners. They are scaled in one dimension, to fill the space between corners completely.

  • the inside. Used to fill the rectangular inside. Scaled in both dimensions as necessary.

Public procedure Draw3x3(const X, Y, DrawWidth, DrawHeight: Single; const Corner: TVector4Integer; const ImageRect: TFloatRectangle); overload;

This item has no description.

Public procedure Draw3x3(const ScreenRect: TRectangle; const Corner: TVector4Integer; const ImageRect: TFloatRectangle); overload;

This item has no description.

Public procedure Draw3x3(const ScreenRect: TFloatRectangle; const Corner: TVector4Integer; const ImageRect: TFloatRectangle); overload;

This item has no description.

Public procedure Draw3x3(const ScreenRect: TFloatRectangle; const Corner: TVector4; const ImageRect: TFloatRectangle); overload;

This item has no description.

Public procedure Draw3x3(const X, Y, DrawWidth, DrawHeight: Single; const Corner: TVector4Integer); overload;

This item has no description.

Public procedure Draw3x3(const ScreenRect: TRectangle; const Corner: TVector4Integer); overload;

This item has no description.

Public procedure Draw3x3(const ScreenRect: TFloatRectangle; const Corner: TVector4Integer); overload;

This item has no description.

Public procedure Draw3x3(const ScreenRect: TFloatRectangle; const Corner: TVector4); overload;

This item has no description.

Public procedure Load(const AImage: TEncodedImage); virtual;

Load the given image contents. Use this to efficiently replace the image contents on GPU. Updates the Width, Height, Alpha to correspond to new image.

It is valid (and reasonable) to call this with AImage instance equal to the image instance that you used when creating this TDrawableImage. That's because TDrawableImage does not automatically update the image contents (once they were loaded to GPU) when you change the underlying TEncodedImage instance.

It is valid to pass Nil as parameter.

Do not call this method too often. This methos copies the image contents from TEncodedImage to GPU, which is not something you want to do every frame. Doing this occasionally, or during the loading/preparation stage, is OK. Doing this often, e.g. during every TCastleUserInterface.Render, will hurt your performance. During the game, it's most efficient to treat the TDrawableImage instances as "constant" – avoid changing their contents, avoid creating new ones.

Public procedure PrepareResources;

Prepare all the possible resources. Since we may load OpenGL resources on-demand (if the TDrawableImage instance was created when OpenGL context was not available yet), this method can be used to force loading OpenGL resources now (if possible). This is only useful if you want to avoid slowdown when loading it later, and prefer to do the loading now.

Public function GetContents(const ImageClass: TCastleImageClass): TCastleImage;

Get the image contents from GPU to CPU.

Exceptions raised
ECannotSaveTextureContents
If we cannot get texture contents (not supported on OpenGLES).
Public procedure RenderToImageBegin(const SetAndRestoreViewport: boolean = true);

Start rendering to this image, using an efficient GPU method ("Framebuffer Object", FBO). Remember that the result lives only on GPU (the underlying TEncodedImage, in normal RAM memory, is not updated by this drawing in any way).

Between RenderToImageBegin and RenderToImageEnd you can use various rendering methods, like

Calling the RenderToImageBegin for the first time automatically creates a TGLRenderToTexture descendant suitable for rendering to this texture. It is automatically released on certain events, you can also explicitly release it by RenderToImageFree.

Public procedure RenderToImageEnd;

This item has no description.

Public procedure RenderToImageFree;

This item has no description.

Public procedure DrawFrom(const SourceImage: TDrawableImage; const DestinationRect, SourceRect: TFloatRectangle);

Draw a SourceImage over this image.

The drawing is done completely on GPU (using the RenderToImageBegin). This is a much faster alternative to drawing using TCastleImage.DrawFrom (that happens on CPU). The result "lives" only on GPU (the underlying TEncodedImage, in normal RAM memory, is not updated by this drawing in any way).

If you use this only occasionally, it's nice to later free the resources by RenderToImageFree.

Properties

Public property Width: Cardinal read FWidth;

This item has no description.

Public property Height: Cardinal read FHeight;

This item has no description.

Public property Alpha: TAutoAlphaChannel read FAlpha write SetAlpha default acAuto;

How to render the alpha channel of the texture.

  • acAuto means to guess correct alpha channel from the loaded image contents, and the current Color. We use alpha blending if the loaded image alpha indicates so, or Color[3] < 1. Otherwise we use alpha testing if the loaded image alpha indicates so. Otherwise we don't use any alpha, we render image opaque.

  • acNone means to ignore it.

  • acTest means to render with alpha-test.

  • acBlending means to render with blending.

This is initialized based on loaded image class and data. This means that e.g. if you have smooth alpha channel in the image, it will be automatically rendered with nice blending.

You can change the value of this property to force a specific rendering method, for example to force using alpha test or alpha blending regardless of alpha values. Or to disable alpha channel usage, because your image must always cover pixels underneath.

Remember that you can also change the alpha channel existence at loading: use LoadAsClass parameters of LoadImage or TDrawableImage.Create to force your image to have/don't have an alpha channel (e.g. use LoadAsClass=[TRGBImage] to force RGB image without alpha, use LoadAsClass=[TRGBAlphaImage] to force alpha channel).

Public property BlendingSourceFactor: TBlendingSourceFactor read FBlendingSourceFactor write SetBlendingSourceFactor default DefaultBlendingSourceFactor;

Blending source factor, if we use blending (see Alpha).

Public property BlendingDestinationFactor: TBlendingDestinationFactor read FBlendingDestinationFactor write SetBlendingDestinationFactor default DefaultBlendingDestinationFactor;

Blending destination factor, if we use blending (see Alpha).

Public property BlendingConstantColor: TCastleColor read FBlendingConstantColor write SetBlendingConstantColor;

For some blending source or destination factors (see BlendingSourceFactor, BlendingDestinationFactor), this constant color (or it's alpha value) take part in the blending equation. Used only if blending (see Alpha). By default, opaque white.

Public property ScaleCorners: Single read FScaleCorners write FScaleCorners default 1;

In case of Draw3x3 the corners on screen are scaled by this amount. This is especially useful for UI scaling, see TCastleContainer.UIScaling and TCastleUserInterface.UIScale.

Public property Color: TCastleColor read FColor write SetColor;

Color to multiply the texture contents (all RGBA channels). By default this is White, which is (1, 1, 1, 1) as RGBA, and it means that texture contents are not actually modified. This case is also optimized when possible, to no multiplication will actually happen.

When the color's alpha is < 1, then we automatically use blending, if Alpha is acAuto (regardless of the image alpha channel, in this case).

Note that if you use TGrayscaleImage with TGrayscaleImage.TreatAsAlpha (which means that texture does not contain any RGB information), then only this color's RGB values determine the drawn RGB color.

Public property SmoothScaling: boolean read FSmoothScaling write SetSmoothScaling;

Is the image scaling mode smooth (bilinear filtering) or not (nearest-pixel filtering). This is important if you draw the image such that one image pixel does not perfectly fit one screen pixel.

If you will not ever do any scaling, then set this to False. It may cause minimally faster drawing, and avoids any possible artifacts from bilinear filtering.

If you will do scaling, you usually want to set this to True, unless you deliberately want a pixelated look (for pixelart).

Note that switching this property after this object is constructed is possible, but costly.

Public property ScalingPossible: boolean read FSmoothScaling write SetSmoothScaling; deprecated 'use SmoothScaling';

Warning: this symbol is deprecated: use SmoothScaling

This item has no description.

Public property CenterX: Single read GetCenterX write SetCenterX default 0.5; deprecated 'use RotationCenter';

Warning: this symbol is deprecated: use RotationCenter

X coordinate of the center of rotation. Value from 0 to 1. Default value 0.5.

Public property CenterY: Single read GetCenterY write SetCenterY default 0.5; deprecated 'use RotationCenter';

Warning: this symbol is deprecated: use RotationCenter

Y coordinate of the center of rotation. Value from 0 to 1. Default value 0.5.

Public property RotationCenter: TVector2 read FRotationCenter write SetRotationCenter;

Center of rotation. Expressed as a fraction within the drawn ScreenRectangle, (0,0) means bottom-left corner, (1,1) means top-right corner. Default (0.5,0.5).

Public property Rotation: Single read FRotation write SetRotation default 0;

Rotation in radians. Increase to rotate in a counter-clockwise direction. Hint: use function like ArcTan2 from Math unit to convert 2D direction into a rotation angle.

Public property Clip: Boolean read FClip write SetClip;

Clip the image by an arbitrary 2D line defined in ClipLine.

Public property ClipLine: TVector3 read FClipLine write SetClipLine;

If Clip, this is the line equation used to determine whether we clip the given pixel. Given a line (A, B, C) and pixel (x, y), the pixel is clipped (rejected) if A * x + B * y + C < 0.

The line equation works in texture coordinates. If the image is drawn complete on the screen, texture coordinates span from (0,0) at bottom-left to (1,1) top-right.

For example ClipLine = (1, 0, -0.5) means that we reject pixels where 1 * x + 0 * y - 0.5 < 0. In other words, we reject pixels where x < 0.5, so we reject the left half of the image.

Public property Texture: TGLTextureId read FTexture;

Internal OpenGL texture identifier.

You cannot free it (e.g. by glFreeTexture), and you cannot change it's parameters (because TDrawableImage assumes it controls all the texture parameters). For normal drawing, you do not need this (use Draw or other rendering routines in this class), but it may be useful to integrate with external rendering systems.

Public property CustomShader: TGLSLProgram read FCustomShader write FCustomShader;

Use a custom shader for image rendering.

The shader must define the same uniform variables and attributes as the standard TDrawableImage shader, like viewport_size, vertex, tex_coord. See for example our default shader code: https://github.com/castle-engine/castle-engine/blob/master/src/images/opengl/glsl/source/image.vs https://github.com/castle-engine/castle-engine/blob/master/src/images/opengl/glsl/source/image.fs .

See also example: examples/images_videos/image_render_custom_shader/ .

Note that some uniforms/attributes are only used in some cases. For example, when TDrawableImage.Color is White (1, 1, 1, 1), then we don't pass "color" uniform. When TDrawableImage.Clip is False, then we don't pass "clip_line" uniform. When assigning your custom shader, you take responsibility of setting the shader that matches the current TDrawableImage properties.

You can (and should, if possible) reuse a single TGLSLProgram instance for many TDrawableImage and TCastleImageControl instances (as TDrawableImage.CustomShader and TCastleImageControl.CustomShader). You can also use your own uniforms in your shader code, of course.

Public property Image: TEncodedImage read FImage write SetImage;

This item has no description.

Public property OwnsImage: boolean read FOwnsImage write FOwnsImage;

This item has no description.

Public property Url: String read FUrl write SetUrl;

URL of currently loaded image. Non-empty only if the image was loaded from URL.

Public property RepeatS: Boolean read FRepeatS write SetRepeatS default false;

Repeat or clamp texture in S (width) or T (height) dimensions.

Public property RepeatT: Boolean read FRepeatT write SetRepeatT default false;

This item has no description.


Generated by PasDoc 0.16.0-snapshot.