Results 1 to 3 of 3

Thread: renderText of QGLWidget not working

  1. #1
    Join Date
    Jan 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default renderText of QGLWidget not working

    Hello!

    I try to display some text in my QT/OpenGL application. I try to use the methond renderText... but instead of letters "squares" are drawn (you can see them on red on the top left corner of the attached screenshot). I hope you can help me.

    The code I use is this:

    Qt Code:
    1. void OGLFrame::paintGL_R(GLenum mode, int x, int y)
    2. {
    3. GLint vp[4];
    4. bool select;
    5.  
    6. glViewport(_vp[0], _vp[1], _vp[2], _vp[3]);
    7.  
    8. if(mode != GL_SELECT)
    9. {
    10. select = false;
    11.  
    12. glRenderMode(GL_RENDER);
    13.  
    14. glMatrixMode(GL_PROJECTION);
    15. glPushMatrix();
    16. glLoadIdentity();
    17. }
    18. else
    19. {
    20. select = true;
    21.  
    22. glGetIntegerv(GL_VIEWPORT, vp);
    23.  
    24. glRenderMode(GL_SELECT);
    25. glInitNames();
    26. glPushName(0);
    27.  
    28. glMatrixMode(GL_PROJECTION);
    29. glPushMatrix();
    30. glLoadIdentity();
    31.  
    32. gluPickMatrix((GLdouble) x, (GLdouble) y, 5.0, 5.0, vp);
    33. }
    34.  
    35. gluPerspective(_fovy, _aspect, 0.01, 2*EXT);
    36.  
    37. glMatrixMode( GL_MODELVIEW );
    38. glPushMatrix();
    39. glLoadIdentity();
    40.  
    41. this->setCamera();
    42.  
    43. _ph->drawObjects(select);
    44.  
    45. this->drawBackGround();
    46.  
    47. glColor4f(1.0, 0.0, 0.0, 1.0);
    48. this->renderText(100, 100, "Hola");
    49.  
    50. // glMatrixMode(GL_PROJECTION);
    51. // glPushMatrix();
    52. // glLoadIdentity();
    53.  
    54. // glMatrixMode(GL_MODELVIEW);
    55. // glPushMatrix();
    56. // glLoadIdentity();
    57.  
    58. // renderText(100, 100, "Hola");
    59.  
    60. // glMatrixMode(GL_MODELVIEW);
    61. // glPopMatrix();
    62. // glMatrixMode(GL_PROJECTION);
    63. // glPopMatrix();
    64.  
    65.  
    66. glMatrixMode(GL_MODELVIEW);
    67. glPopMatrix();
    68.  
    69. glMatrixMode(GL_PROJECTION);
    70. glPopMatrix();
    71.  
    72. glFlush();
    73. glFinish();
    74. }
    To copy to clipboard, switch view to plain text mode 

    As you can see, I made different attempts, but I always get the same result.

    Thanks for your help
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: renderText of QGLWidget not working

    Upgrading from qt 4.3.4 to 4.4.0 made it work.

    Is it a bug of qt 4.3? or was I doing something wrong?

  3. #3
    Join Date
    Jan 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: renderText of QGLWidget not working

    Hi,

    I am facing similar issue after porting my code to Qt5 from Qt 4.8, instead of text square/rectangular blocks are displayed on QGLWidget.
    Please let me know if u found reason for this issue. Text displayed fine with Qt 4.8.

    Thanks.

Similar Threads

  1. renderText is not working correctly
    By validator in forum Qt Programming
    Replies: 3
    Last Post: 27th May 2008, 17:55
  2. QGLWIdget renderText() assertion...
    By adonel in forum Qt Programming
    Replies: 3
    Last Post: 22nd October 2007, 22:30
  3. QGLWidget renderText rotation
    By ToddAtWSU in forum Qt Programming
    Replies: 4
    Last Post: 19th September 2007, 21:52
  4. QGLWidget renderText()
    By ToddAtWSU in forum Qt Programming
    Replies: 8
    Last Post: 21st July 2006, 14:20
  5. QGLWidget renderText
    By Rayven in forum Qt Programming
    Replies: 2
    Last Post: 14th July 2006, 22:02

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.