master
mitchellhansen 5 years ago
parent 2fa08bf99e
commit e4a9170515

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

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

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

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

Loading…
Cancel
Save