//  File:    plot.hpp
//  Author:  Andreas Wittmann <andreas.wittmann@wittnet.at>

//  Comment:

#ifndef PLOTLIB_HPP
#define PLOTLIB_HPP

#include <string>

#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>

#define PLOT_MODE_DEFAULT 0 // Left/Top 0/0
#define PLOT_MODE_CROSS   1 // Middle 0/0 (y-inverted)
#define PLOT_MODE_MATH    2 // Left/Bottom 0/0 (y-inverted)

#define PLOT_HEADLESS_MODE_NULL         0
#define PLOT_HEADLESS_MODE_IMAGE        1
#define PLOT_HEADLESS_MODE_VIDEO        2
#define PLOT_HEADLESS_MODE_SINGLE_IMAGE 3

extern void setup();
extern void frame();
extern void cleanup();
extern bool event(SDL_Event* e);

extern "C" SDL_Window* g_window;
extern "C" SDL_Renderer* g_renderer;

extern uint64_t g_current_frame;
extern int g_running;

// Werden direkt im plot.cpp eingebunden!
extern "C" const unsigned char arial_ttf[];
extern "C" const unsigned int arial_ttf_size;

extern int plot_x_ofs;
extern int plot_y_ofs;
extern int plot_width;
extern int plot_height;

struct PlotPoint {
    double x;
    double y;
};

struct PlotWorldPoint {
    double x;
    double y;
    double z;
};

extern SDL_Color g_draw_color;

void PlotCanvas(int width, int height, int mode = 0);
void PlotMode(int mode);
void PlotBackground(Uint8 r, Uint8 g, Uint8 b);
void PlotCross();
void PlotColor(Uint8 r, Uint8 g, Uint8 b);
void PlotColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
void PlotPixel(double x, double y);
void PlotPixel(PlotPoint a);
void PlotLine(PlotPoint a, PlotPoint b);
void PlotLine(double x1, double y1, double x2, double y2);
void PlotTriangle(PlotPoint a, PlotPoint b, PlotPoint c);
void PlotTriangle(PlotPoint a, PlotPoint b, PlotPoint c, SDL_Texture* texture);
void PlotRectangle(PlotPoint a, PlotPoint b);
void PlotRectangle(double x1, double y1, double x2, double y2);
void PlotFilledRectangle(PlotPoint a, PlotPoint b);
void PlotFilledRectangle(double x1, double y1, double x2, double y2);
void PlotText(double x, double y, const char* format, ...);

void PlotSetFrameDurationMS(Uint32 ms);
void PlotSetFPS(int fps);
void PlotSetFrameLimit(int frames);
//void PlotHeadlessMode(int headless_mode);
uint32_t PlotGetTicks();

#endif // PLOTLIB_HPP
