placeholder_textures.h 4.8 KB

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