Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Multisampling under MFC

  1. #1
    Junior Member Regular Contributor
    Join Date
    Oct 2007
    Location
    Phoenix, AZ
    Posts
    109

    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 ?

  2. #2
    Junior Member Regular Contributor
    Join Date
    Oct 2007
    Location
    Phoenix, AZ
    Posts
    109
    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

  3. #3
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,136
    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).

  4. #4
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    17
    Quote Originally Posted by CRasterImage View Post
    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 ?

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •