MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / Initialize

Method Initialize

SampleFramework11/v1.02/Graphics/PostProcessorBase.cpp:29–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29void PostProcessorBase::Initialize(ID3D11Device* device)
30{
31 this->device = device;
32
33 // Create resources for the full-screen quad
34
35 // Load the shaders
36 std::wstring quadPath = SampleFrameworkDir() + L"Shaders\\Quad.hlsl";
37 quadVS = CompileVSFromFile(device, quadPath.c_str(), "QuadVS");
38
39 // Create the input layout
40 D3D11_INPUT_ELEMENT_DESC layout[] =
41 {
42 { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
43 { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
44 };
45
46 DXCall(device->CreateInputLayout(layout, 2, quadVS->ByteCode->GetBufferPointer(),
47 quadVS->ByteCode->GetBufferSize(), &quadInputLayout));
48
49 // Create and initialize the vertex and index buffers
50 QuadVertex verts[4] =
51 {
52 { XMFLOAT4(1, 1, 1, 1), XMFLOAT2(1, 0) },
53 { XMFLOAT4(1, -1, 1, 1), XMFLOAT2(1, 1) },
54 { XMFLOAT4(-1, -1, 1, 1), XMFLOAT2(0, 1) },
55 { XMFLOAT4(-1, 1, 1, 1), XMFLOAT2(0, 0) }
56 };
57
58 D3D11_BUFFER_DESC desc;
59 desc.Usage = D3D11_USAGE_IMMUTABLE;
60 desc.ByteWidth = sizeof(verts);
61 desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
62 desc.CPUAccessFlags = 0;
63 desc.MiscFlags = 0;
64 D3D11_SUBRESOURCE_DATA initData;
65 initData.pSysMem = verts;
66 initData.SysMemPitch = 0;
67 initData.SysMemSlicePitch = 0;
68 DXCall(device->CreateBuffer(&desc, &initData, &quadVB));
69
70 unsigned short indices[6] = { 0, 1, 2, 2, 3, 0 };
71
72 desc.Usage = D3D11_USAGE_IMMUTABLE;
73 desc.ByteWidth = sizeof(indices);
74 desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
75 desc.CPUAccessFlags = 0;
76 initData.pSysMem = indices;
77 DXCall(device->CreateBuffer(&desc, &initData, &quadIB));
78
79 // Create the constant buffer
80 desc.Usage = D3D11_USAGE_DYNAMIC;
81 desc.ByteWidth = CBSize(sizeof(PSConstants));
82 desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
83 desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
84 DXCall(device->CreateBuffer(&desc, nullptr, &psConstants));
85
86 // Create a depth-stencil state

Callers

nothing calls this directly

Calls 6

SampleFrameworkDirFunction · 0.85
CompileVSFromFileFunction · 0.85
DXCallFunction · 0.85
CBSizeFunction · 0.85
GetBufferPointerMethod · 0.80
GetBufferSizeMethod · 0.80

Tested by

no test coverage detected