Allan Schaffer (allan++at++sgi.com)
Wed, 22 Dec 1999 16:47:40 -0800 (PST)
Well I'll admit I'm stumped, I can't seem to get pipewindow-based
overlays to work properly on my trusty Octane MXE either.
I will point out a minor buglet: your call to glRectf() at that
point in the channel draw callback is being made relative to the
current view matrix; so as the view spins, your rectangle is spinning
too. You should probably set up an ortho projection matrix and an
identity transformation matrix when doing your overlay drawing (and
then restore it afterwards).
However let me suggest a different and far higher-performance
approach than pipewindow-based overlays. Rather than incurring the
[pretty nasty] overhead of switching back & forth between the
standard and overlay visuals all the time, get rid of _all_ the
overlay setup stuff in your code and simply draw your "overlaid
graphics" in the draw callback. Use some z-buffer tricks so that
what you draw always ends up on top, and setup the matrices so you
have a easy 2D drawing area.. Here's what I mean:
static void DrawChannel (pfChannel *channel, void *data)
{
static pfMatrix tempmat;
/* clear & draw regular scene for this channel */
pfClearChan (channel);
pfDraw();
/* Configure the Z buffer so that any GL commands that
follow will always pass the Z test */
glDepthFunc(GL_ALWAYS); /* always draw */
glDepthMask(GL_FALSE);
/* Ensure sane graphics state */
pfPushState();
pfBasicState();
/* Save current projection matrix, to restore later */
glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat *)tempmat);
/* Load an ortho projection matrix for easy 2D positioning */
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((GLfloat *)idmat);
glOrtho(-10.0, 10.0, -10.0, 10.0, 1.0, -1.0);
/* Push current modelview matrix & load identity */
glMatrixMode(GL_MODELVIEW);
pfPushMatrix();
pfLoadMatrix(idmat);
/* HUD/text drawing goes here */
glRasterPos2f (-3.0f, 0.0f);
drawXFontString("text over scene");
pfPopMatrix();
/* restore saved projection matrix */
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((GLfloat *)tempmat);
glMatrixMode(GL_MODELVIEW);
pfPopState();
/* restore default Z functions */
glDepthFunc(GL_LEQUAL);
glDepthMask(GL_TRUE);
}
There's an example of this in
/usr/share/Performer/src/pguide/libpf/C/text.c
Allan
-- Allan Schaffer allan++at++sgi.com Silicon Graphics http://reality.sgi.com/allan
This archive was generated by hypermail 2.0b2 on Wed Dec 22 1999 - 16:47:50 PST