
[ redirecting to the hopengl list... ] Am Dienstag, 12. Juli 2005 14:32 schrieb Felix Breuer:
What is the recommended way to render fonts (i.e. text) using GHC and OpenGL?
I know about libraries/GLUT/examples/RedBook/Font.hs, but I do not want to define the font's letter by hand. So, my questions are:
* Is there a ready-to-use way load fonts (e.g. using FreeType)?
AFAIK, there is no Haskell binding for loading fonts and/or a FreeType binding. Any volunteers?
* Is there a library implementing some OpenGL font rendering method (bitmap, texturemap, outline, etc.) that can be used from GHC?
Not yet, apart from the rudimentary font support in GLUT, see: http://haskell.org/ghc/docs/latest/html/libraries/GLUT/Graphics.UI.GLUT.Font...
* Does anyone have example code for the above?
I think the most comprehensive overview is here (of course for C only): http://www.opengl.org/resources/features/fontsurvey/ If you are looking for high performance font rendering with current graphic cards, by all means use texturing. This is what all mainstream cards that I know of are optimized for, and it has a few nice benefits like scalability and anti-aliasing. Using other techniques you easily end up waiting for the loooong graphic pipelines to be flushed before you can "simply" do some manipulations of the frame buffer. It can be very surprising if a simple frames-per-second counter displayed in some corner of the screen drastically reduces the FPS of your home-grown Quake-clone. Of course this has *never* happened to me... ;-) Cheers, S.

On Thu, 14 Jul 2005 19:56:47 +0200
Sven Panne
AFAIK, there is no Haskell binding for loading fonts and/or a FreeType binding. Any volunteers?
Looking at the page you mentioned, FTGL might be the library one would want to create bindings for: it handles font loading as well as rendering in all its variants. I have no experience whatsoever with creating bindings, but I might have a go at it, if you think it is a reasonably easy task. And if you are ready for a flurry of questions regarding the HOpenGL bindings... I would start working on it in about a month.
If you are looking for high performance font rendering with current graphic cards, by all means use texturing. This is what all mainstream cards that I know of are optimized for, and it has a few nice benefits like scalability and anti-aliasing. Using other techniques you easily end up waiting for the loooong graphic pipelines to be flushed before you can "simply" do some manipulations of the frame buffer. It can be very surprising if a simple frames-per-second counter displayed in some corner of the screen drastically reduces the FPS of your home-grown Quake-clone. Of course this has *never* happened to me... ;-)
:) So if performance does matter you recommend avoiding framebuffer operations in general? I am thinking about how to display a clickable UI in front of a 3D scene and, naively, I would have drawn pixmaps on top of the scene using the framebuffer. If I try to do the same using texture mapped polygons, what is the best setup/projection to make it look like a flat window like UI? How to avoid perspective and blurring effects? (Excuse my many OT questions, I am just curious. Feel free to ignore them.) Thanks, Felix

On 7/15/05, Felix Breuer
So if performance does matter you recommend avoiding framebuffer operations in general? I am thinking about how to display a clickable UI in front of a 3D scene and, naively, I would have drawn pixmaps on top of the scene using the framebuffer. If I try to do the same using texture mapped polygons, what is the best setup/projection to make it look like a flat window like UI? How to avoid perspective and blurring effects?
Use orthogonal projection with the same width and height as your resolution (to make it easier to target a specific position in pixel-units) and make sure you draw your polygons so they're the exact size of the bitmap of the texture. Remember that in OpenGL (x,y)=(0,0) is situated at your lower left and not your upper left (as in, for example, windows GDI). /S -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862

Sebastian Sylvan wrote:
So if performance does matter you recommend avoiding framebuffer operations in general? I am thinking about how to display a clickable UI in front of a 3D scene and, naively, I would have drawn pixmaps on top of the scene using the framebuffer. If I try to do the same using texture mapped polygons, what is the best setup/projection to make it look like a flat window like UI? How to avoid perspective and blurring effects?
Use orthogonal projection with the same width and height as your resolution (to make it easier to target a specific position in pixel-units) and make sure you draw your polygons so they're the exact size of the bitmap of the texture. Remember that in OpenGL (x,y)=(0,0) is situated at your lower left and not your upper left (as in, for example, windows GDI).
You can set up the projection matrix so that the origin is in the
top-left. However, this will result in a negative determinant, so
polygons will be "inside-out" (e.g. the front/back-facing test will be
inverted).
--
Glynn Clements
participants (4)
-
Felix Breuer
-
Glynn Clements
-
Sebastian Sylvan
-
Sven Panne