Results 1 to 12 of 12

Thread: About QGLWidget::renderText

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: About QGLWidget::renderText

    Well, maybe that's because you reset your matrix with glLoadIdentity() in your display list,
    and it messes up coordinates for your renderText & drawText calls...

    I'm sorry, but I have no time to test something now...

    Good luck

    Guilugi.

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

    Default Re: About QGLWidget::renderText

    Hi,thank you for your help firstly.This is still the first problem for me.Could you please give me detailed information about the second method of renderText(). The parameter "z" puzzle me .I have tried the method that you told me yesterday and the coordinates rotated indeed,but the direction of the text was still horizontal (ie. not vertiacal) and its position changed as the coordinates were rotated. Can you help me again,thank you!
    Last edited by showhand; 19th January 2006 at 02:45.
    There is no secret in the face of the code.

  3. #3
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: About QGLWidget::renderText

    Well, 'z' is the third dimension of the space, the depth of your scene.

    In the small code I posted earlier, I did a rotation around this z-axis, to have the x-axis vertical and the y-axis horizontal...to have the text rendered vertical.

    That's strange it doesn't work...
    Can you post me a full sample of code I could compile and debug ?

    Guilugi.

  4. #4
    Join Date
    Jan 2006
    Posts
    26
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: About QGLWidget::renderText

    Sure,following are complete code, plese help me !
    Qt Code:
    1. draw.h
    2. #include<QtOpenGL>
    3. #include<QString>
    4. class Draw:public QGLWidget
    5. {
    6. public:
    7. Draw(QWidget* parent=0);
    8. Draw(void);
    9. void drawText(QString,int,int);
    10. protected:
    11. void initializeGL();
    12. void paintGL();
    13. void resizeGL(int width,int height);
    14. }
    15. draw.cpp
    16. #include "draw.h"
    17. void NgiDrawWiggle::initializeGL()//called firstly
    18. {
    19. z=(this->h/2)/(tan((45.0/2.0)*(3.1415926/180.0)))+0.5;
    20. glShadeModel( GL_SMOOTH );
    21. glClearColor( 1.0, 1.0, 1.0, 0.0 );
    22. glClearDepth( 1.0 );
    23. glDisable( GL_DEPTH_TEST );
    24. // glDepthFunc( GL_LEQUAL );
    25. glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
    26. }
    27. void NgiDrawWiggle::paintGL()
    28. {
    29. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    30. glColor3ub(0,10,250);
    31. drawText("Time",-65,(50-7*h)/20.0);
    32. }
    33. void NgiDrawWiggle::resizeGL(int width,int height)
    34. {
    35. if ( height == 0 )
    36. {
    37. height = 1;
    38. }
    39. glViewport( 0, 0, (GLint)width, (GLint)height );
    40. glMatrixMode( GL_PROJECTION );
    41. glLoadIdentity();
    42. gluPerspective( 45.0, (GLfloat)width/(GLfloat)height, 0.1, 1000 );//
    43. glMatrixMode( GL_MODELVIEW );
    44. }
    45. void Draw::drawText(QString str,int x,int y)
    46. {
    47. glLoadIdentity();
    48. glTranslatef(30.0,30.0,-z);//"z" is the depth of the scene through the "z=(this->h/2)/(tan((45.0/2.0)*(3.1415926/180.0)))+0.5","h" is the height of the scene.
    49. glRotatef(90,0,0,1);
    50. renderText(x,y,0,str);
    51. }
    To copy to clipboard, switch view to plain text mode 
    I really don't know what I should do in the drawText(),thanks for your helping. Would you please give the complete debugged code?By the way, can I use "show list" in which renderText() is included?
    Last edited by showhand; 20th January 2006 at 08:19.
    There is no secret in the face of the code.

  5. #5
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: About QGLWidget::renderText

    Okay,

    So a did some modifications to your code in order to compile it...
    Strangely, I can't see any string drawn...I have to check all the code but I can't do it now

    Meantime, did you solve you problem ?

    Guilugi.

  6. #6
    Join Date
    Jan 2006
    Posts
    26
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: About QGLWidget::renderText

    Hi, thank you for your help these days. I have still not solve my problem. Would you please check my all code which I sent you some days ago. I was perplexed about the method. I will wait for your replying for ever. Would you mind telling me your email and I think I could send the message about other questions. Thank you !
    There is no secret in the face of the code.

  7. #7
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: About QGLWidget::renderText

    Sure,

    (One of) my e-mail addresses : guiluge@hotmail.com
    If you use MSN, you can add, me it will be easier to talk

    Good luck, I'll keep you in touch

    Guilugi.

  8. #8
    Join Date
    Jan 2006
    Posts
    26
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Thumbs up Re: About QGLWidget::renderText

    Hi, I'm so sorry for not keeping touch you because of some reasons these days. This is my MSN: ccc_xiaohan@hotmail.com. I'm afraid we have different time because you are in France and I am in China. But I'll try my best to keep touch with you as possible as I can.
    Thank you.
    There is no secret in the face of the code.

  9. #9
    Join Date
    Jan 2006
    Location
    Boston, MA
    Posts
    40
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: About QGLWidget::renderText

    What's in the result, guys ?

Similar Threads

  1. Qt3 -> Qt4 QGLWidget::renderText problem
    By cometlinear in forum Qt Programming
    Replies: 6
    Last Post: 1st October 2006, 01:52

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.