Results 1 to 5 of 5

Thread: A problem with multiple QGraphicsView-s with OpenGL rendering

  1. #1
    Join Date
    Aug 2010
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default A problem with multiple QGraphicsView-s with OpenGL rendering

    Greetings,
    I have run into a strange problem with multiple QGraphicsView-s and OpenGL rendering.
    I need to implement an application with multiple QGraphicsView-s (each has it's own scene). I have implemented OpenGL rendering just like in documentation (view.setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))) for each view, but now if I use OpenGL rendering in more than one QGraphicsView every one of them shows only black screen (no items are drawn). Is this some kind of a bug, or am I missing something? Please help. Thank you in advance.

    Regards,
    MadBear

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A problem with multiple QGraphicsView-s with OpenGL rendering

    Sounds like a driver issue to me. What platform, Qt version and driver version do you use? Can you reproduce it with a very basic scene? If so, file a bug report with Nokia.

  3. #3
    Join Date
    Aug 2010
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A problem with multiple QGraphicsView-s with OpenGL rendering

    Greetings,
    First I want to thank you for your reply.
    I have updated drivers, but the problem persists (I'm developing the application in OpenSUSE linux). I have also created small application to test this situation:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. QPixmap slika;
    7. slika.load("bug.jpg");
    8. int w=slika.width();
    9. ui->graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    10. ui->graphicsView_2->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    11. pix->setPixmap(slika);
    12. ui->graphicsView->setScene(scena);
    13. scena->addItem(pix);
    14. ui->graphicsView->resetTransform();
    15. ui->graphicsView->scale(1,1);
    16. ui->graphicsView_2->setScene(scena);
    17. ui->graphicsView_2->resetTransform();
    18. ui->graphicsView_2->scale(1,1);
    19. }
    To copy to clipboard, switch view to plain text mode 

    Now if I use OpenGL in only one of the views application works without problem. But if I use OpenGL in both views it shows only 2 black squares where an image is supposed to be. The error it shows is:

    X Error: BadValue (integer parameter out of range for operation) 2
    Extension: 135 (Uknown extension)
    Minor opcode: 16 (Unknown request)
    Resource id: 0x20de

    Am I doing something wrong. I have used 2 GLWidgets in application and it worked without a problem. So what is wrong here? It is driving me insane.
    Thank you.

    Regards,
    MadBear

  4. #4
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A problem with multiple QGraphicsView-s with OpenGL rendering

    Mmh.. this works fine here. Maybe you can try it.

    Qt Code:
    1. #include <QtCore>
    2. #include <QtGui>
    3. #include <QtOpenGL>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8.  
    9. QHBoxLayout* hl = new QHBoxLayout();
    10.  
    11. QWidget* wdg = new QWidget();
    12. wdg->setGeometry(0,0,150,150);
    13. wdg->setWindowTitle("Title1");
    14.  
    15. QGraphicsProxyWidget* proxy = scene->addWidget(wdg);
    16. proxy->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
    17. proxy->setPos(-150,0);
    18.  
    19. QGraphicsPixmapItem* pix = scene->addPixmap(QPixmap("e:/test.jpg"));
    20. pix->setScale(0.1);
    21. pix->setPos(50,0);
    22.  
    23. {
    24. view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    25. view->setScene(scene);
    26. hl->addWidget(view);
    27. }
    28.  
    29. {
    30. view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    31. view->setScene(scene);
    32. QTransform t;
    33. t.scale(0.5,0.5);
    34. view->setTransform(t);
    35. hl->addWidget(view);
    36. }
    37.  
    38. QWidget* w = new QWidget();
    39. w->setLayout(hl);
    40. w->setGeometry(QRect(50, 50, 600, 400));
    41. w->show();
    42. return a.exec();
    43. }
    To copy to clipboard, switch view to plain text mode 
    Joh

  5. #5
    Join Date
    Dec 2007
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A problem with multiple QGraphicsView-s with OpenGL rendering

    I have the same problem as the OP, and the sample code from Johannes shows the proxy widget OK, but the images are two black rectangles.
    If I modify the code to show just one QGraphicsView the image shows correctly.
    If I modify the code so the second view is not scaled, the images are black and I get exactly the same error as the one reported by the OP:
    X Error: BadValue (integer parameter out of range for operation) 2
    Extension: 128 (Uknown extension)
    Minor opcode: 16 (Unknown request)
    Resource id: 0x20de

    This is with Qt 4.6.2 on a 64-bit Kubuntu 10.4 with all the updates installed.
    Grahpics card is a nVidia Quadro NVS 285 using the proprietary nVidia driver version 195

    A windows build of the same code using VC 2008 Express with Qt 4.6.3 works correctly. There were some OpenGL related changes sin 4.6.3, but I am not sure if they are related to this issue. If I have time I will try to update my Qt version on Linux to see if that helps.

Similar Threads

  1. opengl rendering mesh elements contour problem
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 2nd February 2010, 07:07
  2. OpenGL rendering and threads
    By brcain in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2008, 09:45
  3. QGraphicsView + OpenGL -> Pixmap rendering issue
    By JoergRe in forum Qt Programming
    Replies: 2
    Last Post: 20th May 2008, 18:41
  4. problem in rendering opengl on QGraphicsView
    By Sandip in forum Qt Programming
    Replies: 17
    Last Post: 15th April 2008, 08:27
  5. OpenGL rendering problem
    By spud in forum Qt Programming
    Replies: 5
    Last Post: 27th February 2007, 19:44

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.