mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-12 07:45:34 +00:00
Made GraphicsMode query non-eager. The GraphicsMode will only be queried on first access of its Index property, for example when creating an X11 window or a new GraphicsContext.
This commit is contained in:
parent
0feae9b6e3
commit
b503c41bf1
|
@ -19,7 +19,7 @@ namespace OpenTK.Graphics
|
||||||
ColorFormat color_format, accumulator_format;
|
ColorFormat color_format, accumulator_format;
|
||||||
int depth, stencil, buffers, samples;
|
int depth, stencil, buffers, samples;
|
||||||
bool stereo;
|
bool stereo;
|
||||||
IntPtr index; // The id of the pixel format or visual.
|
IntPtr? index; // The id of the pixel format or visual.
|
||||||
|
|
||||||
static GraphicsMode defaultMode;
|
static GraphicsMode defaultMode;
|
||||||
static IGraphicsMode implementation;
|
static IGraphicsMode implementation;
|
||||||
|
@ -53,27 +53,6 @@ namespace OpenTK.Graphics
|
||||||
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.");
|
if (samples < 0) throw new ArgumentOutOfRangeException("samples", "Must be greater than, or equal to zero.");
|
||||||
|
|
||||||
// This method will search for the closest
|
|
||||||
|
|
||||||
if (index == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
GraphicsMode mode;
|
|
||||||
lock (mode_selection_lock)
|
|
||||||
{
|
|
||||||
mode = implementation.SelectGraphicsMode(color, depth, stencil, samples, accum, buffers, stereo);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Index = mode.Index;
|
|
||||||
this.ColorFormat = mode.ColorFormat;
|
|
||||||
this.Depth = mode.Depth;
|
|
||||||
this.Stencil = mode.Stencil;
|
|
||||||
this.Samples = mode.Samples;
|
|
||||||
this.AccumulatorFormat = mode.AccumulatorFormat;
|
|
||||||
this.Buffers = mode.Buffers;
|
|
||||||
this.Stereo = mode.Stereo;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.Index = index;
|
this.Index = index;
|
||||||
this.ColorFormat = color;
|
this.ColorFormat = color;
|
||||||
this.Depth = depth;
|
this.Depth = depth;
|
||||||
|
@ -83,7 +62,6 @@ namespace OpenTK.Graphics
|
||||||
this.Buffers = buffers;
|
this.Buffers = buffers;
|
||||||
this.Stereo = stereo;
|
this.Stereo = stereo;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -311,7 +289,28 @@ namespace OpenTK.Graphics
|
||||||
|
|
||||||
internal IntPtr Index
|
internal IntPtr Index
|
||||||
{
|
{
|
||||||
get { return index; }
|
get
|
||||||
|
{
|
||||||
|
if (index == null)
|
||||||
|
{
|
||||||
|
GraphicsMode mode;
|
||||||
|
lock (mode_selection_lock)
|
||||||
|
{
|
||||||
|
mode = implementation.SelectGraphicsMode(ColorFormat, Depth, Stencil, Samples, AccumulatorFormat, Buffers, Stereo);
|
||||||
|
}
|
||||||
|
|
||||||
|
Index = mode.Index;
|
||||||
|
ColorFormat = mode.ColorFormat;
|
||||||
|
Depth = mode.Depth;
|
||||||
|
Stencil = mode.Stencil;
|
||||||
|
Samples = mode.Samples;
|
||||||
|
AccumulatorFormat = mode.AccumulatorFormat;
|
||||||
|
Buffers = mode.Buffers;
|
||||||
|
Stereo = mode.Stereo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return index.Value;
|
||||||
|
}
|
||||||
set { index = value; }
|
set { index = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue