void CDDraw::InitFullscreen(HWND hWnd) { MoveWindow(hWnd, 0, 0, p->ResolutionX, p->ResolutionY, 1); FullScreen = 1; this->hWnd = hWnd; long hr; if ((hr = DirectDrawCreateEx(NULL, (void **)&DirectDraw, IID_IDirectDraw7, NULL)) != DD_OK) { MessageBox(NULL, "Error: DirectDrawCreateEX", "Error", 0); } if ((hr = DirectDraw->SetCooperativeLevel(hWnd, DDSCL_NORMAL)) != DD_OK) { MessageBox(NULL, "Error: SetCooperativeLevel", "Error", 0); } DDSURFACEDESC2 ddsd; if ((hr = DirectDraw->CreateClipper(NULL, &Clipper, NULL)) != DD_OK) { MessageBox(NULL, "Error: CreateClipper", "Error", 0); } if ((hr = DirectDraw->SetDisplayMode(p->ResolutionX, p->ResolutionY, 16, 0, 0)) != DD_OK) { MessageBox(NULL, "Error: SetDisplayMode", "Error", 0); } Clipper->SetHWnd(0, hWnd); memset (&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; if ((hr = DirectDraw->CreateSurface(&ddsd, &Primary, NULL)) != DD_OK) { MessageBox(NULL, "Error: CreateSurface", "Error", 0); } if ((hr = Primary->SetClipper(Clipper)) != DD_OK) { MessageBox(NULL, "Error: SetClipper", "Error", 0); } ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwWidth = p->ResolutionX; ddsd.dwHeight = p->ResolutionY; if ((hr = DirectDraw->CreateSurface(&ddsd, &Back, NULL)) != DD_OK) { MessageBox(NULL, "Error: CreateBackSurface", "Error", 0); } LoadSurfaces(); GetWindowRect(hWnd, &dest); }
void CBaseMenu::ScreenDimsChanged (int nScreenWidth, int nScreenHeight) { m_szScreen.cx = nScreenWidth; m_szScreen.cy = nScreenHeight; m_szMenuArea.cx = m_szScreen.cx - 10; m_szMenuArea.cy = m_szScreen.cy - 20; UnloadSurfaces(); LoadSurfaces(); // this should cause CalculateMenuDims() to be called... }
int Map_Load (const char *name) { int direxists; map_error = NULL; memset (&loadmap, 0, sizeof(loadmap)); if (Data_IsDir(name, &direxists) && direxists) { loaddir = name; Get = GetFromDir; } else { /* no directory with the map name; try a pak */ const char *ext = ".pak"; char path[2048]; if (strlen(name) > (sizeof(path) - strlen(ext) - 1)) return Error("map name too long"); strcpy (path, name); strcat (path, ext); if ((loadpak = Pak_Open(path)) == NULL) return Error("unable to open \"%s\"", path); Get = GetFromPak; } if (!LoadPlanes()) goto failed; if (!LoadVertices()) goto failed; if (!LoadEdges()) goto failed; if (!LoadEdgeLoops()) goto failed; if (!LoadSurfaces()) goto failed; if (!LoadPortals()) goto failed; if (!LoadNodes()) goto failed; if (!LoadLeafs()) goto failed; if (!LoadTextures()) goto failed; /* success; get rid of current map & switch over */ Map_Unload (); map = loadmap; memset (&loadmap, 0, sizeof(loadmap)); Get = NULL; loadpak = Pak_Close (loadpak); loaddir = NULL; return 1; failed: /* failure; keep the currently-loaded map running */ FreeMap (&loadmap); Get = NULL; loadpak = Pak_Close (loadpak); loaddir = NULL; return 0; }