Texture.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Texture" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. Texture for 2D and 3D.
  5. </brief_description>
  6. <description>
  7. 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].
  8. Textures are often created by loading them from a file. See [method @GDScript.load].
  9. [Texture] is a base for other resources. It cannot be used directly.
  10. [b]Note:[/b] The maximum texture size is 16384×16384 pixels due to graphics hardware limitations. Larger textures may fail to import.
  11. </description>
  12. <tutorials>
  13. </tutorials>
  14. <methods>
  15. <method name="draw" qualifiers="const">
  16. <return type="void" />
  17. <argument index="0" name="canvas_item" type="RID" />
  18. <argument index="1" name="position" type="Vector2" />
  19. <argument index="2" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )" />
  20. <argument index="3" name="transpose" type="bool" default="false" />
  21. <argument index="4" name="normal_map" type="Texture" default="null" />
  22. <description>
  23. Draws the texture using a [CanvasItem] with the [VisualServer] API at the specified [code]position[/code]. Equivalent to [method VisualServer.canvas_item_add_texture_rect] with a rect at [code]position[/code] and the size of this [Texture].
  24. </description>
  25. </method>
  26. <method name="draw_rect" qualifiers="const">
  27. <return type="void" />
  28. <argument index="0" name="canvas_item" type="RID" />
  29. <argument index="1" name="rect" type="Rect2" />
  30. <argument index="2" name="tile" type="bool" />
  31. <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )" />
  32. <argument index="4" name="transpose" type="bool" default="false" />
  33. <argument index="5" name="normal_map" type="Texture" default="null" />
  34. <description>
  35. Draws the texture using a [CanvasItem] with the [VisualServer] API. Equivalent to [method VisualServer.canvas_item_add_texture_rect].
  36. </description>
  37. </method>
  38. <method name="draw_rect_region" qualifiers="const">
  39. <return type="void" />
  40. <argument index="0" name="canvas_item" type="RID" />
  41. <argument index="1" name="rect" type="Rect2" />
  42. <argument index="2" name="src_rect" type="Rect2" />
  43. <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )" />
  44. <argument index="4" name="transpose" type="bool" default="false" />
  45. <argument index="5" name="normal_map" type="Texture" default="null" />
  46. <argument index="6" name="clip_uv" type="bool" default="true" />
  47. <description>
  48. Draws a part of the texture using a [CanvasItem] with the [VisualServer] API. Equivalent to [method VisualServer.canvas_item_add_texture_rect_region].
  49. </description>
  50. </method>
  51. <method name="get_data" qualifiers="const">
  52. <return type="Image" />
  53. <description>
  54. Returns an [Image] that is a copy of data from this [Texture]. [Image]s can be accessed and manipulated directly.
  55. </description>
  56. </method>
  57. <method name="get_height" qualifiers="const">
  58. <return type="int" />
  59. <description>
  60. Returns the texture height.
  61. </description>
  62. </method>
  63. <method name="get_size" qualifiers="const">
  64. <return type="Vector2" />
  65. <description>
  66. Returns the texture size.
  67. </description>
  68. </method>
  69. <method name="get_width" qualifiers="const">
  70. <return type="int" />
  71. <description>
  72. Returns the texture width.
  73. </description>
  74. </method>
  75. <method name="has_alpha" qualifiers="const">
  76. <return type="bool" />
  77. <description>
  78. Returns [code]true[/code] if this [Texture] has an alpha channel.
  79. </description>
  80. </method>
  81. </methods>
  82. <members>
  83. <member name="flags" type="int" setter="set_flags" getter="get_flags" default="4">
  84. The texture's [enum Flags]. [enum Flags] are used to set various properties of the [Texture].
  85. </member>
  86. </members>
  87. <constants>
  88. <constant name="FLAGS_DEFAULT" value="7" enum="Flags">
  89. Default flags. [constant FLAG_MIPMAPS], [constant FLAG_REPEAT] and [constant FLAG_FILTER] are enabled.
  90. </constant>
  91. <constant name="FLAG_MIPMAPS" value="1" enum="Flags">
  92. Generates mipmaps, which are smaller versions of the same texture to use when zoomed out, keeping the aspect ratio.
  93. </constant>
  94. <constant name="FLAG_REPEAT" value="2" enum="Flags">
  95. Repeats the texture (instead of clamp to edge).
  96. [b]Note:[/b] Ignored when using an [AtlasTexture] as these don't support repetition.
  97. </constant>
  98. <constant name="FLAG_FILTER" value="4" enum="Flags">
  99. Uses a magnifying filter, to enable smooth zooming in of the texture.
  100. </constant>
  101. <constant name="FLAG_ANISOTROPIC_FILTER" value="8" enum="Flags">
  102. Uses anisotropic mipmap filtering. Generates smaller versions of the same texture with different aspect ratios.
  103. This results in better-looking textures when viewed from oblique angles.
  104. </constant>
  105. <constant name="FLAG_CONVERT_TO_LINEAR" value="16" enum="Flags">
  106. Converts the texture to the sRGB color space.
  107. </constant>
  108. <constant name="FLAG_MIRRORED_REPEAT" value="32" enum="Flags">
  109. Repeats the texture with alternate sections mirrored.
  110. [b]Note:[/b] Ignored when using an [AtlasTexture] as these don't support repetition.
  111. </constant>
  112. <constant name="FLAG_VIDEO_SURFACE" value="2048" enum="Flags">
  113. Texture is a video surface.
  114. </constant>
  115. </constants>
  116. </class>