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

Method Initialize

BakingLab/MeshRenderer.cpp:302–357  ·  view source on GitHub ↗

Loads resources

Source from the content-addressed store, hash-verified

300
301// Loads resources
302void MeshRenderer::Initialize(ID3D11Device* device, ID3D11DeviceContext* context, const Model* model)
303{
304 this->device = device;
305
306 blendStates.Initialize(device);
307 rasterizerStates.Initialize(device);
308 depthStencilStates.Initialize(device);
309 samplerStates.Initialize(device);
310
311 meshVSConstants.Initialize(device);
312 meshPSConstants.Initialize(device);
313 areaLightConstants.Initialize(device);
314 visualizerConstants.Initialize(device);
315 evsmConstants.Initialize(device);
316 reductionConstants.Initialize(device);
317
318 shSpecularLookupA = LoadTexture(device, L"..\\Content\\Textures\\SHSpecularA.dds");
319 shSpecularLookupB = LoadTexture(device, L"..\\Content\\Textures\\SHSpecularB.dds");
320
321 LoadShaders();
322
323 D3D11_RASTERIZER_DESC rsDesc = RasterizerStates::NoCullDesc();
324 rsDesc.DepthClipEnable = false;
325 DXCall(device->CreateRasterizerState(&rsDesc, &noZClipRSState));
326
327 D3D11_SAMPLER_DESC sampDesc = SamplerStates::AnisotropicDesc();
328 sampDesc.MaxAnisotropy = ShadowAnisotropy;
329 DXCall(device->CreateSamplerState(&sampDesc, &evsmSampler));
330
331 // Create the staging textures for reading back the reduced depth buffer
332 for(uint32 i = 0; i < ReadbackLatency; ++i)
333 reductionStagingTextures[i].Initialize(device, 1, 1, DXGI_FORMAT_R16G16_UNORM);
334
335 CreateShadowMaps();
336
337 GenerateHemisphere(16, 4, device, hemisphereVB, hemisphereIB, numHemisphereIndices);
338
339 GenerateSphere(256, 192, device, areaLightVB, areaLightIB, numAreaLightIndices);
340
341 D3D11_INPUT_ELEMENT_DESC elements[1];
342 elements[0].AlignedByteOffset = 0;
343 elements[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
344 elements[0].InputSlot = 0;
345 elements[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
346 elements[0].InstanceDataStepRate = 0;
347 elements[0].SemanticName = "POSITION";
348 elements[0].SemanticIndex = 0;
349
350 DXCall(device->CreateInputLayout(elements, 1, visualizerVS->ByteCode->GetBufferPointer(),
351 visualizerVS->ByteCode->GetBufferSize(), &visualizerInputLayout));
352
353 DXCall(device->CreateInputLayout(elements, 1, areaLightVS->ByteCode->GetBufferPointer(),
354 areaLightVS->ByteCode->GetBufferSize(), &areaLightInputLayout));
355
356 SetModel(model);
357}
358
359void MeshRenderer::SetModel(const Model* model)

Callers 2

CreateShadowMapsMethod · 0.45
OnResizeMethod · 0.45

Calls 6

LoadTextureFunction · 0.85
DXCallFunction · 0.85
GenerateHemisphereFunction · 0.85
GenerateSphereFunction · 0.85
GetBufferPointerMethod · 0.80
GetBufferSizeMethod · 0.80

Tested by

no test coverage detected