Fexty12573 / SharpPluginLoader

A C# plugin loader for Monster Hunter World
MIT License
32 stars 2 forks source link

Texture loading #27

Closed Fexty12573 closed 6 months ago

Fexty12573 commented 6 months ago

Loading arbitrary images/textures + game textures for displaying with ImGui.

The API looks as follows:

var texture = Renderer.LoadTexture("path/to/texture.png", out var w, out var h);
if (texture == TextureHandle.Invalid)
{
    Log.Error("Failed to load texture"); // Check console for more error messages
}

// ...

ImGui.Image(texture, w, h);

The procedure for game textures is similar:

var texture = ResourceManager.GetResource<Texture>(@"em\em001\00\mod\em001_00_BML", MtDti.Find("rTexture")!);
if (texture is null)
{
    Log.Error("Failed to load texture");
    return;
}

var texHandle = texture.GetTextureHandle();
if (texture == TextureHandle.Invalid)
{
    Log.Error("Failed to obtain texture handle"); // Check console for more error messages
}

// ...

ImGui.Image(texHandle, texture.Width, texture.Height);

Currently supported formats are: