Results 1 to 15 of 15

Thread: paintGL() and initializeGL() help

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default paintGL() and initializeGL() help

    HI,
    my application consists of 3 widget; in the MultipleView I draw myWidget2 and 3;in PerspectiveView myWidget1; application starts with Perspective view; I have insert some printf("...") inside painGL an initializeGL()
    and I see that they are run in this order (when I launch program):
    initializeGL()
    paintGL()
    paintGL()
    paintGL()
    initializeGL()
    initializeGL()

    Qt Code:
    1. void MainForm::changeView(QAction* action) {
    2. if ( action == perspectiveViewAction ) {
    3. WidgetStack->raiseWidget( PerspectiveView );
    4. }
    5. else if ( action == multipleViewAction ) {
    6. WidgetStack->raiseWidget( MultipleView );
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 
    I don't understand why the last 2 paintGL are running before the 2 initializeGL(). Is it right?
    And when I call changeView(), starts sometimes 5 paintGL() other times only two....
    Thanks
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    India
    Posts
    115
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: paintGL() and initializeGL() help

    Quote Originally Posted by mickey
    HI,
    .... I see that they are run in this order (when I launch program):
    initializeGL()
    paintGL()
    paintGL()
    paintGL()
    initializeGL()
    initializeGL()
    .
    .
    .
    I don't understand why the last 2 paintGL are running before the 2 initializeGL(). Is it right?
    initializeGL is always called first. Are you sure last 2 paintGL which you are refering to belong to other two widgets, they could have been posted by widget1? My question may look silly, but it can be true.

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: paintGL() and initializeGL() help

    last 2 paintGL() belong to the first widget? I don't know reason....And Are the last two initializeGL() called from widget2 and widget3? But When does initaliazedGL() start? (when a widget must be painted?)
    When Are initalizeGL() and PaintGL() always bind?
    Thanks
    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: paintGL() and initializeGL() help

    Quote Originally Posted by mickey
    last 2 paintGL() belong to the first widget? I don't know reason....And Are the last two initializeGL() called from widget2 and widget3?
    Change those printf statements to make them output something that will allow you to distinguish between those two widgets (for example the value of "this").

  5. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: paintGL() and initializeGL() help

    OK! My output is this:

    initalizeGL() widget1
    paintGL() widget1
    paintGL() widget1
    paintGL() widget1

    initalizeGL() widget2
    initalizeGL() widget3
    But there aren't reasons (for my humble opinion) for the last 2 paintGL(). Widget1 drawn three time? I have comment all code of paintGL() and 3 paintGL() starts again!!!
    The last two initialize I think is right(?!): initialize context but don't draw (application start with widget1)
    Regards

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

    Default Re: paintGL() and initializeGL() help

    I'm sorry but is it that bad that the paintGL() routine is called one or two times more?

  7. #7
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: paintGL() and initializeGL() help

    I don't know! Is it OK? I'd like to know the reasons that calls paintGL() 3 times; when I changeView (see code post before) widget2 and widget3 are called 2 times for widget (2 widgets = 4 paintGL())....
    Regards

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

    Default Re: paintGL() and initializeGL() help

    Probably the widgets just need to be redrawn. It is difficult to say without seeing your code.

  9. #9
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: paintGL() and initializeGL() help

    I have comment all PaintGL() and any updateGL(). PaintGL() starts three times for the first widget.....Can be any problem from Qt Designer? (when I designed MyWidget class)
    Regards

  10. #10
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: paintGL() and initializeGL() help

    HI,
    I see that for the widget 1 happen (in this order):

    initializeGL()
    resizeGL()
    resizeGL()
    paintGL()
    resizeGL()
    resizeGL()
    paintGL()
    paintGL()

    This is for a widget! Is this strange?
    Qt Code:
    1. void MyWidget::resizeGL( int w, int h )
    2. {
    3. cout << "resize" << this << endl;
    4. // setup viewport, projection etc.:
    5. glMatrixMode (GL_PROJECTION);
    6. glLoadIdentity ();
    7. GLdouble ratio=((GLdouble)w)/(GLdouble)h;
    8. gluPerspective(45,ratio,3,40);
    9. glViewport (0, 0, (GLdouble) w, (GLdouble) h);
    10. glMatrixMode (GL_MODELVIEW);
    11. glLoadIdentity ();
    12. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by mickey; 19th February 2006 at 23:30.
    Regards

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

    Default Re: paintGL() and initializeGL() help

    The number of "paintGL" calls doesn't really depend on the style of coding you take, but on the environment of the widget. If it becomes obscured, it needs to repaint itself, so it calls paintGL.

  12. #12
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: paintGL() and initializeGL() help

    In wich sense "obscured"?
    Regards

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

    Default Re: paintGL() and initializeGL() help

    Quote Originally Posted by mickey
    In wich sense "obscured"?
    I.e. if you move some other window over it.

  14. #14
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: paintGL() and initializeGL() help

    3 paintGL() are called when app starts. there are no any window on my app.

    I insert a getchar() at begin of paintGL(). 1st paint() make nothing, second paint draw my app (windows, toolbar, toolbox) with myWidgetGL black! 3st paint fill myWidgetGL with the objects of the scene....
    Regards

  15. #15
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: paintGL() and initializeGL() help

    Hi,
    I know only now that the problem of multiple start of PaintGL() is my ToolBox. If I delete it paintGL() not starts three times instead of only one!
    What I can do? Idesinger myWidget and myToolBox from designerover a WidgetStack...
    Regards

Similar Threads

  1. QGLWidget, toolbox and paintGL()
    By mickey in forum Qt Programming
    Replies: 3
    Last Post: 21st March 2006, 01:05

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.