Cleaned up context profile selection
Added support for WGL_create_context profiles and added methods for the selection of context flags and profile.
This commit is contained in:
parent
803c575201
commit
94e2649704
2 changed files with 23 additions and 4 deletions
|
@ -5,13 +5,16 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
public enum ArbCreateContext
|
public enum ArbCreateContext
|
||||||
{
|
{
|
||||||
|
CoreProfileBit = 0x0001,
|
||||||
|
CompatibilityProfileBit = 0x0002,
|
||||||
DebugBit = 0x0001,
|
DebugBit = 0x0001,
|
||||||
ForwardCompatibleBit = 0x0002,
|
ForwardCompatibleBit = 0x0002,
|
||||||
MajorVersion = 0x2091,
|
MajorVersion = 0x2091,
|
||||||
MinorVersion = 0x2092,
|
MinorVersion = 0x2092,
|
||||||
LayerPlane = 0x2093,
|
LayerPlane = 0x2093,
|
||||||
Flags = 0x2094,
|
ContextFlags = 0x2094,
|
||||||
ErrorInvalidVersion = 0x2095,
|
ErrorInvalidVersion = 0x2095,
|
||||||
|
ProfileMask = 0x9126
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum WGL_ARB_buffer_region
|
public enum WGL_ARB_buffer_region
|
||||||
|
|
|
@ -122,9 +122,10 @@ namespace OpenTK.Platform.Windows
|
||||||
attributes.Add(minor);
|
attributes.Add(minor);
|
||||||
if (flags != 0)
|
if (flags != 0)
|
||||||
{
|
{
|
||||||
attributes.Add((int)ArbCreateContext.Flags);
|
attributes.Add((int)ArbCreateContext.ContextFlags);
|
||||||
#warning "This is not entirely correct: Embedded is not a valid flag! We need to add a GetARBContextFlags(GraphicsContextFlags) method."
|
attributes.Add((int)GetARBContextFlags(flags));
|
||||||
attributes.Add((int)flags);
|
attributes.Add((int)ArbCreateContext.ProfileMask);
|
||||||
|
attributes.Add((int)GetARBContextProfile(flags));
|
||||||
}
|
}
|
||||||
// According to the docs, " <attribList> specifies a list of attributes for the context.
|
// According to the docs, " <attribList> specifies a list of attributes for the context.
|
||||||
// The list consists of a sequence of <name,value> pairs terminated by the
|
// The list consists of a sequence of <name,value> pairs terminated by the
|
||||||
|
@ -181,6 +182,21 @@ namespace OpenTK.Platform.Windows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ArbCreateContext GetARBContextFlags(GraphicsContextFlags flags)
|
||||||
|
{
|
||||||
|
ArbCreateContext result = 0;
|
||||||
|
result |= (flags & GraphicsContextFlags.ForwardCompatible) != 0 ?
|
||||||
|
ArbCreateContext.CoreProfileBit : ArbCreateContext.CompatibilityProfileBit;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ArbCreateContext GetARBContextProfile(GraphicsContextFlags flags)
|
||||||
|
{
|
||||||
|
ArbCreateContext result = 0;
|
||||||
|
result |= (flags & GraphicsContextFlags.Debug) != 0 ? ArbCreateContext.DebugBit : 0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public WinGLContext(ContextHandle handle, WinWindowInfo window, IGraphicsContext sharedContext,
|
public WinGLContext(ContextHandle handle, WinWindowInfo window, IGraphicsContext sharedContext,
|
||||||
int major, int minor, GraphicsContextFlags flags)
|
int major, int minor, GraphicsContextFlags flags)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue