migueltk's picture

Minor and major OpenGL version incorrect.

Project:The Open Toolkit library
Category:bug report

Hi, ...
Checked in the source code for tutorial, "VBOStatic" on the OpenTK 1.0 branch.

For the following code and for versionOpenGL = "3.3.9901":

           string versionOpenGL = GL.GetString(StringName.Version);
            int major = (int)versionOpenGL [0];
            int minor = (int)versionOpenGL [2];

the result is ...
major = 51
minor = 51

I understand that the code should be changed to:

            string versionOpenGL = GL.GetString(StringName.Version);
            int major = int.Parse(versionOpenGL [0].ToString());
            int minor = int.Parse(versionOpenGL [2].ToString());

now the result is ...


Regards, ...


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture


Status:open» confirmed

Thanks, will fix.

c2woody's picture


Also as already noted the version checks are plain wrong, (major <= 1 && minor < 5) for an error out as in this example will fail for a (hypothetical) version 0.9, the check as well as others in the examples should read if (major < 1) || (major == 1 && minor < 5) to check if at least ver 1.5 is available. This is especially relevant for the 3.x and 4.x version checks (the major < 1 doesn't look too interesting in this example...).

dbacher's picture


Actually, what would be better still is:

var x = new Version(GL.GetString(StringName.Version));
var y = new Version(3, 1, 0, 0);
if (x < y)
   MessageBox.Show("I need OpenGL {0:0.0} or newer to run.  Thanks.", y);
the Fiddler's picture


Status:confirmed» fixed

@dbacher: thanks, I wasn't aware of System.Version!

Finally fixed this in trunk r3084. This was long overdue.

the Fiddler's picture


Version:1.x-dev» 1.1-2014-01-02
Status:fixed» closed

Closing bugs fixed in OpenTK 1.1.

If this is still an issue please file a new bug report at https://github.com/opentk/opentk/issues