Re: pfPipeWindows & Texture on iR

New Message Reply Date view Thread view Subject view Author view

Angus Dorbie (dorbie++at++bitch.reading.sgi.com)
Wed, 22 Jan 1997 13:56:02 +0000


Looks great, what is it?

On Jan 22, 8:47pm, inca++at++public.bta.net.cn wrote:
> Subject: Re: pfPipeWindows & Texture on iR
>
> Thanks for the reply. i'm doing a difficult project that
> has 9 non-rectangular viewports with real-time responding.
> i know multi-windows is bad thing, but can't avoid it.
>

Why can't you avoid multiple windows?
A few overlapping channels and the use of arbitrary clip planes
or maybe just stencil operations would work.

eg:
You draw the channels masks to the stencil planes with
specific values. You don't need unique values for each channel
just ensure that for a given rectangle you have a unique value
for the channel of interest, I reckon you'd need 2 bits of
stencil info:
                      3
                 2 2

                3 1 3

                 2 2
                      3

Everything else is stencil == 0.

You do this once, then in the channel draw function you
set the appropriate stencil test so that rendering is only
performed when the stencil test value == framebuffer value.
Clip planes could then be used to reduce fill overhead.

Here's some OpenGL code I used in Performer for a similar
thing, the idea was to save some pixel fill time by culling
hidden blended pixels outside a circular region using stencil
operations, it didn't produce a measurable improvement for
my project but you have a different objective.

Cheers,
Angus.

static void
StencilHUD(pfPipeWindow *pw)
{
    double f;
    static int mapped = 0;
    float new_x = 0.0f, new_y = 0.0f;
    if(Visual_Mode != VISUAL_OPTICAL)
      return;

      pfSelectPWin(pw);

      glPushMatrix();
      glLoadIdentity();
      glMatrixMode(GL_PROJECTION);
      glPushMatrix();
      glLoadIdentity();
      glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
      glMatrixMode(GL_MODELVIEW);

      glDisable(GL_CULL_FACE);
      glDisable(GL_DEPTH_TEST);
      glEnable(GL_STENCIL_TEST);

      glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);

        glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT);
        glColor3f(0.0f, 0.0f, 0.0f);

        /* Clear stencil planes to one over entire window */
        glClearStencil(0);
        glClear(GL_STENCIL_BUFFER_BIT);
        /* were a drawin' */
        glStencilFunc(GL_ALWAYS, channel_stencil_value, 0x3);
        glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);

        glBegin(GL_TRIANGLE_FAN);
        for(f = 0.0; f< 359.5; f+=1.0)
        {
          pfSinCos((float)f, &new_x, &new_y);
          glVertex2f(new_x, new_y);
        }
        glEnd();

      glEnable(GL_CULL_FACE);
      glEnable(GL_DEPTH_TEST);

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
}

Use this in your channel draw function:

      glStencilFunc(GL_EQUAL, channel_stencil_value, 0x3);
      glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
      glEnable(GL_STENCIL_TEST);
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:54:25 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.