Compare commits

..

1 Commits

Author SHA1 Message Date
fb3869b64e outrageous resize hack 2025-01-03 21:43:40 -08:00
2 changed files with 28 additions and 5 deletions
strafe-client/src
web-client

@ -14,6 +14,9 @@ WorkerDescription{
*/
//up to three frames in flight, dropping new frame requests when all three are busy, and dropping output frames when one renders out of order
fn print(message:&str){
web_sys::console::log_1(&message.into());
}
pub fn new<'a>(
mut graphics:crate::graphics::GraphicsState,
mut config:wgpu::SurfaceConfiguration,
@ -33,10 +36,18 @@ pub fn new<'a>(
}
Instruction::Render(frame_state)=>{
if let Some((size,user_settings))=resize.take(){
println!("Resizing to {:?}",size);
print(format!("Resizing to {:?}",size).as_str());
//let t0=std::time::Instant::now();
config.width=size.width.clamp(1,2560/2);
config.height=size.height.clamp(1,1440/2);
match size{
winit::dpi::PhysicalSize{width:2560,height:1440}=>{
config.width=size.width.clamp(1,2560);
config.height=size.height.clamp(1,1440);
},
_=>{
config.width=size.width.clamp(1,1280);
config.height=size.height.clamp(1,720);
}
}
surface.configure(&device,&config);
graphics.resize(&device,&config,&user_settings);
//println!("Resize took {:?}",t0.elapsed());

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Strafe Client</title>
<base data-trunk-public-url />
@ -13,13 +13,25 @@
width: 100%;
height: 100%;
}
.root {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.main-canvas {
margin: 0;
/* This allows the flexbox to grow to max size, this is needed for WebGPU */
flex: 1;
/* This forces CSS to ignore the width/height of the canvas, this is needed for WebGL */
contain: size;
}
</style>
</head>
<body>
<canvas class="main-canvas" id="canvas"></canvas>
<div class="root">
<canvas class="main-canvas" id="canvas"></canvas>
</div>
<link data-trunk rel="rust" href="../strafe-client/Cargo.toml"/>
</body>
</html>