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

Function initVideo

src/init.cpp:1556–1722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1554}
1555
1556bool initVideo()
1557{
1558 if (!renderer) {
1559 // On Apple:
1560 // * the highest supported compatibility-profile version is 2.1
1561 // * the highest supported core-profile version is 4.1
1562 // * the lowest supported core-profile version is 3.2
1563 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
1564 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
1565 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
1566 //SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
1567 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
1568 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
1569 //SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
1570 }
1571
1572 // desired screen dimensions + position
1573 int screen_x = 0;
1574 int screen_y = 0;
1575 int screen_width = xres;
1576 int screen_height = yres;
1577
1578 printlog("attempting to set display mode to %dx%d on device %d...", screen_width, screen_height, display_id);
1579
1580 /*
1581
1582 2022-11-16
1583
1584 Fullscreen modes in SDL2 are absolutely broken right now on all platforms besides Windows. We are experiencing:
1585
1586 - display server crashes when changing video mode (must be reset in a desktop properties window)
1587 - severe visual glitches when reverting to windowed mode in fullscreen desktop
1588 - fullscreen desktop mode only supports native res - you can't downscale
1589 - window can be placed on the wrong display, and on wayland, it can't be moved at all
1590 - window size sometimes changes but not actual display mode
1591 - window position sometimes wrong, mouse stops at wrong place
1592 - huge black bars (display mode or window size changes, but not contents)
1593 - on macOS 13 "Ventura" SDL_SetWindowFullscreen() crashes to desktop... lovely
1594
1595 So, "true" fullscreen mode is cancelled on POSIX devices. Thanks SDL.
1596
1597 */
1598
1599 if ( !screen )
1600 {
1601 Uint32 flags = 0;
1602 flags |= SDL_WINDOW_OPENGL;
1603
1604#ifndef EDITOR
1605 flags |= SDL_WINDOW_ALLOW_HIGHDPI;
1606#endif
1607
1608 flags |= SDL_WINDOW_RESIZABLE;
1609
1610#ifdef PANDORA
1611 flags |= SDL_WINDOW_FULLSCREEN;
1612#endif
1613

Callers 2

initAppFunction · 0.85
changeVideoModeFunction · 0.85

Calls 2

printlogFunction · 0.85
positionAndLimitWindowFunction · 0.85

Tested by

no test coverage detected