/*!*********************************************************************** @Function OsInitOS @description Saves instance handle and creates main window In this function, we save the instance handle in a global variable and create and display the main program window. *************************************************************************/ bool PVRShellInit::OsInitOS() { m_X11Display = XOpenDisplay( NULL ); if(!m_X11Display) { m_pShell->PVRShellOutputDebug( "Unable to open X display\n"); return false; } m_X11Screen = XDefaultScreen( m_X11Display ); /* If there is a full screen request then set the window size to the display size. If there is no full screen request then reduce window size while keeping the same aspect by dividing the dims by two until it fits inside the display area. If the position has not changed from its default value, set it to the middle of the screen. */ int display_width = XDisplayWidth(m_X11Display,m_X11Screen); int display_height = XDisplayHeight(m_X11Display,m_X11Screen); if(m_pShell->m_pShellData->bFullScreen) { // For OGL we do real fullscreen for others API set a window of fullscreen size if(m_pShell->m_pShellData->nShellDimX < 0) { m_pShell->m_pShellData->nShellDimX = display_width; } if(m_pShell->m_pShellData->nShellDimY < 0) { m_pShell->m_pShellData->nShellDimY = display_height; } } else { if(m_pShell->m_pShellData->nShellDimX < 0) m_pShell->m_pShellData->nShellDimX = (display_width > display_height) ? 800 : 600; if(m_pShell->m_pShellData->nShellDimY < 0) m_pShell->m_pShellData->nShellDimY = (display_width > display_height) ? 600 : 800; if(m_pShell->m_pShellData->nShellDimX > display_width) m_pShell->m_pShellData->nShellDimX = display_width; if(m_pShell->m_pShellData->nShellDimY > display_height) m_pShell->m_pShellData->nShellDimY = display_height; } // Create the window if(!OpenX11Window(*m_pShell)) { m_pShell->PVRShellOutputDebug( "Unable to open X11 window\n" ); return false; } // Pixmap support: create the pixmap if(m_pShell->m_pShellData->bNeedPixmap) { int depth = DefaultDepth(m_X11Display, m_X11Screen); m_X11Pixmap = XCreatePixmap(m_X11Display,m_X11Window,m_pShell->m_pShellData->nShellDimX,m_pShell->m_pShellData->nShellDimY,depth); m_X11GC = XCreateGC(m_X11Display,m_X11Window,0,0); } return true; }
/*!*********************************************************************** @Function OsInitOS @description Saves instance handle and creates main window In this function, we save the instance handle in a global variable and create and display the main program window. *************************************************************************/ bool PVRShellInit::OsInitOS() { // Initialize global strings szTitle = "PVRShell"; x11display = XOpenDisplay( NULL ); if( !x11display ) { m_pShell->PVRShellOutputDebug( "Unable to open X display" ); return false; } x11screen = XDefaultScreen( x11display ); /* If there is a full screen request then set the window size to the display size if there is no fullscreen then reduce window size keeping the same aspect divide dims by to as long as they do not fit into display area If Position is not default one the it is kept , otherwise it is set into the middle of the screen */ int display_width = XDisplayWidth(x11display,x11screen); int display_height = XDisplayHeight(x11display,x11screen); // If user hadn't modified the default values the we adjust them to the screen // if he hadn't modified them then we will determine based on screen aspect // which are default and fit them into screen if(m_pShell->m_pShellData->nShellDimX < 0) { if(display_width > display_height) { m_pShell->m_pShellData->nShellDimX = 640; m_pShell->m_pShellData->nShellDimY = 480; } else { m_pShell->m_pShellData->nShellDimX = 240; m_pShell->m_pShellData->nShellDimY = 320; } } if(m_pShell->m_pShellData->bFullScreen) { // For OGL we do real fullscreen for others API set a window of fullscreen size #ifndef BUILD_OGL m_pShell->m_pShellData->nShellDimX = XDisplayWidth(x11display,x11screen); m_pShell->m_pShellData->nShellDimY = XDisplayHeight(x11display,x11screen); #endif } else { while(m_pShell->m_pShellData->nShellDimX > display_width) (m_pShell->m_pShellData->nShellDimX)>>=1; while(m_pShell->m_pShellData->nShellDimY > display_height) (m_pShell->m_pShellData->nShellDimY)>>=1; // adjust position if not specified otherways if(m_pShell->m_pShellData->bShellPosWasDefault) { m_pShell->m_pShellData->nShellPosX += m_pShell->m_pShellData->nShellDimX/2; m_pShell->m_pShellData->nShellPosY += m_pShell->m_pShellData->nShellDimY/2; } } // Create the window if( !OpenX11Window(*m_pShell)) { m_pShell->PVRShellOutputDebug( "Unable to open X11 window" ); return false; } // Pixmap support: create the pixmap if(m_pShell->m_pShellData->bNeedPixmap) { int depth = DefaultDepth(x11display, x11screen); x11pixmap = XCreatePixmap(x11display,x11window,m_pShell->m_pShellData->nShellDimX,m_pShell->m_pShellData->nShellDimY,depth); x11gc = XCreateGC(x11display,x11window,0,0); } return true; }