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 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;
/// 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]
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
}
}
}