forked from GameTechDev/OutdoorLightScattering
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTexture.cpp
More file actions
83 lines (71 loc) · 3.94 KB
/
Texture.cpp
File metadata and controls
83 lines (71 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "Texture.h"
#include "stdafx.h"
HRESULT CreateTexture(CComPtr<ID3D11ShaderResourceView> &SRV, CComPtr<ID3D11RenderTargetView> &RTV, ID3D11Device* pd3dDevice, UINT Width, UINT Height, DXGI_FORMAT Format)
{
D3D11_TEXTURE2D_DESC CoordinateTexDesc =
{
Width, //UINT Width;
Height, //UINT Height;
1, //UINT MipLevels;
1, //UINT ArraySize;
Format, //DXGI_FORMAT Format;
{1,0}, //DXGI_SAMPLE_DESC SampleDesc;
D3D11_USAGE_DEFAULT, //D3D11_USAGE Usage;
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET, //UINT BindFlags;
0, //UINT MiscFlags;
};
SRV.Release();
RTV.Release();
HRESULT hr;
CComPtr<ID3D11Texture2D> tex;
V_RETURN(pd3dDevice->CreateTexture2D(&CoordinateTexDesc, NULL, &tex));
V_RETURN(pd3dDevice->CreateShaderResourceView(tex, NULL, &SRV));
V_RETURN(pd3dDevice->CreateRenderTargetView(tex, NULL, &RTV));
return S_OK;
}
HRESULT CreateTexture(CComPtr<ID3D11ShaderResourceView> &SRV, CComPtr<ID3D11UnorderedAccessView> &UAV, ID3D11Device* pd3dDevice, UINT Width, UINT Height, DXGI_FORMAT Format)
{
D3D11_TEXTURE2D_DESC CoordinateTexDesc =
{
Width, //UINT Width;
Height, //UINT Height;
1, //UINT MipLevels;
1, //UINT ArraySize;
Format, //DXGI_FORMAT Format;
{1,0}, //DXGI_SAMPLE_DESC SampleDesc;
D3D11_USAGE_DEFAULT, //D3D11_USAGE Usage;
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS, //UINT BindFlags;
0, //UINT CPUAccessFlags;
0, //UINT MiscFlags;
};
SRV.Release();
UAV.Release();
HRESULT hr;
CComPtr<ID3D11Texture2D> tex;
V_RETURN(pd3dDevice->CreateTexture2D(&CoordinateTexDesc, NULL, &tex));
V_RETURN(pd3dDevice->CreateShaderResourceView(tex, NULL, &SRV));
V_RETURN(pd3dDevice->CreateUnorderedAccessView(tex, NULL, &UAV));
return S_OK;
}
HRESULT CreateTexture(CComPtr<ID3D11DepthStencilView> &DSV, ID3D11Device* pd3dDevice, UINT Width, UINT Height, DXGI_FORMAT Format)
{
D3D11_TEXTURE2D_DESC CoordinateTexDesc =
{
Width, //UINT Width;
Height, //UINT Height;
1, //UINT MipLevels;
1, //UINT ArraySize;
Format, //DXGI_FORMAT Format;
{1,0}, //DXGI_SAMPLE_DESC SampleDesc;
D3D11_USAGE_DEFAULT, //D3D11_USAGE Usage;
D3D11_BIND_DEPTH_STENCIL, //UINT BindFlags;
0, //UINT CPUAccessFlags;
0, //UINT MiscFlags;
};
DSV.Release();
HRESULT hr;
CComPtr<ID3D11Texture2D> tex;
V_RETURN(pd3dDevice->CreateTexture2D(&CoordinateTexDesc, NULL, &tex));
V_RETURN(pd3dDevice->CreateDepthStencilView(tex, NULL, &DSV));
return S_OK;
}