Posted by
Matt on
Jan 28, 2011; 2:25pm
URL: https://forum.jogamp.org/New-tutorial-on-AWT-SWT-Swing-GLJPanel-GLCanvas-tp2363921p2366724.html
Wade,
actually it's not even a bug, it's a missing feature that made me LOL when I compared source code for SWT GLCanvas both Linux and Win versions.
Generally, you simply set up multisampling like:
GLData data = new GLData();
data.doubleBuffer = true;
data.depthSize = 24;
data.alphaSize = 8;
data.sampleBuffers = 1; // <------------this
data.samples = 4; // <-------------- this
this.canvas = new GLCanvas(parent, SWT.NONE, data);
you run this under Linux and it works like a charm. Then you run the same code under Windows and no multisampling at all... so you get confused.
You look in the Linux source of GLCanvas and you see in the constructor. There's a glxAttrib array being filled with data from GLData. The very last fields being filled:
if (data.sampleBuffers > 0) {
glxAttrib [pos++] = GLX.GLX_SAMPLE_BUFFERS;
glxAttrib [pos++] = data.sampleBuffers;
}
if (data.samples > 0) {
glxAttrib [pos++] = GLX.GLX_SAMPLES;
glxAttrib [pos++] = data.samples;
}
so... yup, it's working there.
Now you go to Windows implementation of GLCanvas and its constructor. This time we have PIXELFORMATDESCRIPTOR instead of glxAttrib array. But it gets filled with GLData similarly to Linux version. So you scroll down and see this:
//FIXME - use wglChoosePixelFormatARB
// if (data.sampleBuffers > 0) {
// wglAttrib [pos++] = WGL.WGL_SAMPLE_BUFFERS_ARB;
// wglAttrib [pos++] = data.sampleBuffers;
// }
// if (data.samples > 0) {
// wglAttrib [pos++] = WGL.WGL_SAMPLES_ARB;
// wglAttrib [pos++] = data.samples;
// }
and there it is... one big LOL. :-/
No wonder SWT's multisampling isn't working under Windows if its whole >>implementation<< is in fact a commented out code copypasted from Linux impl and marked as FIXME. :-)
I guess the developer responisble for this part gave up Windows multisampling when he realized there's gonna be a bit more work do be done. Later in canvas constructor the WGL.ChoosePixelFormat method is used and it does not support multisampling, one has to use wglChoosePixelFormatARB, and check for this ARB existence at first... it's something like this:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=46I hope this helps :)