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:
<QGLWidget>
or does not come with QtIs 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
Since you said you're using Qt's libraries then GLEW etc probably isn't necessary since Qt wraps and binds the extensions for you.
If you're using QGLWidget it's particularly easy. Check this example that ships with Qt and uses GL_MULTISAMPLE
, particularly the glwidget.cpp file which defines:
#ifndef GL_MULTISAMPLE
#define GL_MULTISAMPLE 0x809D
#endif
If you want to customise the FSAA samples, pass your own QGLFormat to the QGLWidget constructor eg:
QGLFormat format;
format.setDoubleBuffer(true);
format.setDepth(false);
format.setAlpha(false);
format.setSampleBuffers(true);
format.setSamples(4);
QGLWidget *glw = new QGLWidget(format);
Change format.setSamples(4)
to your liking. Be sure to add glEnable(GL_MULTISAMPLE)
in your paintGL() function before rendering your scene.
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.).
A library for helping out with extensions http://glew.sourceforge.net/
GL_MULTISAMPLE is defined within glext.h, glext.h is contained inside some linux package: glew, gtkglext or with some opengl driver (have a look here: http://www.opengl.org/registry/#headers).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With