gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx libmosaic/Mosaic.hxx librenderables/Ren...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz/gfx libmosaic/Mosaic.hxx librenderables/Ren...
Date: Sat, 25 Jan 2003 06:03:21 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        03/01/25 06:03:21

Modified files:
        gfx/libmosaic  : Mosaic.hxx 
        gfx/librenderables: Renderables.cxx Renderables.hxx 
                            renderables.py 
        gfx/libtext    : Text.hxx 
        gfx/util       : demokeys.py 

Log message:
        Make text bindable to two texunits, and motion-sensitive vobs

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libmosaic/Mosaic.hxx.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/Renderables.cxx.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/Renderables.hxx.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.170&tr2=1.171&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtext/Text.hxx.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/util/demokeys.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: gzz/gfx/libmosaic/Mosaic.hxx
diff -u gzz/gfx/libmosaic/Mosaic.hxx:1.12 gzz/gfx/libmosaic/Mosaic.hxx:1.13
--- gzz/gfx/libmosaic/Mosaic.hxx:1.12   Thu Dec 19 08:23:58 2002
+++ gzz/gfx/libmosaic/Mosaic.hxx        Sat Jan 25 06:03:21 2003
@@ -78,11 +78,11 @@
        void free() ;
        /** Cause OpenGL to bind this texture.
         */
