#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use windows::core::*;
use windows::Win32::Foundation::{HWND, POINT, SIZE};
use wintf::ecs::{Window, WindowHandle, WindowPos};
use wintf::*;
fn main() -> Result<()> {
println!("\n========== Multi-Window Graphics Test ==========\n");
human_panic::setup_panic!();
let mgr = WinThreadMgr::new()?;
let world = mgr.world();
println!("[Test] Creating 3 windows...");
world.borrow_mut().world_mut().spawn((
Window {
title: "Test Window 1".to_string(),
..Default::default()
},
WindowPos {
position: Some(POINT { x: 100, y: 100 }),
size: Some(SIZE { cx: 400, cy: 300 }),
..Default::default()
},
));
world.borrow_mut().world_mut().spawn((
Window {
title: "Test Window 2".to_string(),
..Default::default()
},
WindowPos {
position: Some(POINT { x: 550, y: 100 }),
size: Some(SIZE { cx: 400, cy: 300 }),
..Default::default()
},
));
world.borrow_mut().world_mut().spawn((
Window {
title: "Test Window 3".to_string(),
..Default::default()
},
WindowPos {
position: Some(POINT { x: 325, y: 450 }),
size: Some(SIZE { cx: 400, cy: 300 }),
..Default::default()
},
));
println!("[Test] Windows spawned. Running schedules...\n");
world.borrow_mut().try_tick_world();
println!("[Test] First tick completed. Running second tick for graphics initialization...\n");
world.borrow_mut().try_tick_world();
println!("\n[Test] Verifying all windows have graphics components...\n");
use bevy_ecs::prelude::*;
use wintf::ecs::{VisualGraphics, WindowGraphics};
let entities: Vec<(Entity, HWND)> = {
let mut world_ref = world.borrow_mut();
let world_inner = world_ref.world_mut();
let mut query =
world_inner.query::<(Entity, &WindowHandle, &WindowGraphics, &VisualGraphics)>();
query
.iter(world_inner)
.map(|(e, h, _g, _v)| (e, h.hwnd))
.collect()
};
if entities.len() != 3 {
println!("[TEST FAIL] Expected 3 entities, found {}", entities.len());
println!("Press Enter to exit...");
let mut input = String::new();
std::io::stdin().read_line(&mut input).ok();
return Ok(());
}
println!("[TEST PASS] Found 3 entities with all graphics components");
for (entity, hwnd) in entities {
println!("\n[Test] Entity {:?} (HWND: {:?}):", entity, hwnd);
println!(" [PASS] WindowHandle + WindowGraphics + Visual present");
}
println!("\n========================================");
println!("✅ [TEST SUCCESS] All windows initialized correctly!");
println!("========================================\n");
println!("Press Enter to exit...");
let mut input = String::new();
std::io::stdin().read_line(&mut input).ok();
Ok(())
}