Multisampling under MFC

I have a MFC app with a standard CView class.
Getting it to work with OpenGL wasn’t difficult.

However, I have now added support for FSAA Multisampling and it isn’t happening.
Everything checks out, but the multisamplling doesn’t happen. (polygons are still jagged)

I am using code taken directly from a sample MFC project that works just fine.

The only difference, that I can see, has to do with when the pixelformat stuff happens.

The sample project does it after calling createwindow.

In my CView, I don’t have that. I have an OnCreate() handler.

What is the right time and place to setup the opengl pixelformat for an MFC CView ?

Me again.

I don’t have the answer, but I understand more of the problem.

After a closer look at the sample code:

if(Wnd.CreateEx(WS_EX_APPWINDOW, WindowClassName, WindowName, Style, 0, 0, Width, Height, NULL, 0) == FALSE)
return FALSE;
if(Wnd.GetOGLWHelper().InitMultiSampleAntiAliasing(16))
{
Wnd.DestroyWindow();

    if(Wnd.CreateEx(WS_EX_APPWINDOW, WindowClassName, WindowName, Style, 0, 0, Width, Height, NULL, 0) == FALSE)
        return FALSE;
}

I noticed that he creates the window twice.
If he successfully can negotiate a multisample pixelformat, he destroys the window and builds it again.
I don’t know if I can do that with a CView

You have to create another window since you need to set pixel format for it in order to create GL rendering context in which you can execute other WGL functions and actually choose pixel format. You should not use the drawing window for the purpose since it is not recommended to set pixel format more than once for the window. Maybe it is the best to use CFrameWnd, if you are using MFC. Just create it with Create(NULL,NULL).

You create a multi-sampling OpenGL device in the same place where a normal OpenGL device is created,
in the CView::OnCreate function.

And you must enable it before you draw something:
glEnable(GL_MULTISAMPLE_ARB);

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.