2009-02-22 10:43:35 +00:00
|
|
|
|
#region --- License ---
|
|
|
|
|
/* Licensed under the MIT/X11 license.
|
|
|
|
|
* Copyright (c) 2006-2008 the OpenTK Team.
|
|
|
|
|
* This notice may not be removed from any source distribution.
|
|
|
|
|
* See license.txt for licensing detailed licensing details.
|
|
|
|
|
*/
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
2010-10-02 18:52:34 +00:00
|
|
|
|
using System.Threading;
|
|
|
|
|
|
2009-02-22 10:43:35 +00:00
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace OpenTK.Platform.Dummy
|
|
|
|
|
{
|
2010-03-11 22:53:11 +00:00
|
|
|
|
/// \internal
|
2009-02-22 10:43:35 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// An empty IGraphicsContext implementation to be used inside the Visual Studio designer.
|
|
|
|
|
/// This class supports OpenTK, and is not intended for use by OpenTK programs.
|
|
|
|
|
/// </summary>
|
2009-08-17 10:23:16 +00:00
|
|
|
|
internal sealed class DummyGLContext : DesktopGraphicsContext
|
2009-02-22 10:43:35 +00:00
|
|
|
|
{
|
2013-12-28 00:09:59 +00:00
|
|
|
|
readonly GraphicsContext.GetAddressDelegate Loader;
|
|
|
|
|
|
2011-09-06 12:06:30 +00:00
|
|
|
|
int swap_interval;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
static int handle_count;
|
2010-10-02 18:52:34 +00:00
|
|
|
|
Thread current_thread;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
|
|
|
|
#region --- Constructors ---
|
|
|
|
|
|
2009-05-30 19:27:52 +00:00
|
|
|
|
public DummyGLContext()
|
|
|
|
|
{
|
2013-12-28 00:09:59 +00:00
|
|
|
|
Handle = new ContextHandle(
|
|
|
|
|
new IntPtr(Interlocked.Increment(
|
|
|
|
|
ref handle_count)));
|
2009-05-30 19:27:52 +00:00
|
|
|
|
}
|
2013-12-28 00:09:59 +00:00
|
|
|
|
|
|
|
|
|
public DummyGLContext(ContextHandle handle, GraphicsContext.GetAddressDelegate loader)
|
|
|
|
|
: this()
|
2009-05-30 19:27:52 +00:00
|
|
|
|
{
|
2013-12-28 00:09:59 +00:00
|
|
|
|
if (handle != ContextHandle.Zero)
|
|
|
|
|
{
|
|
|
|
|
Handle = handle;
|
|
|
|
|
}
|
|
|
|
|
Loader = loader;
|
2011-12-06 21:54:20 +00:00
|
|
|
|
Mode = new GraphicsMode(new IntPtr(2), 32, 16, 0, 0, 0, 2, false);
|
2009-05-30 19:27:52 +00:00
|
|
|
|
}
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region --- IGraphicsContext Members ---
|
|
|
|
|
|
2009-08-17 10:23:16 +00:00
|
|
|
|
public override void SwapBuffers() { }
|
2010-10-02 18:52:34 +00:00
|
|
|
|
|
|
|
|
|
public override void MakeCurrent(IWindowInfo info)
|
|
|
|
|
{
|
|
|
|
|
Thread new_thread = Thread.CurrentThread;
|
|
|
|
|
// A context may be current only on one thread at a time.
|
|
|
|
|
if (current_thread != null && new_thread != current_thread)
|
|
|
|
|
{
|
|
|
|
|
throw new GraphicsContextException(
|
|
|
|
|
"Cannot make context current on two threads at the same time");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info != null)
|
|
|
|
|
{
|
|
|
|
|
current_thread = Thread.CurrentThread;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
current_thread = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsCurrent
|
|
|
|
|
{
|
|
|
|
|
get { return current_thread != null && current_thread == Thread.CurrentThread; }
|
|
|
|
|
}
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
2013-12-28 00:09:59 +00:00
|
|
|
|
public override IntPtr GetAddress(string function)
|
|
|
|
|
{
|
|
|
|
|
return Loader(function);
|
|
|
|
|
}
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
2013-12-28 00:09:59 +00:00
|
|
|
|
public override IntPtr GetAddress(IntPtr function)
|
|
|
|
|
{
|
|
|
|
|
return IntPtr.Zero;
|
|
|
|
|
}
|
2013-11-28 22:21:19 +00:00
|
|
|
|
|
2011-09-06 12:06:30 +00:00
|
|
|
|
public override int SwapInterval
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return swap_interval;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
swap_interval = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
2009-08-17 10:23:16 +00:00
|
|
|
|
public override void Update(IWindowInfo window)
|
|
|
|
|
{ }
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
2009-08-17 10:23:16 +00:00
|
|
|
|
public override void LoadAll()
|
2013-12-28 00:09:59 +00:00
|
|
|
|
{
|
|
|
|
|
new OpenTK.Graphics.OpenGL.GL().LoadEntryPoints();
|
|
|
|
|
new OpenTK.Graphics.OpenGL4.GL().LoadEntryPoints();
|
|
|
|
|
new OpenTK.Graphics.ES10.GL().LoadEntryPoints();
|
|
|
|
|
new OpenTK.Graphics.ES11.GL().LoadEntryPoints();
|
|
|
|
|
new OpenTK.Graphics.ES20.GL().LoadEntryPoints();
|
|
|
|
|
new OpenTK.Graphics.ES30.GL().LoadEntryPoints();
|
|
|
|
|
}
|
2009-03-07 10:36:51 +00:00
|
|
|
|
|
2009-08-17 10:23:16 +00:00
|
|
|
|
#endregion
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
2009-08-17 10:23:16 +00:00
|
|
|
|
#region --- IDisposable Members ---
|
|
|
|
|
|
2009-09-03 12:23:11 +00:00
|
|
|
|
public override void Dispose() { IsDisposed = true; }
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|