Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: How to render road name text

Hybrid View

  1. #1
    Intern Newbie
    Join Date
    Aug 2013
    Posts
    39

    How to render road name text

    I am using a texture atlas and character sprites to render road names on a map.

    This text will not be updated whilst the program is running.

    All text will be loaded into one vbo, which will consist of vertices and texture coords. It will have an IBO as well.

    I am just trying to figure out how to pass in position data and what the shaders can do.

    (Sounding out my thoughts)
    When the map is zoomed in or out, the text will remain the same size, so the position data for each character must have a central point that it is relative to them all and shader needs to manipulate this as per the scale of the map.

    Could use some advice how to proceed.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    If you want to continually scale the text, I would store the text strings in unit length from -0.5 to 0.5. This will make the scaling easiest since you can just supply a simple uniform vec4 x,y,z and scale and apply this to each vertex of the string when you render the string

  3. #3
    Intern Newbie
    Join Date
    Aug 2013
    Posts
    39
    Please bear with me I'm new to this. Can you explain any further?

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    OK,
    lets say I want to display the string "road name" and place it centred at 10,0,20 on the map.

    If the string needed to be 50 units wide from the camera I could draw it in a box from x = -15 to 35
    If I move the camera further away I have to re-scale so it might be -30 to 70 (double)

    I suggest you start with the string inside -0.5 to 0.5.
    Now for the first view I would scale my vertices by 50 and add the string location (10,0,20)
    For the second view I would scale by 100 and add the origin.

    So when you render the string you just need to supply the origin and scale.

    Note this simple version only works if the map is flat. If its heights change you have to adjust each vertex height from a height map; you may also need to highly tessalate the string mesh so that it fits the terrain well

  5. #5
    Intern Newbie
    Join Date
    Aug 2013
    Posts
    39
    Hi Tonyo,

    My text is going to be rendered character by character not as a string of characters. So this changes things a bit, how would you solve this?

    My map is flat, z = 0.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •