use backend::Facade;
use index::IndicesSource;
use index::ToIndicesSource;
use index::IntoIndexBuffer;
use index::IndexBuffer;
use index::Index;
use index::PrimitiveType;
#[derive(Clone)]
pub struct PointsList<T>(pub Vec<T>);
impl<T> IntoIndexBuffer for PointsList<T> where T: Index + Send + Copy {
fn into_index_buffer<F>(self, facade: &F) -> IndexBuffer where F: Facade {
IndexBuffer::from_raw(facade, self.0, PrimitiveType::Points)
}
}
impl<T> ToIndicesSource for PointsList<T> where T: Index + Send + Copy {
type Data = T;
fn to_indices_source(&self) -> IndicesSource<T> {
IndicesSource::Buffer {
pointer: &self.0,
primitives: PrimitiveType::Points,
offset: 0,
length: self.0.len(),
}
}
}
pub struct LinesList<T>(pub Vec<T>);
impl<T> IntoIndexBuffer for LinesList<T> where T: Index + Send + Copy {
fn into_index_buffer<F>(self, facade: &F) -> IndexBuffer where F: Facade {
IndexBuffer::from_raw(facade, self.0, PrimitiveType::LinesList)
}
}
impl<T> ToIndicesSource for LinesList<T> where T: Index + Send + Copy {
type Data = T;
fn to_indices_source(&self) -> IndicesSource<T> {
IndicesSource::Buffer {
pointer: &self.0,
primitives: PrimitiveType::LinesList,
offset: 0,
length: self.0.len(),
}
}
}
pub struct LinesListAdjacency<T>(pub Vec<T>);
impl<T> IntoIndexBuffer for LinesListAdjacency<T> where T: Index + Send + Copy {
fn into_index_buffer<F>(self, facade: &F) -> IndexBuffer where F: Facade {
IndexBuffer::from_raw(facade, self.0, PrimitiveType::LinesListAdjacency)
}
}
impl<T> ToIndicesSource for LinesListAdjacency<T> where T: Index + Send + Copy {
type Data = T;
fn to_indices_source(&self) -> IndicesSource<T> {
IndicesSource::Buffer {
pointer: &self.0,
primitives: PrimitiveType::LinesListAdjacency,
offset: 0,
length: self.0.len(),
}
}
}
pub struct LineStrip<T>(pub Vec<T>);
impl<T> IntoIndexBuffer for LineStrip<T> where T: Index + Send + Copy {
fn into_index_buffer<F>(self, facade: &F) -> IndexBuffer where F: Facade {
IndexBuffer::from_raw(facade, self.0, PrimitiveType::LineStrip)
}
}
impl<T> ToIndicesSource for LineStrip<T> where T: Index + Send + Copy {
type Data = T;
fn to_indices_source(&self) -> IndicesSource<T> {
IndicesSource::Buffer {
pointer: &self.0,
primitives: PrimitiveType::LineStrip,
offset: 0,
length: self.0.len(),
}
}
}
pub struct LineStripAdjacency<T>(pub Vec<T>);
impl<T> IntoIndexBuffer for LineStripAdjacency<T> where T: Index + Send + Copy {
fn into_index_buffer<F>(self, facade: &F) -> IndexBuffer where F: Facade {
IndexBuffer::from_raw(facade, self.0, PrimitiveType::LineStripAdjacency)
}
}
impl<T> ToIndicesSource for LineStripAdjacency<T> where T: Index + Send + Copy {
type Data = T;
fn to_indices_source(&self) -> IndicesSource<T> {
IndicesSource::Buffer {
pointer: &self.0,
primitives: PrimitiveType::LineStripAdjacency,
offset: 0,
length: self.0.len(),
}
}
}
pub struct TrianglesList<T>(pub Vec<T>);
impl<T> IntoIndexBuffer for TrianglesList<T> where T: Index + Send + Copy {
fn into_index_buffer<F>(self, facade: &F) -> IndexBuffer where F: Facade {
IndexBuffer::from_raw(facade, self.0, PrimitiveType::TrianglesList)
}
}
impl<T> ToIndicesSource for TrianglesList<T> where T: Index + Send + Copy {
type Data = T;
fn to_indices_source(&self) -> IndicesSource<T> {
IndicesSource::Buffer {
pointer: &self.0,
primitives: PrimitiveType::TrianglesList,
offset: 0,
length: self.0.len(),
}
}
}
pub struct TrianglesListAdjacency<T>(pub Vec<T>);
impl<T> IntoIndexBuffer for TrianglesListAdjacency<T> where T: Index + Send + Copy {
fn into_index_buffer<F>(self, facade: &F) -> IndexBuffer where F: Facade {
IndexBuffer::from_raw(facade, self.0, PrimitiveType::TrianglesListAdjacency)
}
}
impl<T> ToIndicesSource for TrianglesListAdjacency<T> where T: Index + Send + Copy {
type Data = T;
fn to_indices_source(&self) -> IndicesSource<T> {
IndicesSource::Buffer {
pointer: &self.0,
primitives: PrimitiveType::TrianglesListAdjacency,
offset: 0,
length: self.0.len(),
}
}
}
pub struct TriangleStrip<T>(pub Vec<T>);
impl<T> IntoIndexBuffer for TriangleStrip<T> where T: Index + Send + Copy {
fn into_index_buffer<F>(self, facade: &F) -> IndexBuffer where F: Facade {
IndexBuffer::from_raw(facade, self.0, PrimitiveType::TriangleStrip)
}
}
impl<T> ToIndicesSource for TriangleStrip<T> where T: Index + Send + Copy {
type Data = T;
fn to_indices_source(&self) -> IndicesSource<T> {
IndicesSource::Buffer {
pointer: &self.0,
primitives: PrimitiveType::TriangleStrip,
offset: 0,
length: self.0.len(),
}
}
}
pub struct TriangleStripAdjacency<T>(pub Vec<T>);
impl<T> IntoIndexBuffer for TriangleStripAdjacency<T> where T: Index + Send + Copy {
fn into_index_buffer<F>(self, facade: &F) -> IndexBuffer where F: Facade {
IndexBuffer::from_raw(facade, self.0, PrimitiveType::TriangleStripAdjacency)
}
}
impl<T> ToIndicesSource for TriangleStripAdjacency<T> where T: Index + Send + Copy {
type Data = T;
fn to_indices_source(&self) -> IndicesSource<T> {
IndicesSource::Buffer {
pointer: &self.0,
primitives: PrimitiveType::TriangleStripAdjacency,
offset: 0,
length: self.0.len(),
}
}
}
pub struct TriangleFan<T>(pub Vec<T>);
impl<T> IntoIndexBuffer for TriangleFan<T> where T: Index + Send + Copy {
fn into_index_buffer<F>(self, facade: &F) -> IndexBuffer where F: Facade {
IndexBuffer::from_raw(facade, self.0, PrimitiveType::TriangleFan)
}
}
impl<T> ToIndicesSource for TriangleFan<T> where T: Index + Send + Copy {
type Data = T;
fn to_indices_source(&self) -> IndicesSource<T> {
IndicesSource::Buffer {
pointer: &self.0,
primitives: PrimitiveType::TriangleFan,
offset: 0,
length: self.0.len(),
}
}
}
pub struct Patches<T>(pub Vec<T>, pub u16);
impl<T> IntoIndexBuffer for Patches<T> where T: Index + Send + Copy {
fn into_index_buffer<F>(self, facade: &F) -> IndexBuffer where F: Facade {
IndexBuffer::from_raw(facade, self.0, PrimitiveType::Patches { vertices_per_patch: self.1 })
}
}
impl<T> ToIndicesSource for Patches<T> where T: Index + Send + Copy {
type Data = T;
fn to_indices_source(&self) -> IndicesSource<T> {
IndicesSource::Buffer {
pointer: &self.0,
primitives: PrimitiveType::Patches { vertices_per_patch: self.1 },
offset: 0,
length: self.0.len(),
}
}
}