use crate::{dx::*, ext::tdx::*};
pub struct VertexShader {
pub d: bool,
pub h: i32
}
impl Tr for VertexShader {
fn as_vertex_shader(&self) -> VertexShader {
VertexShader{d: false, h: self.h}
}
fn handle(&self) -> i32 { self.h }
fn dispose(&mut self) {
if self.d && self.h != 0 {
unsafe { DeleteShader(self.h); }
self.h = 0;
}
}
}
impl Drop for VertexShader {
fn drop(&mut self) { self.dispose(); }
}
impl VertexShader {
pub fn load(n: &String) -> Self {
VertexShader{d: true, h: unsafe { LoadVertexShader(n.as_ptr()) } }
}
pub fn set_shader(&self) {
unsafe { SetUseVertexShader(self.h); }
}
}
pub struct PixelShader {
pub d: bool,
pub h: i32
}
impl Tr for PixelShader {
fn as_pixel_shader(&self) -> PixelShader {
PixelShader{d: false, h: self.h}
}
fn handle(&self) -> i32 { self.h }
fn dispose(&mut self) {
if self.d && self.h != 0 {
unsafe { DeleteShader(self.h); }
self.h = 0;
}
}
}
impl Drop for PixelShader {
fn drop(&mut self) { self.dispose(); }
}
impl PixelShader {
pub fn load(n: &String) -> Self {
PixelShader{d: true, h: unsafe { LoadPixelShader(n.as_ptr()) } }
}
pub fn set_shader(&self) {
unsafe { SetUsePixelShader(self.h); }
}
}
pub struct GeometryShader {
pub d: bool,
pub h: i32
}
impl Tr for GeometryShader {
fn as_geometry_shader(&self) -> GeometryShader {
GeometryShader{d: false, h: self.h}
}
fn handle(&self) -> i32 { self.h }
fn dispose(&mut self) {
if self.d && self.h != 0 {
unsafe { DeleteShader(self.h); }
self.h = 0;
}
}
}
impl Drop for GeometryShader {
fn drop(&mut self) { self.dispose(); }
}
impl GeometryShader {
pub fn load(n: &String) -> Self {
GeometryShader{d: true, h: unsafe { LoadGeometryShader(n.as_ptr()) } }
}
pub fn set_shader(&self) {
unsafe { SetUseGeometryShader(self.h); }
}
}