general code that works the same everywhere?
This. I added another condition to the code that forces forward compatible mode (fc mode = no deprecated functions are loaded). That condition is basically checking a GL3.2 core mask (GL_CONTEXT_PROFILE_MASK) to see if the compatibility profile has been loaded. If either ARB_compatibility or the compatibility profile are available, forward compatible mode isn't forced (the application can still enable it if desirable).
So, the code is general, but parts of it only apply to specific implementations. The driver behavior I've seen so far for the default context creation:
- NVIDIA: ARB_compatibility exposed, GL_CONTEXT_PROFILE_MASK returns 0.
- ATI pre 10.1: ARB_compatibility exposed, retrieving GL_CONTEXT_PROFILE_MASK produces an INVALID_OPERATION error.
- ATI 10.1: ARB_compatibility *not* exposed, GL_CONTEXT_PROFILE_MASK returns GL_CONTEXT_COMPATIBILITY_PROFILE_BIT.