============================================================// InitializeSurfaces() ============================================================//
| 72 | // InitializeSurfaces() |
| 73 | //============================================================// |
| 74 | bool beScreen::InitializeSurfaces() |
| 75 | { |
| 76 | HRESULT hRet; |
| 77 | DDSURFACEDESC2 ddsd; |
| 78 | DDSCAPS2 ddscaps; |
| 79 | LPDIRECTDRAWCLIPPER pClipper; |
| 80 | |
| 81 | if ( m_ScreenParams.m_Flags & BE_SCREENFLAGS_WINDOWED ) |
| 82 | { |
| 83 | // Get normal windowed mode |
| 84 | hRet = m_pDDraw->SetCooperativeLevel(m_ScreenParams.m_OwnerWnd, DDSCL_NORMAL); |
| 85 | if (hRet != DD_OK) |
| 86 | return false; |
| 87 | |
| 88 | // Get the dimensions of the viewport and screen bounds |
| 89 | GetClientRect(m_ScreenParams.m_OwnerWnd, &m_rcViewport); |
| 90 | GetClientRect(m_ScreenParams.m_OwnerWnd, &m_rcScreen); |
| 91 | ClientToScreen(m_ScreenParams.m_OwnerWnd, (POINT*)&m_rcScreen.left); |
| 92 | ClientToScreen(m_ScreenParams.m_OwnerWnd, (POINT*)&m_rcScreen.right); |
| 93 | |
| 94 | // Create the primary surface |
| 95 | ZeroMemory(&ddsd,sizeof(ddsd)); |
| 96 | ddsd.dwSize = sizeof(ddsd); |
| 97 | ddsd.dwFlags = DDSD_CAPS; |
| 98 | ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; |
| 99 | hRet = m_pDDraw->CreateSurface(&ddsd, &this->m_pddsPrimary, NULL); |
| 100 | if (hRet != DD_OK) |
| 101 | return false; |
| 102 | |
| 103 | // Create a clipper object since this is for a Windowed render |
| 104 | hRet = m_pDDraw->CreateClipper(0, &pClipper, NULL); |
| 105 | if (hRet != DD_OK) |
| 106 | return false; |
| 107 | |
| 108 | // Associate the clipper with the window |
| 109 | |
| 110 | pClipper->SetHWnd(0, m_ScreenParams.m_OwnerWnd); |
| 111 | m_pddsPrimary->SetClipper(pClipper); |
| 112 | pClipper->Release(); |
| 113 | pClipper = NULL; |
| 114 | |
| 115 | // Get the backbuffer. For fullscreen mode, the backbuffer was created |
| 116 | // along with the primary, but windowed mode still needs to create one. |
| 117 | ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS; |
| 118 | ddsd.dwWidth = m_ScreenParams.m_iScreenWidth; |
| 119 | ddsd.dwHeight = m_ScreenParams.m_iScreenHeight; |
| 120 | ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; |
| 121 | hRet = m_pDDraw->CreateSurface(&ddsd, &m_pddsBackBuffer, NULL); |
| 122 | if (hRet != DD_OK) |
| 123 | return false; |
| 124 | |
| 125 | // MessageBox(NULL,"AAAAAAAAH","ASH",MB_OK); |
| 126 | } else { |
| 127 | |
| 128 | // Get exclusive mode |
| 129 | hRet = m_pDDraw->SetCooperativeLevel(m_ScreenParams.m_OwnerWnd, DDSCL_EXCLUSIVE | |
| 130 | DDSCL_FULLSCREEN); |
| 131 | if (hRet != DD_OK) |
nothing calls this directly
no test coverage detected