refactoring out shaders

This commit is contained in:
2019-10-07 19:25:47 -07:00
parent 77d30591e6
commit 2fa08bf99e
9 changed files with 109 additions and 65 deletions

View File

@@ -9,39 +9,50 @@ use vulkano::image::{ImmutableImage, ImageUsage, ImageLayout, Dimensions};
use vulkano::format::ClearValue;
use vulkano::format::Format::R8Unorm;
const CACHE_WIDTH: usize = 1000;
const CACHE_HEIGHT: usize = 1000;
/*
So I think this thing is going to build text vertex buffers to send to the GPU.
I assume I will just lay them out in ASCII for now along with a list of
transformation matrices
Glpyh:
index: 0-255,
scale: 0.0 - 99.99
transform: (0.0, 0.0) - (1.0, 1.0)
I'm not sure if I want to send a new transformation matrix for each frame. But I suppose
that can come when I look at caching the sprites
*/
pub struct Glyph {
}
/// Typed wrapper for a u32 shader handle (index id)
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasTextHandle {
pub struct CanvasFontHandle {
pub handle: u32
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasTextCacheHandle {
pub handle: u32
}
/// So currently, I'm using these as container classes which vkprocessor owns
/// I then use a CanvasFrame which accumulates lists of handles and vertices.
pub struct CanvasText {
device: Arc<Device>,
queue: Arc<Queue>,
font: Font<'static>,
cache: Cache<'static>,
cache_pixel_buffer: Vec<u8>,
texts: Vec<u8>,
}
impl CanvasText {
/// Load the font
pub fn new(device: Arc<Device>, queue: Arc<Queue>) -> CanvasText {
let cache = Cache::builder().dimensions(CACHE_WIDTH as u32, CACHE_HEIGHT as u32).build();
let cache_pixel_buffer = vec!(0; CACHE_WIDTH * CACHE_HEIGHT);
let font_data = include_bytes!("../../resources/fonts/sansation.ttf");
let font = Font::from_bytes(font_data as &[u8]).unwrap();
@@ -49,13 +60,19 @@ impl CanvasText {
device: device.clone(),
queue: queue.clone(),
font: font,
cache: cache,
cache_pixel_buffer: vec![],
texts: vec![]
}
}
/// Generate a vertex buffer from the font
/*
So... These fonts are going to have unequal amounts of vertices.
*/
pub fn get_vertex_buffer(&self) {
unimplemented!()
}
/// postpone this until caching
pub fn queue_text(&mut self,
x: f32, y: f32,
size: f32, color: [f32; 4],
@@ -74,7 +91,7 @@ impl CanvasText {
command_buffer: AutoCommandBufferBuilder,
image_num: usize
) -> AutoCommandBufferBuilder {
//
// let screen_width = 0;
// let screen_height = 0;
//