"Invalid texture" apparently...

This commit is contained in:
lif 2019-11-15 01:40:02 -08:00
parent 41a4a016f3
commit 33b3270c10
1 changed files with 11 additions and 4 deletions

View File

@ -119,9 +119,17 @@ impl retro::convert::Handler for MyEmulator {
fn video_refresh(&mut self, data: &[u8], width: u32, height: u32, pitch: u32) {
//println!("video_refresh {}x{}", width, height);
//let rect = Rect::new(0, 0, width, height);
println!("{:?}", self.texture.is_some());
if let Some(ref mut tex) = self.texture {
tex.update(None, data, pitch as usize).unwrap();
if let Some(tex) = self.texture.as_mut() {
tex.with_lock(None, |tex_buffer: &mut [u8], tex_pitch: usize| {
let src_pitch = pitch as usize;
let src_width = width as usize;
for y in 0..(height as usize) {
let src_slice = (y * src_pitch)..((y * src_pitch) + src_width);
let tex_slice = (y * tex_pitch)..((y * tex_pitch) + src_width);
tex_buffer[tex_slice].copy_from_slice(&data[src_slice]);
}
}).unwrap();
//tex.update(None, data, pitch as usize).unwrap();
}
}
@ -145,7 +153,6 @@ pub fn main() -> failure::Fallible<()> {
let (width, height) = emu.base_dimensions();
let window = video_subsystem.window("rust libretro", width, height)
.position_centered()
.opengl()
.build()?;