MCPcopy Create free account
hub / github.com/LukasBanana/LLGL / OnDrawFrame

Method OnDrawFrame

examples/Cpp/HelloGame/HelloGame.cpp:2046–2116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2044 }
2045
2046 void OnDrawFrame() override
2047 {
2048 // Update scene by user input
2049 timer.MeasureTime();
2050 UpdateScene(static_cast<float>(timer.GetDeltaTime()));
2051
2052 commands->Begin();
2053 {
2054 // Bind common input assembly
2055 commands->SetVertexBuffer(*vertexBuffer);
2056
2057 instanceBuffer.Update(*commands, 0, &player.instance, sizeof(player.instance));
2058
2059 // Update mesh instances in dirty range
2060 if (currentLevel != nullptr)
2061 {
2062 const std::uint32_t numInstancesToUpdate = currentLevel->meshInstanceDirtyRange.Count();
2063 if (numInstancesToUpdate > 0)
2064 {
2065 // Update mesh instance buffer
2066 const std::uint32_t firstInstanceToUpdate = (1 + nextLevelInstanceOffset + currentLevel->meshInstanceDirtyRange.begin);
2067
2068 instanceBuffer.Update(
2069 *commands,
2070 sizeof(Instance) * firstInstanceToUpdate,
2071 &(currentLevel->meshInstances[currentLevel->meshInstanceDirtyRange.begin]),
2072 static_cast<std::uint16_t>(sizeof(Instance) * numInstancesToUpdate)
2073 );
2074
2075 // Reset dirty range
2076 currentLevel->meshInstanceDirtyRange.Invalidate();
2077 }
2078 }
2079
2080 // Render shadow-map
2081 SetShadowMapView();
2082 commands->UpdateBuffer(*cbufferScene, 0, &scene, sizeof(scene));
2083
2084 commands->BeginRenderPass(*shadowMapTarget);
2085 {
2086 // Clear depth buffer only, we will render the entire framebuffer
2087 commands->Clear(LLGL::ClearFlags::Depth);
2088 commands->SetViewport(shadowMapTarget->GetResolution());
2089 commands->PushDebugGroup("RenderShadowMap");
2090 {
2091 RenderScene(true);
2092 }
2093 commands->PopDebugGroup();
2094 }
2095 commands->EndRenderPass();
2096
2097 // Render everything directly into the swap-chain
2098 SetCameraView();
2099 commands->UpdateBuffer(*cbufferScene, 0, &scene, sizeof(scene));
2100
2101 commands->BeginRenderPass(*swapChain);
2102 {
2103 // Clear depth buffer only, we will render the entire framebuffer

Callers

nothing calls this directly

Calls 15

UpdateSceneFunction · 0.85
GetDeltaTimeMethod · 0.80
InvalidateMethod · 0.80
BeginMethod · 0.65
SetVertexBufferMethod · 0.65
UpdateBufferMethod · 0.65
BeginRenderPassMethod · 0.65
ClearMethod · 0.65
SetViewportMethod · 0.65
GetResolutionMethod · 0.65
PushDebugGroupMethod · 0.65
PopDebugGroupMethod · 0.65

Tested by

no test coverage detected