
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System;
using Godot;


// https://github.com/jamesdimick/godot-compositor-effect-csharp-test/blob/main/TestCompositorEffect.cs
// https://github.com/txnsor/godot-datamosher/blob/main/shaders/datamosher.glsl
// https://github.com/DevPoodle/godot-compositor-outline/blob/main/outline_effect.gd

namespace Rokojori
{  
  [Tool]
  [GlobalClass]
  public partial class SilhouetteOutlineCompositer:CompositorEffect
  {
    RenderingDevice renderingDevice;
    Rid frameBuffer;

    public void _Init()
    {      
      EffectCallbackType = EffectCallbackTypeEnum.PostOpaque;
      renderingDevice = RenderingServer.GetRenderingDevice();

    }

    public override void _Notification(int what)
    {

    }

    public override void _RenderCallback( int effectCallbackType, RenderData renderData )
    {
      if ( renderingDevice == null || effectCallbackType != (int) EffectCallbackTypeEnum.PostOpaque )
      {
        return;
      }

      var renderBuffers = (RenderSceneBuffersRD) renderData.GetRenderSceneBuffers();

      if ( renderBuffers == null )
      {
        return;
      }

      var size = renderBuffers.GetInternalSize();

      if ( size.X == 0 || size.Y == 0 )
      {
        return;
      }

      var groups = new Vector3((size.X - 1.0f) / 8.0f + 1.0f, (size.Y - 1.0f) / 8.0f + 1.0f, 1.0f).Floor();


    }
  }

}