placeholder_textures.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**************************************************************************/
  2. /* placeholder_textures.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 PLACEHOLDER_TEXTURES_H
  31. #define PLACEHOLDER_TEXTURES_H
  32. #include "scene/resources/texture.h"
  33. class PlaceholderTexture2D : public Texture2D {
  34. GDCLASS(PlaceholderTexture2D, Texture2D)
  35. mutable RID rid;
  36. Size2 size = Size2(1, 1);
  37. protected:
  38. static void _bind_methods();
  39. public:
  40. void set_size(Size2 p_size);
  41. virtual int get_width() const override;
  42. virtual int get_height() const override;
  43. virtual RID get_rid() const override;
  44. virtual bool has_alpha() const override;
  45. virtual Ref<Image> get_image() const override;
  46. PlaceholderTexture2D();
  47. ~PlaceholderTexture2D();
  48. };
  49. class PlaceholderTexture3D : public Texture3D {
  50. GDCLASS(PlaceholderTexture3D, Texture3D)
  51. mutable RID rid;
  52. Vector3i size = Vector3i(1, 1, 1);
  53. protected:
  54. static void _bind_methods();
  55. public:
  56. void set_size(const Vector3i &p_size);
  57. Vector3i get_size() const;
  58. virtual Image::Format get_format() const override;
  59. virtual int get_width() const override;
  60. virtual int get_height() const override;
  61. virtual int get_depth() const override;
  62. virtual bool has_mipmaps() const override;
  63. virtual Vector<Ref<Image>> get_data() const override;
  64. virtual RID get_rid() const override;
  65. PlaceholderTexture3D();
  66. ~PlaceholderTexture3D();
  67. };
  68. class PlaceholderTextureLayered : public TextureLayered {
  69. GDCLASS(PlaceholderTextureLayered, TextureLayered)
  70. mutable RID rid;
  71. Size2i size = Size2i(1, 1);
  72. int layers = 1;
  73. LayeredType layered_type = LAYERED_TYPE_2D_ARRAY;
  74. protected:
  75. static void _bind_methods();
  76. public:
  77. void set_size(const Size2i &p_size);
  78. Size2i get_size() const;
  79. void set_layers(int p_layers);
  80. virtual Image::Format get_format() const override;
  81. virtual LayeredType get_layered_type() const override;
  82. virtual int get_width() const override;
  83. virtual int get_height() const override;
  84. virtual int get_layers() const override;
  85. virtual bool has_mipmaps() const override;
  86. virtual Ref<Image> get_layer_data(int p_layer) const override;
  87. virtual RID get_rid() const override;
  88. PlaceholderTextureLayered(LayeredType p_type);
  89. ~PlaceholderTextureLayered();
  90. };
  91. class PlaceholderTexture2DArray : public PlaceholderTextureLayered {
  92. GDCLASS(PlaceholderTexture2DArray, PlaceholderTextureLayered)
  93. public:
  94. PlaceholderTexture2DArray() :
  95. PlaceholderTextureLayered(LAYERED_TYPE_2D_ARRAY) {}
  96. };
  97. class PlaceholderCubemap : public PlaceholderTextureLayered {
  98. GDCLASS(PlaceholderCubemap, PlaceholderTextureLayered)
  99. public:
  100. PlaceholderCubemap() :
  101. PlaceholderTextureLayered(LAYERED_TYPE_CUBEMAP) {}
  102. };
  103. class PlaceholderCubemapArray : public PlaceholderTextureLayered {
  104. GDCLASS(PlaceholderCubemapArray, PlaceholderTextureLayered)
  105. public:
  106. PlaceholderCubemapArray() :
  107. PlaceholderTextureLayered(LAYERED_TYPE_CUBEMAP_ARRAY) {}
  108. };
  109. #endif // PLACEHOLDER_TEXTURES_H