/// <summary> /// Initializes a new instance of the OpenGLUltravioletDisplay class. /// </summary> /// <param name="displayIndex">The SDL2 display index that this object represents.</param> public OpenGLUltravioletDisplay(Int32 displayIndex) { this.displayIndex = displayIndex; this.displayModes = Enumerable.Range(0, SDL.GetNumDisplayModes(displayIndex)) .Select(modeIndex => CreateDisplayModeFromSDL(displayIndex, modeIndex)) .ToList(); this.name = SDL.GetDisplayName(displayIndex); SDL_DisplayMode sdlDesktopDisplayMode; if (SDL.GetDesktopDisplayMode(displayIndex, &sdlDesktopDisplayMode) < 0) throw new SDL2Exception(); this.desktopDisplayMode = CreateDisplayModeFromSDL(sdlDesktopDisplayMode); this.screenRotationService = ScreenRotationService.Create(this); this.screenDensityService = ScreenDensityService.Create(this); }
/// <summary> /// Determines whether the specified display mode is equivalent to this display mode by comparing /// their vertical and horizontal resolutions, as well as optionally comparing their bit depths /// and refresh rates. /// </summary> /// <param name="other">The <see cref="DisplayMode"/> instance to compare to this instance.</param> /// <param name="considerBitsPerPixel">A value indicating whether to compare the bit depths of the two display modes.</param> /// <param name="considerRefreshRate">A value indicating whether to compare the refresh rates of the two display modes.</param> /// <param name="considerDisplay">A value indicating whether to compare the preferred displays of the two display modes.</param> /// <returns><see langword="true"/> if the two display modes are equivalent; otherwise, <see langword="false"/>.</returns> public Boolean IsEquivalentTo(DisplayMode other, Boolean considerBitsPerPixel = true, Boolean considerRefreshRate = true, Boolean considerDisplay = false) { if (other == null) return false; if (other == this) return true; if (other.Width != Width || other.Height != Height) return false; if (considerBitsPerPixel && other.BitsPerPixel != BitsPerPixel) return false; if (considerRefreshRate && other.RefreshRate != RefreshRate) return false; if (considerDisplay && other.DisplayIndex != DisplayIndex) return false; return true; }