From c96a931ede6141e86fb4f3f33b0bf5769ec078a8 Mon Sep 17 00:00:00 2001 From: laurentgom Date: Fri, 10 Apr 2009 14:05:36 +0000 Subject: [PATCH] Added missing VideoMode functions to SFML.Net git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1073 4e206d99-4929-0410-ac5d-dfc041789085 --- dotnet/src/Window/VideoMode.cs | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/dotnet/src/Window/VideoMode.cs b/dotnet/src/Window/VideoMode.cs index 824769027..8dcced9dc 100644 --- a/dotnet/src/Window/VideoMode.cs +++ b/dotnet/src/Window/VideoMode.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using System.Security; namespace SFML { @@ -42,6 +43,51 @@ namespace SFML BitsPerPixel = bpp; } + //////////////////////////////////////////////////////////// + /// + /// Tell whether or not the video mode is supported + /// + /// True if the video mode is valid, false otherwise + //////////////////////////////////////////////////////////// + public bool IsValid() + { + return sfVideoMode_IsValid(this); + } + + //////////////////////////////////////////////////////////// + /// + /// Get the number of valid video modes + /// + //////////////////////////////////////////////////////////// + public static uint ModesCount + { + get {return sfVideoMode_GetModesCount();} + } + + //////////////////////////////////////////////////////////// + /// + /// Get a valid video mode. + /// Index must be in range [0, ModesCount[. + /// Modes are sorted from best to worst + /// + /// Index of the video mode to get + /// index-th video mode + //////////////////////////////////////////////////////////// + public static VideoMode GetMode(uint index) + { + return sfVideoMode_GetMode(index); + } + + //////////////////////////////////////////////////////////// + /// + /// Get the current desktop video mode + /// + //////////////////////////////////////////////////////////// + public static VideoMode DesktopMode + { + get {return sfVideoMode_GetDesktopMode();} + } + /// Video mode width, in pixels public uint Width; @@ -50,6 +96,20 @@ namespace SFML /// Video mode depth, in bits per pixel public uint BitsPerPixel; + + #region Imports + [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] + static extern VideoMode sfVideoMode_GetDesktopMode(); + + [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] + static extern uint sfVideoMode_GetModesCount(); + + [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] + static extern VideoMode sfVideoMode_GetMode(uint Index); + + [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] + static extern bool sfVideoMode_IsValid(VideoMode Mode); + #endregion } } }