| 222 | } |
| 223 | |
| 224 | bool DX11Engine::SetFullscreen(DXGIOutput const& output, bool fullscreen) |
| 225 | { |
| 226 | if (mSwapChain) |
| 227 | { |
| 228 | auto const& desc = output.GetDescription(); |
| 229 | std::wstring name(desc.DeviceName); |
| 230 | auto iter = mFullscreenState.find(name); |
| 231 | if (iter == mFullscreenState.end()) |
| 232 | { |
| 233 | // This is the first time 'output' has been seen, so insert it |
| 234 | // into the map indicating that the window is not fullscreen. |
| 235 | iter = mFullscreenState.insert(std::make_pair(name, false)).first; |
| 236 | } |
| 237 | |
| 238 | if (iter->second != fullscreen) |
| 239 | { |
| 240 | HRESULT hr; |
| 241 | if (fullscreen) |
| 242 | { |
| 243 | hr = mSwapChain->SetFullscreenState(TRUE, output.GetOutput()); |
| 244 | if (SUCCEEDED(hr)) |
| 245 | { |
| 246 | iter->second = true; |
| 247 | return true; |
| 248 | } |
| 249 | else |
| 250 | { |
| 251 | LogError("Failed to go fullscreen."); |
| 252 | } |
| 253 | } |
| 254 | else |
| 255 | { |
| 256 | hr = mSwapChain->SetFullscreenState(FALSE, nullptr); |
| 257 | if (SUCCEEDED(hr)) |
| 258 | { |
| 259 | iter->second = false; |
| 260 | return true; |
| 261 | } |
| 262 | else |
| 263 | { |
| 264 | LogError("Failed to go windowed."); |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | else |
| 269 | { |
| 270 | // The requested state is the current state, so there is |
| 271 | // nothing to do. |
| 272 | return false; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | LogError("This function requires a swap chain."); |
| 277 | } |
| 278 | |
| 279 | void DX11Engine::ExitFullscreen() |
| 280 | { |
nothing calls this directly
no test coverage detected