
using Godot;
using System.Collections.Generic;

namespace Rokojori
{  
  public class RG_ImageProcessor:RDShaderProcessor
  {
    public readonly CompositorEffectGraphTextureSlot input;
    public readonly CompositorEffectGraphTextureSlot output;

    public RG_ImageProcessor( RDGraph graph, string shaderPath ):base( graph, shaderPath )
    {
      input = new CompositorEffectGraphTextureSlot( this );
      output = new CompositorEffectGraphTextureSlot( this );

      _textureSlots.AddRange( new List<CompositorEffectGraphTextureSlot>{ input, output } );
    } 

    public void SetTextureSlotInputs( RDGraphTextureSlotInput inputSlot, RDGraphTextureSlotInput outputSlot )
    {
      inputSlot.ConnectTo( input );
      outputSlot.ConnectTo( output );
    }

    
    public void SetTextureSlotInputs( RG_ImageProcessor imageProcessorBefore )
    {
      imageProcessorBefore.input.ConnectTo( input );
      imageProcessorBefore.output.ConnectTo( output );
    }

    public CompositorEffectGraphTextureSlot AddTextureSlotInput( RDGraphTextureSlotInput inputSlot, CompositorEffectGraphTextureSlot slot = null )
    {
      slot = slot != null ? slot : new CompositorEffectGraphTextureSlot( this );
      _textureSlots.Add( slot );

      inputSlot.ConnectTo( slot );

      return slot;
    }

    public void AddSampledTextureSlotInput( RDGraphTextureSlotInput inputSlot, RenderingDevice.SamplerFilter filter = RenderingDevice.SamplerFilter.Linear, RenderingDevice.SamplerRepeatMode repeatMode = RenderingDevice.SamplerRepeatMode.Repeat )
    {
      var slot = new CompositorEffectGraphTextureSlot( this );
      slot.UseSampler( filter, repeatMode );
      _textureSlots.Add( slot );
      inputSlot.ConnectTo( slot );
    }


    
  }
}