mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Remove samples/stereo from GraphicsMode, remove some other unused constructors and exceptions.
This commit is contained in:
parent
ec0cb6b997
commit
273f4f5611
@ -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) { }
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,8 +17,7 @@ namespace OpenTK.Graphics
|
|||||||
public class GraphicsMode : IEquatable<GraphicsMode>
|
public class GraphicsMode : IEquatable<GraphicsMode>
|
||||||
{
|
{
|
||||||
ColorFormat color_format;
|
ColorFormat color_format;
|
||||||
int depth, stencil, buffers, samples;
|
int depth, stencil, buffers;
|
||||||
bool stereo;
|
|
||||||
IntPtr? index = null; // The id of the pixel format or visual.
|
IntPtr? index = null; // The id of the pixel format or visual.
|
||||||
|
|
||||||
static GraphicsMode defaultMode;
|
static GraphicsMode defaultMode;
|
||||||
@ -39,116 +38,32 @@ namespace OpenTK.Graphics
|
|||||||
|
|
||||||
#endregion
|
#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)
|
#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,
|
internal GraphicsMode(IntPtr? index, ColorFormat color, int depth, int stencil, int buffers)
|
||||||
int buffers, bool stereo)
|
|
||||||
{
|
{
|
||||||
if (depth < 0) throw new ArgumentOutOfRangeException("depth", "Must be greater than, or equal to zero.");
|
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 (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 (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.Index = index;
|
||||||
this.ColorFormat = color;
|
this.ColorFormat = color;
|
||||||
this.Depth = depth;
|
this.Depth = depth;
|
||||||
this.Stencil = stencil;
|
this.Stencil = stencil;
|
||||||
this.Samples = samples;
|
|
||||||
this.Buffers = buffers;
|
this.Buffers = buffers;
|
||||||
this.Stereo = stereo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#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)
|
#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>
|
/// <summary>Constructs a new GraphicsMode with the specified parameters.</summary>
|
||||||
/// <param name="color">The ColorFormat of the color buffer.</param>
|
/// <param name="color">The ColorFormat of the color buffer.</param>
|
||||||
/// <param name="depth">The number of bits in the depth 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="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>
|
/// <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)
|
public GraphicsMode(ColorFormat color, int depth, int stencil, int buffers)
|
||||||
: this(null, color, depth, stencil, samples, buffers, stereo) { }
|
: this(null, color, depth, stencil, buffers) { }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -226,40 +141,6 @@ namespace OpenTK.Graphics
|
|||||||
|
|
||||||
#endregion
|
#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
|
#region public int Buffers
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -289,9 +170,9 @@ namespace OpenTK.Graphics
|
|||||||
{
|
{
|
||||||
if (defaultMode == null)
|
if (defaultMode == null)
|
||||||
{
|
{
|
||||||
Debug.Print("Creating default GraphicsMode ({0}, {1}, {2}, {3}, {4}, {5}, {6}).", DisplayDevice.Default.BitsPerPixel,
|
Debug.Print("Creating default GraphicsMode ({0}, {1}, {2}, {3}).", DisplayDevice.Default.BitsPerPixel,
|
||||||
16, 0, 0, 0, 2, false);
|
16, 0, 2);
|
||||||
defaultMode = new GraphicsMode(DisplayDevice.Default.BitsPerPixel, 16, 0, 0, 2, false);
|
defaultMode = new GraphicsMode(DisplayDevice.Default.BitsPerPixel, 16, 0, 2);
|
||||||
}
|
}
|
||||||
return defaultMode;
|
return defaultMode;
|
||||||
}
|
}
|
||||||
@ -311,15 +192,13 @@ namespace OpenTK.Graphics
|
|||||||
{
|
{
|
||||||
if (index == null)
|
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;
|
Index = mode.Index;
|
||||||
ColorFormat = mode.ColorFormat;
|
ColorFormat = mode.ColorFormat;
|
||||||
Depth = mode.Depth;
|
Depth = mode.Depth;
|
||||||
Stencil = mode.Stencil;
|
Stencil = mode.Stencil;
|
||||||
Samples = mode.Samples;
|
|
||||||
Buffers = mode.Buffers;
|
Buffers = mode.Buffers;
|
||||||
Stereo = mode.Stereo;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,8 +210,8 @@ namespace OpenTK.Graphics
|
|||||||
/// <returns>! System.String describing the current GraphicsFormat.</returns>
|
/// <returns>! System.String describing the current GraphicsFormat.</returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return String.Format("Index: {0}, Color: {1}, Depth: {2}, Stencil: {3}, Samples: {4}, Buffers: {5}, Stereo: {6}",
|
return String.Format("Index: {0}, Color: {1}, Depth: {2}, Stencil: {3}, Buffers: {4}",
|
||||||
Index, ColorFormat, Depth, Stencil, Samples, Buffers, Stereo);
|
Index, ColorFormat, Depth, Stencil, Buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -14,9 +14,8 @@ namespace OpenTK.Graphics
|
|||||||
{
|
{
|
||||||
// Creates a temporary OpenGL context (if necessary) and finds the mode which closest matches
|
// Creates a temporary OpenGL context (if necessary) and finds the mode which closest matches
|
||||||
// the specified parameters.
|
// the specified parameters.
|
||||||
public virtual GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples, int buffers,
|
public virtual GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int buffers) {
|
||||||
bool stereo) {
|
return new GraphicsMode((IntPtr)1, color, depth, stencil, buffers);
|
||||||
return new GraphicsMode((IntPtr)1, color, depth, stencil, samples, buffers, stereo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,6 @@
|
|||||||
<Compile Include="Graphics\GraphicsContextBase.cs" />
|
<Compile Include="Graphics\GraphicsContextBase.cs" />
|
||||||
<Compile Include="Graphics\GraphicsContextException.cs" />
|
<Compile Include="Graphics\GraphicsContextException.cs" />
|
||||||
<Compile Include="Graphics\GraphicsContextMissingException.cs" />
|
<Compile Include="Graphics\GraphicsContextMissingException.cs" />
|
||||||
<Compile Include="Graphics\GraphicsErrorException.cs" />
|
|
||||||
<Compile Include="Graphics\GraphicsExceptions.cs" />
|
<Compile Include="Graphics\GraphicsExceptions.cs" />
|
||||||
<Compile Include="Graphics\GraphicsMode.cs" />
|
<Compile Include="Graphics\GraphicsMode.cs" />
|
||||||
<Compile Include="Graphics\GraphicsModeException.cs" />
|
<Compile Include="Graphics\GraphicsModeException.cs" />
|
||||||
|
@ -78,12 +78,6 @@ namespace OpenTK.Platform.MacOS
|
|||||||
if (mode.Stencil > 0)
|
if (mode.Stencil > 0)
|
||||||
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_STENCIL_SIZE, mode.Stencil);
|
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)
|
if (fullscreen)
|
||||||
{
|
{
|
||||||
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_FULLSCREEN);
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_FULLSCREEN);
|
||||||
|
@ -200,9 +200,8 @@ namespace OpenTK.Platform.Windows
|
|||||||
|
|
||||||
Mode = new GraphicsMode(
|
Mode = new GraphicsMode(
|
||||||
(IntPtr)modeIndex, new ColorFormat(pfd.RedBits, pfd.GreenBits, pfd.BlueBits, pfd.AlphaBits),
|
(IntPtr)modeIndex, new ColorFormat(pfd.RedBits, pfd.GreenBits, pfd.BlueBits, pfd.AlphaBits),
|
||||||
pfd.DepthBits, pfd.StencilBits, 0,
|
pfd.DepthBits, pfd.StencilBits,
|
||||||
(pfd.Flags & PixelFormatDescriptorFlags.DOUBLEBUFFER) != 0 ? 2 : 1,
|
(pfd.Flags & PixelFormatDescriptorFlags.DOUBLEBUFFER) != 0 ? 2 : 1);
|
||||||
(pfd.Flags & PixelFormatDescriptorFlags.STEREO) != 0);
|
|
||||||
|
|
||||||
Debug.WriteLine(modeIndex);
|
Debug.WriteLine(modeIndex);
|
||||||
if (!Functions.SetPixelFormat(window.DeviceContext, modeIndex, ref pfd))
|
if (!Functions.SetPixelFormat(window.DeviceContext, modeIndex, ref pfd))
|
||||||
|
@ -32,8 +32,7 @@ namespace OpenTK.Platform.X11
|
|||||||
|
|
||||||
#region IGraphicsMode Members
|
#region IGraphicsMode Members
|
||||||
|
|
||||||
public override GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples,
|
public override GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int buffers)
|
||||||
int buffers, bool stereo)
|
|
||||||
{
|
{
|
||||||
GraphicsMode gfx;
|
GraphicsMode gfx;
|
||||||
// The actual GraphicsMode that will be selected.
|
// The actual GraphicsMode that will be selected.
|
||||||
@ -65,8 +64,7 @@ namespace OpenTK.Platform.X11
|
|||||||
++buffers;
|
++buffers;
|
||||||
// the above lines returns 0 - false and 1 - true.
|
// the above lines returns 0 - false and 1 - true.
|
||||||
|
|
||||||
gfx = new GraphicsMode(info.VisualID, new ColorFormat(r, g, b, a), depth, stencil, samples,
|
gfx = new GraphicsMode(info.VisualID, new ColorFormat(r, g, b, a), depth, stencil, buffers);
|
||||||
buffers, stereo);
|
|
||||||
|
|
||||||
using (new XLock(display))
|
using (new XLock(display))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user