Non rectangular viewports?

Non rectangular viewports?

Post by <U11.. » Fri, 19 Feb 1993 08:23:26



Is their anyway to simulate non rectangular viewports using GL ?

To give an idea of what I want to do:
------------------------------------

Say I have a cube:

                             top
                   -----------------------
                  /|                    /|
                 / |                   / |
                /  |                  /  |
               /   |                 /   |
              /    |       front    /    |
             /     |               /     |
            -----------------------      | right
            |      |              |      |
            |      |              |      |
            |      |              |      |
            |      ---------------|-------
      left  |     /               |     /
            |    /                |    /
            |   /                 |   /
            |  /      bottom      |  /
            | /                   | /
            |/                    |/
            -----------------------

Now, I want to designate a viewpoint somewhere inside the cube and
then use the "window()" function to calculate five windows corresponding
to the front, left, right, top and bottom of the cube and then arrange
them on the screen in the following manner:

                   ------------------------------------------
                   |\                                      /|
                   | \                                    / |
                   |  \               top                /  |
                   |   \                                /   |
                   |    \                              /    |
                   |     \----------------------------/     |
                   |     |                            |     |
                   |     |                            |     |
                   |     |                            |     |
                   |     |                            |     |
                   |     |                            |     |
                   |left |           front            |right|
                   |     |                            |     |
                   |     |                            |     |
                   |     |                            |     |
                   |     |                            |     |
                   |     |                            |     |
                   |     /----------------------------\     |
                   |    /                              \    |
                   |   /                                \   |
                   |  /             bottom               \  |
                   | /                                    \ |
                   |/                                      \|
                   ------------------------------------------

I know this CAN be done by texture mapping onto a cube using one of our VGX's,
BUT I want the program to run on a Personal Iris also, so I want to stay away
from texture mapping.

Since by using the "viewport()" function you can only designate a rectangular
area on the screen as a viewport, is there any way to simulate this effect
by shearing?

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

| Graduate Research Assistant                                                 |
| EECS Dept.                                                                  |
| University of Illinois at Chicago                                           |
|                                                                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

 
 
 

Non rectangular viewports?

Post by Gavin Be » Sat, 20 Feb 1993 04:15:59



>Is their anyway to simulate non rectangular viewports using GL ?

Cool question.

The old GL demo called "light" did this-- it had an MTV mode where you
could take the projected image and make it look like it was on a flat
wall hurtling through space.

You should be able to get almost the effect you want by playing with
the projection matrix.  The stuff you draw will cover the entire
(rectangular) viewport, though, so you need to keep primitives from
being drawn outside the non-rectangular region.

The old "light" demo did some colormap tricks to make stuff drawn
outside its borders black (it was designed to run in non-zuffered,
colorindex mode).

There are easier ways of drawing into non-rectangular regions.  You
can do any of:

-- Here's a technique that should work on all machines with z-buffers:
For each of left/right/top/bottom/back, do:
  Clear the z-buffer.
  Disable writing into the color bitplanes by calling wmpack(0)
  Draw a polygon just beyond the near clipping plane in all the
   other images (e.g. right/top/bottom/back if the left image is
   being drawn).  This will make the z-buffer test fail for any
   pixels in these areas, leaving a nice, non-rectangular area that
   will be drawn into.
  Now setup the special perspective transformation and draw the scene.

-- Use the stencil bitplanes, if you have them.

-- Use the GL's arbitrary clipping plane feature, if your machine
supports it.

--