Bugfix: Creating a second GraphicsContext forced context sharing.

This fix will keep existing behavior (forced sharing) in the default case, but adds a new constructor that allows explicitly specifying the shared context. A user can now explicitly specify null for the shared context to get a new non-shared context.
This commit is contained in:
Jonas Boesch 2015-04-21 16:09:48 +02:00 committed by Manuel Zanin
parent 9d29c8c19b
commit 84a210bda5

View file

@ -97,6 +97,23 @@ namespace OpenTK.Graphics
/// Different hardware supports different flags, major and minor versions. Invalid parameters will be silently ignored.
/// </remarks>
public GraphicsContext(GraphicsMode mode, IWindowInfo window, int major, int minor, GraphicsContextFlags flags)
: this(mode, window, FindSharedContext(), major, minor, flags)
{
}
/// <summary>
/// Constructs a new GraphicsContext with the specified GraphicsMode, version and flags, and attaches it to the specified window.
/// </summary>
/// <param name="mode">The OpenTK.Graphics.GraphicsMode of the GraphicsContext.</param>
/// <param name="window">The OpenTK.Platform.IWindowInfo to attach the GraphicsContext to.</param>
/// <param name="shareContext">The GraphicsContext to share resources with, or null for explicit non-sharing.</param>
/// <param name="major">The major version of the new GraphicsContext.</param>
/// <param name="minor">The minor version of the new GraphicsContext.</param>
/// <param name="flags">The GraphicsContextFlags for the GraphicsContext.</param>
/// <remarks>
/// Different hardware supports different flags, major and minor versions. Invalid parameters will be silently ignored.
/// </remarks>
public GraphicsContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, int major, int minor, GraphicsContextFlags flags)
{
lock (SyncRoot)
{
@ -133,8 +150,6 @@ namespace OpenTK.Graphics
Debug.Print("GraphicsContextFlags: {0}", flags);
Debug.Print("Requested version: {0}.{1}", major, minor);
IGraphicsContext shareContext = FindSharedContext();
// Todo: Add a DummyFactory implementing IPlatformFactory.
if (designMode)
{