GLControl requires native backend

SDL does not currently support embedding into Windows Forms (this is an
upstream limitation.) To ensure that existing WinForms applications
continue to function even if SDL is installed, GLControl will now try to
initialize OpenTK with a native backend. The user can still override
this behavior using OpenTK.Toolkit.Init(ToolkitOptions), as normal.
This commit is contained in:
Stefanos A. 2013-11-12 20:37:23 +01:00
parent b9fcf7c3c3
commit ab58d41353

View file

@ -92,6 +92,18 @@ namespace OpenTK
{
if (mode == null)
throw new ArgumentNullException("mode");
// SDL does not currently support embedding
// on external windows. If Open.Toolkit is not yet
// initialized, we'll try to request a native backend
// that supports embedding.
// Most people are using GLControl through the
// WinForms designer in Visual Studio. This approach
// works perfectly in that case.
Toolkit.Init(new ToolkitOptions
{
Backend = PlatformBackend.PreferNative
});
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.UserPaint, true);