Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Can you use Outline font in 2d environment?

  1. #1
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    6

    Can you use Outline font in 2d environment?

    Hi,

    I'm having a hard time using my outline font code in a 2d environment. I've used glOrtho(-8.0f,width,height,-30.0f,-1.0f,1.0f);

    However, after I've initialize the list, and I call
    RenderFont(50.0f, 50.0f, 0.0f, m_fontListBase, "OpenGL Rocks!"); nothing is being displayed.

    So, can somebody please confirmed for me if it is possible to use Outline font in a 2d environment in Opengl?

    Thanks,
    Sky

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: Can you use Outline font in 2d environment?

    Of course it is possible, there is no real difference between 2d and 3d (it is all 3d anyway) other then a different projection matrix. Probably your coordinates are bad, so that the text appears somewhere outside the visible area.

  3. #3
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Can you use Outline font in 2d environment?

    The vertex data of the font's glyphs are scaled to lie in the [0.0, 1.0] range!
    If you have an ortho setup with window coordinates and your start point (50, 50) is onscreen, the font will be displayed really small.
    Try with a smaller glOrtho setup or add a glScale to the font rendering.

  4. #4
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    6

    Re: Can you use Outline font in 2d environment?

    But, I'm having a hard time using my outline font code in a 2d environment.
    My ResizeGLScene is:
    GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
    {
    if(height == 0)
    {
    height = 1;
    }
    glViewport(0,0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0f,width,height,0.0f,-100.0f,100.0f); // Create Ortho 640x480 View (0,0 At Top Left)
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    }

    My InitGL function has a call to:
    m_fontListBase = CreateOutlineFont("Verdana", 48, 0.2f);

    My DrawGlScreen has a statement:
    glPushMatrix();
    glScalef(2.0f, 2.0f, 2.0f);
    RenderFont(200.0, 200.0, 0.0, m_fontListBase, "OpenGL Outline Fonts!");
    glPopMatrix();

    But only a tiny little dot is being displayed at 200,200. I've added/subtracted from the Z value and nothing is happining.

    Can somebody please help or show me a sample code that uses glOrtho and Outline font together

  5. #5
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: Can you use Outline font in 2d environment?

    Just do what Relic says...

  6. #6
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    6

    Re: Can you use Outline font in 2d environment?

    Zengar, my above code has got the glScalef as pointed out by relic but it still is not working.

  7. #7
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Can you use Outline font in 2d environment?

    Maybe because it's too small or it belongs inside your RenderFont() routine?
    Can't tell because we neither know the matrix state at the time you call glScalef() nor what the RenderFont() routine actually does.

  8. #8
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: Can you use Outline font in 2d environment?

    Well, from what relic said every character will be about one pixel large. If you enlarge it twice (with your glScale) it will still be about two pixels. No wonder you see only dots. Try another scaling.

  9. #9
    Senior Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    990

    Re: Can you use Outline font in 2d environment?

    I don't know what's inside the RenderFont() routine but if you're scaling outside this function it's possible that the initial raster position gets scaled as well so that it ends up outside your viewport.

  10. #10
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Can you use Outline font in 2d environment?

    Can somebody please help or show me a sample code that uses glOrtho and Outline font together
    With your wglUseFontOutlines display lists already constructed try something like this instead of your RenderFont() routine (without the glScalef()):

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    // effectively a unit cube ortho setup
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glListBase(m_fontListBase);
    glCallLists(1, GL_UNSIGNED_BYTE, "A");

    That should render a big "A" into the upper right quadrant of the viewport, because the origin is in the center of the screen and the glyph data is in the range [0, 1].

    Now add glOrtho calls like this to see how that affects the renderings size (smaller since the projected area got bigger):
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-2.0, 2.0, -2.0, 2.0, 1, -1);
    ...

Page 1 of 2 12 LastLast

Similar Threads

  1. outline font not showing up
    By p.apaya in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 06-06-2012, 09:17 AM
  2. Antialiasing for Outline Font
    By michalsz in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 03-08-2011, 11:25 AM
  3. FTGL Fill & Outline font
    By thibault in forum OpenGL: General
    Replies: 4
    Last Post: 01-22-2009, 01:47 PM
  4. Outline Font and FOG problem
    By skyeyes in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-08-2008, 04:57 PM
  5. Problem with outline font
    By cyam95 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-29-2001, 10:30 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