#pragma once
#include "node.h"
#include "shape.h"
#include "texture.h"

class NodeImage : public Node
{
public:
    static Plane m_plane;
    static Sampler m_sampler;
    static Sampler m_sampler_mips;
    bool m_use_atlas = false;
    bool m_use_mipmaps = false;
    bool m_autosize = false;
    glm::vec4 m_region;
    glm::vec2 m_off;
    glm::vec2 m_sz;
    glm::vec2 m_scale = { 1.f, 1.f };
    std::string m_path;
    std::string m_url;
    uint16_t m_tex_id;
    std::shared_ptr<Asset> m_remote_asset;
    std::shared_ptr<Texture2D> m_remote_texture;
    bool m_remote_header_decoded = false;
    static void static_init();
    virtual Node* clone_instantiate() const override;
    virtual void clone_copy(Node* dest) const override;
    virtual void create() override;
    virtual void restore_context() override;
    virtual void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr) override;
    virtual void draw() override;
    virtual void added(Node* parent) override;
    bool set_image(const std::string& path);
    void load_url(const std::string& url);
};
