2003/10/16 05:39:20
authorbrian <brian@xwt.org>
Fri, 30 Jan 2004 07:39:22 +0000 (07:39 +0000)
committerbrian <brian@xwt.org>
Fri, 30 Jan 2004 07:39:22 +0000 (07:39 +0000)
darcs-hash:20040130073922-aa32f-35006afe917a7e568875735055c78ca1fde74765.gz

src/org/xwt/Platform.java
src/org/xwt/plat/Darwin.cc
src/org/xwt/plat/Darwin.java
src/org/xwt/plat/OpenGL.cc
src/org/xwt/plat/OpenGL.java
src/org/xwt/translators/Freetype.java

index 0ca55b9..aa8be35 100644 (file)
@@ -124,7 +124,14 @@ public class Platform {
     
     /** creates and returns a picture */
     public static Picture createPicture(int[] data, int w, int h) { return platform._createPicture(data, w, h); }
+    public static Picture createAlphaOnlyPicture(byte[] data, int w, int h) { return platform._createAlphaOnlyPicture(data, w, h); }
+    
     protected Picture _createPicture(int[] b, int w, int h) { return null; }
+    protected Picture _createAlphaOnlyPicture(byte[] b, int w, int h) {
+        int[] b2 = new int[b.length];
+        for(int i=0;i<b.length;i++) b2[i] = (b[i]&0xff) << 24;
+        return _createPicture(b2,w,h);
+    }
 
     /** creates a socket object */
     public static Socket getSocket(String host, int port, boolean ssl, boolean negotiate) throws IOException {
index 7f4d2f3..fc05588 100644 (file)
@@ -57,8 +57,8 @@ static void* dlsym(char* symbol) {
                                                                  NSLOOKUPSYMBOLINIMAGE_OPTION_BIND));
   if (ret == NULL) ret = NSAddressOfSymbol(NSLookupSymbolInImage(SCHandle, symbol,
                                                                  NSLOOKUPSYMBOLINIMAGE_OPTION_BIND));
-  printf("linking symbol %s to address %x\n", symbol, ret);
-  fflush(stdout);
+  /*printf("linking symbol %s to address %x\n", symbol, ret);
+  fflush(stdout);*/
   return ret;
 }
 
