Texture

Inherits: Resource < Reference < Object

Inherited By: AnimatedTexture, AtlasTexture, CurveTexture, GradientTexture, ImageTexture, LargeTexture, NoiseTexture, ProxyTexture, StreamTexture, ViewportTexture

Category: Core

Brief Description

Texture for 2D and 3D.

Properties

int flags

Methods

void draw ( RID canvas_item, Vector2 position, Color modulate=Color( 1, 1, 1, 1 ), bool transpose=false, Texture normal_map=null ) const
void draw_rect ( RID canvas_item, Rect2 rect, bool tile, Color modulate=Color( 1, 1, 1, 1 ), bool transpose=false, Texture normal_map=null ) const
void draw_rect_region ( RID canvas_item, Rect2 rect, Rect2 src_rect, Color modulate=Color( 1, 1, 1, 1 ), bool transpose=false, Texture normal_map=null, bool clip_uv=true ) const
Image get_data ( ) const
int get_height ( ) const
Vector2 get_size ( ) const
int get_width ( ) const
bool has_alpha ( ) const

Enumerations

enum Flags:

  • FLAGS_DEFAULT = 7 — Default flags. Generate mipmaps, repeat, and filter are enabled.
  • FLAG_MIPMAPS = 1 — Generate mipmaps, which are smaller versions of the same texture to use when zoomed out, keeping the aspect ratio.
  • FLAG_REPEAT = 2 — Repeats texture (instead of clamp to edge).
  • FLAG_FILTER = 4 — Magnifying filter, to enable smooth zooming in of the texture.
  • FLAG_ANISOTROPIC_FILTER = 8 — Anisotropic mipmap filtering. Generates smaller versions of the same texture with different aspect ratios.

More effective on planes often shown going to the horrizon as those textures (Walls or Ground for example) get squashed in the viewport to different aspect ratios and regular mipmaps keep the aspect ratio so they don’t optimize storage that well in those cases.

  • FLAG_CONVERT_TO_LINEAR = 16 — Converts texture to SRGB color space.
  • FLAG_MIRRORED_REPEAT = 32 — Repeats texture with alternate sections mirrored.
  • FLAG_VIDEO_SURFACE = 2048 — Texture is a video surface.

Description

A texture works by registering an image in the video hardware, which then can be used in 3D models or 2D Sprite or GUI Control.

Textures are often created by loading them from a file. See @GDScript.load.

Property Descriptions

Setter set_flags(value)
Getter get_flags()

The texture’s flags.

Method Descriptions

  • void draw ( RID canvas_item, Vector2 position, Color modulate=Color( 1, 1, 1, 1 ), bool transpose=false, Texture normal_map=null ) const

  • void draw_rect ( RID canvas_item, Rect2 rect, bool tile, Color modulate=Color( 1, 1, 1, 1 ), bool transpose=false, Texture normal_map=null ) const

  • void draw_rect_region ( RID canvas_item, Rect2 rect, Rect2 src_rect, Color modulate=Color( 1, 1, 1, 1 ), bool transpose=false, Texture normal_map=null, bool clip_uv=true ) const

  • Image get_data ( ) const

  • int get_height ( ) const

Returns the texture height.


Returns the texture size.


  • int get_width ( ) const

Returns the texture width.


  • bool has_alpha ( ) const