Moved DummyGLContext and DummyGLControl to the OpenTK/Platform/Dummy directory and namespace.
Fixed a regression where the GLControl would try to instantiate a normal context inside the VS designer, instead of a dummy one.
This commit is contained in:
parent
829d929ab3
commit
033d4722af
5 changed files with 59 additions and 17 deletions
|
@ -53,13 +53,13 @@ namespace OpenTK
|
|||
/// <param name="mode">The OpenTK.Graphics.GraphicsMode of the control.</param>
|
||||
public GLControl(GraphicsMode mode)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.SetStyle(ControlStyles.Opaque, true);
|
||||
this.SetStyle(ControlStyles.UserPaint, true);
|
||||
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
SetStyle(ControlStyles.Opaque, true);
|
||||
SetStyle(ControlStyles.UserPaint, true);
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
DoubleBuffered = false;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
this.format = mode;
|
||||
|
||||
// On Windows, you first need to create the window, then set the pixel format.
|
||||
|
@ -69,10 +69,12 @@ namespace OpenTK
|
|||
// it would be better to decouple selection from context creation, which will allow us
|
||||
// to clean up this hacky code. The best option is to do this along with multisampling
|
||||
// support.
|
||||
if (Configuration.RunningOnWindows)
|
||||
implementation = new OpenTK.Platform.Windows.WinGLControl(mode, this);
|
||||
if (DesignMode)
|
||||
implementation = new Platform.Dummy.DummyGLControl();
|
||||
else if (Configuration.RunningOnWindows)
|
||||
implementation = new Platform.Windows.WinGLControl(mode, this);
|
||||
else if (Configuration.RunningOnX11)
|
||||
implementation = new OpenTK.Platform.X11.X11GLControl(mode, this);
|
||||
implementation = new Platform.X11.X11GLControl(mode, this);
|
||||
else if (Configuration.RunningOnOSX)
|
||||
throw new PlatformNotSupportedException("Refer to http://www.opentk.com for more information.");
|
||||
|
||||
|
@ -89,10 +91,7 @@ namespace OpenTK
|
|||
{
|
||||
base.OnHandleCreated(e);
|
||||
|
||||
if (DesignMode)
|
||||
this.Context = new DummyGLContext(null);
|
||||
else
|
||||
this.Context = implementation.CreateContext();
|
||||
this.Context = implementation.CreateContext();
|
||||
|
||||
this.window_info = implementation.WindowInfo;
|
||||
this.MakeCurrent();
|
||||
|
@ -193,7 +192,7 @@ namespace OpenTK
|
|||
}
|
||||
}
|
||||
else
|
||||
context = new DummyGLContext(format);
|
||||
context = new Platform.Dummy.DummyGLContext(format);
|
||||
|
||||
this.MakeCurrent();
|
||||
(context as IGraphicsContextInternal).LoadAll();
|
||||
|
|
|
@ -71,11 +71,11 @@ namespace OpenTK.Graphics
|
|||
}
|
||||
|
||||
if (designMode)
|
||||
implementation = new OpenTK.Platform.DummyGLContext(mode);
|
||||
implementation = new Platform.Dummy.DummyGLContext(mode);
|
||||
else if (Configuration.RunningOnWindows)
|
||||
implementation = new OpenTK.Platform.Windows.WinGLContext(mode, window, shareContext);
|
||||
implementation = new Platform.Windows.WinGLContext(mode, window, shareContext);
|
||||
else if (Configuration.RunningOnX11)
|
||||
implementation = new OpenTK.Platform.X11.X11GLContext(mode, window, shareContext, DirectRendering);
|
||||
implementation = new Platform.X11.X11GLContext(mode, window, shareContext, DirectRendering);
|
||||
else
|
||||
throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information.");
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace OpenTK.Platform
|
||||
namespace OpenTK.Platform.Dummy
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty IGraphicsContext implementation to be used inside the Visual Studio designer.
|
26
Source/OpenTK/Platform/Dummy/DummyGLControl.cs
Normal file
26
Source/OpenTK/Platform/Dummy/DummyGLControl.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using OpenTK.Graphics;
|
||||
|
||||
namespace OpenTK.Platform.Dummy
|
||||
{
|
||||
class DummyGLControl : IGLControl
|
||||
{
|
||||
#region IGLControl Members
|
||||
|
||||
public OpenTK.Graphics.GraphicsContext CreateContext()
|
||||
{
|
||||
return new GraphicsContext(null, null);
|
||||
}
|
||||
|
||||
public bool IsIdle
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public IWindowInfo WindowInfo
|
||||
{
|
||||
get { return new DummyWindowInfo(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
17
Source/OpenTK/Platform/Dummy/DummyWindowInfo.cs
Normal file
17
Source/OpenTK/Platform/Dummy/DummyWindowInfo.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenTK.Platform.Dummy
|
||||
{
|
||||
class DummyWindowInfo : IWindowInfo
|
||||
{
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue