#include "App.h" #include #include #include "Box.h" #include App::App() : wnd( 800,600,"Oasis Demo") { std::mt19937 rng(std::random_device{}()); std::uniform_real_distribution adist(0.0f, 3.1415f * 2.0f); std::uniform_real_distribution ddist(0.0f, 3.1415f * 2.0f); std::uniform_real_distribution odist(0.0f, 3.1415f * 0.3f); std::uniform_real_distribution rdist(6.0f, 20.0f); for (auto i = 0; i < 8; i++) { boxes.push_back(std::make_unique( wnd.Gfx(), rng, adist, ddist, odist, rdist )); } wnd.Gfx().SetProjection(DirectX::XMMatrixPerspectiveLH(1.0f, 3.0f / 4.0f, 0.5f, 40.0f)); } int App::Go() { while (true) { // process all messages pending, but to not block for new messages if (const auto ecode = Window::ProcessMessages()) { // if return optional has value, means we're quitting so return exit code return *ecode; } DoFrame(); } } App::~App() {} void App::DoFrame() { auto dt = timer.Mark(); wnd.Gfx().ClearBuffer(0.07f, 0.0f, 0.12f); for (auto& b : boxes) { b->Update(dt); b->Draw(wnd.Gfx()); } wnd.Gfx().EndFrame(); }