Fallback to desktop context if embedded fails

Starting with OpenGL 4.1 and the ARB_ES2_compatibility extension, desktop contexts can execute OpenGL|ES code. This fallback will allow platforms to execute OpenGL|ES code even if EGL is not available (e.g. Nvidia/Windows).
This commit is contained in:
Stefanos A 2013-10-03 17:20:17 +02:00
parent 94c02e827a
commit 80845315db

View file

@ -23,8 +23,8 @@ namespace Examples.Tutorial
{ {
#region Constructor #region Constructor
public SimpleES20Window() public SimpleES20Window(GraphicsContextFlags flags)
: base(800, 600, new GraphicsMode(16, 16), "", GameWindowFlags.Default, DisplayDevice.Default, 2, 0, GraphicsContextFlags.Embedded) : base(800, 600, new GraphicsMode(16, 16), "", GameWindowFlags.Default, DisplayDevice.Default, 2, 0, flags)
{ } { }
#endregion #endregion
@ -108,10 +108,25 @@ namespace Examples.Tutorial
[STAThread] [STAThread]
public static void Main() public static void Main()
{ {
using (SimpleES20Window example = new SimpleES20Window()) SimpleES20Window example;
try
{ {
Utilities.SetWindowTitle(example); example = new SimpleES20Window(GraphicsContextFlags.Default);
example.Run(30.0, 0.0);
//example = new SimpleES20Window(GraphicsContextFlags.Embedded);
}
catch
{
example = new SimpleES20Window(GraphicsContextFlags.Default);
}
if (example != null)
{
using (example)
{
Utilities.SetWindowTitle(example);
example.Run(30.0, 0.0);
}
} }
} }