| 245 | } |
| 246 | |
| 247 | Viewport Camera::GetViewport() const |
| 248 | { |
| 249 | Viewport result = Viewport(Float2::Zero); |
| 250 | float dpiScale = Platform::GetDpiScale(); |
| 251 | |
| 252 | #if USE_EDITOR |
| 253 | // Editor |
| 254 | if (Editor::Managed) |
| 255 | { |
| 256 | result.Size = Editor::Managed->GetGameWindowSize(); |
| 257 | if (auto* window = Editor::Managed->GetGameWindow()) |
| 258 | dpiScale = window->GetDpiScale(); |
| 259 | } |
| 260 | #else |
| 261 | // Game |
| 262 | auto mainWin = Engine::MainWindow; |
| 263 | if (mainWin) |
| 264 | { |
| 265 | const auto size = mainWin->GetClientSize(); |
| 266 | result.Size = size; |
| 267 | dpiScale = mainWin->GetDpiScale(); |
| 268 | } |
| 269 | #endif |
| 270 | |
| 271 | // Remove DPI scale (game viewport coords are unscaled) |
| 272 | result.Size /= dpiScale; |
| 273 | |
| 274 | // Fallback to the default value |
| 275 | if (result.Size.MinValue() <= ZeroTolerance) |
| 276 | result.Size = Float2(1280, 720); |
| 277 | |
| 278 | return result; |
| 279 | } |
| 280 | |
| 281 | void Camera::GetMatrices(Matrix& view, Matrix& projection) const |
| 282 | { |
nothing calls this directly
no test coverage detected