(gfx: &Graphics, width: i32, height: i32, data: &[u8])
| 94 | |
| 95 | impl RawTexture { |
| 96 | pub fn new(gfx: &Graphics, width: i32, height: i32, data: &[u8]) -> RawTexture { |
| 97 | unsafe { |
| 98 | assert_eq!(width as usize * height as usize * 4, data.len()); |
| 99 | |
| 100 | let id = gfx.state.gl.create_texture().unwrap(); |
| 101 | |
| 102 | gfx.bind_texture(Some(id)); |
| 103 | |
| 104 | gfx.state.gl.tex_parameter_i32( |
| 105 | glow::TEXTURE_2D, |
| 106 | glow::TEXTURE_MIN_FILTER, |
| 107 | glow::NEAREST as i32, |
| 108 | ); |
| 109 | |
| 110 | gfx.state.gl.tex_parameter_i32( |
| 111 | glow::TEXTURE_2D, |
| 112 | glow::TEXTURE_MAG_FILTER, |
| 113 | glow::NEAREST as i32, |
| 114 | ); |
| 115 | |
| 116 | gfx.state.gl.tex_parameter_i32( |
| 117 | glow::TEXTURE_2D, |
| 118 | glow::TEXTURE_WRAP_S, |
| 119 | glow::CLAMP_TO_EDGE as i32, |
| 120 | ); |
| 121 | |
| 122 | gfx.state.gl.tex_parameter_i32( |
| 123 | glow::TEXTURE_2D, |
| 124 | glow::TEXTURE_WRAP_T, |
| 125 | glow::CLAMP_TO_EDGE as i32, |
| 126 | ); |
| 127 | |
| 128 | gfx.state |
| 129 | .gl |
| 130 | .tex_parameter_i32(glow::TEXTURE_2D, glow::TEXTURE_BASE_LEVEL, 0); |
| 131 | |
| 132 | gfx.state |
| 133 | .gl |
| 134 | .tex_parameter_i32(glow::TEXTURE_2D, glow::TEXTURE_MAX_LEVEL, 0); |
| 135 | |
| 136 | gfx.state.gl.tex_image_2d( |
| 137 | glow::TEXTURE_2D, |
| 138 | 0, |
| 139 | glow::RGBA8 as i32, |
| 140 | width, |
| 141 | height, |
| 142 | 0, |
| 143 | glow::RGBA, |
| 144 | glow::UNSIGNED_BYTE, |
| 145 | PixelUnpackData::Slice(Some(data)), |
| 146 | ); |
| 147 | |
| 148 | RawTexture { |
| 149 | gfx: gfx.clone(), |
| 150 | id, |
| 151 | width, |
| 152 | height, |
| 153 | } |
nothing calls this directly
no test coverage detected