From f154fc784be7afac2aa26685c5ea00fa78d4e64e Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Wed, 17 Apr 2013 18:38:10 -0400 Subject: [PATCH] Add compiled version info for SDL2 libs. --- src/SDL2.cs | 31 +++++++++++++++++++++++++++++++ src/SDL2_image.cs | 15 +++++++++++++++ src/SDL2_mixer.cs | 15 +++++++++++++++ src/SDL2_ttf.cs | 15 +++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/src/SDL2.cs b/src/SDL2.cs index 1700602..0246617 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -368,6 +368,20 @@ namespace SDL2 #region SDL_version.h, SDL_revision.h + /* Similar to the headers, this is the version we're expecting to be + * running with. You will likely want to check this somewhere in your + * program! + */ + public const int SDL_MAJOR_VERSION = 2; + public const int SDL_MINOR_VERSION = 0; + public const int SDL_PATCHLEVEL = 0; + + public static readonly int SDL_COMPILEDVERSION = SDL_VERSIONNUM( + SDL_MAJOR_VERSION, + SDL_MINOR_VERSION, + SDL_PATCHLEVEL + ); + [StructLayout(LayoutKind.Sequential)] public struct SDL_version { @@ -376,6 +390,23 @@ namespace SDL2 public byte patch; } + public static void SDL_VERSION(ref SDL_version x) + { + x.major = SDL_MAJOR_VERSION; + x.minor = SDL_MINOR_VERSION; + x.patch = SDL_PATCHLEVEL; + } + + public static int SDL_VERSIONNUM(int X, int Y, int Z) + { + return (X * 1000) + (Y * 100) + Z; + } + + public static bool SDL_VERSION_ATLEAST(int X, int Y, int Z) + { + return SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z); + } + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] private static extern void SDL_GetVersion(ref SDL_version ver); diff --git a/src/SDL2_image.cs b/src/SDL2_image.cs index 8ada6cc..66dbe88 100644 --- a/src/SDL2_image.cs +++ b/src/SDL2_image.cs @@ -44,6 +44,14 @@ namespace SDL2 #region SDL_image.h + /* Similar to the headers, this is the version we're expecting to be + * running with. You will likely want to check this somewhere in your + * program! + */ + public const int SDL_IMAGE_MAJOR_VERSION = 2; + public const int SDL_IMAGE_MINOR_VERSION = 0; + public const int SDL_IMAGE_PATCHLEVEL = 0; + [Flags] public enum IMG_InitFlags { @@ -53,6 +61,13 @@ namespace SDL2 IMG_INIT_WEBP = 0x00000008 } + public static void SDL_IMAGE_VERSION(ref SDL.SDL_version X) + { + X.major = SDL_IMAGE_MAJOR_VERSION; + X.minor = SDL_IMAGE_MINOR_VERSION; + X.patch = SDL_IMAGE_PATCHLEVEL; + } + [DllImport(nativeLibName, EntryPoint = "IMG_LinkedVersion", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr INTERNAL_IMG_LinkedVersion(); public static SDL.SDL_version IMG_LinkedVersion() diff --git a/src/SDL2_mixer.cs b/src/SDL2_mixer.cs index 4cee0e0..88212be 100644 --- a/src/SDL2_mixer.cs +++ b/src/SDL2_mixer.cs @@ -44,6 +44,14 @@ namespace SDL2 #region SDL_mixer.h + /* Similar to the headers, this is the version we're expecting to be + * running with. You will likely want to check this somewhere in your + * program! + */ + public const int SDL_MIXER_MAJOR_VERSION = 2; + public const int SDL_MIXER_MINOR_VERSION = 0; + public const int SDL_MIXER_PATCHLEVEL = 0; + /* In C, you can redefine this value before including SDL_mixer.h. * We're not going to allow this in SDL2#, since the value of this * variable is persistent and not dependent on preprocessor ordering. @@ -129,6 +137,13 @@ namespace SDL2 IntPtr b // void* ); + public static void SDL_MIXER_VERSION(ref SDL.SDL_version X) + { + X.major = SDL_MIXER_MAJOR_VERSION; + X.minor = SDL_MIXER_MINOR_VERSION; + X.patch = SDL_MIXER_PATCHLEVEL; + } + [DllImport(nativeLibName, EntryPoint = "MIX_Linked_Version", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr INTERNAL_MIX_Linked_Version(); public static SDL.SDL_version MIX_Linked_Version() diff --git a/src/SDL2_ttf.cs b/src/SDL2_ttf.cs index 4810617..aef59e0 100644 --- a/src/SDL2_ttf.cs +++ b/src/SDL2_ttf.cs @@ -44,6 +44,14 @@ namespace SDL2 #region SDL_ttf.h + /* Similar to the headers, this is the version we're expecting to be + * running with. You will likely want to check this somewhere in your + * program! + */ + public const int SDL_TTF_MAJOR_VERSION = 2; + public const int SDL_TTF_MINOR_VERSION = 2; + public const int SDL_TTF_PATCHLEVEL = 12; + public const int UNICODE_BOM_NATIVE = 0xFEFF; public const int UNICODE_BOM_SWAPPED = 0xFFFE; @@ -58,6 +66,13 @@ namespace SDL2 public const int TTF_HINTING_MONO = 2; public const int TTF_HINTING_NONE = 3; + public static void SDL_TTF_VERSION(ref SDL.SDL_version X) + { + X.major = SDL_TTF_MAJOR_VERSION; + X.minor = SDL_TTF_MINOR_VERSION; + X.patch = SDL_TTF_PATCHLEVEL; + } + [DllImport(nativeLibName, EntryPoint = "TTF_LinkedVersion", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr INTERNAL_TTF_LinkedVersion(); public static SDL.SDL_version TTF_LinkedVersion()