[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz ./TODO gfx/jni/GzzGL-jni.cxx gfx/libpaper/p...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] gzz ./TODO gfx/jni/GzzGL-jni.cxx gfx/libpaper/p... |
Date: |
Wed, 23 Oct 2002 09:45:38 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Tuomas J. Lukka <address@hidden> 02/10/23 09:45:37
Modified files:
. : TODO
gfx/jni : GzzGL-jni.cxx
gfx/libpaper : papermill.py texcoords.py
gzz/gfx/gl : GL.java PaperMill.java
test/gzz/gfx/gl: paper.test
Log message:
Optimizing papers, using copyteximage. Not very successful yet...
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.318&tr2=1.319&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/jni/GzzGL-jni.cxx.diff?tr1=1.53&tr2=1.54&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/papermill.py.diff?tr1=1.54&tr2=1.55&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/texcoords.py.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GL.java.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/PaperMill.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/gfx/gl/paper.test.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
Patches:
Index: gzz/TODO
diff -u gzz/TODO:1.318 gzz/TODO:1.319
--- gzz/TODO:1.318 Wed Oct 23 08:12:38 2002
+++ gzz/TODO Wed Oct 23 09:45:37 2002
@@ -129,7 +129,7 @@
- dicing only when needed
- don't
- soft shadows
- - pre-rendering paper
+ - pre-rendering paper for speedup
- Nokia demo [deadline 24.10]
- xupdf:
- larger structure
Index: gzz/gfx/jni/GzzGL-jni.cxx
diff -u gzz/gfx/jni/GzzGL-jni.cxx:1.53 gzz/gfx/jni/GzzGL-jni.cxx:1.54
--- gzz/gfx/jni/GzzGL-jni.cxx:1.53 Mon Oct 21 02:56:08 2002
+++ gzz/gfx/jni/GzzGL-jni.cxx Wed Oct 23 09:45:37 2002
@@ -537,6 +537,21 @@
}
+JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Texture_1copyTexImage2D(
+ JNIEnv *env, jclass, jint id, jstring bufferstr,
+ jstring targetstr, jint level,
+ jstring iforstring, jint x, jint y, jint w, jint h,
+ jint border) {
+ GLenum buffer = tokenFromJstring(env, bufferstr);
+ GLenum target = tokenFromJstring(env, targetstr);
+ GLenum ifor = tokenFromJstring(env, iforstring);
+ glBindTexture(target, id);
+ glReadBuffer(buffer);
+ glCopyTexImage2D(target, level, ifor, x, y, w, h, border);
+ glBindTexture(target, 0);
+ GLERR
+}
+
JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_impl_1Texture_1shade
(JNIEnv *env, jclass, jint id, jint w, jint h, jint d, jint comp,
jstring internalFormat,
Index: gzz/gfx/libpaper/papermill.py
diff -u gzz/gfx/libpaper/papermill.py:1.54 gzz/gfx/libpaper/papermill.py:1.55
--- gzz/gfx/libpaper/papermill.py:1.54 Wed Oct 16 10:50:11 2002
+++ gzz/gfx/libpaper/papermill.py Wed Oct 23 09:45:37 2002
@@ -2,6 +2,7 @@
from gfx.libpaper.colors import Colors
from gfx.libpaper.texcoords import TexGenXYRepeatUnit
from gfx.libpaper.params import *
+from gzz.vob import SolidBgVob
from gzz.gfx.gl import GL,GLRen,Paper,PaperMill
import java
@@ -134,8 +135,63 @@
setDummyPass(pap.getPass(i))
#if dbg: pap.reg.dump()
+ pap.repeat = rootrep
return pap
-
+
+ def getOptimizedPaper(self, seed, w):
+ pap = self.getPaper(seed)
+
+ # Now, we render a region.
+ v = pap.repeat._getSTVectors()
+
+ s = 256
+ vs = w.createVobScene()
+ vs.map.put(SolidBgVob(java.awt.Color.black))
+
+ cs1 = vs.coords.ortho(0, 0, 0, 0, s, s)
+ cs2 = vs.coords.affineCoordsys(
+ 0, 0, 0, 0,
+ v[0][0], v[0][1], v[1][0], v[1][1]
+ )
+ vs.map.put(GLRen.createPaperQuad(pap, 0, 0, 1, 1, 1))
+ w.renderStill(vs, 1)
+
+ tex = GL.createTexture()
+ tex.copyTexImage2D("FRONT", "TEXTURE_2D", 0,
+ "RGB", 0, vs.getSize().height-1-s,
+ s, s, 0)
+
+ npap = PaperHanger()
+ npap.setNPasses(1)
+ npap.cachedTexture = tex
+
+ ppass = npap.getPass(0)
+
+ texid = tex.getTexId()
+
+ ppass.setSetupcode("""
+ PushAttrib ENABLE_BIT TEXTURE_BIT DEPTH_BUFFER_BIT
+ Disable BLEND
+ Enable DEPTH_TEST
+ DepthFunc LESS
+ BindTexture TEXTURE_2D %(texid)s
+ TexEnv TEXTURE_ENV TEXTURE_ENV_MODE REPLACE
+ """ % locals())
+
+ ppass.setNTexGens(1)
+ ppass.putNormalTexGen(0,
+ [ v[0][0], v[0][1], 0, 0,
+ v[1][0], v[1][1], 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,])
+
+ ppass.setTeardowncode("""
+ PopAttrib
+ ActiveTexture TEXTURE0
+ """)
+
+ return npap
+
def makePaperPass(self, reg, ppass, colors, textures, rootrep, trans = 0,
emboss = 0):
seed = reg.get(regseed, "seed")
rnd = java.util.Random(seed)
Index: gzz/gfx/libpaper/texcoords.py
diff -u gzz/gfx/libpaper/texcoords.py:1.15 gzz/gfx/libpaper/texcoords.py:1.16
--- gzz/gfx/libpaper/texcoords.py:1.15 Wed Oct 16 05:14:10 2002
+++ gzz/gfx/libpaper/texcoords.py Wed Oct 23 09:45:37 2002
@@ -95,7 +95,7 @@
self.vecs = [[ rs * math.cos(as), rt * math.cos(at)],
[ rs * math.sin(as), rt * math.sin(at)]]
- def _getSTVectors(self, rnd):
+ def _getSTVectors(self, rnd=None):
"""Get the 2 4-component vectors that (x,y,0,1) should
be multiplied by to get (s,t).
"""
@@ -107,9 +107,10 @@
r = [[ f * mat[1][1], -f * mat[0][1], 0, "?"],
[ -f * mat[1][0], f * mat[0][0], 0, "?"]]
- # Random offsets
- r[0][3] = rnd.nextDouble()
- r[1][3] = rnd.nextDouble()
+ if rnd != None:
+ # Random offsets
+ r[0][3] = rnd.nextDouble()
+ r[1][3] = rnd.nextDouble()
return r
Index: gzz/gzz/gfx/gl/GL.java
diff -u gzz/gzz/gfx/gl/GL.java:1.15 gzz/gzz/gfx/gl/GL.java:1.16
--- gzz/gzz/gfx/gl/GL.java:1.15 Mon Oct 21 02:56:08 2002
+++ gzz/gzz/gfx/gl/GL.java Wed Oct 23 09:45:37 2002
@@ -460,6 +460,17 @@
internalFormat, transferformat);
}
+ /** Read into this texture from screen.
+ */
+ public void copyTexImage2D(String buffer,
+ String target, int level,
+ String internalFormat, int x, int y,
+ int w, int h, int border) {
+ impl_Texture_copyTexImage2D(getId(), buffer, target,
+ level, internalFormat, x, y, w, h,
+ border);
+ }
+
}
/** Create a new OpenGL texture object.
@@ -481,6 +492,11 @@
int level, int imgid, int xoffs, int yoffs) ;
static private native void impl_Texture_downsampleInto(int id, int intoid,
String target,
int level, String internalFormat, String transferformat);
+ static private native void impl_Texture_copyTexImage2D(
+ int id, String buffer,
+ String target, int level,
+ String internalFormat, int x, int y,
+ int w, int h, int border) ;
//--------- VertexProgramNV
/** A vertex program object.
Index: gzz/gzz/gfx/gl/PaperMill.java
diff -u gzz/gzz/gfx/gl/PaperMill.java:1.5 gzz/gzz/gfx/gl/PaperMill.java:1.6
--- gzz/gzz/gfx/gl/PaperMill.java:1.5 Sat Oct 12 05:50:01 2002
+++ gzz/gzz/gfx/gl/PaperMill.java Wed Oct 23 09:45:37 2002
@@ -22,10 +22,14 @@
*/
package gzz.gfx.gl;
+import gzz.client.GraphicsAPI;
import org.python.util.PythonInterpreter;
public abstract class PaperMill {
public abstract Paper getPaper(int seed);
+ public Paper getOptimizedPaper(int seed, GraphicsAPI.Window w) {
+ return getPaper(seed);
+ }
static private PaperMill instance;
Index: gzz/test/gzz/gfx/gl/paper.test
diff -u gzz/test/gzz/gfx/gl/paper.test:1.4 gzz/test/gzz/gfx/gl/paper.test:1.5
--- gzz/test/gzz/gfx/gl/paper.test:1.4 Wed Oct 16 03:46:39 2002
+++ gzz/test/gzz/gfx/gl/paper.test Wed Oct 23 09:45:37 2002
@@ -28,6 +28,32 @@
checkNotAvgColor(150, 150, 2, 2, (0,0,0), 30)
checkNotAvgColor(250, 250, 2, 2, (0,0,0), 30)
+def testOptimizedPaper():
+ """See that optimized paper really is same as
+ original."""
+ for i in range(0,5):
+ p1 = PaperMill.getInstance().getPaper(i)
+ p2 = PaperMill.getInstance().getOptimizedPaper(i, win)
+
+ pq1 = GLRen.createPaperQuad(p1, 0, 0, 1, 1, 1)
+ pq2 = GLRen.createPaperQuad(p2, 0, 0, 1, 1, 1)
+
+ vs = getvs()
+ vs.map.put(SolidBgVob(Color.blue))
+
+ vs.put(pq1, 0, 0, 0, 150, 300)
+ vs.put(pq2, 0, 150, 0, 150, 300)
+
+ render(vs)
+
+ for x, y, w, h in [
+ (10, 10, 5, 5),
+ (50, 20, 10, 5),
+ (100, 200, 10, 30),
+ ]:
+ checkAvgColor(x+150, y, w, h,
+ getAvgColor(x, y, w, h))
+
# : vim: set syntax=python :
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz ./TODO gfx/jni/GzzGL-jni.cxx gfx/libpaper/p...,
Tuomas J. Lukka <=