Results 1 to 7 of 7

Thread: Qt3 -> Qt4 QGLWidget::renderText problem

  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

  2. #2
    Join Date
    May 2006
    Location
    Bangalore
    Posts
    23
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt3 -> Qt4 QGLWidget::renderText problem

    Quote Originally Posted by cometlinear View Post
    Everything went fine, except that renderText is now rendering the text *behind* my geometry in the projection matrix (perspective).
    Are you calling renderText() before or after calling your other display lists??
    The Keyboard Is Mightier Than The Sword!

  3. #3
    Join Date
    Sep 2006
    Posts
    10
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt3 -> Qt4 QGLWidget::renderText problem

    Hey there,

    Thanks for replying.

    This app does not use any display lists. Do you think that will solve this problem?

    I didn't need a display list when this app ran on Qt3, and it worked fine.


    Thanks again!! Kindest regards,
    -joshua

  4. #4
    Join Date
    Sep 2006
    Posts
    10
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt3 -> Qt4 QGLWidget::renderText problem

    By the way, I should point out that I do call rendertext before I draw any geometry. I didn't think that should matter anyway, since without a Z parameter, renderText should just print on top of everything else.

    Right?


    Thanks!
    -joshua

  5. #5
    Join Date
    May 2006
    Location
    Bangalore
    Posts
    23
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt3 -> Qt4 QGLWidget::renderText problem

    If you aren't using display lists, then its like drawing in immediate mode.

    Then the order certainly matters. Try changing the order of drawing.
    The Keyboard Is Mightier Than The Sword!

  6. #6
    Join Date
    Sep 2006
    Posts
    10
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt3 -> Qt4 QGLWidget::renderText problem

    Thanks, and I will try that.

    But it still doesn't explain the problem, does it? Isn't renderText supposed to draw on top of everything if no Z parameter was passed?

    And, can someone confirm that renderText did indeed change in Qt4? Becuase, again, the app was working fine in Qt3, and the OpenGL code was not changed.


    Thanks again!! best regards,
    -joshua

  7. #7
    Join Date
    Sep 2006
    Posts
    10
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt3 -> Qt4 QGLWidget::renderText - FIXED

    Hi all,

    I solved this: it was becuase I had depth testing enabled.

    I don't know why it worked for Qt3 and not Qt4, but anyway, it's solved now.



    Thanks again for the help!! Kindest regards,
    -joshua

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.