MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GetViewport

Method GetViewport

Source/Engine/Level/Actors/Camera.cpp:247–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247Viewport 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
281void Camera::GetMatrices(Matrix& view, Matrix& projection) const
282{

Callers

nothing calls this directly

Calls 8

GetDpiScaleFunction · 0.85
Float2Class · 0.85
GetGameWindowSizeMethod · 0.80
GetGameWindowMethod · 0.80
GetDpiScaleMethod · 0.80
ViewportClass · 0.50
GetClientSizeMethod · 0.45
MinValueMethod · 0.45

Tested by

no test coverage detected