Search code examples
c++qtopenglmultisampling

where is GL_MULTISAMPLE defined?


Although I have been discouraged from reading the OpenGL redbook, I am still doing it, because it is the only book designed for beginners, and tutorials and/or documentation don't quite substitute for a book although very important. So much for justifying myself :)

Now, there's an example for antialiasing using multisampling, which involved glEnable(GL_MULTISAMPLE);

I am using Qt, and I get a compile error, because GL_MULTISAMPLE is an undeclared identifier. I currently see the following reasons:

  • For some implementations, including the one that comes with Qt, GL_MULTISAMPLE is not defined.
  • It is not in GL/gl.h or GL/glu.h but rather in some other header which is not included in <QGLWidget> or does not come with Qt
  • It is obsolete/deprecated

Is one of the above reasons correct? If not, which is the reason I don't have it and how can I obtain? Thanks in advance


Solution

  • GL_MULTISAMPLE is an used to be extension to OpenGL, until 1.3, and whether or not it is implemented depends on your hardware/drivers/vendor implementation. You might actually want to use GL_MULTISAMPLE_ARB instead. If you are on Windows, the platform provided OpenGL headers will not include this macro.

    See also:

    RA's response will simplify extension handling - I prefer the use of GLee myself, but they are pretty much interchangeable (and GLee does lazy init which helped me fix a critical issue on Solaris), but GLEW is kept more up to date (GLee is outdated now that Kos has brought it to my attention.).