<commit_before>use luminance::{Depth32F, Dim2, Flat, RGBA32F};
use luminance_gl::gl33::{Framebuffer, Pipe, Pipeline, RenderCommand, ShadingCommand, Texture};

use camera::{Camera, Freefly};
use extra::shaders::default::{DEFAULT_3D_INST, DEFAULT_3D_PROJ, DEFAULT_3D_VIEW, DefaultProgram3D};
use object::Object;
use projection::Projectable;
use renderer::Renderer;
use scene::Scene;
use transform::Transformable;

pub type Texture2D<A> = Texture<Flat, Dim2, A>;

/// Simple renderer that takes a camera, a set of model and applies a shader on them. This renderer
/// outputs a single color map along with the depth map.
pub struct SimpleRenderer<'a> {
  program: DefaultProgram3D<'a>,
  framebuffer: Framebuffer<Flat, Dim2, Texture2D<RGBA32F>, Texture2D<Depth32F>>
}

impl<'a> SimpleRenderer<'a> {
  pub fn new_from(w: u32, h: u32, scene: &mut Scene<'a>) -> Self {
    SimpleRenderer {
      program: DefaultProgram3D::new_from(scene).unwrap(),
      framebuffer: Framebuffer::new((w, h), 0).unwrap()
    }
  }
}

impl<'a, 'b, 'c> Renderer<'a, 'b, 'c, (&'a Camera<Freefly>, &'a [&'a Object<'c>]), (&'a Texture2D<RGBA32F>, &'a Texture2D<Depth32F>)> for SimpleRenderer<'c> {
  fn render(&'a self, scene: &'b mut Scene<'c>, input: (&'a Camera<Freefly>, &'a [&'a Object<'c>])) -> (&'a Texture2D<RGBA32F>, &'a Texture2D<Depth32F>) {
    let (camera, objects) = input;
    let program = scene.get_by_id(&self.program).unwrap();

    // reify objects
    let objects: Vec<_> = objects.iter().map(|object| {
      (object, scene.get_by_id(&object.model).unwrap())
    }).collect();

    let tessellations = objects.iter().flat_map(|&(object, ref model)| {
      model.parts.iter().map(move |part| {
        Pipe::new(move |program| {
                    program.update(&DEFAULT_3D_INST, *object.transform().as_ref());
                  },
                  &part.tess)
      })<commit_msg>SimpleRenderer::new_from -> SimpleRenderer::new.<commit_after>use luminance::{Depth32F, Dim2, Flat, RGBA32F};
use luminance_gl::gl33::{Framebuffer, Pipe, Pipeline, RenderCommand, ShadingCommand, Texture};

use camera::{Camera, Freefly};
use extra::shaders::default::{DEFAULT_3D_INST, DEFAULT_3D_PROJ, DEFAULT_3D_VIEW, DefaultProgram3D};
use object::Object;
use projection::Projectable;
use renderer::Renderer;
use scene::Scene;
use transform::Transformable;

pub type Texture2D<A> = Texture<Flat, Dim2, A>;

/// Simple renderer that takes a camera, a set of model and applies a shader on them. This renderer
/// outputs a single color map along with the depth map.
pub struct SimpleRenderer<'a> {
  program: DefaultProgram3D<'a>,
  framebuffer: Framebuffer<Flat, Dim2, Texture2D<RGBA32F>, Texture2D<Depth32F>>
}

impl<'a> SimpleRenderer<'a> {
  pub fn new(w: u32, h: u32, scene: &mut Scene<'a>) -> Self {
    SimpleRenderer {
      program: DefaultProgram3D::new_from(scene).unwrap(),
      framebuffer: Framebuffer::new((w, h), 0).unwrap()
    }
  }
}

impl<'a, 'b, 'c> Renderer<'a, 'b, 'c, (&'a Camera<Freefly>, &'a [&'a Object<'c>]), (&'a Texture2D<RGBA32F>, &'a Texture2D<Depth32F>)> for SimpleRenderer<'c> {
  fn render(&'a self, scene: &'b mut Scene<'c>, input: (&'a Camera<Freefly>, &'a [&'a Object<'c>])) -> (&'a Texture2D<RGBA32F>, &'a Texture2D<Depth32F>) {
    let (camera, objects) = input;
    let program = scene.get_by_id(&self.program).unwrap();

    // reify objects
    let objects: Vec<_> = objects.iter().map(|object| {
      (object, scene.get_by_id(&object.model).unwrap())
    }).collect();

    let tessellations = objects.iter().flat_map(|&(object, ref model)| {
      model.parts.iter().map(move |part| {
        Pipe::new(move |program| {
                    program.update(&DEFAULT_3D_INST, *object.transform().as_ref());
                  },
                  &part.tess)
      })
{'fraction_non_alphanumeric': 0.17238648363252376, 'fraction_numerical': 0.021119324181626188, 'mean_word_length': 4.2993006993007, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2860064', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1340, 'n_words': 311}