Remove samples/stereo from GraphicsMode, remove some other unused constructors and exceptions.

This commit is contained in:
UnknownShadow200 2015-07-02 06:33:19 +10:00
parent ec0cb6b997
commit 273f4f5611
7 changed files with 16 additions and 169 deletions

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.Graphics
{
/// <summary>
/// Identifies a specific OpenGL or OpenGL|ES error. Such exceptions are only thrown
/// when OpenGL or OpenGL|ES automatic error checking is enabled -
/// <see cref="GraphicsContext.ErrorChecking"/> property.
/// Important: Do *not* catch this exception. Rather, fix the underlying issue that caused the error.
/// </summary>
public class GraphicsErrorException : GraphicsException
{
/// <summary>
/// Constructs a new GraphicsErrorException instance with the specified error message.
/// </summary>
/// <param name="message"></param>
public GraphicsErrorException(string message) : base(message) { }
}
}

View File

@ -17,8 +17,7 @@ namespace OpenTK.Graphics
public class GraphicsMode : IEquatable<GraphicsMode>
{
ColorFormat color_format;
int depth, stencil, buffers, samples;
bool stereo;
int depth, stencil, buffers;
IntPtr? index = null; // The id of the pixel format or visual.
static GraphicsMode defaultMode;
@ -39,116 +38,32 @@ namespace OpenTK.Graphics
#endregion
#region internal GraphicsMode(GraphicsMode mode)
internal GraphicsMode(GraphicsMode mode)
: this(mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples, mode.Buffers, mode.Stereo) { }
#endregion
#region internal GraphicsMode(IntPtr? index, ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo)
internal GraphicsMode(IntPtr? index, ColorFormat color, int depth, int stencil, int samples,
int buffers, bool stereo)
internal GraphicsMode(IntPtr? index, ColorFormat color, int depth, int stencil, int buffers)
{
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.Index = index;
this.ColorFormat = color;
this.Depth = depth;
this.Stencil = stencil;
this.Samples = samples;
this.Buffers = buffers;
this.Stereo = stereo;
}
#endregion
#region public GraphicsMode()
/// <summary>Constructs a new GraphicsMode with sensible default parameters.</summary>
public GraphicsMode()
: this(Default)
{ }
#endregion
#region public GraphicsMode(ColorFormat color)
/// <summary>Constructs a new GraphicsMode with the specified parameters.</summary>
/// <param name="color">The ColorFormat of the color buffer.</param>
public GraphicsMode(ColorFormat color)
: this(color, Default.Depth, Default.Stencil, Default.Samples, Default.Buffers, Default.Stereo)
{ }
#endregion
#region public GraphicsMode(ColorFormat color, int depth)
/// <summary>Constructs a new GraphicsMode 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(ColorFormat color, int depth)
: this(color, depth, Default.Stencil, Default.Samples, Default.Buffers, Default.Stereo)
{ }
#endregion
#region public GraphicsMode(ColorFormat color, int depth, int stencil)
/// <summary>Constructs a new GraphicsMode 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(ColorFormat color, int depth, int stencil)
: this(color, depth, stencil, Default.Samples, Default.Buffers, Default.Stereo)
{ }
#endregion
#region public GraphicsMode(ColorFormat color, int depth, int stencil, int samples)
/// <summary>Constructs a new GraphicsMode 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(ColorFormat color, int depth, int stencil, int samples)
: this(color, depth, stencil, samples, Default.Buffers, Default.Stereo)
{ }
#endregion
#region public GraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers)
/// <summary>Constructs a new GraphicsMode 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(ColorFormat color, int depth, int stencil, int samples, int buffers)
: this(color, depth, stencil, samples, buffers, Default.Stereo)
{ }
#endregion
#region public GraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo)
/// <summary>Constructs a new GraphicsMode 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 GraphicsMode 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(ColorFormat color, int depth, int stencil, int samples, int buffers, bool stereo)
: this(null, color, depth, stencil, samples, buffers, stereo) { }
public GraphicsMode(ColorFormat color, int depth, int stencil, int buffers)
: this(null, color, depth, stencil, buffers) { }
#endregion
@ -226,40 +141,6 @@ namespace OpenTK.Graphics
#endregion
#region public int Samples
/// <summary>
/// Gets a System.Int32 that contains the number of FSAA samples per pixel for this GraphicsFormat.
/// </summary>
public int Samples
{
get
{
LazySelectGraphicsMode();
return samples;
}
private set { samples = value; }
}
#endregion
#region public bool Stereo
/// <summary>
/// Gets a System.Boolean indicating whether this DisplayMode is stereoscopic.
/// </summary>
public bool Stereo
{
get
{
LazySelectGraphicsMode();
return stereo;
}
private set { stereo = value; }
}
#endregion
#region public int Buffers
/// <summary>
@ -289,9 +170,9 @@ namespace OpenTK.Graphics
{
if (defaultMode == null)
{
Debug.Print("Creating default GraphicsMode ({0}, {1}, {2}, {3}, {4}, {5}, {6}).", DisplayDevice.Default.BitsPerPixel,
16, 0, 0, 0, 2, false);
defaultMode = new GraphicsMode(DisplayDevice.Default.BitsPerPixel, 16, 0, 0, 2, false);
Debug.Print("Creating default GraphicsMode ({0}, {1}, {2}, {3}).", DisplayDevice.Default.BitsPerPixel,
16, 0, 2);
defaultMode = new GraphicsMode(DisplayDevice.Default.BitsPerPixel, 16, 0, 2);
}
return defaultMode;
}
@ -311,15 +192,13 @@ namespace OpenTK.Graphics
{
if (index == null)
{
GraphicsMode mode = implementation.SelectGraphicsMode(color_format, depth, stencil, samples, buffers, stereo);
GraphicsMode mode = implementation.SelectGraphicsMode(color_format, depth, stencil, buffers);
Index = mode.Index;
ColorFormat = mode.ColorFormat;
Depth = mode.Depth;
Stencil = mode.Stencil;
Samples = mode.Samples;
Buffers = mode.Buffers;
Stereo = mode.Stereo;
}
}
@ -331,8 +210,8 @@ namespace OpenTK.Graphics
/// <returns>! System.String describing the current GraphicsFormat.</returns>
public override string ToString()
{
return String.Format("Index: {0}, Color: {1}, Depth: {2}, Stencil: {3}, Samples: {4}, Buffers: {5}, Stereo: {6}",
Index, ColorFormat, Depth, Stencil, Samples, Buffers, Stereo);
return String.Format("Index: {0}, Color: {1}, Depth: {2}, Stencil: {3}, Buffers: {4}",
Index, ColorFormat, Depth, Stencil, Buffers);
}
/// <summary>

View File

@ -14,9 +14,8 @@ namespace OpenTK.Graphics
{
// Creates a temporary OpenGL context (if necessary) and finds the mode which closest matches
// the specified parameters.
public virtual GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples, int buffers,
bool stereo) {
return new GraphicsMode((IntPtr)1, color, depth, stencil, samples, buffers, stereo);
public virtual GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int buffers) {
return new GraphicsMode((IntPtr)1, color, depth, stencil, buffers);
}
}
}

View File

@ -69,7 +69,6 @@
<Compile Include="Graphics\GraphicsContextBase.cs" />
<Compile Include="Graphics\GraphicsContextException.cs" />
<Compile Include="Graphics\GraphicsContextMissingException.cs" />
<Compile Include="Graphics\GraphicsErrorException.cs" />
<Compile Include="Graphics\GraphicsExceptions.cs" />
<Compile Include="Graphics\GraphicsMode.cs" />
<Compile Include="Graphics\GraphicsModeException.cs" />

View File

@ -77,12 +77,6 @@ namespace OpenTK.Platform.MacOS
if (mode.Stencil > 0)
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_STENCIL_SIZE, mode.Stencil);
if (mode.Samples > 1)
{
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_SAMPLE_BUFFERS_ARB, 1);
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_SAMPLES_ARB, mode.Samples);
}
if (fullscreen)
{

View File

@ -200,9 +200,8 @@ namespace OpenTK.Platform.Windows
Mode = new GraphicsMode(
(IntPtr)modeIndex, new ColorFormat(pfd.RedBits, pfd.GreenBits, pfd.BlueBits, pfd.AlphaBits),
pfd.DepthBits, pfd.StencilBits, 0,
(pfd.Flags & PixelFormatDescriptorFlags.DOUBLEBUFFER) != 0 ? 2 : 1,
(pfd.Flags & PixelFormatDescriptorFlags.STEREO) != 0);
pfd.DepthBits, pfd.StencilBits,
(pfd.Flags & PixelFormatDescriptorFlags.DOUBLEBUFFER) != 0 ? 2 : 1);
Debug.WriteLine(modeIndex);
if (!Functions.SetPixelFormat(window.DeviceContext, modeIndex, ref pfd))

View File

@ -32,8 +32,7 @@ namespace OpenTK.Platform.X11
#region IGraphicsMode Members
public override GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples,
int buffers, bool stereo)
public override GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int buffers)
{
GraphicsMode gfx;
// The actual GraphicsMode that will be selected.
@ -65,8 +64,7 @@ namespace OpenTK.Platform.X11
++buffers;
// the above lines returns 0 - false and 1 - true.
gfx = new GraphicsMode(info.VisualID, new ColorFormat(r, g, b, a), depth, stencil, samples,
buffers, stereo);
gfx = new GraphicsMode(info.VisualID, new ColorFormat(r, g, b, a), depth, stencil, buffers);
using (new XLock(display))
{