#include "RenderTexture.hpp"

TSE::OpenGL::RenderTexture::RenderTexture(Vector2 v, uint textureCount) : buffer(v, textureCount)
{
    buffer.AddResizeNotifiable(this);
}

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

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

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

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

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

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

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

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

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

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