#include <Magnum/GL/Framebuffer.h>
#include <Magnum/GL/Renderer.h>
#include <Magnum/Math/Color.h>
#include <Magnum/Platform/GLContext.h>
#include "magnum_render.h"

using namespace Magnum;

MagnumRenderer::MagnumRenderer() {}

MagnumRenderer::~MagnumRenderer() {}

void MagnumRenderer::hue(float hue) {
  m_hue = hue;
}

void MagnumRenderer::reset(Platform::GLContext *ctx, GL::Framebuffer fbo) {
  m_FBO = std::move(fbo);
  m_ctx = ctx;
}

void MagnumRenderer::render() {
  m_ctx->resetState(GL::Context::State::ExitExternal);

  GL::Renderer::setClearColor(
        Color4::fromHsv({Deg(m_hue), .3f, .9f}));

  m_FBO.bind();
  m_FBO.clear(GL::FramebufferClear::Color |
              GL::FramebufferClear::Depth);

  m_ctx->resetState(GL::Context::State::EnterExternal);
}
