minor graphic modification

This commit is contained in:
Mwa
2026-03-17 23:10:58 +01:00
parent 94120273bb
commit 5c5d8471fa
2 changed files with 13 additions and 13 deletions

View File

@@ -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];
}