From 55d8e5a1dfe24f5e75ebee3ac1fb0eea456db7d8 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Thu, 28 Jan 2021 18:07:48 -0800 Subject: [PATCH] remove FileInfo references --- src/Audio/StaticSound.cs | 4 ++-- src/Audio/StreamingSoundOgg.cs | 6 +++--- src/Graphics/Resources/ShaderModule.cs | 8 +++++--- src/Graphics/Resources/Texture.cs | 4 ++-- src/Graphics/Utility/Bytecode.cs | 4 ++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Audio/StaticSound.cs b/src/Audio/StaticSound.cs index 664b5be0..b27a9529 100644 --- a/src/Audio/StaticSound.cs +++ b/src/Audio/StaticSound.cs @@ -16,9 +16,9 @@ namespace MoonWorks.Audio private bool IsDisposed; - public static StaticSound LoadOgg(AudioDevice device, FileInfo fileInfo) + public static StaticSound LoadOgg(AudioDevice device, string filePath) { - var filePointer = FAudio.stb_vorbis_open_filename(fileInfo.FullName, out var error, IntPtr.Zero); + var filePointer = FAudio.stb_vorbis_open_filename(filePath, out var error, IntPtr.Zero); if (error != 0) { diff --git a/src/Audio/StreamingSoundOgg.cs b/src/Audio/StreamingSoundOgg.cs index 9bec5396..49c9ad9d 100644 --- a/src/Audio/StreamingSoundOgg.cs +++ b/src/Audio/StreamingSoundOgg.cs @@ -18,12 +18,12 @@ namespace MoonWorks.Audio private bool IsDisposed; public static StreamingSoundOgg Load( - AudioDevice device, - FileInfo fileInfo, + AudioDevice device, + string filePath, bool is3D = false, bool loop = false ) { - var fileHandle = FAudio.stb_vorbis_open_filename(fileInfo.FullName, out var error, IntPtr.Zero); + var fileHandle = FAudio.stb_vorbis_open_filename(filePath, out var error, IntPtr.Zero); if (error != 0) { Logger.LogError("Error opening OGG file!"); diff --git a/src/Graphics/Resources/ShaderModule.cs b/src/Graphics/Resources/ShaderModule.cs index 65824c36..255b147f 100644 --- a/src/Graphics/Resources/ShaderModule.cs +++ b/src/Graphics/Resources/ShaderModule.cs @@ -8,12 +8,14 @@ namespace MoonWorks.Graphics { protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyShaderModule; - public unsafe ShaderModule(GraphicsDevice device, FileInfo fileInfo) : base(device) + public unsafe ShaderModule(GraphicsDevice device, string filePath) : base(device) { - fixed (uint* ptr = Bytecode.ReadBytecodeAsUInt32(fileInfo)) + var bytecode = Bytecode.ReadBytecodeAsUInt32(filePath); + + fixed (uint* ptr = bytecode) { Refresh.ShaderModuleCreateInfo shaderModuleCreateInfo; - shaderModuleCreateInfo.codeSize = (UIntPtr) fileInfo.Length; + shaderModuleCreateInfo.codeSize = (UIntPtr) (bytecode.Length * sizeof(uint)); shaderModuleCreateInfo.byteCode = (IntPtr) ptr; Handle = Refresh.Refresh_CreateShaderModule(device.Handle, shaderModuleCreateInfo); diff --git a/src/Graphics/Resources/Texture.cs b/src/Graphics/Resources/Texture.cs index 3211e647..9e3d3998 100644 --- a/src/Graphics/Resources/Texture.cs +++ b/src/Graphics/Resources/Texture.cs @@ -13,10 +13,10 @@ namespace MoonWorks.Graphics protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyTexture; - public static Texture LoadPNG(GraphicsDevice device, FileInfo fileInfo) + public static Texture LoadPNG(GraphicsDevice device, string filePath) { var pixels = Refresh.Refresh_Image_Load( - fileInfo.FullName, + filePath, out var width, out var height, out var channels diff --git a/src/Graphics/Utility/Bytecode.cs b/src/Graphics/Utility/Bytecode.cs index 30d2a3b3..e64091e0 100644 --- a/src/Graphics/Utility/Bytecode.cs +++ b/src/Graphics/Utility/Bytecode.cs @@ -4,11 +4,11 @@ namespace MoonWorks.Graphics { public static class Bytecode { - public static uint[] ReadBytecodeAsUInt32(FileInfo fileInfo) + public static uint[] ReadBytecodeAsUInt32(string filePath) { byte[] data; int size; - using (FileStream stream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read)) + using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { size = (int)stream.Length; data = new byte[size];