[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx demo/irregu4.py libutil/Irregu.hxx
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx demo/irregu4.py libutil/Irregu.hxx |
Date: |
Wed, 13 Nov 2002 09:10:09 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/11/13 09:10:09
Modified files:
gfx/demo : irregu4.py
gfx/libutil : Irregu.hxx
Log message:
Draw inside
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu4.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/Irregu.hxx.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/irregu4.py
diff -u gzz/gfx/demo/irregu4.py:1.7 gzz/gfx/demo/irregu4.py:1.8
--- gzz/gfx/demo/irregu4.py:1.7 Tue Nov 12 04:53:49 2002
+++ gzz/gfx/demo/irregu4.py Wed Nov 13 09:10:09 2002
@@ -2,6 +2,13 @@
from gfx.libpaper.texcache import getCachedTexture
from math import sin,cos
+from gfx.libpaper.papermill import ThePaperMill
+
+seed = 200
+pap = ThePaperMill().getPaper(seed)
+paperquad = GLRen.createPaperQuad(pap, -2, -2, 2, 2, 0)
+
+
ripple_scale = 0.25
texRGBA = getCachedTexture([128, 128, 0, 4, "RGBA", "RGBA",
"irregu", ["radius", "2",
@@ -34,6 +41,26 @@
self.initcode()
+ self.stencil_init = getDListNocoords("""
+ # Create stencil
+ StencilMask 255
+ Enable STENCIL_TEST
+ StencilFunc ALWAYS 0 255
+ StencilOp INCR INCR INCR
+ ColorMask 0 0 0 0
+ """)
+
+ self.stencil_use = getDListNocoords("""
+ Enable STENCIL_TEST
+ StencilFunc NOTEQUAL 0 255
+ StencilOp ZERO ZERO ZERO
+ ColorMask 1 1 1 1
+ """)
+
+ self.stencil_teardown = getDListNocoords("""
+ Disable STENCIL_TEST
+ """)
+
def initcode(self):
code = combinercode("""
PushAttrib ENABLE_BIT TEXTURE_BIT
@@ -184,6 +211,7 @@
SLICE_1D = 16;
SLICE_2D = 32;
SHIFTS = 64;
+ INSIDE = 128;
inner_code = code % {"tex" : texRGBA.getTexId(),
"color" : "1 1 1 1" }
@@ -198,8 +226,6 @@
border1 = .5 * ripple_scale * texscale
texslicing = self.texslicing
- SLICE = (SLICE_2D, SLICE_1D)[self.flags >> 4 & 1]
-
stdcode = """
PushAttrib ENABLE_BIT TEXTURE_BIT
BindTexture TEXTURE_2D %s
@@ -216,7 +242,7 @@
border0, border1, texslicing,
"0 0 0 1 0 0 0 0", "",
0, 0,
- SLICE + Y_COLOR + SHIFTS, stdcode + """
+ SLICE_1D + Y_COLOR + SHIFTS, stdcode + """
BlendFunc ZERO ZERO
Enable BLEND
""", 1.0)
@@ -231,14 +257,14 @@
border0, border1, texslicing,
("0 0 0 0 0 0 0 0", "1 1 1 1 0 0 0 0")[self.flags >> 1 & 1], "",
0, 0,
- SLICE + Y_COLOR, stdcode, 1.0)
+ SLICE_1D + Y_COLOR + (self.flags >> 4 & 1) * INSIDE, stdcode, 1.0)
if GL.hasExtension("GL_NV_register_combiners") and 0:
self.outer = GLRen.createIrregularEdge(
texscale, linewidth, refsize, scale_pow,
border0, border1, texslicing,
"1 1 1 1 0 0 0 0", "", 3, 0,
- Y_SECCOLOR + SLICE + DOTVEC_COLOR + INTERP_DOTVEC,
+ Y_SECCOLOR + SLICE_1D + DOTVEC_COLOR + INTERP_DOTVEC,
outer_code, 1.0)
if (GL.hasExtension("GL_NV_register_combiners") and
@@ -251,7 +277,7 @@
texscale, linewidth, refsize, scale_pow,
border0, border1, texslicing,
"1 1 1 1 0 0 0 0", "", 0, 1,
- Y_SECCOLOR + SLICE,
+ Y_SECCOLOR + SLICE_1D,
outer_code, 1.0)
@@ -271,19 +297,35 @@
self.scale * 0,
self.scale * 0,
self.scale * 150)
+
+ cspap = vs.coords.affineCoordsys(0, 0, 0, 0, 1, 0, 0, 1)
+ vs.matcher.add(cspap, "pap")
+
+
vs.matcher.add(cs1, "1")
if self.flags & 8:
vs.map.put(self.outer, cs1, cs2)
if self.flags & 7:
+ if self.flags & 32:
+ vs.map.put(self.stencil_init)
+
vs.map.put(self.inner, cs1, cs2)
+ if self.flags & 32:
+ vs.map.put(self.stencil_use)
+ vs.map.put(paperquad, cs1, cspap)
+
+ vs.map.put(self.stencil_teardown)
+
+
print "1: ADD TEXTURE", self.flags >> 0& 1
print "2: ADD COLOR", self.flags >> 1 & 1
print "3: ALPHA_TEST", self.flags >> 2 & 1
print "4: OUTER EDGE", self.flags >> 3 & 1
- print "5: 1D SLICE", self.flags >> 4 & 1
+ print "5: INSIDE", self.flags >> 4 & 1
+ print "6: STENCIL", self.flags >> 5 & 1
def key(self, k):
if 0: pass
Index: gzz/gfx/libutil/Irregu.hxx
diff -u gzz/gfx/libutil/Irregu.hxx:1.8 gzz/gfx/libutil/Irregu.hxx:1.9
--- gzz/gfx/libutil/Irregu.hxx:1.8 Tue Nov 12 04:53:49 2002
+++ gzz/gfx/libutil/Irregu.hxx Wed Nov 13 09:10:09 2002
@@ -19,6 +19,10 @@
template <class T>
void nop(T t) {};
+ inline void texCoord(ZPt p) {
+ glTexCoord3f(p.x, p.y, p.z);
+ }
+
inline void texCoord(ZPt p, float q) {
glTexCoord4f(p.x, p.y, p.z, q);
}
@@ -48,6 +52,7 @@
const unsigned SLICE_1D = 16;
const unsigned SLICE_2D = 32;
const unsigned SHIFTS = 64;
+ const unsigned INSIDE = 128;
template <class Coords>
void fill(Coords &coords, ZPt center,
@@ -96,6 +101,16 @@
vert1[i][1] = pt[i] + texslicing * border1 * norm[i];
vert2[i][0] = coords.transform(vert[i][0]);
vert2[i][1] = coords.transform(vert[i][1]);
+ }
+
+ if (flags & INSIDE) {
+ colorfv(c0);
+ glBegin(GL_POLYGON);
+ for (unsigned i = 0; i < pt.size(); i++) {
+ texCoord(vert[i][0]);
+ coords.vertex(vert[i][0]);
+ }
+ glEnd();
}
if (flags & SLICE_2D) {