mirror of
https://github.com/maxartz15/MoonWorksDearImGuiScaffold.git
synced 2024-12-22 15:38:28 +01:00
Refresh2 changes
This commit is contained in:
parent
9d8f4f6089
commit
0cbf877de3
@ -8,19 +8,19 @@
|
||||
<ItemGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))">
|
||||
<Content Include=".\moonlibs\x64\**\*.*">
|
||||
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))">
|
||||
<Content Include=".\moonlibs\lib64\**\*.*">
|
||||
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))">
|
||||
<Content Include=".\moonlibs\osx\**\*.*" >
|
||||
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 4dbd5a2cbeab38f78274644f3b44fe1fa727f304
|
||||
Subproject commit 178a5ea3cfa4ce4ccbcd9e0b6726a8cda791c810
|
BIN
moonlibs/x64/Refresh.dll
(Stored with Git LFS)
BIN
moonlibs/x64/Refresh.dll
(Stored with Git LFS)
Binary file not shown.
@ -19,11 +19,13 @@ class MoonWorksDearImGuiScaffoldGame : Game
|
||||
|
||||
private uint VertexCount = 0;
|
||||
private uint IndexCount = 0;
|
||||
private MoonWorks.Graphics.Buffer ImGuiVertexBuffer = null;
|
||||
private MoonWorks.Graphics.Buffer ImGuiIndexBuffer = null;
|
||||
private GpuBuffer ImGuiVertexBuffer = null;
|
||||
private GpuBuffer ImGuiIndexBuffer = null;
|
||||
|
||||
private TextureStorage TextureStorage;
|
||||
|
||||
private ResourceUploader ResourceUploader;
|
||||
|
||||
public MoonWorksDearImGuiScaffoldGame(
|
||||
WindowCreateInfo windowCreateInfo,
|
||||
FrameLimiterSettings frameLimiterSettings,
|
||||
@ -31,6 +33,7 @@ class MoonWorksDearImGuiScaffoldGame : Game
|
||||
) : base(windowCreateInfo, frameLimiterSettings, 60, debugMode)
|
||||
{
|
||||
TextureStorage = new TextureStorage();
|
||||
ResourceUploader = new ResourceUploader(GraphicsDevice);
|
||||
|
||||
ImGui.CreateContext();
|
||||
|
||||
@ -177,7 +180,7 @@ class MoonWorksDearImGuiScaffoldGame : Game
|
||||
ImGuiVertexBuffer?.Dispose();
|
||||
|
||||
VertexCount = (uint)(drawDataPtr.TotalVtxCount * 1.5f);
|
||||
ImGuiVertexBuffer = MoonWorks.Graphics.Buffer.Create<Position2DTextureColorVertex>(
|
||||
ImGuiVertexBuffer = GpuBuffer.Create<Position2DTextureColorVertex>(
|
||||
GraphicsDevice,
|
||||
BufferUsageFlags.Vertex,
|
||||
VertexCount
|
||||
@ -189,7 +192,7 @@ class MoonWorksDearImGuiScaffoldGame : Game
|
||||
ImGuiIndexBuffer?.Dispose();
|
||||
|
||||
IndexCount = (uint)(drawDataPtr.TotalIdxCount * 1.5f);
|
||||
ImGuiIndexBuffer = MoonWorks.Graphics.Buffer.Create<ushort>(
|
||||
ImGuiIndexBuffer = GpuBuffer.Create<ushort>(
|
||||
GraphicsDevice,
|
||||
BufferUsageFlags.Index,
|
||||
IndexCount
|
||||
@ -203,24 +206,24 @@ class MoonWorksDearImGuiScaffoldGame : Game
|
||||
{
|
||||
var cmdList = drawDataPtr.CmdLists[n];
|
||||
|
||||
commandBuffer.SetBufferData<Position2DTextureColorVertex>(
|
||||
ResourceUploader.SetBufferData(
|
||||
ImGuiVertexBuffer,
|
||||
cmdList.VtxBuffer.Data,
|
||||
vertexOffset,
|
||||
(uint)cmdList.VtxBuffer.Size
|
||||
new Span<Position2DTextureColorVertex>((void*) cmdList.VtxBuffer.Data, cmdList.VtxBuffer.Size)
|
||||
);
|
||||
|
||||
commandBuffer.SetBufferData<ushort>(
|
||||
ResourceUploader.SetBufferData(
|
||||
ImGuiIndexBuffer,
|
||||
cmdList.IdxBuffer.Data,
|
||||
indexOffset,
|
||||
(uint)cmdList.IdxBuffer.Size
|
||||
new Span<ushort>((void*) cmdList.IdxBuffer.Data, cmdList.IdxBuffer.Size)
|
||||
);
|
||||
|
||||
vertexOffset += (uint)cmdList.VtxBuffer.Size;
|
||||
indexOffset += (uint)cmdList.IdxBuffer.Size;
|
||||
vertexOffset += (uint) cmdList.VtxBuffer.Size;
|
||||
indexOffset += (uint) cmdList.IdxBuffer.Size;
|
||||
}
|
||||
|
||||
ResourceUploader.Upload();
|
||||
|
||||
GraphicsDevice.Submit(commandBuffer);
|
||||
}
|
||||
|
||||
@ -249,7 +252,7 @@ class MoonWorksDearImGuiScaffoldGame : Game
|
||||
|
||||
commandBuffer.BindGraphicsPipeline(ImGuiPipeline);
|
||||
|
||||
var vertexUniformOffset = commandBuffer.PushVertexShaderUniforms(
|
||||
commandBuffer.PushVertexShaderUniforms(
|
||||
Matrix4x4.CreateOrthographicOffCenter(0, ioPtr.DisplaySize.X, ioPtr.DisplaySize.Y, 0, -1, 1)
|
||||
);
|
||||
|
||||
@ -294,9 +297,7 @@ class MoonWorksDearImGuiScaffoldGame : Game
|
||||
commandBuffer.DrawIndexedPrimitives(
|
||||
vertexOffset,
|
||||
indexOffset,
|
||||
drawCmd.ElemCount / 3,
|
||||
vertexUniformOffset,
|
||||
0
|
||||
drawCmd.ElemCount / 3
|
||||
);
|
||||
|
||||
indexOffset += drawCmd.ElemCount;
|
||||
@ -308,9 +309,9 @@ class MoonWorksDearImGuiScaffoldGame : Game
|
||||
commandBuffer.EndRenderPass();
|
||||
}
|
||||
|
||||
private void BuildFontAtlas()
|
||||
private unsafe void BuildFontAtlas()
|
||||
{
|
||||
var commandBuffer = GraphicsDevice.AcquireCommandBuffer();
|
||||
var resourceUploader = new ResourceUploader(GraphicsDevice);
|
||||
|
||||
var io = ImGui.GetIO();
|
||||
|
||||
@ -321,17 +322,14 @@ class MoonWorksDearImGuiScaffoldGame : Game
|
||||
out int bytesPerPixel
|
||||
);
|
||||
|
||||
var fontTexture = Texture.CreateTexture2D(
|
||||
GraphicsDevice,
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
TextureFormat.R8G8B8A8,
|
||||
TextureUsageFlags.Sampler
|
||||
var fontTexture = resourceUploader.CreateTexture2D(
|
||||
new Span<byte>((void*) pixelData, width * height * bytesPerPixel),
|
||||
(uint) width,
|
||||
(uint) height
|
||||
);
|
||||
|
||||
commandBuffer.SetTextureData(fontTexture, pixelData, (uint)(width * height * bytesPerPixel));
|
||||
|
||||
GraphicsDevice.Submit(commandBuffer);
|
||||
resourceUploader.Upload();
|
||||
resourceUploader.Dispose();
|
||||
|
||||
io.Fonts.SetTexID(fontTexture.Handle);
|
||||
io.Fonts.ClearTexData();
|
||||
|
Loading…
Reference in New Issue
Block a user