gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx demo/opengl/imaging.py librenderables/r...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz/gfx demo/opengl/imaging.py librenderables/r...
Date: Thu, 21 Nov 2002 03:36:55 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/11/21 03:36:55

Modified files:
        gfx/demo/opengl: imaging.py 
        gfx/librenderables: renderables.py 

Log message:
        YEA\! Depth texture working

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/opengl/imaging.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.148&tr2=1.149&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/opengl/imaging.py
diff -u gzz/gfx/demo/opengl/imaging.py:1.4 gzz/gfx/demo/opengl/imaging.py:1.5
--- gzz/gfx/demo/opengl/imaging.py:1.4  Wed Nov 20 17:12:34 2002
+++ gzz/gfx/demo/opengl/imaging.py      Thu Nov 21 03:36:54 2002
@@ -1,29 +1,31 @@
 from gfx.libutil import effects, nvcode
 
+w.setLocation(0,0,1024,1024)
+
 c = java.util.Random()
 
-ts = 512
+ts = 1024
 
 class BlurScene:
     def __init__(self):
        self.bv = GL.createByteVector(1024 * 768 * 4)
        self.f = effects.IrreguFrame(0, 0, 1000, 1000, 20, 200)
        self.tex = GL.createTexture()
-       self.tex.loadNull2D(0, "RGBA", ts, ts, 0, "RGBA", "UNSIGNED_BYTE")
+       self.tex.loadNull2D(0, "DEPTH_COMPONENT24_SGIX", ts, ts, 0, 
"DEPTH_COMPONENT", "UNSIGNED_SHORT")
+       # self.tex.loadNull2D(0, "RGBA", ts, ts, 0, "RGBA", "UNSIGNED_BYTE")
     def key(self, key):
        pass
     def scene(self, vs):
-       vs.map.put(background((0, .1, 0)))
+       vs.map.put(background((.2, .4, .2)))
 
        sx = ts
        sy = ts
 
 
-       f1cs = vs.orthoCS(0, "X", 50, 100*c.nextDouble(), 100*c.nextDouble(), 
200, 100)
-       vs.map.put(self.f.getContent(), 0, f1cs)
+       for i in range(0,10):
+           f1cs = vs.orthoCS(0, str(i), 100*i, 300*c.nextDouble(), 
300*c.nextDouble(), 200, 100)
+           vs.map.put(self.f.getContent(), 0, f1cs)
 
-       f1cs = vs.orthoCS(0, "Y", 70, 100*c.nextDouble(), 100*c.nextDouble(), 
200, 100)
-       vs.map.put(self.f.getContent(), 0, f1cs)
 
        # vs.put(coloredQuad((1,1,1)), "A", 10, 100*c.nextDouble(), 
100*c.nextDouble(), 200, 100)
        # vs.put(coloredQuad((1,1,1)), "B", 100, 150*c.nextDouble(), 
150*c.nextDouble(), 200, 100)
@@ -69,16 +71,27 @@
            "tex": self.tex.getTexId(),
        }))
 
-       cs = vs.orthoCS(0, "dp", 0, 20, sy+10, 1, 1)
-       cs2 = vs.orthoCS(0, "dp2", 300, 300, sy+10, sx, sy)
+       cs = vs.orthoCS(0, "dp", 0, 0, sy, 1, 1)
+       # cs2 = vs.orthoCS(0, "dp2", 300, 300, sy+10, sx, sy)
+       cs2 = vs.orthoCS(0, "dp2", 0, 0, 0, sx, sy)
        if 1:
-           getp = GLRen.createReadPixels(sx, sy,
-                       "DEPTH_COMPONENT", "UNSIGNED_SHORT", self.bv)
-           texim = GLRen.createTexSubImage2D("TEXTURE_2D", 0, 0, 0, ts, ts, 
-               "RGBA", "UNSIGNED_SHORT_4_4_4_4", self.bv)
-           
-           vs.map.put(getp, cs)
-           vs.map.put(texim)
+           if 1:
+               texim = GLRen.createCopyTexSubImage2D(
+                                   "TEXTURE_2D", 0, 0, 0, ts, ts)
+           elif 1:
+               if 1:
+                   getp = GLRen.createReadPixels(sx, sy,
+                               "DEPTH_COMPONENT", "UNSIGNED_SHORT", self.bv)
+                   texim = GLRen.createTexSubImage2D("TEXTURE_2D", 0, 0, 0, 
ts, ts, 
+                       "RGBA", "UNSIGNED_SHORT_4_4_4_4", self.bv)
+               else:
+                   getp = GLRen.createReadPixels(sx, sy,
+                               "DEPTH_COMPONENT", "UNSIGNED_BYTE", self.bv)
+                   texim = GLRen.createTexSubImage2D("TEXTURE_2D", 0, 0, 0, 
ts, ts, 
+                       "LUMINANCE", "UNSIGNED_BYTE", self.bv)
+               vs.map.put(getp, cs)
+
+           vs.map.put(texim, cs)
 
            # vs.map.put(coloredQuad((1,0,0)), cs2)
 
