|
|
@@ -387,10 +387,12 @@ void Window::run() { |
|
|
|
|
|
|
|
|
|
|
|
void Window::step() { |
|
|
|
double frameTime = system::getTime(); |
|
|
|
double lastFrameTime = internal->frameTime; |
|
|
|
internal->frameTime = system::getTime(); |
|
|
|
internal->lastFrameDuration = internal->frameTime - lastFrameTime; |
|
|
|
internal->frameTime = frameTime; |
|
|
|
internal->lastFrameDuration = frameTime - lastFrameTime; |
|
|
|
// DEBUG("%.2lf Hz", 1.0 / internal->lastFrameDuration); |
|
|
|
double t1 = 0.0, t2 = 0.0, t3 = 0.0, t4 = 0.0, t5 = 0.0; |
|
|
|
|
|
|
|
// Make event handlers and step() have a clean NanoVG context |
|
|
|
nvgReset(vg); |
|
|
@@ -446,6 +448,7 @@ void Window::step() { |
|
|
|
int winWidth, winHeight; |
|
|
|
glfwGetWindowSize(win, &winWidth, &winHeight); |
|
|
|
windowRatio = (float)fbWidth / winWidth; |
|
|
|
t1 = system::getTime(); |
|
|
|
|
|
|
|
if (APP->scene) { |
|
|
|
// DEBUG("%f %f %d %d", pixelRatio, windowRatio, fbWidth, winWidth); |
|
|
@@ -454,6 +457,7 @@ void Window::step() { |
|
|
|
|
|
|
|
// Step scene |
|
|
|
APP->scene->step(); |
|
|
|
t2 = system::getTime(); |
|
|
|
|
|
|
|
// Render scene |
|
|
|
bool visible = glfwGetWindowAttrib(win, GLFW_VISIBLE) && !glfwGetWindowAttrib(win, GLFW_ICONIFIED); |
|
|
@@ -467,16 +471,27 @@ void Window::step() { |
|
|
|
args.vg = vg; |
|
|
|
args.clipBox = APP->scene->box.zeroPos(); |
|
|
|
APP->scene->draw(args); |
|
|
|
t3 = system::getTime(); |
|
|
|
|
|
|
|
glViewport(0, 0, fbWidth, fbHeight); |
|
|
|
glClearColor(0.0, 0.0, 0.0, 1.0); |
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
|
|
|
nvgEndFrame(vg); |
|
|
|
t4 = system::getTime(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
glfwSwapBuffers(win); |
|
|
|
|
|
|
|
t5 = system::getTime(); |
|
|
|
|
|
|
|
// DEBUG("pre-step %6.1f step %6.1f draw %6.1f nvgEndFrame %6.1f glfwSwapBuffers %6.1f total %6.1f", |
|
|
|
// (t1 - frameTime) * 1e3f, |
|
|
|
// (t2 - t1) * 1e3f, |
|
|
|
// (t3 - t2) * 1e3f, |
|
|
|
// (t4 - t2) * 1e3f, |
|
|
|
// (t5 - t4) * 1e3f, |
|
|
|
// (t5 - frameTime) * 1e3f |
|
|
|
// ); |
|
|
|
internal->frame++; |
|
|
|
} |
|
|
|
|
|
|
|