Skip to content

Commit

Permalink
839: fix Android and iOS examples
Browse files Browse the repository at this point in the history
  • Loading branch information
prepare committed Feb 8, 2019
1 parent 368c50e commit ba450a2
Show file tree
Hide file tree
Showing 16 changed files with 1,709 additions and 1,691 deletions.
4 changes: 0 additions & 4 deletions Demo/Android/Xamarin.OpenGL/Xamarin.OpenGL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@
<Project>{280d17d5-4435-4ead-839a-33c5a8990e7e}</Project>
<Name>Typography.OpenFont</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\x_autogen2\PixelFarm.MiniAgg.One\PixelFarm.MiniAgg.One.csproj">
<Project>{fb5f78f5-c921-405d-8f21-42f7c15c2ad9}</Project>
<Name>PixelFarm.MiniAgg.One</Name>
</ProjectReference>
</ItemGroup>
<Import Project="..\..\Shared\DrawingGL.Common.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
Expand Down
1 change: 0 additions & 1 deletion Demo/Shared/DrawingGL.Common.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Tesselate\HalfEdge.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tesselate\MaxFirstList.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tesselate\mesh.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tesselate\Tesselator.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Tesselate\" />
Expand Down
21 changes: 11 additions & 10 deletions Demo/Shared/DrawingGL.Text/TextPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Typography.OpenFont;
using Typography.TextLayout;
using Typography.Contours;
using Tesselate;

namespace DrawingGL.Text
{
Expand All @@ -23,19 +24,19 @@ class TextPrinter : TextPrinterBase
// for tess
//
SimpleCurveFlattener _curveFlattener;
TessTool _tessTool;
Tesselate.TessTool _tessTool;

Typeface _currentTypeface;

//-------------
struct ProcessedGlyph
{
public readonly float[] tessData;
public readonly ushort tessNElements;
public ProcessedGlyph(float[] tessData, ushort tessNElements)
public readonly ushort vertextCount;
public ProcessedGlyph(float[] tessData, ushort vertextCount)
{
this.tessData = tessData;
this.tessNElements = tessNElements;
this.vertextCount = vertextCount;
}
}
GlyphMeshCollection<ProcessedGlyph> _glyphMeshCollection = new GlyphMeshCollection<ProcessedGlyph>();
Expand All @@ -48,7 +49,7 @@ public TextPrinter()
//
_curveFlattener = new SimpleCurveFlattener();

_tessTool = new TessTool();
_tessTool = new Tesselate.TessTool();
}


Expand Down Expand Up @@ -181,17 +182,17 @@ public void GenerateGlyphRuns(TextRun outputTextRun, char[] charBuffer, int star
//do tess
int[] endContours;
float[] flattenPoints = _curveFlattener.Flatten(writablePath._points, out endContours);
int nTessElems;
tessData = _tessTool.TessPolygon(flattenPoints, endContours, out nTessElems);
//-------
processGlyph = new ProcessedGlyph(tessData, (ushort)nTessElems);

tessData = _tessTool.TessAsTriVertexArray(flattenPoints, endContours, out int vertexCount);
processGlyph = new ProcessedGlyph(tessData, (ushort)vertexCount);

_glyphMeshCollection.RegisterCachedGlyph(glyphPlan.glyphIndex, processGlyph);
}

outputTextRun.AddGlyph(
new GlyphRun(glyphPlan,
processGlyph.tessData,
processGlyph.tessNElements));
processGlyph.vertextCount));
}
}
public override void DrawString(char[] textBuffer, int startAt, int len, float x, float y)
Expand Down
10 changes: 5 additions & 5 deletions Demo/Shared/DrawingGL/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ public struct GlyphRun
//glyph run contains...
//1.
Typography.TextLayout.UnscaledGlyphPlan _glyphPlan; //10 bytes
public float[] tessData; //4
public ushort nTessElements;//2
internal GlyphRun(Typography.TextLayout.UnscaledGlyphPlan glyphPlan, float[] tessData, ushort nTessElements)
public float[] _tessData; //4
public ushort _vertextCount;
internal GlyphRun(Typography.TextLayout.UnscaledGlyphPlan glyphPlan, float[] tessData, ushort vertextCount)
{
_glyphPlan = glyphPlan;
this.tessData = tessData;
this.nTessElements = nTessElements;
_tessData = tessData;
_vertextCount = vertextCount;
}
public Typography.TextLayout.UnscaledGlyphPlan GlyphPlan => _glyphPlan;

Expand Down
8 changes: 4 additions & 4 deletions Demo/Shared/DrawingGL/SimpleCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class SimpleCanvas
MyMat4 _flipVerticalView;
MyMat4 _orthoAndFlip;

TessTool _tessTool;
Tesselate.TessTool _tessTool;
SimpleCurveFlattener _curveFlattener;
//---------------------------------
CanvasToShaderSharedResource _shaderRes;
Expand Down Expand Up @@ -56,7 +56,7 @@ public SimpleCanvas(int view_width, int view_height)
//------------
//tools
Tesselate.Tesselator tt = new Tesselate.Tesselator();
_tessTool = new TessTool(tt);
_tessTool = new Tesselate.TessTool(tt);
_curveFlattener = new SimpleCurveFlattener();
ClearColor = Color.White;
//--------
Expand Down Expand Up @@ -133,8 +133,8 @@ public void FillTextRun(TextRun textRun, float x, float y)


_fillShader.FillTriangles(
run.tessData,
run.nTessElements,
run._tessData,
run._vertextCount ,
this.FillColor
);
}
Expand Down
Loading

0 comments on commit ba450a2

Please # to comment.