Skip to content

Guide: Loading textures

Alan Stagner edited this page Jun 9, 2020 · 1 revision

BNA wraps FNA3D internally, which includes the stb_image library, so BNA can load any image format that stb_image supports (PNG, JPG, GIF, TGA, etc). Loading 2D textures is simple:

using BNA.Graphics;

// ...

Texture2D myTexture;
if(Texture2D.Load(graphicsDevice, "./Content/Images/myTexture.jpg") case .Ok(let texture))
{
    // texture is loaded!
    myTexture = texture;
}

You can optionally pass a "mipmap" param. If true, BNA will automatically generate mipmap levels for that texture.