Results 1 to 12 of 12

Thread: About QGLWidget::renderText

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    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.

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
  •  
Qt is a trademark of The Qt Company.