import Foundation
import Metal

public class WarpedGridRenderable: ConfiguredQuadRenderable<WarpedGridRenderable.Config> {
    public struct Config: QuadRenderConfiguration {
        // matches warped_checkerboard_Uniforms
        internal var resolution: ADVector2
        internal var time:      ADFloat
        internal var colorA:    ADVector3
        internal var colorB:    ADVector3
        internal var vortexRadius:   ADFloat
        internal var vortexStrength: ADFloat

        public init(
            resolution:     ADVector2 = .ones,
            time:           ADFloat   = .zero,
            colorA:         ADVector3 = ADVector3(1.0, 0.3, 0.5),
            colorB:         ADVector3 = ADVector3(1.0, 0.45, 0.4),
            vortexRadius:   ADFloat   = 4.0,
            vortexStrength: ADFloat  = -0.4
        ) {
            self.resolution     = resolution
            self.time           = time
            self.colorA         = colorA
            self.colorB         = colorB
            self.vortexRadius   = vortexRadius
            self.vortexStrength = vortexStrength
        }

        public static var defaultConfiguration: Config {
            return Config()
        }
    }

    /// Name of the Metal fragment function in your `.metal` library
    override public var fragmentShaderName: String {
        return "warped_checkerboard_fragment_main"
    }

    /// Hook to set up any extra state before drawing;
    /// here all your `Config` fields are bound automatically.
    override public var configureAction: ConfigureAction {
        return { encoder in
            super.configureAction(encoder)
            // no manual bindings needed—Config fields map to the uniforms struct
        }
    }
}
