Soundbomber's picture

Windows 7

I have done an install of my app on a new windows 7 machine and am getting an InvalidEnum error.
The app was developed using OpenTK 0.9.8.
Are there any known issues regarding the version of OpenGL installed on the client machine and its compatibility with OpenTK 0.9.8?


Comments

Comment viewing options

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

There are many reasons why an InvalidEnum may occur and the quickest way to understand the error is to look up the ailing function on the OpenGL reference pages.

Judging from opengl.org, the most common issue on Windows 7 is that users forget to install OpenGL drivers. Windows will install DirectX drivers automatically but will only emulate OpenGL over GDI or DirectX. However, this emulation layer supports only OpenGL 1.1 (GDI) or 1.4 (DirectX) and trying to use newer features, like VBO, will result in an error. Of course, drivers downloaded from the IHV's (nvidia.com, ati.com, intel.com) or from the manufacturer's website (dell, HP, etc) will bypass the emulator layer and provide better performance and features.

If possible, I would suggest checking GL.GetString(StringName.Vendor) and displaying a warning if it contains "Microsoft Corporation". You should also check that all necessary extensions are available before trying to use them (for example, VBOs require ARB_vertex_buffer_object or GL version 1.5, FBOs require EXT_framebuffer_object or GL version 3.0 and so on.)

Note that OpenTK 0.9.8 has not been tested on Windows 7 at all. It should work, but the first version to officially support Windows 7 is 1.0-beta-2. If possible, I would suggest upgrading to the latest release.

Soundbomber's picture

OK, firstly thank you for the response.
The vendor name shows as "Intel" and I have the latest Intel drivers installed, and I am now working with OpenTK 1.0-beta-3. Still get the InvalidEnum error. I have had a look on the OpenGL forums and can't find anything relevant.
Fiddler you mention checking that all neccessary extensions are available - How do I achieve this (sorry if that is a dumb question!).
For info the error occurs when I call GL.Enable(EnableCap.VertexArray)

the Fiddler's picture

In that case, the error is right: the correct method is GL.EnableClientState(ArrayCap.VertexArray). Personally, I would suggest avoiding vertex arrays completely: vertex buffer objects are faster and safer to use under .Net. (The issue with VAs is that the data store is your responsibility, which means you have to guard it against the garbage collector. VBOs store the data in video memory, which is both faster and safer.)

In OpenGL 1.x, 2.x and 3.x with the compatibility profile, you can check for extension support using:

string[] extensions = GL.GetString(StringName.Extensions).Split(' ');
if (Array.IndexOf(ext, "GL_ARB_vertex_buffer_object") != -1)
{
    // ARB VBOs are supported
}

Moreover, every version of OpenGL moves a number of extensions into core. For example, OpenGL 1.5 introduced vertex buffer objects:

float version = Single.Parse(
    GL.GetString(StringName.Version).Substring(0, 3),
    System.Globalization.CultureInfo.InvariantCulture);
if (version >= 1.5)
{
    // VBOs are supported in core. No need to check for "GL_ARB_vertex_buffer_object"
}

As a rule of thumb, core functions reside in GL., while extension functions live in GL.Arb., GL.Ext., GL.NV., etc. However, some extensions may modify the behavior of core functions (for example, ARB_vertex_buffer_object changes how GL.BufferData works when a VBO is bound - read the extension spec for more information).

Soundbomber's picture

Thanks Fiddler, using GL.EnableClientState(ArrayCap.VertexArray) solved my problem.