Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Corrected version checks in examples. Finally fixes issue [#1898]: "M…

…inor and major OpenGL version incorrect."

git-svn-id: https://opentk.svn.sourceforge.net/svnroot/opentk/trunk@3084 ebc5dd9b-fb1d-0410-b6f8-d24c324e9604
  • Loading branch information...
commit 7743e48950cf42bd4104ae0ff534848c30fb0da2 1 parent ab7e6e6
the_fiddler authored
View
10 Source/Examples/OpenGL/1.x/FramebufferObject.cs
@@ -33,12 +33,12 @@ public SimpleFBO()
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();
}
View
5 Source/Examples/OpenGL/1.x/TextureMatrix.cs
@@ -123,8 +123,9 @@ public static int LoadTexture(string filename)
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);
View
10 Source/Examples/OpenGL/1.x/VBODynamic.cs
@@ -52,6 +52,16 @@ struct ParticleAttribut
/// <param name="e">Not used.</param>
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);
View
12 Source/Examples/OpenGL/1.x/VBOStatic.cs
@@ -57,14 +57,12 @@ protected override void OnLoad(EventArgs e)
{
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);
View
14 Source/Examples/OpenGL/2.x/JuliaSetFractal.cs
@@ -59,15 +59,15 @@ public JuliaSetFractal()
/// <param name="e">Not used.</param>
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;
View
14 Source/Examples/OpenGL/2.x/SimpleGLSL.cs
@@ -56,15 +56,15 @@ public T10_GLSL_Cube()
/// <param name="e">Not used.</param>
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);
View
2  Source/Examples/OpenTK/Test/Extensions.cs
@@ -21,7 +21,7 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.