gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] libvob include/vob/jni/Types.hxx include/vob/vo...


From: Tuomas J. Lukka
Subject: [Gzz-commits] libvob include/vob/jni/Types.hxx include/vob/vo...
Date: Mon, 17 Mar 2003 07:48:19 -0500

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

Modified files:
        include/vob/jni: Types.hxx 
        include/vob/vobs: Text.hxx 
        org/nongnu/libvob/gl: GL.java GLRen.java 
        org/nongnu/libvob/impl/gl: GLTextStyle.java 
        org/nongnu/libvob/vobs: TextVob.java 
        src/jni        : Main.cxx Makefile Render.cxx 
Added files:
        src/jni        : Font.cxx 

Log message:
        Text seems to work

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/jni/Types.hxx.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Text.hxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/GL.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/GLRen.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/impl/gl/GLTextStyle.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/TextVob.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Font.cxx?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Main.cxx.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Makefile.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Render.cxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: libvob/include/vob/jni/Types.hxx
diff -u libvob/include/vob/jni/Types.hxx:1.16 
libvob/include/vob/jni/Types.hxx:1.17
--- libvob/include/vob/jni/Types.hxx:1.16       Sun Mar 16 12:58:49 2003
+++ libvob/include/vob/jni/Types.hxx    Mon Mar 17 07:48:19 2003
@@ -39,6 +39,7 @@
 
 namespace Vob {
 namespace JNI {
+    PREDBGVAR(dbg);
     PREDBGVAR(dbg_convert);
 
     /** The JNI parameter template class.
@@ -66,7 +67,17 @@
                unsigned short> 
            DefaultTextRenderer;
 
-    extern ObjectStorer<DefaultTextRenderer> textrenderers;
+    // XXX MEMLEAK
+    struct RealFont {
+       GLMosaicText::Font *f;
+       DefaultTextRenderer *rend;
+       RealFont(GLMosaicText::Font *f) : f(f) {
+          rend = new DefaultTextRenderer(f);
+       }
+       float getGlyphWidth(int c) { return rend->g.getGlyphWidth(c); }
+    };
+
+    extern ObjectStorer<RealFont> textrenderers;
 
 #define START_VOB_JNI_CONVERSION(type, javaName_, jnitype_)    \
     struct JParameter<type> {                                  \
@@ -163,7 +174,7 @@
 
     START_VOB_JNI_CONVERSION_IDDED(DefaultTextRenderer *, 
                "GL.Font")
-       out = textrenderers[in];
+       out = textrenderers[in]->rend;
     END_VOB_JNI_CONVERSION
 
 }
Index: libvob/include/vob/vobs/Text.hxx
diff -u libvob/include/vob/vobs/Text.hxx:1.1 
libvob/include/vob/vobs/Text.hxx:1.2
--- libvob/include/vob/vobs/Text.hxx:1.1        Sun Mar 16 12:58:49 2003
+++ libvob/include/vob/vobs/Text.hxx    Mon Mar 17 07:48:19 2003
@@ -21,10 +21,11 @@
     
     TextRenderer *rend;
     str text;
+    float yoffs;
     int flags;
 
     template<class F> void params(F &f) {
-       f(rend, text, flags);
+       f(rend, text, yoffs, flags);
     }
 
     template<class Coords> struct Vertexer {
@@ -46,7 +47,7 @@
        }
        Vertexer<T> vertexer(t);
        GLMosaicText::renderIter(*rend, text.begin(), text.end(), 
-               0,0,
+               0,yoffs,
                vertexer, (flags & 1 ? 
                        GLMosaicText::normalBindTexture_01 :
                        GLMosaicText::normalBindTexture)
Index: libvob/org/nongnu/libvob/gl/GL.java
diff -u libvob/org/nongnu/libvob/gl/GL.java:1.4 
libvob/org/nongnu/libvob/gl/GL.java:1.5
--- libvob/org/nongnu/libvob/gl/GL.java:1.4     Mon Mar 10 13:15:54 2003
+++ libvob/org/nongnu/libvob/gl/GL.java Mon Mar 17 07:48:19 2003
@@ -505,16 +505,24 @@
         */
        public void getWidths(float[] w) { putFontWidths(getId(), w); }
     }
+
+    static String defaultFontFile = 
"/usr/share/fonts/type1/gsfonts/n019004l.pfb";
+
     /** Create a new font.
      * @param name Filename to load the font from.
+     *                         null for default.
      * @param loadPt The pixel size to load the font at.
      */
     static public Font createFont(String name, int loadPt) {
-       return new Font(createFontImpl(name, loadPt));
+       return new Font(createFontImpl(
+                   name == null ? defaultFontFile : name, 
+                   loadPt));
     }
+    
+
+    static private native int createFontImpl(String filename, int loadPt);
     static private native float getFontHeight(int id);
     static private native float getFontYOffs(int id);
-    static private native int createFontImpl(String name, int loadPt);
     static private native void deleteFont(int id);
     static private native void putFontWidths(int id, float[] w);
 
Index: libvob/org/nongnu/libvob/gl/GLRen.java
diff -u libvob/org/nongnu/libvob/gl/GLRen.java:1.5 
libvob/org/nongnu/libvob/gl/GLRen.java:1.6
--- libvob/org/nongnu/libvob/gl/GLRen.java:1.5  Sun Mar 16 12:58:49 2003
+++ libvob/org/nongnu/libvob/gl/GLRen.java      Mon Mar 17 07:48:19 2003
@@ -105,14 +105,14 @@
 static public class Text1 extends GL.Renderable1JavaObject  { private 
Text1(int i) { super(i); }
 GL.Font p0;
 }
-static public Text1 createText1(GL.Font p0, String p1, int p2) { 
+static public Text1 createText1(GL.Font p0, String p1, float p2, int p3) { 
 Text1 _ = new Text1(
-implcreateText1(p0.getId(), p1, p2));
+implcreateText1(p0.getId(), p1, p2, p3));
 _.p0 = p0;
 
  return _; }
 
-static private native int implcreateText1(int p0, String p1, int p2) ; 
+static private native int implcreateText1(int p0, String p1, float p2, int p3) 
; 
 
 
 }
