[GtkGLExt] How to perform 2D drawing on top of 3D OpenGL scene



I'm writing a program using Gtk and GtkGLExt.  I have a drawing area
which is using OpenGL to display a scene.  I receive mouse motion events
to rotate, translate, zoom, on this scene.  In the display window, I
would also like to draw some primitives on top of the scene rendered by
OpenGL.  For example, I would like to draw a small coordinate axis in
one corner of the window that is oriented in the same manner as the
scene. (While this particular example might be done via OpenGL, I
believe a lot of extra work would need to be done to keep in in a
particular location on the screen as and a consistent size as rotation,
zooming, and panning are performed.  Knowing the current orientation and
view location, I can calculate the appropriate transform and draw three
lines of different colors.)

At the moment, I'm just drawing some lines on the screen using
gdk_draw_lines in the Expose event callback function which is
responsible for redrawing the OpenGL scene.  I've tried placing the
gdk_draw_lines before and after swapping the front and back buffers.  I
see the lines, but they flicker (when mouse dragging is used to orient,
zoom, pan the scene) and typically do not show up in the last update
when the mouse stops moving.

The coordinate axes are not the only thing I wish to draw, I may also
wish to draw other lines, circles, etc.  So in general my question is
what is the proper way of performing 2D drawing (which may not have
anything to do with the underlying 3D OpenGL scene) on top of an OpenGL
drawing area and have it show up with out flicker.




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