#ifndef _draw_h
#define _draw_h

#define DRAW_SPRITE          0
#define DRAW_TINTED_SPRITE   1
#define DRAW_SPRITE_H_FLIP   2
#define ROTATE_SPRITE        3
#define ROTATE_TINTED_SPRITE 4
#define STRETCH_SPRITE       5
#define BLIT                 6
#define BLIT_CLIPPED         7
#define TEXTOUT_EX           8
#define TEXTOUT_CENTRE_EX    9
#define CLIPPED_TEXTOUT_EX   10
#define MULTILINE_TEXTOUT_EX 11
#define CIRCLEFILL           12
#define CIRCLEFILL_GRADIENT  13
#define RECT                 14
#define RECTFILL             15
#define RECTFILL_GRADIENT    16
#define RECTROUNDED          17
#define MENUBACK             18
#define PUTPIXEL             19
#define MAPBLIP              20
#define HLINE                21
#define VLINE                22
#define LINESTRIP            23
#define CLEAR_TO_COLOR       24
#define COPY_TO              25

typedef struct drawthing
{
  short type;
  short angle;  // 0 to 255
	int x, y, w, h, color, cx, cy;
  float alpha; // 0.0 to 1.0
  float r;
  Rgba colors[4];
  string str;
  Bitmap *bmp;
  TextRenderer *fnt;
	LineStrip l;
} drawthing;

class bitmapdat
{
  vector<Bitmap*> b;
 public:
  void load(DATAFILE *dat);
  void draw(int i, int x, int y, float a = 1.0);
  void destroy();
  int size;
  Bitmap *bmp(int i);
};

extern vector<drawthing> drawqueue;

void buffer_draw_sprite(Bitmap *abitmap, int ax, int ay, float alpha = 1.0);
void buffer_draw_tinted_sprite(Bitmap *abitmap, int ax, int ay, int color, float alpha);
void buffer_draw_sprite_h_flip(Bitmap *abitmap, int ax, int ay, float alpha = 1.0);
void buffer_rotate_sprite(Bitmap *abitmap, int ax, int ay, int aangle, float alpha = 1.0);
void buffer_rotate_tinted_sprite(Bitmap *abitmap, int ax, int ay, int aangle, Rgba acolor, float alpha = 1.0);
void buffer_stretch_sprite(Bitmap *abitmap, int ax, int ay, int aw, int ah, float alpha = 1.0);
void buffer_blit(Bitmap *abitmap, int ax, int ay, float alpha = 1.0);
void buffer_blit_clipped(Bitmap *abitmap, int ax, int ay, int sx, int sy, int aw, int ah, float alpha = 1.0);

void buffer_textout_ex(TextRenderer &afont, string amessage, int ax, int ay, int acolor, float alpha = 1.0);
void buffer_textout_centre_ex(TextRenderer &afont, string amessage, int ax, int ay, int acolor, float alpha = 1.0);
void clipped_textout_ex(TextRenderer &f, string text, int x, int y, int l, int c, float alpha = 1.0);
void multiline_textout_ex(TextRenderer &f, string text, int x, int y, int l, int c, float alpha = 1.0);
void buffer_circlefill(int ax, int ay, float ar, int acolor, float alpha = 1.0);
void buffer_circlefill_gradient(int ax, int ay, float ar, int inner, int outer, float alpha = 1.0);
void buffer_rect(int ax, int ay, int bx, int by, int acolor, float alpha = 1.0);
void buffer_rectfill(int ax, int ay, int bx, int by, int acolor, float alpha = 1.0);
void buffer_rectfill_gradient(int ax, int ay, int bx, int by, int tl, int tr, int br, int bl);
void buffer_rectrounded(int ax, int ay, int bx, int by, int acolor, float alpha = 1.0);
void buffer_menuback(int ax, int ay, int bx, int by, int acolor1, int acolor2, int acolor3, float alpha = 1.0);
void buffer_putpixel(int ax, int ay, int acolor, float alpha = 1.0);
void buffer_mapblip(int ax, int ay, int acolor, float alpha = 1.0);
void buffer_hline(int ax, int ay, int bx, int acolor, float alpha = 1.0);
void buffer_vline(int ax, int ay, int by, int acolor, float alpha = 1.0);
void buffer_linestrip(LineStrip al, Rgba startcolor, Rgba endcolor);
void buffer_clear_to_color(int acolor);
void copy_screen_to(Bitmap *target);

void draw_all(bool refreshcanvas = true);
void draw_all(Bitmap *target);

#endif
