using System; using System.Runtime.InteropServices; using System.Security; namespace SFML { namespace Window { //////////////////////////////////////////////////////////// /// /// VideoMode defines a video mode (width, height, bpp, frequency) /// and provides static functions for getting modes supported /// by the display device /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] public struct VideoMode { //////////////////////////////////////////////////////////// /// /// Construct the video mode with its width and height /// /// Video mode width /// Video mode height //////////////////////////////////////////////////////////// public VideoMode(uint width, uint height) : this(width, height, 32) { } //////////////////////////////////////////////////////////// /// /// Construct the video mode with its width, height and depth /// /// Video mode width /// Video mode height /// Video mode depth (bits per pixel) //////////////////////////////////////////////////////////// public VideoMode(uint width, uint height, uint bpp) { Width = width; Height = height; 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 list of all the supported fullscreen video modes /// //////////////////////////////////////////////////////////// public static VideoMode[] FullscreenModes { get { unsafe { uint Count; VideoMode* ModesPtr = sfVideoMode_GetFullscreenModes(out Count); VideoMode[] Modes = new VideoMode[Count]; for (uint i = 0; i < Count; ++i) Modes[i] = ModesPtr[i]; return Modes; } } } //////////////////////////////////////////////////////////// /// /// Get the current desktop video mode /// //////////////////////////////////////////////////////////// public static VideoMode DesktopMode { get {return sfVideoMode_GetDesktopMode();} } //////////////////////////////////////////////////////////// /// /// Provide a string describing the object /// /// String description of the object //////////////////////////////////////////////////////////// public override string ToString() { return "[VideoMode]" + " Width(" + Width + ")" + " Height(" + Height + ")" + " BitsPerPixel(" + BitsPerPixel + ")"; } /// Video mode width, in pixels public uint Width; /// Video mode height, in pixels public uint Height; /// 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] unsafe static extern VideoMode* sfVideoMode_GetFullscreenModes(out uint Count); [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] static extern bool sfVideoMode_IsValid(VideoMode Mode); #endregion } } }