Question

For instance, I'm using GL_LUMINANCE_ALPHA to transfer two component data to texture. Someone told me that some internal format constants like GL_LUMINACE_ALPHA are deprecated in OpenGL 3.0(maybe 4.0?) or higher, so use GL_RG or GL_RG8, etc.

However, my target OpenGL version is 2.0 or higher and the specification of OpenGL 2.0 does not contain GL_RG/GL_RG8. In this case, I think there are three possibilities:

  1. Use GL_RG/GL_RG8 if the program can run well even with devices which supports OpenGL 2.0 only.
  2. Keep old constants if the program can run well with devices whose OpenGL version is so high that old constants are deprecated.
  3. Detect the OpenGL version in run-time and swtich the constants for each version.

What should I choose? I don't want to take 3. unless I have to because it makes things harder and complicated.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top