From c54be51fa92850e5c108c43d76d80b7120872cc9 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Tue, 5 Jan 2021 16:25:30 -0800 Subject: [PATCH] init and draw functions --- Refresh.cs | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/Refresh.cs b/Refresh.cs index 64ed918..d06939f 100644 --- a/Refresh.cs +++ b/Refresh.cs @@ -66,7 +66,7 @@ namespace RefreshSharp DontCare } - public enum ClearOptions + public enum ClearOptionsBits { Color = 1, Depth = 2, @@ -580,11 +580,99 @@ namespace RefreshSharp public struct FramebufferCreateInfo { public IntPtr renderPass; - public IntPtr pColorTargets; + public IntPtr[] pColorTargets; public uint colorTargetCount; public IntPtr depthStencilTarget; public uint width; public uint height; } + + /* Logging */ + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void Refresh_LogFunc(IntPtr msg); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Refresh_HookLogFunctions( + Refresh_LogFunc info, + Refresh_LogFunc warn, + Refresh_LogFunc error + ); + + /* Init/Quit */ + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr Refresh_CreateDevice( + ref PresentationParameters presentationParameters, + byte debugMode + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Refresh_DestroyDevice(IntPtr device); + + /* Drawing */ + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Refresh_Clear( + IntPtr device, + IntPtr commandBuffer, + ref Rect clearRect, + uint clearOptions, + ref Color[] colors, + uint colorCount, + float depth, + int stencil + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Refresh_DrawInstancedPrimitives( + IntPtr device, + IntPtr commandBuffer, + uint baseVertex, + uint minVertexIndex, + uint numVertices, + uint startIndex, + uint primitiveCount, + uint instanceCount, + IntPtr indices, /* Refresh_Buffer */ + IndexElementSize indexElementSize, + uint vertexParamOffset, + uint fragmentParamOffset + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Refresh_DrawIndexedPrimitives( + IntPtr device, + IntPtr commandBuffer, + uint baseverrtex, + uint minVertexIndex, + uint numVertices, + uint startIndex, + uint primitiveCount, + IntPtr indices, /* Refresh_Buffer */ + IndexElementSize indexElementSize, + uint vertexParamOffset, + uint fragmentParamOffset + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Refresh_DrawPrimitives( + IntPtr device, + IntPtr commandBuffer, + uint vertexStart, + uint primitiveCount, + uint vertexParamOffset, + uint fragmentParamOffset + ); + + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void Refresh_DispatchCompute( + IntPtr device, + IntPtr commandBuffer, + uint groupCountX, + uint groupCountY, + uint groupCountZ, + uint computeParamOffset + ); } }