Skip to content

Commit

Permalink
Fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
rds1983 committed Jun 25, 2022
1 parent 44f7078 commit 08654dd
Show file tree
Hide file tree
Showing 42 changed files with 445 additions and 269 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-and-publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
run: dotnet test build\NvgSharp.MonoGame.sln
- name: Install NuGet
uses: NuGet/setup-nuget@v1
- name: Publish NvgSharp.Text.MonoGame to NuGet
run: nuget.exe push src\NvgSharp.Text\bin\MonoGame\Release\NvgSharp.Text.MonoGame.*.nupkg ${{secrets.NUGET_APIKEY}} -Source https://api.nuget.org/v3/index.json
- name: Publish NvgSharp.Text to NuGet
run: nuget.exe push src\NvgSharp.Text\bin\Release\NvgSharp.Text.*.nupkg ${{secrets.NUGET_APIKEY}} -Source https://api.nuget.org/v3/index.json
- name: Publish NvgSharp.MonoGame to NuGet
run: nuget.exe push src\XNA\bin\MonoGame\Release\NvgSharp.MonoGame.*.nupkg ${{secrets.NUGET_APIKEY}} -Source https://api.nuget.org/v3/index.json
- name: Publish NvgSharp to NuGet
Expand Down
16 changes: 11 additions & 5 deletions build/NvgSharp.FNA.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NvgSharp.Samples.Demo.FNA",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FontStashSharp.FNA", "..\..\FontStashSharp\src\XNA\FontStashSharp.FNA.csproj", "{4200A37F-4272-48EA-8CA7-BA5FE0BD6790}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NvgSharp.FNA", "..\src\XNA\NvgSharp.FNA.csproj", "{36BCD747-5884-499C-B686-DB3222B602E3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NvgSharp.Text.FNA", "..\src\NvgSharp.Text\NvgSharp.Text.FNA.csproj", "{A62DFB9E-0A89-4347-AA7A-2891C1C3D206}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NvgSharp.FNA", "..\src\XNA\NvgSharp.FNA.csproj", "{94601022-412B-46BD-BA20-44A8A91E2022}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -31,10 +33,14 @@ Global
{4200A37F-4272-48EA-8CA7-BA5FE0BD6790}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4200A37F-4272-48EA-8CA7-BA5FE0BD6790}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4200A37F-4272-48EA-8CA7-BA5FE0BD6790}.Release|Any CPU.Build.0 = Release|Any CPU
{36BCD747-5884-499C-B686-DB3222B602E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36BCD747-5884-499C-B686-DB3222B602E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36BCD747-5884-499C-B686-DB3222B602E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36BCD747-5884-499C-B686-DB3222B602E3}.Release|Any CPU.Build.0 = Release|Any CPU
{A62DFB9E-0A89-4347-AA7A-2891C1C3D206}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A62DFB9E-0A89-4347-AA7A-2891C1C3D206}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A62DFB9E-0A89-4347-AA7A-2891C1C3D206}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A62DFB9E-0A89-4347-AA7A-2891C1C3D206}.Release|Any CPU.Build.0 = Release|Any CPU
{94601022-412B-46BD-BA20-44A8A91E2022}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94601022-412B-46BD-BA20-44A8A91E2022}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94601022-412B-46BD-BA20-44A8A91E2022}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94601022-412B-46BD-BA20-44A8A91E2022}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions build/NvgSharp.MonoGame.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NvgSharp.MonoGame", "..\src
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NvgSharp.Samples.Demo.MonoGame", "..\samples\NvgSharp.Samples.Demo\NvgSharp.Samples.Demo.MonoGame.csproj", "{7D2336D8-D4A4-4CF0-A86C-4B904B3EF428}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NvgSharp.Text.MonoGame", "..\src\NvgSharp.Text\NvgSharp.Text.MonoGame.csproj", "{29F04FB2-43D8-4BC8-A92F-07E62F4934E1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -23,6 +25,10 @@ Global
{7D2336D8-D4A4-4CF0-A86C-4B904B3EF428}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D2336D8-D4A4-4CF0-A86C-4B904B3EF428}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D2336D8-D4A4-4CF0-A86C-4B904B3EF428}.Release|Any CPU.Build.0 = Release|Any CPU
{29F04FB2-43D8-4BC8-A92F-07E62F4934E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29F04FB2-43D8-4BC8-A92F-07E62F4934E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29F04FB2-43D8-4BC8-A92F-07E62F4934E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29F04FB2-43D8-4BC8-A92F-07E62F4934E1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions build/NvgSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NvgSharp.Samples.Silk.NET",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NvgSharp.Samples.OpenTK", "..\samples\NvgSharp.Samples.OpenTK\NvgSharp.Samples.OpenTK.csproj", "{9D43A56B-7AFB-434F-83A5-335848FCA1D9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NvgSharp.Text", "..\src\NvgSharp.Text\NvgSharp.Text.csproj", "{2CD25B57-790B-413D-9005-FF4DA59F4D13}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -29,6 +31,10 @@ Global
{9D43A56B-7AFB-434F-83A5-335848FCA1D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D43A56B-7AFB-434F-83A5-335848FCA1D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D43A56B-7AFB-434F-83A5-335848FCA1D9}.Release|Any CPU.Build.0 = Release|Any CPU
{2CD25B57-790B-413D-9005-FF4DA59F4D13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CD25B57-790B-413D-9005-FF4DA59F4D13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CD25B57-790B-413D-9005-FF4DA59F4D13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CD25B57-790B-413D-9005-FF4DA59F4D13}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
13 changes: 4 additions & 9 deletions samples/NvgSharp.Samples.Demo/Demo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Stride.Core.Mathematics;
#else
using System.Drawing;
using Texture2D = System.Object;
using Texture2D = NvgSharp.Samples.Texture;
#endif

namespace NvgSharp.Samples
Expand Down Expand Up @@ -57,8 +57,9 @@ public Demo(NvgContext vg)
imageResult = ImageResult.FromStream(stream, ColorComponents.RedGreenBlueAlpha);
}

