Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Mixing modern OpenGL and QML
Forum Updated to NodeBB v4.3 + New Features

Mixing modern OpenGL and QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 1.8k Views
  • 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.
  • V Offline
    V Offline
    vdw_hmng
    wrote on last edited by
    #1

    Hi,

    We are using developing an application in Qt 5.3.2. We would like to make a custom drawn QML element using QQuickFrameBufferObject and OpenGL 3.3 core profile functions which is higher than the one used standard by QML.

    We would like to know what the best approach to drawing only our element with modern OpenGL and not touch the QML context?

    What we do right now is :

    • Create a QOpenGLContext and QOffscreenSurface set to use Qt 5.3.2
    • We set the share context of our own QOpenGLContext with the context used by QML
    • Before we start rendering we make our own OpenGL context current and after rendering has finished we make the QML context current.

    Is this correct or do we need to make changes? Do we need to call QQuickWindow::resetOpenGLState()

    Thanks!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tomkulaga
      wrote on last edited by tomkulaga
      #2

      Take a look at the "textureingsnode" example. It shows how to use the QQuickFrameBufferObject. I'm using that and it seems to work.

      I don't create a separate context for my custom OpenGL code.

      I do all my rendering from a class derived from QOpenGLFunctions_4_5_Core.

      At the beginning, before create your Q*Application i call:

      void initliaseOpenGL()
      {

      QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
      QSurfaceFormat format;
      format.setDepthBufferSize(24);
      format.setStencilBufferSize(8);
      format.setSamples(4);
      format.setVersion(4, 5);
      format.setRenderableType(QSurfaceFormat::OpenGL);
      format.setProfile(QSurfaceFormat::CoreProfile);
      #ifdef QT_DEBUG
      format.setOption(QSurfaceFormat::DebugContext);
      #endif
      QSurfaceFormat::setDefaultFormat(format);
      }

      to set up OpenGL.

      Now if i change the format.setVersion(4, 5); to format.setVersion(3, 1); I get a crash during openGL init, indicating that it is using a 4.5 core profile, and that the code pasted above is having an effect.

      V 1 Reply Last reply
      0
      • T tomkulaga

        Take a look at the "textureingsnode" example. It shows how to use the QQuickFrameBufferObject. I'm using that and it seems to work.

        I don't create a separate context for my custom OpenGL code.

        I do all my rendering from a class derived from QOpenGLFunctions_4_5_Core.

        At the beginning, before create your Q*Application i call:

        void initliaseOpenGL()
        {

        QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
        QSurfaceFormat format;
        format.setDepthBufferSize(24);
        format.setStencilBufferSize(8);
        format.setSamples(4);
        format.setVersion(4, 5);
        format.setRenderableType(QSurfaceFormat::OpenGL);
        format.setProfile(QSurfaceFormat::CoreProfile);
        #ifdef QT_DEBUG
        format.setOption(QSurfaceFormat::DebugContext);
        #endif
        QSurfaceFormat::setDefaultFormat(format);
        }

        to set up OpenGL.

        Now if i change the format.setVersion(4, 5); to format.setVersion(3, 1); I get a crash during openGL init, indicating that it is using a 4.5 core profile, and that the code pasted above is having an effect.

        V Offline
        V Offline
        vdw_hmng
        wrote on last edited by
        #3

        @tomkulaga

        Hi,

        We cannot do this because if we are making a QML application in Qt 5.3.2. If we set the format to anything above OpenGL 2.0 nothing gets rendered.

        Maybe I should also mention we are developing for Ubuntu 14.04, since we have seen difference on how the initializeOpenGlFunctions works on Linux and on Windows.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MapMap
          wrote on last edited by
          #4

          You might want to consider using Qt Canvas 3D.

          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