5 SDL_RWOPS_UNKNOWN = 0; {* Unknown stream type *}
6 SDL_RWOPS_WINFILE = 1; {* Win32 file *}
7 SDL_RWOPS_STDFILE = 2; {* Stdio file *}
8 SDL_RWOPS_JNIFILE = 3; {* Android asset *}
9 SDL_RWOPS_MEMORY = 4; {* Memory stream *}
10 SDL_RWOPS_MEMORY_RO = 5; {* Read-Only memory stream *}
13 PSDL_RWops = ^TSDL_RWops;
16 * This is the read/write operation structure -- very basic.
20 * Return the size of the file in this rwops, or -1 if unknown
22 TSize = function(context: PSDL_RWops): SInt64; {$IFNDEF GPC} cdecl; {$ENDIF}
25 * Seek to offset relative to whence, one of stdio's whence values:
26 * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END
28 * the final offset in the data stream, or -1 on error.
30 TSeek = function(context: PSDL_RWops; offset: SInt64; whence: SInt32): SInt64; {$IFNDEF GPC} cdecl; {$ENDIF}
33 * Read up to maxnum objects each of size size from the data
34 * stream to the area pointed at by ptr.
36 * the number of objects read, or 0 at error or end of file.
39 TRead = function(context: PSDL_RWops; ptr: Pointer; size: size_t; maxnum: size_t): size_t; {$IFNDEF GPC} cdecl; {$ENDIF}
42 * Write exactly num objects each of size size from the area
43 * pointed at by ptr to data stream.
45 * the number of objects written, or 0 at error or end of file.
48 TWrite = function(context: PSDL_RWops; const ptr: Pointer; size: size_t; num: size_t): size_t; {$IFNDEF GPC} cdecl; {$ENDIF}
51 * Close and free an allocated SDL_RWops structure.
53 * 0 if successful or -1 on write error when flushing data.
56 TClose = function(context: PSDL_RWops): SInt32; {$IFNDEF GPC} cdecl; {$ENDIF}
75 inputStreamRef: Pointer;
76 readableByteChannelRef: Pointer;
78 assetFileDescriptorRef: Pointer;
85 TWindowsIOBuffer = record
94 buffer: TWindowsIOBuffer;
97 TSDL_RWops = packed record
109 2: (unknown: TUnknown);
111 3: (androidio: TAndroidIO);
114 3: (windowsio: TWindowsIO);
121 * Functions to create SDL_RWops structures from various data streams.
124 function SDL_RWFromFile(const _file: PAnsiChar; const mode: PAnsiChar): PSDL_RWops; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RWFromFile' {$ENDIF} {$ENDIF};
126 {function SDL_RWFromFP(fp: file; autoclose: TSDL_Bool): PSDL_RWops; cdecl; external SDL_LibName;} //don't know if this works
128 function SDL_RWFromFP(fp: Pointer; autoclose: TSDL_Bool): PSDL_RWops; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RWFromFP' {$ENDIF} {$ENDIF};
130 function SDL_RWFromMem(mem: Pointer; size: SInt32): PSDL_RWops; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RWFromMem' {$ENDIF} {$ENDIF};
131 function SDL_RWFromConstMem(const mem: Pointer; size: SInt32): PSDL_RWops; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RWFromConstMem' {$ENDIF} {$ENDIF};
136 function SDL_AllocRW: PSDL_RWops; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AllocRW' {$ENDIF} {$ENDIF};
137 procedure SDL_FreeRW(area: PSDL_RWops); cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FreeRW' {$ENDIF} {$ENDIF};
140 RW_SEEK_SET = 0; {**< Seek from the beginning of data *}
141 RW_SEEK_CUR = 1; {**< Seek relative to current read point *}
142 RW_SEEK_END = 2; {**< Seek relative to the end of data *}
147 * Macros to easily read and write from an SDL_RWops structure.
150 function SDL_RWsize(ctx: PSDL_RWops): SInt64;
151 function SDL_RWseek(ctx: PSDL_RWops; offset: SInt64; whence: SInt32): SInt64;
152 function SDL_RWtell(ctx: PSDL_RWops): SInt64;
153 function SDL_RWread(ctx: PSDL_RWops; ptr: Pointer; size: size_t; n: size_t): size_t;
154 function SDL_RWwrite(ctx: PSDL_RWops; ptr: Pointer; size: size_t; n: size_t): size_t;
155 function SDL_RWclose(ctx: PSDL_RWops): SInt32;
156 { Read/write macros }
160 * Read endian functions
162 * Read an item of the specified endianness and return in native format.
165 function SDL_ReadU8(src: PSDL_RWops): UInt8 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ReadU8' {$ENDIF} {$ENDIF};
166 function SDL_ReadLE16(src: PSDL_RWops): UInt16 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ReadLE16' {$ENDIF} {$ENDIF};
167 function SDL_ReadBE16(src: PSDL_RWops): UInt16 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ReadBE16' {$ENDIF} {$ENDIF};
168 function SDL_ReadLE32(src: PSDL_RWops): UInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ReadLE32' {$ENDIF} {$ENDIF};
169 function SDL_ReadBE32(src: PSDL_RWops): UInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ReadBE32' {$ENDIF} {$ENDIF};
170 function SDL_ReadLE64(src: PSDL_RWops): UInt64 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ReadLE64' {$ENDIF} {$ENDIF};
171 function SDL_ReadBE64(src: PSDL_RWops): UInt64 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ReadBE64' {$ENDIF} {$ENDIF};
173 {*Read endian functions*}
176 * Write endian functions
178 * Write an item of native format to the specified endianness.
181 function SDL_WriteU8(dst: PSDL_RWops; value: UInt8): size_t cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WriteU8' {$ENDIF} {$ENDIF};
182 function SDL_WriteLE16(dst: PSDL_RWops; value: UInt16): size_t cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WriteLE16' {$ENDIF} {$ENDIF};
183 function SDL_WriteBE16(dst: PSDL_RWops; value: UInt16): size_t cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WriteBE16' {$ENDIF} {$ENDIF};
184 function SDL_WriteLE32(dst: PSDL_RWops; value: UInt32): size_t cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WriteLE32' {$ENDIF} {$ENDIF};
185 function SDL_WriteBE32(dst: PSDL_RWops; value: UInt32): size_t cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WriteBE32' {$ENDIF} {$ENDIF};
186 function SDL_WriteLE64(dst: PSDL_RWops; value: UInt64): size_t cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WriteLE64' {$ENDIF} {$ENDIF};
187 function SDL_WriteBE64(dst: PSDL_RWops; value: UInt64): size_t cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_WriteBE64' {$ENDIF} {$ENDIF};
188 { Write endian functions }