Boolean CCEGLView::Create(int nWidthInPoints, int nHeightInPoints) { // record the window size in points m_tSizeInPoints.SetWidth(nWidthInPoints); m_tSizeInPoints.SetHeight(nHeightInPoints); // get the screen size TApplication* pApp = TApplication::GetCurrentApplication(); Int32 nWidth = pApp->GetScreenWidth(); Int32 nHeight = pApp->GetScreenHeight(); // calculate the factor and the rect of viewport m_fScreenScaleFactor = MIN((float)nWidth / nWidthInPoints, (float)nHeight / nHeightInPoints); int viewPortW = (int)(m_tSizeInPoints.Width() * m_fScreenScaleFactor); int viewPortH = (int)(m_tSizeInPoints.Height() * m_fScreenScaleFactor); m_rcViewPort.SetX((nWidth - viewPortW) / 2); m_rcViewPort.SetY((nHeight - viewPortH) / 2); m_rcViewPort.SetWidth(viewPortW); m_rcViewPort.SetHeight(viewPortH); Boolean bRet = TWindow::Create(&TRectangle(0, 0, nWidth, nHeight)); if (bRet) { s_pMainWindow = this; } return bRet; }
void TMaze::Show() // Shows everything { Viewport.Set(); Viewer.Sort(); Viewer.Show(); g_Screen.Set(); TRectangle( TPixel(Viewport.ScreenLeft(), Viewport.ScreenTop()), TPixel(Viewport.ScreenRight(), Viewport.ScreenBottom()) ).Draw(BLACK, BLACK, WHITE, WHITE); }