-       void bind(GLenum target = GL_TEXTURE_2D) {
+       void bind(GLenum target = GL_TEXTURE_2D) const {
            if(!id) throw InvalidTexture();
            glBindTexture(target, id);
        }
-       void unbind(GLenum target = GL_TEXTURE_2D) {
+       void unbind(GLenum target = GL_TEXTURE_2D) const {
            glBindTexture(target, 0);
        }
        /** Compare two Ids -- usual semantics.
Index: gzz/gfx/librenderables/Renderables.cxx
diff -u gzz/gfx/librenderables/Renderables.cxx:1.13 
gzz/gfx/librenderables/Renderables.cxx:1.14
--- gzz/gfx/librenderables/Renderables.cxx:1.13 Mon Jan 20 03:30:55 2003
+++ gzz/gfx/librenderables/Renderables.cxx      Sat Jan 25 06:03:21 2003
@@ -13,6 +13,8 @@
 
 namespace Renderables {
 
+    bool sceneMoving = false;
+
     const ZPt unitsquare[4] = {
        ZPt( 0, 0, 0 ),
        ZPt( 1, 0, 0 ),
Index: gzz/gfx/librenderables/Renderables.hxx
diff -u gzz/gfx/librenderables/Renderables.hxx:1.28 
gzz/gfx/librenderables/Renderables.hxx:1.29
--- gzz/gfx/librenderables/Renderables.hxx:1.28 Mon Jan 20 03:30:55 2003
+++ gzz/gfx/librenderables/Renderables.hxx      Sat Jan 25 06:03:21 2003
@@ -148,6 +148,8 @@
 
     using std::vector;
 
+    extern bool sceneMoving;
+
     class Renderer {
        Coords::CoordSet coordset;
     public:
@@ -158,11 +160,13 @@
                                 int *inds2, float *points2, 
                                 float fract, bool show1) {
            coordset.clean();
+           sceneMoving = (interpinds != 0);
            coordset.setPoints(ninds, inds1, points1, interpinds, inds2, 
points2, fract, show1);
        }
 
        void setPoints( int ninds, int *inds1, float *points1) {
            coordset.clean();
+           sceneMoving = false;
            coordset.setPoints(ninds, inds1, points1, 0, 0, 0, 0, true);
        }
        void renderScene(int *codes, 
Index: gzz/gfx/librenderables/renderables.py
diff -u gzz/gfx/librenderables/renderables.py:1.170 
gzz/gfx/librenderables/renderables.py:1.171
--- gzz/gfx/librenderables/renderables.py:1.170 Mon Jan 20 03:30:55 2003
+++ gzz/gfx/librenderables/renderables.py       Sat Jan 25 06:03:21 2003
@@ -137,6 +137,26 @@
 },
 
 {
+    "Type" : "0",
+    "Name" : "MotionCallList",
+    "Data" : "int noStill, noMotion;",
+    "Params" : "DisplayList still, DisplayList motion",
+    # XXX Should store DisplayList
+    "ParamCode" : """
+                   this->noStill = still;
+                   this->noMotion = motion;
+               """,
+    "RenderCode" : """
+           DBG(dbg) << "MotionCallList "<<sceneMoving<<"\\n";
+           if(sceneMoving)
+               glCallList(noMotion);
+           else
+               glCallList(noStill);
+           GLERR
+           """,
+},
+
+{
     "Type": "1",
     "Name" : "CallListCoorded",
     "Data" : "int no;",
@@ -1981,7 +2001,7 @@
                 
                Text::renderIter(*r_date, buffer, buffer+strlen(buffer), 
                      -shifts[0], shifts[0],
-                     v_date
+                     v_date, Text::normalBindTexture
                );
 
                 // use red for sundays..
@@ -1990,7 +2010,7 @@
 
                Text::renderIter(*r_date, buffer, buffer+strlen(buffer),
                     -shifts[0] + 0.03, shifts[0] + 0.03,
-                    v_date
+                    v_date, Text::normalBindTexture
                );
 
             }
@@ -2011,7 +2031,7 @@
 
                Text::renderIter(*r, buffer, buffer+strlen(buffer), 
                     0.1, shifts[1],
-                    v_week_num
+                    v_week_num, Text::normalBindTexture
                );
             
             }
@@ -2029,7 +2049,7 @@
             
                Text::renderIter(*r, d_txt[i].begin(), d_txt[i].end(), 
                     0, shifts[2],
-                    v_weekday
+                    v_weekday, Text::normalBindTexture
                );
             }
 
@@ -2044,7 +2064,7 @@
 
             Text::renderIter(*r, m_txt.begin(), m_txt.end(), 
                 shifts[3], 0,
-                v_month
+                v_month, Text::normalBindTexture
             );
             
            glPopAttrib();
@@ -2061,28 +2081,25 @@
        TextRenderer *r;
        unicodecharvector txt;
        ZPt origin;
-       float heightmul;
-       float widthmul;
+       int flags;
        """,
     "Params" : """
        Font f,
        String text, float x, float y, float z,
-       float widthmul,
-       float heightmul
+       int flags
        """,
     "ParamCode" : """
        r = f;
        txt = text; origin.x = x; origin.y = y; origin.z = z;
-       this->heightmul = heightmul; this->widthmul = widthmul;
+       this->flags = flags;
        """,
     "ExtraClass" : """
        template<class Coords> struct Vertexer {
            const Coords &c;
-           float wmul, hmul;
             ZPt origin;
-           Vertexer(Coords &c, float wmul, float hmul, ZPt origin) : c(c), 
wmul(wmul), hmul(hmul), origin(origin) { }
+           Vertexer(Coords &c, ZPt origin) : c(c), origin(origin) { }
            template<class T> void operator()(const T &x, const T &y) {
-               ZVec tmp(x * wmul, y * hmul, 0);
+               ZVec tmp(x, y, 0);
                c.vertex(origin + tmp);
            }
        };
@@ -2094,12 +2111,14 @@
                     cout << "'" << (char)*it << "' (" << (int)*it << ")\\n";
             }
     
-           Vertexer<Coords> v(coords1, widthmul, heightmul, origin);
+           Vertexer<Coords> v(coords1, origin);
            glPushAttrib(GL_ENABLE_BIT);
            glEnable(GL_BLEND);
            Text::renderIter(*r, txt.begin(), txt.end(), 
                    0,0,
-                   v
+                   v, (flags & 1 ? 
+                           Text::normalBindTexture_01 :
+                           Text::normalBindTexture)
                    );
            glPopAttrib();
             if (dbg) cout << "HorizText done\\n";
@@ -2161,7 +2180,7 @@
            case 0: 
                Text::renderIter(*r, txt.begin(), txt.end(), 
                        0, y,
-                       v
+                       v, Text::normalBindTexture
                        );
                break;
            case 1: /* Show fps. */
@@ -2171,7 +2190,7 @@
                sprintf(buffer, "FPS %2.2f / %2.2f", fps5, fps);
                Text::renderIter(*r, buffer, buffer+strlen(buffer), 
                        0, y,
-                       v
+                       v, Text::normalBindTexture
                        );
                break;
            }
@@ -2226,7 +2245,7 @@
            glEnable(GL_BLEND);
            Text::renderIter(*r, txt.begin(), txt.end(), 
                    0,0,
-                   v
+                   v, Text::normalBindTexture
                    );
            glPopAttrib();
                            
@@ -2490,6 +2509,10 @@
 
     public static gzz.vob.Vob createCallList(String s) {
        return createCallList(createDisplayList(s));
+    }
+    public static gzz.vob.Vob createMotionCallList(String still, String 
motion) {
+       return createMotionCallList(createDisplayList(still),
+                                   createDisplayList(motion));
     }
     public static gzz.vob.Vob createCallListCoorded(String s) {
        return createCallListCoorded(createDisplayList(s));
Index: gzz/gfx/libtext/Text.hxx
diff -u gzz/gfx/libtext/Text.hxx:1.11 gzz/gfx/libtext/Text.hxx:1.12
--- gzz/gfx/libtext/Text.hxx:1.11       Tue Oct  8 03:30:12 2002
+++ gzz/gfx/libtext/Text.hxx    Sat Jan 25 06:03:21 2003
@@ -1,3 +1,5 @@
+#include <functional>
+
 #include <freetype/freetype.h>
 
 #include <libmosaic/Mosaic.hxx>
@@ -245,6 +247,17 @@
        }
     };
 
