Text rendering on different projection matrices

Started by
1 comment, last by mfawcett 18 years, 10 months ago
Hi! I've created a simple static library (FreeType2 wrapper) for use within SDL+OpenGL applications (it will be released soon), and it works fine for me (I mostly code 2D applications that run under orthogonal projection). The problem: people using perspective projection won't get the text rendered right! It wouldn't be hard to change the code (I know how to do it), but every WAY to do it seems to have some associated overhead. Question: How would you proceed? Some options: 1) Create two methods for printing, "renderOrtho" and "renderPerspective", and define wich one to use (using function pointers) based on a constructor argument; 2) Create one single bloated print method that do everything and works on every environment; 3) Force the programmer to change the matrices attributes himself before calling my library methods; 3) Distribute two lightweight versions of the library (an ortho version and a perspective version); Thanks a lot! PS.: I'm using Visual C++ 6.0, SDL, OpenGL and FreeType2
Advertisement
You could add 2 functions that change the projection matrix (using glPushMatrix() and glPopMatrix()) when starting and finishing the text rendering for use with perspetive projectoin matrices. This way if they're already working with a orthogonal projection matrix, they wont need to call the functions, but if they're working with a perspective projection matrix, they can call them. If anything goes wrong, then the problem's out of your hands, 'cause you've given them everything they need to get the job done. ;)
You're writing a library. Force the user to do that work himself. The programmer(s) will write a wrapper for the method they use most.

You could have a look at FTGL which is also an OpenGL wrapper around FreeType.
--Michael Fawcett

This topic is closed to new replies.

Advertisement