diff --git a/Source/Examples/OpenGL/1.x/FramebufferObject.cs b/Source/Examples/OpenGL/1.x/FramebufferObject.cs index 00b50762..c4bd9f2b 100644 --- a/Source/Examples/OpenGL/1.x/FramebufferObject.cs +++ b/Source/Examples/OpenGL/1.x/FramebufferObject.cs @@ -33,12 +33,12 @@ namespace Examples.Tutorial protected override void OnLoad(EventArgs e) { - if (!GL.GetString(StringName.Extensions).Contains("EXT_framebuffer_object")) + base.OnLoad(e); + + if (!GL.GetString(StringName.Extensions).Contains("GL_EXT_framebuffer_object")) { - System.Windows.Forms.MessageBox.Show( - "Your video card does not support Framebuffer Objects. Please update your drivers.", - "FBOs not supported", - System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); + throw new NotSupportedException( + "GL_EXT_framebuffer_object extension is required. Please update your drivers."); Exit(); } diff --git a/Source/Examples/OpenGL/1.x/TextureMatrix.cs b/Source/Examples/OpenGL/1.x/TextureMatrix.cs index 464c305c..749b4318 100644 --- a/Source/Examples/OpenGL/1.x/TextureMatrix.cs +++ b/Source/Examples/OpenGL/1.x/TextureMatrix.cs @@ -123,8 +123,9 @@ namespace Examples.Tutorial GL.GenTextures(1, out texture); GL.BindTexture(Target, texture); - float version = Single.Parse(GL.GetString(StringName.Version).Substring(0, 3), System.Globalization.CultureInfo.InvariantCulture); - if (version >= 1.4) + Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3)); + Version target = new Version(1, 4); + if (version >= target) { GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, (int)All.True); GL.TexParameter(Target, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); diff --git a/Source/Examples/OpenGL/1.x/VBODynamic.cs b/Source/Examples/OpenGL/1.x/VBODynamic.cs index 45e8f320..9e5752e0 100644 --- a/Source/Examples/OpenGL/1.x/VBODynamic.cs +++ b/Source/Examples/OpenGL/1.x/VBODynamic.cs @@ -52,6 +52,16 @@ namespace Examples.Tutorial /// Not used. protected override void OnLoad(EventArgs e) { + base.OnLoad(e); + + Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3)); + Version target = new Version(1, 5); + if (version < target) + { + throw new NotSupportedException(String.Format( + "OpenGL {0} is required (you only have {1}).", target, version)); + } + GL.ClearColor(.1f, 0f, .1f, 0f); GL.Enable(EnableCap.DepthTest); diff --git a/Source/Examples/OpenGL/1.x/VBOStatic.cs b/Source/Examples/OpenGL/1.x/VBOStatic.cs index 4bf3bdff..4e378177 100644 --- a/Source/Examples/OpenGL/1.x/VBOStatic.cs +++ b/Source/Examples/OpenGL/1.x/VBOStatic.cs @@ -57,14 +57,12 @@ namespace Examples.Tutorial { base.OnLoad(e); - string version = GL.GetString(StringName.Version); - int major = (int)version[0]; - int minor = (int)version[2]; - if (major <= 1 && minor < 5) + Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3)); + Version target = new Version(1, 5); + if (version < target) { - System.Windows.Forms.MessageBox.Show("You need at least OpenGL 1.5 to run this example. Aborting.", "VBOs not supported", - System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); - this.Exit(); + throw new NotSupportedException(String.Format( + "OpenGL {0} is required (you only have {1}).", target, version)); } GL.ClearColor(System.Drawing.Color.MidnightBlue); diff --git a/Source/Examples/OpenGL/2.x/JuliaSetFractal.cs b/Source/Examples/OpenGL/2.x/JuliaSetFractal.cs index b63c5ca3..57ea5e7c 100644 --- a/Source/Examples/OpenGL/2.x/JuliaSetFractal.cs +++ b/Source/Examples/OpenGL/2.x/JuliaSetFractal.cs @@ -59,15 +59,15 @@ namespace Examples.Tutorial /// Not used. protected override void OnLoad(EventArgs e) { + base.OnLoad(e); + // Check for necessary capabilities: - string version = GL.GetString(StringName.Version); - int major = (int)version[0]; - int minor = (int)version[2]; - if (major < 2) + Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3)); + Version target = new Version(2, 0); + if (version < target) { - MessageBox.Show("You need at least OpenGL 2.0 to run this example. Aborting.", - "GLSL not supported", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - this.Exit(); + throw new NotSupportedException(String.Format( + "OpenGL {0} is required (you only have {1}).", target, version)); } this.VSync = VSyncMode.On; diff --git a/Source/Examples/OpenGL/2.x/SimpleGLSL.cs b/Source/Examples/OpenGL/2.x/SimpleGLSL.cs index da7d06fd..d0e37fe6 100644 --- a/Source/Examples/OpenGL/2.x/SimpleGLSL.cs +++ b/Source/Examples/OpenGL/2.x/SimpleGLSL.cs @@ -56,15 +56,15 @@ namespace Examples.Tutorial /// Not used. protected override void OnLoad(EventArgs e) { + base.OnLoad(e); + // Check for necessary capabilities: - string version = GL.GetString(StringName.Version); - int major = (int)version[0]; - int minor = (int)version[2]; - if (major < 2) + Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3)); + Version target = new Version(2, 0); + if (version < target) { - MessageBox.Show("You need at least OpenGL 2.0 to run this example. Aborting.", "GLSL not supported", - MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - this.Exit(); + throw new NotSupportedException(String.Format( + "OpenGL {0} is required (you only have {1}).", target, version)); } GL.ClearColor(Color.MidnightBlue); diff --git a/Source/Examples/OpenTK/Test/Extensions.cs b/Source/Examples/OpenTK/Test/Extensions.cs index a9ad6aea..b6f4c2c7 100644 --- a/Source/Examples/OpenTK/Test/Extensions.cs +++ b/Source/Examples/OpenTK/Test/Extensions.cs @@ -21,7 +21,7 @@ using System.Text.RegularExpressions; namespace Examples.WinForms { - [Example("OpenGL Extensions", ExampleCategory.OpenTK, "Test", Documentation="Extensions")] + [Example("OpenGL Extensions", ExampleCategory.OpenTK, "Test", Documentation="Extensions", Visible = false)] public partial class Extensions : Form { #region Fields