Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
hw3d
Commits
d5ba4169
Commit
d5ba4169
authored
Jan 20, 2019
by
chili
Browse files
wrl comptr ftw
parent
d9d02261
Changes
5
Show whitespace changes
Inline
Side-by-side
hw3d/DxgiInfoManager.cpp
View file @
d5ba4169
...
...
@@ -30,15 +30,7 @@ DxgiInfoManager::DxgiInfoManager()
}
HRESULT
hr
;
GFX_THROW_NOINFO
(
DxgiGetDebugInterface
(
__uuidof
(
IDXGIInfoQueue
),
reinterpret_cast
<
void
**>
(
&
pDxgiInfoQueue
)
)
);
}
DxgiInfoManager
::~
DxgiInfoManager
()
{
if
(
pDxgiInfoQueue
!=
nullptr
)
{
pDxgiInfoQueue
->
Release
();
}
GFX_THROW_NOINFO
(
DxgiGetDebugInterface
(
__uuidof
(
IDXGIInfoQueue
),
&
pDxgiInfoQueue
)
);
}
void
DxgiInfoManager
::
Set
()
noexcept
...
...
hw3d/DxgiInfoManager.h
View file @
d5ba4169
#pragma once
#include "ChiliWin.h"
#include <wrl.h>
#include <vector>
#include <dxgidebug.h>
class
DxgiInfoManager
{
public:
DxgiInfoManager
();
~
DxgiInfoManager
();
~
DxgiInfoManager
()
=
default
;
DxgiInfoManager
(
const
DxgiInfoManager
&
)
=
delete
;
DxgiInfoManager
&
operator
=
(
const
DxgiInfoManager
&
)
=
delete
;
void
Set
()
noexcept
;
std
::
vector
<
std
::
string
>
GetMessages
()
const
;
private:
unsigned
long
long
next
=
0u
;
struct
IDXGIInfoQueue
*
pDxgiInfoQueue
=
nullptr
;
Microsoft
::
WRL
::
ComPtr
<
IDXGIInfoQueue
>
pDxgiInfoQueue
;
};
\ No newline at end of file
hw3d/Graphics.cpp
View file @
d5ba4169
...
...
@@ -2,6 +2,8 @@
#include "dxerr.h"
#include <sstream>
namespace
wrl
=
Microsoft
::
WRL
;
#pragma comment(lib,"d3d11.lib")
// graphics exception checking/throwing macros (some with dxgi infos)
...
...
@@ -62,30 +64,9 @@ Graphics::Graphics( HWND hWnd )
&
pContext
)
);
// gain access to texture subresource in swap chain (back buffer)
ID3D11Resource
*
pBackBuffer
=
nullptr
;
GFX_THROW_INFO
(
pSwap
->
GetBuffer
(
0
,
__uuidof
(
ID3D11Resource
),
reinterpret_cast
<
void
**>
(
&
pBackBuffer
)
)
);
GFX_THROW_INFO
(
pDevice
->
CreateRenderTargetView
(
pBackBuffer
,
nullptr
,
&
pTarget
)
);
pBackBuffer
->
Release
();
}
Graphics
::~
Graphics
()
{
if
(
pTarget
!=
nullptr
)
{
pTarget
->
Release
();
}
if
(
pContext
!=
nullptr
)
{
pContext
->
Release
();
}
if
(
pSwap
!=
nullptr
)
{
pSwap
->
Release
();
}
if
(
pDevice
!=
nullptr
)
{
pDevice
->
Release
();
}
wrl
::
ComPtr
<
ID3D11Resource
>
pBackBuffer
;
GFX_THROW_INFO
(
pSwap
->
GetBuffer
(
0
,
__uuidof
(
ID3D11Resource
),
&
pBackBuffer
)
);
GFX_THROW_INFO
(
pDevice
->
CreateRenderTargetView
(
pBackBuffer
.
Get
(),
nullptr
,
&
pTarget
)
);
}
void
Graphics
::
EndFrame
()
...
...
@@ -110,7 +91,7 @@ void Graphics::EndFrame()
void
Graphics
::
ClearBuffer
(
float
red
,
float
green
,
float
blue
)
noexcept
{
const
float
color
[]
=
{
red
,
green
,
blue
,
1.0
f
};
pContext
->
ClearRenderTargetView
(
pTarget
,
color
);
pContext
->
ClearRenderTargetView
(
pTarget
.
Get
()
,
color
);
}
...
...
hw3d/Graphics.h
View file @
d5ba4169
...
...
@@ -2,6 +2,7 @@
#include "ChiliWin.h"
#include "ChiliException.h"
#include <d3d11.h>
#include <wrl.h>
#include <vector>
#include "DxgiInfoManager.h"
...
...
@@ -38,15 +39,15 @@ public:
Graphics
(
HWND
hWnd
);
Graphics
(
const
Graphics
&
)
=
delete
;
Graphics
&
operator
=
(
const
Graphics
&
)
=
delete
;
~
Graphics
();
~
Graphics
()
=
default
;
void
EndFrame
();
void
ClearBuffer
(
float
red
,
float
green
,
float
blue
)
noexcept
;
private:
#ifndef NDEBUG
DxgiInfoManager
infoManager
;
#endif
ID3D11Device
*
pDevice
=
nullptr
;
IDXGISwapChain
*
pSwap
=
nullptr
;
ID3D11DeviceContext
*
pContext
=
nullptr
;
ID3D11RenderTargetView
*
pTarget
=
nullptr
;
Microsoft
::
WRL
::
ComPtr
<
ID3D11Device
>
pDevice
;
Microsoft
::
WRL
::
ComPtr
<
IDXGISwapChain
>
pSwap
;
Microsoft
::
WRL
::
ComPtr
<
ID3D11DeviceContext
>
pContext
;
Microsoft
::
WRL
::
ComPtr
<
ID3D11RenderTargetView
>
pTarget
;
};
\ No newline at end of file
hw3d/hw3d.vcxproj
View file @
d5ba4169
...
...
@@ -22,7 +22,7 @@
<VCProjectVersion>
15.0
</VCProjectVersion>
<ProjectGuid>
{63E56790-0977-47CC-B52B-B1BF8746AFD4}
</ProjectGuid>
<RootNamespace>
hw3d
</RootNamespace>
<WindowsTargetPlatformVersion>
10.0.17
134
.0
</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>
10.0.17
763
.0
</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.Default.props"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"Configuration"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment