Texture.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Texture" inherits="Resource" version="3.4">
  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. </return>
  18. <argument index="0" name="canvas_item" type="RID">
  19. </argument>
  20. <argument index="1" name="position" type="Vector2">
  21. </argument>
  22. <argument index="2" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
  23. </argument>
  24. <argument index="3" name="transpose" type="bool" default="false">
  25. </argument>
  26. <argument index="4" name="normal_map" type="Texture" default="null">
  27. </argument>
  28. <description>
  29. 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].
  30. </description>
  31. </method>
  32. <method name="draw_rect" qualifiers="const">
  33. <return type="void">
  34. </return>
  35. <argument index="0" name="canvas_item" type="RID">
  36. </argument>
  37. <argument index="1" name="rect" type="Rect2">
  38. </argument>
  39. <argument index="2" name="tile" type="bool">
  40. </argument>
  41. <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
  42. </argument>
  43. <argument index="4" name="transpose" type="bool" default="false">
  44. </argument>
  45. <argument index="5" name="normal_map" type="Texture" default="null">
  46. </argument>
  47. <description>
  48. Draws the texture using a [CanvasItem] with the [VisualServer] API. Equivalent to [method VisualServer.canvas_item_add_texture_rect].
  49. </description>
  50. </method>
  51. <method name="draw_rect_region" qualifiers="const">
  52. <return type="void">
  53. </return>
  54. <argument index="0" name="canvas_item" type="RID">
  55. </argument>
  56. <argument index="1" name="rect" type="Rect2">
  57. </argument>
  58. <argument index="2" name="src_rect" type="Rect2">
  59. </argument>
  60. <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )">
  61. </argument>
  62. <argument index="4" name="transpose" type="bool" default="false">
  63. </argument>
  64. <argument index="5" name="normal_map" type="Texture" default="null">
  65. </argument>
  66. <argument index="6" name="clip_uv" type="bool" default="true">
  67. </argument>
  68. <description>
  69. Draws a part of the texture using a [CanvasItem] with the [VisualServer] API. Equivalent to [method VisualServer.canvas_item_add_texture_rect_region].
  70. </description>
  71. </method>
  72. <method name="get_data" qualifiers="const">
  73. <return type="Image">
  74. </return>
  75. <description>
  76. Returns an [Image] that is a copy of data from this [Texture]. [Image]s can be accessed and manipulated directly.
  77. </description>
  78. </method>
  79. <method name="get_height" qualifiers="const">
  80. <return type="int">
  81. </return>
  82. <description>
  83. Returns the texture height.
  84. </description>
  85. </method>
  86. <method name="get_size" qualifiers="const">
  87. <return type="Vector2">
  88. </return>
  89. <description>
  90. Returns the texture size.
  91. </description>
  92. </method>
  93. <method name="get_width" qualifiers="const">
  94. <return type="int">
  95. </return>
  96. <description>
  97. Returns the texture width.
  98. </description>
  99. </method>
  100. <method name="has_alpha" qualifiers="const">
  101. <return type="bool">
  102. </return>
  103. <description>
  104. Returns [code]true[/code] if this [Texture] has an alpha channel.
  105. </description>
  106. </method>
  107. </methods>
  108. <members>
  109. <member name="flags" type="int" setter="set_flags" getter="get_flags" default="4">
  110. The texture's [enum Flags]. [enum Flags] are used to set various properties of the [Texture].
  111. </member>
  112. </members>
  113. <constants>
  114. <constant name="FLAGS_DEFAULT" value="7" enum="Flags">
  115. Default flags. [constant FLAG_MIPMAPS], [constant FLAG_REPEAT] and [constant FLAG_FILTER] are enabled.
  116. </constant>
  117. <constant name="FLAG_MIPMAPS" value="1" enum="Flags">
  118. Generates mipmaps, which are smaller versions of the same texture to use when zoomed out, keeping the aspect ratio.
  119. </constant>
  120. <constant name="FLAG_REPEAT" value="2" enum="Flags">
  121. Repeats the texture (instead of clamp to edge).
  122. [b]Note:[/b] Ignored when using an [AtlasTexture] as these don't support repetition.
  123. </constant>
  124. <constant name="FLAG_FILTER" value="4" enum="Flags">
  125. Uses a magnifying filter, to enable smooth zooming in of the texture.
  126. </constant>
  127. <constant name="FLAG_ANISOTROPIC_FILTER" value="8" enum="Flags">
  128. Uses anisotropic mipmap filtering. Generates smaller versions of the same texture with different aspect ratios.
  129. This results in better-looking textures when viewed from oblique angles.
  130. </constant>
  131. <constant name="FLAG_CONVERT_TO_LINEAR" value="16" enum="Flags">
  132. Converts the texture to the sRGB color space.
  133. </constant>
  134. <constant name="FLAG_MIRRORED_REPEAT" value="32" enum="Flags">
  135. Repeats the texture with alternate sections mirrored.
  136. [b]Note:[/b] Ignored when using an [AtlasTexture] as these don't support repetition.
  137. </constant>
  138. <constant name="FLAG_VIDEO_SURFACE" value="2048" enum="Flags">
  139. Texture is a video surface.
  140. </constant>
  141. </constants>
  142. </class>