Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the documentation for glutInitContextVersion?

The FreeGLUT API documentation does not include an entry for glutInitContextVersion and when I google for it, all I find are a list of questions which don't directly address its usage or effects.

Is it documented anywhere?

like image 942
Nathan Ridley Avatar asked Jan 15 '15 07:01

Nathan Ridley


1 Answers

glutInitContextVersion is not part of the official GLUT API (which is btw. completely outdated), but an unofficial extension added by freeglut. However, its usage is quite straight-forwadd as soon as one knows about how OpenGL's context versions work, which was defined in the ARB_create_context familiy of extensions.

The function will select which OpenGL version is requested when the context is actually created. Note that this does not require the implementation to return a context with exactly the version you are requesting, but it should return one that is compatible to the requested version, so that all features of that version are present.

There are a few things which seem to be undocuemted about freeglut handling this. From looking into the code (for the current stable version 2.8.1), one will see that freeglut implements the following logic: If the implementation cannot fullfill the version constraints, but does support the ARB_create_context extension, it will generate some error and no context will be created. However, if a version is requested, but the implementation does not even support the relevant extensions, a legacy GL context is created, effectively ignoring the version request completely. This seems a bit inconsistent to me. However, as this stuff is not documented and not part of the GLUT spec, it is unclear if the behavior will stay the same in the future or not.

If you don't need some GLUT-specific features (which are basically all relying on deprecated OpenGL anyway), you'll might want to look at some more modern alternatives like GLFW.

like image 155
derhass Avatar answered Nov 15 '22 07:11

derhass