Index: libvob/org/nongnu/libvob/impl/gl/GLTextStyle.java
diff -u libvob/org/nongnu/libvob/impl/gl/GLTextStyle.java:1.2 
libvob/org/nongnu/libvob/impl/gl/GLTextStyle.java:1.3
--- libvob/org/nongnu/libvob/impl/gl/GLTextStyle.java:1.2       Fri Mar  7 
06:38:22 2003
+++ libvob/org/nongnu/libvob/impl/gl/GLTextStyle.java   Mon Mar 17 07:48:19 2003
@@ -37,7 +37,7 @@
  * it's much better to use GraphicsAPI.getTextStyle.
  */
 public class GLTextStyle extends TextStyle {
-public static final String rcsid = "$Id: GLTextStyle.java,v 1.2 2003/03/07 
11:38:22 tjl Exp $";
+public static final String rcsid = "$Id: GLTextStyle.java,v 1.3 2003/03/17 
12:48:19 tjl Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
@@ -52,7 +52,7 @@
        GLTextStyle s = instances[size];
        if(s == null) {
            if(theStaticFont == null)
-               theStaticFont = GL.createFont("gfx/fonts/a010013l.pfb", 64);
+               theStaticFont = GL.createFont(null, 64);
            theStaticFont.getWidths(charWidths);
            if(dbg) for(int i=0; i<256; i++) {
                pa("char '"+((char)i)+"': width "+charWidths[i]);
Index: libvob/org/nongnu/libvob/vobs/TextVob.java
diff -u libvob/org/nongnu/libvob/vobs/TextVob.java:1.1 
libvob/org/nongnu/libvob/vobs/TextVob.java:1.2
--- libvob/org/nongnu/libvob/vobs/TextVob.java:1.1      Sun Mar 16 10:55:05 2003
+++ libvob/org/nongnu/libvob/vobs/TextVob.java  Mon Mar 17 07:48:19 2003
@@ -52,7 +52,7 @@
  * XXX Diagram!
  */
 public class TextVob extends HBox.VobHBox {
-String rcsid = "$Id: TextVob.java,v 1.1 2003/03/16 15:55:05 benja Exp $";
+String rcsid = "$Id: TextVob.java,v 1.2 2003/03/17 12:48:19 tjl Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
@@ -156,13 +156,14 @@
 
     static private Vob start, stop;
     private Vob setColor;
-    /**
+
     static public Vob getStartCode() {
        if(start == null) {
            if (GL.hasExtension("GL_NV_register_combiners")) {
                start = GLCache.getCallList(
 "   PushAttrib ENABLE_BIT TEXTURE_BIT CURRENT_BIT  \n"+
 "   Enable REGISTER_COMBINERS_NV                       \n" +
+"   Enable BLEND                       \n" +
 "   CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1     \n" +
 "   CombinerParameterNV CONSTANT_COLOR0_NV 0 0 0 0.4   \n" +
 "   CombinerInputNV COMBINER0_NV ALPHA VARIABLE_A_NV TEXTURE0 
UNSIGNED_IDENTITY_NV ALPHA  \n" +
@@ -188,7 +189,7 @@
            stop = GLCache.getCallList("PopAttrib");
        }
        return stop;
-       } **/
+    } 
 
     private Vob setColor() {
        if(setColor == null) { 
@@ -204,17 +205,13 @@
      */
     private Vob ht;
     public int putGL(VobScene vs, int coordsys1) {
-       throw new Error("Cannot render TextVob in GL yet");
-       /*
        if(dbg) pa("Addtolistgl text "+text);
        if(ht == null) {
            GLTextStyle gls = (GLTextStyle)style;
-           ht = GLRen.createHorizText(
+           ht = GLRen.createText1(
                    gls.theFont,
                    text, 
-                   0,
                    (baselined ? 1 : gls.theFont.getYOffs()),
-                   0,
                    0);
        }
        vs.map.put(getStartCode());
@@ -222,7 +219,6 @@
        vs.map.put(ht, coordsys1);
        vs.map.put(getStopCode());
        return 0;
-       */
     }
 
 
Index: libvob/src/jni/Main.cxx
diff -u libvob/src/jni/Main.cxx:1.10 libvob/src/jni/Main.cxx:1.11
--- libvob/src/jni/Main.cxx:1.10        Mon Mar 17 05:44:25 2003
+++ libvob/src/jni/Main.cxx     Mon Mar 17 07:48:19 2003
@@ -52,7 +52,7 @@
 
 ObjectStorer<ByteVector> bytevectors("bytevectors");
 
-ObjectStorer<DefaultTextRenderer> textrenderers("Textrenderers");
+ObjectStorer<RealFont> textrenderers("Textrenderers");
 
 ObjectStorer<Os::RenderingSurface> windows("windows");
 Os::Window *defaultWindow; // A kludge
Index: libvob/src/jni/Makefile
diff -u libvob/src/jni/Makefile:1.14 libvob/src/jni/Makefile:1.15
--- libvob/src/jni/Makefile:1.14        Mon Mar 17 05:44:25 2003
+++ libvob/src/jni/Makefile     Mon Mar 17 07:48:19 2003
@@ -1,6 +1,6 @@
 include ../../rules.mk
 
-sources = Gen.cxx GLRen.gen.cxx Main.cxx Strings.cxx Transform.cxx Render.cxx
+sources = Gen.cxx GLRen.gen.cxx Main.cxx Strings.cxx Transform.cxx Render.cxx 
Font.cxx
 
 CALLGL=../../../callgl
 CALLGLOBJS=$(CALLGL)/src/glwrapper/GL_wrapper.o $(CALLGL)/src/callgl.o
@@ -16,7 +16,7 @@
 
 MAINOBJS=../main/Renderer.o
 
-JNIOBJS=GLRen.gen.o Main.o Strings.o Transform.o Render.o $(OSOBJS) 
$(TEXTUREOBJS) $(UTILOBJS) $(CALLGLOBJS) $(TRANSOBJS) $(MAINOBJS) 
$(GLMOSAICTEXTOBJS)
+JNIOBJS=GLRen.gen.o Main.o Strings.o Transform.o Render.o Font.o $(OSOBJS) 
$(TEXTUREOBJS) $(UTILOBJS) $(CALLGLOBJS) $(TRANSOBJS) $(MAINOBJS) 
$(GLMOSAICTEXTOBJS)
 
 
 EXTRAINCLUDE=-I${JAVAHOME}/include -I${JAVAHOME}/include/linux 
Index: libvob/src/jni/Render.cxx
diff -u libvob/src/jni/Render.cxx:1.1 libvob/src/jni/Render.cxx:1.2
--- libvob/src/jni/Render.cxx:1.1       Wed Mar 12 08:37:57 2003
+++ libvob/src/jni/Render.cxx   Mon Mar 17 07:48:19 2003
@@ -37,7 +37,7 @@
 using namespace Vob;
 using namespace Vob::JNI;
 using std::cout;
-STATICDBGVAR(dbg, "JNI.render");
+STATICDBGVAR(dbg_render, "JNI.render");
 
 namespace Vob {
 
@@ -55,39 +55,39 @@
        jintArray j_inds2, jfloatArray j_pts2, 
        jintArray j_codes,
        jfloat fract, jboolean standardcoords, jboolean showFinal) {
-       DBG(dbg) << "RENDER "<<window<<" "<<numinds<<" "
+       DBG(dbg_render) << "RENDER "<<window<<" "<<numinds<<" "
                <<j_inds1<<" "<<j_pts1<<" "<<
                j_interpinds<<" "<<j_inds2<<" "<<j_pts2<<" "<<j_codes<<"\n";
        GLERR
-       DBG(dbg) << "1\n";
+       DBG(dbg_render) << "1\n";
        if(standardcoords) 
           setWindow(window);
-       DBG(dbg) << "2\n";
+       DBG(dbg_render) << "2\n";
 
        if(sizeof(jint) != sizeof(jint) ||
         sizeof(jfloat) != sizeof(float))
          env->FatalError("Invalid data type sizes!");
-       DBG(dbg) << "3\n";
+       DBG(dbg_render) << "3\n";
 
       jint *inds1 = env->GetIntArrayElements(j_inds1, 0);
-       DBG(dbg) << "4\n";
+       DBG(dbg_render) << "4\n";
       jfloat *pts1 = env->GetFloatArrayElements(j_pts1, 0);
-       DBG(dbg) << "5\n";
+       DBG(dbg_render) << "5\n";
 
       jint *inds2 = 0;
       jfloat *pts2 = 0;
       jint *interpinds = 0;
       if(j_inds2 != 0) {
-          DBG(dbg) << "6\n";
+          DBG(dbg_render) << "6\n";
          inds2 = env->GetIntArrayElements(j_inds2, 0);
          pts2 = env->GetFloatArrayElements(j_pts2, 0);
          interpinds = env->GetIntArrayElements(j_interpinds, 0);
       }
-       DBG(dbg) << "7\n";
+       DBG(dbg_render) << "7\n";
 
       jint *codes = env->GetIntArrayElements(j_codes, 0);
 
-      DBG(dbg) << "Got data\n";
+      DBG(dbg_render) << "Got data\n";
 
       renderer.setPoints((int)numinds, 
                        (int *)inds1, (float *)pts1,
@@ -95,23 +95,23 @@
                        (int *)inds2, (float *)pts2,
                        (float)fract, (bool)showFinal);
 
-      DBG(dbg) << "Set datapoints\n";
+      DBG(dbg_render) << "Set datapoints\n";
 
       if(standardcoords) {
          int xywh[4];
          windows.get(window)->getSize(xywh);
-         DBG(dbg) << "Did getSize "<<xywh[0]<<" "<<xywh[1]<<" "<<xywh[2]<<" "
+         DBG(dbg_render) << "Did getSize "<<xywh[0]<<" "<<xywh[1]<<" 
"<<xywh[2]<<" "
                    <<xywh[3]<<"\n";
 
          Renderer::setStandardCoordinates(Vec(xywh[2], xywh[3]));
       }
        GLERR
 
-      DBG(dbg) << "Did stdcoords\n";
+      DBG(dbg_render) << "Did stdcoords\n";
       renderer.renderScene((int *)codes, vob0s, vob1s, vob2s, vob3s);
-      DBG(dbg) << "Did renderscene\n";
+      DBG(dbg_render) << "Did renderscene\n";
       windows.get(window)->swapBuffers();
-      DBG(dbg) << "Did swapbuffers\n";
+      DBG(dbg_render) << "Did swapbuffers\n";
 
       env->ReleaseIntArrayElements(j_codes, codes, JNI_ABORT);
 
@@ -123,7 +123,7 @@
        env->ReleaseFloatArrayElements(j_pts2, pts2, JNI_ABORT);
         env->ReleaseIntArrayElements(j_interpinds, interpinds, JNI_ABORT);
       }
-      DBG(dbg) << "Did releasearrays\n";
+      DBG(dbg_render) << "Did releasearrays\n";
        GLERR
 
       if(standardcoords) {




reply via email to

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