images[i] = vg.TextureManager.CreateTexture(imageResult.Width, imageResult.Height);
vg.TextureManager.SetTextureData(images[i], new Rectangle(0, 0, imageResult.Width, imageResult.Height), imageResult.Data);
var texture = new Texture(imageResult.Width, imageResult.Height);
texture.SetData(new Rectangle(0, 0, imageResult.Width, imageResult.Height), imageResult.Data);
images[i] = texture;
#endif
}

Expand Down Expand Up @@ -529,14 +530,8 @@ public static void drawThumbnails(NvgContext vg, float x, float y, float w, floa
tx += (i % 2) * (thumb + 10);
ty += (i / 2) * (thumb + 10);

#if MONOGAME || FNA || STRIDE
imgw = images[i].Width;
imgh = images[i].Height;
#else
var sz = vg.TextureManager.GetTextureSize(images[i]);
imgw = sz.X;
imgh = sz.Y;
#endif

if (imgw < imgh)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
<OutputPath>bin\FNA\$(Configuration)</OutputPath>
<DefineConstants>$(DefineConstants);FNA</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\XNA\NvgSharp.FNA.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="..\Assets\images\image1.jpg" Link="Assets\images\image1.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down Expand Up @@ -64,4 +61,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NvgSharp.Text\NvgSharp.Text.FNA.csproj" />
<ProjectReference Include="..\..\src\XNA\NvgSharp.FNA.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NvgSharp.Text\NvgSharp.Text.MonoGame.csproj" />
<ProjectReference Include="..\..\src\XNA\NvgSharp.MonoGame.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion samples/NvgSharp.Samples.OpenTK/BufferObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;
using System.Runtime.InteropServices;

namespace NvgSharp.Samples.OpenTK
namespace NvgSharp.Samples
{
public class BufferObject<T> : IDisposable where T : unmanaged
{
Expand Down
2 changes: 1 addition & 1 deletion samples/NvgSharp.Samples.OpenTK/GLUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;


namespace NvgSharp.Samples.OpenTK
namespace NvgSharp.Samples
{
internal static class GLUtility
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NvgSharp.Text\NvgSharp.Text.csproj" />
<ProjectReference Include="..\..\src\NvgSharp\NvgSharp.csproj" />
<None Update="Shader.frag">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
21 changes: 16 additions & 5 deletions samples/NvgSharp.Samples.OpenTK/Platform/Renderer.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using FontStashSharp.Interfaces;
using OpenTK.Graphics.OpenGL4;
using System.Collections.Generic;
using System.Drawing;
using System.Numerics;

namespace NvgSharp.Samples.OpenTK
namespace NvgSharp.Samples
{
internal class Renderer : INvgRenderer
{
Expand All @@ -14,12 +15,8 @@ internal class Renderer : INvgRenderer
private readonly VertexArrayObject _vao;
private readonly bool _edgeAntiAlias, _stencilStrokes;

private readonly Texture2DManager _textureManager = new Texture2DManager();

public bool EdgeAntiAlias => _edgeAntiAlias;

public ITexture2DManager TextureManager => _textureManager;

public unsafe Renderer(bool edgeAntiAlias = true, bool stencilStrokes = true)
{
_edgeAntiAlias = edgeAntiAlias;
Expand Down Expand Up @@ -52,6 +49,20 @@ protected virtual void Dispose(bool disposing)
_shader.Dispose();
}

public object CreateTexture(int width, int height) => new Texture(width, height);

public Point GetTextureSize(object texture)
{
var t = (Texture)texture;
return new Point(t.Width, t.Height);
}

public void SetTextureData(object texture, Rectangle bounds, byte[] data)
{
var t = (Texture)texture;
t.SetData(bounds, data);
}

private void SetUniform(ref UniformInfo uniform)
{
_shader.SetUniform("scissorMat", uniform.scissorMat);
Expand Down
26 changes: 0 additions & 26 deletions samples/NvgSharp.Samples.OpenTK/Platform/Texture2DManager.cs

This file was deleted.

2 changes: 1 addition & 1 deletion samples/NvgSharp.Samples.OpenTK/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;

namespace NvgSharp.Samples.OpenTK
namespace NvgSharp.Samples
{
class Program
{
Expand Down
2 changes: 1 addition & 1 deletion samples/NvgSharp.Samples.OpenTK/Shader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Numerics;
using System.Text;

namespace NvgSharp.Samples.OpenTK
namespace NvgSharp.Samples
{
public class Shader : IDisposable
{
Expand Down
2 changes: 1 addition & 1 deletion samples/NvgSharp.Samples.OpenTK/Texture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;
using System.Drawing;

namespace NvgSharp.Samples.OpenTK
namespace NvgSharp.Samples
{
public unsafe class Texture : IDisposable
{
Expand Down
2 changes: 1 addition & 1 deletion samples/NvgSharp.Samples.OpenTK/VertexArrayObject.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using OpenTK.Graphics.OpenGL4;
using System;

namespace NvgSharp.Samples.OpenTK
namespace NvgSharp.Samples
{
public class VertexArrayObject: IDisposable
{
Expand Down
2 changes: 1 addition & 1 deletion samples/NvgSharp.Samples.OpenTK/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Diagnostics;

namespace NvgSharp.Samples.OpenTK
namespace NvgSharp.Samples
{
internal class Window : GameWindow
{
Expand Down
2 changes: 1 addition & 1 deletion samples/NvgSharp.Samples.Silk.NET/BufferObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;
using System.Runtime.InteropServices;

namespace NvgSharp.Samples.SilkNET
namespace NvgSharp.Samples
{
public class BufferObject<T> : IDisposable where T : unmanaged
{
Expand Down
2 changes: 1 addition & 1 deletion samples/NvgSharp.Samples.Silk.NET/Env.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Silk.NET.OpenGL;

namespace NvgSharp.Samples.SilkNET
namespace NvgSharp.Samples
{
internal static class Env
{
Expand Down
2 changes: 1 addition & 1 deletion samples/NvgSharp.Samples.Silk.NET/GLUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Numerics;


namespace NvgSharp.Samples.SilkNET
namespace NvgSharp.Samples
{
internal static class GLUtility
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NvgSharp.Text\NvgSharp.Text.csproj" />
<ProjectReference Include="..\..\src\NvgSharp\NvgSharp.csproj" />
<None Update="Shader.frag">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
21 changes: 16 additions & 5 deletions samples/NvgSharp.Samples.Silk.NET/Platform/Renderer.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using FontStashSharp.Interfaces;
using Silk.NET.OpenGL;
using System.Collections.Generic;
using System.Drawing;
using System.Numerics;

namespace NvgSharp.Samples.SilkNET
namespace NvgSharp.Samples
{
internal class Renderer : INvgRenderer
{
Expand All @@ -14,12 +15,8 @@ internal class Renderer : INvgRenderer
private readonly VertexArrayObject _vao;
private readonly bool _edgeAntiAlias, _stencilStrokes;

private readonly Texture2DManager _textureManager = new Texture2DManager();

public bool EdgeAntiAlias => _edgeAntiAlias;

public ITexture2DManager TextureManager => _textureManager;

public unsafe Renderer(bool edgeAntiAlias = true, bool stencilStrokes = true)
{
_edgeAntiAlias = edgeAntiAlias;
Expand Down Expand Up @@ -52,6 +49,20 @@ protected virtual void Dispose(bool disposing)
_shader.Dispose();
}

public object CreateTexture(int width, int height) => new Texture(width, height);

public Point GetTextureSize(object texture)
{
var t = (Texture)texture;
return new Point(t.Width, t.Height);
}

public void SetTextureData(object texture, Rectangle bounds, byte[] data)
{
var t = (Texture)texture;
t.SetData(bounds, data);
}

private void SetUniform(ref UniformInfo uniform)
{
_shader.SetUniform("scissorMat", uniform.scissorMat);
Expand Down
26 changes: 0 additions & 26 deletions samples/NvgSharp.Samples.Silk.NET/Platform/Texture2DManager.cs

This file was deleted.

Loading

0 comments on commit 08654dd

Please sign in to comment.