/******************************************************************************
*	File		-	IGraphics.h
*	Author		-	Joey Pollack
*	Date		-	2021/09/02 (y/m/d)
*	Mod Date	-	2021/09/02 (y/m/d)
*	Description	-	Graphics interface for the engine. 
*
******************************************************************************/

#ifndef IGRAPHICS_H_
#define IGRAPHICS_H_

#include "definitions.h"
#include <utils/types.h>
#include <utils/opRes.h>

namespace lunarium
{
	class Core;
	class Window;
	class Image;

	enum RenderTarget
	{
		RT_WINDOW,
		RT_IMAGE
	};

	class IGraphics
	{
	protected:	// Interface methods for use only by the engine
		friend Core;

		IGraphics() : mbIsInit(false) {}

		virtual OpRes Initialize(Window* pWindow, bool enableDebugMessages = true) = 0;
		virtual void Shutdown() = 0;

		virtual void ResizeCanvas() = 0;

		// If render target is set to image the image will be the same
		// size as the window
		virtual void BeginDraw(RenderTarget rt = RenderTarget::RT_WINDOW) = 0;
		virtual Image* EndDraw() = 0;

	public:	// 

		virtual void SetClearColor(Color c) = 0;
        virtual Color GetClearColor() const = 0;

		// Draw Methods
		virtual void DrawLine(glm::vec2 point1, glm::vec2 point2, Color color, float lineWidth) = 0;
		virtual void DrawEllipse(glm::vec2 center, glm::vec2 radii, Color color, float thickness, int resolution) = 0;
		virtual void DrawFilledEllipse(glm::vec2 center, glm::vec2 radii, Color color, int resolution) = 0;
		virtual void DrawBox(Rectangle dimensions, Color color, float thickness) = 0;
		virtual void DrawFilledBox(glm::vec2 topLeft, glm::vec2 botRight, Color color) = 0;
		virtual void DrawImage(Image& image, glm::vec2 topLeft, Color color) = 0;
		virtual void DrawImage(Image& image, Rectangle source, Rectangle destination, Color color) = 0;
		virtual void DrawString(const char* string, Rectangle boundingArea, Color color, float scale = 1.0f, int font = 0) = 0;

		// Takes raw image data and creates and Image class instance out of it.
		// The raw data must be in one of the ImageFormats and it must be 1 byte per channel.
		virtual Image* CreateImage(const unsigned char* pData, int width, int height, ImageFormat format) = 0;
		virtual void DestroyImage(Image* i) = 0;

		// Fonts
		virtual int DefaultFont() const = 0;

		// For weight, 400 is normal and 700 is bold
		virtual int CreateNewFont(const char* name, const unsigned char* fontData, int bufferSize, float size = 12.0f, int weight = 400) = 0;

	protected:

		bool mbIsInit;
		int mDefaultFont;
		Color mClearColor;
		Image* mpFBTexture;
	};
}

#endif	// IGRAPHICS_H_