Texture

Inherits: Resource < Reference < Object

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

Category: Core

Brief Description

Texture for 2D and 3D.

Member Functions

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_flags ( ) const
int get_height ( ) const
Vector2 get_size ( ) const
int get_width ( ) const
bool has_alpha ( ) const
void set_flags ( int flags )

Numeric Constants

  • 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.
  • FLAGS_DEFAULT = 7 — Default flags. Generate mipmaps, repeat, and filter are enabled.
  • 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 = 4096 — 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.

Member Function Description

  • 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_flags ( ) const

Return the current texture flags.

  • int get_height ( ) const

Return the texture height.

Return the texture size.

  • int get_width ( ) const

Return the texture width.

  • bool has_alpha ( ) const
  • void set_flags ( int flags )

Change the texture flags.