Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Cannot set QQuickItem's OpenGL version

[SOLVED] Cannot set QQuickItem's OpenGL version

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Korchkidu
    wrote on last edited by
    #1

    Hi,

    I have a QML application and I need to integrate an OpenGL window. So I did:

    GLViewport.h
    @ class GLViewport : public QQuickItem{...}
    @

    GLViewport.cpp
    @ GLViewport::GLViewport()
    {
    connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(HandleWindowChanged(QQuickWindow*)), Qt::DirectConnection);
    setFlags(QQuickItem::ItemHasContents);
    }

    void GLViewport::HandleWindowChanged(QQuickWindow *win)
    {
      if (win)
      {
        win->setSurfaceType(QSurface::OpenGLSurface);
    
        QSurfaceFormat format;
        format.setRenderableType(QSurfaceFormat::OpenGL);
        format.setSamples(4);
        format.setVersion(3, 2); // <<== this puts a mess!
        format.setProfile&#40;QSurfaceFormat::CoreProfile&#41;;
        win->setFormat(format&#41;;
        win->create(&#41;;
    
        QOpenGLContext *context = new QOpenGLContext;
        context->setFormat(format&#41;;
        context->create(&#41;;
        if (!context->isValid(&#41;)
        {
          std::cout << "ERROR: cannot set OpenGL context" << std::endl;
        }
        context->makeCurrent(win);
    

    [...]

      }
    }
    

    @

    However, the line setFormat(3,2) puts a real mess. Basically, if I comment it, everything works. I have a window with a OpenGL 2.0 and a "internal context" with OpenGL 4.4. Problem is, my viewport needs an OpenGL 3.2 context for drawing our things. How can I achieve that then?

    Thanks for any help!

    UPDATE
    If fact, it does NOT work with "OpenGL under QML example":http://qt-project.org/doc/qt-5/qtquick-scenegraph-openglunderqml-example.html either. If I try to change OpenGL version, I get a black background when doing setVersion(3,2).

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Korchkidu
      wrote on last edited by
      #2

      Anyone running in the same issues?

      Best regards.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Korchkidu
        wrote on last edited by
        #3

        Forget about asking Qt to use a specific opengl version. It simply does not work on Mac OSX for the moment...

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved