Results 1 to 8 of 8

Thread: qt quick with opengl underlay

  1. #1
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default qt quick with opengl underlay

    Hello forum,

    I am trying to draw a teapot as opengl underlay rendering and qt quick UI on top of the underlay to interact with the teapot. Since qt quick 2 uses opengl 2 for all of its rendering , i am using the compatibility profile with the modern opengl pipeline .

    I am having QQuickView subclass as follows:

    Qt Code:
    1. class Window : public QQuickView
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6.  
    7. explicit Window(QWindow *parent = 0);
    8.  
    9. public slots:
    10. void renderOpenGLScene();
    11.  
    12. private:
    13.  
    14. QScopedPointer<AbstractScene> mScene;
    15. QTime mTime;
    16. };
    To copy to clipboard, switch view to plain text mode 

    All the opengl commands are initiated in the following class :

    Qt Code:
    1. class TeapotTessellation : public AbstractScene, protected QOpenGLFunctions_4_3_Compatibility
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6.  
    7. explicit TeapotTessellation(QObject *parent = 0);
    8. ~TeapotTessellation();
    9.  
    10. //scene related functions
    11. virtual void initialise();
    12. virtual void update(float t);
    13. virtual void render();
    14. virtual void resize(int w,int h);
    15.  
    16. private:
    17.  
    18. void loadShaders();
    19.  
    20. GLSLShader *mTessellationShader;
    21.  
    22. TeapotVboPatch *mTeapotPatch;
    23.  
    24. ....................
    25. ....................
    26. };
    27.  
    28. I can see the teapot, but the QML scene is not behaving properly(spring animation of a rounded rectangle) and i get the following info in the cosole:
    29.  
    30. [code]
    31. QSGContext::initialize: stencil buffer support missing, expect rendering errors
    To copy to clipboard, switch view to plain text mode 

    The qml code is tested separately and i works fine.

    Where should i look into the debug this issue ?
    [/code]

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt quick with opengl underlay

    We cannot see how you get your GL code called. You should connect to the beforeRendering() signal with a slot that performs rendering. Remember to reset the state of the GL engine to what QtQuick expects by calling resetOpenGLState().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: qt quick with opengl underlay

    Hi

    I am already connecting the signal as follows:

    Qt Code:
    1. Window::Window(QWindow *parent)
    2. : QQuickView(parent),
    3. mScene(new TeapotTessellation(this))
    4. {
    5. setClearBeforeRendering(false);
    6.  
    7. QObject::connect(this,SIGNAL(beforeRendering()),SLOT(renderOpenGLScene()),Qt::DirectConnection);
    8.  
    9. QTimer *timer = new QTimer(this);
    10. connect(timer,SIGNAL(timeout()),this,SLOT(update()));
    11. timer->start();
    12.  
    13. QSurfaceFormat format;
    14. format.setMajorVersion(4);
    15. format.setMinorVersion(3);
    16. format.setSamples(4);
    17. format.setProfile(QSurfaceFormat::CompatibilityProfile);
    18.  
    19. setFormat(format);
    20. }
    To copy to clipboard, switch view to plain text mode 

    And after every rendering commands i am unbinding the shaders and vertex array object explicitly and i am not sure where to call this resetOpenGLState(). Check also the following snippet:

    Qt Code:
    1. void Window::update()
    2. {
    3. float time = mTime.elapsed() / 1000.0f;
    4.  
    5. mScene->update(time);
    6.  
    7. QQuickView::update();
    8. }
    9.  
    10. void Window::renderOpenGLScene()
    11. {
    12. static bool firstTime = true;
    13.  
    14. if(firstTime)
    15. {
    16. mScene->initialise();
    17. mScene->resize(width(),height());
    18. firstTime = false;
    19. }
    20.  
    21. mScene->render();
    22.  
    23. //SHOULD I CALL THE FUNCTION resetOpenGLState() here ?
    24. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt quick with opengl underlay

    Yes, call the function.

    And you shouldn't access any of the window's properties from the rendering thread. Better initialize that scene before you start drawing.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: qt quick with opengl underlay

    Thanks,

    I have managed to render an opengl scene under the qt quick scene. I largely followed the tutorial titled - "Scene Graph - OpenGL Under QML"


    Now i want to animate the opengl scene that contains a teapot. I usually rotate the opengl scene using the Qt' s timer event and timer function as follows:

    Qt Code:
    1. QTimer *timer = new QTimer(this);
    2. connect(timer,SIGNAL(timeout()),this,SLOT(updateScene()));
    3. timer->start();
    To copy to clipboard, switch view to plain text mode 

    And inside the updateScene() slot I have the following :

    Qt Code:
    1. void GLWindow::updateScene()
    2. {
    3. float t = mTime.elapsed() * 0.001;
    4.  
    5. mScene->update(t);
    6.  
    7. paintGL();
    8. }
    To copy to clipboard, switch view to plain text mode 

    I used the same mechanism while integrating qt quick with opengl underlay, but the teapot only rotates for a while with the mouse click and it stops. I want the teapot to rotate continuously untill the application closes.

    Any hint to achieve this ?

    Thanks

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt quick with opengl underlay

    You have to tell QtQuick scene to update itself. It will call your GL code with the beforeRendering signal.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: qt quick with opengl underlay

    Thanks !

    Any concrete example to what you have just mentioned ?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt quick with opengl underlay

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 5th July 2017, 13:28
  2. Conversion from opengl to opengl es2 (Shapefile rendering)?
    By swapan_gh in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 5th December 2013, 06:59
  3. converting GLUT/OpenGL to Qt/OpenGL - displaying issue
    By yoti13 in forum Qt Programming
    Replies: 1
    Last Post: 25th November 2012, 00:45
  4. Underlay map image in QwtPlot
    By MSUdom5 in forum Qwt
    Replies: 1
    Last Post: 5th May 2012, 01:51
  5. Qt with OpenGL ES for ARM9 - All OpenGL ES tests have failed!
    By vinpa in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 3rd December 2009, 10: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.