No, it is not safe to use OpenGL tokens that a driver knows nothing about. Fortunately, the vast majority of API calls will simply raise a GL_INVALID_ENUM
error and the operation will fail early on before it has a chance to really screw things up.
Solving your GL_LUMINANCE_ALPHA
dilemma is going to take much more than simply swapping in the token GL_RG8
. You will either have to use texture swizzling or swizzling in your shader to make it so that the color of your texture is (R, R, R, G).
Decide which version of OpenGL you are targeting early on, or write separate code paths. But it will never be as simple as switching enum values at run-time.