remove FileInfo references

main
cosmonaut 2021-01-28 18:07:48 -08:00
parent eda1efedbe
commit 55d8e5a1df
5 changed files with 14 additions and 12 deletions

View File

@ -16,9 +16,9 @@ namespace MoonWorks.Audio
private bool IsDisposed; 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) if (error != 0)
{ {

View File

@ -19,11 +19,11 @@ namespace MoonWorks.Audio
public static StreamingSoundOgg Load( public static StreamingSoundOgg Load(
AudioDevice device, AudioDevice device,
FileInfo fileInfo, string filePath,
bool is3D = false, bool is3D = false,
bool loop = 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) if (error != 0)
{ {
Logger.LogError("Error opening OGG file!"); Logger.LogError("Error opening OGG file!");

View File

@ -8,12 +8,14 @@ namespace MoonWorks.Graphics
{ {
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyShaderModule; protected override Action<IntPtr, IntPtr> 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; Refresh.ShaderModuleCreateInfo shaderModuleCreateInfo;
shaderModuleCreateInfo.codeSize = (UIntPtr) fileInfo.Length; shaderModuleCreateInfo.codeSize = (UIntPtr) (bytecode.Length * sizeof(uint));
shaderModuleCreateInfo.byteCode = (IntPtr) ptr; shaderModuleCreateInfo.byteCode = (IntPtr) ptr;
Handle = Refresh.Refresh_CreateShaderModule(device.Handle, shaderModuleCreateInfo); Handle = Refresh.Refresh_CreateShaderModule(device.Handle, shaderModuleCreateInfo);

View File

@ -13,10 +13,10 @@ namespace MoonWorks.Graphics
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyTexture; protected override Action<IntPtr, IntPtr> 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( var pixels = Refresh.Refresh_Image_Load(
fileInfo.FullName, filePath,
out var width, out var width,
out var height, out var height,
out var channels out var channels

View File

@ -4,11 +4,11 @@ namespace MoonWorks.Graphics
{ {
public static class Bytecode public static class Bytecode
{ {
public static uint[] ReadBytecodeAsUInt32(FileInfo fileInfo) public static uint[] ReadBytecodeAsUInt32(string filePath)
{ {
byte[] data; byte[] data;
int size; 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; size = (int)stream.Length;
data = new byte[size]; data = new byte[size];