frametimes
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#include "progressiverenderer.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
|
||||
#include "../common.hpp"
|
||||
#include "../pixel.hpp"
|
||||
#include "../display/displayinterface.hpp"
|
||||
@@ -26,16 +29,21 @@ void ProgressiveRenderer::Render() {
|
||||
for (const auto& object : m_scene->objects)
|
||||
object->Translate({ 0.0f, -1.0f, -3.0f });
|
||||
|
||||
int frames = 0;
|
||||
auto startTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
while (m_interface->Active) {
|
||||
auto frameStartTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
// Take input
|
||||
SDL_Event e;
|
||||
while (SDL_PollEvent(&e))
|
||||
if (e.type == SDL_QUIT) m_interface->Close();
|
||||
|
||||
#pragma omp parallel for schedule(dynamic)
|
||||
for (int x = 0; x < m_scene->w; x++)
|
||||
#pragma omp parallel for schedule(dynamic)
|
||||
for (int y = 0; y < m_scene->h; y++) {
|
||||
|
||||
SDL_Event e;
|
||||
while (SDL_PollEvent(&e))
|
||||
if (e.type == SDL_QUIT) m_interface->Close();
|
||||
|
||||
Ray ray = m_scene->camera->CastRay(x, y);
|
||||
|
||||
float t, i;
|
||||
@@ -54,6 +62,17 @@ void ProgressiveRenderer::Render() {
|
||||
m_interface->SetPixelSafe(x, y, col.rgb());
|
||||
}
|
||||
|
||||
|
||||
auto endTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
frames++;
|
||||
std::cout << "Frame: " << frames << std::endl;
|
||||
std::cout << "Frame Time: " << std::chrono::duration_cast<std::chrono::seconds>(endTime - frameStartTime).count()
|
||||
<< ":" << std::chrono::duration_cast<std::chrono::milliseconds>(endTime - frameStartTime).count() << std::endl;
|
||||
std::cout << "Avg Frame Time: " << std::chrono::duration_cast<std::chrono::seconds>(endTime - startTime).count() / frames
|
||||
<< ":" << std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count() / frames
|
||||
<< std::endl << std::endl;
|
||||
|
||||
// Swap framebuffers
|
||||
m_interface->Update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user