miffe's picture

context.MakeCurrent issues

I'm having troubles with MakeCurrent on contexts, the code below is a boild down example of what I'm trying to do.

            OpenTK.Graphics.IGraphicsContext context;
 
            using (var win = new OpenTK.NativeWindow())
            {
                context = new OpenTK.Graphics.GraphicsContext(OpenTK.Graphics.GraphicsMode.Default, win.WindowInfo);
                context.MakeCurrent(win.WindowInfo);
                context.LoadAll();
                context.MakeCurrent(null);
            }
 
            using (var win = new OpenTK.NativeWindow())
            {
                context.MakeCurrent(win.WindowInfo);
                context.MakeCurrent(null);
            }

The context.MakeCurrent(win.WindowInfo) in the second using block throws an exception saying: Failed to make context 65537 current. Error: 2000
Error 2000 means Invalid Pixel Format.

Is this not how you are supposed to manage contexts? What I'm i doing wrong?