project mouse into view when clicking w/ mouse unlocked

This commit is contained in:
2024-08-28 02:28:24 +10:00
parent 160c9c8a68
commit 503c48404c
12 changed files with 278 additions and 111 deletions

View File

@ -38,11 +38,16 @@ public class Application {
}
// Get window metrics
var backBuffer = Size<Int32>.zero
var backBuffer = Size<Int32>.zero, windowSize = Size<Int32>.zero
guard SDL_GetWindowSizeInPixels(window, &backBuffer.w, &backBuffer.h) >= 0 else {
printErr("SDL_GetWindowSizeInPixels() error: \(String(cString: SDL_GetError()))")
return .exitFailure
}
guard SDL_GetWindowSize(window, &windowSize.w, &windowSize.h) >= 0 else {
printErr("SDL_GetWindowSize() error: \(String(cString: SDL_GetError()))")
return .exitFailure
}
Mouse.instance.setDPI(scale: SIMD2(Size<Float>(backBuffer) / Size<Float>(windowSize)))
// Create Metal renderer
view = SDL_Metal_CreateView(window)