/* Ofront+ 1.0 -sC -48 */
#include "SYSTEM.oh"

typedef
  struct SDL2_DisplayMode {
    INTEGER format, w, h, refreshRate;
    SYSTEM_PTR driverData;
  } SDL2_DisplayMode;

typedef
  struct SDL2_Event {
    INTEGER type;
    CHAR padding1[124];
  } SDL2_Event;

typedef
  BOOLEAN (*SDL2_KeyArray)[1024];

typedef
  struct SDL2_KeyboardEventDesc *SDL2_KeyboardEvent;

typedef
  struct SDL2_Keysym {
    INTEGER scancode, sym;
    SHORTINT mod;
  } SDL2_Keysym;

typedef
  struct SDL2_KeyboardEventDesc {
    INTEGER type, timestamp, windowID;
    SHORTINT state, repeat;
    SDL2_Keysym keysym;
    CHAR padding1[100];
  } SDL2_KeyboardEventDesc;

typedef
  struct SDL2_MouseButtonEventDesc *SDL2_MouseButtonEvent;

typedef
  struct SDL2_MouseButtonEventDesc {
    INTEGER type, timestamp, windowID, which;
    BYTE button, state, clicks, padding1;
    INTEGER x, y;
  } SDL2_MouseButtonEventDesc;

typedef
  struct SDL2_MouseMotionEventDesc *SDL2_MouseMotionEvent;

typedef
  struct SDL2_MouseMotionEventDesc {
    INTEGER type, timestamp, windowID, which, state, x, y, xRel, yRel;
  } SDL2_MouseMotionEventDesc;

typedef
  struct SDL2_MouseWheelEventDesc *SDL2_MouseWheelEvent;

typedef
  struct SDL2_MouseWheelEventDesc {
    INTEGER type, timestamp, windowID, which, x, y, direction;
  } SDL2_MouseWheelEventDesc;

typedef
  struct SDL2_PaletteDesc *SDL2_Palette;

typedef
  struct SDL2_PaletteDesc {
    INTEGER nColors;
    SYSTEM_PTR colors;
    INTEGER version, refCount;
  } SDL2_PaletteDesc;

typedef
  struct SDL2_PixelFormatDesc *SDL2_PixelFormat;

typedef
  struct SDL2_PixelFormatDesc {
    INTEGER format;
    SDL2_Palette palette;
    SHORTINT bitsPerPixel, bytesPerPixel;
    INTEGER rMask, gMask, aMask;
    CHAR padding1[16];
  } SDL2_PixelFormatDesc;

typedef
  struct SDL2_Rect {
    INTEGER x, y, w, h;
  } SDL2_Rect;

typedef
  struct SDL2_SurfaceDesc *SDL2_Surface;

typedef
  struct SDL2_SurfaceDesc {
    INTEGER flags;
    SDL2_PixelFormat format;
    INTEGER w, h, pitch;
    SYSTEM_PTR pixels, userData;
    INTEGER locked;
    SYSTEM_PTR lockData;
    SDL2_Rect clipRect;
    SYSTEM_PTR map;
    INTEGER refCount;
  } SDL2_SurfaceDesc;

typedef
  struct SDL2_TextEditingEventDesc *SDL2_TextEditingEvent;

typedef
  struct SDL2_TextEditingEventDesc {
    INTEGER type, timestamp, windowID;
    CHAR text[32];
    INTEGER start, length;
  } SDL2_TextEditingEventDesc;

typedef
  struct SDL2_TextInputEventDesc *SDL2_TextInputEvent;

typedef
  struct SDL2_TextInputEventDesc {
    INTEGER type, timestamp, windowID;
    CHAR text[32];
  } SDL2_TextInputEventDesc;

typedef
  struct SDL2_WindowEventDesc *SDL2_WindowEvent;

typedef
  struct SDL2_WindowEventDesc {
    INTEGER type, timestamp, windowID;
    SHORTINT event;
    INTEGER data1, data2;
  } SDL2_WindowEventDesc;



