A texture works by registering an image in the video hardware, which then can be used in 3D models or 2D Sprite2D or GUI Control.
Textures are often created by loading them from a file. See @GDScript.load.
Texture2D is a base for other resources. It cannot be used directly.
Called when the entire Texture2D is requested to be drawn over a CanvasItem, with the top-left offset specified in pos
. modulate
specifies a multiplier for the colors being drawn, while transpose
specifies whether drawing should be performed in column-major order instead of row-major order (resulting in 90-degree clockwise rotation).
Note: This is only used in 2D rendering, not 3D.
Called when the Texture2D is requested to be drawn onto CanvasItem's specified rect
. modulate
specifies a multiplier for the colors being drawn, while transpose
specifies whether drawing should be performed in column-major order instead of row-major order (resulting in 90-degree clockwise rotation).
Note: This is only used in 2D rendering, not 3D.
Called when a part of the Texture2D specified by src_rect
's coordinates is requested to be drawn onto CanvasItem's specified rect
. modulate
specifies a multiplier for the colors being drawn, while transpose
specifies whether drawing should be performed in column-major order instead of row-major order (resulting in 90-degree clockwise rotation).
Note: This is only used in 2D rendering, not 3D.
Called when the Texture2D's height is queried.
Called when the Texture2D's width is queried.
Called when the presence of an alpha channel in the Texture2D is queried.
Called when a pixel's opaque state in the Texture2D is queried at the specified (x, y)
position.
Creates a placeholder version of this resource (PlaceholderTexture2D).
Draws the texture using a CanvasItem with the RenderingServer API at the specified position
.
Draws the texture using a CanvasItem with the RenderingServer API.
Draws a part of the texture using a CanvasItem with the RenderingServer API.
Returns the texture height in pixels.
Returns an Image that is a copy of data from this Texture2D (a new Image is created each time). Images can be accessed and manipulated directly.
Note: This will return null
if this Texture2D is invalid.
Note: This will fetch the texture data from the GPU, which might cause performance problems when overused.
Returns the texture size in pixels.
Returns the texture width in pixels.
Returns true
if this Texture2D has an alpha channel.