Results 1 to 5 of 5

Thread: problem about renderText

  1. #1

    Default problem about renderText

    hi:

    I used two qglwidget in my mainwindow. And I invoked renderText in both of the qglwidget. But in one of the qglwidget, I just cannot change the color of text. Could you please help me?

    Code like below:

    Qt Code:
    1. void VARDrawer::DrawLabel()
    2. {
    3. setting->ValidateLabels();
    4. glLineWidth(1.2f);
    5. glColor4f(1.0f,0.0f,0.0f,1.0f);:confused:Do not work here
    6.  
    7. map<int,TextureSetting*>::iterator mi;
    8. for (mi = setting->varMap.begin();
    9. mi != setting->varMap.end() ; mi++)
    10. {
    11. TextureSetting* texSetting = mi->second;
    12. if (texSetting->isDrawLabel)
    13. {
    14.  
    15. QString label(texSetting->srcDim->GetDimensionName().c_str());
    16. Vec3 pos = Vec3(texSetting->blockPos.X,
    17. texSetting->blockPos.Y+texSetting->VisSize.height+0.02f,
    18. 0.0f);
    19.  
    20. renderText(pos.X, pos.Y,0.0f,
    21. texSetting->srcDim->GetDimensionName().c_str());
    22.  
    23. }
    24. }
    25. }
    26. void PareCoordDrawer::DrawAxisLabel(void)
    27. {
    28. setting->ValidateAxisLabel(dataSet);
    29. glLineWidth(1.2f);
    30. qglColor(Qt::red);
    31. QVector<float>::iterator qli;
    32. QList<string>::iterator qsli;
    33. for (qli = setting->axisPos.begin(), qsli = setting->labelList.begin();
    34. qli != setting->axisPos.end(); qli++, qsli++)
    35. {
    36. float pos = *qli;
    37. string dimName = *qsli;
    38. renderText(pos, 1.05f, 0.0f, dimName.c_str());:o Every thing just fine here
    39. }
    40. }
    To copy to clipboard, switch view to plain text mode 


    Thanks,
    zhang
    Last edited by wysota; 19th September 2007 at 10:51. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem about renderText

    Did you try using qglcolor() instead?

  3. #3
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problem about renderText

    I was also having trouble with renderText. I talked to Trolltech and they said:

    Note that renderText() will often have a different color than you expect
    since it calls "glDisable(GL_LIGHTING)".
    I was having trouble with the color when it was inside of a glCallList. However, I don't do anything with lighting so I am not sure why glCallList was affecting it.

  4. #4
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: problem about renderText

    I haven't worked with OpenGL display lists in a while, but if I remember correctly, you can only set the color once for a display list, and that is upon creation of the display list. Every time you call glCallList( ) it will use the color that the object used upon the creation of the display list, not whatever color you try to set for it. So in order to change you color of your display list, you would have to destroy the current display list and create a new one with the new color. If this color changes many times, display lists would then not be the way you would want to handle your situation. But if you only change the color once or twice throughout the execution of the program, display lists would be okay to use.

  5. #5
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problem about renderText

    Thanks, I was setting the color in the glCallList and it still would not always be the color that I set it (I tried both qglColor and the gl color call). RenderText calls its own glCallList so I wonder if that had something to do with it (though calling glCallLists within glCallLists is allowed and should work).

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. QGLWidget renderText problem
    By mbjerkne in forum Qt Programming
    Replies: 1
    Last Post: 7th April 2006, 21:35
  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.