Fallback to desktop context if embedded fails
authorStefanos A <stapostol@gmail.com>
Thu, 3 Oct 2013 15:20:17 +0000 (17:20 +0200)
committerStefanos A <stapostol@gmail.com>
Thu, 3 Oct 2013 15:20:17 +0000 (17:20 +0200)
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).

Source/Examples/OpenGLES/2.0/SimpleWindow20.cs

index 66b6e66bd487c7894f51042a32d105a2cfe4a72c..b810b24f0de7c3121f69473c5e74529edcbc2764 100644 (file)
@@ -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);
+                }
             }
         }