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