| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/io/image.h" |
| 34 |
#include "core/io/resource.h" |
| 35 |
#include "core/variant/typed_array.h" |
| 36 |
#include "scene/resources/curve.h" |
| 37 |
|
| 38 |
class Texture : public Resource { |
| 39 |
GDCLASS(Texture, Resource); |
| 40 |
}; |
| 41 |
|
| 42 |
class Texture2D : public Texture { |
| 43 |
GDCLASS(Texture2D, Texture); |
| 44 |
OBJ_SAVE_TYPE(Texture2D); |
| 45 |
|
| 46 |
protected: |
| 47 |
static void _bind_methods(); |
| 48 |
|
| 49 |
GDVIRTUAL0RC_REQUIRED(int, _get_width) |
| 50 |
GDVIRTUAL0RC_REQUIRED(int, _get_height) |
| 51 |
GDVIRTUAL2RC(bool, _is_pixel_opaque, int, int) |
| 52 |
GDVIRTUAL0RC(bool, _has_alpha) |
| 53 |
|
| 54 |
GDVIRTUAL4C(_draw, RID, Point2, Color, bool) |
| 55 |
GDVIRTUAL5C(_draw_rect, RID, Rect2, bool, Color, bool) |
| 56 |
GDVIRTUAL6C(_draw_rect_region, RID, Rect2, Rect2, Color, bool, bool) |
| 57 |
|
| 58 |
public: |
| 59 |
virtual int get_width() const; |
| 60 |
virtual int get_height() const; |
| 61 |
virtual Size2 get_size() const; |
| 62 |
|
| 63 |
virtual bool is_pixel_opaque(int p_x, int p_y) const; |
| 64 |
|
| 65 |
virtual bool has_alpha() const; |
| 66 |
|
| 67 |
virtual RID get_scaled_rid() const { return get_rid(); } |
| 68 |
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const; |
| 69 |
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const; |
| 70 |
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, bool p_clip_uv = true) const; |
| 71 |
virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const; |
| 72 |
|
| 73 |
virtual Ref<Image> get_image() const { return Ref<Image>(); } |
| 74 |
|
| 75 |
virtual Ref<Resource> create_placeholder() const; |
| 76 |
|
| 77 |
Texture2D(); |
| 78 |
}; |
| 79 |
|
| 80 |
class TextureLayered : public Texture { |
| 81 |
GDCLASS(TextureLayered, Texture); |
| 82 |
|
| 83 |
protected: |
| 84 |
static void _bind_methods(); |
| 85 |
|
| 86 |
GDVIRTUAL0RC_REQUIRED(Image::Format, _get_format) |
| 87 |
GDVIRTUAL0RC_REQUIRED(uint32_t, _get_layered_type) |
| 88 |
GDVIRTUAL0RC_REQUIRED(int, _get_width) |
| 89 |
GDVIRTUAL0RC_REQUIRED(int, _get_height) |
| 90 |
GDVIRTUAL0RC_REQUIRED(int, _get_layers) |
| 91 |
GDVIRTUAL0RC_REQUIRED(bool, _has_mipmaps) |
| 92 |
GDVIRTUAL1RC_REQUIRED(Ref<Image>, _get_layer_data, int) |
| 93 |
public: |
| 94 |
enum LayeredType { |
| 95 |
LAYERED_TYPE_2D_ARRAY, |
| 96 |
LAYERED_TYPE_CUBEMAP, |
| 97 |
LAYERED_TYPE_CUBEMAP_ARRAY |
| 98 |
}; |
| 99 |
|
| 100 |
virtual Image::Format get_format() const; |
| 101 |
virtual LayeredType get_layered_type() const; |
| 102 |
virtual int get_width() const; |
| 103 |
virtual int get_height() const; |
| 104 |
virtual int get_layers() const; |
| 105 |
virtual bool has_mipmaps() const; |
| 106 |
virtual Ref<Image> get_layer_data(int p_layer) const; |
| 107 |
}; |
| 108 |
|
| 109 |
VARIANT_ENUM_CAST(TextureLayered::LayeredType) |
| 110 |
|
| 111 |
class Texture3D : public Texture { |
| 112 |
GDCLASS(Texture3D, Texture); |
| 113 |
|
| 114 |
protected: |
| 115 |
static void _bind_methods(); |
| 116 |
|
| 117 |
TypedArray<Image> _get_datai() const; |
| 118 |
|
| 119 |
GDVIRTUAL0RC_REQUIRED(Image::Format, _get_format) |
| 120 |
GDVIRTUAL0RC_REQUIRED(int, _get_width) |
| 121 |
GDVIRTUAL0RC_REQUIRED(int, _get_height) |
| 122 |
GDVIRTUAL0RC_REQUIRED(int, _get_depth) |
| 123 |
GDVIRTUAL0RC_REQUIRED(bool, _has_mipmaps) |
| 124 |
GDVIRTUAL0RC_REQUIRED(TypedArray<Image>, _get_data) |
| 125 |
public: |
| 126 |
virtual Image::Format get_format() const; |
| 127 |
virtual int get_width() const; |
| 128 |
virtual int get_height() const; |
| 129 |
virtual int get_depth() const; |
| 130 |
virtual bool has_mipmaps() const; |
| 131 |
virtual Vector<Ref<Image>> get_data() const; |
| 132 |
virtual Ref<Resource> create_placeholder() const; |
| 133 |
}; |