How to enable multisampling for OpenGL wxWidgets?

Multisampling is a way to apply Full Screen Smoothing (FSAA) in 3D applications. I need to use multisampling in my OpenGL program, which is currently built into the wxWidgets GUI. Is there any way to do this? Please respond only if you know the detailed steps to achieve this.

I know that you can enable multisampling using WGL (Win32 extensions for OpenGL). However, since my OpenGL program is not written in MFC (and I want the code to be multi-platform portable), this is not an option for me.

+3
source share
1 answer

I finally got Multisampling working with my wxWidgets OpenGL program. It's a bit messy right now, but here's how:

wxWidgets does not support Multisampling in its stable versions (the latest version is currently 2.8.8 ). But it is available as a patch, as well as through a daily snapshot. (The latter is encouraging, as this means that the patch has been adopted and should appear in later stable versions if there are no problems.)

So, there are 2 options:

  • Download and create a patch from your daily snapshot for your wxWidgets work installation.

, , . , Windows, . .

, Windows :

$(WX_WIDGETS_ROOT)/include/wx/glcanvas.h
$(WX_WIDGETS_ROOT)/include/wx/msw/glcanvas.h
$(WX_WIDGETS_ROOT)/src/msw/glcanvas.cpp

wxWidgets.

OpenGL wxWidgets, .

wxGLCanvas:

int attribList[] = {WX_GL_RGBA,
                    WX_GL_DOUBLEBUFFER,
                    WX_GL_SAMPLE_BUFFERS, GL_TRUE, // Multi-sampling
                    WX_GL_DEPTH_SIZE, 16,
                    0, 0};

, GL_SAMPLE_BUFFERS, GL_TRUE. Else, .

wxGLCanvas, :

myGLFrame::myGLFrame    // Derived from wxGLCanvas
(
    wxWindow *parent,
    wxWindowID id,
    const wxPoint& pos,
    const wxSize& size,
    long style,
    const wxString& name
)
: wxGLCanvas(parent, (wxGLCanvas*) NULL, id, pos, size, style, name, attribList)
{
    // ...
}

wxGLCanvas . , OpenGL:

glEnable(GL_MULTISAMPLE);
glDisable(GL_MULTISAMPLE);

OpenGL wxWidgets. , wxWidgets , : -)

+4

Source: https://habr.com/ru/post/1696488/


All Articles