miserable failure to get text rendering to work using these 'easy text rendering' tricks. Will be bringing in a third party library which I have to write the damn backend implementation for
This commit is contained in:
@@ -465,7 +465,7 @@ impl CanvasState {
|
||||
|
||||
// Specify the color to clear the framebuffer with i.e. blue
|
||||
let clear_values = vec!(
|
||||
ClearValue::Float([0.0, 0.0, 1.0, 1.0]),
|
||||
ClearValue::Float([0.0, 0.0, 0.0, 0.0]),
|
||||
ClearValue::DepthStencil((1.0, 0x00)),
|
||||
);
|
||||
|
||||
@@ -500,6 +500,7 @@ impl CanvasState {
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
|
||||
// Images
|
||||
let mut shader = self.shader_buffers.get(
|
||||
self.get_shader_handle(String::from("simple_image"))
|
||||
@@ -604,7 +605,6 @@ impl CanvasState {
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
|
||||
command_buffer
|
||||
.end_render_pass()
|
||||
.unwrap()
|
||||
|
||||
@@ -65,7 +65,7 @@ pub trait CompiledShaderResources {
|
||||
|
||||
|
||||
fn compile(filepath: PathBuf, device: Arc<Device>, shader_type: ShaderType) -> (Entry, Arc<ShaderModule>) {
|
||||
let compiled_shader = shade_runner::load(filepath, Self::convert_sr(shader_type))
|
||||
let compiled_shader = shade_runner::load(filepath, None, Self::convert_sr(shader_type), None)
|
||||
.expect("Shader didn't compile");
|
||||
|
||||
let vulkano_entry =
|
||||
|
||||
@@ -106,6 +106,8 @@ impl CompiledShader for TextShader {
|
||||
let blend = AttachmentBlend {
|
||||
enabled: true,
|
||||
color_op: BlendOp::Add,
|
||||
// color_source: BlendFactor::SrcAlpha,
|
||||
// color_destination: BlendFactor::OneMinusSrcAlpha,
|
||||
color_source: BlendFactor::One,
|
||||
color_destination: BlendFactor::One,
|
||||
alpha_op: BlendOp::Add,
|
||||
@@ -140,8 +142,9 @@ impl CompiledShader for TextShader {
|
||||
third_constant: 0.0,
|
||||
})
|
||||
|
||||
.depth_stencil_simple_depth()
|
||||
.blend_collective(blend)
|
||||
.depth_stencil(stencil)
|
||||
// .blend_collective(blend)
|
||||
|
||||
//.blend_logic_op(LogicOp::Noop)
|
||||
// We have to indicate which subpass of which render pass this pipeline is going to be used
|
||||
// in. The pipeline will only be usable from this particular subpass.
|
||||
|
||||
@@ -12,108 +12,118 @@ pub struct Text {
|
||||
|
||||
/// Container class which implements drawable.
|
||||
impl Text {
|
||||
|
||||
fn accumulator(depth: f32, accumulator: &mut f32, constant: f32) -> f32{
|
||||
|
||||
let accum = *accumulator;
|
||||
*accumulator += constant;
|
||||
return depth + accum + constant;
|
||||
}
|
||||
///
|
||||
pub fn new(position: (f32, f32),
|
||||
size: (f32, f32),
|
||||
depth: u32) -> Text {
|
||||
let normalized_depth = (depth as f32 / 255.0);
|
||||
|
||||
let mut depth_accumulator = 1.0;
|
||||
let depth_accum_constant = -0.01 as f32;
|
||||
|
||||
let verts = {
|
||||
vec![
|
||||
ColorVertex3D {
|
||||
v_position: [-0.5, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
v_position: [-0.5, -0.5, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)+0.1],
|
||||
color: [1.0, 0.0, 0.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
v_position: [-1.0, 1.0, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)+0.1],
|
||||
color: [1.0, 0.8, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.25, 0.0, normalized_depth],
|
||||
v_position: [-0.25, 0.0, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)+0.1],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.25, 0.0, normalized_depth],
|
||||
v_position: [-0.25, 0.0, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [0.8, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
v_position: [-1.0, 1.0, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.0, 0.5, normalized_depth],
|
||||
v_position: [0.0, 0.5, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 0.8, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.25, 0.0, normalized_depth],
|
||||
v_position: [0.25, 0.0, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
v_position: [-1.0, 1.0, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 0.8, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.0, 0.5, normalized_depth],
|
||||
v_position: [0.0, 0.5, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.5, -0.5, normalized_depth],
|
||||
v_position: [0.5, -0.5, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
v_position: [-1.0, 1.0, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.25, 0.0, normalized_depth],
|
||||
v_position: [0.25, 0.0, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.25, -0.5, normalized_depth],
|
||||
v_position: [0.25, -0.5, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
v_position: [-1.0, 1.0, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.5, -0.5, normalized_depth],
|
||||
v_position: [0.5, -0.5, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.25, -0.5, normalized_depth],
|
||||
v_position: [0.25, -0.5, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
v_position: [-1.0, 1.0, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.0, -0.1, normalized_depth],
|
||||
v_position: [0.0, -0.1, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.25, -0.5, normalized_depth],
|
||||
v_position: [-0.25, -0.5, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
v_position: [-1.0, 1.0, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.0, -0.1, normalized_depth],
|
||||
v_position: [0.0, -0.1, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.5, -0.5, normalized_depth],
|
||||
v_position: [-0.5, -0.5, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
v_position: [-1.0, 1.0, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.25, -0.5, normalized_depth],
|
||||
v_position: [-0.25, -0.5, Text::accumulator(normalized_depth, &mut depth_accumulator, depth_accum_constant)],
|
||||
color: [1.0, 1.0, 1.0, 1.0/255.0],
|
||||
}]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user