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 e0ba370b4a
commit 245f45c7eb
2 changed files with 38 additions and 14 deletions

View file

@ -97,6 +97,8 @@ namespace OpenTK.Graphics
Debug.Indent(); Debug.Indent();
Debug.Print("GraphicsMode: {0}", mode); Debug.Print("GraphicsMode: {0}", mode);
Debug.Print("IWindowInfo: {0}", window); Debug.Print("IWindowInfo: {0}", window);
Debug.Print("GraphicsContextFlags: {0}", flags);
Debug.Print("Requested version: {0}.{1}", major, minor);
IGraphicsContext shareContext = null; IGraphicsContext shareContext = null;
if (GraphicsContext.ShareContexts) if (GraphicsContext.ShareContexts)
@ -116,7 +118,11 @@ namespace OpenTK.Graphics
if (designMode) if (designMode)
implementation = new Platform.Dummy.DummyGLContext(); implementation = new Platform.Dummy.DummyGLContext();
else 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) lock (context_lock)
{ {

View file

@ -37,7 +37,7 @@ namespace OpenTK.Platform
{ {
#region Fields #region Fields
static IPlatformFactory implementation; static IPlatformFactory default_implementation, embedded_implementation;
#endregion #endregion
@ -45,10 +45,21 @@ namespace OpenTK.Platform
static Factory() static Factory()
{ {
if (Configuration.RunningOnWindows) implementation = new Windows.WinFactory(); if (Configuration.RunningOnWindows) Default = new Windows.WinFactory();
else if (Configuration.RunningOnX11) implementation = new X11.X11Factory(); else if (Configuration.RunningOnX11) Default = new X11.X11Factory();
else if (Configuration.RunningOnMacOS) implementation = new MacOS.MacOSFactory(); else if (Configuration.RunningOnMacOS) Default = new MacOS.MacOSFactory();
else implementation = new UnsupportedPlatform(); 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 #endregion
@ -57,7 +68,14 @@ namespace OpenTK.Platform
public static IPlatformFactory Default 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 #endregion
@ -67,37 +85,37 @@ namespace OpenTK.Platform
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title,
GraphicsMode mode, GameWindowFlags options, DisplayDevice device) 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) public IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
{ {
return implementation.CreateGLControl(mode, owner); return default_implementation.CreateGLControl(mode, owner);
} }
public IDisplayDeviceDriver CreateDisplayDeviceDriver() 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) 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() public GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext()
{ {
return implementation.CreateGetCurrentGraphicsContext(); return default_implementation.CreateGetCurrentGraphicsContext();
} }
public IGraphicsMode CreateGraphicsMode() public IGraphicsMode CreateGraphicsMode()
{ {
return implementation.CreateGraphicsMode(); return default_implementation.CreateGraphicsMode();
} }
public OpenTK.Input.IKeyboardDriver CreateKeyboardDriver() public OpenTK.Input.IKeyboardDriver CreateKeyboardDriver()
{ {
return implementation.CreateKeyboardDriver(); return default_implementation.CreateKeyboardDriver();
} }
class UnsupportedPlatform : IPlatformFactory class UnsupportedPlatform : IPlatformFactory