texture_rd.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /**************************************************************************/
  2. /* texture_rd.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef TEXTURE_RD_H
  31. #define TEXTURE_RD_H
  32. // Note, these classes are part of the Rendering Device based renderer.
  33. // They are included here to ensure the correct order of registration
  34. // is performed.
  35. // Once the renderer has been moved into a module, these classes should
  36. // be moved as well.
  37. #include "scene/resources/texture.h"
  38. class Texture2DRD : public Texture2D {
  39. GDCLASS(Texture2DRD, Texture2D)
  40. mutable RID texture_rid;
  41. RID texture_rd_rid;
  42. Size2i size;
  43. protected:
  44. static void _bind_methods();
  45. public:
  46. virtual int get_width() const override;
  47. virtual int get_height() const override;
  48. virtual RID get_rid() const override;
  49. virtual bool has_alpha() const override;
  50. virtual Ref<Image> get_image() const override;
  51. void set_texture_rd_rid(RID p_texture_rd_rid);
  52. RID get_texture_rd_rid() const;
  53. Texture2DRD();
  54. ~Texture2DRD();
  55. };
  56. class TextureLayeredRD : public TextureLayered {
  57. GDCLASS(TextureLayeredRD, TextureLayered)
  58. LayeredType layer_type;
  59. mutable RID texture_rid;
  60. RID texture_rd_rid;
  61. Image::Format image_format;
  62. Size2i size;
  63. uint32_t layers = 0;
  64. uint32_t mipmaps = 0;
  65. protected:
  66. static void _bind_methods();
  67. public:
  68. virtual Image::Format get_format() const override;
  69. virtual LayeredType get_layered_type() const override;
  70. virtual int get_width() const override;
  71. virtual int get_height() const override;
  72. virtual int get_layers() const override;
  73. virtual bool has_mipmaps() const override;
  74. virtual RID get_rid() const override;
  75. virtual Ref<Image> get_layer_data(int p_layer) const override;
  76. void set_texture_rd_rid(RID p_texture_rd_rid);
  77. RID get_texture_rd_rid() const;
  78. TextureLayeredRD(LayeredType p_layer_type);
  79. ~TextureLayeredRD();
  80. };
  81. class Texture2DArrayRD : public TextureLayeredRD {
  82. GDCLASS(Texture2DArrayRD, TextureLayeredRD)
  83. public:
  84. Texture2DArrayRD() :
  85. TextureLayeredRD(LAYERED_TYPE_2D_ARRAY) {}
  86. };
  87. class TextureCubemapRD : public TextureLayeredRD {
  88. GDCLASS(TextureCubemapRD, TextureLayeredRD)
  89. public:
  90. TextureCubemapRD() :
  91. TextureLayeredRD(LAYERED_TYPE_CUBEMAP) {}
  92. };
  93. class TextureCubemapArrayRD : public TextureLayeredRD {
  94. GDCLASS(TextureCubemapArrayRD, TextureLayeredRD)
  95. public:
  96. TextureCubemapArrayRD() :
  97. TextureLayeredRD(LAYERED_TYPE_CUBEMAP_ARRAY) {}
  98. };
  99. class Texture3DRD : public Texture3D {
  100. GDCLASS(Texture3DRD, Texture3D)
  101. mutable RID texture_rid;
  102. RID texture_rd_rid;
  103. Image::Format image_format;
  104. Vector3i size;
  105. uint32_t mipmaps = 0;
  106. protected:
  107. static void _bind_methods();
  108. public:
  109. virtual Image::Format get_format() const override;
  110. virtual int get_width() const override;
  111. virtual int get_height() const override;
  112. virtual int get_depth() const override;
  113. virtual bool has_mipmaps() const override;
  114. virtual RID get_rid() const override;
  115. void set_texture_rd_rid(RID p_texture_rd_rid);
  116. RID get_texture_rd_rid() const;
  117. Texture3DRD();
  118. ~Texture3DRD();
  119. };
  120. #endif // TEXTURE_RD_H