/****************************************************************************** * File - graphics.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 #include 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; // framebuffer is the ID of the texture/framebuffer to render to // -1 means draw to the default (most likely the main window) buffer virtual void BeginDraw(int framebuffer = -1) = 0; virtual Image* EndDraw() = 0; public: // virtual void SetClearColor(Color c) = 0; virtual Color GetClearColor() const = 0; virtual int CreateRenderTexture(int width, int height, int channels) = 0; virtual void DestroyRenderTexture(int texture) = 0; // Draw Methods virtual void DrawFilledPolygon(float* pVerts, int numVerts, Color color, glm::vec2 position, float angle = 0.0f) = 0; virtual void DrawLine(glm::vec2 point1, glm::vec2 point2, Color color, float lineWidth, float angle = 0.0f) = 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, float angle = 0.0f) = 0; virtual void DrawFilledBox(Rectangle box, Color color, float angle = 0.0f) = 0; virtual void DrawImage(Image& image, glm::vec2 position, Color color, float angle = 0.0f) = 0; virtual void DrawImage(Image& image, Rectangle source, Rectangle destination, Color color, float angle = 0.0f) = 0; virtual void DrawString(const char* string, Rectangle boundingArea, Color color, float scale = 1.0f, int font = 0) = 0; virtual void RegisterImage(Image& image) = 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; }; } #endif // IGRAPHICS_H_