Книга: DirectX 8 Programming Tutorial

Full Screen

Full Screen

To make our program full screen we need to make a few adjustments to our InitialiseD3D method. We need to change the "Windowed" property of our D3DPRESENT_PARAMETERS structure to FALSE, this specifies that the program will run full screen. Then, we need to set two full screen properties of the D3DPRESENT_PARAMETERS structure. FullScreen_RefreshRateInHz controls the refresh rate of the screen, and FullScreen_PresentationInterval controls the maximum rate that you swap chain (back buffer chain) are flipped. We have selected D3DPRESENT_INTERVAL_ONE which specifies that flipping will only occur when the monitor refreshes.

d3dpp.Windowed = FALSE;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;

Also, we need to select the correct back buffer format for our device. I have written a method, CheckDisplayMode, which will test for a valid format. This method is called in InitialiseD3D.

D3DFORMAT CGame::CheckDisplayMode(UINT nWidth, UINT nHeight, UINT nDepth) {
 UINT x;
 D3DDISPLAYMODE d3ddm;
 for (x = 0; x < m_pD3D->GetAdapterModeCount(0); x++) {
  m_pD3D->EnumAdapterModes(0, x, &d3ddm);
  if (d3ddm.Width == nWidth) {
   if (d3ddm.Height == nHeight) {
    if ((d3ddm.Format == D3DFMT_R5G6B5) || (d3ddm.Format == D3DFMT_X1R5G5B5) || (d3ddm.Format == D3DFMT_X4R4G4B4)) {
     if (nDepth == 16) {
      return d3ddm.Format;
     }
    } else if((d3ddm.Format == D3DFMT_R8G8B8) || (d3ddm.Format == D3DFMT_X8R8G8B8)) {
     if (nDepth == 32) {
      return d3ddm.Format;
     }
    }
   }
  }
 }
 return D3DFMT_UNKNOWN;
}

The only other thing we need to do is modify our WinMain function that created our window. We need to set the x and y positions of the window to be 0 (top left) and we need to change the width and height to the screen size using the GetSystemMetrics function.

Оглавление книги

Оглавление статьи/книги

Генерация: 0.064. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз