2009-01-28 16:18:34 +00:00
|
|
|
using System;
|
|
|
|
using System.Runtime.InteropServices;
|
2009-04-10 14:05:36 +00:00
|
|
|
using System.Security;
|
2009-01-28 16:18:34 +00:00
|
|
|
|
|
|
|
namespace SFML
|
|
|
|
{
|
|
|
|
namespace Window
|
|
|
|
{
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
|
|
|
/// VideoMode defines a video mode (width, height, bpp, frequency)
|
|
|
|
/// and provides static functions for getting modes supported
|
|
|
|
/// by the display device
|
|
|
|
/// </summary>
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
public struct VideoMode
|
|
|
|
{
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
|
|
|
/// Construct the video mode with its width and height
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="width">Video mode width</param>
|
|
|
|
/// <param name="height">Video mode height</param>
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
public VideoMode(uint width, uint height) :
|
|
|
|
this(width, height, 32)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
|
|
|
/// Construct the video mode with its width, height and depth
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="width">Video mode width</param>
|
|
|
|
/// <param name="height">Video mode height</param>
|
|
|
|
/// <param name="bpp">Video mode depth (bits per pixel)</param>
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
public VideoMode(uint width, uint height, uint bpp)
|
|
|
|
{
|
|
|
|
Width = width;
|
|
|
|
Height = height;
|
|
|
|
BitsPerPixel = bpp;
|
|
|
|
}
|
|
|
|
|
2009-04-10 14:05:36 +00:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
|
|
|
/// Tell whether or not the video mode is supported
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>True if the video mode is valid, false otherwise</returns>
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
public bool IsValid()
|
|
|
|
{
|
|
|
|
return sfVideoMode_IsValid(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
2010-03-12 14:07:28 +00:00
|
|
|
/// Get the list of all the supported fullscreen video modes
|
2009-10-12 10:24:49 +00:00
|
|
|
/// </summary>
|
2009-04-10 14:05:36 +00:00
|
|
|
////////////////////////////////////////////////////////////
|
2010-03-12 14:07:28 +00:00
|
|
|
public static VideoMode[] FullscreenModes
|
2009-04-10 14:05:36 +00:00
|
|
|
{
|
2010-03-12 14:07:28 +00:00
|
|
|
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];
|
2009-04-10 14:05:36 +00:00
|
|
|
|
2010-03-12 14:07:28 +00:00
|
|
|
return Modes;
|
|
|
|
}
|
|
|
|
}
|
2009-04-10 14:05:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
|
|
|
/// Get the current desktop video mode
|
2009-10-12 10:24:49 +00:00
|
|
|
/// </summary>
|
2009-04-10 14:05:36 +00:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
public static VideoMode DesktopMode
|
|
|
|
{
|
|
|
|
get {return sfVideoMode_GetDesktopMode();}
|
|
|
|
}
|
|
|
|
|
2010-01-06 12:37:29 +00:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// <summary>
|
|
|
|
/// Provide a string describing the object
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>String description of the object</returns>
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return "[VideoMode]" +
|
2010-01-17 10:03:46 +00:00
|
|
|
" Width(" + Width + ")" +
|
|
|
|
" Height(" + Height + ")" +
|
|
|
|
" BitsPerPixel(" + BitsPerPixel + ")";
|
2010-01-06 12:37:29 +00:00
|
|
|
}
|
|
|
|
|
2009-01-28 16:18:34 +00:00
|
|
|
/// <summary>Video mode width, in pixels</summary>
|
|
|
|
public uint Width;
|
|
|
|
|
|
|
|
/// <summary>Video mode height, in pixels</summary>
|
|
|
|
public uint Height;
|
|
|
|
|
|
|
|
/// <summary>Video mode depth, in bits per pixel</summary>
|
|
|
|
public uint BitsPerPixel;
|
2009-04-10 14:05:36 +00:00
|
|
|
|
|
|
|
#region Imports
|
|
|
|
[DllImport("csfml-window"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern VideoMode sfVideoMode_GetDesktopMode();
|
|
|
|
|
|
|
|
[DllImport("csfml-window"), SuppressUnmanagedCodeSecurity]
|
2010-03-12 14:07:28 +00:00
|
|
|
unsafe static extern VideoMode* sfVideoMode_GetFullscreenModes(out uint Count);
|
2009-04-10 14:05:36 +00:00
|
|
|
|
|
|
|
[DllImport("csfml-window"), SuppressUnmanagedCodeSecurity]
|
|
|
|
static extern bool sfVideoMode_IsValid(VideoMode Mode);
|
|
|
|
#endregion
|
2009-01-28 16:18:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|