diff options
287 files changed, 2832 insertions, 2543 deletions
diff --git a/drivers/SCsub b/drivers/SCsub index 3ea7f23bc4..072addc2b3 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -24,8 +24,8 @@ SConscript('winmidi/SCsub') # Graphics drivers if (env["platform"] != "server"): - SConscript('gles3/SCsub') - SConscript('gles2/SCsub') +# SConscript('gles3/SCsub') +# SConscript('gles2/SCsub') SConscript('vulkan/SCsub') SConscript('gl_context/SCsub') else: diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index 4521b9208d..ea99655cb6 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -35,7 +35,7 @@ #include "core/rid_owner.h" #include "core/self_list.h" #include "scene/resources/mesh.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "servers/visual_server.h" class RasterizerSceneDummy : public RasterizerScene { diff --git a/drivers/dummy/texture_loader_dummy.cpp b/drivers/dummy/texture_loader_dummy.cpp index 2dfc0afe78..bf51d76527 100644 --- a/drivers/dummy/texture_loader_dummy.cpp +++ b/drivers/dummy/texture_loader_dummy.cpp @@ -74,7 +74,7 @@ void ResourceFormatDummyTexture::get_recognized_extensions(List<String> *p_exten } bool ResourceFormatDummyTexture::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture"); + return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatDummyTexture::get_resource_type(const String &p_path) const { diff --git a/drivers/gles2/rasterizer_canvas_gles2.h b/drivers/gles2/rasterizer_canvas_gles2.h index f6ae6a60c0..ce8761b448 100644 --- a/drivers/gles2/rasterizer_canvas_gles2.h +++ b/drivers/gles2/rasterizer_canvas_gles2.h @@ -32,7 +32,7 @@ #define RASTERIZERCANVASGLES2_H #include "rasterizer_storage_gles2.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "shaders/canvas.glsl.gen.h" #include "shaders/lens_distorted.glsl.gen.h" diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index 9a5501f13d..3d0debc0ed 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -34,7 +34,7 @@ #include "rasterizer_canvas_gles2.h" #include "rasterizer_scene_gles2.h" #include "rasterizer_storage_gles2.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" class RasterizerGLES2 : public Rasterizer { diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index f929771c86..17f0565acf 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -1721,7 +1721,7 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn case ShaderLanguage::TYPE_USAMPLER2D: { pi.type = Variant::OBJECT; pi.hint = PROPERTY_HINT_RESOURCE_TYPE; - pi.hint_string = "Texture"; + pi.hint_string = "Texture2D"; } break; case ShaderLanguage::TYPE_SAMPLERCUBE: { diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h index a5f8f1972c..e8dde78760 100644 --- a/drivers/gles2/rasterizer_storage_gles2.h +++ b/drivers/gles2/rasterizer_storage_gles2.h @@ -33,7 +33,7 @@ #include "core/pool_vector.h" #include "core/self_list.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "servers/visual/shader_language.h" #include "shader_compiler_gles2.h" #include "shader_gles2.h" @@ -341,7 +341,7 @@ public: } }; - mutable RID_PtrOwner<Texture> texture_owner; + mutable RID_PtrOwner<Texture2D> texture_owner; Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const; diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h index 8e7a3ae873..b25fbd97f0 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.h +++ b/drivers/gles3/rasterizer_canvas_gles3.h @@ -32,7 +32,7 @@ #define RASTERIZERCANVASGLES3_H #include "rasterizer_storage_gles3.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "shaders/canvas_shadow.glsl.gen.h" #include "shaders/lens_distorted.glsl.gen.h" diff --git a/drivers/gles3/rasterizer_gles3.h b/drivers/gles3/rasterizer_gles3.h index de7c1ab7e1..6b5ce683a4 100644 --- a/drivers/gles3/rasterizer_gles3.h +++ b/drivers/gles3/rasterizer_gles3.h @@ -34,7 +34,7 @@ #include "rasterizer_canvas_gles3.h" #include "rasterizer_scene_gles3.h" #include "rasterizer_storage_gles3.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" class RasterizerGLES3 : public Rasterizer { diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 2a25c1d6cc..0113c5335d 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -2471,7 +2471,7 @@ void RasterizerStorageGLES3::shader_get_param_list(RID p_shader, List<PropertyIn pi.type = Variant::OBJECT; pi.hint = PROPERTY_HINT_RESOURCE_TYPE; - pi.hint_string = "Texture"; + pi.hint_string = "Texture2D"; } break; case ShaderLanguage::TYPE_SAMPLER2DARRAY: case ShaderLanguage::TYPE_ISAMPLER2DARRAY: diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 1953a2e809..7de19eb8a4 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -32,7 +32,7 @@ #define RASTERIZERSTORAGEGLES3_H #include "core/self_list.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "servers/visual/shader_language.h" #include "shader_compiler_gles3.h" #include "shader_gles3.h" @@ -344,7 +344,7 @@ public: } }; - mutable RID_PtrOwner<Texture> texture_owner; + mutable RID_PtrOwner<Texture2D> texture_owner; Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool &r_srgb, bool p_force_decompress) const; diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index af2760e82b..719e4af6b5 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -258,7 +258,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { draw_line(Point2(right_limit, 0), Point2(right_limit, get_size().height), linecolor); - Ref<Texture> close_icon = get_icon("Close", "EditorIcons"); + Ref<Texture2D> close_icon = get_icon("Close", "EditorIcons"); close_icon_rect.position = Vector2(get_size().width - close_icon->get_width() - hsep, hsep); close_icon_rect.size = close_icon->get_size(); @@ -290,7 +290,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { if (node) { int ofs = 0; - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(node, "Node"); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node"); h = MAX(h, icon->get_height()); @@ -391,7 +391,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { { //draw OTHER curves float scale = timeline->get_zoom_scale(); - Ref<Texture> point = get_icon("KeyValue", "EditorIcons"); + Ref<Texture2D> point = get_icon("KeyValue", "EditorIcons"); for (Map<int, Color>::Element *E = subtrack_colors.front(); E; E = E->next()) { _draw_track(E->key(), E->get()); diff --git a/editor/animation_bezier_editor.h b/editor/animation_bezier_editor.h index ef4e62231f..2be388fd57 100644 --- a/editor/animation_bezier_editor.h +++ b/editor/animation_bezier_editor.h @@ -63,9 +63,9 @@ class AnimationBezierTrackEdit : public Control { Vector<Rect2> view_rects; - Ref<Texture> bezier_icon; - Ref<Texture> bezier_handle_icon; - Ref<Texture> selected_icon; + Ref<Texture2D> bezier_icon; + Ref<Texture2D> bezier_handle_icon; + Ref<Texture2D> selected_icon; Rect2 close_icon_rect; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 2edfcced60..cc64db22cc 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1442,11 +1442,11 @@ void AnimationTimelineEdit::_anim_loop_pressed() { int AnimationTimelineEdit::get_buttons_width() const { - Ref<Texture> interp_mode = get_icon("TrackContinuous", "EditorIcons"); - Ref<Texture> interp_type = get_icon("InterpRaw", "EditorIcons"); - Ref<Texture> loop_type = get_icon("InterpWrapClamp", "EditorIcons"); - Ref<Texture> remove_icon = get_icon("Remove", "EditorIcons"); - Ref<Texture> down_icon = get_icon("select_arrow", "Tree"); + Ref<Texture2D> interp_mode = get_icon("TrackContinuous", "EditorIcons"); + Ref<Texture2D> interp_type = get_icon("InterpRaw", "EditorIcons"); + Ref<Texture2D> loop_type = get_icon("InterpWrapClamp", "EditorIcons"); + Ref<Texture2D> remove_icon = get_icon("Remove", "EditorIcons"); + Ref<Texture2D> down_icon = get_icon("select_arrow", "Tree"); int total_w = interp_mode->get_width() + interp_type->get_width() + loop_type->get_width() + remove_icon->get_width(); total_w += (down_icon->get_width() + 4 * EDSCALE) * 4; @@ -1456,7 +1456,7 @@ int AnimationTimelineEdit::get_buttons_width() const { int AnimationTimelineEdit::get_name_limit() const { - Ref<Texture> hsize_icon = get_icon("Hsize", "EditorIcons"); + Ref<Texture2D> hsize_icon = get_icon("Hsize", "EditorIcons"); int limit = MAX(name_limit, add_track->get_minimum_size().width + hsize_icon->get_width()); @@ -1504,7 +1504,7 @@ void AnimationTimelineEdit::_notification(int p_what) { if (l <= 0) l = 0.001; //avoid crashor - Ref<Texture> hsize_icon = get_icon("Hsize", "EditorIcons"); + Ref<Texture2D> hsize_icon = get_icon("Hsize", "EditorIcons"); hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height()); draw_texture(hsize_icon, hsize_rect.position); @@ -1934,7 +1934,7 @@ void AnimationTrackEdit::_notification(int p_what) { Ref<Font> font = get_font("font", "Label"); Color color = get_color("font_color", "Label"); - Ref<Texture> type_icons[6] = { + Ref<Texture2D> type_icons[6] = { get_icon("KeyValue", "EditorIcons"), get_icon("KeyXform", "EditorIcons"), get_icon("KeyCall", "EditorIcons"), @@ -1950,7 +1950,7 @@ void AnimationTrackEdit::_notification(int p_what) { { - Ref<Texture> check = animation->track_is_enabled(track) ? get_icon("checked", "CheckBox") : get_icon("unchecked", "CheckBox"); + Ref<Texture2D> check = animation->track_is_enabled(track) ? get_icon("checked", "CheckBox") : get_icon("unchecked", "CheckBox"); int ofs = in_group ? check->get_width() : 0; //not the best reference for margin but.. @@ -1958,7 +1958,7 @@ void AnimationTrackEdit::_notification(int p_what) { draw_texture(check, check_rect.position); ofs += check->get_width() + hsep; - Ref<Texture> type_icon = type_icons[animation->track_get_type(track)]; + Ref<Texture2D> type_icon = type_icons[animation->track_get_type(track)]; draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2)); ofs += type_icon->get_width() + hsep; @@ -1987,7 +1987,7 @@ void AnimationTrackEdit::_notification(int p_what) { } text_color.a *= 0.7; } else if (node) { - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(node, "Node"); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node"); draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2)); icon_cache = icon; @@ -2049,17 +2049,17 @@ void AnimationTrackEdit::_notification(int p_what) { { - Ref<Texture> wrap_icon[2] = { + Ref<Texture2D> wrap_icon[2] = { get_icon("InterpWrapClamp", "EditorIcons"), get_icon("InterpWrapLoop", "EditorIcons"), }; - Ref<Texture> interp_icon[3] = { + Ref<Texture2D> interp_icon[3] = { get_icon("InterpRaw", "EditorIcons"), get_icon("InterpLinear", "EditorIcons"), get_icon("InterpCubic", "EditorIcons") }; - Ref<Texture> cont_icon[4] = { + Ref<Texture2D> cont_icon[4] = { get_icon("TrackContinuous", "EditorIcons"), get_icon("TrackDiscrete", "EditorIcons"), get_icon("TrackTrigger", "EditorIcons"), @@ -2068,7 +2068,7 @@ void AnimationTrackEdit::_notification(int p_what) { int ofs = get_size().width - timeline->get_buttons_width(); - Ref<Texture> down_icon = get_icon("select_arrow", "Tree"); + Ref<Texture2D> down_icon = get_icon("select_arrow", "Tree"); draw_line(Point2(ofs, 0), Point2(ofs, get_size().height), linecolor, Math::round(EDSCALE)); @@ -2084,7 +2084,7 @@ void AnimationTrackEdit::_notification(int p_what) { update_mode = Animation::UPDATE_CONTINUOUS; } - Ref<Texture> update_icon = cont_icon[update_mode]; + Ref<Texture2D> update_icon = cont_icon[update_mode]; update_mode_rect.position.x = ofs; update_mode_rect.position.y = int(get_size().height - update_icon->get_height()) / 2; @@ -2105,7 +2105,7 @@ void AnimationTrackEdit::_notification(int p_what) { update_mode_rect.size.x += down_icon->get_width(); bezier_edit_rect = Rect2(); } else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) { - Ref<Texture> bezier_icon = get_icon("EditBezier", "EditorIcons"); + Ref<Texture2D> bezier_icon = get_icon("EditBezier", "EditorIcons"); update_mode_rect.size.x += down_icon->get_width(); bezier_edit_rect.position = update_mode_rect.position + (update_mode_rect.size - bezier_icon->get_size()) / 2; bezier_edit_rect.size = bezier_icon->get_size(); @@ -2126,7 +2126,7 @@ void AnimationTrackEdit::_notification(int p_what) { Animation::InterpolationType interp_mode = animation->track_get_interpolation_type(track); - Ref<Texture> icon = interp_icon[interp_mode]; + Ref<Texture2D> icon = interp_icon[interp_mode]; interp_mode_rect.position.x = ofs; interp_mode_rect.position.y = int(get_size().height - icon->get_height()) / 2; @@ -2159,7 +2159,7 @@ void AnimationTrackEdit::_notification(int p_what) { bool loop_wrap = animation->track_get_interpolation_loop_wrap(track); - Ref<Texture> icon = wrap_icon[loop_wrap ? 1 : 0]; + Ref<Texture2D> icon = wrap_icon[loop_wrap ? 1 : 0]; loop_mode_rect.position.x = ofs; loop_mode_rect.position.y = int(get_size().height - icon->get_height()) / 2; @@ -2190,7 +2190,7 @@ void AnimationTrackEdit::_notification(int p_what) { { //erase - Ref<Texture> icon = get_icon("Remove", "EditorIcons"); + Ref<Texture2D> icon = get_icon("Remove", "EditorIcons"); remove_rect.position.x = ofs + ((get_size().width - ofs) - icon->get_width()) / 2; remove_rect.position.y = int(get_size().height - icon->get_height()) / 2; @@ -2271,7 +2271,7 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool if (p_x < p_clip_left || p_x > p_clip_right) return; - Ref<Texture> icon_to_draw = p_selected ? selected_icon : type_icon; + Ref<Texture2D> icon_to_draw = p_selected ? selected_icon : type_icon; // Override type icon for invalid value keys, unless selected. if (!p_selected && animation->track_get_type(track) == Animation::TYPE_VALUE) { @@ -2335,12 +2335,12 @@ void AnimationTrackEdit::draw_bg(int p_clip_left, int p_clip_right) { void AnimationTrackEdit::draw_fg(int p_clip_left, int p_clip_right) { } -void AnimationTrackEdit::draw_texture_clipped(const Ref<Texture> &p_texture, const Vector2 &p_pos) { +void AnimationTrackEdit::draw_texture_clipped(const Ref<Texture2D> &p_texture, const Vector2 &p_pos) { draw_texture_region_clipped(p_texture, Rect2(p_pos, p_texture->get_size()), Rect2(Point2(), p_texture->get_size())); } -void AnimationTrackEdit::draw_texture_region_clipped(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_region) { +void AnimationTrackEdit::draw_texture_region_clipped(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_region) { int clip_left = timeline->get_name_limit(); int clip_right = get_size().width - timeline->get_buttons_width(); @@ -2391,7 +2391,7 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati track = p_track; update(); - Ref<Texture> type_icons[6] = { + Ref<Texture2D> type_icons[6] = { get_icon("KeyValue", "EditorIcons"), get_icon("KeyXform", "EditorIcons"), get_icon("KeyCall", "EditorIcons"), @@ -2413,7 +2413,7 @@ NodePath AnimationTrackEdit::get_path() const { Size2 AnimationTrackEdit::get_minimum_size() const { - Ref<Texture> texture = get_icon("Object", "EditorIcons"); + Ref<Texture2D> texture = get_icon("Object", "EditorIcons"); Ref<Font> font = get_font("font", "Label"); int separation = get_constant("vseparation", "ItemList"); @@ -3199,7 +3199,7 @@ void AnimationTrackEditGroup::_notification(int p_what) { } } -void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture> &p_type, const String &p_name, const NodePath &p_node) { +void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, const String &p_name, const NodePath &p_node) { icon = p_type; node_name = p_name; node = p_node; @@ -4214,7 +4214,7 @@ void AnimationTrackEditor::_update_tracks() { if (!group_sort.has(base_path)) { AnimationTrackEditGroup *g = memnew(AnimationTrackEditGroup); - Ref<Texture> icon = get_icon("Node", "EditorIcons"); + Ref<Texture2D> icon = get_icon("Node", "EditorIcons"); String name = base_path; String tooltip; if (root && root->has_node(base_path)) { @@ -5273,7 +5273,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } String text; - Ref<Texture> icon = get_icon("Node", "EditorIcons"); + Ref<Texture2D> icon = get_icon("Node", "EditorIcons"); if (node) { if (has_icon(node->get_class(), "EditorIcons")) { icon = get_icon(node->get_class(), "EditorIcons"); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 79abda2d49..c2660652d6 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -158,8 +158,8 @@ class AnimationTrackEdit : public Control { Rect2 remove_rect; Rect2 bezier_edit_rect; - Ref<Texture> type_icon; - Ref<Texture> selected_icon; + Ref<Texture2D> type_icon; + Ref<Texture2D> selected_icon; PopupMenu *menu; @@ -167,7 +167,7 @@ class AnimationTrackEdit : public Control { void _zoom_changed(); - Ref<Texture> icon_cache; + Ref<Texture2D> icon_cache; String path_cache; void _menu_selected(int p_index); @@ -208,8 +208,8 @@ public: virtual void draw_fg(int p_clip_left, int p_clip_right); //helper - void draw_texture_clipped(const Ref<Texture> &p_texture, const Vector2 &p_pos); - void draw_texture_region_clipped(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_region); + void draw_texture_clipped(const Ref<Texture2D> &p_texture, const Vector2 &p_pos); + void draw_texture_region_clipped(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_region); void draw_rect_clipped(const Rect2 &p_rect, const Color &p_color, bool p_filled = true); int get_track() const; @@ -251,7 +251,7 @@ class AnimationBezierTrackEdit; class AnimationTrackEditGroup : public Control { GDCLASS(AnimationTrackEditGroup, Control); - Ref<Texture> icon; + Ref<Texture2D> icon; String node_name; NodePath node; Node *root; @@ -264,7 +264,7 @@ protected: void _notification(int p_what); public: - void set_type_and_name(const Ref<Texture> &p_type, const String &p_name, const NodePath &p_node); + void set_type_and_name(const Ref<Texture2D> &p_type, const String &p_name, const NodePath &p_node); virtual Size2 get_minimum_size() const; void set_timeline(AnimationTimelineEdit *p_timeline); void set_root(Node *p_root); diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index bb008e621e..bcdd09987f 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -42,12 +42,12 @@ /// BOOL /// int AnimationTrackEditBool::get_key_height() const { - Ref<Texture> checked = get_icon("checked", "CheckBox"); + Ref<Texture2D> checked = get_icon("checked", "CheckBox"); return checked->get_height(); } Rect2 AnimationTrackEditBool::get_key_rect(int p_index, float p_pixels_sec) { - Ref<Texture> checked = get_icon("checked", "CheckBox"); + Ref<Texture2D> checked = get_icon("checked", "CheckBox"); return Rect2(-checked->get_width() / 2, 0, checked->get_width(), get_size().height); } @@ -58,7 +58,7 @@ bool AnimationTrackEditBool::is_key_selectable_by_distance() const { void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) { bool checked = get_animation()->track_get_key_value(get_track(), p_index); - Ref<Texture> icon = get_icon(checked ? "checked" : "unchecked", "CheckBox"); + Ref<Texture2D> icon = get_icon(checked ? "checked" : "unchecked", "CheckBox"); Vector2 ofs(p_x - icon->get_width() / 2, int(get_size().height - icon->get_height()) / 2); @@ -360,7 +360,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) { - Ref<Texture> texture = object->call("get_texture"); + Ref<Texture2D> texture = object->call("get_texture"); if (!texture.is_valid()) { return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec); } @@ -404,7 +404,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se animation = get_animation()->track_get_key_value(animation_track, animaiton_index); } - Ref<Texture> texture = sf->get_frame(animation, frame); + Ref<Texture2D> texture = sf->get_frame(animation, frame); if (!texture.is_valid()) { return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec); } @@ -434,7 +434,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in return; } - Ref<Texture> texture; + Ref<Texture2D> texture; Rect2 region; if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) { @@ -710,13 +710,13 @@ void AnimationTrackEditSubAnim::set_node(Object *p_object) { int AnimationTrackEditVolumeDB::get_key_height() const { - Ref<Texture> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); return volume_texture->get_height() * 1.2; } void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { - Ref<Texture> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; @@ -728,7 +728,7 @@ void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) { - Ref<Texture> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; int db0 = y_from + (24 / 80.0) * tex_h; @@ -763,7 +763,7 @@ void AnimationTrackEditVolumeDB::draw_key_link(int p_index, float p_pixels_sec, to_x = p_clip_right; } - Ref<Texture> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; diff --git a/editor/animation_track_editor_plugins.h b/editor/animation_track_editor_plugins.h index 4a21ca4d27..378070a45d 100644 --- a/editor/animation_track_editor_plugins.h +++ b/editor/animation_track_editor_plugins.h @@ -35,8 +35,8 @@ class AnimationTrackEditBool : public AnimationTrackEdit { GDCLASS(AnimationTrackEditBool, AnimationTrackEdit); - Ref<Texture> icon_checked; - Ref<Texture> icon_unchecked; + Ref<Texture2D> icon_checked; + Ref<Texture2D> icon_unchecked; public: virtual int get_key_height() const; diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index e05ace53da..f3da1b59b2 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -819,8 +819,8 @@ void CodeTextEditor::_complete_request() { text_editor->code_complete(entries, forced); } -Ref<Texture> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOption &p_option) { - Ref<Texture> tex; +Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOption &p_option) { + Ref<Texture2D> tex; switch (p_option.kind) { case ScriptCodeCompletionOption::KIND_CLASS: { if (has_icon(p_option.display, "EditorIcons")) { diff --git a/editor/code_editor.h b/editor/code_editor.h index fc06407166..6b733a2b3c 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -167,7 +167,7 @@ class CodeTextEditor : public VBoxContainer { void _update_font(); void _complete_request(); - Ref<Texture> _get_completion_icon(const ScriptCodeCompletionOption &p_option); + Ref<Texture2D> _get_completion_icon(const ScriptCodeCompletionOption &p_option); void _font_resize_timeout(); bool _add_font_size(int p_delta); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 1853133bc7..7e283bb27f 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -903,7 +903,7 @@ void ConnectionsDock::update_tree() { while (base) { List<MethodInfo> node_signals2; - Ref<Texture> icon; + Ref<Texture2D> icon; String name; if (!did_script) { diff --git a/editor/create_dialog.h b/editor/create_dialog.h index 94ff1b5bb2..a807e50f65 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -77,7 +77,7 @@ class CreateDialog : public ConfirmationDialog { void _confirmed(); void _text_changed(const String &p_newtext); - Ref<Texture> _get_editor_icon(const String &p_type) const; + Ref<Texture2D> _get_editor_icon(const String &p_type) const; void add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select); diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index df957611cf..46f6815f77 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -174,7 +174,7 @@ void DependencyEditor::_update_list() { TreeItem *root = tree->create_item(); - Ref<Texture> folder = get_icon("folder", "FileDialog"); + Ref<Texture2D> folder = get_icon("folder", "FileDialog"); bool broken = false; @@ -195,7 +195,7 @@ void DependencyEditor::_update_list() { } String name = path.get_file(); - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(type); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type); item->set_text(0, name); item->set_icon(0, icon); item->set_metadata(0, type); @@ -338,7 +338,7 @@ void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) { if (!found) continue; - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(efsd->get_file_type(i)); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(efsd->get_file_type(i)); owners->add_item(efsd->get_file_path(i), icon); } @@ -446,7 +446,7 @@ void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<Removed } //List this file under this dependency - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(rd.file_type); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(rd.file_type); TreeItem *file_item = owners->create_item(tree_items[rd.dependency]); file_item->set_text(0, rd.file); file_item->set_icon(0, icon); @@ -609,7 +609,7 @@ void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Ve if (report[i].get_slice_count("::") > 0) type = report[i].get_slice("::", 1); - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(type); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type); TreeItem *ti = files->create_item(root); ti->set_text(0, dep); @@ -720,7 +720,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa String type = efsd->get_file_type(i); - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(type); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type); ti->set_icon(0, icon); int ds = efsd->get_file_deps(i).size(); ti->set_text(1, itos(ds)); diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index adfffe27ba..0d9e53c71c 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -483,7 +483,7 @@ void DocData::generate(bool p_basic_types) { PropertyDoc pd; pd.name = E->get(); - pd.type = "Texture"; + pd.type = "Texture2D"; c.theme_properties.push_back(pd); } l.clear(); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 86611bd20a..783b996c4d 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -110,7 +110,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { ret = unzGoToNextFile(pkg); } - Map<String, Ref<Texture> > extension_guess; + Map<String, Ref<Texture2D> > extension_guess; { extension_guess["png"] = get_icon("ImageTexture", "EditorIcons"); extension_guess["jpg"] = get_icon("ImageTexture", "EditorIcons"); @@ -122,7 +122,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { extension_guess["vs"] = get_icon("VisualScript", "EditorIcons"); } - Ref<Texture> generic_extension = get_icon("Object", "EditorIcons"); + Ref<Texture2D> generic_extension = get_icon("Object", "EditorIcons"); unzClose(pkg); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 0a60aabd2d..594322f00d 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -144,8 +144,8 @@ void EditorAudioBus::_notification(int p_what) { if (activity_found != channel[i].prev_active) { if (activity_found) { - channel[i].vu_l->set_over_texture(Ref<Texture>()); - channel[i].vu_r->set_over_texture(Ref<Texture>()); + channel[i].vu_l->set_over_texture(Ref<Texture2D>()); + channel[i].vu_r->set_over_texture(Ref<Texture2D>()); } else { channel[i].vu_l->set_over_texture(disabled_vu); channel[i].vu_r->set_over_texture(disabled_vu); @@ -944,7 +944,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { if (!ClassDB::can_instance(E->get())) continue; - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(E->get()); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(E->get()); String name = E->get().operator String().replace("AudioEffect", ""); effect_options->add_item(name); effect_options->set_item_metadata(effect_options->get_item_count() - 1, E->get()); diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index ef6f7e458f..72098c7232 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -54,7 +54,7 @@ class EditorAudioBus : public PanelContainer { GDCLASS(EditorAudioBus, PanelContainer); - Ref<Texture> disabled_vu; + Ref<Texture2D> disabled_vu; LineEdit *track_name; MenuButton *bus_options; VSlider *slider; diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 0b43fd5ac0..d7c610f109 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -479,7 +479,7 @@ EditorPlugin *EditorData::get_editor_plugin(int p_idx) { return editor_plugins[p_idx]; } -void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture> &p_icon) { +void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) { ERR_FAIL_COND_MSG(p_script.is_null(), "It's not a reference to a valid Script object."); CustomType ct; diff --git a/editor/editor_data.h b/editor/editor_data.h index 1b21ce4451..8a6f2f63f6 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -112,7 +112,7 @@ public: String name; Ref<Script> script; - Ref<Texture> icon; + Ref<Texture2D> icon; }; struct EditedScene { @@ -178,7 +178,7 @@ public: void save_editor_global_states(); void restore_editor_global_states(); - void add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture> &p_icon); + void add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon); Object *instance_custom_type(const String &p_type, const String &p_inherits); void remove_custom_type(const String &p_type); const Map<String, Vector<CustomType> > &get_custom_types() const { return custom_types; } diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 3d8ea0b040..d661a3ec3c 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1477,7 +1477,7 @@ String EditorExportPlatformPC::get_os_name() const { return os_name; } -Ref<Texture> EditorExportPlatformPC::get_logo() const { +Ref<Texture2D> EditorExportPlatformPC::get_logo() const { return logo; } @@ -1629,7 +1629,7 @@ void EditorExportPlatformPC::set_os_name(const String &p_name) { os_name = p_name; } -void EditorExportPlatformPC::set_logo(const Ref<Texture> &p_logo) { +void EditorExportPlatformPC::set_logo(const Ref<Texture2D> &p_logo) { logo = p_logo; } diff --git a/editor/editor_export.h b/editor/editor_export.h index 577fd0cf7e..19651b2c62 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -236,7 +236,7 @@ public: virtual String get_os_name() const = 0; virtual String get_name() const = 0; - virtual Ref<Texture> get_logo() const = 0; + virtual Ref<Texture2D> get_logo() const = 0; Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = NULL); @@ -259,7 +259,7 @@ public: }; virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { return OK; } - virtual Ref<Texture> get_run_icon() const { return get_logo(); } + virtual Ref<Texture2D> get_run_icon() const { return get_logo(); } String test_etc2() const; //generic test for etc2 since most platforms use it virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0; @@ -420,7 +420,7 @@ public: virtual String get_name() const; virtual String get_os_name() const; - virtual Ref<Texture> get_logo() const; + virtual Ref<Texture2D> get_logo() const; virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const; virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const; @@ -431,7 +431,7 @@ public: void set_name(const String &p_name); void set_os_name(const String &p_name); - void set_logo(const Ref<Texture> &p_logo); + void set_logo(const Ref<Texture2D> &p_logo); void set_release_64(const String &p_file); void set_release_32(const String &p_file); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 625f46f9d3..c869768c6c 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -78,7 +78,7 @@ void EditorFileDialog::_notification(int p_what) { preview_wheel_index++; if (preview_wheel_index >= 8) preview_wheel_index = 0; - Ref<Texture> frame = get_icon("Progress" + itos(preview_wheel_index + 1), "EditorIcons"); + Ref<Texture2D> frame = get_icon("Progress" + itos(preview_wheel_index + 1), "EditorIcons"); preview->set_texture(frame); preview_wheel_timeout = 0.1; } @@ -263,7 +263,7 @@ void EditorFileDialog::_post_popup() { _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); if (is_visible_in_tree()) { - Ref<Texture> folder = get_icon("folder", "FileDialog"); + Ref<Texture2D> folder = get_icon("folder", "FileDialog"); const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); recent->clear(); @@ -295,7 +295,7 @@ void EditorFileDialog::_post_popup() { set_process_unhandled_input(true); } -void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) { +void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { if (display_mode == DISPLAY_LIST || p_preview.is_null()) return; @@ -305,12 +305,12 @@ void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture String pname = d["path"]; if (pname == p_path) { item_list->set_item_icon(i, p_preview); - item_list->set_item_tag_icon(i, Ref<Texture>()); + item_list->set_item_tag_icon(i, Ref<Texture2D>()); } } } -void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) { +void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { set_process(false); preview_waiting = false; @@ -326,7 +326,7 @@ void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture> } else { preview_vb->hide(); - preview->set_texture(Ref<Texture>()); + preview->set_texture(Ref<Texture2D>()); } } @@ -704,8 +704,8 @@ void EditorFileDialog::update_file_list() { int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); thumbnail_size *= EDSCALE; - Ref<Texture> folder_thumbnail; - Ref<Texture> file_thumbnail; + Ref<Texture2D> folder_thumbnail; + Ref<Texture2D> file_thumbnail; item_list->clear(); @@ -745,7 +745,7 @@ void EditorFileDialog::update_file_list() { dir_access->list_dir_begin(); - Ref<Texture> folder = get_icon("folder", "FileDialog"); + Ref<Texture2D> folder = get_icon("folder", "FileDialog"); const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); List<String> files; List<String> dirs; @@ -841,7 +841,7 @@ void EditorFileDialog::update_file_list() { if (get_icon_func) { - Ref<Texture> icon = get_icon_func(cdir.plus_file(files.front()->get())); + Ref<Texture2D> icon = get_icon_func(cdir.plus_file(files.front()->get())); if (display_mode == DISPLAY_THUMBNAILS) { item_list->set_item_icon(item_list->get_item_count() - 1, file_thumbnail); @@ -1215,7 +1215,7 @@ void EditorFileDialog::_update_favorites() { bool res = access == ACCESS_RESOURCES; String current = get_current_dir(); - Ref<Texture> folder_icon = get_icon("Folder", "EditorIcons"); + Ref<Texture2D> folder_icon = get_icon("Folder", "EditorIcons"); const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); favorites->clear(); diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index 6af261e8dd..8b48604b31 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -68,7 +68,7 @@ public: MODE_SAVE_FILE }; - typedef Ref<Texture> (*GetIconFunc)(const String &); + typedef Ref<Texture2D> (*GetIconFunc)(const String &); typedef void (*RegisterFunc)(EditorFileDialog *); static GetIconFunc get_icon_func; @@ -188,10 +188,10 @@ private: virtual void _post_popup(); void _save_to_recent(); - //callback function is callback(String p_path,Ref<Texture> preview,Variant udata) preview null if could not load + //callback function is callback(String p_path,Ref<Texture2D> preview,Variant udata) preview null if could not load - void _thumbnail_result(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata); - void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata); + void _thumbnail_result(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata); + void _thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata); void _request_single_thumbnail(const String &p_path); void _unhandled_input(const Ref<InputEvent> &p_event); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 556dbcbfc4..22a16ac65a 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1374,7 +1374,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { end = bbcode.length(); String image = bbcode.substr(brk_end + 1, end - brk_end - 1); - Ref<Texture> texture = ResourceLoader::load(base_path.plus_file(image), "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(base_path.plus_file(image), "Texture2D"); if (texture.is_valid()) p_rt->add_image(texture); diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 80981e8fa1..d45b66afce 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -483,7 +483,7 @@ TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray) { - Ref<Texture> icon = empty_icon; + Ref<Texture2D> icon = empty_icon; if (ui_service->has_icon(p_doc->name, "EditorIcons")) icon = ui_service->get_icon(p_doc->name, "EditorIcons"); else if (ClassDB::class_exists(p_doc->name) && ClassDB::is_parent_class(p_doc->name, "Object")) @@ -559,7 +559,7 @@ TreeItem *EditorHelpSearch::Runner::_create_theme_property_item(TreeItem *p_pare TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_type, const String &p_metatype, const String &p_tooltip) { - Ref<Texture> icon; + Ref<Texture2D> icon; String text; if (search_flags & SEARCH_SHOW_HIERARCHY) { icon = ui_service->get_icon(p_icon, "EditorIcons"); diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h index 5d089d1c24..feff96d2e5 100644 --- a/editor/editor_help_search.h +++ b/editor/editor_help_search.h @@ -116,7 +116,7 @@ class EditorHelpSearch::Runner : public Reference { String term; int search_flags; - Ref<Texture> empty_icon; + Ref<Texture2D> empty_icon; Color disabled_color; Map<String, DocData::ClassDoc>::Element *iterator_doc; diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 7c1e58862e..6d2b891dc6 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -61,12 +61,12 @@ Size2 EditorProperty::get_minimum_size() const { } if (keying) { - Ref<Texture> key = get_icon("Key", "EditorIcons"); + Ref<Texture2D> key = get_icon("Key", "EditorIcons"); ms.width += key->get_width() + get_constant("hseparator", "Tree"); } if (checkable) { - Ref<Texture> check = get_icon("checked", "CheckBox"); + Ref<Texture2D> check = get_icon("checked", "CheckBox"); ms.width += check->get_width() + get_constant("hseparation", "CheckBox") + get_constant("hseparator", "Tree"); } @@ -139,7 +139,7 @@ void EditorProperty::_notification(int p_what) { } if (keying) { - Ref<Texture> key; + Ref<Texture2D> key; if (use_keying_next()) { key = get_icon("KeyNext", "EditorIcons"); @@ -215,7 +215,7 @@ void EditorProperty::_notification(int p_what) { int text_limit = text_size; if (checkable) { - Ref<Texture> checkbox; + Ref<Texture2D> checkbox; if (checked) checkbox = get_icon("GuiChecked", "EditorIcons"); else @@ -236,7 +236,7 @@ void EditorProperty::_notification(int p_what) { } if (can_revert) { - Ref<Texture> reload_icon = get_icon("ReloadSmall", "EditorIcons"); + Ref<Texture2D> reload_icon = get_icon("ReloadSmall", "EditorIcons"); text_limit -= reload_icon->get_width() + get_constant("hseparator", "Tree") * 2; revert_rect = Rect2(text_limit + get_constant("hseparator", "Tree"), (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height()); @@ -256,7 +256,7 @@ void EditorProperty::_notification(int p_what) { draw_string(font, Point2(ofs, v_ofs + font->get_ascent()), label, color, text_limit); if (keying) { - Ref<Texture> key; + Ref<Texture2D> key; if (use_keying_next()) { key = get_icon("KeyNext", "EditorIcons"); @@ -1055,7 +1055,7 @@ void EditorInspectorSection::_notification(int p_what) { if (p_what == NOTIFICATION_SORT_CHILDREN) { Ref<Font> font = get_font("font", "Tree"); - Ref<Texture> arrow; + Ref<Texture2D> arrow; if (foldable) { if (object->editor_is_section_unfolded(section)) { @@ -1096,7 +1096,7 @@ void EditorInspectorSection::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Texture> arrow; + Ref<Texture2D> arrow; if (foldable) { if (object->editor_is_section_unfolded(section)) { diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 792247138e..7ad55a13ad 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -198,7 +198,7 @@ class EditorInspectorCategory : public Control { GDCLASS(EditorInspectorCategory, Control); friend class EditorInspector; - Ref<Texture> icon; + Ref<Texture2D> icon; String label; Color bg_color; mutable String tooltip_text; diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 0495722a13..5b77db7707 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -76,7 +76,7 @@ void EditorLog::_notification(int p_what) { void EditorLog::_clear_request() { log->clear(); - tool_button->set_icon(Ref<Texture>()); + tool_button->set_icon(Ref<Texture2D>()); } void EditorLog::_copy_request() { @@ -102,14 +102,14 @@ void EditorLog::add_message(const String &p_msg, MessageType p_type) { } break; case MSG_TYPE_ERROR: { log->push_color(get_color("error_color", "Editor")); - Ref<Texture> icon = get_icon("Error", "EditorIcons"); + Ref<Texture2D> icon = get_icon("Error", "EditorIcons"); log->add_image(icon); log->add_text(" "); tool_button->set_icon(icon); } break; case MSG_TYPE_WARNING: { log->push_color(get_color("warning_color", "Editor")); - Ref<Texture> icon = get_icon("Warning", "EditorIcons"); + Ref<Texture2D> icon = get_icon("Warning", "EditorIcons"); log->add_image(icon); log->add_text(" "); tool_button->set_icon(icon); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index d6dcbf7e84..31d5f8c4fa 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -183,11 +183,11 @@ void EditorNode::_update_scene_tabs() { OS::get_singleton()->global_menu_clear("_dock"); scene_tabs->clear_tabs(); - Ref<Texture> script_icon = gui_base->get_icon("Script", "EditorIcons"); + Ref<Texture2D> script_icon = gui_base->get_icon("Script", "EditorIcons"); for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { Node *type_node = editor_data.get_edited_scene_root(i); - Ref<Texture> icon; + Ref<Texture2D> icon; if (type_node) { icon = EditorNode::get_singleton()->get_object_icon(type_node, "Node"); } @@ -461,7 +461,7 @@ void EditorNode::_notification(int p_what) { ToolButton *tb = singleton->main_editor_buttons[i]; EditorPlugin *p_editor = singleton->editor_table[i]; - Ref<Texture> icon = p_editor->get_icon(); + Ref<Texture2D> icon = p_editor->get_icon(); if (icon.is_valid()) { tb->set_icon(icon); @@ -2942,7 +2942,7 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed tb->set_toggle_mode(true); tb->connect("pressed", singleton, "_editor_select", varray(singleton->main_editor_buttons.size())); tb->set_text(p_editor->get_name()); - Ref<Texture> icon = p_editor->get_icon(); + Ref<Texture2D> icon = p_editor->get_icon(); if (icon.is_valid()) { tb->set_icon(icon); @@ -3767,7 +3767,7 @@ Ref<ImageTexture> EditorNode::_load_custom_class_icon(const String &p_path) cons return NULL; } -Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const { +Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const { ERR_FAIL_COND_V(!p_object || !gui_base, NULL); Ref<Script> script = p_object->get_script(); @@ -3812,7 +3812,7 @@ Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p return NULL; } -Ref<Texture> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) const { +Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) const { ERR_FAIL_COND_V_MSG(p_class.empty(), NULL, "Class name cannot be empty."); if (gui_base->has_icon(p_class, "EditorIcons")) { @@ -3907,7 +3907,7 @@ void EditorNode::progress_end_task_bg(const String &p_task) { singleton->progress_hb->end_task(p_task); } -Ref<Texture> EditorNode::_file_dialog_get_icon(const String &p_path) { +Ref<Texture2D> EditorNode::_file_dialog_get_icon(const String &p_path) { EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem_path(p_path.get_base_dir()); if (efsd) { @@ -4732,7 +4732,7 @@ void EditorNode::_reposition_active_tab(int idx_to) { _update_scene_tabs(); } -void EditorNode::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) { +void EditorNode::_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { int p_tab = p_udata.operator signed int(); if (p_preview.is_valid()) { Rect2 rect = scene_tabs->get_tab_rect(p_tab); @@ -4972,7 +4972,7 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { TextureRect *drag_preview = memnew(TextureRect); Label *label = memnew(Label); - Ref<Texture> preview; + Ref<Texture2D> preview; { //todo make proper previews @@ -5582,7 +5582,6 @@ EditorNode::EditorNode() { Input::get_singleton()->set_use_accumulated_input(true); Resource::_get_local_scene_func = _resource_get_edited_scene; - VisualServer::get_singleton()->textures_keep_original(true); VisualServer::get_singleton()->set_debug_generate_wireframes(true); NavigationServer::get_singleton()->set_active(false); // no nav by default if editor @@ -5682,16 +5681,21 @@ EditorNode::EditorNode() { import_texture.instance(); ResourceFormatImporter::get_singleton()->add_importer(import_texture); - Ref<ResourceImporterLayeredTexture> import_3d; - import_3d.instance(); - import_3d->set_3d(true); - ResourceFormatImporter::get_singleton()->add_importer(import_3d); + Ref<ResourceImporterLayeredTexture> import_cubemap; + import_cubemap.instance(); + import_cubemap->set_mode(ResourceImporterLayeredTexture::MODE_CUBEMAP); + ResourceFormatImporter::get_singleton()->add_importer(import_cubemap); Ref<ResourceImporterLayeredTexture> import_array; import_array.instance(); - import_array->set_3d(false); + import_array->set_mode(ResourceImporterLayeredTexture::MODE_2D_ARRAY); ResourceFormatImporter::get_singleton()->add_importer(import_array); + Ref<ResourceImporterLayeredTexture> import_cubemap_array; + import_cubemap_array.instance(); + import_cubemap_array->set_mode(ResourceImporterLayeredTexture::MODE_CUBEMAP_ARRAY); + ResourceFormatImporter::get_singleton()->add_importer(import_cubemap_array); + Ref<ResourceImporterImage> import_image; import_image.instance(); ResourceFormatImporter::get_singleton()->add_importer(import_image); diff --git a/editor/editor_node.h b/editor/editor_node.h index a5c04d3531..bd2c3d73ae 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -522,13 +522,13 @@ private: Set<FileDialog *> file_dialogs; Set<EditorFileDialog *> editor_file_dialogs; - Map<String, Ref<Texture> > icon_type_cache; + Map<String, Ref<Texture2D> > icon_type_cache; void _build_icon_type_cache(); bool _initializing_addons; Map<String, EditorPlugin *> plugin_addons; - static Ref<Texture> _file_dialog_get_icon(const String &p_path); + static Ref<Texture2D> _file_dialog_get_icon(const String &p_path); static void _file_dialog_register(FileDialog *p_dialog); static void _file_dialog_unregister(FileDialog *p_dialog); static void _editor_file_dialog_register(EditorFileDialog *p_dialog); @@ -582,7 +582,7 @@ private: void _scene_tab_exit(); void _scene_tab_input(const Ref<InputEvent> &p_input); void _reposition_active_tab(int idx_to); - void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata); + void _thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata); void _scene_tab_script_edited(int p_tab); Dictionary _get_main_scene_state(); @@ -772,8 +772,8 @@ public: Ref<Theme> get_editor_theme() const { return theme; } Ref<Script> get_object_custom_type_base(const Object *p_object) const; StringName get_object_custom_type_name(const Object *p_object) const; - Ref<Texture> get_object_icon(const Object *p_object, const String &p_fallback = "Object") const; - Ref<Texture> get_class_icon(const String &p_class, const String &p_fallback = "Object") const; + Ref<Texture2D> get_object_icon(const Object *p_object, const String &p_fallback = "Object") const; + Ref<Texture2D> get_class_icon(const String &p_class, const String &p_fallback = "Object") const; void show_accept(const String &p_text, const String &p_title); void show_warning(const String &p_text, const String &p_title = TTR("Warning!")); diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index f0d69f98fb..6a1d052e02 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -54,7 +54,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { if (!obj) continue; - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(obj); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj); int index = get_popup()->get_item_count(); get_popup()->add_icon_item(icon, E->get().name.capitalize(), objects.size()); @@ -90,7 +90,7 @@ void EditorPath::update_path() { if (!obj) continue; - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(obj); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj); if (icon.is_valid()) set_icon(icon); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index b5f63dcd43..69a2344bc0 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -51,7 +51,7 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_ meshes.push_back(p_meshes[i]); } - Vector<Ref<Texture> > textures = make_mesh_previews(meshes, NULL, p_preview_size); + Vector<Ref<Texture2D> > textures = make_mesh_previews(meshes, NULL, p_preview_size); Array ret; for (int i = 0; i < textures.size(); i++) { ret.push_back(textures[i]); @@ -60,7 +60,7 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_ return ret; } -Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) { +Vector<Ref<Texture2D> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) { int size = p_preview_size; @@ -87,13 +87,13 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> EditorProgress ep("mlib", TTR("Creating Mesh Previews"), p_meshes.size()); - Vector<Ref<Texture> > textures; + Vector<Ref<Texture2D> > textures; for (int i = 0; i < p_meshes.size(); i++) { Ref<Mesh> mesh = p_meshes[i]; if (!mesh.is_valid()) { - textures.push_back(Ref<Texture>()); + textures.push_back(Ref<Texture2D>()); continue; } @@ -114,7 +114,7 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> AABB rot_aabb = xform.xform(aabb); float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5; if (m == 0) { - textures.push_back(Ref<Texture>()); + textures.push_back(Ref<Texture2D>()); continue; } xform.origin = -xform.basis.xform(ofs); //-ofs*m; @@ -131,7 +131,7 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> ep.step(TTR("Thumbnail..."), i); Main::iteration(); Main::iteration(); - Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); + Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); ERR_CONTINUE(!img.is_valid() || img->empty()); Ref<ImageTexture> it(memnew(ImageTexture)); it->create_from_image(img); @@ -314,7 +314,7 @@ EditorInterface::EditorInterface() { } /////////////////////////////////////////// -void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture> &p_icon) { +void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) { EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon); } @@ -605,13 +605,13 @@ String EditorPlugin::get_name() const { return String(); } -const Ref<Texture> EditorPlugin::get_icon() const { +const Ref<Texture2D> EditorPlugin::get_icon() const { if (get_script_instance() && get_script_instance()->has_method("get_plugin_icon")) { return get_script_instance()->call("get_plugin_icon"); } - return Ref<Texture>(); + return Ref<Texture2D>(); } bool EditorPlugin::has_main_screen() const { diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 1a78b72ade..dee63e4322 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -98,7 +98,7 @@ public: Error save_scene(); void save_scene_as(const String &p_scene, bool p_with_preview = true); - Vector<Ref<Texture> > make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size); + Vector<Ref<Texture2D> > make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size); void set_main_screen_editor(const String &p_name); void set_distraction_free_mode(bool p_enter); @@ -123,7 +123,7 @@ protected: static void _bind_methods(); UndoRedo &get_undo_redo() { return *undo_redo; } - void add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture> &p_icon); + void add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon); void remove_custom_type(const String &p_type); public: @@ -187,7 +187,7 @@ public: virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay); virtual String get_name() const; - virtual const Ref<Texture> get_icon() const; + virtual const Ref<Texture2D> get_icon() const; virtual bool has_main_screen() const; virtual void make_visible(bool p_visible); virtual void selected_notify() {} //notify that it was raised by the user, not the editor diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index e5a9c4d699..3ac4fcc21b 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -353,10 +353,10 @@ void EditorProfiler::_update_plot() { if (graph_texture.is_null()) { graph_texture.instance(); } - graph_texture->create(img->get_width(), img->get_height(), img->get_format(), Texture::FLAG_VIDEO_SURFACE); + graph_texture->create_from_image(img); } - graph_texture->set_data(img); + graph_texture->update(img, true); graph->set_texture(graph_texture); graph->update(); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index c134786b89..b018f34e8f 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -135,7 +135,7 @@ void EditorPropertyMultilineText::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { - Ref<Texture> df = get_icon("DistractionFree", "EditorIcons"); + Ref<Texture2D> df = get_icon("DistractionFree", "EditorIcons"); open_big_text->set_icon(df); Ref<Font> font = get_font("font", "Label"); text->set_custom_minimum_size(Vector2(0, font->get_height() * 6)); @@ -865,7 +865,7 @@ void EditorPropertyObjectID::update_property() { } else { edit->set_text(TTR("[Empty]")); edit->set_disabled(true); - edit->set_icon(Ref<Texture>()); + edit->set_icon(Ref<Texture2D>()); } } @@ -1983,7 +1983,7 @@ void EditorPropertyNodePath::update_property() { assign->set_tooltip(p); if (p == NodePath()) { - assign->set_icon(Ref<Texture>()); + assign->set_icon(Ref<Texture2D>()); assign->set_text(TTR("Assign...")); assign->set_flat(false); return; @@ -2000,7 +2000,7 @@ void EditorPropertyNodePath::update_property() { } if (!base_node || !base_node->has_node(p)) { - assign->set_icon(Ref<Texture>()); + assign->set_icon(Ref<Texture2D>()); assign->set_text(p); return; } @@ -2009,7 +2009,7 @@ void EditorPropertyNodePath::update_property() { ERR_FAIL_COND(!target_node); if (String(target_node->get_name()).find("@") != -1) { - assign->set_icon(Ref<Texture>()); + assign->set_icon(Ref<Texture2D>()); assign->set_text(p); return; } @@ -2028,7 +2028,7 @@ void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringNam void EditorPropertyNodePath::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture> t = get_icon("Clear", "EditorIcons"); + Ref<Texture2D> t = get_icon("Clear", "EditorIcons"); clear->set_icon(t); } } @@ -2331,7 +2331,7 @@ void EditorPropertyResource::_menu_option(int p_which) { } } -void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, ObjectID p_obj) { +void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, ObjectID p_obj) { RES p = get_edited_object()->get(get_edited_property()); if (p.is_valid() && p->get_instance_id() == p_obj) { @@ -2412,7 +2412,7 @@ void EditorPropertyResource::_update_menu_items() { const String &t = F->get(); bool is_custom_resource = false; - Ref<Texture> icon; + Ref<Texture2D> icon; if (!custom_resources.empty()) { for (int j = 0; j < custom_resources.size(); j++) { if (custom_resources[j].name == t) { @@ -2493,7 +2493,7 @@ void EditorPropertyResource::_update_menu_items() { } for (int i = 0; i < conversions.size(); i++) { String what = conversions[i]->converts_to(); - Ref<Texture> icon; + Ref<Texture2D> icon; if (has_icon(what, "EditorIcons")) { icon = get_icon(what, "EditorIcons"); @@ -2659,9 +2659,9 @@ void EditorPropertyResource::update_property() { } } - preview->set_texture(Ref<Texture>()); + preview->set_texture(Ref<Texture2D>()); if (res == RES()) { - assign->set_icon(Ref<Texture>()); + assign->set_icon(Ref<Texture2D>()); assign->set_text(TTR("[empty]")); } else { @@ -2712,7 +2712,7 @@ void EditorPropertyResource::setup(const String &p_base_type) { void EditorPropertyResource::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture> t = get_icon("select_arrow", "Tree"); + Ref<Texture2D> t = get_icon("select_arrow", "Tree"); edit->set_icon(t); } diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 1853a6b6e1..7c343f1c67 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -574,7 +574,7 @@ class EditorPropertyResource : public EditorProperty { void _file_selected(const String &p_path); void _menu_option(int p_which); - void _resource_preview(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, ObjectID p_obj); + void _resource_preview(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, ObjectID p_obj); void _resource_selected(); void _viewport_selected(const NodePath &p_path); diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 1f2a02c9a0..92bee53fdb 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -49,15 +49,15 @@ bool EditorResourcePreviewGenerator::handles(const String &p_type) const { ERR_FAIL_V_MSG(false, "EditorResourcePreviewGenerator::handles needs to be overridden."); } -Ref<Texture> EditorResourcePreviewGenerator::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorResourcePreviewGenerator::generate(const RES &p_from, const Size2 &p_size) const { if (get_script_instance() && get_script_instance()->has_method("generate")) { return get_script_instance()->call("generate", p_from, p_size); } - ERR_FAIL_V_MSG(Ref<Texture>(), "EditorResourcePreviewGenerator::generate needs to be overridden."); + ERR_FAIL_V_MSG(Ref<Texture2D>(), "EditorResourcePreviewGenerator::generate needs to be overridden."); } -Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String &p_path, const Size2 &p_size) const { +Ref<Texture2D> EditorResourcePreviewGenerator::generate_from_path(const String &p_path, const Size2 &p_size) const { if (get_script_instance() && get_script_instance()->has_method("generate_from_path")) { return get_script_instance()->call("generate_from_path", p_path, p_size); @@ -90,8 +90,8 @@ bool EditorResourcePreviewGenerator::can_generate_small_preview() const { void EditorResourcePreviewGenerator::_bind_methods() { ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles", PropertyInfo(Variant::STRING, "type"))); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture), "generate", PropertyInfo(Variant::OBJECT, "from", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::VECTOR2, "size"))); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture), "generate_from_path", PropertyInfo(Variant::STRING, "path", PROPERTY_HINT_FILE), PropertyInfo(Variant::VECTOR2, "size"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture2D), "generate", PropertyInfo(Variant::OBJECT, "from", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::VECTOR2, "size"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture2D), "generate_from_path", PropertyInfo(Variant::STRING, "path", PROPERTY_HINT_FILE), PropertyInfo(Variant::VECTOR2, "size"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "generate_small_preview_automatically")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "can_generate_small_preview")); } @@ -107,7 +107,7 @@ void EditorResourcePreview::_thread_func(void *ud) { erp->_thread(); } -void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture> &p_texture, const Ref<Texture> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) { +void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) { preview_mutex->lock(); @@ -160,7 +160,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< if (!preview_generators[i]->handles(type)) continue; - Ref<Texture> generated; + Ref<Texture2D> generated; if (p_item.resource.is_valid()) { generated = preview_generators[i]->generate(p_item.resource, Vector2(thumbnail_size, thumbnail_size)); } else { @@ -172,7 +172,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< small_thumbnail_size *= EDSCALE; if (preview_generators[i]->can_generate_small_preview()) { - Ref<Texture> generated_small; + Ref<Texture2D> generated_small; if (p_item.resource.is_valid()) { generated_small = preview_generators[i]->generate(p_item.resource, Vector2(small_thumbnail_size, small_thumbnail_size)); } else { @@ -322,14 +322,14 @@ void EditorResourcePreview::_thread() { } else { texture.instance(); - texture->create_from_image(img, Texture::FLAG_FILTER); + texture->create_from_image(img); if (has_small_texture) { if (small_img->load(cache_base + "_small.png") != OK) { cache_valid = false; } else { small_texture.instance(); - small_texture->create_from_image(small_img, Texture::FLAG_FILTER); + small_texture->create_from_image(small_img); } } } diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h index 8091fbafdc..94f4bcb466 100644 --- a/editor/editor_resource_preview.h +++ b/editor/editor_resource_preview.h @@ -45,8 +45,8 @@ protected: public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; - virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const; virtual bool generate_small_preview_automatically() const; virtual bool can_generate_small_preview() const; @@ -77,8 +77,8 @@ class EditorResourcePreview : public Node { volatile bool exited; struct Item { - Ref<Texture> preview; - Ref<Texture> small_preview; + Ref<Texture2D> preview; + Ref<Texture2D> small_preview; int order; uint32_t last_hash; uint64_t modified_time; @@ -88,7 +88,7 @@ class EditorResourcePreview : public Node { Map<String, Item> cache; - void _preview_ready(const String &p_str, const Ref<Texture> &p_texture, const Ref<Texture> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud); + void _preview_ready(const String &p_str, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud); void _generate_preview(Ref<ImageTexture> &r_texture, Ref<ImageTexture> &r_small_texture, const QueueItem &p_item, const String &cache_base); static void _thread_func(void *ud); @@ -102,7 +102,7 @@ protected: public: static EditorResourcePreview *get_singleton(); - //callback function is callback(String p_path,Ref<Texture> preview,Variant udata) preview null if could not load + //callback function is callback(String p_path,Ref<Texture2D> preview,Variant udata) preview null if could not load void queue_resource_preview(const String &p_path, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata); void queue_edited_resource_preview(const Ref<Resource> &p_res, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata); diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index 4bbc111aea..db88b0cea4 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -53,7 +53,7 @@ void EditorRunNative::_notification(int p_what) { im->resize(16 * EDSCALE, 16 * EDSCALE); Ref<ImageTexture> small_icon; small_icon.instance(); - small_icon->create_from_image(im, 0); + small_icon->create_from_image(im); MenuButton *mb = memnew(MenuButton); mb->get_popup()->connect("id_pressed", this, "_run_native", varray(i)); mb->connect("pressed", this, "_run_native", varray(-1, i)); diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 5db18d8853..bb8bcdfe6c 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -200,7 +200,7 @@ void EditorSpinSlider::_notification(int p_what) { int string_width = font->get_string_size(label).width; int number_width = get_size().width - sb->get_minimum_size().width - string_width - sep; - Ref<Texture> updown = get_icon("updown", "SpinBox"); + Ref<Texture2D> updown = get_icon("updown", "SpinBox"); if (get_step() == 1) { number_width -= updown->get_width(); @@ -233,7 +233,7 @@ void EditorSpinSlider::_notification(int p_what) { draw_string(font, Vector2(Math::round(sb->get_offset().x + string_width + sep), vofs), numstr, fc, number_width); if (get_step() == 1) { - Ref<Texture> updown2 = get_icon("updown", "SpinBox"); + Ref<Texture2D> updown2 = get_icon("updown", "SpinBox"); int updown_vofs = (get_size().height - updown2->get_height()) / 2; updown_offset = get_size().width - sb->get_margin(MARGIN_RIGHT) - updown2->get_width(); Color c(1, 1, 1); @@ -268,7 +268,7 @@ void EditorSpinSlider::_notification(int p_what) { } if (display_grabber) { - Ref<Texture> grabber_tex; + Ref<Texture2D> grabber_tex; if (mouse_over_grabber) { grabber_tex = get_icon("grabber_highlight", "HSlider"); } else { diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 28bc20a957..78387fceb7 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -41,7 +41,7 @@ #include "modules/svg/image_loader_svg.h" #endif -static Ref<StyleBoxTexture> make_stylebox(Ref<Texture> p_texture, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) { +static Ref<StyleBoxTexture> make_stylebox(Ref<Texture2D> p_texture, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) { Ref<StyleBoxTexture> style(memnew(StyleBoxTexture)); style->set_texture(p_texture); style->set_margin_size(MARGIN_LEFT, p_left * EDSCALE); @@ -99,10 +99,7 @@ Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float const bool upsample = !Math::is_equal_approx(Math::round(p_scale), p_scale); ImageLoaderSVG::create_image_from_string(img, editor_icons_sources[p_index], p_scale, upsample, p_convert_color); - if ((p_scale - (float)((int)p_scale)) > 0.0 || is_gizmo || p_force_filter) - icon->create_from_image(img); // in this case filter really helps - else - icon->create_from_image(img, 0); + icon->create_from_image(img); // in this case filter really helps return icon; } @@ -931,7 +928,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("panel", "EditorAbout", style_complex_window); // HScrollBar - Ref<Texture> empty_icon = memnew(ImageTexture); + Ref<Texture2D> empty_icon = memnew(ImageTexture); theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0)); theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0)); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 684942dbad..a3def15532 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -45,8 +45,8 @@ #include "scene/main/viewport.h" #include "scene/resources/packed_scene.h" -Ref<Texture> FileSystemDock::_get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx) { - Ref<Texture> file_icon; +Ref<Texture2D> FileSystemDock::_get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx) { + Ref<Texture2D> file_icon; if (!p_dir->get_file_import_is_valid(p_idx)) { file_icon = get_icon("ImportFail", "EditorIcons"); } else { @@ -198,11 +198,11 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo if (!fave.begins_with("res://")) continue; - Ref<Texture> folder_icon = get_icon("Folder", "EditorIcons"); + Ref<Texture2D> folder_icon = get_icon("Folder", "EditorIcons"); const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); String text; - Ref<Texture> icon; + Ref<Texture2D> icon; Color color; if (fave == "res://") { text = "/"; @@ -496,7 +496,7 @@ void FileSystemDock::navigate_to_path(const String &p_path) { _navigate_to_path(p_path); } -void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) { +void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { if ((file_list_vb->is_visible_in_tree() || path == p_path.get_base_dir()) && p_preview.is_valid()) { Array uarr = p_udata; int idx = uarr[0]; @@ -512,7 +512,7 @@ void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref<T } } -void FileSystemDock::_tree_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) { +void FileSystemDock::_tree_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { if (p_small_preview.is_valid()) { Array uarr = p_udata; if (tree_update_id == (int)uarr[0]) { @@ -613,9 +613,9 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { String ei = "EditorIcons"; int thumbnail_size = EditorSettings::get_singleton()->get("docks/filesystem/thumbnail_size"); thumbnail_size *= EDSCALE; - Ref<Texture> folder_thumbnail; - Ref<Texture> file_thumbnail; - Ref<Texture> file_thumbnail_broken; + Ref<Texture2D> folder_thumbnail; + Ref<Texture2D> file_thumbnail; + Ref<Texture2D> file_thumbnail_broken; bool use_thumbnails = (file_list_display_mode == FILE_LIST_DISPLAY_THUMBNAILS); @@ -645,7 +645,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { files->set_fixed_icon_size(Size2()); } - Ref<Texture> folder_icon = (use_thumbnails) ? folder_thumbnail : get_icon("folder", "FileDialog"); + Ref<Texture2D> folder_icon = (use_thumbnails) ? folder_thumbnail : get_icon("folder", "FileDialog"); const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); // Build the FileInfo list. @@ -656,7 +656,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { for (int i = 0; i < favorites.size(); i++) { String favorite = favorites[i]; String text; - Ref<Texture> icon; + Ref<Texture2D> icon; if (favorite == "res://") { text = "/"; icon = folder_icon; @@ -759,8 +759,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { String fpath = finfo->path; String ftype = finfo->type; - Ref<Texture> type_icon; - Ref<Texture> big_icon; + Ref<Texture2D> type_icon; + Ref<Texture2D> big_icon; String tooltip = fpath; diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 49692c8349..d20d4add4e 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -176,7 +176,7 @@ private: ItemList *files; bool import_dock_needs_update; - Ref<Texture> _get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx); + Ref<Texture2D> _get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx); bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false); Vector<String> _compute_uncollapsed_paths(); void _update_tree(const Vector<String> &p_uncollapsed_paths = Vector<String>(), bool p_uncollapse_root = false, bool p_select_in_favorites = false, bool p_unfold_path = false); @@ -269,8 +269,8 @@ private: void _get_drag_target_folder(String &target, bool &target_favorites, const Point2 &p_point, Control *p_from) const; void _preview_invalidated(const String &p_path); - void _file_list_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata); - void _tree_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata); + void _file_list_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata); + void _tree_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata); void _update_display_mode(bool p_force = false); diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index c76ff9d679..cd185ae12e 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -88,7 +88,7 @@ void GroupDialog::_load_nodes(Node *p_current) { node->set_metadata(0, path); node->set_tooltip(0, path); - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(p_current, "Node"); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(p_current, "Node"); node->set_icon(0, icon); if (!_can_edit(p_current, selected_group)) { diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index e2d8dc8962..bf293c3a5e 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -380,7 +380,7 @@ Error ColladaImport::_create_material(const String &p_target) { if (texfile.begins_with("/")) { texfile = texfile.replace_first("/", "res://"); } - Ref<Texture> texture = ResourceLoader::load(texfile, "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); @@ -405,7 +405,7 @@ Error ColladaImport::_create_material(const String &p_target) { texfile = texfile.replace_first("/", "res://"); } - Ref<Texture> texture = ResourceLoader::load(texfile, "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { material->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture); material->set_specular(1.0); @@ -432,7 +432,7 @@ Error ColladaImport::_create_material(const String &p_target) { texfile = texfile.replace_first("/", "res://"); } - Ref<Texture> texture = ResourceLoader::load(texfile, "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { material->set_feature(SpatialMaterial::FEATURE_EMISSION, true); @@ -462,7 +462,7 @@ Error ColladaImport::_create_material(const String &p_target) { texfile = texfile.replace_first("/", "res://"); } - Ref<Texture> texture = ResourceLoader::load(texfile, "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { material->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); material->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture); diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index d4664e1bb9..abdbdd29a9 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1277,7 +1277,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b } else { uri = p_base_path.plus_file(uri).replace("\\", "/"); //fix for windows - Ref<Texture> texture = ResourceLoader::load(uri); + Ref<Texture2D> texture = ResourceLoader::load(uri); state.images.push_back(texture); continue; } @@ -1362,11 +1362,11 @@ Error EditorSceneImporterGLTF::_parse_textures(GLTFState &state) { return OK; } -Ref<Texture> EditorSceneImporterGLTF::_get_texture(GLTFState &state, const GLTFTextureIndex p_texture) { - ERR_FAIL_INDEX_V(p_texture, state.textures.size(), Ref<Texture>()); +Ref<Texture2D> EditorSceneImporterGLTF::_get_texture(GLTFState &state, const GLTFTextureIndex p_texture) { + ERR_FAIL_INDEX_V(p_texture, state.textures.size(), Ref<Texture2D>()); const GLTFImageIndex image = state.textures[p_texture].src_image; - ERR_FAIL_INDEX_V(image, state.images.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(image, state.images.size(), Ref<Texture2D>()); return state.images[image]; } @@ -1423,7 +1423,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { if (mr.has("metallicRoughnessTexture")) { const Dictionary &bct = mr["metallicRoughnessTexture"]; if (bct.has("index")) { - const Ref<Texture> t = _get_texture(state, bct["index"]); + const Ref<Texture2D> t = _get_texture(state, bct["index"]); material->set_texture(SpatialMaterial::TEXTURE_METALLIC, t); material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_BLUE); material->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, t); diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index 78d7106b0d..a4a715d17c 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -310,7 +310,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { Vector<int> root_nodes; Vector<GLTFTexture> textures; - Vector<Ref<Texture> > images; + Vector<Ref<Texture2D> > images; Vector<GLTFSkin> skins; Vector<GLTFCamera> cameras; @@ -335,7 +335,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { String _sanitize_bone_name(const String &name); String _gen_unique_bone_name(GLTFState &state, const GLTFSkeletonIndex skel_i, const String &p_name); - Ref<Texture> _get_texture(GLTFState &state, const GLTFTextureIndex p_texture); + Ref<Texture2D> _get_texture(GLTFState &state, const GLTFTextureIndex p_texture); Error _parse_json(const String &p_path, GLTFState &state); Error _parse_glb(const String &p_path, GLTFState &state); diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index 9b819bc341..01b938e690 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -40,24 +40,71 @@ String ResourceImporterLayeredTexture::get_importer_name() const { - return is_3d ? "texture_3d" : "texture_array"; + switch (mode) { + case MODE_CUBEMAP: { + return "cubemap_texture"; + } break; + case MODE_2D_ARRAY: { + return "2d_array_texture"; + } break; + case MODE_CUBEMAP_ARRAY: { + return "cubemap_array_texture"; + } break; + } + + ERR_FAIL_V(""); } String ResourceImporterLayeredTexture::get_visible_name() const { - return is_3d ? "Texture3D" : "TextureArray"; + switch (mode) { + case MODE_CUBEMAP: { + return "Cubemap"; + } break; + case MODE_2D_ARRAY: { + return "Texture2DArray"; + } break; + case MODE_CUBEMAP_ARRAY: { + return "CubemapArray"; + } break; + } + + ERR_FAIL_V(""); } void ResourceImporterLayeredTexture::get_recognized_extensions(List<String> *p_extensions) const { ImageLoader::get_recognized_extensions(p_extensions); } String ResourceImporterLayeredTexture::get_save_extension() const { - return is_3d ? "tex3d" : "texarr"; + switch (mode) { + case MODE_CUBEMAP: { + return "cube"; + } break; + case MODE_2D_ARRAY: { + return "tex2darr"; + } break; + case MODE_CUBEMAP_ARRAY: { + return "cubearr"; + } break; + } + + ERR_FAIL_V(String()); } String ResourceImporterLayeredTexture::get_resource_type() const { - return is_3d ? "Texture3D" : "TextureArray"; + switch (mode) { + case MODE_CUBEMAP: { + return "Cubemap"; + } break; + case MODE_2D_ARRAY: { + return "Texture2DArray"; + } break; + case MODE_CUBEMAP_ARRAY: { + return "CubemapArray"; + } break; + } + ERR_FAIL_V(String()); } bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { @@ -66,47 +113,48 @@ bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_optio } int ResourceImporterLayeredTexture::get_preset_count() const { - return 3; + return 0; } String ResourceImporterLayeredTexture::get_preset_name(int p_idx) const { - static const char *preset_names[] = { - "3D", - "2D", - "ColorCorrect" - }; - - return preset_names[p_idx]; + return ""; } void ResourceImporterLayeredTexture::get_import_options(List<ImportOption> *r_options, int p_preset) const { - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 1 : 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 1)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress/no_bptc_if_rgb"), false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirrored"), 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/filter"), true)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/mipmaps"), p_preset == PRESET_COLOR_CORRECT ? 0 : 1)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/srgb", PROPERTY_HINT_ENUM, "Disable,Enable"), p_preset == PRESET_3D ? 1 : 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/horizontal", PROPERTY_HINT_RANGE, "1,256,1"), p_preset == PRESET_COLOR_CORRECT ? 16 : 8)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/vertical", PROPERTY_HINT_RANGE, "1,256,1"), p_preset == PRESET_COLOR_CORRECT ? 1 : 8)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/channel_pack", PROPERTY_HINT_ENUM, "sRGB Friendly,Optimized"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/mipmaps"), true)); + if (mode == MODE_2D_ARRAY) { + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/horizontal", PROPERTY_HINT_RANGE, "1,256,1"), 8)); + } + if (mode == MODE_2D_ARRAY || mode == MODE_CUBEMAP_ARRAY) { + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/vertical", PROPERTY_HINT_RANGE, "1,256,1"), 8)); + } } -void ResourceImporterLayeredTexture::_save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags) { +void ResourceImporterLayeredTexture::_save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps) { FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE); f->store_8('G'); f->store_8('D'); - if (is_3d) { - f->store_8('3'); - } else { - f->store_8('A'); + switch (mode) { + case MODE_2D_ARRAY: f->store_8('A'); break; + case MODE_CUBEMAP: f->store_8('C'); break; + case MODE_CUBEMAP_ARRAY: f->store_8('X'); break; } + f->store_8('T'); //godot streamable texture f->store_32(p_images[0]->get_width()); f->store_32(p_images[0]->get_height()); f->store_32(p_images.size()); //depth - f->store_32(p_texture_flags); + uint32_t flags = 0; + if (p_mipmaps) { + flags |= TEXTURE_FLAGS_MIPMAPS; + } + f->store_32(flags); if (p_compress_mode != COMPRESS_VIDEO_RAM) { //vram needs to do a first compression to tell what the format is, for the rest its ok f->store_32(p_images[0]->get_format()); @@ -195,12 +243,18 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const int compress_mode = p_options["compress/mode"]; int no_bptc_if_rgb = p_options["compress/no_bptc_if_rgb"]; - int repeat = p_options["flags/repeat"]; - bool filter = p_options["flags/filter"]; bool mipmaps = p_options["flags/mipmaps"]; - int srgb = p_options["flags/srgb"]; - int hslices = p_options["slices/horizontal"]; - int vslices = p_options["slices/vertical"]; + int channel_pack = p_options["compress/channel_pack"]; + int hslices = (p_options.has("slices/horizontal")) ? int(p_options["slices/horizontal"]) : 0; + int vslices = (p_options.has("slices/vertical")) ? int(p_options["slices/vertical"]) : 0; + + if (mode == MODE_CUBEMAP) { + hslices = 3; + vslices = 2; + } else if (mode == MODE_CUBEMAP_ARRAY) { + hslices = 3; + vslices *= 2; //put cubemaps vertically + } Ref<Image> image; image.instance(); @@ -208,17 +262,9 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const if (err != OK) return err; - int tex_flags = 0; - if (repeat > 0) - tex_flags |= Texture::FLAG_REPEAT; - if (repeat == 2) - tex_flags |= Texture::FLAG_MIRRORED_REPEAT; - if (filter) - tex_flags |= Texture::FLAG_FILTER; - if (mipmaps || compress_mode == COMPRESS_VIDEO_RAM) - tex_flags |= Texture::FLAG_MIPMAPS; - if (srgb == 1) - tex_flags |= Texture::FLAG_CONVERT_TO_LINEAR; + if (compress_mode == COMPRESS_VIDEO_RAM) { + mipmaps = true; + } Vector<Ref<Image> > slices; @@ -228,7 +274,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const //optimize if (compress_mode == COMPRESS_VIDEO_RAM) { //if using video ram, optimize - if (srgb) { + if (channel_pack == 0) { //remove alpha if not needed, so compression is more efficient if (image->get_format() == Image::FORMAT_RGBA8 && !image->detect_alpha()) { image->convert(Image::FORMAT_RGB8); @@ -277,14 +323,14 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const if (encode_bptc) { - _save_tex(slices, p_save_path + ".bptc." + extension, compress_mode, Image::COMPRESS_BPTC, mipmaps, tex_flags); + _save_tex(slices, p_save_path + ".bptc." + extension, compress_mode, Image::COMPRESS_BPTC, mipmaps); r_platform_variants->push_back("bptc"); ok_on_pc = true; } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc")) { - _save_tex(slices, p_save_path + ".s3tc." + extension, compress_mode, Image::COMPRESS_S3TC, mipmaps, tex_flags); + _save_tex(slices, p_save_path + ".s3tc." + extension, compress_mode, Image::COMPRESS_S3TC, mipmaps); r_platform_variants->push_back("s3tc"); ok_on_pc = true; formats_imported.push_back("s3tc"); @@ -292,20 +338,20 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) { - _save_tex(slices, p_save_path + ".etc2." + extension, compress_mode, Image::COMPRESS_ETC2, mipmaps, tex_flags); + _save_tex(slices, p_save_path + ".etc2." + extension, compress_mode, Image::COMPRESS_ETC2, mipmaps); r_platform_variants->push_back("etc2"); formats_imported.push_back("etc2"); } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc")) { - _save_tex(slices, p_save_path + ".etc." + extension, compress_mode, Image::COMPRESS_ETC, mipmaps, tex_flags); + _save_tex(slices, p_save_path + ".etc." + extension, compress_mode, Image::COMPRESS_ETC, mipmaps); r_platform_variants->push_back("etc"); formats_imported.push_back("etc"); } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) { - _save_tex(slices, p_save_path + ".pvrtc." + extension, compress_mode, Image::COMPRESS_PVRTC4, mipmaps, tex_flags); + _save_tex(slices, p_save_path + ".pvrtc." + extension, compress_mode, Image::COMPRESS_PVRTC4, mipmaps); r_platform_variants->push_back("pvrtc"); formats_imported.push_back("pvrtc"); } @@ -315,7 +361,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const } } else { //import normally - _save_tex(slices, p_save_path + "." + extension, compress_mode, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, tex_flags); + _save_tex(slices, p_save_path + "." + extension, compress_mode, Image::COMPRESS_S3TC /*this is ignored */, mipmaps); } if (r_metadata) { @@ -396,7 +442,7 @@ ResourceImporterLayeredTexture *ResourceImporterLayeredTexture::singleton = NULL ResourceImporterLayeredTexture::ResourceImporterLayeredTexture() { singleton = this; - is_3d = true; + mode = MODE_CUBEMAP; } ResourceImporterLayeredTexture::~ResourceImporterLayeredTexture() { diff --git a/editor/import/resource_importer_layered_texture.h b/editor/import/resource_importer_layered_texture.h index 6dc4b6ed3c..3dcf50e004 100644 --- a/editor/import/resource_importer_layered_texture.h +++ b/editor/import/resource_importer_layered_texture.h @@ -38,8 +38,19 @@ class StreamTexture; class ResourceImporterLayeredTexture : public ResourceImporter { GDCLASS(ResourceImporterLayeredTexture, ResourceImporter); +public: + enum Mode { + MODE_CUBEMAP, + MODE_2D_ARRAY, + MODE_CUBEMAP_ARRAY + }; + + enum TextureFlags { + TEXTURE_FLAGS_MIPMAPS = 1 + }; - bool is_3d; +private: + Mode mode; static const char *compression_formats[]; protected: @@ -57,12 +68,6 @@ public: virtual String get_save_extension() const; virtual String get_resource_type() const; - enum Preset { - PRESET_3D, - PRESET_2D, - PRESET_COLOR_CORRECT, - }; - enum CompressMode { COMPRESS_LOSSLESS, COMPRESS_VIDEO_RAM, @@ -75,7 +80,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - void _save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags); + void _save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps); virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); @@ -84,7 +89,8 @@ public: virtual bool are_import_settings_valid(const String &p_path) const; virtual String get_import_settings_string() const; - void set_3d(bool p_3d) { is_3d = p_3d; } + void set_mode(Mode p_mode) { mode = p_mode; } + ResourceImporterLayeredTexture(); ~ResourceImporterLayeredTexture(); }; diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index bdd6a197f8..fedf1be94f 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -133,7 +133,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati path = base_path.plus_file(p); } - Ref<Texture> texture = ResourceLoader::load(path); + Ref<Texture2D> texture = ResourceLoader::load(path); if (texture.is_valid()) { current->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); @@ -153,7 +153,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati path = base_path.plus_file(p); } - Ref<Texture> texture = ResourceLoader::load(path); + Ref<Texture2D> texture = ResourceLoader::load(path); if (texture.is_valid()) { current->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture); @@ -173,7 +173,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati path = base_path.plus_file(p); } - Ref<Texture> texture = ResourceLoader::load(path); + Ref<Texture2D> texture = ResourceLoader::load(path); if (texture.is_valid()) { current->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, texture); @@ -187,7 +187,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati String p = l.replace("map_bump", "").replace("\\", "/").strip_edges(); String path = base_path.plus_file(p); - Ref<Texture> texture = ResourceLoader::load(path); + Ref<Texture2D> texture = ResourceLoader::load(path); if (texture.is_valid()) { current->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 88547280ce..f1da5af31c 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -36,16 +36,18 @@ #include "editor/editor_node.h" #include "scene/resources/texture.h" -void ResourceImporterTexture::_texture_reimport_srgb(const Ref<StreamTexture> &p_tex) { +void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_channel) { singleton->mutex->lock(); StringName path = p_tex->get_path(); if (!singleton->make_flags.has(path)) { - singleton->make_flags[path] = 0; + singleton->make_flags[path] = MakeInfo(); } - singleton->make_flags[path] |= MAKE_SRGB_FLAG; + singleton->make_flags[path].flags |= MAKE_ROUGHNESS_FLAG; + singleton->make_flags[path].channel_for_roughness = p_channel; + singleton->make_flags[path].normal_path_for_roughness = p_normal_path; singleton->mutex->unlock(); } @@ -56,10 +58,10 @@ void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture> &p_t StringName path = p_tex->get_path(); if (!singleton->make_flags.has(path)) { - singleton->make_flags[path] = 0; + singleton->make_flags[path] = MakeInfo(); } - singleton->make_flags[path] |= MAKE_3D_FLAG; + singleton->make_flags[path].flags |= MAKE_3D_FLAG; singleton->mutex->unlock(); } @@ -70,10 +72,10 @@ void ResourceImporterTexture::_texture_reimport_normal(const Ref<StreamTexture> StringName path = p_tex->get_path(); if (!singleton->make_flags.has(path)) { - singleton->make_flags[path] = 0; + singleton->make_flags[path] = MakeInfo(); } - singleton->make_flags[path] |= MAKE_NORMAL_FLAG; + singleton->make_flags[path].flags |= MAKE_NORMAL_FLAG; singleton->mutex->unlock(); } @@ -91,7 +93,7 @@ void ResourceImporterTexture::update_imports() { } Vector<String> to_reimport; - for (Map<StringName, int>::Element *E = make_flags.front(); E; E = E->next()) { + for (Map<StringName, MakeInfo>::Element *E = make_flags.front(); E; E = E->next()) { Ref<ConfigFile> cf; cf.instance(); @@ -101,22 +103,22 @@ void ResourceImporterTexture::update_imports() { ERR_CONTINUE(err != OK); bool changed = false; - if (E->get() & MAKE_SRGB_FLAG && int(cf->get_value("params", "flags/srgb")) == 2) { - cf->set_value("params", "flags/srgb", 1); + + if (E->get().flags & MAKE_NORMAL_FLAG && int(cf->get_value("params", "compress/normal_map")) == 0) { + cf->set_value("params", "compress/normal_map", 1); changed = true; } - if (E->get() & MAKE_NORMAL_FLAG && int(cf->get_value("params", "compress/normal_map")) == 0) { - cf->set_value("params", "compress/normal_map", 1); + if (E->get().flags & MAKE_ROUGHNESS_FLAG && int(cf->get_value("params", "roughness/mode")) == 0) { + cf->set_value("params", "roughness/mode", E->get().channel_for_roughness + 2); + cf->set_value("params", "roughness/src_normal", E->get().normal_path_for_roughness); changed = true; } - if (E->get() & MAKE_3D_FLAG && bool(cf->get_value("params", "detect_3d"))) { + if (E->get().flags & MAKE_3D_FLAG && bool(cf->get_value("params", "detect_3d"))) { cf->set_value("params", "detect_3d", false); cf->set_value("params", "compress/mode", 2); - cf->set_value("params", "flags/repeat", true); - cf->set_value("params", "flags/filter", true); - cf->set_value("params", "flags/mipmaps", true); + cf->set_value("params", "format/mipmaps", true); changed = true; } @@ -142,7 +144,7 @@ String ResourceImporterTexture::get_importer_name() const { String ResourceImporterTexture::get_visible_name() const { - return "Texture"; + return "Texture2D"; } void ResourceImporterTexture::get_recognized_extensions(List<String> *p_extensions) const { @@ -204,14 +206,12 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_mode", PROPERTY_HINT_ENUM, "Enabled,Force RGBE"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/bptc_ldr", PROPERTY_HINT_ENUM, "Enabled,RGBA Only"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/normal_map", PROPERTY_HINT_ENUM, "Detect,Enable,Disabled"), 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirrored"), p_preset == PRESET_3D ? 1 : 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/filter"), p_preset != PRESET_2D_PIXEL)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/mipmaps"), p_preset == PRESET_3D)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/anisotropic"), false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/srgb", PROPERTY_HINT_ENUM, "Disable,Enable,Detect"), 2)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/channel_pack", PROPERTY_HINT_ENUM, "sRGB Friendly,Optimized"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "format/mipmaps", PROPERTY_HINT_ENUM, "Detect,Disabled,Enabled"), p_preset == PRESET_DETECT ? 0 : (p_preset == PRESET_3D ? 2 : 1))); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "roughness/mode", PROPERTY_HINT_ENUM, "Detect,Disabled,Red,Green,Blue,Alpha,Gray"), 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "roughness/src_normal", PROPERTY_HINT_FILE, "*.png,*.jpg"), "")); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/fix_alpha_border"), p_preset != PRESET_3D)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/premult_alpha"), false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/HDR_as_SRGB"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/invert_color"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "stream"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "size_limit", PROPERTY_HINT_RANGE, "0,4096,1"), 0)); @@ -219,7 +219,7 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "svg/scale", PROPERTY_HINT_RANGE, "0.001,100,0.001"), 1.0)); } -void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal, bool p_force_po2_for_compressed) { +void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_roughness, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed) { FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE); f->store_8('G'); @@ -229,7 +229,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String bool resize_to_po2 = false; - if (p_compress_mode == COMPRESS_VIDEO_RAM && p_force_po2_for_compressed && (p_mipmaps || p_texture_flags & Texture::FLAG_REPEAT)) { + if (p_compress_mode == COMPRESS_VIDEO_RAM && p_force_po2_for_compressed && p_mipmaps) { resize_to_po2 = true; f->store_16(next_power_of_2(p_image->get_width())); f->store_16(p_image->get_width()); @@ -241,7 +241,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String f->store_16(p_image->get_height()); f->store_16(0); } - f->store_32(p_texture_flags); + f->store_32(0); //texture flags deprecated uint32_t format = 0; @@ -251,8 +251,8 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String format |= StreamTexture::FORMAT_BIT_HAS_MIPMAPS; //mipmaps bit if (p_detect_3d) format |= StreamTexture::FORMAT_BIT_DETECT_3D; - if (p_detect_srgb) - format |= StreamTexture::FORMAT_BIT_DETECT_SRGB; + if (p_detect_roughness) + format |= StreamTexture::FORMAT_BIT_DETECT_ROUGNESS; if (p_detect_normal) format |= StreamTexture::FORMAT_BIT_DETECT_NORMAL; @@ -335,7 +335,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String Image::CompressSource csource = Image::COMPRESS_SOURCE_GENERIC; if (p_force_normal) { csource = Image::COMPRESS_SOURCE_NORMAL; - } else if (p_texture_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { + } else if (p_srgb_friendly) { csource = Image::COMPRESS_SOURCE_SRGB; } @@ -379,11 +379,8 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String int compress_mode = p_options["compress/mode"]; float lossy = p_options["compress/lossy_quality"]; - int repeat = p_options["flags/repeat"]; - bool filter = p_options["flags/filter"]; - bool mipmaps = p_options["flags/mipmaps"]; - bool anisotropic = p_options["flags/anisotropic"]; - int srgb = p_options["flags/srgb"]; + int pack_channels = p_options["compress/channel_pack"]; + bool mipmaps = p_options["format/mipmaps"]; bool fix_alpha_border = p_options["process/fix_alpha_border"]; bool premult_alpha = p_options["process/premult_alpha"]; bool invert_color = p_options["process/invert_color"]; @@ -394,6 +391,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String float scale = p_options["svg/scale"]; bool force_rgbe = p_options["compress/hdr_mode"]; int bptc_ldr = p_options["compress/bptc_ldr"]; + int roughness = p_options["roughness/mode"]; Ref<Image> image; image.instance(); @@ -403,20 +401,6 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String Array formats_imported; - int tex_flags = 0; - if (repeat > 0) - tex_flags |= Texture::FLAG_REPEAT; - if (repeat == 2) - tex_flags |= Texture::FLAG_MIRRORED_REPEAT; - if (filter) - tex_flags |= Texture::FLAG_FILTER; - if (mipmaps || compress_mode == COMPRESS_VIDEO_RAM) - tex_flags |= Texture::FLAG_MIPMAPS; - if (anisotropic) - tex_flags |= Texture::FLAG_ANISOTROPIC_FILTER; - if (srgb == 1) - tex_flags |= Texture::FLAG_CONVERT_TO_LINEAR; - if (size_limit > 0 && (image->get_width() > size_limit || image->get_height() > size_limit)) { //limit size if (image->get_width() >= image->get_height()) { @@ -459,9 +443,10 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } bool detect_3d = p_options["detect_3d"]; - bool detect_srgb = srgb == 2; + bool detect_roughness = roughness == 0; bool detect_normal = normal == 0; bool force_normal = normal == 1; + bool srgb_friendly_pack = pack_channels == 0; if (compress_mode == COMPRESS_VIDEO_RAM) { //must import in all formats, in order of priority (so platform choses the best supported one. IE, etc2 over etc). @@ -497,7 +482,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } if (can_bptc || can_s3tc) { - _save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, can_bptc ? Image::COMPRESS_BPTC : Image::COMPRESS_S3TC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, false); + _save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, can_bptc ? Image::COMPRESS_BPTC : Image::COMPRESS_S3TC, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, false); r_platform_variants->push_back("s3tc"); formats_imported.push_back("s3tc"); ok_on_pc = true; @@ -505,20 +490,20 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) { - _save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, true); + _save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, true); r_platform_variants->push_back("etc2"); formats_imported.push_back("etc2"); } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc")) { - _save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, true); + _save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, true); r_platform_variants->push_back("etc"); formats_imported.push_back("etc"); } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) { - _save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, true); + _save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, true); r_platform_variants->push_back("pvrtc"); formats_imported.push_back("pvrtc"); } @@ -528,7 +513,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } } else { //import normally - _save_stex(image, p_save_path + ".stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, false); + _save_stex(image, p_save_path + ".stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, false); } if (r_metadata) { @@ -609,7 +594,7 @@ ResourceImporterTexture::ResourceImporterTexture() { singleton = this; StreamTexture::request_3d_callback = _texture_reimport_3d; - StreamTexture::request_srgb_callback = _texture_reimport_srgb; + StreamTexture::request_roughness_callback = _texture_reimport_roughness; StreamTexture::request_normal_callback = _texture_reimport_normal; mutex = Mutex::create(); } diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index fbfd47f4f0..acbfde8430 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -33,7 +33,7 @@ #include "core/image.h" #include "core/io/resource_importer.h" - +#include "servers/visual_server.h" class StreamTexture; class ResourceImporterTexture : public ResourceImporter { @@ -42,14 +42,25 @@ class ResourceImporterTexture : public ResourceImporter { protected: enum { MAKE_3D_FLAG = 1, - MAKE_SRGB_FLAG = 2, + MAKE_ROUGHNESS_FLAG = 2, MAKE_NORMAL_FLAG = 4 }; Mutex *mutex; - Map<StringName, int> make_flags; + struct MakeInfo { + + int flags; + String normal_path_for_roughness; + VS::TextureDetectRoughnessChannel channel_for_roughness; + MakeInfo() { + flags = 0; + channel_for_roughness = VS::TEXTURE_DETECT_ROUGNHESS_R; + } + }; + + Map<StringName, MakeInfo> make_flags; - static void _texture_reimport_srgb(const Ref<StreamTexture> &p_tex); + static void _texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, VisualServer::TextureDetectRoughnessChannel p_channel); static void _texture_reimport_3d(const Ref<StreamTexture> &p_tex); static void _texture_reimport_normal(const Ref<StreamTexture> &p_tex); @@ -84,7 +95,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - void _save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal, bool p_force_po2_for_compressed); + void _save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed); virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp index 335e1114e6..00a25ec886 100644 --- a/editor/import/resource_importer_texture_atlas.cpp +++ b/editor/import/resource_importer_texture_atlas.cpp @@ -58,7 +58,7 @@ String ResourceImporterTextureAtlas::get_save_extension() const { String ResourceImporterTextureAtlas::get_resource_type() const { - return "Texture"; + return "Texture2D"; } bool ResourceImporterTextureAtlas::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { @@ -313,7 +313,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file new_atlas->save_png(p_group_file); //update cache if existing, else create - Ref<Texture> cache; + Ref<Texture2D> cache; if (ResourceCache::has(p_group_file)) { Resource *resptr = ResourceCache::get(p_group_file); cache.reference_ptr(resptr); @@ -331,7 +331,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file PackData &pack_data = pack_data_files.write[idx]; - Ref<Texture> texture; + Ref<Texture2D> texture; if (!pack_data.is_mesh) { Vector2 offset = charts[pack_data.chart_pieces[0]].vertices[0] + charts[pack_data.chart_pieces[0]].final_offset; diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index ecd1e341d1..c681cdd033 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -215,7 +215,7 @@ void InspectorDock::_prepare_history() { history_menu->get_popup()->clear(); - Ref<Texture> base_icon = get_icon("Object", "EditorIcons"); + Ref<Texture2D> base_icon = get_icon("Object", "EditorIcons"); Set<ObjectID> already; for (int i = editor_history->get_history_len() - 1; i >= history_to; i--) { @@ -230,7 +230,7 @@ void InspectorDock::_prepare_history() { already.insert(id); - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(obj, ""); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj, ""); if (icon.is_null()) { icon = base_icon; } diff --git a/editor/pane_drag.cpp b/editor/pane_drag.cpp index eef4db456c..b143f86ada 100644 --- a/editor/pane_drag.cpp +++ b/editor/pane_drag.cpp @@ -45,7 +45,7 @@ void PaneDrag::_notification(int p_what) { case NOTIFICATION_DRAW: { - Ref<Texture> icon = mouse_over ? get_icon("PaneDragHover", "EditorIcons") : get_icon("PaneDrag", "EditorIcons"); + Ref<Texture2D> icon = mouse_over ? get_icon("PaneDragHover", "EditorIcons") : get_icon("PaneDrag", "EditorIcons"); if (!icon.is_null()) icon->draw(get_canvas_item(), Point2(0, 0)); @@ -62,7 +62,7 @@ void PaneDrag::_notification(int p_what) { } Size2 PaneDrag::get_minimum_size() const { - Ref<Texture> icon = get_icon("PaneDrag", "EditorIcons"); + Ref<Texture2D> icon = get_icon("PaneDrag", "EditorIcons"); if (!icon.is_null()) return icon->get_size(); return Size2(); diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index c8a36a3a99..f38b95c615 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -573,7 +573,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform(); // All polygon points are sharp, so use the sharp handle icon - const Ref<Texture> handle = get_icon("EditorPathSharpHandle", "EditorIcons"); + const Ref<Texture2D> handle = get_icon("EditorPathSharpHandle", "EditorIcons"); const Vertex active_point = get_active_point(); const int n_polygons = _get_polygon_count(); @@ -661,7 +661,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl if (edge_point.valid()) { - Ref<Texture> add_handle = get_icon("EditorHandleAdd", "EditorIcons"); + Ref<Texture2D> add_handle = get_icon("EditorHandleAdd", "EditorIcons"); p_overlay->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5); } } diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index d743d1ac2f..9261613ddd 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -202,8 +202,8 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { linecolor_soft.a *= 0.5; Ref<Font> font = get_font("font", "Label"); - Ref<Texture> icon = get_icon("KeyValue", "EditorIcons"); - Ref<Texture> icon_selected = get_icon("KeySelected", "EditorIcons"); + Ref<Texture2D> icon = get_icon("KeyValue", "EditorIcons"); + Ref<Texture2D> icon_selected = get_icon("KeySelected", "EditorIcons"); Size2 s = blend_space_draw->get_size(); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index dc7754ba9a..358b763d0c 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -410,8 +410,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { Color linecolor_soft = linecolor; linecolor_soft.a *= 0.5; Ref<Font> font = get_font("font", "Label"); - Ref<Texture> icon = get_icon("KeyValue", "EditorIcons"); - Ref<Texture> icon_selected = get_icon("KeySelected", "EditorIcons"); + Ref<Texture2D> icon = get_icon("KeyValue", "EditorIcons"); + Ref<Texture2D> icon_selected = get_icon("KeySelected", "EditorIcons"); Size2 s = blend_space_draw->get_size(); diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h index 55c2f365ce..ab9db279d5 100644 --- a/editor/plugins/animation_player_editor_plugin.h +++ b/editor/plugins/animation_player_editor_plugin.h @@ -105,7 +105,7 @@ class AnimationPlayerEditor : public VBoxContainer { LineEdit *name; Label *name_title; UndoRedo *undo_redo; - Ref<Texture> autoplay_icon; + Ref<Texture2D> autoplay_icon; bool last_active; float timeline_position; diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 2a582a1249..63c837a216 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -514,7 +514,7 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co accent.a *= 0.6; } - Ref<Texture> icons[6] = { + Ref<Texture2D> icons[6] = { get_icon("TransitionImmediateBig", "EditorIcons"), get_icon("TransitionSyncBig", "EditorIcons"), get_icon("TransitionEndBig", "EditorIcons"), @@ -533,7 +533,7 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co } state_machine_draw->draw_line(p_from, p_to, linecolor, 2, true); - Ref<Texture> icon = icons[p_mode + (p_auto_advance ? 3 : 0)]; + Ref<Texture2D> icon = icons[p_mode + (p_auto_advance ? 3 : 0)]; Transform2D xf; xf.elements[0] = (p_to - p_from).normalized(); @@ -578,9 +578,9 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { Ref<Font> font = get_font("title_font", "GraphNode"); Color font_color = get_color("title_color", "GraphNode"); - Ref<Texture> play = get_icon("Play", "EditorIcons"); - Ref<Texture> auto_play = get_icon("AutoPlay", "EditorIcons"); - Ref<Texture> edit = get_icon("Edit", "EditorIcons"); + Ref<Texture2D> play = get_icon("Play", "EditorIcons"); + Ref<Texture2D> auto_play = get_icon("AutoPlay", "EditorIcons"); + Ref<Texture2D> edit = get_icon("Edit", "EditorIcons"); Color accent = get_color("accent_color", "Editor"); Color linecolor = get_color("font_color", "Label"); linecolor.a *= 0.3; @@ -686,7 +686,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { _connection_draw(from, to, AnimationNodeStateMachineTransition::SwitchMode(transition_mode->get_selected()), true, false, false, false); } - Ref<Texture> tr_reference_icon = get_icon("TransitionImmediateBig", "EditorIcons"); + Ref<Texture2D> tr_reference_icon = get_icon("TransitionImmediateBig", "EditorIcons"); float tr_bidi_offset = int(tr_reference_icon->get_height() * 0.8); //draw transition lines @@ -796,7 +796,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { nr.play.position = offset + Vector2(0, (h - play->get_height()) / 2).floor(); nr.play.size = play->get_size(); - Ref<Texture> play_tex = onstart ? auto_play : play; + Ref<Texture2D> play_tex = onstart ? auto_play : play; if (over_node == name && over_node_what == 0) { state_machine_draw->draw_texture(play_tex, nr.play.position, accent); @@ -918,14 +918,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { transition_mode->add_icon_item(get_icon("TransitionSync", "EditorIcons"), TTR("Sync")); transition_mode->add_icon_item(get_icon("TransitionEnd", "EditorIcons"), TTR("At End")); - //force filter on those, so they deform better - get_icon("TransitionImmediateBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER); - get_icon("TransitionEndBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER); - get_icon("TransitionSyncBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER); - get_icon("TransitionImmediateAutoBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER); - get_icon("TransitionEndAutoBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER); - get_icon("TransitionSyncAutoBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER); - tool_erase->set_icon(get_icon("Remove", "EditorIcons")); tool_autoplay->set_icon(get_icon("AutoPlay", "EditorIcons")); tool_end->set_icon(get_icon("AutoEnd", "EditorIcons")); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index d88a716122..a479703527 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -50,7 +50,7 @@ void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, co price->set_text(p_cost); } -void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture> &p_image) { +void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture2D> &p_image) { ERR_FAIL_COND(p_type != EditorAssetLibrary::IMAGE_QUEUE_ICON); ERR_FAIL_COND(p_index != 0); @@ -145,7 +145,7 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() { ////////////////////////////////////////////////////////////////////////////// -void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const Ref<Texture> &p_image) { +void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const Ref<Texture2D> &p_image) { switch (p_type) { @@ -393,7 +393,7 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int set_process(false); } -void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asset_id, const Ref<Texture> &p_preview, const String &p_download_url, const String &p_sha256_hash) { +void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asset_id, const Ref<Texture2D> &p_preview, const String &p_download_url, const String &p_sha256_hash) { title->set_text(p_title); icon->set_texture(p_preview); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index 8852125b8b..e13d8a6149 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -68,7 +68,7 @@ class EditorAssetLibraryItem : public PanelContainer { void _category_clicked(); void _author_clicked(); - void set_image(int p_type, int p_index, const Ref<Texture> &p_image); + void set_image(int p_type, int p_index, const Ref<Texture2D> &p_image); protected: void _notification(int p_what); @@ -95,19 +95,19 @@ class EditorAssetLibraryItemDescription : public ConfirmationDialog { bool is_video; String video_link; Button *button; - Ref<Texture> image; + Ref<Texture2D> image; }; Vector<Preview> preview_images; TextureRect *preview; - void set_image(int p_type, int p_index, const Ref<Texture> &p_image); + void set_image(int p_type, int p_index, const Ref<Texture2D> &p_image); int asset_id; String download_url; String title; String sha256; - Ref<Texture> icon; + Ref<Texture2D> icon; void _link_click(const String &p_url); void _preview_click(int p_id); @@ -121,7 +121,7 @@ public: void add_preview(int p_id, bool p_video, const String &p_url); String get_title() { return title; } - Ref<Texture> get_preview_icon() { return icon; } + Ref<Texture2D> get_preview_icon() { return icon; } String get_download_url() { return download_url; } int get_asset_id() { return asset_id; } String get_sha256() { return sha256; } @@ -165,7 +165,7 @@ protected: public: void set_external_install(bool p_enable) { external_install = p_enable; } int get_asset_id() { return asset_id; } - void configure(const String &p_title, int p_asset_id, const Ref<Texture> &p_preview, const String &p_download_url, const String &p_sha256_hash); + void configure(const String &p_title, int p_asset_id, const Ref<Texture2D> &p_preview, const String &p_download_url, const String &p_sha256_hash); EditorAssetLibraryItemDownload(); }; diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index ab816dc7f3..11c188dca4 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -2244,7 +2244,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { for (int i = 0; i < selection_results.size(); i++) { CanvasItem *item = selection_results[i].item; - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(item, "Node"); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(item, "Node"); String node_path = "/" + root_name + "/" + root_path.rel_path_to(item->get_path()); int locked = 0; @@ -2966,7 +2966,7 @@ void CanvasItemEditor::_draw_ruler_tool() { } else { if (grid_snap_active) { - Ref<Texture> position_icon = get_icon("EditorPosition", "EditorIcons"); + Ref<Texture2D> position_icon = get_icon("EditorPosition", "EditorIcons"); viewport->draw_texture(get_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); } } @@ -3179,9 +3179,9 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { } void CanvasItemEditor::_draw_selection() { - Ref<Texture> pivot_icon = get_icon("EditorPivot", "EditorIcons"); - Ref<Texture> position_icon = get_icon("EditorPosition", "EditorIcons"); - Ref<Texture> previous_position_icon = get_icon("EditorPositionPrevious", "EditorIcons"); + Ref<Texture2D> pivot_icon = get_icon("EditorPivot", "EditorIcons"); + Ref<Texture2D> position_icon = get_icon("EditorPosition", "EditorIcons"); + Ref<Texture2D> previous_position_icon = get_icon("EditorPositionPrevious", "EditorIcons"); RID ci = viewport->get_canvas_item(); @@ -3540,7 +3540,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans Transform2D xform = transform * canvas_xform * parent_xform; // Draw the node's position - Ref<Texture> position_icon = get_icon("EditorPositionUnselected", "EditorIcons"); + Ref<Texture2D> position_icon = get_icon("EditorPositionUnselected", "EditorIcons"); Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; viewport->draw_set_transform_matrix(simple_xform); @@ -3554,7 +3554,7 @@ void CanvasItemEditor::_draw_hover() { for (int i = 0; i < hovering_results.size(); i++) { - Ref<Texture> node_icon = hovering_results[i].icon; + Ref<Texture2D> node_icon = hovering_results[i].icon; String node_name = hovering_results[i].name; Ref<Font> font = get_font("font", "Label"); @@ -3608,13 +3608,13 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p if (canvas_item) { float offset = 0; - Ref<Texture> lock = get_icon("LockViewport", "EditorIcons"); + Ref<Texture2D> lock = get_icon("LockViewport", "EditorIcons"); if (p_node->has_meta("_edit_lock_") && show_edit_locks) { lock->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); offset += lock->get_size().x; } - Ref<Texture> group = get_icon("GroupViewport", "EditorIcons"); + Ref<Texture2D> group = get_icon("GroupViewport", "EditorIcons"); if (canvas_item->has_meta("_edit_group_") && show_edit_locks) { group->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); //offset += group->get_size().x; @@ -5887,7 +5887,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons String path = files[i]; RES res = ResourceLoader::load(path); ERR_FAIL_COND(res.is_null()); - Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); + Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); if (texture != NULL || scene != NULL) { if (texture != NULL) { @@ -5944,7 +5944,7 @@ bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String &p_targe void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point) { child->set_name(path.get_file().get_basename()); - Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(ResourceCache::get(path))); + Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(ResourceCache::get(path))); Size2 texture_size = texture->get_size(); if (parent) { @@ -6081,7 +6081,7 @@ void CanvasItemEditorViewport::_perform_drop_data() { } } } else { - Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); + Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); if (texture != NULL && texture.is_valid()) { Node *child; if (default_type == "Light2D") @@ -6136,7 +6136,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian continue; } memdelete(instanced_scene); - } else if (type == "Texture" || + } else if (type == "Texture2D" || type == "ImageTexture" || type == "ViewportTexture" || type == "CurveTexture" || @@ -6144,7 +6144,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian type == "StreamTexture" || type == "AtlasTexture" || type == "LargeTexture") { - Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); + Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); if (!texture.is_valid()) { continue; } diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index eb6e621c93..3c4cacf5c8 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -306,7 +306,7 @@ private: struct _HoverResult { Point2 position; - Ref<Texture> icon; + Ref<Texture2D> icon; String name; }; Vector<_HoverResult> hovering_results; @@ -406,8 +406,8 @@ private: Point2 box_selecting_to; Ref<StyleBoxTexture> select_sb; - Ref<Texture> select_handle; - Ref<Texture> anchor_handle; + Ref<Texture2D> select_handle; + Ref<Texture2D> anchor_handle; Ref<ShortCut> drag_pivot_shortcut; Ref<ShortCut> set_pivot_shortcut; diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 8620437ac6..f2b4fdfdf1 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -384,7 +384,7 @@ void Polygon3DEditor::_polygon_draw() { imgeom->clear(); imgeom->set_material_override(line_material); - imgeom->begin(Mesh::PRIMITIVE_LINES, Ref<Texture>()); + imgeom->begin(Mesh::PRIMITIVE_LINES, Ref<Texture2D>()); Rect2 rect; @@ -561,7 +561,7 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) { handle_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); handle_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); handle_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - Ref<Texture> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons"); + Ref<Texture2D> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons"); handle_material->set_point_size(handle->get_width()); handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle); diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index 179ebca562..01b4a61a85 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -435,7 +435,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - Ref<Texture> h = get_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> h = get_icon("EditorHandle", "EditorIcons"); Vector2 size = h->get_size() * 0.5; handles.clear(); diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index a4fc9b37ad..6438b3e6a8 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -787,10 +787,10 @@ bool CurvePreviewGenerator::handles(const String &p_type) const { return p_type == "Curve"; } -Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const { +Ref<Texture2D> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const { Ref<Curve> curve_ref = p_from; - ERR_FAIL_COND_V_MSG(curve_ref.is_null(), Ref<Texture>(), "It's not a reference to a valid Resource object."); + ERR_FAIL_COND_V_MSG(curve_ref.is_null(), Ref<Texture2D>(), "It's not a reference to a valid Resource object."); Curve &curve = **curve_ref; // FIXME: Should be ported to use p_size as done in b2633a97 @@ -848,6 +848,6 @@ Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img_ref, 0); + ptex->create_from_image(img_ref); return ptex; } diff --git a/editor/plugins/curve_editor_plugin.h b/editor/plugins/curve_editor_plugin.h index 06e2692373..c00aa3eca5 100644 --- a/editor/plugins/curve_editor_plugin.h +++ b/editor/plugins/curve_editor_plugin.h @@ -141,7 +141,7 @@ class CurvePreviewGenerator : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const Ref<Resource> &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const; }; #endif // CURVE_EDITOR_PLUGIN_H diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 9b0d5d3daf..2037c17b89 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -76,34 +76,34 @@ void post_process_preview(Ref<Image> p_image) { bool EditorTexturePreviewPlugin::handles(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture"); + return ClassDB::is_parent_class(p_type, "Texture2D"); } bool EditorTexturePreviewPlugin::generate_small_preview_automatically() const { return true; } -Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<Image> img; Ref<AtlasTexture> atex = p_from; Ref<LargeTexture> ltex = p_from; if (atex.is_valid()) { - Ref<Texture> tex = atex->get_atlas(); + Ref<Texture2D> tex = atex->get_atlas(); if (!tex.is_valid()) { - return Ref<Texture>(); + return Ref<Texture2D>(); } Ref<Image> atlas = tex->get_data(); if (!atlas.is_valid()) { - return Ref<Texture>(); + return Ref<Texture2D>(); } img = atlas->get_rect(atex->get_region()); } else if (ltex.is_valid()) { img = ltex->to_image(); } else { - Ref<Texture> tex = p_from; + Ref<Texture2D> tex = p_from; if (tex.is_valid()) { img = tex->get_data(); if (img.is_valid()) { @@ -113,13 +113,13 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 } if (img.is_null() || img->empty()) - return Ref<Texture>(); + return Ref<Texture2D>(); img->clear_mipmaps(); if (img->is_compressed()) { if (img->decompress() != OK) - return Ref<Texture>(); + return Ref<Texture2D>(); } else if (img->get_format() != Image::FORMAT_RGB8 && img->get_format() != Image::FORMAT_RGBA8) { img->convert(Image::FORMAT_RGBA8); } @@ -137,7 +137,7 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } @@ -151,7 +151,7 @@ bool EditorImagePreviewPlugin::handles(const String &p_type) const { return p_type == "Image"; } -Ref<Texture> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<Image> img = p_from; @@ -182,7 +182,7 @@ Ref<Texture> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 & Ref<ImageTexture> ptex; ptex.instance(); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } @@ -199,12 +199,12 @@ bool EditorBitmapPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "BitMap"); } -Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<BitMap> bm = p_from; if (bm->get_size() == Size2()) { - return Ref<Texture>(); + return Ref<Texture2D>(); } PoolVector<uint8_t> data; @@ -231,7 +231,7 @@ Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 if (img->is_compressed()) { if (img->decompress() != OK) - return Ref<Texture>(); + return Ref<Texture2D>(); } else if (img->get_format() != Image::FORMAT_RGB8 && img->get_format() != Image::FORMAT_RGBA8) { img->convert(Image::FORMAT_RGBA8); } @@ -249,7 +249,7 @@ Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } @@ -266,12 +266,13 @@ bool EditorPackedScenePreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "PackedScene"); } -Ref<Texture> EditorPackedScenePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { + +Ref<Texture2D> EditorPackedScenePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { return generate_from_path(p_from->get_path(), p_size); } -Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const { +Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const { String temp_path = EditorSettings::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(p_path).md5_text(); @@ -282,7 +283,7 @@ Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_ String path = cache_base + ".png"; if (!FileAccess::exists(path)) - return Ref<Texture>(); + return Ref<Texture2D>(); Ref<Image> img; img.instance(); @@ -292,11 +293,11 @@ Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_ Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); post_process_preview(img); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } else { - return Ref<Texture>(); + return Ref<Texture2D>(); } } @@ -324,10 +325,10 @@ bool EditorMaterialPreviewPlugin::generate_small_preview_automatically() const { return true; } -Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<Material> material = p_from; - ERR_FAIL_COND_V(material.is_null(), Ref<Texture>()); + ERR_FAIL_COND_V(material.is_null(), Ref<Texture2D>()); if (material->get_shader_mode() == Shader::MODE_SPATIAL) { @@ -342,7 +343,7 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size OS::get_singleton()->delay_usec(10); } - Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); + Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); VS::get_singleton()->mesh_surface_set_material(sphere, 0, RID()); ERR_FAIL_COND_V(!img.is_valid(), Ref<ImageTexture>()); @@ -352,11 +353,11 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size img->resize(thumbnail_size, thumbnail_size, Image::INTERPOLATE_CUBIC); post_process_preview(img); Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } - return Ref<Texture>(); + return Ref<Texture2D>(); } EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { @@ -490,15 +491,15 @@ bool EditorScriptPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "Script"); } -Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<Script> scr = p_from; if (scr.is_null()) - return Ref<Texture>(); + return Ref<Texture2D>(); String code = scr->get_source_code().strip_edges(); if (code == "") - return Ref<Texture>(); + return Ref<Texture2D>(); List<String> kwors; scr->get_language()->get_reserved_words(&kwors); @@ -599,7 +600,7 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } @@ -612,10 +613,10 @@ bool EditorAudioStreamPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "AudioStream"); } -Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<AudioStream> stream = p_from; - ERR_FAIL_COND_V(stream.is_null(), Ref<Texture>()); + ERR_FAIL_COND_V(stream.is_null(), Ref<Texture2D>()); PoolVector<uint8_t> img; @@ -627,7 +628,7 @@ Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const S uint8_t *imgw = imgdata.ptr(); Ref<AudioStreamPlayback> playback = stream->instance_playback(); - ERR_FAIL_COND_V(playback.is_null(), Ref<Texture>()); + ERR_FAIL_COND_V(playback.is_null(), Ref<Texture2D>()); float len_s = stream->get_length(); if (len_s == 0) { @@ -687,7 +688,7 @@ Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const S Ref<Image> image; image.instance(); image->create(w, h, false, Image::FORMAT_RGB8, img); - ptex->create_from_image(image, 0); + ptex->create_from_image(image); return ptex; } @@ -710,10 +711,10 @@ bool EditorMeshPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "Mesh"); //any Mesh } -Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { Ref<Mesh> mesh = p_from; - ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture>()); + ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture2D>()); VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid()); @@ -726,7 +727,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p AABB rot_aabb = xform.xform(aabb); float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5; if (m == 0) - return Ref<Texture>(); + return Ref<Texture2D>(); m = 1.0 / m; m *= 0.5; xform.basis.scale(Vector3(m, m, m)); @@ -743,7 +744,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p OS::get_singleton()->delay_usec(10); } - Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); + Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); VS::get_singleton()->instance_set_base(mesh_instance, RID()); @@ -762,7 +763,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p post_process_preview(img); Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } @@ -831,7 +832,7 @@ bool EditorFontPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "DynamicFontData") || ClassDB::is_parent_class(p_type, "DynamicFont"); } -Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const { +Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const { RES res = ResourceLoader::load(p_path); Ref<DynamicFont> sampled_font; @@ -868,7 +869,7 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c VS::get_singleton()->canvas_item_clear(canvas_item); - Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); + Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); img->convert(Image::FORMAT_RGBA8); @@ -885,16 +886,16 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c post_process_preview(img); Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); + ptex->create_from_image(img); return ptex; } -Ref<Texture> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { +Ref<Texture2D> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { String path = p_from->get_path(); if (!FileAccess::exists(path)) { - return Ref<Texture>(); + return Ref<Texture2D>(); } return generate_from_path(path, p_size); } diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h index e6e4aff8de..840fa2410a 100644 --- a/editor/plugins/editor_preview_plugins.h +++ b/editor/plugins/editor_preview_plugins.h @@ -41,7 +41,7 @@ class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; virtual bool generate_small_preview_automatically() const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorTexturePreviewPlugin(); }; @@ -52,7 +52,7 @@ class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; virtual bool generate_small_preview_automatically() const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorImagePreviewPlugin(); }; @@ -63,7 +63,7 @@ class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; virtual bool generate_small_preview_automatically() const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorBitmapPreviewPlugin(); }; @@ -72,8 +72,8 @@ class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; - virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const; EditorPackedScenePreviewPlugin(); }; @@ -102,7 +102,7 @@ protected: public: virtual bool handles(const String &p_type) const; virtual bool generate_small_preview_automatically() const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorMaterialPreviewPlugin(); ~EditorMaterialPreviewPlugin(); @@ -111,7 +111,7 @@ public: class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorScriptPreviewPlugin(); }; @@ -119,7 +119,7 @@ public: class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator { public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorAudioStreamPreviewPlugin(); }; @@ -146,7 +146,7 @@ protected: public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; EditorMeshPreviewPlugin(); ~EditorMeshPreviewPlugin(); @@ -169,8 +169,8 @@ protected: public: virtual bool handles(const String &p_type) const; - virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; - virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const; + virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; + virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const; EditorFontPreviewPlugin(); ~EditorFontPreviewPlugin(); diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index 9f836ed0d3..b7dfe97081 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -105,7 +105,7 @@ void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const { String base = itos(i) + "/"; p_list->push_back(PropertyInfo(Variant::STRING, base + "text")); - p_list->push_back(PropertyInfo(Variant::OBJECT, base + "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture")); + p_list->push_back(PropertyInfo(Variant::OBJECT, base + "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D")); int flags = get_flags(); diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h index 8a73367bf7..8dcf938139 100644 --- a/editor/plugins/item_list_editor_plugin.h +++ b/editor/plugins/item_list_editor_plugin.h @@ -66,8 +66,8 @@ public: virtual void set_item_text(int p_idx, const String &p_text) {} virtual String get_item_text(int p_idx) const { return ""; }; - virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) {} - virtual Ref<Texture> get_item_icon(int p_idx) const { return Ref<Texture>(); }; + virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) {} + virtual Ref<Texture2D> get_item_icon(int p_idx) const { return Ref<Texture2D>(); }; virtual void set_item_checkable(int p_idx, bool p_check) {} virtual void set_item_radio_checkable(int p_idx, bool p_check) {} @@ -109,8 +109,8 @@ public: virtual void set_item_text(int p_idx, const String &p_text) { ob->set_item_text(p_idx, p_text); } virtual String get_item_text(int p_idx) const { return ob->get_item_text(p_idx); } - virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { ob->set_item_icon(p_idx, p_tex); } - virtual Ref<Texture> get_item_icon(int p_idx) const { return ob->get_item_icon(p_idx); } + virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) { ob->set_item_icon(p_idx, p_tex); } + virtual Ref<Texture2D> get_item_icon(int p_idx) const { return ob->get_item_icon(p_idx); } virtual void set_item_enabled(int p_idx, int p_enabled) { ob->set_item_disabled(p_idx, !p_enabled); } virtual bool is_item_enabled(int p_idx) const { return !ob->is_item_disabled(p_idx); } @@ -139,8 +139,8 @@ public: virtual void set_item_text(int p_idx, const String &p_text) { pp->set_item_text(p_idx, p_text); } virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); } - virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { pp->set_item_icon(p_idx, p_tex); } - virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); } + virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) { pp->set_item_icon(p_idx, p_tex); } + virtual Ref<Texture2D> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); } virtual void set_item_checkable(int p_idx, bool p_check) { pp->set_item_as_checkable(p_idx, p_check); } virtual void set_item_radio_checkable(int p_idx, bool p_check) { pp->set_item_as_radio_checkable(p_idx, p_check); } @@ -182,8 +182,8 @@ public: virtual void set_item_text(int p_idx, const String &p_text) { pp->set_item_text(p_idx, p_text); } virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); } - virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { pp->set_item_icon(p_idx, p_tex); } - virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); } + virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) { pp->set_item_icon(p_idx, p_tex); } + virtual Ref<Texture2D> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); } virtual void set_item_enabled(int p_idx, int p_enabled) { pp->set_item_disabled(p_idx, !p_enabled); } virtual bool is_item_enabled(int p_idx) const { return !pp->is_item_disabled(p_idx); } diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 750f814319..7895c31778 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -59,7 +59,7 @@ void MaterialEditor::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> checkerboard = get_icon("Checkerboard", "EditorIcons"); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); @@ -268,7 +268,7 @@ Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_re // Texture parameter has to be treated specially since SpatialMaterial saved it // as RID but ShaderMaterial needs Texture itself - Ref<Texture> texture = mat->get_texture_by_name(E->get().name); + Ref<Texture2D> texture = mat->get_texture_by_name(E->get().name); if (texture.is_valid()) { smat->set_shader_param(E->get().name, texture); } else { diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 42859e9190..b77cb6453f 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -182,7 +182,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, } } - Vector<Ref<Texture> > textures = EditorInterface::get_singleton()->make_mesh_previews(meshes, &transforms, EditorSettings::get_singleton()->get("editors/grid_map/preview_size")); + Vector<Ref<Texture2D> > textures = EditorInterface::get_singleton()->make_mesh_previews(meshes, &transforms, EditorSettings::get_singleton()->get("editors/grid_map/preview_size")); int j = 0; for (int i = 0; i < ids.size(); i++) { diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp index b036368bc8..3a48673d8e 100644 --- a/editor/plugins/particles_2d_editor_plugin.cpp +++ b/editor/plugins/particles_2d_editor_plugin.cpp @@ -292,7 +292,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() { Ref<ImageTexture> imgt; imgt.instance(); - imgt->create_from_image(img, 0); + imgt->create_from_image(img); pm->set_emission_point_texture(imgt); pm->set_emission_point_count(vpc); @@ -314,7 +314,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() { img->create(w, h, false, Image::FORMAT_RGBA8, colordata); imgt.instance(); - imgt->create_from_image(img, 0); + imgt->create_from_image(img); pm->set_emission_color_texture(imgt); } @@ -337,7 +337,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() { img->create(w, h, false, Image::FORMAT_RGF, normdata); imgt.instance(); - imgt->create_from_image(img, 0); + imgt->create_from_image(img); pm->set_emission_normal_texture(imgt); } else { diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index f869dabf9a..cb29e11b9d 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -410,7 +410,6 @@ void ParticlesEditor::_generate_emission_points() { Ref<ImageTexture> tex; tex.instance(); - tex->create_from_image(image, Texture::FLAG_FILTER); Ref<ParticlesMaterial> material = node->get_process_material(); ERR_FAIL_COND(material.is_null()); @@ -440,7 +439,6 @@ void ParticlesEditor::_generate_emission_points() { Ref<ImageTexture> tex2; tex2.instance(); - tex2->create_from_image(image2, Texture::FLAG_FILTER); material->set_emission_normal_texture(tex2); } else { diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 3737dbdd57..9c5b7ecd01 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -373,12 +373,12 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - const Ref<Texture> path_sharp_handle = get_icon("EditorPathSharpHandle", "EditorIcons"); - const Ref<Texture> path_smooth_handle = get_icon("EditorPathSmoothHandle", "EditorIcons"); + const Ref<Texture2D> path_sharp_handle = get_icon("EditorPathSharpHandle", "EditorIcons"); + const Ref<Texture2D> path_smooth_handle = get_icon("EditorPathSmoothHandle", "EditorIcons"); // Both handle icons must be of the same size const Size2 handle_size = path_sharp_handle->get_size(); - const Ref<Texture> curve_handle = get_icon("EditorCurveHandle", "EditorIcons"); + const Ref<Texture2D> curve_handle = get_icon("EditorCurveHandle", "EditorIcons"); const Size2 curve_handle_size = curve_handle->get_size(); Ref<Curve2D> curve = node->get_curve(); @@ -420,7 +420,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } if (on_edge) { - Ref<Texture> add_handle = get_icon("EditorHandleAdd", "EditorIcons"); + Ref<Texture2D> add_handle = get_icon("EditorHandleAdd", "EditorIcons"); p_overlay->draw_texture(add_handle, edge_point - add_handle->get_size() * 0.5); } } diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 35c0142d4b..4cd30a5242 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -980,7 +980,7 @@ void Polygon2DEditor::_uv_draw() { if (!uv_edit->is_visible() || !_get_node()) return; - Ref<Texture> base_tex = node->get_texture(); + Ref<Texture2D> base_tex = node->get_texture(); if (base_tex.is_null()) return; @@ -1050,7 +1050,7 @@ void Polygon2DEditor::_uv_draw() { } // All UV points are sharp, so use the sharp handle icon - Ref<Texture> handle = get_icon("EditorPathSharpHandle", "EditorIcons"); + Ref<Texture2D> handle = get_icon("EditorPathSharpHandle", "EditorIcons"); Color poly_line_color = Color(0.9, 0.5, 0.5); if (polygons.size() || polygon_create.size()) { diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index 3489537fa4..1349de5d8e 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -205,7 +205,7 @@ void EditorPropertyRootMotion::update_property() { assign->set_tooltip(p); if (p == NodePath()) { - assign->set_icon(Ref<Texture>()); + assign->set_icon(Ref<Texture2D>()); assign->set_text(TTR("Assign...")); assign->set_flat(false); return; @@ -222,7 +222,7 @@ void EditorPropertyRootMotion::update_property() { } if (!base_node || !base_node->has_node(p)) { - assign->set_icon(Ref<Texture>()); + assign->set_icon(Ref<Texture2D>()); assign->set_text(p); return; } @@ -242,7 +242,7 @@ void EditorPropertyRootMotion::setup(const NodePath &p_base_hint) { void EditorPropertyRootMotion::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture> t = get_icon("Clear", "EditorIcons"); + Ref<Texture2D> t = get_icon("Clear", "EditorIcons"); clear->set_icon(t); } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 1da47196f8..078c1e9238 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1647,7 +1647,7 @@ struct _ScriptEditorItemData { String name; String sort_key; - Ref<Texture> icon; + Ref<Texture2D> icon; int index; String tooltip; bool used; @@ -1832,7 +1832,7 @@ void ScriptEditor::_update_script_names() { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (se) { - Ref<Texture> icon = se->get_icon(); + Ref<Texture2D> icon = se->get_icon(); String path = se->get_edited_resource()->get_path(); bool built_in = !path.is_resource_file(); String name; @@ -1893,7 +1893,7 @@ void ScriptEditor::_update_script_names() { if (eh) { String name = eh->get_class(); - Ref<Texture> icon = get_icon("Help", "EditorIcons"); + Ref<Texture2D> icon = get_icon("Help", "EditorIcons"); String tooltip = vformat(TTR("%s Class Reference"), name); _ScriptEditorItemData sd; @@ -2416,7 +2416,7 @@ Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { HBoxContainer *drag_preview = memnew(HBoxContainer); String preview_name = ""; - Ref<Texture> preview_icon; + Ref<Texture2D> preview_icon; ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(cur_node); if (se) { diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index a41480c80d..3fb67c7ecc 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -92,7 +92,7 @@ public: virtual void set_edited_resource(const RES &p_res) = 0; virtual void reload_text() = 0; virtual String get_name() = 0; - virtual Ref<Texture> get_icon() = 0; + virtual Ref<Texture2D> get_icon() = 0; virtual bool is_unsaved() = 0; virtual Variant get_edit_state() = 0; virtual void set_edit_state(const Variant &p_state) = 0; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 1432c3fc63..3a49538542 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -548,13 +548,13 @@ String ScriptTextEditor::get_name() { return name; } -Ref<Texture> ScriptTextEditor::get_icon() { +Ref<Texture2D> ScriptTextEditor::get_icon() { if (get_parent_control() && get_parent_control()->has_icon(script->get_class(), "EditorIcons")) { return get_parent_control()->get_icon(script->get_class(), "EditorIcons"); } - return Ref<Texture>(); + return Ref<Texture2D>(); } void ScriptTextEditor::_validate_script() { diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 9018e9d3c2..39c9d519eb 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -199,7 +199,7 @@ public: virtual Vector<String> get_functions(); virtual void reload_text(); virtual String get_name(); - virtual Ref<Texture> get_icon(); + virtual Ref<Texture2D> get_icon(); virtual bool is_unsaved(); virtual Variant get_edit_state(); virtual void set_edit_state(const Variant &p_state); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 8f7ff04b2c..5ff344166a 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -864,7 +864,7 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) { Spatial *spat = selection_results[i].item; - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node"); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node"); String node_path = "/" + root_name + "/" + root_path.rel_path_to(spat->get_path()); @@ -2371,7 +2371,7 @@ void SpatialEditorViewport::_notification(int p_what) { } } -static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture> icon) { +static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture2D> icon) { // Adjust bar size from control height Vector2 surface_size = surface.get_size(); @@ -3841,12 +3841,12 @@ void SpatialEditorViewportContainer::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW && mouseover) { - Ref<Texture> h_grabber = get_icon("grabber", "HSplitContainer"); - Ref<Texture> v_grabber = get_icon("grabber", "VSplitContainer"); + Ref<Texture2D> h_grabber = get_icon("grabber", "HSplitContainer"); + Ref<Texture2D> v_grabber = get_icon("grabber", "VSplitContainer"); - Ref<Texture> hdiag_grabber = get_icon("GuiViewportHdiagsplitter", "EditorIcons"); - Ref<Texture> vdiag_grabber = get_icon("GuiViewportVdiagsplitter", "EditorIcons"); - Ref<Texture> vh_grabber = get_icon("GuiViewportVhsplitter", "EditorIcons"); + Ref<Texture2D> hdiag_grabber = get_icon("GuiViewportHdiagsplitter", "EditorIcons"); + Ref<Texture2D> vdiag_grabber = get_icon("GuiViewportVdiagsplitter", "EditorIcons"); + Ref<Texture2D> vh_grabber = get_icon("GuiViewportVhsplitter", "EditorIcons"); Vector2 size = get_size(); @@ -6181,7 +6181,7 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color materials[p_name] = mats; } -void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top, const Color &p_albedo) { +void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) { Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6)); @@ -6227,7 +6227,7 @@ void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true); - Ref<Texture> handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons"); + Ref<Texture2D> handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons"); handle_material->set_point_size(handle_t->get_width()); handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle_t); handle_material->set_albedo(Color(1, 1, 1)); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 269e1715ef..f82d796cda 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -785,7 +785,7 @@ protected: public: void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false); - void create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1)); + void create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1)); void create_handle_material(const String &p_name, bool p_billboard = false); void add_material(const String &p_name, Ref<SpatialMaterial> p_material); diff --git a/editor/plugins/sprite_editor_plugin.cpp b/editor/plugins/sprite_editor_plugin.cpp index 6757b180a3..9fd9fefee6 100644 --- a/editor/plugins/sprite_editor_plugin.cpp +++ b/editor/plugins/sprite_editor_plugin.cpp @@ -167,7 +167,7 @@ void SpriteEditor::_menu_option(int p_option) { void SpriteEditor::_update_mesh_data() { - Ref<Texture> texture = node->get_texture(); + Ref<Texture2D> texture = node->get_texture(); if (texture.is_null()) { err_dialog->set_text(TTR("Sprite is empty!")); err_dialog->popup_centered_minsize(); @@ -476,7 +476,7 @@ void SpriteEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node) void SpriteEditor::_debug_uv_draw() { - Ref<Texture> tex = node->get_texture(); + Ref<Texture2D> tex = node->get_texture(); ERR_FAIL_COND(!tex.is_valid()); Point2 draw_pos_offset = Point2(1.0, 1.0); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 4101980e29..2d756af213 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -44,7 +44,7 @@ void SpriteFramesEditor::_open_sprite_sheet() { file_split_sheet->clear_filters(); List<String> extensions; - ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions); + ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions); for (int i = 0; i < extensions.size(); i++) { file_split_sheet->add_filter("*." + extensions[i]); } @@ -249,11 +249,11 @@ void SpriteFramesEditor::_file_load_request(const PoolVector<String> &p_path, in ERR_FAIL_COND(!frames->has_animation(edited_anim)); - List<Ref<Texture> > resources; + List<Ref<Texture2D> > resources; for (int i = 0; i < p_path.size(); i++) { - Ref<Texture> resource; + Ref<Texture2D> resource; resource = ResourceLoader::load(p_path[i]); if (resource.is_null()) { @@ -278,7 +278,7 @@ void SpriteFramesEditor::_file_load_request(const PoolVector<String> &p_path, in int count = 0; - for (List<Ref<Texture> >::Element *E = resources.front(); E; E = E->next()) { + for (List<Ref<Texture2D> >::Element *E = resources.front(); E; E = E->next()) { undo_redo->add_do_method(frames, "add_frame", edited_anim, E->get(), p_at_pos == -1 ? -1 : p_at_pos + count); undo_redo->add_undo_method(frames, "remove_frame", edited_anim, p_at_pos == -1 ? fc : p_at_pos); @@ -297,7 +297,7 @@ void SpriteFramesEditor::_load_pressed() { file->clear_filters(); List<String> extensions; - ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions); + ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions); for (int i = 0; i < extensions.size(); i++) file->add_filter("*." + extensions[i]); @@ -310,7 +310,7 @@ void SpriteFramesEditor::_paste_pressed() { ERR_FAIL_COND(!frames->has_animation(edited_anim)); - Ref<Texture> r = EditorSettings::get_singleton()->get_resource_clipboard(); + Ref<Texture2D> r = EditorSettings::get_singleton()->get_resource_clipboard(); if (!r.is_valid()) { dialog->set_text(TTR("Resource clipboard is empty or not a texture!")); dialog->set_title(TTR("Error!")); @@ -333,7 +333,7 @@ void SpriteFramesEditor::_copy_pressed() { if (tree->get_current() < 0) return; - Ref<Texture> r = frames->get_frame(edited_anim, tree->get_current()); + Ref<Texture2D> r = frames->get_frame(edited_anim, tree->get_current()); if (!r.is_valid()) { return; } @@ -356,7 +356,7 @@ void SpriteFramesEditor::_empty_pressed() { from = frames->get_frame_count(edited_anim); } - Ref<Texture> r; + Ref<Texture2D> r; undo_redo->create_action(TTR("Add Empty")); undo_redo->add_do_method(frames, "add_frame", edited_anim, r, from); @@ -381,7 +381,7 @@ void SpriteFramesEditor::_empty2_pressed() { from = frames->get_frame_count(edited_anim); } - Ref<Texture> r; + Ref<Texture2D> r; undo_redo->create_action(TTR("Add Empty")); undo_redo->add_do_method(frames, "add_frame", edited_anim, r, from + 1); @@ -603,7 +603,7 @@ void SpriteFramesEditor::_animation_remove_confirmed() { undo_redo->add_undo_method(frames, "set_animation_loop", edited_anim, frames->get_animation_loop(edited_anim)); int fc = frames->get_frame_count(edited_anim); for (int i = 0; i < fc; i++) { - Ref<Texture> frame = frames->get_frame(edited_anim, i); + Ref<Texture2D> frame = frames->get_frame(edited_anim, i); undo_redo->add_undo_method(frames, "add_frame", edited_anim, frame); } undo_redo->add_do_method(this, "_update_library"); @@ -688,7 +688,7 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { for (int i = 0; i < frames->get_frame_count(edited_anim); i++) { String name; - Ref<Texture> icon; + Ref<Texture2D> icon; if (frames->get_frame(edited_anim, i).is_null()) { @@ -775,7 +775,7 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant & if (String(d["type"]) == "resource" && d.has("resource")) { RES r = d["resource"]; - Ref<Texture> texture = r; + Ref<Texture2D> texture = r; if (texture.is_valid()) { @@ -794,7 +794,7 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant & String file = files[i]; String ftype = EditorFileSystem::get_singleton()->get_file_type(file); - if (!ClassDB::is_parent_class(ftype, "Texture")) { + if (!ClassDB::is_parent_class(ftype, "Texture2D")) { return false; } } @@ -819,7 +819,7 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da if (String(d["type"]) == "resource" && d.has("resource")) { RES r = d["resource"]; - Ref<Texture> texture = r; + Ref<Texture2D> texture = r; if (texture.is_valid()) { bool reorder = false; diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 57447abf47..804a900582 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -163,7 +163,7 @@ String TextEditor::get_name() { return name; } -Ref<Texture> TextEditor::get_icon() { +Ref<Texture2D> TextEditor::get_icon() { return EditorNode::get_singleton()->get_object_icon(text_file.operator->(), ""); } diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h index fe157a29e6..81896d92be 100644 --- a/editor/plugins/text_editor.h +++ b/editor/plugins/text_editor.h @@ -120,7 +120,7 @@ public: virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter); virtual String get_name(); - virtual Ref<Texture> get_icon(); + virtual Ref<Texture2D> get_icon(); virtual RES get_edited_resource() const; virtual void set_edited_resource(const RES &p_res); void set_edited_file(const Ref<TextFile> &p_file); diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 9489836984..675ba55b34 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -46,7 +46,7 @@ void TextureEditor::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> checkerboard = get_icon("Checkerboard", "EditorIcons"); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); @@ -110,7 +110,7 @@ void TextureEditor::_changed_callback(Object *p_changed, const char *p_prop) { update(); } -void TextureEditor::edit(Ref<Texture> p_texture) { +void TextureEditor::edit(Ref<Texture2D> p_texture) { if (!texture.is_null()) texture->remove_change_receptor(this); @@ -148,11 +148,11 @@ bool EditorInspectorPluginTexture::can_handle(Object *p_object) { void EditorInspectorPluginTexture::parse_begin(Object *p_object) { - Texture *texture = Object::cast_to<Texture>(p_object); + Texture2D *texture = Object::cast_to<Texture2D>(p_object); if (!texture) { return; } - Ref<Texture> m(texture); + Ref<Texture2D> m(texture); TextureEditor *editor = memnew(TextureEditor); editor->edit(m); diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h index f587579902..29ad0183dc 100644 --- a/editor/plugins/texture_editor_plugin.h +++ b/editor/plugins/texture_editor_plugin.h @@ -39,7 +39,7 @@ class TextureEditor : public Control { GDCLASS(TextureEditor, Control); - Ref<Texture> texture; + Ref<Texture2D> texture; protected: void _notification(int p_what); @@ -48,7 +48,7 @@ protected: static void _bind_methods(); public: - void edit(Ref<Texture> p_texture); + void edit(Ref<Texture2D> p_texture); TextureEditor(); ~TextureEditor(); }; @@ -66,7 +66,7 @@ class TextureEditorPlugin : public EditorPlugin { GDCLASS(TextureEditorPlugin, EditorPlugin); public: - virtual String get_name() const { return "Texture"; } + virtual String get_name() const { return "Texture2D"; } TextureEditorPlugin(EditorNode *p_node); }; diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 94aef60f1f..2350c20cb7 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -49,7 +49,7 @@ void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) { } void TextureRegionEditor::_region_draw() { - Ref<Texture> base_tex = NULL; + Ref<Texture2D> base_tex = NULL; if (node_sprite) base_tex = node_sprite->get_texture(); else if (node_sprite_3d) @@ -134,7 +134,7 @@ void TextureRegionEditor::_region_draw() { } } - Ref<Texture> select_handle = get_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> select_handle = get_icon("EditorHandle", "EditorIcons"); Rect2 scroll_rect(Point2(), base_tex->get_size()); @@ -672,7 +672,7 @@ void TextureRegionEditor::_update_autoslice() { autoslice_is_dirty = false; autoslice_cache.clear(); - Ref<Texture> texture = NULL; + Ref<Texture2D> texture = NULL; if (node_sprite) texture = node_sprite->get_texture(); else if (node_sprite_3d) @@ -863,7 +863,7 @@ void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_pro } void TextureRegionEditor::_edit_region() { - Ref<Texture> texture = NULL; + Ref<Texture2D> texture = NULL; if (node_sprite) texture = node_sprite->get_texture(); else if (node_sprite_3d) diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 22105f7ed4..48d80a0017 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -122,7 +122,7 @@ struct _TECategory { Set<RefItem<StyleBox> > stylebox_items; Set<RefItem<Font> > font_items; - Set<RefItem<Texture> > icon_items; + Set<RefItem<Texture2D> > icon_items; Set<Item<Color> > color_items; Set<Item<int> > constant_items; @@ -167,7 +167,7 @@ void ThemeEditor::_save_template_cbk(String fname) { List<StringName> icon_list; Theme::get_default()->get_icon_list(E->key(), &icon_list); for (List<StringName>::Element *F = icon_list.front(); F; F = F->next()) { - _TECategory::RefItem<Texture> it; + _TECategory::RefItem<Texture2D> it; it.name = F->get(); it.item = Theme::get_default()->get_icon(F->get(), E->key()); tc.icon_items.insert(it); @@ -291,7 +291,7 @@ void ThemeEditor::_save_template_cbk(String fname) { if (tc.icon_items.size()) file->store_line("\n; Icon Items:\n"); - for (Set<_TECategory::RefItem<Texture> >::Element *F = tc.icon_items.front(); F; F = F->next()) { + for (Set<_TECategory::RefItem<Texture2D> >::Element *F = tc.icon_items.front(); F; F = F->next()) { file->store_line(E->key() + "." + F->get().name + " = default"); } @@ -324,7 +324,7 @@ void ThemeEditor::_dialog_cbk() { switch (type_select->get_selected()) { - case 0: theme->set_icon(name_edit->get_text(), type_edit->get_text(), Ref<Texture>()); break; + case 0: theme->set_icon(name_edit->get_text(), type_edit->get_text(), Ref<Texture2D>()); break; case 1: theme->set_stylebox(name_edit->get_text(), type_edit->get_text(), Ref<StyleBox>()); break; case 2: theme->set_font(name_edit->get_text(), type_edit->get_text(), Ref<Font>()); break; case 3: theme->set_color(name_edit->get_text(), type_edit->get_text(), Color()); break; @@ -341,7 +341,7 @@ void ThemeEditor::_dialog_cbk() { names.clear(); Theme::get_default()->get_icon_list(fromtype, &names); for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - theme->set_icon(E->get(), fromtype, Ref<Texture>()); + theme->set_icon(E->get(), fromtype, Ref<Texture2D>()); } } { @@ -454,7 +454,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { base_theme->get_icon_list(type, &icons); for (List<StringName>::Element *E = icons.front(); E; E = E->next()) { - theme->set_icon(E->get(), type, import ? base_theme->get_icon(E->get(), type) : Ref<Texture>()); + theme->set_icon(E->get(), type, import ? base_theme->get_icon(E->get(), type) : Ref<Texture2D>()); } List<StringName> shaders; diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 0c3e29028c..425a759dac 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -468,7 +468,7 @@ void TileMapEditor::_update_palette() { palette->add_item(String()); } - Ref<Texture> tex = tileset->tile_get_texture(entries[i].id); + Ref<Texture2D> tex = tileset->tile_get_texture(entries[i].id); if (tex.is_valid()) { Rect2 region = tileset->tile_get_region(entries[i].id); @@ -528,7 +528,7 @@ void TileMapEditor::_update_palette() { }; entries2.sort_custom<SwapComparator>(); - Ref<Texture> tex = tileset->tile_get_texture(sel_tile); + Ref<Texture2D> tex = tileset->tile_get_texture(sel_tile); for (int i = 0; i < entries2.size(); i++) { @@ -761,7 +761,7 @@ void TileMapEditor::_erase_selection() { void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i &p_autotile_coord, const Transform2D &p_xform) { - Ref<Texture> t = node->get_tileset()->tile_get_texture(p_cell); + Ref<Texture2D> t = node->get_tileset()->tile_get_texture(p_cell); if (t.is_null()) return; diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index b24d5add9f..9907871e98 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -62,8 +62,8 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) { } Sprite *mi = Object::cast_to<Sprite>(child); - Ref<Texture> texture = mi->get_texture(); - Ref<Texture> normal_map = mi->get_normal_map(); + Ref<Texture2D> texture = mi->get_texture(); + Ref<Texture2D> normal_map = mi->get_normal_map(); Ref<ShaderMaterial> material = mi->get_material(); if (texture.is_null()) @@ -195,7 +195,7 @@ bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_dat if (String(d["type"]) == "resource" && d.has("resource")) { RES r = d["resource"]; - Ref<Texture> texture = r; + Ref<Texture2D> texture = r; if (texture.is_valid()) { @@ -237,7 +237,7 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C if (String(d["type"]) == "resource" && d.has("resource")) { RES r = d["resource"]; - Ref<Texture> texture = r; + Ref<Texture2D> texture = r; if (texture.is_valid()) add_texture(texture); @@ -639,7 +639,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { texture_dialog->clear_filters(); List<String> extensions; - ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions); + ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions); for (List<String>::Element *E = extensions.front(); E; E = E->next()) { texture_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper()); @@ -753,7 +753,7 @@ void TileSetEditor::_on_texture_list_selected(int p_index) { void TileSetEditor::_on_textures_added(const PoolStringArray &p_paths) { int invalid_count = 0; for (int i = 0; i < p_paths.size(); i++) { - Ref<Texture> t = Ref<Texture>(ResourceLoader::load(p_paths[i])); + Ref<Texture2D> t = Ref<Texture2D>(ResourceLoader::load(p_paths[i])); ERR_CONTINUE_MSG(!t.is_valid(), "'" + p_paths[i] + "' is not a valid texture."); @@ -1183,7 +1183,7 @@ void TileSetEditor::_on_workspace_overlay_draw() { if (t_id < 0) return; - Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> handle = get_icon("EditorHandle", "EditorIcons"); if (draw_handles) { for (int i = 0; i < current_shape.size(); i++) { workspace_overlay->draw_texture(handle, current_shape[i] * workspace->get_scale().x - handle->get_size() * 0.5); @@ -3098,13 +3098,13 @@ Vector2 TileSetEditor::snap_point(const Vector2 &point) { return p; } -void TileSetEditor::add_texture(Ref<Texture> p_texture) { +void TileSetEditor::add_texture(Ref<Texture2D> p_texture) { texture_list->add_item(p_texture->get_path().get_file()); texture_map.insert(p_texture->get_rid(), p_texture); texture_list->set_item_metadata(texture_list->get_item_count() - 1, p_texture->get_rid()); } -void TileSetEditor::remove_texture(Ref<Texture> p_texture) { +void TileSetEditor::remove_texture(Ref<Texture2D> p_texture) { texture_list->remove_item(texture_list->find_metadata(p_texture->get_rid())); texture_map.erase(p_texture->get_rid()); @@ -3117,7 +3117,7 @@ void TileSetEditor::remove_texture(Ref<Texture> p_texture) { } void TileSetEditor::update_texture_list() { - Ref<Texture> selected_texture = get_current_texture(); + Ref<Texture2D> selected_texture = get_current_texture(); helper->set_tileset(tileset); @@ -3326,9 +3326,9 @@ void TileSetEditor::set_current_tile(int p_id) { } } -Ref<Texture> TileSetEditor::get_current_texture() { +Ref<Texture2D> TileSetEditor::get_current_texture() { if (texture_list->get_selected_items().size() == 0) - return Ref<Texture>(); + return Ref<Texture2D>(); else return texture_map[texture_list->get_item_metadata(texture_list->get_selected_items()[0])]; } @@ -3487,7 +3487,7 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const int id = tileset_editor->get_current_tile(); p_list->push_back(PropertyInfo(Variant::NIL, "Selected Tile", PROPERTY_HINT_NONE, "tile_", PROPERTY_USAGE_GROUP)); p_list->push_back(PropertyInfo(Variant::STRING, "tile_name")); - p_list->push_back(PropertyInfo(Variant::OBJECT, "tile_normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture")); + p_list->push_back(PropertyInfo(Variant::OBJECT, "tile_normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D")); p_list->push_back(PropertyInfo(Variant::VECTOR2, "tile_tex_offset")); p_list->push_back(PropertyInfo(Variant::OBJECT, "tile_material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial")); p_list->push_back(PropertyInfo(Variant::COLOR, "tile_modulate")); diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h index 0e0bd6448c..26340824a0 100644 --- a/editor/plugins/tile_set_editor_plugin.h +++ b/editor/plugins/tile_set_editor_plugin.h @@ -114,7 +114,7 @@ class TileSetEditor : public HSplitContainer { int option; ToolButton *tileset_toolbar_buttons[TOOL_TILESET_MAX]; MenuButton *tileset_toolbar_tools; - Map<RID, Ref<Texture> > texture_map; + Map<RID, Ref<Texture2D> > texture_map; bool creating_shape; int dragging_point; @@ -165,10 +165,10 @@ class TileSetEditor : public HSplitContainer { void update_texture_list(); void update_texture_list_icon(); - void add_texture(Ref<Texture> p_texture); - void remove_texture(Ref<Texture> p_texture); + void add_texture(Ref<Texture2D> p_texture); + void remove_texture(Ref<Texture2D> p_texture); - Ref<Texture> get_current_texture(); + Ref<Texture2D> get_current_texture(); static void _import_node(Node *p_node, Ref<TileSet> p_library); static void _import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_merge); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index fb095692bc..ae6087263e 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -2693,8 +2693,7 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubeMap", TTR("Perform the cubic texture lookup."), -1, -1)); texture_node_option_idx = add_options.size(); - add_options.push_back(AddOption("Texture", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the texture lookup."), -1, -1)); - + add_options.push_back(AddOption("Texture2D", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the texture lookup."), -1, -1)); add_options.push_back(AddOption("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubeMapUniform", TTR("Cubic texture uniform lookup."), -1, -1)); add_options.push_back(AddOption("TextureUniform", "Textures", "Variables", "VisualShaderNodeTextureUniform", TTR("2D texture uniform lookup."), -1, -1)); add_options.push_back(AddOption("TextureUniformTriplanar", "Textures", "Variables", "VisualShaderNodeTextureUniformTriplanar", TTR("2D texture uniform lookup with triplanar."), -1, -1, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL)); @@ -2894,7 +2893,7 @@ public: void setup(const Ref<VisualShaderNodeInput> &p_input) { input = p_input; - Ref<Texture> type_icon[5] = { + Ref<Texture2D> type_icon[5] = { EditorNode::get_singleton()->get_gui_base()->get_icon("float", "EditorIcons"), EditorNode::get_singleton()->get_gui_base()->get_icon("Vector3", "EditorIcons"), EditorNode::get_singleton()->get_gui_base()->get_icon("bool", "EditorIcons"), diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 9cc2a79399..14b24892b2 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -107,9 +107,9 @@ private: void set_message(const String &p_msg, MessageType p_type = MESSAGE_SUCCESS, InputType input_type = PROJECT_PATH) { msg->set_text(p_msg); - Ref<Texture> current_path_icon = status_rect->get_texture(); - Ref<Texture> current_install_icon = install_status_rect->get_texture(); - Ref<Texture> new_icon; + Ref<Texture2D> current_path_icon = status_rect->get_texture(); + Ref<Texture2D> current_install_icon = install_status_rect->get_texture(); + Ref<Texture2D> new_icon; switch (p_type) { @@ -1141,8 +1141,8 @@ void ProjectList::_notification(int p_what) { void ProjectList::load_project_icon(int p_index) { Item &item = _projects.write[p_index]; - Ref<Texture> default_icon = get_icon("DefaultProjectIcon", "EditorIcons"); - Ref<Texture> icon; + Ref<Texture2D> default_icon = get_icon("DefaultProjectIcon", "EditorIcons"); + Ref<Texture2D> icon; if (item.icon != "") { Ref<Image> img; img.instance(); @@ -1304,7 +1304,7 @@ void ProjectList::create_project_item_control(int p_index) { Item &item = _projects.write[p_index]; ERR_FAIL_COND(item.control != NULL); // Already created - Ref<Texture> favorite_icon = get_icon("Favorites", "EditorIcons"); + Ref<Texture2D> favorite_icon = get_icon("Favorites", "EditorIcons"); Color font_color = get_color("font_color", "Tree"); ProjectListItemControl *hb = memnew(ProjectListItemControl); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 2dcbc4c14c..63f0b02a40 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -935,7 +935,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: const String &t = j->get(); bool is_custom_resource = false; - Ref<Texture> icon; + Ref<Texture2D> icon; if (!custom_resources.empty()) { for (int k = 0; k < custom_resources.size(); k++) { if (custom_resources[k].name == t) { @@ -1023,7 +1023,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } for (int i = 0; i < conversions.size(); i++) { String what = conversions[i]->converts_to(); - Ref<Texture> icon; + Ref<Texture2D> icon; if (has_icon(what, "EditorIcons")) { icon = get_icon(what, "EditorIcons"); diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 426ec51e4c..fdb1ce3e62 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -120,7 +120,7 @@ void PropertySelector::_update_search() { bool found = false; - Ref<Texture> type_icons[Variant::VARIANT_MAX] = { + Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = { Control::get_icon("Variant", "EditorIcons"), Control::get_icon("bool", "EditorIcons"), Control::get_icon("int", "EditorIcons"), @@ -159,7 +159,7 @@ void PropertySelector::_update_search() { category->set_text(0, E->get().name); category->set_selectable(0, false); - Ref<Texture> icon; + Ref<Texture2D> icon; if (E->get().name == "Script Variables") { icon = get_icon("Script", "EditorIcons"); } else { @@ -234,7 +234,7 @@ void PropertySelector::_update_search() { category->set_text(0, E->get().name.replace_first("*", "")); category->set_selectable(0, false); - Ref<Texture> icon; + Ref<Texture2D> icon; script_methods = false; String rep = E->get().name.replace("*", ""); if (E->get().name == "*Script Methods") { diff --git a/editor/pvrtc_compress.cpp b/editor/pvrtc_compress.cpp index 43963d3aae..f9efe6a50d 100644 --- a/editor/pvrtc_compress.cpp +++ b/editor/pvrtc_compress.cpp @@ -98,7 +98,7 @@ static void _compress_image(Image::CompressMode p_mode, Image *p_image) { // Save source PNG. Ref<ImageTexture> t = memnew(ImageTexture); - t->create_from_image(Ref<Image>(p_image), 0); + t->create_from_image(Ref<Image>(p_image)); ResourceSaver::save(src_img, t); Error err = OS::get_singleton()->execute(ttpath, args, true); @@ -109,7 +109,7 @@ static void _compress_image(Image::CompressMode p_mode, Image *p_image) { ERR_FAIL_MSG("Could not execute PVRTC tool: " + ttpath); } - t = ResourceLoader::load(dst_img, "Texture"); + t = ResourceLoader::load(dst_img, "Texture2D"); if (t.is_null()) { // Clean up generated files. DirAccess::remove_file_or_error(src_img); diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 4cd70b0f8e..ea92e6407c 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -122,7 +122,7 @@ float EditorQuickOpen::_path_cmp(String search, String path) const { return path.to_lower().similarity(search.to_lower()); } -void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture> > > &list) { +void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D> > > &list) { if (!add_directories) { for (int i = 0; i < efsd->get_subdir_count(); i++) { @@ -140,7 +140,7 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str if (path != "res://") { path = path.substr(6, path.length()); if (search_text.is_subsequence_ofi(path)) { - Pair<String, Ref<Texture> > pair; + Pair<String, Ref<Texture2D> > pair; pair.first = path; pair.second = get_icon("folder", "FileDialog"); @@ -169,7 +169,7 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str file = file.substr(6, file.length()); if (ClassDB::is_parent_class(efsd->get_file_type(i), base_type) && (search_text.is_subsequence_ofi(file))) { - Pair<String, Ref<Texture> > pair; + Pair<String, Ref<Texture2D> > pair; pair.first = file; pair.second = get_icon((has_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei); list.push_back(pair); @@ -184,10 +184,10 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str } } -Vector<Pair<String, Ref<Texture> > > EditorQuickOpen::_sort_fs(Vector<Pair<String, Ref<Texture> > > &list) { +Vector<Pair<String, Ref<Texture2D> > > EditorQuickOpen::_sort_fs(Vector<Pair<String, Ref<Texture2D> > > &list) { String search_text = search_box->get_text(); - Vector<Pair<String, Ref<Texture> > > sorted_list; + Vector<Pair<String, Ref<Texture2D> > > sorted_list; if (search_text == String() || list.size() == 0) return list; @@ -223,7 +223,7 @@ void EditorQuickOpen::_update_search() { search_options->clear(); TreeItem *root = search_options->create_item(); EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem(); - Vector<Pair<String, Ref<Texture> > > list; + Vector<Pair<String, Ref<Texture2D> > > list; _parse_fs(efsd, list); list = _sort_fs(list); diff --git a/editor/quick_open.h b/editor/quick_open.h index a4eb44c805..4814e5f310 100644 --- a/editor/quick_open.h +++ b/editor/quick_open.h @@ -49,8 +49,8 @@ class EditorQuickOpen : public ConfirmationDialog { void _update_search(); void _sbox_input(const Ref<InputEvent> &p_ie); - void _parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture> > > &list); - Vector<Pair<String, Ref<Texture> > > _sort_fs(Vector<Pair<String, Ref<Texture> > > &list); + void _parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D> > > &list); + Vector<Pair<String, Ref<Texture2D> > > _sort_fs(Vector<Pair<String, Ref<Texture2D> > > &list); float _path_cmp(String search, String path) const; void _confirmed(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 7410a998ad..34d6d0580e 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2371,7 +2371,7 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { if (!obj) continue; - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(obj); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj); if (menu->get_item_count() == 0) { menu->add_submenu_item(TTR("Sub-Resources"), "Sub-Resources"); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index c49ea72e99..c168418972 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -205,7 +205,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { item->set_collapsed(true); } - Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(p_node, "Node"); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(p_node, "Node"); item->set_icon(0, icon); item->set_metadata(0, p_node->get_path()); @@ -929,7 +929,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from return Variant(); //not editable tree Vector<Node *> selected; - Vector<Ref<Texture> > icons; + Vector<Ref<Texture2D> > icons; TreeItem *next = tree->get_next_selected(NULL); while (next) { diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index c4627e6627..a3764b4085 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -47,13 +47,13 @@ void ScriptCreateDialog::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { for (int i = 0; i < ScriptServer::get_language_count(); i++) { String lang = ScriptServer::get_language(i)->get_type(); - Ref<Texture> lang_icon = get_icon(lang, "EditorIcons"); + Ref<Texture2D> lang_icon = get_icon(lang, "EditorIcons"); if (lang_icon.is_valid()) { language_menu->set_item_icon(i, lang_icon); } } String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", ""); - Ref<Texture> last_lang_icon; + Ref<Texture2D> last_lang_icon; if (!last_lang.empty()) { for (int i = 0; i < language_menu->get_item_count(); i++) { diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 34547717fd..f1946953db 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -434,7 +434,7 @@ int ScriptEditorDebugger::_update_scene_tree(TreeItem *parent, const Array &node item->set_text(0, item_text); item->set_tooltip(0, TTR("Type:") + " " + item_type); ObjectID id = ObjectID(nodes[current_index + 3]); - Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(nodes[current_index + 2], ""); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(nodes[current_index + 2], ""); if (icon.is_valid()) { item->set_icon(0, icon); } @@ -1281,8 +1281,8 @@ void ScriptEditorDebugger::_notification(int p_what) { if (error_count == 0 && warning_count == 0) { errors_tab->set_name(TTR("Errors")); debugger_button->set_text(TTR("Debugger")); - debugger_button->set_icon(Ref<Texture>()); - tabs->set_tab_icon(errors_tab->get_index(), Ref<Texture>()); + debugger_button->set_icon(Ref<Texture2D>()); + tabs->set_tab_icon(errors_tab->get_index(), Ref<Texture2D>()); } else { errors_tab->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")"); debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")"); diff --git a/main/main.cpp b/main/main.cpp index b74ae36434..e63f65f56a 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1350,7 +1350,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { if (String(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image")) != String()) { - Ref<Texture> cursor = ResourceLoader::load(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image")); + Ref<Texture2D> cursor = ResourceLoader::load(ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image")); if (cursor.is_valid()) { Vector2 hotspot = ProjectSettings::get_singleton()->get("display/mouse_cursor/custom_image_hotspot"); Input::get_singleton()->set_custom_mouse_cursor(cursor, Input::CURSOR_ARROW, hotspot); diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp index 51cca32090..9c10fcbd56 100644 --- a/main/tests/test_physics_2d.cpp +++ b/main/tests/test_physics_2d.cpp @@ -85,7 +85,7 @@ class TestPhysics2DMainLoop : public MainLoop { Ref<Image> image = memnew(Image(32, 2, 0, Image::FORMAT_LA8, pixels)); - body_shape_data[Physics2DServer::SHAPE_SEGMENT].image = vs->texture_create_from_image(image); + body_shape_data[Physics2DServer::SHAPE_SEGMENT].image = vs->texture_2d_create(image); RID segment_shape = ps->segment_shape_create(); Rect2 sg(Point2(-16, 0), Point2(16, 0)); @@ -112,7 +112,7 @@ class TestPhysics2DMainLoop : public MainLoop { Ref<Image> image = memnew(Image(32, 32, 0, Image::FORMAT_LA8, pixels)); - body_shape_data[Physics2DServer::SHAPE_CIRCLE].image = vs->texture_create_from_image(image); + body_shape_data[Physics2DServer::SHAPE_CIRCLE].image = vs->texture_2d_create(image); RID circle_shape = ps->circle_shape_create(); ps->shape_set_data(circle_shape, 16); @@ -139,7 +139,7 @@ class TestPhysics2DMainLoop : public MainLoop { Ref<Image> image = memnew(Image(32, 32, 0, Image::FORMAT_LA8, pixels)); - body_shape_data[Physics2DServer::SHAPE_RECTANGLE].image = vs->texture_create_from_image(image); + body_shape_data[Physics2DServer::SHAPE_RECTANGLE].image = vs->texture_2d_create(image); RID rectangle_shape = ps->rectangle_shape_create(); ps->shape_set_data(rectangle_shape, Vector2(16, 16)); @@ -167,7 +167,7 @@ class TestPhysics2DMainLoop : public MainLoop { Ref<Image> image = memnew(Image(32, 64, 0, Image::FORMAT_LA8, pixels)); - body_shape_data[Physics2DServer::SHAPE_CAPSULE].image = vs->texture_create_from_image(image); + body_shape_data[Physics2DServer::SHAPE_CAPSULE].image = vs->texture_2d_create(image); RID capsule_shape = ps->capsule_shape_create(); ps->shape_set_data(capsule_shape, Vector2(16, 32)); @@ -181,7 +181,7 @@ class TestPhysics2DMainLoop : public MainLoop { Ref<Image> image = memnew(Image(convex_png)); - body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].image = vs->texture_create_from_image(image); + body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].image = vs->texture_2d_create(image); RID convex_polygon_shape = ps->convex_polygon_shape_create(); @@ -260,7 +260,7 @@ protected: RID sprite = vs->canvas_item_create(); vs->canvas_item_set_parent(sprite, canvas); vs->canvas_item_set_transform(sprite, p_xform); - Size2 imgsize(vs->texture_get_width(body_shape_data[p_shape].image), vs->texture_get_height(body_shape_data[p_shape].image)); + Size2 imgsize(5, 5); //vs->texture_get_width(body_shape_data[p_shape].image), vs->texture_get_height(body_shape_data[p_shape].image)); vs->canvas_item_add_texture_rect(sprite, Rect2(-imgsize / 2.0, imgsize), body_shape_data[p_shape].image); ps->body_set_force_integration_callback(body, this, "_body_moved", sprite); diff --git a/modules/assimp/import_utils.h b/modules/assimp/import_utils.h index c522b01727..0eb055956b 100644 --- a/modules/assimp/import_utils.h +++ b/modules/assimp/import_utils.h @@ -189,7 +189,7 @@ public: } /** - * Converts aiMatrix4x4 to godot Transform + * Converts aiMatrix4x4 to godot Transform */ static const Transform assimp_matrix_transform(const aiMatrix4x4 p_matrix) { aiMatrix4x4 matrix = p_matrix; @@ -322,15 +322,18 @@ public: ERR_FAIL_COND(map_mode == NULL); aiTextureMapMode tex_mode = map_mode[0]; - int32_t flags = Texture::FLAGS_DEFAULT; + // FIXME: Commented out during Vulkan port. + /* + int32_t flags = Texture2D::FLAGS_DEFAULT; if (tex_mode == aiTextureMapMode_Wrap) { //Default } else if (tex_mode == aiTextureMapMode_Clamp) { - flags = flags & ~Texture::FLAG_REPEAT; + flags = flags & ~Texture2D::FLAG_REPEAT; } else if (tex_mode == aiTextureMapMode_Mirror) { - flags = flags | Texture::FLAG_MIRRORED_REPEAT; + flags = flags | Texture2D::FLAG_MIRRORED_REPEAT; } texture->set_flags(flags); + */ } /** @@ -391,7 +394,7 @@ public: } return Ref<Image>(); } else { - Ref<Texture> texture = ResourceLoader::load(p_path); + Ref<Texture2D> texture = ResourceLoader::load(p_path); ERR_FAIL_COND_V(texture.is_null(), Ref<Image>()); Ref<Image> image = texture->get_data(); ERR_FAIL_COND_V(image.is_null(), Ref<Image>()); @@ -418,7 +421,8 @@ public: if (image_state.raw_image.is_valid()) { image_state.texture.instance(); image_state.texture->create_from_image(image_state.raw_image); - image_state.texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY); + // FIXME: Commented out during Vulkan port. + //image_state.texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY); return true; } } diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index a7701329d8..5494744c48 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -457,7 +457,7 @@ void ResourceFormatDDS::get_recognized_extensions(List<String> *p_extensions) co bool ResourceFormatDDS::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture"); + return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatDDS::get_resource_type(const String &p_path) const { diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp index 27c2358306..facdc2e473 100644 --- a/modules/etc/texture_loader_pkm.cpp +++ b/modules/etc/texture_loader_pkm.cpp @@ -103,7 +103,7 @@ void ResourceFormatPKM::get_recognized_extensions(List<String> *p_extensions) co bool ResourceFormatPKM::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture"); + return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatPKM::get_resource_type(const String &p_path) const { diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp index 5efa915f62..eb43a3971c 100644 --- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp +++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp @@ -297,7 +297,8 @@ godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target) { RID *render_target = (RID *)p_render_target; RID eye_texture = VSG::storage->render_target_get_texture(*render_target); - uint32_t texid = VS::get_singleton()->texture_get_texid(eye_texture); +#warning need to obtain this ID again + uint32_t texid = 0; //VS::get_singleton()->texture_get_texid(eye_texture); return texid; } diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp index dbe00cdf71..8dcafc1987 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp +++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp @@ -132,7 +132,11 @@ bool VideoStreamPlaybackGDNative::open_file(const String &p_file) { pcm_write_idx = -1; samples_decoded = 0; - texture->create((int)texture_size.width, (int)texture_size.height, Image::FORMAT_RGBA8, Texture::FLAG_FILTER | Texture::FLAG_VIDEO_SURFACE); + Ref<Image> img; + img.instance(); + img->create((int)texture_size.width, false, (int)texture_size.height, Image::FORMAT_RGBA8); + + texture->create_from_image(img); } return file_opened; @@ -192,7 +196,7 @@ void VideoStreamPlaybackGDNative::update_texture() { Ref<Image> img = memnew(Image(texture_size.width, texture_size.height, 0, Image::FORMAT_RGBA8, *pba)); - texture->set_data(img); + texture->update(img, true); } // ctor and dtor @@ -283,7 +287,7 @@ void VideoStreamPlaybackGDNative::set_paused(bool p_paused) { paused = p_paused; } -Ref<Texture> VideoStreamPlaybackGDNative::get_texture() const { +Ref<Texture2D> VideoStreamPlaybackGDNative::get_texture() const { return texture; } diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h index bb0346efb4..024cdec196 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.h +++ b/modules/gdnative/videodecoder/video_stream_gdnative.h @@ -168,7 +168,7 @@ public: //virtual int mix(int16_t* p_buffer,int p_frames)=0; - virtual Ref<Texture> get_texture() const; + virtual Ref<Texture2D> get_texture() const; virtual void update(float p_delta); virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata); diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 28d301ada1..a8cb039cb3 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -925,7 +925,7 @@ void GridMapEditor::update_palette() { for (List<_CGMEItemSort>::Element *E = il.front(); E; E = E->next()) { int id = E->get().id; String name = mesh_library->get_item_name(id); - Ref<Texture> preview = mesh_library->get_item_preview(id); + Ref<Texture2D> preview = mesh_library->get_item_preview(id); if (name == "") { name = "#" + itos(id); diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index aa1c822813..19aa281a72 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -42,17 +42,16 @@ NoiseTexture::NoiseTexture() { seamless = false; as_normalmap = false; bump_strength = 8.0; - flags = FLAGS_DEFAULT; noise = Ref<OpenSimplexNoise>(); - texture = VS::get_singleton()->texture_create(); - _queue_update(); } NoiseTexture::~NoiseTexture() { - VS::get_singleton()->free(texture); + if (texture.is_valid()) { + VS::get_singleton()->free(texture); + } if (noise_thread) { Thread::wait_to_finish(noise_thread); memdelete(noise_thread); @@ -101,8 +100,12 @@ void NoiseTexture::_validate_property(PropertyInfo &property) const { void NoiseTexture::_set_texture_data(const Ref<Image> &p_image) { data = p_image; if (data.is_valid()) { - VS::get_singleton()->texture_allocate(texture, size.x, size.y, 0, Image::FORMAT_RGBA8, VS::TEXTURE_TYPE_2D, flags); - 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); + } } emit_changed(); } @@ -250,13 +253,12 @@ int NoiseTexture::get_height() const { return size.y; } -void NoiseTexture::set_flags(uint32_t p_flags) { - flags = p_flags; - VS::get_singleton()->texture_set_flags(texture, flags); -} +RID NoiseTexture::get_rid() const { + if (!texture.is_valid()) { + texture = VS::get_singleton()->texture_2d_placeholder_create(); + } -uint32_t NoiseTexture::get_flags() const { - return flags; + return texture; } Ref<Image> NoiseTexture::get_data() const { diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h index 285fd1eba9..b1d7d3fac9 100644 --- a/modules/opensimplex/noise_texture.h +++ b/modules/opensimplex/noise_texture.h @@ -39,8 +39,8 @@ #include "editor/editor_plugin.h" #include "editor/property_editor.h" -class NoiseTexture : public Texture { - GDCLASS(NoiseTexture, Texture); +class NoiseTexture : public Texture2D { + GDCLASS(NoiseTexture, Texture2D); private: Ref<Image> data; @@ -51,7 +51,7 @@ private: bool update_queued; bool regen_queued; - RID texture; + mutable RID texture; uint32_t flags; Ref<OpenSimplexNoise> noise; @@ -91,10 +91,7 @@ public: int get_width() const; int get_height() const; - virtual void set_flags(uint32_t p_flags); - virtual uint32_t get_flags() const; - - virtual RID get_rid() const { return texture; } + virtual RID get_rid() const; virtual bool has_alpha() const { return false; } virtual Ref<Image> get_data() const; diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 65c21d5af8..36f2fe1ba1 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -154,16 +154,11 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, w.release(); - int tex_flags = Texture::FLAG_FILTER | Texture::FLAG_REPEAT; - - if (mipmaps) - tex_flags |= Texture::FLAG_MIPMAPS; - Ref<Image> image = memnew(Image(width, height, mipmaps, format, data)); ERR_FAIL_COND_V(image->empty(), RES()); Ref<ImageTexture> texture = memnew(ImageTexture); - texture->create_from_image(image, tex_flags); + texture->create_from_image(image); if (r_error) *r_error = OK; @@ -177,12 +172,12 @@ void ResourceFormatPVR::get_recognized_extensions(List<String> *p_extensions) co } bool ResourceFormatPVR::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture"); + return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatPVR::get_resource_type(const String &p_path) const { if (p_path.get_extension().to_lower() == "pvr") - return "Texture"; + return "Texture2D"; return ""; } diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index 00c7e87568..de229745f5 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -110,7 +110,7 @@ void VideoStreamPlaybackTheora::video_write(void) { Ref<Image> img = memnew(Image(size.x, size.y, 0, Image::FORMAT_RGBA8, frame_data)); //zero copy image creation - texture->set_data(img); //zero copy send to visual server + texture->update(img, true); //zero copy send to visual server frames_pending = 1; } @@ -336,7 +336,9 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) { size.x = w; size.y = h; - texture->create(w, h, Image::FORMAT_RGBA8, Texture::FLAG_FILTER | Texture::FLAG_VIDEO_SURFACE); + Ref<Image> img; + img.instance(); + img->create(w, h, false, Image::FORMAT_RGBA8); } else { /* tear down the partial theora setup */ @@ -369,7 +371,7 @@ float VideoStreamPlaybackTheora::get_time() const { return time - /* AudioServer::get_singleton()->get_output_latency() - */ delay_compensation; }; -Ref<Texture> VideoStreamPlaybackTheora::get_texture() const { +Ref<Texture2D> VideoStreamPlaybackTheora::get_texture() const { return texture; } diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h index 0f201ffa9d..c0a0faec4b 100644 --- a/modules/theora/video_stream_theora.h +++ b/modules/theora/video_stream_theora.h @@ -147,7 +147,7 @@ public: void set_file(const String &p_file); - virtual Ref<Texture> get_texture() const; + virtual Ref<Texture2D> get_texture() const; virtual void update(float p_delta); virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index ec20698ae8..18851e6ab6 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -499,7 +499,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { graph->show(); select_func_text->hide(); - Ref<Texture> type_icons[Variant::VARIANT_MAX] = { + Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = { Control::get_icon("Variant", "EditorIcons"), Control::get_icon("bool", "EditorIcons"), Control::get_icon("int", "EditorIcons"), @@ -529,7 +529,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { Control::get_icon("PoolColorArray", "EditorIcons") }; - Ref<Texture> seq_port = Control::get_icon("VisualShaderPort", "EditorIcons"); + Ref<Texture2D> seq_port = Control::get_icon("VisualShaderPort", "EditorIcons"); for (List<StringName>::Element *F = funcs.front(); F; F = F->next()) { // loop through all the functions @@ -702,7 +702,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { vbc->add_child(hbc2); if (left_ok) { - Ref<Texture> t; + Ref<Texture2D> t; if (left_type >= 0 && left_type < Variant::VARIANT_MAX) { t = type_icons[left_type]; } @@ -830,7 +830,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { hbc->add_child(memnew(Label(right_name))); } - Ref<Texture> t; + Ref<Texture2D> t; if (right_type >= 0 && right_type < Variant::VARIANT_MAX) { t = type_icons[right_type]; } @@ -846,7 +846,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { bool dark_theme = get_constant("dark_theme", "Editor"); if (i < mixed_seq_ports) { - gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref<Texture>(), seq_port); + gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref<Texture2D>(), seq_port); } else { gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), right_ok, right_type, _color_from_type(right_type, dark_theme)); } @@ -955,7 +955,7 @@ void VisualScriptEditor::_update_members() { variables->add_button(0, Control::get_icon("Add", "EditorIcons"), -1, false, TTR("Create a new variable.")); variables->set_custom_color(0, Control::get_color("mono_color", "Editor")); - Ref<Texture> type_icons[Variant::VARIANT_MAX] = { + Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = { Control::get_icon("Variant", "EditorIcons"), Control::get_icon("bool", "EditorIcons"), Control::get_icon("int", "EditorIcons"), @@ -2369,7 +2369,7 @@ void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) { button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color); } -void VisualScriptEditor::_button_resource_previewed(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, Variant p_ud) { +void VisualScriptEditor::_button_resource_previewed(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud) { Array ud = p_ud; ERR_FAIL_COND(ud.size() != 2); @@ -2447,7 +2447,7 @@ String VisualScriptEditor::get_name() { return name; } -Ref<Texture> VisualScriptEditor::get_icon() { +Ref<Texture2D> VisualScriptEditor::get_icon() { return Control::get_icon("VisualScript", "EditorIcons"); } @@ -4467,9 +4467,9 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) { TreeItem *root = members->get_root(); - Ref<Texture> del_icon = Control::get_icon("Remove", "EditorIcons"); + Ref<Texture2D> del_icon = Control::get_icon("Remove", "EditorIcons"); - Ref<Texture> edit_icon = Control::get_icon("Edit", "EditorIcons"); + Ref<Texture2D> edit_icon = Control::get_icon("Edit", "EditorIcons"); if (ti->get_parent() == root->get_children()) { diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index 7f3bf79d50..40e9e1cc98 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -277,7 +277,7 @@ class VisualScriptEditor : public ScriptEditorBase { void _selected_method(const String &p_method, const String &p_type, const bool p_connecting); void _draw_color_over_button(Object *obj, Color p_color); - void _button_resource_previewed(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, Variant p_ud); + void _button_resource_previewed(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud); VisualScriptNode::TypeGuess _guess_output_type(int p_port_action_node, int p_port_action_output, Set<int> &p_visited_nodes); @@ -298,7 +298,7 @@ public: virtual Vector<String> get_functions(); virtual void reload_text(); virtual String get_name(); - virtual Ref<Texture> get_icon(); + virtual Ref<Texture2D> get_icon(); virtual bool is_unsaved(); virtual Variant get_edit_state(); virtual void set_edit_state(const Variant &p_state); diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index 99d7ffd05f..e629175094 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -98,7 +98,7 @@ void VisualScriptPropertySelector::_update_search() { List<MethodInfo> methods; List<PropertyInfo> props; TreeItem *category = NULL; - Ref<Texture> type_icons[Variant::VARIANT_MAX] = { + Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = { Control::get_icon("Variant", "EditorIcons"), Control::get_icon("bool", "EditorIcons"), Control::get_icon("int", "EditorIcons"), @@ -133,7 +133,7 @@ void VisualScriptPropertySelector::_update_search() { if (category) { category->set_text(0, b.replace_first("*", "")); category->set_selectable(0, false); - Ref<Texture> icon; + Ref<Texture2D> icon; String rep = b.replace("*", ""); icon = EditorNode::get_singleton()->get_class_icon(rep); category->set_icon(0, icon); diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 2763d30bb5..54d34a48c5 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -141,7 +141,10 @@ bool VideoStreamPlaybackWebm::open_file(const String &p_file) { } frame_data.resize((webm->getWidth() * webm->getHeight()) << 2); - texture->create(webm->getWidth(), webm->getHeight(), Image::FORMAT_RGBA8, Texture::FLAG_FILTER | Texture::FLAG_VIDEO_SURFACE); + Ref<Image> img; + img.instance(); + img->create(webm->getWidth(), webm->getHeight(), false, Image::FORMAT_RGBA8); + texture->create_from_image(img); return true; } @@ -231,7 +234,7 @@ void VideoStreamPlaybackWebm::set_audio_track(int p_idx) { audio_track = p_idx; } -Ref<Texture> VideoStreamPlaybackWebm::get_texture() const { +Ref<Texture2D> VideoStreamPlaybackWebm::get_texture() const { return texture; } @@ -356,7 +359,7 @@ void VideoStreamPlaybackWebm::update(float p_delta) { if (converted) { Ref<Image> img = memnew(Image(image.w, image.h, 0, Image::FORMAT_RGBA8, frame_data)); - texture->set_data(img); //Zero copy send to visual server + texture->update(img); //Zero copy send to visual server video_frame_done = true; } } diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h index e679196cf2..f2a68dd701 100644 --- a/modules/webm/video_stream_webm.h +++ b/modules/webm/video_stream_webm.h @@ -90,7 +90,7 @@ public: virtual void set_audio_track(int p_idx); - virtual Ref<Texture> get_texture() const; + virtual Ref<Texture2D> get_texture() const; virtual void update(float p_delta); virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata); diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 78d87c5629..7bbcb8cfa2 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1424,7 +1424,7 @@ public: return "Android"; } - virtual Ref<Texture> get_logo() const { + virtual Ref<Texture2D> get_logo() const { return logo; } @@ -1639,7 +1639,7 @@ public: #undef CLEANUP_AND_RETURN } - virtual Ref<Texture> get_run_icon() const { + virtual Ref<Texture2D> get_run_icon() const { return run_icon; } diff --git a/platform/android/os_android.h b/platform/android/os_android.h index c2f9a0992f..2979037adc 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -39,7 +39,7 @@ #include "main/input_default.h" //#include "power_android.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" class GodotJavaWrapper; class GodotIOJavaWrapper; diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 3561be8174..f9276c16b5 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -137,7 +137,7 @@ protected: public: virtual String get_name() const { return "iOS"; } virtual String get_os_name() const { return "iOS"; } - virtual Ref<Texture> get_logo() const { return logo; } + virtual Ref<Texture2D> get_logo() const { return logo; } virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const { List<String> list; diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index d2d96181f5..456b0ea8b7 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -43,7 +43,7 @@ #include "ios.h" #include "main/input_default.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "servers/visual_server.h" class OSIPhone : public OS_Unix { diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index c1cb8bcb58..6e1f7d749b 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -212,7 +212,7 @@ public: virtual String get_name() const; virtual String get_os_name() const; - virtual Ref<Texture> get_logo() const; + virtual Ref<Texture2D> get_logo() const; virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const; virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const; @@ -224,7 +224,7 @@ public: virtual String get_option_tooltip(int p_index) const { return p_index ? TTR("Stop HTTP Server") : TTR("Run exported HTML in the system's default browser."); } virtual Ref<ImageTexture> get_option_icon(int p_index) const; virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_option, int p_debug_flags); - virtual Ref<Texture> get_run_icon() const; + virtual Ref<Texture2D> get_run_icon() const; virtual void get_platform_features(List<String> *r_features) { @@ -300,7 +300,7 @@ String EditorExportPlatformJavaScript::get_os_name() const { return "HTML5"; } -Ref<Texture> EditorExportPlatformJavaScript::get_logo() const { +Ref<Texture2D> EditorExportPlatformJavaScript::get_logo() const { return logo; } @@ -598,7 +598,7 @@ Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_prese return OK; } -Ref<Texture> EditorExportPlatformJavaScript::get_run_icon() const { +Ref<Texture2D> EditorExportPlatformJavaScript::get_run_icon() const { return run_icon; } diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 13615de65b..f657ef483e 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -480,7 +480,7 @@ void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_s cursors_cache.erase(p_shape); } - Ref<Texture> texture = p_cursor; + Ref<Texture2D> texture = p_cursor; Ref<AtlasTexture> atlas_texture = p_cursor; Ref<Image> image; Size2 texture_size; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 65a18830ed..96ec7e8541 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -35,7 +35,7 @@ #include "drivers/unix/os_unix.h" #include "main/input_default.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include <emscripten/html5.h> diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index f372093268..312987b8cb 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -74,7 +74,7 @@ protected: public: virtual String get_name() const { return "Mac OSX"; } virtual String get_os_name() const { return "OSX"; } - virtual Ref<Texture> get_logo() const { return logo; } + virtual Ref<Texture2D> get_logo() const { return logo; } virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const { List<String> list; diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 190dbcf662..abd8a252f8 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -42,7 +42,7 @@ #include "main/input_default.h" #include "power_osx.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "servers/visual/visual_server_wrap_mt.h" #include "servers/visual_server.h" diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 314f369dc6..43012220b6 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1861,7 +1861,7 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c cursors_cache.erase(p_shape); } - Ref<Texture> texture = p_cursor; + Ref<Texture2D> texture = p_cursor; Ref<AtlasTexture> atlas_texture = p_cursor; Ref<Image> image; Size2 texture_size; diff --git a/platform/server/os_server.h b/platform/server/os_server.h index 46ca9cb6d1..7e931180e9 100644 --- a/platform/server/os_server.h +++ b/platform/server/os_server.h @@ -43,7 +43,7 @@ #include "platform/x11/power_x11.h" #endif #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "servers/visual_server.h" #undef CursorShape diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 96a196c65d..533293387d 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -1004,7 +1004,7 @@ public: return list; } - virtual Ref<Texture> get_logo() const { + virtual Ref<Texture2D> get_logo() const { return logo; } diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index fb43ab382e..11f30552da 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -41,7 +41,7 @@ #include "main/input_default.h" #include "power_uwp.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "servers/visual_server.h" #include <fcntl.h> diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 2daaf9359a..3a8e8bdb5a 100755 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2517,7 +2517,7 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap cursors_cache.erase(p_shape); } - Ref<Texture> texture = p_cursor; + Ref<Texture2D> texture = p_cursor; Ref<AtlasTexture> atlas_texture = p_cursor; Ref<Image> image; Size2 texture_size; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index cf16295a70..5c6b09629f 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -43,7 +43,7 @@ #include "main/input_default.h" #include "power_windows.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "servers/visual_server.h" #ifdef XAUDIO2_ENABLED #include "drivers/xaudio2/audio_driver_xaudio2.h" diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index ddcaf5f56e..b47c66c57f 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -35,9 +35,9 @@ #include "core/print_string.h" //#include "drivers/gles2/rasterizer_gles2.h" //#include "drivers/gles3/rasterizer_gles3.h" -#include "drivers/dummy/rasterizer_dummy.h" #include "errno.h" #include "key_mapping_x11.h" +#include "servers/visual/rasterizer/rasterizer_rd.h" #include "servers/visual/visual_server_raster.h" #include "servers/visual/visual_server_wrap_mt.h" @@ -406,7 +406,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a //temporary rendering_device = memnew(RenderingDeviceVulkan); rendering_device->initialize(context_vulkan); - RasterizerDummy::make_current(); + RasterizerRD::make_current(); // test shader @@ -3300,7 +3300,7 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c cursors_cache.erase(p_shape); } - Ref<Texture> texture = p_cursor; + Ref<Texture2D> texture = p_cursor; Ref<AtlasTexture> atlas_texture = p_cursor; Ref<Image> image; Size2 texture_size; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 5999e2840e..171f68783c 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -42,7 +42,7 @@ #include "main/input_default.h" #include "power_x11.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "servers/visual_server.h" //#include "servers/visual/visual_server_wrap_mt.h" #include "drivers/vulkan/rendering_device_vulkan.h" 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(); }; /////////////////////////////////////// diff --git a/servers/camera/camera_feed.cpp b/servers/camera/camera_feed.cpp index f58a8bfaaa..e8537950ec 100644 --- a/servers/camera/camera_feed.cpp +++ b/servers/camera/camera_feed.cpp @@ -29,9 +29,12 @@ /*************************************************************************/ #include "camera_feed.h" + #include "servers/visual_server.h" void CameraFeed::_bind_methods() { +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 // The setters prefixed with _ are only exposed so we can have feeds through GDNative! // They should not be called by the end user. @@ -51,7 +54,6 @@ void CameraFeed::_bind_methods() { ClassDB::bind_method(D_METHOD("_set_RGB_img", "rgb_img"), &CameraFeed::set_RGB_img); ClassDB::bind_method(D_METHOD("_set_YCbCr_img", "ycbcr_img"), &CameraFeed::set_YCbCr_img); - ClassDB::bind_method(D_METHOD("_set_YCbCr_imgs", "y_img", "cbcr_img"), &CameraFeed::set_YCbCr_imgs); ClassDB::bind_method(D_METHOD("_allocate_texture", "width", "height", "format", "texture_type", "data_type"), &CameraFeed::allocate_texture); ADD_GROUP("Feed", "feed_"); @@ -66,6 +68,7 @@ void CameraFeed::_bind_methods() { BIND_ENUM_CONSTANT(FEED_UNSPECIFIED); BIND_ENUM_CONSTANT(FEED_FRONT); BIND_ENUM_CONSTANT(FEED_BACK); +#endif } int CameraFeed::get_id() const { @@ -142,10 +145,13 @@ CameraFeed::CameraFeed() { position = CameraFeed::FEED_UNSPECIFIED; transform = Transform2D(1.0, 0.0, 0.0, -1.0, 0.0, 1.0); +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 // create a texture object VisualServer *vs = VisualServer::get_singleton(); texture[CameraServer::FEED_Y_IMAGE] = vs->texture_create(); // also used for RGBA texture[CameraServer::FEED_CBCR_IMAGE] = vs->texture_create(); +#endif } CameraFeed::CameraFeed(String p_name, FeedPosition p_position) { @@ -159,20 +165,28 @@ CameraFeed::CameraFeed(String p_name, FeedPosition p_position) { position = p_position; transform = Transform2D(1.0, 0.0, 0.0, -1.0, 0.0, 1.0); +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 // create a texture object VisualServer *vs = VisualServer::get_singleton(); texture[CameraServer::FEED_Y_IMAGE] = vs->texture_create(); // also used for RGBA texture[CameraServer::FEED_CBCR_IMAGE] = vs->texture_create(); +#endif } CameraFeed::~CameraFeed() { +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 // Free our textures VisualServer *vs = VisualServer::get_singleton(); vs->free(texture[CameraServer::FEED_Y_IMAGE]); vs->free(texture[CameraServer::FEED_CBCR_IMAGE]); +#endif } void CameraFeed::set_RGB_img(Ref<Image> p_rgb_img) { +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 if (active) { VisualServer *vs = VisualServer::get_singleton(); @@ -190,9 +204,12 @@ void CameraFeed::set_RGB_img(Ref<Image> p_rgb_img) { vs->texture_set_data(texture[CameraServer::FEED_RGBA_IMAGE], p_rgb_img); datatype = CameraFeed::FEED_RGB; } +#endif } void CameraFeed::set_YCbCr_img(Ref<Image> p_ycbcr_img) { +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 if (active) { VisualServer *vs = VisualServer::get_singleton(); @@ -210,9 +227,12 @@ void CameraFeed::set_YCbCr_img(Ref<Image> p_ycbcr_img) { vs->texture_set_data(texture[CameraServer::FEED_RGBA_IMAGE], p_ycbcr_img); datatype = CameraFeed::FEED_YCBCR; } +#endif } void CameraFeed::set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img) { +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 if (active) { VisualServer *vs = VisualServer::get_singleton(); @@ -240,8 +260,11 @@ void CameraFeed::set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img) { vs->texture_set_data(texture[CameraServer::FEED_CBCR_IMAGE], p_cbcr_img); datatype = CameraFeed::FEED_YCBCR_SEP; } +#endif } +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 void CameraFeed::allocate_texture(int p_width, int p_height, Image::Format p_format, VisualServer::TextureType p_texture_type, FeedDataType p_data_type) { VisualServer *vs = VisualServer::get_singleton(); @@ -255,6 +278,7 @@ void CameraFeed::allocate_texture(int p_width, int p_height, Image::Format p_for datatype = p_data_type; } +#endif bool CameraFeed::activate_feed() { // nothing to do here diff --git a/servers/camera/camera_feed.h b/servers/camera/camera_feed.h index d5029812c1..b99ded68e4 100644 --- a/servers/camera/camera_feed.h +++ b/servers/camera/camera_feed.h @@ -103,7 +103,10 @@ public: void set_RGB_img(Ref<Image> p_rgb_img); void set_YCbCr_img(Ref<Image> p_ycbcr_img); void set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img); +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 void allocate_texture(int p_width, int p_height, Image::Format p_format, VisualServer::TextureType p_texture_type, FeedDataType p_data_type); +#endif virtual bool activate_feed(); virtual void deactivate_feed(); diff --git a/servers/visual/SCsub b/servers/visual/SCsub index d730144861..9aa395db70 100644 --- a/servers/visual/SCsub +++ b/servers/visual/SCsub @@ -3,3 +3,5 @@ Import('env') env.add_source_files(env.servers_sources, "*.cpp") + +SConscript("rasterizer/SCsub") diff --git a/servers/visual/rasterizer/SCsub b/servers/visual/rasterizer/SCsub new file mode 100644 index 0000000000..70cd4087bf --- /dev/null +++ b/servers/visual/rasterizer/SCsub @@ -0,0 +1,6 @@ +#!/usr/bin/env python + +Import('env') + +env.add_source_files(env.servers_sources, "*.cpp") + diff --git a/servers/visual/rasterizer.cpp b/servers/visual/rasterizer/rasterizer.cpp index 77c716379a..77c716379a 100644 --- a/servers/visual/rasterizer.cpp +++ b/servers/visual/rasterizer/rasterizer.cpp diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer/rasterizer.h index 4d281f27a0..70b9ab18c6 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer/rasterizer.h @@ -60,7 +60,10 @@ public: virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0; virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0; virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0) = 0; +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 virtual void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) = 0; +#endif virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) = 0; virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) = 0; @@ -176,56 +179,44 @@ class RasterizerStorage { public: /* TEXTURE API */ - virtual RID texture_create() = 0; - virtual void texture_allocate(RID p_texture, - int p_width, - int p_height, - int p_depth_3d, - Image::Format p_format, - VS::TextureType p_type, - uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT) = 0; - - virtual void texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_level = 0) = 0; - - virtual void texture_set_data_partial(RID p_texture, - const Ref<Image> &p_image, - int src_x, int src_y, - int src_w, int src_h, - int dst_x, int dst_y, - int p_dst_mip, - int p_level = 0) = 0; - - virtual Ref<Image> texture_get_data(RID p_texture, int p_level = 0) const = 0; - virtual void texture_set_flags(RID p_texture, uint32_t p_flags) = 0; - virtual uint32_t texture_get_flags(RID p_texture) const = 0; - virtual Image::Format texture_get_format(RID p_texture) const = 0; - virtual VS::TextureType texture_get_type(RID p_texture) const = 0; - virtual uint32_t texture_get_texid(RID p_texture) const = 0; - virtual uint32_t texture_get_width(RID p_texture) const = 0; - virtual uint32_t texture_get_height(RID p_texture) const = 0; - virtual uint32_t texture_get_depth(RID p_texture) const = 0; - virtual void texture_set_size_override(RID p_texture, int p_width, int p_height, int p_depth_3d) = 0; + virtual RID texture_2d_create(const Ref<Image> &p_image) = 0; + virtual RID texture_2d_layered_create(const Vector<Ref<Image> > &p_layers, VS::TextureLayeredType p_layered_type) = 0; + virtual RID texture_3d_create(const Vector<Ref<Image> > &p_slices) = 0; //all slices, then all the mipmaps, must be coherent + + virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) = 0; //mostly used for video and streaming + virtual void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) = 0; + virtual void texture_3d_update(RID p_texture, const Ref<Image> &p_image, int p_depth, int p_mipmap) = 0; + + //these two APIs can be used together or in combination with the others. + virtual RID texture_2d_placeholder_create() = 0; + virtual RID texture_2d_layered_placeholder_create() = 0; + virtual RID texture_3d_placeholder_create() = 0; + + virtual Ref<Image> texture_2d_get(RID p_texture) const = 0; + virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const = 0; + virtual Ref<Image> texture_3d_slice_get(RID p_texture, int p_depth, int p_mipmap) const = 0; + + virtual void texture_replace(RID p_texture, RID p_by_texture) = 0; + virtual void texture_set_size_override(RID p_texture, int p_width, int p_height) = 0; +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 virtual void texture_bind(RID p_texture, uint32_t p_texture_no) = 0; +#endif virtual void texture_set_path(RID p_texture, const String &p_path) = 0; virtual String texture_get_path(RID p_texture) const = 0; - virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable) = 0; + virtual void texture_set_detect_3d_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) = 0; + virtual void texture_set_detect_normal_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) = 0; + virtual void texture_set_detect_roughness_callback(RID p_texture, VS::TextureDetectRoughnessCallback p_callback, void *p_userdata) = 0; virtual void texture_debug_usage(List<VS::TextureInfo> *r_info) = 0; - virtual RID texture_create_radiance_cubemap(RID p_source, int p_resolution = -1) const = 0; - - virtual void texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) = 0; - virtual void texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) = 0; - virtual void texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) = 0; - - virtual void textures_keep_original(bool p_enable) = 0; - virtual void texture_set_proxy(RID p_proxy, RID p_base) = 0; - virtual Size2 texture_size_with_proxy(RID p_texture) const = 0; virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) = 0; + virtual Size2 texture_size_with_proxy(RID p_proxy) const = 0; + /* SKY API */ virtual RID sky_create() = 0; diff --git a/servers/visual/rasterizer/rasterizer_canvas_rd.cpp b/servers/visual/rasterizer/rasterizer_canvas_rd.cpp new file mode 100644 index 0000000000..585647ba1d --- /dev/null +++ b/servers/visual/rasterizer/rasterizer_canvas_rd.cpp @@ -0,0 +1 @@ +#include "rasterizer_canvas_rd.h" diff --git a/servers/visual/rasterizer/rasterizer_canvas_rd.h b/servers/visual/rasterizer/rasterizer_canvas_rd.h new file mode 100644 index 0000000000..898fdb238a --- /dev/null +++ b/servers/visual/rasterizer/rasterizer_canvas_rd.h @@ -0,0 +1,28 @@ +#ifndef RASTERIZER_CANVAS_RD_H +#define RASTERIZER_CANVAS_RD_H + +#include "servers/visual/rasterizer/rasterizer.h" + +class RasterizerCanvasRD : public RasterizerCanvas { +public: + RID light_internal_create() { return RID(); } + void light_internal_update(RID p_rid, Light *p_light) {} + void light_internal_free(RID p_rid) {} + + void canvas_begin(){}; + void canvas_end(){}; + + void canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_transform){}; + void canvas_debug_viewport_shadows(Light *p_lights_with_shadow){}; + + void canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {} + + void reset_canvas() {} + + void draw_window_margins(int *p_margins, RID *p_margin_textures) {} + + RasterizerCanvasRD() {} + ~RasterizerCanvasRD() {} +}; + +#endif // RASTERIZER_CANVAS_RD_H diff --git a/servers/visual/rasterizer/rasterizer_rd.cpp b/servers/visual/rasterizer/rasterizer_rd.cpp new file mode 100644 index 0000000000..ecbcc2b251 --- /dev/null +++ b/servers/visual/rasterizer/rasterizer_rd.cpp @@ -0,0 +1,7 @@ +#include "rasterizer_rd.h" + +RasterizerRD::RasterizerRD() { + canvas = memnew(RasterizerCanvasRD); + storage = memnew(RasterizerStorageRD); + scene = memnew(RasterizerSceneForwardRD); +} diff --git a/servers/visual/rasterizer/rasterizer_rd.h b/servers/visual/rasterizer/rasterizer_rd.h new file mode 100644 index 0000000000..17ff29c19b --- /dev/null +++ b/servers/visual/rasterizer/rasterizer_rd.h @@ -0,0 +1,49 @@ +#ifndef RASTERIZER_RD_H +#define RASTERIZER_RD_H + +#include "core/os/os.h" +#include "servers/visual/rasterizer/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer_canvas_rd.h" +#include "servers/visual/rasterizer/rasterizer_scene_forward_rd.h" +#include "servers/visual/rasterizer/rasterizer_storage_rd.h" +class RasterizerRD : public Rasterizer { +protected: + RasterizerCanvasRD *canvas; + RasterizerStorageRD *storage; + RasterizerSceneForwardRD *scene; + +public: + RasterizerStorage *get_storage() { return storage; } + RasterizerCanvas *get_canvas() { return canvas; } + RasterizerScene *get_scene() { return scene; } + + void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {} + + void initialize() {} + void begin_frame(double frame_step) {} + void set_current_render_target(RID p_render_target) {} + void restore_render_target(bool p_3d_was_drawn) {} + void clear_render_target(const Color &p_color) {} + void blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect, int p_screen = 0) {} + void output_lens_distorted_to_screen(RID p_render_target, const Rect2 &p_screen_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) {} + void end_frame(bool p_swap_buffers) { OS::get_singleton()->swap_buffers(); } + void finalize() {} + + static Error is_viable() { + return OK; + } + + static Rasterizer *_create_current() { + return memnew(RasterizerRD); + } + + static void make_current() { + _create_func = _create_current; + } + + virtual bool is_low_end() const { return true; } + + RasterizerRD(); + ~RasterizerRD() {} +}; +#endif // RASTERIZER_RD_H diff --git a/servers/visual/rasterizer/rasterizer_scene_forward_rd.cpp b/servers/visual/rasterizer/rasterizer_scene_forward_rd.cpp new file mode 100644 index 0000000000..56d100ba08 --- /dev/null +++ b/servers/visual/rasterizer/rasterizer_scene_forward_rd.cpp @@ -0,0 +1 @@ +#include "rasterizer_scene_forward_rd.h" diff --git a/servers/visual/rasterizer/rasterizer_scene_forward_rd.h b/servers/visual/rasterizer/rasterizer_scene_forward_rd.h new file mode 100644 index 0000000000..03cadb5ba4 --- /dev/null +++ b/servers/visual/rasterizer/rasterizer_scene_forward_rd.h @@ -0,0 +1,85 @@ +#ifndef RASTERIZER_SCENE_FORWARD_RD_H +#define RASTERIZER_SCENE_FORWARD_RD_H + +#include "servers/visual/rasterizer/rasterizer.h" + +class RasterizerSceneForwardRD : public RasterizerScene { +public: + /* SHADOW ATLAS API */ + + RID shadow_atlas_create() { return RID(); } + void shadow_atlas_set_size(RID p_atlas, int p_size) {} + void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) {} + bool shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) { return false; } + + int get_directional_light_shadow_size(RID p_light_intance) { return 0; } + void set_directional_shadow_count(int p_count) {} + + /* ENVIRONMENT API */ + + RID environment_create() { return RID(); } + + void environment_set_background(RID p_env, VS::EnvironmentBG p_bg) {} + void environment_set_sky(RID p_env, RID p_sky) {} + void environment_set_sky_custom_fov(RID p_env, float p_scale) {} + void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {} + void environment_set_bg_color(RID p_env, const Color &p_color) {} + void environment_set_bg_energy(RID p_env, float p_energy) {} + void environment_set_canvas_max_layer(RID p_env, int p_max_layer) {} + void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0) {} + + void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) {} + void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) {} + void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {} + + void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) {} + + void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) {} + void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, VS::EnvironmentSSAOQuality p_quality, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {} + + void environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {} + + void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) {} + + void environment_set_fog(RID p_env, bool p_enable, const Color &p_color, const Color &p_sun_color, float p_sun_amount) {} + void environment_set_fog_depth(RID p_env, bool p_enable, float p_depth_begin, float p_depth_end, float p_depth_curve, bool p_transmit, float p_transmit_curve) {} + void environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) {} + + bool is_environment(RID p_env) { return false; } + VS::EnvironmentBG environment_get_background(RID p_env) { return VS::ENV_BG_KEEP; } + int environment_get_canvas_max_layer(RID p_env) { return 0; } + + RID light_instance_create(RID p_light) { return RID(); } + void light_instance_set_transform(RID p_light_instance, const Transform &p_transform) {} + void light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform &p_transform, float p_far, float p_split, int p_pass, float p_bias_scale = 1.0) {} + void light_instance_mark_visible(RID p_light_instance) {} + + RID reflection_atlas_create() { return RID(); } + void reflection_atlas_set_size(RID p_ref_atlas, int p_size) {} + void reflection_atlas_set_subdivision(RID p_ref_atlas, int p_subdiv) {} + + RID reflection_probe_instance_create(RID p_probe) { return RID(); } + void reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform) {} + void reflection_probe_release_atlas_index(RID p_instance) {} + bool reflection_probe_instance_needs_redraw(RID p_instance) { return false; } + bool reflection_probe_instance_has_reflection(RID p_instance) { return false; } + bool reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) { return false; } + bool reflection_probe_instance_postprocess_step(RID p_instance) { return true; } + + RID gi_probe_instance_create() { return RID(); } + void gi_probe_instance_set_light_data(RID p_probe, RID p_base, RID p_data) {} + void gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) {} + void gi_probe_instance_set_bounds(RID p_probe, const Vector3 &p_bounds) {} + + void render_scene(const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {} + void render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) {} + + void set_scene_pass(uint64_t p_pass) {} + void set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw) {} + + bool free(RID p_rid) { return true; } + + RasterizerSceneForwardRD() {} + ~RasterizerSceneForwardRD() {} +}; +#endif // RASTERIZER_SCENE_FORWARD_RD_H diff --git a/servers/visual/rasterizer/rasterizer_storage_rd.cpp b/servers/visual/rasterizer/rasterizer_storage_rd.cpp new file mode 100644 index 0000000000..bdaaba8d10 --- /dev/null +++ b/servers/visual/rasterizer/rasterizer_storage_rd.cpp @@ -0,0 +1,78 @@ +#include "rasterizer_storage_rd.h" + +RID RasterizerStorageRD::texture_2d_create(const Ref<Image> &p_image) { + + return RID(); +} + +RID RasterizerStorageRD::texture_2d_layered_create(const Vector<Ref<Image> > &p_layers, VS::TextureLayeredType p_layered_type) { + + return RID(); +} +RID RasterizerStorageRD::texture_3d_create(const Vector<Ref<Image> > &p_slices) { + + return RID(); +} + +void RasterizerStorageRD::texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer) { +} +void RasterizerStorageRD::texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer) { +} +void RasterizerStorageRD::texture_3d_update(RID p_texture, const Ref<Image> &p_image, int p_depth, int p_mipmap) { +} + +//these two APIs can be used together or in combination with the others. +RID RasterizerStorageRD::texture_2d_placeholder_create() { + + return RID(); +} +RID RasterizerStorageRD::texture_2d_layered_placeholder_create() { + + return RID(); +} +RID RasterizerStorageRD::texture_3d_placeholder_create() { + + return RID(); +} + +Ref<Image> RasterizerStorageRD::texture_2d_get(RID p_texture) const { + + return Ref<Image>(); +} +Ref<Image> RasterizerStorageRD::texture_2d_layer_get(RID p_texture, int p_layer) const { + + return Ref<Image>(); +} +Ref<Image> RasterizerStorageRD::texture_3d_slice_get(RID p_texture, int p_depth, int p_mipmap) const { + + return Ref<Image>(); +} + +void RasterizerStorageRD::texture_replace(RID p_texture, RID p_by_texture) { +} +void RasterizerStorageRD::texture_set_size_override(RID p_texture, int p_width, int p_height) { +} + +void RasterizerStorageRD::texture_set_path(RID p_texture, const String &p_path) { +} +String RasterizerStorageRD::texture_get_path(RID p_texture) const { + return String(); +} + +void RasterizerStorageRD::texture_set_detect_3d_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) { +} +void RasterizerStorageRD::texture_set_detect_normal_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) { +} +void RasterizerStorageRD::texture_set_detect_roughness_callback(RID p_texture, VS::TextureDetectRoughnessCallback p_callback, void *p_userdata) { +} +void RasterizerStorageRD::texture_debug_usage(List<VS::TextureInfo> *r_info) { +} + +void RasterizerStorageRD::texture_set_proxy(RID p_proxy, RID p_base) { +} +void RasterizerStorageRD::texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) { +} + +Size2 RasterizerStorageRD::texture_size_with_proxy(RID p_proxy) const { + return Size2(); +} diff --git a/servers/visual/rasterizer/rasterizer_storage_rd.h b/servers/visual/rasterizer/rasterizer_storage_rd.h new file mode 100644 index 0000000000..9c41f81fd7 --- /dev/null +++ b/servers/visual/rasterizer/rasterizer_storage_rd.h @@ -0,0 +1,579 @@ +#ifndef RASTERIZER_STORAGE_RD_H +#define RASTERIZER_STORAGE_RD_H + +#include "core/rid_owner.h" +#include "servers/visual/rasterizer/rasterizer.h" + +class RasterizerStorageRD : public RasterizerStorage { +public: + /* TEXTURE API */ + struct RDTexture { + int width; + int height; + uint32_t flags; + Image::Format format; + Ref<Image> image; + String path; + }; + + struct RDSurface { + uint32_t format; + VS::PrimitiveType primitive; + PoolVector<uint8_t> array; + int vertex_count; + PoolVector<uint8_t> index_array; + int index_count; + AABB aabb; + Vector<PoolVector<uint8_t> > blend_shapes; + Vector<AABB> bone_aabbs; + }; + + struct RDMesh { + Vector<RDSurface> surfaces; + int blend_shape_count; + VS::BlendShapeMode blend_shape_mode; + }; + + mutable RID_PtrOwner<RDTexture> texture_owner; + mutable RID_PtrOwner<RDMesh> mesh_owner; + + virtual RID texture_2d_create(const Ref<Image> &p_image); + virtual RID texture_2d_layered_create(const Vector<Ref<Image> > &p_layers, VS::TextureLayeredType p_layered_type); + virtual RID texture_3d_create(const Vector<Ref<Image> > &p_slices); //all slices, then all the mipmaps, must be coherent + + virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0); //mostly used for video and streaming + virtual void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0); + virtual void texture_3d_update(RID p_texture, const Ref<Image> &p_image, int p_depth, int p_mipmap); + + //these two APIs can be used together or in combination with the others. + virtual RID texture_2d_placeholder_create(); + virtual RID texture_2d_layered_placeholder_create(); + virtual RID texture_3d_placeholder_create(); + + virtual Ref<Image> texture_2d_get(RID p_texture) const; + virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const; + virtual Ref<Image> texture_3d_slice_get(RID p_texture, int p_depth, int p_mipmap) const; + + virtual void texture_replace(RID p_texture, RID p_by_texture); + virtual void texture_set_size_override(RID p_texture, int p_width, int p_height); + + virtual void texture_set_path(RID p_texture, const String &p_path); + virtual String texture_get_path(RID p_texture) const; + + virtual void texture_set_detect_3d_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata); + virtual void texture_set_detect_normal_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata); + virtual void texture_set_detect_roughness_callback(RID p_texture, VS::TextureDetectRoughnessCallback p_callback, void *p_userdata); + + virtual void texture_debug_usage(List<VS::TextureInfo> *r_info); + + virtual void texture_set_proxy(RID p_proxy, RID p_base); + virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable); + + virtual Size2 texture_size_with_proxy(RID p_proxy) const; + + /* SKY API */ + + RID sky_create() { return RID(); } + void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) {} + + /* SHADER API */ + + RID shader_create() { return RID(); } + + void shader_set_code(RID p_shader, const String &p_code) {} + String shader_get_code(RID p_shader) const { return ""; } + void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {} + + void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {} + RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const { return RID(); } + + /* COMMON MATERIAL API */ + + RID material_create() { return RID(); } + + void material_set_render_priority(RID p_material, int priority) {} + void material_set_shader(RID p_shader_material, RID p_shader) {} + RID material_get_shader(RID p_shader_material) const { return RID(); } + + void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {} + Variant material_get_param(RID p_material, const StringName &p_param) const { return Variant(); } + Variant material_get_param_default(RID p_material, const StringName &p_param) const { return Variant(); } + + void material_set_line_width(RID p_material, float p_width) {} + + void material_set_next_pass(RID p_material, RID p_next_material) {} + + bool material_is_animated(RID p_material) { return false; } + bool material_casts_shadows(RID p_material) { return false; } + + void material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {} + void material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {} + + /* MESH API */ + + RID mesh_create() { + RDMesh *mesh = memnew(RDMesh); + ERR_FAIL_COND_V(!mesh, RID()); + mesh->blend_shape_count = 0; + mesh->blend_shape_mode = VS::BLEND_SHAPE_MODE_NORMALIZED; + return mesh_owner.make_rid(mesh); + } + + void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND(!m); + + m->surfaces.push_back(RDSurface()); + RDSurface *s = &m->surfaces.write[m->surfaces.size() - 1]; + s->format = p_format; + s->primitive = p_primitive; + s->array = p_array; + s->vertex_count = p_vertex_count; + s->index_array = p_index_array; + s->index_count = p_index_count; + s->aabb = p_aabb; + s->blend_shapes = p_blend_shapes; + s->bone_aabbs = p_bone_aabbs; + } + + void mesh_set_blend_shape_count(RID p_mesh, int p_amount) { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND(!m); + m->blend_shape_count = p_amount; + } + int mesh_get_blend_shape_count(RID p_mesh) const { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!m, 0); + return m->blend_shape_count; + } + + void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND(!m); + m->blend_shape_mode = p_mode; + } + VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!m, VS::BLEND_SHAPE_MODE_NORMALIZED); + return m->blend_shape_mode; + } + + void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) {} + + void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) {} + RID mesh_surface_get_material(RID p_mesh, int p_surface) const { return RID(); } + + int mesh_surface_get_array_len(RID p_mesh, int p_surface) const { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!m, 0); + + return m->surfaces[p_surface].vertex_count; + } + int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!m, 0); + + return m->surfaces[p_surface].index_count; + } + + PoolVector<uint8_t> mesh_surface_get_array(RID p_mesh, int p_surface) const { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!m, PoolVector<uint8_t>()); + + return m->surfaces[p_surface].array; + } + PoolVector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!m, PoolVector<uint8_t>()); + + return m->surfaces[p_surface].index_array; + } + + uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!m, 0); + + return m->surfaces[p_surface].format; + } + VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!m, VS::PRIMITIVE_POINTS); + + return m->surfaces[p_surface].primitive; + } + + AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!m, AABB()); + + return m->surfaces[p_surface].aabb; + } + Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!m, Vector<PoolVector<uint8_t> >()); + + return m->surfaces[p_surface].blend_shapes; + } + Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!m, Vector<AABB>()); + + return m->surfaces[p_surface].bone_aabbs; + } + + void mesh_remove_surface(RID p_mesh, int p_index) { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND(!m); + ERR_FAIL_COND(p_index >= m->surfaces.size()); + + m->surfaces.remove(p_index); + } + int mesh_get_surface_count(RID p_mesh) const { + RDMesh *m = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND_V(!m, 0); + return m->surfaces.size(); + } + + void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {} + AABB mesh_get_custom_aabb(RID p_mesh) const { return AABB(); } + + AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const { return AABB(); } + void mesh_clear(RID p_mesh) {} + + /* MULTIMESH API */ + + virtual RID multimesh_create() { return RID(); } + + void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, VS::MultimeshColorFormat p_color_format, VS::MultimeshCustomDataFormat p_data = VS::MULTIMESH_CUSTOM_DATA_NONE) {} + int multimesh_get_instance_count(RID p_multimesh) const { return 0; } + + void multimesh_set_mesh(RID p_multimesh, RID p_mesh) {} + void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform &p_transform) {} + void multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) {} + void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) {} + void multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) {} + + RID multimesh_get_mesh(RID p_multimesh) const { return RID(); } + + Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const { return Transform(); } + Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const { return Transform2D(); } + Color multimesh_instance_get_color(RID p_multimesh, int p_index) const { return Color(); } + Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const { return Color(); } + + void multimesh_set_as_bulk_array(RID p_multimesh, const PoolVector<float> &p_array) {} + + void multimesh_set_visible_instances(RID p_multimesh, int p_visible) {} + int multimesh_get_visible_instances(RID p_multimesh) const { return 0; } + + AABB multimesh_get_aabb(RID p_multimesh) const { return AABB(); } + + /* IMMEDIATE API */ + + RID immediate_create() { return RID(); } + void immediate_begin(RID p_immediate, VS::PrimitiveType p_rimitive, RID p_texture = RID()) {} + void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {} + void immediate_normal(RID p_immediate, const Vector3 &p_normal) {} + void immediate_tangent(RID p_immediate, const Plane &p_tangent) {} + void immediate_color(RID p_immediate, const Color &p_color) {} + void immediate_uv(RID p_immediate, const Vector2 &tex_uv) {} + void immediate_uv2(RID p_immediate, const Vector2 &tex_uv) {} + void immediate_end(RID p_immediate) {} + void immediate_clear(RID p_immediate) {} + void immediate_set_material(RID p_immediate, RID p_material) {} + RID immediate_get_material(RID p_immediate) const { return RID(); } + AABB immediate_get_aabb(RID p_immediate) const { return AABB(); } + + /* SKELETON API */ + + RID skeleton_create() { return RID(); } + void skeleton_allocate(RID p_skeleton, int p_bones, bool p_2d_skeleton = false) {} + void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) {} + void skeleton_set_world_transform(RID p_skeleton, bool p_enable, const Transform &p_world_transform) {} + int skeleton_get_bone_count(RID p_skeleton) const { return 0; } + void skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform) {} + Transform skeleton_bone_get_transform(RID p_skeleton, int p_bone) const { return Transform(); } + void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) {} + Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const { return Transform2D(); } + + /* Light API */ + + RID light_create(VS::LightType p_type) { return RID(); } + + RID directional_light_create() { return light_create(VS::LIGHT_DIRECTIONAL); } + RID omni_light_create() { return light_create(VS::LIGHT_OMNI); } + RID spot_light_create() { return light_create(VS::LIGHT_SPOT); } + + void light_set_color(RID p_light, const Color &p_color) {} + void light_set_param(RID p_light, VS::LightParam p_param, float p_value) {} + void light_set_shadow(RID p_light, bool p_enabled) {} + void light_set_shadow_color(RID p_light, const Color &p_color) {} + void light_set_projector(RID p_light, RID p_texture) {} + void light_set_negative(RID p_light, bool p_enable) {} + void light_set_cull_mask(RID p_light, uint32_t p_mask) {} + void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {} + void light_set_use_gi(RID p_light, bool p_enabled) {} + + void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) {} + void light_omni_set_shadow_detail(RID p_light, VS::LightOmniShadowDetail p_detail) {} + + void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) {} + void light_directional_set_blend_splits(RID p_light, bool p_enable) {} + bool light_directional_get_blend_splits(RID p_light) const { return false; } + void light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode) {} + VS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const { return VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE; } + + VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) { return VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; } + VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) { return VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; } + + bool light_has_shadow(RID p_light) const { return false; } + + VS::LightType light_get_type(RID p_light) const { return VS::LIGHT_OMNI; } + AABB light_get_aabb(RID p_light) const { return AABB(); } + float light_get_param(RID p_light, VS::LightParam p_param) { return 0.0; } + Color light_get_color(RID p_light) { return Color(); } + bool light_get_use_gi(RID p_light) { return false; } + uint64_t light_get_version(RID p_light) const { return 0; } + + /* PROBE API */ + + RID reflection_probe_create() { return RID(); } + + void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode) {} + void reflection_probe_set_intensity(RID p_probe, float p_intensity) {} + void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) {} + void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) {} + void reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) {} + void reflection_probe_set_max_distance(RID p_probe, float p_distance) {} + void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {} + void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {} + void reflection_probe_set_as_interior(RID p_probe, bool p_enable) {} + void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {} + void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {} + void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {} + void reflection_probe_set_resolution(RID p_probe, int p_resolution) {} + + AABB reflection_probe_get_aabb(RID p_probe) const { return AABB(); } + VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const { return VisualServer::REFLECTION_PROBE_UPDATE_ONCE; } + uint32_t reflection_probe_get_cull_mask(RID p_probe) const { return 0; } + Vector3 reflection_probe_get_extents(RID p_probe) const { return Vector3(); } + Vector3 reflection_probe_get_origin_offset(RID p_probe) const { return Vector3(); } + float reflection_probe_get_origin_max_distance(RID p_probe) const { return 0.0; } + bool reflection_probe_renders_shadows(RID p_probe) const { return false; } + + void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {} + void instance_remove_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {} + + void instance_add_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {} + void instance_remove_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {} + + /* GI PROBE API */ + + RID gi_probe_create() { return RID(); } + + void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) {} + AABB gi_probe_get_bounds(RID p_probe) const { return AABB(); } + + void gi_probe_set_cell_size(RID p_probe, float p_range) {} + float gi_probe_get_cell_size(RID p_probe) const { return 0.0; } + + void gi_probe_set_to_cell_xform(RID p_probe, const Transform &p_xform) {} + Transform gi_probe_get_to_cell_xform(RID p_probe) const { return Transform(); } + + void gi_probe_set_dynamic_data(RID p_probe, const PoolVector<int> &p_data) {} + PoolVector<int> gi_probe_get_dynamic_data(RID p_probe) const { + PoolVector<int> p; + return p; + } + + void gi_probe_set_dynamic_range(RID p_probe, int p_range) {} + int gi_probe_get_dynamic_range(RID p_probe) const { return 0; } + + void gi_probe_set_energy(RID p_probe, float p_range) {} + float gi_probe_get_energy(RID p_probe) const { return 0.0; } + + void gi_probe_set_bias(RID p_probe, float p_range) {} + float gi_probe_get_bias(RID p_probe) const { return 0.0; } + + void gi_probe_set_normal_bias(RID p_probe, float p_range) {} + float gi_probe_get_normal_bias(RID p_probe) const { return 0.0; } + + void gi_probe_set_propagation(RID p_probe, float p_range) {} + float gi_probe_get_propagation(RID p_probe) const { return 0.0; } + + void gi_probe_set_interior(RID p_probe, bool p_enable) {} + bool gi_probe_is_interior(RID p_probe) const { return false; } + + void gi_probe_set_compress(RID p_probe, bool p_enable) {} + bool gi_probe_is_compressed(RID p_probe) const { return false; } + + uint32_t gi_probe_get_version(RID p_probe) { return 0; } + + GIProbeCompression gi_probe_get_dynamic_data_get_preferred_compression() const { return GI_PROBE_UNCOMPRESSED; } + RID gi_probe_dynamic_data_create(int p_width, int p_height, int p_depth, GIProbeCompression p_compression) { return RID(); } + void gi_probe_dynamic_data_update(RID p_gi_probe_data, int p_depth_slice, int p_slice_count, int p_mipmap, const void *p_data) {} + + /* LIGHTMAP CAPTURE */ + struct Instantiable { + + SelfList<RasterizerScene::InstanceBase>::List instance_list; + + _FORCE_INLINE_ void instance_change_notify(bool p_aabb = true, bool p_materials = true) { + + SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first(); + while (instances) { + + instances->self()->base_changed(p_aabb, p_materials); + instances = instances->next(); + } + } + + _FORCE_INLINE_ void instance_remove_deps() { + SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first(); + while (instances) { + + SelfList<RasterizerScene::InstanceBase> *next = instances->next(); + instances->self()->base_removed(); + instances = next; + } + } + + Instantiable() {} + virtual ~Instantiable() { + } + }; + + struct LightmapCapture : public Instantiable { + + PoolVector<LightmapCaptureOctree> octree; + AABB bounds; + Transform cell_xform; + int cell_subdiv; + float energy; + LightmapCapture() { + energy = 1.0; + cell_subdiv = 1; + } + }; + + mutable RID_PtrOwner<LightmapCapture> lightmap_capture_data_owner; + void lightmap_capture_set_bounds(RID p_capture, const AABB &p_bounds) {} + AABB lightmap_capture_get_bounds(RID p_capture) const { return AABB(); } + void lightmap_capture_set_octree(RID p_capture, const PoolVector<uint8_t> &p_octree) {} + RID lightmap_capture_create() { + LightmapCapture *capture = memnew(LightmapCapture); + return lightmap_capture_data_owner.make_rid(capture); + } + PoolVector<uint8_t> lightmap_capture_get_octree(RID p_capture) const { + const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); + ERR_FAIL_COND_V(!capture, PoolVector<uint8_t>()); + return PoolVector<uint8_t>(); + } + void lightmap_capture_set_octree_cell_transform(RID p_capture, const Transform &p_xform) {} + Transform lightmap_capture_get_octree_cell_transform(RID p_capture) const { return Transform(); } + void lightmap_capture_set_octree_cell_subdiv(RID p_capture, int p_subdiv) {} + int lightmap_capture_get_octree_cell_subdiv(RID p_capture) const { return 0; } + void lightmap_capture_set_energy(RID p_capture, float p_energy) {} + float lightmap_capture_get_energy(RID p_capture) const { return 0.0; } + const PoolVector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const { + const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); + ERR_FAIL_COND_V(!capture, NULL); + return &capture->octree; + } + + /* PARTICLES */ + + RID particles_create() { return RID(); } + + void particles_set_emitting(RID p_particles, bool p_emitting) {} + void particles_set_amount(RID p_particles, int p_amount) {} + void particles_set_lifetime(RID p_particles, float p_lifetime) {} + void particles_set_one_shot(RID p_particles, bool p_one_shot) {} + void particles_set_pre_process_time(RID p_particles, float p_time) {} + void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) {} + void particles_set_randomness_ratio(RID p_particles, float p_ratio) {} + void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) {} + void particles_set_speed_scale(RID p_particles, float p_scale) {} + void particles_set_use_local_coordinates(RID p_particles, bool p_enable) {} + void particles_set_process_material(RID p_particles, RID p_material) {} + void particles_set_fixed_fps(RID p_particles, int p_fps) {} + void particles_set_fractional_delta(RID p_particles, bool p_enable) {} + void particles_restart(RID p_particles) {} + + void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) {} + + void particles_set_draw_passes(RID p_particles, int p_count) {} + void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) {} + + void particles_request_process(RID p_particles) {} + AABB particles_get_current_aabb(RID p_particles) { return AABB(); } + AABB particles_get_aabb(RID p_particles) const { return AABB(); } + + void particles_set_emission_transform(RID p_particles, const Transform &p_transform) {} + + bool particles_get_emitting(RID p_particles) { return false; } + int particles_get_draw_passes(RID p_particles) const { return 0; } + RID particles_get_draw_pass_mesh(RID p_particles, int p_pass) const { return RID(); } + + virtual bool particles_is_inactive(RID p_particles) const { return false; } + + /* RENDER TARGET */ + + RID render_target_create() { return RID(); } + void render_target_set_position(RID p_render_target, int p_x, int p_y) {} + void render_target_set_size(RID p_render_target, int p_width, int p_height) {} + RID render_target_get_texture(RID p_render_target) const { return RID(); } + void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) {} + void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) {} + bool render_target_was_used(RID p_render_target) { return false; } + void render_target_clear_used(RID p_render_target) {} + void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa) {} + + /* CANVAS SHADOW */ + + RID canvas_light_shadow_buffer_create(int p_width) { return RID(); } + + /* LIGHT SHADOW MAPPING */ + + RID canvas_light_occluder_create() { return RID(); } + void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) {} + + VS::InstanceType get_base_type(RID p_rid) const { + if (mesh_owner.owns(p_rid)) { + return VS::INSTANCE_MESH; + } + + return VS::INSTANCE_NONE; + } + + bool free(RID p_rid) { + + if (texture_owner.owns(p_rid)) { + // delete the texture + RDTexture *texture = texture_owner.getornull(p_rid); + texture_owner.free(p_rid); + memdelete(texture); + } + return true; + } + + bool has_os_feature(const String &p_feature) const { return false; } + + void update_dirty_resources() {} + + void set_debug_generate_wireframes(bool p_generate) {} + + void render_info_begin_capture() {} + void render_info_end_capture() {} + int get_captured_render_info(VS::RenderInfo p_info) { return 0; } + + int get_render_info(VS::RenderInfo p_info) { return 0; } + String get_video_adapter_name() const { return String(); } + String get_video_adapter_vendor() const { return String(); } + + static RasterizerStorage *base_singleton; + + RasterizerStorageRD(){}; + ~RasterizerStorageRD() {} +}; + +#endif // RASTERIZER_STORAGE_RD_H diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h index 8044afe164..7b5d2f6cb4 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/visual/visual_server_canvas.h @@ -31,7 +31,7 @@ #ifndef VISUALSERVERCANVAS_H #define VISUALSERVERCANVAS_H -#include "rasterizer.h" +#include "rasterizer/rasterizer.h" #include "visual_server_viewport.h" class VisualServerCanvas { @@ -90,7 +90,7 @@ public: } }; - struct LightOccluderPolygon { + struct LightOccluderPolygon { bool active; Rect2 aabb; diff --git a/servers/visual/visual_server_globals.h b/servers/visual/visual_server_globals.h index 5a9d365eca..5bc76afe4c 100644 --- a/servers/visual/visual_server_globals.h +++ b/servers/visual/visual_server_globals.h @@ -31,7 +31,7 @@ #ifndef VISUAL_SERVER_GLOBALS_H #define VISUAL_SERVER_GLOBALS_H -#include "rasterizer.h" +#include "rasterizer/rasterizer.h" class VisualServerCanvas; class VisualServerViewport; diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 9afcfc4648..ff2a4b01c4 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -32,7 +32,7 @@ #define VISUAL_SERVER_RASTER_H #include "core/math/octree.h" -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "servers/visual_server.h" #include "visual_server_canvas.h" #include "visual_server_globals.h" @@ -142,33 +142,42 @@ public: /* TEXTURE API */ - BIND0R(RID, texture_create) - BIND7(texture_allocate, RID, int, int, int, Image::Format, TextureType, uint32_t) - BIND3(texture_set_data, RID, const Ref<Image> &, int) - BIND10(texture_set_data_partial, RID, const Ref<Image> &, int, int, int, int, int, int, int, int) - BIND2RC(Ref<Image>, texture_get_data, RID, int) - BIND2(texture_set_flags, RID, uint32_t) - BIND1RC(uint32_t, texture_get_flags, RID) - BIND1RC(Image::Format, texture_get_format, RID) - BIND1RC(TextureType, texture_get_type, RID) - BIND1RC(uint32_t, texture_get_texid, RID) - BIND1RC(uint32_t, texture_get_width, RID) - BIND1RC(uint32_t, texture_get_height, RID) - BIND1RC(uint32_t, texture_get_depth, RID) - BIND4(texture_set_size_override, RID, int, int, int) + //these go pass-through, as they can be called from any thread + BIND1R(RID, texture_2d_create, const Ref<Image> &) + BIND2R(RID, texture_2d_layered_create, const Vector<Ref<Image> > &, TextureLayeredType) + BIND1R(RID, texture_3d_create, const Vector<Ref<Image> > &) + + //goes pass-through + BIND3(texture_2d_update_immediate, RID, const Ref<Image> &, int) + //these go through command queue if they are in another thread + BIND3(texture_2d_update, RID, const Ref<Image> &, int) + BIND4(texture_3d_update, RID, const Ref<Image> &, int, int) + + //these also go pass-through + BIND0R(RID, texture_2d_placeholder_create) + BIND0R(RID, texture_2d_layered_placeholder_create) + BIND0R(RID, texture_3d_placeholder_create) + + BIND1RC(Ref<Image>, texture_2d_get, RID) + BIND2RC(Ref<Image>, texture_2d_layer_get, RID, int) + BIND3RC(Ref<Image>, texture_3d_slice_get, RID, int, int) + + BIND2(texture_replace, RID, RID) + + BIND3(texture_set_size_override, RID, int, int) +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 BIND2(texture_bind, RID, uint32_t) +#endif BIND3(texture_set_detect_3d_callback, RID, TextureDetectCallback, void *) - BIND3(texture_set_detect_srgb_callback, RID, TextureDetectCallback, void *) BIND3(texture_set_detect_normal_callback, RID, TextureDetectCallback, void *) + BIND3(texture_set_detect_roughness_callback, RID, TextureDetectRoughnessCallback, void *) BIND2(texture_set_path, RID, const String &) BIND1RC(String, texture_get_path, RID) - BIND1(texture_set_shrink_all_x2_on_set_data, bool) BIND1(texture_debug_usage, List<TextureInfo> *) - BIND1(textures_keep_original, bool) - BIND2(texture_set_proxy, RID, RID) BIND2(texture_set_force_redraw_if_visible, RID, bool) @@ -502,7 +511,10 @@ public: BIND2(environment_set_bg_energy, RID, float) BIND2(environment_set_canvas_max_layer, RID, int) BIND4(environment_set_ambient_light, RID, const Color &, float, float) +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 BIND2(environment_set_camera_feed_id, RID, int) +#endif BIND7(environment_set_ssr, RID, bool, int, float, float, float, bool) BIND13(environment_set_ssao, RID, bool, float, float, float, float, float, float, float, const Color &, EnvironmentSSAOQuality, EnvironmentSSAOBlur, float) diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h index a2d65791a0..61fdfd0861 100644 --- a/servers/visual/visual_server_scene.h +++ b/servers/visual/visual_server_scene.h @@ -31,7 +31,7 @@ #ifndef VISUALSERVERSCENE_H #define VISUALSERVERSCENE_H -#include "servers/visual/rasterizer.h" +#include "servers/visual/rasterizer/rasterizer.h" #include "core/math/geometry.h" #include "core/math/octree.h" diff --git a/servers/visual/visual_server_viewport.h b/servers/visual/visual_server_viewport.h index f701e3612a..4af22a4ad8 100644 --- a/servers/visual/visual_server_viewport.h +++ b/servers/visual/visual_server_viewport.h @@ -33,7 +33,7 @@ #include "core/rid_owner.h" #include "core/self_list.h" -#include "rasterizer.h" +#include "rasterizer/rasterizer.h" #include "servers/arvr/arvr_interface.h" #include "servers/visual_server.h" diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp index 29ea8d80e7..4bce8eb942 100644 --- a/servers/visual/visual_server_wrap_mt.cpp +++ b/servers/visual/visual_server_wrap_mt.cpp @@ -136,7 +136,6 @@ void VisualServerWrapMT::finish() { visual_server->finish(); } - texture_free_cached_ids(); sky_free_cached_ids(); shader_free_cached_ids(); material_free_cached_ids(); diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index b1bbed24fd..9b999a33f6 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -77,34 +77,42 @@ public: #define server_name visual_server #include "servers/server_wrap_mt_common.h" - /* EVENT QUEUING */ - FUNCRID(texture) - FUNC7(texture_allocate, RID, int, int, int, Image::Format, TextureType, uint32_t) - FUNC3(texture_set_data, RID, const Ref<Image> &, int) - FUNC10(texture_set_data_partial, RID, const Ref<Image> &, int, int, int, int, int, int, int, int) - FUNC2RC(Ref<Image>, texture_get_data, RID, int) - FUNC2(texture_set_flags, RID, uint32_t) - FUNC1RC(uint32_t, texture_get_flags, RID) - FUNC1RC(Image::Format, texture_get_format, RID) - FUNC1RC(TextureType, texture_get_type, RID) - FUNC1RC(uint32_t, texture_get_texid, RID) - FUNC1RC(uint32_t, texture_get_width, RID) - FUNC1RC(uint32_t, texture_get_height, RID) - FUNC1RC(uint32_t, texture_get_depth, RID) - FUNC4(texture_set_size_override, RID, int, int, int) + //these go pass-through, as they can be called from any thread + virtual RID texture_2d_create(const Ref<Image> &p_image) { return visual_server->texture_2d_create(p_image); } + virtual RID texture_2d_layered_create(const Vector<Ref<Image> > &p_layers, TextureLayeredType p_layered_type) { return visual_server->texture_2d_layered_create(p_layers, p_layered_type); } + virtual RID texture_3d_create(const Vector<Ref<Image> > &p_slices) { return visual_server->texture_3d_create(p_slices); } + + //goes pass-through + virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) { visual_server->texture_2d_update_immediate(p_texture, p_image, p_layer); } + //these go through command queue if they are in another thread + FUNC3(texture_2d_update, RID, const Ref<Image> &, int) + FUNC4(texture_3d_update, RID, const Ref<Image> &, int, int) + + //these also go pass-through + virtual RID texture_2d_placeholder_create() { return visual_server->texture_2d_placeholder_create(); } + virtual RID texture_2d_layered_placeholder_create() { return visual_server->texture_2d_layered_placeholder_create(); } + virtual RID texture_3d_placeholder_create() { return visual_server->texture_3d_placeholder_create(); } + + FUNC1RC(Ref<Image>, texture_2d_get, RID) + FUNC2RC(Ref<Image>, texture_2d_layer_get, RID, int) + FUNC3RC(Ref<Image>, texture_3d_slice_get, RID, int, int) + + FUNC2(texture_replace, RID, RID) + + FUNC3(texture_set_size_override, RID, int, int) +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 FUNC2(texture_bind, RID, uint32_t) +#endif FUNC3(texture_set_detect_3d_callback, RID, TextureDetectCallback, void *) - FUNC3(texture_set_detect_srgb_callback, RID, TextureDetectCallback, void *) FUNC3(texture_set_detect_normal_callback, RID, TextureDetectCallback, void *) + FUNC3(texture_set_detect_roughness_callback, RID, TextureDetectRoughnessCallback, void *) FUNC2(texture_set_path, RID, const String &) FUNC1RC(String, texture_get_path, RID) - FUNC1(texture_set_shrink_all_x2_on_set_data, bool) FUNC1S(texture_debug_usage, List<TextureInfo> *) - FUNC1(textures_keep_original, bool) - FUNC2(texture_set_proxy, RID, RID) FUNC2(texture_set_force_redraw_if_visible, RID, bool) @@ -429,7 +437,10 @@ public: FUNC2(environment_set_bg_energy, RID, float) FUNC2(environment_set_canvas_max_layer, RID, int) FUNC4(environment_set_ambient_light, RID, const Color &, float, float) +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 FUNC2(environment_set_camera_feed_id, RID, int) +#endif FUNC7(environment_set_ssr, RID, bool, int, float, float, float, bool) FUNC13(environment_set_ssao, RID, bool, float, float, float, float, float, float, float, const Color &, EnvironmentSSAOQuality, EnvironmentSSAOBlur, float) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 19b9e2c783..ba200fe94a 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -51,18 +51,6 @@ VisualServer *VisualServer::create() { return NULL; } -RID VisualServer::texture_create_from_image(const Ref<Image> &p_image, uint32_t p_flags) { - - ERR_FAIL_COND_V(!p_image.is_valid(), RID()); - RID texture = texture_create(); - texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, p_flags); //if it has mipmaps, use, else generate - ERR_FAIL_COND_V(!texture.is_valid(), texture); - - texture_set_data(texture, p_image); - - return texture; -} - Array VisualServer::_texture_debug_usage_bind() { List<TextureInfo> list; @@ -167,7 +155,7 @@ RID VisualServer::get_test_texture() { Ref<Image> data = memnew(Image(TEST_TEXTURE_SIZE, TEST_TEXTURE_SIZE, false, Image::FORMAT_RGB8, test_data)); - test_texture = texture_create_from_image(data); + test_texture = texture_2d_create(data); return test_texture; } @@ -334,9 +322,7 @@ RID VisualServer::get_white_texture() { w[i] = 255; } Ref<Image> white = memnew(Image(4, 4, 0, Image::FORMAT_RGB8, wt)); - white_texture = texture_create(); - texture_allocate(white_texture, 4, 4, 0, Image::FORMAT_RGB8, TEXTURE_TYPE_2D); - texture_set_data(white_texture, white); + white_texture = texture_2d_create(white); return white_texture; } @@ -1647,28 +1633,8 @@ void VisualServer::_bind_methods() { ClassDB::bind_method(D_METHOD("sync"), &VisualServer::sync); ClassDB::bind_method(D_METHOD("draw", "swap_buffers", "frame_step"), &VisualServer::draw, DEFVAL(true), DEFVAL(0.0)); - ClassDB::bind_method(D_METHOD("texture_create"), &VisualServer::texture_create); - ClassDB::bind_method(D_METHOD("texture_create_from_image", "image", "flags"), &VisualServer::texture_create_from_image, DEFVAL(TEXTURE_FLAGS_DEFAULT)); - ClassDB::bind_method(D_METHOD("texture_allocate", "texture", "width", "height", "depth_3d", "format", "type", "flags"), &VisualServer::texture_allocate, DEFVAL(TEXTURE_FLAGS_DEFAULT)); - ClassDB::bind_method(D_METHOD("texture_set_data", "texture", "image", "layer"), &VisualServer::texture_set_data, DEFVAL(0)); - ClassDB::bind_method(D_METHOD("texture_set_data_partial", "texture", "image", "src_x", "src_y", "src_w", "src_h", "dst_x", "dst_y", "dst_mip", "layer"), &VisualServer::texture_set_data_partial, DEFVAL(0)); - ClassDB::bind_method(D_METHOD("texture_get_data", "texture", "cube_side"), &VisualServer::texture_get_data, DEFVAL(CUBEMAP_LEFT)); - ClassDB::bind_method(D_METHOD("texture_set_flags", "texture", "flags"), &VisualServer::texture_set_flags); - ClassDB::bind_method(D_METHOD("texture_get_flags", "texture"), &VisualServer::texture_get_flags); - ClassDB::bind_method(D_METHOD("texture_get_format", "texture"), &VisualServer::texture_get_format); - ClassDB::bind_method(D_METHOD("texture_get_type", "texture"), &VisualServer::texture_get_type); - ClassDB::bind_method(D_METHOD("texture_get_texid", "texture"), &VisualServer::texture_get_texid); - ClassDB::bind_method(D_METHOD("texture_get_width", "texture"), &VisualServer::texture_get_width); - ClassDB::bind_method(D_METHOD("texture_get_height", "texture"), &VisualServer::texture_get_height); - ClassDB::bind_method(D_METHOD("texture_get_depth", "texture"), &VisualServer::texture_get_depth); - ClassDB::bind_method(D_METHOD("texture_set_size_override", "texture", "width", "height", "depth"), &VisualServer::texture_set_size_override); - ClassDB::bind_method(D_METHOD("texture_set_path", "texture", "path"), &VisualServer::texture_set_path); - ClassDB::bind_method(D_METHOD("texture_get_path", "texture"), &VisualServer::texture_get_path); - ClassDB::bind_method(D_METHOD("texture_set_shrink_all_x2_on_set_data", "shrink"), &VisualServer::texture_set_shrink_all_x2_on_set_data); - ClassDB::bind_method(D_METHOD("texture_bind", "texture", "number"), &VisualServer::texture_bind); - - ClassDB::bind_method(D_METHOD("texture_debug_usage"), &VisualServer::_texture_debug_usage_bind); - ClassDB::bind_method(D_METHOD("textures_keep_original", "enable"), &VisualServer::textures_keep_original); +#warning TODO all texture methods need re-binding + #ifndef _3D_DISABLED ClassDB::bind_method(D_METHOD("sky_create"), &VisualServer::sky_create); ClassDB::bind_method(D_METHOD("sky_set_texture", "sky", "cube_map", "radiance_size"), &VisualServer::sky_set_texture); @@ -2058,26 +2024,16 @@ void VisualServer::_bind_methods() { BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MIN); BIND_CONSTANT(MATERIAL_RENDER_PRIORITY_MAX); - 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); - - BIND_ENUM_CONSTANT(TEXTURE_TYPE_2D); - BIND_ENUM_CONSTANT(TEXTURE_TYPE_CUBEMAP); - BIND_ENUM_CONSTANT(TEXTURE_TYPE_2D_ARRAY); - BIND_ENUM_CONSTANT(TEXTURE_TYPE_3D); - - BIND_ENUM_CONSTANT(TEXTURE_FLAG_MIPMAPS); - BIND_ENUM_CONSTANT(TEXTURE_FLAG_REPEAT); - BIND_ENUM_CONSTANT(TEXTURE_FLAG_FILTER); - BIND_ENUM_CONSTANT(TEXTURE_FLAG_ANISOTROPIC_FILTER); - BIND_ENUM_CONSTANT(TEXTURE_FLAG_CONVERT_TO_LINEAR); - BIND_ENUM_CONSTANT(TEXTURE_FLAG_MIRRORED_REPEAT); - BIND_ENUM_CONSTANT(TEXTURE_FLAG_USED_FOR_STREAMING); - BIND_ENUM_CONSTANT(TEXTURE_FLAGS_DEFAULT); + BIND_ENUM_CONSTANT(CUBEMAP_LAYER_LEFT); + BIND_ENUM_CONSTANT(CUBEMAP_LAYER_RIGHT); + BIND_ENUM_CONSTANT(CUBEMAP_LAYER_BOTTOM); + BIND_ENUM_CONSTANT(CUBEMAP_LAYER_TOP); + BIND_ENUM_CONSTANT(CUBEMAP_LAYER_FRONT); + BIND_ENUM_CONSTANT(CUBEMAP_LAYER_BACK); + + BIND_ENUM_CONSTANT(TEXTURE_LAYERED_2D_ARRAY); + BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP); + BIND_ENUM_CONSTANT(TEXTURE_LAYERED_CUBEMAP_ARRAY); BIND_ENUM_CONSTANT(SHADER_SPATIAL); BIND_ENUM_CONSTANT(SHADER_CANVAS_ITEM); diff --git a/servers/visual_server.h b/servers/visual_server.h index e7662695a6..4299870de0 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -80,76 +80,65 @@ public: /* TEXTURE API */ - enum TextureFlags { - TEXTURE_FLAG_MIPMAPS = 1, /// Enable automatic mipmap generation - when available - TEXTURE_FLAG_REPEAT = 2, /// Repeat texture (Tiling), otherwise Clamping - TEXTURE_FLAG_FILTER = 4, /// Create texture with linear (or available) filter - TEXTURE_FLAG_ANISOTROPIC_FILTER = 8, - TEXTURE_FLAG_CONVERT_TO_LINEAR = 16, - TEXTURE_FLAG_MIRRORED_REPEAT = 32, /// Repeat texture, with alternate sections mirrored - TEXTURE_FLAG_USED_FOR_STREAMING = 2048, - TEXTURE_FLAGS_DEFAULT = TEXTURE_FLAG_REPEAT | TEXTURE_FLAG_MIPMAPS | TEXTURE_FLAG_FILTER + enum TextureLayeredType { + TEXTURE_LAYERED_2D_ARRAY, + TEXTURE_LAYERED_CUBEMAP, + TEXTURE_LAYERED_CUBEMAP_ARRAY, }; - enum TextureType { - TEXTURE_TYPE_2D, - TEXTURE_TYPE_CUBEMAP, - TEXTURE_TYPE_2D_ARRAY, - TEXTURE_TYPE_3D, + enum CubeMapLayer { + + CUBEMAP_LAYER_LEFT, + CUBEMAP_LAYER_RIGHT, + CUBEMAP_LAYER_BOTTOM, + CUBEMAP_LAYER_TOP, + CUBEMAP_LAYER_FRONT, + CUBEMAP_LAYER_BACK }; - enum CubeMapSide { + virtual RID texture_2d_create(const Ref<Image> &p_image) = 0; + virtual RID texture_2d_layered_create(const Vector<Ref<Image> > &p_layers, TextureLayeredType p_layered_type) = 0; + virtual RID texture_3d_create(const Vector<Ref<Image> > &p_slices) = 0; //all slices, then all the mipmaps, must be coherent - CUBEMAP_LEFT, - CUBEMAP_RIGHT, - CUBEMAP_BOTTOM, - CUBEMAP_TOP, - CUBEMAP_FRONT, - CUBEMAP_BACK - }; + virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) = 0; //mostly used for video and streaming + virtual void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) = 0; + virtual void texture_3d_update(RID p_texture, const Ref<Image> &p_image, int p_depth, int p_mipmap) = 0; + + //these two APIs can be used together or in combination with the others. + virtual RID texture_2d_placeholder_create() = 0; + virtual RID texture_2d_layered_placeholder_create() = 0; + virtual RID texture_3d_placeholder_create() = 0; - virtual RID texture_create() = 0; - RID texture_create_from_image(const Ref<Image> &p_image, uint32_t p_flags = TEXTURE_FLAGS_DEFAULT); // helper - virtual void texture_allocate(RID p_texture, - int p_width, - int p_height, - int p_depth_3d, - Image::Format p_format, - TextureType p_type, - uint32_t p_flags = TEXTURE_FLAGS_DEFAULT) = 0; - - virtual void texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) = 0; - virtual void texture_set_data_partial(RID p_texture, - const Ref<Image> &p_image, - int src_x, int src_y, - int src_w, int src_h, - int dst_x, int dst_y, - int p_dst_mip, - int p_layer = 0) = 0; - - virtual Ref<Image> texture_get_data(RID p_texture, int p_layer = 0) const = 0; - virtual void texture_set_flags(RID p_texture, uint32_t p_flags) = 0; - virtual uint32_t texture_get_flags(RID p_texture) const = 0; - virtual Image::Format texture_get_format(RID p_texture) const = 0; - virtual TextureType texture_get_type(RID p_texture) const = 0; - virtual uint32_t texture_get_texid(RID p_texture) const = 0; - virtual uint32_t texture_get_width(RID p_texture) const = 0; - virtual uint32_t texture_get_height(RID p_texture) const = 0; - virtual uint32_t texture_get_depth(RID p_texture) const = 0; - virtual void texture_set_size_override(RID p_texture, int p_width, int p_height, int p_depth_3d) = 0; + virtual Ref<Image> texture_2d_get(RID p_texture) const = 0; + virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const = 0; + virtual Ref<Image> texture_3d_slice_get(RID p_texture, int p_depth, int p_mipmap) const = 0; + + virtual void texture_replace(RID p_texture, RID p_by_texture) = 0; + virtual void texture_set_size_override(RID p_texture, int p_width, int p_height) = 0; +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 virtual void texture_bind(RID p_texture, uint32_t p_texture_no) = 0; +#endif virtual void texture_set_path(RID p_texture, const String &p_path) = 0; virtual String texture_get_path(RID p_texture) const = 0; - virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable) = 0; - typedef void (*TextureDetectCallback)(void *); virtual void texture_set_detect_3d_callback(RID p_texture, TextureDetectCallback p_callback, void *p_userdata) = 0; - virtual void texture_set_detect_srgb_callback(RID p_texture, TextureDetectCallback p_callback, void *p_userdata) = 0; virtual void texture_set_detect_normal_callback(RID p_texture, TextureDetectCallback p_callback, void *p_userdata) = 0; + enum TextureDetectRoughnessChannel { + TEXTURE_DETECT_ROUGNHESS_R, + TEXTURE_DETECT_ROUGNHESS_G, + TEXTURE_DETECT_ROUGNHESS_B, + TEXTURE_DETECT_ROUGNHESS_A, + TEXTURE_DETECT_ROUGNHESS_GRAY, + }; + + typedef void (*TextureDetectRoughnessCallback)(void *, const String &, TextureDetectRoughnessChannel); + virtual void texture_set_detect_roughness_callback(RID p_texture, TextureDetectRoughnessCallback p_callback, void *p_userdata) = 0; + struct TextureInfo { RID texture; uint32_t width; @@ -163,8 +152,6 @@ public: virtual void texture_debug_usage(List<TextureInfo> *r_info) = 0; Array _texture_debug_usage_bind(); - virtual void textures_keep_original(bool p_enable) = 0; - virtual void texture_set_proxy(RID p_proxy, RID p_base) = 0; virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) = 0; @@ -722,7 +709,10 @@ public: virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0; virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0; virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0) = 0; +// FIXME: Disabled during Vulkan refactoring, should be ported. +#if 0 virtual void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) = 0; +#endif //set default SSAO options //set default SSR options @@ -1058,8 +1048,8 @@ public: }; // make variant understand the enums -VARIANT_ENUM_CAST(VisualServer::CubeMapSide); -VARIANT_ENUM_CAST(VisualServer::TextureFlags); +VARIANT_ENUM_CAST(VisualServer::TextureLayeredType); +VARIANT_ENUM_CAST(VisualServer::CubeMapLayer); VARIANT_ENUM_CAST(VisualServer::ShaderMode); VARIANT_ENUM_CAST(VisualServer::ArrayType); VARIANT_ENUM_CAST(VisualServer::ArrayFormat); @@ -1098,7 +1088,6 @@ VARIANT_ENUM_CAST(VisualServer::EnvironmentSSAOQuality); VARIANT_ENUM_CAST(VisualServer::EnvironmentSSAOBlur); VARIANT_ENUM_CAST(VisualServer::InstanceFlags); VARIANT_ENUM_CAST(VisualServer::ShadowCastingSetting); -VARIANT_ENUM_CAST(VisualServer::TextureType); //typedef VisualServer VS; // makes it easier to use #define VS VisualServer |