Hi, Are you sure it would be that hard to do in OpenGL? In my GtkGlExt based animation app (kudu.sourceforge.net) I have to draw a selection rectangle based on a mouse drag, which is essentially a 2D drawing over a 3D scene (including rotations and zooming), I simply switched to a orthographic viewing volume and then draw my rectangle, like this:
int viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); glPushMatrix(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0.0, viewport[2], 0.0, viewport[3]); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); /* Perform simple 2D drawing here */ /* sx, sy, ex, ey being (in my case) the four points of the rectangle */ glBegin(GL_LINE_LOOP); glVertex2i(sx, viewport[3] - sy); glVertex2i(sx, viewport[3] - ey); glVertex2i(ex, viewport[3] - ey); glVertex2i(ex, viewport[3] - sy); glEnd(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPopMatrix(); Unless I've misunderstood your question, I don't see why that wouldn't work... Apologies to all for the somewhat off-topic code pasting.. ;-) Daniel Pekelharing On Thu, 2006-02-09 at 08:40 -0600, Douglas Vechinski wrote: > 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. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list