ImageUtilities.cs: linear texture support

This commit is contained in:
JohnCorby 2023-04-20 18:32:56 -07:00
parent e9aebd9924
commit 04ccd8c883

View File

@ -28,7 +28,10 @@ namespace NewHorizons.Utility.Files
return _loadedTextures.ContainsKey(path);
}
public static Texture2D GetTexture(IModBehaviour mod, string filename, bool useMipmaps = true, bool wrap = false)
// needed for backwards compat :P
public static Texture2D GetTexture(IModBehaviour mod, string filename, bool useMipmaps, bool wrap) => GetTexture(mod, filename, useMipmaps, wrap, false);
// bug: cache only considers file path, not wrap/mips/linear. oh well
public static Texture2D GetTexture(IModBehaviour mod, string filename, bool useMipmaps = true, bool wrap = false, bool linear = false)
{
// Copied from OWML but without the print statement lol
var path = Path.Combine(mod.ModHelper.Manifest.ModFolderPath, filename);
@ -42,7 +45,7 @@ namespace NewHorizons.Utility.Files
try
{
var data = File.ReadAllBytes(path);
var texture = new Texture2D(2, 2, TextureFormat.RGBA32, useMipmaps);
var texture = new Texture2D(2, 2, TextureFormat.RGBA32, useMipmaps, linear);
texture.name = Path.GetFileNameWithoutExtension(path);
texture.wrapMode = wrap ? TextureWrapMode.Repeat : TextureWrapMode.Clamp;
texture.LoadImage(data);