parent
bb8144bb01
commit
b3e092e25a
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
initSidebarItems({"mod":[["compu_buffer",""],["compu_kernel",""],["compu_sprite",""],["handles",""]]});
|
||||
initSidebarItems({"mod":[["compu_buffer",""],["compu_kernel",""],["handles",""]]});
|
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
initSidebarItems({"struct":[["Polygon","Convex multi verticy polygon"]]});
|
@ -0,0 +1 @@
|
||||
initSidebarItems({"struct":[["Rect",""]]});
|
@ -0,0 +1 @@
|
||||
initSidebarItems({"mod":[["compu_sprite",""],["polygon",""],["rect",""],["sprite",""]]});
|
@ -1 +1 @@
|
||||
initSidebarItems({"fn":[["main",""]],"mod":[["canvas",""],["compute",""],["sprite",""],["util",""],["vkprocessor",""]]});
|
||||
initSidebarItems({"fn":[["main",""]],"mod":[["canvas",""],["compute",""],["drawables",""],["util",""],["vkprocessor",""]]});
|
@ -1,3 +1,3 @@
|
||||
var N = null;var sourcesIndex = {};
|
||||
sourcesIndex["sfml_rust"] = {"name":"","dirs":[{"name":"canvas","dirs":[{"name":"managed","dirs":[{"name":"shader","files":["dynamic_vertex.rs","generic_shader.rs","mod.rs","shader_common.rs","text_shader.rs"]}],"files":["canvas_text.rs","gpu_buffers.rs","handles.rs","mod.rs"]}],"files":["canvas_frame.rs","canvas_state.rs","mod.rs"]},{"name":"compute","dirs":[{"name":"managed","files":["compu_buffer.rs","compu_kernel.rs","compu_sprite.rs","handles.rs","mod.rs"]}],"files":["compu_frame.rs","compu_state.rs","mod.rs"]},{"name":"util","files":["mod.rs","timer.rs","vertex.rs"]}],"files":["main.rs","sprite.rs","vkprocessor.rs"]};
|
||||
sourcesIndex["sfml_rust"] = {"name":"","dirs":[{"name":"canvas","dirs":[{"name":"managed","dirs":[{"name":"shader","files":["dynamic_vertex.rs","generic_shader.rs","mod.rs","shader_common.rs","text_shader.rs"]}],"files":["canvas_text.rs","gpu_buffers.rs","handles.rs","mod.rs"]}],"files":["canvas_frame.rs","canvas_state.rs","mod.rs"]},{"name":"compute","dirs":[{"name":"managed","files":["compu_buffer.rs","compu_kernel.rs","handles.rs","mod.rs"]}],"files":["compu_frame.rs","compu_state.rs","mod.rs"]},{"name":"drawables","files":["compu_sprite.rs","mod.rs","polygon.rs","rect.rs","sprite.rs"]},{"name":"util","files":["mod.rs","timer.rs","vertex.rs"]}],"files":["main.rs","vkprocessor.rs"]};
|
||||
createSourceSidebar();
|
||||
|
@ -0,0 +1,48 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2020-02-21T22:54:06-08:00
|
||||
|
||||
====== Drawables ======
|
||||
[[/doc/sfml_rust/drawables/index.html|Documentation]]
|
||||
|
||||
=== Details ===
|
||||
Drawables are all able to be passed to the canvas frame to be rendered
|
||||
|
||||
The implementation of the Drawable trait is tightly coupled to the data types defined in VertexType and ingested by the canvas frame
|
||||
|
||||
Right now I have a couple of types that I'm using:
|
||||
|
||||
TextureType(vec, handle)
|
||||
ImageType(vec, handle)
|
||||
ColorType(vec)
|
||||
ThreeDType(vec)
|
||||
|
||||
This maps to the drawables I have implemented
|
||||
|
||||
compu_sprite : ImageType
|
||||
polygon : ColorType
|
||||
rect : ColorType
|
||||
sprite : TextureType
|
||||
|
||||
|
||||
It doesn't matter, how these objects get the VertexType that it needs to return. Generating them on the fly should be generally OK. It won't scale to very large amounts of sprites. But it's fine for now.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2020-02-12T23:22:51-08:00
|
||||
|
||||
====== CompiledGraphicsPipeline ======
|
||||
|
||||
|
||||
|
||||
|
||||
Unfortunately we have to explicitly provide the type to the graphics pipeline if we don't want to fall out into the
|
||||
|
@ -0,0 +1,44 @@
|
||||
Content-Type: text/x-zim-wiki
|
||||
Wiki-Format: zim 0.4
|
||||
Creation-Date: 2020-02-12T23:22:51-08:00
|
||||
|
||||
====== CompiledShader ======
|
||||
|
||||
[[/doc/sfml_rust/canvas/managed/shader/shader_common/trait.CompiledShader.html|Documentation]]
|
||||
|
||||
==== Details ====
|
||||
|
||||
This trait returns:
|
||||
* It's pipeline
|
||||
* It's own assigned handle
|
||||
* The renderpass it copied from the constructor
|
||||
|
||||
==== Implementors ====
|
||||
|
||||
**GenericShader**
|
||||
For basic 2D drawing we just these shaders
|
||||
* Vertex
|
||||
* Fragment
|
||||
We also use a **SingleBufferDefinition**
|
||||
For vertices, we use a **Triangle List**
|
||||
We also use the **generic** depth stencil
|
||||
|
||||
**TextShader**
|
||||
|
||||
Very similar to the GenericShader, but specialized with the depth stencil to draw text.
|
||||
Still using the shaders :
|
||||
* Vertex
|
||||
* Fragment
|
||||
**SingleBufferDefinition**
|
||||
**TriangleList**
|
||||
**DepthStencil** with our own specialized depth stencil values
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,133 @@
|
||||
use crate::canvas::canvas_frame::Drawable;
|
||||
use crate::util::vertex::{VertexTypes, ColorVertex3D};
|
||||
|
||||
///
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Text {
|
||||
pub verts: VertexTypes,
|
||||
|
||||
position: (f32, f32),
|
||||
size: (f32, f32),
|
||||
}
|
||||
|
||||
/// Container class which implements drawable.
|
||||
impl Text {
|
||||
///
|
||||
pub fn new(position: (f32, f32),
|
||||
size: (f32, f32),
|
||||
depth: u32) -> Text {
|
||||
let normalized_depth = (depth as f32 / 255.0);
|
||||
|
||||
let verts = {
|
||||
vec![
|
||||
ColorVertex3D {
|
||||
v_position: [-0.5, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.25, 0.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.25, 0.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.0, 0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.25, 0.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.0, 0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.5, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.25, 0.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.25, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.5, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.25, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.0, -0.1, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.25, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [0.0, -0.1, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.5, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-1.0, 1.0, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
},
|
||||
ColorVertex3D {
|
||||
v_position: [-0.25, -0.5, normalized_depth],
|
||||
color: [1.0, 1.0, 1.0, 1.0],
|
||||
}]
|
||||
};
|
||||
|
||||
Text {
|
||||
verts: VertexTypes::ColorType(verts),
|
||||
position: position,
|
||||
size: size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drawable for Text {
|
||||
fn get(&self) -> VertexTypes {
|
||||
self.verts.clone()
|
||||
}
|
||||
}
|
Loading…
Reference in new issue