[GtkGLExt] Cairo 2D rendering on gtkglext widget.



Hello,

I just started to use the gtkglext widget as a viewer for Inventor (Coin2) scenes on win32 and it works great so far.

By using an OpenGL widget in GTK, I think it should be possible to combine its powers with "native" GTK
rendering. From the documentation I see, that it is possible to render with gtk even between openglcalls.
Therefore it should also be possible to use cairo (??).

The idea is to draw a 2d "HUD" on the gl-rendered content to omit that nasty opengl way of mapping
textured quads to the viewport.

The GTK rendering works fine if I use functions like gdk_draw_rectangle with the casted glcontext:
gdk_draw_rectangle(GDK_DRAWABLE (gldrawable), ... )

But if I try to get an cairo context with this it will fail / crash:
gdk_cairo_create(GDK_DRAWABLE (gldrawable));
(some null-pointer problem)

So I thought lets try it another way:
gdk_cairo_create(widget->window);

This works as usual, but the drawing flickers or disappears sometimes. I just started to work with
gtk and therefore I'm not sure if I know -exactly- what I'm doing ;-) ... looks to me like I don't

In summary, what I tried is the following:
- Render the scene in the expose handler
- After the gl calls section swap the buffers.
- Create a cairo context with gdk_cairo_create(widget->window); to draw the HUD.

As result, the HUD image is there, but while animating or resizing the scene it flickers, dissapears for
some times ... where is the mistake? Is there some window update/invaildation with the rendered GLData
outside the expose handlers?


The questions in short:

1.) Even if I don't need it, is it possible to use cairo inside the gl rendering ?
2.) What is the correct way to draw with cairo on the widgets area (gl or not)
3.) Why will the image flicker if I do it "straight-forward" like explained above (what causes the refresh)


Regards
O. Merle



















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