Class DisplayDevice
Defines a display device on the underlying system, and provides methods to query and change its display parameters.
Inherited Members
Namespace: OpenTK
Assembly: OpenTK.dll
Syntax
public class DisplayDevice
Properties
AvailableResolutions
Gets the list of DisplayResolution objects available on this device.
Declaration
public IList<DisplayResolution> AvailableResolutions { get; }
Property Value
Type | Description |
---|---|
IList<DisplayResolution> |
BitsPerPixel
Gets a System.Int32 that contains number of bits per pixel of this display. Typical values include 8, 16, 24 and 32.
Declaration
public int BitsPerPixel { get; }
Property Value
Type | Description |
---|---|
Int32 |
Bounds
Gets the bounds of this instance in pixel coordinates..
Declaration
public Rectangle Bounds { get; }
Property Value
Type | Description |
---|---|
Rectangle |
Default
Gets the default (primary) display of this system.
Declaration
public static DisplayDevice Default { get; }
Property Value
Type | Description |
---|---|
DisplayDevice |
Height
Gets a System.Int32 that contains the height of this display in pixels.
Declaration
public int Height { get; }
Property Value
Type | Description |
---|---|
Int32 |
IsPrimary
Gets a System.Boolean that indicates whether this Display is the primary Display in systems with multiple Displays.
Declaration
public bool IsPrimary { get; }
Property Value
Type | Description |
---|---|
Boolean |
RefreshRate
Gets a System.Single representing the vertical refresh rate of this display.
Declaration
public float RefreshRate { get; }
Property Value
Type | Description |
---|---|
Single |
Width
Gets a System.Int32 that contains the width of this display in pixels.
Declaration
public int Width { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
ChangeResolution(DisplayResolution)
Changes the resolution of the DisplayDevice.
Declaration
public void ChangeResolution(DisplayResolution resolution)
Parameters
Type | Name | Description |
---|---|---|
DisplayResolution | resolution | The resolution to set. SelectResolution(Int32, Int32, Int32, Single) |
Remarks
If the specified resolution is null, this function will restore the original DisplayResolution.
Exceptions
Type | Condition |
---|---|
GraphicsModeException | Thrown if the requested resolution could not be set. |
ChangeResolution(Int32, Int32, Int32, Single)
Changes the resolution of the DisplayDevice.
Declaration
public void ChangeResolution(int width, int height, int bitsPerPixel, float refreshRate)
Parameters
Type | Name | Description |
---|---|---|
Int32 | width | The new width of the DisplayDevice. |
Int32 | height | The new height of the DisplayDevice. |
Int32 | bitsPerPixel | The new bits per pixel of the DisplayDevice. |
Single | refreshRate | The new refresh rate of the DisplayDevice. |
Exceptions
Type | Condition |
---|---|
GraphicsModeException | Thrown if the requested resolution could not be set. |
GetDisplay(DisplayIndex)
Gets the DisplayDevice for the specified DisplayIndex.
Declaration
public static DisplayDevice GetDisplay(DisplayIndex index)
Parameters
Type | Name | Description |
---|---|---|
DisplayIndex | index | The DisplayIndex that defines the desired display. |
Returns
Type | Description |
---|---|
DisplayDevice | A DisplayDevice or null, if no device corresponds to the specified index. |
RestoreResolution()
Restores the original resolution of the DisplayDevice.
Declaration
public void RestoreResolution()
Exceptions
Type | Condition |
---|---|
GraphicsModeException | Thrown if the original resolution could not be restored. |
SelectResolution(Int32, Int32, Int32, Single)
Selects an available resolution that matches the specified parameters.
Declaration
public DisplayResolution SelectResolution(int width, int height, int bitsPerPixel, float refreshRate)
Parameters
Type | Name | Description |
---|---|---|
Int32 | width | The width of the requested resolution in pixels. |
Int32 | height | The height of the requested resolution in pixels. |
Int32 | bitsPerPixel | The bits per pixel of the requested resolution. |
Single | refreshRate | The refresh rate of the requested resolution in hertz. |
Returns
Type | Description |
---|---|
DisplayResolution | The requested DisplayResolution or null if the parameters cannot be met. |
Remarks
If a matching resolution is not found, this function will retry ignoring the specified refresh rate, bits per pixel and resolution, in this order. If a matching resolution still doesn't exist, this function will return the current resolution.
A parameter set to 0 or negative numbers will not be used in the search (e.g. if refreshRate is 0, any refresh rate will be considered valid).
This function allocates memory.
ToString()
Returns a System.String representing this DisplayDevice.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A System.String representing this DisplayDevice. |