MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / scene_will_connect

Function scene_will_connect

native/ios/src/lib.rs:242–424  ·  view source on GitHub ↗
(
    _this: *mut c_void,
    _sel: Sel,
    scene: *const AnyObject,
    _session: *const AnyObject,
    _options: *const AnyObject,
)

Source from the content-addressed store, hash-verified

240// ============================================================
241
242unsafe extern "C" fn scene_will_connect(
243 _this: *mut c_void,
244 _sel: Sel,
245 scene: *const AnyObject,
246 _session: *const AnyObject,
247 _options: *const AnyObject,
248) {
249 if scene.is_null() { return; }
250
251 // Get screen bounds from UIScreen.mainScreen (simpler than scene.screen)
252 let screen_cls = AnyClass::get(c"UIScreen").unwrap();
253 let screen: Retained<AnyObject> = msg_send![screen_cls, mainScreen];
254 let bounds: CGRect = msg_send![&*screen, bounds];
255 let scale: f64 = msg_send![&*screen, scale];
256
257 let pixel_width = (bounds.size.width * scale) as u32;
258 let pixel_height = (bounds.size.height * scale) as u32;
259
260 // Create UIWindow attached to the scene
261 let window_cls = AnyClass::get(c"UIWindow").unwrap();
262 let window: Allocated<AnyObject> = msg_send![window_cls, alloc];
263 let window: Retained<AnyObject> = msg_send![window, initWithWindowScene: scene];
264
265 // Create BloomViewController (with orientation lock support)
266 let vc_cls = AnyClass::get(c"BloomViewController")
267 .unwrap_or_else(|| AnyClass::get(c"UIViewController").unwrap());
268 let vc: Allocated<AnyObject> = msg_send![vc_cls, alloc];
269 let vc: Retained<AnyObject> = msg_send![vc, init];
270
271 // Create BloomMetalView
272 let view_cls = AnyClass::get(c"BloomMetalView").unwrap();
273 let view: Allocated<AnyObject> = msg_send![view_cls, alloc];
274 let view: Retained<AnyObject> = msg_send![view, initWithFrame: bounds];
275
276 // Set background to green (diagnostic — visible if Metal isn't rendering)
277 let color_cls = AnyClass::get(c"UIColor").unwrap();
278 let green: Retained<AnyObject> = msg_send![color_cls, greenColor];
279 let _: () = msg_send![&*view, setBackgroundColor: &*green];
280
281 // Configure CAMetalLayer
282 let layer: Retained<AnyObject> = msg_send![&*view, layer];
283 let drawable_size = CGSize { width: pixel_width as f64, height: pixel_height as f64 };
284 let _: () = msg_send![&*layer, setDrawableSize: drawable_size];
285 let _: () = msg_send![&*layer, setContentsScale: scale];
286 let _: () = msg_send![&*layer, setOpaque: Bool::NO]; // Non-opaque so green shows if Metal fails
287
288 // Enable touches
289 let _: () = msg_send![&*view, setUserInteractionEnabled: Bool::YES];
290 let _: () = msg_send![&*view, setMultipleTouchEnabled: Bool::YES];
291
292 // Set up window hierarchy
293 let _: () = msg_send![&*vc, setView: &*view];
294 let _: () = msg_send![&*window, setRootViewController: &*vc];
295 let _: () = msg_send![&*window, makeKeyAndVisible];
296
297 // Store references
298 UI_VIEW = Some(view.clone());
299 UI_WINDOW = Some(window);

Callers

nothing calls this directly

Calls 4

getFunction · 0.85
cloneMethod · 0.80
iterMethod · 0.80
pollster_block_onFunction · 0.70

Tested by

no test coverage detected