gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] libvob ./TODO include/vob/vobs/GLState.hxx incl...


From: Tuomas J. Lukka
Subject: [Gzz-commits] libvob ./TODO include/vob/vobs/GLState.hxx incl...
Date: Tue, 13 May 2003 07:48:22 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Changes by:     Tuomas J. Lukka <address@hidden>        03/05/13 07:48:22

Modified files:
        .              : TODO 
        include/vob/vobs: GLState.hxx Paper.hxx 
        org/nongnu/libvob/gl: GL.java SpecialPapers.java 
        org/nongnu/libvob/vobs: SimpleConnection.java 
        src/jni        : Render.cxx 
        src/main       : Renderer.cxx 
        test/tools     : gfx.py 
        test/vob/gl    : specialpaper.test 
        vob/buoy       : buoymanager.py 

Log message:
        Important bug fix: paperquad teardown call. With tests.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/TODO.diff?tr1=1.22&tr2=1.23&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/GLState.hxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Paper.hxx.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/GL.java.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/SpecialPapers.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/vobs/SimpleConnection.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Render.cxx.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/main/Renderer.cxx.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/test/tools/gfx.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/test/vob/gl/specialpaper.test.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/buoy/buoymanager.py.diff?tr1=1.12&tr2=1.13&r1=text&r2=text

Patches:
Index: libvob/TODO
diff -u libvob/TODO:1.22 libvob/TODO:1.23
--- libvob/TODO:1.22    Tue Apr 29 07:26:27 2003
+++ libvob/TODO Tue May 13 07:48:21 2003
@@ -1,38 +1,26 @@
 Tasks for libvob
 
----------: for porting xupdf, for demo on thursday
-    tjl:
-       - try to fix papermill: 
-           - papers have solid colors and there's garbage in some textures
-             (see basis textures with 
-             make rundemo DEMO=org.nongnu.libvob.demo.paper
-              )
-           - optimized papers fail in paper.test
-             (and dicing paper test marked as failing because distort 
-             wasn't found)
-       - port buoy code
-       - image loading
-       - mipzips
-           - test generation and use
-       - transform derivatives
-       + rethink nonlinearity: maybe should rather be "local magnification"...
-       ALPH:
-           - start porting code.
-
-    - error for setting
-
 0.1alpha1: First separate release
-    vegai:
+    anybody:
        - .cvsignores
        - make sure libvob works right with kaffe
+       - change window title from "Gzz"
+       - error handling:
+           - make texture module to throw error if texture not found
+           - crash test GL + GLRen entry points with invalid values
     tjl:
        - port more demos
+           - organize
        - move Vec23 into util.
+       - tutorial
     humppake:
        - navidocize
 
 0.1alpha2: Cleanup
     tjl:
+       + rethink nonlinearity: maybe should rather be "local magnification"...
+       - error for setting coordsys with wrong type
+       - transform derivatives
        - document the template build system
        - go through " grep cout gfx/*/*.[ch]* "
          and deal with them.
Index: libvob/include/vob/vobs/GLState.hxx
diff -u libvob/include/vob/vobs/GLState.hxx:1.1 
libvob/include/vob/vobs/GLState.hxx:1.2
--- libvob/include/vob/vobs/GLState.hxx:1.1     Tue Apr 29 07:22:41 2003
+++ libvob/include/vob/vobs/GLState.hxx Tue May 13 07:48:21 2003
@@ -11,6 +11,8 @@
 #include <vob/Vec23.hxx>
 #include <vob/VecGL.hxx>
 
+#include <sstream>
+
 
 #ifndef VOB_DEFINED
 #define VOB_DEFINED(t)
@@ -21,6 +23,9 @@
 
 using namespace Vob::VecGL;
 
+/** Transform the given GL matrix with the given transformation.
+ * Assumes that the transformation is linear in homogeneous coords.
+ */
 struct TransMatrix {
     enum { NTrans = 1 };
     Token matrix;
@@ -37,6 +42,61 @@
 };
 
 VOB_DEFINED(TransMatrix);
+
+extern std::string testStateRetainCorrect;
+
+/** Test that a given set of Vobs pushes and pops the OpenGL state 
appropriately.
+ * This Vob sets up the test.
+ */
+struct TestStateRetainSetup {
+    enum { NTrans = 0 };
+    template<class F> void params(F &f) {
+       f();
+    }
+    void render() const {
+       glPushAttrib(GL_CURRENT_BIT);
+       glColor4d(.25, .50, .75, .125);
+    }
+
+};
+
+VOB_DEFINED(TestStateRetainSetup);
+
+/** Test that a given set of Vobs pushes and pops the OpenGL state 
appropriately.
+ * This Vob performs the test and sets the test result.
+ */
+struct TestStateRetainTest {
+    enum { NTrans = 0 };
+    template<class F> void params(F &f) {
+       f();
+    }
+    void render() const {
+       glBegin(GL_TRIANGLES);
+       glVertex3f(-100,-100,100);
+       glVertex3f(-99,-100,100);
+       glVertex3f(-100,-99,100);
+       glEnd();
+       GLdouble color[4];
+       glGetDoublev(GL_CURRENT_COLOR, color);
+#define TC(a, b) if(a != b) fail(#a, a, b); 
+       TC(color[0], .25);
+       TC(color[1], .50);
+       TC(color[2], .75);
+       TC(color[3], .125);
+
+       glPopAttrib();
+    }
+private:
+    void fail(char *s, double v0, double v1) const {
+       std::ostringstream o;
+       o << s << ": "<<v0<<" "<<v1<<"\n";
+       testStateRetainCorrect += o.str();
+    }
+
+};
+
+VOB_DEFINED(TestStateRetainTest);
+
 
 }
 }
