From 796e0b9e54a49037bdde3a4e1df6c29d43ddc988 Mon Sep 17 00:00:00 2001 From: Justin Skiles Date: Mon, 26 Aug 2013 18:44:39 -0400 Subject: [PATCH 1/2] Added overload to SDL_RenderCopy method to allow SourceRectangle to be passed as an IntPtr. This allows developers to pass IntPtr.Zero to take advantage of internal SDL default values for null rectangles. --- src/SDL2.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/SDL2.cs b/src/SDL2.cs index 5bf3ba8..3a990aa 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -1246,6 +1246,15 @@ namespace SDL2 ref SDL_Rect srcrect, ref SDL_Rect dstrect ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopy( + IntPtr renderer, + IntPtr texture, + IntPtr srcrect, + ref SDL_Rect dstrect + ); /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] From ad6e7a7fa84d39406d476993a417affdad98281e Mon Sep 17 00:00:00 2001 From: Justin Skiles Date: Mon, 26 Aug 2013 20:16:51 -0400 Subject: [PATCH 2/2] Added all source/destination null parameter overload variations for RenderCopy. Added function comments to explain their use. Fixed inconsistent tabbing. --- src/SDL2.cs | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index 3a990aa..86032a8 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -1247,15 +1247,42 @@ namespace SDL2 ref SDL_Rect dstrect ); - /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */ - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int SDL_RenderCopy( - IntPtr renderer, - IntPtr texture, - IntPtr srcrect, - ref SDL_Rect dstrect - ); - + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */ + /* internally, this function contains logic to use default values when source + and destination rectangles are passed as NULL */ + /* this overload allows for IntPtr.Zero (null) to be passed for source rectangle */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopy( + IntPtr renderer, + IntPtr texture, + IntPtr srcrect, + ref SDL_Rect dstrect + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */ + /* internally, this function contains logic to use default values when source + and destination rectangles are passed as NULL */ + /* this overload allows for IntPtr.Zero (null) to be passed for destination rectangle */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopy( + IntPtr renderer, + IntPtr texture, + ref SDL_Rect srcrect, + IntPtr dstrect + ); + + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */ + /* internally, this function contains logic to use default values when source + and destination rectangles are passed as NULL */ + /* this overload allows for IntPtr.Zero (null) to be passed for both rectangles */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderCopy( + IntPtr renderer, + IntPtr texture, + IntPtr srcrect, + IntPtr dstrect + ); + /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int SDL_RenderCopyEx(