Re: [GtkGLExt] How to show text?



If you are writing any new code, you should absolutely not use the
function gdk_gl_font_use_pango_font() because it has gone away in the
latest version of GtkGlExt.  In fact it was a very crufty function to
begin with.

That said, a good way to render text in your OpenGL widget is shown in
the example font-pangoft2.c that comes with GtkGlExt source
distribution.  I took ideas from that example and used modified code
in a project I'm working on, GtkRadiant, which is an open source map
editor tool for Quake III based games.  If you want to see my code for
rendering text in OpenGL widgets, you can:

  svn checkout https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/trunk

The file that has the font rendering code will then be radiant/glwidget.cpp.

There is one annoying thing with the way these two examples work.  The
"origin" of the text image is the upper left corner of the text area.
(Or is it the lower left corner?  I can't remember now.)  If the
origin point is outside the widget viewport, the entire text won't get
rendered.  So for example If you render the text "abcdefg" and the
letter 'a' is just barely outside the widget to the left, the entire
string won't get rendered (it "disappears").  If you figure out a
clean way to address this issue I'd like to know about it.

2011/3/30 YangXi <jiandingzhe msn com>:
> In OpenGL, it seems I should use glWindowPos() and glDrawPixels() to show
> texts on screen.
> However, I still don't know how to get text bitmap from Pango, and what is
> the usage of gdk_gl_font_use_pango_font().
> Any hints? Thanks a lot!
> _______________________________________________
> gtkglext-list mailing list
> gtkglext-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkglext-list
>
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]