export SYSTEM_ADRINT *SDL2_WindowEventDesc__typ;
export SYSTEM_ADRINT *SDL2_Keysym__typ;
export SYSTEM_ADRINT *SDL2_KeyboardEventDesc__typ;
export SYSTEM_ADRINT *SDL2_MouseMotionEventDesc__typ;
export SYSTEM_ADRINT *SDL2_MouseButtonEventDesc__typ;
export SYSTEM_ADRINT *SDL2_MouseWheelEventDesc__typ;
export SYSTEM_ADRINT *SDL2_TextEditingEventDesc__typ;
export SYSTEM_ADRINT *SDL2_TextInputEventDesc__typ;
export SYSTEM_ADRINT *SDL2_Event__typ;
export SYSTEM_ADRINT *SDL2_Rect__typ;
export SYSTEM_ADRINT *SDL2_PaletteDesc__typ;
export SYSTEM_ADRINT *SDL2_DisplayMode__typ;
export SYSTEM_ADRINT *SDL2_PixelFormatDesc__typ;
export SYSTEM_ADRINT *SDL2_SurfaceDesc__typ;


#include "SDL2.h0"
#define SDL2_BlitScaled(src, srcRect, srcRect__typ, dst, dstRect, dstRect__typ)  SDL_UpperBlitScaled(src, srcRect, dst, dstRect)
#define SDL2_BlitSurface(src, srcRect, srcRect__typ, dst, dstRect, dstRect__typ)  SDL_UpperBlit(src, srcRect, dst, dstRect)
#define SDL2_BlitSurfaceNil(src, dst, dstRect, dstRect__typ)  SDL_UpperBlit(src, (void *)0, dst, dstRect)
#define SDL2_ConvertSurface(src, fmt, flags)  (void *)SDL_ConvertSurface(src, fmt, flags)
#define SDL2_CreateRGBSurface(flags, w, h, depth, rMask, gMask, bMask, aMask)  (void *)SDL_CreateRGBSurface(flags, w, h, depth, rMask, gMask, bMask, aMask)
#define SDL2_CreateRenderer(win, index, flags)  (void *)SDL_CreateRenderer(win, index, flags)
#define SDL2_CreateTextureFromSurface(renderer, surface)  (void *)SDL_CreateTextureFromSurface(renderer, surface)
#define SDL2_CreateWindow(title, title__len, x, y, w, h, flags)  (void *)SDL_CreateWindow(title, x, y, w, h, flags)
#define SDL2_Delay(ms)  SDL_Delay(ms)
#define SDL2_DestroyRenderer(renderer)  SDL_DestroyRenderer(renderer)
#define SDL2_DestroyTexture(texture)  SDL_DestroyTexture(texture)
#define SDL2_DestroyWindow(win)  SDL_DestroyWindow(win)
#define SDL2_FillRect(dst, rect, rect__typ, color)  SDL_FillRect(dst, rect, color)
#define SDL2_FillRectNil(dst, color)  SDL_FillRect(dst, (void *)0, color)
#define SDL2_FreeSurface(surface)  SDL_FreeSurface(surface)
#define SDL2_GetDesktopDisplayMode(displayIndex, mode, mode__typ)  SDL_GetDesktopDisplayMode(displayIndex, mode)
#define SDL2_GetError()  SDL_GetError()
#define SDL2_GetKeyboardState(numKeys)  SDL_GetKeyboardState(numKeys)
#define SDL2_GetKeyboardStateNil()  (void *)SDL_GetKeyboardState((void *)0)
#define SDL2_GetModState()  SDL_GetModState()
#define SDL2_GetMouseState(x, y)  SDL_GetMouseState(x, y)
#define SDL2_GetTicks()  SDL_GetTicks()
#define SDL2_GetWindowFlags(window)  SDL_GetWindowFlags(window)
#define SDL2_GetWindowSize(window, w, h)  SDL_GetWindowSize(window, w, h)
#define SDL2_HasEvent(type)  SDL_HasEvent(type)
#define SDL2_HasEvents(minType, maxType)  SDL_HasEvents(minType, maxType)
#define SDL2_ImgInit(flags)  IMG_Init(flags)
#define SDL2_ImgLoad(file, file__len)  (void *)IMG_Load(file)
#define SDL2_ImgQuit()  IMG_Quit()
#define SDL2_Init(flags)  SDL_Init(flags)
#define SDL2_InitSubSystem(flags)  SDL_InitSubSystem(flags)
#define SDL2_LoadBmpRW(src, freeSrc)  (void *)SDL_LoadBMP_RW(src, freeSrc)
#define SDL2_LockSurface(surface)  SDL_LockSurface(surface)
#define SDL2_MapRGB(format, r, g, b)  SDL_MapRGB(format, r, g, b)
#define SDL2_PeepEvents(events, events__len, numevents, action, minType, maxType)  SDL_PeepEvents(events, numevents, action, minType, maxType)
#define SDL2_PollEvent(e, e__typ)  SDL_PollEvent(e)
#define SDL2_PumpEvents()  SDL_PumpEvents()
#define SDL2_Quit()  SDL_Quit()
#define SDL2_QuitSubSystem(flags)  SDL_QuitSubSystem(flags)
#define SDL2_RWFromFile(fname, fname__len, mode, mode__len)  (void *)SDL_RWFromFile(fname, mode)
#define SDL2_RenderClear(renderer)  SDL_RenderClear(renderer)
#define SDL2_RenderCopy(renderer, texture, srcRect, srcRect__typ, dstRect, dstRect__typ)  SDL_RenderCopy(renderer, texture, srcRect, dstRect)
#define SDL2_RenderCopyNil(renderer, texture)  SDL_RenderCopy(renderer, texture, (void *)0, (void *)0)
#define SDL2_RenderDrawLine(renderer, x1, y1, x2, y2)  SDL_RenderDrawLine(renderer, x1, y1, x2, y2)
#define SDL2_RenderDrawPoint(renderer, x, y)  SDL_RenderDrawPoint(renderer, x, y)
#define SDL2_RenderDrawRect(renderer, rect, rect__typ)  SDL_RenderDrawRect(renderer, rect)
#define SDL2_RenderFillRect(renderer, rect, rect__typ)  SDL_RenderFillRect(renderer, rect)
#define SDL2_RenderPresent(renderer)  SDL_RenderPresent(renderer)
#define SDL2_RenderSetLogicalSize(renderer, w, h)  SDL_RenderSetLogicalSize(renderer, w, h)
#define SDL2_SDLGetKeyboardState(numKeys)  (void *)SDL_GetKeyboardState(numKeys)
#define SDL2_SetClipRect(surface, rect, rect__typ)  SDL_SetClipRect(surface, rect)
#define SDL2_SetClipRectNil(surface)  SDL_SetClipRect(surface, (void *)0)
#define SDL2_SetColorKey(surface, flag, key)  SDL_SetColorKey(surface, flag, key)
#define SDL2_SetHint(name, name__len, value, value__len)  SDL_SetHint(name, value)
#define SDL2_SetRenderDrawBlendMode(renderer, blendMode)  SDL_SetRenderDrawBlendMode(renderer, blendMode)
#define SDL2_SetRenderDrawColor(renderer, r, g, b, a)  SDL_SetRenderDrawColor(renderer, r, g, b, a)
#define SDL2_SetSurfaceAlphaMod(surface, alpha)  SDL_SetSurfaceAlphaMod(surface, alpha)
#define SDL2_SetSurfaceColorMod(surface, r, g, b)  SDL_SetSurfaceColorMod(surface, r, g, b)
#define SDL2_SetTextureAlphaMod(texture, alpha)  SDL_SetTextureAlphaMod(texture, alpha)
#define SDL2_SetTextureColorMod(texture, r, g, b)  SDL_SetTextureColorMod(texture, r, g, b)
#define SDL2_SetWindowFullscreen(win, flags)  SDL_SetWindowFullscreen(win, flags)
#define SDL2_SetWindowIcon(window, icon)  SDL_SetWindowIcon(window, icon)
#define SDL2_SetWindowSize(window, w, h)  SDL_SetWindowSize(window, w, h)
#define SDL2_SetWindowTitle(window, title, title__len)  SDL_SetWindowTitle(window, title)
#define SDL2_ShowCursor(toggle)  SDL_ShowCursor(toggle)
#define SDL2_StartTextInput()  SDL_StartTextInput()
#define SDL2_StopTextInput()  SDL_StopTextInput()
#define SDL2_UnlockSurface(surface)  SDL_UnlockSurface(surface)
#define SDL2_WaitEvent(e, e__typ)  SDL_WaitEvent(e)
#define SDL2_WaitEventTimeout(e, e__typ, timeout)  SDL_WaitEventTimeout(e, timeout)

