Results 1 to 10 of 10

Thread: Problem when mixing openGL and QPainter

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jul 2007
    Posts
    90
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem when mixing openGL and QPainter

    here is the related code.....

    In order to mix QPainter and openGL i have reimplemented paintEvent().

    Qt Code:
    1. void QPyramidTool::paintEvent(QPaintEvent *event)
    2. {
    3.  
    4. QPainter painter;
    5. painter.begin(this);
    6.  
    7. resizeGL(width(),height());
    8. // Rotate the Pyramid and update.
    9. glClearColor(2.0, 2.0, 2.0, 0.0);
    10. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    11. glLoadIdentity();
    12. glTranslated(0.0, 0.0,-10.0);
    13. glRotated(m_nXRot / 10.0, 2.0, 0.0, 0.0);
    14. glRotated(m_nYRot / 10.0, 0.0, 2.0, 0.0);
    15. glRotated(m_nZRot / 10.0, 0.0, 0.0, 2.0);
    16.  
    17. glCallList(m_glObject);
    18.  
    19. event->accept();
    20. }
    21. and the resizeGL() is
    22. void QPyramidTool::resizeGL(int width, int height)
    23. {
    24. int side = qMin(width, height);
    25. glViewport((width - side) / 2, (height - side) / 2, side, side);
    26.  
    27. glMatrixMode(GL_PROJECTION);
    28. glLoadIdentity();
    29. glOrtho(-3.5, +3.5, +3.5, -3.5, 4.0, 20.0);
    30. glMatrixMode(GL_MODELVIEW);
    31. }
    To copy to clipboard, switch view to plain text mode 

    regards,
    sanjay
    Last edited by wysota; 17th March 2008 at 14:15. Reason: missing [code] tags

Similar Threads

  1. qpainter "drawText() problem
    By impeteperry in forum Qt Programming
    Replies: 10
    Last Post: 25th March 2007, 00:46

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.