/
EugenyCh7
/
Puppet2D.Net
Обзор
Документация
Войти
/
EugenyCh7
/
Puppet2D.Net
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Puppet2D.Window/VideoMode.cs
110 строк
4 KB
EugenyCh7
comments fix
24 июл 2025, 22:54
24 июл 2025, 22:54
421ed1f
Код
Авторство
О чём код?
using System; using System.Runtime.InteropServices; using System.Security; using Puppet2D.System; namespace Puppet2D.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; } /// <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> /// Get the list of all the supported fullscreen video modes /// </summary> public static VideoMode[] FullscreenModes { get { unsafe { UIntPtr Count; VideoMode* ModesPtr = sfVideoMode_getFullscreenModes(out Count); VideoMode[] Modes = new VideoMode[(int)Count]; for (int i = 0; i < (int)Count; ++i) { Modes[i] = ModesPtr[i]; } return Modes; } } } /// <summary> /// Get the current desktop video mode /// </summary> public static VideoMode DesktopMode { get { return sfVideoMode_getDesktopMode(); } } /// <summary> /// Provide a string describing the object /// </summary> /// <returns>String description of the object</returns> public override string ToString() { return "[VideoMode]" + " Width(" + Width + ")" + " Height(" + Height + ")" + " BitsPerPixel(" + BitsPerPixel + ")"; } /// <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; #region Imports [DllImport(CSFML.window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] private static extern VideoMode sfVideoMode_getDesktopMode(); [DllImport(CSFML.window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] private unsafe static extern VideoMode* sfVideoMode_getFullscreenModes(out UIntPtr Count); [DllImport(CSFML.window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] private static extern bool sfVideoMode_isValid(VideoMode Mode); #endregion } }