Added Farbfeld texture
    
    
      
        Getty Ritter
        9 years ago
      
    
    
  
  
  Binary diff not shown
      
      | 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | impl<'a> Graphics<'a> { | 
| 34 | 
                      pub fn new(sg: SceneGraph<'a>, t: RawImage2d< | 
              |
| 34 | pub fn new(sg: SceneGraph<'a>, t: RawImage2d<(u16,u16,u16,u16)>) -> Self { | |
| 35 | 35 | let disp = WindowBuilder::new() | 
| 36 | 36 | .with_title(format!("utmyen")) | 
| 37 | 37 | .with_depth_buffer(24) | 
| 45 | 45 | let tex = Texture2d::with_format( | 
| 46 | 46 | &disp, | 
| 47 | 47 | t, | 
| 48 | 
                              glium::texture::UncompressedFloatFormat::U | 
              |
| 48 | glium::texture::UncompressedFloatFormat::U16U16U16U16, | |
| 49 | 49 | glium::texture::MipmapsOption::NoMipmap).unwrap(); | 
| 50 | 50 | Graphics { | 
| 51 | 51 | disp: disp, | 
| 7 | 7 | |
| 8 | 8 | mod graphics; | 
| 9 | 9 | |
| 10 | ||
| 11 | use glium::texture::{RawImage2d}; | |
| 10 | use glium::texture::{RawImage2d,Texture2dDataSource}; | |
| 11 | use therm_model::farbfeld::FFImage; | |
| 12 | 12 | use therm_model::model; | 
| 13 | 13 | use therm_model::graph::SceneGraph; | 
| 14 | 14 | |
| 18 | 18 | model::Model::load_from_file(&file).unwrap() | 
| 19 | 19 | } | 
| 20 | 20 | |
| 21 | fn sample_texture<'a>() -> RawImage2d<'a, u8> { | |
| 22 | use std::io::Cursor; | |
| 23 | let img = image::load( | |
| 24 | Cursor::new(&include_bytes!("../data/test/chest.png")[..]), | |
| 25 | image::PNG).unwrap().to_rgba(); | |
| 26 | let dims = img.dimensions(); | |
| 27 | let img = glium::texture::RawImage2d::from_raw_rgba_reversed(img.into_raw(), dims); | |
| 28 | img | |
| 21 | fn sample_texture<'a>() -> RawImage2d<'a, (u16,u16,u16,u16)> { | |
| 22 | FFImage::from_bz2_file("data/test/chest.ff.bz2").unwrap().into_raw() | |
| 29 | 23 | } | 
| 30 | 24 | |
| 31 | 25 | fn main() { | 
| 33 | 27 | let tex = sample_texture(); | 
| 34 | 28 | |
| 35 | 29 | let mut v = vec![]; | 
| 36 | for x in -20..20i32 { | |
| 37 | for y in -20..20i32 { | |
| 30 | for x in -50..5i32 { | |
| 31 | for y in -5..5i32 { | |
| 38 | 32 | v.push(SceneGraph::Translate(x as f32*0.3, | 
| 39 | 33 | 0.0, | 
| 40 | 34 | y as f32*0.3, |