Results 1 to 7 of 7

Thread: Qt3 -> Qt4 QGLWidget::renderText problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2006
    Posts
    10
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Qt3 -> Qt4 QGLWidget::renderText problem

    Hi all,

    Over the weekend, I ported my OpenGl application from Qt3 to Qt4. Everything went fine, except that renderText is now rendering the text *behind* my geometry in the projection matrix (perspective). I am still only passing the X and Y coordinates to the function. Again, I did not change anything from Qt3 to Qt4.

    Has anyone experienced this? Anyone know the solution? The relevant code is pasted below.



    Thanks!! Kindest regards,
    -joshua







    Qt Code:
    1. ////////////////////////////////////////////
    2. //render some text
    3. //lighting should be disabled before calling this
    4. //or we won't be able to set the color
    5. //disable textures
    6. glDisable(GL_TEXTURE_2D);
    7. glDisable(GL_LIGHTING);
    8. QFont my_font("Arial");
    9. my_font.setPointSize(14);
    10. //this is a required bug-fix
    11. my_font.setStyleHint(QFont::AnyStyle, QFont::PreferBitmap);
    12. glColor4f(1.0, 1.0, 1.0, 1.0);
    13.  
    14. //if they are viewing the earth/moon system
    15. //from perspective view then show a label
    16. if(view == 1){
    17. renderText(27, 27, "The Earth & Moon from Perspective", my_font);
    18. }
    19.  
    20.  
    21. //if they are viewing the earth and moon from the sun
    22. if(view == 2){
    23. renderText(27, 27, "The Earth & Moon from the Sun", my_font);
    24. }
    25.  
    26.  
    27. //if they are viewing the moon from earth
    28. //then iterate through the moon_coord_array
    29. if(view == 3){
    30.  
    31. //render a label
    32. renderText(27, 27, "The Moon from the Earth", my_font);
    33.  
    34. //now make the font size smaller
    35. my_font.setPointSize(11);
    36.  
    37. for(int i=0; i<coord_array_index; i++){
    38. double my_x = moon_coord_array[i].getX();
    39. double my_y = moon_coord_array[i].getY();
    40. QString my_label = moon_coord_array[i].getLabel();
    41. renderText(my_x, my_y, my_label, my_font);
    42. }
    43. }
    44.  
    45.  
    46. //if they are viewing the earth from the moon
    47. if(view == 4){
    48. renderText(27, 27, "The Earth from the Moon", my_font);
    49. }
    50.  
    51. //re-enable lighting
    52. glEnable(GL_LIGHTING);
    53. //enable textures
    54. glEnable(GL_TEXTURE_2D);
    55. ////////////////////////////////////////////
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 25th September 2006 at 07:59. Reason: missing [code] tags

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.