static void GenerateModesTable(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(modes_table)) { TXT_CAST_ARG(txt_table_t, modes_table); char buf[15]; screen_mode_t *modes; txt_radiobutton_t *rbutton; int i; // Pick which modes list to use if (fullscreen) { if (screen_modes_fullscreen == NULL) { BuildFullscreenModesList(); } modes = screen_modes_fullscreen; } else if (aspect_ratio_correct) { modes = screen_modes_scaled; } else { modes = screen_modes_unscaled; } // Build the table TXT_ClearTable(modes_table); TXT_SetColumnWidths(modes_table, 14, 14, 14, 14, 14); for (i=0; modes[i].w != 0; ++i) { // Skip bad fullscreen modes if (fullscreen && !GoodFullscreenMode(&modes[i])) { continue; } sprintf(buf, "%ix%i", modes[i].w, modes[i].h); rbutton = TXT_NewRadioButton(buf, &vidmode, i); TXT_AddWidget(modes_table, rbutton); TXT_SignalConnect(rbutton, "selected", ModeSelected, &modes[i]); } // Find the nearest mode in the list that matches the current // settings vidmode = FindBestMode(modes); if (vidmode > 0) { screen_width = modes[vidmode].w; screen_height = modes[vidmode].h; } }
bool CoreWin32Platform::CreateWin32Window(HINSTANCE hInstance) { this->hInstance = hInstance; //single instance check TCHAR fileName[MAX_PATH]; GetModuleFileName(NULL, fileName, MAX_PATH); fileName[MAX_PATH-1] = 0; //string can be not null-terminated on winXP for(int32 i = 0; i < MAX_PATH; ++i) { if(fileName[i] == L'\\') //symbol \ is not allowed in CreateMutex mutex name { fileName[i] = ' '; } } hMutex = CreateMutex(NULL, FALSE, fileName); if(ERROR_ALREADY_EXISTS == GetLastError()) { return false; } windowedMode = DisplayMode(800, 600, 16, 0); fullscreenMode = DisplayMode(800, 600, 16, 0); currentMode = windowedMode; isFullscreen = false; // create the window, only if we do not use the null device LPCWSTR className = L"DavaFrameworkWindowsDevice"; // Register Class WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = 0; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = 0; wcex.lpszClassName = className; wcex.hIconSm = 0; RegisterClassEx(&wcex); // calculate client size RECT clientSize; clientSize.top = 0; clientSize.left = 0; clientSize.right = currentMode.width; clientSize.bottom = currentMode.height; ULONG style = WINDOWED_STYLE | WS_CLIPCHILDREN; // Create the rendering window if (isFullscreen) { style = WS_VISIBLE | WS_POPUP; } // End if Fullscreen AdjustWindowRect(&clientSize, style, FALSE); int32 realWidth = clientSize.right - clientSize.left; int32 realHeight = clientSize.bottom - clientSize.top; int32 windowLeft = -10000;//(GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; int32 windowTop = -10000;//(GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; if (isFullscreen) { windowLeft = 0; windowTop = 0; } // create window hWindow = CreateWindow( className, L"", style, windowLeft, windowTop, realWidth, realHeight, NULL, NULL, hInstance, NULL); ShowWindow(hWindow, SW_SHOW); UpdateWindow(hWindow); // fix ugly ATI driver bugs. Thanks to ariaci (Taken from Irrlight). MoveWindow(hWindow, windowLeft, windowTop, realWidth, realHeight, TRUE); #if defined(__DAVAENGINE_DIRECTX9__) RenderManager::Create(Core::RENDERER_DIRECTX9); #elif defined(__DAVAENGINE_OPENGL__) RenderManager::Create(Core::RENDERER_OPENGL); #endif RenderManager::Instance()->Create(hInstance, hWindow); FrameworkDidLaunched(); KeyedArchive * options = Core::GetOptions(); //fullscreenMode = GetCurrentDisplayMode(); fullscreenMode = GetCurrentDisplayMode();//FindBestMode(fullscreenMode); if (options) { windowedMode.width = options->GetInt32("width"); windowedMode.height = options->GetInt32("height"); windowedMode.bpp = options->GetInt32("bpp"); // get values from config in case if they are available fullscreenMode.width = options->GetInt32("fullscreen.width", fullscreenMode.width); fullscreenMode.height = options->GetInt32("fullscreen.height", fullscreenMode.height); fullscreenMode.bpp = windowedMode.bpp; fullscreenMode = FindBestMode(fullscreenMode); isFullscreen = (0 != options->GetInt32("fullscreen")); String title = options->GetString("title", "[set application title using core options property 'title']"); WideString titleW = StringToWString(title); SetWindowText(hWindow, titleW.c_str()); } Logger::FrameworkDebug("[PlatformWin32] best display fullscreen mode matched: %d x %d x %d refreshRate: %d", fullscreenMode.width, fullscreenMode.height, fullscreenMode.bpp, fullscreenMode.refreshRate); currentMode = windowedMode; if (isFullscreen) { currentMode = fullscreenMode; } clientSize.top = 0; clientSize.left = 0; clientSize.right = currentMode.width; clientSize.bottom = currentMode.height; AdjustWindowRect(&clientSize, style, FALSE); realWidth = clientSize.right - clientSize.left; realHeight = clientSize.bottom - clientSize.top; windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2; windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2; MoveWindow(hWindow, windowLeft, windowTop, realWidth, realHeight, TRUE); RAWINPUTDEVICE Rid; Rid.usUsagePage = 0x01; Rid.usUsage = 0x02; Rid.dwFlags = 0; Rid.hwndTarget = 0; RegisterRawInputDevices(&Rid, 1, sizeof(Rid)); RenderManager::Instance()->ChangeDisplayMode(currentMode, isFullscreen); RenderManager::Instance()->Init(currentMode.width, currentMode.height); UIControlSystem::Instance()->SetInputScreenAreaSize(currentMode.width, currentMode.height); Core::Instance()->SetPhysicalScreenSize(currentMode.width, currentMode.height); return true; }