Examples: Fix crash/high CPU usage when minimized

This commit is contained in:
SirLynix 2022-06-16 19:57:40 +02:00
parent 976bc09079
commit f3c889c5d5
7 changed files with 41 additions and 0 deletions

View File

@ -7,8 +7,10 @@
#include <NZSL/FieldOffsets.hpp>
#include <NZSL/Parser.hpp>
#include <array>
#include <chrono>
#include <iostream>
#include <random>
#include <thread>
NAZARA_REQUEST_DEDICATED_GPU()
@ -1176,7 +1178,10 @@ int main()
Nz::RenderFrame frame = window.AcquireFrame();
if (!frame)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue;
}
currentFrame = &frame;

View File

@ -6,7 +6,9 @@
#include <NZSL/SpirvPrinter.hpp>
#include <Nazara/Utility.hpp>
#include <array>
#include <chrono>
#include <iostream>
#include <thread>
int main()
{
@ -215,7 +217,10 @@ int main()
Nz::RenderFrame frame = window.AcquireFrame();
if (!frame)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue;
}
viewerInstance.UpdateViewMatrix(Nz::Matrix4f::TransformInverse(viewerPos, camAngles));
viewerInstance.UpdateEyePosition(viewerPos);

View File

@ -16,8 +16,10 @@
#include <Nazara/Widgets.hpp>
#include <entt/entt.hpp>
#include <array>
#include <chrono>
#include <iostream>
#include <limits>
#include <thread>
NAZARA_REQUEST_DEDICATED_GPU()
@ -169,7 +171,10 @@ int main()
Nz::RenderFrame frame = window.AcquireFrame();
if (!frame)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue;
}
renderSystem.Render(registry, frame);

View File

@ -15,8 +15,10 @@
#include <Nazara/Utility/Components.hpp>
#include <entt/entt.hpp>
#include <array>
#include <chrono>
#include <iostream>
#include <limits>
#include <thread>
NAZARA_REQUEST_DEDICATED_GPU()
@ -360,7 +362,10 @@ int main()
Nz::RenderFrame frame = window.AcquireFrame();
if (!frame)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue;
}
renderSystem.Render(registry, frame);

View File

@ -8,7 +8,9 @@
#include <NZSL/Ast/SanitizeVisitor.hpp>
#include <Nazara/Utility.hpp>
#include <array>
#include <chrono>
#include <iostream>
#include <thread>
NAZARA_REQUEST_DEDICATED_GPU()
@ -322,7 +324,10 @@ int main()
Nz::RenderFrame frame = window.AcquireFrame();
if (!frame)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue;
}
ubo.viewMatrix = Nz::Matrix4f::TransformInverse(viewerPos, camAngles);

View File

@ -7,7 +7,9 @@
#include <Nazara/Utility.hpp>
#include <Nazara/Utility/Components.hpp>
#include <entt/entt.hpp>
#include <chrono>
#include <iostream>
#include <thread>
int main()
{
@ -62,6 +64,12 @@ int main()
mainWindow.ProcessEvents();
Nz::RenderFrame renderFrame = mainWindow.AcquireFrame();
if (!renderFrame)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue;
}
renderSystem.Render(registry, renderFrame);
renderFrame.Present();

View File

@ -7,7 +7,9 @@
#include <Nazara/Utility.hpp>
#include <Nazara/Utility/Components.hpp>
#include <entt/entt.hpp>
#include <chrono>
#include <iostream>
#include <thread>
int main()
{
@ -79,6 +81,12 @@ int main()
mainWindow.ProcessEvents();
Nz::RenderFrame renderFrame = mainWindow.AcquireFrame();
if (!renderFrame)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue;
}
renderSystem.Render(registry, renderFrame);
renderFrame.Present();