Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 910
Armen Tsirunyan Avatar asked Nov 17 '10 17:11

Armen Tsirunyan


4 Answers

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.

like image 199
ʀᴏʙ Avatar answered Nov 15 '22 13:11

ʀᴏʙ


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:

  • http://www.opengl.org/resources/faq/technical/extensions.htm
  • http://www.gamedev.net/community/forums/topic.asp?topic_id=536666

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.).

like image 20
逆さま Avatar answered Nov 15 '22 11:11

逆さま


A library for helping out with extensions http://glew.sourceforge.net/

like image 3
ROAR Avatar answered Nov 15 '22 13:11

ROAR


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).

like image 1
angleto Avatar answered Nov 15 '22 11:11

angleto