MCPcopy Create free account
hub / github.com/TurningWheel/Barony / changeVideoMode

Function changeVideoMode

src/init.cpp:1734–1792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1732-------------------------------------------------------------------------------*/
1733
1734bool changeVideoMode(int new_xres, int new_yres)
1735{
1736 float factorX, factorY;
1737 {
1738 int w1, w2, h1, h2;
1739 SDL_GL_GetDrawableSize(screen, &w1, &h1);
1740 SDL_GetWindowSize(screen, &w2, &h2);
1741 factorX = (float)w1 / w2;
1742 factorY = (float)h1 / h2;
1743 }
1744 if (new_xres) {
1745 xres = std::max(1024, new_xres);
1746 }
1747 if (new_yres) {
1748 yres = std::max(720, new_yres);
1749 }
1750 xres /= factorX;
1751 yres /= factorY;
1752 printlog("changing video mode (%d x %d).\n", xres, yres);
1753
1754 // destroy gui fbo
1755 main_framebuffer.destroy();
1756 Frame::fboDestroy();
1757
1758 // set video mode
1759 int result = initVideo();
1760 if ( !result )
1761 {
1762#if defined(APPLE) && !defined(EDITOR)
1763 xres = 2560;
1764 yres = 1440;
1765#else
1766 xres = 1280;
1767 yres = 720;
1768#endif
1769 fullscreen = 0;
1770 borderless = false;
1771 printlog("defaulting to safe video mode...\n");
1772 if ( !initVideo() )
1773 {
1774 return false;
1775 }
1776 }
1777
1778 // create new framebuffers
1779 Frame::fboInit();
1780 if (!hdrEnabled) {
1781 main_framebuffer.unbindForWriting();
1782 }
1783 main_framebuffer.init(xres, yres, GL_NEAREST, GL_NEAREST);
1784 if (!hdrEnabled) {
1785 main_framebuffer.bindForWriting();
1786 }
1787 GL_CHECK_ERR(glClearColor(0.f, 0.f, 0.f, 1.f));
1788 GL_CHECK_ERR(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
1789
1790 // success
1791 return true;

Callers 2

handleEventsFunction · 0.85
consolecommand.cppFile · 0.85

Calls 6

printlogFunction · 0.85
initVideoFunction · 0.85
unbindForWritingMethod · 0.80
bindForWritingMethod · 0.80
destroyMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected