PDA

View Full Version : Text Rendering



ToddAtWSU
09-29-2006, 11:54 AM
I am still haveing major problems with text rendering inside a Qt application I am making. I need to be able to do 2 things, draw text fast and draw rotated text. I originally planned on using Qt's function call QGLWidget::renderText( ) but this does not allow for rotated text. I tried to use QPainter::drawText( ) after using QMatrix::rotate( ) but this did not seem to work either. I did some research and learned that using a QPainter on top of a QGLWidget is very slow and that QGLWidget::renderText( ) is also very slow. I saw a link to an OpenGL text rendering library called FTGL. I got the text to display after installing the library, but it is also slow.

I have a 2-D plot that I can zoom in/out on and pan. Whenever I am zoomed out, it pans at a a reasonable speed. But whenever I start to zoom in and then pan the image, it slows up drastically. If I take off all of my text drawing, (which is just numbers at the corresponding grid lines and axis labels), the plot zooms, pans, and redraws very fast. But with the text drawing I have wait times up to 30-60 seconds long when you get to an ortho <=20. Does anybody know what I can use to render text in a fast manner with small orthos and that can also be rotated? Thanks for all your help!

k_szczech
09-29-2006, 12:49 PM
FTGL is most likely re-creating fonts to adjust quality when you zoom. Perhaps you can find a way to set font quality to some fixed level and avoid that.
You can also try this:
http://quesoglc.sourceforge.net/
Looks like it can be used in both Linux and Windows but I never used it so I don't know if it works fast.

09-29-2006, 01:25 PM
"I originally planned on using Qt's function call QGLWidget::renderText( ) but this does not allow for rotated text."

They probably use glCallLists or glBitmap directly, which would not allow those transformations on anything but the current raster position itself.

"But whenever I start to zoom in and then pan the image, it slows up drastically."

That makes sense. To get the same font quality at different reolutions, the font would need to be recreated at the new zoom level. Otherwise the font would blur (think of stretching a textured quad with a single font glyph).

Creating fonts is not very difficult. You can prerender images of fonts to textures and use quads to render them with arbitrary rotations and translations. Scaling will require a lerped transition to a different prerendered font page or creation of a new one on the fly to match the required resolution.

ToddAtWSU
10-01-2006, 05:41 AM
I had looked at that QuesoGLC but I spent ~4-5 hours trying to get LibXML2 to install and could not get things to work correctly so I gave up on trying to use QuesoGLC. With FTGL (http://homepages.paradise.net.nz/henryj/code/#FTGL) it talks about being able to display text as:


Bit maps
Anti aliased pix maps
Texture maps
Outlines
Polygon meshes
Extruded polygon meshes I chose bitmaps to render my text in but would one of the other methods be more preferable? I am not very proficient in which methods are slow for scaling and panning, so sorry about that. I guess I should say however that the text will never change size. It is just being used for labels and to show me values of my grid lines, I am never trying to make larger text images. Thanks again!

ToddAtWSU
10-01-2006, 05:43 AM
Smedly, I am confused by a comment you made.


They probably use glCallLists or glBitmap directly, which would not allow those transformations on anything but the current raster position itself. I believe I read in the Qt documentation that renderText does use display lists, but display lists can be rotated and scaled. I have done this many times so why would the text not be allowed to be rotated? Thanks for your clarification.

10-02-2006, 08:03 AM
Hi,

I was referring to display lists generated by wglUseFontBitmaps/glXUseXFont, which generate a sequence of glBitmap commands.

Display lists cannot be rotated, of course, but commands can be embedded in them to transform the geometric primitives that follow. In the case of glBitmap, however, only the raster position is transformed, not the bitmap itself.

In other words, my assumption here is that Qt is using glBitmap for text rendering. I've never used Qt, so I can only speculate.

What if anything does the Qt documentation say on the subject? I would think it should specify what sort of transformations are possible when rendering text, or something to that effect.

Cheers

ToddAtWSU
10-04-2006, 08:56 AM
I got FTGL working faster for me now. I am using FTGLBitmap right now but I am guessing I will have to use something different if I want to rotate the text. FTGL also allows for texture mapping, but I don't think this is really desirable since my project is a 2-D plot. If I do have to use texture mapping I will just need to create a 2-D quad that is positioned correctly and is as wide as my string. Is this all I would need to do so I could rotate the text? Thanks again!