@@ -714,8 +714,9 @@ void Darwin$CarbonSurface::natInit(jboolean framed) {
     WindowAttributes attr =  kWindowStandardHandlerAttribute|
       (framed ? kWindowInWindowMenuAttribute|kWindowStandardDocumentAttributes|kWindowLiveResizeAttribute : 0);
     OSStatus r;
-    rect.top = 0; rect.left = 0; rect.bottom = 300; rect.right=300;
-    winWidth = winHeight = 300;
+    rect.top = rect.left = 0;
+    rect.bottom = rect.right = 10;
+    winWidth = winHeight = 10;
     
     r = WC(CreateNewWindow)(wc, attr, &rect, &window);
     checkStatus(r,"CreateNewWindow");
@@ -1198,7 +1199,7 @@ void Darwin$GLCarbonSurface::natBlit(Darwin$GLCarbonPixelBuffer *db, jint sx1, j
     db->activateContext();
     glFlush();
     checkGLError();
-    
+
     WC(aglSetCurrentContext)(ctx);
     checkGLError();
         
index 8da005c..a3e4141 100644 (file)
@@ -275,6 +275,7 @@ public class Darwin extends POSIX {
         private native void reshape(int w, int h);
         // blit_lock is assumed to be held
         public void needsReshape() { needsReshape = true; }
+
         public native void natDispose();
     }
 
@@ -321,6 +322,12 @@ public class Darwin extends POSIX {
         else
             return /*new QZCarbonPicture(data,w,h);*/ null;
     }
+    protected Picture _createAlphaOnlyPicture(byte[] data, int w, int h) {
+        if(openGL != null)
+            return openGL.createAlphaOnlyPicture(data,w,h);
+        else
+            return super.createAlphaOnlyPicture(data,w,h);
+    }
     
     /* A message that is sent through the carbon event queue */
     private static abstract class CarbonMessage {
index 71870c7..5540c2d 100644 (file)
@@ -126,20 +126,26 @@ void OpenGL$GLPixelBuffer::resetClip() {
     }    
 }
 
-void OpenGL$RectGLPicture::natInit(JArray<jint> *data_) {
+// FEATURE: Eliminate duplicate code in RectGLPicture and SquareGLPicture
+void OpenGL$RectGLPicture::natInit(Object *data_, jboolean alphaOnly) {
     unsigned char *buf;
     int i,j;
     int size = width*height;
-    jint *data = elements(data_);
-    buf = new unsigned char[size*4];
     GLuint tex;
 
-    for(i=0,j=0;i<size;i++,j+=4) {
-        jint pixel = data[i];
-        buf[j+0] = (pixel >> 16) & 0xff;
-        buf[j+1] = (pixel >>  8) & 0xff;
-        buf[j+2] = (pixel >>  0) & 0xff;
-        buf[j+3] = (pixel >> 24) & 0xff;
+    if(alphaOnly) {
+        jbyte *data = elements((JArray<jbyte> *)data_);
+        buf = (unsigned char *) data;
+    } else {
+        jint *data = elements((JArray<jint> *)data_);
+        buf = new unsigned char[size*4];
+        for(i=0,j=0;i<size;i++,j+=4) {
+            jint pixel = data[i];
+            buf[j+0] = (pixel >> 16) & 0xff;
+            buf[j+1] = (pixel >>  8) & 0xff;
+            buf[j+2] = (pixel >>  0) & 0xff;
+            buf[j+3] = (pixel >> 24) & 0xff;
+        }
     }
     
     gl->activateSharedContext();
@@ -147,18 +153,23 @@ void OpenGL$RectGLPicture::natInit(JArray<jint> *data_) {
     glGenTextures(1,&tex);
     glBindTexture(GL_TEXTURE_RECTANGLE_EXT,tex);
     glPixelStorei(GL_PACK_ALIGNMENT,1);
-    glTexImage2D(GL_TEXTURE_RECTANGLE_EXT,0,4,width,height,0,GL_RGBA,GL_UNSIGNED_BYTE,buf);
-    delete buf;
+    glTexImage2D(
+        GL_TEXTURE_RECTANGLE_EXT,0,
+        alphaOnly ? GL_ALPHA : GL_RGBA,width,height,0,
+        alphaOnly ? GL_ALPHA : GL_RGBA,GL_UNSIGNED_BYTE,buf);
+    if(!alphaOnly)
+        delete buf;
 
-    // FIXME: enable linear filtering for opengl 1.2
-    glTexParameteri(GL_TEXTURE_RECTANGLE_EXT,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
-    glTexParameteri(GL_TEXTURE_RECTANGLE_EXT,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
+    if(gl->glVersion >= 1.2) {
+        glTexParameteri(GL_TEXTURE_RECTANGLE_EXT,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
+        glTexParameteri(GL_TEXTURE_RECTANGLE_EXT,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
+        glTexParameterf(GL_TEXTURE_RECTANGLE_EXT,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        glTexParameterf(GL_TEXTURE_RECTANGLE_EXT,GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    } else {
+        glTexParameteri(GL_TEXTURE_RECTANGLE_EXT,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
+        glTexParameteri(GL_TEXTURE_RECTANGLE_EXT,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
+    }
     
-    /*glTexParameteri(GL_TEXTURE_RECTANGLE_EXT,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
-    glTexParameteri(GL_TEXTURE_RECTANGLE_EXT,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
-    glTexParameterf(GL_TEXTURE_RECTANGLE_EXT,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    glTexParameterf(GL_TEXTURE_RECTANGLE_EXT,GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);*/
-
     glDisable(GL_TEXTURE_RECTANGLE_EXT);
     checkGLError();
   
@@ -166,8 +177,6 @@ void OpenGL$RectGLPicture::natInit(JArray<jint> *data_) {
 }
 
 void OpenGL$RectGLPicture::draw(jint dx1, jint dy1, jint dx2, jint dy2,jint sx1, jint sy1, jint sx2, jint sy2) { 
-    if (gl->hasRectangularTextures()) {
-       glColor4f(1.0f,1.0f,1.0f,1.0f);
        glEnable(GL_TEXTURE_RECTANGLE_EXT);
        glBindTexture(GL_TEXTURE_RECTANGLE_EXT, textureName);    
        glBegin(GL_QUADS); 
@@ -182,30 +191,6 @@ void OpenGL$RectGLPicture::draw(jint dx1, jint dy1, jint dx2, jint dy2,jint sx1,
        glEnd();
        glDisable(GL_TEXTURE_RECTANGLE_EXT);
        checkGLError();
-    } else {
-        float tx1,ty1,tx2,ty2; // normalized texture coords
-        tx1 = (float) sx1 / (float) width;
-        ty1 = (float) sy1 / (float) height;
-        tx2 = (float) sx2 / (float) width;
-        ty2 = (float) sy2 / (float) height;
-
-        glColor4f(1.0f,1.0f,1.0f,1.0f);
-        glEnable(GL_TEXTURE_2D);
-        glBindTexture(GL_TEXTURE_2D, textureName);    
-        checkGLError();
-        glBegin(GL_QUADS); 
-            glTexCoord2f (tx1, ty1   );
-            glVertex3i   (dx1, dy1, 0);
-            glTexCoord2f (tx2, ty1   ); 
-            glVertex3i   (dx2, dy1, 0);
-            glTexCoord2f (tx2, ty2   ); 
-            glVertex3i   (dx2, dy2, 0);
-            glTexCoord2f (tx1, ty2   );
-            glVertex3i   (dx1, dy2, 0);
-        glEnd();
-        glDisable(GL_TEXTURE_2D);
-        checkGLError();
-    }
 }
 
 void OpenGL::natDeleteTexture(jint tex_) {
@@ -214,45 +199,67 @@ void OpenGL::natDeleteTexture(jint tex_) {
     glDeleteTextures(1,&tex);
 }
 
-void OpenGL$SquareGLPicture::natInit(JArray<jint> *data_) {
+void OpenGL$SquareGLPicture::natInit(Object *data_, jboolean alphaOnly) {
     unsigned char *buf;
     int row,col,p;
-    jint *data = elements(data_);
-    buf = new unsigned char[texWidth*texHeight*4];
     GLuint tex;
 
-    p=0;
-    for(row=0;row<height;row++) {
-        for(col=0;col<width;col++) {
-            jint pixel = data[row*width+col];
-            buf[p+0] = (pixel >> 16) & 0xff;
-            buf[p+1] = (pixel >>  8) & 0xff;
-            buf[p+2] = (pixel >>  0) & 0xff;
-            buf[p+3] = (pixel >> 24) & 0xff;
-            p+=4;
+    if(alphaOnly) {
+        jbyte *data = elements((JArray<jbyte>*) data_);
+        if(texWidth == width && texHeight == height) {
+            buf = (unsigned char*) data;
+        } else {
+            buf = new unsigned char[texWidth*texHeight];
+            p=0;
+            for(row=0;row<height;row++) {
+                for(col=0;col<width;col++)
+                    buf[p++] = data[row*width+col];
+                for(;col<texWidth;col++)
+                    buf[p++] = 0;
+            }
+            for(;row<texHeight;row++)
+                for(col=0;col<texWidth;col++)
+                    buf[p++] = 0;
+        }
+    } else {
+        jint *data = elements((JArray<jint>*) data_);
+        buf = new unsigned char[texWidth*texHeight*4];
+        p=0;
+        for(row=0;row<height;row++) {
+            for(col=0;col<width;col++) {
+                jint pixel = data[row*width+col];
+                buf[p+0] = (pixel >> 16) & 0xff;
+                buf[p+1] = (pixel >>  8) & 0xff;
+                buf[p+2] = (pixel >>  0) & 0xff;
+                buf[p+3] = (pixel >> 24) & 0xff;
+                p+=4;
+            }
+            for(;col < texWidth;col++,p+=4)
+                buf[p+0] = buf[p+1] = buf[p+2] = buf[p+3] = 0;
         }
-        for(;col < texWidth;col++,p+=4)
-            buf[p+0] = buf[p+1] = buf[p+2] = buf[p+3] = 0;
+        for(;row < texHeight;row++) 
+            for(col=0;col<texWidth;col++,p+=4)
+                buf[p+0] = buf[p+1] = buf[p+2] = buf[p+3] = 0;
     }
-    for(;row < texHeight;row++) 
-        for(col=0;col<texWidth;col++,p+=4)
-            buf[p+0] = buf[p+1] = buf[p+2] = buf[p+3] = 0;
     
     gl->activateSharedContext();
     glEnable(GL_TEXTURE_2D);
     glGenTextures(1,&tex);
     glBindTexture(GL_TEXTURE_2D,tex);
     glPixelStorei(GL_PACK_ALIGNMENT,1);
-    glTexImage2D(GL_TEXTURE_2D,0,4,texWidth,texHeight,0,GL_RGBA,GL_UNSIGNED_BYTE,buf);
+    glTexImage2D(GL_TEXTURE_2D,0,alphaOnly ? GL_ALPHA : GL_RGBA,texWidth,texHeight,0,alphaOnly ? GL_ALPHA : GL_RGBA,GL_UNSIGNED_BYTE,buf);
     checkGLError();    
-    delete buf;
+    if(!alphaOnly || width != texWidth || height != texHeight) delete buf;
 
-    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
-    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
-    /*glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
-    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
-    glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);*/
+    if(gl->glVersion >= 1.2) {
+        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
+        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
+        glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    } else {
+        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
+        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
+    }
 
     glDisable(GL_TEXTURE_2D);
     checkGLError();
@@ -267,7 +274,6 @@ void OpenGL$SquareGLPicture::draw(jint dx1, jint dy1, jint dx2, jint dy2,jint sx
     tx2 = (float) sx2 / (float) texWidth;
     ty2 = (float) sy2 / (float) texHeight;
 
-    glColor4f(1.0f,1.0f,1.0f,1.0f);
     glEnable(GL_TEXTURE_2D);
     glBindTexture(GL_TEXTURE_2D, textureName);    
     checkGLError();
index 5367cb6..284fb62 100644 (file)
@@ -11,6 +11,7 @@ abstract class OpenGL {
     boolean hasRectangularTextures() { return rectangularTextures; }
     int maxTexSize;
     int maxRectTexSize;
+    float glVersion;
     String version;
     String renderer;
     String vendor;
@@ -26,13 +27,12 @@ abstract class OpenGL {
             return 1.1f; // just a guess
         }
     }
+    
     // This MUST be called after OpenGL is instansiated (and activateSharedContext is functioning)
     public void init() throws NotSupportedException {
         natInit();
-        float v = parseVersion(version);
-        // FEATURE: enable linear filtering for OpenGL >= 1.2
-        // If we disable linear filtering (and therefor GL_CLAMP_TO_EDGE) we could probably get by with less
-        if(v < 1.1) throw new NotSupportedException("OpenGL 1.1 or greater is required. (you have: " + version +" - " + v + ")");
+        glVersion = parseVersion(version);
+        if(glVersion < 1.1) throw new NotSupportedException("OpenGL 1.1 or greater is required. (you have: " + version +" - " + glVersion + ")");
         if(pretendToBeACrappyVideoCard) {
             maxTexSize = 512;
             maxRectTexSize = 0;
@@ -82,16 +82,16 @@ abstract class OpenGL {
         
         //public native void drawPictureAlphaOnly(Picture source, int dx1, int dy1, int dx2, int dy2,
         //int sx1, int sy1, int sx2, int sy2, int rgb);
-        public void drawPictureAlphaOnly(Picture source, int dx1, int dy1, int dx2, int dy2,
-            int sx1, int sy1, int sx2, int sy2, int rgb) { }
-
-        public void drawPicture(org.xwt.Picture source, int x, int y) {
-            activateContext();
-            GLPicture p = (GLPicture) source;
-            p.draw(x,y);
+        public void drawPictureAlphaOnly(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, int rgb) {
+            drawPicture_(source,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,rgb);
+        }
+        public void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2,int sx1, int sy1, int sx2, int sy2) {
+            drawPicture_(source,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,0xffffffff);
         }
-        public void drawPicture(org.xwt.Picture source, int dx1, int dy1, int dx2, int dy2,int sx1, int sy1, int sx2, int sy2) {
+
+        private void drawPicture_(Picture source, int dx1, int dy1, int dx2, int dy2,int sx1, int sy1, int sx2, int sy2, int color) {
             activateContext();
+            setColor(color);
             GLPicture p = (GLPicture) source;
             p.draw(dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2);
         }
@@ -103,10 +103,19 @@ abstract class OpenGL {
         return 0;
     }
         
+    private Picture _createPicture(Object data, int w, int h, boolean alphaOnly) {
+        if(rectangularTextures && w <= maxRectTexSize && h <= maxRectTexSize) new RectGLPicture(data,w,h,alphaOnly,this);
+        if(w <= maxTexSize && h <= maxTexSize) return new SquareGLPicture(data,w,h,alphaOnly,this);
+        return new MosaicGLPicture(data,w,h,alphaOnly,this);
+    }
+    
     public Picture createPicture(int[] data, int w, int h) {
-        if(rectangularTextures && w <= maxRectTexSize && h <= maxRectTexSize) new RectGLPicture(data,w,h,this);
-        if(w <= maxTexSize && h <= maxTexSize) return new SquareGLPicture(data,w,h,this);
-        return new MosaicGLPicture(data,w,h,this);
+        if(w*h > data.length) throw new Error("should never happen");
+        return _createPicture(data,w,h,false);
+    }
+    public Picture createAlphaOnlyPicture(byte[] data, int w, int h) {
+        if(w*h > data.length) throw new Error("should never happen");
+        return _createPicture(data,w,h,true);
     }
     
     private native void natDeleteTexture(int tex);
@@ -130,7 +139,6 @@ abstract class OpenGL {
             this.height = h;
         }
         
-        public void draw(int x, int y) { draw(x,y,x+width,y+height,0,0,width,height); }
         public abstract void draw(int dx1, int dy1, int dx2, int dy2,int sx1, int sy1, int sx2, int sy2);
         protected abstract void finalize();
     }
@@ -139,12 +147,12 @@ abstract class OpenGL {
         private OpenGL gl;
         public int textureName;
                 
-        public native void natInit(int[] data);
+        public native void natInit(Object data, boolean alphaOnly);
         
-        public RectGLPicture(int[] data,int w, int h, OpenGL gl) {
+        public RectGLPicture(Object data,int w, int h, boolean alphaOnly, OpenGL gl) {
             super(w,h);
             this.gl = gl;
-            natInit(data);
+            natInit(data,alphaOnly);
         }
     
         public native void draw(int dx1, int dy1, int dx2, int dy2,int sx1, int sy1, int sx2, int sy2);  
@@ -157,15 +165,15 @@ abstract class OpenGL {
         private OpenGL gl;
         public int textureName;
                 
-        public native void natInit(int[] data);
+        public native void natInit(Object data, boolean alphaOnly);
                 
-        public SquareGLPicture(int[] data,int w, int h, OpenGL gl) {
+        public SquareGLPicture(Object data,int w, int h, boolean alphaOnly, OpenGL gl) {
             super(w,h);
             this.gl = gl;
             if(w > 0x7fffffff || h > 0x7fffffff) throw new Error("insane texture size: " + w + "x" + h);
             texHeight = roundToPowerOf2(h);
             texWidth = roundToPowerOf2(w);
-            natInit(data);
+            natInit(data,alphaOnly);
         }
         
         public native void draw(int dx1, int dy1, int dx2, int dy2,int sx1, int sy1, int sx2, int sy2); 
@@ -184,21 +192,31 @@ abstract class OpenGL {
             return 1.0f-(float)(w*h)/(float)(w2*h2);
         }
         
+        private static Object subData(Object data, int x, int y, int w, int h, int rowSize) {
+            if(data instanceof byte[]) return subData((byte[])data,x,y,w,h,rowSize);
+            if(data instanceof int[]) return subData((int[])data,x,y,w,h,rowSize);
+            throw new Error("not reached");
+        }
+        
         private static int[] subData(int[] data, int x, int y, int w, int h, int rowSize) {
             int[] sub = new int[w*h];
             int row = y;
-            try {
             for(int i=0;i<h;i++,row++)
                 for(int j=0;j<w;j++)
                     sub[i*w+j] = data[row*rowSize+j+x];
-            } catch(ArrayIndexOutOfBoundsException e) {
-                Log.log(MosaicGLPicture.class,"subData(data("+data.length+"),"+x+","+y+","+w+","+h+","+rowSize);
-                throw e;
-            }
             return sub;
         }
         
-        public MosaicGLPicture(int[] data,int w, int h, OpenGL gl) {
+        private static byte[] subData(byte[] data, int x, int y, int w, int h, int rowSize) {
+            byte[] sub = new byte[w*h];
+            int row = y;
+            for(int i=0;i<h;i++,row++)
+                for(int j=0;j<w;j++)
+                    sub[i*w+j] = data[row*rowSize+j+x];
+            return sub;
+        }
+        
+        public MosaicGLPicture(Object data,int w, int h, boolean alphaOnly, OpenGL gl) {
             super(w,h);
             psize = gl.maxTexSize;
             while(wastedSpace(w,h,psize) > 0.40) psize/=2;
@@ -211,14 +229,14 @@ abstract class OpenGL {
             pics = new GLPicture[rows][cols];
             for(int i=0;i<rows-1;i++)
                 for(int j=0;j<cols-1;j++)
-                    pics[i][j] = new SquareGLPicture(subData(data,j*psize,i*psize,psize,psize,w),psize,psize,gl);
+                    pics[i][j] = new SquareGLPicture(subData(data,j*psize,i*psize,psize,psize,w),psize,psize,alphaOnly,gl);
             tmp = (rows-1)*psize;
             for(int i=0;i<cols-1;i++)
-                pics[rows-1][i] = new SquareGLPicture(subData(data,i*psize,tmp,psize,h-tmp,w),psize,h-tmp,gl);
+                pics[rows-1][i] = new SquareGLPicture(subData(data,i*psize,tmp,psize,h-tmp,w),psize,h-tmp,alphaOnly,gl);
             tmp2 = (cols-1)*psize;
             for(int i=0;i<rows-1;i++)
-                pics[i][cols-1] = new SquareGLPicture(subData(data,tmp2,i*psize,w-tmp2,psize,w),w-tmp2,psize,gl);
-            pics[rows-1][cols-1] = new SquareGLPicture(subData(data,tmp2,tmp,w-tmp2,h-tmp,w),w-tmp2,h-tmp,gl);
+                pics[i][cols-1] = new SquareGLPicture(subData(data,tmp2,i*psize,w-tmp2,psize,w),w-tmp2,psize,alphaOnly,gl);
+            pics[rows-1][cols-1] = new SquareGLPicture(subData(data,tmp2,tmp,w-tmp2,h-tmp,w),w-tmp2,h-tmp,alphaOnly,gl);
         }
         protected void finalize() {  }
         
index ccb3004..1608a75 100644 (file)
@@ -51,19 +51,21 @@ public class Freetype {
                 
                 int width = vm.getUserInfo(6);
                 int height = vm.getUserInfo(7);
-                int[] data = new int[width * height];
+                byte[] data = new byte[width * height];
                 int addr = vm.getUserInfo(5);
 
-                for(int i=0; i<width * height; i += 4) {
+                vm.copyin(addr,data,width*height);
+                
+                /*for(int i=0; i<width * height; i += 4) {
                     int val = vm.memRead(addr + i);
                     for (int k = 3; k >= 0; k--) {
                         if (i + k < width * height)
                             data[i + k] = (val & 0xff) << 24;
                         val >>>= 8;
                     }
-                }
+                }*/
                 
-                glyph.p = Platform.createPicture(data, width, height);
+                glyph.p = Platform.createAlphaOnlyPicture(data, width, height);
                 glyphCache.put(res, new Integer((g << 16) | pointsize), glyph);
             }
         } catch (Exception e) {