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: Wed, 20 Nov 2002 17:12:34 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/11/20 17:12:34

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

Log message:
        Image space algorithm WORKING!!!!!!

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

Patches:
Index: gzz/gfx/demo/opengl/imaging.py
diff -u gzz/gfx/demo/opengl/imaging.py:1.3 gzz/gfx/demo/opengl/imaging.py:1.4
--- gzz/gfx/demo/opengl/imaging.py:1.3  Wed Nov 20 14:22:20 2002
+++ gzz/gfx/demo/opengl/imaging.py      Wed Nov 20 17:12:34 2002
@@ -1,18 +1,22 @@
-from gfx.libutil import effects
+from gfx.libutil import effects, nvcode
 
 c = java.util.Random()
 
+ts = 512
+
 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")
     def key(self, key):
        pass
     def scene(self, vs):
        vs.map.put(background((0, .1, 0)))
 
-       sx = 300
-       sy = 300
+       sx = ts
+       sy = ts
 
 
        f1cs = vs.orthoCS(0, "X", 50, 100*c.nextDouble(), 100*c.nextDouble(), 
200, 100)
@@ -26,7 +30,7 @@
        vs.put(coloredQuad((1,1,1)), "C", 1000, 180*c.nextDouble(), 
180*c.nextDouble(), 200, 100)
 
        vs.map.put(getDListNocoords("""
-       PushAttrib CURRENT_BIT COLOR_BUFFER_BIT DEPTH_BUFFER_BIT ENABLE_BIT 
PIXEL_MODE_BIT
+       PushAttrib CURRENT_BIT COLOR_BUFFER_BIT DEPTH_BUFFER_BIT ENABLE_BIT 
PIXEL_MODE_BIT TEXTURE_BIT
            Disable ALPHA_TEST
            Disable BLEND
            ReadBuffer BACK
@@ -57,11 +61,78 @@
                1 0 0 1
            Enable POST_CONVOLUTION_COLOR_TABLE
            Disable POST_CONVOLUTION_COLOR_TABLE
-       """))
+
+           BindTexture TEXTURE_2D %(tex)s
+           TexParameter TEXTURE_2D TEXTURE_MAX_LEVEL 0
+           Enable TEXTURE_2D
+       """ % {
+           "tex": self.tex.getTexId(),
+       }))
 
        cs = vs.orthoCS(0, "dp", 0, 20, sy+10, 1, 1)
-       cs2 = vs.orthoCS(0, "dp2", 300, 300, sy+10, 1, 1)
+       cs2 = vs.orthoCS(0, "dp2", 300, 300, sy+10, 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)
+
+           # vs.map.put(coloredQuad((1,0,0)), cs2)
+
+           vs.map.put(getDListNocoords(nvcode.combinercode("""
+               BindTexture TEXTURE_2D %(tex)s
+               PushAttrib TEXTURE_BIT
+               TexGen S TEXTURE_GEN_MODE OBJECT_LINEAR
+               TexGen S OBJECT_PLANE 1 0 0 -300
+               TexGen T TEXTURE_GEN_MODE OBJECT_LINEAR
+               TexGen T OBJECT_PLANE 0 1 0 -300
+               Enable TEXTURE_GEN_S
+               Enable TEXTURE_GEN_T
+
+               ActiveTexture TEXTURE1
+               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 T TEXTURE_GEN_MODE OBJECT_LINEAR
+               TexGen T OBJECT_PLANE 0 1 0 -300.005
+               Enable TEXTURE_GEN_S
+               Enable TEXTURE_GEN_T
+
+               TexEnv TEXTURE_ENV TEXTURE_ENV_MODE MODULATE
+
+               ActiveTexture TEXTURE0
+
+               Enable REGISTER_COMBINERS_NV
+               CombinerParameterNV NUM_GENERAL_COMBINERS_NV 2
+
+               # Calculate Tex0 - Tex1
+               CI0 RGB A TEXTURE0 UNSIGNED_IDENTITY_NV RGB
+               CI0 RGB B ZERO UNSIGNED_INVERT_NV RGB
+               CI0 RGB C TEXTURE1 UNSIGNED_IDENTITY_NV RGB
+               CI0 RGB D ZERO EXPAND_NORMAL_NV RGB
+               CO0 RGB DISCARD_NV DISCARD_NV SPARE0_NV SCALE_BY_FOUR_NV NONE 
FALSE FALSE FALSE
+
+               CI1 RGB A SPARE0_NV SIGNED_IDENTITY_NV RGB
+               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 B ZERO UNSIGNED_INVERT_NV RGB
+               FCI C ZERO UNSIGNED_IDENTITY_NV RGB
+               FCI D ZERO UNSIGNED_IDENTITY_NV RGB
+
+           """ % {
+               "tex" : self.tex.getTexId()
+           })))
+           vs.map.put(quad(), cs2)
+           vs.map.put(getDListNocoords("""
+               PopAttrib
+           """))
+       elif 1:
            getp = GLRen.createReadPixels(sx, sy,
                        "RGBA", "UNSIGNED_BYTE", self.bv)
            putp = GLRen.createDrawPixels(sx, sy,
Index: gzz/gfx/librenderables/renderables.py
diff -u gzz/gfx/librenderables/renderables.py:1.147 
gzz/gfx/librenderables/renderables.py:1.148
--- gzz/gfx/librenderables/renderables.py:1.147 Wed Nov 20 14:22:20 2002
+++ gzz/gfx/librenderables/renderables.py       Wed Nov 20 17:12:34 2002
@@ -172,6 +172,35 @@
 },
 
 {
+    "Type": "0",
+    "Name": "TexSubImage2D",
+    "Data" : "GLenum format, type, target; int level, x, y, w,h; GLubyte 
*bytes; ",
+    "Params" : "GLToken target, int level, int x, int y, int w, int h,  
GLToken format, GLToken type, ByteVector bytes",
+    "ParamCode" : """
+       this->level = level;
+       this->x = x;
+       this->y = y;
+       this->w = w;
+       this->h = h;
+       this->target = target;
+       this->format = format;
+       this->type = type;
+       this->bytes = bytes;
+    """,
+    "RenderCode" : """
+       glPushAttrib(GL_PIXEL_MODE_BIT);
+       glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
+       glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+       glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+       glTexSubImage2D(target, level, x, y, w, h, format, type, bytes);
+       GLERR
+       glPopClientAttrib();
+       glPopAttrib();
+    """,
+},
+
+
+{
     "Type": "2",
     "Name": "CopyPixels",
     "Data" : "GLenum type; int w,h; ",




reply via email to

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