[comp.sys.sgi] Opaque patterns

acl3k@topaz.cs.Virginia.EDU (Allan Christian Long) (05/09/91)

Could someone please tell me how to do opaque patterns?  Here's what
I mean:  I have defined a pattern with defpattern.  When I draw
filled primitives with that pattern set, pixels corresponding to
1's in the pattern get set to the current color and pixels
corresponding to 0's in the pattern are unchanged.  Sometimes
this is what I want.  BUT, sometimes I want the 1's in the
pattern set to one color, and the 0's set to a different color.
	I have tried various things, such as drawing the primitive
once with logicop(LO_NSRC) in one color and again with logicop(LO_SRC)
in a different color, but I end up with the same thing as if I
had just drawn it the second way.
	I guess I could invert the pattern myself and use two
different patterns to get what I want, but I was hoping there
would be an easier way.
	Thanks in advance for any help.



A. Chris Long, Jr.
acl3k@virginia.edu
"You can't have everything.  Where would you put it?"  - Steven Wright

tarolli@westcoast.esd.sgi.com (Gary Tarolli) (05/09/91)

In article <1991May8.202442.21658@murdoch.acc.Virginia.EDU>, acl3k@topaz.cs.Virginia.EDU (Allan Christian Long) writes:
> Could someone please tell me how to do opaque patterns?  Here's what
> I mean:  I have defined a pattern with defpattern.  When I draw
> filled primitives with that pattern set, pixels corresponding to
> 1's in the pattern get set to the current color and pixels
> corresponding to 0's in the pattern are unchanged.  Sometimes
> this is what I want.  BUT, sometimes I want the 1's in the
> pattern set to one color, and the 0's set to a different color.
> 	I have tried various things, such as drawing the primitive
> once with logicop(LO_NSRC) in one color and again with logicop(LO_SRC)
> in a different color, but I end up with the same thing as if I
> had just drawn it the second way.
> 	I guess I could invert the pattern myself and use two
> different patterns to get what I want, but I was hoping there
> would be an easier way.
> 	Thanks in advance for any help.
> 
The only way I know how to do this is to invert the pattern as you suggested
and draw the polygon again.  Switching patterns every polygon is not
efficient, so if you can draw all your polygons and then switch patterns
and redraw all your polygons yhou will be better off.  

What you need is a choice between transparent and opaque patterning (and
lien stippling).  This also requires a way to set the background color
that would get displayed when there is a 0 in the pattern.  I will
raise this issue internally to GL developers for future GL releases....
However, this kind of 2-D patterning is more in line with X graphics
than GL graphics...

--------------------
	Gary Tarolli

kurt@cashew.asd.sgi.com (Kurt Akeley) (05/09/91)

In article <1991May8.202442.21658@murdoch.acc.Virginia.EDU>, acl3k@topaz.cs.Virginia.EDU (Allan Christian Long) writes:
|> Could someone please tell me how to do opaque patterns?

stuff deleted

|> 	I guess I could invert the pattern myself and use two
|> different patterns to get what I want, but I was hoping there
|> would be an easier way.

You're right, the only general technique for implementing opaque
stipple using the Iris GL is to draw twice, once with the pattern
using the foreground color, and again with the inverse of the
pattern, using the background color.  In many cases, however,
it is easier and faster to first clear an entire region to the
background color using no pattern, then draw patterned objects
(such as text) using the foreground color.

-- Kurt