+ Reply to Thread
Results 1 to 4 of 4

Thread: RenderText

  1. #1
    Join Date
    Jun 2011
    Posts
    192
    Thanks
    5
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default RenderText

    Hi,

    I'm trying to render text in my glwidget:

    Qt Code:
    1. QString text;
    2. text = "TEST test";
    3.  
    4. float x, y, z;
    5. x = 0;
    6. y = 0;
    7. z = 0;
    8.  
    9. float red, green, blue;
    10. red = 1;
    11. green = 0;
    12. blue = 1;
    13.  
    14. QFont font;
    15. font.setFamily("algerian");
    16. font.setPointSize(25);
    17.  
    18. glPushMatrix();
    19. glColor3f(red, green, blue);
    20. renderText(x, y, z, text, font);
    21. glPopMatrix();
    To copy to clipboard, switch view to plain text mode 

    All my experimenting is resulting in clipping of the text:

    1.) If I increase setPointSize beyond a certain point, clipping starts to happen.

    2.) If I change x y z coordinates, clipping happens (this one appears to change the size of the viewport for the text box)

    3.) If I setPointSize to around 15, I get what I'm going to call natural clipping i.e. half of "TEST test" is clipped i.e. you can only see "TEST".

    So it looks like there's like two viewing ports, one for whatever I want to display in paintGL() and one that gets created and pasted on top of the background viewport that contains the text (I'm going to call this 'display box').

    Two questions:

    1.) How do manipulate the 'display box' that contains the text so that I can resize it to any size I want and have it not get clipped?

    2.) How do I move the text around in my window because X Y Z seems to change the dimensions of the 'display box' not actually move the text around in my gl viewing box?
    Last edited by Atomic_Sheep; 14th September 2017 at 14:27.

  2. #2
    Join Date
    Jun 2011
    Posts
    192
    Thanks
    5
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: RenderText

    Figured it out, nothing to do with Qt but my lack of knowledge of OpenGL, just needed to play around with OpenGL commands to get it all to work!

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    3,411
    Thanks
    200
    Thanked 530 Times in 520 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: RenderText

    So you're going to keep it a secret?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. #4
    Join Date
    Jun 2011
    Posts
    192
    Thanks
    5
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: RenderText

    No secret, just needed to add:

    Qt Code:
    1. void glwidget::resizeGL(int iWidth, int iHeight)
    2. {
    3. glViewport(0, 0, iWidth, iHeight);
    4. }
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to Atomic_Sheep for this useful post:

    d_stranz (15th September 2017)

+ Reply to Thread

Similar Threads

  1. problem about renderText
    By tyzhang3 in forum Qt Programming
    Replies: 4
    Last Post: 19th September 2007, 22:35
  2. renderText with background
    By discostu in forum Qt Programming
    Replies: 0
    Last Post: 24th May 2007, 21:09
  3. renderText
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 24th August 2006, 14:29
  4. QGLWidget renderText
    By Rayven in forum Qt Programming
    Replies: 2
    Last Post: 14th July 2006, 22:02
  5. About QGLWidget::renderText
    By showhand in forum Qt Programming
    Replies: 11
    Last Post: 8th March 2006, 14:50

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