where is GL_MULTISAMPLE defined?
Asked Answered
A

4

7

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

Aliciaalick answered 17/11, 2010 at 17:54 Comment(4)
There are many opengl books besides the red book, most of them are much better for beginners.Folio
@stonemetal: Which would you recommend?Aliciaalick
I'm not sure why people would discourage you from reading it, I think it's an excellent book that gets to the core concepts.Sori
@ Armen Tsirunyan If you just need to learn the API I suggest the OpenGL Super Bible. If you don't know anything about computer graphics and need to know more about the math side of things Computer Graphics Using OpenGL by Hill and KelleyFolio
C
4

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

Chiropodist answered 17/11, 2010 at 18:3 Comment(2)
Umm... That should read "used to be an extension", multisampling's been a part of OpenGL core for a long time now. BTW- is GLee kept up to date now? There are GLEW and GL3W which don't have "lazy inits" but are up-to-date with GL 4.1.Wallenstein
@Wallenstein - thanks for the comment. Looking at GLee, it is way out of date now, but the last time I used it was around the last release of it (late 2009). I replaced GLEW with GLEE specifically because GLEE provided Lazy Init and the software bug I had no time to fix was due to developers creating/destroying/recreating GL Contexts which did not end well on a custom Solaris port. GLEE's lazy init saved the company there. :)Chiropodist
T
6

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.

Tawannatawdry answered 23/2, 2012 at 11:18 Comment(0)
C
4

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

Chiropodist answered 17/11, 2010 at 18:3 Comment(2)
Umm... That should read "used to be an extension", multisampling's been a part of OpenGL core for a long time now. BTW- is GLee kept up to date now? There are GLEW and GL3W which don't have "lazy inits" but are up-to-date with GL 4.1.Wallenstein
@Wallenstein - thanks for the comment. Looking at GLee, it is way out of date now, but the last time I used it was around the last release of it (late 2009). I replaced GLEW with GLEE specifically because GLEE provided Lazy Init and the software bug I had no time to fix was due to developers creating/destroying/recreating GL Contexts which did not end well on a custom Solaris port. GLEE's lazy init saved the company there. :)Chiropodist
S
3

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

Spyglass answered 17/11, 2010 at 17:57 Comment(3)
so, GL_MULTISAMPLE is not in the core OpenGL library?Aliciaalick
Multisampling was added in OpenGL 1.3, your GL-headers are probably only OpenGL 1.1.Riffraff
+1, GLEW is a reliable solution (unless you want to use OpenGL core profile... no idea why the GLEW folks still can't support it properly).Wallenstein
P
1

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

Pibroch answered 17/11, 2010 at 18:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.