Results 1 to 6 of 6

Thread: QGLWidget's PaintGl Method

  1. #1
    Join Date
    Sep 2011
    Posts
    27
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Exclamation QGLWidget's PaintGl Method

    Hello,

    I have started my new project with QT Eclipse, as I told in my previois thread I have Mainwindow and opengl window which is child to it called GLWidget inherited from QGLwidget.What I want to know is..

    In my GL window i need to place different artifacts like I have to place multiple textures and along with that i need to draw some primitives(exolygons) over that textures using opengl core libraries(GLUT). Problem that I found currently is, any drawing on the opengl window is possible only through PaintGL() method, Looks like I cannot use my own methods to draw some textures, everything must be through PaintGL.
    If that is the case How do i draw a different textures and at the same time depending on the some inputs I need to change textures as well as primiives..basically its an kind of scene changes dynamically.

    Hope readers understand what I mean, If not please let me know I will try to eloberate it!
    Please sugget me how to use it!

    Thanks in Advance!

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QGLWidget's PaintGl Method

    Thats right, all painting must be done from painGL method, but you can call other drawing methods from paintGL. Simple example, you can have a boolean values to control what to draw, like this:
    Qt Code:
    1. void MyGlWidget::paintGL(){
    2. if( this->_drawPolygon ){ // boolean value to control visibility of a polygon
    3. this->drawPolygon();
    4. }
    5. if( this->_drawTexture1 ){ // same for visibility of a texture
    6. this->drawTexture1();
    7. }
    8. if( this->_drawSomethingElse ) ...
    9. }
    10.  
    11. // some methods to control what should be rendered
    12. void MyGlWidget::setDrawPolygon( bool draw ){
    13. this->_drawPolygon = draw;
    14. this->updateGL();
    15. }
    16. void MyGlWidget::setDrawTexture1( bool draw ){
    17. this->_drawTexture1 = draw;
    18. this->updateGL();
    19. }
    20. void MyGlWidget::setDrawSomethingElse( ... etc.
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2011
    Posts
    27
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGLWidget's PaintGl Method

    Thanks for the response!

    So, it means userdefined functions must also be called from PaintGL and in that functions we can still use our core opengl commands to draw the polygons and the textures and stuff like that..Is it correct?

    Thanks!

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QGLWidget's PaintGl Method

    userdefined functions must also be called from PaintGL and in that functions we can still use our core opengl commands to draw the polygons and the textures and stuff like that..Is it correct?
    Yes. You can also use standard QPainter 2D drawing on the QGlWidget, if you reimplement paintEvent.

  5. #5
    Join Date
    Sep 2011
    Posts
    27
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGLWidget's PaintGl Method

    Ok..
    I dont know much about QPainter and stuff like that..I am an beginner and looking for something most specific to our project requirements..I still have to read some stuff to get more exposure towards that..
    Any suggestions or links of the tutorials are most welcome!

    And, Could you please drop some code snippet to draw a texture in opengl window by using QT API's?
    Earlier i was using only pure opengl commands to do that in my previous environment..I heard that there is simple ways to do this using QT API functions.

    Thanks!

  6. #6
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QGLWidget's PaintGl Method


Similar Threads

  1. Replies: 7
    Last Post: 1st July 2011, 01:21
  2. drawRect inside paintGL()
    By mickey in forum Newbie
    Replies: 16
    Last Post: 18th April 2006, 01:12
  3. Help on OpenGL in PaintGL
    By mickey in forum Newbie
    Replies: 1
    Last Post: 15th April 2006, 22:17
  4. QGLWidget, toolbox and paintGL()
    By mickey in forum Qt Programming
    Replies: 3
    Last Post: 21st March 2006, 01:05
  5. paintGL() and initializeGL() help
    By mickey in forum Newbie
    Replies: 14
    Last Post: 26th February 2006, 17:15

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.