bool GraphicsSystem::CreateSFMLWindow() { uint32_t style = 0; if (IsFullscreen()) { style = sf::Style::Fullscreen; } else { style |= sf::Style::Close; if (IsResizable()) style |= sf::Style::Resize; if (IsDecorated()) style |= sf::Style::Titlebar; } m_SfWindow.create(sf::VideoMode(m_Width, m_Height), m_Title, style); m_SfWindow.setKeyRepeatEnabled(false); return m_SfWindow.isOpen(); }
void GForce::IdleMonitor() { bool kybdPress = false; float pollDelay; float secsUntilSleep = mScrnSaverDelay - ( mT - mLastActiveTime ); Point pt; // Calc time till next kybd poll (Don't waste time checking the kybd unless we've been idle a while) if ( IsFullscreen() ) pollDelay = .6; // Don't bother rapildly checking the kybd until we're really close to going into screen saver mode else if ( secsUntilSleep < 90 ) pollDelay = secsUntilSleep / 120.0; else pollDelay = 10; // If it's time to poll for activity... if ( mT > mLastKeyPollTime + pollDelay ) { mLastKeyPollTime = mT; // Check the mouse pos and record it as active if its been moved. EgOSUtils::GetMouse( pt ); if ( pt.h != mLastMousePt.h || pt.v != mLastMousePt.v || kybdPress ) { mLastMousePt = pt; mLastActiveTime = mT; } // If we're elligible to enter fullscreen then do it if ( ! mAtFullScreen && mT - mLastActiveTime > mScrnSaverDelay ) { mMouseWillAwaken = true; } } }
void Graphics::SetResolution(unsigned int width, unsigned int height) { DXGI_MODE_DESC modeDesc; DXGI_SWAP_CHAIN_DESC swapChainDesc; m_screenSize.cx = width; m_screenSize.cy = height; if(m_swapChain != NULL) { m_swapChain->GetDesc(&swapChainDesc); if(IsFullscreen() && swapChainDesc.Windowed) { SetResolution(800, 600); } else if(swapChainDesc.BufferDesc.Width != width || swapChainDesc.BufferDesc.Height != height) { m_isReady = false; SAFE_RELEASE(m_depthStencilView); SAFE_RELEASE(m_depthStencilState); SAFE_RELEASE(m_depthStencilBuffer); SAFE_RELEASE(m_renderTargetView); ZeroMemory(&modeDesc, sizeof(modeDesc)); modeDesc.Format = DXGI_FORMAT_UNKNOWN; modeDesc.Width = width; modeDesc.Height = height; m_swapChain->ResizeTarget( &modeDesc ); } } }
VOID SwapChainController12::ToggleFullscreen() { HRESULT hr = S_OK; BOOL Fullscreen = IsFullscreen(); if (Fullscreen == FALSE) { //Not in fullscreen currently, let's enter RECT DesktopArea; Output12* output = m_OutputEnum.SearchOutput(m_Handle); output->GetDesktopArea(&DesktopArea); DXGI_MODE_DESC mode; Zero(mode); CComPtr<IDXGIOutput4> obj = output->GetObj(); mode.Width = DesktopArea.right - DesktopArea.left; mode.Height = DesktopArea.bottom - DesktopArea.top; //ResizeTarget() should be called before SetFullscreenState(), as per MSDN recommendations hr = m_SwapChain->ResizeTarget ( &mode ); CHECK_HR(__LINE__); hr = m_SwapChain->SetFullscreenState ( TRUE, obj ); CHECK_HR(__LINE__); ResizeBuffers(); } else { hr = m_SwapChain->SetFullscreenState ( FALSE, nullptr ); CHECK_HR(__LINE__); } }
/** * @brief * Sets a new display mode */ void WindowConnection::SetDisplayMode(const DisplayMode &sDisplayMode) { // Even if there's no change within the display mode, the real widget size currently may be another than the display size - // in this situation, it's usually nice if the widget size is updated to the set display size, so, we don't perform an early escape test // Are we currently within fullscreen mode? if (IsFullscreen()) { // Any state change? if (m_sDisplayMode.vSize != sDisplayMode.vSize || m_sDisplayMode.nColorBits != sDisplayMode.nColorBits || m_sDisplayMode.nFrequency != sDisplayMode.nFrequency) { // Copy over the new settings m_sDisplayMode = sDisplayMode; // Backup information const SurfaceWindow *pSurface = static_cast<SurfaceWindow*>(GetSurface()); if (pSurface && pSurface->GetNativeWindowHandle()) { // Backup information bool bFullscreen = IsFullscreen(); SurfacePainter *pPainter = GetSurface()->GetPainter(); GetSurface()->SetPainter(nullptr, false); // De-init window DeInit(); // Set new widget size m_pWidget->SetWindowState(StateNormal); m_pWidget->SetSize(GetDisplayMode().vSize); // Init widget InitWidget(bFullscreen); // Set widget into fullscreen state? (the display should now already have the proper size) m_pWidget->SetWindowState(StateFullscreen); // Set previous surface painter GetSurface()->SetPainter(pPainter, false); } } } else { // Just copy over the new settings m_sDisplayMode = sDisplayMode; } // Emit event by using the proper virtual method OnDisplayMode(); }
HRESULT D3DWrapper::ToggleFullscreen() { HRESULT result = S_OK; result = m_swapChain->SetFullscreenState(!IsFullscreen(), NULL); return result; }
/* * Toggle fullscreen. */ void GLimp_ToggleFullscreen(void) { #if SDL_VERSION_ATLEAST(2, 0, 0) int wantFullscreen = !IsFullscreen(); SDL_SetWindowFullscreen(window, wantFullscreen ? SDL_WINDOW_FULLSCREEN : 0); Cvar_SetValue("vid_fullscreen", wantFullscreen); #else SDL_WM_ToggleFullScreen(window); if (IsFullscreen()) { Cvar_SetValue("vid_fullscreen", 1); } else { Cvar_SetValue("vid_fullscreen", 0); } #endif vid_fullscreen->modified = false; }
/** * @brief * Sets whether it's allowed to use Alt-Tab if fullscreen mode is used */ void WindowConnection::SetFullscreenAltTab(bool bAllowed) { m_bFullscreenAltTab = bAllowed; if (m_bFullscreenAltTab || !IsFullscreen()) { if (!m_bFullscreenAltTabKey) { // Release Alt-Tab hotkey m_pWidget->UnregisterHotkey(m_nHotkeyIDAltTab); } } else { if (!m_bFullscreenAltTabKey) { // Catch Alt-Tab hotkey so it can't be used during fullscreen m_nHotkeyIDAltTab = m_pWidget->RegisterHotkey(PLGUIMOD_ALT, PLGUIKEY_TAB); } } }
void Engine::SetFullscreen(bool b) { if(b == IsFullscreen()) return; // no change required uint32 flags = _screen->flags | _screenFlags; // toggle between fullscreen, preserving other flags if(b) flags |= SDL_FULLSCREEN; // add fullscreen flag else flags &= ~SDL_FULLSCREEN; // remove fullscreen flag InitScreen(GetResX(), GetResY(), GetBPP(), flags); }
/** * @brief * Sets the window's fullscreen mode */ void WindowConnection::SetFullscreen(bool bFullscreen) { // Set fullscreen mode if (IsFullscreen() != bFullscreen) { // Backup information const SurfaceWindow *pSurface = static_cast<SurfaceWindow*>(GetSurface()); if (pSurface && pSurface->GetNativeWindowHandle()) { // Backup information SurfacePainter *pPainter = GetSurface()->GetPainter(); GetSurface()->SetPainter(nullptr, false); // De-init window DeInit(); // [HACK] If the widget is currently maximized, change back to normal - if we don't do this and changing from // maximized to fullscreen, the window title is visible within the fullscreen mode... if (bFullscreen && m_pWidget->GetWindowState() == StateMaximized) m_pWidget->SetWindowState(StateNormal); // Init widget InitWidget(bFullscreen); // Set previous surface painter GetSurface()->SetPainter(pPainter, false); // Set widget into fullscreen state? (the display should now already have the proper size) if (bFullscreen) { m_pWidget->SetWindowState(StateFullscreen); } else { m_pWidget->SetWindowState(StateNormal); m_pWidget->SetSize(GetDisplayMode().vSize); } // Emit event by using the proper virtual method OnFullscreenMode(); } } }
gfx::Insets BrowserFrameWin::GetClientAreaInsets() const { // Use the default client insets for an opaque frame or a glass popup/app // frame. if(!GetWidget()->ShouldUseNativeFrame() || !browser_view_->IsBrowserTypeNormal()) { return NativeWidgetWin::GetClientAreaInsets(); } int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); // In fullscreen mode, we have no frame. In restored mode, we draw our own // client edge over part of the default frame. if(IsFullscreen()) { border_thickness = 0; } else if(!IsMaximized()) { border_thickness -= kClientEdgeThickness; } return gfx::Insets(0, border_thickness, border_thickness, border_thickness); }
void Graphics::SetFullscreen( bool fullscreen ) { if(IsFullscreen() != fullscreen) { if(m_swapChain != NULL) { if(fullscreen) { SetResolution(1680, 1050); m_fullscreen = fullscreen; m_swapChain->SetFullscreenState(fullscreen, NULL); } else { m_fullscreen = fullscreen; m_swapChain->SetFullscreenState(fullscreen, NULL); SetResolution(800, 600); } } } return; }
void BrowserFrameWin::UpdateDWMFrame() { // Nothing to do yet, or we're not showing a DWM frame. if(!GetWidget()->client_view() || !browser_frame_->ShouldUseNativeFrame()) { return; } MARGINS margins = { 0 }; if(browser_view_->IsBrowserTypeNormal()) { // In fullscreen mode, we don't extend glass into the client area at all, // because the GDI-drawn text in the web content composited over it will // become semi-transparent over any glass area. if(!IsMaximized() && !IsFullscreen()) { margins.cxLeftWidth = kClientEdgeThickness + 1; margins.cxRightWidth = kClientEdgeThickness + 1; margins.cyBottomHeight = kClientEdgeThickness + 1; margins.cyTopHeight = kClientEdgeThickness + 1; } // In maximized mode, we only have a titlebar strip of glass, no side/bottom // borders. if(!browser_view_->IsFullscreen()) { gfx::Rect tabstrip_bounds( browser_frame_->GetBoundsForTabStrip(browser_view_->tabstrip())); margins.cyTopHeight = tabstrip_bounds.bottom() + kDWMFrameTopOffset; } } else { // For popup and app windows we want to use the default margins. } DwmExtendFrameIntoClientArea(GetNativeView(), &margins); }
/** * @brief * Called when a key is pressed down */ void WindowConnection::OnKeyDown(uint32 nKey, uint32 nModifiers) { // Fullscreen mode toggle allowed and ALT+ENTER pressed? if (m_bToggleFullscreenMode && nKey == PLGUIKEY_RETURN && (nModifiers & PLGUIMOD_ALT) != 0) SetFullscreen(!IsFullscreen()); }
void GForce::RecordSample( long inCurTime ) { long intensity; float t; if ( &mPortA == mCurPort ) mCurPort = &mPortB; else mCurPort = &mPortA; // All the waveshape virtual machines are linked to our time index mT_MS = inCurTime - mT_MS_Base; mT = ( (float) inCurTime ) / 1000.0; // Don't bother doing mouse or kybd poll if sceeen saver mode is disabled if ( mScrnSaverDelay > 0 ) IdleMonitor(); ManageColorChanges(); ManageShapeChanges(); ManageFieldChanges(); ManageParticleChanges(); // Do the blur operation, a fcn of what's oqn the screen, and the current delta field if ( mCurPort == &mPortA ) mPortB.Fade( mPortA, mField -> GetField() ); else mPortA.Fade( mPortB, mField -> GetField() ); /* This redraws the image */ // Draw all the current particles DrawParticles( *mCurPort ); // Draw the current wave shape for the current music sample playing // If there's a morph going, drawing is a mix of both waves if ( mShapeTransTime > 0 ) { float morphPct = (float) ( mShapeTransEnd - mT_MS ) / ( (float) mShapeTransTime ); mWave -> Draw( mNum_S_Steps, *mCurPort, 1, mNextWave, morphPct ); } else mWave -> Draw( mNum_S_Steps, *mCurPort, 1, 0, 0 ); // If we're not currently drawing track text, check to see if we start new text if ( mTrackTextDur == 0 && mTrackTextPosMode ) { if ( mTrackTextStartFcn.Evaluate() > 0 ) StartTrackText(); } // If we already have a t.t. draw in progress, draw the text in the (full) foreground color if ( mTrackTextDur > 0 ) { // From 0 to 1, how far are we into the text display interval? t = ( mT - mTrackTextStartTime ) / mTrackTextDur; // Decrease the text intensity thru time intensity = 255 * ( 1.2 - .3*t ); if ( intensity > 255 ) intensity = 255; mCurPort -> SetTextColor( mPalette[ intensity ] ); mCurPort -> SetTrackTextFont(); mCurPort -> DrawText( mTrackTextPos.h, mTrackTextPos.v, mTrackText ); } // Draw the console text to the offscreen image. Then copy the image to the OS out port if ( mT_MS < mConsoleExpireTime ) { // To ensure the console text is readable, we erase it when we're done mCurPort -> SetTextMode( SRC_XOR ); mCurPort -> SetTextColor( mPalette[ 255 ] ); mCurPort -> SetConsoleFont(); DrawConsole(); DrawFrame(); mCurPort -> SetTextColor( mPalette[ 0 ] ); DrawConsole(); mCurPort -> SetTextMode( SRC_OR ); } else DrawFrame(); // We need to avoid text all bluring together so we overwrite the foreground text we just drew // with text of a lower intensity... if ( mTrackTextDur > 0 ) { // Is the text is about to expire? if not, continue drawing. if ( t <= 1 ) { intensity = 255.5 * pow( t, 1.5 ); mCurPort -> SetTextColor( mPalette[ intensity ] ); mCurPort -> SetTrackTextFont(); mCurPort -> DrawText( mTrackTextPos.h, mTrackTextPos.v, mTrackText ); } else { // The text's duration is up so turn the draw flag off mTrackTextDur = 0; } } // Maintain the frame rate mFrameCount++; if ( mT_MS - mFrameCountStart >= 1500 ) { mCurFrameRate = 10000 * mFrameCount / ( mT_MS - mFrameCountStart ); mFrameCountStart = mT_MS; mFrameCount = 0; } if ( mT_MS - mLastCursorUpdate > 3000 ) { mLastCursorUpdate = mT_MS; if ( IsFullscreen() ) EgOSUtils::HideCursor(); } }
// // Command line. // UBOOL UXViewport::Exec( const TCHAR* Cmd, FOutputDevice& Ar ) { guard(UXViewport::Exec); if( UViewport::Exec( Cmd, Ar ) ) { return 1; } else if( ParseCommand(&Cmd,TEXT("EndFullscreen")) ) { EndFullscreen(); return 1; } else if( ParseCommand(&Cmd,TEXT("ToggleFullscreen")) ) { ToggleFullscreen(); return 1; } else if( ParseCommand(&Cmd,TEXT("Iconify")) ) { Iconify(); return 1; } else if( ParseCommand(&Cmd,TEXT("GetCurrentRes")) ) { Ar.Logf( TEXT("%ix%i"), SizeX, SizeY, (ColorBytes?ColorBytes:2)*8 ); return 1; } else if( ParseCommand(&Cmd,TEXT("GetCurrentColorDepth")) ) { Ar.Logf( TEXT("%i"), (ColorBytes?ColorBytes:2)*8 ); return 1; } else if( ParseCommand(&Cmd,TEXT("GetColorDepths")) ) { Ar.Log( TEXT("16 32") ); return 1; } else if( ParseCommand(&Cmd,TEXT("GetCurrentRenderDevice")) ) { Ar.Log( RenDev->GetClass()->GetPathName() ); return 1; } else if( ParseCommand(&Cmd,TEXT("SetRenderDevice")) ) { FString Saved = RenDev->GetClass()->GetPathName(); INT SavedSizeX=SizeX, SavedSizeY=SizeY, SavedColorBytes=ColorBytes, SavedFullscreen=((BlitFlags & BLIT_Fullscreen)!=0); TryRenderDevice( Cmd, SizeX, SizeY, ColorBytes, SavedFullscreen ); if( !RenDev ) { TryRenderDevice( *Saved, SavedSizeX, SavedSizeY, SavedColorBytes, SavedFullscreen ); check(RenDev); Ar.Log(TEXT("0")); } else Ar.Log(TEXT("1")); return 1; } else if( ParseCommand(&Cmd,TEXT("GetRes")) ) { return 1; } else if( ParseCommand(&Cmd,TEXT("SetRes")) ) { INT X=appAtoi(Cmd); TCHAR* CmdTemp = (TCHAR*) (appStrchr(Cmd,'x') ? appStrchr(Cmd,'x')+1 : appStrchr(Cmd,'X') ? appStrchr(Cmd,'X')+1 : TEXT("")); INT Y=appAtoi(CmdTemp); Cmd = CmdTemp; CmdTemp = (TCHAR*) (appStrchr(Cmd,'x') ? appStrchr(Cmd,'x')+1 : appStrchr(Cmd,'X') ? appStrchr(Cmd,'X')+1 : TEXT("")); INT C=appAtoi(CmdTemp); INT NewColorBytes = C ? C/8 : ColorBytes; if( X && Y ) { HoldCount++; UBOOL Result = RenDev->SetRes( X, Y, NewColorBytes, IsFullscreen() ); HoldCount--; if( !Result ) EndFullscreen(); } return 1; } else if( ParseCommand(&Cmd,TEXT("Preferences")) ) { // No preferences window. return 1; } else return 0; unguard; }
void __INPUT_RECORD_Dump(INPUT_RECORD *rec, wchar_t* pszRecord) { switch(rec->EventType) { case FOCUS_EVENT: wsprintfW(pszRecord, L"FOCUS_EVENT_RECORD: %s", (rec->Event.FocusEvent.bSetFocus?L"TRUE":L"FALSE") ); break; case WINDOW_BUFFER_SIZE_EVENT: wsprintfW(pszRecord, L"WINDOW_BUFFER_SIZE_RECORD: Size = [%d, %d]", rec->Event.WindowBufferSizeEvent.dwSize.X, rec->Event.WindowBufferSizeEvent.dwSize.Y ); break; case MENU_EVENT: wsprintfW(pszRecord, L"MENU_EVENT_RECORD: CommandId = %d (0x%X) ", rec->Event.MenuEvent.dwCommandId, rec->Event.MenuEvent.dwCommandId ); break; case KEY_EVENT: case 0: { WORD AsciiChar = (WORD)(BYTE)rec->Event.KeyEvent.uChar.AsciiChar; wchar_t szKeyName[255]; wsprintfW(pszRecord, L"%s: %s, %d, Vk=%s, Scan=0x%04X uChar=[U='%c' (0x%04X): A='%C' (0x%02X)]\n Ctrl=0x%08X (%c%c%c%c%c - %c%c%c%c)", (rec->EventType==KEY_EVENT?L"KEY_EVENT_RECORD":L"NULL_EVENT_RECORD"), (rec->Event.KeyEvent.bKeyDown?L"Dn":L"Up"), rec->Event.KeyEvent.wRepeatCount, __VK_KEY_ToName(rec->Event.KeyEvent.wVirtualKeyCode, szKeyName), rec->Event.KeyEvent.wVirtualScanCode, ((rec->Event.KeyEvent.uChar.UnicodeChar && !(rec->Event.KeyEvent.uChar.UnicodeChar == L'\t' || rec->Event.KeyEvent.uChar.UnicodeChar == L'\r' || rec->Event.KeyEvent.uChar.UnicodeChar == L'\n'))?rec->Event.KeyEvent.uChar.UnicodeChar:L' '), rec->Event.KeyEvent.uChar.UnicodeChar, (AsciiChar && AsciiChar != '\r' && AsciiChar != '\t' && AsciiChar !='\n' ?AsciiChar:' '), AsciiChar, rec->Event.KeyEvent.dwControlKeyState, (rec->Event.KeyEvent.dwControlKeyState&LEFT_CTRL_PRESSED?L'C':L'c'), (rec->Event.KeyEvent.dwControlKeyState&LEFT_ALT_PRESSED?L'A':L'a'), (rec->Event.KeyEvent.dwControlKeyState&SHIFT_PRESSED?L'S':L's'), (rec->Event.KeyEvent.dwControlKeyState&RIGHT_ALT_PRESSED?L'A':L'a'), (rec->Event.KeyEvent.dwControlKeyState&RIGHT_CTRL_PRESSED?L'C':L'c'), (rec->Event.KeyEvent.dwControlKeyState&ENHANCED_KEY?L'E':L'e'), (rec->Event.KeyEvent.dwControlKeyState&CAPSLOCK_ON?L'C':L'c'), (rec->Event.KeyEvent.dwControlKeyState&NUMLOCK_ON?L'N':L'n'), (rec->Event.KeyEvent.dwControlKeyState&SCROLLLOCK_ON?L'S':L's') ); break; } case MOUSE_EVENT: __MOUSE_EVENT_RECORD_Dump(&rec->Event.MouseEvent, pszRecord); break; default: wsprintfW(pszRecord, L"??????_EVENT_RECORD: EventType = %d", rec->EventType ); break; } wsprintfW(pszRecord+lstrlen(pszRecord), L" (%s)",IsFullscreen()?L"Fullscreen":L"Windowed"); }
/* * Initializes the OpenGL window */ static qboolean GLimp_InitGraphics(qboolean fullscreen) { int flags; int msaa_samples; int stencil_bits; int width, height; char title[24]; if (GetWindowSize(&width, &height) && (width == vid.width) && (height == vid.height)) { /* If we want fullscreen, but aren't */ if (fullscreen != IsFullscreen()) { GLimp_ToggleFullscreen(); } /* Are we now? */ if (fullscreen == IsFullscreen()) { return true; } } /* Is the surface used? */ if (window) { #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_GL_DeleteContext(context); SDL_DestroyWindow(window); #else SDL_FreeSurface(window); #endif } /* Create the window */ VID_NewWindow(vid.width, vid.height); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); if (gl_msaa_samples->value) { msaa_samples = gl_msaa_samples->value; if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1) == -1) { Com_Printf("MSAA is unsupported: %s\n", SDL_GetError()); Cvar_SetValue ("gl_msaa_samples", 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); } else if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa_samples) == -1) { Com_Printf("MSAA %ix is unsupported: %s\n", msaa_samples, SDL_GetError()); Cvar_SetValue("gl_msaa_samples", 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); } } /* Initiate the flags */ flags = SDL_OPENGL; if (fullscreen) { flags |= SDL_FULLSCREEN; } #if !SDL_VERSION_ATLEAST(2, 0, 0) /* For SDL1.2, these things must be done before creating the window */ /* Set the icon */ SetSDLIcon(); /* Set vsync */ SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, gl_swapinterval->value ? 1 : 0); #endif while (1) { if (!CreateSDLWindow(flags)) { if (gl_msaa_samples->value) { VID_Printf(PRINT_ALL, "SDL SetVideoMode failed: %s\n", SDL_GetError()); VID_Printf(PRINT_ALL, "Reverting to %s gl_mode %i (%ix%i) without MSAA.\n", (flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed", (int)Cvar_VariableValue("gl_mode"), vid.width, vid.height); /* Try to recover */ Cvar_SetValue("gl_msaa_samples", 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); } else if (vid.width != 640 || vid.height != 480 || (flags & SDL_FULLSCREEN)) { VID_Printf(PRINT_ALL, "SDL SetVideoMode failed: %s\n", SDL_GetError()); VID_Printf(PRINT_ALL, "Reverting to windowed gl_mode 4 (640x480).\n"); /* Try to recover */ Cvar_SetValue("gl_mode", 4); Cvar_SetValue("vid_fullscreen", 0); vid.width = 640; vid.height = 480; flags &= ~SDL_FULLSCREEN; } else { VID_Error(ERR_FATAL, "Failed to revert to gl_mode 4. Exiting...\n"); return false; } } else { break; } } #if SDL_VERSION_ATLEAST(2, 0, 0) /* For SDL2, these things must be done after creating the window */ /* Set the icon */ SetSDLIcon(); /* Set vsync - TODO: -1 could be set for "late swap tearing" */ SDL_GL_SetSwapInterval(gl_swapinterval->value ? 1 : 0); #endif /* Initialize the stencil buffer */ if (!SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits)) { VID_Printf(PRINT_ALL, "Got %d bits of stencil.\n", stencil_bits); if (stencil_bits >= 1) { have_stencil = true; } } /* Initialize hardware gamma */ InitGamma(); /* Window title */ snprintf(title, sizeof(title), "Yamagi Quake II %s", YQ2VERSION); #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_SetWindowTitle(window, title); #else SDL_WM_SetCaption(title, title); #endif /* No cursor */ SDL_ShowCursor(0); return true; }