initial commit
commit
d8b94d539d
|
@ -0,0 +1,2 @@
|
||||||
|
bin
|
||||||
|
obj
|
|
@ -0,0 +1,145 @@
|
||||||
|
/* WellspringCS - C# bindings for the Wellspring font rendering Library
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022 Evan Hemsley
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
* In no event will the authors be held liable for any damages arising from
|
||||||
|
* the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software in a
|
||||||
|
* product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*
|
||||||
|
* Evan "cosmonaut" Hemsley <evan@moonside.games>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace WellspringCS
|
||||||
|
{
|
||||||
|
public static class Wellspring
|
||||||
|
{
|
||||||
|
private const string nativeLibName = "Wellspring";
|
||||||
|
|
||||||
|
// Version
|
||||||
|
|
||||||
|
public const uint WELLSPRING_MAJOR_VERSION = 0;
|
||||||
|
public const uint WELLSPRING_MINOR_VERSION = 1;
|
||||||
|
public const uint WELLSPRING_PATCH_VERSION = 0;
|
||||||
|
|
||||||
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern uint Wellspring_LinkedVersion();
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct FontRange
|
||||||
|
{
|
||||||
|
uint FontSize;
|
||||||
|
uint FirstCodepoint;
|
||||||
|
uint NumChars;
|
||||||
|
byte OversampleH;
|
||||||
|
byte OversampleV;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct Color
|
||||||
|
{
|
||||||
|
public byte R;
|
||||||
|
public byte G;
|
||||||
|
public byte B;
|
||||||
|
public byte A;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct Vertex
|
||||||
|
{
|
||||||
|
float X;
|
||||||
|
float Y;
|
||||||
|
float Z;
|
||||||
|
float U;
|
||||||
|
float V;
|
||||||
|
byte R;
|
||||||
|
byte G;
|
||||||
|
byte B;
|
||||||
|
byte A;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern IntPtr Wellspring_CreatePacker(
|
||||||
|
IntPtr fontBytes,
|
||||||
|
uint fontBytesLength,
|
||||||
|
uint width,
|
||||||
|
uint height,
|
||||||
|
uint strideInBytes,
|
||||||
|
uint padding
|
||||||
|
);
|
||||||
|
|
||||||
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern uint Wellspring_PackFontRanges(
|
||||||
|
IntPtr packer,
|
||||||
|
IntPtr ranges, /* FontRange array */
|
||||||
|
uint numRanges
|
||||||
|
);
|
||||||
|
|
||||||
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void Wellspring_GetPixels(
|
||||||
|
IntPtr packer,
|
||||||
|
IntPtr pData /* byte array */
|
||||||
|
);
|
||||||
|
|
||||||
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern IntPtr Wellspring_CreateTextBatch();
|
||||||
|
|
||||||
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void Wellspring_StartTextBatch(
|
||||||
|
IntPtr packer
|
||||||
|
);
|
||||||
|
|
||||||
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern byte Wellspring_Draw(
|
||||||
|
IntPtr textBatch,
|
||||||
|
IntPtr packer,
|
||||||
|
float x,
|
||||||
|
float y,
|
||||||
|
float depth,
|
||||||
|
in Color color,
|
||||||
|
IntPtr strBytes, /* UTF-8 bytes */
|
||||||
|
uint strLengthInBytes
|
||||||
|
);
|
||||||
|
|
||||||
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void Wellspring_GetBufferLengths(
|
||||||
|
IntPtr textBatch,
|
||||||
|
out uint vertexCount,
|
||||||
|
out uint indexCount
|
||||||
|
);
|
||||||
|
|
||||||
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void Wellspring_GetBuffers(
|
||||||
|
IntPtr textBatch,
|
||||||
|
IntPtr vertexBuffer, /* Vertex array */
|
||||||
|
IntPtr indexBuffer /* uint array */
|
||||||
|
);
|
||||||
|
|
||||||
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void Wellspring_DestroyTextBatch(
|
||||||
|
IntPtr textBatch
|
||||||
|
);
|
||||||
|
|
||||||
|
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
public static extern void Wellspring_DestroyPacker(
|
||||||
|
IntPtr packer
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<RootNamespace>WellspringCS</RootNamespace>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<Platforms>x64</Platforms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="WellspringCS.dll.config">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<dllmap dll="Refresh" os="windows" target="Wellspring.dll"/>
|
||||||
|
<dllmap dll="Refresh" os="osx" target="libWellspring.0.dylib"/>
|
||||||
|
<dllmap dll="Refresh" os="linux,freebsd,netbsd" target="libWellspring.so.0"/>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.30114.105
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WellspringCS", "WellspringCS.csproj", "{E0467A8A-5830-46EF-B4C6-A8E96CB18D0B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{E0467A8A-5830-46EF-B4C6-A8E96CB18D0B}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||||
|
{E0467A8A-5830-46EF-B4C6-A8E96CB18D0B}.Debug|Any CPU.Build.0 = Debug|x64
|
||||||
|
{E0467A8A-5830-46EF-B4C6-A8E96CB18D0B}.Release|Any CPU.ActiveCfg = Release|x64
|
||||||
|
{E0467A8A-5830-46EF-B4C6-A8E96CB18D0B}.Release|Any CPU.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
Loading…
Reference in New Issue