Corrected version checks in examples. Finally fixes issue [#1898]: "Minor and major OpenGL version incorrect."

This commit is contained in:
the_fiddler 2011-09-06 12:55:19 +00:00
parent 06db92585a
commit f3250baf07
7 changed files with 38 additions and 29 deletions

View file

@ -33,12 +33,12 @@ namespace Examples.Tutorial
protected override void OnLoad(EventArgs e) 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( throw new NotSupportedException(
"Your video card does not support Framebuffer Objects. Please update your drivers.", "GL_EXT_framebuffer_object extension is required. Please update your drivers.");
"FBOs not supported",
System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
Exit(); Exit();
} }

View file

@ -123,8 +123,9 @@ namespace Examples.Tutorial
GL.GenTextures(1, out texture); GL.GenTextures(1, out texture);
GL.BindTexture(Target, texture); GL.BindTexture(Target, texture);
float version = Single.Parse(GL.GetString(StringName.Version).Substring(0, 3), System.Globalization.CultureInfo.InvariantCulture); Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3));
if (version >= 1.4) Version target = new Version(1, 4);
if (version >= target)
{ {
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, (int)All.True); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, (int)All.True);
GL.TexParameter(Target, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); GL.TexParameter(Target, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);

View file

@ -52,6 +52,16 @@ namespace Examples.Tutorial
/// <param name="e">Not used.</param> /// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e) 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.ClearColor(.1f, 0f, .1f, 0f);
GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.DepthTest);

View file

@ -57,14 +57,12 @@ namespace Examples.Tutorial
{ {
base.OnLoad(e); base.OnLoad(e);
string version = GL.GetString(StringName.Version); Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3));
int major = (int)version[0]; Version target = new Version(1, 5);
int minor = (int)version[2]; if (version < target)
if (major <= 1 && minor < 5)
{ {
System.Windows.Forms.MessageBox.Show("You need at least OpenGL 1.5 to run this example. Aborting.", "VBOs not supported", throw new NotSupportedException(String.Format(
System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); "OpenGL {0} is required (you only have {1}).", target, version));
this.Exit();
} }
GL.ClearColor(System.Drawing.Color.MidnightBlue); GL.ClearColor(System.Drawing.Color.MidnightBlue);

View file

@ -59,15 +59,15 @@ namespace Examples.Tutorial
/// <param name="e">Not used.</param> /// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e) protected override void OnLoad(EventArgs e)
{ {
base.OnLoad(e);
// Check for necessary capabilities: // Check for necessary capabilities:
string version = GL.GetString(StringName.Version); Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3));
int major = (int)version[0]; Version target = new Version(2, 0);
int minor = (int)version[2]; if (version < target)
if (major < 2)
{ {
MessageBox.Show("You need at least OpenGL 2.0 to run this example. Aborting.", throw new NotSupportedException(String.Format(
"GLSL not supported", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); "OpenGL {0} is required (you only have {1}).", target, version));
this.Exit();
} }
this.VSync = VSyncMode.On; this.VSync = VSyncMode.On;

View file

@ -56,15 +56,15 @@ namespace Examples.Tutorial
/// <param name="e">Not used.</param> /// <param name="e">Not used.</param>
protected override void OnLoad(EventArgs e) protected override void OnLoad(EventArgs e)
{ {
base.OnLoad(e);
// Check for necessary capabilities: // Check for necessary capabilities:
string version = GL.GetString(StringName.Version); Version version = new Version(GL.GetString(StringName.Version).Substring(0, 3));
int major = (int)version[0]; Version target = new Version(2, 0);
int minor = (int)version[2]; if (version < target)
if (major < 2)
{ {
MessageBox.Show("You need at least OpenGL 2.0 to run this example. Aborting.", "GLSL not supported", throw new NotSupportedException(String.Format(
MessageBoxButtons.OK, MessageBoxIcon.Exclamation); "OpenGL {0} is required (you only have {1}).", target, version));
this.Exit();
} }
GL.ClearColor(Color.MidnightBlue); GL.ClearColor(Color.MidnightBlue);

View file

@ -21,7 +21,7 @@ using System.Text.RegularExpressions;
namespace Examples.WinForms 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 public partial class Extensions : Form
{ {
#region Fields #region Fields