Index: libvob/include/vob/vobs/Paper.hxx
diff -u libvob/include/vob/vobs/Paper.hxx:1.7 
libvob/include/vob/vobs/Paper.hxx:1.8
--- libvob/include/vob/vobs/Paper.hxx:1.7       Wed May  7 08:00:42 2003
+++ libvob/include/vob/vobs/Paper.hxx   Tue May 13 07:48:21 2003
@@ -302,6 +302,7 @@
                }
 
                glEnd();
+               (*it).tearDown_explicit();
            }
            verts.endV3Operation();
 
Index: libvob/org/nongnu/libvob/gl/GL.java
diff -u libvob/org/nongnu/libvob/gl/GL.java:1.12 
libvob/org/nongnu/libvob/gl/GL.java:1.13
--- libvob/org/nongnu/libvob/gl/GL.java:1.12    Fri May  9 06:55:38 2003
+++ libvob/org/nongnu/libvob/gl/GL.java Tue May 13 07:48:21 2003
@@ -812,6 +812,11 @@
        renderImpl(win.getId(), ninds, inds1, pts1, interpinds, inds2, pts2, 
codes,
                            fract, standardcoords, showFinal);
     }
+
+    /** Part of the GL state-retaining test mechanism - see 
TestStateRetainSetup and
+     * TestStateRetainTest.
+     */
+    public static native String getTestStateRetainCorrect();
     private static native void renderImpl(
                int window, 
                int ninds, int[] inds1, float[] pts1, 
Index: libvob/org/nongnu/libvob/gl/SpecialPapers.java
diff -u libvob/org/nongnu/libvob/gl/SpecialPapers.java:1.2 
libvob/org/nongnu/libvob/gl/SpecialPapers.java:1.3
--- libvob/org/nongnu/libvob/gl/SpecialPapers.java:1.2  Mon May 12 10:56:30 2003
+++ libvob/org/nongnu/libvob/gl/SpecialPapers.java      Tue May 13 07:48:21 2003
@@ -14,7 +14,7 @@
        p.setNPasses(1);
        Paper.Pass p0 = p.getPass(0);
        p0.setSetupcode(
-               "PushAttrib COLOR_BUFFER_BIT ENABLE_BIT\n"+
+               "PushAttrib CURRENT_BIT COLOR_BUFFER_BIT ENABLE_BIT\n"+
                "Disable BLEND\n"+
                "Disable TEXTURE_2D\n"+
                "Color "+ColorUtil.colorGLString(color)+"\n"
@@ -43,7 +43,7 @@
        p.setNPasses(1);
        Paper.Pass p0 = p.getPass(0);
        p0.setSetupcode(
-           "PushAttrib COLOR_BUFFER_BIT TEXTURE_BIT ENABLE_BIT\n"+
+           "PushAttrib CURRENT_BIT COLOR_BUFFER_BIT TEXTURE_BIT ENABLE_BIT\n"+
            "Disable BLEND\n"+
            "Color 1 1 1\n"+
            "Enable TEXTURE_2D\n"+
Index: libvob/org/nongnu/libvob/vobs/SimpleConnection.java
diff -u libvob/org/nongnu/libvob/vobs/SimpleConnection.java:1.4 
libvob/org/nongnu/libvob/vobs/SimpleConnection.java:1.5
--- libvob/org/nongnu/libvob/vobs/SimpleConnection.java:1.4     Tue Apr  8 
16:25:02 2003
+++ libvob/org/nongnu/libvob/vobs/SimpleConnection.java Tue May 13 07:48:21 2003
@@ -35,23 +35,23 @@
  */
 
 public class SimpleConnection extends AbstractVob {
-public static final String rcsid = "$Id: SimpleConnection.java,v 1.4 
2003/04/08 20:25:02 tjl Exp $";
+public static final String rcsid = "$Id: SimpleConnection.java,v 1.5 
2003/05/13 11:48:21 tjl Exp $";
 
     float x0, y0, x1, y1;
     Color color;
     Point pt0, pt1;
 
     /**
-     *  @param x0, y0 Coordinate inside first coord system
-     *  @param x1, y1 Coordinate inside second coord system
+     *  @param x0,y0 Coordinate inside first coord system
+     *  @param x1,y1 Coordinate inside second coord system
      */
     public SimpleConnection(float x0, float y0, float x1, float y1) {
        this(x0, y0, x1, y1, null);
     }
 
     /**
-     *  @param x0, y0 Coordinate inside first coord system
-     *  @param x1, y1 Coordinate inside second coord system
+     *  @param x0,y0 Coordinate inside first coord system
+     *  @param x1,y1 Coordinate inside second coord system
      */
     public SimpleConnection(float x0, float y0, float x1, float y1,
                             Color color) {
@@ -76,11 +76,15 @@
        g.drawLine(pt0.x, pt0.y, pt1.x, pt1.y);
     }
 
+    public Vob glsetup;
     Vob line;
+    public Vob glteardown;
 
     public int putGL(VobScene vs, int coordsys1, int coordsys2) {
        if(line == null) line = GLRen.createLineConnector(x0, y0, x1, y1);
+       if(glsetup != null) vs.map.put(glsetup);
        vs.map.put(line, coordsys1, coordsys2);
+       if(glteardown != null) vs.map.put(glteardown);
        return 0;
     }
 }
Index: libvob/src/jni/Render.cxx
diff -u libvob/src/jni/Render.cxx:1.4 libvob/src/jni/Render.cxx:1.5
--- libvob/src/jni/Render.cxx:1.4       Sat Apr 19 15:37:32 2003
+++ libvob/src/jni/Render.cxx   Tue May 13 07:48:21 2003
@@ -29,6 +29,8 @@
 #include <vob/Debug.hxx>
 #include <vob/glerr.hxx>
 
+#include <vob/vobs/GLState.hxx>
+
 #include <vob/jni/Types.hxx>
 
 #include "org_nongnu_libvob_gl_GL.h"
@@ -46,6 +48,13 @@
 extern "C" {
 
 Renderer renderer(defaultTransformFactory);
+
+jf( jstring, getTestStateRetainCorrect)
+  (JNIEnv *env, jclass) {
+      jstring res = stdstr2jstr(env, ::Vob::Vobs::testStateRetainCorrect);
+      ::Vob::Vobs::testStateRetainCorrect = "";
+      return res;
+}
 
 jf( void, renderImpl)
   (JNIEnv *env, jclass, jint window,
Index: libvob/src/main/Renderer.cxx
diff -u libvob/src/main/Renderer.cxx:1.6 libvob/src/main/Renderer.cxx:1.7
--- libvob/src/main/Renderer.cxx:1.6    Sun Apr 20 06:54:31 2003
+++ libvob/src/main/Renderer.cxx        Tue May 13 07:48:21 2003
@@ -17,6 +17,8 @@
 
     namespace Vobs {
        DBGVAR(dbg_irregularquad, "IrregularQuad");
+
+       std::string testStateRetainCorrect;
     }
 
     namespace Dicer {
Index: libvob/test/tools/gfx.py
diff -u libvob/test/tools/gfx.py:1.9 libvob/test/tools/gfx.py:1.10
--- libvob/test/tools/gfx.py:1.9        Fri Apr 25 13:16:45 2003
+++ libvob/test/tools/gfx.py    Tue May 13 07:48:21 2003
@@ -155,3 +155,23 @@
        if abs(dst[i]-dstlist[i]) > delta:
            raise str([srclist, dstlist, dst, i, dst[i], dstlist[i]])
 
+
+
+def checkState1(vs):
+    # Zero the test string
+    print "CS1"
+    print "CS1_X", GL
+    print "CS1_X", GL.getTestStateRetainCorrect
+    GL.getTestStateRetainCorrect()
+    print "CS1_1"
+    vs.put(GLRen.createTestStateRetainSetup())
+    print "CS1_2"
+
+def checkState2(vs):
+    vs.put(GLRen.createTestStateRetainTest())
+
+def checkState3(vs):
+    s = GL.getTestStateRetainCorrect()
+    if s != "":
+       raise s
+
Index: libvob/test/vob/gl/specialpaper.test
diff -u libvob/test/vob/gl/specialpaper.test:1.2 
libvob/test/vob/gl/specialpaper.test:1.3
--- libvob/test/vob/gl/specialpaper.test:1.2    Mon May 12 10:56:30 2003
+++ libvob/test/vob/gl/specialpaper.test        Tue May 13 07:48:21 2003
@@ -5,23 +5,34 @@
 import vob
 from java.awt import Color
 from test.tools.gfx import *
+from vob.putil.misc import quad
 
 
 def testSolid():
     vs = getvs()
     vs.put(vob.vobs.SolidBackdropVob(Color.black))
 
+    checkState1(vs)
+
     paper = vob.gl.SpecialPapers.solidPaper(Color.blue)
     pq = vob.gl.GLRen.createFixedPaperQuad(paper, 0, 0, 1, 1, 0, 10, 10, 10)
 
     vs.put(pq, vs.coords.ortho(0, 0, 100,100, 100, 100))
 
+    checkState2(vs)
+    checkState1(vs)
+
     paper = vob.gl.SpecialPapers.solidPaper(Color.red)
     pq = vob.gl.GLRen.createFixedPaperQuad(paper, 0, 0, 1, 1, 0, 10, 10, 10)
 
     vs.put(pq, vs.coords.ortho(0, 0, 200,100, 100, 100))
 
+    checkState2(vs)
+
     render(vs)
+
+    checkState3(vs)
+
     checkAvgColor(95, 95, 4, 4, (0,0,0))
     checkAvgColor(140, 140, 20, 20, (0,0,255))
     checkAvgColor(240, 140, 20, 20, (255,0,0))
@@ -30,11 +41,18 @@
     vs = getvs()
     vs.put(vob.vobs.SolidBackdropVob(Color.black))
 
+    checkState1(vs)
+
     paper = vob.gl.SpecialPapers.cgraphPaper(100)
     pq = vob.gl.GLRen.createFixedPaperQuad(paper, -100, -100, 200, 200, 0, 10, 
10, 10)
 
     vs.put(pq, vs.coords.ortho(0, 0, 100, 100, 1, 1))
+
+    checkState2(vs)
+
     render(vs)
+
+    checkState3(vs)
 
     checkAvgColor(50, 50, 4, 4, (0,0,0))
     checkAvgColor(50, 250, 4, 4, (255,0,0))
Index: libvob/vob/buoy/buoymanager.py
diff -u libvob/vob/buoy/buoymanager.py:1.12 libvob/vob/buoy/buoymanager.py:1.13
--- libvob/vob/buoy/buoymanager.py:1.12 Wed May  7 08:00:42 2003
+++ libvob/vob/buoy/buoymanager.py      Tue May 13 07:48:22 2003
@@ -32,7 +32,19 @@
 vob.AbstractUpdateManager.defaultAnimationTime = 1500
 vob.AbstractUpdateManager.fractCalc = 
vob.AbstractUpdateManager.LinearCalculator(0)
 
-lineconn = GLRen.createLineConnector(.5, .5, .5, .5)
+# The connector is just a vob.
+lineconn = vob.vobs.SimpleConnection(.5, .5, .5, .5)
+lineconn.glsetup = GLCache.getCallList("""
+           PushAttrib ENABLE_BIT LINE_BIT
+           Disable TEXTURE_2D
+           LineWidth 5
+           Enable BLEND
+           Color 0 0 0 0.6
+       """)
+lineconn.glteardown = GLCache.getCallList("""
+           PopAttrib
+       """)
+
 #lineconn = GLRen.createSqFilletConnection(30, 1, .125, 6)
 
 size = jarray.zeros(2, 'f')
@@ -155,20 +167,9 @@
        otherAnchorCS = otherNode.renderBuoy(self.vs, into, linkId, 
otherAnchor, None)
        self.cs[into] = (otherNode, linkId, otherAnchor, into)
 
-       self.vs.map.put(GLCache.getCallList("""
-           PushAttrib ENABLE_BIT LINE_BIT
-           Disable TEXTURE_2D
-           LineWidth 5
-           Enable BLEND
-           Color 0 0 0 0.6
-       """))
-
        self.vs.map.put(lineconn, anchorUnit, 
                         self.vs.unitSqCS(otherAnchorCS, "UN"))
 
-       self.vs.map.put(GLCache.getCallList("""
-           PopAttrib
-       """))
 
         # Interpolation : old mainvp -> to new buoy
         if hasattr(self, "animationCS_main") and \




reply via email to

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