[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx demo/buoydev.py demo/irregular2.py demo...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] gzz/gfx demo/buoydev.py demo/irregular2.py demo... |
Date: |
Wed, 18 Sep 2002 06:01:26 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Tuomas J. Lukka <address@hidden> 02/09/18 06:01:26
Modified files:
gfx/demo : buoydev.py irregular2.py xupdf.py
gfx/jni : GzzGL-jni.cxx
gfx/librenderables: renderables.py
Added files:
gfx/libutil : effects.py
Log message:
Start trying to work around stencil bug; also, separate irregu2 code
and nadir buoy code into effects.py
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/buoydev.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregular2.py.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/xupdf.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/jni/GzzGL-jni.cxx.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.45&tr2=1.46&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/effects.py?rev=1.1
Patches:
Index: gzz/gfx/demo/buoydev.py
diff -c gzz/gfx/demo/buoydev.py:1.2 gzz/gfx/demo/buoydev.py:1.3
*** gzz/gfx/demo/buoydev.py:1.2 Thu Sep 12 09:04:03 2002
--- gzz/gfx/demo/buoydev.py Wed Sep 18 06:01:26 2002
***************
*** 11,68 ****
def ds():
return rng.nextDouble() * 2 - 1
- linecon = GZZGL.createLineConnector(0, 0)
! # Prototype: project to a semicircle
! # from a point.
! class NadirCircleFloater(Buoy3Floater):
! def __init__(self, vs, center, radius, p, nadir):
! self.vs, self.c, self.r, self.p, self.nadir = vs, center, radius, p,
nadir
! def addBuoy(self, anchorX, anchorY, importance, key, buoy, w, h):
! size = importance
!
! # 1. find the projected buoy point
!
! # Vector from center to projection point
! AmC = (self.p[0] - self.c[0], self.p[1] - self.c[1])
!
! # Vector from anchor to projection point
! v = (anchorX - self.p[0], anchorY - self.p[1])
!
! # Coefficients of the 2nd degree eq
! a = v[0]*v[0] + v[1]*v[1]
! b = 2*(v[0]*AmC[0] + v[1]*AmC[1])
! c = AmC[0]*AmC[0] + AmC[1]+AmC[1] - self.r**2
!
! print "S: ",v,AmC,self.r, a,b,c
!
! # Determinant
! det = b**2 - 4*a*c
! if det <= 0:
! # For now, ignore
! print "Ignoring ",key
! return
!
! ans = (-b + math.sqrt(det)) / (2*a)
! print "DA: ",det,ans
!
! b = (self.p[0] + ans * v[0], self.p[1] + ans * v[1])
! print "Buoy: (%s,%s): (%s,%s)\n"%(
! anchorX, anchorY, b[0], b[1])
!
! # Create the coordinate system
!
! vs = self.vs
! transaffine(vs, str(key)+"_1", b[0], b[1], size, 0, 0, size)
! rotate(vs, str(key)+"_2", 360 * self.nadir.getAngleRad(b[0], b[1]) /
! (2 * math.pi), 0, 0, 1)
! buoy.run()
! poptrans(vs, str(key)+"_2")
! poptrans(vs, str(key)+"_1")
!
! ac = vs.coords.coordsys(0, str(key)+"_5", 10, anchorX, anchorY, 0, 0)
! bc = vs.coords.coordsys(0, str(key)+"_6", 10, b[0], b[1], 0, 0)
! vs.map.put(linecon, ac, bc)
class BScene:
def __init__(self):
--- 11,18 ----
def ds():
return rng.nextDouble() * 2 - 1
! execfile("gfx/libutil/effects.py")
class BScene:
def __init__(self):
***************
*** 99,104 ****
--- 49,55 ----
poptrans(vs, key+"_1")
def scene(self, vs):
+ # GZZGL.reallyClearStencilBuffer(1024, 768);
putnoc(vs, background((0.1,0.4,0.5)))
self.nadir = NadirAngler(800, self.nadiry[0])
***************
*** 126,131 ****
--- 77,85 ----
else:
f = NadirCircleFloater(vs, (ctrx, ctry), rad,
(ctrx+1.5*rad, ctry), self.nadir)
+ putnoc(vs, getDListNocoords("""
+ Disable TEXTURE_2D
+ """))
class R(Runnable):
def run(rself):
vs.put(self.q[self.i], "XXX", 10, -20, -20, 40, 40)
Index: gzz/gfx/demo/irregular2.py
diff -c gzz/gfx/demo/irregular2.py:1.13 gzz/gfx/demo/irregular2.py:1.14
*** gzz/gfx/demo/irregular2.py:1.13 Wed Sep 18 04:15:23 2002
--- gzz/gfx/demo/irregular2.py Wed Sep 18 06:01:26 2002
***************
*** 1,19 ****
from __future__ import nested_scopes
from gzz.gfx.gl import GZZGL
! tex = GZZGL.createTexture()
! tex.shade(128, 128, 0, 4, "RGBA", "RGBA",
! "sawnoise", ["bias", "0.5",
! "scale", "0.15", "freq", "1", "df", "2",
! "scale2", "0.25", "freq2", "10", "df2", ".5"])
! # "scale", "0.2", "freq", "1", "df", "2",
! # "scale2", "0.05", "freq2", "12", "df2", "1.5"])
!
! boxtex = GZZGL.createTexture()
class IrreguScene:
def __init__(self):
- print "Texture id:", tex.getTexId()
self.mode = 255
self.combiners = "Enable"
--- 1,10 ----
from __future__ import nested_scopes
from gzz.gfx.gl import GZZGL
! execfile("gfx/libutil/effects.py")
class IrreguScene:
def __init__(self):
self.mode = 255
self.combiners = "Enable"
***************
*** 43,91 ****
End
""" % locals())
! code = """
! PushAttrib ENABLE_BIT TEXTURE_BIT CURRENT_BIT
! Enable ALPHA_TEST
! AlphaFunc GREATER 0.0
!
! ActiveTexture TEXTURE1
! BindTexture TEXTURE_2D %s
! Enable TEXTURE_2D
! TexImage2D TEXTURE_2D 0 ALPHA 4 4 0 ALPHA 0 0 0 0 0 1 1 0 0 1
1 0 0 0 0 0
! TexParameter TEXTURE_2D TEXTURE_BASE_LEVEL 0
! TexParameter TEXTURE_2D TEXTURE_MAX_LEVEL 0
! TexParameter TEXTURE_2D TEXTURE_WRAP_S CLAMP
! TexParameter TEXTURE_2D TEXTURE_WRAP_T CLAMP
! TexParameter TEXTURE_2D TEXTURE_MIN_FILTER NEAREST
! TexParameter TEXTURE_2D TEXTURE_MAG_FILTER NEAREST
!
! TexGen S TEXTURE_GEN_MODE EYE_LINEAR
! Enable TEXTURE_GEN_S
! TexGen T TEXTURE_GEN_MODE EYE_LINEAR
! Enable TEXTURE_GEN_T
!
! ActiveTexture TEXTURE0
!
! BindTexture TEXTURE_2D %s
! Enable TEXTURE_2D
! %s REGISTER_COMBINERS_NV
! CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1
! CombinerInputNV COMBINER0_NV ALPHA VARIABLE_A_NV TEXTURE1
UNSIGNED_IDENTITY_NV ALPHA
! CombinerInputNV COMBINER0_NV ALPHA VARIABLE_B_NV TEXTURE0
SIGNED_NEGATE_NV ALPHA
! CombinerInputNV COMBINER0_NV ALPHA VARIABLE_C_NV TEXTURE1
UNSIGNED_IDENTITY_NV ALPHA
! CombinerInputNV COMBINER0_NV ALPHA VARIABLE_D_NV
SECONDARY_COLOR_NV UNSIGNED_IDENTITY_NV BLUE
! CombinerOutputNV COMBINER0_NV ALPHA DISCARD_NV DISCARD_NV
SPARE0_NV NONE NONE FALSE FALSE FALSE
!
! FinalCombinerInputNV VARIABLE_A_NV ZERO UNSIGNED_IDENTITY_NV
RGB
! FinalCombinerInputNV VARIABLE_B_NV ZERO UNSIGNED_IDENTITY_NV
RGB
! FinalCombinerInputNV VARIABLE_C_NV ZERO UNSIGNED_IDENTITY_NV
RGB
! FinalCombinerInputNV VARIABLE_D_NV PRIMARY_COLOR_NV
UNSIGNED_IDENTITY_NV RGB
! FinalCombinerInputNV VARIABLE_G_NV SPARE0_NV
UNSIGNED_IDENTITY_NV ALPHA
! """ % (boxtex.getTexId(), tex.getTexId(), self.combiners)
!
!
! self.iq = GZZGL.createIrregularQuad(self.border, self.w, self.h,
self.period, 0, code)
! self.iq2 = GZZGL.createIrregularQuad(self.border, self.w, self.h,
self.period, 1, code)
def key(self, k):
if 0: pass
--- 34,40 ----
End
""" % locals())
! self.irreguframe = IrreguFrame(self.border, w, h, self.period)
def key(self, k):
if 0: pass
***************
*** 136,145 ****
if self.mode & 1:
putnoc(vs, self.black);
! vs.map.put(self.iq2, cs1, cs2)
if self.mode & 2:
putnoc(vs, self.white);
! vs.map.put(self.iq, cs1, cs2)
currentScene = IrreguScene()
--- 85,94 ----
if self.mode & 1:
putnoc(vs, self.black);
! vs.map.put(self.irreguframe.frame, cs1, cs2)
if self.mode & 2:
putnoc(vs, self.white);
! vs.map.put(self.irreguframe.content, cs1, cs2)
currentScene = IrreguScene()
Index: gzz/gfx/demo/xupdf.py
diff -c gzz/gfx/demo/xupdf.py:1.5 gzz/gfx/demo/xupdf.py:1.6
*** gzz/gfx/demo/xupdf.py:1.5 Wed Sep 18 03:38:29 2002
--- gzz/gfx/demo/xupdf.py Wed Sep 18 06:01:26 2002
***************
*** 61,79 ****
pdfpaper(p) for p in prect
]
! def placepapers(vs, cs2, papers, key, x, y, paperx, papery, h):
# The height in coords
ph = papers[0][2]
curx = x - h/ph * paperx
ycoord = y - h/ph * papery
print "x,y for place: ",curx, ycoord
for i in range(0, len(papers)):
! cs1 = vs.coords.affineCoordsys(0, key+"_"+str(i), 10,
! curx, ycoord, h/ph, 0, 0, h/ph)
curx += 1.02 * h/ph * papers[i][1]
- pq = GZZGL.createFisheyePaperQuad(
- papers[i][0], 0, 0, papers[i][1], papers[i][2], 21, 21)
- vs.map.put(pq, cs1, cs2)
# Paper coordinates of current focus
globalx = 0
--- 61,80 ----
pdfpaper(p) for p in prect
]
! def placepapers(vs, cs2, papers, key, x, y, paperx, papery, h,
onlypages=None):
# The height in coords
ph = papers[0][2]
curx = x - h/ph * paperx
ycoord = y - h/ph * papery
print "x,y for place: ",curx, ycoord
for i in range(0, len(papers)):
! if onlypages == None or i in onlypages:
! cs1 = vs.coords.affineCoordsys(0, key+"_"+str(i), 10,
! curx, ycoord, h/ph, 0, 0, h/ph)
! pq = GZZGL.createFisheyePaperQuad(
! papers[i][0], 0, 0, papers[i][1], papers[i][2], 21, 21)
! vs.map.put(pq, cs1, cs2)
curx += 1.02 * h/ph * papers[i][1]
# Paper coordinates of current focus
globalx = 0
Index: gzz/gfx/jni/GzzGL-jni.cxx
diff -c gzz/gfx/jni/GzzGL-jni.cxx:1.21 gzz/gfx/jni/GzzGL-jni.cxx:1.22
*** gzz/gfx/jni/GzzGL-jni.cxx:1.21 Wed Sep 18 04:34:01 2002
--- gzz/gfx/jni/GzzGL-jni.cxx Wed Sep 18 06:01:26 2002
***************
*** 844,850 ****
--- 844,896 ----
return result;
}
+ GLuint buf[1600 * 1200];
+ JNIEXPORT void JNICALL Java_gzz_gfx_gl_GZZGL_reallyClearStencilBuffer
+ (JNIEnv *env, jclass, jint w, jint h) {
+
+ if(w*h > 1600*1200) return;
+
+ cout << "In reallyClear\n\n";
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ cout << "Set up\n";
+ glReadPixels(0, 0, w, h, GL_DEPTH_STENCIL_NV, GL_UNSIGNED_INT_24_8_NV,
buf);
+ cout << "Read pix\n";
+ GLERR
+ for(int i=0; i<w*h; i++) {
+ if(buf[i] != 0) {
+ cout << "Buf "<<i<<" "<<buf[i]<<"\n";
+ goto nonzero;
+ }
+ }
+ cout << "done\n";
+ return;
+ nonzero:
+ cout << "STENCIL CLEARING: NOT ALL ZERO!!!!\n";
+ for(int i=0; i<w*h; i++) buf[i] = 0;
+ cout << "rastpos\n";
+ glPushAttrib(GL_ENABLE_BIT);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_STENCIL_TEST);
+ glStencilMask(255);
+ glRasterPos2d(0,0);
+ glDrawPixels(w, h, GL_DEPTH_STENCIL_NV, GL_UNSIGNED_INT_24_8_NV, buf);
+ glRasterPos2d(0,1);
+ glDrawPixels(w, h, GL_DEPTH_STENCIL_NV, GL_UNSIGNED_INT_24_8_NV, buf);
+ glRasterPos2d(1,0);
+ glDrawPixels(w, h, GL_DEPTH_STENCIL_NV, GL_UNSIGNED_INT_24_8_NV, buf);
+ glRasterPos2d(1,1);
+ glDrawPixels(w, h, GL_DEPTH_STENCIL_NV, GL_UNSIGNED_INT_24_8_NV, buf);
+ glRasterPos2d(w,h);
+ glDrawPixels(w, h, GL_DEPTH_STENCIL_NV, GL_UNSIGNED_INT_24_8_NV, buf);
+ glRasterPos2d(w,0);
+ glDrawPixels(w, h, GL_DEPTH_STENCIL_NV, GL_UNSIGNED_INT_24_8_NV, buf);
+ glRasterPos2d(0,h);
+ glDrawPixels(w, h, GL_DEPTH_STENCIL_NV, GL_UNSIGNED_INT_24_8_NV, buf);
+ glPopAttrib();
+ cout << "drawn\n";
+ }
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.45
gzz/gfx/librenderables/renderables.py:1.46
*** gzz/gfx/librenderables/renderables.py:1.45 Wed Sep 18 05:19:00 2002
--- gzz/gfx/librenderables/renderables.py Wed Sep 18 06:01:26 2002
***************
*** 1530,1535 ****
--- 1530,1539 ----
public static native String getGLString(String name);
public static native float[] getGLFloat(String name);
+ // Clear stencil buffer: on some NVIDIA drivers, there
+ // seems to be a bug.
+ public static native void reallyClearStencilBuffer(int w, int h);
+
""" + cls + " } \n"
open(javafile, "w").write(gzzgljava);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/gfx demo/buoydev.py demo/irregular2.py demo...,
Tuomas J. Lukka <=