How do I flip upside down fonts in FTGL

Posts: 2
Joined: 2014.03
Post: #1
I just useFTGL to use it in my app.
I want to use the version FTBufferFont to render font but it renders in the wrong way.
The font(texture?buffer?) is flipped in the wrong axis.

[Image: SS8am.png]

I want to use this kind of orthographic settings:

void enable2D(int w, int h)
        winWidth = w;
        winHeight = h;
        glViewport(0, 0, w, h);
        //I don't even want to swap the 3rd and 4th param
        //because I like to retain the top-left as the origin
        glOrtho(0, w, h, 0, 0, +1);

I render the font like this:

//No pushing and popping of matrices

    //No translation

    font.Render("Hello World!", -1, position, spacing, FTGL::RenderMode::RENDER_FRONT);

On the other forums, they said, just scaled the y-axis down to -1, but it wont work in mine. Example:

[Image: fAGg1.png]

font is above the screen

I can't see relevant problem like in mine in google so I decide to ask this here again.

How can I invert texture's y-axis without modifying its source code ? (assume its read only)
Quote this message in a reply
⌘-R in Chief
Posts: 1,277
Joined: 2002.05
Post: #2
Unless there's a setting in FTGL to flip Y itself, then you'll need to invert Y and offset the origin when drawing text. Not a big deal.
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #3
Better yet, avoid FTGL like the plague...
Quote this message in a reply
Posts: 1,234
Joined: 2002.10
Post: #4
Quote://I don't even want to swap the 3rd and 4th param
//because I like to retain the top-left as the origin
glOrtho(0, w, h, 0, 0, +1);

In my opinion, this creates more problems than it solves. Yes, putting the origin at the top left makes intuitive sense, and you can fix the transformation Y inversion in several ways. However there are also several OpenGL API which you can not fix. As soon as you use glReadPixels, glViewport, glScissor, glBlitFramebuffer, glCopyTex[Sub]Image, glCopyPixels, glWindowPos, etc, then the API expects the origin at the bottom left, and you'll have to convert between the two coordinate systems anyway.

It's simpler overall to keep window coordinates in the system defined by the API.
Quote this message in a reply
Posts: 338
Joined: 2004.07
Post: #5
Quote:In my opinion, this creates more problems than it solves.

I can vouch for this. I did 2D stuff in OpenGL using the top-left as the origin for years, using this exact method to do it.

It was a huge pain in the ass.

Things like text weren't the only thing to get flipped, and I'd have to replace (y) with (1.0-y) and similar things all over my code to get everything looking right, as well as offsetting things downward by their size.

It got so bad that I'd have something get flipped on me, and when I fixed it, the fix would flip like three other things. Wacko It was a friggin' nightmare.

I finally switched everything back when I moved back to 3D (which seemed to flip half of everything, randomly) and it hasn't given me problems since. (Although my brain still thinks of positive-y as downward sometimes.)

The sooner you learn to love and work with OpenGL's coordinate system instead of trying to make it work around you, the happier you'll be. Trust me.

Justin Ficarrotta
"It is better to be The Man than to work for The Man." - Alexander Seropian
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Xcode and FTGL hiddenspring81 7 11,240 Oct 10, 2013 03:00 PM
Last Post: ardowz
  Bitmap fonts markhula 6 10,779 Feb 27, 2011 12:55 PM
Last Post: markhula
  Anyone run into this problem with FTGL? wadesworld 1 4,040 Apr 21, 2009 02:19 PM
Last Post: Oddity007
  FTGL crash when exiting program Malarkey 8 7,962 Mar 27, 2008 03:33 PM
Last Post: Malarkey
  Anti-aliased bitmapped fonts Jake 12 10,012 Nov 19, 2007 05:02 PM
Last Post: Jake