Can the OpenGL 'deprecated' functions possibly be unsupported?

731 views Asked by At

I am testing with glDrawPixels to port my simple pixel-drawn 2D game from Windows API to OpenGL with GLFW. It runs nicely with FPS over 100, additionally cross-platform.

Just one thing that is slightly annoying me is that I'm using a deprecated feature. I don't see any problems now, but will this possibly be a problem in the future? Can glDrawPixels become suddenly removed? All I need is a cross-platform alternative to winapi's CreateWindow and BitBlt.

1

There are 1 answers

0
derhass On BEST ANSWER

I'd like to extend on the article about deprecation in the OpenGL wiki which was given in the comments already.

The current situation is that we can discern 3 "flavours" of OpenGL contexts on desktop platforms:

  1. "Legacy" GL. This means the GL from the old days, before there was any deprecation scheme, and before there were specifically versioned contexts or profiles.
  2. "Modern" GL in the core profile.
  3. "Modern" GL in the compatibility profile.

The first case, "legacy" GL, is limited to GL 2.1 and earlier in a cross-platform manner. All major desktop OS (Windows, Linux, OSX) have support for this on all major GPU brands (Intel, NVidia, AMD). And this is unlikely to go away for a long time, since all of the "old" software that is not even aware of the existence of modern GL relies on it.

What I describe as "modern" GL means GL 3.2 and later. And there, profiles have been invented. The crux is that only the core profile is required to be supported, the compatibility profile is optional. In core profiles, the deprecated functions are actually removed, so your code will not work in a core profile. In compatibility profiles, the deprecated functions are still available.

So, the only way to mix old legacy features (like fixed-function pipeline, immediate mode, or your glDrawPixels call) with modern GL features, is a compatibility profile. However, in practice, compatibility support is not generally available. MacOSX generally does not support compatibility profiles, and neither do the open source Linux drivers based on Mesa. So you can't really do cross-platform development with a compatibility profile.

Note that I somehow skipped GL 3.0 and 3.1. They are something in between and I recommend never trying to use them. OSX does not support them at all. And actually, any real world GPU which supports GL 3.0 also supports at least GL 3.2 anyway.

I see two options for you:

  1. If the feature set in GL 2.1 is enough for your use case, you can simply stick to legacy GL. Support for it won't go away for a long time.
  2. Switch to modern GL without use of deprecated functions. glDrawPixels has never been efficient. You are probably far better using a textured quad (or maybe even glBlitFramebuffer) for blitting images to the screen.