| 422 | |
| 423 | |
| 424 | void Window::step() { |
| 425 | double frameTime = system::getTime(); |
| 426 | if (std::isfinite(internal->frameTime)) { |
| 427 | internal->lastFrameDuration = frameTime - internal->frameTime; |
| 428 | } |
| 429 | internal->frameTime = frameTime; |
| 430 | internal->fbCount = 0; |
| 431 | // double t1 = 0.0, t2 = 0.0, t3 = 0.0, t4 = 0.0, t5 = 0.0; |
| 432 | |
| 433 | // Make event handlers and step() have a clean NanoVG context |
| 434 | nvgReset(vg); |
| 435 | |
| 436 | bndSetFont(uiFont->handle); |
| 437 | |
| 438 | // Poll events |
| 439 | // Save and restore context because event handler set their own context based on which window they originate from. |
| 440 | Context* context = contextGet(); |
| 441 | glfwPollEvents(); |
| 442 | contextSet(context); |
| 443 | |
| 444 | // In case glfwPollEvents() sets another OpenGL context |
| 445 | glfwMakeContextCurrent(win); |
| 446 | |
| 447 | // Call cursorPosCallback every frame, not just when the mouse moves |
| 448 | { |
| 449 | double xpos, ypos; |
| 450 | glfwGetCursorPos(win, &xpos, &ypos); |
| 451 | cursorPosCallback(win, xpos, ypos); |
| 452 | } |
| 453 | gamepad::step(); |
| 454 | |
| 455 | // Set window title |
| 456 | std::string windowTitle = APP_NAME + " " + APP_EDITION_NAME + " " + APP_VERSION; |
| 457 | if (APP->patch->path != "") { |
| 458 | windowTitle += " - "; |
| 459 | if (!APP->history->isSaved()) |
| 460 | windowTitle += "*"; |
| 461 | windowTitle += system::getFilename(APP->patch->path); |
| 462 | } |
| 463 | if (windowTitle != internal->lastWindowTitle) { |
| 464 | glfwSetWindowTitle(win, windowTitle.c_str()); |
| 465 | internal->lastWindowTitle = windowTitle; |
| 466 | } |
| 467 | |
| 468 | // Get desired pixel ratio |
| 469 | float newPixelRatio; |
| 470 | if (settings::pixelRatio > 0.0) { |
| 471 | newPixelRatio = settings::pixelRatio; |
| 472 | } |
| 473 | else { |
| 474 | glfwGetWindowContentScale(win, &newPixelRatio, NULL); |
| 475 | newPixelRatio = std::floor(newPixelRatio + 0.5); |
| 476 | } |
| 477 | if (newPixelRatio != pixelRatio) { |
| 478 | pixelRatio = newPixelRatio; |
| 479 | APP->event->handleDirty(); |
| 480 | } |
| 481 |
no test coverage detected