Unfortunately, we need to use IntPtrs for SDL_Surface and Mix_Chunk. Otherwise we cannot free these resources. Just do a PtrToStructure in the application.

This commit is contained in:
Ethan Lee 2013-04-09 23:04:37 -04:00
parent d3dcc117e9
commit 9ab0d1d2c3
4 changed files with 176 additions and 568 deletions

View file

@ -678,23 +678,9 @@ namespace SDL2
ref int h ref int h
); );
/* window refers to an SDL_Window* */ /* IntPtr refers to an SDL_Surface*, window to an SDL_Window* */
[DllImport(nativeLibName, EntryPoint = "SDL_GetWindowSurface")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_SDL_GetWindowSurface( public static extern IntPtr SDL_GetWindowSurface(IntPtr window);
IntPtr window
);
public static SDL_Surface SDL_GetWindowSurface(IntPtr window)
{
SDL_Surface result;
IntPtr result_ptr = INTERNAL_SDL_GetWindowSurface(
window
);
result = (SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* window refers to an SDL_Window* */ /* window refers to an SDL_Window* */
[DllImport(nativeLibName, EntryPoint = "SDL_GetWindowTitle")] [DllImport(nativeLibName, EntryPoint = "SDL_GetWindowTitle")]
@ -832,11 +818,11 @@ namespace SDL2
SDL_bool grabbed SDL_bool grabbed
); );
/* window refers to an SDL_Window* */ /* window refers to an SDL_Window*, icon to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern void SDL_SetWindowIcon( public static extern void SDL_SetWindowIcon(
IntPtr window, IntPtr window,
ref SDL_Surface icon IntPtr icon
); );
/* window refers to an SDL_Window* */ /* window refers to an SDL_Window* */
@ -943,11 +929,9 @@ namespace SDL2
uint flags uint flags
); );
/* IntPtr refers to an SDL_Renderer* */ /* IntPtr refers to an SDL_Renderer*, surface to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern IntPtr SDL_CreateRenderer( public static extern IntPtr SDL_CreateRenderer(IntPtr surface);
ref SDL_Surface surface
);
/* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */ /* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
@ -959,11 +943,14 @@ namespace SDL2
int h int h
); );
/* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */ /* IntPtr refers to an SDL_Texture*
* renderer refers to an SDL_Renderer*
* surface refers to an SDL_Surface*
*/
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern IntPtr SDL_CreateTextureFromSurface( public static extern IntPtr SDL_CreateTextureFromSurface(
IntPtr renderer, IntPtr renderer,
ref SDL_Surface surface IntPtr surface
); );
/* renderer refers to an SDL_Renderer* */ /* renderer refers to an SDL_Renderer* */
@ -1863,16 +1850,23 @@ namespace SDL2
public int refcount; public int refcount;
} }
public static bool SDL_MUSTLOCK(ref SDL_Surface surface) /* surface refers to an SDL_Surface* */
public static bool SDL_MUSTLOCK(IntPtr surface)
{ {
return (surface.flags & SDL_RLEACCEL) != 0; SDL_Surface sur;
sur = (SDL_Surface) Marshal.PtrToStructure(
surface,
sur.GetType()
);
return (sur.flags & SDL_RLEACCEL) != 0;
} }
/* src and dst refer to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_BlitSurface( public static extern int SDL_BlitSurface(
ref SDL_Surface src, IntPtr src,
ref SDL_Rect srcrect, ref SDL_Rect srcrect,
ref SDL_Surface dst, IntPtr dst,
ref SDL_Rect dstrect ref SDL_Rect dstrect
); );
@ -1889,57 +1883,28 @@ namespace SDL2
int dst_pitch int dst_pitch
); );
/* fmt refers to an SDL_PixelFormat* */ /* IntPtr refers to an SDL_Surface*
[DllImport(nativeLibName, EntryPoint = "SDL_ConvertSurface")] * src refers to an SDL_Surface*
private static extern IntPtr INTERNAL_SDL_ConvertSurface( * fmt refers to an SDL_PixelFormat*
ref SDL_Surface src, */
[DllImport(nativeLibName)]
public static extern IntPtr SDL_ConvertSurface(
IntPtr src,
IntPtr fmt, IntPtr fmt,
uint flags uint flags
); );
public static SDL_Surface SDL_ConvertSurface(
ref SDL_Surface src,
IntPtr fmt,
uint flags
) {
SDL_Surface result;
IntPtr result_ptr = INTERNAL_SDL_ConvertSurface(
ref src,
fmt,
flags
);
result = (SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
[DllImport(nativeLibName, EntryPoint = "SDL_ConvertSurfaceFormat")] /* IntPtr refers to an SDL_Surface*, src to an SDL_Surface* */
private static extern IntPtr INTERNAL_SDL_ConvertSurfaceFormat( [DllImport(nativeLibName)]
ref SDL_Surface src, public static extern IntPtr SDL_ConvertSurfaceFormat(
IntPtr src,
uint pixel_format, uint pixel_format,
uint flags uint flags
); );
public static SDL_Surface SDL_ConvertSurfaceFormat(
ref SDL_Surface src,
uint pixel_format,
uint flags
) {
SDL_Surface result;
IntPtr result_ptr = INTERNAL_SDL_ConvertSurfaceFormat(
ref src,
pixel_format,
flags
);
result = (SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
[DllImport(nativeLibName, EntryPoint = "SDL_CreateRGBSurface")] /* IntPtr refers to an SDL_Surface* */
private static extern IntPtr INTERNAL_SDL_CreateRGBSurface( [DllImport(nativeLibName)]
public static extern IntPtr SDL_CreateRGBSurface(
uint flags, uint flags,
int width, int width,
int height, int height,
@ -1949,37 +1914,10 @@ namespace SDL2
uint Bmask, uint Bmask,
uint Amask uint Amask
); );
public static SDL_Surface SDL_CreateRGBSurface(
uint flags,
int width,
int height,
int depth,
uint Rmask,
uint Gmask,
uint Bmask,
uint Amask
) {
SDL_Surface result;
IntPtr result_ptr = INTERNAL_SDL_CreateRGBSurface(
flags,
width,
height,
depth,
Rmask,
Gmask,
Bmask,
Amask
);
result = (SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* pixels refers to a void* */ /* pixels refers to a void* */
[DllImport(nativeLibName, EntryPoint = "SDL_CreateRGBSurfaceFrom")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_SDL_CreateRGBSurfaceFrom( public static extern IntPtr SDL_CreateRGBSurfaceFrom(
IntPtr pixels, IntPtr pixels,
int width, int width,
int height, int height,
@ -1990,202 +1928,189 @@ namespace SDL2
uint Bmask, uint Bmask,
uint Amask uint Amask
); );
public static SDL_Surface SDL_CreateRGBSurfaceFrom(
IntPtr pixels,
int width,
int height,
int depth,
int pitch,
uint Rmask,
uint Gmask,
uint Bmask,
uint Amask
) {
SDL_Surface result;
IntPtr result_ptr = INTERNAL_SDL_CreateRGBSurfaceFrom(
pixels,
width,
height,
depth,
pitch,
Rmask,
Gmask,
Bmask,
Amask
);
result = (SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* dst refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_FillRect( public static extern int SDL_FillRect(
ref SDL_Surface dst, IntPtr dst,
ref SDL_Rect rect, ref SDL_Rect rect,
uint color uint color
); );
/* dst refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_FillRects( public static extern int SDL_FillRects(
ref SDL_Surface dst, IntPtr dst,
SDL_Rect[] rects, SDL_Rect[] rects,
int count, int count,
uint color uint color
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern void SDL_FreeSurface(ref SDL_Surface surface); public static extern void SDL_FreeSurface(IntPtr surface);
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern void SDL_GetClipRect( public static extern void SDL_GetClipRect(
ref SDL_Surface surface, IntPtr surface,
ref SDL_Rect rect ref SDL_Rect rect
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_GetColorKey( public static extern int SDL_GetColorKey(
ref SDL_Surface surface, IntPtr surface,
ref uint key ref uint key
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_GetSurfaceAlphaMod( public static extern int SDL_GetSurfaceAlphaMod(
ref SDL_Surface surface, IntPtr surface,
ref byte alpha ref byte alpha
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_GetSurfaceBlendMode( public static extern int SDL_GetSurfaceBlendMode(
ref SDL_Surface surface, IntPtr surface,
ref SDL_BlendMode blendMode ref SDL_BlendMode blendMode
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_GetSurfaceColorMod( public static extern int SDL_GetSurfaceColorMod(
ref SDL_Surface surface, IntPtr surface,
ref byte r, ref byte r,
ref byte g, ref byte g,
ref byte b ref byte b
); );
/* These are for SDL_LoadBMP, which is a macro in the SDL headers. */ /* These are for SDL_LoadBMP, which is a macro in the SDL headers. */
/* THIS IS AN RWops FUNCTION! /* IntPtr refers to an SDL_Surface* */
*/ /* THIS IS AN RWops FUNCTION! */
[DllImport(nativeLibName, EntryPoint = "SDL_LoadBMP_RW")] [DllImport(nativeLibName, EntryPoint = "SDL_LoadBMP_RW")]
private static extern IntPtr INTERNAL_SDL_LoadBMP_RW( private static extern IntPtr INTERNAL_SDL_LoadBMP_RW(
IntPtr src, IntPtr src,
int freesrc int freesrc
); );
public static SDL_Surface SDL_LoadBMP(string file) public static IntPtr SDL_LoadBMP(string file)
{ {
SDL_Surface result;
IntPtr rwops = INTERNAL_SDL_RWFromFile(file, "rb"); IntPtr rwops = INTERNAL_SDL_RWFromFile(file, "rb");
IntPtr result_ptr = INTERNAL_SDL_LoadBMP_RW(rwops, 1); return INTERNAL_SDL_LoadBMP_RW(rwops, 1);
result = (SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
} }
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_LockSurface(ref SDL_Surface surface); public static extern int SDL_LockSurface(IntPtr surface);
/* src and dst refer to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_LowerBlit( public static extern int SDL_LowerBlit(
ref SDL_Surface src, IntPtr src,
ref SDL_Rect srcrect, ref SDL_Rect srcrect,
ref SDL_Surface dst, IntPtr dst,
ref SDL_Rect dstrect ref SDL_Rect dstrect
); );
/* src and dst refer to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_LowerBlitScaled( public static extern int SDL_LowerBlitScaled(
ref SDL_Surface src, IntPtr src,
ref SDL_Rect srcrect, ref SDL_Rect srcrect,
ref SDL_Surface dst, IntPtr dst,
ref SDL_Rect dstrect ref SDL_Rect dstrect
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_SaveBMP( public static extern int SDL_SaveBMP(
ref SDL_Surface surface, IntPtr surface,
[InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)] [InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)]
string file string file
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern SDL_bool SDL_SetClipRect( public static extern SDL_bool SDL_SetClipRect(
ref SDL_Surface surface, IntPtr surface,
ref SDL_Rect rect ref SDL_Rect rect
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_SetColorKey( public static extern int SDL_SetColorKey(
ref SDL_Surface surface, IntPtr surface,
int flag, int flag,
uint key uint key
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_SetSurfaceAlphaMod( public static extern int SDL_SetSurfaceAlphaMod(
ref SDL_Surface surface, IntPtr surface,
byte alpha byte alpha
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_SetSurfaceBlendMode( public static extern int SDL_SetSurfaceBlendMode(
ref SDL_Surface surface, IntPtr surface,
SDL_BlendMode blendMode SDL_BlendMode blendMode
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_SetSurfaceColorMod( public static extern int SDL_SetSurfaceColorMod(
ref SDL_Surface surface, IntPtr surface,
byte r, byte r,
byte g, byte g,
byte b byte b
); );
/* palette refers to an SDL_Palette* */ /* surface refers to an SDL_Surface*, palette to an SDL_Palette* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_SetSurfacePalette( public static extern int SDL_SetSurfacePalette(
ref SDL_Surface surface, IntPtr surface,
IntPtr palette IntPtr palette
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_SetSurfaceRLE( public static extern int SDL_SetSurfaceRLE(
ref SDL_Surface surface, IntPtr surface,
int flag int flag
); );
/* src and dst refer to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_SoftStretch( public static extern int SDL_SoftStretch(
ref SDL_Surface src, IntPtr src,
ref SDL_Rect srcrect, ref SDL_Rect srcrect,
ref SDL_Surface dst, IntPtr dst,
ref SDL_Rect dstrect ref SDL_Rect dstrect
); );
/* surface refers to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern void SDL_UnlockSurface(ref SDL_Surface surface); public static extern void SDL_UnlockSurface(IntPtr surface);
/* src and dst refer to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_UpperBlit( public static extern int SDL_UpperBlit(
ref SDL_Surface src, IntPtr src,
ref SDL_Rect srcrect, ref SDL_Rect srcrect,
ref SDL_Surface dst, IntPtr dst,
ref SDL_Rect dstrect ref SDL_Rect dstrect
); );
/* src and dst refer to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int SDL_UpperBlitScaled( public static extern int SDL_UpperBlitScaled(
ref SDL_Surface src, IntPtr src,
ref SDL_Rect srcrect, ref SDL_Rect srcrect,
ref SDL_Surface dst, IntPtr dst,
ref SDL_Rect dstrect ref SDL_Rect dstrect
); );
@ -3376,10 +3301,10 @@ namespace SDL2
); );
/* Create a cursor from an SDL_Surface */ /* Create a cursor from an SDL_Surface */
/* return value is an SDL_Cursor pointer */ /* IntPtr refers to an SDL_Cursor*, surface to an SDL_Surface* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern IntPtr SDL_CreateColorCursor( public static extern IntPtr SDL_CreateColorCursor(
ref SDL_Surface surface, IntPtr surface,
int hot_x, int hot_x,
int hot_y int hot_y
); );

View file

@ -72,21 +72,12 @@ namespace SDL2
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern void IMG_Quit(); public static extern void IMG_Quit();
[DllImport(nativeLibName, EntryPoint = "IMG_Load")] /* IntPtr refers to an SDL_Surface* */
private static extern IntPtr INTERNAL_IMG_Load( [DllImport(nativeLibName)]
public static extern IntPtr IMG_Load(
[InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)] [InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)]
string file string file
); );
public static SDL.SDL_Surface IMG_Load(string file)
{
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_IMG_Load(file);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */ /* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
@ -99,20 +90,9 @@ namespace SDL2
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int IMG_InvertAlpha(int on); public static extern int IMG_InvertAlpha(int on);
[DllImport(nativeLibName, EntryPoint = "IMG_ReadXPMFromArray")] /* IntPtr refers to an SDL_Surface* */
private static extern IntPtr INTERNAL_IMG_ReadXPMFromArray( [DllImport(nativeLibName)]
ref char[] xpm public static extern IntPtr IMG_ReadXPMFromArray(ref char[] xpm);
);
public static SDL.SDL_Surface IMG_ReadXPMFromArray(ref char[] xpm)
{
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_IMG_ReadXPMFromArray(ref xpm);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
#endregion #endregion
} }

View file

@ -163,21 +163,16 @@ namespace SDL2
/* These are for Mix_LoadWAV, which is a macro in the C header. /* These are for Mix_LoadWAV, which is a macro in the C header.
* THIS IS AN RWops FUNCTION! * THIS IS AN RWops FUNCTION!
*/ */
/* IntPtr refers to a Mix_Chunk* */
[DllImport(nativeLibName, EntryPoint = "Mix_LoadWAV_RW")] [DllImport(nativeLibName, EntryPoint = "Mix_LoadWAV_RW")]
private static extern IntPtr INTERNAL_Mix_LoadWAV_RW( private static extern IntPtr INTERNAL_Mix_LoadWAV_RW(
IntPtr src, IntPtr src,
int freesrc int freesrc
); );
public static Mix_Chunk Mix_LoadWAV(string file) public static IntPtr Mix_LoadWAV(string file)
{ {
Mix_Chunk result;
IntPtr rwops = SDL.INTERNAL_SDL_RWFromFile(file, "rb"); IntPtr rwops = SDL.INTERNAL_SDL_RWFromFile(file, "rb");
IntPtr result_ptr = INTERNAL_Mix_LoadWAV_RW(rwops, 1); return INTERNAL_Mix_LoadWAV_RW(rwops, 1);
result = (Mix_Chunk) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
} }
/* IntPtr refers to a Mix_Music* */ /* IntPtr refers to a Mix_Music* */
@ -187,37 +182,17 @@ namespace SDL2
string file string file
); );
[DllImport(nativeLibName, EntryPoint = "Mix_QuickLoad_WAV")] /* IntPtr refers to a Mix_Chunk* */
private static extern IntPtr INTERNAL_Mix_QuickLoad_WAV(byte[] mem);
public static Mix_Chunk Mix_QuickLoad_WAV(byte[] mem)
{
Mix_Chunk result;
IntPtr result_ptr = INTERNAL_Mix_QuickLoad_WAV(mem);
result = (Mix_Chunk) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
[DllImport(nativeLibName, EntryPoint = "Mix_QuickLoad_RAW")]
private static extern IntPtr INTERNAL_Mix_QuickLoad_RAW(
byte[] mem,
uint len
);
public static Mix_Chunk Mix_QuickLoad_RAW(byte[] mem, uint len)
{
Mix_Chunk result;
IntPtr result_ptr = INTERNAL_Mix_QuickLoad_RAW(mem, len);
result = (Mix_Chunk) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern void Mix_FreeChunk(ref Mix_Chunk chunk); public static extern IntPtr Mix_QuickLoad_WAV(byte[] mem);
/* IntPtr refers to a Mix_Chunk* */
[DllImport(nativeLibName)]
public static extern Mix_Chunk Mix_QuickLoad_RAW(byte[] mem, uint len);
/* chunk refers to a Mix_Chunk* */
[DllImport(nativeLibName)]
public static extern void Mix_FreeChunk(IntPtr chunk);
/* music refers to a Mix_Music* */ /* music refers to a Mix_Music* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
@ -335,18 +310,20 @@ namespace SDL2
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int Mix_GroupNewer(int tag); public static extern int Mix_GroupNewer(int tag);
/* chunk refers to a Mix_Chunk* */
public static int Mix_PlayChannel( public static int Mix_PlayChannel(
int channel, int channel,
ref Mix_Chunk chunk, IntPtr chunk,
int loops int loops
) { ) {
return Mix_PlayChannelTimed(channel, ref chunk, loops, -1); return Mix_PlayChannelTimed(channel, chunk, loops, -1);
} }
/* chunk refers to a Mix_Chunk* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int Mix_PlayChannelTimed( public static extern int Mix_PlayChannelTimed(
int channel, int channel,
ref Mix_Chunk chunk, IntPtr chunk,
int loops, int loops,
int ticks int ticks
); );
@ -355,6 +332,7 @@ namespace SDL2
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int Mix_PlayMusic(IntPtr music, int loops); public static extern int Mix_PlayMusic(IntPtr music, int loops);
/* music refers to a Mix_Music* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int Mix_FadeInMusic( public static extern int Mix_FadeInMusic(
IntPtr music, IntPtr music,
@ -371,19 +349,21 @@ namespace SDL2
double position double position
); );
/* chunk refers to a Mix_Chunk* */
public static int Mix_FadeInChannel( public static int Mix_FadeInChannel(
int channel, int channel,
ref Mix_Chunk chunk, IntPtr chunk,
int loops, int loops,
int ms int ms
) { ) {
return Mix_FadeInChannelTimed(channel, ref chunk, loops, ms, -1); return Mix_FadeInChannelTimed(channel, chunk, loops, ms, -1);
} }
/* chunk refers to a Mix_Chunk* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int Mix_FadeInChannelTimed( public static extern int Mix_FadeInChannelTimed(
int channel, int channel,
ref Mix_Chunk chunk, IntPtr chunk,
int loops, int loops,
int ms, int ms,
int ticks int ticks
@ -392,9 +372,10 @@ namespace SDL2
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int Mix_Volume(int channel, int volume); public static extern int Mix_Volume(int channel, int volume);
/* chunk refers to a Mix_Chunk* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern int Mix_VolumeChunk( public static extern int Mix_VolumeChunk(
ref Mix_Chunk chunk, IntPtr chunk,
int volume int volume
); );
@ -489,18 +470,9 @@ namespace SDL2
IntPtr data // void* IntPtr data // void*
); );
[DllImport(nativeLibName, EntryPoint = "Mix_GetChunk")] /* IntPtr refers to a Mix_Chunk* */
private static extern IntPtr INTERNAL_Mix_GetChunk(int channel); [DllImport(nativeLibName)]
public static Mix_Chunk Mix_GetChunk(int channel) public static extern IntPtr Mix_GetChunk(int channel);
{
Mix_Chunk result;
IntPtr result_ptr = INTERNAL_Mix_GetChunk(channel);
result = (Mix_Chunk) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
[DllImport(nativeLibName)] [DllImport(nativeLibName)]
public static extern void Mix_CloseAudio(); public static extern void Mix_CloseAudio();

View file

@ -219,409 +219,140 @@ namespace SDL2
ref int h ref int h
); );
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderText_Solid")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderText_Solid( public static extern IntPtr TTF_RenderText_Solid(
IntPtr font, IntPtr font,
[InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)] [InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)]
string text, string text,
SDL.SDL_Color fg SDL.SDL_Color fg
); );
public static SDL.SDL_Surface TTF_RenderText_Solid(
IntPtr font,
string text,
SDL.SDL_Color fg
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderText_Solid(
font,
text,
fg
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Solid")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderUTF8_Solid( public static extern IntPtr TTF_RenderUTF8_Solid(
IntPtr font, IntPtr font,
[InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)] [InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)]
string text, string text,
SDL.SDL_Color fg SDL.SDL_Color fg
); );
public static SDL.SDL_Surface TTF_RenderUTF8_Solid(
IntPtr font,
string text,
SDL.SDL_Color fg
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderUTF8_Solid(
font,
text,
fg
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUNICODE_Solid")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderUNICODE_Solid( public static extern IntPtr TTF_RenderUNICODE_Solid(
IntPtr font, IntPtr font,
ushort[] text, ushort[] text,
SDL.SDL_Color fg SDL.SDL_Color fg
); );
public static SDL.SDL_Surface TTF_RenderUNICODE_Solid(
IntPtr font,
ushort[] text,
SDL.SDL_Color fg
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderUNICODE_Solid(
font,
text,
fg
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderGlyph_Solid")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderGlyph_Solid( public static extern IntPtr TTF_RenderGlyph_Solid(
IntPtr font, IntPtr font,
ushort ch, ushort ch,
SDL.SDL_Color fg SDL.SDL_Color fg
); );
public static SDL.SDL_Surface TTF_RenderGlyph_Solid(
IntPtr font,
ushort ch,
SDL.SDL_Color fg
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderGlyph_Solid(
font,
ch,
fg
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderText_Shaded")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderText_Shaded( public static extern IntPtr TTF_RenderText_Shaded(
IntPtr font, IntPtr font,
[InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)] [InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)]
string text, string text,
SDL.SDL_Color fg, SDL.SDL_Color fg,
SDL.SDL_Color bg SDL.SDL_Color bg
); );
public static SDL.SDL_Surface TTF_RenderText_Shaded(
IntPtr font,
string text,
SDL.SDL_Color fg,
SDL.SDL_Color bg
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderText_Shaded(
font,
text,
fg,
bg
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Shaded")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderUTF8_Shaded( public static extern IntPtr TTF_RenderUTF8_Shaded(
IntPtr font, IntPtr font,
[InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)] [InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)]
string text, string text,
SDL.SDL_Color fg, SDL.SDL_Color fg,
SDL.SDL_Color bg SDL.SDL_Color bg
); );
public static SDL.SDL_Surface TTF_RenderUTF8_Shaded(
IntPtr font,
string text,
SDL.SDL_Color fg,
SDL.SDL_Color bg
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderUTF8_Shaded(
font,
text,
fg,
bg
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUNICODE_Shaded")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderUNICODE_Shaded( public static extern IntPtr TTF_RenderUNICODE_Shaded(
IntPtr font, IntPtr font,
ushort[] text, ushort[] text,
SDL.SDL_Color fg, SDL.SDL_Color fg,
SDL.SDL_Color bg SDL.SDL_Color bg
); );
public static SDL.SDL_Surface TTF_RenderUNICODE_Shaded(
IntPtr font,
ushort[] text,
SDL.SDL_Color fg,
SDL.SDL_Color bg
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderUNICODE_Shaded(
font,
text,
fg,
bg
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderGlyph_Shaded")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderGlyph_Shaded( public static extern IntPtr TTF_RenderGlyph_Shaded(
IntPtr font, IntPtr font,
ushort ch, ushort ch,
SDL.SDL_Color fg, SDL.SDL_Color fg,
SDL.SDL_Color bg SDL.SDL_Color bg
); );
public static SDL.SDL_Surface TTF_RenderGlyph_Shaded(
IntPtr font,
ushort ch,
SDL.SDL_Color fg,
SDL.SDL_Color bg
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderGlyph_Shaded(
font,
ch,
fg,
bg
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderText_Blended")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderText_Blended( public static extern IntPtr TTF_RenderText_Blended(
IntPtr font, IntPtr font,
[InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)] [InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)]
string text, string text,
SDL.SDL_Color fg SDL.SDL_Color fg
); );
public static SDL.SDL_Surface TTF_RenderText_Blended(
IntPtr font,
string text,
SDL.SDL_Color fg
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderText_Blended(
font,
text,
fg
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Blended")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderUTF8_Blended( public static extern IntPtr TTF_RenderUTF8_Blended(
IntPtr font, IntPtr font,
[InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)] [InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)]
string text, string text,
SDL.SDL_Color fg SDL.SDL_Color fg
); );
public static SDL.SDL_Surface TTF_RenderUTF8_Blended(
IntPtr font,
string text,
SDL.SDL_Color fg
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderUTF8_Blended(
font,
text,
fg
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUNICODE_Blended")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderUNICODE_Blended( public static extern IntPtr TTF_RenderUNICODE_Blended(
IntPtr font, IntPtr font,
ushort[] text, ushort[] text,
SDL.SDL_Color fg SDL.SDL_Color fg
); );
public static SDL.SDL_Surface TTF_RenderUNICODE_Blended(
IntPtr font,
ushort[] text,
SDL.SDL_Color fg
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderUNICODE_Blended(
font,
text,
fg
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderText_Blended_Wrapped")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderText_Blended_Wrapped( public static extern IntPtr TTF_RenderText_Blended_Wrapped(
IntPtr font, IntPtr font,
[InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)] [InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)]
string text, string text,
SDL.SDL_Color fg, SDL.SDL_Color fg,
uint wrapped uint wrapped
); );
public static SDL.SDL_Surface TTF_RenderText_Blended_Wrapped(
IntPtr font,
string text,
SDL.SDL_Color fg,
uint wrapped
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderText_Blended_Wrapped(
font,
text,
fg,
wrapped
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUTF8_Blended_Wrapped")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderUTF8_Blended_Wrapped( public static extern IntPtr TTF_RenderUTF8_Blended_Wrapped(
IntPtr font, IntPtr font,
[InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)] [InAttribute()] [MarshalAsAttribute(UnmanagedType.LPStr)]
string text, string text,
SDL.SDL_Color fg, SDL.SDL_Color fg,
uint wrapped uint wrapped
); );
public static SDL.SDL_Surface TTF_RenderUTF8_Blended_Wrapped(
IntPtr font,
string text,
SDL.SDL_Color fg,
uint wrapped
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderUTF8_Blended_Wrapped(
font,
text,
fg,
wrapped
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderUNICODE_Blended_Wrapped")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderUNICODE_Blended_Wrapped( public static extern IntPtr TTF_RenderUNICODE_Blended_Wrapped(
IntPtr font, IntPtr font,
ushort[] text, ushort[] text,
SDL.SDL_Color fg, SDL.SDL_Color fg,
uint wrapped uint wrapped
); );
public static SDL.SDL_Surface TTF_RenderUNICODE_Blended_Wrapped(
IntPtr font,
ushort[] text,
SDL.SDL_Color fg,
uint wrapped
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderUNICODE_Blended_Wrapped(
font,
text,
fg,
wrapped
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
[DllImport(nativeLibName, EntryPoint = "TTF_RenderGlyph_Blended")] [DllImport(nativeLibName)]
private static extern IntPtr INTERNAL_TTF_RenderGlyph_Blended( public static extern IntPtr TTF_RenderGlyph_Blended(
IntPtr font, IntPtr font,
ushort ch, ushort ch,
SDL.SDL_Color fg SDL.SDL_Color fg
); );
public static SDL.SDL_Surface TTF_RenderGlyph_Blended(
IntPtr font,
ushort ch,
SDL.SDL_Color fg
) {
SDL.SDL_Surface result;
IntPtr result_ptr = INTERNAL_TTF_RenderGlyph_Blended(
font,
ch,
fg
);
result = (SDL.SDL_Surface) Marshal.PtrToStructure(
result_ptr,
result.GetType()
);
return result;
}
/* font refers to a TTF_Font* */ /* font refers to a TTF_Font* */
[DllImport(nativeLibName)] [DllImport(nativeLibName)]