ecere/gfx/LFBDisplayDriver: Made font ascent available through property
[sdk] / ecere / src / gfx / drivers / LFBDisplayDriver.ec
index 4185e47..bbe5615 100644 (file)
@@ -705,6 +705,10 @@ public class Font : struct
       }
 #endif
    }
+   public property int ascent
+   {
+      get { return (int)(this ? ascent * scale : 0); }
+   }
 };
 
 public class LFBDisplay : struct
@@ -1234,7 +1238,7 @@ public class LFBDisplayDriver : DisplayDriver
       LFBDisplay lfbDisplay = display ? display.driverData : null;
       LFBSurface lfbSurface = surface.driverData;
       uint index;
-      if(display) color = color /*& 0xFFFFFF*/;
+      //if(display) color = color & 0xFFFFFF;
       lfbSurface.foregroundRgb = color;
 
       if(lfbSurface.font && lfbDisplay)
@@ -1269,7 +1273,7 @@ public class LFBDisplayDriver : DisplayDriver
    {
       LFBDisplay lfbDisplay = display ? display.driverData : null;
       LFBSurface lfbSurface = surface.driverData;
-      color = color /*& 0xFFFFFF*/;
+      //color = color & 0xFFFFFF;
       switch(lfbSurface.bitmap.pixelFormat)
       {
          case pixelFormat8:
@@ -2461,7 +2465,7 @@ public class LFBDisplayDriver : DisplayDriver
             ColorAlpha * backsrc;
             ColorAlpha * source = ((ColorAlpha *) src.picture) + sy * addsource + sx;
             ColorAlpha * dest = ((ColorAlpha *) lfbSurface.bitmap.picture) + dy * adddest   + dx;
-            if(flip < 0) source += sw-1;
+            if(flip) source += sw-1;
             adddest -= w;
             yerr = 0;
             for(y=0; y<sh; y++)
@@ -3661,14 +3665,67 @@ public class LFBDisplayDriver : DisplayDriver
          delete mesh.texCoords;
    }
 
-   bool AllocateMesh(DisplaySystem displaySystem, Mesh mesh)
+   bool AllocateMesh(DisplaySystem displaySystem, Mesh mesh, MeshFeatures flags, int nVertices)
    {
       bool result = false;
-
-      if((!mesh.flags.vertices   || mesh.vertices  || (mesh.vertices  = new Vector3Df[mesh.nVertices])) &&
-         (!mesh.flags.normals    || mesh.normals   || (mesh.normals   = new Vector3Df[mesh.nVertices])) &&
-         (!mesh.flags.texCoords1 || mesh.texCoords || (mesh.texCoords = new Pointf  [mesh.nVertices])))
+      if(mesh.nVertices == nVertices)
+      {
          result = true;
+         // Same number of vertices, adding features (Leaves the other features pointers alone)
+         if(mesh.flags != flags)
+         {
+            if(!mesh.flags.vertices && flags.vertices)
+            {
+               if(flags.doubleVertices)
+               {
+                  mesh.vertices = (Vector3Df *)new Vector3D[nVertices];
+               }
+               else
+                  mesh.vertices = new Vector3Df[nVertices];
+            }
+            if(!mesh.flags.normals && flags.normals)
+            {
+               if(flags.doubleNormals)
+               {
+                  mesh.normals = (Vector3Df *)new Vector3D[nVertices];
+               }
+               else
+                  mesh.normals = new Vector3Df[nVertices];
+            }
+            if(!mesh.flags.texCoords1 && flags.texCoords1)
+               mesh.texCoords = new Pointf[nVertices];
+            if(!mesh.flags.colors && flags.colors)
+               mesh.colors = new ColorRGBAf[nVertices];
+         }
+      }
+      else
+      {
+         result = true;
+         // New number of vertices, reallocate all current and new features
+         flags |= mesh.flags;
+         if(flags.vertices)
+         {
+            if(flags.doubleVertices)
+            {
+               mesh.vertices = (Vector3Df *)renew mesh.vertices Vector3D[nVertices];
+            }
+            else
+               mesh.vertices = renew mesh.vertices Vector3Df[nVertices];
+         }
+         if(flags.normals)
+         {
+            if(flags.doubleNormals)
+            {
+               mesh.normals = (Vector3Df *)renew mesh.normals Vector3D[nVertices];
+            }
+            else
+               mesh.normals = renew mesh.normals Vector3Df[nVertices];
+         }
+         if(flags.texCoords1)
+            mesh.texCoords = renew mesh.texCoords Pointf[nVertices];
+         if(flags.colors)
+            mesh.colors = renew mesh.colors ColorRGBAf[nVertices];
+      }
       return result;
    }