diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-06-11 15:43:37 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-02-11 11:53:26 +0100 |
commit | 3f335ce3d446372eeb9ed87f7e117099c4d2dd6a (patch) | |
tree | 669db7ddb21f328215a9c26e9bdaf2565db8c853 /scene | |
parent | 9ffe57a10eecf79ab8df2f0497d0387383755df3 (diff) |
Texture refactor
-Texture renamed to Texture2D
-TextureLayered as base now inherits 2Darray, cubemap and cubemap array
-Removed all references to flags in textures (they will go in the shader)
-Texture3D gone for now (will come back later done properly)
-Create base rasterizer for RenderDevice, RasterizerRD
Diffstat (limited to 'scene')
111 files changed, 1073 insertions, 1652 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 917ced5feb..e787cd9230 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -68,7 +68,7 @@ bool AnimatedSprite::_edit_use_rect() const { if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) { return false; } - Ref<Texture> t; + Ref<Texture2D> t; if (animation) t = frames->get_frame(animation, frame); return t.is_valid(); @@ -84,7 +84,7 @@ Rect2 AnimatedSprite::_get_rect() const { return Rect2(); } - Ref<Texture> t; + Ref<Texture2D> t; if (animation) t = frames->get_frame(animation, frame); if (t.is_null()) @@ -101,7 +101,7 @@ Rect2 AnimatedSprite::_get_rect() const { return Rect2(ofs, s); } -void SpriteFrames::add_frame(const StringName &p_anim, const Ref<Texture> &p_frame, int p_at_pos) { +void SpriteFrames::add_frame(const StringName &p_anim, const Ref<Texture2D> &p_frame, int p_at_pos) { Map<StringName, Anim>::Element *E = animations.find(p_anim); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist."); @@ -438,11 +438,11 @@ void AnimatedSprite::_notification(int p_what) { if (!frames->has_animation(animation)) return; - Ref<Texture> texture = frames->get_frame(animation, frame); + Ref<Texture2D> texture = frames->get_frame(animation, frame); if (texture.is_null()) return; - Ref<Texture> normal = frames->get_normal_frame(animation, frame); + Ref<Texture2D> normal = frames->get_normal_frame(animation, frame); RID ci = get_canvas_item(); diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h index cd00a4e181..2377f54079 100644 --- a/scene/2d/animated_sprite.h +++ b/scene/2d/animated_sprite.h @@ -42,7 +42,7 @@ class SpriteFrames : public Resource { float speed; bool loop; - Vector<Ref<Texture> > frames; + Vector<Ref<Texture2D> > frames; Anim() { loop = true; @@ -80,34 +80,34 @@ public: void set_animation_loop(const StringName &p_anim, bool p_loop); bool get_animation_loop(const StringName &p_anim) const; - void add_frame(const StringName &p_anim, const Ref<Texture> &p_frame, int p_at_pos = -1); + void add_frame(const StringName &p_anim, const Ref<Texture2D> &p_frame, int p_at_pos = -1); int get_frame_count(const StringName &p_anim) const; - _FORCE_INLINE_ Ref<Texture> get_frame(const StringName &p_anim, int p_idx) const { + _FORCE_INLINE_ Ref<Texture2D> get_frame(const StringName &p_anim, int p_idx) const { const Map<StringName, Anim>::Element *E = animations.find(p_anim); - ERR_FAIL_COND_V_MSG(!E, Ref<Texture>(), "Animation '" + String(p_anim) + "' doesn't exist."); - ERR_FAIL_COND_V(p_idx < 0, Ref<Texture>()); + ERR_FAIL_COND_V_MSG(!E, Ref<Texture2D>(), "Animation '" + String(p_anim) + "' doesn't exist."); + ERR_FAIL_COND_V(p_idx < 0, Ref<Texture2D>()); if (p_idx >= E->get().frames.size()) - return Ref<Texture>(); + return Ref<Texture2D>(); return E->get().frames[p_idx]; } - _FORCE_INLINE_ Ref<Texture> get_normal_frame(const StringName &p_anim, int p_idx) const { + _FORCE_INLINE_ Ref<Texture2D> get_normal_frame(const StringName &p_anim, int p_idx) const { const Map<StringName, Anim>::Element *E = animations.find(p_anim); - ERR_FAIL_COND_V_MSG(!E, Ref<Texture>(), "Animation '" + String(p_anim) + "' doesn't exist."); - ERR_FAIL_COND_V(p_idx < 0, Ref<Texture>()); + ERR_FAIL_COND_V_MSG(!E, Ref<Texture2D>(), "Animation '" + String(p_anim) + "' doesn't exist."); + ERR_FAIL_COND_V(p_idx < 0, Ref<Texture2D>()); const Map<StringName, Anim>::Element *EN = animations.find(E->get().normal_name); if (!EN || p_idx >= EN->get().frames.size()) - return Ref<Texture>(); + return Ref<Texture2D>(); return EN->get().frames[p_idx]; } - void set_frame(const StringName &p_anim, int p_idx, const Ref<Texture> &p_frame) { + void set_frame(const StringName &p_anim, int p_idx, const Ref<Texture2D> &p_frame) { Map<StringName, Anim>::Element *E = animations.find(p_anim); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist."); ERR_FAIL_COND(p_idx < 0); diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 5631aa3355..5582580ff9 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -831,7 +831,7 @@ void CanvasItem::draw_circle(const Point2 &p_pos, float p_radius, const Color &p VisualServer::get_singleton()->canvas_item_add_circle(canvas_item, p_pos, p_radius, p_color); } -void CanvasItem::draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos, const Color &p_modulate, const Ref<Texture> &p_normal_map) { +void CanvasItem::draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_pos, const Color &p_modulate, const Ref<Texture2D> &p_normal_map) { ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); @@ -840,14 +840,14 @@ void CanvasItem::draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos p_texture->draw(canvas_item, p_pos, p_modulate, false, p_normal_map); } -void CanvasItem::draw_texture_rect(const Ref<Texture> &p_texture, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) { +void CanvasItem::draw_texture_rect(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) { ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); ERR_FAIL_COND(p_texture.is_null()); p_texture->draw_rect(canvas_item, p_rect, p_tile, p_modulate, p_transpose, p_normal_map); } -void CanvasItem::draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map, bool p_clip_uv) { +void CanvasItem::draw_texture_rect_region(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) { ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); ERR_FAIL_COND(p_texture.is_null()); @@ -861,7 +861,7 @@ void CanvasItem::draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p p_style_box->draw(canvas_item, p_rect); } -void CanvasItem::draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, float p_width, const Ref<Texture> &p_normal_map) { +void CanvasItem::draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, float p_width, const Ref<Texture2D> &p_normal_map) { ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); @@ -886,7 +886,7 @@ void CanvasItem::draw_set_transform_matrix(const Transform2D &p_matrix) { VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item, p_matrix); } -void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map, bool p_antialiased) { +void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, const Ref<Texture2D> &p_normal_map, bool p_antialiased) { ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); @@ -896,7 +896,7 @@ void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal, p_antialiased); } -void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map, bool p_antialiased) { +void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, const Ref<Texture2D> &p_normal_map, bool p_antialiased) { ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); @@ -908,7 +908,7 @@ void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Colo VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal, p_antialiased); } -void CanvasItem::draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture> &p_texture, const Ref<Texture> &p_normal_map, const Transform2D &p_transform, const Color &p_modulate) { +void CanvasItem::draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Transform2D &p_transform, const Color &p_modulate) { ERR_FAIL_COND(p_mesh.is_null()); RID texture_rid = p_texture.is_valid() ? p_texture->get_rid() : RID(); @@ -916,7 +916,7 @@ void CanvasItem::draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture> &p_textur VisualServer::get_singleton()->canvas_item_add_mesh(canvas_item, p_mesh->get_rid(), p_transform, p_modulate, texture_rid, normal_map_rid); } -void CanvasItem::draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture> &p_texture, const Ref<Texture> &p_normal_map) { +void CanvasItem::draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map) { ERR_FAIL_COND(p_multimesh.is_null()); RID texture_rid = p_texture.is_valid() ? p_texture->get_rid() : RID(); @@ -1187,8 +1187,8 @@ void CanvasItem::_bind_methods() { ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture", "normal_map", "antialiased"), &CanvasItem::draw_colored_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("draw_string", "font", "position", "text", "modulate", "clip_w"), &CanvasItem::draw_string, DEFVAL(Color(1, 1, 1)), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("draw_char", "font", "position", "char", "next", "modulate"), &CanvasItem::draw_char, DEFVAL(Color(1, 1, 1))); - ClassDB::bind_method(D_METHOD("draw_mesh", "mesh", "texture", "normal_map", "transform", "modulate"), &CanvasItem::draw_mesh, DEFVAL(Ref<Texture>()), DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1))); - ClassDB::bind_method(D_METHOD("draw_multimesh", "multimesh", "texture", "normal_map"), &CanvasItem::draw_multimesh, DEFVAL(Ref<Texture>())); + ClassDB::bind_method(D_METHOD("draw_mesh", "mesh", "texture", "normal_map", "transform", "modulate"), &CanvasItem::draw_mesh, DEFVAL(Ref<Texture2D>()), DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1))); + ClassDB::bind_method(D_METHOD("draw_multimesh", "multimesh", "texture", "normal_map"), &CanvasItem::draw_multimesh, DEFVAL(Ref<Texture2D>())); ClassDB::bind_method(D_METHOD("draw_set_transform", "position", "rotation", "scale"), &CanvasItem::draw_set_transform); ClassDB::bind_method(D_METHOD("draw_set_transform_matrix", "xform"), &CanvasItem::draw_set_transform_matrix); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 8814d99edd..c4f4c66fab 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -313,16 +313,16 @@ public: void draw_multiline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false); void draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_filled = true, float p_width = 1.0, bool p_antialiased = false); void draw_circle(const Point2 &p_pos, float p_radius, const Color &p_color); - void draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1), const Ref<Texture> &p_normal_map = Ref<Texture>()); - void draw_texture_rect(const Ref<Texture> &p_texture, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()); - void draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = false); + void draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1), const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()); + void draw_texture_rect(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()); + void draw_texture_rect_region(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = false); void draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect); - void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture = Ref<Texture>(), float p_width = 1, const Ref<Texture> &p_normal_map = Ref<Texture>()); - void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_antialiased = false); - void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_antialiased = false); + void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture = Ref<Texture2D>(), float p_width = 1, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()); + void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture2D> p_texture = Ref<Texture2D>(), const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_antialiased = false); + void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture2D> p_texture = Ref<Texture2D>(), const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_antialiased = false); - void draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture> &p_texture, const Ref<Texture> &p_normal_map, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1)); - void draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture> &p_texture, const Ref<Texture> &p_normal_map); + void draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1)); + void draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map); void draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1); float draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, const String &p_next = "", const Color &p_modulate = Color(1, 1, 1)); diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index acb1b0b5a0..0e5c1b8c02 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -207,7 +207,7 @@ void CPUParticles2D::_update_mesh_texture() { VS::get_singleton()->mesh_add_surface_from_arrays(mesh, VS::PRIMITIVE_TRIANGLES, arr); } -void CPUParticles2D::set_texture(const Ref<Texture> &p_texture) { +void CPUParticles2D::set_texture(const Ref<Texture2D> &p_texture) { if (p_texture == texture) return; @@ -231,18 +231,18 @@ void CPUParticles2D::_texture_changed() { } } -Ref<Texture> CPUParticles2D::get_texture() const { +Ref<Texture2D> CPUParticles2D::get_texture() const { return texture; } -void CPUParticles2D::set_normalmap(const Ref<Texture> &p_normalmap) { +void CPUParticles2D::set_normalmap(const Ref<Texture2D> &p_normalmap) { normalmap = p_normalmap; update(); } -Ref<Texture> CPUParticles2D::get_normalmap() const { +Ref<Texture2D> CPUParticles2D::get_normalmap() const { return normalmap; } @@ -1286,8 +1286,8 @@ void CPUParticles2D::_bind_methods() { // No visibility_rect property contrarily to Particles2D, it's updated automatically. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates"); ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime"), "set_draw_order", "get_draw_order"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normalmap", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_normalmap", "get_normalmap"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normalmap", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normalmap", "get_normalmap"); BIND_ENUM_CONSTANT(DRAW_ORDER_INDEX); BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME); diff --git a/scene/2d/cpu_particles_2d.h b/scene/2d/cpu_particles_2d.h index d59b94bcbb..5eb563bbbc 100644 --- a/scene/2d/cpu_particles_2d.h +++ b/scene/2d/cpu_particles_2d.h @@ -147,8 +147,8 @@ private: DrawOrder draw_order; - Ref<Texture> texture; - Ref<Texture> normalmap; + Ref<Texture2D> texture; + Ref<Texture2D> normalmap; //////// @@ -230,11 +230,11 @@ public: void set_draw_passes(int p_count); int get_draw_passes() const; - void set_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_texture() const; - void set_normalmap(const Ref<Texture> &p_normalmap); - Ref<Texture> get_normalmap() const; + void set_normalmap(const Ref<Texture2D> &p_normalmap); + Ref<Texture2D> get_normalmap() const; /////////////////// diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index 1bffaf8084..c24ad9c1c4 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -125,7 +125,7 @@ bool Light2D::is_editor_only() const { return editor_only; } -void Light2D::set_texture(const Ref<Texture> &p_texture) { +void Light2D::set_texture(const Ref<Texture2D> &p_texture) { texture = p_texture; if (texture.is_valid()) @@ -136,7 +136,7 @@ void Light2D::set_texture(const Ref<Texture> &p_texture) { update_configuration_warning(); } -Ref<Texture> Light2D::get_texture() const { +Ref<Texture2D> Light2D::get_texture() const { return texture; } @@ -437,7 +437,7 @@ void Light2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_texture_offset", "get_texture_offset"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_scale", PROPERTY_HINT_RANGE, "0.01,50,0.01"), "set_texture_scale", "get_texture_scale"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index 65db5c6ee6..7c4e883454 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -74,7 +74,7 @@ private: float shadow_smooth; float shadow_gradient_length; Mode mode; - Ref<Texture> texture; + Ref<Texture2D> texture; Vector2 texture_offset; ShadowFilter shadow_filter; @@ -104,8 +104,8 @@ public: void set_editor_only(bool p_editor_only); bool is_editor_only() const; - void set_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_texture() const; void set_texture_offset(const Vector2 &p_offset); Vector2 get_texture_offset() const; diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index c31840c8e1..adc3ea174f 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -188,12 +188,12 @@ Ref<Gradient> Line2D::get_gradient() const { return _gradient; } -void Line2D::set_texture(const Ref<Texture> &p_texture) { +void Line2D::set_texture(const Ref<Texture2D> &p_texture) { _texture = p_texture; update(); } -Ref<Texture> Line2D::get_texture() const { +Ref<Texture2D> Line2D::get_texture() const { return _texture; } @@ -407,7 +407,7 @@ void Line2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::COLOR, "default_color"), "set_default_color", "get_default_color"); ADD_GROUP("Fill", ""); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gradient", PROPERTY_HINT_RESOURCE_TYPE, "Gradient"), "set_gradient", "get_gradient"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_mode", PROPERTY_HINT_ENUM, "None,Tile,Stretch"), "set_texture_mode", "get_texture_mode"); ADD_GROUP("Capping", ""); ADD_PROPERTY(PropertyInfo(Variant::INT, "joint_mode", PROPERTY_HINT_ENUM, "Sharp,Bevel,Round"), "set_joint_mode", "get_joint_mode"); diff --git a/scene/2d/line_2d.h b/scene/2d/line_2d.h index 3c7239f67c..b7e7f59403 100644 --- a/scene/2d/line_2d.h +++ b/scene/2d/line_2d.h @@ -89,8 +89,8 @@ public: void set_gradient(const Ref<Gradient> &gradient); Ref<Gradient> get_gradient() const; - void set_texture(const Ref<Texture> &texture); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &texture); + Ref<Texture2D> get_texture() const; void set_texture_mode(const LineTextureMode mode); LineTextureMode get_texture_mode() const; @@ -132,7 +132,7 @@ private: Ref<Curve> _curve; Color _default_color; Ref<Gradient> _gradient; - Ref<Texture> _texture; + Ref<Texture2D> _texture; LineTextureMode _texture_mode; float _sharp_limit; int _round_precision; diff --git a/scene/2d/mesh_instance_2d.cpp b/scene/2d/mesh_instance_2d.cpp index 93432ec40b..5e258be700 100644 --- a/scene/2d/mesh_instance_2d.cpp +++ b/scene/2d/mesh_instance_2d.cpp @@ -53,8 +53,8 @@ void MeshInstance2D::_bind_methods() { ADD_SIGNAL(MethodInfo("texture_changed")); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_normal_map", "get_normal_map"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normal_map", "get_normal_map"); } void MeshInstance2D::set_mesh(const Ref<Mesh> &p_mesh) { @@ -68,7 +68,7 @@ Ref<Mesh> MeshInstance2D::get_mesh() const { return mesh; } -void MeshInstance2D::set_texture(const Ref<Texture> &p_texture) { +void MeshInstance2D::set_texture(const Ref<Texture2D> &p_texture) { if (p_texture == texture) return; @@ -78,18 +78,18 @@ void MeshInstance2D::set_texture(const Ref<Texture> &p_texture) { _change_notify("texture"); } -void MeshInstance2D::set_normal_map(const Ref<Texture> &p_texture) { +void MeshInstance2D::set_normal_map(const Ref<Texture2D> &p_texture) { normal_map = p_texture; update(); } -Ref<Texture> MeshInstance2D::get_normal_map() const { +Ref<Texture2D> MeshInstance2D::get_normal_map() const { return normal_map; } -Ref<Texture> MeshInstance2D::get_texture() const { +Ref<Texture2D> MeshInstance2D::get_texture() const { return texture; } diff --git a/scene/2d/mesh_instance_2d.h b/scene/2d/mesh_instance_2d.h index 51f75a3ead..3356f44e91 100644 --- a/scene/2d/mesh_instance_2d.h +++ b/scene/2d/mesh_instance_2d.h @@ -38,8 +38,8 @@ class MeshInstance2D : public Node2D { Ref<Mesh> mesh; - Ref<Texture> texture; - Ref<Texture> normal_map; + Ref<Texture2D> texture; + Ref<Texture2D> normal_map; protected: void _notification(int p_what); @@ -53,11 +53,11 @@ public: void set_mesh(const Ref<Mesh> &p_mesh); Ref<Mesh> get_mesh() const; - void set_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_texture() const; - void set_normal_map(const Ref<Texture> &p_texture); - Ref<Texture> get_normal_map() const; + void set_normal_map(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_normal_map() const; MeshInstance2D(); }; diff --git a/scene/2d/multimesh_instance_2d.cpp b/scene/2d/multimesh_instance_2d.cpp index 028459e778..6620027020 100644 --- a/scene/2d/multimesh_instance_2d.cpp +++ b/scene/2d/multimesh_instance_2d.cpp @@ -53,8 +53,8 @@ void MultiMeshInstance2D::_bind_methods() { ADD_SIGNAL(MethodInfo("texture_changed")); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multimesh", PROPERTY_HINT_RESOURCE_TYPE, "MultiMesh"), "set_multimesh", "get_multimesh"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_normal_map", "get_normal_map"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normal_map", "get_normal_map"); } void MultiMeshInstance2D::set_multimesh(const Ref<MultiMesh> &p_multimesh) { @@ -68,7 +68,7 @@ Ref<MultiMesh> MultiMeshInstance2D::get_multimesh() const { return multimesh; } -void MultiMeshInstance2D::set_texture(const Ref<Texture> &p_texture) { +void MultiMeshInstance2D::set_texture(const Ref<Texture2D> &p_texture) { if (p_texture == texture) return; @@ -78,18 +78,18 @@ void MultiMeshInstance2D::set_texture(const Ref<Texture> &p_texture) { _change_notify("texture"); } -Ref<Texture> MultiMeshInstance2D::get_texture() const { +Ref<Texture2D> MultiMeshInstance2D::get_texture() const { return texture; } -void MultiMeshInstance2D::set_normal_map(const Ref<Texture> &p_texture) { +void MultiMeshInstance2D::set_normal_map(const Ref<Texture2D> &p_texture) { normal_map = p_texture; update(); } -Ref<Texture> MultiMeshInstance2D::get_normal_map() const { +Ref<Texture2D> MultiMeshInstance2D::get_normal_map() const { return normal_map; } diff --git a/scene/2d/multimesh_instance_2d.h b/scene/2d/multimesh_instance_2d.h index c3f3e52920..a843606ebf 100644 --- a/scene/2d/multimesh_instance_2d.h +++ b/scene/2d/multimesh_instance_2d.h @@ -39,8 +39,8 @@ class MultiMeshInstance2D : public Node2D { Ref<MultiMesh> multimesh; - Ref<Texture> texture; - Ref<Texture> normal_map; + Ref<Texture2D> texture; + Ref<Texture2D> normal_map; protected: void _notification(int p_what); @@ -54,11 +54,11 @@ public: void set_multimesh(const Ref<MultiMesh> &p_multimesh); Ref<MultiMesh> get_multimesh() const; - void set_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_texture() const; - void set_normal_map(const Ref<Texture> &p_texture); - Ref<Texture> get_normal_map() const; + void set_normal_map(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_normal_map() const; MultiMeshInstance2D(); ~MultiMeshInstance2D(); diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index 746feeaa82..d3bc7b6a5a 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -268,22 +268,22 @@ Rect2 Particles2D::capture_rect() const { return r; } -void Particles2D::set_texture(const Ref<Texture> &p_texture) { +void Particles2D::set_texture(const Ref<Texture2D> &p_texture) { texture = p_texture; update(); } -Ref<Texture> Particles2D::get_texture() const { +Ref<Texture2D> Particles2D::get_texture() const { return texture; } -void Particles2D::set_normal_map(const Ref<Texture> &p_normal_map) { +void Particles2D::set_normal_map(const Ref<Texture2D> &p_normal_map) { normal_map = p_normal_map; update(); } -Ref<Texture> Particles2D::get_normal_map() const { +Ref<Texture2D> Particles2D::get_normal_map() const { return normal_map; } @@ -399,8 +399,8 @@ void Particles2D::_bind_methods() { ADD_GROUP("Process Material", "process_"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "process_material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,ParticlesMaterial"), "set_process_material", "get_process_material"); ADD_GROUP("Textures", ""); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_normal_map", "get_normal_map"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normal_map", "get_normal_map"); BIND_ENUM_CONSTANT(DRAW_ORDER_INDEX); BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME); diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h index 56c328fc38..66281d7950 100644 --- a/scene/2d/particles_2d.h +++ b/scene/2d/particles_2d.h @@ -64,8 +64,8 @@ private: DrawOrder draw_order; - Ref<Texture> texture; - Ref<Texture> normal_map; + Ref<Texture2D> texture; + Ref<Texture2D> normal_map; void _update_particle_emission_transform(); @@ -108,11 +108,11 @@ public: void set_draw_order(DrawOrder p_order); DrawOrder get_draw_order() const; - void set_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_texture() const; - void set_normal_map(const Ref<Texture> &p_normal_map); - Ref<Texture> get_normal_map() const; + void set_normal_map(const Ref<Texture2D> &p_normal_map); + Ref<Texture2D> get_normal_map() const; virtual String get_configuration_warning() const; diff --git a/scene/2d/path_texture.cpp b/scene/2d/path_texture.cpp index df59c9e2bb..590f70a1b2 100644 --- a/scene/2d/path_texture.cpp +++ b/scene/2d/path_texture.cpp @@ -30,33 +30,33 @@ #include "path_texture.h" -void PathTexture::set_begin_texture(const Ref<Texture> &p_texture) { +void PathTexture::set_begin_texture(const Ref<Texture2D> &p_texture) { begin = p_texture; update(); } -Ref<Texture> PathTexture::get_begin_texture() const { +Ref<Texture2D> PathTexture::get_begin_texture() const { return begin; } -void PathTexture::set_repeat_texture(const Ref<Texture> &p_texture) { +void PathTexture::set_repeat_texture(const Ref<Texture2D> &p_texture) { repeat = p_texture; update(); } -Ref<Texture> PathTexture::get_repeat_texture() const { +Ref<Texture2D> PathTexture::get_repeat_texture() const { return repeat; } -void PathTexture::set_end_texture(const Ref<Texture> &p_texture) { +void PathTexture::set_end_texture(const Ref<Texture2D> &p_texture) { end = p_texture; update(); } -Ref<Texture> PathTexture::get_end_texture() const { +Ref<Texture2D> PathTexture::get_end_texture() const { return end; } diff --git a/scene/2d/path_texture.h b/scene/2d/path_texture.h index 9cfa004cfb..014d0dc959 100644 --- a/scene/2d/path_texture.h +++ b/scene/2d/path_texture.h @@ -36,21 +36,21 @@ class PathTexture : public Node2D { GDCLASS(PathTexture, Node2D); - Ref<Texture> begin; - Ref<Texture> repeat; - Ref<Texture> end; + Ref<Texture2D> begin; + Ref<Texture2D> repeat; + Ref<Texture2D> end; int subdivs; bool overlap; public: - void set_begin_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_begin_texture() const; + void set_begin_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_begin_texture() const; - void set_repeat_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_repeat_texture() const; + void set_repeat_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_repeat_texture() const; - void set_end_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_end_texture() const; + void set_end_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_end_texture() const; void set_subdivisions(int p_amount); int get_subdivisions() const; diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index a6da027e0a..da7488b8d8 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -414,7 +414,7 @@ PoolVector<Color> Polygon2D::get_vertex_colors() const { return vertex_colors; } -void Polygon2D::set_texture(const Ref<Texture> &p_texture) { +void Polygon2D::set_texture(const Ref<Texture2D> &p_texture) { texture = p_texture; @@ -428,7 +428,7 @@ void Polygon2D::set_texture(const Ref<Texture> &p_texture) { }*/ update(); } -Ref<Texture> Polygon2D::get_texture() const { +Ref<Texture2D> Polygon2D::get_texture() const { return texture; } @@ -650,9 +650,9 @@ void Polygon2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "antialiased"), "set_antialiased", "get_antialiased"); - ADD_GROUP("Texture", ""); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); - ADD_GROUP("Texture", "texture_"); + ADD_GROUP("Texture2D", ""); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); + ADD_GROUP("Texture2D", "texture_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_offset"), "set_texture_offset", "get_texture_offset"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_scale"), "set_texture_scale", "get_texture_scale"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_rotation_degrees", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater"), "set_texture_rotation_degrees", "get_texture_rotation_degrees"); diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index 07b8828532..929941765f 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -51,7 +51,7 @@ class Polygon2D : public Node2D { Vector<Bone> bone_weights; Color color; - Ref<Texture> texture; + Ref<Texture2D> texture; Size2 tex_scale; Vector2 tex_ofs; bool tex_tile; @@ -108,8 +108,8 @@ public: void set_vertex_colors(const PoolVector<Color> &p_colors); PoolVector<Color> get_vertex_colors() const; - void set_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_texture() const; void set_texture_offset(const Vector2 &p_offset); Vector2 get_texture_offset() const; diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index 55daed0585..34ad45f4bd 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -136,7 +136,7 @@ void Sprite::_notification(int p_what) { } } -void Sprite::set_texture(const Ref<Texture> &p_texture) { +void Sprite::set_texture(const Ref<Texture2D> &p_texture) { if (p_texture == texture) return; @@ -155,18 +155,18 @@ void Sprite::set_texture(const Ref<Texture> &p_texture) { _change_notify("texture"); } -void Sprite::set_normal_map(const Ref<Texture> &p_texture) { +void Sprite::set_normal_map(const Ref<Texture2D> &p_texture) { normal_map = p_texture; update(); } -Ref<Texture> Sprite::get_normal_map() const { +Ref<Texture2D> Sprite::get_normal_map() const { return normal_map; } -Ref<Texture> Sprite::get_texture() const { +Ref<Texture2D> Sprite::get_texture() const { return texture; } @@ -334,9 +334,9 @@ bool Sprite::is_pixel_opaque(const Point2 &p_point) const { if (vflip) q.y = 1.0f - q.y; q = q * src_rect.size + src_rect.position; - - bool is_repeat = texture->get_flags() & Texture::FLAG_REPEAT; - bool is_mirrored_repeat = texture->get_flags() & Texture::FLAG_MIRRORED_REPEAT; +#warning this need to be obtained from CanvasItem repeat mode when I add it + bool is_repeat = false; + bool is_mirrored_repeat = false; if (is_repeat) { int mirror_x = 0; int mirror_y = 0; @@ -457,8 +457,8 @@ void Sprite::_bind_methods() { ADD_SIGNAL(MethodInfo("frame_changed")); ADD_SIGNAL(MethodInfo("texture_changed")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_normal_map", "get_normal_map"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normal_map", "get_normal_map"); ADD_GROUP("Offset", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "centered"), "set_centered", "is_centered"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h index d72bf3168d..55f78015eb 100644 --- a/scene/2d/sprite.h +++ b/scene/2d/sprite.h @@ -38,8 +38,8 @@ class Sprite : public Node2D { GDCLASS(Sprite, Node2D); - Ref<Texture> texture; - Ref<Texture> normal_map; + Ref<Texture2D> texture; + Ref<Texture2D> normal_map; bool centered; Point2 offset; @@ -82,11 +82,11 @@ public: bool is_pixel_opaque(const Point2 &p_point) const; - void set_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_texture() const; - void set_normal_map(const Ref<Texture> &p_texture); - Ref<Texture> get_normal_map() const; + void set_normal_map(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_normal_map() const; void set_centered(bool p_center); bool is_centered() const; diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index d8b880e571..c6400446f0 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -399,7 +399,7 @@ void TileMap::update_dirty_quadrants() { //moment of truth if (!tile_set->has_tile(c.id)) continue; - Ref<Texture> tex = tile_set->tile_get_texture(c.id); + Ref<Texture2D> tex = tile_set->tile_get_texture(c.id); Vector2 tile_ofs = tile_set->tile_get_texture_offset(c.id); Vector2 wofs = _map_to_world(E->key().x, E->key().y); @@ -542,7 +542,7 @@ void TileMap::update_dirty_quadrants() { rect.position += tile_ofs; } - Ref<Texture> normal_map = tile_set->tile_get_normal_map(c.id); + Ref<Texture2D> normal_map = tile_set->tile_get_normal_map(c.id); Color modulate = tile_set->tile_get_modulate(c.id); Color self_modulate = get_self_modulate(); modulate = Color(modulate.r * self_modulate.r, modulate.g * self_modulate.g, diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp index 42d9f88a60..beff74f496 100644 --- a/scene/2d/touch_screen_button.cpp +++ b/scene/2d/touch_screen_button.cpp @@ -34,24 +34,24 @@ #include "core/os/input.h" #include "core/os/os.h" -void TouchScreenButton::set_texture(const Ref<Texture> &p_texture) { +void TouchScreenButton::set_texture(const Ref<Texture2D> &p_texture) { texture = p_texture; update(); } -Ref<Texture> TouchScreenButton::get_texture() const { +Ref<Texture2D> TouchScreenButton::get_texture() const { return texture; } -void TouchScreenButton::set_texture_pressed(const Ref<Texture> &p_texture_pressed) { +void TouchScreenButton::set_texture_pressed(const Ref<Texture2D> &p_texture_pressed) { texture_pressed = p_texture_pressed; update(); } -Ref<Texture> TouchScreenButton::get_texture_pressed() const { +Ref<Texture2D> TouchScreenButton::get_texture_pressed() const { return texture_pressed; } @@ -397,8 +397,8 @@ void TouchScreenButton::_bind_methods() { ClassDB::bind_method(D_METHOD("_input"), &TouchScreenButton::_input); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "pressed", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture_pressed", "get_texture_pressed"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "pressed", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture_pressed", "get_texture_pressed"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "bitmask", PROPERTY_HINT_RESOURCE_TYPE, "BitMap"), "set_bitmask", "get_bitmask"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape2D"), "set_shape", "get_shape"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shape_centered"), "set_shape_centered", "is_shape_centered"); diff --git a/scene/2d/touch_screen_button.h b/scene/2d/touch_screen_button.h index 28dba59402..42e93f7048 100644 --- a/scene/2d/touch_screen_button.h +++ b/scene/2d/touch_screen_button.h @@ -47,8 +47,8 @@ public: }; private: - Ref<Texture> texture; - Ref<Texture> texture_pressed; + Ref<Texture2D> texture; + Ref<Texture2D> texture_pressed; Ref<BitMap> bitmask; Ref<Shape2D> shape; bool shape_centered; @@ -79,11 +79,11 @@ public: virtual bool _edit_use_rect() const; #endif - void set_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_texture() const; - void set_texture_pressed(const Ref<Texture> &p_texture_pressed); - Ref<Texture> get_texture_pressed() const; + void set_texture_pressed(const Ref<Texture2D> &p_texture_pressed); + Ref<Texture2D> get_texture_pressed() const; void set_bitmask(const Ref<BitMap> &p_bitmask); Ref<BitMap> get_bitmask() const; diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index 071afd1a69..d199e53db5 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -86,7 +86,7 @@ float BakedLightmapData::get_energy() const { return energy; } -void BakedLightmapData::add_user(const NodePath &p_path, const Ref<Texture> &p_lightmap, int p_instance) { +void BakedLightmapData::add_user(const NodePath &p_path, const Ref<Texture2D> &p_lightmap, int p_instance) { ERR_FAIL_COND_MSG(p_lightmap.is_null(), "It's not a reference to a valid Texture object."); User user; @@ -105,9 +105,9 @@ NodePath BakedLightmapData::get_user_path(int p_user) const { ERR_FAIL_INDEX_V(p_user, users.size(), NodePath()); return users[p_user].path; } -Ref<Texture> BakedLightmapData::get_user_lightmap(int p_user) const { +Ref<Texture2D> BakedLightmapData::get_user_lightmap(int p_user) const { - ERR_FAIL_INDEX_V(p_user, users.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_user, users.size(), Ref<Texture2D>()); return users[p_user].lightmap; } @@ -491,7 +491,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi Ref<Image> image; image.instance(); - uint32_t tex_flags = Texture::FLAGS_DEFAULT; if (hdr) { //just save a regular image @@ -534,11 +533,10 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi //This texture is saved to SRGB for two reasons: // 1) first is so it looks better when doing the LINEAR->SRGB conversion (more accurate) // 2) So it can be used in the GLES2 backend, which does not support linkear workflow - tex_flags |= Texture::FLAG_CONVERT_TO_LINEAR; } String image_path = save_path.plus_file(mesh_name); - Ref<Texture> texture; + Ref<Texture2D> texture; if (ResourceLoader::import) { @@ -583,7 +581,7 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi tex.instance(); } - tex->create_from_image(image, tex_flags); + tex->create_from_image(image); err = ResourceSaver::save(image_path, tex, ResourceSaver::FLAG_CHANGE_PATH); if (set_path) { @@ -668,7 +666,7 @@ void BakedLightmap::_assign_lightmaps() { ERR_FAIL_COND(!light_data.is_valid()); for (int i = 0; i < light_data->get_user_count(); i++) { - Ref<Texture> lightmap = light_data->get_user_lightmap(i); + Ref<Texture2D> lightmap = light_data->get_user_lightmap(i); ERR_CONTINUE(!lightmap.is_valid()); Node *node = get_node(light_data->get_user_path(i)); diff --git a/scene/3d/baked_lightmap.h b/scene/3d/baked_lightmap.h index 82354cc9f0..895a52aad8 100644 --- a/scene/3d/baked_lightmap.h +++ b/scene/3d/baked_lightmap.h @@ -47,7 +47,7 @@ class BakedLightmapData : public Resource { struct User { NodePath path; - Ref<Texture> lightmap; + Ref<Texture2D> lightmap; int instance_index; }; @@ -75,10 +75,10 @@ public: void set_energy(float p_energy); float get_energy() const; - void add_user(const NodePath &p_path, const Ref<Texture> &p_lightmap, int p_instance = -1); + void add_user(const NodePath &p_path, const Ref<Texture2D> &p_lightmap, int p_instance = -1); int get_user_count() const; NodePath get_user_path(int p_user) const; - Ref<Texture> get_user_lightmap(int p_user) const; + Ref<Texture2D> get_user_lightmap(int p_user) const; int get_user_instance(int p_user) const; void clear_users(); diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp index 0a1beaf3f4..afe60226b6 100644 --- a/scene/3d/immediate_geometry.cpp +++ b/scene/3d/immediate_geometry.cpp @@ -30,7 +30,7 @@ #include "immediate_geometry.h" -void ImmediateGeometry::begin(Mesh::PrimitiveType p_primitive, const Ref<Texture> &p_texture) { +void ImmediateGeometry::begin(Mesh::PrimitiveType p_primitive, const Ref<Texture2D> &p_texture) { VS::get_singleton()->immediate_begin(im, (VS::PrimitiveType)p_primitive, p_texture.is_valid() ? p_texture->get_rid() : RID()); if (p_texture.is_valid()) @@ -144,7 +144,7 @@ void ImmediateGeometry::add_sphere(int p_lats, int p_lons, float p_radius, bool void ImmediateGeometry::_bind_methods() { - ClassDB::bind_method(D_METHOD("begin", "primitive", "texture"), &ImmediateGeometry::begin, DEFVAL(Ref<Texture>())); + ClassDB::bind_method(D_METHOD("begin", "primitive", "texture"), &ImmediateGeometry::begin, DEFVAL(Ref<Texture2D>())); ClassDB::bind_method(D_METHOD("set_normal", "normal"), &ImmediateGeometry::set_normal); ClassDB::bind_method(D_METHOD("set_tangent", "tangent"), &ImmediateGeometry::set_tangent); ClassDB::bind_method(D_METHOD("set_color", "color"), &ImmediateGeometry::set_color); diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h index f45ebd6724..7f506ce9ef 100644 --- a/scene/3d/immediate_geometry.h +++ b/scene/3d/immediate_geometry.h @@ -41,7 +41,7 @@ class ImmediateGeometry : public GeometryInstance { RID im; //a list of textures drawn need to be kept, to avoid references // in VisualServer from becoming invalid if the texture is no longer used - List<Ref<Texture> > cached_textures; + List<Ref<Texture2D> > cached_textures; bool empty; AABB aabb; @@ -49,7 +49,7 @@ protected: static void _bind_methods(); public: - void begin(Mesh::PrimitiveType p_primitive, const Ref<Texture> &p_texture = Ref<Texture>()); + void begin(Mesh::PrimitiveType p_primitive, const Ref<Texture2D> &p_texture = Ref<Texture2D>()); void set_normal(const Vector3 &p_normal); void set_tangent(const Plane &p_tangent); void set_color(const Color &p_color); diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index a4c81b864d..6656f8d751 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -525,7 +525,7 @@ void Sprite3D::_draw() { VS::get_singleton()->immediate_end(immediate); } -void Sprite3D::set_texture(const Ref<Texture> &p_texture) { +void Sprite3D::set_texture(const Ref<Texture2D> &p_texture) { if (p_texture == texture) return; @@ -534,13 +534,12 @@ void Sprite3D::set_texture(const Ref<Texture> &p_texture) { } texture = p_texture; if (texture.is_valid()) { - texture->set_flags(texture->get_flags()); //remove repeat from texture, it looks bad in sprites texture->connect(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->_queue_update); } _queue_update(); } -Ref<Texture> Sprite3D::get_texture() const { +Ref<Texture2D> Sprite3D::get_texture() const { return texture; } @@ -691,7 +690,7 @@ void Sprite3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_hframes", "hframes"), &Sprite3D::set_hframes); ClassDB::bind_method(D_METHOD("get_hframes"), &Sprite3D::get_hframes); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); ADD_GROUP("Animation", ""); ADD_PROPERTY(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_vframes", "get_vframes"); ADD_PROPERTY(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_hframes", "get_hframes"); @@ -731,7 +730,7 @@ void AnimatedSprite3D::_draw() { return; } - Ref<Texture> texture = frames->get_frame(animation, frame); + Ref<Texture2D> texture = frames->get_frame(animation, frame); if (!texture.is_valid()) return; //no texuture no life Vector2 tsize = texture->get_size(); @@ -1003,7 +1002,7 @@ Rect2 AnimatedSprite3D::get_item_rect() const { return Rect2(0, 0, 1, 1); } - Ref<Texture> t; + Ref<Texture2D> t; if (animation) t = frames->get_frame(animation, frame); if (t.is_null()) diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index ddbade147c..8ec07b46ca 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -147,7 +147,7 @@ public: class Sprite3D : public SpriteBase3D { GDCLASS(Sprite3D, SpriteBase3D); - Ref<Texture> texture; + Ref<Texture2D> texture; bool region; Rect2 region_rect; @@ -164,8 +164,8 @@ protected: virtual void _validate_property(PropertyInfo &property) const; public: - void set_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_texture() const; void set_region(bool p_region); bool is_region() const; diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp index c1ec59d49f..1b6e328342 100644 --- a/scene/3d/voxel_light_baker.cpp +++ b/scene/3d/voxel_light_baker.cpp @@ -527,7 +527,7 @@ VoxelLightBaker::MaterialCache VoxelLightBaker::_get_material_cache(Ref<Material if (mat.is_valid()) { - Ref<Texture> albedo_tex = mat->get_texture(SpatialMaterial::TEXTURE_ALBEDO); + Ref<Texture2D> albedo_tex = mat->get_texture(SpatialMaterial::TEXTURE_ALBEDO); Ref<Image> img_albedo; if (albedo_tex.is_valid()) { @@ -538,7 +538,7 @@ VoxelLightBaker::MaterialCache VoxelLightBaker::_get_material_cache(Ref<Material mc.albedo = _get_bake_texture(img_albedo, Color(1, 1, 1), mat->get_albedo()); // no albedo texture, color is additive } - Ref<Texture> emission_tex = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION); + Ref<Texture2D> emission_tex = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION); Color emission_col = mat->get_emission(); float emission_energy = mat->get_emission_energy(); diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 6f3d8c61cf..04ff11f20c 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -40,7 +40,7 @@ Size2 Button::get_minimum_size() const { minsize.width = 0; if (!expand_icon) { - Ref<Texture> _icon; + Ref<Texture2D> _icon; if (icon.is_null() && has_icon("icon")) _icon = Control::get_icon("icon"); else @@ -150,7 +150,7 @@ void Button::_notification(int p_what) { } Ref<Font> font = get_font("font"); - Ref<Texture> _icon; + Ref<Texture2D> _icon; if (icon.is_null() && has_icon("icon")) _icon = Control::get_icon("icon"); else @@ -249,7 +249,7 @@ String Button::get_text() const { return text; } -void Button::set_icon(const Ref<Texture> &p_icon) { +void Button::set_icon(const Ref<Texture2D> &p_icon) { if (icon == p_icon) return; @@ -259,7 +259,7 @@ void Button::set_icon(const Ref<Texture> &p_icon) { minimum_size_changed(); } -Ref<Texture> Button::get_icon() const { +Ref<Texture2D> Button::get_icon() const { return icon; } @@ -331,7 +331,7 @@ void Button::_bind_methods() { BIND_ENUM_CONSTANT(ALIGN_RIGHT); ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), "set_text", "get_text"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_button_icon", "get_button_icon"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_button_icon", "get_button_icon"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), "set_flat", "is_flat"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "clip_text"), "set_clip_text", "get_clip_text"); ADD_PROPERTY(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right"), "set_text_align", "get_text_align"); diff --git a/scene/gui/button.h b/scene/gui/button.h index e975dc52a5..3135b98578 100644 --- a/scene/gui/button.h +++ b/scene/gui/button.h @@ -48,7 +48,7 @@ private: bool flat; String text; String xl_text; - Ref<Texture> icon; + Ref<Texture2D> icon; bool expand_icon; bool clip_text; TextAlign align; @@ -65,8 +65,8 @@ public: void set_text(const String &p_text); String get_text() const; - void set_icon(const Ref<Texture> &p_icon); - Ref<Texture> get_icon() const; + void set_icon(const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_icon() const; void set_expand_icon(bool p_expand_icon); bool is_expand_icon() const; diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index 443121db32..89bd8ab0dd 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -33,10 +33,10 @@ #include "servers/visual_server.h" Size2 CheckBox::get_icon_size() const { - Ref<Texture> checked = Control::get_icon("checked"); - Ref<Texture> unchecked = Control::get_icon("unchecked"); - Ref<Texture> radio_checked = Control::get_icon("radio_checked"); - Ref<Texture> radio_unchecked = Control::get_icon("radio_unchecked"); + Ref<Texture2D> checked = Control::get_icon("checked"); + Ref<Texture2D> unchecked = Control::get_icon("unchecked"); + Ref<Texture2D> radio_checked = Control::get_icon("radio_checked"); + Ref<Texture2D> radio_unchecked = Control::get_icon("radio_unchecked"); Size2 tex_size = Size2(0, 0); if (!checked.is_null()) @@ -73,8 +73,8 @@ void CheckBox::_notification(int p_what) { RID ci = get_canvas_item(); - Ref<Texture> on = Control::get_icon(is_radio() ? "radio_checked" : "checked"); - Ref<Texture> off = Control::get_icon(is_radio() ? "radio_unchecked" : "unchecked"); + Ref<Texture2D> on = Control::get_icon(is_radio() ? "radio_checked" : "checked"); + Ref<Texture2D> off = Control::get_icon(is_radio() ? "radio_unchecked" : "unchecked"); Ref<StyleBox> sb = get_stylebox("normal"); Vector2 ofs; diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index 9d6df94cce..0b093ce850 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -35,8 +35,8 @@ Size2 CheckButton::get_icon_size() const { - Ref<Texture> on = Control::get_icon(is_disabled() ? "on_disabled" : "on"); - Ref<Texture> off = Control::get_icon(is_disabled() ? "off_disabled" : "off"); + Ref<Texture2D> on = Control::get_icon(is_disabled() ? "on_disabled" : "on"); + Ref<Texture2D> off = Control::get_icon(is_disabled() ? "off_disabled" : "off"); Size2 tex_size = Size2(0, 0); if (!on.is_null()) tex_size = Size2(on->get_width(), on->get_height()); @@ -68,8 +68,8 @@ void CheckButton::_notification(int p_what) { RID ci = get_canvas_item(); - Ref<Texture> on = Control::get_icon(is_disabled() ? "on_disabled" : "on"); - Ref<Texture> off = Control::get_icon(is_disabled() ? "off_disabled" : "off"); + Ref<Texture2D> on = Control::get_icon(is_disabled() ? "on_disabled" : "on"); + Ref<Texture2D> off = Control::get_icon(is_disabled() ? "off_disabled" : "off"); Ref<StyleBox> sb = get_stylebox("normal"); Vector2 ofs; diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 01f4070883..68c12c38fa 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -445,7 +445,7 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted()); c->draw_line(Point2(x, y), Point2(x, y), Color(1, 1, 1), 2); } else if (p_which == 1) { - Ref<Texture> hue = get_icon("color_hue", "ColorPicker"); + Ref<Texture2D> hue = get_icon("color_hue", "ColorPicker"); c->draw_texture_rect(hue, Rect2(Point2(), c->get_size())); int y = c->get_size().y - c->get_size().y * (1.0 - h); Color col = Color(); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 4c70bd1d39..be211504a6 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -358,7 +358,7 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const { if (data.icon_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; - p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_icons/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Texture", hint)); + p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_icons/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", hint)); } } { @@ -813,11 +813,11 @@ Size2 Control::get_minimum_size() const { return Size2(); } -Ref<Texture> Control::get_icon(const StringName &p_name, const StringName &p_type) const { +Ref<Texture2D> Control::get_icon(const StringName &p_name, const StringName &p_type) const { if (p_type == StringName() || p_type == get_class_name()) { - const Ref<Texture> *tex = data.icon_override.getptr(p_name); + const Ref<Texture2D> *tex = data.icon_override.getptr(p_name); if (tex) return *tex; } @@ -1063,7 +1063,7 @@ int Control::get_constant(const StringName &p_name, const StringName &p_type) co bool Control::has_icon_override(const StringName &p_name) const { - const Ref<Texture> *tex = data.icon_override.getptr(p_name); + const Ref<Texture2D> *tex = data.icon_override.getptr(p_name); return tex != NULL; } @@ -1880,7 +1880,7 @@ Rect2 Control::get_anchorable_rect() const { return Rect2(Point2(), get_size()); } -void Control::add_icon_override(const StringName &p_name, const Ref<Texture> &p_icon) { +void Control::add_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon) { if (data.icon_override.has(p_name)) { data.icon_override[p_name]->disconnect("changed", this, "_override_changed"); diff --git a/scene/gui/control.h b/scene/gui/control.h index 357858beb6..67e8ed0d27 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -198,7 +198,7 @@ private: NodePath focus_next; NodePath focus_prev; - HashMap<StringName, Ref<Texture> > icon_override; + HashMap<StringName, Ref<Texture2D> > icon_override; HashMap<StringName, Ref<Shader> > shader_override; HashMap<StringName, Ref<StyleBox> > style_override; HashMap<StringName, Ref<Font> > font_override; @@ -420,14 +420,14 @@ public: /* SKINNING */ - void add_icon_override(const StringName &p_name, const Ref<Texture> &p_icon); + void add_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon); void add_shader_override(const StringName &p_name, const Ref<Shader> &p_shader); void add_style_override(const StringName &p_name, const Ref<StyleBox> &p_style); void add_font_override(const StringName &p_name, const Ref<Font> &p_font); void add_color_override(const StringName &p_name, const Color &p_color); void add_constant_override(const StringName &p_name, int p_constant); - Ref<Texture> get_icon(const StringName &p_name, const StringName &p_type = StringName()) const; + Ref<Texture2D> get_icon(const StringName &p_name, const StringName &p_type = StringName()) const; Ref<Shader> get_shader(const StringName &p_name, const StringName &p_type = StringName()) const; Ref<StyleBox> get_stylebox(const StringName &p_name, const StringName &p_type = StringName()) const; Ref<Font> get_font(const StringName &p_name, const StringName &p_type = StringName()) const; diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 2cc9c1a53a..6e7491e7b4 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -424,7 +424,7 @@ void FileDialog::update_file_list() { dir_access->list_dir_begin(); TreeItem *root = tree->create_item(); - Ref<Texture> folder = get_icon("folder"); + Ref<Texture2D> folder = get_icon("folder"); const Color folder_color = get_color("folder_icon_modulate"); List<String> files; List<String> dirs; @@ -518,7 +518,7 @@ void FileDialog::update_file_list() { if (get_icon_func) { - Ref<Texture> icon = get_icon_func(base_dir.plus_file(files.front()->get())); + Ref<Texture2D> icon = get_icon_func(base_dir.plus_file(files.front()->get())); ti->set_icon(0, icon); } diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index d9ab00e0f2..9f6650c276 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -58,7 +58,7 @@ public: MODE_SAVE_FILE }; - typedef Ref<Texture> (*GetIconFunc)(const String &); + typedef Ref<Texture2D> (*GetIconFunc)(const String &); typedef void (*RegisterFunc)(FileDialog *); static GetIconFunc get_icon_func; diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index 46c59f42fc..80431cefe0 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -54,7 +54,6 @@ GradientEdit::GradientEdit() { checker = Ref<ImageTexture>(memnew(ImageTexture)); Ref<Image> img = memnew(Image(checker_bg_png)); - checker->create_from_image(img, ImageTexture::FLAG_REPEAT); } int GradientEdit::_get_point_from_pos(int x) { diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index c09b2414b2..02445000df 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -357,7 +357,7 @@ void GraphEdit::_notification(int p_what) { bool GraphEdit::_filter_input(const Point2 &p_point) { - Ref<Texture> port = get_icon("port", "GraphNode"); + Ref<Texture2D> port = get_icon("port", "GraphNode"); for (int i = get_child_count() - 1; i >= 0; i--) { @@ -389,7 +389,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { Ref<InputEventMouseButton> mb = p_ev; if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) { - Ref<Texture> port = get_icon("port", "GraphNode"); + Ref<Texture2D> port = get_icon("port", "GraphNode"); Vector2 mpos(mb->get_position().x, mb->get_position().y); for (int i = get_child_count() - 1; i >= 0; i--) { @@ -501,7 +501,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { connecting_target = false; top_layer->update(); - Ref<Texture> port = get_icon("port", "GraphNode"); + Ref<Texture2D> port = get_icon("port", "GraphNode"); Vector2 mpos = mm->get_position(); for (int i = get_child_count() - 1; i >= 0; i--) { diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 7b1bfdfdb5..82e890395a 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -170,7 +170,7 @@ bool GraphNode::has_point(const Point2 &p_point) const { if (comment) { Ref<StyleBox> comment = get_stylebox("comment"); - Ref<Texture> resizer = get_icon("resizer"); + Ref<Texture2D> resizer = get_icon("resizer"); if (Rect2(get_size() - resizer->get_size(), resizer->get_size()).has_point(p_point)) { return true; @@ -204,9 +204,9 @@ void GraphNode::_notification(int p_what) { //sb=sb->duplicate(); //sb->call("set_modulate",modulate); - Ref<Texture> port = get_icon("port"); - Ref<Texture> close = get_icon("close"); - Ref<Texture> resizer = get_icon("resizer"); + Ref<Texture2D> port = get_icon("port"); + Ref<Texture2D> close = get_icon("close"); + Ref<Texture2D> resizer = get_icon("resizer"); int close_offset = get_constant("close_offset"); int close_h_offset = get_constant("close_h_offset"); Color close_color = get_color("close_color"); @@ -259,14 +259,14 @@ void GraphNode::_notification(int p_what) { const Slot &s = slot_info[E->key()]; //left if (s.enable_left) { - Ref<Texture> p = port; + Ref<Texture2D> p = port; if (s.custom_slot_left.is_valid()) { p = s.custom_slot_left; } p->draw(get_canvas_item(), icofs + Point2(edgeofs, cache_y[E->key()]), s.color_left); } if (s.enable_right) { - Ref<Texture> p = port; + Ref<Texture2D> p = port; if (s.custom_slot_right.is_valid()) { p = s.custom_slot_right; } @@ -291,7 +291,7 @@ void GraphNode::_notification(int p_what) { } } -void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture> &p_custom_left, const Ref<Texture> &p_custom_right) { +void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture2D> &p_custom_left, const Ref<Texture2D> &p_custom_right) { ERR_FAIL_COND(p_idx < 0); @@ -379,7 +379,7 @@ Size2 GraphNode::get_minimum_size() const { Size2 minsize; minsize.x = title_font->get_string_size(title).x; if (show_close) { - Ref<Texture> close = get_icon("close"); + Ref<Texture2D> close = get_icon("close"); minsize.x += sep + close->get_width(); } @@ -606,7 +606,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { return; } - Ref<Texture> resizer = get_icon("resizer"); + Ref<Texture2D> resizer = get_icon("resizer"); if (resizable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) { @@ -674,7 +674,7 @@ void GraphNode::_bind_methods() { ClassDB::bind_method(D_METHOD("get_title"), &GraphNode::get_title); ClassDB::bind_method(D_METHOD("_gui_input"), &GraphNode::_gui_input); - ClassDB::bind_method(D_METHOD("set_slot", "idx", "enable_left", "type_left", "color_left", "enable_right", "type_right", "color_right", "custom_left", "custom_right"), &GraphNode::set_slot, DEFVAL(Ref<Texture>()), DEFVAL(Ref<Texture>())); + ClassDB::bind_method(D_METHOD("set_slot", "idx", "enable_left", "type_left", "color_left", "enable_right", "type_right", "color_right", "custom_left", "custom_right"), &GraphNode::set_slot, DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>())); ClassDB::bind_method(D_METHOD("clear_slot", "idx"), &GraphNode::clear_slot); ClassDB::bind_method(D_METHOD("clear_all_slots"), &GraphNode::clear_all_slots); ClassDB::bind_method(D_METHOD("is_slot_enabled_left", "idx"), &GraphNode::is_slot_enabled_left); diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h index e1a81b5f3d..a3eb8ed152 100644 --- a/scene/gui/graph_node.h +++ b/scene/gui/graph_node.h @@ -52,8 +52,8 @@ private: bool enable_right; int type_right; Color color_right; - Ref<Texture> custom_slot_left; - Ref<Texture> custom_slot_right; + Ref<Texture2D> custom_slot_left; + Ref<Texture2D> custom_slot_right; Slot() { enable_left = false; @@ -112,7 +112,7 @@ protected: public: bool has_point(const Point2 &p_point) const; - void set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture> &p_custom_left = Ref<Texture>(), const Ref<Texture> &p_custom_right = Ref<Texture>()); + void set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture2D> &p_custom_left = Ref<Texture2D>(), const Ref<Texture2D> &p_custom_right = Ref<Texture2D>()); void clear_slot(int p_idx); void clear_all_slots(); bool is_slot_enabled_left(int p_idx) const; diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 526950dbb3..cf798f36e4 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -32,7 +32,7 @@ #include "core/os/os.h" #include "core/project_settings.h" -void ItemList::add_item(const String &p_item, const Ref<Texture> &p_texture, bool p_selectable) { +void ItemList::add_item(const String &p_item, const Ref<Texture2D> &p_texture, bool p_selectable) { Item item; item.icon = p_texture; @@ -51,7 +51,7 @@ void ItemList::add_item(const String &p_item, const Ref<Texture> &p_texture, boo shape_changed = true; } -void ItemList::add_icon_item(const Ref<Texture> &p_item, bool p_selectable) { +void ItemList::add_icon_item(const Ref<Texture2D> &p_item, bool p_selectable) { Item item; item.icon = p_item; @@ -110,7 +110,7 @@ String ItemList::get_item_tooltip(int p_idx) const { return items[p_idx].tooltip; } -void ItemList::set_item_icon(int p_idx, const Ref<Texture> &p_icon) { +void ItemList::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) { ERR_FAIL_INDEX(p_idx, items.size()); @@ -119,9 +119,9 @@ void ItemList::set_item_icon(int p_idx, const Ref<Texture> &p_icon) { shape_changed = true; } -Ref<Texture> ItemList::get_item_icon(int p_idx) const { +Ref<Texture2D> ItemList::get_item_icon(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture2D>()); return items[p_idx].icon; } @@ -201,7 +201,7 @@ Color ItemList::get_item_custom_fg_color(int p_idx) const { return items[p_idx].custom_fg; } -void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon) { +void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture2D> &p_tag_icon) { ERR_FAIL_INDEX(p_idx, items.size()); @@ -209,9 +209,9 @@ void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon) { update(); shape_changed = true; } -Ref<Texture> ItemList::get_item_tag_icon(int p_idx) const { +Ref<Texture2D> ItemList::get_item_tag_icon(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture2D>()); return items[p_idx].tag_icon; } @@ -1398,7 +1398,7 @@ void ItemList::_set_items(const Array &p_items) { for (int i = 0; i < p_items.size(); i += 3) { String text = p_items[i + 0]; - Ref<Texture> icon = p_items[i + 1]; + Ref<Texture2D> icon = p_items[i + 1]; bool disabled = p_items[i + 2]; int idx = get_item_count(); diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index d9b510c762..da9851dd7d 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -52,11 +52,11 @@ public: private: struct Item { - Ref<Texture> icon; + Ref<Texture2D> icon; bool icon_transposed; Rect2i icon_region; Color icon_modulate; - Ref<Texture> tag_icon; + Ref<Texture2D> tag_icon; String text; bool selectable; bool selected; @@ -125,14 +125,14 @@ protected: static void _bind_methods(); public: - void add_item(const String &p_item, const Ref<Texture> &p_texture = Ref<Texture>(), bool p_selectable = true); - void add_icon_item(const Ref<Texture> &p_item, bool p_selectable = true); + void add_item(const String &p_item, const Ref<Texture2D> &p_texture = Ref<Texture2D>(), bool p_selectable = true); + void add_icon_item(const Ref<Texture2D> &p_item, bool p_selectable = true); void set_item_text(int p_idx, const String &p_text); String get_item_text(int p_idx) const; - void set_item_icon(int p_idx, const Ref<Texture> &p_icon); - Ref<Texture> get_item_icon(int p_idx) const; + void set_item_icon(int p_idx, const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_item_icon(int p_idx) const; void set_item_icon_transposed(int p_idx, const bool transposed); bool is_item_icon_transposed(int p_idx) const; @@ -152,8 +152,8 @@ public: void set_item_metadata(int p_idx, const Variant &p_metadata); Variant get_item_metadata(int p_idx) const; - void set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon); - Ref<Texture> get_item_tag_icon(int p_idx) const; + void set_item_tag_icon(int p_idx, const Ref<Texture2D> &p_tag_icon); + Ref<Texture2D> get_item_tag_icon(int p_idx) const; void set_item_tooltip_enabled(int p_idx, const bool p_enabled); bool is_item_tooltip_enabled(int p_idx) const; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 2504989d2c..3f4fd37c08 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -634,7 +634,7 @@ bool LineEdit::_is_over_clear_button(const Point2 &p_pos) const { if (!clear_button_enabled || !has_point(p_pos)) { return false; } - Ref<Texture> icon = Control::get_icon("clear"); + Ref<Texture2D> icon = Control::get_icon("clear"); int x_ofs = get_stylebox("normal")->get_offset().x; return p_pos.x > get_size().width - icon->get_width() - x_ofs; } @@ -748,7 +748,7 @@ void LineEdit::_notification(int p_what) { bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { - Ref<Texture> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon; + Ref<Texture2D> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon; Color color_icon(1, 1, 1, !is_editable() ? .5 * .9 : .9); if (display_clear_icon) { if (clear_button_status.press_attempt && clear_button_status.pressing_inside) { @@ -1309,7 +1309,7 @@ void LineEdit::set_cursor_position(int p_pos) { int window_width = get_size().width - style->get_minimum_size().width; bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { - Ref<Texture> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon; + Ref<Texture2D> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon; window_width -= r_icon->get_width(); } @@ -1650,7 +1650,7 @@ bool LineEdit::is_selecting_enabled() const { return selecting_enabled; } -void LineEdit::set_right_icon(const Ref<Texture> &p_icon) { +void LineEdit::set_right_icon(const Ref<Texture2D> &p_icon) { if (right_icon == p_icon) { return; } @@ -1659,7 +1659,7 @@ void LineEdit::set_right_icon(const Ref<Texture> &p_icon) { update(); } -Ref<Texture> LineEdit::get_right_icon() { +Ref<Texture2D> LineEdit::get_right_icon() { return right_icon; } diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 037238d682..938974453a 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -91,7 +91,7 @@ private: bool shortcut_keys_enabled; - Ref<Texture> right_icon; + Ref<Texture2D> right_icon; struct Selection { @@ -232,8 +232,8 @@ public: void set_selecting_enabled(bool p_enabled); bool is_selecting_enabled() const; - void set_right_icon(const Ref<Texture> &p_icon); - Ref<Texture> get_right_icon(); + void set_right_icon(const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_right_icon(); virtual bool is_text_field() const; LineEdit(); diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp index 945d1850d7..0ef1f53006 100644 --- a/scene/gui/nine_patch_rect.cpp +++ b/scene/gui/nine_patch_rect.cpp @@ -70,7 +70,7 @@ void NinePatchRect::_bind_methods() { ADD_SIGNAL(MethodInfo("texture_changed")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_center"), "set_draw_center", "is_draw_center_enabled"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect"); @@ -88,7 +88,7 @@ void NinePatchRect::_bind_methods() { BIND_ENUM_CONSTANT(AXIS_STRETCH_MODE_TILE_FIT); } -void NinePatchRect::set_texture(const Ref<Texture> &p_tex) { +void NinePatchRect::set_texture(const Ref<Texture2D> &p_tex) { if (texture == p_tex) return; @@ -103,7 +103,7 @@ void NinePatchRect::set_texture(const Ref<Texture> &p_tex) { _change_notify("texture"); } -Ref<Texture> NinePatchRect::get_texture() const { +Ref<Texture2D> NinePatchRect::get_texture() const { return texture; } diff --git a/scene/gui/nine_patch_rect.h b/scene/gui/nine_patch_rect.h index 3329c0a64c..0ef7f6b299 100644 --- a/scene/gui/nine_patch_rect.h +++ b/scene/gui/nine_patch_rect.h @@ -47,7 +47,7 @@ public: bool draw_center; int margin[4]; Rect2 region_rect; - Ref<Texture> texture; + Ref<Texture2D> texture; AxisStretchMode axis_h, axis_v; @@ -57,8 +57,8 @@ protected: static void _bind_methods(); public: - void set_texture(const Ref<Texture> &p_tex); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_tex); + Ref<Texture2D> get_texture() const; void set_patch_margin(Margin p_margin, int p_size); int get_patch_margin(Margin p_margin) const; diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 3f46afa8e8..6f656025e6 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -58,7 +58,7 @@ void OptionButton::_notification(int p_what) { return; RID ci = get_canvas_item(); - Ref<Texture> arrow = Control::get_icon("arrow"); + Ref<Texture2D> arrow = Control::get_icon("arrow"); Color clr = Color(1, 1, 1); if (get_constant("modulate_arrow")) { switch (get_draw_mode()) { @@ -114,7 +114,7 @@ void OptionButton::pressed() { popup->popup(); } -void OptionButton::add_icon_item(const Ref<Texture> &p_icon, const String &p_label, int p_id) { +void OptionButton::add_icon_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id) { popup->add_icon_radio_check_item(p_icon, p_label, p_id); if (popup->get_item_count() == 1) @@ -134,7 +134,7 @@ void OptionButton::set_item_text(int p_idx, const String &p_text) { if (current == p_idx) set_text(p_text); } -void OptionButton::set_item_icon(int p_idx, const Ref<Texture> &p_icon) { +void OptionButton::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) { popup->set_item_icon(p_idx, p_icon); @@ -161,7 +161,7 @@ String OptionButton::get_item_text(int p_idx) const { return popup->get_item_text(p_idx); } -Ref<Texture> OptionButton::get_item_icon(int p_idx) const { +Ref<Texture2D> OptionButton::get_item_icon(int p_idx) const { return popup->get_item_icon(p_idx); } @@ -289,7 +289,7 @@ void OptionButton::_set_items(const Array &p_items) { for (int i = 0; i < p_items.size(); i += 5) { String text = p_items[i + 0]; - Ref<Texture> icon = p_items[i + 1]; + Ref<Texture2D> icon = p_items[i + 1]; bool disabled = p_items[i + 2]; int id = p_items[i + 3]; Variant meta = p_items[i + 4]; diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h index 04bd28fe28..9658e1fea8 100644 --- a/scene/gui/option_button.h +++ b/scene/gui/option_button.h @@ -57,17 +57,17 @@ protected: static void _bind_methods(); public: - void add_icon_item(const Ref<Texture> &p_icon, const String &p_label, int p_id = -1); + void add_icon_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id = -1); void add_item(const String &p_label, int p_id = -1); void set_item_text(int p_idx, const String &p_text); - void set_item_icon(int p_idx, const Ref<Texture> &p_icon); + void set_item_icon(int p_idx, const Ref<Texture2D> &p_icon); void set_item_id(int p_idx, int p_id); void set_item_metadata(int p_idx, const Variant &p_metadata); void set_item_disabled(int p_idx, bool p_disabled); String get_item_text(int p_idx) const; - Ref<Texture> get_item_icon(int p_idx) const; + Ref<Texture2D> get_item_icon(int p_idx) const; int get_item_id(int p_idx) const; int get_item_index(int p_id) const; Variant get_item_metadata(int p_idx) const; diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 87f17838cf..b494506c6c 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -467,9 +467,9 @@ void PopupMenu::_notification(int p_what) { Ref<StyleBox> hover = get_stylebox("hover"); Ref<Font> font = get_font("font"); // In Item::checkable_type enum order (less the non-checkable member) - Ref<Texture> check[] = { get_icon("checked"), get_icon("radio_checked") }; - Ref<Texture> uncheck[] = { get_icon("unchecked"), get_icon("radio_unchecked") }; - Ref<Texture> submenu = get_icon("submenu"); + Ref<Texture2D> check[] = { get_icon("checked"), get_icon("radio_checked") }; + Ref<Texture2D> uncheck[] = { get_icon("unchecked"), get_icon("radio_unchecked") }; + Ref<Texture2D> submenu = get_icon("submenu"); Ref<StyleBox> separator = get_stylebox("separator"); Ref<StyleBox> labeled_separator_left = get_stylebox("labeled_separator_left"); Ref<StyleBox> labeled_separator_right = get_stylebox("labeled_separator_right"); @@ -549,7 +549,7 @@ void PopupMenu::_notification(int p_what) { Color icon_color(1, 1, 1, items[i].disabled ? 0.5 : 1); if (items[i].checkable_type) { - Texture *icon = (items[i].checked ? check[items[i].checkable_type - 1] : uncheck[items[i].checkable_type - 1]).ptr(); + Texture2D *icon = (items[i].checked ? check[items[i].checkable_type - 1] : uncheck[items[i].checkable_type - 1]).ptr(); icon->draw(ci, item_ofs + Point2(0, Math::floor((h - icon->get_height()) / 2.0)), icon_color); } @@ -651,7 +651,7 @@ void PopupMenu::add_item(const String &p_label, int p_id, uint32_t p_accel) { minimum_size_changed(); } -void PopupMenu::add_icon_item(const Ref<Texture> &p_icon, const String &p_label, int p_id, uint32_t p_accel) { +void PopupMenu::add_icon_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id, uint32_t p_accel) { Item item; ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel); @@ -671,7 +671,7 @@ void PopupMenu::add_check_item(const String &p_label, int p_id, uint32_t p_accel minimum_size_changed(); } -void PopupMenu::add_icon_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_id, uint32_t p_accel) { +void PopupMenu::add_icon_check_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id, uint32_t p_accel) { Item item; ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel); @@ -692,7 +692,7 @@ void PopupMenu::add_radio_check_item(const String &p_label, int p_id, uint32_t p minimum_size_changed(); } -void PopupMenu::add_icon_radio_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_id, uint32_t p_accel) { +void PopupMenu::add_icon_radio_check_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id, uint32_t p_accel) { Item item; ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel); @@ -732,7 +732,7 @@ void PopupMenu::add_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_g minimum_size_changed(); } -void PopupMenu::add_icon_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) { +void PopupMenu::add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) { Item item; ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global); @@ -752,7 +752,7 @@ void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bo minimum_size_changed(); } -void PopupMenu::add_icon_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) { +void PopupMenu::add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) { Item item; ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global); @@ -773,7 +773,7 @@ void PopupMenu::add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_ minimum_size_changed(); } -void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) { +void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) { Item item; ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global); @@ -810,7 +810,7 @@ void PopupMenu::set_item_text(int p_idx, const String &p_text) { update(); minimum_size_changed(); } -void PopupMenu::set_item_icon(int p_idx, const Ref<Texture> &p_icon) { +void PopupMenu::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) { ERR_FAIL_INDEX(p_idx, items.size()); items.write[p_idx].icon = p_icon; @@ -893,9 +893,9 @@ int PopupMenu::get_item_idx_from_text(const String &text) const { return -1; } -Ref<Texture> PopupMenu::get_item_icon(int p_idx) const { +Ref<Texture2D> PopupMenu::get_item_icon(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture2D>()); return items[p_idx].icon; } @@ -1257,7 +1257,7 @@ void PopupMenu::_set_items(const Array &p_items) { for (int i = 0; i < p_items.size(); i += 10) { String text = p_items[i + 0]; - Ref<Texture> icon = p_items[i + 1]; + Ref<Texture2D> icon = p_items[i + 1]; // For compatibility, use false/true for no/checkbox and integers for other values bool checkable = p_items[i + 2]; bool radio_checkable = (int)p_items[i + 2] == Item::CHECKABLE_TYPE_RADIO_BUTTON; diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index f77ede0a8b..a3a858cfde 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -38,7 +38,7 @@ class PopupMenu : public Popup { GDCLASS(PopupMenu, Popup); struct Item { - Ref<Texture> icon; + Ref<Texture2D> icon; String text; String xl_text; bool checked; @@ -121,25 +121,25 @@ protected: public: void add_item(const String &p_label, int p_id = -1, uint32_t p_accel = 0); - void add_icon_item(const Ref<Texture> &p_icon, const String &p_label, int p_id = -1, uint32_t p_accel = 0); + void add_icon_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id = -1, uint32_t p_accel = 0); void add_check_item(const String &p_label, int p_id = -1, uint32_t p_accel = 0); - void add_icon_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_id = -1, uint32_t p_accel = 0); + void add_icon_check_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id = -1, uint32_t p_accel = 0); void add_radio_check_item(const String &p_label, int p_id = -1, uint32_t p_accel = 0); - void add_icon_radio_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_id = -1, uint32_t p_accel = 0); + void add_icon_radio_check_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id = -1, uint32_t p_accel = 0); void add_multistate_item(const String &p_label, int p_max_states, int p_default_state = 0, int p_id = -1, uint32_t p_accel = 0); void add_shortcut(const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); - void add_icon_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); + void add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); void add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); - void add_icon_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); + void add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); void add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); - void add_icon_radio_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); + void add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); void add_submenu_item(const String &p_label, const String &p_submenu, int p_id = -1); void set_item_text(int p_idx, const String &p_text); - void set_item_icon(int p_idx, const Ref<Texture> &p_icon); + void set_item_icon(int p_idx, const Ref<Texture2D> &p_icon); void set_item_checked(int p_idx, bool p_checked); void set_item_id(int p_idx, int p_id); void set_item_accelerator(int p_idx, uint32_t p_accel); @@ -160,7 +160,7 @@ public: String get_item_text(int p_idx) const; int get_item_idx_from_text(const String &text) const; - Ref<Texture> get_item_icon(int p_idx) const; + Ref<Texture2D> get_item_icon(int p_idx) const; bool is_item_checked(int p_idx) const; int get_item_id(int p_idx) const; int get_item_index(int p_id) const; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index b19e1d8362..0c686296b3 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1657,7 +1657,7 @@ void RichTextLabel::_remove_item(Item *p_item, const int p_line, const int p_sub } } -void RichTextLabel::add_image(const Ref<Texture> &p_image, const int p_width, const int p_height) { +void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width, const int p_height) { if (current->type == ITEM_TABLE) return; @@ -2213,7 +2213,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { String image = p_bbcode.substr(brk_end + 1, end - brk_end - 1); - Ref<Texture> texture = ResourceLoader::load(image, "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(image, "Texture2D"); if (texture.is_valid()) add_image(texture); @@ -2239,7 +2239,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { String image = p_bbcode.substr(brk_end + 1, end - brk_end - 1); - Ref<Texture> texture = ResourceLoader::load(image, "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(image, "Texture"); if (texture.is_valid()) add_image(texture, width, height); diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 61ac0bd86c..409aec0ca6 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -147,7 +147,7 @@ private: }; struct ItemImage : public Item { - Ref<Texture> image; + Ref<Texture2D> image; Size2 size; ItemImage() { type = ITEM_IMAGE; } }; @@ -407,7 +407,7 @@ protected: public: String get_text(); void add_text(const String &p_text); - void add_image(const Ref<Texture> &p_image, const int p_width = 0, const int p_height = 0); + void add_image(const Ref<Texture2D> &p_image, const int p_width = 0, const int p_height = 0); void add_newline(); bool remove_line(const int p_line); void push_font(const Ref<Font> &p_font); diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 45fa212886..8e6d0843a7 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -71,8 +71,8 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { if (b->is_pressed()) { double ofs = orientation == VERTICAL ? b->get_position().y : b->get_position().x; - Ref<Texture> decr = get_icon("decrement"); - Ref<Texture> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width(); double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width(); @@ -148,7 +148,7 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { if (drag.active) { double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x; - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> decr = get_icon("decrement"); double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width(); ofs -= decr_size; @@ -159,8 +159,8 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { } else { double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x; - Ref<Texture> decr = get_icon("decrement"); - Ref<Texture> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width(); double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width(); @@ -233,8 +233,8 @@ void ScrollBar::_notification(int p_what) { RID ci = get_canvas_item(); - Ref<Texture> decr = highlight == HIGHLIGHT_DECR ? get_icon("decrement_highlight") : get_icon("decrement"); - Ref<Texture> incr = highlight == HIGHLIGHT_INCR ? get_icon("increment_highlight") : get_icon("increment"); + Ref<Texture2D> decr = highlight == HIGHLIGHT_DECR ? get_icon("decrement_highlight") : get_icon("decrement"); + Ref<Texture2D> incr = highlight == HIGHLIGHT_INCR ? get_icon("increment_highlight") : get_icon("increment"); Ref<StyleBox> bg = has_focus() ? get_stylebox("scroll_focus") : get_stylebox("scroll"); Ref<StyleBox> grabber; @@ -500,8 +500,8 @@ double ScrollBar::get_grabber_offset() const { Size2 ScrollBar::get_minimum_size() const { - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); Ref<StyleBox> bg = get_stylebox("scroll"); Size2 minsize; diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index 9b3ed35e6e..85887ef7b1 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -36,7 +36,7 @@ Size2 Slider::get_minimum_size() const { Ref<StyleBox> style = get_stylebox("slider"); Size2i ss = style->get_minimum_size() + style->get_center_size(); - Ref<Texture> grabber = get_icon("grabber"); + Ref<Texture2D> grabber = get_icon("grabber"); Size2i rs = grabber->get_size(); if (orientation == HORIZONTAL) @@ -57,7 +57,7 @@ void Slider::_gui_input(Ref<InputEvent> p_event) { if (mb->get_button_index() == BUTTON_LEFT) { if (mb->is_pressed()) { - Ref<Texture> grabber = get_icon(mouse_inside || has_focus() ? "grabber_highlight" : "grabber"); + Ref<Texture2D> grabber = get_icon(mouse_inside || has_focus() ? "grabber_highlight" : "grabber"); grab.pos = orientation == VERTICAL ? mb->get_position().y : mb->get_position().x; double grab_width = (double)grabber->get_size().width; @@ -87,7 +87,7 @@ void Slider::_gui_input(Ref<InputEvent> p_event) { if (grab.active) { Size2i size = get_size(); - Ref<Texture> grabber = get_icon("grabber"); + Ref<Texture2D> grabber = get_icon("grabber"); float motion = (orientation == VERTICAL ? mm->get_position().y : mm->get_position().x) - grab.pos; if (orientation == VERTICAL) motion = -motion; @@ -167,8 +167,8 @@ void Slider::_notification(int p_what) { Size2i size = get_size(); Ref<StyleBox> style = get_stylebox("slider"); Ref<StyleBox> grabber_area = get_stylebox("grabber_area"); - Ref<Texture> grabber = get_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled"); - Ref<Texture> tick = get_icon("tick"); + Ref<Texture2D> grabber = get_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled"); + Ref<Texture2D> tick = get_icon("tick"); double ratio = Math::is_nan(get_as_ratio()) ? 0 : get_as_ratio(); if (orientation == VERTICAL) { diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 92377949f8..c49d7f3d12 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -182,7 +182,7 @@ void SpinBox::_line_edit_focus_exit() { _text_entered(line_edit->get_text()); } -inline void SpinBox::_adjust_width_for_icon(const Ref<Texture> &icon) { +inline void SpinBox::_adjust_width_for_icon(const Ref<Texture2D> &icon) { int w = icon->get_width(); if (w != last_w) { @@ -195,7 +195,7 @@ void SpinBox::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Texture> updown = get_icon("updown"); + Ref<Texture2D> updown = get_icon("updown"); _adjust_width_for_icon(updown); diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h index 04491c8477..d3a3d8fe3d 100644 --- a/scene/gui/spin_box.h +++ b/scene/gui/spin_box.h @@ -62,7 +62,7 @@ class SpinBox : public Range { void _line_edit_focus_exit(); - inline void _adjust_width_for_icon(const Ref<Texture> &icon); + inline void _adjust_width_for_icon(const Ref<Texture2D> &icon); protected: void _gui_input(const Ref<InputEvent> &p_event); diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 079907db07..255278be2b 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -74,7 +74,7 @@ void SplitContainer::_resort() { bool second_expanded = (vertical ? second->get_v_size_flags() : second->get_h_size_flags()) & SIZE_EXPAND; // Determine the separation between items - Ref<Texture> g = get_icon("grabber"); + Ref<Texture2D> g = get_icon("grabber"); int sep = get_constant("separation"); sep = (dragger_visibility != DRAGGER_HIDDEN_COLLAPSED) ? MAX(sep, vertical ? g->get_height() : g->get_width()) : 0; @@ -123,7 +123,7 @@ Size2 SplitContainer::get_minimum_size() const { /* Calculate MINIMUM SIZE */ Size2i minimum; - Ref<Texture> g = get_icon("grabber"); + Ref<Texture2D> g = get_icon("grabber"); int sep = get_constant("separation"); sep = (dragger_visibility != DRAGGER_HIDDEN_COLLAPSED) ? MAX(sep, vertical ? g->get_height() : g->get_width()) : 0; @@ -182,7 +182,7 @@ void SplitContainer::_notification(int p_what) { return; int sep = dragger_visibility != DRAGGER_HIDDEN_COLLAPSED ? get_constant("separation") : 0; - Ref<Texture> tex = get_icon("grabber"); + Ref<Texture2D> tex = get_icon("grabber"); Size2 size = get_size(); if (vertical) diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index b045ff4fe1..402623e53d 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -58,7 +58,7 @@ int TabContainer::_get_top_margin() const { if (!c->has_meta("_tab_icon")) continue; - Ref<Texture> tex = c->get_meta("_tab_icon"); + Ref<Texture2D> tex = c->get_meta("_tab_icon"); if (!tex.is_valid()) continue; content_height = MAX(content_height, tex->get_size().height); @@ -81,7 +81,7 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { return; // Handle menu button. - Ref<Texture> menu = get_icon("menu"); + Ref<Texture2D> menu = get_icon("menu"); if (popup && pos.x > size.width - menu->get_width()) { emit_signal("pre_popup_pressed"); @@ -107,8 +107,8 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { popup_ofs = menu->get_width(); } - Ref<Texture> increment = get_icon("increment"); - Ref<Texture> decrement = get_icon("decrement"); + Ref<Texture2D> increment = get_icon("increment"); + Ref<Texture2D> decrement = get_icon("decrement"); if (pos.x > size.width - increment->get_width() - popup_ofs) { if (last_tab_cache < tabs.size() - 1) { first_tab_cache += 1; @@ -159,7 +159,7 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { return; } - Ref<Texture> menu = get_icon("menu"); + Ref<Texture2D> menu = get_icon("menu"); if (popup) { if (pos.x >= size.width - menu->get_width()) { @@ -191,8 +191,8 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { popup_ofs = menu->get_width(); } - Ref<Texture> increment = get_icon("increment"); - Ref<Texture> decrement = get_icon("decrement"); + Ref<Texture2D> increment = get_icon("increment"); + Ref<Texture2D> decrement = get_icon("decrement"); if (pos.x >= size.width - increment->get_width() - popup_ofs) { if (highlight_arrow != 1) { @@ -225,9 +225,9 @@ void TabContainer::_notification(int p_what) { Vector<Control *> tabs = _get_tabs(); int side_margin = get_constant("side_margin"); - Ref<Texture> menu = get_icon("menu"); - Ref<Texture> increment = get_icon("increment"); - Ref<Texture> decrement = get_icon("decrement"); + Ref<Texture2D> menu = get_icon("menu"); + Ref<Texture2D> increment = get_icon("increment"); + Ref<Texture2D> decrement = get_icon("decrement"); int header_width = get_size().width - side_margin * 2; // Find the width of the header area. @@ -272,12 +272,12 @@ void TabContainer::_notification(int p_what) { Ref<StyleBox> tab_bg = get_stylebox("tab_bg"); Ref<StyleBox> tab_fg = get_stylebox("tab_fg"); Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled"); - Ref<Texture> increment = get_icon("increment"); - Ref<Texture> increment_hl = get_icon("increment_highlight"); - Ref<Texture> decrement = get_icon("decrement"); - Ref<Texture> decrement_hl = get_icon("decrement_highlight"); - Ref<Texture> menu = get_icon("menu"); - Ref<Texture> menu_hl = get_icon("menu_highlight"); + Ref<Texture2D> increment = get_icon("increment"); + Ref<Texture2D> increment_hl = get_icon("increment_highlight"); + Ref<Texture2D> decrement = get_icon("decrement"); + Ref<Texture2D> decrement_hl = get_icon("decrement_highlight"); + Ref<Texture2D> menu = get_icon("menu"); + Ref<Texture2D> menu_hl = get_icon("menu_highlight"); Ref<Font> font = get_font("font"); Color font_color_fg = get_color("font_color_fg"); Color font_color_bg = get_color("font_color_bg"); @@ -383,7 +383,7 @@ void TabContainer::_notification(int p_what) { // Draw the tab icon. if (control->has_meta("_tab_icon")) { - Ref<Texture> icon = control->get_meta("_tab_icon"); + Ref<Texture2D> icon = control->get_meta("_tab_icon"); if (icon.is_valid()) { int y = y_center - (icon->get_height() / 2); icon->draw(canvas, Point2i(x_content, y)); @@ -464,7 +464,7 @@ int TabContainer::_get_tab_width(int p_index) const { // Add space for a tab icon. if (control->has_meta("_tab_icon")) { - Ref<Texture> icon = control->get_meta("_tab_icon"); + Ref<Texture2D> icon = control->get_meta("_tab_icon"); if (icon.is_valid()) { width += icon->get_width(); if (text != "") @@ -648,7 +648,7 @@ Variant TabContainer::get_drag_data(const Point2 &p_point) { HBoxContainer *drag_preview = memnew(HBoxContainer); - Ref<Texture> icon = get_tab_icon(tab_over); + Ref<Texture2D> icon = get_tab_icon(tab_over); if (!icon.is_null()) { TextureRect *tf = memnew(TextureRect); tf->set_texture(icon); @@ -745,12 +745,12 @@ int TabContainer::get_tab_idx_at_point(const Point2 &p_point) const { int right_ofs = 0; if (popup) { - Ref<Texture> menu = get_icon("menu"); + Ref<Texture2D> menu = get_icon("menu"); right_ofs += menu->get_width(); } if (buttons_visible_cache) { - Ref<Texture> increment = get_icon("increment"); - Ref<Texture> decrement = get_icon("decrement"); + Ref<Texture2D> increment = get_icon("increment"); + Ref<Texture2D> decrement = get_icon("decrement"); right_ofs += increment->get_width() + decrement->get_width(); } if (p_point.x > size.width - right_ofs) { @@ -834,21 +834,21 @@ String TabContainer::get_tab_title(int p_tab) const { return child->get_name(); } -void TabContainer::set_tab_icon(int p_tab, const Ref<Texture> &p_icon) { +void TabContainer::set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon) { Control *child = _get_tab(p_tab); ERR_FAIL_COND(!child); child->set_meta("_tab_icon", p_icon); update(); } -Ref<Texture> TabContainer::get_tab_icon(int p_tab) const { +Ref<Texture2D> TabContainer::get_tab_icon(int p_tab) const { Control *child = _get_tab(p_tab); - ERR_FAIL_COND_V(!child, Ref<Texture>()); + ERR_FAIL_COND_V(!child, Ref<Texture2D>()); if (child->has_meta("_tab_icon")) return child->get_meta("_tab_icon"); else - return Ref<Texture>(); + return Ref<Texture2D>(); } void TabContainer::set_tab_disabled(int p_tab, bool p_disabled) { diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h index c5a9045ca6..38c029475c 100644 --- a/scene/gui/tab_container.h +++ b/scene/gui/tab_container.h @@ -93,8 +93,8 @@ public: void set_tab_title(int p_tab, const String &p_title); String get_tab_title(int p_tab) const; - void set_tab_icon(int p_tab, const Ref<Texture> &p_icon); - Ref<Texture> get_tab_icon(int p_tab) const; + void set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_tab_icon(int p_tab) const; void set_tab_disabled(int p_tab, bool p_disabled); bool get_tab_disabled(int p_tab) const; diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 6cd95e73fc..4aa7ea8cb1 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -46,7 +46,7 @@ Size2 Tabs::get_minimum_size() const { for (int i = 0; i < tabs.size(); i++) { - Ref<Texture> tex = tabs[i].icon; + Ref<Texture2D> tex = tabs[i].icon; if (tex.is_valid()) { ms.height = MAX(ms.height, tex->get_size().height); if (tabs[i].text != "") @@ -63,7 +63,7 @@ Size2 Tabs::get_minimum_size() const { ms.width += tab_bg->get_minimum_size().width; if (tabs[i].right_button.is_valid()) { - Ref<Texture> rb = tabs[i].right_button; + Ref<Texture2D> rb = tabs[i].right_button; Size2 bms = rb->get_size(); bms.width += get_constant("hseparation"); ms.width += bms.width; @@ -71,7 +71,7 @@ Size2 Tabs::get_minimum_size() const { } if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) { - Ref<Texture> cb = get_icon("close"); + Ref<Texture2D> cb = get_icon("close"); Size2 bms = cb->get_size(); bms.width += get_constant("hseparation"); ms.width += bms.width; @@ -94,8 +94,8 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { highlight_arrow = -1; if (buttons_visible) { - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); int limit = get_size().width - incr->get_width() - decr->get_width(); @@ -163,8 +163,8 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { if (buttons_visible) { - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); int limit = get_size().width - incr->get_width() - decr->get_width(); @@ -245,7 +245,7 @@ void Tabs::_notification(int p_what) { Color color_fg = get_color("font_color_fg"); Color color_bg = get_color("font_color_bg"); Color color_disabled = get_color("font_color_disabled"); - Ref<Texture> close = get_icon("close"); + Ref<Texture2D> close = get_icon("close"); int h = get_size().height; int w = 0; @@ -267,10 +267,10 @@ void Tabs::_notification(int p_what) { w = 0; } - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); - Ref<Texture> incr_hl = get_icon("increment_highlight"); - Ref<Texture> decr_hl = get_icon("decrement_highlight"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); + Ref<Texture2D> incr_hl = get_icon("increment_highlight"); + Ref<Texture2D> decr_hl = get_icon("decrement_highlight"); int limit = get_size().width - incr->get_size().width - decr->get_size().width; @@ -313,7 +313,7 @@ void Tabs::_notification(int p_what) { w += sb->get_margin(MARGIN_LEFT); Size2i sb_ms = sb->get_minimum_size(); - Ref<Texture> icon = tabs[i].icon; + Ref<Texture2D> icon = tabs[i].icon; if (icon.is_valid()) { icon->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - icon->get_height()) / 2)); @@ -328,7 +328,7 @@ void Tabs::_notification(int p_what) { if (tabs[i].right_button.is_valid()) { Ref<StyleBox> style = get_stylebox("button"); - Ref<Texture> rb = tabs[i].right_button; + Ref<Texture2D> rb = tabs[i].right_button; w += get_constant("hseparation"); @@ -352,7 +352,7 @@ void Tabs::_notification(int p_what) { if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) { Ref<StyleBox> style = get_stylebox("button"); - Ref<Texture> cb = close; + Ref<Texture2D> cb = close; w += get_constant("hseparation"); @@ -449,7 +449,7 @@ String Tabs::get_tab_title(int p_tab) const { return tabs[p_tab].text; } -void Tabs::set_tab_icon(int p_tab, const Ref<Texture> &p_icon) { +void Tabs::set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon) { ERR_FAIL_INDEX(p_tab, tabs.size()); tabs.write[p_tab].icon = p_icon; @@ -457,9 +457,9 @@ void Tabs::set_tab_icon(int p_tab, const Ref<Texture> &p_icon) { minimum_size_changed(); } -Ref<Texture> Tabs::get_tab_icon(int p_tab) const { +Ref<Texture2D> Tabs::get_tab_icon(int p_tab) const { - ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture2D>()); return tabs[p_tab].icon; } @@ -475,7 +475,7 @@ bool Tabs::get_tab_disabled(int p_tab) const { return tabs[p_tab].disabled; } -void Tabs::set_tab_right_button(int p_tab, const Ref<Texture> &p_right_button) { +void Tabs::set_tab_right_button(int p_tab, const Ref<Texture2D> &p_right_button) { ERR_FAIL_INDEX(p_tab, tabs.size()); tabs.write[p_tab].right_button = p_right_button; @@ -483,9 +483,9 @@ void Tabs::set_tab_right_button(int p_tab, const Ref<Texture> &p_right_button) { update(); minimum_size_changed(); } -Ref<Texture> Tabs::get_tab_right_button(int p_tab) const { +Ref<Texture2D> Tabs::get_tab_right_button(int p_tab) const { - ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture2D>()); return tabs[p_tab].right_button; } @@ -536,8 +536,8 @@ void Tabs::_update_cache() { Ref<StyleBox> tab_bg = get_stylebox("tab_bg"); Ref<StyleBox> tab_fg = get_stylebox("tab_fg"); Ref<Font> font = get_font("font"); - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); int limit = get_size().width - incr->get_width() - decr->get_width(); int w = 0; @@ -580,7 +580,7 @@ void Tabs::_update_cache() { slen -= get_constant("hseparation"); } if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) { - Ref<Texture> cb = get_icon("close"); + Ref<Texture2D> cb = get_icon("close"); slen -= cb->get_width(); slen -= get_constant("hseparation"); } @@ -604,7 +604,7 @@ void Tabs::_on_mouse_exited() { update(); } -void Tabs::add_tab(const String &p_str, const Ref<Texture> &p_icon) { +void Tabs::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) { Tab t; t.text = p_str; @@ -806,7 +806,7 @@ int Tabs::get_tab_width(int p_idx) const { int x = 0; - Ref<Texture> tex = tabs[p_idx].icon; + Ref<Texture2D> tex = tabs[p_idx].icon; if (tex.is_valid()) { x += tex->get_width(); if (tabs[p_idx].text != "") @@ -823,13 +823,13 @@ int Tabs::get_tab_width(int p_idx) const { x += tab_bg->get_minimum_size().width; if (tabs[p_idx].right_button.is_valid()) { - Ref<Texture> rb = tabs[p_idx].right_button; + Ref<Texture2D> rb = tabs[p_idx].right_button; x += rb->get_width(); x += get_constant("hseparation"); } if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && p_idx == current)) { - Ref<Texture> cb = get_icon("close"); + Ref<Texture2D> cb = get_icon("close"); x += cb->get_width(); x += get_constant("hseparation"); } @@ -842,8 +842,8 @@ void Tabs::_ensure_no_over_offset() { if (!is_inside_tree()) return; - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); int limit = get_size().width - incr->get_width() - decr->get_width(); @@ -885,8 +885,8 @@ void Tabs::ensure_tab_visible(int p_idx) { } int prev_offset = offset; - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); int limit = get_size().width - incr->get_width() - decr->get_width(); for (int i = offset; i <= p_idx; i++) { if (tabs[i].ofs_cache + tabs[i].size_cache > limit) { @@ -967,7 +967,7 @@ void Tabs::_bind_methods() { ClassDB::bind_method(D_METHOD("set_tab_disabled", "tab_idx", "disabled"), &Tabs::set_tab_disabled); ClassDB::bind_method(D_METHOD("get_tab_disabled", "tab_idx"), &Tabs::get_tab_disabled); ClassDB::bind_method(D_METHOD("remove_tab", "tab_idx"), &Tabs::remove_tab); - ClassDB::bind_method(D_METHOD("add_tab", "title", "icon"), &Tabs::add_tab, DEFVAL(""), DEFVAL(Ref<Texture>())); + ClassDB::bind_method(D_METHOD("add_tab", "title", "icon"), &Tabs::add_tab, DEFVAL(""), DEFVAL(Ref<Texture2D>())); ClassDB::bind_method(D_METHOD("set_tab_align", "align"), &Tabs::set_tab_align); ClassDB::bind_method(D_METHOD("get_tab_align"), &Tabs::get_tab_align); ClassDB::bind_method(D_METHOD("get_tab_offset"), &Tabs::get_tab_offset); diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h index c06e47a54a..3170acb46f 100644 --- a/scene/gui/tabs.h +++ b/scene/gui/tabs.h @@ -59,7 +59,7 @@ private: String text; String xl_text; - Ref<Texture> icon; + Ref<Texture2D> icon; int ofs_cache; bool disabled; int size_cache; @@ -67,7 +67,7 @@ private: int x_cache; int x_size_cache; - Ref<Texture> right_button; + Ref<Texture2D> right_button; Rect2 rb_rect; Rect2 cb_rect; }; @@ -115,19 +115,19 @@ protected: int get_tab_idx_at_point(const Point2 &p_point) const; public: - void add_tab(const String &p_str = "", const Ref<Texture> &p_icon = Ref<Texture>()); + void add_tab(const String &p_str = "", const Ref<Texture2D> &p_icon = Ref<Texture2D>()); void set_tab_title(int p_tab, const String &p_title); String get_tab_title(int p_tab) const; - void set_tab_icon(int p_tab, const Ref<Texture> &p_icon); - Ref<Texture> get_tab_icon(int p_tab) const; + void set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_tab_icon(int p_tab) const; void set_tab_disabled(int p_tab, bool p_disabled); bool get_tab_disabled(int p_tab) const; - void set_tab_right_button(int p_tab, const Ref<Texture> &p_right_button); - Ref<Texture> get_tab_right_button(int p_tab) const; + void set_tab_right_button(int p_tab, const Ref<Texture2D> &p_right_button); + Ref<Texture2D> get_tab_right_button(int p_tab) const; void set_tab_align(TabAlign p_align); TabAlign get_tab_align() const; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 9d5e004ed3..a5c316848e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1216,7 +1216,7 @@ void TextEdit::_notification(int p_what) { int horizontal_gap = (cache.info_gutter_width * 30) / 100; int gutter_left = cache.style_normal->get_margin(MARGIN_LEFT) + cache.breakpoint_gutter_width; - Ref<Texture> info_icon = text.get_info_icon(line); + Ref<Texture2D> info_icon = text.get_info_icon(line); // Ensure the icon fits the gutter size. Size2i icon_size = info_icon->get_size(); if (icon_size.width > cache.info_gutter_width - horizontal_gap) { @@ -1645,7 +1645,7 @@ void TextEdit::_notification(int p_what) { Point2 title_pos(completion_rect.position.x, completion_rect.position.y + i * get_row_height() + cache.font->get_ascent() + yofs); // Draw completion icon if it is valid. - Ref<Texture> icon = completion_options[l].icon; + Ref<Texture2D> icon = completion_options[l].icon; Rect2 icon_area(completion_rect.position.x, completion_rect.position.y + i * get_row_height(), icon_area_size.width, icon_area_size.height); if (icon.is_valid()) { const real_t max_scale = 0.7f; @@ -5690,7 +5690,7 @@ void TextEdit::remove_breakpoints() { } } -void TextEdit::set_line_info_icon(int p_line, Ref<Texture> p_icon, String p_info) { +void TextEdit::set_line_info_icon(int p_line, Ref<Texture2D> p_icon, String p_info) { ERR_FAIL_INDEX(p_line, text.size()); text.set_info_icon(p_line, p_icon, p_info); update(); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index b4e7dcfebb..a849f62bc5 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -85,7 +85,7 @@ public: bool has_info : 1; int wrap_amount_cache : 24; Map<int, ColorRegionInfo> region_info; - Ref<Texture> info_icon; + Ref<Texture2D> info_icon; String info; String data; Line() { @@ -129,7 +129,7 @@ public: bool is_hidden(int p_line) const { return text[p_line].hidden; } void set_safe(int p_line, bool p_safe) { text.write[p_line].safe = p_safe; } bool is_safe(int p_line) const { return text[p_line].safe; } - void set_info_icon(int p_line, Ref<Texture> p_icon, String p_info) { + void set_info_icon(int p_line, Ref<Texture2D> p_icon, String p_info) { if (p_icon.is_null()) { text.write[p_line].has_info = false; return; @@ -139,7 +139,7 @@ public: text.write[p_line].has_info = true; } bool has_info_icon(int p_line) const { return text[p_line].has_info; } - const Ref<Texture> &get_info_icon(int p_line) const { return text[p_line].info_icon; } + const Ref<Texture2D> &get_info_icon(int p_line) const { return text[p_line].info_icon; } const String &get_info(int p_line) const { return text[p_line].info; } void insert(int p_at, const String &p_text); void remove(int p_at); @@ -208,12 +208,12 @@ private: struct Cache { - Ref<Texture> tab_icon; - Ref<Texture> space_icon; - Ref<Texture> can_fold_icon; - Ref<Texture> folded_icon; - Ref<Texture> folded_eol_icon; - Ref<Texture> executing_icon; + Ref<Texture2D> tab_icon; + Ref<Texture2D> space_icon; + Ref<Texture2D> can_fold_icon; + Ref<Texture2D> folded_icon; + Ref<Texture2D> folded_eol_icon; + Ref<Texture2D> executing_icon; Ref<StyleBox> style_normal; Ref<StyleBox> style_focus; Ref<StyleBox> style_readonly; @@ -603,7 +603,7 @@ public: Array get_breakpoints_array() const; void remove_breakpoints(); - void set_line_info_icon(int p_line, Ref<Texture> p_icon, String p_info = ""); + void set_line_info_icon(int p_line, Ref<Texture2D> p_icon, String p_info = ""); void clear_info_icons(); void set_line_as_hidden(int p_line, bool p_hidden); diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index 9ffb69037a..5f2e4cf58e 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -122,7 +122,7 @@ void TextureButton::_notification(int p_what) { case NOTIFICATION_DRAW: { DrawMode draw_mode = get_draw_mode(); - Ref<Texture> texdraw; + Ref<Texture2D> texdraw; switch (draw_mode) { case DRAW_NORMAL: { @@ -252,11 +252,11 @@ void TextureButton::_bind_methods() { ClassDB::bind_method(D_METHOD("get_stretch_mode"), &TextureButton::get_stretch_mode); ADD_GROUP("Textures", "texture_"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_normal_texture", "get_normal_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_pressed", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_pressed_texture", "get_pressed_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_hover", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_hover_texture", "get_hover_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_disabled", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_disabled_texture", "get_disabled_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_focused", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_focused_texture", "get_focused_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normal_texture", "get_normal_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_pressed", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_pressed_texture", "get_pressed_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_hover", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_hover_texture", "get_hover_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_disabled", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_disabled_texture", "get_disabled_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_focused", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_focused_texture", "get_focused_texture"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_click_mask", PROPERTY_HINT_RESOURCE_TYPE, "BitMap"), "set_click_mask", "get_click_mask"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand", PROPERTY_HINT_RESOURCE_TYPE, "bool"), "set_expand", "get_expand"); ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_mode", PROPERTY_HINT_ENUM, "Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), "set_stretch_mode", "get_stretch_mode"); @@ -270,24 +270,24 @@ void TextureButton::_bind_methods() { BIND_ENUM_CONSTANT(STRETCH_KEEP_ASPECT_COVERED); } -void TextureButton::set_normal_texture(const Ref<Texture> &p_normal) { +void TextureButton::set_normal_texture(const Ref<Texture2D> &p_normal) { normal = p_normal; update(); minimum_size_changed(); } -void TextureButton::set_pressed_texture(const Ref<Texture> &p_pressed) { +void TextureButton::set_pressed_texture(const Ref<Texture2D> &p_pressed) { pressed = p_pressed; update(); } -void TextureButton::set_hover_texture(const Ref<Texture> &p_hover) { +void TextureButton::set_hover_texture(const Ref<Texture2D> &p_hover) { hover = p_hover; update(); } -void TextureButton::set_disabled_texture(const Ref<Texture> &p_disabled) { +void TextureButton::set_disabled_texture(const Ref<Texture2D> &p_disabled) { disabled = p_disabled; update(); @@ -298,19 +298,19 @@ void TextureButton::set_click_mask(const Ref<BitMap> &p_click_mask) { update(); } -Ref<Texture> TextureButton::get_normal_texture() const { +Ref<Texture2D> TextureButton::get_normal_texture() const { return normal; } -Ref<Texture> TextureButton::get_pressed_texture() const { +Ref<Texture2D> TextureButton::get_pressed_texture() const { return pressed; } -Ref<Texture> TextureButton::get_hover_texture() const { +Ref<Texture2D> TextureButton::get_hover_texture() const { return hover; } -Ref<Texture> TextureButton::get_disabled_texture() const { +Ref<Texture2D> TextureButton::get_disabled_texture() const { return disabled; } @@ -319,12 +319,12 @@ Ref<BitMap> TextureButton::get_click_mask() const { return click_mask; } -Ref<Texture> TextureButton::get_focused_texture() const { +Ref<Texture2D> TextureButton::get_focused_texture() const { return focused; }; -void TextureButton::set_focused_texture(const Ref<Texture> &p_focused) { +void TextureButton::set_focused_texture(const Ref<Texture2D> &p_focused) { focused = p_focused; }; diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h index e39b94abf0..43b10a8e8b 100644 --- a/scene/gui/texture_button.h +++ b/scene/gui/texture_button.h @@ -49,11 +49,11 @@ public: }; private: - Ref<Texture> normal; - Ref<Texture> pressed; - Ref<Texture> hover; - Ref<Texture> disabled; - Ref<Texture> focused; + Ref<Texture2D> normal; + Ref<Texture2D> pressed; + Ref<Texture2D> hover; + Ref<Texture2D> disabled; + Ref<Texture2D> focused; Ref<BitMap> click_mask; bool expand; StretchMode stretch_mode; @@ -69,18 +69,18 @@ protected: static void _bind_methods(); public: - void set_normal_texture(const Ref<Texture> &p_normal); - void set_pressed_texture(const Ref<Texture> &p_pressed); - void set_hover_texture(const Ref<Texture> &p_hover); - void set_disabled_texture(const Ref<Texture> &p_disabled); - void set_focused_texture(const Ref<Texture> &p_focused); + void set_normal_texture(const Ref<Texture2D> &p_normal); + void set_pressed_texture(const Ref<Texture2D> &p_pressed); + void set_hover_texture(const Ref<Texture2D> &p_hover); + void set_disabled_texture(const Ref<Texture2D> &p_disabled); + void set_focused_texture(const Ref<Texture2D> &p_focused); void set_click_mask(const Ref<BitMap> &p_click_mask); - Ref<Texture> get_normal_texture() const; - Ref<Texture> get_pressed_texture() const; - Ref<Texture> get_hover_texture() const; - Ref<Texture> get_disabled_texture() const; - Ref<Texture> get_focused_texture() const; + Ref<Texture2D> get_normal_texture() const; + Ref<Texture2D> get_pressed_texture() const; + Ref<Texture2D> get_hover_texture() const; + Ref<Texture2D> get_disabled_texture() const; + Ref<Texture2D> get_focused_texture() const; Ref<BitMap> get_click_mask() const; bool get_expand() const; diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp index 2d30ff7334..c5650b1795 100644 --- a/scene/gui/texture_progress.cpp +++ b/scene/gui/texture_progress.cpp @@ -32,19 +32,19 @@ #include "core/engine.h" -void TextureProgress::set_under_texture(const Ref<Texture> &p_texture) { +void TextureProgress::set_under_texture(const Ref<Texture2D> &p_texture) { under = p_texture; update(); minimum_size_changed(); } -Ref<Texture> TextureProgress::get_under_texture() const { +Ref<Texture2D> TextureProgress::get_under_texture() const { return under; } -void TextureProgress::set_over_texture(const Ref<Texture> &p_texture) { +void TextureProgress::set_over_texture(const Ref<Texture2D> &p_texture) { over = p_texture; update(); @@ -53,7 +53,7 @@ void TextureProgress::set_over_texture(const Ref<Texture> &p_texture) { } } -Ref<Texture> TextureProgress::get_over_texture() const { +Ref<Texture2D> TextureProgress::get_over_texture() const { return over; } @@ -94,14 +94,14 @@ Size2 TextureProgress::get_minimum_size() const { return Size2(1, 1); } -void TextureProgress::set_progress_texture(const Ref<Texture> &p_texture) { +void TextureProgress::set_progress_texture(const Ref<Texture2D> &p_texture) { progress = p_texture; update(); minimum_size_changed(); } -Ref<Texture> TextureProgress::get_progress_texture() const { +Ref<Texture2D> TextureProgress::get_progress_texture() const { return progress; } @@ -201,7 +201,7 @@ Point2 TextureProgress::get_relative_center() { return p; } -void TextureProgress::draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate) { +void TextureProgress::draw_nine_patch_stretched(const Ref<Texture2D> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate) { Vector2 texture_size = p_texture->get_size(); Vector2 topleft = Vector2(stretch_margin[MARGIN_LEFT], stretch_margin[MARGIN_TOP]); Vector2 bottomright = Vector2(stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_BOTTOM]); @@ -501,9 +501,9 @@ void TextureProgress::_bind_methods() { ClassDB::bind_method(D_METHOD("get_nine_patch_stretch"), &TextureProgress::get_nine_patch_stretch); ADD_GROUP("Textures", "texture_"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_under", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_under_texture", "get_under_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_over", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_over_texture", "get_over_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_progress", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_progress_texture", "get_progress_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_under", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_under_texture", "get_under_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_over", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_over_texture", "get_over_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_progress", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_progress_texture", "get_progress_texture"); ADD_PROPERTY(PropertyInfo(Variant::INT, "fill_mode", PROPERTY_HINT_ENUM, "Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise,Bilinear (Left and Right),Bilinear (Top and Bottom), Clockwise and Counter Clockwise"), "set_fill_mode", "get_fill_mode"); ADD_GROUP("Tint", "tint_"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_under"), "set_tint_under", "get_tint_under"); diff --git a/scene/gui/texture_progress.h b/scene/gui/texture_progress.h index e4a40fd6a3..e05f89aa3e 100644 --- a/scene/gui/texture_progress.h +++ b/scene/gui/texture_progress.h @@ -37,9 +37,9 @@ class TextureProgress : public Range { GDCLASS(TextureProgress, Range); - Ref<Texture> under; - Ref<Texture> progress; - Ref<Texture> over; + Ref<Texture2D> under; + Ref<Texture2D> progress; + Ref<Texture2D> over; protected: static void _bind_methods(); @@ -70,14 +70,14 @@ public: void set_radial_center_offset(const Point2 &p_off); Point2 get_radial_center_offset(); - void set_under_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_under_texture() const; + void set_under_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_under_texture() const; - void set_progress_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_progress_texture() const; + void set_progress_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_progress_texture() const; - void set_over_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_over_texture() const; + void set_over_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_over_texture() const; void set_stretch_margin(Margin p_margin, int p_size); int get_stretch_margin(Margin p_margin) const; @@ -109,7 +109,7 @@ private: Point2 unit_val_to_uv(float val); Point2 get_relative_center(); - void draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate); + void draw_nine_patch_stretched(const Ref<Texture2D> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate); }; VARIANT_ENUM_CAST(TextureProgress::FillMode); diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index 514eff358e..64693e2531 100644 --- a/scene/gui/texture_rect.cpp +++ b/scene/gui/texture_rect.cpp @@ -129,7 +129,7 @@ void TextureRect::_bind_methods() { ClassDB::bind_method(D_METHOD("get_stretch_mode"), &TextureRect::get_stretch_mode); ClassDB::bind_method(D_METHOD("_texture_changed"), &TextureRect::_texture_changed); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand"), "set_expand", "has_expand"); ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_mode", PROPERTY_HINT_ENUM, "Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), "set_stretch_mode", "get_stretch_mode"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_h"), "set_flip_h", "is_flipped_h"); @@ -153,7 +153,7 @@ void TextureRect::_texture_changed() { } } -void TextureRect::set_texture(const Ref<Texture> &p_tex) { +void TextureRect::set_texture(const Ref<Texture2D> &p_tex) { if (p_tex == texture) { return; @@ -173,7 +173,7 @@ void TextureRect::set_texture(const Ref<Texture> &p_tex) { minimum_size_changed(); } -Ref<Texture> TextureRect::get_texture() const { +Ref<Texture2D> TextureRect::get_texture() const { return texture; } diff --git a/scene/gui/texture_rect.h b/scene/gui/texture_rect.h index ef970fa051..77a2828fd4 100644 --- a/scene/gui/texture_rect.h +++ b/scene/gui/texture_rect.h @@ -53,7 +53,7 @@ private: bool expand; bool hflip; bool vflip; - Ref<Texture> texture; + Ref<Texture2D> texture; StretchMode stretch_mode; void _texture_changed(); @@ -64,8 +64,8 @@ protected: static void _bind_methods(); public: - void set_texture(const Ref<Texture> &p_tex); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_tex); + Ref<Texture2D> get_texture() const; void set_expand(bool p_expand); bool has_expand() const; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 790e1d5f4f..7bfe060065 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -129,7 +129,7 @@ void TreeItem::set_cell_mode(int p_column, TreeCellMode p_mode) { c.step = 1; c.val = 0; c.checked = false; - c.icon = Ref<Texture>(); + c.icon = Ref<Texture2D>(); c.text = ""; c.icon_max_w = 0; _changed_notify(p_column); @@ -198,16 +198,16 @@ String TreeItem::get_suffix(int p_column) const { return cells[p_column].suffix; } -void TreeItem::set_icon(int p_column, const Ref<Texture> &p_icon) { +void TreeItem::set_icon(int p_column, const Ref<Texture2D> &p_icon) { ERR_FAIL_INDEX(p_column, cells.size()); cells.write[p_column].icon = p_icon; _changed_notify(p_column); } -Ref<Texture> TreeItem::get_icon(int p_column) const { +Ref<Texture2D> TreeItem::get_icon(int p_column) const { - ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture2D>()); return cells[p_column].icon; } @@ -522,7 +522,7 @@ void TreeItem::deselect(int p_column) { _cell_deselected(p_column); } -void TreeItem::add_button(int p_column, const Ref<Texture> &p_button, int p_id, bool p_disabled, const String &p_tooltip) { +void TreeItem::add_button(int p_column, const Ref<Texture2D> &p_button, int p_id, bool p_disabled, const String &p_tooltip) { ERR_FAIL_INDEX(p_column, cells.size()); ERR_FAIL_COND(!p_button.is_valid()); @@ -542,9 +542,9 @@ int TreeItem::get_button_count(int p_column) const { ERR_FAIL_INDEX_V(p_column, cells.size(), -1); return cells[p_column].buttons.size(); } -Ref<Texture> TreeItem::get_button(int p_column, int p_idx) const { - ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture>()); - ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), Ref<Texture>()); +Ref<Texture2D> TreeItem::get_button(int p_column, int p_idx) const { + ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture2D>()); + ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), Ref<Texture2D>()); return cells[p_column].buttons[p_idx].texture; } String TreeItem::get_button_tooltip(int p_column, int p_idx) const { @@ -577,7 +577,7 @@ int TreeItem::get_button_by_id(int p_column, int p_id) const { return -1; } -void TreeItem::set_button(int p_column, int p_idx, const Ref<Texture> &p_button) { +void TreeItem::set_button(int p_column, int p_idx, const Ref<Texture2D> &p_button) { ERR_FAIL_COND(p_button.is_null()); ERR_FAIL_INDEX(p_column, cells.size()); @@ -1026,7 +1026,7 @@ int Tree::compute_item_height(TreeItem *p_item) const { case TreeItem::CELL_MODE_CUSTOM: case TreeItem::CELL_MODE_ICON: { - Ref<Texture> icon = p_item->cells[i].icon; + Ref<Texture2D> icon = p_item->cells[i].icon; if (!icon.is_null()) { Size2i s = p_item->cells[i].get_icon_size(); @@ -1190,7 +1190,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 int bw = 0; for (int j = p_item->cells[i].buttons.size() - 1; j >= 0; j--) { - Ref<Texture> b = p_item->cells[i].buttons[j].texture; + Ref<Texture2D> b = p_item->cells[i].buttons[j].texture; Size2 s = b->get_size() + cache.button_pressed->get_minimum_size(); if (s.height < label_h) s.height = label_h; @@ -1305,8 +1305,8 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 } break; case TreeItem::CELL_MODE_CHECK: { - Ref<Texture> checked = cache.checked; - Ref<Texture> unchecked = cache.unchecked; + Ref<Texture2D> checked = cache.checked; + Ref<Texture2D> unchecked = cache.unchecked; Point2i check_ofs = item_rect.position; check_ofs.y += Math::floor((real_t)(item_rect.size.y - checked->get_height()) / 2); @@ -1350,7 +1350,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 if (p_item->cells[i].suffix != String()) s += " " + p_item->cells[i].suffix; - Ref<Texture> downarrow = cache.select_arrow; + Ref<Texture2D> downarrow = cache.select_arrow; font->draw(ci, text_pos, s, col, item_rect.size.x - downarrow->get_width()); @@ -1361,7 +1361,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 downarrow->draw(ci, arrow_pos); } else { - Ref<Texture> updown = cache.updown; + Ref<Texture2D> updown = cache.updown; String valtext = String::num(p_item->cells[i].val, Math::range_step_decimals(p_item->cells[i].step)); @@ -1412,7 +1412,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 break; } - Ref<Texture> downarrow = cache.select_arrow; + Ref<Texture2D> downarrow = cache.select_arrow; Rect2i ir = item_rect; @@ -1462,7 +1462,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 if (!p_item->disable_folding && !hide_folding && p_item->children) { //has children, draw the guide box - Ref<Texture> arrow; + Ref<Texture2D> arrow; if (p_item->collapsed) { @@ -1775,7 +1775,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool bool already_cursor = (p_item == selected_item) && col == selected_col; for (int j = c.buttons.size() - 1; j >= 0; j--) { - Ref<Texture> b = c.buttons[j].texture; + Ref<Texture2D> b = c.buttons[j].texture; int w = b->get_size().width + cache.button_pressed->get_minimum_size().width; if (x > col_width - w) { @@ -3825,7 +3825,7 @@ String Tree::get_tooltip(const Point2 &p_pos) const { pos.x -= get_column_width(i); for (int j = c.buttons.size() - 1; j >= 0; j--) { - Ref<Texture> b = c.buttons[j].texture; + Ref<Texture2D> b = c.buttons[j].texture; Size2 size = b->get_size() + cache.button_pressed->get_minimum_size(); if (pos.x > col_width - size.width) { String tooltip = c.buttons[j].tooltip; diff --git a/scene/gui/tree.h b/scene/gui/tree.h index f3c88eb5ac..2072d0fd13 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -66,7 +66,7 @@ private: TreeCellMode mode; - Ref<Texture> icon; + Ref<Texture2D> icon; Rect2i icon_region; String text; String suffix; @@ -97,7 +97,7 @@ private: struct Button { int id; bool disabled; - Ref<Texture> texture; + Ref<Texture2D> texture; Color color; String tooltip; Button() { @@ -189,8 +189,8 @@ public: void set_suffix(int p_column, String p_suffix); String get_suffix(int p_column) const; - void set_icon(int p_column, const Ref<Texture> &p_icon); - Ref<Texture> get_icon(int p_column) const; + void set_icon(int p_column, const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_icon(int p_column) const; void set_icon_region(int p_column, const Rect2 &p_icon_region); Rect2 get_icon_region(int p_column) const; @@ -201,14 +201,14 @@ public: void set_icon_max_width(int p_column, int p_max); int get_icon_max_width(int p_column) const; - void add_button(int p_column, const Ref<Texture> &p_button, int p_id = -1, bool p_disabled = false, const String &p_tooltip = ""); + void add_button(int p_column, const Ref<Texture2D> &p_button, int p_id = -1, bool p_disabled = false, const String &p_tooltip = ""); int get_button_count(int p_column) const; String get_button_tooltip(int p_column, int p_idx) const; - Ref<Texture> get_button(int p_column, int p_idx) const; + Ref<Texture2D> get_button(int p_column, int p_idx) const; int get_button_id(int p_column, int p_idx) const; void erase_button(int p_column, int p_idx); int get_button_by_id(int p_column, int p_id) const; - void set_button(int p_column, int p_idx, const Ref<Texture> &p_button); + void set_button(int p_column, int p_idx, const Ref<Texture2D> &p_button); void set_button_color(int p_column, int p_idx, const Color &p_color); void set_button_disabled(int p_column, int p_idx, bool p_disabled); bool is_button_disabled(int p_column, int p_idx) const; @@ -374,7 +374,7 @@ private: int compute_item_height(TreeItem *p_item) const; int get_item_height(TreeItem *p_item) const; - //void draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color); + //void draw_item_text(String p_text,const Ref<Texture2D>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color); void draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color); int draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item); void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = NULL, bool *r_in_range = NULL, bool p_force_deselect = false); @@ -416,12 +416,12 @@ private: Color title_button_color; - Ref<Texture> checked; - Ref<Texture> unchecked; - Ref<Texture> arrow_collapsed; - Ref<Texture> arrow; - Ref<Texture> select_arrow; - Ref<Texture> updown; + Ref<Texture2D> checked; + Ref<Texture2D> unchecked; + Ref<Texture2D> arrow_collapsed; + Ref<Texture2D> arrow; + Ref<Texture2D> select_arrow; + Ref<Texture2D> updown; Color font_color; Color font_color_selected; diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 0a693d4023..3d8112b986 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -375,12 +375,12 @@ void VideoPlayer::set_stream_position(float p_position) { playback->seek(p_position); } -Ref<Texture> VideoPlayer::get_video_texture() const { +Ref<Texture2D> VideoPlayer::get_video_texture() const { if (playback.is_valid()) return playback->get_texture(); - return Ref<Texture>(); + return Ref<Texture2D>(); } void VideoPlayer::set_autoplay(bool p_enable) { diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index e740e3e4ed..78e7fa05f8 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -86,7 +86,7 @@ public: void set_expand(bool p_expand); bool has_expand() const; - Ref<Texture> get_video_texture() const; + Ref<Texture2D> get_video_texture() const; void set_stream(const Ref<VideoStream> &p_stream); Ref<VideoStream> get_stream() const; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 72ab817e98..412632acfc 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -75,9 +75,6 @@ void ViewportTexture::setup_local_to_scene() { vp->viewport_textures.insert(this); VS::get_singleton()->texture_set_proxy(proxy, vp->texture_rid); - - vp->texture_flags = flags; - VS::get_singleton()->texture_set_flags(vp->texture_rid, flags); } void ViewportTexture::set_viewport_path_in_scene(const NodePath &p_path) { @@ -125,21 +122,7 @@ bool ViewportTexture::has_alpha() const { Ref<Image> ViewportTexture::get_data() const { ERR_FAIL_COND_V_MSG(!vp, Ref<Image>(), "Viewport Texture must be set to use it."); - return VS::get_singleton()->texture_get_data(vp->texture_rid); -} -void ViewportTexture::set_flags(uint32_t p_flags) { - flags = p_flags; - - if (!vp) - return; - - vp->texture_flags = flags; - VS::get_singleton()->texture_set_flags(vp->texture_rid, flags); -} - -uint32_t ViewportTexture::get_flags() const { - - return flags; + return VS::get_singleton()->texture_2d_get(vp->texture_rid); } void ViewportTexture::_bind_methods() { @@ -153,9 +136,8 @@ void ViewportTexture::_bind_methods() { ViewportTexture::ViewportTexture() { vp = NULL; - flags = 0; set_local_to_scene(true); - proxy = VS::get_singleton()->texture_create(); + proxy = VS::get_singleton()->texture_2d_placeholder_create(); } ViewportTexture::~ViewportTexture() { @@ -3321,7 +3303,6 @@ Viewport::Viewport() { viewport = VisualServer::get_singleton()->viewport_create(); texture_rid = VisualServer::get_singleton()->viewport_get_texture(viewport); - texture_flags = 0; render_direct_to_screen = false; diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 79b606cda3..af7c8f1356 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -49,15 +49,14 @@ class Timer; class Viewport; class CollisionObject; -class ViewportTexture : public Texture { +class ViewportTexture : public Texture2D { - GDCLASS(ViewportTexture, Texture); + GDCLASS(ViewportTexture, Texture2D); NodePath path; friend class Viewport; Viewport *vp; - uint32_t flags; RID proxy; @@ -77,9 +76,6 @@ public: virtual bool has_alpha() const; - virtual void set_flags(uint32_t p_flags); - virtual uint32_t get_flags() const; - virtual Ref<Image> get_data() const; ViewportTexture(); @@ -270,7 +266,6 @@ private: bool keep_3d_linear; UpdateMode update_mode; RID texture_rid; - uint32_t texture_flags; DebugDraw debug_draw; diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 433c015a33..3fd900c324 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -524,7 +524,7 @@ void register_scene_types() { ClassDB::register_class<VisualShaderNodeVectorDecompose>(); ClassDB::register_class<VisualShaderNodeTransformDecompose>(); ClassDB::register_class<VisualShaderNodeTexture>(); - ClassDB::register_class<VisualShaderNodeCubeMap>(); + ClassDB::register_class<VisualShaderNodeCubemap>(); ClassDB::register_virtual_class<VisualShaderNodeUniform>(); ClassDB::register_class<VisualShaderNodeScalarUniform>(); ClassDB::register_class<VisualShaderNodeBooleanUniform>(); @@ -533,7 +533,7 @@ void register_scene_types() { ClassDB::register_class<VisualShaderNodeTransformUniform>(); ClassDB::register_class<VisualShaderNodeTextureUniform>(); ClassDB::register_class<VisualShaderNodeTextureUniformTriplanar>(); - ClassDB::register_class<VisualShaderNodeCubeMapUniform>(); + ClassDB::register_class<VisualShaderNodeCubemapUniform>(); ClassDB::register_class<VisualShaderNodeIf>(); ClassDB::register_class<VisualShaderNodeSwitch>(); ClassDB::register_class<VisualShaderNodeScalarSwitch>(); @@ -649,7 +649,7 @@ void register_scene_types() { ClassDB::register_class<World>(); ClassDB::register_class<Environment>(); ClassDB::register_class<World2D>(); - ClassDB::register_virtual_class<Texture>(); + ClassDB::register_virtual_class<Texture2D>(); ClassDB::register_virtual_class<Sky>(); ClassDB::register_class<PanoramaSky>(); ClassDB::register_class<ProceduralSky>(); @@ -663,10 +663,10 @@ void register_scene_types() { ClassDB::register_class<ProxyTexture>(); ClassDB::register_class<AnimatedTexture>(); ClassDB::register_class<CameraTexture>(); - ClassDB::register_class<CubeMap>(); ClassDB::register_virtual_class<TextureLayered>(); - ClassDB::register_class<Texture3D>(); - ClassDB::register_class<TextureArray>(); + ClassDB::register_class<Cubemap>(); + ClassDB::register_class<CubemapArray>(); + ClassDB::register_class<Texture2DArray>(); ClassDB::register_class<Animation>(); ClassDB::register_virtual_class<Font>(); ClassDB::register_class<BitmapFont>(); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 00c56e5eb2..5a6a8dc286 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -69,7 +69,7 @@ static Ref<StyleBoxTexture> make_stylebox(T p_src, float p_left, float p_top, fl img->resize(orig_size.x * scale, orig_size.y * scale); } - texture->create_from_image(img, ImageTexture::FLAG_FILTER); + texture->create_from_image(img); (*tex_cache)[p_src] = texture; } @@ -98,7 +98,7 @@ static Ref<StyleBoxTexture> sb_expand(Ref<StyleBoxTexture> p_sbox, float p_left, } template <class T> -static Ref<Texture> make_icon(T p_src) { +static Ref<Texture2D> make_icon(T p_src) { Ref<ImageTexture> texture(memnew(ImageTexture)); Ref<Image> img = memnew(Image(p_src)); @@ -115,7 +115,7 @@ static Ref<Texture> make_icon(T p_src) { img->convert(Image::FORMAT_RGBA8); img->resize(orig_size.x * scale, orig_size.y * scale); } - texture->create_from_image(img, ImageTexture::FLAG_FILTER); + texture->create_from_image(img); return texture; } @@ -169,7 +169,7 @@ static Ref<StyleBox> make_empty_stylebox(float p_margin_left = -1, float p_margi return style; } -void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture> &default_icon, Ref<StyleBox> &default_style, float p_scale) { +void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture2D> &default_icon, Ref<StyleBox> &default_style, float p_scale) { scale = p_scale; @@ -464,7 +464,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_constant("completion_scroll_width", "TextEdit", 3); theme->set_constant("line_spacing", "TextEdit", 4 * scale); - Ref<Texture> empty_icon = memnew(ImageTexture); + Ref<Texture2D> empty_icon = memnew(ImageTexture); // HScrollBar @@ -873,7 +873,7 @@ void make_default_theme(bool p_hidpi, Ref<Font> p_font) { t.instance(); Ref<StyleBox> default_style; - Ref<Texture> default_icon; + Ref<Texture2D> default_icon; Ref<Font> default_font; if (p_font.is_valid()) { default_font = p_font; diff --git a/scene/resources/default_theme/default_theme.h b/scene/resources/default_theme/default_theme.h index 1807770ff4..46f89a9b50 100644 --- a/scene/resources/default_theme/default_theme.h +++ b/scene/resources/default_theme/default_theme.h @@ -33,7 +33,7 @@ #include "scene/resources/theme.h" -void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture> &default_icon, Ref<StyleBox> &default_style, float p_scale); +void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture2D> &default_icon, Ref<StyleBox> &default_style, float p_scale); void make_default_theme(bool p_hidpi, Ref<Font> p_font); void clear_default_theme(); diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 451029e93b..235f200c4e 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -222,11 +222,6 @@ Error DynamicFontAtSize::_load() { ascent = (face->size->metrics.ascender / 64.0) / oversampling * scale_color_font; descent = (-face->size->metrics.descender / 64.0) / oversampling * scale_color_font; linegap = 0; - texture_flags = 0; - if (id.mipmaps) - texture_flags |= Texture::FLAG_MIPMAPS; - if (id.filter) - texture_flags |= Texture::FLAG_FILTER; valid = true; return OK; @@ -299,16 +294,6 @@ Size2 DynamicFontAtSize::get_char_size(CharType p_char, CharType p_next, const V return ret; } -void DynamicFontAtSize::set_texture_flags(uint32_t p_flags) { - - texture_flags = p_flags; - for (int i = 0; i < textures.size(); i++) { - Ref<ImageTexture> &tex = textures.write[i].texture; - if (!tex.is_null()) - tex->set_flags(p_flags); - } -} - float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks, bool p_advance_only, bool p_outline) const { if (!valid) @@ -536,9 +521,9 @@ DynamicFontAtSize::Character DynamicFontAtSize::_bitmap_to_character(FT_Bitmap b if (tex.texture.is_null()) { tex.texture.instance(); - tex.texture->create_from_image(img, Texture::FLAG_VIDEO_SURFACE | texture_flags); + tex.texture->create_from_image(img); } else { - tex.texture->set_data(img); //update + tex.texture->update(img); //update } } @@ -659,7 +644,6 @@ DynamicFontAtSize::DynamicFontAtSize() { ascent = 1; descent = 1; linegap = 1; - texture_flags = 0; oversampling = font_oversampling; scale_color_font = 1; } @@ -758,34 +742,6 @@ Color DynamicFont::get_outline_color() const { return outline_color; } -bool DynamicFont::get_use_mipmaps() const { - - return cache_id.mipmaps; -} - -void DynamicFont::set_use_mipmaps(bool p_enable) { - - if (cache_id.mipmaps == p_enable) - return; - cache_id.mipmaps = p_enable; - outline_cache_id.mipmaps = p_enable; - _reload_cache(); -} - -bool DynamicFont::get_use_filter() const { - - return cache_id.filter; -} - -void DynamicFont::set_use_filter(bool p_enable) { - - if (cache_id.filter == p_enable) - return; - cache_id.filter = p_enable; - outline_cache_id.filter = p_enable; - _reload_cache(); -} - bool DynamicFontData::is_antialiased() const { return antialiased; @@ -1007,10 +963,6 @@ void DynamicFont::_bind_methods() { ClassDB::bind_method(D_METHOD("set_outline_color", "color"), &DynamicFont::set_outline_color); ClassDB::bind_method(D_METHOD("get_outline_color"), &DynamicFont::get_outline_color); - ClassDB::bind_method(D_METHOD("set_use_mipmaps", "enable"), &DynamicFont::set_use_mipmaps); - ClassDB::bind_method(D_METHOD("get_use_mipmaps"), &DynamicFont::get_use_mipmaps); - ClassDB::bind_method(D_METHOD("set_use_filter", "enable"), &DynamicFont::set_use_filter); - ClassDB::bind_method(D_METHOD("get_use_filter"), &DynamicFont::get_use_filter); ClassDB::bind_method(D_METHOD("set_spacing", "type", "value"), &DynamicFont::set_spacing); ClassDB::bind_method(D_METHOD("get_spacing", "type"), &DynamicFont::get_spacing); @@ -1024,8 +976,6 @@ void DynamicFont::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "size", PROPERTY_HINT_RANGE, "1,1024,1"), "set_size", "get_size"); ADD_PROPERTY(PropertyInfo(Variant::INT, "outline_size", PROPERTY_HINT_RANGE, "0,1024,1"), "set_outline_size", "get_outline_size"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "outline_color"), "set_outline_color", "get_outline_color"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_mipmaps"), "set_use_mipmaps", "get_use_mipmaps"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_filter"), "set_use_filter", "get_use_filter"); ADD_GROUP("Extra Spacing", "extra_spacing"); ADD_PROPERTYI(PropertyInfo(Variant::INT, "extra_spacing_top"), "set_spacing", "get_spacing", SPACING_TOP); ADD_PROPERTYI(PropertyInfo(Variant::INT, "extra_spacing_bottom"), "set_spacing", "get_spacing", SPACING_BOTTOM); diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index 9170767512..94f03665d3 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -56,9 +56,7 @@ public: struct { uint32_t size : 16; uint32_t outline_size : 8; - uint32_t mipmaps : 1; - uint32_t filter : 1; - uint32_t unused : 6; + uint32_t unused : 8; }; uint32_t key; }; @@ -127,8 +125,6 @@ class DynamicFontAtSize : public Reference { float oversampling; float scale_color_font; - uint32_t texture_flags; - bool valid; struct CharTexture { diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 7597cd636e..37a185ecac 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -113,7 +113,10 @@ void Environment::set_ambient_light_sky_contribution(float p_energy) { void Environment::set_camera_feed_id(int p_camera_feed_id) { camera_feed_id = p_camera_feed_id; +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 VS::get_singleton()->environment_set_camera_feed_id(environment, camera_feed_id); +#endif }; Environment::BGMode Environment::get_background() const { @@ -300,12 +303,12 @@ float Environment::get_adjustment_saturation() const { return adjustment_saturation; } -void Environment::set_adjustment_color_correction(const Ref<Texture> &p_ramp) { +void Environment::set_adjustment_color_correction(const Ref<Texture2D> &p_ramp) { adjustment_color_correction = p_ramp; VS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID()); } -Ref<Texture> Environment::get_adjustment_color_correction() const { +Ref<Texture2D> Environment::get_adjustment_color_correction() const { return adjustment_color_correction; } @@ -1273,7 +1276,7 @@ void Environment::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "adjustment_brightness", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_brightness", "get_adjustment_brightness"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "adjustment_contrast", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_contrast", "get_adjustment_contrast"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "adjustment_saturation", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_saturation", "get_adjustment_saturation"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "adjustment_color_correction", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_adjustment_color_correction", "get_adjustment_color_correction"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "adjustment_color_correction", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_adjustment_color_correction", "get_adjustment_color_correction"); BIND_ENUM_CONSTANT(BG_KEEP); BIND_ENUM_CONSTANT(BG_CLEAR_COLOR); diff --git a/scene/resources/environment.h b/scene/resources/environment.h index 62c6c5b4cd..e9088d4fbd 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -114,7 +114,7 @@ private: float adjustment_contrast; float adjustment_saturation; float adjustment_brightness; - Ref<Texture> adjustment_color_correction; + Ref<Texture2D> adjustment_color_correction; bool ssr_enabled; int ssr_max_steps; @@ -246,8 +246,8 @@ public: void set_adjustment_saturation(float p_saturation); float get_adjustment_saturation() const; - void set_adjustment_color_correction(const Ref<Texture> &p_ramp); - Ref<Texture> get_adjustment_color_correction() const; + void set_adjustment_color_correction(const Ref<Texture2D> &p_ramp); + Ref<Texture2D> get_adjustment_color_correction() const; void set_ssr_enabled(bool p_enable); bool is_ssr_enabled() const; diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 19c59b3817..076a0ced48 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -182,7 +182,7 @@ void BitmapFont::_set_textures(const Vector<Variant> &p_textures) { textures.clear(); for (int i = 0; i < p_textures.size(); i++) { - Ref<Texture> tex = p_textures[i]; + Ref<Texture2D> tex = p_textures[i]; ERR_CONTINUE(!tex.is_valid()); add_texture(tex); } @@ -270,7 +270,7 @@ Error BitmapFont::create_from_fnt(const String &p_file) { String base_dir = p_file.get_base_dir(); String file = base_dir.plus_file(keys["file"]); - Ref<Texture> tex = ResourceLoader::load(file); + Ref<Texture2D> tex = ResourceLoader::load(file); if (tex.is_null()) { ERR_PRINT("Can't load font texture!"); } else { @@ -356,7 +356,7 @@ float BitmapFont::get_descent() const { return height - ascent; } -void BitmapFont::add_texture(const Ref<Texture> &p_texture) { +void BitmapFont::add_texture(const Ref<Texture2D> &p_texture) { ERR_FAIL_COND_MSG(p_texture.is_null(), "It's not a reference to a valid Texture object."); textures.push_back(p_texture); @@ -367,9 +367,9 @@ int BitmapFont::get_texture_count() const { return textures.size(); }; -Ref<Texture> BitmapFont::get_texture(int p_idx) const { +Ref<Texture2D> BitmapFont::get_texture(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, textures.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_idx, textures.size(), Ref<Texture2D>()); return textures[p_idx]; }; diff --git a/scene/resources/font.h b/scene/resources/font.h index 411145c153..fc1d92e2f9 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -108,7 +108,7 @@ class BitmapFont : public Font { GDCLASS(BitmapFont, Font); RES_BASE_EXTENSION("font"); - Vector<Ref<Texture> > textures; + Vector<Ref<Texture2D> > textures; public: struct Character { @@ -168,7 +168,7 @@ public: float get_ascent() const; float get_descent() const; - void add_texture(const Ref<Texture> &p_texture); + void add_texture(const Ref<Texture2D> &p_texture); void add_char(CharType p_char, int p_texture_idx, const Rect2 &p_rect, const Size2 &p_align, float p_advance = -1); int get_character_count() const; @@ -176,7 +176,7 @@ public: Character get_character(CharType p_char) const; int get_texture_count() const; - Ref<Texture> get_texture(int p_idx) const; + Ref<Texture2D> get_texture(int p_idx) const; void add_kerning_pair(CharType p_A, CharType p_B, int p_kerning); int get_kerning_pair(CharType p_A, CharType p_B) const; diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index ab4dbb758a..e90a917b27 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1407,7 +1407,7 @@ bool SpatialMaterial::get_feature(Feature p_feature) const { return features[p_feature]; } -void SpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture> &p_texture) { +void SpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture2D> &p_texture) { ERR_FAIL_INDEX(p_param, TEXTURE_MAX); textures[p_param] = p_texture; @@ -1417,19 +1417,19 @@ void SpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture> &p_te _queue_shader_change(); } -Ref<Texture> SpatialMaterial::get_texture(TextureParam p_param) const { +Ref<Texture2D> SpatialMaterial::get_texture(TextureParam p_param) const { - ERR_FAIL_INDEX_V(p_param, TEXTURE_MAX, Ref<Texture>()); + ERR_FAIL_INDEX_V(p_param, TEXTURE_MAX, Ref<Texture2D>()); return textures[p_param]; } -Ref<Texture> SpatialMaterial::get_texture_by_name(StringName p_name) const { +Ref<Texture2D> SpatialMaterial::get_texture_by_name(StringName p_name) const { for (int i = 0; i < (int)SpatialMaterial::TEXTURE_MAX; i++) { TextureParam param = TextureParam(i); if (p_name == shader_names->texture_names[param]) return textures[param]; } - return Ref<Texture>(); + return Ref<Texture2D>(); } void SpatialMaterial::_validate_feature(const String &text, Feature feature, PropertyInfo &property) const { @@ -2137,17 +2137,17 @@ void SpatialMaterial::_bind_methods() { ADD_GROUP("Albedo", "albedo_"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "albedo_color"), "set_albedo", "get_albedo"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "albedo_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_ALBEDO); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "albedo_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_ALBEDO); ADD_GROUP("Metallic", "metallic_"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "metallic", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_metallic", "get_metallic"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "metallic_specular", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_specular", "get_specular"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "metallic_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_METALLIC); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "metallic_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_METALLIC); ADD_PROPERTY(PropertyInfo(Variant::INT, "metallic_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_metallic_texture_channel", "get_metallic_texture_channel"); ADD_GROUP("Roughness", "roughness_"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "roughness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_roughness", "get_roughness"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "roughness_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_ROUGHNESS); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "roughness_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_ROUGHNESS); ADD_PROPERTY(PropertyInfo(Variant::INT, "roughness_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_roughness_texture_channel", "get_roughness_texture_channel"); ADD_GROUP("Emission", "emission_"); @@ -2156,34 +2156,34 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "emission_energy", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_emission_energy", "get_emission_energy"); ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_operator", PROPERTY_HINT_ENUM, "Add,Multiply"), "set_emission_operator", "get_emission_operator"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "emission_on_uv2"), "set_flag", "get_flag", FLAG_EMISSION_ON_UV2); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "emission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_EMISSION); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "emission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_EMISSION); ADD_GROUP("NormalMap", "normal_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "normal_enabled"), "set_feature", "get_feature", FEATURE_NORMAL_MAPPING); ADD_PROPERTY(PropertyInfo(Variant::REAL, "normal_scale", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_normal_scale", "get_normal_scale"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "normal_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_NORMAL); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "normal_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_NORMAL); ADD_GROUP("Rim", "rim_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "rim_enabled"), "set_feature", "get_feature", FEATURE_RIM); ADD_PROPERTY(PropertyInfo(Variant::REAL, "rim", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_rim", "get_rim"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "rim_tint", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_rim_tint", "get_rim_tint"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "rim_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_RIM); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "rim_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_RIM); ADD_GROUP("Clearcoat", "clearcoat_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "clearcoat_enabled"), "set_feature", "get_feature", FEATURE_CLEARCOAT); ADD_PROPERTY(PropertyInfo(Variant::REAL, "clearcoat", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_clearcoat", "get_clearcoat"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "clearcoat_gloss", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_clearcoat_gloss", "get_clearcoat_gloss"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "clearcoat_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_CLEARCOAT); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "clearcoat_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_CLEARCOAT); ADD_GROUP("Anisotropy", "anisotropy_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "anisotropy_enabled"), "set_feature", "get_feature", FEATURE_ANISOTROPY); ADD_PROPERTY(PropertyInfo(Variant::REAL, "anisotropy", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_anisotropy", "get_anisotropy"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anisotropy_flowmap", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_FLOWMAP); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anisotropy_flowmap", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_FLOWMAP); ADD_GROUP("Ambient Occlusion", "ao_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "ao_enabled"), "set_feature", "get_feature", FEATURE_AMBIENT_OCCLUSION); ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_light_affect", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ao_light_affect", "get_ao_light_affect"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "ao_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_AMBIENT_OCCLUSION); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "ao_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_AMBIENT_OCCLUSION); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "ao_on_uv2"), "set_flag", "get_flag", FLAG_AO_ON_UV2); ADD_PROPERTY(PropertyInfo(Variant::INT, "ao_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_ao_texture_channel", "get_ao_texture_channel"); @@ -2195,31 +2195,31 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "depth_max_layers", PROPERTY_HINT_RANGE, "1,32,1"), "set_depth_deep_parallax_max_layers", "get_depth_deep_parallax_max_layers"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "depth_flip_tangent"), "set_depth_deep_parallax_flip_tangent", "get_depth_deep_parallax_flip_tangent"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "depth_flip_binormal"), "set_depth_deep_parallax_flip_binormal", "get_depth_deep_parallax_flip_binormal"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "depth_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_DEPTH); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "depth_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_DEPTH); ADD_GROUP("Subsurf Scatter", "subsurf_scatter_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "subsurf_scatter_enabled"), "set_feature", "get_feature", FEATURE_SUBSURACE_SCATTERING); ADD_PROPERTY(PropertyInfo(Variant::REAL, "subsurf_scatter_strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_subsurface_scattering_strength", "get_subsurface_scattering_strength"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "subsurf_scatter_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_SUBSURFACE_SCATTERING); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "subsurf_scatter_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_SUBSURFACE_SCATTERING); ADD_GROUP("Transmission", "transmission_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "transmission_enabled"), "set_feature", "get_feature", FEATURE_TRANSMISSION); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "transmission", PROPERTY_HINT_COLOR_NO_ALPHA), "set_transmission", "get_transmission"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "transmission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_TRANSMISSION); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "transmission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_TRANSMISSION); ADD_GROUP("Refraction", "refraction_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "refraction_enabled"), "set_feature", "get_feature", FEATURE_REFRACTION); ADD_PROPERTY(PropertyInfo(Variant::REAL, "refraction_scale", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_refraction", "get_refraction"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "refraction_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_REFRACTION); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "refraction_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_REFRACTION); ADD_PROPERTY(PropertyInfo(Variant::INT, "refraction_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_refraction_texture_channel", "get_refraction_texture_channel"); ADD_GROUP("Detail", "detail_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "detail_enabled"), "set_feature", "get_feature", FEATURE_DETAIL); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_mask", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_DETAIL_MASK); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_mask", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_DETAIL_MASK); ADD_PROPERTY(PropertyInfo(Variant::INT, "detail_blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul"), "set_detail_blend_mode", "get_detail_blend_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "detail_uv_layer", PROPERTY_HINT_ENUM, "UV1,UV2"), "set_detail_uv", "get_detail_uv"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_albedo", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_DETAIL_ALBEDO); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_DETAIL_NORMAL); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_albedo", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_DETAIL_ALBEDO); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_DETAIL_NORMAL); ADD_GROUP("UV1", "uv1_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv1_scale"), "set_uv1_scale", "get_uv1_scale"); diff --git a/scene/resources/material.h b/scene/resources/material.h index 8e66011bec..38fb8b2172 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -437,7 +437,7 @@ private: bool features[FEATURE_MAX]; - Ref<Texture> textures[TEXTURE_MAX]; + Ref<Texture2D> textures[TEXTURE_MAX]; _FORCE_INLINE_ void _validate_feature(const String &text, Feature feature, PropertyInfo &property) const; @@ -549,10 +549,10 @@ public: void set_flag(Flags p_flag, bool p_enabled); bool get_flag(Flags p_flag) const; - void set_texture(TextureParam p_param, const Ref<Texture> &p_texture); - Ref<Texture> get_texture(TextureParam p_param) const; + void set_texture(TextureParam p_param, const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_texture(TextureParam p_param) const; // Used only for shader material conversion - Ref<Texture> get_texture_by_name(StringName p_name) const; + Ref<Texture2D> get_texture_by_name(StringName p_name) const; void set_feature(Feature p_feature, bool p_enabled); bool get_feature(Feature p_feature) const; diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp index 754cad4def..ac016bec5d 100644 --- a/scene/resources/mesh_library.cpp +++ b/scene/resources/mesh_library.cpp @@ -104,7 +104,7 @@ void MeshLibrary::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::ARRAY, name + "shapes")); p_list->push_back(PropertyInfo(Variant::OBJECT, name + "navmesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh")); p_list->push_back(PropertyInfo(Variant::TRANSFORM, name + "navmesh_transform")); - p_list->push_back(PropertyInfo(Variant::OBJECT, name + "preview", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_HELPER)); + p_list->push_back(PropertyInfo(Variant::OBJECT, name + "preview", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_HELPER)); } } @@ -162,7 +162,7 @@ void MeshLibrary::set_item_navmesh_transform(int p_item, const Transform &p_tran _change_notify(); } -void MeshLibrary::set_item_preview(int p_item, const Ref<Texture> &p_preview) { +void MeshLibrary::set_item_preview(int p_item, const Ref<Texture2D> &p_preview) { ERR_FAIL_COND_MSG(!item_map.has(p_item), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'."); item_map[p_item].preview = p_preview; @@ -200,14 +200,14 @@ Transform MeshLibrary::get_item_navmesh_transform(int p_item) const { return item_map[p_item].navmesh_transform; } -Ref<Texture> MeshLibrary::get_item_preview(int p_item) const { +Ref<Texture2D> MeshLibrary::get_item_preview(int p_item) const { if (!Engine::get_singleton()->is_editor_hint()) { ERR_PRINT("MeshLibrary item previews are only generated in an editor context, which means they aren't available in a running project."); - return Ref<Texture>(); + return Ref<Texture2D>(); } - ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<Texture>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'."); + ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<Texture2D>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'."); return item_map[p_item].preview; } diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h index 5f1fddae22..9155975f47 100644 --- a/scene/resources/mesh_library.h +++ b/scene/resources/mesh_library.h @@ -51,7 +51,7 @@ public: String name; Ref<Mesh> mesh; Vector<ShapeData> shapes; - Ref<Texture> preview; + Ref<Texture2D> preview; Transform navmesh_transform; Ref<NavigationMesh> navmesh; }; @@ -75,13 +75,13 @@ public: void set_item_navmesh(int p_item, const Ref<NavigationMesh> &p_navmesh); void set_item_navmesh_transform(int p_item, const Transform &p_transform); void set_item_shapes(int p_item, const Vector<ShapeData> &p_shapes); - void set_item_preview(int p_item, const Ref<Texture> &p_preview); + void set_item_preview(int p_item, const Ref<Texture2D> &p_preview); String get_item_name(int p_item) const; Ref<Mesh> get_item_mesh(int p_item) const; Ref<NavigationMesh> get_item_navmesh(int p_item) const; Transform get_item_navmesh_transform(int p_item) const; Vector<ShapeData> get_item_shapes(int p_item) const; - Ref<Texture> get_item_preview(int p_item) const; + Ref<Texture2D> get_item_preview(int p_item) const; void remove_item(int p_item); bool has_item(int p_item) const; diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp index baeb88400e..d852dca7fa 100644 --- a/scene/resources/particles_material.cpp +++ b/scene/resources/particles_material.cpp @@ -790,7 +790,7 @@ float ParticlesMaterial::get_param_randomness(Parameter p_param) const { return randomness[p_param]; } -static void _adjust_curve_range(const Ref<Texture> &p_texture, float p_min, float p_max) { +static void _adjust_curve_range(const Ref<Texture2D> &p_texture, float p_min, float p_max) { Ref<CurveTexture> curve_tex = p_texture; if (!curve_tex.is_valid()) @@ -799,7 +799,7 @@ static void _adjust_curve_range(const Ref<Texture> &p_texture, float p_min, floa curve_tex->ensure_default_setup(p_min, p_max); } -void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture> &p_texture) { +void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture2D> &p_texture) { ERR_FAIL_INDEX(p_param, PARAM_MAX); @@ -857,9 +857,9 @@ void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture> _queue_shader_change(); } -Ref<Texture> ParticlesMaterial::get_param_texture(Parameter p_param) const { +Ref<Texture2D> ParticlesMaterial::get_param_texture(Parameter p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref<Texture>()); + ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref<Texture2D>()); return tex_parameters[p_param]; } @@ -875,7 +875,7 @@ Color ParticlesMaterial::get_color() const { return color; } -void ParticlesMaterial::set_color_ramp(const Ref<Texture> &p_texture) { +void ParticlesMaterial::set_color_ramp(const Ref<Texture2D> &p_texture) { color_ramp = p_texture; VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->color_ramp, p_texture); @@ -883,7 +883,7 @@ void ParticlesMaterial::set_color_ramp(const Ref<Texture> &p_texture) { _change_notify(); } -Ref<Texture> ParticlesMaterial::get_color_ramp() const { +Ref<Texture2D> ParticlesMaterial::get_color_ramp() const { return color_ramp; } @@ -921,19 +921,19 @@ void ParticlesMaterial::set_emission_box_extents(Vector3 p_extents) { VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_box_extents, p_extents); } -void ParticlesMaterial::set_emission_point_texture(const Ref<Texture> &p_points) { +void ParticlesMaterial::set_emission_point_texture(const Ref<Texture2D> &p_points) { emission_point_texture = p_points; VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_points, p_points); } -void ParticlesMaterial::set_emission_normal_texture(const Ref<Texture> &p_normals) { +void ParticlesMaterial::set_emission_normal_texture(const Ref<Texture2D> &p_normals) { emission_normal_texture = p_normals; VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_normal, p_normals); } -void ParticlesMaterial::set_emission_color_texture(const Ref<Texture> &p_colors) { +void ParticlesMaterial::set_emission_color_texture(const Ref<Texture2D> &p_colors) { emission_color_texture = p_colors; VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_color, p_colors); @@ -959,16 +959,16 @@ Vector3 ParticlesMaterial::get_emission_box_extents() const { return emission_box_extents; } -Ref<Texture> ParticlesMaterial::get_emission_point_texture() const { +Ref<Texture2D> ParticlesMaterial::get_emission_point_texture() const { return emission_point_texture; } -Ref<Texture> ParticlesMaterial::get_emission_normal_texture() const { +Ref<Texture2D> ParticlesMaterial::get_emission_normal_texture() const { return emission_normal_texture; } -Ref<Texture> ParticlesMaterial::get_emission_color_texture() const { +Ref<Texture2D> ParticlesMaterial::get_emission_color_texture() const { return emission_color_texture; } @@ -1162,9 +1162,9 @@ void ParticlesMaterial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_shape", PROPERTY_HINT_ENUM, "Point,Sphere,Box,Points,Directed Points"), "set_emission_shape", "get_emission_shape"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "emission_sphere_radius", PROPERTY_HINT_RANGE, "0.01,128,0.01,or_greater"), "set_emission_sphere_radius", "get_emission_sphere_radius"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "emission_box_extents"), "set_emission_box_extents", "get_emission_box_extents"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_point_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_emission_point_texture", "get_emission_point_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_normal_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_emission_normal_texture", "get_emission_normal_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_color_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_emission_color_texture", "get_emission_color_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_point_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_emission_point_texture", "get_emission_point_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_normal_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_emission_normal_texture", "get_emission_normal_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_color_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_emission_color_texture", "get_emission_color_texture"); ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_point_count", PROPERTY_HINT_RANGE, "0,1000000,1"), "set_emission_point_count", "get_emission_point_count"); ADD_GROUP("Flags", "flag_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_align_y"), "set_flag", "get_flag", FLAG_ALIGN_Y_TO_VELOCITY); diff --git a/scene/resources/particles_material.h b/scene/resources/particles_material.h index cc860b3812..246ce58a21 100644 --- a/scene/resources/particles_material.h +++ b/scene/resources/particles_material.h @@ -205,18 +205,18 @@ private: float parameters[PARAM_MAX]; float randomness[PARAM_MAX]; - Ref<Texture> tex_parameters[PARAM_MAX]; + Ref<Texture2D> tex_parameters[PARAM_MAX]; Color color; - Ref<Texture> color_ramp; + Ref<Texture2D> color_ramp; bool flags[FLAG_MAX]; EmissionShape emission_shape; float emission_sphere_radius; Vector3 emission_box_extents; - Ref<Texture> emission_point_texture; - Ref<Texture> emission_normal_texture; - Ref<Texture> emission_color_texture; + Ref<Texture2D> emission_point_texture; + Ref<Texture2D> emission_normal_texture; + Ref<Texture2D> emission_color_texture; int emission_point_count; bool anim_loop; @@ -252,14 +252,14 @@ public: void set_param_randomness(Parameter p_param, float p_value); float get_param_randomness(Parameter p_param) const; - void set_param_texture(Parameter p_param, const Ref<Texture> &p_texture); - Ref<Texture> get_param_texture(Parameter p_param) const; + void set_param_texture(Parameter p_param, const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_param_texture(Parameter p_param) const; void set_color(const Color &p_color); Color get_color() const; - void set_color_ramp(const Ref<Texture> &p_texture); - Ref<Texture> get_color_ramp() const; + void set_color_ramp(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_color_ramp() const; void set_flag(Flags p_flag, bool p_enable); bool get_flag(Flags p_flag) const; @@ -267,17 +267,17 @@ public: void set_emission_shape(EmissionShape p_shape); void set_emission_sphere_radius(float p_radius); void set_emission_box_extents(Vector3 p_extents); - void set_emission_point_texture(const Ref<Texture> &p_points); - void set_emission_normal_texture(const Ref<Texture> &p_normals); - void set_emission_color_texture(const Ref<Texture> &p_colors); + void set_emission_point_texture(const Ref<Texture2D> &p_points); + void set_emission_normal_texture(const Ref<Texture2D> &p_normals); + void set_emission_color_texture(const Ref<Texture2D> &p_colors); void set_emission_point_count(int p_count); EmissionShape get_emission_shape() const; float get_emission_sphere_radius() const; Vector3 get_emission_box_extents() const; - Ref<Texture> get_emission_point_texture() const; - Ref<Texture> get_emission_normal_texture() const; - Ref<Texture> get_emission_color_texture() const; + Ref<Texture2D> get_emission_point_texture() const; + Ref<Texture2D> get_emission_normal_texture() const; + Ref<Texture2D> get_emission_color_texture() const; int get_emission_point_count() const; void set_trail_divisor(int p_divisor); diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index 44c2a46065..79cb9754df 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -98,7 +98,7 @@ RID Shader::get_rid() const { return shader; } -void Shader::set_default_texture_param(const StringName &p_param, const Ref<Texture> &p_texture) { +void Shader::set_default_texture_param(const StringName &p_param, const Ref<Texture2D> &p_texture) { if (p_texture.is_valid()) { default_textures[p_param] = p_texture; @@ -111,17 +111,17 @@ void Shader::set_default_texture_param(const StringName &p_param, const Ref<Text emit_changed(); } -Ref<Texture> Shader::get_default_texture_param(const StringName &p_param) const { +Ref<Texture2D> Shader::get_default_texture_param(const StringName &p_param) const { if (default_textures.has(p_param)) return default_textures[p_param]; else - return Ref<Texture>(); + return Ref<Texture2D>(); } void Shader::get_default_texture_param_list(List<StringName> *r_textures) const { - for (const Map<StringName, Ref<Texture> >::Element *E = default_textures.front(); E; E = E->next()) { + for (const Map<StringName, Ref<Texture2D> >::Element *E = default_textures.front(); E; E = E->next()) { r_textures->push_back(E->key()); } diff --git a/scene/resources/shader.h b/scene/resources/shader.h index 67ae436a4c..702e58aedc 100644 --- a/scene/resources/shader.h +++ b/scene/resources/shader.h @@ -59,7 +59,7 @@ private: // conversion fast and save memory. mutable bool params_cache_dirty; mutable Map<StringName, StringName> params_cache; //map a shader param to a material param.. - Map<StringName, Ref<Texture> > default_textures; + Map<StringName, Ref<Texture2D> > default_textures; virtual void _update_shader() const; //used for visual shader protected: @@ -75,8 +75,8 @@ public: void get_param_list(List<PropertyInfo> *p_params) const; bool has_param(const StringName &p_param) const; - void set_default_texture_param(const StringName &p_param, const Ref<Texture> &p_texture); - Ref<Texture> get_default_texture_param(const StringName &p_param) const; + void set_default_texture_param(const StringName &p_param, const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_default_texture_param(const StringName &p_param) const; void get_default_texture_param_list(List<StringName> *r_textures) const; virtual bool is_text_shader() const; diff --git a/scene/resources/sky.cpp b/scene/resources/sky.cpp index c20fbb4129..59af1f58e8 100644 --- a/scene/resources/sky.cpp +++ b/scene/resources/sky.cpp @@ -77,7 +77,7 @@ void PanoramaSky::_radiance_changed() { } } -void PanoramaSky::set_panorama(const Ref<Texture> &p_panorama) { +void PanoramaSky::set_panorama(const Ref<Texture2D> &p_panorama) { panorama = p_panorama; @@ -90,7 +90,7 @@ void PanoramaSky::set_panorama(const Ref<Texture> &p_panorama) { } } -Ref<Texture> PanoramaSky::get_panorama() const { +Ref<Texture2D> PanoramaSky::get_panorama() const { return panorama; } @@ -105,7 +105,7 @@ void PanoramaSky::_bind_methods() { ClassDB::bind_method(D_METHOD("set_panorama", "texture"), &PanoramaSky::set_panorama); ClassDB::bind_method(D_METHOD("get_panorama"), &PanoramaSky::get_panorama); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "panorama", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_panorama", "get_panorama"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "panorama", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_panorama", "get_panorama"); } PanoramaSky::PanoramaSky() { @@ -415,8 +415,12 @@ void ProceduralSky::_update_sky() { } else { Ref<Image> image = _generate_sky(); - VS::get_singleton()->texture_allocate(texture, image->get_width(), image->get_height(), 0, Image::FORMAT_RGBE9995, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT); - VS::get_singleton()->texture_set_data(texture, image); + if (texture.is_valid()) { + RID new_texture = VS::get_singleton()->texture_2d_create(image); + VS::get_singleton()->texture_replace(texture, new_texture); + } else { + texture = VS::get_singleton()->texture_2d_create(image); + } _radiance_changed(); } } @@ -432,8 +436,13 @@ void ProceduralSky::_queue_update() { void ProceduralSky::_thread_done(const Ref<Image> &p_image) { - VS::get_singleton()->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, Image::FORMAT_RGBE9995, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT); - VS::get_singleton()->texture_set_data(texture, p_image); + if (texture.is_valid()) { + RID new_texture = VS::get_singleton()->texture_2d_create(p_image); + VS::get_singleton()->texture_replace(texture, new_texture); + } else { + texture = VS::get_singleton()->texture_2d_create(p_image); + } + _radiance_changed(); Thread::wait_to_finish(sky_thread); memdelete(sky_thread); @@ -525,7 +534,7 @@ void ProceduralSky::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "sun_curve", PROPERTY_HINT_EXP_EASING), "set_sun_curve", "get_sun_curve"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "sun_energy", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_sun_energy", "get_sun_energy"); - ADD_GROUP("Texture", "texture_"); + ADD_GROUP("Texture2D", "texture_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_size", PROPERTY_HINT_ENUM, "256,512,1024,2048,4096"), "set_texture_size", "get_texture_size"); BIND_ENUM_CONSTANT(TEXTURE_SIZE_256); @@ -539,7 +548,6 @@ void ProceduralSky::_bind_methods() { ProceduralSky::ProceduralSky(bool p_desaturate) { sky = VS::get_singleton()->sky_create(); - texture = VS::get_singleton()->texture_create(); update_queued = false; sky_top_color = Color::hex(0xa5d6f1ff); @@ -582,5 +590,7 @@ ProceduralSky::~ProceduralSky() { sky_thread = NULL; } VS::get_singleton()->free(sky); - VS::get_singleton()->free(texture); + if (texture.is_valid()) { + VS::get_singleton()->free(texture); + } } diff --git a/scene/resources/sky.h b/scene/resources/sky.h index 70ea9c4c18..cc5ec79a1f 100644 --- a/scene/resources/sky.h +++ b/scene/resources/sky.h @@ -69,15 +69,15 @@ class PanoramaSky : public Sky { private: RID sky; - Ref<Texture> panorama; + Ref<Texture2D> panorama; protected: static void _bind_methods(); virtual void _radiance_changed(); public: - void set_panorama(const Ref<Texture> &p_panorama); - Ref<Texture> get_panorama() const; + void set_panorama(const Ref<Texture2D> &p_panorama); + Ref<Texture2D> get_panorama() const; virtual RID get_rid() const; diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 9408d1aa71..1766b531d5 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -118,7 +118,7 @@ StyleBox::StyleBox() { } } -void StyleBoxTexture::set_texture(Ref<Texture> p_texture) { +void StyleBoxTexture::set_texture(Ref<Texture2D> p_texture) { if (texture == p_texture) return; @@ -133,12 +133,12 @@ void StyleBoxTexture::set_texture(Ref<Texture> p_texture) { _change_notify("texture"); } -Ref<Texture> StyleBoxTexture::get_texture() const { +Ref<Texture2D> StyleBoxTexture::get_texture() const { return texture; } -void StyleBoxTexture::set_normal_map(Ref<Texture> p_normal_map) { +void StyleBoxTexture::set_normal_map(Ref<Texture2D> p_normal_map) { if (normal_map == p_normal_map) return; @@ -146,7 +146,7 @@ void StyleBoxTexture::set_normal_map(Ref<Texture> p_normal_map) { emit_changed(); } -Ref<Texture> StyleBoxTexture::get_normal_map() const { +Ref<Texture2D> StyleBoxTexture::get_normal_map() const { return normal_map; } @@ -335,8 +335,8 @@ void StyleBoxTexture::_bind_methods() { ADD_SIGNAL(MethodInfo("texture_changed")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_normal_map", "get_normal_map"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normal_map", "get_normal_map"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect"); ADD_GROUP("Margin", "margin_"); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_margin_size", "get_margin_size", MARGIN_LEFT); diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index 3e0fffdcd9..1aa1a00c55 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -92,8 +92,8 @@ private: float expand_margin[4]; float margin[4]; Rect2 region_rect; - Ref<Texture> texture; - Ref<Texture> normal_map; + Ref<Texture2D> texture; + Ref<Texture2D> normal_map; bool draw_center; Color modulate; AxisStretchMode axis_h; @@ -115,11 +115,11 @@ public: void set_region_rect(const Rect2 &p_region_rect); Rect2 get_region_rect() const; - void set_texture(Ref<Texture> p_texture); - Ref<Texture> get_texture() const; + void set_texture(Ref<Texture2D> p_texture); + Ref<Texture2D> get_texture() const; - void set_normal_map(Ref<Texture> p_normal_map); - Ref<Texture> get_normal_map() const; + void set_normal_map(Ref<Texture2D> p_normal_map); + Ref<Texture2D> get_normal_map() const; void set_draw_center(bool p_enabled); bool is_draw_center_enabled() const; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index b7805b7e38..e28eaeb5f7 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -38,31 +38,31 @@ #include "scene/resources/bit_map.h" #include "servers/camera/camera_feed.h" -Size2 Texture::get_size() const { +Size2 Texture2D::get_size() const { return Size2(get_width(), get_height()); } -bool Texture::is_pixel_opaque(int p_x, int p_y) const { +bool Texture2D::is_pixel_opaque(int p_x, int p_y) const { return true; } -void Texture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { +void Texture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const { RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose, normal_rid); } -void Texture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { +void Texture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const { RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose, normal_rid); } -void Texture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map, bool p_clip_uv) const { +void Texture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const { RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose, normal_rid, p_clip_uv); } -bool Texture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const { +bool Texture2D::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const { r_rect = p_rect; r_src_rect = p_src_rect; @@ -70,34 +70,21 @@ bool Texture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect return true; } -void Texture::_bind_methods() { +void Texture2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_width"), &Texture::get_width); - ClassDB::bind_method(D_METHOD("get_height"), &Texture::get_height); - ClassDB::bind_method(D_METHOD("get_size"), &Texture::get_size); - ClassDB::bind_method(D_METHOD("has_alpha"), &Texture::has_alpha); - ClassDB::bind_method(D_METHOD("set_flags", "flags"), &Texture::set_flags); - ClassDB::bind_method(D_METHOD("get_flags"), &Texture::get_flags); - ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose", "normal_map"), &Texture::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map"), &Texture::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &Texture::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true)); - ClassDB::bind_method(D_METHOD("get_data"), &Texture::get_data); + ClassDB::bind_method(D_METHOD("get_width"), &Texture2D::get_width); + ClassDB::bind_method(D_METHOD("get_height"), &Texture2D::get_height); + ClassDB::bind_method(D_METHOD("get_size"), &Texture2D::get_size); + ClassDB::bind_method(D_METHOD("has_alpha"), &Texture2D::has_alpha); + ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose", "normal_map"), &Texture2D::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map"), &Texture2D::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &Texture2D::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("get_data"), &Texture2D::get_data); - ADD_GROUP("Flags", ""); - ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic Linear,Convert to Linear,Mirrored Repeat,Video Surface"), "set_flags", "get_flags"); ADD_GROUP("", ""); - - BIND_ENUM_CONSTANT(FLAGS_DEFAULT); - BIND_ENUM_CONSTANT(FLAG_MIPMAPS); - BIND_ENUM_CONSTANT(FLAG_REPEAT); - BIND_ENUM_CONSTANT(FLAG_FILTER); - BIND_ENUM_CONSTANT(FLAG_ANISOTROPIC_FILTER); - BIND_ENUM_CONSTANT(FLAG_CONVERT_TO_LINEAR); - BIND_ENUM_CONSTANT(FLAG_MIRRORED_REPEAT); - BIND_ENUM_CONSTANT(FLAG_VIDEO_SURFACE); } -Texture::Texture() { +Texture2D::Texture2D() { } ///////////////////// @@ -108,12 +95,11 @@ void ImageTexture::reload_from_file() { if (!path.is_resource_file()) return; - uint32_t flags = get_flags(); Ref<Image> img; img.instance(); if (ImageLoader::load_image(path, img) == OK) { - create_from_image(img, flags); + create_from_image(img); } else { Resource::reload_from_file(); _change_notify(); @@ -124,19 +110,12 @@ void ImageTexture::reload_from_file() { bool ImageTexture::_set(const StringName &p_name, const Variant &p_value) { if (p_name == "image") - create_from_image(p_value, flags); - else if (p_name == "flags") - if (w * h == 0) - flags = p_value; - else - set_flags(p_value); + create_from_image(p_value); else if (p_name == "size") { Size2 s = p_value; w = s.width; h = s.height; - VisualServer::get_singleton()->texture_set_size_override(texture, w, h, 0); - } else if (p_name == "_data") { - _set_data(p_value); + VisualServer::get_singleton()->texture_set_size_override(texture, w, h); } else return false; @@ -145,12 +124,8 @@ bool ImageTexture::_set(const StringName &p_name, const Variant &p_value) { bool ImageTexture::_get(const StringName &p_name, Variant &r_ret) const { - if (p_name == "image_data") { - - } else if (p_name == "image") + if (p_name == "image") r_ret = get_data(); - else if (p_name == "flags") - r_ret = flags; else if (p_name == "size") r_ret = Size2(w, h); else @@ -161,7 +136,6 @@ bool ImageTexture::_get(const StringName &p_name, Variant &r_ret) const { void ImageTexture::_get_property_list(List<PropertyInfo> *p_list) const { - p_list->push_back(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic,sRGB,Mirrored Repeat")); p_list->push_back(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT)); p_list->push_back(PropertyInfo(Variant::VECTOR2, "size", PROPERTY_HINT_NONE, "")); } @@ -178,79 +152,51 @@ void ImageTexture::_reload_hook(const RID &p_hook) { ERR_FAIL_COND_MSG(err != OK, "Cannot load image from path '" + path + "'."); - VisualServer::get_singleton()->texture_set_data(texture, img); + RID new_texture = VisualServer::get_singleton()->texture_2d_create(img); + VisualServer::get_singleton()->texture_replace(texture, new_texture); _change_notify(); emit_changed(); } -void ImageTexture::create(int p_width, int p_height, Image::Format p_format, uint32_t p_flags) { - - flags = p_flags; - VisualServer::get_singleton()->texture_allocate(texture, p_width, p_height, 0, p_format, VS::TEXTURE_TYPE_2D, p_flags); - format = p_format; - w = p_width; - h = p_height; - _change_notify(); - emit_changed(); -} -void ImageTexture::create_from_image(const Ref<Image> &p_image, uint32_t p_flags) { +void ImageTexture::create_from_image(const Ref<Image> &p_image) { ERR_FAIL_COND(p_image.is_null()); - flags = p_flags; w = p_image->get_width(); h = p_image->get_height(); format = p_image->get_format(); + mipmaps = p_image->has_mipmaps(); - VisualServer::get_singleton()->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, p_flags); - VisualServer::get_singleton()->texture_set_data(texture, p_image); + if (texture.is_null()) { + texture = VisualServer::get_singleton()->texture_2d_create(p_image); + } else { + RID new_texture = VisualServer::get_singleton()->texture_2d_create(p_image); + VisualServer::get_singleton()->texture_replace(texture, new_texture); + } _change_notify(); emit_changed(); image_stored = true; } -void ImageTexture::set_flags(uint32_t p_flags) { - - if (flags == p_flags) - return; - - flags = p_flags; - if (w == 0 || h == 0) { - return; //uninitialized, do not set to texture - } - VisualServer::get_singleton()->texture_set_flags(texture, p_flags); - _change_notify("flags"); - emit_changed(); -} - -uint32_t ImageTexture::get_flags() const { - - return ImageTexture::flags; -} - Image::Format ImageTexture::get_format() const { return format; } -#ifndef DISABLE_DEPRECATED -Error ImageTexture::load(const String &p_path) { - WARN_DEPRECATED; - Ref<Image> img; - img.instance(); - Error err = img->load(p_path); - if (err == OK) { - create_from_image(img); - } - return err; -} -#endif -void ImageTexture::set_data(const Ref<Image> &p_image) { +void ImageTexture::update(const Ref<Image> &p_image, bool p_immediate) { ERR_FAIL_COND(p_image.is_null()); + ERR_FAIL_COND(texture.is_null()); + ERR_FAIL_COND(p_image->get_width() != w || p_image->get_height() != h); + ERR_FAIL_COND(p_image->get_format() != format); + ERR_FAIL_COND(mipmaps != p_image->get_format()); - VisualServer::get_singleton()->texture_set_data(texture, p_image); + if (p_immediate) { + VisualServer::get_singleton()->texture_2d_update_immediate(texture, p_image); + } else { + VisualServer::get_singleton()->texture_2d_update(texture, p_image); + } _change_notify(); emit_changed(); @@ -267,7 +213,7 @@ void ImageTexture::_resource_path_changed() { Ref<Image> ImageTexture::get_data() const { if (image_stored) { - return VisualServer::get_singleton()->texture_get_data(texture); + return VisualServer::get_singleton()->texture_2d_get(texture); } else { return Ref<Image>(); } @@ -285,6 +231,10 @@ int ImageTexture::get_height() const { RID ImageTexture::get_rid() const { + if (texture.is_null()) { + //we are in trouble, create something temporary + texture = VisualServer::get_singleton()->texture_2d_placeholder_create(); + } return texture; } @@ -293,21 +243,21 @@ bool ImageTexture::has_alpha() const { return (format == Image::FORMAT_LA8 || format == Image::FORMAT_RGBA8); } -void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { +void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const { if ((w | h) == 0) return; RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid); } -void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { +void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const { if ((w | h) == 0) return; RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid); } -void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map, bool p_clip_uv) const { +void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const { if ((w | h) == 0) return; @@ -357,7 +307,7 @@ void ImageTexture::set_size_override(const Size2 &p_size) { w = s.x; if (s.y != 0) h = s.y; - VisualServer::get_singleton()->texture_set_size_override(texture, w, h, 0); + VisualServer::get_singleton()->texture_set_size_override(texture, w, h); } void ImageTexture::set_path(const String &p_path, bool p_take_over) { @@ -369,79 +319,29 @@ void ImageTexture::set_path(const String &p_path, bool p_take_over) { Resource::set_path(p_path, p_take_over); } -void ImageTexture::set_storage(Storage p_storage) { - - storage = p_storage; -} - -ImageTexture::Storage ImageTexture::get_storage() const { - - return storage; -} - -void ImageTexture::set_lossy_storage_quality(float p_lossy_storage_quality) { - - lossy_storage_quality = p_lossy_storage_quality; -} - -float ImageTexture::get_lossy_storage_quality() const { - - return lossy_storage_quality; -} - -void ImageTexture::_set_data(Dictionary p_data) { - - Ref<Image> img = p_data["image"]; - ERR_FAIL_COND(!img.is_valid()); - uint32_t flags = p_data["flags"]; - - create_from_image(img, flags); - - set_storage(Storage(p_data["storage"].operator int())); - set_lossy_storage_quality(p_data["lossy_quality"]); - - set_size_override(p_data["size"]); -}; - void ImageTexture::_bind_methods() { - ClassDB::bind_method(D_METHOD("create", "width", "height", "format", "flags"), &ImageTexture::create, DEFVAL(FLAGS_DEFAULT)); - ClassDB::bind_method(D_METHOD("create_from_image", "image", "flags"), &ImageTexture::create_from_image, DEFVAL(FLAGS_DEFAULT)); + ClassDB::bind_method(D_METHOD("create_from_image", "image"), &ImageTexture::create_from_image); ClassDB::bind_method(D_METHOD("get_format"), &ImageTexture::get_format); -#ifndef DISABLE_DEPRECATED - ClassDB::bind_method(D_METHOD("load", "path"), &ImageTexture::load); -#endif - ClassDB::bind_method(D_METHOD("set_data", "image"), &ImageTexture::set_data); - ClassDB::bind_method(D_METHOD("set_storage", "mode"), &ImageTexture::set_storage); - ClassDB::bind_method(D_METHOD("get_storage"), &ImageTexture::get_storage); - ClassDB::bind_method(D_METHOD("set_lossy_storage_quality", "quality"), &ImageTexture::set_lossy_storage_quality); - ClassDB::bind_method(D_METHOD("get_lossy_storage_quality"), &ImageTexture::get_lossy_storage_quality); + ClassDB::bind_method(D_METHOD("update", "image", "immediate"), &ImageTexture::update, DEFVAL(false)); ClassDB::bind_method(D_METHOD("set_size_override", "size"), &ImageTexture::set_size_override); ClassDB::bind_method(D_METHOD("_reload_hook", "rid"), &ImageTexture::_reload_hook); - - ADD_PROPERTY(PropertyInfo(Variant::INT, "storage", PROPERTY_HINT_ENUM, "Uncompressed,Compress Lossy,Compress Lossless"), "set_storage", "get_storage"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "lossy_quality", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_lossy_storage_quality", "get_lossy_storage_quality"); - - BIND_ENUM_CONSTANT(STORAGE_RAW); - BIND_ENUM_CONSTANT(STORAGE_COMPRESS_LOSSY); - BIND_ENUM_CONSTANT(STORAGE_COMPRESS_LOSSLESS); } ImageTexture::ImageTexture() { w = h = 0; - flags = FLAGS_DEFAULT; - texture = VisualServer::get_singleton()->texture_create(); - storage = STORAGE_RAW; - lossy_storage_quality = 0.7; image_stored = false; + mipmaps = false; format = Image::FORMAT_L8; } ImageTexture::~ImageTexture() { - VisualServer::get_singleton()->free(texture); + if (texture.is_valid()) { + VisualServer::get_singleton()->free(texture); + } } ////////////////////////////////////////// @@ -463,12 +363,12 @@ void StreamTexture::_requested_3d(void *p_ud) { request_3d_callback(stex); } -void StreamTexture::_requested_srgb(void *p_ud) { +void StreamTexture::_requested_roughness(void *p_ud, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_roughness_channel) { StreamTexture *st = (StreamTexture *)p_ud; Ref<StreamTexture> stex(st); - ERR_FAIL_COND(!request_srgb_callback); - request_srgb_callback(stex); + ERR_FAIL_COND(!request_roughness_callback); + request_roughness_callback(stex, p_normal_path, p_roughness_channel); } void StreamTexture::_requested_normal(void *p_ud) { @@ -480,19 +380,15 @@ void StreamTexture::_requested_normal(void *p_ud) { } StreamTexture::TextureFormatRequestCallback StreamTexture::request_3d_callback = NULL; -StreamTexture::TextureFormatRequestCallback StreamTexture::request_srgb_callback = NULL; +StreamTexture::TextureFormatRoughnessRequestCallback StreamTexture::request_roughness_callback = NULL; StreamTexture::TextureFormatRequestCallback StreamTexture::request_normal_callback = NULL; -uint32_t StreamTexture::get_flags() const { - - return flags; -} Image::Format StreamTexture::get_format() const { return format; } -Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_custom, int &th_custom, int &flags, Ref<Image> &image, int p_size_limit) { +Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_custom, int &th_custom, Ref<Image> &image, int p_size_limit) { alpha_cache.unref(); @@ -513,15 +409,9 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_ th = f->get_16(); th_custom = f->get_16(); - flags = f->get_32(); //texture flags! + f->get_32(); //texture flags (ignore, no longer supported) uint32_t df = f->get_32(); //data format - /* - print_line("width: " + itos(tw)); - print_line("height: " + itos(th)); - print_line("flags: " + itos(flags)); - print_line("df: " + itos(df)); - */ #ifdef TOOLS_ENABLED if (request_3d_callback && df & FORMAT_BIT_DETECT_3D) { @@ -532,15 +422,15 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_ VS::get_singleton()->texture_set_detect_3d_callback(texture, NULL, NULL); } - if (request_srgb_callback && df & FORMAT_BIT_DETECT_SRGB) { + if (request_roughness_callback && df & FORMAT_BIT_DETECT_ROUGNESS) { //print_line("request detect srgb at " + p_path); - VS::get_singleton()->texture_set_detect_srgb_callback(texture, _requested_srgb, this); + VS::get_singleton()->texture_set_detect_roughness_callback(texture, _requested_roughness, this); } else { //print_line("not requesting detect srgb at " + p_path); - VS::get_singleton()->texture_set_detect_srgb_callback(texture, NULL, NULL); + VS::get_singleton()->texture_set_detect_roughness_callback(texture, NULL, NULL); } - if (request_srgb_callback && df & FORMAT_BIT_DETECT_NORMAL) { + if (request_normal_callback && df & FORMAT_BIT_DETECT_NORMAL) { //print_line("request detect srgb at " + p_path); VS::get_singleton()->texture_set_detect_normal_callback(texture, _requested_normal, this); } else { @@ -716,10 +606,10 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_ Error StreamTexture::load(const String &p_path) { - int lw, lh, lwc, lhc, lflags; + int lw, lh, lwc, lhc; Ref<Image> image; image.instance(); - Error err = _load_data(p_path, lw, lh, lwc, lhc, lflags, image); + Error err = _load_data(p_path, lw, lh, lwc, lhc, image); if (err) return err; @@ -727,16 +617,18 @@ Error StreamTexture::load(const String &p_path) { //temporarily set path if no path set for resource, helps find errors VisualServer::get_singleton()->texture_set_path(texture, p_path); } - VS::get_singleton()->texture_allocate(texture, image->get_width(), image->get_height(), 0, image->get_format(), VS::TEXTURE_TYPE_2D, lflags); - VS::get_singleton()->texture_set_data(texture, image); - if (lwc || lhc) { - VS::get_singleton()->texture_set_size_override(texture, lwc, lhc, 0); + if (texture.is_valid()) { + RID new_texture = VS::get_singleton()->texture_2d_create(image); + VS::get_singleton()->texture_replace(texture, new_texture); } else { + texture = VS::get_singleton()->texture_2d_create(image); + } + if (lwc || lhc) { + VS::get_singleton()->texture_set_size_override(texture, lwc, lhc); } w = lwc ? lwc : lw; h = lhc ? lhc : lh; - flags = lflags; path_to_file = p_path; format = image->get_format(); @@ -759,24 +651,27 @@ int StreamTexture::get_height() const { } RID StreamTexture::get_rid() const { + if (!texture.is_valid()) { + texture = VS::get_singleton()->texture_2d_placeholder_create(); + } return texture; } -void StreamTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { +void StreamTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const { if ((w | h) == 0) return; RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid); } -void StreamTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { +void StreamTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const { if ((w | h) == 0) return; RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid); } -void StreamTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map, bool p_clip_uv) const { +void StreamTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const { if ((w | h) == 0) return; @@ -791,7 +686,11 @@ bool StreamTexture::has_alpha() const { Ref<Image> StreamTexture::get_data() const { - return VS::get_singleton()->texture_get_data(texture); + if (texture.is_valid()) { + return VS::get_singleton()->texture_2d_get(texture); + } else { + return Ref<Image>(); + } } bool StreamTexture::is_pixel_opaque(int p_x, int p_y) const { @@ -829,12 +728,6 @@ bool StreamTexture::is_pixel_opaque(int p_x, int p_y) const { return true; } -void StreamTexture::set_flags(uint32_t p_flags) { - flags = p_flags; - VS::get_singleton()->texture_set_flags(texture, flags); - _change_notify("flags"); - emit_changed(); -} void StreamTexture::reload_from_file() { @@ -851,9 +744,6 @@ void StreamTexture::reload_from_file() { } void StreamTexture::_validate_property(PropertyInfo &property) const { - if (property.name == "flags") { - property.usage = PROPERTY_USAGE_NOEDITOR; - } } void StreamTexture::_bind_methods() { @@ -867,16 +757,15 @@ void StreamTexture::_bind_methods() { StreamTexture::StreamTexture() { format = Image::FORMAT_MAX; - flags = 0; w = 0; h = 0; - - texture = VS::get_singleton()->texture_create(); } StreamTexture::~StreamTexture() { - VS::get_singleton()->free(texture); + if (texture.is_valid()) { + VS::get_singleton()->free(texture); + } } RES ResourceFormatLoaderStreamTexture::load(const String &p_path, const String &p_original_path, Error *r_error) { @@ -944,21 +833,7 @@ bool AtlasTexture::has_alpha() const { return false; } -void AtlasTexture::set_flags(uint32_t p_flags) { - - if (atlas.is_valid()) - atlas->set_flags(p_flags); -} - -uint32_t AtlasTexture::get_flags() const { - - if (atlas.is_valid()) - return atlas->get_flags(); - - return 0; -} - -void AtlasTexture::set_atlas(const Ref<Texture> &p_atlas) { +void AtlasTexture::set_atlas(const Ref<Texture2D> &p_atlas) { ERR_FAIL_COND(p_atlas == this); if (atlas == p_atlas) @@ -967,7 +842,7 @@ void AtlasTexture::set_atlas(const Ref<Texture> &p_atlas) { emit_changed(); _change_notify("atlas"); } -Ref<Texture> AtlasTexture::get_atlas() const { +Ref<Texture2D> AtlasTexture::get_atlas() const { return atlas; } @@ -1026,13 +901,13 @@ void AtlasTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_filter_clip", "enable"), &AtlasTexture::set_filter_clip); ClassDB::bind_method(D_METHOD("has_filter_clip"), &AtlasTexture::has_filter_clip); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "atlas", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_atlas", "get_atlas"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "atlas", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_atlas", "get_atlas"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region"), "set_region", "get_region"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "margin"), "set_margin", "get_margin"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filter_clip"), "set_filter_clip", "has_filter_clip"); } -void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { +void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const { if (!atlas.is_valid()) return; @@ -1051,7 +926,7 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(p_pos + margin.position, rc.size), atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, filter_clip); } -void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { +void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const { if (!atlas.is_valid()) return; @@ -1072,7 +947,7 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, filter_clip); } -void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map, bool p_clip_uv) const { +void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const { //this might not necessarily work well if using a rect, needs to be fixed properly if (!atlas.is_valid()) @@ -1157,13 +1032,6 @@ bool MeshTexture::has_alpha() const { return false; } -void MeshTexture::set_flags(uint32_t p_flags) { -} - -uint32_t MeshTexture::get_flags() const { - return 0; -} - void MeshTexture::set_mesh(const Ref<Mesh> &p_mesh) { mesh = p_mesh; } @@ -1180,15 +1048,15 @@ Size2 MeshTexture::get_image_size() const { return size; } -void MeshTexture::set_base_texture(const Ref<Texture> &p_texture) { +void MeshTexture::set_base_texture(const Ref<Texture2D> &p_texture) { base_texture = p_texture; } -Ref<Texture> MeshTexture::get_base_texture() const { +Ref<Texture2D> MeshTexture::get_base_texture() const { return base_texture; } -void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { +void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const { if (mesh.is_null() || base_texture.is_null()) { return; @@ -1202,7 +1070,7 @@ void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_mo RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid); } -void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { +void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const { if (mesh.is_null() || base_texture.is_null()) { return; } @@ -1224,7 +1092,7 @@ void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid); } -void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map, bool p_clip_uv) const { +void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const { if (mesh.is_null() || base_texture.is_null()) { return; @@ -1266,7 +1134,7 @@ void MeshTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("get_base_texture"), &MeshTexture::get_base_texture); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "base_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_base_texture", "get_base_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "base_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_base_texture", "get_base_texture"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "image_size", PROPERTY_HINT_RANGE, "0,16384,1"), "set_image_size", "get_image_size"); } @@ -1298,22 +1166,7 @@ bool LargeTexture::has_alpha() const { return false; } -void LargeTexture::set_flags(uint32_t p_flags) { - - for (int i = 0; i < pieces.size(); i++) { - pieces.write[i].texture->set_flags(p_flags); - } -} - -uint32_t LargeTexture::get_flags() const { - - if (pieces.size()) - return pieces[0].texture->get_flags(); - - return 0; -} - -int LargeTexture::add_piece(const Point2 &p_offset, const Ref<Texture> &p_texture) { +int LargeTexture::add_piece(const Point2 &p_offset, const Ref<Texture2D> &p_texture) { ERR_FAIL_COND_V(p_texture.is_null(), -1); Piece p; @@ -1330,7 +1183,7 @@ void LargeTexture::set_piece_offset(int p_idx, const Point2 &p_offset) { pieces.write[p_idx].offset = p_offset; }; -void LargeTexture::set_piece_texture(int p_idx, const Ref<Texture> &p_texture) { +void LargeTexture::set_piece_texture(int p_idx, const Ref<Texture2D> &p_texture) { ERR_FAIL_COND(p_texture == this); ERR_FAIL_COND(p_texture.is_null()); @@ -1378,9 +1231,9 @@ Vector2 LargeTexture::get_piece_offset(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, pieces.size(), Vector2()); return pieces[p_idx].offset; } -Ref<Texture> LargeTexture::get_piece_texture(int p_idx) const { +Ref<Texture2D> LargeTexture::get_piece_texture(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, pieces.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_idx, pieces.size(), Ref<Texture2D>()); return pieces[p_idx].texture; } Ref<Image> LargeTexture::to_image() const { @@ -1413,7 +1266,7 @@ void LargeTexture::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data"); } -void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { +void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const { for (int i = 0; i < pieces.size(); i++) { @@ -1422,7 +1275,7 @@ void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m } } -void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const { +void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const { //tiling not supported for this if (size.x == 0 || size.y == 0) @@ -1436,7 +1289,7 @@ void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile pieces[i].texture->draw_rect(p_canvas_item, Rect2(pieces[i].offset * scale + p_rect.position, pieces[i].texture->get_size() * scale), false, p_modulate, p_transpose, p_normal_map); } } -void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map, bool p_clip_uv) const { +void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const { //tiling not supported for this if (p_src_rect.size.x == 0 || p_src_rect.size.y == 0) @@ -1479,211 +1332,7 @@ bool LargeTexture::is_pixel_opaque(int p_x, int p_y) const { LargeTexture::LargeTexture() { } -/////////////////////////////////////////////// - -void CubeMap::set_flags(uint32_t p_flags) { - - flags = p_flags; - if (_is_valid()) - VS::get_singleton()->texture_set_flags(cubemap, flags); -} - -uint32_t CubeMap::get_flags() const { - - return flags; -} - -void CubeMap::set_side(Side p_side, const Ref<Image> &p_image) { - - ERR_FAIL_COND(p_image.is_null()); - ERR_FAIL_COND(p_image->empty()); - ERR_FAIL_INDEX(p_side, 6); - - if (!_is_valid()) { - format = p_image->get_format(); - w = p_image->get_width(); - h = p_image->get_height(); - VS::get_singleton()->texture_allocate(cubemap, w, h, 0, p_image->get_format(), VS::TEXTURE_TYPE_CUBEMAP, flags); - } - - VS::get_singleton()->texture_set_data(cubemap, p_image, VS::CubeMapSide(p_side)); - valid[p_side] = true; -} - -Ref<Image> CubeMap::get_side(Side p_side) const { - - ERR_FAIL_INDEX_V(p_side, 6, Ref<Image>()); - if (!valid[p_side]) - return Ref<Image>(); - return VS::get_singleton()->texture_get_data(cubemap, VS::CubeMapSide(p_side)); -} - -Image::Format CubeMap::get_format() const { - - return format; -} -int CubeMap::get_width() const { - - return w; -} -int CubeMap::get_height() const { - - return h; -} - -RID CubeMap::get_rid() const { - - return cubemap; -} - -void CubeMap::set_storage(Storage p_storage) { - - storage = p_storage; -} - -CubeMap::Storage CubeMap::get_storage() const { - - return storage; -} - -void CubeMap::set_lossy_storage_quality(float p_lossy_storage_quality) { - - lossy_storage_quality = p_lossy_storage_quality; -} - -float CubeMap::get_lossy_storage_quality() const { - - return lossy_storage_quality; -} - -void CubeMap::set_path(const String &p_path, bool p_take_over) { - - if (cubemap.is_valid()) { - VisualServer::get_singleton()->texture_set_path(cubemap, p_path); - } - - Resource::set_path(p_path, p_take_over); -} - -bool CubeMap::_set(const StringName &p_name, const Variant &p_value) { - - if (p_name == "side/left") { - set_side(SIDE_LEFT, p_value); - } else if (p_name == "side/right") { - set_side(SIDE_RIGHT, p_value); - } else if (p_name == "side/bottom") { - set_side(SIDE_BOTTOM, p_value); - } else if (p_name == "side/top") { - set_side(SIDE_TOP, p_value); - } else if (p_name == "side/front") { - set_side(SIDE_FRONT, p_value); - } else if (p_name == "side/back") { - set_side(SIDE_BACK, p_value); - } else if (p_name == "storage") { - storage = Storage(p_value.operator int()); - } else if (p_name == "lossy_quality") { - lossy_storage_quality = p_value; - } else - return false; - - return true; -} - -bool CubeMap::_get(const StringName &p_name, Variant &r_ret) const { - - if (p_name == "side/left") { - r_ret = get_side(SIDE_LEFT); - } else if (p_name == "side/right") { - r_ret = get_side(SIDE_RIGHT); - } else if (p_name == "side/bottom") { - r_ret = get_side(SIDE_BOTTOM); - } else if (p_name == "side/top") { - r_ret = get_side(SIDE_TOP); - } else if (p_name == "side/front") { - r_ret = get_side(SIDE_FRONT); - } else if (p_name == "side/back") { - r_ret = get_side(SIDE_BACK); - } else if (p_name == "storage") { - r_ret = storage; - } else if (p_name == "lossy_quality") { - r_ret = lossy_storage_quality; - } else - return false; - - return true; -} - -void CubeMap::_get_property_list(List<PropertyInfo> *p_list) const { - - p_list->push_back(PropertyInfo(Variant::OBJECT, "side/left", PROPERTY_HINT_RESOURCE_TYPE, "Image")); - p_list->push_back(PropertyInfo(Variant::OBJECT, "side/right", PROPERTY_HINT_RESOURCE_TYPE, "Image")); - p_list->push_back(PropertyInfo(Variant::OBJECT, "side/bottom", PROPERTY_HINT_RESOURCE_TYPE, "Image")); - p_list->push_back(PropertyInfo(Variant::OBJECT, "side/top", PROPERTY_HINT_RESOURCE_TYPE, "Image")); - p_list->push_back(PropertyInfo(Variant::OBJECT, "side/front", PROPERTY_HINT_RESOURCE_TYPE, "Image")); - p_list->push_back(PropertyInfo(Variant::OBJECT, "side/back", PROPERTY_HINT_RESOURCE_TYPE, "Image")); -} - -void CubeMap::_bind_methods() { - - ClassDB::bind_method(D_METHOD("get_width"), &CubeMap::get_width); - ClassDB::bind_method(D_METHOD("get_height"), &CubeMap::get_height); - ClassDB::bind_method(D_METHOD("set_flags", "flags"), &CubeMap::set_flags); - ClassDB::bind_method(D_METHOD("get_flags"), &CubeMap::get_flags); - ClassDB::bind_method(D_METHOD("set_side", "side", "image"), &CubeMap::set_side); - ClassDB::bind_method(D_METHOD("get_side", "side"), &CubeMap::get_side); - ClassDB::bind_method(D_METHOD("set_storage", "mode"), &CubeMap::set_storage); - ClassDB::bind_method(D_METHOD("get_storage"), &CubeMap::get_storage); - ClassDB::bind_method(D_METHOD("set_lossy_storage_quality", "quality"), &CubeMap::set_lossy_storage_quality); - ClassDB::bind_method(D_METHOD("get_lossy_storage_quality"), &CubeMap::get_lossy_storage_quality); - - ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter"), "set_flags", "get_flags"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "storage_mode", PROPERTY_HINT_ENUM, "Raw,Lossy Compressed,Lossless Compressed"), "set_storage", "get_storage"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "lossy_storage_quality"), "set_lossy_storage_quality", "get_lossy_storage_quality"); - - BIND_ENUM_CONSTANT(STORAGE_RAW); - BIND_ENUM_CONSTANT(STORAGE_COMPRESS_LOSSY); - BIND_ENUM_CONSTANT(STORAGE_COMPRESS_LOSSLESS); - - BIND_ENUM_CONSTANT(SIDE_LEFT); - BIND_ENUM_CONSTANT(SIDE_RIGHT); - BIND_ENUM_CONSTANT(SIDE_BOTTOM); - BIND_ENUM_CONSTANT(SIDE_TOP); - BIND_ENUM_CONSTANT(SIDE_FRONT); - BIND_ENUM_CONSTANT(SIDE_BACK); - - BIND_ENUM_CONSTANT(FLAG_MIPMAPS); - BIND_ENUM_CONSTANT(FLAG_REPEAT); - BIND_ENUM_CONSTANT(FLAG_FILTER); - BIND_ENUM_CONSTANT(FLAGS_DEFAULT); -} - -CubeMap::CubeMap() { - - w = h = 0; - flags = FLAGS_DEFAULT; - for (int i = 0; i < 6; i++) - valid[i] = false; - cubemap = VisualServer::get_singleton()->texture_create(); - storage = STORAGE_RAW; - lossy_storage_quality = 0.7; - format = Image::FORMAT_BPTC_RGBA; -} - -CubeMap::~CubeMap() { - - VisualServer::get_singleton()->free(cubemap); -} - -/* BIND_ENUM(CubeMapSize); - BIND_ENUM_CONSTANT( FLAG_CUBEMAP ); - BIND_ENUM_CONSTANT( CUBEMAP_LEFT ); - BIND_ENUM_CONSTANT( CUBEMAP_RIGHT ); - BIND_ENUM_CONSTANT( CUBEMAP_BOTTOM ); - BIND_ENUM_CONSTANT( CUBEMAP_TOP ); - BIND_ENUM_CONSTANT( CUBEMAP_FRONT ); - BIND_ENUM_CONSTANT( CUBEMAP_BACK ); -*/ -/////////////////////////// +/////////////////// void CurveTexture::_bind_methods() { @@ -1761,8 +1410,12 @@ void CurveTexture::_update() { Ref<Image> image = memnew(Image(_width, 1, false, Image::FORMAT_RF, data)); - VS::get_singleton()->texture_allocate(_texture, _width, 1, 0, Image::FORMAT_RF, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_FILTER); - VS::get_singleton()->texture_set_data(_texture, image); + if (_texture.is_valid()) { + RID new_texture = VS::get_singleton()->texture_2d_create(image); + VS::get_singleton()->texture_replace(_texture, new_texture); + } else { + _texture = VS::get_singleton()->texture_2d_create(image); + } emit_changed(); } @@ -1774,15 +1427,19 @@ Ref<Curve> CurveTexture::get_curve() const { RID CurveTexture::get_rid() const { + if (!_texture.is_valid()) { + _texture = VS::get_singleton()->texture_2d_placeholder_create(); + } return _texture; } CurveTexture::CurveTexture() { _width = 2048; - _texture = VS::get_singleton()->texture_create(); } CurveTexture::~CurveTexture() { - VS::get_singleton()->free(_texture); + if (_texture.is_valid()) { + VS::get_singleton()->free(_texture); + } } ////////////////// @@ -1796,12 +1453,13 @@ GradientTexture::GradientTexture() { update_pending = false; width = 2048; - texture = VS::get_singleton()->texture_create(); _queue_update(); } GradientTexture::~GradientTexture() { - VS::get_singleton()->free(texture); + if (texture.is_valid()) { + VS::get_singleton()->free(texture); + } } void GradientTexture::_bind_methods() { @@ -1871,8 +1529,12 @@ void GradientTexture::_update() { Ref<Image> image = memnew(Image(width, 1, false, Image::FORMAT_RGBA8, data)); - VS::get_singleton()->texture_allocate(texture, width, 1, 0, Image::FORMAT_RGBA8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_FILTER); - VS::get_singleton()->texture_set_data(texture, image); + if (texture.is_valid()) { + RID new_texture = VS::get_singleton()->texture_2d_create(image); + VS::get_singleton()->texture_replace(texture, new_texture); + } else { + texture = VS::get_singleton()->texture_2d_create(image); + } emit_changed(); } @@ -1888,7 +1550,10 @@ int GradientTexture::get_width() const { } Ref<Image> GradientTexture::get_data() const { - return VisualServer::get_singleton()->texture_get_data(texture); + if (!texture.is_valid()) { + return Ref<Image>(); + } + return VisualServer::get_singleton()->texture_2d_get(texture); } ////////////////////////////////////// @@ -1898,10 +1563,10 @@ void ProxyTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_base", "base"), &ProxyTexture::set_base); ClassDB::bind_method(D_METHOD("get_base"), &ProxyTexture::get_base); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "base", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_base", "get_base"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "base", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_base", "get_base"); } -void ProxyTexture::set_base(const Ref<Texture> &p_texture) { +void ProxyTexture::set_base(const Ref<Texture2D> &p_texture) { ERR_FAIL_COND(p_texture == this); base = p_texture; @@ -1912,7 +1577,7 @@ void ProxyTexture::set_base(const Ref<Texture> &p_texture) { } } -Ref<Texture> ProxyTexture::get_base() const { +Ref<Texture2D> ProxyTexture::get_base() const { return base; } @@ -1941,24 +1606,14 @@ bool ProxyTexture::has_alpha() const { return false; } -void ProxyTexture::set_flags(uint32_t p_flags) { -} - -uint32_t ProxyTexture::get_flags() const { - - if (base.is_valid()) - return base->get_flags(); - return 0; -} - ProxyTexture::ProxyTexture() { - proxy = VS::get_singleton()->texture_create(); + //proxy = VS::get_singleton()->texture_create(); } ProxyTexture::~ProxyTexture() { - VS::get_singleton()->free(proxy); + //VS::get_singleton()->free(proxy); } ////////////////////////////////////////////// @@ -2018,7 +1673,7 @@ int AnimatedTexture::get_frames() const { return frame_count; } -void AnimatedTexture::set_frame_texture(int p_frame, const Ref<Texture> &p_texture) { +void AnimatedTexture::set_frame_texture(int p_frame, const Ref<Texture2D> &p_texture) { ERR_FAIL_COND(p_texture == this); ERR_FAIL_INDEX(p_frame, MAX_FRAMES); @@ -2027,8 +1682,8 @@ void AnimatedTexture::set_frame_texture(int p_frame, const Ref<Texture> &p_textu frames[p_frame].texture = p_texture; } -Ref<Texture> AnimatedTexture::get_frame_texture(int p_frame) const { - ERR_FAIL_INDEX_V(p_frame, MAX_FRAMES, Ref<Texture>()); +Ref<Texture2D> AnimatedTexture::get_frame_texture(int p_frame) const { + ERR_FAIL_INDEX_V(p_frame, MAX_FRAMES, Ref<Texture2D>()); RWLockRead r(rw_lock); @@ -2113,19 +1768,6 @@ bool AnimatedTexture::is_pixel_opaque(int p_x, int p_y) const { return true; } -void AnimatedTexture::set_flags(uint32_t p_flags) { -} -uint32_t AnimatedTexture::get_flags() const { - - RWLockRead r(rw_lock); - - if (!frames[current_frame].texture.is_valid()) { - return 0; - } - - return frames[current_frame].texture->get_flags(); -} - void AnimatedTexture::_validate_property(PropertyInfo &property) const { String prop = property.name; @@ -2156,7 +1798,7 @@ void AnimatedTexture::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "fps", PROPERTY_HINT_RANGE, "0,1024,0.1"), "set_fps", "get_fps"); for (int i = 0; i < MAX_FRAMES; i++) { - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "frame_" + itos(i) + "/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_frame_texture", "get_frame_texture", i); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "frame_" + itos(i) + "/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_frame_texture", "get_frame_texture", i); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "frame_" + itos(i) + "/delay_sec", PROPERTY_HINT_RANGE, "0.0,16.0,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_frame_delay", "get_frame_delay", i); } @@ -2164,7 +1806,7 @@ void AnimatedTexture::_bind_methods() { } AnimatedTexture::AnimatedTexture() { - proxy = VS::get_singleton()->texture_create(); + //proxy = VS::get_singleton()->texture_create(); VisualServer::get_singleton()->texture_set_force_redraw_if_visible(proxy, true); time = 0; frame_count = 1; @@ -2188,18 +1830,6 @@ AnimatedTexture::~AnimatedTexture() { } /////////////////////////////// -void TextureLayered::set_flags(uint32_t p_flags) { - flags = p_flags; - - if (texture.is_valid()) { - VS::get_singleton()->texture_set_flags(texture, flags); - } -} - -uint32_t TextureLayered::get_flags() const { - return flags; -} - Image::Format TextureLayered::get_format() const { return format; } @@ -2212,82 +1842,93 @@ uint32_t TextureLayered::get_height() const { return height; } -uint32_t TextureLayered::get_depth() const { - return depth; +uint32_t TextureLayered::get_layers() const { + return layers; } -void TextureLayered::_set_data(const Dictionary &p_data) { - ERR_FAIL_COND(!p_data.has("width")); - ERR_FAIL_COND(!p_data.has("height")); - ERR_FAIL_COND(!p_data.has("depth")); - ERR_FAIL_COND(!p_data.has("format")); - ERR_FAIL_COND(!p_data.has("flags")); - ERR_FAIL_COND(!p_data.has("layers")); - int w = p_data["width"]; - int h = p_data["height"]; - int d = p_data["depth"]; - Image::Format format = Image::Format(int(p_data["format"])); - int flags = p_data["flags"]; - Array layers = p_data["layers"]; - ERR_FAIL_COND(layers.size() != d); +Error TextureLayered::_create_from_images(const Array &p_images) { + Vector<Ref<Image> > images; + for (int i = 0; i < p_images.size(); i++) { + Ref<Image> img = p_images[i]; + ERR_FAIL_COND_V(img.is_null(), ERR_INVALID_PARAMETER); + images.push_back(img); + } - create(w, h, d, format, flags); + return create_from_images(images); +} - for (int i = 0; i < layers.size(); i++) { - Ref<Image> img = layers[i]; - ERR_CONTINUE(!img.is_valid()); - ERR_CONTINUE(img->get_format() != format); - ERR_CONTINUE(img->get_width() != w); - ERR_CONTINUE(img->get_height() != h); - set_layer_data(img, i); +Array TextureLayered::_get_images() const { + Array images; + for (int i = 0; i < layers; i++) { + images.push_back(get_layer_data(i)); } + return images; } -Dictionary TextureLayered::_get_data() const { - Dictionary d; - d["width"] = width; - d["height"] = height; - d["depth"] = depth; - d["flags"] = flags; - d["format"] = format; +Error TextureLayered::create_from_images(Vector<Ref<Image> > p_images) { - Array layers; - for (int i = 0; i < depth; i++) { - layers.push_back(get_layer_data(i)); + int new_layers = p_images.size(); + ERR_FAIL_COND_V(new_layers == 0, ERR_INVALID_PARAMETER); + if (layered_type == VS::TEXTURE_LAYERED_CUBEMAP) { + ERR_FAIL_COND_V_MSG(new_layers != 6, ERR_INVALID_PARAMETER, + "Cubemaps require exactly 6 layers"); + } else if (layered_type == VS::TEXTURE_LAYERED_CUBEMAP_ARRAY) { + ERR_FAIL_COND_V_MSG((new_layers % 6) != 0, ERR_INVALID_PARAMETER, + "Cubemap array layers must be a multiple of 6"); } - d["layers"] = layers; - return d; -} -void TextureLayered::create(uint32_t p_width, uint32_t p_height, uint32_t p_depth, Image::Format p_format, uint32_t p_flags) { - VS::get_singleton()->texture_allocate(texture, p_width, p_height, p_depth, p_format, is_3d ? VS::TEXTURE_TYPE_3D : VS::TEXTURE_TYPE_2D_ARRAY, p_flags); + ERR_FAIL_COND_V(p_images[0].is_null() || p_images[0]->empty(), ERR_INVALID_PARAMETER); - width = p_width; - height = p_height; - depth = p_depth; - format = p_format; - flags = p_flags; -} + Image::Format new_format = p_images[0]->get_format(); + int new_width = p_images[0]->get_width(); + int new_height = p_images[0]->get_height(); + bool new_mipmaps = p_images[0]->has_mipmaps(); -void TextureLayered::set_layer_data(const Ref<Image> &p_image, int p_layer) { - ERR_FAIL_COND(!texture.is_valid()); - ERR_FAIL_COND(!p_image.is_valid()); - VS::get_singleton()->texture_set_data(texture, p_image, p_layer); -} + for (int i = 1; i < p_images.size(); i++) { + ERR_FAIL_COND_V_MSG(p_images[i]->get_format() != new_format, ERR_INVALID_PARAMETER, + "All images must share the same format"); + ERR_FAIL_COND_V_MSG(p_images[i]->get_width() != new_width || p_images[i]->get_height() != new_height, ERR_INVALID_PARAMETER, + "All images must share the same dimensions"); + ERR_FAIL_COND_V_MSG(p_images[i]->has_mipmaps() != new_mipmaps, ERR_INVALID_PARAMETER, + "All images must share the usage of mipmaps"); + } -Ref<Image> TextureLayered::get_layer_data(int p_layer) const { + if (texture.is_valid()) { + RID new_texture = VS::get_singleton()->texture_2d_layered_create(p_images, layered_type); + ERR_FAIL_COND_V(!new_texture.is_valid(), ERR_CANT_CREATE); + VS::get_singleton()->texture_replace(texture, new_texture); + } else { + texture = VS::get_singleton()->texture_2d_layered_create(p_images, layered_type); + ERR_FAIL_COND_V(!texture.is_valid(), ERR_CANT_CREATE); + } - ERR_FAIL_COND_V(!texture.is_valid(), Ref<Image>()); - return VS::get_singleton()->texture_get_data(texture, p_layer); + format = new_format; + width = new_width; + height = new_height; + layers = new_layers; + mipmaps = new_mipmaps; + return OK; } -void TextureLayered::set_data_partial(const Ref<Image> &p_image, int p_x_ofs, int p_y_ofs, int p_z, int p_mipmap) { - ERR_FAIL_COND(!texture.is_valid()); - ERR_FAIL_COND(!p_image.is_valid()); - VS::get_singleton()->texture_set_data_partial(texture, p_image, 0, 0, p_image->get_width(), p_image->get_height(), p_x_ofs, p_y_ofs, p_mipmap, p_z); +void TextureLayered::update_layer(const Ref<Image> &p_image, int p_layer) { + ERR_FAIL_COND(texture.is_valid()); + ERR_FAIL_COND(p_image.is_null()); + ERR_FAIL_COND(p_image->get_format() != format); + ERR_FAIL_COND(p_image->get_width() != width || p_image->get_height() != height); + ERR_FAIL_INDEX(p_layer, layers); + ERR_FAIL_COND(p_image->has_mipmaps() != mipmaps); + VS::get_singleton()->texture_2d_update(texture, p_image, p_layer); +} + +Ref<Image> TextureLayered::get_layer_data(int p_layer) const { + ERR_FAIL_INDEX_V(p_layer, layers, Ref<Image>()); + return VS::get_singleton()->texture_2d_layer_get(texture, p_layer); } RID TextureLayered::get_rid() const { + if (texture.is_null()) { + texture = VS::get_singleton()->texture_2d_layered_placeholder_create(); + } return texture; } @@ -2300,42 +1941,29 @@ void TextureLayered::set_path(const String &p_path, bool p_take_over) { } void TextureLayered::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_flags", "flags"), &TextureLayered::set_flags); - ClassDB::bind_method(D_METHOD("get_flags"), &TextureLayered::get_flags); ClassDB::bind_method(D_METHOD("get_format"), &TextureLayered::get_format); ClassDB::bind_method(D_METHOD("get_width"), &TextureLayered::get_width); ClassDB::bind_method(D_METHOD("get_height"), &TextureLayered::get_height); - ClassDB::bind_method(D_METHOD("get_depth"), &TextureLayered::get_depth); + ClassDB::bind_method(D_METHOD("get_layers"), &TextureLayered::get_layers); - ClassDB::bind_method(D_METHOD("create", "width", "height", "depth", "format", "flags"), &TextureLayered::create, DEFVAL(FLAGS_DEFAULT)); - ClassDB::bind_method(D_METHOD("set_layer_data", "image", "layer"), &TextureLayered::set_layer_data); + ClassDB::bind_method(D_METHOD("create_from_images", "images"), &TextureLayered::_create_from_images); + ClassDB::bind_method(D_METHOD("update_layer", "image", "layer"), &TextureLayered::update_layer); ClassDB::bind_method(D_METHOD("get_layer_data", "layer"), &TextureLayered::get_layer_data); - ClassDB::bind_method(D_METHOD("set_data_partial", "image", "x_offset", "y_offset", "layer", "mipmap"), &TextureLayered::set_data_partial, DEFVAL(0)); - - ClassDB::bind_method(D_METHOD("_set_data", "data"), &TextureLayered::_set_data); - ClassDB::bind_method(D_METHOD("_get_data"), &TextureLayered::_get_data); - ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter"), "set_flags", "get_flags"); - ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_data", "_get_data"); + ClassDB::bind_method(D_METHOD("_get_images"), &TextureLayered::_get_images); - BIND_ENUM_CONSTANT(FLAG_MIPMAPS); - BIND_ENUM_CONSTANT(FLAG_REPEAT); - BIND_ENUM_CONSTANT(FLAG_FILTER); - BIND_ENUM_CONSTANT(FLAGS_DEFAULT); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_images", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_INTERNAL), "create_from_images", "_get_images"); } -TextureLayered::TextureLayered(bool p_3d) { - is_3d = p_3d; +TextureLayered::TextureLayered(VisualServer::TextureLayeredType p_layered_type) { + layered_type = p_layered_type; format = Image::FORMAT_MAX; - flags = FLAGS_DEFAULT; width = 0; height = 0; - depth = 0; - - texture = VS::get_singleton()->texture_create(); + layers = 0; } TextureLayered::~TextureLayered() { @@ -2351,15 +1979,19 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String } Ref<TextureLayered> lt; - Ref<Texture3D> tex3d; - Ref<TextureArray> texarr; - - if (p_path.ends_with("tex3d")) { - tex3d.instance(); - lt = tex3d; - } else if (p_path.ends_with("texarr")) { - texarr.instance(); - lt = texarr; + + if (p_path.ends_with("cube")) { + Ref<Cubemap> cube; + cube.instance(); + lt = cube; + } else if (p_path.ends_with("cubearr")) { + Ref<CubemapArray> cubearr; + cubearr.instance(); + lt = cubearr; + } else if (p_path.ends_with("tex2darr")) { + Ref<Texture2DArray> t2darr; + t2darr.instance(); + lt = t2darr; } else { ERR_FAIL_V_MSG(RES(), "Unrecognized layered texture extension."); } @@ -2367,21 +1999,18 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String FileAccess *f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V_MSG(!f, RES(), "Cannot open file '" + p_path + "'."); - uint8_t header[5] = { 0, 0, 0, 0, 0 }; - f->get_buffer(header, 4); + char header[5] = { 0, 0, 0, 0, 0 }; + f->get_buffer((uint8_t *)header, 4); - if (header[0] == 'G' && header[1] == 'D' && header[2] == '3' && header[3] == 'T') { - if (tex3d.is_null()) { - f->close(); - memdelete(f); - ERR_FAIL_COND_V(tex3d.is_null(), RES()); - } - } else if (header[0] == 'G' && header[1] == 'D' && header[2] == 'A' && header[3] == 'T') { - if (texarr.is_null()) { - f->close(); - memdelete(f); - ERR_FAIL_COND_V(texarr.is_null(), RES()); + if (String(header) != "GDLT") { + f->close(); + memdelete(f); + if (r_error) { + *r_error = ERR_FILE_CORRUPT; } + // FIXME: It's bogus that we fail in both branches. Seen while rebasing + // vulkan branch on master branch. + ERR_FAIL_V_MSG(RES(), "Unrecognized layered texture."); } else { f->close(); @@ -2392,12 +2021,11 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String int tw = f->get_32(); int th = f->get_32(); int td = f->get_32(); - int flags = f->get_32(); //texture flags! + bool use_mipmaps = f->get_32() != 0; //texture flags (deprecated) Image::Format format = Image::Format(f->get_32()); uint32_t compression = f->get_32(); // 0 - lossless (PNG), 1 - vram, 2 - uncompressed - lt->create(tw, th, td, format, flags); - + Vector<Ref<Image> > images; for (int layer = 0; layer < td; layer++) { Ref<Image> image; @@ -2470,8 +2098,8 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String } else { //look for regular format - bool mipmaps = (flags & Texture::FLAG_MIPMAPS); - int total_size = Image::get_image_data_size(tw, th, format, mipmaps); + + int total_size = Image::get_image_data_size(tw, th, format, use_mipmaps); PoolVector<uint8_t> img_data; img_data.resize(total_size); @@ -2489,35 +2117,47 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String } } - image->create(tw, th, mipmaps, format, img_data); + image->create(tw, th, use_mipmaps, format, img_data); } - lt->set_layer_data(image, layer); + images.push_back(image); } - if (r_error) - *r_error = OK; + Error err = lt->create_from_images(images); + if (err != OK) { + *r_error = err; + return RES(); + } else { + + if (r_error) + *r_error = OK; + } return lt; } void ResourceFormatLoaderTextureLayered::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("tex3d"); - p_extensions->push_back("texarr"); + p_extensions->push_back("cube"); + p_extensions->push_back("cubearr"); + p_extensions->push_back("tex2darr"); } bool ResourceFormatLoaderTextureLayered::handles_type(const String &p_type) const { - return p_type == "Texture3D" || p_type == "TextureArray"; + return p_type == "Texture2DArray" || p_type == "Cubemap" || p_type == "CubemapArray"; } String ResourceFormatLoaderTextureLayered::get_resource_type(const String &p_path) const { - if (p_path.get_extension().to_lower() == "tex3d") - return "Texture3D"; - if (p_path.get_extension().to_lower() == "texarr") - return "TextureArray"; + if (p_path.get_extension().to_lower() == "cube") + return "Cubemap"; + if (p_path.get_extension().to_lower() == "cubearr") + return "CubemapArray"; + if (p_path.get_extension().to_lower() == "tex2darr") + return "Texture2DArray"; return ""; } +/////////////////////////////// + void CameraTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_camera_feed_id", "feed_id"), &CameraTexture::set_camera_feed_id); ClassDB::bind_method(D_METHOD("get_camera_feed_id"), &CameraTexture::get_camera_feed_id); diff --git a/scene/resources/texture.h b/scene/resources/texture.h index fa698d387b..d1891566d8 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -42,26 +42,14 @@ #include "servers/camera_server.h" #include "servers/visual_server.h" -class Texture : public Resource { - - GDCLASS(Texture, Resource); - OBJ_SAVE_TYPE(Texture); // Saves derived classes with common type so they can be interchanged. +class Texture2D : public Resource { + GDCLASS(Texture2D, Resource); + OBJ_SAVE_TYPE(Texture2D); // Saves derived classes with common type so they can be interchanged. protected: static void _bind_methods(); public: - enum Flags { - FLAG_MIPMAPS = VisualServer::TEXTURE_FLAG_MIPMAPS, - FLAG_REPEAT = VisualServer::TEXTURE_FLAG_REPEAT, - FLAG_FILTER = VisualServer::TEXTURE_FLAG_FILTER, - FLAG_ANISOTROPIC_FILTER = VisualServer::TEXTURE_FLAG_ANISOTROPIC_FILTER, - FLAG_CONVERT_TO_LINEAR = VisualServer::TEXTURE_FLAG_CONVERT_TO_LINEAR, - FLAG_VIDEO_SURFACE = VisualServer::TEXTURE_FLAG_USED_FOR_STREAMING, - FLAGS_DEFAULT = FLAG_MIPMAPS | FLAG_REPEAT | FLAG_FILTER, - FLAG_MIRRORED_REPEAT = VisualServer::TEXTURE_FLAG_MIRRORED_REPEAT - }; - virtual int get_width() const = 0; virtual int get_height() const = 0; virtual Size2 get_size() const; @@ -71,43 +59,28 @@ public: virtual bool has_alpha() const = 0; - virtual void set_flags(uint32_t p_flags) = 0; - virtual uint32_t get_flags() const = 0; - - virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()) const; - 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 Ref<Texture> &p_normal_map = Ref<Texture>()) const; - 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, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true) const; + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const; + 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 Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const; + 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, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = true) const; virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const; virtual Ref<Image> get_data() const { return Ref<Image>(); } - Texture(); + Texture2D(); }; -VARIANT_ENUM_CAST(Texture::Flags); - class BitMap; -class ImageTexture : public Texture { +class ImageTexture : public Texture2D { - GDCLASS(ImageTexture, Texture); + GDCLASS(ImageTexture, Texture2D); RES_BASE_EXTENSION("tex"); -public: - enum Storage { - STORAGE_RAW, - STORAGE_COMPRESS_LOSSY, - STORAGE_COMPRESS_LOSSLESS - }; - -private: - RID texture; + mutable RID texture; Image::Format format; - uint32_t flags; + bool mipmaps; int w, h; - Storage storage; Size2 size_override; - float lossy_storage_quality; mutable Ref<BitMap> alpha_cache; bool image_stored; @@ -122,19 +95,12 @@ protected: virtual void _resource_path_changed(); static void _bind_methods(); - void _set_data(Dictionary p_data); - public: - void create(int p_width, int p_height, Image::Format p_format, uint32_t p_flags = FLAGS_DEFAULT); - void create_from_image(const Ref<Image> &p_image, uint32_t p_flags = FLAGS_DEFAULT); + void create_from_image(const Ref<Image> &p_image); - void set_flags(uint32_t p_flags); - uint32_t get_flags() const; Image::Format get_format() const; -#ifndef DISABLE_DEPRECATED - Error load(const String &p_path); -#endif - void set_data(const Ref<Image> &p_image); + + void update(const Ref<Image> &p_image, bool p_immediate = false); Ref<Image> get_data() const; int get_width() const; @@ -143,17 +109,12 @@ public: virtual RID get_rid() const; bool has_alpha() const; - virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()) const; - 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 Ref<Texture> &p_normal_map = Ref<Texture>()) const; - 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, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true) const; - void set_storage(Storage p_storage); - Storage get_storage() const; + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const; + 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 Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const; + 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, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = true) const; bool is_pixel_opaque(int p_x, int p_y) const; - void set_lossy_storage_quality(float p_lossy_storage_quality); - float get_lossy_storage_quality() const; - void set_size_override(const Size2 &p_size); virtual void set_path(const String &p_path, bool p_take_over = false); @@ -162,9 +123,9 @@ public: ~ImageTexture(); }; -class StreamTexture : public Texture { +class StreamTexture : public Texture2D { - GDCLASS(StreamTexture, Texture); + GDCLASS(StreamTexture, Texture2D); public: enum DataFormat { @@ -180,23 +141,23 @@ public: FORMAT_BIT_STREAM = 1 << 22, FORMAT_BIT_HAS_MIPMAPS = 1 << 23, FORMAT_BIT_DETECT_3D = 1 << 24, - FORMAT_BIT_DETECT_SRGB = 1 << 25, + //FORMAT_BIT_DETECT_SRGB = 1 << 25, FORMAT_BIT_DETECT_NORMAL = 1 << 26, + FORMAT_BIT_DETECT_ROUGNESS = 1 << 27, }; private: - Error _load_data(const String &p_path, int &tw, int &th, int &tw_custom, int &th_custom, int &flags, Ref<Image> &image, int p_size_limit = 0); + Error _load_data(const String &p_path, int &tw, int &th, int &tw_custom, int &th_custom, Ref<Image> &image, int p_size_limit = 0); String path_to_file; - RID texture; + mutable RID texture; Image::Format format; - uint32_t flags; int w, h; mutable Ref<BitMap> alpha_cache; virtual void reload_from_file(); static void _requested_3d(void *p_ud); - static void _requested_srgb(void *p_ud); + static void _requested_roughness(void *p_ud, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_roughness_channel); static void _requested_normal(void *p_ud); protected: @@ -205,12 +166,12 @@ protected: public: typedef void (*TextureFormatRequestCallback)(const Ref<StreamTexture> &); + typedef void (*TextureFormatRoughnessRequestCallback)(const Ref<StreamTexture> &, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_roughness_channel); static TextureFormatRequestCallback request_3d_callback; - static TextureFormatRequestCallback request_srgb_callback; + static TextureFormatRoughnessRequestCallback request_roughness_callback; static TextureFormatRequestCallback request_normal_callback; - uint32_t get_flags() const; Image::Format get_format() const; Error load(const String &p_path); String get_load_path() const; @@ -221,12 +182,11 @@ public: virtual void set_path(const String &p_path, bool p_take_over); - virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()) const; - 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 Ref<Texture> &p_normal_map = Ref<Texture>()) const; - 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, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true) const; + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const; + 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 Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const; + 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, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = true) const; virtual bool has_alpha() const; - virtual void set_flags(uint32_t p_flags); bool is_pixel_opaque(int p_x, int p_y) const; virtual Ref<Image> get_data() const; @@ -243,15 +203,13 @@ public: virtual String get_resource_type(const String &p_path) const; }; -VARIANT_ENUM_CAST(ImageTexture::Storage); - -class AtlasTexture : public Texture { +class AtlasTexture : public Texture2D { - GDCLASS(AtlasTexture, Texture); + GDCLASS(AtlasTexture, Texture2D); RES_BASE_EXTENSION("atlastex"); protected: - Ref<Texture> atlas; + Ref<Texture2D> atlas; Rect2 region; Rect2 margin; bool filter_clip; @@ -265,11 +223,8 @@ public: virtual bool has_alpha() const; - virtual void set_flags(uint32_t p_flags); - virtual uint32_t get_flags() const; - - void set_atlas(const Ref<Texture> &p_atlas); - Ref<Texture> get_atlas() const; + void set_atlas(const Ref<Texture2D> &p_atlas); + Ref<Texture2D> get_atlas() const; void set_region(const Rect2 &p_region); Rect2 get_region() const; @@ -280,9 +235,9 @@ public: void set_filter_clip(const bool p_enable); bool has_filter_clip() const; - virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()) const; - 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 Ref<Texture> &p_normal_map = Ref<Texture>()) const; - 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, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true) const; + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const; + 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 Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const; + 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, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = true) const; virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const; bool is_pixel_opaque(int p_x, int p_y) const; @@ -292,12 +247,12 @@ public: class Mesh; -class MeshTexture : public Texture { +class MeshTexture : public Texture2D { - GDCLASS(MeshTexture, Texture); + GDCLASS(MeshTexture, Texture2D); RES_BASE_EXTENSION("meshtex"); - Ref<Texture> base_texture; + Ref<Texture2D> base_texture; Ref<Mesh> mesh; Size2i size; @@ -311,21 +266,18 @@ public: virtual bool has_alpha() const; - virtual void set_flags(uint32_t p_flags); - virtual uint32_t get_flags() const; - void set_mesh(const Ref<Mesh> &p_mesh); Ref<Mesh> get_mesh() const; void set_image_size(const Size2 &p_size); Size2 get_image_size() const; - void set_base_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_base_texture() const; + void set_base_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_base_texture() const; - virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()) const; - 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 Ref<Texture> &p_normal_map = Ref<Texture>()) const; - 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, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true) const; + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const; + 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 Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const; + 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, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = true) const; virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const; bool is_pixel_opaque(int p_x, int p_y) const; @@ -333,16 +285,16 @@ public: MeshTexture(); }; -class LargeTexture : public Texture { +class LargeTexture : public Texture2D { - GDCLASS(LargeTexture, Texture); + GDCLASS(LargeTexture, Texture2D); RES_BASE_EXTENSION("largetex"); protected: struct Piece { Point2 offset; - Ref<Texture> texture; + Ref<Texture2D> texture; }; Vector<Piece> pieces; @@ -359,179 +311,88 @@ public: virtual bool has_alpha() const; - virtual void set_flags(uint32_t p_flags); - virtual uint32_t get_flags() const; - - int add_piece(const Point2 &p_offset, const Ref<Texture> &p_texture); + int add_piece(const Point2 &p_offset, const Ref<Texture2D> &p_texture); void set_piece_offset(int p_idx, const Point2 &p_offset); - void set_piece_texture(int p_idx, const Ref<Texture> &p_texture); + void set_piece_texture(int p_idx, const Ref<Texture2D> &p_texture); void set_size(const Size2 &p_size); void clear(); int get_piece_count() const; Vector2 get_piece_offset(int p_idx) const; - Ref<Texture> get_piece_texture(int p_idx) const; + Ref<Texture2D> get_piece_texture(int p_idx) const; Ref<Image> to_image() const; - virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()) const; - 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 Ref<Texture> &p_normal_map = Ref<Texture>()) const; - 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, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true) const; + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const; + 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 Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const; + 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, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = true) const; bool is_pixel_opaque(int p_x, int p_y) const; LargeTexture(); }; -class CubeMap : public Resource { - - GDCLASS(CubeMap, Resource); - RES_BASE_EXTENSION("cubemap"); - -public: - enum Storage { - STORAGE_RAW, - STORAGE_COMPRESS_LOSSY, - STORAGE_COMPRESS_LOSSLESS - }; - - enum Side { - - SIDE_LEFT, - SIDE_RIGHT, - SIDE_BOTTOM, - SIDE_TOP, - SIDE_FRONT, - SIDE_BACK - }; - - enum Flags { - FLAG_MIPMAPS = VisualServer::TEXTURE_FLAG_MIPMAPS, - FLAG_REPEAT = VisualServer::TEXTURE_FLAG_REPEAT, - FLAG_FILTER = VisualServer::TEXTURE_FLAG_FILTER, - FLAGS_DEFAULT = FLAG_MIPMAPS | FLAG_REPEAT | FLAG_FILTER, - }; - -private: - bool valid[6]; - RID cubemap; - Image::Format format; - uint32_t flags; - int w, h; - Storage storage; - Size2 size_override; - float lossy_storage_quality; - - _FORCE_INLINE_ bool _is_valid() const { - for (int i = 0; i < 6; i++) { - if (valid[i]) return true; - } - return false; - } - -protected: - bool _set(const StringName &p_name, const Variant &p_value); - bool _get(const StringName &p_name, Variant &r_ret) const; - void _get_property_list(List<PropertyInfo> *p_list) const; - - static void _bind_methods(); - -public: - void set_flags(uint32_t p_flags); - uint32_t get_flags() const; - void set_side(Side p_side, const Ref<Image> &p_image); - Ref<Image> get_side(Side p_side) const; - - Image::Format get_format() const; - int get_width() const; - int get_height() const; - - virtual RID get_rid() const; - - void set_storage(Storage p_storage); - Storage get_storage() const; - - void set_lossy_storage_quality(float p_lossy_storage_quality); - float get_lossy_storage_quality() const; - - virtual void set_path(const String &p_path, bool p_take_over = false); - - CubeMap(); - ~CubeMap(); -}; - -VARIANT_ENUM_CAST(CubeMap::Flags) -VARIANT_ENUM_CAST(CubeMap::Side) -VARIANT_ENUM_CAST(CubeMap::Storage) - class TextureLayered : public Resource { GDCLASS(TextureLayered, Resource); -public: - enum Flags { - FLAG_MIPMAPS = VisualServer::TEXTURE_FLAG_MIPMAPS, - FLAG_REPEAT = VisualServer::TEXTURE_FLAG_REPEAT, - FLAG_FILTER = VisualServer::TEXTURE_FLAG_FILTER, - FLAG_CONVERT_TO_LINEAR = VisualServer::TEXTURE_FLAG_CONVERT_TO_LINEAR, - FLAGS_DEFAULT = FLAG_FILTER, - }; + VS::TextureLayeredType layered_type; -private: - bool is_3d; - RID texture; + mutable RID texture; Image::Format format; - uint32_t flags; int width; int height; - int depth; + int layers; + bool mipmaps; + + Error _create_from_images(const Array &p_images); - void _set_data(const Dictionary &p_data); - Dictionary _get_data() const; + Array _get_images() const; protected: static void _bind_methods(); public: - void set_flags(uint32_t p_flags); - uint32_t get_flags() const; - Image::Format get_format() const; uint32_t get_width() const; uint32_t get_height() const; - uint32_t get_depth() const; + uint32_t get_layers() const; + bool has_mipmaps() const; - void create(uint32_t p_width, uint32_t p_height, uint32_t p_depth, Image::Format p_format, uint32_t p_flags = FLAGS_DEFAULT); - void set_layer_data(const Ref<Image> &p_image, int p_layer); + Error create_from_images(Vector<Ref<Image> > p_images); + void update_layer(const Ref<Image> &p_image, int p_layer); Ref<Image> get_layer_data(int p_layer) const; - void set_data_partial(const Ref<Image> &p_image, int p_x_ofs, int p_y_ofs, int p_z, int p_mipmap = 0); virtual RID get_rid() const; virtual void set_path(const String &p_path, bool p_take_over = false); - TextureLayered(bool p_3d = false); + TextureLayered(VS::TextureLayeredType p_layered_type); ~TextureLayered(); }; -VARIANT_ENUM_CAST(TextureLayered::Flags) +class Texture2DArray : public TextureLayered { -class Texture3D : public TextureLayered { + GDCLASS(Texture2DArray, TextureLayered) +public: + Texture2DArray() : + TextureLayered(VS::TEXTURE_LAYERED_2D_ARRAY) {} +}; - GDCLASS(Texture3D, TextureLayered); +class Cubemap : public TextureLayered { + GDCLASS(Cubemap, TextureLayered); public: - Texture3D() : - TextureLayered(true) {} + Cubemap() : + TextureLayered(VS::TEXTURE_LAYERED_CUBEMAP) {} }; -class TextureArray : public TextureLayered { - - GDCLASS(TextureArray, TextureLayered); +class CubemapArray : public TextureLayered { + GDCLASS(CubemapArray, TextureLayered); public: - TextureArray() : - TextureLayered(false) {} + CubemapArray() : + TextureLayered(VS::TEXTURE_LAYERED_CUBEMAP_ARRAY) {} }; class ResourceFormatLoaderTextureLayered : public ResourceFormatLoader { @@ -548,13 +409,13 @@ public: virtual String get_resource_type(const String &p_path) const; }; -class CurveTexture : public Texture { +class CurveTexture : public Texture2D { - GDCLASS(CurveTexture, Texture); + GDCLASS(CurveTexture, Texture2D); RES_BASE_EXTENSION("curvetex") private: - RID _texture; + mutable RID _texture; Ref<Curve> _curve; int _width; @@ -577,9 +438,6 @@ public: virtual int get_height() const { return 1; } virtual bool has_alpha() const { return false; } - virtual void set_flags(uint32_t p_flags) {} - virtual uint32_t get_flags() const { return FLAG_FILTER; } - CurveTexture(); ~CurveTexture(); }; @@ -597,8 +455,8 @@ public: */ //VARIANT_ENUM_CAST( Texture::CubeMapSide ); -class GradientTexture : public Texture { - GDCLASS(GradientTexture, Texture); +class GradientTexture : public Texture2D { + GDCLASS(GradientTexture, Texture2D); public: struct Point { @@ -633,28 +491,25 @@ public: virtual int get_height() const { return 1; } virtual bool has_alpha() const { return true; } - virtual void set_flags(uint32_t p_flags) {} - virtual uint32_t get_flags() const { return FLAG_FILTER; } - virtual Ref<Image> get_data() const; GradientTexture(); virtual ~GradientTexture(); }; -class ProxyTexture : public Texture { - GDCLASS(ProxyTexture, Texture); +class ProxyTexture : public Texture2D { + GDCLASS(ProxyTexture, Texture2D); private: RID proxy; - Ref<Texture> base; + Ref<Texture2D> base; protected: static void _bind_methods(); public: - void set_base(const Ref<Texture> &p_texture); - Ref<Texture> get_base() const; + void set_base(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_base() const; virtual int get_width() const; virtual int get_height() const; @@ -662,15 +517,12 @@ public: virtual bool has_alpha() const; - virtual void set_flags(uint32_t p_flags); - virtual uint32_t get_flags() const; - ProxyTexture(); ~ProxyTexture(); }; -class AnimatedTexture : public Texture { - GDCLASS(AnimatedTexture, Texture); +class AnimatedTexture : public Texture2D { + GDCLASS(AnimatedTexture, Texture2D); //use readers writers lock for this, since its far more times read than written to RWLock *rw_lock; @@ -684,7 +536,7 @@ private: struct Frame { - Ref<Texture> texture; + Ref<Texture2D> texture; float delay_sec; Frame() { @@ -712,8 +564,8 @@ public: void set_frames(int p_frames); int get_frames() const; - void set_frame_texture(int p_frame, const Ref<Texture> &p_texture); - Ref<Texture> get_frame_texture(int p_frame) const; + void set_frame_texture(int p_frame, const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_frame_texture(int p_frame) const; void set_frame_delay(int p_frame, float p_delay_sec); float get_frame_delay(int p_frame) const; @@ -727,9 +579,6 @@ public: virtual bool has_alpha() const; - virtual void set_flags(uint32_t p_flags); - virtual uint32_t get_flags() const; - virtual Ref<Image> get_data() const; bool is_pixel_opaque(int p_x, int p_y) const; @@ -738,8 +587,8 @@ public: ~AnimatedTexture(); }; -class CameraTexture : public Texture { - GDCLASS(CameraTexture, Texture); +class CameraTexture : public Texture2D { + GDCLASS(CameraTexture, Texture2D); private: int camera_feed_id; diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 1f2fa1d60b..75903c1383 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -196,7 +196,7 @@ bool Theme::_get(const StringName &p_name, Variant &r_ret) const { if (type == "icons") { if (!has_icon(name, node_type)) - r_ret = Ref<Texture>(); + r_ret = Ref<Texture2D>(); else r_ret = get_icon(name, node_type); } else if (type == "styles") { @@ -238,7 +238,7 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { while ((key2 = icon_map[*key].next(key2))) { - list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/icons/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL)); + list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/icons/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL)); } } @@ -322,7 +322,7 @@ Ref<Font> Theme::get_default_theme_font() const { Ref<Theme> Theme::project_default_theme; Ref<Theme> Theme::default_theme; -Ref<Texture> Theme::default_icon; +Ref<Texture2D> Theme::default_icon; Ref<StyleBox> Theme::default_style; Ref<Font> Theme::default_font; @@ -346,7 +346,7 @@ void Theme::set_project_default(const Ref<Theme> &p_project_default) { project_default_theme = p_project_default; } -void Theme::set_default_icon(const Ref<Texture> &p_icon) { +void Theme::set_default_icon(const Ref<Texture2D> &p_icon) { default_icon = p_icon; } @@ -359,7 +359,7 @@ void Theme::set_default_font(const Ref<Font> &p_font) { default_font = p_font; } -void Theme::set_icon(const StringName &p_name, const StringName &p_type, const Ref<Texture> &p_icon) { +void Theme::set_icon(const StringName &p_name, const StringName &p_type, const Ref<Texture2D> &p_icon) { //ERR_FAIL_COND(p_icon.is_null()); @@ -380,7 +380,7 @@ void Theme::set_icon(const StringName &p_name, const StringName &p_type, const R emit_changed(); } } -Ref<Texture> Theme::get_icon(const StringName &p_name, const StringName &p_type) const { +Ref<Texture2D> Theme::get_icon(const StringName &p_name, const StringName &p_type) const { if (icon_map.has(p_type) && icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid()) { @@ -720,7 +720,7 @@ void Theme::clear() { while ((K = icon_map.next(K))) { const StringName *L = NULL; while ((L = icon_map[*K].next(L))) { - Ref<Texture> icon = icon_map[*K][*L]; + Ref<Texture2D> icon = icon_map[*K][*L]; if (icon.is_valid()) { icon->disconnect("changed", this, "_emit_theme_changed"); } diff --git a/scene/resources/theme.h b/scene/resources/theme.h index 4bb614b24e..e60734b144 100644 --- a/scene/resources/theme.h +++ b/scene/resources/theme.h @@ -45,7 +45,7 @@ class Theme : public Resource { void _emit_theme_changed(); - HashMap<StringName, HashMap<StringName, Ref<Texture> > > icon_map; + HashMap<StringName, HashMap<StringName, Ref<Texture2D> > > icon_map; HashMap<StringName, HashMap<StringName, Ref<StyleBox> > > style_map; HashMap<StringName, HashMap<StringName, Ref<Font> > > font_map; HashMap<StringName, HashMap<StringName, Ref<Shader> > > shader_map; @@ -67,7 +67,7 @@ protected: static Ref<Theme> project_default_theme; static Ref<Theme> default_theme; - static Ref<Texture> default_icon; + static Ref<Texture2D> default_icon; static Ref<StyleBox> default_style; static Ref<Font> default_font; @@ -82,15 +82,15 @@ public: static Ref<Theme> get_project_default(); static void set_project_default(const Ref<Theme> &p_project_default); - static void set_default_icon(const Ref<Texture> &p_icon); + static void set_default_icon(const Ref<Texture2D> &p_icon); static void set_default_style(const Ref<StyleBox> &p_style); static void set_default_font(const Ref<Font> &p_font); void set_default_theme_font(const Ref<Font> &p_default_font); Ref<Font> get_default_theme_font() const; - void set_icon(const StringName &p_name, const StringName &p_type, const Ref<Texture> &p_icon); - Ref<Texture> get_icon(const StringName &p_name, const StringName &p_type) const; + void set_icon(const StringName &p_name, const StringName &p_type, const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_icon(const StringName &p_name, const StringName &p_type) const; bool has_icon(const StringName &p_name, const StringName &p_type) const; void clear_icon(const StringName &p_name, const StringName &p_type); void get_icon_list(StringName p_type, List<StringName> *p_list) const; diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index db5037172e..7383e18473 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -326,8 +326,8 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const { int id = E->key(); String pre = itos(id) + "/"; p_list->push_back(PropertyInfo(Variant::STRING, pre + "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); - p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_NOEDITOR)); - p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_NOEDITOR)); + p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_NOEDITOR)); + p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "tex_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::COLOR, pre + "modulate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); @@ -387,7 +387,7 @@ TileSet::BitmaskMode TileSet::autotile_get_bitmask_mode(int p_id) const { return tile_map[p_id].autotile_data.bitmask_mode; } -void TileSet::tile_set_texture(int p_id, const Ref<Texture> &p_texture) { +void TileSet::tile_set_texture(int p_id, const Ref<Texture2D> &p_texture) { ERR_FAIL_COND(!tile_map.has(p_id)); tile_map[p_id].texture = p_texture; @@ -395,22 +395,22 @@ void TileSet::tile_set_texture(int p_id, const Ref<Texture> &p_texture) { _change_notify("texture"); } -Ref<Texture> TileSet::tile_get_texture(int p_id) const { +Ref<Texture2D> TileSet::tile_get_texture(int p_id) const { - ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture>()); + ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture2D>()); return tile_map[p_id].texture; } -void TileSet::tile_set_normal_map(int p_id, const Ref<Texture> &p_normal_map) { +void TileSet::tile_set_normal_map(int p_id, const Ref<Texture2D> &p_normal_map) { ERR_FAIL_COND(!tile_map.has(p_id)); tile_map[p_id].normal_map = p_normal_map; emit_changed(); } -Ref<Texture> TileSet::tile_get_normal_map(int p_id) const { +Ref<Texture2D> TileSet::tile_get_normal_map(int p_id) const { - ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture>()); + ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture2D>()); return tile_map[p_id].normal_map; } diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index eab40ce467..8b540982a4 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -114,8 +114,8 @@ private: struct TileData { String name; - Ref<Texture> texture; - Ref<Texture> normal_map; + Ref<Texture2D> texture; + Ref<Texture2D> normal_map; Vector2 offset; Rect2i region; Vector<ShapeData> shapes_data; @@ -158,11 +158,11 @@ public: void tile_set_name(int p_id, const String &p_name); String tile_get_name(int p_id) const; - void tile_set_texture(int p_id, const Ref<Texture> &p_texture); - Ref<Texture> tile_get_texture(int p_id) const; + void tile_set_texture(int p_id, const Ref<Texture2D> &p_texture); + Ref<Texture2D> tile_get_texture(int p_id) const; - void tile_set_normal_map(int p_id, const Ref<Texture> &p_normal_map); - Ref<Texture> tile_get_normal_map(int p_id) const; + void tile_set_normal_map(int p_id, const Ref<Texture2D> &p_normal_map); + Ref<Texture2D> tile_get_normal_map(int p_id) const; void tile_set_texture_offset(int p_id, const Vector2 &p_offset); Vector2 tile_get_texture_offset(int p_id) const; diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h index 444bb698ae..a9b96214c3 100644 --- a/scene/resources/video_stream.h +++ b/scene/resources/video_stream.h @@ -58,7 +58,8 @@ public: virtual void set_audio_track(int p_idx) = 0; - virtual Ref<Texture> get_texture() const = 0; + virtual Ref<Texture2D> get_texture() const = 0; + virtual void update(float p_delta) = 0; virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata) = 0; diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h index f35318e090..1ee75a4cb7 100644 --- a/scene/resources/visual_shader.h +++ b/scene/resources/visual_shader.h @@ -58,7 +58,7 @@ public: struct DefaultTextureParam { StringName name; - Ref<Texture> param; + Ref<Texture2D> param; }; private: diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 8f0e0058ea..95a8155c31 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -357,7 +357,7 @@ VisualShaderNodeTransformConstant::VisualShaderNodeTransformConstant() { ////////////// Texture String VisualShaderNodeTexture::get_caption() const { - return "Texture"; + return "Texture2D"; } int VisualShaderNodeTexture::get_input_port_count() const { @@ -649,13 +649,13 @@ VisualShaderNodeTexture::Source VisualShaderNodeTexture::get_source() const { return source; } -void VisualShaderNodeTexture::set_texture(Ref<Texture> p_value) { +void VisualShaderNodeTexture::set_texture(Ref<Texture2D> p_value) { texture = p_value; emit_changed(); } -Ref<Texture> VisualShaderNodeTexture::get_texture() const { +Ref<Texture2D> VisualShaderNodeTexture::get_texture() const { return texture; } @@ -727,7 +727,7 @@ void VisualShaderNodeTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("get_texture_type"), &VisualShaderNodeTexture::get_texture_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "source", PROPERTY_HINT_ENUM, "Texture,Screen,Texture2D,NormalMap2D,Depth,SamplerPort"), "set_source", "get_source"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_type", PROPERTY_HINT_ENUM, "Data,Color,Normalmap"), "set_texture_type", "get_texture_type"); BIND_ENUM_CONSTANT(SOURCE_TEXTURE); @@ -746,17 +746,17 @@ VisualShaderNodeTexture::VisualShaderNodeTexture() { source = SOURCE_TEXTURE; } -////////////// CubeMap +////////////// Cubemap -String VisualShaderNodeCubeMap::get_caption() const { - return "CubeMap"; +String VisualShaderNodeCubemap::get_caption() const { + return "Cubemap"; } -int VisualShaderNodeCubeMap::get_input_port_count() const { +int VisualShaderNodeCubemap::get_input_port_count() const { return 3; } -VisualShaderNodeCubeMap::PortType VisualShaderNodeCubeMap::get_input_port_type(int p_port) const { +VisualShaderNodeCubemap::PortType VisualShaderNodeCubemap::get_input_port_type(int p_port) const { switch (p_port) { case 0: return PORT_TYPE_VECTOR; @@ -769,7 +769,7 @@ VisualShaderNodeCubeMap::PortType VisualShaderNodeCubeMap::get_input_port_type(i } } -String VisualShaderNodeCubeMap::get_input_port_name(int p_port) const { +String VisualShaderNodeCubemap::get_input_port_name(int p_port) const { switch (p_port) { case 0: return "uv"; @@ -782,19 +782,19 @@ String VisualShaderNodeCubeMap::get_input_port_name(int p_port) const { } } -int VisualShaderNodeCubeMap::get_output_port_count() const { +int VisualShaderNodeCubemap::get_output_port_count() const { return 2; } -VisualShaderNodeCubeMap::PortType VisualShaderNodeCubeMap::get_output_port_type(int p_port) const { +VisualShaderNodeCubemap::PortType VisualShaderNodeCubemap::get_output_port_type(int p_port) const { return p_port == 0 ? PORT_TYPE_VECTOR : PORT_TYPE_SCALAR; } -String VisualShaderNodeCubeMap::get_output_port_name(int p_port) const { +String VisualShaderNodeCubemap::get_output_port_name(int p_port) const { return p_port == 0 ? "rgb" : "alpha"; } -Vector<VisualShader::DefaultTextureParam> VisualShaderNodeCubeMap::get_default_texture_parameters(VisualShader::Type p_type, int p_id) const { +Vector<VisualShader::DefaultTextureParam> VisualShaderNodeCubemap::get_default_texture_parameters(VisualShader::Type p_type, int p_id) const { VisualShader::DefaultTextureParam dtp; dtp.name = make_unique_id(p_type, p_id, "cube"); dtp.param = cube_map; @@ -803,7 +803,7 @@ Vector<VisualShader::DefaultTextureParam> VisualShaderNodeCubeMap::get_default_t return ret; } -String VisualShaderNodeCubeMap::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { +String VisualShaderNodeCubemap::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { if (source == SOURCE_TEXTURE) { String u = "uniform samplerCube " + make_unique_id(p_type, p_id, "cube"); @@ -817,7 +817,7 @@ String VisualShaderNodeCubeMap::generate_global(Shader::Mode p_mode, VisualShade return String(); } -String VisualShaderNodeCubeMap::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { +String VisualShaderNodeCubemap::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { String code; String id; @@ -860,44 +860,44 @@ String VisualShaderNodeCubeMap::generate_code(Shader::Mode p_mode, VisualShader: return code; } -String VisualShaderNodeCubeMap::get_input_port_default_hint(int p_port) const { +String VisualShaderNodeCubemap::get_input_port_default_hint(int p_port) const { if (p_port == 0) { return "vec3(UV, 0.0)"; } return ""; } -void VisualShaderNodeCubeMap::set_source(Source p_source) { +void VisualShaderNodeCubemap::set_source(Source p_source) { source = p_source; emit_changed(); emit_signal("editor_refresh_request"); } -VisualShaderNodeCubeMap::Source VisualShaderNodeCubeMap::get_source() const { +VisualShaderNodeCubemap::Source VisualShaderNodeCubemap::get_source() const { return source; } -void VisualShaderNodeCubeMap::set_cube_map(Ref<CubeMap> p_value) { +void VisualShaderNodeCubemap::set_cube_map(Ref<Cubemap> p_value) { cube_map = p_value; emit_changed(); } -Ref<CubeMap> VisualShaderNodeCubeMap::get_cube_map() const { +Ref<Cubemap> VisualShaderNodeCubemap::get_cube_map() const { return cube_map; } -void VisualShaderNodeCubeMap::set_texture_type(TextureType p_type) { +void VisualShaderNodeCubemap::set_texture_type(TextureType p_type) { texture_type = p_type; emit_changed(); } -VisualShaderNodeCubeMap::TextureType VisualShaderNodeCubeMap::get_texture_type() const { +VisualShaderNodeCubemap::TextureType VisualShaderNodeCubemap::get_texture_type() const { return texture_type; } -Vector<StringName> VisualShaderNodeCubeMap::get_editable_properties() const { +Vector<StringName> VisualShaderNodeCubemap::get_editable_properties() const { Vector<StringName> props; props.push_back("source"); if (source == SOURCE_TEXTURE) { @@ -907,19 +907,19 @@ Vector<StringName> VisualShaderNodeCubeMap::get_editable_properties() const { return props; } -void VisualShaderNodeCubeMap::_bind_methods() { +void VisualShaderNodeCubemap::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_source", "value"), &VisualShaderNodeCubeMap::set_source); - ClassDB::bind_method(D_METHOD("get_source"), &VisualShaderNodeCubeMap::get_source); + ClassDB::bind_method(D_METHOD("set_source", "value"), &VisualShaderNodeCubemap::set_source); + ClassDB::bind_method(D_METHOD("get_source"), &VisualShaderNodeCubemap::get_source); - ClassDB::bind_method(D_METHOD("set_cube_map", "value"), &VisualShaderNodeCubeMap::set_cube_map); - ClassDB::bind_method(D_METHOD("get_cube_map"), &VisualShaderNodeCubeMap::get_cube_map); + ClassDB::bind_method(D_METHOD("set_cube_map", "value"), &VisualShaderNodeCubemap::set_cube_map); + ClassDB::bind_method(D_METHOD("get_cube_map"), &VisualShaderNodeCubemap::get_cube_map); - ClassDB::bind_method(D_METHOD("set_texture_type", "value"), &VisualShaderNodeCubeMap::set_texture_type); - ClassDB::bind_method(D_METHOD("get_texture_type"), &VisualShaderNodeCubeMap::get_texture_type); + ClassDB::bind_method(D_METHOD("set_texture_type", "value"), &VisualShaderNodeCubemap::set_texture_type); + ClassDB::bind_method(D_METHOD("get_texture_type"), &VisualShaderNodeCubemap::get_texture_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "source", PROPERTY_HINT_ENUM, "Texture,SamplerPort"), "set_source", "get_source"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "cube_map", PROPERTY_HINT_RESOURCE_TYPE, "CubeMap"), "set_cube_map", "get_cube_map"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "cube_map", PROPERTY_HINT_RESOURCE_TYPE, "Cubemap"), "set_cube_map", "get_cube_map"); ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_type", PROPERTY_HINT_ENUM, "Data,Color,Normalmap"), "set_texture_type", "get_texture_type"); BIND_ENUM_CONSTANT(SOURCE_TEXTURE); @@ -930,7 +930,7 @@ void VisualShaderNodeCubeMap::_bind_methods() { BIND_ENUM_CONSTANT(TYPE_NORMALMAP); } -VisualShaderNodeCubeMap::VisualShaderNodeCubeMap() { +VisualShaderNodeCubemap::VisualShaderNodeCubemap() { texture_type = TYPE_DATA; source = SOURCE_TEXTURE; simple_decl = false; @@ -3552,41 +3552,41 @@ String VisualShaderNodeTextureUniformTriplanar::get_input_port_default_hint(int VisualShaderNodeTextureUniformTriplanar::VisualShaderNodeTextureUniformTriplanar() { } -////////////// CubeMap Uniform +////////////// Cubemap Uniform -String VisualShaderNodeCubeMapUniform::get_caption() const { - return "CubeMapUniform"; +String VisualShaderNodeCubemapUniform::get_caption() const { + return "CubemapUniform"; } -int VisualShaderNodeCubeMapUniform::get_output_port_count() const { +int VisualShaderNodeCubemapUniform::get_output_port_count() const { return 1; } -VisualShaderNodeCubeMapUniform::PortType VisualShaderNodeCubeMapUniform::get_output_port_type(int p_port) const { +VisualShaderNodeCubemapUniform::PortType VisualShaderNodeCubemapUniform::get_output_port_type(int p_port) const { return PORT_TYPE_SAMPLER; } -String VisualShaderNodeCubeMapUniform::get_output_port_name(int p_port) const { +String VisualShaderNodeCubemapUniform::get_output_port_name(int p_port) const { return "samplerCube"; } -int VisualShaderNodeCubeMapUniform::get_input_port_count() const { +int VisualShaderNodeCubemapUniform::get_input_port_count() const { return 0; } -VisualShaderNodeCubeMapUniform::PortType VisualShaderNodeCubeMapUniform::get_input_port_type(int p_port) const { +VisualShaderNodeCubemapUniform::PortType VisualShaderNodeCubemapUniform::get_input_port_type(int p_port) const { return PORT_TYPE_SCALAR; } -String VisualShaderNodeCubeMapUniform::get_input_port_name(int p_port) const { +String VisualShaderNodeCubemapUniform::get_input_port_name(int p_port) const { return ""; } -String VisualShaderNodeCubeMapUniform::get_input_port_default_hint(int p_port) const { +String VisualShaderNodeCubemapUniform::get_input_port_default_hint(int p_port) const { return ""; } -String VisualShaderNodeCubeMapUniform::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { +String VisualShaderNodeCubemapUniform::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { String code = "uniform samplerCube " + get_uniform_name(); switch (texture_type) { @@ -3609,11 +3609,11 @@ String VisualShaderNodeCubeMapUniform::generate_global(Shader::Mode p_mode, Visu return code; } -String VisualShaderNodeCubeMapUniform::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { +String VisualShaderNodeCubemapUniform::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { return String(); } -VisualShaderNodeCubeMapUniform::VisualShaderNodeCubeMapUniform() { +VisualShaderNodeCubemapUniform::VisualShaderNodeCubemapUniform() { } ////////////// If diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index 3d57fd0efc..85782bc509 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -191,7 +191,7 @@ public: class VisualShaderNodeTexture : public VisualShaderNode { GDCLASS(VisualShaderNodeTexture, VisualShaderNode); - Ref<Texture> texture; + Ref<Texture2D> texture; public: enum Source { @@ -236,8 +236,8 @@ public: void set_source(Source p_source); Source get_source() const; - void set_texture(Ref<Texture> p_value); - Ref<Texture> get_texture() const; + void set_texture(Ref<Texture2D> p_value); + Ref<Texture2D> get_texture() const; void set_texture_type(TextureType p_type); TextureType get_texture_type() const; @@ -254,9 +254,9 @@ VARIANT_ENUM_CAST(VisualShaderNodeTexture::Source) /////////////////////////////////////// -class VisualShaderNodeCubeMap : public VisualShaderNode { - GDCLASS(VisualShaderNodeCubeMap, VisualShaderNode); - Ref<CubeMap> cube_map; +class VisualShaderNodeCubemap : public VisualShaderNode { + GDCLASS(VisualShaderNodeCubemap, VisualShaderNode); + Ref<Cubemap> cube_map; public: enum Source { @@ -296,19 +296,19 @@ public: void set_source(Source p_source); Source get_source() const; - void set_cube_map(Ref<CubeMap> p_value); - Ref<CubeMap> get_cube_map() const; + void set_cube_map(Ref<Cubemap> p_value); + Ref<Cubemap> get_cube_map() const; void set_texture_type(TextureType p_type); TextureType get_texture_type() const; virtual Vector<StringName> get_editable_properties() const; - VisualShaderNodeCubeMap(); + VisualShaderNodeCubemap(); }; -VARIANT_ENUM_CAST(VisualShaderNodeCubeMap::TextureType) -VARIANT_ENUM_CAST(VisualShaderNodeCubeMap::Source) +VARIANT_ENUM_CAST(VisualShaderNodeCubemap::TextureType) +VARIANT_ENUM_CAST(VisualShaderNodeCubemap::Source) /////////////////////////////////////// /// OPS @@ -1514,8 +1514,8 @@ public: /////////////////////////////////////// -class VisualShaderNodeCubeMapUniform : public VisualShaderNodeTextureUniform { - GDCLASS(VisualShaderNodeCubeMapUniform, VisualShaderNodeTextureUniform); +class VisualShaderNodeCubemapUniform : public VisualShaderNodeTextureUniform { + GDCLASS(VisualShaderNodeCubemapUniform, VisualShaderNodeTextureUniform); public: virtual String get_caption() const; @@ -1532,7 +1532,7 @@ public: virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const; virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty - VisualShaderNodeCubeMapUniform(); + VisualShaderNodeCubemapUniform(); }; /////////////////////////////////////// |