Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

AltSDK: AltSketch Graphics - Fast Draw Vector Geometries, Fonts (C# FreeType port), Image I/O, etc.

Discussion in 'Assets and Asset Store' started by AltSoftLab, Aug 16, 2014.

  1. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    All solutions are already available on AltSoftLab and in Asset Store. Look more at the AltSDK main forum

    AltSDK specialized forums (all these tools are parts of the one AltSDK Asset):
    In this topic we present the graphics sub asset of AltSDK that allows you to easy draw vector graphics, print text with platform independant C# FreeType library, image I/O manipulations, work with resources virtual file system, etc. You can use this features directly on screen or on Unity UI (uGUI) and NGUI controls. Also these features can be used without any GUI (just draw in memory bitmaps).

    NOTE: AltSDK contains full source code of AltSketch Backend & Integration and not depends on any Unity release version. AltSDK Asset requirements ("Unity 4.6 or higher") set by Asset Store Administrators, but AltSketch hasn't such requirements in real.

    AltSketch main features:
    • Fast realtime Raster and Vector Text Render based on AltNETType (C# port of full FreeType font render engine)
    • Pens with different styles (solid, dotted, etc.) for drawing any geometries
    • Brushes with different styles (solid, gradient, image, hatch, user defined material, etc.) for filling any geometries
    • Boolean operations on geometries
    • Programmable geometries (geometry generation by algorithm)
    • Image IO operations with different formats (PNG, Jpeg, animated GIF, BMP, Tiff, TGA) from files, streams, memory buffers
    • Fast integrated Software Render Backend (independent on any external graphics)
    • Flexible API for Hardware Render Backend (implemented for Unity and many other graphics and game engines)
    • AltSketch Unity Hardware Render Backend uses only very simple Unity API (not requires FSAA for anti-aliasing, no special shaders, etc.).
    AltSketch is a pure C# CLS compliant 100% managed, without unsafe blocks Vector Graphics Library with Software and Hardware Render Backends for Games, Scientific Applications & other uses of Computer Graphics. All core functionality collected in one lightweight library AltSketch.dll for Microsoft .NET Framework or Mono (including Silverlight / Moonlight). It depends only on System, System.Data & System.Xml assemblies (.NET Framework 2.0).

    AltSketch has System.Drawing like program interface and Software & Hardware Render Backends (solid and texure AA visual data triangulation), contains a subsystem AltNETType - port of wonderful font rendering library Freetype (READ MORE about AltNETType API) and subsystem AltNETImage for Image manipulations (loading, saving, transformations).

    As AltSketch has several integrations with most popular GUI systems and Mobile platforms, you can develop and test a drawing part of your 3D application/game as independent program, and then easy integrate it into your main solution. Now you can draw Graphics in 3D with Brushes and Pens like you do it with any drawing library. It is flexible and useful development method in case of main project bulking and test complexity, or useful for team development process. Now you can develop graphics part of your Mobile applications without using an emulator as stand-alone application, only running on Mobile devices (or Emulator) for final tests.

    AltSketch has Virtual File System support with Zip containers for resources loading. All AltSketch functionality & extensions works via VirtualFS and all resources can be loaded as from real file system, so from Zip containers (from files or memory streams).

    Graphics in AltSketch begins with drawing lines and shapes, and continues on with work on images and formatting text. Drawing begins with the Graphics class. You can create a Graphics object based on an ImageSource object if you to draw in memory in SW mode and/or to save a picture as a file. Once you create the Graphics object, you have many methods you can use to perform the drawing:
    • Clear: clears the entire surface and fills it with color.
    • DrawEllipse / FillEllipse: draws an ellipse or circle defined by a bounding rectangle specified by a pair of coordinates, a height, and width.
    • DrawGeometry / FillGeometry: draws a vector source geometry as defined by Geometry class
    • DrawIcon and DrawUnstretched: draw the image represented by the specified icon at the specified coordinates, with or without scaling the icon.
    • DrawImage: draws the specified Image object at the specified location.
    • DrawLine: draws a line connecting two points by the coordinate pairs.
    • DrawLines: draws a series of line segments that connect an array of Point structures.
    • DrawPath: draws a series of connected lines and curves.
    • DrawPie / FillPie: draws a pie shape defined by an ellipse specified by a coordinate pair, a width, a height, and two radial lines.
    • DrawPolygon / FillPolygon: draws a shape with three or more sides as defined by an array of Point structures
    • DrawRectangle / FillRectangle: draws a rectangle or square, specified by a coordinate pair, a width, and a height.
    • DrawString: draws the specified text string at the specified location with the specified Brush and Font objects.
    To use any of these methods, you must provide an instance of the Pen class. Typically, you specify the Pen class’ color and width in pixels. In Fill methods you must provide an instance of the Brush class. Also Pen supports Brushes as sources for gradient and image drawing. The supported brushes are:
    • SolidColorBrush
    • LinearGradientBrush
    • RadialGratientBrush
    • ImageBrush & TextureBrush
    • PathGradientBrush (coming soon...)
    Read AltSketch HowTo - http://forum.unity3d.com/threads/262644/#post-1736681

    AltSDK includes wide variety of subAssets based on AltSketch: ported to AltSketch popular libraries (GUI, Plot, GIS, Computer Science, Physics, Graphics etc.):

    AltSDK Full Edition (available only on AltSoftLab) includes many Integration Demos with a wide variety GUI-s & frameworks (all Integrations & HW Render Backends are open sourced, so you can easily adapt it to your applications or improve it if you need):
    • Unity Game Engine
    • XNA / MonoGame
    • OpenTK
    • Silverlight / Moonlight
    • Windows Forms
    • GTK

    AltSDK Social Links:

    AltSketch HowTo - http://forum.unity3d.com/threads/262644/#post-1736681


    Some screenshots are represented below. Look more in AltSoftLab Screenshots Gallery

    AltSketch Unity Vector Text Double Path Transform
    [​IMG]

    AltSketch Unity QuickFont
    [​IMG]

    AltSketch Unity SVG Transformations
    [​IMG]

    AltSketch Unity OxyPlot
    [​IMG]

    AltSketch Unity Geometry Polar Transform
    [​IMG]

    AltSketch Unity Geometry Bilinear and Perspective Transform
    [​IMG]

    AltSketch Unity Pie Chart
    [​IMG]

    AltSketch Unity AltNETType
    [​IMG]

    AltSketch Unity Geometry Boolean Operations
    [​IMG]

    AltSketch Unity NPlot
    [​IMG]

    AltSketch Unity Font Atlas
    [​IMG]

    AltSketch Unity Vector Text Outline Transformations
    [​IMG]

    AltSketch Unity Clipper
    [​IMG]

    AltSketch Unity SVG Outline[​IMG]

    AltSketch Unity ExtBrush
    [​IMG]
     
    Last edited: Jan 8, 2017
  2. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    The base drawing tool of AltSDK is AltSketch Vector Graphics Library. In most cases of API it's like most widely used in the .NET world MS graphics GDI+ (.NET System.Drawing namespace)

    So you can use a lot of web doucumentation tutorials and books related to System.Drawing namespace. Because AltSketch has the same API. For example such info resources are:
    http://msdn.microsoft.com/en-US/en-en/library/system.drawing(v=vs.110).aspx
    http://www.codeproject.com/Articles/1355/Professional-C-Graphics-with-GDI
    http://www.c-sharpcorner.com/UploadFile/mahesh/gdi_plus12092005070041AM/gdi_plus.aspx
    http://www.techotopia.com/index.php/Drawing_Graphics_in_C_Sharp
    http://www.deitel.com/articles/csharp_tutorials/20051025/IntroTo2DGraphics.html
    http://csharpcomputing.com/Tutorials/Lesson13.htm
    http://www.dreamincode.net/forums/topic/67275-the-wonders-of-systemdrawinggraphics/

    Of course AltSDK contains handreds of examples you can deep look and play with.

    Brief info HowTo port System.Drawing code to AltSketch:

    AltSketch uses double arithmetic instead of float, because it has better precision. For example 0.5 in float is not 0.5. It’s 0.499999… And you must use float == 0.5f because float == 0.5 is not working. But maybe some compilers have good results. You can read a lot of web resources related to this task.
    And like in WPF we use double instead of float by default. Point, Size, Rect are double (not int). For 'int' AltSketch uses PointI, SizeI, RectI

    In porting process do by such way:
    • System.Drawing, System.Drawing.Text, System.Drawing.Imaging, System.Drawing.Drawing2D -> Alt.Sketch
    • Use full HorizontalAlignment (VerticalAlignment ) enum with full path Alt.GUI.HorizontalAlignment because HorizontalAlignment property exists (to prevent compiler names conflicts)
    • Point -> PointI
    • Size -> SizeI
    • Rectangle -> RectI
    • PointF -> Point (double)
    • SizeF -> Size (double)
    • RectangleF -> Rect (double)
    • SolidBrush -> SolidColorBrush
    • Image -> ImageSource. Image.Width -> ImageSource.PixelWidth. Image.Height -> ImageSource.PixelHeight. Image.Size -> ImageSource.PixelSize.
    • BitmapData.Scan0 is byte[]
    • Image.FromFile (.FromStream, etc.) -> Bitmap.FromFile (.FromStream, etc.)
    • Icon.FromHandle(bitmap.GetHicon()) -> Icon.FormImage(bitmap)
    • System.Windows.Forms -> Alt.GUI
    • Double arithmetics (all float -> double). Alt.GUI Control Location, Size, Bounds (etc.) – are double (not int)
    • CheckBox.Checked -> CheckBox.IsChecked. CheckButton.Checked -> CheckButton.IsChecked. RadioButton.Checked -> RadioButton.IsChecked
    • Application – object. Make it public to run in AltOS.

    AltNETType OpenGL example. Can be useful to deeper look into multiplatform fully managed AltNETType runtime API instead of native FreeType wrappers (also look into article on CodeProject - http://www.codeproject.com/Tips/668161/Rendering-AltNETType-equals-NET-FreeType-port-with)
    Code (CSharp):
    1. public Font3D(string font, int size)
    2. {
    3.     //  Save the size we need it later on when printing
    4.  
    5.     font_size = size;
    6.     //  We begin by creating a library pointer
    7.     ANT_Library library;
    8.     ANT_Error ret = ANT.ANT_Init_AltNETType(out library);
    9.     if (ret != ANT_Error.ANT_Err_Ok)
    10.     {
    11.         return;
    12.     }
    13.     //  Once we have the library we create and load the font face
    14.     ANT_Face face;
    15.     ret = ANT.ANT_New_Face(library, font, 0, out face);
    16.     if (ret != ANT_Error.ANT_Err_Ok)
    17.     {
    18.         return;
    19.     }
    20.     //  AltNETType (as Freetype) measures the font size in 1/64th of pixels for accuracy
    21.     //  so we need to request characters in size*64
    22.     ANT.ANT_Set_Char_Size(face, size << 6, size << 6, 96, 96);
    23.     //  Provide a reasonably accurate estimate for expected pixel sizes
    24.     //  when we later on create the bitmaps for the font
    25.     ANT.ANT_Set_Pixel_Sizes(face, size, size);
    26.     //  Once we have the face loaded and sized we generate opengl textures
    27.     //  from the glyphs  for each printable character
    28.     textures = new int[128];
    29.     extent_x = new int[128];
    30.     list_base = Gl.glGenLists(128);
    31.     Gl.glGenTextures(128, textures);
    32.     for (int c = 0; c < 128; c++)
    33.     {
    34.         Compile_Character(face, c);
    35.     }
    36.     //  Dispose of these as we don't need
    37.     ANT.ANT_Done_Face(ref face);
    38.     ANT.ANT_Done_AltNETType(ref library);
    39. }
    40. public void Compile_Character(ANT_Face face, int c)
    41. {
    42.     //  We first convert the number index to a character index
    43.     int index = ANT.ANT_Get_Char_Index(face, Convert.ToChar(c));
    44.     //  Here we load the actual glyph for the character
    45.     ANT_Error ret = ANT.ANT_Load_Glyph(face, index, ANT_LOAD.ANT_LOAD_DEFAULT);
    46.     if (ret != 0) return;
    47.     //  Convert the glyph to a bitmap
    48.     ANT_Glyph glyph;
    49.     ret = ANT.ANT_Get_Glyph(face.glyph, out glyph);
    50.     if (ret != ANT_Error.ANT_Err_Ok)
    51.     {
    52.         return;
    53.     }
    54.     ANT.ANT_Glyph_To_Bitmap(ref glyph, ANT_Render_Mode.ANT_RENDER_MODE_NORMAL, null, true);
    55.     ANT_BitmapGlyph glyph_bmp = (ANT_BitmapGlyph) glyph;
    56.     int size = (glyph_bmp.bitmap.width * glyph_bmp.bitmap.rows);
    57.     if (size <= 0)
    58.     {
    59.         //  space is a special `blank` character
    60.         extent_x[c] = 0;
    61.         if (c == 32)
    62.         {
    63.             Gl.glNewList((uint)(list_base + c), Gl.GL_COMPILE);
    64.             Gl.glTranslatef(font_size >> 1, 0, 0);
    65.             extent_x[c] = font_size >> 1;
    66.             Gl.glEndList();
    67.         }
    68.         return;
    69.     }
    70.     byte[] bmp = new byte[size];
    71.     Array.Copy(glyph_bmp.bitmap.buffer, bmp, bmp.Length);
    72.     //  Next we expand the bitmap into an opengl texture        
    73.     int width = next_po2(glyph_bmp.bitmap.width);
    74.     int height = next_po2(glyph_bmp.bitmap.rows);
    75.     byte[] expanded = new byte[2 * width * height];
    76.     for (int j = 0; j < height; j++)
    77.     {
    78.         for (int i = 0; i < width; i++)
    79.         {
    80.             expanded[2 * (i + j * width)] = expanded[2 * (i + j * width) + 1] =
    81.                 (i >= glyph_bmp.bitmap.width || j >= glyph_bmp.bitmap.rows) ?
    82.                     (byte)0 : bmp[i + glyph_bmp.bitmap.width * j];
    83.         }
    84.     }
    85.     //  Set up some texture parameters for opengl
    86.     Gl.glBindTexture(Gl.GL_TEXTURE_2D, textures[c]);
    87.     Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
    88.     Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
    89.     //  Create the texture
    90.     Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, width, height,
    91.         0, Gl.GL_LUMINANCE_ALPHA, Gl.GL_UNSIGNED_BYTE, expanded);
    92.     expanded = null;
    93.     bmp = null;
    94.     //  Create a display list and bind a texture to it
    95.     Gl.glNewList((uint)(list_base + c), Gl.GL_COMPILE);
    96.     Gl.glBindTexture(Gl.GL_TEXTURE_2D, textures[c]);
    97.     //  Account for freetype spacing rules
    98.     Gl.glTranslatef(glyph_bmp.left, 0, 0);
    99.     Gl.glPushMatrix();
    100.     Gl.glTranslatef(0, glyph_bmp.top - glyph_bmp.bitmap.rows, 0);
    101.     float x = (float)glyph_bmp.bitmap.width / (float)width;
    102.     float y = (float)glyph_bmp.bitmap.rows / (float)height;
    103.     //  Draw the quad
    104.     Gl.glBegin(Gl.GL_QUADS);
    105.     Gl.glTexCoord2d(0, 0); Gl.glVertex2f(0, glyph_bmp.bitmap.rows);
    106.     Gl.glTexCoord2d(0, y); Gl.glVertex2f(0, 0);
    107.     Gl.glTexCoord2d(x, y); Gl.glVertex2f(glyph_bmp.bitmap.width, 0);
    108.     Gl.glTexCoord2d(x, 0); Gl.glVertex2f(glyph_bmp.bitmap.width, glyph_bmp.bitmap.rows);
    109.     Gl.glEnd();
    110.     Gl.glPopMatrix();
    111.     //  Advance for the next character      
    112.     Gl.glTranslatef(glyph_bmp.bitmap.width, 0, 0);
    113.     extent_x[c] = glyph_bmp.left + glyph_bmp.bitmap.width;
    114.     Gl.glEndList();
    115. }  
    AltNETType in OpenGL runtime
    [​IMG]
     
    Last edited: Apr 6, 2016
  3. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Post place reserved for the future releases info...
     
    Last edited: Apr 2, 2016
  4. gacltdev

    gacltdev

    Joined:
    May 31, 2013
    Posts:
    416
    Hello,

    Do you have precompiled web player demos and/or Android APK's?

    Is the virtual file system thread safe?

    Do you provide source code? I did not see any indication of source files in the asset store link.

    Thank you
     
  5. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi, cl.9!
    AltSDK Demo contains hundreds of examples of AltSDK in different ways of uses. There are several Unity Web Demos on AltSoftLab representing some of AltSDK features:
    • Unity UI Integration Web Demo
    • NGUI Integration Web Demo
    • Native Web Demo
    Also you can play with Online Silverlight Demo

    Yes

    Only AltSketch Core is closed source. We provide full source code of AltSketch Render Backend and Integration and of cause of the the full Demo (just much scroll down the Package Contents Tree on Asset Store - you will see A LOT OF CS files - look at the last screenshot below; it's because of many data files in Demo in AltData folder and they auto placed on top of the tree - in the next releases we'll put it into Zip storage like we did it in No Commercial SDK and Silverlight Demo) - they placed in _Backend, _Integration and Demo folders. Also we provide all AltSketch Extensions source files (ported to AltSketch popular libraries - GUI, Plot, GIS, Computer Science, Physics, Graphics etc.: SVG.NET, AForge.NET, NPlot, OxyPlot, PieChart, ZedGraph, MigraDoc, PDFsharp, GMap.NET, HTML Renderer, Box2D, Farseer Physics, etc.). It requires Indie Advanced or Professional license

    Bests!

    Johnny,
    AltSoftLab Team

    [​IMG]

    [​IMG]

    [​IMG]

    CS files in Package Contents tree (just much scroll down the Package Contents Tree on Asset Store)
    [​IMG]
     
    Last edited: Nov 26, 2015
  6. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    cl.9, I extended answer for you (please reread my previous post). Also we are always opened for any suggestions for AltSketch project extending, feature requests and discussions! Here or on project official site forum

    Bests!

    Johnny,
    AltSoftLab Team
     
    Last edited: Aug 16, 2014
  7. bjornrun

    bjornrun

    Joined:
    Oct 29, 2013
    Posts:
    78
    It seems to contain a lot of graphic packages. If the GUI packages are good enough it would be very interesting.
    I would like to see workflow examples about developing on Unity. Benefits of developing a native app and then port it to mobile.
    What about performance?
    How well is it integrated with Unity? Do it support all platforms that Unity supports?

    Thanks!
     
  8. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi bjornrun!
    The main idea of AltSketch project is to bring a useful drawing functionality (like Brushes, Pens, Drawing Graphics funcs) into Graphics Engines and extend it (like Custom Shader Brushes – ExtBrush, Vector Graphics, etc.). So you don’t need to operate with Vertex/Index data and hard vector math any more - just draw over your 3D Graphics! Many famous widely used useful libraries has been ported to AltSketch. Because AltSketch has System.Drawing like interface it was not hard (just to rename some names). Also you can easily port to AltSketch by yourself some nice System.Drawing/GDIPlus solutions and use it in your game project or also maybe you can sell it in Unity Asset Store as AltSketch Extension (like extensions for NGUI). With AltSketch it's not need to create new apropriate developed from scratch libraries that solves a trivial tasks (for example Graphs, Plots, Text Rendering, etc. - look at screenshots at the bottom - all this samples are interactive, dinamicaly generated and available in SDK). Just find usefil professional solution and try to port in (if this solution based on System.Drawing, you not need to pay too much time and efforts)!

    Yes, we would like to see too! But it's hasn't difference from any other AltSketch uses (like in XNA, OGRE, NeoAxis, WinForms, WPF, etc.)

    AltSketch has Hardware Render (to Screen and to Render Texture) and fast Software Render to Texture2D. And we working on many optimization things. AltSketch fast and soon it became more faster (read technical description below)! You can play with Online Silverlight Demo or with integration into other Render Engines by downloading No Commercial SDK.

    Unity Backend and Integration is open sourced in package. It’s very structured and simple. You can look into Backends & Integrations into other engines (by downloading No Commercial SDK). In Unity we did it in the same way. Untity Implementation does not depend on a specific version of the Unity, so AltSketch can be used in any Unity version (we didn't use any extra specific Unity functionality).

    We have Multiplatform PC Standalone AltSketch version, Android, iOS, Windows Phone 7.1-8 (you can play with it by downloading No Commercial SDK). AltSketch works in the Web version, but it’s need to update some AltSketch Extensions because of Web restrictions.

    Developing of AltSketch is a hard way of more than 3 years of work. And it will more stronger and wider in the nearest future because we are still hard working on it new functionality!

    In another thread I already answered on technical question. Just copied it:
    All of this can be rendered in several ways:
    - Hardware Render - all the data preprocessed, triangulated, postprocessed and rendered. Text can be rendered as textures and as Vector Data
    - Software Render and then displayed as Texture - we have too fast Software Renderer. It used in some popular GUIs like WinForms, WPF, GTK#, etc.
    - HW Render To Texture - for the some not rarely changing operations can be used buffering
    - Combined SW and HW render - for the too mutch changable vector data SW Render can be used as it in many cases too faster than HW Render with triangulations and some additional data processing

    In all our integrations HW Render To Texture has been implemented. For this case in Unity Backend Unity_RenderTexture class used. For the professional and free Unity edditions we have a little hook in Unity_RenderManager for determining is Unity RenderTexture available (it's not available for Unity Free eddition). If it's not available we just use SW Render buffers.

    And of cause we use many cache systems. Triangulation caches, text textures caches, gradients caches, and many others. But we still hasn't batching. This feature will be added very soon! Too lesser render operations per frame => faster render! We are working on deffered drawing pipeling for this. And another useful thing we will add in the nearest future - is multithread data preprocesing. It's useful for many changed vector data and parallel SW render to buffers and parallel bitmap data processing (like filters, etc.). And the last thing we need is instancing. Now all vector data moved to render as new. We will implement this in the nearest future also! So soon AltSketch will be more faster!

    Of cause for the more efficiency we use compound technics. You can use HW Render to Texture if you prefer it, but there are some limitations now in AltSketch Unity Backend:
    - We still didn't implemented texture multisampling. It's need a special shader or we still didn't find a Unity standart element like DualTextureEffect in XNA. It's because of our our politics: we don't using any extentions in our Backend realisations; only standart communly used features; it's to prevent any limitations to AltSketch user
    - Because of premultiplied alpha. The problem is of transparent data rendering to transparent RenderTexture. In this case you get some visual artefacts then when render this texture. The result will be darker or more transparent than if you render data dirrectly to the target screen. But if you render to not transparent RenderTexture (for example, to White backbuffer) the result will be ok. So if you know that you draw on not transparent you can use HW Render to Texture. It can be managed in the drawing code by Alt.Sketch.RenderImage.SoftwareRender property per each buffer (you can scan these uses in AltSketch SDK).

    So we prefer to use SW Render buffers now for buffering. But HW Render to Texure is available. You can enable this in Unity_RenderManager constructor by disabling line 'RenderToTextureSupported = false' et the end of constructor.

    And the best efficiency in the hands of AltSketch user (like in the hands of any Graphics Library user). For example if you want to draw the same moving circle, it's prefer to change Matrix translation and draw circle in the same place, than draw circle in different places. It's because of triangulation cache usings. If you changing just Matrix the same triangulation data used to draw render primitive. In another case new triangulation process started.
    And use buffers (Alt.Sketch.RenderImage) in the case of rarely changed data.

    AltSketch in work (more screenshots here and available in work in Online Silverlight Demo):

    AltSketch NeoAxis GMap.NET and CombinedGeometry
    [​IMG]

    AltSketch NeoAxis HTML Renderer
    [​IMG]

    AltSketch NeoAxis NPlot and Clipper
    [​IMG]

    AltSketch NeoAxis Accord Face Detection and Vector Text Transformation
    [​IMG]

    AltSketch NeoAxis NPlot and SVG[​IMG]

    AltSketch NeoAxis Awesomium Web Browser
    [​IMG]

    AltSketch OxyPlot - Tile Map Annotation (OpenStreetMap)
    [​IMG]

    AltSketch HTML Renderer - Using the Code
    [​IMG]

    AltSketch HTML Renderer - Text
    [​IMG]

    AltSketch QuickFont (Bounds and Justify) - Alignment Centre
    [​IMG]

    AltSketch QuickFont (Drop Dynamic Shadows)
    [​IMG]

    AltSketch Accord.NET Kinematics Demo
    [​IMG]

    AltSketch Vector Text over 3D
    [​IMG]

    AltSketch OxyPlot - DateTime
    [​IMG]

    AltSketch OxyPlot - Polar Plot
    [​IMG]

    AltSketch OxyPlot - Rectangle Annotations
    [​IMG]

    AltSketch OxyPlot - Scatter Series
    [​IMG]

    AltSketch OxyPlot - Two-Color Line Series
    [​IMG]

    AltSketch OxyPlot - World Population
    [​IMG]

    Johnny,
    AltSoftLab Team
     
    Last edited: Nov 26, 2015
  9. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    We try to use SelfDocumented Naming of all AltSketch/Extensions/Demos modules (classes, structs, enums, funcs). AltSketch in most cases like System.Drawing interface with a few extensions showed in SDK Demo. "Like" means "almost compartible with a few exceptions". For the Extensions we use commonly widely used libraries ported to AltSketch. You can get any assistance here (on this forum) or on the Project Main Site forums.

    And also brief info from the Asset README.TXT:

    UNITY BACKEND & INTEGRATION
    -------------------------------------------------

    AltSketch Unity Backend & Integration files placed in _Backend & _Integration Folders. Backend solves
    all rendering operations. It includes:

    Unity_Renderer - single render context handler (like render to Screen or to Texture)

    Unity_RenderManager - common settings, textures container

    Unity_RenderPrimitive - single render data processor

    Unity_Texture - operates with Texture2D & RenderTextures


    Also Backend contains BrushMaterial-s (placed in _Backend/BrushMaterials folder). Brush materials solve
    to operate with Brush settings and move it to render pipeline. BrushMaterials includes:

    Unity_SolidColorBrushMaterial - SolidColorBrush processor

    Unity_LinearGradientBrushMaterial - LinearGradientBrush processor

    Unity_RadialGradientBrushMaterial - RadialGradientBrush processor

    Unity_ImageBrushMaterial - ImageBrush processor

    Unity_ExtBrushMaterial - ExtBrush processor


    AltSketch Unity Integration consists of 2 main objects:

    AltSketchMonoBehaviour - main MonoBehaviour class that processes all needed Unity events and render

    AltSketchScreenMonoBehaviour - inherits AltSketchMonoBehaviour and solves to process Mouse and Keyboard
    in full screen mode


    AltSketch Unity Backend & Integration is only things you need to integrate the AltSketch core functionality.
    You just need to create script, derive it from AltSketchScreenMonoBehaviour and process some event routings
    like in the way of it do AltSketchDemo.cs (we use Windows Forms events style notation & scheme):

    1. Do some initialisaion in Unity Start method:
    void Start ()
    {
    ...
    }

    2. Process some cleaning in Unity OnDestroy method and at the end call DestroyRender method of AltSketchMonoBehaviour to clean render:

    void OnDestroy()
    {
    ...
    DestroyRender ();
    }


    3. To draw something just override OnPaintBackground, OnRender & OnPaint AltSketchMonoBehaviour methods:

    a) Called first to draw background - just general scheme

    protected override void OnPaintBackground(Alt.GUI.PaintEventArgs e)
    {
    base.OnPaintBackground(e);
    ...
    }

    b) Called secondly. Here you can render something before OnPaint - just general scheme

    protected override void OnRender()
    {
    ...
    }

    c) Called thirdly. The main AltSketch foreground render method

    protected override void OnPaint(Alt.GUI.PaintEventArgs e)
    {
    base.OnPaint(e);
    ...
    }


    4. Override OnResize to process render window resizing event:

    protected override void OnResize(Alt.GUI.ResizeEventArgs e)
    {
    base.OnResize(e);
    ...
    }


    5. Override OnMouseDown, OnMouseUp, OnMouseMove & OnMouseWheel to process Mouse events:

    protected override void OnMouseDown(Alt.GUI.MouseEventArgs e)
    {
    base.OnMouseDown(e);
    ...
    }

    protected override void OnMouseUp(Alt.GUI.MouseEventArgs e)
    {
    base.OnMouseUp(e);
    ...
    }

    protected override void OnMouseMove(Alt.GUI.MouseEventArgs e)
    {
    base.OnMouseMove(e);
    ...
    }

    protected override void OnMouseWheel(Alt.GUI.MouseEventArgs e)
    {
    base.OnMouseWheel(e);
    ...
    }


    6. Override OnKeyDown, OnKeyUp & OnKeyPress to process Keyboard events:

    protected override void OnKeyDown(Alt.GUI.KeyEventArgs e)
    {
    base.OnKeyDown(e);
    ...
    }

    protected override void OnKeyUp(Alt.GUI.KeyEventArgs e)
    {
    base.OnKeyUp(e);
    ...
    }

    protected override void OnKeyPress(Alt.GUI.KeyPressEventArgs e)
    {
    base.OnKeyPress(e);
    ...
    }


    AltSketch DEMO
    -----------------------

    AltSketch SDK Demo examples located in Demo folder.

    AltSketch Demo is built on top of modified and extended AltSketch.Gwen GUI library. Each AltSketch
    example uses it's own class derived from Example__Base class. Example__Base is the Base Gwen Control.

    All examples collected in ExamplesHolder examples handler class. And finally ExamplesHolder owned by
    main AltSketch Demo class - Demo/AltSketchDemo. Demo/AltSketchDemo - is the main top level class used by all
    AltSketch integrations for unification.

    As you can see equal named AltSketchDemo derived from AltSketchScreenMonoBehaviour used just to rout all
    Unity events to Demo/AltSketchDemo object.

    In AltData folder located AltSketch SDK Demo data used in examples. All this data can be zipped into zip file,
    that can be used dirrectly by VirtualFileSystem or attached to any DLL as resource and then added to VFS.

    All addition information you need you can get on AltSketch Project Main Site and on it forums.


    Bests!

    Johnny,
    AltSoftLab Team
     
    Last edited: Aug 17, 2014
  10. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
  11. Arisha

    Arisha

    Joined:
    Jun 13, 2014
    Posts:
    19
    Hi there,

    I want to thanks for a really amazing addon. I played with it some days and it's nice to me to have drawing funcs on top of the 3D Environment as I'm new in Unity

    Some questions:
    What is about Unity Clipboard support? What is the best way to use custom shaders for AltSketch Brushes? And it will be more useful to have Gwen sources because of all examples in Demo based on it.

    Thanx!
     
  12. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi Arisha!

    Thanks a lot! You are welcome! Yes, the main Idea of the AltSketch project is "Just Draw It!". In many cases it's very unfriendful native tools to draw any data with it. It's need to create a tons of addition code with many maths. We use System.Drawing like interface because it's known for a wide variety of coders. It's nice and simple. And also there are many good solutions based on Syste,.Drawing, so it's easy to port it with AltSketch to your 2D / 3D graphics App / Game.

    1. Clipboard support coming next week with the Windows.Forms Clipboard program interface like object. Yes, we try to use common used interfaces - it's easy to adapt for users. And it's good, so no any reason to develop a bicycle!

    3. We decided to release all AltSketch Extensions as open source code (include Gwen GUI) for Indy License too to give users more flexible way to manipulate with needed components. Thanks for request.

    2. It's very easy to use custom shaders in AltSketch Brushes:

    a) Every brush has BrushMaterial realization:

    Unity_SolidColorBrushMaterial - for SolidColorBrush

    Unity_LinearGradientBrushMaterial - for LinearGradientBrush

    Unity_RadialGradientBrushMaterial - for RadialGradientBrush

    Unity_ImageBrushMaterial - for ImageBrush

    Unity_ExtBrushMaterial - for ExtBrush

    Unity Backend contains BrushMaterial-s (placed in _Backend/BrushMaterials folder). Brush materials solve
    to operate with Brush settings and move it to render pipeline.


    b) Every BrushMaterial has an event (just func) that called before Brush will be used:

    protected override void BeginRender(RenderContext renderContext)


    c) And also func called when brush can unsed its params:

    protected override void EndRender()


    d) BrushMaterial has a func that called per each RenderPrimitive to enable BrushMaterial set the params per this RenderPrimitive (for example different shader will be used for AA render and for solid render):

    public UnityEngine.Material GetMaterial(RenderPrimitive renderPrimitive)


    You can do some preparation in BeginRender and clear in EndRender. In GetMaterial you can return custom material. Example of uses is Unity_ExtBrushMaterial that is Material for ExtBrush. ExtBrush is a spetial brush type for common uses. Each Brush has a user parameters that routed to BrushMaterial (you can fine Set/GetExtParameter funcs in Brush-es and BrushMaterials). So we used this parameters in "AltSketch Unity ExtBrush" (look at screenshot below). It's not good axample because we use some Unity integrated shaders ("Hidden/Internal-Flare", "Particles/~Additive-Multiply", "Transparent/Cutout/Specular", "Hidden/Internal-Halo"). But you can use your own interesting shaders with nice effects. Just look at Unity_ExtBrushMaterial and to Demo\Graphics\Example_ExtBrush example and you will see all answers. Good luck!

    Bests!
    Johnny

    AltSketch Unity ExtBrush
    [​IMG]
     
  13. Arisha

    Arisha

    Joined:
    Jun 13, 2014
    Posts:
    19
    Thanks for answer Johnny! I'll try. What difference between AA and non AA RenderPrimitive structure? Why different shaders needs? And when you have plans to share extensions source code?
     
  14. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    For AntiAliased smoothing we use Texture Alpha Mask. So AA triangulation model generates additional AATexture Coords. And of cause you need different shading (or a smart shader) that can render with or without AA Texture. We use a smart AA smothing model that generates AA Render Data only if it's really need in a scene.

    Extensions source code will be available soon with the nearest (next) update.

    Bests!
    Johnny
     
  15. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    AltSketch SDK is not available for free anymore. You can buy it in Unity Asset Store or on the project main site. As we can't release AltSketch SDK interesting LGPL Extensions in Asset Store, it available for download in Download area on the project main site.
     
  16. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    1,699
    That looks cool. Is there some documentation on the API?
     
  17. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi, yoonitee!

    AltSketch API is similar to System.Drawing API. In most cases it just equals to it. Demo with many examples also provided. And we provide additional assistance here or on AltSofLab site forum.
     
  18. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Many new features coming soon!
    And price is reduced for this week
     
    Last edited: Apr 2, 2016
  19. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    1,699
    Behind the scenes does it call Windows GDI for Windows games, and Android canvas graphics API for Android games etc. or is all the rendering done within AltSketch. Just want to know as I think the former would be faster. BTW I think it looks very useful.
     
  20. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    AltSketch is a pure C# CLS compliant 100% managed, without unsafe blocks Vector Graphics Library with Software and Hardware Render Backends for Games, Scientific Applications & other uses of Computer Graphics. All core functionality collected in one lightweight library AltSketch.dll for Microsoft .NET Framework or Mono (including Silverlight / Moonlight). It depends only on System, System.Data & System.Xml assemblies (.NET Framework 2.0).

    In another words: no any Windows GDI and others. More information you can get on AltSoftLab main site
     
  21. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    1,699
    Hi, does it work with Windows Metro (Windows Store apps)? I have written a unity program which uses Windows.Drawing.dll and want it to run on Metro too. (Also PC, Mac, IOS and Android) Could AltSketch do this?
     
  22. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi yoonitee,

    Sorry for delay. For now we have different assemblies for WinPhone, iOS, Android, PC, Silverlight. But on Unity Asset Store the only one version is available (for PC). We are working on AltSketch new features and on AltSketch Portable assembly (PCL). It's coming soon.

    Bests!
     
  23. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    1,699
    I don't think I understand. On the asset store it says it is multi-platform. Is this not correct?
     
  24. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Yes, AltSketch is Multiplatform, but distributed as dynamic assembly. The best is to use PCL assembly fomat, but we still havn't it. So you can purchaise asset, send us a payment invoice ID (we'll check it) and we'll send to you AltSketch assembly versions for Android, iOS and WinPhone
     
  25. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    779
    I'm curious about your Unity implementation. Specifically I am trying to do motion detection within Unity from a webcam stream. I know the AForge framework has a built in motion detector class.

    Will AltSketch allow this? Are there any specific tutorials?
     
  26. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi eco_bach!

    The main target of AltSketch is to be an universal platform indepandent drawing library with like widely used System.Drawing program interface, to have many extensions, HW & SW rendering, wide variety image formats IO operations, ported to C# FreeType engine for fonts loading and rendering, etc. For now we only support just 3 Image Data Pixel Formats: 24, 32 and partly 8A BPP. Even if source file formats is different (BMP, PNG, etc.) it will be converted to supported formats. So you can operate now only with these formats by BitmapData. In the future we'll extend this feature with too many requests.

    Some nice widely used libraries ported to AltSketch use in some operations different pixel formats. So in this case we just commented these source code parts of functionality. AForge is one of these libraries (unsupported features placed in "_Unused" folders). But if you need you can extend AltSketch version of these libraries by converting AltSketch formats to needed for you and try to make these libraries work with unsupported formats. Source code of AForge is available at AltSketch Download area, so if you have already working native AForge example, you can try to port it on AltSketch, detect unsupported features and try to make it workable.

    Bests!
     
  27. Sakati84

    Sakati84

    Joined:
    Dec 10, 2014
    Posts:
    6
    I bought AltSketchPro for Unity. In the readme file of the Awsomium Demo it says: Link Awesomium.Core to Alt.Sketch.Demo project. Where can i download or find this file? Will Awsomium work with Unity under Android?
     
  28. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi Sakati84!
    All possible things you can find on the Awesomium web site. We don't know about Awesomium portability. I think you can find any information on the Awesomium web site. Good luck!

    Bests!
     
    Last edited: Jan 29, 2015
  29. Sakati84

    Sakati84

    Joined:
    Dec 10, 2014
    Posts:
    6
    The Store page says: multiplatform supported! Why don´t you even know if Awsomium runs with Unity under Android?
     
  30. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    We don't care about Awesomium at all. We are not Awesomium developers and it's not a part of AltSketch. We just created a demo of how Awesomium can be used in Gwen GUI. That's all
     
  31. yastrebovks

    yastrebovks

    Joined:
    Jul 2, 2014
    Posts:
    1
    Hi!
    I need to draw grpah independently of Viewport Rect of my Camera. I want to do it with Unity_RenderTexture, but can't deal with it. Help me in this problem!
    Thanks in advance.
     
  32. ioFlow

    ioFlow

    Joined:
    May 30, 2014
    Posts:
    13
    Hi Altsketch dudes,

    I'm thinking of mucking around with some ideas I've had for doing a custom terrain solution in unity...

    If I had an SVG map of a large region and an array of terrain patches (just normal meshes not unity terrain), would it be easy with Altsketch to get each terrain patch to use a different part of the same SVG for their textures?
     
  33. Jimww

    Jimww

    Joined:
    May 14, 2013
    Posts:
    63
    Hi, I'm just poking around at graphics libraries and noticed the AltSoftLab website is down and that there has been no activity for a few months. Is this product being supported?
     
  34. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi,

    You can create bitmaps with requiered sizes and draw your SVG to those bitmaps and then use it in the case you need.
     
    Last edited: Apr 7, 2015
  35. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi,

    Yes, AltSketch is under a hard work development and growing on. New interesting products based on AltSketch coming very soon - we hope it will be amazing! Of course AltSketch will grow more and more all the time!
    We are a hostage of World International Dirty Politics... Because of it we have a little disapointment with our domain registrar (website and mail-server is unavailable now). We hope it will be resolved soon, because we are out of any politics! We are the software engineers, the winners of some computer software competitions. And all our interests is only the computer science!
    All developers, who wrote us by mail, please don't worry! We will answer to all of you as soon as our domain will be available!
     
    Last edited: Apr 8, 2015
  36. Jimww

    Jimww

    Joined:
    May 14, 2013
    Posts:
    63
    I'm sorry to hear this. Do post back when you find a workaround to your support issues.
     
  37. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Of course, don't worry! As soon as the issue will be resolved. We don't want to transfer the domain to more tolerant area - we try to fight for the truth!
     
  38. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi,

    Our website is available again! So you are welcome!
     
  39. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    ATTENTION: AltSketch is no more a self-dependent project. Now it became a part of our mainstream Asset named AltSDK. AltSketch is still available on Unity Asset Store but its future development will be under the AltSDK solution. Developers who alredy have AltSketch SDK can upgrade licenses to AltSDK Full Edition on AltSoftLab or to AltSDK Unity Edition on Unity AssetStore. For more info about AltGUI project please follow to the
     
    Last edited: Jun 25, 2015
    Arisha likes this.
  40. Arisha

    Arisha

    Joined:
    Jun 13, 2014
    Posts:
    19
    Is it means no future updates for AltSketch Assets?
     
  41. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi Aricha,

    AltSketch has been developed as part of our mainstream project AltGUI more than 4 years of development. It's the multiplatform base layer of AltGUI. Some of it's GUI-related functionality moved to AltGUI. Also AltSketch SDK extensions & tools converted to AltGUI and all AltGUI SDK became .NET 2.0 Subset (unlike of some tools of old AltSketch SDK was NET 3.5) and more powerful. So it's not possible to support both old AltSketch SDK and new AltGUI. But we offer the special conditions to developers who already has the AltSketch to upgrade licenses on our website. Also anyone can upgrade Indie license to Indie Advanced or Professional.
     
  42. Arisha

    Arisha

    Joined:
    Jun 13, 2014
    Posts:
    19
    Oh, so many changes... Thanx for explanation. Looking forward to AltGUI
     
  43. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi developers,

    We also added package upgrades on AssetStore. So AltSketch SDK owners can now upgrade licenses not only to AltSDK Full Edition on AltSoftLab, but also to AltSDK Unity Edition on AssetStore. Just now available only for AltSketch Pro users. Soon will be available for Indie too (needs some price changes confirmation on AssetStore).
     
    Last edited: Dec 3, 2015
  44. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    AltSketch Upgrades to AltSDK confirmed by Asset Store and now available for AltSketch Indie users too
     
    Last edited: Dec 3, 2015
  45. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
  46. Loadus

    Loadus

    Joined:
    Nov 5, 2012
    Posts:
    15
    Hey guys,

    With the christmas holidays and some time to spare, I decided to dive into AltSDK. Can you provide a short code example that sets up AltSketch with a fullscreen texture and draws something simple on it like a line, circle, image. Without any GUI stuff, just a bitmap in memory and AltSketch drawing on it so I'll get the understanding of what the structure of the code flow is.

    There is a good amount of examples on the forums and within the SDK, but I can't make heads or tails of it without a stripped-down example.

    I have a test scene that has AltSketchPaint loaded and ready, but I have no idea what to write inside the OnPaint().

    Cheers! :)
     
  47. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    Hi Loadus,
    The base drawing tool of AltSDK is AltSketch Vector Graphics Library. In most cases of API it's like most widely used in the .NET world MS graphics GDI+ (.NET System.Drawing namespace)

    So you can use a lot of web doucumentation tutorials and books related to System.Drawing namespace. Because AltSketch has the same API. For example such info resources are:
    http://msdn.microsoft.com/en-US/en-en/library/system.drawing(v=vs.110).aspx
    http://www.codeproject.com/Articles/1355/Professional-C-Graphics-with-GDI
    http://www.c-sharpcorner.com/UploadFile/mahesh/gdi_plus12092005070041AM/gdi_plus.aspx

    Of course AltSDK contains handreds of examples you can deep look and play with.

    Brief info HowTo port System.Drawing code to AltSketch:

    AltSketch uses double arithmetic instead of float, because it has better precision. For example 0.5 in float is not 0.5. It’s 0.499999… And you must use float == 0.5f because float == 0.5 is not working. But maybe some compilers have good results. You can read a lot of web resources related to this task.
    And like in WPF we use double instead of float by default. Point, Size, Rect are double (not int). For 'int' AltSketch uses PointI, SizeI, RectI

    In porting process do by such way:
    • System.Drawing, System.Drawing.Text, System.Drawing.Imaging, System.Drawing.Drawing2D -> Alt.Sketch
    • Use full HorizontalAlignment (VerticalAlignment ) enum with full path Alt.GUI.HorizontalAlignment because HorizontalAlignment property exists (to prevent compiler names conflicts)
    • Point -> PointI
    • Size -> SizeI
    • Rectangle -> RectI
    • PointF -> Point (double)
    • SizeF -> Size (double)
    • RectangleF -> Rect (double)
    • SolidBrush -> SolidColorBrush
    • Image -> ImageSource. Image.Width -> ImageSource.PixelWidth. Image.Height -> ImageSource.PixelHeight. Image.Size -> ImageSource.PixelSize.
    • BitmapData.Scan0 is byte[]
    • Image.FromFile (.FromStream, etc.) -> Bitmap.FromFile (.FromStream, etc.)
    • Icon.FromHandle(bitmap.GetHicon()) -> Icon.FormImage(bitmap)
    • System.Windows.Forms -> Alt.GUI
    • Double arithmetics (all float -> double). Alt.GUI Control Location, Size, Bounds (etc.) – are double (not int)
    • CheckBox.Checked -> CheckBox.IsChecked. CheckButton.Checked -> CheckButton.IsChecked. RadioButton.Checked -> RadioButton.IsChecked
    • Application – object. Make it public to run in AltOS.
     
  48. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
  49. AltSoftLab

    AltSoftLab

    Joined:
    Jul 25, 2014
    Posts:
    194
    AltNETType OpenGL example. Can be useful to deeper look into multiplatform fully managed AltNETType runtime API instead of native FreeType wrappers (also look into article on CodeProject - http://www.codeproject.com/Tips/668161/Rendering-AltNETType-equals-NET-FreeType-port-with)
    Code (CSharp):
    1. public Font3D(string font, int size)
    2. {
    3.     //  Save the size we need it later on when printing
    4.  
    5.     font_size = size;
    6.     //  We begin by creating a library pointer
    7.     ANT_Library library;
    8.     ANT_Error ret = ANT.ANT_Init_AltNETType(out library);
    9.     if (ret != ANT_Error.ANT_Err_Ok)
    10.     {
    11.         return;
    12.     }
    13.     //  Once we have the library we create and load the font face
    14.     ANT_Face face;
    15.     ret = ANT.ANT_New_Face(library, font, 0, out face);
    16.     if (ret != ANT_Error.ANT_Err_Ok)
    17.     {
    18.         return;
    19.     }
    20.     //  AltNETType (as Freetype) measures the font size in 1/64th of pixels for accuracy
    21.     //  so we need to request characters in size*64
    22.     ANT.ANT_Set_Char_Size(face, size << 6, size << 6, 96, 96);
    23.     //  Provide a reasonably accurate estimate for expected pixel sizes
    24.     //  when we later on create the bitmaps for the font
    25.     ANT.ANT_Set_Pixel_Sizes(face, size, size);
    26.     //  Once we have the face loaded and sized we generate opengl textures
    27.     //  from the glyphs  for each printable character
    28.     textures = new int[128];
    29.     extent_x = new int[128];
    30.     list_base = Gl.glGenLists(128);
    31.     Gl.glGenTextures(128, textures);
    32.     for (int c = 0; c < 128; c++)
    33.     {
    34.         Compile_Character(face, c);
    35.     }
    36.     //  Dispose of these as we don't need
    37.     ANT.ANT_Done_Face(ref face);
    38.     ANT.ANT_Done_AltNETType(ref library);
    39. }
    40. public void Compile_Character(ANT_Face face, int c)
    41. {
    42.     //  We first convert the number index to a character index
    43.     int index = ANT.ANT_Get_Char_Index(face, Convert.ToChar(c));
    44.     //  Here we load the actual glyph for the character
    45.     ANT_Error ret = ANT.ANT_Load_Glyph(face, index, ANT_LOAD.ANT_LOAD_DEFAULT);
    46.     if (ret != 0) return;
    47.     //  Convert the glyph to a bitmap
    48.     ANT_Glyph glyph;
    49.     ret = ANT.ANT_Get_Glyph(face.glyph, out glyph);
    50.     if (ret != ANT_Error.ANT_Err_Ok)
    51.     {
    52.         return;
    53.     }
    54.     ANT.ANT_Glyph_To_Bitmap(ref glyph, ANT_Render_Mode.ANT_RENDER_MODE_NORMAL, null, true);
    55.     ANT_BitmapGlyph glyph_bmp = (ANT_BitmapGlyph) glyph;
    56.     int size = (glyph_bmp.bitmap.width * glyph_bmp.bitmap.rows);
    57.     if (size <= 0)
    58.     {
    59.         //  space is a special `blank` character
    60.         extent_x[c] = 0;
    61.         if (c == 32)
    62.         {
    63.             Gl.glNewList((uint)(list_base + c), Gl.GL_COMPILE);
    64.             Gl.glTranslatef(font_size >> 1, 0, 0);
    65.             extent_x[c] = font_size >> 1;
    66.             Gl.glEndList();
    67.         }
    68.         return;
    69.     }
    70.     byte[] bmp = new byte[size];
    71.     Array.Copy(glyph_bmp.bitmap.buffer, bmp, bmp.Length);
    72.     //  Next we expand the bitmap into an opengl texture        
    73.     int width = next_po2(glyph_bmp.bitmap.width);
    74.     int height = next_po2(glyph_bmp.bitmap.rows);
    75.     byte[] expanded = new byte[2 * width * height];
    76.     for (int j = 0; j < height; j++)
    77.     {
    78.         for (int i = 0; i < width; i++)
    79.         {
    80.             expanded[2 * (i + j * width)] = expanded[2 * (i + j * width) + 1] =
    81.                 (i >= glyph_bmp.bitmap.width || j >= glyph_bmp.bitmap.rows) ?
    82.                     (byte)0 : bmp[i + glyph_bmp.bitmap.width * j];
    83.         }
    84.     }
    85.     //  Set up some texture parameters for opengl
    86.     Gl.glBindTexture(Gl.GL_TEXTURE_2D, textures[c]);
    87.     Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
    88.     Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
    89.     //  Create the texture
    90.     Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, width, height,
    91.         0, Gl.GL_LUMINANCE_ALPHA, Gl.GL_UNSIGNED_BYTE, expanded);
    92.     expanded = null;
    93.     bmp = null;
    94.     //  Create a display list and bind a texture to it
    95.     Gl.glNewList((uint)(list_base + c), Gl.GL_COMPILE);
    96.     Gl.glBindTexture(Gl.GL_TEXTURE_2D, textures[c]);
    97.     //  Account for freetype spacing rules
    98.     Gl.glTranslatef(glyph_bmp.left, 0, 0);
    99.     Gl.glPushMatrix();
    100.     Gl.glTranslatef(0, glyph_bmp.top - glyph_bmp.bitmap.rows, 0);
    101.     float x = (float)glyph_bmp.bitmap.width / (float)width;
    102.     float y = (float)glyph_bmp.bitmap.rows / (float)height;
    103.     //  Draw the quad
    104.     Gl.glBegin(Gl.GL_QUADS);
    105.     Gl.glTexCoord2d(0, 0); Gl.glVertex2f(0, glyph_bmp.bitmap.rows);
    106.     Gl.glTexCoord2d(0, y); Gl.glVertex2f(0, 0);
    107.     Gl.glTexCoord2d(x, y); Gl.glVertex2f(glyph_bmp.bitmap.width, 0);
    108.     Gl.glTexCoord2d(x, 0); Gl.glVertex2f(glyph_bmp.bitmap.width, glyph_bmp.bitmap.rows);
    109.     Gl.glEnd();
    110.     Gl.glPopMatrix();
    111.     //  Advance for the next character        
    112.     Gl.glTranslatef(glyph_bmp.bitmap.width, 0, 0);
    113.     extent_x[c] = glyph_bmp.left + glyph_bmp.bitmap.width;
    114.     Gl.glEndList();
    115. }  
    AltNETType in OpenGL runtime
    [​IMG]
     
    Last edited: Apr 6, 2016