Last active
June 18, 2021 14:26
-
-
Save kant2002/96c6bc8c870cc5a26dba037c82340cdd to your computer and use it in GitHub Desktop.
DirectX and NativeAOT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsafe partial class DirectXComWrappers : ComWrappers | |
{ | |
protected override unsafe ComInterfaceEntry* ComputeVtables(object obj, CreateComInterfaceFlags flags, out int count) | |
{ | |
throw new NotImplementedException(); | |
} | |
protected override object CreateObject(IntPtr externalComObject, CreateObjectFlags flags) | |
{ | |
return new UniversalWrapper(externalComObject); | |
} | |
protected override void ReleaseObjects(IEnumerable objects) | |
{ | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Magic line to break your application. | |
ComWrappers.RegisterForMarshalling(new DirectXComWrappers()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[RuntimeCallableWrapper(typeof(WInterop.Direct2d.IFactory))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[RuntimeCallableWrapper(typeof(WInterop.Direct2d.IFactory))] | |
[RuntimeCallableWrapper(typeof(WInterop.Direct2d.IGeometry))] | |
[RuntimeCallableWrapper(typeof(WInterop.DirectWrite.IRenderingParams))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[RuntimeCallableWrapper(typeof(WInterop.Direct2d.IFactory))] | |
[RuntimeCallableWrapper(typeof(WInterop.Direct2d.IGeometry))] | |
[RuntimeCallableWrapper(typeof(WInterop.DirectWrite.IRenderingParams))] | |
[RuntimeCallableWrapper(typeof(WInterop.Direct2d.IStrokeStyle))] | |
[RuntimeCallableWrapper(typeof(WInterop.Direct2d.ISimplifiedGeometrySink))] | |
[RuntimeCallableWrapper(typeof(WInterop.Direct2d.ITesselationSink))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[System.Runtime.Versioning.SupportedOSPlatform("windows")] | |
internal sealed partial class UniversalWrapper : IDisposable | |
{ | |
private readonly IntPtr instance; | |
public UniversalWrapper(IntPtr instance) | |
{ | |
this.instance = instance; | |
Marshal.AddRef(instance); | |
} | |
public void Dispose() | |
{ | |
Marshal.Release(instance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment