Hi all, may I ask your help. I'm trying to render an OpenGL scene on a GtkGLExt window (to be precise I'm using gtkglextmm) and then to draw over it with plain Gtk+ drawing commands (that is, Gdk or Cairo). Specifically, I want to draw some text in the same font used by the other widgets in my gtkglmm application. From the example in the documentation (http://gtkglext.sourceforge.net/reference/gtkglextmm/font_8cc-example.html) I see that the recommended method for drawing text is to map every individual character onto an OpenGL display list. But that is suboptimal as the text is rendered without antialiasing, ligatures etc. When compared to the text in neighboring widgets, the difference is easily spotted; some fonts look really ugly. Furthermore, handling non-ascii text (for example non-Latin languages) is going to introduce extra complexity. It would be much better if I could draw text directly from a Pango layout. So I tried adding some Cairo commands after the OpenGL commands in the expose handler. This works only partially: it is ok if the window is only redrawn occasionally, but if I refresh it at a given framerate, as I need to, the text "flashes" (try the attached example). I understand that GtkGLExt suppresses the normal Gtk+ double buffering, and relies on OpenGL's own double buffering; so when the OpenGL buffers are switched, the text drawn by Cairo gets erased on screen, and only after some delay it is redrawn. Thus the "flashing". Is my diagnosis correct? If so, how can I work around this problem? Can I restore the Gtk+ double buffering, so that the window is actually redrawn after *both* the OpenGL scene *and* the Cairo text have been drawn? Or can I direct Cairo to draw on the OpenGL back buffer? Or is there another way? Thanks for any help that you can give me. Gerardo
Attachment:
test.cc
Description: test.cc