| 444 | |
| 445 | |
| 446 | bool setVideoFormat(int index, bool test) { |
| 447 | #if defined(_WIN32) |
| 448 | // give windows extra time to test format (context reloading takes a while) |
| 449 | static const float testDuration = 10.0f; |
| 450 | #else |
| 451 | static const float testDuration = 5.0f; |
| 452 | #endif |
| 453 | |
| 454 | // ignore bad formats or when the format test timer is running |
| 455 | if (testVideoFormatTimer != 0.0f || !display->isValidResolution(index)) { |
| 456 | return false; |
| 457 | } |
| 458 | |
| 459 | // ignore if no change |
| 460 | if (display->getResolution() == index) { return true; } |
| 461 | |
| 462 | // change it |
| 463 | testVideoPrevFormat = display->getResolution(); |
| 464 | if (!display->setResolution(index)) { return false; } |
| 465 | |
| 466 | // handle resize |
| 467 | mainWindow->setFullscreen(); |
| 468 | mainWindow->getWindow()->callResizeCallbacks(); |
| 469 | mainWindow->warpMouse(); |
| 470 | if (test) { testVideoFormatTimer = testDuration; } |
| 471 | else if (shouldGrabMouse()) { mainWindow->grabMouse(); } |
| 472 | return true; |
| 473 | } |
| 474 | |
| 475 | |
| 476 |
no test coverage detected