Added support for IPlatformFactory implementations for embedded devices that use EGL. The embedded implementation can be used side-by-side with the normal implementations (useful for platforms that support both desktop GL and EGL).

This commit is contained in:
the_fiddler 2009-08-13 11:52:51 +00:00
parent 686b63a420
commit c4554bd804
2 changed files with 38 additions and 14 deletions

View file

@ -97,6 +97,8 @@ namespace OpenTK.Graphics
Debug.Indent();
Debug.Print("GraphicsMode: {0}", mode);
Debug.Print("IWindowInfo: {0}", window);
Debug.Print("GraphicsContextFlags: {0}", flags);
Debug.Print("Requested version: {0}.{1}", major, minor);
IGraphicsContext shareContext = null;
if (GraphicsContext.ShareContexts)
@ -116,7 +118,11 @@ namespace OpenTK.Graphics
if (designMode)
implementation = new Platform.Dummy.DummyGLContext();
else
implementation = Factory.Default.CreateGLContext(mode, window, shareContext, DirectRendering, major, minor, flags);
switch ((int)(flags & GraphicsContextFlags.Embedded))
{
case 0: implementation = Factory.Default.CreateGLContext(mode, window, shareContext, direct_rendering, major, minor, flags); break;
case 1: implementation = Factory.Embedded.CreateGLContext(mode, window, shareContext, direct_rendering, major, minor, flags); break;
}
lock (context_lock)
{

View file

@ -37,7 +37,7 @@ namespace OpenTK.Platform
{
#region Fields
static IPlatformFactory implementation;
static IPlatformFactory default_implementation, embedded_implementation;
#endregion
@ -45,10 +45,21 @@ namespace OpenTK.Platform
static Factory()
{
if (Configuration.RunningOnWindows) implementation = new Windows.WinFactory();
else if (Configuration.RunningOnX11) implementation = new X11.X11Factory();
else if (Configuration.RunningOnMacOS) implementation = new MacOS.MacOSFactory();
else implementation = new UnsupportedPlatform();
if (Configuration.RunningOnWindows) Default = new Windows.WinFactory();
else if (Configuration.RunningOnX11) Default = new X11.X11Factory();
else if (Configuration.RunningOnMacOS) Default = new MacOS.MacOSFactory();
else Default = new UnsupportedPlatform();
if (Egl.Egl.IsSupported)
{
if (Configuration.RunningOnWindows) Embedded = new Egl.EglWinPlatformFactory();
else if (Configuration.RunningOnX11) Embedded = new Egl.EglX11PlatformFactory();
else if (Configuration.RunningOnMacOS) Embedded = new Egl.EglMacPlatformFactory();
else Embedded = new UnsupportedPlatform();
}
if (Default is UnsupportedPlatform && !(Embedded is UnsupportedPlatform))
Default = Embedded;
}
#endregion
@ -57,7 +68,14 @@ namespace OpenTK.Platform
public static IPlatformFactory Default
{
get { return implementation; }
get { return default_implementation; }
private set { default_implementation = value; }
}
public static IPlatformFactory Embedded
{
get { return embedded_implementation; }
private set { embedded_implementation = value; }
}
#endregion
@ -67,37 +85,37 @@ namespace OpenTK.Platform
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title,
GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
{
return implementation.CreateNativeWindow(x, y, width, height, title, mode, options, device);
return default_implementation.CreateNativeWindow(x, y, width, height, title, mode, options, device);
}
public IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
{
return implementation.CreateGLControl(mode, owner);
return default_implementation.CreateGLControl(mode, owner);
}
public IDisplayDeviceDriver CreateDisplayDeviceDriver()
{
return implementation.CreateDisplayDeviceDriver();
return default_implementation.CreateDisplayDeviceDriver();
}
public IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
{
return implementation.CreateGLContext(mode, window, shareContext, directRendering, major, minor, flags);
return default_implementation.CreateGLContext(mode, window, shareContext, directRendering, major, minor, flags);
}
public GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext()
{
return implementation.CreateGetCurrentGraphicsContext();
return default_implementation.CreateGetCurrentGraphicsContext();
}
public IGraphicsMode CreateGraphicsMode()
{
return implementation.CreateGraphicsMode();
return default_implementation.CreateGraphicsMode();
}
public OpenTK.Input.IKeyboardDriver CreateKeyboardDriver()
{
return implementation.CreateKeyboardDriver();
return default_implementation.CreateKeyboardDriver();
}
class UnsupportedPlatform : IPlatformFactory