master
mitchellhansen 5 years ago
parent 2fa08bf99e
commit e4a9170515

@ -6,8 +6,8 @@ use vulkano::sampler::Sampler;
use vulkano::descriptor::DescriptorSet;
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
use vulkano::buffer::CpuAccessibleBuffer;
use crate::canvas::canvas_text::{CanvasTextCacheHandle, CanvasFontHandle};
use vulkano::pipeline::GraphicsPipelineAbstract;
use crate::canvas::canvas_text::CanvasFontHandle;
#[derive(Clone)]
pub struct CanvasTexture {
@ -53,7 +53,7 @@ impl CanvasImage {
#[derive(Clone)]
pub struct CanvasTextCache {
pub(crate) handle: Arc<CanvasTextCacheHandle>,
//pub(crate) handle: Arc<CanvasTextCacheHandle>,
pub(crate) buffer: Arc<CpuAccessibleBuffer<u8>>,
pub(crate) size: (u32, u32),
}

@ -565,25 +565,25 @@ impl CanvasState {
}
// Text
let mut shader = self.text_buffers.get(
self.get_shader_handle(String::from("simple_text"))
.unwrap().clone().handle as usize
).unwrap();
if !self.text_vertex_buffer.is_empty() {
for (text_handle, vertex_buffer) in self.text_vertex_buffer.clone() {
let handle = texture_handle.clone().handle as usize;
let descriptor_set = self.text_buffers.get(handle).clone().unwrap().clone()
.get_descriptor_set(shader.get_pipeline(), self.sampler.clone());
command_buffer = command_buffer.draw(
shader.get_pipeline().clone(),
// Multiple vertex buffers must have their definition in the pipeline!
&self.dynamic_state.clone(), vec![vertex_buffer],
vec![descriptor_set], (),
).unwrap();
}
}
// let mut shader = self.text_buffers.get(
// self.get_shader_handle(String::from("simple_text"))
// .unwrap().clone().handle as usize
// ).unwrap();
// if !self.text_vertex_buffer.is_empty() {
// for (text_handle, vertex_buffer) in self.text_vertex_buffer.clone() {
// let handle = text_handle.clone().handle as usize;
// let descriptor_set = self.text_buffers.get(handle).clone().unwrap().clone()
// .get_descriptor_set(shader.get_pipeline(), self.sampler.clone());
//
// command_buffer = command_buffer.draw(
// shader.get_pipeline().clone(),
// // Multiple vertex buffers must have their definition in the pipeline!
// &self.dynamic_state.clone(), vec![vertex_buffer],
// vec![descriptor_set], (),
// ).unwrap();
// }
// }
command_buffer
.end_render_pass()

@ -78,9 +78,9 @@ impl CanvasText {
size: f32, color: [f32; 4],
text: &str) {
let glyphs: Vec<PositionedGlyph> = self.font.layout(text, Scale::uniform(size), point(x, y)).map(|x| x.standalone()).collect();
for glyph in &glyphs {
self.cache.queue_glyph(0, glyph.clone());
}
// for glyph in &glyphs {
// self.cache.queue_glyph(0, glyph.clone());
// }
// self.texts.push(TextData {
// glyphs: glyphs.clone(),
// color: color,

@ -177,7 +177,7 @@ pub fn main() {
drop(l);
return;
hprof::end_frame();
hprof::profiler().print_timing();
}

Loading…
Cancel
Save