/*============================================================================*/

__TDESC(SDL2_WindowEventDesc__desc, 2, 0) = {__TDFLDS("WindowEventDesc", 24), {-4}};
__TDESC(SDL2_Keysym__desc, 1, 0) = {__TDFLDS("Keysym", 12), {-4}};
__TDESC(SDL2_KeyboardEventDesc__desc, 2, 0) = {__TDFLDS("KeyboardEventDesc", 128), {-4}};
__TDESC(SDL2_MouseMotionEventDesc__desc, 2, 0) = {__TDFLDS("MouseMotionEventDesc", 36), {-4}};
__TDESC(SDL2_MouseButtonEventDesc__desc, 2, 0) = {__TDFLDS("MouseButtonEventDesc", 28), {-4}};
__TDESC(SDL2_MouseWheelEventDesc__desc, 2, 0) = {__TDFLDS("MouseWheelEventDesc", 28), {-4}};
__TDESC(SDL2_TextEditingEventDesc__desc, 2, 0) = {__TDFLDS("TextEditingEventDesc", 52), {-4}};
__TDESC(SDL2_TextInputEventDesc__desc, 2, 0) = {__TDFLDS("TextInputEventDesc", 44), {-4}};
__TDESC(SDL2_Event__desc, 2, 0) = {__TDFLDS("Event", 128), {-4}};
__TDESC(SDL2_Rect__desc, 2, 0) = {__TDFLDS("Rect", 16), {-4}};
__TDESC(SDL2_PaletteDesc__desc, 2, 1) = {__TDFLDS("PaletteDesc", 16), {4, -8}};
__TDESC(SDL2_DisplayMode__desc, 2, 1) = {__TDFLDS("DisplayMode", 20), {16, -8}};
__TDESC(SDL2_PixelFormatDesc__desc, 2, 0) = {__TDFLDS("PixelFormatDesc", 40), {-4}};
__TDESC(SDL2_SurfaceDesc__desc, 2, 4) = {__TDFLDS("SurfaceDesc", 60), {20, 24, 32, 52, -20}};

export void *SDL2__init (void)
{
  __DEFMOD;
  __REGMOD("SDL2", 0);
  __INITYP(SDL2_WindowEventDesc, SDL2_WindowEventDesc, 0);
  __INITYP(SDL2_Keysym, SDL2_Keysym, 0);
  __INITYP(SDL2_KeyboardEventDesc, SDL2_KeyboardEventDesc, 0);
  __INITYP(SDL2_MouseMotionEventDesc, SDL2_MouseMotionEventDesc, 0);
  __INITYP(SDL2_MouseButtonEventDesc, SDL2_MouseButtonEventDesc, 0);
  __INITYP(SDL2_MouseWheelEventDesc, SDL2_MouseWheelEventDesc, 0);
  __INITYP(SDL2_TextEditingEventDesc, SDL2_TextEditingEventDesc, 0);
  __INITYP(SDL2_TextInputEventDesc, SDL2_TextInputEventDesc, 0);
  __INITYP(SDL2_Event, SDL2_Event, 0);
  __INITYP(SDL2_Rect, SDL2_Rect, 0);
  __INITYP(SDL2_PaletteDesc, SDL2_PaletteDesc, 0);
  __INITYP(SDL2_DisplayMode, SDL2_DisplayMode, 0);
  __INITYP(SDL2_PixelFormatDesc, SDL2_PixelFormatDesc, 0);
  __INITYP(SDL2_SurfaceDesc, SDL2_SurfaceDesc, 0);
/* BEGIN */
  __ENDMOD;
}
