use parameters::ParamInfo;
use std;
use std::error::Error;
use std::fmt::Debug;
use crate::inputs::FFGLData;
use crate::{info, inputs::GLInput, parameters};
#[doc(hidden)]
pub struct Instance<T> {
pub(crate) data: FFGLData,
pub(crate) renderer: T,
}
impl<I> Debug for Instance<I> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Instance")
.field("data", &self.data)
.field("renderer", &std::any::type_name::<I>())
.finish()
}
}
pub trait FFGLInstance {
fn get_param(&self, index: usize) -> f32;
fn set_param(&mut self, index: usize, value: f32);
fn draw(&mut self, inst_data: &FFGLData, frame_data: GLInput);
}
pub trait FFGLHandler {
type Instance: FFGLInstance;
type NewInstanceError: Error + Send + Sync + 'static;
fn init() -> Self;
fn num_params(&'static self) -> usize;
fn param_info(&'static self, index: usize) -> &'static dyn ParamInfo;
fn plugin_info(&'static self) -> info::PluginInfo;
fn new_instance(
&'static self,
inst_data: &FFGLData,
) -> Result<Self::Instance, Self::NewInstanceError>;
}
pub mod simplified;