HOOKFUNC LONG WINAPI MyChangeDisplaySettingsA(LPDEVMODEA lpDevMode, DWORD dwFlags) { if (lpDevMode) { ENTER(lpDevMode->dmPelsWidth, lpDevMode->dmPelsHeight, dwFlags); } else { ENTER(dwFlags); } if (tasflags.forceWindowed && lpDevMode /*&& (dwFlags & CDS_FULLSCREEN)*/) { fakeDisplayWidth = lpDevMode->dmPelsWidth; fakeDisplayHeight = lpDevMode->dmPelsHeight; fakePixelFormatBPP = lpDevMode->dmBitsPerPel; fakeDisplayValid = TRUE; FakeBroadcastDisplayChange(fakeDisplayWidth, fakeDisplayHeight, fakePixelFormatBPP); if (gamehwnd) MakeWindowWindowed(gamehwnd, fakeDisplayWidth, fakeDisplayHeight); return DISP_CHANGE_SUCCESSFUL; } LONG rv = ChangeDisplaySettingsA(lpDevMode, dwFlags); if (lpDevMode) FakeBroadcastDisplayChange(lpDevMode->dmPelsWidth, lpDevMode->dmPelsHeight, lpDevMode->dmBitsPerPel); return rv; }
static void RestoreVideoSettings() { sht::Application * app = sht::Application::GetInstance(); if (app->fullscreen()) { ChangeDisplaySettingsA(NULL, 0); } }
bool kinc_windows_set_display_mode(int display_index, int width, int height, int bpp, int frequency) { DisplayData *display = &displays[display_index]; display->mode_changed = true; DEVMODEA mode = {0}; mode.dmSize = sizeof(mode); strcpy((char*)mode.dmDeviceName, display->name); mode.dmPelsWidth = width; mode.dmPelsHeight = height; mode.dmBitsPerPel = bpp; mode.dmDisplayFrequency = frequency; mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; return ChangeDisplaySettingsA(&mode, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL; }
bool NativeApp::BindDisplayDevice(const ::DisplayDeviceRef &display, const r::VidMode &mode) { RAD_VERIFY(!m_activeDisplay); RAD_ASSERT(display); int screenWidth, screenHeight; if (mode.fullscreen) { DDVars *vars = DDVars::Get(display->m_imp.m_vars); DEVMODEA dm; memcpy(&dm, &vars->dm, sizeof(DEVMODEA)); dm.dmPelsWidth = mode.w; dm.dmPelsHeight = mode.h; if (mode.hz) { dm.dmFields |= DM_DISPLAYFREQUENCY; dm.dmDisplayFrequency = mode.hz; } if (ChangeDisplaySettingsA(&dm, 0) != DISP_CHANGE_SUCCESSFUL) { ChangeDisplaySettings(0, 0); return false; } screenWidth = mode.w; screenHeight = mode.h; } else { screenWidth = display->m_imp.m_defMode.w; screenHeight = display->m_imp.m_defMode.h; } #if !defined(RAD_OPT_PC_TOOLS) ConfigureWindow( mode.w, mode.h, mode.fullscreen, screenWidth, screenHeight ); ShowWindow(s_hWnd, SW_SHOW); UpdateWindow(s_hWnd); #endif display->m_imp.m_curMode = mode; m_activeDisplay = display; return true; }
bool MWindow::create(const char * title, unsigned int width, unsigned int height, int colorBits, bool fullscreen) { GLuint PixelFormat; WNDCLASSA wc; DWORD dwExStyle; DWORD dwStyle; RECT windowRect; windowRect.left = 0; windowRect.right = (long)width; windowRect.top = 0; windowRect.bottom = (long)height; m_hInstance = GetModuleHandle(NULL); // Grab An Instance For Our MWindow wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For MWindow. wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc Handles Messages wc.cbClsExtra = 0; // No Extra MWindow Data wc.cbWndExtra = 0; // No Extra MWindow Data wc.hInstance = m_hInstance; // Set The Instance wc.hIcon = LoadIcon(m_hInstance, MAKEINTRESOURCE(102));//IDI_WINLOGO); // Load The Default Icon wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer wc.hbrBackground = NULL; // No Background Required For GL wc.lpszMenuName = NULL; // We Don't Want A Menu wc.lpszClassName = "OpenGL"; // Set The Class Name if(! RegisterClassA(&wc)) { printf("MWindow : unable to create window class\n"); return false; } // configure fullscreen if(fullscreen) { DEVMODEA dmScreenSettings; // Device Mode memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure dmScreenSettings.dmPelsWidth = width; // Selected Screen Width dmScreenSettings.dmPelsHeight = height; // Selected Screen Height dmScreenSettings.dmBitsPerPel = colorBits; // Selected Bits Per Pixel dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; if(ChangeDisplaySettingsA(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { printf("MWindow : unable to configure fullscreen\n"); return false; } } // window style if(fullscreen) { dwExStyle = WS_EX_APPWINDOW; dwStyle = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; } else { dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; } // adjust window rect AdjustWindowRectEx(&windowRect, dwStyle, false, dwExStyle); // create window if(! (m_hWnd = CreateWindowExA( dwExStyle, // Extended Style For The MWindow "OpenGL", // Class Name title, // MWindow Title dwStyle, // MWindow Style 0, 0, // MWindow Position windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, // Selected Width And Height NULL, // Parent MWindow NULL, // Menu m_hInstance, // Instance NULL))) { printf("MWindow : unable to create window\n"); return false; } // pixel format description static PIXELFORMATDESCRIPTOR pfd= { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support MWindow PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format colorBits, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 16, // 16Bit Z-Buffer (Depth Buffer) 8, // Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; if(! (m_hDC = GetDC(m_hWnd))) { printf("MWindow : unable to create context device\n"); return false; } if(! (PixelFormat = ChoosePixelFormat(m_hDC, &pfd))) { printf("MWindow : unable to find pixel format\n"); return false; } if(! SetPixelFormat(m_hDC, PixelFormat, &pfd)) { printf("MWindow : unable to set pixel format\n"); return false; } if(! (m_hRC = wglCreateContext(m_hDC))) { printf("MWindow : unable to create opengl context\n"); return false; } if(! wglMakeCurrent(m_hDC,m_hRC)) { printf("MWindow : unable to set opengl current context\n"); return false; } ShowWindow(m_hWnd, SW_SHOW); SetForegroundWindow(m_hWnd); SetFocus(m_hWnd); strcpy(m_title, title); //SystemParametersInfo(SPI_GETWORKAREA,0,&DesktopArea,0); RECT rect; GetClientRect(m_hWnd, &rect); m_width = rect.right - rect.left; m_height = rect.bottom - rect.top; m_colorBits = colorBits; m_fullscreen = fullscreen; #ifdef M_HIDE_CONSOLE FreeConsole(); #endif return true; }
void kinc_windows_restore_display(int display) { if (displays[display].mode_changed) { ChangeDisplaySettingsA(&original_modes[display], 0); } }
/*********************************************************************** * ChangeDisplaySettings (USER.620) */ LONG WINAPI ChangeDisplaySettings16( LPDEVMODEA devmode, DWORD flags ) { TRACE_(system)("(%p,0x%08lx), stub\n",devmode,flags); return ChangeDisplaySettingsA(devmode, flags); }
bool Win32_ChangeDisplayMode (const Win32_DisplayMode *displayMode) { if (!displayMode) { return ::ChangeDisplaySettingsA (NULL, NULL) == DISP_CHANGE_SUCCESSFUL; } if (displayMode->width && displayMode->height) { if (displayMode->width != g_desktopDisplayMode.width || displayMode->height != g_desktopDisplayMode.height || displayMode->bpp != g_desktopDisplayMode.bpp) { DEVMODE mode; DEVMODE sel; int i = 0; memset(&sel, 0, sizeof(sel)); while ( ::EnumDisplaySettings(0, i++, &mode)) { if ( mode.dmPelsWidth == displayMode->width && mode.dmPelsHeight == displayMode->height) { if (mode.dmBitsPerPel < displayMode->bpp) { continue; } if (mode.dmDisplayFrequency >= sel.dmDisplayFrequency) { sel = mode; } if (mode.dmBitsPerPel > sel.dmBitsPerPel) { sel = mode; } } } if (sel.dmPelsWidth == 0) { return false; } sel.dmSize = sizeof(sel); sel.dmDriverExtra = 0; sel.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; if ( DISP_CHANGE_SUCCESSFUL != ChangeDisplaySettings(&sel, CDS_FULLSCREEN | CDS_SET_PRIMARY)) { sel.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; if ( DISP_CHANGE_SUCCESSFUL != ChangeDisplaySettingsA(&mode, CDS_FULLSCREEN | CDS_SET_PRIMARY)) { return false; } } } return true; } return false; }