use upscaled mipmaps for tiles
This commit is contained in:
31
src/tile.rs
31
src/tile.rs
@@ -6,30 +6,45 @@ use ::std;
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
|
||||
use self::gfx::{CommandBuffer, Typed};
|
||||
use self::gfx::tex;
|
||||
|
||||
const TILEDIM: u16 = 16;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Tile {
|
||||
pub val: u8,
|
||||
}
|
||||
|
||||
pub fn get_tiles<R, F, T>(factory: &mut F) -> (//gfx::handle::Texture<R, T::Surface>,
|
||||
gfx::handle::ShaderResourceView<R, T::View>)
|
||||
where R: gfx::Resources,
|
||||
F: gfx::Factory<R>,
|
||||
pub fn get_tiles<D, F, T>(device: &mut D,
|
||||
factory: &mut F,
|
||||
command: &mut <D as gfx::Device>::CommandBuffer)
|
||||
-> gfx::handle::ShaderResourceView<D::Resources, T::View>
|
||||
where D: gfx::Device,
|
||||
F: gfx::Factory<D::Resources>,
|
||||
T: gfx::format::TextureFormat {
|
||||
let filename = "data/SHAPES.EGA";
|
||||
let mut file = std::fs::File::open(Path::new(filename))
|
||||
.expect(&format!("failed opening tiles file: {}", filename));
|
||||
let mut ega_bytes = Vec::new();
|
||||
file.read_to_end(&mut ega_bytes).expect("Read tiles file");
|
||||
let ega_page = ega::decode(&ega_bytes, ega::Compression::UNCOMPRESSED, ega::Tiling::TILED(16));
|
||||
let tiles: Vec<&[u8]> = ega_page.iter().collect();
|
||||
let tex = factory.create_texture_const_u8::<T>(tex::Kind::D2Array(16, 16, 256,
|
||||
let ega_page = ega::decode(&ega_bytes, ega::Compression::UNCOMPRESSED, ega::Tiling::TILED(TILEDIM));
|
||||
let mipmap = ega_page.mipmap(2);
|
||||
|
||||
let tex = factory.create_texture_const_u8::<T>(tex::Kind::D2Array(mipmap.dim as u16,
|
||||
mipmap.dim as u16,
|
||||
mipmap.len as u16,
|
||||
tex::AaMode::Single),
|
||||
&tiles)
|
||||
&mipmap.slices())
|
||||
.expect("create tile texture");
|
||||
|
||||
{
|
||||
let mut manager = gfx::handle::Manager::<D::Resources>::new();
|
||||
let view = manager.ref_srv(tex.1.raw());
|
||||
command.generate_mipmap(*view);
|
||||
device.submit(command);
|
||||
}
|
||||
tex.1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user