+    inline void normalBindTexture(const Mosaic::Id &t) {
+       t.bind(GL_TEXTURE_2D);
+    }
+
+    inline void normalBindTexture_01(const Mosaic::Id &t) {
+       glActiveTextureARB(GL_TEXTURE1);
+       t.bind();
+       glActiveTextureARB(GL_TEXTURE0);
+       t.bind();
+    }
+
     template<class Glyphs, class Char> class Renderer {
        Mosaic::Id curtex;
     public:
@@ -263,13 +276,15 @@
        /** Render a single character.
         * @return New x position.
         */
-       template<class Vertex> float renderChar(Char c, float x, float y, 
Vertex &vertex) 
+       template<class Vertex, class TexBind> 
+               float renderChar(Char c, float x, float y, Vertex &vertex,
+                                   const TexBind &t) 
        { // returns new x pos
            QuadGlyph &glyph = g[(unsigned)c];
            if(!glyph.valid()) return x;
            if(glyph.rect.tex != curtex) {
                glEnd();
-               glyph.rect.tex.bind();
+               t(glyph.rect.tex);
                glBegin(GL_QUADS);
            }
            glyph.draw(x, y, vertex);
@@ -288,15 +303,15 @@
      * in order to allow nonlinear transforms of vertices,
      * all vertex commands are routed through the Vertex object.
      */
-    template<class Iterator, class RandomRenderer, class Vertex> 
+    template<class Iterator, class RandomRenderer, class Vertex, class 
TexBind> 
        float renderIter(
                RandomRenderer &r, 
                Iterator begin, Iterator end, 
                float x, float y,
-               Vertex &vertex) {
+               Vertex &vertex, const TexBind &t) {
        r.startRendering();
        while(begin != end) {
-           x = r.renderChar(*begin, x, y, vertex);
+           x = r.renderChar(*begin, x, y, vertex, t);
            begin++;
        }
        r.endRendering();
Index: gzz/gfx/util/demokeys.py
diff -u gzz/gfx/util/demokeys.py:1.5 gzz/gfx/util/demokeys.py:1.6
--- gzz/gfx/util/demokeys.py:1.5        Mon Dec 23 05:34:51 2002
+++ gzz/gfx/util/demokeys.py    Sat Jan 25 06:03:21 2003
@@ -50,16 +50,17 @@
            self.keys = [
                (k[0], _NoAnimation(k[1])) for k in self.keys]
     def getKeys(self):
-       return [k for k in self.keys if not isinstance(k[0], somere.__class__)]
+       return [k for k in self.keys if k[0] != None and not isinstance(k[0], 
somere.__class__)]
            
     def getREs(self):
        """Get the regular expressions this object
        wants to catch.
        """
-       return [k for k in self.keys if isinstance(k[0], somere.__class__)]
+       return [k for k in self.keys if k[0] != None and isinstance(k[0], 
somere.__class__)]
     def keyStrings(self):
        list = []
        for k in self.keys:
+           if k[0] == None: continue
            if isinstance(k[0], somere.__class__):
                list.append(k[0].pattern)
            else:




reply via email to

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