1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
mod errors; use raw::*; use texture::*; mod state; pub use self::state::*; mod framebuffer; pub use self::framebuffer::*; use std::fmt; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum DefaultFramebufferDrawBuffer { None, FrontLeft, FrontRight, BackLeft, BackRight, } impl From<DefaultFramebufferDrawBuffer> for FramebufferDrawBuffer { fn from(draw_buffer: DefaultFramebufferDrawBuffer) -> Self { match draw_buffer { DefaultFramebufferDrawBuffer::None => FramebufferDrawBuffer::None, DefaultFramebufferDrawBuffer::FrontLeft => FramebufferDrawBuffer::FrontLeft, DefaultFramebufferDrawBuffer::FrontRight => FramebufferDrawBuffer::FrontRight, DefaultFramebufferDrawBuffer::BackLeft => FramebufferDrawBuffer::BackLeft, DefaultFramebufferDrawBuffer::BackRight => FramebufferDrawBuffer::BackRight, } } } #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum GeneralFramebufferDrawBuffer { None, ColorAttachment0, ColorAttachment1, ColorAttachment2, ColorAttachment3, ColorAttachment4, ColorAttachment5, ColorAttachment6, ColorAttachment7, } impl From<GeneralFramebufferDrawBuffer> for FramebufferDrawBuffer { fn from(draw_buffer: GeneralFramebufferDrawBuffer) -> Self { match draw_buffer { GeneralFramebufferDrawBuffer::None => FramebufferDrawBuffer::None, GeneralFramebufferDrawBuffer::ColorAttachment0 => FramebufferDrawBuffer::ColorAttachment0, GeneralFramebufferDrawBuffer::ColorAttachment1 => FramebufferDrawBuffer::ColorAttachment1, GeneralFramebufferDrawBuffer::ColorAttachment2 => FramebufferDrawBuffer::ColorAttachment2, GeneralFramebufferDrawBuffer::ColorAttachment3 => FramebufferDrawBuffer::ColorAttachment3, GeneralFramebufferDrawBuffer::ColorAttachment4 => FramebufferDrawBuffer::ColorAttachment4, GeneralFramebufferDrawBuffer::ColorAttachment5 => FramebufferDrawBuffer::ColorAttachment5, GeneralFramebufferDrawBuffer::ColorAttachment6 => FramebufferDrawBuffer::ColorAttachment6, GeneralFramebufferDrawBuffer::ColorAttachment7 => FramebufferDrawBuffer::ColorAttachment7, } } } pub enum DrawTextureAttachOption<'a> { AttachTexture(&'a mut Texture), AttachTextureLayer { texture: &'a mut Texture, level: usize, layer: usize, }, None, Keep, } impl<'a> fmt::Debug for DrawTextureAttachOption<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { DrawTextureAttachOption::AttachTexture(ref texture) => write!( f, "DrawTextureAttachOption {{ TextureId: {:?} }}", texture.get_id() ), DrawTextureAttachOption::AttachTextureLayer { ref texture, level, layer, } => write!( f, "DrawTextureAttachOption {{ TextureId: {:?}, level: {}, layer: {} }}", texture.get_id(), level, layer ), DrawTextureAttachOption::None => write!(f, "DrawTextureAttachOption {{ None }}"), DrawTextureAttachOption::Keep => write!(f, "DrawTextureAttachOption {{ Keep }}"), } } } impl<'a> Default for DrawTextureAttachOption<'a> { fn default() -> DrawTextureAttachOption<'a> { DrawTextureAttachOption::None } } #[derive(Debug)] pub enum DepthStencilOption<'a> { Separate { depth: DrawTextureAttachOption<'a>, stencil: DrawTextureAttachOption<'a>, }, Together(DrawTextureAttachOption<'a>), } impl<'a> Default for DepthStencilOption<'a> { fn default() -> DepthStencilOption<'a> { DepthStencilOption::Separate { depth: DrawTextureAttachOption::None, stencil: DrawTextureAttachOption::None, } } } #[derive(Debug, Default)] pub struct DrawTextureTarget<'a> { pub depth_stencil: DepthStencilOption<'a>, pub color0: DrawTextureAttachOption<'a>, pub color1: DrawTextureAttachOption<'a>, pub color2: DrawTextureAttachOption<'a>, pub color3: DrawTextureAttachOption<'a>, pub color4: DrawTextureAttachOption<'a>, pub color5: DrawTextureAttachOption<'a>, pub color6: DrawTextureAttachOption<'a>, pub color7: DrawTextureAttachOption<'a>, } #[derive(Debug)] pub enum FramebufferRenderTarget<'a> { Default, General(&'a GeneralFramebuffer, &'a DrawTextureTarget<'a>), } impl<'a> DrawTextureTarget<'a> { pub fn keep() -> DrawTextureTarget<'a> { DrawTextureTarget { depth_stencil: DepthStencilOption::Together(DrawTextureAttachOption::Keep), color0: DrawTextureAttachOption::Keep, color1: DrawTextureAttachOption::Keep, color2: DrawTextureAttachOption::Keep, color3: DrawTextureAttachOption::Keep, color4: DrawTextureAttachOption::Keep, color5: DrawTextureAttachOption::Keep, color6: DrawTextureAttachOption::Keep, color7: DrawTextureAttachOption::Keep, } } }