2016-12-14 4 views
3

Кто-нибудь знает, хорошо ли работает библиотека WxWidgets с современным шейдерным стилем openGL (3.3+)? Все, что я нашел, похоже, использует старый стиль. Я ищу использовать QT или WxWidgets для своего приложения, но похоже, что заставить шейдерный материал работать с виджетами может быть кошмаром. У кого-нибудь есть опыт?WxWidgets и современный opengl (3.3+)

ответ

4

В WxWidgets> = 3.1 с использованием wxGLContext с соответствующим Core-контексте wxGLContextAttrs должен работать:

wxGLContextAttrs cxtAttrs; 
cxtAttrs.CoreProfile().OGLVersion(3, 3).EndList(); 

В Ripi2 pointed out от pyramid sample:

//We create a wxGLContext in this constructor. 
//We do OGL initialization at OnSize(). 
MyGLCanvas::MyGLCanvas(MyFrame* parent, const wxGLAttributes& canvasAttrs) 
         : wxGLCanvas(parent, canvasAttrs) 
{ 
    m_parent = parent; 

    m_oglManager = NULL; 
    m_winHeight = 0; // We have not been sized yet 

    // Explicitly create a new rendering context instance for this canvas. 
    wxGLContextAttrs ctxAttrs; 
#ifndef __WXMAC__ 
    // An impossible context, just to test IsOk() 
    ctxAttrs.PlatformDefaults().OGLVersion(99, 2).EndList(); 
    m_oglContext = new wxGLContext(this, NULL, &ctxAttrs); 

    if (!m_oglContext->IsOK()) 
    { 
#if wxUSE_LOGWINDOW 
     wxLogMessage("Trying to set OpenGL 99.2 failed, as expected."); 
#endif // wxUSE_LOGWINDOW 
     delete m_oglContext; 
     ctxAttrs.Reset(); 
#endif //__WXMAC__ 
     ctxAttrs.PlatformDefaults().CoreProfile().OGLVersion(3, 2).EndList(); 
     m_oglContext = new wxGLContext(this, NULL, &ctxAttrs); 
#ifndef __WXMAC__ 
    } 
#endif //__WXMAC__ 

    if (!m_oglContext->IsOK()) 
    { 
     wxMessageBox("This sample needs an OpenGL 3.2 capable driver.\nThe app will end now.", 
        "OpenGL version error", wxOK | wxICON_INFORMATION, this); 
     delete m_oglContext; 
     m_oglContext = NULL; 
    } 
    else 
    { 
#if wxUSE_LOGWINDOW 
     wxLogMessage("OpenGL Core Profile 3.2 successfully set."); 
#endif // wxUSE_LOGWINDOW 
    } 

} 
+4

Существует включенный образец "Пирамида", который показывает, как использовать OpenGL 3.2 с шейдерами. OpenGL 3.2 - это более современная версия, принятая в Mac OS. – Ripi2

Смежные вопросы