From 80845315db4a4fbf410f43b85bb52fbf5b24f6c6 Mon Sep 17 00:00:00 2001 From: Stefanos A Date: Thu, 3 Oct 2013 17:20:17 +0200 Subject: [PATCH] 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). --- .../Examples/OpenGLES/2.0/SimpleWindow20.cs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Source/Examples/OpenGLES/2.0/SimpleWindow20.cs b/Source/Examples/OpenGLES/2.0/SimpleWindow20.cs index 66b6e66b..b810b24f 100644 --- a/Source/Examples/OpenGLES/2.0/SimpleWindow20.cs +++ b/Source/Examples/OpenGLES/2.0/SimpleWindow20.cs @@ -23,8 +23,8 @@ namespace Examples.Tutorial { #region Constructor - public SimpleES20Window() - : base(800, 600, new GraphicsMode(16, 16), "", GameWindowFlags.Default, DisplayDevice.Default, 2, 0, GraphicsContextFlags.Embedded) + public SimpleES20Window(GraphicsContextFlags flags) + : base(800, 600, new GraphicsMode(16, 16), "", GameWindowFlags.Default, DisplayDevice.Default, 2, 0, flags) { } #endregion @@ -108,10 +108,25 @@ namespace Examples.Tutorial [STAThread] public static void Main() { - using (SimpleES20Window example = new SimpleES20Window()) + SimpleES20Window example; + try { - Utilities.SetWindowTitle(example); - example.Run(30.0, 0.0); + example = new SimpleES20Window(GraphicsContextFlags.Default); + + //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); + } } }