the Fiddler.'s picture

Naming Conventions

One of the nicer features of OpenTK is the use of the enumerants of the official OpenGL specs in the interface. This allows functions like GL.Enable to have an actual list of acceptable values (GL.Enums.EnableCap in this case) instead of plain constant ints, which speeds up development when using a code-completing IDE.

This feature isn't flawless however: for one, typing GL.Enums.EnableCap.DEPTH_TEST is quite a bit longer than just GL.DEPTH_TEST (less of a problem if your IDE auto-completes as you type). It would be nice if the "Enums" part could be dropped (so that you could type GL.EnableCap.DEPTH_TEST), but alas this isn't possible - several enums have the same name as OpenGL functions, resulting in clashes. Moreover, the actual specs weren't actually designed with this use in mind, so several functions, which had their specs changed throughout the years, may miss a few possible parameters (for example, TexImage2D can accept GL_BGRA as a parameter, but this is not defined in the PixelFormat enumerant).

As it seems unlikely that the OpenGL 2.1 specs will be updated once the 3.0 specs are released, I have started rounding off some of these rough edges. A couple of genuine errors were corrected, and several "missing" (from the OpenTK point of view) enums were added, which means that in the next version you will be casting from GL.Enums.All a little less. If you happen across any missing enums please report them so that I can add them in the next version.

On another note, I've added a new function in Bind (the code generator used by OpenTK), which changes OpenGL enums from their ALL_CAPS form to the more .Net-like PascalCase convention. It seems natural in retrospect, but I hadn't thought of it before george mentioned it at the forums. The question is, which should be the default choice? Generating one or the other is as simple as passing a commandline parameter and rebuilding OpenTK (-legacy:enums to be exact), but I don't like the idea of making such a change without at leasy some feedback from actual users of the library.

So what do you think? Obey the .Net naming conventions and break existing programs, leave things as they are, or do something else entirely?

PS: The site has been acting up lately, so copy your post to the clipboard before hitting the submit button, just in case...