class_imagetexturelayered.rst 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/ImageTextureLayered.xml.
  6. .. _class_ImageTextureLayered:
  7. ImageTextureLayered
  8. ===================
  9. **Inherits:** :ref:`TextureLayered<class_TextureLayered>` **<** :ref:`Texture<class_Texture>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`Cubemap<class_Cubemap>`, :ref:`CubemapArray<class_CubemapArray>`, :ref:`Texture2DArray<class_Texture2DArray>`
  11. Base class for texture types which contain the data of multiple :ref:`ImageTexture<class_ImageTexture>`\ s. Each image is of the same size and format.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Base class for :ref:`Texture2DArray<class_Texture2DArray>`, :ref:`Cubemap<class_Cubemap>` and :ref:`CubemapArray<class_CubemapArray>`. Cannot be used directly, but contains all the functions necessary for accessing the derived resource types. See also :ref:`Texture3D<class_Texture3D>`.
  16. .. rst-class:: classref-reftable-group
  17. Methods
  18. -------
  19. .. table::
  20. :widths: auto
  21. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`create_from_images<class_ImageTextureLayered_method_create_from_images>`\ (\ images\: :ref:`Array<class_Array>`\[:ref:`Image<class_Image>`\]\ ) |
  23. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | |void| | :ref:`update_layer<class_ImageTextureLayered_method_update_layer>`\ (\ image\: :ref:`Image<class_Image>`, layer\: :ref:`int<class_int>`\ ) |
  25. +---------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. .. rst-class:: classref-section-separator
  27. ----
  28. .. rst-class:: classref-descriptions-group
  29. Method Descriptions
  30. -------------------
  31. .. _class_ImageTextureLayered_method_create_from_images:
  32. .. rst-class:: classref-method
  33. :ref:`Error<enum_@GlobalScope_Error>` **create_from_images**\ (\ images\: :ref:`Array<class_Array>`\[:ref:`Image<class_Image>`\]\ ) :ref:`🔗<class_ImageTextureLayered_method_create_from_images>`
  34. Creates an **ImageTextureLayered** from an array of :ref:`Image<class_Image>`\ s. See :ref:`Image.create()<class_Image_method_create>` for the expected data format. The first image decides the width, height, image format and mipmapping setting. The other images *must* have the same width, height, image format and mipmapping setting.
  35. Each :ref:`Image<class_Image>` represents one ``layer``.
  36. ::
  37. # Fill in an array of Images with different colors.
  38. var images = []
  39. const LAYERS = 6
  40. for i in LAYERS:
  41. var image = Image.create_empty(128, 128, false, Image.FORMAT_RGB8)
  42. if i % 3 == 0:
  43. image.fill(Color.RED)
  44. elif i % 3 == 1:
  45. image.fill(Color.GREEN)
  46. else:
  47. image.fill(Color.BLUE)
  48. images.push_back(image)
  49. # Create and save a 2D texture array. The array of images must have at least 1 Image.
  50. var texture_2d_array = Texture2DArray.new()
  51. texture_2d_array.create_from_images(images)
  52. ResourceSaver.save(texture_2d_array, "res://texture_2d_array.res", ResourceSaver.FLAG_COMPRESS)
  53. # Create and save a cubemap. The array of images must have exactly 6 Images.
  54. # The cubemap's images are specified in this order: X+, X-, Y+, Y-, Z+, Z-
  55. # (in Godot's coordinate system, so Y+ is "up" and Z- is "forward").
  56. var cubemap = Cubemap.new()
  57. cubemap.create_from_images(images)
  58. ResourceSaver.save(cubemap, "res://cubemap.res", ResourceSaver.FLAG_COMPRESS)
  59. # Create and save a cubemap array. The array of images must have a multiple of 6 Images.
  60. # Each cubemap's images are specified in this order: X+, X-, Y+, Y-, Z+, Z-
  61. # (in Godot's coordinate system, so Y+ is "up" and Z- is "forward").
  62. var cubemap_array = CubemapArray.new()
  63. cubemap_array.create_from_images(images)
  64. ResourceSaver.save(cubemap_array, "res://cubemap_array.res", ResourceSaver.FLAG_COMPRESS)
  65. .. rst-class:: classref-item-separator
  66. ----
  67. .. _class_ImageTextureLayered_method_update_layer:
  68. .. rst-class:: classref-method
  69. |void| **update_layer**\ (\ image\: :ref:`Image<class_Image>`, layer\: :ref:`int<class_int>`\ ) :ref:`🔗<class_ImageTextureLayered_method_update_layer>`
  70. Replaces the existing :ref:`Image<class_Image>` data at the given ``layer`` with this new image.
  71. The given :ref:`Image<class_Image>` must have the same width, height, image format, and mipmapping flag as the rest of the referenced images.
  72. If the image format is unsupported, it will be decompressed and converted to a similar and supported :ref:`Format<enum_Image_Format>`.
  73. The update is immediate: it's synchronized with drawing.
  74. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  75. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  76. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  77. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  78. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  79. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  80. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  81. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  82. .. |void| replace:: :abbr:`void (No return value.)`