/******************************************************************************
*	File		-	render_context.h
*	Author		-	Joey Pollack
*	Date		-	2022/07/13 (y/m/d)
*	Mod Date	-	2022/07/13 (y/m/d)
*	Description	-	General setup/shutdown for the render system
******************************************************************************/

#ifndef LUNARIUM_RENDER_CONTEXT_H_
#define LUNARIUM_RENDER_CONTEXT_H_

#include <core/common_defs.h>
#include <utils/op_res.h>
#include <glad/gl.h>
#include <map>
#include <string>

namespace lunarium
{
    class Window;
    class Renderer2D;

    // NOTE:
    // This class will probably not be exposed outside of the Core
    // The Core will expose Renderer2D instead
    class RenderContext
    {
    public:
        RenderContext();
        /// pWindow - the initialized platform window
        /// ppR2D a pointer to an unitialized Renderer2D pointer
        OpRes Initialize(Window* pWindow, Renderer2D** ppR2D, bool enableDebugMessages = true);
		void Shutdown(Renderer2D** ppR2D);
        void SwapBuffers();


    private:
        bool mIsInit;
        Window* mpWindow;

        // TODO: Manage window framebuffer?

    private:    // HELPERS
    
    	void InitDebugMsgSystem();

        private:    // Debug Message System

    friend void GLAPIENTRY MessageCallback(GLenum source, GLenum type, GLuint id,
			GLenum severity, GLsizei length, const GLchar* message, const void* userParam);
		static std::map<int, std::string> mDebugMsgTypes;
		static std::map<int, std::string> mDebugMsgSources;
		static std::map<int, std::string> mDebugMsgSeverity;
    };
}

#endif	// LUNARIUM_RENDER_CONTEXT_H_