#pragma once
#include "engine/media.h"
#include "engine/mediaSDL.h"
#include "libraries/sdl.h"
#include "libraries/sdl_image.h"

#undef main

void                _SDL_init                ( Context* );

void                _SDL_create_screen       ( Context* me, int width, int height, bool fullscreen, bool border, bool resizable );
void                _SDL_handle_io           ( Context* );
Context::Image*     _SDL_image_load          ( Context*, const char* fname );
Context::Image*     _SDL_image_load_mem      ( Context*, void*, int len );
Context::Surface*   _SDL_surface_create      ( Context*, int w, int h);
Context::Surface*   _SDL_surface_from_image  ( Context*, Context::Image* in);
Context::Image*     _SDL_image_from_surface  ( Context*, Context::Image* in);
Context::Sound*     _SDL_sound_load          ( Context*, const char* fname );
Context::Sound*     _SDL_sound_load_mem      ( Context*, void*, int len );
int                 _SDL_sound_unload        ( Context*, Context::Sound*);
int                 _SDL_image_unload        ( Context*, Context::Image*);
int                 _SDL_surface_free        ( Context*, Context::Surface*);
void                _SDL_draw_rectangle      ( Context*, int x1, int y1, int x2, int y2, Context::Color color, bool filled );
void                _SDL_draw_line           ( Context*, int x1, int y1, int x2, int y2, Context::Color color );
void                _SDL_draw_circle         ( Context*, int x, int y, int r, Context::Color color, bool filled );
void                _SDL_draw_ellipse        ( Context*, int x1, int y1, int x2, int y2, Context::Color color, bool filled );
void                _SDL_draw_image          ( Context*, int x, int y, Context::Image* img );
void                _SDL_draw_surface        ( Context*, int x, int y, Context::Surface* img );
void                _SDL_draw_image_part     ( Context*, int x, int y, int left, int top, int w, int h, Context::Image* img );
void                _SDL_draw_surface_part   ( Context*, int x, int y, int left, int top, int w, int h, Context::Surface* img );
int                 _SDL_sound_play          ( Context*, Context::Sound* );
void                _SDL_repaint             ( Context*, int x, int y, int w, int h );
int                 _SDL_image_width         ( Context::Image* );
int                 _SDL_image_height        ( Context::Image* );
int                 _SDL_sound_getlength     ( Context::Sound* ); //in samples
int                 _SDL_sound_getsamplerate ( Context::Sound* ); //in hz
int                 _SDL_surface_width       ( Context::Surface* );
int                 _SDL_surface_height      ( Context::Surface* );
void                _SDL_cleanup             ( Context* );
int                 _SDL_init_sound          ( Context*, int freq, int rate, int bitrate );
void                _SDL_sound_set_callback  ( Context*, void*, void (*audiomixercallbacka)(void*,unsigned char *stream, int len) );
void                _SDL_audiocallback       ( void* unused, unsigned char*, int );
void                _SDL_set_caption         ( Context*, char*, char* );




#define _SDL_SCREEN(a) (*((SDL_Surface**)(a->play)))