aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2017-11-15 10:35:04 -0500
committerDeterminant <[email protected]>2017-11-15 10:35:04 -0500
commit9c4afed302d41df3217fb6e409782ce2f4c53f78 (patch)
tree90991dffa3ee8c7f0d61bfaafed5a7bbe966e31e /src
parent4ee558cabda9945ba9d01394f06c349db1689dad (diff)
use unsafe texture feature
Diffstat (limited to 'src')
-rw-r--r--src/main.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index c894e02..9220694 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -63,7 +63,7 @@ struct SDLWindow {
canvas: RefCell<sdl2::render::WindowCanvas>,
events: RefCell<sdl2::EventPump>,
frame_buffer: UnsafeCell<[u8; FB_SIZE]>,
- texture_creator: sdl2::render::TextureCreator<sdl2::video::WindowContext>,
+ texture: UnsafeCell<sdl2::render::Texture>
}
impl SDLWindow {
@@ -84,7 +84,8 @@ impl SDLWindow {
canvas: RefCell::new(canvas),
events: RefCell::new(sdl_context.event_pump().unwrap()),
frame_buffer: UnsafeCell::new([0; FB_SIZE]),
- texture_creator,
+ texture: UnsafeCell::new(texture_creator.create_texture_streaming(
+ PixelFormatEnum::RGB24, WIN_WIDTH, WIN_HEIGHT).unwrap())
}
}
@@ -130,12 +131,11 @@ impl ppu::Screen for SDLWindow {
fn render(&self) {
let mut canvas = self.canvas.borrow_mut();
let fb = unsafe{&*self.frame_buffer.get()};
- let mut texture = self.texture_creator.create_texture_streaming(
- PixelFormatEnum::RGB24, WIN_WIDTH, WIN_HEIGHT).unwrap();
- texture.update(Rect::new(0, 0, WIN_WIDTH, WIN_HEIGHT), fb, FB_PITCH).unwrap();
+ let texture = unsafe{&mut *self.texture.get()};
+ texture.update(None, fb, FB_PITCH).unwrap();
canvas.copy(&texture, None, Some(Rect::new(0, 0, WIN_WIDTH, WIN_HEIGHT))).unwrap();
canvas.present();
- canvas.set_draw_color(Color::RGB(128, 128, 128));
+ //canvas.set_draw_color(Color::RGB(128, 128, 128));
canvas.clear();
}
}