gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] libvob/vob/fillet light3d.py


From: Janne V. Kujala
Subject: [Gzz-commits] libvob/vob/fillet light3d.py
Date: Mon, 30 Jun 2003 07:04:18 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Branch:         
Changes by:     Janne V. Kujala <address@hidden>        03/06/30 07:04:18

Modified files:
        vob/fillet     : light3d.py 

Log message:
        abstract

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/fillet/light3d.py.diff?tr1=1.21&tr2=1.22&r1=text&r2=text

Patches:
Index: libvob/vob/fillet/light3d.py
diff -u libvob/vob/fillet/light3d.py:1.21 libvob/vob/fillet/light3d.py:1.22
--- libvob/vob/fillet/light3d.py:1.21   Mon Jun 30 03:22:38 2003
+++ libvob/vob/fillet/light3d.py        Mon Jun 30 07:04:18 2003
@@ -134,7 +134,7 @@
            SlideLin("thick", 1, .1, "thickness", "T", "t"),
            Toggle("drawEdge", 1, "Draw edge", "e"),
            Toggle("drawInside", 1, "Draw inside", "i"),
-           Toggle("depthColor", 0, "Color from depth", "d"),
+           Toggle("depthColor", 1, "Color from depth", "d"),
            Toggle("lines", 0, "Toggle showing lines", "l"),
            Toggle("ellipses", 1, "Toggle ellipses", "s"),
            Toggle("stretched", 1, "Toggle stretched", "v"),
@@ -145,13 +145,48 @@
            SlideLin("seed", 42, 1, "seed number", "A", "a"),
            SlideLin("size", 100, 10, "Node size", "K", "k"),
            SlideLin("dice", 20, 1, "Dice factor", "P", "p"),
-           Toggle("fillet3d", 0, "3D fillets", "3"),
+           Toggle("fillet3d", 1, "3D fillets", "3"),
            Toggle("blend3d", 0, "3D fillets blend", "4"),
            SlideLin("linewidth", 2, 1, "line width", "B", "b"),
            Toggle("perspective", 0, "perspective", "F"),
            Toggle("texture", 0, "texture", "x"),
 ]
 
+width = 0
+height = 0
+directDepthCopy = 0
+
+def initBuffers(w, h):
+    print "initBuffers(%s,%s)" % (w,h)
+    global width, height, depthTexture, tmpTexture, directDepthCopy
+    if width == w and height == h: return
+
+    depthTexture = GL.createTexture()
+    tmpTexture = GL.createTexture()
+       
+    if not GL.hasExtension("GL_NV_texture_rectangle"): return
+
+    width,height = w,h
+
+    rect = 1
+    targ = "TEXTURE_RECTANGLE_NV"
+    if directDepthCopy:
+        depthTexture.loadNull2D("TEXTURE_RECTANGLE_NV", 0, "DEPTH_COMPONENT24",
+                               width, height, 0, "DEPTH_COMPONENT", 
+                               "INT")
+    else:
+        depthTexture.loadNull2D("TEXTURE_RECTANGLE_NV", 0, "RGBA8",
+                               width, height, 0, "BGRA", 
+                               "UNSIGNED_INT_8_8_8_8")
+
+       tmpTexture.loadNull2D("TEXTURE_RECTANGLE_NV", 0, "RGB8",
+                             width, height, 0, "RGB", 
+                             "INT")
+       
+    depthTexture.setTexParameter(targ, "TEXTURE_MIN_FILTER", "LINEAR")
+    depthTexture.setTexParameter(targ, "TEXTURE_MAG_FILTER", "LINEAR")
+
+
 
 def drawFillets(self, vs, pc):
        vs.put(getDListNocoords("""
@@ -215,6 +250,11 @@
             PushMatrix
             """ % vp[0].getProgId()))
 
+           if not self.depthColor:
+               vs.put(getDListNocoords("""
+               Disable VERTEX_PROGRAM_ARB
+               """))
+
             if self.texture:
                 vs.put(getDListNocoords("""
                 BindTexture TEXTURE_2D %s
@@ -267,3 +307,94 @@
             BindTexture TEXTURE_2D 0
            PopAttrib
        """))
+
+
+       if self.fillet3d and self.drawEdge:
+           size = vs.getSize()
+           initBuffers(size.width, size.height)
+
+           # Now, draw the edges
+           if directDepthCopy:
+               vs.put(getDListNocoords("""
+                   BindTexture TEXTURE_RECTANGLE_NV %s
+               """ % depthTexture.getTexId()))
+               vs.put(GLRen.createCopyTexSubImage2D("TEXTURE_RECTANGLE_NV",
+                                                    0, 0, 0, width, height),
+                      0)
+
+           else:
+               vs.put(getDListNocoords("""
+               PushAttrib ENABLE_BIT
+               Disable ALPHA_TEST
+               Disable DEPTH_TEST
+               Disable TEXTURE_RECTANGLE_NV
+               Disable TEXTURE_2D
+               """))
+
+               # Copy the color buffer to a texture
+               vs.put(getDListNocoords("""
+                   BindTexture TEXTURE_RECTANGLE_NV %s
+                   """ % tmpTexture.getTexId()))
+               vs.put(GLRen.createCopyTexSubImage2D("TEXTURE_RECTANGLE_NV",
+                                                    0, 0, 0, width, height),
+                      0)
+
+               # Copy stencil&depth to color
+               csdest = vs.translateCS(0,"copydest",0,height)
+               vs.put(GLRen.createCopyPixels(width, height,
+                                             "DEPTH_STENCIL_TO_BGRA_NV"),
+                      0,
+                      csdest,
+                      )
+
+               # Read the depth to a texture
+               vs.put(getDListNocoords("""
+                    BindTexture TEXTURE_RECTANGLE_NV %s
+                   """ % depthTexture.getTexId()))
+               vs.put(GLRen.createCopyTexSubImage2D("TEXTURE_RECTANGLE_NV",
+                                                    0, 0, 0, width, height),
+                      0)
+
+               # Copy the color back from the backup texture
+               vs.put(getDListNocoords("""
+                   BindTexture TEXTURE_RECTANGLE_NV %s
+                   Enable TEXTURE_RECTANGLE_NV
+                   """ % tmpTexture.getTexId()))
+               vs.put(getDList("""
+                    Color 1 1 1
+                   Begin QUAD_STRIP
+                   TexCoord 0 0
+                   Vertex 0 %(h)s
+                   
+                   TexCoord 0 %(h)s
+                   Vertex 0 0
+                   
+                   TexCoord %(w)s  0
+                   Vertex %(w)s %(h)s
+                   
+                   TexCoord %(w)s %(h)s
+                   Vertex %(w)s 0
+                   End
+               """ % { "w" : width, "h" : height }), 0)
+            
+               vs.put(getDListNocoords("""
+                   PopAttrib
+               """))
+
+           vs.put(getDListNocoords("""
+               PushAttrib ENABLE_BIT
+               Color 1 1 1
+               BindProgram FRAGMENT_PROGRAM_NV %s
+               Enable FRAGMENT_PROGRAM_NV
+               Enable BLEND
+               BindTexture TEXTURE_RECTANGLE_NV %s
+           """ % (edgefp.getProgId(),
+                  depthTexture.getTexId())))
+
+           vs.put(quad(), vs.orthoCS(0, "nprEdgeQuad", -100, 0, 0,
+                                     width, height))
+
+           vs.put(getDListNocoords("""
+               BindTexture TEXTURE_RECTANGLE_NV 0
+               PopAttrib
+           """))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]