OpenTK.DisplayDevice Class Reference

Defines a display device on the underlying system, and provides methods to query and change its display parameters. More...

List of all members.

Public Member Functions

DisplayResolution SelectResolution (int width, int height, int bitsPerPixel, float refreshRate)
 Selects an available resolution that matches the specified parameters.
void ChangeResolution (DisplayResolution resolution)
 Changes the resolution of the DisplayDevice.
void ChangeResolution (int width, int height, int bitsPerPixel, float refreshRate)
 Changes the resolution of the DisplayDevice.
void RestoreResolution ()
 Restores the original resolution of the DisplayDevice.
override string ToString ()
 Returns a System.String representing this DisplayDevice.

Properties

Rectangle Bounds [get, set]
 Gets the bounds of this instance in pixel coordinates..
int Width [get]
 Gets a System.Int32 that contains the width of this display in pixels.
int Height [get]
 Gets a System.Int32 that contains the height of this display in pixels.
int BitsPerPixel [get, set]
 Gets a System.Int32 that contains number of bits per pixel of this display. Typical values include 8, 16, 24 and 32.
float RefreshRate [get, set]
 Gets a System.Single representing the vertical refresh rate of this display.
bool IsPrimary [get, set]
 Gets a System.Boolean that indicates whether this Display is the primary Display in systems with multiple Displays.
IList< DisplayResolutionAvailableResolutions [get, set]
 Gets the list of DisplayResolution objects available on this device.
static IList< DisplayDeviceAvailableDisplays [get]
 Gets the list of available DisplayDevice objects.
static DisplayDevice Default [get]
 Gets the default (primary) display of this system.

Detailed Description

Defines a display device on the underlying system, and provides methods to query and change its display parameters.

Definition at line 22 of file DisplayDevice.cs.


Member Function Documentation

void OpenTK.DisplayDevice.ChangeResolution ( int  width,
int  height,
int  bitsPerPixel,
float  refreshRate 
)

Changes the resolution of the DisplayDevice.

Parameters:
width The new width of the DisplayDevice.
height The new height of the DisplayDevice.
bitsPerPixel The new bits per pixel of the DisplayDevice.
refreshRate The new refresh rate of the DisplayDevice.
Exceptions:
Graphics.GraphicsModeException Thrown if the requested resolution could not be set.

Definition at line 249 of file DisplayDevice.cs.

00250         {
00251             this.ChangeResolution(this.SelectResolution(width, height, bitsPerPixel, refreshRate));
00252         }

void OpenTK.DisplayDevice.ChangeResolution ( DisplayResolution  resolution  ) 

Changes the resolution of the DisplayDevice.

Parameters:
resolution The resolution to set. DisplayDevice.SelectResolution
Exceptions:
Graphics.GraphicsModeException Thrown if the requested resolution could not be set.

If the specified resolution is null, this function will restore the original DisplayResolution.

Definition at line 217 of file DisplayDevice.cs.

00218         {
00219             if (resolution == null)
00220                 this.RestoreResolution();
00221 
00222             if (resolution == current_resolution)
00223                 return;
00224 
00225             //effect.FadeOut();
00226 
00227             if (implementation.TryChangeResolution(this, resolution))
00228             {
00229                 if (original_resolution == null)
00230                     original_resolution = current_resolution;
00231                 current_resolution = resolution;
00232             }
00233             else throw new Graphics.GraphicsModeException(String.Format("Device {0}: Failed to change resolution to {1}.",
00234                     this, resolution));
00235 
00236             //effect.FadeIn();
00237         }

void OpenTK.DisplayDevice.RestoreResolution (  ) 

Restores the original resolution of the DisplayDevice.

Exceptions:
Graphics.GraphicsModeException Thrown if the original resolution could not be restored.

Definition at line 260 of file DisplayDevice.cs.

00261         {
00262             if (original_resolution != null)
00263             {
00264                 //effect.FadeOut();
00265 
00266                 if (implementation.TryRestoreResolution(this))
00267                 {
00268                     current_resolution = original_resolution;
00269                     original_resolution = null;
00270                 }
00271                 else throw new Graphics.GraphicsModeException(String.Format("Device {0}: Failed to restore resolution.", this));
00272 
00273                 //effect.FadeIn();
00274             }
00275         }

DisplayResolution OpenTK.DisplayDevice.SelectResolution ( int  width,
int  height,
int  bitsPerPixel,
float  refreshRate 
)

Selects an available resolution that matches the specified parameters.

Parameters:
width The width of the requested resolution in pixels.
height The height of the requested resolution in pixels.
bitsPerPixel The bits per pixel of the requested resolution.
refreshRate The refresh rate of the requested resolution in hertz.
Returns:
The requested DisplayResolution or null if the parameters cannot be met.

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.

Definition at line 180 of file DisplayDevice.cs.

00181         {
00182             DisplayResolution resolution = FindResolution(width, height, bitsPerPixel, refreshRate);
00183             if (resolution == null)
00184                 resolution = FindResolution(width, height, bitsPerPixel, 0);
00185             if (resolution == null)
00186                 resolution = FindResolution(width, height, 0, 0);
00187             if (resolution == null)
00188                 return current_resolution;
00189             return resolution;
00190         }

override string OpenTK.DisplayDevice.ToString (  ) 

Returns a System.String representing this DisplayDevice.

Returns:
A System.String representing this DisplayDevice.

Definition at line 328 of file DisplayDevice.cs.

00329         {
00330             return String.Format("{0}: {1} ({2} modes available)", IsPrimary ? "Primary" : "Secondary",
00331                 Bounds.ToString(), available_resolutions.Count);
00332         }


Property Documentation

IList<DisplayDevice> OpenTK.DisplayDevice.AvailableDisplays [static, get]

Gets the list of available DisplayDevice objects.

Definition at line 285 of file DisplayDevice.cs.

IList<DisplayResolution> OpenTK.DisplayDevice.AvailableResolutions [get, set]

Gets the list of DisplayResolution objects available on this device.

Definition at line 200 of file DisplayDevice.cs.

int OpenTK.DisplayDevice.BitsPerPixel [get, set]

Gets a System.Int32 that contains number of bits per pixel of this display. Typical values include 8, 16, 24 and 32.

Definition at line 120 of file DisplayDevice.cs.

Rectangle OpenTK.DisplayDevice.Bounds [get, set]

Gets the bounds of this instance in pixel coordinates..

Definition at line 90 of file DisplayDevice.cs.

DisplayDevice OpenTK.DisplayDevice.Default [static, get]

Gets the default (primary) display of this system.

Definition at line 294 of file DisplayDevice.cs.

int OpenTK.DisplayDevice.Height [get]

Gets a System.Int32 that contains the height of this display in pixels.

Definition at line 112 of file DisplayDevice.cs.

bool OpenTK.DisplayDevice.IsPrimary [get, set]

Gets a System.Boolean that indicates whether this Display is the primary Display in systems with multiple Displays.

Definition at line 144 of file DisplayDevice.cs.

float OpenTK.DisplayDevice.RefreshRate [get, set]

Gets a System.Single representing the vertical refresh rate of this display.

Definition at line 133 of file DisplayDevice.cs.

int OpenTK.DisplayDevice.Width [get]

Gets a System.Int32 that contains the width of this display in pixels.

Definition at line 105 of file DisplayDevice.cs.

 All Classes Functions Variables Enumerations Properties Events

Generated on Tue Mar 9 14:59:12 2010 for The Open Toolkit library by  doxygen 1.6.1