#include "RenderTexture.hpp"

TSE::GLFW::RenderTexture::RenderTexture(Vector2 v) : buffer(v)
{
    buffer.AddResizeNotifiable(this);
}

TSE::Vector2 TSE::GLFW::RenderTexture::size() const
{
    return buffer.GetSize();
}

void TSE::GLFW::RenderTexture::SetSize(Vector2 v)
{
    buffer.Resize(v);
}

float TSE::GLFW::RenderTexture::Width() const
{
    return buffer.GetSize().x;
}

float TSE::GLFW::RenderTexture::Height() const
{
    return buffer.GetSize().y;
}

TSE::uint TSE::GLFW::RenderTexture::GetTextureId() const
{
    return buffer.GetTextureId();
}

void TSE::GLFW::RenderTexture::Update()
{
    buffer.Update();
}

void TSE::GLFW::RenderTexture::Bind()
{
    buffer.Bind();
}

void TSE::GLFW::RenderTexture::Unbind()
{
    buffer.Unbind();
}

void TSE::GLFW::RenderTexture::OnResize(float width, float height, IResizable *wnd)
{
    for (auto const& i : objectsToResize)
    {
        i->OnResize(width, height, this);
    }
}
