hedgewars/SDLh.pas
branchwebgl
changeset 8026 4a4f21070479
parent 7565 00568d3054d0
child 8096 453917e94e55
equal deleted inserted replaced
8023:7de85783b823 8026:4a4f21070479
   242     SDL_NOFRAME     = $00000020;
   242     SDL_NOFRAME     = $00000020;
   243     SDL_HWACCEL     = $00000100;
   243     SDL_HWACCEL     = $00000100;
   244     SDL_SRCCOLORKEY = $00001000;
   244     SDL_SRCCOLORKEY = $00001000;
   245     SDL_RLEACCEL    = $00004000;
   245     SDL_RLEACCEL    = $00004000;
   246     SDL_SRCALPHA    = $00010000;
   246     SDL_SRCALPHA    = $00010000;
       
   247  {$IFDEF PAS2C}
       
   248     SDL_ANYFORMAT   = $10000000;
       
   249  {$ELSE}
   247     SDL_ANYFORMAT   = $00100000;
   250     SDL_ANYFORMAT   = $00100000;
       
   251  {$ENDIF}
   248     SDL_HWPALETTE   = $20000000;
   252     SDL_HWPALETTE   = $20000000;
   249     SDL_DOUBLEBUF   = $40000000;
   253     SDL_DOUBLEBUF   = $40000000;
   250     SDL_FULLSCREEN  = $80000000;
   254     SDL_FULLSCREEN  = $80000000;
   251 {$ENDIF}
   255 {$ENDIF}
   252 
   256 
   385         colorkey: LongWord;
   389         colorkey: LongWord;
   386         alpha: Byte;
   390         alpha: Byte;
   387 {$ENDIF}
   391 {$ENDIF}
   388         end;
   392         end;
   389 
   393 
   390     TSDL_eventaction = (SDL_ADDEVENT, SDL_PEEPEVENT, SDL_GETEVENT);
   394     TSDL_eventaction = (SDL_ADDEVENT, SDL_PEEKEVENT, SDL_GETEVENT);
   391 
   395 
   392     PSDL_Surface = ^TSDL_Surface;
   396     PSDL_Surface = ^TSDL_Surface;
   393     TSDL_Surface = record
   397     TSDL_Surface = record
   394         flags : LongWord;
   398         flags : LongWord;
   395         format: PSDL_PixelFormat;
   399         format: PSDL_PixelFormat;
   396         w, h  : LongInt;
   400         w, h  : LongInt;
   397         pitch : {$IFDEF SDL13}LongInt{$ELSE}Word{$ENDIF};
   401         pitch : {$IFDEF SDL13}LongInt{$ELSE}Word{$ENDIF};
   398         pixels: Pointer;
   402         pixels: Pointer;
   399         offset: LongInt;
   403         offset: LongInt;
       
   404 {$IFDEF PAS2C}
       
   405 	hwdata:Pointer;
       
   406 	clip_rect:TSDL_Rect;
       
   407         unsed1:LongWord;
       
   408         locked:LongWord;
       
   409         map:Pointer;
       
   410         format_version:Longword;
       
   411         refcount:LongInt;
       
   412 {$ELSE}
       
   413 		      
   400 {$IFDEF SDL13}
   414 {$IFDEF SDL13}
   401         userdata: Pointer;
   415         userdata: Pointer;
   402         locked: LongInt;
   416         locked: LongInt;
   403         lock_data: Pointer;
   417         lock_data: Pointer;
   404         clip_rect: TSDL_Rect;
   418         clip_rect: TSDL_Rect;
   405         map: Pointer;
   419         map: Pointer;
   406         refcount: LongInt;
   420         refcount: LongInt;
       
   421 {$ENDIF}
   407 {$ENDIF}
   422 {$ENDIF}
   408         end;
   423         end;
   409 
   424 
   410 
   425 
   411     PSDL_Color = ^TSDL_Color;
   426     PSDL_Color = ^TSDL_Color;
   745 
   760 
   746     TSDL_EventFilter = function( event : PSDL_Event ): Integer; cdecl;
   761     TSDL_EventFilter = function( event : PSDL_Event ): Integer; cdecl;
   747 
   762 
   748     TByteArray = array[0..65535] of Byte;
   763     TByteArray = array[0..65535] of Byte;
   749     PByteArray = ^TByteArray;
   764     PByteArray = ^TByteArray;
       
   765 
   750     TLongWordArray = array[0..16383] of LongWord;
   766     TLongWordArray = array[0..16383] of LongWord;
   751     PLongWordArray = ^TLongWordArray;
   767     PLongWordArray = ^TLongWordArray;
   752 
   768 
   753     PSDL_Thread = Pointer;
   769     PSDL_Thread = Pointer;
   754     PSDL_mutex = Pointer;
   770     PSDL_mutex = Pointer;
  1107     timedelay:= timedelay;  // avoid hint
  1123     timedelay:= timedelay;  // avoid hint
  1108     interval:= interval;    // avoid hint
  1124     interval:= interval;    // avoid hint
  1109     SDL_EnableKeyRepeat:= 0;
  1125     SDL_EnableKeyRepeat:= 0;
  1110 end;
  1126 end;
  1111 {$ELSE}
  1127 {$ELSE}
  1112 const conversionFormat: TSDL_PixelFormat = (
  1128 const convFormat:TSDL_PixelFormat = (
  1113         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
  1129         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
  1114         Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
  1130         Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
  1115         Rshift: RShift; Gshift: GShift; Bshift: BShift; Ashift: AShift;
  1131         Rshift: RShift; Gshift: GShift; Bshift: BShift; Ashift: AShift;
       
  1132 
       
  1133         //TODO: FIXME in pas2c
       
  1134         {$IFDEF WEBGL}
       
  1135         Rmask: RMask; Gmask: GMask; Bmask: BMask; Amask: AMask;
       
  1136         {$ELSE}
  1116         RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
  1137         RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
  1117         colorkey: 0; alpha: 255);
  1138         colorkey: 0; alpha: 255
       
  1139         {$ENDIF}
       
  1140         );
  1118 
  1141 
  1119 function SDL_AllocFormat(format: LongWord): PSDL_PixelFormat;
  1142 function SDL_AllocFormat(format: LongWord): PSDL_PixelFormat;
  1120 begin
  1143 begin
  1121     format:= format;
  1144     format:= format;
  1122     SDL_AllocFormat:= @conversionFormat;
  1145     SDL_AllocFormat:= @convFormat;
  1123 end;
  1146 end;
  1124 
  1147 
  1125 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat);
  1148 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat);
  1126 begin
  1149 begin
       
  1150    {$IFNDEF PAS2C}
  1127     pixelformat:= pixelformat;  // avoid hint
  1151     pixelformat:= pixelformat;  // avoid hint
       
  1152    {$ENDIF}
  1128 end;
  1153 end;
  1129 {$ENDIF}
  1154 {$ENDIF}
  1130 
  1155 
  1131 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
  1156 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
  1132 begin
  1157 begin
  1133     SDL_MustLock:=
  1158     SDL_MustLock:=
  1134 {$IFDEF SDL13}
  1159 {$IFDEF SDL13}
  1135         ((surface^.flags and SDL_RLEACCEL) <> 0)
  1160         ((surface^.flags and SDL_RLEACCEL) <> 0)
  1136 {$ELSE}
  1161 {$ELSE}
  1137         ( surface^.offset <> 0 ) or (( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0)
  1162         {$IFNDEF WEBGL}( surface^.offset <> 0 ) or {$ENDIF}(( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0)
  1138 {$ENDIF}
  1163 {$ENDIF}
  1139 end;
  1164 end;
  1140 
  1165 
  1141 {$IFNDEF SDL_MIXER_NEWER}
  1166 {$IFNDEF SDL_MIXER_NEWER}
  1142 function  Mix_Init(flags: LongInt): LongInt;
  1167 function  Mix_Init(flags: LongInt): LongInt;