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

Method OnDraw

Source/Engine/Engine/Engine.cpp:377–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377void Engine::OnDraw()
378{
379#if COMPILE_WITH_PROFILER
380 // Auto-enable GPU events when Tracy got connected
381 if (!ProfilerGPU::EventsEnabled && TracyIsConnected)
382 ProfilerGPU::EventsEnabled = true;
383#endif
384 PROFILE_CPU_NAMED("Draw");
385
386 // Begin frame rendering
387 FrameCount++;
388 const double time = Platform::GetTimeSeconds();
389 auto device = GPUDevice::Instance;
390 device->Locker.Lock();
391#if COMPILE_WITH_PROFILER
392 ProfilerGPU::BeginFrame();
393#endif
394
395 device->Draw();
396
397 // End frame rendering
398 FrameMark;
399#if COMPILE_WITH_PROFILER
400 ProfilerGPU::EndFrame();
401#endif
402 device->Locker.Unlock();
403
404 // Calculate FPS
405 EngineImpl::FpsAccumulatedFrames++;
406 if (time - EngineImpl::FpsAccumulated >= 1.0)
407 {
408 EngineImpl::Fps = EngineImpl::FpsAccumulatedFrames;
409 EngineImpl::FpsAccumulatedFrames = 0;
410 EngineImpl::FpsAccumulated = time;
411 }
412
413#if !LOG_ENABLE_AUTO_FLUSH
414 // Flush log file every fourth frame
415 if (FrameCount % 4 == 0)
416 {
417 LOG_FLUSH();
418 }
419#endif
420}
421
422bool Engine::IsHeadless()
423{

Callers

nothing calls this directly

Calls 3

LockMethod · 0.80
UnlockMethod · 0.80
DrawMethod · 0.45

Tested by

no test coverage detected