Results 1 to 2 of 2

Thread: Unable to have a background component with qml + opengl scene graph

  1. #1

    Default Unable to have a background component with qml + opengl scene graph

    Consider the opengl under qml scene graph example http://doc.qt.io/qt-4.8/http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html

    Everything works fine until i create a background rectangle of any color with full opacity.
    I expect the squircle opengl widget to be shown with the rectangular component as a background but actually the background rectangle is drawn above the squircle and I am not able to see the opengl widget drawn using the shaders.

    Actual code :
    Qt Code:
    1. import QtQuick 2.0
    2. import OpenGLUnderQML 1.0
    3.  
    4. Item {
    5.  
    6. width: 320
    7. height: 480
    8.  
    9. //Actual widget which is drawn using opengl
    10. Squircle {
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

    Modified Code
    Qt Code:
    1. import QtQuick 2.0
    2. import OpenGLUnderQML 1.0
    3.  
    4. Item {
    5.  
    6. width: 320
    7. height: 480
    8.  
    9. //Background rectangle which i expect to be shown below the opengl widget
    10. //But actually it gets drawn over the opengl widget
    11. //This is visible by reducing the opacity of the background rectnagle
    12. Rectangle {
    13. anchors.fill: parent
    14. color: "#ffff0000"
    15. }
    16.  
    17. Squircle {
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 

    Will there be any way to draw any qml components below the opengl widget drawn using QML ?

  2. #2

    Default Re: Unable to have a background component with qml + opengl scene graph

    I am able to draw the opengl component above the qml component when i paint on listening to afterRendering signal ( instead of beforeRendering signal )

    changed from
    Qt Code:
    1. connect(window(), &QQuickWindow::beforeRendering, m_renderer, &SquircleRenderer::paint, Qt::DirectConnection);
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. connect(window(), &QQuickWindow::afterRendering, m_renderer, &SquircleRenderer::paint, Qt::DirectConnection);
    To copy to clipboard, switch view to plain text mode 

    Reduced the view port dimensions from
    Qt Code:
    1. glViewport(0, 0, m_viewportSize.width(), m_viewportSize.height());
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. glViewport(80, 0, 150, 500);
    To copy to clipboard, switch view to plain text mode 

    I draw the gl widget only for half of the screen and i expect the rest half of the screen to show my qml component in the background. But the opengl widget draws on one half where its intented to and it leaves a black area in the rest of the screen where i expect the qml background to be shown.

    Any ideas will be appreciated. Thanks in advance.

Similar Threads

  1. QQuickWindow::grabWindow: scene graph already in use
    By TheIndependentAquarius in forum Qt Quick
    Replies: 5
    Last Post: 17th October 2015, 11:27
  2. Replies: 15
    Last Post: 28th December 2014, 14:15
  3. Replies: 2
    Last Post: 20th May 2012, 12:08
  4. Open Scene Graph widget?
    By Caius Aérobus in forum Qt Programming
    Replies: 2
    Last Post: 19th November 2007, 13:23
  5. Qt4 scene graph model
    By grabner in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2006, 08:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.