hedgewars/SDLh.pas
changeset 6281 dc9c44f47e75
parent 6280 3725cfec4542
child 6282 de449b2d9607
equal deleted inserted replaced
6280:3725cfec4542 6281:dc9c44f47e75
   733 {* SDL *}
   733 {* SDL *}
   734 function  SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName;
   734 function  SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName;
   735 function  SDL_InitSubSystem(flags: LongWord): LongInt; cdecl; external SDLLibName;
   735 function  SDL_InitSubSystem(flags: LongWord): LongInt; cdecl; external SDLLibName;
   736 procedure SDL_Quit; cdecl; external SDLLibName;
   736 procedure SDL_Quit; cdecl; external SDLLibName;
   737 
   737 
   738 function  SDL_VideoDriverName(var namebuf; maxlen: LongInt): PChar; cdecl; external SDLLibName;
       
   739 function  SDL_EnableUNICODE(enable: LongInt): LongInt; cdecl; external SDLLibName;
       
   740 function  SDL_EnableKeyRepeat(delay_, interval: LongInt): LongInt; cdecl; external SDLLibName;
       
   741 
       
   742 procedure SDL_Delay(msec: Longword); cdecl; external SDLLibName;
   738 procedure SDL_Delay(msec: Longword); cdecl; external SDLLibName;
   743 function  SDL_GetTicks: Longword; cdecl; external SDLLibName;
   739 function  SDL_GetTicks: Longword; cdecl; external SDLLibName;
   744 
   740 
   745 function  SDL_MustLock(Surface: PSDL_Surface): Boolean;
   741 function  SDL_MustLock(Surface: PSDL_Surface): Boolean;
   746 function  SDL_LockSurface(Surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
   742 function  SDL_LockSurface(Surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
   776 function  SDL_CreateWindow(title: PChar; x,y,w,h, flags: LongInt): PSDL_Window; cdecl; external SDLLibName;
   772 function  SDL_CreateWindow(title: PChar; x,y,w,h, flags: LongInt): PSDL_Window; cdecl; external SDLLibName;
   777 function  SDL_CreateRenderer(window: PSDL_Window; index, flags: LongInt): PSDL_Renderer; cdecl; external SDLLibName;
   773 function  SDL_CreateRenderer(window: PSDL_Window; index, flags: LongInt): PSDL_Renderer; cdecl; external SDLLibName;
   778 function  SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
   774 function  SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
   779 function  SDL_DestroyRenderer(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
   775 function  SDL_DestroyRenderer(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
   780 procedure SDL_SetWindowSize(window: PSDL_Window; w, h: LongInt); cdecl; external SDLLibName;
   776 procedure SDL_SetWindowSize(window: PSDL_Window; w, h: LongInt); cdecl; external SDLLibName;
       
   777 function  SDL_GetCurrentVideoDriver:Pchar; cdecl; external SDLLibName;
   781 
   778 
   782 function  SDL_GL_CreateContext(window: PSDL_Window): PSDL_GLContext; cdecl; external SDLLibName;
   779 function  SDL_GL_CreateContext(window: PSDL_Window): PSDL_GLContext; cdecl; external SDLLibName;
   783 procedure SDL_GL_DeleteContext(context: PSDL_GLContext); cdecl; external SDLLibName;
   780 procedure SDL_GL_DeleteContext(context: PSDL_GLContext); cdecl; external SDLLibName;
   784 function  SDL_GL_SwapWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
   781 function  SDL_GL_SwapWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
   785 function  SDL_GL_SetSwapInterval(interval: LongInt): LongInt; cdecl; external SDLLibName;
   782 function  SDL_GL_SetSwapInterval(interval: LongInt): LongInt; cdecl; external SDLLibName;
   801 function  SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
   798 function  SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
   802 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
   799 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
   803 
   800 
   804 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
   801 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
   805 function  SDL_SetHint(name, value: PChar): boolean; cdecl; external SDLLibName;
   802 function  SDL_SetHint(name, value: PChar): boolean; cdecl; external SDLLibName;
       
   803 procedure SDL_StartTextInput; cdecl; external SDLLibName;
   806 
   804 
   807 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; minType, maxType: LongInt): LongInt; cdecl; external SDLLibName;
   805 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; minType, maxType: LongInt): LongInt; cdecl; external SDLLibName;
   808 {$ELSE}
   806 {$ELSE}
   809 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; mask: Longword): LongInt; cdecl; external SDLLibName;
   807 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; mask: Longword): LongInt; cdecl; external SDLLibName;
   810 {$ENDIF}
   808 {$ENDIF}
   856 {* Compatibility between SDL-1.2 and SDL-1.3 *}
   854 {* Compatibility between SDL-1.2 and SDL-1.3 *}
   857 procedure SDL_WarpMouse(x, y: Word); {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
   855 procedure SDL_WarpMouse(x, y: Word); {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
   858 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
   856 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
   859 function  SDL_AllocFormat(format: Longword): PSDL_PixelFormat; {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
   857 function  SDL_AllocFormat(format: Longword): PSDL_PixelFormat; {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
   860 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
   858 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
       
   859 function  SDL_VideoDriverName(namebuf: PChar; maxlen: LongInt): PChar; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
       
   860 function  SDL_EnableUNICODE(enable: LongInt): LongInt; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
       
   861 function  SDL_EnableKeyRepeat(delay_, interval: LongInt): LongInt; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
   861 
   862 
   862 (*  SDL_ttf  *)
   863 (*  SDL_ttf  *)
   863 function  TTF_Init: LongInt; cdecl; external SDL_TTFLibName;
   864 function  TTF_Init: LongInt; cdecl; external SDL_TTFLibName;
   864 procedure TTF_Quit; cdecl; external SDL_TTFLibName;
   865 procedure TTF_Quit; cdecl; external SDL_TTFLibName;
   865 
   866 
   933 procedure SDLNet_Write32(value: LongWord; buf: pointer);
   934 procedure SDLNet_Write32(value: LongWord; buf: pointer);
   934 function  SDLNet_Read16(buf: pointer): Word;
   935 function  SDLNet_Read16(buf: pointer): Word;
   935 function  SDLNet_Read32(buf: pointer): LongWord;
   936 function  SDLNet_Read32(buf: pointer): LongWord;
   936 
   937 
   937 implementation
   938 implementation
   938 uses uVariables;
   939 uses strings, uVariables;
   939 
   940 
   940 {$IFDEF SDL13}
   941 {$IFDEF SDL13}
   941 // this needs to be reimplemented because in SDL_compat.c the window is the one created in the SDL_SetVideoMode
   942 // this needs to be reimplemented because in SDL_compat.c the window is the one created in the SDL_SetVideoMode
   942 // compatible function, but we use SDL_CreateWindow, so the window would be NULL
   943 // compatible function, but we use SDL_CreateWindow, so the window would be NULL
   943 procedure SDL_WarpMouse(x, y: Word);
   944 procedure SDL_WarpMouse(x, y: Word);
   944 begin
   945 begin
   945     SDL_WarpMouseInWindow(SDLwindow, x, y);
   946     SDL_WarpMouseInWindow(SDLwindow, x, y);
       
   947 end;
       
   948 
       
   949 function SDL_VideoDriverName(namebuf: PChar; maxlen: LongInt): PChar;
       
   950 var name : PChar = nil;
       
   951 begin
       
   952     name:= SDL_GetCurrentVideoDriver();
       
   953     if (name <> nil) and (namebuf <> nil) then
       
   954         begin
       
   955         strlcopy(namebuf, name, maxlen);
       
   956         exit(namebuf)
       
   957         end;
       
   958     exit(name);
       
   959 end;
       
   960 
       
   961 function SDL_EnableUNICODE(enable: LongInt): LongInt;
       
   962 begin
       
   963     SDL_StartTextInput();
       
   964     exit(0);
       
   965 end;
       
   966 
       
   967 function SDL_EnableKeyRepeat(delay_, interval: LongInt): LongInt;
       
   968 begin
       
   969     exit(0);
   946 end;
   970 end;
   947 {$ELSE}
   971 {$ELSE}
   948 function SDL_AllocFormat(format: Longword): PSDL_PixelFormat;
   972 function SDL_AllocFormat(format: Longword): PSDL_PixelFormat;
   949 const conversionFormat: TSDL_PixelFormat = (
   973 const conversionFormat: TSDL_PixelFormat = (
   950         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
   974         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;