[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz gfx/demo/irregu3.py gfx/jni/GzzGL-jni.cxx g...
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz gfx/demo/irregu3.py gfx/jni/GzzGL-jni.cxx g... |
Date: |
Mon, 21 Oct 2002 02:56:10 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 02/10/21 02:56:08
Modified files:
gfx/demo : irregu3.py
gfx/jni : GzzGL-jni.cxx
gzz/gfx/gl : GL.java
Added files:
gfx/libtexture : irregu.texture
Log message:
Try constant edge width with shade_all_levels in irregu3.py; of course,
does not work for magnification
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu3.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.52&tr2=1.53&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtexture/irregu.texture?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GL.java.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/irregu3.py
diff -c gzz/gfx/demo/irregu3.py:1.5 gzz/gfx/demo/irregu3.py:1.6
*** gzz/gfx/demo/irregu3.py:1.5 Fri Oct 18 07:39:16 2002
--- gzz/gfx/demo/irregu3.py Mon Oct 21 02:56:08 2002
***************
*** 6,13 ****
# "scale", "0.15", "freq", "1", "df", "2",
# "scale2", "0.25", "freq2", "10", "df2", ".5"])
! #tex.shade(16, 16, 0, 4, "RGBA", "RGBA",
! # "geometric", ["type", "7", "bias", "-0", "scale", "2"])
--- 6,15 ----
# "scale", "0.15", "freq", "1", "df", "2",
# "scale2", "0.25", "freq2", "10", "df2", ".5"])
! ripple_scale = 0.25
! tex.shade_all_levels(256, 256, 0, 4, "RGBA", "RGBA",
! "irregu", ["radius", "2", str(ripple_scale), "0.25",
! "scale", ".25", "bias", ".75", "eps", ".125"])
***************
*** 24,39 ****
BindTexture TEXTURE_2D %(texid)s
# Try to convince the GL implementation to do
# perspective correct color interpolation
Hint PERSPECTIVE_CORRECTION_HINT NICEST
#Debug mountains
! TexImage2D TEXTURE_2D 0 LUMINANCE_ALPHA 8 1 0 LUMINANCE_ALPHA \
.5 .5 1 1 .5 .5 .85 .85 .5 .5 .7 .7 .5 .5 .55 .55
! TexParameter TEXTURE_2D TEXTURE_BASE_LEVEL 0
! TexParameter TEXTURE_2D TEXTURE_MAX_LEVEL 0
! TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR
TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
Enable TEXTURE_2D
--- 26,44 ----
BindTexture TEXTURE_2D %(texid)s
+ PushMatrix
+ Translate -.5 -.75 0
+
# Try to convince the GL implementation to do
# perspective correct color interpolation
Hint PERSPECTIVE_CORRECTION_HINT NICEST
#Debug mountains
! #TexImage2D TEXTURE_2D 0 LUMINANCE_ALPHA 8 1 0 LUMINANCE_ALPHA \
.5 .5 1 1 .5 .5 .85 .85 .5 .5 .7 .7 .5 .5 .55 .55
! #TexParameter TEXTURE_2D TEXTURE_BASE_LEVEL 0
! #TexParameter TEXTURE_2D TEXTURE_MAX_LEVEL 0
! TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
Enable TEXTURE_2D
***************
*** 44,52 ****
#BlendFunc SRC_ALPHA ONE_MINUS_SRC_ALPHA
#Enable BLEND
#Disable TEXTURE_2D
!
Color 1 1 1 1
# Debug strip
Begin QUAD_STRIP
TexCoord 0 0 0 1
--- 49,59 ----
#BlendFunc SRC_ALPHA ONE_MINUS_SRC_ALPHA
#Enable BLEND
#Disable TEXTURE_2D
!
Color 1 1 1 1
+ TexEnv TEXTURE_ENV TEXTURE_ENV_MODE MODULATE
+
# Debug strip
Begin QUAD_STRIP
TexCoord 0 0 0 1
***************
*** 59,100 ****
Vertex %(e)s %(e)s 0 %(e)s
End
Begin QUAD_STRIP
TexCoord 0 0 0 1
! Color 0 0 0 1
Vertex 0 %(e)s 0 1
TexCoord 0 0 0 %(e)s
! Color 0 0 0 %(e)s
Vertex 0 %(e)s 0 %(e)s
TexCoord 1 0 0 1
! Color 0 0 0 1
Vertex 1 %(e)s 0 1
TexCoord %(e)s 0 0 %(e)s
! Color 0 0 0 %(e)s
Vertex %(e)s %(e)s 0 %(e)s
End
PopAttrib
""" % vars())
class IrreguScene:
def scene(self, vs):
putnoc(vs, background((0.1,0.4,0.5)))
!
! cs1 = vs.coords.affineCoordsys(0, 0, 12, 700, 1000, 0, 0, -600)
vs.matcher.add(cs1, "1")
vs.map.put(irr, cs1)
def key(self, k):
! pass
currentScene = IrreguScene()
--- 66,165 ----
Vertex %(e)s %(e)s 0 %(e)s
End
+ BlendFunc ZERO ZERO
+ Enable BLEND
+
+ TexEnv TEXTURE_ENV TEXTURE_ENV_MODE COMBINE_ARB
+ TexEnv TEXTURE_ENV COMBINE_RGB_ARB DOT3_RGBA_ARB
+ TexEnv TEXTURE_ENV SOURCE0_RGB_ARB TEXTURE
+ TexEnv TEXTURE_ENV OPERAND0_RGB_ARB SRC_COLOR
+ TexEnv TEXTURE_ENV SOURCE1_RGB_ARB PREVIOUS_ARB
+ TexEnv TEXTURE_ENV OPERAND1_RGB_ARB SRC_COLOR
+
+ # Ignored with dot3:
+ #TexEnv TEXTURE_ENV COMBINE_ALPHA_ARB REPLACE
+ #TexEnv TEXTURE_ENV SOURCE0_ALPHA_ARB TEXTURE
+ #TexEnv TEXTURE_ENV OPERAND0_ALPHA_ARB SRC_ALPHA
+ #TexEnv TEXTURE_ENV SOURCE1_ALPHA_ARB TEXTURE
+ #TexEnv TEXTURE_ENV OPERAND1_ALPHA_ARB SRC_ALPHA
+
+ MatrixMode TEXTURE
+ LoadMatrix 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
+ MatrixMode MODELVIEW
+
+ Begin QUAD_STRIP
+
+ TexCoord 0 0 0 1
+ Color 1 .5 .5
+ Vertex 0 %(e)s 0 1
+
+ TexCoord 0 0 0 %(e)s
+ Color .75 .5 .5
+ Vertex 0 %(e)s 0 %(e)s
+
+ TexCoord 1 0 0 1
+ Color 1 .5 .5
+ Vertex 1 %(e)s 0 1
+
+ TexCoord %(e)s 0 0 %(e)s
+ Color .75 .5 .5
+ Vertex %(e)s %(e)s 0 %(e)s
+
+ End
+
+ Disable BLEND
+
+ TexEnv TEXTURE_ENV TEXTURE_ENV_MODE MODULATE
+
+ #Translate 0 -1 0
+ #Scale 1 2 1
Begin QUAD_STRIP
TexCoord 0 0 0 1
! Color 1 1 0 1
Vertex 0 %(e)s 0 1
TexCoord 0 0 0 %(e)s
! Color 1 1 0 %(e)s
Vertex 0 %(e)s 0 %(e)s
TexCoord 1 0 0 1
! Color 1 1 0 1
Vertex 1 %(e)s 0 1
TexCoord %(e)s 0 0 %(e)s
! Color 1 1 0 %(e)s
Vertex %(e)s %(e)s 0 %(e)s
End
+
+ PopMatrix
PopAttrib
""" % vars())
+
+ def getIrregu(x0, y0, x1, y1, s0, t0, s1, t1):
+ tlen = sqrt((s1 - s0)**2 + (t1 - t0)**2)
+ len = sqrt((x1 - x0)**2 + (y1 - y0)**2)
+
+
class IrreguScene:
+ def __init__(self):
+ self.scale = 8
+
def scene(self, vs):
putnoc(vs, background((0.1,0.4,0.5)))
! cs1 = vs.coords.affineCoordsys(0, 0, 512, 384, 128*self.scale, 0, 0,
-64*self.scale)
vs.matcher.add(cs1, "1")
vs.map.put(irr, cs1)
def key(self, k):
! if k == "+": self.scale *= 2.0
! if k == "-": self.scale /= 2.0
currentScene = IrreguScene()
Index: gzz/gfx/jni/GzzGL-jni.cxx
diff -c gzz/gfx/jni/GzzGL-jni.cxx:1.52 gzz/gfx/jni/GzzGL-jni.cxx:1.53
*** gzz/gfx/jni/GzzGL-jni.cxx:1.52 Sat Oct 19 10:26:36 2002
--- gzz/gfx/jni/GzzGL-jni.cxx Mon Oct 21 02:56:08 2002
***************
*** 541,547 ****
(JNIEnv *env, jclass, jint id, jint w, jint h, jint d, jint comp,
jstring internalFormat,
jstring format,
! jstring name, jobjectArray params) {
setWindow();
DBG(dbg)<<"Shade into "<<id<<"\n";
--- 541,547 ----
(JNIEnv *env, jclass, jint id, jint w, jint h, jint d, jint comp,
jstring internalFormat,
jstring format,
! jstring name, jobjectArray params, jboolean shade_all_levels) {
setWindow();
DBG(dbg)<<"Shade into "<<id<<"\n";
***************
*** 563,605 ****
float *value = new float[w * h * (d==0?1:d) * comp];
! s->render(&p, w, h, (d==0?1:d), comp, value);
! if(d == 0) {
! glBindTexture(GL_TEXTURE_2D, id);
!
! glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
! glTexImage2D(GL_TEXTURE_2D, 0,
! tokenFromJstring(env, internalFormat),
! w, h, 0,
! tokenFromJstring(env, format),
! GL_FLOAT,
! value);
!
!
! glBindTexture(GL_TEXTURE_2D, 0);
! } else {
! glBindTexture(GL_TEXTURE_3D, id);
! GLERR
!
! glTexParameteri(GL_TEXTURE_3D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
! GLERR
!
! glTexImage3D(GL_TEXTURE_3D, 0,
! tokenFromJstring(env, internalFormat),
! w, h, d, 0,
! tokenFromJstring(env, format),
! GL_FLOAT,
! value);
!
! GLERR
!
!
! glBindTexture(GL_TEXTURE_3D, 0);
! GLERR
}
delete[] value;
delete s;
--- 563,612 ----
float *value = new float[w * h * (d==0?1:d) * comp];
! GLenum target = (d == 0) ? GL_TEXTURE_2D : GL_TEXTURE_3D;
! glBindTexture(target, id);
+ if (!shade_all_levels) {
+ glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
+ GLERR;
+ }
+
+ int level;
+ for (level = 0; ; level++) {
+ s->render(&p, w, h, (d==0?1:d), comp, value);
+
+ if (d == 0)
+ glTexImage2D(GL_TEXTURE_2D, level,
+ tokenFromJstring(env, internalFormat),
+ w, h, 0,
+ tokenFromJstring(env, format),
+ GL_FLOAT,
+ value);
+ else
+ glTexImage3D(GL_TEXTURE_3D, level,
+ tokenFromJstring(env, internalFormat),
+ w, h, d, 0,
+ tokenFromJstring(env, format),
+ GL_FLOAT,
+ value);
+
+ GLERR;
+
+ if (! (shade_all_levels && (w > 1 || h > 1 || d > 1))) break;
+
+ w = (w + 1) >> 1;
+ h = (h + 1) >> 1;
+ d = (d + 1) >> 1;
+ }
+
+ if (shade_all_levels) {
+ glTexParameterf(target, GL_TEXTURE_BASE_LEVEL, 0);
+ glTexParameterf(target, GL_TEXTURE_MAX_LEVEL, level);
}
+ glBindTexture(target, 0);
+ GLERR;
delete[] value;
delete s;
Index: gzz/gzz/gfx/gl/GL.java
diff -c gzz/gzz/gfx/gl/GL.java:1.14 gzz/gzz/gfx/gl/GL.java:1.15
*** gzz/gzz/gfx/gl/GL.java:1.14 Sat Oct 19 10:26:36 2002
--- gzz/gzz/gfx/gl/GL.java Mon Oct 21 02:56:08 2002
***************
*** 419,425 ****
String internalFormat, String format,
String shaderName, String[] params) {
return impl_Texture_shade(getId(), w, h, d, comps, internalFormat,
format,
! shaderName, params);
}
/** Load a NULL pointer to the texture, which clears the image
--- 419,434 ----
String internalFormat, String format,
String shaderName, String[] params) {
return impl_Texture_shade(getId(), w, h, d, comps, internalFormat,
format,
! shaderName, params, false);
! }
!
! /** Call libtexture to create the image for each mipmap level
separately.
! */
! public int shade_all_levels(int w, int h, int d, int comps,
! String internalFormat, String format,
! String shaderName, String[] params) {
! return impl_Texture_shade(getId(), w, h, d, comps, internalFormat,
format,
! shaderName, params, true);
}
/** Load a NULL pointer to the texture, which clears the image
***************
*** 462,468 ****
static private native void impl_deleteTexture(int id);
static private native int impl_Texture_shade(int id, int w, int h, int d,
int comps,
String internalFormat, String format,
! String shaderName, String[] params);
static private native void impl_Texture_loadNull2D(int id, int level,
String internalFormat, int w, int h,
--- 471,478 ----
static private native void impl_deleteTexture(int id);
static private native int impl_Texture_shade(int id, int w, int h, int d,
int comps,
String internalFormat, String format,
! String shaderName, String[] params,
! boolean shade_all_levels);
static private native void impl_Texture_loadNull2D(int id, int level,
String internalFormat, int w, int h,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz gfx/demo/irregu3.py gfx/jni/GzzGL-jni.cxx g...,
Janne V. Kujala <=