@@ -86,9 +99,9 @@
                BindTexture TEXTURE_2D %(tex)s
                PushAttrib TEXTURE_BIT
                TexGen S TEXTURE_GEN_MODE OBJECT_LINEAR
-               TexGen S OBJECT_PLANE 1 0 0 -300
+               TexGen S OBJECT_PLANE 1 0 0 -0
                TexGen T TEXTURE_GEN_MODE OBJECT_LINEAR
-               TexGen T OBJECT_PLANE 0 1 0 -300
+               TexGen T OBJECT_PLANE 0 -1 0 -0
                Enable TEXTURE_GEN_S
                Enable TEXTURE_GEN_T
 
@@ -96,13 +109,18 @@
                BindTexture TEXTURE_2D %(tex)s
                Enable TEXTURE_2D
                TexGen S TEXTURE_GEN_MODE OBJECT_LINEAR
-               TexGen S OBJECT_PLANE 1 0 0 -300.005
+               TexGen S OBJECT_PLANE 1 0 0 -0.005
                TexGen T TEXTURE_GEN_MODE OBJECT_LINEAR
-               TexGen T OBJECT_PLANE 0 1 0 -300.005
+               TexGen T OBJECT_PLANE 0 -1 0 -0.005
                Enable TEXTURE_GEN_S
                Enable TEXTURE_GEN_T
 
                TexEnv TEXTURE_ENV TEXTURE_ENV_MODE MODULATE
+    
+               Enable ALPHA_TEST
+               Disable BLEND
+               Disable DEPTH_TEST
+               AlphaFunc GREATER 0
 
                ActiveTexture TEXTURE0
 
@@ -110,9 +128,9 @@
                CombinerParameterNV NUM_GENERAL_COMBINERS_NV 2
 
                # Calculate Tex0 - Tex1
-               CI0 RGB A TEXTURE0 UNSIGNED_IDENTITY_NV RGB
+               CI0 RGB A TEXTURE0 UNSIGNED_IDENTITY_NV ALPHA
                CI0 RGB B ZERO UNSIGNED_INVERT_NV RGB
-               CI0 RGB C TEXTURE1 UNSIGNED_IDENTITY_NV RGB
+               CI0 RGB C TEXTURE1 UNSIGNED_IDENTITY_NV ALPHA
                CI0 RGB D ZERO EXPAND_NORMAL_NV RGB
                CO0 RGB DISCARD_NV DISCARD_NV SPARE0_NV SCALE_BY_FOUR_NV NONE 
FALSE FALSE FALSE
 
@@ -120,10 +138,13 @@
                CI1 RGB B SPARE0_NV SIGNED_IDENTITY_NV RGB
                CO1 RGB SPARE0_NV DISCARD_NV DISCARD_NV SCALE_BY_FOUR_NV NONE 
TRUE FALSE FALSE
 
-               FCI A SPARE0_NV UNSIGNED_IDENTITY_NV RGB
+               # FCI A SPARE0_NV UNSIGNED_IDENTITY_NV RGB
+               FCI A ZERO UNSIGNED_IDENTITY_NV RGB
                FCI B ZERO UNSIGNED_INVERT_NV RGB
                FCI C ZERO UNSIGNED_IDENTITY_NV RGB
                FCI D ZERO UNSIGNED_IDENTITY_NV RGB
+
+               FCI G SPARE0_NV UNSIGNED_IDENTITY_NV BLUE
 
            """ % {
                "tex" : self.tex.getTexId()
Index: gzz/gfx/librenderables/renderables.py
diff -u gzz/gfx/librenderables/renderables.py:1.148 
gzz/gfx/librenderables/renderables.py:1.149
--- gzz/gfx/librenderables/renderables.py:1.148 Wed Nov 20 17:12:34 2002
+++ gzz/gfx/librenderables/renderables.py       Thu Nov 21 03:36:55 2002
@@ -199,6 +199,31 @@
     """,
 },
 
+{
+    "Type": "1",
+    "Name": "CopyTexSubImage2D",
+    "Data" : "GLenum target; int level, x, y, w,h;",
+    "Params" : "GLToken target, int level, int x, int y, int w, int h ",
+    "ParamCode" : """
+       this->level = level;
+       this->x = x;
+       this->y = y;
+       this->w = w;
+       this->h = h;
+       this->target = target;
+    """,
+    "RenderCode" : """
+       ZPt pfrom = coords1.transform(ZPt(0,0,0));
+       glRasterPos3f(pfrom.x, pfrom.y, pfrom.z);
+       float ras[4];
+       glGetFloatv(GL_CURRENT_RASTER_POSITION, ras);
+
+       glCopyTexSubImage2D(target, level, x, y, (int)ras[0], (int)ras[1],
+               w, h);
+       GLERR
+    """,
+},
+
 
 {
     "Type": "2",




reply via email to

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