Ticket #16402: opengl_context_profiles3.patch

File opengl_context_profiles3.patch, 19.4 KB (added by captainhorst, 4 years ago)

included fix for windows and simple test on the OpenGL cube sample

  • include/wx/glcanvas.h

    From e1f6c06fbd3fddc74e4a050eca869da7a06d056d Mon Sep 17 00:00:00 2001
    From: Fabio Arnold <fabioarnold90@gmail.com>
    Date: Mon, 4 Aug 2014 20:34:47 +0200
    Subject: [PATCH 1/4] added OpenGL context profiles
    
    ---
     include/wx/glcanvas.h     | 12 +++++++++++-
     interface/wx/glcanvas.h   | 26 +++++++++++++++++++++++++-
     src/osx/cocoa/glcanvas.mm | 11 +++++++++++
     3 files changed, 47 insertions(+), 2 deletions(-)
    
    diff --git a/include/wx/glcanvas.h b/include/wx/glcanvas.h
    index 3b60eb0..27e6073 100644
    a b enum 
    4848    WX_GL_MIN_ACCUM_BLUE,  // use blue buffer with most bits (> MIN_ACCUM_BLUE bits)
    4949    WX_GL_MIN_ACCUM_ALPHA, // use alpha buffer with most bits (> MIN_ACCUM_ALPHA bits)
    5050    WX_GL_SAMPLE_BUFFERS,  // 1 for multisampling support (antialiasing)
    51     WX_GL_SAMPLES          // 4 for 2x2 antialiasing supersampling on most graphics cards
     51    WX_GL_SAMPLES,         // 4 for 2x2 antialiasing supersampling on most graphics cards
     52    WX_GL_CONTEXT_MAJOR_VERSION, // Specifies the major version number for the requested OpenGL context
     53    WX_GL_CONTEXT_MINOR_VERSION, // Specifies the minor version number for the requested OpenGL context
     54    WX_GL_CONTEXT_PROFILE_MASK   // Specifies the OpenGL context profile @see wxGL_CONTEXT_PROFILE_FLAGS
     55};
     56
     57// Constants for use with WX_GL_CONTEXT_PROFILE_MASK.
     58enum
     59{
     60    WX_GL_CONTEXT_PROFILE_CORE          = 0x0001, // OpenGL core profile
     61    WX_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002  // OpenGL compatibility profile
    5262};
    5363
    5464#define wxGLCanvasName wxT("GLCanvas")
  • interface/wx/glcanvas.h

    diff --git a/interface/wx/glcanvas.h b/interface/wx/glcanvas.h
    index 49d120e..5f1ce94 100644
    a b enum 
    137137    WX_GL_SAMPLE_BUFFERS,
    138138
    139139    /// 4 for 2x2 antialiasing supersampling on most graphics cards
    140     WX_GL_SAMPLES
     140    WX_GL_SAMPLES,
     141
     142    /// Specifies the major version number for the requested OpenGL context
     143    WX_GL_CONTEXT_MAJOR_VERSION,
     144
     145    /// Specifies the minor version number for the requested OpenGL context
     146    WX_GL_CONTEXT_MINOR_VERSION,
     147
     148    /// Specifies the OpenGL context profile @see wxGL_CONTEXT_PROFILE_FLAGS
     149    WX_GL_CONTEXT_PROFILE_MASK
     150
     151};
     152
     153/**
     154    @anchor wxGL_CONTEXT_PROFILE_FLAGS
     155
     156    Constants for use with WX_GL_CONTEXT_PROFILE_MASK.
     157*/
     158enum
     159{
     160    /// OpenGL core profile
     161    WX_GL_CONTEXT_PROFILE_CORE          = 0x0001,
     162
     163    /// OpenGL compatibility profile
     164    WX_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002
    141165
    142166};
    143167
  • src/osx/cocoa/glcanvas.mm

    diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm
    index e51fd34..5bf75ee 100644
    a b WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) 
    213213                    data[p++] = NSOpenGLPFASamples;
    214214                    data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++];
    215215                    break;
     216
     217                case WX_GL_CONTEXT_PROFILE_MASK:
     218                    if ( attribList[arg++] == WX_GL_CONTEXT_PROFILE_CORE )
     219                    {
     220                        // TODO: check if OS X version is at least 10.7
     221                        data[p++] = NSOpenGLPFAOpenGLProfile;
     222                        // request core profile and version to be at least 3.2
     223                        data[p++] = NSOpenGLProfileVersion3_2Core;
     224                    }
     225
     226                    break;
    216227            }
    217228        }
    218229
  • include/wx/glcanvas.h

    -- 
    1.8.5.2 (Apple Git-48)
    
    
    From 4058c66be48ad4da24ef1f9518d07d6a1654136f Mon Sep 17 00:00:00 2001
    From: Fabio Arnold <fabioarnold90@gmail.com>
    Date: Tue, 5 Aug 2014 02:46:36 +0200
    Subject: [PATCH 2/4] OpenGL core profile for Windows and Linux
    
    ---
     include/wx/glcanvas.h     |   6 +--
     interface/wx/glcanvas.h   |   6 ---
     src/msw/glcanvas.cpp      | 103 +++++++++++++++++++++++++++++++++++++--
     src/osx/cocoa/glcanvas.mm |   4 +-
     src/unix/glx11.cpp        | 121 +++++++++++++++++++++++++++++++++++++++++++++-
     5 files changed, 224 insertions(+), 16 deletions(-)
    
    diff --git a/include/wx/glcanvas.h b/include/wx/glcanvas.h
    index 27e6073..e3e9ff5 100644
    a b enum 
    4949    WX_GL_MIN_ACCUM_ALPHA, // use alpha buffer with most bits (> MIN_ACCUM_ALPHA bits)
    5050    WX_GL_SAMPLE_BUFFERS,  // 1 for multisampling support (antialiasing)
    5151    WX_GL_SAMPLES,         // 4 for 2x2 antialiasing supersampling on most graphics cards
    52     WX_GL_CONTEXT_MAJOR_VERSION, // Specifies the major version number for the requested OpenGL context
    53     WX_GL_CONTEXT_MINOR_VERSION, // Specifies the minor version number for the requested OpenGL context
    54     WX_GL_CONTEXT_PROFILE_MASK   // Specifies the OpenGL context profile @see wxGL_CONTEXT_PROFILE_FLAGS
     52    WX_GL_CONTEXT_PROFILE_MASK   // Specifies the OpenGL context profile @see wxGL_CONTEXT_PROFILE_FLAGS @since 3.1.0
    5553};
    5654
    57 // Constants for use with WX_GL_CONTEXT_PROFILE_MASK.
     55// Constants for use with WX_GL_CONTEXT_PROFILE_MASK @since 3.1.0
    5856enum
    5957{
    6058    WX_GL_CONTEXT_PROFILE_CORE          = 0x0001, // OpenGL core profile
  • interface/wx/glcanvas.h

    diff --git a/interface/wx/glcanvas.h b/interface/wx/glcanvas.h
    index 5f1ce94..8a92d37 100644
    a b enum 
    139139    /// 4 for 2x2 antialiasing supersampling on most graphics cards
    140140    WX_GL_SAMPLES,
    141141
    142     /// Specifies the major version number for the requested OpenGL context
    143     WX_GL_CONTEXT_MAJOR_VERSION,
    144 
    145     /// Specifies the minor version number for the requested OpenGL context
    146     WX_GL_CONTEXT_MINOR_VERSION,
    147 
    148142    /// Specifies the OpenGL context profile @see wxGL_CONTEXT_PROFILE_FLAGS
    149143    WX_GL_CONTEXT_PROFILE_MASK
    150144
  • src/msw/glcanvas.cpp

    diff --git a/src/msw/glcanvas.cpp b/src/msw/glcanvas.cpp
    index 7beb05c..e102893 100644
    a b LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, 
    4545#endif
    4646
    4747// ----------------------------------------------------------------------------
    48 // define possibly missing WGL constants
     48// define possibly missing WGL constants and types
    4949// ----------------------------------------------------------------------------
    5050
    5151#ifndef WGL_ARB_pixel_format
    LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, 
    7676#define WGL_SAMPLES_ARB                   0x2042
    7777#endif
    7878
     79#ifndef WGL_ARB_create_context
     80#define WGL_ARB_create_context
     81#define WGL_CONTEXT_MAJOR_VERSION_ARB   0x2091
     82#define WGL_CONTEXT_MINOR_VERSION_ARB   0x2092
     83#define WGL_CONTEXT_LAYER_PLANE_ARB     0x2093
     84#define WGL_CONTEXT_FLAGS_ARB           0x2094
     85#define WGL_CONTEXT_DEBUG_BIT_ARB       0x0001
     86#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB  0x0002
     87
     88#ifndef WGL_ARB_create_context_profile
     89#define WGL_ARB_create_context_profile
     90#define WGL_CONTEXT_PROFILE_MASK_ARB              0x9126
     91#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB          0x00000001
     92#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
     93#endif
     94
     95#ifndef WGL_ARB_create_context_robustness
     96#define WGL_ARB_create_context_robustness
     97#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB         0x00000004
     98#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB     0x8256
     99#define WGL_NO_RESET_NOTIFICATION_ARB                   0x8261
     100#define WGL_LOSE_CONTEXT_ON_RESET_ARB                   0x8252
     101#endif
     102#endif
     103
     104#ifndef WGL_EXT_create_context_es2_profile
     105#define WGL_EXT_create_context_es2_profile
     106#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT           0x00000004
     107#endif
     108
     109#ifndef WGL_EXT_create_context_es_profile
     110#define WGL_EXT_create_context_es_profile
     111#define WGL_CONTEXT_ES_PROFILE_BIT_EXT            0x00000004
     112#endif
     113
     114#ifndef WGL_ARB_framebuffer_sRGB
     115#define WGL_ARB_framebuffer_sRGB
     116#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB                0x20A9
     117#endif
     118
     119typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC)
     120    (HDC hDC, HGLRC hShareContext, const int *attribList);
     121
    79122// ----------------------------------------------------------------------------
    80123// libraries
    81124// ----------------------------------------------------------------------------
    LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, 
    108151
    109152IMPLEMENT_CLASS(wxGLContext, wxObject)
    110153
     154// This is ugly. It would be nicer to be able to pass context flags
     155// and the context profile as an argument. Right now context (flags and)
     156// profile are specified in the context pixelformat.
     157// The window will always be created first so the array will be initialized
     158// and then the window will be assigned to the context.
     159// max 8 attributes plus terminator
     160// if first is 0, create legacy context
     161static int s_wglContextAttribs[9] = {0};
     162
    111163wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext* other)
    112164{
    113     m_glContext = wglCreateContext(win->GetHDC());
    114     wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGL context") );
     165    if ( s_wglContextAttribs[0] == 0 ) // create legacy context
     166    {
     167        m_glContext = wglCreateContext(win->GetHDC());
     168        wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGL context") );
     169    }
     170    else // create a context using attributes
     171    {
     172        // We need to create a temporary context to get the
     173        // wglCreateContextAttribsARB function
     174        HGLRC tempContext = wglCreateContext(win->GetHDC());
     175        wxCHECK_RET( tempContext, wxT("Couldn't create OpenGL context") );
     176        wglMakeCurrent(win->GetHDC(), tempContext);
     177        PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB
     178            = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
     179            wglGetProcAddress("wglCreateContextAttribsARB");
     180        wglMakeCurrent(win->GetHDC(), NULL);
     181        wglDeleteContext(tempContext);
     182
     183        wxCHECK_RET( wglCreateContextAttribsARB,
     184            wxT("OpenGL 3.x is not supported") );
     185       
     186        m_glContext = wglCreateContextAttribsARB(
     187            win->GetHDC(), 0, s_wglContextAttribs);
     188        wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGL context") );
     189    }
    115190
    116191    if ( other )
    117192    {
    bool wxGLCanvas::Create(wxWindow *parent, 
    235310    if ( !CreateWindow(parent, id, pos, size, style, name) )
    236311        return false;
    237312
     313    // Find out whether a core profile is requested
     314    bool useCoreProfile = false;
     315    for ( int i = 0; attribList[i]; i++ )
     316    {
     317        if ( attribList[i] == WX_GL_CONTEXT_PROFILE_MASK && attribList[i+1] == WX_GL_CONTEXT_PROFILE_CORE )
     318        {
     319            useCoreProfile = true;
     320            break;
     321        }
     322    }
     323
     324    if ( useCoreProfile )
     325    {
     326        s_wglContextAttribs[0] = WGL_CONTEXT_PROFILE_MASK_ARB;
     327        s_wglContextAttribs[1] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
     328        s_wglContextAttribs[2] = 0; // terminate
     329    }
     330    else
     331    {
     332        s_wglContextAttribs[0] = 0; // create legacy context
     333    }
     334
    238335    PIXELFORMATDESCRIPTOR pfd;
    239336    const int setupVal = DoSetup(pfd, attribList);
    240337    if ( setupVal == 0 ) // PixelFormat error
  • src/osx/cocoa/glcanvas.mm

    diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm
    index 5bf75ee..62f39fe 100644
    a b WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) 
    217217                case WX_GL_CONTEXT_PROFILE_MASK:
    218218                    if ( attribList[arg++] == WX_GL_CONTEXT_PROFILE_CORE )
    219219                    {
    220                         // TODO: check if OS X version is at least 10.7
    221220                        data[p++] = NSOpenGLPFAOpenGLProfile;
    222                         // request core profile and version to be at least 3.2
     221                        // request an OpenGL core profile
     222                        // the OpenGL version will be at least 3.2
    223223                        data[p++] = NSOpenGLProfileVersion3_2Core;
    224224                    }
    225225
  • src/unix/glx11.cpp

    diff --git a/src/unix/glx11.cpp b/src/unix/glx11.cpp
    index ec2bd5b..eb2e13e 100644
    a b  
    3636    #endif
    3737#endif // __SGI__
    3838
     39// ----------------------------------------------------------------------------
     40// define possibly missing XGL constants and types
     41// ----------------------------------------------------------------------------
     42
     43#ifndef GLX_NONE_EXT
     44#define GLX_NONE_EXT                       0x8000
     45#endif
     46
     47#ifndef GLX_ARB_multisample
     48#define GLX_ARB_multisample
     49#define GLX_SAMPLE_BUFFERS_ARB             100000
     50#define GLX_SAMPLES_ARB                    100001
     51#endif
     52
     53#ifndef GLX_EXT_visual_rating
     54#define GLX_EXT_visual_rating
     55#define GLX_VISUAL_CAVEAT_EXT              0x20
     56#define GLX_NONE_EXT                       0x8000
     57#define GLX_SLOW_VISUAL_EXT                0x8001
     58#define GLX_NON_CONFORMANT_VISUAL_EXT      0x800D
     59#endif
     60
     61#ifndef GLX_EXT_visual_info
     62#define GLX_EXT_visual_info
     63#define GLX_X_VISUAL_TYPE_EXT              0x22
     64#define GLX_DIRECT_COLOR_EXT               0x8003
     65#endif
     66
     67#ifndef GLX_ARB_create_context
     68#define GLX_ARB_create_context
     69#define GLX_CONTEXT_MAJOR_VERSION_ARB      0x2091
     70#define GLX_CONTEXT_MINOR_VERSION_ARB      0x2092
     71#define GLX_CONTEXT_FLAGS_ARB              0x2094
     72#define GLX_CONTEXT_DEBUG_BIT_ARB          0x0001
     73#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
     74
     75/* Typedef for the GL 3.0 context creation function */
     76typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC)
     77    (Display * dpy, GLXFBConfig config, GLXContext share_context,
     78    Bool direct, const int *attrib_list);
     79#endif
     80
     81#ifndef GLX_ARB_create_context_profile
     82#define GLX_ARB_create_context_profile
     83#define GLX_CONTEXT_PROFILE_MASK_ARB       0x9126
     84#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB   0x00000001
     85#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
     86#endif
     87
     88#ifndef GLX_ARB_create_context_robustness
     89#define GLX_ARB_create_context_robustness
     90#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB  0x00000004
     91#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB     0x8256
     92#define GLX_NO_RESET_NOTIFICATION_ARB                   0x8261
     93#define GLX_LOSE_CONTEXT_ON_RESET_ARB                   0x8252
     94#endif
     95
     96#ifndef GLX_EXT_create_context_es2_profile
     97#define GLX_EXT_create_context_es2_profile
     98#ifndef GLX_CONTEXT_ES2_PROFILE_BIT_EXT
     99#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT    0x00000002
     100#endif
     101#endif
     102
     103#ifndef GLX_ARB_framebuffer_sRGB
     104#define GLX_ARB_framebuffer_sRGB
     105#ifndef GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB
     106#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB                0x20B2
     107#endif
     108#endif
     109
     110
    39111// ============================================================================
    40112// wxGLContext implementation
    41113// ============================================================================
    42114
    43115IMPLEMENT_CLASS(wxGLContext, wxObject)
    44116
     117// This is ugly. It would be nicer to be able to pass context flags
     118// and the context profile as an argument. Right now context (flags and)
     119// profile are specified in the context pixelformat.
     120// The window will always be created first so the array will be initialized
     121// and then the window will be assigned to the context.
     122// max 8 attributes plus terminator
     123// if first is 0, create legacy context
     124static int s_glxContextAttribs[9] = {0};
     125
    45126wxGLContext::wxGLContext(wxGLCanvas *gc, const wxGLContext *other)
    46127{
    47     if ( wxGLCanvas::GetGLXVersion() >= 13 )
     128    if ( s_glxContextAttribs[0] != 0 ) // OpenGL 3 context creation
     129    {
     130        XVisualInfo *vi = gc->GetXVisualInfo();
     131        wxCHECK_RET( vi, wxT("invalid visual for OpenGL") );
     132
     133        // We need to create a temporary context to get the
     134        // glXCreateContextAttribsARB function
     135        GLXContext tempContext = glXCreateContext( wxGetX11Display(), vi,
     136                                                   NULL,
     137                                                   GL_TRUE );
     138        wxCHECK_RET( tempContext, wxT("Couldn't create OpenGL context") );
     139
     140        PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB
     141            = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
     142            glXGetProcAddress((GLubyte *)"glXCreateContextAttribsARB");
     143        wxCHECK_RET( glXCreateContextAttribsARB,
     144            wxT("OpenGL 3.x is not supported") );
     145
     146        GLXFBConfig *fbc = gc->GetGLXFBConfig();
     147        wxCHECK_RET( fbc, wxT("invalid GLXFBConfig for OpenGL") );
     148
     149        m_glContext = glXCreateContextAttribsARB( wxGetX11Display(), fbc[0],
     150            other ? other->m_glContext : None,
     151            s_glxContextAttribs );
     152
     153        glXDestroyContext( wxGetX11Display(), tempContext );
     154    }
     155    else if ( wxGLCanvas::GetGLXVersion() >= 13 )
    48156    {
    49157        GLXFBConfig *fbc = gc->GetGLXFBConfig();
    50158        wxCHECK_RET( fbc, wxT("invalid GLXFBConfig for OpenGL") );
    wxGLCanvasX11::ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n) 
    170278          old version but must be followed by True or False in the new one.
    171279     */
    172280
     281    s_glxContextAttribs[0] = 0; // default is legacy context
     282
    173283    if ( !wxattrs )
    174284    {
    175285        size_t i = 0;
    wxGLCanvasX11::ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n) 
    315425
    316426                    return false;
    317427
     428                case WX_GL_CONTEXT_PROFILE_MASK:
     429                    if ( wxattrs[arg++] == WX_GL_CONTEXT_PROFILE_CORE )
     430                    {
     431                        s_glxContextAttribs[0] = GLX_CONTEXT_PROFILE_MASK_ARB;
     432                        s_glxContextAttribs[1] = GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
     433                        s_glxContextAttribs[2] = 0;
     434                    }
     435                    break;
     436
    318437                default:
    319438                    wxLogDebug(wxT("Unsupported OpenGL attribute %d"),
    320439                               wxattrs[arg - 1]);
  • src/msw/glcanvas.cpp

    -- 
    1.8.5.2 (Apple Git-48)
    
    
    From 6fcff7022f9f835f280e587a84c4ef0d7a26475e Mon Sep 17 00:00:00 2001
    From: Fabio Arnold <fabioarnold90@gmail.com>
    Date: Tue, 5 Aug 2014 22:44:01 +0200
    Subject: [PATCH 3/4] opengl core profile fixed windows platform
    
    ---
     src/msw/glcanvas.cpp | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/src/msw/glcanvas.cpp b/src/msw/glcanvas.cpp
    index e102893..3f9480c 100644
    a b LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, 
    116116#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB                0x20A9
    117117#endif
    118118
    119 typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC)
     119typedef HGLRC(WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)
    120120    (HDC hDC, HGLRC hShareContext, const int *attribList);
    121121
    122122// ----------------------------------------------------------------------------
  • samples/opengl/cube/cube.cpp

    -- 
    1.8.5.2 (Apple Git-48)
    
    
    From 7b9e9bbe5d640897c14c41fdc8a233c720c279ed Mon Sep 17 00:00:00 2001
    From: Fabio Arnold <fabioarnold90@gmail.com>
    Date: Tue, 5 Aug 2014 22:44:34 +0200
    Subject: [PATCH 4/4] added core profile to opengl cube sample for easier
     testing
    
    ---
     samples/opengl/cube/cube.cpp | 5 +++--
     1 file changed, 3 insertions(+), 2 deletions(-)
    
    diff --git a/samples/opengl/cube/cube.cpp b/samples/opengl/cube/cube.cpp
    index a716c35..4f8008e 100644
    a b wxEND_EVENT_TABLE() 
    461461MyFrame::MyFrame( bool stereoWindow )
    462462       : wxFrame(NULL, wxID_ANY, wxT("wxWidgets OpenGL Cube Sample"))
    463463{
    464     int stereoAttribList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_STEREO, 0 };
     464    int attribList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_CONTEXT_PROFILE_MASK, WX_GL_CONTEXT_PROFILE_CORE, 0};
     465    int stereoAttribList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_STEREO, WX_GL_CONTEXT_PROFILE_MASK, WX_GL_CONTEXT_PROFILE_CORE, 0 };
    465466
    466     new TestGLCanvas(this, stereoWindow ? stereoAttribList : NULL);
     467    new TestGLCanvas(this, stereoWindow ? stereoAttribList : attribList);
    467468
    468469    SetIcon(wxICON(sample));
    469470