Results 1 to 5 of 5

Thread: How to draw text that faces the viewer?

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    2

    How to draw text that faces the viewer?

    I use the excellent TChart package for making presentation graphics in my app. For certain charts I want to do, using TChart's options for OpenGL are just beautifully superb.

    BUT I mystified about how to draw text that faces the viewer, even if the chart itself is oblique or rotated or whatever. Here is an example of what I'm drawing:



    I'd like to have the labels above the boxes (shown as "Hello" in this sample) face the viewer. As a possible workaround, I tried using TextOut and TextOut3D as well, drawing some sample text (also shown in this sample) in an "onAfterDraw" event. In all cases, the text "faces" whatever was "frontward" in the original coords, not towards the viewer.

    This can't be this hard, can it? How do I draw text that faces the viewer?

    (THANK YOU!)

  2. #2
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Los Angeles
    Posts
    374

    Re: How to draw text that faces the viewer?

    This is a TChart question, not an OpenGL question.
    Am I doing your homework for you?

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    2

    Re: How to draw text that faces the viewer?

    Well, how would you do it in OpenGL?

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2010
    Posts
    24

    Re: How to draw text that faces the viewer?

    glrotated or glrotatef perhaps?

    Perhaps calculating the angle between the direction the camera is pointing and the direction the text is pointing via dot product then do glrotated/f on the text?

    In this case, the z doesn't even matter~

  5. #5
    Senior Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    356

    Re: How to draw text that faces the viewer?

    2d way:
    Compute the projection of the point in window coordinate and draw in 2d. Better quality, no filtering issues, better control of the size of the text, but the text will not be immersed in the scene will overwrite everything.

    3d way:
    The direction of the quad for the text should be exactly the opposite of the camera direction. You can compute the vertex point manually with a little of math, another way is to setup the model matrix of the object in a way that the rotation part of the model matrix must be the inverse of the rotation part of the camera matrix.
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

Similar Threads

  1. Front faces, back faces and edge-on faces
    By sam_hawker in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 02-23-2017, 07:24 AM
  2. Text rendering class does not draw text
    By th0masr0ss in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-23-2015, 09:10 PM
  3. Trying to draw solids, faces not appearing correct
    By Lefteris in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 01-04-2010, 07:25 AM
  4. How many faces can I draw?
    By defiopeon in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 04-10-2003, 07:31 AM
  5. Texture that always faces to the viewer?
    By Diapolo in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-04-2001, 03:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean