Renamed GraphicsFormat to GraphicsMode.

This commit is contained in:
the_fiddler 2008-02-28 15:28:40 +00:00
parent 09081803e4
commit c89abaee72
13 changed files with 35 additions and 298 deletions

View file

@ -186,7 +186,7 @@ namespace OpenTK
/// <summary> /// <summary>
/// Gets a System.Boolean indicating whether this DisplayMode is stereoscopic. /// Gets a System.Boolean indicating whether this DisplayMode is stereoscopic.
/// </summary> /// </summary>
[Obsolete("Use GraphicsFormat.Stereo instead.")] [Obsolete("Use GraphicsMode.Stereo instead.")]
public bool Stereo public bool Stereo
{ {
get { return this.stereo; } get { return this.stereo; }
@ -201,7 +201,7 @@ namespace OpenTK
/// Gets a System.Int32 containing the number of buffers associated with this /// Gets a System.Int32 containing the number of buffers associated with this
/// DisplayMode. /// DisplayMode.
/// </summary> /// </summary>
[Obsolete("Use GraphicsFormat.Buffers instead.")] [Obsolete("Use GraphicsMode.Buffers instead.")]
public int Buffers public int Buffers
{ {
get { return this.buffers; } get { return this.buffers; }
@ -233,7 +233,7 @@ namespace OpenTK
#region public ColorDepth Color #region public ColorDepth Color
[Obsolete("Use GraphicsFormat.Color instead.")] [Obsolete("Use GraphicsMode.Color instead.")]
public ColorMode Color public ColorMode Color
{ {
get { return this.color_format; } get { return this.color_format; }
@ -282,21 +282,21 @@ namespace OpenTK
#endregion #endregion
[Obsolete("Use GraphicsFormat.Depth instead.")] [Obsolete("Use GraphicsMode.Depth instead.")]
public int DepthBits public int DepthBits
{ {
get { return this.depthBits; } get { return this.depthBits; }
internal set { this.depthBits = value; } internal set { this.depthBits = value; }
} }
[Obsolete("Use GraphicsFormat.Stencil instead.")] [Obsolete("Use GraphicsMode.Stencil instead.")]
public int StencilBits public int StencilBits
{ {
get { return this.stencilBits; } get { return this.stencilBits; }
internal set { this.stencilBits = value; } internal set { this.stencilBits = value; }
} }
[Obsolete("Use GraphicsFormat.AuxilliaryColorFormat instead.")] [Obsolete("Use GraphicsMode.AuxilliaryColorFormat instead.")]
public int AuxBits public int AuxBits
{ {
get { return this.auxilliary_color_format.BitsPerPixel; } get { return this.auxilliary_color_format.BitsPerPixel; }
@ -307,7 +307,7 @@ namespace OpenTK
#endregion #endregion
internal GraphicsMode ToGraphicsFormat() internal GraphicsMode ToGraphicsMode()
{ {
return new GraphicsMode(this.Color.BitsPerPixel, this.DepthBits, this.StencilBits, 0, this.AuxBits, this.Buffers, this.Stereo); return new GraphicsMode(this.Color.BitsPerPixel, this.DepthBits, this.StencilBits, 0, this.AuxBits, this.Buffers, this.Stereo);
} }

View file

@ -40,7 +40,7 @@ namespace OpenTK
/// </summary> /// </summary>
/// <param name="mode"></param> /// <param name="mode"></param>
public GLControl(DisplayMode mode) public GLControl(DisplayMode mode)
: this(mode.ToGraphicsFormat()) : this(mode.ToGraphicsMode())
{ } { }
public GLControl(GraphicsMode format) public GLControl(GraphicsMode format)
@ -213,17 +213,17 @@ namespace OpenTK
#endregion #endregion
#region public GraphicsFormat GraphicsFormat #region public GraphicsMode GraphicsMode
/// <summary> /// <summary>
/// Gets the GraphicsFormat of the GraphicsContext attached to this GLControl. /// Gets the GraphicsMode of the GraphicsContext attached to this GLControl.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// To change the GraphicsFormat, you must destroy and recreate the GLControl. /// To change the GraphicsMode, you must destroy and recreate the GLControl.
/// </remarks> /// </remarks>
public GraphicsMode GraphicsFormat public GraphicsMode GraphicsMode
{ {
get { return (Context as IGLContextInternal).GraphicsFormat; } get { return (Context as IGLContextInternal).GraphicsMode; }
} }
#endregion #endregion

View file

@ -156,7 +156,7 @@ namespace OpenTK
public GameWindow(DisplayMode mode) public GameWindow(DisplayMode mode)
: this("OpenTK Game Window", mode.Width, mode.Height, : this("OpenTK Game Window", mode.Width, mode.Height,
mode.Fullscreen ? DisplayDevice.PrimaryDisplay.SelectResolution( mode.Fullscreen ? DisplayDevice.PrimaryDisplay.SelectResolution(
mode.Width, mode.Height, mode.Color.BitsPerPixel, 0) : null, mode.ToGraphicsFormat()) { } mode.Width, mode.Height, mode.Color.BitsPerPixel, 0) : null, mode.ToGraphicsMode()) { }
/// <summary> /// <summary>
/// Constructs a new GameWindow with the specified title, and opens a render window with the /// Constructs a new GameWindow with the specified title, and opens a render window with the
@ -166,7 +166,7 @@ namespace OpenTK
/// <param name="title">The Title of the GameWindow.</param> /// <param name="title">The Title of the GameWindow.</param>
[Obsolete] [Obsolete]
public GameWindow(DisplayMode mode, string title) public GameWindow(DisplayMode mode, string title)
: this(title, mode.Width, mode.Height, mode.ToGraphicsFormat()) : this(title, mode.Width, mode.Height, mode.ToGraphicsMode())
{ {
} }

View file

@ -12,7 +12,7 @@ using System.Text;
namespace OpenTK.Graphics namespace OpenTK.Graphics
{ {
/// <summary>Defines the ColorDepth component of a GraphicsFormat.</summary> /// <summary>Defines the ColorDepth component of a GraphicsMode.</summary>
/// <remarks> /// <remarks>
/// <para>A ColorDepth contains Red, Green, Blue and Alpha components that descibe /// <para>A ColorDepth contains Red, Green, Blue and Alpha components that descibe
/// the allocated bits per pixel for the corresponding color.</para> /// the allocated bits per pixel for the corresponding color.</para>

View file

@ -36,7 +36,7 @@ namespace OpenTK.Graphics
/// <param name="mode"></param> /// <param name="mode"></param>
/// <param name="window"></param> /// <param name="window"></param>
public GraphicsContext(DisplayMode mode, IWindowInfo window) public GraphicsContext(DisplayMode mode, IWindowInfo window)
: this(mode.ToGraphicsFormat(), window) : this(mode.ToGraphicsMode(), window)
{ } { }
public GraphicsContext(GraphicsMode format, IWindowInfo window) public GraphicsContext(GraphicsMode format, IWindowInfo window)
@ -247,9 +247,9 @@ namespace OpenTK.Graphics
/// <summary> /// <summary>
/// Gets the DisplayMode of the context. /// Gets the DisplayMode of the context.
/// </summary> /// </summary>
GraphicsMode IGLContextInternal.GraphicsFormat GraphicsMode IGLContextInternal.GraphicsMode
{ {
get { return (implementation as IGLContextInternal).GraphicsFormat; } get { return (implementation as IGLContextInternal).GraphicsMode; }
} }
///// <summary> ///// <summary>

View file

@ -1,263 +0,0 @@
#region --- License ---
/* Licensed under the MIT/X11 license.
* Copyright (c) 2006-2008 the OpenTK Team.
* This notice may not be removed from any source distribution.
* See license.txt for licensing detailed licensing details.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.Graphics
{
/// <summary>Defines the format for graphics operations.</summary>
public class GraphicsMode
{
ColorDepth color_format, accumulator_format;
int depth, stencil, buffers, samples;
bool stereo;
#region --- Constructors ---
#region internal GraphicsFormat(GraphicsFormat mode)
/// <internal />
/// <summary>Constructs a new GraphicsFormat from the given GraphicsFormat.</summary>
/// <param name="mode"></param>
internal GraphicsMode(GraphicsMode mode)
: this(mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples, mode.AccumulatorFormat, mode.Buffers, mode.Stereo) { }
#endregion
#region public GraphicsFormat()
/// <summary>Constructs a new GraphicsFormat with sensible default parameters.</summary>
public GraphicsMode()
: this(Default)
{ }
#endregion
#region public GraphicsFormat(ColorFormat color)
/// <summary>Constructs a new GraphicsFormat with the specified parameters.</summary>
/// <param name="color">The ColorFormat of the color buffer.</param>
public GraphicsMode(ColorDepth color)
: this(color, Default.Depth, Default.Stencil, Default.Samples, Default.AccumulatorFormat, Default.Buffers, Default.Stereo)
{ }
#endregion
#region public GraphicsFormat(ColorFormat color, int depth)
/// <summary>Constructs a new GraphicsFormat with the specified parameters.</summary>
/// <param name="color">The ColorFormat of the color buffer.</param>
/// <param name="depth">The number of bits in the depth buffer.</param>
public GraphicsMode(ColorDepth color, int depth)
: this(color, depth, Default.Stencil, Default.Samples, Default.AccumulatorFormat, Default.Buffers, Default.Stereo)
{ }
#endregion
#region public GraphicsFormat(ColorFormat color, int depth, int stencil)
/// <summary>Constructs a new GraphicsFormat with the specified parameters.</summary>
/// <param name="color">The ColorFormat of the color buffer.</param>
/// <param name="depth">The number of bits in the depth buffer.</param>
/// <param name="stencil">The number of bits in the stencil buffer.</param>
public GraphicsMode(ColorDepth color, int depth, int stencil)
: this(color, depth, stencil, Default.Samples, Default.AccumulatorFormat, Default.Buffers, Default.Stereo)
{ }
#endregion
#region public GraphicsFormat(ColorFormat color, int depth, int stencil, int samples)
/// <summary>Constructs a new GraphicsFormat with the specified parameters.</summary>
/// <param name="color">The ColorFormat of the color buffer.</param>
/// <param name="depth">The number of bits in the depth buffer.</param>
/// <param name="stencil">The number of bits in the stencil buffer.</param>
/// <param name="samples">The number of samples for FSAA.</param>
public GraphicsMode(ColorDepth color, int depth, int stencil, int samples)
: this(color, depth, stencil, samples, Default.AccumulatorFormat, Default.Buffers, Default.Stereo)
{ }
#endregion
#region public GraphicsFormat(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum)
/// <summary>Constructs a new GraphicsFormat with the specified parameters.</summary>
/// <param name="color">The ColorFormat of the color buffer.</param>
/// <param name="depth">The number of bits in the depth buffer.</param>
/// <param name="stencil">The number of bits in the stencil buffer.</param>
/// <param name="samples">The number of samples for FSAA.</param>
/// <param name="accum">The ColorFormat of the accumilliary buffer.</param>
public GraphicsMode(ColorDepth color, int depth, int stencil, int samples, ColorDepth accum)
: this(color, depth, stencil, samples, accum, Default.Buffers, Default.Stereo)
{ }
#endregion
#region public GraphicsFormat(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers)
/// <summary>Constructs a new GraphicsFormat with the specified parameters.</summary>
/// <param name="color">The ColorFormat of the color buffer.</param>
/// <param name="depth">The number of bits in the depth buffer.</param>
/// <param name="stencil">The number of bits in the stencil buffer.</param>
/// <param name="samples">The number of samples for FSAA.</param>
/// <param name="accum">The ColorFormat of the accumilliary buffer.</param>
/// <param name="buffers">The number of render buffers. Typical values include one (single-), two (double-) or three (triple-buffering).</param>
public GraphicsMode(ColorDepth color, int depth, int stencil, int samples, ColorDepth accum, int buffers)
: this(color, depth, stencil, samples, accum, buffers, Default.Stereo)
{ }
#endregion
#region public GraphicsFormat(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo)
/// <summary>Constructs a new GraphicsFormat with the specified parameters.</summary>
/// <param name="color">The ColorFormat of the color buffer.</param>
/// <param name="depth">The number of bits in the depth buffer.</param>
/// <param name="stencil">The number of bits in the stencil buffer.</param>
/// <param name="samples">The number of samples for FSAA.</param>
/// <param name="accum">The ColorFormat of the accumilliary buffer.</param>
/// <param name="stereo">Set to true for a GraphicsFormat with stereographic capabilities.</param>
/// <param name="buffers">The number of render buffers. Typical values include one (single-), two (double-) or three (triple-buffering).</param>
public GraphicsMode(ColorDepth color, int depth, int stencil, int samples, ColorDepth accum, int buffers, bool stereo)
{
if (depth < 0) throw new ArgumentOutOfRangeException("depth", "Must be greater than, or equal to zero.");
if (stencil < 0) throw new ArgumentOutOfRangeException("stencil", "Must be greater than, or equal to zero.");
if (buffers <= 0) throw new ArgumentOutOfRangeException("buffers", "Must be greater than zero.");
if (samples < 0) throw new ArgumentOutOfRangeException("samples", "Must be greater than, or equal to zero.");
this.ColorFormat = color;
this.Depth = depth;
this.Stencil = stencil;
this.AccumulatorFormat = accum;
this.Buffers = buffers;
this.Stereo = stereo;
}
#endregion
#endregion
#region --- Public Methods ---
#region public int ColorFormat
/// <summary>
/// Gets an OpenTK.Graphics.ColorFormat that describes the color format for this GraphicsFormat.
/// </summary>
public ColorDepth ColorFormat
{
get { return color_format; }
private set { color_format = value; }
}
#endregion
#region public int AccumulatorFormat
/// <summary>
/// Gets an OpenTK.Graphics.ColorFormat that describes the accumulator format for this GraphicsFormat.
/// </summary>
public ColorDepth AccumulatorFormat
{
get { return accumulator_format; }
private set { accumulator_format = value; }
}
#endregion
#region public int Depth
/// <summary>
/// Gets a System.Int32 that contains the bits per pixel for the depth buffer
/// for this GraphicsFormat.
/// </summary>
public int Depth
{
get { return depth; }
private set { depth = value; }
}
#endregion
#region public int Stencil
/// <summary>
/// Gets a System.Int32 that contains the bits per pixel for the stencil buffer
/// of this GraphicsFormat.
/// </summary>
public int Stencil
{
get { return stencil; }
private set { stencil = value; }
}
#endregion
/// <summary>
/// Gets a System.Int32 that contains the number of FSAA samples per pixel for this GraphicsFormat.
/// </summary>
public int Samples
{
get { return samples; }
private set { samples = value; }
}
#region public bool Stereo
/// <summary>
/// Gets a System.Boolean indicating whether this DisplayMode is stereoscopic.
/// </summary>
public bool Stereo
{
get { return this.stereo; }
private set { this.stereo = value; }
}
#endregion
#region public int Buffers
/// <summary>
/// Gets a System.Int32 containing the number of buffers associated with this
/// DisplayMode.
/// </summary>
public int Buffers
{
get { return this.buffers; }
private set { this.buffers = value; }
}
#endregion
#region public static GraphicsFormat Default
/// <summary>Returns an OpenTK.GraphicsFormat compatible with the underlying platform.</summary>
public static GraphicsMode Default
{
get { return new GraphicsMode(DisplayDevice.PrimaryDisplay.BitsPerPixel, 16, 0, 0, 0, 2, false); }
}
#endregion
#endregion
#region --- Overrides ---
/// <summary>Returns a System.String describing the current GraphicsFormat.</summary>
/// <returns>! System.String describing the current GraphicsFormat.</returns>
public override string ToString()
{
return String.Format("Color: {0}, Depth: {1}, Stencil: {2}, Samples: {3}, Accum: {4}, Buffers: {5}, Stereo: {6}",
ColorFormat, Depth, Stereo, Samples, AccumulatorFormat, Buffers, Stereo);
}
#endregion
}
}

View file

@ -78,8 +78,8 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
IWindowInfo Info { get; } IWindowInfo Info { get; }
/// <summary>Gets the GraphicsFormat of the context.</summary> /// <summary>Gets the GraphicsMode of the context.</summary>
GraphicsMode GraphicsFormat { get; } GraphicsMode GraphicsMode { get; }
///// <summary> ///// <summary>
///// Gets a System.IntPtr containing the handle to the OpenGL context which is current in the ///// Gets a System.IntPtr containing the handle to the OpenGL context which is current in the

View file

@ -29,7 +29,7 @@ namespace OpenTK.Platform
#region --- IGraphicsContext Members --- #region --- IGraphicsContext Members ---
public IntPtr Context { get { return IntPtr.Zero; } } public IntPtr Context { get { return IntPtr.Zero; } }
public GraphicsMode GraphicsFormat { get { return format; } } public GraphicsMode GraphicsMode { get { return format; } }
public void CreateContext() { } public void CreateContext() { }
public void CreateContext(bool direct) { } public void CreateContext(bool direct) { }

View file

@ -21,7 +21,7 @@ namespace OpenTK.Platform
internal interface INativeGLWindow : IResizable, IDisposable internal interface INativeGLWindow : IResizable, IDisposable
{ {
//void CreateWindow(int width, int height, DisplayMode mode, out IGraphicsContext context); //void CreateWindow(int width, int height, DisplayMode mode, out IGraphicsContext context);
void CreateWindow(int width, int height);//, GraphicsFormat mode, out IGraphicsContext context); void CreateWindow(int width, int height);//, GraphicsMode mode, out IGraphicsContext context);
void DestroyWindow(); void DestroyWindow();
void ProcessEvents(); void ProcessEvents();
void PointToClient(ref System.Drawing.Point p); void PointToClient(ref System.Drawing.Point p);

View file

@ -78,7 +78,7 @@ namespace OpenTK.Platform.Windows
throw new ArgumentException("window", "Must be a valid window."); throw new ArgumentException("window", "Must be a valid window.");
Debug.Print("Setting pixel format..."); Debug.Print("Setting pixel format...");
this.format = this.SetGraphicsFormatPFD(format); this.format = this.SetGraphicsModePFD(format);
Debug.Write("Creating render context... "); Debug.Write("Creating render context... ");
// Do not rely on OpenTK.Platform.Windows.Wgl - the context is not ready yet, // Do not rely on OpenTK.Platform.Windows.Wgl - the context is not ready yet,
@ -220,9 +220,9 @@ namespace OpenTK.Platform.Windows
#endregion #endregion
#region GraphicsFormat IGLContextInternal.GraphicsFormat #region GraphicsMode IGLContextInternal.GraphicsMode
GraphicsMode IGLContextInternal.GraphicsFormat GraphicsMode IGLContextInternal.GraphicsMode
{ {
get { return format; } get { return format; }
} }
@ -269,9 +269,9 @@ namespace OpenTK.Platform.Windows
#region --- Private Methods --- #region --- Private Methods ---
#region GraphicsFormat SetGraphicsFormatPFD(GraphicsFormat format) #region GraphicsMode SetGraphicsModePFD(GraphicsMode format)
GraphicsMode SetGraphicsFormatPFD(GraphicsMode format) GraphicsMode SetGraphicsModePFD(GraphicsMode format)
{ {
deviceContext = Functions.GetDC(this.windowInfo.Handle); deviceContext = Functions.GetDC(this.windowInfo.Handle);
Debug.WriteLine(String.Format("Device context: {0}", deviceContext)); Debug.WriteLine(String.Format("Device context: {0}", deviceContext));
@ -327,7 +327,7 @@ namespace OpenTK.Platform.Windows
(pfd.Flags & PixelFormatDescriptorFlags.STEREO) != 0); (pfd.Flags & PixelFormatDescriptorFlags.STEREO) != 0);
if (!Functions.SetPixelFormat(deviceContext, pixel, ref pixelFormat)) if (!Functions.SetPixelFormat(deviceContext, pixel, ref pixelFormat))
throw new GraphicsContextException(String.Format("Requested GraphicsFormat not available. SetPixelFormat error: {0}", throw new GraphicsContextException(String.Format("Requested GraphicsMode not available. SetPixelFormat error: {0}",
Marshal.GetLastWin32Error())); Marshal.GetLastWin32Error()));
Debug.Print("done! (format: {0})", pixel); Debug.Print("done! (format: {0})", pixel);
@ -336,9 +336,9 @@ namespace OpenTK.Platform.Windows
#endregion #endregion
#region GraphicsFormat SetGraphicsFormatARB(GraphicsFormat format) #region GraphicsMode SetGraphicsModeARB(GraphicsMode format)
GraphicsMode SetGraphicsFormatARB(GraphicsMode format) GraphicsMode SetGraphicsModeARB(GraphicsMode format)
{ {
return null; return null;
} }

View file

@ -322,11 +322,11 @@ namespace OpenTK.Platform.Windows
#region public void CreateWindow(int width, int height) #region public void CreateWindow(int width, int height)
public void CreateWindow(int width, int height)//, GraphicsFormat format, out IGraphicsContext context) public void CreateWindow(int width, int height)//, GraphicsMode format, out IGraphicsContext context)
{ {
Debug.Print("Creating native window."); Debug.Print("Creating native window.");
Debug.Indent(); Debug.Indent();
//Debug.Print("GraphicsFormat: {0}", format.ToString()); //Debug.Print("GraphicsMode: {0}", format.ToString());
CreateParams cp = new CreateParams(); CreateParams cp = new CreateParams();
cp.ClassStyle = cp.ClassStyle =

View file

@ -306,7 +306,7 @@ namespace OpenTK.Platform.X11
#region public DisplayMode Mode #region public DisplayMode Mode
GraphicsMode IGLContextInternal.GraphicsFormat GraphicsMode IGLContextInternal.GraphicsMode
{ {
get { return format; } get { return format; }
} }

View file

@ -495,7 +495,7 @@ namespace OpenTK.Platform.X11
/// </remarks> /// </remarks>
public void CreateWindow(int width, int height, DisplayMode mode, out IGraphicsContext glContext) public void CreateWindow(int width, int height, DisplayMode mode, out IGraphicsContext glContext)
{ {
this.CreateWindow(width, height);//, mode.ToGraphicsFormat(), out glContext); this.CreateWindow(width, height);//, mode.ToGraphicsMode(), out glContext);
glContext = null; glContext = null;
} }