#ifndef SDL2_H
#define SDL2_H


#include <stdint.h>

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

#include "gui/color.h"


typedef struct SurfaceS {
	uint16_t width;
	uint16_t height;
	size_t   scanline;
	size_t   bytes;
	union {
		uint8_t  *bits8;
		uint16_t *bits16;
		uint32_t *bits32;
	} buffer;
} SurfaceT;

typedef struct EventS {
	int32_t flags;
	int32_t x;
	int32_t y;
	int32_t buttons;
	int32_t key;
	int32_t kbstat;
	int32_t dtime;
} EventT;


#define EVENT_FLAG_KEYPRESS      1
#define EVENT_FLAG_LEFT_DOWN     2
#define EVENT_FLAG_LEFT_UP       4
#define EVENT_FLAG_RIGHT_DOWN    8
#define EVENT_FLAG_RIGHT_UP      16

#define BUTTON_LEFT              1
#define BUTTON_RIGHT             2

#define META_ALT                 1
#define META_CTRL                2
#define META_SHIFT               4

#define KEY_ESC                  27


SurfaceT *imageLoad(char *filename);
void      platformEventGet(EventT *event);
uint16_t  videoDisplayHeightGet(void);
uint16_t  videoDisplayWidthGet(void);
void      videoSurfaceBlit(SurfaceT *target, int16_t targetX, int16_t targetY, SurfaceT *source);
void      videoSurfaceBlitWithTransparency(SurfaceT *target, int16_t targetX, int16_t targetY, SurfaceT *source, ColorT transparent);
void      videoSurfaceClear(ColorT color);
SurfaceT *videoSurfaceCreate(int16_t width, int16_t height);
void      videoSurfaceDestroy(SurfaceT *surface);
void      videoSurfaceBox(int16_t x1, int16_t y1, int16_t x2, int16_t y2, ColorT c);
void      videoSurfaceBoxFilled(int16_t x1, int16_t y1, int16_t x2, int16_t y2, ColorT c);
int16_t   videoSurfaceHeightGet(SurfaceT *surface);
void      videoSurfaceLineH(int16_t x1, int16_t x2, int16_t y, ColorT c);
void      videoSurfaceLineV(int16_t x, int16_t y1, int16_t y2, ColorT c);
ColorT    videoSurfacePixelGet(SurfaceT *surface, int16_t x, int16_t y);
void      videoSurfacePixelSet(int16_t x, int16_t y, ColorT c);
void      videoSurfaceSet(SurfaceT *surface);
SurfaceT *videoSurfaceScreenGet(void);
int16_t   videoSurfaceWidthGet(SurfaceT *surface);


#endif // SDL2_H
