/*
PolyGun

Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#ifndef POLYGUN_RENDERER_MASTER_RENDERER_HPP
#define POLYGUN_RENDERER_MASTER_RENDERER_HPP

#include <memory>
#include <functional>
#include <config.hpp>

#include "game/renderer/mesh_renderer.hpp"
#include "game/renderer/gui_renderer.hpp"

namespace polygun::window {
	class Window;
}

namespace polygun::renderer {
	class Shader;
	class Mesh;
	class Texture;
	enum RendererType {
		RENDERER_TYPE_GL,
		RENDERER_TYPE_LEGACY_GL
	};
	class MasterRenderer {
	public:
		MasterRenderer() = default;
		virtual ~MasterRenderer() = default;

		RendererType get_renderer_type() const { return m_renderer_type; }
		MeshRenderer* get_mesh_renderer() { return m_mesh_renderer.get(); }
		GUIRenderer* get_gui_renderer() { return m_gui_renderer.get(); }

		virtual void clear_screen(float r, float g, float b) = 0;
		virtual Shader* create_shader() const = 0;
		virtual Mesh* create_mesh() const = 0;
		virtual Texture* create_texture() const = 0;

		static MasterRenderer* create_master_renderer(RendererType type, window::Window* window);

	protected:
		RendererType m_renderer_type;
		std::unique_ptr<MeshRenderer> m_mesh_renderer;
		std::unique_ptr<GUIRenderer> m_gui_renderer;
	};
}

#endif // POLYGUN_RENDERER_MASTER_RENDERER_HPP
