Multisample window isn't?

Hi again. :slight_smile:

I’ve created a window with GL3.2 context and I -think- I’ve done everything right to make it a multisampling window, however it isn’t.

Here’s what I do:


1. Create the window, CreateWindow(...)
2. Create a 2.1 context:
 - set PIXELFORMATDESCRIPTOR named pfd
 - int format = ChoosePixelFormat( hDC, &pfd )
 - SetPixelFormat( hDC, format, &pfd )
 - HGLRC tmpRC = wglCreateContext( hDC )
 - wglMakeCurrent( hDC, tmpRC )
3. Initialise GLEW
4. Ask wgl for an extended pixel format:
 int pfAttribs[] =
 {
    WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
    WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
    WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
    WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, GL_TRUE,
    WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
    WGL_COLOR_BITS_ARB, 32,
    WGL_DEPTH_BITS_ARB, 24,
    WGL_STENCIL_BITS_ARB, 8,
    WGL_SAMPLE_BUFFERS_ARB, 1,
    WGL_SAMPLES_ARB, 8,
    0
  };

  int formatEx;
  UINT numFormats = 0;
  wglChoosePixelFormatARB( hDC, pfAttribs, NULL, 1, &formatEx, &numFormats );
  if( numFormats > 0 )
    SetPixelFormat( hDC, formatEx, &pfd );
5. Continue by creating a 3.2 context and making it current then at last show the window.
6. In init: glEnable( GL_MULTISAMPLE )

I’ve stepped through the above code and the format returned by wglChoosePixelFormatARB is 45 which, according to OpenGL Extensions Viewer is a pixel format with all the features I’ve requested, including WGL_SAMPLES_ARB = 8.

Later on in the code in my GL init function I check the value of GL_SAMPLES with glGetIntegerv and it is zero, and objects are noticeably not multisampled.

Any ideas?

You can only call ‘SetPixelFormat()’ once per window (see remarks of http://msdn.microsoft.com/en-us/library/dd369049(VS.85).aspx). So you need to create a temp window for format enum stuff…

Ah, I see. Argh, that’ll mean a bit of restructuring. Oh well.

Thanks!