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)
{
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 file

@ -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);

View file

@ -52,6 +52,16 @@ namespace Examples.Tutorial
/// <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 file

@ -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);

View file

@ -59,15 +59,15 @@ namespace Examples.Tutorial
/// <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 file

@ -56,15 +56,15 @@ namespace Examples.Tutorial
/// <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 file

@ -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