GteDXGIOutput.cpp
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #include <GTEnginePCH.h>
10 using namespace gte;
11 
12 
14 {
15  if (mOutput)
16  {
17  mOutput->Release();
18  }
19 }
20 
22  :
23  mOutput(nullptr)
24 {
25  *this = object;
26 }
27 
28 DXGIOutput::DXGIOutput(IDXGIOutput* output)
29  :
30  mOutput(output)
31 {
32  ZeroMemory(&mDescription, sizeof(DXGI_OUTPUT_DESC));
33  if (mOutput)
34  {
35  HRESULT hr = mOutput->GetDesc(&mDescription);
36  CHECK_HR_RETURN_NONE("Unexpected error");
37  }
38 }
39 
41 {
42  if (object.mOutput)
43  {
44  object.mOutput->AddRef();
45  }
46 
47  SafeRelease(mOutput);
48 
49  mOutput = object.mOutput;
50  mDescription = object.mDescription;
51  return *this;
52 }
53 
54 IDXGIOutput* DXGIOutput::GetOutput() const
55 {
56  return mOutput;
57 }
58 
59 DXGI_OUTPUT_DESC const& DXGIOutput::GetDescription() const
60 {
61  return mDescription;
62 }
63 
64 HRESULT DXGIOutput::GetDisplayModes(DXGI_FORMAT format,
65  std::vector<DXGI_MODE_DESC>& modeDescriptions)
66 {
67  modeDescriptions.clear();
68 
69  if (mOutput)
70  {
71  // The zero value for 'flags' says to return the maximum number of
72  // modes, regardless of the DXGI_ENUM_MODES possibilities for flags.
73  // We might want to allow for a different value for DX11.1 when
74  // stereo modes are available.
75  UINT const flags = 0;
76  UINT numModes = 0;
77  HRESULT hr = mOutput->GetDisplayModeList(format, flags, &numModes,
78  nullptr);
79  CHECK_HR_RETURN("Unexpected error", hr);
80 
81  if (numModes > 0)
82  {
83  modeDescriptions.resize(numModes);
84  hr = mOutput->GetDisplayModeList(format, flags, &numModes,
85  &modeDescriptions[0]);
86  CHECK_HR_RETURN("Unexpected error", hr);
87  return hr;
88  }
89 
90  // No modes available for the requested format. This is not an
91  // error condition. The caller must test that the array of
92  // descriptions has no elements and choose another format that
93  // might have modes associated with it.
94  return S_OK;
95  }
96 
97  LogError("Output not yet set.");
98  return DXGI_ERROR_INVALID_CALL;
99 }
100 
101 HRESULT DXGIOutput::FindClosestMatchingMode(DXGI_MODE_DESC const& requested,
102  DXGI_MODE_DESC& closest)
103 {
104  if (mOutput)
105  {
106  HRESULT hr = mOutput->FindClosestMatchingMode(&requested, &closest,
107  nullptr);
108  CHECK_HR_RETURN_NONE("Unexpected error");
109  return hr;
110  }
111 
112  LogError("Output not yet set.");
113  return DXGI_ERROR_INVALID_CALL;
114 }
115 
DXGI_OUTPUT_DESC const & GetDescription() const
IDXGIOutput * mOutput
Definition: GteDXGIOutput.h:45
DXGIOutput & operator=(DXGIOutput const &object)
#define CHECK_HR_RETURN_NONE(msg)
HRESULT FindClosestMatchingMode(DXGI_MODE_DESC const &requested, DXGI_MODE_DESC &closest)
IDXGIOutput * GetOutput() const
#define LogError(message)
Definition: GteLogger.h:92
GLbitfield flags
Definition: glcorearb.h:1591
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:103
ULONG SafeRelease(T *&object)
HRESULT GetDisplayModes(DXGI_FORMAT format, std::vector< DXGI_MODE_DESC > &modeDescriptions)
typedef UINT(WINAPI *PFNWGLGETGPUIDSAMDPROC)(UINT maxCount
#define CHECK_HR_RETURN(msg, value)
GLuint object
Definition: glext.h:6426
DXGIOutput(DXGIOutput const &object)
DXGI_OUTPUT_DESC mDescription
Definition: GteDXGIOutput.h:46


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59