minor graphic modification
This commit is contained in:
@@ -16,7 +16,8 @@ use std::sync::{
|
||||
use std::thread::scope;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use pixels::{Error, Pixels, SurfaceTexture};
|
||||
use pixels::wgpu::{BlendState, Color};
|
||||
use pixels::{Error, Pixels, PixelsBuilder, SurfaceTexture};
|
||||
use winit::application::ApplicationHandler;
|
||||
use winit::dpi::LogicalSize;
|
||||
use winit::event::WindowEvent;
|
||||
@@ -58,8 +59,7 @@ impl<'a> ApplicationHandler for App<'a> {
|
||||
Window::default_attributes()
|
||||
.with_title("bisare screen")
|
||||
.with_min_inner_size(size)
|
||||
.with_maximized(true)
|
||||
.with_transparent(true),
|
||||
.with_maximized(true),
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
@@ -67,7 +67,11 @@ impl<'a> ApplicationHandler for App<'a> {
|
||||
self.w = Some(window.clone());
|
||||
let size = window.inner_size();
|
||||
let surface_texture = SurfaceTexture::new(size.width, size.height, window);
|
||||
self.pixels = Some(Pixels::new(WIDTH, HEIGHT, surface_texture).unwrap());
|
||||
let pix = PixelsBuilder::new(WIDTH, HEIGHT, surface_texture)
|
||||
.clear_color(Color::BLACK)
|
||||
.blend_state(BlendState::REPLACE).build() ;
|
||||
|
||||
self.pixels = Some(pix.unwrap());
|
||||
}
|
||||
|
||||
fn window_event(
|
||||
@@ -208,14 +212,10 @@ impl<'a> ApplicationHandler for App<'a> {
|
||||
for (addr, ubgr) in cpu::SHARED.screen_buf.iter().enumerate() {
|
||||
let raw = ubgr.load(std::sync::atomic::Ordering::Relaxed);
|
||||
#[cfg(not(feature = "rgba"))]
|
||||
let rgba = [raw as u8, (raw >> 8) as u8, (raw >> 16) as u8, 0xff];
|
||||
let rgba: [u8;4] = raw.to_le_bytes();
|
||||
#[cfg(feature = "rgba")]
|
||||
let rgba = [
|
||||
(raw >> 24) as u8,
|
||||
(raw >> 16) as u8,
|
||||
(raw >> 8) as u8,
|
||||
raw as u8,
|
||||
];
|
||||
let rgba =
|
||||
raw.to_be_bytes();
|
||||
for i in 0..4 {
|
||||
screen[addr * 4 + i] = rgba[i];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user