hedgewars/SDLh.pas
changeset 2379 d62b1f224982
parent 2376 ece7b87f1334
child 2390 57fb33ab04a4
equal deleted inserted replaced
2378:66fcb4d62a53 2379:d62b1f224982
    46 {$ENDIF}
    46 {$ENDIF}
    47 {$ENDIF}
    47 {$ENDIF}
    48 
    48 
    49 (*  SDL  *)
    49 (*  SDL  *)
    50 const {$IFDEF WIN32}
    50 const {$IFDEF WIN32}
    51       SDLLibName = 'SDL.dll';
    51 	SDLLibName = 'SDL.dll';
    52       {$ENDIF}
    52 	{$ENDIF}
    53       {$IFDEF UNIX}
    53 	{$IFDEF UNIX}
    54             {$IFDEF DARWIN}
    54 			{$IFDEF DARWIN}
    55             SDLLibName = 'SDL';
    55 			SDLLibName = 'SDL';
    56             {$ELSE}
    56 			{$ELSE}
    57             SDLLibName = 'libSDL.so';
    57 			SDLLibName = 'libSDL.so';
    58             {$ENDIF}
    58 			{$ENDIF}
    59       {$ENDIF}
    59 	{$ENDIF}
    60       SDL_SWSURFACE   = $00000000;
    60 	SDL_SWSURFACE   = $00000000;
    61       SDL_HWSURFACE   = $00000001;
    61 	SDL_HWSURFACE   = $00000001;
    62       SDL_SRCALPHA    = $00010000;
    62 	SDL_SRCALPHA    = $00010000;
    63       SDL_INIT_VIDEO  = $00000020;
    63 	SDL_INIT_VIDEO  = $00000020;
    64       SDL_INIT_AUDIO  = $00000010;
    64 	SDL_INIT_AUDIO  = $00000010;
    65 
    65 
    66 {$IFDEF SDL13}
    66 {$IFDEF SDL13}
    67       SDL_ASYNCBLIT   = $08000000;
    67 	SDL_ASYNCBLIT   = $08000000;
    68       SDL_ANYFORMAT   = $10000000;
    68 	SDL_ANYFORMAT   = $10000000;
    69       SDL_HWPALETTE   = $00200000;
    69 	SDL_HWPALETTE   = $00200000;
    70       SDL_DOUBLEBUF   = $00400000;
    70 	SDL_DOUBLEBUF   = $00400000;
    71       SDL_FULLSCREEN  = $00800000;
    71 	SDL_FULLSCREEN  = $00800000;
    72       SDL_HWACCEL     = $08000000;
    72 	SDL_HWACCEL     = $08000000;
    73       SDL_SRCCOLORKEY = $00020000;
    73 	SDL_SRCCOLORKEY = $00020000;
    74       SDL_RLEACCEL    = $08000000;
    74 	SDL_RLEACCEL    = $08000000;
    75       SDL_NOFRAME     = $02000000;
    75 	SDL_NOFRAME     = $02000000;
    76       SDL_OPENGL      = $04000000;
    76 	SDL_OPENGL      = $04000000;
    77       SDL_RESIZABLE   = $01000000;
    77 	SDL_RESIZABLE   = $01000000;
    78 {$ELSE}
    78 {$ELSE}
    79       SDL_ASYNCBLIT   = $00000004;
    79 	SDL_ASYNCBLIT   = $00000004;
    80       SDL_ANYFORMAT   = $00100000;
    80 	SDL_ANYFORMAT   = $00100000;
    81       SDL_HWPALETTE   = $20000000;
    81 	SDL_HWPALETTE   = $20000000;
    82       SDL_DOUBLEBUF   = $40000000;
    82 	SDL_DOUBLEBUF   = $40000000;
    83       SDL_FULLSCREEN  = $80000000;
    83 	SDL_FULLSCREEN  = $80000000;
    84       SDL_HWACCEL     = $00000100;
    84 	SDL_HWACCEL     = $00000100;
    85       SDL_SRCCOLORKEY = $00001000;
    85 	SDL_SRCCOLORKEY = $00001000;
    86       SDL_RLEACCEL    = $00004000;
    86 	SDL_RLEACCEL    = $00004000;
    87       SDL_NOFRAME     = $00000020;
    87 	SDL_NOFRAME     = $00000020;
    88       SDL_OPENGL      = $00000002;
    88 	SDL_OPENGL      = $00000002;
    89       SDL_RESIZABLE   = $00000010;
    89 	SDL_RESIZABLE   = $00000010;
    90 {$ENDIF}
    90 {$ENDIF}
    91 
    91 
    92       SDL_NOEVENT     = 0;
    92 	SDL_NOEVENT     = 0;
    93       SDL_ACTIVEEVENT = 1;
    93 	SDL_ACTIVEEVENT = 1;
    94       SDL_KEYDOWN     = 2;
    94 	SDL_KEYDOWN     = 2;
    95       SDL_KEYUP       = 3;
    95 	SDL_KEYUP       = 3;
    96       SDL_QUITEV      = 12;
    96 	SDL_MOUSEBUTTONDOWN = 5;
    97       SDL_VIDEORESIZE = 16;
    97 	SDL_MOUSEBUTTONUP   = 6;
       
    98 	SDL_QUITEV      = 12;
       
    99 	SDL_VIDEORESIZE = 16;
    98 
   100 
    99 {$IFDEF SDL13}
   101 {$IFDEF SDL13}
   100       SDL_MOUSEMOTION  = 5;
   102 	SDL_MOUSEMOTION  = 5;
   101 {$ENDIF}
   103 {$ENDIF}
   102 
   104 
   103       SDL_APPINPUTFOCUS = 2;
   105 	SDL_APPINPUTFOCUS = 2;
   104 
   106 	SDL_BUTTON_WHEELDUP = 4;
   105       RMask = $000000FF;
   107 	SDL_BUTTON_WHEELDOWN = 5;
   106       GMask = $0000FF00;
   108 
   107       BMask = $00FF0000;
   109 	RMask = $000000FF;
   108       AMask = $FF000000;
   110 	GMask = $0000FF00;
       
   111 	BMask = $00FF0000;
       
   112 	AMask = $FF000000;
   109 
   113 
   110 type PSDL_Rect = ^TSDL_Rect;
   114 type PSDL_Rect = ^TSDL_Rect;
   111      TSDL_Rect = record
   115 	TSDL_Rect = record
   112 		    {$IFDEF SDL13}
   116 	{$IFDEF SDL13}
   113                  x, y, w, h: LongInt;
   117 		x, y, w, h: LongInt;
   114 		    {$ELSE}
   118 	{$ELSE}
   115                  x, y: SmallInt;
   119 		x, y: SmallInt;
   116                  w, h: Word;
   120 		w, h: Word;
   117             {$ENDIF}
   121 	{$ENDIF}
   118                  end;
   122 		end;
   119 
   123 
   120      TPoint = record
   124 	TPoint = record
   121               X: LongInt;
   125 		X: LongInt;
   122               Y: LongInt;
   126 		Y: LongInt;
   123               end;
   127 		end;
   124 
   128 
   125      PSDL_PixelFormat = ^TSDL_PixelFormat;
   129 	PSDL_PixelFormat = ^TSDL_PixelFormat;
   126      TSDL_PixelFormat = record
   130 	TSDL_PixelFormat = record
   127                         palette: Pointer;
   131 		palette: Pointer;
   128                         BitsPerPixel : Byte;
   132 		BitsPerPixel : Byte;
   129                         BytesPerPixel: Byte;
   133 		BytesPerPixel: Byte;
   130                         Rloss : Byte;
   134 		Rloss : Byte;
   131                         Gloss : Byte;
   135 		Gloss : Byte;
   132                         Bloss : Byte;
   136 		Bloss : Byte;
   133                         Aloss : Byte;
   137 		Aloss : Byte;
   134                         Rshift: Byte;
   138 		Rshift: Byte;
   135                         Gshift: Byte;
   139 		Gshift: Byte;
   136                         Bshift: Byte;
   140 		Bshift: Byte;
   137                         Ashift: Byte;
   141 		Ashift: Byte;
   138                         RMask : Longword;
   142 		RMask : Longword;
   139                         GMask : Longword;
   143 		GMask : Longword;
   140                         BMask : Longword;
   144 		BMask : Longword;
   141                         AMask : Longword;
   145 		AMask : Longword;
   142                         colorkey: Longword;
   146 		colorkey: Longword;
   143                         alpha : Byte;
   147 		alpha : Byte;
   144                         end;
   148 		end;
   145 
   149 
   146 
   150 
   147      PSDL_Surface = ^TSDL_Surface;
   151 	PSDL_Surface = ^TSDL_Surface;
   148      TSDL_Surface = record
   152 	TSDL_Surface = record
   149                     flags : Longword;
   153 		flags : Longword;
   150                     format: PSDL_PixelFormat;
   154 		format: PSDL_PixelFormat;
   151                     w, h  : LongInt;
   155 		w, h  : LongInt;
   152                     pitch : Word;
   156 		pitch : Word;
   153                     pixels: Pointer;
   157 		pixels: Pointer;
   154                     offset: LongInt;
   158 		offset: LongInt;
   155                     end;
   159 		end;
   156 
   160 
   157 
   161 
   158      PSDL_Color = ^TSDL_Color;
   162 	PSDL_Color = ^TSDL_Color;
   159      TSDL_Color = record
   163 	TSDL_Color = record
   160                   case byte of
   164 		case byte of
   161                        0: (r: Byte;
   165 			0: (r: Byte;
   162                            g: Byte;
   166 				g: Byte;
   163                            b: Byte;
   167 				b: Byte;
   164                            unused: Byte;
   168 				unused: Byte;
   165                           );
   169 				);
   166                        1: (value: Longword);
   170 			1: (value: Longword);
   167                   end;
   171 		end;
   168 
   172 
   169 
   173 
   170      PSDL_RWops = ^TSDL_RWops;
   174 	PSDL_RWops = ^TSDL_RWops;
   171      TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl;
   175 	TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl;
   172      TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt;  cdecl;
   176 	TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt;  cdecl;
   173      TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl;
   177 	TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl;
   174      TClose = function( context: PSDL_RWops ): LongInt; cdecl;
   178 	TClose = function( context: PSDL_RWops ): LongInt; cdecl;
   175 
   179 
   176      TStdio = record
   180 	TStdio = record
   177               autoclose: LongInt;
   181 		autoclose: LongInt;
   178               fp: pointer;
   182 		fp: pointer;
   179               end;
   183 		end;
   180 
   184 
   181      TMem = record
   185 	TMem = record
   182             base: PByte;
   186 		base: PByte;
   183             here: PByte;
   187 		here: PByte;
   184             stop: PByte;
   188 		stop: PByte;
   185             end;
   189 		end;
   186 
   190 
   187      TUnknown = record
   191 	TUnknown = record
   188                 data1: Pointer;
   192 		data1: Pointer;
   189                 end;
   193 		end;
   190 
   194 
   191      TSDL_RWops = record
   195 	TSDL_RWops = record
   192                   seek: TSeek;
   196 		seek: TSeek;
   193                   read: TRead;
   197 		read: TRead;
   194                   write: TWrite;
   198 		write: TWrite;
   195                   close: TClose;
   199 		close: TClose;
   196                   type_: Longword;
   200 		type_: Longword;
   197                   case Byte of
   201 		case Byte of
   198                        0: (stdio: TStdio);
   202 			0: (stdio: TStdio);
   199                        1: (mem: TMem);
   203 			1: (mem: TMem);
   200                        2: (unknown: TUnknown);
   204 			2: (unknown: TUnknown);
   201                        end;
   205 			end;
   202 
   206 
   203      TSDL_KeySym = record
   207 	TSDL_KeySym = record
   204                    scancode: Byte;
   208 		scancode: Byte;
   205                    sym: Longword;
   209 		sym: Longword;
   206                    modifier: Longword;
   210 		modifier: Longword;
   207                    unicode: Word;
   211 		unicode: Word;
   208                    end;
   212 		end;
   209 
   213 
   210      TSDL_ActiveEvent = record
   214 	TSDL_ActiveEvent = record
   211 	                type_: byte;
   215 		type_: byte;
   212                     gain: byte;
   216 		gain: byte;
   213                     state: byte;
   217 		state: byte;
   214                     end;
   218 		end;
   215 
   219 
   216      TSDL_KeyboardEvent = record
   220 	TSDL_KeyboardEvent = record
   217                           type_: Byte;
   221 		type_: Byte;
   218                           which: Byte;
   222 		which: Byte;
   219                           state: Byte;
   223 		state: Byte;
   220                           keysym: TSDL_KeySym;
   224 		keysym: TSDL_KeySym;
   221                           end;
   225 		end;
   222 
   226 
   223      TSDL_GLattr = ( SDL_GL_RED_SIZE,
   227 	TSDL_MouseButtonEvent = record
   224                      SDL_GL_GREEN_SIZE,
   228 		_type,
   225                      SDL_GL_BLUE_SIZE,
   229 		which,
   226                      SDL_GL_ALPHA_SIZE,
   230 		button,
   227                      SDL_GL_BUFFER_SIZE,
   231 		state: byte;
   228                      SDL_GL_DOUBLEBUFFER,
   232 		x, y: word;
   229                      SDL_GL_DEPTH_SIZE,
   233 		end;
   230                      SDL_GL_STENCIL_SIZE,
   234 
   231                      SDL_GL_ACCUM_RED_SIZE,
   235 	TSDL_GLattr = (
   232                      SDL_GL_ACCUM_GREEN_SIZE,
   236 		SDL_GL_RED_SIZE,
   233                      SDL_GL_ACCUM_BLUE_SIZE,
   237 		SDL_GL_GREEN_SIZE,
   234                      SDL_GL_ACCUM_ALPHA_SIZE,
   238 		SDL_GL_BLUE_SIZE,
   235                      SDL_GL_STEREO,
   239 		SDL_GL_ALPHA_SIZE,
   236                      SDL_GL_MULTISAMPLEBUFFERS,
   240 		SDL_GL_BUFFER_SIZE,
   237                      SDL_GL_MULTISAMPLESAMPLES,
   241 		SDL_GL_DOUBLEBUFFER,
   238                      SDL_GL_ACCELERATED_VISUAL,
   242 		SDL_GL_DEPTH_SIZE,
   239                      SDL_GL_RETAINED_BACKING,
   243 		SDL_GL_STENCIL_SIZE,
   240                      SDL_GL_CONTEXT_MAJOR_VERSION,
   244 		SDL_GL_ACCUM_RED_SIZE,
   241                      SDL_GL_CONTEXT_MINOR_VERSION );
   245 		SDL_GL_ACCUM_GREEN_SIZE,
       
   246 		SDL_GL_ACCUM_BLUE_SIZE,
       
   247 		SDL_GL_ACCUM_ALPHA_SIZE,
       
   248 		SDL_GL_STEREO,
       
   249 		SDL_GL_MULTISAMPLEBUFFERS,
       
   250 		SDL_GL_MULTISAMPLESAMPLES,
       
   251 		SDL_GL_ACCELERATED_VISUAL,
       
   252 		SDL_GL_RETAINED_BACKING,
       
   253 		SDL_GL_CONTEXT_MAJOR_VERSION,
       
   254 		SDL_GL_CONTEXT_MINOR_VERSION
       
   255 		);
   242 
   256 
   243 {$IFDEF SDL13}
   257 {$IFDEF SDL13}
   244      TSDL_MouseMotionEvent = record
   258      TSDL_MouseMotionEvent = record
   245                              type_: byte;
   259                              type_: byte;
   246                              which: byte;
   260                              which: byte;
   266                        SDL_NOEVENT: (type_: byte);
   280                        SDL_NOEVENT: (type_: byte);
   267                        SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
   281                        SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
   268                        SDL_KEYDOWN, SDL_KEYUP: (key: TSDL_KeyboardEvent);
   282                        SDL_KEYDOWN, SDL_KEYUP: (key: TSDL_KeyboardEvent);
   269                        SDL_QUITEV: (quit: TSDL_QuitEvent);
   283                        SDL_QUITEV: (quit: TSDL_QuitEvent);
   270                        SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent);
   284                        SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent);
       
   285                        SDL_MOUSEBUTTONDOWN,
       
   286                        SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
   271 {$IFDEF SDL13}
   287 {$IFDEF SDL13}
   272                        SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
   288                        SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
   273 {$ENDIF}
   289 {$ENDIF}
   274      end;
   290      end;
   275 
   291