using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework.Graphics;
using SharpGLTF.Schema2;
using GLTFMATERIAL = SharpGLTF.Schema2.Material;
namespace SharpGLTF.Runtime.Pipeline
{
///
/// Converts glTF materials into MonoGame effects
///
public abstract class EffectsFactory
{
#region lifecycle
///
/// Register here your own derived class to override effects creation
///
public static Func InstanceBuilder { get; set; }
public static EffectsFactory Create(GraphicsDevice device, GraphicsResourceTracker disposables, TextureFactory textureFactory = null)
{
ArgumentNullException.ThrowIfNull(device);
ArgumentNullException.ThrowIfNull(disposables);
textureFactory ??= TextureFactory.Create(device, disposables);
var ef = InstanceBuilder?.Invoke(device, disposables, textureFactory);
ef ??= new DefaultEffectsFactory(device, disposables, textureFactory);
return ef;
}
protected EffectsFactory(GraphicsDevice device, GraphicsResourceTracker disposables, TextureFactory textureFactory)
{
_Device = device;
_TexFactory = textureFactory;
_Disposables = disposables;
}
#endregion
#region data
private readonly GraphicsDevice _Device;
private readonly TextureFactory _TexFactory;
private readonly GraphicsResourceTracker _Disposables;
// effects cache
private readonly Dictionary