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
2467d634
Commit
2467d634
authored
Feb 19, 2019
by
chili
Browse files
throw macros organized into headers
parent
d0b34378
Changes
8
Show whitespace changes
Inline
Side-by-side
hw3d/DxgiInfoManager.cpp
View file @
2467d634
...
@@ -3,10 +3,11 @@
...
@@ -3,10 +3,11 @@
#include "Graphics.h"
#include "Graphics.h"
#include <dxgidebug.h>
#include <dxgidebug.h>
#include <memory>
#include <memory>
#include "GraphicsThrowMacros.h"
#include "WindowsThrowMacros.h"
#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "dxguid.lib")
#define GFX_THROW_NOINFO(hrcall) if( FAILED( hr = (hrcall) ) ) throw Graphics::HrException( __LINE__,__FILE__,hr )
DxgiInfoManager
::
DxgiInfoManager
()
DxgiInfoManager
::
DxgiInfoManager
()
{
{
...
...
hw3d/Graphics.cpp
View file @
2467d634
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include <d3dcompiler.h>
#include <d3dcompiler.h>
#include <cmath>
#include <cmath>
#include <DirectXMath.h>
#include <DirectXMath.h>
#include "GraphicsThrowMacros.h"
namespace
wrl
=
Microsoft
::
WRL
;
namespace
wrl
=
Microsoft
::
WRL
;
namespace
dx
=
DirectX
;
namespace
dx
=
DirectX
;
...
@@ -11,22 +12,6 @@ namespace dx = DirectX;
...
@@ -11,22 +12,6 @@ namespace dx = DirectX;
#pragma comment(lib,"d3d11.lib")
#pragma comment(lib,"d3d11.lib")
#pragma comment(lib,"D3DCompiler.lib")
#pragma comment(lib,"D3DCompiler.lib")
// graphics exception checking/throwing macros (some with dxgi infos)
#define GFX_EXCEPT_NOINFO(hr) Graphics::HrException( __LINE__,__FILE__,(hr) )
#define GFX_THROW_NOINFO(hrcall) if( FAILED( hr = (hrcall) ) ) throw Graphics::HrException( __LINE__,__FILE__,hr )
#ifndef NDEBUG
#define GFX_EXCEPT(hr) Graphics::HrException( __LINE__,__FILE__,(hr),infoManager.GetMessages() )
#define GFX_THROW_INFO(hrcall) infoManager.Set(); if( FAILED( hr = (hrcall) ) ) throw GFX_EXCEPT(hr)
#define GFX_DEVICE_REMOVED_EXCEPT(hr) Graphics::DeviceRemovedException( __LINE__,__FILE__,(hr),infoManager.GetMessages() )
#define GFX_THROW_INFO_ONLY(call) infoManager.Set(); (call); {auto v = infoManager.GetMessages(); if(!v.empty()) {throw Graphics::InfoException( __LINE__,__FILE__,v);}}
#else
#define GFX_EXCEPT(hr) Graphics::HrException( __LINE__,__FILE__,(hr) )
#define GFX_THROW_INFO(hrcall) GFX_THROW_NOINFO(hrcall)
#define GFX_DEVICE_REMOVED_EXCEPT(hr) Graphics::DeviceRemovedException( __LINE__,__FILE__,(hr) )
#define GFX_THROW_INFO_ONLY(call) (call)
#endif
Graphics
::
Graphics
(
HWND
hWnd
)
Graphics
::
Graphics
(
HWND
hWnd
)
{
{
...
...
hw3d/GraphicsThrowMacros.h
0 → 100644
View file @
2467d634
#pragma once
// HRESULT hr should exist in the local scope for these macros to work
#define GFX_EXCEPT_NOINFO(hr) Graphics::HrException( __LINE__,__FILE__,(hr) )
#define GFX_THROW_NOINFO(hrcall) if( FAILED( hr = (hrcall) ) ) throw Graphics::HrException( __LINE__,__FILE__,hr )
#ifndef NDEBUG
#define GFX_EXCEPT(hr) Graphics::HrException( __LINE__,__FILE__,(hr),infoManager.GetMessages() )
#define GFX_THROW_INFO(hrcall) infoManager.Set(); if( FAILED( hr = (hrcall) ) ) throw GFX_EXCEPT(hr)
#define GFX_DEVICE_REMOVED_EXCEPT(hr) Graphics::DeviceRemovedException( __LINE__,__FILE__,(hr),infoManager.GetMessages() )
#define GFX_THROW_INFO_ONLY(call) infoManager.Set(); (call); {auto v = infoManager.GetMessages(); if(!v.empty()) {throw Graphics::InfoException( __LINE__,__FILE__,v);}}
#else
#define GFX_EXCEPT(hr) Graphics::HrException( __LINE__,__FILE__,(hr) )
#define GFX_THROW_INFO(hrcall) GFX_THROW_NOINFO(hrcall)
#define GFX_DEVICE_REMOVED_EXCEPT(hr) Graphics::DeviceRemovedException( __LINE__,__FILE__,(hr) )
#define GFX_THROW_INFO_ONLY(call) (call)
#endif
// macro for importing infomanager into local scope
// this.GetInfoManager() must exist
#ifdef NDEBUG
#define INFOMAN() HRESULT hr
#else
#define INFOMAN() HRESULT hr; DxgiInfoManager& infoManager = GetInfoManager()
#endif
hw3d/Window.cpp
View file @
2467d634
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include "Window.h"
#include "Window.h"
#include <sstream>
#include <sstream>
#include "resource.h"
#include "resource.h"
#include "WindowsThrowMacros.h"
// Window Class Stuff
// Window Class Stuff
...
@@ -238,7 +239,6 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
...
@@ -238,7 +239,6 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
{
{
const
POINTS
pt
=
MAKEPOINTS
(
lParam
);
const
POINTS
pt
=
MAKEPOINTS
(
lParam
);
mouse
.
OnLeftPressed
(
pt
.
x
,
pt
.
y
);
mouse
.
OnLeftPressed
(
pt
.
x
,
pt
.
y
);
// bring window to foreground on lclick client region
SetForegroundWindow
(
hWnd
);
SetForegroundWindow
(
hWnd
);
break
;
break
;
}
}
...
...
hw3d/Window.h
View file @
2467d634
...
@@ -90,9 +90,3 @@ private:
...
@@ -90,9 +90,3 @@ private:
HWND
hWnd
;
HWND
hWnd
;
std
::
unique_ptr
<
Graphics
>
pGfx
;
std
::
unique_ptr
<
Graphics
>
pGfx
;
};
};
// error exception helper macro
#define CHWND_EXCEPT( hr ) Window::HrException( __LINE__,__FILE__,(hr) )
#define CHWND_LAST_EXCEPT() Window::HrException( __LINE__,__FILE__,GetLastError() )
#define CHWND_NOGFX_EXCEPT() Window::NoGfxException( __LINE__,__FILE__ )
\ No newline at end of file
hw3d/WindowsThrowMacros.h
0 → 100644
View file @
2467d634
#pragma once
#define CHWND_EXCEPT( hr ) Window::HrException( __LINE__,__FILE__,(hr) )
#define CHWND_LAST_EXCEPT() Window::HrException( __LINE__,__FILE__,GetLastError() )
#define CHWND_NOGFX_EXCEPT() Window::NoGfxException( __LINE__,__FILE__ )
hw3d/hw3d.vcxproj
View file @
2467d634
...
@@ -165,11 +165,13 @@
...
@@ -165,11 +165,13 @@
<ClInclude
Include=
"dxerr.h"
/>
<ClInclude
Include=
"dxerr.h"
/>
<ClInclude
Include=
"DxgiInfoManager.h"
/>
<ClInclude
Include=
"DxgiInfoManager.h"
/>
<ClInclude
Include=
"Graphics.h"
/>
<ClInclude
Include=
"Graphics.h"
/>
<ClInclude
Include=
"GraphicsThrowMacros.h"
/>
<ClInclude
Include=
"Keyboard.h"
/>
<ClInclude
Include=
"Keyboard.h"
/>
<ClInclude
Include=
"Mouse.h"
/>
<ClInclude
Include=
"Mouse.h"
/>
<ClInclude
Include=
"resource.h"
/>
<ClInclude
Include=
"resource.h"
/>
<ClInclude
Include=
"Window.h"
/>
<ClInclude
Include=
"Window.h"
/>
<ClInclude
Include=
"WindowsMessageMap.h"
/>
<ClInclude
Include=
"WindowsMessageMap.h"
/>
<ClInclude
Include=
"WindowsThrowMacros.h"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<ResourceCompile
Include=
"hw3d.rc"
/>
<ResourceCompile
Include=
"hw3d.rc"
/>
...
...
hw3d/hw3d.vcxproj.filters
View file @
2467d634
...
@@ -19,6 +19,9 @@
...
@@ -19,6 +19,9 @@
<Filter
Include=
"Shader"
>
<Filter
Include=
"Shader"
>
<UniqueIdentifier>
{246c933d-909b-4e52-ace4-7be4ab3da27b}
</UniqueIdentifier>
<UniqueIdentifier>
{246c933d-909b-4e52-ace4-7be4ab3da27b}
</UniqueIdentifier>
</Filter>
</Filter>
<Filter
Include=
"Header Files\Macros"
>
<UniqueIdentifier>
{3d927852-8462-4d02-ae2f-01365b05ae28}
</UniqueIdentifier>
</Filter>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<ClCompile
Include=
"WinMain.cpp"
>
<ClCompile
Include=
"WinMain.cpp"
>
...
@@ -92,6 +95,12 @@
...
@@ -92,6 +95,12 @@
<ClInclude
Include=
"DxgiInfoManager.h"
>
<ClInclude
Include=
"DxgiInfoManager.h"
>
<Filter>
Header Files
</Filter>
<Filter>
Header Files
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"GraphicsThrowMacros.h"
>
<Filter>
Header Files\Macros
</Filter>
</ClInclude>
<ClInclude
Include=
"WindowsThrowMacros.h"
>
<Filter>
Header Files\Macros
</Filter>
</ClInclude>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<ResourceCompile
Include=
"hw3d.rc"
>
<ResourceCompile
Include=
"hw3d.rc"
>
...
...
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