Opengl contexts agl, wgl, glx



  • Hi,

    Is it possible to create own opengl contexts which hooks in a normal QT widget instead of using a QGLWidget. I want to make the display drivers independent from the toolkit.

    Thanks in advance



  • I have tried it. My opengl code works within a QGLWidget but not by generating an own agl context (Mac). I don't get a error message. I think the problem is the binding of a standard widget with the agl context. I am using widget->winID(). Is there another way doing this? The winID() works for a directx context.



  • I have never tried on Mac, but it's possible to create QWidget with own OpenGL context.

    You must set QWidget attributes:

    @setAutoFillBackground(false);
    setAttribute(Qt::WA_OpaquePaintEvent);
    setAttribute(Qt::WA_NoSystemBackground);
    setAttribute(Qt::WA_NativeWindow);
    setAttribute(Qt::WA_PaintOnScreen, true);
    setAttribute(Qt::WA_StyledBackground, false);
    setAttribute(Qt::WA_PaintUnclipped);@

    Override QWidget::paintEvent and do nothing in that event.

    When creating context you will need native window handle (this is code for EGL on X11, so I don't how to create GL context on Mac):

    @eglDisplay = eglGetDisplay((EGLNativeDisplayType)x11Info().display());
    eglInitialize(eglDisplay, &majorVersion, &minorVersion);
    // all other create context stuff...@

    Hope this helps.



  • See this post for doing it on the mac (this is specific to setting Lion OpenGL core profile 3.2) but it should work for other context just change the code, the post from mcdi half way down is what I used

    https://qt-project.org/forums/viewthread/8047/



  • Thank you, but I have decided for a QGLWidget.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.