internal unsafe DisplayMode(SDL_DisplayMode mode) : this((PixelDataFormat)mode.format, mode.w, mode.h, mode.refresh_rate, (IntPtr)mode.driverdata) { }
/// <summary> /// Creates an Ultraviolet DisplayMode object from the specified SDL2 display mode. /// </summary> private DisplayMode CreateDisplayModeFromSDL(SDL_DisplayMode mode) { Int32 bpp; UInt32 Rmask, Gmask, Bmask, Amask; SDL.PixelFormatEnumToMasks((uint)mode.format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); return(new DisplayMode(mode.w, mode.h, bpp, mode.refresh_rate, Index)); }
internal static DisplayMode GetDesktop(int displayIndex) { var modeData = new SDL_DisplayMode(); Try(() => SDL_GetDesktopDisplayMode(displayIndex, ref modeData), "SDL_GetDesktopDisplayMode"); var result = new DisplayMode() { _mode = modeData, displayIndex = displayIndex, }; result.modeIndex = DisplayMode .GetAvailable(displayIndex) .IndexOf(result); return(result); }
internal static List <DisplayMode> GetAvailable(int displayIndex) { var result = new List <DisplayMode>(); var numModes = TryGet(() => SDL_GetNumDisplayModes(displayIndex), "SDL_GetNumDisplayModes"); for (var modeIndex = 0; modeIndex < numModes; modeIndex++) { var modeData = new SDL_DisplayMode(); SDL_GetDisplayMode(displayIndex, modeIndex, ref modeData); result.Add(new DisplayMode() { _mode = modeData, displayIndex = displayIndex, modeIndex = modeIndex }); } return(result); }
static void Main(string[] args) { var width = 640; var height = 480; if (SDL_Init(SDL_INIT_VIDEO) != 0) { throw new Exception($"Could not init SDL: {SDL_GetError()}"); } var result = SDL_CreateWindowAndRenderer(width, height, (uint)(SDL_WindowFlags.SDL_WINDOW_SHOWN | SDL_WindowFlags.SDL_WINDOW_OPENGL), out IntPtr window, out IntPtr renderer); if (result != 0) { throw new Exception($"Could not initialize window: {SDL_GetError()}"); } SDL_GetVersion(out SDL_Version version); WriteLine($"Using SDL {version.major}.{version.minor}.{version.patch}"); var displayCount = SDL_GetNumVideoDisplays(); for (int display = 0; display < displayCount; display++) { var numModes = SDL_GetNumDisplayModes(display); WriteLine($"Display {display} - {numModes} modes:"); for (int mode = 0; mode < numModes; mode++) { var modeInfo = new SDL_DisplayMode(); if (SDL_GetDisplayMode(display, mode, ref modeInfo) != 0) { throw new Exception($"Could not get display mode info: {SDL_GetError()}"); } WriteLine("\t" + modeInfo); } } SDL_Quit(); }
public static void SDL_GetCurrentDisplayMode(int i, out SDL_DisplayMode sdlDisplayMode) { sdlDisplayMode = new SDL_DisplayMode(); }
public static int SDL_GetWindowDisplayMode(IntPtr window, ref SDL_DisplayMode mode) => s_SDL_GetWindowDisplayMode_IntPtr_SDL_DisplayMode_t(window, ref mode);
public static int SDL_GetCurrentDisplayMode(int displayIndex, ref SDL_DisplayMode mode) => s_SDL_GetCurrentDisplayMode_int_SDL_DisplayMode_t(displayIndex, ref mode);
public static IntPtr SDL_GetClosestDisplayMode(int displayIndex, ref SDL_DisplayMode mode, ref SDL_DisplayMode closest) => s_SDL_GetClosestDisplayMode_int_SDL_DisplayMode_SDL_DisplayMode_t(displayIndex, ref mode, ref closest);
public static int SDL_GetDesktopDisplayMode(int displayIndex, ref SDL_DisplayMode mode) => s_SDL_GetDesktopDisplayMode_int_SDL_DisplayMode_t(displayIndex, ref mode);
public static int SDL_GetDisplayMode(int displayIndex, int modeIndex, ref SDL_DisplayMode mode) => s_SDL_GetDisplayMode_int_int_SDL_DisplayMode_t(displayIndex, modeIndex, ref mode);
public static extern int SDL_SetWindowDisplayMode( IntPtr window, ref SDL_DisplayMode mode );
public static extern int SDL_GetDisplayMode( int displayIndex, int modeIndex, ref SDL_DisplayMode mode );
public static extern IntPtr SDL_GetClosestDisplayMode( int displayIndex, ref SDL_DisplayMode mode, ref SDL_DisplayMode closest );