Results 1 to 9 of 9

Thread: QGraphicsView animation performance

  1. #1
    Join Date
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default QGraphicsView animation performance

    I want to display an animated image with QGraphicsView. The animated image will play at 30 frames per second, and I will have multiple images at the same time. One way to do it is to have a list of QGraphicsPixmapItem, and keep feeding that to QGraphicsScene. But that seems inefficient. Is there any better way to do this that I'm missing? Maybe I should access the OpenGL device directly?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: QGraphicsView animation performance

    If your viewport is OpenGL based then you can use OpenGL calls to render your item.
    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
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Question Re: QGraphicsView animation performance

    All I'm trying to do is render a triangle and a square (from here http://nehe.gamedev.net/data/lessons....asp?lesson=02 ) , but the viewport is always black.

    VisualizationWindowClass is just a blank dialog from QtDesigner

    Qt Code:
    1. class VisualizationWindow : public VisualizationWindowClass, public QGLWidget
    2. {
    3. virtual void initializeGL(){
    4. qglClearColor(Qt::black);
    5. glShadeModel(GL_FLAT);
    6. }
    7. virtual void resizeGL( int w, int h ){
    8. glViewport( 0, 0, (GLint)w, (GLint)h );
    9. }
    10. virtual void paintGL(){
    11. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    12. glLoadIdentity();
    13. glTranslatef(-1.5f,0.0f,-6.0f);
    14. glBegin(GL_TRIANGLES); // Drawing Using Triangles
    15. glVertex3f( 0.0f, 1.0f, 0.0f); // Top
    16. glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
    17. glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
    18. glEnd();
    19. glTranslatef(3.0f,0.0f,0.0f);
    20. glBegin(GL_QUADS); // Draw A Quad
    21. glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
    22. glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right
    23. glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
    24. glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
    25. glEnd(); // Done Drawing The Quad
    26.  
    27. }
    28.  
    29. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: QGraphicsView animation performance

    So are you using Graphics View or not?
    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
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: QGraphicsView animation performance

    It doesn't seem to be necessary. The system can just display a QGLWidget. If I change the clear color it displays a different color for example. It just doesn't draw anything else.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: QGraphicsView animation performance

    If all you want is a triangle and a square, I'd use QPainter instead of pure OpenGL calls. You can render on QGLWidget if you want of course...
    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
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: QGraphicsView animation performance

    Quote Originally Posted by wysota View Post
    If all you want is a triangle and a square, I'd use QPainter instead of pure OpenGL calls. You can render on QGLWidget if you want of course...
    Thanks but that's not what I want. I'm just demonstrating that even the simplest case doesn't work.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: QGraphicsView animation performance

    It doesn't work probably because your viewport is setup incorrectly. Go to link you provided, scroll down and download the sources fot C++/Qt. You'll see they set up the modelview matrix too.
    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.


  9. The following user says thank you to wysota for this useful post:

    rakkar (3rd September 2009)

  10. #9
    Join Date
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: QGraphicsView animation performance

    Quote Originally Posted by wysota View Post
    It doesn't work probably because your viewport is setup incorrectly. Go to link you provided, scroll down and download the sources fot C++/Qt. You'll see they set up the modelview matrix too.
    Fantastic, thanks for pointing that out.

Similar Threads

  1. Animation and QGraphics
    By PrimeCP in forum Qt Programming
    Replies: 2
    Last Post: 7th May 2009, 00:31
  2. QGraphicsView performance
    By Halabund in forum Newbie
    Replies: 3
    Last Post: 17th April 2009, 10:12
  3. Replies: 0
    Last Post: 5th March 2009, 06:54
  4. QGraphicsView Problem
    By hakkman in forum Qt Programming
    Replies: 2
    Last Post: 14th June 2008, 20:27
  5. QGraphicsView animation issues?
    By m41n1 in forum Qt Programming
    Replies: 2
    Last Post: 6th June 2008, 07:48

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.