MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / SetFullscreen

Method SetFullscreen

GTE/Graphics/DX11/DX11Engine.cpp:224–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224bool 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
279void DX11Engine::ExitFullscreen()
280{

Callers

nothing calls this directly

Calls 3

GetDescriptionMethod · 0.80
endMethod · 0.80
GetOutputMethod · 0.80

Tested by

no test coverage detected