Results 1 to 20 of 21

Thread: Issues with QGLWidget as QMainWindow central widget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Issues with QGLWidget as QMainWindow central widget

    Intel HD OpenGL drivers for Windows are totally broken. You should focus on getting your NVidia drivers to work properly. I'm sure the code of the program itself is correct, it works fine on my Linux+NVidia combo.

    01:00.0 VGA compatible controller: NVIDIA Corporation GF104 [GeForce GTX 460] (rev a1)
    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.


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

    Zyl (13th June 2012)

  3. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Issues with QGLWidget as QMainWindow central widget

    If I may interject . . .

    @Zyl - I see similar artifacts using your code above on my Debian box. Try calling glClear() in your
    paintGL() function:
    Qt Code:
    1. void paintGL() {
    2. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    3. . . .
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to norobro for this useful post:

    Zyl (13th June 2012)

  5. #3
    Join Date
    Nov 2010
    Posts
    20
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Issues with QGLWidget as QMainWindow central widget

    Quote Originally Posted by wysota View Post
    Intel HD OpenGL drivers for Windows are totally broken. You should focus on getting your NVidia drivers to work properly. I'm sure the code of the program itself is correct, it works fine on my Linux+NVidia combo.

    01:00.0 VGA compatible controller: NVIDIA Corporation GF104 [GeForce GTX 460] (rev a1)
    I'd be thankful if you have any instructions/hints regarding this. I remember trying to install the NVidia driver before any Intel HD driver resulting in some message like "You must install Intel HD first [...]" or something along those lines. I also remember uninstalling Intel HD leaving me with a black screen once, requiring me to reinstall Windows - so I'm paranoid about ever touching it again. I still need to test if there are painting problems when doing updateGL() outside the content of a resize event. If yes, I won't be using OGL for anything, because there are too many people with systems like mine. If no, crappy resizing performance is an endurable pain.


    Quote Originally Posted by norobro View Post
    If I may interject . . .

    @Zyl - I see similar artifacts using your code above on my Debian box. Try calling glClear() in your
    paintGL() function:
    Qt Code:
    1. void paintGL() {
    2. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    3. . . .
    To copy to clipboard, switch view to plain text mode 
    Good idea. glClear does the job. Actually... If I don't do glClear, everything still gets cleared with black. At least when I move my squares like so:
    Qt Code:
    1. glBegin(GL_QUADS);
    2. glVertex2i(10 + (20 * i), 10 + (20 * j) + 3 * (countPaint % 150));
    3. glVertex2i(20 + (20 * i), 10 + (20 * j) + 3 * (countPaint % 150));
    4. glVertex2i(20 + (20 * i), 20 + (20 * j) + 3 * (countPaint % 150));
    5. glVertex2i(10 + (20 * i), 20 + (20 * j) + 3 * (countPaint % 150));
    6. glEnd();
    To copy to clipboard, switch view to plain text mode 
    ; the previously drawn ones won't stay visible in the next frame. I'm no OGL expert, but isn't this supposed to not happen unless there actually is a glClear()-call?


    Another thing I noticed: I seem to be able to avoid unneccesary drawing by doing this:

    Qt Code:
    1. void initializeGL() {
    2. // gl-calls here
    3.  
    4. resized = true;
    5. }
    6.  
    7. void resizeGL(int w, int h) {
    8. // gl-calls here
    9.  
    10. resized = true;
    11. }
    12.  
    13. void paintGL() {
    14. if (!resized)
    15. return;
    16.  
    17. // gl-calls to draw here...
    18.  
    19. resized = false;
    20. }
    21.  
    22. private:
    23. bool resized;
    To copy to clipboard, switch view to plain text mode 
    ; this seemingly effectively increases performance and responsiveness.
    EDIT: Doing this running the program using NVidia GPU however causes a black window. The squares would only flash up while resizing it.
    Last edited by Zyl; 12th June 2012 at 15:23.

  6. #4
    Join Date
    Nov 2010
    Posts
    20
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Issues with QGLWidget as QMainWindow central widget

    My research regarding NVidia Optimus resulted in finding out one's either lucky and has an option in the BIOS to disable it (I don't) or else there is no way to get rid of it, as the graphics card needs to pipe frames through the Intel HD component (or something along those lines - it got too technical for me).

    I tried doing something simple as throwing 5 instances of MyQGLWidget into a QHBoxLayout, as well as into a QSplitter, both resulting in a horrendous lagfest, where every widget gets repainted one frame later than the other, regardless of whether I use GPU/Intel HD. This would mean ridiculous performance once I made a proper application from these. I then tried using traditional QWidgets using QPainter and paintEvent, which works pretty much flawlessly with either graphics component. If I just turn these into QGLWidgets again, I am back to horrible performance.

    Bottom line: QWidget probably has enough performance for the simple thing I plan to do, anyway. I just cannot use GLWidgets if they're going to be unreliable, and I don't even think an NVidia Optimus-infested system such as mine already represents the worst possible target machine.

    Thanks for your efforts.

Similar Threads

  1. How can size of QMainWindow's central widget be managed?
    By yogeshm02 in forum Qt Programming
    Replies: 9
    Last Post: 28th March 2014, 21:12
  2. Replies: 2
    Last Post: 29th June 2011, 15:45
  3. Replies: 2
    Last Post: 7th June 2008, 13:12
  4. paint central widget of a QMainWindow???
    By Shuchi Agrawal in forum Newbie
    Replies: 3
    Last Post: 17th January 2007, 08:02
  5. Central Widget of QMainWindow
    By sumsin in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2006, 18:32

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
  •  
Qt is a trademark of The Qt Company.